-
-
diff --git a/Master/texmf-dist/tex/context/base/mkiv/context-performance.tex b/Master/texmf-dist/tex/context/base/mkiv/context-performance.tex
index dd376866496..8b6ef11b2f6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/context-performance.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/context-performance.tex
@@ -1,5 +1,3 @@
-% language=uk
-
\usemodule[art-01,abr-01]
\starttext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/context.lus b/Master/texmf-dist/tex/context/base/mkiv/context.lus
deleted file mode 100644
index 960e96adf7c..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/context.lus
+++ /dev/null
@@ -1,71 +0,0 @@
-if not modules then modules = { } end modules ['context'] = {
- version = 1.001,
- comment = "companion to context.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
---[[
This table specifies what stub files are needed in order to create
-the format. These files are loaded before the format is made so that we
-bypass kpse. When the format itself is used, another stub is used (with
-suffix lui). The current format builder is to a large part determined by
-the way luatex evolved and the process will probaby change.
]]--
-
-local method = 3
-
-local stubfiles = {
-
- 'luat-cod.lua',
-
- -- Here follows a list of trac, luat and data files, but we don't
- -- it this way any more so there is no need to keep this updated.
-
-}
-
--- This method will trigger the creation of a stub file with all neccessary
--- libraries merged. This is how we originally did it.
-
-if method == 1 then
-
- return stubfiles
-
-end
-
--- This method will use this file as stub file so no merge is needed.
-
-if method == 2 then
-
- if resolvers then
- -- we're loading this file in mtxrun
- else
-
- local sourcepath = string.gsub(arg and arg[1] or "","/[^/]+$","")
- local targetpath = "."
-
- if sourcepath == "" then sourcepath = targetpath end
-
- for i=1,#stubfiles do
- local filename = sourcepath .. "/" .. stubfiles[i]
- texio.write_nl("preloading " .. filename)
- dofile(filename)
- end
- texio.write_nl("\n")
-
- end
-
- return "context.lus"
-
-end
-
--- Only a simple stub:
-
-if method == 3 then
-
- return "luat-cod.lua"
-
-end
-
--- The last resort.
-
-return stubfiles
diff --git a/Master/texmf-dist/tex/context/base/mkiv/context.mkiv b/Master/texmf-dist/tex/context/base/mkiv/context.mkiv
index ff4c7f6c6b7..49eb150497e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/context.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/context.mkiv
@@ -45,8 +45,7 @@
%D {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2020.03.10 14:44}
-\edef\contextkind {beta}
+\edef\contextversion{2021.03.05 19:11}
%D Kind of special:
@@ -92,7 +91,6 @@
%D now put it into the environment.
\newtoks\contextversiontoks \contextversiontoks\expandafter{\contextversion}
-\newtoks\contextkindtoks \contextkindtoks \expandafter{\contextkind}
% \normaleverypar{\wait} % uncomment for test of funny injections
@@ -135,7 +133,7 @@
\loadmkvifile{file-ini}
\loadmkvifile{file-res}
-\loadmkvifile{file-lib}
+\loadmkivfile{file-lib}
%D This needs more checking for clashes:
%D
@@ -162,7 +160,7 @@
% \loadmarkfile{luat-ini}
-\loadmarkfile{toks-tra}
+%loadmarkfile{toks-tra}
\loadmarkfile{toks-aux}
%loadmarkfile{toks-map} % obsolete, never used
@@ -196,8 +194,6 @@
\loadmarkfile{trac-tex}
\loadmarkfile{trac-deb} % will move up
-%loadmarkfile{blob-ini} % not to be used, we only use a helper
-
\loadmarkfile{supp-box}
\loadmarkfile{supp-ran}
@@ -264,6 +260,7 @@
\loadmarkfile{lxml-sor}
\loadmkvifile{typo-prc}
+\loadmkivfile{typo-plc}
% \loadmarkfile{anch-pos}
@@ -429,7 +426,7 @@
\loadmarkfile{spac-chr} % depends on fonts
-\loadmarkfile{blob-ini} % not to be used, we only use a helper
+\loadmarkfile{blob-ini}
\loadmarkfile{trac-vis}
\loadmarkfile{trac-jus}
@@ -461,11 +458,10 @@
\loadmarkfile{symb-emj}
+\loadmarkfile{lang-tra}
\loadmarkfile{lang-wrd} % can be optional (discussion with mm sideeffect)
\loadmarkfile{lang-rep} % can be optional (bt 2013 side effect)
-\loadmarkfile{prop-ini} % only for downward compatibility
-
\loadmarkfile{mlib-ctx} % messy order
\loadmarkfile{meta-ini}
@@ -618,7 +614,7 @@
% \to \everyjob
\appendtoks
- \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv","\contextkind","\contextbanner")}% can become automatic
+ \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv","\contextbanner")}% can become automatic
\to \everydump
\errorstopmode \dump \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/context.mkxl b/Master/texmf-dist/tex/context/base/mkiv/context.mkxl
deleted file mode 100644
index 13e6a100b07..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/context.mkxl
+++ /dev/null
@@ -1,619 +0,0 @@
-%D \module
-%D [ file=context,
-%D version=2019.07.24, % 2008.28.10, % 1995.10.10,
-%D title=\CONTEXT,
-%D subtitle=\CONTEXT\ Format Generation,
-%D author=Hans Hagen, % ɦɑns ɦɑˈχən
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-% http://build.contextgarden.net/waterfall?tag=c/lua(meta)tex
-
-%D Welcome to context, pronounced as kontekst (rather dutch) and not as conτεχt.
-
-\catcode`\{=1 \catcode`\}=2 \catcode`\#=6
-
-%D From the next string (which is set by the script that assembles the distribution)
-%D later on we will calculate a number that can be used by use modules to identify
-%D the feature level. Starting with version 2004.8.30 the low level interface is
-%D english. Watch out and adapt your styles an modules.
-
-% \everypar{\writestatus{!!!!}{some spurious input in line \the\inputlineno}\wait}
-
-%D The order of loading will change when all modules have been cleaned up and the
-%D dependencies are more consistent. Beware, the version number has to match \type
-%D {YYYY.MM.DD HH:MM} format.
-
-\edef\contextformat {\jobname}
-\edef\contextversion{2020.03.10 14:44}
-\edef\contextkind {beta}
-
-%D Kind of special:
-
-\chardef\contextlmtxmode\directlua{tex.print(CONTEXTLMTXMODE or 0)}\relax
-
-%D For those who want to use this:
-
-\let\fmtname \contextformat
-\let\fmtversion\contextversion
-
-%D Loading:
-
-\edef\mksuffix {mkiv}
-\edef\contextmark{MKIV}
-
-\ifx\normalinput\undefined \let\normalinput\input \fi
-
-\def\loadmarkfile#1{\normalinput{#1.\mksuffix}}
-\def\loadmkivfile#1{\normalinput{#1.mkiv}}
-\def\loadmkvifile#1{\normalinput{#1.mkvi}}
-\def\loadmkxlfile#1{\normalinput{#1.mkxl}}
-\def\loadmklxfile#1{\normalinput{#1.mklx}}
-
-%D First we load the system modules. These implement a lot of manipulation macros.
-%D We start with setting up some basic \TEX\ machinery.
-
-\loadmkxlfile{syst-ini} % LMTX
-
-%D We just quit if new functionality is expected.
-
-\ifnum\luatexversion<200 % also change message
- \writestatus{!!!!}{Your luametatex binary is too old, you need at least version 2.00!}
- \expandafter\end
-\fi
-
-%D Some checking (more primitives are now defined):
-
-\ifdefined\defaultinterface \else \def\defaultinterface {english} \fi
-%ifdefined\messageinterface \else \let\messageinterface \defaultinterface \fi
-\ifdefined\defaultlanguagetag \else \def\defaultlanguagetag{en} \fi
-
-%D There is only this way to pass the version info to \LUA\ (currently). Hm, we could
-%D now put it into the environment.
-
-\newtoks\contextversiontoks \contextversiontoks\expandafter{\contextversion}
-\newtoks\contextkindtoks \contextkindtoks \expandafter{\contextkind}
-
-% \normaleverypar{\wait} % uncomment for test of funny injections
-
-%D Now the more fundamental code gets defined.
-
-\loadmarkfile{norm-ctx}
-\loadmarkfile{syst-pln}
-\loadmarkfile{syst-mes}
-
-\loadmarkfile{luat-cod}
-\loadmarkfile{luat-bas}
-\loadmarkfile{luat-lib}
-\loadmarkfile{luat-soc}
-
-\loadmarkfile{catc-ini}
-\loadmarkfile{catc-act}
-\loadmarkfile{catc-def}
-\loadmarkfile{catc-ctx}
-\loadmarkfile{catc-sym}
-
-\loadmarkfile{toks-ini}
-\loadmarkfile{cldf-ini}
-
-% \tracecatcodetables
-
-%D From here on we have \unexpanded being \normalprotected, as we already had
-%D \type {\unexpanded} long before etex came around.
-
-\loadmarkfile{luat-ini}
-\loadmarkfile{toks-scn}
-
-\loadmkxlfile{syst-aux} % LMTX
-\loadmkxlfile{syst-lua} % LMTX
-\loadmkxlfile{syst-con} % LMTX
-
-\loadmarkfile{syst-fnt}
-\loadmarkfile{syst-rtp}
-
-\loadmarkfile{luat-usr}
-
-\loadmkvifile{file-ini}
-\loadmkvifile{file-res}
-\loadmkvifile{file-lib}
-
-\loadmkxlfile{core-lmt} % LMTX
-
-%D This needs more checking for clashes:
-%D
-%D \starttyping
-%D \doifelsefileexists{l-macro-imp-codes-luametatex.lua}{\registerctxluafile{l-macro-imp-codes-luametatex}{}}{}
-%D \stoptyping
-
-\loadmarkfile{supp-dir}
-
-\loadmarkfile{char-utf} % generic code (i.e. not much tex) ... could become unic-ini
-\loadmarkfile{char-ini} % tex / context specific
-\loadmarkfile{char-act} % even more specific
-
-\loadmarkfile{mult-ini}
-\loadmarkfile{mult-sys}
-\loadmkxlfile{mult-aux} % LMTX
-\loadmarkfile{mult-def}
-\loadmarkfile{mult-chk}
-\loadmkvifile{mult-dim}
-
-\loadmarkfile{cldf-int} % interface
-
-\loadmarkfile{trac-ctx} % maybe move up
-
-% \loadmarkfile{luat-ini}
-
-\loadmarkfile{toks-tra}
-\loadmarkfile{toks-aux}
-%loadmarkfile{toks-map} % obsolete, never used
-
-\loadmarkfile{attr-ini}
-
-\loadmarkfile{core-ini}
-\loadmarkfile{core-env}
-
-\loadmarkfile{layo-ini}
-
-\loadmarkfile{node-ini}
-
-\loadmarkfile{cldf-bas} % basics / depends on nodes
-
-\loadmkivfile{node-fin}
-\loadmarkfile{node-mig}
-%loadmarkfile{node-pag}
-
-\loadmkxlfile{driv-ini} % LMTX
-
-\loadmkxlfile{back-ini} % LMTX
-\loadmarkfile{back-res}
-\loadmarkfile{back-trf}
-\loadmkxlfile{back-out} % LMTX
-
-\loadmarkfile{attr-col}
-\loadmarkfile{attr-lay}
-\loadmarkfile{attr-neg}
-\loadmarkfile{attr-eff}
-\loadmarkfile{attr-mkr}
-
-\loadmarkfile{trac-tex}
-\loadmarkfile{trac-deb} % will move up
-
-%loadmarkfile{blob-ini} % not to be used, we only use a helper
-
-\loadmkxlfile{supp-box} % LMTX
-
-\loadmarkfile{supp-ran}
-\loadmarkfile{supp-mat}
-
-\loadmarkfile{core-uti}
-\loadmkvifile{file-job}
-
-\loadmarkfile{anch-pos}
-
-\loadmarkfile{typo-ini}
-\loadmarkfile{typo-lin}
-\loadmarkfile{typo-bld} % par builders
-
-\loadmarkfile{typo-inj}
-
-\loadmkvifile{file-syn}
-\loadmkvifile{file-mod}
-
-\loadmarkfile{core-sys}
-\loadmarkfile{core-con}
-
-\loadmarkfile{cont-fil}
-
-\loadmarkfile{regi-ini}
-\loadmarkfile{enco-ini}
-\loadmkxlfile{hand-ini}
-
-\loadmkxlfile{lang-ini} % LMTX
-\loadmarkfile{lang-hyp} % also loads dis
-\loadmkxlfile{lang-lab} % LMTX
-
-\loadmarkfile{unic-ini}
-
-% \loadmarkfile{core-uti}
-\loadmarkfile{core-two}
-\loadmarkfile{core-dat}
-
-\loadmkxlfile{colo-ini} % LMTX
-\loadmarkfile{colo-grp} % optional
-\loadmarkfile{colo-ext}
-
-\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented)
-
-\loadmarkfile{pack-cut}
-
-\loadmarkfile{lang-mis}
-\loadmarkfile{lang-url}
-\loadmarkfile{lang-def}
-
-% \loadmkvifile{file-job} % why so late?
-
-\loadmarkfile{symb-ini} % brrr depends on fonts
-
-\loadmarkfile{sort-ini}
-
-\loadmkvifile{pack-mis}
-\loadmkxlfile{pack-ori} % LMTX
-\loadmkxlfile{pack-rul} % LMTX
-\loadmarkfile{pack-mrl}
-\loadmkvifile{pack-bck}
-\loadmarkfile{pack-fen}
-
-\loadmarkfile{lxml-ini}
-\loadmarkfile{lxml-sor}
-
-\loadmkvifile{typo-prc}
-
-% \loadmarkfile{anch-pos}
-
-\loadmkvifile{strc-ini}
-\loadmarkfile{strc-tag}
-\loadmarkfile{strc-doc}
-\loadmarkfile{strc-num}
-\loadmarkfile{strc-mar}
-\loadmarkfile{strc-sbe}
-\loadmkvifile{strc-lst}
-\loadmarkfile{strc-sec}
-\loadmarkfile{strc-pag} % hm, depends on core-num
-\loadmarkfile{strc-ren}
-\loadmarkfile{strc-xml}
-\loadmarkfile{strc-def} % might happen later
-\loadmkvifile{strc-ref}
-%loadmarkfile{strc-reg}
-\loadmkvifile{strc-lev} % experiment
-
-\loadmarkfile{spac-hor}
-\loadmarkfile{spac-ali}
-\loadmarkfile{spac-flr}
-\loadmkxlfile{spac-ver} % LMTX beware, hooks into strc-sec
-\loadmarkfile{spac-lin}
-\loadmarkfile{spac-pag}
-\loadmarkfile{spac-par}
-\loadmarkfile{spac-def}
-\loadmkvifile{spac-prf}
-\loadmarkfile{spac-grd}
-
-%loadmarkfile{anch-pos}
-
-\loadmkvifile{scrn-ini}
-\loadmkvifile{scrn-ref}
-
-\loadmarkfile{pack-obj}
-
-\loadmklxfile{strc-itm} % LMTX
-
-\loadmkvifile{strc-con}
-\loadmkvifile{strc-des}
-\loadmkvifile{strc-enu}
-
-\loadmarkfile{strc-ind}
-\loadmarkfile{strc-lab}
-\loadmarkfile{strc-syn}
-
-% \loadmarkfile{core-sys}
-
-\loadmarkfile{page-var}
-\loadmkvifile{page-otr}
-\loadmarkfile{page-ini}
-\loadmarkfile{page-ins}
-\loadmarkfile{page-fac}
-\loadmarkfile{page-brk}
-\loadmarkfile{page-col}
-\loadmarkfile{page-inf}
-\loadmarkfile{page-flt}
-\loadmarkfile{page-bck}
-\loadmarkfile{page-not}
-\loadmarkfile{page-one}
-\loadmarkfile{page-lay}
-\loadmkvifile{page-box}
-\loadmklxfile{page-txt} % LMTX
-\loadmarkfile{page-sid} % when
-
-\loadmkvifile{strc-flt}
-
-\loadmarkfile{page-pst}
-\loadmkvifile{page-mbk}
-%loadmarkfile{page-mul} % \usecolumns[old-multicolumns]
-\loadmarkfile{page-mix}
-\loadmarkfile{page-smp}
-%loadmarkfile{page-set} % \usecolumns[old-columnsets]
-\loadmarkfile{page-cst}
-\loadmarkfile{page-pcl} % new
-\loadmkxlfile{pack-lyr} % LMTX
-\loadmarkfile{pack-pos}
-\loadmkvifile{page-mak}
-
-\loadmarkfile{strc-reg} % uses mixed columns
-
-\loadmkvifile{page-lin}
-\loadmarkfile{page-par}
-\loadmarkfile{typo-pag}
-\loadmarkfile{typo-mar}
-\loadmarkfile{typo-itm}
-
-\loadmarkfile{buff-ini}
-\loadmkxlfile{buff-ver} % LMTX
-\loadmkvifile{buff-par}
-
-\loadmarkfile{buff-imp-tex} % optional as also runtime if not loaded
-\loadmarkfile{buff-imp-mp} % optional as also runtime if not loaded
-\loadmarkfile{buff-imp-lua} % optional as also runtime if not loaded
-\loadmarkfile{buff-imp-xml} % optional as also runtime if not loaded
-
-\loadmarkfile{buff-imp-parsed-xml} % optional
-%loadmarkfile{buff-imp-parsed-lua} % optional
-
-\loadmarkfile{strc-blk}
-
-\loadmarkfile{page-imp}
-\loadmkvifile{page-sel} % optional
-\loadmkvifile{page-inj} % optional
-
-\loadmkvifile{scrn-pag}
-\loadmkvifile{scrn-wid}
-\loadmkvifile{scrn-but}
-\loadmkvifile{scrn-bar}
-
-\loadmarkfile{page-com} % optional (after scrn-pag)
-
-\loadmarkfile{strc-bkm} % bookmarks
-
-\loadmarkfile{java-ini}
-
-\loadmkvifile{scrn-fld}
-\loadmkvifile{scrn-hlp}
-
-\loadmarkfile{char-enc} % will move up
-
-\loadmkvifile{font-lib} % way too late but after language
-\loadmklxfile{font-fil} % LMTX
-\loadmkvifile{font-var}
-\loadmkvifile{font-fea}
-\loadmklxfile{font-mat} % LMTX
-\loadmklxfile{font-ini} % LMTX
-\loadmklxfile{font-sym} % LMTX
-\loadmklxfile{font-sty} % LMTX
-\loadmkvifile{font-set}
-\loadmklxfile{font-emp} % LMTX
-\loadmarkfile{font-pre}
-\loadmarkfile{font-unk}
-\loadmarkfile{font-tra}
-\loadmarkfile{font-chk}
-\loadmarkfile{font-uni}
-\loadmkvifile{font-col}
-\loadmkvifile{font-gds}
-\loadmkvifile{font-aux}
-\loadmkvifile{font-sel}
-
-\loadmarkfile{typo-tal}
-\loadmarkfile{typo-par} % par builders (uses fonts)
-
-\loadmarkfile{tabl-com}
-\loadmarkfile{tabl-pln}
-
-\loadmarkfile{tabl-tab} % thrd-tab stripped and merged
-
-\loadmkxlfile{tabl-tbl} % LMTX
-\loadmkxlfile{tabl-ntb} % LMTX
-\loadmarkfile{tabl-nte}
-\loadmarkfile{tabl-ltb}
-\loadmarkfile{tabl-frm}
-\loadmarkfile{tabl-tsp}
-\loadmkvifile{tabl-xtb}
-\loadmarkfile{tabl-mis}
-
-\loadmarkfile{typo-lan}
-
-\loadmarkfile{lxml-css}
-
-\loadmarkfile{spac-chr} % depends on fonts
-
-\loadmarkfile{blob-ini} % not to be used, we only use a helper
-
-\loadmarkfile{trac-vis}
-\loadmarkfile{trac-jus}
-
-\loadmarkfile{typo-cln}
-\loadmarkfile{typo-wrp}
-\loadmarkfile{typo-spa}
-\loadmarkfile{typo-krn}
-\loadmkvifile{typo-itc}
-\loadmarkfile{typo-dir}
-\loadmarkfile{typo-brk}
-\loadmarkfile{typo-cap}
-\loadmarkfile{typo-dig}
-\loadmarkfile{typo-rep}
-\loadmkvifile{typo-txt}
-\loadmarkfile{typo-drp}
-\loadmarkfile{typo-fln}
-\loadmarkfile{typo-sus}
-\loadmarkfile{typo-lig}
-\loadmarkfile{typo-chr}
-\loadmarkfile{typo-rub}
-\loadmkivfile{typo-fkr}
-\loadmkivfile{typo-pnc}
-
-\loadmklxfile{type-ini} % LMTX
-\loadmarkfile{type-set}
-
-\loadmarkfile{scrp-ini}
-
-\loadmarkfile{symb-emj}
-
-\loadmarkfile{lang-wrd} % can be optional (discussion with mm sideeffect)
-\loadmarkfile{lang-rep} % can be optional (bt 2013 side effect)
-
-\loadmarkfile{prop-ini} % only for downward compatibility
-
-\loadmkxlfile{mlib-ctx} % LMTX % messy order
-
-\loadmkxlfile{meta-ini} % LMTX
-\loadmarkfile{meta-tex}
-\loadmarkfile{meta-fun}
-\loadmkxlfile{meta-pag}
-\loadmarkfile{meta-grd}
-\loadmarkfile{meta-fnt}
-\loadmarkfile{meta-nod}
-\loadmarkfile{meta-lua}
-\loadmkxlfile{meta-mac} % LMTX
-
-\loadmarkfile{page-mrk} % depends on mp
-
-\loadmarkfile{page-flw}
-\loadmarkfile{page-spr}
-\loadmarkfile{page-plg}
-\loadmarkfile{page-str}
-
-\loadmarkfile{anch-pgr} % can be moved up (nicer for dependencies)
-\loadmkvifile{anch-bck}
-\loadmarkfile{anch-tab} % overloads tabl-tbl
-\loadmarkfile{anch-bar}
-%loadmarkfile{anch-snc} % when needed this one will be redone
-
-\loadmarkfile{math-ini} % way after font-pre !
-\loadmarkfile{math-pln}
-\loadmarkfile{math-for}
-\loadmarkfile{math-def} % also saves some meanings
-\loadmarkfile{math-ali}
-%loadmarkfile{math-arr}
-\loadmkvifile{math-stc}
-\loadmarkfile{math-frc}
-\loadmarkfile{math-mis}
-\loadmarkfile{math-scr}
-\loadmarkfile{math-int}
-\loadmarkfile{math-del}
-\loadmarkfile{math-fen}
-\loadmkvifile{math-acc}
-\loadmkvifile{math-rad}
-\loadmarkfile{math-inl}
-\loadmarkfile{math-dis}
-%loadmarkfile{math-lan}
-
-%loadmarkfile{phys-dim} % moved to after typo-scr
-
-\loadmarkfile{strc-mat}
-
-\loadmarkfile{chem-ini}
-\loadmarkfile{chem-str}
-
-\loadmarkfile{typo-scr}
-\loadmarkfile{phys-dim}
-
-\loadmarkfile{node-rul} % beware, defined \underbar so after math
-\loadmkvifile{font-sol} % font solutions
-
-\loadmkvifile{strc-not}
-\loadmkvifile{strc-lnt}
-\loadmkivfile{strc-tnt}
-\loadmkivfile{strc-usr}
-
-\loadmarkfile{pack-com}
-\loadmarkfile{typo-del}
-
-\loadmarkfile{grph-trf}
-\loadmarkfile{grph-inc}
-\loadmarkfile{grph-fig}
-\loadmarkfile{grph-raw}
-\loadmarkfile{grph-rul}
-\loadmarkfile{grph-pat}
-
-\loadmarkfile{pack-box}
-\loadmarkfile{pack-bar}
-\loadmarkfile{page-app}
-\loadmarkfile{meta-fig}
-
-\loadmarkfile{page-ffl}
-
-\loadmarkfile{lang-spa} % will become obsolete
-
-\loadmarkfile{typo-ovl} % fuzzy project (tracing) code
-
-% old bibtex support: (will be m-oldbibtex.mkiv)
-
-% \loadmarkfile{bibl-bib}
-% \loadmarkfile{bibl-tra}
-
-% new bibtex support:
-
-\loadmarkfile{publ-ini}
-\loadmarkfile{publ-tra}
-\loadmarkfile{publ-xml}
-\loadmarkfile{publ-old}
-
-%loadmarkfile{x-xtag} % no longer preloaded
-
-\loadmarkfile{meta-xml}
-
-\loadmarkfile{cont-log}
-
-% \loadmarkfile{task-ini}
-
-\loadmarkfile{cldf-ver} % verbatim, this can come late
-\loadmarkfile{cldf-com} % commands, this can come late
-
-\loadmarkfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace
-
-\loadmarkfile{core-def}
-
-%usemodule[x][res-04] % xml resource libraries
-%usemodule[x][res-08] % rlx runtime conversion
-%usemodule[x][res-12] % rli external indentification
-
-% now we hook in backend code (needs checking)
-
-\loadmkxlfile{driv-shp} % LMTX
-
-\loadmarkfile{back-exp}
-\loadmkxlfile{back-pdf} % LMTX
-\loadmkxlfile{back-mps} % LMTX
-\loadmkxlfile{back-lua} % LMTX
-
-\loadmkxlfile{mlib-pdf} % LMTX
-\loadmarkfile{mlib-pps}
-\loadmarkfile{meta-pdf}
-\loadmarkfile{meta-blb}
-\loadmarkfile{grph-epd}
-
-\loadmarkfile{math-inc} % an experiment
-\loadmarkfile{publ-inc} % an experiment
-
-\loadmarkfile{task-ini}
-
-\loadmarkfile{syst-cmp} % compatibility stuff moved here
-
-\loadmkxlfile{libs-ini}
-
-\loadmarkfile{cont-run} % the main runner (used in cont-yes.mkiv)
-
-\setupcurrentlanguage[\defaultlanguagetag]
-
-\prependtoks
- \ctxlua{statistics.starttiming(statistics)}%
-\to \everyjob
-
-\appendtoks
- \ctxlua{statistics.stoptiming(statistics)}%
-\to \everyjob
-
-% \appendtoks
-% \ctxlua{job.prepare()}%
-% \to \everyjob
-
-% \appendtoks
-% \enabletrackers[*]%
-% \to \everyjob
-
-\appendtoks
- \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkxl","\contextkind","\contextbanner")}% can become automatic
-\to \everydump
-
-\errorstopmode \dump \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-con.lua b/Master/texmf-dist/tex/context/base/mkiv/core-con.lua
index 4f6090ef5b5..4bf1424bc02 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-con.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-con.lua
@@ -16,12 +16,15 @@ slower but look nicer this way.
Some code may move to a module in the language namespace.
--ldx]]--
-local floor, osdate, ostime, concat = math.floor, os.date, os.time, table.concat
+local floor = math.floor
+local osdate, ostime = os.date, os.time
+local concat, insert, reverse = table.concat, table.insert, table.reverse
local lower, upper, rep, match, gsub = string.lower, string.upper, string.rep, string.match, string.gsub
local utfchar, utfbyte = utf.char, utf.byte
local tonumber, tostring, type, rawset = tonumber, tostring, type, rawset
local P, S, R, Cc, Cf, Cg, Ct, Cs, C, V, Carg = lpeg.P, lpeg.S, lpeg.R, lpeg.Cc, lpeg.Cf, lpeg.Cg, lpeg.Ct, lpeg.Cs, lpeg.C, lpeg.V, lpeg.Carg
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local div, mod = math.div, math.mod
local context = context
local commands = commands
@@ -328,7 +331,7 @@ converters.nofdays = nofdays
converters.textime = textime
implement { name = "weekday", actions = { weekday, context }, arguments = { "integer", "integer", "integer" } }
-implement { name = "leapyear", actions = { leapyear, context }, arguments = { "integer" } }
+implement { name = "leapyear", actions = { leapyear, context }, arguments = "integer" }
implement { name = "nofdays", actions = { nofdays, context }, arguments = { "integer", "integer" } }
implement { name = "year", actions = { osdate, context }, arguments = "'%Y'" }
@@ -445,6 +448,94 @@ implement {
arguments = { "integer", true }
}
+-- -- - hebrew and jiddish -- -- --
+
+local trace_hebrew trackers.register("converters.hebrew", function(v)
+ trace_hebrew = v
+end)
+
+local list = {
+ { 400, "ת" }, { 300, "ש" }, { 200, "ר" }, { 100, "ק" },
+ { 90, "צ" }, { 80, "פ" }, { 70, "ע" }, { 60, "ס "}, { 50, "נ" }, { 40, "מ" }, { 30, "ל" }, { 20, "כ" }, { 10, "י" },
+ { 9, "ט" }, { 8, "ח" }, { 7, "ז", }, { 6, "ו", }, { 5, "ה" }, { 4, "ד" }, { 3, "ג" }, { 2, "ב" }, { 1, "א" },
+}
+
+local special = {
+ [15] = "ט״ו", -- exception: avoid mixup with God יה
+ [16] = "ט״ז", -- exception: avoid mixup with God יו
+}
+
+local function tohebrew(n,gershayim,geresh)
+ local split = { }
+ local size = 0
+ while n > 1000 do
+ size = size + 1
+ split[size] = n % 1000
+ n = floor(n/1000)
+ end
+ size = size + 1
+ split[size] = n
+ for i=1,size do
+ local t = { }
+ local n = 0
+ local s = split[i]
+ while s > 0 do
+ for i=1,#list do
+ ::again::
+ local li = list[i]
+ local l1 = li[1]
+ local s1 = special[l1]
+ if s1 then
+ s = s - l1
+ n = n + 1
+ t[n] = s1
+ goto again
+ elseif s >= l1 then
+ s = s - l1
+ n = n + 1
+ t[n] = li[2]
+ goto again
+ end
+ end
+ end
+ ::done::
+ split[i] = t
+ end
+ if gershayim then
+ for i=1,size do
+ local si = split[i]
+ local ni = #si
+ if ni >= 2 then
+ local s = "״"
+ insert(split[i],ni,trace_hebrew and ("{\\red "..s.."}") or s)
+ end
+ end
+ end
+ if geresh then
+ for i=2,#split do
+ local s = rep("׳",i-1)
+ insert(split[i],trace_hebrew and ("{\\blue "..s.."}") or s)
+ end
+ end
+ for i=1,size do
+ split[i] = concat(split[i])
+ end
+ return concat(reverse(split))
+end
+
+converters.tohebrew = tohebrew
+converters.hebrewnumerals = converters.tohebrew
+
+-- converters['alphabetic:hb'] = converters.hebrewnumerals
+
+interfaces.implement {
+ name = "hebrewnumerals",
+ actions = { tohebrew, context },
+ arguments = { "integer", true, true }
+}
+
+-- -- --
+
local vector = {
normal = {
[0] = "〇",
@@ -703,115 +794,303 @@ implement {
arguments = { "string", "integer" }
}
--- Well, since the one asking for this didn't test it the following code is not
--- enabled.
---
--- -- This Lua version is based on a Javascript by Behdad Esfahbod which in turn
--- -- is based on GPL'd code by Roozbeh Pournader of the The FarsiWeb Project
--- -- Group: http://www.farsiweb.info/jalali/jalali.js.
--- --
--- -- We start tables at one, I kept it zero based in order to stay close to
--- -- the original.
--- --
--- -- Conversion by Hans Hagen
-
-local g_days_in_month = { [0] = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-local j_days_in_month = { [0] = 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 }
-
-local div = math.div
-local mod = math.mod
-
-function gregorian_to_jalali(gy,gm,gd)
- local jy, jm, jd, g_day_no, j_day_no, j_np, i
- gy, gm, gd = gy - 1600, gm - 1, gd - 1
- g_day_no = 365*gy + div((gy+3),4) - div((gy+99),100) + div((gy+399),400)
- i = 0
- while i < gm do
- g_day_no = g_day_no + g_days_in_month[i]
- i = i + 1
+-- hebrew data conversion
+
+local gregorian_to_hebrew do
+
+ -- The next code is based on the c code at https://github.com/hebcal/hebcal
+ --
+ -- Hebcal : A Jewish Calendar Generator
+ -- Copyright : 1994 - 2004 Danny Sadinoff, 2002 Michael J. Radwin
+ -- License : GPL
+ --
+ -- Because we only need simple dates, we use part of the code. There is more
+ -- at that github place.
+ --
+ -- The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
+ -- The Gregorian date Sunday, December 31, 1 BC is imaginary.
+ --
+ -- The code is luafied and a little different because we have no assignments
+ -- in loops and such. We could speed up the code but then we divert from the
+ -- original. This is not that critical anyway.
+
+ local NISAN = 1
+ local IYYAR = 2
+ local SIVAN = 3
+ local TAMUZ = 4
+ local AV = 5
+ local ELUL = 6
+ local TISHREI = 7
+ local CHESHVAN = 8
+ local KISLEV = 9
+ local TEVET = 10
+ local SHVAT = 11
+ local ADAR_I = 12
+ local ADAR_II = 13
+
+ local mmap = {
+ KISLEV,
+ TEVET,
+ SHVAT,
+ ADAR_I,
+ NISAN,
+ IYYAR,
+ SIVAN,
+ TAMUZ,
+ TISHREI,
+ TISHREI,
+ TISHREI,
+ CHESHVAN
+ }
+
+ local function greg2abs(year,month,day)
+ local y = year - 1
+ return y * 365 + div(y,4)- div(y,100) + div(y,400) + os.nofdays(year,month,day)
+ end
+
+ local function abs2greg(abs)
+
+ local d0 = abs - 1
+
+ local n400 = div(d0, 146097)
+ local d1 = mod(d0, 146097)
+ local n100 = div(d1, 36524)
+ local d2 = mod(d1, 36524)
+ local n4 = div(d2, 1461)
+ local d3 = mod(d2, 1461)
+ local n1 = div(d3, 365)
+
+ local day = mod(d3, 365) + 1
+ local year = 400 * n400 + 100 * n100 + 4 * n4 + n1
+
+ if n100 == 4 or n1 == 4 then
+ return year, 12, 31
+ else
+ year = year + 1
+ month = 1
+ while true do
+ local mlen = os.nofdays(year,month)
+ if mlen < day then
+ day = day - mlen
+ month = month + 1
+ else
+ break
+ end
+ end
+ return year, month, day
+ end
end
- if (gm>1 and ((gy%4==0 and gy%100~=0) or (gy%400==0))) then
- g_day_no = g_day_no + 1
+
+ local function hebrew_leapyear(year)
+ return mod(1 + year * 7, 19) < 7
end
- g_day_no = g_day_no + gd
- j_day_no = g_day_no - 79
- j_np = div(j_day_no,12053)
- j_day_no = mod(j_day_no,12053)
- jy = 979 + 33*j_np + 4*div(j_day_no,1461)
- j_day_no = mod(j_day_no,1461)
- if j_day_no >= 366 then
- jy = jy + div((j_day_no-1),365)
- j_day_no = mod((j_day_no-1),365)
+
+ local function hebrew_months_in_year(year)
+ return hebrew_leapyear(year) and 13 or 12
end
- i = 0
- while i < 11 and j_day_no >= j_days_in_month[i] do
- j_day_no = j_day_no - j_days_in_month[i]
- i = i + 1
+
+ local function hebrew_elapsed_days(year)
+ local y = year - 1
+ local m_elapsed = 235 * div(y,19) + 12 * mod(y,19) + div(((mod(y,19) * 7) + 1),19)
+ local p_elapsed = 204 + 793 * mod(m_elapsed,1080)
+ local h_elapsed = 5 + 12 * m_elapsed + 793 * div(m_elapsed,1080) + div(p_elapsed,1080)
+ local parts = mod(p_elapsed,1080) + 1080 * mod(h_elapsed,24)
+ local day = 1 + 29 * m_elapsed + div(h_elapsed,24)
+ local d = mod(day,7)
+ local alt_day = day
+ if parts >= 19440
+ or (parts >= 9924 and d == 2 and not (hebrew_leapyear(year)))
+ or (parts >= 16789 and d == 1 and hebrew_leapyear(y )) then
+ alt_day = alt_day + 1
+ end
+ d = mod(alt_day,7)
+ if d == 0 or d == 3 or d == 5 then
+ alt_day = alt_day + 1
+ end
+ return alt_day
end
- jm = i + 1
- jd = j_day_no + 1
- return jy, jm, jd
-end
-function jalali_to_gregorian(jy,jm,jd)
- local gy, gm, gd, g_day_no, j_day_no, leap, i
- jy, jm, jd = jy - 979, jm - 1, jd - 1
- j_day_no = 365*jy + div(jy,33)*8 + div((mod(jy,33)+3),4)
- for i=0,jm-1,1 do
- j_day_no = j_day_no + j_days_in_month[i]
+ local function days_in_hebrew_year(year)
+ return hebrew_elapsed_days(year + 1) - hebrew_elapsed_days(year)
end
- j_day_no = j_day_no + jd
- g_day_no = j_day_no + 79
- gy = 1600 + 400*div(g_day_no,146097)
- g_day_no = mod(g_day_no, 146097)
- leap = 1
- if g_day_no >= 36525 then
- g_day_no = g_day_no - 1
- gy = gy + 100*div(g_day_no,36524)
- g_day_no = mod(g_day_no, 36524)
- if g_day_no >= 365 then
- g_day_no = g_day_no + 1
+
+ local function long_cheshvan(year)
+ return mod(days_in_hebrew_year(year),10) == 5
+ end
+
+ local function short_kislev(year)
+ return mod(days_in_hebrew_year(year),10) == 3
+ end
+
+ local function max_days_in_heb_month(month,year)
+ if month == IYYAR or month == TAMUZ or month == ELUL or month == TEVET or month == ADAR_II or
+ (month == ADAR_I and not hebrew_leapyear(year)) or
+ (month == CHESHVAN and not long_cheshvan(year)) or
+ (month == KISLEV and short_kislev (year)) then
+ return 29
else
- leap = 0
+ return 30
end
end
- gy = gy + 4*div(g_day_no,1461)
- g_day_no = mod(g_day_no, 1461)
- if g_day_no >= 366 then
- leap = 0
- g_day_no = g_day_no - 1
- gy = gy + div(g_day_no, 365)
- g_day_no = mod(g_day_no, 365)
- end
- i = 0
- while true do
- local d = g_days_in_month[i] + ((i == 1 and leap) or 0)
- if g_day_no >= d then
- g_day_no = g_day_no - d
- i = i + 1
+
+ local function hebrew2abs(year,month,day)
+ if month < TISHREI then
+ for m=TISHREI, hebrew_months_in_year(year), 1 do
+ day = day + max_days_in_heb_month(m,year)
+ end
+ for m=NISAN, month - 1, 1 do
+ day = day + max_days_in_heb_month(m,year)
+ end
else
- break
+ for m=TISHREI, month - 1, 1 do
+ day = day + max_days_in_heb_month(m,year)
+ end
end
+ return hebrew_elapsed_days(year) - 1373429 + day
end
- gm = i + 1
- gd = g_day_no + 1
- return gy, gm, gd
+
+ local function abs2hebrew(abs)
+ local yy, mm, dd = abs2greg(abs)
+ local day = 1
+ local month = TISHREI
+ local year = 3760 + yy
+ while abs >= hebrew2abs(year+1,month,day) do
+ year = year + 1
+ end
+ if year >= 4635 and year < 10666 then
+ month = mmap[mm]
+ end
+ while abs > hebrew2abs(year,month,max_days_in_heb_month(month,year)) do
+ month = mod(month,hebrew_months_in_year(year)) + 1
+ end
+ day = abs - hebrew2abs(year,month,1) + 1
+ return year, month, day
+ end
+
+ -- months = { "ניסן" "אייר" "סיון" "תמוז" "אב" "אלול" "תשרי" "חשון" "כסלו" "טבת" "שבט" }
+
+ gregorian_to_hebrew = function(y,m,d)
+ return abs2hebrew(greg2abs(y,m,d))
+ end
+
+ converters.gregorian_to_hebrew = gregorian_to_hebrew
+
end
--- local function test(yg,mg,dg,yj,mj,dj)
--- local y1, m1, d1 = jalali_to_gregorian(yj,mj,dj)
--- local y2, m2, d2 = gregorian_to_jalali(yg,mg,dg)
--- print(y1 == yg and m1 == mg and d1 == dg, yg,mg,dg, y1,m1,d1)
--- print(y2 == yj and m2 == mj and d2 == dj, yj,mj,dj, y2,m2,d2)
--- end
+local gregorian_to_jalali, jalali_to_gregorian do
+
+ -- Well, since the one asking for this didn't test it the following code is not
+ -- enabled.
+ --
+ -- -- This Lua version is based on a Javascript by Behdad Esfahbod which in turn
+ -- -- is based on GPL'd code by Roozbeh Pournader of the The FarsiWeb Project
+ -- -- Group: http://www.farsiweb.info/jalali/jalali.js.
+ -- --
+ -- -- We start tables at one, I kept it zero based in order to stay close to
+ -- -- the original.
+ -- --
+ -- -- Conversion by Hans Hagen
+
+ local g_days_in_month = { [0] = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+ local j_days_in_month = { [0] = 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 }
+
+
+ gregorian_to_jalali = function(gy,gm,gd)
+ local jy, jm, jd, g_day_no, j_day_no, j_np, i
+ gy, gm, gd = gy - 1600, gm - 1, gd - 1
+ g_day_no = 365*gy + div((gy+3),4) - div((gy+99),100) + div((gy+399),400)
+ i = 0
+ while i < gm do
+ g_day_no = g_day_no + g_days_in_month[i]
+ i = i + 1
+ end
+ if (gm>1 and ((gy%4==0 and gy%100~=0) or (gy%400==0))) then
+ g_day_no = g_day_no + 1
+ end
+ g_day_no = g_day_no + gd
+ j_day_no = g_day_no - 79
+ j_np = div(j_day_no,12053)
+ j_day_no = mod(j_day_no,12053)
+ jy = 979 + 33*j_np + 4*div(j_day_no,1461)
+ j_day_no = mod(j_day_no,1461)
+ if j_day_no >= 366 then
+ jy = jy + div((j_day_no-1),365)
+ j_day_no = mod((j_day_no-1),365)
+ end
+ i = 0
+ while i < 11 and j_day_no >= j_days_in_month[i] do
+ j_day_no = j_day_no - j_days_in_month[i]
+ i = i + 1
+ end
+ jm = i + 1
+ jd = j_day_no + 1
+ return jy, jm, jd
+ end
+
+ jalali_to_gregorian = function(jy,jm,jd)
+ local gy, gm, gd, g_day_no, j_day_no, leap, i
+ jy, jm, jd = jy - 979, jm - 1, jd - 1
+ j_day_no = 365*jy + div(jy,33)*8 + div((mod(jy,33)+3),4)
+ for i=0,jm-1,1 do
+ j_day_no = j_day_no + j_days_in_month[i]
+ end
+ j_day_no = j_day_no + jd
+ g_day_no = j_day_no + 79
+ gy = 1600 + 400*div(g_day_no,146097)
+ g_day_no = mod(g_day_no, 146097)
+ leap = 1
+ if g_day_no >= 36525 then
+ g_day_no = g_day_no - 1
+ gy = gy + 100*div(g_day_no,36524)
+ g_day_no = mod(g_day_no, 36524)
+ if g_day_no >= 365 then
+ g_day_no = g_day_no + 1
+ else
+ leap = 0
+ end
+ end
+ gy = gy + 4*div(g_day_no,1461)
+ g_day_no = mod(g_day_no, 1461)
+ if g_day_no >= 366 then
+ leap = 0
+ g_day_no = g_day_no - 1
+ gy = gy + div(g_day_no, 365)
+ g_day_no = mod(g_day_no, 365)
+ end
+ i = 0
+ while true do
+ local d = g_days_in_month[i] + ((i == 1 and leap) or 0)
+ if g_day_no >= d then
+ g_day_no = g_day_no - d
+ i = i + 1
+ else
+ break
+ end
+ end
+ gm = i + 1
+ gd = g_day_no + 1
+ return gy, gm, gd
+ end
+
+ -- local function test(yg,mg,dg,yj,mj,dj)
+ -- local y1, m1, d1 = jalali_to_gregorian(yj,mj,dj)
+ -- local y2, m2, d2 = gregorian_to_jalali(yg,mg,dg)
+ -- print(y1 == yg and m1 == mg and d1 == dg, yg,mg,dg, y1,m1,d1)
+ -- print(y2 == yj and m2 == mj and d2 == dj, yj,mj,dj, y2,m2,d2)
+ -- end
+
+ -- test(1953,08,19, 1332,05,28)
+ -- test(1979,02,11, 1357,11,22)
+ -- test(2000,02,28, 1378,12,09)
+ -- test(2000,03,01, 1378,12,11)
+ -- test(2009,02,24, 1387,12,06)
+ -- test(2015,03,21, 1394,01,01)
+ -- test(2016,03,20, 1395,01,01)
--- test(1953,08,19, 1332,05,28)
--- test(1979,02,11, 1357,11,22)
--- test(2000,02,28, 1378,12,09)
--- test(2000,03,01, 1378,12,11)
--- test(2009,02,24, 1387,12,06)
--- test(2015,03,21, 1394,01,01)
--- test(2016,03,20, 1395,01,01)
+ converters.gregorian_to_jalali = gregorian_to_jalali
+ converters.jalali_to_gregorian = jalali_to_gregorian
+
+end
-- -- more efficient but needs testing
@@ -945,7 +1224,7 @@ local words = {
[1000000000000] = "trillion",
}
-local function translate(n)
+local function translate(n,connector)
local w = words[n]
if w then
return w
@@ -995,7 +1274,7 @@ local function translate(n)
if n > 0 then
compose_one(n)
end
- return #t > 0 and concat(t," ") or tostring(n)
+ return #t > 0 and concat(t,connector or " ") or tostring(n)
end
data.english = {
@@ -1067,7 +1346,7 @@ local words = {
[1000000000000] = "billón",
}
-local function translate(n)
+local function translate(n,connector)
local w = words[n]
if w then
return w
@@ -1122,7 +1401,7 @@ local function translate(n)
if n > 0 then
compose_one(n)
end
- return #t > 0 and concat(t," ") or tostring(n)
+ return #t > 0 and concat(t,connector or " ") or tostring(n)
end
data.spanish = {
@@ -1138,20 +1417,20 @@ data.es = data.spanish
-- verbose handler:
-function converters.verbose.translate(n,language)
+function converters.verbose.translate(n,language,connector)
local t = language and data[language]
- return t and t.translate(n) or n
+ return t and t.translate(n,connector) or n
end
-local function verbose(n,language)
+local function verbose(n,language,connector)
local t = language and data[language]
- context(t and t.translate(n) or n)
+ context(t and t.translate(n,connector) or n)
end
implement {
name = "verbose",
actions = verbose,
- arguments = { "integer", "string" }
+ arguments = { "integer", "string", "string" }
}
-- These are just helpers but not really for the tex end. Do we have to
@@ -1227,8 +1506,13 @@ local monthmnems = { -- not variables
-- virtual table
}
-setmetatableindex(months, function(t,k) return "unknown" end)
+local daymnems = { -- not variables
+ -- virtual table
+}
+
setmetatableindex(days, function(t,k) return "unknown" end)
+setmetatableindex(daymnems, function(t,k) return days[k] .. ":mnem" end)
+setmetatableindex(months, function(t,k) return "unknown" end)
setmetatableindex(monthmnems, function(t,k) return months[k] .. ":mnem" end)
do
@@ -1237,6 +1521,10 @@ do
ctx_labeltext(days[n])
end
+ local function daymnem(n)
+ ctx_labeltext(daymnems[n])
+ end
+
local function weekdayname(day,month,year)
ctx_labeltext(days[weekday(day,month,year)])
end
@@ -1255,6 +1543,12 @@ do
arguments = "integer",
}
+ implement {
+ name = "daymnem",
+ actions = daymnem,
+ arguments = "integer",
+ }
+
implement {
name = "weekdayname",
actions = weekdayname,
@@ -1264,22 +1558,28 @@ do
implement {
name = "monthname",
actions = monthname,
- arguments = { "integer" }
+ arguments = "integer",
}
implement {
name = "monthmnem",
actions = monthmnem,
- arguments = { "integer" }
+ arguments = "integer",
}
+ -- todo : short week days
+
local f_monthlong = formatters["\\monthlong{%s}"]
local f_monthshort = formatters["\\monthshort{%s}"]
+ local f_daylong = formatters["\\daylong{%s}"]
+ local f_dayshort = formatters["\\dayshort{%s}"]
local f_weekday = formatters["\\weekday{%s}"]
local f_dayoftheweek = formatters["\\dayoftheweek{%s}{%s}{%s}"]
local function tomonthlong (m) return f_monthlong (tonumber(m) or 1) end
local function tomonthshort(m) return f_monthshort(tonumber(m) or 1) end
+ local function todaylong (d) return f_daylong (tonumber(d) or 1) end
+ local function todayshort (d) return f_dayshort (tonumber(d) or 1) end
local function toweekday (d) return f_weekday (tonumber(d) or 1) end
local function todayoftheweek(d,m,y)
@@ -1288,6 +1588,8 @@ do
addformatter(formatters,"monthlong", [[tomonthlong(%s)]], { tomonthlong = tomonthlong })
addformatter(formatters,"monthshort", [[tomonthshort(%s)]], { tomonthshort = tomonthshort })
+ addformatter(formatters,"daylong", [[todaylong(%s)]], { todaylong = todaylong })
+ addformatter(formatters,"dayshort", [[todayshort(%s)]], { todayshort = todayshort })
addformatter(formatters,"weekday", [[toweekday(%s)]], { toweekday = toweekday })
addformatter(formatters,"dayoftheweek",[[todayoftheweek(%s,%s,%s)]],{ todayoftheweek = todayoftheweek })
@@ -1307,6 +1609,14 @@ do
return f_monthshort(tonumber(osdate("%m",tonumber(e))))
end
+ local function toedaylong(e)
+ return f_datlong(tonumber(osdate("%w",tonumber(e))))
+ end
+
+ local function toedayshort(e)
+ return f_dayshort(tonumber(osdate("%w",tonumber(e))))
+ end
+
local function toeweek(e) -- we run from 1-7 not 0-6
return tostring(tonumber(osdate("%w",tonumber(e)))+1)
end
@@ -1319,18 +1629,20 @@ do
return osdate(format,tonumber(e))
end
- addformatter(formatters,"eyear", [[toeyear(%s)]], { toeyear = toeyear })
- addformatter(formatters,"emonth", [[toemonth(%s)]], { toemonth = toemonth })
- addformatter(formatters,"eday", [[toeday(%s)]], { toeday = toeday })
- addformatter(formatters,"eweek", [[toeweek(%s)]], { toeweek = toeweek })
- addformatter(formatters,"eminute", [[toeminute(%s)]], { toeminute = toeminute })
- addformatter(formatters,"esecond", [[toesecond(%s)]], { toesecond = toesecond })
+ addformatter(formatters,"eyear", [[toeyear(%s)]], { toeyear = toeyear })
+ addformatter(formatters,"emonth", [[toemonth(%s)]], { toemonth = toemonth })
+ addformatter(formatters,"eday", [[toeday(%s)]], { toeday = toeday })
+ addformatter(formatters,"eweek", [[toeweek(%s)]], { toeweek = toeweek })
+ addformatter(formatters,"eminute", [[toeminute(%s)]], { toeminute = toeminute })
+ addformatter(formatters,"esecond", [[toesecond(%s)]], { toesecond = toesecond })
- addformatter(formatters,"emonthlong", [[toemonthlong(%s)]], { toemonthlong = toemonthlong })
- addformatter(formatters,"emonthshort", [[toemonthshort(%s)]], { toemonthshort = toemonthshort })
- addformatter(formatters,"eweekday", [[toeweekday(%s)]], { toeweekday = toeweekday })
+ addformatter(formatters,"emonthlong", [[toemonthlong(%s)]], { toemonthlong = toemonthlong })
+ addformatter(formatters,"emonthshort", [[toemonthshort(%s)]], { toemonthshort = toemonthshort })
+ addformatter(formatters,"edaylong", [[toedaylong(%s)]], { toedaylong = toedaylong })
+ addformatter(formatters,"edayshort", [[toedayshort(%s)]], { toedayshort = toedayshort })
+ addformatter(formatters,"eweekday", [[toeweekday(%s)]], { toeweekday = toeweekday })
- addformatter(formatters,"edate", [[toedate(%s,%s)]], { toedate = toedate })
+ addformatter(formatters,"edate", [[toedate(%s,%s)]], { toedate = toedate })
end
@@ -1346,17 +1658,27 @@ local spaced = {
[v_day] = true,
[v_weekday] = true,
[v_WEEKDAY] = true,
- [v_day] = true,
}
local dateconverters = {
+ ["hebrew:to"] = gregorian_to_hebrew,
["jalali:to"] = gregorian_to_jalali,
["jalali:from"] = jalali_to_gregorian,
}
local variants = {
- mnem = monthmnems,
- jalali = setmetatableindex(function(t,k) return months[k] .. ":jalali" end),
+ mnem = {
+ month = monthmnems,
+ day = daymnems,
+ },
+ hebrew = {
+ month = setmetatableindex(function(t,k) return months[k] .. ":hebrew" end),
+ day = setmetatableindex(function(t,k) return days [k] .. ":hebrew" end),
+ },
+ jalali = {
+ month = setmetatableindex(function(t,k) return months[k] .. ":jalali" end),
+ day = setmetatableindex(function(t,k) return days [k] .. ":jalali" end),
+ },
}
do
@@ -1386,9 +1708,7 @@ do
elseif plus == "++" or plus == "highord" then
ordinal = true
highordinal = true
- -- elseif plus == "mnem" then
- -- mnemonic = true
- elseif plus then -- elseif plus == "mnem" then
+ elseif plus then -- mnem MNEM etc
mnemonic = variants[plus]
end
if not auto and spaced[tag] then
@@ -1396,34 +1716,58 @@ do
end
auto = false
if tag == v_year or tag == "y" or tag == "Y" then
- context(year)
+ if plus then
+ plus = converters[plus]
+ end
+ if plus then
+ context(plus(year))
+ elseif currentlanguage == false then
+ context(year)
+ else
+ ctx_convertnumber(v_year,year)
+ end
elseif tag == "yy" or tag == "YY" then
context("%02i",year % 100)
elseif tag == v_month or tag == "m" then
if currentlanguage == false then
context(Word(months[month]))
- elseif mnemonic then
- ctx_labeltext(variables[mnemonic[month]])
else
- ctx_labeltext(variables[months[month]])
+ if type(mnemonic) == "table" then
+ mnemonic = mnemonic.month
+ end
+ if mnemonic then
+ ctx_labeltext(variables[mnemonic[month]])
+ else
+ ctx_labeltext(variables[months[month]])
+ end
end
elseif tag == v_MONTH then
if currentlanguage == false then
context(Word(variables[months[month]]))
- elseif mnemonic then
- ctx_LABELTEXT(variables[mnemonic[month]])
else
- ctx_LABELTEXT(variables[months[month]])
+ if type(mnemonic) == "table" then
+ mnemonic = mnemonic.month
+ end
+ if mnemonic then
+ ctx_LABELTEXT(variables[mnemonic[month]])
+ else
+ ctx_LABELTEXT(variables[months[month]])
+ end
end
elseif tag == "mm" then
context("%02i",month)
elseif tag == "M" then
context(month)
elseif tag == v_day or tag == "d" then
- if currentlanguage == false then
+ if plus then
+ plus = converters[plus]
+ end
+ if plus then
+ context(plus(day))
+ elseif currentlanguage == false then
context(day)
else
- ctx_convertnumber(v_day,day) -- why not direct
+ ctx_convertnumber(v_day,day)
end
whatordinal = day
elseif tag == "dd" then
@@ -1437,14 +1781,28 @@ do
if currentlanguage == false then
context(Word(days[wd]))
else
- ctx_labeltext(variables[days[wd]])
+ if type(mnemonic) == "table" then
+ mnemonic = mnemonic.day
+ end
+ if mnemonic then
+ ctx_labeltext(variables[mnemonic[wd]])
+ else
+ ctx_labeltext(variables[days[wd]])
+ end
end
elseif tag == v_WEEKDAY then
local wd = weekday(day,month,year)
if currentlanguage == false then
context(Word(days[wd]))
else
- ctx_LABELTEXT(variables[days[wd]])
+ if type(mnemonic) == "table" then
+ mnemonic = mnemonic.day
+ end
+ if mnemonic then
+ ctx_LABELTEXT(variables[mnemonic[wd]])
+ else
+ ctx_LABELTEXT(variables[days[wd]])
+ end
end
elseif tag == "W" then
context(weekday(day,month,year))
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-con.mkiv b/Master/texmf-dist/tex/context/base/mkiv/core-con.mkiv
index b73280d00f1..616ed199640 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-con.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-con.mkiv
@@ -76,6 +76,9 @@
\def\abjadnodotnumerals#1{\clf_abjadnodotnumerals\numexpr#1\relax}
\def\abjadnaivenumerals#1{\clf_alphabetic \numexpr#1\relax{arabic}} % okay?
+\def\hebrewnumerals #1{\clf_hebrewnumerals\numexpr#1\relax}
+\let\yiddishnumerals \hebrewnumerals
+
\def\languagecharacters#1{\clf_alphabetic\numexpr#1\relax{\currentlanguage}} % new
\def\languageCharacters#1{\clf_Alphabetic\numexpr#1\relax{\currentlanguage}} % new
@@ -210,6 +213,8 @@
\unexpanded\def\monthlong #1{\clf_monthname\numexpr#1\relax}
\unexpanded\def\monthshort#1{\clf_monthmnem\numexpr#1\relax}
+\unexpanded\def\daylong #1{\clf_dayname\numexpr#1\relax}
+\unexpanded\def\dayshort #1{\clf_daymnem\numexpr#1\relax}
\let\convertmonth\monthlong % for old times sake
@@ -218,11 +223,15 @@
%D \showsetup{month}
%D \showsetup{MONTH}
+\pushoverloadmode
+
\let\month\monthlong
-\unexpanded\def\MONTH #1{\WORD{\month {#1}}}
-\unexpanded\def\MONTHLONG #1{\WORD{\monthlong {#1}}}
-\unexpanded\def\MONTHSHORT#1{\WORD{\monthshort{#1}}}
+\popoverloadmode
+
+\unexpanded\def\MONTH #1{\WORD{\clf_monthname\numexpr#1\relax}}
+\unexpanded\def\MONTHLONG #1{\WORD{\clf_monthname\numexpr#1\relax}}
+\unexpanded\def\MONTHSHORT#1{\WORD{\clf_monthmnem\numexpr#1\relax}}
%D We never explicitly needed this, but Tobias Burnus pointed out that it would be
%D handy to convert to the day of the week. In doing so, we have to calculate the
@@ -242,8 +251,10 @@
%D \showsetup{weekday}
%D \showsetup{WEEKDAY}
-\unexpanded\def\weekday#1{\clf_dayname\numexpr#1\relax}
-\unexpanded\def\WEEKDAY#1{\WORD{\clf_dayname\numexpr#1\relax}}
+\unexpanded\def\weekday #1{\clf_dayname\numexpr#1\relax}
+\unexpanded\def\WEEKDAY #1{\WORD{\clf_dayname\numexpr#1\relax}}
+\unexpanded\def\DAYLONG #1{\WORD{\clf_dayname\numexpr#1\relax}}
+\unexpanded\def\DAYSHORT#1{\WORD{\clf_daymnem\numexpr#1\relax}}
%D \macros
%D {getdayoftheweek, dayoftheweek}
@@ -407,8 +418,28 @@
%D \stopbuffer
%D
%D \typebuffer \getbuffer
+%D
+%D Some indirectness and abstraction:
+%D
+%D \starttyping
+%D \definedate[crap][year]
+%D \currentdate[crap]
+%D \stoptyping
+
+\installcorenamespace{date}
-\newtoks \everycurrentdate
+\unexpanded\def\definedate
+ {\dodoubleargument\syst_converters_define_date}
+
+\def\syst_converters_define_date[#1][#2]%
+ {\setvalue{\??date#1}{#2}}
+
+\def\syst_converters_check_date_specification#1%
+ {\ifcsname\??date#1\endcsname
+ \edef#1{\lastnamedcs}%
+ \fi}
+
+\newtoks\everycurrentdate
\unexpanded\def\currentdate
{\dosingleempty\syst_converters_current_date}
@@ -417,8 +448,11 @@
{\dontleavehmode
\begingroup
\the\everycurrentdate
+ \edef\forceddatespecification{#1}%
+ \syst_converters_check_date_specification\forceddatespecification
+ \syst_converters_check_date_specification\currentdatespecification
\clf_currentdate
- {#1}{\currentdatespecification}{\labellanguage}%
+ {\forceddatespecification}{\currentdatespecification}{\labellanguage}%
\normalyear\normalmonth\normalday
\endgroup}
@@ -433,16 +467,22 @@
\letdummyparameter\c!m\normalmonth
\letdummyparameter\c!y\normalyear
\getdummyparameters[#1]%
+ \edef\p_d{\directdummyparameter\c!d}%
+ \edef\p_m{\directdummyparameter\c!m}%
+ \edef\p_y{\directdummyparameter\c!y}%
\normalexpanded
{\endgroup
- \normalday \number\directdummyparameter\c!d\relax
- \normalmonth\number\directdummyparameter\c!m\relax
- \normalyear \number\directdummyparameter\c!y\relax}%
+ \ifx\p_d\empty\else\normalday \number\directdummyparameter\c!d\relax\fi
+ \ifx\p_m\empty\else\normalmonth\number\directdummyparameter\c!m\relax\fi
+ \ifx\p_y\empty\else\normalyear \number\directdummyparameter\c!y\relax\fi}%
\fi
\begingroup
\the\everycurrentdate
+ \edef\forceddatespecification{#2}%
+ \syst_converters_check_date_specification\forceddatespecification
+ \syst_converters_check_date_specification\currentdatespecification
\clf_currentdate
- {#2}{\currentdatespecification}{\labellanguage}%
+ {\forceddatespecification}{\currentdatespecification}{\labellanguage}%
\normalyear\normalmonth\normalday
\endgroup}
@@ -627,8 +667,10 @@
\def\ordinalnumber #1{\clf_ordinal\numexpr#1\relax{\currentlanguage}}
\def\Ordinalnumber #1{\Words{\clf_ordinal\numexpr#1\relax{\currentlanguage}}}
-\def\verbosenumber #1{\clf_verbose\numexpr#1\relax{\currentlanguage}}
-\def\VerboseNumber #1{\Words{\clf_verbose\numexpr#1\relax{\currentlanguage}}}
+\let\verbosenumberconnector\space
+
+\def\verbosenumber #1{\clf_verbose\numexpr#1\relax{\currentlanguage}{\verbosenumberconnector}}
+\def\VerboseNumber #1{\Words{\clf_verbose\numexpr#1\relax{\currentlanguage}{\verbosenumberconnector}}}
%D As longs as symbols are linked to levels or numbers, we can also use the
%D conversion mechanism, but in for instance the itemization macros, we prefer
@@ -705,6 +747,12 @@
\defineconversion [abjadnodotnumerals] [\abjadnodotnumerals]
\defineconversion [abjadnaivenumerals] [\abjadnaivenumerals]
+\defineconversion [hebrewnumerals] [\hebrewnumerals]
+\defineconversion [yiddishnumerals] [\yiddishnumerals]
+
+% users can do: \defineconversion [he] [\hebrewnumerals]
+% users can do: \defineconversion [yi] [\hebrewnumerals]
+
\defineconversion [thainumerals] [\thainumerals]
\defineconversion [devanagarinumerals] [\devanagarinumerals]
\defineconversion [gurmurkhinumerals] [\gurmurkhinumerals]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-dat.mkiv b/Master/texmf-dist/tex/context/base/mkiv/core-dat.mkiv
index 9f4344b99d4..41a84c3e61a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-dat.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-dat.mkiv
@@ -77,9 +77,12 @@
\installcommandhandler \??pagestate {pagestate} \??pagestate
+% \def\syst_pagestates_allocate
+% {\expandafter\newcount\csname\??pagestatecounter\currentpagestate\endcsname
+% \expandafter\let\expandafter\c_syst_pagestate\csname\??pagestatecounter\currentpagestate\endcsname}
+
\def\syst_pagestates_allocate
- {\expandafter\newcount\csname\??pagestatecounter\currentpagestate\endcsname
- \expandafter\let\expandafter\c_syst_pagestate\csname\??pagestatecounter\currentpagestate\endcsname}
+ {\expandafter\newcount\csname\??pagestatecounter\currentpagestate\endcsname}
\appendtoks
\syst_pagestates_allocate
@@ -91,19 +94,37 @@
\unexpanded\def\setpagestate
{\dodoubleempty\syst_pagestates_set}
+% \def\syst_pagestates_set[#1][#2]%
+% {\begingroup
+% \edef\currentpagestate{#1}%
+% \ifcsname\??pagestatecounter\currentpagestate\endcsname
+% \let\c_syst_pagestate\lastnamedcs
+% \else
+% \syst_pagestates_allocate
+% \fi
+% \global\advance\c_syst_pagestate\plusone
+% \scratchcounter\lastnamedcs
+% \clf_setpagestate
+% name {\currentpagestate}%
+% tag {\ifsecondargument#2\else\number\c_syst_pagestate\fi}%
+% delay {\pagestateparameter\c!delay}%
+% \relax
+% \endgroup}
+
\def\syst_pagestates_set[#1][#2]%
{\begingroup
\edef\currentpagestate{#1}%
\ifcsname\??pagestatecounter\currentpagestate\endcsname
- \let\c_syst_pagestate\lastnamedcs
+ \scratchcounter\lastnamedcs
+ \advance\scratchcounter\plusone
\else
+ \scratchcounter\plusone
\syst_pagestates_allocate
\fi
- \global\advance\c_syst_pagestate\plusone
- \scratchcounter\lastnamedcs
+ \global\csname\??pagestatecounter\currentpagestate\endcsname\scratchcounter
\clf_setpagestate
name {\currentpagestate}%
- tag {\ifsecondargument#2\else\number\c_syst_pagestate\fi}%
+ tag {\ifsecondargument#2\else\number\scratchcounter\fi}%
delay {\pagestateparameter\c!delay}%
\relax
\endgroup}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-def.mkiv b/Master/texmf-dist/tex/context/base/mkiv/core-def.mkiv
index d10527d7bc7..b09d5b28f30 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-def.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-def.mkiv
@@ -145,7 +145,9 @@
% temporary here:
-\unexpanded\def\arg{\mathortext\normalmatharg\normaltextarg}
+\pushoverloadmode
+ \frozen\unexpanded\def\arg{\mathortext\normalmatharg\normaltextarg}
+\popoverloadmode
% might move to \everydump or even disappear:
@@ -172,6 +174,6 @@
%D Till we fixed all styles:
-\let\\=\crlf
+\enforced\let\\\crlf % frozen or permanent?
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-env.lua b/Master/texmf-dist/tex/context/base/mkiv/core-env.lua
index 50759dd1941..1c5165ac891 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-env.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-env.lua
@@ -47,12 +47,12 @@ local cache = tokens.cache
local iftrue = cache["iftrue"].mode
-local dimencode = cache["scratchdimen"] .command
-local countcode = cache["scratchcounter"] .command
-local tokencode = cache["scratchtoken"] .command
-local skipcode = cache["scratchskip"] .command
-local muskipcode = cache["scratchmuskip"] .command
------ attributecode = cache["scratchattribute"].command
+local dimencode = cache["scratchdimen"] .command -- tokens.commands.register_dimen
+local countcode = cache["scratchcounter"].command -- tokens.commands.register_int
+local tokencode = cache["scratchtoks"] .command -- tokens.commands.register_toks
+local skipcode = cache["scratchskip"] .command -- tokens.commands.register_glue
+local muskipcode = cache["scratchmuskip"] .command -- tokens.commands.register_mu_glue
+local conditioncode = cache["iftrue"] .command -- tokens.commands.if_test
local types = {
[dimencode] = "dimen",
@@ -61,6 +61,7 @@ local types = {
[skipcode] = "skip",
[muskipcode] = "muskip",
-- [attributecode] = "attribute",
+ [conditioncode] = "condition"
}
setmetatableindex(texmodes, function(t,k)
@@ -80,10 +81,6 @@ setmetatableindex(texmodes, function(t,k)
end
end)
-setmetatablenewindex(texmodes, function(t,k)
- report_mode("you cannot set the %s named %a this way","mode",k)
-end)
-
setmetatableindex(texsystemmodes, function(t,k)
local m = systemmodes[k]
if m then
@@ -98,30 +95,39 @@ setmetatableindex(texsystemmodes, function(t,k)
end
end
end)
-setmetatablenewindex(texsystemmodes, function(t,k)
- report_mode("you cannot set the %s named %a this way","systemmode",k)
+
+do -- we could do the same as in lmtx (use the mode)
+
+ local trialtypesettingstate = createtoken("trialtypesettingstate").index
+ local texgetcount = tex.getcount
+
+ context.settrialtypesettingmethod(function()
+ return texgetcount(trialtypesettingstate) ~= 0
+ end)
+
+end
+
+setmetatablenewindex(texmodes, function(t,k) report_mode("you cannot set the %s named %a this way","mode", k) end)
+setmetatablenewindex(texsystemmodes, function(t,k) report_mode("you cannot set the %s named %a this way","systemmode", k) end)
+setmetatablenewindex(texconstants, function(t,k) report_mode("you cannot set the %s named %a this way","constant", k) end)
+setmetatablenewindex(texconditionals, function(t,k) report_mode("you cannot set the %s named %a this way","conditional",k) end)
+setmetatablenewindex(texifs, function(t,k) end)
+
+setmetatablenewindex(texifs, function(t,k)
+ -- just ignore
end)
setmetatableindex(texconstants, function(t,k)
return cache[k].mode ~= 0 and texgetcount(k) or 0
end)
-setmetatablenewindex(texconstants, function(t,k)
- report_mode("you cannot set the %s named %a this way","constant",k)
-end)
setmetatableindex(texconditionals, function(t,k) -- 0 == true
return cache[k].mode ~= 0 and texgetcount(k) == 0
end)
-setmetatablenewindex(texconditionals, function(t,k)
- report_mode("you cannot set the %s named %a this way","conditional",k)
-end)
-table.setmetatableindex(texifs, function(t,k)
+setmetatableindex(texifs, function(t,k)
return cache[k].mode == iftrue
end)
-setmetatablenewindex(texifs, function(t,k)
- -- just ignore
-end)
tex.isdefined = isdefined
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-env.mkiv b/Master/texmf-dist/tex/context/base/mkiv/core-env.mkiv
index 09de435e7c0..0f042f81512 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-env.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-env.mkiv
@@ -17,7 +17,7 @@
\unprotect
-\def\wildcardsymbol{*}
+\ifdefined\wildcardsymbol \else \def\wildcardsymbol{*} \fi
%D Modes:
%D
@@ -104,10 +104,14 @@
% demo: trialtypesetting is a systemmode as well as an if
+\pushoverloadmode
+
\newsystemmode{trialtypesetting}
\expandafter\let\csname\??mode\systemmodeprefix trialtypesetting\endcsname\trialtypesettingstate
+\popoverloadmode
+
\appendtoks
\trialtypesettingstate\enabledmode
\luacopyinputnodes\plusone
@@ -588,13 +592,15 @@
\def\syst_setups_start_loc{\ifsecondargument\expandafter\syst_setups_start_loc_c\else\expandafter\syst_setups_start_loc_d\fi}
\def\syst_setups_start_tex{\ifsecondargument\expandafter\syst_setups_start_tex_c\else\expandafter\syst_setups_start_tex_d\fi}
+% no need for \the\t_syst_setups_lua in the next, now too often
+
\def\syst_setups_start_lua_a{\the\t_syst_setups_lua\dodoubleempty\syst_setups_start_lua} % [ ] delimited
\def\syst_setups_start_xml_a{\the\t_syst_setups_xml\dodoubleempty\syst_setups_start_xml} % [ ] delimited
\def\syst_setups_start_raw_a{\the\t_syst_setups_raw\dodoubleempty\syst_setups_start_raw} % [ ] delimited
\def\syst_setups_start_loc_a{\the\t_syst_setups_loc\dodoubleempty\syst_setups_start_loc} % [ ] delimited
\def\syst_setups_start_tex_a{\the\t_syst_setups_tex\dodoubleempty\syst_setups_start_tex} % [ ] delimited
-% empty preserves inner {} (is removed by the \expandafter{#3})
+% empty preserves inner {} (is removed by the \expandafter{#3}) .. hm, looks old
\def\syst_setups_start_lua_b#1 {\the\t_syst_setups_lua\syst_setups_start_lua_indeed\empty{#1}\empty} % space delimited
\def\syst_setups_start_xml_b#1 {\the\t_syst_setups_xml\syst_setups_start_xml_indeed\empty{#1}\empty} % space delimited
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/core-ini.mkiv
index cb8881c223d..9352c9487e6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-ini.mkiv
@@ -47,12 +47,14 @@
%D Document:
-\newtoks \everysetupdocument
\newtoks \everyendoftextbody
\newtoks \everystarttext
\newtoks \everystoptext
+\newtoks \everystartdocument
+\newtoks \everystopdocument
+
%D Purity:
\newtoks \everyforgetall
@@ -89,7 +91,7 @@
%D Exporting:
-\newtoks\everyinitializeexport
+\newtoks \everyinitializeexport
%D Sectioning:
@@ -170,8 +172,9 @@
\newif \ifinpagebody
\newif \ifinsidecolumns
-\newif \ifdoublesided \doublesidedfalse
-\newif \ifsinglesided \singlesidedtrue
+\newif \ifinsidemulticolumns % simple mixed-in-text columns
+\newif \ifdoublesided \doublesidedfalse
+\newif \ifsinglesided \singlesidedtrue
\newif \ifinsidefloat
\newif \ifdoingblocks
\newif \ifgridsnapping
@@ -180,12 +183,15 @@
\newconstant\pageduplexmode % 0 single 1 double 2 mix
\newconstant\pagebodymode % 0 not 1 normal pagebody 2 spread
+\newcount\nofcolumns \nofcolumns \plusone
+\newcount\nofmulticolumns \nofmulticolumns\plusone
+
%D \macros
%D {ifproductionrun}
%D
%D This boolean can be used to bypass certain initializations.
-\newif\ifproductionrun
+% \newif\ifproductionrun % already defined
\appendtoks
\productionruntrue
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-lmt.lua b/Master/texmf-dist/tex/context/base/mkiv/core-lmt.lua
deleted file mode 100644
index 700ce47211e..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/core-lmt.lua
+++ /dev/null
@@ -1,34 +0,0 @@
-if not modules then modules = { } end modules ['core-lmt'] = {
- version = 1.001,
- comment = "companion to core-lmt.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-local implement = interfaces.implement
-local scankeyword = tokens.scanners.keyword
-
-local settextdir = tex.settextdir
-local setlinedir = tex.setlinedir
-local setpardir = tex.setpardir
-local setboxdir = tex.setboxdir
-
-local function scandir(what)
- if scankeyword("tlt") then
- what(0)
- elseif scankeyword("trt") then
- what(1)
- -- elseif scankeyword("rtt") then
- -- what(2)
- -- elseif scankeyword("ltl") then
- -- what(3)
- else
- what(0)
- end
-end
-
-implement { name = "textdir", public = true, protected = true, actions = function() scandir(settextdir) end }
-implement { name = "linedir", public = true, protected = true, actions = function() scandir(setlinedir) end }
-implement { name = "pardir", public = true, protected = true, actions = function() scandir(setpardir) end }
-implement { name = "boxdir", public = true, protected = true, actions = function() scandir(setboxdir) end }
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-lmt.mkxl b/Master/texmf-dist/tex/context/base/mkiv/core-lmt.mkxl
deleted file mode 100644
index 75a791a50d9..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/core-lmt.mkxl
+++ /dev/null
@@ -1,31 +0,0 @@
-%D \module
-%D [ file=core-lmt,
-%D version=2018.08.2,
-%D title=\CONTEXT\ System Macros,
-%D subtitle=Primitives,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt System Macros / Primitives}
-
-%D This is offered temporarily because in the end we don't expect u sers to use the
-%D low level direction directives directly.
-
-\registerctxluafile{core-lmt}{}
-
-\unprotect
-
-% nothing yet
-
-\protect \endinput
-
-% \starttext
-% abc{\textdir TRTdef}ghi
-% abc{\textdir trtdef}ghi
-% \boxdirection0=1
-% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-sys.lua b/Master/texmf-dist/tex/context/base/mkiv/core-sys.lua
index 7e9648fb845..3ab597849d3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-sys.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-sys.lua
@@ -77,13 +77,9 @@ implement { name = "outputfilename", actions = function() context(environme
statistics.register("result saved in file", function()
-- suffix will be fetched from backend
local outputfilename = environment.outputfilename or environment.jobname or tex.jobname or ""
- -- if (tex.pdfoutput or tex.outputmode) > 0 then
- return format("%s.%s, compresslevel %s, objectcompresslevel %s",outputfilename,"pdf",
- lpdf.getcompression()
- )
- -- else
- -- return format("%s.%s",outputfilename,"dvi") -- hard to imagine
- -- end
+ return lpdf and format("%s.%s, compresslevel %s, objectcompresslevel %s",outputfilename,"pdf",
+ lpdf.getcompression()
+ ) or "error"
end)
implement {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-sys.mkiv b/Master/texmf-dist/tex/context/base/mkiv/core-sys.mkiv
index 7a04df8408f..728d37908df 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-sys.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-sys.mkiv
@@ -132,10 +132,10 @@
[ \v!small=>\divide\scratchcounter 15, % 900,
\v!medium=>\divide\scratchcounter 30, % 1800,
\v!big=>\divide\scratchcounter 60, % 3600,
- \v!normal=>\getnewrandomseed\scratchcounter,
- \s!default=>\getnewrandomseed\scratchcounter,
+ \v!normal=>\scratchcounter\newrandomseed,
+ \s!default=>\scratchcounter\newrandomseed,
\s!unknown=>\scratchcounter#1]%
- \expanded{\setrandomseed{\the\scratchcounter}}%
+ \setrandomseed\scratchcounter
% \writestatus\m!system{randomseed: \the\scratchcounter}%
\endgroup}}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/core-uti.lua b/Master/texmf-dist/tex/context/base/mkiv/core-uti.lua
index 50c7bc9dc6a..887ef9a7536 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/core-uti.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/core-uti.lua
@@ -43,7 +43,7 @@ local report_passes = logs.reporter("job","passes")
job = job or { }
local job = job
-job.version = 1.31
+job.version = 1.32
job.packversion = 1.02
-- some day we will implement loading of other jobs and then we need
@@ -73,10 +73,9 @@ local enabled = true
local initialized = false
directives.register("job.save",function(v) enabled = v end)
-----------.register("job.keep",function(v) kept = v end)
-function job.disablesave() -- can be command
- enabled = false
+function job.disablesave()
+ enabled = false -- for instance called when an error
end
function job.initialize(loadname,savename)
@@ -89,10 +88,7 @@ function job.initialize(loadname,savename)
end
job.load(loadname) -- has to come after structure is defined !
luatex.registerstopactions(function()
- if enabled and not status.lasterrorstring or status.lasterrorstring == "" then
- -- if kept then
- -- job.keep(loadname) -- could move to mtx-context instead
- -- end
+ if enabled then
job.save(savename)
end
end)
@@ -396,37 +392,24 @@ statistics.register("jobdata time",function()
end
end)
--- statistics.register("callbacks", function()
--- local total, indirect = status.callbacks or 0, status.indirect_callbacks or 0
--- local pages = texgetcount('realpageno') - 1
--- if pages > 1 then
--- return format("direct: %s, indirect: %s, total: %s (%i per page)", total-indirect, indirect, total, total/pages)
--- else
--- return format("direct: %s, indirect: %s, total: %s", total-indirect, indirect, total)
--- end
--- end)
-
-function statistics.callbacks()
+statistics.register("callbacks", function()
local c_internal = status.callbacks or 0
local c_file = status.indirect_callbacks or 0
local c_direct = status.direct_callbacks or 0
- local c_late = backends.noflatelua() or 0
+ local c_late = backends.getcallbackstate().count
local c_function = status.function_callbacks or 0
local c_total = c_internal + c_file + c_direct + c_late + c_function
- local n_pages = texgetcount('realpageno') - 1
+ local n_pages = structures.pages.nofpages or 0
local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0
- local s_result = format (
- c_average > 0 and "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)"
- or "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s",
+ local result = format (
+ "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)",
c_internal, c_file, c_direct, c_late, c_function, c_total, c_average
)
statistics.callbacks = function()
- return s_result
+ return result
end
- return s_result
-end
-
-statistics.register("callbacks", statistics.callbacks)
+ return result
+end)
statistics.register("randomizer", function()
if rmethod and rvalue then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-env.lua b/Master/texmf-dist/tex/context/base/mkiv/data-env.lua
index 53f0c27cc27..3b10d89b8b4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-env.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-env.lua
@@ -94,7 +94,9 @@ local relations = allocate { -- todo: handlers also here
mp = {
names = { "mp" },
variable = 'MPINPUTS',
- suffixes = { 'mp', 'mpvi', 'mpiv', 'mpxl', 'mpii' },
+ suffixes = CONTEXTLMTXMODE > 0
+ and { 'mp', 'mpxl', 'mpvi', 'mpiv', 'mpii' }
+ or { 'mp', 'mpvi', 'mpiv', 'mpii' },
usertype = true,
},
tex = {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-fil.lua b/Master/texmf-dist/tex/context/base/mkiv/data-fil.lua
index bbcc954b2ea..8dbc8a0d2cc 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-fil.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-fil.lua
@@ -22,7 +22,7 @@ local appendhash = resolvers.appendhash
local loadcachecontent = caches.loadcontent
-local checkgarbage = utilities.garbagecollector and utilities.garbagecollector.check
+----- checkgarbage = utilities.garbagecollector and utilities.garbagecollector.check
function resolvers.locators.file(specification)
local filename = specification.filename
@@ -128,9 +128,9 @@ function loaders.file(specification,filetype)
report_files("file loader: %a loaded",filename)
end
local s = f:read("*a") -- io.readall(f) is faster but we never have large files here
- if checkgarbage then
- checkgarbage(#s)
- end
+ -- if checkgarbage then
+ -- checkgarbage(#s)
+ -- end
f:close()
if s then
return true, s, #s
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/data-ini.lua
index 2e9010085ba..6cf5669b3e7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-ini.lua
@@ -73,8 +73,9 @@ end
-- Next comes the user's home path. We need this as later on we have
-- to replace ~ with its value.
-do
+if not environment.homedir then
+ local oldhome = osgetenv('HOME')
local homedir = osgetenv(ostype == "windows" and 'USERPROFILE' or 'HOME') or ''
if not homedir or homedir == "" then
@@ -86,6 +87,7 @@ do
ossetenv("HOME", homedir) -- can be used in unix cnf files
ossetenv("USERPROFILE",homedir) -- can be used in windows cnf files
+ environment.oldhome = oldhome
environment.homedir = homedir
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua b/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
index e4795d09d18..2c1a7dbd5d1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
@@ -143,20 +143,31 @@ local function textopener(tag,filename,filehandle,coding)
lines[noflines] = nil
end
pushinputname(filename)
- local currentline, noflines = 0, noflines
- local t = {
+ local currentline = 0
+ local noflines = noflines
+ local handler = {
filename = filename,
noflines = noflines,
-- currentline = 0,
+ gotoline = function(self,n)
+ currentline = n - 1
+ if currentline <= 0 then
+ currentline = 0
+ end
+ end,
+ endoffile = function()
+ return not lines or currentline >= noflines
+ end,
close = function()
local usedname = popinputname() -- should match filename
if trace_locating then
report_tex("%a closer: %a closed",tag,filename)
end
- t = nil
+ handler = nil
+ lines = nil
end,
reader = function(self)
- self = self or t
+ self = self or handler
-- local currentline, noflines = self.currentline, self.noflines
if currentline >= noflines then
return nil
@@ -164,6 +175,7 @@ local function textopener(tag,filename,filehandle,coding)
currentline = currentline + 1
-- self.currentline = currentline
local content = lines[currentline]
+-- lines[currentline] = nil
if content == "" then
return ""
-- elseif content == ctrl_d or ctrl_z then
@@ -181,14 +193,14 @@ local function textopener(tag,filename,filehandle,coding)
end
end
}
- setmetatableindex(t,function(t,k)
+ setmetatableindex(handler,function(t,k)
if k == "currentline" then
return currentline
else
-- no such key
end
end)
- return t
+ return handler
end
helpers.settextopener(textopener) -- can only be done once
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-tmp.lua b/Master/texmf-dist/tex/context/base/mkiv/data-tmp.lua
index 9b0117c1562..9a8a586cda4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-tmp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-tmp.lua
@@ -324,7 +324,11 @@ caches.setluanames = setluanames
--
-- runtime files like fonts are written to the writable cache anyway
+local checkmemory = utilities and utilities.lua and utilities.lua.checkmemory
+local threshold = 100 -- MB
+
function caches.loaddata(readables,name,writable)
+ local used = checkmemory and checkmemory()
if type(readables) == "string" then
readables = { readables }
end
@@ -352,7 +356,11 @@ function caches.loaddata(readables,name,writable)
end
if loader then
loader = loader()
- collectgarbage("step")
+ if checkmemory then
+ checkmemory(used,threshold)
+ else -- generic
+ collectgarbage("step") -- option, really slows down!
+ end
return loader
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-use.lua b/Master/texmf-dist/tex/context/base/mkiv/data-use.lua
index 7df416b65c9..a7ca2389e99 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-use.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-use.lua
@@ -68,7 +68,7 @@ statistics.register("used cache path", function() return caches.usedpaths() end
-- experiment (code will move)
-function statistics.savefmtstatus(texname,formatbanner,sourcefile,kind,banner) -- texname == formatname
+function statistics.savefmtstatus(texname,formatbanner,sourcefile,banner) -- texname == formatname
local enginebanner = status.banner
if formatbanner and enginebanner and sourcefile then
local luvname = file.replacesuffix(texname,"luv") -- utilities.lua.suffixes.luv
diff --git a/Master/texmf-dist/tex/context/base/mkiv/driv-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/driv-ini.lua
index 316613b2167..1e19fd5f887 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/driv-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/driv-ini.lua
@@ -6,6 +6,10 @@ if not modules then modules = { } end modules ['driv-ini'] = {
license = "see context related readme files"
}
+-- This file is a bit overkill because it was meant for both luatex and luametatex
+-- but after the splti I decided not to simplify this one. It can only introduce
+-- issues.
+
local type = type
local addsuffix = file.addsuffix
diff --git a/Master/texmf-dist/tex/context/base/mkiv/driv-ini.mkxl b/Master/texmf-dist/tex/context/base/mkiv/driv-ini.mkxl
deleted file mode 100644
index 9f489a2a1a6..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/driv-ini.mkxl
+++ /dev/null
@@ -1,20 +0,0 @@
-%D \module
-%D [ file=driv-ini,
-%D version=2018.07.26,
-%D title=\CONTEXT\ Driver Macros,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Driver Macros / Initialization}
-
-\registerctxluafile{driv-ini}{}
-
-\unprotect
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/driv-shp.lua b/Master/texmf-dist/tex/context/base/mkiv/driv-shp.lua
deleted file mode 100644
index 5cf7cfcc614..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/driv-shp.lua
+++ /dev/null
@@ -1,1324 +0,0 @@
-if not modules then modules = { } end modules ['driv-shp'] = {
- version = 1.001,
- comment = "companion to driv-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-local type, next = type, next
-local round = math.round
-
-local setmetatableindex = table.setmetatableindex
-local formatters = string.formatters
-local concat = table.concat
-local keys = table.keys
-local sortedhash = table.sortedhash
-local splitstring = string.split
-local idiv = number.idiv
-local extract = bit32.extract
-local nuts = nodes.nuts
-
-local tonut = nodes.tonut
-local tonode = nodes.tonode
-
-local getdirection = nuts.getdirection
-local getlist = nuts.getlist
-local getoffsets = nuts.getoffsets
-local getorientation = nuts.getorientation
-local getfield = nuts.getfield
-local getwhd = nuts.getwhd
-local getkern = nuts.getkern
-local getheight = nuts.getheight
-local getdepth = nuts.getdepth
------ getwidth = nuts.getwidth
-local getnext = nuts.getnext
-local getsubtype = nuts.getsubtype
-local getid = nuts.getid
-local getleader = nuts.getleader
------ getglue = nuts.getglue
-local getshift = nuts.getshift
-local getdata = nuts.getdata
------ getexpansion = nuts.getexpansion
-local getreplace = nuts.getreplace
-local setreplace = nuts.setreplace
-local getfont = nuts.getfont
-
-local setdirection = nuts.setdirection
-local setfield = nuts.setfield
-local setlink = nuts.setlink
-
-local isglyph = nuts.isglyph
-local findtail = nuts.tail
-local nextdir = nuts.traversers.dir
-local nextnode = nuts.traversers.node
-
-local rangedimensions = node.direct.rangedimensions -- nuts ?
-local effectiveglue = nuts.effective_glue
-local start_of_par = nuts.start_of_par
-local dirdimensions = nuts.dirdimensions
-
-local texget = tex.get
-
-local fonthashes = fonts.hashes
-local fontdata = fonthashes.identifiers
-local characters = fonthashes.characters
-local parameters = fonthashes.parameters
-
-local nodecodes = nodes.nodecodes
-local whatsitcodes = nodes.whatsitcodes
-local leadercodes = nodes.leadercodes
-local gluecodes = nodes.gluecodes
-local dircodes = nodes.dircodes
-local dirvalues = nodes.dirvalues
-local subtypes = nodes.subtypes
-
-local normaldir_code = dircodes.normal
-
-local lefttoright_code = dirvalues.lefttoright
-local righttoleft_code = dirvalues.righttoleft
-
-local glyph_code = nodecodes.glyph
-local kern_code = nodecodes.kern
-local glue_code = nodecodes.glue
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local dir_code = nodecodes.dir
-local disc_code = nodecodes.disc
-local math_code = nodecodes.math
-local rule_code = nodecodes.rule
-local whatsit_code = nodecodes.whatsit
------ penalty_code = nodecodes.penalty
------ boundary_code = nodecodes.boundary
-
-local leaders_code = leadercodes.leaders
-local cleaders_code = leadercodes.cleaders
-local xleaders_code = leadercodes.xleaders
-local gleaders_code = leadercodes.gleaders
-
-local spaceskip_code = gluecodes.spaceskip
-
-local saveposwhatsit_code = whatsitcodes.savepos
-local userdefinedwhatsit_code = whatsitcodes.userdefined
-local openwhatsit_code = whatsitcodes.open
-local writewhatsit_code = whatsitcodes.write
-local closewhatsit_code = whatsitcodes.close
-local lateluawhatsit_code = whatsitcodes.latelua
-local literalwhatsit_code = whatsitcodes.literal
-local setmatrixwhatsit_code = whatsitcodes.setmatrix
-local savewhatsit_code = whatsitcodes.save
-local restorewhatsit_code = whatsitcodes.restore
-
-local getpagedimensions getpagedimensions = function()
- getpagedimensions = backends.codeinjections.getpagedimensions
- return getpagedimensions()
-end
-
-local drivers = drivers
-local instances = drivers.instances
-
-local report = logs.reporter("drivers")
-
----------------------------------------------------------------------------------------
-
-local lastfont = nil
-local fontcharacters = nil
-
-local magicconstants = tex.magicconstants
-local trueinch = magicconstants.trueinch
-local maxdimen = magicconstants.maxdimen
-local running = magicconstants.running
-
-local pos_h = 0
-local pos_v = 0
-local pos_r = lefttoright_code
-local shippingmode = "none"
-
-local abs_max_v = 0
-local abs_max_h = 0
-
-local shipbox_h = 0
-local shipbox_v = 0
-local page_size_h = 0
-local page_size_v = 0
------ page_h_origin = 0 -- trueinch
------ page_v_origin = 0 -- trueinch
-
-local initialize
-local finalize
-local updatefontstate
-local pushorientation
-local poporientation
-local flushcharacter
-local flushfontchar
-local flushrule
-local flushliteral
-local flushsetmatrix
-local flushsave
-local flushrestore
-local flushspecial
------ flushimage
-
--- make local
-
-function drivers.getpos () return round(pos_h), round(pos_v) end
-function drivers.getrpos() return round(pos_h), round(pos_v), pos_r end
-function drivers.gethpos() return round(pos_h) end
-function drivers.getvpos() return round(pos_v) end
-
--- characters
-
-local flush_character
-
-local stack = setmetatableindex("table")
-local level = 0
-local nesting = 0
-local main = 0
-
--- experiment (smaller page stream but might be fragile)
-
-local tospace = false directives.register("backends.spaces", function(v) tospace = v end)
-
--- todo: cache streams
-
-local function flush_vf_packet(pos_h,pos_v,pos_r,font,char,data,factor,vfcommands)
-
- if nesting > 100 then
- return
- elseif nesting == 0 then
- main = font
- end
-
- nesting = nesting + 1
-
- local saved_h = pos_h
- local saved_v = pos_v
- local saved_r = pos_r
- pos_r = lefttoright_code
-
- local data = fontdata[font]
- local fnt = font
- local fonts = data.fonts
- local siz = (data.parameters.factor or 1)/65536
-
- local function flushchar(font,char,fnt,chr,f,e)
- if fnt then
- local nest = char ~= chr or font ~= fnt
- if fnt == 0 then
- fnt = main
- end
- return flush_character(false,fnt,chr,factor,nest,pos_h,pos_v,pos_r,f,e)
- else
- return 0
- end
- end
-
- -- we assume resolved fonts: id mandate but maybe also size
-
- for i=1,#vfcommands do
- local packet = vfcommands[i]
- local command = packet[1]
- if command == "char" then
- local chr = packet[2]
- local f = packet[3]
- local e = packet[4]
- pos_h = pos_h + flushchar(font,char,fnt,chr,f,e)
- elseif command == "slot" then
- local index = packet[2]
- local chr = packet[3]
- local f = packet[4]
- local e = packet[5]
- if index == 0 then
- pos_h = pos_h + flushchar(font,char,font,chr,f,e)
- else
- local okay = fonts and fonts[index]
- if okay then
- local fnt = okay.id
- if fnt then
- pos_h = pos_h + flushchar(font,char,fnt,chr,f,e)
- end
- else
- -- safeguard, we assume the font itself (often index 1)
- pos_h = pos_h + flushchar(font,char,font,chr,f,e)
- end
- end
- elseif command == "use" then
- local index = packet[2]
- if index then
- local fnt
- if index == 0 then
- fnt = font
- else
- local okay = fonts and fonts[index]
- if okay then
- fnt = okay.id
- end
- end
- if fnt then
- -- not efficient but ok for now as experiment
- local d = characters[fnt]
- if d then
- for i=3,#packet do
- local chr = packet[i]
- local dat = d[chr]
- if dat then
- flushfontchar(fnt,chr,dat)
- end
- end
- end
- end
- end
- elseif command == "right" then
- local h = packet[2] -- * siz
- if factor ~= 0 and h ~= 0 then
- h = h + h * factor / 1000 -- expansion
- end
- pos_h = pos_h + h
- elseif command == "down" then
- local v = packet[2] -- * siz
- pos_v = pos_v - v
- elseif command == "push" then
- level = level + 1
- local s = stack[level]
- s[1] = pos_h
- s[2] = pos_v
- elseif command == "pop" then
- if level > 0 then
- local s = stack[level]
- pos_h = s[1]
- pos_v = s[2]
- level = level - 1
- end
- elseif command == "pdf" then
- flushliteral(false,pos_h,pos_v,packet[2],packet[3])
- elseif command == "rule" then
- local size_v = packet[2]
- local size_h = packet[3]
- if factor ~= 0 and size_h > 0 then
- size_h = size_h + size_h * factor / 1000
- end
- if size_h > 0 and size_v > 0 then
- flushsimplerule(pos_h,pos_v,pos_r,size_h,size_v)
- pos_h = pos_h + size_h
- end
- elseif command == "font" then
- local index = packet[2]
- local okay = fonts and fonts[index]
- if okay then
- fnt = okay.id or fnt -- or maybe just return
- end
- elseif command == "lua" then
- local code = packet[2]
- if type(code) ~= "function" then
- code = loadstring(code)
- end
- if type(code) == "function" then
- code(font,char,pos_h,pos_v)
- end
- elseif command == "node" then
- local h = packet[2]
- hlist_out(h,getlist(h))
- elseif command == "image" then
- -- doesn't work because intercepted by engine so we use a different
- -- mechanism (for now)
- local image = packet[2]
- -- to do
- elseif command == "pdfmode" then
- -- doesn't happen
- -- elseif command == "special" then
- -- -- not supported
- -- elseif command == "nop" then
- -- -- nothing to do|
- -- elseif command == "scale" then
- -- -- not supported
- end
- end
-
- pos_h = saved_h
- pos_v = saved_v
- pos_r = saved_r
-
- nesting = nesting - 1
-end
-
-local onetimemessage -- could be defined later (todo: make plug for this)
-
-flush_character = function(current,font,char,factor,vfcommands,pos_h,pos_v,pos_r,f,e)
-
- if font ~= lastfont then
- lastfont = font
- fontcharacters = characters[font]
- updatefontstate(font)
- end
-
- local data = fontcharacters[char]
- if not data then
- if char > 0 then
- if not onetimemessage then
- onetimemessage = fonts.loggers.onetimemessage
- end
- onetimemessage(font,char,"missing")
- end
- return 0, 0, 0
- end
-
- local width, height, depth, naturalwidth
- if current then
- naturalwidth, height, depth, factor = getwhd(current,true) -- also get corrected width
- if factor == 0 then
- width = naturalwidth
- else
- -- width = (1.0 + factor/1000000.0) * naturalwidth
- width = naturalwidth + naturalwidth * factor/1000000.0
- -- width = naturalwidth + naturalwidth * 0.000001 * factor
- end
- else
- width = data.width or 0
- height = data.height or 0
- depth = data.depth or 0
- naturalwidth = width
- if not factor then
- factor = 0
- end
- end
-
- if pos_r == righttoleft_code then
- pos_h = pos_h - width
- end
- if vfcommands then
- vfcommands = data.commands
- end
- if vfcommands then
- flush_vf_packet(pos_h,pos_v,pos_r,font,char,data,factor,vfcommands) -- also f ?
- else
- -- kind of messy that we do orientation here and offsets elsewhere
- local orientation = data.orientation
- if orientation and (orientation == 1 or orientation == 3) then
- local x = data.xoffset
- local y = data.yoffset
- if x then
- pos_h = pos_h + x
- end
- if y then
- pos_v = pos_v + y
- end
- pushorientation(orientation,pos_h,pos_v)
- flushcharacter(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor) -- ,naturalwidth,width)
- poporientation(orientation,pos_h,pos_v)
- else
- flushcharacter(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor) -- ,naturalwidth,width)
- end
- end
- return width, height, depth
-end
-
--- end of characters
-
-local function reset_state()
- pos_h = 0
- pos_v = 0
- pos_r = lefttoright_code
- shipbox_h = 0
- shipbox_v = 0
- shippingmode = "none"
- page_size_h = 0
- page_size_v = 0
- -- page_h_origin = 0 -- trueinch
- -- page_v_origin = 0 -- trueinch
-end
-
--- local function dirstackentry(t,k)
--- local v = {
--- cur_h = 0,
--- cur_v = 0,
--- ref_h = 0,
--- ref_v = 0,
--- }
--- t[k] = v
--- return v
--- end
-
------ dirstack = { }
-local dirstack = setmetatableindex(dirstackentry)
-
-local function reset_dir_stack()
- -- dirstack = setmetatableindex(dirstackentry)
- dirstack = { }
-end
-
-local function flushlatelua(current,h,v)
- return backends.latelua(current,h,v)
-end
-
-local function flushwriteout(current)
- if not doing_leaders then
- backends.writeout(current)
- end
-end
-
-local function flushopenout(current)
- if not doing_leaders then
- backends.openout(current)
- end
-end
-
-local function flushcloseout(current)
- if not doing_leaders then
- backends.closeout(current)
- end
-end
-
-local hlist_out, vlist_out do
-
- local function applyanchor(orientation,x,y,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
- local ot = extract(orientation, 0,4)
- local ay = extract(orientation, 4,4)
- local ax = extract(orientation, 8,4)
- local of = extract(orientation,12,4)
- if ot == 4 then
- ot, ay = 0, 1
- elseif ot == 5 then
- ot, ay = 0, 2
- end
- if ot == 0 or ot == 2 then
- if ax == 1 then x = x - width
- elseif ax == 2 then x = x + width
- elseif ax == 3 then x = x - width/2
- elseif ax == 4 then x = x + width/2
- end
- if ot == 2 then
- doffset, hoffset = hoffset, doffset
- end
- if ay == 1 then y = y - doffset
- elseif ay == 2 then y = y + hoffset
- elseif ay == 3 then y = y + (doffset + hoffset)/2 - doffset
- end
- elseif ot == 1 or ot == 3 then
- if ay == 1 then y = y - height
- elseif ay == 2 then y = y + height
- elseif ay == 3 then y = y - height/2
- end
- if ot == 1 then
- doffset, hoffset = hoffset, doffset
- end
- if ax == 1 then x = x - width
- elseif ax == 2 then x = x + width
- elseif ax == 3 then x = x - width/2
- elseif ax == 4 then x = x + width/2
- elseif ax == 5 then x = x - hoffset
- elseif ax == 6 then x = x + doffset
- end
- end
- return ot, x + xoffset, y - yoffset
- end
-
- -- to be checked: begin- or enddir kan nil zijn, weird
-
- -- local function calculate_width_to_enddir(this_box,begindir) -- can be a helper
- -- local dir_nest = 1
- -- local enddir = begindir
- -- for current, subtype in nextdir, getnext(begindir) do
- -- if subtype == normaldir_code then -- todo
- -- dir_nest = dir_nest + 1
- -- else
- -- dir_nest = dir_nest - 1
- -- end
- -- if dir_nest == 0 then -- does the type matter
- -- enddir = current
- -- local width = rangedimensions(this_box,begindir,enddir)
- -- return enddir, width
- -- end
- -- end
- -- if enddir == begindir then
- -- local width = rangedimensions(this_box,begindir) -- ,enddir)
- -- return enddir, width
- -- end
- -- return enddir, 0
- -- end
-
- -- check frequencies of nodes
-
- hlist_out = function(this_box,current)
- local outer_doing_leaders = false
-
- local ref_h = pos_h
- local ref_v = pos_v
- local ref_r = pos_r
- pos_r = getdirection(this_box)
- local boxwidth,
- boxheight,
- boxdepth = getwhd(this_box)
-
- local cur_h = 0
- local cur_v = 0
-
- -- if not current then
- -- current = getlist(this_box)
- -- end
-
- -- we can encounter localpar, boundary and penalty nodes but a special
- -- iterator over content nodes won't save much
-
- for current, id, subtype in nextnode, current do
- if id == glyph_code then
- local char, font = isglyph(current)
- local x_offset, y_offset = getoffsets(current)
- if x_offset ~= 0 or y_offset ~= 0 then
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + x_offset)
- else
- pos_h = ref_h + (cur_h + x_offset)
- end
- pos_v = ref_v - (cur_v - y_offset)
- -- synced
- end
- local wd = flush_character(current,font,char,false,true,pos_h,pos_v,pos_r)
- cur_h = cur_h + wd
- elseif id == glue_code then
- local gluewidth = effectiveglue(current,this_box)
- if gluewidth ~= 0 then
- if subtype >= leaders_code then
- local leader = getleader(current)
- if leader then
- local width, height, depth = getwhd(leader)
- if getid(leader) == rule_code then
- if gluewidth > 0 then
- if height == running then
- height = boxheight
- end
- if depth == running then
- depth = boxdepth
- end
- local total = height + depth
- if total > 0 then
- if pos_r == righttoleft_code then
- pos_h = pos_h - gluewidth
- end
- pos_v = pos_v - depth
- flushrule(leader,pos_h,pos_v,pos_r,gluewidth,total,getsubtype(leader))
- end
- cur_h = cur_h + gluewidth
- end
- elseif width > 0 and gluewidth > 0 then
- local boxdir = getdirection(leader) or lefttoright_code
- gluewidth = gluewidth + 10
- local edge = cur_h + gluewidth
- local lx = 0
- if subtype == gleaders_code then
- local save_h = cur_h
- if pos_r == righttoleft_code then
- cur_h = ref_h - shipbox_h - cur_h
- cur_h = width * (cur_h / width)
- cur_h = ref_h - shipbox_h - cur_h
- else
- cur_h = cur_h + ref_h - shipbox_h
- cur_h = width * (cur_h / width)
- cur_h = cur_h - ref_h - shipbox_h
- end
- if cur_h < save_h then
- cur_h = cur_h + width
- end
- elseif subtype == leaders_code then
- local save_h = cur_h
- cur_h = width * (cur_h / width)
- if cur_h < save_h then
- cur_h = cur_h + width
- end
- else
- lq = gluewidth / width
- lr = gluewidth % width
- if subtype == cleaders_code then
- cur_h = cur_h + lr / 2
- else
- lx = lr / (lq + 1)
- cur_h = cur_h + (lr - (lq - 1) * lx) / 2
- end
- end
- local shift = getshift(leader)
- while cur_h + width <= edge do
- local basepoint_h = 0
- -- local basepoint_v = shift
- if boxdir ~= pos_r then
- basepoint_h = boxwidth
- end
- -- synch_pos_with_cur(ref_h,ref_v,cur_h + basepoint_h,shift)
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + basepoint_h)
- else
- pos_h = ref_h + (cur_h + basepoint_h)
- end
- pos_v = ref_v - shift
- -- synced
- outer_doing_leaders = doing_leaders
- doing_leaders = true
- if getid(leader) == vlist_code then
- vlist_out(leader,getlist(leader))
- else
- hlist_out(leader,getlist(leader))
- end
- doing_leaders = outer_doing_leaders
- cur_h = cur_h + width + lx
- end
- cur_h = edge - 10
- else
- cur_h = cur_h + gluewidth
- end
- else
- cur_h = cur_h + gluewidth
- end
- else
- if tospace and subtype == spaceskip_code then
- -- todo: flush_space
- flush_character(false,getfont(current),32,false,true,pos_h,pos_v,pos_r)
- end
- cur_h = cur_h + gluewidth
- end
- end
- elseif id == hlist_code or id == vlist_code then
- local boxdir = getdirection(current) or lefttoright_code
- local width, height, depth = getwhd(current)
- local list = getlist(current)
- if list then
- local shift, orientation = getshift(current)
- if not orientation then
- local basepoint_h = boxdir ~= pos_r and width or 0
- -- local basepoint_v = shift
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + basepoint_h)
- else
- pos_h = ref_h + (cur_h + basepoint_h)
- end
- pos_v = ref_v - shift
- -- synced
- if id == vlist_code then
- vlist_out(current,list)
- else
- hlist_out(current,list)
- end
- elseif orientation == 0x1000 then
- local orientation, xoffset, yoffset = getorientation(current)
- local basepoint_h = boxdir ~= pos_r and width or 0
- -- local basepoint_v = shift
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + basepoint_h + xoffset)
- else
- pos_h = ref_h + (cur_h + basepoint_h + xoffset)
- end
- pos_v = ref_v - (shift - yoffset)
- -- synced
- if id == vlist_code then
- vlist_out(current,list)
- else
- hlist_out(current,list)
- end
- else
- local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
- local orientation, basepoint_h, basepoint_v = applyanchor(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
- if orientation == 1 then
- basepoint_h = basepoint_h + doffset
- if boxdir == pos_r then
- basepoint_v = basepoint_v - height
- end
- elseif orientation == 2 then
- if boxdir == pos_r then
- basepoint_h = basepoint_h + width
- end
- elseif orientation == 3 then
- basepoint_h = basepoint_h + hoffset
- if boxdir ~= pos_r then
- basepoint_v = basepoint_v - height
- end
- end
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + basepoint_h)
- else
- pos_h = ref_h + (cur_h + basepoint_h)
- end
- pos_v = ref_v - (cur_v + basepoint_v)
- -- synced
- pushorientation(orientation,pos_h,pos_v,pos_r)
- if id == vlist_code then
- vlist_out(current,list)
- else
- hlist_out(current,list)
- end
- poporientation(orientation,pos_h,pos_v,pos_r)
- end
- end
- cur_h = cur_h + width
- elseif id == disc_code then
- local replace, tail = getreplace(current)
- if replace and subtype ~= select_disc then
- -- we could flatten .. no gain
- setlink(tail,getnext(current))
- setlink(current,replace)
- setreplace(current)
- end
- elseif id == kern_code then
- local kern, factor = getkern(current,true)
- if kern ~= 0 then
- if factor ~= 0 then
- cur_h = cur_h + (1.0 + factor/1000000.0) * kern
- else
- cur_h = cur_h + kern
- end
- end
- elseif id == rule_code then
- local width, height, depth = getwhd(current)
- if width > 0 then
- if height == running then
- height = boxheight
- end
- if depth == running then
- depth = boxdepth
- end
- local total = height + depth
- if total > 0 then
- local xoffset, yoffset, left, right = getoffsets(current) -- top bottom
- if left ~= 0 then
- pos_v = pos_v + left
- total = total - left
- end
- if right ~= 0 then
- depth = depth - right
- total = total - right
- end
- if pos_r == righttoleft_code then
- pos_h = pos_h - width
- xoffset = - xoffset
- end
- pos_v = pos_v - depth
- flushrule(current,pos_h + xoffset,pos_v + yoffset,pos_r,width,total,subtype)
- end
- cur_h = cur_h + width
- end
- elseif id == math_code then
- -- local kern = getkern(current)
- -- if kern ~= 0 then
- -- cur_h = cur_h + kern
- -- else
- cur_h = cur_h + effectiveglue(current,this_box)
- -- end
- elseif id == dir_code then
- -- We normally have proper begin-end pairs. A begin without end is (silently) handled
- -- and an end without a begin will be (silently) skipped we only need to move forward
- -- so we then have a faster calculation.
- local dir, cancel = getdirection(current)
- if cancel then
- local ds = dirstack[current]
- if ds then
- ref_h = ds.ref_h
- ref_v = ds.ref_v
- cur_h = ds.cur_h
- cur_v = ds.cur_v
- else
- -- pardir
- end
- pos_r = dir
- else
- local width, enddir = dirdimensions(this_box,current)
- local new_h = cur_h + width
- if dir ~= pos_r then
- cur_h = new_h
- end
- if enddir ~= current then
- dirstack[enddir] = {
- cur_h = new_h,
- cur_v = cur_v,
- ref_h = ref_h,
- ref_v = ref_v,
- }
- setdirection(enddir,pos_r)
- end
- if pos_r == righttoleft_code then
- pos_h = ref_h - cur_h
- else
- pos_h = ref_h + cur_h
- end
- pos_v = ref_v - cur_v
- -- synced
- ref_h = pos_h
- ref_v = pos_v
- cur_h = 0
- cur_v = 0
- pos_r = dir
- goto synced
- end
- elseif id == whatsit_code then
- if subtype == literalwhatsit_code then
- flushliteral(current,pos_h,pos_v)
- elseif subtype == lateluawhatsit_code then
- flushlatelua(current,pos_h,pos_v)
- elseif subtype == setmatrixwhatsit_code then
- flushsetmatrix(current,pos_h,pos_v)
- elseif subtype == savewhatsit_code then
- flushsave(current,pos_h,pos_v)
- elseif subtype == restorewhatsit_code then
- flushrestore(current,pos_h,pos_v)
- elseif subtype == saveposwhatsit_code then
- last_position_x = pos_h
- last_position_y = pos_v
- elseif subtype == writewhatsit_code then
- flushwriteout(current)
- elseif subtype == closewhatsit_code then
- flushcloseout(current)
- elseif subtype == openwhatsit_code then
- flushopenout(current)
- end
- -- elseif id == localpar_code and start_of_par(current) then
- -- local pardir = getdirection(current) or lefttoright_code
- -- if pardir == righttoleft_code then
- -- end
- -- end
- end
- -- There is no gain in skipping over this when we have zero progression
- -- and such.
- if pos_r == righttoleft_code then
- pos_h = ref_h - cur_h
- else
- pos_h = ref_h + cur_h
- end
- pos_v = ref_v - cur_v
- ::synced::
- end
- pos_h = ref_h
- pos_v = ref_v
- pos_r = ref_r
- end
-
- vlist_out = function(this_box,current)
- local outer_doing_leaders = false
-
- local ref_h = pos_h
- local ref_v = pos_v
- local ref_r = pos_r
- pos_r = getdirection(this_box)
-
- local boxwidth,
- boxheight,
- boxdepth = getwhd(this_box)
-
- local cur_h = 0
- local cur_v = - boxheight
- local top_edge = cur_v
-
- if pos_r == righttoleft_code then
- pos_h = ref_h - cur_h
- else
- pos_h = ref_h + cur_h
- end
- pos_v = ref_v - cur_v
- -- synced
-
- -- if not current then
- -- current = getlist(this_box)
- -- end
-
- -- while current do
- -- local id = getid(current)
- for current, id, subtype in nextnode, current do
- if id == glue_code then
- local glueheight = effectiveglue(current,this_box)
- if glueheight ~= 0 then
- if subtype >= leaders_code then
- local leader = getleader(current)
- if leader then
- local width, height, depth = getwhd(leader)
- local total = height + depth
- if getid(leader) == rule_code then
- depth = 0 -- hm
- if total > 0 then
- if width == running then
- width = boxwidth
- end
- if width > 0 then
- if pos_r == righttoleft_code then
- cur_h = cur_h - width
- end
- flushrule(leader,pos_h,pos_v - total,pos_r,width,total,getsubtype(leader))
- end
- cur_v = cur_v + total
- end
- elseif total > 0 and glueheight > 0 then
- glueheight = glueheight + 10
- local edge = cur_v + glueheight
- local ly = 0
- if subtype == gleaders_code then
- save_v = cur_v
- cur_v = ref_v - shipbox_v - cur_v
- cur_v = total * (cur_v / total)
- cur_v = ref_v - shipbox_v - cur_v
- if cur_v < save_v then
- cur_v = cur_v + total
- end
- elseif subtype == leaders_code then -- aleader
- save_v = cur_v
- cur_v = top_edge + total * ((cur_v - top_edge) / total)
- if cur_v < save_v then
- cur_v = cur_v + total
- end
- else
- lq = glueheight / total
- lr = glueheight % total
- if subtype == cleaders_code then
- cur_v = cur_v + lr / 2
- else
- ly = lr / (lq + 1)
- cur_v = cur_v + (lr - (lq - 1) * ly) / 2
- end
- end
- local shift = getshift(leader)
- while cur_v + total <= edge do -- todo: <= edge - total
- -- synch_pos_with_cur(ref_h, ref_v, getshift(leader), cur_v + height)
- if pos_r == righttoleft_code then
- pos_h = ref_h - shift
- else
- pos_h = ref_h + shift
- end
- pos_v = ref_v - (cur_v + height)
- -- synced
- outer_doing_leaders = doing_leaders
- doing_leaders = true
- if getid(leader) == vlist_code then
- vlist_out(leader,getlist(leader))
- else
- hlist_out(leader,getlist(leader))
- end
- doing_leaders = outer_doing_leaders
- cur_v = cur_v + total + ly
- end
- cur_v = edge - 10
- else
- cur_v = cur_v + glueheight
- end
- end
- else
- cur_v = cur_v + glueheight
- end
- end
- elseif id == hlist_code or id == vlist_code then
- local boxdir = getdirection(current) or lefttoright_code
- local width, height, depth = getwhd(current)
- local list = getlist(current)
- if list then
- local shift, orientation = getshift(current)
- if not orientation then
- -- local basepoint_h = shift
- -- local basepoint_v = height
- if boxdir ~= pos_r then
- shift = shift + width
- end
- if pos_r == righttoleft_code then
- pos_h = ref_h - shift
- else
- pos_h = ref_h + shift
- end
- pos_v = ref_v - (cur_v + height)
- -- synced
- if id == vlist_code then
- vlist_out(current,list)
- else
- hlist_out(current,list)
- end
- elseif orientation == 0x1000 then
- local orientation, xoffset, yoffset = getorientation(current)
- -- local basepoint_h = shift
- -- local basepoint_v = height
- if boxdir ~= pos_r then
- shift = shift + width
- end
- if pos_r == righttoleft_code then
- pos_h = ref_h - (shift + xoffset)
- else
- pos_h = ref_h + (shift + xoffset)
- end
- pos_v = ref_v - (cur_v + height - yoffset)
- -- synced
- if id == vlist_code then
- vlist_out(current,list)
- else
- hlist_out(current,list)
- end
- else
- local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
- local orientation, basepoint_h, basepoint_v = applyanchor(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
- if orientation == 1 then
- basepoint_h = basepoint_h + width - height
- basepoint_v = basepoint_v - height
- elseif orientation == 2 then
- basepoint_h = basepoint_h + width
- basepoint_v = basepoint_v + depth - height
- elseif orientation == 3 then -- weird
- basepoint_h = basepoint_h + height
- end
- if pos_r == righttoleft_code then
- pos_h = ref_h - basepoint_h
- else
- pos_h = ref_h + basepoint_h
- end
- pos_v = ref_v - (cur_v + basepoint_v)
- -- synced
- pushorientation(orientation,pos_h,pos_v,pos_r)
- if id == vlist_code then
- vlist_out(current,list)
- else
- hlist_out(current,list)
- end
- poporientation(orientation,pos_h,pos_v,pos_r)
- end
- end
- cur_v = cur_v + height + depth
- elseif id == kern_code then
- cur_v = cur_v + getkern(current)
- elseif id == rule_code then
- local width, height, depth = getwhd(current)
- local total = height + depth
- if total > 0 then
- if width == running then
- width = boxwidth
- end
- if width > 0 then
- local xoffset, yoffset, left, right = getoffsets(current)
- if left ~= 0 then
- width = width - left
- xoffset = left
- end
- if right ~= 0 then
- width = width - right
- end
- if pos_r == righttoleft_code then
- xoffset = - xoffset - width
- end
- flushrule(current,pos_h + xoffset,pos_v - total - yoffset,pos_r,width,total,subtype)
- end
- cur_v = cur_v + total
- end
- elseif id == whatsit_code then
- if subtype == literalwhatsit_code then
- flushliteral(current,pos_h,pos_v)
- elseif subtype == lateluawhatsit_code then
- flushlatelua(current,pos_h,pos_v)
- elseif subtype == setmatrixwhatsit_code then
- flushsetmatrix(current,pos_h,pos_v)
- elseif subtype == savewhatsit_code then
- flushsave(current,pos_h,pos_v)
- elseif subtype == restorewhatsit_code then
- flushrestore(current,pos_h,pos_v)
- elseif subtype == saveposwhatsit_code then
- last_position_x = pos_h
- last_position_y = pos_v
- elseif subtype == writewhatsit_code then
- flushwriteout(current)
- elseif subtype == closewhatsit_code then
- flushcloseout(current)
- elseif subtype == openwhatsit_code then
- flushopenout(current)
- end
- end
- if pos_r == righttoleft_code then
- pos_h = ref_h - cur_h
- else
- pos_h = ref_h + cur_h
- end
- pos_v = ref_v - cur_v
- ::synced::
- end
- pos_h = ref_h
- pos_v = ref_v
- pos_r = ref_r
- end
-
-end
-
-function drivers.converters.lmtx(driver,box,smode,objnum,specification)
-
- if not driver then
- report("error in converter, no driver")
- return
- end
-
- if box then
- box = tonut(box)
- else
- report("error in converter, no box")
- return
- end
-
- local actions = driver.actions
- local flushers = driver.flushers
-
- initialize = actions.initialize
- finalize = actions.finalize
-
- updatefontstate = flushers.updatefontstate
-
- pushorientation = flushers.pushorientation
- poporientation = flushers.poporientation
-
- flushcharacter = flushers.character
- flushfontchar = flushers.fontchar
- flushrule = flushers.rule
- flushsimplerule = flushers.simplerule
- flushspecial = flushers.special
- flushliteral = flushers.literal
- flushsetmatrix = flushers.setmatrix
- flushsave = flushers.save
- flushrestore = flushers.restore
- -- flushimage = flushers.image
-
- reset_dir_stack()
- reset_state()
-
- shippingmode = smode
-
- local details = nil -- must be outside labels
-
- local width, height, depth = getwhd(box)
-
- local total = height + depth
-
- ----- v_offset_par = 0
- ----- h_offset_par = 0
-
- local max_v = total -- + v_offset_par
- local max_h = width -- + h_offset_par
-
- if height > maxdimen or depth > maxdimen or width > maxdimen then
- goto DONE
- end
-
- if max_v > maxdimen then
- goto DONE
- elseif max_v > abs_max_v then
- abs_max_v = max_v
- end
-
- if max_h > maxdimen then
- goto DONE
- elseif max_h > abs_max_h then
- abs_max_h = max_h
- end
-
- if shippingmode == "page" then
-
- -- We have zero offsets in ConTeXt.
-
- local pagewidth, pageheight = getpagedimensions()
-
- -- local h_offset_par = texget("hoffset")
- -- local v_offset_par = texget("voffset")
-
- -- page_h_origin = trueinch
- -- page_v_origin = trueinch
-
- pos_r = lefttoright_code
-
- if pagewidth > 0 then
- page_size_h = pagewidth
- else
- page_size_h = width
- end
-
- if page_size_h == 0 then
- page_size_h = width
- end
-
- if pageheight > 0 then
- page_size_v = pageheight
- else
- page_size_v = total
- end
-
- if page_size_v == 0 then
- page_size_v = total
- end
-
- local refpoint_h = 0 -- + page_h_origin + h_offset_par
- local refpoint_v = page_size_v -- - page_v_origin - v_offset_par
-
- pos_h = refpoint_h
- pos_v = refpoint_v - height
- -- synced
-
- else
-
- -- page_h_origin = 0
- -- page_v_origin = 0
- page_size_h = width
- page_size_v = total
- pos_r = getdirection(box)
- pos_v = depth
- pos_h = pos_r == righttoleft_code and width or 0
-
- end
-
- shipbox_ref_h = pos_h
- shipbox_ref_v = pos_v
-
- details = {
- shippingmode = smode, -- target
- boundingbox = { 0, 0, page_size_h, page_size_v },
- objectnumber = smode ~= "page" and objnum or nil,
- pagenumber = smode == "page" and objnum or nil,
- specification = specification,
- }
-
- initialize(driver,details)
-
- lastfont = nil -- this forces a sync each page / object
-
- if getid(box) == vlist_code then
- vlist_out(box,getlist(box))
- else
- hlist_out(box,getlist(box))
- end
-
- ::DONE::
-
- finalize(driver,details)
-
- shippingmode = "none"
-end
-
--- This will move to back-out.lua eventually.
-
-do
-
- ----- sortedhash = table.sortedhash
-
- ----- tonut = nodes.tonut
- local properties = nodes.properties.data
- local flush = texio.write_nl
-
- local periods = utilities.strings.newrepeater(".")
-
- local function showdetails(n,l)
- local p = properties[tonut(n)]
- if p then
- local done = false
- for k, v in sortedhash(p) do
- if done then
- flush("\n")
- else
- done = true
- end
- flush(periods[l+1] .. " " .. k .. " = " .. tostring(v))
- end
- end
- end
-
- local whatsittracers = {
- latelua = showdetails,
- literal = showdetails,
- }
-
- callback.register("show_whatsit",function(n,l)
- local s = nodes.whatsitcodes[n.subtype]
- texio.write(" [" .. s .. "]")
- local w = whatsittracers[s]
- if w then
- w(n,l)
- end
- end)
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/driv-shp.mkxl b/Master/texmf-dist/tex/context/base/mkiv/driv-shp.mkxl
deleted file mode 100644
index 68b62c72a72..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/driv-shp.mkxl
+++ /dev/null
@@ -1,18 +0,0 @@
-%D \module
-%D [ file=driv-shp,
-%D version=2018.07.26,
-%D title=\CONTEXT\ Driver Macros,
-%D subtitle=Shipout,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\registerctxluafile{driv-shp}{optimize}
-
-\unprotect
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/enco-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/enco-ini.mkiv
index f78643975e5..26f218b035b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/enco-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/enco-ini.mkiv
@@ -314,7 +314,7 @@
% left-overs (some day in private unicode space, so that we can roundtrip)
\unexpanded\def\textblacksquare {\dontleavehmode\hbox{\vrule\s!width.3\s!em\s!height.4\s!em\s!depth-.1\s!em}}
-\unexpanded\def\schwa {\hbox{\rotate[\c!rotation=180,\c!location=\v!high]{\hbox{e}}}}
+%unexpanded\def\schwa {\hbox{\rotate[\c!rotation=180,\c!location=\v!high]{\hbox{e}}}}
\unexpanded\def\schwagrave {\buildtextgrave\schwa}
\chardef\textcontrolspace"2423
@@ -427,7 +427,7 @@
{\char \iffontchar\font"2012 "2012 % figuredash
\else\iffontchar\font"2013 "2013 % endash
\else\iffontchar\font"2212 "2212 % math minus
- "002D % hyphen
+ \else "002D % hyphen
\fi\fi\fi}
\unexpanded\def\textplus
diff --git a/Master/texmf-dist/tex/context/base/mkiv/export-example.css b/Master/texmf-dist/tex/context/base/mkiv/export-example.css
index 19a2a071e88..7cfd7f291fc 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/export-example.css
+++ b/Master/texmf-dist/tex/context/base/mkiv/export-example.css
@@ -405,7 +405,7 @@ context|div.item {
}
itemtag,
-context|div.item {
+context|div.itemtag {
display: none ;
}
@@ -479,8 +479,9 @@ context|div.verbatim {
font-family : "DejaVu Sans Mono", "Lucida Console", monospace ;
}
-/* lines : display */
-/* line : mixed */
+/* lines : display */
+/* line : mixed */
+/* linenumber : inline */
lines,
context|div.lines {
@@ -501,6 +502,15 @@ context|div.line {
white-space : pre-wrap ;
}
+linenumber,
+context|div.linenumber {
+ display : inline-block ;
+ margin-right : 1em ;
+ width : 3em ;
+ text-align : left ;
+ font-family : "DejaVu Sans Mono", "Lucida Console", monospace ;
+}
+
/* synonym : inline */
/* sorting : inline */
@@ -546,44 +556,61 @@ context|div.registerlocation:after {
/* tablerow : display */
/* tablecell : mixed */
+/* we have a few bonus mappings here */
+
table,
context|div.table {
display : table ;
}
-tablerow,
-context|div.tablerow {
+tablerow, tr
+context|div.tablerow, context|div.tr {
display : table-row ;
}
-tablecell[align="middle"],
+tablecell[align="middle"], td[align="middle"],
context|div.tablecell.align-middle {
display : table-cell ;
text-align : center ;
padding : .1em ;
}
-tablecell[align="flushleft"],
+tablecell[align="flushleft"], td[align="flushleft"],
context|div.tablecell.align-flushleft {
display : table-cell ;
text-align : left ;
padding : .1em ;
}
-tablecell[align="flushright"],
+tablecell[align="flushright"], td[align="flushright"],
context|div.tablecell.align-flushright {
display : table-cell ;
text-align : right ;
padding : .1em ;
}
-tablecell,
-context|div.tablecell {
+tablecell, td
+context|div.tablecell, context|div.td {
display : table-cell ;
text-align : left ;
padding : .1em ;
}
+tablehead,
+div.thead, div.tableheader {
+ display : table-header-group ;
+}
+
+tablefoot,
+div.tfoot, div.tablefooter {
+ display : table-footer-group ;
+}
+
+tablebody,
+div.tbody, div.tablebody {
+ display : table-body-group ;
+}
+
/* tabulate : display */
/* tabulaterow : display */
/* tabulatecell : mixed */
@@ -648,6 +675,13 @@ context|div.tabulatecell.kind-equals:before {
content : ":" ;
}
+/*
+
+ A combination needs some processing because it is not a table yet. So, the next
+ mapping is just one row! The tags are a bit confusing now.
+
+*/
+
/* combination : display */
/* combinationpair : display */
/* combinationcontent : mixed */
@@ -660,8 +694,8 @@ context|div.combination {
margin-bottom : 0em ;
}
-combinationpair,
-context|div.combinationpair {
+combinationpair, combinationtext,
+context|div.combinationpair, context|div.combinationtext {
display : table-cell ;
padding-right : 1em ;
}
@@ -727,7 +761,7 @@ context|div.listitem.subsection context|div.listtag {
*/
listitem[detail="chapter"]>listtag,
-context|div.listitem.chapter context|div.listtag {
+context|div.listitem.chapter > context|div.listtag {
display : inline-block ;
margin-left : -5em ;
float : left ;
@@ -735,7 +769,7 @@ context|div.listitem.chapter context|div.listtag {
}
listitem[detail="section"]>listtag,
-context|div.listitem.section context|div.listtag {
+context|div.listitem.section > context|div.listtag {
display : inline-block ;
margin-left : -5em ;
float : left ;
@@ -743,7 +777,7 @@ context|div.listitem.section context|div.listtag {
}
listitem[detail="subsection"]>listtag,
-context|div.listitem.subsection context|div.listtag {
+context|div.listitem.subsection > context|div.listtag {
display : inline-block ;
margin-left : -5em ;
float : left ;
diff --git a/Master/texmf-dist/tex/context/base/mkiv/export-example.tex b/Master/texmf-dist/tex/context/base/mkiv/export-example.tex
index 32cb79c5ea2..9ef414422ee 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/export-example.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/export-example.tex
@@ -1,5 +1,3 @@
-% language=uk
-
\usemodule[abr-01]
\setupexport
diff --git a/Master/texmf-dist/tex/context/base/mkiv/file-ini.mkvi b/Master/texmf-dist/tex/context/base/mkiv/file-ini.mkvi
index 225b6b40deb..5fa5aa560a1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/file-ini.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/file-ini.mkvi
@@ -10,9 +10,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D \TEX\ operates on files, so one wouldn't wonder that there
-%D is a separate module for file commands. In \CONTEXT\ files
-%D are used for several purposes:
+%D \TEX\ operates on files, so one wouldn't wonder that there is a separate module
+%D for file commands. In \CONTEXT\ files are used for several purposes:
%D
%D \startitemize[packed]
%D \item general textual input
@@ -21,10 +20,9 @@
%D \item buffering defered textual input
%D \stopitemize
%D
-%D When dealing with files we can load them as a whole, using
-%D the \type{\input} primitive or load them on a line||by||line
-%D basis, using \type{\read}. Writing is always done line by
-%D line, using \type{\write}.
+%D When dealing with files we can load them as a whole, using the \type {\input}
+%D primitive or load them on a line||by||line basis, using \type {\read}. Writing is
+%D always done line by line, using \type {\write}.
\writestatus{loading}{ConTeXt File Macros / Helpers}
@@ -35,9 +33,9 @@
%D \macros
%D {scratchread, scratchwrite}
%D
-%D We define a scratch file for reading. Keep in mind that
-%D the number of files is limited to~16, so use this one when
-%D possible. We also define a scratch output file.
+%D We define a scratch file for reading. Keep in mind that the number of files is
+%D limited to~16, so use this one when possible. We also define a scratch output
+%D file. In \MKIV\ and \LMTX\ we never use these file handles.
\ifdefined\scratchread \else \newread \scratchread \fi
\ifdefined\scratchwrite \else \newwrite\scratchwrite \fi
@@ -60,12 +58,10 @@
%D \macros
%D {pushendofline,popendofline}
%D
-%D When we are loading files in the middle of the typesetting
-%D process, for instance when we load references, we have to be
-%D sure that the reading process does not generate so called
-%D 'spurious spaces'. This can be prevented by assigning the
-%D line ending character the \CATCODE\ comment. This is
-%D accomplished by
+%D When we are loading files in the middle of the typesetting process, for instance
+%D when we load references, we have to be sure that the reading process does not
+%D generate so called 'spurious spaces'. This can be prevented by assigning the line
+%D ending character the \CATCODE\ comment. This is accomplished by
%D
%D \starttyping
%D \pushendofline
@@ -114,21 +110,20 @@
%D \macros
%D {input, normalinput}
%D
-%D Sometimes we run into troubles when \type {\input} wants to get
-%D expanded, e.g. in a \type {\write} (which happens in the metafun
-%D manual when we permit long MP lines). So, instead of fixing that,
-%D we go for a redefinition of \type {\input}. Of course it's better
-%D to use \type {\readfile} or \type {\processfile}.
+%D Sometimes we run into troubles when \type {\input} wants to get expanded, e.g. in
+%D a \type {\write} (which happens in the metafun manual when we permit long MP
+%D lines). So, instead of fixing that, we go for a redefinition of \type {\input}.
+%D Of course it's better to use \type {\readfile} or \type {\processfile}.
-\unexpanded\def\input{\normalinput}
+% \unexpanded\def\input{\normalinput}
\def\inputgivenfile#name{\normalinput{#name}}
%D \macros
%D {doifelsefile}
%D
-%D The next alternative only looks if a file is present. No
-%D loading is done. This one obeys the standard \TEX\ lookup.
+%D The next alternative only looks if a file is present. No loading is done. This
+%D one obeys the standard \TEX\ lookup.
%D
%D \starttyping
%D \doiffileelse {filename} {found} {not found}
@@ -155,7 +150,7 @@
%D \doifparentfileelse{filename}{yes}{no}
%D \stoptyping
-\ifx\outputfilename\undefined \def\outputfilename{\jobname} \fi
+\ifdefined\outputfilename \else \def\outputfilename{\jobname} \fi
\unexpanded\def\doifelseparentfile{\clf_doifelseparentfile}
@@ -200,10 +195,9 @@
%D \macros
%D {doonlyonce, doinputonce, doendinputonce}
%D
-%D Especially macropackages need only be loaded once.
-%D Repetitive loading not only costs time, relocating registers
-%D often leads to abortion of the processing because \TEX's
-%D capacity is limited. One can prevent multiple execution and
+%D Especially macropackages need only be loaded once. Repetitive loading not only
+%D costs time, relocating registers often leads to abortion of the processing
+%D because \TEX's capacity is limited. One can prevent multiple execution and
%D loading by using one of both:
%D
%D \starttyping
@@ -212,8 +206,8 @@
%D \doendinputonce{filename}
%D \stoptyping
%D
-%D This command obeys the standard method for locating files. We could
-%D move this function to the \LUA\ end.
+%D This command obeys the standard method for locating files. We could move this
+%D function to the \LUA\ end.
\installsystemnamespace {fileonce}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/file-job.lua b/Master/texmf-dist/tex/context/base/mkiv/file-job.lua
index 407c3c15da1..97e223387dc 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/file-job.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/file-job.lua
@@ -27,8 +27,8 @@ local implement = interfaces.implement
local trace_jobfiles = false trackers.register("system.jobfiles", function(v) trace_jobfiles = v end)
local report = logs.reporter("system")
-local report_jobfiles = logs.reporter("system","jobfiles")
-local report_functions = logs.reporter("system","functions")
+local report_jobfiles = logs.reporter("system", "jobfiles")
+local report_functions = logs.reporter("system", "functions")
local texsetcount = tex.setcount
local elements = interfaces.elements
@@ -968,7 +968,11 @@ function document.setcommandline() -- has to happen at the tex end in order to e
-- to trick the files table which actually only has one entry in a tex job
if arguments.timing then
- context.usemodule("timing")
+ context.usemodule { "timing" }
+ end
+
+ if arguments.usage then
+ trackers.enable("system.usage")
end
if arguments.batchmode then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/file-job.mkvi b/Master/texmf-dist/tex/context/base/mkiv/file-job.mkvi
index a46e519c061..1f8da6b0cd8 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/file-job.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/file-job.mkvi
@@ -133,10 +133,15 @@
\unexpanded\def\starttext {\clf_starttext}
\unexpanded\def\stoptext {\clf_stoptext}
\unexpanded\def\forcequitjob {\clf_forcequitjob}
-\unexpanded\def\end {\clf_forceendjob}
\unexpanded\def\autostarttext{\clf_autostarttext}
\unexpanded\def\autostoptext {\clf_autostoptext}
+\pushoverloadmode
+
+\unexpanded\def\end {\clf_forceendjob}
+
+\popoverloadmode
+
\unexpanded\def\finishjob{\stoptext} % nicer in luatex call commandline
\newtoks\everystartnotext
@@ -295,22 +300,81 @@
{\popsystemmode\v!environment
\signalendofinput\v!environment}
-%D Relatively new (might move as it depends on setups):
+%D Upgraded after the ctx 2020 meeting:
+%D
+%D \starttyping
+%D \definedocument[thesis]
+%D
+%D \setupdocument[a=b,e=f]
+%D \setupdocument[thesis][a=x,c=d]
+%D
+%D % \startsetups[thesis:start]
+%D \startsetups[document:start]
+%D START
+%D \stopsetups
+%D
+%D \startsetups[thesis:stop]
+%D % \startsetups[document:stop]
+%D STOP
+%D \stopsetups
+%D
+%D % \startdocument[thesis]
+%D \startthesis
+%D (\currentdocument/a): \documentvariable{a}\par
+%D (\currentdocument/c): \documentvariable{c}\par
+%D (\currentdocument/e): \documentvariable{e}\par
+%D \stopthesis
+%D % \stopdocument
+%D \stoptyping
+
+\installcorenamespace {document}
-%newtoks\everysetupdocument
+\installcommandhandler \??document \s!document \??document
-\unexpanded\def\startdocument % todo: dostarttagged\t!document
- {\dosingleargument\syst_structure_document_start}
+\setupdocument
+ [\c!before=\directsetup{\s!document:\v!start},
+ \c!after =\directsetup{\s!document:\v!stop}]
-\unexpanded\def\syst_structure_document_start[#settings]%
- {\setvariables[\s!document][#settings]%
- \the\everysetupdocument\relax
+\def\syst_document_setup#1%
+ {\directsetup{\doifelsesetups{\currentdocument:\v!start}\currentdocument\s!document:\v!start}}
+
+\appendtoks
+ \normalexpanded {%
+ \startsetups[\currentdocument:\v!start]\noexpand\directsetup{\ifx\empty\currentdocumentparent\s!document\else\currentdocumentparent\fi:\v!start}\stopsetups
+ \startsetups[\currentdocument:\v!stop ]\noexpand\directsetup{\ifx\empty\currentdocumentparent\s!document\else\currentdocumentparent\fi:\v!stop }\stopsetups
+ \setvalue{\e!start\currentdocument}{\dodoubleargument\syst_document_start[\currentdocument]}%
+ \letvalue{\e!stop \currentdocument}\stopdocument
+ }%
+\to \everydefinedocument
+
+\unexpanded\def\startdocument % todo: dostarttagged\t!document
+ {\dodoubleargument\syst_document_start}
+
+\unexpanded\def\syst_document_start[#namespace][#settings]%
+ {\pushmacro\currentdocument
+ \ifsecondargument
+ \edef\currentdocument{#namespace}%
+ \setupcurrentdocument[#settings]%
+ \else\iffirstargument
+ \doifelseassignment{#namespace}%
+ {\let\currentdocument\empty
+ \setupcurrentdocument[#namespace]}%
+ {\edef\currentdocument{#namespace}}%
+ \fi\fi
+ \ifx\empty\currentdocument\else\setmode\currentdocument\fi
\starttext
+ \the\everystartdocument
\documentvariable\c!before}
\unexpanded\def\stopdocument % todo: dostoptagged\t!document
{\documentvariable\c!after
- \stoptext}
+ \the\everystopdocument
+ \stoptext
+ \ifx\empty\currentdocument\else\resetmode\currentdocument\fi
+ \popmacro\currentdocument}
+
+ \let\documentvariable \documentparameter
+\unexpanded\def\unexpandeddocumentvariable{\documentparameter}
\unexpanded\def\doifelsedocumentvariable#name{\doifelsesomething{\documentvariable{#name}}}
\unexpanded\def\doifdocumentvariable #name{\doifsomething {\documentvariable{#name}}}
@@ -318,38 +382,21 @@
\let\doifdocumentvariableelse\doifelsedocumentvariable
-\def\documentvariable#name%
- {\getvariable\s!document{#name}}
-
-\unexpanded\def\unexpandeddocumentvariable#name%
- {\getvariable\s!document{#name}}
-
-\unexpanded\def\setupdocument[#settings]%
- {\setvariables[\s!document][#settings]%
- \the\everysetupdocument\relax}
-
-\unexpanded\def\presetdocument[#settings]%
- {\checkvariables[\s!document][#settings]}
-
-% We silently ignore missing documents. Beware: there are no begin/end setups
-% invoked as we expect the loaded document to be wrapped in \startdocument ...
-% \stopdocument. This is just a convenient variant of input.
-%
-% \unexpanded\def\document
-% {\dosingleempty\syst_document}
-%
-% \def\syst_document[#1]#2%
-% \startdocument[#1]
-% \readfile{#2}{}{}}
-
-% metadata:author metadata:title metadata:subject
-
-\setvariables
- [document]
- [\c!before=\directsetup{\s!document:start},
- \c!after=\directsetup{\s!document:stop}]
-
-%S The document: namespace will be used elsewhere too.
+\unexpanded\def\presetdocument
+ {\dodoubleargument\syst_document_preset}
+
+\unexpanded\def\syst_document_preset[#namespace][#settings]%
+ {\pushmacro\currentdocument
+ \ifsecondargument
+ \edef\currentdocument{#namespace}%
+ \setupcurrentdocument[#settings]%
+ \else\iffirstargument
+ \doifelseassignment{#namespace}%
+ {\let\currentdocument\empty
+ \setupcurrentdocument[#namespace]}%
+ {}%
+ \fi\fi
+ \popmacro\currentdocument}
% Bonus:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/file-lib.mkiv b/Master/texmf-dist/tex/context/base/mkiv/file-lib.mkiv
new file mode 100644
index 00000000000..c2ec555cf2f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/file-lib.mkiv
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=file-lib, % was core-fil,
+%D version=20110701, % 1997.11.15,
+%D title=\CONTEXT\ File Macros,
+%D subtitle=Module Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt File Macros / Libraries}
+
+\unprotect
+
+\registerctxluafile{file-lib}{}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/file-lib.mkvi b/Master/texmf-dist/tex/context/base/mkiv/file-lib.mkvi
deleted file mode 100644
index c2ec555cf2f..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/file-lib.mkvi
+++ /dev/null
@@ -1,20 +0,0 @@
-%D \module
-%D [ file=file-lib, % was core-fil,
-%D version=20110701, % 1997.11.15,
-%D title=\CONTEXT\ File Macros,
-%D subtitle=Module Support,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt File Macros / Libraries}
-
-\unprotect
-
-\registerctxluafile{file-lib}{}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/file-mod.lua b/Master/texmf-dist/tex/context/base/mkiv/file-mod.lua
index 10a18717865..d392887ec18 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/file-mod.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/file-mod.lua
@@ -111,64 +111,66 @@ local function usemodule(name,hasscheme)
end
function environment.usemodules(prefix,askedname,truename)
- local truename = truename or environment.truefilename(askedname)
- local hasprefix = prefix and prefix ~= ""
- local hashname = ((hasprefix and prefix) or "*") .. "-" .. truename
- local status = modstatus[hashname] or false -- yet unset
- if status == 0 then
- -- not found
- elseif status == 1 then
- status = status + 1
- else
- if trace_modules then
- report("locating, prefix %a, askedname %a, truename %a",prefix,askedname,truename)
- end
- local hasscheme = url.hasscheme(truename)
- if hasscheme then
- -- no prefix and suffix done
- if usemodule(truename,true) then
- status = 1
- else
- status = 0
- end
- elseif hasprefix then
- if usemodule(prefix .. "-" .. truename) then
- status = 1
- else
- status = 0
- end
+ local truename = truename or environment.truefilename(askedname) or askedname
+ if truename and truename ~= "" then
+ local hasprefix = prefix and prefix ~= ""
+ local hashname = ((hasprefix and prefix) or "*") .. "-" .. truename
+ local status = modstatus[hashname] or false -- yet unset
+ if status == 0 then
+ -- not found
+ elseif status == 1 then
+ status = status + 1
else
- for i=1,#prefixes do
- -- todo: reconstruct name i.e. basename
- local thename = prefixes[i] .. "-" .. truename
- if usemodule(thename) then
+ if trace_modules then
+ report("locating, prefix %a, askedname %a, truename %a",prefix,askedname,truename)
+ end
+ local hasscheme = url.hasscheme(truename)
+ if hasscheme then
+ -- no prefix and suffix done
+ if usemodule(truename,true) then
status = 1
- break
+ else
+ status = 0
+ end
+ elseif hasprefix then
+ if usemodule(prefix .. "-" .. truename) then
+ status = 1
+ else
+ status = 0
end
- end
- if status then
- -- ok, don't change
- elseif find(truename,"-",1,true) and usemodule(truename) then
- -- assume a user namespace
- report("using user prefixed file %a",truename)
- status = 1
- elseif permit_unprefixed and usemodule(truename) then
- report("using unprefixed file %a",truename)
- status = 1
else
- status = 0
+ for i=1,#prefixes do
+ -- todo: reconstruct name i.e. basename
+ local thename = prefixes[i] .. "-" .. truename
+ if usemodule(thename) then
+ status = 1
+ break
+ end
+ end
+ if status then
+ -- ok, don't change
+ elseif find(truename,"-",1,true) and usemodule(truename) then
+ -- assume a user namespace
+ report("using user prefixed file %a",truename)
+ status = 1
+ elseif permit_unprefixed and usemodule(truename) then
+ report("using unprefixed file %a",truename)
+ status = 1
+ else
+ status = 0
+ end
end
end
+ if status == 0 then
+ missing = true
+ report("%a is not found",askedname)
+ elseif status == 1 then
+ report("%a is loaded",trace_modules and truename or askedname)
+ else
+ report("%a is already loaded",trace_modules and truename or askedname)
+ end
+ modstatus[hashname] = status
end
- if status == 0 then
- missing = true
- report("%a is not found",askedname)
- elseif status == 1 then
- report("%a is loaded",trace_modules and truename or askedname)
- else
- report("%a is already loaded",trace_modules and truename or askedname)
- end
- modstatus[hashname] = status
end
statistics.register("loaded tex modules", function()
@@ -246,18 +248,16 @@ function environment.useluamodule(list)
end
end
-local strings = interfaces.strings
-
implement {
name = "usemodules",
actions = environment.usemodules,
- arguments = strings[2]
+ arguments = "2 strings",
}
implement {
name = "doifelseolderversion",
actions = function(one,two) commands.doifelse(comparedversion(one,two) >= 0) end,
- arguments = strings[2]
+ arguments = "2 strings"
}
implement {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-cff.lua b/Master/texmf-dist/tex/context/base/mkiv/font-cff.lua
index 72b0a038f17..4e2981011ac 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-cff.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-cff.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-cff'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -609,12 +610,15 @@ do
+ p_unsupported
)^1
- parsedictionaries = function(data,dictionaries,what)
+ parsedictionaries = function(data,dictionaries,version)
stack = { }
strings = data.strings
+ if trace_charstrings then
+ report("charstring format %a",version)
+ end
for i=1,#dictionaries do
top = 0
- result = what == "cff" and {
+ result = version == "cff" and {
monospaced = false,
italicangle = 0,
underlineposition = -100,
@@ -1421,13 +1425,15 @@ do
-- to wrap my head around the rather complex variable font specification
-- with regions and axis, the following approach kind of works but is more
-- some trial and error trick. It's still not clear how much of the complex
- -- truetype description applies to cff.
+ -- truetype description applies to cff. Once there are fonts out there we'll
+ -- get there. (Marcel and friends did some tests with recent cff2 fonts so
+ -- the code has been adapted accordingly.)
local reginit = false
local function updateregions(n) -- n + 1
if regions then
- local current = regions[n] or regions[1]
+ local current = regions[n+1] or regions[1]
nofregions = #current
if axis and n ~= reginit then
factors = { }
@@ -1517,7 +1523,7 @@ do
end
end
else
- -- error
+ top = top - nofregions * n
end
end
@@ -2151,7 +2157,14 @@ do
popped = 3
seacs = { }
if regions then
- regions = { regions } -- needs checking
+ -- this was:
+ -- regions = { regions } -- needs checking
+ -- and is now (MFC):
+ regions = { }
+ local deltas = data.deltas
+ for i = 1, #deltas do
+ regions[i] = deltas[i].regions
+ end
axis = data.factors or false
end
end
@@ -2261,8 +2274,8 @@ do
end
-local function readglobals(f,data)
- local routines = readlengths(f)
+local function readglobals(f,data,version)
+ local routines = readlengths(f,version == "cff2")
for i=1,#routines do
routines[i] = readbytetable(f,routines[i])
end
@@ -2320,14 +2333,14 @@ local function readprivates(f,data)
end
end
-local function readlocals(f,data,dictionary)
+local function readlocals(f,data,dictionary,version)
local header = data.header
local private = dictionary.private
if private then
local subroutineoffset = private.data.subroutines
if subroutineoffset ~= 0 then
setposition(f,header.offset+private.offset+subroutineoffset)
- local subroutines = readlengths(f)
+ local subroutines = readlengths(f,version == "cff2")
for i=1,#subroutines do
subroutines[i] = readbytetable(f,subroutines[i])
end
@@ -2344,7 +2357,7 @@ end
-- These charstrings are little programs and described in: Technical Note #5177. A truetype
-- font has only one dictionary.
-local function readcharstrings(f,data,what)
+local function readcharstrings(f,data,version)
local header = data.header
local dictionaries = data.dictionaries
local dictionary = dictionaries[1]
@@ -2355,7 +2368,7 @@ local function readcharstrings(f,data,what)
elseif stringtype == 2 then
setposition(f,header.offset+offset)
-- could be a metatable .. delayed loading
- local charstrings = readlengths(f,what=="cff2")
+ local charstrings = readlengths(f,version=="cff2")
local nofglyphs = #charstrings
for i=1,nofglyphs do
charstrings[i] = readstring(f,charstrings[i])
@@ -2390,7 +2403,8 @@ readers.parsecharstrings = parsecharstrings -- used in font-onr.lua (type 1)
local function readnoselect(f,fontdata,data,glyphs,doshapes,version,streams)
local dictionaries = data.dictionaries
local dictionary = dictionaries[1]
- readglobals(f,data)
+ local cid = not dictionary.private and dictionary.cid
+ readglobals(f,data,version)
readcharstrings(f,data,version)
if version == "cff2" then
dictionary.charset = nil
@@ -2398,9 +2412,27 @@ local function readnoselect(f,fontdata,data,glyphs,doshapes,version,streams)
readencodings(f,data)
readcharsets(f,data,dictionary)
end
+ if cid then
+ local fdarray = cid.fdarray
+ if fdarray then
+ setposition(f,data.header.offset + fdarray)
+ local dictionaries = readlengths(f,version=="cff2")
+ local nofdictionaries = #dictionaries
+ if nofdictionaries > 0 then
+ for i=1,nofdictionaries do
+ dictionaries[i] = readstring(f,dictionaries[i])
+ end
+ parsedictionaries(data,dictionaries)
+ dictionary.private = dictionaries[1].private
+ if nofdictionaries > 1 then
+ report("ignoring dictionaries > 1 in cid font")
+ end
+ end
+ end
+ end
readprivates(f,data)
parseprivates(data,data.dictionaries)
- readlocals(f,data,dictionary)
+ readlocals(f,data,dictionary,version)
startparsing(fontdata,data,streams)
parsecharstrings(fontdata,data,glyphs,doshapes,version,streams)
stopparsing(fontdata,data)
@@ -2412,7 +2444,7 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams)
local dictionary = dictionaries[1]
local cid = dictionary.cid
local cidselect = cid and cid.fdselect
- readglobals(f,data)
+ readglobals(f,data,version)
readcharstrings(f,data,version)
if version ~= "cff2" then
readencodings(f,data)
@@ -2458,7 +2490,7 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams)
local cidarray = cid.fdarray
if cidarray then
setposition(f,header.offset+cidarray)
- local dictionaries = readlengths(f)
+ local dictionaries = readlengths(f,version == "cff2")
for i=1,#dictionaries do
dictionaries[i] = readstring(f,dictionaries[i])
end
@@ -2466,7 +2498,7 @@ local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams)
cid.dictionaries = dictionaries
readcidprivates(f,data)
for i=1,#dictionaries do
- readlocals(f,data,dictionaries[i])
+ readlocals(f,data,dictionaries[i],version)
end
startparsing(fontdata,data,streams)
for i=1,#charstrings do
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-cft.lua b/Master/texmf-dist/tex/context/base/mkiv/font-cft.lua
index ee9ffa6a77a..cf6c232a606 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-cft.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-cft.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['font-cft'] = {
license = "see context related readme files"
}
--- context font tables
+-- context font tables (needs updating)
--
-- todo: extra:
--
@@ -229,7 +229,7 @@ do
data.scaled = {
properties = {
- encodingbytes = t_cardinal,
+ encodingbytes = t_cardinal, -- not in lmtx
embedding = t_cardinal, -- ?
cidinfo = t_hash,
format = t_string,
@@ -238,7 +238,7 @@ do
filename = t_string,
psname = t_string,
name = t_string,
- virtualized = t_boolean,
+ virtualized = t_boolean, -- not in lmtx
hasitalics = t_boolean,
autoitalicamount = t_float,
nostackmath = t_boolean,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua b/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
index ab145ce4d8f..e18e4b8048a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-chk.lua
@@ -9,6 +9,8 @@ if not modules then modules = { } end modules ['font-chk'] = {
-- possible optimization: delayed initialization of vectors
-- move to the nodes namespace
+-- This is old code and I'll make a nicer one for lmtx some day.
+
local next = next
local floor = math.floor
@@ -248,11 +250,14 @@ local function addmissingsymbols(tfmdata) -- we can have an alternative with rul
end
end
end
- if #collected > 0 then
- addcharacters(properties.id, {
- type = "real",
- characters = collected,
- })
+ if next(collected) then
+ local id = properties.id
+ if id then
+ addcharacters(properties.id, {
+ type = "real",
+ characters = collected,
+ })
+ end
end
end
@@ -268,12 +273,6 @@ registerotffeature {
fonts.loggers.add_placeholders = function(id) addmissingsymbols(fontdata[id or true]) end
fonts.loggers.category_to_placeholder = mapping
-function commands.getplaceholderchar(name)
- local id = currentfont()
- addmissingsymbols(fontdata[id])
- context(getprivatenode(fontdata[id],name))
-end
-
-- todo in luatex: option to add characters (just slots, no kerns etc)
-- we can do that now so ...
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-col.lua b/Master/texmf-dist/tex/context/base/mkiv/font-col.lua
index d197c7c8583..c47a299060b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-col.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-col.lua
@@ -478,5 +478,5 @@ implement {
implement {
name = "doifelsecharinfont",
actions = { collections.found, commands.doifelse },
- arguments = { "integer" }
+ arguments = "integer"
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-con.lua b/Master/texmf-dist/tex/context/base/mkiv/font-con.lua
index 1bb63aa5192..f650e5b03d6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-con.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-con.lua
@@ -191,6 +191,9 @@ function constructors.assignmathparameters(target,original) -- simple variant, n
if not mathparameters.FractionDelimiterDisplayStyleSize then
targetmathparameters.FractionDelimiterDisplayStyleSize = 2.40 * targetparameters.size
end
+ if not targetmathparameters.SpaceBeforeScript then
+ targetmathparameters.SpaceBeforeScript = targetmathparameters.SpaceAfterScript
+ end
target.mathparameters = targetmathparameters
end
end
@@ -210,60 +213,45 @@ end
-- we default to false, so a macro package has to enable it explicitly. In
-- LuaTeX the fullname is used to identify a font as being unique.
-constructors.sharefonts = false
-constructors.nofsharedfonts = 0
-local sharednames = { }
+local nofinstances = 0
+local instances = setmetatableindex(function(t,k)
+ nofinstances = nofinstances + 1
+ t[k] = nofinstances
+ return nofinstances
+end)
function constructors.trytosharefont(target,tfmdata)
- if constructors.sharefonts then -- not robust !
- local characters = target.characters
- local n = 1
- local t = { target.psname }
- local u = sortedkeys(characters)
- for i=1,#u do
- local k = u[i]
- n = n + 1 ; t[n] = k
- n = n + 1 ; t[n] = characters[k].index or k
+ local properties = target.properties
+ local instance = properties.instance
+ if instance then
+ local fullname = target.fullname
+ local fontname = target.fontname
+ local psname = target.psname
+ local format = tfmdata.properties.format
+ if format == "opentype" then
+ target.streamprovider = 1
+ elseif format == "truetype" then
+ target.streamprovider = 2
+ else
+ target.streamprovider = 0
end
- local h = md5.HEX(concat(t," "))
- local s = sharednames[h]
- if s then
- if trace_defining then
- report_defining("font %a uses backend resources of font %a",target.fullname,s)
+ if target.streamprovider > 0 then
+ if fullname then
+ fullname = fullname .. ":" .. instances[instance]
+ target.fullname = fullname
+ end
+ if fontname then
+ fontname = fontname .. ":" .. instances[instance]
+ target.fontname = fontname
+ end
+ if psname then
+ psname = psname .. ":" .. instances[instance]
+ target.psname = psname
end
- target.fullname = s
- constructors.nofsharedfonts = constructors.nofsharedfonts + 1
- target.properties.sharedwith = s
- else
- sharednames[h] = target.fullname
end
end
end
--- function constructors.enhanceparameters(parameters)
--- local xheight = parameters.x_height
--- local quad = parameters.quad
--- local space = parameters.space
--- local stretch = parameters.space_stretch
--- local shrink = parameters.space_shrink
--- local extra = parameters.extra_space
--- local slant = parameters.slant
--- -- synonyms
--- parameters.xheight = xheight
--- parameters.spacestretch = stretch
--- parameters.spaceshrink = shrink
--- parameters.extraspace = extra
--- parameters.em = quad
--- parameters.ex = xheight
--- parameters.slantperpoint = slant
--- parameters.spacing = {
--- width = space,
--- stretch = stretch,
--- shrink = shrink,
--- extra = extra,
--- }
--- end
-
local synonyms = {
exheight = "x_height",
xheight = "x_height",
@@ -463,6 +451,7 @@ function constructors.scale(tfmdata,specification)
target.format = properties.format
target.cache = constructors.cacheintex and "yes" or "renew"
--
+ local original = properties.original or tfmdata.original
local fontname = properties.fontname or tfmdata.fontname
local fullname = properties.fullname or tfmdata.fullname
local filename = properties.filename or tfmdata.filename
@@ -474,6 +463,7 @@ function constructors.scale(tfmdata,specification)
--
local psname, psfixed = fixedpsname(psname,fontname or fullname or file.nameonly(filename))
--
+ target.original = original
target.fontname = fontname
target.fullname = fullname
target.filename = filename
@@ -578,6 +568,15 @@ function constructors.scale(tfmdata,specification)
targetparameters.quad = targetquad
targetparameters.extra_space = targetextra_space
--
+ local hshift = parameters.hshift
+ if hshift then
+ targetparameters.hshift = delta * hshift
+ end
+ local vshift = parameters.vshift
+ if vshift then
+ targetparameters.vshift = delta * vshift
+ end
+ --
local ascender = parameters.ascender
if ascender then
targetparameters.ascender = delta * ascender
@@ -601,13 +600,17 @@ function constructors.scale(tfmdata,specification)
--
if hasmath then
constructors.assignmathparameters(target,tfmdata) -- does scaling and whatever is needed
- properties.hasmath = true
- target.nomath = false
- target.MathConstants = target.mathparameters
+ properties.hasmath = true
+ target.nomath = false
+ target.MathConstants = target.mathparameters
+ --
+ local oldmath = properties.oldmath
+ targetproperties.oldmath = oldmath
+ target.oldmath = oldmath
else
- properties.hasmath = false
- target.nomath = true
- target.mathparameters = nil -- nop
+ properties.hasmath = false
+ target.nomath = true
+ target.mathparameters = nil -- nop
end
--
-- Here we support some context specific trickery (this might move to a plugin). During the
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ctx.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ctx.lua
index 6f8354de853..eead8abff67 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ctx.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ctx.lua
@@ -167,12 +167,8 @@ addformatter(formatters,"font:features",[["'"..sequenced(%s," ",true).."'"]],{ s
-- ... like font-sfm or so
constructors.resolvevirtualtoo = true -- context specific (due to resolver)
-
-if CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 then
- constructors.fixprotrusion = false
-end
-
constructors.sharefonts = true -- experimental
+constructors.nofsharedfonts = 0
constructors.nofsharedhashes = 0
constructors.nofsharedvectors = 0
constructors.noffontsloaded = 0
@@ -202,6 +198,7 @@ do
local shares = { }
local hashes = { }
+
local nofinstances = 0
local instances = setmetatableindex(function(t,k)
nofinstances = nofinstances + 1
@@ -240,7 +237,7 @@ do
end
if psname then
-- this one is used for the funny prefix in font names in pdf
- -- so it has ot be kind of unique in order to avoid subset prefix
+ -- so it has to be kind of unique in order to avoid subset prefix
-- clashes being reported
psname = psname .. ":" .. instances[instance]
target.psname = psname
@@ -327,12 +324,16 @@ function definers.resetnullfont()
definers.resetnullfont = function() end
end
+-- This is some initialization code and we don't want (tracing) clutter in lmtx
+-- which is why we follow a different route there. I admit that is sounds freaky.
+-- Watch out: in lmtx the font dimen array is no longer resized automatically.
+
implement {
- name = "resetnullfont",
- onlyonce = true,
- actions = function()
+ name = "resetnullfont",
+ onlyonce = true,
+ permanent = false,
+ actions = function()
for i=1,7 do
- -- we have no direct method yet
context([[\fontdimen%s\nullfont\zeropoint]],i)
end
definers.resetnullfont()
@@ -1010,7 +1011,8 @@ end
local function splitcontext(features) -- presetcontext creates dummy here
local n, sf
- if find(features,",") then
+ -- We can have: "a=yes,b=yes" "a,b" "a" "a=yes" etc.
+ if find(features,"[,=]") then
--
-- from elsewhere (!)
--
@@ -1166,69 +1168,57 @@ local specifiers = { }
do -- else too many locals
- ----- ctx_setdefaultfontname = context.fntsetdefname
- ----- ctx_setsomefontname = context.fntsetsomename
- ----- ctx_setemptyfontsize = context.fntsetnopsize
- ----- ctx_setsomefontsize = context.fntsetsomesize
- ----- ctx_letvaluerelax = context.letvaluerelax
-
- local starttiming = statistics.starttiming
- local stoptiming = statistics.stoptiming
-
- local scanners = tokens.scanners
- local scanstring = scanners.string
- local scaninteger = scanners.integer
- local scannumber = scanners.number
- local scanboolean = scanners.boolean
-
- local setmacro = tokens.setters.macro
- local scanners = interfaces.scanners
-
- -- function commands.definefont_one(str)
+ local starttiming = statistics.starttiming
+ local stoptiming = statistics.stoptiming
- scanners.definefont_one = function()
- local str = scanstring()
+ local setmacro = tokens.setters.macro
- starttiming(fonts)
- if trace_defining then
- report_defining("memory usage before: %s",statistics.memused())
- report_defining("start stage one: %s",str)
- end
- local fullname, size = lpegmatch(splitpattern,str)
- local lookup, name, sub, method, detail = getspecification(fullname)
- if not name then
- report_defining("strange definition %a",str)
- -- ctx_setdefaultfontname()
- elseif name == "unknown" then
- -- ctx_setdefaultfontname()
- else
- -- ctx_setsomefontname(name)
- setmacro("somefontname",name,"global")
- end
- -- we can also use a count for the size
- if size and size ~= "" then
- local mode, size = lpegmatch(sizepattern,size)
- if size and mode then
- texsetcount("scaledfontmode",mode)
- -- ctx_setsomefontsize(size)
- setmacro("somefontsize",size)
+ implement {
+ name = "definefont_one",
+ arguments = "string",
+ actions = function(str)
+ starttiming(fonts)
+ if trace_defining then
+ report_defining("memory usage before: %s",statistics.memused())
+ report_defining("start stage one: %s",str)
+ end
+ local fullname, size = lpegmatch(splitpattern,str)
+ local lookup, name, sub, method, detail = getspecification(fullname)
+ if not name then
+ report_defining("strange definition %a",str)
+ -- ctx_setdefaultfontname()
+ elseif name == "unknown" then
+ -- ctx_setdefaultfontname()
+ else
+ -- ctx_setsomefontname(name)
+ setmacro("somefontname",name,"global")
+ end
+ -- we can also use a count for the size
+ if size and size ~= "" then
+ local mode, size = lpegmatch(sizepattern,size)
+ if size and mode then
+ texsetcount("scaledfontmode",mode)
+ -- ctx_setsomefontsize(size)
+ setmacro("somefontsize",size)
+ else
+ texsetcount("scaledfontmode",0)
+ -- ctx_setemptyfontsize()
+ end
+ elseif true then
+ -- so we don't need to check in tex
+ texsetcount("scaledfontmode",2)
+ -- ctx_setemptyfontsize()
else
texsetcount("scaledfontmode",0)
-- ctx_setemptyfontsize()
end
- elseif true then
- -- so we don't need to check in tex
- texsetcount("scaledfontmode",2)
- -- ctx_setemptyfontsize()
- else
- texsetcount("scaledfontmode",0)
- -- ctx_setemptyfontsize()
- end
- specification = definers.makespecification(str,lookup,name,sub,method,detail,size)
- if trace_defining then
- report_defining("stop stage one")
+ specification = definers.makespecification(str,lookup,name,sub,method,detail,size)
+-- specification.original = str
+ if trace_defining then
+ report_defining("stop stage one")
+ end
end
- end
+ }
local function nice_cs(cs)
return (gsub(cs,".->", ""))
@@ -1242,179 +1232,224 @@ do -- else too many locals
combinefeatures = v
end)
- scanners.definefont_two = function()
- local global = scanboolean() -- \ifx\fontclass\empty\s!false\else\s!true\fi
- local cs = scanstring () -- {#csname}%
- local str = scanstring () -- \somefontfile
- local size = scaninteger() -- \d_font_scaled_font_size
- local inheritancemode = scaninteger() -- \c_font_feature_inheritance_mode
- local classfeatures = scanstring () -- \m_font_class_features
- local fontfeatures = scanstring () -- \m_font_features
- local classfallbacks = scanstring () -- \m_font_class_fallbacks
- local fontfallbacks = scanstring () -- \m_font_fallbacks
- local mathsize = scaninteger() -- \fontface
- local textsize = scaninteger() -- \d_font_scaled_text_face
- local relativeid = scaninteger() -- \relativefontid
- local classgoodies = scanstring () -- \m_font_class_goodies
- local goodies = scanstring () -- \m_font_goodies
- local classdesignsize = scanstring () -- \m_font_class_designsize
- local fontdesignsize = scanstring () -- \m_font_designsize
- local scaledfontmode = scaninteger() -- \scaledfontmode
-
- if trace_defining then
- report_defining("start stage two: %s, size %s, features %a & %a, mode %a",str,size,classfeatures,fontfeatures,inheritancemode)
- end
- -- name is now resolved and size is scaled cf sa/mo
- local lookup, name, sub, method, detail = getspecification(str or "")
- -- new (todo: inheritancemode)
- local designsize = fontdesignsize ~= "" and fontdesignsize or classdesignsize or ""
- local designname = designsizefilename(name,designsize,size)
- if designname and designname ~= "" then
- if trace_defining or trace_designsize then
- report_defining("remapping name %a, specification %a, size %a, designsize %a",name,designsize,size,designname)
- end
- -- we don't catch detail here
- local o_lookup, o_name, o_sub, o_method, o_detail = getspecification(designname)
- if o_lookup and o_lookup ~= "" then lookup = o_lookup end
- if o_method and o_method ~= "" then method = o_method end
- if o_detail and o_detail ~= "" then detail = o_detail end
- name = o_name
- sub = o_sub
- end
- -- so far
- -- some settings can have been overloaded
- if lookup and lookup ~= "" then
- specification.lookup = lookup
- end
- if relativeid and relativeid ~= "" then -- experimental hook
- local id = tonumber(relativeid) or 0
- specification.relativeid = id > 0 and id
- end
- --
- specification.name = name
- specification.size = size
- specification.sub = (sub and sub ~= "" and sub) or specification.sub
- specification.mathsize = mathsize
- specification.textsize = textsize
- specification.goodies = goodies
- specification.cs = cs
- specification.global = global
- specification.scalemode = scaledfontmode -- context specific
- if detail and detail ~= "" then
- specification.method = method or "*"
- specification.detail = detail
- elseif specification.detail and specification.detail ~= "" then
- -- already set
- elseif inheritancemode == 0 then
- -- nothing
- elseif inheritancemode == 1 then
- -- fontonly
- if fontfeatures and fontfeatures ~= "" then
- specification.method = "*"
- specification.detail = fontfeatures
- end
- if fontfallbacks and fontfallbacks ~= "" then
- specification.fallbacks = fontfallbacks
- end
- elseif inheritancemode == 2 then
- -- classonly
- if classfeatures and classfeatures ~= "" then
- specification.method = "*"
- specification.detail = classfeatures
- end
- if classfallbacks and classfallbacks ~= "" then
- specification.fallbacks = classfallbacks
- end
- elseif inheritancemode == 3 then
- -- fontfirst
- if combinefeatures then
- if classfeatures and classfeatures ~= "" then
- specification.method = "*"
- if fontfeatures and fontfeatures ~= "" and fontfeatures ~= classfeatures then
- specification.detail = classfeatures .. "," .. fontfeatures
- else
- specification.detail = classfeatures
- end
- elseif fontfeatures and fontfeatures ~= "" then
- specification.method = "*"
- specification.detail = fontfeatures
+ implement {
+ name = "definefont_two",
+ arguments = {
+ "boolean", "string", "string", "integer", "integer", "string", "string", "string", "string",
+ "integer", "integer", "integer", "string", "string", "string", "string", "integer",
+ },
+ actions = function (
+ global, -- \ifx\fontclass\empty\s!false\else\s!true\fi
+ cs, -- {#csname}%
+ str, -- \somefontfile
+ size, -- \d_font_scaled_font_size
+ inheritancemode, -- \c_font_feature_inheritance_mode
+ classfeatures, -- \m_font_class_features
+ fontfeatures, -- \m_font_features
+ classfallbacks, -- \m_font_class_fallbacks
+ fontfallbacks, -- \m_font_fallbacks
+ mathsize, -- \fontface
+ textsize, -- \d_font_scaled_text_face
+ relativeid, -- \relativefontid
+ classgoodies, -- \m_font_class_goodies
+ goodies, -- \m_font_goodies
+ classdesignsize, -- \m_font_class_designsize
+ fontdesignsize, -- \m_font_designsize
+ scaledfontmode -- \scaledfontmode
+ )
+ if trace_defining then
+ report_defining("start stage two: %s, size %s, features %a & %a, mode %a",str,size,classfeatures,fontfeatures,inheritancemode)
+ end
+ -- name is now resolved and size is scaled cf sa/mo
+ local lookup, name, sub, method, detail = getspecification(str or "")
+ -- new (todo: inheritancemode)
+ local designsize = fontdesignsize ~= "" and fontdesignsize or classdesignsize or ""
+ local designname = designsizefilename(name,designsize,size)
+ if designname and designname ~= "" then
+ if trace_defining or trace_designsize then
+ report_defining("remapping name %a, specification %a, size %a, designsize %a",name,designsize,size,designname)
end
- else
+ -- we don't catch detail here
+ local o_lookup, o_name, o_sub, o_method, o_detail = getspecification(designname)
+ if o_lookup and o_lookup ~= "" then lookup = o_lookup end
+ if o_method and o_method ~= "" then method = o_method end
+ if o_detail and o_detail ~= "" then detail = o_detail end
+ name = o_name
+ sub = o_sub
+ end
+ -- so far
+ -- some settings can have been overloaded
+ if lookup and lookup ~= "" then
+ specification.lookup = lookup
+ end
+ if relativeid and relativeid ~= "" then -- experimental hook
+ local id = tonumber(relativeid) or 0
+ specification.relativeid = id > 0 and id
+ end
+ --
+ specification.name = name
+ specification.size = size
+ specification.sub = (sub and sub ~= "" and sub) or specification.sub
+ specification.mathsize = mathsize
+ specification.textsize = textsize
+ specification.goodies = goodies
+ specification.cs = cs
+ specification.global = global
+ specification.scalemode = scaledfontmode -- context specific
+ if detail and detail ~= "" then
+ specification.method = method or "*"
+ specification.detail = detail
+ elseif specification.detail and specification.detail ~= "" then
+ -- already set
+ elseif inheritancemode == 0 then
+ -- nothing
+ elseif inheritancemode == 1 then
+ -- fontonly
if fontfeatures and fontfeatures ~= "" then
specification.method = "*"
specification.detail = fontfeatures
- elseif classfeatures and classfeatures ~= "" then
+ end
+ if fontfallbacks and fontfallbacks ~= "" then
+ specification.fallbacks = fontfallbacks
+ end
+ elseif inheritancemode == 2 then
+ -- classonly
+ if classfeatures and classfeatures ~= "" then
specification.method = "*"
specification.detail = classfeatures
end
- end
- if fontfallbacks and fontfallbacks ~= "" then
- specification.fallbacks = fontfallbacks
- elseif classfallbacks and classfallbacks ~= "" then
- specification.fallbacks = classfallbacks
- end
- elseif inheritancemode == 4 then
- -- classfirst
- if combinefeatures then
- if fontfeatures and fontfeatures ~= "" then
- specification.method = "*"
- if classfeatures and classfeatures ~= "" and classfeatures ~= fontfeatures then
- specification.detail = fontfeatures .. "," .. classfeatures
- else
+ if classfallbacks and classfallbacks ~= "" then
+ specification.fallbacks = classfallbacks
+ end
+ elseif inheritancemode == 3 then
+ -- fontfirst
+ if combinefeatures then
+ if classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ if fontfeatures and fontfeatures ~= "" and fontfeatures ~= classfeatures then
+ specification.detail = classfeatures .. "," .. fontfeatures
+ else
+ specification.detail = classfeatures
+ end
+ elseif fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
specification.detail = fontfeatures
end
- elseif classfeatures and classfeatures ~= "" then
- specification.method = "*"
- specification.detail = classfeatures
+ else
+ if fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = fontfeatures
+ elseif classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ end
end
- else
- if classfeatures and classfeatures ~= "" then
- specification.method = "*"
- specification.detail = classfeatures
- elseif fontfeatures and fontfeatures ~= "" then
- specification.method = "*"
- specification.detail = fontfeatures
+ if fontfallbacks and fontfallbacks ~= "" then
+ specification.fallbacks = fontfallbacks
+ elseif classfallbacks and classfallbacks ~= "" then
+ specification.fallbacks = classfallbacks
+ end
+ elseif inheritancemode == 4 then
+ -- classfirst
+ if combinefeatures then
+ if fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ if classfeatures and classfeatures ~= "" and classfeatures ~= fontfeatures then
+ specification.detail = fontfeatures .. "," .. classfeatures
+ else
+ specification.detail = fontfeatures
+ end
+ elseif classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ end
+ else
+ if classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ elseif fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = fontfeatures
+ end
+ end
+ if classfallbacks and classfallbacks ~= "" then
+ specification.fallbacks = classfallbacks
+ elseif fontfallbacks and fontfallbacks ~= "" then
+ specification.fallbacks = fontfallbacks
end
end
- if classfallbacks and classfallbacks ~= "" then
- specification.fallbacks = classfallbacks
- elseif fontfallbacks and fontfallbacks ~= "" then
- specification.fallbacks = fontfallbacks
- end
- end
- --
- local tfmdata = definers.read(specification,size) -- id not yet known (size in spec?)
- --
- local lastfontid = 0
- local tfmtype = type(tfmdata)
- if tfmtype == "table" then
- -- setting the extra characters will move elsewhere
- local characters = tfmdata.characters
- local parameters = tfmdata.parameters
- local properties = tfmdata.properties
- -- we use char0 as signal; cf the spec pdf can handle this (no char in slot)
- characters[0] = nil
- -- characters[0x00A0] = { width = parameters.space }
- -- characters[0x2007] = { width = characters[0x0030] and characters[0x0030].width or parameters.space } -- figure
- -- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period
--
- local fallbacks = specification.fallbacks or ""
- local mathsize = (mathsize == 1 or mathsize == 2 or mathsize == 3) and mathsize or nil -- can be unset so we test 1 2 3
- if fallbacks ~= "" and mathsize and not busy then
- busy = true
- -- We need this ugly hack in order to resolve fontnames (at the \TEX end). Originally
- -- math was done in Lua after loading (plugged into aftercopying).
+ local tfmdata = definers.read(specification,size) -- id not yet known (size in spec?)
+ --
+ local lastfontid = 0
+ local tfmtype = type(tfmdata)
+ if tfmtype == "table" then
+ -- setting the extra characters will move elsewhere
+ local characters = tfmdata.characters
+ local parameters = tfmdata.parameters
+ local properties = tfmdata.properties
+ -- we use char0 as signal; cf the spec pdf can handle this (no char in slot)
+ characters[0] = nil
+ -- characters[0x00A0] = { width = parameters.space }
+ -- characters[0x2007] = { width = characters[0x0030] and characters[0x0030].width or parameters.space } -- figure
+ -- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period
--
- -- After tl 2017 I'll also do text fallbacks this way (although backups there are done
- -- in a completely different way.)
- if trace_defining then
- report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
- name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,1)
- end
- mathematics.resolvefallbacks(tfmdata,specification,fallbacks)
- context(function()
- busy = false
- mathematics.finishfallbacks(tfmdata,specification,fallbacks)
+ local fallbacks = specification.fallbacks or ""
+ local mathsize = (mathsize == 1 or mathsize == 2 or mathsize == 3) and mathsize or nil -- can be unset so we test 1 2 3
+ if fallbacks ~= "" and mathsize and not busy then
+ busy = true
+ -- We need this ugly hack in order to resolve fontnames (at the \TEX end). Originally
+ -- math was done in Lua after loading (plugged into aftercopying).
+ --
+ -- After tl 2017 I'll also do text fallbacks this way (although backups there are done
+ -- in a completely different way.)
+ if trace_defining then
+ report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
+ name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,1)
+ end
+ mathematics.resolvefallbacks(tfmdata,specification,fallbacks)
+ context(function()
+ busy = false
+ mathematics.finishfallbacks(tfmdata,specification,fallbacks)
+tfmdata.original = specification.specification
+ local id = definefont(tfmdata)
+ csnames[id] = specification.cs
+ properties.id = id
+ definers.register(tfmdata,id) -- to be sure, normally already done
+ texdefinefont(global,cs,id)
+ constructors.cleanuptable(tfmdata)
+ constructors.finalize(tfmdata)
+ if trace_defining then
+ report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
+ name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,2)
+ end
+ -- resolved (when designsize is used):
+ local size = round(tfmdata.parameters.size or 655360)
+ setmacro("somefontsize",size.."sp")
+ -- ctx_setsomefontsize(size .. "sp")
+ texsetcount("scaledfontsize",size)
+ lastfontid = id
+ --
+ if trace_defining then
+ report_defining("memory usage after: %s",statistics.memused())
+ report_defining("stop stage two")
+ end
+ --
+ texsetcount("global","lastfontid",lastfontid)
+ specifiers[lastfontid] = { str, size }
+ if not mathsize then
+ -- forget about it (can't happen here)
+ elseif mathsize == 0 then
+ -- can't happen (here)
+ else
+ -- maybe only 1 2 3 (we already test for this)
+ lastmathids[mathsize] = lastfontid
+ end
+ stoptiming(fonts)
+ end)
+ return
+ else
+tfmdata.original = specification.specification
local id = definefont(tfmdata)
csnames[id] = specification.cs
properties.id = id
@@ -1424,7 +1459,7 @@ do -- else too many locals
constructors.finalize(tfmdata)
if trace_defining then
report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
- name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,2)
+ name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-")
end
-- resolved (when designsize is used):
local size = round(tfmdata.parameters.size or 655360)
@@ -1432,102 +1467,78 @@ do -- else too many locals
-- ctx_setsomefontsize(size .. "sp")
texsetcount("scaledfontsize",size)
lastfontid = id
- --
- if trace_defining then
- report_defining("memory usage after: %s",statistics.memused())
- report_defining("stop stage two")
- end
- --
- texsetcount("global","lastfontid",lastfontid)
- specifiers[lastfontid] = { str, size }
- if not mathsize then
- -- forget about it (can't happen here)
- elseif mathsize == 0 then
- -- can't happen (here)
- else
- -- maybe only 1 2 3 (we already test for this)
- lastmathids[mathsize] = lastfontid
- end
- stoptiming(fonts)
- end)
- return
- else
- local id = definefont(tfmdata)
- csnames[id] = specification.cs
- properties.id = id
- definers.register(tfmdata,id) -- to be sure, normally already done
- texdefinefont(global,cs,id)
- constructors.cleanuptable(tfmdata)
- constructors.finalize(tfmdata)
+ end
+ elseif tfmtype == "number" then
if trace_defining then
- report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
- name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-")
+ report_defining("reusing %s, id %a, target %a, features %a / %a, fallbacks %a / %a, goodies %a / %a, designsize %a / %a",
+ name,tfmdata,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies,classdesignsize,fontdesignsize)
end
+ csnames[tfmdata] = specification.cs
+ texdefinefont(global,cs,tfmdata)
-- resolved (when designsize is used):
- local size = round(tfmdata.parameters.size or 655360)
- setmacro("somefontsize",size.."sp")
+ local size = round(fontdata[tfmdata].parameters.size or 0)
-- ctx_setsomefontsize(size .. "sp")
+ setmacro("somefontsize",size.."sp")
texsetcount("scaledfontsize",size)
- lastfontid = id
+ lastfontid = tfmdata
+ else
+ report_defining("unable to define %a as %a",name,nice_cs(cs))
+ lastfontid = -1
+ texsetcount("scaledfontsize",0)
+ -- ctx_letvaluerelax(cs) -- otherwise the current definition takes the previous one
end
- elseif tfmtype == "number" then
if trace_defining then
- report_defining("reusing %s, id %a, target %a, features %a / %a, fallbacks %a / %a, goodies %a / %a, designsize %a / %a",
- name,tfmdata,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies,classdesignsize,fontdesignsize)
- end
- csnames[tfmdata] = specification.cs
- texdefinefont(global,cs,tfmdata)
- -- resolved (when designsize is used):
- local size = round(fontdata[tfmdata].parameters.size or 0)
- -- ctx_setsomefontsize(size .. "sp")
- setmacro("somefontsize",size.."sp")
- texsetcount("scaledfontsize",size)
- lastfontid = tfmdata
- else
- report_defining("unable to define %a as %a",name,nice_cs(cs))
- lastfontid = -1
- texsetcount("scaledfontsize",0)
- -- ctx_letvaluerelax(cs) -- otherwise the current definition takes the previous one
- end
- if trace_defining then
- report_defining("memory usage after: %s",statistics.memused())
- report_defining("stop stage two")
- end
- --
- texsetcount("global","lastfontid",lastfontid)
- specifiers[lastfontid] = { str, size }
- if not mathsize then
- -- forget about it
- elseif mathsize == 0 then
- -- can't happen (here)
- else
- -- maybe only 1 2 3
- lastmathids[mathsize] = lastfontid
+ report_defining("memory usage after: %s",statistics.memused())
+ report_defining("stop stage two")
+ end
+ --
+ texsetcount("global","lastfontid",lastfontid)
+ specifiers[lastfontid] = { str, size }
+ if not mathsize then
+ -- forget about it
+ elseif mathsize == 0 then
+ -- can't happen (here)
+ else
+ -- maybe only 1 2 3
+ lastmathids[mathsize] = lastfontid
+ end
+ --
+ stoptiming(fonts)
end
- --
- stoptiming(fonts)
- end
+ }
- function scanners.specifiedfontspec()
- local f = specifiers[scaninteger()]
- if f then
- context(f[1])
- end
- end
- function scanners.specifiedfontsize()
- local f = specifiers[scaninteger()]
- if f then
- context(f[2])
+ implement {
+ name = "specifiedfontspec",
+ arguments = "integer",
+ actions = function(id)
+ local f = specifiers[id]
+ if f then
+ context(f[1])
+ end
end
- end
- function scanners.specifiedfont()
- local f = specifiers[scaninteger()]
- local s = scannumber()
- if f and s then
- context("%s at %0.2p",f[1],s * f[2]) -- we round to 2 decimals (as at the tex end)
+ }
+
+ implement {
+ name = "specifiedfontsize",
+ arguments = "integer",
+ actions = function(id)
+ local f = specifiers[id]
+ if f then
+ context(f[2])
+ end
end
- end
+ }
+ implement {
+ name = "specifiedfont",
+ arguments = { "integer", "number" },
+ actions = function(id,size)
+ local f = specifiers[id]
+ if f and size then
+ context("%s at %0.2p",f[1],size * f[2]) -- we round to 2 decimals (as at the tex end)
+ end
+ end
+ }
--
local function define(specification)
@@ -1636,17 +1647,7 @@ do -- else too many locals
return id, csnames[id]
end
- local read
-
- if CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 then -- maybe always
- read = function(name,size)
- return (define { name = name, size = size } or 0)
- end
- else
- read = definers.read
- end
-
- callbacks.register('define_font', read, "definition of fonts (tfmdata preparation)")
+ callbacks.register('define_font', definers.read, "definition of fonts (tfmdata preparation)")
-- here
@@ -1812,7 +1813,7 @@ function mappings.loadfile(name)
if trace_mapfiles then
report_mapfiles("loading map file %a",name)
end
- lpdf.setmapfile(name)
+ lpdf.setmapfile(name) -- bah. will go in lmtx
loaded[name] = true
end
end
@@ -1830,7 +1831,7 @@ function mappings.loadline(how,line)
if trace_mapfiles then
report_mapfiles("processing map line %a",line)
end
- lpdf.setmapline(how)
+ lpdf.setmapline(how) -- bah. will go in lmtx
loaded[how] = true
end
end
@@ -3369,8 +3370,3 @@ function fonts.helpers.collectanchors(tfmdata)
return anchors
end
-
-if CONTEXTLMTXMODE > 0 then
- fonts.constructors.addtounicode = false
- fonts.constructors.autocleanup = false
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-def.lua b/Master/texmf-dist/tex/context/base/mkiv/font-def.lua
index e287bf79ce5..b752b3258c4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-def.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-def.lua
@@ -207,9 +207,6 @@ function resolvers.name(specification)
features.normal = normal
end
normal.instance = instance
- -- if not callbacks.supported.glyph_stream_provider then
- -- normal.variableshapes = true -- for the moment
- -- end
end
--
local suffix = lower(suffixonly(resolved))
@@ -492,7 +489,9 @@ function definers.read(specification,size,id) -- id can be optional, name can al
end
else
tfmdata = definers.loadfont(specification) -- can be overloaded
+-- put in properties instead
if tfmdata then
+ tfmdata.original = specification.specification
if trace_defining then
report_defining("loaded and hashed: %s",hash)
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua b/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua
index 3058be37b9a..8d7c3d359d9 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-dsp'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -302,7 +303,7 @@ end)
-- values can be anything the min/max permits so we can either think of
-- real values of a fraction along the axis (probably easier)
--- wght:400,wdth:100,ital:1
+-- wght=400,wdth=100,ital=1
local function axistofactors(str)
local t = settings_to_hash(str)
@@ -502,7 +503,7 @@ local function readvariationdata(f,storeoffset,factors) -- store
regions[i] = t
end
-- deltas
- if factors then
+ -- if factors then
for i=1,nofdeltadata do
setposition(f,storeoffset+deltadata[i])
local nofdeltasets = readushort(f)
@@ -527,7 +528,7 @@ local function readvariationdata(f,storeoffset,factors) -- store
scales = factors and getscales(usedregions,factors) or nil,
}
end
- end
+ -- end
setposition(f,position)
return regions, deltadata
end
@@ -822,7 +823,7 @@ end
-- quite often 0, 1, 2
-function readarray(f,offset)
+local function readarray(f,offset)
if offset then
setposition(f,offset)
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-emp.mklx b/Master/texmf-dist/tex/context/base/mkiv/font-emp.mklx
deleted file mode 100644
index 2bd6f3cf9c2..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-emp.mklx
+++ /dev/null
@@ -1,256 +0,0 @@
-%D \module
-%D [ file=font-emp,
-%D version=20120106, % (moved from font-ini)
-%D title=\CONTEXT\ Font Macros,
-%D subtitle=Emphasis,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Font Macros / Emphasis}
-
-\unprotect
-
-%D \macros
-%D {em,emphasistypeface,emphasisboldface}
-%D
-%D The next macro started as a copy of Donald Arseneau's \type {\em} (\TUGNEWS\
-%D Vol.~3, no.~1, 1994). His implementation was a bit more sophisticated version of
-%D the standard \LATEX\ one. We further enhanced the macro, so now it also adapts
-%D itself to boldface mode. Because we favor {\sl slanted} type over {\it italic},
-%D we made the emphasis adaptable, for instance:
-%D
-%D \starttyping
-%D \def\emphasistypeface {\it}
-%D \def\emphasisboldface {\bi}
-%D \stoptyping
-%D
-%D But we prefer:
-%D
-%D \starttyping
-%D \unexpanded\def\emphasistypeface{\sl}
-%D \unexpanded\def\emphasisboldface{\bs}
-%D \stoptyping
-%D
-%D or even better:
-
-\let\m_font_emphasized_typeface\empty
-
-\def\font_emphasis_checked_typeface#slanted#italic%
- {\edef\m_font_emphasized_typeface{\font_bodyfontvariable\s!em}%
- \ifx\m_font_emphasized_typeface\v!slanted
- #slanted%
- \orelse\ifx\m_font_emphasized_typeface\v!italic
- #italic%
- \orelse\ifx\m_font_emphasized_typeface\empty
- #slanted%
- \else
- \csname\m_font_emphasized_typeface\endcsname
- \fi}
-
-\unexpanded\def\emphasistypeface{\font_emphasis_checked_typeface\sl\it}
-\unexpanded\def\emphasisboldface{\font_emphasis_checked_typeface\bs\bi}
-
-\unexpanded\def\normalboldface % public
- {\relax
- \ifx\fontalternative\s!it\bi\orelse
- \ifx\fontalternative\s!sl\bs\else
- \bf\fi}
-
-\unexpanded\def\normalitalicface % public
- {\relax
- \ifx\fontalternative\s!tf\it\orelse
- \ifx\fontalternative\s!bf\bi\else
- \tf\fi}
-
-\unexpanded\def\normalslantedface % public
- {\relax \ifx\fontalternative\s!tf\sl
- \orelse\ifx\fontalternative\s!bf\bs
- \else \tf\fi}
-
-\unexpanded\def\normaltypeface % public
- {\relax
- \ifx\fontalternative\s!bi \it \orelse
- \ifx\fontalternative\s!bs \sl \else
- \tf \fi}
-
-\unexpanded\def\swaptypeface % public
- {\relax
- \ifx\fontalternative\s!it \tf \orelse
- \ifx\fontalternative\s!sl \tf \orelse
- \ifx\fontalternative\s!bf \emphasisboldface \orelse
- \ifx\fontalternative\s!bs \bf \orelse
- \ifx\fontalternative\s!bi \bf \else
- \emphasistypeface \fi}
-
-\let\typeface \normaltypeface % public
-\let\boldface \normalboldface % public
-\let\slantedface\normalslantedface % public
-\let\italicface \normalitalicface % public
-\let\swapface \swaptypeface % public
-
-%D To be set with the default body font environment: \type
-%D {em} being \type {slanted} or \type {italic}.
-
-% maybe a \csname...\fontalternative\endcsname
-
-\newconditional\c_font_emphasis_needed
-
-\unexpanded\def\em
- {\relax
- \ifdim\slantperpoint>\zeropoint
- \settrue\c_font_emphasis_needed
- \else
- \setfalse\c_font_emphasis_needed
- \fi
- \font_emphasis_set_emphasis_boldface % new
- \ifx\fontalternative\s!it
- \unexpanded\def\emphasistypeface{\it}\tf
- \orelse\ifx\fontalternative\s!sl
- \unexpanded\def\emphasistypeface{\sl}\tf
- \orelse\ifx\fontalternative\s!bf
- \emphasisboldface
- \orelse\ifx\fontalternative\s!bs
- \unexpanded\def\emphasisboldface{\bs}\bf
- \orelse\ifx\fontalternative\s!bi
- \unexpanded\def\emphasisboldface{\bi}\bf
- \else
- \emphasistypeface
- \fi
- \ifconditional\c_font_emphasis_needed\else
- \expandafter\aftergroup
- \fi
- \emphasiscorrection}
-
-%D The next feature was not present in previous versions. It
-%D takes care of \type {\em \bf ...} situations.
-
-\let\font_emphasis_saved_emphasis_boldface\relax
-
-\def\font_emphasis_set_emphasis_boldface
- {\let\font_emphasis_saved_emphasis_boldface\bf
- \let\font_emphasis_set_emphasis_boldface\relax
- \let\bf\font_emphasis_bold_bold}
-
-\unexpanded\def\font_emphasis_bold_bold
- {%\relax
- \let\bf\relax % new
- \ifx\fontalternative\s!it
- \bi
- \orelse\ifx\fontalternative\s!sl
- \bs
- \else
- \font_emphasis_saved_emphasis_boldface
- \fi
- \let\bf\font_emphasis_saved_emphasis_boldface}
-
-%D Donald's (adapted) macros take the next character into account when placing
-%D italic correction. As a bonus we also look for something that looks like a dash,
-%D in which case we don't correct.
-
-\let\italiccorrection=\/ % tex primitive
-
-\def\emphasiscorrection % public, not in raw alignment groups, else omit problem
- {\ifhmode\ifnum\currentgrouptype=\aligngroupcode\else
- \expandafter\expandafter\expandafter\font_emphasis_look
- \fi\fi}
-
-\def\font_emphasis_look
- {\begingroup
- \futurelet\nexttoken\font_emphasis_test}
-
-\def\font_emphasis_test
- {\ifcat\noexpand\nexttoken,% we can do better in luatex ... some day ...
- \expandafter\font_emphasis_a
- \else
- \expandafter\font_emphasis_b
- \fi}
-
-\def\font_emphasis_a
- {\futurelet\nexttoken\font_emphasis_correction}
-
-\def\font_emphasis_correction
- {\setbox\scratchbox\hbox{\nexttoken}% tricky as next can be a macro
- \ifzeropt\ht\scratchbox % probably a space
- \expandafter\font_emphasis_b
- \orelse\ifdim\ht\scratchbox<.3\exheight
- \expandafter\expandafter\expandafter\endgroup
- \else
- \expandafter\expandafter\expandafter\font_emphasis_b
- \fi}
-
-\def\font_emphasis_b
- {\scratchskip\lastskip
- \ifzeropt\scratchskip
- \italiccorrection\relax
- \else
- \unskip\italiccorrection\hskip\scratchskip
- \fi
- \endgroup}
-
-%D We end with some examples which show the behavior when some punctuation is met.
-%D We also show how the mechanism adapts itself to bold, italic and slanted typing.
-%D
-%D \startbuffer
-%D test {test}test \par
-%D test {\sl test}test \par
-%D test {\em test}test \par
-%D test {\em test}--test \par
-%D
-%D test {test}, test \par
-%D test {\em test}, test \par
-%D
-%D test {\em test {\em test {\em test} test} test} test \par
-%D test {\bf test {\em test {\em test} test} test} test \par
-%D test {\sl test {\em test {\em test} test} test} test \par
-%D test {\it test {\em test {\em test} test} test} test \par
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D We get:
-%D
-%D \startpacked
-%D \getbuffer
-%D \stoppacked
-
-%D \macros
-%D {emphbf,emphit,emphsl,emphtf}
-%D
-%D The next emphasis alternatives are for \THANH. They adapt their style as good as
-%D possible. These macros are obsolete in \MKIV.
-
-% \unexpanded\def\emphbf{\groupedcommand{\bf\def\emphit{\bi}\def\emphsl{\bs}}{}}
-% \unexpanded\def\emphit{\groupedcommand{\it\def\emphbf{\bi}\def\emphsl{\sl}}{}}
-% \unexpanded\def\emphsl{\groupedcommand{\sl\def\emphbf{\bs}\def\emphit{\it}}{}}
-% \unexpanded\def\emphtf{\groupedcommand{\tf\def\emphbf{\bf}\def\emphit{\it}\def\emphsl{\sl}}{}}
-% \unexpanded\def\emph {\groupedcommand{\em}{}}
-
-\unexpanded\def\font_emphasis_bf{\bf\def\emphit{\bi}\def\emphsl{\bs}}
-\unexpanded\def\font_emphasis_it{\it\def\emphbf{\bi}\def\emphsl{\sl}}
-\unexpanded\def\font_emphasis_sl{\sl\def\emphbf{\bs}\def\emphit{\it}}
-\unexpanded\def\font_emphasis_tf{\tf\def\emphbf{\bf}\def\emphit{\it}\def\emphsl{\sl}}
-
-\unexpanded\def\emphbf{\triggergroupedcommandcs\font_emphasis_bf}
-\unexpanded\def\emphit{\triggergroupedcommandcs\font_emphasis_it}
-\unexpanded\def\emphsl{\triggergroupedcommandcs\font_emphasis_sl}
-\unexpanded\def\emphtf{\triggergroupedcommandcs\font_emphasis_tf}
-\unexpanded\def\emph {\triggergroupedcommandcs\em}
-
-\unexpanded\def\emphasized{\bgroup\em\let\nexttoken}
-
-%D \startbuffer
-%D TEXT {\emphbf text \emphit text \emphtf text \emphsl text} TEXT
-%D TEXT \emphbf{text \emphit{text} \emphtf{text} \emphsl{text}} TEXT
-%D \stopbuffer
-%D
-%D \typebuffer
-%D \startlines
-%D \getbuffer
-%D \stoplines
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-fil.mklx b/Master/texmf-dist/tex/context/base/mkiv/font-fil.mklx
deleted file mode 100644
index 6cc25db1036..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-fil.mklx
+++ /dev/null
@@ -1,422 +0,0 @@
-%D \module
-%D [ file=font-fil,
-%D version=2011.01.13, % (copied fron font-ini)
-%D title=\CONTEXT\ Font Macros,
-%D subtitle=Classes and Files,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Font Macros / Classes and Files}
-
-\unprotect
-
-%D Personally I think that using \TEX\ macro packages is complicated by the way
-%D fonts are handled. Apart from the many encodings, we also deal with different
-%D naming schemes. Confronted with this problem, I decided to change the definitions
-%D into:
-%D
-%D \starttyping
-%D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt]
-%D \stoptyping
-%D
-%D combined with for instance:
-%D
-%D \starttyping
-%D \definefontsynonym [Times-Roman] [tir]
-%D \stoptyping
-
-% \definetypeface[palatino][rm][serif][palatino,allbold][default]
-%
-% \startfontclass[palatino]
-% \definefontsynonym [Serif] [SerifBold]
-% \definefontsynonym [SerifItalic] [SerifBoldItalic]
-% \definefontsynonym [SerifSlanted] [SerifBoldSlanted]
-% \definefontsynonym [SerifCaps] [SerifBold]
-% \stopfontclass
-%
-% \setupbodyfont[palatino]
-
-\unexpanded\def\startfontclass
- {\dosingleempty\font_basics_start_font_class}
-
-\def\font_basics_start_font_class[#class]%
- {\push_macro_fontclass
- \doifelse{#class}\v!each
- {\let\fontclass\empty}
- {\doifsomething{#class}{\def\fontclass{#class}}}}
-
-\unexpanded\def\stopfontclass
- {\pop_macro_fontclass}
-
-\def\classfont#class#name{#class#name} % \definefont[whatever][\classfont{xx}{yy} at 10pt]
-
-%D \macros
-%D {definefontsynonym, doifelsefontsynonym,
-%D expandfontsynonym, truefontname, truefontdata}
-%D
-%D While looking for fonts, fontsynonyms are used for accessing
-%D the files!
-%D
-%D \starttyping
-%D \definefontsynonym[Serif][Lucida-Bright]
-%D \definefontsynonym[Lucida-Bright][lbr][encoding=texnansi]
-%D \stoptyping
-
-\installcorenamespace {fontfile} % file synonyms
-
-\let\m_font_name\empty
-\let\m_font_file\empty
-
-\def \defaultfontfile{\truefontname{Normal}} % was cmtt10, but that one is gone
-\edef\nullfontname {\fontname\nullfont}
-
-\unexpanded\def\definefontsynonym[#name]#crap[#file]%
- {\edef\m_font_name{#name}%
- \edef\m_font_file{#file}%
- \ifx\fontclass\empty
- \expandafter\font_basics_define_font_synonym_nop
- \else
- \expandafter\font_basics_define_font_synonym_yes
- \fi}
-
-\unexpanded\def\font_basics_define_font_synonym_nop
- {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
- \doifelsenextoptionalcs\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil}
-
-\unexpanded\def\font_basics_define_font_synonym_yes
- {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
- \doifelsenextoptionalcs\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil}
-
-\unexpanded\def\edefinefontsynonym[#name]#crap[#file]%
- {\edef\m_font_name{#name}%
- \edef\m_font_file{#file}%
- \ifx\fontclass\empty
- \expandafter\font_basics_define_font_synonym_nop_expanded
- \else
- \expandafter\font_basics_define_font_synonym_yes_expanded
- \fi}
-
-\unexpanded\def\font_basics_define_font_synonym_nop_expanded#crap[#spec]%
- {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
- \normalexpanded{\font_basics_define_font_synonym_nop_opt[#1]}}
-
-\unexpanded\def\font_basics_define_font_synonym_yes_expanded#crap[#spec]%
- {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
- \normalexpanded{\font_basics_define_font_synonym_yes_opt[#spec]}}
-
-\unexpanded\def\font_basics_define_font_synonym_nop_opt[#specification]%
- {\let\p_features \undefined
- \let\p_fallbacks \undefined
- \let\p_goodies \undefined
- \let\p_designsize\undefined
- \expandafter\font_basics_get_font_parameter_nop#specification,]=,}
-
-\unexpanded\def\font_basics_define_font_synonym_yes_opt[#specification]%
- {\let\p_features \undefined
- \let\p_fallbacks \undefined
- \let\p_goodies \undefined
- \let\p_designsize\undefined
- \expandafter\font_basics_get_font_parameter_yes#specification,]=,}
-
-% todo: check if we can use \edef but then we need to protect \mathsizesuffix .. in fact that
-% can be default then: \let\mathsizesuffix\relax .. i need to play with it first
-
-\def\font_basics_get_font_parameter_nop#key=#value,%
- {\if]#key%
- \font_basics_get_font_parameter_nop_finish
- \else
- \expandafter\normaldef\csname p_#key\endcsname{#value}% % no edef as we need to keep \mathsizesuffix
- \expandafter\font_basics_get_font_parameter_nop
- \fi}
-
-\def\font_basics_get_font_parameter_yes#key=#value,%
- {\if]#key%
- \font_basics_get_font_parameter_yes_finish
- \else
- \expandafter\normaldef\csname p_#key\endcsname{#value}% % no edef as we need to keep \mathsizesuffix
- \expandafter\font_basics_get_font_parameter_yes
- \fi}
-
-% helpers, some day these will be toks and counts
-
-% \def\fntsetdefname {\glet\somefontname\defaultfontfile}
-% \def\fntsetsomename{\gdef\somefontname} % takes argument
-% \def\fntsetnopsize {\let\somefontsize\empty}
-% \def\fntsetsomesize{\def\somefontsize} % takes argument
-
-% happens later, else mkvi parsing gets into troubles
-
-% end of helpers
-
-% we could collect them in one macro (but no expansion)
-
-\def\font_basics_define_font_synonym_nop_nil
- {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\undefined
- \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks \endcsname\undefined
- \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\undefined
- \expandafter\let\csname\??fontfile\m_font_name\s!designsize\endcsname\undefined}
-
-\def\font_basics_define_font_synonym_yes_nil
- {\expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined
- \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\undefined
- \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined
- \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\undefined}
-
-\def\font_basics_get_font_parameter_nop_finish
- {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\p_features
- \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks \endcsname\p_fallbacks
- \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\p_goodies
- \expandafter\let\csname\??fontfile\m_font_name\s!designsize\endcsname\p_designsize}
-
-\def\font_basics_get_font_parameter_yes_finish
- {\expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features
- \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\p_fallbacks
- \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies
- \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\p_designsize}
-
-%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}]
-%
-%\defineclassfontsynonym [KopFont] [officina] [SerifBold]
-
-\unexpanded\def\defineclassfontsynonym
- {\dotripleargument\font_basics_define_class_font_synonym}
-
-%\definefontsynonym[#tag][\fontclassname{#class}{#fileortag}]}
-
-\def\font_basics_define_class_font_synonym[#tag][#class][#fileortag]% needs testing
- {\expandafter\normaldef\csname\??fontfile\fontclass#tag\endcsname{\fontclassname{#class}{#fileortag}}%
- \font_basics_define_font_synonym_yes_nil}
-
-\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater
-
-\unexpanded\def\setupfontsynonym
- {\dodoubleempty\dosetupfontsynonym}
-
-\def\dosetupfontsynonym[#name][#settings]% not yet supported, will do when needed
- {}
-
-% todo: replace * by ... less messy with features
-
-\def\truefontname#name%
- {\expandafter\font_helpers_true_fontname#name*\empty*\relax}
-
-\def\font_helpers_true_fontname#name*#first#rest*#crap\relax
- {\ifcsname\??fontfile\fontclass#name\endcsname
- \ifx#first\empty
- %\expandafter\truefontname\csname\??fontfile\fontclass#name\endcsname
- \expandafter\truefontname\lastnamedcs
- \else
- %\expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname*#first#rest%
- \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest%
- \fi
- \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
- \ifx#first\empty
- %\expandafter\truefontname\csname\??fontfile\defaultfontclass#name\endcsname
- \expandafter\truefontname\lastnamedcs
- \else
- %\expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname*#first#rest%
- \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest%
- \fi
- \orelse\ifcsname\??fontfile#name\endcsname
- \ifx#first\empty
- %\expandafter\truefontname\csname\??fontfile#name\endcsname
- \expandafter\truefontname\lastnamedcs
- \else
- %\expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname*#first#rest%
- \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest%
- \fi
- \else
- #name\ifx#first\empty\else*#first#rest\fi
- \fi}
-
-\def\font_helpers_true_fontname_check#name%
- {\expandafter\font_helpers_true_fontname_check_indeed#name*\relax}
-
-\def\font_helpers_true_fontname_check_indeed#name*#crap\relax
- {\ifcsname\??fontfile\fontclass#name\endcsname
- %\expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname
- \expandafter\font_helpers_true_fontname_check\lastnamedcs
- \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
- %\expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname
- \expandafter\font_helpers_true_fontname_check\lastnamedcs
- \orelse\ifcsname\??fontfile#name\endcsname
- %\expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname
- \expandafter\font_helpers_true_fontname_check\lastnamedcs
- \else
- #name%
- \fi}
-
-% ok when the last lookup is not stripped .. we need to be able to define synonyms for symbols
-%
-% \def\truefontname#name%
-% %{\normalexpanded{\noexpand\font_helpers_true_fontname{\clf_truefontname{#name}}}}
-% {\expandafter\expandafter\expandafter\font_helpers_true_fontname\expandafter\expandafter\expandafter{\clf_truefontname{#name}}}
-%
-% \def\font_helpers_true_fontname#name%
-% {\ifcsname\??fontfile\fontclass#name\endcsname
-% \expandafter\font_helpers_true_fontname\expandafter{\lastnamedcs}%
-% \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
-% \expandafter\font_helpers_true_fontname\expandafter{\lastnamedcs}%
-% \orelse\ifcsname\??fontfile#name\endcsname
-% \expandafter\font_helpers_true_fontname\expandafter{\lastnamedcs}%
-% \else
-% % \clf_truefontname{#name}%
-% #name% so the last one can have features !
-% \fi}
-
-\def\expandfontsynonym#command#name% one level expansion
- {\ifcsname\??fontfile\fontclass#name\endcsname
- %\expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\fontclass#name\endcsname}%
- \expandafter\normaldef\expandafter#command\expandafter{\lastnamedcs}%
- \orelse\ifcsname\??fontfile\defaultfontclass#2\endcsname
- %\expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\defaultfontclass#name\endcsname}%
- \expandafter\normaldef\expandafter#command\expandafter{\lastnamedcs}%
- \fi}
-
-\def\doifelsefontsynonym#name%
- {\ifcsname\??fontfile\fontclass#name\endcsname
- \expandafter\firstoftwoarguments
- \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doiffontsynonymelse\doifelsefontsynonym
-
-%D \macros
-%D {tracedfontname}
-%D
-%D A goody:
-
-\def\tracedfontname#name%
- {#name\ifcsname\??fontfile\fontclass#name\endcsname
- %\expandafter\tracedfontname\csname\??fontfile\fontclass#name\endcsname
- \expandafter\tracedfontname\lastnamedcs
- \orelse\ifcsname\??fontfile#name\endcsname
- %\expandafter\tracedfontname\csname\??fontfile#name\endcsname
- \expandafter\tracedfontname\lastnamedcs
- \fi}
-
-%D \macros
-%D {fontclass, defaultfontclass}
-%D
-%D The fontclass model was introduced a while after we implement the basic font
-%D model and at that time we still defaulted to no model at all. Nowadays we default
-%D to the \type {modern} fontclass.
-
-\let\fontclass \empty
-\let\defaultfontclass\empty
-
-\def\fontclassname#class#name% tricky ... no lastnamedcs here due to nesting
- {\ifcsname\??fontfile#class#name\endcsname
- \fontclassname{#class}{\csname\??fontfile#class#name\endcsname}%
- \orelse\ifcsname\??fontfile#name\endcsname
- \fontclassname{#class}{\csname\??fontfile#name\endcsname}%
- \else
- #2%
- \fi}
-
-\installmacrostack\fontclass
-
-%D Files or names can have properties and these need to be consulted at some point.
-%D They can inherit them.
-
-% Why these expanded and rscale not ... maybe not worth the trouble (delayed
-% expansion actually would be better i.e. macros in feature specs). Test
-% without pre-expansion.
-
-\def\font_helpers_update_font_class_parameters
- {\edef\m_font_class_direction {\begincsname\??fontclass\fontclass\fontstyle\s!direction \endcsname}%
- \edef\m_font_class_features {\begincsname\??fontclass\fontclass\fontstyle\s!features \endcsname}%
- \edef\m_font_class_fallbacks {\begincsname\??fontclass\fontclass\fontstyle\s!fallbacks \endcsname}%
- \edef\m_font_class_goodies {\begincsname\??fontclass\fontclass\fontstyle\s!goodies \endcsname}%
- \edef\m_font_class_designsize{\begincsname\??fontclass\fontclass\fontstyle\s!designsize\endcsname}}
-
-% resolve
-
-\def\font_helpers_set_features_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\orelse % class + symbolic_name
- \ifcsname\??fontfile #name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\orelse % symbolic_name
- \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_features_yes\lastnamedcs \orelse % class + parent_name
- \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_features_yes\lastnamedcs \else % parent_name
- \let\m_font_features\empty\fi}
-
-\def\font_helpers_set_fallbacks_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\orelse
- \ifcsname\??fontfile #name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\orelse
- \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_fallbacks_yes\lastnamedcs \orelse
- \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_fallbacks_yes\lastnamedcs \else
- \let\m_font_fallbacks\empty\fi}
-
-\def\font_helpers_set_goodies_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname \edef\m_font_goodies{\lastnamedcs}\orelse
- \ifcsname\??fontfile #name\s!goodies \endcsname \edef\m_font_goodies{\lastnamedcs}\orelse
- \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_goodies_yes\lastnamedcs \orelse
- \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_goodies_yes\lastnamedcs \else
- \let\m_font_goodies\empty\fi}
-
-\def\font_helpers_set_designsize_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\orelse
- \ifcsname\??fontfile #name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\orelse
- \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_designsize_yes\lastnamedcs \orelse
- \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_designsize_yes\lastnamedcs \else
- \let\m_font_designsize\empty\fi}
-
-\def\font_helpers_set_features_nop#name%
- {\ifcsname\??fontfile#name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\orelse
- \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_features_nop\lastnamedcs \else
- \let\m_font_features\empty\fi}
-
-\def\font_helpers_set_fallbacks_nop#name%
- {\ifcsname\??fontfile#name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\orelse
- \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_fallbacks_nop\lastnamedcs \else
- \let\m_font_fallbacks\empty\fi}
-
-\def\font_helpers_set_goodies_nop#name%
- {\ifcsname\??fontfile#name\s!goodies\endcsname \edef\m_font_goodies{\lastnamedcs}\orelse
- \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_goodies_nop\lastnamedcs \else
- \let\m_font_goodies\empty\fi}
-
-\def\font_helpers_set_designsize_nop#name%
- {\ifcsname\??fontfile#name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\orelse
- \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_designsize_nop\lastnamedcs \else
- \let\m_font_designsize\empty\fi}
-
-\def\font_helpers_update_font_parameters_yes
- {\font_helpers_set_features_yes \somefontname
- \font_helpers_set_fallbacks_yes \somefontname
- \font_helpers_set_goodies_yes \somefontname
- \font_helpers_set_designsize_yes\somefontname}
-
-\def\font_helpers_update_font_parameters_nop
- {\font_helpers_set_features_nop \somefontname
- \font_helpers_set_fallbacks_nop \somefontname
- \font_helpers_set_goodies_nop \somefontname
- \font_helpers_set_designsize_nop\somefontname}
-
-\def\font_helpers_update_font_parameters
- {\ifx\fontclass\empty\font_helpers_update_font_parameters_nop\else\font_helpers_update_font_parameters_yes\fi}
-
-\installcorenamespace{fontclass}
-
-% we can pack them (don't use \setxvalue!)
-
-\unexpanded\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#designsize#direction%
- {\letgvalue{\??fontclass\fontclass#style\s!rscale }#rscale%
- \letgvalue{\??fontclass\fontclass#style\s!features }#features%
- \letgvalue{\??fontclass\fontclass#style\s!fallbacks }#fallbacks%
- \letgvalue{\??fontclass\fontclass#style\s!goodies }#goodies%
- \letgvalue{\??fontclass\fontclass#style\s!designsize}#designsize%
- \letgvalue{\??fontclass\fontclass#style\s!direction }#direction}% math
-
-% bonus
-
-\let\currentfontinstancespec\clf_currentfontinstancespec % expandable
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-fil.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-fil.mkvi
index 8622e733f3d..f70be13eeb2 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-fil.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-fil.mkvi
@@ -103,7 +103,7 @@
\unexpanded\def\font_basics_define_font_synonym_nop_expanded#crap[#spec]%
{\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
- \normalexpanded{\font_basics_define_font_synonym_nop_opt[#1]}}
+ \normalexpanded{\font_basics_define_font_synonym_nop_opt[#spec]}}
\unexpanded\def\font_basics_define_font_synonym_yes_expanded#crap[#spec]%
{\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-gds.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-gds.mkvi
index 05cf087903c..405419416a0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-gds.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-gds.mkvi
@@ -43,6 +43,13 @@
\definecolor[colorscheme:3:6][r=.75,g=.75]
\definecolor[colorscheme:3:7][g=.75]
+\definecolor[colorscheme:4:1] [r=.6] % a
+\definecolor[colorscheme:4:5] [g=.6] % e
+\definecolor[colorscheme:4:9] [b=.6] % i
+\definecolor[colorscheme:4:15][g=.6,b=.6] % o
+\definecolor[colorscheme:4:21][r=.6,b=.6] % u
+\definecolor[colorscheme:4:25][r=.6,b=.6] % y
+
\definesystemattribute[colorscheme][public]
\unexpanded\def\loadfontgoodies[#filename]%
@@ -50,11 +57,11 @@
\unexpanded\def\setfontcolorscheme % will move to the lua end
{\clf_enablefontcolorschemes
- \unexpanded\xdef\setfontcolorscheme[##1]{\attribute\colorschemeattribute##1\relax}%
+ \unexpanded\xdef\setfontcolorscheme[##1]{\c_attr_colorscheme##1\relax}%
\setfontcolorscheme}
\unexpanded\def\resetfontcolorscheme
- {\attribute\colorschemeattribute\attributeunsetvalue}
+ {\c_attr_colorscheme\attributeunsetvalue}
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-imp-combining.lua b/Master/texmf-dist/tex/context/base/mkiv/font-imp-combining.lua
new file mode 100644
index 00000000000..7db3b905aca
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-imp-combining.lua
@@ -0,0 +1,170 @@
+if not modules then modules = { } end modules ['font-imp-combining'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA ADE",
+ copyright = "ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+if not context then return end
+
+local next, unpack = next, unpack
+local sort, copy, insert = table.sort, table.copy, table.insert
+local setmetatableindex = table.setmetatableindex
+
+local fontdata = fonts.hashes.identifiers
+local otf = fonts.handlers.otf
+
+local nuts = nodes.nuts
+
+local nextnode = nuts.traversers.node
+local ischar = nuts.ischar
+local getprev = nuts.getprev
+local getnext = nuts.getnext
+local setprev = nuts.setprev
+local setnext = nuts.setnext
+local setboth = nuts.setboth
+local setlink = nuts.setlink
+local exchange = nuts.exchange
+
+local class = { } -- reused
+local point = { } -- reused
+local classes = { }
+local sorters = { }
+local slide = { }
+local count = 0
+
+-- List provided by Joey McCollum (Hebrew Layout Intelligence):
+--
+-- 1. The consonants (Unicode points 05D0-05EA) have no combining class and are never reordered; this is typographically correct.
+-- 2. Shin dot and sin dot (05C1-05C2) should be next, but Unicode places them in combining classes 24 and 25, after the characters in recommended classes 3-5 and many of the characters in recommended class 6.
+-- 3. Dagesh / mapiq (05BC) should be next, but Unicode assigns it a combining class of 21. This means that it will be incorrectly ordered before characters in recommended class 2 and after characters in recommended classes 4-6 after Unicode normalization.
+-- 4. Rafe (05BF) should be next, but Unicode assigns it a combining class of 23. Thus, it will be correctly placed after characters in recommended class 3, but incorrectly placed before characters in recommended class 2 after Unicode normalization.
+-- 5. The holam and holam haser vowel points (05B9-05BA) should be next, but Unicode places them in combining class 19. This means that it will be placed incorrectly before characters in recommended classes 2-4 and after all characters in recommended class 6 except 05BB after Unicode normalization.
+-- 6. The characters in 0591, 0596, 059B, 05A2-05A7, 05AA, 05B0-05B8, 05BB, 05BD, 05C5, 05C7 should be treated as being in the same class, but Unicode places them in combining classes 10-18, 20, 22, and 220.
+-- 7. The prepositive marks yetiv and dehi (059A, 05AD) should be next; Unicode places them in combining class 222, so they should correctly come after all characters in recommended classes 1-6.
+-- 8. The characters 0307, 0593-0595, 0597-0598, 059C-05A1, 05A8, 05AB-05AC, 05AF, 05C4 should be treated as being in the same class; Unicode places them in combining class 230, so they should correctly come after all characters in recommended classes 1-7.
+-- 9. The postpositive marks segolta, pashta, telisha qetana, and zinor (0592, 0599, 05A9, 05AE) should be next; Unicode places them in combining class 230, so they will need to be reordered after the characters in recommended class 8.
+--
+-- Some tests by Joey:
+--
+-- Arial, Calibri, and Times New Roman will correctly typeset most combinations of points even in Unicode's canonical order, but they typeset the normalized sequences (hiriq, shin dot, tipeha) and (qamatz, dagesh, shin dot) incorrectly and their typographically recommended reorderings correctly.
+-- Cardo will correctly typeset most combinations of points even in Unicode's canonical order, but it typesets the normalized sequences (hiriq, shin dot, tipeha) incorrectly and its typographically recommended reorderings correctly.
+-- Frank Ruehl CLM typesets most combinations of points even in Unicode's canonical order, but it consistently does a poor job positioning cantillation marks even when they are placed in the typographically recommended position. Taamey Frank CLM is another version of the same font that handles this correctly, so it is possible that Frank Ruehl CLM is just an obsolete font that did not have well-implemented Hebrew font features for cantillation marks to begin with.
+-- For Linux Libertine, the text samples with both the normalized mark ordering and the typographically recommended mark ordering were typeset poorly. I think that this is just because that font does not have full support for the Hebrew glyph set (it lacks cantillation marks) or Hebrew font features (it does not place Hebrew diacritical marks intelligently), so no mark reordering would fix its problems.
+-- Taamey David CLM and Taamey Frank CLM exhibits the same typographical mistakes as SBL Hebrew when the input is in Unicode canonical order, and these mistakes go away if the marks are ordered in the typographically recommended way.
+--
+-- SBL Hebrew is used as reference font.
+
+classes.hebr = {
+ [0x05C1] = 1, [0x05C2] = 1,
+ [0x05BC] = 2,
+ [0x05BF] = 3,
+ [0x05B9] = 4, [0x05BA] = 4,
+ [0x0591] = 5, [0x0596] = 5, [0x059B] = 5, [0x05A2] = 5, [0x05A3] = 5, [0x05A4] = 5,
+ [0x05A5] = 5, [0x05A6] = 5, [0x05A7] = 5, [0x05AA] = 5, [0x05B0] = 5, [0x05B1] = 5,
+ [0x05B2] = 5, [0x05B3] = 5, [0x05B4] = 5, [0x05B5] = 5, [0x05B6] = 5, [0x05B7] = 5,
+ [0x05B8] = 5, [0x05BB] = 5, [0x05BD] = 5, [0x05C5] = 5, [0x05C7] = 5,
+ [0x059A] = 6, [0x05AD] = 6,
+ [0x0307] = 7, [0x0593] = 7, [0x0594] = 7, [0x0595] = 7, [0x0597] = 7, [0x0598] = 7,
+ [0x059C] = 7, [0x059D] = 7, [0x059E] = 7, [0x059F] = 7, [0x05A0] = 7, [0x05A1] = 7,
+ [0x05A8] = 7, [0x05AB] = 7, [0x05AC] = 7, [0x05AF] = 7, [0x05C4] = 7,
+ [0x0592] = 8, [0x0599] = 8, [0x05A9] = 8, [0x05AE] = 8,
+}
+
+sorters.hebr = function(a,b)
+ return class[a] < class[b]
+end
+
+-- local dflt = setmetatableindex(function(t,k,v)
+-- for k, v in next, characters.data do
+-- local c = v.combining
+-- if c then
+-- t[k] = c
+-- end
+-- end
+-- setmetatableindex(t,nil)
+-- return t[k]
+-- end)
+--
+-- classes.dflt = dflt
+-- sorters.dflt = function(a,b) return class[b] < class[a] end
+
+-- see analyzeprocessor in case we want scripts
+
+local function reorder(head)
+ if count == 2 then
+ local first = slide[1]
+ local last = slide[2]
+ if sorter(last,first) then
+ head = exchange(head,first,last)
+ end
+ elseif count > 1 then
+ local first = slide[1]
+ local last = slide[count]
+ local before = getprev(first)
+ local after = getnext(last)
+ setprev(first)
+ setnext(last)
+ sort(slide,sorter)
+ setlink(unpack(slide))
+ local first = slide[1]
+ local last = slide[count]
+ if before then
+ setlink(before,first)
+ end
+ setlink(last,after)
+ if first == head then
+ head = first
+ end
+ end
+ count = 0
+ return head
+end
+
+local function reorderprocessor(head,font,attr)
+ local tfmdata = fontdata[font]
+ local script = otf.scriptandlanguage(tfmdata,attr)
+ sorter = sorters[script]
+ if sorter then
+ local classes = classes[script]
+ for n in nextnode, head do
+ local char, id = ischar(n,font)
+ if char then
+ local c = classes[char]
+ if c then
+ if count == 0 then
+ count = 1
+ slide = { n }
+ else
+ count = count + 1
+ slide[count] = n
+ end
+ class[n] = c
+ point[n] = char
+ elseif count > 0 then
+ head = reorder(head)
+ end
+ elseif count > 0 then
+ head = reorder(head)
+ end
+ end
+ if count > 0 then
+ head = reorder(head)
+ end
+ end
+ return head
+end
+
+fonts.constructors.features.otf.register {
+ name = "reordercombining",
+ description = "reorder combining characters",
+-- default = true,
+-- initializers = {
+-- node = reorderinitializer,
+-- },
+ processors = {
+ position = 1,
+ node = reorderprocessor,
+ }
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-imp-dimensions.lua b/Master/texmf-dist/tex/context/base/mkiv/font-imp-dimensions.lua
index 24891a2cdf3..760ce37193a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-imp-dimensions.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-imp-dimensions.lua
@@ -47,6 +47,8 @@ local function initialize(tfmdata,key,value)
newdepth = gettexdimen("strutdp")
elseif value == "mono" then
newwidth = emwidth
+ elseif value == "halfmono" then
+ newwidth = emwidth / 2
else
-- there are fonts out there with no x_height ...
local spec = settings_to_array(value)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-imp-effects.lua b/Master/texmf-dist/tex/context/base/mkiv/font-imp-effects.lua
index cc6e4c0bf88..43ce82b71a6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-imp-effects.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-imp-effects.lua
@@ -215,62 +215,88 @@ local rules = {
-- end
-- end
-local function setmathparameters(tfmdata,characters,mathparameters,dx,dy,squeeze)
- if delta ~= 0 then
- for i=1,#rules do
- local name = rules[i]
- local value = mathparameters[name]
- if value then
- mathparameters[name] = (squeeze or 1) * (value + dx)
+-- radicals are not yet ok
+
+local setmathparameters
+local setmathcharacters
+
+if CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 then
+
+ setmathparameters = function(tfmdata,characters,mathparameters,dx,dy,squeeze,multiplier)
+ if delta ~= 0 then
+ for i=1,#rules do
+ local name = rules[i]
+ local value = mathparameters[name]
+ if value then
+ mathparameters[name] = (squeeze or 1) * (value + dy)
+ end
end
end
end
-end
-local function setmathcharacters(tfmdata,characters,mathparameters,dx,dy,squeeze,wdelta,hdelta,ddelta)
+ setmathcharacters = function()
+ end
+
+else
- local function wdpatch(char)
- if wsnap ~= 0 then
- char.width = char.width + wdelta/2
+ setmathparameters = function(tfmdata,characters,mathparameters,dx,dy,squeeze,multiplier)
+ if delta ~= 0 then
+ for i=1,#rules do
+ local name = rules[i]
+ local value = mathparameters[name]
+ if value then
+ mathparameters[name] = (squeeze or 1) * (value + dy)
+ end
+ end
end
end
- local function htpatch(char)
- if hsnap ~= 0 then
- local height = char.height
- if height then
- char.height = char.height + 2 * dy
+ setmathcharacters = function(tfmdata,characters,mathparameters,dx,dy,squeeze,wdelta,hdelta,ddelta)
+
+ -- still not the perfect rule
+
+ local function wdpatch(char)
+ if wsnap ~= 0 then
+ char.width = char.width + wdelta/2
end
end
- end
- local character = characters[0x221A]
+ local function htpatch(char)
+ if hsnap ~= 0 then
+ local height = char.height
+ if height then
+ char.height = char.height + 2 * dy
+ end
+ end
+ end
- if character and character.next then
--- print("base char",0x221A,table.sequenced(character))
- local char = character
- local next = character.next
- wdpatch(char)
- htpatch(char)
- while next do
- char = characters[next]
+ local character = characters[0x221A]
+
+ if character and character.next then
+ local char = character
+ local next = character.next
wdpatch(char)
htpatch(char)
--- print("next char",next,table.sequenced(char))
- next = char.next
- end
- if char then
- local v = char.vert_variants
- if v then
- local top = v[#v]
- if top then
- local char = characters[top.glyph]
--- print("top char",top.glyph,table.sequenced(char))
- htpatch(char)
+ while next do
+ char = characters[next]
+ wdpatch(char)
+ htpatch(char)
+ next = char.next
+ end
+ if char then
+ local v = char.vert_variants
+ if v then
+ local top = v[#v]
+ if top then
+ local char = characters[top.glyph]
+ htpatch(char)
+ end
end
end
end
+
end
+
end
-- local show_effect = { "lua", function(f,c)
@@ -278,7 +304,7 @@ end
-- inspect(fonts.hashes.characters[f][c])
-- end }
--- local show_effect = { "lua", "print('!')" }
+local shiftmode = CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0
local function manipulateeffect(tfmdata)
local effect = tfmdata.properties.effect
@@ -301,42 +327,49 @@ local function manipulateeffect(tfmdata)
local factor = (1 + effect.factor) * factor
local hfactor = (1 + effect.hfactor) * hfactor
local vfactor = (1 + effect.vfactor) * vfactor
- local vshift = vshift ~= 0 and upcommand[vshift] or false
+ if shiftmode then
+ parameters.hshift = hshift
+ parameters.vshift = vshift
+ else
+ vshift = vshift ~= 0 and upcommand[vshift] or false
+ hshift = rightcommand[hshift]
+ end
for unicode, character in next, characters do
local oldwidth = character.width
local oldheight = character.height
local olddepth = character.depth
if oldwidth and oldwidth > 0 then
character.width = oldwidth + wdelta
- local commands = character.commands
- local hshift = rightcommand[hshift]
- if vshift then
- if commands then
- prependcommands ( commands,
--- show_effect,
- hshift,
- vshift
- )
- else
- character.commands = {
--- show_effect,
- hshift,
- vshift,
- charcommand[unicode]
- }
- end
- else
- if commands then
- prependcommands ( commands,
--- show_effect,
- hshift
- )
+ if not shiftmode then
+ local commands = character.commands
+ if vshift then
+ if commands then
+ prependcommands ( commands,
+ -- show_effect,
+ hshift,
+ vshift
+ )
+ else
+ character.commands = {
+ -- show_effect,
+ hshift,
+ vshift,
+ charcommand[unicode]
+ }
+ end
else
- character.commands = {
--- show_effect,
- hshift,
- charcommand[unicode]
- }
+ if commands then
+ prependcommands ( commands,
+ -- show_effect,
+ hshift
+ )
+ else
+ character.commands = {
+ -- show_effect,
+ hshift,
+ charcommand[unicode]
+ }
+ end
end
end
end
@@ -348,7 +381,7 @@ local function manipulateeffect(tfmdata)
end
end
if mathparameters then
- setmathparameters(tfmdata,characters,mathparameters,dx,dy,squeeze)
+ setmathparameters(tfmdata,characters,mathparameters,dx,dy,squeeze,multiplier)
setmathcharacters(tfmdata,characters,mathparameters,dx,dy,squeeze,wdelta,hdelta,ddelta)
end
parameters.factor = factor
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-imp-italics.lua b/Master/texmf-dist/tex/context/base/mkiv/font-imp-italics.lua
index 83c785d3876..6c432d7cf4a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-imp-italics.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-imp-italics.lua
@@ -79,33 +79,7 @@ if context then
registerotffeature(specification)
registerafmfeature(specification)
-end
-
--- no longer used
-
--- if context then
---
--- -- local function initializemathitalics(tfmdata,value) -- yes no delay
--- -- tfmdata.properties.mathitalics = toboolean(value)
--- -- end
--- --
--- -- local specification = {
--- -- name = "mathitalics",
--- -- description = "use alternative math italic correction",
--- -- initializers = {
--- -- base = initializemathitalics,
--- -- node = initializemathitalics,
--- -- }
--- -- }
--- --
--- -- registerotffeature(specification)
--- -- registerafmfeature(specification)
---
--- end
-
--- -- also not used, only when testing
-
-if context then
+ -- only used when testing
local letter = characters.is_letter
local always = true
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-imp-math.lua b/Master/texmf-dist/tex/context/base/mkiv/font-imp-math.lua
index d93ece4059b..d2294e93c6f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-imp-math.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-imp-math.lua
@@ -79,3 +79,53 @@ registerotffeature {
node = initialize,
}
}
+
+function fonts.helpers.mathscriptslots(tfmdata,textcode)
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local rawfeatures = rawresources and rawresources.features
+ local basesubstitutions = rawfeatures and rawfeatures.gsub
+ local sequences = basesubstitutions and tfmdata.resources.sequences
+ if sequences then
+ local characters = tfmdata.characters
+ if characters[textcode] then
+ for s=1,#sequences do
+ local sequence = sequences[s]
+ local sfeatures = sequence.features
+ if sfeatures and sfeatures.ssty then
+ local steps = sequence.steps
+ for i=1,#steps do
+ local coverage = steps[i].coverage
+ if coverage then
+ local okay = coverage[textcode]
+ if okay then
+ return okay
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+local function initialize(tfmdata,key,value)
+ if value then
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local mathconstants = rawresources.mathconstants
+ if mathconstants then
+ tfmdata.properties.oldmath = true
+ end
+ end
+end
+
+local specification = {
+ name = "oldmath",
+ description = "deal with fake opentype fonts",
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+registerotffeature(specification)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-imp-tracing.lua b/Master/texmf-dist/tex/context/base/mkiv/font-imp-tracing.lua
index 6ce44514372..255b4cdf068 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-imp-tracing.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-imp-tracing.lua
@@ -47,58 +47,22 @@ local v_none = variables.none
-- boundingbox={yes|background|frame|empty|}
-local bp = number.dimenfactors.bp
-local r = 16384 * bp -- 65536 // 4
-local f_1 = formatters["%.6F w 0 %.6F %.6F %.6F re f"]
-local f_2 = formatters["[] 0 d 0 J %.6F w %.6F %.6F %.6F %.6F re S"]
-
--- change this into w h d instead of h d w
-
-local backcache = setmetatableindex(function(t,h)
- local h = h * bp
- local v = setmetatableindex(function(t,d)
- local d = d * bp
- local v = setmetatableindex(function(t,w)
- local v = { "pdf", "origin", f_1(r,-d,w*bp,h+d) }
- t[w] = v
- return v
- end)
- t[d] = v
- return v
- end)
- t[h] = v
- return v
-end)
-
-local forecache = setmetatableindex(function(t,h)
- local h = h * bp
- local v = setmetatableindex(function(t,d)
- local d = d * bp
- local v = setmetatableindex(function(t,w)
- -- the frame goes through the boundingbox
- local v = { "pdf", "origin", f_2(r,r/2,-d+r/2,w*bp-r,h+d-r) }
- t[w] = v
- return v
- end)
- t[d] = v
- return v
- end)
- t[h] = v
- return v
-end)
-
-local startcolor = nil
-local stopcolor = nil
+local backgrounds = nil
+local outlines = nil
+local startcolor = nil
+local stopcolor = nil
local function initialize(tfmdata,key,value)
if value then
- if not backcolors then
+ if not backgrounds then
local vfspecials = backends.pdf.tables.vfspecials
- startcolor = vfspecials.startcolor
- stopcolor = vfspecials.stopcolor
+ startcolor = vfspecials.startcolor
+ stopcolor = vfspecials.stopcolor
+ backgrounds = vfspecials.backgrounds
+ outlines = vfspecials.outlines
end
local characters = tfmdata.characters
- local rulecache = backcache
+ local rulecache = backgrounds
local showchar = true
local color = "palegray"
if type(value) == "string" then
@@ -106,9 +70,9 @@ local function initialize(tfmdata,key,value)
for i=1,#value do
local v = value[i]
if v == v_frame then
- rulecache = forecache
+ rulecache = outlines
elseif v == v_background then
- rulecache = backcache
+ rulecache = backgrounds
elseif v == v_empty then
showchar = false
elseif v == v_none then
@@ -175,107 +139,3 @@ local specification = {
registerotffeature(specification)
registerafmfeature(specification)
-
-local f_m = formatters["%F %F m"]
-local f_l = formatters["%F %F l"]
-local f_b = formatters["[] 0 d 0 J %.6F w"]
-local f_e = formatters["s"]
-
-local function ladder(list,docolor,nocolor,lst,offset,sign,default)
- local l = lst[1]
- local x1 = bp * (offset + l.kern) * sign
- local y1 = bp * l.height
- local t = { f_b(r,r/2), f_m(x1,y1) }
- local n = 2
- local m = #lst
- if default > 0 then
- default = default * bp + r
- else
- default = default * bp - r
- end
- if m == 1 then
- n = n + 1 t[n] = f_l(x1,default)
- else
- for i=1,m do
- local l = lst[i]
- local x2 = bp * (offset + l.kern) * sign
- local y2 = bp * l.height
- if i > 1 and y2 == 0 then
- y2 = default
- end
- n = n + 1 t[n] = f_l(x2,y1)
- n = n + 1 t[n] = f_l(x2,y2)
- x1, y1 = x2, y2
- end
- end
- n = n + 1 t[n] = f_e()
- list[#list+1] = docolor
- list[#list+1] = { "pdf", "origin", concat(t," ") }
- list[#list+1] = nocolor
-end
-
-local function initialize(tfmdata,key,value)
- if value then
- if not backcolors then
- local vfspecials = backends.pdf.tables.vfspecials
- startcolor = vfspecials.startcolor
- stopcolor = vfspecials.stopcolor
- end
- local characters = tfmdata.characters
- local brcolor = startcolor("darkred")
- local trcolor = startcolor("darkgreen")
- local blcolor = startcolor("darkblue")
- local tlcolor = startcolor("darkyellow")
- local black = stopcolor
- for unicode, character in next, characters do
- local mathkern = character.mathkern
- if mathkern then
- -- more efficient would be co collect more in one pdf
- -- directive but this is hardly used so not worth the
- -- effort
- local width = character.width or 0
- local height = character.height or 0
- local depth = character.depth or 0
- local list = { }
- local br = mathkern.bottom_right
- local tr = mathkern.top_right
- local bl = mathkern.bottom_left
- local tl = mathkern.top_left
- if br then
- ladder(list,brcolor,black,br,width,1,height)
- end
- if tr then
- ladder(list,trcolor,black,tr,width,1,-depth)
- end
- if bl then
- ladder(list,blcolor,black,bl,0,-1,height)
- end
- if tl then
- ladder(list,tlcolor,black,tl,0,-1,-depth)
- end
- if #list > 0 then
- local commands = character.commands
- if commands then
- character.commands = appendcommandtable(commands,list)
- else
- list[#list+1] = charcommand[unicode]
- character.commands = list
- end
- end
- end
- end
- end
-end
-
-local specification = {
- name = "staircase",
- description = "show staircase kerns",
- position=1,
- manipulators = {
- base = initialize,
- node = initialize,
- }
-}
-
-registerotffeature(specification)
-registerafmfeature(specification)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ini.mklx b/Master/texmf-dist/tex/context/base/mkiv/font-ini.mklx
deleted file mode 100644
index 4b112322dc3..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ini.mklx
+++ /dev/null
@@ -1,2563 +0,0 @@
-%D \module
-%D [ file=font-ini,
-%D version=1998.09.11, % (second)
-%D version=2001.02.20, % (third)
-%D title=\CONTEXT\ Font Macros,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-% todo: < 3 pt => 3pt
-% todo: check where more class usage
-% todo: split font-nam (style/alternative/size)
-% todo: split font-dim (scales etc)
-% todo: reconsider defaultfontclass
-%
-
-%D Watch out: as we define inside macros in sometimes special ways,
-%D an occasional \type {\normaldef} is used in order to please the
-%D \MKVI\ parser.
-
-%D Beware, we use a special set of parameters here:
-%D
-%D \starttabulate[|l|l|]
-%D \NC system variable (fixed) \NC \type {\s!text} \NC \NR
-%D \NC system variable (fixed) \NC \type {\s!script} \NC \NR
-%D \NC system variable (fixed) \NC \type {\s!scriptscript} \NC \NR
-%D \NC system variable (fixed) \NC \type {\s!x} \NC \NR
-%D \NC system variable (fixed) \NC \type {\s!xx} \NC \NR
-%D \NC variable (value) \NC \type {\v!big} \NC \NR
-%D \NC variable (value) \NC \type {\v!small} \NC \NR
-%D \NC constant (regular key) \NC \type {\c!interlinespace} \NC \NR
-%D \NC constant (regular key) \NC \type {\c!em} \NC \NR
-%D \stoptabulate
-%D
-%D The math related ones are similar to the ones used in \TEX\ itself,
-%D the size related ones show up as keywords in the user interface
-%D when switching sizes, and the two constants are used in key|/|value
-%D situations.
-
-%D We should consider design sizes ... maybe kick 'm out which removes
-%D the size code and simplifies things considerably. After all, there
-%D will be no latin modern math in sizes.
-
-\writestatus{loading}{ConTeXt Font Macros / Initialization}
-
-%D Documentation is somewhat messy as it contains bits and pieces of
-%D previous versions.
-
-\unprotect
-
-%D There are several ways to specify a font. Three of them are pure \TEX\ ones, the
-%D fourth one is new:
-%D
-%D \starttyping
-%D \font\name=cmr12
-%D \font\name=cmr12 at 10pt
-%D \font\name=cmr12 scaled 2
-%D \font\name=cmr12 sa 1.440
-%D \stoptyping
-%D
-%D The non||\TEX\ alternative \type{sa} stands for {\em scaled at}. This means as
-%D much as: scale the bodyfontsize with this factor. The scaled option is not that
-%D useful as one needs to know the design size.
-%D
-%D Because \type {sa} (scaled at) and \type {mo} (mapped on) are not low level \TEX\
-%D supported alternatives, we have to test for it ourselves. In doing so, we need an
-%D auxiliary \DIMENSION. We cannot use \type{\scratchdimen} because font loading can
-%D happen at any moment due to postponed loading. We could instead have used dirty
-%D grouping tricks, but this one works too.
-
-% \enableexperiments[fonts.autorscale]
-%
-% \starttypescript[mscore]
-% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default]
-% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860]
-% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065]
-% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020]
-% \stoptypescript
-%
-% \starttext
-% \setupbodyfont[mscore,12pt]
-% \startTEXpage
-% test \ss test \tt test
-% \stopTEXpage
-% \stoptext
-
-% \definetypeface[one][rm][serif][computer-roman][default]
-% \definetypeface[two][rm][serif][computer-roman][default][rscale=.9]
-%
-% {\one \bf test \two test}
-% {\one \bf test \pushcurrentfont \two \popcurrentfont test}
-
-%D \macros
-%D {rm,ss,tt,hw,cg}
-%D
-%D Fonts are defined in separate files. When we define a font, we distinguish
-%D between several styles. In most cases we will use:
-%D
-%D \startlinecorrection
-%D \starttable[|l||]
-%D \HL
-%D \NC roman regular serif \NC \type{\rm} \NC\FR
-%D \NC sansserif sans support \NC \type{\ss} \NC\MR
-%D \NC type teletype mono \NC \type{\tt} \NC\LR
-%D \HL
-%D \stoptable
-%D \stoplinecorrection
-%D
-%D The number of styles is not limited to these three. When using Lucida Bright we
-%D can for instance also define:
-%D
-%D \startlinecorrection
-%D \starttable[|l||]
-%D \HL
-%D \NC handwritten \NC \type{\hw} \NC\FR
-%D \NC calligraphic \NC \type{\cg} \NC\LR
-%D \HL
-%D \stoptable
-%D \stoplinecorrection
-%D
-%D Within such a font set (\type{cmr}) and style (\type{\rm}) we can define a number
-%D of text font alternatives:
-%D
-%D \startlinecorrection
-%D \starttable[|l||]
-%D \HL
-%D \NC typeface \NC \type{\tf} \NC\FR
-%D \NC boldface \NC \type{\bf} \NC\MR
-%D \NC slanted \NC \type{\sl} \NC\MR
-%D \NC italic \NC \type{\it} \NC\MR
-%D \NC boldslanted \NC \type{\bs} \NC\MR
-%D \NC bolditalic \NC \type{\bi} \NC\MR
-%D \NC smallcaps \NC \type{\sc} \NC\LR
-%D \HL
-%D \stoptable
-%D \stoplinecorrection
-%D
-%D Internally fonts are stored as combination of size, style
-%D and alternative, e.g. \type{12pt}+\type{\ss}+\type{\bf}. Users are not confronted
-%D with sizes, but use the style or style+alternative to activate them.
-%D
-%D During the definition of a bodyfont one can also declare the available larger
-%D alternatives:
-%D
-%D \starttyping
-%D \tf \tfa \tfb \tfc ...
-%D \bf \bfa \bfb \bfc ...
-%D \sl \sla \slb \slc ...
-%D \stoptyping
-%D
-%D The smaller ones are automatically supplied and derived from
-%D the the bodyfont environment.
-%D
-%D \starttyping
-%D \tfx \tfxx
-%D \bfx \bfxx
-%D \slx \slxx
-%D \stoptyping
-%D
-%D There are only two smaller alternatives per style. The larger alternatives on the
-%D other hand have no limitations.
-%D
-%D These larger alternatives are mostly used in chapter and section titles or on
-%D title pages. When one switches to a larger alternative, the bold an other ones
-%D automatically adapt themselves:
-%D
-%D \startbuffer
-%D \tfd Hi \bf there\sl, here \tfb I \bf am
-%D \stopbuffer
-%D
-%S \startnarrower
-%D \typebuffer
-%S \stopnarrower
-%D
-%D therefore becomes:
-%D
-%D \startexample
-%D \getbuffer
-%D \stopexample
-%D
-%D Maybe this mechanism isn't always as logic, but as said before, we tried to make
-%D it as intuitive as possible.
-%D
-%D So a specific kind of glyph can be characterized by:
-%D
-%D \startnarrower
-%D family (cmr) + bodyfont (12pt) + style (rm) + alternative (bf) + size (a)
-%D \stopnarrower
-%D
-%D The last component (the size) is optional.
-%D
-%D We introduced \type {\tf} as command to call for the current normally sized
-%D typeface. This commands results in roman, sans serif, teletype or whatever style
-%D is in charge. Such rather massive switches of style sometimes take more
-%D processing time than comfortable. Of course there is a workaround for this: we
-%D can call fonts directly by means of commands like:
-%D
-%D \starttyping
-%D \rmtf \sssl \tttf \rmbsa
-%D \stoptyping
-%D
-%D One should realize that this fast calls have limitations, they lack for instance
-%D automatic super- and subscript support.
-%D
-%D This leaves us two more commands: \type {\tx} and \type {\txx}. These activate a
-%D smaller and even more smaller font than the current one and adapt themselves to
-%D the current alternative, so when \type {\bf} is active, \type {\tx} gives a
-%D smaller boldface, which in turn can be called directly by \type {\bfx}.
-%D
-%D These two smaller alternatives are specified by the bodyfont environment and
-%D therefore not necessarily have similar sizes as \type {\scriptsize} and \type
-%D {\scriptscriptsize}. The main reason for this incompatibility (which can easily
-%D be undone) lays in the fact that we often want a bit bigger characters than in
-%D math mode. In \CONTEXT\ for instance the \type {\tx} and \type {\txx} commands
-%D are used for surrogate \cap {smallcaps} which support both nesting and
-%D alternatives, like in {\bf \cap {a \cap {small} world}}, which was typeset by
-%D
-%D \starttyping
-%D \bf\cap{a \cap{small} world}
-%D \stoptyping
-%D
-%D And compare $\rm \scriptstyle THIS$ with the slightly larger \cap {THIS}:
-%D \ruledhbox {$\rm \scriptstyle scriptstyle: THIS$} or \ruledhbox {\cap {x style:
-%D THIS}} makes a big difference.
-%D
-%D The \type {x..d} sizes should be used grouped. If you don't group them, i.e. call
-%D them in a row, \CONTEXT\ will not be able to sort out your intention (\type {x}
-%D inside \type {d} inside \type {x}. etc.). The following table demonstrates this:
-%D
-%D \def\FontState{\setstrut\ruledhbox{\strut Hello}}
-%D
-%D \starttabulate[|||||]
-%D \HL
-%D \NC \rlap{\quad\bf grouped} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR
-%D \HL
-%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR
-%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR
-%D \NC \type{\tf} \NC \tf \FontState \NC \tf \tx \FontState \NC \tf \txx \FontState \NC \NR
-%D \NC \type{\tfa} \NC \tfa \FontState \NC \tfa \tx \FontState \NC \tfa \txx \FontState \NC \NR
-%D \NC \type{\tfb} \NC \tfb \FontState \NC \tfb \tx \FontState \NC \tfb \txx \FontState \NC \NR
-%D \NC \type{\tfc} \NC \tfc \FontState \NC \tfc \tx \FontState \NC \tfc \txx \FontState \NC \NR
-%D \NC \type{\tfd} \NC \tfd \FontState \NC \tfd \tx \FontState \NC \tfd \txx \FontState \NC \NR
-%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR
-%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR
-%D \HL
-%D \stoptabulate
-%D
-%D \blank
-%D
-%D \starttabulate[|||||]
-%D \HL
-%D \NC \rlap{\quad\bf stacked} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR
-%D \HL
-%D \NC \type{\tfx}
-%D \NC \tfx \FontState
-%D \NC \tfx \tx \FontState
-%D \NC \tfx \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfxx}
-%D \NC \tfx\tfxx \FontState
-%D \NC \tfx\tfxx \tx \FontState
-%D \NC \tfx\tfxx \txx \FontState
-%D \NC \NR
-%D \NC \type{\tf}
-%D \NC \tfx\tfxx\tf \FontState
-%D \NC \tfx\tfxx\tf \tx \FontState
-%D \NC \tfx\tfxx\tf \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfa}
-%D \NC \tfx\tfxx\tf\tfa \FontState
-%D \NC \tfx\tfxx\tf\tfa \tx \FontState
-%D \NC \tfx\tfxx\tf\tfa \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfb}
-%D \NC \tfx\tfxx\tf\tfa\tfb \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb \tx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfc}
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \tx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfd}
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \tx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfx}
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \tx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \txx \FontState
-%D \NC \NR
-%D \NC \type{\tfxx}
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \tx \FontState
-%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \txx \FontState
-%D \NC \NR
-%D \HL
-%D \stoptabulate
-
-\fontslantperpoint \nullfont 0\scaledpoint
-\fontinterwordspace \nullfont 256377\scaledpoint
-\fontinterwordstretch\nullfont 128188\scaledpoint
-\fontinterwordshrink \nullfont 85459\scaledpoint
-\fontexheight \nullfont 338952\scaledpoint
-\fontemwidth \nullfont 786432\scaledpoint
-\fontextraspace \nullfont 85459\scaledpoint
-
-\appendtoks
- \fontslantperpoint \nullfont 0\scaledpoint
- \fontinterwordspace \nullfont 256377\scaledpoint
- \fontinterwordstretch\nullfont 128188\scaledpoint
- \fontinterwordshrink \nullfont 85459\scaledpoint
- \fontexheight \nullfont 338952\scaledpoint
- \fontemwidth \nullfont 786432\scaledpoint
- \fontextraspace \nullfont 85459\scaledpoint
-\to \everyjob
-
-%D Tracing
-
-\newtoks\t_font_tracers_definitions
-
-\unexpanded\def\tracefontdefinitions
- {\the\t_font_tracers_definitions}
-
-%D Some housekeeping macros:
-
-\unexpanded\def\setfontparameters
- {\setfalse\c_font_synchronize
- \the\everybodyfont
- \settrue\c_font_synchronize}
-
-\let\savedfont\empty
-
-\installmacrostack\savedfont
-
-\unexpanded\def\savefont
- {\edef\savedfont{\the\font}% gives \csname
- \push_macro_savedfont}
-
-\unexpanded\def\restorefont
- {\pop_macro_savedfont
- \savedfont}
-
-\unexpanded\def\pushcurrentfont
- {\edef\popcurrentfont
- {\def\noexpand\fontbody {\fontbody}%
- \def\noexpand\fontstyle {\fontstyle}%
- \def\noexpand\fontalternative{\fontalternative}%
- \def\noexpand\fontsize {\fontsize}%
- \font_helpers_check_big_math_synchronization
- \font_helpers_synchronize_font}}
-
-%D \macros{definedfont}
-
-\let\thedefinedfont\relax % not to be confused with \everydefinefont
-
-\unexpanded\def\definedfont
- {\doifelsenextoptionalcs\font_basics_defined_font_yes\font_basics_defined_font_nop}
-
-\def\font_basics_defined_font_yes[#specification]%
- {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
- \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
- \thedefinedfont
- \the\everydefinedfont}
-
-\def\font_basics_defined_font_nop
- {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
- \thedefinedfont
- \the\everydefinedfont}
-
-%D \macros{startfont}
-
-\unexpanded\def\startfont{\begingroup\definedfont}
-\unexpanded\def\stopfont {\endgroup}
-
-%D \macros
-%D {everybodyfont,everyglobalbodyfont}
-%D
-%D Every change in bodyfont size has conseqences for the baseline distance and skips
-%D between paragraphs. These are initialized in other modules. Here we only provide
-%D the hooks that garantees their handling.
-%D
-%D At the system level one can initialize thing like:
-%D
-%D \starttyping
-%D \appendtoks \setupspacing \to \everybodyfont
-%D \stoptyping
-
-%D \macros
-%D {globalbodyfontsize,localbodyfontsize,bodyfontsize}
-%D
-%D Here we have to distinguish between the global (overal) bodyfont size and the
-%D local (sometimes in the textflow) size. We store these dimensions in two
-%D \DIMENSION\ registers. These registers are not to be misused in calculations.
-
-\ifdefined\globalbodyfontsize\else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt
-\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize
-\ifdefined\bodyfontsize \else \newdimen\bodyfontsize \fi \bodyfontsize =\globalbodyfontsize
-
-%D When we assign for instance 12pt to a \DIMENSION\ register the \type {\the}'d
-%D value comes out as 12.0pt, which is often not the way users specify the bodyfont
-%D size. Therefore we use normalized values. They are cached to save overhead in
-%D \LUA\ calls.
-
-\installcorenamespace{fontnormalizedbody}
-
-\def\normalizebodyfontsize#macro#body%
- {\expandafter\let\expandafter#macro\csname\??fontnormalizedbody\number\dimexpr#body\endcsname
- \ifx#macro\relax
- \normalizebodyfontsize_indeed#macro{#body}%
- \fi}
-
-\def\normalizebodyfontsize_indeed#macro#body%
- {\edef#macro{\clf_nbfs\dimexpr#body\relax}%
- \expandafter\glet\csname\??fontnormalizedbody\number\dimexpr#body\endcsname#macro}
-
-\def\thenormalizedbodyfontsize#body%
- {\clf_nbfs\dimexpr#body\relax}
-
-\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}
-\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
-\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
-
-%D \macros
-%D {mapfontsize}
-%D
-%D For special purposes, like in math, you may want to use slightly different sizes
-%D than the ones given. This happens for instance with the Math Times fonts. Mapped
-%D font sizes can be specified by using the \type {mo} key instead of \type {sa} in
-%D font definitions.
-%D
-%D \startbuffer
-%D \mapfontsize[10pt][11pt]
-%D \mapfontsize[11pt][12pt]
-%D \mapfontsize[12pt][13pt]
-%D
-%D \definefont[test][Serif]\test TEST \par
-%D \definefont[test][Serif sa 5]\test TEST \par
-%D \definefont[test][Serif mo 5]\test TEST \par
-%D \definefont[test][Serif sa d]\test TEST \par
-%D \definefont[test][Serif at 60pt]\test TEST \par
-%D \definefont[test][Serif scaled 6000]\test TEST \par
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startpacked
-%D \getbuffer
-%D \stoppacked
-
-\installcorenamespace{mappedfontsize}
-
-\unexpanded\def\mapfontsize
- {\dodoubleargument\font_basics_map_fontsize}
-
-\def\font_basics_map_fontsize[#from][#to]%
- {\setvalue{\??mappedfontsize\the\dimexpr#from\relax}{#to}}
-
-\def\font_basics_set_mapped_fontsize#from%
- {\ifcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname
- \lastnamedcs\else#from%
- \fi}
-
-\installcorenamespace{fontbodyknown}
-\installcorenamespace{fontclassyes} % fontclass
-\installcorenamespace{fontclassnop} % nofontclass
-
-\def\font_helpers_process_relative_size_list#command% could be a toks
- {#command\v!big
- #command\v!small}
-
-\let\v_font_size_relative \plusone
-\def\v_font_size_absolute {\fontbody}
-
-\let\v_font_rscale_default\!!plusone
-\let\p_font_rscale \v_font_rscale_default
-
-\def\font_helpers_check_relative_font_id % can be plugged in later
- {\let\p_font_rscale\minusone
- \let\p_font_rscale\v_font_rscale_default}
-
-\def\font_helpers_check_relative_font_size#style%
- {\edef\p_font_rscale
- {\ifcsname\??fontclass\fontclass#style\s!rscale\endcsname
- \lastnamedcs
- \orelse\ifcsname\??fontclass\defaultfontclass#style\s!rscale\endcsname % brr
- \lastnamedcs
- \else
- \v_font_rscale_default
- \fi}%
- % move elsewhere
- \ifx\p_font_rscale\v!auto
- \let\p_font_rscale\plusone
- \font_helpers_check_relative_font_id
- \else
- \let\relativefontid\minusone
- \fi}
-
-\def\font_rscale_xx#style%
- {\ifcsname\??fontclass\fontclass#style\s!rscale\endcsname
- \lastnamedcs
- \else
- \v_font_rscale_default
- \fi}
-
-\def\font_rscale_mm
- {\ifcsname\??fontclass\fontclass\s!mm\s!rscale\endcsname
- \lastnamedcs
- \else
- \v_font_rscale_default
- \fi}
-
-\def\font_helpers_register_fontbody#body%
- {\expandafter\let\csname\??fontbodyknown#body\endcsname\empty}
-
-%D \macros
-%D {definefontstyle,definefontsize,definefontalternative}
-%D
-%D When setting of switching the overall style we can use the short identifier like
-%D rm and ss, but when defined we can also use more verbose names like roman or
-%D sansserif. Such names are defined by:
-%D
-%D \starttyping
-%D \definefontstyle [serif,rm] [rm]
-%D \definefontstyle [sansserif,ss] [ss]
-%D \stoptyping
-
-\installcorenamespace{fontstyle} % full style prefix (roman etc)
-\installcorenamespace{fontshortstyle} % short style prefix (rm etc)
-
-\installcorenamespace{fontstyleknown}
-\installcorenamespace{fontalternativeknown}
-\installcorenamespace{fontsizeknown}
-
-\newtoks\t_font_style_commands
-\newtoks\t_font_size_commands
-\newtoks\t_font_alternative_commands
-
-\setnewmacro\m_font_style_command \gobbleoneargument
-\setnewmacro\m_font_size_command \gobbleoneargument
-\setnewmacro\m_font_alternative_command\gobbleoneargument
-
-\def\font_helpers_process_style_list #command{\def\m_font_style_command {#command}\the\t_font_style_commands}
-\def\font_helpers_process_size_list #command{\def\m_font_size_command {#command}\the\t_font_size_commands}
-\def\font_helpers_process_alternative_list#command{\def\m_font_alternative_command{#command}\the\t_font_alternative_commands}
-
-\def\font_helpers_register_style #style{\expandafter\let\csname\??fontstyleknown #style\endcsname\empty}
-\def\font_helpers_register_size #size{\expandafter\let\csname\??fontsizeknown #size\endcsname\empty}
-\def\font_helpers_register_alternative#alternative{\expandafter\let\csname\??fontalternativeknown#alternative\endcsname\empty}
-
-\unexpanded\def\definefontstyle
- {\dodoubleargument\font_basics_define_fontstyle}
-
-\def\font_basics_define_fontstyle[#commands][#style]% style: rm ss tt ...
- {\ifcsname\??fontstyleknown#style\endcsname \else % can be delayed till used (cg, hw)
- \font_helpers_register_style{#style}%
- \toksapp\t_font_style_commands{\m_font_style_command{#style}}%
- \fi
- \processcommalist[#commands]{\font_basics_define_fontstyle_indeed{#style}}}
-
-\def\font_basics_define_fontstyle_indeed#style#command%
- {\setvalue{\??fontshortstyle#command}{#style}%
- \setvalue{\??fontstyle #command}{\csname#style\endcsname}}
-
-\unexpanded\def\definefontsize[#size]%
- {\ifcsname\??fontsizeknown#size\endcsname \else
- \font_helpers_register_size{#size}%
- \toksapp\t_font_size_commands{\m_font_size_command{#size}}%
- \fi
- \font_helpers_check_fontname_combinations}
-
-\unexpanded\def\definefontalternative[#alternative]%
- {\ifcsname\??fontalternativeknown#alternative\endcsname \else
- \font_helpers_register_alternative{#alternative}%
- \toksapp\t_font_alternative_commands{\m_font_alternative_command{#alternative}}%
- \fi
- \font_helpers_check_fontname_combinations}
-
-\unexpanded\def\font_helpers_check_fontname_combinations % we need to split math and text here ... todo (math only has mr and mb)
- {\font_helpers_process_style_list\font_helpers_check_fontname_combinations_s}
-
-\def\font_helpers_check_fontname_combinations_s#style%
- {\font_helpers_process_alternative_list{\font_helpers_check_fontname_combinations_indeed_s_a{#style}}}
-
-\def\font_helpers_check_fontname_combinations_indeed_s_a#style#alternative%
- {\font_helpers_process_size_list{\font_basics_check_fontname_combination{#style}{#alternative}}}
-
-\definefontstyle [\s!mm] [\s!mm]
-\definefontstyle [\s!rm] [\s!rm]
-\definefontstyle [\s!ss] [\s!ss]
-\definefontstyle [\s!tt] [\s!tt]
-
-%D We define all the font switching commands globally. After all they are part of
-%D the formal font interface once defined. The size can be empty (so checking is
-%D needed as \type {\bf} is already defined).
-%D
-%D The \type {\normal..} variants are available as extras for cases where the \type
-%D {..} is overloaded.
-
-\newmacro\m_font_mm
-
-\def\font_basics_check_fontname_combination#style% alternative size
- {\edef\m_font_mm{#style}%
- \ifx\m_font_mm\s!mm % prevents \max and alike (re)defs
- \expandafter\font_basics_check_math_bodyfont
- \else
- \expandafter\font_basics_check_text_bodyfont
- \fi{#style}} % no \m_font_mm, not expanded later on
-
-\def\font_basics_check_math_bodyfont#style#alternative#size%
- {}
-
-\def\font_basics_check_text_bodyfont_step#whatever#body% size can be empty (checking needed as \bf is already defined)
- {\ifcsname#whatever\endcsname\else
- \setugvalue{#whatever}{#body}%
- \fi}
-
-\def\font_basics_check_text_bodyfont#style#alternative#size% size can be empty (checking needed as \bf is already defined)
- {\font_basics_check_text_bodyfont_step{#style#size}{\font_helpers_set_current_font_style_size{#style}{#size}}% \rma
- \font_basics_check_text_bodyfont_step{#alternative#size}{\font_helpers_set_current_font_alternative_size{#alternative}{#size}}% \sla
- \font_basics_check_text_bodyfont_step{#style#alternative#size}{\font_helpers_set_current_font_style_alternative_size{#style}{#alternative}{#size}}% \rmsla
- \font_basics_check_text_bodyfont_step{#style}{\font_helpers_set_current_font_style{#style}}% \rm
- \font_basics_check_text_bodyfont_step{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \sl
- \font_basics_check_text_bodyfont_step{#style\s!x }{\font_helpers_set_current_font_x_style_alternative{#style}}% \rmx
- \font_basics_check_text_bodyfont_step{#style\s!xx}{\font_helpers_set_current_font_xx_style_alternative{#style}}% \rmxx
- \font_basics_check_text_bodyfont_step{#alternative\s!x }{\font_helpers_set_current_font_x_alternative{#alternative}}% \slx
- \font_basics_check_text_bodyfont_step{#alternative\s!xx}{\font_helpers_set_current_font_xx_alternative{#alternative}}% \slxx
- \font_basics_check_text_bodyfont_step{#style#alternative}{\font_helpers_set_current_font_style_alternative{#style}{#alternative}}}% \rmsl
-
-%D Scaling macros:
-%D
-%D This system is somewhat complicated by two (possible conflicting) demands:
-%D
-%D \startitemize
-%D \item We support wildcards like \type {sa *} which will adapt to the current
-%D size. This is also the default specification.
-%D \item We support named scales like \type {sa d}; beware: \type {x} and \type {xx}
-%D are valid scales but they are not alway the same as the ones used in for
-%D instance \type {\bfx} because there the sized come from the bodyfont
-%D environment. In the future there maybe a switch that also honors the
-%D environment in named scales.
-%D \stopitemize
-%D
-%D Keep in mind that the smaller sizes are just for text super and subscripts while
-%D larger sizes can be used in titles where for instance math follows the size.
-
-% b:x{\definedfont[SerifBold sa b]x}{\bfb x $x^x$}\par
-% 1:x{\definedfont[SerifBold sa 1]x}{\bf x $x^x$}\par
-% x:x{\definedfont[SerifBold sa x]x}{\bfx x $x^x$}\par
-% xx:x{\definedfont[SerifBold sa xx]x}{\bfxx x $x^x$}\par
-%
-% *:x{\definedfont[Serif sa *]x}\par
-% 1:x{\definedfont[Serif sa 1]x}\par
-% 2:x{\definedfont[Serif sa 2]x}\par
-% 3:x{\definedfont[Serif sa 3]x}\par
-% 4:x{\definedfont[Serif sa 4]x}\par
-% 5:x{\definedfont[Serif sa 5]x}\par
-
-\def\safontscale{\number\dimexpr\v_font_size_absolute\relax}
-\def\mofontscale{\number\dimexpr\font_basics_set_mapped_fontsize\v_font_size_absolute\relax}
-
-\let\somefontname\s!unknown
-\let\somefontspec\s!unknown
-\let\somefontsize\zerocount
-
-\newcount\scaledfontmode % also used at the lua end
-\newcount\scaledfontsize % also used at the lua end
-\newcount\lastfontid % also used at the lua end / tex end
-\newtoks \everydefinefont
-
-\let\relativefontid\minusone % todo, not yet used
-
-\let\c_font_feature_inheritance_fontnone \zerocount % none
-\let\c_font_feature_inheritance_fontonly \plusone % fontonly
-\let\c_font_feature_inheritance_classonly \plustwo % classonly
-\let\c_font_feature_inheritance_fontfirst \plusthree % fontfirst
-\let\c_font_feature_inheritance_classfirst\plusfour % classfirst
-
-\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst
-
-\setnewconstant\c_font_feature_inheritance_mode \c_font_feature_inheritance_default
-
-\newdimen \d_font_scaled_text_face
-\newdimen \d_font_scaled_font_size
-\newconditional\c_font_body_scale
-\newfraction \f_font_body_scale
-
-\unexpanded\def\font_helpers_low_level_define#specification#csname%
- {% we can now set more at the lua end
- \glet\somefontname\defaultfontfile
- \let\somefontsize\empty
- \clf_definefont_one{\detokenize\expandafter{\normalexpanded{#specification}}}% the escapestring catches at \somedimen
- % sets \scaledfontmode and \somefontname and \somefontsize
- \ifcase\fontface\relax
- % \let\v_font_size_absolute\textface % fontbody
- \or
- \let\v_font_size_absolute\textface
- \or
- \let\v_font_size_absolute\scriptface
- \or
- \let\v_font_size_absolute\scriptscriptface
- \or
- \let\v_font_size_absolute\xtextface
- \or
- \let\v_font_size_absolute\xxtextface
- \fi
- %
- \ifcase\scaledfontmode\relax
- % none, avoid the designsize if possible
- \d_font_scaled_font_size-\plusthousand\scaledpoint
- \or
- % at
- \d_font_scaled_font_size\somefontsize
- \or
- % sa
- \d_font_scaled_font_size\v_font_size_absolute\relax
- \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size % uses \somefontsize set by lua
- \or
- % mo
- \d_font_scaled_font_size\font_basics_set_mapped_fontsize\v_font_size_absolute
- \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
- \or
- % scaled, don't use this one as it's unpredictable
- \d_font_scaled_font_size-\somefontsize\scaledpoint
- \else % ht cp
- % experiment, yet undocumented
- \d_font_scaled_font_size\somefontsize
- \fi
- \relax
- \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size
- \ifconditional\c_font_auto_size
- \font_helpers_check_body_scale\fontsize
- \ifconditional\c_font_body_scale
- \d_font_scaled_font_size\f_font_body_scale\d_font_scaled_font_size
- \d_font_scaled_text_face\f_font_body_scale\dimexpr\textface\relax
- \else
- \d_font_scaled_font_size\f_font_body_scale
- \d_font_scaled_text_face\textface
- \fi
- \else
- \d_font_scaled_text_face\textface
- \fi
- \edef\somefontspec{at \number\d_font_scaled_font_size sp}%
- \edef\somefontfile{\truefontname\somefontname}%
- \ifx\somefontfile\s!unknown
- \edef\somefontfile{\defaultfontfile}%
- \fi
- \font_helpers_update_font_parameters
- \font_helpers_update_font_class_parameters
- %\writestatus{fonts}{low level define: #csname/\somefontfile/\number\d_font_scaled_font_size/\fontface/\number\d_font_scaled_text_face}%
- \clf_definefont_two
- \ifx\fontclass\empty\s!false\else\s!true\fi
- {#csname}%
- {\somefontfile}%
- \d_font_scaled_font_size
- \c_font_feature_inheritance_mode
- {\m_font_class_features}%
- {\m_font_features}%
- {\m_font_class_fallbacks}%
- {\m_font_fallbacks}%
- \fontface
- \d_font_scaled_text_face
- \relativefontid
- {\m_font_class_goodies}%
- {\m_font_goodies}%
- {\m_font_class_designsize}%
- {\m_font_designsize}%
- \scaledfontmode
- \relax
- \ifcase\scaledfontsize
- %\scaledfontsize\plusone
- \let\somefontspec\empty
- \let\lastrawfontcall\relax
- \expandafter\let\csname#csname\endcsname\relax
- \else
- \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks)
- \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname
- \the\everydefinefont
- \fi
- \c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
-
-\def\font_helpers_check_body_scale#fontsize% gets character (x xx a etc)
- {\ifcsname\??fontenvironments\fontclass\fontbody#fontsize\endcsname
- \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
- \setfalse\c_font_body_scale % !
- \orelse\ifcsname\??fontenvironments\fontclass\s!default#fontsize\endcsname
- \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
- \settrue\c_font_body_scale
- \orelse\ifcsname\??fontenvironments\fontbody#fontsize\endcsname
- \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
- \setfalse\c_font_body_scale % !
- \orelse\ifcsname\??fontenvironments\s!default#fontsize\endcsname
- \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
- \settrue\c_font_body_scale
- \orelse\ifcsname\??fontenvironments\fontclass\s!default\s!text\endcsname
- \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
- \settrue\c_font_body_scale
- \orelse\ifcsname\??fontenvironments\s!default\s!text\endcsname
- \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
- \settrue\c_font_body_scale
- \else
- \let\f_font_body_scale\plusone
- \settrue\c_font_body_scale
- \fi}
-
-%D The following macros are used at the \LUA\ end. Watch the \type {\normal}
-%D hackery: this makes the mkvi parser happy.
-
-% \normaldef\fntsetdefname {\glet\somefontname\defaultfontfile} % do before calling
-% \normaldef\fntsetnopsize {\let\somefontsize\empty} % do before calling
-% \normaldef\fntsetsomename{\normalgdef\somefontname} % takes argument
-% \normaldef\fntsetsomesize{\normaldef\somefontsize} % takes argument
-
-\newif\ifskipfontcharacteristics \skipfontcharacteristicstrue
-
-\tracingfonts\plussix %
-
-%D When fontclasses are used, we define the font global, since namespaces are
-%D used. Otherwise we parse the specs each time.
-
-\let\fontfile\s!unknown
-
-%D Relatively new:
-
-\installcorenamespace{fonts}
-\installcorenamespace{fontslanguage}
-
-\installsetuponlycommandhandler \??fonts {fonts}
-
-\newconstant\c_fonts_auto_language
-
-\letvalue{\??fontslanguage\v!auto}\plusone % experimental
-%letvalue{\??fontslanguage\v!yes }\plustwo % less efficient, for experiments
-
-\appendtoks
- \c_fonts_auto_language
- \ifcsname\??fontslanguage\fontsparameter\c!language\endcsname
- \lastnamedcs
- \else
- \zerocount
- \fi
-\to \everysetupfonts
-
-\appendtoks
- \ifcase\c_fonts_auto_language
- % nothing
- \or
- \addfflanguage
- % \or
- % font
- \fi
-\to \everylanguage
-
-% \setupfonts
-% [\c!language=\v!auto]
-
-%D \macros
-%D {everyfont,everyfontswitch}
-
-\ifdefined\everyfont \else \newtoks\everyfont \fi
-\ifdefined\everyfontswitch \else \newtoks\everyfontswitch \fi
-
-\def\setfontcharacteristics{\the\everyfont}
-
-% \appendtoks
-% \ifcase\c_fonts_auto_language
-% % nothing
-% \or
-% % auto
-% \or
-% \addfflanguage
-% \fi
-% \to \everyfont
-
-%D \macros
-%D {definefont}
-%D
-%D We also accept \type{sa a}||\type{sa d} as specification.
-%D
-%D Before we implement the main definition macro, we first show one for local use:
-%D
-%D \starttyping
-%D \definefont[Some][LucidaBright at 100pt] \Some some
-%D \definefont[More][LucidaBright scaled 3000] \More more
-%D \definefont[Nice][LucidaBright mo 2] \Nice nice
-%D \definefont[Text][LucidaBright sa 5.4] \Text last
-%D \stoptyping
-%D
-%D The implementation looks as follows:
-
-\unexpanded\def\definefont % [name][spec][1.6 | line=10pt | setup_id]
- {\dotripleempty\font_basics_define_font}
-
-\def\font_basics_define_font
- {\ifthirdargument
- \expandafter\font_basics_define_font_a
- \else
- \expandafter\font_basics_define_font_b
- \fi}
-
-\def\font_basics_define_font_a[#name][#specification][#settings]% [name][spec][1.6 | line=10pt | setup_id]
- {\doifelsesetups{#settings}%
- {\setuvalue{#name}{\font_basics_define_font_with_setups {#name}{#specification}{#settings}}}
- {\setuvalue{#name}{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}}}
-
-\def\font_basics_define_font_b[#name][#specification][#dummy]%
- {\setuvalue{#name}{\font_basics_define_font_without_parameters{#name}{#specification}}}
-
-\def\font_basics_define_font_with_parameters#name#specification#settings%
- {\font_basics_define_font_without_parameters{#name}{#specification}%
- \setuplocalinterlinespace[#settings]%
- \setupspacing\relax} % is this really needed ?
-
-\def\font_basics_define_font_with_setups#name#specification#settings%
- {\font_basics_define_font_without_parameters{#name}{#specification}%
- \setups[#settings]}
-
-%D Beware, in the frozen variants no settings are supported yet, but that might happen
-%D some day.
-
-\unexpanded\def\definefrozenfont
- {\dotripleempty\font_basics_define_frozen_font}
-
-% \def\font_basics_define_frozen_font[#name][#specification][#settings]%
-% {\begingroup
-% \font_basics_define_font[#name][#specification][#settings]%
-% \csname#name\endcsname
-% \expandafter\expandafter\expandafter\endgroup\expandafter\let\csname#name\endcsname\lastrawfontcall}
-
-\def\font_basics_define_frozen_font[#name][#specification][#settings]%
- {\begingroup
- \font_basics_define_font[#name][#specification][#settings]%
- \csname#name\endcsname
- \glet\lastglobalrawfontcall\lastrawfontcall
- \endgroup
- \expandafter\let\csname#name\endcsname\lastglobalrawfontcall}
-
-%D The instance namespace protection makes the switch local so that we can redefine a
-%D logical name and/or change the size in between.
-
-% todo: now mathsize twice in name (so it can go here)
-% todo: check when mathsize is needed
-
-\ifdefined\??fontinstanceready \else \installcorenamespace{fontinstanceready} \fi
-\ifdefined\??fontinstancebasic \else \installcorenamespace{fontinstancebasic} \fi
-\ifdefined\??fontinstanceclass \else \installcorenamespace{fontinstanceclass} \fi
-
-\newconditional\c_font_auto_size \settrue\c_font_auto_size
-
-\let\lastfontidentifier\empty
-
-\def\v_font_identifier_basic{\??fontinstancebasic \lastfontidentifier-\fontsize-\fontface}
-\def\v_font_identifier_class{\??fontinstanceclass\fontclass-\lastfontidentifier-\fontsize-\fontface}
-
-\let\v_font_identifier_basic_saved\v_font_identifier_basic
-\let\v_font_identifier_class_saved\v_font_identifier_class
-
-% \def\v_font_identifier_class{\??fontinstanceclass\fontclass-\lastfontidentifier-\fontstyle-\fontsize} % no \fontface
-
-\def\font_basics_define_font_without_parameters#identifier#2%
- {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
- \edef\lastfontidentifier{#identifier}%
- \let\v_font_size_relative\v_font_rscale_default
- \let\v_font_size_absolute\fontbody
- \font_helpers_low_level_define{#2}\v_font_identifier_basic
- \csname\v_font_identifier_basic\endcsname
- \setfalse\c_font_auto_size
- \setfontcharacteristics
- \the\everyfontswitch
- \let\v_font_identifier_basic\v_font_identifier_basic_saved}
-
-\unexpanded\def\font_helpers_trigger#identifier% make a traced variant
- {\edef\lastfontidentifier{#identifier}%
- \ifcsname\v_font_identifier_class\endcsname
- % \writestatus{fonts}{trigger: reusing \v_font_identifier_class}%
- \expandafter\font_helpers_trigger_reuse
- \else
- % \writestatus{fonts}{trigger: defining \v_font_identifier_class}%
- \expandafter\font_helpers_trigger_define
- \fi}
-
-\def\font_helpers_trigger_define#relative#absolute#specification%
- {\def\v_font_size_relative{#relative}%
- \def\v_font_size_absolute{#absolute}%
- \font_helpers_low_level_define{#specification}\v_font_identifier_class
- \csname\v_font_identifier_class\endcsname
- \setfalse\c_font_auto_size
- \ifskipfontcharacteristics \else
- \setfontcharacteristics
- \the\everyfontswitch
- \fi
- \let\v_font_identifier_class\v_font_identifier_class_saved}
-
-\def\font_helpers_trigger_reuse#relative#absolute#specification%
- {\csname\v_font_identifier_class\endcsname
- \setfalse\c_font_auto_size
- \ifskipfontcharacteristics \else
- \setfontcharacteristics
- \the\everyfontswitch
- \fi
- \let\v_font_identifier_class\v_font_identifier_class_saved}
-
-%D \macros
-%D {currentfontbodyscale}
-%D
-%D Sometimes we need to have access to the font scale including the \type {a}||\type
-%D {d} sizes. The next macro returns the current scaling factor. Take a look at
-%D \type {cont-log.tex} for an example of its use.
-
-\installcorenamespace{fontenvironments}
-
-\def\currentfontbodysize % gets number (the normal sa 1 etc)
- {\ifcsname\??fontenvironments\fontclass\s!default\somefontsize\endcsname
- \lastnamedcs
- \orelse\ifcsname\??fontenvironments\s!default\somefontsize\endcsname
- \lastnamedcs
- \else
- \somefontsize
- \fi}
-
-\def\currentfontbodyscale % gets character (x xx a etc)
- {\csname\??fontenvironments
- \ifcsname\??fontenvironments\fontclass\s!default\fontsize\endcsname\fontclass\s!default\fontsize\orelse
- \ifcsname\??fontenvironments \s!default\fontsize\endcsname \s!default\fontsize\orelse
- \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\fontclass\s!default\s!text \orelse
- \ifcsname\??fontenvironments \s!default\s!text \endcsname \s!default\s!text \else
- \s!default \fi
- \endcsname}
-
-\def\font_currentfontbodyscale % gets character (x xx a etc)
- {\ifcsname\??fontenvironments\fontclass\s!default\fontsize\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments \s!default\fontsize\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else
- \csname\??fontenvironments \s!default \endcsname \fi}
-
-\def\currentfontscale % used in default definition
- {\csname\??fontenvironments
- \ifcsname\??fontenvironments\fontclass\s!default\xfontsize\endcsname\fontclass\s!default\fontsize\orelse
- \ifcsname\??fontenvironments \s!default\xfontsize\endcsname \s!default\fontsize\orelse
- \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\fontclass\s!default\s!text \orelse
- \ifcsname\??fontenvironments \s!default\s!text \endcsname \s!default\s!text \else
- \s!default \fi
- \endcsname}
-
-\def\font_currentfontscale % used in default definition
- {\ifcsname\??fontenvironments\fontclass\s!default\xfontsize\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments \s!default\xfontsize\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else
- \csname\??fontenvironments \s!default \endcsname \fi}
-
-\setvalue{\??fontenvironments\s!default}{1}
-
-%D In the following macros we use \type {\currentxfontsize} to hold the current
-%D x||size of the font. This enables us to support for instance \type {\sl} inside a
-%D \type {\tx} switch.
-
-\newconstant\currentxfontsize
-
-\def\xfontsize{\ifcase\currentxfontsize\fontsize\or\s!x\else\s!xx\fi}
-
-%D Now we enter the area of font switching. The switching mechanism has to take care
-%D of several situations, like:
-%D
-%D \startitemize[packed]
-%D \item changing the overal document fonts (including margins, headers and footers)
-%D \item changing local fonts (only the running text)
-%D \item smaller and even more smaller alternatives (super- and subscripts)
-%D \stopitemize
-%D
-%D \TEX\ offers a powerfull family mechanism for super- and subscripts in math mode.
-%D In text mode however, we don't use families for the smaller alternatives, and
-%D therefore have to take care of it otherwise.
-%D
-%D \macros
-%D {definebodyfontenvironment,setupbodyfontenvironment}
-%D
-%D The relationship between the several sizes of a font, is
-%D defined by:
-%D
-%D \showsetup{definebodyfontenvironment}
-%D
-%D Later on we will see how these parameters are used, so for the moment we stick
-%D with an example:
-%D
-%D \starttyping
-%D \definebodyfontenvironment
-%D [12pt]
-%D [ text=12pt,
-%D script=9pt,
-%D scriptscript=7pt,
-%D x=10pt,
-%D xx=8pt,
-%D big=12pt,
-%D small=10pt]
-%D \stoptyping
-%D
-%D The first argument specifies the bodyfont size to which the settings apply. All
-%D second parameters are specified in dimensions and tell us more about related
-%D sizes.
-%D
-%D Afterwards, one can change values with
-%D
-%D \showsetup{setupbodyfontenvironment}
-%D
-%D When instead of a size the keyword \type{unknown} is
-%D passed, fractions (relations) are used instead of fixed
-%D sizes.
-
-%D {\bf Remark:} We need to cover the following cases, otherwise users can get
-%D confused:
-%D
-%D \starttyping
-%D \setupbodyfont[23pt]
-%D
-%D \definebodyfontenvironment[23pt]
-%D \setupbodyfont[23pt]
-%D
-%D \definebodyfontenvironment[23pt]
-%D \definebodyfont[23pt][rm,ss,tt][default]
-%D \setupbodyfont[23pt]
-%D \stoptyping
-%D
-%D Beware: while some font defs can be global, the bodyfont environment checks
-%D local. This means that multiple local checks resulting in definitions are not
-%D that efficient. So, apart from an occasional switch, one should define an
-%D environment at the outer level.
-
-% \definebodyfontenvironment[33pt]
-% \definebodyfontenvironment[dejavu][default][1=.5]
-% \definebodyfontenvironment[dejavu][default][x=1.2]
-% \definebodyfontenvironment[dejavu][default][a=5]
-% \definebodyfontenvironment[dejavu][33pt][x=100pt]
-
-% the lookup order is:
-%
-% [class] [dimension] [parameters]
-% [class] [default] [parameters] % factors
-% [dimension] [parameters]
-% [default] [parameters] % factors
-%
-% with defaults providing factors
-
-% todo: class:size
-% todo: make assignments global
-
-\letvalue\??fontenvironments\empty % so we default to empty
-
-\def\bodyfontvariable#parameter%
- {\csname\??fontenvironments
- \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\orelse
- \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse
- \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\orelse
- \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi
- \endcsname}
-
-\def\font_bodyfontvariable#parameter%
- {\ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi}
-
-\def\bodyfontsizevariable#size#parameter%
- {\csname\??fontenvironments
- \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse
- \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse
- \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse
- \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi
- \endcsname}
-
-\def\font_bodyfontsizevariable#size#parameter%
- {\ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments #size#parameter\endcsname\lastnamedcs\orelse
- \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi}
-
-\def\bodyfontinterlinespace{\bodyfontvariable\c!interlinespace} % used elsewhere
-
-\def\bodyfontdimension#class#size#parameter#body%
- {\the\dimexpr
- \ifcsname\??fontenvironments #class#size#parameter\endcsname \lastnamedcs \orelse
- \ifcsname\??fontenvironments#class\s!default#parameter\endcsname \lastnamedcs\dimexpr#body\relax\orelse % factor
- \ifcsname\??fontenvironments #size#parameter\endcsname \lastnamedcs \else
- \lastnamedcs\dimexpr#body\relax\fi % factor
- \relax}
-
-\unexpanded\def\definebodyfontenvironment
- {\dotripleempty\font_basics_define_body_font_environment}
-
-\let\setupbodyfontenvironment\definebodyfontenvironment
-
-\installcorenamespace{fontenvironmentknown}
-
-\def\font_helpers_register_environment#class#body%
- {\expandafter\let\csname\??fontenvironmentknown#class#body\endcsname\empty}
-
-\newmacro\m_font_body
-\newmacro\m_font_body_normalized
-
-\def\font_basics_define_body_font_environment
- {\ifthirdargument
- \singleexpandafter\font_basics_define_body_font_environment_class
- \orelse\ifsecondargument
- \expandafter\font_basics_define_body_font_environment_empty
- \else
- \expandafter\font_basics_define_body_font_environment_unset
- \fi}
-
-%D First we handle the class specific case. Beware: you can change values before
-%D a bodyfont is loaded but changing them afterwards can be sort of tricky as
-%D values are not consulted afterwards.
-
-\def\processbodyfontenvironmentlist#1% no \unexpanded as then we cannot use it in alignments
- {\clf_processbodyfontsizes{\strippedcsname#1}}
-
-\def\bodyfontenvironmentlist
- {\clf_getbodyfontsizes}
-
-\def\font_basics_define_body_font_environment_class[#class][#body][#settings]%
- {\edef\m_font_body{#body}%
- \ifx\m_font_body\s!default
- % these are the last resort within a class
- \getrawparameters[\??fontenvironments#class\s!default][#settings]%
- \else
- \normalizebodyfontsize\m_font_body_normalized\m_font_body
- \font_basics_define_body_font_environment_size[#class][\m_font_body_normalized][#settings]%
- \clf_registerbodyfontsize{\m_font_body_normalized}%
- \fi}
-
-%D The empty case uses the same code but needs to ignore the current class settings
-%D (just to be sure, as it's not really needed).
-
-\def\font_basics_define_body_font_environment_empty[#body][#settings][#dummy]%
- {\push_macro_fontclass
- \let\fontclass\empty
- \font_basics_define_body_font_environment_class[][#body][#settings]%
- \pop_macro_fontclass}
-
-\def\font_basics_define_body_font_environment_unset[#body][#dummya][#dummyb]%
- {\push_macro_fontclass
- \let\fontclass\empty
- \font_basics_define_body_font_environment_class[][#body][]%
- \pop_macro_fontclass}
-
-%D We don't check too soon as we can refer to later definitions.
-
-\newconditional\c_font_defining_environment_state % controls messages
-
-\def\font_basics_define_body_font_environment_size[#class][#normalizedbody][#settings]% normalized body
- {\getrawparameters[\??fontenvironments#class#normalizedbody][#settings]%
- \ifcsname\??fontenvironmentknown#class#normalizedbody\endcsname
- % environment and size already defined
- \orelse\ifproductionrun
- \push_macro_fontclass
- \edef\fontclass{#class}%
- \font_helpers_register_environment{#class}{#normalizedbody}%
- \settrue\c_font_defining_environment_state
- \font_helpers_define_unknown_font{#normalizedbody}% current class
- \setfalse\c_font_defining_environment_state
- \pop_macro_fontclass
- \fi
- \font_helpers_register_fontbody{#normalizedbody}}
-
-%D Checking
-
-\def\font_helpers_check_bodyfont_environment#normalizedbody#body%
- {\ifcsname\??fontenvironmentknown\fontclass#normalizedbody\endcsname
- % already defined
- \else
- \font_helpers_check_bodyfont_environment_indeed{#normalizedbody}{#body}%
- \fi}
-
-\def\font_helpers_check_bodyfont_environment_indeed#normalizedbody#body%
- {\font_helpers_register_environment\fontclass{#normalizedbody}%
- \ifcsname\??fontbodyknown#normalizedbody\endcsname
- \else
- \font_helpers_define_unknown_font{#normalizedbody}%
- \fi}
-
-%D We default all parameters to the main bodyfont size, so the next setup is valid
-%D too:
-%D
-%D \starttyping
-%D \definebodyfontenvironment[24pt]
-%D \stoptyping
-%D
-%D All parameters can be redefined when needed, so one doesnot have to stick to the
-%D default ones.
-
-%D \macros
-%D {definebodyfont}
-%D
-%D The next step in defining a bodyfont involves the actual font files, which can be
-%D recognized by their extension \type {tfm}. Installing those file is often beyond
-%D the scope of the user and up to the system administrator.
-%D
-%D \showsetup{definebodyfont}
-%D
-%D This commands takes three arguments: a (series of) bodyfont size(s), the style
-%D group to which the definitions belong, and an alternative, as specified by the
-%D \TEX\ (math) families, extended with~a, b~\unknown.
-%D
-%D We show two examples, that show all the alternative scaling options. The \type
-%D {\tfa} alternatives can be extended with \type {\bfa}, \type {\slb}, etc. or even
-%D \type {e} and higher alternatives. The magic scaled values are derived from plain
-%D \TEX's \type {\magstep}:
-%D
-%D \starttyping
-%D \definebodyfont [12pt] [rm]
-%D [tf=cmr12,
-%D bf=cmbx12,
-%D it=cmti12,
-%D sl=cmsl12,
-%D bi=cmbxti10 at 12pt,
-%D bs=cmbxsl10 at 12pt,
-%D tfa=cmr12 scaled 1.200,
-%D tfb=cmr12 scaled 1.440,
-%D tfc=cmr12 scaled 1.728,
-%D tfd=cmr12 scaled 2.074,
-%D sc=cmcsc10 at 12pt]
-%D
-%D \definebodyfont [12pt,11pt,10pt,9pt,8pt] [rm]
-%D [tf=lbr sa 1,
-%D bf=lbd sa 1,
-%D it=lbi sa 1,
-%D sl=lbsl sa 1,
-%D bi=lbdi sa 1,
-%D bs=lbdi sa 1,
-%D tfa=lbr sa 1.200,
-%D tfb=lbr sa 1.440,
-%D tfc=lbr sa 1.728,
-%D tfd=lbr sa 2.074,
-%D sc=lbr sa 0.833]
-%D \stoptyping
-%D
-%D The second example shows that we can define more sizes at once. The main
-%D difference between these examples is that the Computer Modern Roman come in many
-%D design sizes. This means that there we cannot define them in bulk using \type
-%D {sa}. Instead of \type {rm} (roman) one can define \type {ss} (sans serif), \type
-%D {tt} (teletype), \type {hw} (hand written), \type {cg} (calygraphic) and whatever
-%D styles.
-%D
-%D The first argument may be a comma separated list. This, combined with
-%D specifications using \type{sa} can save a lot of typing. Although all arguments
-%D should be specified, we treat the second argument as optional.
-%D
-%D Defining a bodyfont involves two actions: defining the specific style related
-%D alternatives, like \type {\rma}, \type {\bfa} and \type {\rmsla}, and storing the
-%D definitions of their bodyfont size related fonts. The first step is bodyfont
-%D independant but executed every time. This permits user definitions like \type
-%D {\tfw} or \type {\bfq} for real large alternatives.
-%D
-%D If we move design size info to the lfg file (after all only lm has design sizes)
-%D we can get rid of much code .. 2012 or so.
-
-\installcorenamespace{fontdefinitions}
-
-% [class] [name] [rm,ss] [settings]
-% [class] [10pt,11pt] [rm,ss] [settings]
-% [class] [10pt,11pt] [rm,ss] [name]
-
-% [class] [name] [settings] == [name] [rm] [settings]
-% [class] [10pt,11pt] [settings] == [name] [rm] [settings]
-% [class] [10pt,11pt] [name] == [10pt,11pt] [rm] [name]
-
-\unexpanded\def\definebodyfont
- {\doquadrupleempty\font_basics_define_body_font}
-
-\def\font_basics_define_body_font[#1][#2][#3][#4]%
- {\iffourthargument
- \processcommacommand[#1]{\font_basics_define_body_font_class_given[#2][#3][#4]}%
- \else
- \font_basics_define_body_font_class_known[#1][#2][#3]%
- \fi}
-
-\def\font_basics_define_body_font_class_given[#1][#2][#3]#4%
- {\push_macro_fontclass
- \doifelse{#4}\s!default
- {\let\fontclass\empty}
- {\def\fontclass{#4}}%
- \definebodyfont[#1][#2][#3]%
- \pop_macro_fontclass}
-
-\def\font_basics_define_body_font_class_known
- {\ifthirdargument
- \singleexpandafter\font_basics_define_body_font_a
- \orelse\ifsecondargument
- \expandafter\font_basics_define_body_font_b
- \else
- \expandafter\font_basics_define_body_font_c
- \fi}
-
-\unexpanded\def\font_basics_define_body_font_b[#whatever][#specification][#dummy]% body|identifier defs|identifier
- {\font_basics_define_body_font_a[#whatever][\s!rm][#specification]}
-
-\unexpanded\def\font_basics_define_body_font_c[#whatever][#dummya][#dummyb]% body|identifier
- {\font_basics_define_body_font_a[#whatever][\s!rm][]}
-
-\unexpanded\def\font_basics_define_body_font_a[#whatever]%
- {\doifelsenumber{#whatever}%
- \font_basics_define_body_font_body
- \font_basics_define_body_font_name
- [#whatever]}
-
-\unexpanded\def\font_basics_define_body_font_body[#body][#style][#specification]%
- {\ifcondition\validassignment{#specification}%
- \expandafter\font_basics_define_body_font_body_assignment
- \else
- \expandafter\font_basics_define_body_font_body_identifier
- \fi
- [#body][#style][#specification]}%
-
-\unexpanded\def\font_basics_define_body_font_name[#name][#style][#specification]%
- {\ifcondition\validassignment{#specification}%
- \expandafter\font_basics_define_body_font_name_assignment
- \else
- \expandafter\font_basics_define_body_font_name_identifier
- \fi
- [#name][#style][#specification]}%
-
-\unexpanded\def\font_basics_define_body_font_body_assignment[#bodylist][#stylelist][#assignments]%
- {\processcommalist[#bodylist]{\font_basics_define_body_font_body_assignment_a{#stylelist}{#assignments}}}
-
-\unexpanded\def\font_basics_define_body_font_body_assignment_a#stylelist#assignments#body%
- {\normalizebodyfontsize\m_font_asked_body{#body}%
- % normally we define quite a lot in advance, i.e global defs
- \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body % !!
- \processcommalist[#stylelist]{\font_basics_define_body_font_body_assignment_b{#assignments}}}
-
-\unexpanded\def\font_basics_define_body_font_body_assignment_b#assignments#style%
- {\edef\m_font_asked_style{#style}%
- \processcommalist[#assignments]\font_basics_define_body_font_defs}
-
-\unexpanded\def\font_basics_define_body_font_defs
- {\ifx\fontclass\empty
- \expandafter\font_basics_define_body_font_defs_nop
- \else
- \expandafter\font_basics_define_body_font_defs_yes
- \fi}
-
-\unexpanded\def\font_basics_define_body_font_defs_yes_normal#assignment%
- {\ifx\m_font_asked_style\s!mm
- \expandafter\font_basics_define_body_font_yes_mm
- \else
- \expandafter\font_basics_define_body_font_yes_xx
- \fi[#assignment]}
-
-\unexpanded\def\font_basics_define_body_font_defs_nop_normal#assignment%
- {\ifx\m_font_asked_style\s!mm
- \expandafter\font_basics_define_body_font_nop_mm
- \else
- \expandafter\font_basics_define_body_font_nop_xx
- \fi[#assignment]}
-
-\unexpanded\def\font_basics_define_body_font_defs_yes_traced#assignment%
- {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}%
- \ifx\m_font_asked_style\s!mm
- \expandafter\font_basics_define_body_font_yes_mm
- \else
- \expandafter\font_basics_define_body_font_yes_xx
- \fi[#assignment]}
-
-\unexpanded\def\font_basics_define_body_font_defs_nop_traced#assignment%
- {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}%
- \ifx\m_font_asked_style\s!mm
- \expandafter\font_basics_define_body_font_nop_mm
- \else
- \expandafter\font_basics_define_body_font_nop_xx
- \fi[#assignment]}
-
-\let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_normal
-\let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_normal
-
-\appendtoks
- \let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_traced
- \let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_traced
-\to \t_font_tracers_definitions
-
-%D We split into two characters (first part of spec) and the rest: the first two are
-%D the style and the rest is a size, although in practice one will seldom define the
-%D size directly. We might even drop that as it gives faster code.
-
-\unexpanded\def\font_basics_define_body_font_nop_xx[#one#two#rest=#value]% local
- {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
- \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname\undefined
- \unexpanded\expandafter\normaledef\csname\??fontinstanceready\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname\undefined
- \unexpanded\expandafter\normaledef\csname\??fontinstanceready\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname\undefined
- \unexpanded\expandafter\normaledef\csname\??fontinstanceready\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- }
-
-\unexpanded\def\font_basics_define_body_font_yes_xx[#one#two#rest=#value]% global
- {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
- \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-1\endcsname\undefined
- \unexpanded\expandafter\normalxdef\csname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-0}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-2\endcsname\undefined
- \unexpanded\expandafter\normalxdef\csname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-4}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-3\endcsname\undefined
- \unexpanded\expandafter\normalxdef\csname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-5}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- }
-
-% \writestatus{fonts}{define \m_asked_style\space yes: {\expandafter\meaning\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}
-
-%D Here the rest concerns rl or lr so in this case it is not a size specifier but
-%D a directional one.
-
-\unexpanded\def\font_basics_define_body_font_nop_mm[#one#two#rest=#value]% local
- {%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi
- \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined
- % \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined
- % \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined
- \unexpanded\expandafter\normaledef\csname\??fontinstanceready\m_font_asked_body-\s!mm-#one#two#rest\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\s!mm-#one#two#rest}{\noexpand\font_rscale_mm}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- }
-
-% \writestatus{fonts}{define \m_asked_style\space nop: \expandafter\meaning\csname\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}%
-
-\unexpanded\def\font_basics_define_body_font_yes_mm[#one#two#rest=#value]% global
- {%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi
- \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined
- % \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined
- % \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined
- \unexpanded\expandafter\normalxdef\csname\??fontinstanceready\fontclass-\m_font_asked_body-\s!mm-#one#two#rest\endcsname
- {\font_helpers_trigger{\m_font_asked_body-\s!mm-#one#two#rest}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
- }
-
-% \writestatus{fonts}{define \m_asked_style\space yes: \expandafter\meaning\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}%
-
-\unexpanded\def\font_basics_define_body_font_body_identifier[#bodylist][#stylelist][#name]%
- {\processcommalist[#bodylist]{\font_basics_define_body_font_body_identifier_a{#stylelist}{#name}}}
-
-\unexpanded\def\font_basics_define_body_font_body_identifier_a#stylelist#name#body%
- {\normalizebodyfontsize\m_font_asked_body{#body}%
- \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body % !!
- \processcommalist[#stylelist]{\font_basics_define_body_font_body_identifier_b{#name}}}
-
-\unexpanded\def\font_basics_define_body_font_body_identifier_b#name#style%
- {\edef\m_font_asked_style{#style}%
- %\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] => [#name]}%
- \csname\??fontdefinitions#name:\m_font_asked_style\endcsname} % no checking
-
-\unexpanded\def\font_basics_define_body_font_name_assignment[#name][#stylelist][#assignments]%
- {\processcommalist[#stylelist]{\font_basics_define_body_font_name_assignment_a{#name}{#assignments}}}
-
-\unexpanded\def\font_basics_define_body_font_name_assignment_a#name#assignments#style%
- {%\writestatus\m!fonts{[#name:#style] => [#assignments]}%
- \setevalue{\??fontdefinitions#name:#style}{\font_basics_define_body_font_default{#assignments}}}
-
-\unexpanded\def\font_basics_define_body_font_name_identifier[#name][#stylelist][#identifier]%
- {\processcommalist[#stylelist]{\font_basics_define_body_font_name_identifier_a{#name}{#identifier}}}
-
-\unexpanded\def\font_basics_define_body_font_name_identifier_a#name#identifier#style%
- {%\writestatus\m!fonts{[#name:#style] => [##identifier:#style]}%
- \ifcsname\??fontdefinitions#name:#style\endcsname
- \expandafter\let\csname\??fontdefinitions#name:#style\expandafter\endcsname\csname\??fontdefinitions#identifier:#style\endcsname
- \else
- \expandafter\def\csname\??fontdefinitions#name:#style\endcsname{\csname\??fontdefinitions#identifier:#style\endcsname}%
- \fi}
-
-%D The unknown:
-
-\newconditional\c_font_defining_unknown
-\newconditional\c_font_defining_state
-
-\unexpanded\def\font_helpers_define_unknown_font#body% one level only
- {\font_helpers_register_fontbody{#body}% prevents loop, can go
- \setfalse\c_font_defining_state
- \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_sizes{#body}}%
- \ifconditional\c_font_defining_state
- \setfalse\c_font_defining_state
- \font_helpers_process_style_list{\font_helpers_define_unknown_check_definitions{#body}}%
- \ifconditional\c_font_defining_state
- \ifconditional\c_font_defining_environment_state\else
- %\showmessage\m!fonts{14}{#body}% main
- \clf_registerunknownbodysize{#body}%
- \fi
- \setfalse\c_font_defining_state
- \font_helpers_register_fontbody{#body}%
- % needed ?
- \ifconditional\c_font_defining_unknown
- \else
- \settrue\c_font_defining_unknown
- \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_relatives{#body}}%
- \setfalse\c_font_defining_unknown
- \fi
- \fi
- \fi}
-
-\def\font_helpers_define_unknown_check_sizes#body#relativesize%
- {\ifcsname\??fontenvironments\s!default#relativesize\endcsname % fontclass ?
- \expandafter\normalizebodyfontsize\csname\??fontenvironments#body#relativesize\endcsname{\csname\??fontenvironments\s!default#relativesize\endcsname\dimexpr#body\relax}%
- \settrue\c_font_defining_state
- \fi}
-
-\def\font_helpers_define_unknown_check_definitions#body#style%
- {\ifcsname\??fontdefinitions\s!default:#style\endcsname
- \edef\m_font_asked_body{#body}%
- \edef\m_font_asked_style{#style}%
- \lastnamedcs
- \settrue\c_font_defining_state
- \fi}
-
-% \def\font_helpers_define_unknown_check_relatives#body#relativesize%
-% {\ifcsname\??fontbodyknown\csname\??fontenvironments#body#relativesize\endcsname\endcsname \else
-% % how \lastnamedcs here
-% \expandafter\font_helpers_define_unknown_font\csname\??fontenvironments#body#relativesize\endcsname
-% \settrue\c_font_defining_state
-% \fi}
-
-\def\font_helpers_define_unknown_check_relatives#body#relativesize%
- {\ifcsname\??fontbodyknown\csname\??fontenvironments#body#relativesize\endcsname\endcsname \else
- \expandafter\font_helpers_define_unknown_font\csname\??fontenvironments#body#relativesize\endcsname
- \settrue\c_font_defining_state
- \fi}
-
-\unexpanded\def\font_basics_define_body_font_default#assignments%
- {\font_helpers_check_relative_font_size\m_font_asked_style % still needed here?
- \ifcsname\m_font_asked_style\endcsname\else
- \normalexpanded{\definefontstyle[\m_font_asked_style][\m_font_asked_style]}%
- \fi
- \processcommalist[#assignments]\font_basics_define_body_font_defs
- \let\p_font_rscale\v_font_rscale_default}
-
-%D These macros show that quite some definitions take place. Fonts are not loaded
-%D yet! This means that at format generation time, no font files are present.
-
-\unexpanded\def\font_basics_switch_points#body%
- {\ifcsname\??fontbodyknown#body\endcsname \else
- % we need to check the relative sizes for this body
- \font_helpers_define_unknown_font{#body}%
- \fi%
- \ifcsname\??fontbodyknown#body\endcsname % always true now
- \font_basics_complete_switch{#body}%
- \localbodyfontsize#body\relax
- \normalizebodyfontsize\normalizedbodyfontsize\localbodyfontsize
- \font_helpers_check_bodyfont_environment\normalizedbodyfontsize\normalizedbodyfontsize % !!
- \else
- \showmessage\m!fonts4{#body}%
- \fi}
-
-\unexpanded\def\font_basics_switch_style#style%
- {\ifcsname\??fontstyle#style\endcsname
- \lastnamedcs
- \edef\fontstyle{#style}%
- \ifmmode\mr\fi % in order to be compatible with \rm in math mode
- % \the\everybodyfont % cleaner, in setting size as well as style
- \else
- \showmessage\m!fonts5{#style}%
- \fi}
-
-%D Here comes the main font switching macros. These macros handle changes in size as
-%D well as returning to the global bodyfont size.
-
-\ifdefined\font_preloads_at_definition \else \let\font_preloads_at_definition\relax \fi
-
-\def\font_helpers_set_font#method#specification%
- {\edef\m_font_specification{#specification}%
- \ifx\m_font_specification\empty \else
- \ifx\m_font_specification\v!global % we can have all kind of presets
- \restoreglobalbodyfont
- \else
- \processcommacommand[\m_font_specification]{\font_helpers_set_font_check_size}%
- \processcommacommand[\m_font_specification]{\font_helpers_set_font_set_font{#method}}%
- \ifproductionrun
- \font_preloads_at_definition
- \font_basics_switch_points\normalizedbodyfontsize
- \font_basics_switch_style\fontstyle
- \ifx\defaultfontclass\empty
- \let\defaultfontclass\fontclass
- \fi
- \fi
- \fi
- \currentxfontsize\zerocount
- \fi}
-
-\def\font_helpers_set_font_check_size#option%
- {\doifelsenumber{#option}{\font_helpers_check_bodyfont_environment{#option}{#option}}\donothing}
-
-\def\font_helpers_set_font_set_font#method#option% method=1: set, method=2: switch
- {\doifsomething{#option}{\font_helpers_set_font_set_font_option{#method}{#option}}}
-
-\def\font_helpers_set_font_set_font_option#method#option%
- {\doifelsenumber{#option}%
- \font_helpers_set_font_set_font_option_body
- \font_helpers_set_font_set_font_option_keyword
- {#method}{#option}{#option}}
-
-\newmacro\m_font_keyword
-
-\unexpanded\def\font_helpers_set_font_set_font_option_keyword#method#keyword#message%
- {\edef\m_font_keyword{#keyword}%
- \ifcsname\??fontenvironments\normalizedbodyfontsize\m_font_keyword\endcsname
- \edef\m_font_step{\font_bodyfontvariable\m_font_keyword}%
- \normalexpanded{\font_helpers_set_font_set_font_option_body{#method}{\m_font_step}{#message}}%
- \orelse\ifx\m_font_keyword\v!reset
- \let\fontstyle\empty % new 31/7/2006
- \let\fontsize \empty
- \orelse\ifcsname\??fontstyle\m_font_keyword\endcsname
- \let\fontstyle\m_font_keyword
- \else
- \setcurrentfontclass\m_font_keyword
- \ifcase#method\relax
- \let\globalfontclass\globalfontclass % -)
- \else
- \let\globalfontclass\fontclass
- \fi
- \font_helpers_set_fontstyle_of_fontclass
- \fi}
-
-\def\font_helpers_set_fontstyle_of_fontclass % will be overloaded later
- {\let\fontstyle\s!rm}
-
-\unexpanded\def\font_helpers_set_font_set_font_option_body#method#body#message%
- {\normalizebodyfontsize\normalizedsetfont{#body}% redundant for some calls
- \ifcsname\??fontbodyknown\normalizedsetfont\endcsname \else
- \font_helpers_define_unknown_font\normalizedsetfont
- \fi
- \ifcsname\??fontbodyknown\normalizedsetfont\endcsname
- \localbodyfontsize\normalizedsetfont
- \let\normalizedbodyfontsize\normalizedsetfont
- \else
- \showmessage\m!fonts4{#message}%
- %\font_helpers_set_font_set_font_option_body_fallbacks{#method}{#body}%
- \fi}
-
-% we need to check the fontclass
-
-\def\registerfontclass#class%
- {\letgvalue{\??fontclassyes#class}\v!yes} % global ?
-
-\def\setcurrentfontclass#class%
- {\ifcsname\??fontclassyes#class\endcsname
- \edef\fontclass{#class}%
- \orelse\ifcsname\??fontclassnop#class\endcsname
- % already tried
- \else % too messy: \ifcase\currentgrouplevel % (unpredictable)
- \trycurrentfontclass{#class}%
- \fi}
-
-\ifdefined\trycurrentfontclass \else
-
- \unexpanded\def\trycurrentfontclass#typeface%
- {\letvalueempty{\??fontclassnop#typeface}}
-
-\fi
-
-\let\defaultfontstyle \s!rm
-\let\defaultfontalternative\s!tf
-\let\defaultfontsize \empty
-\let\defaultfontface \!!zerocount
-
-%D So far for synchronisation. (We can inline the following macros.)
-
-\unexpanded\def\setcurrentfont#body#style#alternative#size% not used
- {\edef\fontbody {#body}%
- \edef\fontstyle {#style}%
- \edef\fontalternative{#alternative}%
- \edef\fontsize {#size}%
- \font_helpers_check_big_math_synchronization
- \font_helpers_synchronize_font}
-
-\unexpanded\def\setcurrentfontbody#body% % not used
- {\edef\fontbody{#body}%
- \font_helpers_synchronize_font}
-
-% For Taco: optional fall backs:
-
-\ifdefined\font_typescripts_inherit_check \else
- \let\font_typescripts_inherit_check\gobbleoneargument % implemented in type-ini
-\fi
-
-\unexpanded\def\font_helpers_set_current_font_style#style%
- {\edef\fontstyle{#style}%
- \font_typescripts_inherit_check\fontstyle
- \ifmmode\mr\fi % otherwise \rm not downward compatible ... not adapted yet
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_xsize_alternative#xsize#alternative%
- {\edef\fontface{#xsize}%
- \edef\fontalternative{#alternative}%
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_font_alternative#alternative%
- {\edef\fontalternative{#alternative}%
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_font_size#size%
- {\edef\fontsize{#size}%
- \font_helpers_check_big_math_synchronization % double? better in everymath?
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_font_style_alternative#style#alternative% \rmsl
- {\edef\fontstyle {#style}%
- \edef\fontalternative{#alternative}%
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_font_style_size#style#size% \rma
- {\edef\fontstyle{#style}%
- \edef\fontsize {#size}%
- \font_helpers_check_big_math_synchronization % double? better in everymath?
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_font_alternative_size#alternative#size% \sla
- {\edef\fontalternative{#alternative}%
- \edef\fontsize {#size}%
- \font_helpers_check_big_math_synchronization % double? better in everymath?
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_set_current_font_style_alternative_size#style#alternative#size% \rmsla
- {\edef\fontstyle {#style}%
- \edef\fontalternative{#alternative}%
- \edef\fontsize {#size}%
- \font_helpers_check_big_math_synchronization % double? better in everymath?
- \font_helpers_synchronize_font}
-
-\unexpanded\def\font_helpers_synchronize_font % we can have dups i.e. no need to let fontstrategy
- {\ifx\fontclass\empty
- \applyfontstrategies
- \else
- \applyfontclassstrategies
- \fi
- \setfalse\c_font_auto_size
- \ifskipfontcharacteristics
- \setfontcharacteristics
- \the\everyfontswitch
- \fi}
-
-%D This is the resolver for special cases (sizes) and in practice it is not called
-%D that often so further optimization makes no sense.
-
-\def\font_helpers_check_strategy_class_a % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\fontalternative-\fontsize-\fontface\endcsname
- \setfalse\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_class_b
- \fi}
-
-\def\font_helpers_check_strategy_class_b % --- --- --- def % pt tt bf
- {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\fontalternative-\defaultfontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_class_c
- \fi}
-
-\def\font_helpers_check_strategy_class_c % --- --- def --- % pt tt tf a
- {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\defaultfontalternative-\fontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_class_d
- \fi}
-
-\def\font_helpers_check_strategy_class_d % --- --- def def % pt tt tf
- {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_class_e
- \fi}
-
-\def\font_helpers_check_strategy_class_e % --- def def def % pt rm tf
- {\ifcsname\??fontinstanceready\fontclass-\fontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
- \setfalse\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_class_f
- \fi}
-
-\def\font_helpers_check_strategy_class_f % def def def def % rm tf
- {\ifcsname\??fontinstanceready\fontclass-\defaultfontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_a
- \fi}
-
-% no class
-
-\def\font_helpers_check_strategy_a % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\fontalternative-\fontsize-\fontface\endcsname
- \setfalse\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_b
- \fi}
-
-\def\font_helpers_check_strategy_b % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\fontalternative-\defaultfontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_c
- \fi}
-
-\def\font_helpers_check_strategy_c % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\defaultfontalternative-\fontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_d
- \fi}
-
-\def\font_helpers_check_strategy_d % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_e
- \fi}
-
-\def\font_helpers_check_strategy_e % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\fontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
- \setfalse\c_font_auto_size
- \lastnamedcs
- \else
- \expandafter\font_helpers_check_strategy_f
- \fi}
-
-\def\font_helpers_check_strategy_f % --- --- --- --- % pt tt bf a
- {\ifcsname\??fontinstanceready\defaultfontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
- \settrue\c_font_auto_size
- \lastnamedcs
- \fi}
-
-\let\applyfontstrategies \font_helpers_check_strategy_a
-\let\applyfontclassstrategies\font_helpers_check_strategy_class_a
-
-%D Let's synchronize:
-
-\newconditional\c_font_synchronize \settrue\c_font_synchronize
-
-\prependtoks
- \ifconditional\c_font_synchronize
- \font_helpers_synchronize_math
- \font_helpers_synchronize_font % problem: syncs last font
- \fi
-\to \everybodyfont
-
-%D Setting the normal sizes as well as the x and xx smaller sizes is accomplished by
-%D the next set of macros. When in math mode, the commands \type {\tx} and \type
-%D {\txx} are just a switch to the script and double script styles, but in text mode
-%D the values defined by the bodyfontenvironment are used. Here we also set \type
-%D {\currentxfontsize}.
-
-\def\font_helpers_set_current_font_xxx_alternative#alternative#xsize#scriptstyle%
- {\ifmmode
- #scriptstyle%
- \else
- \font_helpers_set_current_xsize_alternative{#xsize}{#alternative}%
- \fi}
-
-\def\font_helpers_reset_x_fontsize
- {\ifcase\currentxfontsize\else
- \currentxfontsize\zerocount
- % also \sx and \sxx ?
- \let\tx \normaltx
- \let\txx\normaltxx
- \fi}
-
-\let\font_helpers_check_nested_x_fontsize\relax
-
-\def\font_helpers_set_current_font_x_alternative#alternative%
- {\font_helpers_check_nested_x_fontsize
- \font_helpers_set_current_font_xxx_alternative{#alternative}{4}\scriptstyle
- \currentxfontsize\plusone
- \let\tx\txx}
-
-\def\font_helpers_set_current_font_xx_alternative#alternative%
- {\font_helpers_check_nested_x_fontsize
- \font_helpers_set_current_font_xxx_alternative{#alternative}{5}\scriptscriptstyle
- \currentxfontsize\plustwo
- \let\tx\empty
- \let\txx\empty}
-
-%D This alterative is not really needed, but for old time's sake we keep it there.
-%D We can speed it up when needed.
-
-\def\font_helpers_set_current_font_x_style_alternative #alternative{\csname#alternative\endcsname\tx}
-\def\font_helpers_set_current_font_xx_style_alternative#alternative{\csname#alternative\endcsname\txx}
-
-%D These macros also show us that when we call for \type {\tx}, this macro is
-%D redefined to be \type {\txx}. Therefore calls like:
-%D
-%D \startbuffer
-%D {small \tx is \tx beautiful}
-%D {small \tx is \txx beautiful}
-%D {small \txx is \tx beautiful}
-%D {small \txx is \txx beautiful}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D result in:
-%D
-%D \startlines
-%D \getbuffer
-%D \stoplines
-%D
-%D Setting the main size involves the style list and therefore takes a bit more
-%D time. Keep in mind that the fontsize is represented by a character or empty.
-
-\installcorenamespace{fontscalex}
-\installcorenamespace{fontscalexx}
-
-\newconditional\c_font_inherit_scale
-
-\def\font_scale_inherit#1%
- {\begingroup
- \scratchcounterone\fontid\font\relax
- \currentxfontsize\plusone
- \normalexpanded{\definedfont[\clf_specifiedfont\scratchcounterone\font_currentfontscale\relax]}%
- \scratchcountertwo\fontid\font\relax
- \currentxfontsize\plustwo
- \normalexpanded{\definedfont[\clf_specifiedfont\scratchcounterone\font_currentfontscale\relax]}%
- \scratchcounterthree\fontid\font\relax
- % parent -> x -> xx
- % parent -> xx
- \global\expandafter\chardef\csname\??fontscalex \number\scratchcounterone\endcsname\scratchcountertwo
- \global\expandafter\chardef\csname\??fontscalexx\number\scratchcounterone\endcsname\scratchcounterthree
- \global\expandafter\chardef\csname\??fontscalex \number\scratchcountertwo\endcsname\scratchcounterthree
- \global\expandafter\chardef\csname\??fontscalexx\number\scratchcountertwo\endcsname\scratchcounterthree
- \endgroup
- \setfontid\csname#1\number\fontid\font\endcsname}
-
-\def\font_scale_inherit_x
- {\ifcsname\??fontscalex\number\fontid\font\endcsname
- \setfontid\lastnamedcs
- \else
- \font_scale_inherit\??fontscalex
- \fi
- \ifskipfontcharacteristics
- \setfontcharacteristics
- \the\everyfontswitch
- \fi}
-
-\def\font_scale_inherit_xx
- {\ifcsname\??fontscalexx\number\fontid\font\endcsname
- \setfontid\lastnamedcs
- \else
- \font_scale_inherit\??fontscalexx
- \fi
- \ifskipfontcharacteristics
- \setfontcharacteristics
- \the\everyfontswitch
- \fi}
-
-\def\font_scale_defined_x
- {\let\fontface\!!plusfour
- \let\fontalternative\fontalternative
- \font_helpers_synchronize_font}
-
-\def\font_scale_defined_xx
- {\let\fontface\!!plusfive
- \let\fontalternative\fontalternative
- \font_helpers_synchronize_font}
-
-\unexpanded\def\tx
- {\currentxfontsize\plusone
- \ifmmode
- \scriptstyle
- \else\ifconditional\c_font_inherit_scale
- \font_scale_inherit_x
- \else
- \font_scale_defined_x
- \fi\fi
- \let\tx\txx}
-
-\unexpanded\def\txx
- {\currentxfontsize\plustwo
- \ifmmode
- \scriptscriptstyle
- \else\ifconditional\c_font_inherit_scale
- \font_scale_inherit_xx
- \else
- \font_scale_defined_xx
- \fi\fi
- \let\tx \empty
- \let\txx\empty}
-
-\unexpanded\def\sx
- {\currentxfontsize\plusone
- \ifmmode
- \scriptstyle
- \else
- \font_scale_inherit_x
- \fi
- \let\tx\txx
- \let\sx\sxx}
-
-\unexpanded\def\sxx
- {\currentxfontsize\plustwo
- \ifmmode
- \scriptscriptstyle
- \else
- \font_scale_inherit_xx
- \fi
- \let\tx \empty
- \let\txx\empty
- \let\sx \empty
- \let\sxx\empty}
-
-\unexpanded\def\useinheritxsizes{\settrue \c_font_inherit_scale} % not yet public, playground for WS and me
-\unexpanded\def\usedefinedxsizes{\setfalse\c_font_inherit_scale} % not yet public, playground for WS and me
-
-\let\normaltx \tx
-\let\normaltxx\txx
-
-\let\normalsx \sx
-\let\normalsxx\sxx
-
-%D When asking for a complete font switch, for instance from 10 to 12~points, the
-%D next macro does the job. First we normalize the size, next we define the current
-%D range of text, script and scriptscript sizes, then we set the text fonts and the
-%D math families and finally we activate the default typeface and also set the font
-%D specific parameters assigned to \type {\everybodyfont}.
-
-\def\textface {\currentbodyfontdimension\s!text }
-\def\scriptface {\currentbodyfontdimension\s!script }
-\def\scriptscriptface{\currentbodyfontdimension\s!scriptscript}
-\def\xtextface {\currentbodyfontdimension\s!x }
-\def\xxtextface {\currentbodyfontdimension\s!xx }
-
-\installcorenamespace{fontbodyfaces}
-
-\unexpanded\def\font_basics_complete_switch#size%
- {\bodyfontsize#size\relax
- \normalizebodyfontsize\normalizedbodyfontsize\bodyfontsize
- \expandafter\let\expandafter\font_basics_set_faces\csname\??fontbodyfaces\fontbody\endcsname
- \ifx\font_basics_set_faces\relax
- \font_basics_set_faces_preset
- \fi
- \font_basics_set_faces}
-
-\def\font_basics_set_faces_preset
- {\edef\font_basics_set_faces{% 0.2 sec on 10K \tfa
- \noexpand\edef\noexpand\textface {\currentbodyfontdimension\s!text }%
- \noexpand\edef\noexpand\scriptface {\currentbodyfontdimension\s!script }%
- \noexpand\edef\noexpand\scriptscriptface{\currentbodyfontdimension\s!scriptscript}%
- \noexpand\edef\noexpand\xtextface {\currentbodyfontdimension\s!x }%
- \noexpand\edef\noexpand\xxtextface {\currentbodyfontdimension\s!xx }%
- }%
- \expandafter\glet\csname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces}
-
-\def\currentbodyfontdimension#parameter% there can be factors here
- {\the\dimexpr
- \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname
- \lastnamedcs
- \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname
- \lastnamedcs
- \dimexpr\normalizedbodyfontsize\relax
- \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname
- \lastnamedcs
- \else
- \csname\??fontenvironments\s!default#parameter\endcsname
- \dimexpr\normalizedbodyfontsize\relax
- \fi
- \relax}
-
-%D \macros
-%D {setupbodyfont,switchtobodyfont}
-%D
-%D The next two macros are user ones. With \type {\setupbodyfont} one can set the
-%D document bodyfont size, font family, style and/or options defined in files, for
-%D example:
-%D
-%D \starttyping
-%D \setupbodyfont[modern,12pt,roman]
-%D \stoptyping
-%D
-%D This command affects the document as a whole: text, headers and footers. The
-%D second macro however affects only the text:
-%D
-%D \starttyping
-%D \switchtobodyfont[10pt]
-%D \stoptyping
-%D
-%D So we've got:
-%D
-%D \showsetup{setupbodyfont}
-%D \showsetup{switchtobodyfont}
-%D
-%D Both macros look alike. The second one also has to take all kind of keywords into
-%D account.
-
-\ifx\saveinterlinespace \undefined \let\saveinterlinespace \relax \fi
-\ifx\restoreinterlinespace\undefined \let\restoreinterlinespace\relax \fi
-
-% \newtoks \everysetupbodyfont
-% \newtoks \everyswitchtobodyfont
-
-\unexpanded\def\setupbodyfont
- {\doifelsenextoptionalcs\font_basics_setupbodyfont_yes\font_basics_setupbodyfont_nop}
-
-\def\font_basics_setupbodyfont_nop
- {\restoreglobalbodyfont
- \saveinterlinespace}
-
-\def\font_basics_setupbodyfont_yes[#specification]%
- {\doifsomething{#specification}
- {\font_helpers_set_font\plusone{#specification}%
- \globalbodyfontsize\localbodyfontsize
- \normalizebodyfontsize\normalizedglobalbodyfontsize\globalbodyfontsize
- \let\globalfontstyle\fontstyle
- \ifproductionrun
- \the\everybodyfont
- \the\everyglobalbodyfont
- \saveinterlinespace
- \fi
- \the\everysetupbodyfont}}
-
-\unexpanded\def\font_basics_switchtobodyfont#specification%
- {\edef\m_font_step{\font_bodyfontvariable{#specification}}%
- \ifx\m_font_step\empty
- \font_helpers_set_font\zerocount{#specification}%
- \else
- \font_helpers_switch_bodyfont_step % so we have a fast [small] switch
- \fi
- \the\everybodyfont
- \the\everyswitchtobodyfont}
-
-\unexpanded\def\switchtobodyfont[#specification]% could become an ifx
- {\doifsomething{#specification}{\font_basics_switchtobodyfont{#specification}}}
-
-\unexpanded\def\usebodyfontparameter#1%
- {\edef\m_font_bodyfont_asked{#1\c!bodyfont}%
- \ifx\m_font_bodyfont_asked\empty\else
- \font_basics_switchtobodyfont\m_font_bodyfont_asked
- \fi}
-
-\def\font_helpers_switch_bodyfont_step
- {\font_basics_switch_points\m_font_step
- \font_basics_switch_style \fontstyle}
-
-%D The following alternative is meant for math||to||text switching and will be
-%D optimized.
-
-\unexpanded\def\fastswitchtobodyfont#name%
- {\ifcsname\??fontenvironments\normalizedbodyfontsize#name\endcsname
- %\edef\futurebodyfontsize{\csname\??fontenvironments\normalizedbodyfontsize#name\endcsname}%
- \edef\futurebodyfontsize{\lastnamedcs}%
- \ifcsname\??fontbodyknown\futurebodyfontsize\endcsname
- \font_basics_complete_switch\futurebodyfontsize
- \localbodyfontsize\futurebodyfontsize\relax
- \fi
- \fi
- \csname\??fontstyle\fontstyle\endcsname
- \the\everybodyfont}
-
-%D \starttyping
-%D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$
-%D \stoptyping
-
-%D \macros
-%D {usebodyfont}
-%D
-%D This looks nicer then a switch in the preamble
-%D
-%D \starttyping
-%D \usebodyfont[pagella,10pt]
-%D \usebodyfont[termes,10pt]
-%D \usebodyfont[dejavu,10pt]
-%D
-%D \setupbodyfont[dejavu]
-%D
-%D \starttext
-%D test
-%D \stoptext
-%D \stoptyping
-
-\unexpanded\def\usebodyfont[#1]%
- {\ifx\fontclass\empty
- \setupbodyfont[#1]%
- \else
- \switchtobodyfont[#1]%
- \fullrestoreglobalbodyfont
- \fi}
-
-\unexpanded\def\showbodyfontstate
- {\dontleavehmode
- \start
- \infofont
- [fontclass: \fontclass,\space
- fontbody: \fontbody ,\space
- fontface: \fontface ,\space
- fontsize: \fontsize ]%
- \stop}
-
-%D Handy for manuals:
-
-%D The \type {\tochar} commmand takes a specification:
-%D
-%D \starttabulate[|l|l|l|]
-%D \NC e \NC entity \NC e:eacute \NC \NR
-%D \NC x \NC hexadecimal unicode \NC x:013D \NC \NR
-%D \NC d \NC decimal unicode \NC d:123 \NC \NR
-%D \NC s \NC hexadecimal index (slot) \NC s:210D \NC \NR
-%D \NC i \NC decimal index \NC i:456 \NC \NR
-%D \NC n \NC name \NC n:eight \NC \NR
-%D \NC c \NC name \NC c:x \NC \NR
-%D \NC u \NC unicode descriptions \NC u:dog \NC \NR
-%D \NC a \NC all (also descriptions) \NC a:rewind \NC \NR
-%D \stoptabulate
-%D
-%D This is an expandable command!
-
-\unexpanded\def\fontchar #character{\clf_fontchar{#character}}
-\unexpanded\def\fontcharbyindex #index{\clf_fontcharbyindex#index\relax}
- \def\tochar #specifications{\clf_tochar{#specifications}} % expanded (also used in edef)
-
-%D The next auxilliary macro is an alternative to \type {\fontname}.
-
-\def\purefontname#font{\clf_purefontname{\fontname#font}}
-
-%D \macros
-%D {switchstyleonly}
-%D
-%D For switching a style but keeping the alternative, there
-%D is:
-%D
-%D \starttyping
-%D {\bf text \switchstyleonly\ss text}
-%D {\bf text \switchstyleonly[ss]text}
-%D {\sl text \switchstyleonly[sansserif]text}
-%D \stoptyping
-
-\unexpanded\def\switchstyleonly
- {\doifelsenextoptionalcs\font_basics_switch_style_only_opt\font_basics_switch_style_only_arg}
-
-\def\font_basics_switch_style_only_arg#name% stupid version
- {\font_helpers_set_current_font_style{\csname\??fontshortstyle\checkedstrippedcsname#name\endcsname}%
- \the\everybodyfont} % needed ?
-
-\def\font_basics_switch_style_only_opt[#name]% todo : check
- {\font_helpers_set_current_font_style{\csname\??fontshortstyle#name\endcsname}%
- \the\everybodyfont} % needed ?
-
-%D \macros
-%D {definebodyfontswitch}
-%D
-%D \PLAIN\ \TEX\ defines some macro's like \type {\tenpoint} to switch to a specific
-%D bodyfontsize. Just for the sake of compatibility we can define them like:
-%D
-%D \starttyping
-%D \definebodyfontswitch [twelvepoint] [12pt]
-%D \stoptyping
-%D
-%D We don't support language specific synonyms here.
-
-\unexpanded\def\definebodyfontswitch
- {\dodoubleargument\font_basics_define_bodyfont_switch}
-
-\def\font_basics_define_bodyfont_switch[#command][#specification]% no longer a commalist (not useful)
- {\setvalue{#command}{\switchtobodyfont[#specification]}}%
-
-%D \macros
-%D {setsmallbodyfont,setmainbodyfont,setbigbodyfont}
-%D
-%D When we're typesetting at for instance 10pt, we can call for the \type {small} as
-%D well as the \type {big} alternative, related to this main size, using \type
-%D {\switchtobodyfont[small]}. The three alternatives can be activated by the next
-%D three system calls and are defined by the bodyfontenvironment.
-
-\newmacro\m_font_step
-
-\def\font_helpers_set_bodyfont_step#step%
- {\edef\m_font_step{\font_bodyfontvariable{#step}}% not always \cs
- \font_basics_switch_points\m_font_step
- \font_basics_switch_style \fontstyle}
-
-\unexpanded\def\setsmallbodyfont{\font_helpers_set_bodyfont_step\v!small\the\everybodyfont}
-\unexpanded\def\setbigbodyfont {\font_helpers_set_bodyfont_step\v!big \the\everybodyfont}
-
-\unexpanded\def\setmainbodyfont
- {\font_basics_switch_points\normalizedbodyfontsize
- \font_basics_switch_style\fontstyle
- \the\everybodyfont
- \the\everyglobalbodyfont
- \saveinterlinespace}
-
-%D \macros
-%D {restoreglobalbodyfont}
-%D
-%D Users can set whatever font available while typesetting text. Pagenumbers,
-%D footers, headers etc. however must be typeset in the main bodyfont and style of
-%D the document. Returning to the global state can be done with the next macro:
-%D
-%D This macro has to be called when entering the pagebody handling routine as well
-%D as the footnote insert routine. Users can access this feature |<|for instance
-%D when one wants to typeset tables and alike in the main bodyfont and style while
-%D the running text is temporary set to a smaller one|>| by saying \type
-%D {\switchtobodyfont [global]}.
-
-\let\globalfontstyle\s!rm
-
-\unexpanded\def\fullrestoreglobalbodyfont
- {\let\fontsize\defaultfontsize
- \let\fontbody\defaultfontbody
- \let\fontface\defaultfontface
- \currentxfontsize\zerocount
- \let\fontclass\globalfontclass
- \font_basics_switch_points\normalizedglobalbodyfontsize
- \font_basics_switch_style\globalfontstyle
- \redoconvertfont % just in case a pagebreak occurs
- \tf
- \the\everybodyfont
- \the\everyglobalbodyfont
- \saveinterlinespace}
-
-\unexpanded\def\partialrestoreglobalbodyfont
- {\let\fontsize\defaultfontsize
- \let\fontbody\defaultfontbody
- \let\fontface\defaultfontface
- \currentxfontsize\zerocount
- \redoconvertfont
- \tf
- \the\everybodyfont % indeed needed
- \the\everyglobalbodyfont % indeed needed
- \saveinterlinespace}
-
-\unexpanded\def\restoreglobalbodyfont % ook style etc
- {\ifx\fontclass\globalfontclass
- \ifx\fontstyle\globalfontstyle
- \ifx\normalizedbodyfontsize\normalizedglobalbodyfontsize
- \partialrestoreglobalbodyfont
- \else
- \fullrestoreglobalbodyfont
- \fi
- \else
- \fullrestoreglobalbodyfont
- \fi
- \else
- \fullrestoreglobalbodyfont
- \fi}
-
-% in case of troubles: \let\restorebodyfont\fullrestoreglobalbodyfont
-
-%D Here are some fast variants that can be used in cases where no font system is
-%D needed and where fonts are frozen:
-%D
-%D \starttyping
-%D \definefont [TestA][Serif at 10pt]
-%D \predefinefont[TestB][Serif at 20pt]
-%D
-%D \testfeatureonce{1000}{{\TestA}} % .312
-%D \testfeatureonce{1000}{{\TestB}} % < .016
-%D \testfeatureonce{1000}{{\definedfont[Serif at 30pt]}} % .312
-%D \testfeatureonce{1000}{{\predefinedfont[Serif at 40pt]}} % < .016
-%D \stoptyping
-
-\installcorenamespace{predefinedfont}
-
-\unexpanded\def\predefinefont[#1]#2[#3]% global !
- {\setugvalue{#1}{\font_basics_predefine{#1}{#3}}}
-
-\unexpanded\def\predefinedfont[#1]% global !
- {\ifcsname\??predefinedfont#1\endcsname
- \lastnamedcs
- \else
- \font_basics_predefined{#1}%
- \fi}
-
-\unexpanded\def\font_basics_predefine#1#2%
- {\font_basics_defined_font_yes[#2]%
- \expandafter\glet\csname#1\expandafter\endcsname\csname\v_font_identifier_basic\endcsname}
-
-\unexpanded\def\font_basics_predefined#1%
- {\font_basics_predefine{\??predefinedfont#1}{#1}}
-
-%D Handy helper:
-
-\unexpanded\def\savedefinedfont[#1]%
- {\bgroup
- \definedfont[#1]%
- \xdef\saveddefinedfontid {\number\fontid\font}%
- \xdef\saveddefinedfontname{\fontname\font}%
- \egroup}
-
-\def\saveddefinedfontid {\number\fontid\font}
-\def\saveddefinedfontname{\fontname\font}
-
-%D Ugly helper:
-
-\unexpanded\def\saverunningstyleandcolor
- {\unexpanded\edef\restorerunningstyleandcolor
- {\setfontid \number\fontid\font
- \attribute\colormodelattribute \the\attribute\colormodelattribute
- \attribute\colorattribute \the\attribute\colorattribute
- \attribute\transparencyattribute\the\attribute\transparencyattribute
- \relax}}
-
-\let\restorerunningstyleandcolor\relax
-
-%D Handy for defining additional glyphs:
-
-\let\getprivateglyphslot\clf_getprivateglyphslot % kind of private macro
-
-\let\getprivatechar \clf_getprivatechar % gives back a utf !
-\let\getprivatemathchar \clf_getprivatemathchar % gives back a utf !
-\let\getprivateslot \clf_getprivateslot % companion to fonts.helpers.addprivate
-
-% \unexpanded\def\getprivatemathchar#1%
-% {\begingroup\the\textfont\zerocount\getprivatechar{#1}\endgroup}
-
-\def\privatechar % the text variant gets expanded to utf
- {\ifmmode
- \expandafter\getprivatemathchar
- \else
- \expandafter\getprivatechar
- \fi}
-
-%D Some fonts can have color specifiers:
-%D
-%D \starttyping
-%D \definefontfeature[seguiemj-cl][default][colr=yes,ccmp=yes,dist=yes]
-%D \definefontsynonym[emoji][seguiemj*seguiemj-cl]
-%D
-%D \definecolor[emoji-red] [r=.4]
-%D \definecolor[emoji-gray][s=1,t=.5,a=1]
-%D
-%D %definefontcolorpalette [emoji-r] [emoji-red,emoji-gray,textcolor] % bad
-%D \definefontcolorpalette [emoji-r] [emoji-red,emoji-gray] % okay
-%D
-%D \definefontfeature[seguiemj-r][ccmp=yes,dist=yes,colr=emoji-r]
-%D
-%D \definefont[MyEmojiR][seguiemj*seguiemj-r @ 100pt]
-%D
-%D \startTEXpage[offset=10pt]
-%D \MyEmojiR\resolvedemoji{triangular ruler}
-%D \stopTEXpage
-%D \stoptyping
-
-\unexpanded\def\definefontcolorpalette
- {\dodoubleargument\font_define_color_palette}
-
-\def\font_define_color_palette[#1][#2]%
- {\clf_definefontcolorpalette{#1}{#2}}
-
-%D \macros
-%D {addfontpath}
-%D
-%D A way to add a path at runtime (no need to generate database):
-
-\unexpanded\def\usefontpath[#1]%
- {\clf_addfontpath{#1}}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ini.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-ini.mkvi
index 99e7117a38e..271a81c2aa4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ini.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ini.mkvi
@@ -2712,10 +2712,10 @@
\unexpanded\def\saverunningstyleandcolor
{\unexpanded\edef\restorerunningstyleandcolor
- {\setfontid \number\fontid\font
- \attribute\colormodelattribute \the\attribute\colormodelattribute
- \attribute\colorattribute \the\attribute\colorattribute
- \attribute\transparencyattribute\the\attribute\transparencyattribute
+ {\setfontid \number\fontid\font
+ \c_attr_colormodel \the\c_attr_colormodel
+ \c_attr_color \the\c_attr_color
+ \c_attr_transparency\the\c_attr_transparency
\relax}}
\let\restorerunningstyleandcolor\relax
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-lib.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-lib.mkvi
index b3cade5ff07..db9df49cd6f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-lib.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-lib.mkvi
@@ -49,17 +49,13 @@
\registerctxluafile{font-osd}{}
%registerctxluafile{font-osm}{}
-\ifcase\contextlmtxmode
- \ifnum\luatexversion>111
- \doifelsefileexists{font-ocm.lua}
- {\registerctxluafile{font-ocm}{}} % mkiv new
- {\registerctxluafile{font-ocl}{}}
- \else
- \registerctxluafile{font-ocl}{} % generic (will become luatex-fonts-ocl)
- \fi
-\else
- \registerctxluafile{font-ogr}{} % lmtx
-\fi
+% \ifcase\directlua{tex.print(callback.list()["provide_charproc_data"] == false and 1 or 0)}\relax
+% % this is the generic variant that will become luatex-fonts-ocl once we have
+% % more recent versions of luatex 1.13/1.14 on the garden
+ \registerctxluafile{font-ocl}{}
+% \else
+% \registerctxluafile{font-ocm}{}
+% \fi
% we use otf code for type one
@@ -117,6 +113,7 @@
\registerctxluafile{font-imp-dimensions}{}
\registerctxluafile{font-imp-spacekerns}{}
\registerctxluafile{font-imp-tweaks}{}
+\registerctxluafile{font-imp-combining}{}
\doifelsefileexists{font-imp-scripts.lua} {
\registerctxluafile{font-imp-scripts}{}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-map.lua b/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
index 84a28a8b7ed..c983ea96343 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-map.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-map'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -103,6 +104,7 @@ local hash = { }
local conc = { }
table.setmetatableindex(hash,function(t,k)
+ local v
if k < 0xD7FF or (k > 0xDFFF and k <= 0xFFFF) then
v = f_single(k)
else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-mat.mklx b/Master/texmf-dist/tex/context/base/mkiv/font-mat.mklx
deleted file mode 100644
index d08a2ce879f..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-mat.mklx
+++ /dev/null
@@ -1,500 +0,0 @@
-%D \module
-%D [ file=font-mat,
-%D version=2011.01.13, % (copied fron font-ini)
-%D title=\CONTEXT\ Font Macros,
-%D subtitle=Math,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Font Macros / Math}
-
-\unprotect
-
-%D Be nice:
-
-\ifdefined\??fontinstanceready \else \installcorenamespace{fontinstanceready} \fi
-\ifdefined\??fontinstancebasic \else \installcorenamespace{fontinstancebasic} \fi
-\ifdefined\??fontinstanceclass \else \installcorenamespace{fontinstanceclass} \fi
-
-%D The order 3 2 1 of siuze matters: needed for math-fbk relative size storage!
-
-%D \macros
-%D {textonly}
-%D
-%D Traditionally math has a big impact on font definitions, mainly because we need
-%D to define alphabet variants using families and fonts. This means that one can
-%D easily get 10 fonts loaded per math size. In \MKIV\ we use a different approach:
-%D one family which has either a virtual font made of traditional fonts, or an
-%D \OPENTYPE\ font that has it all.
-%D
-%D We currently use only one math family but in the future we might consider using a
-%D second one for bold math. For the moment we keep the \MKII\ method of using a
-%D token register for definitions but we already dropped the text and symbols ones
-%D since they now live in the same family.
-
-\newtoks \t_font_math_strategies
-\newconditional\c_font_synchronize_math_fonts \settrue\c_font_synchronize_math_fonts
-
-\unexpanded\def\font_helpers_synchronize_math % math stuff in mmode
- {\ifconditional\c_font_synchronize_math_fonts\the\t_font_math_strategies\fi}
-
-\unexpanded\def\textonly{\setfalse\c_font_synchronize_math_fonts} % document this
-
-%D The main math font definer. We have removed some optimized code simply because we
-%D now always have a fontclass. We could check for fontclass being default or empty
-%D and save a few tests but it does not help us when no math is defined.
-%D
-%D Because we want to keep mr=.. and mb=... settings (read: not break downward
-%D compatibility by enforcing mrlr etc) we need a bit more code that optimal.
-
-% todo: \c_font_fam_mr
-
-\let\c_font_fam_mr \zerocount % math regular
-\let\c_font_fam_mr_lr\plusone % math regular l2r
-\let\c_font_fam_mr_rl\plustwo % math regular r2l
-
-\let\c_font_fam_mb \plusthree % math bold
-\let\c_font_fam_mb_lr\plusfour % math bold l2r
-\let\c_font_fam_mb_rl\plusfive % math bold r2l
-
-\definesystemattribute[mathfamily][public]
-
-\newconditional\c_font_bidirectional_mathstrategy % can be default, not that much overhead: \settrue\c_font_bidirectional_mathstrategy
-\newconditional\c_font_complete_bold_mathstrategy \settrue\c_font_complete_bold_mathstrategy
-
-\def\mathtextsuffix {-text}
-\def\mathscriptsuffix {-script}
-\def\mathscriptscriptsuffix{-scriptscript}
-
-\def\mathsizesuffix{\ifcase\fontface\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi}
-
-%D Beware: truefontname also does a fallback on defaultfontclass so there
-%D can be some interference here, which is why we use a different method
-%D for bold.
-
-\def\font_helpers_set_math_family_a
- {\ifcsname\??fontinstanceready\fontclass -\fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
- \lastnamedcs \orelse
- \ifcsname\??fontinstanceready\fontclass -\fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
- \lastnamedcs \else
- \font_helpers_set_math_family_b
- \fi}
-
-\def\font_helpers_set_math_family_b
- {\ifcsname\??fontinstanceready\defaultfontclass-\fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
- \lastnamedcs \orelse
- \ifcsname\??fontinstanceready\defaultfontclass-\fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
- \lastnamedcs \else
- \font_helpers_set_math_family_c
- \fi}
-
-\def\font_helpers_set_math_family_c
- {\ifcsname\??fontinstanceready \fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
- \lastnamedcs \orelse
- \ifcsname\??fontinstanceready \fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
- \lastnamedcs \else
- \settrue \c_font_auto_size
- \fi}
-
-\let\mathsizesuffix\empty
-
-\def\font_helpers_set_math_family_indeed#mrtag#family% \fontface etc are also used later on
- {\let\savedfontbody\fontbody
- \let\fontfamily#family%
- % the order is important as we depend on known id's when completing fonts
- % enabling is needed when we have fallbacks which spoils the families
- \let\mathsizesuffix\mathscriptscriptsuffix\let\fontface\!!plusthree
- \font_helpers_set_math_family_a\scriptscriptfont#mrtag\font % defines
- \font_helpers_set_math_family_a\scriptscriptfont#mrtag\font % enables
- \let\mathsizesuffix\mathscriptsuffix \let\fontface\!!plustwo
- \font_helpers_set_math_family_a\scriptfont #mrtag\font % defines
- \font_helpers_set_math_family_a\scriptfont #mrtag\font % enables
- \let\mathsizesuffix\mathtextsuffix \let\fontface\!!plusone
- \font_helpers_set_math_family_a\textfont #mrtag\font % defines
- \font_helpers_set_math_family_a\textfont #mrtag\font % enables
- \let\mathsizesuffix\empty \let\fontface\!!zerocount
- \let\fontbody\savedfontbody
- \setfalse\c_font_auto_size}
-
-\def\font_helpers_set_math_family_bold_a#font#mbfam#mrfam%
- {\ifcsname\??fontinstanceready\fontclass-\fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
- \lastnamedcs #font#mbfam\font \orelse
- \ifcsname\??fontinstanceready\fontclass-\fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
- \lastnamedcs #font#mbfam\font \else
- #font#mbfam#font#mrfam%
- \fi}
-
-\def\font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% \c_font_fam_mb \s!mb \c_font_fam_mr
- {\let\savedfontclass\defaultfontclass
- \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one
- \let\savedfontbody\fontbody
- \let\fontfamily#familytag%
- \let\mathsizesuffix\mathscriptscriptsuffix\let\fontface\!!plusthree
- \font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam% defines
- \font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam% enables
- \let\mathsizesuffix\mathscriptsuffix \let\fontface\!!plustwo
- \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam% defines
- \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam% enables
- \let\mathsizesuffix\mathtextsuffix \let\fontface\!!plusone
- \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% defines
- \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% enables
- \let\mathsizesuffix\empty \let\fontface\!!zerocount
- \let\fontbody\savedfontbody
- \let\defaultfontclass\savedfontclass
- \setfalse\c_font_auto_size}
-
-% optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0))
-%
-% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know
-% all sizes so we postpone the optimization to the first starttext
-%
-% pitfall: we should reset 'm when a fontclass name is reused
-
-\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions
-
-\def\font_helpers_set_math_family#mrfam#familytag%
- {\ifconditional\optimizemathfontdefinitions
- \ifcsname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
- % \writestatus{fonts}{math: reusing \fontclass\fontbody\s!mm#familytag\fontsize1}%
- \font_helpers_preset_math_family_indeed#mrfam#familytag%
- \else
- % \writestatus{fonts}{math: defining \fontclass\fontbody\s!mm#familytag\fontsize1}%
- \font_helpers_set_math_family_indeed#mrfam#familytag%
- \fi
- \else
- \font_helpers_set_math_family_indeed#mrfam#familytag%
- \fi}
-
-\def\font_helpers_set_math_family_bold#mbfam#familytag#mrfam%
- {\ifconditional\optimizemathfontdefinitions
- %\ifcsname\??fontinstanceclass\fontclass-\textface-\s!mm-#familytag-\fontsize-1\endcsname
- \ifcsname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
- \font_helpers_preset_math_family_indeed#mbfam#familytag%
- \else
- \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
- \fi
- \else
- \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
- \fi}
-
-%D It can happen that we use a bodyfont with no math in which case we have a problem
-%D with setting the global bodyfont size in the page builder. For instance in:
-%D
-%D \starttext
-%D \definetypeface[test][rm][serif][pagella][default]
-%D \setupbodyfont[test]
-%D test
-%D \stoptext
-%D
-%D This is why we need the check. At the cost of some extra checking we gain a
-%D little in restoring global states and, what's more important, we get rid of large
-%D math parameter push/pop in tracingall when not needed.
-
-\def\font_helpers_preset_math_family_indeed#fam#familytag%
- {\expandafter\let\expandafter\v_font_math_one\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
- \ifx\v_font_math_one\relax
- \font_helpers_preset_math_family_warning
- \orelse\ifnum\fontid\textfont#fam=\fontid\v_font_math_one\else
- \font_helpers_preset_math_family_indeed_changed#fam#familytag%
- \fi}
-
-\def\font_helpers_preset_math_family_warning
- {\writestatus{fonts}{math: unset for global bodyfont \fontclass\space at \fontbody}}
-
-\def\font_helpers_preset_math_family_indeed_changed#fam#familytag%
- {\scriptscriptfont#fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-3\endcsname
- \scriptfont #fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-2\endcsname
- \textfont #fam\v_font_math_one}
-
-\let\font_helpers_reset_fontclass_math_families\gobbleoneargument
-
-%D It would be nice if characters could be defined in a neutral way (say fam 255)
-%D and be mapped to a real family during noad list construction. However, this
-%D changes tex in critical places so for the moment we simulate this using
-%D manipulation.
-%D
-%D For tracing purposes we use three families but in l2r mode 1 and 2 are copies of
-%D 0 while in rl mode 0 is a copy of 1. There is no real overhead involved in this.
-%D This also permits different font definitions for normal and mixed.
-
-\let\m_font_class_direction\empty
-\let\m_font_class_features \empty
-\let\m_font_class_fallbacks\empty
-\let\m_font_class_goodies \empty
-
-\let\m_font_direction\empty
-\let\m_font_features \empty
-\let\m_font_fallbacks\empty
-\let\m_font_goodies \empty
-
-\appendtoks % can be analyzed once
- % why here ..
- %\edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\s!mm\s!direction\endcsname\csname\??fontclass\fontclass\s!mm\s!direction\endcsname\fi}%
- \edef\m_font_class_direction{\begincsname\??fontclass\fontclass\s!mm\s!direction\endcsname}%
- % ...
- \ifx\m_font_class_direction\v!both
- \settrue\c_font_bidirectional_mathstrategy
- \else
- \setfalse\c_font_bidirectional_mathstrategy
- \fi
-\to \t_font_math_strategies
-
-\def\font_helpers_bidirectional_mathstrategy_yes
- {\font_helpers_set_math_family\c_font_fam_mr_lr\s!mrlr
- \font_helpers_set_math_family\c_font_fam_mr_rl\s!mrrl
- \ifnum\fontid\textfont\c_font_fam_mr=\fontid\textfont\c_font_fam_mr_lr\else
- \font_helpers_bidirectional_mathstrategy_yes_changed
- \fi}
-
-\def\font_helpers_bidirectional_mathstrategy_yes_changed
- {\textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr
- \scriptfont \c_font_fam_mr\scriptfont \c_font_fam_mr_lr
- \scriptscriptfont\c_font_fam_mr\scriptscriptfont\c_font_fam_mr_lr}
-
-\def\font_helpers_bidirectional_mathstrategy_nop
- {\font_helpers_set_math_family\c_font_fam_mr\s!mr
- \ifnum\fontid\textfont\c_font_fam_mr_rl=\fontid\textfont\c_font_fam_mr\else
- \font_helpers_bidirectional_mathstrategy_nop_changed
- \fi}
-
-\def\font_helpers_bidirectional_mathstrategy_nop_changed
- {\textfont \c_font_fam_mr_lr\textfont \c_font_fam_mr
- \scriptfont \c_font_fam_mr_lr\scriptfont \c_font_fam_mr
- \scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr
- \textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr
- \scriptfont \c_font_fam_mr_rl\scriptfont \c_font_fam_mr
- \scriptscriptfont\c_font_fam_mr_rl\scriptscriptfont\c_font_fam_mr}
-
-\appendtoks
- \ifconditional\c_font_bidirectional_mathstrategy
- \font_helpers_bidirectional_mathstrategy_yes
- \else
- \font_helpers_bidirectional_mathstrategy_nop
- \fi
-\to \t_font_math_strategies
-
-\def\font_helpers_complete_bold_mathstrategy_yes_bidi
- {\font_helpers_set_math_family_bold\c_font_fam_mb_lr\s!mblr\c_font_fam_mr_lr
- \font_helpers_set_math_family_bold\c_font_fam_mb_rl\s!mbrl\c_font_fam_mr_rl
- \ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mb_lr\else
- \font_helpers_complete_bold_mathstrategy_yes_bidi_changed
- \fi}
-
-\def\font_helpers_complete_bold_mathstrategy_yes_bidi_changed
- {\textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr
- \scriptfont \c_font_fam_mb\scriptfont \c_font_fam_mb_lr
- \scriptscriptfont\c_font_fam_mb\scriptscriptfont\c_font_fam_mb_lr}
-
-\def\font_helpers_complete_bold_mathstrategy_yes
- {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr\relax
- \ifnum\fontid\textfont\c_font_fam_mb_rl=\fontid\textfont\c_font_fam_mb\else
- \font_helpers_complete_bold_mathstrategy_yes_changed
- \fi}
-
-\def\font_helpers_complete_bold_mathstrategy_yes_changed
- {\textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb
- \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mb
- \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mb
- \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mb
- \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mb
- \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mb}
-
-\def\font_helpers_complete_bold_mathstrategy_nop
- {\ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mr\else
- \font_helpers_complete_bold_mathstrategy_nop_changed
- \fi}
-
-\def\font_helpers_complete_bold_mathstrategy_nop_changed
- {\textfont \c_font_fam_mb \textfont \c_font_fam_mr
- \scriptfont \c_font_fam_mb \scriptfont \c_font_fam_mr
- \scriptscriptfont\c_font_fam_mb \scriptscriptfont\c_font_fam_mr
- \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mr_lr
- \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mr_lr
- \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mr_lr
- \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mr_rl
- \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mr_rl
- \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mr_rl}
-
-\def\font_helpers_apply_complete_bold_mathstrategy
- {\ifconditional\c_font_complete_bold_mathstrategy
- \ifconditional\c_font_bidirectional_mathstrategy
- \font_helpers_complete_bold_mathstrategy_yes_bidi
- \else
- \font_helpers_complete_bold_mathstrategy_yes
- \fi
- \else
- \font_helpers_complete_bold_mathstrategy_nop
- \fi}
-
-\appendtoks
- \font_helpers_apply_complete_bold_mathstrategy
-\to \t_font_math_strategies
-
-\ifdefined\defaultmathfamily \else
- \setnewconstant\defaultmathfamily\zerocount
-\fi
-
-\appendtoks
- \fam\defaultmathfamily % all characters and symbols are in this family
-\to \everymathematics
-
-\unexpanded\def\font_helpers_synchronize_math_family_mr
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy
- \ifconditional\c_math_right_to_left
- \plustwo
- \else
- \plusone
- \fi
- \else
- \zerocount
- \fi}
-
-\unexpanded\def\font_helpers_synchronize_math_family_mb
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy
- \ifconditional\c_math_right_to_left
- \ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi
- \else
- \ifconditional\c_font_pseudo_bold_math_state\plusseven\else\plusfour\fi
- \fi
- \else
- \ifconditional\c_font_pseudo_bold_math_state\plussix\else\plusthree\fi
- \fi}
-
-\installcorenamespace{fontmathsynchronizer}
-\installcorenamespace{fontmathstoredstrategy}
-
-\letvalue{\??fontmathsynchronizer\s!tf }\font_helpers_synchronize_math_family_mr
-\letvalue{\??fontmathsynchronizer\s!sl }\font_helpers_synchronize_math_family_mr
-\letvalue{\??fontmathsynchronizer\s!it }\font_helpers_synchronize_math_family_mr
-\letvalue{\??fontmathsynchronizer\s!bf }\font_helpers_synchronize_math_family_mb
-\letvalue{\??fontmathsynchronizer\s!bs }\font_helpers_synchronize_math_family_mb
-\letvalue{\??fontmathsynchronizer\s!bi }\font_helpers_synchronize_math_family_mb
-\letvalue{\??fontmathsynchronizer\empty}\font_helpers_synchronize_math_family_mr
-
-% \def\font_helpers_synchronize_math_family
-% {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname}
-
-\def\font_helpers_synchronize_math_family
- {\ifcsname\??fontmathsynchronizer\fontalternative\endcsname
- \lastnamedcs
- \else
- \font_helpers_synchronize_math_family_mr
- \fi}
-
-\ifdefined \fontid % we need to keep this test for a while
- \appendtoks
- \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy
- \else
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy
- \fi
- \to \t_font_math_strategies
-\else
- \appendtoks
- \edef\currentmathfontmr{\fontname\textfont\zerocount}%
- \edef\currentmathfontmb{\fontname\textfont\plusthree}%
- \ifx\currentmathfontmr\currentmathfontmb
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy
- \else
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy
- \fi
- \to \t_font_math_strategies
-\fi
-
-%def\font_helpers_synchronize_math_bold_strategy{\csname\??fontmathstoredstrategy\fontclass\endcsname}
-\def\font_helpers_synchronize_math_bold_strategy{\begincsname\??fontmathstoredstrategy\fontclass\endcsname}
-
-\newconditional\c_font_pseudo_bold_math_state
-
-\def\font_helpers_set_math_partial_bold_strategy{\settrue \c_font_pseudo_bold_math_state}
-\def\font_helpers_set_math_full_bold_strategy {\setfalse\c_font_pseudo_bold_math_state}
-
-\appendtoks
- \font_helpers_synchronize_math_bold_strategy
-\to \everymathematics
-
-%D Bold is somewhat special as we might want both full-bold-math mixed regular-math,
-%D as well as automatic adaption to outer bold (in titles and inline text bold) so
-%D we will need explicit switches as well as an automatic one. (We will use lucida
-%D as an example.)
-
-\ifdefined\mathdefault \else \let\mathdefault\relax \fi
-
-\newconditional\c_math_bold
-
-\unexpanded\def\mr % math regular
- {\ifmmode
- \font_helpers_synchronize_math_family_mr
- \else
- \font_helpers_set_current_font_alternative\s!mr
- \fi
- \mathdefault
- \setfalse\c_math_bold}
-
-\unexpanded\def\mb % math bold
- {\ifmmode
- \font_helpers_synchronize_math_family_mb
- \else
- \font_helpers_set_current_font_alternative\s!mb
- \fi
- \mathdefault
- \settrue\c_math_bold}
-
-\appendtoks
- \font_helpers_synchronize_math_family % auto bold
-\to \everymathematics
-
-\appendtoks
- \ifconditional\c_math_bold\mb\fi
-\to \everymathematics
-
-%D \macros
-%D {bigmath,nobigmath}
-%D
-%D We can inhibit this slow||downer with:
-
-% these can best be combined
-
-% 0=never 1=everymath 2=always
-
-\setnewconstant\synchronizebigmathflag\plusone
-
-\appendtoks
- \ifcase\synchronizebigmathflag
- % never
- \or
- \synchronizebigmath
- \or
- % always
- \fi
-\to \everymathematics
-
-\unexpanded\def\nobigmath {\synchronizebigmathflag\zerocount}
-\unexpanded\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath}
-\unexpanded\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath}
-
-\let\bigmathfontsize\empty
-
-\unexpanded\def\synchronizebigmath
- {\ifx\bigmathfontsize\fontsize
- % already in sync
- \else
- \let\bigmathfontsize\fontsize
- \font_helpers_synchronize_math
- \fi}
-
-\unexpanded\def\font_helpers_check_big_math_synchronization
- {\ifcase\synchronizebigmathflag
- % never
- \or
- \ifmmode \synchronizebigmath \fi
- \or
- \synchronizebigmath
- \fi}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-mat.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-mat.mkvi
index 64810d3272a..594475808b7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-mat.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-mat.mkvi
@@ -344,7 +344,7 @@
\to \everymathematics
\unexpanded\def\font_helpers_synchronize_math_family_mr
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy
+ {\c_attr_mathfamily\ifconditional\c_font_bidirectional_mathstrategy
\ifconditional\c_math_right_to_left
\plustwo
\else
@@ -355,7 +355,7 @@
\fi}
\unexpanded\def\font_helpers_synchronize_math_family_mb
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy
+ {\c_attr_mathfamily\ifconditional\c_font_bidirectional_mathstrategy
\ifconditional\c_math_right_to_left
\ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi
\else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-mis.lua b/Master/texmf-dist/tex/context/base/mkiv/font-mis.lua
index fe972114f47..18120f524a0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-mis.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-mis.lua
@@ -21,7 +21,7 @@ local readers = otf.readers
if readers then
- otf.version = otf.version or 3.111
+ otf.version = otf.version or 3.113
otf.cache = otf.cache or containers.define("fonts", "otl", otf.version, true)
function fonts.helpers.getfeatures(name,save)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-nod.lua b/Master/texmf-dist/tex/context/base/mkiv/font-nod.lua
index 8c0f6e441a7..ed307e7c531 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-nod.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-nod.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-nod'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -18,7 +19,6 @@ local match, rep = string.match, string.rep
fonts = fonts or { }
nodes = nodes or { }
-
local fonts = fonts
local nodes = nodes
local context = context
@@ -39,9 +39,6 @@ local tonode = nuts.tonode
local injections = nodes.injections or { }
nodes.injections = injections
-local char_tracers = tracers.characters or { }
-tracers.characters = char_tracers
-
local step_tracers = tracers.steppers or { }
tracers.steppers = step_tracers
@@ -54,7 +51,7 @@ local disc_code = nodecodes.disc
local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local getnext = nuts.getnext
local getprev = nuts.getprev
@@ -111,135 +108,9 @@ local function freeze(h,where)
end
end
-function char_tracers.collect(head,list,tag,n)
- n = n or 0
- local ok = false
- local fn = nil
- while head do
- local char, id = isglyph(head)
- if char then
- local font = id
- if font ~= fn then
- ok, fn = false, font
- end
- if not ok then
- ok = true
- n = n + 1
- list[n] = list[n] or { }
- list[n][tag] = { }
- end
- local l = list[n][tag]
- -- l[#l+1] = { char, font, i }
- l[#l+1] = { char, font }
- elseif id == disc_code then
- -- skip
- -- local pre, post, replace = getdisc(head)
- -- if replace then
- -- for n in nextglyph, replace do
- -- l[#l+1] = { c, f }
- -- end
- -- end
- -- if pre then
- -- for n in nextglyph, pre do
- -- l[#l+1] = { c, f }
- -- end
- -- end
- -- if post then
- -- for n in nextglyph, post do
- -- l[#l+1] = { c, f }
- -- end
- -- end
- else
- ok = false
- end
- head = getnext(head)
- end
-end
-
-function char_tracers.equal(ta, tb)
- if #ta ~= #tb then
- return false
- else
- for i=1,#ta do
- local a = ta[i]
- local b = tb[i]
- -- if a[1] ~= b[1] or a[2] ~= b[2] or a[3] ~= b[3] then
- if a[1] ~= b[1] or a[2] ~= b[2] then
- return false
- end
- end
- end
- return true
-end
-
-function char_tracers.string(t)
- local tt = { }
- for i=1,#t do
- tt[i] = utfchar(t[i][1])
- end
- return concat(tt,"")
-end
-
local f_unicode = formatters["%U"]
local f_badcode = formatters["{%i}"]
-function char_tracers.unicodes(t,decimal)
- local tt = { }
- for i=1,#t do
- local n = t[i][1]
- if n == 0 then
- tt[i] = "-"
- elseif decimal then
- tt[i] = n
- else
- tt[i] = f_unicode(n)
- end
- end
- return concat(tt," ")
-end
-
--- function char_tracers.indices(t,decimal)
--- local tt = { }
--- for i=1,#t do
--- local n = t[i][3]
--- if n == 0 then
--- tt[i] = "-"
--- elseif decimal then
--- tt[i] = n
--- else
--- tt[i] = f_unicode(n)
--- end
--- end
--- return concat(tt," ")
--- end
-
-function char_tracers.start()
- local npc = handlers.characters -- should accept nuts too
- local list = { }
- function handlers.characters(head)
- local n = #list
- char_tracers.collect(head,list,'before',n)
- head = npc(head) -- for the moment tonode
- char_tracers.collect(head,list,'after',n)
- if #list > n then
- list[#list+1] = { }
- end
- return head
- end
- function char_tracers.stop()
- tracers.list['characters'] = list
- local variables = {
- ['title'] = 'ConTeXt Character Processing Information',
- ['color-background-one'] = lmx.get('color-background-yellow'),
- ['color-background-two'] = lmx.get('color-background-purple'),
- }
- lmx.show('context-characters.lmx',variables)
- handlers.characters = npc
- tasks.restart("processors", "characters")
- end
- tasks.restart("processors", "characters")
-end
-
local stack = { }
function tracers.start(tag)
@@ -293,7 +164,6 @@ function step_tracers.glyphs(n,i)
end
function step_tracers.features()
- -- we cannot use first_glyph here as it only finds characters with subtype < 256
local f = collection[1]
for n, char, font in nextglyph, f do
local tfmdata = fontidentifiers[font]
@@ -396,7 +266,7 @@ function step_tracers.codes(i,command,space)
local char, id = isglyph(c)
if char then
showchar(char,id)
- elseif id == dir_code or (id == localpar_code and start_of_par(c)) then
+ elseif id == dir_code or (id == par_code and start_of_par(c)) then
context("[%s]",getdirection(c) or "?")
elseif id == disc_code then
local pre, post, replace = getdisc(c)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ocl.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ocl.lua
index 1890e5ec54e..e6a38af5c3e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ocl.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ocl.lua
@@ -8,10 +8,6 @@ if not modules then modules = { } end modules ['font-ocl'] = {
-- todo : user list of colors
-if CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 then
- return
-end
-
local tostring, tonumber, next = tostring, tonumber, next
local round, max = math.round, math.round
local gsub, find = string.gsub, string.find
@@ -151,85 +147,17 @@ local function convert(t,k)
return v
end
-local start = { "pdf", "mode", "font" } -- force text mode (so get q Q right)
------ stop = { "pdf", "mode", "page" } -- force page mode (else overlap)
-local push = { "pdf", "page", "q" }
-local pop = { "pdf", "page", "Q" }
-
--- -- This one results in color directives inside BT ET but has less q Q pairs. It
--- -- only shows the first glyph in acrobat and nothing more. No problem with other
--- -- renderers.
---
--- local function initializeoverlay(tfmdata,kind,value) -- hm, always value
--- if value then
--- local resources = tfmdata.resources
--- local palettes = resources.colorpalettes
--- if palettes then
--- --
--- local converted = resources.converted
--- if not converted then
--- converted = setmetatableindex(convert)
--- resources.converted = converted
--- end
--- local colorvalues = sharedpalettes[value] or converted[palettes[tonumber(value) or 1] or palettes[1]] or { }
--- local classes = #colorvalues
--- if classes == 0 then
--- return
--- end
--- --
--- local characters = tfmdata.characters
--- local descriptions = tfmdata.descriptions
--- local properties = tfmdata.properties
--- --
--- properties.virtualized = true
--- tfmdata.fonts = {
--- { id = 0 }
--- }
--- --
--- local getactualtext = otf.getactualtext
--- local default = colorvalues[#colorvalues]
--- local b, e = getactualtext(tounicode(0xFFFD))
--- local actualb = { "pdf", "page", b } -- saves tables
--- local actuale = { "pdf", "page", e } -- saves tables
--- --
--- for unicode, character in next, characters do
--- local description = descriptions[unicode]
--- if description then
--- local colorlist = description.colors
--- if colorlist then
--- local u = description.unicode or characters[unicode].unicode
--- local w = character.width or 0
--- local s = #colorlist
--- local goback = w ~= 0 and leftcommand[w] or nil -- needs checking: are widths the same
--- local t = {
--- start,
--- not u and actualb or { "pdf", "page", (getactualtext(tounicode(u))) },
--- push,
--- }
--- local n = 3
--- local l = nil
--- for i=1,s do
--- local entry = colorlist[i]
--- local v = colorvalues[entry.class] or default
--- if v and l ~= v then
--- n = n + 1 t[n] = v
--- l = v
--- end
--- n = n + 1 t[n] = charcommand[entry.slot]
--- if s > 1 and i < s and goback then
--- n = n + 1 t[n] = goback
--- end
--- end
--- n = n + 1 t[n] = pop
--- n = n + 1 t[n] = actuale
--- n = n + 1 t[n] = stop
--- character.commands = t
--- end
--- end
--- end
--- end
--- end
--- end
+-- At some point 'font' mode was added to the engine and we can assume that most distributions
+-- ship a luatex that has it; ancient versions are no longer supported anyway. Begin 2020 there
+-- was an actualtext related mail exchange with RM etc. that might result in similar mode keys
+-- in other tex->pdf programs because there is a bit of inconsistency in the way this is dealt
+-- with. Best is not to touch this code too much.
+
+local mode = { "pdf", "mode", "font" }
+local push = { "pdf", "page", "q" }
+local pop = { "pdf", "page", "Q" }
+
+-- see context git repository for older variant (pre 20200501 cleanup)
local function initializeoverlay(tfmdata,kind,value)
if value then
@@ -278,10 +206,11 @@ local function initializeoverlay(tfmdata,kind,value)
local s = #colorlist
local goback = w ~= 0 and leftcommand[w] or nil -- needs checking: are widths the same
local t = {
+ mode,
not u and actualb or { "pdf", "page", (getactualtext(tounicode(u))) },
push,
}
- local n = 2
+ local n = 3
local l = nil
for i=1,s do
local entry = colorlist[i]
@@ -436,7 +365,7 @@ do
local savedata = io.savedata
local remove = os.remove
- if context and xml.convert then
+if context then
local xmlconvert = xml.convert
local xmlfirst = xml.first
@@ -451,13 +380,13 @@ do
return data
end
- else
+else
function otfsvg.filterglyph(entry,index) -- can be overloaded
return entry.data
end
- end
+end
local runner = sandbox and sandbox.registerrunner {
name = "otfsvg",
@@ -484,6 +413,16 @@ do
-- Because a generic setup can be flawed we need to catch bad inkscape runs which add a bit of
-- ugly overhead. Bah.
+ local new = nil
+
+ local function inkscapeformat(suffix)
+ if new == nil then
+ new = os.resultof("inkscape --version") or ""
+ new = new == "" or not find(new,"Inkscape%s*0")
+ end
+ return new and "filename" or suffix
+ end
+
function otfsvg.topdf(svgshapes,tfmdata)
local pdfshapes = { }
local inkscape = runner()
@@ -493,7 +432,7 @@ do
local nofshapes = #svgshapes
local f_svgfile = formatters["temp-otf-svg-shape-%i.svg"]
local f_pdffile = formatters["temp-otf-svg-shape-%i.pdf"]
- local f_convert = formatters["%s --export-pdf=%s\n"]
+ local f_convert = formatters["%s --export-%s=%s\n"]
local filterglyph = otfsvg.filterglyph
local nofdone = 0
local processed = { }
@@ -507,7 +446,7 @@ do
local svgfile = f_svgfile(index)
local pdffile = f_pdffile(index)
savedata(svgfile,data)
- inkscape:write(f_convert(svgfile,pdffile))
+ inkscape:write(f_convert(svgfile,inkscapeformat("pdf"),pdffile))
processed[index] = true
nofdone = nofdone + 1
if nofdone % 25 == 0 then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ocm.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ocm.lua
new file mode 100644
index 00000000000..2f6c29e65d8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ocm.lua
@@ -0,0 +1,874 @@
+if not modules then modules = { } end modules ['font-ocm'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+if not context then
+ return
+elseif CONTEXTLMTXMODE and CONTEXTLMTXMODE > 0 then
+ return
+else
+ -- Maybe I'll also make a generic variant but for now I just test this in
+ -- MkIV. After all, color fonts are not that much used (and generic is for
+ -- serious looking articles and books and not for fancy documents using
+ -- emoji.) Below is a quick and dirty implementation. Also, it looks like
+ -- these features were never used outside context anyway (in spite of being
+ -- in generic).
+end
+
+local tostring, tonumber, next = tostring, tonumber, next
+local round, max = math.round, math.round
+local sortedkeys, sortedhash, concat = table.sortedkeys, table.sortedhash, table.concat
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local otf = fonts.handlers.otf
+local otfregister = otf.features.register
+local bpfactor = number.dimenfactors.bp
+local typethree = { }
+
+callback.register("provide_charproc_data",function(action,f,...)
+ local registered = typethree[f]
+ if registered then
+ return registered(action,f,...)
+ else
+ return 0, 0 -- this will also disable further calls
+ end
+end)
+
+local defaults = {
+ [1] = function() return 0, 0 end,
+ [2] = function() return 0, 0 end,
+ [3] = function() return 0.001, "" end,
+}
+
+local function registeractions(t)
+ return {
+ [1] = t.preroll or defaults[1],
+ [2] = t.collect or defaults[2],
+ [3] = t.wrapup or defaults[3],
+ }
+end
+
+local function registertypethreeresource(specification,n,o)
+ specification.usedobjects["X"..n] = lpdf.reference(o)
+end
+
+local function registertypethreefont(specification,n,o)
+ specification.usedfonts["F"..n] = lpdf.reference(o)
+end
+
+local function typethreeresources(specification)
+ local usedobjects = specification.usedobjects
+ local usedfonts = specification.usedfonts
+ local resources = { }
+ if next(usedobjects) then
+ resources[#resources+1] = "/XObject << " .. usedobjects() .. " >>"
+ end
+ if next(usedfonts) then
+ resources[#resources+1] = "/Font << " .. usedfonts() .. " >>"
+ end
+ -- resources[#resources+1] = lpdf.collectedresources()
+ specification.usedfonts = nil
+ specification.usedobjects = nil
+ return concat(resources, " ")
+end
+
+local function registerfont(specification,actions)
+ specification.usedfonts = lpdf.dictionary()
+ specification.usedobjects = lpdf.dictionary()
+ typethree[specification.id] = function(action,f,c)
+ return actions[action](specification,f,c)
+ end
+end
+
+fonts.handlers.typethree = {
+ register = function(id,handler)
+ -- needed for manual
+ if not typethree[id] then
+ logs.report("fonts","low level Type3 handler registered for font with id %i",id)
+ typethree[id] = handler
+ end
+ end
+}
+
+local initializeoverlay do
+
+ local f_color = formatters["%.3f %.3f %.3f rg"]
+ local f_gray = formatters["%.3f g"]
+ local sharedpalettes = { }
+ local colors = attributes.list[attributes.private('color')] or { }
+ local transparencies = attributes.list[attributes.private('transparency')] or { }
+
+ function otf.registerpalette(name,values)
+ sharedpalettes[name] = values
+ local color = lpdf.color
+ local transparency = lpdf.transparency
+ local register = colors.register
+ for i=1,#values do
+ local v = values[i]
+ if v == "textcolor" then
+ values[i] = false
+ else
+ local c = nil
+ local t = nil
+ if type(v) == "table" then
+ c = register(name,"rgb",
+ max(round((v.r or 0)*255),255)/255,
+ max(round((v.g or 0)*255),255)/255,
+ max(round((v.b or 0)*255),255)/255
+ )
+ else
+ c = colors[v]
+ t = transparencies[v]
+ end
+ if c and t then
+ values[i] = color(1,c) .. " " .. transparency(t)
+ elseif c then
+ values[i] = color(1,c)
+ elseif t then
+ values[i] = color(1,t)
+ end
+ end
+ end
+ end
+
+ local function convert(t,k)
+ local v = { }
+ for i=1,#k do
+ local p = k[i]
+ local r, g, b = p[1], p[2], p[3]
+ if r == g and g == b then
+ v[i] = f_gray(r/255)
+ else
+ v[i] = f_color(r/255,g/255,b/255)
+ end
+ end
+ t[k] = v
+ return v
+ end
+
+ -- This is by no means watertight (the id mess) especially because we
+ -- don't know it yet. Instead we can just assemble here and avoid the
+ -- box approach. I might do that (so then we need to pass fonts and
+ -- extra resource entries.
+
+ local f_stream = formatters["%s 0 d0 %s 0 0 %s 0 %s cm /X%i Do"]
+ local fontorder = 0
+ local actions = registeractions {
+
+ preroll = function(specification,f,c)
+ local data = specification.delegated[c]
+ local colorlist = data.colorlist
+ local colorvalues = specification.colorvalues
+ local default = specification.default
+ local mainid = specification.mainid
+ local t = { "\\typethreefont{", mainid, "}" }
+ local n = 3
+ local l = nil
+ local m = #colorlist
+ for i=1,m do
+ local entry = colorlist[i]
+ local v = colorvalues[entry.class] or default
+ if v and l ~= v then
+ n = n + 1 ; t[n] = "\\typethreecode{"
+ n = n + 1 ; t[n] = v
+ n = n + 1 ; t[n] = "}"
+ l = v
+ end
+ if i < m then
+ n = n + 1 ; t[n] = "\\typethreechar{"
+ else
+ n = n + 1 ; t[n] = "\\typethreelast{"
+ end
+ n = n + 1 ; t[n] = entry.slot
+ n = n + 1 ; t[n] = "}"
+ end
+ token.set_macro("typethreemacro",concat(t))
+ tex.runlocal("typethreetoks")
+ registertypethreeresource(specification,c,tex.saveboxresource(0,nil,lpdf.collectedresources(),true))
+ -- registertypethreefont(specification,mainid,lpdf.reference(lpdf.getfontobjnumber(mainid)))
+ return 0, 0
+ end,
+
+ collect = function(specification,f,c)
+ local parameters = specification.parameters
+ local data = specification.delegated[c]
+ local factor = parameters.hfactor
+ local units = parameters.units
+ local width = (data.width or 0) / factor
+ local scale = 100
+ local factor = units * bpfactor -- / scale
+ local depth = (data.depth or 0)*factor
+ local shift = - depth / (10*units/1000)
+ local object = pdf.immediateobj("stream",f_stream(width,scale,scale,shift,c))
+ return object, width
+ end,
+
+ wrapup = function(specification,f)
+ return 0.001, typethreeresources(specification)
+ end,
+
+ }
+
+ local function register(specification)
+ registerfont(specification,actions)
+ end
+
+ initializeoverlay = function(tfmdata,kind,value)
+ if value then
+ local resources = tfmdata.resources
+ local palettes = resources.colorpalettes
+ if palettes then
+ local converted = resources.converted
+ if not converted then
+ converted = setmetatableindex(convert)
+ resources.converted = converted
+ end
+ local colorvalues = sharedpalettes[value]
+ local default = false -- so the text color (bad for icon overloads)
+ if colorvalues then
+ default = colorvalues[#colorvalues]
+ else
+ colorvalues = converted[palettes[tonumber(value) or 1] or palettes[1]] or { }
+ end
+ local classes = #colorvalues
+ if classes == 0 then
+ return
+ end
+ --
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local properties = tfmdata.properties
+ local parameters = tfmdata.parameters
+ --
+ properties.virtualized = true
+ --
+ local delegated = { }
+ local index = 0
+ local fonts = tfmdata.fonts or { }
+ local fontindex = #fonts + 1
+ tfmdata.fonts = fonts
+
+ local function flush()
+ if index > 0 then
+ fontorder = fontorder + 1
+ local f = {
+ characters = delegated,
+ parameters = parameters,
+ tounicode = true,
+ format = "type3",
+ name = "InternalTypeThreeFont" , -- .. fontorder,
+ psname = "none",
+ }
+ fonts[fontindex] = {
+ id = font.define(f),
+ delegated = delegated,
+ parameters = parameters,
+ colorvalues = colorvalues,
+ default = default,
+ }
+ end
+ fontindex = fontindex + 1
+ index = 0
+ delegated = { }
+ end
+
+ for unicode, character in sortedhash(characters) do
+ local description = descriptions[unicode]
+ if description then
+ local colorlist = description.colors
+ if colorlist then
+ if index == 255 then
+ flush()
+ end
+ index = index + 1
+ delegated[index] = {
+ width = character.width,
+ height = character.height,
+ depth = character.depth,
+ tounicode = character.tounicode,
+ colorlist = colorlist,
+ }
+ character.commands = {
+ { "slot", fontindex, index },
+ }
+ end
+ end
+ end
+
+ flush()
+ local mainid = font.nextid()
+ for i=1,#fonts do
+ local f = fonts[i]
+ if f.delegated then
+ f.mainid = mainid
+ register(f)
+ end
+ end
+
+ return true
+ end
+ end
+ end
+
+ otfregister {
+ name = "colr",
+ description = "color glyphs",
+ manipulators = {
+ base = initializeoverlay,
+ node = initializeoverlay,
+ }
+ }
+
+end
+
+do
+
+ local nofstreams = 0
+ local f_name = formatters[ [[pdf-glyph-%05i]] ]
+ local f_used = context and formatters[ [[original:///%s]] ] or formatters[ [[%s]] ]
+ local hashed = { }
+ local cache = { }
+
+ local openpdf = pdfe.new
+
+ function otf.storepdfdata(pdf)
+ if pdf then
+ local done = hashed[pdf]
+ if not done then
+ nofstreams = nofstreams + 1
+ local f = f_name(nofstreams)
+ local n = openpdf(pdf,#pdf,f)
+ done = f_used(n)
+ hashed[pdf] = done
+ end
+ return done
+ end
+ end
+
+end
+
+local pdftovirtual do
+
+ local f_stream = formatters["%s 0 d0 %s 0 0 %s %s %s cm /X%i Do"]
+ local fontorder = 0
+ local shared = { }
+ local actions = registeractions {
+
+ preroll = function(specification,f,c)
+ return 0, 0
+ end,
+
+ collect = function(specification,f,c)
+ local parameters = specification.parameters
+ local data = specification.delegated[c]
+ local desdata = data.desdata
+ local pdfdata = data.pdfdata
+ local width = desdata.width or 0
+ local height = desdata.height or 0
+ local depth = desdata.depth or 0
+ local factor = parameters.hfactor
+ local units = parameters.units
+ local typ = type(pdfdata)
+
+ local dx = 0
+ local dy = 0
+ local scale = 1
+
+ if typ == "table" then
+ data = pdfdata.data
+ dx = pdfdata.x or pdfdata.dx or 0
+ dy = pdfdata.y or pdfdata.dy or 0
+ scale = pdfdata.scale or 1
+ elseif typ == "string" then
+ data = pdfdata
+ dx = 0
+ dy = 0
+ else
+ return 0, 0
+ end
+
+ if not data then
+ return 0, 0
+ end
+
+ local name = otf.storepdfdata(data)
+ local xform = shared[name]
+
+ if not xform then
+ xform = images.embed(images.create { filename = name })
+ shared[name] = xform
+ end
+
+ registertypethreeresource(specification,c,xform.objnum)
+
+ scale = scale * (width / (xform.width * bpfactor))
+ dy = - depth + dy
+-- dx = 0
+-- dy = 0
+ local object = pdf.immediateobj("stream",f_stream(width,scale,scale,dx,dy,c)), width
+
+ return object, width
+ end,
+
+ wrapup = function(specification,f)
+ return 1/specification.parameters.units, typethreeresources(specification)
+ end,
+
+ }
+
+ local function register(specification)
+ registerfont(specification,actions)
+ end
+
+ pdftovirtual = function(tfmdata,pdfshapes,kind) -- kind = png|svg
+ if not tfmdata or not pdfshapes or not kind then
+ return
+ end
+ --
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local properties = tfmdata.properties
+ local parameters = tfmdata.parameters
+ local hfactor = parameters.hfactor
+ --
+ properties.virtualized = true
+ --
+ local storepdfdata = otf.storepdfdata
+ --
+ local delegated = { }
+ local index = 0
+ local fonts = tfmdata.fonts or { }
+ local fontindex = #fonts + 1
+ tfmdata.fonts = fonts
+
+ local function flush()
+ if index > 0 then
+ fontorder = fontorder + 1
+ local f = {
+ characters = delegated,
+ parameters = parameters,
+ tounicode = true,
+ format = "type3",
+ name = "InternalTypeThreeFont" .. fontorder,
+ psname = "none",
+ size = parameters.size,
+ }
+ fonts[fontindex] = {
+ id = font.define(f),
+ delegated = delegated,
+ parameters = parameters,
+ }
+ end
+ fontindex = fontindex + 1
+ index = 0
+ delegated = { }
+ end
+
+ for unicode, character in sortedhash(characters) do
+ local idx = character.index
+ if idx then
+ local pdfdata = pdfshapes[idx]
+ local description = descriptions[unicode]
+ if pdfdata and description then
+ if index == 255 then
+ flush()
+ end
+ index = index + 1
+ delegated[index] = {
+ desdata = description,
+ width = character.width,
+ height = character.width,
+ depth = character.width,
+ tounicode = character.tounicode,
+ pdfdata = pdfdata,
+ }
+ character.commands = {
+ { "slot", fontindex, index },
+ }
+ end
+ end
+ end
+ --
+ flush()
+ local mainid = font.nextid()
+ for i=1,#fonts do
+ local f = fonts[i]
+ if f.delegated then
+ f.mainid = mainid
+ register(f)
+ end
+ end
+ --
+ end
+
+end
+
+local initializesvg do
+
+ local otfsvg = otf.svg or { }
+ otf.svg = otfsvg
+ otf.svgenabled = true
+
+ local report_svg = logs.reporter("fonts","svg conversion")
+
+ local loaddata = io.loaddata
+ local savedata = io.savedata
+ local remove = os.remove
+
+ local xmlconvert = xml.convert
+ local xmlfirst = xml.first
+
+ function otfsvg.filterglyph(entry,index)
+ local d = entry.data
+ if gzip.compressed(d) then
+ d = gzip.decompress(d) or d
+ end
+ local svg = xmlconvert(d)
+ local root = svg and xmlfirst(svg,"/svg[@id='glyph"..index.."']")
+ local data = root and tostring(root)
+ return data
+ end
+
+ local runner = sandbox and sandbox.registerrunner {
+ name = "otfsvg",
+ program = "inkscape",
+ method = "pipeto",
+ template = "--export-area-drawing --shell > temp-otf-svg-shape.log",
+ reporter = report_svg,
+ }
+
+ if not runner then
+ --
+ -- poor mans variant for generic:
+ --
+ runner = function()
+ return io.popen("inkscape --export-area-drawing --shell > temp-otf-svg-shape.log","w")
+ end
+ end
+
+ -- There are svg out there with bad viewBox specifications where shapes lay outside that area,
+ -- but trying to correct that didn't work out well enough so I discarded that code. BTW, we
+ -- decouple the inskape run and the loading run because inkscape is working in the background
+ -- in the files so we need to have unique files.
+ --
+ -- Because a generic setup can be flawed we need to catch bad inkscape runs which add a bit of
+ -- ugly overhead. Bah.
+
+ local new = nil
+
+ local function inkscapeformat(suffix)
+ if new == nil then
+ new = os.resultof("inkscape --version") or ""
+ new = new == "" or not find(new,"Inkscape%s*0")
+ end
+ return new and "filename" or suffix
+ end
+
+ function otfsvg.topdf(svgshapes,tfmdata)
+ local pdfshapes = { }
+ local inkscape = runner()
+ if inkscape then
+ -- local indices = fonts.getindices(tfmdata)
+ local descriptions = tfmdata.descriptions
+ local nofshapes = #svgshapes
+ local f_svgfile = formatters["temp-otf-svg-shape-%i.svg"]
+ local f_pdffile = formatters["temp-otf-svg-shape-%i.pdf"]
+ local f_convert = formatters["%s --export-%s=%s\n"]
+ local filterglyph = otfsvg.filterglyph
+ local nofdone = 0
+ local processed = { }
+ report_svg("processing %i svg containers",nofshapes)
+ statistics.starttiming()
+ for i=1,nofshapes do
+ local entry = svgshapes[i]
+ for index=entry.first,entry.last do
+ local data = filterglyph(entry,index)
+ if data and data ~= "" then
+ local svgfile = f_svgfile(index)
+ local pdffile = f_pdffile(index)
+ savedata(svgfile,data)
+ inkscape:write(f_convert(svgfile,inkscapeformat("pdf"),pdffile))
+ processed[index] = true
+ nofdone = nofdone + 1
+ if nofdone % 25 == 0 then
+ report_svg("%i shapes submitted",nofdone)
+ end
+ end
+ end
+ end
+ if nofdone % 25 ~= 0 then
+ report_svg("%i shapes submitted",nofdone)
+ end
+ report_svg("processing can be going on for a while")
+ inkscape:write("quit\n")
+ inkscape:close()
+ report_svg("processing %i pdf results",nofshapes)
+ for index in next, processed do
+ local svgfile = f_svgfile(index)
+ local pdffile = f_pdffile(index)
+ -- local fntdata = descriptions[indices[index]]
+ -- local bounds = fntdata and fntdata.boundingbox
+ local pdfdata = loaddata(pdffile)
+ if pdfdata and pdfdata ~= "" then
+ pdfshapes[index] = {
+ data = pdfdata,
+ -- x = bounds and bounds[1] or 0,
+ -- y = bounds and bounds[2] or 0,
+ }
+ end
+ remove(svgfile)
+ remove(pdffile)
+ end
+ local characters = tfmdata.characters
+ for k, v in next, characters do
+ local d = descriptions[k]
+ local i = d.index
+ if i then
+ local p = pdfshapes[i]
+ if p then
+ local w = d.width
+ local l = d.boundingbox[1]
+ local r = d.boundingbox[3]
+ p.scale = (r - l) / w
+ p.x = l
+ end
+ end
+ end
+ if not next(pdfshapes) then
+ report_svg("there are no converted shapes, fix your setup")
+ end
+ statistics.stoptiming()
+ if statistics.elapsedseconds then
+ report_svg("svg conversion time %s",statistics.elapsedseconds() or "-")
+ end
+ end
+ return pdfshapes
+ end
+
+ initializesvg = function(tfmdata,kind,value) -- hm, always value
+ if value and otf.svgenabled then
+ local svg = tfmdata.properties.svg
+ local hash = svg and svg.hash
+ local timestamp = svg and svg.timestamp
+ if not hash then
+ return
+ end
+ local pdffile = containers.read(otf.pdfcache,hash)
+ local pdfshapes = pdffile and pdffile.pdfshapes
+ if not pdfshapes or pdffile.timestamp ~= timestamp or not next(pdfshapes) then
+ -- the next test tries to catch errors in generic usage but of course can result
+ -- in running again and again
+ local svgfile = containers.read(otf.svgcache,hash)
+ local svgshapes = svgfile and svgfile.svgshapes
+ pdfshapes = svgshapes and otfsvg.topdf(svgshapes,tfmdata,otf.pdfcache.writable,hash) or { }
+ containers.write(otf.pdfcache, hash, {
+ pdfshapes = pdfshapes,
+ timestamp = timestamp,
+ })
+ end
+ pdftovirtual(tfmdata,pdfshapes,"svg")
+ return true
+ end
+ end
+
+ otfregister {
+ name = "svg",
+ description = "svg glyphs",
+ manipulators = {
+ base = initializesvg,
+ node = initializesvg,
+ }
+ }
+
+end
+
+-- This can be done differently e.g. with ffi and gm and we can share code anway. Using
+-- batchmode in gm is not faster and as it accumulates we would need to flush all
+-- individual shapes. But ... in context lmtx (and maybe the backport) we will use
+-- a different and more efficient method anyway. I'm still wondering if I should
+-- keep color code in generic. Maybe it should be optional.
+
+local initializepng do
+
+ local otfpng = otf.png or { }
+ otf.png = otfpng
+ otf.pngenabled = true
+
+ local report_png = logs.reporter("fonts","png conversion")
+
+ local loaddata = io.loaddata
+ local savedata = io.savedata
+ local remove = os.remove
+
+ local runner = sandbox and sandbox.registerrunner {
+ name = "otfpng",
+ program = "gm",
+ template = "convert -quality 100 temp-otf-png-shape.png temp-otf-png-shape.pdf > temp-otf-svg-shape.log",
+ -- reporter = report_png,
+ }
+
+ if not runner then
+ --
+ -- poor mans variant for generic:
+ --
+ runner = function()
+ return os.execute("gm convert -quality 100 temp-otf-png-shape.png temp-otf-png-shape.pdf > temp-otf-svg-shape.log")
+ end
+ end
+
+ -- Alternatively we can create a single pdf file with -adjoin and then pick up pages from
+ -- that file but creating thousands of small files is no fun either.
+
+ local files = utilities.files
+ local openfile = files.open
+ local closefile = files.close
+ local setposition = files.setposition
+ local readstring = files.readstring
+
+ function otfpng.topdf(pngshapes,filename)
+ if pngshapes and filename then
+ local pdfshapes = { }
+ local pngfile = "temp-otf-png-shape.png"
+ local pdffile = "temp-otf-png-shape.pdf"
+ local nofdone = 0
+ local indices = sortedkeys(pngshapes) -- can be sparse
+ local nofindices = #indices
+ report_png("processing %i png containers",nofindices)
+ statistics.starttiming()
+ local filehandle = openfile(filename)
+ for i=1,nofindices do
+ local index = indices[i]
+ local entry = pngshapes[index]
+ -- local data = entry.data -- or placeholder
+ local offset = entry.o
+ local size = entry.s
+ local x = entry.x
+ local y = entry.y
+ local data = nil
+ if offset and size then
+ setposition(filehandle,offset)
+ data = readstring(filehandle,size)
+ savedata(pngfile,data)
+ runner()
+ data = loaddata(pdffile)
+ end
+ pdfshapes[index] = {
+-- x = x ~= 0 and x or nil,
+-- y = y ~= 0 and y or nil,
+ data = data,
+ }
+ nofdone = nofdone + 1
+ if nofdone % 100 == 0 then
+ report_png("%i shapes processed",nofdone)
+ end
+ end
+ closefile(filehandle)
+ report_png("processing %i pdf results",nofindices)
+ remove(pngfile)
+ remove(pdffile)
+ statistics.stoptiming()
+ if statistics.elapsedseconds then
+ report_png("png conversion time %s",statistics.elapsedseconds() or "-")
+ end
+ return pdfshapes
+ end
+ end
+
+ initializepng = function(tfmdata,kind,value) -- hm, always value
+ if value and otf.pngenabled then
+ local png = tfmdata.properties.png
+ local hash = png and png.hash
+ local timestamp = png and png.timestamp
+ if not hash then
+ return
+ end
+ local pdffile = containers.read(otf.pdfcache,hash)
+ local pdfshapes = pdffile and pdffile.pdfshapes
+ if not pdfshapes or pdffile.timestamp ~= timestamp then
+ local pngfile = containers.read(otf.pngcache,hash)
+ local filename = tfmdata.resources.filename
+ local pngshapes = pngfile and pngfile.pngshapes
+ pdfshapes = pngshapes and otfpng.topdf(pngshapes,filename) or { }
+ containers.write(otf.pdfcache, hash, {
+ pdfshapes = pdfshapes,
+ timestamp = timestamp,
+ })
+ end
+ --
+ pdftovirtual(tfmdata,pdfshapes,"png")
+ return true
+ end
+ end
+
+ otfregister {
+ name = "sbix",
+ description = "sbix glyphs",
+ manipulators = {
+ base = initializepng,
+ node = initializepng,
+ }
+ }
+
+ otfregister {
+ name = "cblc",
+ description = "cblc glyphs",
+ manipulators = {
+ base = initializepng,
+ node = initializepng,
+ }
+ }
+
+end
+
+do
+
+ local function initializecolor(tfmdata,kind,value)
+ if value == "auto" then
+ return
+ initializeoverlay(tfmdata,kind,value) or
+ initializesvg (tfmdata,kind,value) or
+ initializepng (tfmdata,kind,value)
+ elseif value == "overlay" then
+ return initializeoverlay(tfmdata,kind,value)
+ elseif value == "svg" then
+ return initializesvg(tfmdata,kind,value)
+ elseif value == "png" or value == "bitmap" then
+ return initializepng(tfmdata,kind,value)
+ else
+ -- forget about it
+ end
+ end
+
+ otfregister {
+ name = "color",
+ description = "color glyphs",
+ manipulators = {
+ base = initializecolor,
+ node = initializecolor,
+ }
+ }
+
+end
+
+-- Old stuff:
+
+do
+
+ local startactualtext = nil
+ local stopactualtext = nil
+
+ function otf.getactualtext(s)
+ if not startactualtext then
+ startactualtext = backends.codeinjections.startunicodetoactualtextdirect
+ stopactualtext = backends.codeinjections.stopunicodetoactualtextdirect
+ end
+ return startactualtext(s), stopactualtext()
+ end
+
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ogr.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ogr.lua
deleted file mode 100644
index 94cf9149401..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ogr.lua
+++ /dev/null
@@ -1,672 +0,0 @@
-if not modules then modules = { } end modules ['font-ogr'] = {
- version = 1.001,
- comment = "companion to font-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- Here we deal with graphic variants and for now also color support ends up here
--- but that might change. It's lmtx only code.
-
-if not context then
- return
-elseif CONTEXTLMTXMODE == 0 then
- return
-end
-
-local tostring, tonumber, next, type = tostring, tonumber, next, type
-local round, max, mod, div = math.round, math.max, math.mod, math.div
-local find = string.find
-local concat, setmetatableindex, sortedhash = table.concat, table.setmetatableindex, table.sortedhash
-local utfbyte = utf.byte
-local formatters = string.formatters
-local settings_to_hash_strict, settings_to_array = utilities.parsers.settings_to_hash_strict, utilities.parsers.settings_to_array
-
-local otf = fonts.handlers.otf
-local otfregister = otf.features.register
-otf.svgenabled = true
-otf.pngenabled = true
-
--- Just to remind me ... rewritten around the time this was posted on YT which
--- was also around the 2019 ctx meeting:
---
--- Gavin Harrison - "Threatening War" by The Pineapple Thief
--- https://www.youtube.com/watch?v=ENF9wth4kwM
-
--- todo: svg color plugin
--- todo: get rid of double cm in svg (tricky as also elsewhere)
--- todo: png offsets (depth)
--- todo: maybe collapse indices so that we have less files (harder to debug)
--- todo: manage (read: assign) font id's in lua so we know in advance
-
--- what here and what in backend ...
-
-do
-
- -- This is a prelude to something better but I'm still experimenting.
-
- local dropins = { }
- fonts.dropins = dropins
- local droppedin = 0
- local identifiers = fonts.hashes.identifiers
-
- function dropins.nextid()
- droppedin = droppedin - 1
- return droppedin
- end
-
- -- todo: pass specification table instead
-
- function dropins.provide(method,t_tfmdata,indexdata,...)
- local droppedin = dropins.nextid()
- local t_characters = t_tfmdata.characters
- local t_descriptions = t_tfmdata.descriptions
- local t_properties = t_tfmdata.properties
- local d_tfmdata = setmetatableindex({ },t_tfmdata)
- local d_properties = setmetatableindex({ },t_properties)
- d_tfmdata.properties = d_properties
- local d_characters = { } -- setmetatableindex({ },t_characters) -- hm, index vs unicode
- local d_descriptions = { } -- setmetatableindex({ },t_descriptions) -- hm, index vs unicode
- d_tfmdata.characters = d_characters
- d_tfmdata.descriptions = d_descriptions
- d_properties.instance = - droppedin -- will become an extra element in the hash
- t_properties.virtualized = true
- identifiers[droppedin] = d_tfmdata
- local fonts = t_tfmdata.fonts or { }
- t_tfmdata.fonts = fonts
- d_properties.format = "type3"
- d_properties.method = method
- d_properties.indexdata = { indexdata, ... } -- can take quite some memory
- local slot = #fonts + 1
- fonts[slot] = { id = droppedin }
- return slot, droppedin, d_tfmdata, d_properties
- end
-
- -- todo: delay this, in which case we can be leaner and meaner
-
- function dropins.clone(method,tfmdata,shapes,...) -- by index
- if method and shapes then
- local characters = tfmdata.characters
- local descriptions = tfmdata.descriptions
- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
- local idx = 255
- local slot = 0
- for k, v in next, characters do
- local index = v.index
- if index then
- local description = descriptions[k]
- if description then
- local shape = shapes[index]
- if shape then
- if idx >= 255 then
- idx = 1
- colrshapes = setmetatableindex({ },shapes)
- slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
- dropchars = tfmdrop.characters
- dropdescs = tfmdrop.descriptions
- else
- idx = idx + 1
- end
- colrshapes[idx] = shape -- so not: description
- -- todo: prepend
- v.commands = { { "slot", slot, idx } }
- -- hack to prevent that type 3 also gets 'use' flags .. todo
- local c = { commands = false, index = idx, dropin = tfmdrop }
- local d = { } -- { index = idx, dropin = tfmdrop }
- setmetatableindex(c,v)
- setmetatableindex(d,description)
- dropchars[idx] = c
- dropdescs[idx] = d -- not needed
- end
- end
- end
- end
- else
- -- error
- end
- end
-
- function dropins.swap(method,tfmdata,shapes,...) -- by unicode
- if method and shapes then
- local characters = tfmdata.characters
- local descriptions = tfmdata.descriptions
- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
- local idx = 255
- local slot = 0
- -- we can have a variant where shaped are by unicode and not by index
- for k, v in next, characters do
- local description = descriptions[k]
- if description then
- local shape = shapes[k]
- if shape then
- if idx >= 255 then
- idx = 1
- colrshapes = setmetatableindex({ },shapes)
- slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
- dropchars = tfmdrop.characters
- dropdescs = tfmdrop.descriptions
- else
- idx = idx + 1
- end
- colrshapes[idx] = shape -- so not: description
- -- todo: prepend
- v.commands = { { "slot", slot, idx } }
- -- hack to prevent that type 3 also gets 'use' flags .. todo
- local c = { commands = false, index = idx, dropin = tfmdrop }
- local d = { } -- index = idx, dropin = tfmdrop }
- setmetatableindex(c,v)
- setmetatableindex(d,description)
- dropchars[idx] = c
- dropdescs[idx] = d -- not needed
- end
- end
- end
- else
- -- error
- end
- end
-
-end
-
-do -- this will move to its own module
-
- local dropins = fonts.dropins
-
- local shapes = setmetatableindex(function(t,k)
- local v = {
- glyphs = { },
- parameters = {
- units = 1000
- },
- }
- t[k] = v
- return v
- end)
-
- function dropins.registerglyphs(parameters)
- local category = parameters.name
- local target = shapes[category].parameters
- for k, v in next, parameters do
- if k ~= "glyphs" then
- target[k] = v
- end
- end
- end
-
- function dropins.registerglyph(parameters)
- local category = parameters.category
- local unicode = parameters.unicode
- local private = parameters.private
- local unichar = parameters.unichar
- if private then
- unicode = fonts.helpers.newprivateslot(private)
- elseif type(unichar) == "string" then
- unicode = utfbyte(unichar)
- else
- local unitype = type(unicode)
- if unitype == "string" then
- local uninumber = tonumber(unicode)
- if uninumber then
- unicode = round(uninumber)
- else
- unicode = utfbyte(unicode)
- end
- elseif unitype == "number" then
- unicode = round(unicode)
- end
- end
- if unicode then
- parameters.unicode = unicode
- -- print(category,unicode)
- shapes[category].glyphs[unicode] = parameters
- else
- -- error
- end
- end
-
- -- local function hascolorspec(t)
- -- if (t.color or "") ~= "" then
- -- return true
- -- elseif (t.fillcolor or "") ~= "" then
- -- return true
- -- elseif (t.drawcolor or "") ~= "" then
- -- return true
- -- elseif (t.linecolor or "") ~= "" then
- -- return true
- -- else
- -- return false
- -- end
- -- end
-
- local function hascolorspec(t)
- for k, v in next, t do
- if find(k,"color") then
- return true
- end
- end
- return false
- end
-
- local function initializemps(tfmdata,kind,value)
- if value then
- local specification = settings_to_hash_strict(value)
- if not specification or not next(specification) then
- specification = { category = value }
- end
- -- todo: multiple categories but then maybe also different
- -- clones because of the units .. for now we assume the same
- -- units
- local category = specification.category
- if category and category ~= "" then
- local categories = settings_to_array(category)
- local usedshapes = nil
- local index = 0
- local spread = tonumber(specification.spread or 0)
- local hascolor = hascolorspec(specification)
- specification.spread = spread -- now a number
- for i=1,#categories do
- local category = categories[i]
- local mpsshapes = shapes[category]
- if mpsshapes then
- local properties = tfmdata.properties
- local parameters = tfmdata.parameters
- local characters = tfmdata.characters
- local descriptions = tfmdata.descriptions
- local mpsparameters = mpsshapes.parameters
- local units = mpsparameters.units or 1000
- local defaultwidth = mpsparameters.width or 0
- local defaultheight = mpsparameters.height or 0
- local defaultdepth = mpsparameters.depth or 0
- local usecolor = mpsparameters.usecolor
- local spread = spread * units
- local defaultcode = mpsparameters.code or ""
- local scale = parameters.size / units
- if hascolor then
- -- the graphic has color
- usecolor = false
- else
- -- do whatever is specified
- end
- usedshapes = usedshapes or {
- instance = "simplefun",
- units = units,
- usecolor = usecolor,
- specification = specification,
- shapes = mpsshapes,
- }
- -- todo: deal with extensibles and more properties
- for unicode, shape in sortedhash(mpsshapes.glyphs) do
- -- local oldc = characters[unicode]
- -- if oldc then
- index = index + 1 -- todo: somehow we end up with 2 as first entry after 0
- local wd = shape.width or defaultwidth
- local ht = shape.height or defaultheight
- local dp = shape.depth or defaultdepth
- local newc = {
- index = index, -- into usedshapes
- width = scale * (wd + spread),
- height = scale * ht,
- depth = scale * dp,
- unicode = unicode,
- }
- --
- characters [unicode] = newc
- descriptions[unicode] = newc
- --
- usedshapes[unicode] = shape.code or defaultcode
- -- end
- end
- end
- end
- if usedshapes then
- -- todo: different font when units and usecolor changes, maybe move into loop
- -- above
- dropins.swap("mps",tfmdata,usedshapes)
- end
- end
- end
- end
-
- -- This kicks in quite late, after features have been checked. So if needed
- -- substitutions need to be defined with force.
-
- otfregister {
- name = "metapost",
- description = "metapost glyphs",
- manipulators = {
- base = initializemps,
- node = initializemps,
- }
- }
-
-end
-
--- This sits here for historcal reasons so for now we keep it here.
-
-local startactualtext = nil
-local stopactualtext = nil
-
-function otf.getactualtext(s)
- if not startactualtext then
- startactualtext = backends.codeinjections.startunicodetoactualtextdirect
- stopactualtext = backends.codeinjections.stopunicodetoactualtextdirect
- end
- return startactualtext(s), stopactualtext()
-end
-
--- This is also somewhat specific.
-
-local sharedpalettes do
-
- sharedpalettes = { }
-
- local colors = attributes.list[attributes.private('color')] or { }
- local transparencies = attributes.list[attributes.private('transparency')] or { }
-
- function otf.registerpalette(name,values)
- sharedpalettes[name] = values
- local color = lpdf.color
- local transparency = lpdf.transparency
- local register = colors.register
- for i=1,#values do
- local v = values[i]
- if v == "textcolor" then
- values[i] = false
- else
- local c = nil
- local t = nil
- if type(v) == "table" then
- c = register(name,"rgb",
- max(round((v.r or 0)*255),255)/255,
- max(round((v.g or 0)*255),255)/255,
- max(round((v.b or 0)*255),255)/255
- )
- else
- c = colors[v]
- t = transparencies[v]
- end
- if c and t then
- values[i] = color(1,c) .. " " .. transparency(t)
- elseif c then
- values[i] = color(1,c)
- elseif t then
- values[i] = color(1,t)
- end
- end
- end
- end
-
-end
-
-local initializeoverlay do
-
- -- we should use the proper interface instead but for now:
-
- local colors = attributes.colors
- local rgbtocmyk = colors.rgbtocmyk
-
- local f_cmyk = formatters["%.3N %.3f %.3N %.3N k"]
- local f_rgb = formatters["%.3N %.3f %.3N rg"]
- local f_gray = formatters["%.3N g"]
-
- local function convert(t,k)
- local v = { }
- local m = colors.model
- for i=1,#k do
- local p = k[i]
- local r, g, b = p[1]/255, p[2]/255, p[3]/255
- if r == g and g == b then
- p = f_gray(r)
- elseif m == "cmyk" then
- p = f_cmyk(rgbtocmyk(r,g,b))
- else
- p = f_rgb(r,g,b)
- end
- v[i] = p
- end
- t[k] = v
- return v
- end
-
- initializeoverlay = function(tfmdata,kind,value) -- we really need the id ... todo
- if value then
- local resources = tfmdata.resources
- local palettes = resources.colorpalettes
- if palettes then
- --
- local converted = resources.converted
- if not converted then
- converted = setmetatableindex(convert)
- resources.converted = converted
- end
- local colorvalues = sharedpalettes[value]
- local default = false -- so the text color (bad for icon overloads)
- if colorvalues then
- default = colorvalues[#colorvalues]
- else
- colorvalues = converted[palettes[tonumber(value) or 1] or palettes[1]] or { }
- end
- local classes = #colorvalues
- if classes == 0 then
- return
- end
- --
- local characters = tfmdata.characters
- local descriptions = tfmdata.descriptions
- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
- local idx = 255
- local slot = 0
- --
- -- maybe delay in which case we have less fonts as we can be sparse
- --
- for k, v in next, characters do
- local index = v.index
- if index then
- local description = descriptions[k]
- if description then
- local colorlist = description.colors
- if colorlist then
- if idx >= 255 then
- idx = 1
- colrshapes = { }
- slot, droppedin, tfmdrop = fonts.dropins.provide("color",tfmdata,colrshapes,colorvalues)
- dropchars = tfmdrop.characters
- dropdescs = tfmdrop.descriptions
- else
- idx = idx + 1
- end
- --
- colrshapes[idx] = description
- -- todo: use extender
- local u = { "use", 0 }
- for i=1,#colorlist do
- u[i+2] = colorlist[i].slot
- end
- v.commands = { u, { "slot", slot, idx } }
- -- hack to prevent that type 3 also gets 'use' flags .. todo
- local c = { commands = false, index = idx, dropin = tfmdata }
- local d = { } -- index = idx, dropin = tfmdrop
- setmetatableindex(c,v)
- setmetatableindex(d,description)
- dropchars[idx] = c
- dropdescs[idx] = d -- not needed
- end
- end
- end
- end
- return true
- end
- end
- end
-
- fonts.handlers.otf.features.register {
- name = "colr",
- description = "color glyphs",
- manipulators = {
- base = initializeoverlay,
- node = initializeoverlay,
- }
- }
-
-end
-
-local initializesvg do
-
- local report_svg = logs.reporter("fonts","svg")
-
- local cached = true -- maybe always false (after i've optimized the lot)
-
- directives.register("fonts.svg.cached", function(v) cached = v end)
-
- initializesvg = function(tfmdata,kind,value) -- hm, always value
- if value then
- local properties = tfmdata.properties
- local svg = properties.svg
- local hash = svg and svg.hash
- local timestamp = svg and svg.timestamp
- if not hash then
- return
- end
- local shapes = nil
- local method = nil
- local enforce = attributes.colors.model == "cmyk"
- if cached and not enforce then
- -- we need a different hash than for mkiv, so we append:
- local pdfhash = hash .. "-svg"
- local pdffile = containers.read(otf.pdfcache,pdfhash)
- local pdfshapes = pdffile and pdffile.pdfshapes
- local pdftarget = file.join(otf.pdfcache.writable,file.addsuffix(pdfhash,"pdf"))
- if not pdfshapes or pdffile.timestamp ~= timestamp or not next(pdfshapes) or not lfs.isfile(pdftarget) then
- local svgfile = containers.read(otf.svgcache,hash)
- local svgshapes = svgfile and svgfile.svgshapes
- pdfshapes = svgshapes and metapost.svgshapestopdf(svgshapes,pdftarget,report_svg,tfmdata.parameters.units) or { }
- -- look at ocl: we should store scale and x and y
- containers.write(otf.pdfcache, pdfhash, {
- pdfshapes = pdfshapes,
- timestamp = timestamp,
- })
- end
- shapes = pdfshapes
- method = "pdf"
- else
- local mpsfile = containers.read(otf.mpscache,hash)
- local mpsshapes = mpsfile and mpsfile.mpsshapes
- if not mpsshapes or mpsfile.timestamp ~= timestamp or not next(mpsshapes) then
- local svgfile = containers.read(otf.svgcache,hash)
- local svgshapes = svgfile and svgfile.svgshapes
- -- still suboptimal
- mpsshapes = svgshapes and metapost.svgshapestomp(svgshapes,report_svg,tfmdata.parameters.units) or { }
- if enforce then
- -- cheap conversion, no black component generation
- mpsshapes.preamble = "interim svgforcecmyk := 1;"
- end
- containers.write(otf.mpscache, hash, {
- mpsshapes = mpsshapes,
- timestamp = timestamp,
- })
- end
- shapes = mpsshapes
- method = "mps"
- end
- if shapes then
- shapes.fixdepth = value == "fixdepth"
- fonts.dropins.clone(method,tfmdata,shapes)
- end
- return true
- end
- end
-
- otfregister {
- name = "svg",
- description = "svg glyphs",
- manipulators = {
- base = initializesvg,
- node = initializesvg,
- }
- }
-
-end
-
-local initializepng do
-
- -- If this is really critical we can also use a pdf file as cache but I don't expect
- -- png fonts to remain used.
-
- local colors = attributes.colors
-
- local report_png = logs.reporter("fonts","png conversion")
-
- initializepng = function(tfmdata,kind,value) -- hm, always value
- if value then
- local properties = tfmdata.properties
- local png = properties.png
- local hash = png and png.hash
- local timestamp = png and png.timestamp
- if not hash then
- return
- end
- local pngfile = containers.read(otf.pngcache,hash)
- local pngshapes = pngfile and pngfile.pngshapes
- if pngshapes then
- if colors.model == "cmyk" then
- pngshapes.enforcecmyk = true
- end
- fonts.dropins.clone("png",tfmdata,pngshapes)
- end
- return true
- end
- end
-
- otfregister {
- name = "sbix",
- description = "sbix glyphs",
- manipulators = {
- base = initializepng,
- node = initializepng,
- }
- }
-
- otfregister {
- name = "cblc",
- description = "cblc glyphs",
- manipulators = {
- base = initializepng,
- node = initializepng,
- }
- }
-
-end
-
-do
-
- -- I need to check jpeg and such but will do that when I run into
- -- it.
-
- local function initializecolor(tfmdata,kind,value)
- if value == "auto" then
- return
- initializeoverlay(tfmdata,kind,value) or
- initializesvg(tfmdata,kind,value) or
- initializepng(tfmdata,kind,value)
- elseif value == "overlay" then
- return initializeoverlay(tfmdata,kind,value)
- elseif value == "svg" then
- return initializesvg(tfmdata,kind,value)
- elseif value == "png" or value == "bitmap" then
- return initializepng(tfmdata,kind,value)
- else
- -- forget about it
- end
- end
-
- otfregister {
- name = "color",
- description = "color glyphs",
- manipulators = {
- base = initializecolor,
- node = initializecolor,
- }
- }
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-one.lua b/Master/texmf-dist/tex/context/base/mkiv/font-one.lua
index 5387516b4d5..829f52ea043 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-one.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-one.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-one'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -591,15 +592,18 @@ local function copytotfm(data)
parameters.descender = abs(metadata.descender or 0)
parameters.units = 1000
--
- properties.spacer = spacer
+ properties.spacer = spacer
+ properties.format = fonts.formats[filename] or "type1"
+ properties.filename = filename
+ properties.fontname = fontname
+ properties.fullname = fullname
+ properties.psname = fullname
+ properties.name = filename or fullname or fontname
+ properties.private = properties.private or data.private or privateoffset
+ --
+if not CONTEXTLMTXMODE or CONTEXTLMTXMODE == 0 then
properties.encodingbytes = 2
- properties.format = fonts.formats[filename] or "type1"
- properties.filename = filename
- properties.fontname = fontname
- properties.fullname = fullname
- properties.psname = fullname
- properties.name = filename or fullname or fontname
- properties.private = properties.private or data.private or privateoffset
+end
--
if next(characters) then
return {
@@ -723,6 +727,7 @@ local function read_from_afm(specification)
local tfmdata = afmtotfm(specification)
if tfmdata then
tfmdata.properties.name = specification.name
+ tfmdata.properties.id = specification.id
tfmdata = constructors.scale(tfmdata, specification)
local allfeatures = tfmdata.shared.features or specification.features.normal
constructors.applymanipulators("afm",tfmdata,allfeatures,trace_features,report_afm)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-onr.lua b/Master/texmf-dist/tex/context/base/mkiv/font-onr.lua
index fc6bead5889..c33b09f9e2a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-onr.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-onr.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-onr'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ota.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ota.lua
index 6cbf4bb86fe..ce1b22b50d7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ota.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ota.lua
@@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['font-ota'] = {
-- context only
local type = type
+local setmetatableindex = table.setmetatableindex
if not trackers then trackers = { register = function() end } end
@@ -285,7 +286,7 @@ if not classifiers then
local f_nko, l_nko = characters.blockrange("nko")
local f_ext_a, l_ext_a = characters.blockrange("arabicextendeda")
- classifiers = table.setmetatableindex(function(t,k)
+ classifiers = setmetatableindex(function(t,k)
if type(k) == "number" then
local c = chardata[k]
local v = false
@@ -461,6 +462,119 @@ methods.syrc = methods.arab
methods.mand = methods.arab
methods.nko = methods.arab
+-- a quick first attemp .. more later
+
+do
+
+ -- https://github.com/n8willis/opentype-shaping-documents/blob/master/opentype-shaping-mongolian.md#joining-properties
+ -- todo syrc
+
+ local joining = setmetatableindex(function(t,k)
+ if type(k) == "number" then
+ local c = chardata[k]
+ local v = false
+ if c then
+ local mongolian = c.mongolian
+ --
+ v = mongolian
+ end
+ t[k] = v
+ return v
+ end
+ end)
+
+ function methods.mong(head,font,attr)
+ local first, last
+ local current = head
+ local done = false
+ local prevjoin = nil
+ local prestate = nil
+ current = tonut(current)
+
+ local function wrapup()
+ if last then
+ if last ~= first then
+ local s = getstate(last)
+ if s == s_medi then
+ setstate(last,s_fina)
+ elseif s == s_init then
+ setstate(last,s_isol)
+ end
+ end
+ last = nil
+ first = nil
+ prevjoin = nil
+ prestate = nil
+ end
+ end
+
+ while current do
+ local char, id = ischar(current,font)
+ if char and not getstate(current) then
+ local currjoin = joining[char]
+ done = true
+ if not last then
+ setstate(current,s_isol)
+ prevjoin = currjoin
+ first = current
+ last = current
+ prevstate = s_isol
+ elseif currjoin == "t" then -- transparent
+ -- keep state
+ last = current
+ elseif prevjoin == "d" or prevjoin == "jc" or prevjoin == "l" then
+ if currjoin == "d" or prevjoin == "jc" or prevjoin == "r" then
+ local s = getstate(last)
+ if s == s_isol then
+ setstate(last,s_init)
+ elseif s == s_fina then
+ setstate(last,s_medi)
+ end
+ setstate(current,s_fina)
+ prevstate = s_fina
+ elseif prevjoin == "nj" or prevjoin == "l" then
+ local s = getstate(last)
+ if s == s_medi then
+ setstate(last,s_fina)
+ elseif s == s_init then
+ setstate(last,s_isol)
+ end
+ setstate(current,s_isol)
+ prevstate = s_isol
+ end
+ prevjoin = currjoin
+ last = current
+ elseif prevjoin == "nj" or prevjoin == "r" then
+ if s == s_medi then
+ setstate(last,s_fina)
+ elseif s == s_init then
+ setstate(last,s_isol)
+ end
+ setstate(current,s_isol)
+ prevjoin = currjoin
+ prevstate = s_isol
+ last = current
+ elseif last then
+ wrapup()
+ end
+ else
+ if last then
+ wrapup()
+ end
+ if id == math_code then -- a bit duplicate as we test for glyphs twice
+ current = end_of_math(current)
+ end
+ end
+ current = getnext(current)
+ end
+ if last then
+ wrapup()
+ end
+ return head, done
+ end
+
+end
+
directives.register("otf.analyze.useunicodemarks",function(v)
analyzers.useunicodemarks = v
end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otd.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otd.lua
index 2633c6caec5..3f1b212dbb3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-otd.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-otd.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-otd'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
index 2e7878d3dfd..bb02044dca6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-otj'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -110,7 +111,7 @@ local properties = nodes.properties.data
local fontkern = nuts.pool and nuts.pool.fontkern -- context
local italickern = nuts.pool and nuts.pool.italickern -- context
-local useitalickerns = false
+local useitalickerns = false -- context only
directives.register("fonts.injections.useitalics", function(v)
if v then
@@ -119,7 +120,7 @@ directives.register("fonts.injections.useitalics", function(v)
useitalickerns = v
end)
-do if not fontkern then -- generic
+if not fontkern then -- generic
local thekern = nuts.new("kern",0) -- fontkern
local setkern = nuts.setkern
@@ -131,9 +132,9 @@ do if not fontkern then -- generic
return n
end
-end end
+end
-do if not italickern then -- generic
+if not italickern then -- generic
local thekern = nuts.new("kern",3) -- italiccorrection
local setkern = nuts.setkern
@@ -145,7 +146,7 @@ do if not italickern then -- generic
return n
end
-end end
+end
function injections.installnewkern() end -- obsolete
@@ -664,7 +665,15 @@ local function inject_kerns_only(head,where)
-- left|glyph|right
local leftkern = i.leftkern
if leftkern and leftkern ~= 0 then
- head = insert_node_before(head,current,fontkern(leftkern))
+ if prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
+ else
+ head = insert_node_before(head,current,fontkern(leftkern))
+ end
end
end
if prevdisc then
@@ -819,12 +828,26 @@ local function inject_positions_only(head,where)
if rightkern and leftkern == -rightkern then
setoffsets(current,leftkern,false)
rightkern = 0
+ elseif prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
else
head = insert_node_before(head,current,fontkern(leftkern))
end
end
if rightkern and rightkern ~= 0 then
- insert_node_after(head,current,fontkern(rightkern))
+ if next and getid(next) == glue_code then
+ if useitalickerns then
+ insert_node_after(head,current,italickern(rightkern))
+ else
+ setwidth(next, getwidth(next) + rightkern)
+ end
+ else
+ insert_node_after(head,current,fontkern(rightkern))
+ end
end
else
local i = p.emptyinjections
@@ -1270,12 +1293,26 @@ local function inject_everything(head,where)
if rightkern and leftkern == -rightkern then
setoffsets(current,leftkern,false)
rightkern = 0
+ elseif prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
else
head = insert_node_before(head,current,fontkern(leftkern))
end
end
if rightkern and rightkern ~= 0 then
- insert_node_after(head,current,fontkern(rightkern))
+ if next and getid(next) == glue_code then
+ if useitalickerns then
+ insert_node_after(head,current,italickern(rightkern))
+ else
+ setwidth(next, getwidth(next) + rightkern)
+ end
+ else
+ insert_node_after(head,current,fontkern(rightkern))
+ end
end
end
else
@@ -1518,7 +1555,7 @@ local function inject_everything(head,where)
end
--
if keepregisteredcounts then
- keepregisteredcounts = false
+ keepregisteredcounts = false
else
nofregisteredkerns = 0
nofregisteredpositions = 0
@@ -1707,16 +1744,18 @@ local function injectspaces(head)
if useitalickerns then
local new = rightkern * factor
if trace_spaces then
- report_spaces("%C [%p + %p]",nextchar,old,new)
+ report_spaces("[%p + %p] %C",old,new,nextchar)
end
insert_node_after(head,n,italickern(new))
else
local new = old + rightkern * factor
if trace_spaces then
- report_spaces("[%p -> %p] %C",nextchar,old,new)
+ report_spaces("[%p -> %p] %C",old,new,nextchar)
end
setwidth(n,new)
end
+ else
+ -- message
end
rightkern = false
end
@@ -1753,3 +1792,4 @@ function injections.handler(head,where)
return head
end
end
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otl.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otl.lua
index aff4cc8c8d9..8159db180d6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-otl.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-otl.lua
@@ -52,7 +52,7 @@ local report_otf = logs.reporter("fonts","otf loading")
local fonts = fonts
local otf = fonts.handlers.otf
-otf.version = 3.111 -- beware: also sync font-mis.lua and in mtx-fonts
+otf.version = 3.113 -- beware: also sync font-mis.lua and in mtx-fonts
otf.cache = containers.define("fonts", "otl", otf.version, true)
otf.svgcache = containers.define("fonts", "svg", otf.version, true)
otf.pngcache = containers.define("fonts", "png", otf.version, true)
@@ -486,23 +486,26 @@ local function copytotfm(data,cache_id)
end
end
--
- parameters.designsize = (designsize/10)*65536
- parameters.minsize = (minsize /10)*65536
- parameters.maxsize = (maxsize /10)*65536
- parameters.ascender = abs(metadata.ascender or 0)
- parameters.descender = abs(metadata.descender or 0)
- parameters.units = units
- parameters.vheight = metadata.defaultvheight
+ parameters.designsize = (designsize/10)*65536
+ parameters.minsize = (minsize /10)*65536
+ parameters.maxsize = (maxsize /10)*65536
+ parameters.ascender = abs(metadata.ascender or 0)
+ parameters.descender = abs(metadata.descender or 0)
+ parameters.units = units
+ parameters.vheight = metadata.defaultvheight
--
- properties.space = spacer
+ properties.space = spacer
+ properties.format = data.format or formats.otf
+ properties.filename = filename
+ properties.fontname = fontname
+ properties.fullname = fullname
+ properties.psname = psname
+ properties.name = filename or fullname
+ properties.subfont = subfont
+ --
+if not CONTEXTLMTXMODE or CONTEXTLMTXMODE == 0 then
properties.encodingbytes = 2
- properties.format = data.format or formats.otf
- properties.filename = filename
- properties.fontname = fontname
- properties.fullname = fullname
- properties.psname = psname
- properties.name = filename or fullname
- properties.subfont = subfont
+end
--
-- properties.name = specification.name
-- properties.sub = specification.sub
@@ -605,6 +608,7 @@ local function read_from_otf(specification)
-- this late ? .. needs checking
tfmdata.properties.name = specification.name
tfmdata.properties.sub = specification.sub
+ tfmdata.properties.id = specification.id
--
tfmdata = constructors.scale(tfmdata,specification)
local allfeatures = tfmdata.shared.features or specification.features.normal
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua
index e726053202f..531f665de72 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-otr'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -2084,8 +2085,6 @@ local function readtable(tag,f,fontdata,specification,...)
end
end
-local variablefonts_supported = (context and true) or (logs and logs.application and true) or false
-
local function readdata(f,offset,specification)
local fontdata, tables = loadtables(f,specification,offset)
@@ -2094,12 +2093,6 @@ local function readdata(f,offset,specification)
prepareglyps(fontdata)
end
- if not variablefonts_supported then
- specification.instance = nil
- specification.variable = nil
- specification.factors = nil
- end
-
fontdata.temporary = { }
readtable("name",f,fontdata,specification)
@@ -2118,71 +2111,66 @@ local function readdata(f,offset,specification)
readtable("avar",f,fontdata,specification)
readtable("fvar",f,fontdata,specification)
- if variablefonts_supported then
-
- local variabledata = fontdata.variabledata
-
- if variabledata then
- local instances = variabledata.instances
- local axis = variabledata.axis
- if axis and (not instances or #instances == 0) then
- instances = { }
- variabledata.instances = instances
- local function add(n,subfamily,value)
- local values = { }
- for i=1,#axis do
- local a = axis[i]
- values[i] = {
- axis = a.tag,
- value = i == n and value or a.default,
- }
- end
- instances[#instances+1] = {
- subfamily = subfamily,
- values = values,
- }
- end
+ local variabledata = fontdata.variabledata
+
+ if variabledata then
+ local instances = variabledata.instances
+ local axis = variabledata.axis
+ if axis and (not instances or #instances == 0) then
+ instances = { }
+ variabledata.instances = instances
+ local function add(n,subfamily,value)
+ local values = { }
for i=1,#axis do
- local a = axis[i]
- local tag = a.tag
- add(i,"default"..tag,a.default)
- add(i,"minimum"..tag,a.minimum)
- add(i,"maximum"..tag,a.maximum)
+ local a = axis[i]
+ values[i] = {
+ axis = a.tag,
+ value = i == n and value or a.default,
+ }
end
- -- report("%i fake instances added",#instances)
+ instances[#instances+1] = {
+ subfamily = subfamily,
+ values = values,
+ }
end
- end
-
- if not specification.factors then
- local instance = specification.instance
- if type(instance) == "string" then
- local factors = helpers.getfactors(fontdata,instance)
- if factors then
- specification.factors = factors
- fontdata.factors = factors
- fontdata.instance = instance
- report("user instance: %s, factors: % t",instance,factors)
- else
- report("user instance: %s, bad factors",instance)
- end
+ for i=1,#axis do
+ local a = axis[i]
+ local tag = a.tag
+ add(i,"default"..tag,a.default)
+ add(i,"minimum"..tag,a.minimum)
+ add(i,"maximum"..tag,a.maximum)
end
+ -- report("%i fake instances added",#instances)
end
-
- if not fontdata.factors then
- if fontdata.variabledata then
- local factors = helpers.getfactors(fontdata,true)
- if factors then
- specification.factors = factors
- fontdata.factors = factors
- -- report("factors: % t",factors)
- -- else
- -- report("bad factors")
- end
+ end
+ if not specification.factors then
+ local instance = specification.instance
+ if type(instance) == "string" then
+ local factors = helpers.getfactors(fontdata,instance)
+ if factors then
+ specification.factors = factors
+ fontdata.factors = factors
+ fontdata.instance = instance
+ report("user instance: %s, factors: % t",instance,factors)
else
- -- report("unknown instance")
+ report("user instance: %s, bad factors",instance)
end
end
+ end
+ if not fontdata.factors then
+ if fontdata.variabledata then
+ local factors = helpers.getfactors(fontdata,true)
+ if factors then
+ specification.factors = factors
+ fontdata.factors = factors
+ -- report("factors: % t",factors)
+ -- else
+ -- report("bad factors")
+ end
+ else
+ -- report("unknown instance")
+ end
end
readtable("os/2",f,fontdata,specification)
@@ -2433,6 +2421,7 @@ function readers.loadfont(filename,n,instance)
hascolor = fontdata.hascolor or false,
instance = fontdata.instance,
factors = fontdata.factors,
+ nofsubfonts = fontdata.subfonts and #fontdata.subfonts or nil,
},
resources = {
-- filename = fontdata.filename,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua
index f20a349eeb2..880bcb6d50a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-ots'] = { -- sequences
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -12,7 +13,7 @@ with plain it has to be so. This module is part of
and discussion about improvements and functionality mostly happens on the
mailing list.
-
The specification of OpenType is (or at least a decade ago was) kind of vague.
+
The specification of OpenType is (or at least decades ago was) kind of vague.
Apart from a lack of a proper free specifications there's also the problem that
Microsoft and Adobe may have their own interpretation of how and in what order to
apply features. In general the Microsoft website has more detailed specifications
@@ -25,7 +26,7 @@ effect that suddenly fonts behave differently. We don't want to catch all font
issues.
After a lot of experiments (mostly by Taco, me and Idris) the first implementation
-becaus quite useful. When it did most of what we wanted, a more optimized version
+was already quite useful. When it did most of what we wanted, a more optimized version
evolved. Of course all errors are mine and of course the code can be improved. There
are quite some optimizations going on here and processing speed is currently quite
acceptable and has been improved over time. Many complex scripts are not yet supported
@@ -217,6 +218,7 @@ local copy_only_glyphs = nuts.copy_only_glyphs
local count_components = nuts.count_components
local set_components = nuts.set_components
local get_components = nuts.get_components
+local flush_components = nuts.flush_components
---------------------------------------------------------------------------------------
@@ -250,7 +252,10 @@ local glue_code = nodecodes.glue
local disc_code = nodecodes.disc
local math_code = nodecodes.math
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
+
+local lefttoright_code = nodes.dirvalues.lefttoright
+local righttoleft_code = nodes.dirvalues.righttoleft
local discretionarydisc_code = disccodes.discretionary
local ligatureglyph_code = glyphcodes.ligature
@@ -484,6 +489,7 @@ local function markstoligature(head,start,stop,char)
setsubtype(base,ligatureglyph_code)
set_components(base,start)
setlink(prev,base,next)
+ flush_components(start)
return head, base
end
end
@@ -496,9 +502,25 @@ end
-- in the not discfound branch then. We now have skiphash too so we can be more
-- selective if needed (todo).
+-- we can have more granularity here but for now we only do a simple check
+
+local no_left_ligature_code = 1
+local no_right_ligature_code = 2
+local no_left_kern_code = 4
+local no_right_kern_code = 8
+
+local has_glyph_option = node.direct.has_glyph_option or function(n,c)
+ if c == no_left_ligature_code or c == no_right_ligature_code then
+ return getattr(n,a_noligature) == 1
+ else
+ return false
+ end
+end
+
+-- in lmtx we need to check the components and can be slightly more clever
+
local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfound,hasmarks) -- brr head
- if getattr(start,a_noligature) == 1 then
- -- so we can do: e\noligature{ff}e e\noligature{f}fie (we only look at the first)
+ if has_glyph_option(start,no_right_ligature_code) then
return head, start
end
if start == stop and getchar(start) == char then
@@ -533,19 +555,19 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
if not marks[char] then
baseindex = baseindex + componentindex
componentindex = count_components(start,marks)
- -- we can be more clever here: "not deletemarks or (skiphash and not skiphash[char])"
- -- and such:
+ -- we can be more clever here: "not deletemarks or (skiphash and not skiphash[char])"
+ -- and such:
elseif not deletemarks then
-- we can get a loop when the font expects otherwise (i.e. unexpected deletemarks)
setligaindex(start,baseindex + getligaindex(start,componentindex))
if trace_marks then
- logwarning("%s: keep mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start))
+ logwarning("%s: keep ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start))
end
local n = copy_node(start)
copyinjection(n,start) -- is this ok ? we position later anyway
head, current = insert_node_after(head,current,n) -- unlikely that mark has components
elseif trace_marks then
- logwarning("%s: delete mark %s",pref(dataset,sequence),gref(char))
+ logwarning("%s: delete ligature mark %s",pref(dataset,sequence),gref(char))
end
start = getnext(start)
end
@@ -558,7 +580,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
if marks[char] then
setligaindex(start,baseindex + getligaindex(start,componentindex))
if trace_marks then
- logwarning("%s: set mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start))
+ logwarning("%s: set ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start))
end
start = getnext(start)
else
@@ -568,6 +590,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
break
end
end
+ flush_components(components)
else
-- discfound ... forget about marks .. probably no scripts that hyphenate and have marks
local discprev, discnext = getboth(discfound)
@@ -806,6 +829,9 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
-- of{f-}{}{f}e o{f-}{}{f}fe o{-}{}{ff}e (oe and ff ligature)
-- we can end up here when we have a start run .. testruns start at a disc but
-- so here we have the other case: char + disc
+ --
+ -- Challenge for Kai (latinmodern): \hyphenation{fii-f-f-iif} fiiffiif
+ --
if discfound then
-- don't assume marks in a disc and we don't run over a disc (for now)
local pre, post, replace = getdisc(discfound)
@@ -898,81 +924,89 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
end
function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection)
- local startchar = getchar(start)
- local format = step.format
- if format == "single" or type(kerns) == "table" then -- the table check can go
- local dx, dy, w, h = setposition(0,start,factor,rlmode,kerns,injection)
- if trace_kerns then
- logprocess("%s: shifting single %s by %s xy (%p,%p) and wh (%p,%p)",pref(dataset,sequence),gref(startchar),format,dx,dy,w,h)
- end
+ if has_glyph_option(start,no_right_kern_code) then
+ return head, start, false
else
- local k = (format == "move" and setmove or setkern)(start,factor,rlmode,kerns,injection)
- if trace_kerns then
- logprocess("%s: shifting single %s by %s %p",pref(dataset,sequence),gref(startchar),format,k)
+ local startchar = getchar(start)
+ local format = step.format
+ if format == "single" or type(kerns) == "table" then -- the table check can go
+ local dx, dy, w, h = setposition(0,start,factor,rlmode,kerns,injection)
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s xy (%p,%p) and wh (%p,%p)",pref(dataset,sequence),gref(startchar),format,dx,dy,w,h)
+ end
+ else
+ local k = (format == "move" and setmove or setkern)(start,factor,rlmode,kerns,injection)
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s %p",pref(dataset,sequence),gref(startchar),format,k)
+ end
end
+ return head, start, true
end
- return head, start, true
end
function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection)
- local snext = getnext(start)
- if not snext then
+ if has_glyph_option(start,no_right_kern_code) then
return head, start, false
else
- local prev = start
- while snext do
- local nextchar = ischar(snext,currentfont)
- if nextchar then
- if skiphash and skiphash[nextchar] then -- includes marks too when flag
- prev = snext
- snext = getnext(snext)
- else
- local krn = kerns[nextchar]
- if not krn then
- break
- end
- local format = step.format
- if format == "pair" then
- local a = krn[1]
- local b = krn[2]
- if a == true then
- -- zero
- elseif a then -- #a > 0
- local x, y, w, h = setposition(1,start,factor,rlmode,a,injection)
- if trace_kerns then
- local startchar = getchar(start)
- logprocess("%s: shifting first of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections")
- end
+ local snext = getnext(start)
+ if not snext then
+ return head, start, false
+ else
+ local prev = start
+ while snext do
+ local nextchar = ischar(snext,currentfont)
+ if nextchar then
+ if skiphash and skiphash[nextchar] then -- includes marks too when flag
+ prev = snext
+ snext = getnext(snext)
+ else
+ local krn = kerns[nextchar]
+ if not krn then
+ break
end
- if b == true then
- -- zero
- start = snext -- cf spec
- elseif b then -- #b > 0
- local x, y, w, h = setposition(2,snext,factor,rlmode,b,injection)
+ local format = step.format
+ if format == "pair" then
+ local a = krn[1]
+ local b = krn[2]
+ if a == true then
+ -- zero
+ elseif a then -- #a > 0
+ local x, y, w, h = setposition(1,start,factor,rlmode,a,injection)
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting first of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections")
+ end
+ end
+ if b == true then
+ -- zero
+ start = snext -- cf spec
+ elseif b then -- #b > 0
+ local x, y, w, h = setposition(2,snext,factor,rlmode,b,injection)
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting second of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections")
+ end
+ start = snext -- cf spec
+ elseif forcepairadvance then
+ start = snext -- for testing, not cf spec
+ end
+ return head, start, true
+ elseif krn ~= 0 then
+ local k = (format == "move" and setmove or setkern)(snext,factor,rlmode,krn,injection)
if trace_kerns then
- local startchar = getchar(start)
- logprocess("%s: shifting second of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections")
+ logprocess("%s: inserting %s %p between %s and %s as %s",pref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar),injection or "injections")
end
- start = snext -- cf spec
- elseif forcepairadvance then
- start = snext -- for testing, not cf spec
- end
- return head, start, true
- elseif krn ~= 0 then
- local k = (format == "move" and setmove or setkern)(snext,factor,rlmode,krn,injection)
- if trace_kerns then
- logprocess("%s: inserting %s %p between %s and %s as %s",pref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar),injection or "injections")
+ return head, start, true
+ else -- can't happen
+ break
end
- return head, start, true
- else -- can't happen
- break
end
+ else
+ break
end
- else
- break
end
+ return head, start, false
end
- return head, start, false
end
end
@@ -1501,92 +1535,98 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup
end
function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
- local mapping = currentlookup.mapping
- if mapping == nil then
- mapping = getmapping(dataset,sequence,currentlookup)
- end
- if mapping then
- local startchar = getchar(start)
- local kerns = mapping[startchar]
- if kerns then
- local format = currentlookup.format
- if format == "single" then
- local dx, dy, w, h = setposition(0,start,factor,rlmode,kerns) -- currentlookup.flags ?
- if trace_kerns then
- logprocess("%s: shifting single %s by %s (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),format,dx,dy,w,h)
- end
- else -- needs checking .. maybe no kerns format for single
- local k = (format == "move" and setmove or setkern)(start,factor,rlmode,kerns,injection)
- if trace_kerns then
- logprocess("%s: shifting single %s by %s %p",cref(dataset,sequence),gref(startchar),format,k)
+ -- we actually should check no_left_kern_code with next
+ if not has_glyph_option(start,no_right_kern_code) then
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local startchar = getchar(start)
+ local kerns = mapping[startchar]
+ if kerns then
+ local format = currentlookup.format
+ if format == "single" then
+ local dx, dy, w, h = setposition(0,start,factor,rlmode,kerns) -- currentlookup.flags ?
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),format,dx,dy,w,h)
+ end
+ else -- needs checking .. maybe no kerns format for single
+ local k = (format == "move" and setmove or setkern)(start,factor,rlmode,kerns,injection)
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s %p",cref(dataset,sequence),gref(startchar),format,k)
+ end
end
+ return head, start, true
end
- return head, start, true
end
end
return head, start, false
end
function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) -- todo: injections ?
- local mapping = currentlookup.mapping
- if mapping == nil then
- mapping = getmapping(dataset,sequence,currentlookup)
- end
- if mapping then
- local snext = getnext(start)
- if snext then
- local startchar = getchar(start)
- local kerns = mapping[startchar] -- always 1 step
- if kerns then
- local prev = start
- while snext do
- local nextchar = ischar(snext,currentfont)
- if not nextchar then
- break
- end
- if skiphash and skiphash[nextchar] then
- prev = snext
- snext = getnext(snext)
- else
- local krn = kerns[nextchar]
- if not krn then
+ -- we actually should check no_left_kern_code with next
+ if not has_glyph_option(start,no_right_kern_code) then
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local snext = getnext(start)
+ if snext then
+ local startchar = getchar(start)
+ local kerns = mapping[startchar] -- always 1 step
+ if kerns then
+ local prev = start
+ while snext do
+ local nextchar = ischar(snext,currentfont)
+ if not nextchar then
break
end
- local format = currentlookup.format
- if format == "pair" then
- local a = krn[1]
- local b = krn[2]
- if a == true then
- -- zero
- elseif a then
- local x, y, w, h = setposition(1,start,factor,rlmode,a,"injections") -- currentlookups flags?
- if trace_kerns then
- local startchar = getchar(start)
- logprocess("%s: shifting first of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h)
- end
+ if skiphash and skiphash[nextchar] then
+ prev = snext
+ snext = getnext(snext)
+ else
+ local krn = kerns[nextchar]
+ if not krn then
+ break
end
- if b == true then
- -- zero
- start = snext -- cf spec
- elseif b then -- #b > 0
- local x, y, w, h = setposition(2,snext,factor,rlmode,b,"injections")
+ local format = currentlookup.format
+ if format == "pair" then
+ local a = krn[1]
+ local b = krn[2]
+ if a == true then
+ -- zero
+ elseif a then
+ local x, y, w, h = setposition(1,start,factor,rlmode,a,"injections") -- currentlookups flags?
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting first of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h)
+ end
+ end
+ if b == true then
+ -- zero
+ start = snext -- cf spec
+ elseif b then -- #b > 0
+ local x, y, w, h = setposition(2,snext,factor,rlmode,b,"injections")
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting second of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h)
+ end
+ start = snext -- cf spec
+ elseif forcepairadvance then
+ start = snext -- for testing, not cf spec
+ end
+ return head, start, true
+ elseif krn ~= 0 then
+ local k = (format == "move" and setmove or setkern)(snext,factor,rlmode,krn)
if trace_kerns then
- local startchar = getchar(start)
- logprocess("%s: shifting second of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h)
+ logprocess("%s: inserting %s %p between %s and %s",cref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar))
end
- start = snext -- cf spec
- elseif forcepairadvance then
- start = snext -- for testing, not cf spec
- end
- return head, start, true
- elseif krn ~= 0 then
- local k = (format == "move" and setmove or setkern)(snext,factor,rlmode,krn)
- if trace_kerns then
- logprocess("%s: inserting %s %p between %s and %s",cref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar))
+ return head, start, true
+ else
+ break
end
- return head, start, true
- else
- break
end
end
end
@@ -2056,6 +2096,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
local sweepnode = sweepnode
local sweeptype = sweeptype
local sweepoverflow = false
+ local checkdisc = getprev(head)
local keepdisc = not sweepnode
local lookaheaddisc = nil
local backtrackdisc = nil
@@ -2089,6 +2130,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
sweepnode = current
current = getnext(current)
else
+ -- we can use an iterator
while replace and i <= l do
if getid(replace) == glyph_code then
i = i + 1
@@ -2189,7 +2231,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
local current = prev
local i = f
local t = sweeptype == "pre" or sweeptype == "replace"
- if not current and t and current == checkdisk then
+ if not current and t and current == checkdisc then
current = getprev(sweepnode)
end
while current and i > 1 do -- missing getprev added / moved outside
@@ -2218,7 +2260,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
end
end
current = getprev(current)
- if t and current == checkdisk then
+ if t and current == checkdisc then
current = getprev(sweepnode)
end
end
@@ -2443,6 +2485,10 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,s
local current = start
local last = start
+ if s == 1 then
+ goto next
+ end
+
-- current match
if l > f then
@@ -2512,10 +2558,9 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,s
break
end
end
- -- commented, for Kai to check
- -- if n <= l then
- -- notmatchpre[last] = true
- -- end
+ if n <= l then
+ notmatchpre[last] = true
+ end
else
notmatchpre[last] = true
end
@@ -3287,6 +3332,7 @@ local nesting = 0
local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
local done = false
local sweep = sweephead[head]
+ local start
if sweep then
start = sweep
-- sweephead[head] = nil
@@ -3448,6 +3494,7 @@ end
local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
local done = false
local sweep = sweephead[head]
+ local start
if sweep then
start = sweep
-- sweephead[head] = nil
@@ -3618,8 +3665,6 @@ end
local txtdirstate, pardirstate do -- this might change (no need for nxt in pardirstate)
local getdirection = nuts.getdirection
- local lefttoright = 0
- local righttoleft = 1
txtdirstate = function(start,stack,top,rlparmode)
local dir, pop = getdirection(start)
@@ -3628,19 +3673,19 @@ local txtdirstate, pardirstate do -- this might change (no need for nxt in pard
return 0, rlparmode
else
top = top - 1
- if stack[top] == righttoleft then
+ if stack[top] == righttoleft_code then
return top, -1
else
return top, 1
end
end
- elseif dir == lefttoright then
+ elseif dir == lefttoright_code then
top = top + 1
- stack[top] = lefttoright
+ stack[top] = lefttoright_code
return top, 1
- elseif dir == righttoleft then
+ elseif dir == righttoleft_code then
top = top + 1
- stack[top] = righttoleft
+ stack[top] = righttoleft_code
return top, -1
else
return top, rlparmode
@@ -3649,14 +3694,9 @@ local txtdirstate, pardirstate do -- this might change (no need for nxt in pard
pardirstate = function(start)
local dir = getdirection(start)
- if dir == lefttoright then
- return 1, 1
- elseif dir == righttoleft then
- return -1, -1
- -- for old times sake we we handle strings too
- elseif dir == "TLT" then
+ if dir == lefttoright_code then
return 1, 1
- elseif dir == "TRT" then
+ elseif dir == righttoleft_code then
return -1, -1
else
return 0, 0
@@ -3755,9 +3795,9 @@ do
local initialrl = 0
- if getid(head) == localpar_code and start_of_par(head) then
+ if getid(head) == par_code and start_of_par(head) then
initialrl = pardirstate(head)
- elseif direction == 1 or direction == "TRT" then
+ elseif direction == righttoleft_code then
initialrl = -1
end
@@ -3909,7 +3949,7 @@ do
elseif id == dir_code then
topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode)
start = getnext(start)
- -- elseif id == localpar_code and start_of_par(start) then
+ -- elseif id == par_code and start_of_par(start) then
-- rlparmode, rlmode = pardirstate(start)
-- start = getnext(start)
else
@@ -3993,7 +4033,7 @@ do
elseif id == dir_code then
topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode)
start = getnext(start)
- -- elseif id == localpar_code and start_of_par(start) then
+ -- elseif id == par_code and start_of_par(start) then
-- rlparmode, rlmode = pardirstate(start)
-- start = getnext(start)
else
@@ -4052,7 +4092,7 @@ do
local done = false
local dirstack = { nil } -- could move outside function but we can have local runs (maybe a few more nils)
local start = head
- local initialrl = (direction == 1 or direction == "TRT") and -1 or 0
+ local initialrl = (direction == righttoleft_code) and -1 or 0
local rlmode = initialrl
local rlparmode = initialrl
local topstack = 0
@@ -4104,7 +4144,7 @@ do
elseif id == dir_code then
topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode)
start = getnext(start)
- -- elseif id == localpar_code and start_of_par(start) then
+ -- elseif id == par_code and start_of_par(start) then
-- rlparmode, rlmode = pardirstate(start)
-- start = getnext(start)
else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ott.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ott.lua
index c9e467f2253..f4d7e05a137 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ott.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ott.lua
@@ -1117,41 +1117,6 @@ local checkers = {
end
}
--- Keep this:
---
--- function otf.features.normalize(features)
--- if features then
--- local h = { }
--- for k, v in next, features do
--- k = lower(k)
--- if k == "language" then
--- v = gsub(lower(v),"[^a-z0-9]","")
--- h.language = rawget(verboselanguages,v) or (languages[v] and v) or "dflt" -- auto adds
--- elseif k == "script" then
--- v = gsub(lower(v),"[^a-z0-9]","")
--- h.script = rawget(verbosescripts,v) or (scripts[v] and v) or "dflt" -- auto adds
--- else
--- if type(v) == "string" then
--- local b = is_boolean(v)
--- if type(b) == "nil" then
--- v = tonumber(v) or lower(v)
--- else
--- v = b
--- end
--- end
--- if not rawget(features,k) then
--- k = rawget(verbosefeatures,k) or k
--- end
--- local c = checkers[k]
--- h[k] = c and c(v) or v
--- end
--- end
--- return h
--- end
--- end
-
--- inspect(fonts.handlers.otf.statistics.usedfeatures)
-
if not storage then
return
end
@@ -1178,9 +1143,6 @@ function otffeatures.normalize(features,wrap) -- wrap is for context
h.script = rawget(verbosescripts,v) or (scripts[v] and v) or "dflt" -- auto adds
elseif k == "axis" then
h[k] = normalizedaxis(value)
- if not callbacks.supported.glyph_stream_provider then
- h.variableshapes = true -- for the moment
- end
else
local uk = usedfeatures[key]
local uv = uk[value]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-pre.mkiv b/Master/texmf-dist/tex/context/base/mkiv/font-pre.mkiv
index 8e2e0a7a9f3..445dedd2543 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-pre.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-pre.mkiv
@@ -173,10 +173,15 @@
[arabic]
[fin2=yes,fin3=yes,med2=yes]
+\definefontfeature
+ [reordercombining]
+ [reordercombining=yes]
+
\definefontfeature
[hebrew]
[semitic-complete]
- [script=hebr]
+ [script=hebr,
+ reordercombining=yes] % seems to work best with reasonable fonts
\definefontfeature
[simplearabic]
@@ -320,6 +325,17 @@
\definefontfeature [tamil-two] [tamil-one] [script=tml2]
\definefontfeature [telugu-two] [telugu-one] [script=tel2]
+% mongolian
+
+\definefontfeature
+ [mongolian]
+ [default]
+ [script=mong,
+ init=yes,medi=yes,fina=yes,isol=yes,
+ rlig=yes,rclt=yes,calt=yes,
+ %dlig=yes,cswh=yes, % optional
+ mset]
+
% tibetan
\definefontfeature
@@ -389,10 +405,17 @@
mathalternates=yes,
mathitalics=yes, % we pass them
mathdimensions=all,
+ % mathkerns=yes,
% mathgaps=yes,
language=dflt,
script=math]
+% Users can define this:
+%
+% \definefontfeature
+% [oldmath]
+% [oldmath=yes]
+
\ifdefined\mathnolimitsmode
\mathnolimitsmode\plusone % font driven (only opentype)
\fi
@@ -915,10 +938,14 @@
\unexpanded\def\normalss{\font_helpers_set_current_font_style{\s!ss}}
\unexpanded\def\normaltt{\font_helpers_set_current_font_style{\s!tt}}
+\pushoverloadmode
+
\let\rm\normalrm
\let\ss\normalss
\let\tt\normaltt
+\popoverloadmode
+
\protect \endinput
% LM math vs CM math (analysis by Taco):
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-prv.lua b/Master/texmf-dist/tex/context/base/mkiv/font-prv.lua
index c3323ca743e..15057e2554e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-prv.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-prv.lua
@@ -80,3 +80,36 @@ end
function helpers.newprivateslot(name)
return sharedprivates[name]
end
+
+do
+
+ local context = context
+ local utfchar = utf.char
+
+ interfaces.implement {
+ name = "privatecharacter",
+ public = true,
+ -- protected = true,
+ arguments = "string",
+ actions = function(name)
+ local c = sharedprivates[name]
+ if c then
+ context(utfchar(c))
+ end
+ end
+ }
+
+ interfaces.implement {
+ name = "privatecharactercode",
+ public = true,
+ -- protected = true,
+ arguments = "string",
+ actions = function(name)
+ local c = sharedprivates[name]
+ if c then
+ context(c) -- serialized, not a number
+ end
+ end
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-run.mkiv b/Master/texmf-dist/tex/context/base/mkiv/font-run.mkiv
index 2f6cd32df9f..6bfa7ee7267 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-run.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-run.mkiv
@@ -350,7 +350,7 @@
\ifdefined\databox \else \newbox\databox \fi
-\unexpanded\gdef\testminimalbaseline#1% to be used in a 10 column tabulate
+\unexpanded\gdef\font_show_minimal_baseline#1% to be used in a 10 column tabulate
{\setbox\databox\ruledhbox{#1}%
\scratchdimen\htdp\databox
\normalexpanded {
@@ -374,18 +374,14 @@
\font_show_only_english\showminimalbaseline
\else
\starttabulate[|l|T|T|T|T|T|T|T|T|T|]
- \testminimalbaseline{\hbox to \emwidth{\hss\showstruts\strut\hss}}%
- \testminimalbaseline{(/)}%
- \testminimalbaseline{\normalstartimath\frac{1}{2}x\normalsuperscript2\normalsubscript3\normalstopimath}
+ \font_show_minimal_baseline{\hbox to \emwidth{\hss\showstruts\strut\hss}}%
+ \font_show_minimal_baseline{(/)}%
+ \font_show_minimal_baseline{\normalstartimath\frac{1}{2}x\normalsuperscript2\normalsubscript3\normalstopimath}
\stoptabulate
\fi}
-\unexpanded\gdef\showkerning#1%
- {\bgroup
- \let\MPfshowcommand\ruledhbox
- \setMPtext\s!dummy{#1}%
- \startMPcode draw textext(\MPstring\s!dummy);\stopMPcode
- \egroup}
+\unexpanded\gdef\showkerning
+ {\groupedcommandcs\showfontkerns\relax}
\unexpanded\gdef\showcharratio
{\dowithnextboxcontent
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-sel.lua b/Master/texmf-dist/tex/context/base/mkiv/font-sel.lua
index 15d3838f6d0..9a611f9faa3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-sel.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-sel.lua
@@ -96,7 +96,7 @@ extras["features"] = function(data,alternative,features)
local e = gsub(gsub(features,"*",d),"{(.*)}","%1")
local f = data.features
if trace_features then
- report_features("Alternative '%s': Saving features '%s'",alternative,e)
+ report_features("alternative '%s': saving features '%s'",alternative,e)
end
if not f then
f = { }
@@ -109,7 +109,7 @@ extras["goodies"] = function(data,alternative,goodies)
local e = gsub(goodies,"{(.*)}","%1")
local g = data.goodies
if trace_goodies then
- report_goodies("Alternative '%s': Saving goodies '%s'",alternative,e)
+ report_goodies("alternative '%s': saving goodies '%s'",alternative,e)
end
if not g then
g = { }
@@ -137,7 +137,7 @@ local function selectfont_savefile(data,alternative,bodyfontsize,size,file)
end
a[bodyfontsize] = { size, n }
if trace_files then
- report_files("Alternative '%s': Saving file '%s' for size '%s'",alternative,n,size)
+ report_files("alternative '%s': saving file '%s' for size '%s'",alternative,n,size)
end
end
@@ -145,7 +145,7 @@ methods["name"] = function(data,alternative,name)
local family = data.metadata.family
local filename = cleanname(gsub(name,"*",family))
if trace_alternatives then
- report_selectfont("Alternative '%s': Using method 'name' with argument '%s'",alternative,filename)
+ report_selectfont("alternative '%s': using method 'name' with argument '%s'",alternative,filename)
end
local fontname = getlookups{ fontname = filename }
local fullname = getlookups{ fullname = filename }
@@ -155,7 +155,7 @@ methods["name"] = function(data,alternative,name)
selectfont_savefile(data,alternative,0,"default",fullname[1])
else
if trace_alternatives then
- report_selectfont("Alternative '%s': No font was found for the requested name '%s'",alternative,filename)
+ report_selectfont("alternative '%s': no font was found for the requested name '%s'",alternative,filename)
end
end
end
@@ -164,14 +164,14 @@ methods["file"] = function(data,alternative,file)
local family = data.metadata.family
local filename = cleanname(gsub(removesuffix(file),"*",family))
if trace_alternatives then
- report_selectfont("Alternative '%s': Using method 'file' with argument '%s'",alternative,filename)
+ report_selectfont("alternative '%s': using method 'file' with argument '%s'",alternative,filename)
end
local filename = getlookups{ cleanfilename = cleanname(filename) }
if #filename > 0 then
selectfont_savefile(data,alternative,0,"default",filename[1])
else
if trace_alternatives then
- report_selectfont("Alternative '%s': No font was found for the requested file '%s'",alternative,cleanname(gsub(removesuffix(file),"*",family)))
+ report_selectfont("alternative '%s': no font was found for the requested file '%s'",alternative,cleanname(gsub(removesuffix(file),"*",family)))
end
end
end
@@ -243,7 +243,7 @@ local function m_style_family(family)
return family
elseif #fontname > 0 then
local fontfamily = fontname[1]["familyname"]
- report_selectfont("The name '%s' is not a proper family name, use '%s' instead.",askedname,fontfamily)
+ report_selectfont("the name '%s' is not a proper family name, use '%s' instead.",askedname,fontfamily)
return nil
else
return nil
@@ -353,7 +353,7 @@ local function m_style_size(data,alternative,entries)
end
else
if trace_alternatives then
- report_selectfont("Alternative '%s': Multiple files are available for the requested style '%s' from '%s'",alternative,style,family)
+ report_selectfont("alternative '%s': multiple files are available for the requested style '%s' from '%s'",alternative,style,family)
end
end
end
@@ -386,7 +386,7 @@ methods["style"] = function(data,alternative,style)
m_style_size(data,alternative,entries)
else
if trace_alternatives then
- report_selectfont("Alternative '%s': No font was found for the requested style '%s' from '%s'",alternative,style,family)
+ report_selectfont("alternative '%s': no font was found for the requested style '%s' from '%s'",alternative,style,family)
end
end
end
@@ -394,21 +394,21 @@ end
methods[v_default] = function(data,alternative)
local family = data.metadata.family
if trace_alternatives then
- report_selectfont("Alternative '%s': Using method 'default'",alternative)
+ report_selectfont("alternative '%s': using method 'default'",alternative)
end
local result = getlookups{ familyname = cleanname(family) }
if #result == 1 and alternative == "tf" then
if trace_alternatives then
- report_selectfont("Alternative '%s': The family '%s' contains only one font",alternative,family)
+ report_selectfont("alternative '%s': the family '%s' contains only one font",alternative,family)
end
selectfont_savefile(data,alternative,0,"default",result[1])
-- if trace_alternatives then
- -- report_selectfont("Alternative '%s': Changing method 'default' to method 'style'",alternative)
+ -- report_selectfont("alternative '%s': changing method 'default' to method 'style'",alternative)
-- end
-- methods["file"](data,alternative,result[1]["filename"])
else
if trace_alternatives then
- report_selectfont("Alternative '%s': Changing method 'default' to method 'style'",alternative)
+ report_selectfont("alternative '%s': changing method 'default' to method 'style'",alternative)
end
methods["style"](data,alternative,alternative)
end
@@ -478,7 +478,7 @@ function selectfont.registerfontalternative(alternative)
local a = alternatives[alternative]
if not a then
if trace_register then
- report_selectfont("Register alternative '%s'",alternative)
+ report_selectfont("register alternative '%s'",alternative)
end
a = true
alternatives[alternative] = a
@@ -598,23 +598,23 @@ function selectfont.fontsynonym(data,class,style,alternative,index)
local fontfallback = formatters["fallback-%s-%s-%s"](fontclass,style,alternative)
for _, fontsize in next, fontsizes do
-- if trace_typescript then
- -- report_typescript("Synonym: '%s', Size: '%s', File: '%s'",fontfile,fontfiles[fontsize][1],fontfiles[fontsize][2])
+ -- report_typescript("synonym: '%s', size: '%s', file: '%s'",fontfile,fontfiles[fontsize][1],fontfiles[fontsize][2])
-- end
registerdesignsizes(fontfile,fontfiles[fontsize][1],fontfiles[fontsize][2])
end
if fallback then
-- if trace_typescript then
- -- report_typescript("Synonym: '%s', File: '%s', Features: '%s'",fontsynonym,fontfile,fontfeature)
+ -- report_typescript("synonym: '%s', file: '%s', features: '%s'",fontsynonym,fontfile,fontfeature)
-- end
ctx_definefontsynonym( { fontsynonym }, { fontfile }, { features = fontfeature } )
else
-- if trace_typescript then
- -- report_typescript("Synonym: '%s', File: '%s', Features: '%s', Goodies: '%s', Fallbacks: '%s'",fontsynonym,fontfile,fontfeature,fontgoodie,fontfallback)
+ -- report_typescript("synonym: '%s', file: '%s', features: '%s', goodies: '%s', fallbacks: '%s'",fontsynonym,fontfile,fontfeature,fontgoodie,fontfallback)
-- end
ctx_definefontsynonym( { fontsynonym }, { fontfile }, { features = fontfeature, goodies = fontgoodie, fallbacks = fontfallback } )
if synonym then
-- if trace_typescript then
- -- report_typescript("Synonym: '%s', File: '%s'",synonym,fontsynonym)
+ -- report_typescript("synonym: '%s', file: '%s'",synonym,fontsynonym)
-- end
ctx_definefontsynonym( { synonym }, { fontsynonym } )
end
@@ -628,13 +628,13 @@ function selectfont.fontfallback(data,class,style,alternative,index)
local force = data.options.force ~= "" and data.options.force or ""
local fontfeature = data.features and data.features[alternative] or data.options.features
local fontclass = lower(class)
- local fontsynonym = formatters ["synonym-%s-%s-%s-%s"](fontclass,style,alternative,index)
- local fontfallback = formatters["fallback-%s-%s-%s"] (fontclass,style,alternative)
+ local fontsynonym = formatters["synonym-%s-%s-%s-%s"](fontclass,style,alternative,index)
+ local fontfallback = formatters["fallback-%s-%s-%s"] (fontclass,style,alternative)
if index == 1 then
ctx_resetfontfallback( { fontfallback } )
end
-- if trace_typescript then
- -- report_typescript("Fallback: '%s', Synonym: '%s', Range: '%s', Scale: '%s', Check: '%s', Force: '%s'",fontfallback,fontsynonym,range,scale,check,force)
+ -- report_typescript("fallback: '%s', synonym: '%s', range: '%s', scale: '%s', check: '%s', force: '%s'",fontfallback,fontsynonym,range,scale,check,force)
-- end
ctx_definefontfallback( { fontfallback }, { fontsynonym }, { range }, { rscale = scale, check = check, force = force } )
end
@@ -653,7 +653,7 @@ function selectfont.filefallback(data,class,style,alternative,index)
ctx_resetfontfallback( { fontfallback } )
end
-- if trace_typescript then
- -- report_typescript("Fallback: '%s', File: '%s', Features: '%s', Range: '%s', Scale: '%s', Check: '%s', Force: '%s', Offset: '%s'",fontfallback,fontfile[2],fontfeature,range,scale,check,force,offset)
+ -- report_typescript("fallback: '%s', file: '%s', features: '%s', range: '%s', scale: '%s', check: '%s', force: '%s', offset: '%s'",fontfallback,fontfile[2],fontfeature,range,scale,check,force,offset)
-- end
ctx_definefontfallback( { fontfallback }, { formatters["file:%s*%s"](fontfile[2],fontfeature) }, { range }, { rscale = scale, check = check, force = force, offset = offset } )
end
@@ -737,7 +737,7 @@ function selectfont.bodyfont(data)
fontsynonym = formatters["synonym-%s-%s-%s"](fontclass,fontstyle,alternative)
fontlist[#fontlist+1] = formatters["%s=%s sa 1"] (alternative,fontsynonym)
-- if trace_typescript then
- -- report_typescript("Alternative '%s': Synonym '%s'",alternative,fontsynonym)
+ -- report_typescript("alternative '%s': synonym '%s'",alternative,fontsynonym)
-- end
end
fontlist = concat(fontlist,",")
@@ -760,7 +760,7 @@ function selectfont.typeface(data)
local size = data.options.designsize ~= "" and data.options.designsize or "default"
local scale = data.options.rscale ~= "" and data.options.rscale or 1
-- if trace_typescript then
- -- report_typescript("Class: '%s', Style: '%s', Size: '%s', Scale: '%s'",fontclass,fontstyle,size,scale)
+ -- report_typescript("class: '%s', style: '%s', size: '%s', scale: '%s'",fontclass,fontstyle,size,scale)
-- end
ctx_definetypeface( { fontclass }, { fontstyle }, { style }, { "" }, { "default" }, { designsize = size, rscale = scale } )
end
@@ -770,7 +770,7 @@ function selectfont.default(data)
local fontclass = data.metadata.typeface
local fontstyle = data.metadata.style
local style = m_style[fontstyle]
- report_selectfont("The requested font '%s' has no files for the 'tf' alternative, Latin Modern is used instead.",family)
+ report_selectfont("the requested font '%s' has no files for the 'tf' alternative, Latin Modern is used instead.",family)
ctx_definetypeface( { fontclass }, { fontstyle }, { style }, { "modern" }, { "default" } )
end
@@ -799,7 +799,7 @@ function selectfont.definefallbackfamily(index)
if fontfiles then
selectfont.registerfallback(index)
else
- report_selectfont("The requested fallback font '%s' for typeface '%s' style '%s' was ignored because no files where found.",family,fontclass,fontstyle)
+ report_selectfont("the requested fallback font '%s' for typeface '%s' style '%s' was ignored because no files where found.",family,fontclass,fontstyle)
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-shp.lua b/Master/texmf-dist/tex/context/base/mkiv/font-shp.lua
index 3d2e5b7c902..78e8597b937 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-shp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-shp.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-shp'] = {
local tonumber, next = tonumber, next
local concat = table.concat
-local formatters = string.formatters
+local formatters, lower = string.formatters, string.lower
local otf = fonts.handlers.otf
local afm = fonts.handlers.afm
@@ -221,7 +221,7 @@ end
local function loadstreams(cache,filename,sub,instance)
local base = file.basename(filename)
local name = file.removesuffix(base)
- local kind = file.suffix(filename)
+ local kind = lower(file.suffix(filename))
local attr = lfs.attributes(filename)
local size = attr and attr.size or 0
local time = attr and attr.modification or 0
@@ -346,7 +346,7 @@ local function getstreamhash(fontid)
local fontdata = identifiers[fontid]
if fontdata then
local properties = fontdata.properties
- return makehash(properties.filename,fontdata.subindex,properties.instance)
+ return makehash(properties.filename,properties.subfont,properties.instance)
end
end
@@ -379,124 +379,17 @@ otf.loadstreamdata = loadstreamdata -- not public
otf.loadshapes = loadshapes
otf.getstreamhash = getstreamhash -- not public, might move to other namespace
-local f_c = formatters["%.6N %.6N %.6N %.6N %.6N %.6N c"]
-local f_l = formatters["%.6N %.6N l"]
-local f_m = formatters["%.6N %.6N m"]
-
-local function segmentstopdf(segments,factor,bt,et)
- local t = { }
- local m = 0
- local n = #segments
- local d = false
- for i=1,n do
- local s = segments[i]
- local w = s[#s]
- if w == "c" then
- m = m + 1
- t[m] = f_c(s[1]*factor,s[2]*factor,s[3]*factor,s[4]*factor,s[5]*factor,s[6]*factor)
- elseif w == "l" then
- m = m + 1
- t[m] = f_l(s[1]*factor,s[2]*factor)
- elseif w == "m" then
- m = m + 1
- t[m] = f_m(s[1]*factor,s[2]*factor)
- elseif w == "q" then
- local p = segments[i-1]
- local n = #p
- local l_x = factor*p[n-2]
- local l_y = factor*p[n-1]
- local m_x = factor*s[1]
- local m_y = factor*s[2]
- local r_x = factor*s[3]
- local r_y = factor*s[4]
- m = m + 1
- t[m] = f_c (
- l_x + 2/3 * (m_x-l_x), l_y + 2/3 * (m_y-l_y),
- r_x + 2/3 * (m_x-r_x), r_y + 2/3 * (m_y-r_y),
- r_x, r_y
- )
- end
- end
- m = m + 1
- t[m] = "h f" -- B*
- if bt and et then
- t[0] = bt
- t[m+1] = et
- return concat(t,"\n",0,m+1)
- else
- return concat(t,"\n")
- end
-end
-
-local function initialize(tfmdata,key,value)
- if value then
- local shapes = otf.loadoutlinedata(tfmdata)
- if not shapes then
- return
- end
- local glyphs = shapes.glyphs
- if not glyphs then
- return
- end
- local characters = tfmdata.characters
- local parameters = tfmdata.parameters
- local hfactor = parameters.hfactor * (7200/7227)
- local factor = hfactor / 65536
- local getactualtext = otf.getactualtext
- for unicode, char in next, characters do
- if char.commands then
- -- can't happen as we're doing this before other messing around
- else
- local shape = glyphs[char.index]
- if shape then
- local segments = shape.segments
- if segments then
- -- we need inline in order to support color
- local bt, et = getactualtext(char.tounicode or char.unicode or unicode)
- char.commands = {
- { "pdf", "origin", segmentstopdf(segments,factor,bt,et) }
- }
- end
- end
- end
- end
- end
-end
-
-otf.features.register {
- name = "variableshapes", -- enforced for now
- description = "variable shapes",
- manipulators = {
- base = initialize,
- node = initialize,
- }
-}
-
--- In the end it is easier to just provide the new charstring (cff) and points (ttf). First
--- of all we already have the right information so there is no need to patch the already complex
--- backend code (we only need to make sure the cff is valid). Also, I prototyped support for
--- these fonts using (converted to) normal postscript shapes, a functionality that was already
--- present for a while for metafun. This solution even permits us to come up with usage of such
--- fonts in unexpected ways. It also opens the road to shapes generated with metafun includes
--- as real cff (or ttf) shapes instead of virtual in-line shapes.
---
--- This is probably a prelude to writing a complete backend font inclusion plugin in lua. After
--- all I already have most info. For this we just need to pass a list of used glyphs (or analyze
--- them ourselves).
-
local streams = fonts.hashes.streams
-if callbacks.supported.glyph_stream_provider then
+-- we can now assume that luatex has this one
- callback.register("glyph_stream_provider",function(id,index,mode)
- if id > 0 then
- local streams = streams[id].streams
- -- print(id,index,streams[index])
- if streams then
- return streams[index] or ""
- end
+callback.register("glyph_stream_provider",function(id,index,mode)
+ if id > 0 then
+ local streams = streams[id].streams
+ -- print(id,index,streams[index])
+ if streams then
+ return streams[index] or ""
end
- return ""
- end)
-
-end
+ end
+ return ""
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-sol.lua b/Master/texmf-dist/tex/context/base/mkiv/font-sol.lua
index 2017afcb225..c618739959f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-sol.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-sol.lua
@@ -105,12 +105,14 @@ local disc_code = nodecodes.disc
local kern_code = nodecodes.kern
local hlist_code = nodecodes.hlist
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local whatsit_code = nodecodes.whatsit
local fontkern_code = kerncodes.fontkern
+local righttoleft_code = nodes.dirvalues.righttoleft
+
local userdefinedwhatsit_code = whatsitcodes.userdefined
local nodeproperties = nodes.properties.data
@@ -379,7 +381,7 @@ function splitters.split(head) -- best also pass the direction
end
end
if r2l then
- local dirnode = new_direction(righttoleft) -- brrr, we don't pop ... to be done (when used at all)
+ local dirnode = new_direction(righttoleft_code) -- brrr, we don't pop ... to be done (when used at all)
setlink(dirnode,list)
list = dirnode
end
@@ -434,13 +436,13 @@ function splitters.split(head) -- best also pass the direction
flush()
end
local direction, pop = getdirection(current)
- r2l = not pop and direction == righttoleft
- elseif id == localpar_code and start_of_par(current) then
+ r2l = not pop and direction == righttoleft_code
+ elseif id == par_code and start_of_par(current) then
if start then
flush() -- very unlikely as this starts a paragraph
end
local direction = getdirection(current)
- r2l = direction == righttoleft or direction == "TRT" -- for old times sake
+ r2l = direction == righttoleft_code
else
if start then
flush()
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-sty.mklx b/Master/texmf-dist/tex/context/base/mkiv/font-sty.mklx
deleted file mode 100644
index 81884333bb1..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-sty.mklx
+++ /dev/null
@@ -1,458 +0,0 @@
-%D \module
-%D [ file=font-sty,
-%D version=2011.01.13, % (copied fron font-ini)
-%D title=\CONTEXT\ Font Macros,
-%D subtitle=Styles,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Font Macros / Styles}
-
-\unprotect
-
-%D \macros
-%D {definealternativestyle}
-%D
-%D In the main modules we are going to implement lots of parameterized commands and
-%D one of these parameters will concern the font to use. To suit consistent use of
-%D fonts we here implement a mechanism for defining the keywords that present a
-%D particular style or alternative.
-%D
-%D \starttyping
-%D \definealternativestyle [keywords] [\style] [\nostyle]
-%D \stoptyping
-%D
-%D The first command is used in the normal textflow, while the second command takes
-%D care of headings and alike. Consider the next two definitions:
-%D
-%D \starttyping
-%D \definealternativestyle [bold] [\bf] []
-%D \definealternativestyle [cap] [\cap] [\cap]
-%D \stoptyping
-%D
-%D A change \type {\bf} in a heading which is to be set in \type {\tfd} does not look
-%D that well, so therefore we leave the second argument of \type
-%D {\definealternativestyle} empty. When we capatalize characters using the pseudo
-%D small cap command \type {\cap}, we want this to take effect in both text and
-%D headings, which is accomplished by assigning both arguments.
-
-\installcorenamespace{alternativestyles} % settings
-\installcorenamespace{alternativestyle} % instances
-
-\installsetuponlycommandhandler \??alternativestyles {alternativestyles}
-
-\setnewconstant \c_font_current_alternative_style_index \plusone
-
-\unexpanded\def\definealternativestyle
- {\dotripleempty\font_basics_define_alternative_style}
-
-\def\font_basics_define_alternative_style[#commands][#variantone][#varianttwo]%
- {\processcommalist[#commands]{\font_basics_define_alternative_style_indeed{#variantone}{#varianttwo}}}
-
-\let\definestyle\definealternativestyle % later redefined
-
-\newconstant\c_fonts_basics_alternative_style_method
-
-\def\font_basics_define_alternative_style_indeed#variantone#varianttwo#command%
- {\setuvalue{\??alternativestyle#command}{\font_helpers_apply_alternative_style{#variantone}{#varianttwo}}%
- \ifcsname#command\endcsname
- % no redefinition
- \orelse\ifnum\c_fonts_basics_alternative_style_method=\plusone
- \ifthirdargument
- \setuevalue{#command}{\triggergroupedcommandcs\begincsname\??alternativestyle#command\endcsname}%
- \else
- \setuvalue{#command}{\triggergroupedcommand{#variantone}}%
- \fi
- \else
- \setuvalue{#command}{\triggergroupedcommand{#variantone}}%
- \fi}
-
-\def\font_helpers_apply_alternative_style
- {\ifcase\c_font_current_alternative_style_index
- \expandafter\gobbletwoarguments
- \or
- \expandafter\firstoftwoarguments
- \or
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\def\applyalternativestyle#name% public
- {\begincsname\??alternativestyle#name\endcsname}
-
-\appendtoks
- \doifelse{\alternativestylesparameter\c!method}\v!auto
- {\c_fonts_basics_alternative_style_method\plusone}%
- {\c_fonts_basics_alternative_style_method\zerocount}%
-\to \everysetupalternativestyles
-
-%D Maybe too generic, but probably ok is the following. (Maybe one day we will use a
-%D dedicated grouped command for styles.)
-
-% \appendtoks
-% \let\groupedcommand\thirdofthreearguments
-% \to \everysimplifycommands
-
-%D This command also defines the keyword as command. This means that the example
-%D definition of \type {bold} we gave before, results in a command \type {\bold}
-%D which can be used as:
-%D
-%D \startbuffer
-%D He's a \bold{bold} man with a {\bold head}.
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D or
-%D
-%D \startexample
-%D \definealternativestyle[bold][\bf][]\getbuffer
-%D \stopexample
-%D
-%D Such definitions are of course unwanted for \type {\cap} because this would
-%D result in an endless recursive call. Therefore we check on the existance of both
-%D the command and the substitution. The latter is needed because for instance \type
-%D {\type} is an entirely diferent command. That command handles verbatim, while the
-%D style command would just switch to teletype font. This is just an example of a
-%D tricky naming coincidence.
-%D
-%D \macros
-%D {doconvertfont,noconvertfont,
-%D dontconvertfont,redoconvertfont}
-%D
-%D After having defined such keywords, we can call for them by using
-%D
-%D \starttyping
-%D \doconvertfont{keyword}{text}
-%D \stoptyping
-%D
-%D We deliberately pass an argument. This enables us to assign converters that
-%D handle one argument, like \type {\cap}.
-%D
-%D By default the first specification is used to set the style, exept when we say
-%D \type {\dontconvertfont}, after which the second specification is used. We can
-%D also directly call for \type {\noconvertfont}. In nested calls, we can restore
-%D the conversion by saying \type {\redoconvertfont}.
-%D
-%D These commands are not grouped! Grouping is most probably done by the calling
-%D macro's and would lead to unnecessary overhead.
-
-\let\m_current_convert_font \empty
-\let\m_current_convert_font_dt\empty
-
-\unexpanded\def\doconvertfont#specification% takes second argument / this command is obsolete
- {\edef\m_current_convert_font{#specification}%
- \ifx\m_current_convert_font\empty
- %\expandafter\firstofoneargument
- \else
- \expandafter\font_helpers_do_convert_font
- \fi}
-
-\def\font_helpers_do_convert_font
- {\edef\m_current_convert_font_dt{\detokenize\expandafter{\m_current_convert_font}}%
- \ifcsname\??alternativestyle\m_current_convert_font_dt\endcsname
- \expandafter\lastnamedcs
- \orelse\ifcsname\m_current_convert_font_dt\endcsname
- \expandafter\lastnamedcs
- \else
- \expandafter\m_current_convert_font
- \fi}
-
-%D Low level switches (downward compatible, but we keep them as one can use them in
-%D styles):
-%D
-%D \starttyping
-%D \usemodule[abr-02]
-%D \setuphead[chapter][style=\bfb]
-%D \setupfooter[style=\dontconvertfont\bf]
-%D \chapter{This is \TEX}
-%D \stoptyping
-
-\unexpanded\def\dontconvertfont{\c_font_current_alternative_style_index\plustwo} % needs checking in usage
-\unexpanded\def\redoconvertfont{\c_font_current_alternative_style_index\plusone} % needs checking in usage
-
-%D The new one:
-
-\setfalse\fontattributeisset
-
-\unexpanded\def\dousestyleparameter#value%
- {\edef\currentstyleparameter{#value}%
- \ifx\currentstyleparameter\empty\else
- \expandafter\dousecurrentstyleparameter
- \fi}
-
-\unexpanded\def\dousestylehashparameter#hash#parameter%
- {\ifcsname#hash#parameter\endcsname
- \expandafter\dousestyleparameter\lastnamedcs
- \fi}
-
-\unexpanded\def\dousecurrentstyleparameter % empty check outside here
- {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
- \settrue\fontattributeisset % reset is done elsewhere
- \ifcsname\??alternativestyle\detokenizedstyleparameter\endcsname
- \lastnamedcs
- \orelse\ifcsname\detokenizedstyleparameter\endcsname
- \lastnamedcs
- \else
- \currentstyleparameter
- \fi}
-
-\let\dosetfontattribute\dousestylehashparameter % for a while
-
-%D New commands (not yet interfaced):
-%D
-%D \startbuffer
-%D \definestyle[one][style=bold,color=darkblue]
-%D
-%D test \one{test} test
-%D test \style[one]{test} test
-%D test \style[color=red]{test} test
-%D test \style[Serif at 20pt]{test} test
-%D \stopbuffer
-%D
-%D \typebuffer \startlines \getbuffer \stoplines
-
-% definitions .. no tagging here
-
-\installcorenamespace{style}
-\installcorenamespace{stylecheck}
-\installcorenamespace{stylehack}
-
-\installcommandhandler \??style {style} \??style
-
-\setupstyle
- [%\c!style=,
- %\c!color=,
- \c!method=\v!command]
-
-\appendtoks
- \letvalue{\??stylecheck\currentstyle}\relax
- \edef\p_method{\styleparameter\c!method}%
- \ifx\p_method\v!command
- \setuevalue{\e!start\currentstyle}{\font_styles_apply_start{\currentstyle}}%
- \setuevalue{\e!stop \currentstyle}{\font_styles_apply_stop}%
- \setuevalue {\currentstyle}{\font_styles_apply_grouped{\currentstyle}}% no longer groupedcommand here
- \fi
-\to \everydefinestyle
-
-\unexpanded\def\font_styles_apply_start#name%
- {\begingroup
- \font_styles_use_defined{#name}}
-
-\unexpanded\def\font_styles_apply_stop
- {\endgroup}
-
-\unexpanded\def\font_styles_apply_grouped#name% assumes that the next is { or \bgroup
- {\bgroup
- \def\g_style{\font_styles_use_defined{#name}}%
- \afterassignment\g_style
- \let\nexttoken}
-
-\unexpanded\def\font_styles_use_defined#name%
- {\edef\currentstyle{#name}%
- \usestylestyleandcolor\c!style\c!color}
-
-\unexpanded\def\font_styles_use_generic#specification%
- {\let\currentstyle\s!unknown % reasonable generic tag
- \letstyleparameter\c!style\empty
- \letstyleparameter\c!color\empty
- \setupcurrentstyle[#specification]%
- \usestylestyleandcolor\c!style\c!color}
-
-% commands
-
-\installcorenamespace{styleargument}
-
-\unexpanded\def\style[#name]% as this is can be a switch we use groupedcommand
- {\csname\??styleargument
- \ifcsname\??stylecheck#name\endcsname
- 2% defined as style
- \orelse\ifcsname\??stylehack#name\endcsname
- 4% defined as command
- \orelse\ifcsname#name\endcsname
- 1% defined as command
- \else
- 3% specification
- \fi
- \endcsname{#name}}
-
-% \setvalue{\??styleargument1}#name%
-% {\groupedcommand{\begincsname#name\endcsname}{}}
-
-\setvalue{\??styleargument1}#name%
- {\expandafter\triggergroupedcommandcs\begincsname#name\endcsname}
-
-% \setvalue{\??styleargument2}#name%
-% {\groupedcommand{\font_styles_use_defined{#name}}{}} % or {\font_styles_apply_grouped{#name}}
-
-\setvalue{\??styleargument2}#name%
- {\triggergroupedcommand{\font_styles_use_defined{#name}}} % or {\font_styles_apply_grouped{#name}}
-
-\setvalue{\??styleargument3}#specification%
- {\doifelseassignment{#specification}\font_styles_assignment\font_styles_direct{#specification}}
-
-\setvalue{\??styleargument4}#name%
- {\expandafter\triggergroupedcommandcs\begincsname\??stylehack#name\endcsname}
-
-\setvalue{\??stylehack\s!math}% dirty trick
- {\groupedcommand\normalstartimath\normalstopimath}
-
-% \def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}}
-% \def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}}
-
-\def\font_styles_assignment#specification{\triggergroupedcommand{\font_styles_use_generic{#specification}}}
-\def\font_styles_direct #specification{\triggergroupedcommand{\definedfont[#specification]}}
-
-% environments
-
-\installcorenamespace{styleenvironment}
-
-\unexpanded\def\startstyle[#name]%
- {\begingroup
- \csname\??styleenvironment
- \ifcsname\??stylecheck#name\endcsname
- 2% defined as style
- \orelse\ifcsname#name\endcsname
- 1% defined as command
- \else
- 3% specification
- \fi
- \endcsname{#name}}
-
-\unexpanded\def\stopstyle
- {\endgroup
- \autoinsertnextspace} % will be configurable, maybe also in \definestartstop
-
-\setvalue{\??styleenvironment1}#name%
- {\csname#name\endcsname}
-
-\setvalue{\??styleenvironment2}#name%
- {\font_styles_use_defined{#name}}
-
-\setvalue{\??styleenvironment3}#specification%
- {\doifelseassignment{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}}
-
-\def\font_styles_start_assignment#specification{\font_styles_use_generic{#specification}}
-\def\font_styles_start_direct #specification{\definedfont[#specification]\relax}
-
-%D Still experimental (might even go away).
-
-% \definestylecollection[mine]
-
-% \definestyleinstance[mine][default][sorry]
-% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl]
-% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl]
-% \definestyleinstance[mine][bf][\sl]
-% \definestyleinstance[mine][sl][\tt]
-
-% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}}
-
-\installcorenamespace{stylecollection}
-
-\unexpanded\def\definestylecollection
- {\dosingleargument\font_styles_define_style_collection}
-
-\def\font_styles_define_style_collection[#name]%
- {\iffirstargument
- \setuvalue{#name}{\styleinstance[#name]}%
- \def\font_styles_define_style_collection_a#style%
- {\def\font_styles_define_style_collection_b#alternative{\undefinevalue{\??stylecollection#name:#style:#alternative}}%
- \font_helpers_process_alternative_list\font_styles_define_style_collection_b
- \font_styles_define_style_collection_b\s!default}%
- \font_helpers_process_style_list\font_styles_define_style_collection_a
- \font_styles_define_style_collection_a\s!default
- \fi}
-
-\let\font_styles_define_style_collection_a\relax
-\let\font_styles_define_style_collection_b\relax
-
-\unexpanded\def\definestyleinstance
- {\doquadrupleargument\font_styles_define_style_instance}
-
-\def\font_styles_define_style_instance[#instance][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever]
- {\iffirstargument
- \ifcsname#instance\endcsname\else\font_styles_define_style_collection[#instance]\fi
- \fi
- \iffourthargument
- \setvalue{\??stylecollection#instance:#2:#3}{#4}%
- \orelse\ifthirdargument
- \setvalue{\??stylecollection#instance::#2}{#3}%
- \orelse\ifsecondargument
- \letvalueempty{\??stylecollection#instance::#2}%
- \fi}
-
-% \unexpanded\def\styleinstance[#instance]% will be made faster
-% {%\begingroup\normalexpanded{\noexpand\infofont[#1:\fontstyle:\fontalternative]}\endgroup
-% \executeifdefined{\??stylecollection#instance:\fontstyle:\fontalternative}%
-% {\executeifdefined{\??stylecollection#instance:\fontstyle:\s!default}%
-% {\executeifdefined{\??stylecollection#instance::\fontalternative}
-% {\getvalue {\??stylecollection#instance::\s!default}}}}}
-
-\unexpanded\def\styleinstance[#instance]% maybe \lastnamedcs here too
- {\csname\??stylecollection#instance:%
- \ifcsname\??stylecollection#instance:\fontstyle:\fontalternative\endcsname
- \fontstyle:\fontalternative
- \orelse\ifcsname\??stylecollection#instance:\fontstyle:\s!default\endcsname
- \fontstyle:\s!default
- \orelse\ifcsname\??stylecollection#instance::\fontalternative\endcsname
- :\fontalternative
- \else
- :\s!default
- \fi
- \endcsname}
-
-%D Variant selectors
-%D
-%D \starttyping
-%D \mathematics {\vsone{\utfchar{0x2229}}}
-%D \mathematics {\utfchar{0x2229}\vsone{}}
-%D \stoptyping
-
-\unexpanded\edef\vsone#character{#character\normalUchar"FE00 } % used
-\unexpanded\edef\vstwo#character{#character\normalUchar"FE01 } % not used but handy for testing
-
-%D For historic reasons we keep the following around but they are no longer that
-%D relevant for \MKIV.
-
-\unexpanded\def\doattributes#1#2#3#4%
- {\begingroup % geen \bgroup, anders in mathmode lege \hbox
- \dousestylehashparameter{#1}{#2}%
- \dousecolorhashparameter{#1}{#3}%
- #4%
- \endgroup}
-
-\unexpanded\def\dostartattributes#1#2#3%
- {\begingroup % geen \bgroup, anders in mathmode lege \hbox
- \dousestylehashparameter{#1}{#2}%
- \dousecolorhashparameter{#1}{#3}}
-
-\let\dostopattributes\endgroup
-
-%D New but it needs to be supported explicitly (as in natural tables).
-
-\newconditional\c_font_styles_math
-
-\unexpanded\def\font_styles_math_reset
- {\setfalse\c_font_styles_math}
-
-\unexpanded\def\font_styles_math_start
- {\ifconditional\c_font_styles_math
- \startimath
- \fi
- \relax}
-
-\unexpanded\def\font_styles_math_stop
- {\relax
- \ifconditional\c_font_styles_math
- \stopimath
- \fi}
-
-\definealternativestyle[\v!math][\settrue\c_font_styles_math]
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-sty.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-sty.mkvi
index a24194355e2..519381a2e1a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-sty.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-sty.mkvi
@@ -181,6 +181,9 @@
\setfalse\fontattributeisset
+\let\currentstyleparameter \empty % these might become private
+\let\currentdetokenizedstyleparameter\empty % these might become private
+
\unexpanded\def\dousestyleparameter#value%
{\edef\currentstyleparameter{#value}%
\ifx\currentstyleparameter\empty\else
@@ -193,11 +196,11 @@
\fi}
\unexpanded\def\dousecurrentstyleparameter % empty check outside here
- {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
+ {\edef\currentdetokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
\settrue\fontattributeisset % reset is done elsewhere
- \ifcsname\??alternativestyle\detokenizedstyleparameter\endcsname
+ \ifcsname\??alternativestyle\currentdetokenizedstyleparameter\endcsname
\lastnamedcs
- \else\ifcsname\detokenizedstyleparameter\endcsname
+ \else\ifcsname\currentdetokenizedstyleparameter\endcsname
\lastnamedcs
\else
\currentstyleparameter
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-sym.mklx b/Master/texmf-dist/tex/context/base/mkiv/font-sym.mklx
deleted file mode 100644
index 33f8a62da7b..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/font-sym.mklx
+++ /dev/null
@@ -1,245 +0,0 @@
-%D \module
-%D [ file=font-mat,
-%D version=2011.01.13, % (copied fron font-ini)
-%D title=\CONTEXT\ Font Macros,
-%D subtitle=Symbolic Access,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Font Macros / Symbolic Access}
-
-\unprotect
-
-%D \macros
-%D {getglyph, symbolicfont}
-%D
-%D Individual glyphs can be accessed by using
-%D
-%D \starttyping
-%D \getglyph{fontname}{character}
-%D \stoptyping
-%D
-%D This macro is used in for instance the symbol modules and as one can see, it does
-%D obey the small and even smaller sizes. The \type {\symbolicfont} macro can be
-%D used to switch to a font named \type {fontname} (see \type {cont-log} and \type
-%D {symb-eur} for examples of symbolic definitions.
-
-\def\v_font_string_a
- {\ifx\fontstyle\s!rm \s!Serif \orelse
- \ifx\fontstyle\s!ss \s!Sans \orelse
- \ifx\fontstyle\s!tt \s!Mono \else
- \s!Serif \fi}
-
-\def\v_font_string_b
- {\ifx\fontstyle\s!rm \s!Regular \orelse
- \ifx\fontstyle\s!ss \s!Support \orelse
- \ifx\fontstyle\s!tt \s!Type \else
- \s!Serif \fi}
-
-\def\v_font_string_c
- {\ifx\fontalternative\s!bf \s!Bold \orelse
- \ifx\fontalternative\s!sl \s!Slanted \orelse
- \ifx\fontalternative\s!it \s!Italic \orelse
- \ifx\fontalternative\s!bs \s!BoldSlanted \orelse
- \ifx\fontalternative\s!bi \s!BoldItalic \fi}
-
-\let\v_font_string_d\s!Serif % default fontstyle (will be redefined in type-ini)
-
-\definefontsynonym
- [CurrentFont]
- [\noexpand\v_font_string_a\noexpand\v_font_string_c]
-
-% potential generalization:
-%
-% \letvalue{\??fontfile:t:\s!rm}\s!Serif
-% \letvalue{\??fontfile:t:\s!ss}\s!Sans
-% \letvalue{\??fontfile:t:\s!tt}\s!Mono
-%
-% \letvalue{\??fontfile:a:\s!rm}\s!Regular
-% \letvalue{\??fontfile:a:\s!ss}\s!Support
-% \letvalue{\??fontfile:a:\s!tt}\s!Type
-%
-% \letvalue{\??fontfile:s:\s!bf}\s!Bold
-% \letvalue{\??fontfile:s:\s!sl}\s!Slanted
-% \letvalue{\??fontfile:s:\s!it}\s!Italic
-% \letvalue{\??fontfile:s:\s!bs}\s!BoldSlanted
-% \letvalue{\??fontfile:s:\s!bi}\s!BoldItalic
-%
-% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
-% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
-% \def\v_font_string_b{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif}
-% \def\v_font_string_c{\executeifdefined{\??fontfile:s:\fontstyle}\empty}
-% \def\v_font_string_d{\executeifdefined{\??fontfile:t:\csname\??typescriptdefaultstyles\fontclass\endcsname}\s!Serif}
-
-%D \macros
-%D {fontstylesuffix}
-%D
-%D The next macro is used to map non latin fontnames on fonts. See \type
-%D {font-uni} for an example of its use.
-
-\def\fontstylesuffix% why the \s!Regular ? see \getglyph
- {\ifx\fontalternative\s!tf \s!Regular \orelse
- \ifx\fontalternative\s!bf \s!Bold \orelse
- \ifx\fontalternative\s!sl \s!Slanted \orelse
- \ifx\fontalternative\s!it \s!Italic \orelse
- \ifx\fontalternative\s!bs \s!BoldSlanted \orelse
- \ifx\fontalternative\s!bi \s!BoldItalic \orelse
- \ifx\fontalternative\s!sc \s!Caps \else
- \s!Regular \fi}
-
-\def\glyphfontfile#base% appends
- {#base%
- \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname
- \v_font_string_a\v_font_string_c
- \orelse\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname
- \v_font_string_b\v_font_string_c
- \orelse\ifcsname\??fontfile#base\v_font_string_a\endcsname
- \v_font_string_a
- \orelse\ifcsname\??fontfile#base\v_font_string_b\endcsname
- \v_font_string_b
- \orelse\ifcsname\??fontfile#base\v_font_string_c\endcsname
- \v_font_string_c
- \fi}
-
-%D The next macro can be used to make decisions based on the shape:
-
-\def\doifelseitalic#yes#nop%
- {\ifx\fontalternative\s!sl#yes\orelse
- \ifx\fontalternative\s!it#yes\orelse
- \ifx\fontalternative\s!bs#yes\orelse
- \ifx\fontalternative\s!bi#yes\else#nop\fi}
-
-\let\doifitalicelse\doifelseitalic
-
-%D For an example of usage of the following command, see \type {cont-log.tex}.
-%D
-%D \starttyping
-%D \def\symbolicfont#specification{\definedfont[\glyphfontfile{#specification} sa *]}
-%D \stoptyping
-%D
-%D Since we know what scaling it to be applied, we can implement a much faster
-%D alternative:
-
-\installcorenamespace{symbolfont}
-
-\let\thedefinedfont\relax
-
-\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
- {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \lastnamedcs
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
- {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \lastnamedcs
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\setstyledsymbolicfont#fontname% quite a slowdown, glyphfontfile
- {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#fontname}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \lastnamedcs
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\setdirectsymbolicfont#fontname%
- {\edef\askedsymbolfont{\truefontname{#fontname} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \lastnamedcs
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\font_basics_define_symbolic_font
- {\definefont[currentsymbolfont][\askedsymbolfont]%
- \currentsymbolfont
- \expandafter\glet\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall}
-
-\unexpanded\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_fontchar{#character}}}
-\unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_fontchar{#character}}}
-\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}}
-\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}}
-\unexpanded\def\resolvedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_tochar{#character}}}
-\unexpanded\def\resolvedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_tochar{#character}}}
-
-% this one is wrong:
-
-\unexpanded\def\getscaledglyph#scale#name#content%
- {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifelsenumber{#content}\char\donothing#content}}
-
-\let\getglyph \getglyphstyled % old
-\let\getrawglyph \getglyphdirect % old
-\let\symbolicsizedfont\setscaledstyledsymbolicfont % old
-\let\symbolicfont \setstyledsymbolicfont % old
-
-\unexpanded\def\symbolicscaledfont{\setsscaledstyledsymbolicfont\fontbody}
-\unexpanded\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody}
-
-%D The last implementation of \type {\getglyph} permits definitions like:
-%D
-%D \starttyping
-%D \definefontsynonym [EuroSans] [eurose]
-%D \definefontsynonym [EuroSansBold] [euroseb]
-%D \definefontsynonym [EuroSansItalic] [eurosei]
-%D \definefontsynonym [EuroSansSlanted] [eurosei]
-%D \definefontsynonym [EuroSansBoldItalic] [eurosebi]
-%D \definefontsynonym [EuroSansBoldSlanted] [eurosebi]
-%D
-%D \definesymbol [euro] [\getglyph{Euro}{\char160}]
-%D
-%D \def\euro{\symbol[euro]}
-%D \stoptyping
-%D
-%D These definitions guarantee that the next calls work okay:
-%D
-%D \starttyping
-%D \ss \tf\euro \bf\euro \sla\euro \itd\euro \bs\euro \bic\euro
-%D \stoptyping
-%D
-%D The shape as well as the size is adapted to the current environment.
-
-%D \macros
-%D {setfont}
-%D
-%D Every now and then we want to define a font directly, for instance when we
-%D typeset title pages. The next macro saves some typing:
-
-\unexpanded\def\setfont% geen \font_helpers_set_font mogelijk
- {\afterassignment\font_basics_set_font\font\nextfont=}
-
-\def\font_basics_set_font
- {\nextfont\setupinterlinespace}% hm, we need to use \setuplocalinterlinespace
-
-%D One can call this macro as:
-%D
-%D \starttyping
-%D \setfont cmr10 at 60pt
-%D \stoptyping
-%D
-%D After which the font is active and the baselines and struts are set.
-
-%D \macros{doiffontcharelse}
-
-\unexpanded\def\doifelsefontchar#specification#unicode% this could be a direct lua call
- {\begingroup
- \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
- \iffontchar\font#unicode\relax
- \endgroup\expandafter\firstoftwoarguments
- \else
- \endgroup\expandafter\secondoftwoarguments
- \fi}
-
-\let\doiffontcharelse\doifelsefontchar
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-tfm.lua b/Master/texmf-dist/tex/context/base/mkiv/font-tfm.lua
index e2f0d22f2a8..945421a4219 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-tfm.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-tfm.lua
@@ -139,16 +139,17 @@ local function read_from_tfm(specification)
-- If reencode returns a new table, we assume that we're doing something
-- special. An 'auto' reencode picks up its vector from the pfb file.
- if lpdf and lpdf.getmapentry and not features.reencode then
+ local getmapentry = fonts.mappings.getentry
+
+ if getmapentry and not features.reencode then
-- This can happen multiple times but not that often so we don't
-- optimize this.
- local encoding, pfbfile, encfile = lpdf.getmapentry(filename)
+ local encoding, pfbfile, encfile = getmapentry(filename)
if encoding and pfbfile then
features.reencode = encfile
features.pfbfile = pfbfile
end
end
-
local newtfmdata = (depth[filename] == 1) and tfm.reencode(tfmdata,specification)
if newtfmdata then
tfmdata = newtfmdata
@@ -162,6 +163,7 @@ local function read_from_tfm(specification)
shared.features = features
shared.resources = resources
--
+ properties.id = specification.id
properties.name = tfmdata.name -- todo: fallback
properties.fontname = tfmdata.fontname -- todo: fallback
properties.psname = tfmdata.psname -- todo: fallback
@@ -170,9 +172,9 @@ local function read_from_tfm(specification)
properties.format = tfmdata.format or fonts.formats.tfm -- better than nothing
properties.usedbitmap = tfmdata.usedbitmap
--
-if lpdf and lpdf.getmapentry and newtfmdata then
- properties.filename = features.pfbfile
-end
+ if getmapentry and newtfmdata then
+ properties.filename = features.pfbfile
+ end
--
tfmdata.properties = properties
tfmdata.resources = resources
@@ -234,8 +236,10 @@ end
--
-- The tounicode data is passed to the backend that constructs the vectors for us.
--
- tfmdata.tounicode = 1
- local tounicode = fonts.mappings.tounicode
+if not CONTEXTLMTXMODE or CONTEXTLMTXMODE == 0 then
+ tfmdata.tounicode = 1
+end
+ local tounicode = fonts.mappings.tounicode
for unicode, v in next, tfmdata.characters do
local u = v.unicode
if u then
@@ -439,7 +443,7 @@ do
local characters = { }
local originals = tfmdata.characters
local indices = { }
- local parentfont = { "font", 1 }
+ local parentfont = { "font", 1 } -- can be zero (self referencing)
local private = tfmdata.privateoffset or constructors.privateoffset
local reported = encdone[tfmfile][encfile] -- bah, encdone for tfm or pfb ?
-- create characters table
@@ -447,6 +451,14 @@ do
-- vector : pfbindex -> name
-- encoding : tfmindex -> name
+ -- we store the order also because some tex encodings (see math-vfu) needs
+ -- that for remapping with non standard glyphs names cq. lack of unicode
+ -- slot information
+
+ for k, v in next, originals do
+ v.order = k
+ end
+
local backmap = vector and table.swapped(vector)
local done = { } -- prevent duplicate
for tfmindex, name in sortedhash(encoding) do -- predictable order
@@ -458,7 +470,7 @@ do
else
unicode = private
private = private + 1
- if not reported then
+ if trace_defining and not reported then
report_tfm("glyph %a in font %a with encoding %a gets unicode %U",name,tfmfile,encfile,unicode)
end
end
@@ -514,11 +526,13 @@ do
tfmdata.fullname = tfmdata.fullname or tfmdata.name
tfmdata.psname = file.nameonly(pfbfile or tfmdata.name)
tfmdata.filename = pfbfile
- tfmdata.encodingbytes = 2
-- tfmdata.format = bitmap and "type3" or "type1"
tfmdata.format = "type1"
+if not CONTEXTLMTXMODE or CONTEXTLMTXMODE == 0 then
+ tfmdata.encodingbytes = 2
tfmdata.tounicode = 1
tfmdata.embedding = "subset"
+end
tfmdata.usedbitmap = bitmap and virtualid
tfmdata.private = private
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-tpk.lua b/Master/texmf-dist/tex/context/base/mkiv/font-tpk.lua
index 05ecdd45ce1..16b89c3932c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-tpk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-tpk.lua
@@ -1,5 +1,6 @@
- if not modules then modules = { } end modules ['font-tpk'] = {
+if not modules then modules = { } end modules ['font-tpk'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -847,7 +848,6 @@ do
direction = direction,
-- checksum = checksum,
-- embedding = "unknown",
- -- encodingbytes = 0,
-- extend = 1000,
-- slant = 0,
-- squeeze = 0,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-tra.mkiv b/Master/texmf-dist/tex/context/base/mkiv/font-tra.mkiv
index 89a50c5aeb2..99c7ab3c822 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-tra.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-tra.mkiv
@@ -20,8 +20,8 @@
%D \macros
%D {showbodyfont}
%D
-%D One can call for a rather simple overview of a bodyfont and the
-%D relations between its alternative fonts.
+%D One can call for a rather simple overview of a bodyfont and the relations between
+%D its alternative fonts.
%D
%D \showsetup{showbodyfont}
%D
@@ -37,9 +37,8 @@
%D \macros
%D {showfontstrip, testminimalbaseline, showminimalbaseline}
%D
-%D The next command can come in handy when combining
-%D different fonts into a collection (typeface) and
-%D determining optimal baseline distances.
+%D The next command can come in handy when combining different fonts into a
+%D collection (typeface) and determining optimal baseline distances.
%D
%D \showfontstrip \blank \showminimalbaseline
@@ -109,10 +108,8 @@
\unexpanded\def\stopotfcollecting {\ctxlua{nodes.tracers.steppers.stop()}}
\unexpanded\def\resetotfcollecting{\ctxlua{nodes.tracers.steppers.reset()}}
-% Rather experimental:
-%
% \page \showotfcomposition{arabtype*arab-default at 48pt}{-1}{الضَّرَّ} \page
-% \page \showotfcomposition{arabtype*arab-default at 48pt}{-1}{لِلّٰهِ} \page
+% \page \showotfcomposition{arabtype*arab-default at 48pt}{-1}{لِلّٰهِ} \page
\unexpanded\def\showotfstepglyphs#1%
{\ctxlua{nodes.tracers.steppers.glyphs(\number\otfcollector,#1)}%
@@ -360,7 +357,7 @@
% new
-\unexpanded\def\savefont[#1]% not yet in i-*.xml
+\unexpanded\def\savefontdata[#1]% not yet in i-*.xml
{\begingroup
\getdummyparameters[#1]%
\clf_savefont {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua
index 651ede17e21..a2732aa5f2e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-ttf'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -162,8 +163,7 @@ local function mergecomposites(glyphs,shapes)
return contours, points
end
--- for index=1,#glyphs do
- for index=0,#glyphs-1 do
+ for index=0,#glyphs do
local shape = shapes[index]
if shape then
local components = shape.components
@@ -658,7 +658,7 @@ local function repackpoints(glyphs,shapes)
local result = { } -- reused
local xpoints = { } -- reused
local ypoints = { } -- reused
- for index=0,#glyphs-1 do
+ for index=0,#glyphs do
local shape = shapes[index]
if shape then
local r = 0
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-vfc.lua b/Master/texmf-dist/tex/context/base/mkiv/font-vfc.lua
index dfe6b3afc46..eff0aa6c636 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-vfc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-vfc.lua
@@ -13,7 +13,7 @@ local fonts = fonts
local helpers = fonts.helpers
local setmetatableindex = table.setmetatableindex
-local makeweak = table.makeweak
+----- makeweak = table.makeweak
-- Helpers dealing with virtual fonts: beware, these are final values so
-- don't change the content of tables gotten this way!
diff --git a/Master/texmf-dist/tex/context/base/mkiv/good-ctx.lua b/Master/texmf-dist/tex/context/base/mkiv/good-ctx.lua
index 82ef25e29de..80672676c7b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/good-ctx.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/good-ctx.lua
@@ -32,6 +32,7 @@ local fontgoodies = fonts.goodies or { }
local nuts = nodes.nuts
local tonut = nuts.tonut
local getattr = nuts.getattr
+local getprop = nuts.getprop
local nextglyph = nuts.traversers.glyph
-- colorschemes
@@ -61,8 +62,10 @@ local function setcolorscheme(tfmdata,scheme)
local characters = tfmdata.characters
for i=1,#what do
local w = what[i]
- for j=1,#w do
- local name = w[j]
+ local force = w.force
+ local list = w.list or w
+ for j=1,#list do
+ local name = list[j]
local kind = type(name)
if name == "*" then
-- inefficient but only used for tracing anyway
@@ -81,10 +84,16 @@ local function setcolorscheme(tfmdata,scheme)
-- limited usage: we only deal with non reassigned
-- maybe some day I'll also support the ones with a
-- tounicode in this range
- for unicode=start,stop do
- if characters[unicode] then
+ if force then
+ for unicode=start,stop do
reverse[unicode] = i
end
+ else
+ for unicode=start,stop do
+ if characters[unicode] then
+ reverse[unicode] = i
+ end
+ end
end
end
else
@@ -150,6 +159,13 @@ function colorschemes.coloring(head)
if f ~= lastfont then
lastfont = f
lastscheme = fontproperties[f].colorscheme
+ if not lastscheme then
+ local p = getprop(n, "original")
+ if p then
+ lastfont = p.font
+ lastscheme = fontproperties[lastfont].colorscheme
+ end
+ end
end
if a ~= lastattr then
lastattr = a
@@ -158,6 +174,7 @@ function colorschemes.coloring(head)
if lastscheme then
local sc = lastscheme[char]
if sc then
+ -- todo: use new lmtx mechanism instead
setnodecolor(n,lastcache[sc]) -- we could inline this one
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/good-mth.lua b/Master/texmf-dist/tex/context/base/mkiv/good-mth.lua
index 18a97976fd3..3473cc205c4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/good-mth.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/good-mth.lua
@@ -6,8 +6,9 @@ if not modules then modules = { } end modules ['good-mth'] = {
license = "see context related readme files"
}
-local type, next = type, next
+local type, next, tonumber, unpack = type, next, tonumber, unpack
local ceil = math.ceil
+local match = string.match
local fonts = fonts
@@ -20,6 +21,10 @@ local fontgoodies = fonts.goodies or { }
local fontcharacters = fonts.hashes.characters
+local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
+
+local report_math = logs.reporter("mathematics","initializing")
+
local nuts = nodes.nuts
local setlink = nuts.setlink
@@ -33,11 +38,149 @@ local new_vlist = nodepool.vlist
local insert_node_after = nuts.insert_after
+local helpers = fonts.helpers
+local upcommand = helpers.commands.up
+local rightcommand = helpers.commands.right
+local charcommand = helpers.commands.char
+local prependcommands = helpers.prependcommands
+
-- experiment, we have to load the definitions immediately as they precede
-- the definition so they need to be initialized in the typescript
+local function withscriptcode(tfmdata,unicode,data,action)
+ if type(unicode) == "string" then
+ local p, u = match(unicode,"^(.-):(.-)$")
+ if u then
+ u = tonumber(u)
+ if u then
+ local slots = fonts.helpers.mathscriptslots(tfmdata,u)
+ if slots then
+ if p == "*" then
+ action(u,data)
+ for i=1,#slots do
+ action(slots[i],data)
+ end
+ else
+ p = tonumber(p)
+ if p then
+ action(slots[p],data)
+ end
+ end
+ end
+ end
+ end
+ else
+ action(unicode,data)
+ end
+end
+
local function finalize(tfmdata,feature,value)
- mathematics.overloaddimensions(tfmdata,tfmdata,value)
+-- if tfmdata.mathparameters then -- funny, cambria text has this
+ local goodies = tfmdata.goodies
+ if goodies then
+ local virtualized = mathematics.virtualized
+ for i=1,#goodies do
+ local goodie = goodies[i]
+ local mathematics = goodie.mathematics
+ local dimensions = mathematics and mathematics.dimensions
+ if dimensions then
+ if trace_defining then
+ report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size)
+ end
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local parameters = tfmdata.parameters
+ local factor = parameters.factor
+ local hfactor = parameters.hfactor
+ local vfactor = parameters.vfactor
+ local function overloadone(unicode,data)
+ local character = characters[unicode]
+ if not character then
+ local c = virtualized[unicode]
+ if c then
+ character = characters[c]
+ end
+ end
+ if character then
+ local width = data.width
+ local height = data.height
+ local depth = data.depth
+ if trace_defining and (width or height or depth) then
+ report_math("overloading dimensions of %C, width %p, height %p, depth %p",
+ unicode,width or 0,height or 0,depth or 0)
+ end
+ if width then character.width = width * hfactor end
+ if height then character.height = height * vfactor end
+ if depth then character.depth = depth * vfactor end
+ --
+ local xoffset = data.xoffset
+ local yoffset = data.yoffset
+ if xoffset == "llx" then
+ local d = descriptions[unicode]
+ if d then
+ xoffset = - d.boundingbox[1] * hfactor
+ character.width = character.width + xoffset
+ xoffset = rightcommand[xoffset]
+ else
+ xoffset = nil
+ end
+ elseif xoffset and xoffset ~= 0 then
+ xoffset = rightcommand[xoffset * hfactor]
+ else
+ xoffset = nil
+ end
+ if yoffset and yoffset ~= 0 then
+ yoffset = upcommand[yoffset * vfactor]
+ else
+ yoffset = nil
+ end
+ if xoffset or yoffset then
+ local commands = characters.commands
+ if commands then
+ prependcommands(commands,yoffset,xoffset)
+ else
+ local slot = charcommand[unicode]
+ if xoffset and yoffset then
+ character.commands = { xoffset, yoffset, slot }
+ elseif xoffset then
+ character.commands = { xoffset, slot }
+ else
+ character.commands = { yoffset, slot }
+ end
+ end
+ end
+ elseif trace_defining then
+ report_math("no overloading dimensions of %C, not in font",unicode)
+ end
+ end
+ local function overload(dimensions)
+ for unicode, data in next, dimensions do
+ withscriptcode(tfmdata,unicode,data,overloadone)
+ end
+ end
+ if value == nil then
+ value = { "default" }
+ end
+ if value == "all" or value == true then
+ for name, value in next, dimensions do
+ overload(value)
+ end
+ else
+ if type(value) == "string" then
+ value = utilities.parsers.settings_to_array(value)
+ end
+ if type(value) == "table" then
+ for i=1,#value do
+ local d = dimensions[value[i]]
+ if d then
+ overload(d)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
end
registerotffeature {
@@ -58,7 +201,7 @@ local function initialize(goodies)
local maplines = mathgoodies.maplines
if virtuals then
for name, specification in next, virtuals do
- -- beware, they are all constructed
+ -- beware, they are all constructed ... we should be more selective
mathematics.makefont(name,specification,goodies)
end
end
@@ -77,10 +220,11 @@ end
fontgoodies.register("mathematics", initialize)
-local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end)
+-- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end)
local function initialize(tfmdata)
- if enabled and tfmdata.mathparameters then -- funny, cambria text has this
+-- if enabled and tfmdata.mathparameters then -- funny, cambria text has this
+ if tfmdata.mathparameters then -- funny, cambria text has this
local goodies = tfmdata.goodies
if goodies then
local characters = tfmdata.characters
@@ -91,12 +235,15 @@ local function initialize(tfmdata)
if mathgoodies then
local kerns = mathgoodies.kerns
if kerns then
- for unicode, specification in next, kerns do
+ local function kernone(unicode,data)
local chardata = characters[unicode]
- if chardata and (not chardata.mathkerns or specification.force) then
- chardata.mathkerns = specification
+ if chardata and (not chardata.mathkerns or data.force) then
+ chardata.mathkerns = data
end
end
+ for unicode, data in next, kerns do
+ withscriptcode(tfmdata,unicode,data,kernone)
+ end
return
end
end
@@ -109,9 +256,9 @@ local function initialize(tfmdata)
end
registerotffeature {
- name = "mathkerns",
- description = "math kerns",
- default = true,
+ name = "mathkerns",
+ description = "math kerns",
+ -- default = true,
initializers = {
base = initialize,
node = initialize,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-bmp.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-bmp.lua
index e10b01aa4b6..6669b5db1d4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-bmp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-bmp.lua
@@ -39,10 +39,6 @@ function bitmaps.new(xsize,ysize,colorspace,colordepth,mask,index)
}
end
--- function backends.codeinjections.bitmap(bitmap)
--- return lpdf.injectors.bitmap(bitmap)
--- end
-
local function flush(bitmap)
local specification = backends.codeinjections.bitmap(bitmap)
if specification then
@@ -89,7 +85,7 @@ local function placeholder(nx,ny)
end
end
- return lpdf.injectors.bitmap(bitmap)
+ return backends.codeinjections.bitmap(bitmap)
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-chk.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-chk.lua
index ed78b856c60..0cfc9ba085b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-chk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-chk.lua
@@ -35,7 +35,7 @@ function checkers.pdf(data)
local request = data.request
local used = data.used
if request and used and not request.scanimage then
- local image = lpdf.epdf.image
+ local image = lpdf.epdf.image -- ok, this is a pdf specific main function
local openpdf = image.open
local closepdf = image.close
local querypdf = image.query
@@ -127,9 +127,9 @@ function checkers.pdf(data)
return genericchecker(data)
end
-local function wrappedidentify(identify,filename)
+local function wrappedidentify(identify,filename,filetype)
local wrapup = function() report_inclusion("fatal error reading %a",filename) end
- local _, result = xpcall(identify,wrapup,filename)
+ local _, result = xpcall(identify,wrapup,filename,filetype)
if result then
local xsize = result.xsize or 0
local ysize = result.ysize or 0
@@ -163,10 +163,9 @@ function checkers.jpg(data)
local used = data.used
if request and used and not request.scanimage then
local identify = graphics.identify
- local inject = lpdf.injectors.jpg
local found = false
request.scanimage = function(t)
- local result = wrappedidentify(identify,t.filename)
+ local result = wrappedidentify(identify,t.filename,"jpg")
found = not result.error
return {
filename = result.filename,
@@ -187,7 +186,7 @@ function checkers.jpg(data)
request.copyimage = function(t)
if found then
found = false
- return inject(t)
+ return backends.codeinjections.jpg(t)
end
end
end
@@ -199,10 +198,9 @@ function checkers.jp2(data) -- idem as jpg
local used = data.used
if request and used and not request.scanimage then
local identify = graphics.identify
- local inject = lpdf.injectors.jp2
local found = false
request.scanimage = function(t)
- local result = wrappedidentify(identify,t.filename)
+ local result = wrappedidentify(identify,t.filename,"jp2")
found = not result.error
return {
filename = result.filename,
@@ -223,7 +221,7 @@ function checkers.jp2(data) -- idem as jpg
request.copyimage = function(t)
if found then
found = false
- return inject(t)
+ return backends.codeinjections.jp2(t)
end
end
end
@@ -235,10 +233,9 @@ function checkers.png(data) -- same as jpg (for now)
local used = data.used
if request and used and not request.scanimage then
local identify = graphics.identify
- local inject = lpdf.injectors.png -- currently pdf specific
local found = false
request.scanimage = function(t)
- local result = wrappedidentify(identify,t.filename)
+ local result = wrappedidentify(identify,t.filename,"png")
found = not result.error
return {
filename = result.filename,
@@ -263,7 +260,7 @@ function checkers.png(data) -- same as jpg (for now)
t.colorref = used.colorref -- this is a bit of a hack
if found then
found = false
- local ok, result = pcall(inject,t)
+ local ok, result = pcall(backends.codeinjections.png,t)
if ok then
return result
else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-con.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-con.lua
index c3c711b0c72..b3d39f0bd93 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-con.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-con.lua
@@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['grph-con'] = {
local P, R, S, Cc, C, Cs, Ct, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.Cc, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.match
local tonumber = tonumber
+local find = string.find
local longtostring = string.longtostring
local formatters = string.formatters
local expandfilename = dir.expandname
@@ -194,6 +195,22 @@ do -- svg
-- arguments change again? Ok, it's weirder, with -A then it's a name only when
-- not . (current)
+ -- Beware: the order of printed output lines is a bit random depending on the
+ -- method of calling (bin or pipe) because part of the message prints to stdout
+ -- and part to stderr. Also, on Windows, a second call to the old binaries
+ -- doesn't return anything at all, so that is also a signal of it being old.
+ -- This test will be dropped in 2021 anyway.
+
+ local new = nil
+
+ local function inkscapeformat(suffix)
+ if new == nil then
+ new = os.resultof("inkscape --version") or ""
+ new = new == "" or not find(new,"Inkscape%s*0")
+ end
+ return new and "filename" or suffix
+ end
+
local runner = sandbox.registerrunner {
name = "svg to something",
program = "inkscape",
@@ -209,7 +226,7 @@ do -- svg
resolution = "string",
},
defaults = {
- format = "pdf",
+ format = format,
resolution = "600",
}
}
@@ -220,7 +237,7 @@ do -- svg
function svgconverter.pdf(oldname,newname)
runner {
- format = "pdf",
+ format = inkscapeformat("pdf"),
resolution = "600",
newname = expandfilename(newname),
oldname = expandfilename(oldname),
@@ -229,7 +246,7 @@ do -- svg
function svgconverter.png(oldname,newname)
runner {
- format = "png",
+ format = inkscapeformat("png"),
resolution = "600",
newname = expandfilename(newname),
oldname = expandfilename(oldname),
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-epd.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-epd.lua
index f8fa62953dc..0993270f14a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-epd.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-epd.lua
@@ -40,7 +40,7 @@ local function mergegoodies(optionlist)
end
function figures.mergegoodies(optionlist)
- -- todo: we can use runtoks instead
+ -- todo: we can use runlocal instead
context.stepwise(function()
-- we use stepwise because we might need to define symbols
-- for stamps that have no default appearance
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-fig.mkiv b/Master/texmf-dist/tex/context/base/mkiv/grph-fig.mkiv
index 3bf3248a6b4..9d34a841794 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-fig.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-fig.mkiv
@@ -256,6 +256,9 @@
\tpack{\vskip12\points\box2\vskip6\points}}%
\endgroup}
+\definesystemconstant {vwa}
+\definesystemconstant {vwb}
+
\unexpanded\def\grph_steps_three_referring(#1,#2)#3(#4,#5)#6[#7]%
{\advance\c_grph_steps_reference\plusone
\position(#1,#2)
@@ -324,7 +327,7 @@
\thisissomeinternal\s!vwb
{#8}%
\gotosomeinternal\s!vwa{#8}\realfolio
- {\hbox to 1.5em{\the\c_grph_steps_reference\presetgoto\hfill}}%
+ {\hbox to 1.5em{\the\c_grph_steps_reference\hfill}}%
\quad#1 (#2,#3) (#5,#6) [#8]\hfill}%
\endgraf}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-img.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-img.lua
index 4b4bee1fc08..0dc5efa7038 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-img.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-img.lua
@@ -97,6 +97,13 @@ do
[0x01] = { name = "TEM", zerolength = true }, -- temporary use
}
+ setmetatableindex(tags, function(t,k)
+ -- we can add some tracing if needed (global) to get an idea
+ local v = "tag " .. k
+ t[k] = v
+ return v
+ end)
+
-- More can be found in http://www.exif.org/Exif2-2.PDF but basically we have
-- good old tiff tags here.
@@ -254,7 +261,7 @@ do
local length = 0
local tagdata = tags[category]
if not tagdata then
- specification.error = "invalid tag"
+ specification.error = "invalid tag " .. (category or "?")
break
elseif tagdata.supported == false then
specification.error = "unsupported " .. tagdata.comment
@@ -602,8 +609,11 @@ do
local y = f:readcardinal4()
local u = f:readcardinal()
if u == 1 then -- meters
- -- x = round(0.0254 * x)
- -- y = round(0.0254 * y)
+ -- there was a reason why this was commented
+ x = round(0.0254 * x)
+ y = round(0.0254 * y)
+ if x == 0 then x = 1 end
+ if y == 0 then y = 1 end
end
specification.xres = x
specification.yres = y
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-inc.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-inc.lua
index 8032f3c240f..6fdf74c08da 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-inc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-inc.lua
@@ -703,11 +703,11 @@ implement { name = "figurestatus", actions = { get, context }, arguments = { "
implement { name = "figurerequest", actions = { get, context }, arguments = { "'request'", "string", "string" } }
implement { name = "figureused", actions = { get, context }, arguments = { "'used'", "string", "string" } }
-implement { name = "figurefilepath", actions = { get, file.dirname, context }, arguments = { "'used'", "'fullname'" } }
-implement { name = "figurefilename", actions = { get, file.nameonly, context }, arguments = { "'used'", "'fullname'" } }
-implement { name = "figurefiletype", actions = { get, file.extname, context }, arguments = { "'used'", "'fullname'" } }
+implement { name = "figurefilepath", public = true, actions = { get, file.dirname, context }, arguments = { "'used'", "'fullname'" } }
+implement { name = "figurefilename", public = true, actions = { get, file.nameonly, context }, arguments = { "'used'", "'fullname'" } }
+implement { name = "figurefiletype", public = true, actions = { get, file.extname, context }, arguments = { "'used'", "'fullname'" } }
-implement { name = "figuresetdimensions", actions = setdimensions, arguments = { "integer" } }
+implement { name = "figuresetdimensions", actions = setdimensions, arguments = "integer" }
-- todo: local path or cache path
@@ -1377,7 +1377,6 @@ function figures.dummy(data)
du.width = du.width or figures.defaultwidth
du.height = du.height or figures.defaultheight
du.depth = du.depth or figures.defaultdepth
- -- box.dir = "TLT"
box.width = du.width
box.height = du.height
box.depth = du.depth
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-inc.mkiv b/Master/texmf-dist/tex/context/base/mkiv/grph-inc.mkiv
index 578bad1d067..0b8065989fc 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-inc.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-inc.mkiv
@@ -23,11 +23,6 @@
\registerctxluafile{grph-img}{}
\registerctxluafile{grph-inc}{}
-\ifcase\contextlmtxmode \else
- \registerctxluafile{grph-bmp}{}
- \registerctxluafile{grph-chk}{}
-\fi
-
\registerctxluafile{grph-con}{}
\registerctxluafile{grph-fil}{}
\registerctxluafile{grph-mem}{}
@@ -416,7 +411,7 @@
\else\ifx\p_crossreference\v!no
% nothing
\else\ifx\p_crossreference\v!yes
- \ifassignment
+ \ifcondition\validassignment{#2}%
\scratchcounter\clf_figure_register_page{#1}{}{#2}\relax
\else
\scratchcounter\clf_figure_register_page{#1}{#2}{#3}\relax
@@ -568,9 +563,9 @@
\def\figurefullname {\clf_figureused{fullname}{}}
\def\noffigurepages {\clf_figureused{pages}{0}}
-\def\figurefilepath {\clf_figurefilepath}
-\def\figurefilename {\clf_figurefilename}
-\def\figurefiletype {\clf_figurefiletype}
+% \def\figurefilepath {\clf_figurefilepath} % public in lua
+% \def\figurefilename {\clf_figurefilename} % public in lua
+% \def\figurefiletype {\clf_figurefiletype} % public in lua
\let\naturalfigurewidth \figurenaturalwidth
\let\naturalfigureheight \figurenaturalheight
@@ -687,7 +682,6 @@
% \vss
\vkern\ht\foundexternalfigure
%
- % \parfillskip\zeropoint
\ht\foundexternalfigure\zeropoint
\dp\foundexternalfigure\zeropoint
\hpack to \wd\foundexternalfigure\bgroup
@@ -904,25 +898,6 @@
\unexpanded\def\overlayfigure#1%
{\externalfigure[#1][\c!width=\d_overlay_width,\c!height=\d_overlay_height]}
-% Experimental (will become cleaner):
-
-\ifcase\contextlmtxmode \else
-
- \unexpanded\def\includesvgfile {\dontleavehmode\begingroup\dodoubleempty\grph_include_svg_file}
- \unexpanded\def\includesvgbuffer{\dontleavehmode\begingroup\dodoubleempty\grph_include_svg_buffer}
-
- \def\grph_include_svg_file[#1][#2]%
- {\getdummyparameters[\c!offset=\zeropoint,#2]%
- \clf_includesvgfile{#1}\dimexpr\dummyparameter\c!offset\relax
- \endgroup}
-
- \def\grph_include_svg_buffer[#1][#2]%
- {\getdummyparameters[\c!offset=\zeropoint,#2]%
- \clf_includesvgbuffer{#1}\dimexpr\dummyparameter\c!offset\relax
- \endgroup}
-
-\fi
-
% Bonus:
\useexternalfigure
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-pat.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-pat.lua
index e38a9a674d6..4310af672b7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-pat.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-pat.lua
@@ -38,7 +38,7 @@ interfaces.implement {
return
end
nodes.handlers.finalizebox(number)
- names[name] = lpdf.registerpattern {
+ names[name] = backends.codeinjections.registerpattern {
number = number,
width = specification.width or box.width,
height = specification.height or (box.height + box.depth) ,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-rul.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-rul.lua
index 5067b0165ee..0582a0ad0c8 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-rul.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-rul.lua
@@ -87,6 +87,8 @@ do
local replacer = utilities.templates.replacer
+ -- todo: RuleColor -> just string ?
+
local predefined = {
["fake:word"] = replacer [[
FakeWord(%width%,%height%,%depth%,%line%,%color%);
@@ -133,7 +135,9 @@ def RuleColor = %color% enddef ;
initialized = true
simplemetapost("rulefun",formatters["randomseed := %s;"](getrandom("rulefun",0,4095)))
end
- local pdf = caching and cache[code] or simplemetapost("rulefun",code) -- w, h, d
+ -- we enable extensions but we could also consider to delegate colors
+ -- to the node finalizer
+ local pdf = caching and cache[code] or simplemetapost("rulefun",code,true)
if trace_mp then
report_mp("code: %s",code)
report_mp("pdf : %s",pdf)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-trf.lua b/Master/texmf-dist/tex/context/base/mkiv/grph-trf.lua
new file mode 100644
index 00000000000..b152a54dba0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-trf.lua
@@ -0,0 +1,126 @@
+if not modules then modules = { } end modules ['grph-trf'] = {
+ version = 1.001,
+ comment = "companion to grph-trf.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- see grph-trf-todo.lua for older preliminary code for the rest
+
+local sind, cosd, tand, abs = math.sind, math.cosd, math.tand, math.abs
+
+local texsetdimen = tex.setdimen
+
+local function analyzerotate(rotation,width,height,depth,total,notfit,obeydepth)
+ --
+ -- print(rotation,width,height,depth,notfit,obeydepth)
+ --
+ local sin = sind(rotation)
+ local cos = cosd(rotation)
+ local abssin = abs(sin)
+ local abscos = abs(cos)
+ local xsize = 0
+ local ysize = 0
+ local xposition = 0
+ local yposition = 0
+ local xoffset = 0
+ local yoffset = 0
+ local newwidth = width
+ local newheight = height
+ local newdepth = depth
+ -- print(sin,cos)
+ if sin > 0 then
+ if cos > 0 then
+ xsize = cos * width + sin * total
+ ysize = sin * width + cos * total
+ yposition = cos * total
+ if notfit then
+ xoffset = - sin * height
+ newwidth = sin * depth + cos * width
+ else
+ newwidth = xsize + xposition - xoffset
+ end
+ if obeydepth then
+ yoffset = cos * depth
+ end
+ newheight = ysize - yoffset
+ newdepth = yoffset
+ -- print("case 1, done")
+ else
+ xsize = abscos * width + sin * total
+ ysize = sin * width + abscos * total
+ xposition = abscos * width
+ if notfit then
+ xoffset = - xsize + sin * depth
+ end
+ if obeydepth then
+ yoffset = abscos * height
+ newwidth = abssin * total + abscos * width + xoffset
+ else
+ newwidth = xsize
+ end
+ newheight = ysize - yoffset
+ newdepth = yoffset
+ -- print("case 2, done")
+ end
+ else
+ if cos < 0 then
+ xsize = abscos * width + abssin * total
+ ysize = abssin * width + abscos * total
+ xposition = xsize
+ yposition = abssin * width
+ if notfit then
+ xoffset = - xsize + abssin * height
+ end
+ if obeydepth then
+ yoffset = ysize + cos * depth
+ end
+ newwidth = notfit and (abssin * height) or xsize
+ newheight = ysize - yoffset
+ newdepth = yoffset
+ -- print("case 3, done")
+ else
+ xsize = cos * width + abssin * total
+ ysize = abssin * width + cos * total
+ xposition = abssin * total
+ yposition = cos * total
+ if notfit then
+ xoffset = - abssin * depth
+ newwidth = xsize + xoffset
+ else
+ newwidth = xsize
+ end
+ if obeydepth then
+ yoffset = cos * depth
+ end
+ newheight = ysize - yoffset + sin * width
+ newdepth = yoffset - sin * width
+ -- print("case 4, done")
+ end
+ end
+ texsetdimen("d_grph_rotate_x_size", xsize)
+ texsetdimen("d_grph_rotate_y_size", ysize)
+ texsetdimen("d_grph_rotate_x_position", xposition)
+ texsetdimen("d_grph_rotate_y_position", yposition)
+ texsetdimen("d_grph_rotate_x_offset", xoffset)
+ texsetdimen("d_grph_rotate_y_offset", yoffset)
+ texsetdimen("d_grph_rotate_new_width", newwidth)
+ texsetdimen("d_grph_rotate_new_height", newheight)
+ texsetdimen("d_grph_rotate_new_depth", newdepth)
+end
+
+interfaces.implement {
+ name = "analyzerotate",
+ actions = analyzerotate,
+ arguments = {
+-- "integer",
+ "number",
+ "dimension",
+ "dimension",
+ "dimension",
+ "dimension",
+ "conditional",
+ "conditional",
+ },
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/grph-trf.mkiv b/Master/texmf-dist/tex/context/base/mkiv/grph-trf.mkiv
index f9218036c33..d6a6acd78ca 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/grph-trf.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/grph-trf.mkiv
@@ -24,6 +24,8 @@
%D We could move the calculations to \LUA\ and clean up this lot anyway. On the
%D other hand, there is some danger of messing up so it has a real low priority.
+\registerctxluafile{grph-trf}{}
+
% local:
\newdimen\d_grph_scale_x_size
@@ -794,6 +796,8 @@
\installcorenamespace {rotatelocation}
\installcorenamespace {rotatepreset}
+% todo: scratchcounters
+
\newdimen\d_grph_rotate_x_size
\newdimen\d_grph_rotate_y_size
\newdimen\d_grph_rotate_x_offset
@@ -811,6 +815,10 @@
\let\d_grph_rotate_saved_height\!!heightb
\let\d_grph_rotate_saved_depth \!!depthb
+\let\d_grph_rotate_new_width \!!widthc
+\let\d_grph_rotate_new_height\!!heightc
+\let\d_grph_rotate_new_depth \!!depthc
+
\newconditional\c_grph_rotate_obey_depth
\newconditional\c_grph_rotate_not_fit
\newconditional\c_grph_rotate_center
@@ -948,111 +956,30 @@
\d_grph_rotate_saved_width \wd\nextbox
\d_grph_rotate_saved_height\ht\nextbox
\d_grph_rotate_saved_depth \dp\nextbox
- \setbox\nextbox\naturalvpack{\vskip.5\ht\nextbox\hskip-.5\wd\nextbox\box\nextbox}%
+ \setbox\nextbox\naturalhpack{\hskip-.5\wd\nextbox\lower.5\ht\nextbox\box\nextbox}%
\smashbox\nextbox
\fi
+ %
\d_grph_rotate_width \wd\nextbox
\d_grph_rotate_height\ht\nextbox
\d_grph_rotate_depth \dp\nextbox
- \setbox\nextbox\naturalvpack{\naturalhpack{\raise\dp\nextbox\box\nextbox}}%
- \d_grph_rotate_used_height \ht\nextbox
- % much of the next happens in lua (all the sin and cos) so we can do that in
- % one go if needed
- \setcalculatedcos\cos\p_rotation_rotation
- \setcalculatedsin\sin\p_rotation_rotation
- \ifdim\sin\points>\zeropoint
- \ifdim\cos\points>\zeropoint
- \grph_rotate_calculate_a
- \grph_rotate_apply
- \else
- \grph_rotate_calculate_b
- \grph_rotate_apply
- \wd\nextbox\ifconditional\c_grph_rotate_not_fit\sin\d_grph_rotate_depth\else\d_grph_rotate_x_size\fi
- \fi
- \else
- \ifdim\cos\points<\zeropoint
- \grph_rotate_calculate_c
- \grph_rotate_apply
- \wd\nextbox\ifconditional\c_grph_rotate_not_fit\negated\sin\d_grph_rotate_height\else\d_grph_rotate_x_size\fi
- \else\ifdim\sin\points=\zeropoint
- \grph_rotate_calculate_d
- \grph_rotate_apply
- % no wd ?
- \else
- \grph_rotate_calculate_e
- \grph_rotate_apply
- \wd\nextbox\ifconditional\c_grph_rotate_not_fit\negated\sin\d_grph_rotate_height\else\d_grph_rotate_x_size\fi
- \fi\fi
- \fi
- \ifconditional\c_grph_rotate_center
- \setbox\nextbox\naturalvpack{\vskip-.5\d_grph_rotate_saved_height\hskip.5\d_grph_rotate_saved_height\box\nextbox}%
- \wd\nextbox\d_grph_rotate_saved_width
- \ht\nextbox\d_grph_rotate_saved_height
- \dp\nextbox\d_grph_rotate_saved_depth
- \fi
- \boxcursor\box\nextbox}
-
-\def\grph_rotate_calculate_a
- {\d_grph_rotate_x_size\dimexpr\cos\d_grph_rotate_width+\sin\d_grph_rotate_used_height\relax
- \d_grph_rotate_y_size\dimexpr\sin\d_grph_rotate_width+\cos\d_grph_rotate_used_height\relax
- \d_grph_rotate_x_position\zeropoint
- \d_grph_rotate_y_position\cos\d_grph_rotate_used_height
- \ifconditional\c_grph_rotate_not_fit
- \d_grph_rotate_x_offset\dimexpr\negated\sin\d_grph_rotate_used_height+\sin\d_grph_rotate_depth\relax
- \fi
- \ifconditional\c_grph_rotate_obey_depth
- \d_grph_rotate_y_offset\cos\d_grph_rotate_depth
- \fi}
-
-\def\grph_rotate_calculate_b
- {\d_grph_rotate_x_size\dimexpr\negated\cos\d_grph_rotate_width+\sin\d_grph_rotate_used_height\relax
- \d_grph_rotate_y_size\dimexpr\sin\d_grph_rotate_width+\negated\cos\d_grph_rotate_used_height\relax
- \d_grph_rotate_x_position\negated\cos\d_grph_rotate_width
- \d_grph_rotate_y_position\zeropoint
- \ifconditional\c_grph_rotate_not_fit
- \d_grph_rotate_x_offset\dimexpr-\d_grph_rotate_x_size+\sin\d_grph_rotate_depth\relax
- \fi
- \ifconditional\c_grph_rotate_obey_depth
- \d_grph_rotate_y_offset\negated\cos\d_grph_rotate_height
- \fi}
-
-\def\grph_rotate_calculate_c
- {\d_grph_rotate_x_size\dimexpr\negated\cos\d_grph_rotate_width+\negated\sin\d_grph_rotate_used_height\relax
- \d_grph_rotate_y_size\dimexpr\negated\sin\d_grph_rotate_width+\negated\cos\d_grph_rotate_used_height\relax
- \d_grph_rotate_x_position\d_grph_rotate_x_size
- \d_grph_rotate_y_position\negated\sin\d_grph_rotate_width
- \ifconditional\c_grph_rotate_not_fit
- \d_grph_rotate_x_offset\dimexpr-\d_grph_rotate_x_size+\negated\sin\d_grph_rotate_height\relax
- \fi
- \ifconditional\c_grph_rotate_obey_depth
- \d_grph_rotate_y_offset\dimexpr\d_grph_rotate_y_size+\cos\d_grph_rotate_depth\relax
- \fi}
-
-\def\grph_rotate_calculate_d
- {\d_grph_rotate_x_size\dimexpr\cos\d_grph_rotate_width+\negated\sin\d_grph_rotate_used_height\relax
- \d_grph_rotate_y_size\dimexpr\negated\sin\d_grph_rotate_width+\cos\d_grph_rotate_used_height\relax
- \d_grph_rotate_x_position\zeropoint
- \d_grph_rotate_y_position\d_grph_rotate_y_size
- \d_grph_rotate_x_offset\zeropoint
- \ifconditional\c_grph_rotate_obey_depth
- \d_grph_rotate_y_offset\d_grph_rotate_depth
- \fi}
-
-\def\grph_rotate_calculate_e
- {\d_grph_rotate_x_size\dimexpr\cos\d_grph_rotate_width+\negated\sin\d_grph_rotate_used_height\relax
- \d_grph_rotate_y_size\dimexpr\negated\sin\d_grph_rotate_width+\cos\d_grph_rotate_used_height\relax
- \d_grph_rotate_x_position\negated\sin\d_grph_rotate_used_height
- \d_grph_rotate_y_position\d_grph_rotate_y_size
- \ifconditional\c_grph_rotate_not_fit
- \d_grph_rotate_x_offset\dimexpr-\d_grph_rotate_x_size+\negated\sin\d_grph_rotate_height\relax
- \fi
- \ifconditional\c_grph_rotate_obey_depth
- \d_grph_rotate_y_offset\negated\sin\d_grph_rotate_depth
- \fi}
-
-\def\grph_rotate_apply
- {\setbox\nextbox\naturalvpack to \d_grph_rotate_y_size
- {\vfill
+ %
+ \setbox\nextbox\naturalvpack{\naturalhpack{\raise\dp\nextbox\box\nextbox}}% can we do without
+ %
+ \d_grph_rotate_used_height\ht\nextbox
+ %
+ \clf_analyzerotate % rather accurate
+ \p_rotation_rotation\space
+ \d_grph_rotate_width
+ \d_grph_rotate_height
+ \d_grph_rotate_depth
+ \d_grph_rotate_used_height
+ \c_grph_rotate_not_fit
+ \c_grph_rotate_obey_depth
+ \relax
+ %
+ \setbox\nextbox\naturalvpack to \d_grph_rotate_y_size
+ {\vfilll
\naturalhpack to \d_grph_rotate_x_size
{\dostartrotation\p_rotation_rotation
\wd\nextbox\zeropoint
@@ -1061,9 +988,24 @@
\dostoprotation
\hfill}%
\kern\d_grph_rotate_y_position}%
+ %
\setbox\nextbox\naturalhpack
{\kern\dimexpr\d_grph_rotate_x_position+\d_grph_rotate_x_offset\relax
- \lower\d_grph_rotate_y_offset\box\nextbox}}
+ \lower\d_grph_rotate_y_offset
+ \box\nextbox}%
+ %
+ \ifconditional\c_grph_rotate_center
+ \setbox\nextbox\naturalhpack{\hskip.5\d_grph_rotate_saved_width\lower-.5\d_grph_rotate_saved_height\box\nextbox}%
+ \wd\nextbox\d_grph_rotate_saved_width
+ \ht\nextbox\d_grph_rotate_saved_height
+ \dp\nextbox\d_grph_rotate_saved_depth
+ \else
+ \wd\nextbox\d_grph_rotate_new_width
+ \ht\nextbox\d_grph_rotate_new_height
+ \dp\nextbox\d_grph_rotate_new_depth
+ \fi
+ %
+ \boxcursor\box\nextbox}
% \dostepwiserecurse{0}{360}{10}
% {\startlinecorrection[blank]
@@ -1077,4 +1019,23 @@
% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=high] {\ruledhbox{\bfb (high)}}}}}
% \stoplinecorrection}
+% \def\Test{\ruledhbox{%
+% \def\DemoX{\vl\kern.5\emwidth\vl}%
+% \kern\emwidth\ruledhpack{\green\rotate[rotation=20] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\blue \rotate[rotation=0] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\red \rotate[rotation=-20] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\green\rotate[rotation=200] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\blue \rotate[rotation=180] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\red \rotate[rotation=-200]{\ruledhpack{\DemoX}}}%
+% \kern\emwidth}}
+
+% \startTEXpage[offset=10pt,align=middle]
+% \setuprotate[location=fit] \Test \par {\infofont\setstrut\strut fit} \par
+% \setuprotate[location=depth] \Test \par {\infofont\setstrut\strut depth} \par
+% \setuprotate[location=broad] \Test \par {\infofont\setstrut\strut broad} \par
+% \setuprotate[location=high] \Test \par {\infofont\setstrut\strut high} \par
+% \setuprotate[location=middle] \Test \par {\infofont\setstrut\strut middle} \par
+% \setuprotate[location=default] \Test \par {\infofont\setstrut\strut default} \par
+% \stopTEXpage
+
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/hand-ini.mkxl b/Master/texmf-dist/tex/context/base/mkiv/hand-ini.mkxl
deleted file mode 100644
index ca6922dddeb..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/hand-ini.mkxl
+++ /dev/null
@@ -1,111 +0,0 @@
-%D \module
-%D [ file=hand-ini,
-%D version=2008.02.12,
-%D title=\CONTEXT\ Handling Macros,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D Handling is implemented differently in \MKIV. Maybe I'll cook up
-%D some compatibility hack.
-
-% \definefontfeature[demo][default][mode=node,expansion=quality]
-% \definefontfeature[demo][default][mode=node,protrusion=pure]
-
-% experimental setup:
-%
-% \showframe \setupalign[hanging] \enabletrackers[fonts.protrusion]
-%
-% \definefontfeature[default] [default][mode=node,script=latn]
-% %definefontfeature[whatever][default][mode=node,lfbd=yes,rtbd=yes,script=latn]
-% \definefontfeature[whatever][default][mode=node,protrusion=quality]
-% \definefontfeature[whocares][default][mode=node,protrusion=yes,opbd=yes,script=latn] % left|right|yes
-%
-% \definedfont[fxlbi.otf*default] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
-% \definedfont[fxlbi.otf*whatever] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
-% \definedfont[fxlbi.otf*whocares] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
-%
-% %definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn,featurefile=texgyrepagella-regularxx.fea]
-% \definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn]
-%
-% \definedfont[texgyrepagella-regularxx.otf*whocares] \input tufte
-
-\unprotect
-
-%D New stuff.
-
-\unexpanded\def\setupfontexpansion {\dodoubleargument\font_expansion_setup }
-\unexpanded\def\setupfontprotrusion{\dodoubleargument\font_protrusion_setup}
-
-\def\font_expansion_setup [#1][#2]{\clf_setupfontexpansion {#1}{#2}}
-\def\font_protrusion_setup[#1][#2]{\clf_setupfontprotrusion{#1}{#2}}
-
-% \setupfontprotrusion[quality-upright][vector=quality]
-% \setupfontprotrusion[quality-slanted][vector=quality,right=1.5]
-
-\let\adjustspacing\relax \newcount\adjustspacing % a little bit protection
-\let\protrudechars\relax \newcount\protrudechars % a little bit protection
-
-% at some point we can introduce extreme expansion, i.e. \normaladjustspacing\plustwo
-
-% 0 = disabled
-% 1 = notused (thesis)
-% 2 = glyph + kern
-% 3 = glyph only
-
-\def\font_expansion_enable {\normaladjustspacing\plusthree}
-\def\font_expansion_enable_k{\normaladjustspacing\plustwo}
-%def\font_expansion_enable_n{\normaladjustspacing\plusone}
-\def\font_expansion_disable {\normaladjustspacing\zerocount}
-
-\def\font_protruding_enable_b{\normalprotrudechars\plusthree} % also deal with r2l (experimental lmtx)
-\def\font_protruding_enable {\normalprotrudechars\plustwo }
-\def\font_protruding_disable {\normalprotrudechars\zerocount}
-
-\appendtoks \font_expansion_disable \to \everyforgetall % Here or not here?
-\appendtoks \font_protruding_disable \to \everyforgetall % Here or not here?
-
-% \def\fonthandlingerror{\writestatus\m!fonts{font handling is replaced by features in mkiv}}
-%
-% \let\fonthandling\empty
-%
-% \unexpanded\def\startfonthandling #1{\fonthandlingerror\fonthandlingerror\gobbleuntil\stopfonthandling} % can't happen
-% \unexpanded\def\definefonthandling {\dotripleempty\dodefinefonthandling}
-% \unexpanded\def\setupfonthandling {\dodoubleempty\dosetupfonthandling }
-% \def\dodefinefonthandling[#1][#2][#3]{\fonthandlingerror}
-% \def\dosetupfonthandling [#1][#2]{\fonthandlingerror}
-% \def\usehandling [#1]{\fonthandlingerror}
-
-\installcorenamespace{expansion}
-
-\installcommandhandler \??expansion {expansion} \??expansion
-
-\appendtoks
- \setuevalue{\??expansion:\currentexpansion}%
- {\adjustspacingstep \expansionparameter\c!step\relax
- \adjustspacingstretch\expansionparameter\c!stretch\relax
- \adjustspacingshrink \expansionparameter\c!shrink\relax}%
-\to \everydefineexpansion
-
-\defineexpansion
- [\c!step=1,
- \c!stretch=40,
- \c!shrink=20]
-
-% \defineexpansion
-% [myexpansion]
-% [\c!stretch=50,
-% \c!shrink=20]
-
-\unexpanded\def\setexpansion
- {\dosingleempty\font_expansion_set}
-
-\unexpanded\def\font_expansion_set[#1]%
- {\begincsname\??expansion:#1\endcsname}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-lpeg.lua b/Master/texmf-dist/tex/context/base/mkiv/l-lpeg.lua
index 7979a40fb94..b0868ba4886 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/l-lpeg.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/l-lpeg.lua
@@ -203,12 +203,14 @@ local collapser = Cs(spacer^0/"" * nonspacer^0 * ((spacer^0/" " * nonspac
local nospacer = Cs((whitespace^1/"" + nonwhitespace^1)^0)
local b_collapser = Cs( whitespace^0 /"" * (nonwhitespace^1 + whitespace^1/" ")^0)
-local e_collapser = Cs((whitespace^1 * endofstring/"" + nonwhitespace^1 + whitespace^1/" ")^0)
local m_collapser = Cs( (nonwhitespace^1 + whitespace^1/" ")^0)
+local e_collapser = Cs((whitespace^1 * endofstring/"" + nonwhitespace^1 + whitespace^1/" ")^0)
+local x_collapser = Cs( (nonwhitespace^1 + whitespace^1/"" )^0)
local b_stripper = Cs( spacer^0 /"" * (nonspacer^1 + spacer^1/" ")^0)
-local e_stripper = Cs((spacer^1 * endofstring/"" + nonspacer^1 + spacer^1/" ")^0)
local m_stripper = Cs( (nonspacer^1 + spacer^1/" ")^0)
+local e_stripper = Cs((spacer^1 * endofstring/"" + nonspacer^1 + spacer^1/" ")^0)
+local x_stripper = Cs( (nonspacer^1 + spacer^1/"" )^0)
patterns.stripper = stripper
patterns.fullstripper = fullstripper
@@ -218,10 +220,12 @@ patterns.nospacer = nospacer
patterns.b_collapser = b_collapser
patterns.m_collapser = m_collapser
patterns.e_collapser = e_collapser
+patterns.x_collapser = x_collapser
patterns.b_stripper = b_stripper
patterns.m_stripper = m_stripper
patterns.e_stripper = e_stripper
+patterns.x_stripper = x_stripper
patterns.lowercase = lowercase
patterns.uppercase = uppercase
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-lua.lua b/Master/texmf-dist/tex/context/base/mkiv/l-lua.lua
index f411230d4aa..00989c5cea7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/l-lua.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/l-lua.lua
@@ -195,12 +195,6 @@ function optionalrequire(...)
end
end
--- nice for non ascii scripts (this might move):
-
-if lua then
- lua.mask = load([[τεχ = 1]]) and "utf" or "ascii"
-end
-
local flush = io.flush
if flush then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-os.lua b/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
index 9aa8b8aa78c..73841074c46 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/l-os.lua
@@ -358,6 +358,8 @@ elseif name == "macosx" then
platform = "osx-intel"
elseif find(architecture,"x86_64",1,true) then
platform = "osx-64"
+ elseif find(architecture,"arm64",1,true) then
+ platform = "osx-64"
else
platform = "osx-ppc"
end
@@ -604,11 +606,19 @@ os.isleapyear = isleapyear
local days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-local function nofdays(year,month)
+local function nofdays(year,month,day)
if not month then
return isleapyear(year) and 365 or 364
- else
+ elseif not day then
return month == 2 and isleapyear(year) and 29 or days[month]
+ else
+ for i=1,month-1 do
+ day = day + days[i]
+ end
+ if month > 2 and isleapyear(year) then
+ day = day + 1
+ end
+ return day
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-package.lua b/Master/texmf-dist/tex/context/base/mkiv/l-package.lua
index 0dd71e5eca8..ef37aebe74e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/l-package.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/l-package.lua
@@ -16,7 +16,7 @@ if not modules then modules = { } end modules ['l-package'] = {
-- -- local mylib = require("libtest")
-- -- local mysql = require("luasql.mysql")
-local type = type
+local type, unpack = type, unpack
local gsub, format, find = string.gsub, string.format, string.find
local insert, remove = table.insert, table.remove
@@ -54,7 +54,7 @@ local function lualibfile(name)
return lpegmatch(pattern,name) or name
end
-local offset = luarocks and 1 or 0 -- todo: also check other extras
+local offset = luarocks and 1 or 0 -- todo: also check other extras ... we'll drop this luarocks anyway
local helpers = package.helpers or {
cleanpath = cleanpath,
@@ -70,6 +70,7 @@ local helpers = package.helpers or {
methods = {
},
sequence = {
+ "reset loaded",
"already loaded",
"preload table",
"qualified path", -- beware, lua itself doesn't handle qualified paths (prepends ./)
@@ -91,6 +92,7 @@ local builtin = helpers.builtin
local extraluapaths = { }
local extralibpaths = { }
+local checkedfiles = { }
local luapaths = nil -- delayed
local libpaths = nil -- delayed
local oldluapath = nil
@@ -245,10 +247,17 @@ local function loadedaslib(resolved,rawname) -- todo: strip all before first -
-- so, we can do a require("foo/bar") and initialize bar
-- local base = gsub(file.basename(rawname),"%.","_")
local init = "luaopen_" .. gsub(base,"%.","_")
+ local data = { resolved, init, "" }
+ checkedfiles[#checkedfiles+1] = data
if helpers.trace then
helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
- return package.loadlib(resolved,init)
+ local a, b, c = package.loadlib(resolved,init)
+ if not a and type(b) == "string" then
+-- data[3] = gsub(b or "unknown error","[\n\r]","")
+ data[3] = string.fullstrip(b or "unknown error")
+ end
+ return a, b, c -- c can be 'init'
end
helpers.loadedaslib = loadedaslib
@@ -295,12 +304,21 @@ end
helpers.loadedbyname = loadedbyname
+methods["reset loaded"] = function(name)
+ checkedfiles = { }
+ return false
+end
+
+
methods["already loaded"] = function(name)
return package.loaded[name]
end
methods["preload table"] = function(name)
- return builtin["preload table"](name)
+ local f = builtin["preload table"]
+ if f then
+ return f(name)
+ end
end
methods["qualified path"]=function(name)
@@ -316,22 +334,34 @@ methods["lib extra list"] = function(name)
end
methods["path specification"] = function(name)
- getluapaths() -- triggers list building and tracing
- return builtin["path specification"](name)
+ local f = builtin["path specification"]
+ if f then
+ getluapaths() -- triggers list building and tracing
+ return f(name)
+ end
end
methods["cpath specification"] = function(name)
- getlibpaths() -- triggers list building and tracing
- return builtin["cpath specification"](name)
+ local f = builtin["cpath specification"]
+ if f then
+ getlibpaths() -- triggers list building and tracing
+ return f(name)
+ end
end
methods["all in one fallback"] = function(name)
- return builtin["all in one fallback"](name)
+ local f = builtin["all in one fallback"]
+ if f then
+ return f(name)
+ end
end
methods["not loaded"] = function(name)
if helpers.trace then
helpers.report("unable to locate '%s'",name or "?")
+ for i=1,#checkedfiles do
+ helpers.report("checked file '%s', initializer '%s', message '%s'",unpack(checkedfiles[i]))
+ end
end
return nil
end
@@ -346,19 +376,22 @@ function helpers.loaded(name)
level = level + 1
for i=1,#sequence do
local method = sequence[i]
- if helpers.trace then
- helpers.report("%s, level '%s', method '%s', name '%s'","locating",level,method,name)
- end
- local result, rest = methods[method](name)
- if type(result) == "function" then
+ local lookup = method and methods[method]
+ if type(lookup) == "function" then
if helpers.trace then
- helpers.report("%s, level '%s', method '%s', name '%s'","found",level,method,name)
+ helpers.report("%s, level '%s', method '%s', name '%s'","locating",level,method,name)
end
- if helpers.traceused then
- used[#used+1] = { level = level, name = name }
+ local result, rest = lookup(name)
+ if type(result) == "function" then
+ if helpers.trace then
+ helpers.report("%s, level '%s', method '%s', name '%s'","found",level,method,name)
+ end
+ if helpers.traceused then
+ used[#used+1] = { level = level, name = name }
+ end
+ level = level - 1
+ return result, rest
end
- level = level - 1
- return result, rest
end
end
-- safeguard, we never come here
diff --git a/Master/texmf-dist/tex/context/base/mkiv/l-unicode.lua b/Master/texmf-dist/tex/context/base/mkiv/l-unicode.lua
index c57aaf33ebc..03016ed9010 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/l-unicode.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/l-unicode.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['l-unicode'] = {
version = 1.001,
+ optimize = true,
comment = "companion to luat-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-def.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-def.mkiv
index 7f3e85f0812..85c1f3ac775 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-def.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-def.mkiv
@@ -256,17 +256,18 @@
\c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
\installlanguage
- [\s!sl]
- [\c!spacing=\v!packed,
- \c!leftsentence=\hbox{\endash\space},
- \c!rightsentence=\hbox{\space\endash},
- \c!leftsubsentence=\endash,
- \c!rightsubsentence=\endash,
- \c!leftquote=\guilsingleright,
- \c!rightquote=\guilsingleleft,
- \c!leftquotation=\rightguillemot,
- \c!rightquotation=\leftguillemot,
- \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+ [\s!sl]
+ [\c!command=\v!no,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\guilsingleright,
+ \c!rightquote=\guilsingleleft,
+ \c!leftquotation=\rightguillemot,
+ \c!rightquotation=\leftguillemot,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
\installlanguage [\s!polish] [\s!pl]
\installlanguage [\s!czech] [\s!cs]
@@ -308,8 +309,55 @@
\c!date={\v!day,\space,\v!month,\space,\v!year},
\s!patterns=\s!uk]
-\installlanguage [\s!russian] [\s!ru]
-\installlanguage [\s!ukrainian] [\s!ua]
+\installlanguage
+ [\s!be]
+ [\s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\leftguillemot,
+ \c!rightsentence=\rightguillemot,
+ \c!leftsubsentence=\lowerleftdoubleninequote,
+ \c!rightsubsentence=\upperrightdoublesixquote,
+ \c!leftquote=\lowerleftdoubleninequote,
+ \c!rightquote=\upperrightdoublesixquote,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+ \installlanguage
+ [\s!sr]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\upperrightsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperleftdoubleninequote,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!mk]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\endash,
+ \c!rightsentence=\endash,
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\upperleftsingleninequote,
+ \c!rightquote=\upperrightsinglesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage [\s!russian] [\s!ru]
+\installlanguage [\s!ukrainian] [\s!ua]
+\installlanguage [\s!belarussian][\s!be]
+\installlanguage [\s!serbian] [\s!sr]
+\installlanguage [\s!sr-latn] [\s!sr]
+\installlanguage [\s!sr-cyrl] [\s!sr]
+\installlanguage [\s!macedonian] [\s!mk]
+
% Uralic Languages: Cheremiss, Estonian, Finnish, Karelian, Laap,
% Mordvinian, Permian tongues, Hungarian, Ostyak, Vogul, Samoyed
@@ -413,7 +461,12 @@
\c!rightquotation=\upperrightdoubleninequote,
\c!date={\v!day,\space,\v!month,{،\space},\v!year}]
-\installlanguage [\s!hebrew] [\s!he]
+\installlanguage % same as arabic now .. someone needs to fix this
+ [\s!yi]
+ [\s!he]
+
+\installlanguage [\s!hebrew] [\s!he]
+\installlanguage [\s!yiddish] [\s!yi]
% Arabic Languages
@@ -484,11 +537,28 @@
% Artificial Languages: Esperanto
+\installlanguage
+ [\s!esperanto]
+ [%\c!spacing=\v!packed,
+ %\c!leftsentence=\emdash,
+ %\c!rightsentence=\emdash,
+ %\c!leftsubsentence=\emdash,
+ %\c!rightsubsentence=\emdash,
+ %\c!leftquote=\lowerleftdoubleninequote,
+ %\c!rightquote=\upperrightdoublesixquote,
+ %\c!leftquotation=\lowerleftdoubleninequote,
+ %\c!rightquotation=\upperrightdoublesixquote,
+ %\c!date={\v!year,~m.,\space,\v!month,\space,\v!day,~d.},
+ \s!patterns=eo,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=2]
+
% Baltic Languages: Lettish/Latvian, Lietuvių/Lithuanian
\installlanguage
[\s!lt]
- [\c!spacing=\v!packed,
+ [\c!command=\v!no,
+ \c!spacing=\v!packed,
\c!leftsentence=\emdash,
\c!rightsentence=\emdash,
\c!leftsubsentence=\emdash,
@@ -583,9 +653,6 @@
% Sardian, Catalan, French, Ladino, Portuguese, Proven\c{c}al,
% Spanish
-\ifdefined\guillemotspace \else \let\guillemotspace\empty \fi
-\ifdefined\sentencespace \else \let\sentencespace \empty \fi
-
\installlanguage
[\s!fr]
[\c!spacing=\v!packed,
@@ -632,7 +699,8 @@
\installlanguage
[\s!it]
- [\c!spacing=\v!packed,
+ [\c!command=\v!no,
+ \c!spacing=\v!packed,
\c!leftsentence=\emdash,
\c!rightsentence=\emdash,
\c!leftsubsentence=\endash,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua
index 90e84f65d42..3e4678801f5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua
@@ -28,7 +28,7 @@ local getchar = nuts.getchar
local setchar = nuts.setchar
local getdisc = nuts.getdisc
local setdisc = nuts.setdisc
-local getlang = nuts.setlang
+local getlanguage = nuts.getlanguage
local getboth = nuts.getboth
local setlist = nuts.setlist
local setlink = nuts.setlink
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-exp.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-exp.lua
index 254961ee6f9..c2eb46990aa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-exp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-exp.lua
@@ -116,7 +116,7 @@ if LUATEXVERSION < 1.005 then -- not loaded any more
end
end
if template then
- local language = template and getlang(template)
+ local language = template and getlanguage(template)
local data = getlanguagedata(language)
local prechar = data.prehyphenchar
local postchar = data.posthyphenchar
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.lua
index 93457c7a22c..ca9f519cee4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.lua
@@ -644,7 +644,7 @@ if context then
local getprev = nuts.getprev
local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
- local getlang = nuts.getlang
+ local getlanguage = nuts.getlanguage
local getattrlist = nuts.getattrlist
local setattrlist = nuts.setattrlist
local isglyph = nuts.isglyph
@@ -1410,7 +1410,7 @@ featureset.hyphenonly = hyphenonly == v_yes
if skipping then
current = getnext(current)
else
- local lang = getlang(current)
+ local lang = getlanguage(current)
local font = getfont(current)
if lang ~= language or font ~= lastfont then
if dictionary and size > charmin and leftmin + rightmin <= size then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.mkiv
index 9301fd1d873..d8fbb0b229a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-hyp.mkiv
@@ -30,8 +30,8 @@
\writestatus{loading}{ConTeXt Language Macros / Initialization}
-\registerctxluafile{lang-dis}{}
-\registerctxluafile{lang-hyp}{}
+\registerctxluafile{lang-dis}{autosuffix}
+\registerctxluafile{lang-hyp}{autosuffix}
\unprotect
@@ -45,8 +45,10 @@
\newcount\compoundhyphenpenalty
-\automatichyphenmode \plusone
-\hyphenpenaltymode \plusfour
+\ifcase\contextlmtxmode
+ \hyphenpenaltymode\plusfour
+ \automatichyphenmode\plusone
+\fi
\hyphenpenalty 50 % hyphenator
\automatichyphenpenalty 50 % -
@@ -150,7 +152,7 @@ rightedge {\dummyparameter\c!rightedge}%
{\clf_sethyphenationfeatures{#1}}
\unexpanded\def\resethyphenationfeatures
- {\hyphenationattribute\attributeunsetvalue}
+ {\attribute\hyphenationattribute\attributeunsetvalue}
\resethyphenationfeatures
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-imp-serbian.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-imp-serbian.lua
new file mode 100644
index 00000000000..377d6dfde1d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-imp-serbian.lua
@@ -0,0 +1,38 @@
+return {
+ transliterations = {
+ ["serbian to latin"] = {
+ mapping = {
+ ["А"] = "A", ["а"] = "a",
+ ["Б"] = "B", ["б"] = "b",
+ ["В"] = "V", ["в"] = "v",
+ ["Г"] = "G", ["г"] = "g",
+ ["Д"] = "D", ["д"] = "d",
+ ["Е"] = "E", ["е"] = "e",
+ ["Ж"] = "Ž", ["ж"] = "ž",
+ ["З"] = "Z", ["з"] = "z",
+ ["И"] = "I", ["и"] = "i",
+ ["Й"] = "J", ["й"] = "j",
+ ["К"] = "K", ["к"] = "k",
+ ["Л"] = "L", ["л"] = "l",
+ ["М"] = "M", ["м"] = "m",
+ ["Н"] = "N", ["н"] = "n",
+ ["О"] = "O", ["о"] = "o",
+ ["П"] = "P", ["п"] = "p",
+ ["Р"] = "R", ["р"] = "r",
+ ["С"] = "S", ["с"] = "s",
+ ["Т"] = "T", ["т"] = "t",
+ ["У"] = "U", ["у"] = "u",
+ ["Ф"] = "F", ["ф"] = "f",
+ ["Х"] = "Ch", ["х"] = "ch",
+ ["Ц"] = "C", ["ц"] = "c",
+ ["Ч"] = "Č", ["ч"] = "č",
+ ["Ш"] = "Š", ["ш"] = "š",
+ ["Щ"] = "Št", ["щ"] = "št",
+ ["Ъ"] = "Ă", ["ъ"] = "ă",
+ ["Ь"] = "′", ["ь"] = "′",
+ ["Ю"] = "Ju", ["ю"] = "ju",
+ ["Я"] = "Ja", ["я"] = "ja",
+ }
+ }
+ }
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-ini.lua
index ce2b89f3c97..7a8aab8183f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-ini.lua
@@ -48,8 +48,7 @@ local sethjcode = lang.sethjcode
local uccodes = characters.uccodes
local lccodes = characters.lccodes
-lang.exceptions = lang.hyphenation
-local new_langage = lang.new
+local new_language = lang.new
languages = languages or {}
local languages = languages
@@ -85,7 +84,7 @@ local function resolve(tag)
if data then
instance = data.instance
if not instance then
- instance = new_langage(data.number)
+ instance = new_language(data.number)
data.instance = instance
end
end
@@ -101,7 +100,7 @@ local function tolang(what) -- returns lang object
if data then
local instance = data.lang
if not instance then
- instance = new_langage(data.number)
+ instance = new_language(data.number)
data.instance = instance
end
return instance
@@ -502,6 +501,14 @@ else
end
end
+ if CONTEXTLMTXMODE > 0 then
+ numbers[0] = "null"
+ registered.null = {
+ number = 0,
+ instance = new_language(0),
+ }
+ end
+
end
-- not that usefull, global values
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkiv
index f9d7e0f510f..ffa280b053d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkiv
@@ -311,7 +311,7 @@
\c!time={h,:,m},
\c!date={\v!year,\ ,\v!month,\ ,\v!day},
\c!text=Ag,
- \s!font=] % \v!auto : experimental !
+ \c!font=] % \v!auto : experimental !
% to be tested:
%
@@ -430,6 +430,12 @@
\let\dohyphens\relax
+\unexpanded\def\usehyphensparameter#1%
+ {\edef\p_hyphens{#1\c!hyphens}%
+ \ifx\p_hyhens\v!no
+ \nohyphens
+ \fi}
+
\unexpanded\def\lang_basics_synchronize_min_max % maybe store this at the lua end
{% these values are stored along with glyph nodes
\lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin +\hyphenminoffset\relax
@@ -486,12 +492,12 @@
\unexpanded\def\setuplanguages
{\setuplanguage[\s!default]}
-% \setuplanguages[\s!font=\v!auto]
-% \setuplanguage[\s!default][\s!font=\v!auto]
-% \setuplanguage[nl][\s!font=\v!auto]
+% \setuplanguages[\c!font=\v!auto]
+% \setuplanguage[\s!default][\c!font=\v!auto]
+% \setuplanguage[nl][\c!font=\v!auto]
\appendtoks
- \edef\p_language_font{\languageparameter\s!font}%
+ \edef\p_language_font{\languageparameter\c!font}%
\ifx\p_language_font\empty\else
\ifx\p_language_font\v!auto
\doaddfeature\currentlanguage
@@ -717,9 +723,16 @@
%D New:
-\unexpanded\def\traceddiscretionary#1#2#3%
- {\dontleavehmode
- \discretionary{\darkred#1}{\darkgreen#2}{\darkblue#3}}
+\unexpanded\def\traceddiscretionary#1#%
+ {\dontleavehmode\lang_basics_traced_discretionary{#1}}
+
+\unexpanded\def\lang_basics_traced_discretionary#1#2#3#4%
+ {\normaldiscretionary#1{\darkred#2}{\darkgreen#3}{\darkblue#4}}
+
+\installtextracker
+ {discretionaries}
+ {\let\discretionary\traceddiscretionary}
+ {\let\discretionary\normaldiscretionary}
\unexpanded\def\samplediscretionary
{\traceddiscretionary
@@ -727,6 +740,4 @@
{\clf_currentposthyphenchar post}%
{replace}}
-% todo: make this configurable
-
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkxl b/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkxl
deleted file mode 100644
index 8bcba01d8d0..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-ini.mkxl
+++ /dev/null
@@ -1,730 +0,0 @@
-%D \module
-%D [ file=lang-ini,
-%D version=1996.01.25,
-%D title=\CONTEXT\ Language Macros,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D This module needs a further cleanup (real split between ii/iv).
-
-% \cldcontext{languages.numbers[tex.count.mainlanguagenumber]}
-
-%D This module implements multi||language support of \CONTEXT, which should not be
-%D confused with the multi||lingual interface. This support will be extended when
-%D needed. Properties of languages are defined in \TEX\ files as well as \LUA\
-%D files.
-
-\writestatus{loading}{ConTeXt Language Macros / Initialization}
-
-\registerctxluafile{lang-ini}{}
-\registerctxluafile{lang-def}{}
-\registerctxluafile{lang-cnt}{}
-
-\unprotect
-
-\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi
-\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi
-
-%D When loading hyphenation patterns, \TEX\ assign a number to each loaded table,
-%D starting with~0. Switching to a specific table is done by assigning the relevant
-%D number to the predefined \COUNTER\ \type {\language}. However, in \MKIV\ a lot
-%D of management is delegated to \LUA.
-
-%D We keep track of the last loaded patterns by means of a pseudo \COUNTER. This
-%D just one of those situations in which we don't want to spent a real one. Language
-%D zero has no patterns, first of all because I like to start numbering at one. It
-%D may come in handy for special purposes as well.
-
-\normallanguage\zerocount \def\loadedlanguage{1}
-
-%D \macros
-%D {currentlanguage, setupcurrentlanguage}
-%D
-%D Instead of numbers,we are going to use symbolic names for the languages. The
-%D current langage is saved in the macro \type {\currentlanguage}. The setup macro
-%D is mainly used for cosmetic purposes.
-%D
-%D \starttyping
-%D \dorecurse{3}
-%D {\language[nl]
-%D \startmode[*en] english \stopmode
-%D \startmode[*nl] dutch \stopmode
-%D \language[en]
-%D \startmode[*en] english \stopmode
-%D \startmode[*nl] dutch \stopmode}
-%D \stoptyping
-
-\let\currentlanguage \empty
-\let\currentmainlanguage\empty
-
-%D \macros
-%D {defaultlanguage,languageparameter,specificlanguageparameter}
-%D
-%D We don't use the commandhandler here (yet) because we have a rather special
-%D fallback mechanism so quite some compatibility testing is needed.
-
-\installcorenamespace{language}
-\installcorenamespace{languagelinked}
-
-\def\currentusedlanguage{\currentlanguage}
-
-\def\defaultlanguage#1%
- {\ifcsname\??language#1\s!default\endcsname
- \expandafter\defaultlanguage\lastnamedcs
- \else
- #1%
- \fi}
-
-\def\languageparameter#1%
- {\ifcsname\??language\currentlanguage#1\endcsname
- \lastnamedcs
- \orelse\ifcsname\??language\currentlanguage\s!default\endcsname
- \expandafter\specificlanguageparameter\lastnamedcs{#1}%
- \orelse\ifcsname\??language\s!default#1\endcsname
- \lastnamedcs
- \fi}
-
-\def\specificlanguageparameter#1#2%
- {\ifcsname\??language#1#2\endcsname
- \lastnamedcs
- \orelse\ifcsname\??language#1\s!default\endcsname
- \expandafter\specificlanguageparameter\lastnamedcs{#2}%
- \orelse\ifcsname\??language\s!default#2\endcsname
- \lastnamedcs
- \fi}
-
-\def\mainlanguageparameter#1%
- {\ifcsname\??language\currentmainlanguage#1\endcsname
- \lastnamedcs
- \orelse\ifcsname\??language\currentmainlanguage\s!default\endcsname
- \expandafter\specificlanguageparameter\lastnamedcs{#1}%
- \orelse\ifcsname\??language\s!default#1\endcsname
- \lastnamedcs
- \fi}
-
-\let\usedlanguageparameter\languageparameter
-
-\def\askedlanguageparameter#1% assumes \currentusedlanguage being set
- {\ifcsname\??language\currentusedlanguage#1\endcsname
- \lastnamedcs
- \orelse\ifcsname\??language\currentusedlanguage\s!default\endcsname
- \expandafter\specificlanguageparameter\lastnamedcs{#1}%
- \orelse\ifcsname\??language\s!default#1\endcsname
- \lastnamedcs
- \fi}
-
-\unexpanded\def\setusedlanguage#1%
- {\edef\currentusedlanguage{\reallanguagetag{#1}}%
- \ifx\currentusedlanguage\empty
- \let\currentusedlanguage \currentlanguage
- \let\usedlanguageparameter\languageparameter
- \orelse\ifx\currentusedlanguage\v!global
- \let\currentusedlanguage \currentmainlanguage
- \let\usedlanguageparameter\mainlanguageparameter
- \orelse\ifx\currentusedlanguage\v!local
- \let\currentusedlanguage \currentlanguage
- \let\usedlanguageparameter\languageparameter
- \else
- \let\usedlanguageparameter\askedlanguageparameter
- \fi}
-
-\unexpanded\def\setupcurrentlanguage[#1]%
- {\setcurrentlanguage\currentmainlanguage{#1}}
-
-\unexpanded\def\setcurrentlanguage#1#2% sets modes: **id (currentmain) *id (current)
- {\edef\xaskedlanguage{#1}% otherwise clash with \askedlanguage
- \ifx\xaskedlanguage\empty \else
- \ifx\currentmainlanguage\empty\else\resetsystemmode{\systemmodeprefix\currentmainlanguage}\fi
- \let\currentmainlanguage\xaskedlanguage
- \setsystemmode{\systemmodeprefix\currentmainlanguage}%
- \fi
- \edef\xaskedlanguage{#2}%
- \ifx\xaskedlanguage\empty \else
- \ifx\currentlanguage\empty\else\resetsystemmode\currentlanguage\fi
- \let\currentlanguage\xaskedlanguage
- \setsystemmode\currentlanguage
- \fi}
-
-%D The internal macros will be defined later.
-
-%D \macros
-%D {installlanguage}
-%D
-%D Hyphenation patterns can only be loaded when the format file is prepared. The
-%D next macro takes care of this loading. A language is specified with
-%D
-%D \showsetup{installlanguage}
-%D
-%D When \type {state} equals \type {start}, both patterns and additional hyphenation
-%D specifications are loaded. These files are seached for in the patterns path
-%D have names like \type {lang-nl.lua}.
-%D
-%D The \type {spacing} variable specifies how the spaces after punctuation has to be
-%D handled. English is by tradition more tolerant to inter||sentence spacing than
-%D other languages.
-%D
-%D This macro also defines \type {\identifier} as a shortcut switch to the language.
-%D Furthermore the command defined as being language specific, are executed. With
-%D \type {default} we can default to another language (patterns) at format
-%D generation time. Patterns are loaded at runtime.
-
-\newtoks \everysetuplanguage
-
-\def\installedlanguages{\clf_installedlanguages}
-
-\unexpanded\def\doifelselanguage#1%
- {\ifcsname\??language#1\c!state\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doiflanguageelse\doifelselanguage
-
-\def\reallanguagetag#1%
- {\ifcsname\??languagelinked#1\endcsname\lastnamedcs\else#1\fi}
-
-% \language[#1] gave unwanted side effect of loading language specifics
-
-\unexpanded\def\installlanguage
- {\dodoubleargument\lang_basics_install}
-
-% \def\lang_basics_install[#1][#2]%
-% {\doifelseassignment{#2}
-% {\doifelselanguage{#1}
-% {\getparameters[\??language#1][#2]}
-% {\setvalue{\??languagelinked#1}{#1}%
-% \lang_basics_install_indeed{#1}{#1}%
-% \getparameters[\??language#1][\c!state=\v!start,#2]}%
-% \edef\currentsetuplanguage{#1}%
-% \clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}%
-% \the\everysetuplanguage}
-% {\setvalue{\??languagelinked#1}{#2}%
-% \clf_setlanguagesynonym{#1}{#2}%
-% \lang_basics_install_indeed{#1}{#2}}}
-
-\def\lang_basics_install[#1][#2]%
- {\ifcondition\validassignment{#2}%
- \doifelselanguage{#1}
- {\getparameters[\??language#1][#2]}
- {\setvalue{\??languagelinked#1}{#1}%
- \lang_basics_install_indeed{#1}{#1}%
- \getparameters[\??language#1][\c!state=\v!start,#2]}%
- \edef\currentsetuplanguage{#1}%
- \clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}%
- \the\everysetuplanguage
- \else
- \setvalue{\??languagelinked#1}{#2}%
- \clf_setlanguagesynonym{#1}{#2}%
- \lang_basics_install_indeed{#1}{#2}%
- \fi}
-
-\def\lang_basics_install_indeed#1#2%
- {\ifcsname#1\endcsname\else\setuvalue{#1}{\lang_basics_set_current[#2]}\fi}
-
-%D When the second argument is a language identifier, a synonym is created. This
-%D feature is present because we used dutch mnemonics in the dutch version, but
-%D nowadays conform a standard.
-
-\unexpanded\def\doifelsepatterns#1%
- {\begingroup % will change
- \lang_basics_set_current[#1]%
- \ifnum\normallanguage>\zerocount
- \endgroup\expandafter\firstoftwoarguments
- \else
- \endgroup\expandafter\secondoftwoarguments
- \fi}
-
-\let\doifpatternselse\doifelsepatterns
-
-%D \macros
-%D {setuplanguage}
-%D
-%D Quick and dirty, but useful:
-%D
-%D \showsetup{setuplanguage}
-%D
-%D Beware, this command can only be used when a language is installed.
-
-\unexpanded\def\setuplanguage
- {\dodoubleempty\lang_basics_setup}
-
-\ifdefined\lang_basics_synchronize \else
- \let\lang_basics_synchronize\relax % be nice for setups till we have one
-\fi
-
-\installmacrostack\currentlanguage
-
-\def\lang_basics_setup[#1][#2]%
- {\ifsecondargument
- \push_macro_currentlanguage % can be default
- \edef\currentsetuplanguage{\reallanguagetag{#1}}%
- \getparameters[\??language\currentsetuplanguage][#2]%
- \the\everysetuplanguage
- \pop_macro_currentlanguage
- %\doif\currentsetuplanguage\currentlanguage we can have influenced inheritance (default)
- \else
- \let\currentsetuplanguage\currentlanguage
- \getparameters[\??language\currentsetuplanguage][#1]%
- \the\everysetuplanguage
- \fi
- \lang_basics_synchronize}
-
-\appendtoks
- \clf_unloadlanguage{\currentsetuplanguage}%
-\to \everysetuplanguage
-
-\setuplanguage
- [\s!default]
- [\s!patterns=,
- \s!lefthyphenmin=2,
- \s!righthyphenmin=2,
- \s!lefthyphenchar=-1,
- \s!righthyphenchar=45,
- % used in compound i.e. interfaced with c! and can be anything so no numbers
- \c!lefthyphen=,
- \c!righthyphen=-,
- \c!hyphen=-,
- \c!spacing=\v!packed,
- \c!compoundhyphen=\compoundhyphen,
- \c!rightcompoundhyphen=\compoundhyphen,
- \c!leftcompoundhyphen=,
- \c!midsentence=---,
- \c!leftsentence=---,
- \c!rightsentence=---,
- \c!leftsubsentence=---,
- \c!rightsubsentence=---,
- \c!leftquote=\upperleftsinglesixquote,
- \c!rightquote=\upperrightsingleninequote,
- \c!leftquotation=\upperleftdoublesixquote,
- \c!rightquotation=\upperrightdoubleninequote,
- \c!leftspeech=\languageparameter\c!leftquotation,
- \c!middlespeech=,
- \c!rightspeech=\languageparameter\c!rightquotation,
- \c!limittext=\unknown,
- \c!time={h,:,m},
- \c!date={\v!year,\ ,\v!month,\ ,\v!day},
- \c!text=Ag,
- \s!font=] % \v!auto : experimental !
-
-% to be tested:
-%
-% \setuplanguage
-% [\s!default]
-% [\c!righthyphenchar="AD]
-
-%D The values \type {leftsentence} and \type {rightsentence} can be (and are) used
-%D to implement automatic subsentence boundary glyphs, like in {\fr |<|french
-%D guillemots|>|} or {\de |<|german guillemots|>|} or {\nl |<|dutch dashes|>|} like
-%D situations. Furthermore \type {leftquotation} and \type {leftquote} come into
-%D view \quotation {when we quote} or \quote {quote} something.
-
-%D \macros
-%D {currentdatespecification, currenttimespecification}
-%D
-%D Just to make things easy we can ask for the current date specification by saying:
-
-\def\currentdatespecification{\languageparameter\c!date}
-\def\currenttimespecification{\languageparameter\c!time}
-
-%D Carefull reading of these macros shows that it's legal to say
-%D
-%D \starttyping
-%D \installlanguage [du] [de]
-%D \stoptyping
-
-%D \macros
-%D {language,mainlanguage}
-%D
-%D Switching to another language (actually another hyphenation pattern) is done
-%D with:
-%D
-%D \starttyping
-%D \language[identifier]
-%D \stoptyping
-%D
-%D or with \type {\identifier}. Just to be compatible with \PLAIN\ \TEX, we still
-%D support the original meaning, so
-%D
-%D \starttyping
-%D \language=1
-%D \stoptyping
-%D
-%D is a valid operation, where the relation between number and language depends on
-%D the order in installing languages.
-%D
-%D \showsetup{language}
-%D \showsetup{mainlanguage}
-%D
-%D Both commands take a predefined language identifier as argument. We can use \type
-%D {\mainlanguage[identifier]} for setting the (indeed) main language. This is the
-%D language used for translating labels like {\em figure} and {\em table}. The main
-%D language defaults to the current language.
-
-\newtoks \everylanguage
-
-\installcorenamespace{languagenumbers}
-
-\appendtoks
- % we need to reassign the number because new patterns can be defined later on
- % so let's hope not that many \setups happen during a run
- \expandafter\glet\csname\??languagenumbers\currentlanguage\endcsname\undefined
-\to \everysetuplanguage
-
-\def\lang_basics_synchronize_yes
- {\zerocount % see below
- \global\expandafter\chardef\csname\??languagenumbers\currentlanguage\endcsname
- \clf_languagenumber
- {\currentlanguage}%
- {\defaultlanguage\currentlanguage}%
- {\languageparameter\s!patterns}%
- {\languageparameter\c!factor}%
- \relax
- \normallanguage\csname\??languagenumbers\currentlanguage\endcsname}
-
-\let\lang_basics_synchronize_nop\zerocount % not loaded anyway
-
-\letvalue{\??languagenumbers}\lang_basics_synchronize_nop % initime
-
-\appendtoks
- \letvalue{\??languagenumbers}\lang_basics_synchronize_yes % runtime
-\to \everydump
-
-\def\lang_basics_synchronize
- {\normallanguage\csname\??languagenumbers
- \ifcsname\??languagenumbers\currentlanguage\endcsname
- \currentlanguage
- \fi
- \endcsname
- \relax
- \the\everylanguage
- \relax}
-
-\newcount\hyphenstate
-\newcount\hyphenminoffset
-
-\unexpanded\def\lesshyphens
- {\advance\hyphenminoffset\plusone
- \lang_basics_synchronize_min_max}
-
-\unexpanded\def\morehyphens
- {\ifcase\hyphenminoffset \else
- \advance\hyphenminoffset\minusone
- \fi
- \lang_basics_synchronize_min_max}
-
-\unexpanded\def\nohyphens % nicer for url's
- {\ifx\dohyphens\relax
- \unexpanded\edef\dohyphens
- {\hyphenminoffset\the\hyphenminoffset\relax
- \lang_basics_synchronize_min_max}%
- \fi
- \hyphenminoffset\plusthousand
- \lang_basics_synchronize_min_max}
-
-\let\dohyphens\relax
-
-\unexpanded\def\lang_basics_synchronize_min_max % maybe store this at the lua end
- {% these values are stored along with glyph nodes
- \lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin +\hyphenminoffset\relax
- \righthyphenmin\numexpr0\languageparameter\s!righthyphenmin+\hyphenminoffset\relax
- \hyphenationmin\numexpr0\languageparameter\s!hyphenmin\relax
- % these values are stored with the language (global!)
- \prehyphenchar \languageparameter\s!righthyphenchar\relax
- \posthyphenchar\languageparameter\s!lefthyphenchar \relax}
-
-\appendtoks
- \lang_basics_synchronize_min_max
-\to \everylanguage
-
-\unexpanded\def\unhyphenated
- {\groupedcommand{\lefthyphenmin\maxdimen}\donothing}
-
-% \appendtoks
-% \setups[\languageparameter\c!setups]%
-% \to \everylanguage
-
-%D You can setup the default language to reset settings.
-
-\appendtoks
- \edef\currentlanguagesetups{\languageparameter\c!setups}%
- \ifx\currentlanguagesetups\empty \else
- \setups[\currentlanguagesetups]%
- \fi
-\to \everylanguage
-
-% new
-
-\appendtoks
- \usebidiparameter\languageparameter
-\to \everylanguage
-
-% this will move to core-spa !
-
-\appendtoks
- \edef\p_spacing{\languageparameter\c!spacing}%
- \ifx\p_spacing\v!broad
- \nonfrenchspacing
- \else
- \frenchspacing
- \fi
-\to \everylanguage
-
-% \mainlanguage[nl] \setuplanguage[nl][lefthyphen=,righthyphen=?]
-%
-% \dorecurse{100}{dit is toch wel een heel\normalhyphendiscretionary lang\normalhyphendiscretionary woord \recurselevel\ }
-% \dorecurse{100}{dit is toch wel een heellangwoord \recurselevel\ }
-
-% new experimental feature
-
-\unexpanded\def\setuplanguages
- {\setuplanguage[\s!default]}
-
-% \setuplanguages[\s!font=\v!auto]
-% \setuplanguage[\s!default][\s!font=\v!auto]
-% \setuplanguage[nl][\s!font=\v!auto]
-
-\appendtoks
- \edef\p_language_font{\languageparameter\s!font}%
- \ifx\p_language_font\empty
- \orelse\ifx\p_language_font\v!auto
- \doaddfeature\currentlanguage
- \else
- \doaddfeature\p_language_font
- \fi
-\to \everylanguage
-
-%D Fast switcher
-
-\def\lang_basics_switch_asked
- {\ifcsname\??languagelinked\askedlanguage\endcsname
- \edef\askedlanguage{\lastnamedcs}%
- \ifx\currentlanguage\askedlanguage \else
- \setcurrentlanguage\currentmainlanguage\askedlanguage
- \lang_basics_synchronize
- \fi
- \fi}
-
-\unexpanded\def\uselanguageparameter#1%
- {\edef\askedlanguage{#1\c!language}%
- \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
-
-\unexpanded\def\douselanguageparameter#1% fast setter
- {\edef\askedlanguage{#1}%
- \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
-
-\unexpanded\def\lang_basics_set_current[#1]%
- {\edef\askedlanguage{#1}%
- \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
-
-\unexpanded\def\language
- {\doifelsenextoptionalcs\lang_basics_set_current\normallanguage}
-
-\let\setlanguage\language % we make these synonyms
-
-\let\patterns\gobbleoneargument
-
-\newcount\mainlanguagenumber
-
-%D Beware: you might need to use \type {\dontleavehmode} outside and|/|or \type {\par}
-%D inside the group!
-
-\unexpanded\def\startlanguage
- {\begingroup\language}
-
-\let\stoplanguage\endgroup
-
-\unexpanded\def\mainlanguage[#1]%
- {\edef\askedlanguage{#1}%
- \ifx\askedlanguage\empty
- \orelse\ifcsname\??languagelinked\askedlanguage\endcsname
- %\edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}%
- \edef\askedlanguage{\lastnamedcs}%
- \ifx\currentlanguage\askedlanguage
- \ifx\currentmainlanguage\askedlanguage \else
- \setcurrentlanguage\askedlanguage\askedlanguage
- \lang_basics_synchronize
- \fi
- \else
- \setcurrentlanguage\askedlanguage\askedlanguage
- \lang_basics_synchronize
- \fi
- \fi
- \mainlanguagenumber\normallanguage}
-
-\appendtoks
- \normallanguage\mainlanguagenumber
-\to \everybeforepagebody
-
-%D Used at all?
-
-\def\splitsequence#1#2%
- {\doifelse{#1}\v!no{#2}{\doifelse{#1}\v!yes{\languageparameter\c!limittext}{#1}}}
-
-\def\splitsymbol#1%
- {\splitsequence{#1}{\languageparameter\c!limittext}}
-
-%D Just like with subsentence boundary symbols, quotes placement depends on the
-%D current language, therefore we show the defaults here.
-%D
-%D \def\ShowLanguageValues [#1] [#2] #3 #4
-%D {\blank
-%D \startlinecorrection
-%D \vbox\bgroup
-%D \language[#1]
-%D \midaligned{\bf#2 subsentence symbol and quotes}
-%D \framed[width=\hsize,frame=off,topframe=on,bottomframe=on,offset=.5ex]
-%D {\hfil\quotation{#3 #4}\hfil\quote{#2}\hfil
-%D \startsubsentence\startsubsentence#3\stopsubsentence#4\stopsubsentence\hfil}
-%D \egroup
-%D \stoplinecorrection
-%D \blank}
-%D
-%D \ShowLanguageValues [af] [afrikaans] afrikaanse ...
-%D \ShowLanguageValues [ca] [catalan] catalan ...
-%D \ShowLanguageValues [cs] [czech] tjechisch tex
-%D \ShowLanguageValues [cs] [slovak] slowaakse ...
-%D \ShowLanguageValues [da] [danish] deense ...
-%D \ShowLanguageValues [de] [german] duitse degelijkheid
-%D \ShowLanguageValues [en] [english] engelse humor
-%D \ShowLanguageValues [et] [estonian] ...
-%D \ShowLanguageValues [fi] [finnish] finse ...
-%D \ShowLanguageValues [fr] [french] franse slag
-%D \ShowLanguageValues [it] [italian] italiaanse ...
-%D \ShowLanguageValues [la] [latin] latijnse missen
-%D \ShowLanguageValues [nl] [dutch] nederlandse zuinigheid
-%D \ShowLanguageValues [nb] [bokmal] noorse zalm
-%D \ShowLanguageValues [nn] [nnynorsk] noorse zalm
-%D \ShowLanguageValues [pl] [polish] poolse vlag
-%D \ShowLanguageValues [pt] [portuguese] portugese ...
-%D \ShowLanguageValues [es] [spanish] spaans benauwd
-%D \ShowLanguageValues [sv] [swedish] zweedse ...
-%D \ShowLanguageValues [tr] [turkish] turks fruit
-
-%D We support a lot of languages. These are specified and loaded in separate files,
-%D according to their roots. Here we only take care of (postponed) setting of the
-%D current language.
-%D
-%D \unprotect
-%D \placetable{The germanic languages (\type{lang-ger})}
-%D \starttable[||||]
-%D \HL
-%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
-%D \HL
-%D \NC \s!nl \NC dutch \NC germanic \NC\FR
-%D \NC \s!en \NC english \NC germanic \NC\MR
-%D \NC \s!de \NC german \NC germanic \NC\MR
-%D \NC \s!da \NC danish \NC germanic \NC\MR
-%D \NC \s!sv \NC swedish \NC germanic \NC\MR
-%D \NC \s!af \NC afrikaans \NC germanic \NC\MR
-%D \NC \s!nb \NC bokmal \NC germanic \NC\LR
-%D \NC \s!nn \NC nynorsk \NC germanic \NC\LR
-%D \HL
-%D \stoptable
-%D \protect
-%D
-%D \unprotect
-%D \placetable{The italic languages (\type{lang-ita})}
-%D \starttable[||||]
-%D \HL
-%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
-%D \HL
-%D \NC \s!fr \NC french \NC italic \NC\FR
-%D \NC \s!ca \NC catalan \NC italic \NC\MR
-%D \NC \s!es \NC spanish \NC italic \NC\MR
-%D \NC \s!it \NC italian \NC italic \NC\MR
-%D \NC \s!la \NC latin \NC italic \NC\MR
-%D \NC \s!pt \NC portuguese \NC italic \NC\LR
-%D \HL
-%D \stoptable
-%D \protect
-%D
-%D \unprotect
-%D \placetable{The slavic languages (\type{lang-sla})}
-%D \starttable[||||]
-%D \HL
-%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
-%D \HL
-%D \NC \s!pl \NC polish \NC slavic \NC\FR
-%D \NC \s!cs \NC czech \NC slavic \NC\MR
-%D \NC \s!sk \NC slavik \NC slavic \NC\LR
-%D \HL
-%D \stoptable
-%D \protect
-%D \unprotect
-%D
-%D \placetable{The altaic languages (\type{lang-alt})}
-%D \starttable[||||]
-%D \HL
-%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
-%D \HL
-%D \NC \s!tr \NC turkish \NC altaic \NC\SR
-%D \HL
-%D \stoptable
-%D
-%D \placetable{The uralic languages (\type{lang-ura})}
-%D \starttable[||||]
-%D \HL
-%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
-%D \HL
-%D \NC \s!fi \NC finnish \NC uralic \NC\SR
-%D \HL
-%D \stoptable
-%D \protect
-
-\unexpanded\def\nopatterns{\normallanguage\minusone}
-
-%D We default to the language belonging to the interface. This is one of the few
-%D places outside the interface modules where \type {\startinterface} is used.
-
-\setupcurrentlanguage[\s!en]
-
-\unexpanded\def\initializemainlanguage
- {\mainlanguage[\currentlanguage]%
- \showmessage\m!languages9\currentlanguage}
-
-%D New:
-
-\let\stopexceptions\relax
-
-\unexpanded\def\startexceptions
- {\dosingleempty\lang_basics_start_exceptions}
-
-\def\lang_basics_start_exceptions[#1]#2\stopexceptions % multilingual or not?
- {\begingroup
- \edef\askedlanguage{\reallanguagetag{#1}}%
- \ifx\askedlanguage\empty
- \let\askedlanguage\currentlanguage
- \fi
- \clf_setlanguageexceptions{\askedlanguage}{#2}%
- \endgroup}
-
-\unexpanded\def\hyphenation
- {\clf_setlanguageexceptions{\currentlanguage}}
-
-%D For the moment here:
-
-\uchyph 1 % also treat uppercase
-\exhyphenchar 45 % to permit breaking at explicit hyphens
-
-%D New:
-
-\unexpanded\def\traceddiscretionary#1#2#3%
- {\dontleavehmode
- \discretionary{\darkred#1}{\darkgreen#2}{\darkblue#3}}
-
-\unexpanded\def\samplediscretionary
- {\traceddiscretionary
- {pre\clf_currentprehyphenchar}%
- {\clf_currentposthyphenchar post}%
- {replace}}
-
-% todo: make this configurable
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-lab.mkxl b/Master/texmf-dist/tex/context/base/mkiv/lang-lab.mkxl
deleted file mode 100644
index a527224e9dc..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-lab.mkxl
+++ /dev/null
@@ -1,390 +0,0 @@
-%D \module
-%D [ file=lang-lab,
-%D version=1997.08.27,
-%D title=\CONTEXT\ Language Macros,
-%D subtitle=Labels,
-%D author=Hans Hagen / Tobias Burnus,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Language Macros / Labels}
-
-\registerctxluafile{lang-lab}{}
-\registerctxluafile{lang-txt}{}
-
-\unprotect
-
-%D Left-overs:
-
-\ifdefined\sixperemspace \else
- \def\sixperemspace{\normalUchar"2006}
-\fi
-
-%D In this module we deal with language dependant labels and prefixes, like in {\em
-%D Figure~12} and {\em Chapter 1}. In this file we set the default values. Users can
-%D easily overrule these.
-%D
-%D This module is dedicated to the grandfather of Tobias Burnus, who's extensive
-%D languages oriented library helped us a lot in finding the right translations. All
-%D those labels are collected in files that reflect their common ancestor.
-%D
-%D Not all languages can be satisfied with the labeling mechanism as provided here.
-%D Chinese for instance put a label in front as well as after a part number. This is
-%D why the current implementation of labels supports two labels too.
-
-%D \macros
-%D {setupheadtext, setuplabeltext}
-%D
-%D First we present some macros that deal with what we will call head and label
-%D texts. Such texts are defines by:
-%D
-%D \showsetup{setupheadtext}
-%D \showsetup{setuplabeltext}
-%D
-%D A regular \CONTEXT\ stores some 1500 labels at most.
-%D
-%D These commands accept all kind of inputs:
-%D
-%D \starttyping
-%D \setuplabeltext [language] [labellabel=text]
-%D \setuplabeltext [language] [labellabel=text,labellabel=text,...]
-%D \setuplabeltext [labellabel=text]
-%D \setuplabeltext [labellabel=text,labellabel=text,...]
-%D \stoptyping
-%D
-%D The last two cases concern the current language.
-
-\installcorenamespace{label}
-
-\let\currentlabelcategory\empty
-
-\unexpanded\def\definelabelclass
- {\dodoubleempty\lang_labels_define_class}
-
-\def\lang_labels_define_class[#1][#2]%
- {\normalexpanded
- {\lang_labels_define_class_indeed
- {#1}%
- {\ifsecondargument#2\else\zerocount\fi}%
- \expandafter\noexpand\csname dogetupsome#1text\endcsname
- \expandafter\noexpand\csname #1language\endcsname
- \expandafter\noexpand\csname dodogetupsome#1text\endcsname
- \expandafter\noexpand\csname left#1text\endcsname
- \expandafter\noexpand\csname right#1text\endcsname
- \expandafter\noexpand\csname #1texts\endcsname
- \expandafter\noexpand\csname #1text\endcsname}}
-
-% hm, not interfaced
-
-\let\thetextprefix\empty
-
-\unexpanded\def\lang_labels_define_class_indeed#1#2#3#4#5#6#7#8#9%
- {\setuvalue{setup#1text}{\protecttextprefixes#2\def\currenttextprefixclass{#1}\dodoubleempty\lang_labels_text_prefix_setup}%
- \setuvalue{preset#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dodoubleempty\lang_labels_text_prefix_setup}%
- \setuvalue{copy#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dodoubleempty\lang_labels_text_prefix_copy}%
- \setuvalue{start#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dotripleempty\lang_labels_text_prefix_start[#1]}%
- \letvalue{stop#1text}\relax
- \def#4{\reallanguagetag{\defaultlanguage\currentmainlanguage}}%
- \ifnum#2=\plustwo % used for math and tags
- \def#3{#5#4}%
- \def#5##1##2% ##1=language
- {\ifcsname\??label\currentlabelcategory#1:##1:##2\endcsname
- \lastnamedcs
- \orelse\ifcsname\??label#1:##1:##2\endcsname
- \lastnamedcs
- % \orelse\ifcsname\??language#4\s!default\endcsname
- % \expandafter#5\csname\??language#4\s!default\endcsname{##2}%
- \orelse\ifcsname\??language##1\s!default\endcsname
- %\expandafter#5\csname\??language##1\s!default\endcsname{##2}%
- \expandafter#5\lastnamedcs{##2}%
- \orelse\ifcsname\??label\currentlabelcategory#1:##2\endcsname
- \lastnamedcs
- \orelse\ifcsname\??label#1:##2\endcsname
- \lastnamedcs
- \orelse\ifcsname\??label\currentlabelcategory#1:\s!en:##2\endcsname
- \lastnamedcs
- \orelse\ifcsname\??label#1:\s!en:##2\endcsname
- \lastnamedcs
- \else
- ##2%
- \fi}%
- \let#6\gobbleoneargument
- \let#7\gobbleoneargument
- \let#8\gobbletwoarguments
- \let#9#3%
- \else
- \unexpanded\def#3{#5#4}%
- \unexpanded\def#5##1##2%
- {\ifcsname\??label#1:##1:##2\endcsname
- %\expandafter\let\expandafter\thetextprefix\csname\??label#1:##1:##2\endcsname
- \expandafter\let\expandafter\thetextprefix\lastnamedcs
- \orelse\ifcsname\??language#4\s!default\endcsname
- %\expandafter#5\csname\??language#4\s!default\endcsname{##2}%
- \expandafter#5\lastnamedcs{##2}%
- \orelse\ifcsname\??label#1:##2\endcsname
- %\expandafter\let\expandafter\thetextprefix\csname\??label#1:##2\endcsname
- \expandafter\let\expandafter\thetextprefix\lastnamedcs
- \orelse\ifcsname\??label#1:\s!en:##2\endcsname
- %\expandafter\let\expandafter\thetextprefix\csname\??label#1:\s!en:##2\endcsname
- \expandafter\let\expandafter\thetextprefix\lastnamedcs
- \else
- \let\thetextprefix\dummytextprefix
- \fi}%
- \unexpanded\def#6##1{#3{##1}\expandafter\flushleftlabelclass \thetextprefix}%
- \unexpanded\def#7##1{#3{##1}\expandafter\flushrightlabelclass\thetextprefix}%
- \unexpanded\def#8##1{#3{##1}\expandafter\flushbothlabelclass \thetextprefix}% #2
- \unexpanded\def#9##1{#3{##1}\expandafter\flushleftlabelclass \thetextprefix}%
- \fi
- \appendtoks
- \let#6\firstofoneargument % to be checked
- \let#7\firstofoneargument % to be checked
- \let#8\firstofoneargument % to be checked
- \let#9\firstofoneargument % to be checked
- \to \everysimplifycommands}
-
-\let\flushleftlabelclass \firstoftwoarguments
-\let\flushrightlabelclass\secondoftwoarguments
-\def\flushbothlabelclass #1#2#3{#1#3#2}
-\def\dummytextprefix {\empty\empty}
-
-%D \macros
-%D {headtext, labeltext, leftlabeltext, rightlabeltext, labeltexts}
-%D
-%D Once defined, head and label texts can be called upon using:
-%D
-%D \showsetup{headtext}
-%D \showsetup{labeltext}
-%D
-%D \macros
-%D {presetheadtext,presetlabeltext}
-%D
-%D These macros enable us to automatically define head and label texts without
-%D replacing predefined ones. They are internal macros.
-
-\appendtoks \let\labellanguage\currentlanguage \to \everycurrentdate
-
-\newconstant\protecttextprefixes
-
-\let\currenttextprefixtag \s!unknown
-\let\currenttextprefixclass\s!unknown
-
-\def\lang_labels_text_prefix_start[#1][#2][#3]% class language name
- {\ifthirdargument
- \edef\currenttextprefixtag{\reallanguagetag{#2}}%
- \edef\currenttextprefixname{#3}%
- \else
- \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
- \edef\currenttextprefixname{#2}%
- \fi
- \grabuntil{stop#1text}\lang_labels_text_prefix_start_indeed}
-
-\def\lang_labels_text_prefix_start_indeed#1% text (not special checking done here yet, only for long texts anyway)
- {\expandafter\edef\csname\??label\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname%
- {{\clf_strip{#1}}\empty}}
-
-\def\lang_labels_text_prefix_setup[#1][#2]%
- {\ifsecondargument
- \edef\currenttextprefixtag{\reallanguagetag{#1}}%
- \processcommalist[#2]\lang_labels_text_prefix_setup_indeed
- \else
- \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
- \processcommalist[#1]\lang_labels_text_prefix_setup_indeed
- \fi}
-
-\def\lang_labels_text_prefix_setup_indeed#1%
- {\lang_labels_text_prefix_assign[#1]}
-
-\def\lang_labels_text_prefix_assign[#1=#2]%
- {\lang_labels_text_prefix_assign_indeed{#1}[#2,,]}
-
-\def\lang_labels_text_prefix_assign_indeed#1%
- {\ifcase\protecttextprefixes
- % no checking
- \expandafter\lang_labels_text_prefix_assign_yes
- \or
- % checking
- \ifcsname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname
- \expandafter\expandafter\expandafter\lang_labels_text_prefix_assign_nop
- \else
- \expandafter\expandafter\expandafter\lang_labels_text_prefix_assign_yes
- \fi
- \or
- % simple assignment (a bit overkill but it fits in the whole)
- \expandafter\lang_labels_text_prefix_assign_dumb
- \fi{#1}}
-
-\let\m_lang_labels_left \empty
-\let\m_lang_labels_right\empty
-
-% \def\lang_labels_text_prefix_assign_yes#1[#2,#3,#4]%
-% {\def\m_lang_labels_left {#2}% no longer an edef ... else \Word undefined expansion issues
-% \def\m_lang_labels_right{#3}% no longer an edef ... else \Word undefined expansion issues
-% \ifx\m_lang_labels_right\empty
-% \ifx\m_lang_labels_left\empty
-% \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{\empty\empty}%
-% \else
-% \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}\empty}%
-% \fi
-% \else
-% \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}{#3}}%
-% \fi}
-%
-% how we love obscure efficicency ...
-
-\def\lang_labels_text_prefix_assign_yes#1[#2,#3,#4]%
- {\def\m_lang_labels_left {#2}% no longer an edef ... else \Word undefined expansion issues
- \def\m_lang_labels_right{#3}% no longer an edef ... else \Word undefined expansion issues
- \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1%
- \ifx\m_lang_labels_right\empty
- \ifx\m_lang_labels_left\empty
- \endcsname{\empty\empty}%
- \else
- \endcsname{{#2}\empty}%
- \fi
- \else
- \endcsname{{#2}{#3}}%
- \fi}
-
-\def\lang_labels_text_prefix_assign_nop#1[#2]%
- {}
-
-\def\lang_labels_text_prefix_assign_dumb#1[#2,#3]%
- {\expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}}
-
-\unexpanded\def\setlabeltextpair#1#2#3#4#5% a fast one for usage at the Lua end
- {%\writestatus{!!!!}{#1:\reallanguagetag{#2}:#3}%
- \expandafter\def\csname\??label#1:\reallanguagetag{#2}:#3\endcsname{{#4}{#5}}} % class tag key left right
-
-\def\lang_labels_text_prefix_copy[#1][#2]%
- {\ifsecondargument
- \edef\currenttextprefixtag{\reallanguagetag{#1}}%
- \processcommalist[#2]\lang_labels_text_prefix_copy_indeed
- \else
- \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
- \processcommalist[#1]\lang_labels_text_prefix_copy_indeed
- \fi}
-
-\def\lang_labels_text_prefix_copy_indeed#1%
- {\lang_labels_text_prefix_copy_pair[#1]}
-
-\def\lang_labels_text_prefix_copy_pair[#1=#2]%
- {\lang_labels_text_prefix_copy_pair_indeed{#1}[#2,,]}
-
-% \def\lang_labels_text_prefix_copy_pair_indeed#1[#2,#3]%
-% {\expandafter\let
-% \csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\expandafter\endcsname
-% \csname\??label\currenttextprefixclass:\currenttextprefixtag:#2\endcsname}
-%
-% this delays the aliasing so that we can switch maillanguage in between
-
-\def\lang_labels_text_prefix_copy_pair_indeed#1[#2,#3]%
- {\expandafter\edef\csname\??label\currenttextprefixclass:#1\endcsname
- {{\noexpand\csname\??label\currenttextprefixclass:\noexpand\reallanguagetag\noexpand\currentmainlanguage:#2\endcsname}{}}}
-
-\definelabelclass [head] [0] % titles
-\definelabelclass [label] [0] % texts
-\definelabelclass [mathlabel] [0] % functions
-\definelabelclass [taglabel] [2] % tags
-
-\clf_definelabels{head}{titles}\s!true\relax
-\clf_definelabels{label}{texts}\s!true\relax
-\clf_definelabels{mathlabel}{functions}\s!false\relax
-\clf_definelabels{taglabel}{tags}\s!false\relax
-
-%D \macros
-%D {translate}
-%D
-%D Sometimes macros contain language specific words that are to be typeset. Such
-%D macros can be made (more) language independant by using:
-%D
-%D \showsetup{translate}
-%D
-%D like for instance:
-%D
-%D \starttyping
-%D \translate[en=something,nl=iets]
-%D \stoptyping
-%D
-%D which expands to {\em something} or {\em iets}, depending on de current language.
-
-\installcorenamespace{translation}
-
-\unexpanded\def\translate
- {\dosingleempty\lang_translate}
-
-\def\lang_translate[#1]%
- {\getparameters[\??translation][#1]%
- \ifcsname\??translation\currentlanguage\endcsname
- \lastnamedcs
- \orelse\ifcsname\??translation\s!en\endcsname
- \lastnamedcs
- \else
- [translation #1]%
- \fi}
-
-%D When used without argument, the last defined values are used. This enables
-%D repetitive use like
-%D
-%D \starttyping
-%D \en \translate\ means \nl \translate
-%D \stoptyping
-
-%D \macros
-%D {assigntranslation}
-%D
-%D This macro is a system macro, and can be used to assign a translation to a macro.
-%D Its form is:
-%D
-%D \starttyping
-%D \assigntranslation[en=something,nl=iets]\to\command
-%D \stoptyping
-
-\unexpanded\def\assigntranslation[#1]\to#2% bad, this \to
- {\getparameters[\??translation][#1]%
- \edef#2{\begincsname\??translation\currentlanguage\endcsname}}
-
-%D \macros
-%D {commalistsentence}
-%D
-%D Redone in \LUA:
-%D
-%D \startbuffer
-%D \commalistsentence[aap,noot,mies]
-%D \commalistsentence[aap,noot]
-%D \commalistsentence[aap]
-%D \commalistsentence[a,b,c]
-%D \commalistsentence[a,b,c][{ \& },{ and }]
-%D \commalistsentence[a,b,c][+,-]
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlines
-%D \getbuffer
-%D \stoplines
-
-\unexpanded\def\commalistsentence
- {\dodoubleempty\typo_helpers_concat_comma_list}
-
-\def\typo_helpers_concat_comma_list[#1][#2]%
- {\clf_concatcommalist
- text {#1}%
- separators {#2}%
- separator {\detokenize\expandafter{\normalexpanded{\labeltext{and-1}}}}%
- last {\detokenize\expandafter{\normalexpanded{\labeltext{and-2}}}}%
- \relax}
-
-\setuplabeltext [\s!nl] [and-1={{, }}, and-2={{ en }}] % 1, 2 en 3
-\setuplabeltext [\s!en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3
-\setuplabeltext [\s!de] [and-1={{, }}, and-2={{ und }}] % 1, 2 und 3
-\setuplabeltext [\s!hr] [and-1={{, }}, and-2={{ i }}] % 1, 2 i 3
-
-%D Goodie (handy at \LUA\ end):
-
-\unexpanded\def\LABELTEXT#1{\WORD{\labeltext{#1}}} % only for simple cases!
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-mis.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-mis.mkiv
index 3ec29a782f8..4d81c01faa6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-mis.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-mis.mkiv
@@ -254,12 +254,12 @@
\def\lang_discretionaries_check_after
{\setfalse\punctafterdiscretionary
\setfalse\spaceafterdiscretionary
- \ifx\blankspace\nextnext \settrue \spaceafterdiscretionary \else
- \ifx\space \nextnext \settrue \spaceafterdiscretionary \else
- \ifx .\nextnext \settrue \punctafterdiscretionary \else
- \ifx ,\nextnext \settrue \punctafterdiscretionary \else
- \ifx :\nextnext \settrue \punctafterdiscretionary \else
- \ifx ;\nextnext \settrue \punctafterdiscretionary \fi\fi\fi\fi\fi\fi}
+ \ifx\blankspace\nexttoken \settrue \spaceafterdiscretionary \else
+ \ifx\space \nexttoken \settrue \spaceafterdiscretionary \else
+ \ifx .\nexttoken \settrue \punctafterdiscretionary \else
+ \ifx ,\nexttoken \settrue \punctafterdiscretionary \else
+ \ifx :\nexttoken \settrue \punctafterdiscretionary \else
+ \ifx ;\nexttoken \settrue \punctafterdiscretionary \fi\fi\fi\fi\fi\fi}
\letvalue{\??discretionarymode m}\handlemathmodediscretionary
@@ -268,7 +268,7 @@
\let\nextnextnext\egroup
\def\next##1#1%
{\def\next{\activedododotextmodediscretionary#1{##1}}%
- \futurelet\nextnext\next}%
+ \futurelet\nexttoken\next}%
\next}
\let\discretionarytoken \relax
@@ -279,7 +279,7 @@
\def\textmodediscretionary{\handletextmodediscretionary{#1}}%
\lang_discretionaries_check_after
\ifx\discretionarytoken\empty
- \ifx#1\nextnext % takes care of ||| and +++ and ......
+ \ifx#1\nexttoken % takes care of ||| and +++ and ......
\ifcsname\??discretionaryaction\string#1\endcsname
\lastnamedcs
\else\ifconditional\spaceafterdiscretionary
@@ -296,7 +296,7 @@
\else
\lang_discretionaries_check_before
% the next line has been changed (20050203)
- % \prewordbreak\hbox{\textmodediscretionary\nextnext}\postwordbreak
+ % \prewordbreak\hbox{\textmodediscretionary\nexttoken}\postwordbreak
% but an hbox blocks a possible \discretionary
\ifcsname\??discretionaryaction\endcsname
\lastnamedcs
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-rep.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-rep.lua
index d0f6f6d5f24..9f89fa24848 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-rep.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-rep.lua
@@ -40,6 +40,10 @@ local trace_details = false trackers.register("languages.replacements.deta
local report_replacement = logs.reporter("languages","replacements")
local glyph_code = nodes.nodecodes.glyph
+local glue_code = nodes.nodecodes.glue
+
+local spaceskip_code = nodes.gluecodes.spaceskip
+local xspaceskip_code = nodes.gluecodes.xspaceskip
local nuts = nodes.nuts
@@ -47,6 +51,7 @@ local getnext = nuts.getnext
local getprev = nuts.getprev
local getattr = nuts.getattr
local getid = nuts.getid
+local getsubtype = nuts.getsubtype
local getchar = nuts.getchar
local isglyph = nuts.isglyph
@@ -82,7 +87,7 @@ local replacements = languages.replacements or { }
languages.replacements = replacements
local a_replacements = attributes.private("replacements")
-local a_noligature = attributes.private("noligature")
+local a_noligature = attributes.private("noligature") -- to be adapted to lmtx !
local lists = { }
local last = 0
@@ -105,7 +110,7 @@ lists[v_reset].attribute = unsetvalue -- so we discard 0
local function add(root,word,replacement)
local processor, replacement = splitprocessor(replacement,true) -- no check
replacement = lpegmatch(stripper,replacement) or replacement
- local list = utfsplit(word,true)
+ local list = utfsplit(word) -- ,true)
local size = #list
for i=1,size do
local l = utfbyte(list[i])
@@ -159,47 +164,6 @@ function languages.replacements.addlist(category,list)
end
end
-local function hit(a,head)
- local tree = trees[a]
- if tree then
- local root = tree[getchar(head)]
- if root then
- local current = getnext(head)
- local lastrun = false
- local lastfinal = false
- while current do
- local char, id = isglyph(current)
- -- if not char and id == glue_code then
- -- char = " " -- if needed we can also deal with spaces and special nbsp and such
- -- end
- if char then
- local newroot = root[char]
- if not newroot then
- return lastrun, lastfinal
- else
- local final = newroot.final
- if final then
- if trace_details then
- report_replacement("hitting word %a, replacement %a",final.word,final.replacement)
- end
- lastrun = current
- lastfinal = final
- else
- root = newroot
- end
- end
- current = getnext(current)
- else
- break
- end
- end
- if lastrun then
- return lastrun, lastfinal
- end
- end
- end
-end
-
local function tonodes(list,template)
local head, current
for i=1,#list do
@@ -214,120 +178,241 @@ local function tonodes(list,template)
return head
end
+local is_punctuation = characters.is_punctuation
+
+-- We can try to be clever and use the fact that there is no match to skip
+-- over to the next word but it is gives fuzzy code so for now I removed
+-- that optimization (when I really need a high performance version myself
+-- I will look into it (but so far I never used this mechanism myself).
+--
+-- We used to have the hit checker as function but is got messy when checks
+-- for punctuation was added.
+
+local function replace(head,first,last,final,hasspace,overload)
+ local current = first
+ local prefirst = getprev(first) or head
+ local postlast = getnext(last)
+ local oldlength = final.oldlength
+ local newcodes = final.newcodes
+ local newlength = newcodes and #newcodes or 0
+ if trace_replacements then
+ report_replacement("replacing word %a by %a",final.word,final.replacement)
+ end
+ if hasspace or final.special then
+ -- It's easier to delete and insert so we do just that. On the todo list is
+ -- turn injected spaces into glue but easier might be to let the char break
+ -- handler do that ...
+ local prev = getprev(current)
+ local next = getnext(last)
+ local list = current
+ setnext(last)
+ setlink(prev,next)
+ current = prev
+ if not current then
+ head = nil
+ end
+ local i = 1
+ while i <= newlength do
+ local codes = newcodes[i]
+ if type(codes) == "table" then
+ local method = codes[1]
+ if method == "discretionary" then
+ local pre, post, replace = codes[2], codes[3], codes[4]
+ if pre then
+ pre = tonodes(pre,first)
+ end
+ if post then
+ post = tonodes(post,first)
+ end
+ if replace then
+ replace = tonodes(replace,first)
+ end
+ -- todo: also set attr
+ local new = new_disc(pre,post,replace)
+ setattrlist(new,first)
+ head, current = insert_after(head,current,new)
+ elseif method == "noligature" then
+ -- not that efficient to copy but ok for testing
+ local list = codes[2]
+ if list then
+ for i=1,#list do
+ local new = copy_node(first)
+ setchar(new,list[i])
+ setattr(new,a_noligature,1)
+ head, current = insert_after(head,current,new)
+ end
+ else
+ local new = copy_node(first)
+ setchar(new,zwnj)
+ head, current = insert_after(head,current,new)
+ end
+ else
+ report_replacement("unknown method %a",method or "?")
+ end
+ else
+ local new = copy_node(first)
+ setchar(new,codes)
+ head, current = insert_after(head,current,new)
+ end
+ i = i + 1
+ end
+ flush_list(list)
+ elseif newlength == 0 then
+ -- we overload
+ elseif oldlength == newlength then
+ if final.word ~= final.replacement then
+ for i=1,newlength do
+ setchar(current,newcodes[i])
+ current = getnext(current)
+ end
+ end
+ current = getnext(final)
+ elseif oldlength < newlength then
+ for i=1,newlength-oldlength do
+ local n = copy_node(current)
+ setchar(n,newcodes[i])
+ head, current = insert_node_before(head,current,n)
+ current = getnext(current)
+ end
+ for i=newlength-oldlength+1,newlength do
+ setchar(current,newcodes[i])
+ current = getnext(current)
+ end
+ else
+ for i=1,oldlength-newlength do
+ head, current = remove_node(head,current,true)
+ end
+ for i=1,newlength do
+ setchar(current,newcodes[i])
+ current = getnext(current)
+ end
+ end
+ if overload then
+ overload(final,getnext(prefirst),getprev(postlast))
+ end
+ return head, postlast
+end
+
+-- we handle just one space
+
function replacements.handler(head)
- local current = head
- local overload = attributes.applyoverloads
+ local current = head
+ local overload = attributes.applyoverloads
+ local mode = false -- we're in word or punctuation mode
+ local wordstart = false
+ local wordend = false
+ local prevend = false
+ local prevfinal = false
+ local tree = false
+ local root = false
+ local hasspace = false
while current do
- if getid(current) == glyph_code then
+ local id = getid(current) -- or use the char getter
+ if id == glyph_code then
local a = getattr(current,a_replacements)
if a then
- local last, final = hit(a,current)
- if last then
- local precurrent = getprev(current) or head
- local oldlength = final.oldlength
- local newcodes = final.newcodes
- local newlength = newcodes and #newcodes or 0
- if trace_replacement then
- report_replacement("replacing word %a by %a",final.word,final.replacement)
- end
- if final.special then
- -- easier is to delete and insert (a simple callout to tex would be more efficient)
- -- maybe just walk over a replacement string instead
- local prev = getprev(current)
- local next = getnext(last)
- local list = current
- setnext(last)
- setlink(prev,next)
- current = prev
- if not current then
- head = nil
- end
- local i = 1
- while i <= newlength do
- local codes = newcodes[i]
- if type(codes) == "table" then
- local method = codes[1]
- if method == "discretionary" then
- local pre, post, replace = codes[2], codes[3], codes[4]
- if pre then
- pre = tonodes(pre,last)
- end
- if post then
- post = tonodes(post,last)
- end
- if replace then
- replace = tonodes(replace,last)
- end
- -- todo: also set attr
- local new = new_disc(pre,post,replace)
- setattrlist(new,last)
- head, current = insert_after(head,current,new)
- elseif method == "noligature" then
- -- not that efficient to copy but ok for testing
- local list = codes[2]
- if list then
- for i=1,#list do
- local new = copy_node(last)
- setchar(new,list[i])
- setattr(new,a_noligature,1)
- head, current = insert_after(head,current,new)
- end
- else
- local new = copy_node(last)
- setchar(new,zwnj)
- head, current = insert_after(head,current,new)
- end
- else
- -- todo
+ -- we have a run
+ tree = trees[a]
+ if tree then
+ local char = getchar(current)
+ local punc = is_punctuation[char]
+ if mode == "punc" then
+ if not punc then
+ if root then
+ local final = root.final
+ if final then
+ head = replace(head,wordstart,wordend,final,hasspace,overload)
+ elseif prevfinal then
+ head = replace(head,wordstart,prevend,prevfinal,hasspace,overload)
end
- else
- local new = copy_node(last)
- setchar(new,codes)
- head, current = insert_after(head,current,new)
+ prevfinal = false
+ root = false
end
- i = i + 1
+ mode = "word"
end
- flush_list(list)
- elseif newlength == 0 then
- -- nothing gets replaced
- current = getnext(last)
- elseif oldlength == newlength then -- #old == #new
- if final.word == final.replacement then
- -- nothing to do but skip
- else
- for i=1,newlength do
- setchar(current,newcodes[i])
- current = getnext(current)
+ elseif mode == "word" then
+ if punc then
+ if root then
+ local final = root.final
+ if final then
+ head = replace(head,wordstart,wordend,final,hasspace,overload)
+ elseif prevfinal then
+ head = replace(head,wordstart,prevend,prevfinal,hasspace,overload)
+ end
+ prevfinal = false
+ root = false
end
+ mode = "punc"
end
- elseif oldlength < newlength then -- #old < #new
- for i=1,newlength-oldlength do
- local n = copy_node(current)
- setchar(n,newcodes[i])
- head, current = insert_node_before(head,current,n)
- current = getnext(current)
- end
- for i=newlength-oldlength+1,newlength do
- setchar(current,newcodes[i])
- current = getnext(current)
+ else
+ mode = punc and "punc" or "word"
+ end
+ if root then
+ root = root[char]
+ if root then
+ wordend = current
end
- else -- #old > #new
- for i=1,oldlength-newlength do
- head, current = remove_node(head,current,true)
+ else
+ if prevfinal then
+ head = replace(head,wordstart,prevend,prevfinal,hasspace,overload)
+ prevfinal = false
end
- for i=1,newlength do
- setchar(current,newcodes[i])
- current = getnext(current)
+ root = tree[char]
+ if root then
+ wordstart = current
+ wordend = current
+ prevend = false
+ hasspace = false
end
end
- if overload then
- overload(final,getnext(precurrent),getprev(current))
+ else
+ root= false
+ end
+ else
+ tree = false
+ end
+ current = getnext(current)
+ elseif root then
+ local final = root.final
+ if mode == "word" and id == glue_code then
+ local s = getsubtype(current)
+ if s == spaceskip_code or s == xspaceskip_code then
+ local r = root[32] -- maybe more types
+ if r then
+ if not prevend then
+ local f = root.final
+ if f then
+ prevend = wordend
+ prevfinal = f
+ end
+ end
+ wordend = current
+ root = r
+ hasspace = true
+ goto moveon
end
end
end
+ if final then
+ head, current = replace(head,wordstart,wordend,final,hasspace,overload)
+ elseif prevfinal then
+ head, current = replace(head,wordstart,prevend,prevfinal,hasspace,overload)
+ end
+ prevfinal = false
+ root = false
+ ::moveon::
+ current = getnext(current)
+ else
+ current = getnext(current)
+ end
+ end
+ if root then
+ local final = root.final
+ if final then
+ head = replace(head,wordstart,wordend,final,hasspace,overload)
+ elseif prevfinal then
+ head = replace(head,wordstart,prevend,prevfinal,hasspace,overload)
end
- -- we're one ahead now but we need to because we handle words
- current = getnext(current)
end
return head
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-rep.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-rep.mkiv
index 7864b029a7b..a3aaec8e95d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-rep.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-rep.mkiv
@@ -54,7 +54,7 @@
{\clf_setreplacements{#1}}
\unexpanded\def\resetreplacements
- {\attribute\replacementsattribute\attributeunsetvalue}
+ {\c_attr_replacements\attributeunsetvalue}
\unexpanded\def\replaceword
{\dotripleempty\languages_replacements_replace}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-tra.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-tra.lua
new file mode 100644
index 00000000000..5fd123349a3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-tra.lua
@@ -0,0 +1,123 @@
+if not modules then modules = { } end modules ['lang-tra'] = {
+ version = 1.001,
+ comment = "companion to lang-tra.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local utfbyte, utfsplit = utf.byte, utf.split
+
+local nuts = nodes.nuts
+
+local nextchar = nuts.traversers.char
+
+local getattr = nuts.getattr
+local setchar = nuts.setchar
+
+local insert_before = nuts.insert_before
+local copy_node = nuts.copy
+
+local texsetattribute = tex.setattribute
+
+local transliteration = { }
+languages.transliteration = transliteration
+
+local a_transliteration = attributes.private("transliteration")
+local unsetvalue = attributes.unsetvalue
+
+local lastmapping = 0
+local loadedmappings = { }
+
+function transliteration.define(name,vector)
+ local m = loadedmappings[vector]
+ if m == nil then
+ lastmapping = lastmapping + 1
+ local data = require("lang-imp-" .. name)
+ if data then
+ local transliterations = data.transliterations
+ if transliterations then
+ for name, d in next, transliterations do
+ local vector = d.vector
+ if not vector then
+ local mapping = d.mapping
+ if mapping then
+ vector = { }
+ for k, v in next, mapping do
+ local vv = utfsplit(v)
+ for i=1,#vv do
+ vv[i] = utfbyte(vv[i])
+ end
+ vector[utfbyte(k)] = vv
+ end
+ d.vector = vector
+ end
+ end
+ d.attribute = lastmapping
+ loadedmappings[name] = d
+ loadedmappings[lastmapping] = d
+ end
+ end
+ end
+ m = loadedmappings[vector] or false
+ end
+end
+
+local enabled = false
+
+function transliteration.set(vector)
+ if not enabled then
+ nodes.tasks.enableaction("processors", "languages.transliteration.handler")
+ enabled = true
+ end
+ local m = loadedmappings[vector]
+ texsetattribute(a_transliteration,m and m.attribute or unsetvalue)
+end
+
+function transliteration.handler(head)
+ local aprev = nil
+ local vector = nil
+ for current, char in nextchar, head do
+ local a = getattr(current,a_transliteration)
+ if a then
+ if a ~= aprev then
+ aprev = a
+ vector = loadedmappings[a]
+ if vector then
+ vector = vector.vector
+ end
+ end
+ if vector then
+ local t = vector[char]
+ if t then
+ local n = #t
+ setchar(current,t[n])
+ local p = current
+ if n > 1 then
+ for i = n-1,1,-1 do
+ local g = copy_node(current)
+ setchar(g,t[i])
+ head, p = insert_before(head, p, g)
+ end
+ end
+ end
+ end
+ end
+ end
+ return head
+end
+
+interfaces.implement {
+ name = "settransliteration",
+ arguments = "string",
+ actions = transliteration.set,
+}
+
+interfaces.implement {
+ name = "definedtransliteration",
+ arguments = "2 strings",
+ actions = transliteration.define,
+}
+
+nodes.tasks.prependaction("processors", "normalizers", "languages.transliteration.handler", nil, "nut", "disabled" )
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-tra.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-tra.mkiv
new file mode 100644
index 00000000000..b8e64066166
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-tra.mkiv
@@ -0,0 +1,98 @@
+%D \module
+%D [ file=lang-tra,
+%D version=2020.10.31,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Transliteration,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Language Macros / Transliteration}
+
+\registerctxluafile{lang-tra}{}
+
+\unprotect
+
+\definesystemattribute[transliteration][public,global]
+
+\installcorenamespace {transliteration}
+
+\unexpanded\def\definetransliteration
+ {\dodoubleempty\lang_transliteration_define}
+
+\unexpanded\def\lang_transliteration_define[#1][#2]%
+ {\clf_definedtransliteration{#1}{#2}}
+
+\unexpanded\def\settransliteration[#1]%
+ {\clf_settransliteration{#1}}
+
+\unexpanded\def\starttransliteration[#1]%
+ {\begingroup
+ \clf_settransliteration{#1}}
+
+\unexpanded\def\stoptransliteration
+ {\endgroup}
+
+\unexpanded\def\resettransliteration
+ {\c_attr_transliteration\attributeunsetvalue}
+
+\appendtoks
+ \resettransliteration
+\to \everyinitializeverbatim
+
+\protect \endinput
+
+% \setupbodyfont[dejavu]
+%
+% \input lang-tra.mkiv
+%
+% \definetransliteration[serbian][serbian to latin]
+%
+% \starttext
+%
+% \settransliteration[serbian to latin]
+%
+% \startchapter[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \start
+% \settransliteration[serbian to latin]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stop
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stopchapter
+%
+% \resettransliteration
+%
+% \startchapter[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \start
+% \settransliteration[serbian to latin]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stop
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stopchapter
+%
+% \definehead[ChapterA][chapter]
+% \definehead[ChapterB][chapter]
+%
+% \startsetups s-to-l
+% \settransliteration[serbian to latin]
+% \red
+% \stopsetups
+%
+% % maybe we need a setups key for this
+% % hm, \definesetups [xxx] [aa,bb,cc]
+%
+% \setuphead[ChapterB][commandbefore=\setups{s-to-l}]
+%
+% \startChapterA[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% \stopChapterA
+%
+% \startChapterB[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% \stopChapterB
+%
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-txt.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-txt.lua
index f89795e3972..026abbd0ed4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-txt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-txt.lua
@@ -18,6 +18,8 @@ if not modules then modules = { } end modules ['lang-txt'] = {
--
-- af Afrikaans ...
-- ar Arabic Idris Samawi Hamid, Khaled Hosny
+-- be Belarussian Darya Hryshkavets (2019)
+-- bg Bulgarian Vladislav Hinkin, Aleš Ďurčanský (2019)
-- ca Catalan ...
-- cn Chinese Wang Lei, ...
-- cs Czech Tom Hudec, Petr Sojka, Richard Gabriel
@@ -25,7 +27,7 @@ if not modules then modules = { } end modules ['lang-txt'] = {
-- de German Tobias Burnus, ...
-- en English Hans Hagen, ...
-- es Spanish Andrés Montoya, ...
--- et Estonian Clyde Johnston
+-- et Estonian Clyde Johnston (2018)
-- fi Finish ...
-- fr French Daniel Flipo, Arthur Reutenauer
-- gr Greek Apostolos Syropoulos, Thomas Schmitz
@@ -36,17 +38,19 @@ if not modules then modules = { } end modules ['lang-txt'] = {
-- kr Korean Jeong Dalyoung
-- la Latin ...
-- lt Lithuanian Marius Aleknevičius
--- mk Macedonian Jakub Loula, Tomáš Hála (2019), Stojan Trajanovski
+-- mk Macedonian Jakub Loula, Tomáš Hála (2019), Stojan Trajanovski (2019)
-- nb Norwegian Hans Fredrik Nordhaug, ...
-- nn Norwegian Hans Fredrik Nordhaug, ...
-- nl Dutch Hans Hagen
--- pe Persian Mohammad Hossein Bateni
--- pl Polish Grzegorz Sapijaszko
+-- pe Persian Mohammad Hossein Bateni (2016)
+-- pl Polish Grzegorz Sapijaszko (2011)
-- pt Portuguese Pedro F. M. Mendonça
-- ro Romanian Dan Seracu, ...
-- ru Russian Olga Briginets, Alexander Bokovoy, Victor Figurnov, ...
-- sk Slovak Tomáš Hála (2012)
-- sl Slovenian Mojca Miklavec
+-- sr Serbian Ivan Pešić (2020)
+-- sr-latn Serbian Ivan Pešić (2020)
-- sv Swedish ...
-- tk Turkish Tobias Burnus
-- tr Turkmen Nazar Annagurban
@@ -71,35 +75,49 @@ data.labels={
["btx"]={
["In"]={
["labels"]={
+ ["be"]="У",
+ ["bg"]="в",
["en"]="In",
["es"]="En",
["fr"]="Dans",
["mk"]="во",
["pe"]="در",
+ ["sr"]="У",
+ ["sr-latn"]="U",
},
},
["Number"]={
["labels"]={
+ ["be"]="Нумар",
+ ["bg"]="номер",
["de"]="Numer",
["en"]="Number",
["fr"]="Numéro",
["mk"]="Број",
["nl"]="Nummer",
["pe"]="شماره",
+ ["sr"]="Број",
+ ["sr-latn"]="Broj",
},
},
["Volume"]={
["labels"]={
+ ["be"]="Гук",
+ ["bg"]="обем",
["de"]="Band",
["en"]="Volume",
["et"]="Köide",
["mk"]="Том",
["nl"]="Deel",
["pe"]="جلد",
+ ["sr"]="Том",
+ ["sr-latn"]="Tom",
},
},
["and"]={
["labels"]={
+ ["be"]="i",
+ ["bg"]="a",
["de"]="und",
["en"]="and",
["es"]="y",
@@ -109,10 +127,14 @@ data.labels={
["mk"]="и",
["nl"]="en",
["pe"]="و",
+ ["sr"]="и",
+ ["sr-latn"]="i",
},
},
["edition"]={
["labels"]={
+ ["be"]="Выданне",
+ ["bg"]="издание",
["de"]="Auflage",
["en"]="edition",
["es"]="edición",
@@ -122,10 +144,14 @@ data.labels={
["mk"]="издание",
["nl"]="editie",
["pe"]="ویرایش",
+ ["sr"]="издање",
+ ["sr-latn"]="izdanje",
},
},
["editor"]={
["labels"]={
+ ["be"]="Рэдактар",
+ ["bg"]="редактор",
["de"]="Herausgeber",
["en"]="editor",
["et"]="toimetaja",
@@ -133,10 +159,14 @@ data.labels={
["it"]="a cura di",
["mk"]="уредник",
["pe"]="ویراستار",
+ ["sr"]="уредник",
+ ["sr-latn"]="urednik",
},
},
["editors"]={
["labels"]={
+ ["be"]="Рэдактары",
+ ["bg"]="редактори",
["de"]="Herausgeber",
["en"]="editors",
["es"]="editores",
@@ -144,20 +174,27 @@ data.labels={
["fr"]="éditeurs",
["it"]="a cura di",
["mk"]="уредници",
-
+ ["sr"]="уредници",
+ ["sr-latn"]="urednici",
},
},
["in"]={
["labels"]={
+ ["be"]="у",
+ ["bg"]="в",
["en"]="in",
["es"]="en",
["fr"]="dans",
["mk"]="во",
["pe"]="در",
+ ["sr"]="у",
+ ["sr-latn"]="u",
},
},
["mastersthesis"]={
["labels"]={
+ ["be"]="Дыпломная работа",
+ ["bg"]="дипломна работа",
["de"]="Masterarbeit",
["en"]="Master's thesis",
["es"]="Tesis de maestría",
@@ -167,55 +204,76 @@ data.labels={
["mk"]="Магистерска дисертација",
["nl"]="Masterproef",
["pe"]="پایاننامه کارشناسی ارشد",
+ ["sr"]="Мастер дисертација",
+ ["sr-latn"]="Master disertacija",
},
},
["number"]={
["labels"]={
+ ["be"]="нумар",
+ ["bg"]="номер",
["de"]="Numer",
["en"]="number",
["fr"]="numéro",
["mk"]="број",
["nl"]="nummer",
["pe"]="شماره",
+ ["sr"]="број",
+ ["sr-latn"]="broj",
},
},
["of"]={
["labels"]={
+ ["be"]="з",
+ ["bg"]="на",
["de"]="von",
["en"]="of",
["fr"]="de",
["mk"]="од",
["nl"]="van",
+ ["sr"]="од",
+ ["sr-latn"]="od",
},
},
["others"]={
["labels"]={
["en"]="et al.",
["et"]="jt",
- ["mk"]="и др.",
+ ["mk"]="и др.",
+ ["sr"]="и др.",
+ ["sr-latn"]="i dr.",
},
},
["p"]={
["labels"]={
+ ["be"]="стар.",
["de"]="S.",
["en"]="p.",
- ["mk"]="стр.",
["et"]="lk",
+ ["mk"]="стр.",
["pe"]="ص",
+ ["sr"]="стр.",
+ ["sr-latn"]="str.",
},
},
["pages"]={
["labels"]={
+ ["be"]="старонка",
+ ["bg"]="страни",
["de"]="Seiten",
["en"]="pages",
["et"]="leheküljed",
["mk"]="страници",
["nl"]="paginas",
["pe"]="صفحات",
+ ["sr"]="страницa",
+ ["sr-latn"]="stranica",
},
},
["patent"]={
["labels"]={
+ ["be"]="патэнт",
+ ["bg"]="патент",
["de"]="Patent",
["en"]="Patent",
["es"]="Patente",
@@ -224,10 +282,14 @@ data.labels={
["it"]="Brevetto",
["mk"]="Патент",
["nl"]="Octrooi",
+ ["sr"]="Патент",
+ ["sr-latn"]="Patent",
},
},
["phdthesis"]={
["labels"]={
+ ["be"]="Доктарская дысертацыя",
+ ["bg"]="дисертачна работа",
["de"]="Dissertation",
["en"]="PhD thesis",
["es"]="Tesis doctoral",
@@ -237,6 +299,8 @@ data.labels={
["mk"]="Докторска дисертација",
["nl"]="Proefschrift",
["pe"]="رساله دکتری",
+ ["sr"]="Докторска дисертација",
+ ["sr-latn"]="Doktorska disertacija",
},
},
["pp"]={
@@ -246,10 +310,14 @@ data.labels={
["et"]="lk-d",
["mk"]="стр.",
["pe"]="صص",
+ ["sr"]="стр.",
+ ["sr-latn"]="str.",
},
},
["technicalreport"]={
["labels"]={
+ ["be"]="Тэхнічны даклад",
+ ["bg"]="технически доклад",
["de"]="Technischer Bericht",
["en"]="Technical report",
["es"]="Informe técnico",
@@ -259,20 +327,28 @@ data.labels={
["mk"]="Технички извештај",
["nl"]="Technisch rapport",
["pe"]="گزارش فنی",
+ ["sr"]="Технички извештај",
+ ["sr-latn"]="Tehnički izveštaj",
},
},
["volume"]={
["labels"]={
+ ["be"]="гучнасць",
+ ["bg"]="обем",
["de"]="Band",
["en"]="volume",
["et"]="köide",
["mk"]="том",
["nl"]="deel",
["pe"]="جلد",
+ ["sr"]="том",
+ ["sr-latn"]="tom",
},
},
["with"]={
["labels"]={
+ ["be"]="з",
+ ["bg"]="със",
["de"]="mit",
["en"]="with",
["es"]="con",
@@ -281,177 +357,213 @@ data.labels={
["it"]="con",
["mk"]="со",
["nl"]="met",
+ ["sr"]="са",
+ ["sr-latn"]="sa",
},
},
},
["functions"]={
["Pr"]={
["labels"]={
- ["cz"]="P",
+ ["cs"]="P",
["en"]="Pr",
- ["mk"]="P",
+ ["mk"]="P",
["sk"]="P",
+ ["sr"]="P",
+ ["sr-latn"]="P",
},
},
["arccos"]={
["labels"]={
- ["cz"]="arccos",
+ ["cs"]="arccos",
["en"]="arccos",
["es"]="arc\\sixperemspace cos",
["hr"]="arc\\sixperemspace cos",
- ["mk"]="arccos",
+ ["mk"]="arccos",
["pl"]="arc\\sixperemspace cos",
["sk"]="arccos",
+ ["sr"]="arccos",
+ ["sr-latn"]="arccos",
},
},
["arccosh"]={
["labels"]={
- ["cz"]="arccosh",
+ ["cs"]="arccosh",
["en"]="arccosh",
["es"]="arc\\sixperemspace cosh",
["hr"]="arc\\sixperemspace cosh",
- ["mk"]="arccosh",
+ ["mk"]="arccosh",
["pl"]="arc\\sixperemspace cosh",
["sk"]="arccosh",
+ ["sr"]="arccosh",
+ ["sr-latn"]="arccosh",
},
},
["arcctg"]={
["labels"]={
- ["cz"]="arccotg",
+ ["cs"]="arccotg",
["en"]="arccot",
["es"]="arc\\sixperemspace cot",
["hr"]="arc\\sixperemspace ctg",
- ["mk"]="arccotg",
+ ["mk"]="arccotg",
["pl"]="arc\\sixperemspace ctg",
["sk"]="arccotg",
+ ["sr"]="arcctg",
+ ["sr-latn"]="arcctg",
},
},
["arcsin"]={
["labels"]={
- ["cz"]="arcsin",
+ ["cs"]="arcsin",
["en"]="arcsin",
["es"]="arc\\sixperemspace sen",
["hr"]="arc\\sixperemspace sin",
- ["mk"]="arcsin",
+ ["mk"]="arcsin",
["pl"]="arc\\sixperemspace sin",
["sk"]="arcsin",
+ ["sr"]="arcsin",
+ ["sr-latn"]="arcsin",
},
},
["arcsinh"]={
["labels"]={
- ["cz"]="arcsinh",
+ ["cs"]="arcsinh",
["en"]="arcsinh",
["es"]="arc\\sixperemspace senh",
["hr"]="arc\\sixperemspace sinh",
- ["mk"]="arcsinh",
+ ["mk"]="arcsinh",
["pl"]="arc\\sixperemspace sinh",
["sk"]="arcsinh",
+ ["sr"]="arcsinh",
+ ["sr-latn"]="arcsinh",
},
},
["arctan"]={
["labels"]={
- ["cz"]="arctg",
+ ["cs"]="arctg",
["en"]="arctan",
["es"]="arc\\sixperemspace tan",
["hr"]="arc\\sixperemspace tg",
- ["mk"]="arctg",
+ ["mk"]="arctg",
["pl"]="arc\\sixperemspace tg",
["sk"]="arctg",
+ ["sr"]="arctg",
+ ["sr-latn"]="arctg",
},
},
["arctanh"]={
["labels"]={
- ["cz"]="arctgh",
+ ["cs"]="arctgh",
["en"]="arctanh",
["es"]="arc\\sixperemspace tanh",
["hr"]="arc\\sixperemspace tgh",
- ["mk"]="arctgh",
+ ["mk"]="arctgh",
["pl"]="arc\\sixperemspace tgh",
["sk"]="arctgh",
+ ["sr"]="arctgh",
+ ["sr-latn"]="arctgh",
},
},
["arg"]={
["labels"]={
- ["cz"]="arg",
+ ["cs"]="arg",
["en"]="arg",
["es"]="arg",
- ["mk"]="arg",
+ ["mk"]="arg",
["sk"]="arg",
+ ["sr"]="arg",
+ ["sr-latn"]="arg",
},
},
["cos"]={
["labels"]={
- ["cz"]="cos",
+ ["cs"]="cos",
["en"]="cos",
["es"]="cos",
- ["mk"]="cos",
+ ["mk"]="cos",
["sk"]="cos",
+ ["sr"]="cos",
+ ["sr-latn"]="cos",
},
},
["cosh"]={
["labels"]={
- ["cz"]="cosh",
+ ["cs"]="cosh",
["en"]="cosh",
["es"]="cosh",
- ["mk"]="cosh",
+ ["mk"]="cosh",
["sk"]="cosh",
+ ["sr"]="cosh",
+ ["sr-latn"]="cosh",
},
},
["cot"]={
["labels"]={
- ["cz"]="cotg",
+ ["cs"]="cotg",
["en"]="cot",
["es"]="cot",
["hr"]="ctg",
- ["mk"]="ctg",
+ ["mk"]="ctg",
["pl"]="ctg",
["sk"]="cotg",
+ ["sr"]="ctg",
+ ["sr-latn"]="ctg",
},
},
["coth"]={
["labels"]={
- ["cz"]="cotgh",
+ ["cs"]="cotgh",
["en"]="coth",
["es"]="coth",
- ["mk"]="ctgh",
+ ["mk"]="ctgh",
["sk"]="cotgh",
+ ["sr"]="ctgh",
+ ["sr-latn"]="ctgh",
},
},
["csc"]={
["labels"]={
- ["cz"]="cosec",
+ ["cs"]="cosec",
["en"]="csc",
["es"]="csc",
- ["mk"]="cosec",
+ ["mk"]="cosec",
["sk"]="cosec",
+ ["sr"]="cosec",
+ ["sr-latn"]="cosec",
},
},
["ctg"]={
["labels"]={
- ["cz"]="cotg",
+ ["cs"]="cotg",
["en"]="cot",
["es"]="cot",
["hr"]="ctg",
- ["mk"]="ctg",
+ ["mk"]="ctg",
["pl"]="ctg",
["sk"]="cotg",
+ ["sr"]="ctg",
+ ["sr-latn"]="ctg",
},
},
["deg"]={
["labels"]={
- ["cz"]="deg",
+ ["cs"]="deg",
["en"]="deg",
["es"]="gr",
- ["mk"]="deg",
+ ["mk"]="deg",
["sk"]="deg",
+ ["sr"]="deg",
+ ["sr-latn"]="deg",
},
},
["det"]={
["labels"]={
- ["cz"]="det",
+ ["cs"]="det",
["en"]="det",
["es"]="det",
["sk"]="det",
+ ["sr"]="det",
+ ["sr-latn"]="det",
},
},
["diff"]={
@@ -461,35 +573,41 @@ data.labels={
},
["dim"]={
["labels"]={
- ["cz"]="dim",
+ ["cs"]="dim",
["en"]="dim",
["es"]="dim",
- ["mk"]="dim",
+ ["mk"]="dim",
["sk"]="dim",
+ ["sr"]="dim",
+ ["sr-latn"]="dim",
},
},
["exp"]={
["labels"]={
- ["cz"]="exp",
+ ["cs"]="exp",
["en"]="exp",
["es"]="exp",
["sk"]="exp",
+ ["sr"]="exp",
+ ["sr-latn"]="exp",
},
},
["gcd"]={
["labels"]={
- ["cz"]="NSD",
+ ["cs"]="NSD",
["en"]="gcd",
["es"]="mcd",
["hr"]="nzd",
- ["mk"]="НЗД",
+ ["mk"]="НЗД",
["nl"]="ggd",
["sk"]="NSD",
+ ["sr"]="НЗД",
+ ["sr-latn"]="NZD",
},
},
["hom"]={
["labels"]={
- ["cz"]="Hom",
+ ["cs"]="Hom",
["en"]="hom",
["es"]="hom",
["sk"]="Hom",
@@ -497,207 +615,237 @@ data.labels={
},
["inf"]={
["labels"]={
- ["cz"]="inf",
+ ["cs"]="inf",
["en"]="inf",
["es"]="inf",
- ["mk"]="inf",
+ ["mk"]="inf",
["sk"]="inf",
+ ["sr"]="inf",
+ ["sr-latn"]="inf",
},
},
["injlim"]={
["labels"]={
- ["cz"]="inj\\sixperemspace lim",
+ ["cs"]="inj\\sixperemspace lim",
["en"]="inj\\sixperemspace lim",
["es"]="lím\\sixperemspace iny",
["sk"]="inj\\sixperemspace lim",
+ ["sr"]="inj\\sixperemspace lim",
+ ["sr-latn"]="inj\\sixperemspace lim",
},
},
["ker"]={
["labels"]={
- ["cz"]="ker",
+ ["cs"]="ker",
["en"]="ker",
["es"]="Ker",
["sk"]="ker",
+ ["sr"]="ker",
+ ["sr-latn"]="ker",
},
},
["lcm"]={
["labels"]={
- ["cz"]="NSN",
+ ["cs"]="NSN",
["en"]="lcm",
["es"]="MCM",
["hr"]="nzv",
- ["mk"]="НЗС",
+ ["mk"]="НЗС",
["nl"]="kgv",
["sk"]="NSN",
+ ["sr"]="НЗС",
+ ["sr-latn"]="NZS",
},
},
["lg"]={
["labels"]={
- ["cz"]="log",
+ ["cs"]="log",
["en"]="lg",
["es"]="log",
- ["mk"]="lg",
+ ["mk"]="lg",
["sk"]="log",
+ ["sr"]="lg",
+ ["sr-latn"]="lg",
},
},
["lim"]={
["labels"]={
- ["cz"]="lim",
+ ["cs"]="lim",
["en"]="lim",
["es"]="lím",
- ["mk"]="lim",
+ ["mk"]="lim",
["sk"]="lim",
+ ["sr"]="lim",
+ ["sr-latn"]="lim",
},
},
["liminf"]={
["labels"]={
- ["cz"]="lim\\sixperemspace inf",
+ ["cs"]="lim\\sixperemspace inf",
["en"]="lim\\sixperemspace inf",
["es"]="lím\\sixperemspace inf",
- ["mk"]="lim\\sixperemspace inf",
+ ["mk"]="lim\\sixperemspace inf",
["sk"]="lim\\sixperemspace inf",
+ ["sr"]="lim\\sixperemspace inf",
+ ["sr-latn"]="lim\\sixperemspace inf",
},
},
["limsup"]={
["labels"]={
- ["cz"]="lim\\sixperemspace sup",
+ ["cs"]="lim\\sixperemspace sup",
["en"]="lim\\sixperemspace sup",
["es"]="lím\\sixperemspace sup",
- ["mk"]="lim\\sixperemspace sup",
+ ["mk"]="lim\\sixperemspace sup",
["sk"]="lim\\sixperemspace sup",
+ ["sr"]="lim\\sixperemspace sup",
+ ["sr-latn"]="lim\\sixperemspace sup",
},
},
["ln"]={
["labels"]={
- ["cz"]="ln",
+ ["cs"]="ln",
["en"]="ln",
["es"]="ln",
- ["mk"]="ln",
+ ["mk"]="ln",
["sk"]="ln",
+ ["sr"]="ln",
+ ["sr-latn"]="ln",
},
},
["log"]={
["labels"]={
- ["cz"]="log",
+ ["cs"]="log",
["en"]="log",
["es"]="log",
- ["mk"]="log",
+ ["mk"]="log",
["sk"]="log",
+ ["sr"]="log",
+ ["sr-latn"]="log",
},
},
["max"]={
["labels"]={
- ["cz"]="max",
+ ["cs"]="max",
["en"]="max",
["es"]="máx",
- ["mk"]="max",
+ ["mk"]="max",
["sk"]="max",
+ ["sr"]="max",
+ ["sr-latn"]="max",
},
},
["median"]={
["labels"]={
- ["cz"]="\\tilde",
+ ["cs"]="\\tilde",
["en"]="median",
["es"]="Mediana",
["sk"]="\\tilde",
+ ["sr"]="median",
+ ["sr-latn"]="median",
},
},
["min"]={
["labels"]={
- ["cz"]="min",
+ ["cs"]="min",
["en"]="min",
["es"]="mín",
- ["mk"]="min",
+ ["mk"]="min",
["sk"]="min",
+ ["sr"]="min",
+ ["sr-latn"]="min",
},
},
["mod"]={
["labels"]={
- ["cz"]="mod",
+ ["cs"]="mod",
["en"]="mod",
["es"]="mod",
- ["mk"]="mod",
+ ["mk"]="mod",
["sk"]="mod",
+ ["sr"]="mod",
+ ["sr-latn"]="mod",
},
},
["projlim"]={
["labels"]={
- ["cz"]="proj\\sixperemspace lim",
+ ["cs"]="proj\\sixperemspace lim",
["en"]="proj\\sixperemspace lim",
["es"]="lím\\sixperemspace proy",
["sk"]="proj\\sixperemspace lim",
+ ["sr"]="proj\\sixperemspace lim",
+ ["sr-latn"]="proj\\sixperemspace lim",
},
},
["sec"]={
["labels"]={
- ["cz"]="sec",
+ ["cs"]="sec",
["en"]="sec",
["es"]="sec",
- ["mk"]="sec",
+ ["mk"]="sec",
["sk"]="sec",
+ ["sr"]="sec",
+ ["sr-latn"]="sec",
},
},
["sin"]={
["labels"]={
- ["cz"]="sin",
+ ["cs"]="sin",
["en"]="sin",
["es"]="sen",
- ["mk"]="sin",
+ ["mk"]="sin",
["sk"]="sin",
+ ["sr"]="sin",
+ ["sr-latn"]="sin",
},
},
["sinh"]={
["labels"]={
- ["cz"]="sinh",
+ ["cs"]="sinh",
["en"]="sinh",
["es"]="senh",
- ["mk"]="sinh",
+ ["mk"]="sinh",
["sk"]="sinh",
+ ["sr"]="sinh",
+ ["sr-latn"]="sinh",
},
},
["sup"]={
["labels"]={
- ["cz"]="sup",
+ ["cs"]="sup",
["en"]="sup",
["es"]="sup",
- ["mk"]="sup",
+ ["mk"]="sup",
["sk"]="sup",
+ ["sr"]="sup",
+ ["sr-latn"]="sup",
},
},
["tan"]={
["labels"]={
- ["cz"]="tg",
+ ["cs"]="tg",
["en"]="tan",
["es"]="tan",
["hr"]="tg",
["mk"]="tg",
["pl"]="tg",
["sk"]="tg",
+ ["sr"]="tg",
+ ["sr-latn"]="tg",
},
},
["tanh"]={
["labels"]={
- ["cz"]="tgh",
+ ["cs"]="tgh",
["en"]="tanh",
["es"]="tanh",
- ["mk"]="tgh",
+ ["mk"]="tgh",
["sk"]="tgh",
+ ["sr"]="tgh",
+ ["sr-latn"]="tgh",
},
},
},
["texts"]={
- ["following:singular"]={
- ["labels"]={
- ["en"]="f.",
- ["fr"]=hairspace .. "sq",
- },
- },
- ["following:plural"]={
- ["labels"]={
- ["en"]="ff.",
- ["fr"]=hairspace .. "sqq",
- },
- },
["and"]={
["labels"]={
["af"]="",
@@ -727,6 +875,7 @@ data.labels={
["ru"]="",
["sk"]=" a ",
["sl"]="",
+ ["sr"]=" и ",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -739,6 +888,7 @@ data.labels={
["labels"]={
["af"]="Bylae ",
["ar"]="ملحق ",
+ ["be"]="Апендыцыт",
["ca"]="Apèndix ",
["cn"]="附录",
["cs"]="Příloha ",
@@ -768,6 +918,8 @@ data.labels={
["ru"]="",
["sk"]="Príloha ",
["sl"]="Dodatek ",
+ ["sr"]="Додатак ",
+ ["sr-latn"]="Dodatak ",
["sv"]="",
["tk"]="Goşmaça",
["tr"]="",
@@ -781,6 +933,8 @@ data.labels={
["ar"]="أبريل",
["ar-dz"]="أفريل",
["ar-sy"]="نيسان",
+ ["be"]="красавіка",
+ ["bg"]="април",
["ca"]="abril",
["cn"]="四月",
["cs"]="dubna",
@@ -799,8 +953,8 @@ data.labels={
["kr"]="4",
["la"]="Aprilis",
["lt"]="balandžio",
- ["nb"]="april",
["mk"]="април",
+ ["nb"]="april",
["nl"]="april",
["nn"]="april",
["pe"]="آوریل",
@@ -810,6 +964,8 @@ data.labels={
["ru"]="апреля",
["sk"]="apríla",
["sl"]="april",
+ ["sr"]="aприл",
+ ["sr-latn"]="april",
["sv"]="april",
["tk"]="aprel",
["tr"]="nisan",
@@ -829,7 +985,7 @@ data.labels={
["ca"]="",
["cs"]="dub.",
["da"]="",
- ["de"]="",
+ ["de"]="Apr.",
["en"]="apr",
["es"]="abr.",
["et"]="apr",
@@ -851,6 +1007,8 @@ data.labels={
["ru"]="",
["sk"]="apr.",
["sl"]="",
+ ["sr"]="апр.",
+ ["sr-latn"]="apr.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -888,6 +1046,8 @@ data.labels={
["ru"]="на странице ",
["sk"]="na strane ",
["sl"]="na strani ",
+ ["sr"]="на страници ",
+ ["sr-latn"]="na stranici ",
["sv"]="på sida ",
["tk"]="",
["tr"]="",
@@ -902,6 +1062,8 @@ data.labels={
["ar-dz"]="أوت",
["ar-ma"]="غشت",
["ar-sy"]="آب",
+ ["be"]="жнівня",
+ ["bg"]="август",
["ca"]="agost",
["cn"]="八月",
["cs"]="srpna",
@@ -931,6 +1093,8 @@ data.labels={
["ru"]="августа",
["sk"]="augusta",
["sl"]="avgust",
+ ["sr"]="август",
+ ["sr-latn"]="avgust",
["sv"]="augusti",
["tk"]="awgust",
["tr"]="ağustos",
@@ -950,7 +1114,7 @@ data.labels={
["ca"]="",
["cs"]="srp.",
["da"]="",
- ["de"]="",
+ ["de"]="Aug.",
["en"]="aug",
["es"]="ago.",
["et"]="aug",
@@ -972,6 +1136,8 @@ data.labels={
["ru"]="",
["sk"]="aug.",
["sl"]="",
+ ["sr"]="авг.",
+ ["sr-latn"]="avg.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -984,6 +1150,8 @@ data.labels={
["labels"]={
["af"]="Hoofstuk ",
["ar"]="باب ",
+ ["be"]="Глава ",
+ ["bg"]="Eпизод ",
["ca"]="Capítol ",
["cn"]={ "第", "章" },
["cs"]="Kapitola ",
@@ -1013,6 +1181,9 @@ data.labels={
["ru"]="",
["sk"]="Kapitola ",
["sl"]="Poglavje ",
+ ["sr"]="Поглавље ",
+ ["sr"]="Глава ",
+ ["sr-latn"]="Glava ",
["sv"]="",
["tk"]="Bap",
["tr"]="",
@@ -1023,6 +1194,8 @@ data.labels={
["continued"]={
["labels"]={
["af"]="",
+ ["be"]=" (працяг)",
+ ["bg"]=" (продължение)",
["ca"]="",
["cs"]=" (pokračování)",
["da"]="",
@@ -1049,6 +1222,9 @@ data.labels={
["ru"]="",
["sk"]=" (pokračovanie)",
["sl"]="",
+ ["sr"]=" (наставио)",
+ ["sr"]=" (наставак)",
+ ["sr-latn"]=" (nastavak)",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1058,12 +1234,15 @@ data.labels={
},
["day"]={
["labels"]={
+ ["bg"]="ден",
["en"]="day",
["et"]="päev",
["kr"]="일",
["mk"]="ден",
["nl"]="dag",
["pe"]="روز",
+ ["sr"]="дан",
+ ["sr-latn"]="dan",
},
},
["december"]={
@@ -1072,6 +1251,8 @@ data.labels={
["ar"]="ديسمبر",
["ar-ma"]="دجنبر",
["ar-sy"]="كانون الأول",
+ ["be"]="снежня",
+ ["bg"]="декември",
["ca"]="desembre",
["cn"]="十二月",
["cs"]="prosince",
@@ -1090,8 +1271,8 @@ data.labels={
["kr"]="12",
["la"]="December",
["lt"]="gruodžio",
- ["nb"]="desember",
["mk"]="декември",
+ ["nb"]="desember",
["nl"]="december",
["nn"]="desember",
["pe"]="دسامبر",
@@ -1101,6 +1282,8 @@ data.labels={
["ru"]="декабря",
["sk"]="decembra",
["sl"]="december",
+ ["sr"]="децембар",
+ ["sr-latn"]="decembar",
["sv"]="december",
["tk"]="dekabr",
["tr"]="aralık",
@@ -1120,7 +1303,7 @@ data.labels={
["ca"]="",
["cs"]="pros.",
["da"]="",
- ["de"]="",
+ ["de"]="Dez.",
["en"]="dec",
["es"]="dic.",
["et"]="dets",
@@ -1142,6 +1325,8 @@ data.labels={
["ru"]="",
["sk"]="dec.",
["sl"]="",
+ ["sr"]="дец.",
+ ["sr-latn"]="dec.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1155,6 +1340,8 @@ data.labels={
["ar"]="فبراير",
["ar-dz"]="فيفري",
["ar-sy"]="شباط",
+ ["be"]="лютага",
+ ["bg"]="февруари",
["ca"]="febrer",
["cn"]="二月",
["cs"]="února",
@@ -1184,6 +1371,8 @@ data.labels={
["ru"]="февраля",
["sk"]="februára",
["sl"]="februar",
+ ["sr"]="фебруар",
+ ["sr-latn"]="februar",
["sv"]="februari",
["tk"]="fewral",
["tr"]="Şubat",
@@ -1203,7 +1392,7 @@ data.labels={
["ca"]="",
["cs"]="ún.",
["da"]="",
- ["de"]="",
+ ["de"]="Feb.",
["en"]="feb",
["es"]="feb.",
["et"]="veebr",
@@ -1225,6 +1414,8 @@ data.labels={
["ru"]="",
["sk"]="feb.",
["sl"]="",
+ ["sr"]="феб.",
+ ["sr-latn"]="feb.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1236,6 +1427,8 @@ data.labels={
["labels"]={
["af"]="Figuur ",
["ar"]="شكل ",
+ ["be"]="Малюнак",
+ ["bg"]="Фигура",
["ca"]="Figura ",
["cn"]="图",
["cs"]="Obrázek ",
@@ -1265,6 +1458,8 @@ data.labels={
["ru"]="Рисунок ",
["sk"]="Obrázok ",
["sl"]="Slika ",
+ ["sr"]="Слика ",
+ ["sr-latn"]="Slika ",
["sv"]="Figur ",
["tk"]="Surat",
["tr"]="Şekil ",
@@ -1272,6 +1467,18 @@ data.labels={
["vi"]="Hình ",
},
},
+ ["following:plural"]={
+ ["labels"]={
+ ["en"]="ff.",
+ ["fr"]=hairspace .. "sqq",
+ },
+ },
+ ["following:singular"]={
+ ["labels"]={
+ ["en"]="f.",
+ ["fr"]=hairspace .. "sq",
+ },
+ },
["followingpage"]={
["labels"]={
["en"]="on a following page",
@@ -1279,12 +1486,16 @@ data.labels={
["mk"]="на следната страница",
["nl"]="op een volgende bladzijde",
["pe"]="در صفحات آینده",
+ ["sr"]="на следећој страници",
+ ["sr-latn"]="na sledećoj stranici",
},
},
["friday"]={
["labels"]={
["af"]="vrydag",
["ar"]="الجمعة",
+ ["be"]="пятніца",
+ ["bg"]="петък",
["ca"]="divendres",
["cn"]="星期五",
["cs"]="pátek",
@@ -1314,6 +1525,8 @@ data.labels={
["ru"]="пятница",
["sk"]="piatok",
["sl"]="petek",
+ ["sr"]="петак",
+ ["sr-latn"]="petak",
["sv"]="fredag",
["tk"]="bäşinji gün",
["tr"]="cuma",
@@ -1321,10 +1534,20 @@ data.labels={
["vi"]="thứ sáu",
},
},
+ ["friday:mnem"]={
+ ["labels"]={
+ ["de"]="Fr.",
+ ["en"]="fri",
+ ["sr"]="пет.",
+ ["sr-latn"]="pet.",
+ },
+ },
["graphic"]={
["labels"]={
["af"]="Grafiek ",
["ar"]="رسم ",
+ ["be"]="Графіка ",
+ ["bg"]="Графичен ",
["ca"]="Gràfica ",
["cn"]="插图",
["cs"]="Graf ",
@@ -1353,6 +1576,8 @@ data.labels={
["ru"]="График ",
["sk"]="Graf ",
["sl"]="Slika ",
+ ["sr"]="График ",
+ ["sr-latn"]="Grafik ",
["sv"]="Grafik ",
["tk"]="Grafik",
["tr"]="Grafik",
@@ -1364,6 +1589,7 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="كما وضحنا سابقا",
+ ["be"]="Графіка",
["ca"]="",
["cs"]="viz výše",
["da"]="se foroven",
@@ -1391,6 +1617,9 @@ data.labels={
["ru"]="см. выше",
["sk"]="pozri hore",
["sl"]="glej zgoraj",
+ ["sr"]="види горе",
+ ["sr"]="као што је показано изнад",
+ ["sr-latn"]="kao što je pokazano iznad",
["sv"]="se ovan",
["tk"]="",
["tr"]="",
@@ -1402,6 +1631,8 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="كما نوضح لاحقا",
+ ["be"]="гл. вышэй",
+ ["bg"]="ў далейшым",
["ca"]="",
["cs"]="viz níže",
["da"]="se forneden",
@@ -1429,6 +1660,9 @@ data.labels={
["ru"]="см. ниже",
["sk"]="pozri ďalej",
["sl"]="glej spodaj",
+ ["sr"]="види доле",
+ ["sr"]="као што је показано ниже",
+ ["sr-latn"]="kao što je pokazano niže",
["sv"]="se nedan",
["tk"]="",
["tr"]="",
@@ -1440,6 +1674,8 @@ data.labels={
["labels"]={
["af"]="Intermezzo ",
["ar"]="فسحة ",
+ ["be"]="Устаўка",
+ ["bg"]="Aнтракт ",
["ca"]="Intermedi ",
["cn"]="퉣",
["cs"]="Intermezzo ",
@@ -1468,6 +1704,9 @@ data.labels={
["ru"]="Вставка ",
["sk"]="Intermezzo ",
["sl"]="Intermezzo ",
+ ["sr"]="Интермеззо ",
+ ["sr"]="Дигресија ",
+ ["sr-latn"]="Digresija ",
["sv"]="Intermezzo ",
["tk"]="Arakesme",
["tr"]="",
@@ -1481,6 +1720,8 @@ data.labels={
["ar"]="يناير",
["ar-dz"]="جانفي",
["ar-sy"]="كانون الثاني",
+ ["be"]="студзеня",
+ ["bg"]="януари",
["ca"]="gener",
["cn"]="一月",
["cs"]="ledna",
@@ -1510,6 +1751,8 @@ data.labels={
["ru"]="января",
["sk"]="januára",
["sl"]="januar",
+ ["sr"]="јануар",
+ ["sr-latn"]="januar",
["sv"]="januari",
["tk"]="ýanwar",
["tr"]="ocak",
@@ -1529,7 +1772,7 @@ data.labels={
["ca"]="",
["cs"]="led.",
["da"]="",
- ["de"]="",
+ ["de"]="Jan.",
["en"]="jan",
["es"]="ene.",
["et"]="jaan",
@@ -1551,6 +1794,8 @@ data.labels={
["ru"]="",
["sk"]="jan.",
["sl"]="",
+ ["sr"]="јан.",
+ ["sr-latn"]="jan.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1565,6 +1810,8 @@ data.labels={
["ar-dz"]="جويلة",
["ar-ma"]="يوليوز",
["ar-sy"]="تموز",
+ ["be"]="ліпня",
+ ["bg"]="юли",
["ca"]="juliol",
["cn"]="七月",
["cs"]="července",
@@ -1594,6 +1841,8 @@ data.labels={
["ru"]="июля",
["sk"]="júla",
["sl"]="julij",
+ ["sr"]="jул",
+ ["sr-latn"]="jul",
["sv"]="juli",
["tk"]="iýul",
["tr"]="temmuz",
@@ -1613,7 +1862,7 @@ data.labels={
["ca"]="",
["cs"]="čce",
["da"]="",
- ["de"]="",
+ ["de"]="Jul.",
["en"]="jul",
["es"]="jul.",
["et"]="juuli",
@@ -1635,6 +1884,8 @@ data.labels={
["ru"]="",
["sk"]="júla",
["sl"]="",
+ ["sr"]="јул.",
+ ["sr-latn"]="jul.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1648,6 +1899,8 @@ data.labels={
["ar"]="يونيو",
["ar-dz"]="جوان",
["ar-sy"]="حزيران",
+ ["be"]="чэрвня",
+ ["bg"]="юни",
["ca"]="juny",
["cn"]="六月",
["cs"]="června",
@@ -1677,6 +1930,8 @@ data.labels={
["ru"]="июня",
["sk"]="júna",
["sl"]="junij",
+ ["sr"]="јун",
+ ["sr-latn"]="jun",
["sv"]="juni",
["tk"]="iýun",
["tr"]="haziran",
@@ -1696,7 +1951,7 @@ data.labels={
["ca"]="",
["cs"]="čer.",
["da"]="",
- ["de"]="",
+ ["de"]="Jun.",
["en"]="jun",
["es"]="jun.",
["et"]="juuni",
@@ -1718,6 +1973,8 @@ data.labels={
["ru"]="",
["sk"]="júna",
["sl"]="",
+ ["sr"]="јун",
+ ["sr-latn"]="jun",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1729,6 +1986,8 @@ data.labels={
["labels"]={
["af"]="reël ",
["ar"]="سطر ",
+ ["be"]="радок ",
+ ["bg"]="ред ",
["ca"]="línia ",
["cn"]="行",
["cs"]="řádek ",
@@ -1758,6 +2017,8 @@ data.labels={
["ru"]="строка ",
["sk"]="riadok ",
["sl"]="vrstica ",
+ ["sr"]="линија ",
+ ["sr-latn"]="linija ",
["sv"]="rad ",
["tk"]="setir",
["tr"]="satır ",
@@ -1769,6 +2030,8 @@ data.labels={
["labels"]={
["af"]="reëls ",
["ar"]="السطور ",
+ ["be"]="радкi ",
+ ["bg"]="редове ",
["ca"]="línies ",
["cn"]="行",
["cs"]="řádky ",
@@ -1798,6 +2061,8 @@ data.labels={
["ru"]="строки ",
["sk"]="riadky ",
["sl"]="vrstice ",
+ ["sr"]="линије ",
+ ["sr-latn"]="linije ",
["sv"]="rader ",
["tk"]="setirler",
["tr"]="satırlar ",
@@ -1810,6 +2075,8 @@ data.labels={
["af"]="maart",
["ar"]="مارس",
["ar-sy"]="آذار",
+ ["be"]="сакавіка",
+ ["bg"]="март",
["ca"]="març",
["cn"]="三月",
["cs"]="března",
@@ -1839,6 +2106,8 @@ data.labels={
["ru"]="марта",
["sk"]="marca",
["sl"]="marec",
+ ["sr"]="март",
+ ["sr-latn"]="mart",
["sv"]="mars",
["tk"]="mart",
["tr"]="mart",
@@ -1858,7 +2127,7 @@ data.labels={
["ca"]="",
["cs"]="břez.",
["da"]="",
- ["de"]="",
+ ["de"]="Mrz.",
["en"]="mar",
["es"]="mar.",
["et"]="märts",
@@ -1880,6 +2149,8 @@ data.labels={
["ru"]="",
["sk"]="mar.",
["sl"]="",
+ ["sr"]="мар.",
+ ["sr-latn"]="mar.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1894,6 +2165,8 @@ data.labels={
["ar-dz"]="ماي",
["ar-ma"]="ماي",
["ar-sy"]="أيار",
+ ["be"]="мая",
+ ["bg"]="маӣ",
["ca"]="maig",
["cn"]="五月",
["cs"]="května",
@@ -1923,6 +2196,8 @@ data.labels={
["ru"]="мая",
["sk"]="mája",
["sl"]="maj",
+ ["sr"]="мај",
+ ["sr-latn"]="maj",
["sv"]="maj",
["tk"]="maý",
["tr"]="mayıs",
@@ -1942,7 +2217,7 @@ data.labels={
["ca"]="",
["cs"]="květ.",
["da"]="",
- ["de"]="",
+ ["de"]="Mai",
["en"]="may",
["es"]="may.",
["et"]="mai",
@@ -1964,6 +2239,8 @@ data.labels={
["ru"]="",
["sk"]="mája",
["sl"]="",
+ ["sr"]="мај",
+ ["sr-latn"]="maj",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -1975,6 +2252,8 @@ data.labels={
["labels"]={
["af"]="maandag",
["ar"]="الاثنين",
+ ["be"]="панядзелак",
+ ["bg"]="понеделник",
["ca"]="dilluns",
["cn"]="星期一",
["cs"]="pondělí",
@@ -2004,6 +2283,8 @@ data.labels={
["ru"]="понедельник",
["sk"]="pondelok",
["sl"]="ponedeljek",
+ ["sr"]="понедељак",
+ ["sr-latn"]="ponedeljak",
["sv"]="måndag",
["tk"]="birinji gün",
["tr"]="pazartesi",
@@ -2011,14 +2292,26 @@ data.labels={
["vi"]="thứ hai",
},
},
+ ["monday:mnem"]={
+ ["labels"]={
+ ["de"]="Mo.",
+ ["en"]="mon",
+ ["sr"]="пон.",
+ ["sr-latn"]="pon.",
+ },
+ },
["month"]={
["labels"]={
+ ["be"]="месяц",
+ ["bg"]="месец",
["en"]="month",
["et"]="kuu",
["kr"]="월",
["mk"]="месец",
["nl"]="maand",
["pe"]="ماه",
+ ["sr"]="месец",
+ ["sr-latn"]="mesec",
},
},
["november"]={
@@ -2027,6 +2320,8 @@ data.labels={
["ar"]="نوفمبر",
["ar-ma"]="نونبر",
["ar-sy"]="تشرين الثاني",
+ ["be"]="лістапада",
+ ["bg"]="ноември",
["ca"]="novembre",
["cn"]="十一月",
["cs"]="listopadu",
@@ -2056,6 +2351,8 @@ data.labels={
["ru"]="ноября",
["sk"]="novembra",
["sl"]="november",
+ ["sr"]="новембар",
+ ["sr-latn"]="novembar",
["sv"]="november",
["tk"]="noýabr",
["tr"]="kasım",
@@ -2075,7 +2372,7 @@ data.labels={
["ca"]="",
["cs"]="list.",
["da"]="",
- ["de"]="",
+ ["de"]="Nov.",
["en"]="nov",
["es"]="nov.",
["et"]="nov",
@@ -2097,6 +2394,8 @@ data.labels={
["ru"]="",
["sk"]="nov.",
["sl"]="",
+ ["sr"]="нов.",
+ ["sr-latn"]="nov.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2109,6 +2408,8 @@ data.labels={
["af"]="oktober",
["ar"]="أكتوبر",
["ar-sy"]="تشرين الأول",
+ ["be"]="кастрычніка",
+ ["bg"]="октомври",
["ca"]="octubre",
["cn"]="十月",
["cs"]="října",
@@ -2138,6 +2439,8 @@ data.labels={
["ru"]="октября",
["sk"]="októbra",
["sl"]="oktober",
+ ["sr"]="октобар",
+ ["sr-latn"]="oktobar",
["sv"]="oktober",
["tk"]="oktýabr",
["tr"]="ekim",
@@ -2157,7 +2460,7 @@ data.labels={
["ca"]="",
["cs"]="říj.",
["da"]="",
- ["de"]="",
+ ["de"]="Okt.",
["en"]="oct",
["es"]="oct.",
["et"]="okt",
@@ -2179,6 +2482,8 @@ data.labels={
["ru"]="",
["sk"]="okt.",
["sl"]="",
+ ["sr"]="окт.",
+ ["sr-latn"]="okt.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2190,6 +2495,8 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="صفحة ",
+ ["be"]="старонка ",
+ ["bg"]="страна",
["ca"]="",
["cs"]="strana ",
["da"]="Side ",
@@ -2217,6 +2524,8 @@ data.labels={
["ru"]="страница ",
["sk"]="strana ",
["sl"]="stran ",
+ ["sr"]="страница ",
+ ["sr-latn"]="stranica ",
["sv"]="Sida ",
["tk"]="",
["tr"]="",
@@ -2228,6 +2537,8 @@ data.labels={
["labels"]={
["af"]="Deel ",
["ar"]="جزء ",
+ ["be"]="Частка ",
+ ["bg"]="Частка ",
["ca"]="Part ",
["cn"]={ "第", "部分" },
["cs"]="Část ",
@@ -2257,6 +2568,8 @@ data.labels={
["ru"]="Часть ",
["sk"]="Časť ",
["sl"]="Del ",
+ ["sr"]="Део ",
+ ["sr-latn"]="Deo ",
["sv"]="Del ",
["tk"]="Bölüm",
["tr"]="Cilt ",
@@ -2271,12 +2584,16 @@ data.labels={
["mk"]="на претходната страница",
["nl"]="op een voorgaande bladzijde",
["pe"]="در صفحات گذشته",
+ ["sr"]="на претходној страници",
+ ["sr-latn"]="na prethodnoj stranici",
},
},
["saturday"]={
["labels"]={
["af"]="saterdag",
["ar"]="السبت",
+ ["be"]="субота",
+ ["bg"]="сряда",
["ca"]="dissabte",
["cn"]="星期六",
["cs"]="sobota",
@@ -2306,6 +2623,8 @@ data.labels={
["ru"]="суббота",
["sk"]="sobota",
["sl"]="sobota",
+ ["sr"]="субота",
+ ["sr-latn"]="subota",
["sv"]="lördag",
["tk"]="altynjy gün",
["tr"]="cumartesi",
@@ -2313,11 +2632,20 @@ data.labels={
["vi"]="thứ bảy",
},
},
+ ["saturday:mnem"]={
+ ["labels"]={
+ ["de"]="Sa.",
+ ["en"]="sat",
+ ["sr"]="суб.",
+ ["sr-latn"]="sub.",
+ },
+ },
["section"]={
["hidden"]=true,
["labels"]={
["af"]="Paragraaf ",
["ar"]="فصل ",
+ ["bg"]="Cекция ",
["ca"]="Secció ",
["cn"]={ "第", "节" },
["cs"]="Sekce ",
@@ -2336,8 +2664,8 @@ data.labels={
["kr"]={ "제", "절" },
["la"]="",
["lt"]="",
- ["nb"]="",
["mk"]="Поглавје ",
+ ["nb"]="",
["nl"]="",
["nn"]="",
["pe"]="بخش ",
@@ -2347,6 +2675,8 @@ data.labels={
["ru"]="",
["sk"]="Sekcia ",
["sl"]="",
+ ["sr"]="Одељак ",
+ ["sr-latn"]="Odeljak ",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2358,6 +2688,8 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="انظر ",
+ ["be"]="гл. ",
+ ["bg"]="погледни",
["ca"]="",
["cs"]="viz ",
["da"]="se ",
@@ -2385,6 +2717,8 @@ data.labels={
["ru"]="см. ",
["sk"]="pozri ",
["sl"]="glej ",
+ ["sr"]="види ",
+ ["sr-latn"]="vidi ",
["sv"]="se ",
["tk"]="",
["tr"]="",
@@ -2398,6 +2732,8 @@ data.labels={
["ar"]="سبتمبر",
["ar-ma"]="شتنبر",
["ar-sy"]="أيلول",
+ ["be"]="верасня",
+ ["bg"]="септември",
["ca"]="setembre",
["cn"]="九月",
["cs"]="září",
@@ -2427,6 +2763,8 @@ data.labels={
["ru"]="сентября",
["sk"]="septembra",
["sl"]="september",
+ ["sr"]="септембар",
+ ["sr-latn"]="septembar",
["sv"]="september",
["tk"]="sentýabr",
["tr"]="eylül",
@@ -2446,7 +2784,7 @@ data.labels={
["ca"]="",
["cs"]="září",
["da"]="",
- ["de"]="",
+ ["de"]="Sep.",
["en"]="sep",
["es"]="sep.",
["et"]="sept",
@@ -2468,6 +2806,8 @@ data.labels={
["ru"]="",
["sk"]="sept.",
["sl"]="",
+ ["sr"]="сеп.",
+ ["sr-latn"]="sep.",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2480,6 +2820,7 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="فصل أدنى ",
+ ["bg"]="Подсекция ",
["ca"]="Subsecció ",
["cn"]="",
["cs"]="Podsekce ",
@@ -2508,6 +2849,8 @@ data.labels={
["ru"]="",
["sk"]="Podsekcia ",
["sl"]="",
+ ["sr"]="Пододељак ",
+ ["sr-latn"]="Pododeljak ",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2520,6 +2863,7 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="فصل أدنى أدنى ",
+ ["bg"]="Подподсекция ",
["ca"]="Subsubsecció ",
["cn"]="",
["cs"]="Podpodsekce ",
@@ -2548,6 +2892,8 @@ data.labels={
["ru"]="",
["sk"]="Podpodsekcia ",
["sl"]="",
+ ["sr"]="Подпододељак ",
+ ["sr-latn"]="Podpododeljak ",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2560,6 +2906,7 @@ data.labels={
["labels"]={
["af"]="",
["ar"]="فصل أدنى أدنى أدنى ",
+ ["bg"]="Подподподсекция ",
["ca"]="Subsubsubsecció ",
["cn"]="",
["cs"]="Podpodpodsekce ",
@@ -2588,6 +2935,8 @@ data.labels={
["ru"]="",
["sk"]="Podpodpodsekcia ",
["sl"]="",
+ ["sr"]="Подподпододељак ",
+ ["sr-latn"]="Podpodpododeljak ",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -2599,6 +2948,8 @@ data.labels={
["labels"]={
["af"]="sondag",
["ar"]="الأحد",
+ ["be"]="нядзеля",
+ ["bg"]="неделя",
["ca"]="diumenge",
["cn"]="星期日",
["cs"]="neděle",
@@ -2628,6 +2979,8 @@ data.labels={
["ru"]="воскресенье",
["sk"]="nedeľa",
["sl"]="nedelja",
+ ["sr"]="недеља",
+ ["sr-latn"]="nedelja",
["sv"]="söndag",
["tk"]="dynç gün",
["tr"]="pazar",
@@ -2635,10 +2988,20 @@ data.labels={
["vi"]="chủ nhật",
},
},
+ ["sunday:mnem"]={
+ ["labels"]={
+ ["de"]="So.",
+ ["en"]="sun",
+ ["sr"]="нед.",
+ ["sr-latn"]="ned.",
+ },
+ },
["table"]={
["labels"]={
["af"]="Tabel",
["ar"]="جدول ",
+ ["be"]="Табліца ",
+ ["bg"]="Таблица ",
["ca"]="Taula ",
["cn"]="表",
["cs"]="Tabulka ",
@@ -2668,6 +3031,8 @@ data.labels={
["ru"]="Таблица ",
["sk"]="Tabuľka ",
["sl"]="Tabela ",
+ ["sr"]="Табела ",
+ ["sr-latn"]="Tabela ",
["sv"]="Tabell ",
["tk"]="Tablisa",
["tr"]="Tablo ",
@@ -2679,6 +3044,8 @@ data.labels={
["labels"]={
["af"]="donderdag",
["ar"]="الخميس",
+ ["be"]="чацвер",
+ ["bg"]="четвъртък",
["ca"]="dijous",
["cn"]="星期四",
["cs"]="čtvrtek",
@@ -2708,6 +3075,8 @@ data.labels={
["ru"]="четверг",
["sk"]="štvrtok",
["sl"]="četrtek",
+ ["sr"]="четвртак",
+ ["sr-latn"]="četvrtak",
["sv"]="torsdag",
["tk"]="dördünji gün",
["tr"]="perşembe",
@@ -2715,10 +3084,20 @@ data.labels={
["vi"]="thứ năm",
},
},
+ ["thursday:mnem"]={
+ ["labels"]={
+ ["de"]="Do.",
+ ["en"]="thu",
+ ["sr"]="чет.",
+ ["sr-latn"]="čet.",
+ },
+ },
["tuesday"]={
["labels"]={
["af"]="dinsdag",
["ar"]="الثلاثاء",
+ ["be"]="аўторак",
+ ["bg"]="вторник",
["ca"]="dimarts",
["cn"]="星期二",
["cs"]="úterý",
@@ -2748,6 +3127,8 @@ data.labels={
["ru"]="вторник",
["sk"]="utorok",
["sl"]="torek",
+ ["sr"]="уторак",
+ ["sr-latn"]="utorak",
["sv"]="tisdag",
["tk"]="ikinji gün",
["tr"]="salı",
@@ -2755,10 +3136,20 @@ data.labels={
["vi"]="thứ ba",
},
},
+ ["tuesday:mnem"]={
+ ["labels"]={
+ ["de"]="Di.",
+ ["en"]="tue",
+ ["sr"]="уто.",
+ ["sr-latn"]="uto.",
+ },
+ },
["wednesday"]={
["labels"]={
["af"]="woensdag",
["ar"]="الأربعاء",
+ ["be"]="серада",
+ ["bg"]="сряда",
["ca"]="dimecres",
["cn"]="星期三",
["cs"]="středa",
@@ -2788,6 +3179,8 @@ data.labels={
["ru"]="среда",
["sk"]="streda",
["sl"]="sreda",
+ ["sr"]="среда",
+ ["sr-latn"]="sreda",
["sv"]="onsdag",
["tk"]="üçünji",
["tr"]="çarşamba",
@@ -2795,14 +3188,25 @@ data.labels={
["vi"]="thứ tư",
},
},
+ ["wednesday:mnem"]={
+ ["labels"]={
+ ["de"]="Mi.",
+ ["en"]="wed",
+ ["sr"]="сре.",
+ ["sr-latn"]="sre.",
+ },
+ },
["year"]={
["labels"]={
+ ["bg"]="година",
["en"]="year",
["et"]="aasta",
["kr"]="년",
["mk"]="година",
["nl"]="jaar",
["pe"]="سال",
+ ["sr"]="година",
+ ["sr-latn"]="godina",
},
},
},
@@ -2811,6 +3215,8 @@ data.labels={
["labels"]={
["af"]="Afkortings",
["ar"]="الاختصارات",
+ ["be"]="Спіс скарачэнняў",
+ ["bg"]="Съкращения",
["ca"]="Abreviacions",
["cn"]="缩略语",
["cs"]="Zkratky",
@@ -2840,6 +3246,8 @@ data.labels={
["ru"]="Список сокращений",
["sk"]="Skratky",
["sl"]="Kratice",
+ ["sr"]="Скраћенице",
+ ["sr-latn"]="Skraćenice",
["sv"]="Förkortningar",
["tk"]="Gysgaltmalar",
["tr"]="Kısaltmalar",
@@ -2851,6 +3259,8 @@ data.labels={
["labels"]={
["af"]="Inhoud",
["ar"]="المحتويات",
+ ["be"]="Змест",
+ ["bg"]="Съдържание",
["ca"]="Índex de continguts",
["cn"]="目录",
["cs"]="Obsah",
@@ -2880,6 +3290,8 @@ data.labels={
["ru"]="Содержание",
["sk"]="Obsah",
["sl"]="Kazalo",
+ ["sr"]="Садржај",
+ ["sr-latn"]="Sadržaj",
["sv"]="Innehåll",
["tk"]="Mazmuny",
["tr"]="Fihrist",
@@ -2891,6 +3303,7 @@ data.labels={
["labels"]={
["af"]="Figure",
["ar"]="الأشكال",
+ ["be"]="Спіс ілюстрацый",
["ca"]="Figures",
["cn"]="图形",
["cs"]="Seznam obrázků",
@@ -2920,6 +3333,8 @@ data.labels={
["ru"]="Список иллюстраций",
["sk"]="Zoznam obrázkov",
["sl"]="Slike",
+ ["sr"]="Слике",
+ ["sr-latn"]="Slike",
["sv"]="Figurer",
["tk"]="Suratlar",
["tr"]="Şekiller",
@@ -2931,6 +3346,7 @@ data.labels={
["labels"]={
["af"]="Grafieke",
["ar"]="الرسوم",
+ ["be"]="Графiка",
["ca"]="Gràfiques",
["cn"]="图",
["cs"]="Seznam grafů",
@@ -2960,6 +3376,8 @@ data.labels={
["ru"]="Список графиков",
["sk"]="Zoznam grafov",
["sl"]="Slike",
+ ["sr"]="Графици",
+ ["sr-latn"]="Grafici",
["sv"]="Grafik",
["tk"]="Grafikler",
["tr"]="Grafikler",
@@ -2971,6 +3389,8 @@ data.labels={
["labels"]={
["af"]="Indeks",
["ar"]="الفهرس",
+ ["be"]="Алфавітны паказальнік",
+ ["bg"]="Индэкс",
["ca"]="Índex alfabètic",
["cn"]="索引",
["cs"]="Rejstřík",
@@ -3000,6 +3420,9 @@ data.labels={
["ru"]="Алфавитный указатель",
["sk"]="Zoznam",
["sl"]="Stvarno kazalo",
+ ["sr"]="Индекс",
+ ["sr"]="Индекс појмова",
+ ["sr-latn"]="Indeks pojmova",
["sv"]="Sakregister",
["tk"]="Indeks",
["tr"]="İndex",
@@ -3011,6 +3434,7 @@ data.labels={
["labels"]={
["af"]="Intermezzos",
["ar"]="فسح",
+ ["be"]="Спіс уставак",
["ca"]="Intermedis",
["cn"]="퉣",
["cs"]="Intermezza",
@@ -3039,6 +3463,9 @@ data.labels={
["ru"]="Список вставок",
["sk"]="Intermezzá",
["sl"]="Intermezzi",
+ ["sr"]="Интермеззи",
+ ["sr"]="Списак дигресија",
+ ["sr-latn"]="Spisak digresija",
["sv"]="Intermezzon",
["tk"]="Arakesmeler",
["tr"]="",
@@ -3050,6 +3477,8 @@ data.labels={
["labels"]={
["af"]="Logos",
["ar"]="الشعارات",
+ ["be"]="Лагатыпы",
+ ["bg"]="Логотипи",
["ca"]="Logotips",
["cn"]="徽贬",
["cs"]="Loga",
@@ -3079,6 +3508,8 @@ data.labels={
["ru"]="Логотипы",
["sk"]="Logá",
["sl"]="Logotipi",
+ ["sr"]="Логотипи",
+ ["sr-latn"]="Logotipi",
["sv"]="Loggor",
["tk"]="Logolar",
["tr"]="Logolar",
@@ -3116,6 +3547,8 @@ data.labels={
["ru"]="",
["sk"]="Literatúra",
["sl"]="Literatura",
+ ["sr"]="Литература",
+ ["sr-latn"]="Literatura",
["sv"]="",
["tk"]="",
["tr"]="",
@@ -3127,6 +3560,7 @@ data.labels={
["labels"]={
["af"]="Tabelle",
["ar"]="الجداول",
+ ["be"]="Спіс табліц",
["ca"]="Taules",
["cn"]="表格",
["cs"]="Seznam tabulek",
@@ -3156,6 +3590,8 @@ data.labels={
["ru"]="Список таблиц",
["sk"]="Zoznam tabuliek",
["sl"]="Tabele",
+ ["sr"]="Табеле",
+ ["sr-latn"]="Tabele",
["sv"]="Tabeller",
["tk"]="Tablisalar",
["tr"]="Tablolar",
@@ -3167,6 +3603,8 @@ data.labels={
["labels"]={
["af"]="Eenhede",
["ar"]="الوحدات",
+ ["be"]="Адзінкі вымярэння",
+ ["bg"]="Адзінкі",
["ca"]="Unitats",
["cn"]="计量单位",
["cs"]="Jednotky",
@@ -3196,6 +3634,8 @@ data.labels={
["ru"]="Единицы измерения",
["sk"]="Jednotky",
["sl"]="Enote",
+ ["sr"]="Јединице",
+ ["sr-latn"]="Jedinice",
["sv"]="Enheter",
["tk"]="Birlikler",
["tr"]="Birimler",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-url.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-url.lua
index 7428d64ab24..7a8b7ca86c3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-url.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-url.lua
@@ -9,7 +9,9 @@ if not modules then modules = { } end modules ['lang-url'] = {
local utfcharacters, utfbyte, utfchar = utf.characters, utf.byte, utf.char
local min, max = math.min, math.max
-local context = context
+local context = context
+local ctx_pushcatcodes = context.pushcatcodes
+local ctx_popcatcodes = context.popcatcodes
local implement = interfaces.implement
local variables = interfaces.variables
@@ -190,9 +192,9 @@ local function action(hyphenatedurl,str,left,right,disc)
end
end
if dodi then
- list[i] = "\\d"
+ list[i] = "\\lang_url_d "
else
- list[i] = "\\" .. what .. "{" .. utfbyte(char) .. "}"
+ list[i] = "\\lang_url_" .. what .. "{" .. utfbyte(char) .. "}"
end
prev = char
end
@@ -200,7 +202,9 @@ local function action(hyphenatedurl,str,left,right,disc)
report("old : %s",str)
report("new : %t",list)
end
+ ctx_pushcatcodes("prtcatcodes")
context("%t",list)
+ ctx_popcatcodes()
end
-- urls.action = function(_,...) action(...) end -- sort of obsolete
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-url.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lang-url.mkiv
index 6afef63cee2..8f1a979dc56 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-url.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-url.mkiv
@@ -100,22 +100,17 @@
{\dontleavehmode
\begingroup
\the\everyhyphenatedurl
- \normallanguage\zerocount
- \let\a\lang_url_a % after
- \let\b\lang_url_b % before
- \let\d\lang_url_d % disc
- \let\l\lang_url_l % letter
- \let\c\lang_url_c % character
- \let\L\lang_url_L % letter_nobreak
- \let\C\lang_url_C % character_nobreak
+ \normallanguage\zerocount % \nohyphens in mkiv
\scratchskipone\zeropoint\s!plus\dimexpr\emwidth/12\s!minus\dimexpr\emwidth/24\relax % 1.00pt @ 12pt
\scratchskiptwo\zeropoint\s!plus\dimexpr\emwidth/48\s!minus\dimexpr\emwidth/96\relax % 0.25pt @ 12pt
+ \unprotect
\normalexpanded{\noexpand\clf_hyphenatedurl
{\noexpand\detokenize{#1}}%
\hyphenatedurllefthyphenmin
\hyphenatedurlrighthyphenmin
{\hyphenatedurldiscretionary}%
}%
+ \protect
\endgroup}
%D \macros
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
index 9fbced2ce95..1c440bd7f2a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
@@ -39,7 +39,7 @@ local getid = nuts.getid
local getchar = nuts.getchar
local setattr = nuts.setattr
----- getattr = nuts.getattr
-local getlang = nuts.getlang
+local getlanguage = nuts.getlanguage
local ischar = nuts.ischar
local nextnode = nuts.traversers.node
@@ -163,7 +163,7 @@ local function mark_words(head,whenfound) -- can be optimized and shared
while current do
local code, id = ischar(current) -- not isglyph because otherwise we can run into
if code then -- processed streams (\about[foo] does that)
- local a = getlang(current)
+ local a = getlanguage(current)
if a then
if a ~= language then
if s > 0 then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-curl.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-curl.lua
deleted file mode 100644
index b307397948c..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-curl.lua
+++ /dev/null
@@ -1,296 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-curl'] = {
- version = 1.001,
- comment = "companion to luat-lib.mkxl",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/curl/libcurl.dll
-
-local libname = "curl"
-local libfile = "libcurl"
-
-local curllib = resolvers.libraries.validoptional(libname)
-
-if not curllib then return end
-
--- We're good, so we continue.
-
-local next, type = next, type
-local lower, gsub = string.lower, string.gsub
-
-local mapping = {
- ["acceptencoding"] = 102,
- ["accepttimeoutms"] = 212,
- ["addressscope"] = 171,
- ["append"] = 50,
- ["autoreferer"] = 58,
- ["buffersize"] = 98,
- ["cainfo"] = 65,
- ["capath"] = 97,
- ["certinfo"] = 172,
- -- ["chunkbgnfunction"] = 198,
- ["chunkdata"] = 201,
- -- ["chunkendfunction"] = 199,
- ["closepolicy"] = 72,
- ["closesocketdata"] = 209,
- -- ["closesocketfunction"] = 208,
- ["connectonly"] = 141,
- ["connecttimeout"] = 78,
- ["connecttimeoutms"] = 156,
- -- ["convfromnetworkfunction"] = 142,
- -- ["convfromutf8function"] = 144,
- -- ["convtonetworkfunction"] = 143,
- ["cookie"] = 22,
- ["cookiefile"] = 31,
- ["cookiejar"] = 82,
- ["cookielist"] = 135,
- ["cookiesessionv"] = 96,
- ["copypostfields"] = 165,
- ["crlf"] = 27,
- ["crlfile"] = 169,
- ["customrequest"] = 36,
- ["debugdata"] = 95,
- -- ["debugfunction"] = 94,
- ["dirlistonly"] = 48,
- ["dnscachetimeout"] = 92,
- ["dnsinterface"] = 221,
- ["dnslocalip4"] = 222,
- ["dnslocalip6"] = 223,
- ["dnsservers"] = 211,
- ["dnsuseglobalcache"] = 91,
- ["egdsocket"] = 77,
- ["errorbuffer"] = 10,
- ["expect100timeoutms"] = 227,
- ["failonerror"] = 45,
- ["file"] = 1,
- ["filetime"] = 69,
- ["fnmatchdata"] = 202,
- -- ["fnmatchfunction"] = 200,
- ["followlocation"] = 52,
- ["forbidreuse"] = 75,
- ["freshconnect"] = 74,
- ["ftpaccount"] = 134,
- ["ftpalternativetouser"] = 147,
- ["ftpcreatemissingdirs"] = 110,
- ["ftpfilemethod"] = 138,
- ["ftpresponsetimeout"] = 112,
- ["ftpskippasvip"] = 137,
- ["ftpsslccc"] = 154,
- ["ftpuseeprt"] = 106,
- ["ftpuseepsv"] = 85,
- ["ftpusepret"] = 188,
- ["ftpport"] = 17,
- ["ftpsslauth"] = 129,
- ["gssapidelegation"] = 210,
- ["header"] = 42,
- ["headerdata"] = 29,
- -- ["headerfunction"] = 79,
- ["http200aliases"] = 104,
- ["httpcontentdecoding"] = 158,
- ["httptransferdecoding"] = 157,
- ["httpversion"] = 84,
- ["httpauth"] = 107,
- ["httpget"] = 80,
- ["httpheader"] = 23,
- ["httppost"] = 24,
- ["httpproxytunnel"] = 61,
- ["ignorecontentlength"] = 136,
- ["infile"] = 9,
- ["infilesize"] = 14,
- ["infilesizelarge"] = 115,
- ["interface"] = 62,
- ["interleavedata"] = 195,
- -- ["interleavefunction"] = 196,
- ["ioctldata"] = 131,
- -- ["ioctlfunction"] = 130,
- ["ipresolve"] = 113,
- ["issuercert"] = 170,
- ["keypasswd"] = 26,
- ["krblevel"] = 63,
- ["localport"] = 139,
- ["localportrange"] = 140,
- ["loginoptions"] = 224,
- ["lowspeedlimit"] = 19,
- ["lowspeedtime"] = 20,
- ["mailauth"] = 217,
- ["mailfrom"] = 186,
- ["mailrcpt"] = 187,
- ["maxrecvspeedlarge"] = 146,
- ["maxsendspeedlarge"] = 145,
- ["maxconnects"] = 71,
- ["maxfilesize"] = 114,
- ["maxfilesizelarge"] = 117,
- ["maxredirs"] = 68,
- ["netrc"] = 51,
- ["netrcfile"] = 118,
- ["newdirectoryperms"] = 160,
- ["newfileperms"] = 159,
- ["nobody"] = 44,
- ["noprogress"] = 43,
- ["noproxy"] = 177,
- ["nosignal"] = 99,
- ["opensocketdata"] = 164,
- -- ["opensocketfunction"] = 163,
- ["password"] = 174,
- ["port"] = 3,
- ["post"] = 47,
- -- ["postfields"] = 15,
- -- ["postfieldsize"] = 60,
- -- ["postfieldsizelarge"] = 120,
- ["postquote"] = 39,
- ["postredir"] = 161,
- ["prequote"] = 93,
- ["private"] = 103,
- ["progressdata"] = 57,
- -- ["progressfunction"] = 56,
- ["protocols"] = 181,
- ["proxy"] = 4,
- ["proxytransfermode"] = 166,
- ["proxyauth"] = 111,
- ["proxypassword"] = 176,
- ["proxyport"] = 59,
- ["proxytype"] = 101,
- ["proxyusername"] = 175,
- ["proxyuserpwd"] = 6,
- ["put"] = 54,
- ["quote"] = 28,
- ["randomfile"] = 76,
- ["range"] = 7,
- ["readdata"] = 9,
- -- ["readfunction"] = 12,
- ["redirprotocols"] = 182,
- ["referer"] = 16,
- ["resolve"] = 203,
- ["resumefrom"] = 21,
- ["resumefromlarge"] = 116,
- ["rtspclientcseq"] = 193,
- ["rtsprequest"] = 189,
- ["rtspservercseq"] = 194,
- ["rtspsessionid"] = 190,
- ["rtspstreamuri"] = 191,
- ["rtsptransport"] = 192,
- ["rtspheader"] = 23,
- ["saslir"] = 218,
- ["seekdata"] = 168,
- -- ["seekfunction"] = 167,
- ["serverresponsetimeout"] = 112,
- ["share"] = 100,
- ["sockoptdata"] = 149,
- -- ["sockoptfunction"] = 148,
- ["socks5gssapinec"] = 180,
- ["socks5gssapiservice"] = 179,
- ["sshauthtypes"] = 151,
- ["sshhostpublickeymd5"] = 162,
- ["sshkeydata"] = 185,
- -- ["sshkeyfunction"] = 184,
- ["sshknownhosts"] = 183,
- ["sshprivatekeyfile"] = 153,
- ["sshpublickeyfile"] = 152,
- ["sslcipherlist"] = 83,
- ["sslctxdata"] = 109,
- -- ["sslctxfunction"] = 108,
- ["sslenablealpn"] = 226,
- ["sslenablenpn"] = 225,
- ["ssloptions"] = 216,
- ["sslsessionidcache"] = 150,
- ["sslverifyhost"] = 81,
- ["sslverifypeer"] = 64,
- ["sslcert"] = 25,
- ["sslcerttype"] = 86,
- ["sslengine"] = 89,
- ["sslenginedefault"] = 90,
- ["sslkey"] = 87,
- ["sslkeytype"] = 88,
- ["sslversion"] = 32,
- ["stderr"] = 37,
- ["tcpkeepalive"] = 213,
- ["tcpkeepidle"] = 214,
- ["tcpkeepintvl"] = 215,
- ["tcpnodelay"] = 121,
- ["telnetoptions"] = 70,
- ["tftpblksize"] = 178,
- ["timecondition"] = 33,
- ["timeout"] = 13,
- ["timeoutms"] = 155,
- ["timevalue"] = 34,
- ["tlsauthpassword"] = 205,
- ["tlsauthtype"] = 206,
- ["tlsauthusername"] = 204,
- ["transferencoding"] = 207,
- ["transfertext"] = 53,
- ["unrestrictedauth"] = 105,
- ["upload"] = 46,
- ["url"] = 2,
- ["usessl"] = 119,
- ["useragent"] = 18,
- ["username"] = 173,
- ["userpwd"] = 5,
- ["verbose"] = 41,
- ["wildcardmatch"] = 197,
- ["writedata"] = 1,
- -- ["writefunction"] = 11,
- ["writeheader"] = 29,
- ["writeinfo"] = 40,
- ["xferinfodata"] = 57,
- -- ["xferinfofunction"] = 219,
- ["xoauth2bearer"] = 220,
-}
-
-table.setmetatableindex(mapping,function(t,k)
- local s = gsub(lower(k),"[^a-z0-9]","")
- local v = rawget(t,s) or false
- t[k] = v
- return v
-end)
-
-local curl_fetch = curllib.fetch
-local curl_escape = curllib.escape
-local curl_unescape = curllib.unescape
-local curl_getversion = curllib.getversion
-
-local report = logs.reporter(libname)
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local function fetch(options)
- if okay() then
- local t = type(options)
- if t == "table" then
- local o = { }
- for name, value in next, options do
- local index = mapping[name]
- if index then
- o[index] = value
- end
- end
- return curl_fetch(o)
- elseif t == "string" then
- return curl_fetch { [mapping.url] = options }
- else
- report("invalid argument")
- end
- end
-end
-
-local curl = {
- getversion = function () return okay() and curl_getversion() end,
- escape = function (s) return okay() and curl_escape (s) end,
- unescape = function (s) return okay() and curl_unescape (s) end,
- fetch = fetch,
-}
-
--- inspect(curl.fetch("http://www.pragma-ade.com/index.html"))
--- inspect(curl.fetch { url = "http://www.pragma-ade.com/index.html" })
-
-package.loaded[libname] = curl
-
-return curl
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-ghostscript.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-ghostscript.lua
deleted file mode 100644
index b129a58c143..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-ghostscript.lua
+++ /dev/null
@@ -1,111 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-ghostscript'] = {
- version = 1.001,
- comment = "companion to luat-lib.mkxl",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
-local libname = "ghostscript"
-local libfile = "gsdll64" -- what on unix?
-
-local gslib = resolvers.libraries.validoptional(libname)
-
-if not gslib then return end
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local insert = table.insert
-local formatters = string.formatters
-
-local ghostscript = utilities.ghostscript or { }
-utilities.ghostscript = ghostscript
-
-local gs_execute = gslib.execute
-local nofruns = 0
-local report = logs.reporter(libname)
-
-function ghostscript.convert(specification)
- if okay() then
- --
- nofruns = nofruns + 1
- statistics.starttiming(ghostscript)
- --
- local inputname = specification.inputname
- if not inputname or inputname == "" then
- report("invalid run %s, no inputname specified",nofruns)
- statistics.stoptiming(ghostscript)
- return false
- end
- local outputname = specification.outputname
- if not outputname or outputname == "" then
- outputname = file.replacesuffix(inputname,"pdf")
- end
- --
- if not lfs.isfile(inputname) then
- report("invalid run %s, input file %a is not found",nofruns,inputname)
- statistics.stoptiming(ghostscript)
- return false
- end
- --
- local device = specification.device
- if not device or device == "" then
- device = "pdfwrite"
- end
- --
- local code = specification.code
- if not code or code == "" then
- code = ".setpdfwrite"
- end
- --
- local options = specification.options or { }
- --
- insert(options,"-dNOPAUSE")
- insert(options,"-dBATCH")
- insert(options,"-dSAFER")
- insert(options,formatters["-sDEVICE=%s"](device))
- insert(options,formatters["-sOutputFile=%s"](outputname))
- insert(options,"-c")
- insert(options,code)
- insert(options,"-f")
- insert(options,inputname)
- --
- report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname)
- report("")
- local done = gslib_execute(options)
- report("")
- --
- statistics.stoptiming(ghostscript)
- if done then
- return outputname
- else
- report("run %s quit with errors",nofruns)
- return false
- end
- end
-end
-
-function ghostscript.statistics(report)
- local runtime = statistics.elapsedtime(ghostscript)
- if report then
- report("nofruns %s, runtime %s",nofruns,runtime)
- else
- return {
- runtime = runtime,
- nofruns = nofruns,
- }
- end
-end
-
--- for i=1,100 do
--- ghostscript.convert { inputname = "temp.eps" }
--- ghostscript.convert { inputname = "t:/escrito/tiger.eps" }
--- end
--- ghostscript.statistics(true)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-graphicsmagick.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-graphicsmagick.lua
deleted file mode 100644
index 6f5d1d967fd..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-graphicsmagick.lua
+++ /dev/null
@@ -1,77 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-graphicsmagick'] = {
- version = 1.001,
- comment = "companion to luat-lib.mkxl",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
-local libname = "graphicsmagick"
-local libfile = { "CORE_RL_magick_", "CORE_RL_wand_" }
-
-local gmlib = resolvers.libraries.validoptional(libname)
-
-if not gmlib then return end
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local graphicsmagick = utilities.graphicsmagick or { }
-utilities.graphicsmagick = graphicsmagick
-utilities.graphicmagick = graphicsmagick
-
-local gm_execute = gmlib.execute
-local nofruns = 0
-local report = logs.reporter(libname)
-
-function graphicsmagick.convert(specification)
- if okay() then
- --
- nofruns = nofruns + 1
- statistics.starttiming(graphicsmagick)
- --
- local inputname = specification.inputname
- if not inputname or inputname == "" then
- report("invalid run %s, no inputname specified",nofruns)
- statistics.stoptiming(graphicsmagick)
- return false
- end
- local outputname = specification.outputname
- if not outputname or outputname == "" then
- outputname = file.replacesuffix(inputname,"pdf")
- end
- --
- if not lfs.isfile(inputname) then
- report("invalid run %s, input file %a is not found",nofruns,inputname)
- statistics.stoptiming(graphicsmagick)
- return false
- end
- --
- report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname)
- --
- gm_execute { inputfile = inputname, outputfile = outputname }
- --
- statistics.stoptiming(graphicsmagick)
- end
-end
-
-function graphicsmagick.statistics(report)
- local runtime = statistics.elapsedtime(graphicsmagick)
- if report then
- report("nofruns %s, runtime %s",nofruns,runtime)
- else
- return {
- runtime = runtime,
- nofruns = nofruns,
- }
- end
-end
-
--- graphicsmagick.convert { inputname = "t:/sources/hacker.jpg", outputname = "e:/tmp/hacker.png" }
--- graphicsmagick.statistics(true)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mujs.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mujs.lua
deleted file mode 100644
index 264c8e53126..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mujs.lua
+++ /dev/null
@@ -1,126 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-mujs'] = {
- version = 1.001,
- comment = "companion to luat-imp-mujs.mkxl",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- This is an experiment. When a new user knows \JAVASCRIPT\ it can be a
--- stepping stone to using \LUA.
-
--- local ecmascript = optional.mujs.initialize("libmujs")
--- local execute = optional.mujs.execute
-
-local libname = "mujs"
-local libfile = "libmujs"
-
-if package.loaded[libname] then
- return package.loaded[libname]
-end
-
-local mujslib = resolvers.libraries.validoptional(libname)
-
-if not mujslib then
- return
-end
-
-local files = { }
-local openfile = io.open
-local findfile = resolvers.findfile
-
-local mujs_execute = mujslib.execute
-local mujs_dofile = mujslib.dofile
-local mujs_reset = mujslib.reset
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- mujs_execute(
- "var catcodes = { " ..
- "'tex': " .. tex.texcatcodes .. "," ..
- "'ctx': " .. tex.ctxcatcodes .. "," ..
- "'prt': " .. tex.prtcatcodes .. "," ..
- "'vrb': " .. tex.vrbcatcodes .. "," ..
- "};"
- )
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-mujslib.setfindfile(findfile)
-
-mujslib.setopenfile(function(name)
- local full = findfile(name)
- if full then
- local f = openfile(full,"rb")
- if f then
- for i=1,100 do
- if not files[i] then
- files[i] = f
- return i
- end
- end
- end
- end
-end)
-
-mujslib.setclosefile(function(id)
- local f = files[id]
- if f then
- f:close()
- files[id] = false
- end
-end)
-
-mujslib.setreadfile(function(id,how)
- local f = files[id]
- if f then
- return (f:read(how or "*l"))
- end
-end)
-
-mujslib.setseekfile(function(id,whence,offset)
- local f = files[id]
- if f then
- return (f:seek(whence,offset))
- end
-end)
-
-local reporters = {
- console = logs.reporter("mujs","console"),
- report = logs.reporter("mujs","report"),
-}
-
-mujslib.setconsole(function(category,name)
- reporters[category](name)
-end)
-
-local mujs = {
- ["execute"] = function(c,s) if okay() then mujs_execute(c,s) end end,
- ["dofile"] = function(n) if okay() then mujs_dofile(n) end end,
- ["reset"] = function(n) if okay() then mujs_reset(n) end end,
-}
-
-package.loaded[libname] = mujs
-
-optional.loaded.mujs = mujs
-
-interfaces.implement {
- name = "ecmacode",
- actions = mujs.execute,
- arguments = "string",
- public = true,
-}
-
-interfaces.implement {
- name = "ecmafile",
- actions = mujs.dofile,
- arguments = "string",
- public = true,
- protected = true,
-}
-
-return mujs
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mujs.mkxl b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mujs.mkxl
deleted file mode 100644
index 0f278dff5b2..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mujs.mkxl
+++ /dev/null
@@ -1,121 +0,0 @@
-%D \module
-%D [ file=libs-imp-mujs,
-%D version=2020.02.08,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=MuJS interpreter,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D Just an experiment:
-%D
-%D \starttyping
-%D http://mujs.com
-%D \stoptyping
-
-\ifdefined\ecmacode
- \expandafter \endinput
-\fi
-
-\registerctxluafile{libs-imp-mujs}{}
-
-\unprotect
-
-% todo: environment
-
-\let\stopecmacode\relax
-
-\normalprotected\def\startecmacode % \stopecmacode
- {\begingroup
- \obeylualines
- \obeyluatokens
- \luat_start_ecma_code_indeed}
-
-\def\luat_start_ecma_code_indeed#1\stopecmacode
- {\normalexpanded{\endgroup\noexpand\ecmacode{#1}}}
-
-\protect
-
-\continueifinputfile{libs-imp-mujs.mkxl}
-
-\usemodule[article-basic,abbreviations-logos]
-
-\starttext
-
-\startbuffer
-\startluacode
- local mujs = require("libs-imp-mujs")
-
- mujs.execute [[
- var MyMax = 1000;
- ]]
-
- mujs.execute [[
- console("Example One!");
- texsprint("\\startpacked");
- for (var i = 1; i <= MyMax; i = i + 1) {
- texprint(
- "This is a buildbot compilation challenge for Mojca: "
- .concat(Math.sqrt(i/MyMax))
- .concat("!\\par")
- );
- }
- texsprint("\\stoppacked");
- ]]
-
- -- mujs.execute [[
- -- something very bad: an error
- -- ]]
-\stopluacode
-
-\startecmacode
- console("Example Two!");
- for (var i = 1; i <= MyMax; i = i + 1) {
- texsprint(
- "And an opportunity for Alan to attract highschool students to \\TeX: "
- .concat(i)
- .concat("! ")
- );
- }
-\stopecmacode
-
-\ecmacode {
- console("Example Three!");
- texprint("And otherwise a way to prototype \\JAVASCRIPT\\ code in \\PDF.")
-}
-
-\startecmacode
- var f = File("libs-imp-mujs.mkxl","r");
- console(f);
- // var l = f.read(400);
- var l = f.read("*a");
- console(l);
- f.close();
-\stopecmacode
-
-\startecmacode
- console("Example Four!");
- texsprint("\\startMPcode "
- .concat(' fill fullcircle scaled 6cm withcolor "darkred";')
- .concat(' fill fullcircle scaled 4cm withcolor "darkgreen";')
- .concat(' fill fullcircle scaled 2cm withcolor "darkblue";')
- .concat("\\stopMPcode ")
- );
-\stopecmacode
-
-\startluacode
- context.startMPcode()
- context('fill fullcircle scaled 6cm withcolor "middlecyan";')
- context('fill fullcircle scaled 4cm withcolor "middlemagenta";')
- context('fill fullcircle scaled 2cm withcolor "middleyellow";')
- context.stopMPcode()
-\stopluacode
-\stopbuffer
-
-\typebuffer \page \getbuffer
-
-\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mysql.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mysql.lua
deleted file mode 100644
index 3e938a6de48..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-mysql.lua
+++ /dev/null
@@ -1,220 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-mysql'] = {
- version = 1.001,
- comment = "companion to util-sql.lua",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/mysql/libmysql.dll
-
-local libname = "mysql"
-local libfile = "libmysql"
-
-local mysqllib = resolvers.libraries.validoptional(libname)
-
-if not mysqllib then return end
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local lpegmatch = lpeg.match
-local setmetatable = setmetatable
-
-local sql = utilities.sql or require("util-sql")
-local report = logs.reporter(libname)
-
-local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
-local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
-
-local mysql_open = mysqllib.open
-local mysql_close = mysqllib.close
-local mysql_execute = mysqllib.execute
-local mysql_getmessage = mysqllib.getmessage
-
-local helpers = sql.helpers
-local methods = sql.methods
-local validspecification = helpers.validspecification
-local preparetemplate = helpers.preparetemplate
-local querysplitter = helpers.querysplitter
-local cache = { }
-local timeout -- = 3600 -- to be tested
-
-local function connect(specification)
- local db = mysql_open(
- specification.database or "",
- specification.username or "",
- specification.password or "",
- specification.host or "",
- specification.port
- )
- if db and timeout then
- mysql_execute(db,formatters["SET SESSION connect_timeout=%s ;"](timeout))
- end
- return db
-end
-
-local function execute_once(specification,retry)
- if okay() then
- if trace_sql then
- report("executing mysql")
- end
- if not validspecification(specification) then
- report("error in specification")
- end
- local query = preparetemplate(specification)
- if not query then
- report("error in preparation")
- return
- else
- query = lpegmatch(querysplitter,query)
- end
- local base = specification.database -- or specification.presets and specification.presets.database
- if not base then
- report("no database specified")
- return
- end
- local result = { }
- local keys = { }
- local id = specification.id
- local db = nil
- if id then
- local session = cache[id]
- if session then
- db = session.db
- else
- db = connect(specification)
- if not db then
- report("no session database specified")
- else
- cache[id] = {
- specification = specification,
- db = db,
- }
- end
- end
- else
- db = connect(specification)
- end
- if not db then
- report("no database opened")
- else
- local converter = specification.converter
- local nofrows = 0
- local callback = nil
- if converter then
- local convert = converter.mysql
- callback = function(nofcolumns,values,fields)
- nofrows = nofrows + 1
- result[nofrows] = convert(values)
- end
- else
- callback = function(nofcolumns,values,fields)
- local column = { }
- for i=1,nofcolumns do
- local field
- if fields then
- field = fields[i]
- keys[i] = field
- else
- field = keys[i]
- end
- if field then
- column[field] = values[i]
- end
- end
- nofrows = nofrows + 1
- result[nofrows] = column
- end
- end
- for i=1,#query do
- local okay = mysql_execute(db,query[i],callback)
- if not okay then
- if id and retry and i == 1 then
- report("error: %s, retrying to connect",mysql_getmessage(db))
- mysql_close(db)
- cache[id] = nil
- return execute_once(specification,false)
- else
- report("error: %s",mysql_getmessage(db))
- end
- end
- end
- end
- if db and not id then
- mysql_close(db)
- end
- -- bonus
- local one = result[1]
- if one then
- setmetatable(result,{ __index = one } )
- end
- --
- return result, keys
- else
- report("error: ","no library loaded")
- end
-end
-
-local function execute(specification)
- return execute_once(specification,true)
-end
-
--- Here we build the dataset stepwise so we don't use the data hack that
--- is used in the client variant.
-
-local wraptemplate = [[
-local converters = utilities.sql.converters
-local deserialize = utilities.sql.deserialize
-
-local tostring = tostring
-local tonumber = tonumber
-local booleanstring = string.booleanstring
-
-%s
-
-return function(cells)
- -- %s (not needed)
- -- %s (not needed)
- return {
- %s
- }
-end
-]]
-
--- return function(result)
--- if not result then
--- return { }
--- end
--- local nofrows = #result
--- if nofrows == 0 then
--- return { }
--- end
--- local target = { } -- no %s needed here
--- for i=1,nofrows do
--- target[%s] = {
--- %s
--- }
--- end
--- return result
--- end
-
-local celltemplate = "cells[%s]"
-
-methods.mysql = {
- execute = execute,
- usesfiles = false,
- wraptemplate = wraptemplate,
- celltemplate = celltemplate,
-}
-
-package.loaded["util-sql-imp-ffi"] = methods.mysql
-package.loaded["util-sql-imp-mysql"] = methods.mysql
-package.loaded["util-sql-imp-library"] = methods.mysql
-package.loaded[libname] = methods.mysql
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-postgress.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-postgress.lua
deleted file mode 100644
index 629079b01a5..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-postgress.lua
+++ /dev/null
@@ -1,200 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-postgress'] = {
- version = 1.001,
- comment = "companion to util-sql.lua",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- Not yet untested !
-
--- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/postgress/libpq.dll
-
--- we can now share the code between mysql, postgress, sqlite ... todo
-
-local libname = "postgress"
-local libfile = "libpq"
-
-local postgresslib = resolvers.libraries.validoptional(libname)
-
-if not postgresslib then return end
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local lpegmatch = lpeg.match
-local setmetatable = setmetatable
-
-local sql = utilities.sql or require("util-sql")
-local report = logs.reporter(libname)
-
-local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
-local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
-
-local postgress_open = postgresslib.open
-local postgress_close = postgresslib.close
-local postgress_execute = postgresslib.execute
-local postgress_getmessage = postgresslib.getmessage
-
-local helpers = sql.helpers
-local methods = sql.methods
-local validspecification = helpers.validspecification
-local preparetemplate = helpers.preparetemplate
-local querysplitter = helpers.querysplitter -- not needed
-local cache = { }
-
-local function connect(specification)
- return postgress_open(
- specification.database or "",
- specification.username or "",
- specification.password or "",
- specification.host or "",
- specification.port
- )
-end
-
-local function execute_once(specification,retry)
- if okay() then
- if trace_sql then
- report("executing postgress")
- end
- if not validspecification(specification) then
- report("error in specification")
- end
- local query = preparetemplate(specification)
- if not query then
- report("error in preparation")
- return
- else
- query = lpegmatch(querysplitter,query) -- not needed
- end
- local base = specification.database -- or specification.presets and specification.presets.database
- if not base then
- report("no database specified")
- return
- end
- local result = { }
- local keys = { }
- local id = specification.id
- local db = nil
- if id then
- local session = cache[id]
- if session then
- db = session.db
- else
- db = connect(specification)
- if not db then
- report("no session database specified")
- else
- cache[id] = {
- specification = specification,
- db = db,
- }
- end
- end
- else
- db = connect(specification)
- end
- if not db then
- report("no database opened")
- else
- local converter = specification.converter
- local nofrows = 0
- local callback = nil
- if converter then
- local convert = converter.postgress
- callback = function(nofcolumns,values,fields)
- nofrows = nofrows + 1
- result[nofrows] = convert(values)
- end
- else
- callback = function(nofcolumns,values,fields)
- local column = { }
- for i=1,nofcolumns do
- local field
- if fields then
- field = fields[i]
- keys[i] = field
- else
- field = keys[i]
- end
- if field then
- column[field] = values[i]
- end
- end
- nofrows = nofrows + 1
- result[nofrows] = column
- end
- end
- for i=1,#query do
- local okay = postgress_execute(db,query[i],callback)
- if not okay then
- if id and retry and i == 1 then
- report("error: %s, retrying to connect",postgress_getmessage(db))
- postgress_close(db)
- cache[id] = nil
- return execute_once(specification,false)
- else
- report("error: %s",postgress_getmessage(db))
- end
- end
- end
- end
- if db and not id then
- postgress_close(db)
- end
- -- bonus
- local one = result[1]
- if one then
- setmetatable(result,{ __index = one } )
- end
- --
- return result, keys
- else
- report("error: ","no library loaded")
- end
-end
-
-local function execute(specification)
- return execute_once(specification,true)
-end
-
--- Here we build the dataset stepwise so we don't use the data hack that
--- is used in the client variant.
-
-local wraptemplate = [[
-local converters = utilities.sql.converters
-local deserialize = utilities.sql.deserialize
-
-local tostring = tostring
-local tonumber = tonumber
-local booleanstring = string.booleanstring
-
-%s
-
-return function(cells)
- -- %s (not needed)
- -- %s (not needed)
- return {
- %s
- }
-end
-]]
-
-local celltemplate = "cells[%s]"
-
-methods.postgress = {
- execute = execute,
- usesfiles = false,
- wraptemplate = wraptemplate,
- celltemplate = celltemplate,
-}
-
-package.loaded["util-sql-imp-postgress"] = methods.postgress
-package.loaded[libname] = methods.postgress
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-sqlite.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-sqlite.lua
deleted file mode 100644
index 5d38986f347..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-sqlite.lua
+++ /dev/null
@@ -1,187 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-sqlite'] = {
- version = 1.001,
- comment = "companion to util-sql.lua",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/sqlite/sqlite3.dll
-
-local libname = "sqlite"
-local libfile = "sqlite3"
-
-local sqlitelib = resolvers.libraries.validoptional(libname)
-
-if not sqlitelib then return end
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local next, tonumber = next, tonumber
-local setmetatable = setmetatable
-local formatters = string.formatters
-
-local sql = utilities.sql or require("util-sql")
-local report = logs.reporter(libname)
-
-local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
-local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
-
-local sqlite_open = sqlitelib.open
-local sqlite_close = sqlitelib.close
-local sqlite_execute = sqlitelib.execute
-local sqlite_getmessage = sqlitelib.getmessage
-
-local helpers = sql.helpers
-local methods = sql.methods
-local validspecification = helpers.validspecification
-local preparetemplate = helpers.preparetemplate
-local cache = { }
-
--- synchronous journal_mode locking_mode 1000 logger inserts
---
--- normal normal normal 6.8
--- off off normal 0.1
--- normal off normal 2.1
--- normal persist normal 5.8
--- normal truncate normal 4.2
--- normal truncate exclusive 4.1
-
-local f_preamble = formatters[ [[
-ATTACH `%s` AS `%s` ;
-PRAGMA `%s`.synchronous = normal ;
-]] ]
-
-local function execute(specification)
- if okay() then
- if trace_sql then
- report("executing sqlite")
- end
- if not validspecification(specification) then
- report("error in specification")
- end
- local query = preparetemplate(specification)
- if not query then
- report("error in preparation")
- return
- end
- local base = specification.database -- or specification.presets and specification.presets.database
- if not base then
- report("no database specified")
- return
- end
- local filename = file.addsuffix(base,"db")
- local result = { }
- local keys = { }
- local id = specification.id
- local db = nil
- local preamble = nil
- if id then
- local session = cache[id]
- if session then
- db = session.db
- else
- db = sqlite_open(filename)
- preamble = f_preamble(filename,base,base)
- if not db then
- report("no session database specified")
- else
- cache[id] = {
- name = filename,
- db = db,
- }
- end
- end
- else
- db = open_db(filename)
- preamble = f_preamble(filename,base,base)
- end
- if not db then
- report("no database opened")
- else
- local converter = specification.converter
- local nofrows = 0
- local callback = nil
- if preamble then
- query = preamble .. query -- only needed in open
- end
- if converter then
- local convert = converter.sqlite
- callback = function(nofcolumns,values,fields)
- nofrows = nofrows + 1
- result[nofrows] = convert(values)
- end
- else
- callback = function(nofcolumns,values,fields)
- local column = { }
- for i=1,nofcolumns do
- local field
- if fields then
- field = fields[i]
- keys[i] = field
- else
- field = keys[i]
- end
- if field then
- column[field] = values[i]
- end
- end
- nofrows = nofrows + 1
- result[nofrows] = column
- end
- end
- local okay = sqlite_execute(db,query,callback)
- if not okay then
- report("error: %s",sqlite_getmessage(db))
- -- elseif converter then
- -- result = converter.sqlite(result)
- end
- end
- if db and not id then
- sqlite_close(db)
- end
- return result, keys
- else
- report("error: ","no library loaded")
- end
-end
-
-local wraptemplate = [[
-local converters = utilities.sql.converters
-local deserialize = utilities.sql.deserialize
-
-local tostring = tostring
-local tonumber = tonumber
-local booleanstring = string.booleanstring
-
-%s
-
-return function(cells)
- -- %s (not needed)
- -- %s (not needed)
- return {
- %s
- }
-end
-]]
-
-local celltemplate = "cells[%s]"
-
-methods.sqlite = {
- execute = execute,
- usesfiles = false,
- wraptemplate = wraptemplate,
- celltemplate = celltemplate,
-}
-
-package.loaded["util-sql-imp-sqlite"] = methods.sqlite
-package.loaded[libname] = methods.sqlite
-
-return methods.sqlite
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-zint.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-zint.lua
deleted file mode 100644
index 2c346ae7d5f..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-zint.lua
+++ /dev/null
@@ -1,161 +0,0 @@
-if not modules then modules = { } end modules ['libs-imp-ghostscript'] = {
- version = 1.001,
- comment = "companion to luat-lib.mkxl",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
-local libname = "zint"
-local libfile = "libzint" -- what on unix?
--- local libfile = "/usr/local/lib/libzint.so"
-
-local zintlib = resolvers.libraries.validoptional(libname)
-
-if not zintlib then return end
-
-local function okay()
- if resolvers.libraries.optionalloaded(libname,libfile) then
- okay = function() return true end
- else
- okay = function() return false end
- end
- return okay()
-end
-
-local zint = utilities.zint or { }
-utilities.zint = zint
-
-local zintlib_execute = zintlib.execute
-
-local next, type, unpack = next, type, unpack
-local lower, gsub = string.lower, string.gsub
-
-local mapping = {
- ["code 11"] = 1, ["pharma one-track"] = 51, ["aztec code"] = 92,
- ["standard 2of5"] = 2, ["pzn"] = 52, ["daft code"] = 93,
- ["interleaved 2of5"] = 3, ["pharma two-track"] = 53, ["micro qr code"] = 97,
- ["iata 2of5"] = 4, ["pdf417"] = 55, ["hibc code 128"] = 98,
- ["data logic"] = 6, ["pdf417 trunc"] = 56, ["hibc code 39"] = 99,
- ["industrial 2of5"] = 7, ["maxicode"] = 57, ["hibc data matrix"] = 102,
- ["code 39"] = 8, ["qr code"] = 58, ["hibc qr code"] = 104,
- ["extended code 39"] = 9, ["code 128-b"] = 60, ["hibc pdf417"] = 106,
- ["ean"] = 13, ["ap standard customer"] = 63, ["hibc micropdf417"] = 108,
- ["ean + check"] = 14, ["ap reply paid"] = 66, ["hibc codablock-f"] = 110,
- ["gs1-128"] = 16, ["ap routing"] = 67, ["hibc aztec code"] = 112,
- ["codabar"] = 18, ["ap redirection"] = 68, ["dotcode"] = 115,
- ["code 128"] = 20, ["isbn"] = 69, ["han xin code"] = 116,
- ["leitcode"] = 21, ["rm4scc"] = 70, ["rm mailmark"] = 121,
- ["identcode"] = 22, ["data matrix"] = 71, ["aztec runes"] = 128,
- ["code 16k"] = 23, ["ean-14"] = 72, ["code 32"] = 129,
- ["code 49"] = 24, ["vin (north america)"] = 73, ["comp ean"] = 130,
- ["code 93"] = 25, ["codablock-f"] = 74, ["comp gs1-128"] = 131,
- ["flattermarken"] = 28, ["nve-18"] = 75, ["comp databar omni"] = 132,
- ["gs1 databar omni"] = 29, ["japanese post"] = 76, ["comp databar ltd"] = 133,
- ["gs1 databar ltd"] = 30, ["korea post"] = 77, ["comp databar expom"] = 134,
- ["gs1 databar expom"] = 31, ["gs1 databar stack"] = 79, ["comp upc-a"] = 135,
- ["telepen alpha"] = 32, ["gs1 databar stack omni"] = 80, ["comp upc-e"] = 136,
- ["upc-a"] = 34, ["gs1 databar eso"] = 81, ["comp databar stack"] = 137,
- ["upc-a + check"] = 35, ["planet"] = 82, ["comp databar stack omni"] = 138,
- ["upc-e"] = 37, ["micropdf"] = 84, ["comp databar eso"] = 139,
- ["upc-e + check"] = 38, ["usps onecode"] = 85, ["channel code"] = 140,
- ["postnet"] = 40, ["uk plessey"] = 86, ["code one"] = 141,
- ["msi plessey"] = 47, ["telepen numeric"] = 87, ["grid matrix"] = 142,
- ["fim"] = 49, ["itf-14"] = 89, ["upnqr"] = 143,
- ["logmars"] = 50, ["kix code"] = 90, ["rmqr"] = 145,
-}
-
-table.setmetatableindex(mapping,function(t,k)
- local s = gsub(lower(k),"[^a-z0-9]","")
- local v = rawget(t,s) or false
- t[k] = v
- return v
-end)
-
-local report = logs.reporter("zint")
-local context = context
-local shown = false
-
------ f_rectangle = string.formatters["%sofill unitsquare xysized (%N,%N) shifted (%N,%N);"]
-
-local function execute(specification)
- if okay() then
- local code = specification.code
- local text = specification.text
- if code then
- local id = mapping[code]
- if id then
- specification.code = id
- local result = zintlib_execute(specification)
- if result then
- -- not that fast but if needed we can speed it up
- context.startMPcode()
- local rectangles = result.rectangles
- local hexagons = result.hexagons
- local circles = result.circles
- local strings = result.strings
- if rectangles then
- local n = #rectangles
- for i=1,n do
- local r = rectangles[i]
- context("%sofill unitsquare xysized (%N,%N) shifted (%N,%N);",
- i == n and "d" or "n",r[3],r[4],r[1],r[2])
- -- rectangles[i] = f_rectangle(i == n and "d" or "n",r[3],r[4],r[1],r[2])
- end
- -- context("% t",rectangles)
- end
- if hexagons then
- local n = #hexagons
- for i=1,#hexagons do
- context("%sofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;",
- i == n and "d" or "n",unpack(hexagons[i]))
- end
- end
- if circles then
- local n = #circles
- for i=1,#circles do
- local c = circles[i]
- context("%sofill unitcircle scaled %N shifted (%N,%N);",
- i == n and "d" or "n",c[3],c[1],c[2])
- end
- end
- if strings then
- -- We set the font at the encapsulating level.
- for i=1,#strings do
- local s = strings[i]
- context('draw textext("%s") scaled (%N/10) shifted (%N,%N);',
- s[4],s[3],s[1],s[2])
- end
- end
- context.stopMPcode()
- end
- else
- report("unknown barcode alternative %a",code)
- if not shown then
- report("")
- report("valid barcode alternatives:")
- report("")
- local list = table.sortedkeys(mapping)
- for i=1,#list do
- report(" %s", list[i])
- end
- report("")
- shown = true
- end
- end
- end
- end
-end
-
-optional.loaded.zint = { execute = execute }
-
-interfaces.implement {
- name = "zint",
- actions = execute,
- arguments = {
- {
- { "code" },
- { "text" },
- }
- }
-}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-zint.mkxl b/Master/texmf-dist/tex/context/base/mkiv/libs-imp-zint.mkxl
deleted file mode 100644
index 72ce8157efe..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-imp-zint.mkxl
+++ /dev/null
@@ -1,64 +0,0 @@
-%D \module
-%D [ file=m-zint,
-%D version=2010.12.07,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=Zint Barcode Generator,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D Using \type {zint} seems to be the easiest way to generate
-%D (PDF417) barcodes so therefore we now have this module. There
-%D are proper (also windows) binaries at:
-%D
-%D \starttyping
-%D http://www.zint.org.uk
-%D \stoptyping
-%D
-%D There is a bit more code than needed as we want to be able to
-%D feed names.
-
-\registerctxluafile{libs-imp-zint}{}
-
-\unprotect
-
-\definefont[usedzintfont][dejavusansmono at 10bp]
-
-\unexpanded\def\barcode[#1]% [alternative=,text=]
- {\bgroup
- \usedzintfont
- \getdummyparameters
- [\c!alternative=,\c!text=,#1]%
- \scale
- [#1]%
- {\clf_zint
- code {\dummyparameter\c!alternative}
- text {\dummyparameter\c!text}
- \relax}
- \egroup}
-
-\protect
-
-\continueifinputfile{libs-imp-zint.mkxl}
-
-\starttext
-
-% \dorecurse{1000}{
- \startTEXpage
- \barcode[alternative=PDF417,text={Hans Hagen}]%
- \blank
- \barcode[alternative=PDF417,text={Ton Otten}]%
- \blank
- \barcode[alternative=ISBN,text=9789490688011]%
- \blank
- \barcode[alternative=isbn,text=9789490688011,width=3cm]%
- \stopTEXpage
-% }
-
-\stoptext
-
-
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/libs-ini.lua
index 2bac3201d28..5b8390df2a1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/libs-ini.lua
@@ -13,10 +13,10 @@ if not modules then modules = { } end modules ['libs-ini'] = {
-- is doing.
local type, unpack = type, unpack
+local find = string.find
-- here we implement the resolver
-local type = type
local nameonly = file.nameonly
local joinfile = file.join
@@ -30,8 +30,10 @@ local expandpaths = resolvers.expandedpathlistfromvariable
local report = logs.reporter("resolvers","libraries")
local trace = false
+local silent = false
-trackers.register("resolvers.lib", function(v) trace = v end)
+trackers.register("resolvers.lib", function(v) trace = v end)
+trackers.register("resolvers.lib.silent", function(v) silent = v end)
local function findlib(required) -- todo: cache
local suffix = os.libsuffix or "so"
@@ -143,10 +145,10 @@ function libraries.optionalloaded(name,libnames)
end
end
local initialized = thelib_initialize(unpack(libnames))
- if initialized then
- report("using library '% + t'",libnames)
- else
+ if not initialized then
report("unable to initialize library '% + t'",libnames)
+ elseif not silent then
+ report("using library '% + t'",libnames)
end
return initialized
end
@@ -154,6 +156,9 @@ function libraries.optionalloaded(name,libnames)
end
end
+-- For the moment the next blob is needed when we run \MTXRUN\ on top of \LUATEX\ and
+-- \LUAJITTEX\ but at some point we will {\em always} assume \LUAMETATEX\ as runner.
+
if FFISUPPORTED and ffi and ffi.load then
local ffiload = ffi.load
@@ -194,3 +199,19 @@ end
-- }
-- end
-- }
+
+local dofile = dofile
+local savedrequire = require
+
+function require(name,version)
+ if find(name,"%.lua$") or find(name,"%.lmt$") then
+ local m = dofile(findfile(name))
+ if m then
+ package.loaded[name] = m
+ return m
+ end
+ else
+ return savedrequire(name)
+ end
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/libs-ini.mkxl b/Master/texmf-dist/tex/context/base/mkiv/libs-ini.mkxl
deleted file mode 100644
index 18163beed12..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/libs-ini.mkxl
+++ /dev/null
@@ -1,31 +0,0 @@
-%D \module
-%D [ file=libs-ini,
-%D version=2020.01.02,
-%D title=\CONTEXT\ Lua Macros,
-%D subtitle=Libraries,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\registerctxluafile{libs-ini}{}
-
-\registerctxluafile{libs-imp-curl}{}
-\registerctxluafile{libs-imp-ghostscript}{}
-\registerctxluafile{libs-imp-graphicsmagick}{}
-
-% These are loaded on demand:
-
-% \registerctxluafile{libs-imp-mysql}{}
-% \registerctxluafile{libs-imp-sqlite}{}
-% \registerctxluafile{libs-imp-postgress}{}
-
-\unprotect
-
-% \unexpanded\def\uselibrary[#1]%
-% {\clf_uselibrary{#1}}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-ano.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-ano.lua
index c04ada15156..a120ff2f4ee 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-ano.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-ano.lua
@@ -712,7 +712,8 @@ function codeinjections.prerollreference(actions) -- share can become option
local bs, bc = pdfborder()
main = pdfdictionary {
Subtype = pdf_link,
- Border = bs,
+ -- Border = bs,
+ Border = pdfshareobjectreference(bs),
C = bc,
H = (not actions.highlight and pdf_n) or nil,
A = pdfshareobjectreference(main),
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-aux.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-aux.lua
index 0d7cecbb853..91636ad04e0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-aux.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-aux.lua
@@ -22,7 +22,8 @@ local cache = table.setmetatableindex(function(t,k) -- can be made weak
if v < 0x10000 then
v = format("%04x",v)
else
- v = format("%04x%04x",rshift(v,10),v%1024+0xDC00)
+ v = v - 0x10000
+ v = format("%04x%04x",rshift(v,10)+0xD800,v%1024+0xDC00)
end
t[k] = v
return v
@@ -71,7 +72,7 @@ local more = 0
local pattern = C(4) / function(s) -- needs checking !
local now = tonumber(s,16)
if more > 0 then
- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
more = 0
return utfchar(now)
elseif now >= 0xD800 and now <= 0xDBFF then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-col.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-col.lua
index c586300e55b..d3b612593d5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-col.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-col.lua
@@ -818,14 +818,20 @@ do
end
end
+ -- A problem is that we need to transfer back and this is kind of
+ -- messy so we force text mode .. i'll do a better job on that but
+ -- will experiment first (both engines). Virtual fonts will change
+ -- anyway.
+
backends.pdf.tables.vfspecials = allocate { -- todo: distinguish between glyph and rule color
startcolor = startcolor,
-- stopcolor = { "pdf", "page", "0 g 0 G Q" },
- stopcolor = { "pdf", "page", "Q" },
+ stopcolor = { "pdf", "text", "Q" },
startslant = startslant,
- stopslant = { "pdf", "origin", "Q" },
+ -- stopslant = { "pdf", "origin", "Q" },
+ stopslant = { "pdf", "text", "Q" },
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-emb.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-emb.lua
deleted file mode 100644
index 4ffcfd8a846..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-emb.lua
+++ /dev/null
@@ -1,2224 +0,0 @@
-if not modules then modules = { } end modules ['lpdf-ini'] = {
- version = 1.001,
- comment = "companion to lpdf-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- vkgoeswild: Pink Floyd - Shine on You Crazy Diamond - piano cover (around that
--- time I redid the code, a reminder so to say)
-
--- At some point I wanted to have access to the shapes so that we could use them in
--- metapost. So, after looking at the cff and ttf specifications, I decided to write
--- parsers. At somepoint we needed a cff parser anyway in order to calculate the
--- dimensions. Then variable fonts came around and a option was added to recreate
--- streams of operators and a logical next step was to do all inclusion that way. It
--- was only then that I found out that some of the juggling also happens in the the
--- backend, but spread over places, so I could have saved myself some time
--- deciphering the specifications. Anyway, here we go.
---
--- Color fonts are a bit messy. Catching issues with older fonts will break new ones
--- so I don't think that it's wise to build in too many catches (like for fonts with
--- zero boundingboxes, weird dimensions, transformations that in a next version are
--- fixed, etc.). Better is then to wait till something gets fixed. If a spec doesn't
--- tell me how to deal with it ... I'll happily wait till it does. After all we're
--- not in a hurry as these fonts are mostly meant for the web or special purposes
--- with manual tweaking in desk top publishing applications. Keep in mind that Emoji
--- can have funny dimensions (e.g. to be consistent within a font, so no tight ones).
-
--- When we have moved to lmtx I will document a bit more. Till then it's experimental
--- and subjected to change.
-
-local next, type, unpack, rawget = next, type, unpack, rawget
-local char, byte, gsub, sub, match, rep, gmatch = string.char, string.byte, string.gsub, string.sub, string.match, string.rep, string.gmatch
-local formatters = string.formatters
-local format = string.format
-local concat, sortedhash, sort = table.concat, table.sortedhash, table.sort
-local utfchar = utf.char
-local random, round, max, abs, ceiling = math.random, math.round, math.max, math.abs, math.ceiling
-local extract, lshift, rshift, band, bor = bit32.extract, bit32.lshift, bit32.rshift, bit32.band, bit32.bor
-local idiv = number.idiv
-local setmetatableindex = table.setmetatableindex
-
-local pdfnull = lpdf.null
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfconstant = lpdf.constant
-local pdfstring = lpdf.string
-local pdfreference = lpdf.reference
-local pdfreserveobject = lpdf.reserveobject
-local pdfflushobject = lpdf.flushobject
-local pdfflushstreamobject = lpdf.flushstreamobject
-
-local report_fonts = logs.reporter("backend","fonts")
-
-local trace_fonts = false
-local trace_details = false
-
-local dimenfactors = number.dimenfactors
-local bpfactor = dimenfactors.bp
-local ptfactor = dimenfactors.pt
-
-trackers.register("backend.pdf.fonts",function(v) trace_fonts = v end)
-
-local readers = fonts.handlers.otf.readers
-local getinfo = readers.getinfo
-
-local setposition = utilities.files.setposition
-local readstring = utilities.files.readstring
-local openfile = utilities.files.open
-local closefile = utilities.files.close
-
-
--- needs checking: signed vs unsigned
-
-local tocardinal1 = char
-
-local function tocardinal2(n)
- return char(extract(n,8,8),extract(n,0,8))
-end
-
-local function tocardinal3(n)
- return char(extract(n,16,8),extract(n,8,8),extract(n,0,8))
-end
-
-local function tocardinal4(n)
- return char(extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
-end
-
-local function tointeger2(n)
- return char(extract(n,8,8),extract(n,0,8))
-end
-
-local function tointeger3(n)
- return char(extract(n,16,8),extract(n,8,8),extract(n,0,8))
-end
-
-local function tointeger4(n)
- return char(extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
-end
-
-local function tocardinal8(n)
- local l = idiv(n,0x100000000)
- local r = n % 0x100000000
- return char(extract(l,24,8),extract(l,16,8),extract(l,8,8),extract(l,0,8),
- extract(r,24,8),extract(r,16,8),extract(r,8,8),extract(r,0,8))
-end
-
--- A couple of shared helpers.
-
-local tounicodedictionary, widtharray, collectindices, subsetname, includecidset, forcecidset, tocidsetdictionary
-
-do
-
- -- Because we supply tounicodes ourselves we only use bfchar mappings (as in the
- -- backend). In fact, we can now no longer pass the tounicodes to the frontend but
- -- pick them up from the descriptions.
-
- local f_mapping_2 = formatters["<%02X> <%s>"]
- local f_mapping_4 = formatters["<%04X> <%s>"]
-
- local tounicode = fonts.mappings.tounicode
-
-local tounicode_template = [[
-%%!PS-Adobe-3.0 Resource-CMap
-%%%%DocumentNeededResources: ProcSet (CIDInit)
-%%%%IncludeResource: ProcSet (CIDInit)
-%%%%BeginResource: CMap (TeX-%s-0)
-%%%%Title: (TeX-%s-0 TeX %s 0)|
-%%%%Version: 1.000
-%%%%EndComments
-/CIDInit /ProcSet findresource begin
- 12 dict begin
- begincmap
- /CIDSystemInfo
- << /Registry (TeX) /Ordering (%s) /Supplement 0 >>
- def
- /CMapName
- /TeX-Identity-%s
- def
- /CMapType
- 2
- def
- 1 begincodespacerange
- <%s> <%s>
- endcodespacerange
- %i beginbfchar
-%s
- endbfchar
- endcmap
- CMapName currentdict /CMap defineresource pop
- end
-end
-%%%%EndResource
-%%%%EOF]]
-
- tounicodedictionary = function(details,indices,maxindex,name,wide)
- local mapping = { }
- local length = 0
- if maxindex > 0 then
- local f_mapping = wide and f_mapping_4 or f_mapping_2
- for index=1,maxindex do
- local data = indices[index]
- if data then
- length = length + 1
- local unicode = data.unicode
- if unicode then
- unicode = tounicode(unicode)
- else
- unicode = "FFFD"
- end
- mapping[length] = f_mapping(index,unicode)
- end
- end
- end
- local name = gsub(name,"%+","-") -- like luatex does
- local first = wide and "0000" or "00"
- local last = wide and "FFFF" or "FF"
- local blob = format(tounicode_template,name,name,name,name,name,first,last,length,concat(mapping,"\n"))
- return blob
- end
-
- widtharray = function(details,indices,maxindex,units)
- local widths = pdfarray()
- local length = 0
- local factor = 10000 / units
- if maxindex > 0 then
- local lastindex = -1
- local sublist = nil
- for index=1,maxindex do
- local data = indices[index]
- if data then
- local width = data.width -- hm, is inaccurate for cff, so take from elsewhere
- if width then
- -- width = round(width * 10000 / units) / 10
- width = round(width * factor) / 10
- else
- width = 0
- end
- if index == lastindex + 1 then
- sublist[#sublist+1] = width
- else
- if sublist then
- length = length + 1
- widths[length] = sublist
- end
- sublist = pdfarray { width }
- length = length + 1
- widths[length] = index
- end
- lastindex = index
- end
- end
- length = length + 1
- widths[length] = sublist
- end
- return widths
- end
-
- collectindices = function(descriptions,indices)
- local minindex = 0xFFFF
- local maxindex = 0
- local reverse = { }
- -- todo: already at definition time trigger copying streams
- -- and add extra indices ... first i need a good example of
- -- a clash
- -- for unicode, data in next, descriptions do
- -- local i = data.index or unicode
- -- if reverse[i] then
- -- print("CLASH")
- -- else
- -- reverse[i] = data
- -- end
- -- end
- for unicode, data in next, descriptions do
- reverse[data.index or unicode] = data
- end
- for index in next, indices do
- if index > maxindex then
- maxindex = index
- end
- if index < minindex then
- minindex = index
- end
- indices[index] = reverse[index]
- end
- if minindex > maxindex then
- minindex = maxindex
- end
- return indices, minindex, maxindex
- end
-
- includecidset = false
- forcecidset = false -- for private testing only
-
- directives.register("backend.pdf.forcecidset",function(v)
- forcecidset = v
- end)
-
- tocidsetdictionary = function(indices,min,max)
- if includecidset or forcecidset then
- local b = { }
- local m = idiv(max+7,8)
- for i=0,max do
- b[i] = 0
- end
- b[0] = bor(b[0],lshift(1,7)) -- force notdef into the file
- for i=min,max do
- if indices[i] then
- local bi = idiv(i,8)
- local ni = i % 8
- b[bi] = bor(b[bi],lshift(1,7-ni))
- end
- end
- b = char(unpack(b,0,#b))
- return pdfreference(pdfflushstreamobject(b))
- end
- end
-
- -- Actually we can use the same as we only embed once.
-
- -- subsetname = function(name)
- -- return "CONTEXT" .. name
- -- end
-
- local prefixes = { } -- todo: set fixed one
-
- subsetname = function(name)
- local prefix
- while true do
- prefix = utfchar(random(65,90),random(65,90),random(65,90),random(65,90),random(65,90),random(65,90))
- if not prefixes[prefix] then
- prefixes[prefix] = true
- break
- end
- end
- return prefix .. "+" .. name
- end
-
-end
-
--- Map file mess.
-
-local loadmapfile, loadmapline, getmapentry do
-
- -- We only need to pick up the filename and optionally the enc file
- -- as we only use them for old school virtual math fonts. We might as
- -- we drop this completely.
-
- local find, match, splitlines = string.find, string.match, string.splitlines
-
-
- local mappings = { }
-
- loadmapline = function(n)
- if trace_fonts then
- report_fonts("mapline: %s",n)
- end
- local name, fullname, encfile, pfbfile = match(n,"(%S+)%s+(%S+).-<(.-%.enc).-<(.-%.pfb)")
- if name then
- mappings[name] = { fullname, encfile, pfbfile }
- end
- end
-
- loadmapfile = function(n)
- local okay, data = resolvers.loadbinfile(n,"map")
- if okay and data then
- data = splitlines(data)
- for i=1,#data do
- local d = data[i]
- if d ~= "" and not find(d,"^[#%%]") then
- loadmapline(d)
- end
- end
- end
- end
-
- getmapentry = function(n)
- local n = file.nameonly(n)
- local m = mappings[n]
- if m then
- local encfile = m[2]
- local encoding = fonts.encodings.load(encfile)
- if not encoding then
- return
- end
- local pfbfile = resolvers.findfile(m[3],"pfb")
- if not pfbfile or pfbfile == "" then
- return
- end
- return encoding, pfbfile, encfile
- end
- end
-
- lpdf.getmapentry = getmapentry
-
-end
-
--- The three writers: opentype, truetype and type1.
-
-local mainwriters = { }
-
-do
-
- -- advh = os2.ascender - os2.descender
- -- tsb = default_advh - os2.ascender
-
- -- truetype has the following tables:
-
- -- head : mandate
- -- hhea : mandate
- -- vhea : mandate
- -- hmtx : mandate
- -- maxp : mandate
- -- glyf : mandate
- -- loca : mandate
- --
- -- cvt : if needed (but we flatten)
- -- fpgm : if needed (but we flatten)
- -- prep : if needed (but we flatten)
- -- PCLT : if needed (but we flatten)
- --
- -- name : not needed for T2: backend does that
- -- post : not needed for T2: backend does that
- -- OS/2 : not needed for T2: backend does that
- -- cmap : not needed for T2: backend does that
-
- local streams = utilities.streams
- local openstring = streams.openstring
- local readcardinal2 = streams.readcardinal2
- ----- readcardinal4 = streams.readcardinal4
-
- local otfreaders = fonts.handlers.otf.readers
-
- local function readcardinal4(f) -- this needs to be sorted out
- local a = readcardinal2(f)
- local b = readcardinal2(f)
- if a and b then
- return a * 0x10000 + b
- end
- end
-
- -- -- --
-
- local tablereaders = { }
- local tablewriters = { }
- local tablecreators = { }
- local tableloaders = { }
-
- local openfontfile, closefontfile, makefontfile, makemetadata do
-
- local details = {
- details = true,
- platformnames = true,
- platformextras = true,
- }
-
- -- .022 sec on luatex manual, neglectable:
-
- -- local function checksum(data)
- -- local s = openstring(data)
- -- local n = 0
- -- local d = #data
- -- while true do
- -- local c = readcardinal4(s)
- -- if c then
- -- n = (n + c) % 0x100000000
- -- else
- -- break
- -- end
- -- end
- -- return n
- -- end
-
- local function checksum(data)
- local s = openstring(data)
- local n = 0
- local d = #data
- while true do
- local a = readcardinal2(s)
- local b = readcardinal2(s)
- if b then
- n = (n + a * 0x10000 + b) % 0x100000000
- else
- break
- end
- end
- return n
- end
-
- openfontfile = function(details)
- return {
- offset = 0,
- order = { },
- used = { },
- details = details,
- streams = details.streams,
- }
- end
-
- closefontfile = function(fontfile)
- for k, v in next, fontfile do
- fontfile[k] = nil -- so it can be collected asap
- end
- end
-
- local metakeys = {
- "uniqueid", "version",
- "copyright", "license", "licenseurl",
- "manufacturer", "vendorurl",
- "family", "subfamily",
- "typographicfamily", "typographicsubfamily",
- "fullname", "postscriptname",
- }
-
- local template = [[
-
-
-
-
-
-%s
-
-
-
-
-]]
-
- makemetadata = function(fontfile)
- local names = fontfile.streams.names
- local list = { }
- local f_name = formatters["%s"]
- for i=1,#metakeys do
- local m = metakeys[i]
- local n = names[m]
- if n then
- list[#list+1] = f_name(m,n,m)
- end
- end
- return format(template,concat(list,"\n"))
- end
-
- makefontfile = function(fontfile)
- local order = fontfile.order
- local used = fontfile.used
- local count = 0
- for i=1,#order do
- local tag = order[i]
- local data = fontfile[tag]
- if data and #data > 0 then
- count = count + 1
- else
- fontfile[tag] = false
- end
- end
- local offset = 12 + (count * 16)
- local headof = 0
- local list = {
- "" -- placeholder
- }
- local i = 1
- local k = 0
- while i <= count do
- i = lshift(i,1)
- k = k + 1
- end
- local searchrange = lshift(i,3)
- local entryselector = k - 1
- local rangeshift = lshift(count,4) - lshift(i,3)
- local index = {
- tocardinal4(0x00010000), -- tables.version
- tocardinal2(count),
- tocardinal2(searchrange),
- tocardinal2(entryselector),
- tocardinal2(rangeshift),
- }
- --
- local ni = #index
- local nl = #list
- for i=1,#order do
- local tag = order[i]
- local data = fontfile[tag]
- if data then
- local csum = checksum(data)
- local dlength = #data
- local length = idiv(dlength+3,4) * 4
- local padding = length - dlength
- nl = nl + 1 ; list[nl] = data
- for i=1,padding do
- nl = nl + 1 ; list[nl] = "\0"
- end
- if #tag == 3 then
- tag = tag .. " "
- end
- ni = ni + 1 ; index[ni] = tag -- must be 4 chars
- ni = ni + 1 ; index[ni] = tocardinal4(csum)
- ni = ni + 1 ; index[ni] = tocardinal4(offset)
- ni = ni + 1 ; index[ni] = tocardinal4(dlength)
- used[i] = offset -- not used
- if tag == "head" then
- headof = offset
- end
- offset = offset + length
- end
- end
- list[1] = concat(index)
- local off = #list[1] + headof + 1 + 8
- list = concat(list)
- local csum = (0xB1B0AFBA - checksum(list)) % 0x100000000
- list = sub(list,1,off-1) .. tocardinal4(csum) .. sub(list,off+4,#list)
- return list
- end
-
- local function register(fontfile,name)
- local u = fontfile.used
- local o = fontfile.order
- if not u[name] then
- o[#o+1] = name
- u[name] = true
- end
- end
-
- local function create(fontfile,name)
- local t = { }
- fontfile[name] = t
- return t
- end
-
- local function write(fontfile,name)
- local t = fontfile[name]
- if not t then
- return
- end
- register(fontfile,name)
- if type(t) == "table" then
- if t[0] then
- fontfile[name] = concat(t,"",0,#t)
- elseif #t > 0 then
- fontfile[name] = concat(t)
- else
- fontfile[name] = false
- end
- end
- end
-
- tablewriters.head = function(fontfile)
- register(fontfile,"head")
- local t = fontfile.streams.fontheader
- fontfile.head = concat {
- tocardinal4(t.version),
- tocardinal4(t.fontversionnumber),
- tocardinal4(t.checksum),
- tocardinal4(t.magic),
- tocardinal2(t.flags),
- tocardinal2(t.units),
- tocardinal8(t.created),
- tocardinal8(t.modified),
- tocardinal2(t.xmin),
- tocardinal2(t.ymin),
- tocardinal2(t.xmax),
- tocardinal2(t.ymax),
- tocardinal2(t.macstyle),
- tocardinal2(t.smallpixels),
- tocardinal2(t.directionhint),
- tocardinal2(t.indextolocformat),
- tocardinal2(t.glyphformat),
- }
- end
-
- tablewriters.hhea = function(fontfile)
- register(fontfile,"hhea")
- local t = fontfile.streams.horizontalheader
- local n = t and fontfile.nofglyphs or 0
- fontfile.hhea = concat {
- tocardinal4(t.version),
- tocardinal2(t.ascender),
- tocardinal2(t.descender),
- tocardinal2(t.linegap),
- tocardinal2(t.maxadvancewidth),
- tocardinal2(t.minleftsidebearing),
- tocardinal2(t.minrightsidebearing),
- tocardinal2(t.maxextent),
- tocardinal2(t.caretsloperise),
- tocardinal2(t.caretsloperun),
- tocardinal2(t.caretoffset),
- tocardinal2(t.reserved_1),
- tocardinal2(t.reserved_2),
- tocardinal2(t.reserved_3),
- tocardinal2(t.reserved_4),
- tocardinal2(t.metricdataformat),
- tocardinal2(n) -- t.nofmetrics
- }
- end
-
- tablewriters.vhea = function(fontfile)
- local t = fontfile.streams.verticalheader
- local n = t and fontfile.nofglyphs or 0
- register(fontfile,"vhea")
- fontfile.vhea = concat {
- tocardinal4(t.version),
- tocardinal2(t.ascender),
- tocardinal2(t.descender),
- tocardinal2(t.linegap),
- tocardinal2(t.maxadvanceheight),
- tocardinal2(t.mintopsidebearing),
- tocardinal2(t.minbottomsidebearing),
- tocardinal2(t.maxextent),
- tocardinal2(t.caretsloperise),
- tocardinal2(t.caretsloperun),
- tocardinal2(t.caretoffset),
- tocardinal2(t.reserved_1),
- tocardinal2(t.reserved_2),
- tocardinal2(t.reserved_3),
- tocardinal2(t.reserved_4),
- tocardinal2(t.metricdataformat),
- tocardinal2(n) -- t.nofmetrics
- }
- end
-
- tablewriters.maxp = function(fontfile)
- register(fontfile,"maxp")
- local t = fontfile.streams.maximumprofile
- local n = fontfile.nofglyphs
- -- if fontfile.streams.cffinfo then
- -- error
- -- end
- fontfile.maxp = concat {
- tocardinal4(0x00010000),
- tocardinal2(n),
- tocardinal2(t.points),
- tocardinal2(t.contours),
- tocardinal2(t.compositepoints),
- tocardinal2(t.compositecontours),
- tocardinal2(t.zones),
- tocardinal2(t.twilightpoints),
- tocardinal2(t.storage),
- tocardinal2(t.functiondefs),
- tocardinal2(t.instructiondefs),
- tocardinal2(t.stackelements),
- tocardinal2(t.sizeofinstructions),
- tocardinal2(t.componentelements),
- tocardinal2(t.componentdepth),
- }
- end
-
- tablecreators.loca = function(fontfile) return create(fontfile,"loca") end
- tablewriters .loca = function(fontfile) return write (fontfile,"loca") end
-
- tablecreators.glyf = function(fontfile) return create(fontfile,"glyf") end
- tablewriters .glyf = function(fontfile) return write (fontfile,"glyf") end
-
- tablecreators.hmtx = function(fontfile) return create(fontfile,"hmtx") end
- tablewriters .hmtx = function(fontfile) return write (fontfile,"hmtx") end
-
- tablecreators.vmtx = function(fontfile) return create(fontfile,"vmtx") end
- tablewriters .vmtx = function(fontfile) return write (fontfile,"vmtx") end
-
- tableloaders .cmap = function(fontfile) return read (fontfile,"cmap") end
- tablewriters .cmap = function(fontfile) return write (fontfile,"cmap") end
-
- tableloaders .name = function(fontfile) return read (fontfile,"name") end
- tablewriters .name = function(fontfile) return write (fontfile,"name") end
-
- tableloaders .post = function(fontfile) return read (fontfile,"post") end
- tablewriters .post = function(fontfile) return write (fontfile,"post") end
-
- end
-
- mainwriters["truetype"] = function(details)
- --
- local fontfile = openfontfile(details)
- local basefontname = details.basefontname
- local streams = details.streams
- local blobs = streams.streams
- local fontheader = streams.fontheader
- local horizontalheader = streams.horizontalheader
- local verticalheader = streams.verticalheader
- local maximumprofile = streams.maximumprofile
- local names = streams.names
- local descriptions = details.rawdata.descriptions
- local metadata = details.rawdata.metadata
- local indices = details.indices
- local metabbox = { fontheader.xmin, fontheader.ymin, fontheader.xmax, fontheader.ymax }
- local indices,
- minindex,
- maxindex = collectindices(descriptions,indices)
- local glyphstreams = tablecreators.glyf(fontfile)
- local locations = tablecreators.loca(fontfile)
- local horizontals = tablecreators.hmtx(fontfile)
- local verticals = tablecreators.vmtx(fontfile)
- --
- local zero2 = tocardinal2(0)
- local zero4 = tocardinal4(0)
- --
- local horizontal = horizontalheader.nofmetrics > 0
- local vertical = verticalheader.nofmetrics > 0
- --
- local streamoffset = 0
- local lastoffset = zero4
- local g, h, v = 0, 0, 0
- --
- -- todo: locate notdef
- --
- if minindex > 0 then
- local blob = blobs[0]
- if blob and #blob > 0 then
- locations[0] = lastoffset
- g = g + 1 ; glyphstreams[g] = blob
- h = h + 1 ; horizontals [h] = zero4
- if vertical then
- v = v + 1 ; verticals[v] = zero4
- end
- streamoffset = streamoffset + #blob
- lastoffset = tocardinal4(streamoffset)
- else
- report_fonts("missing .notdef in font %a",basefontname)
- end
- -- todo: use a rep for h/v
- for index=1,minindex-1 do
- locations[index] = lastoffset
- h = h + 1 ; horizontals[h] = zero4
- if vertical then
- v = v + 1 ; verticals[v] = zero4
- end
- end
- end
- for index=minindex,maxindex do
- locations[index] = lastoffset
- local data = indices[index]
- if data then
- local blob = blobs[index] -- we assume padding
- if blob and #blob > 0 then
- g = g + 1 ; glyphstreams[g] = blob
- h = h + 1 ; horizontals [h] = tocardinal2(data.width or 0)
- h = h + 1 ; horizontals [h] = tocardinal2(data.boundingbox[1])
- if vertical then
- v = v + 1 ; verticals[v] = tocardinal2(data.height or 0)
- v = v + 1 ; verticals[v] = tocardinal2(data.boundingbox[3])
- end
- streamoffset = streamoffset + #blob
- lastoffset = tocardinal4(streamoffset)
- else
- h = h + 1 ; horizontals[h] = zero4
- if vertical then
- v = v + 1 ; verticals[v] = zero4
- end
- report_fonts("missing blob for index %i in font %a",index,basefontname)
- end
- else
- h = h + 1 ; horizontals[h] = zero4
- if vertical then
- v = v + 1 ; verticals[v] = zero4
- end
- end
- end
- locations[maxindex+1] = lastoffset -- cf spec
- --
- local nofglyphs = maxindex + 1 -- include zero
- --
- fontheader.checksum = 0
- fontheader.indextolocformat = 1
- maximumprofile.nofglyphs = nofglyphs
- --
- fontfile.format = "tff"
- fontfile.basefontname = basefontname
- fontfile.nofglyphs = nofglyphs
- --
- tablewriters.head(fontfile)
- tablewriters.hhea(fontfile)
- if vertical then
- tablewriters.vhea(fontfile)
- end
- tablewriters.maxp(fontfile)
-
- tablewriters.loca(fontfile)
- tablewriters.glyf(fontfile)
-
- tablewriters.hmtx(fontfile)
- if vertical then
- tablewriters.vmtx(fontfile)
- end
- --
- local fontdata = makefontfile(fontfile)
- local fontmeta = makemetadata(fontfile)
- --
- fontfile = closefontfile(fontfile)
- --
- local units = metadata.units
- local basefont = pdfconstant(basefontname)
- local widths = widtharray(details,indices,maxindex,units)
- local object = details.objectnumber
- local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,true)
- local tocidset = tocidsetdictionary(indices,minindex,maxindex)
- local metabbox = metadata.boundingbox or { 0, 0, 0, 0 }
- local fontbbox = pdfarray { unpack(metabbox) }
- local ascender = metadata.ascender
- local descender = metadata.descender
- local capheight = metadata.capheight or fontbbox[4]
- local stemv = metadata.weightclass
- local italicangle = metadata.italicangle
- local xheight = metadata.xheight or fontbbox[4]
- --
- if stemv then
- stemv = (stemv/65)^2 + 50
- end
- --
- local function scale(n)
- if n then
- return round((n) * 10000 / units) / 10
- else
- return 0
- end
- end
- --
- local reserved = pdfreserveobject()
- local child = pdfdictionary {
- Type = pdfconstant("Font"),
- Subtype = pdfconstant("CIDFontType2"),
- BaseFont = basefont,
- FontDescriptor = pdfreference(reserved),
- W = pdfreference(pdfflushobject(widths)),
- CIDToGIDMap = pdfconstant("Identity"),
- CIDSystemInfo = pdfdictionary {
- Registry = pdfstring("Adobe"),
- Ordering = pdfstring("Identity"),
- Supplement = 0,
- }
- }
- local descendants = pdfarray {
- pdfreference(pdfflushobject(child)),
- }
- local descriptor = pdfdictionary {
- Type = pdfconstant("FontDescriptor"),
- FontName = basefont,
- Flags = 4,
- FontBBox = fontbbox,
- Ascent = scale(ascender),
- Descent = scale(descender),
- ItalicAngle = round(italicangle or 0),
- CapHeight = scale(capheight),
- StemV = scale(stemv),
- XHeight = scale(xheight),
- FontFile2 = pdfreference(pdfflushstreamobject(fontdata)),
- CIDSet = tocidset,
- Metadata = fontmeta and pdfreference(pdfflushstreamobject(fontmeta)) or nil,
- }
- local parent = pdfdictionary {
- Type = pdfconstant("Font"),
- Subtype = pdfconstant("Type0"),
- Encoding = pdfconstant(details.properties.writingmode == "vertical" and "Identity-V" or "Identity-H"),
- BaseFont = basefont,
- DescendantFonts = descendants,
- ToUnicode = pdfreference(pdfflushstreamobject(tounicode)),
- }
- pdfflushobject(reserved,descriptor)
- pdfflushobject(object,parent)
- --
- -- if trace_details then
- -- local name = "temp.ttf"
- -- report_fonts("saving %a",name)
- -- io.savedata(name,fontdata)
- -- inspect(fonts.handlers.otf.readers.loadfont(name))
- -- end
- --
- end
-
- do
- -- todo : cff2
-
- local details = {
- details = true,
- platformnames = true,
- platformextras = true,
- }
-
- tablecreators.cff = function(fontfile)
- fontfile.charstrings = { }
- fontfile.charmappings = { }
- fontfile.cffstrings = { }
- fontfile.cffhash = { }
- return fontfile.charstrings , fontfile.charmappings
- end
-
- local todictnumber, todictreal, todictinteger, todictoffset do
-
- local maxnum = 0x7FFFFFFF
- local minnum = - 0x7FFFFFFF - 1
- local epsilon = 1.0e-5
-
- local int2tag = "\28"
- local int4tag = "\29"
- local realtag = "\30"
-
- todictinteger = function(n)
- if not n then
- return char(band(139,0xFF))
- elseif n >= -107 and n <= 107 then
- return char(band(n + 139,0xFF))
- elseif n >= 108 and n <= 1131 then
- n = 0xF700 + n - 108
- return char(band(rshift(n,8),0xFF),band(n,0xFF))
- elseif n >= -1131 and n <= -108 then
- n = 0xFB00 - n - 108
- return char(band(rshift(n,8),0xFF),band(n,0xFF))
- elseif n >= -32768 and n <= 32767 then
- -- return int2tag .. tointeger2(n)
- return char(28,extract(n,8,8),extract(n,0,8))
- else
- -- return int4tag .. tointeger4(n)
- return char(29,extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
- end
- end
-
- -- -- not called that often
- --
- -- local encoder = readers.cffencoder
- --
- -- todictinteger = function(n)
- -- if not n then
- -- return encoder[0]
- -- elseif n >= -1131 and n <= 1131 then
- -- return encoder[n]
- -- elseif n >= -32768 and n <= 32767 then
- -- -- return int2tag .. tointeger2(n)
- -- return char(28,extract(n,8,8),extract(n,0,8))
- -- else
- -- -- return int4tag .. tointeger4(n)
- -- return char(29,extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
- -- end
- -- end
-
- todictoffset = function(n)
- return int4tag .. tointeger4(n)
- end
-
- local e = false
- local z = byte("0")
- local dp = 10
- local ep = 11
- local em = 12
- local mn = 14
- local es = 15
-
- local fg = formatters["%g"]
-
- todictreal = function(v)
- local s = fg(v)
- local t = { [0] = realtag }
- local n = 0
- for s in gmatch(s,".") do
- if s == "e" or s == "E" then
- e = true
- elseif s == "+" then
- -- skip
- elseif s == "-" then
- n = n + 1
- if e then
- t[n] = em
- e = false
- else
- t[n] = mn
- end
- else
- if e then
- n = n + 1
- t[n] = ep
- e = false
- end
- n = n + 1
- if s == "." then
- t[n] = dp
- else
- t[n] = byte(s) - z
- end
- end
- end
- n = n + 1
- t[n] = es
- if (n % 2) ~= 0 then
- n = n + 1
- t[n] = es
- end
- local j = 0
- for i=1,n,2 do
- j = j + 1
- t[j] = char(t[i]*0x10+t[i+1])
- end
- t = concat(t,"",0,j)
- return t
- end
-
- todictnumber = function(n)
- if not n or n == 0 then
- return todictinteger(0)
- elseif (n > maxnum or n < minnum or (abs(n - round(n)) > epsilon)) then
- return todictreal(n)
- else
- return todictinteger(n)
- end
- end
-
- end
-
- local todictkey = char
-
- local function todictstring(fontfile,value)
- if not value then
- value = ""
- end
- local s = fontfile.cffstrings
- local h = fontfile.cffhash
- local n = h[value]
- if not n then
- n = #s + 1
- s[n] = value
- h[value] = n
- end
- return todictinteger(390+n)
- end
-
- local function todictboolean(b)
- return todictinteger(b and 1 or 0)
- end
-
- local function todictdeltas(t)
- local r = { }
- for i=1,#t do
- r[i] = todictnumber(t[i]-(t[i-1] or 0))
- end
- return concat(r)
- end
-
- local function todictarray(t)
- local r = { }
- for i=1,#t do
- r[i] = todictnumber(t[i])
- end
- return concat(r)
- end
-
- local function writestring(target,source,offset,what)
- target[#target+1] = source
- -- report_fonts("string : %-11s %06i # %05i",what,offset,#source)
- return offset + #source
- end
-
- local function writetable(target,source,offset,what)
- source = concat(source)
- target[#target+1] = source
- -- report_fonts("table : %-11s %06i # %05i",what,offset,#source)
- return offset + #source
- end
-
- local function writeindex(target,source,offset,what)
- local n = #source
- local t = #target
- t = t + 1 ; target[t] = tocardinal2(n)
- if n > 0 then
- local data = concat(source)
- local size = #data -- assume the worst
- local offsetsize, tocardinal
- if size < 0xFF then
- offsetsize, tocardinal = 1, tocardinal1
- elseif size < 0xFFFF then
- offsetsize, tocardinal = 2, tocardinal2
- elseif size < 0xFFFFFF then
- offsetsize, tocardinal = 3, tocardinal3
- elseif size < 0xFFFFFFFF then
- offsetsize, tocardinal = 4, tocardinal4
- end
- -- report_fonts("index : %-11s %06i # %05i (%i entries with offset size %i)",what,offset,#data,n,offsetsize)
- offset = offset + 2 + 1 + (n + 1) * offsetsize + size
- -- bytes per offset
- t = t + 1 ; target[t] = tocardinal1(offsetsize)
- -- list of offsets (one larger for length calculation)
- local offset = 1 -- mandate
- t = t + 1 ; target[t] = tocardinal(offset)
- for i=1,n do
- offset = offset + #source[i]
- t = t + 1 ; target[t] = tocardinal(offset)
- end
- t = t + 1 ; target[t] = data
- else
- -- report_fonts("index : %-11s %06i # %05i (no entries)",what,offset,0)
- offset = offset + 2
- end
- -- print("offset",offset,#concat(target))
- return offset
- end
-
- tablewriters.cff = function(fontfile)
- --
- local streams = fontfile.streams
- local cffinfo = streams.cffinfo or { }
- local names = streams.names or { }
- local fontheader = streams.fontheader or { }
- local basefontname = fontfile.basefontname
- --
- local offset = 0
- local dictof = 0
- local target = { }
- --
- local charstrings = fontfile.charstrings
- local nofglyphs = #charstrings + 1
- local fontmatrix = { 0.001, 0, 0, 0.001, 0, 0 } -- todo
- local fontbbox = fontfile.fontbbox
- local defaultwidth = cffinfo.defaultwidth or 0
- local nominalwidth = cffinfo.nominalwidth or 0
- local bluevalues = cffinfo.bluevalues
- local otherblues = cffinfo.otherblues
- local familyblues = cffinfo.familyblues
- local familyotherblues = cffinfo.familyotherblues
- local bluescale = cffinfo.bluescale
- local blueshift = cffinfo.blueshift
- local bluefuzz = cffinfo.bluefuzz
- local stdhw = cffinfo.stdhw
- local stdvw = cffinfo.stdvw
- --
- if defaultwidth == 0 then defaultwidth = nil end
- if nomimalwidth == 0 then nominalwidth = nil end
- if bluevalues then bluevalues = todictarray(bluevalues) end
- if otherblues then otherblues = todictarray(otherblues) end
- if familyblues then familyblues = todictarray(familyblues) end
- if familyotherblues then familyotherblues = todictarray(familyotherblues) end
- if bluescale then bluescale = todictnumber(bluescale) end
- if blueshift then blueshift = todictnumber(blueshift) end
- if bluefuzz then bluefuzz = todictnumber(bluefuzz) end
- if stdhw then stdhw = todictdeltas(stdhw) end
- if stdvw then stdvw = todictdeltas(stdvw) end
- --
- local fontversion = todictstring(fontfile,fontheader.fontversion or "uknown version")
- local familyname = todictstring(fontfile,cffinfo.familyname or names.family or basefontname)
- local fullname = todictstring(fontfile,cffinfo.fullname or basefontname)
- local weight = todictstring(fontfile,cffinfo.weight or "Normal")
- local fontbbox = todictarray(fontbbox)
- local strokewidth = todictnumber(cffinfo.strokewidth)
- local monospaced = todictboolean(cffinfo.monospaced)
- local italicangle = todictnumber(cffinfo.italicangle)
- local underlineposition = todictnumber(cffinfo.underlineposition)
- local underlinethickness = todictnumber(cffinfo.underlinethickness)
- local charstringtype = todictnumber(2)
- local fontmatrix = todictarray(fontmatrix)
- local ros = todictstring(fontfile,"Adobe") -- registry
- .. todictstring(fontfile,"Identity") -- identity
- .. todictnumber(0) -- supplement
- local cidcount = todictnumber(fontfile.nofglyphs)
- local fontname = todictstring(fontfile,basefontname)
- local fdarrayoffset = todictoffset(0)
- local fdselectoffset = todictoffset(0)
- local charstringoffset = todictoffset(0)
- local charsetoffset = todictoffset(0)
- local privateoffset = todictoffset(0)
- --
- local defaultwidthx = todictnumber(defaultwidth)
- local nominalwidthx = todictnumber(nominalwidth)
- local private = ""
- .. (defaultwidthx and (defaultwidthx .. todictkey(20)) or "")
- .. (nominalwidthx and (nominalwidthx .. todictkey(21)) or "")
- .. (bluevalues and (bluevalues .. todictkey(6)) or "")
- .. (otherblues and (otherblues .. todictkey(7)) or "")
- .. (familyblues and (familyblues .. todictkey(8)) or "")
- .. (familyotherblues and (familyotherblues .. todictkey(9)) or "")
- .. (bluescale and (bluescale .. todictkey(12,9)) or "")
- .. (blueshift and (blueshift .. todictkey(12,10)) or "")
- .. (bluefuzz and (bluefuzz .. todictkey(12,11)) or "")
- .. (stdhw and (stdhw .. todictkey(12,12)) or "")
- .. (stdvw and (stdvw .. todictkey(12,13)) or "")
- local privatesize = todictnumber(#private)
- local privatespec = privatesize .. privateoffset
- --
- -- header (fixed @ 1)
- --
- local header =
- tocardinal1(1) -- major
- .. tocardinal1(0) -- minor
- .. tocardinal1(4) -- header size
- .. tocardinal1(4) -- offset size
- --
- offset = writestring(target,header,offset,"header")
- --
- -- name index (fixed @ 2) (has to be sorted)
- --
- local names = {
- basefontname,
- }
- --
- offset = writeindex(target,names,offset,"names")
- --
- -- topdict index (fixed @ 3)
- --
- local topvars =
- charstringoffset .. todictkey(17)
- .. charsetoffset .. todictkey(15)
- .. fdarrayoffset .. todictkey(12,36)
- .. fdselectoffset .. todictkey(12,37)
- .. privatespec .. todictkey(18)
- --
- local topdict = {
- ros .. todictkey(12,30) -- first
- .. cidcount .. todictkey(12,34)
- .. familyname .. todictkey( 3)
- .. fullname .. todictkey( 2)
- .. weight .. todictkey( 4)
- .. fontbbox .. todictkey( 5)
- .. monospaced .. todictkey(12, 1)
- .. italicangle .. todictkey(12, 2)
- .. underlineposition .. todictkey(12, 3)
- .. underlinethickness .. todictkey(12, 4)
- .. charstringtype .. todictkey(12, 6)
- .. fontmatrix .. todictkey(12, 7)
- .. strokewidth .. todictkey(12, 8)
- .. topvars
- }
- --
- offset = writeindex(target,topdict,offset,"topdict")
- dictof = #target
- --
- -- string index (fixed @ 4)
- --
- offset = writeindex(target,fontfile.cffstrings,offset,"strings")
- --
- -- global subroutine index (fixed @ 5)
- --
- offset = writeindex(target,{},offset,"globals")
- --
- -- Encoding (cff1)
- --
- -- offset = writeindex(target,{},offset,"encoding")
- --
- -- Charsets
- --
- charsetoffset = todictoffset(offset)
- offset = writetable(target,fontfile.charmappings,offset,"charsets")
- --
- -- fdselect
- --
- local fdselect =
- tocardinal1(3) -- format
- .. tocardinal2(1) -- n of ranges
- -- entry 1
- .. tocardinal2(0) -- first gid
- .. tocardinal1(0) -- fd index
- -- entry 2
--- .. tocardinal2(fontfile.sparsemax-1) -- sentinel
- .. tocardinal2(fontfile.sparsemax) -- sentinel
- --
- fdselectoffset = todictoffset(offset)
- offset = writestring(target,fdselect,offset,"fdselect")
- --
- -- charstrings
- --
- charstringoffset = todictoffset(offset)
- offset = writeindex(target,charstrings,offset,"charstrings")
- --
- -- font dict
- --
- -- offset = writeindex(target,{},offset,"fontdict")
- --
- -- private
- --
- privateoffset = todictoffset(offset)
- privatespec = privatesize .. privateoffset
- offset = writestring(target,private,offset,"private")
- --
- local fdarray = {
- fontname .. todictkey(12,38)
- .. privatespec .. todictkey(18)
- }
- fdarrayoffset = todictoffset(offset)
- offset = writeindex(target,fdarray,offset,"fdarray")
- --
- topdict = target[dictof]
- topdict = sub(topdict,1,#topdict-#topvars)
- topvars =
- charstringoffset .. todictkey(17)
- .. charsetoffset .. todictkey(15)
- .. fdarrayoffset .. todictkey(12,36)
- .. fdselectoffset .. todictkey(12,37)
- .. privatespec .. todictkey(18)
- target[dictof] = topdict .. topvars
- --
- target = concat(target)
- -- if trace_details then
- -- local name = "temp.cff"
- -- report_fonts("saving %a",name)
- -- io.savedata(name,target)
- -- inspect(fonts.handlers.otf.readers.cffcheck(name))
- -- end
- return target
- end
-
- end
-
- -- todo: check widths (missing a decimal)
-
- mainwriters["opentype"] = function(details)
- --
- local fontfile = openfontfile(details)
- local basefontname = details.basefontname
- local streams = details.streams
- local blobs = streams.streams
- local fontheader = streams.fontheader
- local maximumprofile = streams.maximumprofile
- local names = streams.names
- local descriptions = details.rawdata.descriptions
- local metadata = details.rawdata.metadata
- local indices = details.indices
- local metabbox = { fontheader.xmin, fontheader.ymin, fontheader.xmax, fontheader.ymax }
- local correction = 1
-
- -- (*) We share code with type1 and when we have old school tfm with
- -- pfb but without descriptions we're kind of toast.
-
- if not descriptions or not next(descriptions) then
- -- This is good enough, we only need indices and widths.
- descriptions = details.fontdata.characters
- -- This is a hack, we have no basepoints.
- correction = details.fontdata.parameters.size / 1000
- -- And this needs checking.
- correction = correction * bpfactor / ptfactor
- metadata = { }
- end
-
- --
-
- local indices,
- minindex,
- maxindex = collectindices(descriptions,indices)
- local streamoffset = 0
- local glyphstreams,
- charmappings = tablecreators.cff(fontfile)
- --
- local zero2 = tocardinal2(0)
- local zero4 = tocardinal4(0)
- --
- -- we need to locate notdef (or store its unicode someplace)
- --
- local blob = blobs[0] or "\14"
- local sparsemax = 1
- local lastoffset = zero4
- glyphstreams[sparsemax] = blob
- charmappings[sparsemax] = tocardinal1(0) -- format 0
- streamoffset = streamoffset + #blob
- lastoffset = tocardinal4(streamoffset)
- if minindex == 0 then
- minindex = 1
- end
- for index=minindex,maxindex do
- if indices[index] then
- local blob = blobs[index] or "\14"
- sparsemax = sparsemax + 1
- glyphstreams[sparsemax] = blob
- charmappings[sparsemax] = tocardinal2(index)
- streamoffset = streamoffset + #blob
- lastoffset = tocardinal4(streamoffset)
- end
- end
- --
- fontfile.nofglyphs = maxindex + 1
- fontfile.sparsemax = sparsemax
- fontfile.format = "cff"
- fontfile.basefontname = basefontname
- fontfile.fontbbox = metabbox
- --
- local fontdata = tablewriters.cff(fontfile)
- local fontmeta = makemetadata(fontfile)
- --
- fontfile = closefontfile(fontfile)
- --
- local units = fontheader.units or metadata.units
-
- local basefont = pdfconstant(basefontname)
- local widths = widtharray(details,indices,maxindex,units * correction)
- local object = details.objectnumber
- local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,true)
- local tocidset = tocidsetdictionary(indices,minindex,maxindex)
- local fontbbox = pdfarray { unpack(metabbox) }
- local ascender = metadata.ascender or 0
- local descender = metadata.descender or 0
- local capheight = metadata.capheight or fontbbox[4]
- local stemv = metadata.weightclass
- local italicangle = metadata.italicangle
- local xheight = metadata.xheight or fontbbox[4]
- if stemv then
- stemv = (stemv/65)^2 + 50
- else
--- stemv = 2
- end
- --
- local function scale(n)
- if n then
- return round((n) * 10000 / units) / 10
- else
- return 0
- end
- end
- --
- local reserved = pdfreserveobject()
- local child = pdfdictionary {
- Type = pdfconstant("Font"),
- Subtype = pdfconstant("CIDFontType0"),
- BaseFont = basefont,
- FontDescriptor = pdfreference(reserved),
- W = pdfreference(pdfflushobject(widths)),
- CIDSystemInfo = pdfdictionary {
- Registry = pdfstring("Adobe"),
- Ordering = pdfstring("Identity"),
- Supplement = 0,
- }
- }
- local descendants = pdfarray {
- pdfreference(pdfflushobject(child)),
- }
- local fontstream = pdfdictionary {
- Subtype = pdfconstant("CIDFontType0C"),
- }
- local descriptor = pdfdictionary {
- Type = pdfconstant("FontDescriptor"),
- FontName = basefont,
- Flags = 4,
- FontBBox = fontbbox,
- Ascent = scale(ascender),
- Descent = scale(descender),
- ItalicAngle = round(italicangle or 0),
- CapHeight = scale(capheight),
- StemV = scale(stemv),
- XHeight = scale(xheight),
- CIDSet = tocidset,
- FontFile3 = pdfreference(pdfflushstreamobject(fontdata,fontstream())),
- Metadata = fontmeta and pdfreference(pdfflushstreamobject(fontmeta)) or nil,
- }
- local parent = pdfdictionary {
- Type = pdfconstant("Font"),
- Subtype = pdfconstant("Type0"),
- Encoding = pdfconstant(details.properties.writingmode == "vertical" and "Identity-V" or "Identity-H"),
- BaseFont = basefont,
- DescendantFonts = descendants,
- ToUnicode = pdfreference(pdfflushstreamobject(tounicode)),
- }
- pdfflushobject(reserved,descriptor)
- pdfflushobject(object,parent)
- end
-
- mainwriters["type1"] = function(details)
- -- We abuse the cff includer which is ok but for special cases like
- -- tfm -> pfb we don't have the right descriptions and scale so this
- -- is why we cheat elsewhere. Maybe I should just drop that kind of
- -- support and assume afm files to be present. See (*) above.
- local s = details.streams
- local m = details.rawdata.metadata
- if m then
- local h = s.horizontalheader
- local c = s.cffinfo
- local n = s.names
- h.ascender = m.ascender or h.ascender
- h.descender = m.descender or h.descender
- n.copyright = m.copyright or n.copyright
- n.family = m.familyname or n.familyname
- n.fullname = m.fullname or n.fullname
- n.fontname = m.fontname or n.fontname
- n.subfamily = m.subfamilyname or n.subfamilyname
- n.version = m.version or n.version
- setmetatableindex(h,m)
- setmetatableindex(c,m)
- setmetatableindex(n,m)
- end
- mainwriters["opentype"](details)
- end
-
- do
-
- -- The methods might become plugins.
-
- local methods = { }
-
- local pdfimage = lpdf.epdf.image
- local openpdf = pdfimage.open
- local closepdf = pdfimage.close
- local copypage = pdfimage.copy
-
- local embedimage = images.embed
-
- local f_glyph = formatters["G%d"]
- local f_char = formatters["BT /V%d 1 Tf [<%04X>] TJ ET"]
- local f_width = formatters["%.6N 0 d0"]
- local f_index = formatters["I%d"]
- local f_image_xy = formatters["%.6N 0 d0 1 0 0 1 %.6N %.6N cm /%s Do"]
- local f_image_c = formatters["/%s Do"]
- local f_image_c_xy = formatters["%.6N 0 0 %.6N %.6N %.6N cm /%s Do"]
- local f_image_w = formatters["%.6N 0 d0 %s"]
- local f_image_d = formatters["%.6N 0 d0 1 0 0 1 0 %.6N cm /%s Do"]
- local f_stream = formatters["%.6N 0 d0 %s"]
- local f_stream_c = formatters["%.6N 0 0 0 0 0 d1 %s"]
- local f_stream_d = formatters["%.6N 0 d0 1 0 0 1 0 %.6N cm %s"]
-
- -- A type 3 font has at most 256 characters and Acrobat also wants a zero slot
- -- to be filled. We can share a mandate zero slot character. We also need to
- -- make sure that we use bytes as index in the page stream as well as in the
- -- tounicode vector.
-
- local c_notdef = nil
- local r_notdef = nil
- local w_notdef = nil
- local fontbbox = nil
-
- -- pk inclusion (not really tested but not really used either)
-
- function methods.pk(filename)
- local pkfullname = resolvers.findpk(basedfontname,resolution)
- if not pkfullname or pkfullname == "" then
- return
- end
- local readers = fonts.handlers.tfm.readers
- local result = readers.loadpk(pkfullname)
- local convert = readers.pktopdf
- if not result or result.error then
- return
- end
- local resolution = 600
- local widthfactor = resolution / 72
- local scalefactor = 72 / resolution / 10
- local factor = widthfactor / 65536
- local function pktopdf(glyph,data)
- return convert(glyph,data,factor) -- return pdfcode, width
- end
- return result.glyphs, scalefactor, pktopdf, false, false
- end
-
- -- pdf inclusion
-
- local used = setmetatableindex("table")
-
- function methods.pdf(filename,details)
- local properties = details.properties
- local pdfshapes = properties.indexdata[1]
- local pdfdoc = openpdf(pdfshapes.filename)
- local xforms = pdfdictionary()
- local nofglyphs = 0
- if pdfdoc then
- local scale = 10 * details.parameters.size/details.parameters.designsize
- local units = details.parameters.units
- local factor = units * bpfactor / scale
- local fixdepth = pdfshapes.fixdepth
- local useddoc = used[pdfdoc]
- local function pdftopdf(glyph,data)
- local width = (data.width or 0) * factor
- local image = useddoc[glyph]
- local reference = nil
- if not image then
- image = embedimage(copypage(pdfdoc,glyph))
- nofglyphs = nofglyphs + 1
- local name = f_glyph(nofglyphs)
- local stream = nil
- if fixdepth then
- local depth = data.depth or 0
- local height = data.height or 0
- if depth ~= 0 or height ~= 0 then
- local d = data.dropin.descriptions[data.index]
- local b = d.boundingbox
- local l = b[1]
- local r = b[3]
- local w = r - l
- local scale = w / d.width
- local x = l
- local y = - b[4] - b[2] - d.depth
- local scale = w / (image.width * bpfactor)
- stream = f_image_c_xy(scale,scale,x,y,name)
- else
- stream = f_image_c(name)
- end
- else
- stream = f_image_c(name)
- end
- useddoc[glyph] = image
- image.embedded_name = name
- image.embedded_stream = stream
- image.embedded_reference = pdfreference(image.objnum)
- end
- xforms[image.embedded_name] = image.embedded_reference
- return f_image_w(width,image.embedded_stream), width
- end
- local function closepdf()
- -- closepdf(pdfdoc)
- end
- local function getresources()
- return pdfdictionary { XObject = xforms }
- end
- return pdfshapes, 1/units, pdftopdf, closepdf, getresources
- end
- end
-
- -- mps inclusion
-
- local decompress = gzip.decompress
- local metapost = metapost
- local simplemprun = metapost.simple
- local setparameterset = metapost.setparameterset
-
- function methods.mps(filename,details)
- local properties = details.properties
- local parameters = details.parameters
- local mpshapes = properties.indexdata[1] -- indexdata will change
- if mpshapes then
- local scale = 10 * parameters.size/parameters.designsize
- local units = mpshapes.units or parameters.units
- local factor = units * bpfactor / scale
- local fixdepth = mpshapes.fixdepth
- local usecolor = mpshapes.usecolor
- local specification = mpshapes.specification
- local shapedefinitions = mpshapes.shapes
- local instance = mpshapes.instance
- --
- simplemprun(instance,"begingroup;",true,true)
- setparameterset("mpsfont",specification)
- if shapedefinitions then
- local preamble = shapedefinitions.parameters.preamble
- if preamble then
- simplemprun(instance,preamble,true,true)
- end
- end
- --
- local function mpstopdf(mp,data)
- local width = data.width
- if decompress then
- mp = decompress(mp)
- end
- local pdf = simplemprun(instance,mp,true) -- can be sped up, minifun
- local width = width * factor
- if usecolor then
- return f_stream_c(width,pdf), width
- elseif fixdepth then
- local depth = data.depth or 0
- local height = data.height or 0
- if depth ~= 0 or height ~= 0 then
- return f_stream_d(width,(-height-depth)*factor,pdf), width
- end
- end
- return f_stream(width,pdf), width
- end
- --
- local function resetmps()
- setparameterset("mpsfont")
- simplemprun(instance,"endgroup;",true,true)
- end
- --
- local function getresources()
- return lpdf.collectedresources {
- serialize = false,
- }
- end
- --
- return mpshapes, 1/units, mpstopdf, resetmps, getresources
- end
- end
-
- -- png inclusion
-
- -- With d1 the image mask is used when given and obeys color. So it is needed for pure bw
- -- bitmap fonts, so here we really need d0.
- --
- -- Acrobat X pro only seems to see the image mask but other viewers are doing it ok. Acrobat
- -- reader crashes. We really need to add a notdef!
-
- local files = utilities.files
- local openfile = files.open
- local closefile = files.close
- local setposition = files.setposition
- local readstring = files.readstring
-
- function methods.png(filename,details)
- local properties = details.properties
- local pngshapes = properties.indexdata[1]
- if pngshapes then
- local parameters = details.parameters
- local png = properties.png
- local hash = png.hash
- local xforms = pdfdictionary()
- local nofglyphs = 0
- local scale = 10 * parameters.size/parameters.designsize
- local factor = bpfactor / scale
- -- local units = parameters.units -- / 1000
- local units = 1000
- local filehandle = openfile(details.filename,true)
- local function pngtopdf(glyph,data)
- -- local info = graphics.identifiers.png(glyph.data,"string")
- local offset = glyph.o
- local size = glyph.s
- local pdfdata = nil
- if offset and size then
- setposition(filehandle,offset)
- local blob = readstring(filehandle,size)
- local info = graphics.identifiers.png(blob,"string")
- info.enforcecmyk = pngshapes.enforcecmyk
- local image = lpdf.injectors.png(info,"string")
- local width = (data.width or 0) * factor
- if image then
- embedimage(image)
- nofglyphs = nofglyphs + 1
- local xoffset = (glyph.x or 0) / units
- local yoffset = (glyph.y or 0) / units
- local name = f_glyph(nofglyphs)
- xforms[name] = pdfreference(image.objnum)
- pdfdata = f_image_xy(width,xoffset,yoffset,name)
- end
- end
- return pdfdata or f_stream(width), width
- end
- local function closepng()
- if filehandle then
- closefile(filehandle)
- end
- pngshapes = nil
- end
- local function getresources()
- return pdfdictionary { XObject = xforms }
- end
- return pngshapes, 1, pngtopdf, closepng, getresources
- end
- end
-
- function methods.color(filename,details)
- local colrshapes = details.properties.indexdata[1]
- local colrvalues = details.properties.indexdata[2]
- local usedfonts = { }
- local function colrtopdf(description,data)
- -- descriptions by index
- local colorlist = description.colors
- if colorlist then
- local dropdata = data.dropin
- local dropid = dropdata.properties.id
- local dropunits = dropdata.parameters.units -- shared
- local descriptions = dropdata.descriptions
- usedfonts[dropid] = dropid
- local w = description.width or 0
- local s = #colorlist
- local l = nil
- local t = { f_width(w) }
- local n = 1
- local d = colrvalues[#colrvalues]
- for i=1,s do
- local entry = colorlist[i]
- local v = colrvalues[entry.class] or d
- if v and l ~= v then
- n = n + 1 ; t[n] = v
- l = v
- end
- local e = descriptions[entry.slot]
- if e then
- n = n + 1 ; t[n] = f_char(dropid,e.index)
- end
- end
- return concat(t," "), w / dropunits
- end
- end
- local function getresources()
- return lpdf.collectedresources {
- serialize = false,
- fonts = usedfonts,
- fontprefix = "V",
- }
- end
- return colrshapes, 1, colrtopdf, false, getresources
- end
-
- mainwriters["type3"] = function(details)
- local properties = details.properties
- local basefontname = details.basefontname or properties.name
- local askedmethod = properties.method or "pk"
- local method = methods[askedmethod] or methods.pk
- if not method then
- return
- end
- local glyphs, scalefactor, glyphtopdf, reset, getresources = method(basedfontname,details)
- if not glyphs then
- return
- end
- local parameters = details.parameters
- local object = details.objectnumber
- local factor = parameters.factor -- normally 1
- local fontmatrix = pdfarray { scalefactor, 0, 0, scalefactor, 0, 0 }
- local indices,
- minindex,
- maxindex = collectindices(details.fontdata.characters,details.indices)
- local widths = pdfarray()
- local differences = pdfarray()
- local charprocs = pdfdictionary()
- local basefont = pdfconstant(basefontname)
- local d = 0
- local w = 0
- local forcenotdef = minindex > 0
- local lastindex = -0xFF
- if forcenotdef then
- widths[0] = 0
- minindex = 0
- lastindex = 0
- d = 2
- if not c_notdef then
- w_notdef = 0
- c_notdef = pdfconstant(".notdef")
- r_notdef = pdfreference(pdfflushstreamobject("0 0 d0"))
- end
- differences[1] = w_notdef
- differences[2] = c_notdef
- charprocs[".notdef"] = r_notdef
- end
-
- for i=1,maxindex-minindex+1 do
- widths[i] = 0
- end
-
- for index, data in sortedhash(indices) do
- local name = f_index(index)
- local glyph = glyphs[index]
- if glyph then
- local stream, width = glyphtopdf(glyph,data)
- if stream then
- if index - 1 ~= lastindex then
- d = d + 1 differences[d] = index
- end
- lastindex = index
- d = d + 1 differences[d] = pdfconstant(name)
- charprocs[name] = pdfreference(pdfflushstreamobject(stream))
- widths[index-minindex+1] = width
- end
- else
- report_fonts("missing glyph %i in type3 font %a",index,basefontname)
- end
- end
- if not fontbbox then
- -- The specification permits zero values and these are actually also more
- -- robust as then there are no assumptions and no accuracy is needed.
- fontbbox = pdfarray { 0, 0, 0, 0 }
- end
- local encoding = pdfdictionary {
- Type = pdfconstant("Encoding"),
- Differences = differences,
- }
- local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,false)
- local resources = getresources and getresources()
- if not resources or not next(resources) then
- -- resources = lpdf.procset(true)
- resources = nil
- end
- local descriptor = pdfdictionary {
- -- most is optional in type3
- Type = pdfconstant("FontDescriptor"),
- FontName = basefont,
- Flags = 4,
- ItalicAngle = 0,
- }
- local parent = pdfdictionary {
- Type = pdfconstant("Font"),
- Subtype = pdfconstant("Type3"),
- Name = basefont,
- FontBBox = fontbbox,
- FontMatrix = fontmatrix,
- CharProcs = pdfreference(pdfflushobject(charprocs)),
- Encoding = pdfreference(pdfflushobject(encoding)),
- FirstChar = minindex,
- LastChar = maxindex,
- Widths = pdfreference(pdfflushobject(widths)),
- FontDescriptor = pdfreference(pdfflushobject(descriptor)),
- Resources = resources,
- ToUnicode = tounicode and pdfreference(pdfflushstreamobject(tounicode)),
- }
- pdfflushobject(object,parent)
- if reset then
- reset()
- end
- end
-
- end
-
-end
-
--- writingmode
-
-local usedfonts = fonts.hashes.identifiers -- for now
-local noffonts = 0
-
--- The main injector.
-
--- here we need to test for sharing otherwise we reserve too many
--- objects
-
-local getstreamhash = fonts.handlers.otf.getstreamhash
-local loadstreamdata = fonts.handlers.otf.loadstreamdata
-
--- we can actually now number upwards (so not use fontid in /F)
-
-local objects = setmetatableindex(function(t,k)
- local v
- if type(k) == "number" then
- local h = getstreamhash(k)
- v = rawget(t,h)
- if not v then
- v = pdfreserveobject()
- t[h] = v
- end
- if trace_fonts then
- report_fonts("font id %i bound to hash %s and object %i",k,h,v)
- end
- else
- -- no problem as it can be svg only
- -- report_fonts("fatal error, hash %s asked but not used",k,h,v)
- v = pdfreserveobject()
- t[k] = v
- end
- return v
-end)
-
-local n = 0
-
-local names = setmetatableindex(function(t,k)
- local v
- if type(k) == "number" then
- local h = getstreamhash(k)
- v = rawget(t,h)
- if not v then
- n = n + 1
- v = n
- t[h] = v
- end
- if trace_fonts then
- report_fonts("font id %i bound to hash %s and name %i",k,h,n)
- end
- end
- t[k] = v
- return v
-end)
-
-function lpdf.flushfonts()
-
- local mainfonts = { }
-
- statistics.starttiming(objects)
-
- for fontid, used in sortedhash(lpdf.usedcharacters) do
-
- -- for a bitmap we need a different hash unless we stick to a fixed high
- -- resolution which makes much sense
-
- local hash = getstreamhash(fontid)
- if hash then
- local parent = mainfonts[hash]
- if not parent then
- local fontdata = usedfonts[fontid]
- local rawdata = fontdata.shared and fontdata.shared.rawdata
- local resources = fontdata.resources
- local properties = fontdata.properties -- writingmode and type3
- local parameters = fontdata.parameters -- used in type3
- if not rawdata then
- -- we have a virtual font that loaded directly ... at some point i will
- -- sort this out (in readanddefine we need to do a bit more) .. the problem
- -- is that we have a hybrid font then
- for xfontid, xfontdata in next, fonts.hashes.identifiers do
- if fontid ~= xfontid then
- local xhash = getstreamhash(xfontid)
- if hash == xhash then
- rawdata = xfontdata.shared and xfontdata.shared.rawdata
- if rawdata then
- resources = xfontdata.resources
- properties = xfontdata.properties
- parameters = xfontdata.parameters
- break
- end
- end
- end
- end
- end
- if rawdata then
- parent = {
- hash = hash,
- fontdata = fontdata,
- filename = resources.filename or properties.filename or "unset",
- indices = { },
- rawdata = rawdata,
- properties = properties, -- we assume consistency
- parameters = parameters, -- we assume consistency
- streams = { },
- objectnumber = objects[hash],
- basefontname = subsetname(properties.psname or properties.name or "unset"),
- name = names[hash],
- }
- mainfonts[hash] = parent
- noffonts = noffonts + 1
- end
- end
- if parent then
- local indices = parent.indices
- for k in next, used do
- indices[k] = true
- end
- end
- end
- end
-
- -- this is no not yet ok for tfm / type 1 .. we need to move the nested blobs ourside the loop
-
- for hash, details in sortedhash(mainfonts) do
- local filename = details.filename
- if next(details.indices) then
- if trace_fonts then
- report_fonts("embedding %a hashed as %a",filename,hash)
- end
- local properties = details.properties
- local bitmap = properties.usedbitmap
- local method = properties.method -- will be pk | pdf | svg | ...
- if bitmap or method then
- local format = "type3"
- local writer = mainwriters[format]
- if writer then
- if trace_fonts then
- report_fonts("using main writer %a",format)
- end
- writer(details)
- end
- else
- local format = properties.format
- local writer = mainwriters[format]
- if not writer then
- -- This will move to the tpk module where we will also deal
- -- with bitmaps then.
- local encoding, pfbfile, encfile = getmapentry(filename)
- if trace_fonts then
- report_fonts("file %a resolved to encoding %a and file %a",filename,encoding,pfbfile)
- end
- if encoding and pfbfile then
- filename = pfbfile
- format = "type1"
- --
- -- another (temp) hack
- local size = details.fontdata.parameters.size
- local factor = details.fontdata.parameters.factor
- local descriptions = { }
- local characters = details.fontdata.characters
- --
- local names, _, _, metadata = fonts.constructors.handlers.pfb.loadvector(pfbfile)
- local reverse = table.swapped(names)
- local vector = encoding.vector
- local indices = details.indices
- local remapped = { }
- local factor = bpfactor * size / 65536
- for k, v in next, indices do
- local name = vector[k]
- local index = reverse[name] or 0
- local width = factor * (characters[k].width or 0)
- descriptions[k] = {
- width = width,
- index = index,
- name = name,
- }
- remapped[index] = true
- end
- details.indices = remapped
- --
- details.rawdata.descriptions = descriptions
- details.filename = filename
- details.rawdata.metadata = { }
- --
- properties.filename = filename
- properties.format = format
- writer = mainwriters[format]
- end
- end
- if not writer then
- local pfbfile = file.replacesuffix(filename,"pfb")
- if encoding and pfbfile then
- filename = pfbfile
- format = "type1"
- --
- -- another (temp) hack
- local size = details.fontdata.parameters.size
- local factor = details.fontdata.parameters.factor
- local descriptions = { }
- local characters = details.fontdata.characters
- --
- local names, _, _, metadata = fonts.constructors.handlers.pfb.loadvector(pfbfile)
- local reverse = table.swapped(names)
- local vector = encoding.vector
- local indices = details.indices
- local remapped = { }
- local factor = bpfactor * size / 65536
- for k, v in next, indices do
- local name = vector[k]
- local index = reverse[name] or 0
- local width = factor * (characters[k].width or 0)
- descriptions[k] = {
- width = width,
- index = index,
- name = name,
- }
- remapped[index] = true
- end
- details.indices = remapped
- --
- details.rawdata.descriptions = descriptions
- details.filename = filename
- details.rawdata.metadata = { }
- --
- properties.filename = filename
- properties.format = format
- writer = mainwriters[format]
- end
- end
- if writer then
- if trace_fonts then
- report_fonts("using main writer %a",format)
- end
- -- better move this test to the writers .. cleaner
- local streams = loadstreamdata(details.fontdata)
- if streams and streams.fontheader and streams.names then
- details.streams = streams
- writer(details)
- details.streams = { }
- elseif trace_fonts then
- -- can be ok for e.g. emoji
- report_fonts("no streams in %a",filename)
- end
- -- free some memory
- else -- if trace_fonts then
- report_fonts("no %a writer for %a",format,filename)
- end
- end
- else -- not problem for svg ...
- -- report_fonts("no indices for %a",filename)
- end
- if trace_fonts then
- report_fonts("embedded indices: % t",table.sortedkeys(details.indices))
- end
- mainfonts[details.hash] = false -- done
- end
-
- statistics.stoptiming(objects)
-
-end
-
-statistics.register("font embedding time",function()
- if noffonts > 0 then
- return format("%s seconds, %s fonts", statistics.elapsedtime(objects),noffonts)
- end
-end)
-
--- this is temporary
-
-local done = false
-
-updaters.register("backend.update.pdf",function()
- if not done then
- function pdf.getfontobjnum (k) return objects[k] end
- function pdf.getfontname (k) return names [k] end
- function pdf.includechar () end -- maybe, when we need it
- function pdf.includefont () end -- maybe, when we need it
- function pdf.includecharlist () end -- maybe, when we need it
- function pdf.setomitcidset (v) includecidset = not toboolean(v) end
- function pdf.setomitcharset () end -- we don't need that in lmtx
- function pdf.setsuppressoptionalinfo() end -- we don't need that in lmtx
- function pdf.mapfile (n) loadmapfile(n) end
- function pdf.mapline (n) loadmapline(n) end
- -- this will change
- lpdf.registerdocumentfinalizer(lpdf.flushfonts,1,"wrapping up fonts")
- done = true
- end
-end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-eng.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-eng.lua
index 21c7e66e999..26a63e9a0ef 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-eng.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-eng.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['lpdf-eng'] = {
version = 1.001,
+ optimize = true,
comment = "companion to lpdf-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-epa.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-epa.lua
index 45000aebc75..0ff764e1d72 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-epa.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-epa.lua
@@ -510,7 +510,7 @@ local validstamps = {
ForPublicRelease = true,
}
--- todo: we can use runtoks instead of steps
+-- todo: we can use runlocal instead of steps
local function validStamp(v)
local name = "Stamped" -- fallback
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-fld.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-fld.lua
index e5a95fdab7c..e14968eb8ad 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-fld.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-fld.lua
@@ -1003,17 +1003,17 @@ function nodeinjections.typesetfield(name,specification)
end
end
-local function save_parent(field,specification,d,hasopt)
+local function save_parent(field,specification,d)
local kidsnum = pdfreserveobject()
d.Kids = pdfreference(kidsnum)
field.kidsnum = kidsnum
field.kids = pdfarray()
- if hasopt then
- local optnum = pdfreserveobject()
- d.Opt = pdfreference(optnum)
- field.optnum = optnum
- field.opt = pdfarray()
- end
+-- if d.Opt then
+-- local optnum = pdfreserveobject()
+-- d.Opt = pdfreference(optnum)
+-- field.optnum = optnum
+-- field.opt = pdfarray()
+-- end
local pnum = pdfflushobject(d)
field.pobj = pnum
collected[#collected+1] = pdfreference(pnum)
@@ -1022,12 +1022,12 @@ end
local function save_kid(field,specification,d,optname)
local kn = pdfreserveobject()
field.kids[#field.kids+1] = pdfreference(kn)
- if optname then
- local opt = field.opt
- if opt then
- opt[#opt+1] = optname
- end
- end
+-- if optname then
+-- local opt = field.opt
+-- if opt then
+-- opt[#opt+1] = optname
+-- end
+-- end
local width = specification.width or 0
local height = specification.height or 0
local depth = specification.depth or 0
@@ -1243,7 +1243,7 @@ local function makecheckparent(field,specification)
FT = pdf_btn,
V = fielddefault(field,default),
}
- save_parent(field,specification,d,true)
+ save_parent(field,specification,d)
end
local function makecheckchild(name,specification)
@@ -1371,7 +1371,7 @@ local function makeradioparent(field,specification)
-- H = pdf_n,
V = fielddefault(field),
}
- save_parent(field,specification,d,true)
+ save_parent(field,specification,d)
end
-- local function makeradiochild(name,specification)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-fmt.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-fmt.lua
index 388db0be3d9..c6a3f25ff5e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-fmt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-fmt.lua
@@ -885,8 +885,8 @@ function codeinjections.setformat(s)
end
local pdf_version = spec.pdf_version * 10
local inject_metadata = spec.inject_metadata
- local majorversion = math.div(pdf_version,10)
- local minorversion = math.mod(pdf_version,10)
+ local majorversion = math.floor(math.div(pdf_version,10))
+ local minorversion = math.floor(math.mod(pdf_version,10))
local objectcompression = spec.object_compression and pdf_version >= 15
local compresslevel = level or lpdf.compresslevel() -- keep default
local objectcompresslevel = (objectcompression and (level or lpdf.objectcompresslevel())) or 0
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua
index e827419a6ce..963b1dde319 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua
@@ -293,3 +293,5 @@ end
function lpdf.patternstream(n,width,height)
return f_pattern("Pt" .. n,width*basepoints,height*basepoints)
end
+
+backends.pdf.codeinjections.registerpattern = lpdf.registerpattern
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-img.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-img.lua
deleted file mode 100644
index 17305a1cfa6..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-img.lua
+++ /dev/null
@@ -1,1340 +0,0 @@
-if not modules then modules = { } end modules ['lpdf-img'] = {
- version = 1.001,
- comment = "companion to lpdf-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- This started as an experiment but has potential for some (cached) optimizations.
--- At some point we can also use it for fonts. For small images performance is ok
--- with pure lua but for bigger images we can use some helpers. Normally in a
--- typesetting workflow non-interlaced images are used. One should convert
--- interlaced images to more efficient non-interlaced ones (ok, we can cache
--- them if needed).
---
--- The \LUA\ code is slightly optimized so we could have done with less lines if
--- we wanted but best gain a little. The idea is that we collect striped (in stages)
--- so that we can play with substitutions.
-
-local type = type
-local concat, move = table.concat, table.move
-local ceil, min = math.ceil, math.min
-local char, byte, find, gmatch = string.char, string.byte, string.find, string.gmatch
-local idiv = number.idiv
-local band, rshift = bit32.band, bit32.rshift
-
-local loaddata = io.loaddata
-local setmetatableindex = table.setmetatableindex
-local formatters = string.formatters
-
-local streams = utilities.streams
-local openstring = streams.openstring
-local readstring = streams.readstring
-local readbytetable = streams.readbytetable
-
-local newreader = io.newreader
-
-local tobytetable = string.bytetable
-
-local lpdf = lpdf or { }
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfconstant = lpdf.constant
-local pdfstring = lpdf.string
-local pdfflushstreamobject = lpdf.flushstreamobject
-local pdfreference = lpdf.reference
-local pdfverbose = lpdf.verbose
-
-local pdfmajorversion = lpdf.majorversion
-local pdfminorversion = lpdf.minorversion
-
-local createimage = images.create
-
-local zlibcompress = (xzip or zlib).compress
-local zlibdecompress = (xzip or zlib).decompress
-
-local trace = false
-
-local report_jpg = logs.reporter("graphics","jpg")
-local report_jp2 = logs.reporter("graphics","jp2")
-local report_png = logs.reporter("graphics","png")
-
-trackers.register("graphics.backend", function(v) trace = v end)
-
-local injectors = { }
-lpdf.injectors = injectors
-
--- todo: load from a virtual file
-
-local function loadcontent(filename,method)
- return method == "string" and filename or loaddata(filename)
-end
-
-local function newcontent(filename,method)
- return newreader(filename,method)
-end
-
---
-
-local chars = setmetatableindex(function(t,k) -- share this one
- local v = (k <= 0 and "\000") or (k >= 255 and "\255") or char(k)
- t[k] = v
- return v
-end)
-
-do
-
- function injectors.jpg(specification,method)
- if specification.error then
- return
- end
- local filename = specification.filename
- if not filename then
- return
- end
- local colorspace = specification.colorspace or jpg_gray
- local decodearray = nil
- ----- procset = colorspace == 0 and "image b" or "image c"
- if colorspace == 1 then
- colorspace = "DeviceGray"
- elseif colorspace == 2 then
- colorspace = "DeviceRGB"
- elseif colorspace == 3 then
- colorspace = "DeviceCMYK"
- decodearray = pdfarray { 1, 0, 1, 0, 1, 0, 1, 0 }
- end
- -- todo: set filename
- local xsize = specification.xsize
- local ysize = specification.ysize
- local colordepth = specification.colordepth
- local content = loadcontent(filename,method)
- local xobject = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Image"),
- -- BBox = pdfarray { 0, 0, xsize, ysize },
- Width = xsize,
- Height = ysize,
- BitsPerComponent = colordepth,
- Filter = pdfconstant("DCTDecode"),
- ColorSpace = pdfconstant(colorspace),
- Decode = decodearray,
- Length = #content, -- specification.length
- } + specification.attr
- if trace then
- report_jpg("%s: width %i, height %i, colordepth %i, size %i",filename,xsize,ysize,colordepth,#content)
- end
- return createimage {
- bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
- transform = specification.transform,
- nolength = true,
- nobbox = true,
- notype = true,
- stream = content,
- attr = xobject(),
- }
- end
-
-end
-
-do
-
- function injectors.jp2(specification,method)
- if specification.error then
- return
- end
- local filename = specification.filename
- if not filename then
- return
- end
- -- todo: set filename
- local xsize = specification.xsize
- local ysize = specification.ysize
- local content = loadcontent(filename,method)
- local xobject = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Image"),
- BBox = pdfarray { 0, 0, xsize, ysize },
- Width = xsize,
- Height = ysize,
- Filter = pdfconstant("JPXDecode"),
- Length = #content, -- specification.length
- } + specification.attr
- if trace then
- report_jp2("%s: width %i, height %i, size %i",filename,xsize,ysize,#content)
- end
- return createimage {
- bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
- transform = specification.transform,
- nolength = true,
- nobbox = true,
- notype = true,
- stream = content,
- attr = xobject(),
- }
- end
-
-end
-
-do
-
- -- We don't like interlaced files. You can deinterlace them beforehand because otherwise
- -- each run you add runtime. Actually, even masked images can best be converted to PDF
- -- beforehand.
-
- -- The amount of code is larger that I like and looks somewhat redundant but we sort of
- -- optimize a few combinations that happen often.
-
- local pngapplyfilter = pngdecode.applyfilter
- local pngsplitmask = pngdecode.splitmask
- local pnginterlace = pngdecode.interlace
- local pngexpand = pngdecode.expand
- local pngtocmyk = pngdecode.tocmyk
-
- local filtermask, decodemask, decodestrip, transpose, expand, tocmyk
-
- local newindex = lua.newindex
- local newtable = lua.newtable
-
- local function newoutput(size)
- if newindex then
- return newindex(size,0)
- end
- local t = newtable and newtable(size,0) or { }
- for i=1,size do
- t[i] = 0
- end
- return t
- end
-
- local function convert(t)
- if type(t) == "table" then
- for i=1,#t do
- local ti = t[i]
- if ti ~= "" then -- soon gone
- t[i] = chars[ti]
- end
- end
- return concat(t)
- else
- return t
- end
- end
-
- local function zero(t,k)
- return 0
- end
-
- local function applyfilter(t,xsize,ysize,bpp)
- local len = xsize * bpp + 1
- local n = 1
- local m = len - 1
- for i=1,ysize do
- local filter = t[n]
- t[n] = ""
- if filter == 0 then
- elseif filter == 1 then
- for j=n+bpp+1,n+m do
- t[j] = (t[j] + t[j-bpp]) % 256
- end
- elseif filter == 2 then
- for j=n+1,n+m do
- t[j] = (t[j] + t[j-len]) % 256
- end
- elseif filter == 3 then
- for j=n+1,n+bpp do
- t[j] = (t[j] + idiv(t[j-len],2)) % 256
- end
- for j=n+bpp+1,n+m do
- t[j] = (t[j] + idiv(t[j-bpp] + t[j-len],2)) % 256
- end
- elseif filter == 4 then
- for j=n+1,n+bpp do
- local p = j - len
- local b = t[p]
- if b > 0 then
- t[j] = (t[j] + b) % 256
- end
- end
- for j=n+bpp+1,n+m do
- local p = j - len
- local a = t[j-bpp]
- local b = t[p]
- local c = t[p-bpp]
- local pa = b - c
- local pb = a - c
- local pc = pa + pb
- if pa < 0 then pa = - pa end
- if pb < 0 then pb = - pb end
- if pc < 0 then pc = - pc end
- t[j] = (t[j] + ((pa <= pb and pa <= pc and a) or (pb <= pc and b) or c)) % 256
- end
- end
- n = n + len
- end
- return t
- end
-
- local filtermask_l = function (content,xsize,ysize,colordepth,colorspace,hasfilter)
- local mask = { }
- local bytes = colordepth == 16 and 2 or 1
- local bpp = colorspace == "DeviceRGB" and 3 or 1
- local length = #content
- local size = ysize * xsize * ((bpp+1)*bytes + (hasfilter and 1 or 0))
- local n = 1
- local l = 1
- if bytes == 2 then
- if bpp == 1 then
- for i=1,ysize do
- if hasfilter then
- content[n] = "" ; n = n + 1
- end
- for j=1,xsize do
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- mask[l] = chars[content[n]] ; l = l + 1
- content[n] = "" ; n = n + 1
- mask[l] = chars[content[n]] ; l = l + 1
- content[n] = "" ; n = n + 1
- end
- end
- elseif bpp == 3 then
- for i=1,ysize do
- if hasfilter then
- content[n] = "" ; n = n + 1
- end
- for j=1,xsize do
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- mask[l] = chars[content[n]] ; l = l + 1
- content[n] = "" ; n = n + 1
- mask[l] = chars[content[n]] ; l = l + 1
- content[n] = "" ; n = n + 1
- end
- end
- else
- return "", ""
- end
- else
- if bpp == 1 then
- for i=1,ysize do
- if hasfilter then
- content[n] = "" ; n = n + 1
- end
- for j=1,xsize do
- content[n] = chars[content[n]] ; n = n + 1
- mask[l] = chars[content[n]] ; l = l + 1
- content[n] = "" ; n = n + 1
- end
- end
- elseif bpp == 3 then
- for i=1,ysize do
- if hasfilter then
- content[n] = "" ; n = n + 1
- end
- for j=1,xsize do
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- content[n] = chars[content[n]] ; n = n + 1
- mask[l] = chars[content[n]] ; l = l + 1
- content[n] = "" ; n = n + 1
- end
- end
- else
- return "", ""
- end
- end
- return concat(content), concat(mask)
- end
-
- local decodemask_l = function(content,xsize,ysize,colordepth,colorspace)
- local bytes = colordepth == 16 and 2 or 1
- local bpp = colorspace == "DeviceRGB" and 3 or 1
- local slice = bytes*(bpp+1)
- local length = #content
- local size = ysize * xsize * ((bpp+1)*bytes + 1) -- assume filter
- content = openstring(content)
- content = readbytetable(content,length)
- setmetatableindex(content,zero)
- applyfilter(content,xsize,ysize,slice)
- content, mask = filtermask(content,xsize,ysize,colordepth,colorspace,true)
- return content, mask
- end
-
- local filtermask_c = function(content,xsize,ysize,colordepth,colorspace)
- local bytes = colordepth == 16 and 2 or 1
- local bpp = colorspace == "DeviceRGB" and 3 or 1
- return pngsplitmask(content,xsize,ysize,bpp,bytes)
- end
-
- local decodemask_c = function(content,xsize,ysize,colordepth,colorspace)
- local mask = true
- local filter = false
- local bytes = colordepth == 16 and 2 or 1
- local bpp = colorspace == "DeviceRGB" and 3 or 1
- local slice = bytes * (bpp + 1) -- always a mask
- content = pngapplyfilter(content,xsize,ysize,slice)
- return pngsplitmask(content,xsize,ysize,bpp,bytes,mask,filter)
- end
-
- local function decodestrip_l(s,nx,ny,slice)
- local input = readbytetable(s,ny*(nx*slice+1))
- setmetatableindex(input,zero)
- applyfilter(input,nx,ny,slice)
- return input, true
- end
-
- local function decodestrip_c(s,nx,ny,slice)
- local input = readstring(s,ny*(nx*slice+1))
- input = pngapplyfilter(input,nx,ny,slice)
- return input, false
- end
-
- local xstart = { 0, 4, 0, 2, 0, 1, 0 }
- local ystart = { 0, 0, 4, 0, 2, 0, 1 }
- local xstep = { 8, 8, 4, 4, 2, 2, 1 }
- local ystep = { 8, 8, 8, 4, 4, 2, 2 }
-
- local xblock = { 8, 4, 4, 2, 2, 1, 1 }
- local yblock = { 8, 8, 4, 4, 2, 2, 1 }
-
- local function transpose_l(xsize,ysize,slice,pass,input,output,filter)
- local xstart = xstart[pass]
- local xstep = xstep[pass]
- local ystart = ystart[pass]
- local ystep = ystep[pass]
- local nx = idiv(xsize + xstep - xstart - 1,xstep)
- local ny = idiv(ysize + ystep - ystart - 1,ystep)
- local offset = filter and 1 or 0
- local xstep = xstep * slice
- local xstart = xstart * slice
- local xsize = xsize * slice
- local target = ystart * xsize + xstart + 1
- local ystep = ystep * xsize
- local start = 1
- local plus = nx * xstep
- local step = plus - xstep
- if not output then
- output = newoutput(xsize*(parts or slice)*ysize)
- end
- if slice == 1 then
- for j=0,ny-1 do
- start = start + offset
- local target = target + j * ystep
- for target=target,target+step,xstep do
- output[target] = input[start]
- start = start + slice
- end
- end
- elseif slice == 2 then
- for j=0,ny-1 do
- start = start + offset
- local target = target + j * ystep
- for target=target,target+step,xstep do
- output[target] = input[start]
- output[target+1] = input[start+1]
- start = start + slice
- end
- end
- elseif slice == 3 then
- for j=0,ny-1 do
- start = start + offset
- local target = target + j * ystep
- for target=target,target+step,xstep do
- output[target] = input[start]
- output[target+1] = input[start+1]
- output[target+2] = input[start+2]
- start = start + slice
- end
- end
- elseif slice == 4 then
- for j=0,ny-1 do
- start = start + offset
- local target = target + j * ystep
- for target=target,target+step,xstep do
- output[target] = input[start]
- output[target+1] = input[start+1]
- output[target+2] = input[start+2]
- output[target+3] = input[start+3]
- start = start + slice
- end
- end
- else
- local delta = slice - 1
- for j=0,ny-1 do
- start = start + offset
- local target = target + j * ystep
- for target=target,target+step,xstep do
- move(input,start,start+delta,target,output)
- start = start + slice
- end
- end
- end
- return output;
- end
-
- local transpose_c = pnginterlace
-
- -- print(band(rshift(v,4),0x03),extract(v,4,2))
- -- print(band(rshift(v,6),0x03),extract(v,6,2))
-
- local function expand_l(t,xsize,ysize,parts,run,factor,filter)
- local size = ysize * xsize + 1 -- a bit of overshoot, needs testing, probably a few bytes us ok
- local xline = filter and (run+1) or run
- local f = filter and 1 or 0
- local l = xline - 1
- local n = 1
- local o = newoutput(size)
- local k = 0
- if factor then
- if parts == 4 then
- for i=1,ysize do
- for j=n+f,n+l do
- local v = t[j]
- if v == 0 then
- k = k + 2
- else
- k = k + 1 ; o[k] = extract4(v,4) * 0x11
- k = k + 1 ; o[k] = extract4(v,0) * 0x11
- end
- end
- k = i * xsize
- n = n + xline
- end
- elseif parts == 2 then
- for i=1,ysize do
- for j=n+f,n+l do
- local v = t[j]
- if v == 0 then
- k = k + 4
- else
- k = k + 1 ; o[k] = extract2(v,6) * 0x55
- k = k + 1 ; o[k] = extract2(v,4) * 0x55
- k = k + 1 ; o[k] = extract2(v,2) * 0x55
- k = k + 1 ; o[k] = extract2(v,0) * 0x55
- end
- end
- k = i * xsize
- n = n + xline
- end
- else
- for i=1,ysize do
- for j=n+f,n+l do
- local v = t[j]
- if v == 0 then
- k = k + 8
- else
- k = k + 1 ; if band(v,0x80) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,7) * 0xFF
- k = k + 1 ; if band(v,0x40) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,6) * 0xFF
- k = k + 1 ; if band(v,0x20) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,5) * 0xFF
- k = k + 1 ; if band(v,0x10) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,4) * 0xFF
- k = k + 1 ; if band(v,0x08) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,3) * 0xFF
- k = k + 1 ; if band(v,0x04) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,2) * 0xFF
- k = k + 1 ; if band(v,0x02) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,1) * 0xFF
- k = k + 1 ; if band(v,0x01) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,0) * 0xFF
- end
- end
- k = i * xsize
- n = n + xline
- end
- end
- else
- if parts == 4 then
- for i=1,ysize do
- for j=n+f,n+l do
- local v = t[j]
- if v == 0 then
- k = k + 2
- else
- k = k + 1 ; o[k] = extract4(v,4)
- k = k + 1 ; o[k] = extract4(v,0)
- end
- end
- k = i * xsize
- n = n + xline
- end
- elseif parts == 2 then
- for i=1,ysize do
- for j=n+f,n+l do
- local v = t[j]
- if v == 0 then
- k = k + 4
- else
- k = k + 1 ; o[k] = extract2(v,6)
- k = k + 1 ; o[k] = extract2(v,4)
- k = k + 1 ; o[k] = extract2(v,2)
- k = k + 1 ; o[k] = extract2(v,0)
- end
- end
- k = i * xsize
- n = n + xline
- end
- else
- for i=1,ysize do
- for j=n+f,n+l do
- local v = t[j]
- if v == 0 then
- k = k + 8
- else
- k = k + 1 ; if band(v,0x80) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,7)
- k = k + 1 ; if band(v,0x40) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,6)
- k = k + 1 ; if band(v,0x20) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,5)
- k = k + 1 ; if band(v,0x10) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,4)
- k = k + 1 ; if band(v,0x08) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,3)
- k = k + 1 ; if band(v,0x04) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,2)
- k = k + 1 ; if band(v,0x02) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,1)
- k = k + 1 ; if band(v,0x01) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,0)
- end
- end
- k = i * xsize
- n = n + xline
- end
- end
- end
- for i=size,xsize * ysize +1,-1 do
- o[i] = nil
- end
- return o, false
- end
-
- local expand_c = pngexpand
-
- local function analyze(colordepth,colorspace,palette,mask)
- -- return bytes, parts, factor
- if palette then
- if colordepth == 16 then
- return 2, false, false
- elseif colordepth == 8 then
- return 1, false, false
- elseif colordepth == 4 then
- return 1, 4, false
- elseif colordepth == 2 then
- return 1, 2, false
- elseif colordepth == 1 then
- return 1, 1, false
- end
- elseif colorspace == "DeviceGray" then
- if colordepth == 16 then
- return mask and 4 or 2, false, false
- elseif colordepth == 8 then
- return mask and 2 or 1, false, false
- elseif colordepth == 4 then
- return 1, 4, true
- elseif colordepth == 2 then
- return 1, 2, true
- elseif colordepth == 1 then
- return 1, 1, true
- end
- else
- if colordepth == 16 then
- return mask and 8 or 6, false, false
- elseif colordepth == 8 then
- return mask and 4 or 3, false, false
- elseif colordepth == 4 then
- return 3, 4, true
- elseif colordepth == 2 then
- return 3, 2, true
- elseif colordepth == 1 then
- return 3, 1, true
- end
- end
- return false, false, false
- end
-
- -- 1 6 4 6 2 6 4 6
- -- 7 7 7 7 7 7 7 7
- -- 5 6 5 6 5 6 5 6
- -- 7 7 7 7 7 7 7 7
- -- 3 6 4 6 3 6 4 6
- -- 7 7 7 7 7 7 7 7
- -- 5 6 5 6 5 6 5 6
- -- 7 7 7 7 7 7 7 7
-
- local function deinterlace(content,xsize,ysize,colordepth,colorspace,palette,mask)
- local slice, parts, factor = analyze(colordepth,colorspace,palette,mask)
- if slice then
- content = openstring(zlibdecompress(content))
- local filter = false
- local output = false
- for pass=1,7 do
- local xstart = xstart[pass]
- local xstep = xstep[pass]
- local ystart = ystart[pass]
- local ystep = ystep[pass]
- local nx = idiv(xsize + xstep - xstart - 1,xstep)
- local ny = idiv(ysize + ystep - ystart - 1,ystep)
- if nx > 0 and ny > 0 then
- local input, filter
- if parts then
- local nxx = ceil(nx*parts/8)
- input, filter = decodestrip(content,nxx,ny,slice)
- input, filter = expand(input,nx,ny,parts,nxx,factor,filter)
- else
- input, filter = decodestrip(content,nx,ny,slice)
- end
- output = transpose(xsize,ysize,slice,pass,input,output,filter)
- end
- -- if pass == 3 then
- -- break -- still looks ok, could be nice for a preroll
- -- end
- end
- return output, parts and 8 or false
- end
- end
-
- -- 1 (palette used), 2 (color used), and 4 (alpha channel used)
-
- -- paeth:
- --
- -- p = a + b - c
- -- pa = abs(p - a) => a + b - c - a => b - c
- -- pb = abs(p - b) => a + b - c - b => a - c
- -- pc = abs(p - c) => a + b - c - c => a + b - c - c => a - c + b - c => pa + pb
-
- local function full(t,k) local v = "\xFF" t[k] = v return v end
-
- local function expandvector(transparent)
- local s = openstring(transparent)
- local n = #transparent
- local r = { }
- for i=0,n-1 do
- r[i] = readstring(s,1) -- readchar
- end
- setmetatableindex(r,full)
- return r
- end
-
- local function createmask_l(content,palette,transparent,xsize,ysize,colordepth,colorspace)
- if palette then
- local r = expandvector(transparent)
- local size = xsize*ysize
- local len = ceil(xsize*colordepth/8) + 1
- local o = newoutput(xsize*ysize)
- local u = setmetatableindex(zero)
- content = zlibdecompress(content)
- content = openstring(content)
- for i=0,ysize-1 do
- local t = readbytetable(content,len)
- local k = i * xsize
- local filter = t[1]
- if filter == 0 then
- elseif filter == 1 then
- for j=3,len do
- t[j] = (t[j] + t[j-1]) % 256
- end
- elseif filter == 2 then
- for j=2,len do
- t[j] = (t[j] + u[j]) % 256
- end
- elseif filter == 3 then
- local j = 2
- t[j] = (t[j] + idiv(u[j],2)) % 256
- for j=3,len do
- t[j] = (t[j] + idiv(t[j-1] + u[j],2)) % 256
- end
- elseif filter == 4 then
- local j = 2
- local p = j - len
- local b = t[p]
- if b < 0 then
- b = - b
- end
- if b > 0 then
- t[j] = (t[j] + b) % 256
- end
- for j=3,len do
- local p = j - len
- local a = t[j-1]
- local b = t[p]
- local c = t[p-1]
- local pa = b - c
- local pb = a - c
- local pc = pa + pb
- if pa < 0 then pa = - pa end
- if pb < 0 then pb = - pb end
- if pc < 0 then pc = - pc end
- t[j] = (t[j] + ((pa <= pb and pa <= pc and a) or (pb <= pc and b) or c)) % 256
- end
- end
- if colordepth == 8 then
- for j=2,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[v]
- end
- elseif colordepth == 4 then
- for j=2,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[extract4(v,4)]
- k = k + 1 ; o[k] = r[extract4(v,0)]
- end
- elseif colordepth == 2 then
- for j=2,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[extract2(v,6)]
- k = k + 1 ; o[k] = r[extract2(v,4)]
- k = k + 1 ; o[k] = r[extract2(v,2)]
- k = k + 1 ; o[k] = r[extract2(v,0)]
- end
- else
- for j=2,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[extract1(v,7)]
- k = k + 1 ; o[k] = r[extract1(v,6)]
- k = k + 1 ; o[k] = r[extract1(v,5)]
- k = k + 1 ; o[k] = r[extract1(v,4)]
- k = k + 1 ; o[k] = r[extract1(v,3)]
- k = k + 1 ; o[k] = r[extract1(v,2)]
- k = k + 1 ; o[k] = r[extract1(v,1)]
- k = k + 1 ; o[k] = r[extract1(v,0)]
- end
- end
- u = t
- end
- return concat(o,"",1,size)
- end
- end
-
- local function createmask_c(content,palette,transparent,xsize,ysize,colordepth,colorspace)
- if palette then
- local r = expandvector(transparent)
- local size = xsize*ysize
- local len = ceil(xsize*colordepth/8)
- local o = newoutput(size)
- content = zlibdecompress(content)
- content = pngapplyfilter(content,len,ysize,1) -- nostrip (saves copy)
- content = openstring(content)
- for i=0,ysize-1 do
- local t = readbytetable(content,len)
- local k = i * xsize
- if colordepth == 8 then
- for j=1,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[v]
- end
- elseif colordepth == 4 then
- for j=1,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[extract4(v,4)]
- k = k + 1 ; o[k] = r[extract4(v,0)]
- end
- elseif colordepth == 2 then
- for j=1,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[extract2(v,6)]
- k = k + 1 ; o[k] = r[extract2(v,4)]
- k = k + 1 ; o[k] = r[extract2(v,2)]
- k = k + 1 ; o[k] = r[extract2(v,0)]
- end
- else
- for j=1,len do
- local v = t[j]
- k = k + 1 ; o[k] = r[extract1(v,7)]
- k = k + 1 ; o[k] = r[extract1(v,6)]
- k = k + 1 ; o[k] = r[extract1(v,5)]
- k = k + 1 ; o[k] = r[extract1(v,4)]
- k = k + 1 ; o[k] = r[extract1(v,3)]
- k = k + 1 ; o[k] = r[extract1(v,2)]
- k = k + 1 ; o[k] = r[extract1(v,1)]
- k = k + 1 ; o[k] = r[extract1(v,0)]
- end
- end
- end
- return concat(o,"",1,size)
- end
- end
-
- local function tocmyk_l(content,colordepth)
- local l = #content
- local t = { }
- local n = 0
- if colordepth == 8 then
- for i=1,l,3 do
- local r, g, b = byte(content,i,i+2)
- n = n + 1 ; t[n] = char(255-r,255-g,255-b,0) -- a tad faster than chars[...]
- end
- else
- for i=1,l,6 do
- local r1, r2, g1, g2, b1, b2 = byte(content,i,i+5)
- n = n + 1 ; t[n] = char(255-r1,255-r2,255-g1,255-g2,255-b1,255-b2,0,0)
- end
- end
- return concat(t)
- end
-
- local tocmyk_c = pngtocmyk or tocmyk_l
-
- local function converttocmyk(content,colorspace,colordepth)
- if colorspace == "DeviceRGB" and colordepth == 8 or colordepth == 16 then
- local done = tocmyk(content,colordepth)
- if done then
- content = done
- colorspace = "DeviceCMYK"
- end
- end
- return content, colorspace
- end
-
- local function switch(v)
- if v then
- filtermask = filtermask_l
- decodemask = decodemask_l
- decodestrip = decodestrip_l
- transpose = transpose_l
- expand = expand_l
- createmask = createmask_l
- tocmyk = tocmyk_l
- else
- filtermask = filtermask_c
- decodemask = decodemask_c
- decodestrip = decodestrip_c
- transpose = transpose_c
- expand = expand_c
- createmask = createmask_c
- tocmyk = tocmyk_c
- end
- end
-
- if pngapplyfilter then
- switch(false)
- directives.register("graphics.png.purelua",switch)
- else
- switch(true)
- end
-
- local alwaysdecode = false -- trucky with palettes
- local compresslevel = 3
-
- directives.register("graphics.png.recompress", function(v)
- alwaysdecode = v
- end)
-
- directives.register("graphics.png.compresslevel", function(v)
- v = tonumber(v)
- if compresslevel >= 0 or compresslevel <= 9 then
- compresslevel = v
- end
- end)
-
- function injectors.png(specification,method) -- todo: method in specification
- if specification.error then
- return
- end
- local filename = specification.filename
- if not filename then
- return
- end
- local colorspace = specification.colorspace
- if not colorspace then
- return
- end
- local interlace = specification.interlace or 0
- if interlace == 1 then
- interlace = true
- elseif interlace == 0 then
- interlace = false
- else
- report_png("unknown interlacing %i",interlace)
- return
- end
- local tables = specification.tables
- if not tables then
- return
- end
- local idat = tables.idat
- if not idat then
- return
- end
- local pngfile = newcontent(filename,method)
- if not pngfile then
- return
- end
- local content = idat(pngfile,true)
- tables.idat = false
- --
- -- if tables.gama then
- -- report_png("ignoring gamma correction")
- -- end
- --
- local xsize = specification.xsize
- local ysize = specification.ysize
- local colordepth = specification.colordepth or 8
- local mask = false
- local transparent = false
- local palette = false
- local enforcecmyk = specification.enforcecmyk
- local colors = 1
- if colorspace == 0 then -- gray | image b
- colorspace = "DeviceGray"
- transparent = true
- elseif colorspace == 2 then -- rgb | image c
- colorspace = "DeviceRGB"
- colors = 3
- transparent = true
- elseif colorspace == 3 then -- palette | image c+i
- colorspace = "DeviceRGB"
- palette = true
- transparent = true
- elseif colorspace == 4 then -- gray | alpha | image b
- colorspace = "DeviceGray"
- mask = true
- elseif colorspace == 6 then -- rgb | alpha | image c
- colorspace = "DeviceRGB"
- colors = 3
- mask = true
- else
- report_png("unknown colorspace %i",colorspace)
- return
- end
- --
- if transparent then
- local trns = tables.trns
- if trns then
- transparent = trns(pngfile,true)
- if transparent == "" then
- transparent = false
- end
- tables.trns = false
- else
- transparent = false
- end
- end
- --
- local decode = alwaysdecode -- tricky, might go away
- local filter = pdfconstant("FlateDecode")
- local major = pdfmajorversion()
- local minor = pdfminorversion()
- if major > 1 then
- -- we're okay
- elseif minor < 5 and colordepth == 16 then
- report_png("16 bit colordepth not supported in pdf < 1.5")
- return
- elseif minor < 4 and (mask or transparent) then
- report_png("alpha channels not supported in pdf < 1.4")
- return
- elseif minor < 2 then
- report_png("you'd better use a version > 1.2")
- return
- -- decode = true
- end
- --
- -- todo: compresslevel (or delegate)
- --
- if palette then
- local plte = tables.plte
- if plte then
- palette = plte(pngfile,true)
- if palette == "" then
- palette = false
- end
- tables.plte = false
- else
- palette = false
- end
- end
- --
- if interlace then
- local r, p = deinterlace(content,xsize,ysize,colordepth,colorspace,palette,mask)
- if not r then
- return
- end
- if p then
- colordepth = p
- end
- if mask then
- if not (colordepth == 8 or colordepth == 16) then
- report_png("mask can't be split from the image")
- return
- end -- get rid of bpp:
- content, mask = filtermask(r,xsize,ysize,colordepth,colorspace,false)
- else
- content = convert(r) -- can be in deinterlace if needed
- end
- if enforcecmyk then
- content, colorspace = converttocmyk(content,colorspace,colordepth)
- end
- if compresslevel > 0 then
- content = zlibcompress(content,compresslevel)
- else
- filter = nil
- end
- decode = true
- elseif mask then
- if not (colordepth == 8 or colordepth == 16) then
- report_png("mask can't be split from the image")
- return
- end
- content = zlibdecompress(content)
- content, mask = decodemask(content,xsize,ysize,colordepth,colorspace)
- if enforcecmyk and not palette then
- content, colorspace = converttocmyk(content,colorspace,colordepth)
- end
- if compresslevel > 0 then
- content = zlibcompress(content,compresslevel)
- else
- filter = nil
- end
- decode = true -- we don't copy the filter byte
- elseif transparent then
- -- in test suite
- -- how about decode/recompress here
- if palette then
- mask = createmask(content,palette,transparent,xsize,ysize,colordepth,colorspace)
- else
- pallette = false
- end
- elseif decode or (enforcecmyk and not palette) then
- -- this one needs checking
- local bytes = analyze(colordepth,colorspace)
- if bytes then
- content = zlibdecompress(content)
- content = decodestrip(openstring(content),xsize,ysize,bytes)
- if enforcecmyk and not palette then
- content, colorspace = converttocmyk(content,colorspace,colordepth)
- end
- if compresslevel > 0 then
- content = zlibcompress(content,compresslevel)
- else
- filter = nil
- end
- else
- return
- end
- decode = true -- due to enforcecmyk
- else
- -- print("PASS ON")
- end
- if palette then
- local colorspace = "DeviceRGB"
- local nofbytes = 3
- if enforcecmyk then
- palette = converttocmyk(palette,colorspace,8)
- colorspace = "DeviceCMYK"
- nofbytes = 4
- end
- palette = pdfarray {
- pdfconstant("Indexed"),
- pdfconstant(colorspace),
- idiv(#palette,nofbytes),
- pdfreference(pdfflushstreamobject(palette)),
- }
- end
- pngfile:close()
- local xobject = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Image"),
- -- BBox = pdfarray { 0, 0, xsize, ysize },
- Width = xsize,
- Height = ysize,
- BitsPerComponent = colordepth,
- Filter = filter,
- ColorSpace = palette or pdfconstant(colorspace),
- Length = #content,
- } + specification.attr
- if mask then
- local d = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Image"),
- Width = xsize,
- Height = ysize,
- BitsPerComponent = palette and 8 or colordepth,
- ColorSpace = pdfconstant("DeviceGray"),
- }
- xobject.SMask = pdfreference(pdfflushstreamobject(mask,d()))
- end
- if not decode then
- xobject.DecodeParms = pdfdictionary {
- Colors = colors,
- Columns = xsize,
- BitsPerComponent = colordepth,
- Predictor = 15,
- }
- end
- if trace then
- report_png("%s: width %i, height %i, colordepth %i, size %i, palette %l, mask %l, transparent %l, decode %l",filename,xsize,ysize,colordepth,#content,palette,mask,transparent,decode)
- end
- if specification.colorref then
- xobject.ColorSpace = pdfreference(specification.colorref)
- end
- local width = specification.width or xsize * 65536
- local height = specification.height or ysize * 65536
- return createimage {
- bbox = { 0, 0, width/xsize, height/ysize }, -- mandate
- transform = specification.transform,
- nolength = true,
- nobbox = true,
- notype = true,
- stream = content,
- attr = xobject(),
- }
- end
-
-end
-
-do
-
- local function pack(specification,what)
- local t = { }
- local n = 0
- local s = specification.colorspace
- local d = specification.data
- local x = specification.xsize
- local y = specification.ysize
- if what == "mask" then
- d = specification.mask
- s = 1
- elseif what == "indexed" then
- s = 1
- elseif what == "index" then
- d = specification.index
- s = - s
- end
- if s > 0 then
- if s == 1 then
- for i=1,y do
- local r = d[i]
- for j=1,x do
- n = n + 1 ; t[n] = chars[r[j]]
- end
- end
- elseif s == 2 then
- for i=1,y do
- local r = d[i]
- for j=1,x do
- local c = r[j]
- n = n + 1 ; t[n] = chars[c[1]]
- n = n + 1 ; t[n] = chars[c[2]]
- n = n + 1 ; t[n] = chars[c[3]]
- -- n = n + 1 ; t[n] = char(c[1],c[2],c[3]) -- test this
- end
- end
- elseif s == 3 then
- for i=1,y do
- local r = d[i]
- for j=1,x do
- local c = r[j]
- n = n + 1 ; t[n] = chars[c[1]]
- n = n + 1 ; t[n] = chars[c[2]]
- n = n + 1 ; t[n] = chars[c[3]]
- n = n + 1 ; t[n] = chars[c[4]]
- -- n = n + 1 ; t[n] = char(c[1],c[2],c[3],c[4]) -- test this
- end
- end
- end
- return concat(t)
- else
- local z = d[0] and 0 or 1
- if s == -1 then
- local f = formatters["%02X"]
- for i=z,#d do
- n = n + 1 ; t[n] = f(d[i])
- end
- elseif s == -2 then
- local f = formatters["%02X%02X%02X"]
- for i=z,#d do
- local c = d[i]
- n = n + 1 ; t[n] = f(c[1],c[2],c[3])
- end
- elseif s == -3 then
- local f = formatters["%02X%02X%02X%02X"]
- for i=z,#d do
- local c = d[i]
- n = n + 1 ; t[n] = f(c[1],c[2],c[3],c[4])
- end
- end
- return "<" .. concat(t," ") .. ">"
- end
- return ""
- end
-
- function injectors.bitmap(specification)
- local data = specification.data
- if not data then
- return
- end
- local xsize = specification.xsize or 0
- local ysize = specification.ysize or 0
- if xsize == 0 or ysize == 0 then
- return
- end
- local colorspace = specification.colorspace or 1
- if colorspace == 1 then
- colorspace = "DeviceGray"
- elseif colorspace == 2 then
- colorspace = "DeviceRGB"
- elseif colorspace == 3 then
- colorspace = "DeviceCMYK"
- end
- local colordepth = (specification.colordepth or 2) == 16 or 8
- local index = specification.index
- local content = pack(specification,index and "indexed" or "data")
- local mask = specification.mask
- local colorspace = pdfconstant(colorspace)
- if index then
- colorspace = pdfarray {
- pdfconstant("Indexed"),
- colorspace,
- #index + (index[0] and 0 or -1), -- upper index
- pdfverbose(pack(specification,"index"))
- }
- end
- local xobject = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Image"),
- BBox = pdfarray { 0, 0, xsize, ysize },
- Width = xsize,
- Height = ysize,
- BitsPerComponent = colordepth,
- ColorSpace = colorspace,
- Length = #content, -- specification.length
- }
- if mask then
- local d = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Image"),
- Width = xsize,
- Height = ysize,
- BitsPerComponent = colordepth,
- ColorSpace = pdfconstant("DeviceGray"),
- }
- xobject.SMask = pdfreference(pdfflushstreamobject(pack(specification,"mask"),d()))
- end
- return createimage {
- bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
- -- nolength = true,
- nobbox = true,
- notype = true,
- stream = content,
- attr = xobject(),
- }
- end
-
- backends.pdf.codeinjections.bitmap = injectors.bitmap
-
-end
-
--- local function validcompression(data)
--- local d = utilities.streams.openstring(data)
--- local b1 = utilities.streams.readbyte(d)
--- local b2 = utilities.streams.readbyte(d)
--- print(b1,b2)
--- if (b1 * 256 + b2) % 31 ~= 0 then
--- return false, "no zlib compressed file"
--- end
--- local method = band(b1,15)
--- if method ~= 8 then
--- return false, "method 8 expected"
--- end
--- local detail = band(rshift(b1,4),15)
--- if detail > 7 then
--- return false, "window 32 expected"
--- end
--- local preset = band(rshift(b2,5),1)
--- if preset ~= 0 then
--- return false, "unexpected preset dictionary"
--- end
--- return true
--- end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-ini.lua
index 2163e874852..1098ef8fa38 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-ini.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['lpdf-ini'] = {
version = 1.001,
+ optimize = true,
comment = "companion to lpdf-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -7,6 +8,9 @@ if not modules then modules = { } end modules ['lpdf-ini'] = {
}
-- beware of "too many locals" here
+--
+-- The lua files are still hybrid ones but we keep that as a reference for the
+-- lmt variants that started out as copies.
local setmetatable, getmetatable, type, next, tostring, tonumber, rawset = setmetatable, getmetatable, type, next, tostring, tonumber, rawset
local char, byte, format, gsub, concat, match, sub, gmatch = string.char, string.byte, string.format, string.gsub, table.concat, string.match, string.sub, string.gmatch
@@ -25,7 +29,6 @@ local report_finalizing = logs.reporter("backend","finalizing")
local report_blocked = logs.reporter("backend","blocked")
local implement = interfaces.implement
-local two_strings = interfaces.strings[2]
local context = context
@@ -295,7 +298,9 @@ do
if v < 0x10000 then
v = format("%04x",v)
else
- v = format("%04x%04x",rshift(v,10),v%1024+0xDC00)
+ v = v - 0x10000
+ v = format("%04x%04x",rshift(v,10)+0xD800,v%1024+0xDC00)
+ -- v = format("%04x%04x",rshift(v-0x10000,10)+0xD800,v%1024+0xDC00)
end
t[k] = v
return v
@@ -316,7 +321,7 @@ do
local pattern = C(4) / function(s) -- needs checking !
local now = tonumber(s,16)
if more > 0 then
- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
more = 0
return utfchar(now)
elseif now >= 0xD800 and now <= 0xDBFF then
@@ -445,10 +450,14 @@ do
local f_key_null = formatters["/%s null"]
local f_key_value = formatters["/%s %s"]
- local f_key_dictionary = formatters["/%s << % t >>"]
- local f_dictionary = formatters["<< % t >>"]
- local f_key_array = formatters["/%s [ % t ]"]
- local f_array = formatters["[ % t ]"]
+ -- local f_key_dictionary = formatters["/%s << % t >>"]
+ -- local f_dictionary = formatters["<< % t >>"]
+ local f_key_dictionary = formatters["/%s << %s >>"]
+ local f_dictionary = formatters["<< %s >>"]
+ -- local f_key_array = formatters["/%s [ % t ]"]
+ -- local f_array = formatters["[ % t ]"]
+ local f_key_array = formatters["/%s [ %s ]"]
+ local f_array = formatters["[ %s ]"]
local f_key_number = formatters["/%s %N"] -- always with max 9 digits and integer is possible
local f_tonumber = formatters["%N"] -- always with max 9 digits and integer is possible
@@ -501,8 +510,9 @@ do
if e then
r[n+1] = e
end
+ r = concat(r," ")
if contentonly then
- return concat(r," ")
+ return r
elseif key then
return f_key_dictionary(key,r)
else
@@ -550,8 +560,9 @@ do
if e then
r[tn+1] = e
end
+ r = concat(r," ")
if contentonly then
- return concat(r, " ")
+ return r
elseif key then
return f_key_array(key,r)
else
@@ -1553,16 +1564,16 @@ end
-- interface
implement { name = "lpdf_collectedresources", actions = { lpdf.collectedresources, context } }
-implement { name = "lpdf_addtocatalog", arguments = two_strings, actions = lpdf.addtocatalog }
-implement { name = "lpdf_addtoinfo", arguments = two_strings, actions = function(a,b,c) lpdf.addtoinfo(a,b,c) end } -- gets adapted
-implement { name = "lpdf_addtonames", arguments = two_strings, actions = lpdf.addtonames }
-implement { name = "lpdf_addtopageattributes", arguments = two_strings, actions = lpdf.addtopageattributes }
-implement { name = "lpdf_addtopagesattributes", arguments = two_strings, actions = lpdf.addtopagesattributes }
-implement { name = "lpdf_addtopageresources", arguments = two_strings, actions = lpdf.addtopageresources }
-implement { name = "lpdf_adddocumentextgstate", arguments = two_strings, actions = function(a,b) lpdf.adddocumentextgstate (a,pdfverbose(b)) end }
-implement { name = "lpdf_adddocumentcolorspace", arguments = two_strings, actions = function(a,b) lpdf.adddocumentcolorspace(a,pdfverbose(b)) end }
-implement { name = "lpdf_adddocumentpattern", arguments = two_strings, actions = function(a,b) lpdf.adddocumentpattern (a,pdfverbose(b)) end }
-implement { name = "lpdf_adddocumentshade", arguments = two_strings, actions = function(a,b) lpdf.adddocumentshade (a,pdfverbose(b)) end }
+implement { name = "lpdf_addtocatalog", arguments = "2 strings", actions = lpdf.addtocatalog }
+implement { name = "lpdf_addtoinfo", arguments = "2 strings", actions = function(a,b,c) lpdf.addtoinfo(a,b,c) end } -- gets adapted
+implement { name = "lpdf_addtonames", arguments = "2 strings", actions = lpdf.addtonames }
+implement { name = "lpdf_addtopageattributes", arguments = "2 strings", actions = lpdf.addtopageattributes }
+implement { name = "lpdf_addtopagesattributes", arguments = "2 strings", actions = lpdf.addtopagesattributes }
+implement { name = "lpdf_addtopageresources", arguments = "2 strings", actions = lpdf.addtopageresources }
+implement { name = "lpdf_adddocumentextgstate", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentextgstate (a,pdfverbose(b)) end }
+implement { name = "lpdf_adddocumentcolorspace", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentcolorspace(a,pdfverbose(b)) end }
+implement { name = "lpdf_adddocumentpattern", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentpattern (a,pdfverbose(b)) end }
+implement { name = "lpdf_adddocumentshade", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentshade (a,pdfverbose(b)) end }
-- more helpers: copy from lepd to lpdf
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-lmt.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-lmt.lua
deleted file mode 100644
index 3966143b4cd..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-lmt.lua
+++ /dev/null
@@ -1,2765 +0,0 @@
-if not modules then modules = { } end modules ['lpdf-lmt'] = {
- version = 1.001,
- comment = "companion to lpdf-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- The code below was originally in back-lpd.lua but it makes more sense in
--- this namespace. I will rename variables.
---
--- There is no way that a lua based backend can compete with the original one
--- for relative simple text runs. And we're talking seconds here on say 500
--- pages with paragraphs alternativng between three fonts and colors. But such
--- documents are rare so in practice we are quite okay, especially because in
--- ConTeXt we can gain quite a bit elsewhere. So, when we loose 30% on such
--- simple documents, we break even on for instance the manual, and gain 30% on
--- Thomas's turture test (also for other reasons). But .. who knows what magic
--- I can cook up in due time.
-
--- If you consider this complex, watch:
---
--- https://www.youtube.com/watch?v=6H-cAzfB2qo
---
--- or in distractionmode:
---
--- https://www.youtube.com/watch?v=TYuTE_1jvvE
--- https://www.youtube.com/watch?v=nnicGKX3lvM
---
--- For the moment we have to support the built in backend as well as the alternative. So
--- the next interface is suboptimal and will change at some time. At that moment I will
--- also optimize and extend.
-
-local type, next, unpack, tonumber = type, next, unpack, tonumber
-local char, rep, find = string.char, string.rep, string.find
-local formatters, splitupstring = string.formatters, string.splitup
-local band, extract = bit32.band, bit32.extract
-local concat, sortedhash = table.concat, table.sortedhash
-local setmetatableindex = table.setmetatableindex
-local loaddata = io.loaddata
-
-local bpfactor = number.dimenfactors.bp
-
-local md5HEX = md5.HEX
-local osuuid = os.uuid
-local zlibcompress = (xzip or zlib).compress
-
-local nuts = nodes.nuts
-local tonut = nodes.tonut
-
-local getdata = nuts.getdata
-local getsubtype = nuts.getsubtype
-local getwhd = nuts.getwhd
-local flushlist = nuts.flush_list
-
-local pdfincludeimage = lpdf.includeimage
-local pdfgetfontname = lpdf.getfontname
-local pdfgetfontobjnumber = lpdf.getfontobjnumber
-
-local pdfreserveobject = lpdf.reserveobject
-local pdfpagereference = lpdf.pagereference
-local pdfflushobject = lpdf.flushobject
-local pdfreference = lpdf.reference
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfconstant = lpdf.constant
-local pdfflushstreamobject = lpdf.flushstreamobject
-local pdfliteral = lpdf.literal -- not to be confused with a whatsit!
-
-local pdf_pages = pdfconstant("Pages")
-local pdf_page = pdfconstant("Page")
-local pdf_xobject = pdfconstant("XObject")
-local pdf_form = pdfconstant("Form")
-
-local fonthashes = fonts.hashes
-local characters = fonthashes.characters
-local descriptions = fonthashes.descriptions
-local parameters = fonthashes.parameters
-local properties = fonthashes.properties
-
-local report = logs.reporter("backend")
-
--- used variables
-
-local pdf_h, pdf_v
-local need_tm, need_tf, cur_tmrx, cur_factor, cur_f, cur_e
-local need_width, need_mode, done_width, done_mode
-local mode
-local f_pdf_cur, f_pdf, fs_cur, fs, f_cur
-local tj_delta, cw
-local usedfonts, usedxforms, usedximages, usedxgroups
-local getxformname, getximagename
-local boundingbox, shippingmode, objectnumber
-local tmrx, tmry, tmsx, tmsy, tmtx, tmty
-local cmrx, cmry, cmsx, cmsy, cmtx, cmty
-
-local function usefont(t,k) -- a bit redundant hash
- local v = pdfgetfontname(k)
- t[k] = v
- return v
-end
-
-local function reset_variables(specification)
- pdf_h, pdf_v = 0, 0
- cmrx, cmry = 1.0, 1.0
- cmsx, cmsy = 0.0, 0.0
- cmtx, cmty = 0.0, 0.0
- tmrx, tmry = 1.0, 1.0
- tmsx, tmsy = 0.0, 0.0
- tmtx, tmty = 0.0, 0.0
- need_tm = false
- need_tf = false
- need_width = 0
- need_mode = 0
- done_width = false
- done_mode = false
- mode = "page"
- shippingmode = specification.shippingmode
- objectnumber = specification.objectnumber
- cur_tmrx = 0.0
- f_cur = 0
- f_pdf_cur = 0 -- nullfont
- f_pdf = 0 -- nullfont
- fs_cur = 0
- fs = 0
- cur_factor = 0
- cur_f = false
- cur_e = false
- tj_delta = 0.0
- cw = 0.0
- usedfonts = setmetatableindex(usefont)
- usedxforms = { }
- usedximages = { }
- -- usedxgroups = { }
- boundingbox = specification.boundingbox
-end
-
--- buffer
-
-local buffer = lua.newtable(1024,0) -- { }
-local b = 0
-
-local function reset_buffer()
- b = 0
-end
-
--- fonts
-
-local fontcharacters
-local fontdescriptions
-local fontparameters
-local fontproperties
-local usedcharacters = setmetatableindex("table")
-local pdfcharacters
-
-local horizontalmode = true
------ widefontmode = true
-local scalefactor = 1
-local threshold = 655360
-local tjfactor = 100 / 65536
-
-lpdf.usedcharacters = usedcharacters
-
-local function updatefontstate(font)
- fontcharacters = characters[font]
- fontdescriptions = descriptions[font]
- fontparameters = parameters[font]
- fontproperties = properties[font]
- local size = fontparameters.size -- or bad news
- local designsize = fontparameters.designsize or size
- pdfcharacters = usedcharacters[font]
- horizontalmode = fontparameters.writingmode ~= "vertical"
- -- widefontmode = fontproperties.encodingbytes == 2
- scalefactor = (designsize/size) * tjfactor
- local fthreshold = fontproperties.threshold
- threshold = (fthreshold and (size * fthreshold / 100)) or 655360
-end
-
--- helpers
-
-local f_cm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"]
-local f_tm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N Tm"]
-
-local saved_text_pos_v = 0
-local saved_text_pos_h = 0
-
-local function begin_text()
- saved_text_pos_h = pdf_h
- saved_text_pos_v = pdf_v
- b = b + 1 ; buffer[b] = "BT"
- need_tf = true
- need_width = 0
- need_mode = 0
- mode = "text"
-end
-
-local function end_text()
- if done_width then
- b = b + 1 ; buffer[b] = "0 w"
- done_width = false
- end
- if done_mode then
- b = b + 1 ; buffer[b] = "0 Tr"
- done_mode = false
- end
- b = b + 1 ; buffer[b] = "ET"
- pdf_h = saved_text_pos_h
- pdf_v = saved_text_pos_v
- mode = "page"
-end
-
-local saved_chararray_pos_h
-local saved_chararray_pos_v
-
-local saved_b = 0
-
-local function begin_chararray()
- saved_chararray_pos_h = pdf_h
- saved_chararray_pos_v = pdf_v
- cw = horizontalmode and saved_chararray_pos_h or - saved_chararray_pos_v
- tj_delta = 0
- saved_b = b
- b = b + 1 ; buffer[b] = " ["
- mode = "chararray"
-end
-
-local function end_chararray()
- b = b + 1 ; buffer[b] = "] TJ"
- buffer[saved_b] = concat(buffer,"",saved_b,b)
- b = saved_b
- pdf_h = saved_chararray_pos_h
- pdf_v = saved_chararray_pos_v
- mode = "text"
-end
-
-local function begin_charmode()
- b = b + 1 ; buffer[b] = "<"
- mode = "char"
-end
-
-local function end_charmode()
- b = b + 1 ; buffer[b] = ">"
- mode = "chararray"
-end
-
-local function calc_pdfpos(h,v)
- -- mostly char
- if mode == "page" then
- cmtx = h - pdf_h
- cmty = v - pdf_v
- return h ~= pdf_h or v ~= pdf_v
- elseif mode == "text" then
- tmtx = h - saved_text_pos_h
- tmty = v - saved_text_pos_v
- return h ~= pdf_h or v ~= pdf_v
- elseif horizontalmode then
- tmty = v - saved_text_pos_v
- tj_delta = cw - h
- return tj_delta ~= 0 or v ~= pdf_v
- else
- tmtx = h - saved_text_pos_h
- tj_delta = cw + v
- return tj_delta ~= 0 or h ~= pdf_h
- end
-end
-
-local function pdf_set_pos(h,v)
- local move = calc_pdfpos(h,v)
- if move then
- b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor)
- pdf_h = pdf_h + cmtx
- pdf_v = pdf_v + cmty
- end
-end
-
-local function pdf_reset_pos()
- if mode == "page" then
- cmtx = - pdf_h
- cmty = - pdf_v
- if pdf_h == 0 and pdf_v == 0 then
- return
- end
- elseif mode == "text" then
- tmtx = - saved_text_pos_h
- tmty = - saved_text_pos_v
- if pdf_h == 0 and pdf_v == 0 then
- return
- end
- elseif horizontalmode then
- tmty = - saved_text_pos_v
- tj_delta = cw
- if tj_delta == 0 and pdf_v == 0 then
- return
- end
- else
- tmtx = - saved_text_pos_h
- tj_delta = cw
- if tj_delta == 0 and pdf_h == 0 then
- return
- end
- end
- b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor)
- pdf_h = pdf_h + cmtx
- pdf_v = pdf_v + cmty
-end
-
-local function pdf_set_pos_temp(h,v)
- local move = calc_pdfpos(h,v)
- if move then
- b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor)
- end
-end
-
--- these dummy returns makes using them a bit faster
-
-local function pdf_end_string_nl()
- if mode == "char" then
- end_charmode()
- return end_chararray()
- elseif mode == "chararray" then
- return end_chararray()
- end
-end
-
-local function pdf_goto_textmode()
- if mode == "page" then
- pdf_reset_pos()
- return begin_text()
- elseif mode ~= "text" then
- if mode == "char" then
- end_charmode()
- return end_chararray()
- else -- if mode == "chararray" then
- return end_chararray()
- end
- end
-end
-
-local function pdf_goto_pagemode()
- if mode ~= "page" then
- if mode == "char" then
- end_charmode()
- end_chararray()
- return end_text()
- elseif mode == "chararray" then
- end_chararray()
- return end_text()
- elseif mode == "text" then
- return end_text()
- end
- end
-end
-
-local function pdf_goto_fontmode()
- if mode == "char" then
- end_charmode()
- end_chararray()
- end_text()
- elseif mode == "chararray" then
- end_chararray()
- end_text()
- elseif mode == "text" then
- end_text()
- end
- pdf_reset_pos()
- mode = "page"
-end
-
--- characters
-
-local flushcharacter do
-
- local round = math.round
-
- -- across pages ... todo: clean up because we don't need to pass the font
- -- as fontparameters already has checked / set it we can also have a variable
- -- for it so
-
- local naturalwidth = nil
-
- local naturalwidths = setmetatableindex(function(t,font)
- local d = descriptions[font]
- local c = characters[font]
- local f = parameters[font].hfactor
- local v = setmetatableindex(function(t,char)
- local e = d and d[char]
- local w
- if e then
- w = e.width
- if w then
- w = w * f
- end
- end
- if not w then
- e = c[char]
- if e then
- w = e.width or 0
- end
- end
- if not w then
- w = 0
- end
- t[char] = w
- return w
- end)
- t[font] = v
- return v
- end)
-
- local function setup_fontparameters(font,factor,f,e)
- local slant = fontparameters.slantfactor or 0
- local extend = fontparameters.extendfactor or 1
- local squeeze = fontparameters.squeezefactor or 1
- local expand = 1 + factor / 1000000
- local format = fontproperties.format
- if e then
- extend = extend * e
- end
- tmrx = expand * extend
- tmsy = slant
- tmry = squeeze
- need_width = fontparameters.width or 0
- need_mode = fontparameters.mode or 0
- f_cur = font
- f_pdf = usedfonts[font] -- cache
- cur_factor = factor
- cur_f = f
- cur_e = e
- tj_delta = 0
- fs = fontparameters.size * bpfactor
- if f then
- fs = fs * f
- end
- -- kind of special:
- if format == "opentype" or format == "type1" then
- fs = fs * 1000 / fontparameters.units -- can we avoid this ?
- end
- --
- naturalwidth = naturalwidths[font]
- end
-
- -- This only saves a little on hz because there we switch a lot of
- -- instances.
-
- -- local lastslant, lastextend, lastsqueeze, lastformat, lastsize, lastwidth, lastmode, lastused, lastfont
-
- -- local function setup_fontparameters(font,factor,f,e)
- -- if font ~= lastfont then
- -- lastslant = fontparameters.slantfactor or 0
- -- lastextend = fontparameters.extendfactor or 1
- -- lastsqueeze = fontparameters.squeezefactor or 1
- -- lastformat = fontproperties.format
- -- lastsize = fontparameters.size * bpfactor
- -- if format == "opentype" or format == "type1" then
- -- lastsize = lastsize * 1000 / fontparameters.units -- can we avoid this ?
- -- end
- -- lastwidth = fontparameters.width
- -- lastmode = fontparameters.mode
- -- lastused = usedfonts[font] -- cache
- -- lastfont = font
- -- end
- -- local expand = 1 + factor / 1000000
- -- if e then
- -- tmrx = expand * lastextend * e
- -- else
- -- tmrx = expand * lastextend
- -- end
- -- tmsy = lastslant
- -- tmry = lastsqueeze
- -- need_width = lastwidth
- -- need_mode = lastmode
- -- f_cur = lastfont
- -- f_pdf = lastused
- -- cur_factor = factor
- -- cur_f = f
- -- cur_e = e
- -- tj_delta = 0
- -- if f then
- -- fs = lastsize * f
- -- else
- -- fs = lastsize
- -- end
- -- end
-
- local f_width = formatters["%.6N w"]
- local f_mode = formatters["%i Tr"] -- can be hash
- local f_font = formatters["/F%i %.6N Tf"] -- can be hash
-
- local s_width = "0 w"
- local s_mode = "0 Tr"
-
- local function set_font()
- -- if need_width and need_width ~= 0 then
- if need_width ~= 0 then
- b = b + 1 ; buffer[b] = f_width(bpfactor * need_width / 1000)
- done_width = true
- elseif done_width then
- b = b + 1 ; buffer[b] = s_width
- done_width = false
- end
- -- if need_mode and need_mode ~= 0 then
- if need_mode ~= 0 then
- b = b + 1 ; buffer[b] = f_mode(need_mode)
- done_mode = true
- elseif done_mode then
- b = b + 1 ; buffer[b] = s_mode
- done_mode = false
- end
- b = b + 1 ; buffer[b] = f_font(f_pdf,fs)
- f_pdf_cur = f_pdf
- fs_cur = fs
- need_tf = false
- need_tm = true
- end
-
- local function set_textmatrix(h,v)
- local move = calc_pdfpos(h,v)
- if need_tm or move then
- b = b + 1 ; buffer[b] = f_tm(tmrx, tmsx, tmsy, tmry, tmtx*bpfactor, tmty*bpfactor)
- pdf_h = saved_text_pos_h + tmtx
- pdf_v = saved_text_pos_v + tmty
- need_tm = false
- end
- cur_tmrx = tmrx
- end
-
- local f_hex_4 = formatters["%04X"]
- local f_hex_2 = formatters["%02X"]
-
- local h_hex_4 = setmetatableindex(function(t,k) -- we already have this somewhere
- if k < 256 then -- maybe 512
- -- not sparse in this range
- for i=0,255 do
- t[i] = f_hex_4(i)
- end
- return t[k]
- else
- local v = f_hex_4(k)
- t[k] = v
- return v
- end
- end)
- local h_hex_2 = setmetatableindex(function(t,k) -- we already have this somewhere
- local v = k < 256 and f_hex_2(k) or "00"
- t[k] = v
- return v
- end)
-
- local trace_threshold = false trackers.register("backends.pdf.threshold", function(v) trace_threshold = v end)
-
- flushcharacter = function(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor) -- ,naturalwidth,width)
- if need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then
- pdf_goto_textmode()
- setup_fontparameters(font,factor,f,e)
- set_font()
- elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_f ~= f or cur_e ~= e then
- setup_fontparameters(font,factor,f,e)
- need_tm = true
- end
- local move = calc_pdfpos(pos_h,pos_v)
-
- -- if trace_threshold then
- -- report(
- -- "font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p",
- -- font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw
- -- )
- -- end
-
- if move or need_tm then
- if not need_tm then
- if horizontalmode then
- if (saved_text_pos_v + tmty) ~= pdf_v then
- need_tm = true
- elseif tj_delta >= threshold or tj_delta <= -threshold then
- need_tm = true
- end
- else
- if (saved_text_pos_h + tmtx) ~= pdf_h then
- need_tm = true
- elseif tj_delta >= threshold or tj_delta <= -threshold then
- need_tm = true
- end
- end
- end
- if need_tm then
- pdf_goto_textmode()
- set_textmatrix(pos_h,pos_v)
- begin_chararray()
- move = calc_pdfpos(pos_h,pos_v)
- end
- if move then
- local d = tj_delta * scalefactor
- if d <= -0.5 or d >= 0.5 then
- if mode == "char" then
- end_charmode()
- end
- b = b + 1 ; buffer[b] = round(d) -- or f_skip(d)
- end
- cw = cw - tj_delta
- end
- end
-
- if mode == "chararray" then
- begin_charmode()
- end
-
- cw = cw + naturalwidth[char] * tmrx
-
- local index = data.index or char
-
- b = b + 1 ; buffer[b] = font > 0 and h_hex_4[index] or h_hex_2[index]
-
- if not pdfcharacters[index] then
- pdfcharacters[index] = true
- end
-
- end
-
- flushfontchar = function(font,char,data)
- local dummy = usedfonts[font]
- local index = data.index or char
- if not pdfcharacters[index] then
- pdfcharacters[index] = true
- end
- return dummy
- end
-
-end
-
--- literals
-
-local flushliteral do
-
- local nodeproperties = nodes.properties.data
- local literalvalues = nodes.literalvalues
-
- local originliteral_code = literalvalues.origin
- local pageliteral_code = literalvalues.page
- local alwaysliteral_code = literalvalues.always
- local rawliteral_code = literalvalues.raw
- local textliteral_code = literalvalues.text
- local fontliteral_code = literalvalues.font
-
- flushliteral = function(current,pos_h,pos_v,mode,str)
- if mode then
- if not str then
- mode, str = originliteral_code, mode
- elseif mode == "mode" then
- mode = literalvalues[str]
- if mode == originliteral_code then
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- elseif mode == pageliteral_code then
- pdf_goto_pagemode()
- elseif mode == textliteral_code then
- pdf_goto_textmode()
- elseif mode == fontliteral_code then
- pdf_goto_fontmode()
- elseif mode == alwaysliteral_code then
- pdf_end_string_nl()
- need_tm = true
- elseif mode == rawliteral_code then
- pdf_end_string_nl()
- end
- return
- else
- mode = literalvalues[mode]
- end
- else
- local p = nodeproperties[current]
- if p then
- str = p.data
- mode = p.mode
- else
- str, mode = getdata(current)
- end
- end
- if str and str ~= "" then
- if mode == originliteral_code then
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- elseif mode == pageliteral_code then
- pdf_goto_pagemode()
- elseif mode == textliteral_code then
- pdf_goto_textmode()
- elseif mode == fontliteral_code then
- pdf_goto_fontmode()
- elseif mode == alwaysliteral_code then
- pdf_end_string_nl()
- need_tm = true
- elseif mode == rawliteral_code then
- pdf_end_string_nl()
- else
- report("check literal")
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- end
- b = b + 1 ; buffer[b] = str
- end
- end
-
- updaters.register("backend.update.pdf",function()
- function pdf.print(mode,str)
- if str then
- mode = literalvalues[mode]
- else
- mode, str = originliteral_code, mode
- end
- if str and str ~= "" then
- if mode == originliteral_code then
- pdf_goto_pagemode()
- -- pdf_set_pos(pdf_h,pdf_v)
- elseif mode == pageliteral_code then
- pdf_goto_pagemode()
- elseif mode == textliteral_code then
- pdf_goto_textmode()
- elseif mode == fontliteral_code then
- pdf_goto_fontmode()
- elseif mode == alwaysliteral_code then
- pdf_end_string_nl()
- need_tm = true
- elseif mode == rawliteral_code then
- pdf_end_string_nl()
- else
- pdf_goto_pagemode()
- -- pdf_set_pos(pdf_h,pdf_v)
- end
- b = b + 1 ; buffer[b] = str
- end
- end
- end)
-
-end
-
--- grouping & orientation
-
-local flushsave, flushrestore, flushsetmatrix do
-
- local matrices = { }
- local positions = { }
- local nofpositions = 0
- local nofmatrices = 0
-
- local f_matrix = formatters["%s 0 0 cm"]
-
- flushsave = function(current,pos_h,pos_v)
- nofpositions = nofpositions + 1
- positions[nofpositions] = { pos_h, pos_v, nofmatrices }
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- b = b + 1 ; buffer[b] = "q"
- end
-
- flushrestore = function(current,pos_h,pos_v)
- if nofpositions < 1 then
- return
- end
- local t = positions[nofpositions]
- -- local h = pos_h - t[1]
- -- local v = pos_v - t[2]
- if shippingmode == "page" then
- nofmatrices = t[3]
- end
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- b = b + 1 ; buffer[b] = "Q"
- nofpositions = nofpositions - 1
- end
-
- local function pdf_set_matrix(str,pos_h,pos_v)
- if shippingmode == "page" then
- local rx, sx, sy, ry = splitupstring(str," ")
- if rx and ry and sx and ry then
- rx, sx, sy, ry = tonumber(rx), tonumber(sx), tonumber(sy), tonumber(ry)
- local tx = pos_h * (1 - rx) - pos_v * sy
- local ty = pos_v * (1 - ry) - pos_h * sx
- if nofmatrices > 1 then
- local t = matrices[nofmatrices]
- local r_x, s_x, s_y, r_y, te, tf = t[1], t[2], t[3], t[4], t[5], t[6]
- rx, sx = rx * r_x + sx * s_y, rx * s_x + sx * r_y
- sy, ry = sy * r_x + ry * s_y, sy * s_x + ry * r_y
- tx, ty = tx * r_x + ty * s_y, tx * s_x + ty * r_y
- end
- nofmatrices = nofmatrices + 1
- matrices[nofmatrices] = { rx, sx, sy, ry, tx, ty }
- end
- end
- end
-
- local nodeproperties = nodes.properties.data
-
- flushsetmatrix = function(current,pos_h,pos_v)
- local str
- if type(current) == "string" then
- str = current
- else
- local p = nodeproperties[current]
- if p then
- str = p.matrix
- else
- str = getdata(current) -- for the moment
- end
- end
- if str and str ~= "" then
- pdf_set_matrix(str,pos_h,pos_v)
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- b = b + 1 ; buffer[b] = f_matrix(str)
- end
- end
-
- do
-
- local function hasmatrix()
- return nofmatrices > 0
- end
-
- local function getmatrix()
- if nofmatrices > 0 then
- return unpack(matrices[nofmatrices])
- else
- return 1, 0, 0, 1, 0, 0
- end
- end
-
- updaters.register("backend.update.pdf",function()
- pdf.hasmatrix = hasmatrix
- pdf.getmatrix = getmatrix
- end)
-
- end
-
- pushorientation = function(orientation,pos_h,pos_v,pos_r)
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- b = b + 1 ; buffer[b] = "q"
- if orientation == 1 then
- b = b + 1 ; buffer[b] = "0 -1 1 0 0 0 cm" -- 90
- elseif orientation == 2 then
- b = b + 1 ; buffer[b] = "-1 0 0 -1 0 0 cm" -- 180
- elseif orientation == 3 then
- b = b + 1 ; buffer[b] = "0 1 -1 0 0 0 cm" -- 270
- end
- end
-
- poporientation = function(orientation,pos_h,pos_v,pos_r)
- pdf_goto_pagemode()
- pdf_set_pos(pos_h,pos_v)
- b = b + 1 ; buffer[b] = "Q"
- end
-
- -- pushorientation = function(orientation,pos_h,pos_v,pos_r)
- -- flushsave(false,pos_h,pos_v)
- -- if orientation == 1 then
- -- flushsetmatrix("0 -1 1 0",pos_h,pos_v)
- -- elseif orientation == 2 then
- -- flushsetmatrix("-1 0 0 -1",pos_h,pos_v)
- -- elseif orientation == 3 then
- -- flushsetmatrix("0 1 -1 0",pos_h,pos_v)
- -- end
- -- end
-
- -- poporientation = function(orientation,pos_h,pos_v,pos_r)
- -- flushrestore(false,pos_h,pos_v)
- -- end
-
-end
-
--- rules
-
-local flushedxforms = { } -- actually box resources but can also be direct
-local localconverter = nil -- will be set
-
-local flushrule, flushsimplerule, flushimage, flushgroup do
-
- local rulecodes = nodes.rulecodes
- local newrule = nodes.pool.rule
-
- local setprop = nuts.setprop
- local getprop = nuts.getprop
-
- local normalrule_code = rulecodes.normal
- local boxrule_code = rulecodes.box
- local imagerule_code = rulecodes.image
- local emptyrule_code = rulecodes.empty
- local userrule_code = rulecodes.user
- local overrule_code = rulecodes.over
- local underrule_code = rulecodes.under
- local fractionrule_code = rulecodes.fraction
- local radicalrule_code = rulecodes.radical
- local outlinerule_code = rulecodes.outline
-
- local rule_callback = callbacks.functions.process_rule
-
- local f_fm = formatters["/Fm%d Do"]
- local f_im = formatters["/Im%d Do"]
- local f_gr = formatters["/Gp%d Do"]
-
- local s_b = "q"
- local s_e = "Q"
-
- local f_v = formatters["[] 0 d 0 J %.6N w 0 0 m %.6N 0 l S"]
- local f_h = formatters["[] 0 d 0 J %.6N w 0 0 m 0 %.6N l S"]
-
- local f_f = formatters["0 0 %.6N %.6N re f"]
- local f_o = formatters["[] 0 d 0 J 0 0 %.6N %.6N re S"]
- local f_w = formatters["[] 0 d 0 J %.6N w 0 0 %.6N %.6N re S"]
-
- -- Historically the index is an object which is kind of bad.
-
- local boxresources, n = { }, 0
-
- getxformname = function(index)
- local l = boxresources[index]
- if l then
- return l.name
- else
- report("no box resource %S",index)
- end
- end
-
- updaters.register("backend.update.pdf",function()
- pdf.getxformname = getxformname
- end)
-
- local function saveboxresource(box,attributes,resources,immediate,kind,margin)
- n = n + 1
- local immediate = true
- local margin = margin or 0 -- or dimension
- local objnum = pdfreserveobject()
- local list = tonut(type(box) == "number" and tex.takebox(box) or box)
- --
- local width, height, depth = getwhd(list)
- --
- local l = {
- width = width,
- height = height,
- depth = depth,
- margin = margin,
- attributes = attributes,
- resources = resources,
- list = nil,
- type = kind,
- name = n,
- index = objnum,
- objnum = objnum,
- }
- boxresources[objnum] = l
- if immediate then
- localconverter(list,"xform",objnum,l)
- flushedxforms[objnum] = { true , objnum }
- flushlist(list)
- else
- l.list = list
- end
- return objnum
- end
-
- local function useboxresource(index,wd,ht,dp)
- local l = boxresources[index]
- if l then
- if wd or ht or dp then
- wd, ht, dp = wd or 0, ht or 0, dp or 0
- else
- wd, ht, dp = l.width, l.height, l.depth
- end
- local rule = newrule(wd,ht,dp) -- newboxrule
- rule.subtype = boxrule_code
- setprop(tonut(rule),"index",index)
- return rule, wd, ht, dp
- else
- report("no box resource %S",index)
- end
- end
-
- local function getboxresourcedimensions(index)
- local l = boxresources[index]
- if l then
- return l.width, l.height, l.depth, l.margin
- else
- report("no box resource %S",index)
- end
- end
-
- local function getboxresourcebox(index)
- local l = boxresources[index]
- if l then
- return l.list
- end
- end
-
- updaters.register("backend.update.tex",function()
- tex.saveboxresource = saveboxresource
- tex.useboxresource = useboxresource
- tex.getboxresourcedimensions = getboxresourcedimensions
- tex.getboxresourcebox = getboxresourcebox
- end)
-
- -- a bit of a mess: index is now objnum but that has to change to a proper index
- -- ... an engine inheritance
-
- local function flushpdfxform(current,pos_h,pos_v,pos_r,size_h,size_v)
- -- object properties
- local objnum = getprop(current,"index")
- local name = getxformname(objnum)
- local info = flushedxforms[objnum]
- local r = boxresources[objnum]
- if not info then
- info = { false , objnum }
- flushedxforms[objnum] = info
- end
- local wd, ht, dp = getboxresourcedimensions(objnum)
- -- or: wd, ht, dp = r.width, r.height, r.depth
- -- sanity check
- local htdp = ht + dp
- if wd == 0 or size_h == 0 or htdp == 0 or size_v == 0 then
- return
- end
- -- calculate scale
- local rx, ry = 1, 1
- if wd ~= size_h or htdp ~= size_v then
- rx = size_h / wd
- ry = size_v / htdp
- end
- -- flush the reference
- usedxforms[objnum] = true
- pdf_goto_pagemode()
- calc_pdfpos(pos_h,pos_v)
- tx = cmtx * bpfactor
- ty = cmty * bpfactor
- b = b + 1 ; buffer[b] = s_b
- b = b + 1 ; buffer[b] = f_cm(rx,0,0,ry,tx,ty)
- b = b + 1 ; buffer[b] = f_fm(name)
- b = b + 1 ; buffer[b] = s_e
- end
-
- -- place image also used in vf but we can use a different one if we need it
-
- local imagetypes = images.types -- pdf png jpg jp2 jbig2 stream memstream
- local img_none = imagetypes.none
- local img_pdf = imagetypes.pdf
- local img_stream = imagetypes.stream
- local img_memstream = imagetypes.memstream
-
- local one_bp = 65536 * bpfactor
-
- local imageresources, n = { }, 0
-
- getximagename = function(index)
- local l = imageresources[index]
- if l then
- return l.name
- else
- report("no image resource %S",index)
- end
- end
-
- updaters.register("backend.update.pdf",function()
- pdf.getximagename = getximagename
- end)
-
- -- Groups are flushed immediately but we can decide to make them into a
- -- specific whatsit ... but not now. We could hash them if needed when
- -- we use lot sof them in mp ... but not now.
-
- usedxgroups = { }
- local groups = 0
- local group = nil
-
- flushgroup = function(content,bbox)
- if not group then
- group = pdfdictionary {
- Type = pdfconstant("Group"),
- S = pdfconstant("Transparency"),
- }
- end
- local wrapper = pdfdictionary {
- Type = pdf_xobject,
- Subtype = pdf_form,
- FormType = 1,
- Group = group,
- BBox = pdfarray(bbox),
- Resources = lpdf.collectedresources { serialize = false },
- }
- local objnum = pdfflushstreamobject(content,wrapper,false)
- groups = groups + 1
- usedxgroups[groups] = objnum
- return f_gr(groups)
- end
-
- lpdf.flushgroup = flushgroup -- todo: access via driver in mlib-pps
-
- -- end of experiment
-
- local function flushpdfximage(current,pos_h,pos_v,pos_r,size_h,size_v)
-
- local width,
- height,
- depth = getwhd(current)
- local total = height + depth
- local transform = getprop(current,"transform") or 0 -- we never set it ... so just use rotation then
- local index = getprop(current,"index") or 0
- local kind,
- xorigin,
- yorigin,
- xsize,
- ysize,
- rotation, -- transform / orientation / rotation : it's a mess (i need to redo this)
- objnum,
- groupref = pdfincludeimage(index) -- needs to be sorted out, bad name (no longer mixed anyway)
-
- if not kind then
- report("invalid image %S",index)
- return
- end
-
- local rx, sx, sy, ry, tx, ty = 1, 0, 0, 1, 0, 0
-
- -- tricky: xsize and ysize swapped
-
- if kind == img_pdf or kind == img_stream or kind == img_memstream then
- rx, ry, tx, ty = 1/xsize, 1/ysize, xorigin/xsize, yorigin/ysize
- else
- -- if kind == img_png then
- -- -- if groupref > 0 and img_page_group_val == 0 then
- -- -- img_page_group_val = groupref
- -- -- end
- -- end
- rx, ry = bpfactor, bpfactor
- end
-
- if band(transform,7) > 3 then
- -- mirror
- rx, tx = -rx, -tx
- end
- local t = band(transform + rotation,3)
- if t == 0 then
- -- nothing
- elseif t == 1 then
- -- rotation over 90 degrees (counterclockwise)
- rx, sx, sy, ry, tx, ty = 0, rx, -ry, 0, -ty, tx
- elseif t == 2 then
- -- rotation over 180 degrees (counterclockwise)
- rx, ry, tx, ty = -rx, -ry, -tx, -ty
- elseif t == 3 then
- -- rotation over 270 degrees (counterclockwise)
- rx, sx, sy, ry, tx, ty = 0, -rx, ry, 0, ty, -tx
- end
-
- rx = rx * width
- sx = sx * total
- sy = sy * width
- ry = ry * total
- tx = pos_h - tx * width
- ty = pos_v - ty * total
-
- local t = transform + rotation
-
- if band(transform,7) > 3 then
- t = t + 1
- end
-
- t = band(t,3)
-
- if t == 0 then
- -- no transform
- elseif t == 1 then
- -- rotation over 90 degrees (counterclockwise)
- tx = tx + width
- elseif t == 2 then
- -- rotation over 180 degrees (counterclockwise)
- tx = tx + width
- ty = ty + total
- elseif t == 3 then
- -- rotation over 270 degrees (counterclockwise)
- ty = ty + total
- end
-
- -- a flaw in original, can go:
- --
- -- if img_page_group_val == 0 then
- -- img_page_group_val = group_ref
- -- end
-
- usedximages[index] = objnum -- hm
-
- pdf_goto_pagemode()
-
- calc_pdfpos(tx,ty)
-
- tx = cmtx * bpfactor
- ty = cmty * bpfactor
-
- b = b + 1 ; buffer[b] = s_b
- b = b + 1 ; buffer[b] = f_cm(rx,sx,sy,ry,tx,ty)
- b = b + 1 ; buffer[b] = f_im(index)
- b = b + 1 ; buffer[b] = s_e
- end
-
- flushimage = function(index,width,height,depth,pos_h,pos_v)
-
- -- used in vf characters
-
- local total = height + depth
- local kind,
- xorigin, yorigin,
- xsize, ysize,
- rotation,
- objnum,
- groupref = pdfincludeimage(index)
-
- local rx = width / xsize
- local sx = 0
- local sy = 0
- local ry = total / ysize
- local tx = pos_h
- -- to be sorted out
- -- local ty = pos_v - depth
- local ty = pos_v -- we assume that depth is dealt with in the caller (for now)
-
- usedximages[index] = objnum
-
- pdf_goto_pagemode()
-
- calc_pdfpos(tx,ty)
-
- tx = cmtx * bpfactor
- ty = cmty * bpfactor
-
- b = b + 1 ; buffer[b] = s_b
- b = b + 1 ; buffer[b] = f_cm(rx,sx,sy,ry,tx,ty)
- b = b + 1 ; buffer[b] = f_im(index)
- b = b + 1 ; buffer[b] = s_e
- end
-
- -- For the moment we need this hack because the engine checks the 'image'
- -- command in virtual fonts (so we use lua instead).
-
- flushrule = function(current,pos_h,pos_v,pos_r,size_h,size_v,subtype)
-
- if subtype == emptyrule_code then
- return
- elseif subtype == boxrule_code then
- return flushpdfxform(current,pos_h,pos_v,pos_r,size_h,size_v)
- elseif subtype == imagerule_code then
- return flushpdfximage(current,pos_h,pos_v,pos_r,size_h,size_v)
- end
- if subtype == userrule_code or subtype >= overrule_code and subtype <= radicalrule_code then
- pdf_goto_pagemode()
- b = b + 1 ; buffer[b] = s_b
- pdf_set_pos_temp(pos_h,pos_v)
- rule_callback(current,size_h,size_v,pos_r) -- so we pass direction
- b = b + 1 ; buffer[b] = s_e
- return
- end
-
- pdf_goto_pagemode()
-
- -- local saved_b = b
-
- b = b + 1 ; buffer[b] = s_b
-
- local dim_h = size_h * bpfactor
- local dim_v = size_v * bpfactor
- local rule
-
- if dim_v <= one_bp then
- pdf_set_pos_temp(pos_h,pos_v + 0.5 * size_v)
- rule = f_v(dim_v,dim_h)
- elseif dim_h <= one_bp then
- pdf_set_pos_temp(pos_h + 0.5 * size_h,pos_v)
- rule = f_h(dim_h,dim_v)
- else
- pdf_set_pos_temp(pos_h,pos_v)
- if subtype == outlinerule_code then
- local linewidth = getdata(current)
- if linewidth > 0 then
- rule = f_w(linewidth * bpfactor,dim_h,dim_v)
- else
- rule = f_o(dim_h,dim_v)
- end
- else
- rule = f_f(dim_h,dim_v)
- end
- end
-
- b = b + 1 ; buffer[b] = rule
- b = b + 1 ; buffer[b] = s_e
-
- -- buffer[saved_b] = concat(buffer," ",saved_b,b)
- -- b = saved_b
-
- end
-
- flushsimplerule = function(pos_h,pos_v,pos_r,size_h,size_v)
- pdf_goto_pagemode()
-
- b = b + 1 ; buffer[b] = s_b
-
- local dim_h = size_h * bpfactor
- local dim_v = size_v * bpfactor
- local rule
-
- if dim_v <= one_bp then
- pdf_set_pos_temp(pos_h,pos_v + 0.5 * size_v)
- rule = f_v(dim_v,dim_h)
- elseif dim_h <= one_bp then
- pdf_set_pos_temp(pos_h + 0.5 * size_h,pos_v)
- rule = f_h(dim_h,dim_v)
- else
- pdf_set_pos_temp(pos_h,pos_v)
- rule = f_f(dim_h,dim_v)
- end
-
- b = b + 1 ; buffer[b] = rule
- b = b + 1 ; buffer[b] = s_e
- end
-
-end
-
---- basics
-
-local wrapup, registerpage do
-
- local pages = { }
- local maxkids = 10
- local nofpages = 0
- local pagetag = "unset"
-
- registerpage = function(object)
- nofpages = nofpages + 1
- local objnum = pdfpagereference(nofpages)
- pages[nofpages] = {
- page = nofpages, -- original number, only for diagnostics
- objnum = objnum,
- object = object,
- tag = pagetag,
- }
- end
-
- function lpdf.setpagetag(tag)
- pagetag = tag or "unset"
- end
-
- function lpdf.getnofpages()
- return nofpages
- end
-
- function lpdf.getpagetags()
- local list = { }
- for i=1,nofpages do
- list[i] = pages[i].tag
- end
- return list
- end
-
- function lpdf.setpageorder(mapping)
- -- mapping can be a hash so:
- local list = table.sortedkeys(mapping)
- local n = #list
- if n == nofpages then
- local done = { }
- local hash = { }
- for i=1,n do
- local order = mapping[list[i]]
- if hash[order] then
- report("invalid page order, duplicate entry %i",order)
- return
- elseif order < 1 or order > nofpages then
- report("invalid page order, no page %i",order)
- return
- else
- done[i] = pages[order]
- hash[order] = true
- end
- end
- pages = done
- else
- report("invalid page order, %i entries expected",nofpages)
- end
- end
-
- -- We can have this, but then via codeinjections etc. Later.
-
- -- function structures.pages.swapthem()
- -- local n = lpdf.getnofpages()
- -- local t = { }
- -- for i=1,n do
- -- t[i] = i
- -- end
- -- for i=2,math.odd(n) and n or (n-1),2 do
- -- t[i] = i+1
- -- t[i+1] = i
- -- end
- -- lpdf.setpageorder(t)
- -- end
-
- wrapup = function(driver)
-
- -- hook (to reshuffle pages)
- local pagetree = { }
- local parent = nil
- local minimum = 0
- local maximum = 0
- local current = 0
- if #pages > 1.5 * maxkids then
- repeat
- local plist, pnode
- if current == 0 then
- plist, minimum = pages, 1
- elseif current == 1 then
- plist, minimum = pagetree, 1
- else
- plist, minimum = pagetree, maximum + 1
- end
- maximum = #plist
- if maximum > minimum then
- local kids
- for i=minimum,maximum do
- local p = plist[i]
- if not pnode or #kids == maxkids then
- kids = pdfarray()
- parent = pdfreserveobject()
- pnode = pdfdictionary {
- objnum = parent,
- Type = pdf_pages,
- Kids = kids,
- Count = 0,
- }
- pagetree[#pagetree+1] = pnode
- end
- kids[#kids+1] = pdfreference(p.objnum)
- pnode.Count = pnode.Count + (p.Count or 1)
- p.Parent = pdfreference(parent)
- end
- end
- current = current + 1
- until maximum == minimum
- -- flush page tree
- for i=1,#pagetree do
- local entry = pagetree[i]
- local objnum = entry.objnum
- entry.objnum = nil
- pdfflushobject(objnum,entry)
- end
- else
- -- ugly
- local kids = pdfarray()
- local list = pdfdictionary {
- Type = pdf_pages,
- Kids = kids,
- Count = nofpages,
- }
- parent = pdfreserveobject()
- for i=1,nofpages do
- local page = pages[i]
- kids[#kids+1] = pdfreference(page.objnum)
- page.Parent = pdfreference(parent)
- end
- pdfflushobject(parent,list)
- end
- for i=1,nofpages do
- local page = pages[i]
- local object = page.object
- object.Parent = page.Parent
- pdfflushobject(page.objnum,object)
- end
- lpdf.addtocatalog("Pages",pdfreference(parent))
-
- end
-
-end
-
-pdf_h, pdf_v = 0, 0
-
-local function initialize(driver,details)
- reset_variables(details)
- reset_buffer()
-end
-
--- This will all move and be merged and become less messy.
-
--- todo: more clever resource management: a bit tricky as we can inject
--- stuff in the page stream
-
-local compact = false
-
-do
-
- -- This is more a convenience feature and it might even be not entirely robust.
- -- It removes redundant color directives which makes the page stream look a bit
- -- nicer (also when figuring out issues). I might add more here but there is
- -- some additional overhead involved so runtime can be impacted.
-
- local P, R, S, Cs, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.Cs, lpeg.match
-
- local p_ds = (R("09") + S(" ."))^1
- ----- p_nl = S("\n\r")^1
- local p_nl = S("\n")^1
- local p_eg = P("Q")
-
- local p_cl = p_ds * (P("rg") + P("g") + P("k")) * p_ds * (P("RG") + P("G") + P("K"))
- ----- p_cl = (p_ds * (P("rg") + P("g") + P("k") + P("RG") + P("G") + P("K")))^1
- local p_tr = P("/Tr") * p_ds * P("gs")
-
- local p_no_cl = (p_cl * p_nl) / ""
- local p_no_tr = (p_tr * p_nl) / ""
- local p_no_nl = 1 - p_nl
-
- local p_do_cl = p_cl * p_nl
- local p_do_tr = p_tr * p_nl
-
- local p_do_eg = p_eg * p_nl
-
- local pattern = Cs( (
- (p_no_cl + p_no_tr)^0 * p_do_eg -- transparencies and colors before Q
- + p_no_tr * p_no_cl * p_do_tr * p_do_cl -- transparencies and colors before others
- + p_no_cl * p_do_cl -- successive colors
- + p_no_tr * p_do_tr -- successive transparencies
- + p_no_nl^1
- + 1
- )^1 )
-
- local oldsize = 0
- local newsize = 0
-
- directives.register("pdf.compact", function(v)
- compact = v and function(s)
- oldsize = oldsize + #s
- s = lpegmatch(pattern,s) or s
- newsize = newsize + #s
- return s
- end
- end)
-
- statistics.register("pdf pagestream",function()
- if oldsize ~= newsize then
- return string.format("old size: %i, new size %i",oldsize,newsize)
- end
- end)
-
-
-end
-
-local flushdeferred -- defined later
-
-local level = 0
-
-local finalize do
-
- local f_font = formatters["F%d"]
-
- local f_form = formatters["Fm%d"]
- local f_group = formatters["Gp%d"]
- local f_image = formatters["Im%d"]
-
- finalize = function(driver,details)
-
- level = level + 1
-
- pdf_goto_pagemode() -- for now
-
- local objnum = details.objnum
- local specification = details.specification
-
- local content = concat(buffer,"\n",1,b)
-
- if compact then
- content = compact(content)
- end
-
- local fonts = nil
- local xforms = nil
-
- if next(usedfonts) then
- fonts = pdfdictionary { }
- for k, v in next, usedfonts do
- fonts[f_font(v)] = pdfreference(pdfgetfontobjnumber(k)) -- we can overload for testing
- end
- end
-
- -- messy: use real indexes for both ... so we need to change some in the
- -- full luatex part
-
- if next(usedxforms) or next(usedximages) or next(usedxgroups) then
- xforms = pdfdictionary { }
- for k in sortedhash(usedxforms) do
- -- xforms[f_form(k)] = pdfreference(k)
- xforms[f_form(getxformname(k))] = pdfreference(k)
- end
- for k, v in sortedhash(usedximages) do
- xforms[f_image(k)] = pdfreference(v)
- end
- for k, v in sortedhash(usedxgroups) do
- xforms[f_group(k)] = pdfreference(v)
- end
- end
-
- reset_buffer()
-
- -- finish_pdfpage_callback(shippingmode == "page")
-
- if shippingmode == "page" then
-
- local pageproperties = lpdf.getpageproperties()
-
- local pageresources = pageproperties.pageresources
- local pageattributes = pageproperties.pageattributes
- local pagesattributes = pageproperties.pagesattributes
-
- pageresources.Font = fonts
- pageresources.XObject = xforms
- pageresources.ProcSet = lpdf.procset()
-
- local xorigin, yorigin, relocated = backends.codeinjections.getpageorigin() -- for now here
-
- local bbox = pdfarray {
- (boundingbox[1] + xorigin) * bpfactor,
- (boundingbox[2] + yorigin) * bpfactor,
- (boundingbox[3] + xorigin) * bpfactor,
- (boundingbox[4] + yorigin) * bpfactor,
- }
-
- if relocated then
- content = formatters["1 0 0 1 %.6N %.6N cm\n%s"](bbox[1],bbox[2],content)
- end
-
- local contentsobj = pdfflushstreamobject(content,false,false)
-
- pageattributes.Type = pdf_page
- pageattributes.Contents = pdfreference(contentsobj)
- pageattributes.Resources = pageresources
- -- pageattributes.Resources = pdfreference(pdfflushobject(pageresources))
- pageattributes.MediaBox = bbox
- pageattributes.Parent = nil -- precalculate
- pageattributes.Group = nil -- todo
-
- -- resources can be indirect
-
- registerpage(pageattributes)
-
- lpdf.finalizepage(true)
-
- if relocated then
- if pageattributes.TrimBox then pageattributes.TrimBox = box end
- if pageattributes.CropBox then pageattributes.CropBox = box end
- if pageattributes.BleedBox then pageattributes.BleedBox = box end
- end
-
- else
-
- local xformtype = specification.type or 0
- local margin = specification.margin or 0
- local attributes = specification.attributes or ""
- local resources = specification.resources or ""
-
- local wrapper = nil
-
- if xformtype == 0 then
- wrapper = pdfdictionary {
- Type = pdf_xobject,
- Subtype = pdf_form,
- FormType = 1,
- BBox = nil,
- Matrix = nil,
- Resources = nil,
- }
- else
- wrapper = pdfdictionary {
- BBox = nil,
- Matrix = nil,
- Resources = nil,
- }
- end
- if xformtype == 0 or xformtype == 1 or xformtype == 3 then
- wrapper.BBox = pdfarray {
- -margin * bpfactor,
- -margin * bpfactor,
- (boundingbox[3] + margin) * bpfactor,
- (boundingbox[4] + margin) * bpfactor,
- }
- end
- if xformtype == 0 or xformtype == 2 or xformtype == 3 then
- wrapper.Matrix = pdfarray { 1, 0, 0, 1, 0, 0 }
- end
-
- -- todo: additional = resources
-
- local boxresources = lpdf.collectedresources { serialize = false }
- boxresources.Font = fonts
- boxresources.XObject = xforms
-
- -- todo: maybe share them
- -- wrapper.Resources = pdfreference(pdfflushobject(boxresources))
-
- if resources ~= "" then
- boxresources = boxresources + resources
- end
- if attributes ~= "" then
- wrapper = wrapper + attributes
- end
-
- wrapper.Resources = next(boxresources) and boxresources or nil
- wrapper.ProcSet = lpdf.procset()
-
- -- pdfflushstreamobject(content,wrapper,false,objectnumber)
- pdfflushstreamobject(content,wrapper,false,specification.objnum)
-
- end
-
- for objnum in sortedhash(usedxforms) do
- local f = flushedxforms[objnum]
- if f[1] == false then
- f[1] = true
- local objnum = f[2] -- specification.objnum
- local specification = boxresources[objnum]
- local list = specification.list
- localconverter(list,"xform",f[2],specification)
- end
- end
-
- pdf_h, pdf_v = 0, 0
-
- if level == 1 then
- flushdeferred()
- end
- level = level - 1
-
- end
-
-end
-
-updaters.register("backend.update.pdf",function()
- job.positions.registerhandlers {
- getpos = drivers.getpos,
- getrpos = drivers.getrpos,
- gethpos = drivers.gethpos,
- getvpos = drivers.getvpos,
- }
-end)
-
-updaters.register("backend.update",function()
- local saveboxresource = tex.boxresources.save
- --
- -- also in lpdf-res .. brrr .. needs fixing
- --
- backends.codeinjections.registerboxresource = function(n,offset)
- local r = saveboxresource(n,nil,nil,false,0,offset or 0)
- return r
- end
-end)
-
--- now comes the pdf file handling
-
-local objects = { }
-local streams = { } -- maybe just parallel to objects (no holes)
-local nofobjects = 0
-local offset = 0
-local f = false
-local flush = false
-local threshold = 40 -- also #("/Filter /FlateDecode") (compression threshold)
-local objectstream = true
-local compress = true
-local cache = false
-local info = ""
-local catalog = ""
-local lastdeferred = false
-local majorversion = 1
-local minorversion = 7
-local trailerid = true
-
-directives.register("backend.pdf.threshold",function(v)
- if v then
- threshold = tonumber(v) or 40
- else
- threshold = -1000
- end
-end)
-
-local f_object = formatters["%i 0 obj\010%s\010endobj\010"]
-local f_stream_n_u = formatters["%i 0 obj\010<< /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
-local f_stream_n_c = formatters["%i 0 obj\010<< /Filter /FlateDecode /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
-local f_stream_d_u = formatters["%i 0 obj\010<< %s /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
-local f_stream_d_c = formatters["%i 0 obj\010<< %s /Filter /FlateDecode /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
-local f_stream_d_r = formatters["%i 0 obj\010<< %s >>\010stream\010%s\010endstream\010endobj\010"]
-
------ f_object_b = formatters["%i 0 obj\010"]
-local f_stream_b_n_u = formatters["%i 0 obj\010<< /Length %i >>\010stream\010"]
-local f_stream_b_n_c = formatters["%i 0 obj\010<< /Filter /FlateDecode /Length %i >>\010stream\010"]
-local f_stream_b_d_u = formatters["%i 0 obj\010<< %s /Length %i >>\010stream\010"]
-local f_stream_b_d_c = formatters["%i 0 obj\010<< %s /Filter /FlateDecode /Length %i >>\010stream\010"]
-local f_stream_b_d_r = formatters["%i 0 obj\010<< %s >>\010stream\010"]
-
------ s_object_e = "\010endobj\010"
-local s_stream_e = "\010endstream\010endobj\010"
-
-do
-
- local function setinfo() end -- we get it
- local function setcatalog() end -- we get it
-
- local function settrailerid(v)
- trailerid = v or false
- end
-
- local function setmajorversion(v) majorversion = tonumber(v) or majorversion end
- local function setminorversion(v) minorversion = tonumber(v) or minorversion end
-
- local function getmajorversion(v) return majorversion end
- local function getminorversion(v) return minorversion end
-
- local function setcompresslevel (v) compress = v and v ~= 0 and true or false end
- local function setobjcompresslevel(v) objectstream = v and v ~= 0 and true or false end
-
- local function getcompresslevel (v) return compress and 3 or 0 end
- local function getobjcompresslevel(v) return objectstream and 1 or 0 end
-
- local function setpageresources () end -- needs to be sorted out
- local function setpageattributes () end
- local function setpagesattributes() end
-
- updaters.register("backend.update.pdf",function()
- pdf.setinfo = setinfo
- pdf.setcatalog = setcatalog
- pdf.settrailerid = settrailerid
- pdf.setmajorversion = setmajorversion
- pdf.setminorversion = setminorversion
- pdf.getmajorversion = getmajorversion
- pdf.getminorversion = getminorversion
- pdf.setcompresslevel = setcompresslevel
- pdf.setobjcompresslevel = setobjcompresslevel
- pdf.getcompresslevel = getcompresslevel
- pdf.getobjcompresslevel = getobjcompresslevel
- pdf.setpageresources = setpageresources
- pdf.setpageattributes = setpageattributes
- pdf.setpagesattributes = setpagesattributes
- end)
-
-end
-
-local addtocache, flushcache, cache do
-
- local data, d = { }, 0
- local list, l = { }, 0
- local coffset = 0
- local indices = { }
-
- local maxsize = 32 * 1024 -- uncompressed
- local maxcount = 0xFF
-
- addtocache = function(n,str)
- local size = #str
- if size == 0 then
- -- todo: message
- return
- end
- if coffset + size > maxsize or d == maxcount then
- flushcache()
- end
- if d == 0 then
- nofobjects = nofobjects + 1
- objects[nofobjects] = false
- streams[nofobjects] = indices
- cache = nofobjects
- end
- objects[n] = - cache
- indices[n] = d
- d = d + 1
- -- can have a comment n 0 obj as in luatex
- data[d] = str
- l = l + 1 ; list[l] = n
- l = l + 1 ; list[l] = coffset
- coffset = coffset + size + 1
- end
-
- local p_ObjStm = pdfconstant("ObjStm")
-
- flushcache = function() -- references cannot be stored
- if l > 0 then
- list = concat(list," ")
- data[0] = list
- data = concat(data,"\010",0,d)
- local strobj = pdfdictionary {
- Type = p_ObjStm,
- N = d,
- First = #list + 1,
- }
- objects[cache] = offset
- local b = nil
- local e = s_stream_e
- if compress then
- local comp = zlibcompress(data,3)
- if comp and #comp < #data then
- data = comp
- b = f_stream_b_d_c(cache,strobj(),#data)
- else
- b = f_stream_b_d_u(cache,strobj(),#data)
- end
- else
- b = f_stream_b_d_u(cache,strobj(),#data)
- end
- flush(f,b)
- flush(f,data)
- flush(f,e)
- offset = offset + #b + #data + #e
- data, d = { }, 0
- list, l = { }, 0
- coffset = 0
- indices = { }
- end
- end
-
-end
-
-local function pdfreserveobj()
- nofobjects = nofobjects + 1
- objects[nofobjects] = false
- return nofobjects
-end
-
-local pages = table.setmetatableindex(function(t,k)
- local v = pdfreserveobj()
- t[k] = v
- return v
-end)
-
-local function getpageref(n)
- return pages[n]
-end
-
-local function refobj()
- -- not needed, as we have auto-delay
-end
-
-local function flushnormalobj(data,n)
- if not n then
- nofobjects = nofobjects + 1
- n = nofobjects
- end
- data = f_object(n,data)
- if level == 0 then
- objects[n] = offset
- offset = offset + #data
- flush(f,data)
- else
- if not lastdeferred then
- lastdeferred = n
- elseif n < lastdeferred then
- lastdeferred = n
- end
- objects[n] = data
- end
- return n
-end
-
-local function flushstreamobj(data,n,dict,comp,nolength)
- if not data then
- report("no data for %S",dict)
- return
- end
- if not n then
- nofobjects = nofobjects + 1
- n = nofobjects
- end
- local size = #data
- if level == 0 then
- local b = nil
- local e = s_stream_e
- if nolength then
- b = f_stream_b_d_r(n,dict)
- elseif comp ~= false and compress and size > threshold then
- local compdata = zlibcompress(data,3)
- if compdata then
- local compsize = #compdata
- if compsize > size - threshold then
- b = dict and f_stream_b_d_u(n,dict,size) or f_stream_b_n_u(n,size)
- else
- data = compdata
- b = dict and f_stream_b_d_c(n,dict,compsize) or f_stream_b_n_c(n,compsize)
- end
- else
- b = dict and f_stream_b_d_u(n,dict,size) or f_stream_b_n_u(n,size)
- end
- else
- b = dict and f_stream_b_d_u(n,dict,size) or f_stream_b_n_u(n,size)
- end
- flush(f,b)
- flush(f,data)
- flush(f,e)
- objects[n] = offset
- offset = offset + #b + #data + #e
- else
- if nolength then
- data = f_stream_d_r(n,dict,data)
- elseif comp ~= false and compress and size > threshold then
- local compdata = zlibcompress(data,3)
- if compdata then
- local compsize = #compdata
- if compsize > size - threshold then
- data = dict and f_stream_d_u(n,dict,size,data) or f_stream_n_u(n,size,data)
- else
- data = dict and f_stream_d_c(n,dict,compsize,compdata) or f_stream_n_c(n,compsize,compdata)
- end
- else
- data = dict and f_stream_d_u(n,dict,size,data) or f_stream_n_u(n,size,data)
- end
- else
- data = dict and f_stream_d_u(n,dict,size,data) or f_stream_n_u(n,size,data)
- end
- if not lastdeferred then
- lastdeferred = n
- elseif n < lastdeferred then
- lastdeferred = n
- end
- objects[n] = data
- end
- return n
-end
-
-flushdeferred = function() -- was forward defined
- if lastdeferred then
- for n=lastdeferred,nofobjects do
- local o = objects[n]
- if type(o) == "string" then
- objects[n] = offset
- offset = offset + #o
- flush(f,o)
- end
- end
- lastdeferred = false
- end
-end
-
--- n = pdf.obj([n,] objtext)
--- n = pdf.obj([n,] "file", filename)
--- n = pdf.obj([n,] "stream", streamtext [, attrtext])
--- n = pdf.obj([n,] "streamfile", filename [, attrtext])
---
--- n = pdf.obj {
--- type = , -- raw|stream
--- immediate = ,
--- objnum = ,
--- attr = ,
--- compresslevel = ,
--- objcompression = ,
--- file = ,
--- string = ,
--- nolength = ,
--- }
-
-local function obj(a,b,c,d)
- local kind --, immediate
- local objnum, data, attr, filename
- local compresslevel, objcompression, nolength
- local argtype = type(a)
- if argtype == "table" then
- kind = a.type -- raw | stream
- -- immediate = a.immediate
- objnum = a.objnum
- attr = a.attr
- compresslevel = a.compresslevel
- objcompression = a.objcompression
- filename = a.file
- data = a.string or a.stream or ""
- nolength = a.nolength
- if kind == "stream" then
- if filename then
- data = loaddata(filename) or ""
- end
- elseif kind == "raw"then
- if filename then
- data = loaddata(filename) or ""
- end
- elseif kind == "file"then
- kind = "raw"
- data = filename and loaddata(filename) or ""
- elseif kind == "streamfile" then
- kind = "stream"
- data = filename and loaddata(filename) or ""
- end
- else
- if argtype == "number" then
- objnum = a
- a, b, c = b, c, d
- else
- nofobjects = nofobjects + 1
- objnum = nofobjects
- end
- if b then
- if a == "stream" then
- kind = "stream"
- data = b
- elseif a == "file" then
- -- kind = "raw"
- data = loaddata(b)
- elseif a == "streamfile" then
- kind = "stream"
- data = loaddata(b)
- else
- data = "" -- invalid object
- end
- attr = c
- else
- -- kind = "raw"
- data = a
- end
- end
- if not objnum then
- nofobjects = nofobjects + 1
- objnum = nofobjects
- end
- -- todo: immediate
- if kind == "stream" then
- flushstreamobj(data,objnum,attr,compresslevel and compresslevel > 0 or nil,nolength)
- elseif objectstream and objcompression ~= false then
- addtocache(objnum,data)
- else
- flushnormalobj(data,objnum)
- end
- return objnum
-end
-
-updaters.register("backend.update.pdf",function()
- pdf.reserveobj = pdfreserveobj
- pdf.getpageref = getpageref
- pdf.refobj = refobj
- pdf.flushstreamobj = flushstreamobj
- pdf.flushnormalobj = flushnormalobj
- pdf.obj = obj
- pdf.immediateobj = obj
-end)
-
--- In lua 5.4 the methods are now moved one metalevel deeper so we need to get them
--- from mt.__index instead. (I did get that at first.) It makes for a slightly (imo)
--- nicer interface but no real gain in speed as we don't flush that often.
-
-local openfile, closefile do
-
- -- I used to do but then figured out that when I open and save a file in a mode
- -- that removes trailing spaces, the xref becomes invalid. The problem was then that a
- -- reconstruction of the file by a viewer gives weird effects probably because percent symbols
- -- gets interpreted then. Thanks to Ross Moore for noticing this side effect!
-
- local f_used = formatters["%010i 00000 n\013\010"]
- local f_link = formatters["%010i 00000 f\013\010"]
- local f_first = formatters["%010i 65535 f\013\010"]
-
- local f_pdf = formatters["%%PDF-%i.%i\010"]
- local f_xref = formatters["xref\0100 %i\010"]
- local f_trailer_id = formatters["trailer\010<< %s /ID [ <%s> <%s> ] >>\010startxref\010%i\010%%%%EOF"]
- local f_trailer_no = formatters["trailer\010<< %s >>\010startxref\010%i\010%%%%EOF"]
- local f_startxref = formatters["startxref\010%i\010%%%%EOF"]
-
- local inmemory = false
- local close = false
-
- openfile = function(filename)
- if inmemory then
- local n = 0
- f = { }
- flush = function(f,s)
- n = n + 1 f[n] = s
- end
- close = function(f)
- f = concat(f)
- io.savedata(filename,f)
- f = false
- end
- -- local n = 0
- -- f = {
- -- write = function(self,s)
- -- n = n + 1 f[n] = s
- -- end,
- -- close = function(self)
- -- f = concat(f)
- -- io.savedata(filename,f)
- -- f = false
- -- end,
- -- }
- else
- f = io.open(filename,"wb")
- if not f then
- -- message
- os.exit()
- end
- -- f:setvbuf("full",64*1024)
- local m = getmetatable(f)
- flush = m.write or m.__index.write
- close = m.close or m.__index.close
- end
- local v = f_pdf(majorversion,minorversion)
- -- local b = "%\xCC\xD5\xC1\xD4\xC5\xD8\xD0\xC4\xC6\010" -- LUATEXPDF (+128)
- local b = "%\xC3\xCF\xCE\xD4\xC5\xD8\xD4\xD0\xC4\xC6\010" -- CONTEXTPDF (+128)
- flush(f,v)
- flush(f,b)
- offset = #v + #b
- end
-
- closefile = function(abort)
- if abort then
- f:close()
- f = io.open(abort,"wb")
- if f then
- local name = resolvers.findfile("context-lmtx-error.pdf")
- if name then
- local data = io.loaddata(name)
- if data then
- f:write(data)
- f:close()
- return
- end
- end
- f:close()
- removefile(abort)
- end
- else
- local xrefoffset = offset
- local lastfree = 0
- local noffree = 0
- local catalog = lpdf.getcatalog()
- local info = lpdf.getinfo()
- if trailerid == true then
- trailerid = md5HEX(osuuid())
- elseif trailerid and #trailerid > 32 then
- trailerid = md5HEX(trailerid)
- else
- trailerid = false
- end
- if objectstream then
- flushdeferred()
- flushcache()
- --
- xrefoffset = offset
- --
- nofobjects = nofobjects + 1
- objects[nofobjects] = offset -- + 1
- --
- -- combine these three in one doesn't really give less code so
- -- we go for the efficient ones
- --
- local nofbytes = 4
- local c1, c2, c3, c4
- if offset <= 0xFFFF then
- nofbytes = 2
- for i=1,nofobjects do
- local o = objects[i]
- if not o then
- noffree = noffree + 1
- else
- local strm = o < 0
- if strm then
- o = -o
- end
- c1 = extract(o,8,8)
- c2 = extract(o,0,8)
- if strm then
- objects[i] = char(2,c1,c2,streams[o][i])
- else
- objects[i] = char(1,c1,c2,0)
- end
- end
- end
- if noffree > 0 then
- for i=nofobjects,1,-1 do
- local o = objects[i]
- if not o then
- local f1 = extract(lastfree,8,8)
- local f2 = extract(lastfree,0,8)
- objects[i] = char(0,f1,f2,0)
- lastfree = i
- end
- end
- end
- elseif offset <= 0xFFFFFF then
- nofbytes = 3
- for i=1,nofobjects do
- local o = objects[i]
- if not o then
- noffree = noffree + 1
- else
- local strm = o < 0
- if strm then
- o = -o
- end
- c1 = extract(o,16,8)
- c2 = extract(o, 8,8)
- c3 = extract(o, 0,8)
- if strm then
- objects[i] = char(2,c1,c2,c3,streams[o][i])
- else
- objects[i] = char(1,c1,c2,c3,0)
- end
- end
- end
- if noffree > 0 then
- for i=nofobjects,1,-1 do
- local o = objects[i]
- if not o then
- local f1 = extract(lastfree,16,8)
- local f2 = extract(lastfree, 8,8)
- local f3 = extract(lastfree, 0,8)
- objects[i] = char(0,f1,f2,f3,0)
- lastfree = i
- end
- end
- end
- else
- nofbytes = 4
- for i=1,nofobjects do
- local o = objects[i]
- if not o then
- noffree = noffree + 1
- else
- local strm = o < 0
- if strm then
- o = -o
- end
- c1 = extract(o,24,8)
- c2 = extract(o,16,8)
- c3 = extract(o, 8,8)
- c4 = extract(o, 0,8)
- if strm then
- objects[i] = char(2,c1,c2,c3,c4,streams[o][i])
- else
- objects[i] = char(1,c1,c2,c3,c4,0)
- end
- end
- end
- if noffree > 0 then
- for i=nofobjects,1,-1 do
- local o = objects[i]
- if not o then
- local f1 = extract(lastfree,24,8)
- local f2 = extract(lastfree,16,8)
- local f3 = extract(lastfree, 8,8)
- local f4 = extract(lastfree, 0,8)
- objects[i] = char(0,f1,f2,f3,f4,0)
- lastfree = i
- end
- end
- end
- end
- objects[0] = rep("\0",1+nofbytes+1)
- local data = concat(objects,"",0,nofobjects)
- local xref = pdfdictionary {
- Type = pdfconstant("XRef"),
- Size = nofobjects + 1,
- W = pdfarray { 1, nofbytes, 1 },
- Root = catalog,
- Info = info,
- ID = trailerid and pdfarray { pdfliteral(trailerid,true), pdfliteral(trailerid,true) } or nil,
- }
- if compress then
- local comp = zlibcompress(data,3)
- if comp then
- data = comp
- flush(f,f_stream_b_d_c(nofobjects,xref(),#data))
- else
- flush(f,f_stream_b_d_u(nofobjects,xref(),#data))
- end
- else
- flush(f,f_stream_b_d_u(nofobjects,xref(),#data))
- end
- flush(f,data)
- flush(f,s_stream_e)
- flush(f,f_startxref(xrefoffset))
- else
- flushdeferred()
- xrefoffset = offset
- flush(f,f_xref(nofobjects+1))
- local trailer = pdfdictionary {
- Size = nofobjects+1,
- Root = catalog,
- Info = info,
- }
- for i=1,nofobjects do
- local o = objects[i]
- if o then
- objects[i] = f_used(o)
- end
- end
- for i=nofobjects,1,-1 do
- local o = objects[i]
- if not o then
- objects[i] = f_link(lastfree)
- lastfree = i
- end
- end
- objects[0] = f_first(lastfree)
- flush(f,concat(objects,"",0,nofobjects))
- trailer.Size = nofobjects + 1
- if trailerid then
- flush(f,f_trailer_id(trailer(),trailerid,trailerid,xrefoffset))
- else
- flush(f,f_trailer_no(trailer(),xrefoffset))
- end
- end
- f:close()
- end
- io.flush()
- closefile = function() end
- end
-
-end
-
--- For the moment we overload it here, although back-fil.lua eventually will
--- be merged with back-pdf as it's pdf specific, or maybe back-imp-pdf or so.
-
-updaters.register("backend.update.pdf",function()
-
- -- We overload img but at some point it will even go away, so we just
- -- reimplement what we need in context. This will change completely i.e.
- -- we will drop the low level interface!
-
- local codeinjections = backends.pdf.codeinjections
-
- local imagetypes = images.types -- pdf png jpg jp2 jbig2 stream memstream
- local img_none = imagetypes.none
-
- local rulecodes = nodes.rulecodes
-
- local setprop = nodes.nuts.setprop
-
- local report_images = logs.reporter("backend","images")
-
- local lastindex = 0
- local indices = { }
-
- local bpfactor = number.dimenfactors.bp
- local imagerule_code = rulecodes.image
-
- function codeinjections.newimage(specification)
- return specification
- end
-
- function codeinjections.copyimage(original)
- return setmetatableindex(original)
- end
-
- function codeinjections.scanimgage(specification)
- return specification
- end
-
- local function embedimage(specification)
- if specification then
- lastindex = lastindex + 1
- index = lastindex
- specification.index = index
- local xobject = pdfdictionary { }
- if not specification.notype then
- xobject.Type = pdf_xobject
- xobject.Subtype = pdf_form
- xobject.FormType = 1
- end
- local bbox = specification.bbox
- if bbox and not specification.nobbox then
- xobject.BBox = pdfarray {
- bbox[1] * bpfactor,
- bbox[2] * bpfactor,
- bbox[3] * bpfactor,
- bbox[4] * bpfactor,
- }
- end
- xobject = xobject + specification.attr
- if bbox and not specification.width then
- specification.width = bbox[3]
- end
- if bbox and not specification.height then
- specification.height = bbox[4]
- end
- local dict = xobject()
- --
- nofobjects = nofobjects + 1
- local objnum = nofobjects
- local nolength = specification.nolength
- local stream = specification.stream or specification.string
- --
- -- We cannot set type in native img so we need this hack or
- -- otherwise we need to patch too much. Better that i write
- -- a wrapper then. Anyway, it has to be done better: a key that
- -- tells either or not to scale by xsize/ysize when flushing.
- --
- if not specification.type then
- local kind = specification.kind
- if kind then
- -- take that one
- elseif attr and find(attr,"BBox") then
- kind = img_stream
- else
- -- hack: a bitmap
- kind = img_none
- end
- specification.type = kind
- specification.kind = kind
- end
- local compress = compresslevel and compresslevel > 0 or nil
- flushstreamobj(stream,objnum,dict,compress,nolength)
- specification.objnum = objnum
- specification.rotation = specification.rotation or 0
- specification.orientation = specification.orientation or 0
- specification.transform = specification.transform or 0
- specification.stream = nil
- specification.attr = nil
- specification.type = specification.kind or specification.type or img_none
- indices[index] = specification -- better create a real specification
- return specification
- end
- end
-
- codeinjections.embedimage = embedimage
-
- function codeinjections.wrapimage(specification)
- --
- local index = specification.index
- if not index then
- embedimage(specification)
- end
- --
- local width = specification.width or 0
- local height = specification.height or 0
- local depth = specification.depth or 0
- -- newimagerule
- local n = nodes.pool.rule(width,height,depth)
- n.subtype = imagerule_code
- setprop(tonut(n),"index",specification.index)
- return n
- end
-
- function pdf.includeimage(index)
- local specification = indices[index]
- if specification then
- local bbox = specification.bbox
- local xorigin = bbox[1]
- local yorigin = bbox[2]
- local xsize = bbox[3] - xorigin -- we need the original ones, not the 'rotated' ones
- local ysize = bbox[4] - yorigin -- we need the original ones, not the 'rotated' ones
- local transform = specification.transform or 0
- local objnum = specification.objnum or pdfreserveobj()
- local groupref = nil
- local kind = specification.kind or specification.type or img_none -- determines scaling type
- return
- kind,
- xorigin, yorigin,
- xsize, ysize,
- transform,
- objnum,
- groupref
- end
- end
-
-end)
-
-updaters.register("backend.update.lpdf",function()
-
- -- todo: an md5 or sha2 hash can save space
- -- todo: make a type 3 font instead
- -- todo: move to lpdf namespace
-
- local pdfimage = lpdf.epdf.image
- local newpdf = pdfimage.new
- local openpdf = pdfimage.open
- local closepdf = pdfimage.close
- local copypage = pdfimage.copy
-
- local embedimage = images.embed
-
- local nofstreams = 0
- local topdf = { }
- local toidx = { }
-
- local function storedata_s(pdf)
- local idx = toidx[pdf]
- if not idx then
- nofstreams = nofstreams + 1
- idx = nofstreams
- toidx[pdf] = nofstreams
- topdf[idx] = pdf
- end
- return idx
- end
-
- local function vfimage_s(id,wd,ht,dp,pos_h,pos_v)
- local index = topdf[id]
- if type(index) == "string" then
- local pdfdoc = newpdf(index,#index)
- local image = copypage(pdfdoc)
- local bbox = image.bbox
- image.width = bbox[3] - bbox[1]
- image.height = bbox[4] - bbox[2]
- embedimage(image)
- index = image.index
- topdf[id] = index
- end
- -- pdf.print or pdf.literal
- flushimage(index,wd,ht,dp,pos_h,pos_v)
- end
-
- local function storedata_n(name,page)
- local idx = toidx[pdf]
- if not idx then
- nofstreams = nofstreams + 1
- idx = nofstreams
- toidx[pdf] = nofstreams
- topdf[idx] = pdf
- end
- return idx
- end
-
- -- We need to have a way to close such a pdf ... esp for fonts.
-
- local pdfdocs = { }
-
- local function vfimage_n(name,page,wd,ht,dp,pos_h,pos_v)
- local d = pdfdocs[name]
- if not d then
- d = { doc = openpdf(name), pages = { } }
- pdfdocs[name] = d
- end
- local index = d.pages[page]
- if not index then
- local image = copypage(d.doc,page)
- local bbox = image.bbox
- image.width = bbox[3] - bbox[1]
- image.height = bbox[4] - bbox[2]
- embedimage(image)
- index = image.index
- d.pages[page] = index
- end
- flushimage(index,wd,ht,dp,pos_h,pos_v)
- end
-
- local function pdfvfimage(wd,ht,dp,data,name)
- if type(data) == "number" then
- return { "lua", function(font,char,pos_h,pos_v)
- vfimage_n(name,data,wd,ht,dp,pos_h,pos_v)
- end }
- else
- return { "lua", function(font,char,pos_h,pos_v)
- local id = storedata_s(data)
- vfimage_s(id,wd,ht,dp,pos_h,pos_v)
- end }
- end
- end
-
- lpdf.vfimage = pdfvfimage
-
-end)
-
--- The driver.
-
-do
-
- local isfile = lfs.isfile
- local removefile = os.remove
- local renamefile = os.rename
- -- local copyfile = file.copy
- -- local addsuffix = file.addsuffix
- local texgetbox = tex.getbox
-
- local pdfname = nil
- local converter = nil
- local useddriver = nil -- a bit of a hack
-
- local function outputfilename(driver)
- return pdfname
- end
-
- -- todo: prevent twice
-
- local function prepare(driver)
- if not environment.initex then
- -- install new functions in pdf namespace
- updaters.apply("backend.update.pdf")
- -- install new functions in lpdf namespace
- updaters.apply("backend.update.lpdf")
- -- adapt existing shortcuts to lpdf namespace
- updaters.apply("backend.update.tex")
- -- adapt existing shortcuts to tex namespace
- updaters.apply("backend.update")
- --
- -- if rawget(pdf,"setforcefile") then
- -- pdf.setforcefile(false) -- default anyway
- -- end
- --
- pdfname = file.addsuffix(tex.jobname,"pdf")
- openfile(pdfname)
- --
- luatex.registerstopactions(1,function()
- if pdfname then
- lpdf.finalizedocument()
- closefile()
- end
- end)
- --
- luatex.registerpageactions(1,function()
- if pdfname then
- lpdf.finalizepage(true)
- end
- end)
- -- --
- lpdf.registerdocumentfinalizer(wrapup,nil,"wrapping up")
- --
- end
- --
- environment.lmtxmode = CONTEXTLMTXMODE
- --
- converter = drivers.converters.lmtx
- useddriver = driver
- end
-
- local function wrapup(driver)
- if pdfname then
- closefile()
- pdfname = nil
- end
- end
-
- local function cleanup(driver)
- if pdfname then
- closefile(pdfname)
- pdfname = nil
- end
- end
-
- local function convert(driver,boxnumber)
- converter(driver,texgetbox(boxnumber),"page")
- end
-
- localconverter = function(...)
- converter(useddriver,...)
- end
-
- drivers.install {
- name = "pdf",
- flushers = {
- character = flushcharacter,
- fontchar = flushfontchar,
- rule = flushrule,
- simplerule = flushsimplerule,
- pushorientation = pushorientation,
- poporientation = poporientation,
- --
- literal = flushliteral,
- setmatrix = flushsetmatrix,
- save = flushsave,
- restore = flushrestore,
- image = flushimage,
- group = flushgroup,
- --
- updatefontstate = updatefontstate,
- },
- actions = {
- prepare = prepare,
- wrapup = wrapup,
- cleanup = cleanup,
- --
- initialize = initialize,
- convert = convert,
- finalize = finalize,
- --
- outputfilename = outputfilename,
- },
- }
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-mis.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-mis.lua
index 7227f9dba8a..94e9fc2714f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-mis.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-mis.lua
@@ -17,7 +17,8 @@ if not modules then modules = { } end modules ['lpdf-mis'] = {
local next, tostring, type = next, tostring, type
local format, gsub, formatters = string.format, string.gsub, string.formatters
-local flattened = table.flattened
+local concat, flattened = table.concat, table.flattened
+local settings_to_array = utilities.parsers.settings_to_array
local backends, lpdf, nodes = backends, lpdf, nodes
@@ -236,19 +237,13 @@ local function setupidentity()
end
local keywords = identity.keywords or ""
if keywords ~= "" then
- keywords = gsub(keywords, "[%s,]+", " ")
- addtoinfo("Keywords",pdfunicode(keywords), keywords)
+ keywords = concat(settings_to_array(keywords), " ")
+ addtoinfo("Keywords", pdfunicode(keywords), keywords)
end
local id = lpdf.id()
addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
--
addtoinfo("ConTeXt.Version",version)
- --
- local lmtx = codeinjections.lmtxmode()
- if lmtx then
- addtoinfo("ConTeXt.LMTX",formatters["%0.2f"](lmtx))
- end
- --
addtoinfo("ConTeXt.Time",os.date("%Y-%m-%d %H:%M"))
addtoinfo("ConTeXt.Jobname",jobname)
addtoinfo("ConTeXt.Url","www.pragma-ade.com")
@@ -451,7 +446,7 @@ local function documentspecification()
if not pagespec or pagespec == "" then
pagespec = v_default
end
- local settings = utilities.parsers.settings_to_array(pagespec)
+ local settings = settings_to_array(pagespec)
-- so the first one detemines the defaults
local first = settings[1]
local defaults = pagespecs[first]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-pde.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-pde.lua
index ec1064a0dfd..1c80eb5b274 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-pde.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-pde.lua
@@ -48,6 +48,7 @@ local abs = math.abs
local concat, swapped, sortedhash, sortedkeys = table.concat, table.swapped, table.sortedhash, table.sortedkeys
local utfchar = string.char
local setmetatableindex = table.setmetatableindex
+local ioopen = io.open
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
local P, C, S, R, Ct, Cc, V, Carg, Cs, Cf, Cg = lpeg.P, lpeg.C, lpeg.S, lpeg.R, lpeg.Ct, lpeg.Cc, lpeg.V, lpeg.Carg, lpeg.Cs, lpeg.Cf, lpeg.Cg
@@ -67,6 +68,7 @@ local lpdf_epdf = { }
lpdf.epdf = lpdf_epdf
local pdfopen = pdfe.open
+local pdfopenfile = pdfe.openfile
local pdfnew = pdfe.new
local pdfclose = pdfe.close
@@ -440,8 +442,11 @@ function lpdf_epdf.load(filename,userpassword,ownerpassword,fromstring)
if not document then
statistics.starttiming(lpdf_epdf)
local __data__
+ local __file__
if fromstring then
__data__ = pdfnew(filename,#filename)
+ elseif pdfopenfile then
+ __data__ = pdfopenfile(ioopen(filename,"rb"))
else
__data__ = pdfopen(filename)
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-vfc.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-vfc.lua
new file mode 100644
index 00000000000..5c1937ab9a6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-vfc.lua
@@ -0,0 +1,50 @@
+if not modules then modules = { } end modules ['lpdf-vfc'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local bp = number.dimenfactors.bp
+local r = 16384 * bp
+local f_1 = formatters["%.6F w 0 %.6F %.6F %.6F re f"]
+local f_2 = formatters["[] 0 d 0 J %.6F w %.6F %.6F %.6F %.6F re S"]
+
+local vfspecials = backends.pdf.tables.vfspecials
+
+vfspecials.backgrounds = setmetatableindex(function(t,h)
+ local h = h * bp
+ local v = setmetatableindex(function(t,d)
+ local d = d * bp
+ local v = setmetatableindex(function(t,w)
+ local v = { "pdf", "origin", f_1(r,-d,w*bp,h+d) }
+ t[w] = v
+ return v
+ end)
+ t[d] = v
+ return v
+ end)
+ t[h] = v
+ return v
+end)
+
+vfspecials.outlines = setmetatableindex(function(t,h)
+ local h = h * bp
+ local v = setmetatableindex(function(t,d)
+ local d = d * bp
+ local v = setmetatableindex(function(t,w)
+ -- the frame goes through the boundingbox
+ local v = { "pdf", "origin", f_2(r,r/2,-d+r/2,w*bp-r,h+d-r) }
+ t[w] = v
+ return v
+ end)
+ t[d] = v
+ return v
+ end)
+ t[h] = v
+ return v
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-cbk.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-cbk.lua
index d3184e1af77..9fd55f3ecc0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-cbk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-cbk.lua
@@ -333,7 +333,7 @@ nodes (in this case 121049).
The following code is kind of experimental. In the documents
that describe the development of we report
-on speed tests. One observation is thta it sometimes helps to
+on speed tests. One observation is that it sometimes helps to
restart the collector. Okay, experimental code has been removed,
because messing aroudn with the gc is too unpredictable.
--ldx]]--
@@ -347,6 +347,8 @@ local garbagecollector = utilities.garbagecollector
garbagecollector.enabled = false -- could become a directive
garbagecollector.criterium = 4*1024*1024
+-- garbagecollector.enabled = true
+
-- Lua allocates up to 12 times the amount of memory needed for
-- handling a string, and for large binary chunks (like chinese otf
-- files) we get a prominent memory consumption. Even when a variable
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-cnf.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-cnf.lua
index 4939b05c39c..f1690832125 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-cnf.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-cnf.lua
@@ -19,20 +19,79 @@ texconfig.shell_escape = 't'
luatex = luatex or { }
local luatex = luatex
-texconfig.error_line = 79 -- frozen / large values can crash
-texconfig.expand_depth = 10000
-texconfig.half_error_line = 50 -- frozen
-texconfig.hash_extra = 100000
-texconfig.max_in_open = 1000 -- frozen
-texconfig.max_print_line = 100000 -- frozen
-texconfig.max_strings = 500000
-texconfig.nest_size = 1000
-texconfig.param_size = 25000
-texconfig.save_size = 100000
-texconfig.stack_size = 10000
-texconfig.function_size = 32768
-texconfig.properties_size = 10000
-texconfig.fix_mem_init = 750000
+texconfig.error_line = 250
+texconfig.expand_depth = 10000
+texconfig.half_error_line = 125
+texconfig.max_print_line = 100000
+texconfig.max_strings = 500000
+texconfig.hash_extra = 200000
+texconfig.function_size = 32768
+texconfig.properties_size = 10000
+texconfig.level_max = 500
+texconfig.level_chr = 46 -- period
+
+if CONTEXTLMTXMODE > 0 then
+
+texconfig.max_in_open = 2000
+texconfig.nest_size = 10000
+texconfig.param_size = 100000
+texconfig.save_size = 500000
+texconfig.stack_size = 100000
+texconfig.buffer_size = 10000000
+texconfig.token_size = 10000000
+texconfig.node_size = 50000000
+texconfig.max_pool = 10000000
+
+else
+
+texconfig.max_in_open = 1000
+texconfig.nest_size = 1000
+texconfig.param_size = 25000
+texconfig.save_size = 100000
+texconfig.stack_size = 10000
+texconfig.buf_size = 10000000
+texconfig.fix_mem_init = 1000000
+
+end
+
+local variablenames = CONTEXTLMTXMODE > 0 and {
+ error_line = false,
+ half_error_line = false,
+ max_print_line = false,
+ max_in_open = false,
+ expand_depth = true,
+ hash_extra = true,
+ nest_size = true,
+ max_strings = true,
+ max_pool = true,
+ param_size = true,
+ save_size = true,
+ stack_size = true,
+ function_size = true,
+ properties_size = true,
+ token_size = true,
+ node_size = true,
+ buffer_size = true,
+ level_max = true,
+ level_chr = true,
+} or {
+ error_line = false,
+ half_error_line = false,
+ max_print_line = false,
+ max_in_open = false,
+ expand_depth = true,
+ hash_extra = true,
+ nest_size = true,
+ max_strings = true,
+ param_size = true,
+ save_size = true,
+ stack_size = true,
+ function_size = true,
+ properties_size = true,
+ fix_mem_init = true,
+ level_max = true,
+ level_chr = true,
+}
local stub = [[
@@ -68,15 +127,17 @@ function texconfig.init()
},
basictex = {
-- always
- "callback", "font", "lang", "lua", "node", "status", "tex", "texconfig", "texio", "token",
- -- not in luametatex
- "img", "pdf",
+ "callback", "font", "lua", "node", "status", "tex", "texconfig", "texio", "token",
+ -- not in luametatex
+ "img", "pdf", "lang",
+ -- in luametatex
+ "language",
},
extralua = {
-- not in luametatex
"unicode", "utf", "gzip", "zip", "zlib",
-- in luametatex
- "xzip", "xmath", "xcomplex", "basexx",
+ "xzip", "xmath", "xcomplex", "xdecimal", "basexx",
-- maybe some day in luametatex
"lz4", "lzo",
-- always (mime can go)
@@ -201,22 +262,6 @@ end)
-- done, from now on input and callbacks are internal
]]
-local variablenames = {
- error_line = false,
- half_error_line = false,
- max_print_line = false,
- max_in_open = false,
- expand_depth = true,
- hash_extra = true,
- nest_size = true,
- max_strings = true,
- param_size = true,
- save_size = true,
- stack_size = true,
- function_size = true,
- properties_size = true,
-}
-
local function makestub()
name = name or (environment.jobname .. ".lui")
report("creating stub file %a using directives:",name)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-cod.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-cod.lua
index 8d5d65a452a..b3abecbbab4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-cod.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-cod.lua
@@ -20,19 +20,21 @@ local texconfig, lua = texconfig, lua
texconfig.kpse_init = false
texconfig.shell_escape = 't'
-texconfig.error_line = 79 -- frozen / large values can crash
-texconfig.expand_depth = 10000
-texconfig.half_error_line = 50 -- frozen
-texconfig.max_in_open = 1000
-texconfig.max_print_line = 100000
-texconfig.max_strings = 500000
-texconfig.nest_size = 1000
-texconfig.param_size = 25000
-texconfig.save_size = 100000
-texconfig.stack_size = 10000
-texconfig.function_size = 32768
-texconfig.properties_size = 10000
-texconfig.fix_mem_init = 750000
+texconfig.error_line = 250
+texconfig.expand_depth = 10000
+texconfig.half_error_line = 125
+texconfig.max_in_open = 1000
+texconfig.max_print_line = 100000
+texconfig.max_strings = 500000
+texconfig.nest_size = 1000
+texconfig.param_size = 25000
+texconfig.save_size = 100000
+texconfig.stack_size = 10000
+texconfig.function_size = 32768
+texconfig.properties_size = 10000
+texconfig.fix_mem_init = 1000000
+texconfig.level_max = 500
+texconfig.level_chr = 46 -- period
-- registering bytecode chunks
@@ -59,9 +61,6 @@ local strip = false if arg then for i=-1,#arg do if arg[i] == "--c:strip" then s
function lua.registercode(filename,options)
local barename = gsub(filename,"%.[%a%d]+$","")
- if barename == filename then
- filename = filename .. ".lua"
- end
local basename = match(barename,"^.+[/\\](.-)$") or barename
if not bytedone[basename] then
local opts = { }
@@ -70,10 +69,13 @@ function lua.registercode(filename,options)
opts[s] = true
end
end
+ if barename == filename then
+ filename = filename .. ".lua"
+ end
local code = environment.luafilechunk(filename,false,opts.optimize)
if code then
bytedone[basename] = true
- if environment.initex then
+ if environment.initex and not opts.initexonly then
local n = lua.lastbytecode + 1
bytedata[n] = { name = barename, options = opts }
if strip or opts.strip then
@@ -142,7 +144,7 @@ if LUATEXVERSION == nil then
end
if CONTEXTLMTXMODE == nil then
- CONTEXTLMTXMODE = LUATEXENGINE == "luametatex" and 1 or 0
+ CONTEXTLMTXMODE = 0
end
if LUATEXFUNCTIONALITY == nil then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-cod.mkiv b/Master/texmf-dist/tex/context/base/mkiv/luat-cod.mkiv
index 823b918c3bd..e7d58e8abe7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-cod.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-cod.mkiv
@@ -15,8 +15,8 @@
\unprotect
-%D We cannot use the following due to the fact that existing usage
-%D demanded duplicating hashes.
+%D We cannot use the following due to the fact that existing usage demanded
+%D duplicating hashes.
%D
%D \starttyping
%D \def\expanded#1{\normalexpanded{\noexpand#1}} % ## mess
@@ -24,10 +24,9 @@
\newif\ifproductionrun
-%D Originally we compiled the \LUA\ files externally and loaded
-%D then at runtime, but when the amount grew, we realized that
-%D we needed away to store them in the format, which is what
-%D bytecode arrays do. And so the following is obsolete:
+%D Originally we compiled the \LUA\ files externally and loaded then at runtime, but
+%D when the amount grew, we realized that we needed away to store them in the
+%D format, which is what bytecode arrays do. And so the following is obsolete:
%D
%D \starttyping
%D \setnewconstant\ctxluaembeddingmode \plusone
@@ -36,16 +35,15 @@
%D 1 = runtime compilation and embedding
%D \stoptyping
%D
-%D Allocation of \LUA\ engines has changed too. The original idea
-%D was to have multiple \LUA\ instances and it worked that way for
-%D several years. Hoewver in practice we used only one engine because
-%D scripts need to share data anyway. So eventually \LUATEX\ got only
-%D one instance. Because each call is reentrant there is not much
-%D danger for crashes.
+%D Allocation of \LUA\ engines has changed too. The original idea was to have
+%D multiple \LUA\ instances and it worked that way for several years. Hoewver in
+%D practice we used only one engine because scripts need to share data anyway. So
+%D eventually \LUATEX\ got only one instance. Because each call is reentrant there
+%D is not much danger for crashes.
%D
-%D Most code here has changed after version 0.60 as part of adaption to
-%D new functionality. We no longer support the hooks for initializing
-%D code as this can be done at the \LUA\ end.
+%D Most code here has changed after version 0.60 as part of adaption to new
+%D functionality. We no longer support the hooks for initializing code as this can
+%D be done at the \LUA\ end.
% we can drop the \zerocount as it's default
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-env.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-env.lua
index 1620a26e521..edf127765a8 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-env.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-env.lua
@@ -38,14 +38,6 @@ local mt = {
else
return "unknown"
end
- elseif k == "kind" then
- local kind = texgettoks and texgettoks("contextkindtoks")
- if kind and kind ~= "" then
- rawset(environment,"kind",kind)
- return kind
- else
- return "unknown"
- end
elseif k == "jobname" or k == "formatname" then
local name = tex and tex[k]
if name or name== "" then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-fio.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-fio.lua
index 26db46a88ab..2418eec1b59 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-fio.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-fio.lua
@@ -8,7 +8,6 @@ if not modules then modules = { } end modules ['luat-fio'] = {
local format = string.format
local concat = table.concat
-local sequenced = table.sequenced
texconfig.kpse_init = false
texconfig.shell_escape = 't'
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-fmt.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-fmt.lua
index 538556ed282..fe97cf604b9 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-fmt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-fmt.lua
@@ -6,6 +6,15 @@ if not modules then modules = { } end modules ['luat-fmt'] = {
license = "see context related readme files"
}
+-- The original idea was to have a generic format builder and as a result the code
+-- here (and some elsewhere) is bit more extensive that we really need for context.
+-- For instance, in the real beginning we had runtime loading because we had no
+-- bytecode registers yet. We also had multiple files as stubs and the context.lus
+-- file specified these. More than a decade only the third method was used, just
+-- loading luat-cod, so in the end we could get rid of the lus file. In due time
+-- I'll strip the code here because something generic will never take of and we
+-- moved on to luametatex anyway.
+
local format = string.format
local concat = table.concat
local quoted = string.quoted
@@ -13,9 +22,6 @@ local luasuffixes = utilities.lua.suffixes
local report_format = logs.reporter("resolvers","formats")
--- this is a bit messy: we also handle flags in mtx-context so best we
--- can combine this some day (all here)
-
local function primaryflags(arguments)
local flags = { }
if arguments.silent then
@@ -58,7 +64,7 @@ end
-- The silent option is for Taco. It's a bit of a hack because we cannot yet mess
-- with directives. In fact, I could probably clean up the maker a bit by now.
-local template = [[--ini %primaryflags% --lua=%luafile% %texfile% %secondaryflags% %dump% %redirect%]]
+local template = [[--ini %primaryflags% --lua=%luafile% %texfile% %secondaryflags% %redirect%]]
local checkers = {
primaryflags = "verbose", -- "flags"
@@ -66,21 +72,20 @@ local checkers = {
luafile = "readable", -- "cache"
texfile = "readable", -- "cache"
redirect = "string",
- dump = "string",
binarypath = "string",
}
local runners = {
- luatex = sandbox.registerrunner {
- name = "make luatex format",
- program = "luatex",
+ luametatex = sandbox.registerrunner {
+ name = "make luametatex format",
+ program = "luametatex",
template = template,
checkers = checkers,
reporter = report_format,
},
- luametatex = sandbox.registerrunner {
- name = "make luametatex format",
- program = "luametatex",
+ luatex = sandbox.registerrunner {
+ name = "make luatex format",
+ program = "luatex",
template = template,
checkers = checkers,
reporter = report_format,
@@ -94,6 +99,18 @@ local runners = {
},
}
+local stubfiles = {
+ luametatex = "luat-cod.lmt",
+ luatex = "luat-cod.lua",
+ luajittex = "luat-cod.lua",
+}
+
+local suffixes = {
+ luametatex = "mkxl",
+ luatex = "mkiv",
+ luajittex = "mkiv",
+}
+
local function validbinarypath()
-- if environment.arguments.addbinarypath then
if not environment.arguments.nobinarypath then
@@ -107,137 +124,75 @@ local function validbinarypath()
end
end
+local function fatalerror(startupdir,...)
+ report_format(...)
+ lfs.chdir(startupdir)
+end
+
function environment.make_format(formatname)
- -- first we set up the engine and normally that information is provided
- -- by the engine ... when we move to luametatex we could decide to simplfy
- -- all the following
- local arguments = environment.arguments
- local engine = environment.ownmain or "luatex"
- local silent = arguments.silent
- local errors = arguments.errors
+ local arguments = environment.arguments
+ local engine = environment.ownmain or "luatex"
+ local silent = arguments.silent
+ local errors = arguments.errors
+ local runner = runners[engine]
+ local startupdir = dir.current()
+ if not runner then
+ return fatalerror(startupdir,"the format %a cannot be generated, no runner available for engine %a",name,engine)
+ end
-- now we locate the to be used source files ... there are some variants that we
-- need to take care
- local texsourcename = ""
- local texsourcepath = ""
- local fulltexsourcename = ""
- if engine == "luametatex" then
- texsourcename = file.addsuffix(formatname,"mkxl")
- fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
- end
- if fulltexsourcename == "" then
- texsourcename = file.addsuffix(formatname,"mkiv")
- fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
+ local luasourcename = stubfiles[engine]
+ if not luasourcename then
+ return fatalerror(startupdir,"no lua stub file specified for %a",engine)
end
+ local texsourcename = file.addsuffix(formatname,suffixes[engine])
+ local fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
if fulltexsourcename == "" then
- texsourcename = file.addsuffix(formatname,"tex")
- fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
+ return fatalerror(startupdir,"no tex source file with name %a (mkiv or tex)",formatname)
end
- if fulltexsourcename == "" then
- report_format("no tex source file with name %a (mkiv or tex)",formatname)
- return
- end
- report_format("using tex source file %a",fulltexsourcename)
-- this is tricky: we normally have an expanded path but when we don't have one,
-- the current path gets appended
- fulltexsourcename = dir.expandname(fulltexsourcename)
- texsourcepath = file.dirname(fulltexsourcename)
- if not lfs.isfile(fulltexsourcename) then
- report_format("no accessible tex source file with name %a",fulltexsourcename)
- return
+ local fulltexsourcename = dir.expandname(fulltexsourcename)
+ local texsourcepath = file.dirname(fulltexsourcename)
+ if lfs.isfile(fulltexsourcename) then
+ report_format("using tex source file %a",fulltexsourcename)
+ else
+ return fatalerror(startupdir,"no accessible tex source file with name %a",fulltexsourcename)
end
-- we're getting there, that is: we have a file that specifies the context format;
-- in addition to that file we need a stub for setting up lua as we start rather
- -- minimalistic
- local specificationname = "context.lus"
- local specificationpath = ""
- local fullspecificationname = resolvers.findfile(specificationname) or ""
- if fullspecificationname == "" then
- report_format("unable to locate specification file %a",specificationname)
- return
- end
- report_format("using specification file %a",fullspecificationname)
- -- let's expand the found name and so an extra check
- fullspecificationname = dir.expandname(fullspecificationname)
- specificationpath = file.dirname(fullspecificationname)
- if texsourcepath ~= specificationpath then
- report_format("tex source file and specification file are on different paths")
- return
- end
- -- let's do an additional check here, if only because we then have a bit better
- -- feedback on what goes wrong
- if not lfs.isfile(fulltexsourcename) then
- report_format("no accessible tex source file with name %a",fulltexsourcename)
- return
- end
- if not lfs.isfile(fullspecificationname) then
- report_format("no accessible specification file with name %a",fulltexsourcename)
- return
+ -- minimalistic ..
+ local fullluasourcename = dir.expandname(file.join(texsourcepath,luasourcename) or "")
+ if lfs.isfile(fullluasourcename) then
+ report_format("using lua stub file %a",fullluasourcename)
+ else
+ return fatalerror(startupdir,"no accessible lua stub file with name %a",fulltexsourcename)
end
- -- we're still going strong
- report_format("using tex source path %a",texsourcepath)
-- we will change tot the format path because some local files will be created
-- in the process and we don't want clutter
local validformatpath = caches.getwritablepath("formats",engine) or ""
- local startupdir = dir.current()
if validformatpath == "" then
- report_format("invalid format path, insufficient write access")
- return
+ return fatalerror(startupdir,"invalid format path, insufficient write access")
end
-- in case we have a qualified path, we need to do this before we change
-- because we can have half qualified paths (in lxc)
local binarypath = validbinarypath()
report_format("changing to format path %a",validformatpath)
- lfs.chdir(validformatpath)
- if dir.current() ~= validformatpath then
- report_format("unable to change to format path %a",validformatpath)
- return
- end
- -- we're now ready for making the format which we do on the first found
- -- writable path
- local usedluastub = nil
- local usedlualibs = dofile(fullspecificationname)
- if type(usedlualibs) == "string" then
- usedluastub = file.join(specificationpath,usedlualibs)
- elseif type(usedlualibs) == "table" then
- report_format("using stub specification %a",fullspecificationname)
- local texbasename = file.basename(name)
- local luastubname = file.addsuffix(texbasename,luasuffixes.lua)
- local lucstubname = file.addsuffix(texbasename,luasuffixes.luc)
- -- pack libraries in stub
- report_format("creating initialization file %a",luastubname)
- utilities.merger.selfcreate(usedlualibs,specificationpath,luastubname)
- -- compile stub file (does not save that much as we don't use this stub at startup any more)
- if utilities.lua.compile(luastubname,lucstubname) and lfs.isfile(lucstubname) then
- report_format("using compiled initialization file %a",lucstubname)
- usedluastub = lucstubname
- else
- report_format("using uncompiled initialization file %a",luastubname)
- usedluastub = luastubname
- end
- else
- report_format("invalid stub specification %a",fullspecificationname)
- lfs.chdir(startupdir)
- return
- end
- -- we're ready to go now but first we check if we actually do have a runner
- -- for this engine ... we'd better have one
- local runner = runners[engine]
- if not runner then
- report_format("the format %a cannot be generated, no runner available for engine %a",name,engine)
- lfs.chdir(startupdir)
- return
+ -- lfs.chdir(validformatpath)
+ -- if dir.current() ~= validformatpath then
+ if not lfs.chdir(validformatpath) then
+ return fatalerror(startupdir,"unable to change to format path %a",validformatpath)
end
-- now we can generate the format, where we use a couple of flags,
-- split into two categories
local primaryflags = primaryflags(arguments)
local secondaryflags = secondaryflags(arguments)
- local specification = {
+ local specification = {
binarypath = binarypath,
primaryflags = primaryflags,
secondaryflags = secondaryflags,
- luafile = quoted(usedluastub),
+ luafile = quoted(fullluasourcename),
texfile = quoted(fulltexsourcename),
- dump = os.platform == "unix" and "\\\\dump" or "\\dump",
}
if silent then
specification.redirect = "> temp.log"
@@ -255,7 +210,7 @@ function environment.make_format(formatname)
end
report_format("format path : %s",validformatpath)
report_format("luatex engine : %s",engine)
- report_format("lua startup file : %s",usedluastub)
+ report_format("lua startup file : %s",fullluasourcename)
if primaryflags ~= "" then
report_format("primary flags : %s",primaryflags)
end
@@ -342,9 +297,9 @@ function environment.run_format(formatname,scriptname,filename,primaryflags,seco
luafile = quoted(scriptname),
texfile = filename ~= "" and quoted(filename) or "",
}
- statistics.starttiming()
+ statistics.starttiming("make format")
local result = runner(specification)
- local runtime = statistics.stoptiming()
+ statistics.stoptiming("make format")
if verbose then
report_format()
if binarypath and binarypath ~= "" then
@@ -362,7 +317,7 @@ function environment.run_format(formatname,scriptname,filename,primaryflags,seco
if secondaryflags ~= "" then
report_format("secondary flags : %s",secondaryflags)
end
- report_format("run time : %.3f seconds",runtime)
+ report_format("run time : %0.3f seconds",statistics.elapsed("make format"))
report_format("return value : %s",result == 0 and "okay" or "error")
report_format()
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-ini.lua
index cec0161e7b0..dcca8cec7a8 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-ini.lua
@@ -25,21 +25,15 @@ if not global then
global = _G
end
-LUATEXVERSION = status.luatex_version/100
- + tonumber(status.luatex_revision)/10000
-
-LUATEXENGINE = status.luatex_engine and string.lower(status.luatex_engine)
- or (string.find(status.banner,"LuajitTeX",1,true) and "luajittex" or "luatex")
-
+LUATEXVERSION = status.luatex_version/100 + tonumber(status.luatex_revision)/10000
+LUATEXENGINE = status.luatex_engine and string.lower(status.luatex_engine) or "luametatex"
LUATEXFUNCTIONALITY = status.development_id or 6346
-
LUATEXFORMATID = status.format_id or 0
+JITSUPPORTED = false
+INITEXMODE = status.run_state == 0 -- initializing updating production
+CONTEXTLMTXMODE = 0
-JITSUPPORTED = LUATEXENGINE == "luajittex" or jit
-
-INITEXMODE = status.ini_version
-
-CONTEXTLMTXMODE = CONTEXTLMTXMODE or (LUATEXENGINE == "luametatex" and 1) or 0
+status.ini_version = INITEXMODE -- for a while
function os.setlocale()
-- no need for a message
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/luat-ini.mkiv
index d1d829be978..09014ad86cd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-ini.mkiv
@@ -34,7 +34,7 @@
% the \type {\normalexpanded} around \type {\directlua}. Something to discuss
% in the team.
-\normalprotected\def\startlua % \stoplua
+\protected\def\startlua % \stoplua
{\begingroup
\obeylualines
\luat_start_lua_indeed}
@@ -42,7 +42,7 @@
\def\luat_start_lua_indeed#1\stoplua
{\normalexpanded{\endgroup\noexpand\directlua{#1}}} % \zerocount is default
-\normalprotected\def\startluacode % \stopluacode
+\protected\def\startluacode % \stopluacode
{\begingroup
\obeylualines
\obeyluatokens
@@ -77,24 +77,28 @@
\edef\lua_letter_seven {\string\7} \edef\lua_letter_eight {\string\8}
\edef\lua_letter_nine {\string\9} \edef\lua_letter_zero {\string\0}
+\pushoverloadmode
+ \let\-\explicitdiscretionary
+\popoverloadmode
+
\everyluacode {% \appendtoks
- \let\\\lua_letter_backslash
- \let\|\lua_letter_bar \let\-\lua_letter_dash
- \let\(\lua_letter_lparent \let\)\lua_letter_rparent
- \let\{\lua_letter_lbrace \let\}\lua_letter_rbrace
- \let\'\lua_letter_squote \let\"\lua_letter_dquote
- \let\n\lua_letter_n \let\r\lua_letter_r
- \let\f\lua_letter_f \let\t\lua_letter_t
- \let\a\lua_letter_a \let\b\lua_letter_b
- \let\v\lua_letter_v \let\s\lua_letter_s
- \let\1\lua_letter_one \let\2\lua_letter_two
- \let\3\lua_letter_three \let\4\lua_letter_four
- \let\5\lua_letter_five \let\6\lua_letter_six
- \let\7\lua_letter_seven \let\8\lua_letter_eight
- \let\9\lua_letter_nine \let\0\lua_letter_zero
+ \enforced\let\\\lua_letter_backslash
+ \enforced\let\|\lua_letter_bar \enforced\let\-\lua_letter_dash
+ \enforced\let\(\lua_letter_lparent \enforced\let\)\lua_letter_rparent
+ \enforced\let\{\lua_letter_lbrace \enforced\let\}\lua_letter_rbrace
+ \enforced\let\'\lua_letter_squote \enforced\let\"\lua_letter_dquote
+ \enforced\let\n\lua_letter_n \enforced\let\r\lua_letter_r
+ \enforced\let\f\lua_letter_f \enforced\let\t\lua_letter_t
+ \enforced\let\a\lua_letter_a \enforced\let\b\lua_letter_b
+ \enforced\let\v\lua_letter_v \enforced\let\s\lua_letter_s
+ \enforced\let\1\lua_letter_one \enforced\let\2\lua_letter_two
+ \enforced\let\3\lua_letter_three \enforced\let\4\lua_letter_four
+ \enforced\let\5\lua_letter_five \enforced\let\6\lua_letter_six
+ \enforced\let\7\lua_letter_seven \enforced\let\8\lua_letter_eight
+ \enforced\let\9\lua_letter_nine \enforced\let\0\lua_letter_zero
} % \to \everyluacode
-\normalprotected\def\obeyluatokens
+\protected\def\obeyluatokens
{\setcatcodetable\luacatcodes
\the\everyluacode}
@@ -121,13 +125,12 @@
%D \edef\luaescapestring#1{\!!bs#1\!!es}
%D \stoptyping
-\def\setdocumentfilename #1#2{\clf_setdocumentfilename\numexpr#1\relax{#2}}
-\def\setdocumentargument #1#2{\clf_setdocumentargument{#1}{#2}}
-\def\setdocumentargumentdefault#1#2{\clf_setdocumentdefaultargument{#1}{#2}}
-\def\getdocumentfilename #1{\clf_getdocumentfilename\numexpr#1\relax}
-\def\getdocumentargument #1{\clf_getdocumentargument{#1}{}}
-\def\setdocumentargument #1#2{\clf_setdocumentargument{#1}{#2}}
-\def\getdocumentargumentdefault#1#2{\clf_getdocumentargument{#1}{#2}}
+\protected\def\setdocumentfilename #1#2{\clf_setdocumentfilename\numexpr#1\relax{#2}}
+\protected\def\setdocumentargument #1#2{\clf_setdocumentargument{#1}{#2}}
+\protected\def\setdocumentargumentdefault#1#2{\clf_setdocumentdefaultargument{#1}{#2}}
+ \def\getdocumentfilename #1{\clf_getdocumentfilename\numexpr#1\relax}
+ \def\getdocumentargument #1{\clf_getdocumentargument{#1}{}}
+ \def\getdocumentargumentdefault#1#2{\clf_getdocumentargument{#1}{#2}}
% seldom used so no need for speedy variants:
@@ -147,7 +150,7 @@
%D Experimental:
-\normalprotected\def\startluaparameterset[#1]%
+\protected\def\startluaparameterset[#1]%
{\begingroup
\obeylualines
\obeyluatokens
@@ -186,7 +189,7 @@
%D \ctxluacode{context("%0.5f",1/3)}
%D \stoptyping
-\normalprotected\def\ctxluacode
+\protected\def\ctxluacode
{\begingroup
\obeylualines
\obeyluatokens
@@ -217,7 +220,7 @@
\installsystemnamespace{ctxfunction}
-\normalprotected\def\startctxfunctiondefinition #1 %
+\protected\def\startctxfunctiondefinition #1 %
{\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_definition_indeed{#1}}
\installsystemnamespace{luafunction}
@@ -227,13 +230,13 @@
\expandafter\chardef\csname\??luafunction#1\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax
\expandafter\edef\csname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}}
-\normalprotected\def\setctxluafunction#1#2% experiment
+\protected\def\setctxluafunction#1#2% experiment
{\expandafter\chardef\csname\??luafunction#1\endcsname#2\relax
\expandafter\edef\csname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}}
\let\stopctxfunctiondefinition\relax
-\normalprotected\def\startctxfunction #1 %
+\protected\def\startctxfunction #1 %
{\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_indeed{#1}}
\def\luat_start_lua_function_indeed#1#2\stopctxfunction
@@ -267,23 +270,23 @@
% \ifdefined\normalluadef
- \normalprotected\def\installctxfunction#1#2% expandable
+ \protected\def\installctxfunction#1#2% expandable
{\edef\m_syst_name{\csstring#1}%
\global\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax}
- \normalprotected\def\installctxscanner#1#2% expandable
+ \protected\def\installctxscanner#1#2% expandable
{\edef\m_syst_name{\csstring#1}%
\global\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax}
- \normalprotected\def\installprotectedctxfunction#1#2% protected
+ \protected\def\installprotectedctxfunction#1#2% protected
{\edef\m_syst_name{\csstring#1}%
- \global\normalprotected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax}
+ \global\protected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax}
- \normalprotected\def\installprotectedctxscanner#1#2% protected
+ \protected\def\installprotectedctxscanner#1#2% protected
{\edef\m_syst_name{\csstring#1}%
- \global\normalprotected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax}
+ \global\protected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax}
- \normalprotected\def\resetctxscanner#1%
+ \protected\def\resetctxscanner#1%
{\edef\m_syst_name{\csstring#1}%
\expandafter\glet\csname\m_syst_name\endcsname\relax}
@@ -295,53 +298,53 @@
% \else
%
% \ifdefined\luafunctioncall \else
-% \normalprotected\def\luafunctioncall{\luafunction}
+% \protected\def\luafunctioncall{\luafunction}
% \fi
%
-% \normalprotected\def\installctxfunction#1#2% expandable
+% \protected\def\installctxfunction#1#2% expandable
% {\edef\m_syst_name{\csstring#1}%
% \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxfunction("#2",true)}\relax
% \expandafter\xdef\csname\m_syst_name\endcsname{\noexpand\luafunction\csname\??luafunction\m_syst_name\endcsname}}
%
-% \normalprotected\def\installctxscanner#1#2% expandable
+% \protected\def\installctxscanner#1#2% expandable
% {\edef\m_syst_name{\csstring#1}%
% \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name","#2",true)}\relax
% \expandafter\xdef\csname\m_syst_name\endcsname{\noexpand\luafunction\csname\??luafunction\m_syst_name\endcsname}}
%
-% \normalprotected\def\installprotectedctxfunction#1#2% protected
+% \protected\def\installprotectedctxfunction#1#2% protected
% {\edef\m_syst_name{\csstring#1}%
% \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxfunction("#2",true)}\relax
% \expandafter\xdef\csname\m_syst_name\endcsname{\noexpand\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
%
-% \normalprotected\def\installprotectedctxscanner#1#2% protected
+% \protected\def\installprotectedctxscanner#1#2% protected
% {\edef\m_syst_name{\csstring#1}%
% \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name","#2",true)}\relax
% \expandafter\xdef\csname\m_syst_name\endcsname{\noexpand\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
%
-% \normalprotected\def\resetctxscanner#1%
+% \protected\def\resetctxscanner#1%
% {\edef\m_syst_name{\csstring#1}%
% \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\zerocount
% \expandafter\glet\csname\m_syst_name\endcsname\relax}
%
-% % \normalprotected\def\installctxfunctioncall#1#2%
+% % \protected\def\installctxfunctioncall#1#2%
% % {\edef\m_syst_name{\csstring#1}%
% % \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxfunction("#2",true)}\relax
% % \expandafter\xdef\csname\m_syst_name\endcsname{\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
% %
-% % \normalprotected\def\installctxscannercall#1#2%
+% % \protected\def\installctxscannercall#1#2%
% % {\edef\m_syst_name{\csstring#1}%
% % \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name","#2",true)}\relax
% % \expandafter\xdef\csname\m_syst_name\endcsname{\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
% %
-% % \normalprotected\def\installprotectedctxfunctioncall#1#2%
+% % \protected\def\installprotectedctxfunctioncall#1#2%
% % {\edef\m_syst_name{\csstring#1}%
% % \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxfunction("#2",true)}\relax
-% % \normalprotected\expandafter\xdef\csname\m_syst_name\endcsname{\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
+% % \protected\expandafter\xdef\csname\m_syst_name\endcsname{\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
% %
-% % \normalprotected\def\installprotectedctxscannercall#1#2%
+% % \protected\def\installprotectedctxscannercall#1#2%
% % {\edef\m_syst_name{\csstring#1}%
% % \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name","#2",true)}\relax
-% % \normalprotected\expandafter\xdef\csname\m_syst_name\endcsname{\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
+% % \protected\expandafter\xdef\csname\m_syst_name\endcsname{\luafunctioncall\csname\??luafunction\m_syst_name\endcsname}}
%
% \fi
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-lib.mkiv b/Master/texmf-dist/tex/context/base/mkiv/luat-lib.mkiv
index 0ffd1dd4076..6dbcdaf54a3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-lib.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-lib.mkiv
@@ -24,8 +24,8 @@
\registerctxluafile{util-dim}{}
\registerctxluafile{trac-set}{}
-\registerctxluafile{trac-log}{}
-\registerctxluafile{trac-inf}{}
+\registerctxluafile{luat-log}{autosuffix}
+\registerctxluafile{trac-inf}{autosuffix}
\registerctxluafile{util-lua}{}
\registerctxluafile{util-deb}{} % could also be done in trac-deb.mkiv
@@ -45,10 +45,6 @@
\registerctxluafile{util-soc-imp-http} {}
\registerctxluafile{util-soc-imp-tp} {}
-\ifcase\contextlmtxmode\else
- \registerctxluafile{util-zip}{}
-\fi
-
\registerctxluafile{data-ini}{}
\registerctxluafile{data-exp}{}
\registerctxluafile{data-env}{}
@@ -73,13 +69,9 @@
\registerctxluafile{data-use}{}
\registerctxluafile{data-aux}{}
-% \ifcase\contextlmtxmode
-% \registerctxluafile{util-lib}{}
-% \fi
-
\registerctxluafile{luat-cbk}{}
\registerctxluafile{luat-run}{}
-\registerctxluafile{luat-fio}{}
+\registerctxluafile{luat-fio}{autosuffix}
\registerctxluafile{luat-cnf}{}
\registerctxluafile{luat-lua}{}
\registerctxluafile{luat-sto}{}
@@ -99,8 +91,8 @@
\registerctxluafile{lxml-aux}{}
\registerctxluafile{lxml-mis}{}
-\normalprotected\def\writestatus#1#2{\ctxlua{logs.status([==[#1]==],[==[#2]==])}}
-\normalprotected\def\writestring #1{\ctxlua{logs.writer([==[#1]==],"\string\n")}}
-\normalprotected\def\writeline {\ctxlua{logs.newline()}}
+\protected\def\writestatus#1#2{\ctxlua{logs.status([==[#1]==],[==[#2]==])}}
+\protected\def\writestring #1{\ctxlua{logs.writer([==[#1]==],"\string\n")}}
+\protected\def\writeline {\ctxlua{logs.newline()}}
\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-log.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-log.lua
new file mode 100644
index 00000000000..8bfec8d218e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-log.lua
@@ -0,0 +1,795 @@
+if not modules then modules = { } end modules ['luat-log'] = {
+ version = 1.001,
+ comment = "companion to trac-log.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- In fact all writes could go through lua and we could write the console and
+-- terminal handler in lua then. Ok, maybe it's slower then, so a no-go.
+
+-- This used to be combined in trac-log but as we also split between mkiv and lmtx
+-- we now have dedicated files. A side effect is a smaller format and a smaller
+-- mtxrun.
+
+local next, type, select, print = next, type, select, print
+local format, gmatch, find = string.format, string.gmatch, string.find
+local concat, insert, remove = table.concat, table.insert, table.remove
+local topattern = string.topattern
+local utfchar = utf.char
+local datetime = os.date
+local openfile = io.open
+
+local write_nl = texio and texio.write_nl
+local write = texio and texio.write
+
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+local settings_to_hash = utilities.parsers.settings_to_hash
+local sortedkeys = table.sortedkeys
+
+-- variant is set now
+
+local variant = "default"
+----- variant = "ansi"
+
+logs = logs or { }
+local logs = logs
+
+-- we extend the formatters:
+
+formatters.add (
+ formatters, "unichr",
+ [["U+" .. format("%%05X",%s) .. " (" .. utfchar(%s) .. ")"]]
+)
+
+formatters.add (
+ formatters, "chruni",
+ [[utfchar(%s) .. " (U+" .. format("%%05X",%s) .. ")"]]
+)
+
+-- basic loggers
+
+local function ignore() end
+
+setmetatableindex(logs, function(t,k) t[k] = ignore ; return ignore end)
+
+local report, subreport, status, settarget, setformats, settranslations
+
+local direct, subdirect, writer, pushtarget, poptarget, setlogfile, settimedlog, setprocessor, setformatters, newline
+
+-- we use formatters but best check for % then because for simple messages but
+-- we don't want this overhead for single messages (not that there are that
+-- many; we could have a special weak table)
+
+local function ansisupported(specification)
+ if specification ~= "ansi" and specification ~= "ansilog" then
+ return false
+ elseif os and os.enableansi then
+ return os.enableansi()
+ else
+ return false
+ end
+end
+
+do
+
+ if texio.setescape then
+ texio.setescape(0) -- or (false)
+ end
+
+ if arg and ansisupported then
+ -- we're don't have environment.arguments yet
+ for k, v in next, arg do -- k can be negative !
+ if v == "--ansi" or v == "--c:ansi" then
+ if ansisupported("ansi") then
+ variant = "ansi"
+ end
+ break
+ elseif v == "--ansilog" or v == "--c:ansilog" then
+ if ansisupported("ansilog") then
+ variant = "ansilog"
+ end
+ break
+ end
+ end
+ end
+
+ local function useluawrites()
+
+ -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2)
+ -- still needed for luajittex .. luatex should not have that ^^ mess
+
+ local texio_write_nl = texio.write_nl
+ local texio_write = texio.write
+ local io_write = io.write
+
+ write_nl = function(target,...)
+ if not io_write then
+ io_write = io.write
+ end
+ if target == "term and log" then
+ texio_write_nl("log",...)
+ texio_write_nl("term","")
+ io_write(...)
+ elseif target == "log" then
+ texio_write_nl("log",...)
+ elseif target == "term" then
+ texio_write_nl("term","")
+ io_write(...)
+ elseif type(target) == "number" then
+ texio_write_nl(target,...) -- a tex output channel
+ elseif target ~= "none" then
+ texio_write_nl("log",target,...)
+ texio_write_nl("term","")
+ io_write(target,...)
+ end
+ end
+
+ write = function(target,...)
+ if not io_write then
+ io_write = io.write
+ end
+ if target == "term and log" then
+ texio_write("log",...)
+ io_write(...)
+ elseif target == "log" then
+ texio_write("log",...)
+ elseif target == "term" then
+ io_write(...)
+ elseif type(target) == "number" then
+ texio_write(target,...) -- a tex output channel
+ elseif target ~= "none" then
+ texio_write("log",target,...)
+ io_write(target,...)
+ end
+ end
+
+ texio.write = write
+ texio.write_nl = write_nl
+
+ useluawrites = ignore
+
+ end
+
+ -- local format = string.formatter
+
+ local whereto = "both"
+ local target = nil
+ local targets = nil
+
+ local formats = table.setmetatableindex("self")
+ local translations = table.setmetatableindex("self")
+
+ local report_yes, subreport_yes, direct_yes, subdirect_yes, status_yes
+ local report_nop, subreport_nop, direct_nop, subdirect_nop, status_nop
+
+ local variants = {
+ default = {
+ formats = {
+ report_yes = formatters["%-15s > %s\n"],
+ report_nop = formatters["%-15s >\n"],
+ direct_yes = formatters["%-15s > %s"],
+ direct_nop = formatters["%-15s >"],
+ subreport_yes = formatters["%-15s > %s > %s\n"],
+ subreport_nop = formatters["%-15s > %s >\n"],
+ subdirect_yes = formatters["%-15s > %s > %s"],
+ subdirect_nop = formatters["%-15s > %s >"],
+ status_yes = formatters["%-15s : %s\n"],
+ status_nop = formatters["%-15s :\n"],
+ },
+ targets = {
+ logfile = "log",
+ log = "log",
+ file = "log",
+ console = "term",
+ terminal = "term",
+ both = "term and log",
+ },
+ },
+ ansi = {
+ formats = {
+ report_yes = formatters["[0;33m%-15s [0;1m>[0m %s\n"],
+ report_nop = formatters["[0;33m%-15s [0;1m>[0m\n"],
+ direct_yes = formatters["[0;33m%-15s [0;1m>[0m %s"],
+ direct_nop = formatters["[0;33m%-15s [0;1m>[0m"],
+ subreport_yes = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m %s\n"],
+ subreport_nop = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m\n"],
+ subdirect_yes = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m %s"],
+ subdirect_nop = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m"],
+ status_yes = formatters["[0;33m%-15s [0;1m:[0m %s\n"],
+ status_nop = formatters["[0;33m%-15s [0;1m:[0m\n"],
+ },
+ targets = {
+ logfile = "none",
+ log = "none",
+ file = "none",
+ console = "term",
+ terminal = "term",
+ both = "term",
+ },
+ }
+ }
+
+ variants.ansilog = {
+ formats = variants.ansi.formats,
+ targets = variants.default.targets,
+ }
+
+ logs.flush = io.flush
+
+ writer = function(...)
+ write_nl(target,...)
+ end
+
+ newline = function()
+ write_nl(target,"\n")
+ end
+
+ report = function(a,b,c,...)
+ if c ~= nil then
+ write_nl(target,report_yes(translations[a],formatters[formats[b]](c,...)))
+ elseif b then
+ write_nl(target,report_yes(translations[a],formats[b]))
+ elseif a then
+ write_nl(target,report_nop(translations[a]))
+ else
+ write_nl(target,"\n")
+ end
+ end
+
+ direct = function(a,b,c,...)
+ if c ~= nil then
+ return direct_yes(translations[a],formatters[formats[b]](c,...))
+ elseif b then
+ return direct_yes(translations[a],formats[b])
+ elseif a then
+ return direct_nop(translations[a])
+ else
+ return ""
+ end
+ end
+
+ subreport = function(a,s,b,c,...)
+ if c ~= nil then
+ write_nl(target,subreport_yes(translations[a],translations[s],formatters[formats[b]](c,...)))
+ elseif b then
+ write_nl(target,subreport_yes(translations[a],translations[s],formats[b]))
+ elseif a then
+ write_nl(target,subreport_nop(translations[a],translations[s]))
+ else
+ write_nl(target,"\n")
+ end
+ end
+
+ subdirect = function(a,s,b,c,...)
+ if c ~= nil then
+ return subdirect_yes(translations[a],translations[s],formatters[formats[b]](c,...))
+ elseif b then
+ return subdirect_yes(translations[a],translations[s],formats[b])
+ elseif a then
+ return subdirect_nop(translations[a],translations[s])
+ else
+ return ""
+ end
+ end
+
+ status = function(a,b,c,...)
+ if c ~= nil then
+ write_nl(target,status_yes(translations[a],formatters[formats[b]](c,...)))
+ elseif b then
+ write_nl(target,status_yes(translations[a],formats[b]))
+ elseif a then
+ write_nl(target,status_nop(translations[a]))
+ else
+ write_nl(target,"\n")
+ end
+ end
+
+ settarget = function(askedwhereto)
+ whereto = askedwhereto or whereto or "both"
+ target = targets[whereto]
+ if not target then
+ whereto = "both"
+ target = targets[whereto]
+ end
+ if target == "term" or target == "term and log" then
+ logs.flush = io.flush
+ else
+ logs.flush = ignore
+ end
+ end
+
+ local stack = { }
+
+ pushtarget = function(newtarget)
+ insert(stack,target)
+ settarget(newtarget)
+ end
+
+ poptarget = function()
+ if #stack > 0 then
+ settarget(remove(stack))
+ end
+ end
+
+ setformats = function(f)
+ formats = f
+ end
+
+ settranslations = function(t)
+ translations = t
+ end
+
+ setprocessor = function(f)
+ local writeline = write_nl
+ write_nl = function(target,...)
+ writeline(target,f(...))
+ end
+ end
+
+ setformatters = function(specification)
+ local t = nil
+ local f = nil
+ local d = variants.default
+ if not specification then
+ --
+ elseif type(specification) == "table" then
+ t = specification.targets
+ f = specification.formats or specification
+ else
+ if not ansisupported(specification) then
+ specification = "default"
+ end
+ local v = variants[specification]
+ if v then
+ t = v.targets
+ f = v.formats
+ variant = specification
+ end
+ end
+ targets = t or d.targets
+ target = targets[whereto] or target
+ if f then
+ d = d.formats
+ else
+ f = d.formats
+ d = f
+ end
+ setmetatableindex(f,d)
+ report_yes = f.report_yes
+ report_nop = f.report_nop
+ subreport_yes = f.subreport_yes
+ subreport_nop = f.subreport_nop
+ direct_yes = f.direct_yes
+ direct_nop = f.direct_nop
+ subdirect_yes = f.subdirect_yes
+ subdirect_nop = f.subdirect_nop
+ status_yes = f.status_yes
+ status_nop = f.status_nop
+ if variant == "ansi" or variant == "ansilog" then
+ useluawrites() -- because tex escapes ^^, not needed in lmtx
+ end
+ settarget(whereto)
+ end
+
+ setformatters(variant)
+
+ setlogfile = ignore
+ settimedlog = ignore
+
+ -- settimedlog = function()
+ -- local localtime = os.localtime
+ -- local writeline = write_nl
+ -- write_nl = function(f,...)
+ -- writeline(f,localtime() .. " | " .. concat { ... })
+ -- end
+ -- settimedlog = ignore
+ -- end
+
+end
+
+logs.report = report
+logs.subreport = subreport
+logs.status = status
+logs.settarget = settarget
+logs.pushtarget = pushtarget
+logs.poptarget = poptarget
+logs.setformats = setformats
+logs.settranslations = settranslations
+
+logs.setlogfile = setlogfile
+logs.settimedlog = settimedlog
+logs.setprocessor = setprocessor
+logs.setformatters = setformatters
+
+logs.direct = direct
+logs.subdirect = subdirect
+logs.writer = writer
+logs.newline = newline
+
+local data = { }
+local states = nil
+local force = false
+
+function logs.reporter(category,subcategory)
+ local logger = data[category]
+ if not logger then
+ local state = states == true
+ if not state and type(states) == "table" then
+ for c, _ in next, states do
+ if find(category,c) then
+ state = true
+ break
+ end
+ end
+ end
+ logger = {
+ reporters = { },
+ state = state,
+ }
+ data[category] = logger
+ end
+ local reporter = logger.reporters[subcategory or "default"]
+ if not reporter then
+ if subcategory then
+ reporter = function(...)
+ if force or not logger.state then
+ subreport(category,subcategory,...)
+ end
+ end
+ logger.reporters[subcategory] = reporter
+ else
+ local tag = category
+ reporter = function(...)
+ if force or not logger.state then
+ report(category,...)
+ end
+ end
+ logger.reporters.default = reporter
+ end
+ end
+ return reporter
+end
+
+logs.new = logs.reporter -- for old times sake
+
+-- context specicific: this ends up in the macro stream
+
+local ctxreport = logs.writer
+
+function logs.setmessenger(m)
+ ctxreport = m
+end
+
+function logs.messenger(category,subcategory)
+ -- we need to avoid catcode mess (todo: fast context)
+ if subcategory then
+ return function(...)
+ ctxreport(subdirect(category,subcategory,...))
+ end
+ else
+ return function(...)
+ ctxreport(direct(category,...))
+ end
+ end
+end
+
+-- so far
+
+local function setblocked(category,value) -- v.state == value == true : disable
+ if category == true or category == "all" then
+ -- lock all
+ category, value = "*", true
+ elseif category == false then
+ -- unlock all
+ category, value = "*", false
+ elseif value == nil then
+ -- lock selective
+ value = true
+ end
+ if category == "*" then
+ states = value
+ for k, v in next, data do
+ v.state = value
+ end
+ else
+ alllocked = false
+ states = settings_to_hash(category,type(states)=="table" and states or nil)
+ for c in next, states do
+ local v = data[c]
+ if v then
+ v.state = value
+ else
+ c = topattern(c,true,true)
+ for k, v in next, data do
+ if find(k,c) then
+ v.state = value
+ end
+ end
+ end
+ end
+ end
+end
+
+function logs.disable(category,value)
+ setblocked(category,value == nil and true or value)
+end
+
+function logs.enable(category)
+ setblocked(category,false)
+end
+
+function logs.categories()
+ return sortedkeys(data)
+end
+
+function logs.show()
+ local n, c, s, max = 0, 0, 0, 0
+ for category, v in table.sortedpairs(data) do
+ n = n + 1
+ local state = v.state
+ local reporters = v.reporters
+ local nc = #category
+ if nc > c then
+ c = nc
+ end
+ for subcategory, _ in next, reporters do
+ local ns = #subcategory
+ if ns > c then
+ s = ns
+ end
+ local m = nc + ns
+ if m > max then
+ max = m
+ end
+ end
+ local subcategories = concat(sortedkeys(reporters),", ")
+ if state == true then
+ state = "disabled"
+ elseif state == false then
+ state = "enabled"
+ else
+ state = "unknown"
+ end
+ -- no new here
+ report("logging","category %a, subcategories %a, state %a",category,subcategories,state)
+ end
+ report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
+end
+
+local delayed_reporters = { }
+
+setmetatableindex(delayed_reporters,function(t,k)
+ local v = logs.reporter(k.name)
+ t[k] = v
+ return v
+end)
+
+function utilities.setters.report(setter,...)
+ delayed_reporters[setter](...)
+end
+
+directives.register("logs.blocked", function(v)
+ setblocked(v,true)
+end)
+
+directives.register("logs.target", function(v)
+ settarget(v)
+end)
+
+do
+
+ local report = logs.reporter("pages") -- not needed but saves checking when we grep for it
+ local texgetcount = tex and tex.getcount
+
+ local real, user, sub = 0, 0, 0
+
+ function logs.start_page_number()
+ real = texgetcount("realpageno")
+ user = texgetcount("userpageno")
+ sub = texgetcount("subpageno")
+ end
+
+ local timing = false
+ local usage = false
+ local lasttime = nil
+
+ logs.private = {
+ enablepagetiming = function()
+ usage = true
+ end,
+ getpagetiming = function()
+ return type(usage) == "table" and usage
+ end,
+ }
+
+ trackers.register("pages.timing", function() timing = "" end)
+
+ function logs.stop_page_number() -- the first page can includes the initialization so we omit this in average
+ if timing or usage then
+ local elapsed = statistics.currenttime(statistics)
+ local average, page
+ if not lasttime or real < 2 then
+ average = elapsed
+ page = elapsed
+ else
+ average = elapsed / (real - 1)
+ page = elapsed - lasttime
+ end
+ lasttime = elapsed
+ if timing then
+ timing = formatters[", total %0.03f, page %0.03f, average %0.03f"](elapsed,page,average)
+ end
+ if usage then
+ usage = {
+ page = {
+ real = real,
+ user = user,
+ sub = sub,
+ },
+ time = {
+ elapsed = elapsed,
+ page = page,
+ average = average,
+ }
+ }
+ end
+ end
+ if real <= 0 then
+ report("flushing page%s",timing)
+ elseif user <= 0 then
+ report("flushing realpage %s%s",real,timing)
+ elseif sub <= 0 then
+ report("flushing realpage %s, userpage %s%s",real,user,timing)
+ else
+ report("flushing realpage %s, userpage %s, subpage %s%s",real,user,sub,timing)
+ end
+ logs.flush()
+ end
+
+end
+
+-- we don't have show_open and show_close callbacks yet
+
+do
+ local texerror = tex and tex.error or print
+ local formatters = string.formatters
+
+ function logs.texerrormessage(fmt,first,...) -- for the moment we put this function here
+ texerror(first and formatters[fmt](first,...) or fmt)
+ end
+
+end
+
+-- this is somewhat slower but prevents out-of-order messages when print is mixed
+-- with texio.write
+
+-- io.stdout:setvbuf('no')
+-- io.stderr:setvbuf('no')
+
+-- windows: > nul 2>&1
+-- unix : > null 2>&1
+
+if package.helpers.report then
+ package.helpers.report = logs.reporter("package loader") -- when used outside mtxrun
+end
+
+do
+
+ local finalactions = { }
+ local fatalerrors = { }
+ local possiblefatal = { }
+ local loggingerrors = false
+
+ function logs.loggingerrors()
+ return loggingerrors
+ end
+
+ directives.register("logs.errors",function(v)
+ loggingerrors = v
+ if type(v) == "string" then
+ fatalerrors = settings_to_hash(v)
+ else
+ fatalerrors = { }
+ end
+ end)
+
+ function logs.registerfinalactions(...)
+ insert(finalactions,...) -- so we can force an order if needed
+ end
+
+ local what = nil
+ local report = nil
+ local state = nil
+ local target = nil
+
+ local function startlogging(t,r,w,s)
+ target = t
+ state = force
+ force = true
+ report = type(r) == "function" and r or logs.reporter(r)
+ what = w
+ pushtarget(target)
+ newline()
+ if s then
+ report("start %s: %s",what,s)
+ else
+ report("start %s",what or "")
+ end
+ if target == "logfile" then
+ newline()
+ end
+ return report
+ end
+
+ local function stoplogging()
+ if target == "logfile" then
+ newline()
+ end
+ report("stop %s",what or "")
+ if target == "logfile" then
+ newline()
+ end
+ poptarget()
+ state = oldstate
+ end
+
+ function logs.startfilelogging(...)
+ return startlogging("logfile", ...)
+ end
+
+ logs.stopfilelogging = stoplogging
+
+ local done = false
+
+ function logs.starterrorlogging(r,w,...)
+ if not done then
+ pushtarget("terminal")
+ newline()
+ logs.report("error logging","start possible issues")
+ poptarget()
+ done = true
+ end
+ if fatalerrors[w] then
+ possiblefatal[w] = true
+ end
+ return startlogging("terminal",r,w,...)
+ end
+
+ logs.stoperrorlogging = stoplogging
+
+ function logs.finalactions()
+ if #finalactions > 0 then
+ for i=1,#finalactions do
+ finalactions[i]()
+ end
+ if done then
+ pushtarget("terminal")
+ newline()
+ logs.report("error logging","stop possible issues")
+ poptarget()
+ end
+ return next(possiblefatal) and sortedkeys(possiblefatal) or false
+ end
+ end
+
+end
+
+-- just in case we load from context
+
+local dummy = function() end
+
+function logs.application(t)
+ return {
+ name = t.name or tex.jobname,
+ banner = t.banner,
+ report = logs.reporter(t.name),
+ moreinfo = dummy,
+ export = dummy,
+ help = dummy,
+ identify = dummy,
+ version = dummy,
+ }
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua
index e6789a2338a..3c50a41f89c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua
@@ -30,36 +30,125 @@ local report_macros = logs.reporter("interface","macros")
local stack, top, n, hashes = { }, nil, 0, { }
-local function set(s)
- if top then
- n = n + 1
- if n > 9 then
- report_macros("number of arguments > 9, ignoring %s",s)
- else
+-- local function set(s)
+-- if top then
+-- n = n + 1
+-- if n > 9 then
+-- report_macros("number of arguments > 9, ignoring %s",s)
+-- else
+-- local ns = #stack
+-- local h = hashes[ns]
+-- if not h then
+-- h = rep("#",2^(ns-1))
+-- hashes[ns] = h
+-- end
+-- if s == "ignore" then
+-- top[s] = ""
+-- return h .. "0"
+-- else
+-- local m = h .. n
+-- top[s] = m
+-- return m
+-- end
+-- end
+-- end
+-- end
+
+-- local function get(s)
+-- if s == "ignore" then
+-- return ""
+-- else
+-- if not top then
+-- report_macros("keeping #%s, no stack",s)
+-- return "#" .. s -- can be lua
+-- end
+-- local m = top[s]
+-- if m then
+-- return m
+-- else
+-- report_macros("keeping #%s, not on stack",s)
+-- return "#" .. s -- quite likely an error
+-- end
+-- end
+-- end
+
+local set = CONTEXTLMTXMODE > 0 and
+ function(s)
+ if top then
local ns = #stack
local h = hashes[ns]
if not h then
h = rep("#",2^(ns-1))
hashes[ns] = h
end
- local m = h .. n
- top[s] = m
- return m
+ if s == "ignore" then
+ return h .. "-"
+ elseif s == "spacer" then
+ return h .. "*"
+ elseif s == "pickup" then
+ return h .. ":"
+ else
+ n = n + 1
+ if n > 9 then
+ report_macros("number of arguments > 9, ignoring %s",s)
+ elseif s == "discard" then
+ top[s] = ""
+ return h .. "0"
+ elseif s == "keepbraces" then
+ top[s] = ""
+ return h .. "+"
+ elseif s == "mandate" then
+ top[s] = ""
+ return h .. "="
+ elseif s == "keepmandate" then
+ top[s] = ""
+ return h .. "_"
+ elseif s == "prunespacing" then
+ top[s] = ""
+ return h .. "/"
+ else
+ local m = h .. n
+ top[s] = m
+ return m
+ end
+ end
+ end
+ end
+or
+ function(s)
+ if top then
+ local ns = #stack
+ local h = hashes[ns]
+ if not h then
+ h = rep("#",2^(ns-1))
+ hashes[ns] = h
+ end
+ n = n + 1
+ if n > 9 then
+ report_macros("number of arguments > 9, ignoring %s",s)
+ else
+ local m = h .. n
+ top[s] = m
+ return m
+ end
end
end
-end
local function get(s)
- if not top then
- report_macros("keeping #%s, no stack",s)
- return "#" .. s -- can be lua
- end
- local m = top[s]
- if m then
- return m
+ if s == "ignore" or s == "discard" then
+ return ""
else
- report_macros("keeping #%s, not on stack",s)
- return "#" .. s -- quite likely an error
+ if not top then
+ report_macros("keeping #%s, no stack",s)
+ return "#" .. s -- can be lua
+ end
+ local m = top[s]
+ if m then
+ return m
+ else
+ report_macros("keeping #%s, not on stack",s)
+ return "#" .. s -- quite likely an error
+ end
end
end
@@ -209,7 +298,7 @@ end
function macros.convertfile(oldname,newname) -- beware, no testing on oldname == newname
local data = loadtexfile(oldname)
- data = interfaces.preprocessed(data) or "" -- interfaces not yet defined
+ data = macros.preprocessed(data) or "" -- interfaces not yet defined
savedata(newname,data)
end
@@ -336,6 +425,8 @@ end
-- ]]))
-- print(macros.preprocessed([[\checked \def \bla #bla{bla#{bla}}]]))
+-- print(macros.preprocessed([[\checked \def \bla #bla#discard#foo{bla#{bla}+#ignore+bla#foo}]]))
+-- print(macros.preprocessed([[\checked \def \bla #bla#ignore#foo{bla#{bla}+#ignore+bla#foo}]]))
-- print(macros.preprocessed([[\def\bla#bla{#{bla}bla}]]))
-- print(macros.preprocessed([[\def\blä#{blá}{blà:#{blá}}]]))
-- print(macros.preprocessed([[\def\blä#bla{blà:#bla}]]))
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-run.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-run.lua
index d29a463b88c..874287ee1a0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-run.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-run.lua
@@ -45,6 +45,7 @@ local function start_run()
if logs.start_run then
logs.start_run()
end
+ -- logs.report("engine","%s version %s, format id %s",LUATEXENGINE,LUATEXVERSION,LUATEXFORMATID)
for i=1,#startactions do
startactions[i]()
end
@@ -61,7 +62,9 @@ local function stop_run()
if trace_tex_status then
logs.newline()
for k, v in table.sortedhash(status.list()) do
- report_tex("%S=%S",k,v)
+ if type(v) ~= "table" then
+ report_tex("%S=%S",k,v)
+ end
end
end
if quit then
@@ -99,18 +102,11 @@ end
local function report_output_log()
end
--- local function show_open()
--- end
-
--- local function show_close()
--- end
-
local function pre_dump_actions()
for i=1,#dumpactions do
dumpactions[i]()
end
lua.finalize(trace_lua_dump and report_lua or nil)
- -- statistics.savefmtstatus("\jobname","\contextversion","context.tex")
end
local function wrapup_synctex()
@@ -131,10 +127,10 @@ appendgroup(wrapupactions,"user")
appendgroup(cleanupactions,"system")
appendgroup(cleanupactions,"user")
-local function wrapup_run()
+local function wrapup_run(someerror)
local runner = wrapupactions.runner
if runner then
- runner()
+ runner(someerror) -- we could use the error flag in lmtx
end
end
@@ -297,3 +293,36 @@ end)
-- end
-- end)
+local report = logs.reporter("csname overload")
+local reported = { }
+
+callback.register("handle_overload", function(fatal,overload,csname,flags)
+ if not reported[csname] then
+ logs.newline()
+ local readstate = status.readstate
+ local filename = readstate.filename
+ local linenumber = readstate.linenumber
+ local flags = tokens.flags and tokens.flags(csname) or { }
+ if filename and linenumber then
+ report("%s, protection level %i, control sequence %a, properties '% t', file %a, line %i",
+ fatal and "fatal error" or "warning",overload,csname,flags,filename,linenumber)
+ else
+ report("%s, protection level %i, control sequence %a, properties '% t'",
+ fatal and "fatal error" or "warning",overload,csname,flags)
+ end
+ reported[csname] = true
+ logs.newline()
+ if fatal then
+ cleanup_run()
+ osexit(1)
+ end
+ end
+end)
+
+-- bonus
+
+if environment.initex then
+
+ luatex.registerdumpactions(statistics.showmemory)
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-sto.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-sto.lua
index 620de9a15b4..feb5464009b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-sto.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-sto.lua
@@ -94,27 +94,12 @@ if environment.initex then
end
--- to be tested with otf caching:
-
-function lua.collectgarbage(threshold)
- local current = collectgarbage("count")
- local threshold = threshold or 256 * 1024
- while true do
- collectgarbage("collect")
- local previous = collectgarbage("count")
- if current - previous < threshold then
- break
- else
- current = previous
- end
- end
-end
-
statistics.register("stored bytecode data", function()
- local nofmodules = (storage.nofmodules > 0 and storage.nofmodules) or (status.luabytecodes - lua.firstbytecode - 1)
- local nofdumps = (storage.noftables > 0 and storage.noftables ) or storage.max-storage.min + 1
- local tofmodules = storage.tofmodules or 0
- local tofdumps = storage.toftables or 0
+ local nofbytecodes = CONTEXTLMTXMODE > 0 and status.luastate.bytecodes or status.luabytecodes
+ local nofmodules = (storage.nofmodules > 0 and storage.nofmodules) or (nofbytecodes - lua.firstbytecode - 1)
+ local nofdumps = (storage.noftables > 0 and storage.noftables ) or storage.max-storage.min + 1
+ local tofmodules = storage.tofmodules or 0
+ local tofdumps = storage.toftables or 0
if environment.initex then
local luautilities = utilities.lua
return format("%s modules, %s tables, %s chunks, %s chunks stripped (%s bytes)",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-usr.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-usr.lua
index b49379bbf05..1756bb19842 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-usr.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-usr.lua
@@ -102,23 +102,6 @@ interfaces.implement {
arguments = "2 strings",
}
--- local scanners = interfaces.scanners
---
--- local function ctxscanner(name)
--- local scanner = scanners[name]
--- if scanner then
--- scanner()
--- else
--- report("unknown scanner: %s",name)
--- end
--- end
---
--- interfaces.implement {
--- name = "clfscanner",
--- actions = ctxscanner,
--- arguments = "string",
--- }
-
local function registername(name,message)
if not name or name == "" then
report_instance("no valid name given")
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-usr.mkiv b/Master/texmf-dist/tex/context/base/mkiv/luat-usr.mkiv
index f3868ccf4bc..ebd96e031c4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/luat-usr.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/luat-usr.mkiv
@@ -38,13 +38,14 @@
%D \macros
%D {definenamedlua}
%D
-%D We provide an interface for defining instances:
+%D We provide an interface for defining instances. We don't have the definers yet
+%D so we do itlow level:
\def\s!lua {lua}
\def\s!code {code}
\def\s!data {data}
-%def\s!start{start}
-%def\s!stop {stop}
+\def\s!start{start}
+\def\s!stop {stop}
%D Beware: because \type {\expanded} is een convert command, the error
%D message will show \type{} as part of the message.
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-aux.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-aux.lua
index ed0f03fd8c7..126df4d82de 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-aux.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-aux.lua
@@ -22,7 +22,7 @@ local xmlapplylpath = xml.applylpath
local type, next, setmetatable, getmetatable = type, next, setmetatable, getmetatable
local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat
-local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.format, string.find, string.strip
+local gmatch, gsub, format, find, strip, match = string.gmatch, string.gsub, string.format, string.find, string.strip, string.match
local utfbyte = utf.byte
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
local striplinepatterns = utilities.strings.striplinepatterns
@@ -176,7 +176,7 @@ local function xmltoelement(whatever,root)
end
local element
if type(whatever) == "string" then
- element = xmlinheritedconvert(whatever,root) -- beware, not really a root
+ element = xmlinheritedconvert(whatever,root,true) -- beware, not really a root
else
element = whatever -- we assume a table
end
@@ -195,16 +195,29 @@ end
xml.toelement = xmltoelement
+-- local function copiedelement(element,newparent)
+-- if type(element) ~= "string" then
+-- element = xmlcopy(element).dt
+-- if newparent and type(element) == "table" then
+-- element.__p__ = newparent
+-- end
+-- end
+-- return element
+-- end
+
local function copiedelement(element,newparent)
- if type(element) == "string" then
- return element
- else
+ if type(element) ~= "string" then
element = xmlcopy(element).dt
if newparent and type(element) == "table" then
- element.__p__ = newparent
+ for i=1,#element do
+ local e = element[i]
+ if type(e) == "table" then
+ e.__p__ = newparent
+ end
+ end
end
- return element
end
+ return element
end
function xml.delete(root,pattern)
@@ -247,6 +260,33 @@ function xml.delete(root,pattern)
end
end
+function xml.wipe(root,pattern) -- not yet in manual
+ local collected = xmlapplylpath(root,pattern)
+ if collected then
+ for c=1,#collected do
+ local e = collected[c]
+ local p = e.__p__
+ if p then
+ local d = p.dt
+ local ni = e.ni
+ if ni <= #d then
+ local dt = e.dt
+ if #dt == 1 then
+ local d1 = dt[1]
+ if type(d1) == "string" and match(d1,"^%s*$") then
+ if trace_manipulations then
+ report('wiping',pattern,c,e)
+ end
+ remove(d,ni)
+ redo_ni(d) -- can be made faster and inlined
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
function xml.replace(root,pattern,whatever)
local element = root and xmltoelement(whatever,root)
local collected = element and xmlapplylpath(root,pattern)
@@ -430,10 +470,10 @@ local function include(xmldata,pattern,attribute,recursive,loaddata,level)
-- for the moment hard coded
epdt[ek.ni] = xml.escaped(data) -- d[k] = xml.escaped(data)
else
-local settings = xmldata.settings
-local savedresource = settings.currentresource
-settings.currentresource = name
- local xi = xmlinheritedconvert(data,xmldata)
+ local settings = xmldata.settings
+ local savedresource = settings.currentresource
+ settings.currentresource = name
+ local xi = xmlinheritedconvert(data,xmldata,true)
if not xi then
epdt[ek.ni] = "" -- xml.empty(d,k)
else
@@ -443,7 +483,7 @@ settings.currentresource = name
local child = xml.body(xi) -- xml.assign(d,k,xi)
child.__p__ = ekrt
child.__f__ = name -- handy for tracing
-child.cf = name
+ child.cf = name
epdt[ek.ni] = child
local settings = xmldata.settings
local inclusions = settings and settings.inclusions
@@ -517,30 +557,49 @@ end
local b_collapser = lpegpatterns.b_collapser
local m_collapser = lpegpatterns.m_collapser
local e_collapser = lpegpatterns.e_collapser
+local x_collapser = lpegpatterns.x_collapser
local b_stripper = lpegpatterns.b_stripper
local m_stripper = lpegpatterns.m_stripper
local e_stripper = lpegpatterns.e_stripper
+local x_stripper = lpegpatterns.x_stripper
-local function stripelement(e,nolines,anywhere)
+local function stripelement(e,nolines,anywhere,everything)
local edt = e.dt
if edt then
local n = #edt
if n == 0 then
return e -- convenient
+ elseif everything then
+ local t = { }
+ local m = 0
+ for i=1,n do
+ local str = edt[i]
+ if type(str) ~= "string" then
+ m = m + 1
+ t[m] = str
+ elseif str ~= "" then
+ str = lpegmatch(x_collapser,str)
+ if str ~= "" then
+ m = m + 1
+ t[m] = str
+ end
+ end
+ end
+ e.dt = t
elseif anywhere then
local t = { }
local m = 0
- for e=1,n do
- local str = edt[e]
+ for i=1,n do
+ local str = edt[i]
if type(str) ~= "string" then
m = m + 1
t[m] = str
elseif str ~= "" then
if nolines then
- str = lpegmatch((n == 1 and b_collapser) or (n == m and e_collapser) or m_collapser,str)
+ str = lpegmatch((i == 1 and b_collapser) or (i == m and e_collapser) or m_collapser,str)
else
- str = lpegmatch((n == 1 and b_stripper) or (n == m and e_stripper) or m_stripper,str)
+ str = lpegmatch((i == 1 and b_stripper) or (i == m and e_stripper) or m_stripper,str)
end
if str ~= "" then
m = m + 1
@@ -584,15 +643,51 @@ end
xml.stripelement = stripelement
-function xml.strip(root,pattern,nolines,anywhere) -- strips all leading and trailing spacing
+function xml.strip(root,pattern,nolines,anywhere,everything) -- strips all leading and trailing spacing
local collected = xmlapplylpath(root,pattern) -- beware, indices no longer are valid now
if collected then
for i=1,#collected do
- stripelement(collected[i],nolines,anywhere)
+ stripelement(collected[i],nolines,anywhere,everything)
end
end
+-- return root
end
+-- local function compactelement(e)
+-- local edt = e.dt
+-- if edt then
+-- local t = { }
+-- local m = 0
+-- for e=1,#edt do
+-- local str = edt[e]
+-- if type(str) ~= "string" then
+-- m = m + 1
+-- t[m] = str
+-- elseif str ~= "" and find(str,"%S") then
+-- m = m + 1
+-- t[m] = str
+-- end
+-- end
+-- e.dt = t
+-- end
+-- return e -- convenient
+-- end
+
+local function compactelement(e)
+ local edt = e.dt
+ if edt then
+ for e=1,#edt do
+ local str = edt[e]
+ if type(str) == "string" and not find(str,"%S") then
+ edt[e] = ""
+ end
+ end
+ end
+ return e -- convenient
+end
+
+xml.compactelement = compactelement
+
local function renamespace(root, oldspace, newspace) -- fast variant
local ndt = #root.dt
for i=1,ndt or 0 do
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-css.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-css.lua
index 96dc626f7db..76cc4891e1d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-css.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-css.lua
@@ -17,6 +17,8 @@ local setmetatableindex = table.setmetatableindex
xml.css = xml.css or { }
local css = xml.css
+local report_css = logs and logs.reporter("xml","css") or function(...) print(string.format(...)) end
+
local getid = lxml.getid
if not number.dimenfactors then
@@ -787,7 +789,7 @@ local p_not = P(":not") * Cc(true) * skipspace * P("(") * skipspace
local p_yes = Cc(false) * skipspace * p_step
local p_stepper = Ct((skipspace * (p_not+p_yes))^1)
-local p_steps = Ct((p_stepper * p_separator^0)^1) * skipspace * (P(-1) + function() print("error") end)
+local p_steps = Ct((p_stepper * p_separator^0)^1) * skipspace * (P(-1) + function() report_css("recovering from error") end)
local cache = setmetatableindex(function(t,k)
local v = lpegmatch(p_steps,k) or false
@@ -1063,13 +1065,15 @@ end
-- -- faster interface (1.02):
interfaces.implement {
- name = "xmlstylevalue",
+ name = "xmlcssstylevalue",
+ public = true,
actions = css.stylevalue,
arguments = "2 strings",
}
interfaces.implement {
- name = "xmlmappedstylevalue",
+ name = "xmlcssmappedstylevalue",
+ public = true,
actions = css.mappedstylevalue,
arguments = "3 strings",
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-css.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lxml-css.mkiv
index 04000a6caba..271afdb7dc7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-css.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-css.mkiv
@@ -69,8 +69,8 @@
% \xmlregistersetup{html:settings}
% \xmlprocessbuffer{main}{temp}{}
-\let\xmlcssstylevalue \clf_xmlstylevalue
-\let\xmlcssmappedstylevalue\clf_xmlmappedstylevalue
+% \xmlcssstylevalue % defined at lua end
+% \xmlcssmappedstylevalue % defined at lua end
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-ctx.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lxml-ctx.mkiv
index e0beb22bf68..7d44d61bea1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-ctx.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-ctx.mkiv
@@ -11,8 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D Experimental. This might change! Also, it might become a module
-%D instead if core code.
+%D Experimental. This might change! Also, it might become a module instead if
+%D core code.
\writestatus{loading}{ConTeXt XML Support / Goodies}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.lua
index 348ecbbe45c..43643f71a18 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.lua
@@ -21,120 +21,124 @@ local implement = interfaces.implement
-- lxml.id
-implement { name = "lxmlid", actions = lxml.getid, arguments = "string" }
-
-implement { name = "xmldoif", actions = lxml.doif, arguments = "2 strings" }
-implement { name = "xmldoifnot", actions = lxml.doifnot, arguments = "2 strings" }
-implement { name = "xmldoifelse", actions = lxml.doifelse, arguments = "2 strings" }
-implement { name = "xmldoiftext", actions = lxml.doiftext, arguments = "2 strings" }
-implement { name = "xmldoifnottext", actions = lxml.doifnottext, arguments = "2 strings" }
-implement { name = "xmldoifelsetext", actions = lxml.doifelsetext, arguments = "2 strings" }
-
-implement { name = "xmldoifempty", actions = lxml.doifempty, arguments = "2 strings" }
-implement { name = "xmldoifnotempty", actions = lxml.doifnotempty, arguments = "2 strings" }
-implement { name = "xmldoifelseempty", actions = lxml.doifelseempty, arguments = "2 strings" }
-implement { name = "xmldoifselfempty", actions = lxml.doifempty, arguments = "string" } -- second arg is not passed (used)
-implement { name = "xmldoifnotselfempty", actions = lxml.doifnotempty, arguments = "string" } -- second arg is not passed (used)
-implement { name = "xmldoifelseselfempty", actions = lxml.doifelseempty, arguments = "string" } -- second arg is not passed (used)
-
---------- { name = "xmlcontent", actions = lxml.content, arguments = "string" }
---------- { name = "xmlflushstripped", actions = lxml.strip, arguments = { "string", true } }
-
-implement { name = "xmlall", actions = lxml.all, arguments = "2 strings" }
-implement { name = "xmlatt", actions = lxml.att, arguments = "2 strings" }
-implement { name = "xmlattdef", actions = lxml.att, arguments = "3 strings" }
-implement { name = "xmlattribute", actions = lxml.attribute, arguments = "3 strings" }
-implement { name = "xmlattributedef", actions = lxml.attribute, arguments = "4 strings" }
-implement { name = "xmlbadinclusions", actions = lxml.badinclusions, arguments = "string" }
-implement { name = "xmlchainatt", actions = lxml.chainattribute, arguments = { "string", "'/'", "string" } }
-implement { name = "xmlchainattdef", actions = lxml.chainattribute, arguments = { "string", "'/'", "string", "string" } }
-implement { name = "xmlchecknamespace", actions = xml.checknamespace, arguments = { "lxmlid", "string", "string" } }
-implement { name = "xmlcommand", actions = lxml.command, arguments = "3 strings" }
-implement { name = "xmlconcat", actions = lxml.concat, arguments = "3 strings" } -- \detokenize{#3}
-implement { name = "xmlconcatrange", actions = lxml.concatrange, arguments = { "string", "string", "string", "string", "string" } } -- \detokenize{#5}
-implement { name = "xmlcontext", actions = lxml.context, arguments = "2 strings" }
-implement { name = "xmlcount", actions = lxml.count, arguments = "2 strings" }
-implement { name = "xmldelete", actions = lxml.delete, arguments = "2 strings" }
-implement { name = "xmldirect", actions = lxml.direct, arguments = "string" }
-implement { name = "xmldirectives", actions = lxml.directives.setup, arguments = "string" }
-implement { name = "xmldirectivesafter", actions = lxml.directives.after, arguments = "string" }
-implement { name = "xmldirectivesbefore", actions = lxml.directives.before, arguments = "string" }
-implement { name = "xmldisplayverbatim", actions = lxml.displayverbatim, arguments = "string" }
-implement { name = "xmlelement", actions = lxml.element, arguments = "2 strings" } -- could be integer but now we can alias
-implement { name = "xmlfilter", actions = lxml.filter, arguments = "2 strings" }
-implement { name = "xmlfilterlist", actions = lxml.filterlist, arguments = "2 strings" }
-implement { name = "xmlfirst", actions = lxml.first, arguments = "2 strings" }
-implement { name = "xmlflush", actions = lxml.flush, arguments = "string" }
-implement { name = "xmlflushcontext", actions = lxml.context, arguments = "string" }
-implement { name = "xmlflushlinewise", actions = lxml.flushlinewise, arguments = "string" }
-implement { name = "xmlflushpure", actions = lxml.pure, arguments = "string" }
-implement { name = "xmlflushspacewise", actions = lxml.flushspacewise, arguments = "string" }
-implement { name = "xmlflushtext", actions = lxml.text, arguments = "string" }
-implement { name = "xmlfunction", actions = lxml.applyfunction, arguments = "2 strings" }
-implement { name = "xmlinclude", actions = lxml.include, arguments = { "string", "string", "string", true } }
-implement { name = "xmlincludeoptions", actions = lxml.include, arguments = "4 strings" }
-implement { name = "xmlinclusion", actions = lxml.inclusion, arguments = "string" }
-implement { name = "xmlinclusionbase", actions = lxml.inclusion, arguments = { "string", false, true } }
-implement { name = "xmlinclusions", actions = lxml.inclusions, arguments = "string" }
-implement { name = "xmlindex", actions = lxml.index, arguments = "3 strings" } -- can be integer but now we can alias
-implement { name = "xmlinlineverbatim", actions = lxml.inlineverbatim, arguments = "string" }
-implement { name = "xmllast", actions = lxml.last, arguments = "2 strings" }
-implement { name = "xmllastatt", actions = lxml.lastatt }
-implement { name = "xmllastmatch", actions = lxml.lastmatch }
-implement { name = "xmllastpar", actions = lxml.lastpar }
-implement { name = "xmlloadfile", actions = lxml.load, arguments = "3 strings" }
-implement { name = "xmlloadbuffer", actions = lxml.loadbuffer, arguments = "3 strings" }
-implement { name = "xmlloaddata", actions = lxml.loaddata, arguments = "3 strings" }
-implement { name = "xmlloaddirectives", actions = lxml.directives.load, arguments = "string" }
-implement { name = "xmlmain", actions = lxml.main, arguments = "string" }
-implement { name = "xmlmatch", actions = lxml.match, arguments = "string" }
-implement { name = "xmlname", actions = lxml.name, arguments = "string" }
-implement { name = "xmlnamespace", actions = lxml.namespace, arguments = "string" }
-implement { name = "xmlnonspace", actions = lxml.nonspace, arguments = "2 strings" }
-implement { name = "xmlpar", actions = lxml.par, arguments = "2 strings" }
-implement { name = "xmlparam", actions = lxml.param, arguments = "3 strings" }
-implement { name = "xmlpath", actions = lxml.path, arguments = { "string", "'/'" } }
-implement { name = "xmlpopmatch", actions = lxml.popmatch }
-implement { name = "xmlpos", actions = lxml.pos, arguments = "string" }
-implement { name = "xmlpure", actions = lxml.pure, arguments = "2 strings" }
-implement { name = "xmlpushmatch", actions = lxml.pushmatch }
-implement { name = "xmlraw", actions = lxml.raw, arguments = "2 strings" }
-implement { name = "xmlrawtex", actions = lxml.rawtex, arguments = "2 strings" }
-implement { name = "xmlrefatt", actions = lxml.refatt, arguments = "2 strings" }
-implement { name = "xmlregisterns", actions = xml.registerns, arguments = "2 strings" }
-implement { name = "xmlremapname", actions = xml.remapname, arguments = { "lxmlid", "string","string","string" } }
-implement { name = "xmlremapnamespace", actions = xml.renamespace, arguments = { "lxmlid", "string", "string" } }
-implement { name = "xmlsave", actions = lxml.save, arguments = "2 strings" }
-implement { name = "xmlsetatt", actions = lxml.setatt, arguments = "3 strings" }
-implement { name = "xmlsetattribute", actions = lxml.setattribute, arguments = "4 strings" }
-implement { name = "xmlsetpar", actions = lxml.setpar, arguments = "3 strings" }
-implement { name = "xmlsetparam", actions = lxml.setparam, arguments = "4 strings" }
-implement { name = "xmlsetsetup", actions = lxml.setsetup, arguments = "3 strings" }
-implement { name = "xmlsnippet", actions = lxml.snippet, arguments = "2 strings" }
-implement { name = "xmlstrip", actions = lxml.strip, arguments = "2 strings" }
-implement { name = "xmlstripanywhere", actions = lxml.strip, arguments = { "string", "string", true, true } }
-implement { name = "xmlstripnolines", actions = lxml.strip, arguments = { "string", "string", true } }
-implement { name = "xmlstripped", actions = lxml.stripped, arguments = "2 strings" }
-implement { name = "xmlstrippednolines", actions = lxml.stripped, arguments = { "string", "string", true } }
-implement { name = "xmltag", actions = lxml.tag, arguments = "string" }
-implement { name = "xmltext", actions = lxml.text, arguments = "2 strings" }
-implement { name = "xmltobuffer", actions = lxml.tobuffer, arguments = "3 strings" }
-implement { name = "xmltobuffertextonly", actions = lxml.tobuffer, arguments = { "string", "string", "string", false } }
-implement { name = "xmltobufferverbose", actions = lxml.tobuffer, arguments = { "string", "string", "string", true, true } }
-implement { name = "xmltofile", actions = lxml.tofile, arguments = "3 strings" }
-implement { name = "xmltoparameters", actions = lxml.toparameters, arguments = "string" }
-implement { name = "xmlverbatim", actions = lxml.verbatim, arguments = "string" }
-
-implement { name = "xmlstartraw", actions = lxml.startraw }
-implement { name = "xmlstopraw", actions = lxml.stopraw }
-
-implement { name = "xmlprependsetup", actions = lxml.installsetup, arguments = { 1, "string", "string" } } -- 2:*
-implement { name = "xmlappendsetup", actions = lxml.installsetup, arguments = { 2, "string", "string" } } -- 2:*
-implement { name = "xmlbeforesetup", actions = lxml.installsetup, arguments = { 3, "string", "string", "string" } } -- 2:*
-implement { name = "xmlaftersetup", actions = lxml.installsetup, arguments = { 4, "string", "string", "string" } } -- 2:*
-implement { name = "xmlremovesetup", actions = lxml.removesetup, arguments = "2 strings" } -- 1:*
-implement { name = "xmlflushsetups", actions = lxml.flushsetups, arguments = "3 strings" } -- 2:*
-implement { name = "xmlresetsetups", actions = lxml.resetsetups, arguments = "string" }
+implement { name = "lxmlid", public = true, actions = lxml.getid, arguments = "string" }
+
+implement { name = "xmldoif", public = true, actions = lxml.doif, arguments = "2 strings" }
+implement { name = "xmldoifnot", public = true, actions = lxml.doifnot, arguments = "2 strings" }
+implement { name = "xmldoifelse", public = true, actions = lxml.doifelse, arguments = "2 strings" }
+implement { name = "xmldoiftext", public = true, actions = lxml.doiftext, arguments = "2 strings" }
+implement { name = "xmldoifnottext", public = true, actions = lxml.doifnottext, arguments = "2 strings" }
+implement { name = "xmldoifelsetext", public = true, actions = lxml.doifelsetext, arguments = "2 strings" }
+
+implement { name = "xmldoifempty", public = true, actions = lxml.doifempty, arguments = "2 strings" }
+implement { name = "xmldoifnotempty", public = true, actions = lxml.doifnotempty, arguments = "2 strings" }
+implement { name = "xmldoifelseempty", public = true, actions = lxml.doifelseempty, arguments = "2 strings" }
+implement { name = "xmldoifselfempty", public = true, actions = lxml.doifempty, arguments = "string" } -- second arg is not passed (used)
+implement { name = "xmldoifnotselfempty", public = true, actions = lxml.doifnotempty, arguments = "string" } -- second arg is not passed (used)
+implement { name = "xmldoifelseselfempty", public = true, actions = lxml.doifelseempty, arguments = "string" } -- second arg is not passed (used)
+
+--------- { name = "xmlcontent", actions = lxml.content, arguments = "string" }
+--------- { name = "xmlflushstripped", actions = lxml.strip, arguments = { "string", true } }
+
+implement { name = "xmlall", public = true, actions = lxml.all, arguments = "2 strings" }
+implement { name = "xmlatt", public = true, actions = lxml.att, arguments = "2 strings" }
+implement { name = "xmlattdef", public = true, actions = lxml.att, arguments = "3 strings" }
+implement { name = "xmlattribute", public = true, actions = lxml.attribute, arguments = "3 strings" }
+implement { name = "xmlattributedef", public = true, actions = lxml.attribute, arguments = "4 strings" }
+implement { name = "xmlbadinclusions", public = true, actions = lxml.badinclusions, arguments = "string" }
+implement { name = "xmlchainatt", public = true, actions = lxml.chainattribute, arguments = { "string", "'/'", "string" } }
+implement { name = "xmlchainattdef", public = true, actions = lxml.chainattribute, arguments = { "string", "'/'", "string", "string" } }
+implement { name = "xmlchecknamespace", public = true, actions = xml.checknamespace, arguments = { "lxmlid", "string", "string" } }
+implement { name = "xmlcommand", public = true, actions = lxml.command, arguments = "3 strings" }
+implement { name = "xmlconcat", actions = lxml.concat, arguments = "3 strings" } -- \detokenize{#3}
+implement { name = "xmlconcatrange", actions = lxml.concatrange, arguments = "5 strings" } -- \detokenize{#5}
+--------- { name = "xmlconcat", actions = lxml.concat, arguments = { "string", "string", "verbatim" } }
+--------- { name = "xmlconcatrange", actions = lxml.concatrange, arguments = { "string", "string", "string", "string", "verbatim" } }
+implement { name = "xmlcontext", public = true, actions = lxml.context, arguments = "2 strings" }
+implement { name = "xmlcount", public = true, actions = lxml.count, arguments = "2 strings" }
+implement { name = "xmldepth", public = true, actions = lxml.depth, arguments = "string" }
+implement { name = "xmldelete", public = true, actions = lxml.delete, arguments = "2 strings" }
+implement { name = "xmldirect", public = true, actions = lxml.direct, arguments = "string" }
+implement { name = "xmldirectives", public = true, actions = lxml.directives.setup, arguments = "string" }
+implement { name = "xmldirectivesafter", public = true, actions = lxml.directives.after, arguments = "string" }
+implement { name = "xmldirectivesbefore", public = true, actions = lxml.directives.before, arguments = "string" }
+implement { name = "xmldisplayverbatim", public = true, actions = lxml.displayverbatim, arguments = "string" }
+implement { name = "xmlelement", public = true, actions = lxml.element, arguments = "2 strings" } -- could be integer but now we can alias
+implement { name = "xmlfilter", public = true, actions = lxml.filter, arguments = "2 strings" }
+implement { name = "xmlfilterlist", public = true, actions = lxml.filterlist, arguments = "2 strings" }
+implement { name = "xmlfirst", public = true, actions = lxml.first, arguments = "2 strings" }
+implement { name = "xmlflush", public = true, actions = lxml.flush, arguments = "string" }
+implement { name = "xmlflushcontext", public = true, actions = lxml.context, arguments = "string" }
+implement { name = "xmlflushlinewise", public = true, actions = lxml.flushlinewise, arguments = "string" }
+implement { name = "xmlflushpure", public = true, actions = lxml.pure, arguments = "string" }
+implement { name = "xmlflushspacewise", public = true, actions = lxml.flushspacewise, arguments = "string" }
+implement { name = "xmlflushtext", public = true, actions = lxml.text, arguments = "string" }
+implement { name = "xmlfunction", public = true, actions = lxml.applyfunction, arguments = "2 strings" }
+implement { name = "xmlinclude", public = true, actions = lxml.include, arguments = { "string", "string", "string", true } }
+implement { name = "xmlincludeoptions", public = true, actions = lxml.include, arguments = "4 strings" }
+implement { name = "xmlinclusion", public = true, actions = lxml.inclusion, arguments = "string" }
+implement { name = "xmlinclusionbase", public = true, actions = lxml.inclusion, arguments = { "string", false, true } }
+implement { name = "xmlinclusions", public = true, actions = lxml.inclusions, arguments = "string" }
+implement { name = "xmlindex", public = true, actions = lxml.index, arguments = "3 strings" } -- can be integer but now we can alias
+implement { name = "xmlinlineverbatim", public = true, actions = lxml.inlineverbatim, arguments = "string" }
+implement { name = "xmllast", public = true, actions = lxml.last, arguments = "2 strings" }
+implement { name = "xmllastatt", public = true, actions = lxml.lastatt }
+implement { name = "xmllastmatch", public = true, actions = lxml.lastmatch }
+implement { name = "xmllastpar", public = true, actions = lxml.lastpar }
+implement { name = "xmlloadfile", actions = lxml.load, arguments = "3 strings" }
+implement { name = "xmlloadbuffer", actions = lxml.loadbuffer, arguments = "3 strings" }
+implement { name = "xmlloaddata", actions = lxml.loaddata, arguments = "3 strings" }
+implement { name = "xmlloaddirectives", public = true, actions = lxml.directives.load, arguments = "string" }
+implement { name = "xmlmain", public = true, actions = lxml.main, arguments = "string" }
+implement { name = "xmlmatch", public = true, actions = lxml.match, arguments = "string" }
+implement { name = "xmlname", public = true, actions = lxml.name, arguments = "string" }
+implement { name = "xmlnamespace", public = true, actions = lxml.namespace, arguments = "string" }
+implement { name = "xmlnonspace", public = true, actions = lxml.nonspace, arguments = "2 strings" }
+implement { name = "xmlpar", public = true, actions = lxml.par, arguments = "2 strings" }
+implement { name = "xmlparam", public = true, actions = lxml.param, arguments = "3 strings" }
+implement { name = "xmlpath", public = true, actions = lxml.path, arguments = { "string", "'/'" } }
+implement { name = "xmlpopmatch", public = true, actions = lxml.popmatch }
+implement { name = "xmlpos", public = true, actions = lxml.pos, arguments = "string" }
+implement { name = "xmlpure", public = true, actions = lxml.pure, arguments = "2 strings" }
+implement { name = "xmlpushmatch", public = true, actions = lxml.pushmatch }
+implement { name = "xmlraw", public = true, actions = lxml.raw, arguments = "2 strings" }
+implement { name = "xmlrawtex", actions = lxml.rawtex, arguments = "2 strings" }
+implement { name = "xmlrefatt", public = true, actions = lxml.refatt, arguments = "2 strings" }
+implement { name = "xmlregisterns", public = true, actions = xml.registerns, arguments = "2 strings" }
+implement { name = "xmlremapname", public = true, actions = xml.remapname, arguments = { "lxmlid", "string","string","string" } }
+implement { name = "xmlremapnamespace", public = true, actions = xml.renamespace, arguments = { "lxmlid", "string", "string" } }
+implement { name = "xmlsave", public = true, actions = lxml.save, arguments = "2 strings" }
+implement { name = "xmlsetatt", public = true, actions = lxml.setatt, arguments = "3 strings" }
+implement { name = "xmlsetattribute", public = true, actions = lxml.setattribute, arguments = "4 strings" }
+implement { name = "xmlsetpar", public = true, actions = lxml.setpar, arguments = "3 strings" }
+implement { name = "xmlsetparam", public = true, actions = lxml.setparam, arguments = "4 strings" }
+implement { name = "xmlsetsetup", public = true, actions = lxml.setsetup, arguments = "3 strings" }
+implement { name = "xmlsnippet", public = true, actions = lxml.snippet, arguments = "2 strings" }
+implement { name = "xmlstrip", public = true, actions = lxml.strip, arguments = "2 strings" }
+implement { name = "xmlstripanywhere", public = true, actions = lxml.strip, arguments = { "string", "string", true, true } }
+implement { name = "xmlstripeverything", public = true, actions = lxml.strip, arguments = { "string", "string", true, true, true } }
+implement { name = "xmlstripnolines", public = true, actions = lxml.strip, arguments = { "string", "string", true } }
+implement { name = "xmlstripped", public = true, actions = lxml.stripped, arguments = "2 strings" }
+implement { name = "xmlstrippednolines", public = true, actions = lxml.stripped, arguments = { "string", "string", true } }
+implement { name = "xmltag", public = true, actions = lxml.tag, arguments = "string" }
+implement { name = "xmltext", public = true, actions = lxml.text, arguments = "2 strings" }
+implement { name = "xmltobuffer", public = true, actions = lxml.tobuffer, arguments = "3 strings" }
+implement { name = "xmltobuffertextonly", public = true, actions = lxml.tobuffer, arguments = { "string", "string", "string", false } }
+implement { name = "xmltobufferverbose", public = true, actions = lxml.tobuffer, arguments = { "string", "string", "string", true, true } }
+implement { name = "xmltofile", public = true, actions = lxml.tofile, arguments = "3 strings" }
+implement { name = "xmltoparameters", public = true, actions = lxml.toparameters, arguments = "string" }
+implement { name = "xmlverbatim", public = true, actions = lxml.verbatim, arguments = "string" }
+
+implement { name = "xmlstartraw", actions = lxml.startraw }
+implement { name = "xmlstopraw", actions = lxml.stopraw }
+
+implement { name = "xmlprependsetup", actions = lxml.installsetup, arguments = { 1, "string", "string" } } -- 2:*
+implement { name = "xmlappendsetup", actions = lxml.installsetup, arguments = { 2, "string", "string" } } -- 2:*
+implement { name = "xmlbeforesetup", actions = lxml.installsetup, arguments = { 3, "string", "string", "string" } } -- 2:*
+implement { name = "xmlaftersetup", actions = lxml.installsetup, arguments = { 4, "string", "string", "string" } } -- 2:*
+implement { name = "xmlremovesetup", actions = lxml.removesetup, arguments = "2 strings" } -- 1:*
+implement { name = "xmlflushsetups", actions = lxml.flushsetups, arguments = "3 strings" } -- 2:*
+implement { name = "xmlresetsetups", actions = lxml.resetsetups, arguments = "string" }
implement { name = "xmlgetindex", actions = lxml.getindex, arguments = "2 strings" }
implement { name = "xmlwithindex", actions = lxml.withindex, arguments = "3 strings" }
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.mkiv
index 09358e11cba..52514519a96 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-ini.mkiv
@@ -34,7 +34,7 @@
\def\ctxlxml #1{\ctxlua{lxml.#1}}
-% for now indirect
+% for now indirect .. this will change when we have updated luatex (scan_argument)
\def\xmlconcat #1#2#3{\clf_xmlconcat {#1}{#2}{\detokenize{#3}}}
\def\xmlconcatrange #1#2#3#4#5{\clf_xmlconcatrange{#1}{#2}{#3}{#4}{\detokenize{#5}}}
@@ -49,93 +49,94 @@
% aliased
-\let\xmlall \clf_xmlall
-\let\xmlatt \clf_xmlatt
-\let\xmlattdef \clf_xmlattdef
-\let\xmlattribute \clf_xmlattribute
-\let\xmlattributedef \clf_xmlattributedef
-\let\xmlbadinclusions \clf_xmlbadinclusions
-\let\xmlchainatt \clf_xmlchainatt
-\let\xmlchainattdef \clf_xmlchainattdef
-\let\xmlchecknamespace \clf_xmlchecknamespace
-\let\xmlcommand \clf_xmlcommand
-\let\xmlcontext \clf_xmlcontext
-\let\xmlcount \clf_xmlcount
-\let\xmldelete \clf_xmldelete
-\let\xmldirect \clf_xmldirect % in loops, not dt but root
-\let\xmldirectives \clf_xmldirectives
-\let\xmldirectivesafter \clf_xmldirectivesafter
-\let\xmldirectivesbefore \clf_xmldirectivesbefore
-\let\xmldisplayverbatim \clf_xmldisplayverbatim
-\let\xmlelement \clf_xmlelement
-\let\xmlfilter \clf_xmlfilter
-\let\xmlfilterlist \clf_xmlfilterlist
-\let\xmlfirst \clf_xmlfirst
-\let\xmlflush \clf_xmlflush
-\let\xmlflushcontext \clf_xmlflushcontext
-\let\xmlflushlinewise \clf_xmlflushlinewise
-\let\xmlflushpure \clf_xmlflushpure
-\let\xmlflushspacewise \clf_xmlflushspacewise
-\let\xmlflushtext \clf_xmlflushtext
-\let\xmlfunction \clf_xmlfunction
-\let\xmlinclude \clf_xmlinclude
-\let\xmlincludeoptions \clf_xmlincludeoptions
-\let\xmlinclusion \clf_xmlinclusion
-\let\xmlinclusionbase \clf_xmlinclusionbase
-\let\xmlinclusions \clf_xmlinclusions
-\let\xmlindex \clf_xmlindex
-\let\xmlinlineverbatim \clf_xmlinlineverbatim
-\let\xmllast \clf_xmllast
-\let\xmllastatt \clf_xmllastatt
-\let\xmllastmatch \clf_xmllastmatch
-\let\xmllastpar \clf_xmllastpar
-\let\xmlloaddirectives \clf_xmlloaddirectives
-\let\xmlmain \clf_xmlmain
-\let\xmlmatch \clf_xmlmatch
-\let\xmlname \clf_xmlname
-\let\xmlnamespace \clf_xmlnamespace
-\let\xmlnonspace \clf_xmlnonspace
-\let\xmlpar \clf_xmlpar
-\let\xmlparam \clf_xmlparam
-\let\xmlpath \clf_xmlpath
-\let\xmlpopmatch \clf_xmlpopmatch
-\let\xmlpos \clf_xmlpos
-\let\xmlposition \clf_xmlindex
-\let\xmlpure \clf_xmlpure
-\let\xmlpushmatch \clf_xmlpushmatch
-\let\xmlraw \clf_xmlraw
-\let\xmlrefatt \clf_xmlrefatt
-\let\xmlregisterns \clf_xmlregisterns % document
-\let\xmlremapname \clf_xmlremapname % element
-\let\xmlremapnamespace \clf_xmlremapnamespace % document
-\let\xmlsave \clf_xmlsave
-\let\xmlsetatt \clf_xmlsetatt
-\let\xmlsetattribute \clf_xmlsetattribute
-\let\xmlsetpar \clf_xmlsetpar
-\let\xmlsetparam \clf_xmlsetparam
-\let\xmlsetsetup \clf_xmlsetsetup
-\let\xmlsnippet \clf_xmlsnippet
-\let\xmlstrip \clf_xmlstrip
-\let\xmlstripanywhere \clf_xmlstripanywhere
-\let\xmlstripnolines \clf_xmlstripnolines
-\let\xmlstripped \clf_xmlstripped
-\let\xmlstrippednolines \clf_xmlstrippednolines
-\let\xmltag \clf_xmltag
-\let\xmltext \clf_xmltext
-\let\xmltobuffer \clf_xmltobuffer % id pattern name
-\let\xmltobuffertextonly \clf_xmltobuffertextonly % id pattern name
-\let\xmltobufferverbose \clf_xmltobufferverbose % id pattern name
-\let\xmltofile \clf_xmltofile % id pattern filename
-\let\xmltoparameters \clf_xmltoparameters
-\let\xmlverbatim \clf_xmlverbatim
-
-\unexpanded\def\xmlinfo#1{\hbox{\ttxx[\clf_xmlname{#1}]}}
+%let\xmlall \clf_xmlall
+%let\xmlatt \clf_xmlatt
+%let\xmlattdef \clf_xmlattdef
+%let\xmlattribute \clf_xmlattribute
+%let\xmlattributedef \clf_xmlattributedef
+%let\xmlbadinclusions \clf_xmlbadinclusions
+%let\xmlchainatt \clf_xmlchainatt
+%let\xmlchainattdef \clf_xmlchainattdef
+%let\xmlchecknamespace \clf_xmlchecknamespace
+%let\xmlcommand \clf_xmlcommand
+%let\xmlcontext \clf_xmlcontext
+%let\xmlcount \clf_xmlcount
+%let\xmldelete \clf_xmldelete
+%let\xmldirect \clf_xmldirect % in loops, not dt but root
+%let\xmldirectives \clf_xmldirectives
+%let\xmldirectivesafter \clf_xmldirectivesafter
+%let\xmldirectivesbefore \clf_xmldirectivesbefore
+%let\xmldisplayverbatim \clf_xmldisplayverbatim
+%let\xmlelement \clf_xmlelement
+%let\xmlfilter \clf_xmlfilter
+%let\xmlfilterlist \clf_xmlfilterlist
+%let\xmlfirst \clf_xmlfirst
+%let\xmlflush \clf_xmlflush
+%let\xmlflushcontext \clf_xmlflushcontext
+%let\xmlflushlinewise \clf_xmlflushlinewise
+%let\xmlflushpure \clf_xmlflushpure
+%let\xmlflushspacewise \clf_xmlflushspacewise
+%let\xmlflushtext \clf_xmlflushtext
+%let\xmlfunction \clf_xmlfunction
+%let\xmlinclude \clf_xmlinclude
+%let\xmlincludeoptions \clf_xmlincludeoptions
+%let\xmlinclusion \clf_xmlinclusion
+%let\xmlinclusionbase \clf_xmlinclusionbase
+%let\xmlinclusions \clf_xmlinclusions
+%let\xmlindex \clf_xmlindex
+%let\xmlinlineverbatim \clf_xmlinlineverbatim
+%let\xmllast \clf_xmllast
+%let\xmllastatt \clf_xmllastatt
+%let\xmllastmatch \clf_xmllastmatch
+%let\xmllastpar \clf_xmllastpar
+%let\xmlloaddirectives \clf_xmlloaddirectives
+%let\xmlmain \clf_xmlmain
+%let\xmlmatch \clf_xmlmatch
+%let\xmlname \clf_xmlname
+%let\xmlnamespace \clf_xmlnamespace
+%let\xmlnonspace \clf_xmlnonspace
+%let\xmlpar \clf_xmlpar
+%let\xmlparam \clf_xmlparam
+%let\xmlpath \clf_xmlpath
+%let\xmlpopmatch \clf_xmlpopmatch
+%let\xmlpos \clf_xmlpos
+%let\xmlpure \clf_xmlpure
+%let\xmlpushmatch \clf_xmlpushmatch
+%let\xmlraw \clf_xmlraw
+%let\xmlrefatt \clf_xmlrefatt
+%let\xmlregisterns \clf_xmlregisterns % document
+%let\xmlremapname \clf_xmlremapname % element
+%let\xmlremapnamespace \clf_xmlremapnamespace % document
+%let\xmlsave \clf_xmlsave
+%let\xmlsetatt \clf_xmlsetatt
+%let\xmlsetattribute \clf_xmlsetattribute
+%let\xmlsetpar \clf_xmlsetpar
+%let\xmlsetparam \clf_xmlsetparam
+%let\xmlsetsetup \clf_xmlsetsetup
+%let\xmlsnippet \clf_xmlsnippet
+%let\xmlstrip \clf_xmlstrip
+%let\xmlstripanywhere \clf_xmlstripanywhere
+%let\xmlstripnolines \clf_xmlstripnolines
+%let\xmlstripped \clf_xmlstripped
+%let\xmlstrippednolines \clf_xmlstrippednolines
+%let\xmltag \clf_xmltag
+%let\xmltext \clf_xmltext
+%let\xmltobuffer \clf_xmltobuffer % id pattern name
+%let\xmltobuffertextonly \clf_xmltobuffertextonly % id pattern name
+%let\xmltobufferverbose \clf_xmltobufferverbose % id pattern name
+%let\xmltofile \clf_xmltofile % id pattern filename
+%let\xmltoparameters \clf_xmltoparameters
+%let\xmlverbatim \clf_xmlverbatim
+
+\let\xmlposition \xmlindex
+
+\unexpanded\def\xmlinfo#1{\hbox{\ttxx[\xmlname{#1}]}}
\unexpanded\def\xmlshow#1{\startpacked\ttx\xmlverbatim{#1}\stoppacked}
% the next one is handy for mode runs because it enforces a consistent
% #1 indexing (needed when using \xmltext{main:123}{...} like calls
-\let\xmladdindex \clf_xmladdindex
+%let\xmladdindex \clf_xmladdindex
% we need to pass the last argument as function, so
@@ -185,23 +186,23 @@
% these are expandable! todo: \xmldoifelseattribute
-\let\xmldoif \clf_xmldoif
-\let\xmldoifnot \clf_xmldoifnot
-\let\xmldoifelse \clf_xmldoifelse
-\let\xmldoiftext \clf_xmldoiftext
-\let\xmldoifnottext \clf_xmldoifnottext
-\let\xmldoifelsetext \clf_xmldoifelsetext
-
-\let\xmldoifatt \clf_xmldoifatt
-\let\xmldoifnotatt \clf_xmldoifnotatt
-\let\xmldoifelseatt \clf_xmldoifelseatt
-
-\let\xmldoifempty \clf_xmldoifempty
-\let\xmldoifnotempty \clf_xmldoifnotempty
-\let\xmldoifelseempty \clf_xmldoifelseempty
-\let\xmldoifselfempty \clf_xmldoifselfempty
-\let\xmldoifnotselfempty \clf_xmldoifnotselfempty
-\let\xmldoifelseselfempty \clf_xmldoifelseselfempty
+%let\xmldoif \clf_xmldoif
+%let\xmldoifnot \clf_xmldoifnot
+%let\xmldoifelse \clf_xmldoifelse
+%let\xmldoiftext \clf_xmldoiftext
+%let\xmldoifnottext \clf_xmldoifnottext
+%let\xmldoifelsetext \clf_xmldoifelsetext
+
+%let\xmldoifatt \clf_xmldoifatt
+%let\xmldoifnotatt \clf_xmldoifnotatt
+%let\xmldoifelseatt \clf_xmldoifelseatt
+
+%let\xmldoifempty \clf_xmldoifempty
+%let\xmldoifnotempty \clf_xmldoifnotempty
+%let\xmldoifelseempty \clf_xmldoifelseempty
+%let\xmldoifselfempty \clf_xmldoifselfempty
+%let\xmldoifnotselfempty \clf_xmldoifnotselfempty
+%let\xmldoifelseselfempty \clf_xmldoifelseselfempty
\let\xmldoiftextelse \xmldoifelsetext
\let\xmldoifemptyelse \xmldoifelseempty
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-lpt.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-lpt.lua
index 5bcdfbabcb0..9e4b475fb09 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-lpt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-lpt.lua
@@ -648,7 +648,7 @@ local lp_attribute = (P("@") + P("attribute::")) / "" * Cc("(ll.at and ll.at['")
----- lp_fastpos_n = (P("-") * R("09")^1 * P(-1)) / function(s) return "(" .. s .. "<0 and (#list+".. s .. "==l))" end
local lp_fastpos_p = P("+")^0 * R("09")^1 * P(-1) / "l==%0"
-local lp_fastpos_n = P("-") * R("09")^1 * P(-1) / "(%0<0 and (#list+%0==l))"
+local lp_fastpos_n = P("-") * R("09")^1 * P(-1) / "(%0<0 and (#list+%0+1==l))" -- +1 added
local lp_fastpos = lp_fastpos_n + lp_fastpos_p
local lp_reserved = C("and") + C("or") + C("not") + C("div") + C("mod") + C("true") + C("false")
@@ -1317,6 +1317,8 @@ end
-- return false
-- end
+-- could be a hashed hash
+
expressions.oneof = function(s,...)
for i=1,select("#",...) do
if s == select(i,...) then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-tab.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-tab.lua
index 8f6379f2f8b..3af4974d300 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-tab.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-tab.lua
@@ -1292,13 +1292,26 @@ end
xml.convert = xmlconvert
-function xml.inheritedconvert(data,xmldata) -- xmldata is parent
+function xml.inheritedconvert(data,xmldata,cleanup) -- xmldata is parent
local settings = xmldata.settings
if settings then
settings.parent_root = xmldata -- to be tested
end
-- settings.no_root = true
local xc = xmlconvert(data,settings) -- hm, we might need to locate settings
+ if cleanup then
+ local x = xc.dt
+ if x then
+ x = x[1]
+ if x and x.tg == "@pi@" then
+ local dt = x.dt
+ local pi = dt and dt[1]
+ if type(pi) == "string" and find(pi,"^xml") then
+ remove(dt,1)
+ end
+ end
+ end
+ end
-- xc.settings = nil
-- xc.entities = nil
-- xc.special = nil
@@ -1414,9 +1427,17 @@ local function copy(old,p)
new[k] = t
elseif k == "dt" then
v.__p__ = nil
- v = copy(v,new)
- new[k] = v
- v.__p__ = p
+ local t = { }
+ for i=1,#v do
+ local vi = v[i]
+ if type(vi) == "table" then
+ t[i] = copy(vi,new)
+ else
+ t[i] = vi
+ end
+ end
+ new[k] = t
+ t.__p__ = p
else
new[k] = v -- so we also share entities, etc in root
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-tex.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-tex.lua
index 9ab8cafc60a..7a79ee15f4d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lxml-tex.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-tex.lua
@@ -14,7 +14,7 @@ local concat, insert, remove, sortedkeys, reversed = table.concat, table.insert,
local format, sub, gsub, find, gmatch, match = string.format, string.sub, string.gsub, string.find, string.gmatch, string.match
local type, next, tonumber, tostring, select = type, next, tonumber, tostring, select
local lpegmatch = lpeg.match
-local P, S, C, Cc, Cs = lpeg.P, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs
+local P, S, C = lpeg.P, lpeg.S, lpeg.C
local patterns = lpeg.patterns
local setmetatableindex = table.setmetatableindex
local formatters, strip = string.formatters, string.strip
@@ -472,6 +472,7 @@ lxml.addindex = addindex
implement {
name = "xmladdindex",
arguments = "string",
+ public = true,
actions = addindex,
}
@@ -1754,6 +1755,23 @@ local function concatlist(collected,separator,lastseparator,textonly) -- test th
concatrange(collected,false,false,separator,lastseparator,textonly)
end
+local function depth(collected)
+ local d = 0
+ if collected then
+ local c = collected and collected[1]
+ if c.tg then
+ while c do
+ d = d + 1
+ c = c.__p__
+ if not c then
+ break
+ end
+ end
+ end
+ end
+ contextsprint(ctxcatcodes,d)
+end
+
texfinalizers.first = first
texfinalizers.last = last
texfinalizers.all = all
@@ -1777,6 +1795,7 @@ texfinalizers.concatrange = concatrange
texfinalizers.chainattribute = chainattribute
texfinalizers.chainpath = chainpath
texfinalizers.default = all -- !!
+texfinalizers.depth = depth
function texfinalizers.tag(collected,n)
if collected then
@@ -1862,6 +1881,10 @@ lxml.verbatim = verbatim
-- helpers
+function lxml.depth(id)
+ depth { getid(id) }
+end
+
function lxml.first(id,pattern)
local collected = xmlapplylpath(getid(id),pattern)
if collected then
@@ -2070,7 +2093,8 @@ do
implement {
name = "xmldoifatt",
arguments = "3 strings",
- actions = function(id,k,v)
+ public = true,
+ actions = function(id,k,v)
local e = getid(id)
ctx_doif(e and e.at[k] == v or false)
end
@@ -2079,7 +2103,8 @@ do
implement {
name = "xmldoifnotatt",
arguments = "3 strings",
- actions = function(id,k,v)
+ public = true,
+ actions = function(id,k,v)
local e = getid(id)
ctx_doifnot(e and e.at[k] == v or false)
end
@@ -2088,7 +2113,8 @@ do
implement {
name = "xmldoifelseatt",
arguments = "3 strings",
- actions = function(id,k,v)
+ public = true,
+ actions = function(id,k,v)
local e = getid(id)
ctx_doifelse(e and e.at[k] == v or false)
end
@@ -2356,8 +2382,8 @@ function lxml.nonspace(id,pattern) -- slow, todo loop
xmltprint(xmlcollect(getid(id),pattern,true))
end
-function lxml.strip(id,pattern,nolines,anywhere)
- xml.strip(getid(id),pattern,nolines,anywhere)
+function lxml.strip(id,pattern,nolines,anywhere,everywhere)
+ xml.strip(getid(id),pattern,nolines,anywhere,everywhere)
end
function lxml.stripped(id,pattern,nolines)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/m-gnuplot.mkxl b/Master/texmf-dist/tex/context/base/mkiv/m-gnuplot.mkxl
deleted file mode 100644
index 2077b174182..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/m-gnuplot.mkxl
+++ /dev/null
@@ -1,97 +0,0 @@
-%D \module
-%D [ file=m-gnuplot,
-%D version=2020.02.10,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=Gnuplot,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D This is a variant on the \GNUPLOT\ terminal code. At some point (when there is a
-%D reason) I will make a proper environment that can be used for embedded code.
-
-\unexpanded\def\includegnuplotsvgfile[#1]%
- {\hbox\bgroup
- \ctxlua{metapost.startsvghashing()}%
- \includesvgfile[#1]%
- \ctxlua{metapost.stopsvghashing()}%
- \egroup}
-
-\startluacode
-
-local modificationtime = lfs.modification
-local longtostring = string.longtostring
-local formatters = string.formatters
-local expandfilename = dir.expandname
-local isfile = lfs.isfile
-
-local runner = sandbox.registerrunner {
- name = "gnuplot to svg",
- program = "gnuplot",
- template = longtostring [[
- -e "set output '%newname%'; set terminal svg"
- "%oldname%"
- ]],
- checkers = {
- oldname = "readable",
- newname = "writable",
- },
-}
-
-figures.programs.gnuplot = {
- runner = runner,
-}
-
-local function remap(specification)
- local oldname = specification.fullname
- if oldname then
- local newname = file.replacesuffix(oldname,"svg")
- local oldtime = modificationtime(oldname) or 0
- local newtime = modificationtime(newname) or 0
- if newtime == 0 or oldtime > newtime then
- runner {
- newname = expandfilename(newname),
- oldname = expandfilename(oldname),
- }
- end
- if isfile(newname) then
- local only = file.nameonly(newname)
- local name = formatters["svg-%s-inclusion"](only)
- local code = formatters["\\includegnuplotsvgfile[%s]\\resetbuffer[%s]"](newname,name)
- buffers.assign(name,code)
- specification.format = "buffer"
- specification.fullname = name
- end
- end
- return specification
-end
-
-figures.remappers.gp = { svg = remap }
-
-\stopluacode
-
-\continueifinputfile{m-gnuplot.mkxl}
-
-\startluacode
-io.savedata("m-gnuplot-demo.gp", [[
-set format xy "$%g$"
-
-set title 'This is a plot of $y=\\sin(x)$'
-set xlabel 'This is the $x$ axis'
-set ylabel 'This is the $y$ axis'
-
-plot [0:6.28] [0:1] sin(x)
-]])
-\stopluacode
-
-\starttext
-
- \externalfigure[m-gnuplot-demo.gp][conversion=svg,width=4cm]
-
- \externalfigure[m-gnuplot-demo.gp][conversion=svg,width=8cm]
-
-\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/m-oldbibtex.mkiv b/Master/texmf-dist/tex/context/base/mkiv/m-oldbibtex.mkiv
index 08c23e7cc87..3300e0d799a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/m-oldbibtex.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/m-oldbibtex.mkiv
@@ -10,7 +10,12 @@
%C This module is part of the \CONTEXT\ macro||package and is therefore copyrighted
%D by \PRAGMA. See mreadme.pdf for details.
-\loadmarkfile{bibl-bib}
-\loadmarkfile{bibl-tra}
+\ifconditional\contextlmtxmode
+ \loadmkivfile{bibl-bib}
+ \loadmkivfile{bibl-tra}
+\else
+ \loadmkivfile{bibl-bib}
+ \loadmkxlfile{bibl-tra}
+\fi
\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-act.lua b/Master/texmf-dist/tex/context/base/mkiv/math-act.lua
index 1f0140960fe..e1ef751d7ed 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-act.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-act.lua
@@ -55,7 +55,11 @@ end
function mathematics.initializeparameters(target,original)
local mathparameters = original.mathparameters
if mathparameters and next(mathparameters) then
- target.mathparameters = mathematics.dimensions(mathparameters)
+ mathparameters = mathematics.dimensions(mathparameters)
+ if not mathparameters.SpaceBeforeScript then
+ mathparameters.SpaceBeforeScript = mathparameters.SpaceAfterScript
+ end
+ target.mathparameters = mathparameters
end
end
@@ -224,117 +228,6 @@ sequencers.appendaction("mathparameters","system","mathematics.overloadparameter
sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont")
sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaftercopyingfont")
-local virtualized = mathematics.virtualized
-
-function mathematics.overloaddimensions(target,original,set)
- local goodies = target.goodies
- if goodies then
- for i=1,#goodies do
- local goodie = goodies[i]
- local mathematics = goodie.mathematics
- local dimensions = mathematics and mathematics.dimensions
- if dimensions then
- if trace_defining then
- report_math("overloading dimensions in %a @ %p",target.properties.fullname,target.parameters.size)
- end
- local characters = target.characters
- local descriptions = target.descriptions
- local parameters = target.parameters
- local factor = parameters.factor
- local hfactor = parameters.hfactor
- local vfactor = parameters.vfactor
- -- to be sure
- target.type = "virtual"
- target.properties.virtualized = true
- --
- local function overload(dimensions)
- for unicode, data in next, dimensions do
- local character = characters[unicode]
- if not character then
- local c = virtualized[unicode]
- if c then
- character = characters[c]
- end
- end
- if character then
- --
- local width = data.width
- local height = data.height
- local depth = data.depth
- if trace_defining and (width or height or depth) then
- report_math("overloading dimensions of %C, width %p, height %p, depth %p",
- unicode,width or 0,height or 0,depth or 0)
- end
- if width then character.width = width * hfactor end
- if height then character.height = height * vfactor end
- if depth then character.depth = depth * vfactor end
- --
- local xoffset = data.xoffset
- local yoffset = data.yoffset
- if xoffset == "llx" then
- local d = descriptions[unicode]
- if d then
- xoffset = - d.boundingbox[1] * hfactor
- character.width = character.width + xoffset
- xoffset = rightcommand[xoffset]
- else
- xoffset = nil
- end
- elseif xoffset and xoffset ~= 0 then
- xoffset = rightcommand[xoffset * hfactor]
- else
- xoffset = nil
- end
- if yoffset and yoffset ~= 0 then
- yoffset = upcommand[yoffset * vfactor]
- else
- yoffset = nil
- end
- if xoffset or yoffset then
- local commands = characters.commands
- if commands then
- prependcommands(commands,yoffset,xoffset)
- else
- local slot = charcommand[unicode]
- if xoffset and yoffset then
- character.commands = { xoffset, yoffset, slot }
- elseif xoffset then
- character.commands = { xoffset, slot }
- else
- character.commands = { yoffset, slot }
- end
- end
- end
- elseif trace_defining then
- report_math("no overloading dimensions of %C, not in font",unicode)
- end
- end
- end
- if set == nil then
- set = { "default" }
- end
- if set == "all" or set == true then
- for name, set in next, dimensions do
- overload(set)
- end
- else
- if type(set) == "string" then
- set = utilities.parsers.settings_to_array(set)
- end
- if type(set) == "table" then
- for i=1,#set do
- local d = dimensions[set[i]]
- if d then
- overload(d)
- end
- end
- end
- end
- end
- end
- end
-end
-
-- no, it's a feature now (see good-mth):
--
-- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.overloaddimensions")
@@ -350,6 +243,8 @@ mathematics.tweaks = tweaks
-- these could go to math-fbk
+-- local virtualized = mathematics.virtualized
+--
-- local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap)
-- local characters = target.characters
-- -- if not characters[newchr] then -- xits needs an enforce
@@ -599,8 +494,10 @@ interfaces.implement {
-- if not fonts then
-- fonts = { }
-- target.fonts = fonts
+-- if not CONTEXTLMTXMODE or CONTEXTLMTXMODE == 0 then
-- target.type = "virtual"
-- target.properties.virtualized = true
+-- end
-- end
-- if #fonts == 0 then
-- fonts[1] = { id = 0, size = size } -- sel, will be resolved later
@@ -705,8 +602,10 @@ function mathematics.finishfallbacks(target,specification,fallbacks)
fonts = { }
target.fonts = fonts
end
+ --
target.type = "virtual"
target.properties.virtualized = true
+ --
if #fonts == 0 then
fonts[1] = { id = 0, size = size } -- self, will be resolved later
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-ali.mkiv b/Master/texmf-dist/tex/context/base/mkiv/math-ali.mkiv
index 400326d2691..e617224d22d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-ali.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-ali.mkiv
@@ -50,23 +50,6 @@
\def\displayopenupvalue{.25\bodyfontsize}
-% \def\math_build_eqalign
-% {\scratchtoks\emptytoks
-% \d_math_eqalign_distance\mathalignmentparameter\c!distance
-% \scratchcounterone\mathalignmentparameter\c!m
-% \scratchcountertwo\mathalignmentparameter\c!n
-% \normalexpanded{\scratchtoks{\the\scratchtoks\the\t_math_align_a}}%
-% \scratchcounter\plusone
-% \dorecurse{\numexpr\scratchcounterone*\scratchcountertwo-\plusone\relax}
-% {\ifnum\scratchcounter=\scratchcountertwo
-% \scratchcounter\plusone
-% \scratchtoks\expandafter{\the\scratchtoks\math_eqalign_distance}%
-% \else
-% \advance\scratchcounter\plusone
-% \fi
-% \normalexpanded{\scratchtoks{\the\scratchtoks\the\t_math_align_b}}}%
-% \normalexpanded{\scratchtoks{\the\scratchtoks\the\t_math_align_c}}}
-
\def\math_build_eqalign
{\scratchtoks\emptytoks
\d_math_eqalign_distance\mathalignmentparameter\c!distance\relax
@@ -78,6 +61,7 @@
{\ifnum\scratchcounter=\scratchcountertwo
\scratchcounter\plusone
\etoksapp\scratchtoks{\math_eqalign_distance}%
+ \etoksapp\scratchtoks{\global\c_math_eqalign_column\zerocount}%
\else
\advance\scratchcounter\plusone
\fi
@@ -395,7 +379,7 @@
{\advance\c_math_eqalign_column\plusone\math_eqalign_set_column}% takes argument
\global\c_math_eqalign_column\plusone
\dostarttagged\t!math\empty
- \dostarttagged\t!mathtable\currentmathalignment
+ \dostarttagged\t!mtable\currentmathalignment
\numberedeqalign}
\def\math_alignment_stop
@@ -473,13 +457,13 @@
\def\math_first_in_eqalign
{\global\c_math_eqalign_column\plusone
- \dostarttagged\t!mathtablerow \empty
- \dostarttagged\t!mathtablecell\empty}
+ \dostarttagged\t!mtablerow \empty
+ \dostarttagged\t!mtablecell\empty}
\def\math_next_in_eqalign
{\global\advance\c_math_eqalign_column\plusone
\dostoptagged % finish cell
- \dostarttagged\t!mathtablecell\empty}
+ \dostarttagged\t!mtablecell\empty}
\def\math_left_of_eqalign
{\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname
@@ -832,7 +816,7 @@
\def\math_matrix_start_table
{\global\c_math_eqalign_column\zerocount
\dostarttagged\t!math\empty
- \dostarttagged\t!mathtable\empty}
+ \dostarttagged\t!mtable\empty}
\def\math_matrix_stop_table
{\dostoptagged
@@ -840,13 +824,13 @@
\def\math_matrix_start_row
{\noalign{\global\c_math_eqalign_column\zerocount}%
- \dostarttagged\t!mathtablerow\empty}
+ \dostarttagged\t!mtablerow\empty}
\def\math_matrix_stop_row
{\dostoptagged}
\unexpanded\def\math_matrix_start_cell
- {\dostarttagged\t!mathtablecell\empty
+ {\dostarttagged\t!mtablecell\empty
\hss
\math_left_of_eqalign
\startimath
@@ -1012,12 +996,12 @@
\let\mathmatrixleft \empty % experimental hook
\let\mathmatrixright\empty % experimental hook
-\setvalue{\??mathmatrixalignlocation\v!top }{\raise\dimexpr(\nextboxdp-\nextboxht)/2 +\mathaxisheight\textfont\zerocount\relax}
+\setvalue{\??mathmatrixalignlocation\v!top }{\raise\dimexpr(\nextboxdp-\nextboxht)/2 +\mathaxisheight\mathstyle\relax}
\setvalue{\??mathmatrixalignlocation\v!high }{\raise\dimexpr(\nextboxdp-\nextboxht)/2\relax}
\setvalue{\??mathmatrixalignlocation\v!center}{\relax}
\setvalue{\??mathmatrixalignlocation\v!lohi} {\relax}
\setvalue{\??mathmatrixalignlocation\v!normal}{\relax}
-\setvalue{\??mathmatrixalignlocation\v!bottom}{\lower\dimexpr(\nextboxdp-\nextboxht)/2 +\mathaxisheight\textfont\zerocount\relax}
+\setvalue{\??mathmatrixalignlocation\v!bottom}{\lower\dimexpr(\nextboxdp-\nextboxht)/2 +\mathaxisheight\mathstyle\relax}
\setvalue{\??mathmatrixalignlocation\v!low }{\lower\dimexpr(\nextboxdp-\nextboxht)/2\relax}
\def\math_matrix_finish_nextbox
@@ -1908,7 +1892,7 @@
\begingroup
\beforedisplayspace
% subset of \everydisplay:
- \attribute \mathmodeattribute \plusone
+ \c_attr_mathmode\plusone
\settrue \indisplaymath
% end of subset
\informulatrue}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-def.mkiv b/Master/texmf-dist/tex/context/base/mkiv/math-def.mkiv
index 641f7411edb..901f075d348 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-def.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-def.mkiv
@@ -1,4 +1,4 @@
-%D \module
+ %D \module
%D [ file=math-tex,
%D version=2001.04.12,
%D title=\CONTEXT\ Math Macros,
@@ -15,13 +15,15 @@
\unprotect
-%D Some day this will be done at the lua end.
+\pushoverloadmode % cap etc
\startluacode
mathematics.define(\number\defaultmathfamily)
-- mathematics.xml.registerentities()
\stopluacode
+\popoverloadmode
+
\activatemathcharacters
%D The \mfunction macro is an alternative for \hbox with a controlable font
@@ -80,6 +82,8 @@
{\savenormalmeaning{#1}%
\expandafter\def\expandafter#1\expandafter{\csname normal\csstring#1\endcsname#2}}
+\pushoverloadmode
+
\setoperatorlimits \int \intlimits
\setoperatorlimits \iint \intlimits
\setoperatorlimits \iiint \intlimits
@@ -90,6 +94,8 @@
\setoperatorlimits \ointclockwise \intlimits
\setoperatorlimits \ointctrclockwise \intlimits
+\popoverloadmode
+
%D \macros
%D {centercolon, colonminus, minuscolon, colonequals, equalscolon,
%D colonapprox, approxcolon, colonsim, simcolon, coloncolon,
@@ -131,6 +137,8 @@
%D The next macros take care of the space between the colon and the
%D relation symbol.
+\pushoverloadmode
+
\definemathcommand [colonsep] {\mkern-1.2mu}
\definemathcommand [doublecolonsep] {\mkern-0.9mu}
@@ -154,6 +162,8 @@
\definemathcommand [coloncolonsim] [rel] {\coloncolon\colonsep\sim}
\definemathcommand [simcoloncolon] [rel] {\sim\coloncolon\colonsep}
+\popoverloadmode
+
% \appendtoks
% \def\over{\primitive\over}%
% \to \everymathematics
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-dim.lua b/Master/texmf-dist/tex/context/base/mkiv/math-dim.lua
index eb7adb53f97..06b4bbd97fd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-dim.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-dim.lua
@@ -62,6 +62,7 @@ local defaults = {
radical_vgap = { default = { "RadicalVerticalGap", "default_rule_thickness+(abs(default_rule_thickness)/4)" },
display_style = { "RadicalDisplayStyleVerticalGap", "default_rule_thickness+(abs(math_x_height)/4)" }, },
space_after_script = { default = { "SpaceAfterScript", "script_space" }, },
+ space_before_script = { default = { "SpaceAfterScript", "script_space" }, },
stack_denom_down = { default = { "StackBottomShiftDown", "denom2" },
cramped_display_style = { "StackBottomDisplayStyleShiftDown", "denom1" },
display_style = { "StackBottomDisplayStyleShiftDown", "denom1" }, },
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua b/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
index 963461de5cf..6b43a901bdd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
@@ -53,13 +53,15 @@ function fallbacks.apply(target,original)
-- we also have forcedsize ... at this moment we already passed through
-- constructors.scale so we have this set
local parameters = target.parameters
+ local properties = target.properties
local mathsize = parameters.mathsize
if mathsize < 1 or mathsize > 3 then
return
end
- local characters = target.characters
- local size = parameters.size
- local usedfonts = target.fonts
+ local characters = target.characters
+ local size = parameters.size
+ local usedfonts = target.fonts
+ local compactmath = properties.compactmath
if not usedfonts then
usedfonts = { { id = 0 } } -- we need at least one entry (automatically done anyway)
target.fonts = usedfonts
@@ -91,6 +93,10 @@ function fallbacks.apply(target,original)
else
textdata = target
end
+ if compactmath then
+ scriptid = textid
+ scriptscriptid = textid
+ end
if scriptid and scriptid ~= 0 then
scriptindex = #usedfonts + 1
scriptdata = identifiers[scriptid]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-fen.mkiv b/Master/texmf-dist/tex/context/base/mkiv/math-fen.mkiv
index 6c6724bf52e..246ff989d93 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-fen.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-fen.mkiv
@@ -65,9 +65,39 @@
% we need the direct use of \Udelimiter because of { etc
+%D So we can do:
+%D
+%D \starttyping
+%D $ a + \fenced[bar][size=1] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=2] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=3] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=4] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=big] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=Big] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=bigg]{\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=Bigg]{\frac {b} {c}} + d $
+%D $ a + \fenced[bar][factor=1] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][factor=2] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][factor=4] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar] {\frac {b} {c}} + d $
+%D \stoptyping
+
\newconditional\c_math_fenced_mirror \settrue \c_math_fenced_mirror
\newconditional\c_math_fenced_sized \setfalse\c_math_fenced_sized
+\installcorenamespace {mathfencesize}
+
+\setvalue{\??mathfencesize big}{1}
+\setvalue{\??mathfencesize Big}{2}
+\setvalue{\??mathfencesize bigg}{3}
+\setvalue{\??mathfencesize Bigg}{4}
+
+\def\math_fenced_force_size#1#2%
+ {\c_attr_mathsize\numexpr
+ #1*\plushundred
+ +\ifcsname\??mathfencesize#2\endcsname\lastnamedcs\else#2\fi
+ \relax}
+
\unexpanded\def\math_fenced_inject#1#2#3#4%
{\ifx#1\empty
#2.%
@@ -200,9 +230,6 @@
\edef\currentmathfence{#1}%
\dosingleempty\math_fenced_fenced_indeed}
-\def\math_fenced_force_size#1#2%
- {\attribute\mathsizeattribute\numexpr#1*\plushundred+#2\relax}
-
% \unexpanded\def\math_fenced_fenced_indeed[#1]#2%
% {\iffirstargument\setupcurrentmathfence[#1]\fi
% \math_fenced_fenced_common
@@ -635,6 +662,11 @@
\installcorenamespace{mathbig}
+\setvalue{\??mathbig1}{0.85}
+\setvalue{\??mathbig2}{1.15}
+\setvalue{\??mathbig3}{1.45}
+\setvalue{\??mathbig4}{1.75}
+
\unexpanded\def\choosemathbig#1#2% so we accept \big{||} as well
{{\naturalhbox\bgroup
\startimath
@@ -644,13 +676,32 @@
\math_fenced_force_size\bigmathdelimitervariant{#1}\relax
\math_fenced_step#2\relax
\else
- \math_fenced_step#2{\vpack to\csname\??mathbig\number#1\endcsname\bodyfontsize{}}%
+ \math_fenced_step#2{\vpack to\csname\??mathbig#1\endcsname\bodyfontsize{}}%
\fi
\nulldelimiterspace\zeropoint\relax
\mathsurround\zeropoint
\stopimath
\egroup}}
+% needs testing:
+%
+% \unexpanded\def\choosemathbig#1#2% so we accept \big{||} as well
+% {{\naturalhbox\bgroup
+% \startimath
+% \ifcase\bigmathdelimitermethod
+% \Uvextensible#2\relax
+% \or
+% \math_fenced_force_size\bigmathdelimitervariant{#1}\relax
+% \Uvextensible#2\relax
+% \else
+% \scratchdimen.5\dimexpr\csname\??mathbig\number#1\endcsname\bodyfontsize+1.1\exheight\relax
+% \Uvextensible\s!axis \s!depth \scratchdimen \s!height \scratchdimen #2\relax
+% \fi
+% \nulldelimiterspace\zeropoint\relax
+% \mathsurround\zeropoint
+% \stopimath
+% \egroup}}
+
\def\math_fenced_step#1#2%
{\setfalse\c_math_fenced_unknown
\setfalse\c_math_fenced_done
@@ -675,15 +726,10 @@
\math_fenced_step#2\relax
\endgroup}
-\setvalue{\??mathbig1}{0.85}
-\setvalue{\??mathbig2}{1.15}
-\setvalue{\??mathbig3}{1.45}
-\setvalue{\??mathbig4}{1.75}
-
-\definemathcommand [big] {\choosemathbig\plusone }
-\definemathcommand [Big] {\choosemathbig\plustwo }
-\definemathcommand [bigg] {\choosemathbig\plusthree}
-\definemathcommand [Bigg] {\choosemathbig\plusfour }
+\definemathcommand [big] {\choosemathbig1}
+\definemathcommand [Big] {\choosemathbig2}
+\definemathcommand [bigg] {\choosemathbig3}
+\definemathcommand [Bigg] {\choosemathbig4}
\definemathcommand [bigl] [open] [one] {\big}
\definemathcommand [bigm] [rel] [one] {\big}
@@ -789,10 +835,10 @@
\let\math_fences_normal_middle\middle
\let\math_fences_normal_both \leftorright
-\unexpanded\def\math_fences_auto_left #1{\attribute\mathautofenceattribute\plusone #1\attribute\mathautofenceattribute\attributeunsetvalue}
-\unexpanded\def\math_fences_auto_right #1{\attribute\mathautofenceattribute\plustwo #1\attribute\mathautofenceattribute\attributeunsetvalue}
-\unexpanded\def\math_fences_auto_middle#1{\attribute\mathautofenceattribute\plusthree#1\attribute\mathautofenceattribute\attributeunsetvalue}
-\unexpanded\def\math_fences_auto_both #1{\attribute\mathautofenceattribute\plusfour #1\attribute\mathautofenceattribute\attributeunsetvalue}
+\unexpanded\def\math_fences_auto_left #1{\c_attr_mathautofence\plusone #1\c_attr_mathautofence\attributeunsetvalue}
+\unexpanded\def\math_fences_auto_right #1{\c_attr_mathautofence\plustwo #1\c_attr_mathautofence\attributeunsetvalue}
+\unexpanded\def\math_fences_auto_middle#1{\c_attr_mathautofence\plusthree#1\c_attr_mathautofence\attributeunsetvalue}
+\unexpanded\def\math_fences_auto_both #1{\c_attr_mathautofence\plusfour #1\c_attr_mathautofence\attributeunsetvalue}
\let\autofenceopen \math_fences_auto_left % for testing
\let\autofenceclose \math_fences_auto_right % for testing
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-frc.lua b/Master/texmf-dist/tex/context/base/mkiv/math-frc.lua
index 190c364101d..fa3ac515fe1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-frc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-frc.lua
@@ -13,6 +13,7 @@ local variables = interfaces.variables
local v_no = variables.no
local v_yes = variables.yes
+local v_hidden = variables.hidden
local resolved = {
[0x007B] = "\\{",
@@ -35,11 +36,12 @@ local function mathfraction(how,left,right,width)
else
context("\\atopwithdelims%s%s",resolved[left],resolved[right])
end
- elseif how == v_yes then
+ elseif how == v_yes or how == v_hidden then
+ local norule = how == v_hidden and LUATEXFUNCTIONALITY > 7361 and " norule " or ""
if left == 0x002E and right == 0x002E then
- context("\\normalabove%ssp",width)
+ context("\\normalabove%s%s%ssp",norule,width)
else
- context("\\abovewithdelims%s%s%ssp",resolved[left],resolved[right],width)
+ context("\\abovewithdelims%s%s%s%s%ssp",norule,resolved[left],resolved[right],width)
end
else -- v_auto
if left == 0x002E and right == 0x002E then
@@ -55,3 +57,41 @@ interfaces.implement {
actions = mathfraction,
arguments = { "string", "number", "number", "dimen" }
}
+
+-- experimental code in lmtx
+
+if CONTEXTLMTXMODE > 0 then
+
+ local ctx_Uatop = context.Uatop
+ local ctx_Uover = context.Uover
+
+ local function umathfraction(how,left,right,width)
+ if how == v_no then
+ if left == 0x002E and right == 0x002E then
+ ctx_Uatop()
+ else
+ context("\\Uatopwithdelims%s%s",resolved[left],resolved[right])
+ end
+ elseif how == v_yes or how == v_hidden then
+ local norule = how == v_hidden and " norule " or ""
+ if left == 0x002E and right == 0x002E then
+ context("\\Uabove%s%ssp",norule,width)
+ else
+ context("\\Uabovewithdelims%s%s%s%ssp",norule,resolved[left],resolved[right],width)
+ end
+ else -- v_auto
+ if left == 0x002E and right == 0x002E then
+ ctx_Uover()
+ else
+ context("\\Uoverwithdelims%s%s",resolved[left],resolved[right])
+ end
+ end
+ end
+
+ interfaces.implement {
+ name = "umathfraction",
+ actions = umathfraction,
+ arguments = { "string", "number", "number", "dimen" }
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-frc.mkiv b/Master/texmf-dist/tex/context/base/mkiv/math-frc.mkiv
index 97107a6bf91..1b0149f96b4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-frc.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-frc.mkiv
@@ -361,10 +361,12 @@
\unexpanded\def\xfrac#1#2{\normalxfrac{\let\xfrac\xxfrac#1}{\let\xfrac\xxfrac#2}}
-%D Spacing:
+%D Spacing (sensitive for definition of \triggermathstyle:
-\unexpanded\def\nomathfractiongaps {\normalexpanded{\math_no_fraction_gaps \triggermathstyle\mathstyle}} % maybe collect settings
-\unexpanded\def\overlaymathfractiongaps{\normalexpanded{\math_overlay_fraction_gaps\triggermathstyle\mathstyle}} % maybe collect settings
+% \ifcase\contextlmtxmode
+
+\unexpanded\def\nomathfractiongaps {\normalexpanded{\math_no_fraction_gaps \mathstyletrigger\mathstyle}} % maybe collect settings
+\unexpanded\def\overlaymathfractiongaps{\normalexpanded{\math_overlay_fraction_gaps\mathstyletrigger\mathstyle}} % maybe collect settings
\unexpanded\def\math_no_fraction_gaps#1%
{\Umathfractionnumup #1\zeropoint
@@ -377,6 +379,21 @@
\Umathfractiondenomvgap#1\zeropoint
\Umathfractiondenomdown#1\zeropoint}
+% \else
+
+% \unexpanded\def\math_no_fraction_gaps
+% {\Umathfractionnumup \mathstyle\zeropoint
+% \Umathfractiondenomdown\mathstyle\zeropoint}
+%
+% \unexpanded\def\math_overlay_fraction_gaps
+% {\Umathfractionnumup \mathstyle\zeropoint
+% \Umathfractionnumvgap \mathstyle\zeropoint
+% %Umathfractionrule \mathstyle\zeropoint
+% \Umathfractiondenomvgap\mathstyle\zeropoint
+% \Umathfractiondenomdown\mathstyle\zeropoint}
+
+% \fi
+
\installcorenamespace{mathfractiondistance}
\letvalue{\??mathfractiondistance\v!none }\nomathfractiongaps
@@ -613,8 +630,6 @@
%D More fracking (for Alan):
-\def\s!vfrac{vfrac}
-
\unexpanded\def\math_frac_colored_vulgar#1#2%
{\savecolor
\colo_helpers_activate\p_math_fractions_color
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-inc.lua b/Master/texmf-dist/tex/context/base/mkiv/math-inc.lua
index 010d29a359a..7c32adde6ca 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-inc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-inc.lua
@@ -20,6 +20,8 @@ local undent = buffers.undent
local f_entity = string.formatters["&x%X;"]
local f_blob = string.formatters['\n\n\n\n%s']
+local report_tags = logs.reporter("structure","tags")
+
local all = nil
local back = nil
@@ -62,7 +64,12 @@ local function getblob(n)
local root = xml.load(full)
for c in xml.collected(root,"formulacontent") do
local index = tonumber(c.at.n)
- all[index] = f_blob(index,beautify(xmltext(c,"math") or ""))
+ local data = beautify(xmltext(c,"math") or "")
+ if index and data then
+ all[index] = f_blob(index,data)
+ else
+ report_tags("no formula content id")
+ end
end
local it = mathematics.alphabets.regular.it
for k, v in next, it.digits do back[v] = k end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/math-ini.lua
index 0af9a2121ba..19bf868020a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-ini.lua
@@ -97,9 +97,17 @@ local classes = allocate {
root = 16, -- a private one
}
-local open_class = 4
-local middle_class = 4
-local close_class = 5
+local open_class = 4
+local middle_class = 4
+local close_class = 5
+local accent_class = 8
+local radical_class = 9
+local topaccent_class = 11
+local botaccent_class = 12
+local under_class = 13
+local over_class = 14
+local delimiter_class = 15
+local root_class = 16
local accents = allocate {
accent = true, -- some can be both
@@ -231,39 +239,73 @@ local setmathcharacter = function(class,family,slot,unicode,mset,dset)
return mset, dset
end
-local f_accent = formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ]
-local f_topaccent = formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ]
-local f_botaccent = formatters[ [[\ugdef\%s{\Umathbotaccent 0 "%X "%X }]] ]
-local f_over = formatters[ [[\ugdef\%s{\Udelimiterover "%X "%X }]] ]
-local f_under = formatters[ [[\ugdef\%s{\Udelimiterunder "%X "%X }]] ]
-local f_fence = formatters[ [[\ugdef\%s{\Udelimiter "%X "%X "%X }]] ]
-local f_delimiter = formatters[ [[\ugdef\%s{\Udelimiter 0 "%X "%X }]] ]
-local f_radical = formatters[ [[\ugdef\%s{\Uradical "%X "%X }]] ]
-local f_root = formatters[ [[\ugdef\%s{\Uroot "%X "%X }]] ]
------ f_char = formatters[ [[\ugdef\%s{\Umathchar "%X "%X "%X }]]
-local f_char = formatters[ [[\Umathchardef\%s "%X "%X "%X ]] ]
+-- todo: make nice setters for this in lua
+
+local f_accent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ]
+local f_topaccent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ]
+local f_botaccent = formatters[ [[\defUmathbotaccent \%s{%X}{%X}{%X}]] ]
+local f_over = formatters[ [[\defUdelimiterover \%s{%X}{%X}{%X}]] ]
+local f_under = formatters[ [[\defUdelimiterunder\%s{%X}{%X}{%X}]] ]
+local f_fence = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ]
+local f_delimiter = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ]
+local f_radical = formatters[ [[\defUradical \%s{%X}{%X}]] ]
+local f_root = formatters[ [[\defUroot \%s{%X}{%X}]] ]
+local f_char = formatters[ [[\defUmathchar \%s{%X}{%X}{%X}]] ]
+
+local texmathchardef = tex.mathchardef
+
+-- local setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing
+-- if class == classes.accent then
+-- ctx_sprint(f_topaccent(name,0,family,slot))
+-- elseif class == classes.topaccent then
+-- ctx_sprint(f_topaccent(name,0,family,slot))
+-- elseif class == classes.botaccent then
+-- ctx_sprint(f_botaccent(name,0,family,slot))
+-- elseif class == classes.over then
+-- ctx_sprint(f_over(name,0,family,slot))
+-- elseif class == classes.under then
+-- ctx_sprint(f_under(name,0,family,slot))
+-- elseif class == open_class or class == close_class or class == middle_class then
+-- setdelcode("global",slot,{family,slot,0,0})
+-- ctx_sprint(f_fence(name,class,family,slot))
+-- elseif class == classes.delimiter then
+-- setdelcode("global",slot,{family,slot,0,0})
+-- ctx_sprint(f_delimiter(name,0,family,slot))
+-- elseif class == classes.radical then
+-- ctx_sprint(f_radical(name,family,slot))
+-- elseif class == classes.root then
+-- ctx_sprint(f_root(name,family,slot))
+-- elseif texmathchardef then
+-- texmathchardef(name,class,family,slot,"permanent")
+-- else
+-- -- beware, open/close and other specials should not end up here
+-- ctx_sprint(f_char(name,class,family,slot))
+-- end
+-- end
local setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing
- if class == classes.accent then
- ctx_sprint(f_accent(name,family,slot))
- elseif class == classes.topaccent then
- ctx_sprint(f_topaccent(name,family,slot))
- elseif class == classes.botaccent then
- ctx_sprint(f_botaccent(name,family,slot))
- elseif class == classes.over then
- ctx_sprint(f_over(name,family,slot))
- elseif class == classes.under then
- ctx_sprint(f_under(name,family,slot))
+ if class == accent_class then
+ ctx_sprint(f_topaccent(name,0,family,slot))
+ elseif class == topaccent_class then
+ ctx_sprint(f_topaccent(name,0,family,slot))
+ elseif class == botaccent_class then
+ ctx_sprint(f_botaccent(name,0,family,slot))
+ elseif class == over_class then
+ ctx_sprint(f_over(name,0,family,slot))
+ elseif class == under_class then
+ ctx_sprint(f_under(name,0,family,slot))
elseif class == open_class or class == close_class or class == middle_class then
setdelcode("global",slot,{family,slot,0,0})
ctx_sprint(f_fence(name,class,family,slot))
- elseif class == classes.delimiter then
+ elseif class == delimiter_class then
setdelcode("global",slot,{family,slot,0,0})
- ctx_sprint(f_delimiter(name,family,slot))
- elseif class == classes.radical then
+ ctx_sprint(f_delimiter(name,0,family,slot))
+ elseif class == radical_class then
ctx_sprint(f_radical(name,family,slot))
- elseif class == classes.root then
+ elseif class == root_class then
ctx_sprint(f_root(name,family,slot))
+ elseif texmathchardef then
+ texmathchardef(name,class,family,slot,"permanent")
else
-- beware, open/close and other specials should not end up here
ctx_sprint(f_char(name,class,family,slot))
@@ -642,7 +684,7 @@ function mathematics.big(tfmdata,unicode,n,method)
end
end
end
- elseif method == 3 then
+ elseif method >= 3 then
local size = 1.33^n
if method == 4 then
size = tfmdata.parameters.size * size
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/math-ini.mkiv
index c79d3579c8b..d0e18ff4b1b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-ini.mkiv
@@ -103,9 +103,9 @@
\def\Umathaccents {\Umathaccent \s!both }
\ifdefined\Umathcharclass \else
- \def\Umathcharclass{\cldcontext{tex.getmathcode(token.scan_int())[1]}}
- \def\Umathcharfam {\cldcontext{tex.getmathcode(token.scan_int())[2]}}
- \def\Umathcharslot {\cldcontext{tex.getmathcode(token.scan_int())[3]}}
+ \def\Umathcharclass{\numexpr\cldcontext{tex.getmathcode(token.scan_int())[1]}\relax}
+ \def\Umathcharfam {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[2]}\relax}
+ \def\Umathcharslot {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[3]}\relax}
\fi
%D The attributes that we will use (todo: pack some into one but uglier code):
@@ -134,12 +134,12 @@
\fi
\appendtoks
- \attribute\mathmodeattribute\plusone
+ \c_attr_mathmode\plusone
\to \everydisplay
\appendtoks
- \attribute\mathmodeattribute\plusone
- \attribute\displaymathattribute\plusone
+ \c_attr_mathmode \plusone
+ \c_attr_displaymath\plusone
\to \everybeforedisplayformula
\setnewconstant\defaultmathfamily \zerocount % 255
@@ -596,7 +596,7 @@
\appendtoks
\ifcase\c_math_renderings_attribute\else
- \attribute\mathrenderingattribute\c_math_renderings_attribute
+ \c_attr_mathrendering\c_math_renderings_attribute
\fi
\to \everymathematics
@@ -867,10 +867,10 @@
\let\math_tags_mfunctiontxt\gobbletwoarguments
\let\math_tags_mfunctionlab\gobbletwoarguments
-\unexpanded\def\math_tags_mo_indeed#1{\begingroup \attribute\mathcategoryattribute\plusone #1\endgroup}
-\unexpanded\def\math_tags_mi_indeed#1{\begingroup \attribute\mathcategoryattribute\plustwo #1\endgroup}
-\unexpanded\def\math_tags_mn_indeed#1{\begingroup\mathupright\attribute\mathcategoryattribute\plusthree\math_set_o_both#1\endgroup}
-\unexpanded\def\math_tags_ms_indeed#1{\begingroup\mathupright\attribute\mathcategoryattribute\plusfour \math_set_p_both#1\endgroup} % todo: mathoptext
+\unexpanded\def\math_tags_mo_indeed#1{\begingroup \c_attr_mathcategory\plusone #1\endgroup}
+\unexpanded\def\math_tags_mi_indeed#1{\begingroup \c_attr_mathcategory\plustwo #1\endgroup}
+\unexpanded\def\math_tags_mn_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusthree\math_set_o_both#1\endgroup}
+\unexpanded\def\math_tags_ms_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusfour \math_set_p_both#1\endgroup} % todo: mathoptext
\newconditional\c_apply_function
@@ -1390,7 +1390,7 @@
\to \everysetupmathematics
\appendtoks
- \attribute\mathbidiattribute\ifconditional\c_math_right_to_left\c_math_bidi\else\attributeunsetvalue\fi
+ \c_attr_mathbidi\ifconditional\c_math_right_to_left\c_math_bidi\else\attributeunsetvalue\fi
\to \everyswitchmathematics
%D Delayed: greek.
@@ -1445,15 +1445,15 @@
% only used local
-\unexpanded\def\mathgreekupright{\attribute\mathgreekattribute"222\relax}
-\unexpanded\def\mathgreekitalic {\attribute\mathgreekattribute"333\relax}
-\unexpanded\def\mathgreekdefault{\attribute\mathgreekattribute"000\relax}
+\unexpanded\def\mathgreekupright{\c_attr_mathgreek"222\relax}
+\unexpanded\def\mathgreekitalic {\c_attr_mathgreek"333\relax}
+\unexpanded\def\mathgreekdefault{\c_attr_mathgreek"000\relax}
\let\mathgreeknormal\mathgreekupright
\let\mathgreeknone \mathgreekdefault
\appendtoks
- \attribute\mathgreekattribute\c_math_greek_attribute
+ \c_attr_mathgreek\c_math_greek_attribute
\to \everymathematics
\setupmathematics
@@ -1488,7 +1488,7 @@
\appendtoks
\math_collapsing_initialize
- \attribute\mathcollapsingattribute\c_math_collapsing_attribute
+ \c_attr_mathcollapsing\c_math_collapsing_attribute
\to \everymathematics
\setupmathematics
@@ -1526,7 +1526,7 @@
\appendtoks
\math_italics_initialize
- \attribute\mathitalicsattribute\c_math_italics_attribute
+ \c_attr_mathitalics\c_math_italics_attribute
\to \everymathematics
% \setupmathematics % done later
@@ -1563,7 +1563,7 @@
\appendtoks
\math_kernpairs_initialize
- \attribute\mathkernpairsattribute\c_math_kernpairs_attribute
+ \c_attr_mathkernpairs\c_math_kernpairs_attribute
\to \everymathematics
\setupmathematics
@@ -1611,13 +1611,13 @@
% \mathcode\c_math_period\c_math_special
% \let,\math_punctuation_comma
% \let.\math_punctuation_period
-% \attribute\mathpunctuationattribute\plustwo}
+% \c_attr_mathpunctuation\plustwo}
%
% \unexpanded\gdef\math_punctuation_initialize_yes
-% {\attribute\mathpunctuationattribute\plustwo}
+% {\c_attr_mathpunctuation\plustwo}
%
% \unexpanded\gdef\math_punctuation_initialize_nop
-% {\attribute\mathpunctuationattribute\plusone}
+% {\c_attr_mathpunctuation\plusone}
%
% \egroup
%
@@ -1760,7 +1760,7 @@
\setupmathematics
[\v!autopunctuation=\v!no] % no | yes | all | comma | yes,semicolon | all,semicolon
-%D The consequences of settign this are as follows:
+%D The consequences of setting this are as follows:
%D
%D \def\TestA#1#2#3%
%D {\ifnum#1=0 \type{#2}\else\setupmathematics[autopunctuation={#2}]$#3$\fi}
@@ -1841,6 +1841,8 @@
% error
\fi}
+\let\mathstyletrigger\triggermathstyle
+
\def\triggeredmathstyleparameter#1% to bypass the relax
{\ifcase\numexpr\normalmathstyle\relax
#1\displaystyle \or % 0
@@ -1980,7 +1982,7 @@
\scriptscriptfont \else
\textfont
\fi
- \zeropoint}
+ \zerocount}
\def\mathemwidth
{\fontdimen
@@ -1996,7 +1998,7 @@
\scriptscriptfont \else
\textfont
\fi
- \zeropoint}
+ \zerocount}
%D A plain inheritance:
@@ -2778,8 +2780,9 @@
%
% 0x002B=plus 0x2212=minus 0x2013=endash
-\unexpanded\def\mathplus {+}
-\unexpanded\def\mathminus{\ifmmode –\else\iffontchar\font`−−\else –\fi\fi}
+\unexpanded\def\mathplus {+}
+\unexpanded\def\mathminus {\ifmmode –\else\iffontchar\font`−−\else –\fi\fi}
+\unexpanded\def\mathplusminus{±}
%D The \type {\displaywidth} is only known inside a display formula, so we need to catch
%D it when still zero.
@@ -2825,7 +2828,7 @@
\to \everyswitchmathematics % only in mathematics
\appendtoks
- \attribute\mathdomainattribute\c_math_domain_attribute
+ \c_attr_mathdomain\c_math_domain_attribute
\to \everymathematics
\setupmathematics
@@ -2899,17 +2902,35 @@
%D Experiment
\unexpanded\def\math_scripts_stack
- {\attribute\mathunstackattribute\attributeunsetvalue}
+ {\c_attr_mathunstack\attributeunsetvalue}
\unexpanded\def\math_scripts_unstack
{\clf_enablescriptunstacking
- \attribute\mathunstackattribute\plusone}
+ \c_attr_mathunstack\plusone}
\appendtoks
\let\stackscripts \math_scripts_stack
\let\unstackscripts\math_scripts_unstack
\to \everymathematics
+%D Expensive (tracing and inject) but a primitive (using factors) is tricky as we
+%D want this frozen support.
+
+\def\math_openup_parameter#1#2%
+ {\ifzeropt#1\displaystyle \else\ifdim#1\displaystyle =\maxdimen\else\frozen#1\displaystyle #2#1\displaystyle \fi\fi
+ \ifzeropt#1\crampeddisplaystyle \else\ifdim#1\crampeddisplaystyle =\maxdimen\else\frozen#1\crampeddisplaystyle #2#1\crampeddisplaystyle \fi\fi
+ \ifzeropt#1\textstyle \else\ifdim#1\textstyle =\maxdimen\else\frozen#1\textstyle #2#1\textstyle \fi\fi
+ \ifzeropt#1\crampedtextstyle \else\ifdim#1\crampedtextstyle =\maxdimen\else\frozen#1\crampedtextstyle #2#1\crampedtextstyle \fi\fi
+ \ifzeropt#1\scriptstyle \else\ifdim#1\scriptstyle =\maxdimen\else\frozen#1\scriptstyle #2#1\scriptstyle \fi\fi
+ \ifzeropt#1\crampedscriptstyle \else\ifdim#1\crampedscriptstyle =\maxdimen\else\frozen#1\crampedscriptstyle #2#1\crampedscriptstyle \fi\fi
+ \ifzeropt#1\scriptscriptstyle \else\ifdim#1\scriptscriptstyle =\maxdimen\else\frozen#1\scriptscriptstyle #2#1\scriptscriptstyle \fi\fi
+ \ifzeropt#1\crampedscriptscriptstyle\else\ifdim#1\crampedscriptscriptstyle=\maxdimen\else\frozen#1\crampedscriptscriptstyle#2#1\crampedscriptscriptstyle\fi\fi}
+
+\unexpanded\def\mathopenupparameter#1#2%
+ {\ifdim#2\points=\zeropoint\else
+ \math_openup_parameter#1{#2}%
+ \fi}
+
\protect \endinput
% % not used (yet)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-map.lua b/Master/texmf-dist/tex/context/base/mkiv/math-map.lua
index 2233722a03d..97860b923ba 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-map.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-map.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['math-map'] = {
version = 1.001,
+ optimize = true,
comment = "companion to math-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-noa.lua b/Master/texmf-dist/tex/context/base/mkiv/math-noa.lua
index f53410b18cd..1fb763a3b6c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-noa.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-noa.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['math-noa'] = {
version = 1.001,
+ optimize = true,
comment = "companion to math-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -124,10 +125,14 @@ local getdepth = nuts.getdepth
local getnucleus = nuts.getnucleus
local getsub = nuts.getsub
local getsup = nuts.getsup
+local getsubpre = nuts.getsubpre
+local getsuppre = nuts.getsuppre
local setnucleus = nuts.setnucleus
local setsub = nuts.setsub
local setsup = nuts.setsup
+local setsubpre = nuts.setsubpre
+local setsuppre = nuts.setsuppre
local flush_node = nuts.flush
local copy_node = nuts.copy
@@ -198,7 +203,7 @@ local subbox_code = nodecodes.subbox -- attr list
local submlist_code = nodecodes.submlist -- attr list
local mathchar_code = nodecodes.mathchar -- attr fam char
local mathtextchar_code = nodecodes.mathtextchar -- attr fam char
-local delim_code = nodecodes.delim -- attr small_fam small_char large_fam large_char
+local delimiter_code = nodecodes.delimiter -- attr small_fam small_char large_fam large_char
----- style_code = nodecodes.style -- attr style
----- parameter_code = nodecodes.parameter -- attr style
local math_choice = nodecodes.choice -- attr display text script scriptscript
@@ -273,7 +278,11 @@ local function process(start,what,n,parent)
local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
noad = getsup (start) if noad then process(noad,what,n,start) end -- list
noad = getsub (start) if noad then process(noad,what,n,start) end -- list
- elseif id == mathchar_code or id == mathtextchar_code or id == delim_code then
+ if getsubpre then
+ noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list
+ end
+ elseif id == mathchar_code or id == mathtextchar_code or id == delimiter_code then
break
elseif id == subbox_code or id == submlist_code then
local noad = getlist(start) if noad then process(noad,what,n,start) end -- list (not getlist !)
@@ -293,12 +302,20 @@ local function process(start,what,n,parent)
local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
noad = getsup (start) if noad then process(noad,what,n,start) end -- list
noad = getsub (start) if noad then process(noad,what,n,start) end -- list
+ if getsubpre then
+ noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list
+ end
noad = getfield(start,"left") if noad then process(noad,what,n,start) end -- delimiter
noad = getfield(start,"degree") if noad then process(noad,what,n,start) end -- list
elseif id == accent_code then
local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
noad = getsup (start) if noad then process(noad,what,n,start) end -- list
noad = getsub (start) if noad then process(noad,what,n,start) end -- list
+ if getsubpre then
+ noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list
+ end
noad = getfield(start,"accent") if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"bot_accent") if noad then process(noad,what,n,start) end -- list
-- elseif id == style_code then
@@ -322,6 +339,10 @@ local function processnested(current,what,n)
noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
noad = getsup (current) if noad then process(noad,what,n,current) end -- list
noad = getsub (current) if noad then process(noad,what,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list
+ end
elseif id == subbox_code or id == submlist_code then
noad = getlist(current) if noad then process(noad,what,n,current) end -- list (not getlist !)
elseif id == fraction_code then
@@ -340,12 +361,20 @@ local function processnested(current,what,n)
noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
noad = getsup (current) if noad then process(noad,what,n,current) end -- list
noad = getsub (current) if noad then process(noad,what,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list
+ end
noad = getfield(current,"left") if noad then process(noad,what,n,current) end -- delimiter
noad = getfield(current,"degree") if noad then process(noad,what,n,current) end -- list
elseif id == accent_code then
noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
noad = getsup (current) if noad then process(noad,what,n,current) end -- list
noad = getsub (current) if noad then process(noad,what,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list
+ end
noad = getfield(current,"accent") if noad then process(noad,what,n,current) end -- list
noad = getfield(current,"bot_accent") if noad then process(noad,what,n,current) end -- list
end
@@ -358,6 +387,10 @@ local function processstep(current,process,n,id)
noad = getnucleus(current) if noad then process(noad,n,current) end -- list
noad = getsup (current) if noad then process(noad,n,current) end -- list
noad = getsub (current) if noad then process(noad,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,n,current) end -- list
+ end
elseif id == subbox_code or id == submlist_code then
noad = getlist(current) if noad then process(noad,n,current) end -- list (not getlist !)
elseif id == fraction_code then
@@ -376,12 +409,20 @@ local function processstep(current,process,n,id)
noad = getnucleus(current) if noad then process(noad,n,current) end -- list
noad = getsup (current) if noad then process(noad,n,current) end -- list
noad = getsub (current) if noad then process(noad,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,n,current) end -- list
+ end
noad = getfield(current,"left") if noad then process(noad,n,current) end -- delimiter
noad = getfield(current,"degree") if noad then process(noad,n,current) end -- list
elseif id == accent_code then
noad = getnucleus(current) if noad then process(noad,n,current) end -- list
noad = getsup (current) if noad then process(noad,n,current) end -- list
noad = getsub (current) if noad then process(noad,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,n,current) end -- list
+ end
noad = getfield(current,"accent") if noad then process(noad,n,current) end -- list
noad = getfield(current,"bot_accent") if noad then process(noad,n,current) end -- list
end
@@ -542,7 +583,7 @@ do
end
end
end
- families[delim_code] = function(pointer)
+ families[delimiter_code] = function(pointer)
if getfield(pointer,"small_fam") == 0 then
local a = getattr(pointer,a_mathfamily)
if a and a > 0 then
@@ -574,7 +615,7 @@ do
-- will become:
- -- families[delim_code] = function(pointer)
+ -- families[delimiter_code] = function(pointer)
-- if getfam(pointer) == 0 then
-- local a = getattr(pointer,a_mathfamily)
-- if a and a > 0 then
@@ -717,7 +758,7 @@ do
end
end
- relocate[delim_code] = function(pointer)
+ relocate[delimiter_code] = function(pointer)
if trace_analyzing then
setnodecolor(pointer,"font:fina")
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-rad.mkvi b/Master/texmf-dist/tex/context/base/mkiv/math-rad.mkvi
index c0b128a616c..a11ec045d0d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-rad.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-rad.mkvi
@@ -26,12 +26,24 @@
% \def\rootradical{\Uroot \defaultmathfamily "221A } % can be done in char-def
% \def\surdradical{\Uradical \defaultmathfamily "221A } % can be done in char-def
-\def\root#1\of{\rootradical{#1}} % #2
+\unexpanded\def\root#1\of{\rootradical{#1}} % #2
\unexpanded\def\sqrt{\doifelsenextoptionalcs\rootwithdegree\rootwithoutdegree}
-\unexpanded\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird
- {\normalexpanded{\rootradical{\normalunexpanded{#1}}{\noexpand\triggermathstyle{\normalmathstyle}\normalunexpanded{#2}}}}
+% \ifcase \contextlmtxmode
+
+ \unexpanded\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird
+ {\normalexpanded{\rootradical
+ {\normalunexpanded{#1}}%
+ {\noexpand\triggermathstyle{\number\normalmathstyle}%
+ \normalunexpanded{#2}}}}
+
+% \else % experimental new keyword: (maybe keywords should come after the symbol)
+%
+% \unexpanded\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird
+% {\Uroot style \normalmathstyle "0 "221A {#1}{#2}}
+%
+% \fi
\unexpanded\def\rootwithdegree[#1]{\rootradical{#1}}
\unexpanded\def\rootwithoutdegree {\rootradical {}}
@@ -43,8 +55,36 @@
% \let\normalsurd\surd % \Uradical "0 "221A
% \unexpanded\def\surd{\normalsurd{}}
-
-%D The real thing:
+%D The real thing. If needed one can control matters with one of the many
+%D \type {\Umath...} parameters.
+%D
+%D \starttyping
+%D \def\R {\Umathradicaldegreeafter\textstyle0pt}
+%D \def\RR{\Umathradicaldegreeafter\textstyle\dimexpr
+%D \Umathradicaldegreeafter\textstyle+.1em\relax}
+%D \def\RRR{\frozen\Umathradicaldegreeafter\textstyle\dimexpr
+%D \Umathradicaldegreeafter\textstyle+.2em\relax}
+%D
+%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par
+%D $ \sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D $ \RR\sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D
+%D \def\R {\Umathradicaldegreeafter\textstyle
+%D 0pt}
+%D \def\RR {\Umathradicaldegreeafter\textstyle
+%D 0.95\Umathradicaldegreeafter\textstyle}
+%D \def\RRR{\frozen\Umathradicaldegreeafter\textstyle
+%D 0.9\Umathradicaldegreeafter\textstyle}
+%D
+%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par
+%D $ \sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D $ \RR\sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D
+%D \def\RR {\mathopenupparameter\Umathradicaldegreeafter{.1}}
+%D
+%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par
+%D $ \sqrt[3]{5} {\RR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D \stoptyping
\installcorenamespace{mathradical}
\installcorenamespace{mathradicalalternative}
@@ -157,10 +197,11 @@
enddef ;
\stopMPextensions
-\startuniqueMPgraphic{math:radical:default}%{...}
+\startuniqueMPgraphic{minifun::math:radical:default}%{...}
draw
math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset)
- withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30
+ % withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30
+ withpen pencircle scaled OverlayLineWidth
% dashed evenly
withcolor OverlayLineColor ;
\stopuniqueMPgraphic
@@ -177,7 +218,8 @@
\d_overlay_height \ht\nextbox
\d_overlay_depth \dp\nextbox
\d_overlay_offset \scratchoffset
- \d_overlay_linewidth\linewidth
+ \d_overlay_linewidth\the\dimexpr\triggeredmathstyleparameter\Umathfractionrule
+ %
\edef\overlaylinecolor{\mathradicalparameter\c!color}%
%
\edef\p_mp{\mathradicalparameter\c!mp}%
@@ -201,7 +243,7 @@
\fi
\endgroup}
-\definemathradical[sqrt][mp=math:radical:default]
+\definemathradical[sqrt][mp=minifun::math:radical:default]
% \setupmathradical[sqrt][alternative=normal,color=darkblue]
% \setupmathradical[sqrt][alternative=mp,color=darkgreen]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-stc.mkvi b/Master/texmf-dist/tex/context/base/mkiv/math-stc.mkvi
index 8048bf92364..8f2a20440f3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-stc.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-stc.mkvi
@@ -16,12 +16,12 @@
\unprotect
-%D WARNING: If the code here changes, the export needs to be checked! Stackers are rather
-%D special because the order in mathml matters, so we flush in [base under over] order. We
-%D also do some analysis at the \TEX\ end (passing the right variant). It's easy in the
-%D export to deal with it but in the pdf stream less trivial as we don't actually analyze
-%D there.
-
+%D WARNING: If the code here changes, the export needs to be checked! Stackers are
+%D rather special because the order in mathml matters, so we flush in [base under
+%D over] order. We also do some analysis at the \TEX\ end (passing the right
+%D variant). It's easy in the export to deal with it but in the pdf stream less
+%D trivial as we don't actually analyze there.
+%D
%D At some point the \MKII\ arrow mechanism has been converted to \MKIV, but we kept
%D most of the logic. We now have a more generic variant dealing with extensibles.
%D There are a few demands than we need to meet:
@@ -42,11 +42,11 @@
%D to support the traditional Latin Modern Virtual math font those were extended
%D with a couple of virtual extensibles as well.
%D
-%D {\em For the moment we still have some mess here: we can deal with known dimensions, but
-%D fillers (like \type {\rightarrowfil} don't work with \OPENTYPE\ extensibles yet
-%D because there is no way to let them stretch like leaders. At some point \LUATEX\
-%D might provide a auto||fit||to||encapsulated||box and if not I will cook up a \LUA\
-%D based variant.}
+%D {\em For the moment we still have some mess here: we can deal with known
+%D dimensions, but fillers (like \type {\rightarrowfil} don't work with \OPENTYPE\
+%D extensibles yet because there is no way to let them stretch like leaders. At some
+%D point \LUATEX\ might provide a auto||fit||to||encapsulated||box and if not I will
+%D cook up a \LUA\ based variant.}
%D
%D We could mess with something like \type {$mid\limits^{top}_{bottom}$} but we like
%D a bit more control. At some point we need to add some hacks to get exports
@@ -54,9 +54,9 @@
%D
%D In the end we have a more flexible mechanism which also handles text variants.
-%D When wrapping up some math developments I decided to add mp support here
-%D as well. A nice evening job with Joe Bonamassa performing live on the big
-%D screen (real nice bluray's). See meta-imp-mat.mkiv for examples.
+%D When wrapping up some math developments I decided to add mp support here as well.
+%D A nice evening job with Joe Bonamassa performing live on the big screen (real
+%D nice bluray's). See meta-imp-mat.mkiv for examples.
% possible improvements:
%
@@ -150,9 +150,9 @@
\let\math_stackers_stop_tagged \relax
\appendtoks
- \def\math_stackers_start_tagged_mid{\dostarttagged\t!mathstackermid\empty\hbox\bgroup}%
- \def\math_stackers_start_tagged_top{\dostarttagged\t!mathstackertop\empty\hbox\bgroup}%
- \def\math_stackers_start_tagged_bot{\dostarttagged\t!mathstackerbot\empty\hbox\bgroup}%
+ \def\math_stackers_start_tagged_mid{\dostarttagged\t!mstackermid\empty\hbox\bgroup}%
+ \def\math_stackers_start_tagged_top{\dostarttagged\t!mstackertop\empty\hbox\bgroup}%
+ \def\math_stackers_start_tagged_bot{\dostarttagged\t!mstackerbot\empty\hbox\bgroup}%
\def\math_stackers_stop_tagged {\egroup\dostoptagged}%
\to \everysetuptagging
@@ -328,7 +328,7 @@
{\begingroup
\edef\currentmathstackers{#category}%
\mathstackersparameter\c!left\relax
- \dostarttagged\t!mathstacker\currentmathstackers
+ \dostarttagged\t!mstacker\currentmathstackers
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\p_offset {\mathstackersparameter\c!offset}%
\edef\p_location {\mathstackersparameter\c!location}%
@@ -415,7 +415,7 @@
\advance\scratchwidth2\scratchhoffset
%
\ifcase#method\relax
- \dostarttagged\t!mathstackermid\empty
+ \dostarttagged\t!mstackermid\empty
\setbox\scratchboxthree\csname\??mathstackersalternative\p_alternative\endcsname
\dostoptagged
\fi
@@ -433,20 +433,15 @@
\ifcsname\??mathstackerslocation\p_location\endcsname
\ifcase\csname\??mathstackerslocation\p_location\endcsname\relax
\scratchdistance\zeropoint
- \or
- % top
+ \or % top
\scratchdistance\zeropoint
- \or
- % high
+ \or % high
\scratchdistance.25\htdp\scratchboxthree
- \or
- % centered
+ \or % centered
\scratchdistance.5\htdp\scratchboxthree
- \or
- % low
+ \or % low
\scratchdistance.75\htdp\scratchboxthree
- \or
- % bottom
+ \or % bottom
\scratchdistance\htdp\scratchboxthree
\else
\scratchdistance\zeropoint
@@ -602,7 +597,7 @@
\setupcurrentmathstackers[#settings]%
\fi
\mathstackersparameter\c!left\relax
- \dostarttagged\t!mathstacker\currentmathstackers
+ \dostarttagged\t!mstacker\currentmathstackers
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\m_math_stackers_text_middle {#text}%
%
@@ -798,7 +793,7 @@
\unexpanded\def\math_stackers_make_double_text#where#category#codepoint#text#extra%
{\math_stackers_start_group{#category}%
\mathstackersparameter\c!left\relax
- \dostarttagged\t!mathstacker\currentmathstackers
+ \dostarttagged\t!mstacker\currentmathstackers
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\currentmathstackers{#category}%
%
@@ -1069,8 +1064,8 @@
%D We save a few definitions that we automatically got from the \type {char-def.lua}
%D database.
-% Be careful in choosing what accents you take (the code below uses a
-% combining one):
+% Be careful in choosing what accents you take (the code below uses a combining
+% one):
%
% \startbuffer
% % $\Umathaccent top 0 0 "20D7 {example}$
@@ -1224,15 +1219,15 @@
% We don't use overline and underline. This is one of the overlooked aspects of
% unicode cq. opentype math: why treat rules different than e.g. arrows and
% accents. It is a bit unfortunate that the opportunity to move math to new
-% technologies happened outside the tex domain (and/or some aspects were kept
-% while in fact they were side effects of limitations of traditional fonts).
-% From the unicode aware tex engines' implementation point of view things
-% could have been done a bit nicer but then: the community didn't seem to care
-% too much and just has to follow now.
+% technologies happened outside the tex domain (and/or some aspects were kept while
+% in fact they were side effects of limitations of traditional fonts). From the
+% unicode aware tex engines' implementation point of view things could have been
+% done a bit nicer but then: the community didn't seem to care too much and just
+% has to follow now.
%
-% Anyhow, we use a character based approach so that at least we get unicode
-% stuff in the backend (okay, we still need to deal with some cut and paste
-% issues but at least we now know what we deal with.
+% Anyhow, we use a character based approach so that at least we get unicode stuff
+% in the backend (okay, we still need to deal with some cut and paste issues but at
+% least we now know what we deal with.
% alternatively we can move the original to FE*
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-tag.lua b/Master/texmf-dist/tex/context/base/mkiv/math-tag.lua
index 9267e0f39c0..41373fcb58b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-tag.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-tag.lua
@@ -52,7 +52,7 @@ local subbox_code = nodecodes.subbox -- attr list
local submlist_code = nodecodes.submlist -- attr list
local mathchar_code = nodecodes.mathchar -- attr fam char
local mathtextchar_code = nodecodes.mathtextchar -- attr fam char
-local delim_code = nodecodes.delim -- attr small_fam small_char large_fam large_char
+local delimiter_code = nodecodes.delimiter -- attr small_fam small_char large_fam large_char
local style_code = nodecodes.style -- attr style
local choice_code = nodecodes.choice -- attr display text script scriptscript
local fence_code = nodecodes.fence -- attr subtype
@@ -259,7 +259,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
stop_tagged()
-- showtag(start,id,false)
break
- elseif id == delim_code then
+ elseif id == delimiter_code then
-- check for code
setattr(start,a_tagged,start_tagged("mo"))
stop_tagged()
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-ttv.lua b/Master/texmf-dist/tex/context/base/mkiv/math-ttv.lua
index 1f644e78834..151183212a3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-ttv.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-ttv.lua
@@ -62,7 +62,7 @@ mathencodings["large-to-small"] = {
}
-- Beware: these are (in cm/lm) below the baseline due to limitations
--- in the tfm format bu the engien (combined with the mathclass) takes
+-- in the tfm format but the engine (combined with the mathclass) takes
-- care of it. If we need them in textmode, we should make them virtual
-- and move them up but we're in no hurry with that.
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-vfu.lua b/Master/texmf-dist/tex/context/base/mkiv/math-vfu.lua
index 9090955e9c4..221bbff8975 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-vfu.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-vfu.lua
@@ -628,10 +628,6 @@ setmetatableindex(reverse, function(t,name)
return r
end)
--- use char and font hash
---
--- commands = { { "font", slot }, { "char", unicode } },
-
local function copy_glyph(main,target,original,unicode,slot)
local addprivate = fonts.helpers.addprivate
local olddata = original[unicode]
@@ -837,7 +833,6 @@ function vfmath.define(specification,set,goodies)
setmetatableindex(goodies,parent.goodies)
end
--
- properties.virtualized = true
properties.hasitalics = true
properties.hasmath = true
--
@@ -850,9 +845,11 @@ function vfmath.define(specification,set,goodies)
-- we need to set some values in main as well (still?)
--
main.fullname = properties.fullname
- main.type = "virtual"
main.nomath = false
--
+ properties.virtualized = true
+ main.type = "virtual"
+ --
parameters.x_height = parameters.x_height or 0
--
local already_reported = false
@@ -918,7 +915,7 @@ function vfmath.define(specification,set,goodies)
else
local vectorname = ss.vector
if vectorname then
- local offset = 0xFF000
+ local offset = 0xFF000 -- todo: -- private
local vector = mathencodings[vectorname]
local rotcev = reverse[vectorname]
local isextension = ss.extension
@@ -926,11 +923,11 @@ function vfmath.define(specification,set,goodies)
local fc = fs.characters
local fd = fs.descriptions
local si = shared[s]
+ local fontname = fs.properties.name or "unknown"
local skewchar = ss.skewchar
for unicode, index in next, vector do
local fci = fc[index]
if not fci then
- local fontname = fs.properties.name or "unknown"
local rf = reported[fontname]
if not rf then rf = { } reported[fontname] = rf end
local rv = rf[vectorname]
@@ -1111,7 +1108,8 @@ function vfmath.define(specification,set,goodies)
-- so better is to also reserve the id already which then involves some more
-- management (so not now).
fontlist[#fontlist+1] = {
- id = font.nextid(),
+ -- id = font.nextid(),
+ id = 0, -- self
size = size,
}
vfmath.addmissing(main,#fontlist,size)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-blb.lua b/Master/texmf-dist/tex/context/base/mkiv/meta-blb.lua
index 9ee57d80dd1..c690f3902e7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-blb.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-blb.lua
@@ -293,7 +293,7 @@ function mp.mf_inject_blob(category,str)
newblob(category,str) -- only for tracing
mp_category = category
mp_str = str
- tex.runtoks("mpblobtext")
+ tex.runlocal("mpblobtext")
end
interfaces.implement {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-fig.mkiv b/Master/texmf-dist/tex/context/base/mkiv/meta-fig.mkiv
index e89cb14425d..d18adc927c0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-fig.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-fig.mkiv
@@ -65,8 +65,8 @@
\getfiguredimensions[#1]% [\c!object=\v!no] already set
\startMPcode
draw externalfigure "#1"
- xscaled \the\dimexpr\figurewidth \relax\space % must be points
- yscaled \the\dimexpr\figureheight\relax\space % must be points
+ xsized \the\dimexpr\figurewidth \relax\space % must be points
+ ysized \the\dimexpr\figureheight\relax\space % must be points
#2 ;
\stopMPcode
\egroup}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-fnt.lua b/Master/texmf-dist/tex/context/base/mkiv/meta-fnt.lua
index 92bbe071617..54c66ceb976 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-fnt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-fnt.lua
@@ -12,6 +12,7 @@ local format = string.format
local formatters = string.formatters
local chardata = characters.data
local fontdata = fonts.hashes.identifiers
+local round = math.round
local vffonts = fonts.handlers.vf
@@ -97,7 +98,7 @@ local function process(mpxformat,name,instances,scalefactor)
local fontname = file.removesuffix(file.basename(name))
local modification = attributes.modification
local filesize = attributes.size
- local hash = file.robustname(formatters["%s %05i %03i"](fontname,scalefactor*1000,instances))
+ local hash = file.robustname(formatters["%s %05i %03i"](fontname,round(scalefactor*1000),instances))
local lists = containers.read(mpfonts.cache,hash)
if not lists or lists.modification ~= modification or lists.filesize ~= filesize or lists.instances ~= instances or lists.scalefactor ~= scalefactor then
statistics.starttiming(flusher)
@@ -167,8 +168,8 @@ local function build(g,v)
local t = { }
for d=1,#data do
t = fonts.constructors.scale(data[d],-1000)
- -- local id = font.nextid()
- -- t.fonts = { { id = id } }
+ local id = font.nextid()
+ t.fonts = { { id = id } }
fontdata[id] = t
if v[5] then
vffonts.helpers.composecharacters(t)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl
deleted file mode 100644
index d79e59f69f4..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl
+++ /dev/null
@@ -1,349 +0,0 @@
-%D \module
-%D [ file=meta-imp-gamesymbols,
-%D version=2019.10.10,
-%D title=\METAPOST\ Graphics,
-%D subtitle=Game Symbols,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D The \METAFUN\ code here is not optimal and efficient but as it serves as an
-%D example I decided to keep it simple. Also, performance is not really an issue
-%D here anyway. Inspired by the classic \quote {Concrete Mathematics} by Don Knuth
-%D we define dice and dominos, which happen to be \UNICODE\ characters now. We
-%D use this opportunity to demonstrate slightly different approached.
-
-%D Each dice gets it's own macro at the \METAPOST\ end. Watch how we use the \type
-%D {simplefun} instance in combination with a calculation wrapper. This will just
-%D execute the code and leave no traces in the text flow. The code itself is not
-%D that spectacular:
-
-\startMPcalculation{simplefun}
-
- def DiceFrame =
- pickup pencircle scaled 1/2 ;
- draw unitsquare scaled 8 ;
- pickup pencircle scaled 3/2 ;
- enddef ;
-
- vardef DiceOne =
- DiceFrame ;
- draw (4,4) ;
- enddef ;
- vardef DiceTwoA =
- DiceFrame ;
- draw (2,6) ; draw (6,2) ;
- enddef ;
- vardef DiceTwoB =
- DiceFrame ;
- draw (6,6) ; draw (2,2) ;
- enddef ;
- vardef DiceTwo =
- if hasoption "mpsfont" "option" "reverse" :
- DiceTwoB
- else :
- DiceTwoA
- fi ;
- enddef ;
- vardef DiceThreeA =
- DiceFrame ;
- draw (2,6) ; draw (4,4) ; draw (6,2) ;
- enddef ;
- vardef DiceThreeB =
- DiceFrame ;
- draw (6,6) ; draw (4,4) ; draw (2,2) ;
- enddef ;
- vardef DiceThree =
- if hasoption "mpsfont" "option" "reverse" :
- DiceThreeB
- else :
- DiceThreeA
- fi ;
- enddef ;
- vardef DiceFour =
- DiceFrame ;
- draw (2,6) ; draw (6,6) ; draw (2,2) ; draw (6,2) ;
- enddef ;
- vardef DiceFive =
- DiceFrame ;
- draw (2,6) ; draw (6,6) ; draw (4,4) ; draw (2,2) ; draw (6,2) ;
- enddef ;
- vardef DiceSix =
- DiceFrame ;
- draw (2,6) ; draw (6,6) ; draw (2,4) ; draw (6,4) ; draw (2,2) ; draw (6,2) ;
- enddef ;
-
- vardef DiceBad =
- pickup pencircle scaled 1/2 ;
- draw unitsquare scaled 8 ;
- draw (1,7) -- (7,1) ; draw (1,1) -- (7,7) ;
- enddef ;
-
- lmt_registerglyphs [
- name = "dice",
- units = 12,
- width = 8,
- height = 8,
- depth = 0,
- usecolor = true,
- ] ;
-
- lmt_registerglyph [ category = "dice", unicode = "0x2680", code = "DiceOne;" ] ;
- lmt_registerglyph [ category = "dice", unicode = "0x2681", code = "DiceTwo;" ] ;
- lmt_registerglyph [ category = "dice", unicode = "0x2682", code = "DiceThree;" ] ;
- lmt_registerglyph [ category = "dice", unicode = "0x2683", code = "DiceFour;" ] ;
- lmt_registerglyph [ category = "dice", unicode = "0x2684", code = "DiceFive;" ] ;
- lmt_registerglyph [ category = "dice", unicode = "0x2685", code = "DiceSix;" ] ;
-
- lmt_registerglyph [ category = "dice", private = "invaliddice", code = "DiceBad;" ] ;
-
-\stopMPcalculation
-
-%D At the \TEX\ end we define three features. The reverse is just there for fun. The
-%D digits features will map digits onto dice.
-
-\definefontfeature
- [dice:normal]
- [default]
- [metapost={category=dice}]
-
-\definefontfeature
- [dice:reverse]
- [default]
- [metapost={category=dice,option=reverse}]
-
-\definefontfeature
- [dice:digits]
- [dice:digits=yes]
-
-%D The mapping to dice happens here:
-
-\startluacode
-
- -- local invalid = fonts.helpers.privateslot("invaliddice")
-
- fonts.handlers.otf.addfeature("dice:digits", {
- type = "substitution",
- order = { "dice:digits" },
- nocheck = true,
- data = {
- [0x30] = "invaliddice",
- [0x31] = 0x2680,
- [0x32] = 0x2681,
- [0x33] = 0x2682,
- [0x34] = 0x2683,
- [0x35] = 0x2684,
- [0x36] = 0x2685,
- [0x37] = "invaliddice",
- [0x38] = "invaliddice",
- [0x39] = "invaliddice",
- },
- } )
-
-\stopluacode
-
-%D An example is given at the the end of this file so we now move forward with
-%D the dominos.
-
-\startMPcalculation{simplefun}
-
- %D Because there are so many dominos we predefine the shapes and then register
- %D the lot in a loop.
-
- picture Dominos[] ;
-
- Dominos[0] := image() ;
- Dominos[1] := image(draw(4,4);) ;
- Dominos[2] := image(draw(2,6);draw(6,2););
- Dominos[3] := image(draw(2,6);draw(4,4);draw(6,2););
- Dominos[4] := image(draw(2,6);draw(6,6);draw(2,2);draw(6,2););
- Dominos[5] := image(draw(2,6);draw(6,6);draw(4,4);draw(2,2);draw(6,2););
- Dominos[6] := image(draw(2,6);draw(4,6);draw(6,6);draw(2,2);draw(4,2);draw(6,2););
- % Dominos[7] := Dominos[0] ;
- % Dominos[8] := Dominos[0] ;
- % Dominos[9] := Dominos[0] ;
-
- %D Defining the font properties is straightforward:
-
- lmt_registerglyphs [
- name = "dominos",
- units = 12,
- width = 16,
- height = 8,
- depth = 0,
- usecolor = true,
- ] ;
-
- %D We have horizontal dominos:
-
- def DrawDominoH(expr a, b) =
- draw image (
- pickup pencircle scaled 1/2 ;
- if (getparameterdefault "mpsfont" "color" "") = "black" :
- fillup unitsquare xyscaled (16,8) ;
- draw (8,.5) -- (8,7.5) withcolor white ;
- pickup pencircle scaled 3/2 ;
- draw Dominos[a]
- withpen currentpen
- withcolor white ;
- draw Dominos[b] shifted (8,0)
- withpen currentpen
- withcolor white ;
- else :
- draw unitsquare xyscaled (16,8) ;
- draw (8,0) -- (8,8) ;
- pickup pencircle scaled 3/2 ;
- draw Dominos[a]
- withpen currentpen ;
- draw Dominos[b] shifted (8,0)
- withpen currentpen ;
- fi ;
- ) ;
- enddef ;
-
- %D and vertical ones. We could use the above macro and rotate and shift and reflect
- %D but why bother with it:
-
- def DrawDominoV(expr a, b) = % is H rotated and shifted
- draw image (
- pickup pencircle scaled 1/2 ;
- if (getparameterdefault "mpsfont" "color" "") = "black" :
- fillup unitsquare xyscaled (8,16) ;
- draw (.5,8) -- (7.5,8) withcolor white ;
- pickup pencircle scaled 3/2 ;
- draw Dominos[a] rotatedaround(center Dominos[a],90)
- withpen currentpen
- withcolor white ;
- draw Dominos[b] rotatedaround(center Dominos[b],90) shifted (0,8)
- withpen currentpen
- withcolor white ;
- else :
- draw unitsquare xyscaled (8,16) ;
- draw (0,8) -- (8,8) ;
- pickup pencircle scaled 3/2 ;
- draw Dominos[a] rotatedaround(center Dominos[a],90)
- withpen currentpen ;
- draw Dominos[b] rotatedaround(center Dominos[b],90) shifted (0,8)
- withpen currentpen ;
- fi ;
- ) ;
- enddef ;
-
- %D We have two simple loops that define the horizontal range:
-
- save unicode ; numeric unicode ; unicode := 127025 ; % 1F031
-
- for i=0 upto 6 :
- for j=0 upto 6 :
- lmt_registerglyph [
- category = "dominos",
- unicode = unicode,
- code = "DrawDominoH(" & decimal i & "," & decimal j & ");",
- width = 16,
- height = 8,
- ] ;
- unicode := unicode + 1 ;
- endfor ;
- endfor ;
-
- %D and the vertical range:
-
- save unicode ; numeric unicode ; unicode := 127075 ;
-
- for i=0 upto 6 :
- for j=0 upto 6 :
- lmt_registerglyph [
- category = "dominos",
- unicode = unicode,
- code = "DrawDominoV(" & decimal i & "," & decimal j & ");",
- width = 8,
- height = 16,
- ] ;
- unicode := unicode + 1 ;
- endfor ;
- endfor ;
-
- %D Now we're done at the \METAFUN\ end.
-
-\stopMPcalculation
-
-%D We predefine two features:
-
-\definefontfeature
- [dominos:white]
- [default]
- [metapost={category=dominos}]
-
-\definefontfeature
- [dominos:black]
- [default]
- [metapost={category=dominos,color=black}]
-
-\definefontfeature
- [dominos:digits]
- [dominos:digits=yes]
-
-%D This last feature is yet to be defined. We could deal with the invalid
-%D dominos with some substitution trickery but let's keep it simple.
-
-\startluacode
-
- local ligatures = { }
- local unicode = 127025
-
- for i=0x30,0x36 do
- for j=0x30,0x36 do
- ligatures[unicode] = { i, j }
- unicode = unicode + 1 ;
- end
- end
-
- fonts.handlers.otf.addfeature("dominos:digits", {
- type = "ligature",
- order = { "dominos:digits" },
- nocheck = true,
- data = ligatures,
- } )
-
-\stopluacode
-
-\continueifinputfile{meta-imp-gamesymbols.mkxl}
-
-\starttext
-
- \definefont[DominoW][Serif*dominos:white]
- \definefont[DominoB][Serif*dominos:black]
- \definefont[DominoD][Serif*dominos:white,dominos:digits]
-
- \startTEXpage[offset=3pt]
- \DominoW
- \char"1F043\quad 🀱\quad
- \char"1F052\quad 🀲\quad
- \char"1F038\quad 🀳\quad
- \darkgreen\char"1F049\quad \char"1F07B\quad
- \DominoB
- \char"1F087\quad
- \char"1F088\quad
- \char"1F089\quad
- \DominoD
- \darkred 12\quad56\quad64%
- \stopTEXpage
-
- \definefont[DiceN][Serif*dice:normal]
- \definefont[DiceR][Serif*dice:reverse]
- \definefont[DiceD][Serif*dice:normal,dice:digits]
-
- \startTEXpage[offset=3pt]
- \DiceN
- \dostepwiserecurse{"2680}{"2685}{1}{\char#1\quad}%
- \DiceN
- \dostepwiserecurse{"2680}{"2685}{1}{\char#1\quad}%
- \DiceD
- \darkblue 2\quad5\quad3\quad0
- \stopTEXpage
-
-\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-mat.mkiv b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-mat.mkiv
index 495864a9eeb..e1b5d9d0059 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-mat.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-mat.mkiv
@@ -129,7 +129,9 @@
% main handler
def math_stacker_draw_accent(expr p) =
- draw p withpen pencircle scaled OverlayLineWidth xyscaled (2,3) rotated 45 ;
+% draw p withpen pencircle scaled OverlayLineWidth xyscaled (2,3) rotated 45 ;
+% draw p withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 45 ;
+ draw p withpen pencircle scaled OverlayLineWidth ;
enddef ;
def math_stacker_draw_arrow(expr p) =
@@ -204,11 +206,16 @@
\startuniqueMPgraphic{minifun::math:radical:default}{axis,ex,em}
draw
math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset)
- withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30
+ % withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30
+ withpen pencircle scaled OverlayLineWidth
% dashed evenly
withcolor OverlayLineColor ;
\stopuniqueMPgraphic
+% already setup:
+%
+% definemathradical [sqrt] [mp=minifun::math:radical:default]
+
\continueifinputfile{meta-imp-mat.mkiv}
\setupmathstackers [both] [color=darkred,alternative=mp]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-symbols.mkxl b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-symbols.mkxl
deleted file mode 100644
index f88fd6f8787..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-symbols.mkxl
+++ /dev/null
@@ -1,99 +0,0 @@
-%D \module
-%D [ file=meta-imp-symbols,
-%D version=2019.10.01,
-%D title=\METAPOST\ Graphics,
-%D subtitle=Symbols,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D This is an (experimental) prelude to more.
-
-\startMPcalculation{simplefun}
-
- pen SymbolPen ; SymbolPen := pencircle scaled 1/4 ;
-
- vardef SymbolBullet = fill unitcircle scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x2022 •
- vardef SymbolDash = draw (origin--right) scaled 3 shifted (1.5,3.0) withpen SymbolPen scaled 2 enddef ; % 0x2013 –
- vardef SymbolTriangle = draw unittriangle scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25B6 ⊳
- vardef SymbolCircle = fill unitcircle scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x2218 ∘
- vardef SymbolSquare = draw unitsquare scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25A1 □
- vardef SymbolDiamond = draw unitdiamond scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x22C4 ⋄
- vardef SymbolBlackTriangle = fillup unittriangle scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25B6 ▶
- vardef SymbolBlackSquare = fillup unitsquare scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25A0 ■
- vardef SymbolBlackDiamond = fillup unitdiamond scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25C6 ◆
-
- vardef SymbolNotDef =
- draw center unitcircle
- scaled 3
- shifted (1.5,1.5)
- withpen SymbolPen scaled 4
- enddef ;
-
- vardef SymbolStar = % 0x22C6 % ⋆
- SymbolNotDef
- enddef ;
-
- vardef SymbolCheckmark = % 0x2713 ✓
- SymbolNotDef
- enddef ;
-
- vardef SymbolAsterisk = % 0x2217 ∗
- SymbolNotDef
- enddef ;
-
- % We could set code directly to the meaning of the macro.
-
- lmt_registerglyphs [
- name = "symbols",
- units = 10,
- usecolor = true,
- width = 6,
- height = 6,
- depth = 0,
- code = "SymbolNotDef ;",
- ] ;
-
- lmt_registerglyph [ category = "symbols", unicode = "0x2022", code = "SymbolBullet ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x2013", code = "SymbolDash ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x22C6" ] ; % , code = "SymbolStar ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x22B3", code = "SymbolTriangle ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x2218", code = "SymbolCircle ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x25A1", code = "SymbolSquare ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x22C4", code = "SymbolDiamond ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x2713" ] ; % , code = "SymbolCheckmark ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x2217" ] ; % , code = "SymbolAsterisk ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x25B6", code = "SymbolBlackTriangle ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x25A0", code = "SymbolBlackSquare ;" ] ;
- lmt_registerglyph [ category = "symbols", unicode = "0x25C6", code = "SymbolBlackDiamond ;" ] ;
-
-\stopMPcalculation
-
-\continueifinputfile{meta-imp-symbols.mkxl}
-
-\usemodule[article-basic] \setupbodyfont[pagella]
-
-\starttext
-
-\definefontfeature[metasymbols][metapost=symbols]
-
-\definefont[MyFont] [Serif*default,metasymbols sa 1]
-
-Some metasymbols:
-
-\startitem {\MyFont • □ ◆}\quad Regular rendering. \stopitem
-\startitem {\MyFont\red • □ ◆}\quad Rendering with color. \stopitem
-\startitem {\MyFont\blue\showglyphs • □ ◆}\quad Idem but with boundingboxes shown. \stopitem
-
-And some more:
-
-\startlines
- • – ⋆ ⊳ ∘ □ ⋄ ✓ ∗ ▶ ■ ◆
- {\MyFont • – ⋆ ⊳ ∘ □ ⋄ ✓ ∗ ▶ ■ ◆}
-\stoplines
-
-\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-threesix.mkxl b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-threesix.mkxl
deleted file mode 100644
index 277aa85f717..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-threesix.mkxl
+++ /dev/null
@@ -1,253 +0,0 @@
-% not yet a module
-
-\startluacode
- local gsub, utfbyte = string.gsub, utf.byte
-
- -- The font from DEK's facs9b.ps (I wish I was clever enough to understand all the good
- -- stuff in there):
-
- local font36 = {
- ["0"] = [[00111100 01111110 11000011 11000011 11000011 11000011 01111110 00111100]],
- ["1"] = [[00011100 11111100 11101100 00001100 00001100 00001100 11111111 11111111]],
- ["2"] = [[00111110 01110011 01110011 00000011 00001110 00111000 11110001 11111111]],
- ["3"] = [[01111110 01100110 00000110 00111100 00000110 11100111 11100111 01111110]],
- ["4"] = [[00001110 00011110 00110110 01100110 11111111 11111111 00000110 00001110]],
- ["5"] = [[01111110 01111110 01000000 01111100 01000111 00000011 11000111 11111110]],
- ["6"] = [[01111110 01100110 11000000 11011100 11100110 11000011 01100011 01111110]],
- ["7"] = [[11111111 11111111 10000111 10001110 00011100 00011100 00011100 00011100]],
- ["8"] = [[01111110 01100110 01100110 00111100 11000011 11000011 11000011 01111110]],
- ["9"] = [[01111110 11000110 11000011 01100111 00111011 00000011 01100110 01111110]],
- ["A"] = [[000110000 000111000 001111100 001101100 011001110 011111110 010000110 111100111]],
- ["B"] = [[1111100 1110110 0110110 0111100 0110011 0110011 1110011 1111100]],
- ["C"] = [[01111101 11110011 11100001 11100001 11100000 11100000 11100001 01111110]],
- ["D"] = [[11111100 11100010 01100011 01100011 01100011 01100011 11100010 11111100]],
- ["E"] = [[1111111 1110001 0110101 0111100 0110100 0110001 1110001 1111111]],
- ["F"] = [[11111111 11100001 01100101 01111100 01100100 01100000 11111000 11111000]],
- ["G"] = [[01111010 11100110 11100010 11100000 11100111 11100010 11100010 01111100]],
- ["H"] = [[11100111 11100111 01000010 01111110 01000010 01000010 11100111 11100111]],
- ["I"] = [[1111111 1111111 0011000 0011000 0011000 0011000 1111111 1111111]],
- ["J"] = [[01111111 01111111 00000110 00000110 11110110 01100110 01100110 00111100]],
- ["K"] = [[11101110 11100100 01101000 01110000 01111000 01101100 11100110 11101111]],
- ["L"] = [[111111000 111111000 011000000 011000000 011000000 011000011 111000011 111111111]],
- ["M"] = [[1100000011 1110000111 0111111110 0100110010 0100110010 0100000010 1100000011 1100000011]],
- ["N"] = [[11000011 11100011 01110010 01111010 01011110 01001110 11100110 11100010]],
- ["O"] = [[01111110 11000011 11000011 11000011 11000011 11000011 11000011 01111110]],
- ["P"] = [[11111110 11100011 01100011 01111110 01100000 01100000 11111000 11111000]],
- ["Q"] = [[01111100 11000110 11000110 11000110 11000110 11001110 11000110 01111101]],
- ["R"] = [[11111100 11100110 01100110 01111100 01101000 01100100 11100010 11100111]],
- ["S"] = [[01111110 11100001 11100001 01111000 00011110 10000111 11000011 10111110]],
- ["T"] = [[1111111111 1100110011 1100110011 0000110000 0000110000 0000110000 0001111000 0001111000]],
- ["U"] = [[111101111 111101111 011000010 011000010 011000010 011000010 011000010 001111100]],
- ["V"] = [[11111000111 11111000111 01110000010 00110000100 00111000100 00011001000 00001101000 00001110000]],
- ["W"] = [[111000000111 111000000111 110000000010 011000000100 011001000100 001101101000 001101101000 000110110000]],
- ["X"] = [[1111001110 1111000110 0001101000 0000110000 0000110000 0001011000 0110001111 0111001111]],
- ["Y"] = [[111100011 111100011 011000010 001110100 000111000 000011000 001111110 001111110]],
- ["Z"] = [[11111111 10000111 00001110 00011100 00111000 01110000 11100001 11111111]],
- }
-
- local f_code = string.formatters["ThreeSix(%s);"]
- local replace = { ["0"] = "N;", ["1"] = "Y;", [" "] = "L;" }
-
- local function remap(str)
- -- permit abundant spacing (bonus)
- str = gsub(str,"%s+", " ")
- -- remap what we got to macro calls
- str = gsub(str,".",replace)
- -- return the result
- return str
- end
-
- function MP.registerthreesix(name)
- fonts.dropins.registerglyphs {
- name = name,
- units = 12,
- usecolor = true,
- preamble = "InitializeThreeSix;",
- }
- for u, v in table.sortedhash(font36) do
- local ny = 8
- local nx = (#v - ny + 1) // ny
- local height = ny * 1.1 - 0.1
- local width = nx * 1.1 - 0.1
- fonts.dropins.registerglyph {
- category = name,
- unicode = utfbyte(u),
- width = width,
- height = height,
- code = f_code(remap(v)),
- }
- end
- end
-
- MP.registerthreesix("fontthreesix")
-\stopluacode
-
-% \startMPcalculation{simplefun}
-% def InitializeThreeSix =
-% save Y, N, L, S ; save dx, dy, nx, ny ;
-% save shape, fillcolor, mypen, random, currentpen, spread, hoffset ;
-% string shape, fillcolor, mypen ; boolean random ; pen currentpen ;
-% dx := 11/10 ;
-% dy := - 11/10 ;
-% nx := - dx ;
-% ny := 0 ;
-% shape := getparameterdefault "mpsfont" "shape" "circle" ;
-% random := hasoption "mpsfont" "random" "true" ;
-% fillcolor := getparameterdefault "mpsfont" "color" "" ;
-% mypen := getparameterdefault "mpsfont" "pen" "" ;
-% spread := getparameterdefault "mpsfont" "spread" 0 ;
-% hoffset := 12 * spread / 2 ;
-% currentpen := pencircle
-% if mypen = "fancy" :
-% xscaled 1/20 yscaled 2/20 rotated 45
-% else :
-% scaled 1/20
-% fi ;
-% if shape == "square" :
-% def S =
-% unitsquare if random : randomized 1/10 fi
-% shifted (nx,ny)
-% enddef ;
-% elseif shape = "diamond" :
-% def S =
-% unitdiamond if random : randomized 1/10 fi
-% shifted (nx,ny)
-% enddef ;
-% else :
-% def S =
-% unitcircle if random : randomizedcontrols 1/20 fi
-% shifted (nx,ny)
-% enddef ;
-% fi ;
-% def N =
-% nx := nx + dx ;
-% draw S ;
-% enddef ;
-% if fillcolor = "random" :
-% def Y =
-% nx := nx + dx ;
-% fillup S withcolor white randomized (2/3,2/3,2/3) ;
-% enddef ;
-% elseif fillcolor = "" :
-% def Y =
-% nx := nx + dx ;
-% fillup S ;
-% enddef ;
-% else :
-% def Y =
-% nx := nx + dx ;
-% fillup S withcolor fillcolor ;
-% enddef ;
-% fi ;
-% def L =
-% nx := - dx ;
-% ny := ny + dy ;
-% enddef ;
-% enddef ;
-%
-% vardef ThreeSix (text code) =
-% InitializeThreeSix ;
-% draw image (code) shifted (hoffset,-ny) ;
-% enddef ;
-% \stopMPcalculation
-
-\startMPcalculation{simplefun}
- def InitializeThreeSix =
- save Y, N, L, S ;
- % save dx, dy, nx, ny ;
- save shape, fillcolor, mypen, random, threesixpen, spread, hoffset ;
- string shape, fillcolor, mypen ; boolean random ; pen threesixpen ;
- % dx := 11/10 ;
- % dy := - 11/10 ;
- % nx := - dx ;
- % ny := 0 ;
- shape := getparameterdefault "mpsfont" "shape" "circle" ;
- random := hasoption "mpsfont" "random" "true" ;
- fillcolor := getparameterdefault "mpsfont" "color" "" ;
- mypen := getparameterdefault "mpsfont" "pen" "" ;
- spread := getparameterdefault "mpsfont" "spread" 0 ;
- hoffset := 12 * spread / 2 ;
- threesixpen := pencircle
- if mypen = "fancy" :
- xscaled 1/20 yscaled 2/20 rotated 45
- else :
- scaled 1/20
- fi ;
- if shape == "square" :
- def S =
- unitsquare if random : randomized 1/10 fi
- shifted (nx,ny)
- enddef ;
- elseif shape = "diamond" :
- def S =
- unitdiamond if random : randomized 1/10 fi
- shifted (nx,ny)
- enddef ;
- else :
- def S =
- unitcircle if random : randomizedcontrols 1/20 fi
- shifted (nx,ny)
- enddef ;
- fi ;
- def N =
- nx := nx + dx ;
- draw S ;
- enddef ;
- if fillcolor = "random" :
- def Y =
- nx := nx + dx ;
- fillup S withcolor white randomized (2/3,2/3,2/3) ;
- enddef ;
- elseif fillcolor = "" :
- def Y =
- nx := nx + dx ;
- fillup S ;
- enddef ;
- else :
- def Y =
- nx := nx + dx ;
- fillup S withcolor fillcolor ;
- enddef ;
- fi ;
- def L =
- nx := - dx ;
- ny := ny + dy ;
- enddef ;
- enddef ;
-
- vardef ThreeSix (text code) =
- save dx, dy, nx, ny ;
- dx := 11/10 ;
- dy := - 11/10 ;
- nx := - dx ;
- ny := 0 ;
- pickup threesixpen ;
- draw image (code) shifted (hoffset,-ny) ;
- enddef ;
-\stopMPcalculation
-
-\definefontfeature % black and white, with some spread
- [fontthreesix]
- [default]
- [metapost=fontthreesix]
-
-\definefontfeature % color, with some spread
- [fontthreesix-tweak]
- [default]
- [metapost={category=fontthreesix,spread=.1}]
-
-\definefontfeature % color, with some spread
- [fontthreesix-color]
- [default]
- [metapost={category=fontthreesix,shape=diamond,color=random,pen=fancy,spread=.1}]
-
-\definefontfeature % color, tight
- [fontthreesix-initial]
- [metapost={category=fontthreesix,color=random,shape=circle}] % units?
-
-\definefont[DEKFontA][Serif*fontthreesix]
-\definefont[DEKFontB][Serif*fontthreesix-color]
-\definefont[DEKFontC][Serif*fontthreesix-initial]
-\definefont[DEKFontD][Serif*fontthreesix-tweak]
-
-\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
index e683c3766c9..2c28acf7290 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
@@ -25,7 +25,7 @@
\unprotect
-\definesystemvariable {sh} % ShapedText .. todo: commandhandler
+\ifdefined\??sh \else \definesystemvariable {sh} \fi % ShapedText .. todo: commandhandler
\unexpanded\def\setupshapetexts
{\dodoubleempty\getparameters[\??sh]}
@@ -80,16 +80,17 @@
\unexpanded\def\adaptparshape
{\def\docommand##1%
- {\ifcase\scratchcounter
- \expandafter\appendtoks\space##1 \to\scratchtoks
- \else
- \advance\scratchcounter\minusone
- \fi}%
+ {\doifsomething{##1}%
+ {\ifcase\scratchcounter\relax
+ \expandafter\appendtoks\space##1 \to\scratchtoks
+ \else
+ \advance\scratchcounter\minusone
+ \fi}}%
\scratchcounter\prevgraf
\doglobal\decrement(\totalparlines,\scratchcounter)%
\multiply\scratchcounter\plustwo
\scratchtoks\emptytoks
- \expanded{\processseparatedlist[\the\partoks][\space]}\docommand
+ \expanded{\processseparatedlist[\the\partoks][\space]}\docommand % we can have two spaces
\global\partoks\scratchtoks
\parshape\totalparlines\the\partoks\relax}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkiv
index ac920450e84..9305a04957e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkiv
@@ -136,25 +136,34 @@
\let\stopMPinclusions\relax
+% The next was broken since we added instances so it will go away!
+
\unexpanded\def\MPinclusions
{\dosingleempty\meta_inclusions}
\def\meta_inclusions[#1]%
{\edef\m_meta_option{#1}%
- \dosinglegroupempty\meta_inclusions_indeed}
+ \dodoublegroupempty\meta_inclusions_indeed}
\def\meta_inclusions_indeed#1#2%
{\let\m_meta_saved_instance\currentMPinstance
- \edef\currentMPinstance{#1}%
- \ifx\currentMPinstance\empty
- \let\currentMPinstance\defaultMPinstance
- \fi
\ifx\m_meta_option\!!plustoken \else
\global\t_meta_inclusions\emptytoks
\fi
- \gtoksapp\t_meta_inclusions{#2}%
+ \ifsecondargument
+ \edef\currentMPinstance{#1}%
+ \ifx\currentMPinstance\empty
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \gtoksapp\t_meta_inclusions{#2}%
+ \else
+ \let\currentMPinstance\defaultMPinstance
+ \gtoksapp\t_meta_inclusions{#1}%
+ \fi
\let\currentMPinstance\m_meta_saved_instance}
+% so far
+
\installcommandhandler \??mpinstance {MPinstance} \??mpinstance
\setupMPinstance
@@ -874,11 +883,8 @@
{\meta_prepare_instance_variable{#1}%
\edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}
-\unexpanded\def\getMPdata {\clf_getMPdata}
- \let\rawMPdata \clf_getMPdata
-
-\unexpanded\def\getMPstored{\clf_getMPstored}
- \let\rawMPstored \clf_getMPstored
+\unexpanded\def\getMPdata{\clf_getMPdata}
+ \let\rawMPdata \clf_getMPdata
%D We need this trick because we need to make sure that the tex scanner sees
%D newlines and does not quit. Also, we do need to flush the buffer under a normal
@@ -1110,7 +1116,7 @@
% \newcount\c_overlay_linetransparency
% \appendtoks
-% \c_overlay_colormodel \attribute\colormodelattribute
+% \c_overlay_colormodel \c_attr_colormodel
% \c_overlay_color \colo_helpers_inherited_current_ca\overlaycolor
% \c_overlay_transparency \colo_helpers_inherited_current_ta\overlaycolor
% \c_overlay_linecolor \colo_helpers_inherited_current_ca\overlaylinecolor
@@ -1368,8 +1374,8 @@
\appendtoks
\clf_mpsetoutercolor
\MPcolormethod\space
- \attribute\colormodelattribute\space
- \attribute\colorattribute\space
+ \c_attr_colormodel\space
+ \c_attr_color\space
\dogetattribute{transparency}\relax
\to \everyMPgraphic
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkxl b/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkxl
deleted file mode 100644
index e08aa560a71..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-ini.mkxl
+++ /dev/null
@@ -1,1465 +0,0 @@
-%D \module
-%D [ file=meta-ini,
-%D version=2008.03.25,
-%D title=\METAPOST\ Graphics,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\ currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-% initializations:
-%
-% - pass settings from tex to mp (delayed expansion)
-% - used by context core (and modules)
-% - cummulative definitions
-% - flushed each graphic
-% - can be disabled per instance
-% - managed at the tex end
-%
-% extensions:
-%
-% - add mp functionality (immediate expansion)
-% - cummulative
-% - all instances or subset of instances
-% - can be disabled per instance
-% - managed at the lua/mp end
-% - could be managed at the tex end but no real reason and also messy
-%
-% definitions:
-%
-% - add mp functionality (delayed expansion)
-% - cummulative
-% - per instance
-% - managed at the tex end
-%
-% inclusions:
-%
-% - add mp functionality (delayed expansion)
-% - cummulative only when [+]
-% - per instance
-% - managed at the tex end
-%
-% order of execution:
-%
-% definitions
-% extensions
-% inclusions
-% beginfig
-% initializations
-% graphic
-% endfig
-
-% The instance will be implemented stepwise ... I should redo some code in order to
-% make the macros look better than they do now.
-
-\writestatus{loading}{MetaPost Graphics / Initializations}
-
-\registerctxluafile{meta-ini}{}
-
-\unprotect
-
-\newtoks \everyMPgraphic % mp % public or not ?
-
-\appendtoks
- \restoreendofline % see interferences-001.tex
-\to \everyMPgraphic
-
-\def\MPruntimefile {mprun}
-\def\currentMPformat {metafun}
-\def\defaultMPinstance{metafun}
-
-\installcorenamespace{mpinstance}
-\installcorenamespace{mpinclusions}
-\installcorenamespace{mpdefinitions}
-\installcorenamespace{mpgraphic}
-\installcorenamespace{mpstaticgraphic}
-\installcorenamespace{mpclip}
-
-\newtoks \t_meta_initializations % tex, each
-\def \t_meta_inclusions {\csname\??mpinclusions \currentMPinstance\endcsname} % token register
-\def \t_meta_definitions {\csname\??mpdefinitions\currentMPinstance\endcsname} % token register
-
-%D The next command is, of course, dedicated to Mojca, who needs it for gnuplot.
-%D Anyway, the whole multiple engine mechanism is to keep her gnuplot from
-%D interfering.
-
-\unexpanded\def\startMPdefinitions
- {\dosinglegroupempty\meta_start_definitions}
-
-\def\meta_start_definitions#1#2\stopMPdefinitions
- {\let\m_meta_saved_instance\currentMPinstance
- \edef\currentMPinstance{#1}%
- \ifx\currentMPinstance\empty
- \let\currentMPinstance\defaultMPinstance
- \fi
- \gtoksapp\t_meta_definitions{#2}%
- \let\currentMPinstance\m_meta_saved_instance}
-
-\let\stopMPdefinitions\relax
-
-\unexpanded\def\startMPextensions
- {\dosinglegroupempty\meta_start_extensions}
-
-\def\meta_start_extensions#1#2\stopMPextensions % we could use buffers instead
- {\clf_setmpextensions{#1}{#2}}
-
-\let\stopMPextensions\relax
-
-\unexpanded\def\startMPinitializations#1\stopMPinitializations % for all instances, when enabled
- {\gtoksapp\t_meta_initializations{#1}}
-
-\let\stopMPinitializations\relax
-
-\unexpanded\def\startMPinclusions
- {\dosingleempty\meta_start_inclusions}
-
-\unexpanded\def\meta_start_inclusions[#1]%
- {\edef\m_meta_option{#1}%
- \dosinglegroupempty\meta_start_inclusions_indeed}
-
-\def\meta_start_inclusions_indeed#1#2\stopMPinclusions
- {\let\m_meta_saved_instance\currentMPinstance
- \edef\currentMPinstance{#1}%
- \ifx\currentMPinstance\empty
- \let\currentMPinstance\defaultMPinstance
- \fi
- \ifx\m_meta_option\!!plustoken \else
- \global\t_meta_inclusions\emptytoks
- \fi
- \gtoksapp\t_meta_inclusions{#2}%
- \let\currentMPinstance\m_meta_saved_instance}
-
-\let\stopMPinclusions\relax
-
-\unexpanded\def\MPinclusions
- {\dosingleempty\meta_inclusions}
-
-\def\meta_inclusions[#1]%
- {\edef\m_meta_option{#1}%
- \dosinglegroupempty\meta_inclusions_indeed}
-
-\def\meta_inclusions_indeed#1#2%
- {\let\m_meta_saved_instance\currentMPinstance
- \edef\currentMPinstance{#1}%
- \ifx\currentMPinstance\empty
- \let\currentMPinstance\defaultMPinstance
- \fi
- \ifx\m_meta_option\!!plustoken \else
- \global\t_meta_inclusions\emptytoks
- \fi
- \gtoksapp\t_meta_inclusions{#2}%
- \let\currentMPinstance\m_meta_saved_instance}
-
-\installcommandhandler \??mpinstance {MPinstance} \??mpinstance
-
-\setupMPinstance
- [\s!format=metafun,
- \s!extensions=\v!no,
- \s!initializations=\v!no,
- \c!method=\s!default,
- \c!textstyle=,
- \c!textcolor=]
-
-\appendtoks
- \ifcsname\??mpdefinitions\currentMPinstance\endcsname \else
- \expandafter\newtoks\csname\??mpdefinitions\currentMPinstance\endcsname
- \fi
- \ifcsname\??mpinclusions\currentMPinstance\endcsname \else
- \expandafter\newtoks\csname\??mpinclusions\currentMPinstance\endcsname
- \fi
- \t_meta_definitions\emptytoks % in case we redefine
- \t_meta_inclusions \emptytoks % in case we redefine
-\to \everydefineMPinstance
-
-\unexpanded\def\resetMPinstance[#1]%
- {\writestatus\m!metapost{reset will be implemented when needed}}
-
-\def\meta_analyze_graphicname[#1]%
- %{\normalexpanded{\meta_analyze_graphicname_indeed[#1::::]}}
- {\normalexpanded{\meta_analyze_graphicname_indeed[#1}::::]}
-
-\def\meta_show_properties_indeed
- {\writestatus{metapost}{name: \currentMPgraphicname, instance: \currentMPinstance, format: \currentMPformat}}
-
-\let\meta_show_properties\donothing
-
-\installtextracker
- {metapost.properties}
- {\let\meta_show_properties\meta_show_properties_indeed}
- {\let\meta_show_properties\donothing}
-
-\unexpanded\def\meta_analyze_graphicname_indeed[#1::#2::#3]% instance ::
- {\edef\currentMPgraphicname{#2}%
- \ifx\currentMPgraphicname\empty
- \edef\currentMPgraphicname{#1}%
- \let\currentMPinstance\defaultMPinstance
- \orelse\ifcsname\??mpdefinitions#1\endcsname
- \edef\currentMPinstance{#1}%
- \else
- \let\currentMPinstance\defaultMPinstance
- \fi
- \edef\currentMPformat{\MPinstanceparameter\s!format}%
- \meta_show_properties}
-
-\def\currentMPgraphicname{\s!unknown}
-\def\currentMPinstance {\defaultMPinstance}
-\def\currentMPformat {\currentMPinstance}
-
-\defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
-\defineMPinstance[minifun] [\s!format=minifun,\s!extensions=\v!yes,\s!initializations=\v!yes]
-\defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
-\defineMPinstance[lessfun] [\s!format=metafun]
-\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double]
-\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary]
-\defineMPinstance[decimalfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal]
-
-\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
-
-\defineMPinstance[metapost] [\s!format=mpost]
-\defineMPinstance[nofun] [\s!format=mpost]
-\defineMPinstance[doublepost] [\s!format=mpost,\c!method=\s!double]
-\defineMPinstance[binarypost] [\s!format=mpost,\c!method=\s!binary]
-\defineMPinstance[decimalpost][\s!format=mpost,\c!method=\s!decimal]
-
-\defineMPinstance[simplefun] [\s!format=metafun,\c!method=\s!double] % maybe use minifun
-
-%defineMPinstance[megapost] [\s!format=mpost,\c!method=\s!decimal]
-
-\newconditional\c_meta_include_initializations
-
-\def\meta_begin_graphic_group#1%
- {\begingroup
- \meta_analyze_graphicname[#1]}
-
-\def\meta_end_graphic_group
- {\endgroup}
-
-\def\MPaskedfigure{false}
-
-\def\meta_flush_current_initializations
- {\ifconditional\c_meta_include_initializations
- \the\t_meta_initializations
- \fi}
-
-\def\meta_flush_current_inclusions
- {\the\t_meta_inclusions}
-
-\def\meta_flush_current_definitions
- {\the\t_meta_definitions}
-
-\def\meta_start_current_graphic
- {\begingroup
- \meta_enable_include
- \the\everyMPgraphic
- \edef\p_initializations{\MPinstanceparameter\s!initializations}%
- \ifx\p_initializations\v!yes
- \settrue \c_meta_include_initializations
- \else
- \setfalse\c_meta_include_initializations
- \fi
- \edef\p_setups{\MPinstanceparameter\c!setups}%
- \ifx\p_setups\empty \else
- \setups[\p_setups]%
- \fi
- \useMPinstancestyleparameter\c!textstyle}
-
-\def\meta_set_current_color
- {\useMPinstancecolorparameter\c!textcolor}
-
-\def\meta_stop_current_graphic
- {\global\t_meta_definitions\emptytoks
- \global\t_meta_inclusions\emptytoks
- \endgroup}
-
-\def\meta_process_graphic_start
- {\pushMPboundingbox
- \setbox\b_meta_graphic\hpack\bgroup}
-
-\let\meta_relocate_graphic\relax % experimental hook
-
-\def\meta_process_graphic_stop
- {\egroup
- \meta_place_graphic
- \meta_relocate_graphic
- \popMPboundingbox}
-
-\unexpanded\def\meta_process_graphic_instance#1%
- {\edef\currentMPinstance{#1}%
- \ifx\currentMPinstance\empty
- \let\currentMPinstance\defaultMPinstance
- \fi
- \edef\currentMPformat{\MPinstanceparameter\s!format}%
- \meta_process_graphic}
-
-\unexpanded\def\meta_process_graphic#1% todo: extensions and inclusions outside beginfig
- {\meta_start_current_graphic
- \forgetall
- \edef\p_extensions{\MPinstanceparameter\s!extensions}%
- \meta_process_graphic_start
- \normalexpanded{\noexpand\clf_mpgraphic
- instance {\currentMPinstance}%
- format {\currentMPformat}%
- data {#1;}%
- initializations {\meta_flush_current_initializations}%
- \ifx\p_extensions\v!yes
- extensions {\clf_getmpextensions{\currentMPinstance}}% goes through tex again
- \fi
- inclusions {\meta_flush_current_inclusions}%
- definitions {\meta_flush_current_definitions}%
- figure {\MPaskedfigure}%
- method {\MPinstanceparameter\c!method}%
- namespace {\??graphicvariable\currentmpvariableclass:}%
- \relax}%
- \meta_process_graphic_stop
- \meta_stop_current_graphic}
-
-\let\meta_process_graphic_figure_start\relax
-\let\meta_process_graphic_figure_stop \relax
-
-\unexpanded\def\processMPfigurefile#1% special case: obeys beginfig .. endfig and makes pages
- {\begingroup
- \let\normal_meta_process_graphic_start\meta_process_graphic_start
- \let\normal_meta_process_graphic_stop \meta_process_graphic_stop
- \let\meta_process_graphic_start\relax
- \let\meta_process_graphic_stop \relax
- \def\meta_process_graphic_figure_start{\startTEXpage[\c!offset=\v!overlay,\c!align=]\normal_meta_process_graphic_start}%
- \def\meta_process_graphic_figure_stop {\normal_meta_process_graphic_stop\stopTEXpage}
- \def\MPaskedfigure{all}%
- \meta_process_graphic{input "#1" ;}%
- \endgroup}
-
-%D Calling up previously defined graphics.
-
-% \def\includeMPgraphic#1% gets expanded !
-% {\ifcsname\??mpgraphic#1\endcsname
-% \csname\??mpgraphic#1\endcsname ; % ; is safeguard
-% \fi}
-%
-% \unexpanded\def\meta_enable_include % public
-% {\let\meta_handle_use_graphic \thirdofthreearguments
-% \let\meta_handle_reusable_graphic\thirdofthreearguments}
-%
-% but ... we want this too:
-%
-% \startuseMPgraphic{x}
-% draw textext("\externalfigure[foo.pdf]") ;
-% \stopuseMPgraphic
-%
-% \useMPgraphic{x}
-%
-% so we cannot overload unless we let back to the original meanings each graphic
-% ... a better solution is:
-
-\def\includeMPgraphic#1% gets expanded !
- {\ifcsname\??mpgraphic#1\endcsname
- \doubleexpandafter\fourthoffourarguments\lastnamedcs ; % ; is safeguard
- \fi}
-
-\let\meta_enable_include\relax
-
-%D Drawings (stepwise built):
-
-\newif\ifMPdrawingdone \MPdrawingdonefalse
-
-\unexpanded\def\finalizeMPdrawing
- {\MPdrawingdonetrue}
-
-\let\MPdrawingdata\empty
-
-\unexpanded\def\resetMPdrawing
- {\glet\MPdrawingdata\empty
- \global\MPdrawingdonefalse}
-
-\unexpanded\def\pushMPdrawing
- {\globalpushmacro\MPdrawingdata
- \glet\MPdrawingdata\empty}
-
-\unexpanded\def\popMPdrawing
- {\globalpopmacro\MPdrawingdata}
-
-\unexpanded\def\getMPdrawing
- {\ifMPdrawingdone
- \expandafter\meta_process_graphic\expandafter{\MPdrawingdata}% is this expansion still needed?
- \fi}
-
-\def\startMPdrawing
- {\dosingleempty\meta_start_drawing}
-
-\def\meta_start_drawing[#1]#2\stopMPdrawing % to be redone, this ascii stuff
- {\relax
- \bgroup
- \meta_enable_include
- \doifelse{#1}{-}{\convertargument#2\to\asciia}{\def\asciia{#2}}%
- \xdef\MPdrawingdata{\MPdrawingdata\asciia}%
- \egroup}
-
-\let\stopMPdrawing\relax
-
-\def\MPdrawing#1%
- {\relax
- \bgroup
- \meta_enable_include
- \xdef\MPdrawingdata{\MPdrawingdata#1}%
- \egroup}
-
-\unexpanded\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
- {\setgvalue{\??mpclip#1}{#2}}
-
-\let\stopMPclip\relax
-
-\unexpanded\def\meta_grab_clip_path#1#2#3%
- {\begingroup
- \d_overlay_width #2\relax
- \d_overlay_height#3\relax
- \edef\width {\the\d_overlay_width \space}%
- \edef\height{\the\d_overlay_height\space}%
- \edef\currentMPclip{#1}%
- \ifcsname\??mpclip\currentMPclip\endcsname
- \meta_grab_clip_path_yes
- \else
- \meta_grab_clip_path_nop
- \fi
- \endgroup}
-
-\def\meta_grab_clip_path_yes
- {\meta_start_current_graphic
- \normalexpanded{\noexpand\clf_mpsetclippath
- instance {\currentMPinstance}%
- format {\currentMPformat}%
- data {\csname\??mpclip\currentMPclip\endcsname}%
- initializations {\meta_flush_current_initializations}%
- useextensions {\MPinstanceparameter\s!extensions}%
- inclusions {\meta_flush_current_inclusions}%
- method {\MPinstanceparameter\c!method}%
- width \d_overlay_width
- height \d_overlay_height
- \relax}%
- \meta_stop_current_graphic}
-
-\def\meta_grab_clip_path_nop
- {\clf_mpsetclippath
- width \d_overlay_width
- height \d_overlay_height
- \relax}
-
-%D Since we want labels to follow the document settings, we also set the font
-%D related variables.
-
-\unexpanded\def\MPfontsizehskip#1%
- {\dontleavehmode
- \begingroup
- \definedfont[#1]%
- \hskip\clf_currentdesignsize\scaledpoint\relax
- \endgroup}
-
-\definefontsynonym[MetafunDefault][Regular*default]
-
-\startMPinitializations % scale is not yet ok
- defaultfont:="\truefontname{MetafunDefault}";
- % defaultscale:=\the\bodyfontsize/10pt; % only when hard coded 10pt
- % defaultscale:=1;
-\stopMPinitializations
-
-%D A signal that we're in combined \CONTEXT||\METAFUN mode:
-
-\startMPextensions
- string contextversion;contextversion:="\contextversion"; % expanded
-\stopMPextensions
-
-%D \macros
-%D {setupMPvariables}
-%D
-%D When we build collections of \METAPOST\ graphics, like background and buttons,
-%D the need for passing settings arises. By (mis|)|using the local prefix that
-%D belongs to \type {\framed}, we get a rather natural interface to backgrounds. To
-%D prevent conflicts, we will use the \type {-} in \METAPOST\ specific variables,
-%D like:
-%D
-%D \starttyping
-%D \setupMPvariables[meta:button][size=20pt]
-%D \stoptyping
-
-% \lineheight 2pt 2 \scratchcounter red 0.4 .5\bodyfontsize
-%
-% see cont-loc for test code
-
-%D Currently the inheritance of backgrounds does not work and we might drop it
-%D anyway (too messy)
-
-\newbox\b_meta_variable_box
-
-\let \currentmpvariableclass \empty
-\let \m_meta_current_variable \empty
-\let \m_meta_current_variable_template\empty
-
-\installcorenamespace{graphicvariable}
-
-\def\meta_prepare_variable_default{\MPcolor{black}} % just to be sure we use a color but ...
-
-\unexpanded\def\setupMPvariables
- {\dodoubleempty\meta_setup_variables}
-
-\def\meta_setup_variables[#1][#2]%
- {\ifsecondargument
- \getrawparameters[\??graphicvariable#1:][#2]%
- \else
- \getrawparameters[\??graphicvariable:][#1]%
- \fi}
-
-\unexpanded\def\presetMPvariable
- {\dodoubleargument\meta_preset_variable}
-
-\def\meta_preset_variable[#1][#2=#3]%
- {\ifcsname\??graphicvariable#1:#2\endcsname \else
- \setvalue{\??graphicvariable#1:#2}{#3}%
- \fi}
-
-\def\MPrawvar#1#2% no checking
- {\begincsname\??graphicvariable#1:#2\endcsname}
-
-\def\MPvariable#1% todo: could be a framed chain
- {\begincsname\??graphicvariable\currentmpvariableclass:#1\endcsname}
-
-\unexpanded\def\useMPvariables
- {\dodoubleargument\meta_use_variables}
-
-\def\meta_use_variables[#1][#2]%
- {\edef\currentmpvariableclass{#1}%
- \meta_prepare_variables{#2}}
-
-\unexpanded\def\meta_prepare_variables#1%
- {\processcommalist[#1]\meta_prepare_variable}
-
-\unexpanded\def\meta_prepare_variable#1%
- {\edef\m_meta_current_variable_template
- {\??graphicvariable\currentmpvariableclass:#1}%
- \edef\m_meta_current_variable
- {\begincsname\m_meta_current_variable_template\endcsname}%
- \ifx\m_meta_current_variable\empty
- \expandafter\meta_prepare_variable_nop
- \else
- \expandafter\meta_prepare_variable_yes
- \fi}
-
-\unexpanded\def\meta_prepare_instance_variables
- {\expandafter\processcommalist\expandafter[\m_meta_instance_variables]\meta_prepare_instance_variable}
-
-\unexpanded\def\meta_prepare_instance_variable#1%
- {\edef\m_meta_current_variable_template
- {\??graphicvariable\currentmpvariableclass:#1}%
- \edef\m_meta_current_variable
- {\ifcsname\m_meta_current_variable_template\endcsname
- \lastnamedcs
- \else
- \begincsname\??graphicvariable\currentMPgraphicname:#1\endcsname
- \fi}%
- \ifx\m_meta_current_variable\empty
- \expandafter\meta_prepare_variable_nop
- \else
- \expandafter\meta_prepare_variable_yes
- \fi}
-
-\def\meta_prepare_variable_nop
- {\expandafter \let\csname\m_meta_current_variable_template\endcsname\meta_prepare_variable_default}
-
-\def\meta_prepare_variable_color % we use the attribute so we dont' go through namedcolor (why not)
- {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\MPcolor\m_meta_current_variable}}
-
-\def\meta_prepare_variable_number
- {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\number\m_meta_current_variable}}% also accepts 0.number
-
-\def\meta_prepare_variable_dimension
- {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\the\dimexpr\m_meta_current_variable}}
-
-\def\meta_prepare_variable_yes
- {\ifchkdim\m_meta_current_variable\or
- \meta_prepare_variable_dimension
- \else\ifchknum\m_meta_current_variable\or
- \meta_prepare_variable_number
- \else
- \doifelsecolor\m_meta_current_variable
- \meta_prepare_variable_color
- \meta_prepare_variable_dimension
- \fi\fi}
-
-\let\MPvar \MPvariable
-\let\setMPvariables\setupMPvariables
-
-%D \macros
-%D {startuniqueMPgraphic, uniqueMPgraphic}
-%D
-%D This macros is probably of most use to myself, since I like to use graphics that
-%D adapt themselves. The next \METAPOST\ kind of graphic is both unique and reused
-%D when possible.
-%D
-%D \starttyping
-%D \defineoverlay[example][\uniqueMPgraphic{test}]
-%D
-%D \startuniqueMPgraphic {test}
-%D draw OverlayBox ;
-%D \stopuniqueMPgraphic
-%D
-%D \startuniqueMPgraphic {test}
-%D draw OverlayBox ;
-%D \stopuniqueMPgraphic
-%D \stoptyping
-
-\def\overlaystamp % watch the \MPcolor, since colors can be redefined
- {\the\d_overlay_width :%
- \the\d_overlay_height :%
- \the\d_overlay_depth :%
- \the\d_overlay_offset :%
- \the\d_overlay_linewidth:%
- \MPcolor\overlaycolor :% % todo, expand once \m_overlaycolor
- \MPcolor\overlaylinecolor} % todo, expand once \m_overlaylinecolor
-
-%D A better approach is to let additional variables play a role in determining the
-%D uniqueness. In the next macro, the second, optional, argument is used to
-%D guarantee the uniqueness, as well as prepare variables for passing them to
-%D \METAPOST.
-%D
-%D \starttyping
-%D \startuniqueMPgraphic{meta:hash}{gap,angle,...}
-%D \stoptyping
-%D
-%D The calling macro also accepts a second argument. For convenient use in overlay
-%D definitions, we use \type {{}} instead of \type {[]}.
-%D
-%D \starttyping
-%D \uniqueMPgraphic{meta:hash}{gap=10pt,angle=30}
-%D \stoptyping
-
-\newcount\c_meta_object_counter
-\newbox \b_meta_graphic
-
-% hm, isn't this already done elsewhere?
-
-\unexpanded\def\meta_obey_box_depth
- {\setbox\b_meta_graphic\hpack\bgroup
- \raise\MPlly\box\b_meta_graphic
- \egroup}
-
-\unexpanded\def\meta_ignore_box_depth
- {\normalexpanded
- {\meta_obey_box_depth % hence the \unexpanded
- \wd\b_meta_graphic\the\wd\b_meta_graphic
- \ht\b_meta_graphic\the\ht\b_meta_graphic
- \dp\b_meta_graphic\the\dp\b_meta_graphic}}
-
-\unexpanded\def\meta_obey_box_origin
- {\setbox\b_meta_graphic\hpack\bgroup
- \kern\MPllx\raise\MPlly\box\b_meta_graphic
- \egroup}
-
-\unexpanded\def\obeyMPboxdepth {\let\meta_relocate_box\meta_obey_box_depth}
-\unexpanded\def\ignoreMPboxdepth{\let\meta_relocate_box\meta_ignore_box_depth}
-\unexpanded\def\obeyMPboxorigin {\let\meta_relocate_box\meta_obey_box_origin}
-\unexpanded\def\normalMPboxdepth{\let\meta_relocate_box\relax}
-
-\let\meta_relocate_box\relax
-
-\unexpanded\def\meta_place_graphic % the converter also displaces so in fact we revert
- {\meta_relocate_box
- \box\b_meta_graphic}
-
-\unexpanded\def\meta_reuse_box#1#2#3#4#5% space delimiting would save some tokens
- {\MPllx#2\MPlly#3\MPurx#4\MPury#5%
- \hpack{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent
-
-\unexpanded\def\meta_use_box
- {\setunreferencedobject{MP}}
-
-\def\meta_handle_unique_graphic#1#2#3% when there are too many, we can store data at the lua end, although,
- {\begingroup % when there are that many they're probably not that unique anyway
- \edef\currentmpvariableclass{#1}%
- \extendMPoverlaystamp{#2}% incl prepare
- \ifcsname\??mpgraphic\overlaystamp:#1\endcsname
- \lastnamedcs
- \else
- \meta_enable_include % redundant
- \global\advance\c_meta_object_counter\plusone
- \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox
- \setxvalue{\??mpgraphic\overlaystamp:#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
- \csname\??mpgraphic\overlaystamp:#1\endcsname\empty
- \fi
- \endgroup}
-
-\unexpanded\def\startuniqueMPgraphic
- {\dodoublegroupempty\meta_start_unique_graphic}
-
-\let\stopuniqueMPgraphic\relax
-
-\def\meta_start_unique_graphic#1%
- {\normalexpanded{\meta_start_unique_graphic_indeed{#1}}}
-
-\unexpanded\def\meta_start_unique_graphic_indeed#1#2#3\stopuniqueMPgraphic
- {\setgvalue{\??mpgraphic#1}{\meta_handle_unique_graphic{#1}{#2}{#3}}}
-
-\unexpanded\def\uniqueMPgraphic
- {\dodoublegroupempty\meta_unique_graphic}
-
-\def\meta_unique_graphic#1#2%
- {\meta_begin_graphic_group{#1}%
- \setupMPvariables[#1][#2]%
- \begincsname\??mpgraphic#1\endcsname\empty
- \meta_end_graphic_group}
-
-\def\meta_handle_use_graphic#1#2#3%
- {\begingroup
- \edef\currentmpvariableclass{#1}%
- \edef\m_meta_instance_variables{#2}%
- \ifx\m_meta_instance_variables\empty \else
- \meta_prepare_instance_variables
- \fi
- \meta_enable_include % redundant
- \meta_process_graphic{#3}%
- \endgroup}
-
-\unexpanded\def\startuseMPgraphic
- {\dodoublegroupempty\meta_start_use_graphic}
-
-\let\stopuseMPgraphic\relax
-
-\def\meta_start_use_graphic#1%
- {\normalexpanded{\meta_start_use_graphic_indeed{#1}}}
-
-\unexpanded\def\meta_start_use_graphic_indeed#1#2#3\stopuseMPgraphic
- {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}
-
-\unexpanded\def\startusableMPgraphic % redundant but handy
- {\dodoublegroupempty\meta_start_usable_graphic}
-
-\let\stopusableMPgraphic\relax
-
-\def\meta_start_usable_graphic#1%
- {\normalexpanded{\meta_start_usable_graphic_indeed{#1}}}
-
-\unexpanded\def\meta_start_usable_graphic_indeed#1#2#3\stopusableMPgraphic
- {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}
-
-\def\meta_handle_reusable_graphic#1#2#3%
- {\begingroup
- \edef\currentmpvariableclass{#1}%
- \edef\m_meta_instance_variables{#2}%
- \ifx\m_meta_instance_variables\empty \else
- \meta_prepare_instance_variables
- \fi
- \meta_enable_include % redundant
- \global\advance\c_meta_object_counter\plusone
- \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox
- \setxvalue{\??mpgraphic#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
- \csname\??mpgraphic#1\endcsname\empty
- \endgroup}
-
-\unexpanded\def\startreusableMPgraphic
- {\dodoublegroupempty\meta_start_reusable_graphic}
-
-\let\stopreusableMPgraphic\relax
-
-\def\meta_start_reusable_graphic#1%
- {\normalexpanded{\meta_start_reusable_graphic_indeed{#1}}}
-
-\unexpanded\def\meta_start_reusable_graphic_indeed#1#2#3\stopreusableMPgraphic
- {\setgvalue{\??mpgraphic#1}{\meta_handle_reusable_graphic{#1}{#2}{#3}}}
-
-\unexpanded\def\useMPgraphic
- {\dodoublegroupempty\meta_use_graphic}
-
-\def\meta_use_graphic#1#2%
- {\meta_begin_graphic_group{#1}%
- \ifcsname\??mpgraphic#1\endcsname
- \edef\usedMPgraphicname{#1}%
- \orelse\ifcsname\??mpgraphic\currentMPgraphicname\endcsname
- \let\usedMPgraphicname\currentMPgraphicname
- \else
- \let\usedMPgraphicname\empty
- \fi
- \ifx\usedMPgraphicname\empty
- % message
- \else
- \doifsomething{#2}{\setupMPvariables[\usedMPgraphicname][#2]}%
- \csname\??mpgraphic\usedMPgraphicname\endcsname
- \fi
- \meta_end_graphic_group}
-
-\let\reuseMPgraphic \useMPgraphic % we can save a setup here if needed
-\let\reusableMPgraphic\reuseMPgraphic % we can save a setup here if needed
-
-%D \macros
-%D {startuniqueMPpagegraphic,uniqueMPpagegraphic}
-%D
-%D Experimental.
-
-\def\m_meta_page_prefix{\doifelseoddpage oe}
-
-\def\overlaypagestamp
- {\m_meta_page_prefix :%
- \the\d_overlay_width :%
- \the\d_overlay_height :%
- \the\d_overlay_depth :%
- \the\d_overlay_offset :%
- \the\d_overlay_linewidth:%
- \MPcolor\overlaycolor :%
- \MPcolor\overlaylinecolor}
-
-\unexpanded\def\startuniqueMPpagegraphic
- {\dodoublegroupempty\meta_start_unique_page_graphic}
-
-\let\stopuniqueMPpagegraphic\relax
-
-\def\meta_start_unique_page_graphic#1%
- {\normalexpanded{\meta_start_unique_page_graphic_indeed{#1}}}
-
-\unexpanded\def\meta_start_unique_page_graphic_indeed#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage
- {\setgvalue{\??mpgraphic o:#1}{\meta_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state
- \setgvalue{\??mpgraphic e:#1}{\meta_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined
-
-\unexpanded\def\uniqueMPpagegraphic
- {\dodoublegroupempty\meta_unique_page_graphic}
-
-\def\meta_unique_page_graphic#1#2%
- {\meta_begin_graphic_group{#1}%
- \let\overlaystamp\overlaypagestamp
- \setupMPvariables[\m_meta_page_prefix:#1][#2]% prefix is new here
- \csname\??mpgraphic\m_meta_page_prefix:#1\endcsname\empty
- \meta_end_graphic_group}
-
-%D One way of defining a stamp is:
-%D
-%D \starttyping
-%D \def\extendMPoverlaystamp#1%
-%D {\def\docommand##1%
-%D {\edef\overlaystamp{\overlaystamp:\MPvariable{##1}}}%
-%D \processcommalist[#1]\docommand}
-%D \stoptyping
-%D
-%D Since we need to feed \METAPOST\ with expanded dimensions, we introduce a
-%D dedicated expansion engine. We redefine \type {\extendMPoverlaystamp} to
-
-\unexpanded\def\extendMPoverlaystamp#1%
- {\processcommalist[#1]\meta_extend_overlay_stamp}
-
-\def\meta_extend_overlay_stamp#1%
- {\meta_prepare_instance_variable{#1}%
- \edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}
-
-\unexpanded\def\getMPdata {\clf_getMPdata}
- \let\rawMPdata \clf_getMPdata
-
-\unexpanded\def\getMPstored{\clf_getMPstored}
- \let\rawMPstored \clf_getMPstored
-
-%D We need this trick because we need to make sure that the tex scanner sees
-%D newlines and does not quit. Also, we do need to flush the buffer under a normal
-%D catcode regime in order to expand embedded tex macros. As usual with buffers,
-%D \type {#1} can be a list.
-
-\unexpanded\def\processMPbuffer
- {\dosingleempty\meta_process_buffer}
-
-\def\meta_process_buffer[#1]%
- {\meta_begin_graphic_group{#1}%
- \meta_process_graphic{\clf_feedback{\currentMPgraphicname}}%
- \meta_end_graphic_group}
-
-\unexpanded\def\runMPbuffer
- {\dosingleempty\meta_run_buffer}
-
-\def\meta_run_buffer[#1]% processing only
- {\startnointerference\meta_process_buffer[#1]\stopnointerference}
-
-%D \macros
-%D {startMPenvironment, resetMPenvironment}
-%D
-%D In order to synchronize the main \TEX\ run and the runs local to \METAPOST,
-%D environments can be passed.
-
-\unexpanded\def\startMPenvironment
- {\begingroup
- \catcode\endoflineasciicode \ignorecatcode
- \dosingleempty\meta_start_environment}
-
-\def\meta_start_environment[#1]#2\stopMPenvironment
- {\endgroup
- \edef\m_meta_option{#1}
- \ifx\m_meta_option\s!reset
- \resetMPenvironment % reset mp toks
- \orelse\ifx\m_meta_option\v!global
- #2% % use in main doc too
- \orelse\ifx\m_meta_option\!!plustoken
- #2% % use in main doc too
- \fi
- \clf_mptexset{\detokenize{#2}}}
-
-\let\stopMPenvironment\relax
-
-\unexpanded\def\resetMPenvironment
- {\clf_mptexreset}
-
-\unexpanded\def\useMPenvironmentbuffer[#1]%
- {\clf_mptexsetfrombuffer{#1}}
-
-%D This command takes \type {[reset]} as optional argument.
-%D
-%D \starttyping
-%D \startMPenvironment
-%D \setupbodyfont[pos,14.4pt]
-%D \stopMPenvironment
-%D
-%D \startMPcode
-%D draw btex \sl Hans Hagen etex scaled 5 ;
-%D \stopMPcode
-%D \stoptyping
-%D
-%D The most simple case:
-
-\unexpanded\def\startMPcode
- {\dosinglegroupempty\meta_start_code}
-
-\let\stopMPcode\relax
-
-\def\meta_start_code
- {\iffirstargument
- \expandafter\meta_start_code_instance
- \else
- \expandafter\meta_start_code_standard
- \fi}
-
-\def\meta_start_code_instance#1#2\stopMPcode
- {\begingroup
- \edef\currentMPinstance{#1}%
- \let\currentMPgraphicname\empty
- \edef\currentMPformat{\MPinstanceparameter\s!format}%
- \meta_enable_include
- \meta_process_graphic{#2}%
- \endgroup}
-
-\def\meta_start_code_standard#1#2\stopMPcode
- {\begingroup
- \let\currentMPinstance\defaultMPinstance
- \let\currentMPgraphicname\empty
- \edef\currentMPformat{\MPinstanceparameter\s!format}%
- \meta_process_graphic{#2}%
- \endgroup}
-
-\unexpanded\def\MPcode
- {\dodoublegroupempty\meta_code}
-
-\def\meta_code
- {\ifsecondargument
- \expandafter\meta_code_instance
- \else
- \expandafter\meta_code_standard
- \fi}
-
-\def\meta_code_instance#1#2%
- {\meta_begin_graphic_group{#1}%
- \meta_enable_include
- \meta_process_graphic{#2}%
- \meta_end_graphic_group}
-
-\def\meta_code_standard#1#2%
- {\let\currentMPinstance\defaultMPinstance
- \meta_enable_include
- \meta_process_graphic{#1}}
-
-% a bit nasty (also needed for compatibility:
-
-% \startMPrun input mp-www.mp ; \stopMPrun
-% \externalfigure[mprun.3][width=10cm,height=8cm]
-
-% \startMPrun{mprun} input mp-www.mp ; \stopMPrun % instance
-% \externalfigure[mprun.4][width=10cm,height=8cm]
-
-\let\MPruninstance\defaultMPinstance
-
-\unexpanded\def\useMPrun#1#2% name n
- {\begingroup
- \def\MPaskedfigure{#2}%
- \doifelsenothing{#1}
- {\useMPgraphic{mprun}}%
- {\useMPgraphic{#1}}%
- \endgroup}
-
-\unexpanded\def\startMPrun
- {\dosinglegroupempty\meta_start_run}
-
-\def\meta_start_run#1#2\stopMPrun
- {\iffirstargument
- \startuseMPgraphic{#1}#2\stopuseMPgraphic
- \else
- \startuseMPgraphic{mprun}#2\stopuseMPgraphic
- \fi}
-
-\let\stopMPrun\relax
-
-%D The \type {\resetMPenvironment} is a quick way to erase
-%D the token list.
-%D
-%D You should be aware of independencies. For instance, if you use a font
-%D in a graphic that is not used in the main document, you need to load the
-%D typescript at the outer level (either directly or by using the global
-%D option).
-%D
-%D \starttyping
-%D \usetypescript[palatino][texnansi]
-%D
-%D \startMPenvironment
-%D \usetypescript[palatino][texnansi]
-%D \enableregime[utf]
-%D \setupbodyfont[palatino]
-%D \stopMPenvironment
-%D
-%D \startMPpage
-%D draw btex aap‒noot coördinatie – één etex ;
-%D \stopMPpage
-%D \stoptyping
-
-%D Loading specific \METAPOST\ related definitions is
-%D accomplished by:
-
-\unexpanded\def\useMPlibrary[#1]{\clf_useMPlibrary{#1}}
-
-%D \macros
-%D {setMPtext, MPtext, MPstring, MPbetex}
-%D
-%D To be documented:
-%D
-%D \starttyping
-%D \setMPtext{identifier}{text}
-%D
-%D \MPtext {identifier}
-%D \MPstring{identifier}
-%D \MPbetex {identifier}
-%D \stoptyping
-
-\installcorenamespace{mptext}
-
-\unexpanded\def\setMPtext#1#2% todo : #1 must be made : safe
- {\defconvertedargument\ascii{#2}%
- \dodoglobal\letvalue{\??mptext#1}\ascii}
-
-\def\MPtext #1{\begincsname\??mptext#1\endcsname\empty}
-\def\MPstring#1{"\begincsname\??mptext#1\endcsname\empty"}
-\def\MPbetex #1{btex \begincsname\??mptext#1\endcsname\space etex}
-
-%D In order to communicate conveniently with the \TEX\ engine, we introduce some
-%D typesetting variables.
-
-% \setupcolors[state=stop,conversion=never] % quite tricky ... type mismatch
-
-% \startMPextensions
-% color OverlayColor,OverlayLineColor;
-% \stopMPextensions
-
-\startMPinitializations
- CurrentLayout:="\currentlayout";
-\stopMPinitializations
-
-% \startMPinitializations
-% OverlayWidth:=\overlaywidth;
-% OverlayHeight:=\overlayheight;
-% OverlayDepth:=\overlaydepth;
-% OverlayLineWidth:=\overlaylinewidth;
-% OverlayOffset:=\overlayoffset;
-% \stopMPinitializations
-
-%D A dirty trick, ** in colo-ini.lua (mpcolor). We cannot use a vardef, because
-%D that fails with spot colors.
-
-\startMPinitializations
- def OverlayLineColor=\ifx\overlaylinecolor\empty black \else\MPcolor{\overlaylinecolor} \fi enddef;
- def OverlayColor =\ifx\overlaycolor \empty black \else\MPcolor{\overlaycolor} \fi enddef;
-\stopMPinitializations
-
-% \newcount\c_overlay_colormodel
-% \newcount\c_overlay_color
-% \newcount\c_overlay_transparency
-% \newcount\c_overlay_linecolor
-% \newcount\c_overlay_linetransparency
-
-% \appendtoks
-% \c_overlay_colormodel \attribute\colormodelattribute
-% \c_overlay_color \colo_helpers_inherited_current_ca\overlaycolor
-% \c_overlay_transparency \colo_helpers_inherited_current_ta\overlaycolor
-% \c_overlay_linecolor \colo_helpers_inherited_current_ca\overlaylinecolor
-% \c_overlay_linetransparency\colo_helpers_inherited_current_ta\overlaylinecolor
-% \to \everyMPgraphic
-
-% \startMPinitializations
-% BaseLineSkip:=\the\baselineskip;
-% LineHeight:=\the\baselineskip;
-% BodyFontSize:=\the\bodyfontsize;
-% %
-% TopSkip:=\the\topskip;
-% StrutHeight:=\strutheight;
-% StrutDepth:=\strutdepth;
-% %
-% CurrentWidth:=\the\hsize;
-% CurrentHeight:=\the\vsize;
-% HSize:=\the\hsize ;
-% VSize:=\the\vsize ;
-% %
-% EmWidth:=\the\emwidth;
-% ExHeight:=\the\exheight;
-% \stopMPinitializations
-
-\appendtoks
- \disablediscretionaries
- %\disablecompoundcharacters
-\to \everyMPgraphic
-
-% \appendtoks % before color, inefficient, replace by low level copy
-% \doregistercolor{currentcolor}\currentcolorname
-% \to \everyMPgraphic
-
-% \color[green]{abc \startMPcode
-% fill fullcircle scaled 3cm withoutcolor;
-% fill fullcircle scaled 2cm withcolor \MPcolor{currentcolor} ;
-% fill fullcircle scaled 1cm withcolor \MPcolor{red} ;
-% \stopMPcode def}
-
-\appendtoks
- \baselineskip1\baselineskip
- \lineheight 1\lineheight
- \topskip 1\topskip
-\to \everyMPgraphic
-
-\appendtoks
- \let \# \letterhash
- \let \_ \letterunderscore
- \let \& \letterampersand
- \let \{ \letteropenbrace
- \let \} \letterclosebrace
-\to \everyMPgraphic
-
-%D \macros
-%D {PDFMPformoffset}
-%D
-%D In \PDF, forms are clipped and therefore we have to take precautions to get this
-%D right. Since this is related to objects, we use the same offset as used there.
-
-\def\PDFMPformoffset{\objectoffset}
-
-\newtoks\everyinsertMPfile
-
-\startMPextensions
- def initialize_form_numbers =
- do_initialize_numbers;
- enddef;
-\stopMPextensions
-
-\startMPextensions
- vardef ForegroundBox =
- unitsquare xysized(HSize,VSize)
- enddef ;
-\stopMPextensions
-
-% \startMPextensions
-% PageFraction := 1 ;
-% \stopMPextensions
-
-% \startMPinitializations
-% PageFraction := if \lastpage>1: (\realfolio-1)/(\lastpage-1) else: 1 fi ;
-% \stopMPinitializations
-
-\startMPdefinitions {metapost}
- if unknown context_bare : input mp-bare.mpiv ; fi ;
-\stopMPdefinitions
-\startMPdefinitions {binarypost}
- if unknown context_bare : input mp-bare.mpiv ; fi ;
-\stopMPdefinitions
-\startMPdefinitions {decimalpost}
- if unknown context_bare : input mp-bare.mpiv ; fi ;
-\stopMPdefinitions
-\startMPdefinitions {doublepost}
- if unknown context_bare : input mp-bare.mpiv ; fi ;
-\stopMPdefinitions
-
-% \startMPdefinitions {nofun}
-% if unknown context_bare : input mp-bare.mpiv ; fi ;
-% \stopMPdefinitions
-
-%D And some more. These are not really needed since we don't use the normal figure
-%D inclusion macros any longer.
-
-\appendtoks
- \externalfigurepostprocessors\emptytoks % safeguard
-\to \everyinsertMPfile
-
-%D We also take care of disabling fancy figure features, that can terribly interfere
-%D when dealing with symbols, background graphics and running (postponed) graphics.
-%D You won't believe me if I tell you what funny side effects can occur. One took me
-%D over a day to uncover when processing the screen version of the \METAFUN\ manual.
-
-\def\doifelseMPgraphic#1%
- {\ifcsname\??mpgraphic #1\endcsname\expandafter\firstoftwoarguments \orelse
- \ifcsname\??mpgraphic o:#1\endcsname\expandafter\firstoftwoarguments \orelse
- \ifcsname\??mpgraphic e:#1\endcsname\expandafter\firstoftwoarguments \else
- \expandafter\secondoftwoarguments\fi}
-
-\let\doifMPgraphicelse\doifelseMPgraphic
-
-%D New:
-
-\definelayerpreset % no dx,dy - else nasty non-mp placement
- [mp]
- [\c!y=-\MPury,
- \c!x=\MPllx,
- \c!method=\v!fit]
-
-\definelayer
- [mp]
- [\c!preset=mp]
-
-%D Usage:
-%D
-%D \starttyping
-%D \defineviewerlayer[one][state=start]
-%D \defineviewerlayer[two][state=stop]
-%D
-%D \startuseMPgraphic{step-1}
-%D fill fullcircle scaled 10cm withcolor red ;
-%D \stopuseMPgraphic
-%D
-%D \startuseMPgraphic{step-2}
-%D fill fullcircle scaled 5cm withcolor green ;
-%D \stopuseMPgraphic
-%D
-%D \setlayer[mp]{\viewerlayer[one]{\useMPgraphic{step-1}}}
-%D \setlayer[mp]{\viewerlayer[two]{\useMPgraphic{step-2}}}
-%D
-%D \ruledhbox{\flushlayer[mp]}
-%D \stoptyping
-%D
-%D Reusing graphics is also possible (now):
-%D
-%D \starttyping
-%D \startreusableMPgraphic{axis}
-%D tickstep := 1cm ; ticklength := 2mm ;
-%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
-%D tickstep := tickstep/2 ; ticklength := ticklength/2 ;
-%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
-%D \stopreusableMPgraphic
-%D
-%D \startuseMPgraphic{demo}
-%D drawpoint "1cm,1.5cm" ;
-%D \stopuseMPgraphic
-%D
-%D \definelayer[mp][preset=mp]
-%D \setlayer[mp]{\reuseMPgraphic{axis}}
-%D \setlayer[mp]{\useMPgraphic{demo}}
-%D \ruledhbox{\flushlayer[mp]}
-%D \stoptyping
-
-%D \macros
-%D {startstaticMPfigure,useMPstaticfigure}
-%D
-%D Static figures are processed only when there has been something changed. Here is
-%D Aditya Mahajan's testcase:
-%D
-%D \startbuffer
-%D \startstaticMPfigure{circle}
-%D fill fullcircle scaled 1cm withcolor blue;
-%D \stopstaticMPfigure
-%D
-%D \startstaticMPfigure{axis}
-%D drawarrow (0,0)--(2cm,0) ;
-%D drawarrow (0,0)--(0,2cm) ;
-%D label.llft(textext("(0,0)") ,origin) ;
-%D \stopstaticMPfigure
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure
- {\startreusableMPgraphic{\??mpstaticgraphic#1}#2\stopreusableMPgraphic}
-
-\unexpanded\def\startstaticMPgraphic
- {\dodoublegroupempty\meta_start_static_graphic}
-
-\def\meta_start_static_graphic#1#2#3\stopstaticMPgraphic
- {\startreusableMPgraphic{\??mpstaticgraphic#1}{#2}#3\stopreusableMPgraphic}
-
-\let\stopstaticMPfigure \relax
-\let\stopstaticMPgraphic\relax
-
-\unexpanded\def\usestaticMPfigure
- {\dodoubleempty\meta_use_static_figure}
-
-\def\meta_use_static_figure[#1][#2]%
- {\ifsecondargument
- \scale[#2]{\reuseMPgraphic{\??mpstaticgraphic#1}}%
- \else
- \reuseMPgraphic{\??mpstaticgraphic#1}%
- \fi}
-
-%D Goody for preventing overflows:
-
-\def\MPdivten[#1]{\withoutpt\the\dimexpr#1pt/10\relax}
-
-%D There is no way to distinguish the black color that you get when you issue a
-%D \type {draw} without color specification from a color that has an explicit black
-%D specification unless you set the variable \type {defaultcolormodel} to 1.
-%D Hoewever, in that case you cannot distinguish that draw from one with a \type
-%D {withoutcolor} specification. This means that we have to provide multiple
-%D variants of inheritance.
-%D
-%D In any case we need to tell the converter what the inherited color is to start
-%D with. Case~3 is kind of unpredictable as it closely relates to the order in which
-%D paths are flushed. If you want to inherit automatically from the surrounding, you
-%D can best stick to variant 1. Variant 0 (an isolated graphic) is the default.
-%D
-%D \startbuffer
-%D \startuseMPgraphic{test}
-%D drawoptions(withpen pencircle scaled 1pt) ;
-%D def shift_cp = currentpicture := currentpicture shifted (-15pt,0) ; enddef ;
-%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ;
-%D fill fullcircle scaled 10pt ; shift_cp ;
-%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ;
-%D fill fullcircle scaled 10pt withcolor red ; shift_cp ;
-%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ;
-%D fill fullcircle scaled 10pt ; shift_cp ;
-%D \stopuseMPgraphic
-%D
-%D \starttabulate
-%D \NC 0\quad \NC \MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
-%D \NC 1\quad \NC \MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
-%D \NC 2\quad \NC \MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
-%D \NC 3\quad \NC \MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
-%D \stoptabulate
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\newconstant\MPcolormethod
-
-\appendtoks
- \clf_mpsetoutercolor
- \MPcolormethod\space
- \attribute\colormodelattribute\space
- \attribute\colorattribute\space
- \dogetattribute{transparency}\relax
-\to \everyMPgraphic
-
-% \startMPinitializations
-% defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi;
-% \stopMPinitializations
-
-%D macros
-%D {mprunvar,mpruntab,mprunset}
-%D
-%D \starttyping
-%D \startMPcode
-%D passvariable("version","1.0") ;
-%D passvariable("number",123) ;
-%D passvariable("string","whatever") ;
-%D passvariable("point",(1.5,2.8)) ;
-%D passvariable("triplet",(1/1,1/2,1/3)) ;
-%D passvariable("quad",(1.1,2.2,3.3,4.4)) ;
-%D passvariable("boolean",false) ;
-%D passvariable("path",fullcircle scaled 1cm) ;
-%D draw fullcircle scaled 20pt ;
-%D \stopMPcode
-%D
-%D \ctxlua{inspect(metapost.variables)}
-%D
-%D \MPrunvar{version} \MPruntab{quad}{3} (\MPrunset{triplet}{,})
-%D
-%D $(x,y) = (\MPruntab{point}{1},\MPruntab{point}{2})$
-%D $(x,y) = (\MPrunset{point}{,})$
-%D \stoptyping
-
-\def\MPrunvar #1{\clf_mprunvar{#1}} \let\mprunvar\MPrunvar
-\def\MPruntab#1#2{\clf_mpruntab{#1}#2\relax} \let\mpruntab\MPruntab % #2 is number
-\def\MPrunset#1#2{\clf_mprunset{#1}{#2}} \let\mprunset\MPrunset
-
-\prependtoks \clf_mppushvariables \to \everybeforepagebody
-\appendtoks \clf_mppopvariables \to \everyafterpagebody
-
-\let\MPpushvariables\clf_mppushvariables
-\let\MPpopvariables \clf_mppopvariables
-
-%D We also provide an outputless run:
-
-\unexpanded\def\startMPcalculation
- {\begingroup
- \setbox\nextbox\hpack\bgroup
- \dosinglegroupempty\meta_start_calculation}
-
-\let\stopMPcalculation\relax
-
-\def\meta_start_calculation
- {\iffirstargument
- \expandafter\meta_start_calculation_instance
- \else
- \expandafter\meta_start_calculation_standard
- \fi}
-
-\def\meta_start_calculation_instance#1#2\stopMPcalculation
- {\edef\currentMPinstance{#1}%
- \let\currentMPgraphicname\empty
- \edef\currentMPformat{\MPinstanceparameter\s!format}%
- \meta_enable_include
- \meta_process_graphic{#2;draw origin}%
- \egroup
- \endgroup}
-
-\def\meta_start_calculation_standard#1#2\stopMPcalculation
- {\let\currentMPinstance\defaultMPinstance
- \let\currentMPgraphicname\empty
- \edef\currentMPformat{\MPinstanceparameter\s!format}%
- \meta_process_graphic{#2;draw origin}%
- \egroup
- \endgroup}
-
-%D \macros
-%D {setupMPgraphics}
-%D
-%D Here is a generic setup command:
-
-\installcorenamespace{MPgraphics}
-
-\installsetuponlycommandhandler \??MPgraphics {MPgraphics}
-
-%D Here we hook in the outer color. When \type {color} is set to \type {global} we
-%D get the outer color automatically. If you change this setting, you should do it
-%D grouped in order not to make other graphics behave in unexpected ways.
-
-\appendtoks
- \doifelse{\directMPgraphicsparameter\c!color}\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}%
-\to \everysetupMPgraphics
-
-\setupMPgraphics
- [\c!color=\v!local]
-
-%D This can save some runtime: rename the mpy file from a first run (when stable) to
-%D another file and reuse it. One can also use the original filename, but a copy is
-%D often better.
-%D
-%D \starttyping
-%D \setupMPgraphics
-%D [mpy=\jobname.mpy]
-%D \stoptyping
-
-\appendtoks
- \edef\p_mpy{\directMPgraphicsparameter{mpy}}%
- \ifx\p_mpy\empty \else
- \let\MPdataMPYfile\p_mpy
- \clf_registermpyfile{\p_mpy}%
- \fi
-\to \everysetupMPgraphics
-
-%D Some more helpers (see \type {meta-grd.mkiv} for an example of usage):
-
-\def\MPdpar#1#2{\the\dimexpr#1#2\relax\empty}
-\def\MPnpar#1#2{\the\numexpr#1#2\relax\empty}
-\def\MPspar#1#2{"#1#2"}
-
-%D Done.
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-lua.lua b/Master/texmf-dist/tex/context/base/mkiv/meta-lua.lua
index 42d0366308c..cdcd5c0a857 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-lua.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-lua.lua
@@ -89,7 +89,7 @@ mplib.finders.mpstemplate = function(specification,name,mode,ftype)
data = errorformatter(nameonly)
end
local name = luatex.registertempfile(nameonly,true)
- local data = metapost.checktexts(data)
+-- local data = metapost.checktexts(data)
io.savedata(name,data)
return name
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-mac.mkxl b/Master/texmf-dist/tex/context/base/mkiv/meta-mac.mkxl
deleted file mode 100644
index 3bf38b4c826..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-mac.mkxl
+++ /dev/null
@@ -1,66 +0,0 @@
-%D \module
-%D [ file=meta-scn,
-%D version=2019.07.19,
-%D title=\METAPOST\ Graphics,
-%D subtitle=LMTX support,
-%D author=Hans Hagen,
-%D date=\ currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\unprotect
-
-\unexpanded\def\defineMPparameterset[#1]{\clf_lmt_parameters_define{#1}}
-\unexpanded\def\presetMPparameters [#1]{\clf_lmt_parameters_preset{#1}}
-\unexpanded\def\resetMPparameters [#1]{\clf_lmt_parameters_reset {#1}}
-
-% \unexpanded\def\useMPgraphic
-% {\doifnextoptionalelse\meta_use_MP_graphic_yes\meta_use_MP_graphic_nop}
-
-% \def\meta_use_MP_graphic_nop
-% {\dodoublegroupempty\meta_use_graphic}
-
-% \def\meta_use_MP_graphic_yes
-% {\dodoubleempty\meta_use_graphic_new}
-
-% \def\meta_use_graphic_new[#1][#2]%
-% {\begingroup
-% % If really needed weh can use grouplevel but normally these graphics are
-% % not nested.
-% \clf_lmt_parameters_preset{#1}[#2]%
-% \meta_use_graphic{#1}{}%
-% \clf_lmt_parameters_reset{#1}%
-% \endgroup}
-
-\unexpanded\def\useMPmacro
- {\dotripleempty\meta_use_macro}
-
-\def\meta_use_macro[#1][#2][#3]%
- {\ifthirdargument
- \meta_begin_graphic_group{#1}%
- \meta_enable_include
- \clf_lmt_parameters_preset{#2}[#3]%
- \meta_process_graphic{lmt_#2;}%
- \clf_lmt_parameters_reset{#2}%
- \meta_end_graphic_group
- \else\ifsecondargument
- \doifelseassignment{#2}
- {\let\currentMPinstance\defaultMPinstance
- \meta_enable_include
- \clf_lmt_parameters_preset{#1}[#2]%
- \meta_process_graphic{lmt_#1;}%
- \clf_lmt_parameters_reset{#1}}%
- {\meta_begin_graphic_group{#1}%
- \meta_enable_include
- \meta_process_graphic{lmt_#1;}%
- \meta_end_graphic_group}%
- \else
- \let\currentMPinstance\defaultMPinstance
- \meta_enable_include
- \meta_process_graphic{lmt_#1;}%
- \fi\fi}
-
-\protect
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-pag.mkxl b/Master/texmf-dist/tex/context/base/mkiv/meta-pag.mkxl
deleted file mode 100644
index 86de11eeb5c..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-pag.mkxl
+++ /dev/null
@@ -1,26 +0,0 @@
-%D \module
-%D [ file=meta-pag,
-%D version=1999.07.10,
-%D title=\METAPOST\ Graphics,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D These definitions used to be part of the old \type {core-mps} file, later changed
-%D into \type {meta-ini}, but keeping them separate is cleaner. In the meantime not
-%D that much is left here.
-
-\writestatus{loading}{MetaPost Graphics / Page Data Management}
-
-\unprotect
-
-\prependtoks
- \calculatereducedvsizes % bah, this is really needed
-\to \everyMPgraphic
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-cnt.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-cnt.lua
deleted file mode 100644
index 761eac6551a..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-cnt.lua
+++ /dev/null
@@ -1,2021 +0,0 @@
-if not modules then modules = { } end modules ['mlib-cnt'] = {
- version = 1.001,
- comment = "companion to mlib-ctx.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
--- The only useful reference that I could find about this topic is in wikipedia:
---
--- https://en.wikipedia.org/wiki/Marching_squares
---
--- I derived the edge code from:
---
--- https://physiology.arizona.edu/people/secomb/contours
---
--- and also here:
---
--- https://github.com/secomb/GreensV4
---
--- which has the banner:
---
--- TWS, November 1989. Converted to C September 2007. Revised February 2009.
---
--- and has a liberal licence. I optimized the code so that it runs a bit faster in Lua and
--- there's probably more room for optimization (I tried several variants). For instance I
--- don't use that many tables because access is costly. We don't have a compiler that does
--- some optimizing (even then the c code can probably be made more efficient).
---
--- We often have the same node so it's cheaper to reuse the wsp tables and reconstruct
--- the point in the path then to alias the original point. We can be more clever:
--- straighten, but it's more work so maybe I will do that later; for now I only added
--- a test for equality. There are some experiments in this file too and not all might
--- work. It's a playground for me.
---
--- The code is meant for metafun so it is not general purpose. The bitmap variant is
--- relatively fast and bitmaps compress well. When all is settled I might make a couple
--- of helpers in C for this purpose but not now.
---
--- I removed optimization code (more aggressive flattening and such because it didn't really
--- pay off now that we use combined paths with just line segments. I also moved some other
--- code to a experimental copy. So we now only have the bare helpers needed here.
-
--- Todo: look into zero case (lavel 1) for shapes ... omiting the background calculation
--- speeds up quite a bit.
-
-local next, type, tostring = next, type, tostring
-local round, abs, min, max, floor = math.round, math.abs, math.min, math.max, math.floor
-local concat, move = table.concat, table.move
-
-local bor = bit32.bor -- it's really time to ditch support for luajit
-
-local starttiming = statistics.starttiming
-local stoptiming = statistics.stoptiming
-local elapsedtime = statistics.elapsedtime
-
-local formatters = string.formatters
-local setmetatableindex = table.setmetatableindex
-local sortedkeys = table.sortedkeys
-local sequenced = table.sequenced
-
-local metapost = metapost or { }
-local mp = mp or { }
-
-local getparameterset = metapost.getparameterset
-
-local mpflush = mp.flush
-local mpcolor = mp.color
-local mpstring = mp.string
-local mpdraw = mp.draw
-local mpfill = mp.fill
-local mpflatten = mp.flatten
-
-local report = logs.reporter("mfun contour")
-
-local version = 0.007
-
--- we iterate using integers so that we get a better behaviour at zero
-
-local f_function_n = formatters [ [[
- local math = math
- local round = math.round
- %s
- return function(data,nx,ny,nxmin,nxmax,xstep,nymin,nymax,ystep)
- local sx = nxmin
- for mx=1,nx do
- local dx = data[mx]
- local x = sx * xstep
- local sy = nymin
- for my=1,ny do
- local y = sy * ystep
- dx[my] = %s
- sy = sy + 1
- end
- sx = sx + 1
- end
- return 0
- end
-]] ]
-
-local f_function_y = formatters [ [[
- local math = math
- local round = math.round
- local nan = NaN
- local inf = math.huge
- %s
- return function(data,nx,ny,nxmin,nxmax,xstep,nymin,nymax,ystep,dnan,dinf,report)
- local sx = nxmin
- local er = 0
- for mx=nxmin,nxmax do
- local dx = data[mx]
- local x = sx * xstep
- local sy = nymin
- for my=nymin,nymax do
- local y = sy * ystep
- local n = %s
- if n == nan then
- er = er + 1
- if er < 10 then
- report("nan at (%s,%s)",x,y)
- end
- n = dnan
- elseif n == inf then
- er = er + 1
- if er < 10 then
- report("inf at (%s,%s)",x,y)
- end
- n = dinf
- end
- dx[my] = n
- sy = sy + 1
- end
- sx = sx + 1
- end
- return er
- end
-]] ]
-
-local f_color = formatters [ [[
- local math = math
- local min = math.min
- local max = math.max
- local n = %s
- local minz = %s
- local maxz = %s
-
- local color_value = 0
- local color_step = mp.lmt_color_functions.step
- local color_shade = mp.lmt_color_functions.shade
-
- local function step(...)
- return color_step(color_value,n,...)
- end
- local function shade(...)
- return color_shade(color_value,n,...)
- end
- local function lin(l)
- return l/n
- end
- %s
- return function(l)
- color_value = l
- return %s
- end
-]] ]
-
-local inbetween = attributes and attributes.colors.helpers.inbetween
-
-mp.lmt_color_functions = {
- step = function(l,n,r,g,b,s)
- if not s then
- s = 1
- end
- local f = l / n
- local r = s * 1.5 - 4 * abs(f-r)
- local g = s * 1.5 - 4 * abs(f-g)
- local b = s * 1.5 - 4 * abs(f-b)
- return min(max(r,0),1), min(max(g,0),1), min(max(b,0),1)
- end,
- shade = function(l,n,one,two)
- local f = l / n
- local r = inbetween(one,two,1,f)
- local g = inbetween(one,two,2,f)
- local b = inbetween(one,two,3,f)
- return min(max(r,0),1), min(max(g,0),1), min(max(b,0),1)
- end,
-}
-
-local f_box = formatters [ [[draw rawtexbox("contour",%s) xysized (%s,%s) ;]] ]
-
-local n_box = 0
-
--- todo: remove old one, so we need to store old hashes
-
-local nofcontours = 0
-
--- We don't want cosmetics like axis and labels to trigger a calculation,
--- especially a slow one.
-
-local hashfields = {
- "xmin", "xmax", "xstep", "ymin", "ymax", "ystep",
- "levels", "colors", "level", "preamble", "function", "functions", "color", "values",
- "background", "foreground", "linewidth", "backgroundcolor", "linecolor",
-}
-
-local function prepare(p)
- local h = { }
- for i=1,#hashfields do
- local f = hashfields[i]
- h[f] = p[f]
- end
- local hash = md5.HEX(sequenced(h))
- local name = formatters["%s-m-c-%03i.lua"](tex.jobname,nofcontours)
- return name, hash
-end
-
-local function getcache(p)
- local cache = p.cache
- if cache then
- local name, hash = prepare(p)
- local data = table.load(name)
- if data and data.hash == hash and data.version == version then
- p.result = data
- return true
- else
- return false, hash, name
- end
- end
- return false, nil, nil
-end
-
-local function setcache(p)
- local result = p.result
- local name = result.name
- if name then
- if result.bitmap then
- result.bitmap = nil
- else
- result.data = nil
- end
- result.color = nil
- result.action = nil
- result.cached = nil
- io.savedata(name, table.fastserialize(result))
- else
- os.remove((prepare(p)))
- end
-end
-
-function mp.lmt_contours_start()
-
- starttiming("lmt_contours")
-
- nofcontours = nofcontours + 1
-
- local p = getparameterset()
-
- local xmin = p.xmin
- local xmax = p.xmax
- local ymin = p.ymin
- local ymax = p.ymax
- local xstep = p.xstep
- local ystep = p.ystep
- local levels = p.levels
- local colors = p.colors
- local nx = 0
- local ny = 0
- local means = setmetatableindex("number")
- local values = setmetatableindex("number")
- local data = setmetatableindex("table")
- local minmean = false
- local maxmean = false
-
- local cached, hash, name = getcache(p)
-
- local function setcolors(preamble,levels,minz,maxz,color,nofvalues)
- if colors then
- local function f(k)
- return #colors[1] == 1 and 0 or { 0, 0, 0 }
- end
- setmetatableindex(colors, function(t,k)
- local v = f(k)
- t[k] = v
- return v
- end)
- local c = { }
- local n = 1
- for i=1,nofvalues do
- c[i] = colors[n]
- n = n + 1
- end
- return c, f
- else
- local tcolor = f_color(levels,minz,maxz,preamble,color)
- local colors = { }
- local fcolor = load(tcolor)
- if type(fcolor) ~= "function" then
- report("error in color function, case %i: %s",1,color)
- fcolor = false
- else
- fcolor = fcolor()
- if type(fcolor) ~= "function" then
- report("error in color function, case %i: %s",2,color)
- fcolor = false
- end
- end
- if not fcolor then
- local color_step = mp.lmt_color_functions.step
- fcolor = function(l)
- return color_step(l,levels,0.25,0.50,0.75)
- end
- end
- for i=1,nofvalues do
- colors[i] = { fcolor(i) }
- end
- if attributes.colors.model == "cmyk" then
- for i=1,#colors do
- local c = colors[i]
- colors[i] = { 1 - c[1], 1 - c[2], 1 - c[3], 0 }
- end
- end
- return colors, fcolor
- end
- end
-
- if cached then
- local result = p.result
- local colors, color = setcolors(
- p.preamble,
- p.levels,
- result.minz,
- result.maxz,
- p.color,
- result.nofvalues
- )
- result.color = color
- result.colors = colors
- result.cached = true
- return
- end
-
- local functioncode = p["function"]
- local functionrange = p.range
- local functionlist = functionrange and p.functions
- local preamble = p.preamble
-
- if xstep == 0 then xstep = (xmax - xmin)/100 end
- if ystep == 0 then ystep = (ymax - ymin)/100 end
-
- local nxmin = round(xmin/xstep)
- local nxmax = round(xmax/xstep)
- local nymin = round(ymin/ystep)
- local nymax = round(ymax/ystep)
- local nx = nxmax - nxmin + 1
- local ny = nymax - nymin + 1
-
- local function executed(data,code)
- local fcode = p.check and f_function_y or f_function_n
- fcode = fcode(preamble,code)
- fcode = load(fcode)
- if type(fcode) == "function" then
- fcode = fcode()
- end
- if type(fcode) == "function" then
- local er = fcode(
- data, nx, ny,
- nxmin, nxmax, xstep,
- nymin, nymax, ystep,
- p.defaultnan, p.defaultinf, report
- )
- if er > 0 then
- report("%i errors in: %s",er,code)
- end
- return true
- else
- return false -- fatal error
- end
- end
-
- -- for i=1,nx do
- -- data[i] = lua.newtable(ny,0)
- -- end
-
- if functionlist then
-
- local datalist = { }
- local minr = functionrange[1]
- local maxr = functionrange[2] or minr
- local size = #functionlist
-
- for l=1,size do
-
- local func = setmetatableindex("table")
- if not executed(func,functionlist[l]) then
- report("error in executing function %i from functionlist",l)
- return
- end
-
- local bit = l -- + 1
-
- if l == 1 then
- for i=1,nx do
- local di = data[i]
- local fi = func[i]
- for j=1,ny do
- local f = fi[j]
- if f >= minr and f <= maxr then
- di[j] = bit
- else
- di[j] = 0
- end
- end
- end
- else
- for i=1,nx do
- local di = data[i]
- local fi = func[i]
- for j=1,ny do
- local f = fi[j]
- if f >= minr and f <= maxr then
- di[j] = bor(di[j],bit)
- end
- end
- end
- end
-
- end
-
- -- we can simplify the value mess below
-
- elseif functioncode then
-
- if not executed(data,functioncode) then
- report("error in executing function")
- return -- fatal error
- end
-
- else
-
- report("no valid function(s)")
- return -- fatal error
-
- end
-
- minz = data[1][1]
- maxz = minz
-
- for i=1,nx do
- local d = data[i]
- for j=1,ny do
- local v = d[j]
- if v < minz then
- minz = v
- elseif v > maxz then
- maxz = v
- end
- end
- end
-
- if functionlist then
-
- for i=minz,maxz do
- values[i] = i
- end
-
- levels = maxz
-
- minmean = minz
- maxmean = maxz
-
- else
-
- local snap = (maxz - minz + 1) / levels
-
- for i=1,nx do
- local d = data[i]
- for j=1,ny do
- local dj = d[j]
- local v = round((dj - minz) / snap)
- values[v] = values[v] + 1
- means [v] = means [v] + dj
- d[j] = v
- end
- end
-
- local list = sortedkeys(values)
- local count = values
- local remap = { }
-
- values = { }
-
- for i=1,#list do
- local v = list[i]
- local m = means[v] / count[v]
- remap [v] = i
- values[i] = m
- if not minmean then
- minmean = m
- maxmean = m
- elseif m < minmean then
- minmean = m
- elseif m > maxmean then
- maxmean = m
- end
- end
-
- for i=1,nx do
- local d = data[i]
- for j=1,ny do
- d[j] = remap[d[j]]
- end
- end
-
- end
-
- -- due to rounding we have values + 1 so we can have a floor, ceil, round
- -- option as well as levels -1
-
- local nofvalues = #values
-
- local colors = setcolors(
- p.preamble,levels,minz,maxz,p.color,nofvalues
- )
-
- p.result = {
- version = version,
- values = values,
- nofvalues = nofvalues,
- minz = minz,
- maxz = maxz,
- minmean = minmean,
- maxmean = maxmean,
- data = data,
- color = color,
- nx = nx,
- ny = ny,
- colors = colors,
- name = name,
- hash = hash,
- islist = functionlist and true or false,
- }
-
- report("index %i, nx %i, ny %i, levels %i", nofcontours, nx, ny, nofvalues)
-end
-
-function mp.lmt_contours_stop()
- local p = getparameterset()
- local e = stoptiming("lmt_contours")
- setcache(p)
- p.result = nil
- local f = p["function"]
- local l = p.functions
- report("index %i, %0.3f seconds for: %s",
- nofcontours, e, "[ " .. concat(l or { f } ," ] [ ") .. " ]"
- )
-end
-
-function mp.lmt_contours_bitmap_set()
- local p = getparameterset()
- local result = p.result
-
- local values = result.values
- local nofvalues = result.nofvalues
- local rawdata = result.data
- local nx = result.nx
- local ny = result.ny
- local colors = result.colors
- local depth = #colors[1] -- == 3 and "rgb" or "gray"
-
- -- i need to figure out this offset of + 1
-
- local bitmap = graphics.bitmaps.new(
- nx, ny,
- (depth == 3 and "rgb") or (depth == 4 and "cmyk") or "gray",
- 1, false, true
- )
-
- local palette = bitmap.index or { } -- has to start at 0
- local data = bitmap.data
- local p = 0
-
- if depth == 3 or depth == 4 then
- for i=1,nofvalues do
- local c = colors[i]
- local r = round((c[1] or 0) * 255)
- local g = round((c[2] or 0) * 255)
- local b = round((c[3] or 0) * 255)
- local k = depth == 4 and round((c[4] or 0) * 255) or nil
- palette[p] = {
- (r > 255 and 255) or (r < 0 and 0) or r,
- (g > 255 and 255) or (g < 0 and 0) or g,
- (b > 255 and 255) or (b < 0 and 0) or b,
- k
- }
- p = p + 1
- end
- else
- for i=1,nofvalues do
- local s = colors[i][1]
- local s = round((s or 0) * 255)
- palette[p] = (
- (s > 255 and 255) or (s < 0 and 0) or s
- )
- p = p + 1
- end
- end
-
- -- As (1,1) is the left top corner so we need to flip of we start in
- -- the left bottom (we cannot loop reverse because we want a properly
- -- indexed table.
-
- local k = 0
- for y=ny,1,-1 do
- k = k + 1
- local d = data[k]
- for x=1,nx do
- d[x] = rawdata[x][y] - 1
- end
- end
-
- result.bitmap = bitmap
-end
-
-function mp.lmt_contours_bitmap_get()
- local p = getparameterset()
- local result = p.result
- local bitmap = result.bitmap
- local box = nodes.hpack(graphics.bitmaps.flush(bitmap))
- n_box = n_box + 1
- nodes.boxes.savenode("contour",tostring(n_box),box)
- return f_box(n_box,bitmap.xsize,bitmap.ysize)
-end
-
-function mp.lmt_contours_cleanup()
- nodes.boxes.reset("contour")
- n_box = 0
-end
-
-function mp.lmt_contours_edge_set()
- local p = getparameterset()
- local result = p.result
-
- if result.cached then return end
-
- local values = result.values
- local nofvalues = result.nofvalues
- local data = result.data
- local nx = result.nx
- local ny = result.ny
-
- local xmin = p.xmin
- local xmax = p.xmax
- local ymin = p.ymin
- local ymax = p.ymax
- local xstep = p.xstep
- local ystep = p.ystep
-
- local wsp = { }
- local edges = { }
-
- for value=1,nofvalues do
-
- local iwsp = 0
- local di = data[1]
- local dc
- local edge = { }
- local e = 0
- -- the next loop is fast
- for i=1,nx do
- local di1 = data[i+1]
- local dij = di[1]
- local d = dij - value
- local dij1
- for j=1,ny do
- if j < ny then
- dij1 = di[j+1]
- dc = dij1 - value
- if (d >= 0 and dc < 0) or (d < 0 and dc >= 0) then
- iwsp = iwsp + 1
- local y = (d * (j+1) - dc * j) / (d - dc)
- if i == 1 then
- wsp[iwsp] = { i, y, 0, (i + (j-1)*nx) }
- elseif i == nx then
- wsp[iwsp] = { i, y, (i - 1 + (j-1)*nx), 0 }
- else
- local jx = (i + (j-1)*nx)
- wsp[iwsp] = { i, y, jx - 1, jx }
- end
- end
- end
- if i < nx then
- local dc = di1[j] - value
- if (d >= 0 and dc < 0) or (d < 0 and dc >= 0) then
- iwsp = iwsp + 1
- local x = (d * (i+1) - dc * i) / (d - dc)
- if j == 1 then
- wsp[iwsp] = { x, j, 0, (i + (j-1)*nx) }
- elseif j == ny then
- wsp[iwsp] = { x, j, (i + (j-2)*nx), 0 }
- else
- local jx = i + (j-1)*nx
- wsp[iwsp] = { x, j, jx - nx, jx }
- end
- end
- end
- dij = dij1
- d = dc
- end
- di = di1
- end
- -- the next loop takes time
- for i=1,iwsp do
- local wspi = wsp[i]
- for isq=3,4 do
- local nsq = wspi[isq]
- if nsq ~= 0 then
- local px = wspi[1]
- local py = wspi[2]
- local p = { px, py }
- local pn = 2
- wspi[isq] = 0
- while true do
- for ii=1,iwsp do
- local w = wsp[ii]
- local n1 = w[3]
- local n2 = w[4]
- if n1 == nsq then
- local x = w[1]
- local y = w[2]
- if x ~= px or y ~= py then
- pn = pn + 1
- p[pn] = x
- pn = pn + 1
- p[pn] = y
- px = x
- py = y
- end
- nsq = n2
- w[3] = 0
- w[4] = 0
- if nsq == 0 then
- if pn == 1 then
- pn = pn + 1
- p[pn] = w
- end
- goto flush
- end
- elseif n2 == nsq then
- local x = w[1]
- local y = w[2]
- if x ~= px or y ~= py then
- pn = pn + 1
- p[pn] = x
- pn = pn + 1
- p[pn] = y
- px = x
- py = y
- end
- nsq = n1
- w[3] = 0
- w[4] = 0
- if nsq == 0 then
- goto flush
- end
- end
- end
- end
- ::flush::
- e = e + 1
- edge[e] = p
- if mpflatten then
- mpflatten(p)
- end
- end
- end
- end
-
-
- edges[value] = edge
-
- end
-
- result.edges = edges
-
-end
-
-function mp.lmt_contours_shade_set(edgetoo)
- local p = getparameterset()
- local result = p.result
-
- if result.cached then return end
-
- local values = result.values
- local nofvalues = result.nofvalues
- local data = result.data
- local nx = result.nx
- local ny = result.ny
- local color = result.color
-
- local edges = setmetatableindex("table")
- local shades = setmetatableindex("table")
-
- local sqtype = setmetatableindex("table")
-
- local xspoly = { 0, 0, 0, 0, 0, 0 }
- local yspoly = { 0, 0, 0, 0, 0, 0 }
- local xrpoly = { }
- local yrpoly = { }
-
- local xrpoly = { } -- lua.newtable(2000,0)
- local yrpoly = { } -- lua.newtable(2000,0)
-
- -- for i=1,2000 do
- -- xrpoly[i] = 0
- -- yrpoly[i] = 0
- -- end
-
- -- Unlike a c compiler lua will not optimize loops to run in parallel so we expand
- -- some of the loops and make sure we don't calculate when not needed. Not that nice
- -- but not that bad either. Maybe I should just write this from scratch.
-
--- local i = 0
--- local j = 0
-
- -- Analyze each rectangle separately. Overwrite lower colors
-
- -- Unrolling the loops and copying code and using constants is faster and doesn't
- -- produce much more code in the end, also because we then can leave out the not
- -- seen branches. One can argue about the foundit2* blobs but by stepwise optimizing
- -- this is the result.
-
- shades[1] = { { 0, 0, nx - 1, 0, nx - 1, ny - 1, 0, ny - 1 } }
- edges [1] = { { } }
-
- -- this is way too slow ... i must have messed up some loop .. what is this with value 1
-
- for value=1,nofvalues do
--- for value=2,nofvalues do
-
- local edge = { }
- local nofe = 0
- local shade = { }
- local nofs = 0
-
- for i=1,nx-1 do
- local s = sqtype[i]
- for j=1,ny-1 do
- s[j] = 0
- end
- end
-
- local nrp = 0
-
- local function addedge(a,b,c,d)
- nofe = nofe + 1 edge[nofe] = a
- nofe = nofe + 1 edge[nofe] = b
- nofe = nofe + 1 edge[nofe] = c
- nofe = nofe + 1 edge[nofe] = d
- end
- while true do
- -- search for a square of type 0 with >= 1 corner above contour level
- local i
- local j
- local d0 = data[1]
- local d1 = data[2]
- for ii=1,nx do
- local s = sqtype[ii]
- for jj=1,ny do
- if s[jj] == 0 then
- if d0[jj] > value then i = ii j = jj goto foundit end
- if d1[jj] > value then i = ii j = jj goto foundit end
- local j1 = jj + 1
- if d1[j1] > value then i = ii j = jj goto foundit end
- if d0[j1] > value then i = ii j = jj goto foundit end
- end
- end
- d0 = d1
- d1 = data[ii+1]
- end
- break
- ::foundit::
- -- initialize r-polygon (nrp seems to be 1 or 2)
- nrp = nrp + 1
-
- local first = true
- local nrpoly = 0
- local nspoly = 0
- local nrpm = -nrp
- -- this is the main loop
- while true do
- -- search for a square of type -nrp
- if first then
- first = false
- if sqtype[i][j] == 0 then -- true anyway
- goto foundit1
- end
- end
- for ii=1,nx do
- local s = sqtype[ii]
- for jj=1,ny do
- if s[jj] == nrpm then
- i = ii
- j = jj
- goto foundit1
- end
- end
- end
- break
- ::foundit1::
- while true do
-
- -- search current then neighboring squares for square type 0, with a corner in common with current square above contour level
-
- -- top/bottom ... a bit cheating here
-
- local i_l, i_c, i_r -- i left current right
- local j_b, j_c, j_t -- j bottom current top
-
- local i_n = i + 1 -- i next (right)
- local j_n = j + 1 -- j next (top)
-
- local i_p = i - 1 -- i previous (bottom)
- local j_p = j - 1 -- j previous (right)
-
- local d_c = data[i]
- local d_r = data[i_n]
-
- local sq
-
- i_c = i ; j_c = j ; if i_c < nx and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
- if d_c[j_c] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit21 end
- if d_c[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit22 end
- if d_r[j_c] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit23 end
- if d_r[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit24 end
- end end
-
- i_c = i_n ; j_c = j ; if i_c < nx and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
- if d_r[j_c] > value then i_l = i ; i_r = i_n + 1 ; j_b = j_p ; j_t = j_n ; d_c = d_r ; d_r = data[i_r] ; goto foundit21 end
- if d_r[j_n] > value then i_l = i ; i_r = i_n + 1 ; j_b = j_p ; j_t = j_n ; d_c = d_r ; d_r = data[i_r] ; goto foundit22 end
- end end
-
- i_c = i ; j_c = j_n ; if i_c < nx and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
- if d_c[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j ; j_t = j_n + 1 ; goto foundit21 end
- if d_r[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j ; j_t = j_n + 1 ; goto foundit23 end
- end end
-
- i_c = i_p ; j_c = j ; if i_c > 0 and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
- if d_c[j_c] > value then i_l = i_p - 1 ; i_r = i ; j_b = j_p ; j_t = j_n ; d_r = d_c ; d_c = data[i_p] ; goto foundit23 end
- if d_c[j_n] > value then i_l = i_p - 1 ; i_r = i ; j_b = j_p ; j_t = j_n ; d_r = d_c ; d_c = data[i_p] ; goto foundit24 end
- end end
-
- i_c = i ; j_c = j_p ; if i < nx and j_c > 0 then sq = sqtype[i_c] if sq[j_c] == 0 then
- if d_c[j] > value then i_l = i_p ; i_r = i_n ; j_b = j_p - 1 ; j_t = j ; goto foundit22 end
- if d_r[j] > value then i_l = i_p ; i_r = i_n ; j_b = j_p - 1 ; j_t = j ; goto foundit24 end
- end end
-
- -- not found
-
- sqtype[i][j] = nrp
-
- break
-
- -- define s-polygon for found square (i_c,j_c) - may have up to 6 sides
-
- ::foundit21:: -- 1 2 3 4
-
- sq[j_c] = nrpm
-
- xspoly[1] = i_l ; yspoly[1] = j_b
- xspoly[2] = i_c ; yspoly[2] = j_b
- if d_r[j_c] > value then -- dd2
- xspoly[3] = i_c ; yspoly[3] = j_c
- if d_r[j_t] > value then -- dd3
- xspoly[4] = i_l ; yspoly[4] = j_c
- if d_c[j_t] > value then -- dd4
- nspoly = 4
- else
- xspoly[5] = i_l ; yspoly[5] = j_c ; nspoly = 5
- end
- elseif d_c[j_t] > value then -- dd4
- xspoly[4] = i_c ; yspoly[4] = j_c ;
- xspoly[5] = i_l ; yspoly[5] = j_c ; nspoly = 5
- else
- xspoly[4] = i_l ; yspoly[4] = j_c ; nspoly = 4
- if edgetoo then addedge(i_c, j_c, i_l, j_c) end
- end
- elseif d_r[j_t] > value then -- dd3
- xspoly[3] = i_c ; yspoly[3] = j_b
- xspoly[4] = i_c ; yspoly[4] = j_c
- if d_c[j_t] > value then -- dd4
- xspoly[5] = i_l ; yspoly[5] = j_c ; nspoly = 5
- else
- xspoly[5] = i_l ; yspoly[5] = j_c ;
- xspoly[6] = i_l ; yspoly[6] = j_c ; nspoly = 6
- end
- elseif d_c[j_t] > value then -- dd4
- if edgetoo then addedge(i_c, j_b, i_c, j_c) end
- xspoly[3] = i_c ; yspoly[3] = j_c ;
- xspoly[4] = i_l ; yspoly[4] = j_c ; nspoly = 4
- else
- if edgetoo then addedge(i_c, j_b, i_l, j_c) end
- xspoly[3] = i_l ; yspoly[3] = j_c ; nspoly = 3
- end
- goto done
-
- ::foundit22:: -- 4 1 2 3
-
- sq[j_c] = nrpm
-
- xspoly[1] = i_l ; yspoly[1] = j_c
- xspoly[2] = i_l ; yspoly[2] = j_b
- if d_c[j_c] > value then -- dd2
- xspoly[3] = i_c ; yspoly[3] = j_b
- if d_r[j_c] > value then -- dd3
- xspoly[4] = i_c ; yspoly[4] = j_c
- if d_r[j_t] > value then -- dd4
- nspoly = 4
- else
- xspoly[5] = i_c ; yspoly[5] = j_c ; nspoly = 5 -- suspicious, the same
- end
- elseif d_r[j_t] > value then -- dd4
- xspoly[4] = i_c ; yspoly[4] = j_b ;
- xspoly[5] = i_c ; yspoly[5] = j_c ; nspoly = 5
- else
- if edgetoo then addedge(i_c, j_b, i_c, j_c) end
- xspoly[4] = i_c ; yspoly[4] = j_c ; nspoly = 4
- end
- elseif d_r[j_c] > value then -- dd3
- xspoly[3] = i_l ; yspoly[3] = j_b
- xspoly[4] = i_c ; yspoly[4] = j_b
- xspoly[5] = i_c ; yspoly[5] = j_c
- if d_r[j_t] > value then -- dd4
- nspoly = 5
- else
- xspoly[6] = i_c ; yspoly[6] = j_c ; nspoly = 6
- end
- elseif d_r[j_t] > value then -- dd4
- if edgetoo then addedge(i_l, j_b, i_c, j_b) end
- xspoly[3] = i_c ; yspoly[3] = j_b
- xspoly[4] = i_c ; yspoly[4] = j_c ; nspoly = 4
- else
- if edgetoo then addedge(i_l, j_b, i_c, j_c) end
- xspoly[3] = i_c ; yspoly[3] = j_c ; nspoly = 3
- end
- goto done
-
- ::foundit23:: -- 2 3 4 1
-
- sq[j_c] = nrpm
-
- xspoly[1] = i_c ; yspoly[1] = j_b
- xspoly[2] = i_c ; yspoly[2] = j_c
- if d_r[j_t] > value then -- dd2
- xspoly[3] = i_l ; yspoly[3] = j_c
- if d_c[j_t] > value then -- dd3
- xspoly[4] = i_l ; yspoly[4] = j_b
- if d_c[j_c] > value then -- dd4
- nspoly = 4
- else
- xspoly[5] = i_l ; yspoly[5] = j_b ; nspoly = 5
- end
- elseif d_c[j_c] > value then -- dd4
- xspoly[4] = i_l ; yspoly[4] = j_c
- xspoly[5] = i_l ; yspoly[5] = j_b ; nspoly = 5
- else
- if edgetoo then addedge(i_l, j_c, i_l, j_b) end
- xspoly[4] = i_l ; yspoly[4] = j_b ; nspoly = 4
- end
- elseif d_c[j_t] > value then -- dd3
- xspoly[3] = i_c ; yspoly[3] = j_c
- xspoly[4] = i_l ; yspoly[4] = j_c
- xspoly[5] = i_l ; yspoly[5] = j_b
- if d_c[j_c] > value then -- dd4
- nspoly = 5
- else
- xspoly[6] = i_l ; yspoly[6] = j_b ; nspoly = 6
- end
- elseif d_c[j_c] > value then -- dd4
- if edgetoo then addedge(i_c, j_c, i_l, j_c) end
- xspoly[3] = i_l ; yspoly[3] = j_c ;
- xspoly[4] = i_l ; yspoly[4] = j_b ; nspoly = 4
- else
- if edgetoo then addedge(i_c, j_c, i_l, j_b) end
- xspoly[3] = i_l ; yspoly[3] = j_b ; nspoly = 3
- end
- goto done
-
- ::foundit24:: -- 3 4 1 2
-
- sq[j_c] = nrpm
-
- xspoly[1] = i_c ; yspoly[1] = j_c
- xspoly[2] = i_l ; yspoly[2] = j_c
- if d_c[j_t] > value then -- dd2
- if d_c[j_c] > value then -- dd3
- xspoly[3] = i_l ; yspoly[3] = j_b
- xspoly[4] = i_c ; yspoly[4] = j_b
- if d_r[j_c] > value then -- dd4
- nspoly = 4
- else
- xspoly[5] = i_c ; yspoly[5] = j_b ; nspoly = 5
- end
- else
- xspoly[3] = i_l ; yspoly[3] = j_b
- if d_r[j_c] > value then -- dd4
-
- local xv34 = (dd3*i_c-dd4*i_l)/(dd3 - dd4) -- probably i_l
- print("4.4 : xv34",xv34,i_c,i_l)
-
- -- if edgetoo then addedge(i_l, j_b, xv34, j_b) end
- xspoly[4] = xv34 ; yspoly[4] = j_b ;
- xspoly[5] = i_c ; yspoly[5] = j_b ; nspoly = 5
- else
- if edgetoo then addedge(i_l, j_b, i_c, j_b) end
- xspoly[4] = i_c ; yspoly[4] = j_b ; nspoly = 4
- end
- end
- elseif d_c[j_c] > value then -- dd3
- xspoly[3] = i_l ; yspoly[3] = j_b
- xspoly[4] = i_l ; yspoly[4] = j_b
- xspoly[5] = i_c ; yspoly[5] = j_b
- if d_r[j_c] > value then -- dd4
- nspoly = 5
- else
- xspoly[6] = i_c ; yspoly[6] = j_b ; nspoly = 6
- end
- elseif d_r[j_c] > value then -- dd4
- if edgetoo then addedge(i_l, j_c, i_l, j_b) end
- xspoly[3] = i_l ; yspoly[3] = j_b
- xspoly[4] = i_c ; yspoly[4] = j_b ; nspoly = 4
- else
- if edgetoo then addedge(i_l, j_c, i_c, j_b) end
- xspoly[3] = i_c ; yspoly[3] = j_b ; nspoly = 3
- end
- -- goto done
-
- ::done::
- -- combine s-polygon with existing r-polygon, eliminating redundant segments
-
- if nrpoly == 0 then
- -- initiate r-polygon
- for i=1,nspoly do
- xrpoly[i] = xspoly[i]
- yrpoly[i] = yspoly[i]
- end
- nrpoly = nspoly
- else
- -- search r-polygon and s-polygon for one side that matches
- --
- -- this is a bottleneck ... we keep this variant here but next go for a faster
- -- alternative
- --
- -- local ispoly, irpoly
- -- for r=nrpoly,1,-1 do
- -- local r1
- -- for s=1,nspoly do
- -- local s1 = s % nspoly + 1
- -- if xrpoly[r] == xspoly[s1] and yrpoly[r] == yspoly[s1] then
- -- if not r1 then
- -- r1 = r % nrpoly + 1
- -- end
- -- if xrpoly[r1] == xspoly[s] and yrpoly[r1] == yspoly[s] then
- -- ispoly = s
- -- irpoly = r
- -- goto foundit3
- -- end
- -- end
- -- end
- -- end
- --
- -- local ispoly, irpoly
- -- local xr1 = xrpoly[1]
- -- local yr1 = yrpoly[1]
- -- for r0=nrpoly,1,-1 do
- -- for s0=1,nspoly do
- -- if xr1 == xspoly[s0] and yr1 == yspoly[s0] then
- -- if s0 == nspoly then
- -- if xr0 == xspoly[1] and yr0 == yspoly[1] then
- -- ispoly = s0
- -- irpoly = r0
- -- goto foundit3
- -- end
- -- else
- -- local s1 = s0 + 1
- -- if xr0 == xspoly[s1] and yr0 == yspoly[s1] then
- -- ispoly = s0
- -- irpoly = r0
- -- goto foundit3
- -- end
- -- end
- -- end
- -- end
- -- xr1 = xrpoly[r0]
- -- yr1 = yrpoly[r0]
- -- end
- --
- -- but ...
- --
- local minx = xspoly[1]
- local miny = yspoly[1]
- local maxx = xspoly[1]
- local maxy = yspoly[1]
- for i=1,nspoly do
- local y = yspoly[i]
- if y < miny then
- miny = y
- elseif y > maxy then
- maxy = y
- end
- local x = xspoly[i]
- if x < minx then
- minx = y
- elseif x > maxx then
- maxx = x
- end
- end
- -- we can delay accessing y ...
- local ispoly, irpoly
- local xr1 = xrpoly[1]
- local yr1 = yrpoly[1]
- for r0=nrpoly,1,-1 do
- if xr1 >= minx and xr1 <= maxx and yr1 >= miny and yr1 <= maxy then
- local xr0 = xrpoly[r0]
- local yr0 = yrpoly[r0]
- for s0=1,nspoly do
- if xr1 == xspoly[s0] and yr1 == yspoly[s0] then
- if s0 == nspoly then
- if xr0 == xspoly[1] and yr0 == yspoly[1] then
- ispoly = s0
- irpoly = r0
- goto foundit3
- end
- else
- local s1 = s0 + 1
- if xr0 == xspoly[s1] and yr0 == yspoly[s1] then
- ispoly = s0
- irpoly = r0
- goto foundit3
- end
- end
- end
- end
- xr1 = xr0
- yr1 = yr0
- else
- xr1 = xrpoly[r0]
- yr1 = yrpoly[r0]
- end
- end
- --
- goto nomatch3
- ::foundit3::
- local match1 = 0
- local rpoly1 = irpoly + nrpoly
- local spoly1 = ispoly - 1
- for i=2,nspoly-1 do
- -- search for further matches nearby
- local ir = (rpoly1 - i) % nrpoly + 1
- local is = (spoly1 + i) % nspoly + 1
- if xrpoly[ir] == xspoly[is] and yrpoly[ir] == yspoly[is] then
- match1 = match1 + 1
- else
- break -- goto nomatch1
- end
- end
- ::nomatch1::
- local match2 = 0
- local rpoly2 = irpoly - 1
- local spoly2 = ispoly + nspoly
- for i=2,nspoly-1 do
- -- search other way for further matches nearby
- local ir = (rpoly2 + i) % nrpoly + 1
- local is = (spoly2 - i) % nspoly + 1
- if xrpoly[ir] == xspoly[is] and yrpoly[ir] == yspoly[is] then
- match2 = match2 + 1
- else
- break -- goto nomatch2
- end
- end
- ::nomatch2::
- -- local dnrpoly = nspoly - 2 - 2*match1 - 2*match2
- local dnrpoly = nspoly - 2*(match1 + match2 + 1)
- local ispolystart = (ispoly + match1) % nspoly + 1 -- first node of s-polygon to include
- local irpolyend = (rpoly1 - match1 - 1) % nrpoly + 1 -- last node of s-polygon to include
- if dnrpoly ~= 0 then
- local irpolystart = (irpoly + match2) % nrpoly + 1 -- first node of s-polygon to include
- if irpolystart > irpolyend then
- -- local ispolyend = (spoly1 - match2 + nspoly)%nspoly + 1 -- last node of s-polygon to include
- if dnrpoly > 0 then
- -- expand the arrays xrpoly and yrpoly
- for i=nrpoly,irpolystart,-1 do
- local k = i + dnrpoly
- xrpoly[k] = xrpoly[i]
- yrpoly[k] = yrpoly[i]
- end
- else -- if dnrpoly < 0 then
- -- contract the arrays xrpoly and yrpoly
- for i=irpolystart,nrpoly do
- local k = i + dnrpoly
- xrpoly[k] = xrpoly[i]
- yrpoly[k] = yrpoly[i]
- end
- end
- end
- nrpoly = nrpoly + dnrpoly
- end
- if nrpoly < irpolyend then
- for i=irpolyend,nrpoly+1,-1 do
- -- otherwise these values get lost!
- local k = i - nrpoly
- xrpoly[k] = xrpoly[i]
- yrpoly[k] = yrpoly[i]
- end
- end
- local n = nspoly - 2 - match1 - match2
- if n == 1 then
- local irpoly1 = irpolyend % nrpoly + 1
- local ispoly1 = ispolystart % nspoly + 1
- xrpoly[irpoly1] = xspoly[ispoly1]
- yrpoly[irpoly1] = yspoly[ispoly1]
- elseif n > 0 then
- -- often 2
- for i=1,n do
- local ii = i - 1
- local ir = (irpolyend + ii) % nrpoly + 1
- local is = (ispolystart + ii) % nspoly + 1
- xrpoly[ir] = xspoly[is]
- yrpoly[ir] = yspoly[is]
- end
- end
- ::nomatch3::
- end
- end
- end
-
- if nrpoly > 0 then
- local t = { }
- local n = 0
- for i=1,nrpoly do
- n = n + 1 t[n] = xrpoly[i]
- n = n + 1 t[n] = yrpoly[i]
- end
- if mpflatten then
- mpflatten(t) -- maybe integrate
- end
- nofs = nofs + 1
- shade[nofs] = t
- -- print(value,nrpoly,#t,#t-nrpoly*2)
- end
-
- end
-
- edges [value+1] = edge
- shades[value+1] = shade
--- edges [value] = edge
--- shades[value] = shade
- end
-
- result.shades = shades
- result.shapes = edges
-
-end
-
--- accessors
-
-function mp.lmt_contours_nx (i) return getparameterset().result.nx end
-function mp.lmt_contours_ny (i) return getparameterset().result.ny end
-
-function mp.lmt_contours_nofvalues() return getparameterset().result.nofvalues end
-function mp.lmt_contours_value (i) return getparameterset().result.values[i] end
-
-function mp.lmt_contours_minz (i) return getparameterset().result.minz end
-function mp.lmt_contours_maxz (i) return getparameterset().result.maxz end
-
-function mp.lmt_contours_minmean (i) return getparameterset().result.minmean end
-function mp.lmt_contours_maxmean (i) return getparameterset().result.maxmean end
-
-function mp.lmt_contours_xrange () local p = getparameterset() mpstring(formatters["x = [%.3N,%.3N] ;"](p.xmin,p.xmax)) end
-function mp.lmt_contours_yrange () local p = getparameterset() mpstring(formatters["y = [%.3N,%.3N] ;"](p.ymin,p.ymax)) end
-
-function mp.lmt_contours_format()
- local p = getparameterset()
- return mpstring(p.result.islist and "@i" or p.zformat or p.format)
-end
-
-function mp.lmt_contours_function()
- local p = getparameterset()
- return mpstring(p.result.islist and concat(p["functions"], ", ") or p["function"])
-end
-
-function mp.lmt_contours_range()
- local p = getparameterset()
- local r = p.result.islist and p.range
- if not r or #r == 0 then
- return mpstring("")
- elseif #r == 1 then
- return mpstring(r[1])
- else
- return mpstring(formatters["z = [%s,%s]"](r[1],r[2]))
- end
-end
-
-function mp.lmt_contours_edge_paths(value)
- mpdraw(getparameterset().result.edges[value],true)
- mpflush()
-end
-
-function mp.lmt_contours_shape_paths(value)
- mpdraw(getparameterset().result.shapes[value],false)
- mpflush()
-end
-
-function mp.lmt_contours_shade_paths(value)
- mpfill(getparameterset().result.shades[value],true)
- mpflush()
-end
-
-function mp.lmt_contours_color(value)
- local p = getparameterset()
- local color = p.result.colors[value]
- if color then
- mpcolor(color)
- end
-end
-
--- The next code is based on the wikipedia page. It was a bit tedius job to define the
--- coordinates but hupefully I made no errors. I rendered all shapes independently and
--- tripple checked bit one never knows ...
-
--- maybe some day write from scatch, like this (axis are swapped):
-
-local d = 1/2
-
-local paths = {
- { 0, d, d, 0 },
- { 1, d, d, 0 },
- { 0, d, 1, d },
- { 1, d, d, 1 },
- { 0, d, d, 1, d, 0, 1, d }, -- saddle
- { d, 0, d, 1 },
- { 0, d, d, 1 },
- { 0, d, d, 1 },
- { d, 0, d, 1 },
- { 0, d, d, 0, 1, d, d, 1 }, -- saddle
- { 1, d, d, 1 },
- { 0, d, 1, d },
- { d, 0, 1, d },
- { d, 0, 0, d },
-}
-
-local function whatever(data,nx,ny,threshold)
- local edges = { }
- local e = 0
- local d0 = data[1]
- for j=1,ny-1 do
- local d1 = data[j+1]
- local k = j + 1
- for i=1,nx-1 do
- local v = 0
- local l = i + 1
- local c1 = d0[i]
- if c1 < threshold then
- v = v + 8
- end
- local c2 = d0[l]
- if c2 < threshold then
- v = v + 4
- end
- local c3 = d1[l]
- if c3 < threshold then
- v = v + 2
- end
- local c4 = d1[i]
- if c4 < threshold then
- v = v + 1
- end
- if v > 0 and v < 15 then
- if v == 5 or v == 10 then
- local a = (c1 + c2 + c3 + c4) / 4
- if a < threshold then
- v = v == 5 and 10 or 5
- end
- local p = paths[v]
- e = e + 1 edges[e] = k - p[2]
- e = e + 1 edges[e] = i + p[1]
- e = e + 1 edges[e] = k - p[4]
- e = e + 1 edges[e] = i + p[3]
- e = e + 1 edges[e] = k - p[6]
- e = e + 1 edges[e] = i + p[5]
- e = e + 1 edges[e] = k - p[8]
- e = e + 1 edges[e] = i + p[7]
- else
- local p = paths[v]
- e = e + 1 edges[e] = k - p[2]
- e = e + 1 edges[e] = i + p[1]
- e = e + 1 edges[e] = k - p[4]
- e = e + 1 edges[e] = i + p[3]
- end
- end
- end
- d0 = d1
- end
- return edges
-end
-
--- todo: just fetch when needed, no need to cache
-
-function mp.lmt_contours_edge_set_by_cell()
- local p = getparameterset()
- local result = p.result
-
- if result.cached then return end
-
- local values = result.values
- local nofvalues = result.nofvalues
- local data = result.data
- local nx = result.nx
- local ny = result.ny
- local lines = { }
- result.lines = lines
- for value=1,nofvalues do
- lines[value] = whatever(data,ny,nx,value)
- end
-end
-
-function mp.lmt_contours_edge_get_cell(value)
- mpdraw(getparameterset().result.lines[value])
- mpflush()
-end
-
-local singles = {
- { d, 0, 0, 0, 0, d }, -- 1 0001
- { d, 0, 0, d }, -- 2 0002
- { 1, d, 1, 0, d, 0 }, -- 3 0010
- { 1, d, 1, 0, 0, 0, 0, d }, -- 4 0011
- { 1, d, 1, 0, d, 0, 0, d }, -- 5 0012
- { 1, d, d, 0 }, -- 6 0020
- { 1, d, d, 0, 0, 0, 0, d }, -- 7 0021
- { 1, d, 0, d }, -- 8 0022
- { d, 1, 1, 1, 1, d }, -- 9 0100
- false, -- 10 0101
- false, -- 11 0102
- { d, 1, 1, 1, 1, 0, d, 0 }, -- 12 0110
- { d, 1, 1, 1, 1, 0, 0, 0, 0, d }, -- 13 0111
- { d, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 14 0112
- { d, 1, 1, 1, 1, d, d, 0 }, -- 15 0120
- { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, -- 16 0121
- { d, 1, 1, 1, 1, d, 0, d }, -- 17 0122
- { d, 1, 1, d }, -- 18 0200
- false, -- 19 0201
- false, -- 20 0202
- { d, 1, 1, d, 1, 0, d, 0 }, -- 21 0210
- { d, 1, 1, d, 1, 0, 0, 0, 0, d }, -- 22 0211
- false, -- 23 0212
- { d, 1, d, 0 }, -- 24 0220
- { d, 1, d, 0, 0, 0, 0, d }, -- 25 0221
- { d, 1, 0, d }, -- 26 0222
- { 0, 1, d, 1, 0, d }, -- 27 1000
- { 0, 1, d, 1, d, 0, 0, 0 }, -- 28 1001
- { 0, 1, d, 1, d, 0, 0, d }, -- 29 1002
- false, -- 30 1010
- { 0, 1, d, 1, 1, d, 1, 0, 0, 0 }, -- 31 1011
- { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, -- 32 1012
- false, -- 33 1020
- { 0, 1, d, 1, 1, d, d, 0, 0, 0 }, -- 34 1021
- { 0, 1, d, 1, 1, d, 0, d }, -- 35 1022
- { 0, 1, 1, 1, 1, d, 0, d }, -- 36 1100
- { 0, 1, 1, 1, 1, d, d, 0, 0, 0 }, -- 37 1101
- { 0, 1, 1, 1, 1, d, d, 0, 0, d }, -- 38 1102
- { 0, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 39 1110
- { 0, 1, 1, 1, 1, 0, 0, 0 }, -- 40 1111
- { 0, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 41 1112
- { 0, 1, 1, 1, 1, d, d, 0, 0, d }, -- 42 1120
- { 0, 1, 1, 1, 1, d, d, 0, 0, 0 }, -- 43 1121
- { 0, 1, 1, 1, 1, d, 0, d }, -- 44 1122
- { 0, 1, d, 1, 1, d, 0, d }, -- 45 1200
- { 0, 1, d, 1, 1, d, d, 0, 0, 0 }, -- 46 1201
- false, -- 47 1202
- { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, -- 48 1210
- { 0, 1, d, 1, 1, d, 1, 0, 0, 0 }, -- 49 1211
- false, -- 50 1212
- { 0, 1, d, 1, d, 0, 0, d }, -- 51 1220
- { 0, 1, d, 1, d, 0, 0, 0 }, -- 52 1221
- { 0, 1, d, 1, 0, d }, -- 53 1222
- { d, 1, 0, d }, -- 54 2000
- { d, 1, d, 0, 0, 0, 0, d }, -- 55 2001
- { d, 1, d, 0 }, -- 56 2002
- false, -- 57 2010
- { d, 1, 1, d, 1, 0, 0, 0, 0, d }, -- 58 2011
- { d, 1, 1, d, 1, 0, d, 0 }, -- 59 2012
- false, -- 60 2020
- false, -- 61 2021
- { d, 1, 1, d }, -- 62 2022
- { d, 1, 1, 1, 1, d, 0, d }, -- 63 2100
- { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, -- 64 2101
- { d, 1, 1, 1, 1, d, d, 0 }, -- 65 2102
- { d, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 66 2110
- { d, 1, 1, 1, 1, 0, 0, 0, 0, d }, -- 67 2111
- { d, 1, 1, 1, 1, 0, d, 0 }, -- 68 2112
- false, -- 69 2120
- false, -- 70 2121
- { d, 1, 1, 1, 1, d }, -- 71 2122
- { 1, d, 0, d }, -- 72 2200
- { 1, d, d, 0, 0, 0, 0, d }, -- 73 2201
- { 1, d, d, 0 }, -- 74 2202
- { 1, d, 1, 0, d, 0, 0, d }, -- 75 2210
- { 1, d, 1, 0, 0, 0, 0, d }, -- 76 2211
- { 1, d, 1, 0, d, 0 }, -- 77 2212
- { d, 0, 0, d }, -- 78 2220
- { 0, d, 0, 0, d, 0 }, -- 79 2221
-}
-
-local sadles = {
- false, false, false, false, false, false, false, false, false,
- { { d, 1, 1, 1, 1, d }, { d, 0, 0, 0, 0, d }, { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, false, false, false }, -- 10 0101
- { { d, 1, 1, 1, 1, d }, { d, 0, 0, d }, { d, 1, 1, 1, 1, d, d, 0, 0, d }, false, false, false }, -- 11 0102
- false, false, false, false, false, false, false,
- { { d, 1, 1, d }, { d, 0, 0, 0, 0, d }, { d, 1, 1, d, d, 0, 0, 0, 0, d }, false, false, false }, -- 19 0201
- { { d, 1, 1, d }, { d, 0, 0, d }, { d, 1, 1, d, d, 0, 0, d }, false, { d, 1, 0, d }, { 1, d, d, 0 } }, -- 20 0202
- false, false,
- { false, false, { d, 1, 1, d, 1, 0, d, 0, 0, d }, false, { d, 1, 0,d, }, { 1, d, 1, 0,d, 0 } }, -- 23 0212
- false, false, false, false, false, false,
- { { 0, 1, d, 1, 0, d }, { 1, d, 1, 0, d, 0 }, { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, false, false, false }, -- 30 1010
- false, false,
- { { 1, 0, d, 0, 0, d, }, { 1, d, d, 0 }, { 0, 1, d, 1, 1, d, d, 0, 0, d }, false, false, false }, -- 33 1020
- false, false, false, false, false, false, false, false, false, false, false, false, false,
- { false, false, { 0,1, d, 1, 1, d, d, 0, 0, d }, false, { 0,1, d, 1, 0, d }, {1, d, d, 0 } }, -- 47 1202
- false, false,
- { false, false, { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, false, { 0, 1, d, 1, 0, d }, { 1, d, 1, 0, d, 0 } }, -- 50 1212
- false, false, false, false, false, false,
- { { d, 1, 0, d }, { 1, d, 1, 0, 0, d }, { d, 1, 1, d, 1, 0, d, 0, 0, d }, false, false, false }, -- 57 2010
- false, false,
- { { d, 1, 0,d }, { 1, d, d, 0 }, { d, 1, 1, d, d, 0, 0, d }, false, { d, 1, 1, d }, { d, 0, 0, d } }, -- 60 2020
- { false, false, { d, 1, 1, d, d, 0, 0, 0, 0, d }, false, { d, 1, 1, d }, { d, 0, 0, 0, 0, d } }, -- 61 2021
- false, false, false, false, false, false, false,
- { false, false, { d, 1, 1, 1, 1, d, d, 0, 0, d }, false, { d, 1, 1, 1, 1, d }, { d, 0,0,d } }, -- 69 2120
- { false, false, { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, false, { d, 1, 1, 1, 1, d }, { d, 0, 0, 0, 0, d } }, -- 70 2121
-}
-
-local function whatever(data,nx,ny,threshold,background)
-
- if background then
-
- local llx = 1/2
- local lly = llx
- local urx = ny + llx
- local ury = nx + lly
-
- return { { llx, lly, urx, 0, urx, ury, 0, ury } }
-
- else
-
- local bands = { }
- local b = 0
-
- local function band(s,n,x,y) -- simple. no closure so fast
- if n == 6 then
- return {
- x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
- }
- elseif n == 8 then
- return {
- x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
- x - s[ 8], y + s[ 7],
- }
- elseif n == 10 then
- return {
- x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
- x - s[ 8], y + s[ 7], x - s[10], y + s[ 9],
- }
- elseif n == 4 then
- return {
- x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3],
- }
- else -- 12
- return {
- x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
- x - s[ 8], y + s[ 7], x - s[10], y + s[ 9], x - s[12], y + s[11],
- }
- end
- end
-
- local pp = { }
-
- local d0 = data[1]
- for j=1,ny-1 do
- local d1 = data[j+1]
- local k = j + 1
- local p = false
- for i=1,nx-1 do
- local v = 0
- local l = i + 1
- local c1 = d0[i]
- if c1 == threshold then
- v = v + 27
- elseif c1 > threshold then
- v = v + 54
- end
- local c2 = d0[l]
- if c2 == threshold then
- v = v + 9
- elseif c2 > threshold then
- v = v + 18
- end
- local c3 = d1[l]
- if c3 == threshold then
- v = v + 3
- elseif c3 > threshold then
- v = v + 6
- end
- local c4 = d1[i]
- if c4 == threshold then
- v = v + 1
- elseif c4 > threshold then
- v = v + 2
- end
- if v > 0 and v < 80 then
- if v == 40 then
- -- a little optimization: full areas appended horizontally
- if p then
- p[4] = l -- i + 1
- p[6] = l -- i + 1
- else
- -- x-0 y+1 x-1 y+1 x-1 y+0 x-0 y+0
- p = { j, i, j, l, k, l, k, i }
- b = b + 1 ; bands[b] = p
- end
- else
- local s = singles[v]
- if s then
- b = b + 1 ; bands[b] = band(s,#s,k,i)
- else
- local s = sadles[v]
- if s then
- local m = (c1 + c2 + c3 + c4) / 4
- if m < threshold then
- local s1 = s[1] if s1 then b = b + 1 ; bands[b] = band(s1,#s1,i,j) end
- local s2 = s[2] if s2 then b = b + 1 ; bands[b] = band(s2,#s2,i,j) end
- elseif m == threshold then
- local s3 = s[3] if s3 then b = b + 1 ; bands[b] = band(s3,#s3,i,j) end
- local s4 = s[4] if s4 then b = b + 1 ; bands[b] = band(s4,#s4,i,j) end
- else
- local s5 = s[5] if s5 then b = b + 1 ; bands[b] = band(s5,#s5,i,j) end
- local s6 = s[6] if s6 then b = b + 1 ; bands[b] = band(s6,#s6,i,j) end
- end
- end
- end
- p = false
- end
- else
- p = false
- end
- end
- d0 = d1
- end
- return bands
- end
-end
-
-function mp.lmt_contours_edge_set_by_band(value)
- local p = getparameterset()
- local result = p.result
-
- if result.cached then return end
-
- local values = result.values
- local nofvalues = result.nofvalues
- local data = result.data
- local nx = result.nx
- local ny = result.ny
- local bands = { }
- result.bands = bands
- for value=1,nofvalues do
- bands[value] = whatever(data,ny,nx,value,value == 1)
- end
-end
-
-function mp.lmt_contours_edge_get_band(value)
- mpfill(getparameterset().result.bands[value],true)
- mpflush()
-end
-
--- Because we share some code surface plots also end up here. When working on the
--- contour macros by concidence I ran into a 3D plot in
---
--- https://staff.science.uva.nl/a.j.p.heck/Courses/mptut.pdf
---
--- The code is pure MetaPost and works quite well. With a bit of optimization
--- performance is also ok, but in the end a Lua solution is twice as fast and also
--- permits some more tweaking at no cost. So, below is an adaptation of an example
--- in the mentioned link. It's one of these cases where access to pseudo arrays
--- is slowing down MP.
-
-local sqrt, sin, cos = math.sqrt, math.sin, math.cos
-
-local f_fill_rgb = formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"]
-local f_draw_rgb = formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"]
-local f_mesh_rgb = formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"]
-local f_fill_cmy = formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N,0) ;"]
-local f_draw_cmy = formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"]
-local f_mesh_cmy = formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N,0) ;"]
-
-local f_function_n = formatters [ [[
- local math = math
- local round = math.round
- %s
- return function(x,y)
- return %s
- end
-]] ]
-
-local f_function_y = formatters [ [[
- local math = math
- local round = math.round
- local nan = NaN
- local inf = math.huge
- local er = 0
- %s
- return function(x,y,dnan,dinf,report)
- local n = %s
- if n == nan then
- er = er + 1
- if er < 10 then
- report("nan at (%s,%s)",x,y)
- end
- n = dnan
- elseif n == inf then
- er = er + 1
- if er < 10 then
- report("inf at (%s,%s)",x,y)
- end
- n = dinf
- end
- dx[my] = n
- sy = sy + 1
- end
- return n, er
-end
-]] ]
-
-local f_color = formatters [ [[
- local math = math
- return function(f)
- return %s
- end
-]] ]
-
-function mp.lmt_surface_do(specification)
- --
- -- The projection and color brightness calculation have been inlined. We also store
- -- differently.
- --
- -- todo: ignore weird paths
- --
- -- The prototype is now converted to use lmt parameter sets.
- --
- local p = getparameterset("surface")
- --
- local preamble = p.preamble or ""
- local code = p.code or "return x + y"
- local colorcode = p.color or "return f, f, f"
- local linecolor = p.linecolor or 1
- local xmin = p.xmin or -1
- local xmax = p.xmax or 1
- local ymin = p.ymin or -1
- local ymax = p.ymax or 1
- local xstep = p.xstep or .1
- local ystep = p.ystep or .1
- local bf = p.brightness or 100
- local clip = p.clip or false
- local lines = p.lines
- local ha = p.snap or 0.01
- local hb = 2 * ha
- --
- if lines == nil then lines = true end
- --
- if xstep == 0 then xstep = (xmax - xmin)/100 end
- if ystep == 0 then ystep = (ymax - ymin)/100 end
-
- local nxmin = round(xmin/xstep)
- local nxmax = round(xmax/xstep)
- local nymin = round(ymin/ystep)
- local nymax = round(ymax/ystep)
- local nx = nxmax - nxmin + 1
- local ny = nymax - nymin + 1
- --
- local xvector = p.xvector or { -0.7, -0.7 }
- local yvector = p.yvector or { 1, 0 }
- local zvector = p.zvector or { 0, 1 }
- local light = p.light or { 3, 3, 10 }
- --
- local xrx, xry = xvector[1], xvector[2]
- local yrx, yry = yvector[1], yvector[2]
- local zrx, zry = zvector[1], zvector[2]
- local xp, yp, zp = light[1], light[2], light[3]
- --
- local data = setmetatableindex("table")
- local dx = (xmax - xmin) / nx
- local dy = (ymax - ymin) / ny
- local xt = xmin
- --
- local minf, maxf
- --
- -- similar as contours but no data loop here
- --
- local fcode = load((p.check and f_function_y or f_function_n)(preamble,code))
- local func = type(fcode) == "function" and fcode()
- if type(func) ~= "function" then
- return false -- fatal error
- end
- --
- local ccode = load(f_color(colorcode))
- local color = type(ccode) == "function" and ccode()
- if type(color) ~= "function" then
- return false -- fatal error
- end
- --
- for i=0,nx do
- local yt = ymin
- for j=0,ny do
- local zt = func(xt,yt)
- -- projection from 3D to 2D coordinates
- local x = xt * xrx + yt * yrx + zt * zrx
- local y = xt * xry + yt * yry + zt * zry
- local z = zt
- -- numerical derivatives by central differences
- local dfx = (func(xt+ha,yt) - func(xt-ha,yt)) / hb
- local dfy = (func(xt,yt+ha) - func(xt,yt-ha)) / hb
- -- compute brightness factor at a point
- local ztp = zt - zp
- local ytp = yt - yp
- local xtp = xt - xp
- local ztp = zt - zp
- local ytp = yt - yp
- local xtp = xt - xp
- local ca = -ztp + dfy*ytp + dfx*xtp
- local cb = sqrt(1+dfx*dfx+dfy*dfy)
- local cc = sqrt(ztp*ztp + ytp*ytp + xtp*xtp)
- local fac = bf*ca/(cb*cc*cc*cc)
- -- addition: check range
- if not minf then
- minf = fac
- maxf = fac
- elseif fac < minf then
- minf = fac
- elseif fac > maxf then
- maxf = fac
- end
- --
- data[i][j] = { x, y, fac }
- --
- yt = yt + dy
- end
- xt = xt + dx
- end
- local result = { }
- local r = 0
- local range = maxf - minf
- local cl = linecolor or 1
- local enforce = attributes.colors.model == "cmyk"
- for i=0,nx-1 do
- for j=0,ny-1 do
- -- points
- local z1 = data[i] [j]
- local z2 = data[i] [j+1]
- local z3 = data[i+1][j+1]
- local z4 = data[i+1][j]
- -- color
- local cf = z1[3]
- if clip then
- -- best clip here if needed
- if cf < 0 then
- cf = 0
- elseif cf > 1 then
- cf = 1
- end
- else
- -- or remap when we want to
- cf = (z1[3] - minf) / range
- end
- local z11 = z1[1]
- local z12 = z1[2]
- local z21 = z2[1]
- local z22 = z2[2]
- local z31 = z3[1]
- local z32 = z3[2]
- local z41 = z4[1]
- local z42 = z4[2]
- -- if lines then
- -- -- fill first and draw then, previous shapes can be covered
- -- else
- -- -- fill and draw in one go to prevent artifacts
- -- end
- local cr, cg, cb = color(cf)
- if not cr then cr = 0 end
- if not cg then cg = 0 end
- if not cb then cb = 0 end
- if enforce then
- cr, cg, cb = 1 - cr, 1 - cg, 1 - cb
- r = r + 1
- if lines then
- result[r] = f_fill_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
- r = r + 1
- result[r] = f_draw_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cl)
- else
- result[r] = f_mesh_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
- end
- else
- r = r + 1
- if lines then
- result[r] = f_fill_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
- r = r + 1
- result[r] = f_draw_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cl)
- else
- result[r] = f_mesh_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
- end
- end
- end
- end
- mp.direct(concat(result))
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua
index c913408cd05..24b02f6f6a6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua
@@ -266,10 +266,10 @@ function metapost.getclippath(specification) -- why not a special instance for t
result = metapost.filterclippath(result)
end
stoptiming(metapost)
- metapost.pushformat()
+ metapost.popformat()
return result
else
- metapost.pushformat()
+ metapost.popformat()
end
end
@@ -335,12 +335,13 @@ statistics.register("metapost", function()
if n and n > 0 then
local elapsedtime = statistics.elapsedtime
local elapsed = statistics.elapsed
+ local runs, stats = metapost.nofscriptruns()
local instances,
memory = metapost.getstatistics(true)
- return format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %i, memory: %0.3f M",
+ return format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %s, memory: %0.3f M",
elapsedtime(metapost), elapsedtime(mplib), elapsedtime(metapost.exectime), n,
elapsedtime((elapsed(metapost) + elapsed(mplib) + elapsed(metapost.exectime)) / n),
- instances, metapost.nofscriptruns(),memory/(1024*1024))
+ instances, stats and stats or runs, memory/(1024*1024))
else
return nil
end
@@ -400,3 +401,31 @@ implement {
name = "mptexreset",
actions = mptex.reset
}
+
+-- moved from mlib-lua:
+
+mp = mp or { -- system namespace
+ set = { },
+ get = { },
+ aux = { },
+ scan = { },
+ skip = { },
+ inject = { },
+}
+
+MP = MP or { } -- user namespace
+
+-- We had this:
+--
+-- table.setmetatablecall(mp,function(t,k) mpprint(k) end)
+--
+-- but the next one is more interesting because we cannot use calls like:
+--
+-- lua.mp.somedefdname("foo")
+--
+-- which is due to expansion of somedefdname during suffix creation. So:
+--
+-- lua.mp("somedefdname","foo")
+
+table.setmetatablecall(mp,function(t,k,...) return t[k](...) end)
+table.setmetatablecall(MP,function(t,k,...) return t[k](...) end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkiv
index a1ed7efeb8c..7fb567746d0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkiv
@@ -13,14 +13,13 @@
\writestatus{loading}{MetaPost Library Graphics / Initializations}
+\registerctxluafile{mlib-fio}{}
\registerctxluafile{mlib-run}{}
\registerctxluafile{mlib-ctx}{}
-\registerctxluafile{mlib-lua}{}
-\registerctxluafile{mlib-lmp}{}
-\registerctxluafile{mlib-int}{}
-
-\doifelsefileexists{mlib-cnt.lua}{\registerctxluafile{mlib-cnt}{optimize}}{}
-\doifelsefileexists{mlib-svg.lua}{\registerctxluafile{mlib-svg}{optimize}}{}
+\registerctxluafile{mlib-lua}{autosuffix}
+\registerctxluafile{mlib-mpf}{}
+\registerctxluafile{mlib-lmp}{autosuffix}
+\registerctxluafile{mlib-int}{autosuffix}
\unprotect
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkxl b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkxl
deleted file mode 100644
index bb246062710..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.mkxl
+++ /dev/null
@@ -1,31 +0,0 @@
-%D \module
-%D [ file=mlib-ctx,
-%D version=2008.03.25,
-%D title=\METAPOST\ Integrated Graphics,
-%D subtitle=Basics,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{MetaPost Library Graphics / Initializations}
-
-\registerctxluafile{mlib-run}{}
-\registerctxluafile{mlib-ctx}{}
-\registerctxluafile{mlib-lua}{}
-\registerctxluafile{mlib-scn}{}
-\registerctxluafile{mlib-mat}{}
-\registerctxluafile{mlib-lmp}{}
-\registerctxluafile{mlib-int}{}
-\registerctxluafile{mlib-lmt}{}
-
-\doifelsefileexists{mlib-cnt.lua}{\registerctxluafile{mlib-cnt}{}}{}
-\doifelsefileexists{mlib-svg.lua}{\registerctxluafile{mlib-svg}{}}{}
-
-\unprotect
-
-\protect \endinput
-
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-fio.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-fio.lua
new file mode 100644
index 00000000000..51c88eb2237
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-fio.lua
@@ -0,0 +1,85 @@
+if not modules then modules = { } end modules ['mlib-run'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local concat = table.concat
+local mplib = mplib
+
+local report_logger = logs.reporter("metapost log")
+local report_error = logs.reporter("metapost error")
+
+local l, nl, dl = { }, 0, false
+local t, nt, dt = { }, 0, false
+local e, ne, de = { }, 0, false
+
+mplib.realtimelogging = false
+
+local function logger(target,str)
+ if target == 1 then
+ -- log
+ elseif target == 2 or target == 3 then
+ -- term
+ if str == "\n" then
+ mplib.realtimelogging = true
+ if nl > 0 then
+ report_logger(concat(l,"",1,nl))
+ nl, dl = 0, false
+ elseif not dl then
+ report_logger("")
+ dl = true
+ end
+ else
+ nl = nl + 1
+ l[nl] = str
+ end
+ elseif target == 4 then
+ report_error(str)
+ end
+end
+
+local finders = { }
+mplib.finders = finders -- also used in meta-lua.lua
+
+local new_instance = mplib.new
+
+local function validftype(ftype)
+ if ftype == "mp" then
+ return "mp"
+ else
+ return nil
+ end
+end
+
+finders.file = function(specification,name,mode,ftype)
+ return resolvers.findfile(name,validftype(ftype))
+end
+
+local function i_finder(name,mode,ftype) -- fake message for mpost.map and metafun.mpvi
+ local specification = url.hashed(name)
+ local finder = finders[specification.scheme] or finders.file
+ local found = finder(specification,name,mode,validftype(ftype))
+ return found
+end
+
+local function o_finder(name,mode,ftype)
+ return name
+end
+
+o_finder = sandbox.register(o_finder,sandbox.filehandlerone,"mplib output finder")
+
+local function finder(name,mode,ftype)
+ return (mode == "w" and o_finder or i_finder)(name,mode,validftype(ftype))
+end
+
+function mplib.new(specification)
+ specification.find_file = finder
+ specification.run_logger = logger
+ return new_instance(specification)
+end
+
+mplib.finder = finder
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-int.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-int.lua
index 6fca9530236..2f5f539e9ec 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-int.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-int.lua
@@ -20,8 +20,6 @@ local mpcolor = attributes.colors.mpcolor
local emwidths = fonts.hashes.emwidths
local exheights = fonts.hashes.exheights
-local mpgetdimen = mp.getdimen
-
local registerscript = metapost.registerscript
local on_right_page = structures.pages.on_right
@@ -34,233 +32,123 @@ local function defaultcolormodel() -- can be helper
return (colormethod == 0 or colormethod == 1) and 1 or 3
end
-if CONTEXTLMTXMODE > 0 then
-
- local t = os.date("*t") -- maybe this should be a very early on global
-
- registerscript("year", function() return t.year end)
- registerscript("month", function() return t.month end)
- registerscript("day", function() return t.day end)
- registerscript("hour", function() return t.hour end)
- registerscript("minute", function() return t.min end)
- registerscript("second", function() return t.sec end)
-
- registerscript("PaperHeight", function() return getdimen("paperheight") * factor end)
- registerscript("PaperWidth", function() return getdimen("paperwidth") * factor end)
- registerscript("PrintPaperHeight", function() return getdimen("printpaperheight") * factor end)
- registerscript("PrintPaperWidth", function() return getdimen("printpaperwidth") * factor end)
- registerscript("TopSpace", function() return getdimen("topspace") * factor end)
- registerscript("BottomSpace", function() return getdimen("bottomspace") * factor end)
- registerscript("BackSpace", function() return getdimen("backspace") * factor end)
- registerscript("CutSpace", function() return getdimen("cutspace") * factor end)
- registerscript("MakeupHeight", function() return getdimen("makeupheight") * factor end)
- registerscript("MakeupWidth", function() return getdimen("makeupwidth") * factor end)
- registerscript("TopHeight", function() return getdimen("topheight") * factor end)
- registerscript("TopDistance", function() return getdimen("topdistance") * factor end)
- registerscript("HeaderHeight", function() return getdimen("headerheight") * factor end)
- registerscript("HeaderDistance", function() return getdimen("headerdistance") * factor end)
- registerscript("TextHeight", function() return getdimen("textheight") * factor end)
- registerscript("FooterDistance", function() return getdimen("footerdistance") * factor end)
- registerscript("FooterHeight", function() return getdimen("footerheight") * factor end)
- registerscript("BottomDistance", function() return getdimen("bottomdistance") * factor end)
- registerscript("BottomHeight", function() return getdimen("bottomheight") * factor end)
- registerscript("LeftEdgeWidth", function() return getdimen("leftedgewidth") * factor end)
- registerscript("LeftEdgeDistance", function() return getdimen("leftedgedistance") * factor end)
- registerscript("LeftMarginWidth", function() return getdimen("leftmarginwidth") * factor end)
- registerscript("LeftMarginDistance", function() return getdimen("leftmargindistance") * factor end)
- registerscript("TextWidth", function() return getdimen("textwidth") * factor end)
- registerscript("RightMarginDistance", function() return getdimen("rightmargindistance") * factor end)
- registerscript("RightMarginWidth", function() return getdimen("rightmarginwidth") * factor end)
- registerscript("RightEdgeDistance", function() return getdimen("rightedgedistance") * factor end)
- registerscript("RightEdgeWidth", function() return getdimen("rightedgewidth") * factor end)
- registerscript("InnerMarginDistance", function() return getdimen("innermargindistance") * factor end)
- registerscript("InnerMarginWidth", function() return getdimen("innermarginwidth") * factor end)
- registerscript("OuterMarginDistance", function() return getdimen("outermargindistance") * factor end)
- registerscript("OuterMarginWidth", function() return getdimen("outermarginwidth") * factor end)
- registerscript("InnerEdgeDistance", function() return getdimen("inneredgedistance") * factor end)
- registerscript("InnerEdgeWidth", function() return getdimen("inneredgewidth") * factor end)
- registerscript("OuterEdgeDistance", function() return getdimen("outeredgedistance") * factor end)
- registerscript("OuterEdgeWidth", function() return getdimen("outeredgewidth") * factor end)
- registerscript("PageOffset", function() return getdimen("pagebackgroundoffset") * factor end)
- registerscript("PageDepth", function() return getdimen("pagebackgrounddepth") * factor end)
- registerscript("LayoutColumns", function() return getcount("layoutcolumns") end)
- registerscript("LayoutColumnDistance", function() return getdimen("layoutcolumndistance") * factor end)
- registerscript("LayoutColumnWidth", function() return getdimen("layoutcolumnwidth") * factor end)
- registerscript("SpineWidth", function() return getdimen("spinewidth") * factor end)
- registerscript("PaperBleed", function() return getdimen("paperbleed") * factor end)
-
- registerscript("RealPageNumber", function() return getcount("realpageno") end)
- registerscript("LastPageNumber", function() return getcount("lastpageno") end)
-
- registerscript("PageNumber", function() return getcount("pageno") end)
- registerscript("NOfPages", function() return getcount("lastpageno") end)
-
- registerscript("SubPageNumber", function() return getcount("subpageno") end)
- registerscript("NOfSubPages", function() return getcount("lastsubpageno") end)
-
- registerscript("CurrentColumn", function() return getcount("mofcolumns") end)
- registerscript("NOfColumns", function() return getcount("nofcolumns") end)
-
- registerscript("BaseLineSkip", function() return get ("baselineskip",true) * factor end)
- registerscript("LineHeight", function() return getdimen("lineheight") * factor end)
- registerscript("BodyFontSize", function() return getdimen("bodyfontsize") * factor end)
-
- registerscript("TopSkip", function() return get ("topskip",true) * factor end)
- registerscript("StrutHeight", function() return getdimen("strutht") * factor end)
- registerscript("StrutDepth", function() return getdimen("strutdp") * factor end)
-
- registerscript("PageNumber", function() return getcount("pageno") end)
- registerscript("RealPageNumber", function() return getcount("realpageno") end)
- registerscript("NOfPages", function() return getcount("lastpageno") end)
-
- registerscript("CurrentWidth", function() return get ("hsize") * factor end)
- registerscript("CurrentHeight", function() return get ("vsize") * factor end)
-
- registerscript("EmWidth", function() return emwidths [false] * factor end)
- registerscript("ExHeight", function() return exheights[false] * factor end)
-
- registerscript("HSize", function() return get ("hsize") * factor end)
- registerscript("VSize", function() return get ("vsize") * factor end)
- registerscript("LastPageNumber", function() return getcount("lastpageno") end)
-
- registerscript("OverlayWidth", function() return getdimen("d_overlay_width") * factor end)
- registerscript("OverlayHeight", function() return getdimen("d_overlay_height") * factor end)
- registerscript("OverlayDepth", function() return getdimen("d_overlay_depth") * factor end)
- registerscript("OverlayLineWidth", function() return getdimen("d_overlay_linewidth") * factor end)
- registerscript("OverlayOffset", function() return getdimen("d_overlay_offset") * factor end)
- registerscript("OverlayRegion", function() mpstring(getmacro("m_overlay_region")) end)
- -- ("CurrentLayout", function() mpstring(getmacro("currentlayout")) end)
-
- registerscript("PageFraction", page_fraction)
- registerscript("OnRightPage", on_right_page)
- registerscript("OnOddPage", is_odd_page )
- registerscript("InPageBody", in_body_page )
-
- registerscript("defaultcolormodel", defaultcolormodel)
-
-else
-
- function mp.PaperHeight () mpnumeric(getdimen("paperheight") * factor) end
- function mp.PaperWidth () mpnumeric(getdimen("paperwidth") * factor) end
- function mp.PrintPaperHeight () mpnumeric(getdimen("printpaperheight") * factor) end
- function mp.PrintPaperWidth () mpnumeric(getdimen("printpaperwidth") * factor) end
- function mp.TopSpace () mpnumeric(getdimen("topspace") * factor) end
- function mp.BottomSpace () mpnumeric(getdimen("bottomspace") * factor) end
- function mp.BackSpace () mpnumeric(getdimen("backspace") * factor) end
- function mp.CutSpace () mpnumeric(getdimen("cutspace") * factor) end
- function mp.MakeupHeight () mpnumeric(getdimen("makeupheight") * factor) end
- function mp.MakeupWidth () mpnumeric(getdimen("makeupwidth") * factor) end
- function mp.TopHeight () mpnumeric(getdimen("topheight") * factor) end
- function mp.TopDistance () mpnumeric(getdimen("topdistance") * factor) end
- function mp.HeaderHeight () mpnumeric(getdimen("headerheight") * factor) end
- function mp.HeaderDistance () mpnumeric(getdimen("headerdistance") * factor) end
- function mp.TextHeight () mpnumeric(getdimen("textheight") * factor) end
- function mp.FooterDistance () mpnumeric(getdimen("footerdistance") * factor) end
- function mp.FooterHeight () mpnumeric(getdimen("footerheight") * factor) end
- function mp.BottomDistance () mpnumeric(getdimen("bottomdistance") * factor) end
- function mp.BottomHeight () mpnumeric(getdimen("bottomheight") * factor) end
- function mp.LeftEdgeWidth () mpnumeric(getdimen("leftedgewidth") * factor) end
- function mp.LeftEdgeDistance () mpnumeric(getdimen("leftedgedistance") * factor) end
- function mp.LeftMarginWidth () mpnumeric(getdimen("leftmarginwidth") * factor) end
- function mp.LeftMarginDistance () mpnumeric(getdimen("leftmargindistance") * factor) end
- function mp.TextWidth () mpnumeric(getdimen("textwidth") * factor) end
- function mp.RightMarginDistance () mpnumeric(getdimen("rightmargindistance") * factor) end
- function mp.RightMarginWidth () mpnumeric(getdimen("rightmarginwidth") * factor) end
- function mp.RightEdgeDistance () mpnumeric(getdimen("rightedgedistance") * factor) end
- function mp.RightEdgeWidth () mpnumeric(getdimen("rightedgewidth") * factor) end
- function mp.InnerMarginDistance () mpnumeric(getdimen("innermargindistance") * factor) end
- function mp.InnerMarginWidth () mpnumeric(getdimen("innermarginwidth") * factor) end
- function mp.OuterMarginDistance () mpnumeric(getdimen("outermargindistance") * factor) end
- function mp.OuterMarginWidth () mpnumeric(getdimen("outermarginwidth") * factor) end
- function mp.InnerEdgeDistance () mpnumeric(getdimen("inneredgedistance") * factor) end
- function mp.InnerEdgeWidth () mpnumeric(getdimen("inneredgewidth") * factor) end
- function mp.OuterEdgeDistance () mpnumeric(getdimen("outeredgedistance") * factor) end
- function mp.OuterEdgeWidth () mpnumeric(getdimen("outeredgewidth") * factor) end
- function mp.PageOffset () mpnumeric(getdimen("pagebackgroundoffset") * factor) end
- function mp.PageDepth () mpnumeric(getdimen("pagebackgrounddepth") * factor) end
- function mp.LayoutColumns () mpnumeric(getcount("layoutcolumns")) end
- function mp.LayoutColumnDistance() mpnumeric(getdimen("layoutcolumndistance") * factor) end
- function mp.LayoutColumnWidth () mpnumeric(getdimen("layoutcolumnwidth") * factor) end
- function mp.SpineWidth () mpnumeric(getdimen("spinewidth") * factor) end
- function mp.PaperBleed () mpnumeric(getdimen("paperbleed") * factor) end
-
- function mp.RealPageNumber () mpnumeric(getcount("realpageno") ) end
- function mp.LastPageNumber () mpnumeric(getcount("lastpageno") ) end
-
- function mp.PageNumber () mpnumeric(getcount("pageno") ) end
- function mp.NOfPages () mpnumeric(getcount("lastpageno") ) end
-
- function mp.SubPageNumber () mpnumeric(getcount("subpageno") ) end
- function mp.NOfSubPages () mpnumeric(getcount("lastsubpageno") ) end
-
- function mp.CurrentColumn () mpnumeric(getcount("mofcolumns") ) end
- function mp.NOfColumns () mpnumeric(getcount("nofcolumns") ) end
-
- function mp.BaseLineSkip () mpnumeric(get ("baselineskip",true) * factor) end
- function mp.LineHeight () mpnumeric(getdimen("lineheight") * factor) end
- function mp.BodyFontSize () mpnumeric(getdimen("bodyfontsize") * factor) end
-
- function mp.TopSkip () mpnumeric(get ("topskip",true) * factor) end
- function mp.StrutHeight () mpnumeric(getdimen("strutht") * factor) end
- function mp.StrutDepth () mpnumeric(getdimen("strutdp") * factor) end
-
- function mp.PageNumber () mpnumeric(getcount("pageno") ) end
- function mp.RealPageNumber () mpnumeric(getcount("realpageno") ) end
- function mp.NOfPages () mpnumeric(getcount("lastpageno") ) end
-
- function mp.CurrentWidth () mpnumeric(get ("hsize") * factor) end
- function mp.CurrentHeight () mpnumeric(get ("vsize") * factor) end
-
- function mp.EmWidth () mpnumeric(emwidths [false] * factor) end
- function mp.ExHeight () mpnumeric(exheights[false] * factor) end
-
- function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end
- function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end
- function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end
- function mp.OverlayLineWidth () mpnumeric(getdimen("d_overlay_linewidth") * factor) end
- function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end
- function mp.OverlayRegion () mpstring (getmacro("m_overlay_region") ) end
-
- function mp.PageFraction () mpnumeric(page_fraction() ) end
- function mp.OnRightPage () mpboolean(on_right_page() ) end
- function mp.OnOddPage () mpboolean(is_odd_page () ) end
- function mp.InPageBody () mpboolean(in_body_page () ) end
-
- function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end
- function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end
- function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end
- function mp.OverlayLineWidth () mpnumeric(getdimen("d_overlay_linewidth") * factor) end
- function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end
- function mp.OverlayRegion () mpstring (getmacro("m_overlay_region") ) end
- -- mp.CurrentLayout () mpstring (getmacro("currentlayout")) end
-
- function mp.defaultcolormodel () mpnumeric(defaultcolormodel()) end
-
- mp.HSize = mp.CurrentWidth
- mp.VSize = mp.CurrentHeight
- mp.LastPageNumber = mp.NOfPages
-
- -- not much difference (10000 calls in a graphic neither as expansion seems to win
- -- over defining the macro etc) so let's not waste counters then
-
- -- function mp.OverlayColor()
- -- local c = mpcolor(
- -- getcount("c_overlay_colormodel"),
- -- getcount("c_overlay_color"),
- -- getcount("c_overlay_transparency")
- -- )
- -- mpquoted(c)
- -- end
- --
- -- function mp.OverlayLineColor()
- -- local c = mpcolor(
- -- getcount("c_overlay_colormodel"),
- -- getcount("c_overlay_linecolor"),
- -- getcount("c_overlay_linetransparency")
- -- )
- -- mpquoted(c)
- -- end
-
-end
-
-
+function mp.PaperHeight () mpnumeric(getdimen("paperheight") * factor) end
+function mp.PaperWidth () mpnumeric(getdimen("paperwidth") * factor) end
+function mp.PrintPaperHeight () mpnumeric(getdimen("printpaperheight") * factor) end
+function mp.PrintPaperWidth () mpnumeric(getdimen("printpaperwidth") * factor) end
+function mp.TopSpace () mpnumeric(getdimen("topspace") * factor) end
+function mp.BottomSpace () mpnumeric(getdimen("bottomspace") * factor) end
+function mp.BackSpace () mpnumeric(getdimen("backspace") * factor) end
+function mp.CutSpace () mpnumeric(getdimen("cutspace") * factor) end
+function mp.MakeupHeight () mpnumeric(getdimen("makeupheight") * factor) end
+function mp.MakeupWidth () mpnumeric(getdimen("makeupwidth") * factor) end
+function mp.TopHeight () mpnumeric(getdimen("topheight") * factor) end
+function mp.TopDistance () mpnumeric(getdimen("topdistance") * factor) end
+function mp.HeaderHeight () mpnumeric(getdimen("headerheight") * factor) end
+function mp.HeaderDistance () mpnumeric(getdimen("headerdistance") * factor) end
+function mp.TextHeight () mpnumeric(getdimen("textheight") * factor) end
+function mp.FooterDistance () mpnumeric(getdimen("footerdistance") * factor) end
+function mp.FooterHeight () mpnumeric(getdimen("footerheight") * factor) end
+function mp.BottomDistance () mpnumeric(getdimen("bottomdistance") * factor) end
+function mp.BottomHeight () mpnumeric(getdimen("bottomheight") * factor) end
+function mp.LeftEdgeWidth () mpnumeric(getdimen("leftedgewidth") * factor) end
+function mp.LeftEdgeDistance () mpnumeric(getdimen("leftedgedistance") * factor) end
+function mp.LeftMarginWidth () mpnumeric(getdimen("leftmarginwidth") * factor) end
+function mp.LeftMarginDistance () mpnumeric(getdimen("leftmargindistance") * factor) end
+function mp.TextWidth () mpnumeric(getdimen("textwidth") * factor) end
+function mp.RightMarginDistance () mpnumeric(getdimen("rightmargindistance") * factor) end
+function mp.RightMarginWidth () mpnumeric(getdimen("rightmarginwidth") * factor) end
+function mp.RightEdgeDistance () mpnumeric(getdimen("rightedgedistance") * factor) end
+function mp.RightEdgeWidth () mpnumeric(getdimen("rightedgewidth") * factor) end
+function mp.InnerMarginDistance () mpnumeric(getdimen("innermargindistance") * factor) end
+function mp.InnerMarginWidth () mpnumeric(getdimen("innermarginwidth") * factor) end
+function mp.OuterMarginDistance () mpnumeric(getdimen("outermargindistance") * factor) end
+function mp.OuterMarginWidth () mpnumeric(getdimen("outermarginwidth") * factor) end
+function mp.InnerEdgeDistance () mpnumeric(getdimen("inneredgedistance") * factor) end
+function mp.InnerEdgeWidth () mpnumeric(getdimen("inneredgewidth") * factor) end
+function mp.OuterEdgeDistance () mpnumeric(getdimen("outeredgedistance") * factor) end
+function mp.OuterEdgeWidth () mpnumeric(getdimen("outeredgewidth") * factor) end
+function mp.PageOffset () mpnumeric(getdimen("pagebackgroundoffset") * factor) end
+function mp.PageDepth () mpnumeric(getdimen("pagebackgrounddepth") * factor) end
+function mp.LayoutColumns () mpnumeric(getcount("layoutcolumns")) end
+function mp.LayoutColumnDistance() mpnumeric(getdimen("layoutcolumndistance") * factor) end
+function mp.LayoutColumnWidth () mpnumeric(getdimen("layoutcolumnwidth") * factor) end
+function mp.SpineWidth () mpnumeric(getdimen("spinewidth") * factor) end
+function mp.PaperBleed () mpnumeric(getdimen("paperbleed") * factor) end
+
+function mp.RealPageNumber () mpnumeric(getcount("realpageno") ) end
+function mp.LastPageNumber () mpnumeric(getcount("lastpageno") ) end
+
+function mp.PageNumber () mpnumeric(getcount("pageno") ) end
+function mp.NOfPages () mpnumeric(getcount("lastpageno") ) end
+
+function mp.SubPageNumber () mpnumeric(getcount("subpageno") ) end
+function mp.NOfSubPages () mpnumeric(getcount("lastsubpageno") ) end
+
+function mp.CurrentColumn () mpnumeric(getcount("mofcolumns") ) end
+function mp.NOfColumns () mpnumeric(getcount("nofcolumns") ) end
+
+function mp.BaseLineSkip () mpnumeric(get ("baselineskip",true) * factor) end
+function mp.LineHeight () mpnumeric(getdimen("lineheight") * factor) end
+function mp.BodyFontSize () mpnumeric(getdimen("bodyfontsize") * factor) end
+
+function mp.TopSkip () mpnumeric(get ("topskip",true) * factor) end
+function mp.StrutHeight () mpnumeric(getdimen("strutht") * factor) end
+function mp.StrutDepth () mpnumeric(getdimen("strutdp") * factor) end
+
+function mp.PageNumber () mpnumeric(getcount("pageno") ) end
+function mp.RealPageNumber () mpnumeric(getcount("realpageno") ) end
+function mp.NOfPages () mpnumeric(getcount("lastpageno") ) end
+
+function mp.CurrentWidth () mpnumeric(get ("hsize") * factor) end
+function mp.CurrentHeight () mpnumeric(get ("vsize") * factor) end
+
+function mp.EmWidth () mpnumeric(emwidths [false] * factor) end
+function mp.ExHeight () mpnumeric(exheights[false] * factor) end
+
+function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end
+function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end
+function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end
+function mp.OverlayLineWidth () mpnumeric(getdimen("d_overlay_linewidth") * factor) end
+function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end
+function mp.OverlayRegion () mpstring (getmacro("m_overlay_region") ) end
+
+function mp.PageFraction () mpnumeric(page_fraction() ) end
+function mp.OnRightPage () mpboolean(on_right_page() ) end
+function mp.OnOddPage () mpboolean(is_odd_page () ) end
+function mp.InPageBody () mpboolean(in_body_page () ) end
+
+function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end
+function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end
+function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end
+function mp.OverlayLineWidth () mpnumeric(getdimen("d_overlay_linewidth") * factor) end
+function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end
+function mp.OverlayRegion () mpstring (getmacro("m_overlay_region") ) end
+-- mp.CurrentLayout () mpstring (getmacro("currentlayout")) end
+
+function mp.defaultcolormodel () mpnumeric(defaultcolormodel()) end
+
+mp.HSize = mp.CurrentWidth
+mp.VSize = mp.CurrentHeight
+mp.LastPageNumber = mp.NOfPages
+
+-- not much difference (10000 calls in a graphic neither as expansion seems to win
+-- over defining the macro etc) so let's not waste counters then
+
+-- function mp.OverlayColor()
+-- local c = mpcolor(
+-- getcount("c_overlay_colormodel"),
+-- getcount("c_overlay_color"),
+-- getcount("c_overlay_transparency")
+-- )
+-- mpquoted(c)
+-- end
+--
+-- function mp.OverlayLineColor()
+-- local c = mpcolor(
+-- getcount("c_overlay_colormodel"),
+-- getcount("c_overlay_linecolor"),
+-- getcount("c_overlay_linetransparency")
+-- )
+-- mpquoted(c)
+-- end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-lmp.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-lmp.lua
index f000f428245..79370d2ce8d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-lmp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-lmp.lua
@@ -6,219 +6,60 @@ if not modules then modules = { } end modules ['mlib-lmp'] = {
license = "see context related readme files",
}
+-- path relates stuff ... todo: use a stack (or numeric index to list)
+
local type = type
local aux = mp.aux
local mpnumeric = aux.numeric
local mppair = aux.pair
-local mpquoted = aux.quoted
-local mpdirect = aux.direct
-
--- todo: use a stack?
-
-do
-
- local p = nil
- local n = 0
-
- local function mf_path_reset()
- p = nil
- n = 0
- end
-
- if CONTEXTLMTXMODE > 0 then
-
- local scan = mp.scan
- local scannumber = scan.number
- local scanpath = scan.path
-
- local function mf_path_length()
- p = scanpath()
- n = p and #p or 1
- mpnumeric(n)
- end
-
- local function mf_path_point()
- local i = scannumber()
- if i > 0 and i <= n then
- local pi = p[i]
- mppair(pi[1],pi[2])
- end
- end
-
- local function mf_path_left()
- local i = scannumber()
- if i > 0 and i <= n then
- local pi = p[i]
- mppair(pi[5],pi[6])
- end
- end
-
- local function mf_path_right()
- local i = scannumber()
- if i > 0 and i <= n then
- local pn
- if i == 1 then
- pn = p[2] or p[1]
- else
- pn = p[i+1] or p[1]
- end
- mppair(pn[3],pn[4])
- end
- end
-
- local registerscript = metapost.registerscript
-
- registerscript("pathreset", mf_path_reset)
- registerscript("pathlengthof", mf_path_length)
- registerscript("pathpointof", mf_path_point)
- registerscript("pathleftof", mf_path_left)
- registerscript("pathrightof", mf_path_right)
-
- else
-
- local get = mp.get
- local mpgetpath = get.path
-
- local function mf_path_length(name)
- p = mpgetpath(name)
- n = p and #p or 0
- mpnumeric(n)
- end
-
- local function mf_path_point(i)
- if i > 0 and i <= n then
- local pi = p[i]
- mppair(pi[1],pi[2])
- end
- end
-
- local function mf_path_left(i)
- if i > 0 and i <= n then
- local pi = p[i]
- mppair(pi[5],pi[6])
- end
- end
- local function mf_path_right(i)
- if i > 0 and i <= n then
- local pn
- if i == 1 then
- pn = p[2] or p[1]
- else
- pn = p[i+1] or p[1]
- end
- mppair(pn[3],pn[4])
- end
- end
-
- mp.mf_path_length = mf_path_length mp.pathlength = mf_path_length
- mp.mf_path_point = mf_path_point mp.pathpoint = mf_path_point
- mp.mf_path_left = mf_path_left mp.pathleft = mf_path_left
- mp.mf_path_right = mf_path_right mp.pathright = mf_path_right
- mp.mf_path_reset = mf_path_reset mp.pathreset = mf_path_reset
-
- end
+local p = nil
+local n = 0
+local function mf_path_reset()
+ p = nil
+ n = 0
end
-do
+local get = mp.get
+local mpgetpath = get.path
- -- if needed we can optimize the sub (cache last split)
-
- local utflen, utfsub = utf.len, utf.sub
-
- function mp.utflen(s)
- mpnumeric(utflen(s))
- end
+local function mf_path_length(name)
+ p = mpgetpath(name)
+ n = p and #p or 0
+ mpnumeric(n)
+end
- function mp.utfsub(s,f,t)
- mpquoted(utfsub(s,f,t or f))
+local function mf_path_point(i)
+ if i > 0 and i <= n then
+ local pi = p[i]
+ mppair(pi[1],pi[2])
end
-
end
-if CONTEXTLMTXMODE > 0 then
-
- function mp.lmt_svg_include()
- local labelfile = metapost.getparameter { "labelfile" }
- if labelfile and labelfile ~= "" then
- local labels = table.load(labelfile) -- todo: same path as svg file
- if type(labels) == "table" then
- for i=1,#labels do
- metapost.remaptext(labels[i])
- end
- end
- end
- local fontname = metapost.getparameter { "fontname" }
- if fontname and fontname ~= "" then
- local unicode = metapost.getparameter { "unicode" }
- if unicode then
- mpdirect (
- metapost.svgglyphtomp(fontname,math.round(unicode))
- )
- end
- return
- end
- local colorfile = metapost.getparameter { "colormap" }
- local colormap = false
- if colorfile and colorfile ~= "" then
- colormap = metapost.svgcolorremapper(colorfile)
- end
- local filename = metapost.getparameter { "filename" }
- if filename and filename ~= "" then
- mpdirect ( metapost.svgtomp {
- data = io.loaddata(filename),
- remap = true,
- colormap = colormap,
- } )
- else
- local buffer = metapost.getparameter { "buffer" }
- if buffer then
- mpdirect ( metapost.svgtomp {
- data = buffers.getcontent(buffer),
- -- remap = true,
- colormap = colormap,
- } )
- else
- local code = metapost.getparameter { "code" }
- if code then
- mpdirect ( metapost.svgtomp {
- data = code,
- colormap = colormap,
- } )
- end
- end
- end
+local function mf_path_left(i)
+ if i > 0 and i <= n then
+ local pi = p[i]
+ mppair(pi[5],pi[6])
end
-
end
-if CONTEXTLMTXMODE > 0 then
-
- function mp.lmt_do_remaptext()
- local parameters = metapost.scanparameters()
- if parameters and parameters.label then
- metapost.remaptext(parameters)
+local function mf_path_right(i)
+ if i > 0 and i <= n then
+ local pn
+ if i == 1 then
+ pn = p[2] or p[1]
+ else
+ pn = p[i+1] or p[1]
end
+ mppair(pn[3],pn[4])
end
-
end
-if CONTEXTLMTXMODE > 0 then
-
- local dropins = fonts.dropins
- local registerglyphs = dropins.registerglyphs
- local registerglyph = dropins.registerglyph
-
- function mp.lmt_register_glyph()
- registerglyph(metapost.getparameterset("mpsglyph"))
- end
-
- function mp.lmt_register_glyphs()
- registerglyphs(metapost.getparameterset("mpsglyphs"))
- end
-
-end
+mp.mf_path_length = mf_path_length mp.pathlength = mf_path_length
+mp.mf_path_point = mf_path_point mp.pathpoint = mf_path_point
+mp.mf_path_left = mf_path_left mp.pathleft = mf_path_left
+mp.mf_path_right = mf_path_right mp.pathright = mf_path_right
+mp.mf_path_reset = mf_path_reset mp.pathreset = mf_path_reset
-todecimal = xdecimal and xdecimal.new or tonumber -- bonus
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua
deleted file mode 100644
index 9137861a58e..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua
+++ /dev/null
@@ -1,63 +0,0 @@
-if not modules then modules = { } end modules ['mlib-lmt'] = {
- version = 1.001,
- comment = "companion to mlib-ctx.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
-local mppath = mp.path
-
-local scannumeric = mp.scan.numeric
-local scanpath = mp.scan.path
-
-local getparameter = metapost.getparameter
-
-function mp.lmt_function_x(xmin,xmax,xstep,code,shape) -- experimental
- local code = "return function(x) return " .. code .. " end"
- local action = load(code)
- local points = { }
- local nofpoints = 0
- if action then
- action = action()
- end
- if shape == "steps" then
- local halfx = xstep / 2
- local lastx = xmin
- local lasty = action(xmin)
- for xi = xmin, xmax, xstep do
- local yi = action(xi)
- local xx = lastx + halfx
- nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, lasty }
- nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, yi }
- lastx = xi
- lasty = yi
- end
- if points[nofpoints][1] ~= xmax then
- local yi = action(xmax)
- local xx = lastx + halfx
- nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, lasty }
- nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, yi }
- lastx = xi
- lasty = yi
- end
- else
- for xi = xmin, xmax, xstep do
- nofpoints = nofpoints + 1 ; points[nofpoints] = { xi, action(xi) }
- end
- if points[nofpoints][1] ~= xmax then
- nofpoints = nofpoints + 1 ; points[nofpoints] = { xmax, action(xmax) }
- end
- end
- mppath(points,shape == "curve" and ".." or "--",false)
-end
-
-function mp.lmt_mesh_set()
- local mesh = getparameter { "mesh", "paths" }
- structures.references.currentset.mesh = mesh
-end
-
-function mp.lmt_mesh_update()
- local mesh = getparameter { "paths" } or getparameter { "mesh", "paths" }
- mesh[scannumeric()] = scanpath(true)
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-lua.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-lua.lua
index 83ce152e201..b38dbdcf6ea 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-lua.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-lua.lua
@@ -6,1305 +6,45 @@ if not modules then modules = { } end modules ['mlib-lua'] = {
license = "see context related readme files",
}
--- This is very preliminary code!
+local type = type
+local insert, remove = table.insert, table.remove
--- maybe we need mplib.model, but how with instances
+local set = mp.set
+local get = mp.get
-local type, tostring, tonumber, select, loadstring = type, tostring, tonumber, select, loadstring
-local find, match, gsub, gmatch = string.find, string.match, string.gsub, string.gmatch
-local concat, insert, remove = table.concat, table.insert, table.remove
+local currentmpx = nil
+local stack = { }
-local formatters = string.formatters
-local lpegmatch = lpeg.match
-local lpegpatterns = lpeg.patterns
+local get_numeric = mplib.get_numeric
+local get_integer = mplib.get_integer
+local get_string = mplib.get_string
+local get_boolean = mplib.get_boolean
+local get_path = mplib.get_path
+local set_path = mplib.set_path
-local P, S, Ct, Cs, Cc, C = lpeg.P, lpeg.S, lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.C
-
-local report_luarun = logs.reporter("metapost","lua")
-local report_script = logs.reporter("metapost","script")
-local report_message = logs.reporter("metapost")
-
-local trace_luarun = false trackers.register("metapost.lua",function(v) trace_luarun = v end)
-
-local be_tolerant = true directives.register("metapost.lua.tolerant", function(v) be_tolerant = v end)
-
-local get, set, aux, scan = { }, { }, { }, { }
-
-mp = mp or { -- system namespace
- set = set,
- get = get,
- aux = aux,
- scan = scan,
-}
-
-MP = MP or { -- user namespace
-}
-
--- We had this:
---
--- table.setmetatablecall(mp,function(t,k) mpprint(k) end)
---
--- but the next one is more interesting because we cannot use calls like:
---
--- lua.mp.somedefdname("foo")
---
--- which is due to expansion of somedefdname during suffix creation. So:
---
--- lua.mp("somedefdname","foo")
-
-table.setmetatablecall(mp,function(t,k,...) return t[k](...) end)
-table.setmetatablecall(MP,function(t,k,...) return t[k](...) end)
-
-do
-
- local currentmpx = nil
- local stack = { }
-
- if CONTEXTLMTXMODE > 0 then
-
- local scan_next = mplib.scan_next
- local scan_expression = mplib.scan_expression
- local scan_token = mplib.scan_token
- local scan_symbol = mplib.scan_symbol
- local scan_numeric = mplib.scan_numeric
- local scan_integer = mplib.scan_integer
- local scan_boolean = mplib.scan_boolean
- local scan_string = mplib.scan_string
- local scan_pair = mplib.scan_pair
- local scan_color = mplib.scan_color
- local scan_cmykcolor = mplib.scan_cmykcolor
- local scan_transform = mplib.scan_transform
- local scan_path = mplib.scan_path
- local scan_pen = mplib.scan_pen
-
- scan.next = function(k) return scan_next (currentmpx,k) end
- scan.expression = function(k) return scan_expression(currentmpx,k) end
- scan.token = function(k) return scan_token (currentmpx,k) end
- scan.symbol = function(k,e) return scan_symbol (currentmpx,k,e) end
- scan.numeric = function() return scan_numeric (currentmpx) end
- scan.number = function() return scan_numeric (currentmpx) end
- scan.integer = function() return scan_integer (currentmpx) end
- scan.boolean = function() return scan_boolean (currentmpx) end
- scan.string = function() return scan_string (currentmpx) end
- scan.pair = function(t) return scan_pair (currentmpx,t) end
- scan.color = function(t) return scan_color (currentmpx,t) end
- scan.cmykcolor = function(t) return scan_cmykcolor (currentmpx,t) end
- scan.transform = function(t) return scan_transform (currentmpx,t) end
- scan.path = function(t) return scan_path (currentmpx,t) end
- scan.pen = function(t) return scan_pen (currentmpx,t) end
-
- else
-
- local get_numeric = mplib.get_numeric
- local get_integer = mplib.get_integer
- local get_string = mplib.get_string
- local get_boolean = mplib.get_boolean
- local get_path = mplib.get_path
- local set_path = mplib.set_path
-
- get.numeric = function(s) return get_numeric(currentmpx,s) end
- get.number = function(s) return get_numeric(currentmpx,s) end
- get.integer = function(s) return get_integer(currentmpx,s) end
- get.string = function(s) return get_string (currentmpx,s) end
- get.boolean = function(s) return get_boolean(currentmpx,s) end
- get.path = function(s) return get_path (currentmpx,s) end
- set.path = function(s,t) return set_path (currentmpx,s,t) end -- not working yet
-
- end
-
- function metapost.pushscriptrunner(mpx)
- insert(stack,mpx)
- currentmpx = mpx
- end
-
- function metapost.popscriptrunner()
- currentmpx = remove(stack,mpx)
- end
-
- function metapost.currentmpx()
- return currentmpx
- end
-
- local status = mplib.status
-
- function metapost.currentmpxstatus()
- return status and status(currentmpx) or 0
- end
-
-end
-
-do
-
- -- serializers
-
- local f_integer = formatters["%i"]
- local f_numeric = formatters["%F"]
-
- -- no %n as that can produce -e notation and that is not so nice for scaled butmaybe we
- -- should then switch between ... i.e. make a push/pop for the formatters here ... not now.
-
- local f_integer = formatters["%i"]
- local f_numeric = formatters["%F"]
- local f_pair = formatters["(%F,%F)"]
- local f_ctrl = formatters["(%F,%F) .. controls (%F,%F) and (%F,%F)"]
- local f_triplet = formatters["(%F,%F,%F)"]
- local f_quadruple = formatters["(%F,%F,%F,%F)"]
- local f_transform = formatters["totransform(%F,%F,%F,%F,%F,%F)"]
- local f_pen = formatters["(pencircle transformed totransform(%F,%F,%F,%F,%F,%F))"]
-
- local f_points = formatters["%p"]
- local f_pair_pt = formatters["(%p,%p)"]
- local f_ctrl_pt = formatters["(%p,%p) .. controls (%p,%p) and (%p,%p)"]
- local f_triplet_pt = formatters["(%p,%p,%p)"]
- local f_quadruple_pt = formatters["(%p,%p,%p,%p)"]
-
- local r = P('%') / "percent"
- + P('"') / "dquote"
- + P('\n') / "crlf"
- -- + P(' ') / "space"
- local a = Cc("&")
- local q = Cc('"')
- local p = Cs(q * (r * a)^-1 * (a * r * (P(-1) + a) + P(1))^0 * q)
-
- mp.cleaned = function(s) return lpegmatch(p,s) or s end
-
- -- management
-
- -- sometimes we gain (e.g. .5 sec on the sync test)
-
- local cache = table.makeweak()
-
- local runscripts = { }
- local runnames = { }
- local nofscripts = 0
-
- function metapost.registerscript(name,f)
- nofscripts = nofscripts + 1
- if f then
- runscripts[nofscripts] = f
- runnames[name] = nofscripts
- else
- runscripts[nofscripts] = name
- end
- return nofscripts
- end
-
- function metapost.scriptindex(name)
- return runnames[name] or 0
- end
-
- -- The gbuffer sharing and such is not really needed now but make a dent when
- -- we have a high volume of simpel calls (loops) so we keep it around for a
- -- while.
-
- local nesting = 0
- local runs = 0
- local gbuffer = { }
- local buffer = gbuffer
- local n = 0
-
- local function mpdirect1(a)
- n = n + 1 buffer[n] = a
- end
- local function mpdirect2(a,b)
- n = n + 1 buffer[n] = a
- n = n + 1 buffer[n] = b
- end
- local function mpdirect3(a,b,c)
- n = n + 1 buffer[n] = a
- n = n + 1 buffer[n] = b
- n = n + 1 buffer[n] = c
- end
- local function mpdirect4(a,b,c,d)
- n = n + 1 buffer[n] = a
- n = n + 1 buffer[n] = b
- n = n + 1 buffer[n] = c
- n = n + 1 buffer[n] = d
- end
- local function mpdirect5(a,b,c,d,e)
- n = n + 1 buffer[n] = a
- n = n + 1 buffer[n] = b
- n = n + 1 buffer[n] = c
- n = n + 1 buffer[n] = d
- n = n + 1 buffer[n] = e
- end
-
- local function mpflush(separator)
- buffer[1] = concat(buffer,separator or "",1,n)
- n = 1
- end
-
- function metapost.runscript(code)
- nesting = nesting + 1
- runs = runs + 1
-
- local index = type(code) == "number"
- local f
- local result
-
- if index then
- f = runscripts[code]
- if not f then
- report_luarun("%i: bad index: %s",nesting,code)
- elseif trace_luarun then
- report_luarun("%i: index: %i",nesting,code)
- end
- else
- if trace_luarun then
- report_luarun("%i: code: %s",nesting,code)
- end
- f = cache[code]
- if not f then
- f = loadstring("return " .. code)
- if f then
- cache[code] = f
- elseif be_tolerant then
- f = loadstring(code)
- if f then
- cache[code] = f
- end
- end
- end
- end
-
- -- returning nil is more efficient and a signal not to scan in mp
-
- if f then
-
- local lbuffer, ln
-
- if nesting == 1 then
- buffer = gbuffer
- n = 0
- else
- lbuffer = buffer
- ln = n
- buffer = { }
- n = 0
- end
-
- result = f()
-
- if result then
- local t = type(result)
- if t == "number" then
- result = f_numeric(result)
- elseif t == "table" then
- result = concat(result) -- no spaces here
- else
- result = tostring(result)
- end
- if trace_luarun then
- report_luarun("%i: %s result: %s",nesting,t,result)
- end
- elseif n == 0 then
- result = ""
- if trace_luarun then
- report_luarun("%i: no buffered result",nesting)
- end
- elseif n == 1 then
- result = buffer[1]
- if trace_luarun then
- report_luarun("%i: 1 buffered result: %s",nesting,result)
- end
- else
- -- the space is why we sometimes have collectors
- if nesting == 1 then
- result = concat(buffer," ",1,n)
- if n > 500 or #result > 10000 then
- gbuffer = { } -- newtable(20,0)
- lbuffer = gbuffer
- end
- else
- result = concat(buffer," ")
- end
- if trace_luarun then
- report_luarun("%i: %i buffered results: %s",nesting,n,result)
- end
- end
-
- if nesting == 1 then
- n = 0
- else
- buffer = lbuffer
- n = ln
- end
-
- else
- report_luarun("%i: no result, invalid code: %s",nesting,code)
- result = ""
- end
-
- nesting = nesting - 1
-
- return result
- end
-
- function metapost.nofscriptruns()
- return runs
- end
-
- -- writers
-
- local function mpp(value)
- n = n + 1
- local t = type(value)
- if t == "number" then
- buffer[n] = f_numeric(value)
- elseif t == "string" then
- buffer[n] = value
- elseif t == "table" then
- if #t == 6 then
- buffer[n] = "totransform(" .. concat(value,",") .. ")"
- else
- buffer[n] = "(" .. concat(value,",") .. ")"
- end
- else -- boolean or whatever
- buffer[n] = tostring(value)
- end
- end
-
- local function mpprint(first,second,...)
- if second == nil then
- if first ~= nil then
- mpp(first)
- end
- else
- for i=1,select("#",first,second,...) do
- local value = (select(i,first,second,...))
- if value ~= nil then
- mpp(value)
- end
- end
- end
- end
-
- local function mpp(value)
- n = n + 1
- local t = type(value)
- if t == "number" then
- buffer[n] = f_numeric(value)
- elseif t == "string" then
- buffer[n] = lpegmatch(p,value)
- elseif t == "table" then
- if #t > 4 then
- buffer[n] = ""
- else
- buffer[n] = "(" .. concat(value,",") .. ")"
- end
- else -- boolean or whatever
- buffer[n] = tostring(value)
- end
- end
-
- local function mpvprint(first,second,...) -- variable print
- if second == nil then
- if first ~= nil then
- mpp(first)
- end
- else
- for i=1,select("#",first,second,...) do
- local value = (select(i,first,second,...))
- if value ~= nil then
- mpp(value)
- end
- end
- end
- end
-
- local function mpstring(value)
- n = n + 1
- buffer[n] = lpegmatch(p,value)
- end
-
- local function mpboolean(b)
- n = n + 1
- buffer[n] = b and "true" or "false"
- end
-
- local function mpnumeric(f)
- n = n + 1
- if not f or f == 0 then
- buffer[n] = "0"
- else
- buffer[n] = f_numeric(f)
- end
- end
-
- local function mpinteger(i)
- n = n + 1
- -- buffer[n] = i and f_integer(i) or "0"
- buffer[n] = i or "0"
- end
-
- local function mppoints(i)
- n = n + 1
- if not i or i == 0 then
- buffer[n] = "0pt"
- else
- buffer[n] = f_points(i)
- end
- end
-
- local function mppair(x,y)
- n = n + 1
- if type(x) == "table" then
- buffer[n] = f_pair(x[1],x[2])
- else
- buffer[n] = f_pair(x,y)
- end
- end
-
- local function mppairpoints(x,y)
- n = n + 1
- if type(x) == "table" then
- buffer[n] = f_pair_pt(x[1],x[2])
- else
- buffer[n] = f_pair_pt(x,y)
- end
- end
-
- local function mptriplet(x,y,z)
- n = n + 1
- if type(x) == "table" then
- buffer[n] = f_triplet(x[1],x[2],x[3])
- else
- buffer[n] = f_triplet(x,y,z)
- end
- end
-
- local function mptripletpoints(x,y,z)
- n = n + 1
- if type(x) == "table" then
- buffer[n] = f_triplet_pt(x[1],x[2],x[3])
- else
- buffer[n] = f_triplet_pt(x,y,z)
- end
- end
-
- local function mpquadruple(w,x,y,z)
- n = n + 1
- if type(w) == "table" then
- buffer[n] = f_quadruple(w[1],w[2],w[3],w[4])
- else
- buffer[n] = f_quadruple(w,x,y,z)
- end
- end
-
- local function mpquadruplepoints(w,x,y,z)
- n = n + 1
- if type(w) == "table" then
- buffer[n] = f_quadruple_pt(w[1],w[2],w[3],w[4])
- else
- buffer[n] = f_quadruple_pt(w,x,y,z)
- end
- end
-
- local function mptransform(x,y,xx,xy,yx,yy)
- n = n + 1
- if type(x) == "table" then
- buffer[n] = f_transform(x[1],x[2],x[3],x[4],x[5],x[6])
- else
- buffer[n] = f_transform(x,y,xx,xy,yx,yy)
- end
- end
-
- local function mpcolor(c,m,y,k)
- n = n + 1
- if type(c) == "table" then
- local l = #c
- if l == 4 then
- buffer[n] = f_quadruple(c[1],c[2],c[3],c[4])
- elseif l == 3 then
- buffer[n] = f_triplet(c[1],c[2],c[3])
- else
- buffer[n] = f_numeric(c[1])
- end
- else
- if k then
- buffer[n] = f_quadruple(c,m,y,k)
- elseif y then
- buffer[n] = f_triplet(c,m,y)
- else
- buffer[n] = f_numeric(c)
- end
- end
- end
-
- -- we have three kind of connectors:
- --
- -- .. ... -- (true)
-
- local function mp_path(f2,f6,t,connector,cycle)
- if type(t) == "table" then
- local tn = #t
- if tn == 1 then
- local t1 = t[1]
- n = n + 1
- if t.pen then
- buffer[n] = f_pen(unpack(t1))
- else
- buffer[n] = f2(t1[1],t1[2])
- end
- elseif tn > 0 then
- if connector == true or connector == nil then
- connector = ".."
- elseif connector == false then
- connector = "--"
- end
- if cycle == nil then
- cycle = t.cycle
- if cycle == nil then
- cycle = true
- end
- end
- local six = connector == ".." -- otherwise we use whatever gets asked for
- local controls = connector -- whatever
- local a = t[1]
- local b = t[2]
- n = n + 1
- buffer[n] = "("
- n = n + 1
- if six and #a == 6 and #b == 6 then
- buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
- controls = ".."
- else
- buffer[n] = f2(a[1],a[2])
- controls = connector
- end
- for i=2,tn-1 do
- a = b
- b = t[i+1]
- n = n + 1
- buffer[n] = connector
- n = n + 1
- if six and #a == 6 and #b == 6 then
- buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
- controls = ".."
- else
- buffer[n] = f2(a[1],a[2])
- controls = connector
- end
- end
- n = n + 1
- buffer[n] = connector
- a = b
- b = t[1]
- n = n + 1
- if cycle then
- if six and #a == 6 and #b == 6 then
- buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
- controls = ".."
- else
- buffer[n] = f2(a[1],a[2])
- controls = connector
- end
- n = n + 1
- buffer[n] = connector
- n = n + 1
- buffer[n] = "cycle"
- else
- buffer[n] = f2(a[1],a[2])
- end
- n = n + 1
- buffer[n] = ")"
- end
- end
- end
-
- local function mppath(...)
- mp_path(f_pair,f_ctrl,...)
- end
-
- local function mppathpoints(...)
- mp_path(f_pair_pt,f_ctrl_pt,...)
- end
-
- local function mpsize(t)
- n = n + 1
- buffer[n] = type(t) == "table" and f_numeric(#t) or "0"
- end
-
- local replacer = lpeg.replacer("@","%%")
-
- local function mpfprint(fmt,...)
- n = n + 1
- if not find(fmt,"%",1,true) then
- fmt = lpegmatch(replacer,fmt)
- end
- buffer[n] = formatters[fmt](...)
- end
-
- local function mpquoted(fmt,s,...)
- if s then
- n = n + 1
- if not find(fmt,"%",1,true) then
- fmt = lpegmatch(replacer,fmt)
- end
- -- buffer[n] = '"' .. formatters[fmt](s,...) .. '"'
- buffer[n] = lpegmatch(p,formatters[fmt](s,...))
- elseif fmt then
- n = n + 1
- -- buffer[n] = '"' .. fmt .. '"'
- buffer[n] = lpegmatch(p,fmt)
- else
- -- something is wrong
- end
- end
-
- aux.direct = mpdirect1
- aux.direct1 = mpdirect1
- aux.direct2 = mpdirect2
- aux.direct3 = mpdirect3
- aux.direct4 = mpdirect4
- aux.flush = mpflush
-
- aux.print = mpprint
- aux.vprint = mpvprint
- aux.boolean = mpboolean
- aux.string = mpstring
- aux.numeric = mpnumeric
- aux.number = mpnumeric
- aux.integer = mpinteger
- aux.points = mppoints
- aux.pair = mppair
- aux.pairpoints = mppairpoints
- aux.triplet = mptriplet
- aux.tripletpoints = mptripletpoints
- aux.quadruple = mpquadruple
- aux.quadruplepoints = mpquadruplepoints
- aux.path = mppath
- aux.pathpoints = mppathpoints
- aux.size = mpsize
- aux.fprint = mpfprint
- aux.quoted = mpquoted
- aux.transform = mptransform
- aux.color = mpcolor
-
- -- for the moment
-
- local function mpdraw(lines,list) -- n * 4
- if list then
- local c = #lines
- for i=1,c do
- local ci = lines[i]
- local ni = #ci
- n = n + 1 buffer[n] = i < c and "d(" or "D("
- for j=1,ni,2 do
- local l = j + 1
- n = n + 1 buffer[n] = ci[j]
- n = n + 1 buffer[n] = ","
- n = n + 1 buffer[n] = ci[l]
- n = n + 1 buffer[n] = l < ni and ")--(" or ");"
- end
- end
- else
- local l = #lines
- local m = l - 4
- for i=1,l,4 do
- n = n + 1 buffer[n] = i < m and "d(" or "D("
- n = n + 1 buffer[n] = lines[i]
- n = n + 1 buffer[n] = ","
- n = n + 1 buffer[n] = lines[i+1]
- n = n + 1 buffer[n] = ")--("
- n = n + 1 buffer[n] = lines[i+2]
- n = n + 1 buffer[n] = ","
- n = n + 1 buffer[n] = lines[i+3]
- n = n + 1 buffer[n] = ");"
- end
- end
- end
-
- local function mpfill(lines,list)
- if list then
- local c = #lines
- for i=1,c do
- local ci = lines[i]
- local ni = #ci
- n = n + 1 buffer[n] = i < c and "f(" or "F("
- for j=1,ni,2 do
- local l = j + 1
- n = n + 1 buffer[n] = ci[j]
- n = n + 1 buffer[n] = ","
- n = n + 1 buffer[n] = ci[l]
- n = n + 1 buffer[n] = l < ni and ")--(" or ")--C;"
- end
- end
- else
- local l = #lines
- local m = l - 4
- for i=1,l,4 do
- n = n + 1 buffer[n] = i < m and "f(" or "F("
- n = n + 1 buffer[n] = lines[i]
- n = n + 1 buffer[n] = ","
- n = n + 1 buffer[n] = lines[i+1]
- n = n + 1 buffer[n] = ")--("
- n = n + 1 buffer[n] = lines[i+2]
- n = n + 1 buffer[n] = ","
- n = n + 1 buffer[n] = lines[i+3]
- n = n + 1 buffer[n] = ")--C;"
- end
- end
- end
-
- aux.draw = mpdraw
- aux.fill = mpfill
-
- for k, v in next, aux do mp[k] = v end
-
-end
-
-do
-
- -- Another experimental feature:
-
- local mpnumeric = mp.numeric
- local scanstring = scan.string
- local scriptindex = metapost.scriptindex
-
- function mp.mf_script_index(name)
- local index = scriptindex(name)
- -- report_script("method %i, name %a, index %i",1,name,index)
- mpnumeric(index)
- end
-
- -- once bootstrapped ... (needs pushed mpx instances)
-
- metapost.registerscript("scriptindex",function()
- local name = scanstring()
- local index = scriptindex(name)
- -- report_script("method %i, name %a, index %i",2,name,index)
- mpnumeric(index)
- end)
-
-end
-
--- the next will move to mlib-lmp.lua
-
-do
-
- local mpnamedcolor = attributes.colors.mpnamedcolor
- local mpprint = aux.print
- local scanstring = scan.string
-
- mp.mf_named_color = function(str)
- mpprint(mpnamedcolor(str))
- end
-
- metapost.registerscript("namedcolor",function()
- mpprint(mpnamedcolor(scanstring()))
--- test: return mpnamedcolor(scanstring())
- end)
+get.numeric = function(s) return get_numeric(currentmpx,s) end
+get.number = function(s) return get_numeric(currentmpx,s) end
+get.integer = function(s) return get_integer(currentmpx,s) end
+get.string = function(s) return get_string (currentmpx,s) end
+get.boolean = function(s) return get_boolean(currentmpx,s) end
+get.path = function(s) return get_path (currentmpx,s) end
+set.path = function(s,t) return set_path (currentmpx,s,t) end -- not working yet
+function metapost.pushscriptrunner(mpx)
+ insert(stack,mpx)
+ currentmpx = mpx
end
-function mp.n(t) -- used ?
- return type(t) == "table" and #t or 0
+function metapost.popscriptrunner()
+ currentmpx = remove(stack,mpx)
end
-do
-
- -- experiment: names can change
-
- local mppath = aux.path
- local mpsize = aux.size
-
- local whitespace = lpegpatterns.whitespace
- local newline = lpegpatterns.newline
- local setsep = newline^2
- local comment = (S("#%") + P("--")) * (1-newline)^0 * (whitespace - setsep)^0
- local value = (1-whitespace)^1 / tonumber
- local entry = Ct( value * whitespace * value)
- local set = Ct((entry * (whitespace-setsep)^0 * comment^0)^1)
- local series = Ct((set * whitespace^0)^1)
-
- local pattern = whitespace^0 * series
-
- local datasets = { }
- mp.datasets = datasets
-
- function mp.dataset(str)
- return lpegmatch(pattern,str)
- end
-
- function datasets.load(tag,filename)
- if not filename then
- tag, filename = file.basename(tag), tag
- end
- local data = lpegmatch(pattern,io.loaddata(filename) or "")
- datasets[tag] = {
- data = data,
- line = function(n) mppath(data[n or 1]) end,
- size = function() mpsize(data) end,
- }
- end
-
- table.setmetatablecall(datasets,function(t,k,f,...)
- local d = datasets[k]
- local t = type(d)
- if t == "table" then
- d = d[f]
- if type(d) == "function" then
- d(...)
- else
- mpvprint(...)
- end
- elseif t == "function" then
- d(f,...)
- end
- end)
-
+function metapost.currentmpx()
+ return currentmpx
end
--- \startluacode
--- local str = [[
--- 10 20 20 20
--- 30 40 40 60
--- 50 10
---
--- 10 10 20 30
--- 30 50 40 50
--- 50 20 -- the last one
---
--- 10 20 % comment
--- 20 10
--- 30 40 # comment
--- 40 20
--- 50 10
--- ]]
---
--- MP.myset = mp.dataset(str)
---
--- inspect(MP.myset)
--- \stopluacode
---
--- \startMPpage
--- color c[] ; c[1] := red ; c[2] := green ; c[3] := blue ;
--- for i=1 upto lua("mp.print(mp.n(MP.myset))") :
--- draw lua("mp.path(MP.myset[" & decimal i & "])") withcolor c[i] ;
--- endfor ;
--- \stopMPpage
-
--- texts:
-
-do
-
- local mptriplet = mp.triplet
-
- local bpfactor = number.dimenfactors.bp
- local textexts = nil
- local mptriplet = mp.triplet
- local nbdimensions = nodes.boxes.dimensions
-
- function mp.mf_tt_initialize(tt)
- textexts = tt
- end
-
- function mp.mf_tt_dimensions(n)
- local box = textexts and textexts[n]
- if box then
- -- could be made faster with nuts but not critical
- mptriplet(box.width*bpfactor,box.height*bpfactor,box.depth*bpfactor)
- else
- mptriplet(0,0,0)
- end
- end
-
- function mp.mf_tb_dimensions(category,name)
- local w, h, d = nbdimensions(category,name)
- mptriplet(w*bpfactor,h*bpfactor,d*bpfactor)
- end
-
- function mp.report(a,b,c,...)
- if c then
- report_message("%s : %s",a,formatters[(gsub(b,"@","%%"))](c,...))
- elseif b then
- report_message("%s : %s",a,b)
- elseif a then
- report_message("%s : %s","message",a)
- end
- end
+local status = mplib.status
+function metapost.currentmpxstatus()
+ return status and status(currentmpx) or 0
end
-
-do
-
- local mpprint = aux.print
- local modes = tex.modes
- local systemmodes = tex.systemmodes
-
- function mp.mode(s)
- mpprint(modes[s] and true or false)
- end
-
- function mp.systemmode(s)
- mpprint(systemmodes[s] and true or false)
- end
-
- mp.processingmode = mp.mode
-
-end
-
--- for alan's nodes:
-
-do
-
- local mpprint = aux.print
- local mpquoted = aux.quoted
-
- function mp.isarray(str)
- mpprint(find(str,"%d") and true or false)
- end
-
- function mp.prefix(str)
- mpquoted(match(str,"^(.-)[%d%[]") or str)
- end
-
- -- function mp.dimension(str)
- -- local n = 0
- -- for s in gmatch(str,"%[?%-?%d+%]?") do --todo: lpeg
- -- n = n + 1
- -- end
- -- mpprint(n)
- -- end
-
- mp.dimension = lpeg.counter(P("[") * lpegpatterns.integer * P("]") + lpegpatterns.integer,mpprint)
-
- -- faster and okay as we don't have many variables but probably only
- -- basename makes sense and even then it's not called that often
-
- -- local hash = table.setmetatableindex(function(t,k)
- -- local v = find(k,"%d") and true or false
- -- t[k] = v
- -- return v
- -- end)
- --
- -- function mp.isarray(str)
- -- mpprint(hash[str])
- -- end
- --
- -- local hash = table.setmetatableindex(function(t,k)
- -- local v = '"' .. (match(k,"^(.-)%d") or k) .. '"'
- -- t[k] = v
- -- return v
- -- end)
- --
- -- function mp.prefix(str)
- -- mpprint(hash[str])
- -- end
-
-end
-
-do
-
- local getmacro = tex.getmacro
- local getdimen = tex.getdimen
- local getcount = tex.getcount
- local gettoks = tex.gettoks
- local setmacro = tex.setmacro
- local setdimen = tex.setdimen
- local setcount = tex.setcount
- local settoks = tex.settoks
-
- local mpprint = mp.print
- local mpquoted = mp.quoted
-
- local bpfactor = number.dimenfactors.bp
-
- -- more helpers
-
- local function getmacro(k) mpprint (getmacro(k)) end
- local function getdimen(k) mpprint (getdimen(k)*bpfactor) end
- local function getcount(k) mpprint (getcount(k)) end
- local function gettoks (k) mpquoted(gettoks (k)) end
-
- local function setmacro(k,v) setmacro(k,v) end
- local function setdimen(k,v) setdimen(k,v/bpfactor) end
- local function setcount(k,v) setcount(k,v) end
- local function settoks (k,v) settoks (k,v) end
-
- -- def foo = lua.mp.foo ... enddef ; % loops due to foo in suffix
-
- mp._get_macro_ = getmacro mp.getmacro = getmacro
- mp._get_dimen_ = getdimen mp.getdimen = getdimen
- mp._get_count_ = getcount mp.getcount = getcount
- mp._get_toks_ = gettoks mp.gettoks = gettoks
-
- mp._set_macro_ = setmacro mp.setmacro = setmacro
- mp._set_dimen_ = setdimen mp.setdimen = setdimen
- mp._set_count_ = setcount mp.setcount = setcount
- mp._set_toks_ = settoks mp.settoks = settoks
-
-end
-
--- position fun
-
-do
-
- local mprint = mp.print
- local fprint = mp.fprint
- local qprint = mp.quoted
- local jobpositions = job.positions
- local getwhd = jobpositions.whd
- local getxy = jobpositions.xy
- local getposition = jobpositions.position
- local getpage = jobpositions.page
- local getregion = jobpositions.region
- local getmacro = tokens.getters.macro
-
- function mp.positionpath(name)
- local w, h, d = getwhd(name)
- if w then
- fprint("((%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle)",0,-d,w,-d,w,h,0,h)
- else
- mprint("(origin--cycle)")
- end
- end
-
- function mp.positioncurve(name)
- local w, h, d = getwhd(name)
- if w then
- fprint("((%p,%p)..(%p,%p)..(%p,%p)..(%p,%p)..cycle)",0,-d,w,-d,w,h,0,h)
- else
- mprint("(origin--cycle)")
- end
- end
-
- function mp.positionbox(name)
- local p, x, y, w, h, d = getposition(name)
- if p then
- fprint("((%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle)",x,y-d,x+w,y-d,x+w,y+h,x,y+h)
- else
- mprint("(%p,%p)",x,y)
- end
- end
-
- function mp.positionxy(name)
- local x, y = getxy(name)
- if x then
- fprint("(%p,%p)",x,y)
- else
- mprint("origin")
- end
- end
-
- function mp.positionpage(name)
- fprint("%i",getpage(name) or 0)
- end
-
- function mp.positionregion(name)
- local r = getregion(name)
- if r then
- qprint(r)
- else
- qprint("unknown")
- end
- end
-
- function mp.positionwhd(name)
- local w, h, d = getwhd(name)
- if w then
- fprint("(%p,%p,%p)",w,h,d)
- else
- mprint("(0,0,0)")
- end
- end
-
- function mp.positionpxy(name)
- local p, x, y = getposition(name)
- if p then
- fprint("(%p,%p,%p)",p,x,y)
- else
- mprint("(0,0,0)")
- end
- end
-
- function mp.positionanchor()
- qprint(getmacro("MPanchorid"))
- end
-
-end
-
-do
-
- local mppair = mp.pair
-
- function mp.textextanchor(s)
- local x, y = match(s,"tx_anchor=(%S+) (%S+)") -- todo: make an lpeg
- if x and y then
- x = tonumber(x)
- y = tonumber(y)
- end
- mppair(x or 0,y or 0)
- end
-
-end
-
-do
-
- local mprint = mp.print
- local qprint = mp.quoted
- local getmacro = tokens.getters.macro
-
- function mp.texvar(name)
- mprint(getmacro(metapost.namespace .. name))
- end
-
- function mp.texstr(name)
- qprint(getmacro(metapost.namespace .. name))
- end
-
-end
-
-do
-
- local mpprint = aux.print
- local mpvprint = aux.vprint
-
- local hashes = { }
-
- function mp.newhash(name)
- if name then
- hashes[name] = { }
- else
- for i=1,#hashes+1 do
- if not hashes[i] then
- hashes[i] = { }
- mpvprint(i)
- return
- end
- end
- end
- end
-
- function mp.disposehash(n)
- if tonumber(n) then
- hashes[n] = false
- else
- hashes[n] = nil
- end
- end
-
- function mp.inhash(n,key)
- local h = hashes[n]
- mpvprint(h and h[key] and true or false)
- end
-
- function mp.tohash(n,key,value)
- local h = hashes[n]
- if h then
- if value == nil then
- h[key] = true
- else
- h[key] = value
- end
- end
- end
-
- function mp.fromhash(n,key)
- local h = hashes[n]
- mpvprint(h and h[key] or false)
- end
-
- interfaces.implement {
- name = "MPfromhash",
- arguments = "2 strings",
- actions = function(name,key)
- local h = hashes[name] or hashes[tonumber(name)]
- if h then
- local v = h[key] or h[tonumber(key)]
- if v then
- context(v)
- end
- end
- end
- }
-
-end
-
-do
-
- -- a bit overkill: just a find(str,"mf_object=") can be enough
- --
- -- todo : share with mlib-pps.lua metapost,isobject
-
- local mpboolean = aux.boolean
-
- local p1 = P("mf_object=")
- local p2 = lpegpatterns.eol * p1
- local pattern = (1-p2)^0 * p2 + p1
-
- function mp.isobject(str)
- mpboolean(pattern and str ~= "" and lpegmatch(pattern,str))
- end
-
-end
-
-function mp.flatten(t)
- local tn = #t
-
- local t1 = t[1]
- local t2 = t[2]
- local t3 = t[3]
- local t4 = t[4]
-
- for i=1,tn-5,2 do
- local t5 = t[i+4]
- local t6 = t[i+5]
- if t1 == t3 and t3 == t5 and ((t2 <= t4 and t4 <= t6) or (t6 <= t4 and t4 <= t2)) then
- t[i+3] = t2
- t4 = t2
- t[i] = false
- t[i+1] = false
- elseif t2 == t4 and t4 == t6 and ((t1 <= t3 and t3 <= t5) or (t5 <= t3 and t3 <= t1)) then
- t[i+2] = t1
- t3 = t1
- t[i] = false
- t[i+1] = false
- end
- t1 = t3
- t2 = t4
- t3 = t5
- t4 = t6
- end
-
- -- remove duplicates
-
- local t1 = t[1]
- local t2 = t[2]
- for i=1,tn-2,2 do
- local t3 = t[i+2]
- local t4 = t[i+3]
- if t1 == t3 and t2 == t4 then
- t[i] = false
- t[i+1] = false
- end
- t1 = t3
- t2 = t4
- end
-
- -- move coordinates
-
- local m = 0
- for i=1,tn,2 do
- if t[i] then
- m = m + 1 t[m] = t[i]
- m = m + 1 t[m] = t[i+1]
- end
- end
-
- -- prune the table (not gc'd)
-
- for i=tn,m+1,-1 do
- t[i] = nil
- end
-
- -- safeguard so that we have at least one segment
-
- if m == 2 then
- t[3] = t[1]
- t[4] = t[2]
- end
-
-end
-
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-mat.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-mat.lua
deleted file mode 100644
index 6c82a4658b5..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-mat.lua
+++ /dev/null
@@ -1,137 +0,0 @@
-if not modules then modules = { } end modules ['mlib-mat'] = {
- version = 1.001,
- comment = "companion to mlib-ctx.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
-local scanners = mp.scan
-local registerscript = metapost.registerscript
-
-local scannumeric = scanners.numeric
-local scanpair = scanners.pair
-local scancolor = scanners.color
-
-local mppair = mp.pair
-
-local m = xmath
-local c = xcomplex
-
-local m_acos = m.acos registerscript("m_acos", function() return m_acos (scannumeric()) end)
-local m_acosh = m.acosh registerscript("m_acosh", function() return m_acosh (scannumeric()) end)
-local m_asin = m.asin registerscript("m_asin", function() return m_asin (scannumeric()) end)
-local m_asinh = m.asinh registerscript("m_asinh", function() return m_asinh (scannumeric()) end)
-local m_atan = m.atan registerscript("m_atan", function() return m_atan (scannumeric()) end)
-local m_atan2 = m.atan2 registerscript("m_atan2", function() return m_atan2 (scanpair ()) end)
-local m_atanh = m.atanh registerscript("m_atanh", function() return m_atanh (scannumeric()) end)
-local m_cbrt = m.cbrt registerscript("m_cbrt", function() return m_cbrt (scannumeric()) end)
-local m_ceil = m.ceil registerscript("m_ceil", function() return m_ceil (scannumeric()) end)
-local m_copysign = m.copysign registerscript("m_copysign", function() return m_copysign (scanpair ()) end)
-local m_cos = m.cos registerscript("m_cos", function() return m_cos (scannumeric()) end)
-local m_cosh = m.cosh registerscript("m_cosh", function() return m_cosh (scannumeric()) end)
-local m_deg = m.deg registerscript("m_deg", function() return m_deg (scannumeric()) end)
-local m_erf = m.erf registerscript("m_erf", function() return m_erf (scannumeric()) end)
-local m_erfc = m.erfc registerscript("m_erfc", function() return m_erfc (scannumeric()) end)
-local m_exp = m.exp registerscript("m_exp", function() return m_exp (scannumeric()) end)
-local m_exp2 = m.exp2 registerscript("m_exp2", function() return m_exp2 (scannumeric()) end)
-local m_expm1 = m.expm1 registerscript("m_expm1", function() return m_expm1 (scannumeric()) end)
-local m_fabs = m.fabs registerscript("m_fabs", function() return m_fabs (scannumeric()) end)
-local m_fdim = m.fdim registerscript("m_fdim", function() return m_fdim (scanpair ()) end)
-local m_floor = m.floor registerscript("m_floor", function() return m_floor (scannumeric()) end)
-local m_fma = m.fma registerscript("m_fma", function() return m_fma (scancolor ()) end)
-local m_fmax = m.fmax registerscript("m_fmax", function() return m_fmax (scannumeric()) end)
-local m_fmin = m.fmin registerscript("m_fmin", function() return m_fmin (scannumeric()) end)
-local m_fmod = m.fmod registerscript("m_fmod", function() return m_fmod (scanpair ()) end)
-local m_frexp = m.frexp registerscript("m_frexp", function() return m_frexp (scannumeric()) end)
-local m_gamma = m.gamma registerscript("m_gamma", function() return m_gamma (scannumeric()) end)
-local m_hypot = m.hypot registerscript("m_hypot", function() return m_hypot (scanpair ()) end)
-local m_isfinite = m.isfinite registerscript("m_isfinite", function() return m_isfinite (scannumeric()) end)
-local m_isinf = m.isinf registerscript("m_isinf", function() return m_isinf (scannumeric()) end)
-local m_isnan = m.isnan registerscript("m_isnan", function() return m_isnan (scannumeric()) end)
-local m_isnormal = m.isnormal registerscript("m_isnormal", function() return m_isnormal (scannumeric()) end)
-local m_j0 = m.j0 registerscript("m_j0", function() return m_j0 (scannumeric()) end)
-local m_j1 = m.j1 registerscript("m_j1", function() return m_j1 (scannumeric()) end)
-local m_jn = m.jn registerscript("m_jn", function() return m_jn (scanpair ()) end)
-local m_ldexp = m.ldexp registerscript("m_ldexp", function() return m_ldexp (scanpair ()) end)
-local m_lgamma = m.lgamma registerscript("m_lgamma", function() return m_lgamma (scannumeric()) end)
-local m_log = m.log registerscript("m_log", function() return m_log (scannumeric()) end)
-local m_log10 = m.log10 registerscript("m_log10", function() return m_log10 (scannumeric()) end)
-local m_log1p = m.log1p registerscript("m_log1p", function() return m_log1p (scannumeric()) end)
-local m_log2 = m.log2 registerscript("m_log2", function() return m_log2 (scannumeric()) end)
-local m_logb = m.logb registerscript("m_logb", function() return m_logb (scannumeric()) end)
-local m_modf = m.modf registerscript("m_modf", function() return m_modf (scannumeric()) end)
-local m_nearbyint = m.nearbyint registerscript("m_nearbyint", function() return m_nearbyint(scannumeric()) end)
-local m_nextafter = m.nextafter registerscript("m_nextafter", function() return m_nextafter(scanpair ()) end)
-local m_pow = m.pow registerscript("m_pow", function() return m_pow (scanpair ()) end)
-local m_rad = m.rad registerscript("m_rad", function() return m_rad (scannumeric()) end)
-local m_remainder = m.remainder registerscript("m_remainder", function() return m_remainder(scanpair ()) end)
-local m_remquo = m.remquo registerscript("m_remquo", function() return m_remquo (scannumeric()) end)
-local m_round = m.round registerscript("m_round", function() return m_round (scannumeric()) end)
-local m_scalbn = m.scalbn registerscript("m_scalbn", function() return m_scalbn (scanpair ()) end)
-local m_sin = m.sin registerscript("m_sin", function() return m_sin (scannumeric()) end)
-local m_sinh = m.sinh registerscript("m_sinh", function() return m_sinh (scannumeric()) end)
-local m_sqrt = m.sqrt registerscript("m_sqrt", function() return m_sqrt (scannumeric()) end)
-local m_tan = m.tan registerscript("m_tan", function() return m_tan (scannumeric()) end)
-local m_tanh = m.tanh registerscript("m_tanh", function() return m_tanh (scannumeric()) end)
-local m_tgamma = m.tgamma registerscript("m_tgamma", function() return m_tgamma (scannumeric()) end)
-local m_trunc = m.trunc registerscript("m_trunc", function() return m_trunc (scannumeric()) end)
-local m_y0 = m.y0 registerscript("m_y0", function() return m_y0 (scannumeric()) end)
-local m_y1 = m.y1 registerscript("m_y1", function() return m_y1 (scannumeric()) end)
-local m_yn = m.yn registerscript("m_yn", function() return m_yn (scanpair ()) end)
-
-if not (c and c.sin) then
- return
-end
-
-local c_topair = c.topair
-local c_new = c.new
-
-local c_sin = c.sin registerscript("c_sin", function() return mppair(c_topair(c_sin (c_new(scanpair())))) end)
-local c_cos = c.cos registerscript("c_cos", function() return mppair(c_topair(c_cos (c_new(scanpair())))) end)
-local c_tan = c.tan registerscript("c_tan", function() return mppair(c_topair(c_tan (c_new(scanpair())))) end)
-local c_sinh = c.sinh registerscript("c_sinh", function() return mppair(c_topair(c_sinh (c_new(scanpair())))) end)
-local c_cosh = c.cosh registerscript("c_cosh", function() return mppair(c_topair(c_cosh (c_new(scanpair())))) end)
-local c_tanh = c.tanh registerscript("c_tanh", function() return mppair(c_topair(c_tanh (c_new(scanpair())))) end)
-
-local c_asin = c.asin registerscript("c_asin", function() return mppair(c_topair(c_sin (c_new(scanpair())))) end)
-local c_acos = c.acos registerscript("c_acos", function() return mppair(c_topair(c_cos (c_new(scanpair())))) end)
-local c_atan = c.atan registerscript("c_atan", function() return mppair(c_topair(c_tan (c_new(scanpair())))) end)
-local c_asinh = c.asinh registerscript("c_asinh", function() return mppair(c_topair(c_sinh (c_new(scanpair())))) end)
-local c_acosh = c.acosh registerscript("c_acosh", function() return mppair(c_topair(c_cosh (c_new(scanpair())))) end)
-local c_atanh = c.atanh registerscript("c_atanh", function() return mppair(c_topair(c_tanh (c_new(scanpair())))) end)
-
-local c_sqrt = c.sqrt registerscript("c_sqrt", function() return mppair(c_topair(c_sqrt (c_new(scanpair())))) end)
-local c_abs = c.abs registerscript("c_abs", function() return c_topair(c_abs (c_new(scanpair()))) end)
-local c_arg = c.arg registerscript("c_arg", function() return c_topair(c_arg (c_new(scanpair()))) end)
-local c_conj = c.conj registerscript("c_conj", function() return mppair(c_topair(c_conj (c_new(scanpair())))) end)
-local c_exp = c.exp registerscript("c_exp", function() return mppair(c_topair(c_exp (c_new(scanpair())))) end)
-local c_log = c.log registerscript("c_log", function() return mppair(c_topair(c_log (c_new(scanpair())))) end)
-local c_proj = c.proj registerscript("c_proj", function() return mppair(c_topair(c_proj (c_new(scanpair())))) end)
-
-local c_erf = c.erf registerscript("c_erf", function() return mppair(c_topair(c_erf (c_new(scanpair())))) end)
-local c_erfc = c.erfc registerscript("c_erfc", function() return mppair(c_topair(c_erfc (c_new(scanpair())))) end)
-local c_erfcx = c.erfcx registerscript("c_erfcx", function() return mppair(c_topair(c_erfcx (c_new(scanpair())))) end)
-local c_erfi = c.erfi registerscript("c_erfi", function() return mppair(c_topair(c_erfi (c_new(scanpair())))) end)
-local c_dawson = c.dawson registerscript("c_dawson", function() return mppair(c_topair(c_dawson(c_new(scanpair())))) end)
-
-local c_voigt = c.voigt
-local c_voigt_hwhm = c.voigt_hwhm
-
-registerscript("c_voigt", function()
- return mppair(c_topair(c_voigt(c_new(scanpair()),c_new(scanpair()),c_new(scanpair()))))
-end)
-
-registerscript("c_voigt_hwhm", function()
- return mppair(c_topair(c_voigt_hwhm(c_new(scanpair()),c_new(scanpair()))))
-end)
-
-local c_pow = c.pow registerscript("c_pow", function() return mppair(c_topair(c_pow(c_new(scanpair()),c_new(scanpair())))) end)
-local c_add = c.add registerscript("c_add", function() return mppair(c_topair(c_add(c_new(scanpair()),c_new(scanpair())))) end)
-local c_sub = c.sub registerscript("c_sub", function() return mppair(c_topair(c_sub(c_new(scanpair()),c_new(scanpair())))) end)
-local c_mul = c.mul registerscript("c_mul", function() return mppair(c_topair(c_mul(c_new(scanpair()),c_new(scanpair())))) end)
-local c_div = c.div registerscript("c_div", function() return mppair(c_topair(c_div(c_new(scanpair()),c_new(scanpair())))) end)
-
-local c_imag = c.imag registerscript("c_imag", function() return c_topair(c_imag(c_new(scanpair()))) end)
-local c_real = c.real registerscript("c_real", function() return c_topair(c_real(c_new(scanpair()))) end)
-local c_neg = c.neg registerscript("c_new", function() return c_topair(c_neg (c_new(scanpair()))) end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-mpf.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-mpf.lua
new file mode 100644
index 00000000000..7452c011187
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-mpf.lua
@@ -0,0 +1,1244 @@
+if not modules then modules = { } end modules ['mlib-mpf'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- moved from mlib-lua:
+
+local type, tostring, tonumber, select, loadstring = type, tostring, tonumber, select, loadstring
+local find, match, gsub, gmatch = string.find, string.match, string.gsub, string.gmatch
+local concat = table.concat
+
+local formatters = string.formatters
+local lpegmatch = lpeg.match
+local lpegpatterns = lpeg.patterns
+
+local P, S, Ct, Cs, Cc, C = lpeg.P, lpeg.S, lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.C
+
+local report_luarun = logs.reporter("metapost","lua")
+local report_script = logs.reporter("metapost","script")
+local report_message = logs.reporter("metapost")
+
+local trace_luarun = false trackers.register("metapost.lua",function(v) trace_luarun = v end)
+
+local be_tolerant = true directives.register("metapost.lua.tolerant", function(v) be_tolerant = v end)
+
+local set = mp.set
+local get = mp.get
+local aux = mp.aux
+local scan = mp.scan
+local inject = mp.inject
+
+do
+
+ -- serializers
+
+ local f_integer = formatters["%i"]
+ local f_numeric = formatters["%F"]
+
+ -- no %n as that can produce -e notation and that is not so nice for scaled butmaybe we
+ -- should then switch between ... i.e. make a push/pop for the formatters here ... not now.
+
+ local f_integer = formatters["%i"]
+ local f_numeric = formatters["%F"]
+ local f_pair = formatters["(%F,%F)"]
+ local f_ctrl = formatters["(%F,%F) .. controls (%F,%F) and (%F,%F)"]
+ local f_triplet = formatters["(%F,%F,%F)"]
+ local f_quadruple = formatters["(%F,%F,%F,%F)"]
+ local f_transform = formatters["totransform(%F,%F,%F,%F,%F,%F)"]
+ local f_pen = formatters["(pencircle transformed totransform(%F,%F,%F,%F,%F,%F))"]
+
+ local f_points = formatters["%p"]
+ local f_pair_pt = formatters["(%p,%p)"]
+ local f_ctrl_pt = formatters["(%p,%p) .. controls (%p,%p) and (%p,%p)"]
+ local f_triplet_pt = formatters["(%p,%p,%p)"]
+ local f_quadruple_pt = formatters["(%p,%p,%p,%p)"]
+
+ local r = P('%') / "percent"
+ + P('"') / "dquote"
+ + P('\n') / "crlf"
+ -- + P(' ') / "space"
+ local a = Cc("&")
+ local q = Cc('"')
+ local p = Cs(q * (r * a)^-1 * (a * r * (P(-1) + a) + P(1))^0 * q)
+
+ mp.cleaned = function(s) return lpegmatch(p,s) or s end
+
+ -- management
+
+ -- sometimes we gain (e.g. .5 sec on the sync test)
+
+ local cache = table.makeweak()
+
+ local runscripts = { }
+ local runnames = { }
+ local nofscripts = 0
+
+ function metapost.registerscript(name,f)
+ nofscripts = nofscripts + 1
+ if f then
+ runscripts[nofscripts] = f
+ runnames[name] = nofscripts
+ else
+ runscripts[nofscripts] = name
+ end
+ return nofscripts
+ end
+
+ function metapost.scriptindex(name)
+ return runnames[name] or 0
+ end
+
+ -- The gbuffer sharing and such is not really needed now but make a dent when
+ -- we have a high volume of simpel calls (loops) so we keep it around for a
+ -- while.
+
+ local nesting = 0
+ local runs = 0
+ local gbuffer = { }
+ local buffer = gbuffer
+ local n = 0
+
+ local function mpdirect1(a)
+ n = n + 1 buffer[n] = a
+ end
+ local function mpdirect2(a,b)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ end
+ local function mpdirect3(a,b,c)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ end
+ local function mpdirect4(a,b,c,d)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ n = n + 1 buffer[n] = d
+ end
+ local function mpdirect5(a,b,c,d,e)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ n = n + 1 buffer[n] = d
+ n = n + 1 buffer[n] = e
+ end
+
+ local function mpflush(separator)
+ buffer[1] = concat(buffer,separator or "",1,n)
+ n = 1
+ end
+
+ function metapost.runscript(code)
+ nesting = nesting + 1
+ runs = runs + 1
+
+ local index = type(code) == "number"
+ local f
+ local result
+
+ if index then
+ f = runscripts[code]
+ if not f then
+ report_luarun("%i: bad index: %s",nesting,code)
+ elseif trace_luarun then
+ report_luarun("%i: index: %i",nesting,code)
+ end
+ else
+ if trace_luarun then
+ report_luarun("%i: code: %s",nesting,code)
+ end
+ f = cache[code]
+ if not f then
+ f = loadstring("return " .. code)
+ if f then
+ cache[code] = f
+ elseif be_tolerant then
+ f = loadstring(code)
+ if f then
+ cache[code] = f
+ end
+ end
+ end
+ end
+
+ -- returning nil is more efficient and a signal not to scan in mp
+
+ if f then
+
+ local lbuffer, ln
+
+ if nesting == 1 then
+ buffer = gbuffer
+ n = 0
+ else
+ lbuffer = buffer
+ ln = n
+ buffer = { }
+ n = 0
+ end
+
+ result = f()
+ if result then
+ local t = type(result)
+ if t == "number" then
+ result = f_numeric(result)
+ elseif t == "table" then
+ result = concat(result) -- no spaces here
+ else
+ result = tostring(result)
+ end
+ if trace_luarun then
+ report_luarun("%i: %s result: %s",nesting,t,result)
+ end
+ elseif n == 0 then
+ -- result = ""
+ result = nil -- no scantokens done then
+ if trace_luarun then
+ report_luarun("%i: no buffered result",nesting)
+ end
+ elseif n == 1 then
+ result = buffer[1]
+ if trace_luarun then
+ report_luarun("%i: 1 buffered result: %s",nesting,result)
+ end
+ else
+ -- the space is why we sometimes have collectors
+ if nesting == 1 then
+ -- if we had no space we could pass result directly in lmtx
+ result = concat(buffer," ",1,n)
+ if n > 500 or #result > 10000 then
+ gbuffer = { } -- newtable(20,0)
+ lbuffer = gbuffer
+ end
+ else
+ -- if we had no space we could pass result directly in lmtx
+ result = concat(buffer," ")
+ end
+ if trace_luarun then
+ report_luarun("%i: %i buffered results: %s",nesting,n,result)
+ end
+ end
+
+ if nesting == 1 then
+ n = 0
+ else
+ buffer = lbuffer
+ n = ln
+ end
+
+ else
+ report_luarun("%i: no result, invalid code: %s",nesting,code)
+ result = ""
+ end
+
+ nesting = nesting - 1
+
+ return result
+ end
+
+ function metapost.nofscriptruns()
+ return runs
+ end
+
+ -- writers
+
+ local function mpp(value)
+ n = n + 1
+ local t = type(value)
+ if t == "number" then
+ buffer[n] = f_numeric(value)
+ elseif t == "string" then
+ buffer[n] = value
+ elseif t == "table" then
+ if #t == 6 then
+ buffer[n] = "totransform(" .. concat(value,",") .. ")"
+ else
+ buffer[n] = "(" .. concat(value,",") .. ")"
+ end
+ else -- boolean or whatever
+ buffer[n] = tostring(value)
+ end
+ end
+
+ local function mpprint(first,second,...)
+ if second == nil then
+ if first ~= nil then
+ mpp(first)
+ end
+ else
+ for i=1,select("#",first,second,...) do
+ local value = (select(i,first,second,...))
+ if value ~= nil then
+ mpp(value)
+ end
+ end
+ end
+ end
+
+ local function mpp(value)
+ n = n + 1
+ local t = type(value)
+ if t == "number" then
+ buffer[n] = f_numeric(value)
+ elseif t == "string" then
+ buffer[n] = lpegmatch(p,value)
+ elseif t == "table" then
+ if #t > 4 then
+ buffer[n] = ""
+ else
+ buffer[n] = "(" .. concat(value,",") .. ")"
+ end
+ else -- boolean or whatever
+ buffer[n] = tostring(value)
+ end
+ end
+
+ local function mpvprint(first,second,...) -- variable print
+ if second == nil then
+ if first ~= nil then
+ mpp(first)
+ end
+ else
+ for i=1,select("#",first,second,...) do
+ local value = (select(i,first,second,...))
+ if value ~= nil then
+ mpp(value)
+ end
+ end
+ end
+ end
+
+ local function mpstring(value)
+ n = n + 1
+ buffer[n] = lpegmatch(p,value)
+ end
+
+ local function mpboolean(b)
+ n = n + 1
+ buffer[n] = b and "true" or "false"
+ end
+
+ local function mpnumeric(f)
+ n = n + 1
+ if not f or f == 0 then
+ buffer[n] = "0"
+ else
+ buffer[n] = f_numeric(f)
+ end
+ end
+
+ local function mpinteger(i)
+ n = n + 1
+ -- buffer[n] = i and f_integer(i) or "0"
+ buffer[n] = i or "0"
+ end
+
+ local function mppoints(i)
+ n = n + 1
+ if not i or i == 0 then
+ buffer[n] = "0pt"
+ else
+ buffer[n] = f_points(i)
+ end
+ end
+
+ local function mppair(x,y)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_pair(x[1],x[2])
+ else
+ buffer[n] = f_pair(x,y)
+ end
+ end
+
+ local function mppairpoints(x,y)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_pair_pt(x[1],x[2])
+ else
+ buffer[n] = f_pair_pt(x,y)
+ end
+ end
+
+ local function mptriplet(x,y,z)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_triplet(x[1],x[2],x[3])
+ else
+ buffer[n] = f_triplet(x,y,z)
+ end
+ end
+
+ local function mptripletpoints(x,y,z)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_triplet_pt(x[1],x[2],x[3])
+ else
+ buffer[n] = f_triplet_pt(x,y,z)
+ end
+ end
+
+ local function mpquadruple(w,x,y,z)
+ n = n + 1
+ if type(w) == "table" then
+ buffer[n] = f_quadruple(w[1],w[2],w[3],w[4])
+ else
+ buffer[n] = f_quadruple(w,x,y,z)
+ end
+ end
+
+ local function mpquadruplepoints(w,x,y,z)
+ n = n + 1
+ if type(w) == "table" then
+ buffer[n] = f_quadruple_pt(w[1],w[2],w[3],w[4])
+ else
+ buffer[n] = f_quadruple_pt(w,x,y,z)
+ end
+ end
+
+ local function mptransform(x,y,xx,xy,yx,yy)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_transform(x[1],x[2],x[3],x[4],x[5],x[6])
+ else
+ buffer[n] = f_transform(x,y,xx,xy,yx,yy)
+ end
+ end
+
+ local function mpcolor(c,m,y,k)
+ n = n + 1
+ if type(c) == "table" then
+ local l = #c
+ if l == 4 then
+ buffer[n] = f_quadruple(c[1],c[2],c[3],c[4])
+ elseif l == 3 then
+ buffer[n] = f_triplet(c[1],c[2],c[3])
+ else
+ buffer[n] = f_numeric(c[1])
+ end
+ else
+ if k then
+ buffer[n] = f_quadruple(c,m,y,k)
+ elseif y then
+ buffer[n] = f_triplet(c,m,y)
+ else
+ buffer[n] = f_numeric(c)
+ end
+ end
+ end
+
+ -- we have three kind of connectors:
+ --
+ -- .. ... -- (true)
+
+ local function mp_path(f2,f6,t,connector,cycle)
+ if type(t) == "table" then
+ local tn = #t
+ if tn == 1 then
+ local t1 = t[1]
+ n = n + 1
+ if t.pen then
+ buffer[n] = f_pen(unpack(t1))
+ else
+ buffer[n] = f2(t1[1],t1[2])
+ end
+ elseif tn > 0 then
+ if connector == true or connector == nil then
+ connector = ".."
+ elseif connector == false then
+ connector = "--"
+ end
+ if cycle == nil then
+ cycle = t.cycle
+ if cycle == nil then
+ cycle = true
+ end
+ end
+ local six = connector == ".." -- otherwise we use whatever gets asked for
+ local controls = connector -- whatever
+ local a = t[1]
+ local b = t[2]
+ n = n + 1
+ buffer[n] = "("
+ n = n + 1
+ if six and #a == 6 and #b == 6 then
+ buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
+ controls = ".."
+ else
+ buffer[n] = f2(a[1],a[2])
+ controls = connector
+ end
+ for i=2,tn-1 do
+ a = b
+ b = t[i+1]
+ n = n + 1
+ buffer[n] = connector
+ n = n + 1
+ if six and #a == 6 and #b == 6 then
+ buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
+ controls = ".."
+ else
+ buffer[n] = f2(a[1],a[2])
+ controls = connector
+ end
+ end
+ n = n + 1
+ buffer[n] = connector
+ a = b
+ b = t[1]
+ n = n + 1
+ if cycle then
+ if six and #a == 6 and #b == 6 then
+ buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
+ controls = ".."
+ else
+ buffer[n] = f2(a[1],a[2])
+ controls = connector
+ end
+ n = n + 1
+ buffer[n] = connector
+ n = n + 1
+ buffer[n] = "cycle"
+ else
+ buffer[n] = f2(a[1],a[2])
+ end
+ n = n + 1
+ buffer[n] = ")"
+ end
+ end
+ end
+
+ local function mppath(...)
+ mp_path(f_pair,f_ctrl,...)
+ end
+
+ local function mppathpoints(...)
+ mp_path(f_pair_pt,f_ctrl_pt,...)
+ end
+
+ local function mpsize(t)
+ n = n + 1
+ buffer[n] = type(t) == "table" and f_numeric(#t) or "0"
+ end
+
+ local replacer = lpeg.replacer("@","%%")
+
+ local function mpfprint(fmt,...)
+ n = n + 1
+ if not find(fmt,"%",1,true) then
+ fmt = lpegmatch(replacer,fmt)
+ end
+ buffer[n] = formatters[fmt](...)
+ end
+
+ local function mpquoted(fmt,s,...)
+ if s then
+ n = n + 1
+ if not find(fmt,"%",1,true) then
+ fmt = lpegmatch(replacer,fmt)
+ end
+ -- buffer[n] = '"' .. formatters[fmt](s,...) .. '"'
+ buffer[n] = lpegmatch(p,formatters[fmt](s,...))
+ elseif fmt then
+ n = n + 1
+ -- buffer[n] = '"' .. fmt .. '"'
+ buffer[n] = lpegmatch(p,fmt)
+ else
+ -- something is wrong
+ end
+ end
+
+ aux.direct = mpdirect1
+ aux.direct1 = mpdirect1
+ aux.direct2 = mpdirect2
+ aux.direct3 = mpdirect3
+ aux.direct4 = mpdirect4
+ aux.flush = mpflush
+
+ aux.print = mpprint
+ aux.vprint = mpvprint
+ aux.boolean = mpboolean
+ aux.string = mpstring
+ aux.numeric = mpnumeric
+ aux.number = mpnumeric
+ aux.integer = mpinteger
+ aux.points = mppoints
+ aux.pair = mppair
+ aux.pairpoints = mppairpoints
+ aux.triplet = mptriplet
+ aux.tripletpoints = mptripletpoints
+ aux.quadruple = mpquadruple
+ aux.quadruplepoints = mpquadruplepoints
+ aux.path = mppath
+ aux.pathpoints = mppathpoints
+ aux.size = mpsize
+ aux.fprint = mpfprint
+ aux.quoted = mpquoted
+ aux.transform = mptransform
+ aux.color = mpcolor
+
+ -- for the moment
+
+ local function mpdraw(lines,list) -- n * 4
+ if list then
+ local c = #lines
+ for i=1,c do
+ local ci = lines[i]
+ local ni = #ci
+ n = n + 1 buffer[n] = i < c and "d(" or "D("
+ for j=1,ni,2 do
+ local l = j + 1
+ n = n + 1 buffer[n] = ci[j]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = ci[l]
+ n = n + 1 buffer[n] = l < ni and ")--(" or ");"
+ end
+ end
+ else
+ local l = #lines
+ local m = l - 4
+ for i=1,l,4 do
+ n = n + 1 buffer[n] = i < m and "d(" or "D("
+ n = n + 1 buffer[n] = lines[i]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+1]
+ n = n + 1 buffer[n] = ")--("
+ n = n + 1 buffer[n] = lines[i+2]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+3]
+ n = n + 1 buffer[n] = ");"
+ end
+ end
+ end
+
+ local function mpfill(lines,list)
+ if list then
+ local c = #lines
+ for i=1,c do
+ local ci = lines[i]
+ local ni = #ci
+ n = n + 1 buffer[n] = i < c and "f(" or "F("
+ for j=1,ni,2 do
+ local l = j + 1
+ n = n + 1 buffer[n] = ci[j]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = ci[l]
+ n = n + 1 buffer[n] = l < ni and ")--(" or ")--C;"
+ end
+ end
+ else
+ local l = #lines
+ local m = l - 4
+ for i=1,l,4 do
+ n = n + 1 buffer[n] = i < m and "f(" or "F("
+ n = n + 1 buffer[n] = lines[i]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+1]
+ n = n + 1 buffer[n] = ")--("
+ n = n + 1 buffer[n] = lines[i+2]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+3]
+ n = n + 1 buffer[n] = ")--C;"
+ end
+ end
+ end
+
+ aux.draw = mpdraw
+ aux.fill = mpfill
+
+ for k, v in next, aux do mp[k] = v end
+
+end
+
+do
+
+ -- Another experimental feature:
+
+ local mpnumeric = mp.numeric
+ local scanstring = scan.string
+ local scriptindex = metapost.scriptindex
+
+ function mp.mf_script_index(name)
+ local index = scriptindex(name)
+ -- report_script("method %i, name %a, index %i",1,name,index)
+ mpnumeric(index)
+ end
+
+ -- once bootstrapped ... (needs pushed mpx instances)
+
+ metapost.registerscript("scriptindex",function()
+ local name = scanstring()
+ local index = scriptindex(name)
+ -- report_script("method %i, name %a, index %i",2,name,index)
+ mpnumeric(index)
+ end)
+
+end
+
+-- the next will move to mlib-lmp.lua
+
+do
+
+ local mpnamedcolor = attributes.colors.mpnamedcolor
+ local mpprint = aux.print
+ local scanstring = scan.string
+
+ mp.mf_named_color = function(str)
+ mpprint(mpnamedcolor(str))
+ end
+
+ -- todo: we can inject but currently we always get a string back so then
+ -- we need to deal with it upstream in the color module ... not now
+
+ metapost.registerscript("namedcolor",function()
+ mpprint(mpnamedcolor(scanstring()))
+ end)
+
+end
+
+function mp.n(t) -- used ?
+ return type(t) == "table" and #t or 0
+end
+
+do
+
+ -- experiment: names can change
+
+ local mppath = aux.path
+ local mpsize = aux.size
+
+ local whitespace = lpegpatterns.whitespace
+ local newline = lpegpatterns.newline
+ local setsep = newline^2
+ local comment = (S("#%") + P("--")) * (1-newline)^0 * (whitespace - setsep)^0
+ local value = (1-whitespace)^1 / tonumber
+ local entry = Ct( value * whitespace * value)
+ local set = Ct((entry * (whitespace-setsep)^0 * comment^0)^1)
+ local series = Ct((set * whitespace^0)^1)
+
+ local pattern = whitespace^0 * series
+
+ local datasets = { }
+ mp.datasets = datasets
+
+ function mp.dataset(str)
+ return lpegmatch(pattern,str)
+ end
+
+ function datasets.load(tag,filename)
+ if not filename then
+ tag, filename = file.basename(tag), tag
+ end
+ local data = lpegmatch(pattern,io.loaddata(filename) or "")
+ datasets[tag] = {
+ data = data,
+ line = function(n) mppath(data[n or 1]) end,
+ size = function() mpsize(data) end,
+ }
+ end
+
+ table.setmetatablecall(datasets,function(t,k,f,...)
+ local d = datasets[k]
+ local t = type(d)
+ if t == "table" then
+ d = d[f]
+ if type(d) == "function" then
+ d(...)
+ else
+ mpvprint(...)
+ end
+ elseif t == "function" then
+ d(f,...)
+ end
+ end)
+
+end
+
+-- \startluacode
+-- local str = [[
+-- 10 20 20 20
+-- 30 40 40 60
+-- 50 10
+--
+-- 10 10 20 30
+-- 30 50 40 50
+-- 50 20 -- the last one
+--
+-- 10 20 % comment
+-- 20 10
+-- 30 40 # comment
+-- 40 20
+-- 50 10
+-- ]]
+--
+-- MP.myset = mp.dataset(str)
+--
+-- inspect(MP.myset)
+-- \stopluacode
+--
+-- \startMPpage
+-- color c[] ; c[1] := red ; c[2] := green ; c[3] := blue ;
+-- for i=1 upto lua("mp.print(mp.n(MP.myset))") :
+-- draw lua("mp.path(MP.myset[" & decimal i & "])") withcolor c[i] ;
+-- endfor ;
+-- \stopMPpage
+
+-- texts:
+
+do
+
+ local mptriplet = mp.triplet
+
+ local bpfactor = number.dimenfactors.bp
+ local textexts = nil
+ local mptriplet = mp.triplet
+ local nbdimensions = nodes.boxes.dimensions
+
+ function mp.mf_tt_initialize(tt)
+ textexts = tt
+ end
+
+ function mp.mf_tt_dimensions(n)
+ local box = textexts and textexts[n]
+ if box then
+ -- could be made faster with nuts but not critical
+ mptriplet(box.width*bpfactor,box.height*bpfactor,box.depth*bpfactor)
+ else
+ mptriplet(0,0,0)
+ end
+ end
+
+ function mp.mf_tb_dimensions(category,name)
+ local w, h, d = nbdimensions(category,name)
+ mptriplet(w*bpfactor,h*bpfactor,d*bpfactor)
+ end
+
+ function mp.report(a,b,c,...)
+ if c then
+ report_message("%s : %s",a,formatters[(gsub(b,"@","%%"))](c,...))
+ elseif b then
+ report_message("%s : %s",a,b)
+ elseif a then
+ report_message("%s : %s","message",a)
+ end
+ end
+
+end
+
+do
+
+ local mpprint = aux.print
+ local modes = tex.modes
+ local systemmodes = tex.systemmodes
+
+ function mp.mode(s)
+ mpprint(modes[s] and true or false)
+ end
+
+ function mp.systemmode(s)
+ mpprint(systemmodes[s] and true or false)
+ end
+
+ mp.processingmode = mp.mode
+
+end
+
+-- for alan's nodes:
+
+do
+
+ local mpprint = aux.print
+ local mpquoted = aux.quoted
+
+ function mp.isarray(str)
+ mpprint(find(str,"%d") and true or false)
+ end
+
+ function mp.prefix(str)
+ mpquoted(match(str,"^(.-)[%d%[]") or str)
+ end
+
+ -- function mp.dimension(str)
+ -- local n = 0
+ -- for s in gmatch(str,"%[?%-?%d+%]?") do --todo: lpeg
+ -- n = n + 1
+ -- end
+ -- mpprint(n)
+ -- end
+
+ mp.dimension = lpeg.counter(P("[") * lpegpatterns.integer * P("]") + lpegpatterns.integer,mpprint)
+
+ -- faster and okay as we don't have many variables but probably only
+ -- basename makes sense and even then it's not called that often
+
+ -- local hash = table.setmetatableindex(function(t,k)
+ -- local v = find(k,"%d") and true or false
+ -- t[k] = v
+ -- return v
+ -- end)
+ --
+ -- function mp.isarray(str)
+ -- mpprint(hash[str])
+ -- end
+ --
+ -- local hash = table.setmetatableindex(function(t,k)
+ -- local v = '"' .. (match(k,"^(.-)%d") or k) .. '"'
+ -- t[k] = v
+ -- return v
+ -- end)
+ --
+ -- function mp.prefix(str)
+ -- mpprint(hash[str])
+ -- end
+
+end
+
+do
+
+ local getmacro = tokens.getters.macro
+ local setmacro = tokens.setters.macro
+
+ local getdimen = tex.getdimen
+ local getcount = tex.getcount
+ local gettoks = tex.gettoks
+ local setdimen = tex.setdimen
+ local setcount = tex.setcount
+ local settoks = tex.settoks
+
+ local mpprint = mp.print
+ local mpquoted = mp.quoted
+
+ local bpfactor = number.dimenfactors.bp
+
+ -- more helpers
+
+ function mp.getmacro(k) mpquoted(getmacro(k)) end
+ function mp.getdimen(k) mpprint (getdimen(k)*bpfactor) end
+ function mp.getcount(k) mpprint (getcount(k)) end
+ function mp.gettoks (k) mpquoted(gettoks (k)) end
+
+ function mp.setmacro(k,v) setmacro(k,v) end
+ function mp.setdimen(k,v) setdimen(k,v/bpfactor) end
+ function mp.setcount(k,v) setcount(k,v) end
+ function mp.settoks (k,v) settoks (k,v) end
+
+ function mp.setglobalmacro(k,v) setmacro(k,v,"global") end
+ function mp.setglobaldimen(k,v) setdimen("global",k,v/bpfactor) end
+ function mp.setglobalcount(k,v) setcount("global",k,v) end
+ function mp.setglobaltoks (k,v) settoks ("global",k,v) end
+
+ -- def foo = lua.mp.foo ... enddef ; % loops due to foo in suffix
+
+ mp._get_macro_ = mp.getmacro
+ mp._get_dimen_ = mp.getdimen
+ mp._get_count_ = mp.getcount
+ mp._get_toks_ = mp.gettoks
+
+ mp._set_macro_ = mp.setmacro
+ mp._set_dimen_ = mp.setdimen
+ mp._set_count_ = mp.setcount
+ mp._set_toks_ = mp.settoks
+
+ mp._set_global_macro_ = mp.setglobalmacro
+ mp._set_global_dimen_ = mp.setglobaldimen
+ mp._set_global_count_ = mp.setglobalcount
+ mp._set_global_toks_ = mp.setglobaltoks
+
+end
+
+-- position fun
+
+do
+
+ local mpprint = mp.print
+ local mpfprint = mp.fprint
+ local mpquoted = mp.quoted
+ local jobpositions = job.positions
+ local getwhd = jobpositions.whd
+ local getxy = jobpositions.xy
+ local getposition = jobpositions.position
+ local getpage = jobpositions.page
+ local getregion = jobpositions.region
+ local getmacro = tokens.getters.macro
+
+ function mp.positionpath(name)
+ local w, h, d = getwhd(name)
+ if w then
+ mpfprint("((%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle)",0,-d,w,-d,w,h,0,h)
+ else
+ mpprint("(origin--cycle)")
+ end
+ end
+
+ function mp.positioncurve(name)
+ local w, h, d = getwhd(name)
+ if w then
+ mpfprint("((%p,%p)..(%p,%p)..(%p,%p)..(%p,%p)..cycle)",0,-d,w,-d,w,h,0,h)
+ else
+ mpprint("(origin--cycle)")
+ end
+ end
+
+ function mp.positionbox(name)
+ local p, x, y, w, h, d = getposition(name)
+ if p then
+ mpfprint("((%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle)",x,y-d,x+w,y-d,x+w,y+h,x,y+h)
+ else
+ mpprint("(%p,%p)",x,y)
+ end
+ end
+
+ function mp.positionxy(name)
+ local x, y = getxy(name)
+ if x then
+ mpfprint("(%p,%p)",x,y)
+ else
+ mpprint("origin")
+ end
+ end
+
+ function mp.positionpage(name)
+ mpfprint("%i",getpage(name) or 0)
+ end
+
+ function mp.positionregion(name)
+ local r = getregion(name)
+ if r then
+ mpquoted(r)
+ else
+ mpquoted("unknown")
+ end
+ end
+
+ function mp.positionwhd(name)
+ local w, h, d = getwhd(name)
+ if w then
+ mpfprint("(%p,%p,%p)",w,h,d)
+ else
+ mpprint("(0,0,0)")
+ end
+ end
+
+ function mp.positionpxy(name)
+ local p, x, y = getposition(name)
+ if p then
+ mpfprint("(%p,%p,%p)",p,x,y)
+ else
+ mpprint("(0,0,0)")
+ end
+ end
+
+ function mp.positionanchor()
+ mpquoted(getmacro("MPanchorid"))
+ end
+
+end
+
+do
+
+ local mppair = mp.pair
+
+ function mp.textextanchor(s)
+ local x, y = match(s,"tx_anchor=(%S+) (%S+)") -- todo: make an lpeg
+ if x and y then
+ x = tonumber(x)
+ y = tonumber(y)
+ end
+ mppair(x or 0,y or 0)
+ end
+
+end
+
+do
+
+ local mpprint = mp.print
+ local mpquoted = mp.quoted
+ local getmacro = tokens.getters.macro
+
+ function mp.texvar(name)
+ mpprint(getmacro(metapost.namespace .. name))
+ end
+
+ function mp.texstr(name)
+ mpquoted(getmacro(metapost.namespace .. name))
+ end
+
+end
+
+do
+
+ local mpprint = aux.print
+ local mpvprint = aux.vprint
+
+ local hashes = { }
+
+ function mp.newhash(name)
+ if name then
+ hashes[name] = { }
+ else
+ for i=1,#hashes+1 do
+ if not hashes[i] then
+ hashes[i] = { }
+ mpvprint(i)
+ return
+ end
+ end
+ end
+ end
+
+ function mp.disposehash(n)
+ if tonumber(n) then
+ hashes[n] = false
+ else
+ hashes[n] = nil
+ end
+ end
+
+ function mp.inhash(n,key)
+ local h = hashes[n]
+ mpvprint(h and h[key] and true or false)
+ end
+
+ function mp.tohash(n,key,value)
+ local h = hashes[n]
+ if h then
+ if value == nil then
+ h[key] = true
+ else
+ h[key] = value
+ end
+ end
+ end
+
+ function mp.fromhash(n,key)
+ local h = hashes[n]
+ mpvprint(h and h[key] or false)
+ end
+
+ interfaces.implement {
+ name = "MPfromhash",
+ arguments = "2 strings",
+ actions = function(name,key)
+ local h = hashes[name] or hashes[tonumber(name)]
+ if h then
+ local v = h[key] or h[tonumber(key)]
+ if v then
+ context(v)
+ end
+ end
+ end
+ }
+
+end
+
+do
+
+ -- a bit overkill: just a find(str,"mf_object=") can be enough
+ --
+ -- todo : share with mlib-pps.lua metapost,isobject
+
+ local mpboolean = aux.boolean
+
+ local p1 = P("mf_object=")
+ local p2 = lpegpatterns.eol * p1
+ local pattern = (1-p2)^0 * p2 + p1
+
+ function mp.isobject(str)
+ mpboolean(pattern and str ~= "" and lpegmatch(pattern,str))
+ end
+
+end
+
+function mp.flatten(t)
+ local tn = #t
+
+ local t1 = t[1]
+ local t2 = t[2]
+ local t3 = t[3]
+ local t4 = t[4]
+
+ for i=1,tn-5,2 do
+ local t5 = t[i+4]
+ local t6 = t[i+5]
+ if t1 == t3 and t3 == t5 and ((t2 <= t4 and t4 <= t6) or (t6 <= t4 and t4 <= t2)) then
+ t[i+3] = t2
+ t4 = t2
+ t[i] = false
+ t[i+1] = false
+ elseif t2 == t4 and t4 == t6 and ((t1 <= t3 and t3 <= t5) or (t5 <= t3 and t3 <= t1)) then
+ t[i+2] = t1
+ t3 = t1
+ t[i] = false
+ t[i+1] = false
+ end
+ t1 = t3
+ t2 = t4
+ t3 = t5
+ t4 = t6
+ end
+
+ -- remove duplicates
+
+ local t1 = t[1]
+ local t2 = t[2]
+ for i=1,tn-2,2 do
+ local t3 = t[i+2]
+ local t4 = t[i+3]
+ if t1 == t3 and t2 == t4 then
+ t[i] = false
+ t[i+1] = false
+ end
+ t1 = t3
+ t2 = t4
+ end
+
+ -- move coordinates
+
+ local m = 0
+ for i=1,tn,2 do
+ if t[i] then
+ m = m + 1 t[m] = t[i]
+ m = m + 1 t[m] = t[i+1]
+ end
+ end
+
+ -- prune the table (not gc'd)
+
+ for i=tn,m+1,-1 do
+ t[i] = nil
+ end
+
+ -- safeguard so that we have at least one segment
+
+ if m == 2 then
+ t[3] = t[1]
+ t[4] = t[2]
+ end
+
+end
+
+do
+
+ -- if needed we can optimize the sub (cache last split)
+
+ local mpnumeric = mp.numeric
+ local mpquoted = mp.quoted
+
+ local utflen = utf.len
+ local utfsub = utf.sub
+
+ function mp.utflen(s)
+ mpnumeric(utflen(s))
+ end
+
+ function mp.utfsub(s,f,t)
+ mpquoted(utfsub(s,f,t))
+ end
+
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.lua
index 372a77f4181..e737b5d8688 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.lua
@@ -27,7 +27,7 @@ local copy_node = node.copy
local write_node = node.write
local pen_info = mplib.pen_info
-local object_fields = mplib.fields
+local getfields = mplib.getfields or mplib.fields -- todo: in lmtx get them once and then use gettype
local save_table = false
local force_stroke = false
@@ -363,18 +363,20 @@ end
local stack = { }
local function pushproperties(figure)
+ -- maybe there will be getters in lmtx
local boundingbox = figure:boundingbox()
+ local slot = figure:charcode() or 0
local properties = {
llx = boundingbox[1],
lly = boundingbox[2],
urx = boundingbox[3],
ury = boundingbox[4],
- slot = figure:charcode(),
+ slot = slot,
width = figure:width(),
height = figure:height(),
depth = figure:depth(),
- italic = figure:italcorr(),
- number = figure:charcode() or 0,
+ italic = figure:italcorr(), -- figure:italic() in lmtx
+ number = slot,
}
insert(stack,properties)
metapost.properties = properties
@@ -460,7 +462,7 @@ function metapost.flush(specification,result)
result[#result+1] = evenodd and "W* n" or "W n"
elseif objecttype == "stop_clip" then
result[#result+1] = "Q"
- miterlimit, linecap, linejoin, dashed = -1, -1, -1, "" -- was false
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
-- skip
elseif objecttype == "start_group" then
@@ -475,7 +477,7 @@ function metapost.flush(specification,result)
bbox = toboundingbox(object.path),
})
result = { }
-miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
else
insert(groupstack,false)
end
@@ -490,7 +492,7 @@ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
result[#result+1] = reference
result = pluginactions(data.after,result,flushfigure)
result[#result+1] = "Q"
-miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
end
else
-- we use an indirect table as we want to overload
@@ -744,9 +746,9 @@ function metapost.totable(result,askedfig)
for o=1,#objects do
local object = objects[o]
local result = { }
- local fields = object_fields(object) -- hm, is this the whole list, if so, we can get it once
+ local fields = getfields(object) -- hm, is this the whole list, if so, we can get it once
for f=1,#fields do
- local field = fields[f]
+ local field = fields[f]
result[field] = object[field]
end
results[o] = result
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.mkxl b/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.mkxl
deleted file mode 100644
index 763e7ecdd46..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-pdf.mkxl
+++ /dev/null
@@ -1,171 +0,0 @@
-%D \module
-%D [ file=mlib-pdf,
-%D version=2008.03.25,
-%D title=\METAPOST\ Integrated Graphics,
-%D subtitle=Conversion to PDF,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\unprotect
-
-%D We use bit more code that needed because we want to limit the amount of boxing.
-
-\registerctxluafile{mlib-pdf}{}
-
-%D Some code is shared between MPLIB and MPS. The following variables are also
-%D available for introspection and other purposes.
-
-\ifdefined\MPwidth \else \newdimen\MPwidth \fi
-\ifdefined\MPheight \else \newdimen\MPheight \fi
-
-\ifdefined\MPllx \else \newdimen\MPllx \fi
-\ifdefined\MPlly \else \newdimen\MPlly \fi
-\ifdefined\MPurx \else \newdimen\MPurx \fi
-\ifdefined\MPury \else \newdimen\MPury \fi
-
-\ifdefined\MPbox \else \newbox \MPbox \fi
-
-\unexpanded\def\setMPboundingbox#1#2#3#4% at some point we might pass them as base or scaled points
- {\global\MPllx #1\onebasepoint
- \global\MPlly #2\onebasepoint
- \global\MPurx #3\onebasepoint
- \global\MPury #4\onebasepoint
- \global\MPwidth \dimexpr\MPurx-\MPllx\relax
- \global\MPheight\dimexpr\MPury-\MPlly\relax}
-
-\unexpanded\def\resetMPboundingbox
- {\global\MPwidth \zeropoint
- \global\MPheight\zeropoint
- \global\MPllx \zeropoint
- \global\MPlly \zeropoint
- \global\MPurx \zeropoint
- \global\MPury \zeropoint}
-
-\let\popMPboundingbox\relax
-
-\unexpanded\def\pushMPboundingbox
- {\edef\popMPboundingbox
- {\global\MPwidth \the\MPwidth
- \global\MPheight\the\MPheight
- \global\MPllx \the\MPllx
- \global\MPlly \the\MPlly
- \global\MPurx \the\MPurx
- \global\MPury \the\MPury
- \relax}}
-
-% we need to combine these
-
-\unexpanded\def\repositionMPboxindeed
- {\setbox\MPbox\hpack\bgroup
- \kern-\MPllx
- \raise-\MPlly
- \box\MPbox
- \egroup}
-
-\unexpanded\def\repositionMPbox
- {\ifzeropt\MPllx
- \ifzeropt\MPlly
- % okay
- \else
- \repositionMPboxindeed
- \fi
- \else
- \repositionMPboxindeed
- \fi}
-
-\unexpanded\def\finalizeMPbox
- {\repositionMPbox
- \setbox\MPbox\vpack to \MPheight\bgroup
- \vfill
- \hsize\MPwidth
- \smashbox\MPbox
- \box\MPbox
- \egroup
- \wd\MPbox\MPwidth
- \ht\MPbox\MPheight}
-
-% combined
-
-\unexpanded\def\finalizeMPbox
- {\boxxoffset\MPbox-\MPllx\relax
- \boxyoffset\MPbox\dimexpr\boxyoffset\MPbox-\MPheight-\MPlly\relax
- \wd\MPbox\MPwidth
- \ht\MPbox\MPheight}
-
-% MPLIB specific:
-
-\def\MPLIBtoPDF{\clf_mpflushliteral} % expanded
-
-\unexpanded\def\startMPLIBtoPDF#1#2#3#4%
- {\meta_process_graphic_figure_start
- \dostarttagged\t!mpgraphic\empty
- \naturalhpack attr \imageattribute \plusone \bgroup
- \dousecolorparameter\s!black\forcecolorhack
- \setMPboundingbox{#1}{#2}{#3}{#4}%
- \setbox\MPbox\vpack\bgroup
- % \forgetall % already done elsewhere
- \noindent} % forces the proper cm in the backend
-
-\unexpanded\def\stopMPLIBtoPDF
- {\egroup
- \finalizeMPbox
- \box\MPbox
- \egroup
- \dostoptagged
- \meta_process_graphic_figure_stop}
-
-\def\MPLIBflushreset % This can (will) move to the Lua end.
- {\clf_mpflushreset}
-
-%D Kind of special:
-%
-% test.mp:
-%
-% beginfig(1) fill fullcircle scaled 10cm withcolor red ; endfig ;
-% beginfig(2) draw fullcircle scaled 5cm withcolor blue ; endfig ;
-% beginfig(3) draw textext("just some text") ; endfig ;
-%
-% standalone pages:
-%
-% \starttext
-% \directMPgraphic{input "test.mp" ;}
-% \stoptext
-
-\let\normalstartMPLIBtoPDF\startMPLIBtoPDF
-\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF
-
-\unexpanded\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF}
-\unexpanded\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage}
-
-\unexpanded\def\directMPgraphic
- {\dodoublegroupempty\mlib_direct_graphic}
-
-\def\mlib_direct_graphic#1#2% makes pages (todo: make boxes)
- {\meta_begin_graphic_group{#1}%
- \let\startMPLIBtoPDF\directstartMPLIBtoPDF
- \let\stopMPLIBtoPDF \directstopMPLIBtoPDF
- \meta_start_current_graphic
- \forgetall
- \edef\p_extensions{\MPinstanceparameter\s!extensions}%
- \normalexpanded{\noexpand\clf_mpgraphic
- instance {\currentMPinstance}%
- format {\currentMPformat}%
- data {#2;}%
- initializations {\meta_flush_current_initializations}%
- \ifx\p_extensions\v!yes
- extensions {\clf_getmpextensions{\currentMPinstance}}%
- \fi
- inclusions {\meta_flush_current_inclusions}%
- definitions {\meta_flush_current_definitions}%
- figure {all}%
- method {\MPinstanceparameter\c!method}%
- \relax}%
- \meta_stop_current_graphic
- \meta_end_graphic_group}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.lua
index 0250df35c60..8a6f4b4f825 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.lua
@@ -25,6 +25,7 @@ local setmacro = interfaces.setmacro
local texsetbox = tex.setbox
local textakebox = tex.takebox -- or: nodes.takebox
+local texrunlocal = tex.runlocal
local copy_list = node.copy_list
local flush_list = node.flush_list
local setmetatableindex = table.setmetatableindex
@@ -250,6 +251,7 @@ local function startjob(plugmode,kind,mpx)
top = {
textexts = { }, -- all boxes, optionally with a different color
texstrings = { },
+ texregimes = { },
mapstrings = { },
mapindices = { },
mapmoves = { },
@@ -499,8 +501,8 @@ implement {
arguments = { "dimen", "dimen", "dimen" },
actions = function(wd,ht,dp)
local hd = ht + dp
- setmacro("sx",wd ~= 0 and factor/wd or 0)
- setmacro("sy",hd ~= 0 and factor/hd or 0)
+ setmacro("mlib_sx",wd ~= 0 and factor/wd or 0)
+ setmacro("mlib_sy",hd ~= 0 and factor/hd or 0)
end
}
@@ -811,7 +813,13 @@ local tx_reset, tx_process do
local mp_t = nil
local function processtext()
- local mp_text = top.texstrings[mp_index]
+ local mp_text = top.texstrings[mp_index]
+ local mp_regime = top.texregimes[mp_index]
+ if mp_regime and tonumber(mp_regime) >= 0 then
+ mp_text = function()
+ context.sprint(mp_regime,top.texstrings[mp_index] or "")
+ end
+ end
if not mp_text then
report_textexts("missing text for index %a",mp_index)
elseif not mp_c then
@@ -842,14 +850,15 @@ local tx_reset, tx_process do
local madetext = nil
- function mp.mf_some_text(index,str)
+ function mp.mf_some_text(index,str,regime)
mp_target = index
mp_index = index
mp_c = nil
mp_a = nil
mp_t = nil
top.texstrings[mp_index] = str
- tex.runtoks("mptexttoks")
+ top.texregimes[mp_index] = regime or -1
+ texrunlocal("mptexttoks")
local box = textakebox("mptextbox")
top.textexts[mp_target] = box
mp.triplet(bp*box.width,bp*box.height,bp*box.depth)
@@ -857,7 +866,7 @@ local tx_reset, tx_process do
end
function mp.mf_made_text(index)
- mp.mf_some_text(index,madetext)
+ mp.mf_some_text(index,madetext,catcodes.numbers.ctxcatcodes) -- btex/etex ..
end
-- a label can be anything, also something mp doesn't like in strings
@@ -899,7 +908,7 @@ local tx_reset, tx_process do
mp.triplet(top.mapmoves[index])
end
- function mp.mf_map_text(index,str)
+ function mp.mf_map_text(index,str,regime)
local map = top.mapindices[tonumber(str)]
if type(map) == "table" then
local text = map.text
@@ -912,14 +921,16 @@ local tx_reset, tx_process do
-- the image text
if overload then
top.texstrings[mp_index] = map.template or map.label or "error"
- tex.runtoks("mptexttoks")
+ top.texregimes[mp_index] = regime or -1
+ texrunlocal("mptexttoks")
local box = textakebox("mptextbox") or new_hlist()
width = bp * box.width
where = overload.where
end
-- the real text
top.texstrings[mp_index] = overload and overload.text or text or "error"
- tex.runtoks("mptexttoks")
+ top.texregimes[mp_index] = regime or -1
+ texrunlocal("mptexttoks")
local box = textakebox("mptextbox") or new_hlist()
local twd = bp * box.width
local tht = bp * box.height
@@ -953,8 +964,8 @@ local tx_reset, tx_process do
-- instance in a macro definition (rawtextext (pass back string)) ... of course one
-- should use textext so this is just a catch. When not in lmtx it's never immediate.
- local reported = false
- local awayswrap = CONTEXTLMTXMODE <= 1
+ local reported = false
+ local alwayswrap = false -- CONTEXTLMTXMODE <= 1 -- was always nil due to typo
function metapost.maketext(s,mode)
if not reported then
@@ -1036,7 +1047,7 @@ local tx_reset, tx_process do
local mp_hash = prescript.tx_cache
local box
if mp_hash == "no" then
- tex.runtoks("mptexttoks")
+ texrunlocal("mptexttoks")
box = textakebox("mptextbox")
else
local cache = data.texhash
@@ -1069,7 +1080,7 @@ local tx_reset, tx_process do
if box then
box = copy_list(box)
else
- tex.runtoks("mptexttoks")
+ texrunlocal("mptexttoks")
box = textakebox("mptextbox")
cache[mp_hash] = box
end
@@ -1152,7 +1163,7 @@ local gt_reset, gt_process do
if not graphics[index] then
mp_index = index
mp_str = str
- tex.runtoks("mpgraphictexttoks")
+ texrunlocal("mpgraphictexttoks")
end
end
@@ -1573,7 +1584,7 @@ local ot_reset, ot_process do
mp_index = index
mp_kind = kind
mp_str = str
- tex.runtoks("mpoutlinetoks")
+ texrunlocal("mpoutlinetoks")
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.mkiv
index 05113058511..74d6ae142d0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-pps.mkiv
@@ -86,7 +86,7 @@
\unexpanded\def\MPLIBfigure#1#2%
{\setbox\scratchbox\hpack{\externalfigure[#1][\c!mask=#2]}%
\clf_mpsetsxsy\wd\scratchbox\ht\scratchbox\zeropoint
- \vpack to \zeropoint{\vss\hpack to \zeropoint{\fastsxsy{\sx}{\sy}{\box\scratchbox}\hss}}}
+ \vpack to \zeropoint{\vss\hpack to \zeropoint{\fastsxsy{\mlib_sx}{\mlib_sy}{\box\scratchbox}\hss}}}
% horrible (we could inline scale and matrix code):
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-run.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-run.lua
index 07fa6a19198..602d6f36c0d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-run.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-run.lua
@@ -34,14 +34,11 @@ local find, striplines = string.find, utilities.strings.striplines
local concat, insert, remove = table.concat, table.insert, table.remove
local emptystring = string.is_empty
-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_terminal = false trackers.register("metapost.terminal", function(v) trace_terminal = v end)
local report_metapost = logs.reporter("metapost")
-local report_terminal = logs.reporter("metapost","terminal")
local texerrormessage = logs.texerrormessage
local starttiming = statistics.starttiming
@@ -60,9 +57,9 @@ metapost.exectime = metapost.exectime or { } -- hack
metapost.nofruns = 0
local mpxformats = { }
-local mpxterminals = { }
local nofformats = 0
local mpxpreambles = { }
+local mpxterminals = { }
local mpxextradata = { }
-- The flatten hack is needed because the library currently barks on \n\n and the
@@ -112,225 +109,6 @@ function metapost.resetlastlog()
metapost.lastlog = ""
end
------ mpbasepath = lpeg.instringchecker(lpeg.append { "/metapost/context/", "/metapost/base/" })
-local mpbasepath = lpeg.instringchecker(P("/metapost/") * (P("context") + P("base")) * P("/"))
-
--- mplib has no real io interface so we have a different mechanism than
--- tex (as soon as we have more control, we will use the normal code)
---
--- for some reason mp sometimes calls this function twice which is inefficient
--- but we cannot catch this
-
-local realtimelogging do
-
- local finders = { }
- mplib.finders = finders -- also used in meta-lua.lua
-
- local new_instance = mplib.new
-
- local function validftype(ftype)
- if ftype == "mp" then
- return "mp"
- else
- return nil
- end
- end
-
- finders.file = function(specification,name,mode,ftype)
- return resolvers.findfile(name,validftype(ftype))
- end
-
- -- this will be redone in lmtx
-
- local function i_finder(name,mode,ftype) -- fake message for mpost.map and metafun.mpvi
- local specification = url.hashed(name)
- local finder = finders[specification.scheme] or finders.file
- local found = finder(specification,name,mode,validftype(ftype))
- return found
- end
-
- local function o_finder(name,mode,ftype)
- return name
- end
-
- o_finder = sandbox.register(o_finder,sandbox.filehandlerone,"mplib output finder")
-
- local function finder(name,mode,ftype)
- return (mode == "w" and o_finder or i_finder)(name,mode,validftype(ftype))
- end
-
- local report_logger = logs.reporter("metapost log")
- local report_error = logs.reporter("metapost error")
-
- local l, nl, dl = { }, 0, false
- local t, nt, dt = { }, 0, false
- local e, ne, de = { }, 0, false
-
- local function logger(target,str)
- if target == 1 then
- -- log
- elseif target == 2 or target == 3 then
- -- term
- if str == "\n" then
- realtimelogging = true
- if nl > 0 then
- report_logger(concat(l,"",1,nl))
- nl, dl = 0, false
- elseif not dl then
- report_logger("")
- dl = true
- end
- else
- nl = nl + 1
- l[nl] = str
- end
- elseif target == 4 then
- report_error(str)
- end
- end
-
- -- experiment, todo: per instance, just a push / pop ?
-
- local findtexfile = resolvers.findtexfile
- local opentexfile = resolvers.opentexfile
- local splitlines = string.splitlines
-
- local function writetoterminal(terminaldata,maxterm,d)
- local t = type(d)
- local n = 0
- if t == "string" then
- d = splitlines(d)
- n = #d
- for i=1,#d do
- maxterm = maxterm + 1
- terminaldata[maxterm] = d[i]
- end
- elseif t == "table" then
- for i=1,#d do
- local l = d[i]
- if find(l,"[\n\r]") then
- local s = splitlines(l)
- local m = #s
- for i=1,m do
- maxterm = maxterm + 1
- terminaldata[maxterm] = s[i]
- end
- n = n + m
- else
- maxterm = maxterm + 1
- terminaldata[maxterm] = d[i]
- n = 1
- end
- end
- end
- if trace_terminal then
- report_metapost("writing %i lines, in cache %s",n,maxterm)
- end
- return maxterm
- end
-
- local function readfromterminal(terminaldata,maxterm,nowterm)
- if nowterm >= maxterm then
- terminaldata[nowterm] = false
- maxterm = 0
- nowterm = 0
- if trace_terminal then
- report_metapost("resetting, maxcache %i",#terminaldata)
- end
- return maxterm, nowterm, nil
- else
- if nowterm > 0 then
- terminaldata[nowterm] = false
- end
- nowterm = nowterm + 1
- local s = terminaldata[nowterm]
- if trace_terminal then
- report_metapost("reading line %i: %s",nowterm,s)
- end
- return maxterm, nowterm, s
- end
- end
-
- local function fileopener()
-
- -- these can go into the table itself
-
- local terminaldata = { }
- local maxterm = 0
- local nowterm = 0
-
- local terminal = {
- name = "terminal",
- close = function()
- -- terminal = { }
- -- maxterm = 0
- -- nowterm = 0
- end,
- reader = function()
- local line
- maxterm, nowterm, line = readfromterminal(terminaldata,maxterm,nowterm)
- return line
- end,
- writer = function(d)
- maxterm = writetoterminal(terminaldata,maxterm,d)
- end,
- }
-
- return function(name,mode,kind)
- if name == "terminal" then
- -- report_metapost("opening terminal")
- return terminal
- elseif mode == "w" then
- local f = io.open(name,"wb")
- if f then
- -- report_metapost("opening file %a for writing",full)
- return {
- name = full,
- writer = function(s) return f:write(s) end, -- io.write(f,s)
- close = function() f:close() end,
- }
- end
- else
- local full = findtexfile(name,validftype(ftype))
- if full then
- -- report_metapost("opening file %a for reading",full)
- return opentexfile(full)
- end
- end
- end
-
- end
-
- -- end of experiment
-
- if CONTEXTLMTXMODE > 0 then
-
- function mplib.new(specification)
- local openfile = fileopener()
- specification.find_file = finder
- specification.run_logger = logger
- specification.open_file = openfile
- specification.interaction = "silent"
- specification.halt_on_error = true
- local instance = new_instance(specification)
- mpxterminals[instance] = openfile("terminal")
- return instance
- end
-
- else
-
- function mplib.new(specification)
- specification.find_file = finder
- specification.run_logger = logger
- return new_instance(specification)
- end
-
- end
-
- mplib.finder = finder
-
-end
-
local new_instance = mplib.new
local find_file = mplib.finder
@@ -340,7 +118,7 @@ function metapost.reporterror(result)
return true
elseif result.status == 0 then
return false
- elseif realtimelogging then
+ elseif mplib.realtimelogging then
return false -- we already reported
else
local t = result.term
@@ -405,7 +183,7 @@ function metapost.load(name,method)
end
end
method = method and methods[method] or "scaled"
- local mpx = new_instance {
+ local mpx, terminal = new_instance {
ini_version = true,
math_mode = method,
run_script = metapost.runscript,
@@ -414,12 +192,14 @@ function metapost.load(name,method)
extensions = 1,
-- random_seed = seed,
utf8_mode = true,
+ text_mode = true,
}
report_metapost("initializing number mode %a",method)
local result
if not mpx then
result = { status = 99, error = "out of memory"}
else
+ mpxterminals[mpx] = terminal
-- pushing permits advanced features
metapost.pushscriptrunner(mpx)
result = executempx(mpx,f_preamble(file.addsuffix(name,"mp"),seed))
@@ -557,17 +337,17 @@ function metapost.reset(mpx)
if mpxformats[mpx] then
local instance = mpxformats[mpx]
instance:finish()
- mpxterminals[instance] = nil
- mpxextradata[mpx] = nil
- mpxformats [mpx] = nil
+ mpxterminals[mpx] = nil
+ mpxextradata[mpx] = nil
+ mpxformats [mpx] = nil
end
else
for name, instance in next, mpxformats do
if instance == mpx then
mpx:finish()
+ mpxterminals[mpx] = nil
mpxextradata[mpx] = nil
mpxformats [mpx] = nil
- mpxterminals[mpx] = nil
break
end
end
@@ -881,20 +661,21 @@ do
end
+local getstatistics = mplib.getstatistics or mplib.statistics
+
function metapost.getstatistics(memonly)
if memonly then
local n, m = 0, 0
for name, mpx in next, mpxformats do
n = n + 1
- m = m + mpx:statistics().memory
+ m = m + getstatistics(mpx).memory
end
return n, m
else
local t = { }
for name, mpx in next, mpxformats do
- t[name] = mpx:statistics()
+ t[name] = getstatistics(mpx)
end
return t
end
end
-
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-scn.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-scn.lua
deleted file mode 100644
index 709961543bf..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-scn.lua
+++ /dev/null
@@ -1,777 +0,0 @@
-if not modules then modules = { } end modules ['mlib-scn'] = {
- version = 1.001,
- comment = "companion to mlib-ctx.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
--- Very experimental, for Alan and me.
-
--- for i = 1 upto 32000 : % 0.062
--- ts := 5mm / 20;
--- endfor ;
---
--- for i = 1 upto 32000 : % 0.219
--- ts := (getparameter "axis" "sy") / 20;
--- endfor ;
---
--- for i = 1 upto 32000 : % 0.266
--- ts := (getparameterx "axis" "sy") / 20;
--- endfor ;
---
--- pushparameters "axis";
--- for i = 1 upto 32000 : % 0.250
--- ts := (getparameterx "sy") / 20;
--- endfor ;
--- popparameters;
-
-local type, next, rawget, getmetatable = type, next, rawget, getmetatable
-local byte, gmatch = string.byte, string.gmatch
-local insert, remove = table.insert, table.remove
-
-local mplib = mplib
-local metapost = metapost
-
-local codes = mplib.codes()
-local types = mplib.types()
-
-table.hashed(codes)
-table.hashed(types)
-
-metapost.codes = codes
-metapost.types = types
-
-local setmetatableindex = table.setmetatableindex
-
-local scanners = mp.scan
-
-local scannext = scanners.next
-local scanexpression = scanners.expression
-local scantoken = scanners.token
-local scansymbol = scanners.symbol
-local scannumeric = scanners.numeric
-local scannumber = scanners.number
-local scaninteger = scanners.integer
-local scanboolean = scanners.boolean
-local scanstring = scanners.string
-local scanpair = scanners.pair
-local scancolor = scanners.color
-local scancmykcolor = scanners.cmykcolor
-local scantransform = scanners.transform
-local scanpath = scanners.path
-local scanpen = scanners.pen
-
-local mpprint = mp.print
-local mpnumeric = mp.numeric
-local mpstring = mp.string
-local mpquoted = mp.quoted
-local mpboolean = mp.boolean
-local mppair = mp.pair
-local mppath = mp.path
-local mptriplet = mp.triplet
-local mpquadruple = mp.quadruple
-local mptransform = mp.transform
-local mpvalue = mp.value
-
-local report = logs.reporter("metapost")
-
-local semicolon_code = codes.semicolon
-local equals_code = codes.equals
-local comma_code = codes.comma
-local colon_code = codes.colon
-local leftbrace_code = codes.leftbrace
-local rightbrace_code = codes.rightbrace
-local leftbracket_code = codes.leftbracket
-local rightbracket_code = codes.rightbracket
-local leftdelimiter_code = codes.leftdelimiter
-local rightdelimiter_code = codes.rightdelimiter
-local numeric_code = codes.numeric
-local string_code = codes.string
-local capsule_code = codes.capsule
-local nullary_code = codes.nullary
-local tag_code = codes.tag
-local definedmacro_code = codes.definedmacro
-
-local typescanners = nil
-local tokenscanners = nil
-local scanset = nil
-local scanparameters = nil
-
-scanset = function() -- can be optimized, we now read twice
- scantoken()
- if scantoken(true) == rightbrace_code then
- scantoken()
- return { }
- else
- local l = { }
- local i = 0
- while true do
- i = i + 1
- local s = scansymbol(true)
- if s == "{" then
- l[i] = scanset()
- elseif s == "[" then
- local d = { }
- scansymbol()
- while true do
- local s = scansymbol()
- if s == "]" then
- break;
- elseif s == "," then
- -- continue
- else
- local t = scantoken(true)
- if t == equals_code or t == colon_code then
- scantoken()
- end
- d[s] = tokenscanners[scantoken(true)]()
- end
- end
- l[i] = d
- else
- local e = scanexpression(true)
- l[i] = (typescanners[e] or scanexpression)()
- end
- if scantoken() == rightbrace_code then
- break
- else
- -- whatever
- end
- end
- return l
- end
-end
-
-local function scan_pair () return scanpair (true) end
-local function scan_color () return scancolor (true) end
-local function scan_cmykcolor() return scancmykcolor(true) end
-local function scan_transform() return scantransform(true) end
-
-tokenscanners = {
- [leftbrace_code] = scanset,
- [numeric_code] = scannumeric,
- [string_code] = scanstring,
- [nullary_code] = scanboolean, -- todo
-}
-
-typescanners = {
- [types.known] = scannumeric,
- [types.numeric] = scannumeric,
- [types.string] = scanstring,
- [types.boolean] = scanboolean,
- [types.pair] = scan_pair,
- [types.color] = scan_color,
- [types.cmykcolor] = scan_cmykcolor,
- [types.transform] = scan_transform,
- [types.path] = scanpath,
- [types.pen] = scanpen,
-}
-
-table.setmetatableindex(tokenscanners,function()
- local e = scanexpression(true)
- return typescanners[e] or scanexpression
-end)
-
--- a key like 'color' has code 'declare'
-
-local function scanparameters(fenced)
- local data = { }
- local close = "]"
- if not fenced then
- close = ";"
- elseif scansymbol(true) == "[" then
- scansymbol()
- else
- return data
- end
- while true do
- -- local s = scansymbol()
- local s = scansymbol(false,false)
- if s == close then
- break;
- elseif s == "," then
- -- continue
- else
- local t = scantoken(true)
- if t == equals_code or t == colon_code then
- -- optional equal or :
- scantoken()
- end
- local kind = scantoken(true)
- if kind == leftdelimiter_code or kind == tag_code or kind == capsule_code then
- kind = scanexpression(true)
- data[s] = (typescanners[kind] or scanexpression)()
- elseif kind == leftbracket_code then
- data[s] = get_parameters(true)
- else
- data[s] = tokenscanners[kind]()
- end
- end
- end
- return data
-end
-
-local namespaces = { }
-local presets = { }
-local passed = { }
-
-local function get_parameters(nested)
- local data = { }
- if nested or scansymbol(true) == "[" then
- scansymbol()
- else
- return data
- end
- while true do
- local s = scansymbol(false,false)
- if s == "]" then
- break;
- elseif s == "," then
- -- continue
- else
- local t = scantoken(true)
- if t == equals_code or t == colon_code then
- -- optional equal or :
- scantoken()
- end
- local kind = scantoken(true)
- if kind == leftdelimiter_code or kind == tag_code or kind == capsule_code then
- kind = scanexpression(true)
- data[s] = (typescanners[kind] or scanexpression)()
- elseif kind == leftbracket_code then
- data[s] = get_parameters(true)
- else
- data[s] = tokenscanners[kind]()
- end
- end
- end
- return data
-end
-
-local function getparameters()
- local namespace = scanstring()
- -- same as below
- local parameters = get_parameters()
- local presets = presets[namespace]
- local passed = passed[namespace]
- if passed then
- if presets then
- setmetatableindex(passed,presets)
- end
- setmetatableindex(parameters,passed)
- elseif presets then
- setmetatableindex(parameters,presets)
- end
- namespaces[namespace] = parameters
- --
-end
-
-local function applyparameters()
- local saved = namespaces
- local namespace = scanstring()
- local action = scanstring() -- before we scan the parameters
- -- same as above
- local parameters = get_parameters()
- local presets = presets[namespace]
- local passed = passed[namespace]
- if passed then
- if presets then
- setmetatableindex(passed,presets)
- end
- setmetatableindex(parameters,passed)
- elseif presets then
- setmetatableindex(parameters,presets)
- end
- namespaces[namespace] = parameters
- -- till here
- mpprint(action)
- namespaces = saved
-end
-
-local function presetparameters()
- local namespace = scanstring()
- local parent = nil
- local t = scantoken(true)
- if t == string_code then
- parent = presets[scanstring()]
- end
- local p = get_parameters()
- if parent then
- setmetatableindex(p,parent)
- end
- presets[namespace] = p
-end
-
-local function collectnames()
- local l = { } -- can be reused but then we can't nest
- local n = 0
- while true do
- local t = scantoken(true)
- -- (1) not really needed
- if t == numeric_code then
- n = n + 1 l[n] = scaninteger(1)
- elseif t == string_code then
- n = n + 1 l[n] = scanstring(1)
- elseif t == nullary_code then
- n = n + 1 l[n] = scanboolean(1)
- elseif t == leftdelimiter_code or t == tag_code or t == capsule_code then
- t = scanexpression(true)
- n = n + 1 l[n] = (typescanners[t] or scanexpression)()
- else
- break
- end
- end
- return l, n
-end
-
-local function get(v)
- local t = type(v)
- if t == "number" then
- return mpnumeric(v)
- elseif t == "boolean" then
- return mpboolean(v)
- elseif t == "string" then
- return mpquoted(v)
- elseif t == "table" then
- local n = #v
- if type(v[1]) == "table" then
- return mppath(v) -- cycle ?
- elseif n == 2 then
- return mppair(v)
- elseif n == 3 then
- return mptriplet(v)
- elseif n == 4 then
- return mpquadruple(v)
- elseif n == 6 then
- return mptransform(v)
- end
- end
- return mpnumeric(0)
-end
-
-local stack = { }
-
-local function pushparameters()
- local l, n = collectnames()
- insert(stack,namespaces)
- for i=1,n do
- local n = namespaces[l[i]]
- if type(n) == "table" then
- namespaces = n
- else
- break
- end
- end
-end
-
-local function popparameters()
- local n = remove(stack)
- if n then
- namespaces = n
- else
- report("stack error")
- end
-end
-
--- todo:
-
-local function getparameter()
- local list, n = collectnames()
- local v = namespaces
- for i=1,n do
- local l = list[i]
- local vl = v[l]
- if vl == nil then
- if type(l) == "number" then
- vl = v[1]
- if vl == nil then
- return mpnumeric(0)
- end
- else
- return mpnumeric(0)
- end
- end
- v = vl
- end
- if v == nil then
- return mpnumeric(0)
- else
- return get(v)
- end
-end
-
-local function hasparameter()
- local list, n = collectnames()
- local v = namespaces
- for i=1,n do
- local l = list[i]
- local vl = rawget(v,l)
- if vl == nil then
- if type(l) == "number" then
- vl = rawget(v,1)
- if vl == nil then
- return mpboolean(false)
- end
- else
- return mpboolean(false)
- end
- end
- v = vl
- end
- if v == nil then
- return mpboolean(false)
- else
- return mpboolean(true)
- end
-end
-
-local function hasoption()
- local list, n = collectnames()
- if n > 1 then
- local v = namespaces
- if n > 2 then
- for i=1,n-1 do
- local l = list[i]
- local vl = v[l]
- if vl == nil then
- return mpboolean(false)
- end
- v = vl
- end
- else
- v = v[list[1]]
- end
- if type(v) == "string" then
- -- no caching .. slow anyway
- local o = list[n]
- if v == o then
- return mpboolean(true)
- end
- for vv in gmatch(v,"[^%s,]+") do
- for oo in gmatch(o,"[^%s,]+") do
- if vv == oo then
- return mpboolean(true)
- end
- end
- end
- end
- end
- return mpboolean(false)
-end
-
-local function getparameterdefault()
- local list, n = collectnames()
- local v = namespaces
- if n == 1 then
- local l = list[1]
- local vl = v[l]
- if vl == nil then
- -- maybe backtrack
- local top = stack[#stack]
- if top then
- vl = top[l]
- end
- end
- if vl == nil then
- return mpnumeric(0)
- else
- return get(vl)
- end
- else
- for i=1,n-1 do
- local l = list[i]
- local vl = v[l]
- if vl == nil then
- if type(l) == "number" then
- vl = v[1]
- if vl == nil then
- return get(list[n])
- end
- else
- local last = list[n]
- if last == "*" then
- -- so, only when not pushed
- local m = getmetatable(namespaces[list[1]])
- if n then
- m = m.__index -- can also be a _m_
- end
- if m then
- local v = m
- for i=2,n-1 do
- local l = list[i]
- local vl = v[l]
- if vl == nil then
- return mpnumeric(0)
- end
- v = vl
- end
- if v == nil then
- return mpnumeric(0)
- else
- return get(v)
- end
- end
- return mpnumeric(0)
- else
- return get(last)
- end
- end
- end
- v = vl
- end
- if v == nil then
- return get(list[n])
- else
- return get(v)
- end
- end
-end
-
-local function getparametercount()
- local list, n = collectnames()
- local v = namespaces
- for i=1,n do
- v = v[list[i]]
- if not v then
- break
- end
- end
- return mpnumeric(type(v) == "table" and #v or 0)
-end
-
-local function getmaxparametercount()
- local list, n = collectnames()
- local v = namespaces
- for i=1,n do
- v = v[list[i]]
- if not v then
- break
- end
- end
- local n = 0
- if type(v) == "table" then
- local v1 = v[1]
- if type(v1) == "table" then
- n = #v1
- for i=2,#v do
- local vi = v[i]
- if type(vi) == "table" then
- local vn = #vi
- if vn > n then
- n = vn
- end
- else
- break;
- end
- end
- end
-
- end
- return mpnumeric(n)
-end
-
-local validconnectors = {
- [".."] = true,
- ["..."] = true,
- ["--"] = true,
-}
-
-local function getparameterpath()
- local list, n = collectnames()
- local close = list[n]
- if type(close) == "boolean" then
- n = n - 1
- else
- close = false
- end
- local connector = list[n]
- if type(connector) == "string" and validconnectors[connector] then
- n = n - 1
- else
- connector = "--"
- end
- local v = namespaces
- for i=1,n do
- v = v[list[i]]
- if not v then
- break
- end
- end
- if type(v) == "table" then
- return mppath(v,connector,close)
- else
- return mppair(0,0)
- end
-end
-
-local function getparameterpen()
- local list, n = collectnames()
- local v = namespaces
- for i=1,n do
- v = v[list[i]]
- if not v then
- break
- end
- end
- if type(v) == "table" then
- return mppath(v,"..",true)
- else
- return mppair(0,0)
- end
-end
-
-local function getparametertext()
- local list, n = collectnames()
- local strut = list[n]
- if type(strut) == "boolean" then
- n = n - 1
- else
- strut = false
- end
- local v = namespaces
- for i=1,n do
- v = v[list[i]]
- if not v then
- break
- end
- end
- if type(v) == "string" then
- return mpquoted("\\strut " .. v)
- else
- return mpquoted("")
- end
-end
-
--- local function getparameteroption()
--- local list, n = collectnames()
--- local last = list[n]
--- if type(last) == "string" then
--- n = n - 1
--- else
--- return false
--- end
--- local v = namespaces
--- for i=1,n do
--- v = v[list[i]]
--- if not v then
--- break
--- end
--- end
--- if type(v) == "string" and v ~= "" then
--- for s in gmatch(v,"[^ ,]+") do
--- if s == last then
--- return true
--- end
--- end
--- end
--- return false
--- end
-
-function metapost.scanparameters()
--- scantoken() -- we scan the semicolon
- return get_parameters()
-end
-
-metapost.registerscript("getparameters", getparameters)
-metapost.registerscript("applyparameters", applyparameters)
-metapost.registerscript("presetparameters", presetparameters)
-metapost.registerscript("hasparameter", hasparameter)
-metapost.registerscript("hasoption", hasoption)
-metapost.registerscript("getparameter", getparameter)
-metapost.registerscript("getparameterdefault", getparameterdefault)
-metapost.registerscript("getparametercount", getparametercount)
-metapost.registerscript("getmaxparametercount",getmaxparametercount)
-metapost.registerscript("getparameterpath", getparameterpath)
-metapost.registerscript("getparameterpen", getparameterpen)
-metapost.registerscript("getparametertext", getparametertext)
---------.registerscript("getparameteroption", getparameteroption)
-metapost.registerscript("pushparameters", pushparameters)
-metapost.registerscript("popparameters", popparameters)
-
-function metapost.getparameter(list)
- local n = #list
- local v = namespaces
- for i=1,n do
- local l = list[i]
- local vl = v[l]
- if vl == nil then
- return
- end
- v = vl
- end
- return v
-end
-
-function metapost.getparameterset(namespace)
- return namespace and namespaces[namespace] or namespaces
-end
-
-function metapost.setparameterset(namespace,t)
- namespaces[namespace] = t
-end
-
--- goodies
-
-metapost.registerscript("definecolor", function()
- scantoken() -- we scan the semicolon
- local s = get_parameters()
- attributes.colors.defineprocesscolordirect(s)
-end)
-
--- tex scanners
-
-local scanners = tokens.scanners
-local scanhash = scanners.hash
-local scanstring = scanners.string
-local scanvalue = scanners.value
-local scaninteger = scanners.integer
-local scanboolean = scanners.boolean
-local scanfloat = scanners.float
-local scandimension = scanners.dimension
-
-local definitions = { }
-
-local bpfactor = number.dimenfactors.bp
-local comma = byte(",")
-local close = byte("]")
-
-local scanrest = function() return scanvalue(comma,close) or "" end
-local scandimension = function() return scandimension() * bpfactor end
-
-local scanners = {
- ["integer"] = scaninteger,
- ["number"] = scanfloat,
- ["numeric"] = scanfloat,
- ["boolean"] = scanboolean,
- ["string"] = scanrest,
- ["dimension"] = scandimension,
-}
-
-interfaces.implement {
- name = "lmt_parameters_define",
- arguments = "string",
- actions = function(namespace)
- local d = scanhash()
- for k, v in next, d do
- d[k] = scanners[v] or scanrest
- end
- definitions[namespace] = d
- end,
-}
-
-interfaces.implement {
- name = "lmt_parameters_preset",
- arguments = "string",
- actions = function(namespace)
- passed[namespace] = scanhash(definitions[namespace])
- end,
-}
-
-interfaces.implement {
- name = "lmt_parameters_reset",
- arguments = "string",
- actions = function(namespace)
- passed[namespace] = nil
- end,
-}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-svg.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-svg.lua
deleted file mode 100644
index 3d15840a7b6..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mlib-svg.lua
+++ /dev/null
@@ -1,3268 +0,0 @@
-if not modules then modules = { } end modules ['mlib-svg'] = {
- version = 1.001,
- comment = "companion to mlib-ctx.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
--- Just a few notes:
---
--- There is no real need to boost performance here .. we can always make a fast
--- variant when really needed. I will also do some of the todo's when I run into
--- proper fonts. I need to optimize this a bit but will do that once I'm satisfied
--- with the outcome and don't need more hooks and plugs. At some point I will
--- optimize the MetaPost part because now we probably have more image wrapping
--- than needed.
---
--- As usual with these standards, things like a path can be very compact while the
--- rest is very verbose which defeats the point. This is a first attempt. There will
--- be a converter to MP as well as directly to PDF. This module was made for one of
--- the dangerous curves talks at the 2019 CTX meeting. I will do the font when I
--- need it (not that hard).
---
--- The fact that in the more recent versions of SVG the older text related elements
--- are depricated and not even supposed to be supported, combined with the fact that
--- the text element assumes css styling, demonstrates that there is not so much as a
--- standard. It basically means that whatever technology dominates at some point
--- (probably combined with some libraries that at that point exist) determine what
--- is standard. Anyway, it probably also means that these formats are not that
--- suitable for long term archival purposes. So don't take the next implementation
--- too serious. So in the end we now have (1) attributes for properties (which is
--- nice and clean and what attributes are for, (2) a style attribute that needs to
--- be parsed, (3) classes that map to styles and (4) element related styles, plus a
--- kind of inheritance (given the limited number of elements sticking to only as
--- wrapper would have made much sense. Anyway, we need to deal with it. With all
--- these style things going on, one can wonder where it will end. Basically svg
--- became just a html element that way and less clean too. The same is true for
--- tspan, which means that text itself is nested xml.
---
--- We can do a direct conversion to PDF but then we also loose the abstraction which
--- in the future will be used, and for fonts we need to spawn out to TeX anyway, so
--- the little overhead of calling MetaPost is okay I guess. Also, we want to
--- overload labels, share fonts with the main document, etc. and are not aiming at a
--- general purpose SVG converter. For going to PDF one can just use InkScape.
---
--- Written with Anne Clark on speakers as distraction.
---
--- Todo when I run into an example (but ony when needed and reasonable):
---
--- var(color,color)
--- --color
--- currentColor : when i run into an example
--- a bit more shading
--- clip = [ auto | rect(llx,lly,urx,ury) ] (in svg)
--- xlink url ... whatever
--- masks
--- opacity per group (i need to add that to metafun first, inefficient pdf but
--- maybe filldraw can help here)
---
--- Maybe in metafun:
---
--- penciled n -> withpen pencircle scaled n
--- applied (...) -> transformed bymatrix (...)
--- withopacity n -> withtransparency (1,n)
-
--- When testing mbo files:
---
--- empty paths
--- missing control points
--- funny fontnames like abcdefverdana etc
--- paths representing glyphs but also with style specs
--- all kind of attributes
--- very weird and inefficient shading
-
--- One can run into pretty crazy images, like lines that are fills being clipped
--- to some width. That's the danger of hiding yourself behind an interface I guess.
-
-local rawget, rawset, type, tonumber, tostring, next, setmetatable = rawget, rawset, type, tonumber, tostring, next, setmetatable
-
-local P, S, R, C, Ct, Cs, Cc, Cp, Cg, Cf, Carg = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.Cp, lpeg.Cg, lpeg.Cf, lpeg.Carg
-
-local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
-local sqrt = math.sqrt
-local concat, setmetatableindex, sortedhash = table.concat, table.setmetatableindex, table.sortedhash
-local gmatch, gsub, find, match, rep = string.gmatch, string.gsub, string.find, string.match, string.rep
-local formatters, fullstrip = string.formatters, string.fullstrip
-local utfsplit, utfbyte = utf.split, utf.byte
-
-local xmlconvert, xmlcollected, xmlcount, xmlfirst, xmlroot = xml.convert, xml.collected, xml.count, xml.first, xml.root
-local xmltext, xmltextonly = xml.text, xml.textonly
-local css = xml.css or { } -- testing
-
-local function xmlinheritattributes(c,pa)
- local at = c.at
- local dt = c.dt
- if at and dt then
- if pa then
- setmetatableindex(at,pa)
- end
- for i=1,#dt do
- local dti = dt[i]
- if type(dti) == "table" then
- xmlinheritattributes(dti,at)
- end
- end
- else
- -- comment of so
- end
-end
-
-xml.inheritattributes = xmlinheritattributes
-
--- Maybe some day helpers will move to the metapost.svg namespace!
-
-metapost = metapost or { }
-local metapost = metapost
-local context = context
-
-local report = logs.reporter("metapost","svg")
-
-local trace = false trackers.register("metapost.svg", function(v) trace = v end)
-local trace_text = false trackers.register("metapost.svg.text", function(v) trace_text = v end)
-local trace_path = false trackers.register("metapost.svg.path", function(v) trace_path = v end)
-local trace_result = false trackers.register("metapost.svg.result", function(v) trace_result = v end)
-
-local pathtracer = {
- ["stroke"] = "darkred",
- ["stroke-opacity"] = ".5",
- ["stroke-width"] = ".5",
- ["fill"] = "darkgray",
- ["fill-opacity"] = ".75",
-}
-
--- This is just an experiment. Todo: reset hash etc. Also implement
--- an option handler.
-
-local svghash = false do
-
- local svglast = 0
- local svglist = false
-
- local function checkhash(t,k)
- local n = svglast + 1
- svglast = n
- svglist[n] = k
- t[k] = n
- return n
- end
-
- function metapost.startsvghashing()
- svglast = 0
- svglist = { }
- svghash = setmetatableindex(checkhash)
- end
-
- function metapost.stopsvghashing()
- svglast = 0
- svglist = false
- svghash = false
- end
-
- interfaces.implement {
- name = "svghashed",
- arguments = "integer",
- actions = function(n)
- local t = svglist and svglist[n]
- if t then
- context(t)
- end
- end
- }
-
-end
-
--- We have quite some closures because otherwise we run into the local variable
--- limitations. It doesn't always look pretty now, sorry. I'll clean up this mess
--- some day (the usual nth iteration of code).
---
--- Most of the conversion is rather trivial code till I ran into a file with arcs. A
--- bit of searching lead to the a2c javascript function but it has some puzzling
--- thingies (like sin and cos definitions that look like leftovers and possible
--- division by zero). Anyway, we can if needed optimize it a bit more. Here does it
--- come from:
-
--- http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
--- https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/src/path.js
-
-local a2c do
-
- local pi, sin, cos, tan, asin, abs = math.pi, math.sin, math.cos, math.tan, math.asin, math.abs
-
- local d120 = (pi * 120) / 180
- local pi2 = 2 * pi
-
- a2c = function(x1, y1, rx, ry, angle, large, sweep, x2, y2, f1, f2, cx, cy)
-
- if (rx == 0 or ry == 0 ) or (x1 == x2 and y1 == y2) then
- return { x1, y1, x2, y2, x2, y2 }
- end
-
- local recursive = f1
- local rad = pi / 180 * angle
- local res = nil
- local cosrad = cos(-rad) -- local cosrad = cosd(angle)
- local sinrad = sin(-rad) -- local sinrad = sind(angle)
-
- if not recursive then
-
- x1, y1 = x1 * cosrad - y1 * sinrad, x1 * sinrad + y1 * cosrad
- x2, y2 = x2 * cosrad - y2 * sinrad, x2 * sinrad + y2 * cosrad
-
- local x = (x1 - x2) / 2
- local y = (y1 - y2) / 2
- local xx = x * x
- local yy = y * y
- local h = xx / (rx * rx) + yy / (ry * ry)
-
- if h > 1 then
- h = sqrt(h)
- rx = h * rx
- ry = h * ry
- end
-
- local rx2 = rx * rx
- local ry2 = ry * ry
- local ry2xx = ry2 * xx
- local rx2yy = rx2 * yy
- local total = rx2yy + ry2xx -- otherwise overflow
-
- local k = total == 0 and 0 or sqrt(abs((rx2 * ry2 - rx2yy - ry2xx) / total))
-
- if large == sweep then
- k = -k
- end
-
- cx = k * rx * y / ry + (x1 + x2) / 2
- cy = k * -ry * x / rx + (y1 + y2) / 2
-
- f1 = (y1 - cy) / ry -- otherwise crash on a tiny eps
- f2 = (y2 - cy) / ry -- otherwise crash on a tiny eps
-
- f1 = asin((f1 < -1.0 and -1.0) or (f1 > 1.0 and 1.0) or f1)
- f2 = asin((f2 < -1.0 and -1.0) or (f2 > 1.0 and 1.0) or f2)
-
- if x1 < cx then f1 = pi - f1 end
- if x2 < cx then f2 = pi - f2 end
-
- if f1 < 0 then f1 = pi2 + f1 end
- if f2 < 0 then f2 = pi2 + f2 end
-
- if sweep ~= 0 and f1 > f2 then f1 = f1 - pi2 end
- if sweep == 0 and f2 > f1 then f2 = f2 - pi2 end
-
- end
-
- if abs(f2 - f1) > d120 then
- local f2old = f2
- local x2old = x2
- local y2old = y2
- f2 = f1 + d120 * ((sweep ~= 0 and f2 > f1) and 1 or -1)
- x2 = cx + rx * cos(f2)
- y2 = cy + ry * sin(f2)
- res = a2c(x2, y2, rx, ry, angle, 0, sweep, x2old, y2old, f2, f2old, cx, cy)
- end
-
- local c1 = cos(f1)
- local s1 = sin(f1)
- local c2 = cos(f2)
- local s2 = sin(f2)
-
- local t = tan((f2 - f1) / 4)
- local hx = 4 * rx * t / 3
- local hy = 4 * ry * t / 3
-
- local r = { x1 - hx * s1, y1 + hy * c1, x2 + hx * s2, y2 - hy * c2, x2, y2, unpack(res or { }) }
-
- if not recursive then -- we can also check for sin/cos being 0/1
- cosrad = cos(rad)
- sinrad = sin(rad)
- -- cosrad = cosd(angle)
- -- sinrad = sind(angle)
- for i0=1,#r,2 do
- local i1 = i0 + 1
- local x = r[i0]
- local y = r[i1]
- r[i0] = x * cosrad - y * sinrad
- r[i1] = x * sinrad + y * cosrad
- end
- end
-
- return r
- end
-
-end
-
--- We share some patterns.
-
-local p_digit = lpegpatterns.digit
-local p_hexdigit = lpegpatterns.hexdigit
-local p_space = lpegpatterns.whitespace
-
-local factors = {
- ["pt"] = 1.25,
- ["mm"] = 3.543307,
- ["cm"] = 35.43307,
- ["px"] = 1,
- ["pc"] = 15,
- ["in"] = 90,
- ["em"] = 12 * 1.25,
- ["ex"] = 8 * 1.25,
-}
-
-local percentage_r = 1/100
-local percentage_x = percentage_r
-local percentage_y = percentage_r
-
--- incredible: we can find .123.456 => 0.123 0.456 ...
-
-local p_command_x = C(S("Hh"))
-local p_command_y = C(S("Vv"))
-local p_command_xy = C(S("CcLlMmQqSsTt"))
-local p_command_a = C(S("Aa"))
-local p_command = C(S("Zz"))
-
-local p_optseparator = S("\t\n\r ,")^0
-local p_separator = S("\t\n\r ,")^1
-local p_number = (S("+-")^0 * (p_digit^0 * P(".") * p_digit^1 + p_digit^1 * P(".") + p_digit^1))
- * (P("e") * S("+-")^0 * p_digit^1)^-1
-
-local function convert (n) n = tonumber(n) return n end
-local function convert_r (n,u) n = tonumber(n) if u == true then return percentage_r * n elseif u then return u * n else return n end end
-local function convert_x (n,u) n = tonumber(n) if u == true then return percentage_x * n elseif u then return u * n else return n end end
-local function convert_y (n,u) n = tonumber(n) if u == true then return percentage_y * n elseif u then return u * n else return n end end
-local function convert_vx(n,u) n = tonumber(n) if u == true then return percentage_x * n elseif u then return u * n else return n end end
-local function convert_vy(n,u) n = - tonumber(n) if u == true then return percentage_y * n elseif u then return u * n else return n end end
-
-local p_unit = (P("p") * S("txc") + P("e") * S("xm") + S("mc") * P("m") + P("in")) / factors
-local p_percent = P("%") * Cc(true)
-
-local c_number_n = C(p_number)
-local c_number_u = C(p_number) * (p_unit + p_percent)^-1
-
-local p_number_n = c_number_n / convert
-local p_number_x = c_number_u / convert_x
-local p_number_vx = c_number_u / convert_vx
-local p_number_y = c_number_u / convert_y
-local p_number_vy = c_number_u / convert_vy
-local p_number_r = c_number_u / convert_r
-
-local function asnumber (s) return s and lpegmatch(p_number, s) or 0 end
-local function asnumber_r (s) return s and lpegmatch(p_number_r, s) or 0 end
-local function asnumber_x (s) return s and lpegmatch(p_number_x, s) or 0 end
-local function asnumber_y (s) return s and lpegmatch(p_number_y, s) or 0 end
-local function asnumber_vx(s) return s and lpegmatch(p_number_vx,s) or 0 end
-local function asnumber_vy(s) return s and lpegmatch(p_number_vy,s) or 0 end
-
-local p_number_vx_t = Ct { (p_number_vx + p_separator)^1 }
-local p_number_vy_t = Ct { (p_number_vy + p_separator)^1 }
-
-local zerotable = { 0 }
-
-local function asnumber_vx_t(s) return s and lpegmatch(p_number_vx_t,s) or zerotable end
-local function asnumber_vy_t(s) return s and lpegmatch(p_number_vy_t,s) or zerotable end
-
-local p_numbersep = p_number_n + p_separator
-local p_numbers = p_optseparator * P("(") * p_numbersep^0 * p_optseparator * P(")")
-local p_fournumbers = p_numbersep^4
-local p_path = Ct ( (
- p_command_xy * (p_optseparator * p_number_vx *
- p_optseparator * p_number_vy )^1
- + p_command_x * (p_optseparator * p_number_vx )^1
- + p_command_y * (p_optseparator * p_number_vy )^1
- + p_command_a * (p_optseparator * p_number_vx *
- p_optseparator * p_number_vy *
- p_optseparator * p_number_r *
- p_optseparator * p_number_n * -- flags
- p_optseparator * p_number_n * -- flags
- p_optseparator * p_number_vx *
- p_optseparator * p_number_vy )^1
- + p_command
- + p_separator
-)^1 )
-
--- We can actually use the svg color definitions from the tex end but maybe a user
--- doesn't want those replace the normal definitions.
---
--- local hexhash = setmetatableindex(function(t,k) local v = lpegmatch(p_hexcolor, k) t[k] = v return v end) -- per file
--- local hexhash3 = setmetatableindex(function(t,k) local v = lpegmatch(p_hexcolor3,k) t[k] = v return v end) -- per file
---
--- local function hexcolor (c) return hexhash [c] end -- directly do hexhash [c]
--- local function hexcolor3(c) return hexhash3[c] end -- directly do hexhash3[c]
-
-local colormap = false
-
-local function prepared(t)
- if type(t) == "table" then
- local mapping = t.mapping or { }
- local mapper = t.mapper
- local colormap = setmetatableindex(mapping)
- if mapper then
- setmetatableindex(colormap,function(t,k)
- local v = mapper(k)
- t[k] = v or k
- return v
- end)
- end
- return colormap
- else
- return false
- end
-end
-
-local colormaps = setmetatableindex(function(t,k)
- local v = false
- if type(k) == "string" then
- v = prepared(table.load(k)) -- todo: same path as svg file
- elseif type(k) == "table" then
- v = prepared(k)
- k = k.name or k
- end
- t[k] = v
- return v
-end)
-
-function metapost.svgcolorremapper(colormap)
- return colormaps[colormap]
-end
-
--- todo: cache colors per image / remapper
-
-local colorcomponents, withcolor, thecolor do
-
- local svgcolors = {
- aliceblue = 0xF0F8FF, antiquewhite = 0xFAEBD7, aqua = 0x00FFFF, aquamarine = 0x7FFFD4,
- azure = 0xF0FFFF, beige = 0xF5F5DC, bisque = 0xFFE4C4, black = 0x000000,
- blanchedalmond = 0xFFEBCD, blue = 0x0000FF, blueviolet = 0x8A2BE2, brown = 0xA52A2A,
- burlywood = 0xDEB887, cadetblue = 0x5F9EA0, hartreuse = 0x7FFF00, chocolate = 0xD2691E,
- coral = 0xFF7F50, cornflowerblue = 0x6495ED, cornsilk = 0xFFF8DC, crimson = 0xDC143C,
- cyan = 0x00FFFF, darkblue = 0x00008B, darkcyan = 0x008B8B, darkgoldenrod = 0xB8860B,
- darkgray = 0xA9A9A9, darkgreen = 0x006400, darkgrey = 0xA9A9A9, darkkhaki = 0xBDB76B,
- darkmagenta = 0x8B008B, darkolivegreen = 0x556B2F, darkorange = 0xFF8C00, darkorchid = 0x9932CC,
- darkred = 0x8B0000, darksalmon = 0xE9967A, darkseagreen = 0x8FBC8F, darkslateblue = 0x483D8B,
- darkslategray = 0x2F4F4F, darkslategrey = 0x2F4F4F, darkturquoise = 0x00CED1, darkviolet = 0x9400D3,
- deeppink = 0xFF1493, deepskyblue = 0x00BFFF, dimgray = 0x696969, dimgrey = 0x696969,
- dodgerblue = 0x1E90FF, firebrick = 0xB22222, floralwhite = 0xFFFAF0, forestgreen = 0x228B22,
- fuchsia = 0xFF00FF, gainsboro = 0xDCDCDC, ghostwhite = 0xF8F8FF, gold = 0xFFD700,
- goldenrod = 0xDAA520, gray = 0x808080, green = 0x008000, greenyellow = 0xADFF2F,
- grey = 0x808080, honeydew = 0xF0FFF0, hotpink = 0xFF69B4, indianred = 0xCD5C5C,
- indigo = 0x4B0082, ivory = 0xFFFFF0, khaki = 0xF0E68C, lavender = 0xE6E6FA,
- lavenderblush = 0xFFF0F5, lawngreen = 0x7CFC00, lemonchiffon = 0xFFFACD, lightblue = 0xADD8E6,
- lightcoral = 0xF08080, lightcyan = 0xE0FFFF, lightgoldenrodyellow = 0xFAFAD2, lightgray = 0xD3D3D3,
- lightgreen = 0x90EE90, lightgrey = 0xD3D3D3, lightpink = 0xFFB6C1, lightsalmon = 0xFFA07A,
- lightseagreen = 0x20B2AA, lightskyblue = 0x87CEFA, lightslategray = 0x778899, lightslategrey = 0x778899,
- lightsteelblue = 0xB0C4DE, lightyellow = 0xFFFFE0, lime = 0x00FF00, limegreen = 0x32CD32,
- linen = 0xFAF0E6, magenta = 0xFF00FF, maroon = 0x800000, mediumaquamarine = 0x66CDAA,
- mediumblue = 0x0000CD, mediumorchid = 0xBA55D3, mediumpurple = 0x9370DB, mediumseagreen = 0x3CB371,
- mediumslateblue = 0x7B68EE, mediumspringgreen = 0x00FA9A, mediumturquoise = 0x48D1CC, mediumvioletred = 0xC71585,
- midnightblue = 0x191970, mintcream = 0xF5FFFA, mistyrose = 0xFFE4E1, moccasin = 0xFFE4B5,
- navajowhite = 0xFFDEAD, navy = 0x000080, oldlace = 0xFDF5E6, olive = 0x808000,
- olivedrab = 0x6B8E23, orange = 0xFFA500, orangered = 0xFF4500, orchid = 0xDA70D6,
- palegoldenrod = 0xEEE8AA, palegreen = 0x98FB98, paleturquoise = 0xAFEEEE, palevioletred = 0xDB7093,
- papayawhip = 0xFFEFD5, peachpuff = 0xFFDAB9, peru = 0xCD853F, pink = 0xFFC0CB,
- plum = 0xDDA0DD, powderblue = 0xB0E0E6, purple = 0x800080, red = 0xFF0000,
- rosybrown = 0xBC8F8F, royalblue = 0x4169E1, saddlebrown = 0x8B4513, salmon = 0xFA8072,
- sandybrown = 0xF4A460, seagreen = 0x2E8B57, seashell = 0xFFF5EE, sienna = 0xA0522D,
- silver = 0xC0C0C0, skyblue = 0x87CEEB, slateblue = 0x6A5ACD, slategray = 0x708090,
- slategrey = 0x708090, snow = 0xFFFAFA, springgreen = 0x00FF7F, steelblue = 0x4682B4,
- tan = 0xD2B48C, teal = 0x008080, thistle = 0xD8BFD8, tomato = 0xFF6347,
- turquoise = 0x40E0D0, violet = 0xEE82EE, wheat = 0xF5DEB3, white = 0xFFFFFF,
- whitesmoke = 0xF5F5F5, yellow = 0xFFFF00, yellowgreen = 0x9ACD32,
- }
-
- local f_rgb = formatters['withcolor svgcolor(%.3N,%.3N,%.3N)']
- local f_cmyk = formatters['withcolor svgcmyk(%.3N,%.3N,%.3N,%.3N)']
- local f_gray = formatters['withcolor svggray(%.3N)']
- local f_rgba = formatters['withcolor svgcolor(%.3N,%.3N,%.3N) withtransparency (1,%.3N)']
- local f_graya = formatters['withcolor svggray(%.3N) withtransparency (1,%.3N)']
- local f_name = formatters['withcolor "%s"']
- local f_svgcolor = formatters['svgcolor(%.3N,%.3N,%.3N)']
- local f_svgcmyk = formatters['svgcmyk(%.3N,%.3N,%.3N,%.3N)']
- local f_svggray = formatters['svggray(%.3N)']
- local f_svgname = formatters['"%s"']
-
- local extract = bit32.extract
-
- local triplets = setmetatableindex(function(t,k)
- -- we delay building all these strings
- local v = svgcolors[k]
- if v then
- v = { extract(v,16,8)/255, extract(v,8,8)/255, extract(v,0,8)/255 }
- else
- v = false
- end
- t[k] = v
- return v
- end)
-
- local p_fraction = C(p_number) * C("%")^-1 / function(a,b) return tonumber(a) / (b and 100 or 255) end
- local p_angle = C(p_number) * P("deg")^0 / function(a) return tonumber(a) end
- local p_percent = C(p_number) * P("%") / function(a) return tonumber(a) / 100 end
- local p_absolute = C(p_number) / tonumber
-
- local p_left = P("(")
- local p_right = P(")")
- local p_a = P("a")^-1
- local p_h_a_color = p_left
- * p_angle
- * p_separator * p_percent
- * p_separator * p_percent
- * p_separator^0 * p_absolute^0
- * p_right
-
- local colors = attributes.colors
- local colorvalues = colors.values
- local colorindex = attributes.list[attributes.private('color')]
- local hsvtorgb = colors.hsvtorgb
- local hwbtorgb = colors.hwbtorgb
- local forcedmodel = colors.forcedmodel
-
- local p_splitcolor =
- P("#") * C(p_hexdigit*p_hexdigit)^1 / function(r,g,b)
- return "rgb",
- tonumber(r or 0, 16) / 255 or 0,
- tonumber(g or 0, 16) / 255 or 0,
- tonumber(b or 0, 16) / 255 or 0
- end
- +
- P("rgb") * p_a
- * p_left * (p_fraction + p_separator)^-3 * (p_absolute + p_separator)^0 * p_right / function(r,g,b,a)
- return "rgb", r or 0, g or 0, b or 0, a or false
- end
- + P("cmyk")
- * p_left * (p_absolute + p_separator)^0 * p_right / function(c,m,y,k)
- return "cmyk", c or 0, m or 0, y or 0, k or 0
- end
- + P("hsl") * p_a
- * p_h_a_color / function(h,s,l,a)
- local r, g, b = hsvtorgb(h,s,l,a)
- return "rgb", r or 0, g or 0, b or 0, a or false
- end
- + P("hwb") * p_a
- * p_h_a_color / function(h,w,b,a)
- local r, g, b = hwbtorgb(h,w,b)
- return "rgb", r or 0, g or 0, b or 0, a or false
- end
-
- function metapost.svgsplitcolor(color)
- if type(color) == "string" then
- local what, s1, s2, s3, s4 = lpegmatch(p_splitcolor,color)
- if not what then
- local t = triplets[color]
- if t then
- what, s1, s2, s3 = "rgb", t[1], t[2], t[3]
- end
- end
- return what, s1, s2, s3, s4
- else
- return "gray", 0, false
- end
- end
-
-
- local function registeredcolor(name)
- local color = colorindex[name]
- if color then
- local v = colorvalues[color]
- local t = forcedmodel(v[1])
- if t == 2 then
- return "gray", v[2]
- elseif t == 3 then
- return "rgb", v[3], v[4], v[5]
- elseif t == 4 then
- return "cmyk", v[6], v[7], v[8], v[9]
- else
- --
- end
- end
- end
-
- -- we can have a fast check for #000000
-
- local function validcolor(color)
- if colormap then
- local c = colormap[color]
- local t = type(c)
- if t == "table" then
- local what = t[1]
- if what == "rgb" then
- return
- what,
- tonumber(t[2]) or 0,
- tonumber(t[3]) or 0,
- tonumber(t[4]) or 0,
- tonumber(t[4]) or false
- elseif what == "cmyk" then
- return
- what,
- tonumber(t[2]) or 0,
- tonumber(t[3]) or 0,
- tonumber(t[4]) or 0,
- tonumber(t[5]) or 0
- elseif what == "gray" then
- return
- what,
- tonumber(t[2]) or 0,
- tonumber(t[3]) or false
- end
- elseif t == "string" then
- color = c
- end
- end
- local what, s1, s2, s3, s4 = registeredcolor(color)
- if what then
- return what, s1, s2, s3, s4
- end
- what, s1, s2, s3, s4 = lpegmatch(p_splitcolor,color)
- if not what then
- local t = triplets[color]
- if t then
- s1, s3, s3 = t[1], t[2], t[3]
- what = "rgb"
- end
- end
- return what, s1, s2, s3, s4
- end
-
- colorcomponents = function(color)
- local what, s1, s2, s3, s4 = validcolor(color)
- return s1, s2, s3, s4 -- so 4 means cmyk
- end
-
- withcolor = function(color)
- local what, s1, s2, s3, s4 = validcolor(color)
- -- print(color,what, s1, s2, s3, s4)
- if what == "rgb" then
- if s4 then
- if s1 == s2 and s1 == s3 then
- return f_graya(s1,s4)
- else
- return f_rgba(s1,s2,s3,s4)
- end
- else
- if s1 == s2 and s1 == s3 then
- return f_gray(s1)
- else
- return f_rgb(s1,s2,s3)
- end
- end
- elseif what == "cmyk" then
- return f_cmyk(s1,s2,s3,s4)
- elseif what == "gray" then
- if s2 then
- return f_graya(s1,s2)
- else
- return f_gray(s1)
- end
- end
- return f_name(color)
- end
-
- thecolor = function(color)
- local what, s1, s2, s3, s4 = validcolor(color)
- if what == "rgb" then
- if s4 then
- if s1 == s2 and s1 == s3 then
- return f_svggraya(s1,s4)
- else
- return f_svgrgba(s1,s2,s3,s4)
- end
- else
- if s1 == s2 and s1 == s3 then
- return f_svggray(s1)
- else
- return f_svgrgb(s1,s2,s3)
- end
- end
- elseif what == "cmyk" then
- return f_cmyk(s1,s2,s3,s4)
- elseif what == "gray" then
- if s2 then
- return f_svggraya(s1,s2)
- else
- return f_svggray(s1)
- end
- end
- return f_svgname(color)
- end
-
-end
-
--- actually we can loop faster because we can go to the last one
-
-local grabpath, grablist do
-
- local f_moveto = formatters['(%N,%N)']
- local f_curveto_z = formatters['controls(%N,%N)and(%N,%N)..(%N,%N)']
- local f_curveto_n = formatters['..controls(%N,%N)and(%N,%N)..(%N,%N)']
- local f_lineto_z = formatters['(%N,%N)']
- local f_lineto_n = formatters['--(%N,%N)']
-
- local m = { __index = function() return 0 end }
-
- grabpath = function(str)
- local p = lpegmatch(p_path,str) or { }
- local np = #p
- local all = { entries = np, closed = false, curve = false }
- if np == 0 then
- return all
- end
- setmetatable(p,m)
- local t = { } -- no real saving here if we share
- local n = 0
- local a = 0
- local i = 0
- local last = "M"
- local prev = last
- local kind = "L"
- local x, y = 0, 0
- local x1, y1 = 0, 0
- local x2, y2 = 0, 0
- local rx, ry = 0, 0
- local ar, al = 0, 0
- local as, ac = 0, nil
- local mx, my = 0, 0
- while i < np do
- i = i + 1
- local pi = p[i]
- if type(pi) ~= "number" then
- last = pi
- i = i + 1
- pi = p[i]
- end
- -- most often
- if last == "c" then
- x1 = x + pi
- i = i + 1 ; y1 = y + p[i]
- i = i + 1 ; x2 = x + p[i]
- i = i + 1 ; y2 = y + p[i]
- i = i + 1 ; x = x + p[i]
- i = i + 1 ; y = y + p[i]
- goto curveto
- elseif last == "l" then
- x = x + pi
- i = i + 1 ; y = y + p[i]
- goto lineto
- elseif last == "h" then
- x = x + pi
- goto lineto
- elseif last == "v" then
- y = y + pi
- goto lineto
- elseif last == "a" then
- x1 = x
- y1 = y
- rx = pi
- i = i + 1 ; ry = p[i]
- i = i + 1 ; ar = p[i]
- i = i + 1 ; al = p[i]
- i = i + 1 ; as = p[i]
- i = i + 1 ; x = x + p[i]
- i = i + 1 ; y = y + p[i]
- goto arc
- elseif last == "s" then
- if prev == "C" then
- x1 = 2 * x - x2
- y1 = 2 * y - y2
- else
- x1 = x
- y1 = y
- end
- x2 = x + pi
- i = i + 1 ; y2 = y + p[i]
- i = i + 1 ; x = x + p[i]
- i = i + 1 ; y = y + p[i]
- goto curveto
- elseif last == "m" then
- if n > 0 then
- a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
- end
- x = x + pi
- i = i + 1 ; y = y + p[i]
- goto moveto
- elseif last == "z" then
- goto close
- -- less frequent
- elseif last == "C" then
- x1 = pi
- i = i + 1 ; y1 = p[i]
- i = i + 1 ; x2 = p[i]
- i = i + 1 ; y2 = p[i]
- i = i + 1 ; x = p[i]
- i = i + 1 ; y = p[i]
- goto curveto
- elseif last == "L" then
- x = pi
- i = i + 1 ; y = p[i]
- goto lineto
- elseif last == "H" then
- x = pi
- goto lineto
- elseif last == "V" then
- y = pi
- goto lineto
- elseif last == "A" then
- x1 = x
- y1 = y
- rx = pi
- i = i + 1 ; ry = p[i]
- i = i + 1 ; ar = p[i]
- i = i + 1 ; al = p[i]
- i = i + 1 ; as = p[i]
- i = i + 1 ; x = p[i]
- i = i + 1 ; y = p[i]
- goto arc
- elseif last == "S" then
- if prev == "C" then
- x1 = 2 * x - x2
- y1 = 2 * y - y2
- else
- x1 = x
- y1 = y
- end
- x2 = pi
- i = i + 1 ; y2 = p[i]
- i = i + 1 ; x = p[i]
- i = i + 1 ; y = p[i]
- goto curveto
- elseif last == "M" then
- if n > 0 then
- a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
- end
- x = pi ;
- i = i + 1 ; y = p[i]
- goto moveto
- elseif last == "Z" then
- goto close
- -- very seldom
- elseif last == "q" then
- x1 = x + pi
- i = i + 1 ; y1 = y + p[i]
- i = i + 1 ; x2 = x + p[i]
- i = i + 1 ; y2 = y + p[i]
- goto quadratic
- elseif last == "t" then
- if prev == "C" then
- x1 = 2 * x - x1
- y1 = 2 * y - y1
- else
- x1 = x
- y1 = y
- end
- x2 = x + pi
- i = i + 1 ; y2 = y + p[i]
- goto quadratic
- elseif last == "Q" then
- x1 = pi
- i = i + 1 ; y1 = p[i]
- i = i + 1 ; x2 = p[i]
- i = i + 1 ; y2 = p[i]
- goto quadratic
- elseif last == "T" then
- if prev == "C" then
- x1 = 2 * x - x1
- y1 = 2 * y - y1
- else
- x1 = x
- y1 = y
- end
- x2 = pi
- i = i + 1 ; y2 = p[i]
- goto quadratic
- else
- goto continue
- end
- ::moveto::
- n = n + 1 ; t[n] = f_moveto(x,y)
- last = last == "M" and "L" or "l"
- prev = "M"
- mx = x
- my = y
- goto continue
- ::lineto::
- n = n + 1 ; t[n] = (n > 0 and f_lineto_n or f_lineto_z)(x,y)
- prev = "L"
- goto continue
- ::curveto::
- n = n + 1 ; t[n] = (n > 0 and f_curveto_n or f_curveto_z)(x1,y1,x2,y2,x,y)
- prev = "C"
- goto continue
- ::arc::
- ac = a2c(x1,y1,rx,ry,ar,al,as,x,y)
- for i=1,#ac,6 do
- n = n + 1 ; t[n] = (n > 0 and f_curveto_n or f_curveto_z)(
- ac[i],ac[i+1],ac[i+2],ac[i+3],ac[i+4],ac[i+5]
- )
- end
- prev = "A"
- goto continue
- ::quadratic::
- n = n + 1 ; t[n] = (n > 0 and f_curveto_n or f_curveto_z)(
- x + 2/3 * (x1-x ), y + 2/3 * (y1-y ),
- x2 + 2/3 * (x1-x2), y2 + 2/3 * (y1-y2),
- x2, y2
- )
- x = x2
- y = y2
- prev = "C"
- goto continue
- ::close::
- -- n = n + 1 ; t[n] = prev == "C" and "..cycle" or "--cycle"
- n = n + 1 ; t[n] = "--cycle"
- if n > 0 then
- a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
- end
- if i == np then
- break
- else
- i = i - 1
- end
- kind = prev
- prev = "Z"
- -- this is kind of undocumented: a close also moves back
- x = mx
- y = my
- ::continue::
- end
- if n > 0 then
- a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
- end
- if prev == "Z" then
- all.closed = true
- end
- all.curve = (kind == "C" or kind == "A")
- return all, p
- end
-
- -- this is a bit tricky as what are points for a mark ... the next can be simplified
- -- a lot
-
- grablist = function(p)
- local np = #p
- if np == 0 then
- return nil
- end
- local t = { }
- local n = 0
- local a = 0
- local i = 0
- local last = "M"
- local prev = last
- local kind = "L"
- local x, y = 0, 0
- local x1, y1 = 0, 0
- local x2, y2 = 0, 0
- local rx, ry = 0, 0
- local ar, al = 0, 0
- local as, ac = 0, nil
- local mx, my = 0, 0
- while i < np do
- i = i + 1
- local pi = p[i]
- if type(pi) ~= "number" then
- last = pi
- i = i + 1
- pi = p[i]
- end
- -- most often
- if last == "c" then
- x1 = x + pi
- i = i + 1 ; y1 = y + p[i]
- i = i + 1 ; x2 = x + p[i]
- i = i + 1 ; y2 = y + p[i]
- i = i + 1 ; x = x + p[i]
- i = i + 1 ; y = y + p[i]
- goto curveto
- elseif last == "l" then
- x = x + pi
- i = i + 1 ; y = y + p[i]
- goto lineto
- elseif last == "h" then
- x = x + pi
- goto lineto
- elseif last == "v" then
- y = y + pi
- goto lineto
- elseif last == "a" then
- x1 = x
- y1 = y
- rx = pi
- i = i + 1 ; ry = p[i]
- i = i + 1 ; ar = p[i]
- i = i + 1 ; al = p[i]
- i = i + 1 ; as = p[i]
- i = i + 1 ; x = x + p[i]
- i = i + 1 ; y = y + p[i]
- goto arc
- elseif last == "s" then
- if prev == "C" then
- x1 = 2 * x - x2
- y1 = 2 * y - y2
- else
- x1 = x
- y1 = y
- end
- x2 = x + pi
- i = i + 1 ; y2 = y + p[i]
- i = i + 1 ; x = x + p[i]
- i = i + 1 ; y = y + p[i]
- goto curveto
- elseif last == "m" then
- x = x + pi
- i = i + 1 ; y = y + p[i]
- goto moveto
- elseif last == "z" then
- goto close
- -- less frequent
- elseif last == "C" then
- x1 = pi
- i = i + 1 ; y1 = p[i]
- i = i + 1 ; x2 = p[i]
- i = i + 1 ; y2 = p[i]
- i = i + 1 ; x = p[i]
- i = i + 1 ; y = p[i]
- goto curveto
- elseif last == "L" then
- x = pi
- i = i + 1 ; y = p[i]
- goto lineto
- elseif last == "H" then
- x = pi
- goto lineto
- elseif last == "V" then
- y = pi
- goto lineto
- elseif last == "A" then
- x1 = x
- y1 = y
- rx = pi
- i = i + 1 ; ry = p[i]
- i = i + 1 ; ar = p[i]
- i = i + 1 ; al = p[i]
- i = i + 1 ; as = p[i]
- i = i + 1 ; x = p[i]
- i = i + 1 ; y = p[i]
- goto arc
- elseif last == "S" then
- if prev == "C" then
- x1 = 2 * x - x2
- y1 = 2 * y - y2
- else
- x1 = x
- y1 = y
- end
- x2 = pi
- i = i + 1 ; y2 = p[i]
- i = i + 1 ; x = p[i]
- i = i + 1 ; y = p[i]
- goto curveto
- elseif last == "M" then
- x = pi ;
- i = i + 1 ; y = p[i]
- goto moveto
- elseif last == "Z" then
- goto close
- -- very seldom
- elseif last == "q" then
- x1 = x + pi
- i = i + 1 ; y1 = y + p[i]
- i = i + 1 ; x2 = x + p[i]
- i = i + 1 ; y2 = y + p[i]
- goto quadratic
- elseif last == "t" then
- if prev == "C" then
- x1 = 2 * x - x1
- y1 = 2 * y - y1
- else
- x1 = x
- y1 = y
- end
- x2 = x + pi
- i = i + 1 ; y2 = y + p[i]
- goto quadratic
- elseif last == "Q" then
- x1 = pi
- i = i + 1 ; y1 = p[i]
- i = i + 1 ; x2 = p[i]
- i = i + 1 ; y2 = p[i]
- goto quadratic
- elseif last == "T" then
- if prev == "C" then
- x1 = 2 * x - x1
- y1 = 2 * y - y1
- else
- x1 = x
- y1 = y
- end
- x2 = pi
- i = i + 1 ; y2 = p[i]
- goto quadratic
- else
- goto continue
- end
- ::moveto::
- n = n + 1 ; t[n] = x
- n = n + 1 ; t[n] = y
- last = last == "M" and "L" or "l"
- prev = "M"
- mx = x
- my = y
- goto continue
- ::lineto::
- n = n + 1 ; t[n] = x
- n = n + 1 ; t[n] = y
- prev = "L"
- goto continue
- ::curveto::
- n = n + 1 ; t[n] = x
- n = n + 1 ; t[n] = y
- prev = "C"
- goto continue
- ::arc::
- ac = a2c(x1,y1,rx,ry,ar,al,as,x,y)
- for i=1,#ac,6 do
- n = n + 1 ; t[n] = ac[i+4]
- n = n + 1 ; t[n] = ac[i+5]
- end
- prev = "A"
- goto continue
- ::quadratic::
- n = n + 1 ; t[n] = x2
- n = n + 1 ; t[n] = y2
- x = x2
- y = y2
- prev = "C"
- goto continue
- ::close::
- n = n + 1 ; t[n] = mx
- n = n + 1 ; t[n] = my
- if i == np then
- break
- end
- kind = prev
- prev = "Z"
- x = mx
- y = my
- ::continue::
- end
- return t
- end
-
-end
-
--- todo: viewbox helper
-
-local s_wrapped_start = "draw image ("
-local f_wrapped_stop = formatters[") shifted (0,%N) scaled %N ;"]
-
-local handletransform, handleviewbox do
-
- local sind = math.sind
-
- --todo: better lpeg
-
- local f_rotatedaround = formatters[" rotatedaround((%N,%N),%N)"]
- local f_rotated = formatters[" rotated(%N)"]
- local f_shifted = formatters[" shifted(%N,%N)"]
- local f_slanted_x = formatters[" xslanted(%N)"]
- local f_slanted_y = formatters[" yslanted(%N)"]
- local f_scaled = formatters[" scaled(%N)"]
- local f_xyscaled = formatters[" xyscaled(%N,%N)"]
- local f_matrix = formatters[" transformed bymatrix(%N,%N,%N,%N,%N,%N)"]
-
- local s_transform_start = "draw image ( "
- local f_transform_stop = formatters[")%s ;"]
-
- local function rotate(r,x,y)
- if x then
- return r and f_rotatedaround(x,-(y or x),-r)
- elseif r then
- return f_rotated(-r)
- else
- return ""
- end
- end
-
- local function translate(x,y)
- if y then
- return f_shifted(x,-y)
- elseif x then
- return f_shifted(x,0)
- else
- return ""
- end
- end
-
- local function scale(x,y)
- if y then
- return f_xyscaled(x,y)
- elseif x then
- return f_scaled(x)
- else
- return ""
- end
- end
-
- local function skewx(x)
- if x then
- return f_slanted_x(sind(-x))
- else
- return ""
- end
- end
-
- local function skewy(y)
- if y then
- return f_slanted_y(sind(-y))
- else
- return ""
- end
- end
-
- local function matrix(rx,sx,sy,ry,tx,ty)
- return f_matrix(rx or 1, sx or 0, sy or 0, ry or 1, tx or 0, - (ty or 0))
- end
-
- -- How to deal with units here? Anyway, order seems to matter.
-
- local p_transform = Cf ( Ct("") * (
- lpegpatterns.whitespace^0 * Cg(
- C("translate") * (p_numbers / translate) -- maybe xy
- + C("scale") * (p_numbers / scale)
- + C("rotate") * (p_numbers / rotate)
- + C("matrix") * (p_numbers / matrix)
- + C("skewX") * (p_numbers / skewx)
- + C("skewY") * (p_numbers / skewy)
- )
- )^1, rawset)
-
- handletransform = function(at)
- local t = at.transform
- if t then
- local e = lpegmatch(p_transform,t)
- if e then
- e = concat({
- e.rotate or "",
- e.skewX or "",
- e.skewY or "",
- e.scale or "",
- e.translate or "",
- e.matrix or "",
- }, " ")
- return s_transform_start, f_transform_stop(e), t
- end
- end
- end
-
- handleviewbox = function(v)
- if v then
- local x, y, w, h = lpegmatch(p_fournumbers,v)
- if h then
- return x, y, w, h
- end
- end
- end
-
-end
-
-local dashed do
-
- -- actually commas are mandate but we're tolerant
-
- local f_dashed_n = formatters[" dashed dashpattern (%s ) "]
- local f_dashed_y = formatters[" dashed dashpattern (%s ) shifted (%N,0) "]
-
- local p_number = p_optseparator/"" * p_number_r
- local p_on = Cc(" on ") * p_number
- local p_off = Cc(" off ") * p_number
- local p_dashed = Cs((p_on * p_off^-1)^1)
-
- dashed = function(s,o)
- if not find(s,",") then
- -- a bit of a hack:
- s = s .. " " .. s
- end
- return (o and f_dashed_y or f_dashed_n)(lpegmatch(p_dashed,s),o)
- end
-
-end
-
-do
-
- local handlers = { }
- local process = false
- local root = false
- local result = false
- local r = false
- local definitions = false
- local classstyles = false
- local tagstyles = false
-
- local tags = {
- ["a"] = true,
- -- ["altgGlyph"] = true,
- -- ["altgGlyphDef"] = true,
- -- ["altgGlyphItem"] = true,
- -- ["animate"] = true,
- -- ["animateColor"] = true,
- -- ["animateMotion"] = true,
- -- ["animateTransform"] = true,
- ["circle"] = true,
- ["clipPath"] = true,
- -- ["color-profile"] = true,
- -- ["cursor"] = true,
- ["defs"] = true,
- -- ["desc"] = true,
- ["ellipse"] = true,
- -- ["filter"] = true,
- -- ["font"] = true,
- -- ["font-face"] = true,
- -- ["font-face-format"] = true,
- -- ["font-face-name"] = true,
- -- ["font-face-src"] = true,
- -- ["font-face-uri"] = true,
- -- ["foreignObject"] = true,
- ["g"] = true,
- -- ["glyph"] = true,
- -- ["glyphRef"] = true,
- -- ["hkern"] = true,
- ["image"] = true,
- ["line"] = true,
- ["linearGradient"] = true,
- ["marker"] = true,
- -- ["mask"] = true,
- -- ["metadata"] = true,
- -- ["missing-glyph"] = true,
- -- ["mpath"] = true,
- ["path"] = true,
- -- ["pattern"] = true,
- ["polygon"] = true,
- ["polyline"] = true,
- ["radialGradient"] = true,
- ["rect"] = true,
- -- ["script"] = true,
- -- ["set"] = true,
- ["stop"] = true,
- ["style"] = true,
- ["svg"] = true,
- -- ["switch"] = true,
- ["symbol"] = true,
- ["text"] = true,
- -- ["textPath"] = true,
- -- ["title"] = true,
- ["tspan"] = true,
- ["use"] = true,
- -- ["view"] = true,
- -- ["vkern"] = true,
- }
-
- local function handlechains(c)
- if tags[c.tg] then
- local at = c.at
- local dt = c.dt
- if at and dt then
- -- at["inkscape:connector-curvature"] = nil -- cleare entry and might prevent table growth
- local estyle = rawget(at,"style")
- if estyle and estyle ~= "" then
- for k, v in gmatch(estyle,"%s*([^:]+):%s*([^;]+);?") do
- at[k] = v
- end
- end
- local eclass = rawget(at,"class")
- if eclass and eclass ~= "" then
- for c in gmatch(eclass,"[^ ]+") do
- local s = classstyles[c]
- if s then
- for k, v in next, s do
- at[k] = v
- end
- end
- end
- end
- local tstyle = tagstyles[tag]
- if tstyle then
- for k, v in next, tstyle do
- at[k] = v
- end
- end
- if trace_path and pathtracer then
- for k, v in next, pathtracer do
- at[k] = v
- end
- end
- for i=1,#dt do
- local dti = dt[i]
- if type(dti) == "table" then
- handlechains(dti)
- end
- end
- end
- end
- end
-
- local handlestyle do
-
- -- It can also be CDATA but that is probably dealt with because we only
- -- check for style entries and ignore the rest. But maybe we also need
- -- to check a style at the outer level?
-
- local p_key = C((R("az","AZ","09","__","--")^1))
- local p_spec = P("{") * C((1-P("}"))^1) * P("}")
- local p_valid = Carg(1) * P(".") * p_key + Carg(2) * p_key
- local p_grab = ((p_valid * p_space^0 * p_spec / rawset) + p_space^1 + P(1))^1
-
- local fontspecification = css.fontspecification
-
- handlestyle = function(c)
- local s = xmltext(c)
- lpegmatch(p_grab,s,1,classstyles,tagstyles)
- for k, v in next, classstyles do
- local t = { }
- for k, v in gmatch(v,"%s*([^:]+):%s*([^;]+);?") do
- if k == "font" then
- local s = fontspecification(v)
- for k, v in next, s do
- t["font-"..k] = v
- end
- else
- t[k] = v
- end
- end
- classstyles[k] = t
- end
- for k, v in next, tagstyles do
- local t = { }
- for k, v in gmatch(v,"%s*([^:]+):%s*([^;]+);?") do
- if k == "font" then
- local s = fontspecification(v)
- for k, v in next, s do
- t["font-"..k] = v
- end
- else
- t[k] = v
- end
- end
- tagstyles[k] = t
- end
- end
-
- function handlers.style()
- -- ignore
- end
-
- end
-
- -- We can have root in definitions and then do a metatable lookup but use
- -- is not used that often I guess.
-
- local function locate(id)
- local res = definitions[id]
- if res then
- return res
- end
- local ref = gsub(id,"^url%(#(.-)%)$","%1")
- local ref = gsub(ref,"^#","")
- -- we can make a fast id lookup
- local res = xmlfirst(root,"**[@id='"..ref.."']")
- if res then
- definitions[id] = res
- end
- return res
- end
-
- -- also locate
-
- local function handleclippath(at)
- local clippath = at["clip-path"]
-
- if not clippath then
- return
- end
-
- local spec = definitions[clippath] or locate(clippath)
-
- -- do we really need thsi crap
- if not spec then
- local index = match(clippath,"(%d+)")
- if index then
- spec = xmlfirst(root,"clipPath["..tostring(tonumber(index) or 0).."]")
- end
- end
- -- so far for the crap
-
- if not spec then
- report("unknown clip %a",clippath)
- return
- elseif spec.tg ~= "clipPath" then
- report("bad clip %a",clippath)
- return
- end
-
- ::again::
- for c in xmlcollected(spec,"/(path|use|g)") do
- local tg = c.tg
- if tg == "use" then
- local ca = c.at
- local id = ca["xlink:href"]
- if id then
- spec = locate(id)
- if spec then
- local sa = spec.at
- setmetatableindex(sa,ca)
- if spec.tg == "path" then
- local d = sa.d
- if d then
- local p = grabpath(d)
- p.evenodd = sa["clip-rule"] == "evenodd"
- p.close = true
- return p, clippath
- else
- return
- end
- else
- goto again
- end
- end
- end
- -- break
- elseif tg == "path" then
- local ca = c.at
- local d = ca.d
- if d then
- local p = grabpath(d)
- p.evenodd = ca["clip-rule"] == "evenodd"
- p.close = true
- return p, clippath
- else
- return
- end
- else
- -- inherit?
- end
- end
- end
-
- local s_shade_linear = ' withshademethod "linear" '
- local s_shade_circular = ' withshademethod "circular" '
- local f_shade_step = formatters['withshadestep ( withshadefraction %N withshadecolors(%s,%s) )']
- local f_shade_one = formatters['withprescript "sh_center_a=%N %N"']
- local f_shade_two = formatters['withprescript "sh_center_b=%N %N"']
-
- local f_color = formatters['withcolor "%s"']
- local f_opacity = formatters['withtransparency (1,%N)']
- local f_pen = formatters['withpen pencircle scaled %N']
-
- -- todo: gradient unfinished
- -- todo: opacity but first we need groups in mp
-
- local function gradient(id)
- local spec = definitions[id] -- no locate !
- if spec then
- local kind = spec.tg
- local shade = nil
- local n = 1
- local a = spec.at
- if kind == "linearGradient" then
- shade = { s_shade_linear }
- --
- local x1 = rawget(a,"x1")
- local y1 = rawget(a,"y1")
- local x2 = rawget(a,"x2")
- local y2 = rawget(a,"y2")
- if x1 and y1 then
- n = n + 1 ; shade[n] = f_shade_one(asnumber_vx(x1),asnumber_vy(y1))
- end
- if x2 and y2 then
- n = n + 1 ; shade[n] = f_shade_one(asnumber_vx(x2),asnumber_vy(y2))
- end
- --
- elseif kind == "radialGradient" then
- shade = { s_shade_circular }
- --
- local cx = rawget(a,"cx") -- x center
- local cy = rawget(a,"cy") -- y center
- local r = rawget(a,"r" ) -- radius
- local fx = rawget(a,"fx") -- focal points
- local fy = rawget(a,"fy") -- focal points
- --
- if cx and cy then
- -- todo
- end
- if r then
- -- todo
- end
- if fx and fy then
- -- todo
- end
- else
- report("unknown gradient %a",id)
- return
- end
- -- local gu = a.gradientUnits
- -- local gt = a.gradientTransform
- -- local sm = a.spreadMethod
- local colora, colorb
- -- startcolor ?
- for c in xmlcollected(spec,"/stop") do
- local a = c.at
- local offset = rawget(a,"offset")
- local colorb = rawget(a,"stop-color")
- local opacity = rawget(a,"stop-opacity")
- if colorb then
- colorb = thecolor(colorb)
- end
- if not colora then
- colora = colorb
- end
- -- what if no percentage
-
- local fraction = offset and asnumber_r(offset)
- if not fraction then
- -- offset = tonumber(offset)
- -- for now
- fraction = xmlcount(spec,"/stop")/100
- end
-
- if colora and colorb and color_a ~= "" and color_b ~= "" then
- n = n + 1 ; shade[n] = f_shade_step(fraction,colora,colorb)
- end
-
- colora = colorb
- end
- return concat(shade," ")
- end
- end
-
- local function drawproperties(stroke,at,opacity)
- local p = at["stroke-width"]
- if p then
- p = f_pen(asnumber_r(p))
- end
- local d = at["stroke-dasharray"]
- if d == "none" then
- d = nil
- elseif d then
- local o = at["stroke-dashoffset"]
- if o and o ~= "none" then
- o = asnumber_r(o)
- else
- o = false
- end
- d = dashed(d,o)
- end
- local c = withcolor(stroke)
- local o = at["stroke-opacity"] or (opacity and at["opacity"])
- if o == "none" then
- o = nil
- elseif o then
- o = asnumber_r(o)
- if o and o ~= 1 then
- o = f_opacity(o)
- else
- o = nil
- end
- end
- return p, d, c, o
- end
-
- local s_opacity_start = "draw image ("
- local f_opacity_stop = formatters["setgroup currentpicture to boundingbox currentpicture withtransparency (1,%N)) ;"]
-
- local function sharedopacity(at)
- local o = at["opacity"]
- if o and o ~= "none" then
- o = asnumber_r(o)
- if o and o ~= 1 then
- return s_opacity_start, f_opacity_stop(o)
- end
- end
- end
-
- local function fillproperties(fill,at,opacity)
- local c = c ~= "none" and (gradient(fill) or withcolor(fill)) or nil
- local o = at["fill-opacity"] or (opacity and at["opacity"])
- if o and o ~= "none" then
- o = asnumber_r(o)
- if o == 1 then
- return c
- elseif o then
- return c, f_opacity(o), o == 0
- end
- end
- return c
- end
-
- -- todo: clip = [ auto | rect(llx,lly,urx,ury) ]
-
- local s_offset_start = "draw image ( "
- local f_offset_stop = formatters[") shifted (%N,%N) ;"]
- local s_rotation_start = "draw image ( "
- local f_rotation_stop = formatters[") rotatedaround((0,0),-angle((%N,%N))) ;"]
- local f_rotation_angle = formatters[") rotatedaround((0,0),-%N) ;"]
-
- local function offset(at)
- local x = asnumber_vx(rawget(at,"x"))
- local y = asnumber_vy(rawget(at,"y"))
- if x ~= 0 or y ~= 0 then
- return s_offset_start, f_offset_stop(x,y)
- end
- end
-
- local s_viewport_start = "draw image ("
- local s_viewport_stop = ") ;"
- local f_viewport_shift = formatters["currentpicture := currentpicture shifted (%03N,%03N);"]
- local f_viewport_scale = formatters["currentpicture := currentpicture xysized (%03N,%03N);"]
- local f_viewport_clip = formatters["clip currentpicture to (unitsquare xyscaled (%03N,%03N));"]
-
- local function viewport(x,y,w,h,noclip,scale)
- r = r + 1 ; result[r] = s_viewport_start
- return function()
- local okay = w ~= 0 and h ~= 0
- if okay and scale then
- r = r + 1 ; result[r] = f_viewport_scale(w,h)
- end
- if x ~= 0 or y ~= 0 then
- r = r + 1 ; result[r] = f_viewport_shift(-x,y)
- end
- if okay and not noclip then
- r = r + 1 ; result[r] = f_viewport_clip(w,-h)
- end
-
- r = r + 1 ; result[r] = s_viewport_stop
- end
- end
-
- -- maybe forget about defs and just always locate (and then backtrack
- -- over if needed)
-
- function handlers.defs(c)
- for c in xmlcollected(c,"/*") do
- local a = c.at
- if a then
- local id = rawget(a,"id")
- if id then
- definitions["#" .. id ] = c
- definitions["url(#" .. id .. ")"] = c
- end
- end
- end
- end
-
- function handlers.symbol(c)
- if uselevel == 0 then
- local id = rawget(c.at,"id")
- if id then
- definitions["#" .. id ] = c
- definitions["url(#" .. id .. ")"] = c
- end
- else
- handlers.g(c)
- end
- end
-
- local uselevel = 0
-
- function handlers.use(c)
- local at = c.at
- local id = rawget(at,"href") or rawget(at,"xlink:href") -- better a rawget
- local res = locate(id)
- if res then
- -- width height ?
- uselevel = uselevel + 1
- local boffset, eoffset = offset(at)
- local btransform, etransform, transform = handletransform(at)
-
- if boffset then
- r = r + 1 result[r] = boffset
- end
-
- -- local clippath = at.clippath
-
- if btransform then
- r = r + 1 result[r] = btransform
- end
-
- local _transform = transform
- local _clippath = clippath
- at["transform"] = false
- -- at["clip-path"] = false
-
- process(res,"/*")
-
- at["transform"] = _transform
- -- at["clip-path"] = _clippath
-
- if etransform then
- r = r + 1 ; result[r] = etransform
- end
-
- if eoffset then
- r = r + 1 result[r] = eoffset
- end
-
- uselevel = uselevel - 1
- else
- report("use: unknown definition %a",id)
- end
- end
-
- local f_no_draw = formatters['nodraw (%s)']
- local f_do_draw = formatters['draw (%s)']
- local f_no_fill_c = formatters['nofill (%s..cycle)']
- local f_do_fill_c = formatters['fill (%s..cycle)']
- local f_eo_fill_c = formatters['eofill (%s..cycle)']
- local f_no_fill_l = formatters['nofill (%s--cycle)']
- local f_do_fill_l = formatters['fill (%s--cycle)']
- local f_eo_fill_l = formatters['eofill (%s--cycle)']
- local f_do_fill = f_do_fill_c
- local f_eo_fill = f_eo_fill_c
- local f_no_fill = f_no_fill_c
- local s_clip_start = 'draw image ('
- local f_clip_stop_c = formatters[') ; clip currentpicture to (%s..cycle) ;']
- local f_clip_stop_l = formatters[') ; clip currentpicture to (%s--cycle) ;']
- local f_clip_stop = f_clip_stop_c
- local f_eoclip_stop_c = formatters[') ; eoclip currentpicture to (%s..cycle) ;']
- local f_eoclip_stop_l = formatters[') ; eoclip currentpicture to (%s--cycle) ;']
- local f_eoclip_stop = f_eoclip_stop_c
-
- -- could be shared and then beginobject | endobject
-
- local function flushobject(object,at,c,o)
- local btransform, etransform = handletransform(at)
- local cpath = handleclippath(at)
-
- if cpath then
- r = r + 1 ; result[r] = s_clip_start
- end
-
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
-
- r = r + 1 ; result[r] = f_do_draw(object)
-
- if c then
- r = r + 1 ; result[r] = c
- end
-
- if o then
- r = r + 1 ; result[r] = o
- end
-
- if etransform then
- r = r + 1 ; result[r] = etransform
- end
-
- r = r + 1 ; result[r] = ";"
-
- if cpath then
- local f_done = cpath.evenodd
- if cpath.curve then
- f_done = f_done and f_eoclip_stop_c or f_clip_stop_c
- else
- f_done = f_done and f_eoclip_stop_l or f_clip_stop_l
- end
- r = r + 1 ; result[r] = f_done(cpath[1])
- end
- end
-
- do
-
- local flush
-
- local f_linecap = formatters["interim linecap := %s ;"]
- local f_linejoin = formatters["interim linejoin := %s ;"]
- local f_miterlimit = formatters["interim miterlimit := %s ;"]
-
- local s_begingroup = "begingroup;"
- local s_endgroup = "endgroup;"
-
- local linecaps = { butt = "butt", square = "squared", round = "rounded" }
- local linejoins = { miter = "mitered", bevel = "beveled", round = "rounded" }
-
- local function startlineproperties(at)
- local cap = at["stroke-linecap"]
- local join = at["stroke-linejoin"]
- local limit = at["stroke-miterlimit"]
- cap = cap and linecaps [cap]
- join = join and linejoins[join]
- limit = limit and asnumber_r(limit)
- if cap or join or limit then
- r = r + 1 ; result[r] = s_begingroup
- if cap then
- r = r + 1 ; result[r] = f_linecap(cap)
- end
- if join then
- r = r + 1 ; result[r] = f_linejoin(join)
- end
- if limit then
- r = r + 1 ; result[r] = f_miterlimit(limit)
- end
- return function()
- at["stroke-linecap"] = false
- at["stroke-linejoin"] = false
- at["stroke-miterlimit"] = false
- r = r + 1 ; result[r] = s_endgroup
- at["stroke-linecap"] = cap
- at["stroke-linejoin"] = join
- at["stroke-miterlimit"] = limit
- end
- end
- end
-
- -- markers are a quite rediculous thing .. let's assume simple usage for now
-
- function handlers.marker()
- -- todo: is just a def too
- end
-
- -- kind of local svg ... so make a generic one
- --
- -- todo: combine more (offset+scale+rotation)
-
- local function makemarker(where,c,x1,y1,x2,y2,x3,y3)
- local at = c.at
- local refx = rawget(at,"refX")
- local refy = rawget(at,"refY")
- local width = rawget(at,"markerWidth")
- local height = rawget(at,"markerHeight")
- local view = rawget(at,"viewBox")
- local orient = rawget(at,"orient")
- -- local ratio = rawget(at,"preserveAspectRatio")
- local units = at["markerUnits"]
- local height = at["markerHeight"]
- local angx = 0
- local angy = 0
- local angle = 0
-
- if where == "beg" then
- if orient == "auto" then -- unchecked
- -- no angle
- angx = x2 - x3
- angy = y2 - y3
- elseif orient == "auto-start-reverse" then -- checked
- -- points to start
- angx = x3 - x2
- angy = y3 - y2
- elseif orient then -- unchecked
- angle = asnumber_r(orient)
- end
- elseif where == "end" then
- if orient == "auto" then -- unchecked
- -- no angle ?
- angx = x1 - x2
- angy = y1 - y2
- elseif orient == "auto-start-reverse" then -- unchecked
- -- points to end
- angx = x2 - x1
- angy = y2 - y1
- elseif orient then -- unchecked
- angle = asnumber_r(orient)
- end
- elseif orient then -- unchecked
- angle = asnumber_r(orient)
- end
-
- -- what wins: viewbox or w/h
-
- refx = asnumber_x(refx)
- refy = asnumber_y(refy)
-
- width = width and asnumber_x(width) or 3 -- defaults
- height = height and asnumber_y(height) or 3 -- defaults
-
- local x = 0
- local y = 0
- local w = width
- local h = height
-
- -- kind of like the main svg
-
- r = r + 1 ; result[r] = s_offset_start
-
- local wrapupviewport
--- todo : better viewbox code
- local xpct, ypct, rpct
- if view then
- x, y, w, h = handleviewbox(view)
- end
-
- if width ~= 0 then
- w = width
- end
- if height ~= 0 then
- h = height
- end
-
- if h then
- xpct = percentage_x
- ypct = percentage_y
- rpct = percentage_r
- percentage_x = w / 100
- percentage_y = h / 100
- percentage_r = (sqrt(w^2 + h^2) / sqrt(2)) / 100
- wrapupviewport = viewport(x,y,w,h,true,true) -- no clip
- end
-
- -- we can combine a lot here:
-
- local hasref = refx ~= 0 or refy ~= 0
- local hasrot = angx ~= 0 or angy ~= 0 or angle ~= 0
-
- local btransform, etransform, transform = handletransform(at)
-
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
-
- if hasrot then
- r = r + 1 ; result[r] = s_rotation_start
- end
-
- if hasref then
- r = r + 1 ; result[r] = s_offset_start
- end
-
- local _transform = transform
- at["transform"] = false
-
- handlers.g(c)
-
- at["transform"] = _transform
-
- if hasref then
- r = r + 1 ; result[r] = f_offset_stop(-refx,refy)
- end
-
- if hasrot then
- if angle ~= 0 then
- r = r + 1 ; result[r] = f_rotation_angle(angle)
- else
- r = r + 1 ; result[r] = f_rotation_stop(angx,angy)
- end
- end
-
- if etransform then
- r = r + 1 ; result[r] = etransform
- end
-
- if h then
- percentage_x = xpct
- percentage_y = ypct
- percentage_r = rpct
- if wrapupviewport then
- wrapupviewport()
- end
- end
- r = r + 1 ; result[r] = f_offset_stop(x2,y2)
-
- end
-
- local function addmarkers(list,begmarker,midmarker,endmarker)
- local n = #list
- if n > 3 then
- if begmarker then
- local m = locate(begmarker)
- if m then
- makemarker("beg",m,false,false,list[1],list[2],list[3],list[4])
- end
- end
- if midmarker then
- local m = locate(midmarker)
- if m then
- for i=3,n-2,2 do
- makemarker("mid",m,list[i-2],list[i-1],list[i],list[i+1],list[i+2],list[i+3])
- end
- end
- end
- if endmarker then
- local m = locate(endmarker)
- if m then
- makemarker("end",m,list[n-3],list[n-2],list[n-1],list[n],false,false)
- end
- end
- else
- -- no line
- end
- end
-
- local function flush(shape,dofill,at,list,begmarker,midmarker,endmarker)
-
- local fill = dofill and (at["fill"] or "black")
- local stroke = at["stroke"] or "none"
-
- local btransform, etransform = handletransform(at)
- local cpath = handleclippath(at)
-
- if cpath then
- r = r + 1 ; result[r] = s_clip_start
- end
-
- local has_stroke = stroke and stroke ~= "none"
- local has_fill = fill and fill ~= "none"
-
- local bopacity, eopacity
- if has_stroke and has_fill then
- bopacity, eopacity = sharedopacity(at)
- end
-
- if bopacity then
- r = r + 1 ; result[r] = bopacity
- end
-
- if has_fill then
- local color, opacity = fillproperties(fill,at,not has_stroke)
- local f_xx_fill = at["fill-rule"] == "evenodd" and f_eo_fill or f_do_fill
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
- r = r + 1 result[r] = f_xx_fill(shape)
- if color then
- r = r + 1 ; result[r] = color
- end
- if opacity then
- r = r + 1 ; result[r] = opacity
- end
- r = r + 1 ; result[r] = etransform or ";"
- end
-
- if has_stroke then
- local wrapup = startlineproperties(at)
- local pen, dashing, color, opacity = drawproperties(stroke,at,not has_fill)
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
- r = r + 1 ; result[r] = f_do_draw(shape)
- if pen then
- r = r + 1 ; result[r] = pen
- end
- if dashing then
- r = r + 1 ; result[r] = dashing
- end
- if color then
- r = r + 1 ; result[r] = color
- end
- if opacity then
- r = r + 1 ; result[r] = opacity
- end
- r = r + 1 ; result[r] = etransform or ";"
- --
- if list then
- addmarkers(list,begmarker,midmarker,endmarker)
- end
- --
- if wrapup then
- wrapup()
- end
- end
-
- if eopacity then
- r = r + 1 ; result[r] = eopacity
- end
-
- if cpath then
- r = r + 1 ; result[r] = (cpath.evenodd and f_eoclip_stop or f_clip_stop)(cpath[1])
- end
-
- end
-
- local f_rectangle = formatters['unitsquare xyscaled (%N,%N) shifted (%N,%N)']
- local f_rounded = formatters['roundedsquarexy(%N,%N,%N,%N) shifted (%N,%N)']
- local f_line = formatters['((%N,%N)--(%N,%N))']
- local f_ellipse = formatters['(fullcircle xyscaled (%N,%N) shifted (%N,%N))']
- local f_circle = formatters['(fullcircle scaled %N shifted (%N,%N))']
-
- function handlers.line(c)
- local at = c.at
- local x1 = rawget(at,"x1")
- local y1 = rawget(at,"y1")
- local x2 = rawget(at,"x2")
- local y2 = rawget(at,"y2")
-
- x1 = x1 and asnumber_vx(x1) or 0
- y1 = y1 and asnumber_vy(y1) or 0
- x2 = x2 and asnumber_vx(x2) or 0
- y2 = y2 and asnumber_vy(y2) or 0
-
- flush(f_line(x1,y1,x2,y2),false,at)
- end
-
- function handlers.rect(c)
- local at = c.at
- local width = rawget(at,"width")
- local height = rawget(at,"height")
- local x = rawget(at,"x")
- local y = rawget(at,"y")
- local rx = rawget(at,"rx")
- local ry = rawget(at,"ry")
-
- width = width and asnumber_x(width) or 0
- height = height and asnumber_y(height) or 0
- x = x and asnumber_vx(x) or 0
- y = y and asnumber_vy(y) or 0
-
- y = y - height
-
- if rx then rx = asnumber(rx) end
- if ry then ry = asnumber(ry) end
-
- if rx or ry then
- if not rx then rx = ry end
- if not ry then ry = rx end
- flush(f_rounded(width,height,rx,ry,x,y),true,at)
- else
- flush(f_rectangle(width,height,x,y),true,at)
- end
- end
-
- function handlers.ellipse(c)
- local at = c.at
- local cx = rawget(at,"cx")
- local cy = rawget(at,"cy")
- local rx = rawget(at,"rx")
- local ry = rawget(at,"ry")
-
- cx = cx and asnumber_vx(cx) or 0
- cy = cy and asnumber_vy(cy) or 0
- rx = rx and asnumber_r (rx) or 0
- ry = ry and asnumber_r (ry) or 0
-
- flush(f_ellipse(2*rx,2*ry,cx,cy),true,at)
- end
-
- function handlers.circle(c)
- local at = c.at
- local cx = rawget(at,"cx")
- local cy = rawget(at,"cy")
- local r = rawget(at,"r")
-
- cx = cx and asnumber_vx(cx) or 0
- cy = cy and asnumber_vy(cy) or 0
- r = r and asnumber_r (r) or 0
-
- flush(f_circle(2*r,cx,cy),true,at)
- end
-
- local f_lineto_z = formatters['(%N,%N)']
- local f_lineto_n = formatters['--(%N,%N)']
-
- local p_pair = p_optseparator * p_number_vx * p_optseparator * p_number_vy
- local p_open = Cc("(")
- local p_close = Carg(1) * P(true) / function(s) return s end
- local p_polyline = Cs(p_open * (p_pair / f_lineto_z) * (p_pair / f_lineto_n)^0 * p_close)
- local p_polypair = Ct(p_pair^0)
-
- local function poly(c,final)
- local at = c.at
- local points = rawget(at,"points")
- if points then
- local path = lpegmatch(p_polyline,points,1,final)
- local list = nil
- local begmarker = rawget(at,"marker-start")
- local midmarker = rawget(at,"marker-mid")
- local endmarker = rawget(at,"marker-end")
- if begmarker or midmarker or endmarker then
- list = lpegmatch(p_polypair,points)
- end
- flush(path,true,at,list,begmarker,midmarker,endmarker)
- end
- end
-
- function handlers.polyline(c) poly(c, ")") end
- function handlers.polygon (c) poly(c,"--cycle)") end
-
- local s_image_start = "draw image ("
- local s_image_stop = ") ;"
-
- function handlers.path(c)
- local at = c.at
- local d = rawget(at,"d")
- if d then
- local shape, l = grabpath(d)
- local fill = at["fill"] or "black"
- local stroke = at["stroke"] or "none"
- local n = #shape
-
- local btransform, etransform = handletransform(at)
- local cpath = handleclippath(at)
-
- if cpath then
- r = r + 1 ; result[r] = s_clip_start
- end
-
- -- todo: image (nicer for transform too)
-
- if fill and fill ~= "none" then
- local color, opacity = fillproperties(fill,at)
- local f_xx_fill = at["fill-rule"] == "evenodd"
- if shape.closed then
- f_xx_fill = f_xx_fill and f_eo_fill or f_do_fill
- elseif shape.curve then
- f_xx_fill = f_xx_fill and f_eo_fill_c or f_do_fill_c
- else
- f_xx_fill = f_xx_fill and f_eo_fill_l or f_do_fill_l
- end
- if n == 1 then
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
- r = r + 1 result[r] = f_xx_fill(shape[1])
- if color then
- r = r + 1 ; result[r] = color
- end
- if opacity then
- r = r + 1 ; result[r] = opacity
- end
- r = r + 1 ; result[r] = etransform or ";"
- else
- r = r + 1 ; result[r] = btransform or s_image_start
- for i=1,n do
- if i == n then
- r = r + 1 ; result[r] = f_xx_fill(shape[i])
- if color then
- r = r + 1 ; result[r] = color
- end
- if opacity then
- r = r + 1 ; result[r] = opacity
- end
- else
- r = r + 1 ; result[r] = f_no_fill(shape[i])
- end
- r = r + 1 ; result[r] = ";"
- end
- r = r + 1 ; result[r] = etransform or s_image_stop
- end
- end
-
- if stroke and stroke ~= "none" then
- local begmarker = rawget(at,"marker-start")
- local midmarker = rawget(at,"marker-mid")
- local endmarker = rawget(at,"marker-end")
- if begmarker or midmarker or endmarker then
- list = grablist(l)
- end
- local wrapup = startlineproperties(at)
- local pen, dashing, color, opacity = drawproperties(stroke,at)
- if n == 1 and not list then
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
- r = r + 1 result[r] = f_do_draw(shape[1])
- if pen then
- r = r + 1 ; result[r] = pen
- end
- if dashing then
- r = r + 1 ; result[r] = dashing
- end
- if color then
- r = r + 1 ; result[r] = color
- end
- if opacity then
- r = r + 1 ; result[r] = opacity
- end
- r = r + 1 result[r] = etransform or ";"
- else
- r = r + 1 result[r] = btransform or "draw image ("
- for i=1,n do
- r = r + 1 result[r] = f_do_draw(shape[i])
- if pen then
- r = r + 1 ; result[r] = pen
- end
- if dashing then
- r = r + 1 ; result[r] = dashing
- end
- if color then
- r = r + 1 ; result[r] = color
- end
- if opacity then
- r = r + 1 ; result[r] = opacity
- end
- r = r + 1 ; result[r] = ";"
- end
- if list then
- addmarkers(list,begmarker,midmarker,endmarker)
- end
- r = r + 1 ; result[r] = etransform or ") ;"
- end
- if wrapup then
- wrapup()
- end
- end
-
- if cpath then
- r = r + 1 ; result[r] = f_clip_stop(cpath[1])
- end
-
- end
- end
-
- end
-
- -- kind of special
-
- do
-
- -- some day:
- --
- -- specification = identifiers.jpg(data."string")
- -- specification.data = data
- -- inclusion takes from data
- -- specification.data = false
-
- local f_image = formatters[ [[figure("%s") xysized (%N,%N) shifted (%N,%N)]] ]
-
- local nofimages = 0
-
- function handlers.image(c)
- local at = c.at
- local im = rawget(at,"xlink:href")
- if im then
- local kind, data = match(im,"^data:image/([a-z]+);base64,(.*)$")
- if kind == "png" then
- -- ok
- elseif kind == "jpeg" then
- kind = "jpg"
- else
- kind = false
- end
- if kind and data then
- local w = rawget(at,"width")
- local h = rawget(at,"height")
- local x = rawget(at,"x")
- local y = rawget(at,"y")
- w = w and asnumber_x(w)
- h = h and asnumber_y(h)
- x = x and asnumber_vx(x) or 0
- y = y and asnumber_vy(y) or 0
- nofimages = nofimages + 1
- local name = "temp-svg-image-" .. nofimages .. "." .. kind
- local data = mime.decode("base64")(data)
- io.savedata(name,data)
- if not w or not h then
- local info = graphics.identifiers[kind](data,"string")
- if info then
- -- todo: keep aspect ratio attribute
- local xsize = info.xsize
- local ysize = info.ysize
- if not w then
- if not h then
- w = xsize
- h = ysize
- else
- w = (h / ysize) * xsize
- end
- else
- h = (w / xsize) * ysize
- end
- end
- end
- -- safeguard:
- if not w then w = h or 1 end
- if not h then h = w or 1 end
- luatex.registertempfile(name)
- -- done:
- flushobject(f_image(name,w,h,x,y - h),at)
- else
- -- nothing done
- end
- end
- end
-
- end
-
- -- these transform: g a text svg symbol
-
- do
-
- function handlers.a(c)
- process(c,"/*")
- end
-
- function handlers.g(c) -- much like flushobject so better split and share
- local at = c.at
-
- local btransform, etransform, transform = handletransform(at)
- local cpath, clippath = handleclippath(at)
-
- if cpath then
- r = r + 1 ; result[r] = s_clip_start
- end
-
- if btransform then
- r= r + 1 result[r] = btransform
- end
-
- local _transform = transform
- local _clippath = clippath
- at["transform"] = false
- at["clip-path"] = false
-
- process(c,"/*")
-
- at["transform"] = _transform
- at["clip-path"] = _clippath
-
- if etransform then
- r = r + 1 ; result[r] = etransform
- end
-
- if cpath then
- local f_done = cpath.evenodd
- if cpath.curve then
- f_done = f_done and f_eoclip_stop_c or f_clip_stop_c
- else
- f_done = f_done and f_eoclip_stop_l or f_clip_stop_l
- end
- r = r + 1 ; result[r] = f_done(cpath[1])
- end
- end
-
- -- this will never really work out
- --
- -- todo: register text in lua in mapping with id, then draw mapping unless overloaded
- -- using lmt_svglabel with family,style,weight,size,id passed
-
- -- nested tspans are messy: they can have displacements but in inkscape we also
- -- see x and y (inner and outer element)
-
- -- The size is a bit of an issue. I assume that the specified size relates to the
- -- designsize but we want to be able to use other fonts.
-
- do
-
- local f_styled = formatters["\\svgstyled{%s}{%s}{%s}{%s}"]
- local f_colored = formatters["\\svgcolored{%.3N}{%.3N}{%.3N}{"]
- local f_placed = formatters["\\svgplaced{%.3N}{%.3N}{}{"]
- local f_poschar = formatters["\\svgposchar{%.3N}{%.3N}{%s}"]
- local f_char = formatters["\\svgchar{%s}"]
-
- local f_scaled = formatters["\\svgscaled{%N}{%s}{%s}{%s}"]
- local f_normal = formatters["\\svgnormal{%s}{%s}{%s}"]
- local f_hashed = formatters["\\svghashed{%s}"]
-
- -- We move to the outer (x,y) and when we have an inner offset we
- -- (need to) compensate for that outer offset.
-
- -- local f_text_scaled_svg = formatters['(svgtext("%s") scaled %N shifted (%N,%N))']
- -- local f_text_normal_svg = formatters['(svgtext("%s") shifted (%N,%N))']
- -- local f_text_simple_svg = formatters['svgtext("%s")']
-
- local anchors = {
- ["start"] = "drt",
- ["end"] = "dflt",
- ["middle"] = "d",
- }
-
- local f_text_normal_svg = formatters['(textext.%s("%s") shifted (%N,%N))']
- local f_text_simple_svg = formatters['textext.%s("%s")']
-
- -- or just maptext
-
- local f_mapped_normal_svg = formatters['(svgtext("%s") shifted (%N,%N))']
- local f_mapped_simple_svg = formatters['svgtext("%s")']
-
- local cssfamily = css.family
- local cssstyle = css.style
- local cssweight = css.weight
- local csssize = css.size
-
- local usedfonts = setmetatableindex(function(t,k)
- local v = setmetatableindex("table")
- t[k] = v
- return v
- end)
-
- local p_texescape = lpegpatterns.texescape
-
- -- For now as I need it for my (some 1500) test files.
-
- local function checkedfamily(name)
- if find(name,"^.-verdana.-$") then
- name = "verdana"
- end
- return name
- end
-
- -- todo: only escape some chars and handle space
-
- local defaultsize = 10
-
- local function collect(t,c,x,y,size,scale,family,tx,ty)
- local at = c.at
- local ax = rawget(at,"x")
- local ay = rawget(at,"y")
- local dx = rawget(at,"dx")
- local dy = rawget(at,"dy")
- local v_fill = at["fill"]
- local v_family = at["font-family"]
- local v_style = at["font-style"]
- local v_weight = at["font-weight"]
- local v_size = at["font-size"]
- --
- ax = ax and asnumber_vx(ax) or x
- ay = ay and asnumber_vy(ay) or y
- dx = dx and asnumber_vx(dx) or 0
- dy = dy and asnumber_vy(dy) or 0
- --
- if v_family then v_family = cssfamily(v_family) end
- if v_style then v_style = cssstyle (v_style) end
- if v_weight then v_weight = cssweight(v_weight) end
- if v_size then v_size = csssize (v_size,factors) end
- --
- ax = ax - x
- ay = ay - y
- --
- local elayered = ax ~= 0 or ay ~= 0 or false
- local eplaced = dx ~= 0 or dy ~= 0 or false
-
- local usedsize, usedscaled
-
- if elayered then
- -- we're now at the outer level again so we need to scale
- -- back to the outer level values
- t[#t+1] = formatters["\\svgsetlayer{%0N}{%0N}{"](ax,-ay)
- usedsize = v_size or defaultsize
- usedscale = usedsize / defaultsize
- else
- -- we're nested so we can be scaled
- usedsize = v_size or size
- usedscale = (usedsize / defaultsize) / scale
- end
- --
- -- print("element ",c.tg)
- -- print(" layered ",elayered)
- -- print(" font size ",v_size)
- -- print(" parent size ",size)
- -- print(" parent scale",scale)
- -- print(" used size ",usedsize)
- -- print(" used scale ",usedscale)
- --
- if eplaced then
- t[#t+1] = f_placed(dx,dy)
- end
- --
- if not v_family then v_family = family end
- if not v_weight then v_weight = "normal" end
- if not v_style then v_style = "normal" end
- --
- if v_family then
- v_family = fonts.names.cleanname(v_family)
- v_family = checkedfamily(v_family)
- end
- --
- usedfonts[v_family][v_weight][v_style] = true
- --
--- if usedscale == 1 then
--- t[#t+1] = f_normal( v_family,v_weight,v_style)
--- else
- t[#t+1] = f_scaled(usedscale,v_family,v_weight,v_style)
--- end
- t[#t+1] = "{"
- --
- local ecolored = v_fill and v_fill ~= "" or false
- if ecolored then
- -- todo cmyk
- local r, g, b = colorcomponents(v_fill)
- if r and g and b then
- t[#t+1] = f_colored(r,g,b)
- else
- ecolored = false
- end
- end
- --
- local dt = c.dt
- local nt = #dt
- for i=1,nt do
- local di = dt[i]
- if type(di) == "table" then
- -- can be a tspan (should we pass dx too)
- collect(t,di,x,y,usedsize,usedscale,v_family)
- else
- if i == 1 then
- di = gsub(di,"^%s+","")
- end
- if i == nt then
- di = gsub(di,"%s+$","")
- end
- local chars = utfsplit(di)
- if svghash then
- di = f_hashed(svghash[di])
- elseif tx then
- for i=1,#chars do
- chars[i] = f_poschar(
- (tx[i] or 0) - x,
- (ty[i] or 0) - y,
- utfbyte(chars[i])
- )
- end
- di = "{" .. concat(chars) .. "}"
- else
- -- this needs to be texescaped ! and even quotes and newlines
- -- or we could register it but that's a bit tricky as we nest
- -- and don't know what we can expect here
- -- di = lpegmatch(p_texescape,di) or di
- for i=1,#chars do
- chars[i] = f_char(utfbyte(chars[i]))
- end
- di = concat(chars)
- end
- t[#t+1] = di
- end
- end
- --
- if ecolored then
- t[#t+1] = "}"
- end
- --
- t[#t+1] = "}"
- --
- if eplaced then
- t[#t+1] = "}"
- end
- if elayered then
- t[#t+1] = "}"
- end
- --
- return t
- end
-
- local s_startlayer = "\\svgstartlayer "
- local s_stoplayer = "\\svgstoplayer "
-
- function handlers.text(c)
- local only = fullstrip(xmltextonly(c))
- -- if metapost.processing() then
- local at = c.at
- local x = rawget(at,"x")
- local y = rawget(at,"y")
-
- local tx = asnumber_vx_t(x)
- local ty = asnumber_vy_t(y)
-
- x = tx[1] or 0 -- catch bad x/y spec
- y = ty[1] or 0 -- catch bad x/y spec
-
- local v_fill = at["fill"]
- if not v_fill or v_fill == "none" then
- v_fill = "black"
- end
- local color, opacity, invisible = fillproperties(v_fill,at)
- local anchor = anchors[at["text-anchor"] or "start"] or "drt"
- local r = metapost.remappedtext(only)
- if r then
- if x == 0 and y == 0 then
- only = f_mapped_simple_svg(r.index)
- else
- only = f_mapped_normal_svg(r.index,x,y)
- end
- flushobject(only,at,color,opacity)
- if trace_text then
- report("text: %s",only)
- end
- elseif not invisible then -- can be an option
- local scale = 1
- local textid = 0
- local result = { }
- local nx = #tx
- local ny = #ty
- --
- result[#result+1] = s_startlayer
- if nx > 1 or ny > 1 then
- concat(collect(result,c,x,y,defaultsize,1,"serif",tx,ty))
- else
- concat(collect(result,c,x,y,defaultsize,1,"serif"))
- end
- result[#result+1] = s_stoplayer
- result = concat(result)
- if x == 0 and y == 0 then
- result = f_text_simple_svg(anchor,result)
- else
- result = f_text_normal_svg(anchor,result,x,y)
- end
- flushobject(result,at,color,opacity)
- if trace_text then
- report("text: %s",result)
- end
- elseif trace_text then
- report("invisible text: %s",only)
- end
- -- elseif trace_text then
- -- report("ignored text: %s",only)
- -- end
- end
-
- function metapost.reportsvgfonts()
- for family, weights in sortedhash(usedfonts) do
- for weight, styles in sortedhash(weights) do
- for style in sortedhash(styles) do
- report("used font: %s-%s-%s",family,weight,style)
- end
- end
- end
- end
-
- statistics.register("used svg fonts",function()
- if next(usedfonts) then
- -- also in log file
- logs.startfilelogging(report,"used svg fonts")
- local t = { }
- for family, weights in sortedhash(usedfonts) do
- for weight, styles in sortedhash(weights) do
- for style in sortedhash(styles) do
- report("%s-%s-%s",family,weight,style)
- t[#t+1] = formatters["%s-%s-%s"](family,weight,style)
- end
- end
- end
- logs.stopfilelogging()
- return concat(t," ")
- end
- end)
-
- end
-
- function handlers.svg(c,x,y,w,h,noclip,notransform,normalize)
- local at = c.at
-
- local wrapupviewport
- local bhacked
- local ehacked
- local wd = w
- -- local ex, em
- local xpct, ypct, rpct
-
- local btransform, etransform, transform = handletransform(at)
-
- if trace then
- report("view: %s, xpct %N, ypct %N","before",percentage_x,percentage_y)
- end
-
- local viewbox = at.viewBox
-
- if viewbox then
- x, y, w, h = handleviewbox(viewbox)
- if trace then
- report("viewbox: x %N, y %N, width %N, height %N",x,y,w,h)
- end
- end
- if not w or not h or w == 0 or h == 0 then
- noclip = true
- end
- if h then
- --
- -- em = factors["em"]
- -- ex = factors["ex"]
- -- factors["em"] = em
- -- factors["ex"] = ex
- --
- xpct = percentage_x
- ypct = percentage_y
- rpct = percentage_r
- percentage_x = w / 100
- percentage_y = h / 100
- percentage_r = (sqrt(w^2 + h^2) / sqrt(2)) / 100
- if trace then
- report("view: %s, xpct %N, ypct %N","inside",percentage_x,percentage_y)
- end
- wrapupviewport = viewport(x,y,w,h,noclip)
- end
- -- todo: combine transform and offset here
-
- -- some fonts need this (bad transforms + viewbox)
- if v and normalize and w and wd and w ~= wd and w > 0 and wd > 0 then
- bhacked = s_wrapped_start
- ehacked = f_wrapped_stop(y or 0,wd/w)
- end
- if btransform then
- r = r + 1 ; result[r] = btransform
- end
- if bhacked then
- r = r + 1 ; result[r] = bhacked
- end
- local boffset, eoffset = offset(at)
- if boffset then
- r = r + 1 result[r] = boffset
- end
-
- at["transform"] = false
- at["viewBox"] = false
-
- process(c,"/*")
-
- at["transform"] = transform
- at["viewBox"] = viewbox
-
- if eoffset then
- r = r + 1 result[r] = eoffset
- end
- if ehacked then
- r = r + 1 ; result[r] = ehacked
- end
- if etransform then
- r = r + 1 ; result[r] = etransform
- end
- if h then
- --
- -- factors["em"] = em
- -- factors["ex"] = ex
- --
- percentage_x = xpct
- percentage_y = ypct
- percentage_r = rpct
- if wrapupviewport then
- wrapupviewport()
- end
- end
- if trace then
- report("view: %s, xpct %N, ypct %N","after",percentage_x,percentage_y)
- end
- end
-
- end
-
- process = function(x,p)
- for c in xmlcollected(x,p) do
- local tg = c.tg
- local h = handlers[c.tg]
- if h then
- h(c)
- end
- end
- end
-
- -- For huge inefficient files there can be lots of garbage to collect so
- -- maybe we should run the collector when a file is larger than say 50K.
-
- function metapost.svgtomp(specification,pattern,notransform,normalize)
- local mps = ""
- local svg = specification.data
- if type(svg) == "string" then
- svg = xmlconvert(svg)
- end
- if svg then
- local c = xmlfirst(svg,pattern or "/svg")
- if c then
- root = svg
- result = { }
- r = 0
- definitions = { }
- tagstyles = { }
- classstyles = { }
- colormap = specification.colormap
- for s in xmlcollected(c,"style") do -- can also be in a def, so let's play safe
- handlestyle(c)
- end
- handlechains(c)
- xmlinheritattributes(c) -- put this in handlechains
- handlers.svg (
- c,
- specification.x,
- specification.y,
- specification.width,
- specification.height,
- specification.noclip,
- notransform,
- normalize,
- specification.remap
- )
- if trace_result then
- report("result graphic:\n %\n t",result)
- end
- mps = concat(result," ")
- root = false
- result = false
- r = false
- definitions = false
- tagstyles = false
- classstyles = false
- colormap = false
- else
- report("missing svg root element")
- end
- else
- report("bad svg blob")
- end
- return mps
- end
-
-end
-
--- These helpers might move to their own module .. some day ... also they will become
--- a bit more efficient, because we now go to mp and back which is kind of redundant,
--- but for now it will do.
-
-do
-
- local bpfactor = number.dimenfactors.bp
-
- function metapost.includesvgfile(filename,offset) -- offset in sp
- if lfs.isfile(filename) then
- context.startMPcode("doublefun")
- context('draw lmt_svg [ filename = "%s", offset = %N ] ;',filename,(offset or 0)*bpfactor)
- context.stopMPcode()
- end
- end
-
- function metapost.includesvgbuffer(name,offset) -- offset in sp
- context.startMPcode("doublefun")
- context('draw lmt_svg [ buffer = "%s", offset = %N ] ;',name or "",(offset or 0)*bpfactor)
- context.stopMPcode()
- end
-
- interfaces.implement {
- name = "includesvgfile",
- actions = metapost.includesvgfile,
- arguments = { "string", "dimension" },
- }
-
- interfaces.implement {
- name = "includesvgbuffer",
- actions = metapost.includesvgbuffer,
- arguments = { "string", "dimension" },
- }
-
- function metapost.showsvgpage(data)
- local dd = data.data
- if not dd then
- local fn = data.filename
- dd = fn and table.load(fn)
- end
- if type(dd) == "table" then
- local comment = data.comment
- local offset = data.pageoffset
- local index = data.index
- local first = math.max(index or 1,1)
- local last = math.min(index or #dd,#dd)
- for i=first,last do
- local d = setmetatableindex( {
- data = dd[i],
- comment = comment and i or false,
- pageoffset = offset or nil,
- }, data)
- metapost.showsvgpage(d)
- end
- elseif data.method == "code" then
- context.startMPcode(doublefun)
- context(metapost.svgtomp(data))
- context.stopMPcode()
- else
- context.startMPpage { instance = "doublefun", offset = data.pageoffset or nil }
- context(metapost.svgtomp(data))
- local comment = data.comment
- if comment then
- context("draw boundingbox currentpicture withcolor .6red ;")
- context('draw textext.bot("\\strut\\tttf %s") ysized (10pt) shifted center bottomboundary currentpicture ;',comment)
- end
- context.stopMPpage()
- end
- end
-
- function metapost.typesvgpage(data)
- local dd = data.data
- if not dd then
- local fn = data.filename
- dd = fn and table.load(fn)
- end
- if type(dd) == "table" then
- local index = data.index
- if index and index > 0 and index <= #dd then
- data = dd[index]
- else
- data = nil
- end
- end
- if type(data) == "string" and data ~= "" then
- buffers.assign("svgpage",data)
- context.typebuffer ({ "svgpage" }, { option = "XML", strip = "yes" })
- end
- end
-
- function metapost.svgtopdf(data,...)
- local mps = metapost.svgtomp(data,...)
- if mps then
- -- todo: special instance, only basics needed
- local pdf = metapost.simple("metafun",mps,true,false,"svg")
- if pdf then
- return pdf
- else
- -- message
- end
- else
- -- message
- end
- end
-
-end
-
-do
-
- local runner = sandbox.registerrunner {
- name = "otfsvg2pdf",
- program = "context",
- template = "--batchmode --purgeall --runs=2 %filename%",
- reporter = report_svg,
- }
-
- -- By using an independent pdf file instead of pdf streams we can use resources and still
- -- cache. This is the old method updated. Maybe a future version will just do this runtime
- -- but for now this is the most efficient method.
-
- local decompress = gzip.decompress
- local compress = gzip.compress
-
- function metapost.svgshapestopdf(svgshapes,pdftarget,report_svg)
- local texname = "temp-otf-svg-to-pdf.tex"
- local pdfname = "temp-otf-svg-to-pdf.pdf"
- local tucname = "temp-otf-svg-to-pdf.tuc"
- local nofshapes = #svgshapes
- local pdfpages = { filename = pdftarget }
- local pdfpage = 0
- local t = { }
- local n = 0
- --
- os.remove(texname)
- os.remove(pdfname)
- os.remove(tucname)
- --
- if report_svg then
- report_svg("processing %i svg containers",nofshapes)
- statistics.starttiming(pdfpages)
- end
- --
- -- can be option:
- --
- -- n = n + 1 ; t[n] = "\\nopdfcompression"
- --
- n = n + 1 ; t[n] = "\\starttext"
- n = n + 1 ; t[n] = "\\setupMPpage[alternative=offset,instance=doublefun]"
- --
- for i=1,nofshapes do
- local entry = svgshapes[i]
- local data = entry.data
- if decompress then
- data = decompress(data) or data
- end
- local specification = {
- data = xmlconvert(data),
- x = 0,
- y = 1000,
- width = 1000,
- height = 1000,
- noclip = true,
- }
- for index=entry.first,entry.last do
- if not pdfpages[index] then
- pdfpage = pdfpage + 1
- pdfpages[index] = pdfpage
- local pattern = "/svg[@id='glyph" .. index .. "']"
- n = n + 1 ; t[n] = "\\startMPpage"
- n = n + 1 ; t[n] = metapost.svgtomp(specification,pattern,true,true) or ""
- n = n + 1 ; t[n] = "\\stopMPpage"
- end
- end
- end
- n = n + 1 ; t[n] = "\\stoptext"
- io.savedata(texname,concat(t,"\n"))
- runner { filename = texname }
- os.remove(pdftarget)
- file.copy(pdfname,pdftarget)
- if report_svg then
- statistics.stoptiming(pdfpages)
- report_svg("svg conversion time %s",statistics.elapsedseconds(pdfpages))
- end
- os.remove(texname)
- os.remove(pdfname)
- os.remove(tucname)
- return pdfpages
- end
-
- function metapost.svgshapestomp(svgshapes,report_svg)
- local nofshapes = #svgshapes
- local mpshapes = { }
- if report_svg then
- report_svg("processing %i svg containers",nofshapes)
- statistics.starttiming(mpshapes)
- end
- for i=1,nofshapes do
- local entry = svgshapes[i]
- local data = entry.data
- if decompress then
- data = decompress(data) or data
- end
- local specification = {
- data = xmlconvert(data),
- x = 0,
- y = 1000,
- width = 1000,
- height = 1000,
- noclip = true,
- }
- for index=entry.first,entry.last do
- if not mpshapes[index] then
- local pattern = "/svg[@id='glyph" .. index .. "']"
- local mpcode = metapost.svgtomp(specification,pattern,true,true) or ""
- if mpcode ~= "" and compress then
- mpcode = compress(mpcode) or mpcode
- end
- mpshapes[index] = mpcode
- end
- end
- end
- if report_svg then
- statistics.stoptiming(mpshapes)
- report_svg("svg conversion time %s",statistics.elapsedseconds(mpshapes))
- end
- return mpshapes
- end
-
- function metapost.svgglyphtomp(fontname,unicode)
- if fontname and unicode then
- local id = fonts.definers.internal { name = fontname }
- if id then
- local tfmdata = fonts.hashes.identifiers[id]
- if tfmdata then
- local properties = tfmdata.properties
- local svg = properties.svg
- local hash = svg and svg.hash
- local timestamp = svg and svg.timestamp
- if hash then
- local svgfile = containers.read(fonts.handlers.otf.svgcache,hash)
- local svgshapes = svgfile and svgfile.svgshapes
- if svgshapes then
- if type(unicode) == "string" then
- unicode = utfbyte(unicode)
- end
- local chardata = tfmdata.characters[unicode]
- local index = chardata and chardata.index
- if index then
- for i=1,#svgshapes do
- local entry = svgshapes[i]
- if index >= entry.first and index <= entry.last then
- local data = entry.data
- if data then
- local root = xml.convert(gzip.decompress(data) or data)
- return metapost.svgtomp (
- {
- data = root,
- x = 0,
- y = 1000,
- width = 1000,
- height = 1000,
- noclip = true,
- },
- "/svg[@id='glyph" .. index .. "']",
- true,
- true
- )
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-arrange.tex b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-arrange.tex
index e970ac450cd..ab638dde6f7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-arrange.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-arrange.tex
@@ -35,7 +35,7 @@
\doifdocumentargument {paperoffset} {
\definepapersize
- [offset=\getdocumentargument{paperoffset}]
+ [offset=\getdocumentargumentdefault{paperoffset}{0pt}]
}
\doifdocumentargumentelse {noduplex} {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-compare.tex b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-compare.tex
index ffa744013f5..c940270c8ab 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-compare.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-compare.tex
@@ -24,17 +24,17 @@
\starttext
\starttexdefinition unexpanded ShowBoth #1#2#3
- \startTEXpage
+ \startTEXpage[width=21cm]
\startoverlay
- {\externalfigure[#1][page=#3]}
- {\externalfigure[#2][page=#3]}
+ {\externalfigure[#1][page=#3,width=21cm]}
+ {\externalfigure[#2][page=#3,width=21cm]}
\stopoverlay
\stopTEXpage
\stoptexdefinition
\starttexdefinition unexpanded ShowPage #1#2
- \startTEXpage
- \externalfigure[#1][page=#2]
+ \startTEXpage[width=21cm]
+ \externalfigure[#1][page=#2,width=21cm]
\stopTEXpage
\stoptexdefinition
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-meaning.tex b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-meaning.tex
index 88b81ef041e..2ec66780eb5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-meaning.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-meaning.tex
@@ -31,19 +31,31 @@
\setupbodyfont
[dejavu]
-\def\showmeaning#1%
+\unexpanded\def\ShowMeaning#1%
{\ctxlua{logs.pushtarget("both")}%
\writestatus{meaning}{\strippedcsname#1}%
\writestring{}%
\writestring{\expandafter\meaning\begincsname#1\endcsname}%
\ctxlua{logs.poptarget()}}
+\unexpanded\def\ShowTokens#1%
+ {\ctxlua{logs.pushtarget("both")}%
+ \writestatus{tokens}{\strippedcsname#1}%
+ \writestring{}%
+ \ifcase\contextlmtxmode
+ \writestring{only supported in lmtx}%
+ \else
+ \expandafter\showluatokens\begincsname#1\endcsname
+ \fi
+ \ctxlua{logs.poptarget()}}
+
\starttext
\usemodule[setups-macros]
\startluacode
local h = tex.hashtokens()
+ local t = environment.arguments.tokens
local function showmeaning(str)
local h = interfaces.macros.collect(str)
@@ -54,7 +66,11 @@
local hi = h[i]
context.type(hi)
context.par()
- context.showmeaning(hi)
+ if t then
+ context.ShowTokens(hi)
+ else
+ context.ShowMeaning(hi)
+ end
end
context.page()
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-select.tex b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-select.tex
index 2f63f595513..61f58d61f0a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-select.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-select.tex
@@ -1,5 +1,3 @@
-% engine=luatex
-
%D \module
%D [ file=mtx-context-select,
%D version=2008.11.10, % about that time i started playing with this
@@ -31,11 +29,11 @@
\input mtx-context-common.tex
\setuppapersize
- [\getdocumentargumentdefault{paperformat_from}{A4}]
- [\getdocumentargumentdefault{paperformat_to}{A4}]
+ [\getdocumentargumentdefault{paperformat_paper}{A4}]
+ [\getdocumentargumentdefault{paperformat_print}{A4}]
\setuppaper
- [offset=\getdocumentargumentdefault{paperformat_to}{0pt}]
+ [offset=\getdocumentargumentdefault{paperoffset}{0pt}]
\setuplayout
[width=middle,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-timing.tex b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-timing.tex
index c545c768f97..db0d4c28322 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-timing.tex
+++ b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-timing.tex
@@ -19,14 +19,27 @@
\enablemode[no-timing] \usemodule[timing]
+\usemodule[article-basic]
+
\setuplayout
- [topspace=1cm,
- bottomspace=.5cm,
- header=0pt,
- width=middle,
- height=middle,
+ [tight]
+ [footer=15pt,
style=\tt]
+\setuplayout
+ [tight]
+
+\setupbodyfont
+ [10pt]
+
+% \setuplayout
+% [topspace=1cm,
+% bottomspace=.5cm,
+% header=0pt,
+% width=middle,
+% height=middle,
+% style=\tt]
+
\setupfootertexts
[\getdocumentfilename{1}-luatex-progress.lut \emdash\ \pagenumber]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkiv
index 99d252c6b67..d7921bcc290 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkiv
@@ -186,28 +186,28 @@
%D and that only the high level setup commands are used with language specific
%D interfaces.
-% \unexpanded\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
-% \unexpanded\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+% \protected\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+% \protected\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
+% \protected\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+% \protected\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+% \protected\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+% \protected\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
% \startinterface english
- \unexpanded\def\mult_interfaces_let #1#2{\expandafter \let\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_lete#1#2{\expandafter \let\csname#1#2\endcsname\empty}
- \unexpanded\def\mult_interfaces_def #1#2{\expandafter \def\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1#2\endcsname}
+ \protected\def\mult_interfaces_let #1#2{\expandafter \let\csname#1#2\endcsname}
+ \protected\def\mult_interfaces_lete#1#2{\expandafter \let\csname#1#2\endcsname\empty}
+ \protected\def\mult_interfaces_def #1#2{\expandafter \def\csname#1#2\endcsname}
+ \protected\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1#2\endcsname}
+ \protected\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1#2\endcsname}
+ \protected\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1#2\endcsname}
% \stopinterface
%D Do, we only interface the assignment definition:
-\unexpanded\def\mult_interfaces_adef#1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\protected\def\mult_interfaces_adef#1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
\startinterface english
- \unexpanded\def\mult_interfaces_adef#1#2{\expandafter \def\csname#1#2\endcsname}
+ \protected\def\mult_interfaces_adef#1#2{\expandafter \def\csname#1#2\endcsname}
\stopinterface
% the commented detokenized variant that backtracks ... needs testing usage first
@@ -226,7 +226,7 @@
\def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter}
-\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only)
+\protected\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only)
{\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing
\def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
\def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
@@ -238,7 +238,7 @@
\def#8##1{\begincsname#1#2:##1\endcsname}
\def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}}
-\unexpanded\def\installparameterhandler#1#2%
+\protected\def\installparameterhandler#1#2%
{\normalexpanded
{\mult_interfaces_install_parameter_handler
{\noexpand#1}% \??aa
@@ -251,18 +251,18 @@
\expandafter\noexpand\csname direct#2parameter\endcsname
\expandafter\noexpand\csname letfrom#2parameter\endcsname}} % strict#2parameter is gone
-\unexpanded\def\mult_interfaces_install_root_parameter_handler#1#2#3%
+\protected\def\mult_interfaces_install_root_parameter_handler#1#2#3%
{\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root
\def#3##1{\begincsname#1:##1\endcsname}}
-\unexpanded\def\installrootparameterhandler#1#2%
+\protected\def\installrootparameterhandler#1#2%
{\normalexpanded
{\mult_interfaces_install_root_parameter_handler
{\noexpand#1}% \??aa
\expandafter\noexpand\csname detokenizedroot#2parameter\endcsname
\expandafter\noexpand\csname root#2parameter\endcsname}}
-\unexpanded\def\mult_interfaces_install_parameter_hash_handler#1#2#3#4#5#6#7#8#9%
+\protected\def\mult_interfaces_install_parameter_hash_handler#1#2#3#4#5#6#7#8#9%
{\ifx#2\relax\let#2\empty\fi
\def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used?
\def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
@@ -271,9 +271,9 @@
\def#6{#1#2:}%
\def#7##1{#1##1:}%
\def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}%
- \unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}}
+ \protected\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}}
-\unexpanded\def\installparameterhashhandler#1#2%
+\protected\def\installparameterhashhandler#1#2%
{\expandafter\let\csname#2namespace\endcsname#1%
\normalexpanded
{\mult_interfaces_install_parameter_hash_handler
@@ -291,23 +291,23 @@
% todo: inline the def/let
-% \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
+% \protected\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
% {\ifx#2\relax\let#2\empty\fi
-% \unexpanded\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate)
-% \unexpanded\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate)
-% \unexpanded\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2
-% \unexpanded\def#6{\mult_interfaces_lete{#1#2:}}}% ##1
+% \protected\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate)
+% \protected\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate)
+% \protected\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2
+% \protected\def#6{\mult_interfaces_lete{#1#2:}}}% ##1
%
% \startinterface english
- \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
+ \protected\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
{\ifx#2\relax\let#2\empty\fi
- \unexpanded\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
- \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
- \unexpanded\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2
- \unexpanded\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1
+ \protected\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
+ \protected\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
+ \protected\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2
+ \protected\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1
% \stopinterface
-\unexpanded\def\installparametersethandler#1#2%
+\protected\def\installparametersethandler#1#2%
{\normalexpanded
{\mult_interfaces_install_parameter_set_handler
{\noexpand#1}% \??aa
@@ -323,20 +323,20 @@
\let\currentstyleparameter\empty
\let\currentcolorparameter\empty
-\unexpanded\def\mult_interfaces_install_style_and_color_handler#1#2#3#4%
- {\unexpanded\def#2##1##2% style color
+\protected\def\mult_interfaces_install_style_and_color_handler#1#2#3#4%
+ {\protected\def#2##1##2% style color
{\edef\currentstyleparameter{#1{##1}}% this name is public (can also set color e.g. in underline)
\ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi
\edef\currentcolorparameter{#1{##2}}% this name is public (so we do this after the style switch)
\ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}%
- \unexpanded\def#3##1% style
+ \protected\def#3##1% style
{\edef\currentstyleparameter{#1{##1}}% this name is public
\ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi}%
- \unexpanded\def#4##1% color
+ \protected\def#4##1% color
{\edef\currentcolorparameter{#1{##1}}% this name is public
\ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}}
-\unexpanded\def\installstyleandcolorhandler#1#2%
+\protected\def\installstyleandcolorhandler#1#2%
{\normalexpanded
{\mult_interfaces_install_style_and_color_handler
\expandafter\noexpand\csname #2parameter\endcsname
@@ -360,12 +360,12 @@
\def\getparentchain #1#2{\begincsname#1#2:\s!chain\endcsname}
\def\getcurrentparentchain#1#2{\begincsname#1#2:\s!chain\endcsname}
-% \unexpanded\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones
+% \protected\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones
% {\ifx#4\relax\let#4\empty\fi % see \defineregister
-% \unexpanded\def#2{\dotripleempty#5}%
+% \protected\def#2{\dotripleempty#5}%
% \newtoks#6%
% \newtoks#7%
-% \unexpanded\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
+% \protected\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
% {\let#9#4%
% \edef#4{##1}%
% \ifthirdargument
@@ -398,12 +398,12 @@
% \the#7%
% \let#4#9}}
-\unexpanded\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones
+\protected\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones
{\ifx#4\relax\let#4\empty\fi % see \defineregister
- \unexpanded\def#2{\dotripleempty#5}%
+ \protected\def#2{\dotripleempty#5}%
\newtoks#6%
\newtoks#7%
- \unexpanded\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
+ \protected\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
{\let#9#4%
\edef#4{##1}%
\ifthirdargument
@@ -435,7 +435,7 @@
\the#7%
\let#4#9}}
-\unexpanded\def\installdefinehandler#1#2#3%
+\protected\def\installdefinehandler#1#2#3%
{\normalexpanded
{\mult_interfaces_install_define_handler
{\noexpand#1}% \??aa
@@ -448,13 +448,13 @@
\expandafter\noexpand\csname current#2parent\endcsname
\expandafter\noexpand\csname saved_defined_#2\endcsname}}
-\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8#9%
+\protected\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8#9%
{\ifx#3\relax\let#3\empty\fi
- \unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
+ \protected\def#2{\dodoubleempty#4}%
+ \protected\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
\newtoks#5%
\newtoks#8%
- \unexpanded\def#4[##1][##2]% maybe helper
+ \protected\def#4[##1][##2]% maybe helper
{\let#7#3%
\ifsecondargument
\def#9####1% we will have a simple one as well
@@ -470,7 +470,7 @@
\let#3#7%
\the#8}}
-\unexpanded\def\installsetuphandler#1#2%
+\protected\def\installsetuphandler#1#2%
{\normalexpanded
{\mult_interfaces_install_setup_handler
{\noexpand#1}% \??aa
@@ -488,18 +488,18 @@
\let\doingrootsetnamed \plusthree % \setuplayout[name]
\let\doingrootsetroot \plusfour % \setuplayout
-\unexpanded\def\mult_interfaces_install_switch_setup_handler_a#1#2#3#4#5%
+\protected\def\mult_interfaces_install_switch_setup_handler_a#1#2#3#4#5%
{\ifx#3\relax\let#3\empty\fi
- \unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}}
+ \protected\def#2{\dodoubleempty#4}%
+ \protected\def#5{\mult_interfaces_get_parameters{#1#3:}}}
-% \unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
+% \protected\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
% {\newtoks#5%
% \newconstant#2%
% \newtoks#8%
% \newtoks#9%
% \ifx#6\relax\let#6\empty\fi
-% \unexpanded\def#4[##1][##2]% maybe helper
+% \protected\def#4[##1][##2]% maybe helper
% {\ifsecondargument % no commalist here
% % \setuplayout[whatever][key=value]
% \let#7#3%
@@ -542,13 +542,13 @@
% #2\zerocount % mode is always zero at the end
% \the#9}}
-\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
+\protected\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
{\newtoks#5%
\newconstant#2%
\newtoks#8%
\newtoks#9%
\ifx#6\relax\let#6\empty\fi
- \unexpanded\def#4[##1][##2]% maybe helper
+ \protected\def#4[##1][##2]% maybe helper
{\ifsecondargument % no commalist here
% \setuplayout[whatever][key=value]
\let#7#3%
@@ -590,7 +590,7 @@
#2\zerocount % mode is always zero at the end
\the#9}}
-\unexpanded\def\installswitchsetuphandler#1#2%
+\protected\def\installswitchsetuphandler#1#2%
{\normalexpanded
{\mult_interfaces_install_switch_setup_handler_a
{\noexpand#1}% \??aa
@@ -609,10 +609,10 @@
\expandafter\noexpand\csname everyswitch#2\endcsname
\expandafter\noexpand\csname everysetup#2root\endcsname}}
-\unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8#9%
+\protected\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8#9%
{\ifx#3\relax\let#3\empty\fi
- \unexpanded\def#2{\dotripleempty#4}%
- \unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}%
+ \protected\def#2{\dotripleempty#4}%
+ \protected\def#6{\mult_interfaces_get_parameters{#1#3:}}%
\newtoks#5%
\def#4[##1][##2][##3]%
{\let#8#3%
@@ -637,7 +637,7 @@
\fi\fi
\let#3#8}}
-\unexpanded\def\installautosetuphandler#1#2%
+\protected\def\installautosetuphandler#1#2%
{\normalexpanded
{\mult_interfaces_install_auto_setup_handler
{\noexpand#1}% \??aa
@@ -650,40 +650,40 @@
\expandafter\noexpand\csname saved_setup_current#2\endcsname
\expandafter\noexpand\csname nested_setup_current#2\endcsname}}
-\unexpanded\def\installbasicparameterhandler#1#2%
+\protected\def\installbasicparameterhandler#1#2%
{\installparameterhandler {#1}{#2}%
\installparameterhashhandler{#1}{#2}%
\installparametersethandler {#1}{#2}%
\installrootparameterhandler{#1}{#2}}
-\unexpanded\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
+\protected\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
{\installbasicparameterhandler{#1}{#2}%
\installautosetuphandler {#1}{#2}}
-\unexpanded\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
+\protected\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
{\installbasicparameterhandler{#1}{#2}%
\installautosetuphandler {#1}{#2}%
\installstyleandcolorhandler {#1}{#2}}
-\unexpanded\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self)
+\protected\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self)
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
\installsetuphandler {#1}{#2}%
\installstyleandcolorhandler {#1}{#2}}
-\unexpanded\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self)
+\protected\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self)
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
\installswitchsetuphandler {#1}{#2}%
\installstyleandcolorhandler {#1}{#2}}
-\unexpanded\def\installautocommandhandler#1#2#3% automatically defined cloned setups
+\protected\def\installautocommandhandler#1#2#3% automatically defines cloned setups
{\installbasicparameterhandler{#1}{#2}%
\installdefinehandler {#1}{#2}{#3}%
\installautosetuphandler {#1}{#2}%
\installstyleandcolorhandler {#1}{#2}}
-\unexpanded\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining
+\protected\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining
{\installbasicparameterhandler{#1}{#2}%
\installsetuphandler {#1}{#2}%
\installstyleandcolorhandler {#1}{#2}}
@@ -699,14 +699,14 @@
%D We don't need colons for such simple cases.
-\unexpanded\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4#5%
+\protected\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4#5%
%%{\def#3##1{\csname\ifcsname#1##1\endcsname#1##1\else\s!empty\fi\endcsname}%
{\def#3##1{\begincsname#1##1\endcsname}%
\def#4##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}%
% \def#4##1{\mult_interfaces_detokenize{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}}%
\def#5##1{\begincsname#1##1\endcsname}}
-\unexpanded\def\installdirectparameterhandler#1#2%
+\protected\def\installdirectparameterhandler#1#2%
{\normalexpanded
{\mult_interfaces_install_direct_parameter_handler
{\noexpand#1}%
@@ -715,13 +715,13 @@
\expandafter\noexpand\csname detokenized#2parameter\endcsname
\expandafter\noexpand\csname direct#2parameter\endcsname}}
-\unexpanded\def\mult_interfaces_install_direct_setup_handler#1#2#3#4#5%
- {\unexpanded\def#2{\dosingleempty#3}%
+\protected\def\mult_interfaces_install_direct_setup_handler#1#2#3#4#5%
+ {\protected\def#2{\dosingleempty#3}%
\newtoks#5%
\def#3[##1]{\mult_interfaces_get_parameters#1[##1]\the#5}%
\def#4{\mult_interfaces_get_parameters#1}}
-\unexpanded\def\installdirectsetuphandler#1#2%
+\protected\def\installdirectsetuphandler#1#2%
{\normalexpanded
{\mult_interfaces_install_direct_setup_handler
{\noexpand#1}% \??aa
@@ -730,21 +730,21 @@
\expandafter\noexpand\csname setupcurrent#2\endcsname % no \every (we use 'current' for consistency)
\expandafter\noexpand\csname everysetup#2\endcsname}}
-% \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
-% {\unexpanded\def#2{\mult_interfaces_def #1}%
-% \unexpanded\def#3{\mult_interfaces_edef#1}%
-% \unexpanded\def#4{\mult_interfaces_let #1}%
-% \unexpanded\def#5{\mult_interfaces_let #1\empty}}%
+% \protected\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
+% {\protected\def#2{\mult_interfaces_def #1}%
+% \protected\def#3{\mult_interfaces_edef#1}%
+% \protected\def#4{\mult_interfaces_let #1}%
+% \protected\def#5{\mult_interfaces_let #1\empty}}%
% \startinterface english
- \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
- {\unexpanded\def#2##1{\expandafter \def\csname#1##1\endcsname}%
- \unexpanded\def#3##1{\expandafter\edef\csname#1##1\endcsname}%
- \unexpanded\def#4##1{\expandafter \let\csname#1##1\endcsname}%
- \unexpanded\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}%
+ \protected\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
+ {\protected\def#2##1{\expandafter \def\csname#1##1\endcsname}%
+ \protected\def#3##1{\expandafter\edef\csname#1##1\endcsname}%
+ \protected\def#4##1{\expandafter \let\csname#1##1\endcsname}%
+ \protected\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}%
% \stopinterface
-\unexpanded\def\installdirectparametersethandler#1#2%
+\protected\def\installdirectparametersethandler#1#2%
{\normalexpanded
{\mult_interfaces_install_direct_parameter_set_handler
{\noexpand#1}% \??aa
@@ -755,13 +755,13 @@
\let\installdirectstyleandcolorhandler\installstyleandcolorhandler
-\unexpanded\def\installdirectcommandhandler#1#2%
+\protected\def\installdirectcommandhandler#1#2%
{\installdirectparameterhandler {#1}{#2}%
\installdirectsetuphandler {#1}{#2}%
\installdirectparametersethandler {#1}{#2}%
\installdirectstyleandcolorhandler{#1}{#2}}
-\unexpanded\def\installsetuponlycommandhandler#1#2%
+\protected\def\installsetuponlycommandhandler#1#2%
{\installdirectparameterhandler{#1}{#2}%
\installdirectsetuphandler {#1}{#2}%
}% maybe \installdirectparametersethandler {#1}{#2}%
@@ -789,15 +789,15 @@
% yes:\twoparameter{alpha}\par
% yes:\twoparameter{beta}\par
-\unexpanded\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance}
+\protected\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance}
{\expandafter\edef\csname\csname#1namespace\endcsname#2:\s!parent\endcsname{\csname#3namespace\endcsname#4}}
-\unexpanded\def\relateparameterhandlersbyns#1#2#3#4% {from} {instance} {to} {instance}
+\protected\def\relateparameterhandlersbyns#1#2#3#4% {from} {instance} {to} {instance}
{\expandafter\edef\csname#1#2:\s!parent\endcsname{#3#4}}
%D Here is another experiment:
-\unexpanded\def\installactionhandler#1%
+\protected\def\installactionhandler#1%
{\normalexpanded
{\mult_interfaces_install_action_handler
{#1}%
@@ -805,9 +805,9 @@
\expandafter\noexpand\csname setupcurrent#1\endcsname
\expandafter\noexpand\csname #1_action\endcsname}}
-% \unexpanded\def\mult_interfaces_install_action_handler#1#2#3#4%
-% {\unexpanded\expandafter\def\csname#1\endcsname{\dodoubleempty#4}%
-% \unexpanded\def#4[##1][##2]%
+% \protected\def\mult_interfaces_install_action_handler#1#2#3#4%
+% {\protected\expandafter\def\csname#1\endcsname{\dodoubleempty#4}%
+% \protected\def#4[##1][##2]%
% {\begingroup
% \ifsecondargument
% \edef#2{##1}%
@@ -823,9 +823,9 @@
% \directsetup{handler:action:#1}%
% \endgroup}}
-\unexpanded\def\mult_interfaces_install_action_handler#1#2#3#4%
- {\unexpanded\expandafter\def\csname#1\endcsname{\dodoubleempty#4}%
- \unexpanded\def#4[##1][##2]%
+\protected\def\mult_interfaces_install_action_handler#1#2#3#4%
+ {\protected\expandafter\def\csname#1\endcsname{\dodoubleempty#4}%
+ \protected\def#4[##1][##2]%
{\begingroup
\ifsecondargument
\edef#2{##1}%
@@ -846,7 +846,7 @@
% First we had, in tune with the regular system variables:
%
% \starttyping
-% \unexpanded\def\installnamespace#1{\setvalue{????#1}{@@@@#1}}
+% \protected\def\installnamespace#1{\setvalue{????#1}{@@@@#1}}
% \stoptyping
%
% The following variant is nicer and in principle faster but that gets unnoticed
@@ -880,7 +880,7 @@
\def\v_interfaces_prefix_template
{\number\c_mult_interfaces_n_of_namespaces>}
-\unexpanded\def\installnamespace#1% for modules and users
+\protected\def\installnamespace#1% for modules and users
{\ifcsname ????#1\endcsname
\writestatus\m!system{duplicate user namespace '#1'}\wait
\else
@@ -888,7 +888,7 @@
\expandafter\edef\csname ????#1\endcsname{\v_interfaces_prefix_template}%
\fi}
-\unexpanded\def\installcorenamespace#1%
+\protected\def\installcorenamespace#1%
{\ifcsname ??#1\endcsname
\writestatus\m!system{duplicate core namespace '#1'}\wait
\else
@@ -913,16 +913,16 @@
\letvalue\??dummy\empty
- \def\dummyparameter #1{\begincsname\??dummy#1\endcsname}
- \def\directdummyparameter #1{\begincsname\??dummy#1\endcsname}
-\unexpanded\def\setdummyparameter #1{\expandafter\def\csname\??dummy#1\endcsname}
-\unexpanded\def\setexpandeddummyparameter#1{\expandafter\edef\csname\??dummy#1\endcsname}
-\unexpanded\def\letdummyparameter #1{\expandafter\let\csname\??dummy#1\endcsname}
+ \def\dummyparameter #1{\begincsname\??dummy#1\endcsname}
+ \def\directdummyparameter #1{\begincsname\??dummy#1\endcsname}
+\protected\def\setdummyparameter #1{\expandafter\def\csname\??dummy#1\endcsname}
+\protected\def\setexpandeddummyparameter#1{\expandafter\edef\csname\??dummy#1\endcsname}
+\protected\def\letdummyparameter #1{\expandafter\let\csname\??dummy#1\endcsname}
-% \unexpanded\def\getdummyparameters
+% \protected\def\getdummyparameters
% {\mult_interfaces_get_parameters\??dummy}
-\unexpanded\def\getdummyparameters[#1%
+\protected\def\getdummyparameters[#1%
{\if\noexpand#1]%
\expandafter\gobbleoneargument
\else
@@ -977,7 +977,7 @@
%
% This is a user (module) command:
-\unexpanded\def\definenamespace
+\protected\def\definenamespace
{\dodoubleargument\mult_interfaces_define_name_space}
\def\mult_interfaces_define_name_space[#1][#2]% namespace settings
@@ -992,7 +992,7 @@
%D \showparentchain{@@am}{left}
%D \stoptyping
-\unexpanded\def\showparentchain#1#2%
+\protected\def\showparentchain#1#2%
{\writestatus\m!system{chain: [ \mult_interfaces_show_parent_chain{#1#2}]}}
% \def\mult_interfaces_show_parent_chain#1%
@@ -1010,7 +1010,7 @@
%D Another helper (needs to be applied):
-\unexpanded\def\doifelsecommandhandler#1#2% namespace name
+\protected\def\doifelsecommandhandler#1#2% namespace name
{\ifcsname#1#2:\s!parent\endcsname
\expandafter\firstoftwoarguments
\else
@@ -1019,14 +1019,14 @@
\let\doifcommandhandlerelse\doifelsecommandhandler
-\unexpanded\def\doifcommandhandler#1#2% namespace name
+\protected\def\doifcommandhandler#1#2% namespace name
{\ifcsname#1#2:\s!parent\endcsname
\expandafter\firstofoneargument
\else
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifnotcommandhandler#1#2% namespace name
+\protected\def\doifnotcommandhandler#1#2% namespace name
{\ifcsname#1#2:\s!parent\endcsname
\expandafter\gobbleoneargument
\else
@@ -1077,7 +1077,7 @@
\def\s!double{double}
\def\s!triple{triple}
-% \unexpanded\def\syst_helpers_double_empty#1#2#3%
+% \protected\def\syst_helpers_double_empty#1#2#3%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_double_empty_one_yes_mult#2#3}%
@@ -1105,17 +1105,17 @@
% \def\syst_helpers_double_empty_one_spaced_mult#1#2{#1[{#2}] }
% \def\syst_helpers_double_empty_one_normal_mult#1#2{#1[{#2}]}
%
-% \unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8%
+% \protected\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8%
% {\ifx#3\relax\let#3\empty\fi
-% \unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
+% \protected\def#5{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
% \newtoks#4%
% \newtoks#7%
% \edef\m_mult_interface_setup{\csstring#2_}%
-% \unexpanded\edef#2{\syst_helpers_double_empty
+% \protected\edef#2{\syst_helpers_double_empty
% \csname\m_mult_interface_setup\s!simple\endcsname
% \csname\m_mult_interface_setup\s!single\endcsname
% \csname\m_mult_interface_setup\s!double\endcsname}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!double\endcsname[##1][##2]%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!double\endcsname[##1][##2]%
% {\let#6#3%
% \def#8####1% we will have a simple one as well
% {\edef#3{####1}%
@@ -1124,21 +1124,21 @@
% \processcommalist[##1]#8%
% \let#3#6%
% \the#7}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!single\endcsname[##1]%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!single\endcsname[##1]%
% {\let#6#3%
% \let#3\empty
% \mult_interfaces_get_parameters{#1:}[##1]%
% \the#4%
% \let#3#6%
% \the#7}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!simple\endcsname%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!simple\endcsname%
% {\let#6#3%
% \let#3\empty
% \the#4%
% \let#3#6%
% \the#7}}
-% \unexpanded\def\installsetuphandler#1#2%
+% \protected\def\installsetuphandler#1#2%
% {\normalexpanded
% {\mult_interfaces_install_setup_handler
% {\noexpand#1}% \??aa
@@ -1150,7 +1150,7 @@
% \expandafter\noexpand\csname everysetup#2root\endcsname
% \expandafter\noexpand\csname nested_setup_current#2\endcsname}}
%
-% \unexpanded\def\syst_helpers_triple_empty#1#2#3#4%
+% \protected\def\syst_helpers_triple_empty#1#2#3#4%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_triple_empty_one_yes_mult#2#3#4}%
@@ -1196,17 +1196,17 @@
% \def\syst_helpers_triple_empty_three_spaced_mult#1#2#3{#1[{#2}][{#3}] }
% \def\syst_helpers_triple_empty_three_normal_mult#1#2#3{#1[{#2}][{#3}]}
%
-% \unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8%
+% \protected\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8%
% {\ifx#3\relax\let#3\empty\fi
-% \unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}%
+% \protected\def#5{\mult_interfaces_get_parameters{#1#3:}}%
% \newtoks#4%
% \edef\m_mult_interface_setup{\csstring#2_}%
-% \unexpanded\edef#2{\syst_helpers_triple_empty
+% \protected\edef#2{\syst_helpers_triple_empty
% \csname\m_mult_interface_setup\s!simple\endcsname
% \csname\m_mult_interface_setup\s!single\endcsname
% \csname\m_mult_interface_setup\s!double\endcsname
% \csname\m_mult_interface_setup\s!triple\endcsname}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!triple\endcsname[##1][##2][##3]%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!triple\endcsname[##1][##2][##3]%
% {\let#7#3%
% \def#8####1%
% {\edef#3{####1}%
@@ -1215,7 +1215,7 @@
% \the#4}%
% \processcommalist[##1]#8%
% \let#3#7}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!double\endcsname[##1][##2]%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!double\endcsname[##1][##2]%
% {\let#7#3%
% \def#8####1%
% {\edef#3{####1}%
@@ -1224,19 +1224,19 @@
% \the#4}%
% \processcommalist[##1]#8%
% \let#3#7}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!single\endcsname[##1]%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!single\endcsname[##1]%
% {\let#7#3%
% \let#3\empty
% \mult_interfaces_get_parameters{#1:}[##1]%
% \the#4%
% \let#3#7}%
-% \unexpanded\expandafter\def\csname\m_mult_interface_setup\s!simple\endcsname%
+% \protected\expandafter\def\csname\m_mult_interface_setup\s!simple\endcsname%
% {\let#7#3%
% \let#3\empty
% \the#4%
% \let#3#7}}
%
-% \unexpanded\def\installautosetuphandler#1#2%
+% \protected\def\installautosetuphandler#1#2%
% {\normalexpanded
% {\mult_interfaces_install_auto_setup_handler
% {\noexpand#1}% \??aa
@@ -1266,30 +1266,30 @@
\let\c_mult_set\relax
-\unexpanded\def\mult_interfaces_install_definition_set#1#2#3#4#5#6#7%
+\protected\def\mult_interfaces_install_definition_set#1#2#3#4#5#6#7%
{\newcount#3%
\let#6\empty
- \unexpanded\def#2%
+ \protected\def#2%
{\expandafter\let\expandafter\c_mult_set\csname #1_t_#6\endcsname
\ifx\c_mult_set\relax
\expandafter\newtoks\c_mult_set
\expandafter\let\csname #1_t_#6\endcsname\c_mult_set
\fi}
- \unexpanded\def#4##1%
+ \protected\def#4##1%
{\pushmacro#6%
\advance#3\plusone
\edef#6{##1}%
\unprotect}%
- \unexpanded\def#5%
+ \protected\def#5%
{\protect
\advance#3\minusone
\popmacro#6}%
- \unexpanded\def#7##1%
+ \protected\def#7##1%
{\edef#6{##1}%
#2%
\the\c_mult_set\relax}}
-\unexpanded\def\installdefinitionset#1#2%
+\protected\def\installdefinitionset#1#2%
{\normalexpanded
{\mult_interfaces_install_definition_set
{\noexpand#1}% \??aa
@@ -1300,13 +1300,13 @@
\expandafter\noexpand\csname current#2\endcsname
\expandafter\noexpand\csname use#2\endcsname}}
-\unexpanded\def\mult_interfaces_install_definition_set_member#1#2#3#4#5#6#7#8#9% no everysetups etc
+\protected\def\mult_interfaces_install_definition_set_member#1#2#3#4#5#6#7#8#9% no everysetups etc
{\let#5#2%
- \unexpanded\def#2%
+ \protected\def#2%
{\ifcase#4\relax\expandafter#5\else\expandafter#6\fi}%
- \unexpanded\def#6%
+ \protected\def#6%
{\dodoubleempty#7}%
- \unexpanded\def#7[##1][##2]%
+ \protected\def#7[##1][##2]%
{\ifsecondargument
%#3\c_mult_set\expandafter{\the\c_mult_set#9[##1][##2]}%
#3\toksapp\c_mult_set{#9[##1][##2]}%
@@ -1315,7 +1315,7 @@
#3\toksapp\c_mult_set{#8[##1]}%
\fi\fi}}
-\unexpanded\def\installdefinitionsetmember#1#2#3#4%
+\protected\def\installdefinitionsetmember#1#2#3#4%
{\normalexpanded
{\mult_interfaces_install_definition_set_member
{\noexpand#3}% \??aa
@@ -1330,13 +1330,13 @@
%D Another experiment:
-\unexpanded\def\mult_interfaces_install_parent_injector#1#2#3#4%
- {\unexpanded\def#4##1%
+\protected\def\mult_interfaces_install_parent_injector#1#2#3#4%
+ {\protected\def#4##1%
{\ifx#3\empty
\expandafter\def\csname#1#2:\s!parent\endcsname{#1##1}%
\fi}}
-\unexpanded\def\installparentinjector#1#2%
+\protected\def\installparentinjector#1#2%
{\normalexpanded{\mult_interfaces_install_parent_injector
{\noexpand#1}%
\expandafter\noexpand\csname current#2\endcsname
@@ -1346,7 +1346,7 @@
% Faster but not used that much to make a dent in performance. But, because it's
% cleaner anyway and also gives less tracing, we apply it a few times.
-\unexpanded\def\syst_helpers_install_macro_stack#1#2#3%
+\protected\def\syst_helpers_install_macro_stack#1#2#3%
{\xdef\m_syst_helpers_push_macro{\csstring#1}%
\ifcsname#3\m_syst_helpers_push_macro\endcsname\else
\expandafter\newcount\csname#3\m_syst_helpers_push_macro\endcsname
@@ -1362,23 +1362,23 @@
\noexpand\csname\m_syst_helpers_push_macro\noexpand\the\csname#3\m_syst_helpers_push_macro\endcsname\endcsname}%
\fi}
-\unexpanded\def\installmacrostack #1{\syst_helpers_install_macro_stack#1\let \??localpushedmacro }
-\unexpanded\def\installglobalmacrostack#1{\syst_helpers_install_macro_stack#1\glet\??globalpushedmacro}
+\protected\def\installmacrostack #1{\syst_helpers_install_macro_stack#1\let \??localpushedmacro }
+\protected\def\installglobalmacrostack#1{\syst_helpers_install_macro_stack#1\glet\??globalpushedmacro}
% \unprotect
%
% \installcorenamespace {test} \installcommandhandler \??test {test} \??test
-% \unexpanded\def\TestMeA[#1]%
+% \protected\def\TestMeA[#1]%
% {\edef\currenttest{#1}
% \edef\p_before{\testparameter\c!before}%
% \ifx\p_before\empty \relax \else \relax \fi}
-% \unexpanded\def\TestMeB[#1]%
+% \protected\def\TestMeB[#1]%
% {\edef\currenttest{#1}
% \doifelsenothing{\testparameter\c!before}\relax\relax}
-% \unexpanded\def\TestMeC[#1]%
+% \protected\def\TestMeC[#1]%
% {\edef\currenttest{#1}
% \expandafter\expandafter\expandafter\ifx\testparameter\c!before\empty \relax \else \relax \fi}
-% \unexpanded\def\TestMeD[#1]%
+% \protected\def\TestMeD[#1]%
% {\edef\currenttest{#1}
% \doubleexpandafter\ifx\testparameter\c!before\empty \relax \else \relax \fi}
%
@@ -1396,7 +1396,7 @@
% only gain a few milliseconds:
%
% \starttyping
-% \unexpanded\def\foo#1{[foo:#1]}
+% \protected\def\foo#1{[foo:#1]}
%
% \installcommalistprocessor {foo} \foo
% \installcommalistprocessorcommand \processfoolist \foo
@@ -1413,7 +1413,7 @@
% \processfoolist[{x,y,z}]\par
% \processcommalist[{x,y,z}]\foo\blank
%
-% \unexpanded\def\foo#1{}
+% \protected\def\foo#1{}
%
% \testfeatureonce{400000}{\processfoolist [fixed,middle,bar]} \elapsedtime\quad
%%\testfeatureonce{400000}{\commalistprocessor{foo}[fixed,middle,bar]} \elapsedtime\quad
@@ -1434,46 +1434,46 @@
\installcorenamespace{commalistprocessorpickup}
\installcorenamespace{commalistprocessorfinish}
-\unexpanded\def\installcommalistprocessor#1#2% 8 macro names overhead
+\protected\def\installcommalistprocessor#1#2% 8 macro names overhead
{\let\nexttoken\relax
- \unexpanded\expandafter\edef\csname\??commalistprocessor#1\endcsname[%
+ \protected\expandafter\edef\csname\??commalistprocessor#1\endcsname[%
{\futurelet\nexttoken\csname\??commalistprocessorcheck#1\endcsname}%
- \unexpanded\expandafter\edef\csname\??commalistprocessorcheck#1\endcsname
+ \protected\expandafter\edef\csname\??commalistprocessorcheck#1\endcsname
{\noexpand\ifx\nexttoken]%
\noexpand\expandafter\noexpand\gobblethreearguments
\noexpand\else
\noexpand\expandafter\csname\??commalistprocessorwrap#1\endcsname
\noexpand\fi
\relax}% this one preserved the next {}
- \unexpanded\expandafter\edef\csname\??commalistprocessorwrap#1\endcsname##1]%
+ \protected\expandafter\edef\csname\??commalistprocessorwrap#1\endcsname##1]%
{\csname\??commalistprocessorfirst#1\endcsname##1,]\relax}%
- \unexpanded\expandafter\edef\csname\??commalistprocessorfirst#1\endcsname##1% picks up \relax
+ \protected\expandafter\edef\csname\??commalistprocessorfirst#1\endcsname##1% picks up \relax
{\csname\??commalistprocessornext#1\endcsname}%
- \unexpanded\expandafter\edef\csname\??commalistprocessornext#1\endcsname
+ \protected\expandafter\edef\csname\??commalistprocessornext#1\endcsname
{\noexpand\ifx\nexttoken\noexpand\blankspace
\noexpand\expandafter\csname\??commalistprocessorspace#1\endcsname
\noexpand\else
\noexpand\expandafter\csname\??commalistprocessorfinish#1\endcsname
\noexpand\fi}%
- \unexpanded\expandafter\edef\csname\??commalistprocessorfinish#1\endcsname
+ \protected\expandafter\edef\csname\??commalistprocessorfinish#1\endcsname
{\noexpand\ifx\nexttoken]%
\noexpand\expandafter\noexpand\gobbleoneargument
\noexpand\else
\noexpand\expandafter\csname\??commalistprocessoraction#1\endcsname
\noexpand\fi}%
- \unexpanded\expandafter\edef\csname\??commalistprocessoraction#1\endcsname##1,%
+ \protected\expandafter\edef\csname\??commalistprocessoraction#1\endcsname##1,%
{\noexpand#2{##1}%
\futurelet\nexttoken\csname\??commalistprocessornext#1\endcsname}%
\let\next\:%
- \unexpanded\edef \:{\csname\??commalistprocessorspace#1\endcsname}%
- \unexpanded\expandafter\edef\: {\futurelet\nexttoken\csname\??commalistprocessornext#1\endcsname}%
+ \protected\edef \:{\csname\??commalistprocessorspace#1\endcsname}%
+ \protected\expandafter\edef\: {\futurelet\nexttoken\csname\??commalistprocessornext#1\endcsname}%
\let\:\next}
-\unexpanded\def\installcommalistprocessorcommand#1#2% \processor \action
+\protected\def\installcommalistprocessorcommand#1#2% \processor \action
{\edef\p_name{\csstring#2}%
\installcommalistprocessor\p_name{#2}%
\expandafter\let\expandafter#1\csname\??commalistprocessor\p_name\endcsname}
-\unexpanded\def\commalistprocessor#1{\csname\??commalistprocessor#1\endcsname}
+\protected\def\commalistprocessor#1{\csname\??commalistprocessor#1\endcsname}
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkxl b/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkxl
deleted file mode 100644
index 3fed8c26e68..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-aux.mkxl
+++ /dev/null
@@ -1,1170 +0,0 @@
-%D \module
-%D [ file=mult-aux,
-%D version=2010.08.2,
-%D title=\CONTEXT\ Multilingual Macros,
-%D subtitle=Helpers,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D A generalization of \MKIV-like inheritance. Just something to play with
-%D (interface might change). The code here evolved in an email exchange between me
-%D and Wolgang Schuster.
-
-\writestatus{loading}{ConTeXt Multilingual Macros / Helpers}
-
-\registerctxluafile{mult-aux}{}
-
-\unprotect
-
-\edef\??empty{\Uchar25} \letvalue{\Uchar25}\empty % hex 19
-
-% \edef\s!parent{\Uchar29} % inlining is ugly, a tiny bit faster, but neglectable on a run
-
-%D \starttyping
-%D \unprotect
-%D \def\????aa{@@@@aa}
-%D
-%D \installparameterhandler \????aa {whatever}
-%D \installsetuphandler \????aa {whatever}
-%D \installdefinehandler \????aa {whatever} \????aa % #3 == defaultroot
-%D \installfontandcolorhandler\????aa {whatever}
-%D
-%D % \installcommandhandler \????aa {whatever} \????aa
-%D \protect
-%D
-%D % \whateverparameter \c!test
-%D % \whateverparameterhash \c!test
-%D % \namedwhateverparameter \mycurrentwhatever \c!test
-%D % \usewhateverstyleandcolor \c!style \c!color
-%D % \everydefinewhatever (sets \currentwhatever)
-%D % \everypresetwhatever (can be used to reset parameters as we can redefine)
-%D % \everysetupwhatever (sets \currentwhatever)
-%D
-%D \starttext
-%D \definewhatever[first] \definewhatever[second][first]
-%D test: \def\currentwhatever{first} \whateverparameter{method} \par
-%D \setupwhatever [method=unset] test: \def\currentwhatever{first} \whateverparameter{method} \par
-%D \setupwhatever[first] [method=first] test: \def\currentwhatever{first} \whateverparameter{method} \par
-%D test: \def\currentwhatever{second} \whateverparameter{method} \par
-%D \setupwhatever[second][method=second] test: \def\currentwhatever{second} \whateverparameter{method} \par
-%D \stoptext
-%D \stoptyping
-
-% problem: every* could clash
-%
-% There can be less {} in the following definitions if we assume \??aa and \c!somecs
-%
-% todo: \def\detokenized...parameter#1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2\endcsname}} % always root
-%
-% it might be more efficient to do this at the lua and
-%
-% watch the push/pop and predefinition of current .. this is needed for nested
-% definitions and overloaded defines using the predefined one
-
-% todo: add (relaxed) postsetup and postdefine hooks, just after the everys
-
-%D Start of experimental code: especially tables can have many assignments and
-%D although most time is spent in the typesetting anyway, we can squeeze out a
-%D little bit. Of course having 500 rows of 50 columns each with some setting does
-%D not happen that often. One should keep in mind that in the average document
-%D having some 500 assignments is no exception but there we're talking of
-%D neglectable runtime for them. Of course in the definitions below there is no real
-%D gain, only in the generated \setup* commands. Another situation with many
-%D assignments is \XML\ where we can pass attributes and normally don't do testing
-%D of them making sense.
-%
-% \testfeatureonce{100000}{\getparameters[bla][a=111,b=222,c=333]}% 1.669s
-% \testfeatureonce{100000}{\mult_interfaces_get_parameters{bla} [a=111,b=222,c=333]}% 1.529s
-% \testfeatureonce{100000}{\def\m_mult_interfaces_namespace{bla}\mult_interfaces_get_parameters_indeed[a=111,b=222,c=333]}% 1.466s
-
-\let\m_mult_interfaces_namespace\empty
-
-\def\mult_interfaces_get_parameters#1[#2%
- {\if\noexpand#2]%
- \expandafter\gobbleoneargument
- \else
- \def\m_mult_interfaces_namespace{#1}%
- \expandafter\mult_interfaces_get_parameters_indeed
- \fi#2}
-
-\def\mult_interfaces_get_parameters_indeed#1]% namespace already set
- {\mult_interfaces_get_parameters_item#1,],^^^^0004}
-
-\def\mult_interfaces_get_parameters_item#1,#2% #2 takes space before ,
- {\if,#1,% dirty trick for testing #1=empty
- \expandafter\mult_interfaces_get_parameters_item
- \orelse\if]#1%
- \expandafter\gobbleoneargument
- \else
- \mult_interfaces_get_parameters_assign#1==\empty^^^^0004%
- % \expandafter\mult_interfaces_get_parameters_item % saves skipping when at end
- \fi#2}
-
-\def\mult_interfaces_get_parameters_error#1#2% #3%
- {\mult_interfaces_get_parameters_error_indeed{#1}{#2}%
- \gobbleoneargument}
-
-\def\mult_interfaces_get_parameters_error_indeed#1#2%
- {\showassignerror{#2}{\the\inputlineno\space(#1)}}
-
-\def\mult_interfaces_get_parameters_assign#1=#2=#3#4^^^^0004%
- {\ifx\empty#1\empty
- \expandafter\mult_interfaces_get_parameters_error
- \orelse\ifx#3\empty
- \expandafter\mult_interfaces_get_parameters_error
- \else
- \expandafter\mult_interfaces_adef % assignment def
- \fi
- \m_mult_interfaces_namespace{#1}{#2}%
- \doubleexpandafter\mult_interfaces_get_parameters_item}
-
-\startinterface english
-
- % some 10% faster
-
- \let\mult_interfaces_get_parameters_error\undefined
-
- \def\mult_interfaces_get_parameters_error_one#1\csname#2#3\endcsname#4%
- {\mult_interfaces_get_parameters_error_indeed{#2}{#3}\iftrue}
-
- \def\mult_interfaces_get_parameters_error_two#1\csname#2#3\endcsname#4%
- {\mult_interfaces_get_parameters_error_indeed{#2}{#3}}
-
- \def\mult_interfaces_get_parameters_assign#1=#2=#3#4^^^^0004%
- {\ifx\empty#1\empty
- \mult_interfaces_get_parameters_error_one
- \orelse\ifx#3\empty
- \mult_interfaces_get_parameters_error_two
- \else
- \expandafter\def\csname\m_mult_interfaces_namespace#1\endcsname{#2}%
- \fi
- \doubleexpandafter\mult_interfaces_get_parameters_item}
-
-\stopinterface
-
-\newif\ifassignment
-
-\def\mult_check_for_assignment_indeed#1=#2#3^^^^0004%
- {\if#2^^^^0003\assignmentfalse\else\assignmenttrue\fi}
-
-\def\mult_check_for_assignment_indeed_begin_#1=#2#3^^^^0004%
- {\if#2^^^^0003}
-
-\def\mult_check_for_assignment#1%
- {\expandafter\mult_check_for_assignment_indeed\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
-
-% End of experimental code.
-
-%D This can give wrong results when we pass e.g. \type{\c!format}, so either we need
-%D to use the \type {\k!} ones, but these are not defined in the english interface
-%D so from now on we assume that the low level ones are used with the symbolic names
-%D and that only the high level setup commands are used with language specific
-%D interfaces.
-
-% \unexpanded\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
-% \unexpanded\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-% \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-
-% \startinterface english
- \unexpanded\def\mult_interfaces_let #1#2{\expandafter \let\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_lete#1#2{\expandafter \let\csname#1#2\endcsname\empty}
- \unexpanded\def\mult_interfaces_def #1#2{\expandafter \def\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1#2\endcsname}
- \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1#2\endcsname}
-% \stopinterface
-
-%D Do, we only interface the assignment definition:
-
-\unexpanded\def\mult_interfaces_adef#1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-
-\startinterface english
- \unexpanded\def\mult_interfaces_adef#1#2{\expandafter \def\csname#1#2\endcsname}
-\stopinterface
-
-% the commented detokenized variant that backtracks ... needs testing usage first
-%
-% \let\whatever\relax
-%
-% \definetest[oeps][bagger=\whatever]
-%
-% \def\currenttest{oeps} \edef\hans{\detokenizedtestparameter{bagger}}\meaning\hans\par
-% \def\currenttest{oeps} \edef\hans{\detokenizedtestparameter{reggab}}\meaning\hans\par
-%
-% slower: \def#3##1{\csname\ifcsname#1#2:##1\endcsname\expandafter\csstring\lastnamedcs\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
-
-%D pre-expansion can be a bit faster but handly any effect on a normal run so let's
-%D go for saving some memory
-
-\def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter}
-
-\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only)
- {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing
- \def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
- \def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
- %\def#5##1##2{\ifx##1\relax\??empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ?
- %\def#5##1##2{\ifx##1\relax\??empty\else#4##1{##2}\fi}% is {} needed around ##1 ?
- \def#5##1##2{\ifx##1\relax^^^^0019\else#4##1{##2}\fi}% is {} needed around ##1 ?
- \def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}%
- \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack
- \def#8##1{\begincsname#1#2:##1\endcsname}
- \def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}}
-
-\unexpanded\def\installparameterhandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_parameter_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname #2parameter\endcsname
- \expandafter\noexpand\csname do#2parameter\endcsname % or : #2_parameter
- \expandafter\noexpand\csname do#2parentparameter\endcsname % or : #2_parent_parameter
- \expandafter\noexpand\csname named#2parameter\endcsname
- \expandafter\noexpand\csname detokenized#2parameter\endcsname
- \expandafter\noexpand\csname direct#2parameter\endcsname
- \expandafter\noexpand\csname letfrom#2parameter\endcsname}} % strict#2parameter is gone
-
-\unexpanded\def\mult_interfaces_install_root_parameter_handler#1#2#3%
- {\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root
- \def#3##1{\begincsname#1:##1\endcsname}}
-
-\unexpanded\def\installrootparameterhandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_root_parameter_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname detokenizedroot#2parameter\endcsname
- \expandafter\noexpand\csname root#2parameter\endcsname}}
-
-\unexpanded\def\mult_interfaces_install_parameter_hash_handler#1#2#3#4#5#6#7#8#9%
- {\ifx#2\relax\let#2\empty\fi
- \def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used?
- \def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
- %\def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}%
- \def#5##1##2{\ifx##1\relax\else#4##1{##2}\fi}%
- \def#6{#1#2:}%
- \def#7##1{#1##1:}%
- \def#8{\ifx#2\empty\orelse\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi}%
- \unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}}
-
-\unexpanded\def\installparameterhashhandler#1#2%
- {\expandafter\let\csname#2namespace\endcsname#1%
- \normalexpanded
- {\mult_interfaces_install_parameter_hash_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname #2parameterhash\endcsname
- \expandafter\noexpand\csname do#2parameterhash\endcsname % or : #2_parameter_hash
- \expandafter\noexpand\csname do#2parentparameterhash\endcsname % or : #2_parent_parameter_hash
- \expandafter\noexpand\csname current#2hash\endcsname
- \expandafter\noexpand\csname named#2hash\endcsname
- \expandafter\noexpand\csname check#2parent\endcsname
- \expandafter\noexpand\csname chaintocurrent#2\endcsname}}
-
-%D In \MKIV\ we can probably use the english variant for all other languages too.
-
-% todo: inline the def/let
-
-% \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
-% {\ifx#2\relax\let#2\empty\fi
-% \unexpanded\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate)
-% \unexpanded\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate)
-% \unexpanded\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2
-% \unexpanded\def#6{\mult_interfaces_lete{#1#2:}}}% ##1
-%
-% \startinterface english
- \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
- {\ifx#2\relax\let#2\empty\fi
- \unexpanded\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
- \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
- \unexpanded\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2
- \unexpanded\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1
-% \stopinterface
-
-\unexpanded\def\installparametersethandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_parameter_set_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname set#2parameter\endcsname
- \expandafter\noexpand\csname setexpanded#2parameter\endcsname
- \expandafter\noexpand\csname let#2parameter\endcsname
- \expandafter\noexpand\csname reset#2parameter\endcsname}}
-
-\let\dousecurrentstyleparameter\relax
-\let\dousecurrentcolorparameter\relax
-
-\let\currentstyleparameter\empty
-\let\currentcolorparameter\empty
-
-\unexpanded\def\mult_interfaces_install_style_and_color_handler#1#2#3#4%
- {\unexpanded\def#2##1##2% style color
- {\edef\currentstyleparameter{#1{##1}}% this name is public (can also set color e.g. in underline)
- \ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi
- \edef\currentcolorparameter{#1{##2}}% this name is public (so we do this after the style switch)
- \ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}%
- \unexpanded\def#3##1% style
- {\edef\currentstyleparameter{#1{##1}}% this name is public
- \ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi}%
- \unexpanded\def#4##1% color
- {\edef\currentcolorparameter{#1{##1}}% this name is public
- \ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}}
-
-\unexpanded\def\installstyleandcolorhandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_style_and_color_handler
- \expandafter\noexpand\csname #2parameter\endcsname
- \expandafter\noexpand\csname use#2styleandcolor\endcsname % maybe an alias use#2styleandcolorparameters
- \expandafter\noexpand\csname use#2styleparameter\endcsname
- \expandafter\noexpand\csname use#2colorparameter\endcsname}}
-
-\let\definehandlerparent\empty
-
-% \def\mult_check_for_parent#1#2#3#4%
-% {\ifcsname#1#4:\s!parent\endcsname \else \ifx#4\empty \else
-% \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}%
-% \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}%
-% \fi \fi}
-
-\def\mult_check_for_parent#1#2#3#4%
- {\ifcsname#1#4:\s!parent\endcsname\orelse\ifx#4\empty\else
- \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}%
- \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}%
- \fi}
-
-%def\mult_interfaces_chain#1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\space\fi}
-%def\getparentchain #1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\fi}
-%def\getcurrentparentchain#1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\fi}
-
-\def\mult_interfaces_chain#1#2{\ifcsname#1#2:\s!chain\endcsname\lastnamedcs\space\fi}
-\def\getparentchain #1#2{\begincsname#1#2:\s!chain\endcsname}
-\def\getcurrentparentchain#1#2{\begincsname#1#2:\s!chain\endcsname}
-
-\unexpanded\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones
- {\ifx#4\relax\let#4\empty\fi % see \defineregister
- \unexpanded\def#2{\dotripleempty#5}%
- \newtoks#6%
- \newtoks#7%
- \unexpanded\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
- {\let#9#4%
- \edef#4{##1}%
- \ifthirdargument
- \the#6% predefine
- \edef#8{##2}%
- \mult_check_for_parent{#1}{#3}#4#8%
- \expandafter\edef\csname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}%
- \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}%
- \mult_interfaces_get_parameters{#1#4:}[##3]%
- \orelse\ifsecondargument
- \the#6% predefine
- \ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##2}=^^^^0003^^^^0003^^^^0004%
- \edef#8{##2}%
- \mult_check_for_parent{#1}{#3}#4#8%
- \expandafter\edef\csname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}%
- \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}%
- \else
- \let#8\empty
- \expandafter\edef\csname#1#4:\s!chain\endcsname{##1}%
- \expandafter\edef\csname#1#4:\s!parent\endcsname{#3}%
- \mult_interfaces_get_parameters{#1#4:}[##2]%
- \fi
- \else
- \the#6% predefine
- \let#8\empty
- \expandafter\edef\csname#1#4:\s!chain\endcsname{##1}%
- \expandafter\edef\csname#1#4:\s!parent\endcsname{#3}%
- \fi
- \the#7%
- \let#4#9}}
-
-\unexpanded\def\installdefinehandler#1#2#3%
- {\normalexpanded
- {\mult_interfaces_install_define_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname define#2\endcsname
- {\noexpand#3}% root
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname define_#2\endcsname % semi-public
- \expandafter\noexpand\csname everypreset#2\endcsname
- \expandafter\noexpand\csname everydefine#2\endcsname
- \expandafter\noexpand\csname current#2parent\endcsname
- \expandafter\noexpand\csname saved_defined_#2\endcsname}}
-
-\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8#9%
- {\ifx#3\relax\let#3\empty\fi
- \unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
- \newtoks#5%
- \newtoks#8%
- \unexpanded\def#4[##1][##2]% maybe helper
- {\let#7#3%
- \ifsecondargument
- \def#9####1% we will have a simple one as well
- {\edef#3{####1}%
- \mult_interfaces_get_parameters{#1#3:}[##2]%
- \the#5}%
- \processcommalist[##1]#9%
- \else
- \let#3\empty
- \mult_interfaces_get_parameters{#1:}[##1]%
- \the#5%
- \fi
- \let#3#7%
- \the#8}}
-
-\unexpanded\def\installsetuphandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_setup_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname setup#2\endcsname
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname setup_#2\endcsname % semi-public
- \expandafter\noexpand\csname everysetup#2\endcsname
- \expandafter\noexpand\csname setupcurrent#2\endcsname
- \expandafter\noexpand\csname saved_setup_current#2\endcsname
- \expandafter\noexpand\csname everysetup#2root\endcsname
- \expandafter\noexpand\csname nested_setup_current#2\endcsname}}
-
-\let\doingrootsetupnamed\plusone % \setuplayout[name][key=value]
-\let\doingrootsetuproot \plustwo % \setuplayout [key=value]
-\let\doingrootsetnamed \plusthree % \setuplayout[name]
-\let\doingrootsetroot \plusfour % \setuplayout
-
-\unexpanded\def\mult_interfaces_install_switch_setup_handler_a#1#2#3#4#5%
- {\ifx#3\relax\let#3\empty\fi
- \unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}}
-
-\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
- {\newtoks#5%
- \newconstant#2%
- \newtoks#8%
- \newtoks#9%
- \ifx#6\relax\let#6\empty\fi
- \unexpanded\def#4[##1][##2]% maybe helper
- {\ifsecondargument % no commalist here
- % \setuplayout[whatever][key=value]
- \let#7#3%
- \let#6#3%
- \edef#3{##1}%
- #2\doingrootsetupnamed
- \mult_interfaces_get_parameters{#1#3:}[##2]%
- \the#5%
- \ifx#3#6\the#8\fi % only switchsetups if previous == current
- \let#3#7%
- \orelse\iffirstargument
- % \mult_check_for_assignment{##1}%
- \ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##1}=^^^^0003^^^^0003^^^^0004%
- % \setuplayout[whatever]
- \let#6#3% % previous becomes current
- \edef#3{##1}% this will catch reset so one needs to test for it
- #2\doingrootsetnamed
- \the#5% % we can check for previous vs current
- \the#8% switchsetups
- \else
- % \setuplayout[key=value]
- \let#7#3%
- \let#6#3%
- \let#3\empty
- #2\doingrootsetuproot
- \mult_interfaces_get_parameters{#1:}[##1]%
- \the#5%
- \the#8% switchsetups
- \let#3#7%
- \fi
- \else
- % \setuplayout
- \let#6#3% % previous becomes current
- \let#3\empty % current becomes empty
- #2\doingrootsetroot
- \the#5%
- \the#8% switchsetups
- \fi
- #2\zerocount % mode is always zero at the end
- \the#9}}
-
-\unexpanded\def\installswitchsetuphandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_switch_setup_handler_a
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname setup#2\endcsname
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname setup_#2\endcsname % semi-public
- \expandafter\noexpand\csname setupcurrent#2\endcsname
- \mult_interfaces_install_switch_setup_handler_b
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname #2setupmode\endcsname
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname setup_#2\endcsname % semi-public
- \expandafter\noexpand\csname everysetup#2\endcsname
- \expandafter\noexpand\csname previous#2\endcsname
- \expandafter\noexpand\csname saved_setup_current#2\endcsname
- \expandafter\noexpand\csname everyswitch#2\endcsname
- \expandafter\noexpand\csname everysetup#2root\endcsname}}
-
-\unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8#9%
- {\ifx#3\relax\let#3\empty\fi
- \unexpanded\def#2{\dotripleempty#4}%
- \unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}%
- \newtoks#5%
- \def#4[##1][##2][##3]%
- {\let#8#3%
- \ifthirdargument
- \def#9####1%
- {\edef#3{####1}%
- \expandafter\def\csname#1#3:\s!parent\endcsname{#1##2}%
- \mult_interfaces_get_parameters{#1#3:}[##3]% always sets parent
- \the#5}%
- \processcommalist[##1]#9%
- \orelse\ifsecondargument
- \def#9####1%
- {\edef#3{####1}%
- #7% checks parent and sets if needed
- \mult_interfaces_get_parameters{#1#3:}[##2]%
- \the#5}%
- \processcommalist[##1]#9%
- \else
- \let#3\empty
- \mult_interfaces_get_parameters{#1:}[##1]%
- \the#5%
- \fi
- \let#3#8}}
-
-\unexpanded\def\installautosetuphandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_auto_setup_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname setup#2\endcsname
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname setup_#2\endcsname % semi-public
- \expandafter\noexpand\csname everysetup#2\endcsname
- \expandafter\noexpand\csname setupcurrent#2\endcsname
- \expandafter\noexpand\csname check#2parent\endcsname
- \expandafter\noexpand\csname saved_setup_current#2\endcsname
- \expandafter\noexpand\csname nested_setup_current#2\endcsname}}
-
-\unexpanded\def\installbasicparameterhandler#1#2%
- {\installparameterhandler {#1}{#2}%
- \installparameterhashhandler{#1}{#2}%
- \installparametersethandler {#1}{#2}%
- \installrootparameterhandler{#1}{#2}}
-
-\unexpanded\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
- {\installbasicparameterhandler{#1}{#2}%
- \installautosetuphandler {#1}{#2}}
-
-\unexpanded\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
- {\installbasicparameterhandler{#1}{#2}%
- \installautosetuphandler {#1}{#2}%
- \installstyleandcolorhandler {#1}{#2}}
-
-\unexpanded\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self)
- {\installbasicparameterhandler{#1}{#2}%
- \installdefinehandler {#1}{#2}{#3}%
- \installsetuphandler {#1}{#2}%
- \installstyleandcolorhandler {#1}{#2}}
-
-\unexpanded\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self)
- {\installbasicparameterhandler{#1}{#2}%
- \installdefinehandler {#1}{#2}{#3}%
- \installswitchsetuphandler {#1}{#2}%
- \installstyleandcolorhandler {#1}{#2}}
-
-\unexpanded\def\installautocommandhandler#1#2#3% automatically defined cloned setups
- {\installbasicparameterhandler{#1}{#2}%
- \installdefinehandler {#1}{#2}{#3}%
- \installautosetuphandler {#1}{#2}%
- \installstyleandcolorhandler {#1}{#2}}
-
-\unexpanded\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining
- {\installbasicparameterhandler{#1}{#2}%
- \installsetuphandler {#1}{#2}%
- \installstyleandcolorhandler {#1}{#2}}
-
-%D Many mechanisms have some kind of inheritance in place, and these are the
-%D speed||critical ones. Therefore there is no reason to stick to \type {\@@xxkey}
-%D for the sake of performance. For this reason we also provide a direct variant.
-%D This permits a more consistent treatment of namespaces. A \type
-%D {\whateverparameter} call is three times slower and a \type
-%D {\directwhateverparameter} call two times but for some 100K expansions we only
-%D loose some .1 second which is neglectable given the small amount of expansions in
-%D real runs.
-
-%D We don't need colons for such simple cases.
-
-\unexpanded\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4#5%
-%%{\def#3##1{\csname\ifcsname#1##1\endcsname#1##1\else\s!empty\fi\endcsname}%
- {\def#3##1{\begincsname#1##1\endcsname}%
- \def#4##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}%
- % \def#4##1{\mult_interfaces_detokenize{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}}%
- \def#5##1{\begincsname#1##1\endcsname}}
-
-\unexpanded\def\installdirectparameterhandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_direct_parameter_handler
- {\noexpand#1}%
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname #2parameter\endcsname
- \expandafter\noexpand\csname detokenized#2parameter\endcsname
- \expandafter\noexpand\csname direct#2parameter\endcsname}}
-
-\unexpanded\def\mult_interfaces_install_direct_setup_handler#1#2#3#4#5%
- {\unexpanded\def#2{\dosingleempty#3}%
- \newtoks#5%
- \def#3[##1]{\mult_interfaces_get_parameters#1[##1]\the#5}%
- \def#4{\mult_interfaces_get_parameters#1}}
-
-\unexpanded\def\installdirectsetuphandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_direct_setup_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname setup#2\endcsname
- \expandafter\noexpand\csname setup_#2\endcsname % semi-public
- \expandafter\noexpand\csname setupcurrent#2\endcsname % no \every (we use 'current' for consistency)
- \expandafter\noexpand\csname everysetup#2\endcsname}}
-
-% \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
-% {\unexpanded\def#2{\mult_interfaces_def #1}%
-% \unexpanded\def#3{\mult_interfaces_edef#1}%
-% \unexpanded\def#4{\mult_interfaces_let #1}%
-% \unexpanded\def#5{\mult_interfaces_let #1\empty}}%
-
-% \startinterface english
- \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
- {\unexpanded\def#2##1{\expandafter \def\csname#1##1\endcsname}%
- \unexpanded\def#3##1{\expandafter\edef\csname#1##1\endcsname}%
- \unexpanded\def#4##1{\expandafter \let\csname#1##1\endcsname}%
- \unexpanded\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}%
-% \stopinterface
-
-\unexpanded\def\installdirectparametersethandler#1#2%
- {\normalexpanded
- {\mult_interfaces_install_direct_parameter_set_handler
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname set#2parameter\endcsname
- \expandafter\noexpand\csname setexpanded#2parameter\endcsname
- \expandafter\noexpand\csname let#2parameter\endcsname
- \expandafter\noexpand\csname reset#2parameter\endcsname}}
-
-\let\installdirectstyleandcolorhandler\installstyleandcolorhandler
-
-\unexpanded\def\installdirectcommandhandler#1#2%
- {\installdirectparameterhandler {#1}{#2}%
- \installdirectsetuphandler {#1}{#2}%
- \installdirectparametersethandler {#1}{#2}%
- \installdirectstyleandcolorhandler{#1}{#2}}
-
-\unexpanded\def\installsetuponlycommandhandler#1#2%
- {\installdirectparameterhandler{#1}{#2}%
- \installdirectsetuphandler {#1}{#2}%
- }% maybe \installdirectparametersethandler {#1}{#2}%
-
-% Experiment:
-
-% \installcorenamespace {one}
-% \installcorenamespace {two}
-%
-% \installcommandhandler \??one {one} \??one
-% \installcommandhandler \??two {two} \??two
-%
-% \defineone[test] \setupone[test][alpha=first]
-% \definetwo[test] \setuptwo[test][beta=second]
-%
-% \protect
-%
-% \def\currentone{test}
-% \def\currenttwo{test}
-%
-% \relateparameterhandlers {two} {test} {one} {test}
-%
-% yes:\oneparameter{alpha}\par
-% nop:\oneparameter{beta}\par
-% yes:\twoparameter{alpha}\par
-% yes:\twoparameter{beta}\par
-
-\unexpanded\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance}
- {\expandafter\edef\csname\csname#1namespace\endcsname#2:\s!parent\endcsname{\csname#3namespace\endcsname#4}}
-
-\unexpanded\def\relateparameterhandlersbyns#1#2#3#4% {from} {instance} {to} {instance}
- {\expandafter\edef\csname#1#2:\s!parent\endcsname{#3#4}}
-
-%D Here is another experiment:
-
-\unexpanded\def\installactionhandler#1%
- {\normalexpanded
- {\mult_interfaces_install_action_handler
- {#1}%
- \expandafter\noexpand\csname current#1\endcsname
- \expandafter\noexpand\csname setupcurrent#1\endcsname
- \expandafter\noexpand\csname #1_action\endcsname}}
-
-% \unexpanded\def\mult_interfaces_install_action_handler#1#2#3#4%
-% {\unexpanded\expandafter\def\csname#1\endcsname{\dodoubleempty#4}%
-% \unexpanded\def#4[##1][##2]%
-% {\begingroup
-% \ifsecondargument
-% \edef#2{##1}%
-% #3[##2]%
-% \else\iffirstargument
-% \doifelseassignment{##1}
-% {\let#2\empty
-% #3[##1]}%
-% {\edef#2{##1}}%
-% \else
-% \let#2\empty
-% \fi\fi
-% \directsetup{handler:action:#1}%
-% \endgroup}}
-
-\unexpanded\def\mult_interfaces_install_action_handler#1#2#3#4%
- {\unexpanded\expandafter\def\csname#1\endcsname{\dodoubleempty#4}%
- \unexpanded\def#4[##1][##2]%
- {\begingroup
- \ifsecondargument
- \edef#2{##1}%
- #3[##2]%
- \orelse\iffirstargument
- \ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##1}=^^^^0003^^^^0003^^^^0004%
- \edef#2{##1}%
- \else
- \let#2\empty
- #3[##1]%
- \fi
- \else
- \let#2\empty
- \fi
- \directsetup{handler:action:#1}%
- \endgroup}}
-
-% First we had, in tune with the regular system variables:
-%
-% \starttyping
-% \unexpanded\def\installnamespace#1{\setvalue{????#1}{@@@@#1}}
-% \stoptyping
-%
-% The following variant is nicer and in principle faster but that gets unnoticed
-% unless lots of expansion happens. Also, we can use long tags but the internal
-% expansion will be relatively small (and unlikely more than 4 characters). For
-% instance, \??xx used to expand to @@xx but now becomes for instance 123::. This
-% is one character more but in quite some cases we had : after such a tag in the
-% old situation. In the new situation we create more namespaces and don't need that
-% : any more, so we end up with on the average the same amount of tokens and
-% definitely less when we consider cases like \??xx:\c!align: which now is just
-% \??somealign and therefore has length 5 now (instead of 4+1+5+1=10).
-%
-% Eventualy we will have a verbose \blablanamespace and the difference between core
-% and regular can go ... after all, \xxxparameter can already clash between the two
-% prefix groups .. if users use this mechanism a lot they should use verbose names
-% anyway (the old two character names were mostly an optimization as they also
-% expanded to these characters).
-
-% todo: register namespaces at lua end for logging and reverse resolve
-% todo: move this to syst-ini so that we can use it real early
-
-\newcount\c_mult_interfaces_n_of_namespaces
-
-%def\v_interfaces_prefix_template{\number \c_mult_interfaces_n_of_namespaces>}
-%def\v_interfaces_prefix_template{\characters\c_mult_interfaces_n_of_namespaces>}
-
-%def\v_interfaces_prefix_template % consistently %03i>
-% {\ifnum\c_mult_interfaces_n_of_namespaces<\plusten00\else\ifnum\c_mult_interfaces_n_of_namespaces<\plushundred0\fi\fi
-% \number\c_mult_interfaces_n_of_namespaces>}
-
-\def\v_interfaces_prefix_template
- {\number\c_mult_interfaces_n_of_namespaces>}
-
-\unexpanded\def\installnamespace#1% for modules and users
- {\ifcsname ????#1\endcsname
- \writestatus\m!system{duplicate user namespace '#1'}\wait
- \else
- \global\advance\c_mult_interfaces_n_of_namespaces\plusone
- \expandafter\edef\csname ????#1\endcsname{\v_interfaces_prefix_template}%
- \fi}
-
-\unexpanded\def\installcorenamespace#1%
- {\ifcsname ??#1\endcsname
- \writestatus\m!system{duplicate core namespace '#1'}\wait
- \else
- \global\advance\c_mult_interfaces_n_of_namespaces\plusone
- \expandafter\edef\csname ??#1\endcsname{\v_interfaces_prefix_template}%
- \clf_registernamespace\c_mult_interfaces_n_of_namespaces{#1}%
- \fi}
-
-\def\mult_interfaces_get_parameters_error_indeed#1#2%
- {\clf_showassignerror{#1}{#2}\inputlineno}
-
-% We install two core namespaces here, as we want nice error messages. Maybe
-% we will reserve the first 9.
-
-\installcorenamespace{fontinstanceready}
-\installcorenamespace{fontinstancebasic}
-\installcorenamespace{fontinstanceclass}
-
-%D The next one is handy for local assignments.
-
-\installcorenamespace{dummy}
-
-\letvalue\??dummy\empty
-
- \def\dummyparameter #1{\begincsname\??dummy#1\endcsname}
- \def\directdummyparameter #1{\begincsname\??dummy#1\endcsname}
-\unexpanded\def\setdummyparameter #1{\expandafter\def\csname\??dummy#1\endcsname}
-\unexpanded\def\setexpandeddummyparameter#1{\expandafter\edef\csname\??dummy#1\endcsname}
-\unexpanded\def\letdummyparameter #1{\expandafter\let\csname\??dummy#1\endcsname}
-
-% \unexpanded\def\getdummyparameters
-% {\mult_interfaces_get_parameters\??dummy}
-
-\unexpanded\def\getdummyparameters[#1%
- {\if\noexpand#1]%
- \expandafter\gobbleoneargument
- \else
- \let\m_mult_interfaces_namespace\??dummy
- \expandafter\mult_interfaces_get_parameters_indeed
- \fi#1}
-
-\mult_interfaces_install_style_and_color_handler
- \directdummyparameter
- \usedummystyleandcolor
- \usedummystyleparameter
- \usedummycolorparameter
-
-% Maybe a \definecorenamespace[name][directparameter,directsetup][parent] but we
-% don't gain much. Actually we might just inline all definitions.
-
-% \enabletrackers[interfaces.namespaces,context.flush]
-%
-% \definenamespace
-% [xy]
-% [type=module,
-% comment=test module,
-% version=1,
-% name=test,
-% style=yes,
-% command=yes,
-% setup=list,
-% set=yes,
-% parent=xy]
-%
-% \unprotect
-% \getparameters
-% [\????xy]
-% [text=]
-% \protect
-%
-% \definetest[one]
-%
-% \starttext
-%
-% “\testparameter{text}”
-%
-% \setuptest[text=foo]
-%
-% “\testparameter{text}”
-%
-% \setuptest[one][text=bar]
-%
-% “\testparameter{text}”
-%
-% \stoptext
-%
-% This is a user (module) command:
-
-\unexpanded\def\definenamespace
- {\dodoubleargument\mult_interfaces_define_name_space}
-
-\def\mult_interfaces_define_name_space[#1][#2]% namespace settings
- {\clf_definenamespace{#1}{#2}}
-
-\def\listnamespaces
- {\clf_listnamespaces}
-
-%D Helper:
-%D
-%D \starttyping
-%D \showparentchain{@@am}{left}
-%D \stoptyping
-
-\unexpanded\def\showparentchain#1#2%
- {\writestatus\m!system{chain: [ \mult_interfaces_show_parent_chain{#1#2}]}}
-
-% \def\mult_interfaces_show_parent_chain#1%
-% {#1 => %
-% \ifcsname#1:\s!parent\endcsname
-% \expandafter\mult_interfaces_show_parent_chain\csname#1:\s!parent\endcsname
-% \fi}
-
-\def\mult_interfaces_show_parent_chain#1%
- {#1 => %
- \ifcsname#1:\s!parent\endcsname
- %\expandafter\mult_interfaces_show_parent_chain\csname#1:\s!parent\endcsname
- \expandafter\mult_interfaces_show_parent_chain\lastnamedcs
- \fi}
-
-%D Another helper (needs to be applied):
-
-\unexpanded\def\doifelsecommandhandler#1#2% namespace name
- {\ifcsname#1#2:\s!parent\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifcommandhandlerelse\doifelsecommandhandler
-
-\unexpanded\def\doifcommandhandler#1#2% namespace name
- {\ifcsname#1#2:\s!parent\endcsname
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifnotcommandhandler#1#2% namespace name
- {\ifcsname#1#2:\s!parent\endcsname
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\let\doifcommandhandlerelse\doifelsecommandhandler
-
-% another set of (fast) helpers (grep for usage):
-
-\def\expandnamespaceparameter#1#2#3% \??xx \getp \c!xx \v!yy
- {\csname#1\ifcsname#1\expandafter\expandafter\expandafter\mult_aux_expand_namespace_parameter#2#3}
-
-\def\mult_aux_expand_namespace_parameter#1#2% \cs \v!yy
- {#1\endcsname#1\else#2\fi\endcsname}
-
-\def\expandnamespacemacro#1#2#3% \??xx \some_edefed_cs \c!yy
- {\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname}
-
-\def\expandnamespacevalue#1#2% \??xx {...} \c!yy == optimized \expandcheckedcsname
- {\csname#1\ifcsname#1\normalexpanded{\noexpand\syst_helpers_expand_checked_value{#2}}}
-
-\def\syst_helpers_expand_checked_value#1#2%
- {#1\endcsname#1\else#2\fi\endcsname}
-
-%D Conventions:
-%D
-%D \starttyping
-%D \newcount \c_class_whatever
-%D \newconditional \c_class_whatever
-%D \newconstant \c_class_whatever
-%D \newdimen \d_class_whatever
-%D \newskip \s_class_whatever
-%D \newmuskip \s_class_whatever
-%D \newbox \b_class_whatever
-%D \newtoks \t_class_whatever
-%D
-%D \edef\p_class_whatever{\classparameter\c!whatever}
-%D \edef\m_class_whatever{whatever}
-%D \stoptyping
-
-% experiment: in principle this is faster but not that noticeable as we don't do that
-% many assignments and mechanism that do are also slow; the advantage is mostly nicer
-% in tracing
-
-\def\s!simple{simple}
-\def\s!single{single}
-\def\s!double{double}
-\def\s!triple{triple}
-
-\let\c_mult_set\relax
-
-\unexpanded\def\mult_interfaces_install_definition_set#1#2#3#4#5#6#7%
- {\newcount#3%
- \let#6\empty
- \unexpanded\def#2%
- {\expandafter\let\expandafter\c_mult_set\csname #1_t_#6\endcsname
- \ifx\c_mult_set\relax
- \expandafter\newtoks\c_mult_set
- \expandafter\let\csname #1_t_#6\endcsname\c_mult_set
- \fi}
- \unexpanded\def#4##1%
- {\pushmacro#6%
- \advance#3\plusone
- \edef#6{##1}%
- \unprotect}%
- \unexpanded\def#5%
- {\protect
- \advance#3\minusone
- \popmacro#6}%
- \unexpanded\def#7##1%
- {\edef#6{##1}%
- #2%
- \the\c_mult_set\relax}}
-
-\unexpanded\def\installdefinitionset#1#2%
- {\normalexpanded
- {\mult_interfaces_install_definition_set
- {\noexpand#1}% \??aa
- \expandafter\noexpand\csname set_#2_toks\endcsname
- \expandafter\noexpand\csname #2_nesting_depth\endcsname
- \expandafter\noexpand\csname push#2\endcsname
- \expandafter\noexpand\csname pop#2\endcsname
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname use#2\endcsname}}
-
-\unexpanded\def\mult_interfaces_install_definition_set_member#1#2#3#4#5#6#7#8#9% no everysetups etc
- {\let#5#2%
- \unexpanded\def#2%
- {\ifcase#4\relax\expandafter#5\else\expandafter#6\fi}%
- \unexpanded\def#6%
- {\dodoubleempty#7}%
- \unexpanded\def#7[##1][##2]%
- {\ifsecondargument
- %#3\c_mult_set\expandafter{\the\c_mult_set#9[##1][##2]}%
- #3\toksapp\c_mult_set{#9[##1][##2]}%
- \orelse\iffirstargument
- %#3\c_mult_set\expandafter{\the\c_mult_set#8[##1]}%
- #3\toksapp\c_mult_set{#8[##1]}%
- \fi}}
-
-\unexpanded\def\installdefinitionsetmember#1#2#3#4%
- {\normalexpanded
- {\mult_interfaces_install_definition_set_member
- {\noexpand#3}% \??aa
- \expandafter\noexpand\csname setup#4\endcsname
- \expandafter\noexpand\csname set_#2_toks\endcsname
- \expandafter\noexpand\csname #2_nesting_depth\endcsname
- \expandafter\noexpand\csname normal_setup_#4\endcsname
- \expandafter\noexpand\csname delayed_setup_#4\endcsname
- \expandafter\noexpand\csname do_delayed_setup_#4\endcsname
- \expandafter\noexpand\csname setup#4_\s!single\endcsname
- \expandafter\noexpand\csname setup#4_\s!double\endcsname}}
-
-%D Another experiment:
-
-\unexpanded\def\mult_interfaces_install_parent_injector#1#2#3#4%
- {\unexpanded\def#4##1%
- {\ifx#3\empty
- \expandafter\def\csname#1#2:\s!parent\endcsname{#1##1}%
- \fi}}
-
-\unexpanded\def\installparentinjector#1#2%
- {\normalexpanded{\mult_interfaces_install_parent_injector
- {\noexpand#1}%
- \expandafter\noexpand\csname current#2\endcsname
- \expandafter\noexpand\csname current#2parent\endcsname
- \expandafter\noexpand\csname inject#2parent\endcsname}}
-
-% Faster but not used that much to make a dent in performance. But, because it's
-% cleaner anyway and also gives less tracing, we apply it a few times.
-
-\unexpanded\def\syst_helpers_install_macro_stack#1#2#3%
- {\xdef\m_syst_helpers_push_macro{\csstring#1}%
- \ifcsname#3\m_syst_helpers_push_macro\endcsname\else
- \expandafter\newcount\csname#3\m_syst_helpers_push_macro\endcsname
- \expandafter\edef\csname push_macro_\m_syst_helpers_push_macro\endcsname
- {\noexpand\expandafter\glet
- \noexpand\csname\m_syst_helpers_push_macro\noexpand\the\csname#3\m_syst_helpers_push_macro\endcsname\endcsname
- \noexpand#1%
- \global\advance\csname#3\m_syst_helpers_push_macro\endcsname\plusone}%
- \expandafter\edef\csname pop_macro_\m_syst_helpers_push_macro\endcsname
- {\global\advance\csname#3\m_syst_helpers_push_macro\endcsname\minusone
- \noexpand\expandafter#2%
- \noexpand\expandafter\noexpand#1%
- \noexpand\csname\m_syst_helpers_push_macro\noexpand\the\csname#3\m_syst_helpers_push_macro\endcsname\endcsname}%
- \fi}
-
-\unexpanded\def\installmacrostack #1{\syst_helpers_install_macro_stack#1\let \??localpushedmacro }
-\unexpanded\def\installglobalmacrostack#1{\syst_helpers_install_macro_stack#1\glet\??globalpushedmacro}
-
-% \unprotect
-%
-% \installcorenamespace {test} \installcommandhandler \??test {test} \??test
-% \unexpanded\def\TestMeA[#1]%
-% {\edef\currenttest{#1}
-% \edef\p_before{\testparameter\c!before}%
-% \ifx\p_before\empty \relax \else \relax \fi}
-% \unexpanded\def\TestMeB[#1]%
-% {\edef\currenttest{#1}
-% \doifelsenothing{\testparameter\c!before}\relax\relax}
-% \unexpanded\def\TestMeC[#1]%
-% {\edef\currenttest{#1}
-% \expandafter\expandafter\expandafter\ifx\testparameter\c!before\empty \relax \else \relax \fi}
-% \unexpanded\def\TestMeD[#1]%
-% {\edef\currenttest{#1}
-% \doubleexpandafter\ifx\testparameter\c!before\empty \relax \else \relax \fi}
-%
-% \protect
-%
-% \starttext
-% \definetest[foo] \definetest[bar][foo] \setuptest[bar][before=indeed]
-% \testfeatureonce{100000}{\TestMeA[bar]} A:\elapsedtime \par % 0.502
-% \testfeatureonce{100000}{\TestMeB[bar]} B:\elapsedtime \par % 0.530
-% \testfeatureonce{100000}{\TestMeC[bar]} C:\elapsedtime \par % 0.487
-% \testfeatureonce{100000}{\TestMeD[bar]} D:\elapsedtime \par % 0.493
-% \stoptext
-
-% There is no real demand for this ... even if this is two to three times as fast we
-% only gain a few milliseconds:
-%
-% \starttyping
-% \unexpanded\def\foo#1{[foo:#1]}
-%
-% \installcommalistprocessor {foo} \foo
-% \installcommalistprocessorcommand \processfoolist \foo
-%
-% \infofont
-%
-% \commalistprocessor{foo}[a,b,c,{x,y,z},d]\par
-% \processfoolist[a, b, c, {x,y,z}, d]\par
-% \processcommalist[{x,y,z}]\foo\blank
-%
-% \commalistprocessor{foo}[{x,y,z},a]\par
-% \commalistprocessor{foo}[{x,y,z}]\par
-% \processfoolist[{x,y,z},a]\par
-% \processfoolist[{x,y,z}]\par
-% \processcommalist[{x,y,z}]\foo\blank
-%
-% \unexpanded\def\foo#1{}
-%
-% \testfeatureonce{400000}{\processfoolist [fixed,middle,bar]} \elapsedtime\quad
-%%\testfeatureonce{400000}{\commalistprocessor{foo}[fixed,middle,bar]} \elapsedtime\quad
-% \testfeatureonce{400000}{\processcommalist [fixed,middle,bar]\foo} \elapsedtime\quad
-% \stoptyping
-%
-% For instance the luatex manual only has some 3000 calls. But I keep this around as one
-% never knows when we might need it.
-
-\installcorenamespace{commalistprocessor}
-\installcorenamespace{commalistprocessorwrap}
-\installcorenamespace{commalistprocessorfirst}
-\installcorenamespace{commalistprocessornext}
-\installcorenamespace{commalistprocessoraction}
-
-\unexpanded\def\installcommalistprocessor#1#2% 5 macro names overhead
- {\unexpanded\expandafter\edef\csname\??commalistprocessor#1\endcsname[%
- % {\noexpand\futureexpandis]%
- % \noexpand\gobbleoneargument
- % \csname\??commalistprocessorpickup#1\endcsname}
- %\unexpanded\expandafter\edef\csname\??commalistprocessorpickup#1\endcsname
- {\csname\??commalistprocessorwrap#1\endcsname\relax}% \relax preserves {}
- \unexpanded\expandafter\edef\csname\??commalistprocessorwrap#1\endcsname##1]%
- {\csname\??commalistprocessorfirst#1\endcsname##1,]}
- \unexpanded\expandafter\edef\csname\??commalistprocessorfirst#1\endcsname\relax
- {\csname\??commalistprocessornext#1\endcsname}%
- \unexpanded\expandafter\edef\csname\??commalistprocessornext#1\endcsname
- {\noexpand\futureexpandis]%
- \noexpand\gobbleoneargument
- \csname\??commalistprocessoraction#1\endcsname}
- \unexpanded\expandafter\edef\csname\??commalistprocessoraction#1\endcsname##1,%
- {\noexpand#2{##1}%
- \csname\??commalistprocessornext#1\endcsname}}
-
-\unexpanded\def\installcommalistprocessorcommand#1#2% \processor \action
- {\edef\p_name{\csstring#2}%
- \installcommalistprocessor\p_name{#2}%
- \expandafter\let\expandafter#1\csname\??commalistprocessor\p_name\endcsname}
-
-\unexpanded\def\commalistprocessor#1{\csname\??commalistprocessor#1\endcsname}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-chk.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mult-chk.mkiv
index 83b82242e67..529ab2308ab 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-chk.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-chk.mkiv
@@ -35,8 +35,8 @@
\registerctxluafile{mult-chk}{}
-\unexpanded\def\setvalidparameterkeys{\dodoubleargument\mult_checkers_set_valid_parameter_keys}
-\unexpanded\def\addvalidparameterkeys{\dodoubleargument\mult_checkers_add_valid_parameter_keys}
+\protected\def\setvalidparameterkeys{\dodoubleargument\mult_checkers_set_valid_parameter_keys}
+\protected\def\addvalidparameterkeys{\dodoubleargument\mult_checkers_add_valid_parameter_keys}
\def\mult_checkers_set_valid_parameter_keys[#1][#2]{\clf_setvalidinterfacekeys{#1}{#2}}
\def\mult_checkers_add_valid_parameter_keys[#1][#2]{\clf_addvalidinterfacekeys{#1}{#2}}
@@ -64,8 +64,8 @@
{\def\syst_helpers_get_parameters_assign{\syst_helpers_get_parameters_assign_indeed#1}% will change
\syst_helpers_process_comma_item#2,],^^^^0004}
-\unexpanded\def\disablecheckparameters{\let\getcheckedparameters\mult_checkers_get_checked_parameters_nop}
-\unexpanded\def\enablecheckparameters {\let\getcheckedparameters\mult_checkers_get_checked_parameters_yes}
+\protected\def\disablecheckparameters{\let\getcheckedparameters\mult_checkers_get_checked_parameters_nop}
+\protected\def\enablecheckparameters {\let\getcheckedparameters\mult_checkers_get_checked_parameters_yes}
\disablecheckparameters
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua
index 1e22aaa865c..0f2ef419c17 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua
@@ -11,16 +11,16 @@ if not modules then modules = { } end modules ['mult-def'] = {
return {
["commands"]={
- ["CAPPED"]={
- ["cs"]="KAP",
- ["de"]="KAP",
- ["en"]="CAP",
- ["fr"]="CAP",
- ["it"]="CAP",
- ["nl"]="KAP",
- ["pe"]="CAP",
- ["ro"]="KAP",
- },
+--["CAPPED"]={
+-- ["cs"]="KAP",
+-- ["de"]="KAP",
+-- ["en"]="CAP",
+-- ["fr"]="CAP",
+-- ["it"]="CAP",
+-- ["nl"]="KAP",
+-- ["pe"]="CAP",
+-- ["ro"]="KAP",
+--},
["Character"]={
["cs"]="Znak",
["de"]="Buchstabe",
@@ -75,7 +75,7 @@ return {
["cs"]="Kap",
["de"]="Kap",
["en"]="Cap",
- ["fr"]="Cap",
+ ["fr"]="PetitesCap",
["it"]="Cap",
["nl"]="Kap",
["pe"]="Cap",
@@ -85,7 +85,7 @@ return {
["cs"]="Kaps",
["de"]="Kaps",
["en"]="Caps",
- ["fr"]="Caps",
+ ["fr"]="PetitesCaps",
["it"]="Caps",
["nl"]="Kaps",
["pe"]="Caps",
@@ -145,23 +145,67 @@ return {
["cs"]="oref",
["de"]="ueber",
["en"]="about",
- ["fr"]="concernant",
+ ["fr"]="apropos",
["it"]="intorno",
["nl"]="about",
["pe"]="درمورد",
["ro"]="despre",
},
+ ["adaptfontfeature"]={
+ ["en"]="adaptfontfeature",
+ ["fr"]="adapterfonctionnalitepolice",
+ },
["adaptlayout"]={
["cs"]="prizpusobvzhled",
["de"]="passelayoutan",
["en"]="adaptlayout",
- ["fr"]="adaptedisposition",
+ ["fr"]="adaptermiseenpage",
["it"]="adattalayout",
["nl"]="paslayoutaan",
["pe"]="تنظیمطرحبندی",
["ro"]="adapteazaaspect",
},
- ["adding"]={},
+ ["addfeature"]={
+ ["en"]="addfeature",
+ ["fr"]="ajouterfonctionnalite",
+ },
+ ["alignbottom"]={
+ ["en"]="alignbottom",
+ ["fr"]="alignerbas",
+ },
+ ["aligned"]={
+ ["en"]="aligned",
+ ["fr"]="aligne",
+ },
+ ["alignedbox"]={
+ ["en"]="alignedbox",
+ ["fr"]="boitealignee",
+ },
+ ["alignedline"]={
+ ["en"]="alignedline",
+ ["fr"]="lignealignee",
+ },
+ ["alignhere"]={
+ ["en"]="alignhere",
+ ["fr"]="alignerici",
+ },
+ ["alignment"]={
+ ["en"]="alignment",
+ ["fr"]="alignement",
+ ["nl"]="uitlijnen",
+ },
+ ["alignmentcharacter"]={
+ ["en"]="alignmentcharacter",
+ ["fr"]="caracterealignement",
+ },
+ ["applytocharacters"]={
+ ["en"]="applytocharacters",
+ ["fr"]="appliquerauxcaracteres",
+ },
+ ["applytofirstcharacter"]={
+ ["en"]="applytofirstcharacter",
+ ["fr"]="appliqueraupremiercaractere",
+ },
["arg"]={
["cs"]="arg",
["de"]="arg",
@@ -176,7 +220,7 @@ return {
["cs"]="pref",
["de"]="bei",
["en"]="at",
- ["fr"]="a",
+ ["fr"]="en",
["it"]="al",
["nl"]="op",
["pe"]="در",
@@ -186,7 +230,7 @@ return {
["cs"]="atleftmargin",
["de"]="atleftmargin",
["en"]="atleftmargin",
- ["fr"]="atleftmargin",
+ ["fr"]="enmargegauche",
["it"]="atleftmargin",
["nl"]="oplinkermarge",
["pe"]="درحاشیهچپ",
@@ -196,7 +240,7 @@ return {
["cs"]="nastrane",
["de"]="aufseite",
["en"]="atpage",
- ["fr"]="alapage",
+ ["fr"]="enpage",
["it"]="apagina",
["nl"]="oppagina",
["pe"]="درصفحه",
@@ -206,7 +250,7 @@ return {
["cs"]="atrightmargin",
["de"]="atrightmargin",
["en"]="atrightmargin",
- ["fr"]="atrightmargin",
+ ["fr"]="enmargedroite",
["it"]="atrightmargin",
["nl"]="oprechtermarge",
["pe"]="درحاشیهراست",
@@ -226,7 +270,7 @@ return {
["cs"]="odsazenizleva",
["de"]="rumpfweite",
["en"]="backspace",
- ["fr"]="retourarriere",
+ ["fr"]="retourarrière",
["it"]="spaziodietro",
["nl"]="rugwit",
["pe"]="فاصلهپشت",
@@ -236,7 +280,7 @@ return {
["cs"]="cernalinka",
["de"]="rechteck",
["en"]="blackrule",
- ["fr"]="lignenoire",
+ ["fr"]="traitepais",
["it"]="lineanera",
["nl"]="blokje",
["pe"]="خطسیاه",
@@ -246,7 +290,7 @@ return {
["cs"]="cernelinky",
["de"]="rechtecke",
["en"]="blackrules",
- ["fr"]="lignesnoires",
+ ["fr"]="traitsepais",
["it"]="lineenere",
["nl"]="blokjes",
["pe"]="خطهایسیاه",
@@ -256,7 +300,7 @@ return {
["cs"]="preskoc",
["de"]="blanko",
["en"]="blank",
- ["fr"]="vide",
+ ["fr"]="vierge",
["it"]="rigovuoto",
["nl"]="blanko",
["pe"]="خالی",
@@ -272,11 +316,15 @@ return {
["pe"]="چوبخط",
["ro"]="semncarte",
},
+ ["bottombox"]={
+ ["en"]="bottombox",
+ ["fr"]="boitebas",
+ },
["bottomdistance"]={
["cs"]="vzdalenostspodku",
["de"]="abstandunten",
["en"]="bottomdistance",
- ["fr"]="distanceinf",
+ ["fr"]="distancebas",
["it"]="distanzafondo",
["nl"]="onderafstand",
["pe"]="فاصلهپایین",
@@ -286,27 +334,39 @@ return {
["cs"]="vyskaspodku",
["de"]="hoeheunten",
["en"]="bottomheight",
- ["fr"]="hauteurinf",
+ ["fr"]="hauteurbas",
["it"]="altezzafondo",
["nl"]="onderhoogte",
["pe"]="ارتفاعپایین",
["ro"]="inaltimejos",
},
+ ["bottomleftbox"]={
+ ["en"]="bottomleftbox",
+ ["fr"]="basgaucheboite",
+ },
+ ["bottomrightbox"]={
+ ["en"]="bottomrightbox",
+ ["fr"]="boitebasdroite",
+ },
["bottomspace"]={
["cs"]="bottomspace",
["de"]="bottomspace",
["en"]="bottomspace",
- ["fr"]="espaceinf",
+ ["fr"]="espacebas",
["it"]="spaziofondo",
["nl"]="bodemwit",
["pe"]="فضایپایین",
["ro"]="spatiujos",
},
+ ["buildtextbottomdot"]={
+ ["en"]="buildtextbottomdot",
+ ["fr"]="construirepointtextebas",
+ },
["but"]={
["cs"]="spodek",
["de"]="but",
["en"]="but",
- ["fr"]="but",
+ ["fr"]="mais",
["it"]="fondo",
["nl"]="but",
["pe"]="اما",
@@ -326,7 +386,7 @@ return {
["cs"]="bypassblocks",
["de"]="bypassblocks",
["en"]="bypassblocks",
- ["fr"]="sauteblocs",
+ ["fr"]="eviteblocs",
["it"]="saltablocchi",
["nl"]="passeerblokken",
["pe"]="عبوربلوکها",
@@ -366,7 +426,7 @@ return {
["cs"]="orez",
["de"]="ausschnitt",
["en"]="clip",
- ["fr"]="clip",
+ ["fr"]="decouper",
["it"]="clip",
["nl"]="clip",
["pe"]="گیره",
@@ -376,7 +436,7 @@ return {
["cs"]="klonujpole",
["de"]="klonierefeld",
["en"]="clonefield",
- ["fr"]="clonechamp",
+ ["fr"]="clonerchamp",
["it"]="clonacampo",
["nl"]="kloonveld",
["pe"]="میدانشبیهسازی",
@@ -426,7 +486,7 @@ return {
["cs"]="porovnejskupinubarev",
["de"]="vergleichefarbengruppe",
["en"]="comparecolorgroup",
- ["fr"]="comparegroupecouleur",
+ ["fr"]="comparergroupecouleur",
["it"]="confrontagruppocolori",
["nl"]="vergelijkkleurgroep",
["pe"]="مقایسهگروهرنگ",
@@ -436,7 +496,7 @@ return {
["cs"]="porovnejpaletu",
["de"]="vergleichepalette",
["en"]="comparepalet",
- ["fr"]="comparepalette",
+ ["fr"]="comparerpalette",
["it"]="confrontatavolozza",
["nl"]="vergelijkpalet",
["pe"]="لوحمقایسه",
@@ -446,7 +506,7 @@ return {
["cs"]="completepagenumber",
["de"]="completepagenumber",
["en"]="completepagenumber",
- ["fr"]="completenumeropage",
+ ["fr"]="numeropagecomplet",
["it"]="numeropaginacompleto",
["nl"]="volledigepaginanummer",
["pe"]="شمارهصفحهکامل",
@@ -456,7 +516,7 @@ return {
["cs"]="completeregister",
["de"]="completeregister",
["en"]="completeregister",
- ["fr"]="completeregistre",
+ ["fr"]="registrecomplet",
["it"]="completeregister",
["nl"]="volledigregister",
["pe"]="ثبتکامل",
@@ -476,7 +536,7 @@ return {
["cs"]="konvertujcislo",
["de"]="konvertierezahl",
["en"]="convertnumber",
- ["fr"]="convertitnumero",
+ ["fr"]="convertirnumero",
["it"]="convertinumero",
["nl"]="converteernummer",
["pe"]="شمارهمبدل",
@@ -486,7 +546,7 @@ return {
["cs"]="kopirujpole",
["de"]="kopierefeld",
["en"]="copyfield",
- ["fr"]="copitchamp",
+ ["fr"]="copierchamp",
["it"]="copiacampo",
["nl"]="copieerveld",
["pe"]="میدانکپی",
@@ -496,7 +556,7 @@ return {
["cs"]="korekcebilehomista",
["de"]="korrigierezwischenraum",
["en"]="correctwhitespace",
- ["fr"]="corrigeespaceblanc",
+ ["fr"]="corrigerespaceblanc",
["it"]="correggispaziobianco",
["nl"]="corrigeerwitruimte",
["pe"]="فضایسفیدصحیح",
@@ -526,7 +586,7 @@ return {
["cs"]="parovastrana",
["de"]="doppelseite",
["en"]="couplepage",
- ["fr"]="pagedouble",
+ ["fr"]="couplepage",
["it"]="accoppiapagina",
["nl"]="koppelpagina",
["pe"]="صفحهزوج",
@@ -576,7 +636,7 @@ return {
["cs"]="aktualnicislonadpisu",
["de"]="heutigeskopfnummer",
["en"]="currentheadnumber",
- ["fr"]="numerotetecourant",
+ ["fr"]="numerotetecourante",
["it"]="numerotestacorrente",
["nl"]="huidigekopnummer",
["pe"]="شمارهسرجاری",
@@ -586,7 +646,7 @@ return {
["cs"]="cutspace",
["de"]="cutspace",
["en"]="cutspace",
- ["fr"]="cutspace",
+ ["fr"]="espacecoupe",
["it"]="cutspace",
["nl"]="snijwit",
["pe"]="فضایبرش",
@@ -626,7 +686,7 @@ return {
["cs"]="definuj",
["de"]="definieren",
["en"]="define",
- ["fr"]="definit",
+ ["fr"]="définir",
["it"]="definisci",
["nl"]="definieer",
["pe"]="تعریف",
@@ -636,7 +696,7 @@ return {
["cs"]="definujakcent",
["de"]="definiereakzent",
["en"]="defineaccent",
- ["fr"]="definitaccent",
+ ["fr"]="définiraccent",
["it"]="definisciaccento",
["nl"]="definieeraccent",
["pe"]="تعریفلهجه",
@@ -646,7 +706,7 @@ return {
["cs"]="definujpreskok",
["de"]="definiereblanko",
["en"]="defineblank",
- ["fr"]="definitvide",
+ ["fr"]="définirvierge",
["it"]="definiscirigovuoto",
["nl"]="definieerblanko",
["pe"]="تعریفخالی",
@@ -656,7 +716,7 @@ return {
["cs"]="definujblok",
["de"]="definiereblock",
["en"]="defineblock",
- ["fr"]="definitbloc",
+ ["fr"]="définirbloc",
["it"]="definisciblocco",
["nl"]="definieerblok",
["pe"]="تعریفبلوک",
@@ -666,7 +726,7 @@ return {
["cs"]="definujzakladnifont",
["de"]="definierefliesstext",
["en"]="definebodyfont",
- ["fr"]="definitpolicecorps",
+ ["fr"]="définirpolicedecorps",
["it"]="definiscifontdeltesto",
["nl"]="definieerkorps",
["pe"]="تعریفقلممتن",
@@ -676,17 +736,21 @@ return {
["cs"]="definujprostredizakladnihofontu",
["de"]="definierefliesstextumgebung",
["en"]="definebodyfontenvironment",
- ["fr"]="definitenvironnementpolicecorps",
+ ["fr"]="définirenvironnementpolicedecorps",
["it"]="definisciambientefontdeltesto",
["nl"]="definieerkorpsomgeving",
["pe"]="تعریفمحیطقلمبدنه",
["ro"]="definestemediulfonttext",
},
+ ["definebodyfontswitch"]={
+ ["en"]="definebodyfontswitch",
+ ["fr"]="définircommutateurpolicedecorps",
+ },
["definebuffer"]={
["cs"]="definujbuffer",
["de"]="definierepuffer",
["en"]="definebuffer",
- ["fr"]="definitbuffer",
+ ["fr"]="définirtampon",
["it"]="definiscibuffer",
["nl"]="definieerbuffer",
["pe"]="تعریفبافر",
@@ -696,17 +760,25 @@ return {
["cs"]="definujznak",
["de"]="definierezeichen",
["en"]="definecharacter",
- ["fr"]="definicaractere",
+ ["fr"]="définircaractere",
["it"]="definiscicarattere",
["nl"]="definieerkarakter",
["pe"]="تعریفحرف",
["ro"]="definestecaracter",
},
+ ["definecharacterkerning"]={
+ ["en"]="definecharacterkerning",
+ ["fr"]="définirapprochecaracteres",
+ },
+ ["definecharacterspacing"]={
+ ["en"]="definecharacterspacing",
+ ["fr"]="définirespacementcaracteres",
+ },
["definecolor"]={
["cs"]="definujbarvu",
["de"]="definierefarbe",
["en"]="definecolor",
- ["fr"]="definitcouleur",
+ ["fr"]="définircouleur",
["it"]="definiscicolore",
["nl"]="definieerkleur",
["pe"]="تعریفرنگ",
@@ -716,7 +788,7 @@ return {
["cs"]="definujskupinubarev",
["de"]="definierefarbengruppe",
["en"]="definecolorgroup",
- ["fr"]="definitgroupecouleur",
+ ["fr"]="définirgroupecouleur",
["it"]="definiscigruppocolori",
["nl"]="definieerkleurgroep",
["pe"]="تعریفگروهرنگ",
@@ -726,7 +798,7 @@ return {
["cs"]="definecolumnbreak",
["de"]="definecolumnbreak",
["en"]="definecolumnbreak",
- ["fr"]="definitsautdecolonne",
+ ["fr"]="définirsautdecolonne",
["it"]="definecolumnbreak",
["nl"]="definieerkolomovergang",
["pe"]="تعریفشکستنستون",
@@ -736,7 +808,7 @@ return {
["cs"]="definecolumnset",
["de"]="definecolumnset",
["en"]="definecolumnset",
- ["fr"]="definitjeucolonne",
+ ["fr"]="définirjeucolonnes",
["it"]="definiscigruppocolonne",
["nl"]="definieerkolomgroep",
["pe"]="تعریفمجموعهستون",
@@ -746,7 +818,7 @@ return {
["cs"]="definecombination",
["de"]="definecombination",
["en"]="definecombination",
- ["fr"]="definecombination",
+ ["fr"]="définircombinaison",
["it"]="definecombination",
["nl"]="definieercombinatie",
["pe"]="تعریفترکیب",
@@ -756,7 +828,7 @@ return {
["cs"]="definujkombinovanyseznam",
["de"]="definierezusammengestellteliste",
["en"]="definecombinedlist",
- ["fr"]="definitlisteimbriquee",
+ ["fr"]="définirlistecombinee",
["it"]="definiscielencocombinato",
["nl"]="definieersamengesteldelijst",
["pe"]="تعریفلیستترکیبی",
@@ -766,7 +838,7 @@ return {
["cs"]="definujprikaz",
["de"]="definierebefehl",
["en"]="definecommand",
- ["fr"]="definitcommande",
+ ["fr"]="définircommande",
["it"]="definiscicomando",
["nl"]="definieercommando",
["pe"]="تعریففرمان",
@@ -776,7 +848,7 @@ return {
["cs"]="definujkonverzi",
["de"]="definierekonversion",
["en"]="defineconversion",
- ["fr"]="definitconversion",
+ ["fr"]="définirconversion",
["it"]="definisciconversione",
["nl"]="definieerconversie",
["pe"]="تعریفتبدیل",
@@ -786,27 +858,35 @@ return {
["cs"]="definujpopis",
["de"]="definierebeschreibung",
["en"]="definedescription",
- ["fr"]="definitdescription",
+ ["fr"]="définirdescription",
["it"]="definiscidescrizione",
["nl"]="doordefinieren",
["pe"]="تعریفشرح",
["ro"]="definestedescriere",
},
+ ["definedfont"]={
+ ["en"]="definedfont",
+ ["fr"]="policedefinie",
+ },
["defineenumeration"]={
["cs"]="definujvycet",
["de"]="definierenummerierung",
["en"]="defineenumeration",
- ["fr"]="definitenumeration",
+ ["fr"]="définirénumération",
["it"]="definiscienumerazione",
["nl"]="doornummeren",
["pe"]="تعریفشمارهبندی",
["ro"]="definesteenumerare",
},
+ ["definefallbackfamily"]={
+ ["en"]="definefallbackfamily",
+ ["fr"]="définirfamillederepli",
+ },
["definefield"]={
["cs"]="definujpole",
["de"]="definierefeld",
["en"]="definefield",
- ["fr"]="definitchamp",
+ ["fr"]="définirchamp",
["it"]="definiscicampo",
["nl"]="definieerveld",
["pe"]="تعریفمیدان",
@@ -816,7 +896,7 @@ return {
["cs"]="definujzasobnikpoli",
["de"]="definierefeldstapel",
["en"]="definefieldstack",
- ["fr"]="definitpilechamp",
+ ["fr"]="définirpilechamp",
["it"]="definiscistackcampi",
["nl"]="definieerveldstapel",
["pe"]="تعریفتودهمیدان",
@@ -826,17 +906,25 @@ return {
["cs"]="definujobrazeksymbol",
["de"]="definiereabbsymbol",
["en"]="definefiguresymbol",
- ["fr"]="definitsymbolefigure",
+ ["fr"]="définirfiguresymbole",
["it"]="definiscifigurasimbolo",
["nl"]="definieerfiguursymbool",
["pe"]="تعریفنمادشکل",
["ro"]="definestesimbolfigura",
},
+ ["definefilefallback"]={
+ ["en"]="definefilefallback",
+ ["fr"]="définirfichierderepli",
+ },
+ ["definefirstline"]={
+ ["en"]="definefirstline",
+ ["fr"]="définirpremiereligne",
+ },
["definefloat"]={
["cs"]="definujplvouciobjekt",
["de"]="definieregleitobjekt",
["en"]="definefloat",
- ["fr"]="definitflottant",
+ ["fr"]="définirflottant",
["it"]="definiscioggettomobile",
["nl"]="definieerplaatsblok",
["pe"]="تعریفشناور",
@@ -846,17 +934,49 @@ return {
["cs"]="definujfont",
["de"]="definiereschrift",
["en"]="definefont",
- ["fr"]="definitpolice",
+ ["fr"]="définirpolice",
["it"]="definiscifont",
["nl"]="definieerfont",
["pe"]="تعریفقلم",
["ro"]="definestefont",
},
+ ["definefontalternative"]={
+ ["en"]="definefontalternative",
+ ["fr"]="définirvariantepolice",
+ },
+ ["definefontfallback"]={
+ ["en"]="definefontfallback",
+ ["fr"]="définirpolicederepli",
+ },
+ ["definefontfamily"]={
+ ["en"]="definefontfamily",
+ ["fr"]="définirfamillepolice",
+ },
+ ["definefontfamilypreset"]={
+ ["en"]="definefontfamilypreset",
+ ["fr"]="définirprereglagefamillepolice",
+ },
+ ["definefontfeature"]={
+ ["en"]="definefontfeature",
+ ["fr"]="définirfonctionnalitepolice",
+ },
+ ["definefontfile"]={
+ ["en"]="definefontfile",
+ ["fr"]="définirfichierpolice",
+ },
+ ["definefontsize"]={
+ ["en"]="definefontsize",
+ ["fr"]="définirtaillepolice",
+ },
+ ["definefontsolution"]={
+ ["en"]="definefontsolution",
+ ["fr"]="définirsolutionpolice",
+ },
["definefontstyle"]={
["cs"]="definujstylfontu",
["de"]="definiereschriftstil",
["en"]="definefontstyle",
- ["fr"]="definitstylepolice",
+ ["fr"]="définirstylepolice",
["it"]="definiscistilefont",
["nl"]="definieerfontstijl",
["pe"]="تعریفسبکقلم",
@@ -866,7 +986,7 @@ return {
["cs"]="definujsynonumumfontu",
["de"]="defineschriftsynonym",
["en"]="definefontsynonym",
- ["fr"]="definitsynonymepolice",
+ ["fr"]="définirsynonymepolice",
["it"]="definiscisinonimofont",
["nl"]="definieerfontsynoniem",
["pe"]="تعریفمترادفقلم",
@@ -876,7 +996,7 @@ return {
["cs"]="definujoramovani",
["de"]="definiereumrahmt",
["en"]="defineframed",
- ["fr"]="defineframed",
+ ["fr"]="définirencadre",
["it"]="definisciincorniciato",
["nl"]="definieeromlijnd",
["pe"]="تعریفقالبی",
@@ -886,17 +1006,21 @@ return {
["cs"]="definujoramovanytext",
["de"]="definiereumrahmtertext",
["en"]="defineframedtext",
- ["fr"]="defineframedtext",
+ ["fr"]="définirtexteencadre",
["it"]="definiscitestoincorniciato",
["nl"]="definieerkadertekst",
["pe"]="تعریفمتنقالبی",
["ro"]="definestetextinconjurat",
},
+ ["definefrozenfont"]={
+ ["en"]="definefrozenfont",
+ ["fr"]="définirpolicegelee",
+ },
["definehbox"]={
["cs"]="definujhbox",
["de"]="definierehbox",
["en"]="definehbox",
- ["fr"]="definithbox",
+ ["fr"]="définirhbox",
["it"]="definiscihbox",
["nl"]="definieerhbox",
["pe"]="تعریفجعبهافقی",
@@ -906,21 +1030,26 @@ return {
["cs"]="definujnadpis",
["de"]="definiereueberschrift",
["en"]="definehead",
- ["fr"]="definittete",
+ ["fr"]="définirtete",
["it"]="definiscitesta",
["nl"]="definieerkop",
["pe"]="تعریفسر",
["ro"]="definesteantet",
},
+ ["definehyphenationfeatures"]={
+ ["en"]="definehyphenationfeatures",
+ ["fr"]="définirfonctionnalitescesure",
+ },
["defineindentedtext"]={
["en"]="defineindentedtext",
+ ["fr"]="définirtexteindente",
["nl"]="definieeringesprongentext",
},
["defineinmargin"]={
["cs"]="defineinmargin",
["de"]="defineinmargin",
["en"]="defineinmargin",
- ["fr"]="definitdansmarge",
+ ["fr"]="définirdansmarge",
["it"]="defineinmargin",
["nl"]="definieerinmarge",
["pe"]="تعریفدرونحاشیه",
@@ -930,7 +1059,7 @@ return {
["cs"]="definujinterakcnimenu",
["de"]="definiereinteraktionsmenue",
["en"]="defineinteractionmenu",
- ["fr"]="definitmenuinteraction",
+ ["fr"]="définirmenuinteraction",
["it"]="definiscimenuinterazione",
["nl"]="definieerinteractiemenu",
["pe"]="تعریفمنویپانل",
@@ -940,17 +1069,21 @@ return {
["cs"]="defineitemgroup",
["de"]="defineitemgroup",
["en"]="defineitemgroup",
- ["fr"]="defineitemgroup",
+ ["fr"]="définirgroupedéléments",
["it"]="defineitemgroup",
["nl"]="definieeritemgroep",
["pe"]="تعریفگروهآیتم",
["ro"]="defineitemgroup",
},
+ ["defineitems"]={
+ ["en"]="defineitems",
+ ["fr"]="définiréléments",
+ },
["definelabel"]={
["cs"]="definujpopisek",
["de"]="definierelabel",
["en"]="definelabel",
- ["fr"]="definitetiquette",
+ ["fr"]="définiretiquette",
["it"]="definiscietichetta",
["nl"]="doorlabelen",
["pe"]="تعریفبرچسب",
@@ -960,7 +1093,7 @@ return {
["cs"]="definelayer",
["de"]="definelayer",
["en"]="definelayer",
- ["fr"]="definitcalque",
+ ["fr"]="définircalque",
["it"]="definelayer",
["nl"]="definieerlayer",
["pe"]="تعریفلایه",
@@ -970,17 +1103,21 @@ return {
["cs"]="definelayout",
["de"]="definelayout",
["en"]="definelayout",
- ["fr"]="definitdisposition",
+ ["fr"]="définirmiseenpage",
["it"]="definiscilayout",
["nl"]="definieerlayout",
["pe"]="تعریفطرحبندی",
["ro"]="definelayout",
},
+ ["definelinenote"]={
+ ["en"]="definelinenote",
+ ["fr"]="définirnotedeligne",
+ },
["definelist"]={
["cs"]="definujseznam",
["de"]="definiereliste",
["en"]="definelist",
- ["fr"]="definitliste",
+ ["fr"]="définirliste",
["it"]="definiscielenco",
["nl"]="definieerlijst",
["pe"]="تعریفلیست",
@@ -990,7 +1127,7 @@ return {
["cs"]="definujlogo",
["de"]="definierelogo",
["en"]="definelogo",
- ["fr"]="definitlogo",
+ ["fr"]="définirlogo",
["it"]="definiscilogo",
["nl"]="definieerbeeldmerk",
["pe"]="تعریفآرم",
@@ -1000,7 +1137,7 @@ return {
["cs"]="definujhlavnipole",
["de"]="definierehauptfeld",
["en"]="definemainfield",
- ["fr"]="definitchampprincipal",
+ ["fr"]="définirchampprincipal",
["it"]="definiscicampoprincipale",
["nl"]="definieerhoofdveld",
["pe"]="تعریفمیداناصلی",
@@ -1010,7 +1147,7 @@ return {
["cs"]="definujupravu",
["de"]="definiereumbruch",
["en"]="definemakeup",
- ["fr"]="definitmakeup",
+ ["fr"]="définircomposition",
["it"]="definiscimakeup",
["nl"]="definieeropmaak",
["pe"]="تعریفآرایش",
@@ -1020,7 +1157,7 @@ return {
["cs"]="definujznaceni",
["de"]="definierebeschriftung",
["en"]="definemarking",
- ["fr"]="definitmarquage",
+ ["fr"]="définirmarquage",
["it"]="definiscimarcatura",
["nl"]="definieermarkering",
["pe"]="تعریفنشانهگذاری",
@@ -1030,17 +1167,29 @@ return {
["cs"]="definemathalignment",
["de"]="definemathalignment",
["en"]="definemathalignment",
- ["fr"]="definemathalignment",
+ ["fr"]="définiralignementmath",
["it"]="definemathalignment",
["nl"]="definieerwiskundeuitlijnen",
["pe"]="تعریفتنظیمریاضی",
["ro"]="definemathalignment",
},
+ ["definemode"]={
+ ["en"]="definemode",
+ ["fr"]="définirmode",
+ },
+ ["definenamedcolor"]={
+ ["en"]="definenamedcolor",
+ ["fr"]="définircouleurnommee",
+ },
+ ["definenote"]={
+ ["en"]="definenote",
+ ["fr"]="définirnote",
+ },
["defineoutput"]={
["cs"]="definujvystup",
["de"]="defineoutput",
["en"]="defineoutput",
- ["fr"]="definitsortie",
+ ["fr"]="définirsortie",
["it"]="definiscioutput",
["nl"]="definieeruitvoer",
["pe"]="تعریفخروجی",
@@ -1050,7 +1199,7 @@ return {
["cs"]="definujprekryv",
["de"]="definiereoverlay",
["en"]="defineoverlay",
- ["fr"]="definitrevetement",
+ ["fr"]="définirsuperposition",
["it"]="definiscisovrapposizione",
["nl"]="definieeroverlay",
["pe"]="تعریفپوشش",
@@ -1060,7 +1209,7 @@ return {
["cs"]="definepagebreak",
["de"]="definepagebreak",
["en"]="definepagebreak",
- ["fr"]="definitsautdepage",
+ ["fr"]="définirsautdepage",
["it"]="definepagebreak",
["nl"]="definieerpaginaovergang",
["pe"]="تعریفشکستصفحه",
@@ -1070,7 +1219,7 @@ return {
["cs"]="definujpaletu",
["de"]="definierepalette",
["en"]="definepalet",
- ["fr"]="definitpalette",
+ ["fr"]="définirpalette",
["it"]="definiscitavolozza",
["nl"]="definieerpalet",
["pe"]="تعریفلوح",
@@ -1080,7 +1229,7 @@ return {
["cs"]="definujvelikostpapiru",
["de"]="definierepapierformat",
["en"]="definepapersize",
- ["fr"]="definittaillepapier",
+ ["fr"]="définirtaillepapier",
["it"]="definiscidimensionicarta",
["nl"]="definieerpapierformaat",
["pe"]="تعریفاندازهبرگ",
@@ -1090,17 +1239,21 @@ return {
["cs"]="definujodstavce",
["de"]="definiereabsaetze",
["en"]="defineparagraphs",
- ["fr"]="definitparagraphes",
+ ["fr"]="définirparagraphes",
["it"]="definiscicapoversi",
["nl"]="definieeralineas",
["pe"]="تعریفپاراگرافها",
["ro"]="definesteparagraf",
},
+ ["defineperiodkerning"]={
+ ["en"]="defineperiodkerning",
+ ["fr"]="reglerapprochepoint",
+ },
["defineplacement"]={
["cs"]="defineplacement",
["de"]="defineplacement",
["en"]="defineplacement",
- ["fr"]="defineplacement",
+ ["fr"]="définirplacement",
["it"]="defineplacement",
["nl"]="definieerplaats",
["pe"]="تعریفجانشانی",
@@ -1110,7 +1263,7 @@ return {
["cs"]="definujprofil",
["de"]="definiereprofil",
["en"]="defineprofile",
- ["fr"]="definitprofil",
+ ["fr"]="définirprofil",
["it"]="definisciprofilo",
["nl"]="definieerprofiel",
["pe"]="تعریفپروفایل",
@@ -1120,7 +1273,7 @@ return {
["cs"]="definujprogram",
["de"]="definiereprogramme",
["en"]="defineprogram",
- ["fr"]="definitprogramme",
+ ["fr"]="définirprogramme",
["it"]="definisciprogramma",
["nl"]="definieerprogramma",
["pe"]="تعریفبرنامه",
@@ -1130,7 +1283,7 @@ return {
["cs"]="definerawfont",
["de"]="definerawfont",
["en"]="definerawfont",
- ["fr"]="definitpolicebrute",
+ ["fr"]="définirpolicebrute",
["it"]="definiscifontgrezzo",
["nl"]="definerawfont",
["pe"]="تعریفقلمخام",
@@ -1140,7 +1293,7 @@ return {
["cs"]="definujodkaz",
["de"]="definierereferenz",
["en"]="definereference",
- ["fr"]="definitreference",
+ ["fr"]="définirreference",
["it"]="definisciriferimento",
["nl"]="definieerreferentie",
["pe"]="تعریفمرجع",
@@ -1150,7 +1303,7 @@ return {
["cs"]="definujformatodkazu",
["de"]="definierereferenzformat",
["en"]="definereferenceformat",
- ["fr"]="definitformatreference",
+ ["fr"]="définirformatrereference",
["it"]="definisciformatoriferimento",
["nl"]="definieerreferentieformaat",
["pe"]="تعریفشمایلمرجع",
@@ -1160,7 +1313,7 @@ return {
["cs"]="definujseznamodkazu",
["de"]="definierereferenzliste",
["en"]="definereferencelist",
- ["fr"]="definitlistereference",
+ ["fr"]="définirlistereference",
["it"]="definiscilistariferimenti",
["nl"]="definieerreferentielijst",
["pe"]="تعریفلیستمرجع",
@@ -1170,7 +1323,7 @@ return {
["cs"]="definujrejstrik",
["de"]="definiereregister",
["en"]="defineregister",
- ["fr"]="definitregistre",
+ ["fr"]="définirregistre",
["it"]="definisciregistro",
["nl"]="definieerregister",
["pe"]="تعریفثبت",
@@ -1180,7 +1333,7 @@ return {
["cs"]="definerule",
["de"]="definerule",
["en"]="definerule",
- ["fr"]="definitregle",
+ ["fr"]="définirtrait",
["it"]="definiscilinea",
["nl"]="definieerlijn",
["pe"]="تعریفخطحائل",
@@ -1190,7 +1343,7 @@ return {
["cs"]="definujsekci",
["de"]="definiereabschnitt",
["en"]="definesection",
- ["fr"]="definitsection",
+ ["fr"]="définirsection",
["it"]="definiscisezione",
["nl"]="definieersectie",
["pe"]="تعریفبخش",
@@ -1200,7 +1353,7 @@ return {
["cs"]="definujbloksekce",
["de"]="definiereabschnittsblock",
["en"]="definesectionblock",
- ["fr"]="definitblocsection",
+ ["fr"]="définirblocsection",
["it"]="definiscibloccosezione",
["nl"]="definieersectieblok",
["pe"]="تعریفبلوکبخش",
@@ -1210,7 +1363,7 @@ return {
["cs"]="definujtrideni",
["de"]="definieresortieren",
["en"]="definesorting",
- ["fr"]="definittri",
+ ["fr"]="définirtri",
["it"]="definisciordinamento",
["nl"]="definieersorteren",
["pe"]="تعریفترتیب",
@@ -1220,7 +1373,7 @@ return {
["cs"]="definujstartstop",
["de"]="definierestartstop",
["en"]="definestartstop",
- ["fr"]="definitdemarrestoppe",
+ ["fr"]="définirdébutfin",
["it"]="definisciiniziatermina",
["nl"]="definieerstartstop",
["pe"]="تعریفشروعپایان",
@@ -1230,7 +1383,7 @@ return {
["cs"]="definujstyl",
["de"]="definierestil",
["en"]="definestyle",
- ["fr"]="definitstyle",
+ ["fr"]="définirstyle",
["it"]="definiscistile",
["nl"]="definieerletter",
["pe"]="تعریفسبک",
@@ -1240,7 +1393,7 @@ return {
["cs"]="definujpodpole",
["de"]="definieresubfeld",
["en"]="definesubfield",
- ["fr"]="definitsouschamp",
+ ["fr"]="définirsouschamp",
["it"]="definiscisottocampo",
["nl"]="definieersubveld",
["pe"]="تعریفزیرمیدان",
@@ -1250,7 +1403,7 @@ return {
["cs"]="definujsymbol",
["de"]="definieresymbol",
["en"]="definesymbol",
- ["fr"]="definitsymbole",
+ ["fr"]="définirsymbole",
["it"]="definiscisimbolo",
["nl"]="definieersymbool",
["pe"]="تعریفنماد",
@@ -1260,7 +1413,7 @@ return {
["cs"]="definujsynonyma",
["de"]="definieresynonyme",
["en"]="definesynonyms",
- ["fr"]="definitsynonymes",
+ ["fr"]="définirsynonymes",
["it"]="definiscisinonimi",
["nl"]="definieersynoniemen",
["pe"]="تعریفمترادفها",
@@ -1270,7 +1423,7 @@ return {
["cs"]="definujsablonutabulky",
["de"]="definieretabellenvorlage",
["en"]="definetabletemplate",
- ["fr"]="definittrametableau",
+ ["fr"]="définirgabarittable",
["it"]="definiscimodellotabella",
["nl"]="definieertabelvorm",
["pe"]="تعریفالگویجدول",
@@ -1280,7 +1433,7 @@ return {
["cs"]="definujtabelaci",
["de"]="definieretabulator",
["en"]="definetabulate",
- ["fr"]="definittabulation",
+ ["fr"]="définirtabulation",
["it"]="definiscitabulato",
["nl"]="definieertabulatie",
["pe"]="تعریفجدولبندی",
@@ -1290,7 +1443,7 @@ return {
["cs"]="definujtext",
["de"]="definieretext",
["en"]="definetext",
- ["fr"]="definittexte",
+ ["fr"]="définirtexte",
["it"]="definiscitesto",
["nl"]="definieertekst",
["pe"]="تعریفمتن",
@@ -1298,13 +1451,18 @@ return {
},
["definetextbackground"]={
["en"]="definetextbackground",
+ ["fr"]="définirtextearriereplan",
["nl"]="definieertekstachtergrond",
},
+ ["definetextnote"]={
+ ["en"]="definetextnote",
+ ["fr"]="définirnotetexte",
+ },
["definetextposition"]={
["cs"]="definetextposition",
["de"]="definetextposition",
["en"]="definetextposition",
- ["fr"]="definitpositiontexte",
+ ["fr"]="définirpositiontexte",
["it"]="definisciposizionetesto",
["nl"]="definieertekstpositie",
["pe"]="تعریفمکانمتن",
@@ -1314,7 +1472,7 @@ return {
["cs"]="definetextvariable",
["de"]="definetextvariable",
["en"]="definetextvariable",
- ["fr"]="definitvariabletexte",
+ ["fr"]="définirvariabletexte",
["it"]="definiscivariabiletesto",
["nl"]="definieertekstvariabele",
["pe"]="تعریفمتغیرمتن",
@@ -1324,7 +1482,7 @@ return {
["cs"]="definetype",
["de"]="definetype",
["en"]="definetype",
- ["fr"]="definittype",
+ ["fr"]="définirtranscrire",
["it"]="definiscitype",
["nl"]="definieertype",
["pe"]="تعریفتایپ",
@@ -1334,7 +1492,7 @@ return {
["cs"]="definujopis",
["de"]="definieretippen",
["en"]="definetyping",
- ["fr"]="definitdactylo",
+ ["fr"]="définirtranscription",
["it"]="definiscityping",
["nl"]="definieertypen",
["pe"]="تعریفتایپکردن",
@@ -1344,17 +1502,21 @@ return {
["cs"]="definujverzi",
["de"]="definiereversion",
["en"]="defineversion",
- ["fr"]="definitversion",
+ ["fr"]="définirversion",
["it"]="definisciversion",
["nl"]="definieerversie",
["pe"]="تعریفنسخه",
["ro"]="definesteversiune",
},
+ ["depthspanningtext"]={
+ ["en"]="depthspanningtext",
+ ["fr"]="jambagetextecouvrant",
+ },
["determineheadnumber"]={
["cs"]="stanovcislonadpisu",
["de"]="bestimmekopfnummer",
["en"]="determineheadnumber",
- ["fr"]="determinenumerotete",
+ ["fr"]="determinernumerotete",
["it"]="determinanumerotesta",
["nl"]="bepaalkopnummer",
["pe"]="تعیینشمارهسر",
@@ -1364,7 +1526,7 @@ return {
["cs"]="stanovcharakteristickuseznamu",
["de"]="bestimmelistencharakeristika",
["en"]="determinelistcharacteristics",
- ["fr"]="determinecaracteristiqueliste",
+ ["fr"]="determinercaracteristiquesliste",
["it"]="determinacarattersticheelenco",
["nl"]="bepaallijstkenmerken",
["pe"]="تعیینمشخصاتلیست",
@@ -1374,7 +1536,7 @@ return {
["cs"]="urcicharakteristikurejstriku",
["de"]="bestimmeregistercharakteristika",
["en"]="determineregistercharacteristics",
- ["fr"]="determinecaracteristiquesregistre",
+ ["fr"]="determinercaracteristiquesregistre",
["it"]="determinacaratteristicheregistro",
["nl"]="bepaalregisterkenmerken",
["pe"]="تعیینمشخصاتثبت",
@@ -1394,12 +1556,20 @@ return {
["cs"]="zablokujinterakcnimenu",
["de"]="inaktiviereinteraktionsmenue",
["en"]="disableinteractionmenu",
- ["fr"]="inhibemenuinteraction",
+ ["fr"]="desactivermenuinteraction",
["it"]="disabilitamenuinterazione",
["nl"]="blokkeerinteractiemenu",
["pe"]="ازکارانداختنمنویپانل",
["ro"]="dezactiveazameniuinteractiune",
},
+ ["disablemode"]={
+ ["en"]="disablemode",
+ ["fr"]="desactivermode",
+ },
+ ["doaddfeature"]={
+ ["en"]="doaddfeature",
+ ["fr"]="faireajouterfonctionnalite",
+ },
["domicile"]={
["cs"]="bydliste",
["de"]="wohnort",
@@ -1410,11 +1580,15 @@ return {
["pe"]="مسکن",
["ro"]="domiciliu",
},
+ ["dontconvertfont"]={
+ ["en"]="dontconvertfont",
+ ["fr"]="nepasconvertirpolice",
+ },
["donttest"]={
["cs"]="zadnytest",
["de"]="keintest",
["en"]="donttest",
- ["fr"]="sanstest",
+ ["fr"]="sanstester",
["it"]="notest",
["nl"]="geentest",
["pe"]="امتحاننکن",
@@ -1440,21 +1614,29 @@ return {
["pe"]="عرضلبه",
["ro"]="latimecolturi",
},
+ ["emphasisboldface"]={
+ ["en"]="emphasisboldface",
+ ["fr"]="policegrasaccentue",
+ },
["emptylines"]={
["cs"]="emptylines",
["de"]="emptylines",
["en"]="emptylines",
- ["fr"]="emptylines",
+ ["fr"]="lignesvide",
["it"]="emptylines",
["nl"]="legeregels",
["pe"]="خطهاخالی",
["ro"]="emptylines",
},
+ ["enablemode"]={
+ ["en"]="enablemode",
+ ["fr"]="activermode",
+ },
["environment"]={
["cs"]="prostredi",
["de"]="umgebung",
["en"]="environment",
- ["fr"]="environement",
+ ["fr"]="environnement",
["it"]="ambiente",
["nl"]="omgeving",
["pe"]="محیط",
@@ -1480,6 +1662,14 @@ return {
["pe"]="حقیقت",
["ro"]="fact",
},
+ ["fastswitchtobodyfont"]={
+ ["en"]="fastswitchtobodyfont",
+ ["fr"]="passerrapideapolicedecorps",
+ },
+ ["feature"]={
+ ["en"]="feature",
+ ["fr"]="fonctionnalite",
+ },
["field"]={
["cs"]="pole",
["de"]="feld",
@@ -1504,7 +1694,7 @@ return {
["cs"]="vyplnovepole",
["de"]="ausfuellfeld",
["en"]="fillinfield",
- ["fr"]="remplitchamp",
+ ["fr"]="champarenseigner",
["it"]="camporiempimento",
["nl"]="invulveld",
["pe"]="درجدرمیدان",
@@ -1514,7 +1704,7 @@ return {
["cs"]="vyplnovyradek",
["de"]="gefuelltezeile",
["en"]="fillinline",
- ["fr"]="remplitligne",
+ ["fr"]="lignearenseigner",
["it"]="rigariempimento",
["nl"]="invulregel",
["pe"]="درجدرخط",
@@ -1524,7 +1714,7 @@ return {
["cs"]="vyplnovelinky",
["de"]="gefuelltesrechteck",
["en"]="fillinrules",
- ["fr"]="remplitlignesreglees",
+ ["fr"]="traitsarenseigner",
["it"]="lineeriempimento",
["nl"]="invullijnen",
["pe"]="درجدرخطها",
@@ -1534,22 +1724,30 @@ return {
["cs"]="vyplnenytext",
["de"]="ausfuelltext",
["en"]="fillintext",
- ["fr"]="remplittexte",
+ ["fr"]="textearenseigner",
["it"]="testoriempimento",
["nl"]="invultekst",
["pe"]="درجدرمتن",
["ro"]="textumplere",
},
+ ["firstcharacter"]={
+ ["en"]="firstcharacter",
+ ["fr"]="premiercaractere",
+ },
["fitfield"]={
["cs"]="prizpusobivepole",
["de"]="passendfeld",
["en"]="fitfield",
- ["fr"]="ajustechamp",
+ ["fr"]="adapterchamp",
["it"]="adattacampo",
["nl"]="passendveld",
["pe"]="پرکردنمیدان",
["ro"]="potrivestecamp",
},
+ ["fittopbaselinegrid"]={
+ ["en"]="fittopbaselinegrid",
+ ["fr"]="adaptergrillehautlignedebase",
+ },
["fixedspace"]={
["cs"]="tvrdamezera",
["de"]="festesspatium",
@@ -1570,11 +1768,15 @@ return {
["pe"]="فضاهایثابت",
["ro"]="spatiifixate",
},
+ ["flushnotes"]={
+ ["en"]="flushnotes",
+ ["fr"]="vidernotes",
+ },
["followprofile"]={
["cs"]="dodrzujprofil",
["de"]="folgeprofil",
["en"]="followprofile",
- ["fr"]="suivantprofil",
+ ["fr"]="suivreprofile",
["it"]="seguiprofilo",
["nl"]="volgprofiel",
["pe"]="پیرویپروفایل",
@@ -1584,7 +1786,7 @@ return {
["cs"]="dodrzujverziprofilu",
["de"]="folgeprofilversion",
["en"]="followprofileversion",
- ["fr"]="suivantversionprofil",
+ ["fr"]="suivreversionprofil",
["it"]="seguiversioneprofilo",
["nl"]="volgprofielversie",
["pe"]="پیروینسخهپروفایل",
@@ -1594,7 +1796,7 @@ return {
["cs"]="dodrzujverzi",
["de"]="folgeversion",
["en"]="followversion",
- ["fr"]="suivantversion",
+ ["fr"]="suivreversion",
["it"]="seguiversione",
["nl"]="volgversie",
["pe"]="پیروینسخه",
@@ -1624,7 +1826,7 @@ return {
["cs"]="poznamkapodcarou",
["de"]="fussnote",
["en"]="footnote",
- ["fr"]="notepdp",
+ ["fr"]="notebdp",
["it"]="notapdp",
["nl"]="voetnoot",
["pe"]="پانوشت",
@@ -1634,7 +1836,7 @@ return {
["cs"]="footnotetext",
["de"]="footnotetext",
["en"]="footnotetext",
- ["fr"]="textenotepdp",
+ ["fr"]="textenotebdp",
["it"]="testonotapdp",
["nl"]="voetnoottekst",
["pe"]="متنپانوشت",
@@ -1644,12 +1846,16 @@ return {
["cs"]="forceblocks",
["de"]="forceblocks",
["en"]="forceblocks",
- ["fr"]="forceblocs",
+ ["fr"]="forcerblocs",
["it"]="forzablocchi",
["nl"]="forceerblokken",
["pe"]="اجباربلوکها",
["ro"]="forteazablocuri",
},
+ ["forcecharacterstripping"]={
+ ["en"]="forcecharacterstripping",
+ ["fr"]="forcerdemontagecaracteres",
+ },
["formulanumber"]={
["cs"]="cislorovnice",
["de"]="formelnummer",
@@ -1674,7 +1880,7 @@ return {
["cs"]="oramovani",
["de"]="umrahmt",
["en"]="framed",
- ["fr"]="framed",
+ ["fr"]="encadre",
["it"]="incorniciato",
["nl"]="omlijnd",
["pe"]="قالبی",
@@ -1690,21 +1896,29 @@ return {
["pe"]="از",
["ro"]="din",
},
+ ["fromlinenote"]={
+ ["en"]="fromlinenote",
+ ["fr"]="denotedeligne",
+ },
["getbuffer"]={
["cs"]="ziskejbuffer",
["de"]="holepuffer",
["en"]="getbuffer",
- ["fr"]="prendbuffer",
+ ["fr"]="obtenirtampon",
["it"]="prendibuffer",
["nl"]="haalbuffer",
["pe"]="دریافتبافر",
["ro"]="adubuffer",
},
+ ["getfirstcharacter"]={
+ ["en"]="getfirstcharacter",
+ ["fr"]="obtenirpremiercaractere",
+ },
["getmarking"]={
["cs"]="ziskejznaceni",
["de"]="holebeschriftung",
["en"]="getmarking",
- ["fr"]="obtientmarquage",
+ ["fr"]="obtenirmarquage",
["it"]="prendimarcatura",
["nl"]="haalmarkering",
["pe"]="دریافتنشانه",
@@ -1714,17 +1928,29 @@ return {
["cs"]="getnumber",
["de"]="getnumber",
["en"]="getnumber",
- ["fr"]="getnumber",
+ ["fr"]="obtenirnumero",
["it"]="getnumber",
["nl"]="haalnummer",
["pe"]="دریافتشماره",
["ro"]="getnumber",
},
+ ["globaldisablemode"]={
+ ["en"]="globaldisablemode",
+ ["fr"]="desactivermodeglobal",
+ },
+ ["globalenablemode"]={
+ ["en"]="globalenablemode",
+ ["fr"]="activermodeglobal",
+ },
+ ["globalpreventmode"]={
+ ["en"]="globalpreventmode",
+ ["fr"]="empechermodeglobal",
+ },
["godown"]={
["cs"]="jdidolu",
["de"]="nachunten",
["en"]="godown",
- ["fr"]="vaenbas",
+ ["fr"]="allerenbas",
["it"]="vaigiu",
["nl"]="omlaag",
["pe"]="بروپایین",
@@ -1734,7 +1960,7 @@ return {
["cs"]="jdina",
["de"]="zu",
["en"]="goto",
- ["fr"]="va",
+ ["fr"]="allera",
["it"]="vaia",
["nl"]="naar",
["pe"]="بروبه",
@@ -1744,7 +1970,7 @@ return {
["cs"]="jdinabox",
["de"]="zurbox",
["en"]="gotobox",
- ["fr"]="vaalaboite",
+ ["fr"]="alleraboite",
["it"]="vaiabox",
["nl"]="naarbox",
["pe"]="بروبهجعبه",
@@ -1754,7 +1980,7 @@ return {
["cs"]="jdinastranu",
["de"]="zurseite",
["en"]="gotopage",
- ["fr"]="vaalapage",
+ ["fr"]="allerapage",
["it"]="vaiapagina",
["nl"]="naarpagina",
["pe"]="بروبهصفحه",
@@ -1794,7 +2020,7 @@ return {
["cs"]="vlasovalinka",
["de"]="haarlinie",
["en"]="hairline",
- ["fr"]="ligneh",
+ ["fr"]="ligneavectrait",
["it"]="capello",
["nl"]="haarlijn",
["pe"]="خطمو",
@@ -1804,7 +2030,7 @@ return {
["cs"]="nadpis",
["de"]="kopf",
["en"]="head",
- ["fr"]="tete",
+ ["fr"]="tête",
["it"]="testa",
["nl"]="kop",
["pe"]="سر",
@@ -1814,7 +2040,7 @@ return {
["cs"]="vzdalenostzahlavi",
["de"]="kopfzeilenabstand",
["en"]="headerdistance",
- ["fr"]="distanceentete",
+ ["fr"]="distanceentête",
["it"]="distanzaintestazione",
["nl"]="hoofdafstand",
["pe"]="فاصلهسربرگ",
@@ -1824,7 +2050,7 @@ return {
["cs"]="vyskazahlavi",
["de"]="kopfzeilenhoehe",
["en"]="headerheight",
- ["fr"]="hauteurentete",
+ ["fr"]="hauteurentête",
["it"]="altezzaintestazione",
["nl"]="hoofdhoogte",
["pe"]="ارتفاعسربرگ",
@@ -1854,7 +2080,7 @@ return {
["cs"]="headsym",
["de"]="headsym",
["en"]="headsym",
- ["fr"]="headsym",
+ ["fr"]="symtete",
["it"]="headsym",
["nl"]="kopsym",
["pe"]="نمادسر",
@@ -1870,11 +2096,15 @@ return {
["pe"]="متنسر",
["ro"]="texttitlu",
},
+ ["heightspanningtext"]={
+ ["en"]="heightspanningtext",
+ ["fr"]="hauteurtextecouvrant",
+ },
["hideblocks"]={
["cs"]="schovejbloky",
["de"]="verbergebloecke",
["en"]="hideblocks",
- ["fr"]="cacheblocs",
+ ["fr"]="cacherblocs",
["it"]="nascondiblocchi",
["nl"]="verbergblokken",
["pe"]="بلوکهاپنهان",
@@ -1884,7 +2114,7 @@ return {
["cs"]="vysoky",
["de"]="hoch",
["en"]="high",
- ["fr"]="haut",
+ ["fr"]="exposant",
["it"]="ap",
["nl"]="hoog",
["pe"]="بلند",
@@ -1894,7 +2124,7 @@ return {
["cs"]="hl",
["de"]="hl",
["en"]="hl",
- ["fr"]="hl",
+ ["fr"]="lh",
["it"]="hl",
["nl"]="hl",
["pe"]="خا",
@@ -1904,7 +2134,7 @@ return {
["cs"]="immediatebetweenlist",
["de"]="immediatebetweenlist",
["en"]="immediatebetweenlist",
- ["fr"]="immediatebetweenlist",
+ ["fr"]="immediatemententreliste",
["it"]="immediatebetweenlist",
["nl"]="directtussenlijst",
["pe"]="فوریبینلیست",
@@ -1914,7 +2144,7 @@ return {
["cs"]="immediatetolist",
["de"]="immediatetolist",
["en"]="immediatetolist",
- ["fr"]="immediatetolist",
+ ["fr"]="immediatementalister",
["it"]="immediatetolist",
["nl"]="directnaarlijst",
["pe"]="فوریبهلیست",
@@ -1934,7 +2164,7 @@ return {
["cs"]="zvysujicicislo",
["de"]="nummererhoehen",
["en"]="incrementnumber",
- ["fr"]="incrementenumero",
+ ["fr"]="incrementernumero",
["it"]="incrementanumero",
["nl"]="verhoognummer",
["pe"]="شمارهافزایش",
@@ -1944,7 +2174,7 @@ return {
["cs"]="odsazovani",
["de"]="einziehen",
["en"]="indenting",
- ["fr"]="composeenalinea",
+ ["fr"]="indentation",
["it"]="rientro",
["nl"]="inspringen",
["pe"]="تورفتگی",
@@ -1954,7 +2184,7 @@ return {
["cs"]="zaramovani",
["de"]="imumriss",
["en"]="inframed",
- ["fr"]="inframed",
+ ["fr"]="dansencadre",
["it"]="circondato",
["nl"]="inlijnd",
["pe"]="درقالبی",
@@ -1964,7 +2194,7 @@ return {
["cs"]="plnezneni",
["de"]="volleswort",
["en"]="infull",
- ["fr"]="infull",
+ ["fr"]="encomplet",
["it"]="perlungo",
["nl"]="voluit",
["pe"]="درپر",
@@ -1974,7 +2204,7 @@ return {
["cs"]="ininner",
["de"]="ininner",
["en"]="ininner",
- ["fr"]="ininner",
+ ["fr"]="dansinterieur",
["it"]="ininner",
["nl"]="inbinnen",
["pe"]="درداخلی",
@@ -2014,7 +2244,7 @@ return {
["cs"]="vradku",
["de"]="inzeile",
["en"]="inline",
- ["fr"]="alaligne",
+ ["fr"]="enligne",
["it"]="inriga",
["nl"]="inregel",
["pe"]="درخط",
@@ -2034,7 +2264,7 @@ return {
["cs"]="mazaramovani",
["de"]="immaumrise",
["en"]="inmaframed",
- ["fr"]="inmframed",
+ ["fr"]="dansencadremath",
["it"]="inmaframed",
["nl"]="inwilijnd",
["pe"]="inmframed",
@@ -2044,7 +2274,7 @@ return {
["cs"]="inneredgedistance",
["de"]="inneredgedistance",
["en"]="inneredgedistance",
- ["fr"]="inneredgedistance",
+ ["fr"]="distancebordinterieur",
["it"]="inneredgedistance",
["nl"]="binnenrandafstand",
["pe"]="فاصلهلبهداخلی",
@@ -2054,7 +2284,7 @@ return {
["cs"]="inneredgewidth",
["de"]="inneredgewidth",
["en"]="inneredgewidth",
- ["fr"]="inneredgewidth",
+ ["fr"]="largeurbordinterieur",
["it"]="inneredgewidth",
["nl"]="binnenrandbreedte",
["pe"]="عرضلبهداخلی",
@@ -2064,7 +2294,7 @@ return {
["cs"]="innermargindistance",
["de"]="innermargindistance",
["en"]="innermargindistance",
- ["fr"]="innermargindistance",
+ ["fr"]="distancemargeinterieure",
["it"]="innermargindistance",
["nl"]="binnenmargeafstand",
["pe"]="فاصلهحاشیهداخلی",
@@ -2074,7 +2304,7 @@ return {
["cs"]="innermarginwidth",
["de"]="innermarginwidth",
["en"]="innermarginwidth",
- ["fr"]="innermarginwidth",
+ ["fr"]="largeurmargeinterieure",
["it"]="innermarginwidth",
["nl"]="binnenmargebreedte",
["pe"]="عرضحاشیهداخلی",
@@ -2094,7 +2324,7 @@ return {
["cs"]="inouter",
["de"]="inouter",
["en"]="inouter",
- ["fr"]="inouter",
+ ["fr"]="dansexterieur",
["it"]="inouter",
["nl"]="inbuiten",
["pe"]="درخارجی",
@@ -2134,7 +2364,7 @@ return {
["cs"]="instalacejazyka",
["de"]="installieresprache",
["en"]="installlanguage",
- ["fr"]="installelangue",
+ ["fr"]="installerlangue",
["it"]="installalingua",
["nl"]="installeertaal",
["pe"]="نصبزبان",
@@ -2174,27 +2404,35 @@ return {
["cs"]="polozka",
["de"]="pos",
["en"]="item",
- ["fr"]="element",
+ ["fr"]="élément",
["it"]="elemento",
["nl"]="som",
["pe"]="آیتم",
["ro"]="element",
},
+ ["itemgroup"]={
+ ["en"]="itemgroup",
+ ["fr"]="groupedéléments",
+ },
["items"]={
["cs"]="polozky",
["de"]="posten",
["en"]="items",
- ["fr"]="elements",
+ ["fr"]="éléments",
["it"]="elementi",
["nl"]="items",
["pe"]="آیتمها",
["ro"]="element",
},
+ ["itemtag"]={
+ ["en"]="itemtag",
+ ["fr"]="étiquettedélément",
+ },
["its"]={
["cs"]="pol",
["de"]="its",
["en"]="its",
- ["fr"]="el",
+ ["fr"]="els",
["it"]="el",
["nl"]="its",
["pe"]="its",
@@ -2204,12 +2442,16 @@ return {
["cs"]="zachovejbloky",
["de"]="behaltebloecke",
["en"]="keepblocks",
- ["fr"]="gardeblocs",
+ ["fr"]="conserverblocs",
["it"]="tieniblocchi",
["nl"]="handhaafblokken",
["pe"]="حفظبلوکها",
["ro"]="pastreazablocuri",
},
+ ["kerncharacters"]={
+ ["en"]="kerncharacters",
+ ["fr"]="approchercaracteres",
+ },
["label"]={
["cs"]="poppisek",
["de"]="label",
@@ -2234,7 +2476,7 @@ return {
["cs"]="textpopisku",
["de"]="labeltext",
["en"]="labeltext",
- ["fr"]="labeltexte",
+ ["fr"]="texteetiquette",
["it"]="testoetichetta",
["nl"]="labeltekst",
["pe"]="متنبرچسب",
@@ -2250,6 +2492,14 @@ return {
["pe"]="زبان",
["ro"]="limba",
},
+ ["languageCharacters"]={
+ ["en"]="languageCharacters",
+ ["fr"]="Caractereslangue",
+ },
+ ["languagecharacters"]={
+ ["en"]="languagecharacters",
+ ["fr"]="caractereslangue",
+ },
["leftaligned"]={
["cs"]="zarovnanovlevo",
["de"]="linksbuendig",
@@ -2260,6 +2510,10 @@ return {
["pe"]="چپچین",
["ro"]="aliniatstanga",
},
+ ["leftbottombox"]={
+ ["en"]="leftbottombox",
+ ["fr"]="boitebasgauche",
+ },
["leftedgedistance"]={
["cs"]="vzdalenostlevehookraje",
["de"]="abstandlinkerrand",
@@ -2280,6 +2534,10 @@ return {
["pe"]="عرضلبهچپ",
["ro"]="latimecoltstanga",
},
+ ["leftline"]={
+ ["en"]="leftline",
+ ["fr"]="lignegauche",
+ },
["leftmargindistance"]={
["cs"]="vzdalenostlevemarginalie",
["de"]="linkemarginalafstand",
@@ -2310,6 +2568,19 @@ return {
["pe"]="پا",
["ro"]="leg",
},
+ ["linecorrection"]={
+ ["en"]="linecorrection",
+ ["fr"]="correctionligne",
+ ["nl"]="regelcorrectie",
+ },
+ ["linenote"]={
+ ["en"]="linenote",
+ ["fr"]="notedeligne",
+ },
+ ["linespanningtext"]={
+ ["en"]="linespanningtext",
+ ["fr"]="largeurtextecouvrant",
+ },
["linewidth"]={
["cs"]="tloustkacary",
["de"]="liniendicke",
@@ -2334,7 +2605,7 @@ return {
["cs"]="delkaseznamu",
["de"]="listenlaenge",
["en"]="listlength",
- ["fr"]="llongueurliste",
+ ["fr"]="longueurtexte",
["it"]="lunghezzaelenco",
["nl"]="lijstlengte",
["pe"]="طوللیست",
@@ -2344,7 +2615,7 @@ return {
["cs"]="listsymbol",
["de"]="listsymbol",
["en"]="listsymbol",
- ["fr"]="listesymbole",
+ ["fr"]="symboleliste",
["it"]="listsymbol",
["nl"]="lijstsymbool",
["pe"]="نمادلیست",
@@ -2360,11 +2631,24 @@ return {
["pe"]="عرضلیست",
["ro"]="latimelista",
},
+ ["loadfontgoodies"]={
+ ["en"]="loadfontgoodies",
+ ["fr"]="charerfriandisespolice",
+ },
+ ["localfootnotes"]={
+ ["en"]="localfootnotes",
+ ["fr"]="notesbdplocales",
+ ["nl"]="lokalevoetnoten",
+ },
+ ["localnotes"]={
+ ["en"]="localnotes",
+ ["fr"]="noteslocales",
+ },
["logfields"]={
["cs"]="zaznamovepole",
["de"]="registrierefelder",
["en"]="logfields",
- ["fr"]="logchamp",
+ ["fr"]="logchamps",
["it"]="logcampi",
["nl"]="registreervelden",
["pe"]="میدانهایگزارش",
@@ -2374,7 +2658,7 @@ return {
["cs"]="nivy",
["de"]="tiho",
["en"]="lohi",
- ["fr"]="baha",
+ ["fr"]="inex",
["it"]="pedap",
["nl"]="laho",
["pe"]="پابا",
@@ -2384,7 +2668,7 @@ return {
["cs"]="nizky",
["de"]="tief",
["en"]="low",
- ["fr"]="bas",
+ ["fr"]="indice",
["it"]="ped",
["nl"]="laag",
["pe"]="پایین",
@@ -2414,7 +2698,7 @@ return {
["cs"]="vyskasazby",
["de"]="satzhoehe",
["en"]="makeupheight",
- ["fr"]="hauteurmakeup",
+ ["fr"]="hauteurcomposition",
["it"]="altezzamakeup",
["nl"]="zethoogte",
["pe"]="ارتفاعآرایش",
@@ -2424,7 +2708,7 @@ return {
["cs"]="sirkasazby",
["de"]="satzbreite",
["en"]="makeupwidth",
- ["fr"]="largeurmakeup",
+ ["fr"]="largeurcomposition",
["it"]="ampiezzamakeup",
["nl"]="zetbreedte",
["pe"]="عرضآرایش",
@@ -2434,12 +2718,17 @@ return {
["cs"]="okr",
["de"]="mar",
["en"]="mar",
- ["fr"]="mar",
+ ["fr"]="rem",
["it"]="mar",
["nl"]="mar",
["pe"]="حاش",
["ro"]="mar",
},
+ ["marginblock"]={
+ ["en"]="marginblock",
+ ["fr"]="blocmarginal",
+ ["nl"]="margeblok",
+ },
["margindistance"]={
["cs"]="vzdalenostmarginalie",
["de"]="marginalafstand",
@@ -2454,7 +2743,7 @@ return {
["cs"]="marginalnilinka",
["de"]="marginallinie",
["en"]="marginrule",
- ["fr"]="margereglee",
+ ["fr"]="traitmarge",
["it"]="lineamargine",
["nl"]="kantlijn",
["pe"]="خطحاشیه",
@@ -2514,7 +2803,7 @@ return {
["cs"]="oznacverzi",
["de"]="beschrifteversion",
["en"]="markversion",
- ["fr"]="marquageversion",
+ ["fr"]="marquerversion",
["it"]="marcaversione",
["nl"]="markeerversie",
["pe"]="نسخهنشانه",
@@ -2524,7 +2813,7 @@ return {
["cs"]="matematika",
["de"]="mathematik",
["en"]="mathematics",
- ["fr"]="mathematique",
+ ["fr"]="mathematics",
["it"]="matematica",
["nl"]="wiskunde",
["pe"]="ریاضی",
@@ -2544,7 +2833,7 @@ return {
["cs"]="maoramovani",
["de"]="maumrise",
["en"]="maframed",
- ["fr"]="mframed",
+ ["fr"]="encadremath",
["it"]="maframed",
["nl"]="wilijnd",
["pe"]="mframed",
@@ -2564,7 +2853,7 @@ return {
["cs"]="zrcadlit",
["de"]="spiegeln",
["en"]="mirror",
- ["fr"]="reflete",
+ ["fr"]="refleter",
["it"]="riflessione",
["nl"]="spiegel",
["pe"]="آینه",
@@ -2584,7 +2873,7 @@ return {
["cs"]="moveformula",
["de"]="moveformula",
["en"]="moveformula",
- ["fr"]="deplaceformule",
+ ["fr"]="deplacerformule",
["it"]="spostaformula",
["nl"]="verplaatsformule",
["pe"]="انتقالفرمول",
@@ -2594,7 +2883,7 @@ return {
["cs"]="premistinamrizku",
["de"]="amgitterneuausrichten",
["en"]="moveongrid",
- ["fr"]="deplacesurgrille",
+ ["fr"]="deplacersurgrille",
["it"]="spostaagriglia",
["nl"]="verplaatsopgrid",
["pe"]="انتقالبهتوری",
@@ -2604,7 +2893,7 @@ return {
["cs"]="movesidefloat",
["de"]="movesidefloat",
["en"]="movesidefloat",
- ["fr"]="movesidefloat",
+ ["fr"]="deplacerflottantcote",
["it"]="movesidefloat",
["nl"]="verplaatszijblok",
["pe"]="انتقالکنارشناور",
@@ -2614,7 +2903,7 @@ return {
["cs"]="navigating",
["de"]="navigating",
["en"]="navigating",
- ["fr"]="navigating",
+ ["fr"]="navigation",
["it"]="navigating",
["nl"]="navigerend",
["pe"]="هدایت",
@@ -2634,7 +2923,7 @@ return {
["cs"]="zadnezahlaviaupati",
["de"]="keinekopfundfusszeilen",
["en"]="noheaderandfooterlines",
- ["fr"]="sanslignesenteteetpdp",
+ ["fr"]="sansentêtenipdp",
["it"]="nientelineintestazionepdp",
["nl"]="geenhoofdenvoetregels",
["pe"]="بدونخطسروتهبرگ",
@@ -2644,12 +2933,16 @@ return {
["cs"]="zadneodsazovani",
["de"]="nichteinziehen",
["en"]="noindenting",
- ["fr"]="sansalinea",
+ ["fr"]="sansindentation",
["it"]="nienterientro",
["nl"]="nietinspringen",
["pe"]="بدونتورفتگی",
["ro"]="faraaliniat",
},
+ ["noitem"]={
+ ["en"]="noitem",
+ ["fr"]="sansélément",
+ },
["nolist"]={
["cs"]="zadnyseznam",
["de"]="keineliste",
@@ -2674,7 +2967,7 @@ return {
["cs"]="zadnedalsibloky",
["de"]="keinebloeckemehr",
["en"]="nomoreblocks",
- ["fr"]="pasplusdeblocs",
+ ["fr"]="sansplusdeblocs",
["it"]="bastablocchi",
["nl"]="geenblokkenmeer",
["pe"]="بدونبلوکهایبیشتر",
@@ -2684,7 +2977,7 @@ return {
["cs"]="zadnedalsisoubory",
["de"]="keinedateienmehr",
["en"]="nomorefiles",
- ["fr"]="pasplusdefichiers",
+ ["fr"]="sansplusdefichiers",
["it"]="bastafile",
["nl"]="geenfilesmeer",
["pe"]="بدونفایلهایبیشتر",
@@ -2694,7 +2987,7 @@ return {
["cs"]="nop",
["de"]="nop",
["en"]="nop",
- ["fr"]="nop",
+ ["fr"]="san",
["it"]="nop",
["nl"]="nop",
["pe"]="منفی",
@@ -2720,11 +3013,15 @@ return {
["pe"]="یادداشت",
["ro"]="nota",
},
+ ["notesymbol"]={
+ ["en"]="notesymbol",
+ ["fr"]="symbolenote",
+ },
["notopandbottomlines"]={
["cs"]="zadnehorniadolniradky",
["de"]="keinzeilenobenundunten",
["en"]="notopandbottomlines",
- ["fr"]="sanslignessupetinf",
+ ["fr"]="sansligneshautetbas",
["it"]="nientelineecimafondo",
["nl"]="geenbovenenonderregels",
["pe"]="بدونخطبالاوپایین",
@@ -2734,7 +3031,7 @@ return {
["cs"]="nokap",
["de"]="nokap",
["en"]="nocap",
- ["fr"]="nocap",
+ ["fr"]="paspetitescaps",
["it"]="nocap",
["nl"]="nokap",
["pe"]="سرپوشکوچکنه",
@@ -2774,7 +3071,7 @@ return {
["cs"]="outeredgedistance",
["de"]="outeredgedistance",
["en"]="outeredgedistance",
- ["fr"]="outeredgedistance",
+ ["fr"]="distancebordexterieur",
["it"]="outeredgedistance",
["nl"]="buitenrandafstand",
["pe"]="فاصلهلبهخارجی",
@@ -2784,7 +3081,7 @@ return {
["cs"]="outeredgewidth",
["de"]="outeredgewidth",
["en"]="outeredgewidth",
- ["fr"]="outeredgewidth",
+ ["fr"]="largeurbordexterieur",
["it"]="outeredgewidth",
["nl"]="buitenrandbreedte",
["pe"]="عرضلبهخارجی",
@@ -2794,7 +3091,7 @@ return {
["cs"]="outermargindistance",
["de"]="outermargindistance",
["en"]="outermargindistance",
- ["fr"]="outermargindistance",
+ ["fr"]="distancemargeexterieure",
["it"]="outermargindistance",
["nl"]="buitenmargeafstand",
["pe"]="فاصلهحاشیهخارجی",
@@ -2804,7 +3101,7 @@ return {
["cs"]="outermarginwidth",
["de"]="outermarginwidth",
["en"]="outermarginwidth",
- ["fr"]="outermarginwidth",
+ ["fr"]="largeurmargeexterieure",
["it"]="outermarginwidth",
["nl"]="buitenmargebreedte",
["pe"]="عرضحاشیهخارجی",
@@ -2814,7 +3111,7 @@ return {
["cs"]="zhustene",
["de"]="kleinerdurchschuss",
["en"]="packed",
- ["fr"]="groupe",
+ ["fr"]="sansespaceentreitem",
["it"]="impaccato",
["nl"]="opelkaar",
["pe"]="فشرده",
@@ -2830,11 +3127,15 @@ return {
["pe"]="صفحه",
["ro"]="pagina",
},
+ ["pagebreak"]={
+ ["en"]="pagebreak",
+ ["fr"]="sautdepage",
+ },
["pagedepth"]={
["cs"]="pagedepth",
["de"]="pagedepth",
["en"]="pagedepth",
- ["fr"]="pagedepth",
+ ["fr"]="profondeurpage",
["it"]="pagedepth",
["nl"]="paginadiepte",
["pe"]="عمقصفحه",
@@ -2854,7 +3155,7 @@ return {
["cs"]="pageoffset",
["de"]="pageoffset",
["en"]="pageoffset",
- ["fr"]="pageoffset",
+ ["fr"]="decalagepage",
["it"]="pageoffset",
["nl"]="paginaoffset",
["pe"]="آفستصفحه",
@@ -2904,7 +3205,7 @@ return {
["cs"]="umistizalozky",
["de"]="platzierebookmarks",
["en"]="placebookmarks",
- ["fr"]="placemarquespages",
+ ["fr"]="placermarquepages",
["it"]="mettisegnalibro",
["nl"]="plaatsbookmarks",
["pe"]="درجچوبخط",
@@ -2914,7 +3215,7 @@ return {
["cs"]="umistikombinovanyseznam",
["de"]="platzierezusammengestellteliste",
["en"]="placecombinedlist",
- ["fr"]="placelisteinmbriquee",
+ ["fr"]="placerlistecombinee",
["it"]="mettielencocombinato",
["nl"]="plaatssamengesteldelijst",
["pe"]="درجلیستمختلط",
@@ -2924,7 +3225,7 @@ return {
["cs"]="placefloat",
["de"]="placefloat",
["en"]="placefloat",
- ["fr"]="placeflottant",
+ ["fr"]="placerflottant",
["it"]="placefloat",
["nl"]="plaatsplaatsblok",
["pe"]="درجشناور",
@@ -2934,7 +3235,7 @@ return {
["cs"]="umistipoznamkypodcarou",
["de"]="platzierefussnoten",
["en"]="placefootnotes",
- ["fr"]="placenotespdp",
+ ["fr"]="placernotesbdp",
["it"]="mettinotepdp",
["nl"]="plaatsvoetnoten",
["pe"]="درجپانوشتها",
@@ -2944,7 +3245,7 @@ return {
["cs"]="umistirovnici",
["de"]="platziereformel",
["en"]="placeformula",
- ["fr"]="placeformule",
+ ["fr"]="placerformule",
["it"]="mettiformula",
["nl"]="plaatsformule",
["pe"]="درجفرمول",
@@ -2954,7 +3255,7 @@ return {
["cs"]="placeheadnumber",
["de"]="placeheadnumber",
["en"]="placeheadnumber",
- ["fr"]="placenumerotete",
+ ["fr"]="placernumerotete",
["it"]="posizionanumerotesta",
["nl"]="plaatskopnummer",
["pe"]="درجشمارهسر",
@@ -2964,7 +3265,7 @@ return {
["cs"]="placeheadtext",
["de"]="placeheadtext",
["en"]="placeheadtext",
- ["fr"]="placetextetete",
+ ["fr"]="placertextetete",
["it"]="posizionatestotesta",
["nl"]="plaatskoptekst",
["pe"]="درجمتنسر",
@@ -2974,7 +3275,7 @@ return {
["cs"]="umistilegendu",
["de"]="platzierelegende",
["en"]="placelegend",
- ["fr"]="placelegende",
+ ["fr"]="placerlegende",
["it"]="mettilegenda",
["nl"]="plaatslegenda",
["pe"]="درجراهنما",
@@ -2984,7 +3285,7 @@ return {
["cs"]="umistiseznam",
["de"]="platziereliste",
["en"]="placelist",
- ["fr"]="placeliste",
+ ["fr"]="placerliste",
["it"]="mettielenco",
["nl"]="plaatslijst",
["pe"]="درجلیست",
@@ -2992,33 +3293,46 @@ return {
},
["placelistofsynonyms"]={
["en"]="placelistofsynonyms",
+ ["fr"]="placerlistedesynonymes",
["nl"]="plaatslijstmetsynoniemen",
},
["placelocalfootnotes"]={
["cs"]="umistilokalnipoznamkypodcarou",
["de"]="platzierelokalefussnoten",
["en"]="placelocalfootnotes",
- ["fr"]="placenotespdplocales",
+ ["fr"]="placernotesbdplocales",
["it"]="mettinotepdplocali",
["nl"]="plaatslokalevoetnoten",
["pe"]="درجپانوشتهایموضعی",
["ro"]="punenotesubsollocale",
},
+ ["placelocalnotes"]={
+ ["en"]="placelocalnotes",
+ ["fr"]="placernoteslocales",
+ },
["placelogos"]={
["cs"]="umistiloga",
["de"]="platzierelogo",
["en"]="placelogos",
- ["fr"]="placelogos",
+ ["fr"]="placerlogo",
["it"]="mettiloghi",
["nl"]="plaatsbeeldmerken",
["pe"]="درجآرمها",
["ro"]="punelogouri",
},
+ ["placenamedfloat"]={
+ ["en"]="placenamedfloat",
+ ["fr"]="placerflottantnomme",
+ },
+ ["placenotes"]={
+ ["en"]="placenotes",
+ ["fr"]="placernotes",
+ },
["placeongrid"]={
["cs"]="umistinamrizku",
["de"]="amgitterausrichten",
["en"]="placeongrid",
- ["fr"]="placesurgrille",
+ ["fr"]="placersurgrille",
["it"]="mettiingriglia",
["nl"]="plaatsopgrid",
["pe"]="درجدرتوری",
@@ -3028,7 +3342,7 @@ return {
["cs"]="umistinadsebe",
["de"]="platziereuntereinander",
["en"]="placeontopofeachother",
- ["fr"]="placelesunsaudessusdesautres",
+ ["fr"]="placerlunaudessusdelautre",
["it"]="mettiunosullaltro",
["nl"]="plaatsonderelkaar",
["pe"]="درجدربالاییکدیگر",
@@ -3038,7 +3352,7 @@ return {
["cs"]="placepagenumber",
["de"]="placepagenumber",
["en"]="placepagenumber",
- ["fr"]="placenumeropage",
+ ["fr"]="placernumeropage",
["it"]="mettinumeropagina",
["nl"]="plaatspaginanummer",
["pe"]="درجشمارهصفحه",
@@ -3048,7 +3362,7 @@ return {
["cs"]="placerawlist",
["de"]="placerawlist",
["en"]="placerawlist",
- ["fr"]="placerawlist",
+ ["fr"]="placerlistebrute",
["it"]="placerawlist",
["nl"]="plaatsruwelijst",
["pe"]="درجلیستخام",
@@ -3058,7 +3372,7 @@ return {
["cs"]="placereferencelist",
["de"]="placereferencelist",
["en"]="placereferencelist",
- ["fr"]="placelistereference",
+ ["fr"]="placerlistereference",
["it"]="placereferencelist",
["nl"]="plaatsreferentielijst",
["pe"]="درجلیستمرجع",
@@ -3068,7 +3382,7 @@ return {
["cs"]="umistirejstrik",
["de"]="platziereregister",
["en"]="placeregister",
- ["fr"]="placeregistre",
+ ["fr"]="placerregistre",
["it"]="mettiregistro",
["nl"]="plaatsregister",
["pe"]="درجثبت",
@@ -3078,7 +3392,7 @@ return {
["cs"]="placerule",
["de"]="placerule",
["en"]="placerule",
- ["fr"]="placeregle",
+ ["fr"]="placertrait",
["it"]="mettilinea",
["nl"]="plaatslijn",
["pe"]="درجخط",
@@ -3088,7 +3402,7 @@ return {
["cs"]="umistivedlesebe",
["de"]="platzierenebeneinander",
["en"]="placesidebyside",
- ["fr"]="placecoteacote",
+ ["fr"]="placercoteacote",
["it"]="mettifiancoafianco",
["nl"]="plaatsnaastelkaar",
["pe"]="درجکناربهکنار",
@@ -3098,7 +3412,7 @@ return {
["cs"]="umistipodrovnici",
["de"]="platziereunterformel",
["en"]="placesubformula",
- ["fr"]="placesousformule",
+ ["fr"]="placersousformule",
["it"]="mettisottoformula",
["nl"]="plaatssubformule",
["pe"]="درجزیرفرمول",
@@ -3108,7 +3422,7 @@ return {
["cs"]="placetextvariable",
["de"]="placetextvariable",
["en"]="placetextvariable",
- ["fr"]="placevariabletexte",
+ ["fr"]="placervariabletexte",
["it"]="mettivariabiletesto",
["nl"]="plaatstekstvariabele",
["pe"]="درجمتغیرمتن",
@@ -3128,17 +3442,45 @@ return {
["cs"]="positiontext",
["de"]="positiontext",
["en"]="positiontext",
- ["fr"]="positionnetexte",
+ ["fr"]="texteposition",
["it"]="posizionatesto",
["nl"]="positioneertekst",
["pe"]="مکانمتن",
["ro"]="pozitietext",
},
+ ["postponenotes"]={
+ ["en"]="postponenotes",
+ ["fr"]="reporternotes",
+ },
+ ["postponingnotes"]={
+ ["en"]="postponingnotes",
+ ["fr"]="reportnotes",
+ },
+ ["predefinedfont"]={
+ ["en"]="predefinedfont",
+ ["fr"]="policepredefinie",
+ },
+ ["predefinefont"]={
+ ["en"]="predefinefont",
+ ["fr"]="predéfinirpolice",
+ },
+ ["presetdocument"]={
+ ["en"]="presetdocument",
+ ["fr"]="prereglerdocument",
+ },
+ ["prettyprintbuffer"]={
+ ["en"]="prettyprintbuffer",
+ ["fr"]="imprimerjolimenttampon",
+ },
+ ["preventmode"]={
+ ["en"]="preventmode",
+ ["fr"]="empechermode",
+ },
["printpaperheight"]={
["cs"]="vyskatiskpapiru",
["de"]="printpapierhoehe",
["en"]="printpaperheight",
- ["fr"]="hauteureditionpapier",
+ ["fr"]="hauteurpapierimpression",
["it"]="altezzacartastampa",
["nl"]="printpapierhoogte",
["pe"]="چاپارتفاعبرگ",
@@ -3148,7 +3490,7 @@ return {
["cs"]="sirkatiskpapiru",
["de"]="printpapierbreite",
["en"]="printpaperwidth",
- ["fr"]="largeureditionpapier",
+ ["fr"]="largeurpapierimpression",
["it"]="ampiezzacartastampa",
["nl"]="printpapierbreedte",
["pe"]="چاپعرضبرگ",
@@ -3158,17 +3500,21 @@ return {
["cs"]="zpracujbloky",
["de"]="bearbeitebloecke",
["en"]="processblocks",
- ["fr"]="traiteblocs",
+ ["fr"]="traiterblocs",
["it"]="elaborablocchi",
["nl"]="verwerkblokken",
["pe"]="بلوکهایپردازش",
["ro"]="proceseazabloc",
},
+ ["processbodyfontenvironmentlist"]={
+ ["en"]="processbodyfontenvironmentlist",
+ ["fr"]="traiterlisteenvironnementpolicedecorps",
+ },
["processpage"]={
["cs"]="zpracujstranu",
["de"]="bearbeiteseite",
["en"]="processpage",
- ["fr"]="traitepage",
+ ["fr"]="traiterpage",
["it"]="elaborapagina",
["nl"]="verwerkpagina",
["pe"]="صفحهپردازش",
@@ -3248,12 +3594,16 @@ return {
["cs"]="opakovat",
["de"]="wiederholen",
["en"]="redo",
- ["fr"]="refait",
+ ["fr"]="refaire",
["it"]="rifai",
["nl"]="herhaal",
["pe"]="انجامدوباره",
["ro"]="refa",
},
+ ["redoconvertfont"]={
+ ["en"]="redoconvertfont",
+ ["fr"]="refaireconvertirpolice",
+ },
["ref"]={
["cs"]="ref",
["de"]="ref",
@@ -3278,7 +3628,7 @@ return {
["cs"]="odkaz",
["de"]="verweis",
["en"]="referral",
- ["fr"]="recommandation",
+ ["fr"]="redirection",
["it"]="referral",
["nl"]="kenmerk",
["pe"]="رجوع",
@@ -3288,7 +3638,7 @@ return {
["cs"]="odkaznadatum",
["de"]="verweisdatum",
["en"]="referraldate",
- ["fr"]="daterecommandation",
+ ["fr"]="dateredirection",
["it"]="datareferral",
["nl"]="kenmerkdatum",
["pe"]="تاریخرجوع",
@@ -3298,22 +3648,38 @@ return {
["cs"]="odkazujici",
["de"]="referieren",
["en"]="referring",
- ["fr"]="faitreference",
+ ["fr"]="fairereference",
["it"]="referring",
["nl"]="refereer",
["pe"]="مراجعه",
["ro"]="referring",
},
+ ["registerfontclass"]={
+ ["en"]="registerfontclass",
+ ["fr"]="enregistrerclassepolice",
+ },
+ ["registerhyphenationexception"]={
+ ["en"]="registerhyphenationexception",
+ ["fr"]="enregistrerexceptioncesure",
+ },
+ ["registerhyphenationpattern"]={
+ ["en"]="registerhyphenationpattern",
+ ["fr"]="enregistrermotifcesure",
+ },
["remark"]={
["cs"]="oznaceni",
["de"]="bemerkung",
["en"]="remark",
- ["fr"]="commentaire",
+ ["fr"]="remarque",
["it"]="commento",
["nl"]="toelichting",
["pe"]="توجه",
["ro"]="remarca",
},
+ ["replacefeature"]={
+ ["en"]="replacefeature",
+ ["fr"]="remplacerfonctionnalite",
+ },
["reset"]={
["cs"]="reset",
["de"]="ruecksetzten",
@@ -3324,6 +3690,50 @@ return {
["pe"]="بازنشانی",
["ro"]="reset",
},
+ ["resetandaddfeature"]={
+ ["en"]="resetandaddfeature",
+ ["fr"]="razetajouterfonctionnalite",
+ },
+ ["resetcharacteralign"]={
+ ["en"]="resetcharacteralign",
+ ["fr"]="razalignercaractere",
+ },
+ ["resetcharacterkerning"]={
+ ["en"]="resetcharacterkerning",
+ ["fr"]="razapprochecaracteres",
+ },
+ ["resetcharacterspacing"]={
+ ["en"]="resetcharacterspacing",
+ ["fr"]="razespacementcaracteres",
+ },
+ ["resetcharacterstripping"]={
+ ["en"]="resetcharacterstripping",
+ ["fr"]="razdemontagecaracteres",
+ },
+ ["resetfeature"]={
+ ["en"]="resetfeature",
+ ["fr"]="razfonctionnalite",
+ },
+ ["resetfontcolorsheme"]={
+ ["en"]="resetfontcolorsheme",
+ ["fr"]="razthemecouleurpolice",
+ },
+ ["resetfontfallback"]={
+ ["en"]="resetfontfallback",
+ ["fr"]="razpolicederepli",
+ },
+ ["resetfontsolution"]={
+ ["en"]="resetfontsolution",
+ ["fr"]="zarsolutionpolice",
+ },
+ ["resethyphenationfeatures"]={
+ ["en"]="resethyphenationfeatures",
+ ["fr"]="razfonctionnalitescesure",
+ },
+ ["resetlocalfloats"]={
+ ["en"]="resetlocalfloats",
+ ["fr"]="razflottantslocaux",
+ },
["resetmarking"]={
["cs"]="resetznaceni",
["de"]="ruecksetztenbeschriftung",
@@ -3334,6 +3744,10 @@ return {
["pe"]="بازنشانینشانهگذاری",
["ro"]="reseteazamarcaje",
},
+ ["resetmode"]={
+ ["en"]="resetmode",
+ ["fr"]="razmode",
+ },
["resetnumber"]={
["cs"]="resetnumber",
["de"]="resetnumber",
@@ -3344,16 +3758,44 @@ return {
["pe"]="بازنشانیشماره",
["ro"]="resetnumber",
},
- ["resettext"]={
+ ["resetpath"]={
+ ["en"]="resetpath",
+ ["fr"]="razchemin",
+ },
+ ["resetperiodkerning"]={
+ ["en"]="resetperiodkerning",
+ ["fr"]="razapprochepoint",
+ },
+ ["resetsystemmode"]={
+ ["en"]="resetsystemmode",
+ ["fr"]="razmodesysteme",
+ },
+ ["resettextcontent"]={
["cs"]="resettextcontent",
["de"]="resettextcontent",
["en"]="resettextcontent",
- ["fr"]="resettextcontent",
+ ["fr"]="raztexte",
["it"]="resettextcontent",
["nl"]="resettekstinhoud",
["pe"]="بازنشانیمتن",
["ro"]="resettextcontent",
},
+ ["resetvisualizers"]={
+ ["en"]="resetvisualizers",
+ ["fr"]="razvisualisateurs",
+ },
+ ["restoreglobalbodyfont"]={
+ ["en"]="restoreglobalbodyfont",
+ ["fr"]="restaurerpolicedecorpsglobale",
+ },
+ ["retestfeature"]={
+ ["en"]="retestfeature",
+ ["fr"]="retesterfonctionnalite",
+ },
+ ["revivefeature"]={
+ ["en"]="revivefeature",
+ ["fr"]="relancerfonctionnalite",
+ },
["rightaligned"]={
["cs"]="zarovnanovpravo",
["de"]="rechtsbuendig",
@@ -3364,6 +3806,10 @@ return {
["pe"]="تنظیمراست",
["ro"]="aliniatdreapta",
},
+ ["rightbottombox"]={
+ ["en"]="rightbottombox",
+ ["fr"]="boitebasdroite",
+ },
["rightedgedistance"]={
["cs"]="vzdalenostpravehookraje",
["de"]="abstandrechterrand",
@@ -3384,6 +3830,10 @@ return {
["pe"]="عرضلبهراست",
["ro"]="latimecoltdreapta",
},
+ ["rightline"]={
+ ["en"]="rightline",
+ ["fr"]="lignedroite",
+ },
["rightmargindistance"]={
["cs"]="vzdalenostpravemarginalie",
["de"]="rechtemarginalafstand",
@@ -3418,7 +3868,7 @@ return {
["cs"]="otocit",
["de"]="drehen",
["en"]="rotate",
- ["fr"]="oriente",
+ ["fr"]="tourner",
["it"]="ruota",
["nl"]="roteer",
["pe"]="دوران",
@@ -3426,13 +3876,14 @@ return {
},
["savebuffer"]={
["en"]="savebuffer",
+ ["fr"]="enregistrertampon",
["nl"]="bewaarbuffer",
},
["scale"]={
["cs"]="meritko",
["de"]="format",
["en"]="scale",
- ["fr"]="echelle",
+ ["fr"]="mettrealechelle",
["it"]="scala",
["nl"]="schaal",
["pe"]="مقیاس",
@@ -3452,7 +3903,7 @@ return {
["cs"]="vyberbloky",
["de"]="waehlebloeckeaus",
["en"]="selectblocks",
- ["fr"]="selectionneblocs",
+ ["fr"]="selectionnerblocs",
["it"]="selezionablocchi",
["nl"]="selecteerblokken",
["pe"]="انتخاببلوکها",
@@ -3462,7 +3913,7 @@ return {
["cs"]="vyberpapir",
["de"]="waehlepapieraus",
["en"]="selectpaper",
- ["fr"]="selectionnepapier",
+ ["fr"]="selectionnerpapier",
["it"]="selezionacarta",
["nl"]="selecteerpapier",
["pe"]="انتخاببرگ",
@@ -3472,27 +3923,127 @@ return {
["cs"]="vyberverzi",
["de"]="waehleversionaus",
["en"]="selectversion",
- ["fr"]="selectionneversion",
+ ["fr"]="selectionnerversion",
["it"]="selezionaversione",
["nl"]="selecteerversie",
["pe"]="انتخابنسخه",
["ro"]="selecteazaversiune",
},
+ ["setbigbodyfont"]={
+ ["en"]="setbigbodyfont",
+ ["fr"]="reglerpolicedecorpsimportante",
+ },
+ ["setcharacteralign"]={
+ ["en"]="setcharacteralign",
+ ["fr"]="regleralignercaractere",
+ },
+ ["setcharacteraligndetail"]={
+ ["en"]="setcharacteraligndetail",
+ ["fr"]="reglerdetailalignercaractere",
+ },
+ ["setcharactercasing"]={
+ ["en"]="setcharactercasing",
+ ["fr"]="reglercassecaracteres",
+ },
+ ["setcharactercleaning"]={
+ ["en"]="setcharactercleaning",
+ ["fr"]="reglernettoyagecaracteres",
+ },
+ ["setcharacterkerning"]={
+ ["en"]="setcharacterkerning",
+ ["fr"]="reglerapprochecaracteres",
+ },
+ ["setcharacterspacing"]={
+ ["en"]="setcharacterspacing",
+ ["fr"]="reglerespacementcaracteres",
+ },
+ ["setcharacterstripping"]={
+ ["en"]="setcharacterstripping",
+ ["fr"]="reglerdemontagecaracteres",
+ },
+ ["setcurrentfontclass"]={
+ ["en"]="setcurrentfontclass",
+ ["fr"]="reglerclassepolicecourante",
+ },
+ ["setfirstline"]={
+ ["en"]="setfirstline",
+ ["fr"]="reglerpremiereligne",
+ },
+ ["setfirstpasscharacteralign"]={
+ ["en"]="setfirstpasscharacteralign",
+ ["fr"]="regleralignercaracterepremierepasse",
+ },
+ ["setfont"]={
+ ["en"]="setfont",
+ ["fr"]="reglerpolice",
+ },
+ ["setfontcolorsheme"]={
+ ["en"]="setfontcolorsheme",
+ ["fr"]="reglerthemecouleurpolice",
+ },
+ ["setfontfeature"]={
+ ["en"]="setfontfeature",
+ ["fr"]="reglerfonctionnalitepolice",
+ },
+ ["setfontsolution"]={
+ ["en"]="setfontsolution",
+ ["fr"]="reglersolutionpolice",
+ },
+ ["setfontstrut"]={
+ ["en"]="setfontstrut",
+ ["fr"]="reglerentretoisepolice",
+ },
+ ["sethyphenationfeatures"]={
+ ["en"]="sethyphenationfeatures",
+ ["fr"]="reglerfonctionnalitescesure",
+ },
+ ["setmainbodyfont"]={
+ ["en"]="setmainbodyfont",
+ ["fr"]="reglerpolicedecorpsprincipale",
+ },
+ ["setmode"]={
+ ["en"]="setmode",
+ ["fr"]="reglermode",
+ },
+ ["setnote"]={
+ ["en"]="setnote",
+ ["fr"]="reglernote",
+ },
+ ["setnotetext"]={
+ ["en"]="setnotetext",
+ ["fr"]="reglertextenote",
+ },
["setnumber"]={
["cs"]="setnumber",
["de"]="setnumber",
["en"]="setnumber",
- ["fr"]="affectenumero",
+ ["fr"]="reglernumero",
["it"]="setnumber",
["nl"]="setnummer",
["pe"]="تعیینشماره",
["ro"]="setnumber",
},
+ ["setperiodkerning"]={
+ ["en"]="setperiodkerning",
+ ["fr"]="reglerapprochepoint",
+ },
+ ["setsecondpasscharacteralign"]={
+ ["en"]="setsecondpasscharacteralign",
+ ["fr"]="regleralignercaracteresecondepasse",
+ },
+ ["setsmallbodyfont"]={
+ ["en"]="setsmallbodyfont",
+ ["fr"]="reglerpolicedecorpspetite",
+ },
+ ["setsystemmode"]={
+ ["en"]="setsystemmode",
+ ["fr"]="reglermodesysteme",
+ },
["settextcontent"]={
["cs"]="settextcontent",
["de"]="settext",
["en"]="settextcontent",
- ["fr"]="settext",
+ ["fr"]="reglercontenutexte",
["it"]="settext",
["nl"]="steltekstinhoudin",
["pe"]="تعیینمحتوایمتن",
@@ -3502,7 +4053,7 @@ return {
["cs"]="settextvariable",
["de"]="settextvariable",
["en"]="settextvariable",
- ["fr"]="affectevariabletexte",
+ ["fr"]="reglervariabletexte",
["it"]="setvariabiletesto",
["nl"]="kentekstvariabeletoe",
["pe"]="تعیینمتغیرمتن",
@@ -3512,7 +4063,7 @@ return {
["cs"]="nastavzarovnani",
["de"]="stelleausrichtungein",
["en"]="setupalign",
- ["fr"]="reglealignement",
+ ["fr"]="configureraligner",
["it"]="impostaallineamento",
["nl"]="steluitlijnenin",
["pe"]="بارگذاریتنظیم",
@@ -3522,7 +4073,7 @@ return {
["cs"]="setupanswerarea",
["de"]="setupanswerarea",
["en"]="setupanswerarea",
- ["fr"]="setupanswerarea",
+ ["fr"]="configurerzonereponse",
["it"]="setupanswerarea",
["nl"]="stelantwoordgebiedin",
["pe"]="setupanswerarea",
@@ -3532,17 +4083,21 @@ return {
["cs"]="nastavusporadani",
["de"]="stelleanordnenein",
["en"]="setuparranging",
- ["fr"]="reglearrangement",
+ ["fr"]="configurerarrangement",
["it"]="impostaparranging",
["nl"]="stelarrangerenin",
["pe"]="بارگذاریترتیب",
["ro"]="seteazaaranjareapag",
},
+ ["setupattachment"]={
+ ["en"]="setupattachment",
+ ["fr"]="configurepiecejointe",
+ },
["setupbackground"]={
["cs"]="nastavpozadi",
["de"]="stellehintergrundein",
["en"]="setupbackground",
- ["fr"]="reglearriereplan",
+ ["fr"]="configurerarriereplan",
["it"]="impostasfondo",
["nl"]="stelachtergrondin",
["pe"]="بارگذاریپسزمینه",
@@ -3552,7 +4107,7 @@ return {
["cs"]="nastavpozadi",
["de"]="stellehintergruendeein",
["en"]="setupbackgrounds",
- ["fr"]="reglearriereplans",
+ ["fr"]="configurerarriereplans",
["it"]="impostasfondi",
["nl"]="stelachtergrondenin",
["pe"]="بارگذاریپسزمینهها",
@@ -3562,7 +4117,7 @@ return {
["cs"]="nastavcernelinky",
["de"]="stellerechteckein",
["en"]="setupblackrules",
- ["fr"]="reglelignesnoires",
+ ["fr"]="configurertraitsepais",
["it"]="impostalineenere",
["nl"]="stelblokjesin",
["pe"]="بارگذاریخطهایسیاه",
@@ -3572,7 +4127,7 @@ return {
["cs"]="nastavpreskok",
["de"]="stelleblankoein",
["en"]="setupblank",
- ["fr"]="definitvide",
+ ["fr"]="configurervierge",
["it"]="impostarigovuoto",
["nl"]="stelblankoin",
["pe"]="بارگذاریخالی",
@@ -3582,7 +4137,7 @@ return {
["cs"]="nastavblok",
["de"]="stelleblockein",
["en"]="setupblock",
- ["fr"]="reglebloc",
+ ["fr"]="configurerbloc",
["it"]="impostablocco",
["nl"]="stelblokin",
["pe"]="بارگذاریبلوک",
@@ -3592,7 +4147,7 @@ return {
["cs"]="nastavzakladnifont",
["de"]="stellefliesstextein",
["en"]="setupbodyfont",
- ["fr"]="reglepolicecorps",
+ ["fr"]="configurerpolicedecorps",
["it"]="impostafontdeltesto",
["nl"]="stelkorpsin",
["pe"]="بارگذاریقلممتن",
@@ -3602,7 +4157,7 @@ return {
["cs"]="nastavprostredizakladnihofontu",
["de"]="stellefliesstextumgebungein",
["en"]="setupbodyfontenvironment",
- ["fr"]="regleenvironnementpolicecorps",
+ ["fr"]="configurerenvironnementpolicedecorps",
["it"]="impostaambientefontdeltesto",
["nl"]="stelkorpsomgevingin",
["pe"]="بارگذاریمحیطقلممتن",
@@ -3612,7 +4167,7 @@ return {
["cs"]="nastavspodek",
["de"]="stelleuntenein",
["en"]="setupbottom",
- ["fr"]="regleinf",
+ ["fr"]="configurerbas",
["it"]="impostafondo",
["nl"]="stelonderin",
["pe"]="بارگذاریپایین",
@@ -3622,7 +4177,7 @@ return {
["cs"]="nastavdolnitexty",
["de"]="stelletextuntenein",
["en"]="setupbottomtexts",
- ["fr"]="regletextesinf",
+ ["fr"]="configurertextesbas",
["it"]="impostatestifondo",
["nl"]="stelondertekstenin",
["pe"]="بارگذاریمتنپایین",
@@ -3632,7 +4187,7 @@ return {
["cs"]="nastavbuffer",
["de"]="stellepufferein",
["en"]="setupbuffer",
- ["fr"]="reglebuffer",
+ ["fr"]="configurertampon",
["it"]="impostabuffer",
["nl"]="stelbufferin",
["pe"]="بارگذاریبافر",
@@ -3642,7 +4197,7 @@ return {
["cs"]="nastavtlacitka",
["de"]="stelleknopfein",
["en"]="setupbuttons",
- ["fr"]="regleboutons",
+ ["fr"]="configurerboutons",
["it"]="impostapulsanti",
["nl"]="stelbuttonsin",
["pe"]="بارگذاریدکمهها",
@@ -3652,7 +4207,7 @@ return {
["cs"]="nastavkapitalky",
["de"]="stelleversalienein",
["en"]="setupcapitals",
- ["fr"]="reglecapitales",
+ ["fr"]="configurercapitales",
["it"]="impostamaiuscole",
["nl"]="stelkapitalenin",
["pe"]="setupcapitals",
@@ -3662,7 +4217,7 @@ return {
["cs"]="nastavpopisek",
["de"]="stellebildunterschriftein",
["en"]="setupcaption",
- ["fr"]="regleintitule",
+ ["fr"]="configurerintitule",
["it"]="impostacaption",
["nl"]="stelblokkopjein",
["pe"]="بارگذاریشرح",
@@ -3672,17 +4227,29 @@ return {
["cs"]="nastavpopisky",
["de"]="stellebilderunterschriftein",
["en"]="setupcaptions",
- ["fr"]="regleintitules",
+ ["fr"]="configurerintitules",
["it"]="impostacaptions",
["nl"]="stelblokkopjesin",
["pe"]="بارگذاریشرحها",
["ro"]="seteazalegendele",
},
+ ["setupcharacteralign"]={
+ ["en"]="setupcharacteralign",
+ ["fr"]="configureralignercaractere",
+ },
+ ["setupcharacterkerning"]={
+ ["en"]="setupcharacterkerning",
+ ["fr"]="configurerapprochecaracteres",
+ },
+ ["setupcharacterspacing"]={
+ ["en"]="setupcharacterspacing",
+ ["fr"]="configurerespacementcaracteres",
+ },
["setupclipping"]={
["cs"]="nastavorez",
["de"]="stelleausschnittein",
["en"]="setupclipping",
- ["fr"]="regleclipping",
+ ["fr"]="configurerdecoupage",
["it"]="impostaclippling",
["nl"]="stelclipin",
["pe"]="بارگذاریچیدن",
@@ -3692,7 +4259,7 @@ return {
["cs"]="nastavbarvu",
["de"]="stellefarbeein",
["en"]="setupcolor",
- ["fr"]="reglecouleur",
+ ["fr"]="configurercouleur",
["it"]="impostacolore",
["nl"]="stelkleurin",
["pe"]="بارگذاریرنگ",
@@ -3702,7 +4269,7 @@ return {
["cs"]="nastavbarvy",
["de"]="stellefarbenein",
["en"]="setupcolors",
- ["fr"]="reglecouleurs",
+ ["fr"]="configurercouleurs",
["it"]="impostacolori",
["nl"]="stelkleurenin",
["pe"]="بارگذاریرنگها",
@@ -3712,7 +4279,7 @@ return {
["cs"]="nastavsloupce",
["de"]="stellespaltenein",
["en"]="setupcolumns",
- ["fr"]="reglecolonnes",
+ ["fr"]="configurercolonnes",
["it"]="impostacolonne",
["nl"]="stelkolommenin",
["pe"]="بارگذاریستونها",
@@ -3722,7 +4289,7 @@ return {
["cs"]="setupcolumnset",
["de"]="setupcolumnset",
["en"]="setupcolumnset",
- ["fr"]="reglejeucolonne",
+ ["fr"]="configurerjeucolonnes",
["it"]="impostagruppocolonne",
["nl"]="stelkolomgroepin",
["pe"]="بارگذاریمجموعهستون",
@@ -3732,7 +4299,7 @@ return {
["cs"]="setupcolumnsetlines",
["de"]="setupcolumnsetlines",
["en"]="setupcolumnsetlines",
- ["fr"]="setupcolumnsetlines",
+ ["fr"]="configurerlignesjeucolonnes",
["it"]="setupcolumnsetlines",
["nl"]="stelkolomgroepregelsin",
["pe"]="بارگذاریخطهایمجموعهستون",
@@ -3742,7 +4309,7 @@ return {
["cs"]="setupcolumnsetstart",
["de"]="setupcolumnsetstart",
["en"]="setupcolumnsetstart",
- ["fr"]="setupcolumnsetstart",
+ ["fr"]="configurerfinjeucolonnes",
["it"]="setupcolumnsetstart",
["nl"]="stelkolomgroepstartin",
["pe"]="بارگذاریشروعمجموعهستون",
@@ -3752,7 +4319,7 @@ return {
["cs"]="nastavspojeni",
["de"]="stellekombinationein",
["en"]="setupcombinations",
- ["fr"]="reglecombinaisons",
+ ["fr"]="configurercombinaisons",
["it"]="impostacombinazioni",
["nl"]="stelcombinatiesin",
["pe"]="بارگذاریترکیبها",
@@ -3762,7 +4329,7 @@ return {
["cs"]="nastavkombinovanyseznam",
["de"]="stellezusammengestelltelisteein",
["en"]="setupcombinedlist",
- ["fr"]="reglelisteimbriquee",
+ ["fr"]="configurerlistecombinee",
["it"]="impostaelencocombinato",
["nl"]="stelsamengesteldelijstin",
["pe"]="بارگذاریلیستترکیبی",
@@ -3772,45 +4339,51 @@ return {
["cs"]="nastavkomentar",
["de"]="stellekommentarein",
["en"]="setupcomment",
- ["fr"]="reglecommentaire",
+ ["fr"]="configurercommentaire",
["it"]="impostacommento",
["nl"]="stelcommentaarin",
["pe"]="بارگذاریتوضیح",
["ro"]="seteazacomentariu",
},
+ ["setupcounter"]={
+ ["en"]="setupcounter",
+ ["fr"]="configurercompteur",
+ },
+ ["setupdescription"]={
+ ["en"]="setupdescription",
+ ["fr"]="configurerdescription",
+ ["nl"]="steldoordefinierenin",
+ },
["setupdescriptions"]={
["cs"]="nastavpopisy",
["de"]="definierebeschreibungen",
["en"]="setupdescriptions",
- ["fr"]="regledescriptions",
+ ["fr"]="configurerdescriptions",
["it"]="impostadescrizioni",
["nl"]="steldoordefinierenin",
["pe"]="بارگذاریشرح",
["ro"]="seteazadescriere",
},
- ["setupdescription"]={
- ["en"]="setupdescription",
- ["nl"]="steldoordefinierenin",
+ ["setupenumeration"]={
+ ["en"]="setupenumeration",
+ ["fr"]="configurerénumération",
+ ["nl"]="steldoornummerenin",
},
["setupenumerations"]={
["cs"]="nastavvycty",
["de"]="stellebeschreibungein",
["en"]="setupenumerations",
- ["fr"]="regleenumerations",
+ ["fr"]="configurerénumérations",
["it"]="impostaenumerazioni",
["nl"]="steldoornummerenin",
["pe"]="بارگذاریشمارهگذاریها",
["ro"]="seteazaenumerare",
},
- ["setupenumeration"]={
- ["en"]="setupenumeration",
- ["nl"]="steldoornummerenin",
- },
["setupexternalfigures"]={
["cs"]="nastavexterniobrazy",
["de"]="stelleexterneabbildungenein",
["en"]="setupexternalfigures",
- ["fr"]="reglefiguresexternes",
+ ["fr"]="configurerfiguresexterne",
["it"]="impostafigureesterne",
["nl"]="stelexternefigurenin",
["pe"]="بارگذاریشکلهایخارجی",
@@ -3820,7 +4393,7 @@ return {
["cs"]="nastavpole",
["de"]="stellefeldein",
["en"]="setupfield",
- ["fr"]="reglechamp",
+ ["fr"]="configurerchamp",
["it"]="impostacampo",
["nl"]="stelveldin",
["pe"]="بارگذاریمیدان",
@@ -3830,7 +4403,7 @@ return {
["cs"]="nastavvsechnapole",
["de"]="stellefelderin",
["en"]="setupfields",
- ["fr"]="reglechamps",
+ ["fr"]="configurerchamps",
["it"]="impostacampi",
["nl"]="stelveldenin",
["pe"]="بارگذاریمیدانها",
@@ -3840,7 +4413,7 @@ return {
["cs"]="nastavvyplnoveradky",
["de"]="stellegefuelltezeileein",
["en"]="setupfillinlines",
- ["fr"]="regleremplitligne",
+ ["fr"]="configurerlignesarenseigner",
["it"]="impostarigheriempimento",
["nl"]="stelinvulregelsin",
["pe"]="بارگذاریپرکردنخطها",
@@ -3850,17 +4423,21 @@ return {
["cs"]="nastavvyplnovelinky",
["de"]="stellegefuelltesrechteckein",
["en"]="setupfillinrules",
- ["fr"]="regleremplitlignesreglees",
+ ["fr"]="configurertraitsarenseigner",
["it"]="impostalineeriempimento",
["nl"]="stelinvullijnenin",
["pe"]="بارگذاریدرجدرخطها",
["ro"]="seteazarigleumplere",
},
+ ["setupfirstline"]={
+ ["en"]="setupfirstline",
+ ["fr"]="configurerpremiereligne",
+ },
["setupfloat"]={
["cs"]="nastavplvouciobjekt",
["de"]="stellegleitobjektein",
["en"]="setupfloat",
- ["fr"]="regleflottant",
+ ["fr"]="configurerflottant",
["it"]="impostaoggettomobile",
["nl"]="stelplaatsblokin",
["pe"]="بارگذاریشناور",
@@ -3870,7 +4447,7 @@ return {
["cs"]="nastavplvouciobjekty",
["de"]="stellegleitobjekteein",
["en"]="setupfloats",
- ["fr"]="regleflottants",
+ ["fr"]="configurerflottants",
["it"]="impostaoggettimobili",
["nl"]="stelplaatsblokkenin",
["pe"]="بارگذاریشناورها",
@@ -3880,17 +4457,33 @@ return {
["cs"]="nastavdeleniplvoucichobjektu",
["de"]="stelleplatziegeteiltegleitobjekt",
["en"]="setupfloatsplitting",
- ["fr"]="regleseparationflottant",
+ ["fr"]="configurerpartageflottants",
["it"]="impostaspezzamentooggettomobile",
["nl"]="stelplaatsbloksplitsenin",
["pe"]="بارگذاریشکافتنشناورها",
["ro"]="seteazaimpartireafloat",
},
+ ["setupfontexpansion"]={
+ ["en"]="setupfontexpansion",
+ ["fr"]="configurerexpansionpolice",
+ },
+ ["setupfontprotrusion"]={
+ ["en"]="setupfontprotrusion",
+ ["fr"]="configurerprotrusionpolice",
+ },
+ ["setupfonts"]={
+ ["en"]="setupfonts",
+ ["fr"]="configurerpolices",
+ },
+ ["setupfontsolution"]={
+ ["en"]="setupfontsolution",
+ ["fr"]="configuresolutionpolice",
+ },
["setupfooter"]={
["cs"]="nastavupati",
["de"]="stellefusszeileein",
["en"]="setupfooter",
- ["fr"]="reglepdp",
+ ["fr"]="configurerpdp",
["it"]="impostapdp",
["nl"]="stelvoetin",
["pe"]="بارگذاریتهبرگ",
@@ -3900,7 +4493,7 @@ return {
["cs"]="nastavtextyupati",
["de"]="stellefusszeilentextein",
["en"]="setupfootertexts",
- ["fr"]="regletextespdp",
+ ["fr"]="configurertextespdp",
["it"]="impostatestipdp",
["nl"]="stelvoettekstenin",
["pe"]="بارگذاریمتنپانوشت",
@@ -3910,7 +4503,7 @@ return {
["cs"]="nastavdefinicipoznamekpodcarou",
["de"]="stellefussnotendefinitionein",
["en"]="setupfootnotedefinition",
- ["fr"]="definitnotepdp",
+ ["fr"]="configurerdefinitionnotebdp",
["it"]="impostadefinizionenotepdp",
["nl"]="stelvoetnootdefinitiein",
["pe"]="بارگذاریتعریفپانوشت",
@@ -3920,7 +4513,7 @@ return {
["cs"]="nastavpoznamkypodcarou",
["de"]="stellefussnotenein",
["en"]="setupfootnotes",
- ["fr"]="reglenotepdp",
+ ["fr"]="configurernotesbdp",
["it"]="impostanotepdp",
["nl"]="stelvoetnotenin",
["pe"]="بارگذاریپانوشتها",
@@ -3930,55 +4523,57 @@ return {
["cs"]="setupforms",
["de"]="setupforms",
["en"]="setupforms",
- ["fr"]="regleformulaires",
+ ["fr"]="configurerformulaires",
["it"]="impostaforms",
["nl"]="stelformulierenin",
["pe"]="بارگذاریطرح",
["ro"]="seteazaformulare",
},
+ ["setupformula"]={
+ ["en"]="setupformula",
+ ["fr"]="configurerformule",
+ ["nl"]="stelformulein",
+ },
["setupformulas"]={
["cs"]="nastavrovnice",
["de"]="stelleformelnein",
["en"]="setupformulae",
- ["fr"]="regleformules",
+ ["fr"]="configurerformules",
["it"]="impostaformule",
["nl"]="stelformulesin",
["pe"]="بارگذاریفرمولها",
["ro"]="seteazaformule",
},
- ["setupformula"]={
- ["en"]="setupformula",
- ["nl"]="stelformulein",
- },
["setupframed"]={
["cs"]="nastavoramovani",
["de"]="stelleumrahmtein",
["en"]="setupframed",
- ["fr"]="regleencadre",
+ ["fr"]="configurerencadre",
["it"]="impostaincorniciato",
["nl"]="stelomlijndin",
["pe"]="بارگذاریقالبی",
["ro"]="seteazainconjurat",
},
+ ["setupframedtext"]={
+ ["en"]="setupframedtext",
+ ["fr"]="configurertexteencadre",
+ ["nl"]="stelkadertekstin",
+ },
["setupframedtexts"]={
["cs"]="nastavoramovanetexty",
["de"]="stelleumrahmtetexteein",
["en"]="setupframedtexts",
- ["fr"]="setupframedtexts",
+ ["fr"]="configurertextesencadres",
["it"]="impostatestiincorniciati",
["nl"]="stelkadertekstenin",
["pe"]="بارگذاریمتنقالبی",
["ro"]="definestetexteinconjurate",
},
- ["setupframedtext"]={
- ["en"]="setupframedtext",
- ["nl"]="stelkadertekstin",
- },
["setuphead"]={
["cs"]="nastavnadpis",
["de"]="stelleueberschriftein",
["en"]="setuphead",
- ["fr"]="regletete",
+ ["fr"]="configurertête",
["it"]="impostatesta",
["nl"]="stelkopin",
["pe"]="بارگذاریسر",
@@ -3988,7 +4583,7 @@ return {
["cs"]="nastavzahlavi",
["de"]="stellekopfzeileein",
["en"]="setupheader",
- ["fr"]="regleentete",
+ ["fr"]="configurerentête",
["it"]="impostainstestazione",
["nl"]="stelhoofdin",
["pe"]="بارگذاریسربرگ",
@@ -3998,7 +4593,7 @@ return {
["cs"]="nastavtextyzahlavi",
["de"]="stellekopfzeilentextein",
["en"]="setupheadertexts",
- ["fr"]="regletextesentete",
+ ["fr"]="configurertextesentête",
["it"]="impostatestiintestazioni",
["nl"]="stelhoofdtekstenin",
["pe"]="بارگذاریمتنسربرگ",
@@ -4008,7 +4603,7 @@ return {
["cs"]="nastavcislonadpisu",
["de"]="stellekopfzahlein",
["en"]="setupheadnumber",
- ["fr"]="reglenumerotete",
+ ["fr"]="configurernumerotête",
["it"]="impostanumerotesta",
["nl"]="stelkopnummerin",
["pe"]="بارگذاریشمارهسر",
@@ -4018,7 +4613,7 @@ return {
["cs"]="nastavnadpisy",
["de"]="stelleueberschriftenein",
["en"]="setupheads",
- ["fr"]="regletetes",
+ ["fr"]="configurertêtes",
["it"]="impostateste",
["nl"]="stelkoppenin",
["pe"]="بارگذاریسرها",
@@ -4028,17 +4623,21 @@ return {
["cs"]="nastavtexthlavicky",
["de"]="stelleueberschrifttextein",
["en"]="setupheadtext",
- ["fr"]="regletextetete",
+ ["fr"]="configurertextêtete",
["it"]="impostatestointestazioni",
["nl"]="stelkoptekstin",
["pe"]="بارگذاریمتنسر",
["ro"]="seteazatexttitlu",
},
+ ["setuphyphenation"]={
+ ["en"]="setuphyphenation",
+ ["fr"]="configurercesure",
+ },
["setuphyphenmark"]={
["cs"]="nastavdelitko",
["de"]="stellebindestrichein",
["en"]="setuphyphenmark",
- ["fr"]="reglemarquagehyphenation",
+ ["fr"]="configurermarquecesure",
["it"]="impostasegnosillabazione",
["nl"]="stelkoppeltekenin",
["pe"]="بارگذارینشانهشکستن",
@@ -4046,13 +4645,14 @@ return {
},
["setupindentedtext"]={
["en"]="setupindentedtext",
+ ["fr"]="configurertexteindente",
["nl"]="stelingesprongentextin",
},
["setupindenting"]={
["cs"]="nastavodsazovani",
["de"]="stelleeinziehenein",
["en"]="setupindenting",
- ["fr"]="reglecomposeenalinea",
+ ["fr"]="configurerindentation",
["it"]="impostarientro",
["nl"]="stelinspringenin",
["pe"]="بارگذاریتورفتگی",
@@ -4062,7 +4662,7 @@ return {
["cs"]="nastavmarginalie",
["de"]="stelleinmarginalieein",
["en"]="setupinmargin",
- ["fr"]="regledansmarge",
+ ["fr"]="configurerdansmarge",
["it"]="impostainmargine",
["nl"]="stelinmargein",
["pe"]="بارگذاریدرونحاشیه",
@@ -4072,7 +4672,7 @@ return {
["cs"]="nastavinterakci",
["de"]="stelleinteraktionein",
["en"]="setupinteraction",
- ["fr"]="regleinteraction",
+ ["fr"]="configurerinteraction",
["it"]="impostainterazione",
["nl"]="stelinteractiein",
["pe"]="بارگذاریپانل",
@@ -4082,7 +4682,7 @@ return {
["cs"]="nastavinterakcnilistu",
["de"]="stelleinteraktionsbalkenein",
["en"]="setupinteractionbar",
- ["fr"]="reglebarreinteraction",
+ ["fr"]="configurerbarreinteraction",
["it"]="impostabarrainterazione",
["nl"]="stelinteractiebalkin",
["pe"]="بارگذاریمیلهپانل",
@@ -4092,7 +4692,7 @@ return {
["cs"]="nastavinterakcnimenu",
["de"]="stelleinteraktionsmenueein",
["en"]="setupinteractionmenu",
- ["fr"]="reglemenuinteraction",
+ ["fr"]="configurermenuinteraction",
["it"]="impostamenuinterazione",
["nl"]="stelinteractiemenuin",
["pe"]="بارگذاریمنویپانل",
@@ -4102,7 +4702,7 @@ return {
["cs"]="nastavinterakcniobrazovku",
["de"]="stelleinteraktionsbildschirmein",
["en"]="setupinteractionscreen",
- ["fr"]="regleecraninteraction",
+ ["fr"]="configurerecraninteraction",
["it"]="impostaschermointerazione",
["nl"]="stelinteractieschermin",
["pe"]="بارگذاریپردهپانل",
@@ -4112,7 +4712,7 @@ return {
["cs"]="nastavmeziradkovoumezeru",
["de"]="stellezeilenabstandein",
["en"]="setupinterlinespace",
- ["fr"]="regleespacementinterligne",
+ ["fr"]="configurerespaceinterligne",
["it"]="impostainterlinea",
["nl"]="stelinterliniein",
["pe"]="بارگذاریفاصلهبینخط",
@@ -4122,7 +4722,7 @@ return {
["cs"]="setupitemgroup",
["de"]="setupitemgroup",
["en"]="setupitemgroup",
- ["fr"]="setupitemgroup",
+ ["fr"]="configurergroupedéléments",
["it"]="setupitemgroup",
["nl"]="stelitemgroepin",
["pe"]="بارگذاریگروهآیتم",
@@ -4132,7 +4732,7 @@ return {
["cs"]="nastavvycty",
["de"]="stelleaufzaehlungenein",
["en"]="setupitemizations",
- ["fr"]="reglegroupeselements",
+ ["fr"]="configurergroupesdéléments",
["it"]="impostaelencazioni",
["nl"]="stelopsommingenin",
["pe"]="بارگذاریگروههایآیتم",
@@ -4142,7 +4742,7 @@ return {
["cs"]="nastavpolozky",
["de"]="stellepostenein",
["en"]="setupitems",
- ["fr"]="regleelements",
+ ["fr"]="configureréléments",
["it"]="impostaelementi",
["nl"]="stelitemsin",
["pe"]="بارگذاریآیتمها",
@@ -4152,7 +4752,7 @@ return {
["cs"]="nastavtextpopisku",
["de"]="stellelabeltextein",
["en"]="setuplabeltext",
- ["fr"]="reglelabeltexte",
+ ["fr"]="configureretiquettetexte",
["it"]="impostatestoetichette",
["nl"]="stellabeltekstin",
["pe"]="باگذاریمتنبرچسب",
@@ -4162,7 +4762,7 @@ return {
["cs"]="nastavjazyk",
["de"]="stellespracheein",
["en"]="setuplanguage",
- ["fr"]="reglelangue",
+ ["fr"]="configurerlangue",
["it"]="impostalingua",
["nl"]="steltaalin",
["pe"]="بارگذاریزبان",
@@ -4172,7 +4772,7 @@ return {
["cs"]="nastavvzhled",
["de"]="stellelayoutein",
["en"]="setuplayout",
- ["fr"]="regledisposition",
+ ["fr"]="configurermiseenpage",
["it"]="impostalayout",
["nl"]="stellayoutin",
["pe"]="بارگذاریطرحبندی",
@@ -4182,17 +4782,21 @@ return {
["cs"]="nastavlegendu",
["de"]="stellelegendeein",
["en"]="setuplegend",
- ["fr"]="reglelegende",
+ ["fr"]="configurerlegende",
["it"]="impostalegenda",
["nl"]="stellegendain",
["pe"]="بارگذاریراهنما",
["ro"]="seteazalegenda",
},
+ ["setuplinenote"]={
+ ["en"]="setuplinenote",
+ ["fr"]="configurernotedeligne",
+ },
["setuplinenumbering"]={
["cs"]="nastavcislovaniradku",
["de"]="stellezeilennumerierungein",
["en"]="setuplinenumbering",
- ["fr"]="reglenumerotationligne",
+ ["fr"]="configurernumérotationligne",
["it"]="impostanumerazionerighe",
["nl"]="stelregelnummerenin",
["pe"]="بارگذاریشمارهگذاریخط",
@@ -4202,7 +4806,7 @@ return {
["cs"]="nastavradky",
["de"]="stellezeilenein",
["en"]="setuplines",
- ["fr"]="reglelignes",
+ ["fr"]="configurerlignes",
["it"]="impostarighe",
["nl"]="stelregelsin",
["pe"]="بارگذاریخطها",
@@ -4212,7 +4816,7 @@ return {
["cs"]="nastavsirkucary",
["de"]="stellelinienbreiteein",
["en"]="setuplinewidth",
- ["fr"]="regleepaisseurligne",
+ ["fr"]="configurerepaisseurtrait",
["it"]="impostaampiezzariga",
["nl"]="stellijndiktein",
["pe"]="بارگذاریعرضخط",
@@ -4222,7 +4826,7 @@ return {
["cs"]="nastavseznam",
["de"]="stellelisteein",
["en"]="setuplist",
- ["fr"]="regleliste",
+ ["fr"]="configurerliste",
["it"]="impostaelenco",
["nl"]="stellijstin",
["pe"]="بارگذاریلیست",
@@ -4232,35 +4836,37 @@ return {
["cs"]="nastavupravu",
["de"]="stelleumbruchein",
["en"]="setupmakeup",
- ["fr"]="reglemakeup",
+ ["fr"]="configurercomposition",
["it"]="impostamakeup",
["nl"]="stelopmaakin",
["pe"]="بارگذاریآرایش",
["ro"]="seteazamakeup",
},
+ ["setupmarginblock"]={
+ ["en"]="setupmarginblock",
+ ["fr"]="configurerblocmarginal",
+ ["nl"]="stelmargeblokkenin",
+ },
["setupmarginblocks"]={
["cs"]="nastavmarginalniblok",
["de"]="stellemarginalblockein",
["en"]="setupmarginblocks",
- ["fr"]="regleblocmarge",
+ ["fr"]="configurerblocmarge",
["it"]="impostablocchimargine",
["nl"]="stelmargeblokkenin",
["pe"]="بارگذاریبلوکهایحاشیه",
["ro"]="seteazablocurimarginale",
},
- ["setupmarginblock"]={
- ["en"]="setupmarginblock",
- ["nl"]="stelmargeblokkenin",
- },
["setupmargindata"]={
["en"]="setupmargindata",
+ ["fr"]="configurerdonneesmarginales",
["nl"]="stelinmargein",
},
["setupmarginrules"]={
["cs"]="nastavmarginalnilinky",
["de"]="stellemarginallinieein",
["en"]="setupmarginrules",
- ["fr"]="reglemargereglee",
+ ["fr"]="configurertraitsmarge",
["it"]="impostalineemargine",
["nl"]="stelkantlijnin",
["pe"]="بارگذاریخطهایحاشیه",
@@ -4270,7 +4876,7 @@ return {
["cs"]="nastavznaceni",
["de"]="stellebeschriftungein",
["en"]="setupmarking",
- ["fr"]="reglemarquage",
+ ["fr"]="configurermarquage",
["it"]="impostamarcatura",
["nl"]="stelmarkeringin",
["pe"]="بارگذارینشانهگذاری",
@@ -4280,7 +4886,7 @@ return {
["cs"]="setupmathalignment",
["de"]="setupmathalignment",
["en"]="setupmathalignment",
- ["fr"]="setupmathalignment",
+ ["fr"]="configureralignementmath",
["it"]="setupmathalignment",
["nl"]="stelwiskundeuitlijnenin",
["pe"]="بارگذاریتنظیمریاضی",
@@ -4290,17 +4896,33 @@ return {
["cs"]="nastavzuzeni",
["de"]="stelleengerein",
["en"]="setupnarrower",
- ["fr"]="reglecompoetroite",
+ ["fr"]="configurerplusetroit",
["it"]="impostapiustretto",
["nl"]="stelsmallerin",
["pe"]="بارگذاریباریکتر",
["ro"]="seteazaingust",
},
+ ["setupnotation"]={
+ ["en"]="setupnotation",
+ ["fr"]="configurernotation",
+ },
+ ["setupnotations"]={
+ ["en"]="setupnotations",
+ ["fr"]="configurernotations",
+ },
+ ["setupnote"]={
+ ["en"]="setupnote",
+ ["fr"]="configurenote",
+ },
+ ["setupnotes"]={
+ ["en"]="setupnotes",
+ ["fr"]="configurenotes",
+ },
["setupnumber"]={
["cs"]="setupnumber",
["de"]="setupnumber",
["en"]="setupnumber",
- ["fr"]="reglenumero",
+ ["fr"]="configurernumero",
["it"]="impostanumerazione",
["nl"]="stelnummerin",
["pe"]="بارگذاریشماره",
@@ -4310,7 +4932,7 @@ return {
["cs"]="nastavcislovani",
["de"]="stellenummerierungein",
["en"]="setupnumbering",
- ["fr"]="reglenumerotation",
+ ["fr"]="configurernumérotation",
["it"]="impostanumerazione",
["nl"]="stelnummerenin",
["pe"]="بارگذاریشمارهگذاری",
@@ -4320,7 +4942,7 @@ return {
["cs"]="nastavumisteniprotejsku",
["de"]="stellegegenueberplatzierenein",
["en"]="setupoppositeplacing",
- ["fr"]="regleplacementopposition",
+ ["fr"]="configurerplacementopposition",
["it"]="impostaposizionamentoopposti",
["nl"]="stelnaastplaatsenin",
["pe"]="بارگذاریدرجمخالف",
@@ -4330,7 +4952,7 @@ return {
["cs"]="nastavvystup",
["de"]="stelleausgabeein",
["en"]="setupoutput",
- ["fr"]="reglesortie",
+ ["fr"]="configurersortie",
["it"]="impostaoutput",
["nl"]="steluitvoerin",
["pe"]="بارگذاریخروجی",
@@ -4340,7 +4962,7 @@ return {
["cs"]="nastavkomentarstrany",
["de"]="stelleseitenkommentarein",
["en"]="setuppagecomment",
- ["fr"]="reglecommentairepage",
+ ["fr"]="configurercommentairepage",
["it"]="impostacommentopagina",
["nl"]="stelpaginacommentaarin",
["pe"]="بارگذاریتوضیحصفحه",
@@ -4350,7 +4972,7 @@ return {
["cs"]="nastavcislostrany",
["de"]="stelleseitennummerein",
["en"]="setuppagenumber",
- ["fr"]="reglenumeropage",
+ ["fr"]="configurernumeropage",
["it"]="impostanumeropagina",
["nl"]="stelpaginanummerin",
["pe"]="بارگذاریشمارهصفحه",
@@ -4360,7 +4982,7 @@ return {
["cs"]="nastavcislovanistran",
["de"]="stelleseitennummeriernungein",
["en"]="setuppagenumbering",
- ["fr"]="reglenumerotationpage",
+ ["fr"]="configurernumérotationpage",
["it"]="impostanumerazionepagina",
["nl"]="stelpaginanummeringin",
["pe"]="بارگذاریشمارهگذاریصفحه",
@@ -4370,7 +4992,7 @@ return {
["cs"]="nastavprechodstrany",
["de"]="stelleseitenuebergangein",
["en"]="setuppagetransitions",
- ["fr"]="regletransitionspage",
+ ["fr"]="configurertransitionpage",
["it"]="impostatransizionepagina",
["nl"]="stelpaginaovergangenin",
["pe"]="بارگذاریگذارصفحه",
@@ -4380,7 +5002,7 @@ return {
["cs"]="nastavpaletu",
["de"]="stellepaletteein",
["en"]="setuppalet",
- ["fr"]="reglepalette",
+ ["fr"]="configurerpalette",
["it"]="impostatavolozza",
["nl"]="stelpaletin",
["pe"]="بارگذاریلوح",
@@ -4390,7 +5012,7 @@ return {
["cs"]="setuppaper",
["de"]="setuppaper",
["en"]="setuppaper",
- ["fr"]="reglepapier",
+ ["fr"]="configurerpapier",
["it"]="setuppaper",
["nl"]="stelpapierin",
["pe"]="بارگذاریبرگ",
@@ -4400,7 +5022,7 @@ return {
["cs"]="nastavvelikostpapiru",
["de"]="stellepapierformatein",
["en"]="setuppapersize",
- ["fr"]="regletaillepapier",
+ ["fr"]="configurertaillepapier",
["it"]="impostadimensionicarta",
["nl"]="stelpapierformaatin",
["pe"]="بارگذاریاندازهبرگ",
@@ -4410,7 +5032,7 @@ return {
["cs"]="nastavcislovaniodstavcu",
["de"]="stelleabsatznummerierungein",
["en"]="setupparagraphnumbering",
- ["fr"]="reglenumerotationparagraphe",
+ ["fr"]="configurernumérotationparagraphe",
["it"]="impostanumerazionecapoversi",
["nl"]="stelparagraafnummerenin",
["pe"]="بارگذاریشمارهگذاریپاراگراف",
@@ -4420,17 +5042,21 @@ return {
["cs"]="nastavodstavce",
["de"]="stelleabsaetzeein",
["en"]="setupparagraphs",
- ["fr"]="regleparagraphes",
+ ["fr"]="configurerparagraphe",
["it"]="impostacapoversi",
["nl"]="stelalineasin",
["pe"]="بارگذاریپاراگرافها",
["ro"]="seteazaparagrafe",
},
+ ["setupperiodkerning"]={
+ ["en"]="setupperiodkerning",
+ ["fr"]="configurerapprochepoint",
+ },
["setupplacement"]={
["cs"]="setupplacement",
["de"]="setupplacement",
["en"]="setupplacement",
- ["fr"]="setupplacement",
+ ["fr"]="configurerplacement",
["it"]="setupplacement",
["nl"]="stelplaatsin",
["pe"]="بارگذاریجانشانی",
@@ -4440,7 +5066,7 @@ return {
["cs"]="nastavumistovani",
["de"]="stellepositionierenein",
["en"]="setuppositioning",
- ["fr"]="reglepositionnement",
+ ["fr"]="configurerpositionnement",
["it"]="impostaposizionamento",
["nl"]="stelpositionerenin",
["pe"]="بارگذاریمکانگذاری",
@@ -4450,7 +5076,7 @@ return {
["cs"]="nastavprofily",
["de"]="stelleprofilein",
["en"]="setupprofiles",
- ["fr"]="regleprofils",
+ ["fr"]="configurerprofils",
["it"]="impostaprofili",
["nl"]="stelprofielenin",
["pe"]="بارگذاریپروفایلها",
@@ -4460,7 +5086,7 @@ return {
["cs"]="nastavprogramy",
["de"]="stelleprogrammein",
["en"]="setupprograms",
- ["fr"]="regleprogrammes",
+ ["fr"]="configurerprogrammes",
["it"]="impostaprogrammi",
["nl"]="stelprogrammasin",
["pe"]="بارگذاریبرنامهها",
@@ -4470,7 +5096,7 @@ return {
["cs"]="nastavpublikace",
["de"]="stellepublikationein",
["en"]="setuppublications",
- ["fr"]="reglepublications",
+ ["fr"]="configurerpublications",
["it"]="impostapubblicazioni",
["nl"]="stelpublicatiesin",
["pe"]="بارگذارینشرها",
@@ -4480,7 +5106,7 @@ return {
["cs"]="nastavcitaci",
["de"]="stellezitierenein",
["en"]="setupquote",
- ["fr"]="demarreciter",
+ ["fr"]="configurerciter",
["it"]="impostamenzione",
["nl"]="stelciterenin",
["pe"]="بارگذارینقل",
@@ -4490,7 +5116,7 @@ return {
["cs"]="nastavseznamodkazu",
["de"]="stellereferenzlisteein",
["en"]="setupreferencelist",
- ["fr"]="reglelistereference",
+ ["fr"]="configurerlistereference",
["it"]="impostalistariferimenti",
["nl"]="stelreferentielijstin",
["pe"]="بارگذاریلیستمرجع",
@@ -4500,7 +5126,7 @@ return {
["cs"]="nastavodkazovani",
["de"]="stellereferenzierenein",
["en"]="setupreferencing",
- ["fr"]="reglereferencage",
+ ["fr"]="configurerreferencement",
["it"]="impostariferimento",
["nl"]="stelrefererenin",
["pe"]="بارگذاریارجاع",
@@ -4510,7 +5136,7 @@ return {
["cs"]="nastavrejstrik",
["de"]="stelleregisterein",
["en"]="setupregister",
- ["fr"]="regleregistre",
+ ["fr"]="configurerregistre",
["it"]="impostaregistro",
["nl"]="stelregisterin",
["pe"]="بارگذاریثبت",
@@ -4520,7 +5146,7 @@ return {
["cs"]="nastavotoceni",
["de"]="stelledrehenein",
["en"]="setuprotate",
- ["fr"]="regleoriente",
+ ["fr"]="configurerrotation",
["it"]="impostarotazione",
["nl"]="stelroterenin",
["pe"]="بارگذاریدوران",
@@ -4530,7 +5156,7 @@ return {
["cs"]="setuprule",
["de"]="setuprule",
["en"]="setuprule",
- ["fr"]="regleregle",
+ ["fr"]="configurertrait",
["it"]="impostalinea",
["nl"]="stellijnin",
["pe"]="بارگذاریخط",
@@ -4540,7 +5166,7 @@ return {
["cs"]="nastavrastr",
["de"]="stellerasterein",
["en"]="setupscreens",
- ["fr"]="regleecrans",
+ ["fr"]="configurerecran",
["it"]="impostaschermi",
["nl"]="stelrastersin",
["pe"]="بارگذاریپردهها",
@@ -4550,7 +5176,7 @@ return {
["cs"]="nastavsekci",
["de"]="stelleabschnittein",
["en"]="setupsection",
- ["fr"]="reglesection",
+ ["fr"]="configurersection",
["it"]="impostasezione",
["nl"]="stelsectiein",
["pe"]="بارگذاریبخش",
@@ -4560,7 +5186,7 @@ return {
["cs"]="nastavbloksekce",
["de"]="stelleabschnittsblockein",
["en"]="setupsectionblock",
- ["fr"]="regleblocsection",
+ ["fr"]="configurerblocsection",
["it"]="impostabloccosezione",
["nl"]="stelsectieblokin",
["pe"]="بارگذاریبلوکبخش",
@@ -4570,7 +5196,7 @@ return {
["cs"]="nastavtrideni",
["de"]="stellesortierenein",
["en"]="setupsorting",
- ["fr"]="regletri",
+ ["fr"]="configurertri",
["it"]="impostaordinamento",
["nl"]="stelsorterenin",
["pe"]="بارگذاریترتیب",
@@ -4580,7 +5206,7 @@ return {
["cs"]="nastavradkovani",
["de"]="stellespatiumein",
["en"]="setupspacing",
- ["fr"]="regleespacement",
+ ["fr"]="configurerespacement",
["it"]="impostaspaziatura",
["nl"]="stelspatieringin",
["pe"]="بارگذاریفضاگذاری",
@@ -4590,7 +5216,7 @@ return {
["cs"]="setupstartstop",
["de"]="setupstartstop",
["en"]="setupstartstop",
- ["fr"]="regledemarrestoppe",
+ ["fr"]="configurerdébutfin",
["it"]="impostainiziatermina",
["nl"]="stelstartstopin",
["pe"]="بارگذاریشروعپایان",
@@ -4600,7 +5226,7 @@ return {
["cs"]="setupstrut",
["de"]="setupstrut",
["en"]="setupstrut",
- ["fr"]="reglestrut",
+ ["fr"]="configurerentretoise",
["it"]="impostastrut",
["nl"]="stelstrutin",
["pe"]="بارگذاریبست",
@@ -4610,7 +5236,7 @@ return {
["cs"]="nastavpodcislostrany",
["de"]="stelleunterseitennummerein",
["en"]="setupsubpagenumber",
- ["fr"]="reglesousnumeropage",
+ ["fr"]="configurernumerosouspage",
["it"]="impostanumerosottopagina",
["nl"]="stelsubpaginanummerin",
["pe"]="بارگذاریشمارهزیرصفحه",
@@ -4620,7 +5246,7 @@ return {
["cs"]="nastavsadusymbolu",
["de"]="stellesymbolsetein",
["en"]="setupsymbolset",
- ["fr"]="reglejeusymboles",
+ ["fr"]="configurerjeusymboles",
["it"]="impostasetsimboli",
["nl"]="stelsymboolsetin",
["pe"]="بارگذاریمجموعهنماد",
@@ -4630,7 +5256,7 @@ return {
["cs"]="nastavsynchronizaci",
["de"]="stellesynchronisationein",
["en"]="setupsynchronization",
- ["fr"]="reglesynchronisation",
+ ["fr"]="configurersynchronisation",
["it"]="impostasincronizzazione",
["nl"]="stelsynchronisatiein",
["pe"]="بارگذاریتطابق",
@@ -4640,7 +5266,7 @@ return {
["cs"]="nastavsynchronizacnilistu",
["de"]="stellesynchronisationsbalkenein",
["en"]="setupsynchronizationbar",
- ["fr"]="reglebarresynchronisation",
+ ["fr"]="configurerbarresynchronisation",
["it"]="impostabarrasincronizzazione",
["nl"]="stelsynchronisatiebalkin",
["pe"]="بارگذاریمیلهتطابق",
@@ -4650,7 +5276,7 @@ return {
["cs"]="nastavsynonyma",
["de"]="stellesynonymein",
["en"]="setupsynonyms",
- ["fr"]="reglesynonymes",
+ ["fr"]="configurersynonymes",
["it"]="impostasinonimi",
["nl"]="stelsynoniemenin",
["pe"]="بارگذاریمترادفها",
@@ -4660,7 +5286,7 @@ return {
["cs"]="nastavsystem",
["de"]="stellesystemein",
["en"]="setupsystem",
- ["fr"]="reglesysteme",
+ ["fr"]="configurersysteme",
["it"]="impostasistema",
["nl"]="stelsysteemin",
["pe"]="بارگذاریسیستم",
@@ -4670,7 +5296,7 @@ return {
["cs"]="nastavtab",
["de"]="stelletabein",
["en"]="setuptab",
- ["fr"]="regletab",
+ ["fr"]="configurertab",
["it"]="impostatab",
["nl"]="steltabin",
["pe"]="بارگذاریتب",
@@ -4680,7 +5306,7 @@ return {
["cs"]="nastavtabulky",
["de"]="stelletabellenein",
["en"]="setuptables",
- ["fr"]="regletableaux",
+ ["fr"]="configurertables",
["it"]="impostatabelle",
["nl"]="steltabellenin",
["pe"]="بارگذاریجدولها",
@@ -4690,7 +5316,7 @@ return {
["cs"]="nastavtabelaci",
["de"]="stelletabulatorein",
["en"]="setuptabulate",
- ["fr"]="regletabulation",
+ ["fr"]="configurertabulation",
["it"]="impostatabulato",
["nl"]="steltabulatiein",
["pe"]="بارگذاریجدولبندی",
@@ -4700,7 +5326,7 @@ return {
["cs"]="nastavtext",
["de"]="stelletextein",
["en"]="setuptext",
- ["fr"]="regletexte",
+ ["fr"]="configurertexte",
["it"]="impostatesto",
["nl"]="steltekstin",
["pe"]="بارگذاریمتن",
@@ -4708,13 +5334,18 @@ return {
},
["setuptextbackground"]={
["en"]="setuptextbackground",
+ ["fr"]="configurertextearriereplan",
["nl"]="steltekstachtergrondin",
},
+ ["setuptextnote"]={
+ ["en"]="setuptextnote",
+ ["fr"]="configurernotetexte",
+ },
["setuptextposition"]={
["cs"]="setuptextposition",
["de"]="setuptextposition",
["en"]="setuptextposition",
- ["fr"]="reglepositiontexte",
+ ["fr"]="configurerpositiontexte",
["it"]="impostaposizionetesto",
["nl"]="steltekstpositiein",
["pe"]="بارگذاریمکانمتن",
@@ -4724,7 +5355,7 @@ return {
["cs"]="nastavtextovelinky",
["de"]="stelletextumrissein",
["en"]="setuptextrules",
- ["fr"]="reglelignesreglestexte",
+ ["fr"]="configurertextetraits",
["it"]="impostalineetesto",
["nl"]="steltekstlijnenin",
["pe"]="بارگذاریخطهایمتن",
@@ -4734,7 +5365,7 @@ return {
["cs"]="nastavtexttexty",
["de"]="stelletexttexteein",
["en"]="setuptexttexts",
- ["fr"]="regletextestexte",
+ ["fr"]="configurertextestexte",
["it"]="impostatestotesti",
["nl"]="stelteksttekstenin",
["pe"]="بارگذاریمتنمتنها",
@@ -4744,7 +5375,7 @@ return {
["cs"]="setuptextvariable",
["de"]="setuptextvariable",
["en"]="setuptextvariable",
- ["fr"]="reglevariabletexte",
+ ["fr"]="configurervariabletexte",
["it"]="impostavariabiletesto",
["nl"]="steltekstvariabelein",
["pe"]="بارگذاریمتغیرمتن",
@@ -4754,7 +5385,7 @@ return {
["cs"]="nastavtenkelinky",
["de"]="stelleduennerumrissein",
["en"]="setupthinrules",
- ["fr"]="regletraitsfins",
+ ["fr"]="configurertraitsfins",
["it"]="impostalineesottili",
["nl"]="steldunnelijnenin",
["pe"]="بارگذاریخطهاینازک",
@@ -4764,7 +5395,7 @@ return {
["cs"]="nastavtoleranci",
["de"]="stelletoleranzein",
["en"]="setuptolerance",
- ["fr"]="regletolerance",
+ ["fr"]="configurertolerance",
["it"]="impostatolleranza",
["nl"]="steltolerantiein",
["pe"]="بارگذاریبردباری",
@@ -4774,7 +5405,7 @@ return {
["cs"]="nastavhorejsek",
["de"]="stellenobenein",
["en"]="setuptop",
- ["fr"]="reglesup",
+ ["fr"]="configurerhaut",
["it"]="impostacima",
["nl"]="stelbovenin",
["pe"]="بارگذاریبالا",
@@ -4784,7 +5415,7 @@ return {
["cs"]="nastavhornitexty",
["de"]="stelletextobenein",
["en"]="setuptoptexts",
- ["fr"]="regletextessup",
+ ["fr"]="configurertexteshaut",
["it"]="impostatesticima",
["nl"]="stelboventekstenin",
["pe"]="بارگذاریمتنهایبالا",
@@ -4794,7 +5425,7 @@ return {
["cs"]="nastavtype",
["de"]="stelletipein",
["en"]="setuptype",
- ["fr"]="regletype",
+ ["fr"]="configurertranscrire",
["it"]="impostatype",
["nl"]="steltypein",
["pe"]="بارگذاریتایپ",
@@ -4804,7 +5435,7 @@ return {
["cs"]="nastavopis",
["de"]="stelletippenein",
["en"]="setuptyping",
- ["fr"]="regledactylo",
+ ["fr"]="configurertranscription",
["it"]="impostatyping",
["nl"]="steltypenin",
["pe"]="بارگذاریتایپکردن",
@@ -4814,7 +5445,7 @@ return {
["cs"]="nastavpodtrzeni",
["de"]="stelleunterstreichenein",
["en"]="setupunderbar",
- ["fr"]="reglesouslignage",
+ ["fr"]="configurersouligner",
["it"]="impostasottolinea",
["nl"]="stelonderstrepenin",
["pe"]="بارگذاریمیلهزیر",
@@ -4824,7 +5455,7 @@ return {
["cs"]="nastavurl",
["de"]="stelleurlein",
["en"]="setupurl",
- ["fr"]="regleurl",
+ ["fr"]="configurerurl",
["it"]="impostaurl",
["nl"]="stelurlin",
["pe"]="setupurl",
@@ -4834,7 +5465,7 @@ return {
["cs"]="nastavverze",
["de"]="stelleversionein",
["en"]="setupversions",
- ["fr"]="regleversions",
+ ["fr"]="configurerversions",
["it"]="impostaversioni",
["nl"]="stelversiesin",
["pe"]="بارگذارینسخهها",
@@ -4844,17 +5475,21 @@ return {
["cs"]="nastavbilamista",
["de"]="stellezwischenraumein",
["en"]="setupwhitespace",
- ["fr"]="regleespaceblanc",
+ ["fr"]="configurerespaceblanc",
["it"]="impostaspaziobianco",
["nl"]="stelwitruimtein",
["pe"]="بارگذاریفضایسفید",
["ro"]="seteazaspatiualb",
},
+ ["setvisualizerfont"]={
+ ["en"]="setvisualizerfont",
+ ["fr"]="reglervisualisateurpolice",
+ },
["showbodyfont"]={
["cs"]="ukazzakladnifont",
["de"]="zeigefliesstext",
["en"]="showbodyfont",
- ["fr"]="montrepolicecorps",
+ ["fr"]="montrerpolicedecorps",
["it"]="mostrafontdeltesto",
["nl"]="toonkorps",
["pe"]="نمایشقلمبدنه",
@@ -4864,7 +5499,7 @@ return {
["cs"]="ukazpostredizakladnihofontu",
["de"]="zeigefliesstextumgebung",
["en"]="showbodyfontenvironment",
- ["fr"]="montreenvironnementpolicecorps",
+ ["fr"]="montrerenvironnementpolicedecorps",
["it"]="mostraambientefontdeltesto",
["nl"]="toonkorpsomgeving",
["pe"]="نمایشمحیطقلمبدنه",
@@ -4874,7 +5509,7 @@ return {
["cs"]="ukazbarvu",
["de"]="zeigefarbe",
["en"]="showcolor",
- ["fr"]="montrecouleur",
+ ["fr"]="montrercouleur",
["it"]="mostracolore",
["nl"]="toonkleur",
["pe"]="نمایشرنگ",
@@ -4884,17 +5519,21 @@ return {
["cs"]="ukazskupinubarev",
["de"]="zeigefarbengruppe",
["en"]="showcolorgroup",
- ["fr"]="montregroupecouleur",
+ ["fr"]="montrergroupecouleur",
["it"]="mostragruppocolori",
["nl"]="toonkleurgroep",
["pe"]="نمایشگروهرنگ",
["ro"]="afiseazagrupculoare",
},
+ ["showcounter"]={
+ ["en"]="showcounter",
+ ["fr"]="montrercompteur",
+ },
["showexternalfigures"]={
["cs"]="ukazexterniobrazy",
["de"]="zeigeexterneabbildungen",
["en"]="showexternalfigures",
- ["fr"]="montrefiguresexternes",
+ ["fr"]="montrerfiguresexternes",
["it"]="mostrafiguresterne",
["nl"]="toonexternefiguren",
["pe"]="نمایششکلهایخارجی",
@@ -4904,17 +5543,49 @@ return {
["cs"]="ukazpole",
["de"]="zeigefelder",
["en"]="showfields",
- ["fr"]="montrechamps",
+ ["fr"]="montrerchamps",
["it"]="mostracampi",
["nl"]="toonvelden",
["pe"]="نمایشمیدانها",
["ro"]="afiseazacampuri",
},
+ ["showfont"]={
+ ["en"]="showfont",
+ ["fr"]="montrerpolice",
+ },
+ ["showfontdata"]={
+ ["en"]="showfontdata",
+ ["fr"]="montrerdonneespolice",
+ },
+ ["showfontexpansion"]={
+ ["en"]="showfontexpansion",
+ ["fr"]="montrerexpansionpolice",
+ },
+ ["showfontitalics"]={
+ ["en"]="showfontitalics",
+ ["fr"]="montreritaliquespolice",
+ },
+ ["showfontkerns"]={
+ ["en"]="showfontkerns",
+ ["fr"]="montrerlesapproches",
+ },
+ ["showfontparameters"]={
+ ["en"]="showfontparameters",
+ ["fr"]="montrerparametrespolice",
+ },
+ ["showfontstrip"]={
+ ["en"]="showfontstrip",
+ ["fr"]="montrervisuellementpolice",
+ },
+ ["showfontstyle"]={
+ ["en"]="showfontstyle",
+ ["fr"]="montrerstylepolice",
+ },
["showframe"]={
["cs"]="ukazramecek",
["de"]="zeigerahmen",
["en"]="showframe",
- ["fr"]="montrecadre",
+ ["fr"]="montrermiseenpage",
["it"]="mostracornice",
["nl"]="toonkader",
["pe"]="نمایشقالب",
@@ -4924,17 +5595,25 @@ return {
["cs"]="ukazmrizku",
["de"]="zeigegitter",
["en"]="showgrid",
- ["fr"]="montregrille",
+ ["fr"]="montrergrille",
["it"]="mostragriglia",
["nl"]="toongrid",
["pe"]="نمایشتوری",
["ro"]="afiseazagrid",
},
+ ["showhyphenationtrace"]={
+ ["en"]="showhyphenationtrace",
+ ["fr"]="montrertracecesure",
+ },
+ ["showkerning"]={
+ ["en"]="showkerning",
+ ["fr"]="montrerapproche",
+ },
["showlayout"]={
["cs"]="ukazvzhled",
["de"]="zeigelayout",
["en"]="showlayout",
- ["fr"]="montredisposition",
+ ["fr"]="montrermiseenpage",
["it"]="mostralyout",
["nl"]="toonlayout",
["pe"]="نمایشطرحبندی",
@@ -4944,17 +5623,21 @@ return {
["cs"]="ukazupravu",
["de"]="zeigeumbruch",
["en"]="showmakeup",
- ["fr"]="montremakeup",
+ ["fr"]="montrercomposition",
["it"]="mostramakeup",
["nl"]="toonopmaak",
["pe"]="نمایشآرایش",
["ro"]="afiseazamakeup",
},
+ ["showminimalbaseline"]={
+ ["en"]="showminimalbaseline",
+ ["fr"]="montrerlignedebase",
+ },
["showpalet"]={
["cs"]="ukazpaletu",
["de"]="zeigepalette",
["en"]="showpalet",
- ["fr"]="montrepalette",
+ ["fr"]="montrerpalette",
["it"]="mostratavolozza",
["nl"]="toonpalet",
["pe"]="نمایشلوح",
@@ -4964,7 +5647,7 @@ return {
["cs"]="ukazvytisk",
["de"]="zeigedruck",
["en"]="showprint",
- ["fr"]="montreedition",
+ ["fr"]="montrerimpression",
["it"]="mostrastampa",
["nl"]="toonprint",
["pe"]="نمایشچاپ",
@@ -4974,7 +5657,7 @@ return {
["cs"]="ukaznastaveni",
["de"]="zeigeeinstellungen",
["en"]="showsetups",
- ["fr"]="montrereglages",
+ ["fr"]="montrerconfigurations",
["it"]="mostraimpostazioni",
["nl"]="tooninstellingen",
["pe"]="نمایشبارگذاریها",
@@ -4984,7 +5667,7 @@ return {
["cs"]="ukazpodpery",
["de"]="zeigestruts",
["en"]="showstruts",
- ["fr"]="montrestruts",
+ ["fr"]="montrerentretoises",
["it"]="mostrastruts",
["nl"]="toonstruts",
["pe"]="نمایشبستها",
@@ -4994,7 +5677,7 @@ return {
["cs"]="ukazsadusymbolu",
["de"]="showsymbolset",
["en"]="showsymbolset",
- ["fr"]="montrejeusymboles",
+ ["fr"]="montrerjeusymboles",
["it"]="mostrasetsimboli",
["nl"]="toonsymboolset",
["pe"]="نمایشمجموعهعلامت",
@@ -5004,7 +5687,7 @@ return {
["cs"]="kap",
["de"]="kap",
["en"]="cap",
- ["fr"]="cap",
+ ["fr"]="petitescap",
["it"]="cap",
["nl"]="kap",
["pe"]="cap",
@@ -5040,11 +5723,15 @@ return {
["pe"]="فضا",
["ro"]="spatiu",
},
+ ["specialitem"]={
+ ["en"]="specialitem",
+ ["fr"]="élémentspécial",
+ },
["splitfloat"]={
["cs"]="rozdelplvouciobjekt",
["de"]="teilegleitobjekt",
["en"]="splitfloat",
- ["fr"]="separeflottant",
+ ["fr"]="flottantpartage",
["it"]="spezzaoggettomobile",
["nl"]="splitsplaatsblok",
["pe"]="شکافتنشناور",
@@ -5054,21 +5741,17 @@ return {
["cs"]="startzarovnavani",
["de"]="startausrichtung",
["en"]="startalignment",
- ["fr"]="demarrealignement",
+ ["fr"]="débutalignement",
["it"]="iniziaallineamento",
["nl"]="startuitlijnen",
["pe"]="شروعتنظیم",
["ro"]="startaliniere",
},
- ["alignment"]={
- ["en"]="alignment",
- ["nl"]="uitlijnen",
- },
["startbackground"]={
["cs"]="startpozadi",
["de"]="starthintergrund",
["en"]="startbackground",
- ["fr"]="demarrearriereplan",
+ ["fr"]="débutarriereplan",
["it"]="iniziasfondo",
["nl"]="startachtergrond",
["pe"]="شروعپسزمینه",
@@ -5078,7 +5761,7 @@ return {
["cs"]="startkodovani",
["de"]="startkodierung",
["en"]="startcoding",
- ["fr"]="demarrecodage",
+ ["fr"]="débutcodage",
["it"]="iniziacodifica",
["nl"]="startcodering",
["pe"]="شروعکد",
@@ -5088,7 +5771,7 @@ return {
["cs"]="startbarva",
["de"]="startfarbe",
["en"]="startcolor",
- ["fr"]="demarrecouleur",
+ ["fr"]="débutcouleur",
["it"]="iniziacolore",
["nl"]="startkleur",
["pe"]="شروعرنگ",
@@ -5098,7 +5781,7 @@ return {
["cs"]="startcolumnmakeup",
["de"]="startcolumnmakeup",
["en"]="startcolumnmakeup",
- ["fr"]="startcolumnmakeup",
+ ["fr"]="débutcompositioncolonne",
["it"]="startcolumnmakeup",
["nl"]="startkolomopmaak",
["pe"]="شروعآرایشستون",
@@ -5108,7 +5791,7 @@ return {
["cs"]="startsloupce",
["de"]="startspalten",
["en"]="startcolumns",
- ["fr"]="demarrecolonnes",
+ ["fr"]="débutcolonnes",
["it"]="iniziacolonne",
["nl"]="startkolommen",
["pe"]="شروعستونها",
@@ -5118,7 +5801,7 @@ return {
["cs"]="startcolumnset",
["de"]="startcolumnset",
["en"]="startcolumnset",
- ["fr"]="demarrejeucolonne",
+ ["fr"]="débutjeucolonnes",
["it"]="iniziagruppocolonne",
["nl"]="startkolomgroep",
["pe"]="شروعمجموعهستون",
@@ -5128,7 +5811,7 @@ return {
["cs"]="startspojeni",
["de"]="startkombination",
["en"]="startcombination",
- ["fr"]="demarrecombinaison",
+ ["fr"]="débutcombinaison",
["it"]="iniziacombinazione",
["nl"]="startcombinatie",
["pe"]="شروعترکیب",
@@ -5138,7 +5821,7 @@ return {
["cs"]="startkomponenta",
["de"]="startkomponente",
["en"]="startcomponent",
- ["fr"]="demarrecomposant",
+ ["fr"]="débutcomposant",
["it"]="iniziacomponente",
["nl"]="startonderdeel",
["pe"]="شروعمولفه",
@@ -5148,7 +5831,7 @@ return {
["cs"]="startdokument",
["de"]="startdokument",
["en"]="startdocument",
- ["fr"]="demarredocument",
+ ["fr"]="débutdocument",
["it"]="iniziadocumento",
["nl"]="startdocument",
["pe"]="شروعنوشتار",
@@ -5158,7 +5841,7 @@ return {
["cs"]="startprostredi",
["de"]="startumgebung",
["en"]="startenvironment",
- ["fr"]="demarreenvironement",
+ ["fr"]="débutenvironnement",
["it"]="iniziaambiente",
["nl"]="startomgeving",
["pe"]="شروعمحیط",
@@ -5168,7 +5851,7 @@ return {
["cs"]="startobraz",
["de"]="startabbildung",
["en"]="startfigure",
- ["fr"]="demarrefigure",
+ ["fr"]="débutfigure",
["it"]="iniziafigura",
["nl"]="startfiguur",
["pe"]="شروعشکل",
@@ -5176,13 +5859,14 @@ return {
},
["startframed"]={
["en"]="startframed",
+ ["fr"]="débutencadre",
["nl"]="startomlijnd",
},
["startglobal"]={
["cs"]="startglobalni",
["de"]="startglobal",
["en"]="startglobal",
- ["fr"]="demarreglobal",
+ ["fr"]="débutglobal",
["it"]="iniziaglobale",
["nl"]="startglobaal",
["pe"]="شروعسراسری",
@@ -5192,7 +5876,7 @@ return {
["cs"]="startradek",
["de"]="startzeile",
["en"]="startline",
- ["fr"]="demarreligne",
+ ["fr"]="débutligneref",
["it"]="iniziariga",
["nl"]="startregel",
["pe"]="شروعخط",
@@ -5202,21 +5886,21 @@ return {
["cs"]="startkorekceradku",
["de"]="startzeilenkorrektur",
["en"]="startlinecorrection",
- ["fr"]="demarrecorrectionligne",
+ ["fr"]="débutcorrectionligne",
["it"]="iniziacorrezioneriga",
["nl"]="startregelcorrectie",
["pe"]="شروعتصحیحخط",
["ro"]="startcorectielinie",
},
- ["linecorrection"]={
- ["en"]="linecorrection",
- ["nl"]="regelcorrectie",
+ ["startlinenote"]={
+ ["en"]="startlinenote",
+ ["fr"]="débutnotedeligne",
},
["startlinenumbering"]={
["cs"]="startcislovaniradku",
["de"]="startzeilennumerierung",
["en"]="startlinenumbering",
- ["fr"]="demarrenumerotationligne",
+ ["fr"]="débutnumérotationligne",
["it"]="inizianumerazionerighe",
["nl"]="startregelnummeren",
["pe"]="شروعشمارهگذاریخط",
@@ -5226,7 +5910,7 @@ return {
["cs"]="startradky",
["de"]="startzeilen",
["en"]="startlines",
- ["fr"]="demarrelignes",
+ ["fr"]="débutlignes",
["it"]="iniziarighe",
["nl"]="startregels",
["pe"]="شروعخطها",
@@ -5236,7 +5920,7 @@ return {
["cs"]="startlokalni",
["de"]="startlokal",
["en"]="startlocal",
- ["fr"]="demarrelocal",
+ ["fr"]="débutlocal",
["it"]="inizialocale",
["nl"]="startlokaal",
["pe"]="شروعموضعی",
@@ -5246,21 +5930,17 @@ return {
["cs"]="startlokalnipoznamkypodcarou",
["de"]="startlokalefussnoten",
["en"]="startlocalfootnotes",
- ["fr"]="demarrenotespdplocales",
+ ["fr"]="débutnotesbdplocal",
["it"]="inizianotepdplocali",
["nl"]="startlokalevoetnoten",
["pe"]="شروعپانوشتهایموضعی",
["ro"]="startnotesubsollocale",
},
- ["localfootnotes"]={
- ["en"]="localfootnotes",
- ["nl"]="lokalevoetnoten",
- },
["startmakeup"]={
["cs"]="startuprava",
["de"]="startumbruch",
["en"]="startmakeup",
- ["fr"]="demarremakeup",
+ ["fr"]="débutcomposition",
["it"]="iniziamakeup",
["nl"]="startopmaak",
["pe"]="شروعآرایش",
@@ -5270,21 +5950,17 @@ return {
["cs"]="startmarginalniblok",
["de"]="startmarginalblock",
["en"]="startmarginblock",
- ["fr"]="demarreblocmarge",
+ ["fr"]="débutblocmarge",
["it"]="iniziabloccomargine",
["nl"]="startmargeblok",
["pe"]="شروعبلوکحاشیه",
["ro"]="startblocmarginal",
},
- ["marginblock"]={
- ["en"]="marginblock",
- ["nl"]="margeblok",
- },
["startmarginrule"]={
["cs"]="startmarginalnilinka",
["de"]="startmarginallinie",
["en"]="startmarginrule",
- ["fr"]="demarremargereglee",
+ ["fr"]="débuttraitmarge",
["it"]="inizialineamargine",
["nl"]="startkantlijn",
["pe"]="شروعخطحاشیه",
@@ -5294,7 +5970,7 @@ return {
["cs"]="startzuzeni",
["de"]="startenger",
["en"]="startnarrower",
- ["fr"]="demarrecompoetroite",
+ ["fr"]="débutplusetroit",
["it"]="iniziapiustretto",
["nl"]="startsmaller",
["pe"]="شروعباریکتر",
@@ -5304,7 +5980,7 @@ return {
["cs"]="startprotejsek",
["de"]="startgegenueber",
["en"]="startopposite",
- ["fr"]="demarreopposition",
+ ["fr"]="débutopposition",
["it"]="iniziaopposto",
["nl"]="startnaast",
["pe"]="شروعمخالف",
@@ -5314,17 +5990,17 @@ return {
["cs"]="startprekryv",
["de"]="startoverlay",
["en"]="startoverlay",
- ["fr"]="demarrerevetement",
+ ["fr"]="débutsuperposition",
["it"]="iniziasovrapposizione",
["nl"]="startoverlay",
["pe"]="شروعپوشش",
["ro"]="startoverlay",
},
- ["startoverzicht"]={
+ ["startoverview"]={
["cs"]="startprehled",
["de"]="startueberblick",
["en"]="startoverview",
- ["fr"]="demarrevuedensemble",
+ ["fr"]="débutvuedensemble",
["it"]="iniziaoverview",
["nl"]="startoverzicht",
["pe"]="شروعبازبینی",
@@ -5334,7 +6010,7 @@ return {
["cs"]="startzhustene",
["de"]="startkleinerdurchschuss",
["en"]="startpacked",
- ["fr"]="demarregroupe",
+ ["fr"]="débutemballage",
["it"]="iniziaimpaccato",
["nl"]="startopelkaar",
["pe"]="شروعفشرده",
@@ -5344,7 +6020,7 @@ return {
["cs"]="startumistovani",
["de"]="startpositionieren",
["en"]="startpositioning",
- ["fr"]="demarrepositionnement",
+ ["fr"]="débutpositionnement",
["it"]="iniziaposizionamento",
["nl"]="startpositioneren",
["pe"]="شروعمکانگذاری",
@@ -5354,7 +6030,7 @@ return {
["cs"]="startprodukt",
["de"]="startprodukt",
["en"]="startproduct",
- ["fr"]="demarreproduit",
+ ["fr"]="débutproduit",
["it"]="iniziaprodotto",
["nl"]="startprodukt",
["pe"]="شروعتولید",
@@ -5364,7 +6040,7 @@ return {
["cs"]="startprofil",
["de"]="startprofil",
["en"]="startprofile",
- ["fr"]="demarreprofil",
+ ["fr"]="débutprofil",
["it"]="iniziaprofilo",
["nl"]="startprofiel",
["pe"]="شروعپروفایل",
@@ -5374,7 +6050,7 @@ return {
["cs"]="startprojekt",
["de"]="startprojekt",
["en"]="startproject",
- ["fr"]="demarreprojet",
+ ["fr"]="débutprojet",
["it"]="iniziaprogetto",
["nl"]="startprojekt",
["pe"]="شروعپروژه",
@@ -5384,7 +6060,7 @@ return {
["cs"]="startcitace",
["de"]="startzitat",
["en"]="startquotation",
- ["fr"]="demarrecitation",
+ ["fr"]="débutcitation",
["it"]="iniziacitazione",
["nl"]="startcitaat",
["pe"]="شروعنقلقول",
@@ -5394,7 +6070,7 @@ return {
["cs"]="startrastr",
["de"]="startraster",
["en"]="startraster",
- ["fr"]="demarreraster",
+ ["fr"]="débutraster",
["it"]="iniziaraster",
["nl"]="startraster",
["pe"]="startraster",
@@ -5404,7 +6080,7 @@ return {
["cs"]="startsadasymbolu",
["de"]="startsymbolset",
["en"]="startsymbolset",
- ["fr"]="demarrejeusymboles",
+ ["fr"]="débutjeusymboles",
["it"]="iniziasetsimboli",
["nl"]="startsymboolset",
["pe"]="شروعمجموعهنماد",
@@ -5414,7 +6090,7 @@ return {
["cs"]="startsynchronizace",
["de"]="startsynchronisation",
["en"]="startsynchronization",
- ["fr"]="demarresynchronisation",
+ ["fr"]="débutsynchronisation",
["it"]="iniziasincronizzazione",
["nl"]="startsynchronisatie",
["pe"]="شروعتطابق",
@@ -5424,7 +6100,7 @@ return {
["cs"]="starttabulka",
["de"]="starttabelle",
["en"]="starttable",
- ["fr"]="demarretableau",
+ ["fr"]="débuttable",
["it"]="iniziatabella",
["nl"]="starttabel",
["pe"]="شروعجدول",
@@ -5434,7 +6110,7 @@ return {
["cs"]="starttabulky",
["de"]="starttabellen",
["en"]="starttables",
- ["fr"]="demarretableaux",
+ ["fr"]="débuttables",
["it"]="iniziatabelle",
["nl"]="starttabellen",
["pe"]="شروعجدولها",
@@ -5444,7 +6120,7 @@ return {
["cs"]="starttext",
["de"]="starttext",
["en"]="starttext",
- ["fr"]="demarretexte",
+ ["fr"]="débuttexte",
["it"]="iniziatesto",
["nl"]="starttekst",
["pe"]="شروعمتن",
@@ -5452,17 +6128,14 @@ return {
},
["starttextbackground"]={
["en"]="starttextbackground",
+ ["fr"]="débuttextearriereplan",
["nl"]="starttekstachtergrond",
},
- ["textbackground"]={
- ["en"]="textbackground",
- ["nl"]="tekstachtergrond",
- },
["starttextrule"]={
["cs"]="starttextovalinka",
["de"]="starttextlinie",
["en"]="starttextrule",
- ["fr"]="demarreligneregleetexte",
+ ["fr"]="débuttextetrait",
["it"]="inizialineatesto",
["nl"]="starttekstlijn",
["pe"]="شروعخطمتن",
@@ -5472,7 +6145,7 @@ return {
["cs"]="startnezhustene",
["de"]="startgrosserdurchschuss",
["en"]="startunpacked",
- ["fr"]="demarredegroupe",
+ ["fr"]="débutdesemballage",
["it"]="iniziaunpacked",
["nl"]="startvanelkaar",
["pe"]="شروعغیرفشرده",
@@ -5482,7 +6155,7 @@ return {
["cs"]="startverze",
["de"]="startversion",
["en"]="startversion",
- ["fr"]="demarreversion",
+ ["fr"]="débutversion",
["it"]="iniziaversione",
["nl"]="startversie",
["pe"]="شروعنسخه",
@@ -5492,7 +6165,7 @@ return {
["cs"]="stopzarovnavani",
["de"]="stopausrichtung",
["en"]="stopalignment",
- ["fr"]="stoppealignement",
+ ["fr"]="finalignement",
["it"]="terminaallineamento",
["nl"]="stopuitlijnen",
["pe"]="پایانتنظیم",
@@ -5502,7 +6175,7 @@ return {
["cs"]="stoppozadi",
["de"]="stophintergrund",
["en"]="stopbackground",
- ["fr"]="stoppearriereplan",
+ ["fr"]="finarriereplan",
["it"]="terminasfondo",
["nl"]="stopachtergrond",
["pe"]="پایانپسزمینه",
@@ -5512,7 +6185,7 @@ return {
["cs"]="stopkodovani",
["de"]="stopkodierung",
["en"]="stopcoding",
- ["fr"]="stoppecodage",
+ ["fr"]="fincodage",
["it"]="terminacodifica",
["nl"]="stopcodering",
["pe"]="پایانکد",
@@ -5522,7 +6195,7 @@ return {
["cs"]="stopbarva",
["de"]="stopfarbe",
["en"]="stopcolor",
- ["fr"]="stoppecouleur",
+ ["fr"]="fincouleur",
["it"]="terminacolore",
["nl"]="stopkleur",
["pe"]="پایانرنگ",
@@ -5532,7 +6205,7 @@ return {
["cs"]="stopcolumnmakeup",
["de"]="stopcolumnmakeup",
["en"]="stopcolumnmakeup",
- ["fr"]="stopcolumnmakeup",
+ ["fr"]="fincompositioncolonne",
["it"]="stopcolumnmakeup",
["nl"]="stopkolomopmaak",
["pe"]="پایانآرایشستون",
@@ -5542,7 +6215,7 @@ return {
["cs"]="stopsloupce",
["de"]="stopspalten",
["en"]="stopcolumns",
- ["fr"]="stoppecolonnes",
+ ["fr"]="fincolonnes",
["it"]="terminacolonne",
["nl"]="stopkolommen",
["pe"]="پایانستونها",
@@ -5552,7 +6225,7 @@ return {
["cs"]="stopcolumnset",
["de"]="stopcolumnset",
["en"]="stopcolumnset",
- ["fr"]="stoppejeucolonne",
+ ["fr"]="finjeucolonnes",
["it"]="terminagruppocolonne",
["nl"]="stopkolomgroep",
["pe"]="پایانمجموعهستون",
@@ -5562,7 +6235,7 @@ return {
["cs"]="stopspojeni",
["de"]="stopkombination",
["en"]="stopcombination",
- ["fr"]="stoppecombinaison",
+ ["fr"]="fincombinaison",
["it"]="terminacombinazione",
["nl"]="stopcombinatie",
["pe"]="پایانترکیب",
@@ -5572,7 +6245,7 @@ return {
["cs"]="stopkomponenta",
["de"]="stopkomponente",
["en"]="stopcomponent",
- ["fr"]="stoppecomposant",
+ ["fr"]="fincomposant",
["it"]="terminacomponente",
["nl"]="stoponderdeel",
["pe"]="پایانمولفه",
@@ -5582,7 +6255,7 @@ return {
["cs"]="stopdokument",
["de"]="stopdokument",
["en"]="stopdocument",
- ["fr"]="stoppedocument",
+ ["fr"]="findocument",
["it"]="terminadocumento",
["nl"]="stopdocument",
["pe"]="پایاننوشتار",
@@ -5592,7 +6265,7 @@ return {
["cs"]="stopprostredi",
["de"]="stopumgebung",
["en"]="stopenvironment",
- ["fr"]="stoppeenvironement",
+ ["fr"]="finenvironnement",
["it"]="terminaambiente",
["nl"]="stopomgeving",
["pe"]="پایانمحیط",
@@ -5600,13 +6273,14 @@ return {
},
["stopframed"]={
["en"]="stopframed",
+ ["fr"]="finencadre",
["nl"]="stopomlijnd",
},
["stopglobal"]={
["cs"]="stopglobalni",
["de"]="stopglobal",
["en"]="stopglobal",
- ["fr"]="stoppeglobal",
+ ["fr"]="finglobal",
["it"]="terminaglobale",
["nl"]="stopglobaal",
["pe"]="پایانسراسری",
@@ -5616,7 +6290,7 @@ return {
["cs"]="stopradek",
["de"]="stopzeile",
["en"]="stopline",
- ["fr"]="stoppeligne",
+ ["fr"]="finligneref",
["it"]="terminariga",
["nl"]="stopregel",
["pe"]="پایانخط",
@@ -5626,17 +6300,21 @@ return {
["cs"]="stopkorekceradku",
["de"]="stopzeilenkorrektur",
["en"]="stoplinecorrection",
- ["fr"]="stoppecorrectionligne",
+ ["fr"]="fincorrectionligne",
["it"]="terminacorrezioneriga",
["nl"]="stopregelcorrectie",
["pe"]="پایانتصحیحخط",
["ro"]="stopcorectielinie",
},
+ ["stoplinenote"]={
+ ["en"]="stoplinenote",
+ ["fr"]="finnotedeligne",
+ },
["stoplinenumbering"]={
["cs"]="stopcislovaniradku",
["de"]="stopzeilennumerierung",
["en"]="stoplinenumbering",
- ["fr"]="stoppenumerotationligne",
+ ["fr"]="finnumérotationligne",
["it"]="terminanumerazionerighe",
["nl"]="stopregelnummeren",
["pe"]="پایانشمارهگذاریخط",
@@ -5646,7 +6324,7 @@ return {
["cs"]="stopradky",
["de"]="stopzeilen",
["en"]="stoplines",
- ["fr"]="stoppelignes",
+ ["fr"]="finlignes",
["it"]="terminarighe",
["nl"]="stopregels",
["pe"]="پایانخطها",
@@ -5656,7 +6334,7 @@ return {
["cs"]="stoplokalni",
["de"]="stoplokal",
["en"]="stoplocal",
- ["fr"]="stoppelocal",
+ ["fr"]="finlocal",
["it"]="terminalocale",
["nl"]="stoplokaal",
["pe"]="پایانموضعی",
@@ -5666,7 +6344,7 @@ return {
["cs"]="stoplokalnipoznamkypodcarou",
["de"]="stoplokalefussnoten",
["en"]="stoplocalfootnotes",
- ["fr"]="stoppenotespdplocales",
+ ["fr"]="finnotesbdplocal",
["it"]="terminanotepdplocali",
["nl"]="stoplokalevoetnoten",
["pe"]="پایانپانوشتهایموضعی",
@@ -5676,7 +6354,7 @@ return {
["cs"]="stopuprava",
["de"]="stopumbruch",
["en"]="stopmakeup",
- ["fr"]="stoppemakeup",
+ ["fr"]="fincomposition",
["it"]="terminamakeup",
["nl"]="stopopmaak",
["pe"]="پایانآرایش",
@@ -5686,7 +6364,7 @@ return {
["cs"]="stopmarginalniblok",
["de"]="stopmarginalblock",
["en"]="stopmarginblock",
- ["fr"]="stoppeblocmarge",
+ ["fr"]="finblocmarge",
["it"]="terminabloccomargine",
["nl"]="stopmargeblok",
["pe"]="پایانبلوکحاشیه",
@@ -5696,7 +6374,7 @@ return {
["cs"]="stopmarginalnilinka",
["de"]="stopmarginallinie",
["en"]="stopmarginrule",
- ["fr"]="stoppemargereglee",
+ ["fr"]="fintraitmarge",
["it"]="terminalineamargine",
["nl"]="stopkantlijn",
["pe"]="پایانخطحاشیه",
@@ -5706,7 +6384,7 @@ return {
["cs"]="stopzuzeni",
["de"]="stopenger",
["en"]="stopnarrower",
- ["fr"]="stopcompoetroite",
+ ["fr"]="finplusetroit",
["it"]="terminapiustretto",
["nl"]="stopsmaller",
["pe"]="پایاننازکتر",
@@ -5716,7 +6394,7 @@ return {
["cs"]="stopprotejsek",
["de"]="stopgegenueber",
["en"]="stopopposite",
- ["fr"]="stoppeopposition",
+ ["fr"]="finopposition",
["it"]="terminaopposto",
["nl"]="stopnaast",
["pe"]="پایانمخالف",
@@ -5726,17 +6404,17 @@ return {
["cs"]="stopprekryv",
["de"]="stopoverlay",
["en"]="stopoverlay",
- ["fr"]="stopperevetement",
+ ["fr"]="finsuperposition",
["it"]="terminasovrapposizione",
["nl"]="stopoverlay",
["pe"]="پایانپوشش",
["ro"]="stopoverlay",
},
- ["stopoverzicht"]={
+ ["stopoverview"]={
["cs"]="stopprehled",
["de"]="stopueberblick",
["en"]="stopoverview",
- ["fr"]="stoppevuedensemble",
+ ["fr"]="finvuedensemble",
["it"]="terminaoverview",
["nl"]="stopoverzicht",
["pe"]="پایانبازبینی",
@@ -5746,7 +6424,7 @@ return {
["cs"]="stopzhustene",
["de"]="stopkleinerdurchschuss",
["en"]="stoppacked",
- ["fr"]="stoppegroupe",
+ ["fr"]="finemballage",
["it"]="terminaimpaccato",
["nl"]="stopopelkaar",
["pe"]="پایانفشرده",
@@ -5756,7 +6434,7 @@ return {
["cs"]="stopumistovani",
["de"]="stoppositionieren",
["en"]="stoppositioning",
- ["fr"]="stoppepositionnement",
+ ["fr"]="finpositionnement",
["it"]="terminaposizionamento",
["nl"]="stoppositioneren",
["pe"]="پایانمکانگذاری",
@@ -5766,7 +6444,7 @@ return {
["cs"]="stopprodukt",
["de"]="stopprodukt",
["en"]="stopproduct",
- ["fr"]="stoppeproduit",
+ ["fr"]="finproduit",
["it"]="terminaprodotto",
["nl"]="stopprodukt",
["pe"]="پایانتولید",
@@ -5776,7 +6454,7 @@ return {
["cs"]="stopprofil",
["de"]="stopprofil",
["en"]="stopprofile",
- ["fr"]="stoppeprofil",
+ ["fr"]="finprofil",
["it"]="terminaprofili",
["nl"]="stopprofiel",
["pe"]="پایانپروفایل",
@@ -5786,7 +6464,7 @@ return {
["cs"]="stopprojekt",
["de"]="stopprojekt",
["en"]="stopproject",
- ["fr"]="stoppeprojet",
+ ["fr"]="finprojet",
["it"]="terminaprogetto",
["nl"]="stopprojekt",
["pe"]="پایانپروژه",
@@ -5796,7 +6474,7 @@ return {
["cs"]="stopcitace",
["de"]="stopzitat",
["en"]="stopquotation",
- ["fr"]="stoppecitation",
+ ["fr"]="fincitation",
["it"]="terminacitazione",
["nl"]="stopcitaat",
["pe"]="پایاننقلقول",
@@ -5806,7 +6484,7 @@ return {
["cs"]="stoprastr",
["de"]="stopraster",
["en"]="stopraster",
- ["fr"]="stopperaster",
+ ["fr"]="finraster",
["it"]="terminaraster",
["nl"]="stopraster",
["pe"]="stopraster",
@@ -5816,7 +6494,7 @@ return {
["cs"]="stopsynchronizace",
["de"]="stopsynchronisation",
["en"]="stopsynchronization",
- ["fr"]="stoppesynchronisation",
+ ["fr"]="finsynchronisation",
["it"]="terminasincronizzazione",
["nl"]="stopsynchronisatie",
["pe"]="پایانتطابق",
@@ -5826,7 +6504,7 @@ return {
["cs"]="stoptabulka",
["de"]="stoptabelle",
["en"]="stoptable",
- ["fr"]="stoppetableau",
+ ["fr"]="fintable",
["it"]="terminatabella",
["nl"]="stoptabel",
["pe"]="پایانجدول",
@@ -5836,7 +6514,7 @@ return {
["cs"]="stoptabulky",
["de"]="stoptabellen",
["en"]="stoptables",
- ["fr"]="stoppetableaux",
+ ["fr"]="fintables",
["it"]="terminatabelle",
["nl"]="stoptabellen",
["pe"]="پایانجدولها",
@@ -5846,7 +6524,7 @@ return {
["cs"]="stoptext",
["de"]="stoptext",
["en"]="stoptext",
- ["fr"]="stoppetexte",
+ ["fr"]="fintexte",
["it"]="terminatesto",
["nl"]="stoptekst",
["pe"]="پایانمتن",
@@ -5854,13 +6532,14 @@ return {
},
["stoptextbackground"]={
["en"]="stoptextbackground",
+ ["fr"]="fintextearriereplan",
["nl"]="stoptekstachtergrond",
},
["stoptextrule"]={
["cs"]="stoptextovalinka",
["de"]="stoptextlinie",
["en"]="stoptextrule",
- ["fr"]="stoppeligneregleetexte",
+ ["fr"]="fintextetrait",
["it"]="terminalineatesto",
["nl"]="stoptekstlijn",
["pe"]="پایانخطمتن",
@@ -5870,7 +6549,7 @@ return {
["cs"]="stopnezhustene",
["de"]="stopgrosserdurchschuss",
["en"]="stopunpacked",
- ["fr"]="stoppedegroupe",
+ ["fr"]="findesemballage",
["it"]="terminaunpacked",
["nl"]="stopvanelkaar",
["pe"]="پایانغیرفشرده",
@@ -5880,7 +6559,7 @@ return {
["cs"]="stopverze",
["de"]="stopversion",
["en"]="stopversion",
- ["fr"]="stoppeversion",
+ ["fr"]="finversion",
["it"]="terminaversioni",
["nl"]="stopversie",
["pe"]="پایاننسخه",
@@ -5896,6 +6575,14 @@ return {
["pe"]="کشیده",
["ro"]="intins",
},
+ ["strictinspectnextcharacter"]={
+ ["en"]="strictinspectnextcharacter",
+ ["fr"]="inspecterstrictementcaracteresuivant",
+ },
+ ["stripcharacter"]={
+ ["en"]="stripcharacter",
+ ["fr"]="demontercaractere",
+ },
["subformulanumber"]={
["cs"]="cislopodrovnice",
["de"]="unterformelnummer",
@@ -5910,17 +6597,21 @@ return {
["cs"]="subpagenumber",
["de"]="subpagenumber",
["en"]="subpagenumber",
- ["fr"]="sousnumeropage",
+ ["fr"]="numerosouspage",
["it"]="subpagenumber",
["nl"]="subpaginanummer",
["pe"]="شمارهزیرصفحه",
["ro"]="subpagenumber",
},
+ ["subtractfeature"]={
+ ["en"]="subtractfeature",
+ ["fr"]="enleverfonctionnalite",
+ },
["switchtobodyfont"]={
["cs"]="prepninazakladnifont",
["de"]="wechselezumfliesstext",
["en"]="switchtobodyfont",
- ["fr"]="changepolicecorps",
+ ["fr"]="passerapolicedecorps",
["it"]="cambiaafontdeltesto",
["nl"]="switchnaarkorps",
["pe"]="تغییربهقلمبدنه",
@@ -5930,7 +6621,7 @@ return {
["cs"]="switchtorawfont",
["de"]="switchtorawfont",
["en"]="switchtorawfont",
- ["fr"]="changepolicebrute",
+ ["fr"]="passerapolicebrute",
["it"]="passaafontgrezzo",
["nl"]="switchtorawfont",
["pe"]="تغییربهقلمخام",
@@ -5958,6 +6649,7 @@ return {
},
["symoffset"]={
["en"]="symoffset",
+ ["fr"]="decalagesym",
["nl"]="symoffset",
},
["synchronizationbar"]={
@@ -5974,7 +6666,7 @@ return {
["cs"]="synchronizovat",
["de"]="synchronisieren",
["en"]="synchronize",
- ["fr"]="synchronise",
+ ["fr"]="synchroniser",
["it"]="sincronizza",
["nl"]="synchroniseer",
["pe"]="تطابق",
@@ -5994,12 +6686,20 @@ return {
["cs"]="testcolumn",
["de"]="testcolumn",
["en"]="testcolumn",
- ["fr"]="testcolumn",
+ ["fr"]="testcolonne",
["it"]="testcolumn",
["nl"]="testkolom",
["pe"]="ستونامتحان",
["ro"]="testcolumn",
},
+ ["testfeature"]={
+ ["en"]="testfeature",
+ ["fr"]="testerfonctionnalite",
+ },
+ ["testfeatureonce"]={
+ ["en"]="testfeatureonce",
+ ["fr"]="testerfonctionnaliteunfois",
+ },
["testpage"]={
["cs"]="testpage",
["de"]="testpage",
@@ -6020,6 +6720,15 @@ return {
["pe"]="تک",
["ro"]="tex",
},
+ ["textbackground"]={
+ ["en"]="textbackground",
+ ["fr"]="textearriereplan",
+ ["nl"]="tekstachtergrond",
+ },
+ ["textcolor"]={
+ ["en"]="textcolor",
+ ["fr"]="textecouleura",
+ },
["textheight"]={
["cs"]="vyskatextu",
["de"]="texthoehe",
@@ -6030,6 +6739,10 @@ return {
["pe"]="ارتفاعمتن",
["ro"]="inaltimetext",
},
+ ["textnote"]={
+ ["en"]="textnote",
+ ["fr"]="notetexte",
+ },
["textreference"]={
["cs"]="odkaznatext",
["de"]="textreferenz",
@@ -6044,7 +6757,7 @@ return {
["cs"]="textovalinka",
["de"]="textlinie",
["en"]="textrule",
- ["fr"]="ligneregleetexte",
+ ["fr"]="traittexte",
["it"]="lineatesto",
["nl"]="tekstlijn",
["pe"]="خطمتن",
@@ -6070,6 +6783,18 @@ return {
["pe"]="عرضمتن",
["ro"]="latimetext",
},
+ ["thefirstcharacter"]={
+ ["en"]="thefirstcharacter",
+ ["fr"]="lepremiercaractere",
+ },
+ ["thenormalizedbodyfontsize"]={
+ ["en"]="thenormalizedbodyfontsize",
+ ["fr"]="lataillenormaliseepolicedecorps",
+ },
+ ["theremainingcharacters"]={
+ ["en"]="theremainingcharacters",
+ ["fr"]="lescaracteresrestants",
+ },
["thinrule"]={
["cs"]="tenkalinka",
["de"]="duennelinie",
@@ -6090,11 +6815,15 @@ return {
["pe"]="خطهاینازک",
["ro"]="liniisubtiri",
},
+ ["tolinenote"]={
+ ["en"]="tolinenote",
+ ["fr"]="alanotedeligne",
+ },
["tooltip"]={
["cs"]="bublinkovanapoveda",
["de"]="tooltip",
["en"]="tooltip",
- ["fr"]="suggestion",
+ ["fr"]="infobulle",
["it"]="tooltip",
["nl"]="suggestie",
["pe"]="tooltip",
@@ -6104,7 +6833,7 @@ return {
["cs"]="vzdalenosthorejsku",
["de"]="abstandoben",
["en"]="topdistance",
- ["fr"]="distancesup",
+ ["fr"]="distancehaut",
["it"]="distanzacima",
["nl"]="bovenafstand",
["pe"]="فاصلهبالا",
@@ -6114,7 +6843,7 @@ return {
["cs"]="vyskahorejsku",
["de"]="hoeheoben",
["en"]="topheight",
- ["fr"]="hauteursup",
+ ["fr"]="hauteurhaut",
["it"]="altezzacima",
["nl"]="bovenhoogte",
["pe"]="ارتفاعبالا",
@@ -6124,7 +6853,7 @@ return {
["cs"]="odsazenishora",
["de"]="kopfweite",
["en"]="topspace",
- ["fr"]="espacesup",
+ ["fr"]="espacehaut",
["it"]="spaziocima",
["nl"]="kopwit",
["pe"]="فضایبالا",
@@ -6164,7 +6893,7 @@ return {
["cs"]="pis",
["de"]="tip",
["en"]="typ",
- ["fr"]="typ",
+ ["fr"]="transcrireaveccesure",
["it"]="typ",
["nl"]="typ",
["pe"]="typ",
@@ -6174,7 +6903,7 @@ return {
["cs"]="opis",
["de"]="tippen",
["en"]="type",
- ["fr"]="dactylographier",
+ ["fr"]="transcrire",
["it"]="type",
["nl"]="type",
["pe"]="تایپ",
@@ -6184,27 +6913,39 @@ return {
["cs"]="typebuffer",
["de"]="tippepuffer",
["en"]="typebuffer",
- ["fr"]="tapebuffer",
+ ["fr"]="transcriretampon",
["it"]="typebuffer",
["nl"]="typebuffer",
["pe"]="تایپبافر",
["ro"]="scriebuffer",
},
+ ["typedefinedbuffer"]={
+ ["en"]="typedefinedbuffer",
+ ["fr"]="transcriretampondefini",
+ },
["typefile"]={
["cs"]="opissoubor",
["de"]="tippedatei",
["en"]="typefile",
- ["fr"]="fichierdactylo",
+ ["fr"]="transcrirefichier",
["it"]="typefile",
["nl"]="typefile",
["pe"]="تایپپرونده",
["ro"]="typefile",
},
+ ["typeinlinebuffer"]={
+ ["en"]="typeinlinebuffer",
+ ["fr"]="transcriretamponenligne",
+ },
+ ["typing"]={
+ ["en"]="typing",
+ ["fr"]="transcription",
+ },
["unitmeaning"]={
["cs"]="vyznam",
["de"]="bedeutung",
["en"]="unitmeaning",
- ["fr"]="sensunite",
+ ["fr"]="significationunite",
["it"]="nomeunita",
["nl"]="betekenis",
["pe"]="معنیواحد",
@@ -6220,11 +6961,15 @@ return {
["pe"]="ناشناس",
["ro"]="necunoscut",
},
+ ["unregisterhyphenationpattern"]={
+ ["en"]="unregisterhyphenationpattern",
+ ["fr"]="desenregistrermotifcesure",
+ },
["useJSscripts"]={
["cs"]="uzijJSscripts",
["de"]="verwendeJSscript",
["en"]="useJSscripts",
- ["fr"]="utiliseJSscripts",
+ ["fr"]="utiliserJSscript",
["it"]="usaJSscripts",
["nl"]="gebruikJSscripts",
["pe"]="useJSscripts",
@@ -6234,7 +6979,7 @@ return {
["cs"]="uzijURL",
["de"]="verwendeURL",
["en"]="useURL",
- ["fr"]="utiliseURL",
+ ["fr"]="utiliserURL",
["it"]="usaURL",
["nl"]="gebruikURL",
["pe"]="useURL",
@@ -6244,7 +6989,7 @@ return {
["cs"]="useXMLfilter",
["de"]="useXMLfilter",
["en"]="useXMLfilter",
- ["fr"]="useXMLfilter",
+ ["fr"]="utiliserfiltreXML",
["it"]="useXMLfilter",
["nl"]="gebruikXMLfilter",
["pe"]="useXMLfilter",
@@ -6254,17 +6999,25 @@ return {
["cs"]="uzijbloky",
["de"]="verwendebloecke",
["en"]="useblocks",
- ["fr"]="utiliseblocs",
+ ["fr"]="utiliserblocs",
["it"]="usablocco",
["nl"]="gebruikblokken",
["pe"]="استفادهبلوکها",
["ro"]="folosestebloc",
},
+ ["usebodyfont"]={
+ ["en"]="usebodyfont",
+ ["fr"]="utiliserpolicedecorps",
+ },
+ ["usebodyfontparameter"]={
+ ["en"]="usebodyfontparameter",
+ ["fr"]="utiliserparametrepolicedecorps",
+ },
["usecommands"]={
["cs"]="uzijprikazy",
["de"]="verwendebefehl",
["en"]="usecommands",
- ["fr"]="utilisecommandes",
+ ["fr"]="utilisercommandes",
["it"]="usacomandi",
["nl"]="gebruikcommandos",
["pe"]="استفادهفرمانها",
@@ -6274,7 +7027,7 @@ return {
["cs"]="uzijkodovani",
["de"]="benutzekodierung",
["en"]="useencoding",
- ["fr"]="utiliseencodage",
+ ["fr"]="utilisercodage",
["it"]="usacodifica",
["nl"]="usecodering",
["pe"]="استفادهرمزینه",
@@ -6284,7 +7037,7 @@ return {
["cs"]="uzijexternidokument",
["de"]="verwendeexteresdokument",
["en"]="useexternaldocument",
- ["fr"]="utilisedocumentexterne",
+ ["fr"]="utiliserdocumentexterne",
["it"]="usadocumentoesterno",
["nl"]="gebruikexterndocument",
["pe"]="استفادهنوشتارخارجی",
@@ -6294,7 +7047,7 @@ return {
["cs"]="uzijexterniobraz",
["de"]="verwendeexterneabbildung",
["en"]="useexternalfigure",
- ["fr"]="utilisefigureexterne",
+ ["fr"]="utiliserfigureexterne",
["it"]="usafiguraesterna",
["nl"]="gebruikexternfiguur",
["pe"]="استفادهشکلخارجی",
@@ -6304,7 +7057,7 @@ return {
["cs"]="uzijexternisoubor",
["de"]="verwendeexternedatei",
["en"]="useexternalfile",
- ["fr"]="utilisefichierexterne",
+ ["fr"]="utiliserfichierexterne",
["it"]="usafileesterno",
["nl"]="gebruikexternefile",
["pe"]="استفادهپروندهخارجی",
@@ -6314,7 +7067,7 @@ return {
["cs"]="uzijexternisoubory",
["de"]="verwendeexternedateien",
["en"]="useexternalfiles",
- ["fr"]="utilisefichiersexternes",
+ ["fr"]="utiliserfichiersexternes",
["it"]="usafileesterni",
["nl"]="gebruikexternefiles",
["pe"]="استفادهپروندههایخارجی",
@@ -6324,7 +7077,7 @@ return {
["cs"]="uzijexternizvuk",
["de"]="verwendeexternestonstueck",
["en"]="useexternalsoundtrack",
- ["fr"]="utilisepsiteaudioexterne",
+ ["fr"]="utilisersonexterne",
["it"]="usacolonnasonoraesterna",
["nl"]="gebruikexterngeluidsfragment",
["pe"]="استفادهقطعهموزیکخارجی",
@@ -6334,7 +7087,7 @@ return {
["cs"]="uzijmodul",
["de"]="verwendemodul",
["en"]="usemodule",
- ["fr"]="utilisemodule",
+ ["fr"]="utilisermodule",
["it"]="usamodulo",
["nl"]="gebruikmodule",
["pe"]="استفادهمدول",
@@ -6344,7 +7097,7 @@ return {
["cs"]="uzijmoduly",
["de"]="verwendemodule",
["en"]="usemodules",
- ["fr"]="utilisemodules",
+ ["fr"]="utilisermodules",
["it"]="usamoduli",
["nl"]="gebruikmodules",
["pe"]="استفادهمدولها",
@@ -6354,7 +7107,7 @@ return {
["cs"]="uzijadresar",
["de"]="benutzeverzeichnis",
["en"]="usedirectory",
- ["fr"]="utilisechemin",
+ ["fr"]="utiliserchemin",
["it"]="usacartella",
["nl"]="gebruikpad",
["pe"]="استفادهمسیر",
@@ -6364,7 +7117,7 @@ return {
["cs"]="uzijodkazy",
["de"]="verwendereferenzen",
["en"]="usereferences",
- ["fr"]="utilisereferences",
+ ["fr"]="utiliserreferences",
["it"]="usariferimenti",
["nl"]="gebruikreferenties",
["pe"]="استفادهمرجعها",
@@ -6374,7 +7127,7 @@ return {
["cs"]="uzijspeciality",
["de"]="benutzespezielles",
["en"]="usespecials",
- ["fr"]="utilisespecialites",
+ ["fr"]="utiliserspeciaux",
["it"]="usaspecialita",
["nl"]="gebruikspecials",
["pe"]="استفادهویژگیها",
@@ -6384,7 +7137,7 @@ return {
["cs"]="uzijsymbol",
["de"]="verwendesymbole",
["en"]="usesymbols",
- ["fr"]="utilisesymboles",
+ ["fr"]="utilisersymboles",
["it"]="usasimboli",
["nl"]="gebruiksymbolen",
["pe"]="استفادهنمادها",
@@ -6394,7 +7147,7 @@ return {
["cs"]="usetypescript",
["de"]="usetypescript",
["en"]="usetypescript",
- ["fr"]="usetypescript",
+ ["fr"]="utiliserscriptdepolices",
["it"]="usetypescript",
["nl"]="gebruiktypescript",
["pe"]="استفادهدستخطتایپ",
@@ -6404,6 +7157,7 @@ return {
["cs"]="usetypescriptfile",
["de"]="usetypescriptfile",
["en"]="usetypescriptfile",
+ ["fr"]="utiliserfichierscriptdepolices",
["it"]="usetypescriptfile",
["nl"]="gebruiktypescriptfile",
["pe"]="استفادهپروندهدستخطتایپ",
@@ -6413,12 +7167,16 @@ return {
["cs"]="uzijurl",
["de"]="verwendeurl",
["en"]="useurl",
- ["fr"]="utiliseurl",
+ ["fr"]="utiliserurl",
["it"]="usaurl",
["nl"]="gebruikurl",
["pe"]="useurl",
["ro"]="folosesteurl",
},
+ ["verbatim"]={
+ ["en"]="verbatim",
+ ["fr"]="verbatim",
+ },
["version"]={
["cs"]="verze",
["de"]="version",
@@ -6433,7 +7191,7 @@ return {
["cs"]="vl",
["de"]="vl",
["en"]="vl",
- ["fr"]="vl",
+ ["fr"]="lv",
["it"]="vl",
["nl"]="vl",
["pe"]="خع",
@@ -6459,11 +7217,15 @@ return {
["pe"]="فضایسفید",
["ro"]="spatiualb",
},
+ ["widthspanningtext"]={
+ ["en"]="widthspanningtext",
+ ["fr"]="largeurtextecouvrant",
+ },
["wordright"]={
["cs"]="slovovpravo",
["de"]="wortrechts",
["en"]="wordright",
- ["fr"]="motdroit",
+ ["fr"]="ecrireadroite",
["it"]="paroladestra",
["nl"]="woordrechts",
["pe"]="کلمهراست",
@@ -6473,7 +7235,7 @@ return {
["cs"]="zapismeziseznam",
["de"]="schreibezwischenliste",
["en"]="writebetweenlist",
- ["fr"]="ecritentreliste",
+ ["fr"]="ecrireentreliste",
["it"]="scrividentroelenco",
["nl"]="schrijftussenlijst",
["pe"]="بنویسبینلیست",
@@ -6483,7 +7245,7 @@ return {
["cs"]="zapisdoseznamu",
["de"]="schreibezurliste",
["en"]="writetolist",
- ["fr"]="ecritdansliste",
+ ["fr"]="ecriredansliste",
["it"]="scriviinelenco",
["nl"]="schrijfnaarlijst",
["pe"]="بنویسدرلیست",
@@ -6493,7 +7255,7 @@ return {
["cs"]="zapisdoseznamuodkazu",
["de"]="schreibezurreferenzliste",
["en"]="writetoreferencelist",
- ["fr"]="ecritdanslistereference",
+ ["fr"]="ecriredanslistereference",
["it"]="scriviinlistariferimenti",
["nl"]="schrijfnaarreferentielijst",
["pe"]="بنویسدرلیستمرجع",
@@ -6503,7 +7265,7 @@ return {
["cs"]="zapisdorejstriku",
["de"]="schreibezumregister",
["en"]="writetoregister",
- ["fr"]="ecritregistre",
+ ["fr"]="ecriredansregistre",
["it"]="scriviinregistro",
["nl"]="schrijfnaarregister",
["pe"]="بنویسدرثبت",
@@ -6511,10 +7273,6 @@ return {
},
},
["constants"]={
- ["fractions"]={
- ["en"]="fractions",
- ["nl"]="breuken",
- },
["action"]={
["cs"]="akce",
["de"]="aktion",
@@ -6539,7 +7297,7 @@ return {
["cs"]="po",
["de"]="nach",
["en"]="after",
- ["fr"]="apres",
+ ["fr"]="après",
["it"]="dopo",
["nl"]="na",
["pe"]="بعداز",
@@ -6549,7 +7307,7 @@ return {
["cs"]="pohlavicce",
["de"]="nachkopf",
["en"]="afterhead",
- ["fr"]="aprestete",
+ ["fr"]="aprèstête",
["it"]="dopotesta",
["nl"]="kopna",
["pe"]="بعدازسر",
@@ -6559,7 +7317,7 @@ return {
["cs"]="klavesapo",
["de"]="nachtaste",
["en"]="afterkey",
- ["fr"]="aprescle",
+ ["fr"]="aprèsclé",
["it"]="dopotasto",
["nl"]="natoets",
["pe"]="بعدازکلید",
@@ -6567,58 +7325,68 @@ return {
},
["aftersection"]={
["en"]="aftersection",
+ ["fr"]="aprèssection",
["nl"]="nasectie",
},
["align"]={
["cs"]="zarovnani",
["de"]="ausrichtung",
["en"]="align",
- ["fr"]="alignement",
+ ["fr"]="aligner",
["it"]="allinea",
["nl"]="uitlijnen",
["pe"]="تنظیم",
["ro"]="aliniere",
},
+ ["alignbottom"]={
+ ["en"]="alignbottom",
+ ["fr"]="alignerbas",
+ },
["aligncharacter"]={
["cs"]="aligncharacter",
["de"]="aligncharacter",
["en"]="aligncharacter",
- ["fr"]="caracterealigne",
+ ["fr"]="alignersurcaractere",
["it"]="allineacarattere",
["nl"]="karakteruitlijnen",
["pe"]="حرفتنظیم",
["ro"]="aliniazacaracter",
},
- ["alignmentleftwidth"]={
- ["en"]="alignmentleftwidth",
- },
- ["alignmentrightwidth"]={
- ["en"]="alignmentrightwidth",
- },
- ["alignmentleftsample"]={
- ["en"]="alignmentleftsample",
- },
- ["alignmentrightsample"]={
- ["en"]="alignmentrightsample",
- },
["alignmentcharacter"]={
["cs"]="alignmentcharacter",
["de"]="alignmentcharacter",
["en"]="alignmentcharacter",
- ["fr"]="alignementcaractere",
+ ["fr"]="caracterealignement",
["it"]="carattereallineamento",
["nl"]="uitlijnkarakter",
["pe"]="حرفتنظیمکردن",
["ro"]="alierecaracter",
},
+ ["alignmentleftsample"]={
+ ["en"]="alignmentleftsample",
+ ["fr"]="echantillongauchealignement",
+ },
+ ["alignmentleftwidth"]={
+ ["en"]="alignmentleftwidth",
+ ["fr"]="largeurgauchealignement",
+ },
+ ["alignmentrightsample"]={
+ ["en"]="alignmentrightsample",
+ ["fr"]="echantillondroitealignement",
+ },
+ ["alignmentrightwidth"]={
+ ["en"]="alignmentrightwidth",
+ ["fr"]="largeurdroitealignement",
+ },
["alignsymbol"]={
["en"]="alignsymbol",
+ ["fr"]="alignersursymbol",
},
["aligntitle"]={
["cs"]="zarovnejtitul",
["de"]="titelausrichten",
["en"]="aligntitle",
- ["fr"]="alignementtitre",
+ ["fr"]="alignersurtitre",
["it"]="allineatitolo",
["nl"]="titeluitlijnen",
["pe"]="عنوانتنظیم",
@@ -6628,22 +7396,25 @@ return {
["cs"]="alternativa",
["de"]="alternative",
["en"]="alternative",
- ["fr"]="alternative",
+ ["fr"]="variante",
["it"]="alternativa",
["nl"]="variant",
["pe"]="جایگزین",
["ro"]="alternativ",
},
- ["stylealternative"]={
- ["en"]="stylealternative",
- ["nl"]="stylevariant",
- },
["anchor"]={
["en"]="anchor",
+ ["fr"]="ancre",
["nl"]="anker",
},
+ ["anchoring"]={
+ ["en"]="anchoring",
+ ["fr"]="ancrage",
+ ["nl"]="verankering",
+ },
["andtext"]={
["en"]="andtext",
+ ["fr"]="ettexte",
},
["apa"]={
["cs"]="apa",
@@ -6657,6 +7428,7 @@ return {
},
["arguments"]={
["en"]="arguments",
+ ["fr"]="arguments",
["nl"]="argumenten",
},
["arrow"]={
@@ -6671,24 +7443,29 @@ return {
},
["artauthor"]={
["en"]="artauthor",
+ ["fr"]="artauteur",
},
["artauthoretaldisplay"]={
["en"]="artauthoretaldisplay",
+ ["fr"]="artauteuretalaffichage",
},
["artauthoretallimit"]={
["en"]="artauthoretallimit",
+ ["fr"]="artauteuretallimite",
},
["artauthoretaltext"]={
["en"]="artauthoretaltext",
+ ["fr"]="artauteuretaltexte",
},
["artoffset"]={
["en"]="artoffset",
+ ["fr"]="artdecalage",
},
["at"]={
["cs"]="u",
["de"]="bei",
["en"]="at",
- ["fr"]="a",
+ ["fr"]="en",
["it"]="ad",
["nl"]="op",
["pe"]="در",
@@ -6706,15 +7483,19 @@ return {
},
["authorconversion"]={
["en"]="authorconversion",
+ ["fr"]="auteurconversion",
},
["authoretaldisplay"]={
["en"]="authoretaldisplay",
+ ["fr"]="auteuretalaffichage",
},
["authoretallimit"]={
["en"]="authoretallimit",
+ ["fr"]="auteuretallimite",
},
["authoretaltext"]={
["en"]="authoretaltext",
+ ["fr"]="auteuretaltexte",
},
["auto"]={
["cs"]="auto",
@@ -6728,13 +7509,14 @@ return {
},
["autocase"]={
["en"]="autocase",
+ ["fr"]="autocase",
["nl"]="autocase",
},
["autofile"]={
["cs"]="autofile",
["de"]="autofile",
["en"]="autofile",
- ["fr"]="autofile",
+ ["fr"]="autofichier",
["it"]="autofile",
["nl"]="autofile",
["pe"]="پروندهخودکار",
@@ -6754,7 +7536,7 @@ return {
["cs"]="autohang",
["de"]="autohang",
["en"]="autohang",
- ["fr"]="autohang",
+ ["fr"]="autosuspendre",
["it"]="autohang",
["nl"]="autohang",
["pe"]="آویزانخودکار",
@@ -6764,7 +7546,7 @@ return {
["cs"]="autostrut",
["de"]="autostrut",
["en"]="autostrut",
- ["fr"]="autostrut",
+ ["fr"]="autoentretoise",
["it"]="autostrut",
["nl"]="autostrut",
["pe"]="بستخودکار",
@@ -6782,10 +7564,12 @@ return {
},
["availableheight"]={
["en"]="availableheight",
+ ["fr"]="hauteurdisponible",
["nl"]="beschikbarehoogte",
},
["availablewidth"]={
["en"]="availablewidth",
+ ["fr"]="largeurdisponible",
["nl"]="beschikbarebreedte",
},
["axis"]={
@@ -6870,13 +7654,14 @@ return {
},
["backreference"]={
["en"]="backreference",
+ ["fr"]="retroreference",
["nl"]="terugreferentie",
},
["backspace"]={
["cs"]="zpetnamezera",
["de"]="rumpfspatium",
["en"]="backspace",
- ["fr"]="retour",
+ ["fr"]="espacearrière",
["it"]="backspace",
["nl"]="rugwit",
["pe"]="فضایپس",
@@ -6886,7 +7671,7 @@ return {
["cs"]="rovnovaha",
["de"]="ausgleichen",
["en"]="balance",
- ["fr"]="equilibre",
+ ["fr"]="equilibrer",
["it"]="bilanciamento",
["nl"]="balanceren",
["pe"]="تعادل",
@@ -6914,13 +7699,14 @@ return {
},
["beforesection"]={
["en"]="beforesection",
+ ["fr"]="avantsection",
["nl"]="voorsectie",
},
["bet"]={
["cs"]="bet",
["de"]="bet",
["en"]="bet",
- ["fr"]="bet",
+ ["fr"]="suj",
["it"]="bet",
["nl"]="bet",
["pe"]="bet",
@@ -6928,12 +7714,13 @@ return {
},
["bidi"]={
["en"]="bidi",
+ ["fr"]="bidi",
},
["big"]={
["cs"]="velky",
["de"]="gross",
["en"]="big",
- ["fr"]="grand",
+ ["fr"]="important",
["it"]="grande",
["nl"]="groot",
["pe"]="بزرگ",
@@ -6943,7 +7730,7 @@ return {
["cs"]="prazdny",
["de"]="blanko",
["en"]="blank",
- ["fr"]="vide",
+ ["fr"]="vierge",
["it"]="rigovuoto",
["nl"]="blanko",
["pe"]="خالی",
@@ -6951,12 +7738,13 @@ return {
},
["bleedoffset"]={
["en"]="bleedoffset",
+ ["fr"]="decalagefuite",
},
["blockway"]={
["cs"]="dobloku",
["de"]="blockauf",
["en"]="blockway",
- ["fr"]="blockway",
+ ["fr"]="faconbloc",
["it"]="blockway",
["nl"]="blokwijze",
["pe"]="راهبلوک",
@@ -6966,7 +7754,7 @@ return {
["cs"]="zakladnifont",
["de"]="fliesstext",
["en"]="bodyfont",
- ["fr"]="policecorps",
+ ["fr"]="policedecorps",
["it"]="fonttesto",
["nl"]="korps",
["pe"]="قلمبدنه",
@@ -6974,24 +7762,31 @@ return {
},
["boffset"]={
["en"]="boffset",
+ ["fr"]="decalageb",
},
["boldfeatures"]={
["en"]="boldfeatures",
+ ["fr"]="fonctionnalitesgras",
},
["boldfont"]={
["en"]="boldfont",
+ ["fr"]="policegras",
},
["bolditalicfeatures"]={
["en"]="bolditalicfeatures",
+ ["fr"]="fonctionnalitesgrasitalique",
},
["bolditalicfont"]={
["en"]="bolditalicfont",
+ ["fr"]="policegrasitalique",
},
["boldslantedfeatures"]={
["en"]="boldslantedfeatures",
+ ["fr"]="fonctionnalitesgrasincline",
},
["boldslantedfont"]={
["en"]="boldslantedfont",
+ ["fr"]="policegrasincline",
},
["bookmark"]={
["cs"]="zalozka",
@@ -7007,7 +7802,7 @@ return {
["cs"]="spodek",
["de"]="unten",
["en"]="bottom",
- ["fr"]="inf",
+ ["fr"]="bas",
["it"]="fondo",
["nl"]="onder",
["pe"]="پایین",
@@ -7015,19 +7810,22 @@ return {
},
["bottomafter"]={
["en"]="bottomafter",
+ ["fr"]="basaprès",
},
["bottombefore"]={
["en"]="bottombefore",
+ ["fr"]="basavant",
},
["bottomcommand"]={
["en"]="bottomcommand",
+ ["fr"]="commandebas",
["nl"]="ondercommando",
},
["bottomdistance"]={
["cs"]="vzdalenostspodku",
["de"]="abstandunten",
["en"]="bottomdistance",
- ["fr"]="distanceinf",
+ ["fr"]="distancebas",
["it"]="distanzafondo",
["nl"]="onderafstand",
["pe"]="فاصلهپایین",
@@ -7037,7 +7835,7 @@ return {
["cs"]="ramecekdole",
["de"]="untenrahmen",
["en"]="bottomframe",
- ["fr"]="cadreinf",
+ ["fr"]="cadrebas",
["it"]="cornicefondo",
["nl"]="onderkader",
["pe"]="قالبپایین",
@@ -7047,7 +7845,7 @@ return {
["cs"]="offsetspodku",
["de"]="untenoffset",
["en"]="bottomoffset",
- ["fr"]="decalageinf",
+ ["fr"]="decalagebas",
["it"]="offsetfondo",
["nl"]="onderoffset",
["pe"]="آفستپایین",
@@ -7057,7 +7855,7 @@ return {
["cs"]="bottomspace",
["de"]="bottomspace",
["en"]="bottomspace",
- ["fr"]="espaceinf",
+ ["fr"]="espacebas",
["it"]="spaziofondo",
["nl"]="bodemwit",
["pe"]="فضایپایین",
@@ -7067,7 +7865,7 @@ return {
["cs"]="statusspodku",
["de"]="untenstatus",
["en"]="bottomstate",
- ["fr"]="etatinf",
+ ["fr"]="etatbas",
["it"]="statofondo",
["nl"]="onderstatus",
["pe"]="وضعیتپایین",
@@ -7075,17 +7873,19 @@ return {
},
["break"]={
["en"]="break",
+ ["fr"]="saut",
["nl"]="break",
},
["buffer"]={
["en"]="buffer",
+ ["fr"]="tampon",
["nl"]="buffer",
},
["cache"]={
["cs"]="cache",
["de"]="cache",
["en"]="cache",
- ["fr"]="cache",
+ ["fr"]="memoirecache",
["it"]="cache",
["nl"]="cache",
["pe"]="میانگیر",
@@ -7103,13 +7903,14 @@ return {
},
["category"]={
["en"]="category",
+ ["fr"]="categorie",
["nl"]="categorie",
},
["ccommand"]={
["cs"]="cprikaz",
["de"]="cbefehl",
["en"]="ccommand",
- ["fr"]="ccommande",
+ ["fr"]="commandec",
["it"]="ccomando",
["nl"]="ccommando",
["pe"]="فرمان",
@@ -7117,12 +7918,15 @@ return {
},
["character"]={
["en"]="character",
+ ["fr"]="caractere",
},
["characters"]={
["en"]="characters",
+ ["fr"]="caracteres",
},
["check"]={
["en"]="check",
+ ["fr"]="verifier",
},
["click"]={
["cs"]="klik",
@@ -7158,7 +7962,7 @@ return {
["cs"]="clipoffset",
["de"]="clipoffset",
["en"]="clipoffset",
- ["fr"]="clipoffset",
+ ["fr"]="decalagedecoupe",
["it"]="clipoffset",
["nl"]="clipoffset",
["pe"]="آفستکلیپ",
@@ -7168,7 +7972,7 @@ return {
["cs"]="zavriakci",
["de"]="schliessenaktion",
["en"]="closeaction",
- ["fr"]="actionfermeture",
+ ["fr"]="fermeraction",
["it"]="azionechiudi",
["nl"]="sluitactie",
["pe"]="بستنکنش",
@@ -7178,7 +7982,7 @@ return {
["cs"]="closecommand",
["de"]="closecommand",
["en"]="closecommand",
- ["fr"]="closecommand",
+ ["fr"]="fermercommande",
["it"]="closecommand",
["nl"]="sluitcommando",
["pe"]="بستنفرمان",
@@ -7186,13 +7990,14 @@ return {
},
["closepage"]={
["en"]="closepage",
+ ["fr"]="fermerpage",
["nl"]="sluitpagina",
},
["closepageaction"]={
["cs"]="akcezavrenistranky",
["de"]="closepageaction",
["en"]="closepageaction",
- ["fr"]="actionfermeturepage",
+ ["fr"]="fermeractionpage",
["it"]="azionechiudipagina",
["nl"]="sluitpaginaactie",
["pe"]="بستنعملصفحه",
@@ -7202,7 +8007,7 @@ return {
["cs"]="closesymbol",
["de"]="closesymbol",
["en"]="closesymbol",
- ["fr"]="closesymbol",
+ ["fr"]="fermersymbol",
["it"]="closesymbol",
["nl"]="sluitsymbool",
["pe"]="بستننماد",
@@ -7250,6 +8055,7 @@ return {
},
["comma"]={
["en"]="comma",
+ ["fr"]="virgule",
},
["command"]={
["cs"]="prikaz",
@@ -7265,7 +8071,7 @@ return {
["cs"]="prikazpo",
["de"]="zumbefehl",
["en"]="commandafter",
- ["fr"]="commandeapres",
+ ["fr"]="commandeaprès",
["it"]="comdandodopo",
["nl"]="nacommando",
["pe"]="فرمانبعداز",
@@ -7293,15 +8099,19 @@ return {
},
["comment"]={
["en"]="comment",
+ ["fr"]="commentaire",
},
["commentchar"]={
["en"]="commentchar",
+ ["fr"]="caracommentaire",
},
["commentoffset"]={
["en"]="commentoffset",
+ ["fr"]="decalagecommentaire",
},
["compact"]={
["en"]="compact",
+ ["fr"]="compact",
["nl"]="compact",
},
["component"]={
@@ -7318,7 +8128,7 @@ return {
["cs"]="compoundhyphen",
["de"]="compoundhyphen",
["en"]="compoundhyphen",
- ["fr"]="compoundhyphen",
+ ["fr"]="traitdunioncompose",
["it"]="compoundhyphen",
["nl"]="koppelteken",
["pe"]="compoundhyphen",
@@ -7328,36 +8138,42 @@ return {
["cs"]="compress",
["de"]="compress",
["en"]="compress",
- ["fr"]="compress",
+ ["fr"]="reduire",
["it"]="compress",
["nl"]="comprimeren",
["pe"]="فشردن",
["ro"]="compress",
},
- ["compressseparator"]={
- ["en"]="compressseparator",
- },
["compressdistance"]={
["en"]="compressdistance",
+ ["fr"]="distancereduction",
},
["compressmethod"]={
["en"]="compressmethod",
+ ["fr"]="methodereduction",
+ },
+ ["compressseparator"]={
+ ["en"]="compressseparator",
+ ["fr"]="separateurreduction",
},
["compressstopper"]={
["en"]="compressstopper",
+ ["fr"]="stoppeurreduction",
},
["concerns"]={
["en"]="concerns",
+ ["fr"]="concerne",
["nl"]="betreft",
},
["connector"]={
["en"]="connector",
+ ["fr"]="connecteur",
},
["continue"]={
["cs"]="pokracovat",
["de"]="fortsetzen",
["en"]="continue",
- ["fr"]="continue",
+ ["fr"]="continuer",
["it"]="continua",
["nl"]="doorgaan",
["pe"]="ادامه",
@@ -7367,7 +8183,7 @@ return {
["cs"]="kontrastnibarva",
["de"]="kontrastfarbe",
["en"]="contrastcolor",
- ["fr"]="coleurcontraste",
+ ["fr"]="couleurconstrast",
["it"]="colorecontrasto",
["nl"]="contrastkleur",
["pe"]="contrastcolor",
@@ -7397,7 +8213,7 @@ return {
["cs"]="konverzesouboru",
["de"]="konvertieredatei",
["en"]="convertfile",
- ["fr"]="conversionfichier",
+ ["fr"]="convertirfichier",
["it"]="convertifile",
["nl"]="converteerfile",
["pe"]="پروندهتبدیل",
@@ -7405,6 +8221,7 @@ return {
},
["copies"]={
["en"]="copies",
+ ["fr"]="copies",
["nl"]="kopieen",
},
["corner"]={
@@ -7431,7 +8248,7 @@ return {
["cs"]="zpusobpropojeni",
["de"]="verkopplungsart",
["en"]="couplingway",
- ["fr"]="modecouplage",
+ ["fr"]="faconcouplage",
["it"]="modoaccoppiamento",
["nl"]="koppelwijze",
["pe"]="روشتزویج",
@@ -7447,14 +8264,17 @@ return {
["pe"]="criterium",
["ro"]="criteriu",
},
- ["crossreference"]={
- ["en"]="crossreference",
- },
["cropoffset"]={
["en"]="cropoffset",
+ ["fr"]="decalagerecadre",
+ },
+ ["crossreference"]={
+ ["en"]="crossreference",
+ ["fr"]="renvoi",
},
["cssfile"]={
["en"]="cssfile",
+ ["fr"]="fichiercss",
},
["current"]={
["cs"]="aktualni",
@@ -7470,7 +8290,7 @@ return {
["cs"]="cutspace",
["de"]="cutspace",
["en"]="cutspace",
- ["fr"]="cutspace",
+ ["fr"]="espacecoupe",
["it"]="cutspace",
["nl"]="snijwit",
["pe"]="فضایبرش",
@@ -7498,9 +8318,11 @@ return {
},
["database"]={
["en"]="database",
+ ["fr"]="basededonnees",
},
["dataset"]={
["en"]="dataset",
+ ["fr"]="jeudedonnees",
},
["date"]={
["cs"]="datum",
@@ -7512,15 +8334,11 @@ return {
["pe"]="تاریخ",
["ro"]="data",
},
- ["time"]={
- ["en"]="time",
- ["nl"]="tijd",
- },
["deepnumbercommand"]={
["cs"]="deepnumbercommand",
["de"]="deepnumbercommand",
["en"]="deepnumbercommand",
- ["fr"]="deepnumbercommand",
+ ["fr"]="commandeprofondenumero",
["it"]="deepnumbercommand",
["nl"]="diepnummercommando",
["pe"]="فرمانشمارهعمیق",
@@ -7530,12 +8348,16 @@ return {
["cs"]="deeptextcommand",
["de"]="deeptextcommand",
["en"]="deeptextcommand",
- ["fr"]="deeptextcommand",
+ ["fr"]="commandeprofondetexte",
["it"]="deeptextcommand",
["nl"]="dieptekstcommando",
["pe"]="فرمانمتنعمیق",
["ro"]="deeptextcommand",
},
+ ["define"]={
+ ["en"]="define",
+ ["nl"]="definieer",
+ },
["default"]={
["cs"]="implicitni",
["de"]="default",
@@ -7546,11 +8368,19 @@ return {
["pe"]="پیشفرض",
["ro"]="implicit",
},
+ ["defaultwidth"]={
+ ["en"]="defaultwidth",
+ ["nl"]="defaultbreedte",
+ },
+ ["defaultheight"]={
+ ["en"]="defaultheight",
+ ["nl"]="defaulthoogte",
+ },
["delay"]={
["cs"]="prodleva",
["de"]="wartezeit",
["en"]="delay",
- ["fr"]="delai",
+ ["fr"]="retard",
["it"]="attesa",
["nl"]="wachttijd",
["pe"]="تاخیر",
@@ -7606,6 +8436,10 @@ return {
["pe"]="نمایش",
["ro"]="display",
},
+ ["displaythreshold"]={
+ ["en"]="displaythreshold",
+ ["fr"]="seuilaffichage",
+ },
["distance"]={
["cs"]="vzdalenost",
["de"]="abstand",
@@ -7618,6 +8452,7 @@ return {
},
["domain"]={
["en"]="domain",
+ ["fr"]="domaine",
},
["dot"]={
["cs"]="tecka",
@@ -7641,12 +8476,13 @@ return {
},
["down"]={
["en"]="down",
+ ["fr"]="enbas",
},
["dummy"]={
["cs"]="dummy",
["de"]="dummy",
["en"]="dummy",
- ["fr"]="dummy",
+ ["fr"]="factice",
["it"]="dummy",
["nl"]="dummy",
["pe"]="مصنوعی",
@@ -7694,15 +8530,19 @@ return {
},
["editor"]={
["en"]="editor",
+ ["fr"]="editeur",
},
["editoretaldisplay"]={
["en"]="editoretaldisplay",
+ ["fr"]="editeurealaffichage",
},
["editoretallimit"]={
["en"]="editoretallimit",
+ ["fr"]="editeureallimite",
},
["editoretaltext"]={
["en"]="editoretaltext",
+ ["fr"]="editeurealtexte",
},
["empty"]={
["cs"]="prazdne",
@@ -7716,17 +8556,22 @@ return {
},
["entities"]={
["en"]="entities",
+ ["fr"]="entitees",
["nl"]="entities",
},
["entries"]={
["en"]="entries",
+ ["fr"]="entrees",
["nl"]="ingangen",
},
+ ["processors"]={
+ ["en"]="processors",
+ },
["equalheight"]={
["cs"]="equalheight",
["de"]="equalheight",
["en"]="equalheight",
- ["fr"]="equalheight",
+ ["fr"]="hauteuregale",
["it"]="equalheight",
["nl"]="equalheight",
["pe"]="ارتفاعیکسان",
@@ -7736,7 +8581,7 @@ return {
["cs"]="equalwidth",
["de"]="equalwidth",
["en"]="equalwidth",
- ["fr"]="equalwidth",
+ ["fr"]="margeuregale",
["it"]="equalwidth",
["nl"]="equalwidth",
["pe"]="عرضیکسان",
@@ -7746,7 +8591,7 @@ return {
["cs"]="escape",
["de"]="escape",
["en"]="escape",
- ["fr"]="escape",
+ ["fr"]="echappatoire",
["it"]="escape",
["nl"]="escape",
["pe"]="فرار",
@@ -7754,15 +8599,19 @@ return {
},
["etaldisplay"]={
["en"]="etaldisplay",
+ ["fr"]="etalaffichage",
},
["etallimit"]={
["en"]="etallimit",
+ ["fr"]="etallimite",
},
["etaloption"]={
["en"]="etaloption",
+ ["fr"]="etaloption",
},
["etaltext"]={
["en"]="etaltext",
+ ["fr"]="etalttexte",
},
["evenmargin"]={
["cs"]="sudamarginalie",
@@ -7776,9 +8625,11 @@ return {
},
["exact"]={
["en"]="exact",
+ ["fr"]="exact",
},
["exitoffset"]={
["en"]="exitoffset",
+ ["fr"]="decalagesortie",
},
["expansion"]={
["cs"]="expanzen",
@@ -7792,6 +8643,7 @@ return {
},
["export"]={
["en"]="export",
+ ["fr"]="exporter",
["nl"]="exporteer",
},
["extras"]={
@@ -7818,12 +8670,16 @@ return {
["cs"]="fallback",
["de"]="fallback",
["en"]="fallback",
- ["fr"]="fallback",
+ ["fr"]="repli",
["it"]="fallback",
["nl"]="terugval",
["pe"]="عقبریختن",
["ro"]="fallback",
},
+ ["fallbacks"]={
+ ["en"]="fallbacks",
+ ["fr"]="replis",
+ },
["family"]={
["cs"]="rodina",
["de"]="familie",
@@ -7836,12 +8692,19 @@ return {
},
["features"]={
["en"]="features",
+ ["fr"]="fonctionnalites",
+ },
+ ["featureset"]={
+ ["en"]="featureset",
+ ["fr"]="jeufonctionnalite",
},
["fences"]={
["en"]="fences",
+ ["fr"]="barrieres",
},
["field"]={
["en"]="field",
+ ["fr"]="champ",
["nl"]="veld",
},
["fieldbackgroundcolor"]={
@@ -7878,7 +8741,7 @@ return {
["cs"]="offsetpole",
["de"]="feldoffset",
["en"]="fieldoffset",
- ["fr"]="offsetchamp",
+ ["fr"]="decalagechamp",
["it"]="offsetcampo",
["nl"]="veldoffset",
["pe"]="آفستمیدان",
@@ -7896,21 +8759,27 @@ return {
},
["filler"]={
["en"]="filler",
+ ["fr"]="remplisseur",
},
["filter"]={
["en"]="filter",
+ ["fr"]="filtre",
},
["filtercommand"]={
["en"]="filtercommand",
+ ["fr"]="commandefiltre",
},
["finalnamesep"]={
["en"]="finalnamesep",
+ ["fr"]="sepnomfinal",
},
["finalpagesep"]={
["en"]="finalpagesep",
+ ["fr"]="seppagefinale",
},
["finalpubsep"]={
["en"]="finalpubsep",
+ ["fr"]="seppubfinale",
},
["first"]={
["cs"]="prvni",
@@ -7924,6 +8793,7 @@ return {
},
["firstnamesep"]={
["en"]="firstnamesep",
+ ["fr"]="seppremiernom",
},
["firstpage"]={
["cs"]="prvnistranka",
@@ -7955,6 +8825,11 @@ return {
["pe"]="تمرکزدرون",
["ro"]="focusin",
},
+ ["focusoffset"]={
+ ["en"]="focusoffset",
+ ["fr"]="decalagefocus",
+ ["nl"]="focusoffset",
+ },
["focusout"]={
["cs"]="focusout",
["de"]="focusout",
@@ -7965,9 +8840,9 @@ return {
["pe"]="تمرکزبیرون",
["ro"]="focusout",
},
- ["focusoffset"]={
- ["en"]="focusoffset",
- ["nl"]="focusoffset",
+ ["font"]={
+ ["en"]="font",
+ ["nl"]="font",
},
["footer"]={
["cs"]="upati",
@@ -7983,7 +8858,7 @@ return {
["cs"]="vzdalenostupati",
["de"]="fusszeilenabstand",
["en"]="footerdistance",
- ["fr"]="dsitancepdp",
+ ["fr"]="distancepdp",
["it"]="distanzapdp",
["nl"]="voetafstand",
["pe"]="فاصلهتهبرگ",
@@ -8003,7 +8878,7 @@ return {
["cs"]="sila",
["de"]="zwinge",
["en"]="force",
- ["fr"]="force",
+ ["fr"]="forcer",
["it"]="forza",
["nl"]="forceer",
["pe"]="اجبار",
@@ -8039,6 +8914,11 @@ return {
["pe"]="شمایل",
["ro"]="format",
},
+ ["fractions"]={
+ ["en"]="fractions",
+ ["fr"]="fractions",
+ ["nl"]="breuken",
+ },
["frame"]={
["cs"]="ramecek",
["de"]="rahmen",
@@ -8111,6 +8991,7 @@ return {
},
["freeregion"]={
["en"]="freeregion",
+ ["fr"]="regionlibre",
["nl"]="vrijgebied",
},
["from"]={
@@ -8125,15 +9006,17 @@ return {
},
["functioncolor"]={
["en"]="functioncolor",
+ ["fr"]="couleurfonction",
},
["functionstyle"]={
["en"]="functionstyle",
+ ["fr"]="stylefonction",
},
["get"]={
["cs"]="ziskat",
["de"]="hole",
["en"]="get",
- ["fr"]="obtient",
+ ["fr"]="obtenir",
["it"]="prendi",
["nl"]="haal",
["pe"]="بگیر",
@@ -8151,6 +9034,7 @@ return {
},
["goodies"]={
["en"]="goodies",
+ ["fr"]="friandises",
},
["grid"]={
["cs"]="mrizka",
@@ -8164,15 +9048,17 @@ return {
},
["group"]={
["en"]="group",
+ ["fr"]="groupe",
},
["groupsuffix"]={
["en"]="groupsuffix",
+ ["fr"]="suffixegroupe",
},
["hang"]={
["cs"]="zaveseni",
["de"]="haengend",
["en"]="hang",
- ["fr"]="suspend",
+ ["fr"]="suspendre",
["it"]="sospendi",
["nl"]="hang",
["pe"]="بیاویز",
@@ -8180,10 +9066,12 @@ return {
},
["hcompact"]={
["en"]="hcompact",
+ ["fr"]="compacth",
["nl"]="hcomprimeer",
},
["headalign"]={
["en"]="headalign",
+ ["fr"]="alignertete",
["nl"]="kopuitlijnen",
},
["headcolor"]={
@@ -8216,15 +9104,11 @@ return {
["pe"]="تبدیلسر",
["ro"]="conversietitlu",
},
- ["headseparator"]={
- ["en"]="headseparator",
- ["nl"]="kopscheider",
- },
["header"]={
["cs"]="zahlavi",
["de"]="kopfzeile",
["en"]="header",
- ["fr"]="entete",
+ ["fr"]="entête",
["it"]="intestazione",
["nl"]="hoofd",
["pe"]="سربرگ",
@@ -8234,7 +9118,7 @@ return {
["cs"]="vzdalenostzahlavi",
["de"]="kopfzeilenabstand",
["en"]="headerdistance",
- ["fr"]="distanceentete",
+ ["fr"]="distanceentête",
["it"]="distanzaintestazione",
["nl"]="hoofdafstand",
["pe"]="فاصلهسربرگ",
@@ -8244,7 +9128,7 @@ return {
["cs"]="statuszahlavi",
["de"]="kopfzeilenstatus",
["en"]="headerstate",
- ["fr"]="etatentete",
+ ["fr"]="etatentête",
["it"]="statointestazione",
["nl"]="hoofdstatus",
["pe"]="وضعیتسربرگ",
@@ -8270,6 +9154,11 @@ return {
["pe"]="شمارهسر",
["ro"]="numartitlu",
},
+ ["headseparator"]={
+ ["en"]="headseparator",
+ ["fr"]="separateurtete",
+ ["nl"]="kopscheider",
+ },
["headstyle"]={
["cs"]="stylhlavicky",
["de"]="kopfstil",
@@ -8294,25 +9183,17 @@ return {
["cs"]="hfaktor",
["de"]="hfaktor",
["en"]="hfactor",
- ["fr"]="facteurhauteur",
+ ["fr"]="facteurh",
["it"]="hfactor",
["nl"]="hfactor",
["pe"]="عاملارتفاع",
["ro"]="hfactor",
},
- ["vfactor"]={
- ["cs"]="vfaktor",
- ["de"]="vfaktor",
- ["en"]="vfactor",
- ["it"]="vfactor",
- ["nl"]="vfactor",
- ["ro"]="vfactor",
- },
["hfil"]={
["cs"]="hfil",
["de"]="hfil",
["en"]="hfil",
- ["fr"]="hfil",
+ ["fr"]="remplissageh",
["it"]="hfil",
["nl"]="hfil",
["pe"]="پرکردنارتفاع",
@@ -8320,32 +9201,33 @@ return {
},
["hidenumber"]={
["en"]="hidenumber",
- },
- ["horizontal"]={
- ["cs"]="horizontalne",
- ["de"]="horizontal",
- ["en"]="horizontal",
- ["fr"]="horizontale",
- ["it"]="orizzontale",
- ["nl"]="horizontaal",
- ["pe"]="افقی",
- ["ro"]="orizontal",
+ ["fr"]="cachernumero",
},
["hoffset"]={
["cs"]="hoffset",
["de"]="hoffset",
["en"]="hoffset",
- ["fr"]="decalagehauteur",
+ ["fr"]="decalageh",
["it"]="hoffset",
["nl"]="hoffset",
["pe"]="آفستا",
["ro"]="hoffset",
},
+ ["horizontal"]={
+ ["cs"]="horizontalne",
+ ["de"]="horizontal",
+ ["en"]="horizontal",
+ ["fr"]="horizontal",
+ ["it"]="orizzontale",
+ ["nl"]="horizontaal",
+ ["pe"]="افقی",
+ ["ro"]="orizontal",
+ },
["horoffset"]={
["cs"]="horoffset",
["de"]="rumpfabstand",
["en"]="horoffset",
- ["fr"]="horoffset",
+ ["fr"]="decalagehor",
["it"]="horoffset",
["nl"]="rugoffset",
["pe"]="آفستافق",
@@ -8355,7 +9237,7 @@ return {
["cs"]="hyphen",
["de"]="hyphen",
["en"]="hyphen",
- ["fr"]="hyphen",
+ ["fr"]="traitdunion",
["it"]="hyphen",
["nl"]="hyphen",
["pe"]="شکستن",
@@ -8363,12 +9245,13 @@ return {
},
["hyphens"]={
["en"]="hyphens",
+ ["fr"]="traitsdunion",
},
["icommand"]={
["cs"]="iprikaz",
["de"]="ibefehl",
["en"]="icommand",
- ["fr"]="icommande",
+ ["fr"]="commandei",
["it"]="icomando",
["nl"]="icommando",
["pe"]="icommand",
@@ -8376,12 +9259,13 @@ return {
},
["ignore"]={
["en"]="ignore",
+ ["fr"]="ignorer",
},
["in"]={
["cs"]="v",
["de"]="in",
["en"]="in",
- ["fr"]="in",
+ ["fr"]="dans",
["it"]="in",
["nl"]="in",
["pe"]="درون",
@@ -8401,7 +9285,7 @@ return {
["cs"]="zvysit",
["de"]="erhoehen",
["en"]="increment",
- ["fr"]="incremente",
+ ["fr"]="incrementer",
["it"]="incremento",
["nl"]="verhoog",
["pe"]="افزایش",
@@ -8411,7 +9295,7 @@ return {
["cs"]="zvysujicicislo",
["de"]="nummererhoehen",
["en"]="incrementnumber",
- ["fr"]="incrementenumero",
+ ["fr"]="incrementernumero",
["it"]="incrementanumero",
["nl"]="verhoognummer",
["pe"]="شمارهافزایش",
@@ -8421,17 +9305,20 @@ return {
["cs"]="odsazovani",
["de"]="einziehen",
["en"]="indenting",
- ["fr"]="composeenalinea",
+ ["fr"]="indentation",
["it"]="rientro",
["nl"]="inspringen",
["pe"]="تورفتگی",
["ro"]="aliniat",
},
+ ["indentlist"]={
+ ["en"]="indentlist",
+ },
["indentnext"]={
["cs"]="odsadpristi",
["de"]="ziehefolgendeein",
["en"]="indentnext",
- ["fr"]="indentesuivant",
+ ["fr"]="indenterauuivant",
["it"]="rientrasuccessivo",
["nl"]="springvolgendein",
["pe"]="متنتورفته",
@@ -8439,6 +9326,7 @@ return {
},
["index"]={
["en"]="index",
+ ["fr"]="index",
},
["indicator"]={
["cs"]="indikator",
@@ -8452,6 +9340,11 @@ return {
},
["initialsep"]={
["en"]="initialsep",
+ ["fr"]="sepinitial",
+ },
+ ["inlinethreshold"]={
+ ["en"]="inlinethreshold",
+ ["fr"]="seuilenligne",
},
["inner"]={
["cs"]="vnitrni",
@@ -8485,13 +9378,16 @@ return {
},
["insidesection"]={
["en"]="insidesection",
+ ["fr"]="auseinsection",
["nl"]="binnensectie",
},
["instance"]={
["en"]="instance",
+ ["fr"]="instance",
},
["intent"]={
["en"]="intent",
+ ["fr"]="intention",
},
["interaction"]={
["cs"]="interakce",
@@ -8515,19 +9411,22 @@ return {
},
["internalgrid"]={
["en"]="internalgrid",
+ ["fr"]="grilleinterieure",
["nl"]="interngrid",
},
["italicfeatures"]={
["en"]="italicfeatures",
+ ["fr"]="fonctionnalitesitalique",
},
["italicfont"]={
["en"]="italicfont",
+ ["fr"]="policeitalique",
},
["itemalign"]={
["cs"]="itemalign",
["de"]="itemalign",
["en"]="itemalign",
- ["fr"]="itemalign",
+ ["fr"]="alignerelem",
["it"]="itemalign",
["nl"]="itemuitlijnen",
["pe"]="تنظیمآیتم",
@@ -8537,7 +9436,7 @@ return {
["cs"]="polozky",
["de"]="posten",
["en"]="items",
- ["fr"]="elements",
+ ["fr"]="élément",
["it"]="elementi",
["nl"]="items",
["pe"]="آیتمها",
@@ -8545,21 +9444,25 @@ return {
},
["joiners"]={
["en"]="joiners",
+ ["fr"]="joins",
},
["journalconversion"]={
["en"]="journalconversion",
+ ["fr"]="conversionjournal",
},
["juniorsep"]={
["en"]="juniorsep",
+ ["fr"]="sepjunior",
},
["keeptogether"]={
["en"]="keeptogether",
+ ["fr"]="conserverensemble",
},
["ken"]={
["cs"]="ken",
["de"]="ken",
["en"]="ken",
- ["fr"]="ken",
+ ["fr"]="rep",
["it"]="ken",
["nl"]="ken",
["pe"]="ken",
@@ -8569,7 +9472,7 @@ return {
["cs"]="keyexpansion",
["de"]="keyexpansion",
["en"]="keyexpansion",
- ["fr"]="keyexpansion",
+ ["fr"]="expansioncle",
["it"]="keyexpansion",
["nl"]="sleutelexpansie",
["pe"]="گسترشکلید",
@@ -8577,13 +9480,14 @@ return {
},
["keys"]={
["en"]="keys",
+ ["fr"]="cles",
["nl"]="sleutels",
},
["keyword"]={
["cs"]="keyword",
["de"]="keyword",
["en"]="keyword",
- ["fr"]="motcle",
+ ["fr"]="motclé",
["it"]="parolachiave",
["nl"]="trefwoord",
["pe"]="کلیدواژه",
@@ -8599,17 +9503,36 @@ return {
["pe"]="برچسب",
["ro"]="eticheta",
},
+ ["labelalternative"]={
+ ["en"]="labelalternative",
+ ["fr"]="varianteetiquette",
+ ["nl"]="labelvariant",
+ },
+ ["labelcolor"]={
+ ["en"]="labelcolor",
+ ["fr"]="couleuretiquette",
+ ["nl"]="labelkleur",
+ },
["labeloffset"]={
["en"]="labeloffset",
+ ["fr"]="decalageetiquette",
+ },
+ ["labelstyle"]={
+ ["en"]="labelstyle",
+ ["fr"]="styleetiquette",
+ ["nl"]="labelletter",
},
["language"]={
["en"]="language",
+ ["fr"]="langue",
},
["last"]={
["en"]="last",
+ ["fr"]="dernier",
},
["lastnamesep"]={
["en"]="lastnamesep",
+ ["fr"]="sepderniernom",
},
["lastpage"]={
["cs"]="poslednistrana",
@@ -8623,12 +9546,15 @@ return {
},
["lastpagesep"]={
["en"]="lastpagesep",
+ ["fr"]="sepdernierepage",
},
["lastpubsep"]={
["en"]="lastpubsep",
+ ["fr"]="sepdernierepub",
},
["layout"]={
["en"]="layout",
+ ["fr"]="miseenpage",
["nl"]="layout",
},
["left"]={
@@ -8655,7 +9581,7 @@ return {
["cs"]="leftcompoundhyphen",
["de"]="leftcompoundhyphen",
["en"]="leftcompoundhyphen",
- ["fr"]="leftcompoundhyphen",
+ ["fr"]="traitdunioncomposegauche",
["it"]="leftcompoundhyphen",
["nl"]="linkerkoppelteken",
["pe"]="leftcompoundhyphen",
@@ -8695,7 +9621,7 @@ return {
["cs"]="lefthyphen",
["de"]="lefthyphen",
["en"]="lefthyphen",
- ["fr"]="lefthyphen",
+ ["fr"]="traitduniongauche",
["it"]="lefthyphen",
["nl"]="lefthyphen",
["pe"]="شکستچپ",
@@ -8751,6 +9677,10 @@ return {
["pe"]="نقلچپ",
["ro"]="minicitatstanga",
},
+ ["leftsample"]={
+ ["en"]="leftsample",
+ ["fr"]="echantillongauche",
+ },
["leftsentence"]={
["cs"]="vetavlevo",
["de"]="linkersatz",
@@ -8765,7 +9695,7 @@ return {
["cs"]="leftspeech",
["de"]="leftspeech",
["en"]="leftspeech",
- ["fr"]="leftspeech",
+ ["fr"]="discoursgauche",
["it"]="leftspeech",
["nl"]="linkeruitspraak",
["pe"]="سخنرانیچپ",
@@ -8775,7 +9705,7 @@ return {
["cs"]="stylvlevo",
["de"]="linkerstil",
["en"]="leftstyle",
- ["fr"]="leftstyle",
+ ["fr"]="stylegauche",
["it"]="stilesinistra",
["nl"]="linkerletter",
["pe"]="سبکچپ",
@@ -8813,9 +9743,11 @@ return {
},
["leftwords"]={
["en"]="leftwords",
+ ["fr"]="motsgauche",
},
["less"]={
["en"]="less",
+ ["fr"]="moins",
["nl"]="minder",
},
["level"]={
@@ -8842,7 +9774,7 @@ return {
["cs"]="limittext",
["de"]="limittext",
["en"]="limittext",
- ["fr"]="limittext",
+ ["fr"]="textelimite",
["it"]="limittext",
["nl"]="limiettekst",
["pe"]="مرزمتن",
@@ -8868,6 +9800,10 @@ return {
["pe"]="تصحیحخط",
["ro"]="corectielinie",
},
+ ["linedirection"]={
+ ["en"]="linedirection",
+ ["nl"]="regelrichting",
+ },
["lines"]={
["cs"]="radky",
["de"]="zeilen",
@@ -8920,6 +9856,7 @@ return {
},
["loffset"]={
["en"]="loffset",
+ ["fr"]="decalagel",
},
["logo"]={
["cs"]="logo",
@@ -8945,7 +9882,7 @@ return {
["cs"]="barvaznacky",
["de"]="beschrfarbe",
["en"]="marcolor",
- ["fr"]="couleurmarquage",
+ ["fr"]="couleurrem",
["it"]="coloremarcatura",
["nl"]="markleur",
["pe"]="رنگحاش",
@@ -8975,7 +9912,7 @@ return {
["cs"]="textovahrana",
["de"]="marginalkante",
["en"]="marginedge",
- ["fr"]="bordmarge",
+ ["fr"]="margebord",
["it"]="bordomargine",
["nl"]="kantlijn",
["pe"]="لبهحاشیه",
@@ -8985,7 +9922,7 @@ return {
["cs"]="textmarginalnihookraje",
["de"]="marginalkantetext",
["en"]="marginedgetext",
- ["fr"]="textebordmarge",
+ ["fr"]="textemargebord",
["it"]="testobordomargine",
["nl"]="kantlijntekst",
["pe"]="متنلبهحاشیه",
@@ -9003,6 +9940,7 @@ return {
},
["mark"]={
["en"]="mark",
+ ["fr"]="marque",
["nl"]="kernmerk",
},
["marking"]={
@@ -9019,7 +9957,7 @@ return {
["cs"]="stylsnacky",
["de"]="beschrstil",
["en"]="marstyle",
- ["fr"]="stylemarquage",
+ ["fr"]="stylerem",
["it"]="stilemarcatura",
["nl"]="marletter",
["pe"]="سبکحاش",
@@ -9027,16 +9965,20 @@ return {
},
["mask"]={
["en"]="mask",
+ ["fr"]="masque",
["nl"]="masker",
},
["mathclass"]={
["en"]="mathclass",
+ ["fr"]="classemath",
},
["mathlimits"]={
["en"]="mathlimits",
+ ["fr"]="limitesmath",
},
["mathstyle"]={
["en"]="mathstyle",
+ ["fr"]="stylemath",
},
["max"]={
["cs"]="max",
@@ -9050,6 +9992,7 @@ return {
},
["maxdepth"]={
["en"]="maxdepth",
+ ["fr"]="profondeurmax",
},
["maxheight"]={
["cs"]="maxvyska",
@@ -9073,6 +10016,7 @@ return {
},
["maybeyear"]={
["en"]="maybeyear",
+ ["fr"]="anneepeutetre",
},
["menu"]={
["cs"]="menu",
@@ -9104,47 +10048,51 @@ return {
["pe"]="میان",
["ro"]="mijloc",
},
- ["middlecommand"]={
- ["en"]="middlecommand",
- ["nl"]="middencommando",
- },
["middlecolor"]={
["en"]="middlecolor",
+ ["fr"]="couleurmilieu",
["nl"]="middenkleur",
},
- ["middlestyle"]={
- ["en"]="middlestyle",
- ["nl"]="middenletter",
- },
- ["middlewidth"]={
- ["en"]="middlewidth",
- ["nl"]="middenbreedte",
+ ["middlecommand"]={
+ ["en"]="middlecommand",
+ ["fr"]="commandemilieu",
+ ["nl"]="middencommando",
},
["middlespeech"]={
["cs"]="middlespeech",
["de"]="middlespeech",
["en"]="middlespeech",
- ["fr"]="middlespeech",
+ ["fr"]="discoursmilieu",
["it"]="middlespeech",
["nl"]="middenuitspraak",
["pe"]="سخنرانیمیانی",
["ro"]="middlespeech",
},
+ ["middlestyle"]={
+ ["en"]="middlestyle",
+ ["fr"]="stylemilieu",
+ ["nl"]="middenletter",
+ },
["middletext"]={
["cs"]="strednitext",
["de"]="mittigertext",
["en"]="middletext",
- ["fr"]="textecentre",
+ ["fr"]="textemilieu",
["it"]="testocentro",
["nl"]="middentekst",
["pe"]="متنمیانی",
["ro"]="textmijloc",
},
+ ["middlewidth"]={
+ ["en"]="middlewidth",
+ ["fr"]="largeurmilieu",
+ ["nl"]="middenbreedte",
+ },
["midsentence"]={
["cs"]="midsentence",
["de"]="midsentence",
["en"]="midsentence",
- ["fr"]="midsentence",
+ ["fr"]="milieuphrase",
["it"]="midsentence",
["nl"]="middenzin",
["pe"]="جملهمیانی",
@@ -9194,7 +10142,7 @@ return {
["cs"]="moffset",
["de"]="moffset",
["en"]="moffset",
- ["fr"]="moffset",
+ ["fr"]="decalagem",
["it"]="moffset",
["nl"]="moffset",
["pe"]="moffset",
@@ -9202,26 +10150,32 @@ return {
},
["monthconversion"]={
["en"]="monthconversion",
+ ["fr"]="conversionmois",
["nl"]="maandconversie",
},
["more"]={
["en"]="more",
+ ["fr"]="plus",
["nl"]="meer",
},
["mpdepth"]={
["en"]="mpdepth",
+ ["fr"]="profondeurmp",
["nl"]="mpdiepte",
},
["mpheight"]={
["en"]="mpheight",
+ ["fr"]="hauteurmp",
["nl"]="mphoogte",
},
["mpoffset"]={
["en"]="mpoffset",
+ ["fr"]="decalagemp",
["nl"]="mpoffset",
},
["mpwidth"]={
["en"]="mpwidth",
+ ["fr"]="largeurmp",
["nl"]="mpbreedte",
},
["n"]={
@@ -9246,12 +10200,13 @@ return {
},
["namesep"]={
["en"]="namesep",
+ ["fr"]="sepnom",
},
["nbottom"]={
["cs"]="nspodek",
["de"]="nunten",
["en"]="nbottom",
- ["fr"]="ninf",
+ ["fr"]="nbas",
["it"]="nfondo",
["nl"]="nonder",
["pe"]="nbottom",
@@ -9279,15 +10234,19 @@ return {
},
["nextleft"]={
["en"]="nextleft",
+ ["fr"]="suivantgauche",
},
["nextleftquotation"]={
["en"]="nextleftquotation",
+ ["fr"]="citationgauchesuivante",
},
["nextright"]={
["en"]="nextright",
+ ["fr"]="suivantdroite",
},
["nextrightquotation"]={
["en"]="nextrightquotation",
+ ["fr"]="citationdroitesuivante",
},
["nl"]={
["cs"]="nl",
@@ -9331,10 +10290,12 @@ return {
},
["note"]={
["en"]="note",
+ ["fr"]="note",
["nl"]="noot",
},
["notes"]={
["en"]="notes",
+ ["fr"]="notes",
["nl"]="noten",
},
["nr"]={
@@ -9361,7 +10322,7 @@ return {
["cs"]="nvrsek",
["de"]="noben",
["en"]="ntop",
- ["fr"]="nsup",
+ ["fr"]="nhaut",
["it"]="ncima",
["nl"]="nboven",
["pe"]="ntop",
@@ -9379,6 +10340,7 @@ return {
},
["numberalign"]={
["en"]="numberalign",
+ ["fr"]="alignernumero",
["nl"]="nummeruitlijnen",
},
["numbercolor"]={
@@ -9403,15 +10365,17 @@ return {
},
["numberconversion"]={
["en"]="numberconversion",
+ ["fr"]="conversionnumero",
},
["numberconversionset"]={
["en"]="numberconversionset",
+ ["fr"]="jeuconversionnumero",
},
["numberdistance"]={
["cs"]="numberdistance",
["de"]="numberdistance",
["en"]="numberdistance",
- ["fr"]="numberdistance",
+ ["fr"]="distancenumero",
["it"]="numberdistance",
["nl"]="nummerafstand",
["pe"]="فاصلهشماره",
@@ -9421,7 +10385,7 @@ return {
["cs"]="cislovani",
["de"]="nummerierung",
["en"]="numbering",
- ["fr"]="numerotation",
+ ["fr"]="numérotation",
["it"]="numerazione",
["nl"]="nummeren",
["pe"]="شمارهگذاری",
@@ -9429,18 +10393,21 @@ return {
},
["numberorder"]={
["en"]="numberorder",
+ ["fr"]="ordrenumero",
},
["numberprefix"]={
["en"]="numberprefix",
+ ["fr"]="prefixenumero",
},
["numbersegments"]={
["en"]="numbersegments",
+ ["fr"]="segmentsnumero",
},
["numberseparator"]={
["cs"]="oddelovaccisla",
["de"]="nummernseperator",
["en"]="numberseparator",
- ["fr"]="separateurnumbero",
+ ["fr"]="separateurnumero",
["it"]="separatorenumero",
["nl"]="nummerscheider",
["pe"]="جداکنندهشماره",
@@ -9448,15 +10415,24 @@ return {
},
["numberseparatorset"]={
["en"]="numberseparatorset",
+ ["fr"]="jeuseparateurnumero",
},
["numberset"]={
["en"]="numberset",
+ ["fr"]="jeunumero",
},
["numberstarter"]={
["en"]="numberstarter",
+ ["fr"]="demarreurnumero",
},
["numberstopper"]={
["en"]="numberstopper",
+ ["fr"]="stoppeurnumero",
+ },
+ ["numberstrut"]={
+ ["en"]="numberstrut",
+ ["fr"]="entretoisenumero",
+ ["nl"]="nummerstrut",
},
["numberstyle"]={
["cs"]="stylcisla",
@@ -9472,7 +10448,7 @@ return {
["cs"]="numberwidth",
["de"]="numberwidth",
["en"]="numberwidth",
- ["fr"]="numberwidth",
+ ["fr"]="largeurnumero",
["it"]="numberwidth",
["nl"]="nummerbreedte",
["pe"]="عرضشماره",
@@ -9522,7 +10498,7 @@ return {
["cs"]="lichyokraj",
["de"]="ungeraderand",
["en"]="oddmargin",
- ["fr"]="margepaire",
+ ["fr"]="margeimpaire",
["it"]="marginedispari",
["nl"]="onevenmarge",
["pe"]="حاشیهفرد",
@@ -9532,7 +10508,7 @@ return {
["cs"]="offset",
["de"]="offset",
["en"]="offset",
- ["fr"]="offset",
+ ["fr"]="decalage",
["it"]="offset",
["nl"]="offset",
["pe"]="آفست",
@@ -9542,7 +10518,7 @@ return {
["cs"]="otevriakci",
["de"]="oeffenaktion",
["en"]="openaction",
- ["fr"]="actionouverture",
+ ["fr"]="actionouvrir",
["it"]="azioneapri",
["nl"]="openactie",
["pe"]="عملباز",
@@ -9550,13 +10526,14 @@ return {
},
["openpage"]={
["en"]="openpage",
+ ["fr"]="ouvrirpage",
["nl"]="openpagina",
},
["openpageaction"]={
["cs"]="akceotevrenistranky",
["de"]="openpageaction",
["en"]="openpageaction",
- ["fr"]="actionouverturepage",
+ ["fr"]="actionouvrirpage",
["it"]="azioneapripagina",
["nl"]="openpaginaactie",
["pe"]="عملصفحهباز",
@@ -9564,9 +10541,11 @@ return {
},
["openup"]={
["en"]="openup",
+ ["fr"]="ouverture",
},
["opticalsize"]={
["en"]="opticalsize",
+ ["fr"]="tailleoptique",
},
["option"]={
["cs"]="volba",
@@ -9580,12 +10559,9 @@ return {
},
["order"]={
["en"]="order",
+ ["fr"]="ordre",
["nl"]="volgorde",
},
- ["anchoring"]={
- ["en"]="anchoring",
- ["nl"]="verankering",
- },
["orientation"]={
["cs"]="orientation",
["de"]="orientation",
@@ -9598,6 +10574,7 @@ return {
},
["otherstext"]={
["en"]="otherstext",
+ ["fr"]="texteautres",
},
["outermargin"]={
["cs"]="outermargin",
@@ -9613,17 +10590,21 @@ return {
["cs"]="overprint",
["de"]="overprint",
["en"]="overprint",
- ["fr"]="overprint",
+ ["fr"]="surimpression",
["it"]="overprint",
["nl"]="overprint",
["pe"]="overprint",
["ro"]="overprint",
},
+ ["ownerpassword"]={
+ ["en"]="ownerpassword",
+ ["fr"]="motdepasseproprietaire",
+ },
["ownnumber"]={
["cs"]="vlastnicislo",
["de"]="eigenenummer",
["en"]="ownnumber",
- ["fr"]="numeroproprio",
+ ["fr"]="numeropropre",
["it"]="numeroproprio",
["nl"]="eigennummer",
["pe"]="شمارهخود",
@@ -9631,6 +10612,7 @@ return {
},
["packcriterium"]={
["en"]="packcriterium",
+ ["fr"]="criterepack",
["nl"]="opelkaarcriterium",
},
["page"]={
@@ -9647,7 +10629,7 @@ return {
["cs"]="hranicestranky",
["de"]="seitenbegrenzung",
["en"]="pageboundaries",
- ["fr"]="limitespage",
+ ["fr"]="frontierespage",
["it"]="limitipagina",
["nl"]="paginaovergangen",
["pe"]="مرزهایصفحه",
@@ -9665,6 +10647,7 @@ return {
},
["pagecolormodel"]={
["en"]="pagecolormodel",
+ ["fr"]="modelecouleurpage",
["nl"]="paginakleurmodel",
},
["pagecommand"]={
@@ -9679,18 +10662,23 @@ return {
},
["pageconnector"]={
["en"]="pageconnector",
+ ["fr"]="connecteurpage",
},
["pageconversion"]={
["en"]="pageconversion",
+ ["fr"]="conversionpage",
},
["pageconversionset"]={
["en"]="pageconversionset",
+ ["fr"]="jeuconversionpage",
},
["pageleft"]={
["en"]="pageleft",
+ ["fr"]="pagegauche",
},
["pagemethod"]={
["en"]="pagemethod",
+ ["fr"]="methodepage",
["nl"]="paginamethode",
},
["pagenumber"]={
@@ -9705,48 +10693,63 @@ return {
},
["pageprefix"]={
["en"]="pageprefix",
+ ["fr"]="prefixepage",
},
["pageprefixconnector"]={
["en"]="pageprefixconnector",
+ ["fr"]="connecteurprefixepage",
},
["pageprefixconversion"]={
["en"]="pageprefixconversion",
+ ["fr"]="conversionprefixepage",
},
["pageprefixconversionset"]={
["en"]="pageprefixconversionset",
+ ["fr"]="jeuconversionprefixepage",
},
["pageprefixsegments"]={
["en"]="pageprefixsegments",
+ ["fr"]="segmentsprefixepage",
},
["pageprefixseparatorset"]={
["en"]="pageprefixseparatorset",
+ ["fr"]="jeuseparateurprefixepage",
},
["pageprefixset"]={
["en"]="pageprefixset",
+ ["fr"]="jeuprefixepage",
},
["pageprefixstarter"]={
["en"]="pageprefixstarter",
+ ["fr"]="demarreurprefixepage",
},
["pageprefixstopper"]={
["en"]="pageprefixstopper",
+ ["fr"]="stoppeurprefixpage",
},
["pageright"]={
["en"]="pageright",
+ ["fr"]="pagedroite",
},
["pagesegments"]={
["en"]="pagesegments",
+ ["fr"]="segmentspage",
},
["pagesep"]={
["en"]="pagesep",
+ ["fr"]="seppage",
},
["pageseparatorset"]={
["en"]="pageseparatorset",
+ ["fr"]="jeuseparateurpage",
},
["pageset"]={
["en"]="pageset",
+ ["fr"]="jeupage",
},
["pagestarter"]={
["en"]="pagestarter",
+ ["fr"]="demarreurpage",
},
["pagestate"]={
["cs"]="pagestate",
@@ -9760,6 +10763,7 @@ return {
},
["pagestopper"]={
["en"]="pagestopper",
+ ["fr"]="stoppeurpage",
},
["pagestyle"]={
["cs"]="stylstranky",
@@ -9803,12 +10807,13 @@ return {
},
["period"]={
["en"]="period",
+ ["fr"]="periode",
},
["place"]={
["cs"]="umistit",
["de"]="platziere",
["en"]="place",
- ["fr"]="place",
+ ["fr"]="placer",
["it"]="metti",
["nl"]="plaatsen",
["pe"]="بگذار",
@@ -9818,17 +10823,20 @@ return {
["cs"]="umistihlavicku",
["de"]="setzekopf",
["en"]="placehead",
- ["fr"]="placetete",
+ ["fr"]="placertete",
["it"]="mettitesta",
["nl"]="plaatskop",
["pe"]="بگذارسر",
["ro"]="punetitlu",
},
+ ["placeholder"]={
+ ["en"]="placeholder",
+ },
["placestopper"]={
["cs"]="predelmista",
["de"]="setzetrenner",
["en"]="placestopper",
- ["fr"]="emplacementstopper",
+ ["fr"]="placerstoppeur",
["it"]="mettistopper",
["nl"]="plaatsafsluiter",
["pe"]="بگذارایست",
@@ -9856,33 +10864,41 @@ return {
},
["prefixconnector"]={
["en"]="prefixconnector",
+ ["fr"]="connecteurprefixe",
},
["prefixconversion"]={
["en"]="prefixconversion",
+ ["fr"]="conversionprefixe",
},
["prefixconversionset"]={
["en"]="prefixconversionset",
+ ["fr"]="jeuconversionprefixe",
},
["prefixsegments"]={
["en"]="prefixsegments",
+ ["fr"]="segmentsprefixe",
},
["prefixseparatorset"]={
["en"]="prefixseparatorset",
+ ["fr"]="jeuseparateurprefixe",
},
["prefixset"]={
["en"]="prefixset",
+ ["fr"]="jeuprefixe",
},
["prefixstarter"]={
["en"]="prefixstarter",
+ ["fr"]="demarreurprefixe",
},
["prefixstopper"]={
["en"]="prefixstopper",
+ ["fr"]="stoppeurprefixe",
},
["preset"]={
["cs"]="prednastaveni",
["de"]="voreinstellung",
["en"]="preset",
- ["fr"]="prereglage",
+ ["fr"]="preregler",
["it"]="preimpostato",
["nl"]="preset",
["pe"]="preset",
@@ -9892,7 +10908,7 @@ return {
["cs"]="nahled",
["de"]="vorschau",
["en"]="preview",
- ["fr"]="previsualisation",
+ ["fr"]="apercu",
["it"]="anteprima",
["nl"]="preview",
["pe"]="پیشدید",
@@ -9920,13 +10936,14 @@ return {
},
["print"]={
["en"]="print",
+ ["fr"]="imprimer",
["nl"]="print",
},
["printable"]={
["cs"]="tisknutelne",
["de"]="druckbar",
["en"]="printable",
- ["fr"]="editable",
+ ["fr"]="imprimable",
["it"]="stampabile",
["nl"]="printbaar",
["pe"]="قابلچاپ",
@@ -9936,7 +10953,7 @@ return {
["cs"]="process",
["de"]="process",
["en"]="process",
- ["fr"]="process",
+ ["fr"]="traiter",
["it"]="process",
["nl"]="proces",
["pe"]="پردازش",
@@ -9944,15 +10961,19 @@ return {
},
["profile"]={
["en"]="profile",
+ ["fr"]="profil",
},
["properties"]={
["en"]="properties",
+ ["fr"]="proprietes",
},
["pubsep"]={
["en"]="pubsep",
+ ["fr"]="seppub",
},
["quotechar"]={
["en"]="quotechar",
+ ["fr"]="caracitation",
},
["radius"]={
["cs"]="polomer",
@@ -9976,6 +10997,7 @@ return {
},
["range"]={
["en"]="range",
+ ["fr"]="gamme",
["nl"]="bereik",
},
["reduction"]={
@@ -10000,6 +11022,7 @@ return {
},
["refcommand"]={
["en"]="refcommand",
+ ["fr"]="commanderef",
},
["reference"]={
["cs"]="odkaz",
@@ -10013,15 +11036,20 @@ return {
},
["referencemethod"]={
["en"]="referencemethod",
+ ["fr"]="methodereference",
+ },
+ ["referencetext"]={
+ ["en"]="referencetext",
},
["referenceprefix"]={
["en"]="referenceprefix",
+ ["fr"]="prefixereference",
},
["referencing"]={
["cs"]="odkazujici",
["de"]="referieren",
["en"]="referencing",
- ["fr"]="referencing",
+ ["fr"]="referencement",
["it"]="referencing",
["nl"]="refereren",
["pe"]="مراجعه",
@@ -10029,13 +11057,14 @@ return {
},
["region"]={
["en"]="region",
+ ["fr"]="region",
["nl"]="gebied",
},
["regionin"]={
["cs"]="oblastuvnitr",
["de"]="regionin",
["en"]="regionin",
- ["fr"]="entreregion",
+ ["fr"]="regiondedans",
["it"]="entraregione",
["nl"]="gebiedin",
["pe"]="ناحیهدرون",
@@ -10045,7 +11074,7 @@ return {
["cs"]="oblastvne",
["de"]="regionaus",
["en"]="regionout",
- ["fr"]="regionexterieure",
+ ["fr"]="regiondehors",
["it"]="esciregione",
["nl"]="gebieduit",
["pe"]="ناحیهبیرون",
@@ -10053,21 +11082,25 @@ return {
},
["register"]={
["en"]="register",
+ ["fr"]="registre",
},
["regularfeatures"]={
["en"]="regularfeatures",
+ ["fr"]="fonctionnalitesordinaires",
},
["regularfont"]={
["en"]="regularfont",
+ ["fr"]="policereordinaire",
},
["renderingsetup"]={
["en"]="renderingsetup",
+ ["fr"]="configurationrendu",
},
["repeat"]={
["cs"]="opakovat",
["de"]="wiederholen",
["en"]="repeat",
- ["fr"]="repete",
+ ["fr"]="repeter",
["it"]="ripeti",
["nl"]="herhaal",
["pe"]="تکرار",
@@ -10077,7 +11110,7 @@ return {
["cs"]="reset",
["de"]="reset",
["en"]="reset",
- ["fr"]="reset",
+ ["fr"]="raz",
["it"]="reset",
["nl"]="reset",
["pe"]="بازنشانی",
@@ -10105,12 +11138,13 @@ return {
},
["resources"]={
["en"]="resources",
+ ["fr"]="ressources",
},
["reverse"]={
["cs"]="reverse",
["de"]="reverse",
["en"]="reverse",
- ["fr"]="inverse",
+ ["fr"]="inverser",
["it"]="invertito",
["nl"]="omgekeerd",
["pe"]="برعکس",
@@ -10126,6 +11160,10 @@ return {
["pe"]="راست",
["ro"]="dreapta",
},
+ ["rightchars"]={
+ ["en"]="rightchars",
+ ["fr"]="caracteresdroite",
+ },
["rightcolor"]={
["cs"]="barvavpravo",
["de"]="rechterfarbe",
@@ -10140,7 +11178,7 @@ return {
["cs"]="rightcompoundhyphen",
["de"]="rightcompoundhyphen",
["en"]="rightcompoundhyphen",
- ["fr"]="rightcompoundhyphen",
+ ["fr"]="traitdunioncomposedroite",
["it"]="rightcompoundhyphen",
["nl"]="rechterkoppelteken",
["pe"]="rightcompoundhyphen",
@@ -10170,7 +11208,7 @@ return {
["cs"]="ramecekvpravo",
["de"]="rechterrahmen",
["en"]="rightframe",
- ["fr"]="cadredroit",
+ ["fr"]="cadredroite",
["it"]="cornicedestra",
["nl"]="rechterkader",
["pe"]="قالبراست",
@@ -10180,7 +11218,7 @@ return {
["cs"]="righthyphen",
["de"]="righthyphen",
["en"]="righthyphen",
- ["fr"]="righthyphen",
+ ["fr"]="traitduniondroite",
["it"]="righthyphen",
["nl"]="righthyphen",
["pe"]="righthyphen",
@@ -10210,7 +11248,7 @@ return {
["cs"]="pravyoffset",
["de"]="rechterabstand",
["en"]="rightoffset",
- ["fr"]="rightoffset",
+ ["fr"]="decalagedroite",
["it"]="offsetdestro",
["nl"]="rechteroffset",
["pe"]="آفستراست",
@@ -10236,6 +11274,10 @@ return {
["pe"]="نقلراست",
["ro"]="minicitatdreapta",
},
+ ["rightsample"]={
+ ["en"]="rightsample",
+ ["fr"]="echantillondroite",
+ },
["rightsentence"]={
["cs"]="vetavpravo",
["de"]="rechtersatz",
@@ -10250,7 +11292,7 @@ return {
["cs"]="rightspeech",
["de"]="rightspeech",
["en"]="rightspeech",
- ["fr"]="rightspeech",
+ ["fr"]="discoursdroite",
["it"]="rightspeech",
["nl"]="rechteruitspraak",
["pe"]="سخنرانیراست",
@@ -10280,7 +11322,7 @@ return {
["cs"]="textvpravo",
["de"]="rechtertext",
["en"]="righttext",
- ["fr"]="textedroit",
+ ["fr"]="textedroite",
["it"]="testodestro",
["nl"]="rechtertekst",
["pe"]="متنراست",
@@ -10298,12 +11340,11 @@ return {
},
["rightwords"]={
["en"]="rightwords",
- },
- ["rightchars"]={
- ["en"]="rightchars",
+ ["fr"]="motsdroite",
},
["roffset"]={
["en"]="roffset",
+ ["fr"]="decalager",
},
["rotation"]={
["cs"]="rotace",
@@ -10319,7 +11360,7 @@ return {
["cs"]="linka",
["de"]="linie",
["en"]="rule",
- ["fr"]="ligne",
+ ["fr"]="trait",
["it"]="linea",
["nl"]="lijn",
["pe"]="خط",
@@ -10329,7 +11370,7 @@ return {
["cs"]="barvalinky",
["de"]="linienfarbe",
["en"]="rulecolor",
- ["fr"]="couleurligne",
+ ["fr"]="couleurtrait",
["it"]="colorelinea",
["nl"]="lijnkleur",
["pe"]="رنگخط",
@@ -10337,13 +11378,14 @@ return {
},
["rulecommand"]={
["en"]="rulecommand",
+ ["fr"]="commandetrait",
["nl"]="lijncommando",
},
["rulethickness"]={
["cs"]="tloustkalinky",
["de"]="liniendicke",
["en"]="rulethickness",
- ["fr"]="epaisseurligne",
+ ["fr"]="epaisseurtrait",
["it"]="spessorelinea",
["nl"]="lijndikte",
["pe"]="ضخامتخط",
@@ -10359,12 +11401,6 @@ return {
["pe"]="همانصفحه",
["ro"]="aceeasipagina",
},
- ["leftsample"]={
- ["en"]="leftsample",
- },
- ["rightsample"]={
- ["en"]="rightsample",
- },
["sample"]={
["cs"]="vzor",
["de"]="muster",
@@ -10377,9 +11413,11 @@ return {
},
["samplesize"]={
["en"]="samplesize",
+ ["fr"]="tailleechantillon",
},
["saveinlist"]={
["en"]="saveinlist",
+ ["fr"]="enregistrerdansliste",
},
["scale"]={
["cs"]="meritko",
@@ -10395,7 +11433,7 @@ return {
["cs"]="rozsah",
["de"]="bereich",
["en"]="scope",
- ["fr"]="scope",
+ ["fr"]="perimetre",
["it"]="scope",
["nl"]="scope",
["pe"]="طرح",
@@ -10423,12 +11461,15 @@ return {
},
["sectionblock"]={
["en"]="sectionblock",
+ ["fr"]="blocsection",
},
["sectionconversion"]={
["en"]="sectionconversion",
+ ["fr"]="conversionsection",
},
["sectionconversionset"]={
["en"]="sectionconversionset",
+ ["fr"]="jeuconversionsection",
},
["sectionnumber"]={
["cs"]="cislooddilu",
@@ -10442,21 +11483,27 @@ return {
},
["sectionresetset"]={
["en"]="sectionresetset",
+ ["fr"]="jeurazsection",
},
["sectionsegments"]={
["en"]="sectionsegments",
+ ["fr"]="segmentssection",
},
["sectionseparatorset"]={
["en"]="sectionseparatorset",
+ ["fr"]="jeuseparateursection",
},
["sectionset"]={
["en"]="sectionset",
+ ["fr"]="jeusection",
},
["sectionstarter"]={
["en"]="sectionstarter",
+ ["fr"]="demarreursection",
},
["sectionstopper"]={
["en"]="sectionstopper",
+ ["fr"]="stoppeursection",
},
["separator"]={
["cs"]="oddelovac",
@@ -10470,28 +11517,30 @@ return {
},
["separatorcolor"]={
["en"]="separatorcolor",
+ ["fr"]="couleurseparateur",
["nl"]="scheiderkleur",
},
["separatorstyle"]={
["en"]="separatorstyle",
+ ["fr"]="styleseparateur",
["nl"]="scheiderletter",
},
["set"]={
["cs"]="set",
["de"]="set",
["en"]="set",
- ["fr"]="set",
+ ["fr"]="regler",
["it"]="set",
["nl"]="set",
["pe"]="قراربده",
["ro"]="set",
},
["setups"]={
- ["comment"]="no translations",
["en"]="setups",
},
["shrink"]={
["en"]="shrink",
+ ["fr"]="retrecir",
["nl"]="krimp",
},
["side"]={
@@ -10508,7 +11557,7 @@ return {
["cs"]="sidealign",
["de"]="sidealign",
["en"]="sidealign",
- ["fr"]="sidealign",
+ ["fr"]="alignercote",
["it"]="sidealign",
["nl"]="zijuitlijnen",
["pe"]="تنظیمکنار",
@@ -10518,7 +11567,7 @@ return {
["cs"]="sidemethod",
["de"]="sidemethod",
["en"]="sidemethod",
- ["fr"]="sidemethod",
+ ["fr"]="methodecote",
["it"]="sidemethod",
["nl"]="zijmethode",
["pe"]="روشکنار",
@@ -10528,7 +11577,7 @@ return {
["cs"]="bocnimezeraza",
["de"]="nebennachspatium",
["en"]="sidespaceafter",
- ["fr"]="espacelateralapres",
+ ["fr"]="espacelatéralaprès",
["it"]="spaziolateraledopo",
["nl"]="zijnawit",
["pe"]="فضایکناریبعد",
@@ -10546,15 +11595,12 @@ return {
},
["sidespaceinbetween"]={
["en"]="sidespaceinbetween",
+ ["fr"]="espacelateralentre",
["nl"]="zijtussenwit",
},
- ["spaceafterside"]={
- ["en"]="spaceafterside",
- ["nl"]="witnazij",
- },
- ["spacebeforeside"]={
- ["en"]="spacebeforeside",
- ["nl"]="witvoorzij",
+ ["sidethreshold"]={
+ ["en"]="sidethreshold",
+ ["fr"]="seuilcote",
},
["sign"]={
["cs"]="znak",
@@ -10566,11 +11612,16 @@ return {
["pe"]="علامت",
["ro"]="semn",
},
+ ["simplecommand"]={
+ ["en"]="simplecommand",
+ ["fr"]="commandesimple",
+ ["nl"]="simpelcommando",
+ },
["size"]={
["cs"]="velikost",
["de"]="groesse",
["en"]="size",
- ["fr"]="dimension",
+ ["fr"]="taille",
["it"]="dimensione",
["nl"]="formaat",
["pe"]="اندازه",
@@ -10578,9 +11629,11 @@ return {
},
["slantedfeatures"]={
["en"]="slantedfeatures",
+ ["fr"]="fonctionnalitesincline",
},
["slantedfont"]={
["en"]="slantedfont",
+ ["fr"]="policeinclinee",
},
["small"]={
["cs"]="male",
@@ -10594,22 +11647,26 @@ return {
},
["smallcapsfeatures"]={
["en"]="smallcapsfeatures",
+ ["fr"]="fonctionnalitespetitescaps",
},
["smallcapsfont"]={
["en"]="smallcapsfont",
+ ["fr"]="policepetitescaps",
},
["solution"]={
["en"]="solution",
+ ["fr"]="solution",
["nl"]="oplossing",
},
["sort"]={
["en"]="sort",
+ ["fr"]="trier",
},
["sorttype"]={
["cs"]="sorttype",
["de"]="sorttype",
["en"]="sorttype",
- ["fr"]="sorttype",
+ ["fr"]="modetri",
["it"]="sorttype",
["nl"]="sortering",
["pe"]="ترتیبتایپ",
@@ -10619,7 +11676,7 @@ return {
["cs"]="zdroj",
["de"]="quelle",
["en"]="source",
- ["fr"]="origine",
+ ["fr"]="source",
["it"]="origine",
["nl"]="bron",
["pe"]="منبع",
@@ -10639,12 +11696,17 @@ return {
["cs"]="mezeraza",
["de"]="nachspatium",
["en"]="spaceafter",
- ["fr"]="espaceapres",
+ ["fr"]="espaceaprès",
["it"]="spaziodopo",
["nl"]="nawit",
["pe"]="فضابعداز",
["ro"]="spatiudupa",
},
+ ["spaceafterside"]={
+ ["en"]="spaceafterside",
+ ["fr"]="espaceaprèscoté",
+ ["nl"]="witnazij",
+ },
["spacebefore"]={
["cs"]="mezerapred",
["de"]="vorspatium",
@@ -10655,11 +11717,16 @@ return {
["pe"]="فضاقبلاز",
["ro"]="spatiuinainte",
},
+ ["spacebeforeside"]={
+ ["en"]="spacebeforeside",
+ ["fr"]="espaceavantcote",
+ ["nl"]="witvoorzij",
+ },
["spaceinbetween"]={
["cs"]="spaceinbetween",
["de"]="spaceinbetween",
["en"]="spaceinbetween",
- ["fr"]="spaceinbetween",
+ ["fr"]="espaceentre",
["it"]="spaceinbetween",
["nl"]="tussenwit",
["pe"]="فضادربین",
@@ -10677,12 +11744,13 @@ return {
},
["specification"]={
["en"]="specification",
+ ["fr"]="specification",
},
["split"]={
["cs"]="split",
["de"]="split",
["en"]="split",
- ["fr"]="split",
+ ["fr"]="partager",
["it"]="separa",
["nl"]="splitsen",
["pe"]="شکافتن",
@@ -10692,7 +11760,7 @@ return {
["cs"]="splitcolor",
["de"]="splitcolor",
["en"]="splitcolor",
- ["fr"]="splitcolor",
+ ["fr"]="couleurpartage",
["it"]="splitcolor",
["nl"]="splitskleur",
["pe"]="شکافتنرنگ",
@@ -10702,7 +11770,7 @@ return {
["cs"]="splitmethod",
["de"]="splitmethod",
["en"]="splitmethod",
- ["fr"]="splitmethod",
+ ["fr"]="methodepartage",
["it"]="splitmethod",
["nl"]="splitsmethode",
["pe"]="روششکافتن",
@@ -10712,7 +11780,7 @@ return {
["cs"]="splitoffset",
["de"]="splitoffset",
["en"]="splitoffset",
- ["fr"]="splitoffset",
+ ["fr"]="decalagepartage",
["it"]="splitoffset",
["nl"]="splitsoffset",
["pe"]="شکافتنآفست",
@@ -10722,7 +11790,7 @@ return {
["cs"]="spot",
["de"]="spot",
["en"]="spot",
- ["fr"]="spot",
+ ["fr"]="tondirect",
["it"]="spot",
["nl"]="spot",
["pe"]="لکه",
@@ -10732,7 +11800,7 @@ return {
["cs"]="stack",
["de"]="stack",
["en"]="stack",
- ["fr"]="stack",
+ ["fr"]="pile",
["it"]="stack",
["nl"]="stapel",
["pe"]="توده",
@@ -10740,13 +11808,14 @@ return {
},
["stackname"]={
["en"]="stackname",
+ ["fr"]="nompile",
["nl"]="stapelnaam",
},
["start"]={
["cs"]="start",
["de"]="start",
["en"]="start",
- ["fr"]="demarre",
+ ["fr"]="début",
["it"]="inizia",
["nl"]="start",
["pe"]="شروع",
@@ -10754,13 +11823,14 @@ return {
},
["starter"]={
["en"]="starter",
+ ["fr"]="demarreur",
["nl"]="opener",
},
["state"]={
["cs"]="status",
["de"]="status",
["en"]="state",
- ["fr"]="etat",
+ ["fr"]="état",
["it"]="stato",
["nl"]="status",
["pe"]="وضعیت",
@@ -10770,7 +11840,7 @@ return {
["cs"]="krok",
["de"]="schritt",
["en"]="step",
- ["fr"]="pas",
+ ["fr"]="etape",
["it"]="passo",
["nl"]="stap",
["pe"]="گام",
@@ -10780,7 +11850,7 @@ return {
["cs"]="stop",
["de"]="stop",
["en"]="stop",
- ["fr"]="stoppe",
+ ["fr"]="fin",
["it"]="termina",
["nl"]="stop",
["pe"]="پایان",
@@ -10790,7 +11860,7 @@ return {
["cs"]="predel",
["de"]="abschnitttrenner",
["en"]="stopper",
- ["fr"]="taquet",
+ ["fr"]="stoppeur",
["it"]="stopper",
["nl"]="afsluiter",
["pe"]="ایست",
@@ -10800,7 +11870,7 @@ return {
["cs"]="natahnout",
["de"]="strecken",
["en"]="stretch",
- ["fr"]="etire",
+ ["fr"]="etirer",
["it"]="dilata",
["nl"]="rek",
["pe"]="کشیدن",
@@ -10808,25 +11878,18 @@ return {
},
["strip"]={
["en"]="strip",
+ ["fr"]="bande",
},
["strut"]={
["cs"]="strut",
["de"]="strut",
["en"]="strut",
- ["fr"]="strut",
+ ["fr"]="entretoise",
["it"]="strut",
["nl"]="strut",
["pe"]="بست",
["ro"]="strut",
},
- ["numberstrut"]={
- ["en"]="numberstrut",
- ["nl"]="nummerstrut",
- },
- ["titlestrut"]={
- ["en"]="titlestrut",
- ["nl"]="titelstrut",
- },
["style"]={
["cs"]="pismeno",
["de"]="stil",
@@ -10837,6 +11900,11 @@ return {
["pe"]="سبک",
["ro"]="stil",
},
+ ["stylealternative"]={
+ ["en"]="stylealternative",
+ ["fr"]="variantestyle",
+ ["nl"]="stylevariant",
+ },
["sub"]={
["cs"]="pod",
["de"]="unter",
@@ -10861,7 +11929,7 @@ return {
["cs"]="suffix",
["de"]="suffix",
["en"]="suffix",
- ["fr"]="suffix",
+ ["fr"]="suffixe",
["it"]="suffix",
["nl"]="suffix",
["pe"]="پسوند",
@@ -10869,23 +11937,29 @@ return {
},
["suffixseparator"]={
["en"]="suffixseparator",
+ ["fr"]="separateursuffixe",
["nl"]="suffixscheider",
},
["suffixstopper"]={
["en"]="suffixstopper",
+ ["fr"]="stoppeursuffixe",
["nl"]="suffixafsluiter",
},
["surnamefirstnamesep"]={
["en"]="surnamefirstnamesep",
+ ["fr"]="sepnomfamilleprenom",
},
["surnameinitialsep"]={
["en"]="surnameinitialsep",
+ ["fr"]="sepnomfamilleinitial",
},
["surnamesep"]={
["en"]="surnamesep",
+ ["fr"]="seprenom",
},
["svgstyle"]={
["en"]="svgstyle",
+ ["fr"]="stylesvg",
},
["sx"]={
["cs"]="sx",
@@ -10911,7 +11985,7 @@ return {
["cs"]="symzarovnani",
["de"]="symausrichtung",
["en"]="symalign",
- ["fr"]="symalignement",
+ ["fr"]="alignersym",
["it"]="symallinea",
["nl"]="symuitlijnen",
["pe"]="تنظیمنماد",
@@ -10929,6 +12003,7 @@ return {
},
["symbolcommand"]={
["en"]="symbolcommand",
+ ["fr"]="commandesymbole",
},
["symbolset"]={
["cs"]="sadasymbolu",
@@ -10984,7 +12059,7 @@ return {
["cs"]="synonymcommand",
["de"]="synonymbefehl",
["en"]="synonymcommand",
- ["fr"]="synonymcommand",
+ ["fr"]="commandesynonyme",
["it"]="synonymcommand",
["nl"]="synoniemcommando",
["pe"]="synonymcommand",
@@ -11022,6 +12097,7 @@ return {
},
["textalign"]={
["en"]="textalign",
+ ["fr"]="alignertexte",
},
["textcolor"]={
["cs"]="barvatextu",
@@ -11087,7 +12163,7 @@ return {
["cs"]="textmethod",
["de"]="textmethod",
["en"]="textmethod",
- ["fr"]="textmethod",
+ ["fr"]="methodetexte",
["it"]="textmethod",
["nl"]="tekstmethode",
["pe"]="روشمتن",
@@ -11145,15 +12221,12 @@ return {
},
["threshold"]={
["en"]="threshold",
+ ["fr"]="seuil",
},
- ["sidethreshold"]={
- ["en"]="sidethreshold",
- },
- ["displaythreshold"]={
- ["en"]="displaythreshold",
- },
- ["inlinethreshold"]={
- ["en"]="inlinethreshold",
+ ["time"]={
+ ["en"]="time",
+ ["fr"]="temps",
+ ["nl"]="tijd",
},
["title"]={
["cs"]="titul",
@@ -11175,15 +12248,11 @@ return {
["pe"]="رنگعنوان",
["ro"]="culoaretitlu",
},
- ["simplecommand"]={
- ["en"]="simplecommand",
- ["nl"]="simpelcommando",
- },
["titlecommand"]={
["cs"]="titlecommand",
["de"]="titlecommand",
["en"]="titlecommand",
- ["fr"]="titlecommand",
+ ["fr"]="commandetitre",
["it"]="titlecommand",
["nl"]="titelcommando",
["pe"]="فرمانعنوان",
@@ -11203,7 +12272,7 @@ return {
["cs"]="titleleft",
["de"]="titleleft",
["en"]="titleleft",
- ["fr"]="titleleft",
+ ["fr"]="gauchetitre",
["it"]="titleleft",
["nl"]="titellinks",
["pe"]="عنوانچپ",
@@ -11213,12 +12282,17 @@ return {
["cs"]="titleright",
["de"]="titleright",
["en"]="titleright",
- ["fr"]="titleright",
+ ["fr"]="droitetitre",
["it"]="titleright",
["nl"]="titelrechts",
["pe"]="عنوانراست",
["ro"]="titleright",
},
+ ["titlestrut"]={
+ ["en"]="titlestrut",
+ ["fr"]="entretoisetitre",
+ ["nl"]="titelstrut",
+ },
["titlestyle"]={
["cs"]="styltitulek",
["de"]="titelstil",
@@ -11241,6 +12315,7 @@ return {
},
["toffset"]={
["en"]="toffset",
+ ["fr"]="decalaget",
},
["tolerance"]={
["cs"]="tolerance",
@@ -11256,7 +12331,7 @@ return {
["cs"]="vrsek",
["de"]="oben",
["en"]="top",
- ["fr"]="sup",
+ ["fr"]="haut",
["it"]="cima",
["nl"]="boven",
["pe"]="بالا",
@@ -11264,13 +12339,14 @@ return {
},
["topcommand"]={
["en"]="topcommand",
+ ["fr"]="commandehaut",
["nl"]="bovencommando",
},
["topdistance"]={
["cs"]="vzdalenostvrsku",
["de"]="obenabstand",
["en"]="topdistance",
- ["fr"]="distancesup",
+ ["fr"]="distancehaut",
["it"]="distanzacima",
["nl"]="bovenafstand",
["pe"]="فاصلهبالا",
@@ -11280,7 +12356,7 @@ return {
["cs"]="rameceknahore",
["de"]="obenrahmen",
["en"]="topframe",
- ["fr"]="cadresup",
+ ["fr"]="cadrehaut",
["it"]="cornicecima",
["nl"]="bovenkader",
["pe"]="قالبراست",
@@ -11290,7 +12366,7 @@ return {
["cs"]="offsetvrsku",
["de"]="obenoffset",
["en"]="topoffset",
- ["fr"]="decalagesup",
+ ["fr"]="decalagehaut",
["it"]="offsetcima",
["nl"]="bovenoffset",
["pe"]="آفستبالا",
@@ -11300,7 +12376,7 @@ return {
["cs"]="svrchnimezera",
["de"]="kopfspatium",
["en"]="topspace",
- ["fr"]="espacesup",
+ ["fr"]="espacehaut",
["it"]="spaziocima",
["nl"]="kopwit",
["pe"]="فضایبالا",
@@ -11310,7 +12386,7 @@ return {
["cs"]="statusvrsku",
["de"]="statusoben",
["en"]="topstate",
- ["fr"]="etatsup",
+ ["fr"]="etathaut",
["it"]="statocima",
["nl"]="bovenstatus",
["pe"]="وضعیتبالا",
@@ -11318,22 +12394,26 @@ return {
},
["totalnumber"]={
["en"]="totalnumber",
+ ["fr"]="nombretotal",
},
["transform"]={
- ["en"]="transform",
- ["nl"]="transformatie",
+ ["en"]="transform",
+ ["fr"]="transformer",
+ ["nl"]="transformatie",
},
["translate"]={
["en"]="translate",
+ ["fr"]="traduire",
},
["trimoffset"]={
["en"]="trimoffset",
+ ["fr"]="decalagecoupe",
},
["type"]={
["cs"]="typ",
["de"]="typ",
["en"]="type",
- ["fr"]="type",
+ ["fr"]="transcrire",
["it"]="type",
["nl"]="type",
["pe"]="تایپ",
@@ -11361,12 +12441,13 @@ return {
},
["up"]={
["en"]="up",
+ ["fr"]="enhaut",
},
["urlalternative"]={
["cs"]="urlalternativa",
["de"]="urlalternative",
["en"]="urlalternative",
- ["fr"]="alternativeurl",
+ ["fr"]="varianteurl",
["it"]="alternativaurl",
["nl"]="urlvariant",
["pe"]="urlalternative",
@@ -11382,6 +12463,10 @@ return {
["pe"]="urlspace",
["ro"]="spatiuurl",
},
+ ["userpassword"]={
+ ["en"]="userpassword",
+ ["fr"]="motdepasseutilisateur",
+ },
["validate"]={
["cs"]="validovat",
["de"]="validieren",
@@ -11394,13 +12479,14 @@ return {
},
["values"]={
["en"]="values",
+ ["fr"]="valeurs",
["nl"]="waarden",
},
["vcommand"]={
["cs"]="vprikaz",
["de"]="vbefehl",
["en"]="vcommand",
- ["fr"]="vcommande",
+ ["fr"]="commandev",
["it"]="vcomando",
["nl"]="vcommando",
["pe"]="vcommand",
@@ -11408,37 +12494,48 @@ return {
},
["vcompact"]={
["en"]="vcompact",
+ ["fr"]="compactv",
["nl"]="vcomprimeer",
},
["vector"]={
["en"]="vector",
+ ["fr"]="vecteur",
["nl"]="vector",
},
+ ["veroffset"]={
+ ["cs"]="offsethlavicky",
+ ["de"]="kopfoffset",
+ ["en"]="veroffset",
+ ["fr"]="decalagever",
+ ["it"]="veroffset",
+ ["nl"]="kopoffset",
+ ["pe"]="آفستعم",
+ ["ro"]="veroffset",
+ },
["vertical"]={
["cs"]="vertikalne",
["de"]="vertikal",
["en"]="vertical",
- ["fr"]="verticale",
+ ["fr"]="vertical",
["it"]="verticale",
["nl"]="vertikaal",
["pe"]="عمودی",
["ro"]="vertical",
},
- ["veroffset"]={
- ["cs"]="offsethlavicky",
- ["de"]="kopfoffset",
- ["en"]="veroffset",
- ["fr"]="veroffset",
- ["it"]="veroffset",
- ["nl"]="kopoffset",
- ["pe"]="آفستعم",
- ["ro"]="veroffset",
+ ["vfactor"]={
+ ["cs"]="vfaktor",
+ ["de"]="vfaktor",
+ ["en"]="vfactor",
+ ["fr"]="facteurv",
+ ["it"]="vfactor",
+ ["nl"]="vfactor",
+ ["ro"]="vfactor",
},
["vfil"]={
["cs"]="vfil",
["de"]="vfil",
["en"]="vfil",
- ["fr"]="vfil",
+ ["fr"]="remplissagev",
["it"]="vfil",
["nl"]="vfil",
["pe"]="vfil",
@@ -11446,12 +12543,13 @@ return {
},
["viewerprefix"]={
["en"]="viewerprefix",
+ ["fr"]="prefixevisualisateur",
},
["voffset"]={
["cs"]="voffset",
["de"]="voffset",
["en"]="voffset",
- ["fr"]="voffset",
+ ["fr"]="decalagev",
["it"]="voffset",
["nl"]="voffset",
["pe"]="آفستع",
@@ -11459,12 +12557,13 @@ return {
},
["vonsep"]={
["en"]="vonsep",
+ ["fr"]="sepvon",
},
["way"]={
["cs"]="zpusob",
["de"]="art",
["en"]="way",
- ["fr"]="mode",
+ ["fr"]="maniere",
["it"]="modo",
["nl"]="wijze",
["pe"]="راه",
@@ -11474,7 +12573,7 @@ return {
["cs"]="sfaktor",
["de"]="bfaktor",
["en"]="wfactor",
- ["fr"]="facteurlargeur",
+ ["fr"]="facteurw",
["it"]="wfactor",
["nl"]="bfactor",
["pe"]="wfactor",
@@ -11502,12 +12601,18 @@ return {
},
["words"]={
["en"]="words",
+ ["fr"]="mots",
+ },
+ ["xanchor"]={
+ ["en"]="xanchor",
+ ["fr"]="ancrex",
+ ["nl"]="xanker",
},
["xfactor"]={
["cs"]="xfaktor",
["de"]="xfaktor",
["en"]="xfactor",
- ["fr"]="xfactor",
+ ["fr"]="facteurx",
["it"]="xfactor",
["nl"]="xfactor",
["pe"]="فاکتورایکس",
@@ -11515,6 +12620,7 @@ return {
},
["xhtml"]={
["en"]="xhtml",
+ ["fr"]="xhtml",
},
["xmax"]={
["cs"]="xmax",
@@ -11528,16 +12634,13 @@ return {
},
["xmlsetup"]={
["en"]="xmlsetup",
- },
- ["xanchor"]={
- ["en"]="xanchor",
- ["nl"]="xanker",
+ ["fr"]="configurationxml",
},
["xoffset"]={
["cs"]="xoffset",
["de"]="xoffset",
["en"]="xoffset",
- ["fr"]="xoffset",
+ ["fr"]="decalagex",
["it"]="xoffset",
["nl"]="xoffset",
["pe"]="آفستایکس",
@@ -11547,7 +12650,7 @@ return {
["cs"]="xmeritko",
["de"]="xformat",
["en"]="xscale",
- ["fr"]="xscale",
+ ["fr"]="echellex",
["it"]="xscale",
["nl"]="xschaal",
["pe"]="مقیاسایکس",
@@ -11557,17 +12660,22 @@ return {
["cs"]="xkrok",
["de"]="xschritt",
["en"]="xstep",
- ["fr"]="xstep",
+ ["fr"]="etapex",
["it"]="xstep",
["nl"]="xstap",
["pe"]="گامایکس",
["ro"]="xstep",
},
+ ["yanchor"]={
+ ["en"]="yanchor",
+ ["fr"]="ancrey",
+ ["nl"]="yanker",
+ },
["yfactor"]={
["cs"]="yfaktor",
["de"]="yfaktor",
["en"]="yfactor",
- ["fr"]="yfactor",
+ ["fr"]="facteury",
["it"]="yfactor",
["nl"]="yfactor",
["pe"]="فاکتوروای",
@@ -11583,15 +12691,11 @@ return {
["pe"]="ymax",
["ro"]="ymax",
},
- ["yanchor"]={
- ["en"]="yanchor",
- ["nl"]="yanker",
- },
["yoffset"]={
["cs"]="yoffset",
["de"]="yoffset",
["en"]="yoffset",
- ["fr"]="yoffset",
+ ["fr"]="decalagey",
["it"]="yoffset",
["nl"]="yoffset",
["pe"]="آفستوای",
@@ -11601,7 +12705,7 @@ return {
["cs"]="ymeritko",
["de"]="yformat",
["en"]="yscale",
- ["fr"]="yscale",
+ ["fr"]="echelley",
["it"]="yscale",
["nl"]="yschaal",
["pe"]="مقیاسوای",
@@ -11611,25 +12715,19 @@ return {
["cs"]="ykrok",
["de"]="yschritt",
["en"]="ystep",
- ["fr"]="ystep",
+ ["fr"]="etapey",
["it"]="ystep",
["nl"]="ystap",
["pe"]="گاموای",
["ro"]="ystep",
},
- ["ownerpassword"]={
- ["en"]="ownerpassword",
- },
- ["userpassword"]={
- ["en"]="userpassword",
- },
},
["elements"]={
["answerlines"]={
["cs"]="answerlines",
["de"]="answerlines",
["en"]="answerlines",
- ["fr"]="answerlines",
+ ["fr"]="lignesreponse",
["it"]="answerlines",
["nl"]="antwoordregels",
["pe"]="answerlines",
@@ -11639,7 +12737,7 @@ return {
["cs"]="answerspace",
["de"]="answerspace",
["en"]="answerspace",
- ["fr"]="answerspace",
+ ["fr"]="espacereponse",
["it"]="answerspace",
["nl"]="antwoordruimte",
["pe"]="answerspace",
@@ -11649,7 +12747,7 @@ return {
["cs"]="zacatek",
["de"]="anfang",
["en"]="begin",
- ["fr"]="debut",
+ ["fr"]="commencer",
["it"]="inizio",
["nl"]="beginvan",
["pe"]="عنصرها",
@@ -11659,7 +12757,7 @@ return {
["cs"]="uplny",
["de"]="vollende",
["en"]="complete",
- ["fr"]="complete",
+ ["fr"]="complet",
["it"]="completo",
["nl"]="volledige",
["pe"]="کامل",
@@ -11689,7 +12787,7 @@ return {
["cs"]="konec",
["de"]="ende",
["en"]="end",
- ["fr"]="fin",
+ ["fr"]="terminer",
["it"]="fine",
["nl"]="eindvan",
["pe"]="انتها",
@@ -11709,7 +12807,7 @@ return {
["cs"]="ziskat",
["de"]="get",
["en"]="get",
- ["fr"]="obtient",
+ ["fr"]="obtenir",
["it"]="prendi",
["nl"]="haal",
["pe"]="بگیر",
@@ -11719,7 +12817,7 @@ return {
["cs"]="zvysit",
["de"]="erhoehen",
["en"]="increment",
- ["fr"]="incremente",
+ ["fr"]="incrementer",
["it"]="incrementa",
["nl"]="verhoog",
["pe"]="افزایش",
@@ -11749,7 +12847,7 @@ return {
["cs"]="nacist",
["de"]="laden",
["en"]="load",
- ["fr"]="charge",
+ ["fr"]="charger",
["it"]="carica",
["nl"]="laad",
["pe"]="بارگذاشتن",
@@ -11769,7 +12867,7 @@ return {
["cs"]="zlom",
["de"]="umbruch",
["en"]="makeup",
- ["fr"]="makeup",
+ ["fr"]="composition",
["it"]="makeup",
["nl"]="opmaak",
["pe"]="آرایش",
@@ -11789,7 +12887,7 @@ return {
["cs"]="umisti",
["de"]="platziere",
["en"]="place",
- ["fr"]="place",
+ ["fr"]="placer",
["it"]="metti",
["nl"]="plaats",
["pe"]="مکان",
@@ -11829,7 +12927,7 @@ return {
["cs"]="viz",
["de"]="sieh",
["en"]="see",
- ["fr"]="voit",
+ ["fr"]="voir",
["it"]="vedi",
["nl"]="zie",
["pe"]="ببینید",
@@ -11839,7 +12937,7 @@ return {
["cs"]="nastaveni",
["de"]="stelle",
["en"]="setup",
- ["fr"]="regle",
+ ["fr"]="configurer",
["it"]="imposta",
["nl"]="stel",
["pe"]="بارگذاری",
@@ -11849,7 +12947,7 @@ return {
["cs"]="start",
["de"]="start",
["en"]="start",
- ["fr"]="demarre",
+ ["fr"]="début",
["it"]="inizia",
["nl"]="start",
["pe"]="شروع",
@@ -11859,7 +12957,7 @@ return {
["cs"]="stop",
["de"]="stop",
["en"]="stop",
- ["fr"]="stoppe",
+ ["fr"]="fin",
["it"]="termina",
["nl"]="stop",
["pe"]="پایان",
@@ -11879,6114 +12977,6414 @@ return {
["cs"]="opis",
["de"]="type",
["en"]="type",
- ["fr"]="type",
+ ["fr"]="transcrire",
["it"]="type",
["nl"]="type",
["pe"]="تایپ",
["ro"]="type",
},
},
- ["variables"]={
- ["aside"]={
- ["en"]="aside",
+ ["setupstrings"]={
+ ["cd:angle-l"]={
+ ["en"]="<<...>>",
},
- ["ordinal"]={
- ["en"]="ordinal",
+ ["cd:angle-s"]={
+ ["en"]="<<...>>",
},
- ["Ordinal"]={
- ["en"]="Ordinal",
+ ["cd:apply-l"]={
+ ["en"]="[..,..=>..,..]",
},
- ["Addition"]={
- ["cs"]="Pridavek",
- ["de"]="Zusatz",
- ["en"]="Addition",
- ["fr"]="Ajout",
- ["it"]="Aggiunta",
- ["nl"]="Toevoeging",
- ["pe"]="جمع",
- ["ro"]="Adaugare",
+ ["cd:apply-s"]={
+ ["en"]="[..=>..]",
},
- ["Alphabetic"]={
- ["en"]="Alphabetic",
+ ["cd:assignment-l"]={
+ ["en"]="[..,..=..,..]",
+ ["lua"]="{ ..,..=..,.. } ",
},
- ["Balloon"]={
- ["cs"]="Bublinka",
- ["de"]="Ballon",
- ["en"]="Balloon",
- ["fr"]="Ballon",
- ["it"]="Pallone",
- ["nl"]="Ballon",
- ["pe"]="بادکنک",
- ["ro"]="Balon",
+ ["cd:assignment-s"]={
+ ["en"]="[..=..]",
+ ["lua"]="{ ..=.. } ",
},
- ["Cap"]={
- ["cs"]="Kap",
- ["de"]="Kap",
- ["en"]="Cap",
- ["fr"]="Cap",
- ["it"]="Cap",
- ["nl"]="Kap",
- ["pe"]="Cap",
- ["ro"]="Cap",
+ ["cd:assignmentbraces-l"]={
+ ["en"]="{..,..=..,..}",
},
- ["Capital"]={
- ["cs"]="Kapitalky",
- ["de"]="Versalien",
- ["en"]="Capital",
- ["fr"]="Capitale",
- ["it"]="Maiuscolo",
- ["nl"]="Kapitaal",
- ["pe"]="Capital",
- ["ro"]="Majuscula",
+ ["cd:assignmentbraces-s"]={
+ ["en"]="{..=..}",
},
- ["Character"]={
- ["cs"]="Pismeno",
- ["de"]="Buchstabe",
- ["en"]="Character",
- ["fr"]="Caratere",
- ["it"]="Lettera",
- ["nl"]="Letter",
- ["pe"]="Character",
- ["ro"]="Caracter",
+ ["cd:assignmentbrackets-l"]={
+ ["en"]="[..,..=..,..]",
+ ["lua"]="{ ..,..=..,.. } ",
},
- ["Characters"]={
- ["cs"]="Pismena",
- ["de"]="Buchstaben",
- ["en"]="Characters",
- ["fr"]="Caracteres",
- ["it"]="Lettere",
- ["nl"]="Letters",
- ["pe"]="Characters",
- ["ro"]="Caractere",
+ ["cd:assignmentbrackets-s"]={
+ ["en"]="[..=..]",
+ ["lua"]="{ ..=.. } ",
},
- ["CloseDocument"]={
- ["cs"]="ZavritDokument",
- ["de"]="SchliesseDokument",
- ["en"]="CloseDocument",
- ["fr"]="FermeDocument",
- ["it"]="ChiudiDocumento",
- ["nl"]="SluitDocument",
- ["pe"]="بستننوشتار",
- ["ro"]="InchideDocument",
+ ["cd:assignmentparentheses-l"]={
+ ["en"]="(..,..=..,..)",
},
- ["ExitViewer"]={
- ["cs"]="UkoncitProhlizec",
- ["de"]="BeendeViewer",
- ["en"]="ExitViewer",
- ["fr"]="SortVisualisateur",
- ["it"]="EsciVisualizzatore",
- ["nl"]="VerlaatViewer",
- ["pe"]="خروجنمایشگر",
- ["ro"]="IesireVizualizator",
+ ["cd:assignmentparentheses-s"]={
+ ["en"]="(..=..)",
},
- ["FirstPage"]={
- ["cs"]="PrvniStrana",
- ["de"]="ErsteSeite",
- ["en"]="FirstPage",
- ["fr"]="PremierePage",
- ["it"]="PrimaPagina",
- ["nl"]="EerstePagina",
- ["pe"]="صفحهاول",
- ["ro"]="PrimaPagina",
+ ["cd:braces-l"]={
+ ["en"]="{...,...}",
+ ["lua"]=".. ... ..",
},
- ["FitHeight"]={
- ["cs"]="FitHeight",
- ["de"]="HoehePassend",
- ["en"]="FitHeight",
- ["fr"]="AjusteHauteur",
- ["it"]="FitHeight",
- ["nl"]="HoogtePassend",
- ["pe"]="پرکردنارتفاع",
- ["ro"]="AjustatInaltime",
+ ["cd:braces-s"]={
+ ["en"]="{...}",
+ ["lua"]="\"...\"",
},
- ["FitWidth"]={
- ["cs"]="FitWidth",
- ["de"]="BreitePassend",
- ["en"]="FitWidth",
- ["fr"]="AjusteLargeur",
- ["it"]="FitWidth",
- ["nl"]="BreedtePassend",
- ["pe"]="پرکردنعرض",
- ["ro"]="AjustatLatime",
+ ["cd:brackets-l"]={
+ ["en"]="[...,...]",
+ ["lua"]="{..., ...}",
},
- ["GotoPage"]={
- ["cs"]="JdiNaStranku",
- ["de"]="GotoPage",
- ["en"]="GotoPage",
- ["fr"]="VaalaPage",
- ["it"]="VaiAPagina",
- ["nl"]="GaNaarPagina",
- ["pe"]="بروبهصفحه",
- ["ro"]="LaPagina",
+ ["cd:brackets-s"]={
+ ["en"]="[...]",
+ ["lua"]="{ ... }",
},
- ["Greek"]={
- ["cs"]="Recky",
- ["de"]="Griechisch",
- ["en"]="Greek",
- ["fr"]="Grec",
- ["it"]="Greco",
- ["nl"]="Grieks",
- ["pe"]="یونانی",
- ["ro"]="Grec",
+ ["cd:buffer"]={
+ ["cs"]="buffer",
+ ["de"]="buffer",
+ ["en"]="buffer",
+ ["fr"]="tampon",
+ ["it"]="buffer",
+ ["nl"]="buffer",
+ ["ro"]="buffer",
},
- ["Help"]={
- ["cs"]="Napoveda",
- ["de"]="Hilfe",
- ["en"]="Help",
- ["fr"]="Aide",
- ["it"]="Aiuto",
- ["nl"]="Help",
- ["pe"]="کمک",
- ["ro"]="Ajutor",
+ ["cd:case-l"]={
+ ["en"]="\\case ",
},
- ["HideField"]={
- ["cs"]="SkryjPole",
- ["de"]="VerbergeFeld",
- ["en"]="HideField",
- ["fr"]="CacheChamp",
- ["it"]="NascondiCampo",
- ["nl"]="VerbergVeld",
- ["pe"]="پنهانمیدان",
- ["ro"]="AscundeCamp",
+ ["cd:case-s"]={
+ ["en"]="\\case ",
},
- ["HideLayer"]={
- ["cs"]="HideLayer",
- ["de"]="HideLayer",
- ["en"]="HideLayer",
- ["fr"]="CacheCalque",
- ["it"]="HideLayer",
- ["nl"]="VerbergLaag",
- ["pe"]="پنهانلایه",
- ["ro"]="HideLayer",
+ ["cd:category"]={
+ ["cs"]="category",
+ ["de"]="category",
+ ["en"]="category",
+ ["fr"]="categorie",
+ ["it"]="category",
+ ["nl"]="category",
+ ["ro"]="category",
},
- ["Key"]={
- ["cs"]="Klavesa",
- ["de"]="Schluessel",
- ["en"]="Key",
- ["fr"]="Cle",
- ["it"]="Tasto",
- ["nl"]="Sleutel",
- ["pe"]="کلید",
- ["ro"]="Cheie",
+ ["cd:character"]={
+ ["cs"]="character",
+ ["de"]="character",
+ ["en"]="character",
+ ["fr"]="caractere",
+ ["it"]="character",
+ ["nl"]="karakter",
+ ["ro"]="character",
},
- ["LastPage"]={
- ["cs"]="PosledniStrana",
- ["de"]="LetzteSeite",
- ["en"]="LastPage",
- ["fr"]="DernierePage",
- ["it"]="UltimaPagina",
- ["nl"]="LaatstePagina",
- ["pe"]="صفحهآخر",
- ["ro"]="UltimaPagina",
+ ["cd:color"]={
+ ["cs"]="color",
+ ["de"]="color",
+ ["en"]="color",
+ ["fr"]="couleur",
+ ["it"]="color",
+ ["nl"]="kleur",
+ ["ro"]="color",
},
- ["LoadForm"]={
- ["cs"]="NacistFormular",
- ["de"]="LadeFormular",
- ["en"]="LoadForm",
- ["fr"]="ChargeForm",
- ["it"]="CaricaForm",
- ["nl"]="LaadFormulier",
- ["pe"]="بارگذاشتنفرم",
- ["ro"]="IncarcaFormular",
+ ["cd:column"]={
+ ["cs"]="column",
+ ["de"]="column",
+ ["en"]="column",
+ ["fr"]="colonne",
+ ["it"]="column",
+ ["nl"]="kolom",
+ ["ro"]="column",
},
- ["MONTH"]={
- ["cs"]="MESIC",
- ["de"]="MONAT",
- ["en"]="MONTH",
- ["fr"]="MOIS",
- ["it"]="MESE",
- ["nl"]="MAAND",
- ["pe"]="ماه",
- ["ro"]="LUNA",
+ ["cd:command"]={
+ ["cs"]="Befehl",
+ ["de"]="Befehl",
+ ["en"]="command",
+ ["fr"]="commande",
+ ["it"]="Befehl",
+ ["nl"]="commando",
+ ["ro"]="Befehl",
},
- ["New"]={
- ["cs"]="Novy",
- ["de"]="Neu",
- ["en"]="New",
- ["fr"]="Nouveau",
- ["it"]="Nuovo",
- ["nl"]="Nieuw",
- ["pe"]="جدید",
- ["ro"]="Nou",
+ ["cd:content"]={
+ ["cs"]="content",
+ ["de"]="content",
+ ["en"]="content",
+ ["fr"]="contenu",
+ ["it"]="content",
+ ["nl"]="inhoud",
+ ["ro"]="content",
},
- ["NextJump"]={
- ["cs"]="NasledujiciSkok",
- ["de"]="NaechsterSprung",
- ["en"]="NextJump",
- ["fr"]="SautSuivant",
- ["it"]="SaltoSuccessivo",
- ["nl"]="VolgendeSprong",
- ["pe"]="پرشبعدی",
- ["ro"]="SaltUrmator",
+ ["cd:content-l"]={
+ ["en"]="{.. ... ..}",
+ ["lua"]="\".. ... ..\"",
},
- ["NextPage"]={
- ["cs"]="DalsiStrana",
- ["de"]="FolgendeSeite",
- ["en"]="NextPage",
- ["fr"]="PageSuivante",
- ["it"]="PaginaSuccessiva",
- ["nl"]="VolgendePagina",
- ["pe"]="صفحهبعدی",
- ["ro"]="PaginaUrmatoare",
+ ["cd:content-s"]={
+ ["en"]="{...}",
+ ["lua"]="\"...\"",
},
- ["Numbers"]={
- ["cs"]="Cisla",
- ["de"]="Ziffern",
- ["en"]="Numbers",
- ["fr"]="Numeros",
- ["it"]="Numeri",
- ["nl"]="Cijfers",
- ["pe"]="شمارهها",
- ["ro"]="Numere",
+ ["cd:csname"]={
+ ["cs"]="csname",
+ ["de"]="csname",
+ ["en"]="csname",
+ ["fr"]="nomsc",
+ ["it"]="csname",
+ ["nl"]="naam",
+ ["ro"]="csname",
},
- ["OpenNamedDocument"]={
- ["cs"]="OpenNamedDocument",
- ["de"]="OpenNamedDocument",
- ["en"]="OpenNamedDocument",
- ["fr"]="OuvreDocumentNomme",
- ["it"]="OpenNamedDocument",
- ["nl"]="OpenDocumentOpNaam",
- ["pe"]="بازکردننوشتارذخیرهشده",
- ["ro"]="OpenNamedDocument",
+ ["cd:csname-l"]={
+ ["en"]="\\...",
},
- ["Paragraph"]={
- ["cs"]="Odstavec",
- ["de"]="Absatz",
- ["en"]="Paragraph",
- ["fr"]="Paragraphe",
- ["it"]="Capoverso",
- ["nl"]="Paragraaf",
- ["pe"]="پاراگراف",
- ["ro"]="Paragraf",
+ ["cd:csname-s"]={
+ ["en"]="\\...",
},
- ["PauseMovie"]={
- ["cs"]="PozastavitFilm",
- ["de"]="PauseFilm",
- ["en"]="PauseMovie",
- ["fr"]="PauseFilm",
- ["it"]="PausaFilm",
- ["nl"]="PauzeerFilm",
- ["pe"]="ایستفیلم",
- ["ro"]="PauzaFilm",
+ ["cd:delimiter"]={
+ ["cs"]="delimiter",
+ ["de"]="delimiter",
+ ["en"]="delimiter",
+ ["fr"]="delimiteur",
+ ["it"]="delimiter",
+ ["nl"]="delimiter",
+ ["ro"]="delimiter",
},
- ["PauseRendering"]={
- ["cs"]="PauseRendering",
- ["de"]="PauseRendering",
- ["en"]="PauseRendering",
- ["fr"]="PauseRendering",
- ["it"]="PauseRendering",
- ["nl"]="PauzeerRendering",
- ["pe"]="توقفتعبیر",
- ["ro"]="PauseRendering",
+ ["cd:destination"]={
+ ["cs"]="destination",
+ ["de"]="destination",
+ ["en"]="destination",
+ ["fr"]="destination",
+ ["it"]="destination",
+ ["nl"]="bestemming",
+ ["ro"]="destination",
},
- ["PauseSound"]={
- ["cs"]="PozastavitZvuk",
- ["de"]="PauseSound",
- ["en"]="PauseSound",
- ["fr"]="PauseSon",
- ["it"]="PausaSuono",
- ["nl"]="PauzeerGeluid",
- ["pe"]="ایستصدا",
- ["ro"]="PauzaSunet",
+ ["cd:destination-l"]={
+ ["en"]="[..,{..[ref,..]},..]",
},
- ["PreviousJump"]={
- ["cs"]="PredchoziSkok",
- ["de"]="VorigerSprung",
- ["en"]="PreviousJump",
- ["fr"]="SautPrecedent",
- ["it"]="SaltoPrecedente",
- ["nl"]="VorigeSprong",
- ["pe"]="پرشقبلی",
- ["ro"]="SaltPrecedent",
+ ["cd:destination-s"]={
+ ["en"]="[{..[ref]}]",
},
- ["PreviousPage"]={
- ["cs"]="PredchoziStrana",
- ["de"]="VorigeSeite",
- ["en"]="PreviousPage",
- ["fr"]="PagePrecedente",
- ["it"]="PaginaPrecedente",
- ["nl"]="VorigePagina",
- ["pe"]="صفحهقبلی",
- ["ro"]="PaginaPrecedenta",
+ ["cd:dimension"]={
+ ["cs"]="Dimension",
+ ["de"]="Dimension",
+ ["en"]="dimension",
+ ["fr"]="dimension",
+ ["it"]="Dimension",
+ ["nl"]="maat",
+ ["ro"]="Dimension",
},
- ["PrintDocument"]={
- ["cs"]="VytisknoutDokument",
- ["de"]="DruckeDokument",
- ["en"]="PrintDocument",
- ["fr"]="ImprimeDocument",
- ["it"]="StampaDocumento",
- ["nl"]="PrintDocument",
- ["pe"]="چاپنوشتار",
- ["ro"]="TiparesteDocument",
+ ["cd:displaymath"]={
+ ["cs"]="formula",
+ ["de"]="formula",
+ ["en"]="formula",
+ ["fr"]="affichemath",
+ ["it"]="formula",
+ ["nl"]="formule",
+ ["ro"]="formula",
},
- ["Query"]={
- ["cs"]="Query",
- ["de"]="Query",
- ["en"]="Query",
- ["fr"]="Query",
- ["it"]="Richiesta",
- ["nl"]="RaadpleegDocument",
- ["pe"]="پرسش",
- ["ro"]="Query",
+ ["cd:displaymath-l"]={
+ ["en"]="$$...$$",
},
- ["QueryAgain"]={
- ["cs"]="QueryAgain",
- ["de"]="QueryAgain",
- ["en"]="QueryAgain",
- ["fr"]="QueryAgain",
- ["it"]="RinnovaRichiesta",
- ["nl"]="HerhaalRaadplegen",
- ["pe"]="پرسشدوباره",
- ["ro"]="QueryAgain",
+ ["cd:displaymath-s"]={
+ ["en"]="$$...$$",
},
- ["ResetForm"]={
- ["cs"]="ResetFormulare",
- ["de"]="ZuruecksetzenFormular",
- ["en"]="ResetForm",
- ["fr"]="RazForm",
- ["it"]="ReimpostaForm",
- ["nl"]="ResetFormulier",
- ["pe"]="دوبارهنشانیفرم",
- ["ro"]="ResetareFormular",
+ ["cd:else-l"]={
+ ["en"]="\\else ",
},
- ["ResumeMovie"]={
- ["cs"]="PokracovatFilm",
- ["de"]="FortsetzenFilm",
- ["en"]="ResumeMovie",
- ["fr"]="ReprendFilm",
- ["it"]="RiprendiFilm",
- ["nl"]="HervatFilm",
- ["pe"]="ادامهفیلم",
- ["ro"]="RepornesteFilm",
+ ["cd:else-s"]={
+ ["en"]="\\else ",
},
- ["ResumeRendering"]={
- ["cs"]="ResumeRendering",
- ["de"]="ResumeRendering",
- ["en"]="ResumeRendering",
- ["fr"]="ResumeRendering",
- ["it"]="ResumeRendering",
- ["nl"]="HervatRendering",
- ["pe"]="ادامهتعبیر",
- ["ro"]="ResumeRendering",
+ ["cd:false"]={
+ ["cs"]="false",
+ ["de"]="false",
+ ["en"]="false",
+ ["fr"]="faux",
+ ["it"]="false",
+ ["nl"]="false",
+ ["ro"]="false",
},
- ["ResumeSound"]={
- ["cs"]="PokracovatZvuk",
- ["de"]="ResumeSound",
- ["en"]="ResumeSound",
- ["fr"]="ReprendSon",
- ["it"]="RiprendiSuono",
- ["nl"]="HervatGeluid",
- ["pe"]="ادامهصدا",
- ["ro"]="RepornesteSunet",
+ ["cd:fi-l"]={
+ ["en"]="\\fi ",
},
- ["Romannumerals"]={
- ["cs"]="Rimskecislice",
- ["de"]="Roemischezahlen",
- ["en"]="Romannumerals",
- ["fr"]="Chiffresromains",
- ["it"]="Numeriromani",
- ["nl"]="Romeins",
- ["pe"]="اعدادبزرگلاتین",
- ["ro"]="Numereromane",
+ ["cd:fi-s"]={
+ ["en"]="\\fi ",
},
- ["SaveDocument"]={
- ["cs"]="UlozitDokument",
- ["de"]="SpeichereDokument",
- ["en"]="SaveDocument",
- ["fr"]="SauvegardeDocument",
- ["it"]="SalvaDocumento",
- ["nl"]="BewaarDocument",
- ["pe"]="ذخیرهنوشتار",
- ["ro"]="SalvareDocument",
+ ["cd:file"]={
+ ["cs"]="file",
+ ["de"]="file",
+ ["en"]="file",
+ ["fr"]="fichier",
+ ["it"]="file",
+ ["nl"]="file",
+ ["ro"]="file",
},
- ["SaveForm"]={
- ["cs"]="UlozitFormular",
- ["de"]="SpeicheFormular",
- ["en"]="SaveForm",
- ["fr"]="SauvegardeForm",
- ["it"]="SalvaForm",
- ["nl"]="BewaarFormulier",
- ["pe"]="ذخیرهفرم",
- ["ro"]="SalveazaFormular",
+ ["cd:file-l"]={
+ ["en"]=" ... ",
},
- ["SaveNamedDocument"]={
- ["cs"]="SaveNamedDocument",
- ["de"]="SaveNamedDocument",
- ["en"]="SaveNamedDocument",
- ["fr"]="SauvegardeDocumentNomme",
- ["it"]="SaveNamedDocument",
- ["nl"]="BewaarDocumentOpNaam",
- ["pe"]="ذخیرهنوشتاربانام",
- ["ro"]="SaveNamedDocument",
+ ["cd:file-s"]={
+ ["en"]=" ... ",
},
- ["SearchAgain"]={
- ["cs"]="HledatZnovu",
- ["de"]="WeiterSuchen",
- ["en"]="SearchAgain",
- ["fr"]="RechercheSuivant",
- ["it"]="CercaAncora",
- ["nl"]="HerhaalZoeken",
- ["pe"]="جستجویدوباره",
- ["ro"]="CautaDinNou",
+ ["cd:first"]={
+ ["cs"]="first",
+ ["de"]="first",
+ ["en"]="first",
+ ["fr"]="premier",
+ ["it"]="first",
+ ["nl"]="eerste",
+ ["ro"]="first",
},
- ["SearchDocument"]={
- ["cs"]="ProhledatDokument",
- ["de"]="DokumentDurchsuchen",
- ["en"]="SearchDocument",
- ["fr"]="RechercheDocument",
- ["it"]="CercaDocumento",
- ["nl"]="DoorzoekDocument",
- ["pe"]="جستجوینوشتار",
- ["ro"]="CautaDocument",
+ ["cd:font"]={
+ ["cs"]="font",
+ ["de"]="font",
+ ["en"]="font",
+ ["fr"]="police",
+ ["it"]="font",
+ ["nl"]="font",
+ ["ro"]="font",
},
- ["ShowBookmarks"]={
- ["cs"]="UkazZalozky",
- ["de"]="ShowBookmarks",
- ["en"]="ShowBookmarks",
- ["fr"]="ShowBookmarks",
- ["it"]="MostraSegnalibro",
- ["nl"]="ShowBookmarks",
- ["pe"]="نمایشچوبخط",
- ["ro"]="ShowBookmarks",
+ ["cd:formula"]={
+ ["cs"]="Formel",
+ ["de"]="Formel",
+ ["en"]="formula",
+ ["fr"]="formule",
+ ["it"]="Formel",
+ ["nl"]="formule",
+ ["ro"]="Formel",
},
- ["ShowField"]={
- ["cs"]="UkazPole",
- ["de"]="ZeigeFeld",
- ["en"]="ShowField",
- ["fr"]="MontreChamp",
- ["it"]="MostraCampo",
- ["nl"]="ToonVeld",
- ["pe"]="نمایشمیدان",
- ["ro"]="AfiseazaCamp",
+ ["cd:identifier"]={
+ ["cs"]="Name",
+ ["de"]="Name",
+ ["en"]="identifier",
+ ["fr"]="identifiant",
+ ["it"]="Name",
+ ["nl"]="naam",
+ ["ro"]="Name",
},
- ["ShowThumbs"]={
- ["cs"]="UkazNahledy",
- ["de"]="ShowThumbs",
- ["en"]="ShowThumbs",
- ["fr"]="ShowThumbs",
- ["it"]="MostraThumbs",
- ["nl"]="ShowThumbs",
- ["pe"]="نمایششصت",
- ["ro"]="ShowThumbs",
+ ["cd:if-l"]={
+ ["en"]="\\if... ",
},
- ["StartMovie"]={
- ["cs"]="SpustitFilm",
- ["de"]="StartFilm",
- ["en"]="StartMovie",
- ["fr"]="DemarreFilm",
- ["it"]="IniziaFilm",
- ["nl"]="StartFilm",
- ["pe"]="شروعفیلم",
- ["ro"]="StartFilm",
+ ["cd:if-s"]={
+ ["en"]="\\if... ",
},
- ["StartRendering"]={
- ["cs"]="StartRendering",
- ["de"]="StartRendering",
- ["en"]="StartRendering",
- ["fr"]="StartRendering",
- ["it"]="StartRendering",
- ["nl"]="StartRendering",
- ["pe"]="شروعتعبیر",
- ["ro"]="StartRendering",
+ ["cd:index"]={
+ ["cs"]="entry",
+ ["de"]="entry",
+ ["en"]="entry",
+ ["fr"]="index",
+ ["it"]="entry",
+ ["nl"]="ingang",
+ ["ro"]="entry",
},
- ["StartSound"]={
- ["cs"]="StartZvuk",
- ["de"]="StartSound",
- ["en"]="StartSound",
- ["fr"]="DemarreSon",
- ["it"]="IniziaSuono",
- ["nl"]="StartGeluid",
- ["pe"]="شروعصدا",
- ["ro"]="StartSunet",
+ ["cd:index-l"]={
+ ["en"]="{..+...+..}",
},
- ["StopMovie"]={
- ["cs"]="ZastavitFilm",
- ["de"]="StopFilm",
- ["en"]="StopMovie",
- ["fr"]="StoppeFilm",
- ["it"]="FermaFilm",
- ["nl"]="StopFilm",
- ["pe"]="پایانفیلم",
- ["ro"]="StopFilm",
+ ["cd:index-s"]={
+ ["en"]="{...}",
},
- ["StopRendering"]={
- ["cs"]="StopRendering",
- ["de"]="StopRendering",
- ["en"]="StopRendering",
- ["fr"]="StopRendering",
- ["it"]="StopRendering",
- ["nl"]="StopRendering",
- ["pe"]="پایانتعبیر",
- ["ro"]="StopRendering",
+ ["cd:inherits"]={
+ ["cs"]="inherits",
+ ["de"]="inherits",
+ ["en"]="inherits",
+ ["fr"]="heritede",
+ ["it"]="inherits",
+ ["nl"]="erft",
+ ["ro"]="inherits",
},
- ["StopSound"]={
- ["cs"]="StopZvuk",
- ["de"]="StopSound",
- ["en"]="StopSound",
- ["fr"]="StoppeSon",
- ["it"]="FermaSuono",
- ["nl"]="StopGeluid",
- ["pe"]="پایانصدا",
- ["ro"]="StopSunet",
+ ["cd:inlinemath-l"]={
+ ["en"]="$...$",
},
- ["SubmitForm"]={
- ["cs"]="PoslatFormular",
- ["de"]="VersendeFormular",
- ["en"]="SubmitForm",
- ["fr"]="SoumettreForm",
- ["it"]="MandaForm",
- ["nl"]="VerzendFormulier",
- ["pe"]="تسلیمفرم",
- ["ro"]="TrimiteFormular",
+ ["cd:inlinemath-s"]={
+ ["en"]="$...$",
},
- ["ToggleLayer"]={
- ["cs"]="ToggleLayer",
- ["de"]="ToggleLayer",
- ["en"]="ToggleLayer",
- ["fr"]="ToggleLayer",
- ["it"]="ToggleLayer",
- ["nl"]="WisselLaag",
- ["pe"]="تغییرلایه",
- ["ro"]="ToggleLayer",
+ ["cd:key"]={
+ ["cs"]="key",
+ ["de"]="key",
+ ["en"]="key",
+ ["fr"]="cle",
+ ["it"]="key",
+ ["nl"]="parameter",
+ ["ro"]="key",
},
- ["ToggleViewer"]={
- ["cs"]="ZmenitProhlizec",
- ["de"]="WechseleViewer",
- ["en"]="ToggleViewer",
- ["fr"]="ChangeVisualisateur",
- ["it"]="ScambiaVisualizzatore",
- ["nl"]="WisselViewer",
- ["pe"]="تغییرنمایشگر",
- ["ro"]="SchimbaVizualizator",
+ ["cd:language"]={
+ ["cs"]="sprache",
+ ["de"]="sprache",
+ ["en"]="language",
+ ["fr"]="langage",
+ ["it"]="sprache",
+ ["nl"]="taal",
+ ["ro"]="sprache",
},
- ["URL"]={
- ["cs"]="URL",
- ["de"]="URL",
- ["en"]="URL",
- ["fr"]="URL",
- ["it"]="URL",
- ["nl"]="URL",
- ["pe"]="URL",
- ["ro"]="URL",
+ ["cd:last"]={
+ ["cs"]="last",
+ ["de"]="last",
+ ["en"]="last",
+ ["fr"]="dernier",
+ ["it"]="last",
+ ["nl"]="laatste",
+ ["ro"]="last",
},
- ["VideLayer"]={
- ["cs"]="VideLayer",
- ["de"]="VideLayer",
- ["en"]="VideLayer",
- ["fr"]="VideLayer",
- ["it"]="VideLayer",
- ["nl"]="ToonLaag",
- ["pe"]="VideLayer",
- ["ro"]="VideLayer",
+ ["cd:list"]={
+ ["cs"]="Liste",
+ ["de"]="Liste",
+ ["en"]="list",
+ ["fr"]="liste",
+ ["it"]="Liste",
+ ["nl"]="lijst",
+ ["ro"]="Liste",
},
- ["ViewerHelp"]={
- ["cs"]="NapovedaProhlizece",
- ["de"]="ViewerHilfe",
- ["en"]="ViewerHelp",
- ["fr"]="AideVisualisateur",
- ["it"]="AiutoVisualizzatore",
- ["nl"]="ViewerHelp",
- ["pe"]="کمکنمایشگر",
- ["ro"]="AjutorVizualizator",
+ ["cd:lpath"]={
+ ["cs"]="lpath",
+ ["de"]="lpath",
+ ["en"]="lpath",
+ ["fr"]="cheminl",
+ ["it"]="lpath",
+ ["nl"]="lpath",
+ ["ro"]="lpath",
},
- ["WEEKDAY"]={
- ["cs"]="VSEDNIDEN",
- ["de"]="WOCHENTAG",
- ["en"]="WEEKDAY",
- ["fr"]="JOURSEMAINE",
- ["it"]="GIORNOSETTIMANA",
- ["nl"]="WEEKDAG",
- ["pe"]="روزهفته",
- ["ro"]="ZISAPTAMANA",
+ ["cd:luafunction"]={
+ ["cs"]="luafunction",
+ ["de"]="luafunction",
+ ["en"]="luafunction",
+ ["fr"]="fonctionlua",
+ ["it"]="luafunction",
+ ["nl"]="luafunction",
+ ["ro"]="luafunction",
},
- ["WORD"]={
- ["cs"]="SLOVO",
- ["de"]="WORT",
- ["en"]="WORD",
- ["fr"]="MOT",
- ["it"]="PAROLA",
- ["nl"]="WOORD",
- ["pe"]="کلمه",
- ["ro"]="CUVANT",
+ ["cd:macro-l"]={
+ ["en"]="\\... ",
},
- ["WORDS"]={
- ["cs"]="SLOVA",
- ["de"]="WOERTER",
- ["en"]="WORDS",
- ["fr"]="MOTS",
- ["it"]="PAROLE",
- ["nl"]="WOORDEN",
- ["pe"]="WORDS",
- ["ro"]="CUVINTE",
+ ["cd:macro-s"]={
+ ["en"]="\\... ",
},
- ["Word"]={
- ["cs"]="Slovo",
- ["de"]="Wort",
- ["en"]="Word",
- ["fr"]="Mot",
- ["it"]="Parola",
- ["nl"]="Woord",
- ["pe"]="Word",
- ["ro"]="Cuvant",
+ ["cd:mark"]={
+ ["cs"]="Beschriftung",
+ ["de"]="Beschriftung",
+ ["en"]="mark",
+ ["fr"]="marque",
+ ["it"]="Beschriftung",
+ ["nl"]="markering",
+ ["ro"]="Beschriftung",
},
- ["Words"]={
- ["cs"]="Slova",
- ["de"]="Woerter",
- ["en"]="Words",
- ["fr"]="Mots",
- ["it"]="Parole",
- ["nl"]="Woorden",
- ["pe"]="Words",
- ["ro"]="Cuvinte",
+ ["cd:marking"]={
+ ["cs"]="marking",
+ ["de"]="marking",
+ ["en"]="marking",
+ ["fr"]="marquage",
+ ["it"]="marking",
+ ["nl"]="markering",
+ ["ro"]="marking",
},
- ["abbreviation"]={
- ["cs"]="zkratka",
- ["de"]="abkuerzung",
- ["en"]="abbreviation",
- ["fr"]="abreviation",
- ["it"]="abbreviazione",
- ["nl"]="afkorting",
- ["pe"]="اختصار",
- ["ro"]="abreviere",
+ ["cd:math"]={
+ ["cs"]="formula",
+ ["de"]="formula",
+ ["en"]="formula",
+ ["fr"]="math",
+ ["it"]="formula",
+ ["nl"]="formule",
+ ["ro"]="formula",
},
- ["abbreviations"]={
- ["cs"]="zkratky",
- ["de"]="abkuerzungen",
- ["en"]="abbreviations",
- ["fr"]="abreviations",
- ["it"]="abbreviazioni",
- ["nl"]="afkortingen",
- ["pe"]="اختصارات",
- ["ro"]="abrevieri",
+ ["cd:math-l"]={
+ ["en"]="$...$",
},
- ["absolute"]={
- ["cs"]="absolutni",
- ["de"]="absolut",
- ["en"]="absolute",
- ["fr"]="absolute",
- ["it"]="assoluto",
- ["nl"]="absoluut",
- ["pe"]="قطعی",
- ["ro"]="absolut",
+ ["cd:math-s"]={
+ ["en"]="$...$",
},
- ["anchor"]={
- ["en"]="anchor",
- ["nl"]="anker",
+ ["cd:matrix"]={
+ ["cs"]="n*m",
+ ["de"]="n*m",
+ ["en"]="n*m",
+ ["fr"]="matrice",
+ ["it"]="n*m",
+ ["nl"]="n*m",
+ ["ro"]="n*m",
},
- ["action"]={
- ["cs"]="akce",
- ["de"]="aktion",
- ["en"]="action",
- ["fr"]="action",
- ["it"]="azione",
- ["nl"]="actie",
- ["pe"]="کنش",
- ["ro"]="actiune",
+ ["cd:name"]={
+ ["cs"]="Name",
+ ["de"]="Name",
+ ["en"]="name",
+ ["fr"]="nom",
+ ["it"]="Name",
+ ["nl"]="naam",
+ ["ro"]="Name",
},
- ["after"]={
- ["cs"]="po",
- ["de"]="nach",
- ["en"]="after",
- ["fr"]="apres",
- ["it"]="dopo",
- ["nl"]="na",
- ["pe"]="بعداز",
- ["ro"]="dupa",
+ ["cd:noargument-l"]={
+ ["en"]="\\...",
},
- ["all"]={
- ["cs"]="vse",
- ["de"]="alles",
- ["en"]="all",
- ["fr"]="tout",
- ["it"]="tutti",
- ["nl"]="alles",
- ["pe"]="همه",
- ["ro"]="tot",
+ ["cd:noargument-s"]={
+ ["en"]="\\...",
},
- ["alphabetic"]={
- ["en"]="alphabetic",
+ ["cd:node"]={
+ ["cs"]="node",
+ ["de"]="node",
+ ["en"]="node",
+ ["fr"]="noeud",
+ ["it"]="node",
+ ["nl"]="node",
+ ["ro"]="node",
},
- ["always"]={
- ["cs"]="vzdy",
- ["de"]="immer",
- ["en"]="always",
- ["fr"]="toujours",
- ["it"]="sempre",
- ["nl"]="altijd",
- ["pe"]="همواره",
- ["ro"]="totdeauna",
+ ["cd:none-l"]={
+ ["en"]=".. ... ..",
},
- ["and"]={
- ["de"]="und",
- ["en"]="and",
- ["nl"]="en",
+ ["cd:none-s"]={
+ ["en"]="...",
},
- ["answerarea"]={
- ["cs"]="answerarea",
- ["de"]="answerarea",
- ["en"]="answerarea",
- ["fr"]="answerarea",
- ["it"]="answerarea",
- ["nl"]="antwoordgebied",
- ["pe"]="answerarea",
- ["ro"]="answerarea",
+ ["cd:nothing"]={
+ ["cs"]="empty",
+ ["de"]="empty",
+ ["en"]="empty",
+ ["fr"]="rien",
+ ["it"]="empty",
+ ["nl"]="leeg",
+ ["ro"]="empty",
},
- ["appendices"]={
- ["cs"]="dodatky",
- ["de"]="anhaenge",
- ["en"]="appendices",
- ["fr"]="annexes",
- ["it"]="appendici",
- ["nl"]="bijlagen",
- ["pe"]="پیوستها",
- ["ro"]="apendixuri",
+ ["cd:nothing-l"]={
+ ["en"]="...",
},
- ["appendix"]={
- ["cs"]="dodatek",
- ["de"]="anhang",
- ["en"]="appendix",
- ["fr"]="annexe",
- ["it"]="appendice",
- ["nl"]="bijlage",
- ["pe"]="پیوست",
- ["ro"]="apendix",
+ ["cd:nothing-s"]={
+ ["en"]="...",
},
- ["april"]={
- ["cs"]="duben",
- ["de"]="april",
- ["en"]="april",
- ["fr"]="avril",
- ["it"]="aprile",
- ["nl"]="april",
- ["pe"]="آوریل",
- ["ro"]="aprilie",
+ ["cd:number"]={
+ ["cs"]="Nummer",
+ ["de"]="Nummer",
+ ["en"]="number",
+ ["fr"]="nombre",
+ ["it"]="Nummer",
+ ["nl"]="getal",
+ ["ro"]="Nummer",
},
- ["atleftmargin"]={
- ["cs"]="atleftmargin",
- ["de"]="atleftmargin",
- ["en"]="atleftmargin",
- ["fr"]="atleftmargin",
- ["it"]="atleftmargin",
- ["nl"]="oplinkermarge",
- ["pe"]="درحاشیهچپ",
- ["ro"]="atleftmargin",
+ ["cd:oneargument"]={
+ ["en"]="\\...#1",
},
- ["atmargin"]={
- ["cs"]="naokraji",
- ["de"]="amrand",
- ["en"]="atmargin",
- ["fr"]="alamarge",
- ["it"]="almargine",
- ["nl"]="opmarge",
- ["pe"]="درحاشیه",
- ["ro"]="lamargine",
+ ["cd:optional"]={
+ ["cs"]="opt",
+ ["de"]="opt",
+ ["en"]="opt",
+ ["fr"]="optionnel",
+ ["it"]="opt",
+ ["nl"]="opt",
+ ["ro"]="opt",
},
- ["atpage"]={
- ["cs"]="nastrance",
- ["de"]="aufseite",
- ["en"]="atpage",
- ["fr"]="alapage",
- ["it"]="apagina",
- ["nl"]="oppagina",
- ["pe"]="درصفحه",
- ["ro"]="lapagina",
+ ["cd:or-l"]={
+ ["en"]="\\or ",
},
- ["atrightmargin"]={
- ["cs"]="atrightmargin",
- ["de"]="atrightmargin",
- ["en"]="atrightmargin",
- ["fr"]="atrightmargin",
- ["it"]="atrightmargin",
- ["nl"]="oprechtermarge",
- ["pe"]="درحاشیهراست",
- ["ro"]="atrightmargin",
+ ["cd:or-s"]={
+ ["en"]="\\or ",
},
- ["attachment"]={
- ["en"]="attachment",
- ["nl"]="aanhangsel",
+ ["cd:par-l"]={
+ ["en"]="\\par ",
},
- ["august"]={
- ["cs"]="srpen",
- ["de"]="august",
- ["en"]="august",
- ["fr"]="août",
- ["it"]="agosto",
- ["nl"]="augustus",
- ["pe"]="آگوست",
- ["ro"]="august",
+ ["cd:par-s"]={
+ ["en"]="\\par ",
},
- ["author"]={
- ["cs"]="autor",
- ["de"]="autor",
- ["en"]="author",
- ["fr"]="auteur",
- ["it"]="autore",
- ["nl"]="auteur",
- ["ro"]="autor",
+ ["cd:parenthesis-l"]={
+ ["en"]="(...,...)",
},
- ["auto"]={
- ["cs"]="auto",
- ["de"]="auto",
- ["en"]="auto",
- ["fr"]="auto",
- ["it"]="auto",
- ["nl"]="auto",
- ["pe"]="خودکار",
- ["ro"]="auto",
+ ["cd:parenthesis-s"]={
+ ["en"]="(...)",
},
- ["autointro"]={
- ["cs"]="autouvod",
- ["de"]="autointro",
- ["en"]="autointro",
- ["fr"]="autointro",
- ["it"]="autointro",
- ["nl"]="autointro",
- ["pe"]="پیشگفتارخودکار",
- ["ro"]="autointro",
+ ["cd:path"]={
+ ["cs"]="path",
+ ["de"]="path",
+ ["en"]="path",
+ ["fr"]="chemin",
+ ["it"]="path",
+ ["nl"]="path",
+ ["ro"]="path",
},
- ["autopunctuation"]={
- ["en"]="autopunctuation",
+ ["cd:plural"]={
+ ["cs"]="plural",
+ ["de"]="plural",
+ ["en"]="plural",
+ ["fr"]="pluriel",
+ ["it"]="plural",
+ ["nl"]="naam",
+ ["ro"]="plural",
},
- ["back"]={
- ["cs"]="zpet",
- ["de"]="zurueck",
- ["en"]="back",
- ["fr"]="retour",
- ["it"]="dietro",
- ["nl"]="terug",
- ["pe"]="پشت",
- ["ro"]="inapot",
+ ["cd:position"]={
+ ["cs"]="position",
+ ["de"]="position",
+ ["en"]="position",
+ ["fr"]="position",
+ ["it"]="position",
+ ["nl"]="positie",
+ ["ro"]="position",
},
- ["background"]={
- ["cs"]="pozadi",
- ["de"]="hintergrund",
- ["en"]="background",
- ["fr"]="arriereplan",
- ["it"]="sfondo",
- ["nl"]="achtergrond",
- ["pe"]="پسزمینه",
- ["ro"]="fundal",
+ ["cd:position-l"]={
+ ["en"]="(...,...)",
},
- ["backmatter"]={
- ["cs"]="epilogy",
- ["de"]="epiloge",
- ["en"]="backmatter",
- ["fr"]="epilogue",
- ["it"]="postambolo",
- ["nl"]="uitleidingen",
- ["pe"]="پسمطلب",
- ["ro"]="epilogul",
+ ["cd:position-s"]={
+ ["en"]="(...)",
},
- ["backpart"]={
- ["cs"]="epilog",
- ["de"]="epilog",
- ["en"]="backpart",
- ["fr"]="postface",
- ["it"]="postfazione",
- ["nl"]="uitleiding",
- ["pe"]="پسقسمت",
- ["ro"]="epilog",
+ ["cd:processor"]={
+ ["cs"]="processor",
+ ["de"]="processor",
+ ["en"]="processor",
+ ["fr"]="processeur",
+ ["it"]="processor",
+ ["nl"]="verwerker",
+ ["ro"]="processor",
},
- ["backspace"]={
- ["cs"]="zpetnamezera",
- ["de"]="rumpfspatium",
- ["en"]="backspace",
- ["fr"]="retourarriere",
- ["it"]="backspace",
- ["nl"]="rugwit",
- ["pe"]="فضایپشت",
- ["ro"]="spatiuspate",
+ ["cd:reference"]={
+ ["cs"]="reference",
+ ["de"]="reference",
+ ["en"]="reference",
+ ["fr"]="reference",
+ ["it"]="reference",
+ ["nl"]="verwijzing",
+ ["ro"]="reference",
},
- ["backward"]={
- ["cs"]="zpet",
- ["de"]="rueckwaerts",
- ["en"]="backward",
- ["fr"]="retourarriere",
- ["it"]="indietro",
- ["nl"]="achteruit",
- ["pe"]="عقبگرد",
- ["ro"]="inapoi",
+ ["cd:reference-l"]={
+ ["en"]="[...,...]",
+ ["lua"]="{..., ...}",
},
- ["bbl"]={
- ["en"]="bbl",
+ ["cd:reference-s"]={
+ ["en"]="[...]",
+ ["lua"]="{ ... }",
},
- ["before"]={
- ["cs"]="pred",
- ["de"]="vor",
- ["en"]="before",
- ["fr"]="avant",
- ["it"]="prima",
- ["nl"]="voor",
- ["pe"]="قبلاز",
- ["ro"]="inainte",
+ ["cd:row"]={
+ ["cs"]="row",
+ ["de"]="row",
+ ["en"]="row",
+ ["fr"]="rang",
+ ["it"]="row",
+ ["nl"]="rij",
+ ["ro"]="row",
},
- ["begin"]={
- ["en"]="begin",
- ["nl"]="begin",
+ ["cd:section"]={
+ ["cs"]="Abschnitt",
+ ["de"]="Abschnitt",
+ ["en"]="section",
+ ["fr"]="section",
+ ["it"]="Abschnitt",
+ ["nl"]="sectie",
+ ["ro"]="Abschnitt",
},
- ["bib"]={
- ["en"]="bib",
+ ["cd:sectionblock"]={
+ ["cs"]="sectionblock",
+ ["de"]="sectionblock",
+ ["en"]="sectionblock",
+ ["fr"]="blocsection",
+ ["it"]="sectionblock",
+ ["nl"]="sectieblok",
+ ["ro"]="sectionblock",
},
- ["big"]={
- ["cs"]="velke",
- ["de"]="gross",
- ["en"]="big",
- ["fr"]="grand",
- ["it"]="grande",
- ["nl"]="groot",
- ["pe"]="بزرگ",
- ["ro"]="mare",
+ ["cd:see"]={
+ ["cs"]="siehe",
+ ["de"]="siehe",
+ ["en"]="see",
+ ["fr"]="voir",
+ ["it"]="siehe",
+ ["nl"]="zie",
+ ["ro"]="siehe",
},
- ["bigbodyfont"]={
- ["cs"]="bigbodyfont",
- ["de"]="bigbodyfont",
- ["en"]="bigbodyfont",
- ["fr"]="grandepolicecorp",
- ["it"]="grossofontdeltesto",
- ["nl"]="grootkorps",
- ["pe"]="قلمبدنهبزرگ",
- ["ro"]="bigbodyfont",
+ ["cd:sep-l"]={
+ ["en"]="\\",
},
- ["bigger"]={
- ["en"]="bigger",
- ["nl"]="groter",
+ ["cd:sep-s"]={
+ ["en"]="\\",
},
- ["bigpreference"]={
- ["cs"]="vysokapriorita",
- ["de"]="grosszuegig",
- ["en"]="bigpreference",
- ["fr"]="grandepreference",
- ["it"]="grandepreferenza",
- ["nl"]="grotevoorkeur",
- ["pe"]="اولویتبزرگ",
- ["ro"]="preferintamare",
+ ["cd:setup"]={
+ ["cs"]="setup",
+ ["de"]="setup",
+ ["en"]="setup",
+ ["fr"]="configurer",
+ ["it"]="setup",
+ ["nl"]="setup",
+ ["ro"]="setup",
},
- ["blank"]={
- ["cs"]="prazdny",
- ["de"]="blanko",
- ["en"]="blank",
- ["fr"]="vide",
- ["it"]="rigovuoto",
- ["nl"]="blanko",
- ["pe"]="خالی",
- ["ro"]="blank",
+ ["cd:sign"]={
+ ["en"]="[-+]",
},
- ["block"]={
- ["en"]="block",
+ ["cd:singular"]={
+ ["cs"]="singular",
+ ["de"]="singular",
+ ["en"]="singular",
+ ["fr"]="singulier",
+ ["it"]="singular",
+ ["nl"]="naam",
+ ["ro"]="singular",
},
- ["blockquote"]={
- ["cs"]="blockquote",
- ["de"]="blockquote",
- ["en"]="blockquote",
- ["fr"]="blockquote",
- ["it"]="blockquote",
- ["nl"]="blokcitaat",
- ["pe"]="نقلبلوک",
- ["ro"]="blockquote",
+ ["cd:style"]={
+ ["cs"]="style",
+ ["de"]="style",
+ ["en"]="style",
+ ["fr"]="style",
+ ["it"]="style",
+ ["nl"]="letter",
+ ["ro"]="style",
},
- ["bodymatter"]={
- ["cs"]="hlavnicasti",
- ["de"]="haupttexte",
- ["en"]="bodymatter",
- ["fr"]="texteprincipal",
- ["it"]="testiprincipali",
- ["nl"]="hoofdteksten",
- ["pe"]="مطلببدنه",
- ["ro"]="principalul",
+ ["cd:template"]={
+ ["cs"]="template",
+ ["de"]="template",
+ ["en"]="template",
+ ["fr"]="gabarit",
+ ["it"]="template",
+ ["nl"]="sjabloon",
+ ["ro"]="template",
},
- ["bodypart"]={
- ["cs"]="hlavnicast",
- ["de"]="haupttext",
- ["en"]="bodypart",
- ["fr"]="corpsdetexte",
- ["it"]="testoprincipale",
- ["nl"]="hoofdtekst",
- ["pe"]="قسمتبدنه",
- ["ro"]="principal",
+ ["cd:template-l"]={
+ ["en"]="[|...|...|]",
},
- ["bold"]={
- ["cs"]="tucne",
- ["de"]="fett",
- ["en"]="bold",
- ["fr"]="gras",
- ["it"]="grassetto",
- ["nl"]="vet",
- ["pe"]="مشکی",
- ["ro"]="aldin",
+ ["cd:template-s"]={
+ ["en"]="[|...|]",
},
- ["bolditalic"]={
- ["cs"]="tucnekurzivni",
- ["de"]="fettitalic",
- ["en"]="bolditalic",
- ["fr"]="italiquegras",
- ["it"]="grassettocorsivo",
- ["nl"]="vetitalic",
- ["pe"]="ایتالیکمشکی",
- ["ro"]="aldinitalic",
+ ["cd:text"]={
+ ["cs"]="Text",
+ ["de"]="Text",
+ ["en"]="text",
+ ["fr"]="texte",
+ ["it"]="Text",
+ ["nl"]="tekst",
+ ["ro"]="Text",
},
- ["boldslanted"]={
- ["cs"]="tucnesklonene",
- ["de"]="fettgeneigt",
- ["en"]="boldslanted",
- ["fr"]="inclinegras",
- ["it"]="grassettoinclinato",
- ["nl"]="vetschuin",
- ["pe"]="خوابیدهمشکی",
- ["ro"]="aldininclinat",
+ ["cd:textual-l"]={
+ ["en"]=".. ... ..",
},
- ["bookmark"]={
- ["cs"]="zalozka",
- ["de"]="bookmark",
- ["en"]="bookmark",
- ["fr"]="marquepage",
- ["it"]="segnalibro",
- ["nl"]="bookmark",
- ["pe"]="چوبخط",
- ["ro"]="semncarte",
+ ["cd:textual-s"]={
+ ["en"]="...",
},
- ["both"]={
- ["cs"]="obe",
- ["de"]="beide",
- ["en"]="both",
- ["fr"]="lesdeux",
- ["it"]="entrambi",
- ["nl"]="beide",
- ["pe"]="هردو",
- ["ro"]="ambele",
+ ["cd:threearguments"]={
+ ["en"]="\\...#1#2#3",
},
- ["bothtext"]={
- ["en"]="bothtext",
+ ["cd:threewords-l"]={
+ ["en"]="[..+..+..]",
},
- ["bottom"]={
- ["cs"]="spodek",
- ["de"]="unten",
- ["en"]="bottom",
- ["fr"]="inf",
- ["it"]="fondo",
- ["nl"]="onder",
- ["pe"]="پایین",
- ["ro"]="subsol",
+ ["cd:threewords-s"]={
+ ["en"]="[..+..+..]",
},
- ["box"]={
- ["en"]="box",
+ ["cd:title"]={
+ ["cs"]="Setup",
+ ["de"]="Setup",
+ ["en"]="setup",
+ ["fr"]="titre",
+ ["it"]="Setup",
+ ["nl"]="setup",
+ ["ro"]="Setup",
},
- ["brief"]={
- ["cs"]="brief",
- ["de"]="brief",
- ["en"]="brief",
- ["fr"]="brief",
- ["it"]="brief",
- ["nl"]="brief",
- ["pe"]="مختصر",
- ["ro"]="brief",
+ ["cd:to-l"]={
+ ["en"]="\\to ",
},
- ["broad"]={
- ["cs"]="siroky",
- ["de"]="breit",
- ["en"]="broad",
- ["fr"]="large",
- ["it"]="ampio",
- ["nl"]="ruim",
- ["pe"]="گسترده",
- ["ro"]="broad",
+ ["cd:to-s"]={
+ ["en"]="\\to ",
},
- ["buffer"]={
- ["cs"]="buffer",
- ["de"]="puffer",
- ["en"]="buffer",
- ["fr"]="buffer",
- ["it"]="buffer",
- ["nl"]="buffer",
- ["pe"]="بافر",
- ["ro"]="buffer",
+ ["cd:triplet"]={
+ ["cs"]="triplet",
+ ["de"]="triplet",
+ ["en"]="triplet",
+ ["fr"]="triplet",
+ ["it"]="triplet",
+ ["nl"]="triplet",
+ ["ro"]="triplet",
},
- ["by"]={
- ["cs"]="skrz",
- ["de"]="pro",
- ["en"]="by",
- ["fr"]="par",
- ["it"]="da",
- ["nl"]="per",
- ["pe"]="بوسیله",
- ["ro"]="de",
+ ["cd:triplet-l"]={
+ ["en"]="[x:y:z,..]",
},
- ["calligraphic"]={
- ["cs"]="kaligraficke",
- ["de"]="kalligraphie",
- ["en"]="calligraphic",
- ["fr"]="calligraphique",
- ["it"]="calligrafico",
- ["nl"]="calligrafie",
- ["pe"]="خوشنویسی",
- ["ro"]="caligrafic",
+ ["cd:triplet-s"]={
+ ["en"]="[x:y:z]",
},
- ["camel"]={
- ["en"]="camel",
+ ["cd:true"]={
+ ["cs"]="true",
+ ["de"]="true",
+ ["en"]="true",
+ ["fr"]="vrai",
+ ["it"]="true",
+ ["nl"]="true",
+ ["ro"]="true",
},
- ["cap"]={
- ["cs"]="kap",
- ["de"]="kap",
- ["en"]="cap",
- ["fr"]="cap",
- ["it"]="cap",
- ["nl"]="kap",
- ["pe"]="cap",
- ["ro"]="cap",
+ ["cd:twoarguments"]={
+ ["en"]="\\...#1#2",
},
- ["capital"]={
- ["cs"]="kapitalky",
- ["de"]="versalien",
- ["en"]="capital",
- ["fr"]="capitale",
- ["it"]="maiuscolo",
- ["nl"]="kapitaal",
- ["pe"]="capital",
- ["ro"]="majuscula",
+ ["cd:twowords-l"]={
+ ["en"]="[..+..]",
},
- ["center"]={
- ["cs"]="center",
- ["de"]="center",
- ["en"]="center",
- ["fr"]="center",
- ["it"]="center",
- ["nl"]="centreer",
- ["pe"]="مرکز",
- ["ro"]="center",
+ ["cd:twowords-s"]={
+ ["en"]="[..+..]",
},
- ["centerlast"]={
- ["en"]="centerlast",
+ ["cd:url"]={
+ ["cs"]="url",
+ ["de"]="url",
+ ["en"]="url",
+ ["fr"]="url",
+ ["it"]="url",
+ ["nl"]="url",
+ ["ro"]="url",
},
- ["chapter"]={
- ["cs"]="kapitola",
- ["de"]="kapitel",
- ["en"]="chapter",
- ["fr"]="chapitre",
- ["it"]="capitolo",
- ["nl"]="hoofdstuk",
- ["pe"]="فصل",
- ["ro"]="capitol",
+ ["cd:userdata"]={
+ ["cs"]="userdata",
+ ["de"]="userdata",
+ ["en"]="userdata",
+ ["fr"]="donneesutilisateur",
+ ["it"]="userdata",
+ ["nl"]="gebruikersdata",
+ ["ro"]="userdata",
},
- ["character"]={
- ["cs"]="pismeno",
- ["de"]="buchstabe",
- ["en"]="character",
- ["fr"]="caractere",
- ["it"]="lettera",
- ["nl"]="letter",
- ["pe"]="حرف",
- ["ro"]="caracter",
+ ["cd:value"]={
+ ["cs"]="value",
+ ["de"]="value",
+ ["en"]="value",
+ ["fr"]="valeur",
+ ["it"]="value",
+ ["nl"]="waarde",
+ ["ro"]="value",
},
- ["characters"]={
- ["cs"]="pismena",
- ["de"]="buchstaben",
- ["en"]="characters",
- ["fr"]="caracteres",
- ["it"]="lettere",
- ["nl"]="letters",
- ["pe"]="حرفها",
- ["ro"]="caractere",
+ ["cd:word"]={
+ ["cs"]="word",
+ ["de"]="word",
+ ["en"]="word",
+ ["fr"]="mot",
+ ["it"]="word",
+ ["nl"]="woord",
+ ["ro"]="word",
},
- ["chemical"]={
- ["en"]="chemical",
+ ["cd:word-l"]={
+ ["en"]="{.. ... ..}",
+ ["lua"]="\".. ... ..\"",
},
- ["chemicals"]={
- ["en"]="chemicals",
+ ["cd:word-s"]={
+ ["en"]="{...}",
+ ["lua"]="\"...\"",
},
- ["chemistry"]={
- ["en"]="chemistry",
- ["nl"]="chemie",
+ ["cd:xmlsetup"]={
+ ["cs"]="xmlsetup",
+ ["de"]="xmlsetup",
+ ["en"]="xmlsetup",
+ ["fr"]="configurationxml",
+ ["it"]="xmlsetup",
+ ["nl"]="xmlsetup",
+ ["ro"]="xmlsetup",
},
- ["cite"]={
- ["en"]="cite",
+ },
+ ["variables"]={
+ ["Addition"]={
+ ["cs"]="Pridavek",
+ ["de"]="Zusatz",
+ ["en"]="Addition",
+ ["fr"]="Ajout",
+ ["it"]="Aggiunta",
+ ["nl"]="Toevoeging",
+ ["pe"]="جمع",
+ ["ro"]="Adaugare",
},
- ["closed"]={
- ["en"]="closed",
- ["nl"]="gesloten",
+ ["Alphabetic"]={
+ ["en"]="Alphabetic",
+ ["fr"]="Alphabetique",
},
- ["color"]={
- ["cs"]="barevne",
- ["de"]="farbe",
- ["en"]="color",
- ["fr"]="couleur",
- ["it"]="colore",
- ["nl"]="kleur",
- ["pe"]="رنگ",
- ["ro"]="culoare",
+ ["Balloon"]={
+ ["cs"]="Bublinka",
+ ["de"]="Ballon",
+ ["en"]="Balloon",
+ ["fr"]="Ballon",
+ ["it"]="Pallone",
+ ["nl"]="Ballon",
+ ["pe"]="بادکنک",
+ ["ro"]="Balon",
},
- ["column"]={
- ["cs"]="column",
- ["de"]="column",
- ["en"]="column",
- ["fr"]="colonne",
- ["it"]="colonna",
- ["nl"]="kolom",
- ["pe"]="ستون",
- ["ro"]="coloana",
+ ["Cap"]={
+ ["cs"]="Kap",
+ ["de"]="Kap",
+ ["en"]="Cap",
+ ["fr"]="Cap",
+ ["it"]="Cap",
+ ["nl"]="Kap",
+ ["pe"]="Cap",
+ ["ro"]="Cap",
},
- ["columns"]={
- ["cs"]="sloupce",
- ["de"]="spalten",
- ["en"]="columns",
- ["fr"]="colonnes",
- ["it"]="colonne",
- ["nl"]="kolommen",
- ["pe"]="ستونها",
- ["ro"]="coloane",
+ ["Capital"]={
+ ["cs"]="Kapitalky",
+ ["de"]="Versalien",
+ ["en"]="Capital",
+ ["fr"]="Capitales",
+ ["it"]="Maiuscolo",
+ ["nl"]="Kapitaal",
+ ["pe"]="Capital",
+ ["ro"]="Majuscula",
},
- ["combination"]={
- ["en"]="combination",
- ["nl"]="combinatie",
+ ["Character"]={
+ ["cs"]="Pismeno",
+ ["de"]="Buchstabe",
+ ["en"]="Character",
+ ["fr"]="Caractere",
+ ["it"]="Lettera",
+ ["nl"]="Letter",
+ ["pe"]="Character",
+ ["ro"]="Caracter",
},
- ["command"]={
- ["cs"]="prikaz",
- ["de"]="befehl",
- ["en"]="command",
- ["fr"]="commande",
- ["it"]="comando",
- ["nl"]="commando",
- ["pe"]="فرمان",
- ["ro"]="comanda",
+ ["Characters"]={
+ ["cs"]="Pismena",
+ ["de"]="Buchstaben",
+ ["en"]="Characters",
+ ["fr"]="Caracteres",
+ ["it"]="Lettere",
+ ["nl"]="Letters",
+ ["pe"]="Characters",
+ ["ro"]="Caractere",
},
- ["commands"]={
- ["cs"]="prikazy",
- ["de"]="befehle",
- ["en"]="commands",
- ["fr"]="commandes",
- ["it"]="comandi",
- ["nl"]="commandos",
- ["pe"]="فرمانها",
- ["ro"]="comenzi",
+ ["CloseDocument"]={
+ ["cs"]="ZavritDokument",
+ ["de"]="SchliesseDokument",
+ ["en"]="CloseDocument",
+ ["fr"]="FermerDocument",
+ ["it"]="ChiudiDocumento",
+ ["nl"]="SluitDocument",
+ ["pe"]="بستننوشتار",
+ ["ro"]="InchideDocument",
},
- ["comment"]={
- ["cs"]="komentar",
- ["de"]="kommentar",
- ["en"]="comment",
- ["fr"]="commentaire",
- ["it"]="commento",
- ["nl"]="commentaar",
- ["pe"]="توضیح",
- ["ro"]="comentariu",
+ ["ExitViewer"]={
+ ["cs"]="UkoncitProhlizec",
+ ["de"]="BeendeViewer",
+ ["en"]="ExitViewer",
+ ["fr"]="SortirVisualisateur",
+ ["it"]="EsciVisualizzatore",
+ ["nl"]="VerlaatViewer",
+ ["pe"]="خروجنمایشگر",
+ ["ro"]="IesireVizualizator",
},
- ["component"]={
- ["cs"]="komponenta",
- ["de"]="komponente",
- ["en"]="component",
- ["fr"]="composant",
- ["it"]="componente",
- ["nl"]="onderdeel",
- ["pe"]="مولفه",
- ["ro"]="componenta",
+ ["FirstPage"]={
+ ["cs"]="PrvniStrana",
+ ["de"]="ErsteSeite",
+ ["en"]="FirstPage",
+ ["fr"]="PremierePage",
+ ["it"]="PrimaPagina",
+ ["nl"]="EerstePagina",
+ ["pe"]="صفحهاول",
+ ["ro"]="PrimaPagina",
},
- ["compressseparator"]={
- ["en"]="compressseparator",
+ ["FitHeight"]={
+ ["cs"]="FitHeight",
+ ["de"]="HoehePassend",
+ ["en"]="FitHeight",
+ ["fr"]="AdapterHauteur",
+ ["it"]="FitHeight",
+ ["nl"]="HoogtePassend",
+ ["pe"]="پرکردنارتفاع",
+ ["ro"]="AjustatInaltime",
},
- ["compressstopper"]={
- ["en"]="compressstopper",
+ ["FitWidth"]={
+ ["cs"]="FitWidth",
+ ["de"]="BreitePassend",
+ ["en"]="FitWidth",
+ ["fr"]="AdapterLargeur",
+ ["it"]="FitWidth",
+ ["nl"]="BreedtePassend",
+ ["pe"]="پرکردنعرض",
+ ["ro"]="AjustatLatime",
},
- ["concept"]={
- ["cs"]="koncept",
- ["de"]="konzept",
- ["en"]="concept",
- ["fr"]="concept",
- ["it"]="concetto",
- ["nl"]="concept",
- ["pe"]="مفهوم",
- ["ro"]="concept",
+ ["GotoPage"]={
+ ["cs"]="JdiNaStranku",
+ ["de"]="GotoPage",
+ ["en"]="GotoPage",
+ ["fr"]="AlleraPage",
+ ["it"]="VaiAPagina",
+ ["nl"]="GaNaarPagina",
+ ["pe"]="بروبهصفحه",
+ ["ro"]="LaPagina",
},
- ["construction"]={
- ["en"]="construction",
+ ["Greek"]={
+ ["cs"]="Recky",
+ ["de"]="Griechisch",
+ ["en"]="Greek",
+ ["fr"]="Grec",
+ ["it"]="Greco",
+ ["nl"]="Grieks",
+ ["pe"]="یونانی",
+ ["ro"]="Grec",
},
- ["content"]={
- ["cs"]="obsah",
- ["de"]="inhalt",
- ["en"]="content",
- ["fr"]="contenu",
- ["it"]="indice",
- ["nl"]="inhoud",
- ["pe"]="محتوا",
- ["ro"]="cuprins",
+ ["Help"]={
+ ["cs"]="Napoveda",
+ ["de"]="Hilfe",
+ ["en"]="Help",
+ ["fr"]="Aide",
+ ["it"]="Aiuto",
+ ["nl"]="Help",
+ ["pe"]="کمک",
+ ["ro"]="Ajutor",
},
- ["contents"]={
- ["cs"]="obsah",
- ["de"]="inhalte",
- ["en"]="contents",
- ["fr"]="contenus",
- ["it"]="indici",
- ["nl"]="inhouden",
- ["pe"]="محتویات",
- ["ro"]="cuprinsuri",
+ ["HideField"]={
+ ["cs"]="SkryjPole",
+ ["de"]="VerbergeFeld",
+ ["en"]="HideField",
+ ["fr"]="CacherChamps",
+ ["it"]="NascondiCampo",
+ ["nl"]="VerbergVeld",
+ ["pe"]="پنهانمیدان",
+ ["ro"]="AscundeCamp",
},
- ["continue"]={
- ["cs"]="pokracovat",
- ["de"]="fortsetzten",
- ["en"]="continue",
- ["fr"]="continue",
- ["it"]="continua",
- ["nl"]="verder",
- ["pe"]="ادامه",
- ["ro"]="continuu",
+ ["HideLayer"]={
+ ["cs"]="HideLayer",
+ ["de"]="HideLayer",
+ ["en"]="HideLayer",
+ ["fr"]="CacherCalque",
+ ["it"]="HideLayer",
+ ["nl"]="VerbergLaag",
+ ["pe"]="پنهانلایه",
+ ["ro"]="HideLayer",
},
- ["continued"]={
- ["en"]="continued",
- ["nl"]="vervolgd",
+ ["Key"]={
+ ["cs"]="Klavesa",
+ ["de"]="Schluessel",
+ ["en"]="Key",
+ ["fr"]="Cle",
+ ["it"]="Tasto",
+ ["nl"]="Sleutel",
+ ["pe"]="کلید",
+ ["ro"]="Cheie",
},
- ["controls"]={
- ["cs"]="controls",
- ["de"]="controls",
- ["en"]="controls",
- ["fr"]="controles",
- ["it"]="controlli",
- ["nl"]="sturing",
- ["pe"]="کنترلها",
- ["ro"]="controale",
+ ["LastPage"]={
+ ["cs"]="PosledniStrana",
+ ["de"]="LetzteSeite",
+ ["en"]="LastPage",
+ ["fr"]="DernierePage",
+ ["it"]="UltimaPagina",
+ ["nl"]="LaatstePagina",
+ ["pe"]="صفحهآخر",
+ ["ro"]="UltimaPagina",
},
- ["conversion"]={
- ["cs"]="konverze",
- ["de"]="konversion",
- ["en"]="conversion",
- ["fr"]="conversion",
- ["it"]="coversione",
- ["nl"]="conversie",
- ["pe"]="تبدیل",
- ["ro"]="conversie",
+ ["LoadForm"]={
+ ["cs"]="NacistFormular",
+ ["de"]="LadeFormular",
+ ["en"]="LoadForm",
+ ["fr"]="ChargerFormulaire",
+ ["it"]="CaricaForm",
+ ["nl"]="LaadFormulier",
+ ["pe"]="بارگذاشتنفرم",
+ ["ro"]="IncarcaFormular",
},
- ["current"]={
- ["cs"]="aktualni",
- ["de"]="aktuell",
- ["en"]="current",
- ["fr"]="courant",
- ["it"]="corrente",
- ["nl"]="huidige",
- ["pe"]="جاری",
- ["ro"]="curent",
+ ["MONTH"]={
+ ["cs"]="MESIC",
+ ["de"]="MONAT",
+ ["en"]="MONTH",
+ ["fr"]="MOIS",
+ ["it"]="MESE",
+ ["nl"]="MAAND",
+ ["pe"]="ماه",
+ ["ro"]="LUNA",
},
- ["cutspace"]={
- ["cs"]="cutspace",
- ["de"]="cutspace",
- ["en"]="cutspace",
- ["fr"]="cutspace",
- ["it"]="cutspace",
- ["nl"]="snijwit",
- ["pe"]="فضایبرش",
- ["ro"]="cutspace",
+ ["New"]={
+ ["cs"]="Novy",
+ ["de"]="Neu",
+ ["en"]="New",
+ ["fr"]="Nouveau",
+ ["it"]="Nuovo",
+ ["nl"]="Nieuw",
+ ["pe"]="جدید",
+ ["ro"]="Nou",
},
- ["dataset"]={
- ["en"]="dataset",
+ ["NextJump"]={
+ ["cs"]="NasledujiciSkok",
+ ["de"]="NaechsterSprung",
+ ["en"]="NextJump",
+ ["fr"]="SautSuivant",
+ ["it"]="SaltoSuccessivo",
+ ["nl"]="VolgendeSprong",
+ ["pe"]="پرشبعدی",
+ ["ro"]="SaltUrmator",
},
- ["date"]={
- ["cs"]="datum",
- ["de"]="datum",
- ["en"]="date",
- ["fr"]="date",
- ["it"]="data",
- ["nl"]="datum",
- ["pe"]="تاریخ",
- ["ro"]="data",
+ ["NextPage"]={
+ ["cs"]="DalsiStrana",
+ ["de"]="FolgendeSeite",
+ ["en"]="NextPage",
+ ["fr"]="PageSuivante",
+ ["it"]="PaginaSuccessiva",
+ ["nl"]="VolgendePagina",
+ ["pe"]="صفحهبعدی",
+ ["ro"]="PaginaUrmatoare",
},
- ["day"]={
- ["cs"]="den",
- ["de"]="tag",
- ["en"]="day",
- ["fr"]="jour",
- ["it"]="giorno",
- ["nl"]="dag",
- ["pe"]="روز",
- ["ro"]="zi",
+ ["Numbers"]={
+ ["cs"]="Cisla",
+ ["de"]="Ziffern",
+ ["en"]="Numbers",
+ ["fr"]="Numeros",
+ ["it"]="Numeri",
+ ["nl"]="Cijfers",
+ ["pe"]="شمارهها",
+ ["ro"]="Numere",
},
- ["december"]={
- ["cs"]="prosinec",
- ["de"]="dezember",
- ["en"]="december",
- ["fr"]="decembre",
- ["it"]="dicembre",
- ["nl"]="december",
- ["pe"]="دسامبر",
- ["ro"]="decembrie",
+ ["OpenNamedDocument"]={
+ ["cs"]="OpenNamedDocument",
+ ["de"]="OpenNamedDocument",
+ ["en"]="OpenNamedDocument",
+ ["fr"]="OuvrirDocumentNomme",
+ ["it"]="OpenNamedDocument",
+ ["nl"]="OpenDocumentOpNaam",
+ ["pe"]="بازکردننوشتارذخیرهشده",
+ ["ro"]="OpenNamedDocument",
},
- ["default"]={
- ["cs"]="implicitni",
- ["de"]="default",
- ["en"]="default",
- ["fr"]="defaut",
- ["it"]="implicito",
- ["nl"]="default",
- ["pe"]="پیشفرض",
- ["ro"]="implicit",
+ ["Ordinal"]={
+ ["en"]="Ordinal",
+ ["fr"]="Ordinal",
},
- ["depth"]={
- ["cs"]="podlehloubky",
- ["de"]="tiefe",
- ["en"]="depth",
- ["fr"]="profondeur",
- ["it"]="profondita",
- ["nl"]="diepte",
- ["pe"]="عمق",
- ["ro"]="adancime",
+ ["Paragraph"]={
+ ["cs"]="Odstavec",
+ ["de"]="Absatz",
+ ["en"]="Paragraph",
+ ["fr"]="Paragraphe",
+ ["it"]="Capoverso",
+ ["nl"]="Paragraaf",
+ ["pe"]="پاراگراف",
+ ["ro"]="Paragraf",
},
- ["description"]={
- ["cs"]="popis",
- ["de"]="beschreibung",
- ["en"]="description",
- ["fr"]="description",
- ["it"]="descrizione",
- ["nl"]="doordefinitie",
- ["pe"]="شرح",
- ["ro"]="descriere",
+ ["PauseMovie"]={
+ ["cs"]="PozastavitFilm",
+ ["de"]="PauseFilm",
+ ["en"]="PauseMovie",
+ ["fr"]="PauseFilm",
+ ["it"]="PausaFilm",
+ ["nl"]="PauzeerFilm",
+ ["pe"]="ایستفیلم",
+ ["ro"]="PauzaFilm",
},
- ["disable"]={
- ["cs"]="zablokovat",
- ["de"]="sperren",
- ["en"]="disable",
- ["fr"]="desactiver",
- ["it"]="disattiva",
- ["nl"]="blokkeer",
- ["pe"]="ناتوان",
- ["ro"]="dezactivat",
+ ["PauseRendering"]={
+ ["cs"]="PauseRendering",
+ ["de"]="PauseRendering",
+ ["en"]="PauseRendering",
+ ["fr"]="PauseRendu",
+ ["it"]="PauseRendering",
+ ["nl"]="PauzeerRendering",
+ ["pe"]="توقفتعبیر",
+ ["ro"]="PauseRendering",
},
- ["display"]={
- ["cs"]="obrazovka",
- ["de"]="bildschirm",
- ["en"]="display",
- ["fr"]="affichage",
- ["it"]="schermo",
- ["nl"]="scherm",
- ["pe"]="نمایش",
- ["ro"]="display",
+ ["PauseSound"]={
+ ["cs"]="PozastavitZvuk",
+ ["de"]="PauseSound",
+ ["en"]="PauseSound",
+ ["fr"]="PauseSon",
+ ["it"]="PausaSuono",
+ ["nl"]="PauzeerGeluid",
+ ["pe"]="ایستصدا",
+ ["ro"]="PauzaSunet",
},
- ["dot"]={
- ["cs"]="tecka",
- ["de"]="punkt",
- ["en"]="dot",
- ["fr"]="point",
- ["it"]="punto",
- ["nl"]="punt",
- ["pe"]="نقطه",
- ["ro"]="punct",
+ ["PreviousJump"]={
+ ["cs"]="PredchoziSkok",
+ ["de"]="VorigerSprung",
+ ["en"]="PreviousJump",
+ ["fr"]="SautPrecedent",
+ ["it"]="SaltoPrecedente",
+ ["nl"]="VorigeSprong",
+ ["pe"]="پرشقبلی",
+ ["ro"]="SaltPrecedent",
},
- ["doublesided"]={
- ["cs"]="dvoustranny",
- ["de"]="doppelseitig",
- ["en"]="doublesided",
- ["fr"]="rectoverso",
- ["it"]="doppiafaccia",
- ["nl"]="dubbelzijdig",
- ["pe"]="دورو",
- ["ro"]="douafete",
+ ["PreviousPage"]={
+ ["cs"]="PredchoziStrana",
+ ["de"]="VorigeSeite",
+ ["en"]="PreviousPage",
+ ["fr"]="PagePrecedente",
+ ["it"]="PaginaPrecedente",
+ ["nl"]="VorigePagina",
+ ["pe"]="صفحهقبلی",
+ ["ro"]="PaginaPrecedenta",
},
- ["down"]={
- ["en"]="down",
- ["nl"]="omlaag",
+ ["PrintDocument"]={
+ ["cs"]="VytisknoutDokument",
+ ["de"]="DruckeDokument",
+ ["en"]="PrintDocument",
+ ["fr"]="ImprimerDocument",
+ ["it"]="StampaDocumento",
+ ["nl"]="PrintDocument",
+ ["pe"]="چاپنوشتار",
+ ["ro"]="TiparesteDocument",
},
- ["each"]={
- ["cs"]="kazdy",
- ["de"]="jede",
- ["en"]="each",
- ["fr"]="chaque",
- ["it"]="ogni",
- ["nl"]="elk",
- ["pe"]="هر",
- ["ro"]="fiecare",
+ ["Query"]={
+ ["cs"]="Query",
+ ["de"]="Query",
+ ["en"]="Query",
+ ["fr"]="Interroger",
+ ["it"]="Richiesta",
+ ["nl"]="RaadpleegDocument",
+ ["pe"]="پرسش",
+ ["ro"]="Query",
},
- ["edge"]={
- ["cs"]="hrana",
- ["de"]="kante",
- ["en"]="edge",
- ["fr"]="bord",
- ["it"]="bordo",
- ["nl"]="rand",
- ["pe"]="لبه",
- ["ro"]="bordura",
+ ["QueryAgain"]={
+ ["cs"]="QueryAgain",
+ ["de"]="QueryAgain",
+ ["en"]="QueryAgain",
+ ["fr"]="InterrogerSuivant",
+ ["it"]="RinnovaRichiesta",
+ ["nl"]="HerhaalRaadplegen",
+ ["pe"]="پرسشدوباره",
+ ["ro"]="QueryAgain",
},
- ["effective"]={
- ["en"]="effective",
- ["nl"]="effectief",
+ ["ResetForm"]={
+ ["cs"]="ResetFormulare",
+ ["de"]="ZuruecksetzenFormular",
+ ["en"]="ResetForm",
+ ["fr"]="RazFormulaire",
+ ["it"]="ReimpostaForm",
+ ["nl"]="ResetFormulier",
+ ["pe"]="دوبارهنشانیفرم",
+ ["ro"]="ResetareFormular",
},
- ["embed"]={
- ["en"]="embed",
- ["nl"]="sluitin",
+ ["ResumeMovie"]={
+ ["cs"]="PokracovatFilm",
+ ["de"]="FortsetzenFilm",
+ ["en"]="ResumeMovie",
+ ["fr"]="RepriseFilm",
+ ["it"]="RiprendiFilm",
+ ["nl"]="HervatFilm",
+ ["pe"]="ادامهفیلم",
+ ["ro"]="RepornesteFilm",
},
- ["empty"]={
- ["cs"]="prazdne",
- ["de"]="leer",
- ["en"]="empty",
- ["fr"]="vide",
- ["it"]="vuoto",
- ["nl"]="leeg",
- ["pe"]="تهی",
- ["ro"]="gol",
+ ["ResumeRendering"]={
+ ["cs"]="ResumeRendering",
+ ["de"]="ResumeRendering",
+ ["en"]="ResumeRendering",
+ ["fr"]="RepriseRendu",
+ ["it"]="ResumeRendering",
+ ["nl"]="HervatRendering",
+ ["pe"]="ادامهتعبیر",
+ ["ro"]="ResumeRendering",
},
- ["enable"]={
- ["en"]="enable",
+ ["ResumeSound"]={
+ ["cs"]="PokracovatZvuk",
+ ["de"]="ResumeSound",
+ ["en"]="ResumeSound",
+ ["fr"]="RepriseSon",
+ ["it"]="RiprendiSuono",
+ ["nl"]="HervatGeluid",
+ ["pe"]="ادامهصدا",
+ ["ro"]="RepornesteSunet",
},
- ["end"]={
- ["en"]="end",
- ["nl"]="eind",
+ ["Romannumerals"]={
+ ["cs"]="Rimskecislice",
+ ["de"]="Roemischezahlen",
+ ["en"]="Romannumerals",
+ ["fr"]="Chiffresromains",
+ ["it"]="Numeriromani",
+ ["nl"]="Romeins",
+ ["pe"]="اعدادبزرگلاتین",
+ ["ro"]="Numereromane",
},
- ["endnote"]={
- ["cs"]="endnote",
- ["de"]="endnote",
- ["en"]="endnote",
- ["fr"]="notefin",
- ["it"]="endnote",
- ["nl"]="eindnoot",
- ["pe"]="تهنوشت",
- ["ro"]="endnote",
+ ["SaveDocument"]={
+ ["cs"]="UlozitDokument",
+ ["de"]="SpeichereDokument",
+ ["en"]="SaveDocument",
+ ["fr"]="EnregistrerDocument",
+ ["it"]="SalvaDocumento",
+ ["nl"]="BewaarDocument",
+ ["pe"]="ذخیرهنوشتار",
+ ["ro"]="SalvareDocument",
},
- ["textnote"]={
- ["en"]="textnote",
- ["nl"]="tekstnoot",
+ ["SaveForm"]={
+ ["cs"]="UlozitFormular",
+ ["de"]="SpeicheFormular",
+ ["en"]="SaveForm",
+ ["fr"]="EnregistrerFormulaire",
+ ["it"]="SalvaForm",
+ ["nl"]="BewaarFormulier",
+ ["pe"]="ذخیرهفرم",
+ ["ro"]="SalveazaFormular",
},
- ["enumeration"]={
- ["cs"]="vycet",
- ["de"]="nummerierung",
- ["en"]="enumeration",
- ["fr"]="enumeration",
- ["it"]="enumerazione",
- ["nl"]="doornummering",
- ["pe"]="شمارهبندی",
- ["ro"]="enumerare",
+ ["SaveNamedDocument"]={
+ ["cs"]="SaveNamedDocument",
+ ["de"]="SaveNamedDocument",
+ ["en"]="SaveNamedDocument",
+ ["fr"]="EnregistrerDocumentNomme",
+ ["it"]="SaveNamedDocument",
+ ["nl"]="BewaarDocumentOpNaam",
+ ["pe"]="ذخیرهنوشتاربانام",
+ ["ro"]="SaveNamedDocument",
},
- ["environment"]={
- ["cs"]="prostredi",
- ["de"]="umgebung",
- ["en"]="environment",
- ["fr"]="environement",
- ["it"]="ambiente",
- ["nl"]="omgeving",
- ["pe"]="محیط",
- ["ro"]="mediu",
+ ["SearchAgain"]={
+ ["cs"]="HledatZnovu",
+ ["de"]="WeiterSuchen",
+ ["en"]="SearchAgain",
+ ["fr"]="ChercherSuivant",
+ ["it"]="CercaAncora",
+ ["nl"]="HerhaalZoeken",
+ ["pe"]="جستجویدوباره",
+ ["ro"]="CautaDinNou",
},
- ["even"]={
- ["cs"]="sude",
- ["de"]="gerade",
- ["en"]="even",
- ["fr"]="paire",
- ["it"]="pari",
- ["nl"]="even",
- ["pe"]="زوج",
- ["ro"]="par",
+ ["SearchDocument"]={
+ ["cs"]="ProhledatDokument",
+ ["de"]="DokumentDurchsuchen",
+ ["en"]="SearchDocument",
+ ["fr"]="ChercherDocument",
+ ["it"]="CercaDocumento",
+ ["nl"]="DoorzoekDocument",
+ ["pe"]="جستجوینوشتار",
+ ["ro"]="CautaDocument",
},
- ["export"]={
- ["en"]="export",
+ ["ShowBookmarks"]={
+ ["cs"]="UkazZalozky",
+ ["de"]="ShowBookmarks",
+ ["en"]="ShowBookmarks",
+ ["fr"]="MontrerMarquepages",
+ ["it"]="MostraSegnalibro",
+ ["nl"]="ShowBookmarks",
+ ["pe"]="نمایشچوبخط",
+ ["ro"]="ShowBookmarks",
},
- ["external"]={
- ["cs"]="externi",
- ["de"]="extern",
- ["en"]="external",
- ["fr"]="external",
- ["it"]="esterno",
- ["nl"]="extern",
- ["pe"]="خارجی",
- ["ro"]="extern",
+ ["ShowField"]={
+ ["cs"]="UkazPole",
+ ["de"]="ZeigeFeld",
+ ["en"]="ShowField",
+ ["fr"]="MontrerChamp",
+ ["it"]="MostraCampo",
+ ["nl"]="ToonVeld",
+ ["pe"]="نمایشمیدان",
+ ["ro"]="AfiseazaCamp",
},
- ["extremestretch"]={
- ["en"]="extremestretch",
+ ["ShowThumbs"]={
+ ["cs"]="UkazNahledy",
+ ["de"]="ShowThumbs",
+ ["en"]="ShowThumbs",
+ ["fr"]="MontrerVignettes",
+ ["it"]="MostraThumbs",
+ ["nl"]="ShowThumbs",
+ ["pe"]="نمایششصت",
+ ["ro"]="ShowThumbs",
},
- ["fact"]={
- ["cs"]="fakt",
- ["de"]="gegeben",
- ["en"]="fact",
- ["fr"]="fait",
- ["it"]="fatto",
- ["nl"]="gegeven",
- ["pe"]="fact",
- ["ro"]="fapt",
+ ["StartMovie"]={
+ ["cs"]="SpustitFilm",
+ ["de"]="StartFilm",
+ ["en"]="StartMovie",
+ ["fr"]="débutFilm",
+ ["it"]="IniziaFilm",
+ ["nl"]="StartFilm",
+ ["pe"]="شروعفیلم",
+ ["ro"]="StartFilm",
},
- ["february"]={
- ["cs"]="unor",
- ["de"]="februar",
- ["en"]="february",
- ["fr"]="fevrier",
- ["it"]="febbraio",
- ["nl"]="februari",
- ["pe"]="فوریه",
- ["ro"]="februarie",
+ ["StartRendering"]={
+ ["cs"]="StartRendering",
+ ["de"]="StartRendering",
+ ["en"]="StartRendering",
+ ["fr"]="débutRendu",
+ ["it"]="StartRendering",
+ ["nl"]="StartRendering",
+ ["pe"]="شروعتعبیر",
+ ["ro"]="StartRendering",
},
- ["field"]={
- ["en"]="field",
- ["nl"]="veld",
+ ["StartSound"]={
+ ["cs"]="StartZvuk",
+ ["de"]="StartSound",
+ ["en"]="StartSound",
+ ["fr"]="débutSon",
+ ["it"]="IniziaSuono",
+ ["nl"]="StartGeluid",
+ ["pe"]="شروعصدا",
+ ["ro"]="StartSunet",
},
- ["figure"]={
- ["cs"]="obrazek",
- ["de"]="abbildung",
- ["en"]="figure",
- ["fr"]="figure",
- ["it"]="figura",
- ["nl"]="figuur",
- ["pe"]="شکل",
- ["ro"]="figura",
+ ["StopMovie"]={
+ ["cs"]="ZastavitFilm",
+ ["de"]="StopFilm",
+ ["en"]="StopMovie",
+ ["fr"]="FinFilm",
+ ["it"]="FermaFilm",
+ ["nl"]="StopFilm",
+ ["pe"]="پایانفیلم",
+ ["ro"]="StopFilm",
+ },
+ ["StopRendering"]={
+ ["cs"]="StopRendering",
+ ["de"]="StopRendering",
+ ["en"]="StopRendering",
+ ["fr"]="FinRendu",
+ ["it"]="StopRendering",
+ ["nl"]="StopRendering",
+ ["pe"]="پایانتعبیر",
+ ["ro"]="StopRendering",
+ },
+ ["StopSound"]={
+ ["cs"]="StopZvuk",
+ ["de"]="StopSound",
+ ["en"]="StopSound",
+ ["fr"]="FinSon",
+ ["it"]="FermaSuono",
+ ["nl"]="StopGeluid",
+ ["pe"]="پایانصدا",
+ ["ro"]="StopSunet",
+ },
+ ["SubmitForm"]={
+ ["cs"]="PoslatFormular",
+ ["de"]="VersendeFormular",
+ ["en"]="SubmitForm",
+ ["fr"]="SoumettreFormulaire",
+ ["it"]="MandaForm",
+ ["nl"]="VerzendFormulier",
+ ["pe"]="تسلیمفرم",
+ ["ro"]="TrimiteFormular",
+ },
+ ["ToggleLayer"]={
+ ["cs"]="ToggleLayer",
+ ["de"]="ToggleLayer",
+ ["en"]="ToggleLayer",
+ ["fr"]="BasculerCalque",
+ ["it"]="ToggleLayer",
+ ["nl"]="WisselLaag",
+ ["pe"]="تغییرلایه",
+ ["ro"]="ToggleLayer",
+ },
+ ["ToggleViewer"]={
+ ["cs"]="ZmenitProhlizec",
+ ["de"]="WechseleViewer",
+ ["en"]="ToggleViewer",
+ ["fr"]="BasculerVisualisateur",
+ ["it"]="ScambiaVisualizzatore",
+ ["nl"]="WisselViewer",
+ ["pe"]="تغییرنمایشگر",
+ ["ro"]="SchimbaVizualizator",
+ },
+ ["URL"]={
+ ["cs"]="URL",
+ ["de"]="URL",
+ ["en"]="URL",
+ ["fr"]="URL",
+ ["it"]="URL",
+ ["nl"]="URL",
+ ["pe"]="URL",
+ ["ro"]="URL",
+ },
+ ["VideLayer"]={
+ ["cs"]="VideLayer",
+ ["de"]="VideLayer",
+ ["en"]="VideLayer",
+ ["fr"]="VideCalque",
+ ["it"]="VideLayer",
+ ["nl"]="ToonLaag",
+ ["pe"]="VideLayer",
+ ["ro"]="VideLayer",
+ },
+ ["ViewerHelp"]={
+ ["cs"]="NapovedaProhlizece",
+ ["de"]="ViewerHilfe",
+ ["en"]="ViewerHelp",
+ ["fr"]="AideVisualisateur",
+ ["it"]="AiutoVisualizzatore",
+ ["nl"]="ViewerHelp",
+ ["pe"]="کمکنمایشگر",
+ ["ro"]="AjutorVizualizator",
+ },
+ ["WEEKDAY"]={
+ ["cs"]="VSEDNIDEN",
+ ["de"]="WOCHENTAG",
+ ["en"]="WEEKDAY",
+ ["fr"]="JOURSEMAINE",
+ ["it"]="GIORNOSETTIMANA",
+ ["nl"]="WEEKDAG",
+ ["pe"]="روزهفته",
+ ["ro"]="ZISAPTAMANA",
+ },
+ ["WORD"]={
+ ["cs"]="SLOVO",
+ ["de"]="WORT",
+ ["en"]="WORD",
+ ["fr"]="MOT",
+ ["it"]="PAROLA",
+ ["nl"]="WOORD",
+ ["pe"]="کلمه",
+ ["ro"]="CUVANT",
+ },
+ ["WORDS"]={
+ ["cs"]="SLOVA",
+ ["de"]="WOERTER",
+ ["en"]="WORDS",
+ ["fr"]="MOTS",
+ ["it"]="PAROLE",
+ ["nl"]="WOORDEN",
+ ["pe"]="WORDS",
+ ["ro"]="CUVINTE",
+ },
+ ["Word"]={
+ ["cs"]="Slovo",
+ ["de"]="Wort",
+ ["en"]="Word",
+ ["fr"]="Mot",
+ ["it"]="Parola",
+ ["nl"]="Woord",
+ ["pe"]="Word",
+ ["ro"]="Cuvant",
+ },
+ ["Words"]={
+ ["cs"]="Slova",
+ ["de"]="Woerter",
+ ["en"]="Words",
+ ["fr"]="Mots",
+ ["it"]="Parole",
+ ["nl"]="Woorden",
+ ["pe"]="Words",
+ ["ro"]="Cuvinte",
+ },
+ ["abbreviation"]={
+ ["cs"]="zkratka",
+ ["de"]="abkuerzung",
+ ["en"]="abbreviation",
+ ["fr"]="abreviation",
+ ["it"]="abbreviazione",
+ ["nl"]="afkorting",
+ ["pe"]="اختصار",
+ ["ro"]="abreviere",
+ },
+ ["abbreviations"]={
+ ["cs"]="zkratky",
+ ["de"]="abkuerzungen",
+ ["en"]="abbreviations",
+ ["fr"]="abreviations",
+ ["it"]="abbreviazioni",
+ ["nl"]="afkortingen",
+ ["pe"]="اختصارات",
+ ["ro"]="abrevieri",
+ },
+ ["absolute"]={
+ ["cs"]="absolutni",
+ ["de"]="absolut",
+ ["en"]="absolute",
+ ["fr"]="absolu",
+ ["it"]="assoluto",
+ ["nl"]="absoluut",
+ ["pe"]="قطعی",
+ ["ro"]="absolut",
+ },
+ ["action"]={
+ ["cs"]="akce",
+ ["de"]="aktion",
+ ["en"]="action",
+ ["fr"]="action",
+ ["it"]="azione",
+ ["nl"]="actie",
+ ["pe"]="کنش",
+ ["ro"]="actiune",
+ },
+ ["after"]={
+ ["cs"]="po",
+ ["de"]="nach",
+ ["en"]="after",
+ ["fr"]="après",
+ ["it"]="dopo",
+ ["nl"]="na",
+ ["pe"]="بعداز",
+ ["ro"]="dupa",
+ },
+ ["all"]={
+ ["cs"]="vse",
+ ["de"]="alles",
+ ["en"]="all",
+ ["fr"]="tout",
+ ["it"]="tutti",
+ ["nl"]="alles",
+ ["pe"]="همه",
+ ["ro"]="tot",
+ },
+ ["alphabetic"]={
+ ["en"]="alphabetic",
+ ["fr"]="Alphabetique",
+ },
+ ["always"]={
+ ["cs"]="vzdy",
+ ["de"]="immer",
+ ["en"]="always",
+ ["fr"]="toujours",
+ ["it"]="sempre",
+ ["nl"]="altijd",
+ ["pe"]="همواره",
+ ["ro"]="totdeauna",
+ },
+ ["anchor"]={
+ ["en"]="anchor",
+ ["fr"]="ancre",
+ ["nl"]="anker",
+ },
+ ["and"]={
+ ["de"]="und",
+ ["en"]="and",
+ ["fr"]="et",
+ ["nl"]="en",
+ },
+ ["answerarea"]={
+ ["cs"]="answerarea",
+ ["de"]="answerarea",
+ ["en"]="answerarea",
+ ["fr"]="zonereponse",
+ ["it"]="answerarea",
+ ["nl"]="antwoordgebied",
+ ["pe"]="answerarea",
+ ["ro"]="answerarea",
+ },
+ ["appendices"]={
+ ["cs"]="dodatky",
+ ["de"]="anhaenge",
+ ["en"]="appendices",
+ ["fr"]="annexes",
+ ["it"]="appendici",
+ ["nl"]="bijlagen",
+ ["pe"]="پیوستها",
+ ["ro"]="apendixuri",
+ },
+ ["appendix"]={
+ ["cs"]="dodatek",
+ ["de"]="anhang",
+ ["en"]="appendix",
+ ["fr"]="annexe",
+ ["it"]="appendice",
+ ["nl"]="bijlage",
+ ["pe"]="پیوست",
+ ["ro"]="apendix",
+ },
+ ["april"]={
+ ["cs"]="duben",
+ ["de"]="april",
+ ["en"]="april",
+ ["fr"]="avril",
+ ["it"]="aprile",
+ ["nl"]="april",
+ ["pe"]="آوریل",
+ ["ro"]="aprilie",
+ },
+ ["aside"]={
+ ["en"]="aside",
+ ["fr"]="apart",
+ },
+ ["atleftmargin"]={
+ ["cs"]="atleftmargin",
+ ["de"]="atleftmargin",
+ ["en"]="atleftmargin",
+ ["fr"]="enmargegauche",
+ ["it"]="atleftmargin",
+ ["nl"]="oplinkermarge",
+ ["pe"]="درحاشیهچپ",
+ ["ro"]="atleftmargin",
+ },
+ ["atmargin"]={
+ ["cs"]="naokraji",
+ ["de"]="amrand",
+ ["en"]="atmargin",
+ ["fr"]="enmarge",
+ ["it"]="almargine",
+ ["nl"]="opmarge",
+ ["pe"]="درحاشیه",
+ ["ro"]="lamargine",
+ },
+ ["atpage"]={
+ ["cs"]="nastrance",
+ ["de"]="aufseite",
+ ["en"]="atpage",
+ ["fr"]="enpage",
+ ["it"]="apagina",
+ ["nl"]="oppagina",
+ ["pe"]="درصفحه",
+ ["ro"]="lapagina",
+ },
+ ["atrightmargin"]={
+ ["cs"]="atrightmargin",
+ ["de"]="atrightmargin",
+ ["en"]="atrightmargin",
+ ["fr"]="enmargedroite",
+ ["it"]="atrightmargin",
+ ["nl"]="oprechtermarge",
+ ["pe"]="درحاشیهراست",
+ ["ro"]="atrightmargin",
+ },
+ ["attachment"]={
+ ["en"]="attachment",
+ ["fr"]="piecejointe",
+ ["nl"]="aanhangsel",
+ },
+ ["august"]={
+ ["cs"]="srpen",
+ ["de"]="august",
+ ["en"]="august",
+ ["fr"]="aout",
+ ["it"]="agosto",
+ ["nl"]="augustus",
+ ["pe"]="آگوست",
+ ["ro"]="august",
+ },
+ ["author"]={
+ ["cs"]="autor",
+ ["de"]="autor",
+ ["en"]="author",
+ ["fr"]="auteur",
+ ["it"]="autore",
+ ["nl"]="auteur",
+ ["ro"]="autor",
+ },
+ ["auto"]={
+ ["cs"]="auto",
+ ["de"]="auto",
+ ["en"]="auto",
+ ["fr"]="auto",
+ ["it"]="auto",
+ ["nl"]="auto",
+ ["pe"]="خودکار",
+ ["ro"]="auto",
+ },
+ ["autointro"]={
+ ["cs"]="autouvod",
+ ["de"]="autointro",
+ ["en"]="autointro",
+ ["fr"]="autointro",
+ ["it"]="autointro",
+ ["nl"]="autointro",
+ ["pe"]="پیشگفتارخودکار",
+ ["ro"]="autointro",
+ },
+ ["autopunctuation"]={
+ ["en"]="autopunctuation",
+ ["fr"]="autoponctuation",
+ },
+ ["back"]={
+ ["cs"]="zpet",
+ ["de"]="zurueck",
+ ["en"]="back",
+ ["fr"]="retour",
+ ["it"]="dietro",
+ ["nl"]="terug",
+ ["pe"]="پشت",
+ ["ro"]="inapot",
+ },
+ ["background"]={
+ ["cs"]="pozadi",
+ ["de"]="hintergrund",
+ ["en"]="background",
+ ["fr"]="arriereplan",
+ ["it"]="sfondo",
+ ["nl"]="achtergrond",
+ ["pe"]="پسزمینه",
+ ["ro"]="fundal",
+ },
+ ["backmatter"]={
+ ["cs"]="epilogy",
+ ["de"]="epiloge",
+ ["en"]="backmatter",
+ ["fr"]="pagesdefin",
+ ["it"]="postambolo",
+ ["nl"]="uitleidingen",
+ ["pe"]="پسمطلب",
+ ["ro"]="epilogul",
+ },
+ ["backpart"]={
+ ["cs"]="epilog",
+ ["de"]="epilog",
+ ["en"]="backpart",
+ ["fr"]="postface",
+ ["it"]="postfazione",
+ ["nl"]="uitleiding",
+ ["pe"]="پسقسمت",
+ ["ro"]="epilog",
+ },
+ ["backspace"]={
+ ["cs"]="zpetnamezera",
+ ["de"]="rumpfspatium",
+ ["en"]="backspace",
+ ["fr"]="retourarrière",
+ ["it"]="backspace",
+ ["nl"]="rugwit",
+ ["pe"]="فضایپشت",
+ ["ro"]="spatiuspate",
+ },
+ ["backward"]={
+ ["cs"]="zpet",
+ ["de"]="rueckwaerts",
+ ["en"]="backward",
+ ["fr"]="enarriere",
+ ["it"]="indietro",
+ ["nl"]="achteruit",
+ ["pe"]="عقبگرد",
+ ["ro"]="inapoi",
+ },
+ ["bbl"]={
+ ["en"]="bbl",
+ ["fr"]="bbl",
+ },
+ ["before"]={
+ ["cs"]="pred",
+ ["de"]="vor",
+ ["en"]="before",
+ ["fr"]="avant",
+ ["it"]="prima",
+ ["nl"]="voor",
+ ["pe"]="قبلاز",
+ ["ro"]="inainte",
},
- ["figures"]={
- ["cs"]="obrazky",
- ["de"]="abbildungen",
- ["en"]="figures",
- ["fr"]="figures",
- ["it"]="figure",
- ["nl"]="figuren",
- ["pe"]="شکلها",
- ["ro"]="figure",
+ ["begin"]={
+ ["en"]="begin",
+ ["fr"]="commencer",
+ ["nl"]="begin",
},
- ["file"]={
- ["cs"]="soubor",
- ["de"]="datei",
- ["en"]="file",
- ["fr"]="fichier",
- ["it"]="file",
- ["nl"]="file",
- ["pe"]="پرونده",
- ["ro"]="fisier",
+ ["bib"]={
+ ["en"]="bib",
+ ["fr"]="bib",
},
- ["final"]={
- ["cs"]="finalni",
- ["de"]="endfassung",
- ["en"]="final",
- ["fr"]="final",
- ["it"]="finale",
- ["nl"]="definitief",
- ["pe"]="نهایی",
- ["ro"]="final",
+ ["big"]={
+ ["cs"]="velke",
+ ["de"]="gross",
+ ["en"]="big",
+ ["fr"]="important",
+ ["it"]="grande",
+ ["nl"]="groot",
+ ["pe"]="بزرگ",
+ ["ro"]="mare",
},
- ["first"]={
- ["cs"]="prvni",
- ["de"]="erste",
- ["en"]="first",
- ["fr"]="premier",
- ["it"]="primo",
- ["nl"]="eerste",
- ["pe"]="اولی",
- ["ro"]="primul",
+ ["bigbodyfont"]={
+ ["cs"]="bigbodyfont",
+ ["de"]="bigbodyfont",
+ ["en"]="bigbodyfont",
+ ["fr"]="policedecorpsimportante",
+ ["it"]="grossofontdeltesto",
+ ["nl"]="grootkorps",
+ ["pe"]="قلمبدنهبزرگ",
+ ["ro"]="bigbodyfont",
},
- ["firstcolumn"]={
- ["cs"]="firstcolumn",
- ["de"]="firstcolumn",
- ["en"]="firstcolumn",
- ["fr"]="premierecolonne",
- ["it"]="firstcolumn",
- ["nl"]="eerstekolom",
- ["pe"]="ستوناول",
- ["ro"]="firstcolumn",
+ ["bigger"]={
+ ["en"]="bigger",
+ ["fr"]="plusimportant",
+ ["nl"]="groter",
},
- ["firstpage"]={
- ["cs"]="prvnistranka",
- ["de"]="ersteseite",
- ["en"]="firstpage",
- ["fr"]="premierepage",
- ["it"]="primapagina",
- ["nl"]="eerstepagina",
- ["pe"]="صفحهاول",
- ["ro"]="primapagina",
+ ["bigpreference"]={
+ ["cs"]="vysokapriorita",
+ ["de"]="grosszuegig",
+ ["en"]="bigpreference",
+ ["fr"]="preferenceimportante",
+ ["it"]="grandepreferenza",
+ ["nl"]="grotevoorkeur",
+ ["pe"]="اولویتبزرگ",
+ ["ro"]="preferintamare",
},
- ["firstsubpage"]={
- ["cs"]="prvnipodstranka",
- ["de"]="ersteunterseite",
- ["en"]="firstsubpage",
- ["fr"]="premieresouspage",
- ["it"]="primasottopagina",
- ["nl"]="eerstesubpagina",
- ["pe"]="زیرصفحهاول",
- ["ro"]="primasubpagina",
+ ["blank"]={
+ ["cs"]="prazdny",
+ ["de"]="blanko",
+ ["en"]="blank",
+ ["fr"]="vierge",
+ ["it"]="rigovuoto",
+ ["nl"]="blanko",
+ ["pe"]="خالی",
+ ["ro"]="blank",
},
- ["fit"]={
- ["cs"]="prizpusobive",
- ["de"]="passend",
- ["en"]="fit",
- ["fr"]="adapte",
- ["it"]="adatta",
- ["nl"]="passend",
- ["pe"]="پرکردن",
- ["ro"]="ajustat",
+ ["block"]={
+ ["en"]="block",
+ ["fr"]="bloc",
},
- ["five"]={
- ["cs"]="pet",
- ["de"]="fuenf",
- ["en"]="five",
- ["fr"]="cinq",
- ["it"]="cinque",
- ["nl"]="vijf",
- ["pe"]="پنج",
- ["ro"]="cinci",
+ ["blockquote"]={
+ ["cs"]="blockquote",
+ ["de"]="blockquote",
+ ["en"]="blockquote",
+ ["fr"]="citerbloc",
+ ["it"]="blockquote",
+ ["nl"]="blokcitaat",
+ ["pe"]="نقلبلوک",
+ ["ro"]="blockquote",
},
- ["six"]={
- ["cs"]="six",
- ["de"]="sechs",
- ["en"]="six",
- ["fr"]="six",
- ["it"]="six",
- ["nl"]="zes",
- ["pe"]="six",
- ["ro"]="six",
+ ["bodymatter"]={
+ ["cs"]="hlavnicasti",
+ ["de"]="haupttexte",
+ ["en"]="bodymatter",
+ ["fr"]="pagescorpsdetexte",
+ ["it"]="testiprincipali",
+ ["nl"]="hoofdteksten",
+ ["pe"]="مطلببدنه",
+ ["ro"]="principalul",
+ },
+ ["bodypart"]={
+ ["cs"]="hlavnicast",
+ ["de"]="haupttext",
+ ["en"]="bodypart",
+ ["fr"]="corpsdetexte",
+ ["it"]="testoprincipale",
+ ["nl"]="hoofdtekst",
+ ["pe"]="قسمتبدنه",
+ ["ro"]="principal",
+ },
+ ["bold"]={
+ ["cs"]="tucne",
+ ["de"]="fett",
+ ["en"]="bold",
+ ["fr"]="gras",
+ ["it"]="grassetto",
+ ["nl"]="vet",
+ ["pe"]="مشکی",
+ ["ro"]="aldin",
+ },
+ ["bolditalic"]={
+ ["cs"]="tucnekurzivni",
+ ["de"]="fettitalic",
+ ["en"]="bolditalic",
+ ["fr"]="grasitalique",
+ ["it"]="grassettocorsivo",
+ ["nl"]="vetitalic",
+ ["pe"]="ایتالیکمشکی",
+ ["ro"]="aldinitalic",
+ },
+ ["boldslanted"]={
+ ["cs"]="tucnesklonene",
+ ["de"]="fettgeneigt",
+ ["en"]="boldslanted",
+ ["fr"]="grasincline",
+ ["it"]="grassettoinclinato",
+ ["nl"]="vetschuin",
+ ["pe"]="خوابیدهمشکی",
+ ["ro"]="aldininclinat",
+ },
+ ["bookmark"]={
+ ["cs"]="zalozka",
+ ["de"]="bookmark",
+ ["en"]="bookmark",
+ ["fr"]="marquepage",
+ ["it"]="segnalibro",
+ ["nl"]="bookmark",
+ ["pe"]="چوبخط",
+ ["ro"]="semncarte",
+ },
+ ["both"]={
+ ["cs"]="obe",
+ ["de"]="beide",
+ ["en"]="both",
+ ["fr"]="chacun",
+ ["it"]="entrambi",
+ ["nl"]="beide",
+ ["pe"]="هردو",
+ ["ro"]="ambele",
+ },
+ ["bothtext"]={
+ ["en"]="bothtext",
+ ["fr"]="textechacun",
+ },
+ ["bottom"]={
+ ["cs"]="spodek",
+ ["de"]="unten",
+ ["en"]="bottom",
+ ["fr"]="bas",
+ ["it"]="fondo",
+ ["nl"]="onder",
+ ["pe"]="پایین",
+ ["ro"]="subsol",
+ },
+ ["box"]={
+ ["en"]="box",
+ ["fr"]="boite",
+ },
+ ["brief"]={
+ ["cs"]="brief",
+ ["de"]="brief",
+ ["en"]="brief",
+ ["fr"]="brief",
+ ["it"]="brief",
+ ["nl"]="brief",
+ ["pe"]="مختصر",
+ ["ro"]="brief",
+ },
+ ["broad"]={
+ ["cs"]="siroky",
+ ["de"]="breit",
+ ["en"]="broad",
+ ["fr"]="large",
+ ["it"]="ampio",
+ ["nl"]="ruim",
+ ["pe"]="گسترده",
+ ["ro"]="broad",
+ },
+ ["buffer"]={
+ ["cs"]="buffer",
+ ["de"]="puffer",
+ ["en"]="buffer",
+ ["fr"]="tampon",
+ ["it"]="buffer",
+ ["nl"]="buffer",
+ ["pe"]="بافر",
+ ["ro"]="buffer",
+ },
+ ["by"]={
+ ["cs"]="skrz",
+ ["de"]="pro",
+ ["en"]="by",
+ ["fr"]="par",
+ ["it"]="da",
+ ["nl"]="per",
+ ["pe"]="بوسیله",
+ ["ro"]="de",
},
- ["seven"]={
- ["cs"]="seven",
- ["de"]="sieben",
- ["en"]="seven",
- ["fr"]="seven",
- ["it"]="seven",
- ["nl"]="zeven",
- ["pe"]="seven",
- ["ro"]="seven",
+ ["calligraphic"]={
+ ["cs"]="kaligraficke",
+ ["de"]="kalligraphie",
+ ["en"]="calligraphic",
+ ["fr"]="calligraphique",
+ ["it"]="calligrafico",
+ ["nl"]="calligrafie",
+ ["pe"]="خوشنویسی",
+ ["ro"]="caligrafic",
},
- ["eight"]={
- ["cs"]="eight",
- ["de"]="acht",
- ["en"]="eight",
- ["fr"]="eight",
- ["it"]="eight",
- ["nl"]="acht",
- ["pe"]="eight",
- ["ro"]="eight",
+ ["camel"]={
+ ["en"]="camel",
+ ["fr"]="camel",
},
- ["nine"]={
- ["cs"]="nine",
- ["de"]="neun",
- ["en"]="nine",
- ["fr"]="nine",
- ["it"]="nine",
- ["nl"]="negen",
- ["pe"]="nine",
- ["ro"]="nine",
+ ["cap"]={
+ ["cs"]="kap",
+ ["de"]="kap",
+ ["en"]="cap",
+ ["fr"]="cap",
+ ["it"]="cap",
+ ["nl"]="kap",
+ ["pe"]="cap",
+ ["ro"]="cap",
},
- ["fix"]={
- ["cs"]="fixuj",
- ["de"]="stellewiederher",
- ["en"]="fix",
- ["fr"]="fixe",
- ["it"]="fisso",
- ["nl"]="herstel",
- ["pe"]="ثابتکن",
- ["ro"]="fix",
+ ["capital"]={
+ ["cs"]="kapitalky",
+ ["de"]="versalien",
+ ["en"]="capital",
+ ["fr"]="capitales",
+ ["it"]="maiuscolo",
+ ["nl"]="kapitaal",
+ ["pe"]="capital",
+ ["ro"]="majuscula",
},
- ["fixed"]={
- ["cs"]="fixne",
- ["de"]="fest",
- ["en"]="fixed",
- ["fr"]="fixe",
- ["it"]="fisso",
- ["nl"]="vast",
- ["pe"]="ثابت",
- ["ro"]="fixat",
+ ["category"]={
+ ["en"]="category",
+ ["fr"]="categorie",
},
- ["flexible"]={
- ["cs"]="prizpusobive",
- ["de"]="flexibel",
- ["en"]="flexible",
- ["fr"]="flexible",
- ["it"]="flessibile",
- ["nl"]="flexibel",
- ["pe"]="انعطافپذیر",
- ["ro"]="flexibil",
+ ["cd:character"]={
+ ["en"]="cd:character",
+ ["fr"]="caracteres",
},
- ["float"]={
- ["cs"]="plvouciobjekt",
- ["de"]="gleitobjekt",
- ["en"]="float",
- ["fr"]="flottant",
- ["it"]="oggettomobile",
- ["nl"]="blok",
- ["pe"]="شناور",
- ["ro"]="obiectmobil",
+ ["cd:font"]={
+ ["en"]="cd:font",
+ ["fr"]="police",
},
- ["flushinner"]={
- ["cs"]="flushinner",
- ["de"]="flushinner",
- ["en"]="flushinner",
- ["fr"]="flushinner",
- ["it"]="flushinner",
- ["nl"]="lijnbinnen",
- ["pe"]="پمپداخلی",
- ["ro"]="flushinner",
+ ["center"]={
+ ["cs"]="center",
+ ["de"]="center",
+ ["en"]="center",
+ ["fr"]="centrer",
+ ["it"]="center",
+ ["nl"]="centreer",
+ ["pe"]="مرکز",
+ ["ro"]="center",
},
- ["flushleft"]={
- ["cs"]="flushleft",
- ["de"]="flushleft",
- ["en"]="flushleft",
- ["fr"]="flushleft",
- ["it"]="flushleft",
- ["nl"]="lijnlinks",
- ["pe"]="پمپچپ",
- ["ro"]="flushleft",
+ ["centerlast"]={
+ ["en"]="centerlast",
+ ["fr"]="centrerdernier",
},
- ["flushouter"]={
- ["cs"]="flushouter",
- ["de"]="flushouter",
- ["en"]="flushouter",
- ["fr"]="flushouter",
- ["it"]="flushouter",
- ["nl"]="lijnbuiten",
- ["pe"]="پمپخارجی",
- ["ro"]="flushouter",
+ ["chapter"]={
+ ["cs"]="kapitola",
+ ["de"]="kapitel",
+ ["en"]="chapter",
+ ["fr"]="chapitre",
+ ["it"]="capitolo",
+ ["nl"]="hoofdstuk",
+ ["pe"]="فصل",
+ ["ro"]="capitol",
},
- ["flushright"]={
- ["cs"]="flushright",
- ["de"]="flushright",
- ["en"]="flushright",
- ["fr"]="flushright",
- ["it"]="flushright",
- ["nl"]="lijnrechts",
- ["pe"]="پمپراست",
- ["ro"]="flushright",
+ ["character"]={
+ ["cs"]="pismeno",
+ ["de"]="buchstabe",
+ ["en"]="character",
+ ["fr"]="caractere",
+ ["it"]="lettera",
+ ["nl"]="letter",
+ ["pe"]="حرف",
+ ["ro"]="caracter",
},
- ["followingpage"]={
- ["en"]="followingpage",
- ["nl"]="opvolgendepagina",
+ ["characters"]={
+ ["cs"]="pismena",
+ ["de"]="buchstaben",
+ ["en"]="characters",
+ ["fr"]="caracteres",
+ ["it"]="lettere",
+ ["nl"]="letters",
+ ["pe"]="حرفها",
+ ["ro"]="caractere",
},
- ["footer"]={
- ["cs"]="upati",
- ["de"]="fusszeile",
- ["en"]="footer",
- ["fr"]="pdp",
- ["it"]="piedipagina",
- ["nl"]="voet",
- ["pe"]="تهبرگ",
- ["ro"]="subsol",
+ ["chemical"]={
+ ["en"]="chemical",
+ ["fr"]="chimique",
},
- ["footnote"]={
- ["cs"]="poznamkapodcarou",
- ["de"]="fussnote",
- ["en"]="footnote",
- ["fr"]="notepdp",
- ["it"]="notapdp",
- ["nl"]="voetnoot",
- ["pe"]="پانوشت",
- ["ro"]="notasubsol",
+ ["chemicals"]={
+ ["en"]="chemicals",
+ ["fr"]="chimiques",
},
- ["force"]={
- ["cs"]="sila",
- ["de"]="zwinge",
- ["en"]="force",
- ["fr"]="force",
- ["it"]="forza",
- ["nl"]="forceer",
- ["pe"]="اجبار",
- ["ro"]="fortat",
+ ["chemistry"]={
+ ["en"]="chemistry",
+ ["fr"]="chimie",
+ ["nl"]="chemie",
},
- ["foreground"]={
- ["cs"]="popredi",
- ["de"]="vordergrund",
- ["en"]="foreground",
- ["fr"]="premierplan",
- ["it"]="foreground",
- ["nl"]="voorgrond",
- ["pe"]="پیشزمینه",
- ["ro"]="primplan",
+ ["cite"]={
+ ["en"]="cite",
+ ["fr"]="cite",
},
- ["formula"]={
- ["cs"]="rovnice",
- ["de"]="formel",
- ["en"]="formula",
- ["fr"]="formule",
- ["it"]="formula",
- ["nl"]="formule",
- ["pe"]="فرمول",
- ["ro"]="formula",
+ ["closed"]={
+ ["en"]="closed",
+ ["fr"]="ferme",
+ ["nl"]="gesloten",
},
- ["formulas"]={
- ["cs"]="rovnice",
- ["de"]="formeln",
- ["en"]="formulas",
- ["fr"]="formules",
- ["it"]="formule",
- ["nl"]="formules",
- ["pe"]="فرمولها",
- ["ro"]="formule",
+ ["color"]={
+ ["cs"]="barevne",
+ ["de"]="farbe",
+ ["en"]="color",
+ ["fr"]="couleur",
+ ["it"]="colore",
+ ["nl"]="kleur",
+ ["pe"]="رنگ",
+ ["ro"]="culoare",
},
- ["forward"]={
- ["cs"]="vpred",
- ["de"]="vorwaerts",
- ["en"]="forward",
- ["fr"]="avance",
- ["it"]="avanti",
- ["nl"]="vooruit",
- ["pe"]="بهجلو",
- ["ro"]="avans",
+ ["column"]={
+ ["cs"]="column",
+ ["de"]="column",
+ ["en"]="column",
+ ["fr"]="colonne",
+ ["it"]="colonna",
+ ["nl"]="kolom",
+ ["pe"]="ستون",
+ ["ro"]="coloana",
},
- ["four"]={
- ["cs"]="ctyri",
- ["de"]="vier",
- ["en"]="four",
- ["fr"]="quatre",
- ["it"]="quattro",
- ["nl"]="vier",
- ["pe"]="چهار",
- ["ro"]="patru",
+ ["columns"]={
+ ["cs"]="sloupce",
+ ["de"]="spalten",
+ ["en"]="columns",
+ ["fr"]="colonnes",
+ ["it"]="colonne",
+ ["nl"]="kolommen",
+ ["pe"]="ستونها",
+ ["ro"]="coloane",
},
- ["frame"]={
- ["cs"]="ramecek",
- ["de"]="rahmen",
- ["en"]="frame",
- ["fr"]="cadre",
- ["it"]="cornice",
- ["nl"]="kader",
- ["pe"]="قالب",
- ["ro"]="incadrat",
+ ["combination"]={
+ ["en"]="combination",
+ ["fr"]="combinaison",
+ ["nl"]="combinatie",
},
- ["framedtext"]={
- ["cs"]="oramovanytext",
- ["de"]="umrahmtertext",
- ["en"]="framedtext",
- ["fr"]="texteencadre",
- ["it"]="testoincorniciato",
- ["nl"]="kadertekst",
- ["pe"]="متنقالبی",
- ["ro"]="textinconjurat",
+ ["command"]={
+ ["cs"]="prikaz",
+ ["de"]="befehl",
+ ["en"]="command",
+ ["fr"]="commande",
+ ["it"]="comando",
+ ["nl"]="commando",
+ ["pe"]="فرمان",
+ ["ro"]="comanda",
},
- ["friday"]={
- ["cs"]="patek",
- ["de"]="freitag",
- ["en"]="friday",
- ["fr"]="vendredi",
- ["it"]="venerdi",
- ["nl"]="vrijdag",
- ["pe"]="جمعه",
- ["ro"]="vineri",
+ ["commands"]={
+ ["cs"]="prikazy",
+ ["de"]="befehle",
+ ["en"]="commands",
+ ["fr"]="commandes",
+ ["it"]="comandi",
+ ["nl"]="commandos",
+ ["pe"]="فرمانها",
+ ["ro"]="comenzi",
},
- ["frontmatter"]={
- ["cs"]="prednicasti",
- ["de"]="einleitungen",
- ["en"]="frontmatter",
- ["fr"]="preambule",
- ["it"]="preambolo",
- ["nl"]="inleidingen",
- ["pe"]="پیشمطلب",
- ["ro"]="prologul",
+ ["comment"]={
+ ["cs"]="komentar",
+ ["de"]="kommentar",
+ ["en"]="comment",
+ ["fr"]="commentaire",
+ ["it"]="commento",
+ ["nl"]="commentaar",
+ ["pe"]="توضیح",
+ ["ro"]="comentariu",
},
- ["frontpart"]={
- ["cs"]="prednicast",
- ["de"]="einleitung",
- ["en"]="frontpart",
- ["fr"]="preface",
- ["it"]="prefazione",
- ["nl"]="inleiding",
- ["pe"]="پیشقسمت",
- ["ro"]="prolog",
+ ["component"]={
+ ["cs"]="komponenta",
+ ["de"]="komponente",
+ ["en"]="component",
+ ["fr"]="composant",
+ ["it"]="componente",
+ ["nl"]="onderdeel",
+ ["pe"]="مولفه",
+ ["ro"]="componenta",
},
- ["fullhz"]={
- ["cs"]="fullhz",
- ["de"]="fullhz",
- ["en"]="fullhz",
- ["fr"]="fullhz",
- ["it"]="fullhz",
- ["nl"]="fullenhz",
- ["pe"]="fullhz",
- ["ro"]="fullhz",
+ ["compressseparator"]={
+ ["en"]="compressseparator",
+ ["fr"]="separateurreduction",
},
- ["global"]={
- ["cs"]="globalne",
- ["de"]="global",
- ["en"]="global",
- ["fr"]="global",
- ["it"]="globale",
- ["nl"]="globaal",
- ["pe"]="سراسری",
- ["ro"]="global",
+ ["compressstopper"]={
+ ["en"]="compressstopper",
+ ["fr"]="stoppeurreduction",
},
- ["graphic"]={
- ["cs"]="graf",
- ["de"]="grafik",
- ["en"]="graphic",
- ["fr"]="graphique",
- ["it"]="grafico",
- ["nl"]="grafiek",
- ["pe"]="گرافیک",
- ["ro"]="graficul",
+ ["concept"]={
+ ["cs"]="koncept",
+ ["de"]="konzept",
+ ["en"]="concept",
+ ["fr"]="concept",
+ ["it"]="concetto",
+ ["nl"]="concept",
+ ["pe"]="مفهوم",
+ ["ro"]="concept",
},
- ["graphics"]={
- ["cs"]="grafy",
- ["de"]="grafiken",
- ["en"]="graphics",
- ["fr"]="graphiques",
- ["it"]="grafici",
- ["nl"]="grafieken",
- ["pe"]="گرافیکها",
- ["ro"]="graficele",
+ ["construction"]={
+ ["en"]="construction",
+ ["fr"]="construction",
},
- ["gray"]={
- ["cs"]="seda",
- ["de"]="grau",
- ["en"]="gray",
- ["fr"]="gris",
- ["it"]="grigio",
- ["nl"]="grijs",
- ["pe"]="خاکستری",
- ["ro"]="gri",
+ ["content"]={
+ ["cs"]="obsah",
+ ["de"]="inhalt",
+ ["en"]="content",
+ ["fr"]="contenu",
+ ["it"]="indice",
+ ["nl"]="inhoud",
+ ["pe"]="محتوا",
+ ["ro"]="cuprins",
},
- ["greek"]={
- ["cs"]="recky",
- ["de"]="griechisch",
- ["en"]="greek",
- ["fr"]="grec",
- ["it"]="greco",
- ["nl"]="grieks",
- ["pe"]="یونانی",
- ["ro"]="grec",
+ ["contents"]={
+ ["cs"]="obsah",
+ ["de"]="inhalte",
+ ["en"]="contents",
+ ["fr"]="contenus",
+ ["it"]="indici",
+ ["nl"]="inhouden",
+ ["pe"]="محتویات",
+ ["ro"]="cuprinsuri",
},
- ["grid"]={
- ["cs"]="mrizka",
- ["de"]="gritter",
- ["en"]="grid",
- ["fr"]="grille",
- ["it"]="griglia",
- ["nl"]="grid",
- ["pe"]="توری",
- ["ro"]="grila",
+ ["continue"]={
+ ["cs"]="pokracovat",
+ ["de"]="fortsetzten",
+ ["en"]="continue",
+ ["fr"]="continuer",
+ ["it"]="continua",
+ ["nl"]="verder",
+ ["pe"]="ادامه",
+ ["ro"]="continuu",
},
- ["halfline"]={
- ["cs"]="pulradku",
- ["de"]="halbezeile",
- ["en"]="halfline",
- ["fr"]="demiligne",
- ["it"]="mezzariga",
- ["nl"]="halveregel",
- ["pe"]="نیمخط",
- ["ro"]="jumatatelinie",
+ ["continued"]={
+ ["en"]="continued",
+ ["fr"]="continue",
+ ["nl"]="vervolgd",
},
- ["handwritten"]={
- ["cs"]="rukopisne",
- ["de"]="handschrift",
- ["en"]="handwritten",
- ["fr"]="manuscript",
- ["it"]="grafiamanuale",
- ["nl"]="handschrift",
- ["pe"]="دستنوشته",
- ["ro"]="scrismanual",
+ ["controls"]={
+ ["cs"]="controls",
+ ["de"]="controls",
+ ["en"]="controls",
+ ["fr"]="controles",
+ ["it"]="controlli",
+ ["nl"]="sturing",
+ ["pe"]="کنترلها",
+ ["ro"]="controale",
},
- ["hang"]={
- ["cs"]="zaveseni",
- ["de"]="haengend",
- ["en"]="hang",
- ["fr"]="suspend",
- ["it"]="sospendi",
- ["nl"]="hang",
- ["pe"]="بیاویز",
- ["ro"]="suspenda",
+ ["conversion"]={
+ ["cs"]="konverze",
+ ["de"]="konversion",
+ ["en"]="conversion",
+ ["fr"]="conversion",
+ ["it"]="coversione",
+ ["nl"]="conversie",
+ ["pe"]="تبدیل",
+ ["ro"]="conversie",
},
- ["hanging"]={
- ["cs"]="visici",
- ["de"]="haengend",
- ["en"]="hanging",
- ["fr"]="suspend",
- ["it"]="sospeso",
- ["nl"]="hangend",
- ["pe"]="آویزان",
- ["ro"]="suspendat",
+ ["current"]={
+ ["cs"]="aktualni",
+ ["de"]="aktuell",
+ ["en"]="current",
+ ["fr"]="courant",
+ ["it"]="corrente",
+ ["nl"]="huidige",
+ ["pe"]="جاری",
+ ["ro"]="curent",
},
- ["hangingboth"]={
- ["en"]="hangingboth",
- ["nl"]="beidehangend",
+ ["cutspace"]={
+ ["cs"]="cutspace",
+ ["de"]="cutspace",
+ ["en"]="cutspace",
+ ["fr"]="espacecoupe",
+ ["it"]="cutspace",
+ ["nl"]="snijwit",
+ ["pe"]="فضایبرش",
+ ["ro"]="cutspace",
},
- ["head"]={
- ["cs"]="hlavicka",
- ["de"]="kopf",
- ["en"]="head",
- ["fr"]="tete",
- ["it"]="testa",
- ["nl"]="kop",
- ["pe"]="سر",
- ["ro"]="antet",
+ ["dataset"]={
+ ["en"]="dataset",
+ ["fr"]="jeudedonnees",
},
- ["header"]={
- ["cs"]="zahlavi",
- ["de"]="kopfzeile",
- ["en"]="header",
- ["fr"]="entete",
- ["it"]="intestazione",
- ["nl"]="hoofd",
- ["pe"]="سربرگ",
- ["ro"]="antet",
+ ["date"]={
+ ["cs"]="datum",
+ ["de"]="datum",
+ ["en"]="date",
+ ["fr"]="date",
+ ["it"]="data",
+ ["nl"]="datum",
+ ["pe"]="تاریخ",
+ ["ro"]="data",
},
- ["height"]={
- ["cs"]="vyska",
- ["de"]="hoehe",
- ["en"]="height",
- ["fr"]="hauteur",
- ["it"]="altezza",
- ["nl"]="hoogte",
- ["pe"]="ارتفاع",
- ["ro"]="inaltime",
+ ["day"]={
+ ["cs"]="den",
+ ["de"]="tag",
+ ["en"]="day",
+ ["fr"]="jour",
+ ["it"]="giorno",
+ ["nl"]="dag",
+ ["pe"]="روز",
+ ["ro"]="zi",
},
- ["helptext"]={
- ["cs"]="textnapovedy",
- ["de"]="hilfetext",
- ["en"]="helptext",
- ["fr"]="texteaide",
- ["it"]="testoaiuto",
- ["nl"]="helptekst",
- ["pe"]="متنکمکی",
- ["ro"]="textajutator",
+ ["december"]={
+ ["cs"]="prosinec",
+ ["de"]="dezember",
+ ["en"]="december",
+ ["fr"]="decembre",
+ ["it"]="dicembre",
+ ["nl"]="december",
+ ["pe"]="دسامبر",
+ ["ro"]="decembrie",
},
- ["hencefore"]={
- ["cs"]="vyse",
- ["de"]="vorher",
- ["en"]="hencefore",
- ["fr"]="precedent",
- ["it"]="precedente",
- ["nl"]="hierboven",
- ["pe"]="hencefore",
- ["ro"]="precedent",
+ ["default"]={
+ ["cs"]="implicitni",
+ ["de"]="default",
+ ["en"]="default",
+ ["fr"]="defaut",
+ ["it"]="implicito",
+ ["nl"]="default",
+ ["pe"]="پیشفرض",
+ ["ro"]="implicit",
},
- ["here"]={
- ["cs"]="zde",
- ["de"]="hier",
- ["en"]="here",
- ["fr"]="ici",
- ["it"]="qui",
- ["nl"]="hier",
- ["pe"]="اینجا",
- ["ro"]="aici",
+ ["depth"]={
+ ["cs"]="podlehloubky",
+ ["de"]="tiefe",
+ ["en"]="depth",
+ ["fr"]="profondeur",
+ ["it"]="profondita",
+ ["nl"]="diepte",
+ ["pe"]="عمق",
+ ["ro"]="adancime",
},
- ["hereafter"]={
- ["cs"]="nize",
- ["de"]="nachher",
- ["en"]="hereafter",
- ["fr"]="suivant",
- ["it"]="seguente",
- ["nl"]="hieronder",
- ["pe"]="ازاینبهبعد",
- ["ro"]="urmator",
+ ["description"]={
+ ["cs"]="popis",
+ ["de"]="beschreibung",
+ ["en"]="description",
+ ["fr"]="description",
+ ["it"]="descrizione",
+ ["nl"]="doordefinitie",
+ ["pe"]="شرح",
+ ["ro"]="descriere",
},
- ["hidden"]={
- ["cs"]="skryte",
- ["de"]="versteckt",
- ["en"]="hidden",
- ["fr"]="cache",
- ["it"]="nascosto",
- ["nl"]="verborgen",
- ["pe"]="پنهانی",
- ["ro"]="ascuns",
+ ["disable"]={
+ ["cs"]="zablokovat",
+ ["de"]="sperren",
+ ["en"]="disable",
+ ["fr"]="desactiver",
+ ["it"]="disattiva",
+ ["nl"]="blokkeer",
+ ["pe"]="ناتوان",
+ ["ro"]="dezactivat",
},
- ["hiddenbar"]={
- ["en"]="hiddenbar",
+ ["display"]={
+ ["cs"]="obrazovka",
+ ["de"]="bildschirm",
+ ["en"]="display",
+ ["fr"]="affichage",
+ ["it"]="schermo",
+ ["nl"]="scherm",
+ ["pe"]="نمایش",
+ ["ro"]="display",
},
- ["hiding"]={
- ["cs"]="skryt",
- ["de"]="verbergen",
- ["en"]="hiding",
- ["fr"]="cache",
- ["it"]="nascondere",
- ["nl"]="verbergen",
- ["pe"]="پنهانکردن",
- ["ro"]="ascundere",
+ ["dot"]={
+ ["cs"]="tecka",
+ ["de"]="punkt",
+ ["en"]="dot",
+ ["fr"]="point",
+ ["it"]="punto",
+ ["nl"]="punt",
+ ["pe"]="نقطه",
+ ["ro"]="punct",
},
- ["high"]={
- ["cs"]="vysoko",
- ["de"]="hoch",
- ["en"]="high",
- ["fr"]="haut",
- ["it"]="alto",
- ["nl"]="hoog",
- ["pe"]="بلند",
- ["ro"]="inalt",
+ ["doublesided"]={
+ ["cs"]="dvoustranny",
+ ["de"]="doppelseitig",
+ ["en"]="doublesided",
+ ["fr"]="rectoverso",
+ ["it"]="doppiafaccia",
+ ["nl"]="dubbelzijdig",
+ ["pe"]="دورو",
+ ["ro"]="douafete",
},
- ["horizontal"]={
- ["cs"]="horizontalne",
- ["de"]="horizontal",
- ["en"]="horizontal",
- ["fr"]="horizontale",
- ["it"]="orizzontale",
- ["nl"]="horizontaal",
- ["pe"]="افقی",
- ["ro"]="orizontal",
+ ["down"]={
+ ["en"]="down",
+ ["fr"]="enbas",
+ ["nl"]="omlaag",
},
- ["hyphenated"]={
- ["cs"]="hyphenated",
- ["de"]="hyphenate",
- ["en"]="hyphenated",
- ["fr"]="hyphenated",
- ["it"]="sillabato",
- ["nl"]="afgebroken",
- ["pe"]="شکسته",
- ["ro"]="despsilabe",
+ ["each"]={
+ ["cs"]="kazdy",
+ ["de"]="jede",
+ ["en"]="each",
+ ["fr"]="chaque",
+ ["it"]="ogni",
+ ["nl"]="elk",
+ ["pe"]="هر",
+ ["ro"]="fiecare",
},
- ["hz"]={
- ["cs"]="hz",
- ["de"]="hz",
- ["en"]="hz",
- ["fr"]="hz",
- ["it"]="hz",
- ["nl"]="hz",
- ["pe"]="hz",
- ["ro"]="hz",
+ ["edge"]={
+ ["cs"]="hrana",
+ ["de"]="kante",
+ ["en"]="edge",
+ ["fr"]="bord",
+ ["it"]="bordo",
+ ["nl"]="rand",
+ ["pe"]="لبه",
+ ["ro"]="bordura",
},
- ["inbetween"]={
- ["cs"]="mezi",
- ["de"]="zwischen",
- ["en"]="inbetween",
- ["fr"]="entre",
- ["it"]="tra",
- ["nl"]="tussen",
- ["pe"]="دربین",
- ["ro"]="intre",
+ ["effective"]={
+ ["en"]="effective",
+ ["fr"]="effectif",
+ ["nl"]="effectief",
},
- ["index"]={
- ["cs"]="rejstrik",
- ["de"]="index",
- ["en"]="index",
- ["fr"]="index",
- ["it"]="indiceanalitico",
- ["nl"]="index",
- ["pe"]="نمایه",
- ["ro"]="index",
+ ["eight"]={
+ ["cs"]="eight",
+ ["de"]="acht",
+ ["en"]="eight",
+ ["fr"]="huit",
+ ["it"]="eight",
+ ["nl"]="acht",
+ ["pe"]="eight",
+ ["ro"]="eight",
},
- ["indices"]={
- ["cs"]="rejstriky",
- ["de"]="indizies",
- ["en"]="indices",
- ["fr"]="indices",
- ["it"]="indicianalitici",
- ["nl"]="indices",
- ["pe"]="نمایهها",
- ["ro"]="indexuri",
+ ["embed"]={
+ ["en"]="embed",
+ ["fr"]="integrer",
+ ["nl"]="sluitin",
},
- ["inherit"]={
- ["cs"]="inherit",
- ["de"]="inherit",
- ["en"]="inherit",
- ["fr"]="herite",
- ["it"]="inherit",
- ["nl"]="erf",
- ["pe"]="ارثبردن",
- ["ro"]="inherit",
+ ["empty"]={
+ ["cs"]="prazdne",
+ ["de"]="leer",
+ ["en"]="empty",
+ ["fr"]="vide",
+ ["it"]="vuoto",
+ ["nl"]="leeg",
+ ["pe"]="تهی",
+ ["ro"]="gol",
},
- ["ininner"]={
- ["cs"]="ininner",
- ["de"]="ininner",
- ["en"]="ininner",
- ["fr"]="ininner",
- ["it"]="ininner",
- ["nl"]="inbinnen",
- ["pe"]="درداخلی",
- ["ro"]="ininner",
+ ["enable"]={
+ ["en"]="enable",
+ ["fr"]="activer",
},
- ["ininneredge"]={
- ["en"]="ininneredge",
+ ["end"]={
+ ["en"]="end",
+ ["fr"]="terminer",
+ ["nl"]="eind",
},
- ["ininnermargin"]={
- ["en"]="ininnermargin",
+ ["endnote"]={
+ ["cs"]="endnote",
+ ["de"]="endnote",
+ ["en"]="endnote",
+ ["fr"]="noteseule",
+ ["it"]="endnote",
+ ["nl"]="eindnoot",
+ ["pe"]="تهنوشت",
+ ["ro"]="endnote",
},
- ["inleft"]={
- ["cs"]="ivlevo",
- ["de"]="imlinken",
- ["en"]="inleft",
- ["fr"]="dansgauche",
- ["it"]="insinistra",
- ["nl"]="inlinker",
- ["pe"]="درونچپ",
- ["ro"]="instanga",
+ ["enumeration"]={
+ ["cs"]="vycet",
+ ["de"]="nummerierung",
+ ["en"]="enumeration",
+ ["fr"]="énumération",
+ ["it"]="enumerazione",
+ ["nl"]="doornummering",
+ ["pe"]="شمارهبندی",
+ ["ro"]="enumerare",
},
- ["inleftedge"]={
- ["cs"]="nalevo",
- ["de"]="imlinkenrand",
- ["en"]="inleftedge",
- ["fr"]="dansbordgauche",
- ["it"]="inlatosinistro",
- ["nl"]="inlinkerrand",
- ["pe"]="درلبهچپ",
- ["ro"]="inparteastanga",
+ ["environment"]={
+ ["cs"]="prostredi",
+ ["de"]="umgebung",
+ ["en"]="environment",
+ ["fr"]="environnement",
+ ["it"]="ambiente",
+ ["nl"]="omgeving",
+ ["pe"]="محیط",
+ ["ro"]="mediu",
},
- ["inleftmargin"]={
- ["cs"]="nalevyokraj",
- ["de"]="inlinkermarginale",
- ["en"]="inleftmargin",
- ["fr"]="dansmargegauche",
- ["it"]="inmarginesinistro",
- ["nl"]="inlinkermarge",
- ["pe"]="درحاشیهچپ",
- ["ro"]="inmargineastanga",
+ ["even"]={
+ ["cs"]="sude",
+ ["de"]="gerade",
+ ["en"]="even",
+ ["fr"]="paire",
+ ["it"]="pari",
+ ["nl"]="even",
+ ["pe"]="زوج",
+ ["ro"]="par",
},
- ["inline"]={
- ["en"]="inline",
+ ["export"]={
+ ["en"]="export",
+ ["fr"]="exporter",
},
- ["inmargin"]={
- ["cs"]="naokraji",
- ["de"]="imrand",
- ["en"]="inmargin",
- ["fr"]="dansmarge",
- ["it"]="inmargine",
- ["nl"]="inmarge",
- ["pe"]="درونحاشیه",
- ["ro"]="inmargine",
+ ["external"]={
+ ["cs"]="externi",
+ ["de"]="extern",
+ ["en"]="external",
+ ["fr"]="externe",
+ ["it"]="esterno",
+ ["nl"]="extern",
+ ["pe"]="خارجی",
+ ["ro"]="extern",
},
- ["inner"]={
- ["cs"]="uvnitr",
- ["de"]="innen",
- ["en"]="inner",
- ["fr"]="interieur",
- ["it"]="interno",
- ["nl"]="binnen",
- ["pe"]="داخلی",
- ["ro"]="intern",
+ ["extremestretch"]={
+ ["en"]="extremestretch",
+ ["fr"]="etirementextreme",
},
- ["inneredge"]={
- ["cs"]="inneredge",
- ["de"]="inneredge",
- ["en"]="inneredge",
- ["fr"]="bordinterieur",
- ["it"]="bordointerno",
- ["nl"]="binnenrand",
- ["pe"]="لبهداخلی",
- ["ro"]="inneredge",
+ ["fact"]={
+ ["cs"]="fakt",
+ ["de"]="gegeben",
+ ["en"]="fact",
+ ["fr"]="fait",
+ ["it"]="fatto",
+ ["nl"]="gegeven",
+ ["pe"]="fact",
+ ["ro"]="fapt",
},
- ["innermargin"]={
- ["cs"]="innermargin",
- ["de"]="innermargin",
- ["en"]="innermargin",
- ["fr"]="margeinterieure",
- ["it"]="margineinterno",
- ["nl"]="binnenmarge",
- ["pe"]="حاشیهداخلی",
- ["ro"]="innermargin",
+ ["fallback"]={
+ ["en"]="fallback",
+ ["fr"]="repli",
},
- ["inother"]={
- ["cs"]="inother",
- ["de"]="inother",
- ["en"]="inother",
- ["fr"]="inother",
- ["it"]="inother",
- ["nl"]="inandere",
- ["pe"]="inother",
- ["ro"]="inother",
+ ["february"]={
+ ["cs"]="unor",
+ ["de"]="februar",
+ ["en"]="february",
+ ["fr"]="fevrier",
+ ["it"]="febbraio",
+ ["nl"]="februari",
+ ["pe"]="فوریه",
+ ["ro"]="februarie",
},
- ["inouter"]={
- ["cs"]="inouter",
- ["de"]="inouter",
- ["en"]="inouter",
- ["fr"]="inouter",
- ["it"]="inouter",
- ["nl"]="inbuiten",
- ["pe"]="درخارجی",
- ["ro"]="inouter",
+ ["field"]={
+ ["en"]="field",
+ ["fr"]="champ",
+ ["nl"]="veld",
},
- ["inouteredge"]={
- ["en"]="inouteredge",
+ ["figure"]={
+ ["cs"]="obrazek",
+ ["de"]="abbildung",
+ ["en"]="figure",
+ ["fr"]="figure",
+ ["it"]="figura",
+ ["nl"]="figuur",
+ ["pe"]="شکل",
+ ["ro"]="figura",
+ },
+ ["figures"]={
+ ["cs"]="obrazky",
+ ["de"]="abbildungen",
+ ["en"]="figures",
+ ["fr"]="figures",
+ ["it"]="figure",
+ ["nl"]="figuren",
+ ["pe"]="شکلها",
+ ["ro"]="figure",
+ },
+ ["file"]={
+ ["cs"]="soubor",
+ ["de"]="datei",
+ ["en"]="file",
+ ["fr"]="fichier",
+ ["it"]="file",
+ ["nl"]="file",
+ ["pe"]="پرونده",
+ ["ro"]="fisier",
},
- ["inoutermargin"]={
- ["en"]="inoutermargin",
+ ["final"]={
+ ["cs"]="finalni",
+ ["de"]="endfassung",
+ ["en"]="final",
+ ["fr"]="final",
+ ["it"]="finale",
+ ["nl"]="definitief",
+ ["pe"]="نهایی",
+ ["ro"]="final",
},
- ["inright"]={
- ["cs"]="ivpravo",
- ["de"]="imrechten",
- ["en"]="inright",
- ["fr"]="dansdroit",
- ["it"]="indestra",
- ["nl"]="inrechter",
- ["pe"]="درونراست",
- ["ro"]="indreapta",
+ ["first"]={
+ ["cs"]="prvni",
+ ["de"]="erste",
+ ["en"]="first",
+ ["fr"]="premier",
+ ["it"]="primo",
+ ["nl"]="eerste",
+ ["pe"]="اولی",
+ ["ro"]="primul",
},
- ["inrightedge"]={
- ["cs"]="napravo",
- ["de"]="imrechtenrand",
- ["en"]="inrightedge",
- ["fr"]="dansborddroit",
- ["it"]="inlatodestro",
- ["nl"]="inrechterrand",
- ["pe"]="درلبهراست",
- ["ro"]="inparteadreapta",
+ ["firstcolumn"]={
+ ["cs"]="firstcolumn",
+ ["de"]="firstcolumn",
+ ["en"]="firstcolumn",
+ ["fr"]="premierecolonne",
+ ["it"]="firstcolumn",
+ ["nl"]="eerstekolom",
+ ["pe"]="ستوناول",
+ ["ro"]="firstcolumn",
},
- ["inrightmargin"]={
- ["cs"]="napravyokraj",
- ["de"]="inrechtermarginale",
- ["en"]="inrightmargin",
- ["fr"]="dansmargedroite",
- ["it"]="inmarginedestro",
- ["nl"]="inrechtermarge",
- ["pe"]="درحاشیهراست",
- ["ro"]="inmargineadreapta",
+ ["firstpage"]={
+ ["cs"]="prvnistranka",
+ ["de"]="ersteseite",
+ ["en"]="firstpage",
+ ["fr"]="premierepage",
+ ["it"]="primapagina",
+ ["nl"]="eerstepagina",
+ ["pe"]="صفحهاول",
+ ["ro"]="primapagina",
},
- ["integral"]={
- ["en"]="integral",
+ ["firstsubpage"]={
+ ["cs"]="prvnipodstranka",
+ ["de"]="ersteunterseite",
+ ["en"]="firstsubpage",
+ ["fr"]="premieresouspage",
+ ["it"]="primasottopagina",
+ ["nl"]="eerstesubpagina",
+ ["pe"]="زیرصفحهاول",
+ ["ro"]="primasubpagina",
},
- ["interaction"]={
- ["cs"]="interakce",
- ["de"]="interaktion",
- ["en"]="interaction",
- ["fr"]="interaction",
- ["it"]="interazione",
- ["nl"]="interactie",
- ["pe"]="پانل",
- ["ro"]="interactiune",
+ ["fit"]={
+ ["cs"]="prizpusobive",
+ ["de"]="passend",
+ ["en"]="fit",
+ ["fr"]="adapter",
+ ["it"]="adatta",
+ ["nl"]="passend",
+ ["pe"]="پرکردن",
+ ["ro"]="ajustat",
},
- ["interactionmenu"]={
- ["cs"]="interaktivnimenu",
- ["de"]="interaktionsmenue",
- ["en"]="interactionmenu",
- ["fr"]="menuinteraction",
- ["it"]="menuinterattivo",
- ["nl"]="interactiemenu",
- ["pe"]="منویپانل",
- ["ro"]="meniuinteractiune",
+ ["five"]={
+ ["cs"]="pet",
+ ["de"]="fuenf",
+ ["en"]="five",
+ ["fr"]="cinq",
+ ["it"]="cinque",
+ ["nl"]="vijf",
+ ["pe"]="پنج",
+ ["ro"]="cinci",
},
- ["interactive"]={
- ["en"]="interactive",
+ ["fix"]={
+ ["cs"]="fixuj",
+ ["de"]="stellewiederher",
+ ["en"]="fix",
+ ["fr"]="fix",
+ ["it"]="fisso",
+ ["nl"]="herstel",
+ ["pe"]="ثابتکن",
+ ["ro"]="fix",
},
- ["intermezzi"]={
- ["cs"]="intermezzi",
- ["de"]="intermezzi",
- ["en"]="intermezzi",
- ["fr"]="intermezzi",
- ["it"]="intermezzi",
- ["nl"]="intermezzos",
- ["pe"]="میانپردهها",
- ["ro"]="intermezzi",
+ ["fixed"]={
+ ["cs"]="fixne",
+ ["de"]="fest",
+ ["en"]="fixed",
+ ["fr"]="fixe",
+ ["it"]="fisso",
+ ["nl"]="vast",
+ ["pe"]="ثابت",
+ ["ro"]="fixat",
},
- ["intermezzo"]={
- ["cs"]="intermezzo",
- ["de"]="intermezzo",
- ["en"]="intermezzo",
- ["fr"]="intermezzo",
- ["it"]="intermezzo",
- ["nl"]="intermezzo",
- ["pe"]="میانپرده",
- ["ro"]="intermezzo",
+ ["flexible"]={
+ ["cs"]="prizpusobive",
+ ["de"]="flexibel",
+ ["en"]="flexible",
+ ["fr"]="flexible",
+ ["it"]="flessibile",
+ ["nl"]="flexibel",
+ ["pe"]="انعطافپذیر",
+ ["ro"]="flexibil",
},
- ["intext"]={
- ["cs"]="dotextu",
- ["de"]="imtext",
- ["en"]="intext",
- ["fr"]="danstexte",
- ["it"]="intesto",
- ["nl"]="intekst",
- ["pe"]="درونمتن",
- ["ro"]="intext",
+ ["float"]={
+ ["cs"]="plvouciobjekt",
+ ["de"]="gleitobjekt",
+ ["en"]="float",
+ ["fr"]="flottant",
+ ["it"]="oggettomobile",
+ ["nl"]="blok",
+ ["pe"]="شناور",
+ ["ro"]="obiectmobil",
},
- ["headintext"]={
- ["en"]="headintext",
- ["nl"]="kopintekst",
+ ["flushinner"]={
+ ["cs"]="flushinner",
+ ["de"]="flushinner",
+ ["en"]="flushinner",
+ ["fr"]="alignerinterieur",
+ ["it"]="flushinner",
+ ["nl"]="lijnbinnen",
+ ["pe"]="پمپداخلی",
+ ["ro"]="flushinner",
},
- ["intro"]={
- ["cs"]="uvod",
- ["de"]="intro",
- ["en"]="intro",
- ["fr"]="intro",
- ["it"]="intro",
- ["nl"]="intro",
- ["pe"]="پیشگفتار",
- ["ro"]="intro",
+ ["flushleft"]={
+ ["cs"]="flushleft",
+ ["de"]="flushleft",
+ ["en"]="flushleft",
+ ["fr"]="alignergauche",
+ ["it"]="flushleft",
+ ["nl"]="lijnlinks",
+ ["pe"]="پمپچپ",
+ ["ro"]="flushleft",
},
- ["italic"]={
- ["cs"]="kurziva",
- ["de"]="italic",
- ["en"]="italic",
- ["fr"]="italique",
- ["it"]="corsivo",
- ["nl"]="italic",
- ["pe"]="ایتالیک",
- ["ro"]="italic",
+ ["flushouter"]={
+ ["cs"]="flushouter",
+ ["de"]="flushouter",
+ ["en"]="flushouter",
+ ["fr"]="alignerexterieur",
+ ["it"]="flushouter",
+ ["nl"]="lijnbuiten",
+ ["pe"]="پمپخارجی",
+ ["ro"]="flushouter",
},
- ["italicbold"]={
- ["cs"]="kurzivnitucne",
- ["de"]="italicfett",
- ["en"]="italicbold",
- ["fr"]="grasitalique",
- ["it"]="corsivograssetto",
- ["nl"]="italicvet",
- ["pe"]="مشکیایتالیک",
- ["ro"]="italicaldin",
+ ["flushright"]={
+ ["cs"]="flushright",
+ ["de"]="flushright",
+ ["en"]="flushright",
+ ["fr"]="alignerdroite",
+ ["it"]="flushright",
+ ["nl"]="lijnrechts",
+ ["pe"]="پمپراست",
+ ["ro"]="flushright",
},
- ["item"]={
- ["cs"]="polozka",
- ["de"]="pos",
- ["en"]="item",
- ["fr"]="element",
- ["it"]="elemento",
- ["nl"]="som",
- ["pe"]="آیتم",
- ["ro"]="element",
+ ["followingpage"]={
+ ["en"]="followingpage",
+ ["fr"]="pagesuccesseur",
+ ["nl"]="opvolgendepagina",
},
- ["itemize"]={
- ["cs"]="vycet",
- ["de"]="aufzaehlung",
- ["en"]="itemize",
- ["fr"]="lister",
- ["it"]="elenco",
- ["nl"]="opsomming",
- ["pe"]="آیتمبندی",
- ["ro"]="enumerare",
+ ["font"]={
+ ["en"]="font",
+ ["nl"]="font",
},
- ["its"]={
- ["cs"]="pol",
- ["de"]="its",
- ["en"]="its",
- ["fr"]="its",
- ["it"]="its",
- ["nl"]="its",
- ["pe"]="آیم",
- ["ro"]="propriu",
+ ["footer"]={
+ ["cs"]="upati",
+ ["de"]="fusszeile",
+ ["en"]="footer",
+ ["fr"]="pdp",
+ ["it"]="piedipagina",
+ ["nl"]="voet",
+ ["pe"]="تهبرگ",
+ ["ro"]="subsol",
},
- ["january"]={
- ["cs"]="leden",
- ["de"]="januar",
- ["en"]="january",
- ["fr"]="janvier",
- ["it"]="gennaio",
- ["nl"]="januari",
- ["pe"]="ژانویه",
- ["ro"]="ianuarie",
+ ["footnote"]={
+ ["cs"]="poznamkapodcarou",
+ ["de"]="fussnote",
+ ["en"]="footnote",
+ ["fr"]="notebdp",
+ ["it"]="notapdp",
+ ["nl"]="voetnoot",
+ ["pe"]="پانوشت",
+ ["ro"]="notasubsol",
},
- ["joinedup"]={
- ["cs"]="spojeno",
- ["de"]="keinabstand",
- ["en"]="joinedup",
- ["fr"]="joinedup",
- ["it"]="unito",
- ["nl"]="aansluitend",
- ["pe"]="متصلبالا",
- ["ro"]="unit",
+ ["force"]={
+ ["cs"]="sila",
+ ["de"]="zwinge",
+ ["en"]="force",
+ ["fr"]="forcer",
+ ["it"]="forza",
+ ["nl"]="forceer",
+ ["pe"]="اجبار",
+ ["ro"]="fortat",
},
- ["notjoinedup"]={
- ["en"]="notjoinedup",
- ["nl"]="nietaansluitend",
+ ["foreground"]={
+ ["cs"]="popredi",
+ ["de"]="vordergrund",
+ ["en"]="foreground",
+ ["fr"]="premierplan",
+ ["it"]="foreground",
+ ["nl"]="voorgrond",
+ ["pe"]="پیشزمینه",
+ ["ro"]="primplan",
},
- ["july"]={
- ["cs"]="cervenec",
- ["de"]="juli",
- ["en"]="july",
- ["fr"]="juillet",
- ["it"]="luglio",
- ["nl"]="juli",
- ["pe"]="ژولای",
- ["ro"]="iulie",
+ ["formula"]={
+ ["cs"]="rovnice",
+ ["de"]="formel",
+ ["en"]="formula",
+ ["fr"]="formule",
+ ["it"]="formula",
+ ["nl"]="formule",
+ ["pe"]="فرمول",
+ ["ro"]="formula",
},
- ["june"]={
- ["cs"]="cerven",
- ["de"]="juni",
- ["en"]="june",
- ["fr"]="juin",
- ["it"]="giugno",
- ["nl"]="juni",
- ["pe"]="ژوئن",
- ["ro"]="iunie",
+ ["formulas"]={
+ ["cs"]="rovnice",
+ ["de"]="formeln",
+ ["en"]="formulas",
+ ["fr"]="formules",
+ ["it"]="formule",
+ ["nl"]="formules",
+ ["pe"]="فرمولها",
+ ["ro"]="formule",
},
- ["keep"]={
- ["cs"]="drzet",
- ["de"]="behalte",
- ["en"]="keep",
- ["fr"]="maintient",
- ["it"]="mantieni",
- ["nl"]="handhaaf",
- ["pe"]="نگهدار",
- ["ro"]="mentine",
+ ["forward"]={
+ ["cs"]="vpred",
+ ["de"]="vorwaerts",
+ ["en"]="forward",
+ ["fr"]="enavant",
+ ["it"]="avanti",
+ ["nl"]="vooruit",
+ ["pe"]="بهجلو",
+ ["ro"]="avans",
},
- ["kerncharacters"]={
- ["en"]="kerncharacters",
+ ["four"]={
+ ["cs"]="ctyri",
+ ["de"]="vier",
+ ["en"]="four",
+ ["fr"]="quatre",
+ ["it"]="quattro",
+ ["nl"]="vier",
+ ["pe"]="چهار",
+ ["ro"]="patru",
},
- ["knockout"]={
- ["cs"]="knockout",
- ["de"]="knockout",
- ["en"]="knockout",
- ["fr"]="knockout",
- ["it"]="knockout",
- ["nl"]="knockout",
- ["pe"]="knockout",
- ["ro"]="knockout",
+ ["fractions"]={
+ ["en"]="fractions",
+ ["fr"]="fractions",
},
- ["label"]={
- ["cs"]="popisek",
- ["de"]="label",
- ["en"]="label",
- ["fr"]="etiquette",
- ["it"]="etichetta",
- ["nl"]="label",
- ["pe"]="برچسب",
- ["ro"]="eticheta",
+ ["frame"]={
+ ["cs"]="ramecek",
+ ["de"]="rahmen",
+ ["en"]="frame",
+ ["fr"]="cadre",
+ ["it"]="cornice",
+ ["nl"]="kader",
+ ["pe"]="قالب",
+ ["ro"]="incadrat",
},
- ["landscape"]={
- ["cs"]="nasirku",
- ["de"]="querformat",
- ["en"]="landscape",
- ["fr"]="paysage",
- ["it"]="orizzontale",
- ["nl"]="liggend",
- ["pe"]="صفحهگسترده",
- ["ro"]="vedere",
+ ["framedtext"]={
+ ["cs"]="oramovanytext",
+ ["de"]="umrahmtertext",
+ ["en"]="framedtext",
+ ["fr"]="texteencadre",
+ ["it"]="testoincorniciato",
+ ["nl"]="kadertekst",
+ ["pe"]="متنقالبی",
+ ["ro"]="textinconjurat",
},
- ["last"]={
- ["cs"]="posledni",
- ["de"]="letzte",
- ["en"]="last",
- ["fr"]="dernier",
- ["it"]="ultimo",
- ["nl"]="laatste",
- ["pe"]="آخرین",
- ["ro"]="ultim",
+ ["friday"]={
+ ["cs"]="patek",
+ ["de"]="freitag",
+ ["en"]="friday",
+ ["fr"]="vendredi",
+ ["it"]="venerdi",
+ ["nl"]="vrijdag",
+ ["pe"]="جمعه",
+ ["ro"]="vineri",
},
- ["lastcolumn"]={
- ["cs"]="lastcolumn",
- ["de"]="lastcolumn",
- ["en"]="lastcolumn",
- ["fr"]="dernierecolonne",
- ["it"]="lastcolumn",
- ["nl"]="laatstekolom",
- ["pe"]="آخرینستون",
- ["ro"]="lastcolumn",
+ ["frontmatter"]={
+ ["cs"]="prednicasti",
+ ["de"]="einleitungen",
+ ["en"]="frontmatter",
+ ["fr"]="pagesliminaires",
+ ["it"]="preambolo",
+ ["nl"]="inleidingen",
+ ["pe"]="پیشمطلب",
+ ["ro"]="prologul",
},
- ["lastpage"]={
- ["cs"]="poslednistrana",
- ["de"]="letzteseite",
- ["en"]="lastpage",
- ["fr"]="dernierepage",
- ["it"]="ultimapagina",
- ["nl"]="laatstepagina",
- ["pe"]="صفحهآخر",
- ["ro"]="ultimapagina",
+ ["frontpart"]={
+ ["cs"]="prednicast",
+ ["de"]="einleitung",
+ ["en"]="frontpart",
+ ["fr"]="preface",
+ ["it"]="prefazione",
+ ["nl"]="inleiding",
+ ["pe"]="پیشقسمت",
+ ["ro"]="prolog",
},
- ["lastpagenumber"]={
- ["cs"]="lastpagenumber",
- ["de"]="lastpagenumber",
- ["en"]="lastpagenumber",
- ["fr"]="derniernumeropage",
- ["it"]="lastpagenumber",
- ["nl"]="laatstepaginanummer",
- ["pe"]="شماهصفحهآخر",
- ["ro"]="lastpagenumber",
+ ["fullhz"]={
+ ["cs"]="fullhz",
+ ["de"]="fullhz",
+ ["en"]="fullhz",
+ ["fr"]="hzcomplet",
+ ["it"]="fullhz",
+ ["nl"]="fullenhz",
+ ["pe"]="fullhz",
+ ["ro"]="fullhz",
},
- ["lastsubpage"]={
- ["cs"]="poslaednipodstranka",
- ["de"]="letzteunterseite",
- ["en"]="lastsubpage",
- ["fr"]="dernieresouspage",
- ["it"]="ultimasottopagina",
- ["nl"]="laatstesubpagina",
- ["pe"]="زیرصفحهآخر",
- ["ro"]="ultimasubpagina",
+ ["global"]={
+ ["cs"]="globalne",
+ ["de"]="global",
+ ["en"]="global",
+ ["fr"]="global",
+ ["it"]="globale",
+ ["nl"]="globaal",
+ ["pe"]="سراسری",
+ ["ro"]="global",
},
- ["layer"]={
- ["cs"]="layer",
- ["de"]="layer",
- ["en"]="layer",
- ["fr"]="layer",
- ["it"]="layer",
- ["nl"]="layer",
- ["pe"]="layer",
- ["ro"]="layer",
+ ["graphic"]={
+ ["cs"]="graf",
+ ["de"]="grafik",
+ ["en"]="graphic",
+ ["fr"]="graphique",
+ ["it"]="grafico",
+ ["nl"]="grafiek",
+ ["pe"]="گرافیک",
+ ["ro"]="graficul",
},
- ["left"]={
- ["cs"]="vlevo",
- ["de"]="links",
- ["en"]="left",
- ["fr"]="gauche",
- ["it"]="sinistra",
- ["nl"]="links",
- ["pe"]="چپ",
- ["ro"]="stanga",
+ ["graphics"]={
+ ["cs"]="grafy",
+ ["de"]="grafiken",
+ ["en"]="graphics",
+ ["fr"]="graphiques",
+ ["it"]="grafici",
+ ["nl"]="grafieken",
+ ["pe"]="گرافیکها",
+ ["ro"]="graficele",
},
- ["leftedge"]={
- ["cs"]="levahrana",
- ["de"]="linkekante",
- ["en"]="leftedge",
- ["fr"]="bordgauche",
- ["it"]="bordosinistro",
- ["nl"]="linkerrand",
- ["pe"]="لبهچپ",
- ["ro"]="bordurastanga",
+ ["gray"]={
+ ["cs"]="seda",
+ ["de"]="grau",
+ ["en"]="gray",
+ ["fr"]="gris",
+ ["it"]="grigio",
+ ["nl"]="grijs",
+ ["pe"]="خاکستری",
+ ["ro"]="gri",
},
- ["lefthanging"]={
- ["cs"]="lefthanging",
- ["de"]="lefthanging",
- ["en"]="lefthanging",
- ["fr"]="lefthanging",
- ["it"]="lefthanging",
- ["nl"]="linkshangend",
- ["pe"]="آویزانچپ",
- ["ro"]="lefthanging",
+ ["greek"]={
+ ["cs"]="recky",
+ ["de"]="griechisch",
+ ["en"]="greek",
+ ["fr"]="grec",
+ ["it"]="greco",
+ ["nl"]="grieks",
+ ["pe"]="یونانی",
+ ["ro"]="grec",
},
- ["leftmargin"]={
- ["cs"]="levyokraj",
- ["de"]="linkerrand",
- ["en"]="leftmargin",
- ["fr"]="margegauche",
- ["it"]="marginesinistro",
- ["nl"]="linkermarge",
- ["pe"]="حاشیهچپ",
- ["ro"]="marginestanga",
+ ["grid"]={
+ ["cs"]="mrizka",
+ ["de"]="gritter",
+ ["en"]="grid",
+ ["fr"]="grille",
+ ["it"]="griglia",
+ ["nl"]="grid",
+ ["pe"]="توری",
+ ["ro"]="grila",
},
- ["leftpage"]={
- ["cs"]="levastranka",
- ["de"]="linkerseite",
- ["en"]="leftpage",
- ["fr"]="pagegauche",
- ["it"]="paginasinistra",
- ["nl"]="linkerpagina",
- ["pe"]="صفحهچپ",
- ["ro"]="paginastanga",
+ ["halfline"]={
+ ["cs"]="pulradku",
+ ["de"]="halbezeile",
+ ["en"]="halfline",
+ ["fr"]="demiligne",
+ ["it"]="mezzariga",
+ ["nl"]="halveregel",
+ ["pe"]="نیمخط",
+ ["ro"]="jumatatelinie",
},
- ["lefttoright"]={
- ["cs"]="lefttoright",
- ["de"]="lefttoright",
- ["en"]="lefttoright",
- ["fr"]="lefttoright",
- ["it"]="lefttoright",
- ["nl"]="lefttoright",
- ["pe"]="lefttoright",
- ["ro"]="lefttoright",
+ ["handwritten"]={
+ ["cs"]="rukopisne",
+ ["de"]="handschrift",
+ ["en"]="handwritten",
+ ["fr"]="manuscript",
+ ["it"]="grafiamanuale",
+ ["nl"]="handschrift",
+ ["pe"]="دستنوشته",
+ ["ro"]="scrismanual",
},
- ["legend"]={
- ["cs"]="legenda",
- ["de"]="legende",
- ["en"]="legend",
- ["fr"]="legende",
- ["it"]="legenda",
- ["nl"]="legenda",
- ["pe"]="راهنما",
- ["ro"]="legenda",
+ ["hang"]={
+ ["cs"]="zaveseni",
+ ["de"]="haengend",
+ ["en"]="hang",
+ ["fr"]="suspendre",
+ ["it"]="sospendi",
+ ["nl"]="hang",
+ ["pe"]="بیاویز",
+ ["ro"]="suspenda",
},
- ["less"]={
- ["en"]="less",
- ["nl"]="minder",
+ ["hanging"]={
+ ["cs"]="visici",
+ ["de"]="haengend",
+ ["en"]="hanging",
+ ["fr"]="suspension",
+ ["it"]="sospeso",
+ ["nl"]="hangend",
+ ["pe"]="آویزان",
+ ["ro"]="suspendat",
},
- ["lesshyphenation"]={
- ["cs"]="lesshyphenation",
- ["de"]="lesshyphenation",
- ["en"]="lesshyphenation",
- ["fr"]="lesshyphenation",
- ["it"]="lesshyphenation",
- ["nl"]="lesshyphenation",
- ["pe"]="شکستکلماتکمتر",
- ["ro"]="lesshyphenation",
+ ["hangingboth"]={
+ ["en"]="hangingboth",
+ ["fr"]="suspensionchacun",
+ ["nl"]="beidehangend",
},
- ["letterspacing"]={
- ["en"]="letterspacing",
+ ["head"]={
+ ["cs"]="hlavicka",
+ ["de"]="kopf",
+ ["en"]="head",
+ ["fr"]="tete",
+ ["it"]="testa",
+ ["nl"]="kop",
+ ["pe"]="سر",
+ ["ro"]="antet",
},
- ["line"]={
- ["cs"]="radek",
- ["de"]="zeile",
- ["en"]="line",
- ["fr"]="ligne",
- ["it"]="riga",
- ["nl"]="regel",
- ["pe"]="خط",
- ["ro"]="linie",
+ ["header"]={
+ ["cs"]="zahlavi",
+ ["de"]="kopfzeile",
+ ["en"]="header",
+ ["fr"]="entête",
+ ["it"]="intestazione",
+ ["nl"]="hoofd",
+ ["pe"]="سربرگ",
+ ["ro"]="antet",
},
- ["linenote"]={
- ["cs"]="linenote",
- ["de"]="linenote",
- ["en"]="linenote",
- ["fr"]="noteligne",
- ["it"]="linenote",
- ["nl"]="regelnoot",
- ["pe"]="خطنوشت",
- ["ro"]="linenote",
+ ["headintext"]={
+ ["en"]="headintext",
+ ["fr"]="tetedanstexte",
+ ["nl"]="kopintekst",
},
- ["lines"]={
- ["cs"]="radky",
- ["de"]="zeilen",
- ["en"]="lines",
- ["fr"]="lignes",
- ["it"]="righe",
- ["nl"]="regels",
- ["pe"]="خطها",
- ["ro"]="linii",
+ ["height"]={
+ ["cs"]="vyska",
+ ["de"]="hoehe",
+ ["en"]="height",
+ ["fr"]="hauteur",
+ ["it"]="altezza",
+ ["nl"]="hoogte",
+ ["pe"]="ارتفاع",
+ ["ro"]="inaltime",
},
- ["linked"]={
- ["en"]="linked",
+ ["helptext"]={
+ ["cs"]="textnapovedy",
+ ["de"]="hilfetext",
+ ["en"]="helptext",
+ ["fr"]="texteaide",
+ ["it"]="testoaiuto",
+ ["nl"]="helptekst",
+ ["pe"]="متنکمکی",
+ ["ro"]="textajutator",
},
- ["list"]={
- ["cs"]="seznam",
- ["de"]="liste",
- ["en"]="list",
- ["fr"]="liste",
- ["it"]="elenco",
- ["nl"]="lijst",
- ["pe"]="لیست",
- ["ro"]="lista",
+ ["hencefore"]={
+ ["cs"]="vyse",
+ ["de"]="vorher",
+ ["en"]="hencefore",
+ ["fr"]="precedemment",
+ ["it"]="precedente",
+ ["nl"]="hierboven",
+ ["pe"]="hencefore",
+ ["ro"]="precedent",
+ },
+ ["here"]={
+ ["cs"]="zde",
+ ["de"]="hier",
+ ["en"]="here",
+ ["fr"]="ici",
+ ["it"]="qui",
+ ["nl"]="hier",
+ ["pe"]="اینجا",
+ ["ro"]="aici",
},
- ["local"]={
- ["cs"]="lokalne",
- ["de"]="lokal",
- ["en"]="local",
- ["fr"]="local",
- ["it"]="locale",
- ["nl"]="lokaal",
- ["pe"]="موضعی",
- ["ro"]="local",
+ ["hereafter"]={
+ ["cs"]="nize",
+ ["de"]="nachher",
+ ["en"]="hereafter",
+ ["fr"]="ciapres",
+ ["it"]="seguente",
+ ["nl"]="hieronder",
+ ["pe"]="ازاینبهبعد",
+ ["ro"]="urmator",
},
- ["localenvironment"]={
- ["cs"]="lokalnihoprostredi",
- ["de"]="lokaleumgebung",
- ["en"]="localenvironment",
- ["fr"]="environementlocal",
- ["it"]="ambientelocale",
- ["nl"]="deelomgeving",
- ["pe"]="محیطموضعی",
- ["ro"]="mediulocal",
+ ["hidden"]={
+ ["cs"]="skryte",
+ ["de"]="versteckt",
+ ["en"]="hidden",
+ ["fr"]="cache",
+ ["it"]="nascosto",
+ ["nl"]="verborgen",
+ ["pe"]="پنهانی",
+ ["ro"]="ascuns",
},
- ["logo"]={
- ["cs"]="logo",
- ["de"]="logo",
- ["en"]="logo",
- ["fr"]="logo",
- ["it"]="logo",
- ["nl"]="logo",
- ["pe"]="آرم",
- ["ro"]="logo",
+ ["hiddenbar"]={
+ ["en"]="hiddenbar",
+ ["fr"]="barrecachee",
},
- ["logos"]={
- ["cs"]="loga",
- ["de"]="logos",
- ["en"]="logos",
- ["fr"]="logos",
- ["it"]="loghi",
- ["nl"]="logos",
- ["pe"]="آرمها",
- ["ro"]="logos",
+ ["hiding"]={
+ ["cs"]="skryt",
+ ["de"]="verbergen",
+ ["en"]="hiding",
+ ["fr"]="encachant",
+ ["it"]="nascondere",
+ ["nl"]="verbergen",
+ ["pe"]="پنهانکردن",
+ ["ro"]="ascundere",
},
- ["lohi"]={
- ["cs"]="nivy",
- ["de"]="hoti",
- ["en"]="lohi",
- ["fr"]="baha",
- ["it"]="pedap",
- ["nl"]="laho",
- ["pe"]="پابا",
- ["ro"]="lohi",
+ ["high"]={
+ ["cs"]="vysoko",
+ ["de"]="hoch",
+ ["en"]="high",
+ ["fr"]="exp",
+ ["it"]="alto",
+ ["nl"]="hoog",
+ ["pe"]="بلند",
+ ["ro"]="inalt",
},
- ["long"]={
- ["en"]="long",
+ ["horizontal"]={
+ ["cs"]="horizontalne",
+ ["de"]="horizontal",
+ ["en"]="horizontal",
+ ["fr"]="horizontal",
+ ["it"]="orizzontale",
+ ["nl"]="horizontaal",
+ ["pe"]="افقی",
+ ["ro"]="orizontal",
},
- ["loose"]={
- ["cs"]="uvolnene",
- ["de"]="lose",
- ["en"]="loose",
- ["fr"]="perte",
- ["it"]="lento",
- ["nl"]="los",
- ["pe"]="شل",
- ["ro"]="larg",
+ ["hyphenated"]={
+ ["cs"]="hyphenated",
+ ["de"]="hyphenate",
+ ["en"]="hyphenated",
+ ["fr"]="aveccesure",
+ ["it"]="sillabato",
+ ["nl"]="afgebroken",
+ ["pe"]="شکسته",
+ ["ro"]="despsilabe",
},
- ["low"]={
- ["cs"]="nizko",
- ["de"]="tief",
- ["en"]="low",
- ["fr"]="bas",
- ["it"]="basso",
- ["nl"]="laag",
- ["pe"]="پایین",
- ["ro"]="jos",
+ ["hz"]={
+ ["cs"]="hz",
+ ["de"]="hz",
+ ["en"]="hz",
+ ["fr"]="hz",
+ ["it"]="hz",
+ ["nl"]="hz",
+ ["pe"]="hz",
+ ["ro"]="hz",
},
- ["ls"]={
- ["cs"]="ls",
- ["de"]="ls",
- ["en"]="ls",
- ["fr"]="ls",
- ["it"]="ls",
- ["nl"]="ls",
- ["pe"]="ls",
- ["ro"]="ls",
+ ["inbetween"]={
+ ["cs"]="mezi",
+ ["de"]="zwischen",
+ ["en"]="inbetween",
+ ["fr"]="entre",
+ ["it"]="tra",
+ ["nl"]="tussen",
+ ["pe"]="دربین",
+ ["ro"]="intre",
},
- ["makeup"]={
- ["cs"]="zlom",
- ["de"]="umbruch",
- ["en"]="makeup",
- ["fr"]="makeup",
- ["it"]="makeup",
- ["nl"]="opmaak",
- ["pe"]="آرایش",
- ["ro"]="marcaj",
+ ["index"]={
+ ["cs"]="rejstrik",
+ ["de"]="index",
+ ["en"]="index",
+ ["fr"]="index",
+ ["it"]="indiceanalitico",
+ ["nl"]="index",
+ ["pe"]="نمایه",
+ ["ro"]="index",
},
- ["mar"]={
- ["cs"]="mar",
- ["de"]="mar",
- ["en"]="mar",
- ["fr"]="mar",
- ["it"]="mar",
- ["nl"]="mar",
- ["pe"]="حاش",
- ["ro"]="mar",
+ ["indices"]={
+ ["cs"]="rejstriky",
+ ["de"]="indizies",
+ ["en"]="indices",
+ ["fr"]="indices",
+ ["it"]="indicianalitici",
+ ["nl"]="indices",
+ ["pe"]="نمایهها",
+ ["ro"]="indexuri",
},
- ["march"]={
- ["cs"]="brezen",
- ["de"]="maerz",
- ["en"]="march",
- ["fr"]="mars",
- ["it"]="marzo",
- ["nl"]="maart",
- ["pe"]="مارس",
- ["ro"]="martie",
+ ["inherit"]={
+ ["cs"]="inherit",
+ ["de"]="inherit",
+ ["en"]="inherit",
+ ["fr"]="heriter",
+ ["it"]="inherit",
+ ["nl"]="erf",
+ ["pe"]="ارثبردن",
+ ["ro"]="inherit",
},
- ["margin"]={
- ["cs"]="marginalie",
- ["de"]="marginalie",
- ["en"]="margin",
- ["fr"]="marge",
- ["it"]="margine",
- ["nl"]="marge",
- ["pe"]="حاشیه",
- ["ro"]="margine",
+ ["ininner"]={
+ ["cs"]="ininner",
+ ["de"]="ininner",
+ ["en"]="ininner",
+ ["fr"]="dansinterieur",
+ ["it"]="ininner",
+ ["nl"]="inbinnen",
+ ["pe"]="درداخلی",
+ ["ro"]="ininner",
},
- ["marginedge"]={
- ["cs"]="textovahrana",
- ["de"]="marginalkante",
- ["en"]="marginedge",
- ["fr"]="bordmarge",
- ["it"]="bordomargine",
- ["nl"]="kantlijn",
- ["pe"]="لبهحاشیه",
- ["ro"]="marginebordura",
+ ["ininneredge"]={
+ ["en"]="ininneredge",
+ ["fr"]="dansbordinterieur",
},
- ["margintext"]={
- ["cs"]="marginalnitext",
- ["de"]="marginaltext",
- ["en"]="margintext",
- ["fr"]="textemarge",
- ["it"]="testoinmargine",
- ["nl"]="margetekst",
- ["pe"]="متنحاشیه",
- ["ro"]="textmarginal",
+ ["ininnermargin"]={
+ ["en"]="ininnermargin",
+ ["fr"]="dansmargeinterieure",
},
- ["margintitle"]={
- ["cs"]="titulmarginalie",
- ["de"]="marginaltitel",
- ["en"]="margintitle",
- ["fr"]="titremarge",
- ["it"]="titoloinmargine",
- ["nl"]="margetitel",
- ["pe"]="عنوانحاشیه",
- ["ro"]="titlumarginal",
+ ["inleft"]={
+ ["cs"]="ivlevo",
+ ["de"]="imlinken",
+ ["en"]="inleft",
+ ["fr"]="dansgauche",
+ ["it"]="insinistra",
+ ["nl"]="inlinker",
+ ["pe"]="درونچپ",
+ ["ro"]="instanga",
+ },
+ ["inleftedge"]={
+ ["cs"]="nalevo",
+ ["de"]="imlinkenrand",
+ ["en"]="inleftedge",
+ ["fr"]="dansbordgauche",
+ ["it"]="inlatosinistro",
+ ["nl"]="inlinkerrand",
+ ["pe"]="درلبهچپ",
+ ["ro"]="inparteastanga",
},
- ["marking"]={
- ["cs"]="znaceni",
- ["de"]="beschriftung",
- ["en"]="marking",
- ["fr"]="marquage",
- ["it"]="marcatura",
- ["nl"]="markering",
- ["pe"]="نشانهگذاری",
- ["ro"]="marcaje",
+ ["inleftmargin"]={
+ ["cs"]="nalevyokraj",
+ ["de"]="inlinkermarginale",
+ ["en"]="inleftmargin",
+ ["fr"]="dansmargegauche",
+ ["it"]="inmarginesinistro",
+ ["nl"]="inlinkermarge",
+ ["pe"]="درحاشیهچپ",
+ ["ro"]="inmargineastanga",
},
- ["math"]={
- ["en"]="math",
+ ["inline"]={
+ ["en"]="inline",
+ ["fr"]="enligne",
},
- ["mathalignment"]={
- ["cs"]="mathalignment",
- ["de"]="mathalignment",
- ["en"]="mathalignment",
- ["fr"]="mathalignment",
- ["it"]="mathalignment",
- ["nl"]="wiskundeuitlijnen",
- ["pe"]="تنظیمریاضی",
- ["ro"]="mathalignment",
+ ["inmargin"]={
+ ["cs"]="naokraji",
+ ["de"]="imrand",
+ ["en"]="inmargin",
+ ["fr"]="dansmarge",
+ ["it"]="inmargine",
+ ["nl"]="inmarge",
+ ["pe"]="درونحاشیه",
+ ["ro"]="inmargine",
},
- ["mathcases"]={
- ["cs"]="mathcases",
- ["de"]="mathcases",
- ["en"]="mathcases",
- ["fr"]="mathcases",
- ["it"]="mathcases",
- ["nl"]="mathcases",
- ["pe"]="حالتهایریاضی",
- ["ro"]="mathcases",
+ ["inner"]={
+ ["cs"]="uvnitr",
+ ["de"]="innen",
+ ["en"]="inner",
+ ["fr"]="interieur",
+ ["it"]="interno",
+ ["nl"]="binnen",
+ ["pe"]="داخلی",
+ ["ro"]="intern",
},
- ["mathematics"]={
- ["cs"]="mathematika",
- ["de"]="mathematik",
- ["en"]="mathematics",
- ["fr"]="mathematique",
- ["it"]="matematica",
- ["nl"]="wiskunde",
- ["pe"]="ریاضی",
- ["ro"]="matematica",
+ ["inneredge"]={
+ ["cs"]="inneredge",
+ ["de"]="inneredge",
+ ["en"]="inneredge",
+ ["fr"]="bordinterieur",
+ ["it"]="bordointerno",
+ ["nl"]="binnenrand",
+ ["pe"]="لبهداخلی",
+ ["ro"]="inneredge",
},
- ["mathmatrix"]={
- ["cs"]="mathmatrix",
- ["de"]="mathmatrix",
- ["en"]="mathmatrix",
- ["fr"]="mathmatrix",
- ["it"]="mathmatrix",
- ["nl"]="wiskundematrix",
- ["pe"]="ماتریشریاضی",
- ["ro"]="mathmatrix",
+ ["innermargin"]={
+ ["cs"]="innermargin",
+ ["de"]="innermargin",
+ ["en"]="innermargin",
+ ["fr"]="margeinterieure",
+ ["it"]="margineinterno",
+ ["nl"]="binnenmarge",
+ ["pe"]="حاشیهداخلی",
+ ["ro"]="innermargin",
},
- ["max"]={
- ["cs"]="max",
- ["de"]="max",
- ["en"]="max",
- ["fr"]="max",
- ["it"]="max",
- ["nl"]="max",
- ["pe"]="بیشترین",
- ["ro"]="max",
+ ["inother"]={
+ ["cs"]="inother",
+ ["de"]="inother",
+ ["en"]="inother",
+ ["fr"]="dansautre",
+ ["it"]="inother",
+ ["nl"]="inandere",
+ ["pe"]="inother",
+ ["ro"]="inother",
},
- ["maxdepth"]={
- ["en"]="maxdepth",
- ["nl"]="maxdiepte",
+ ["inouter"]={
+ ["cs"]="inouter",
+ ["de"]="inouter",
+ ["en"]="inouter",
+ ["fr"]="dansexterieur",
+ ["it"]="inouter",
+ ["nl"]="inbuiten",
+ ["pe"]="درخارجی",
+ ["ro"]="inouter",
},
- ["maxheight"]={
- ["en"]="maxheight",
- ["nl"]="maxhoogte",
+ ["inouteredge"]={
+ ["en"]="inouteredge",
+ ["fr"]="dansbordexterieur",
},
- ["maxwidth"]={
- ["en"]="maxwidth",
- ["nl"]="maxbreedte",
+ ["inoutermargin"]={
+ ["en"]="inoutermargin",
+ ["fr"]="dansmargeexterieure",
},
- ["may"]={
- ["cs"]="kveten",
- ["de"]="mai",
- ["en"]="may",
- ["fr"]="mai",
- ["it"]="maggio",
- ["nl"]="mei",
- ["pe"]="مه",
- ["ro"]="mai",
+ ["inright"]={
+ ["cs"]="ivpravo",
+ ["de"]="imrechten",
+ ["en"]="inright",
+ ["fr"]="dansdroite",
+ ["it"]="indestra",
+ ["nl"]="inrechter",
+ ["pe"]="درونراست",
+ ["ro"]="indreapta",
},
- ["mediaeval"]={
- ["cs"]="stredoveky",
- ["de"]="mittelalterlich",
- ["en"]="mediaeval",
- ["fr"]="medieval",
- ["it"]="medievale",
- ["nl"]="mediaeval",
- ["pe"]="mediaeval",
- ["ro"]="medieval",
+ ["inrightedge"]={
+ ["cs"]="napravo",
+ ["de"]="imrechtenrand",
+ ["en"]="inrightedge",
+ ["fr"]="dansborddroit",
+ ["it"]="inlatodestro",
+ ["nl"]="inrechterrand",
+ ["pe"]="درلبهراست",
+ ["ro"]="inparteadreapta",
},
- ["medium"]={
- ["cs"]="stredni",
- ["de"]="mittel",
- ["en"]="medium",
- ["fr"]="moyen",
- ["it"]="medio",
- ["nl"]="middel",
- ["pe"]="متوسط",
- ["ro"]="mediu",
+ ["inrightmargin"]={
+ ["cs"]="napravyokraj",
+ ["de"]="inrechtermarginale",
+ ["en"]="inrightmargin",
+ ["fr"]="dansmargedroite",
+ ["it"]="inmarginedestro",
+ ["nl"]="inrechtermarge",
+ ["pe"]="درحاشیهراست",
+ ["ro"]="inmargineadreapta",
},
- ["middle"]={
- ["cs"]="nastred",
- ["de"]="mittig",
- ["en"]="middle",
- ["fr"]="milieu",
- ["it"]="centro",
- ["nl"]="midden",
- ["pe"]="میان",
- ["ro"]="centru",
+ ["integral"]={
+ ["en"]="integral",
+ ["fr"]="integrale",
},
- ["min"]={
- ["cs"]="min",
- ["de"]="min",
- ["en"]="min",
- ["fr"]="min",
- ["it"]="min",
- ["nl"]="min",
- ["pe"]="کمترین",
- ["ro"]="min",
+ ["interaction"]={
+ ["cs"]="interakce",
+ ["de"]="interaktion",
+ ["en"]="interaction",
+ ["fr"]="interaction",
+ ["it"]="interazione",
+ ["nl"]="interactie",
+ ["pe"]="پانل",
+ ["ro"]="interactiune",
},
- ["mindepth"]={
- ["en"]="mindepth",
- ["nl"]="mindiepte",
+ ["interactionmenu"]={
+ ["cs"]="interaktivnimenu",
+ ["de"]="interaktionsmenue",
+ ["en"]="interactionmenu",
+ ["fr"]="menuinteraction",
+ ["it"]="menuinterattivo",
+ ["nl"]="interactiemenu",
+ ["pe"]="منویپانل",
+ ["ro"]="meniuinteractiune",
},
- ["minheight"]={
- ["cs"]="minvyska",
- ["de"]="minhoehe",
- ["en"]="minheight",
- ["fr"]="hauteurmin",
- ["it"]="altezzamin",
- ["nl"]="minhoogte",
- ["pe"]="کمترینارتفاع",
- ["ro"]="inaltimeminima",
+ ["interactive"]={
+ ["en"]="interactive",
+ ["fr"]="interactif",
},
- ["minwidth"]={
- ["cs"]="minsirka",
- ["de"]="minbreite",
- ["en"]="minwidth",
- ["fr"]="largeurmin",
- ["it"]="ampiezzamin",
- ["nl"]="minbreedte",
- ["pe"]="کمترینعرض",
- ["ro"]="latimeminima",
+ ["intermezzi"]={
+ ["cs"]="intermezzi",
+ ["de"]="intermezzi",
+ ["en"]="intermezzi",
+ ["fr"]="interludes",
+ ["it"]="intermezzi",
+ ["nl"]="intermezzos",
+ ["pe"]="میانپردهها",
+ ["ro"]="intermezzi",
},
- ["mirrored"]={
- ["cs"]="zrcadleno",
- ["de"]="gespiegelt",
- ["en"]="mirrored",
- ["fr"]="reflete",
- ["it"]="riflesso",
- ["nl"]="gespiegeld",
- ["pe"]="منعکس",
- ["ro"]="oglindit",
+ ["intermezzo"]={
+ ["cs"]="intermezzo",
+ ["de"]="intermezzo",
+ ["en"]="intermezzo",
+ ["fr"]="interlude",
+ ["it"]="intermezzo",
+ ["nl"]="intermezzo",
+ ["pe"]="میانپرده",
+ ["ro"]="intermezzo",
},
- ["mixed"]={
- ["en"]="mixed",
+ ["intext"]={
+ ["cs"]="dotextu",
+ ["de"]="imtext",
+ ["en"]="intext",
+ ["fr"]="danstexte",
+ ["it"]="intesto",
+ ["nl"]="intekst",
+ ["pe"]="درونمتن",
+ ["ro"]="intext",
},
- ["monday"]={
- ["cs"]="pondeli",
- ["de"]="montag",
- ["en"]="monday",
- ["fr"]="lundi",
- ["it"]="lunedi",
- ["nl"]="maandag",
- ["pe"]="دوشنبه",
- ["ro"]="luni",
+ ["intro"]={
+ ["cs"]="uvod",
+ ["de"]="intro",
+ ["en"]="intro",
+ ["fr"]="intro",
+ ["it"]="intro",
+ ["nl"]="intro",
+ ["pe"]="پیشگفتار",
+ ["ro"]="intro",
},
- ["mono"]={
- ["cs"]="mono",
- ["de"]="mono",
- ["en"]="mono",
- ["fr"]="mono",
- ["it"]="mono",
- ["nl"]="mono",
- ["pe"]="مونو",
- ["ro"]="mono",
+ ["invertedshort"]={
+ ["en"]="invertedshort",
},
- ["monobold"]={
- ["cs"]="monotucne",
- ["de"]="monofett",
- ["en"]="monobold",
- ["fr"]="monogras",
- ["it"]="monograssetto",
- ["nl"]="monovet",
- ["pe"]="monobold",
- ["ro"]="monoaldin",
+ ["italic"]={
+ ["cs"]="kurziva",
+ ["de"]="italic",
+ ["en"]="italic",
+ ["fr"]="italique",
+ ["it"]="corsivo",
+ ["nl"]="italic",
+ ["pe"]="ایتالیک",
+ ["ro"]="italic",
},
- ["mononormal"]={
- ["en"]="mononormal",
+ ["italicbold"]={
+ ["cs"]="kurzivnitucne",
+ ["de"]="italicfett",
+ ["en"]="italicbold",
+ ["fr"]="italiquegras",
+ ["it"]="corsivograssetto",
+ ["nl"]="italicvet",
+ ["pe"]="مشکیایتالیک",
+ ["ro"]="italicaldin",
},
- ["month"]={
- ["cs"]="mesic",
- ["de"]="monat",
- ["en"]="month",
- ["fr"]="mois",
- ["it"]="mese",
- ["nl"]="maand",
- ["pe"]="ماه",
- ["ro"]="luna",
+ ["item"]={
+ ["cs"]="polozka",
+ ["de"]="pos",
+ ["en"]="item",
+ ["fr"]="élément",
+ ["it"]="elemento",
+ ["nl"]="som",
+ ["pe"]="آیتم",
+ ["ro"]="element",
},
- ["more"]={
- ["en"]="more",
- ["nl"]="meer",
+ ["itemize"]={
+ ["cs"]="vycet",
+ ["de"]="aufzaehlung",
+ ["en"]="itemize",
+ ["fr"]="détailler",
+ ["it"]="elenco",
+ ["nl"]="opsomming",
+ ["pe"]="آیتمبندی",
+ ["ro"]="enumerare",
},
- ["morehyphenation"]={
- ["cs"]="morehyphenation",
- ["de"]="morehyphenation",
- ["en"]="morehyphenation",
- ["fr"]="morehyphenation",
- ["it"]="morehyphenation",
- ["nl"]="morehyphenation",
- ["pe"]="شکستکلماتبیشتر",
- ["ro"]="morehyphenation",
+ ["its"]={
+ ["cs"]="pol",
+ ["de"]="its",
+ ["en"]="its",
+ ["fr"]="els",
+ ["it"]="its",
+ ["nl"]="its",
+ ["pe"]="آیم",
+ ["ro"]="propriu",
},
- ["name"]={
- ["cs"]="jmeno",
- ["de"]="name",
- ["en"]="name",
- ["fr"]="nom",
- ["it"]="nome",
- ["nl"]="naam",
- ["pe"]="نام",
- ["ro"]="nume",
+ ["january"]={
+ ["cs"]="leden",
+ ["de"]="januar",
+ ["en"]="january",
+ ["fr"]="janvier",
+ ["it"]="gennaio",
+ ["nl"]="januari",
+ ["pe"]="ژانویه",
+ ["ro"]="ianuarie",
},
- ["narrow"]={
- ["cs"]="uzky",
- ["de"]="schmall",
- ["en"]="narrow",
- ["fr"]="etroit",
- ["it"]="stretto",
- ["nl"]="smal",
- ["pe"]="نازک",
- ["ro"]="ingust",
+ ["joinedup"]={
+ ["cs"]="spojeno",
+ ["de"]="keinabstand",
+ ["en"]="joinedup",
+ ["fr"]="sansespaceentre",
+ ["it"]="unito",
+ ["nl"]="aansluitend",
+ ["pe"]="متصلبالا",
+ ["ro"]="unit",
},
- ["negative"]={
- ["cs"]="negativ",
- ["de"]="negativ",
- ["en"]="negative",
- ["fr"]="negatif",
- ["it"]="negativo",
- ["nl"]="negatief",
- ["pe"]="منفی",
- ["ro"]="negativ",
+ ["july"]={
+ ["cs"]="cervenec",
+ ["de"]="juli",
+ ["en"]="july",
+ ["fr"]="juillet",
+ ["it"]="luglio",
+ ["nl"]="juli",
+ ["pe"]="ژولای",
+ ["ro"]="iulie",
},
- ["never"]={
- ["cs"]="nikdy",
- ["de"]="nie",
- ["en"]="never",
- ["fr"]="jamais",
- ["it"]="mai",
- ["nl"]="nooit",
- ["pe"]="هیچگاه",
- ["ro"]="niciodata",
+ ["june"]={
+ ["cs"]="cerven",
+ ["de"]="juni",
+ ["en"]="june",
+ ["fr"]="juin",
+ ["it"]="giugno",
+ ["nl"]="juni",
+ ["pe"]="ژوئن",
+ ["ro"]="iunie",
},
- ["new"]={
- ["cs"]="novy",
- ["de"]="neu",
- ["en"]="new",
- ["fr"]="nouveau",
- ["it"]="nuovo",
- ["nl"]="nieuw",
- ["pe"]="جدید",
- ["ro"]="nou",
+ ["keep"]={
+ ["cs"]="drzet",
+ ["de"]="behalte",
+ ["en"]="keep",
+ ["fr"]="conserver",
+ ["it"]="mantieni",
+ ["nl"]="handhaaf",
+ ["pe"]="نگهدار",
+ ["ro"]="mentine",
},
- ["next"]={
- ["cs"]="dalsi",
- ["de"]="folgende",
- ["en"]="next",
- ["fr"]="prochain",
- ["it"]="successivo",
- ["nl"]="volgende",
- ["pe"]="بعدی",
- ["ro"]="urmatorul",
+ ["kerncharacters"]={
+ ["en"]="kerncharacters",
+ ["fr"]="approchercaracteres",
},
- ["nextevenpage"]={
- ["cs"]="dalsisudastranka",
- ["de"]="naechstegeradeseite",
- ["en"]="nextevenpage",
- ["fr"]="pagepairesuivante",
- ["it"]="paginaparisuccessiva",
- ["nl"]="volgendeevenpagina",
- ["pe"]="صفحهزوجبعدی",
- ["ro"]="paginaparaurmatoarea",
+ ["knockout"]={
+ ["cs"]="knockout",
+ ["de"]="knockout",
+ ["en"]="knockout",
+ ["fr"]="knockout",
+ ["it"]="knockout",
+ ["nl"]="knockout",
+ ["pe"]="knockout",
+ ["ro"]="knockout",
},
- ["nextoddpage"]={
- ["cs"]="dalsilichastranka",
- ["de"]="naechsteungeradeseite",
- ["en"]="nextoddpage",
- ["fr"]="pageimpairesuivante",
- ["it"]="paginadisparisuccessiva",
- ["nl"]="volgendeonevenpagina",
- ["pe"]="صفحهفردبعدی",
- ["ro"]="paginaimparaurmatoarea",
+ ["label"]={
+ ["cs"]="popisek",
+ ["de"]="label",
+ ["en"]="label",
+ ["fr"]="etiquette",
+ ["it"]="etichetta",
+ ["nl"]="label",
+ ["pe"]="برچسب",
+ ["ro"]="eticheta",
},
- ["nextpage"]={
- ["cs"]="dalsistranka",
- ["de"]="folgendeseite",
- ["en"]="nextpage",
- ["fr"]="pagesuivante",
- ["it"]="paginasuccessiva",
- ["nl"]="volgendepagina",
- ["pe"]="صفحهبعدی",
- ["ro"]="paginaurmatoare",
+ ["landscape"]={
+ ["cs"]="nasirku",
+ ["de"]="querformat",
+ ["en"]="landscape",
+ ["fr"]="paysage",
+ ["it"]="orizzontale",
+ ["nl"]="liggend",
+ ["pe"]="صفحهگسترده",
+ ["ro"]="vedere",
},
- ["nextsubpage"]={
- ["cs"]="dalsipodstranka",
- ["de"]="folgendeunterseite",
- ["en"]="nextsubpage",
- ["fr"]="souspagesuivante",
- ["it"]="sottopaginasuccessiva",
- ["nl"]="volgendesubpagina",
- ["pe"]="زیرصفحهبعدی",
- ["ro"]="urmatoareasubpagina",
+ ["last"]={
+ ["cs"]="posledni",
+ ["de"]="letzte",
+ ["en"]="last",
+ ["fr"]="dernier",
+ ["it"]="ultimo",
+ ["nl"]="laatste",
+ ["pe"]="آخرین",
+ ["ro"]="ultim",
},
- ["no"]={
- ["cs"]="ne",
- ["de"]="nein",
- ["en"]="no",
- ["fr"]="non",
- ["it"]="no",
- ["nl"]="nee",
- ["pe"]="نه",
- ["ro"]="nu",
+ ["lastcolumn"]={
+ ["cs"]="lastcolumn",
+ ["de"]="lastcolumn",
+ ["en"]="lastcolumn",
+ ["fr"]="dernierecolonne",
+ ["it"]="lastcolumn",
+ ["nl"]="laatstekolom",
+ ["pe"]="آخرینستون",
+ ["ro"]="lastcolumn",
},
- ["nocheck"]={
- ["cs"]="nocheck",
- ["de"]="nocheck",
- ["en"]="nocheck",
- ["fr"]="nonverifie",
- ["it"]="nocheck",
- ["nl"]="geencontrole",
- ["pe"]="بدونبررسی",
- ["ro"]="nocheck",
+ ["lastpage"]={
+ ["cs"]="poslednistrana",
+ ["de"]="letzteseite",
+ ["en"]="lastpage",
+ ["fr"]="dernierepage",
+ ["it"]="ultimapagina",
+ ["nl"]="laatstepagina",
+ ["pe"]="صفحهآخر",
+ ["ro"]="ultimapagina",
},
- ["nodepth"]={
- ["en"]="nodepth",
+ ["lastpagenumber"]={
+ ["cs"]="lastpagenumber",
+ ["de"]="lastpagenumber",
+ ["en"]="lastpagenumber",
+ ["fr"]="numerodenierepage",
+ ["it"]="lastpagenumber",
+ ["nl"]="laatstepaginanummer",
+ ["pe"]="شماهصفحهآخر",
+ ["ro"]="lastpagenumber",
},
- ["nofit"]={
- ["cs"]="nofit",
- ["de"]="nofit",
- ["en"]="nofit",
- ["fr"]="nofit",
- ["it"]="nofit",
- ["nl"]="nietpassend",
- ["pe"]="بدونپرکردن",
- ["ro"]="nofit",
+ ["lastsubpage"]={
+ ["cs"]="poslaednipodstranka",
+ ["de"]="letzteunterseite",
+ ["en"]="lastsubpage",
+ ["fr"]="dernieresouspage",
+ ["it"]="ultimasottopagina",
+ ["nl"]="laatstesubpagina",
+ ["pe"]="زیرصفحهآخر",
+ ["ro"]="ultimasubpagina",
},
- ["nogrid"]={
- ["cs"]="nogrid",
- ["de"]="nogrid",
- ["en"]="nogrid",
- ["fr"]="nogrid",
- ["it"]="nogrid",
- ["nl"]="geengrid",
- ["pe"]="بدونتوری",
- ["ro"]="nogrid",
+ ["layer"]={
+ ["cs"]="layer",
+ ["de"]="layer",
+ ["en"]="layer",
+ ["fr"]="calque",
+ ["it"]="layer",
+ ["nl"]="layer",
+ ["pe"]="layer",
+ ["ro"]="layer",
},
- ["noheight"]={
- ["en"]="noheight",
+ ["left"]={
+ ["cs"]="vlevo",
+ ["de"]="links",
+ ["en"]="left",
+ ["fr"]="gauche",
+ ["it"]="sinistra",
+ ["nl"]="links",
+ ["pe"]="چپ",
+ ["ro"]="stanga",
},
- ["nohz"]={
- ["cs"]="nohz",
- ["de"]="nohz",
- ["en"]="nohz",
- ["fr"]="nohz",
- ["it"]="nohz",
- ["nl"]="geenhz",
- ["pe"]="nohz",
- ["ro"]="nohz",
+ ["leftedge"]={
+ ["cs"]="levahrana",
+ ["de"]="linkekante",
+ ["en"]="leftedge",
+ ["fr"]="bordgauche",
+ ["it"]="bordosinistro",
+ ["nl"]="linkerrand",
+ ["pe"]="لبهچپ",
+ ["ro"]="bordurastanga",
},
- ["noline"]={
- ["en"]="noline",
+ ["lefthanging"]={
+ ["cs"]="lefthanging",
+ ["de"]="lefthanging",
+ ["en"]="lefthanging",
+ ["fr"]="suspensiongauche",
+ ["it"]="lefthanging",
+ ["nl"]="linkshangend",
+ ["pe"]="آویزانچپ",
+ ["ro"]="lefthanging",
},
- ["nomarking"]={
- ["cs"]="zadneznaceni",
- ["de"]="keinebeschriftung",
- ["en"]="nomarking",
- ["fr"]="sansmarquage",
- ["it"]="nomarcature",
- ["nl"]="geenmarkering",
- ["pe"]="بدوننشانهگذاری",
- ["ro"]="faramarcare",
+ ["leftmargin"]={
+ ["cs"]="levyokraj",
+ ["de"]="linkerrand",
+ ["en"]="leftmargin",
+ ["fr"]="margegauche",
+ ["it"]="marginesinistro",
+ ["nl"]="linkermarge",
+ ["pe"]="حاشیهچپ",
+ ["ro"]="marginestanga",
},
- ["nomenubar"]={
- ["en"]="nomenubar",
- ["nl"]="geenmenubalk",
+ ["leftpage"]={
+ ["cs"]="levastranka",
+ ["de"]="linkerseite",
+ ["en"]="leftpage",
+ ["fr"]="surpagegauche",
+ ["it"]="paginasinistra",
+ ["nl"]="linkerpagina",
+ ["pe"]="صفحهچپ",
+ ["ro"]="paginastanga",
},
- ["none"]={
- ["cs"]="zadny",
- ["de"]="kein",
- ["en"]="none",
- ["fr"]="rien",
- ["it"]="nessuno",
- ["nl"]="geen",
- ["pe"]="هیچکدام",
- ["ro"]="niciunul",
+ ["lefttoright"]={
+ ["cs"]="lefttoright",
+ ["de"]="lefttoright",
+ ["en"]="lefttoright",
+ ["fr"]="gaucheadroite",
+ ["it"]="lefttoright",
+ ["nl"]="lefttoright",
+ ["pe"]="lefttoright",
+ ["ro"]="lefttoright",
},
- ["nonumber"]={
- ["cs"]="nonumber",
- ["de"]="nonumber",
- ["en"]="nonumber",
- ["fr"]="sansnumero",
- ["it"]="nonumber",
- ["nl"]="geennummer",
- ["pe"]="بدونشماره",
- ["ro"]="nonumber",
+ ["legend"]={
+ ["cs"]="legenda",
+ ["de"]="legende",
+ ["en"]="legend",
+ ["fr"]="legende",
+ ["it"]="legenda",
+ ["nl"]="legenda",
+ ["pe"]="راهنما",
+ ["ro"]="legenda",
},
- ["norepeat"]={
- ["en"]="norepeat",
+ ["less"]={
+ ["en"]="less",
+ ["fr"]="moins",
+ ["nl"]="minder",
},
- ["normal"]={
- ["cs"]="normalni",
- ["de"]="normal",
- ["en"]="normal",
- ["fr"]="normal",
- ["it"]="normale",
- ["nl"]="normaal",
- ["pe"]="نرمال",
- ["ro"]="normal",
+ ["lesshyphenation"]={
+ ["cs"]="lesshyphenation",
+ ["de"]="lesshyphenation",
+ ["en"]="lesshyphenation",
+ ["fr"]="moinsdecesure",
+ ["it"]="lesshyphenation",
+ ["nl"]="lesshyphenation",
+ ["pe"]="شکستکلماتکمتر",
+ ["ro"]="lesshyphenation",
},
- ["nospacing"]={
- ["cs"]="nospacing",
- ["de"]="nospacing",
- ["en"]="nospacing",
- ["fr"]="sansespacement",
- ["it"]="nospacing",
- ["nl"]="geenspatiering",
- ["pe"]="بدونفضاگذاری",
- ["ro"]="nospacing",
+ ["letterspacing"]={
+ ["en"]="letterspacing",
+ ["fr"]="espacementlettre",
},
- ["not"]={
- ["cs"]="ne",
- ["de"]="nicht",
- ["en"]="not",
- ["fr"]="pas",
- ["it"]="non",
- ["nl"]="niet",
- ["pe"]="بدون",
- ["ro"]="nu",
+ ["line"]={
+ ["cs"]="radek",
+ ["de"]="zeile",
+ ["en"]="line",
+ ["fr"]="ligne",
+ ["it"]="riga",
+ ["nl"]="regel",
+ ["pe"]="خط",
+ ["ro"]="linie",
},
- ["notation"]={
- ["en"]="notation",
+ ["linenote"]={
+ ["cs"]="linenote",
+ ["de"]="linenote",
+ ["en"]="linenote",
+ ["fr"]="noteligne",
+ ["it"]="linenote",
+ ["nl"]="regelnoot",
+ ["pe"]="خطنوشت",
+ ["ro"]="linenote",
},
- ["note"]={
- ["en"]="note",
+ ["lines"]={
+ ["cs"]="radky",
+ ["de"]="zeilen",
+ ["en"]="lines",
+ ["fr"]="lignes",
+ ["it"]="righe",
+ ["nl"]="regels",
+ ["pe"]="خطها",
+ ["ro"]="linii",
},
- ["nothanging"]={
- ["cs"]="nothanging",
- ["de"]="nothanging",
- ["en"]="nothanging",
- ["fr"]="nonsuspendu",
- ["it"]="nonsospeso",
- ["nl"]="niethangend",
- ["pe"]="بدونآویزانکردن",
- ["ro"]="nothanging",
+ ["linked"]={
+ ["en"]="linked",
+ ["fr"]="lie",
},
- ["nothyphenated"]={
- ["cs"]="nothyphenated",
- ["de"]="nothyphenated",
- ["en"]="nothyphenated",
- ["fr"]="nothyphenated",
- ["it"]="nonsillabato",
- ["nl"]="nietafgebroken",
- ["pe"]="بدونشکست",
- ["ro"]="nedespsilabe",
+ ["list"]={
+ ["cs"]="seznam",
+ ["de"]="liste",
+ ["en"]="list",
+ ["fr"]="liste",
+ ["it"]="elenco",
+ ["nl"]="lijst",
+ ["pe"]="لیست",
+ ["ro"]="lista",
},
- ["november"]={
- ["cs"]="listopad",
- ["de"]="november",
- ["en"]="november",
- ["fr"]="novembre",
- ["it"]="novembre",
- ["nl"]="november",
- ["pe"]="نوامبر",
- ["ro"]="noiembrie",
+ ["local"]={
+ ["cs"]="lokalne",
+ ["de"]="lokal",
+ ["en"]="local",
+ ["fr"]="local",
+ ["it"]="locale",
+ ["nl"]="lokaal",
+ ["pe"]="موضعی",
+ ["ro"]="local",
},
- ["nowhere"]={
- ["cs"]="nikde",
- ["de"]="nirgens",
- ["en"]="nowhere",
- ["fr"]="nulpart",
- ["it"]="danessunaparte",
- ["nl"]="nergens",
- ["pe"]="هیچحا",
- ["ro"]="niciunde",
+ ["localenvironment"]={
+ ["cs"]="lokalnihoprostredi",
+ ["de"]="lokaleumgebung",
+ ["en"]="localenvironment",
+ ["fr"]="environnementlocal",
+ ["it"]="ambientelocale",
+ ["nl"]="deelomgeving",
+ ["pe"]="محیطموضعی",
+ ["ro"]="mediulocal",
},
- ["nowhite"]={
- ["cs"]="zadnabila",
- ["de"]="keinweiss",
- ["en"]="nowhite",
- ["fr"]="sansblanc",
- ["it"]="nobianco",
- ["nl"]="geenwit",
- ["pe"]="سفیدنه",
- ["ro"]="faraalb",
+ ["logo"]={
+ ["cs"]="logo",
+ ["de"]="logo",
+ ["en"]="logo",
+ ["fr"]="logo",
+ ["it"]="logo",
+ ["nl"]="logo",
+ ["pe"]="آرم",
+ ["ro"]="logo",
},
- ["number"]={
- ["cs"]="cislo",
- ["de"]="nummer",
- ["en"]="number",
- ["fr"]="numero",
- ["it"]="numero",
- ["nl"]="nummer",
- ["pe"]="شماره",
- ["ro"]="numar",
+ ["logos"]={
+ ["cs"]="loga",
+ ["de"]="logos",
+ ["en"]="logos",
+ ["fr"]="logos",
+ ["it"]="loghi",
+ ["nl"]="logos",
+ ["pe"]="آرمها",
+ ["ro"]="logos",
},
- ["numbers"]={
- ["cs"]="cisla",
- ["de"]="ziffern",
- ["en"]="numbers",
- ["fr"]="numeros",
- ["it"]="numeri",
- ["nl"]="cijfers",
- ["pe"]="شمارهها",
- ["ro"]="numere",
+ ["lohi"]={
+ ["cs"]="nivy",
+ ["de"]="hoti",
+ ["en"]="lohi",
+ ["fr"]="inex",
+ ["it"]="pedap",
+ ["nl"]="laho",
+ ["pe"]="پابا",
+ ["ro"]="lohi",
},
- ["october"]={
- ["cs"]="rijen",
- ["de"]="oktober",
- ["en"]="october",
- ["fr"]="octobre",
- ["it"]="ottobre",
- ["nl"]="oktober",
- ["pe"]="اکتبر",
- ["ro"]="octombrie",
+ ["long"]={
+ ["en"]="long",
+ ["fr"]="long",
},
- ["odd"]={
- ["cs"]="liche",
- ["de"]="ungerade",
- ["en"]="odd",
- ["fr"]="impair",
- ["it"]="dispari",
- ["nl"]="oneven",
- ["pe"]="فرد",
- ["ro"]="impar",
+ ["loose"]={
+ ["cs"]="uvolnene",
+ ["de"]="lose",
+ ["en"]="loose",
+ ["fr"]="envrac",
+ ["it"]="lento",
+ ["nl"]="los",
+ ["pe"]="شل",
+ ["ro"]="larg",
},
- ["off"]={
- ["cs"]="vyp",
- ["de"]="aus",
- ["en"]="off",
- ["fr"]="desactive",
- ["it"]="disattivo",
- ["nl"]="uit",
- ["pe"]="خاموش",
- ["ro"]="dezactivat",
+ ["low"]={
+ ["cs"]="nizko",
+ ["de"]="tief",
+ ["en"]="low",
+ ["fr"]="ind",
+ ["it"]="basso",
+ ["nl"]="laag",
+ ["pe"]="پایین",
+ ["ro"]="jos",
},
- ["offset"]={
- ["cs"]="offset",
- ["de"]="offset",
- ["en"]="offset",
- ["fr"]="offset",
- ["it"]="offset",
- ["nl"]="offset",
- ["pe"]="آفست",
- ["ro"]="offset",
+ ["ls"]={
+ ["cs"]="ls",
+ ["de"]="ls",
+ ["en"]="ls",
+ ["fr"]="ls",
+ ["it"]="ls",
+ ["nl"]="ls",
+ ["pe"]="ls",
+ ["ro"]="ls",
},
- ["old"]={
- ["cs"]="old",
- ["de"]="old",
- ["en"]="old",
- ["fr"]="old",
- ["it"]="old",
- ["nl"]="oud",
- ["pe"]="قدیمی",
- ["ro"]="old",
+ ["makeup"]={
+ ["cs"]="zlom",
+ ["de"]="umbruch",
+ ["en"]="makeup",
+ ["fr"]="composition",
+ ["it"]="makeup",
+ ["nl"]="opmaak",
+ ["pe"]="آرایش",
+ ["ro"]="marcaj",
},
- ["oldstyle"]={
- ["en"]="oldstyle",
+ ["mar"]={
+ ["cs"]="mar",
+ ["de"]="mar",
+ ["en"]="mar",
+ ["fr"]="rem",
+ ["it"]="mar",
+ ["nl"]="mar",
+ ["pe"]="حاش",
+ ["ro"]="mar",
},
- ["fractions"]={
- ["en"]="fractions",
+ ["march"]={
+ ["cs"]="brezen",
+ ["de"]="maerz",
+ ["en"]="march",
+ ["fr"]="mars",
+ ["it"]="marzo",
+ ["nl"]="maart",
+ ["pe"]="مارس",
+ ["ro"]="martie",
+ },
+ ["margin"]={
+ ["cs"]="marginalie",
+ ["de"]="marginalie",
+ ["en"]="margin",
+ ["fr"]="marge",
+ ["it"]="margine",
+ ["nl"]="marge",
+ ["pe"]="حاشیه",
+ ["ro"]="margine",
},
- ["on"]={
- ["cs"]="zap",
- ["de"]="an",
- ["en"]="on",
- ["fr"]="actif",
- ["it"]="attivo",
- ["nl"]="aan",
- ["pe"]="روی",
- ["ro"]="on",
+ ["marginedge"]={
+ ["cs"]="textovahrana",
+ ["de"]="marginalkante",
+ ["en"]="marginedge",
+ ["fr"]="margebord",
+ ["it"]="bordomargine",
+ ["nl"]="kantlijn",
+ ["pe"]="لبهحاشیه",
+ ["ro"]="marginebordura",
},
- ["one"]={
- ["cs"]="jedna",
- ["de"]="eins",
- ["en"]="one",
- ["fr"]="un",
- ["it"]="uno",
- ["nl"]="een",
- ["pe"]="یک",
- ["ro"]="unu",
+ ["margintext"]={
+ ["cs"]="marginalnitext",
+ ["de"]="marginaltext",
+ ["en"]="margintext",
+ ["fr"]="textemarge",
+ ["it"]="testoinmargine",
+ ["nl"]="margetekst",
+ ["pe"]="متنحاشیه",
+ ["ro"]="textmarginal",
},
- ["opposite"]={
- ["cs"]="naproti",
- ["de"]="gegenueber",
- ["en"]="opposite",
- ["fr"]="opposition",
- ["it"]="opposto",
- ["nl"]="naast",
- ["pe"]="مخالف",
- ["ro"]="opus",
+ ["margintitle"]={
+ ["cs"]="titulmarginalie",
+ ["de"]="marginaltitel",
+ ["en"]="margintitle",
+ ["fr"]="titremarge",
+ ["it"]="titoloinmargine",
+ ["nl"]="margetitel",
+ ["pe"]="عنوانحاشیه",
+ ["ro"]="titlumarginal",
},
- ["outer"]={
- ["cs"]="vnejsi",
- ["de"]="aussen",
- ["en"]="outer",
- ["fr"]="exterieur",
- ["it"]="esterno",
- ["nl"]="buiten",
- ["pe"]="خارجی",
- ["ro"]="extern",
+ ["marking"]={
+ ["cs"]="znaceni",
+ ["de"]="beschriftung",
+ ["en"]="marking",
+ ["fr"]="marquage",
+ ["it"]="marcatura",
+ ["nl"]="markering",
+ ["pe"]="نشانهگذاری",
+ ["ro"]="marcaje",
},
- ["outeredge"]={
- ["cs"]="outeredge",
- ["de"]="outeredge",
- ["en"]="outeredge",
- ["fr"]="bordexterieur",
- ["it"]="bordoesterno",
- ["nl"]="buitenrand",
- ["pe"]="لبهخارجی",
- ["ro"]="outeredge",
+ ["math"]={
+ ["en"]="math",
+ ["fr"]="math",
},
- ["outermargin"]={
- ["cs"]="outermargin",
- ["de"]="outermargin",
- ["en"]="outermargin",
- ["fr"]="margeexterieure",
- ["it"]="margineesterno",
- ["nl"]="buitenmarge",
- ["pe"]="حاشیهخارجی",
- ["ro"]="outermargin",
+ ["mathalignment"]={
+ ["cs"]="mathalignment",
+ ["de"]="mathalignment",
+ ["en"]="mathalignment",
+ ["fr"]="alignementmath",
+ ["it"]="mathalignment",
+ ["nl"]="wiskundeuitlijnen",
+ ["pe"]="تنظیمریاضی",
+ ["ro"]="mathalignment",
},
- ["overbar"]={
- ["cs"]="nadtrzeno",
- ["de"]="ueberstrichen",
- ["en"]="overbar",
- ["fr"]="overbar",
- ["it"]="sopralinea",
- ["nl"]="overstreep",
- ["pe"]="میلهرو",
- ["ro"]="barasus",
+ ["mathcases"]={
+ ["cs"]="mathcases",
+ ["de"]="mathcases",
+ ["en"]="mathcases",
+ ["fr"]="casmath",
+ ["it"]="mathcases",
+ ["nl"]="mathcases",
+ ["pe"]="حالتهایریاضی",
+ ["ro"]="mathcases",
},
- ["overbars"]={
- ["cs"]="nadtrzeni",
- ["de"]="ueberstreichen",
- ["en"]="overbars",
- ["fr"]="overbars",
- ["it"]="sopralinee",
- ["nl"]="overstrepen",
- ["pe"]="میلههارو",
- ["ro"]="supralinie",
+ ["mathematics"]={
+ ["cs"]="mathematika",
+ ["de"]="mathematik",
+ ["en"]="mathematics",
+ ["fr"]="mathematics",
+ ["it"]="matematica",
+ ["nl"]="wiskunde",
+ ["pe"]="ریاضی",
+ ["ro"]="matematica",
},
- ["overlay"]={
- ["cs"]="prekryv",
- ["de"]="overlay",
- ["en"]="overlay",
- ["fr"]="revetement",
- ["it"]="sovrapponi",
- ["nl"]="overlay",
- ["pe"]="پوشش",
- ["ro"]="overlay",
+ ["mathmatrix"]={
+ ["cs"]="mathmatrix",
+ ["de"]="mathmatrix",
+ ["en"]="mathmatrix",
+ ["fr"]="matricemath",
+ ["it"]="mathmatrix",
+ ["nl"]="wiskundematrix",
+ ["pe"]="ماتریشریاضی",
+ ["ro"]="mathmatrix",
},
- ["overprint"]={
- ["cs"]="overprint",
- ["de"]="overprint",
- ["en"]="overprint",
- ["fr"]="overprint",
- ["it"]="overprint",
- ["nl"]="overprint",
- ["pe"]="overprint",
- ["ro"]="overprint",
+ ["max"]={
+ ["cs"]="max",
+ ["de"]="max",
+ ["en"]="max",
+ ["fr"]="max",
+ ["it"]="max",
+ ["nl"]="max",
+ ["pe"]="بیشترین",
+ ["ro"]="max",
},
- ["overstrike"]={
- ["cs"]="preskrtnuto",
- ["de"]="durchgestrichen",
- ["en"]="overstrike",
- ["fr"]="surlignetout",
- ["it"]="sbarrato",
- ["nl"]="doorstreep",
- ["pe"]="خطزدن",
- ["ro"]="liniepeste",
+ ["maxdepth"]={
+ ["en"]="maxdepth",
+ ["fr"]="profondeurmax",
+ ["nl"]="maxdiepte",
},
- ["overstrikes"]={
- ["cs"]="preskrtnuti",
- ["de"]="durchstreichen",
- ["en"]="overstrikes",
- ["fr"]="surligne",
- ["it"]="sbarrati",
- ["nl"]="doorstrepen",
- ["pe"]="خطزدنها",
- ["ro"]="liniipeste",
+ ["maxheight"]={
+ ["en"]="maxheight",
+ ["fr"]="hauteurmax",
+ ["nl"]="maxhoogte",
},
- ["packed"]={
- ["cs"]="zhustene",
- ["de"]="gepackt",
- ["en"]="packed",
- ["fr"]="groupe",
- ["it"]="impaccato",
- ["nl"]="opelkaar",
- ["pe"]="فشرده",
- ["ro"]="impachetat",
+ ["maxwidth"]={
+ ["en"]="maxwidth",
+ ["fr"]="largeurmax",
+ ["nl"]="maxbreedte",
},
- ["page"]={
- ["cs"]="stranka",
- ["de"]="seite",
- ["en"]="page",
- ["fr"]="page",
- ["it"]="pagina",
- ["nl"]="pagina",
- ["pe"]="صفحه",
- ["ro"]="pagina",
+ ["may"]={
+ ["cs"]="kveten",
+ ["de"]="mai",
+ ["en"]="may",
+ ["fr"]="mai",
+ ["it"]="maggio",
+ ["nl"]="mei",
+ ["pe"]="مه",
+ ["ro"]="mai",
},
- ["pagecomment"]={
- ["cs"]="komentarstranky",
- ["de"]="pagecomment",
- ["en"]="pagecomment",
- ["fr"]="commentairepage",
- ["it"]="commentopagina",
- ["nl"]="paginacommentaar",
- ["pe"]="توضیحصفحه",
- ["ro"]="comentariupagina",
+ ["mediaeval"]={
+ ["cs"]="stredoveky",
+ ["de"]="mittelalterlich",
+ ["en"]="mediaeval",
+ ["fr"]="medieval",
+ ["it"]="medievale",
+ ["nl"]="mediaeval",
+ ["pe"]="mediaeval",
+ ["ro"]="medieval",
},
- ["pagenumber"]={
- ["cs"]="cislostranky",
- ["de"]="seitennummer",
- ["en"]="pagenumber",
- ["fr"]="numeropage",
- ["it"]="numeropagina",
- ["nl"]="paginanummer",
- ["pe"]="شمارهصفحه",
- ["ro"]="numarpagina",
+ ["medium"]={
+ ["cs"]="stredni",
+ ["de"]="mittel",
+ ["en"]="medium",
+ ["fr"]="moyen",
+ ["it"]="medio",
+ ["nl"]="middel",
+ ["pe"]="متوسط",
+ ["ro"]="mediu",
},
- ["paper"]={
- ["cs"]="papir",
- ["de"]="papier",
- ["en"]="paper",
- ["fr"]="papier",
- ["it"]="carta",
- ["nl"]="papier",
- ["pe"]="برگ",
- ["ro"]="foaie",
+ ["middle"]={
+ ["cs"]="nastred",
+ ["de"]="mittig",
+ ["en"]="middle",
+ ["fr"]="milieu",
+ ["it"]="centro",
+ ["nl"]="midden",
+ ["pe"]="میان",
+ ["ro"]="centru",
},
- ["paragraph"]={
- ["cs"]="odstavec",
- ["de"]="absatz",
- ["en"]="paragraph",
- ["fr"]="paragraphe",
- ["it"]="capoverso",
- ["nl"]="alinea",
- ["pe"]="پاراگراف",
- ["ro"]="paragraf",
+ ["min"]={
+ ["cs"]="min",
+ ["de"]="min",
+ ["en"]="min",
+ ["fr"]="min",
+ ["it"]="min",
+ ["nl"]="min",
+ ["pe"]="کمترین",
+ ["ro"]="min",
},
- ["part"]={
- ["cs"]="cast",
- ["de"]="teil",
- ["en"]="part",
- ["fr"]="partie",
- ["it"]="parte",
- ["nl"]="deel",
- ["pe"]="قسمت",
- ["ro"]="parte",
+ ["mindepth"]={
+ ["en"]="mindepth",
+ ["fr"]="profondeurmin",
+ ["nl"]="mindiepte",
},
- ["positive"]={
- ["cs"]="positiv",
- ["de"]="positiv",
- ["en"]="positive",
- ["fr"]="positif",
- ["it"]="positivo",
- ["nl"]="positief",
- ["pe"]="مثبت",
- ["ro"]="positiv",
+ ["minheight"]={
+ ["cs"]="minvyska",
+ ["de"]="minhoehe",
+ ["en"]="minheight",
+ ["fr"]="hauteurmin",
+ ["it"]="altezzamin",
+ ["nl"]="minhoogte",
+ ["pe"]="کمترینارتفاع",
+ ["ro"]="inaltimeminima",
},
- ["postponing"]={
- ["cs"]="odlozit",
- ["de"]="verschieben",
- ["en"]="postponing",
- ["fr"]="postponing",
- ["it"]="posporre",
- ["nl"]="uitstellen",
- ["pe"]="تاخیر",
- ["ro"]="postponing",
+ ["minwidth"]={
+ ["cs"]="minsirka",
+ ["de"]="minbreite",
+ ["en"]="minwidth",
+ ["fr"]="largeurmin",
+ ["it"]="ampiezzamin",
+ ["nl"]="minbreedte",
+ ["pe"]="کمترینعرض",
+ ["ro"]="latimeminima",
},
- ["postscript"]={
- ["cs"]="postscript",
- ["de"]="postscript",
- ["en"]="postscript",
- ["fr"]="postscript",
- ["it"]="postscript",
- ["nl"]="postscript",
- ["pe"]="پستاسکریپت",
- ["ro"]="postscript",
+ ["mirrored"]={
+ ["cs"]="zrcadleno",
+ ["de"]="gespiegelt",
+ ["en"]="mirrored",
+ ["fr"]="reflete",
+ ["it"]="riflesso",
+ ["nl"]="gespiegeld",
+ ["pe"]="منعکس",
+ ["ro"]="oglindit",
},
- ["precedingpage"]={
- ["en"]="precedingpage",
- ["nl"]="voorafgaandepagina",
+ ["mixed"]={
+ ["en"]="mixed",
+ ["fr"]="mixte",
},
- ["preference"]={
- ["cs"]="nastaveni",
- ["de"]="einstellung",
- ["en"]="preference",
- ["fr"]="preference",
- ["it"]="preferenza",
- ["nl"]="voorkeur",
- ["pe"]="ترجیح",
- ["ro"]="preferinta",
+ ["monday"]={
+ ["cs"]="pondeli",
+ ["de"]="montag",
+ ["en"]="monday",
+ ["fr"]="lundi",
+ ["it"]="lunedi",
+ ["nl"]="maandag",
+ ["pe"]="دوشنبه",
+ ["ro"]="luni",
},
- ["preview"]={
- ["cs"]="nahled",
- ["de"]="vorschau",
- ["en"]="preview",
- ["fr"]="previsualisation",
- ["it"]="anteprima",
- ["nl"]="preview",
- ["pe"]="پیشدید",
- ["ro"]="previzualizare",
+ ["mono"]={
+ ["cs"]="mono",
+ ["de"]="mono",
+ ["en"]="mono",
+ ["fr"]="mono",
+ ["it"]="mono",
+ ["nl"]="mono",
+ ["pe"]="مونو",
+ ["ro"]="mono",
},
- ["previous"]={
- ["cs"]="predchozi",
- ["de"]="vorig",
- ["en"]="previous",
- ["fr"]="precedent",
- ["it"]="precedente",
- ["nl"]="vorige",
- ["pe"]="قبلی",
- ["ro"]="precedent",
+ ["monobold"]={
+ ["cs"]="monotucne",
+ ["de"]="monofett",
+ ["en"]="monobold",
+ ["fr"]="monogras",
+ ["it"]="monograssetto",
+ ["nl"]="monovet",
+ ["pe"]="monobold",
+ ["ro"]="monoaldin",
},
- ["previousevenpage"]={
- ["cs"]="predchozisudastranka",
- ["de"]="vorigegeradeseite",
- ["en"]="previousevenpage",
- ["fr"]="pagepaireprecedente",
- ["it"]="paginapariprecedente",
- ["nl"]="vorigeevenpagina",
- ["pe"]="صفحهزوجقبلی",
- ["ro"]="paginaparaprecedenta",
+ ["mononormal"]={
+ ["en"]="mononormal",
+ ["fr"]="normalmono",
},
- ["previousoddpage"]={
- ["cs"]="predchozilichastranka",
- ["de"]="vorigeungeradeseite",
- ["en"]="previousoddpage",
- ["fr"]="pageimpaireprecedente",
- ["it"]="paginadispariprecedente",
- ["nl"]="vorigeonevenpagina",
- ["pe"]="صفحهفردقبلی",
- ["ro"]="paginaimparaprecedenta",
+ ["month"]={
+ ["cs"]="mesic",
+ ["de"]="monat",
+ ["en"]="month",
+ ["fr"]="mois",
+ ["it"]="mese",
+ ["nl"]="maand",
+ ["pe"]="ماه",
+ ["ro"]="luna",
},
- ["previouspage"]={
- ["cs"]="predchozistranka",
- ["de"]="vorigeseite",
- ["en"]="previouspage",
- ["fr"]="pageprecedente",
- ["it"]="paginaprecedente",
- ["nl"]="vorigepagina",
- ["pe"]="صفحهقبلی",
- ["ro"]="paginaanterioara",
+ ["more"]={
+ ["en"]="more",
+ ["fr"]="plus",
+ ["nl"]="meer",
},
- ["previoussubpage"]={
- ["cs"]="predchozipodstranka",
- ["de"]="vorigeunterseite",
- ["en"]="previoussubpage",
- ["fr"]="souspageprecedente",
- ["it"]="sottopaginaprecedente",
- ["nl"]="vorigesubpagina",
- ["pe"]="زیرصفحهقبلی",
- ["ro"]="subpaginaanterioara",
+ ["morehyphenation"]={
+ ["cs"]="morehyphenation",
+ ["de"]="morehyphenation",
+ ["en"]="morehyphenation",
+ ["fr"]="plusdecesure",
+ ["it"]="morehyphenation",
+ ["nl"]="morehyphenation",
+ ["pe"]="شکستکلماتبیشتر",
+ ["ro"]="morehyphenation",
},
- ["print"]={
- ["en"]="print",
- ["nl"]="print",
+ ["name"]={
+ ["cs"]="jmeno",
+ ["de"]="name",
+ ["en"]="name",
+ ["fr"]="nom",
+ ["it"]="nome",
+ ["nl"]="naam",
+ ["pe"]="نام",
+ ["ro"]="nume",
},
- ["printable"]={
- ["cs"]="tisknutelne",
- ["de"]="druckbar",
- ["en"]="printable",
- ["fr"]="editable",
- ["it"]="stampabile",
- ["nl"]="printbaar",
- ["pe"]="قابلچاپ",
- ["ro"]="tiparibil",
+ ["narrow"]={
+ ["cs"]="uzky",
+ ["de"]="schmall",
+ ["en"]="narrow",
+ ["fr"]="etroit",
+ ["it"]="stretto",
+ ["nl"]="smal",
+ ["pe"]="نازک",
+ ["ro"]="ingust",
+ },
+ ["negative"]={
+ ["cs"]="negativ",
+ ["de"]="negativ",
+ ["en"]="negative",
+ ["fr"]="negatif",
+ ["it"]="negativo",
+ ["nl"]="negatief",
+ ["pe"]="منفی",
+ ["ro"]="negativ",
},
- ["process"]={
- ["cs"]="process",
- ["de"]="process",
- ["en"]="process",
- ["fr"]="process",
- ["it"]="process",
- ["nl"]="proces",
- ["pe"]="پردازش",
- ["ro"]="process",
+ ["never"]={
+ ["cs"]="nikdy",
+ ["de"]="nie",
+ ["en"]="never",
+ ["fr"]="jamais",
+ ["it"]="mai",
+ ["nl"]="nooit",
+ ["pe"]="هیچگاه",
+ ["ro"]="niciodata",
},
- ["product"]={
- ["cs"]="produkt",
- ["de"]="produkt",
- ["en"]="product",
- ["fr"]="produit",
- ["it"]="prodotto",
- ["nl"]="produkt",
- ["pe"]="محصول",
- ["ro"]="produs",
+ ["new"]={
+ ["cs"]="novy",
+ ["de"]="neu",
+ ["en"]="new",
+ ["fr"]="nouveau",
+ ["it"]="nuovo",
+ ["nl"]="nieuw",
+ ["pe"]="جدید",
+ ["ro"]="nou",
},
- ["program"]={
- ["cs"]="program",
- ["de"]="programm",
- ["en"]="program",
- ["fr"]="programme",
- ["it"]="programma",
- ["nl"]="programma",
- ["pe"]="برنامه",
- ["ro"]="program",
+ ["next"]={
+ ["cs"]="dalsi",
+ ["de"]="folgende",
+ ["en"]="next",
+ ["fr"]="suivant",
+ ["it"]="successivo",
+ ["nl"]="volgende",
+ ["pe"]="بعدی",
+ ["ro"]="urmatorul",
},
- ["project"]={
- ["cs"]="projekt",
- ["de"]="projekt",
- ["en"]="project",
- ["fr"]="projet",
- ["it"]="progetto",
- ["nl"]="project",
- ["pe"]="پروژه",
- ["ro"]="proiect",
+ ["nextevenpage"]={
+ ["cs"]="dalsisudastranka",
+ ["de"]="naechstegeradeseite",
+ ["en"]="nextevenpage",
+ ["fr"]="pagepairesuivante",
+ ["it"]="paginaparisuccessiva",
+ ["nl"]="volgendeevenpagina",
+ ["pe"]="صفحهزوجبعدی",
+ ["ro"]="paginaparaurmatoarea",
},
- ["protected"]={
- ["cs"]="chranene",
- ["de"]="geschuetzt",
- ["en"]="protected",
- ["fr"]="protege",
- ["it"]="protetto",
- ["nl"]="beschermd",
- ["pe"]="حفاظتشده",
- ["ro"]="protejat",
+ ["nextoddpage"]={
+ ["cs"]="dalsilichastranka",
+ ["de"]="naechsteungeradeseite",
+ ["en"]="nextoddpage",
+ ["fr"]="pageimpairesuivante",
+ ["it"]="paginadisparisuccessiva",
+ ["nl"]="volgendeonevenpagina",
+ ["pe"]="صفحهفردبعدی",
+ ["ro"]="paginaimparaurmatoarea",
},
- ["quadruple"]={
- ["cs"]="ctyrnasobny",
- ["de"]="viertel",
- ["en"]="quadruple",
- ["fr"]="quadruple",
- ["it"]="quadruplo",
- ["nl"]="viertal",
- ["pe"]="quadruple",
- ["ro"]="cvadrupul",
+ ["nextpage"]={
+ ["cs"]="dalsistranka",
+ ["de"]="folgendeseite",
+ ["en"]="nextpage",
+ ["fr"]="pagesuivante",
+ ["it"]="paginasuccessiva",
+ ["nl"]="volgendepagina",
+ ["pe"]="صفحهبعدی",
+ ["ro"]="paginaurmatoare",
},
- ["quarterline"]={
- ["en"]="quarterline",
- ["nl"]="kwartregel",
+ ["nextsubpage"]={
+ ["cs"]="dalsipodstranka",
+ ["de"]="folgendeunterseite",
+ ["en"]="nextsubpage",
+ ["fr"]="souspagesuivante",
+ ["it"]="sottopaginasuccessiva",
+ ["nl"]="volgendesubpagina",
+ ["pe"]="زیرصفحهبعدی",
+ ["ro"]="urmatoareasubpagina",
},
- ["quotation"]={
- ["cs"]="citace",
- ["de"]="zitat",
- ["en"]="quotation",
- ["fr"]="citation",
- ["it"]="citazione",
- ["nl"]="citaat",
- ["pe"]="نقلقول",
- ["ro"]="citat",
+ ["nine"]={
+ ["cs"]="nine",
+ ["de"]="neun",
+ ["en"]="nine",
+ ["fr"]="neuf",
+ ["it"]="nine",
+ ["nl"]="negen",
+ ["pe"]="nine",
+ ["ro"]="nine",
},
- ["quote"]={
- ["cs"]="citovat",
- ["de"]="zitieren",
- ["en"]="quote",
- ["fr"]="citer",
- ["it"]="menzione",
- ["nl"]="citeer",
- ["pe"]="نقل",
- ["ro"]="minicitat",
+ ["no"]={
+ ["cs"]="ne",
+ ["de"]="nein",
+ ["en"]="no",
+ ["fr"]="non",
+ ["it"]="no",
+ ["nl"]="nee",
+ ["pe"]="نه",
+ ["ro"]="nu",
},
- ["ran"]={
- ["cs"]="rozsah",
- ["de"]="ran",
- ["en"]="ran",
- ["fr"]="cours",
- ["it"]="corse",
- ["nl"]="ran",
- ["pe"]="برد",
- ["ro"]="rulat",
+ ["nocheck"]={
+ ["cs"]="nocheck",
+ ["de"]="nocheck",
+ ["en"]="nocheck",
+ ["fr"]="sansverifier",
+ ["it"]="nocheck",
+ ["nl"]="geencontrole",
+ ["pe"]="بدونبررسی",
+ ["ro"]="nocheck",
},
- ["random"]={
- ["cs"]="nahodny",
- ["de"]="zufaellig",
- ["en"]="random",
- ["fr"]="aleatoire",
- ["it"]="casuale",
- ["nl"]="willekeurig",
- ["pe"]="تصادفی",
- ["ro"]="aleator",
+ ["nodepth"]={
+ ["en"]="nodepth",
+ ["fr"]="sansprodondeur",
},
- ["readonly"]={
- ["cs"]="pouzeprocteni",
- ["de"]="nurlesbar",
- ["en"]="readonly",
- ["fr"]="lectureseule",
- ["it"]="solalettura",
- ["nl"]="alleenleesbaar",
- ["pe"]="تنهاخواندنی",
- ["ro"]="readonly",
+ ["nofit"]={
+ ["cs"]="nofit",
+ ["de"]="nofit",
+ ["en"]="nofit",
+ ["fr"]="sansadapter",
+ ["it"]="nofit",
+ ["nl"]="nietpassend",
+ ["pe"]="بدونپرکردن",
+ ["ro"]="nofit",
},
- ["rectangular"]={
- ["cs"]="pravouhly",
- ["de"]="rechteckig",
- ["en"]="rectangular",
- ["fr"]="rectangulaire",
- ["it"]="rettangolare",
- ["nl"]="recht",
- ["pe"]="چهارگوشه",
- ["ro"]="rectangular",
+ ["nogrid"]={
+ ["cs"]="nogrid",
+ ["de"]="nogrid",
+ ["en"]="nogrid",
+ ["fr"]="sansgrille",
+ ["it"]="nogrid",
+ ["nl"]="geengrid",
+ ["pe"]="بدونتوری",
+ ["ro"]="nogrid",
},
- ["reference"]={
- ["cs"]="odkaz",
- ["de"]="referenz",
- ["en"]="reference",
- ["fr"]="reference",
- ["it"]="riferimento",
- ["nl"]="referentie",
- ["pe"]="مرجع",
- ["ro"]="referinta",
+ ["noheight"]={
+ ["en"]="noheight",
+ ["fr"]="sanshauteur",
},
- ["referral"]={
- ["cs"]="znacka",
- ["de"]="merkmal",
- ["en"]="referral",
- ["fr"]="referral",
- ["it"]="referral",
- ["nl"]="kenmerk",
- ["pe"]="مراجعه",
- ["ro"]="referinta",
+ ["nohz"]={
+ ["cs"]="nohz",
+ ["de"]="nohz",
+ ["en"]="nohz",
+ ["fr"]="sanshz",
+ ["it"]="nohz",
+ ["nl"]="geenhz",
+ ["pe"]="nohz",
+ ["ro"]="nohz",
},
- ["register"]={
- ["cs"]="rejstrik",
- ["de"]="register",
- ["en"]="register",
- ["fr"]="registre",
- ["it"]="registro",
- ["nl"]="register",
- ["pe"]="ثبت",
- ["ro"]="registru",
+ ["noline"]={
+ ["en"]="noline",
+ ["fr"]="sansligne",
},
- ["regular"]={
- ["cs"]="pravidelne",
- ["de"]="regular",
- ["en"]="regular",
- ["fr"]="regulier",
- ["it"]="regolare",
- ["nl"]="regular",
- ["pe"]="منظم",
- ["ro"]="regular",
+ ["nomarking"]={
+ ["cs"]="zadneznaceni",
+ ["de"]="keinebeschriftung",
+ ["en"]="nomarking",
+ ["fr"]="sansmarquage",
+ ["it"]="nomarcature",
+ ["nl"]="geenmarkering",
+ ["pe"]="بدوننشانهگذاری",
+ ["ro"]="faramarcare",
},
- ["relative"]={
- ["cs"]="relativni",
- ["de"]="relativ",
- ["en"]="relative",
- ["fr"]="relatif",
- ["it"]="relativo",
- ["nl"]="relatief",
- ["pe"]="نسبی",
- ["ro"]="relativ",
+ ["nomenubar"]={
+ ["en"]="nomenubar",
+ ["fr"]="sansbarremenu",
+ ["nl"]="geenmenubalk",
},
- ["repeat"]={
- ["cs"]="opakovat",
- ["de"]="wiederholen",
- ["en"]="repeat",
- ["fr"]="repete",
- ["it"]="ripeti",
- ["nl"]="herhaal",
- ["pe"]="تکرار",
- ["ro"]="repetat",
+ ["none"]={
+ ["cs"]="zadny",
+ ["de"]="kein",
+ ["en"]="none",
+ ["fr"]="aucun",
+ ["it"]="nessuno",
+ ["nl"]="geen",
+ ["pe"]="هیچکدام",
+ ["ro"]="niciunul",
},
- ["required"]={
- ["cs"]="pozadovane",
- ["de"]="obligatorisch",
- ["en"]="required",
- ["fr"]="recquis",
- ["it"]="richiestp",
- ["nl"]="verplicht",
- ["pe"]="موردنیاز",
- ["ro"]="obligatoriu",
+ ["nonumber"]={
+ ["cs"]="nonumber",
+ ["de"]="nonumber",
+ ["en"]="nonumber",
+ ["fr"]="sansnumero",
+ ["it"]="nonumber",
+ ["nl"]="geennummer",
+ ["pe"]="بدونشماره",
+ ["ro"]="nonumber",
},
- ["reset"]={
- ["cs"]="reset",
- ["de"]="zuruecksetzten",
- ["en"]="reset",
- ["fr"]="raz",
- ["it"]="reimposta",
- ["nl"]="reset",
- ["pe"]="بازنشانی",
- ["ro"]="reset",
+ ["norepeat"]={
+ ["en"]="norepeat",
+ ["fr"]="sansrepetition",
},
- ["reverse"]={
- ["cs"]="reverse",
- ["de"]="reverse",
- ["en"]="reverse",
- ["fr"]="inverse",
- ["it"]="invertito",
- ["nl"]="omgekeerd",
- ["pe"]="برعکس",
- ["ro"]="reverse",
+ ["normal"]={
+ ["cs"]="normalni",
+ ["de"]="normal",
+ ["en"]="normal",
+ ["fr"]="normal",
+ ["it"]="normale",
+ ["nl"]="normaal",
+ ["pe"]="نرمال",
+ ["ro"]="normal",
},
- ["right"]={
- ["cs"]="vpravo",
- ["de"]="rechts",
- ["en"]="right",
- ["fr"]="droite",
- ["it"]="destra",
- ["nl"]="rechts",
- ["pe"]="راست",
- ["ro"]="dreapta",
+ ["normalshort"]={
+ ["en"]="normalshort",
},
- ["rightedge"]={
- ["cs"]="pravahrana",
- ["de"]="rechterkante",
- ["en"]="rightedge",
- ["fr"]="borddroit",
- ["it"]="bordodestro",
- ["nl"]="rechterrand",
- ["pe"]="لبهراست",
- ["ro"]="borduradreapta",
+ ["nospacing"]={
+ ["cs"]="nospacing",
+ ["de"]="nospacing",
+ ["en"]="nospacing",
+ ["fr"]="sansespacement",
+ ["it"]="nospacing",
+ ["nl"]="geenspatiering",
+ ["pe"]="بدونفضاگذاری",
+ ["ro"]="nospacing",
},
- ["righthanging"]={
- ["cs"]="righthanging",
- ["de"]="righthanging",
- ["en"]="righthanging",
- ["fr"]="righthanging",
- ["it"]="righthanging",
- ["nl"]="rechtshangend",
- ["pe"]="آویزانکردنراست",
- ["ro"]="righthanging",
+ ["nostopper"]={
+ ["en"]="nostopper",
+ ["fr"]="sansstoppeur",
+ ["nl"]="geenafsluiter",
},
- ["rightmargin"]={
- ["cs"]="pravyokraj",
- ["de"]="rechterrand",
- ["en"]="rightmargin",
- ["fr"]="margedroite",
- ["it"]="marginedestro",
- ["nl"]="rechtermarge",
- ["pe"]="حاشیهراست",
- ["ro"]="marginedreapta",
+ ["not"]={
+ ["cs"]="ne",
+ ["de"]="nicht",
+ ["en"]="not",
+ ["fr"]="pas",
+ ["it"]="non",
+ ["nl"]="niet",
+ ["pe"]="بدون",
+ ["ro"]="nu",
},
- ["rightpage"]={
- ["cs"]="pravastranka",
- ["de"]="rechterseite",
- ["en"]="rightpage",
- ["fr"]="pagedroite",
- ["it"]="paginadestra",
- ["nl"]="rechterpagina",
- ["pe"]="صفحهراست",
- ["ro"]="paginadreapta",
+ ["notation"]={
+ ["en"]="notation",
+ ["fr"]="notation",
},
- ["righttoleft"]={
- ["cs"]="righttoleft",
- ["de"]="righttoleft",
- ["en"]="righttoleft",
- ["fr"]="righttoleft",
- ["it"]="righttoleft",
- ["nl"]="righttoleft",
- ["pe"]="righttoleft",
- ["ro"]="righttoleft",
+ ["note"]={
+ ["en"]="note",
+ ["fr"]="note",
},
- ["roman"]={
- ["cs"]="antikva",
- ["de"]="antiqua",
- ["en"]="roman",
- ["fr"]="roman",
- ["it"]="roman",
- ["nl"]="romaan",
- ["pe"]="رومن",
- ["ro"]="roman",
+ ["nothanging"]={
+ ["cs"]="nothanging",
+ ["de"]="nothanging",
+ ["en"]="nothanging",
+ ["fr"]="sanssuspension",
+ ["it"]="nonsospeso",
+ ["nl"]="niethangend",
+ ["pe"]="بدونآویزانکردن",
+ ["ro"]="nothanging",
},
- ["romannumerals"]={
- ["cs"]="rimskecislice",
- ["de"]="roemischezahlen",
- ["en"]="romannumerals",
- ["fr"]="chiffresromains",
- ["it"]="numeriromani",
- ["nl"]="romeins",
- ["pe"]="شمارهلاتین",
- ["ro"]="numereromane",
+ ["nothyphenated"]={
+ ["cs"]="nothyphenated",
+ ["de"]="nothyphenated",
+ ["en"]="nothyphenated",
+ ["fr"]="sanscesure",
+ ["it"]="nonsillabato",
+ ["nl"]="nietafgebroken",
+ ["pe"]="بدونشکست",
+ ["ro"]="nedespsilabe",
},
- ["rotate"]={
- ["cs"]="otoc",
- ["de"]="drehe",
- ["en"]="rotate",
- ["fr"]="oriente",
- ["it"]="ruota",
- ["nl"]="roteer",
- ["pe"]="دوران",
- ["ro"]="rotit",
+ ["notjoinedup"]={
+ ["en"]="notjoinedup",
+ ["fr"]="passansespaceentre",
+ ["nl"]="nietaansluitend",
},
- ["rotated"]={
- ["cs"]="otoceno",
- ["de"]="gedreht",
- ["en"]="rotated",
- ["fr"]="tourne",
- ["it"]="ruotato",
- ["nl"]="geroteerd",
- ["pe"]="دورانیافته",
- ["ro"]="rotat",
+ ["november"]={
+ ["cs"]="listopad",
+ ["de"]="november",
+ ["en"]="november",
+ ["fr"]="novembre",
+ ["it"]="novembre",
+ ["nl"]="november",
+ ["pe"]="نوامبر",
+ ["ro"]="noiembrie",
},
- ["round"]={
- ["cs"]="zaobleny",
- ["de"]="rund",
- ["en"]="round",
- ["fr"]="rond",
- ["it"]="rotondo",
- ["nl"]="rond",
- ["pe"]="گرد",
- ["ro"]="rotund",
+ ["nowhere"]={
+ ["cs"]="nikde",
+ ["de"]="nirgens",
+ ["en"]="nowhere",
+ ["fr"]="nullepart",
+ ["it"]="danessunaparte",
+ ["nl"]="nergens",
+ ["pe"]="هیچحا",
+ ["ro"]="niciunde",
+ },
+ ["nowhite"]={
+ ["cs"]="zadnabila",
+ ["de"]="keinweiss",
+ ["en"]="nowhite",
+ ["fr"]="sansblanc",
+ ["it"]="nobianco",
+ ["nl"]="geenwit",
+ ["pe"]="سفیدنه",
+ ["ro"]="faraalb",
},
- ["row"]={
- ["cs"]="row",
- ["de"]="row",
- ["en"]="row",
- ["fr"]="rang",
- ["it"]="row",
- ["nl"]="rij",
- ["pe"]="سطر",
- ["ro"]="rand",
+ ["number"]={
+ ["cs"]="cislo",
+ ["de"]="nummer",
+ ["en"]="number",
+ ["fr"]="numero",
+ ["it"]="numero",
+ ["nl"]="nummer",
+ ["pe"]="شماره",
+ ["ro"]="numar",
},
- ["rule"]={
- ["cs"]="linka",
- ["de"]="linie",
- ["en"]="rule",
- ["fr"]="regle",
- ["it"]="linea",
- ["nl"]="lijn",
- ["pe"]="خط",
- ["ro"]="rigla",
+ ["numbers"]={
+ ["cs"]="cisla",
+ ["de"]="ziffern",
+ ["en"]="numbers",
+ ["fr"]="numeros",
+ ["it"]="numeri",
+ ["nl"]="cijfers",
+ ["pe"]="شمارهها",
+ ["ro"]="numere",
},
- ["samepage"]={
- ["cs"]="stejnastranka",
- ["de"]="selbeseite",
- ["en"]="samepage",
- ["fr"]="memepage",
- ["it"]="stessapagina",
- ["nl"]="zelfdepagina",
- ["pe"]="همانصفحه",
- ["ro"]="aceeasipagina",
+ ["october"]={
+ ["cs"]="rijen",
+ ["de"]="oktober",
+ ["en"]="october",
+ ["fr"]="octobre",
+ ["it"]="ottobre",
+ ["nl"]="oktober",
+ ["pe"]="اکتبر",
+ ["ro"]="octombrie",
},
- ["sans"]={
- ["cs"]="sans",
- ["de"]="sans",
- ["en"]="sans",
- ["fr"]="sans",
- ["it"]="sans",
- ["nl"]="sans",
- ["pe"]="سانز",
- ["ro"]="sans",
+ ["odd"]={
+ ["cs"]="liche",
+ ["de"]="ungerade",
+ ["en"]="odd",
+ ["fr"]="impair",
+ ["it"]="dispari",
+ ["nl"]="oneven",
+ ["pe"]="فرد",
+ ["ro"]="impar",
},
- ["sansbold"]={
- ["cs"]="sanstucne",
- ["de"]="sansfett",
- ["en"]="sansbold",
- ["fr"]="sansgras",
- ["it"]="sansgrassetto",
- ["nl"]="sansvet",
- ["pe"]="مشکیسانز",
- ["ro"]="sansaldin",
+ ["off"]={
+ ["cs"]="vyp",
+ ["de"]="aus",
+ ["en"]="off",
+ ["fr"]="arret",
+ ["it"]="disattivo",
+ ["nl"]="uit",
+ ["pe"]="خاموش",
+ ["ro"]="dezactivat",
},
- ["sansnormal"]={
- ["en"]="sansnormal",
+ ["offset"]={
+ ["cs"]="offset",
+ ["de"]="offset",
+ ["en"]="offset",
+ ["fr"]="decalage",
+ ["it"]="offset",
+ ["nl"]="offset",
+ ["pe"]="آفست",
+ ["ro"]="offset",
},
- ["sansserif"]={
- ["cs"]="bezserifu",
- ["de"]="grotesk",
- ["en"]="sansserif",
- ["fr"]="sansserif",
- ["it"]="sansserif",
- ["nl"]="schreefloos",
- ["pe"]="سانزسریف",
- ["ro"]="sansserif",
+ ["old"]={
+ ["cs"]="old",
+ ["de"]="old",
+ ["en"]="old",
+ ["fr"]="ancien",
+ ["it"]="old",
+ ["nl"]="oud",
+ ["pe"]="قدیمی",
+ ["ro"]="old",
},
- ["saturday"]={
- ["cs"]="sobota",
- ["de"]="samstag",
- ["en"]="saturday",
- ["fr"]="samedi",
- ["it"]="sabato",
- ["nl"]="zaterdag",
- ["pe"]="شنبه",
- ["ro"]="sambata",
+ ["oldstyle"]={
+ ["en"]="oldstyle",
+ ["fr"]="styleancien",
},
- ["screen"]={
- ["cs"]="rastr",
- ["de"]="raster",
- ["en"]="screen",
- ["fr"]="ecran",
- ["it"]="schermo",
- ["nl"]="raster",
- ["pe"]="پرده",
- ["ro"]="ecran",
+ ["on"]={
+ ["cs"]="zap",
+ ["de"]="an",
+ ["en"]="on",
+ ["fr"]="marche",
+ ["it"]="attivo",
+ ["nl"]="aan",
+ ["pe"]="روی",
+ ["ro"]="on",
},
- ["section"]={
- ["cs"]="sekce",
- ["de"]="absatz",
- ["en"]="section",
- ["fr"]="section",
- ["it"]="capoverso",
- ["nl"]="paragraaf",
- ["pe"]="بخش",
- ["ro"]="sectiune",
+ ["one"]={
+ ["cs"]="jedna",
+ ["de"]="eins",
+ ["en"]="one",
+ ["fr"]="un",
+ ["it"]="uno",
+ ["nl"]="een",
+ ["pe"]="یک",
+ ["ro"]="unu",
},
- ["sectionblockenvironment"]={
- ["cs"]="sectionblockenvironment",
- ["de"]="sectionblockenvironment",
- ["en"]="sectionblockenvironment",
- ["fr"]="environementblocsection",
- ["it"]="ambientebloccosezione",
- ["nl"]="sectieblokomgeving",
- ["pe"]="محیطبلوکبخش",
- ["ro"]="blocsectiuneambient",
+ ["opposite"]={
+ ["cs"]="naproti",
+ ["de"]="gegenueber",
+ ["en"]="opposite",
+ ["fr"]="enface",
+ ["it"]="opposto",
+ ["nl"]="naast",
+ ["pe"]="مخالف",
+ ["ro"]="opus",
},
- ["sectionnumber"]={
- ["cs"]="cislooddilu",
- ["de"]="abschnittsnummer",
- ["en"]="sectionnumber",
- ["fr"]="numerosection",
- ["it"]="numerosezione",
- ["nl"]="sectienummer",
- ["pe"]="شمارهبخش",
- ["ro"]="numarsetiune",
+ ["ordinal"]={
+ ["en"]="ordinal",
+ ["fr"]="ordinal",
},
- ["see"]={
- ["cs"]="viz",
- ["de"]="sieh",
- ["en"]="see",
- ["fr"]="voit",
- ["it"]="vedi",
- ["nl"]="zie",
- ["pe"]="ببینید",
- ["ro"]="vezi",
+ ["outer"]={
+ ["cs"]="vnejsi",
+ ["de"]="aussen",
+ ["en"]="outer",
+ ["fr"]="exterieur",
+ ["it"]="esterno",
+ ["nl"]="buiten",
+ ["pe"]="خارجی",
+ ["ro"]="extern",
},
- ["selectfont"]={
- ["en"]="selectfont",
+ ["outeredge"]={
+ ["cs"]="outeredge",
+ ["de"]="outeredge",
+ ["en"]="outeredge",
+ ["fr"]="bordexterieur",
+ ["it"]="bordoesterno",
+ ["nl"]="buitenrand",
+ ["pe"]="لبهخارجی",
+ ["ro"]="outeredge",
},
- ["separator"]={
- ["en"]="separator",
- ["nl"]="scheider",
+ ["outermargin"]={
+ ["cs"]="outermargin",
+ ["de"]="outermargin",
+ ["en"]="outermargin",
+ ["fr"]="margeexterieure",
+ ["it"]="margineesterno",
+ ["nl"]="buitenmarge",
+ ["pe"]="حاشیهخارجی",
+ ["ro"]="outermargin",
},
- ["september"]={
- ["cs"]="zari",
- ["de"]="september",
- ["en"]="september",
- ["fr"]="septembre",
- ["it"]="settembre",
- ["nl"]="september",
- ["pe"]="سپتامبر",
- ["ro"]="septembrie",
+ ["overbar"]={
+ ["cs"]="nadtrzeno",
+ ["de"]="ueberstrichen",
+ ["en"]="overbar",
+ ["fr"]="surligner",
+ ["it"]="sopralinea",
+ ["nl"]="overstreep",
+ ["pe"]="میلهرو",
+ ["ro"]="barasus",
},
- ["serif"]={
- ["cs"]="serif",
- ["de"]="serif",
- ["en"]="serif",
- ["fr"]="serif",
- ["it"]="serif",
- ["nl"]="serif",
- ["pe"]="سریف",
- ["ro"]="serif",
+ ["overbars"]={
+ ["cs"]="nadtrzeni",
+ ["de"]="ueberstreichen",
+ ["en"]="overbars",
+ ["fr"]="surlignermots",
+ ["it"]="sopralinee",
+ ["nl"]="overstrepen",
+ ["pe"]="میلههارو",
+ ["ro"]="supralinie",
},
- ["serifbold"]={
- ["en"]="serifbold",
+ ["overlay"]={
+ ["cs"]="prekryv",
+ ["de"]="overlay",
+ ["en"]="overlay",
+ ["fr"]="superposition",
+ ["it"]="sovrapponi",
+ ["nl"]="overlay",
+ ["pe"]="پوشش",
+ ["ro"]="overlay",
},
- ["serifnormal"]={
- ["en"]="serifnormal",
+ ["overprint"]={
+ ["cs"]="overprint",
+ ["de"]="overprint",
+ ["en"]="overprint",
+ ["fr"]="surimpression",
+ ["it"]="overprint",
+ ["nl"]="overprint",
+ ["pe"]="overprint",
+ ["ro"]="overprint",
},
- ["serried"]={
- ["cs"]="semknuto",
- ["de"]="kleinerabstand",
- ["en"]="serried",
- ["fr"]="serried",
- ["it"]="vicino",
- ["nl"]="aanelkaar",
- ["pe"]="تنگهم",
- ["ro"]="serried",
+ ["overstrike"]={
+ ["cs"]="preskrtnuto",
+ ["de"]="durchgestrichen",
+ ["en"]="overstrike",
+ ["fr"]="barrer",
+ ["it"]="sbarrato",
+ ["nl"]="doorstreep",
+ ["pe"]="خطزدن",
+ ["ro"]="liniepeste",
},
- ["setups"]={
- ["comment"]="no translations",
- ["en"]="setups",
+ ["overstrikes"]={
+ ["cs"]="preskrtnuti",
+ ["de"]="durchstreichen",
+ ["en"]="overstrikes",
+ ["fr"]="barrermots",
+ ["it"]="sbarrati",
+ ["nl"]="doorstrepen",
+ ["pe"]="خطزدنها",
+ ["ro"]="liniipeste",
},
- ["sheet"]={
- ["cs"]="sheet",
- ["de"]="sheet",
- ["en"]="sheet",
- ["fr"]="sheet",
- ["it"]="sheet",
- ["nl"]="sheet",
- ["pe"]="ورقه",
- ["ro"]="sheet",
+ ["packed"]={
+ ["cs"]="zhustene",
+ ["de"]="gepackt",
+ ["en"]="packed",
+ ["fr"]="sansespaceentreitem",
+ ["it"]="impaccato",
+ ["nl"]="opelkaar",
+ ["pe"]="فشرده",
+ ["ro"]="impachetat",
},
- ["shiftdown"]={
- ["en"]="shiftdown",
+ ["page"]={
+ ["cs"]="stranka",
+ ["de"]="seite",
+ ["en"]="page",
+ ["fr"]="page",
+ ["it"]="pagina",
+ ["nl"]="pagina",
+ ["pe"]="صفحه",
+ ["ro"]="pagina",
},
- ["shiftup"]={
- ["en"]="shiftup",
+ ["pagecomment"]={
+ ["cs"]="komentarstranky",
+ ["de"]="pagecomment",
+ ["en"]="pagecomment",
+ ["fr"]="commentairepage",
+ ["it"]="commentopagina",
+ ["nl"]="paginacommentaar",
+ ["pe"]="توضیحصفحه",
+ ["ro"]="comentariupagina",
},
- ["short"]={
- ["cs"]="short",
- ["de"]="kurz",
- ["en"]="short",
- ["fr"]="short",
- ["it"]="short",
- ["nl"]="kort",
- ["ro"]="short",
+ ["pagenumber"]={
+ ["cs"]="cislostranky",
+ ["de"]="seitennummer",
+ ["en"]="pagenumber",
+ ["fr"]="numeropage",
+ ["it"]="numeropagina",
+ ["nl"]="paginanummer",
+ ["pe"]="شمارهصفحه",
+ ["ro"]="numarpagina",
},
- ["simplefonts"]={
- ["en"]="simplefonts",
+ ["paper"]={
+ ["cs"]="papir",
+ ["de"]="papier",
+ ["en"]="paper",
+ ["fr"]="papier",
+ ["it"]="carta",
+ ["nl"]="papier",
+ ["pe"]="برگ",
+ ["ro"]="foaie",
},
- ["simplelist"]={
- ["en"]="simplelist",
+ ["paragraph"]={
+ ["cs"]="odstavec",
+ ["de"]="absatz",
+ ["en"]="paragraph",
+ ["fr"]="paragraphe",
+ ["it"]="capoverso",
+ ["nl"]="alinea",
+ ["pe"]="پاراگراف",
+ ["ro"]="paragraf",
},
- ["singlesided"]={
- ["cs"]="jednostranne",
- ["de"]="einzelseitig",
- ["en"]="singlesided",
- ["fr"]="recto",
- ["it"]="facciasingola",
- ["nl"]="enkelzijdig",
- ["pe"]="یکرو",
- ["ro"]="ofata",
+ ["part"]={
+ ["cs"]="cast",
+ ["de"]="teil",
+ ["en"]="part",
+ ["fr"]="partie",
+ ["it"]="parte",
+ ["nl"]="deel",
+ ["pe"]="قسمت",
+ ["ro"]="parte",
},
- ["slanted"]={
- ["cs"]="sklonene",
- ["de"]="geneigt",
- ["en"]="slanted",
- ["fr"]="incline",
- ["it"]="inclinato",
- ["nl"]="schuin",
- ["pe"]="خوابیده",
- ["ro"]="inclinat",
+ ["positive"]={
+ ["cs"]="positiv",
+ ["de"]="positiv",
+ ["en"]="positive",
+ ["fr"]="positif",
+ ["it"]="positivo",
+ ["nl"]="positief",
+ ["pe"]="مثبت",
+ ["ro"]="positiv",
},
- ["slantedbold"]={
- ["cs"]="sklonenetucne",
- ["de"]="geneigtfett",
- ["en"]="slantedbold",
- ["fr"]="grasincline",
- ["it"]="inclinatograssetto",
- ["nl"]="schuinvet",
- ["pe"]="مشکیخوابیده",
- ["ro"]="inclinataldin",
+ ["postponing"]={
+ ["cs"]="odlozit",
+ ["de"]="verschieben",
+ ["en"]="postponing",
+ ["fr"]="report",
+ ["it"]="posporre",
+ ["nl"]="uitstellen",
+ ["pe"]="تاخیر",
+ ["ro"]="postponing",
},
- ["small"]={
- ["cs"]="male",
- ["de"]="klein",
- ["en"]="small",
- ["fr"]="petit",
- ["it"]="piccolo",
- ["nl"]="klein",
- ["pe"]="کوچک",
- ["ro"]="mic",
+ ["postscript"]={
+ ["cs"]="postscript",
+ ["de"]="postscript",
+ ["en"]="postscript",
+ ["fr"]="postscript",
+ ["it"]="postscript",
+ ["nl"]="postscript",
+ ["pe"]="پستاسکریپت",
+ ["ro"]="postscript",
},
- ["smallbodyfont"]={
- ["cs"]="smallbodyfont",
- ["de"]="smallbodyfont",
- ["en"]="smallbodyfont",
- ["fr"]="petitepolicecorps",
- ["it"]="piccolofontdelcorpo",
- ["nl"]="kleinkorps",
- ["pe"]="قلمبدنهکوچک",
- ["ro"]="smallbodyfont",
+ ["precedingpage"]={
+ ["en"]="precedingpage",
+ ["fr"]="pageantecedent",
+ ["nl"]="voorafgaandepagina",
},
- ["smallbold"]={
- ["cs"]="maletucne",
- ["de"]="kleinfett",
- ["en"]="smallbold",
- ["fr"]="graspetit",
- ["it"]="piccolograssetto",
- ["nl"]="kleinvet",
- ["pe"]="مشکیکوچک",
- ["ro"]="micaldin",
+ ["preference"]={
+ ["cs"]="nastaveni",
+ ["de"]="einstellung",
+ ["en"]="preference",
+ ["fr"]="preference",
+ ["it"]="preferenza",
+ ["nl"]="voorkeur",
+ ["pe"]="ترجیح",
+ ["ro"]="preferinta",
},
- ["smallbolditalic"]={
- ["cs"]="maletucnekurzivni",
- ["de"]="kleinfettitalic",
- ["en"]="smallbolditalic",
- ["fr"]="italiquegraspetit",
- ["it"]="piccolograssettocorsivo",
- ["nl"]="kleinvetitalic",
- ["pe"]="ایتالیکمشکیکوچک",
- ["ro"]="micaldininclinat",
+ ["preview"]={
+ ["cs"]="nahled",
+ ["de"]="vorschau",
+ ["en"]="preview",
+ ["fr"]="apercu",
+ ["it"]="anteprima",
+ ["nl"]="preview",
+ ["pe"]="پیشدید",
+ ["ro"]="previzualizare",
},
- ["smallboldslanted"]={
- ["cs"]="maletucnesklonene",
- ["de"]="kleinfettgeneigt",
- ["en"]="smallboldslanted",
- ["fr"]="inclinegraspetit",
- ["it"]="piccolograssettoinclinato",
- ["nl"]="kleinvetschuin",
- ["pe"]="خوابیدهمشکیکوچک",
- ["ro"]="micaldininclinat",
+ ["previous"]={
+ ["cs"]="predchozi",
+ ["de"]="vorig",
+ ["en"]="previous",
+ ["fr"]="precedent",
+ ["it"]="precedente",
+ ["nl"]="vorige",
+ ["pe"]="قبلی",
+ ["ro"]="precedent",
},
- ["smallcaps"]={
- ["cs"]="kapitalky",
- ["de"]="smallcaps",
- ["en"]="smallcaps",
- ["fr"]="petitescapitales",
- ["it"]="maiuscoletto",
- ["nl"]="smallcaps",
- ["pe"]="smallcaps",
- ["ro"]="majusculemici",
+ ["previousevenpage"]={
+ ["cs"]="predchozisudastranka",
+ ["de"]="vorigegeradeseite",
+ ["en"]="previousevenpage",
+ ["fr"]="pagepaireprecedente",
+ ["it"]="paginapariprecedente",
+ ["nl"]="vorigeevenpagina",
+ ["pe"]="صفحهزوجقبلی",
+ ["ro"]="paginaparaprecedenta",
},
- ["smaller"]={
- ["en"]="smaller",
- ["nl"]="kleiner",
+ ["previousoddpage"]={
+ ["cs"]="predchozilichastranka",
+ ["de"]="vorigeungeradeseite",
+ ["en"]="previousoddpage",
+ ["fr"]="pageimpaireprecedente",
+ ["it"]="paginadispariprecedente",
+ ["nl"]="vorigeonevenpagina",
+ ["pe"]="صفحهفردقبلی",
+ ["ro"]="paginaimparaprecedenta",
},
- ["smallitalic"]={
- ["cs"]="malekurzivni",
- ["de"]="kleinitalic",
- ["en"]="smallitalic",
- ["fr"]="italiquepetit",
- ["it"]="piccolocorsivo",
- ["nl"]="kleinitalic",
- ["pe"]="ایتالیککوچک",
- ["ro"]="micitalic",
+ ["previouspage"]={
+ ["cs"]="predchozistranka",
+ ["de"]="vorigeseite",
+ ["en"]="previouspage",
+ ["fr"]="pageprecedente",
+ ["it"]="paginaprecedente",
+ ["nl"]="vorigepagina",
+ ["pe"]="صفحهقبلی",
+ ["ro"]="paginaanterioara",
},
- ["smallitalicbold"]={
- ["cs"]="malekurzivnitucne",
- ["de"]="kleinitalicfett",
- ["en"]="smallitalicbold",
- ["fr"]="grasitaliquepetit",
- ["it"]="piccolocorsivograssetto",
- ["nl"]="kleinitalicvet",
- ["pe"]="مشکیایتالیککوچک",
- ["ro"]="micitalicaldin",
+ ["previoussubpage"]={
+ ["cs"]="predchozipodstranka",
+ ["de"]="vorigeunterseite",
+ ["en"]="previoussubpage",
+ ["fr"]="souspageprecedente",
+ ["it"]="sottopaginaprecedente",
+ ["nl"]="vorigesubpagina",
+ ["pe"]="زیرصفحهقبلی",
+ ["ro"]="subpaginaanterioara",
},
- ["smallnormal"]={
- ["cs"]="malenormalni",
- ["de"]="kleinnormal",
- ["en"]="smallnormal",
- ["fr"]="normalpetit",
- ["it"]="piccolonormale",
- ["nl"]="kleinnormaal",
- ["pe"]="نرمالکوچک",
- ["ro"]="micnormal",
+ ["print"]={
+ ["en"]="print",
+ ["fr"]="imprimer",
+ ["nl"]="print",
},
- ["smallslanted"]={
- ["cs"]="malesklonene",
- ["de"]="kleingeneigt",
- ["en"]="smallslanted",
- ["fr"]="inclinepetit",
- ["it"]="piccoloinclinato",
- ["nl"]="kleinschuin",
- ["pe"]="خوابیدهکوچک",
- ["ro"]="micinclinat",
+ ["printable"]={
+ ["cs"]="tisknutelne",
+ ["de"]="druckbar",
+ ["en"]="printable",
+ ["fr"]="imprimable",
+ ["it"]="stampabile",
+ ["nl"]="printbaar",
+ ["pe"]="قابلچاپ",
+ ["ro"]="tiparibil",
},
- ["smallslantedbold"]={
- ["cs"]="malesklonenetucne",
- ["de"]="kleingeneigtfett",
- ["en"]="smallslantedbold",
- ["fr"]="grasinclinepetit",
- ["it"]="piccoloinclinatograssetto",
- ["nl"]="kleinschuinvet",
- ["pe"]="مشکیخوابیدهکوچک",
- ["ro"]="micinclinataldin",
+ ["process"]={
+ ["cs"]="process",
+ ["de"]="process",
+ ["en"]="process",
+ ["fr"]="traiter",
+ ["it"]="process",
+ ["nl"]="proces",
+ ["pe"]="پردازش",
+ ["ro"]="process",
},
- ["smalltype"]={
- ["cs"]="maletype",
- ["de"]="kleintippen",
- ["en"]="smalltype",
- ["fr"]="petittype",
- ["it"]="piccolotype",
- ["nl"]="kleintype",
- ["pe"]="تایپکوچک",
- ["ro"]="mictype",
+ ["product"]={
+ ["cs"]="produkt",
+ ["de"]="produkt",
+ ["en"]="product",
+ ["fr"]="produit",
+ ["it"]="prodotto",
+ ["nl"]="produkt",
+ ["pe"]="محصول",
+ ["ro"]="produs",
},
- ["somewhere"]={
- ["cs"]="nekde",
- ["de"]="irgendwo",
- ["en"]="somewhere",
- ["fr"]="qqpart",
- ["it"]="daqualcheparte",
- ["nl"]="ergens",
- ["pe"]="جایی",
- ["ro"]="undeva",
+ ["program"]={
+ ["cs"]="program",
+ ["de"]="programm",
+ ["en"]="program",
+ ["fr"]="programme",
+ ["it"]="programma",
+ ["nl"]="programma",
+ ["pe"]="برنامه",
+ ["ro"]="program",
},
- ["sorted"]={
- ["cs"]="tridene",
- ["de"]="sortiert",
- ["en"]="sorted",
- ["fr"]="trie",
- ["it"]="ordinato",
- ["nl"]="gesorteerd",
- ["pe"]="مرتب",
- ["ro"]="sortat",
+ ["project"]={
+ ["cs"]="projekt",
+ ["de"]="projekt",
+ ["en"]="project",
+ ["fr"]="projet",
+ ["it"]="progetto",
+ ["nl"]="project",
+ ["pe"]="پروژه",
+ ["ro"]="proiect",
},
- ["sorting"]={
- ["en"]="sorting",
+ ["protected"]={
+ ["cs"]="chranene",
+ ["de"]="geschuetzt",
+ ["en"]="protected",
+ ["fr"]="protege",
+ ["it"]="protetto",
+ ["nl"]="beschermd",
+ ["pe"]="حفاظتشده",
+ ["ro"]="protejat",
},
- ["space"]={
- ["cs"]="mezera",
- ["de"]="spatium",
- ["en"]="space",
- ["fr"]="espace",
- ["it"]="spazio",
- ["nl"]="spatie",
- ["pe"]="فضا",
- ["ro"]="spatiu",
+ ["quadruple"]={
+ ["cs"]="ctyrnasobny",
+ ["de"]="viertel",
+ ["en"]="quadruple",
+ ["fr"]="quadruple",
+ ["it"]="quadruplo",
+ ["nl"]="viertal",
+ ["pe"]="quadruple",
+ ["ro"]="cvadrupul",
},
- ["spacing"]={
- ["cs"]="mezerovani",
- ["de"]="spatiumausgleich",
- ["en"]="spacing",
- ["fr"]="espacement",
- ["it"]="spaziatura",
- ["nl"]="spatiering",
- ["pe"]="فضاگذاری",
- ["ro"]="spatiere",
+ ["quarterline"]={
+ ["en"]="quarterline",
+ ["fr"]="quartdeligne",
+ ["nl"]="kwartregel",
},
- ["speech"]={
- ["cs"]="speech",
- ["de"]="speech",
- ["en"]="speech",
- ["fr"]="discours",
- ["it"]="speech",
- ["nl"]="spraak",
- ["pe"]="سخنرانی",
- ["ro"]="speech",
+ ["quotation"]={
+ ["cs"]="citace",
+ ["de"]="zitat",
+ ["en"]="quotation",
+ ["fr"]="citation",
+ ["it"]="citazione",
+ ["nl"]="citaat",
+ ["pe"]="نقلقول",
+ ["ro"]="citat",
},
- ["split"]={
- ["cs"]="split",
- ["de"]="split",
- ["en"]="split",
- ["fr"]="split",
- ["it"]="separa",
- ["nl"]="splitsen",
- ["pe"]="شکافتن",
- ["ro"]="split",
+ ["quote"]={
+ ["cs"]="citovat",
+ ["de"]="zitieren",
+ ["en"]="quote",
+ ["fr"]="citer",
+ ["it"]="menzione",
+ ["nl"]="citeer",
+ ["pe"]="نقل",
+ ["ro"]="minicitat",
},
- ["spot"]={
- ["cs"]="spot",
- ["de"]="spot",
- ["en"]="spot",
- ["fr"]="spot",
- ["it"]="spot",
- ["nl"]="spot",
- ["pe"]="لکه",
- ["ro"]="spot",
+ ["ran"]={
+ ["cs"]="rozsah",
+ ["de"]="ran",
+ ["en"]="ran",
+ ["fr"]="gam",
+ ["it"]="corse",
+ ["nl"]="ran",
+ ["pe"]="برد",
+ ["ro"]="rulat",
+ },
+ ["random"]={
+ ["cs"]="nahodny",
+ ["de"]="zufaellig",
+ ["en"]="random",
+ ["fr"]="aleatoire",
+ ["it"]="casuale",
+ ["nl"]="willekeurig",
+ ["pe"]="تصادفی",
+ ["ro"]="aleator",
},
- ["standard"]={
- ["cs"]="standardni",
- ["de"]="standard",
- ["en"]="standard",
- ["fr"]="standard",
- ["it"]="standard",
- ["nl"]="standaard",
- ["pe"]="استاندارد",
- ["ro"]="standard",
+ ["readonly"]={
+ ["cs"]="pouzeprocteni",
+ ["de"]="nurlesbar",
+ ["en"]="readonly",
+ ["fr"]="lectureseule",
+ ["it"]="solalettura",
+ ["nl"]="alleenleesbaar",
+ ["pe"]="تنهاخواندنی",
+ ["ro"]="readonly",
},
- ["start"]={
- ["cs"]="start",
- ["de"]="start",
- ["en"]="start",
- ["fr"]="demarre",
- ["it"]="inizia",
- ["nl"]="start",
- ["pe"]="شروع",
- ["ro"]="start",
+ ["rectangular"]={
+ ["cs"]="pravouhly",
+ ["de"]="rechteckig",
+ ["en"]="rectangular",
+ ["fr"]="rectangulaire",
+ ["it"]="rettangolare",
+ ["nl"]="recht",
+ ["pe"]="چهارگوشه",
+ ["ro"]="rectangular",
},
- ["starter"]={
- ["en"]="starter",
- ["nl"]="opener",
+ ["reference"]={
+ ["cs"]="odkaz",
+ ["de"]="referenz",
+ ["en"]="reference",
+ ["fr"]="reference",
+ ["it"]="riferimento",
+ ["nl"]="referentie",
+ ["pe"]="مرجع",
+ ["ro"]="referinta",
},
- ["sticker"]={
- ["cs"]="sticker",
- ["de"]="sticker",
- ["en"]="sticker",
- ["fr"]="sticker",
- ["it"]="sticker",
- ["nl"]="sticker",
- ["pe"]="دشنه",
- ["ro"]="sticker",
+ ["referral"]={
+ ["cs"]="znacka",
+ ["de"]="merkmal",
+ ["en"]="referral",
+ ["fr"]="redirection",
+ ["it"]="referral",
+ ["nl"]="kenmerk",
+ ["pe"]="مراجعه",
+ ["ro"]="referinta",
},
- ["stop"]={
- ["cs"]="stop",
- ["de"]="stop",
- ["en"]="stop",
- ["fr"]="stoppe",
- ["it"]="termina",
- ["nl"]="stop",
- ["pe"]="پایان",
- ["ro"]="stop",
+ ["region"]={
+ ["en"]="region",
+ ["fr"]="region",
+ ["nl"]="gebied",
},
- ["stopper"]={
- ["cs"]="predel",
- ["de"]="trenner",
- ["en"]="stopper",
- ["fr"]="stopper",
- ["it"]="stopper",
- ["nl"]="afsluiter",
- ["pe"]="ایست",
- ["ro"]="stopper",
+ ["register"]={
+ ["cs"]="rejstrik",
+ ["de"]="register",
+ ["en"]="register",
+ ["fr"]="registre",
+ ["it"]="registro",
+ ["nl"]="register",
+ ["pe"]="ثبت",
+ ["ro"]="registru",
},
- ["nostopper"]={
- ["en"]="nostopper",
- ["nl"]="geenafsluiter",
+ ["regular"]={
+ ["cs"]="pravidelne",
+ ["de"]="regular",
+ ["en"]="regular",
+ ["fr"]="ordinaire",
+ ["it"]="regolare",
+ ["nl"]="regular",
+ ["pe"]="منظم",
+ ["ro"]="regular",
},
- ["stretch"]={
- ["cs"]="natahnout",
- ["de"]="strecken",
- ["en"]="stretch",
- ["fr"]="etire",
- ["it"]="dilata",
- ["nl"]="rek",
- ["pe"]="بکش",
- ["ro"]="dilatat",
+ ["relative"]={
+ ["cs"]="relativni",
+ ["de"]="relativ",
+ ["en"]="relative",
+ ["fr"]="relatif",
+ ["it"]="relativo",
+ ["nl"]="relatief",
+ ["pe"]="نسبی",
+ ["ro"]="relativ",
},
- ["stretched"]={
- ["en"]="stretched",
+ ["repeat"]={
+ ["cs"]="opakovat",
+ ["de"]="wiederholen",
+ ["en"]="repeat",
+ ["fr"]="repeter",
+ ["it"]="ripeti",
+ ["nl"]="herhaal",
+ ["pe"]="تکرار",
+ ["ro"]="repetat",
},
- ["strict"]={
- ["cs"]="striktni",
- ["de"]="streng",
- ["en"]="strict",
- ["fr"]="strict",
- ["it"]="rigido",
- ["nl"]="streng",
- ["pe"]="اکید",
- ["ro"]="strict",
+ ["required"]={
+ ["cs"]="pozadovane",
+ ["de"]="obligatorisch",
+ ["en"]="required",
+ ["fr"]="requis",
+ ["it"]="richiestp",
+ ["nl"]="verplicht",
+ ["pe"]="موردنیاز",
+ ["ro"]="obligatoriu",
},
- ["strong"]={
- ["cs"]="strong",
- ["de"]="strong",
- ["en"]="strong",
- ["fr"]="strong",
- ["it"]="strong",
- ["nl"]="sterk",
- ["pe"]="محکم",
- ["ro"]="strong",
+ ["reset"]={
+ ["cs"]="reset",
+ ["de"]="zuruecksetzten",
+ ["en"]="reset",
+ ["fr"]="raz",
+ ["it"]="reimposta",
+ ["nl"]="reset",
+ ["pe"]="بازنشانی",
+ ["ro"]="reset",
},
- ["strut"]={
- ["cs"]="strut",
- ["de"]="strut",
- ["en"]="strut",
- ["fr"]="strut",
- ["it"]="strut",
- ["nl"]="strut",
- ["pe"]="بست",
- ["ro"]="strut",
+ ["reverse"]={
+ ["cs"]="reverse",
+ ["de"]="reverse",
+ ["en"]="reverse",
+ ["fr"]="inverser",
+ ["it"]="invertito",
+ ["nl"]="omgekeerd",
+ ["pe"]="برعکس",
+ ["ro"]="reverse",
},
- ["sub"]={
- ["cs"]="pod",
- ["de"]="unter",
- ["en"]="sub",
- ["fr"]="sous",
- ["it"]="sotto",
- ["nl"]="sub",
- ["pe"]="زیر",
- ["ro"]="sub",
+ ["right"]={
+ ["cs"]="vpravo",
+ ["de"]="rechts",
+ ["en"]="right",
+ ["fr"]="droite",
+ ["it"]="destra",
+ ["nl"]="rechts",
+ ["pe"]="راست",
+ ["ro"]="dreapta",
},
- ["subbackward"]={
- ["cs"]="podzpet",
- ["de"]="unterrueckwaerts",
- ["en"]="subbackward",
- ["fr"]="sousretourarriere",
- ["it"]="sottoindietro",
- ["nl"]="subachteruit",
- ["pe"]="زیرعقبگرد",
- ["ro"]="subinapoi",
+ ["rightedge"]={
+ ["cs"]="pravahrana",
+ ["de"]="rechterkante",
+ ["en"]="rightedge",
+ ["fr"]="borddroit",
+ ["it"]="bordodestro",
+ ["nl"]="rechterrand",
+ ["pe"]="لبهراست",
+ ["ro"]="borduradreapta",
},
- ["subformula"]={
- ["cs"]="subrovnice",
- ["de"]="subformel",
- ["en"]="subformula",
- ["fr"]="subformule",
- ["it"]="subformula",
- ["nl"]="subformule",
- ["pe"]="زیرفرمول",
- ["ro"]="subformula",
+ ["righthanging"]={
+ ["cs"]="righthanging",
+ ["de"]="righthanging",
+ ["en"]="righthanging",
+ ["fr"]="suspensiondroite",
+ ["it"]="righthanging",
+ ["nl"]="rechtshangend",
+ ["pe"]="آویزانکردنراست",
+ ["ro"]="righthanging",
},
- ["subforward"]={
- ["cs"]="podvpred",
- ["de"]="untervorwaerts",
- ["en"]="subforward",
- ["fr"]="sousavance",
- ["it"]="sottoavanti",
- ["nl"]="subvooruit",
- ["pe"]="زیرجلوگرد",
- ["ro"]="subavans",
+ ["rightmargin"]={
+ ["cs"]="pravyokraj",
+ ["de"]="rechterrand",
+ ["en"]="rightmargin",
+ ["fr"]="margedroite",
+ ["it"]="marginedestro",
+ ["nl"]="rechtermarge",
+ ["pe"]="حاشیهراست",
+ ["ro"]="marginedreapta",
},
- ["subject"]={
- ["cs"]="tema",
- ["de"]="thema",
- ["en"]="subject",
- ["fr"]="sujet",
- ["it"]="argomento",
- ["nl"]="onderwerp",
- ["pe"]="موضوع",
- ["ro"]="subiect",
+ ["rightpage"]={
+ ["cs"]="pravastranka",
+ ["de"]="rechterseite",
+ ["en"]="rightpage",
+ ["fr"]="surpagedroite",
+ ["it"]="paginadestra",
+ ["nl"]="rechterpagina",
+ ["pe"]="صفحهراست",
+ ["ro"]="paginadreapta",
},
- ["subpage"]={
- ["cs"]="podstranka",
- ["de"]="unterseite",
- ["en"]="subpage",
- ["fr"]="souspage",
- ["it"]="sottopagina",
- ["nl"]="subpagina",
- ["pe"]="زیرصفحه",
- ["ro"]="subpagina",
+ ["righttoleft"]={
+ ["cs"]="righttoleft",
+ ["de"]="righttoleft",
+ ["en"]="righttoleft",
+ ["fr"]="droiteagauche",
+ ["it"]="righttoleft",
+ ["nl"]="righttoleft",
+ ["pe"]="righttoleft",
+ ["ro"]="righttoleft",
},
- ["subs"]={
- ["en"]="subs",
+ ["roman"]={
+ ["cs"]="antikva",
+ ["de"]="antiqua",
+ ["en"]="roman",
+ ["fr"]="romain",
+ ["it"]="roman",
+ ["nl"]="romaan",
+ ["pe"]="رومن",
+ ["ro"]="roman",
},
- ["subsection"]={
- ["cs"]="podsekce",
- ["de"]="unterabsatz",
- ["en"]="subsection",
- ["fr"]="soussection",
- ["it"]="sottocapoverso",
- ["nl"]="subparagraaf",
- ["pe"]="زیربخش",
- ["ro"]="subsectiune",
+ ["romannumerals"]={
+ ["cs"]="rimskecislice",
+ ["de"]="roemischezahlen",
+ ["en"]="romannumerals",
+ ["fr"]="chiffresromains",
+ ["it"]="numeriromani",
+ ["nl"]="romeins",
+ ["pe"]="شمارهلاتین",
+ ["ro"]="numereromane",
},
- ["subsubject"]={
- ["cs"]="podtema",
- ["de"]="unterthema",
- ["en"]="subsubject",
- ["fr"]="soussujet",
- ["it"]="sottoargomento",
- ["nl"]="subonderwerp",
- ["pe"]="زیرموضوع",
- ["ro"]="subsubiect",
+ ["rotate"]={
+ ["cs"]="otoc",
+ ["de"]="drehe",
+ ["en"]="rotate",
+ ["fr"]="tourner",
+ ["it"]="ruota",
+ ["nl"]="roteer",
+ ["pe"]="دوران",
+ ["ro"]="rotit",
},
- ["subsubsection"]={
- ["cs"]="podpodsekce",
- ["de"]="unterunterabsatz",
- ["en"]="subsubsection",
- ["fr"]="soussoussection",
- ["it"]="sottosottocapoverso",
- ["nl"]="subsubparagraaf",
- ["pe"]="زیرزیربخش",
- ["ro"]="subsubsectiune",
+ ["rotated"]={
+ ["cs"]="otoceno",
+ ["de"]="gedreht",
+ ["en"]="rotated",
+ ["fr"]="tourne",
+ ["it"]="ruotato",
+ ["nl"]="geroteerd",
+ ["pe"]="دورانیافته",
+ ["ro"]="rotat",
},
- ["subsubsubject"]={
- ["cs"]="podpodtema",
- ["de"]="unterunterthema",
- ["en"]="subsubsubject",
- ["fr"]="soussoussujet",
- ["it"]="sottosottoargomento",
- ["nl"]="subsubonderwerp",
- ["pe"]="زیرزیرموضوع",
- ["ro"]="subsubsubiect",
+ ["round"]={
+ ["cs"]="zaobleny",
+ ["de"]="rund",
+ ["en"]="round",
+ ["fr"]="rond",
+ ["it"]="rotondo",
+ ["nl"]="rond",
+ ["pe"]="گرد",
+ ["ro"]="rotund",
},
- ["subsubsubsection"]={
- ["cs"]="podpodpodsekce",
- ["de"]="unterunterunterabsatz",
- ["en"]="subsubsubsection",
- ["fr"]="soussoussoussection",
- ["it"]="sottosottosottocapoverso",
- ["nl"]="subsubsubparagraaf",
- ["pe"]="زیرزیرزیربخش",
- ["ro"]="subsubsubsectiune",
+ ["row"]={
+ ["cs"]="row",
+ ["de"]="row",
+ ["en"]="row",
+ ["fr"]="rang",
+ ["it"]="row",
+ ["nl"]="rij",
+ ["pe"]="سطر",
+ ["ro"]="rand",
},
- ["subsubsubsubject"]={
- ["cs"]="podpodpodtema",
- ["de"]="unterunterunterthema",
- ["en"]="subsubsubsubject",
- ["fr"]="soussoussoussujet",
- ["it"]="sottosottosottoargomento",
- ["nl"]="subsubsubonderwerp",
- ["pe"]="زیرزیرزیرموضوع",
- ["ro"]="subsubsubsubiect",
+ ["rule"]={
+ ["cs"]="linka",
+ ["de"]="linie",
+ ["en"]="rule",
+ ["fr"]="trait",
+ ["it"]="linea",
+ ["nl"]="lijn",
+ ["pe"]="خط",
+ ["ro"]="rigla",
},
- ["subsubsubsubsection"]={
- ["cs"]="podpodpodpodsekce",
- ["de"]="unterunterunterunterabsatz",
- ["en"]="subsubsubsubsection",
- ["fr"]="soussoussoussoussection",
- ["it"]="sottosottosottosottocapoverso",
- ["nl"]="subsubsubsubparagraaf",
- ["pe"]="زیرزیرزیرزیربخش",
- ["ro"]="subsubsubsubsectiune",
+ ["samepage"]={
+ ["cs"]="stejnastranka",
+ ["de"]="selbeseite",
+ ["en"]="samepage",
+ ["fr"]="memepage",
+ ["it"]="stessapagina",
+ ["nl"]="zelfdepagina",
+ ["pe"]="همانصفحه",
+ ["ro"]="aceeasipagina",
},
- ["subsubsubsubsubject"]={
- ["cs"]="podpodpodpodtema",
- ["de"]="unterunterunterunterthema",
- ["en"]="subsubsubsubsubject",
- ["fr"]="soussoussoussoussujet",
- ["it"]="sottosottosottosottoargomento",
- ["nl"]="subsubsubsubonderwerp",
- ["pe"]="زیرزیرزیرزیرموضوع",
- ["ro"]="subsubsubsubsubiect",
+ ["sans"]={
+ ["cs"]="sans",
+ ["de"]="sans",
+ ["en"]="sans",
+ ["fr"]="sans",
+ ["it"]="sans",
+ ["nl"]="sans",
+ ["pe"]="سانز",
+ ["ro"]="sans",
},
- ["subsubsubsubsubsection"]={
- ["cs"]="podpodpodpodpodsekce",
- ["de"]="unterunterunterunterunterabsatz",
- ["en"]="subsubsubsubsubsection",
- ["fr"]="soussoussoussoussoussection",
- ["it"]="sottosottosottosottosottocapoverso",
- ["nl"]="subsubsubsubsubparagraaf",
- ["pe"]="زیرزیرزیرزیرزیربخش",
- ["ro"]="subsubsubsubsubsectiune",
+ ["sansbold"]={
+ ["cs"]="sanstucne",
+ ["de"]="sansfett",
+ ["en"]="sansbold",
+ ["fr"]="sansserifbold",
+ ["it"]="sansgrassetto",
+ ["nl"]="sansvet",
+ ["pe"]="مشکیسانز",
+ ["ro"]="sansaldin",
},
- ["subsubsubsubsubsubject"]={
- ["cs"]="podpodpodpodpodtema",
- ["de"]="unterunterunterunterunterthema",
- ["en"]="subsubsubsubsubsubject",
- ["fr"]="soussoussoussoussoussujet",
- ["it"]="sottosottosottosottosottoargomento",
- ["nl"]="subsubsubsubsubonderwerp",
- ["pe"]="زیرزیرزیرزیرزیرموضوع",
- ["ro"]="subsubsubsubsubsubiect",
+ ["sansnormal"]={
+ ["en"]="sansnormal",
+ ["fr"]="normalsans",
},
- ["subsubsubsubsubsubsection"]={
- ["cs"]="podpodpodpodpodpodsekce",
- ["de"]="unterunterunterunterunterunterabsatz",
- ["en"]="subsubsubsubsubsubsection",
- ["fr"]="soussoussoussoussoussoussection",
- ["it"]="sottosottosottosottosottosottocapoverso",
- ["nl"]="subsubsubsubsubsubparagraaf",
- ["pe"]="زیرزیرزیرزیرزیرزیربخش",
- ["ro"]="subsubsubsubsubsubsectiune",
+ ["sansserif"]={
+ ["cs"]="bezserifu",
+ ["de"]="grotesk",
+ ["en"]="sansserif",
+ ["fr"]="sansserif",
+ ["it"]="sansserif",
+ ["nl"]="schreefloos",
+ ["pe"]="سانزسریف",
+ ["ro"]="sansserif",
},
- ["subsubsubsubsubsubsubject"]={
- ["cs"]="podpodpodpodpodpodtema",
- ["de"]="unterunterunterunterunterunterthema",
- ["en"]="subsubsubsubsubsubsubject",
- ["fr"]="soussoussoussoussoussoussujet",
- ["it"]="sottosottosottosottosottosottoargomento",
- ["nl"]="subsubsubsubsubsubonderwerp",
- ["pe"]="زیرزیرزیرزیرزیرزیرموضوع",
- ["ro"]="subsubsubsubsubsubsubiect",
+ ["saturday"]={
+ ["cs"]="sobota",
+ ["de"]="samstag",
+ ["en"]="saturday",
+ ["fr"]="samedi",
+ ["it"]="sabato",
+ ["nl"]="zaterdag",
+ ["pe"]="شنبه",
+ ["ro"]="sambata",
+ },
+ ["screen"]={
+ ["cs"]="rastr",
+ ["de"]="raster",
+ ["en"]="screen",
+ ["fr"]="ecran",
+ ["it"]="schermo",
+ ["nl"]="raster",
+ ["pe"]="پرده",
+ ["ro"]="ecran",
},
- ["subsubsubsubsubsubsubsection"]={
- ["cs"]="podpodpodpodpodpodpodsekce",
- ["de"]="unterunterunterunterunterunterunterabsatz",
- ["en"]="subsubsubsubsubsubsubsection",
- ["fr"]="soussoussoussoussoussoussoussection",
- ["it"]="sottosottosottosottosottosottosottocapoverso",
- ["nl"]="subsubsubsubsubsubsubparagraaf",
- ["pe"]="زیرزیرزیرزیرزیرزیرزیربخش",
- ["ro"]="subsubsubsubsubsubsubsectiune",
+ ["section"]={
+ ["cs"]="sekce",
+ ["de"]="absatz",
+ ["en"]="section",
+ ["fr"]="section",
+ ["it"]="capoverso",
+ ["nl"]="paragraaf",
+ ["pe"]="بخش",
+ ["ro"]="sectiune",
},
- ["subsubsubsubsubsubsubsubject"]={
- ["cs"]="podpodpodpodpodpodpodtema",
- ["de"]="unterunterunterunterunterunterunterthema",
- ["en"]="subsubsubsubsubsubsubsubject",
- ["fr"]="soussoussoussoussoussoussoussujet",
- ["it"]="sottosottosottosottosottosottosottoargomento",
- ["nl"]="subsubsubsubsubsubsubonderwerp",
- ["pe"]="زیرزیرزیرزیرزیرزیرزیرموضوع",
- ["ro"]="subsubsubsubsubsubsubsubiect",
+ ["sectionblockenvironment"]={
+ ["cs"]="sectionblockenvironment",
+ ["de"]="sectionblockenvironment",
+ ["en"]="sectionblockenvironment",
+ ["fr"]="environnementblocsection",
+ ["it"]="ambientebloccosezione",
+ ["nl"]="sectieblokomgeving",
+ ["pe"]="محیطبلوکبخش",
+ ["ro"]="blocsectiuneambient",
},
- ["subsubsubsubsubsubsubsubsection"]={
- ["cs"]="podpodpodpodpodpodpodpodsekce",
- ["de"]="unterunterunterunterunterunterunterunterabsatz",
- ["en"]="subsubsubsubsubsubsubsubsection",
- ["fr"]="soussoussoussoussoussoussoussoussection",
- ["it"]="sottosottosottosottosottosottosottosottocapoverso",
- ["nl"]="subsubsubsubsubsubsubsubparagraaf",
- ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیربخش",
- ["ro"]="subsubsubsubsubsubsubsubsectiune",
+ ["sectionnumber"]={
+ ["cs"]="cislooddilu",
+ ["de"]="abschnittsnummer",
+ ["en"]="sectionnumber",
+ ["fr"]="numerosection",
+ ["it"]="numerosezione",
+ ["nl"]="sectienummer",
+ ["pe"]="شمارهبخش",
+ ["ro"]="numarsetiune",
},
- ["subsubsubsubsubsubsubsubsubject"]={
- ["cs"]="podpodpodpodpodpodpodpodtema",
- ["de"]="unterunterunterunterunterunterunterunterthema",
- ["en"]="subsubsubsubsubsubsubsubsubject",
- ["fr"]="soussoussoussoussoussoussoussoussujet",
- ["it"]="sottosottosottosottosottosottosottosottoargomento",
- ["nl"]="subsubsubsubsubsubsubsubonderwerp",
- ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیرموضوع",
- ["ro"]="subsubsubsubsubsubsubsubsubiect",
+ ["see"]={
+ ["cs"]="viz",
+ ["de"]="sieh",
+ ["en"]="see",
+ ["fr"]="voir",
+ ["it"]="vedi",
+ ["nl"]="zie",
+ ["pe"]="ببینید",
+ ["ro"]="vezi",
},
- ["subsubsubsubsubsubsubsubsubsection"]={
- ["cs"]="podpodpodpodpodpodpodpodpodsekce",
- ["de"]="unterunterunterunterunterunterunterunterunterabsatz",
- ["en"]="subsubsubsubsubsubsubsubsubsection",
- ["fr"]="soussoussoussoussoussoussoussoussoussection",
- ["it"]="sottosottosottosottosottosottosottosottosottocapoverso",
- ["nl"]="subsubsubsubsubsubsubsubsubparagraaf",
- ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیرزیربخش",
- ["ro"]="subsubsubsubsubsubsubsubsubsectiune",
+ ["selectfont"]={
+ ["en"]="selectfont",
+ ["fr"]="selectionnerpolice",
},
- ["subsubsubsubsubsubsubsubsubsubject"]={
- ["cs"]="podpodpodpodpodpodpodpodpodtema",
- ["de"]="unterunterunterunterunterunterunterunterunterthema",
- ["en"]="subsubsubsubsubsubsubsubsubsubject",
- ["fr"]="soussoussoussoussoussoussoussoussoussujet",
- ["it"]="sottosottosottosottosottosottosottosottosottoargomento",
- ["nl"]="subsubsubsubsubsubsubsubsubonderwerp",
- ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیرزیرموضوع",
- ["ro"]="subsubsubsubsubsubsubsubsubsubiect",
+ ["separator"]={
+ ["en"]="separator",
+ ["fr"]="separateur",
+ ["nl"]="scheider",
},
- ["sunday"]={
- ["cs"]="nedele",
- ["de"]="sonntag",
- ["en"]="sunday",
- ["fr"]="dimanche",
- ["it"]="domenica",
- ["nl"]="zondag",
- ["pe"]="یکشنبه",
- ["ro"]="duminica",
+ ["september"]={
+ ["cs"]="zari",
+ ["de"]="september",
+ ["en"]="september",
+ ["fr"]="septembre",
+ ["it"]="settembre",
+ ["nl"]="september",
+ ["pe"]="سپتامبر",
+ ["ro"]="septembrie",
},
- ["support"]={
- ["cs"]="podpora",
- ["de"]="support",
- ["en"]="support",
- ["fr"]="support",
- ["it"]="supporto",
- ["nl"]="support",
- ["pe"]="حمایت",
- ["ro"]="suport",
+ ["serif"]={
+ ["cs"]="serif",
+ ["de"]="serif",
+ ["en"]="serif",
+ ["fr"]="serif",
+ ["it"]="serif",
+ ["nl"]="serif",
+ ["pe"]="سریف",
+ ["ro"]="serif",
},
- ["sym"]={
- ["cs"]="sym",
- ["de"]="sym",
- ["en"]="sym",
- ["fr"]="sym",
- ["it"]="sim",
- ["nl"]="sym",
- ["pe"]="نم",
- ["ro"]="sym",
+ ["serifbold"]={
+ ["en"]="serifbold",
+ ["fr"]="serifgras",
},
- ["symbol"]={
- ["cs"]="symbol",
- ["de"]="symbol",
- ["en"]="symbol",
- ["fr"]="symbole",
- ["it"]="simbolo",
- ["nl"]="symbool",
- ["pe"]="نماد",
- ["ro"]="simbol",
+ ["serifnormal"]={
+ ["en"]="serifnormal",
+ ["fr"]="serifnormal",
},
- ["synchronize"]={
- ["cs"]="synchronize",
- ["de"]="synchronize",
- ["en"]="synchronize",
- ["fr"]="synchronize",
- ["it"]="synchronize",
- ["nl"]="synchroniseer",
- ["pe"]="تطابق",
- ["ro"]="synchronize",
+ ["serried"]={
+ ["cs"]="semknuto",
+ ["de"]="kleinerabstand",
+ ["en"]="serried",
+ ["fr"]="serre",
+ ["it"]="vicino",
+ ["nl"]="aanelkaar",
+ ["pe"]="تنگهم",
+ ["ro"]="serried",
},
- ["synonym"]={
- ["en"]="synonym",
+ ["setups"]={
+ ["en"]="setups",
},
- ["system"]={
- ["cs"]="system",
- ["de"]="systeme",
- ["en"]="system",
- ["fr"]="systeme",
- ["it"]="sistema",
- ["nl"]="systeem",
- ["pe"]="سیستم",
- ["ro"]="sistem",
+ ["seven"]={
+ ["cs"]="seven",
+ ["de"]="sieben",
+ ["en"]="seven",
+ ["fr"]="sept",
+ ["it"]="seven",
+ ["nl"]="zeven",
+ ["pe"]="seven",
+ ["ro"]="seven",
},
- ["table"]={
- ["cs"]="tabulka",
- ["de"]="tabelle",
- ["en"]="table",
- ["fr"]="tableau",
- ["it"]="tabella",
- ["nl"]="tabel",
- ["pe"]="جدول",
- ["ro"]="tabelul",
+ ["sheet"]={
+ ["cs"]="sheet",
+ ["de"]="sheet",
+ ["en"]="sheet",
+ ["fr"]="feuille",
+ ["it"]="sheet",
+ ["nl"]="sheet",
+ ["pe"]="ورقه",
+ ["ro"]="sheet",
},
- ["tablehead"]={
- ["cs"]="zahlavitabulky",
- ["de"]="tabellenueberschrift",
- ["en"]="tablehead",
- ["fr"]="tetetableau",
- ["it"]="testatabella",
- ["nl"]="tabelkop",
- ["pe"]="سرجدول",
- ["ro"]="antettabel",
+ ["shiftdown"]={
+ ["en"]="shiftdown",
+ ["fr"]="decalerenbas",
},
- ["tables"]={
- ["cs"]="tabulky",
- ["de"]="tabellen",
- ["en"]="tables",
- ["fr"]="tables",
- ["it"]="tabelle",
- ["nl"]="tabellen",
- ["pe"]="جدولها",
- ["ro"]="tabelele",
+ ["shiftup"]={
+ ["en"]="shiftup",
+ ["fr"]="decalerenhaut",
},
- ["tabletail"]={
- ["cs"]="konectabulky",
- ["de"]="tabellenende",
- ["en"]="tabletail",
- ["fr"]="queuetableau",
- ["it"]="codatabella",
- ["nl"]="tabelstaart",
- ["pe"]="دنبالهجدول",
- ["ro"]="subsoltabel",
+ ["short"]={
+ ["cs"]="short",
+ ["de"]="kurz",
+ ["en"]="short",
+ ["fr"]="court",
+ ["it"]="short",
+ ["nl"]="kort",
+ ["ro"]="short",
},
- ["tabulate"]={
- ["cs"]="tabelator",
- ["de"]="tabulator",
- ["en"]="tabulate",
- ["fr"]="tabule",
- ["it"]="tabulato",
- ["nl"]="tabulatie",
- ["pe"]="جدولبندی",
- ["ro"]="tabulate",
+ ["simplefonts"]={
+ ["en"]="simplefonts",
+ ["fr"]="policessimple",
},
- ["tabulatehead"]={
- ["cs"]="tabulatehead",
- ["de"]="tabulatehead",
- ["en"]="tabulatehead",
- ["fr"]="tetetabule",
- ["it"]="testatabulato",
- ["nl"]="tabulatiekop",
- ["pe"]="سرجدولبندی",
- ["ro"]="tabulatehead",
+ ["simplelist"]={
+ ["en"]="simplelist",
+ ["fr"]="listesimple",
},
- ["tabulatetail"]={
- ["cs"]="tabulatetail",
- ["de"]="tabulatetail",
- ["en"]="tabulatetail",
- ["fr"]="queuetabule",
- ["it"]="codatabulato",
- ["nl"]="tabulatiestaart",
- ["pe"]="دنبالهجدولبندی",
- ["ro"]="tabulatetail",
+ ["singlesided"]={
+ ["cs"]="jednostranne",
+ ["de"]="einzelseitig",
+ ["en"]="singlesided",
+ ["fr"]="recto",
+ ["it"]="facciasingola",
+ ["nl"]="enkelzijdig",
+ ["pe"]="یکرو",
+ ["ro"]="ofata",
},
- ["tall"]={
- ["cs"]="vysoko",
- ["de"]="lang",
- ["en"]="tall",
- ["fr"]="long",
- ["it"]="alto",
- ["nl"]="lang",
- ["pe"]="دراز",
- ["ro"]="inalt",
+ ["six"]={
+ ["cs"]="six",
+ ["de"]="sechs",
+ ["en"]="six",
+ ["fr"]="six",
+ ["it"]="six",
+ ["nl"]="zes",
+ ["pe"]="six",
+ ["ro"]="six",
},
- ["teletype"]={
- ["cs"]="strojopis",
- ["de"]="fernschreiber",
- ["en"]="teletype",
- ["fr"]="teletype",
- ["it"]="teletype",
- ["nl"]="teletype",
- ["pe"]="دورنگاره",
- ["ro"]="teletype",
+ ["slanted"]={
+ ["cs"]="sklonene",
+ ["de"]="geneigt",
+ ["en"]="slanted",
+ ["fr"]="incline",
+ ["it"]="inclinato",
+ ["nl"]="schuin",
+ ["pe"]="خوابیده",
+ ["ro"]="inclinat",
},
- ["temporary"]={
- ["cs"]="docasne",
- ["de"]="temporaer",
- ["en"]="temporary",
- ["fr"]="temporaire",
- ["it"]="temporaneo",
- ["nl"]="voorlopig",
- ["pe"]="موقتی",
- ["ro"]="temporar",
+ ["slantedbold"]={
+ ["cs"]="sklonenetucne",
+ ["de"]="geneigtfett",
+ ["en"]="slantedbold",
+ ["fr"]="inclinegras",
+ ["it"]="inclinatograssetto",
+ ["nl"]="schuinvet",
+ ["pe"]="مشکیخوابیده",
+ ["ro"]="inclinataldin",
},
- ["test"]={
- ["cs"]="test",
- ["de"]="test",
- ["en"]="test",
- ["fr"]="test",
- ["it"]="test",
- ["nl"]="test",
- ["pe"]="تست",
- ["ro"]="test",
+ ["small"]={
+ ["cs"]="male",
+ ["de"]="klein",
+ ["en"]="small",
+ ["fr"]="petit",
+ ["it"]="piccolo",
+ ["nl"]="klein",
+ ["pe"]="کوچک",
+ ["ro"]="mic",
},
- ["text"]={
- ["cs"]="text",
- ["de"]="text",
- ["en"]="text",
- ["fr"]="texte",
- ["it"]="testo",
- ["nl"]="tekst",
- ["pe"]="متن",
- ["ro"]="text",
+ ["smallbodyfont"]={
+ ["cs"]="smallbodyfont",
+ ["de"]="smallbodyfont",
+ ["en"]="smallbodyfont",
+ ["fr"]="policedecorpspetite",
+ ["it"]="piccolofontdelcorpo",
+ ["nl"]="kleinkorps",
+ ["pe"]="قلمبدنهکوچک",
+ ["ro"]="smallbodyfont",
},
- ["three"]={
- ["cs"]="tri",
- ["de"]="drei",
- ["en"]="three",
- ["fr"]="trois",
- ["it"]="tre",
- ["nl"]="drie",
- ["pe"]="سه",
- ["ro"]="trei",
+ ["smallbold"]={
+ ["cs"]="maletucne",
+ ["de"]="kleinfett",
+ ["en"]="smallbold",
+ ["fr"]="petitgras",
+ ["it"]="piccolograssetto",
+ ["nl"]="kleinvet",
+ ["pe"]="مشکیکوچک",
+ ["ro"]="micaldin",
},
- ["thursday"]={
- ["cs"]="ctvrtek",
- ["de"]="donnerstag",
- ["en"]="thursday",
- ["fr"]="jeudi",
- ["it"]="giovedi",
- ["nl"]="donderdag",
- ["pe"]="پنجشنبه",
- ["ro"]="joi",
+ ["smallbolditalic"]={
+ ["cs"]="maletucnekurzivni",
+ ["de"]="kleinfettitalic",
+ ["en"]="smallbolditalic",
+ ["fr"]="petitgrasitalique",
+ ["it"]="piccolograssettocorsivo",
+ ["nl"]="kleinvetitalic",
+ ["pe"]="ایتالیکمشکیکوچک",
+ ["ro"]="micaldininclinat",
},
- ["tight"]={
- ["en"]="tight",
- ["nl"]="krap",
+ ["smallboldslanted"]={
+ ["cs"]="maletucnesklonene",
+ ["de"]="kleinfettgeneigt",
+ ["en"]="smallboldslanted",
+ ["fr"]="petitgrasincline",
+ ["it"]="piccolograssettoinclinato",
+ ["nl"]="kleinvetschuin",
+ ["pe"]="خوابیدهمشکیکوچک",
+ ["ro"]="micaldininclinat",
},
- ["title"]={
- ["cs"]="titul",
- ["de"]="titel",
- ["en"]="title",
- ["fr"]="titre",
- ["it"]="titolo",
- ["nl"]="titel",
- ["pe"]="عنوان",
- ["ro"]="titlu",
+ ["smallcaps"]={
+ ["cs"]="kapitalky",
+ ["de"]="smallcaps",
+ ["en"]="smallcaps",
+ ["fr"]="petitescaps",
+ ["it"]="maiuscoletto",
+ ["nl"]="smallcaps",
+ ["pe"]="smallcaps",
+ ["ro"]="majusculemici",
},
- ["toggle"]={
- ["cs"]="toggle",
- ["de"]="toggle",
- ["en"]="wissel",
- ["fr"]="toggle",
- ["it"]="toggle",
- ["nl"]="toggle",
- ["pe"]="تغییر",
- ["ro"]="toggle",
+ ["smaller"]={
+ ["en"]="smaller",
+ ["fr"]="pluspetit",
+ ["nl"]="kleiner",
},
- ["tolerant"]={
- ["cs"]="tolerantni",
- ["de"]="tolerant",
- ["en"]="tolerant",
- ["fr"]="tolerant",
- ["it"]="tollerante",
- ["nl"]="soepel",
- ["pe"]="بردبار",
- ["ro"]="tolerant",
+ ["smallitalic"]={
+ ["cs"]="malekurzivni",
+ ["de"]="kleinitalic",
+ ["en"]="smallitalic",
+ ["fr"]="petititalique",
+ ["it"]="piccolocorsivo",
+ ["nl"]="kleinitalic",
+ ["pe"]="ایتالیککوچک",
+ ["ro"]="micitalic",
},
- ["top"]={
- ["cs"]="vrsek",
- ["de"]="oben",
- ["en"]="top",
- ["fr"]="sup",
- ["it"]="cima",
- ["nl"]="boven",
- ["pe"]="بالا",
- ["ro"]="sus",
+ ["smallitalicbold"]={
+ ["cs"]="malekurzivnitucne",
+ ["de"]="kleinitalicfett",
+ ["en"]="smallitalicbold",
+ ["fr"]="petititaliquegras",
+ ["it"]="piccolocorsivograssetto",
+ ["nl"]="kleinitalicvet",
+ ["pe"]="مشکیایتالیککوچک",
+ ["ro"]="micitalicaldin",
},
- ["tuesday"]={
- ["cs"]="utery",
- ["de"]="dienstag",
- ["en"]="tuesday",
- ["fr"]="mardi",
- ["it"]="martedi",
- ["nl"]="dinsdag",
- ["pe"]="سهشنبه",
- ["ro"]="marti",
+ ["smallnormal"]={
+ ["cs"]="malenormalni",
+ ["de"]="kleinnormal",
+ ["en"]="smallnormal",
+ ["fr"]="petitnormal",
+ ["it"]="piccolonormale",
+ ["nl"]="kleinnormaal",
+ ["pe"]="نرمالکوچک",
+ ["ro"]="micnormal",
+ },
+ ["smallslanted"]={
+ ["cs"]="malesklonene",
+ ["de"]="kleingeneigt",
+ ["en"]="smallslanted",
+ ["fr"]="petitincline",
+ ["it"]="piccoloinclinato",
+ ["nl"]="kleinschuin",
+ ["pe"]="خوابیدهکوچک",
+ ["ro"]="micinclinat",
+ },
+ ["smallslantedbold"]={
+ ["cs"]="malesklonenetucne",
+ ["de"]="kleingeneigtfett",
+ ["en"]="smallslantedbold",
+ ["fr"]="petitinclinegras",
+ ["it"]="piccoloinclinatograssetto",
+ ["nl"]="kleinschuinvet",
+ ["pe"]="مشکیخوابیدهکوچک",
+ ["ro"]="micinclinataldin",
},
- ["two"]={
- ["cs"]="dve",
- ["de"]="zwei",
- ["en"]="two",
- ["fr"]="deux",
- ["it"]="due",
- ["nl"]="twee",
- ["pe"]="دو",
- ["ro"]="doi",
+ ["smalltype"]={
+ ["cs"]="maletype",
+ ["de"]="kleintippen",
+ ["en"]="smalltype",
+ ["fr"]="petitcaractere",
+ ["it"]="piccolotype",
+ ["nl"]="kleintype",
+ ["pe"]="تایپکوچک",
+ ["ro"]="mictype",
},
- ["txt"]={
- ["cs"]="txt",
- ["de"]="txt",
- ["en"]="txt",
- ["fr"]="txt",
- ["it"]="txt",
- ["nl"]="txt",
- ["pe"]="txt",
- ["ro"]="txt",
+ ["somewhere"]={
+ ["cs"]="nekde",
+ ["de"]="irgendwo",
+ ["en"]="somewhere",
+ ["fr"]="qqpart",
+ ["it"]="daqualcheparte",
+ ["nl"]="ergens",
+ ["pe"]="جایی",
+ ["ro"]="undeva",
},
- ["type"]={
- ["cs"]="opis",
- ["de"]="tippen",
- ["en"]="type",
- ["fr"]="type",
- ["it"]="type",
- ["nl"]="type",
- ["pe"]="تایپ",
- ["ro"]="type",
+ ["sorted"]={
+ ["cs"]="tridene",
+ ["de"]="sortiert",
+ ["en"]="sorted",
+ ["fr"]="trie",
+ ["it"]="ordinato",
+ ["nl"]="gesorteerd",
+ ["pe"]="مرتب",
+ ["ro"]="sortat",
},
- ["typing"]={
- ["cs"]="typing",
- ["de"]="tippen",
- ["en"]="typing",
- ["fr"]="typing",
- ["it"]="typing",
- ["nl"]="typen",
- ["pe"]="تایپکردن",
- ["ro"]="typing",
+ ["sorting"]={
+ ["en"]="sorting",
+ ["fr"]="tri",
},
- ["unavailable"]={
- ["cs"]="nedostupne",
- ["de"]="nichtverfuegbar",
- ["en"]="unavailable",
- ["fr"]="indisponible",
- ["it"]="nondisponibile",
- ["nl"]="nietbeschikbaar",
- ["pe"]="غیرموجود",
- ["ro"]="nedisponibil",
+ ["space"]={
+ ["cs"]="mezera",
+ ["de"]="spatium",
+ ["en"]="space",
+ ["fr"]="espace",
+ ["it"]="spazio",
+ ["nl"]="spatie",
+ ["pe"]="فضا",
+ ["ro"]="spatiu",
},
- ["underbar"]={
- ["cs"]="podtrzeno",
- ["de"]="unterstrichen",
- ["en"]="underbar",
- ["fr"]="souslignetout",
- ["it"]="sottolinea",
- ["nl"]="onderstreep",
- ["pe"]="میلهزیر",
- ["ro"]="sublinie",
+ ["spacing"]={
+ ["cs"]="mezerovani",
+ ["de"]="spatiumausgleich",
+ ["en"]="spacing",
+ ["fr"]="espacement",
+ ["it"]="spaziatura",
+ ["nl"]="spatiering",
+ ["pe"]="فضاگذاری",
+ ["ro"]="spatiere",
},
- ["underbars"]={
- ["cs"]="podtrzeni",
- ["de"]="unterstreichen",
- ["en"]="underbars",
- ["fr"]="sousligne",
- ["it"]="sottolinee",
- ["nl"]="onderstrepen",
- ["pe"]="میلههایزیر",
- ["ro"]="sublinii",
+ ["speech"]={
+ ["cs"]="speech",
+ ["de"]="speech",
+ ["en"]="speech",
+ ["fr"]="discours",
+ ["it"]="speech",
+ ["nl"]="spraak",
+ ["pe"]="سخنرانی",
+ ["ro"]="speech",
},
- ["understrike"]={
- ["en"]="understrike",
+ ["split"]={
+ ["cs"]="split",
+ ["de"]="split",
+ ["en"]="split",
+ ["fr"]="partager",
+ ["it"]="separa",
+ ["nl"]="splitsen",
+ ["pe"]="شکافتن",
+ ["ro"]="split",
},
- ["understrikes"]={
- ["en"]="understrikes",
+ ["spot"]={
+ ["cs"]="spot",
+ ["de"]="spot",
+ ["en"]="spot",
+ ["fr"]="tondirect",
+ ["it"]="spot",
+ ["nl"]="spot",
+ ["pe"]="لکه",
+ ["ro"]="spot",
},
- ["unframed"]={
- ["en"]="unframed",
+ ["standard"]={
+ ["cs"]="standardni",
+ ["de"]="standard",
+ ["en"]="standard",
+ ["fr"]="standard",
+ ["it"]="standard",
+ ["nl"]="standaard",
+ ["pe"]="استاندارد",
+ ["ro"]="standard",
},
- ["unicode"]={
- ["en"]="unicode",
+ ["start"]={
+ ["cs"]="start",
+ ["de"]="start",
+ ["en"]="start",
+ ["fr"]="activé",
+ ["it"]="inizia",
+ ["nl"]="start",
+ ["pe"]="شروع",
+ ["ro"]="start",
},
- ["unit"]={
- ["cs"]="jednotka",
- ["de"]="einheit",
- ["en"]="unit",
- ["fr"]="unite",
- ["it"]="unita",
- ["nl"]="eenheid",
- ["pe"]="واحد",
- ["ro"]="unitate",
+ ["starter"]={
+ ["en"]="starter",
+ ["fr"]="demarreur",
+ ["nl"]="opener",
},
- ["units"]={
- ["cs"]="jednotky",
- ["de"]="einheiten",
- ["en"]="units",
- ["fr"]="unites",
- ["it"]="unita",
- ["nl"]="eenheden",
- ["pe"]="واحدها",
- ["ro"]="unitati",
+ ["sticker"]={
+ ["cs"]="sticker",
+ ["de"]="sticker",
+ ["en"]="sticker",
+ ["fr"]="autocollant",
+ ["it"]="sticker",
+ ["nl"]="sticker",
+ ["pe"]="دشنه",
+ ["ro"]="sticker",
},
- ["unknown"]={
- ["cs"]="neznamy",
- ["de"]="unbekannt",
- ["en"]="unknown",
- ["fr"]="inconnu",
- ["it"]="ignoto",
- ["nl"]="onbekend",
- ["pe"]="ناشناس",
- ["ro"]="necunoscut",
+ ["stop"]={
+ ["cs"]="stop",
+ ["de"]="stop",
+ ["en"]="stop",
+ ["fr"]="fin",
+ ["it"]="termina",
+ ["nl"]="stop",
+ ["pe"]="پایان",
+ ["ro"]="stop",
},
- ["unpacked"]={
- ["cs"]="rozbalene",
- ["de"]="ungepackt",
- ["en"]="unpacked",
- ["fr"]="degroupe",
- ["it"]="unpacked",
- ["nl"]="vanelkaar",
- ["pe"]="غیرفشرده",
- ["ro"]="despachetat",
+ ["stopper"]={
+ ["cs"]="predel",
+ ["de"]="trenner",
+ ["en"]="stopper",
+ ["fr"]="stoppeur",
+ ["it"]="stopper",
+ ["nl"]="afsluiter",
+ ["pe"]="ایست",
+ ["ro"]="stopper",
},
- ["up"]={
- ["en"]="up",
- ["nl"]="omhoog",
+ ["stretch"]={
+ ["cs"]="natahnout",
+ ["de"]="strecken",
+ ["en"]="stretch",
+ ["fr"]="etirer",
+ ["it"]="dilata",
+ ["nl"]="rek",
+ ["pe"]="بکش",
+ ["ro"]="dilatat",
},
- ["url"]={
- ["cs"]="url",
- ["de"]="url",
- ["en"]="url",
- ["fr"]="url",
- ["it"]="url",
- ["nl"]="url",
- ["pe"]="url",
- ["ro"]="url",
+ ["stretched"]={
+ ["en"]="stretched",
+ ["fr"]="etire",
},
- ["used"]={
- ["cs"]="uzito",
- ["de"]="verwende",
- ["en"]="used",
- ["fr"]="used",
- ["it"]="usato",
- ["nl"]="gebruikt",
- ["pe"]="استفادهشده",
- ["ro"]="folosit",
+ ["strict"]={
+ ["cs"]="striktni",
+ ["de"]="streng",
+ ["en"]="strict",
+ ["fr"]="strict",
+ ["it"]="rigido",
+ ["nl"]="streng",
+ ["pe"]="اکید",
+ ["ro"]="strict",
},
- ["value"]={
- ["cs"]="hodnota",
- ["de"]="wert",
- ["en"]="value",
- ["fr"]="valeur",
- ["it"]="valore",
- ["nl"]="waarde",
- ["pe"]="مقدار",
- ["ro"]="valoare",
+ ["strong"]={
+ ["cs"]="strong",
+ ["de"]="strong",
+ ["en"]="strong",
+ ["fr"]="fort",
+ ["it"]="strong",
+ ["nl"]="sterk",
+ ["pe"]="محکم",
+ ["ro"]="strong",
},
- ["vertical"]={
- ["cs"]="vertikalne",
- ["de"]="vertikal",
- ["en"]="vertical",
- ["fr"]="verticale",
- ["it"]="verticale",
- ["nl"]="vertikaal",
- ["pe"]="عمودی",
- ["ro"]="vertical",
+ ["strut"]={
+ ["cs"]="strut",
+ ["de"]="strut",
+ ["en"]="strut",
+ ["fr"]="entretoise",
+ ["it"]="strut",
+ ["nl"]="strut",
+ ["pe"]="بست",
+ ["ro"]="strut",
},
- ["very"]={
- ["cs"]="velmi",
- ["de"]="sehr",
- ["en"]="very",
- ["fr"]="tres",
- ["it"]="molto",
- ["nl"]="zeer",
- ["pe"]="خیلی",
- ["ro"]="foarte",
+ ["sub"]={
+ ["cs"]="pod",
+ ["de"]="unter",
+ ["en"]="sub",
+ ["fr"]="sous",
+ ["it"]="sotto",
+ ["nl"]="sub",
+ ["pe"]="زیر",
+ ["ro"]="sub",
},
- ["verystrict"]={
- ["cs"]="velmistriktni",
- ["de"]="sehrstreng",
- ["en"]="verystrict",
- ["fr"]="tresstrict",
- ["it"]="moltorigido",
- ["nl"]="zeerstreng",
- ["pe"]="خیلیسختگیر",
- ["ro"]="foartestrict",
+ ["subbackward"]={
+ ["cs"]="podzpet",
+ ["de"]="unterrueckwaerts",
+ ["en"]="subbackward",
+ ["fr"]="petitenarriere",
+ ["it"]="sottoindietro",
+ ["nl"]="subachteruit",
+ ["pe"]="زیرعقبگرد",
+ ["ro"]="subinapoi",
},
- ["verytolerant"]={
- ["cs"]="velmitolerantni",
- ["de"]="sehrtolerant",
- ["en"]="verytolerant",
- ["fr"]="trestolerant",
- ["it"]="moltotollerante",
- ["nl"]="zeersoepel",
- ["pe"]="خیلیبردبار",
- ["ro"]="foartetolerant",
+ ["subformula"]={
+ ["cs"]="subrovnice",
+ ["de"]="subformel",
+ ["en"]="subformula",
+ ["fr"]="sousformule",
+ ["it"]="subformula",
+ ["nl"]="subformule",
+ ["pe"]="زیرفرمول",
+ ["ro"]="subformula",
},
- ["vfenced"]={
- ["en"]="vfenced",
+ ["subforward"]={
+ ["cs"]="podvpred",
+ ["de"]="untervorwaerts",
+ ["en"]="subforward",
+ ["fr"]="petitenavant",
+ ["it"]="sottoavanti",
+ ["nl"]="subvooruit",
+ ["pe"]="زیرجلوگرد",
+ ["ro"]="subavans",
},
- ["vulgarfraction"]={
- ["en"]="vulgarfraction",
+ ["subject"]={
+ ["cs"]="tema",
+ ["de"]="thema",
+ ["en"]="subject",
+ ["fr"]="sujet",
+ ["it"]="argomento",
+ ["nl"]="onderwerp",
+ ["pe"]="موضوع",
+ ["ro"]="subiect",
},
- ["weak"]={
- ["cs"]="weak",
- ["de"]="weak",
- ["en"]="weak",
- ["fr"]="weak",
- ["it"]="weak",
- ["nl"]="zwak",
- ["pe"]="هفته",
- ["ro"]="weak",
+ ["subpage"]={
+ ["cs"]="podstranka",
+ ["de"]="unterseite",
+ ["en"]="subpage",
+ ["fr"]="souspage",
+ ["it"]="sottopagina",
+ ["nl"]="subpagina",
+ ["pe"]="زیرصفحه",
+ ["ro"]="subpagina",
},
- ["wednesday"]={
- ["cs"]="streda",
- ["de"]="mittwoch",
- ["en"]="wednesday",
- ["fr"]="mercredi",
- ["it"]="mercoledi",
- ["nl"]="woensdag",
- ["pe"]="چهارشنبه",
- ["ro"]="miercuri",
+ ["subs"]={
+ ["en"]="subs",
+ ["fr"]="subs",
},
- ["week"]={
- ["cs"]="tyden",
- ["de"]="woche",
- ["en"]="week",
- ["fr"]="semaine",
- ["it"]="settimana",
- ["nl"]="week",
- ["pe"]="هفته",
- ["ro"]="saptamana",
+ ["subsection"]={
+ ["cs"]="podsekce",
+ ["de"]="unterabsatz",
+ ["en"]="subsection",
+ ["fr"]="soussection",
+ ["it"]="sottocapoverso",
+ ["nl"]="subparagraaf",
+ ["pe"]="زیربخش",
+ ["ro"]="subsectiune",
},
- ["weekday"]={
- ["cs"]="vsedniden",
- ["de"]="wochentag",
- ["en"]="weekday",
- ["fr"]="joursemaine",
- ["it"]="giornosettimana",
- ["nl"]="weekdag",
- ["pe"]="روزهفته",
- ["ro"]="zisaptamana",
+ ["subsubject"]={
+ ["cs"]="podtema",
+ ["de"]="unterthema",
+ ["en"]="subsubject",
+ ["fr"]="soussujet",
+ ["it"]="sottoargomento",
+ ["nl"]="subonderwerp",
+ ["pe"]="زیرموضوع",
+ ["ro"]="subsubiect",
},
- ["white"]={
- ["cs"]="bily",
- ["de"]="weiss",
- ["en"]="white",
- ["fr"]="blanc",
- ["it"]="bianco",
- ["nl"]="wit",
- ["pe"]="سفید",
- ["ro"]="alb",
+ ["subsubsection"]={
+ ["cs"]="podpodsekce",
+ ["de"]="unterunterabsatz",
+ ["en"]="subsubsection",
+ ["fr"]="soussoussection",
+ ["it"]="sottosottocapoverso",
+ ["nl"]="subsubparagraaf",
+ ["pe"]="زیرزیربخش",
+ ["ro"]="subsubsectiune",
},
- ["wide"]={
- ["cs"]="siroce",
- ["de"]="breit",
- ["en"]="wide",
- ["fr"]="ample",
- ["it"]="ampio",
- ["nl"]="breed",
- ["pe"]="گسترده",
- ["ro"]="larg",
+ ["subsubsubject"]={
+ ["cs"]="podpodtema",
+ ["de"]="unterunterthema",
+ ["en"]="subsubsubject",
+ ["fr"]="soussoussujet",
+ ["it"]="sottosottoargomento",
+ ["nl"]="subsubonderwerp",
+ ["pe"]="زیرزیرموضوع",
+ ["ro"]="subsubsubiect",
},
- ["width"]={
- ["cs"]="sirka",
- ["de"]="breite",
- ["en"]="width",
- ["fr"]="largeur",
- ["it"]="ampiezza",
- ["nl"]="breedte",
- ["pe"]="عرض",
- ["ro"]="latime",
+ ["subsubsubsection"]={
+ ["cs"]="podpodpodsekce",
+ ["de"]="unterunterunterabsatz",
+ ["en"]="subsubsubsection",
+ ["fr"]="soussoussoussection",
+ ["it"]="sottosottosottocapoverso",
+ ["nl"]="subsubsubparagraaf",
+ ["pe"]="زیرزیرزیربخش",
+ ["ro"]="subsubsubsectiune",
},
- ["word"]={
- ["cs"]="slovo",
- ["de"]="wort",
- ["en"]="word",
- ["fr"]="mot",
- ["it"]="parola",
- ["nl"]="woord",
- ["pe"]="word",
- ["ro"]="cuvant",
+ ["subsubsubsubject"]={
+ ["cs"]="podpodpodtema",
+ ["de"]="unterunterunterthema",
+ ["en"]="subsubsubsubject",
+ ["fr"]="soussoussoussujet",
+ ["it"]="sottosottosottoargomento",
+ ["nl"]="subsubsubonderwerp",
+ ["pe"]="زیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubiect",
},
- ["words"]={
- ["en"]="words",
+ ["subsubsubsubsection"]={
+ ["cs"]="podpodpodpodsekce",
+ ["de"]="unterunterunterunterabsatz",
+ ["en"]="subsubsubsubsection",
+ ["fr"]="soussoussoussoussection",
+ ["it"]="sottosottosottosottocapoverso",
+ ["nl"]="subsubsubsubparagraaf",
+ ["pe"]="زیرزیرزیرزیربخش",
+ ["ro"]="subsubsubsubsectiune",
},
- ["xml"]={
- ["cs"]="xml",
- ["de"]="xml",
- ["en"]="xml",
- ["fr"]="xml",
- ["it"]="xml",
- ["nl"]="xml",
- ["pe"]="xml",
- ["ro"]="xml",
+ ["subsubsubsubsubject"]={
+ ["cs"]="podpodpodpodtema",
+ ["de"]="unterunterunterunterthema",
+ ["en"]="subsubsubsubsubject",
+ ["fr"]="soussoussoussoussujet",
+ ["it"]="sottosottosottosottoargomento",
+ ["nl"]="subsubsubsubonderwerp",
+ ["pe"]="زیرزیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubsubiect",
},
- ["year"]={
- ["cs"]="rok",
- ["de"]="jahr",
- ["en"]="year",
- ["fr"]="annee",
- ["it"]="anno",
- ["nl"]="jaar",
- ["pe"]="سال",
- ["ro"]="an",
+ ["subsubsubsubsubsection"]={
+ ["cs"]="podpodpodpodpodsekce",
+ ["de"]="unterunterunterunterunterabsatz",
+ ["en"]="subsubsubsubsubsection",
+ ["fr"]="soussoussoussoussoussection",
+ ["it"]="sottosottosottosottosottocapoverso",
+ ["nl"]="subsubsubsubsubparagraaf",
+ ["pe"]="زیرزیرزیرزیرزیربخش",
+ ["ro"]="subsubsubsubsubsectiune",
},
- ["yes"]={
- ["cs"]="ano",
- ["de"]="ja",
- ["en"]="yes",
- ["fr"]="oui",
- ["it"]="si",
- ["nl"]="ja",
- ["pe"]="بله",
- ["ro"]="da",
+ ["subsubsubsubsubsubject"]={
+ ["cs"]="podpodpodpodpodtema",
+ ["de"]="unterunterunterunterunterthema",
+ ["en"]="subsubsubsubsubsubject",
+ ["fr"]="soussoussoussoussoussujet",
+ ["it"]="sottosottosottosottosottoargomento",
+ ["nl"]="subsubsubsubsubonderwerp",
+ ["pe"]="زیرزیرزیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubsubsubiect",
},
- },
- ["setupstrings"]={
- ["cd:buffer"]={
- ["cs"]="buffer",
- ["de"]="buffer",
- ["en"]="buffer",
- ["fr"]="buffer",
- ["it"]="buffer",
- ["nl"]="buffer",
- ["ro"]="buffer",
+ ["subsubsubsubsubsubsection"]={
+ ["cs"]="podpodpodpodpodpodsekce",
+ ["de"]="unterunterunterunterunterunterabsatz",
+ ["en"]="subsubsubsubsubsubsection",
+ ["fr"]="soussoussoussoussoussoussection",
+ ["it"]="sottosottosottosottosottosottocapoverso",
+ ["nl"]="subsubsubsubsubsubparagraaf",
+ ["pe"]="زیرزیرزیرزیرزیرزیربخش",
+ ["ro"]="subsubsubsubsubsubsectiune",
},
- ["cd:category"]={
- ["cs"]="category",
- ["de"]="category",
- ["en"]="category",
- ["fr"]="category",
- ["it"]="category",
- ["nl"]="category",
- ["ro"]="category",
+ ["subsubsubsubsubsubsubject"]={
+ ["cs"]="podpodpodpodpodpodtema",
+ ["de"]="unterunterunterunterunterunterthema",
+ ["en"]="subsubsubsubsubsubsubject",
+ ["fr"]="soussoussoussoussoussoussujet",
+ ["it"]="sottosottosottosottosottosottoargomento",
+ ["nl"]="subsubsubsubsubsubonderwerp",
+ ["pe"]="زیرزیرزیرزیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubsubsubsubiect",
},
- ["cd:character"]={
- ["cs"]="character",
- ["de"]="character",
- ["en"]="character",
- ["fr"]="character",
- ["it"]="character",
- ["nl"]="karakter",
- ["ro"]="character",
+ ["subsubsubsubsubsubsubsection"]={
+ ["cs"]="podpodpodpodpodpodpodsekce",
+ ["de"]="unterunterunterunterunterunterunterabsatz",
+ ["en"]="subsubsubsubsubsubsubsection",
+ ["fr"]="soussoussoussoussoussoussoussection",
+ ["it"]="sottosottosottosottosottosottosottocapoverso",
+ ["nl"]="subsubsubsubsubsubsubparagraaf",
+ ["pe"]="زیرزیرزیرزیرزیرزیرزیربخش",
+ ["ro"]="subsubsubsubsubsubsubsectiune",
},
- ["cd:color"]={
- ["cs"]="color",
- ["de"]="color",
- ["en"]="color",
- ["fr"]="color",
- ["it"]="color",
- ["nl"]="kleur",
- ["ro"]="color",
+ ["subsubsubsubsubsubsubsubject"]={
+ ["cs"]="podpodpodpodpodpodpodtema",
+ ["de"]="unterunterunterunterunterunterunterthema",
+ ["en"]="subsubsubsubsubsubsubsubject",
+ ["fr"]="soussoussoussoussoussoussoussujet",
+ ["it"]="sottosottosottosottosottosottosottoargomento",
+ ["nl"]="subsubsubsubsubsubsubonderwerp",
+ ["pe"]="زیرزیرزیرزیرزیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubsubsubsubsubiect",
},
- ["cd:column"]={
- ["cs"]="column",
- ["de"]="column",
- ["en"]="column",
- ["fr"]="column",
- ["it"]="column",
- ["nl"]="kolom",
- ["ro"]="column",
+ ["subsubsubsubsubsubsubsubsection"]={
+ ["cs"]="podpodpodpodpodpodpodpodsekce",
+ ["de"]="unterunterunterunterunterunterunterunterabsatz",
+ ["en"]="subsubsubsubsubsubsubsubsection",
+ ["fr"]="soussoussoussoussoussoussoussoussection",
+ ["it"]="sottosottosottosottosottosottosottosottocapoverso",
+ ["nl"]="subsubsubsubsubsubsubsubparagraaf",
+ ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیربخش",
+ ["ro"]="subsubsubsubsubsubsubsubsectiune",
},
- ["cd:command"]={
- ["cs"]="Befehl",
- ["de"]="Befehl",
- ["en"]="command",
- ["fr"]="Befehl",
- ["it"]="Befehl",
- ["nl"]="commando",
- ["ro"]="Befehl",
+ ["subsubsubsubsubsubsubsubsubject"]={
+ ["cs"]="podpodpodpodpodpodpodpodtema",
+ ["de"]="unterunterunterunterunterunterunterunterthema",
+ ["en"]="subsubsubsubsubsubsubsubsubject",
+ ["fr"]="soussoussoussoussoussoussoussoussujet",
+ ["it"]="sottosottosottosottosottosottosottosottoargomento",
+ ["nl"]="subsubsubsubsubsubsubsubonderwerp",
+ ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubsubsubsubsubsubiect",
},
- ["cd:content"]={
- ["cs"]="content",
- ["de"]="content",
- ["en"]="content",
- ["fr"]="content",
- ["it"]="content",
- ["nl"]="inhoud",
- ["ro"]="content",
+ ["subsubsubsubsubsubsubsubsubsection"]={
+ ["cs"]="podpodpodpodpodpodpodpodpodsekce",
+ ["de"]="unterunterunterunterunterunterunterunterunterabsatz",
+ ["en"]="subsubsubsubsubsubsubsubsubsection",
+ ["fr"]="soussoussoussoussoussoussoussoussoussection",
+ ["it"]="sottosottosottosottosottosottosottosottosottocapoverso",
+ ["nl"]="subsubsubsubsubsubsubsubsubparagraaf",
+ ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیرزیربخش",
+ ["ro"]="subsubsubsubsubsubsubsubsubsectiune",
},
- ["cd:csname"]={
- ["cs"]="csname",
- ["de"]="csname",
- ["en"]="csname",
- ["fr"]="csname",
- ["it"]="csname",
- ["nl"]="naam",
- ["ro"]="csname",
+ ["subsubsubsubsubsubsubsubsubsubject"]={
+ ["cs"]="podpodpodpodpodpodpodpodpodtema",
+ ["de"]="unterunterunterunterunterunterunterunterunterthema",
+ ["en"]="subsubsubsubsubsubsubsubsubsubject",
+ ["fr"]="soussoussoussoussoussoussoussoussoussujet",
+ ["it"]="sottosottosottosottosottosottosottosottosottoargomento",
+ ["nl"]="subsubsubsubsubsubsubsubsubonderwerp",
+ ["pe"]="زیرزیرزیرزیرزیرزیرزیرزیرزیرموضوع",
+ ["ro"]="subsubsubsubsubsubsubsubsubsubiect",
},
- ["cd:delimiter"]={
- ["cs"]="delimiter",
- ["de"]="delimiter",
- ["en"]="delimiter",
- ["fr"]="delimiter",
- ["it"]="delimiter",
- ["nl"]="delimiter",
- ["ro"]="delimiter",
+ ["sunday"]={
+ ["cs"]="nedele",
+ ["de"]="sonntag",
+ ["en"]="sunday",
+ ["fr"]="dimanche",
+ ["it"]="domenica",
+ ["nl"]="zondag",
+ ["pe"]="یکشنبه",
+ ["ro"]="duminica",
},
- ["cd:destination"]={
- ["cs"]="destination",
- ["de"]="destination",
- ["en"]="destination",
- ["fr"]="destination",
- ["it"]="destination",
- ["nl"]="bestemming",
- ["ro"]="destination",
+ ["support"]={
+ ["cs"]="podpora",
+ ["de"]="support",
+ ["en"]="support",
+ ["fr"]="support",
+ ["it"]="supporto",
+ ["nl"]="support",
+ ["pe"]="حمایت",
+ ["ro"]="suport",
},
- ["cd:dimension"]={
- ["cs"]="Dimension",
- ["de"]="Dimension",
- ["en"]="dimension",
- ["fr"]="Dimension",
- ["it"]="Dimension",
- ["nl"]="maat",
- ["ro"]="Dimension",
+ ["sym"]={
+ ["cs"]="sym",
+ ["de"]="sym",
+ ["en"]="sym",
+ ["fr"]="sym",
+ ["it"]="sim",
+ ["nl"]="sym",
+ ["pe"]="نم",
+ ["ro"]="sym",
},
- ["cd:displaymath"]={
- ["cs"]="formula",
- ["de"]="formula",
- ["en"]="formula",
- ["fr"]="formula",
- ["it"]="formula",
- ["nl"]="formule",
- ["ro"]="formula",
+ ["symbol"]={
+ ["cs"]="symbol",
+ ["de"]="symbol",
+ ["en"]="symbol",
+ ["fr"]="symbole",
+ ["it"]="simbolo",
+ ["nl"]="symbool",
+ ["pe"]="نماد",
+ ["ro"]="simbol",
},
- ["cd:false"]={
- ["cs"]="false",
- ["de"]="false",
- ["en"]="false",
- ["fr"]="false",
- ["it"]="false",
- ["nl"]="false",
- ["ro"]="false",
+ ["synchronize"]={
+ ["cs"]="synchronize",
+ ["de"]="synchronize",
+ ["en"]="synchronize",
+ ["fr"]="synchroniser",
+ ["it"]="synchronize",
+ ["nl"]="synchroniseer",
+ ["pe"]="تطابق",
+ ["ro"]="synchronize",
},
- ["cd:file"]={
- ["cs"]="file",
- ["de"]="file",
- ["en"]="file",
- ["fr"]="file",
- ["it"]="file",
- ["nl"]="file",
- ["ro"]="file",
+ ["synonym"]={
+ ["en"]="synonym",
+ ["fr"]="synonyme",
},
- ["cd:path"]={
- ["cs"]="path",
- ["de"]="path",
- ["en"]="path",
- ["fr"]="path",
- ["it"]="path",
- ["nl"]="path",
- ["ro"]="path",
+ ["system"]={
+ ["cs"]="system",
+ ["de"]="systeme",
+ ["en"]="system",
+ ["fr"]="systeme",
+ ["it"]="sistema",
+ ["nl"]="systeem",
+ ["pe"]="سیستم",
+ ["ro"]="sistem",
},
- ["cd:first"]={
- ["cs"]="first",
- ["de"]="first",
- ["en"]="first",
- ["fr"]="first",
- ["it"]="first",
- ["nl"]="eerste",
- ["ro"]="first",
+ ["table"]={
+ ["cs"]="tabulka",
+ ["de"]="tabelle",
+ ["en"]="table",
+ ["fr"]="table",
+ ["it"]="tabella",
+ ["nl"]="tabel",
+ ["pe"]="جدول",
+ ["ro"]="tabelul",
},
- ["cd:font"]={
- ["cs"]="font",
- ["de"]="font",
- ["en"]="font",
- ["fr"]="font",
- ["it"]="font",
- ["nl"]="font",
- ["ro"]="font",
+ ["tablehead"]={
+ ["cs"]="zahlavitabulky",
+ ["de"]="tabellenueberschrift",
+ ["en"]="tablehead",
+ ["fr"]="tetetableau",
+ ["it"]="testatabella",
+ ["nl"]="tabelkop",
+ ["pe"]="سرجدول",
+ ["ro"]="antettabel",
},
- ["cd:formula"]={
- ["cs"]="Formel",
- ["de"]="Formel",
- ["en"]="formula",
- ["fr"]="Formel",
- ["it"]="Formel",
- ["nl"]="formule",
- ["ro"]="Formel",
+ ["tables"]={
+ ["cs"]="tabulky",
+ ["de"]="tabellen",
+ ["en"]="tables",
+ ["fr"]="tables",
+ ["it"]="tabelle",
+ ["nl"]="tabellen",
+ ["pe"]="جدولها",
+ ["ro"]="tabelele",
},
- ["cd:identifier"]={
- ["cs"]="Name",
- ["de"]="Name",
- ["en"]="identifier",
- ["fr"]="Name",
- ["it"]="Name",
- ["nl"]="naam",
- ["ro"]="Name",
+ ["tabletail"]={
+ ["cs"]="konectabulky",
+ ["de"]="tabellenende",
+ ["en"]="tabletail",
+ ["fr"]="queuetable",
+ ["it"]="codatabella",
+ ["nl"]="tabelstaart",
+ ["pe"]="دنبالهجدول",
+ ["ro"]="subsoltabel",
},
- ["cd:index"]={
- ["cs"]="entry",
- ["de"]="entry",
- ["en"]="entry",
- ["fr"]="entry",
- ["it"]="entry",
- ["nl"]="ingang",
- ["ro"]="entry",
+ ["tabulate"]={
+ ["cs"]="tabelator",
+ ["de"]="tabulator",
+ ["en"]="tabulate",
+ ["fr"]="tabulation",
+ ["it"]="tabulato",
+ ["nl"]="tabulatie",
+ ["pe"]="جدولبندی",
+ ["ro"]="tabulate",
},
- ["cd:inherits"]={
- ["cs"]="inherits",
- ["de"]="inherits",
- ["en"]="inherits",
- ["fr"]="inherits",
- ["it"]="inherits",
- ["nl"]="erft",
- ["ro"]="inherits",
+ ["tabulatehead"]={
+ ["cs"]="tabulatehead",
+ ["de"]="tabulatehead",
+ ["en"]="tabulatehead",
+ ["fr"]="tetetabulation",
+ ["it"]="testatabulato",
+ ["nl"]="tabulatiekop",
+ ["pe"]="سرجدولبندی",
+ ["ro"]="tabulatehead",
},
- ["cd:key"]={
- ["cs"]="key",
- ["de"]="key",
- ["en"]="key",
- ["fr"]="key",
- ["it"]="key",
- ["nl"]="parameter",
- ["ro"]="key",
+ ["tabulatetail"]={
+ ["cs"]="tabulatetail",
+ ["de"]="tabulatetail",
+ ["en"]="tabulatetail",
+ ["fr"]="queuetabulation",
+ ["it"]="codatabulato",
+ ["nl"]="tabulatiestaart",
+ ["pe"]="دنبالهجدولبندی",
+ ["ro"]="tabulatetail",
},
- ["cd:language"]={
- ["cs"]="sprache",
- ["de"]="sprache",
- ["en"]="language",
- ["fr"]="sprache",
- ["it"]="sprache",
- ["nl"]="taal",
- ["ro"]="sprache",
+ ["tall"]={
+ ["cs"]="vysoko",
+ ["de"]="lang",
+ ["en"]="tall",
+ ["fr"]="grand",
+ ["it"]="alto",
+ ["nl"]="lang",
+ ["pe"]="دراز",
+ ["ro"]="inalt",
},
- ["cd:last"]={
- ["cs"]="last",
- ["de"]="last",
- ["en"]="last",
- ["fr"]="last",
- ["it"]="last",
- ["nl"]="laatste",
- ["ro"]="last",
+ ["teletype"]={
+ ["cs"]="strojopis",
+ ["de"]="fernschreiber",
+ ["en"]="teletype",
+ ["fr"]="caractereterminal",
+ ["it"]="teletype",
+ ["nl"]="teletype",
+ ["pe"]="دورنگاره",
+ ["ro"]="teletype",
},
- ["cd:list"]={
- ["cs"]="Liste",
- ["de"]="Liste",
- ["en"]="list",
- ["fr"]="Liste",
- ["it"]="Liste",
- ["nl"]="lijst",
- ["ro"]="Liste",
+ ["temporary"]={
+ ["cs"]="docasne",
+ ["de"]="temporaer",
+ ["en"]="temporary",
+ ["fr"]="temporaire",
+ ["it"]="temporaneo",
+ ["nl"]="voorlopig",
+ ["pe"]="موقتی",
+ ["ro"]="temporar",
},
- ["cd:lpath"]={
- ["cs"]="lpath",
- ["de"]="lpath",
- ["en"]="lpath",
- ["fr"]="lpath",
- ["it"]="lpath",
- ["nl"]="lpath",
- ["ro"]="lpath",
+ ["test"]={
+ ["cs"]="test",
+ ["de"]="test",
+ ["en"]="test",
+ ["fr"]="test",
+ ["it"]="test",
+ ["nl"]="test",
+ ["pe"]="تست",
+ ["ro"]="test",
},
- ["cd:luafunction"]={
- ["cs"]="luafunction",
- ["de"]="luafunction",
- ["en"]="luafunction",
- ["fr"]="luafunction",
- ["it"]="luafunction",
- ["nl"]="luafunction",
- ["ro"]="luafunction",
+ ["text"]={
+ ["cs"]="text",
+ ["de"]="text",
+ ["en"]="text",
+ ["fr"]="texte",
+ ["it"]="testo",
+ ["nl"]="tekst",
+ ["pe"]="متن",
+ ["ro"]="text",
},
- ["cd:mark"]={
- ["cs"]="Beschriftung",
- ["de"]="Beschriftung",
- ["en"]="mark",
- ["fr"]="Beschriftung",
- ["it"]="Beschriftung",
- ["nl"]="markering",
- ["ro"]="Beschriftung",
+ ["textnote"]={
+ ["en"]="textnote",
+ ["fr"]="notetexte",
+ ["nl"]="tekstnoot",
},
- ["cd:marking"]={
- ["cs"]="marking",
- ["de"]="marking",
- ["en"]="marking",
- ["fr"]="marking",
- ["it"]="marking",
- ["nl"]="markering",
- ["ro"]="marking",
+ ["three"]={
+ ["cs"]="tri",
+ ["de"]="drei",
+ ["en"]="three",
+ ["fr"]="trois",
+ ["it"]="tre",
+ ["nl"]="drie",
+ ["pe"]="سه",
+ ["ro"]="trei",
},
- ["cd:math"]={
- ["cs"]="formula",
- ["de"]="formula",
- ["en"]="formula",
- ["fr"]="formula",
- ["it"]="formula",
- ["nl"]="formule",
- ["ro"]="formula",
+ ["thursday"]={
+ ["cs"]="ctvrtek",
+ ["de"]="donnerstag",
+ ["en"]="thursday",
+ ["fr"]="jeudi",
+ ["it"]="giovedi",
+ ["nl"]="donderdag",
+ ["pe"]="پنجشنبه",
+ ["ro"]="joi",
},
- ["cd:matrix"]={
- ["cs"]="n*m",
- ["de"]="n*m",
- ["en"]="n*m",
- ["fr"]="n*m",
- ["it"]="n*m",
- ["nl"]="n*m",
- ["ro"]="n*m",
+ ["tight"]={
+ ["en"]="tight",
+ ["fr"]="resserre",
+ ["nl"]="krap",
},
- ["cd:name"]={
- ["cs"]="Name",
- ["de"]="Name",
- ["en"]="name",
- ["fr"]="Name",
- ["it"]="Name",
- ["nl"]="naam",
- ["ro"]="Name",
+ ["title"]={
+ ["cs"]="titul",
+ ["de"]="titel",
+ ["en"]="title",
+ ["fr"]="titre",
+ ["it"]="titolo",
+ ["nl"]="titel",
+ ["pe"]="عنوان",
+ ["ro"]="titlu",
},
- ["cd:node"]={
- ["cs"]="node",
- ["de"]="node",
- ["en"]="node",
- ["fr"]="node",
- ["it"]="node",
- ["nl"]="node",
- ["ro"]="node",
+ ["toggle"]={
+ ["cs"]="toggle",
+ ["de"]="toggle",
+ ["en"]="wissel",
+ ["fr"]="basculer",
+ ["it"]="toggle",
+ ["nl"]="toggle",
+ ["pe"]="تغییر",
+ ["ro"]="toggle",
},
- ["cd:nothing"]={
- ["cs"]="empty",
- ["de"]="empty",
- ["en"]="empty",
- ["fr"]="empty",
- ["it"]="empty",
- ["nl"]="leeg",
- ["ro"]="empty",
+ ["tolerant"]={
+ ["cs"]="tolerantni",
+ ["de"]="tolerant",
+ ["en"]="tolerant",
+ ["fr"]="tolerant",
+ ["it"]="tollerante",
+ ["nl"]="soepel",
+ ["pe"]="بردبار",
+ ["ro"]="tolerant",
},
- ["cd:number"]={
- ["cs"]="Nummer",
- ["de"]="Nummer",
- ["en"]="number",
- ["fr"]="Nummer",
- ["it"]="Nummer",
- ["nl"]="getal",
- ["ro"]="Nummer",
+ ["top"]={
+ ["cs"]="vrsek",
+ ["de"]="oben",
+ ["en"]="top",
+ ["fr"]="haut",
+ ["it"]="cima",
+ ["nl"]="boven",
+ ["pe"]="بالا",
+ ["ro"]="sus",
},
- ["cd:optional"]={
- ["cs"]="opt",
- ["de"]="opt",
- ["en"]="opt",
- ["fr"]="opt",
- ["it"]="opt",
- ["nl"]="opt",
- ["ro"]="opt",
+ ["tuesday"]={
+ ["cs"]="utery",
+ ["de"]="dienstag",
+ ["en"]="tuesday",
+ ["fr"]="mardi",
+ ["it"]="martedi",
+ ["nl"]="dinsdag",
+ ["pe"]="سهشنبه",
+ ["ro"]="marti",
},
- ["cd:plural"]={
- ["cs"]="plural",
- ["de"]="plural",
- ["en"]="plural",
- ["fr"]="plural",
- ["it"]="plural",
- ["nl"]="naam",
- ["ro"]="plural",
+ ["two"]={
+ ["cs"]="dve",
+ ["de"]="zwei",
+ ["en"]="two",
+ ["fr"]="deux",
+ ["it"]="due",
+ ["nl"]="twee",
+ ["pe"]="دو",
+ ["ro"]="doi",
},
- ["cd:position"]={
- ["cs"]="position",
- ["de"]="position",
- ["en"]="position",
- ["fr"]="position",
- ["it"]="position",
- ["nl"]="positie",
- ["ro"]="position",
+ ["txt"]={
+ ["cs"]="txt",
+ ["de"]="txt",
+ ["en"]="txt",
+ ["fr"]="txt",
+ ["it"]="txt",
+ ["nl"]="txt",
+ ["pe"]="txt",
+ ["ro"]="txt",
},
- ["cd:processor"]={
- ["cs"]="processor",
- ["de"]="processor",
- ["en"]="processor",
- ["fr"]="processor",
- ["it"]="processor",
- ["nl"]="verwerker",
- ["ro"]="processor",
+ ["type"]={
+ ["cs"]="opis",
+ ["de"]="tippen",
+ ["en"]="type",
+ ["fr"]="transcrire",
+ ["it"]="type",
+ ["nl"]="type",
+ ["pe"]="تایپ",
+ ["ro"]="type",
},
- ["cd:reference"]={
- ["cs"]="reference",
- ["de"]="reference",
- ["en"]="reference",
- ["fr"]="reference",
- ["it"]="reference",
- ["nl"]="verwijzing",
- ["ro"]="reference",
+ ["typing"]={
+ ["cs"]="typing",
+ ["de"]="tippen",
+ ["en"]="typing",
+ ["fr"]="transcription",
+ ["it"]="typing",
+ ["nl"]="typen",
+ ["pe"]="تایپکردن",
+ ["ro"]="typing",
},
- ["cd:row"]={
- ["cs"]="row",
- ["de"]="row",
- ["en"]="row",
- ["fr"]="row",
- ["it"]="row",
- ["nl"]="rij",
- ["ro"]="row",
+ ["unavailable"]={
+ ["cs"]="nedostupne",
+ ["de"]="nichtverfuegbar",
+ ["en"]="unavailable",
+ ["fr"]="indisponible",
+ ["it"]="nondisponibile",
+ ["nl"]="nietbeschikbaar",
+ ["pe"]="غیرموجود",
+ ["ro"]="nedisponibil",
},
- ["cd:section"]={
- ["cs"]="Abschnitt",
- ["de"]="Abschnitt",
- ["en"]="section",
- ["fr"]="Abschnitt",
- ["it"]="Abschnitt",
- ["nl"]="sectie",
- ["ro"]="Abschnitt",
+ ["underbar"]={
+ ["cs"]="podtrzeno",
+ ["de"]="unterstrichen",
+ ["en"]="underbar",
+ ["fr"]="souligner",
+ ["it"]="sottolinea",
+ ["nl"]="onderstreep",
+ ["pe"]="میلهزیر",
+ ["ro"]="sublinie",
},
- ["cd:sectionblock"]={
- ["cs"]="sectionblock",
- ["de"]="sectionblock",
- ["en"]="sectionblock",
- ["fr"]="sectionblock",
- ["it"]="sectionblock",
- ["nl"]="sectieblok",
- ["ro"]="sectionblock",
+ ["underbars"]={
+ ["cs"]="podtrzeni",
+ ["de"]="unterstreichen",
+ ["en"]="underbars",
+ ["fr"]="soulignermots",
+ ["it"]="sottolinee",
+ ["nl"]="onderstrepen",
+ ["pe"]="میلههایزیر",
+ ["ro"]="sublinii",
},
- ["cd:see"]={
- ["cs"]="siehe",
- ["de"]="siehe",
- ["en"]="see",
- ["fr"]="siehe",
- ["it"]="siehe",
- ["nl"]="zie",
- ["ro"]="siehe",
+ ["understrike"]={
+ ["en"]="understrike",
+ ["fr"]="soubarrer",
},
- ["cd:setup"]={
- ["cs"]="setup",
- ["de"]="setup",
- ["en"]="setup",
- ["fr"]="setup",
- ["it"]="setup",
- ["nl"]="setup",
- ["ro"]="setup",
+ ["understrikes"]={
+ ["en"]="understrikes",
+ ["fr"]="soubarrermots",
},
- ["cd:singular"]={
- ["cs"]="singular",
- ["de"]="singular",
- ["en"]="singular",
- ["fr"]="singular",
- ["it"]="singular",
- ["nl"]="naam",
- ["ro"]="singular",
+ ["unframed"]={
+ ["en"]="unframed",
+ ["fr"]="desencadre",
},
- ["cd:style"]={
- ["cs"]="style",
- ["de"]="style",
- ["en"]="style",
- ["fr"]="style",
- ["it"]="style",
- ["nl"]="letter",
- ["ro"]="style",
+ ["unicode"]={
+ ["en"]="unicode",
+ ["fr"]="unicode",
},
- ["cd:template"]={
- ["cs"]="template",
- ["de"]="template",
- ["en"]="template",
- ["fr"]="template",
- ["it"]="template",
- ["nl"]="sjabloon",
- ["ro"]="template",
+ ["unit"]={
+ ["cs"]="jednotka",
+ ["de"]="einheit",
+ ["en"]="unit",
+ ["fr"]="unite",
+ ["it"]="unita",
+ ["nl"]="eenheid",
+ ["pe"]="واحد",
+ ["ro"]="unitate",
},
- ["cd:text"]={
- ["cs"]="Text",
- ["de"]="Text",
- ["en"]="text",
- ["fr"]="Text",
- ["it"]="Text",
- ["nl"]="tekst",
- ["ro"]="Text",
+ ["units"]={
+ ["cs"]="jednotky",
+ ["de"]="einheiten",
+ ["en"]="units",
+ ["fr"]="unites",
+ ["it"]="unita",
+ ["nl"]="eenheden",
+ ["pe"]="واحدها",
+ ["ro"]="unitati",
},
- ["cd:title"]={
- ["cs"]="Setup",
- ["de"]="Setup",
- ["en"]="setup",
- ["fr"]="Setup",
- ["it"]="Setup",
- ["nl"]="setup",
- ["ro"]="Setup",
+ ["unknown"]={
+ ["cs"]="neznamy",
+ ["de"]="unbekannt",
+ ["en"]="unknown",
+ ["fr"]="inconnu",
+ ["it"]="ignoto",
+ ["nl"]="onbekend",
+ ["pe"]="ناشناس",
+ ["ro"]="necunoscut",
},
- ["cd:triplet"]={
- ["cs"]="triplet",
- ["de"]="triplet",
- ["en"]="triplet",
- ["fr"]="triplet",
- ["it"]="triplet",
- ["nl"]="triplet",
- ["ro"]="triplet",
+ ["unpacked"]={
+ ["cs"]="rozbalene",
+ ["de"]="ungepackt",
+ ["en"]="unpacked",
+ ["fr"]="avecespaceentreitem",
+ ["it"]="unpacked",
+ ["nl"]="vanelkaar",
+ ["pe"]="غیرفشرده",
+ ["ro"]="despachetat",
},
- ["cd:true"]={
- ["cs"]="true",
- ["de"]="true",
- ["en"]="true",
- ["fr"]="true",
- ["it"]="true",
- ["nl"]="true",
- ["ro"]="true",
+ ["up"]={
+ ["en"]="up",
+ ["fr"]="enhaut",
+ ["nl"]="omhoog",
},
- ["cd:url"]={
+ ["url"]={
["cs"]="url",
["de"]="url",
["en"]="url",
["fr"]="url",
["it"]="url",
["nl"]="url",
+ ["pe"]="url",
["ro"]="url",
},
- ["cd:userdata"]={
- ["cs"]="userdata",
- ["de"]="userdata",
- ["en"]="userdata",
- ["fr"]="userdata",
- ["it"]="userdata",
- ["nl"]="gebruikersdata",
- ["ro"]="userdata",
+ ["used"]={
+ ["cs"]="uzito",
+ ["de"]="verwende",
+ ["en"]="used",
+ ["fr"]="utilise",
+ ["it"]="usato",
+ ["nl"]="gebruikt",
+ ["pe"]="استفادهشده",
+ ["ro"]="folosit",
},
- ["cd:value"]={
- ["cs"]="value",
- ["de"]="value",
+ ["value"]={
+ ["cs"]="hodnota",
+ ["de"]="wert",
["en"]="value",
- ["fr"]="value",
- ["it"]="value",
+ ["fr"]="valeur",
+ ["it"]="valore",
["nl"]="waarde",
- ["ro"]="value",
+ ["pe"]="مقدار",
+ ["ro"]="valoare",
},
- ["cd:word"]={
- ["cs"]="word",
- ["de"]="word",
+ ["vertical"]={
+ ["cs"]="vertikalne",
+ ["de"]="vertikal",
+ ["en"]="vertical",
+ ["fr"]="vertical",
+ ["it"]="verticale",
+ ["nl"]="vertikaal",
+ ["pe"]="عمودی",
+ ["ro"]="vertical",
+ },
+ ["very"]={
+ ["cs"]="velmi",
+ ["de"]="sehr",
+ ["en"]="very",
+ ["fr"]="tres",
+ ["it"]="molto",
+ ["nl"]="zeer",
+ ["pe"]="خیلی",
+ ["ro"]="foarte",
+ },
+ ["verystrict"]={
+ ["cs"]="velmistriktni",
+ ["de"]="sehrstreng",
+ ["en"]="verystrict",
+ ["fr"]="tresstrict",
+ ["it"]="moltorigido",
+ ["nl"]="zeerstreng",
+ ["pe"]="خیلیسختگیر",
+ ["ro"]="foartestrict",
+ },
+ ["verytolerant"]={
+ ["cs"]="velmitolerantni",
+ ["de"]="sehrtolerant",
+ ["en"]="verytolerant",
+ ["fr"]="trestolerant",
+ ["it"]="moltotollerante",
+ ["nl"]="zeersoepel",
+ ["pe"]="خیلیبردبار",
+ ["ro"]="foartetolerant",
+ },
+ ["vfenced"]={
+ ["en"]="vfenced",
+ ["fr"]="cloturev",
+ },
+ ["vulgarfraction"]={
+ ["en"]="vulgarfraction",
+ ["fr"]="vulgarfraction",
+ },
+ ["weak"]={
+ ["cs"]="weak",
+ ["de"]="weak",
+ ["en"]="weak",
+ ["fr"]="faible",
+ ["it"]="weak",
+ ["nl"]="zwak",
+ ["pe"]="هفته",
+ ["ro"]="weak",
+ },
+ ["wednesday"]={
+ ["cs"]="streda",
+ ["de"]="mittwoch",
+ ["en"]="wednesday",
+ ["fr"]="mercredi",
+ ["it"]="mercoledi",
+ ["nl"]="woensdag",
+ ["pe"]="چهارشنبه",
+ ["ro"]="miercuri",
+ },
+ ["week"]={
+ ["cs"]="tyden",
+ ["de"]="woche",
+ ["en"]="week",
+ ["fr"]="semaine",
+ ["it"]="settimana",
+ ["nl"]="week",
+ ["pe"]="هفته",
+ ["ro"]="saptamana",
+ },
+ ["weekday"]={
+ ["cs"]="vsedniden",
+ ["de"]="wochentag",
+ ["en"]="weekday",
+ ["fr"]="joursemaine",
+ ["it"]="giornosettimana",
+ ["nl"]="weekdag",
+ ["pe"]="روزهفته",
+ ["ro"]="zisaptamana",
+ },
+ ["white"]={
+ ["cs"]="bily",
+ ["de"]="weiss",
+ ["en"]="white",
+ ["fr"]="blanc",
+ ["it"]="bianco",
+ ["nl"]="wit",
+ ["pe"]="سفید",
+ ["ro"]="alb",
+ },
+ ["wide"]={
+ ["cs"]="siroce",
+ ["de"]="breit",
+ ["en"]="wide",
+ ["fr"]="ample",
+ ["it"]="ampio",
+ ["nl"]="breed",
+ ["pe"]="گسترده",
+ ["ro"]="larg",
+ },
+ ["width"]={
+ ["cs"]="sirka",
+ ["de"]="breite",
+ ["en"]="width",
+ ["fr"]="largeur",
+ ["it"]="ampiezza",
+ ["nl"]="breedte",
+ ["pe"]="عرض",
+ ["ro"]="latime",
+ },
+ ["word"]={
+ ["cs"]="slovo",
+ ["de"]="wort",
["en"]="word",
- ["fr"]="word",
- ["it"]="word",
+ ["fr"]="mot",
+ ["it"]="parola",
["nl"]="woord",
- ["ro"]="word",
+ ["pe"]="word",
+ ["ro"]="cuvant",
},
- ["cd:xmlsetup"]={
- ["cs"]="xmlsetup",
- ["de"]="xmlsetup",
- ["en"]="xmlsetup",
- ["fr"]="xmlsetup",
- ["it"]="xmlsetup",
- ["nl"]="xmlsetup",
- ["ro"]="xmlsetup",
+ ["words"]={
+ ["en"]="words",
+ ["fr"]="mots",
+ },
+ ["xml"]={
+ ["cs"]="xml",
+ ["de"]="xml",
+ ["en"]="xml",
+ ["fr"]="xml",
+ ["it"]="xml",
+ ["nl"]="xml",
+ ["pe"]="xml",
+ ["ro"]="xml",
+ },
+ ["year"]={
+ ["cs"]="rok",
+ ["de"]="jahr",
+ ["en"]="year",
+ ["fr"]="annee",
+ ["it"]="anno",
+ ["nl"]="jaar",
+ ["pe"]="سال",
+ ["ro"]="an",
+ },
+ ["yes"]={
+ ["cs"]="ano",
+ ["de"]="ja",
+ ["en"]="yes",
+ ["fr"]="oui",
+ ["it"]="si",
+ ["nl"]="ja",
+ ["pe"]="بله",
+ ["ro"]="da",
},
- ["cd:sign"] = { en = "[-+]" },
- ["cd:csname-s"] = { en = "\\..." },
- ["cd:csname-l"] = { en = "\\..." },
- ["cd:noargument-s"] = { en = "\\..." },
- ["cd:noargument-l"] = { en = "\\..." },
- ["cd:oneargument"] = { en = "\\...#1" },
- ["cd:twoarguments"] = { en = "\\...#1#2" },
- ["cd:threearguments"] = { en = "\\...#1#2#3" },
- ["cd:braces-s"] = { en = "{...}", lua = '"..."' },
- ["cd:braces-l"] = { en = "{...,...}", lua = '".. ... .."' },
- ["cd:brackets-s"] = { en = "[...]", lua = "{ ... }" },
- ["cd:brackets-l"] = { en = "[...,...]", lua = "{..., ...}" },
- ["cd:parenthesis-s"] = { en = "(...)" },
- ["cd:parenthesis-l"] = { en = "(...,...)" },
- ["cd:index-s"] = { en = "{...}" },
- ["cd:index-l"] = { en = "{..+...+..}" },
- ["cd:math-s"] = { en = "$...$" },
- ["cd:math-l"] = { en = "$...$" },
- ["cd:inlinemath-s"] = { en = "$...$" },
- ["cd:inlinemath-l"] = { en = "$...$" },
- ["cd:displaymath-s"] = { en = "$$...$$" },
- ["cd:displaymath-l"] = { en = "$$...$$" },
- ["cd:template-s"] = { en = "[|...|]" },
- ["cd:template-l"] = { en = "[|...|...|]" },
- ["cd:twowords-s"] = { en = "[..+..]" },
- ["cd:twowords-l"] = { en = "[..+..]" },
- ["cd:threewords-s"] = { en = "[..+..+..]" },
- ["cd:threewords-l"] = { en = "[..+..+..]" },
- ["cd:angle-s"] = { en = "<<...>>" },
- ["cd:angle-l"] = { en = "<<...>>" },
- ["cd:reference-s"] = { en = "[...]", lua = "{ ... }" },
- ["cd:reference-l"] = { en = "[...,...]", lua = "{..., ...}" },
- ["cd:position-s"] = { en = "(...)" },
- ["cd:position-l"] = { en = "(...,...)" },
- ["cd:triplet-s"] = { en = "[x:y:z]" },
- ["cd:triplet-l"] = { en = "[x:y:z,..]" },
- ["cd:word-s"] = { en = "{...}", lua = '"..."' },
- ["cd:word-l"] = { en = "{.. ... ..}", lua = '".. ... .."' },
- ["cd:content-s"] = { en = "{...}", lua = '"..."' },
- ["cd:content-l"] = { en = "{.. ... ..}", lua = '".. ... .."' },
- ["cd:textual-s"] = { en = "..." },
- ["cd:textual-l"] = { en = ".. ... .." },
- ["cd:none-s"] = { en = "..." },
- ["cd:none-l"] = { en = ".. ... .." },
- ["cd:macro-s"] = { en = "\\... " },
- ["cd:macro-l"] = { en = "\\... " },
- ["cd:to-s"] = { en = "\\to " },
- ["cd:to-l"] = { en = "\\to " },
- ["cd:destination-s"] = { en = "[{..[ref]}]" },
- ["cd:destination-l"] = { en = "[..,{..[ref,..]},..]" },
- ["cd:nothing-s"] = { en = "..." },
- ["cd:nothing-l"] = { en = "..." },
- ["cd:file-s"] = { en = " ... " },
- ["cd:file-l"] = { en = " ... " },
- ["cd:assignment-s"] = { en = "[..=..]", lua = "{ ..=.. } " },
- ["cd:assignment-l"] = { en = "[..,..=..,..]", lua = "{ ..,..=..,.. } " },
- ["cd:assignmentbraces-s"] = { en = "{..=..}" },
- ["cd:assignmentbraces-l"] = { en = "{..,..=..,..}" },
- ["cd:assignmentbrackets-s"] = { en = "[..=..]", lua = "{ ..=.. } " },
- ["cd:assignmentbrackets-l"] = { en = "[..,..=..,..]", lua = "{ ..,..=..,.. } " },
- ["cd:assignmentparentheses-s"] = { en = "(..=..)" },
- ["cd:assignmentparentheses-l"] = { en = "(..,..=..,..)" },
- ["cd:apply-s"] = { en = "[..=>..]" },
- ["cd:apply-l"] = { en = "[..,..=>..,..]" },
- ["cd:if-s"] = { en = "\\if... " },
- ["cd:if-l"] = { en = "\\if... " },
- ["cd:case-s"] = { en = "\\case " },
- ["cd:case-l"] = { en = "\\case " },
- ["cd:else-s"] = { en = "\\else " },
- ["cd:else-l"] = { en = "\\else " },
- ["cd:or-s"] = { en = "\\or " },
- ["cd:or-l"] = { en = "\\or " },
- ["cd:fi-s"] = { en = "\\fi " },
- ["cd:fi-l"] = { en = "\\fi " },
- ["cd:par-s"] = { en = "\\par " },
- ["cd:par-l"] = { en = "\\par " },
- ["cd:sep-s"] = { en = "\\" },
- ["cd:sep-l"] = { en = "\\" },
- }
+ },
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-def.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mult-def.mkiv
index 78fcdf667dd..0a450e8b070 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-def.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-def.mkiv
@@ -37,9 +37,9 @@
% some left-overs
-\def\c!HL{HL}
-\def\c!VL{VL}
-\def\c!NL{NL}
+\defineinterfaceconstant {HL} {HL}
+\defineinterfaceconstant {VL} {VL}
+\defineinterfaceconstant {NL} {NL}
% stop todo
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-dim.mkvi b/Master/texmf-dist/tex/context/base/mkiv/mult-dim.mkvi
index 0224e3dbb16..952550055c6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-dim.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-dim.mkvi
@@ -48,10 +48,10 @@
\setvalue{\??dimensionnormal-\v!big }#value#dimension#small#medium#big{#dimension=-#big\relax}
\letvalue{\??dimensionnormal\s!unknown}\assign_dimension_direct
-% \unexpanded\def\assigndimension#value%
+% \protected\def\assigndimension#value%
% {\csname\??dimensionnormal\ifcsname\??dimensionnormal#value\endcsname#value\else\s!unknown\fi\endcsname{#value}}
-\unexpanded\def\assigndimension#value%
+\protected\def\assigndimension#value%
{\ifcsname\??dimensionnormal#value\endcsname
\expandafter\lastnamedcs
\else
@@ -81,10 +81,10 @@
\setvalue{\??dimensionalfa\v!big }#value#macro#small#medium#big{\edef#macro{#big}}
\letvalue{\??dimensionalfa\s!unknown}\assign_alpha_dimension_direct
-% \unexpanded\def\assignalfadimension#value%
+% \protected\def\assignalfadimension#value%
% {\csname\??dimensionalfa\ifcsname\??dimensionalfa#value\endcsname#value\else\s!unknown\fi\endcsname{#value}}
-\unexpanded\def\assignalfadimension#value%
+\protected\def\assignalfadimension#value%
{\ifcsname\??dimensionalfa#value\endcsname
\expandafter\lastnamedcs
\else
@@ -115,10 +115,10 @@
\setvalue{\??dimensionvalue\v!big }#value#macro#small#medium#big{\edef#macro{#big}}
\letvalue{\??dimensionvalue\s!unknown}\assign_value_direct
-% \unexpanded\def\assignvalue#value%
+% \protected\def\assignvalue#value%
% {\csname\??dimensionvalue\ifcsname\??dimensionvalue#value\endcsname#value\else\s!unknown\fi\endcsname{#value}}
-\unexpanded\def\assignvalue#value%
+\protected\def\assignvalue#value%
{\ifcsname\??dimensionvalue#value\endcsname
\expandafter\lastnamedcs
\else
@@ -157,10 +157,10 @@
\setbox\b_assign_width\emptybox}
\letvalue{\??dimensionwidth\s!unknown}\assign_width_direct
-% \unexpanded\def\assignwidth#value%
+% \protected\def\assignwidth#value%
% {\csname\??dimensionwidth\ifcsname\??dimensionwidth#value\endcsname#value\else\s!unknown\fi\endcsname{#value}}
-\unexpanded\def\assignwidth#value%
+\protected\def\assignwidth#value%
{\ifcsname\??dimensionwidth#value\endcsname
\expandafter\lastnamedcs
\else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-fmt.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-fmt.lua
new file mode 100644
index 00000000000..0d11a425333
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-fmt.lua
@@ -0,0 +1,338 @@
+if not modules then modules = { } end modules ['mult-fmt'] = {
+ version = 1.001,
+ comment = "companion to mult-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local next = next
+local concat, sortedhash = table.concat, table.sortedhash
+local sub, formatters = string.sub, string.formatters
+local utfsplit = utf.split
+
+local prtcatcodes = catcodes.numbers.prtcatcodes
+local contextsprint = context.sprint
+local implement = interfaces.implement
+
+local setmacro = token.set_macro
+local definedmacro = token.is_defined
+
+local report = logs.reporter("interface")
+local report_interface = logs.reporter("interface","initialization")
+local report_variable = logs.reporter("variable")
+local report_constant = logs.reporter("constant")
+local report_command = logs.reporter("command")
+local report_element = logs.reporter("element")
+local report_format = logs.reporter("format")
+local report_messagetag = logs.reporter("messagetag")
+local report_setupstring = logs.reporter("setupstring")
+
+local function limit(str,n)
+ if n > 6 and #str > n then
+ n = n - 4
+ local t = utfsplit(str)
+ local m = #t
+ if m > n then
+ t[n] = " ..."
+ str = concat(t,"",1,n)
+ end
+ end
+ return str
+end
+
+-- function interfaces.setuserinterface(interface,response)
+-- local variables = interfaces.variables
+-- local constants = interfaces.constants
+-- local elements = interfaces.elements
+-- local formats = interfaces.formats
+-- local translations = interfaces.translations
+-- local setupstrings = interfaces.setupstrings
+-- local complete = interfaces.complete
+-- local sharedstorage = storage.shared
+-- --
+-- sharedstorage.currentinterface, currentinterface = interface, interface
+-- sharedstorage.currentresponse, currentresponse = response, response
+-- --
+-- if environment.initex then
+-- local nofconstants = 0
+-- local nofvariables = 0
+-- local nofelements = 0
+-- local nofcommands = 0
+-- local nofformats = 0
+-- local noftranslations = 0
+-- local nofsetupstrings = 0
+-- --
+-- do
+-- local list = complete.constants -- forces the load
+-- local t = { }
+-- local f = formatters["\\ui_c{%s}{%s}"]
+-- local s = formatters["\\ui_s{%s}"]
+-- logs.startfilelogging(report,"translated constants")
+-- for given, constant in sortedhash(list) do
+-- constant = constant[interface] or constant.en or given
+-- constants[constant] = given -- breedte -> width
+-- nofconstants = nofconstants + 1
+-- if given == constant then
+-- t[nofconstants] = s(given)
+-- else
+-- t[nofconstants] = f(given,constant)
+-- end
+-- report_constant("%-40s: %s",given,constant)
+-- end
+-- logs.stopfilelogging()
+-- contextsprint(prtcatcodes,concat(t))
+-- end
+-- do
+-- local list = complete.variables -- forces the load
+-- local t = { }
+-- local f = formatters["\\ui_v{%s}{%s}"]
+-- logs.startfilelogging(report,"translated variables")
+-- for given, variable in sortedhash(list) do
+-- variable = variable[interface] or variable.en or given
+-- variables[given] = variable -- ja -> yes
+-- nofvariables = nofvariables + 1
+-- t[nofvariables] = f(given,variable)
+-- report_variable("%-40s: %s",given,variable)
+-- end
+-- logs.stopfilelogging()
+-- contextsprint(prtcatcodes,concat(t))
+-- end
+-- do
+-- local list = complete.elements -- forces the load
+-- local t = { }
+-- local f = formatters["\\ui_e{%s}{%s}"]
+-- logs.startfilelogging(report,"translated elements")
+-- for given, element in sortedhash(list) do
+-- element = element[interface] or element.en or given
+-- elements[element] = given
+-- nofelements = nofelements + 1
+-- t[nofelements] = f(given,element)
+-- report_element("%-40s: %s",given,element)
+-- end
+-- logs.stopfilelogging()
+-- contextsprint(prtcatcodes,concat(t))
+-- end
+-- do
+-- local list = complete.commands -- forces the load
+-- local t = { }
+-- local n = 0
+-- local f = formatters["\\ui_a\\%s\\%s"] -- formatters["\\ui_m{%s}{%s}"]
+-- logs.startfilelogging(report,"translated commands")
+-- for given, command in sortedhash(list) do
+-- command = command[interface] or command.en or given
+-- if command ~= given then
+-- n = n + 1
+-- t[n] = f(given,command)
+-- report_command("%-40s: %s",given,command)
+-- end
+-- nofcommands = nofcommands + 1
+-- end
+-- logs.stopfilelogging()
+-- contextsprint(prtcatcodes,"\\toksapp\\everydump{"..concat(t).."}")
+-- end
+-- do
+-- local list = complete.messages.formats
+-- logs.startfilelogging(report,"translated message formats")
+-- for given, format in sortedhash(list) do
+-- local found = format[interface] or format.en or given
+-- formats[given] = found
+-- nofformats = nofformats + 1
+-- report_messagetag("%-40s: %s",limit(given,38),limit(found,38))
+-- end
+-- logs.stopfilelogging()
+-- end
+-- do
+-- local list = complete.messages.translations
+-- logs.startfilelogging(report,"translated message tags")
+-- for given, translation in sortedhash(list) do
+-- local found = translation[interface] or translation.en or given
+-- translations[given] = found
+-- noftranslations = noftranslations + 1
+-- report_messagetag("%-40s: %s",given,found)
+-- end
+-- logs.stopfilelogging()
+-- end
+-- do
+-- local list = complete.setupstrings
+-- logs.startfilelogging(report,"translated setupstrings")
+-- for given, setupstring in sortedhash(list) do
+-- local found = setupstring[interface] or setupstring.en or given
+-- setupstrings[given] = found
+-- nofsetupstrings = nofsetupstrings + 1
+-- report_setupstring("%-40s: %s",given,found)
+-- end
+-- logs.stopfilelogging()
+-- end
+-- report_interface("definitions: %a constants, %a variables, %a elements, %a commands, %a formats, %a translations, %a setupstrings",
+-- nofconstants,nofvariables,nofelements,nofcommands,nofformats,noftranslations,nofsetupstrings)
+-- else
+-- report_interface("the language(s) can only be set when making the format")
+-- end
+-- interfaces.currentinterface = currentinterface
+-- interfaces.currentresponse = currentresponse
+-- end
+
+-- different per interface
+--
+-- en:
+--
+-- ui_c macro:#1#2 -> \immutable \gdefcsname \c!prefix! #1\endcsname {#1}
+-- ui_v macro:#1#2 -> \immutable \gdefcsname \v!prefix! #1\endcsname {#2}
+-- ui_e macro:#1#2 -> \immutable \gdefcsname \e!prefix! #1\endcsname {#2}
+-- ui_a macro:#1#2 -> \frozen \protected \def #2{#1}
+--
+-- otherwise:
+--
+-- ui_c macro:#1#2 -> \immutable \gdefcsname \c!prefix! #1\endcsname {#1}
+-- \immutable \gdefcsname \k!prefix! #2\endcsname {#1}
+
+function interfaces.setuserinterface(interface,response)
+ local variables = interfaces.variables
+ local constants = interfaces.constants
+ local elements = interfaces.elements
+ local formats = interfaces.formats
+ local translations = interfaces.translations
+ local setupstrings = interfaces.setupstrings
+ local complete = interfaces.complete
+ local sharedstorage = storage.shared
+ --
+ sharedstorage.currentinterface, currentinterface = interface, interface
+ sharedstorage.currentresponse, currentresponse = response, response
+ --
+ if environment.initex then
+ local nofconstants = 0
+ local nofvariables = 0
+ local nofelements = 0
+ local nofcommands = 0
+ local nofformats = 0
+ local noftranslations = 0
+ local nofsetupstrings = 0
+ local reversetoo = interface ~= "en"
+ --
+ do
+ local list = complete.constants -- forces the load
+ logs.startfilelogging(report,"translated constants")
+ for given, constant in sortedhash(list) do
+ constant = constant[interface] or constant.en or given
+ constants[constant] = given -- breedte -> width
+ nofconstants = nofconstants + 1
+ setmacro("c!" .. given,given,"immutable")
+ if reversetoo then
+ setmacro("k!" .. constant,given,"immutable")
+ end
+ report_constant("%-40s: %s",given,constant)
+ end
+ logs.stopfilelogging()
+ end
+ do
+ local list = complete.variables -- forces the load
+ logs.startfilelogging(report,"translated variables")
+ for given, variable in sortedhash(list) do
+ variable = variable[interface] or variable.en or given
+ variables[given] = variable -- ja -> yes
+ nofvariables = nofvariables + 1
+ setmacro("v!" .. given,variable,"immutable")
+ report_variable("%-40s: %s",given,variable)
+ end
+ logs.stopfilelogging()
+ end
+ do
+ local list = complete.elements -- forces the load
+ logs.startfilelogging(report,"translated elements")
+ for given, element in sortedhash(list) do
+ element = element[interface] or element.en or given
+ elements[element] = given
+ nofelements = nofelements + 1
+ setmacro("e!" .. given,element,"immutable")
+ report_element("%-40s: %s",given,element)
+ end
+ logs.stopfilelogging()
+ end
+-- do
+-- local list = complete.commands -- forces the load
+-- local todo = { } -- normally a small list
+-- logs.startfilelogging(report,"translated commands")
+-- for given, command in sortedhash(list) do
+-- command = command[interface] or command.en or given
+-- if command ~= given then
+-- report_command("%-40s: %s",given,command)
+-- todo[given] = command
+-- end
+-- nofcommands = nofcommands + 1
+-- end
+-- logs.stopfilelogging()
+-- -- For some reason we get corrupted definitions.
+-- luatex.registerdumpactions(function()
+-- for given, command in sortedhash(todo) do
+-- -- if definedmacro(given) then
+-- setmacro(command,"\\"..given,"frozen","protected","global")
+-- -- end
+-- end
+-- end)
+-- end
+ do
+ local list = complete.commands -- forces the load
+ local t = { }
+ local n = 0
+ local f = formatters["\\frozen\\protected\\def\\%s{\\%s}"] -- formatters["\\ui_m{%s}{%s}"]
+ logs.startfilelogging(report,"translated commands")
+ for given, command in sortedhash(list) do
+ command = command[interface] or command.en or given
+ if command ~= given then
+ n = n + 1
+ t[n] = f(command,given)
+ report_command("%-40s: %s",given,command)
+ end
+ nofcommands = nofcommands + 1
+ end
+ logs.stopfilelogging()
+ contextsprint(prtcatcodes,"\\toksapp\\everydump{"..concat(t).."}")
+ end
+ do
+ local list = complete.messages.formats
+ logs.startfilelogging(report,"translated message formats")
+ for given, format in sortedhash(list) do
+ local found = format[interface] or format.en or given
+ formats[given] = found
+ nofformats = nofformats + 1
+ report_messagetag("%-40s: %s",limit(given,38),limit(found,38))
+ end
+ logs.stopfilelogging()
+ end
+ do
+ local list = complete.messages.translations
+ logs.startfilelogging(report,"translated message tags")
+ for given, translation in sortedhash(list) do
+ local found = translation[interface] or translation.en or given
+ translations[given] = found
+ noftranslations = noftranslations + 1
+ report_messagetag("%-40s: %s",given,found)
+ end
+ logs.stopfilelogging()
+ end
+ do
+ local list = complete.setupstrings
+ logs.startfilelogging(report,"translated setupstrings")
+ for given, setupstring in sortedhash(list) do
+ local found = setupstring[interface] or setupstring.en or given
+ setupstrings[given] = found
+ nofsetupstrings = nofsetupstrings + 1
+ report_setupstring("%-40s: %s",given,found)
+ end
+ logs.stopfilelogging()
+ end
+ report_interface("definitions: %a constants, %a variables, %a elements, %a commands, %a formats, %a translations, %a setupstrings",
+ nofconstants,nofvariables,nofelements,nofcommands,nofformats,noftranslations,nofsetupstrings)
+ else
+ report_interface("the language(s) can only be set when making the format")
+ end
+ interfaces.currentinterface = currentinterface
+ interfaces.currentresponse = currentresponse
+end
+
+interfaces.implement {
+ name = "setuserinterface",
+ actions = interfaces.setuserinterface,
+ arguments = "2 strings",
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-fun.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-fun.lua
index 99700f47458..4ecbb1abdf4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-fun.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-fun.lua
@@ -2,7 +2,7 @@ return {
internals = {
--
"nocolormodel", "greycolormodel", "graycolormodel", "rgbcolormodel", "cmykcolormodel",
- "shadefactor",
+ "shadefactor", "shadeoffset",
"textextoffset", "textextanchor",
"normaltransparent", "multiplytransparent", "screentransparent", "overlaytransparent",
"softlighttransparent", "hardlighttransparent", "colordodgetransparent", "colorburntransparent",
@@ -17,7 +17,7 @@ return {
"drawoptionsfactor",
"dq", "sq",
"crossingscale", "crossingoption",
- "contextlmtxmode",
+ "contextlmtxmode", "metafunversion", "minifunversion",
--
-- for the moment we put these here as they need to stand out
--
@@ -74,6 +74,7 @@ return {
"withshadedomain", "withshademethod", "withshadefactor", "withshadevector",
"withshadecenter", "withshadedirection", "withshaderadius", "withshadetransform",
"withshadestep", "withshadefraction", "withshadeorigin", "shownshadevector", "shownshadeorigin",
+ "shownshadedirection", "shownshadecenter",
"cmyk", "spotcolor", "multitonecolor", "namedcolor",
"drawfill", "undrawfill",
"inverted", "uncolored", "softened", "grayed", "greyed",
@@ -85,11 +86,12 @@ return {
"withmask", "bitmapimage",
"colordecimals", "ddecimal", "dddecimal", "ddddecimal", "colordecimalslist",
"textext", "thetextext", "rawtextext", "textextoffset", "texbox", "thetexbox", "rawtexbox", "istextext",
+ "rawmadetext", "validtexbox", "onetimetextext", "rawfmttext", "thefmttext", "fmttext", "onetimefmttext",
"notcached", "keepcached",
"verbatim",
"thelabel", "label",
"autoalign",
- "transparent", "withtransparency",
+ "transparent", "withtransparency", "withopacity",
"property", "properties", "withproperties",
"asgroup",
"infont", -- redefined using textext
@@ -174,6 +176,7 @@ return {
"isarray", "prefix", "dimension",
"getmacro", "getdimen", "getcount", "gettoks",
"setmacro", "setdimen", "setcount", "settoks",
+ "setglobalmacro", "setglobaldimen", "setglobalcount", "setglobaltoks",
--
"positionpath", "positioncurve", "positionxy", "positionpxy",
"positionwhd", "positionpage", "positionregion", "positionbox",
@@ -185,16 +188,21 @@ return {
--
"inpath", "pointof", "leftof", "rightof",
--
- "utflen", "utfsub",
+ "utfnum", "utflen", "utfsub",
--
"newhash", "disposehash", "inhash", "tohash",
--
"isarray", "prefix", "isobject",
--
- "comment", "report", "lua", "mp", "MP", "luacall",
+ "comment", "report", "lua", "lualist", "mp", "MP", "luacall",
--
"mirrored", "mirroredabout",
--
- "scriptindex",
+ "scriptindex", "newscriptindex",
+ --
+ "newcolor", "newrgbcolor", "newcmykcolor",
+ "newnumeric", "newboolean", "newtransform", "newpath", "newpicture", "newstring", "newpair",
+
+ "mpvar",
},
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua
index 0c8581281d1..eb758fcbf07 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua
@@ -233,138 +233,6 @@ end
logs.setmessenger(context.verbatim.ctxreport)
--- todo: use setmacro
-
-function interfaces.setuserinterface(interface,response)
- sharedstorage.currentinterface, currentinterface = interface, interface
- sharedstorage.currentresponse, currentresponse = response, response
- if environment.initex then
- local setmacro = false
- -- local setmacro = interfaces.setmacro -- cleaner (but we need to test first)
- local nofconstants = 0
- local nofvariables = 0
- local nofelements = 0
- local nofcommands = 0
- local nofformats = 0
- local noftranslations = 0
- local nofsetupstrings = 0
- --
- if setmacro then
- for given, constant in next, complete.constants do
- constant = constant[interface] or constant.en or given
- constants[constant] = given -- breedte -> width
- nofconstants = nofconstants + 1
- setmacro("c!"..given,given)
- if currentinterface ~= "en" then
- setmacro("k!"..constant,given)
- end
- end
- else
- local t, f, s = { }, formatters["\\ui_c{%s}{%s}"], formatters["\\ui_s{%s}"]
- for given, constant in next, complete.constants do
- constant = constant[interface] or constant.en or given
- constants[constant] = given -- breedte -> width
- nofconstants = nofconstants + 1
- if given == constant then
- t[nofconstants] = s(given)
- else
- t[nofconstants] = f(given,constant)
- end
- end
- contextsprint(prtcatcodes,concat(t))
- end
- --
- if setmacro then
- for given, variable in next, complete.variables do
- variable = variable[interface] or variable.en or given
- variables[given] = variable -- ja -> yes
- nofvariables = nofvariables + 1
- setmacro("v!"..given,variable)
- end
- else
- local t, f = { }, formatters["\\ui_v{%s}{%s}"]
- for given, variable in next, complete.variables do
- variable = variable[interface] or variable.en or given
- variables[given] = variable -- ja -> yes
- nofvariables = nofvariables + 1
- t[nofvariables] = f(given,variable)
- end
- contextsprint(prtcatcodes,concat(t))
- end
- --
- if setmacro then
- for given, element in next, complete.elements do
- element = element[interface] or element.en or given
- elements[element] = given
- nofelements = nofelements + 1
- setmacro("e!"..given,element)
- end
- else
- local t, f = { }, formatters["\\ui_e{%s}{%s}"]
- for given, element in next, complete.elements do
- element = element[interface] or element.en or given
- elements[element] = given
- nofelements = nofelements + 1
- t[nofelements] = f(given,element)
- end
- contextsprint(prtcatcodes,concat(t))
- end
- --
- if setmacro then
- -- this can only work ok when we already have defined the command
- luatex.registerdumpactions(function()
- for given, command in next, complete.commands do
- command = command[interface] or command.en or given
- if command ~= given then
- setmacro(prtcatcodes,given,"\\"..command)
- end
- nofcommands = nofcommands + 1
- end
- end)
- else
- local t, n, f = { }, 0, formatters["\\ui_m{%s}{%s}"]
- for given, command in next, complete.commands do
- command = command[interface] or command.en or given
- if command ~= given then
- n = n + 1
- t[n] = f(given,command)
- end
- nofcommands = nofcommands + 1
- end
- contextsprint(prtcatcodes,concat(t))
- end
- --
- for given, format in next, complete.messages.formats do
- formats[given] = format[interface] or format.en or given
- nofformats = nofformats + 1
- end
- --
- for given, translation in next, complete.messages.translations do
- translations[given] = translation[interface] or translation.en or given
- noftranslations = noftranslations + 1
- end
- --
- for given, setupstring in next, complete.setupstrings do
- setupstring = setupstring[interface] or setupstring.en or given
- setupstrings[given] = setupstring
- nofsetupstrings = nofsetupstrings + 1
- end
- --
- report_interface("definitions: %a constants, %a variables, %a elements, %a commands, %a formats, %a translations, %a setupstrings",
- nofconstants,nofvariables,nofelements,nofcommands,nofformats,noftranslations,nofsetupstrings)
- else
- report_interface("the language(s) can only be set when making the format")
- end
- interfaces.currentinterface = currentinterface
- interfaces.currentresponse = currentresponse
-end
-
-interfaces.implement {
- name = "setuserinterface",
- actions = interfaces.setuserinterface,
- arguments = "2 strings",
-}
-
interfaces.cachedsetups = interfaces.cachedsetups or { }
interfaces.hashedsetups = interfaces.hashedsetups or { }
@@ -437,10 +305,10 @@ implement {
}
local function gss(s)
- contextsprint(vrbcatcodes,getsetupstring(s))
- end
+ contextsprint(vrbcatcodes,getsetupstring(s))
+end
-implement { -- will b eoverloaded
+implement { -- will be overloaded
name = "getsetupstring",
actions = gss,
arguments = "string",
@@ -454,16 +322,18 @@ implement {
local function showassignerror(namespace,key,line)
- local ns, instance = match(namespace,"^(%d+)[^%a]+(%a*)")
- if ns then
- namespace = corenamespaces[tonumber(ns)] or ns
- end
- -- injected in the stream for timing:
- if instance and instance ~= "" then
- context.writestatus("setup",formatters["error in line %a, namespace %a, instance %a, key %a"](line,namespace,instance,key))
- else
- context.writestatus("setup",formatters["error in line %a, namespace %a, key %a"](line,namespace,key))
- end
+ -- if key and key ~= "" and key ~= "," then
+ local ns, instance = match(namespace,"^(%d+)[^%a]+(%a*)")
+ if ns then
+ namespace = corenamespaces[tonumber(ns)] or ns
+ end
+ -- injected in the stream for timing:
+ if instance and instance ~= "" then
+ context.writestatus("setup",formatters["error in line %a, namespace %a, instance %a, key %a"](line,namespace,instance,key))
+ else
+ context.writestatus("setup",formatters["error in line %a, namespace %a, key %a"](line,namespace,key))
+ end
+ -- end
end
implement {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv
index 641c8a4f50e..75fa5c7bfa4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv
@@ -20,6 +20,7 @@
\unprotect
\registerctxluafile{mult-ini}{}
+\registerctxluafile{mult-fmt}{initexonly}
%D \macros
%D [constanten,variabelen,commands]
@@ -59,6 +60,7 @@
\def\m!prefix!{m!}
\def\s!prefix!{s!}
\def\v!prefix!{v!}
+\def\t!prefix!{t!}
%D \macros
%D [constants,variables,commands]
@@ -105,33 +107,35 @@
%D than once. Savings like this should of course be implemented in english, just
%D because \TEX\ is english.
-\def\s!width {width} \let\!!width \s!width % obsolete
-\def\s!height{height} \let\!!height\s!height % obsolete
-\def\s!depth {depth} \let\!!depth \s!depth % obsolete
-\def\s!spread{spread} \let\!!spread\s!spread % obsolete
-\def\s!plus {plus} \let\!!plus \s!plus % obsolete
-\def\s!minus {minus} \let\!!minus \s!minus % obsolete
-\def\s!left {left}
-\def\s!right {right}
-\def\s!fil {fil}
-\def\s!fill {fill} \let\!!fill \s!fill % obsolete
-\def\s!filll {filll}
-\def\s!to {to} \let\!!to \s!to % obsolete
-\def\s!attr {attr}
-\def\s!axis {axis}
-
-\def\s!bottom{bottom}
-\def\s!top {top}
-\def\s!both {both}
-
-\def\s!reverse {reverse}
+\def\s!width {width}
+\def\s!height {height}
+\def\s!depth {depth}
+\def\s!spread {spread}
+\def\s!plus {plus}
+\def\s!minus {minus}
+\def\s!to {to}
+
+\def\s!fil {fil}
+\def\s!fill {fill}
+\def\s!filll {filll}
+
+\def\s!attr {attr}
+\def\s!axis {axis}
+\def\s!both {both}
+\def\s!bottom {bottom}
+\def\s!left {left}
+\def\s!options {options}
\def\s!orientation{orientation}
-\def\s!xoffset {xoffset}
+\def\s!reverse {reverse}
+\def\s!right {right}
+\def\s!top {top}
\def\s!xmove {xmove}
-\def\s!yoffset {yoffset}
+\def\s!xoffset {xoffset}
\def\s!ymove {ymove}
+\def\s!yoffset {yoffset}
%D \macros
+
%D {defineinterfaceconstant,
%D defineinterfacevariable,
%D defineinterfaceelement,
@@ -165,9 +169,9 @@
%D \def\e!name{meaning}
%D \stoptyping
-\unexpanded\def\defineinterfaceconstant #1#2{\expandafter\def\csname\c!prefix!#1\endcsname{#2}}
-\unexpanded\def\defineinterfacevariable #1#2{\expandafter\def\csname\v!prefix!#1\endcsname{#2}}
-\unexpanded\def\defineinterfaceelement #1#2{\expandafter\def\csname\e!prefix!#1\endcsname{#2}}
+\protected\def\defineinterfaceconstant#1#2{\expandafter\def\csname\c!prefix!#1\endcsname{#2}}
+\protected\def\defineinterfacevariable#1#2{\expandafter\def\csname\v!prefix!#1\endcsname{#2}}
+\protected\def\defineinterfaceelement #1#2{\expandafter\def\csname\e!prefix!#1\endcsname{#2}}
%D Next come some interface independant constants:
%D
@@ -175,7 +179,7 @@
%D \definefileconstant {name} {meaning}
%D \stoptyping
-\unexpanded\def\definefileconstant #1#2{\expandafter\def\csname\f!prefix!#1\endcsname{#2}}
+\protected\def\definefileconstant#1#2{\expandafter\def\csname\f!prefix!#1\endcsname{#2}}
%D And finaly we have the one argument, space saving constants
%D
@@ -184,8 +188,13 @@
%D \definemessageconstant {name}
%D \stoptyping
-\unexpanded\def\definesystemconstant #1{\expandafter\def\csname\s!prefix!#1\endcsname{#1}}
-\unexpanded\def\definemessageconstant #1{\expandafter\def\csname\m!prefix!#1\endcsname{#1}}
+\protected\def\definesystemconstant #1{\expandafter\def\csname\s!prefix!#1\endcsname{#1}}
+\protected\def\definemessageconstant#1{\expandafter\def\csname\m!prefix!#1\endcsname{#1}}
+
+%D For now here:
+
+\protected\def\definetagconstant #1{\expandafter\def\csname\t!prefix!#1\endcsname{#1}}
+\protected\def\aliastagconstant #1#2{\expandafter\let\csname\t!prefix!#1\expandafter\endcsname\csname\t!prefix!#2\endcsname}
%D In a parameter driven system, some parameters are shared by more system
%D components. In \CONTEXT\ we can distinguish parameters by a unique prefix. Such a
@@ -195,7 +204,7 @@
%D \definesystemvariable {name}
%D \stoptyping
-\unexpanded\def\definesystemvariable#1{\expandafter\edef\csname\??prefix#1\endcsname{\@@prefix#1}}
+\protected\def\definesystemvariable#1{\expandafter\edef\csname\??prefix#1\endcsname{\@@prefix#1}}
\definesystemvariable{ms}
@@ -260,7 +269,7 @@
%D \stopinterface
%D \stoptyping
-\unexpanded\def\startinterface #1
+\protected\def\startinterface #1
{\doifnot{#1}{all}{\doifnotinset\currentinterface{#1}{\gobbleuntil\stopinterface}}}
\let\stopinterface\relax
@@ -344,7 +353,7 @@
%D
%D These will become obsolete:
-\unexpanded\def\startmessages #1 library: #2 %
+\protected\def\startmessages #1 library: #2 %
{\begingroup
\ifcsname\m!prefix!#2\endcsname\else\setgvalue{\m!prefix!#2}{#2}\fi
\catcode\endoflineasciicode\othercatcode
@@ -359,21 +368,21 @@
\let\stopmessages\relax
-\unexpanded\def\setinterfacemessage#1#2#3%
+\protected\def\setinterfacemessage#1#2#3%
{\ifcsname\m!prefix!#1\endcsname\else\setgvalue{\m!prefix!#1}{#1}\fi
\clf_setinterfacemessage{#1}{#2}{#3}}
-\unexpanded\def\setmessagetext #1#2{\relax\edef\currentmessagetext{\clf_getmessage{#1}{#2}}}
-\unexpanded\def\getmessage #1#2{\relax\clf_getmessage{#1}{#2}}
-\unexpanded\def\doifelsemessage #1#2{\relax\clf_doifelsemessage{#1}{#2}}
-\unexpanded\def\showmessage #1#2#3{\relax\clf_showmessage{#1}{#2}{#3}}
-\unexpanded\def\writestatus #1#2{\relax\clf_writestatus{#1}{#2}}
-\unexpanded\def\message {\relax\clf_message}
+\protected\def\setmessagetext #1#2{\relax\edef\currentmessagetext{\clf_getmessage{#1}{#2}}}
+\protected\def\getmessage #1#2{\relax\clf_getmessage{#1}{#2}}
+\protected\def\doifelsemessage #1#2{\relax\clf_doifelsemessage{#1}{#2}}
+\protected\def\showmessage #1#2#3{\relax\clf_showmessage{#1}{#2}{#3}}
+\protected\def\writestatus #1#2{\relax\clf_writestatus{#1}{#2}}
+\protected\def\message {\relax\clf_message}
\let\doifmessageelse\doifelsemessage
-\unexpanded\def\inlinemessage #1{\dontleavehmode{\tttf#1}}
-\unexpanded\def\displaymessage#1{\blank\inlinemessage{#1}\blank}
+\protected\def\inlinemessage #1{\dontleavehmode{\tttf#1}}
+\protected\def\displaymessage#1{\blank\inlinemessage{#1}\blank}
\let\getsetupstring\clf_getsetupstring
\let\rawsetupstring\clf_rawsetupstring
@@ -392,15 +401,15 @@
%D backmapping (\type{\c!k...}) and make \type {\c!c...} similar to \type {\v!...}.
%D In that case we can simply the following setters.
-\unexpanded\def\doletvalue #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-\unexpanded\def\dosetvalue #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-\unexpanded\def\dosetevalue #1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-\unexpanded\def\dosetgvalue #1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-\unexpanded\def\dosetxvalue #1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
-\unexpanded\def\doresetvalue #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
-\unexpanded\def\doignorevalue#1#2#3{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
+\protected\def\doletvalue #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\protected\def\dosetvalue #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\protected\def\dosetevalue #1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\protected\def\dosetgvalue #1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\protected\def\dosetxvalue #1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\protected\def\doresetvalue #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
+\protected\def\doignorevalue#1#2#3{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
-\unexpanded\def\docopyvalue#1#2#3%
+\protected\def\docopyvalue#1#2#3%
{\ifcsname\k!prefix!#3\endcsname
\expandafter\def\csname#1\csname\k!prefix!#3\endcsname\expandafter\endcsname\expandafter
{\csname#2\csname\k!prefix!#3\endcsname\endcsname}%
@@ -411,15 +420,15 @@
\startinterface english
- \unexpanded\def\doletvalue #1#2{\expandafter \let\csname#1#2\endcsname}
- \unexpanded\def\dosetvalue #1#2{\expandafter \def\csname#1#2\endcsname}
- \unexpanded\def\dosetevalue #1#2{\expandafter\edef\csname#1#2\endcsname}
- \unexpanded\def\dosetgvalue #1#2{\expandafter\gdef\csname#1#2\endcsname}
- \unexpanded\def\dosetxvalue #1#2{\expandafter\xdef\csname#1#2\endcsname}
- \unexpanded\def\doresetvalue #1#2{\expandafter \let\csname#1#2\endcsname\empty}
- \unexpanded\def\doignorevalue#1#2#3{\expandafter \let\csname#1#2\endcsname\empty}
+ \protected\def\doletvalue #1#2{\expandafter \let\csname#1#2\endcsname}
+ \protected\def\dosetvalue #1#2{\expandafter \def\csname#1#2\endcsname}
+ \protected\def\dosetevalue #1#2{\expandafter\edef\csname#1#2\endcsname}
+ \protected\def\dosetgvalue #1#2{\expandafter\gdef\csname#1#2\endcsname}
+ \protected\def\dosetxvalue #1#2{\expandafter\xdef\csname#1#2\endcsname}
+ \protected\def\doresetvalue #1#2{\expandafter \let\csname#1#2\endcsname\empty}
+ \protected\def\doignorevalue#1#2#3{\expandafter \let\csname#1#2\endcsname\empty}
- \unexpanded\def\docopyvalue#1#2#3%
+ \protected\def\docopyvalue#1#2#3%
{\expandafter\def\csname#1#3\expandafter\endcsname\expandafter
{\csname#2#3\endcsname}}
@@ -428,9 +437,9 @@
%D We can now redefine some messages that will be introduced in the multi||lingual
%D system module.
-\unexpanded\def\showassignerror #1#2{\showmessage\m!check1{#1,#2}}
-\unexpanded\def\showargumenterror#1#2{\showmessage\m!check2{#1,#2}}
-\unexpanded\def\showdefinederror #1#2{\showmessage\m!check3{#1,#2}}
+\protected\def\showassignerror #1#2{\showmessage\m!check1{#1,#2}}
+\protected\def\showargumenterror#1#2{\showmessage\m!check2{#1,#2}}
+\protected\def\showdefinederror #1#2{\showmessage\m!check3{#1,#2}}
%D \CONTEXT\ is a parameter driven package. This means that users instruct the
%D system by means of variables, values and keywords. These instructions take the
@@ -598,7 +607,7 @@
%D simple setup command:
%D
%D \starttyping
-%D \unexpanded\def\setupbox[#1]%
+%D \protected\def\setupbox[#1]%
%D {\getparameters[\??bx][#1]}
%D \stoptyping
%D
@@ -667,11 +676,11 @@
% temporary mkiv hack (we can best just store the whole table in memory)
-\unexpanded\def\setinterfaceconstant#1#2%
+\protected\def\setinterfaceconstant#1#2%
{\clf_setinterfaceconstant{#1}{#2}%
\expandafter\def\csname\c!prefix!#1\endcsname{#1}}
-\unexpanded\def\setinterfacevariable#1#2%
+\protected\def\setinterfacevariable#1#2%
{\clf_setinterfacevariable{#1}{#2}%
\expandafter\def\csname\v!prefix!#1\endcsname{#2}}
@@ -682,7 +691,7 @@
%D too. It's a bit redundant, because in these situations we could use the
%D c||version, but for documentation purposes the x||alternative comes in handy.
-\unexpanded\def\defineinterfaceconstant#1#2%
+\protected\def\defineinterfaceconstant#1#2%
{\expandafter\def\csname\c!prefix!#1\endcsname{#2}}
%D \macros
@@ -697,7 +706,7 @@
%D {\stelin}. Such split elements are no problem, because we just define two
%D elements. When no second part is needed, we use a \type {-}:
-\unexpanded\def\setinterfaceelement#1#2%
+\protected\def\setinterfaceelement#1#2%
{\clf_setinterfaceelement{#1}{#2}%
\ifcsname\e!prefix!#1\endcsname
\doifnotvalue{\e!prefix!#1}{#2}{\setvalue{\e!prefix!#1}{#2}}%
@@ -705,38 +714,27 @@
\setvalue{\e!prefix!#1}{#2}%
\fi}
-\unexpanded\def\setinterfacecommand#1#2%
+\protected\def\setinterfacecommand#1#2%
{\doifnot{#1}{#2}% todo: let when already defined
{\expandafter\def\csname#2\expandafter\endcsname\expandafter{\csname#1\endcsname}}}
%D We just ignore these:
-\unexpanded\def\startvariables{\gobbleuntil\stopvariables} \let\stopvariables\relax
-\unexpanded\def\startconstants{\gobbleuntil\stopconstants} \let\stopconstants\relax
-\unexpanded\def\startelements {\gobbleuntil\stopelements } \let\stopelements \relax
-\unexpanded\def\startcommands {\gobbleuntil\stopcommands } \let\stopcommands \relax
+\protected\def\startvariables{\gobbleuntil\stopvariables} \let\stopvariables\relax
+\protected\def\startconstants{\gobbleuntil\stopconstants} \let\stopconstants\relax
+\protected\def\startelements {\gobbleuntil\stopelements } \let\stopelements \relax
+\protected\def\startcommands {\gobbleuntil\stopcommands } \let\stopcommands \relax
%D For at the \LUA\ end (experiment):
-% \def\do@sicon#1#2{\expandafter\gdef\csname\c!prefix!#1\endcsname{#1}%
-% \expandafter\gdef\csname\k!prefix!#2\endcsname{#1}} % backmapping from non english
-% \def\do@sivar#1#2{\expandafter\gdef\csname\v!prefix!#1\endcsname{#2}}
-% \def\do@siele#1#2{\expandafter\gdef\csname\e!prefix!#1\endcsname{#2}}
-% \def\do@sicom#1#2{\expandafter\gdef\csname#2\expandafter\endcsname\expandafter{\csname#1\endcsname}}
-%
-% \startinterface english
-%
-% \def\do@sicon#1#2{\expandafter\gdef\csname\c!prefix!#1\endcsname{#1}}
-%
-% \stopinterface
-
\def\ui_c#1#2{\expandafter\gdef\csname\c!prefix!#1\endcsname{#1}%
\expandafter\gdef\csname\k!prefix!#2\endcsname{#1}} % backmapping from non english
\def\ui_s #1{\expandafter\gdef\csname\c!prefix!#1\endcsname{#1}%
\expandafter\gdef\csname\k!prefix!#1\endcsname{#1}} % backmapping from non english
\def\ui_v#1#2{\expandafter\gdef\csname\v!prefix!#1\endcsname{#2}}
\def\ui_e#1#2{\expandafter\gdef\csname\e!prefix!#1\endcsname{#2}}
-\def\ui_m#1#2{\expandafter\gdef\csname#2\expandafter\endcsname\expandafter{\csname#1\endcsname}}
+%def\ui_m#1#2{\expandafter\gdef\csname#2\expandafter\endcsname\expandafter{\csname#1\endcsname}}
+\def\ui_a#1#2{\aliasmacro#2#1}
\startinterface english
@@ -760,11 +758,11 @@
\def\contextbanner
{ConTeXt \space
- ver: \contextversion \space \contextmark \space \contextkind \space \space
+ ver: \contextversion \space \contextmark \space \space
fmt: \formatversion \space \space
int: \currentinterface/\currentresponses}
-\unexpanded\def\showcontextbanner
+\protected\def\showcontextbanner
{\writestatus\m!system\empty
\writestatus\m!system\contextbanner
\writestatus\m!system\empty}
@@ -781,9 +779,9 @@
% \def\contextversionnumber#1.#2.#3 #4:#5\relax{#1\ifnum#2<10 0\fi\purenumber{#2}\ifnum#3<10 0\fi\purenumber{#3} #4:#5}
% \edef\contextversionnumber{\expandafter\contextversionnumber\contextversion\relax\space\contextmark}
-\unexpanded\def \contextversionnumber #1.#2.#3 #4:#5\relax{#1#2#3}
- \contextversionno \expandafter\contextversionnumber\contextversion\relax
- \edef \contextversionnumber {\the\contextversionno\space\contextmark}
+\protected\def \contextversionnumber #1.#2.#3 #4:#5\relax{#1#2#3}
+ \contextversionno \expandafter\contextversionnumber\contextversion\relax
+ \edef \contextversionnumber {\the\contextversionno\space\contextmark}
%D \macros
%D {everydump}
@@ -792,7 +790,7 @@
\ifx\undefined\everydump
\newtoks\everydump
- \def\dump{\the\everydump\normaldump}
+ \def\dump{\the\everydump\global\everydump\emptytoks\glet\dump\relax\normaldump}
\fi
% \appendtoks \showcontextbanner \to \everydump
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua
index aa0329e48cf..a893d455c1f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua
@@ -12,7 +12,7 @@ return {
["constants"] = {
--
"zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive",
- "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen",
+ "plussix", "plusseven", "pluseight", "plusnine", "plusten", "pluseleven", "plustwelve", "plussixteen",
"plusfifty", "plushundred", "plusonehundred", "plustwohundred", "plusfivehundred",
"plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "maxcardminusone",
"zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxcount", "maxdimen", "scaledpoint", "thousandpoint",
@@ -34,7 +34,7 @@ return {
--
"fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "texenginefunctionality",
"luatexengine", "pdftexengine", "xetexengine", "unknownengine",
- "contextformat", "contextversion", "contextkind", "contextlmtxmode", "contextmark", "mksuffix",
+ "contextformat", "contextversion", "contextlmtxmode", "contextmark", "mksuffix",
--
"activecatcode",
--
@@ -45,26 +45,36 @@ return {
--
"attributeunsetvalue",
--
+ "statuswrite",
+ --
"uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle",
--
"inicatcodes",
"ctxcatcodes", "texcatcodes", "notcatcodes", "txtcatcodes", "vrbcatcodes",
"prtcatcodes", "nilcatcodes", "luacatcodes", "tpacatcodes", "tpbcatcodes",
- "xmlcatcodes", "ctdcatcodes",
+ "xmlcatcodes", "ctdcatcodes", "rlncatcodes",
--
"escapecatcode", "begingroupcatcode", "endgroupcatcode", "mathshiftcatcode", "alignmentcatcode",
"endoflinecatcode", "parametercatcode", "superscriptcatcode", "subscriptcatcode", "ignorecatcode",
"spacecatcode", "lettercatcode", "othercatcode", "activecatcode", "commentcatcode", "invalidcatcode",
--
"tabasciicode", "newlineasciicode", "formfeedasciicode", "endoflineasciicode", "endoffileasciicode",
- "spaceasciicode", "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode",
+ "commaasciicode", "spaceasciicode", "periodasciicode",
+ "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode",
"colonasciicode", "backslashasciicode", "circumflexasciicode", "underscoreasciicode",
"leftbraceasciicode", "barasciicode", "rightbraceasciicode", "tildeasciicode", "delasciicode",
"leftparentasciicode", "rightparentasciicode",
"lessthanasciicode", "morethanasciicode", "doublecommentsignal",
"atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode",
"doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode",
- "primeasciicode", "hyphenasciicode",
+ "primeasciicode", "hyphenasciicode", "percentasciicode", "leftbracketasciicode", "rightbracketasciicode",
+ --
+ "frozenhsizecode", "frozenskipcode", "frozenhangcode", "frozenindentcode", "frozenparfillcode",
+ "frozenadjustcode", "frozenprotrudecode", "frozentolerancecode", "frozenstretchcode",
+ "frozenloosenesscode", "frozenlastlinecode", "frozenlinepenaltycode", "frozenclubpenaltycode",
+ "frozenwidowpenaltycode", "frozendisplaypenaltycode", "frozenbrokenpenaltycode",
+ "frozendemeritscode", "frozenshapecode", "frozenlinecode", "frozenhyphenationcode",
+ "frozenallcode",
--
"activemathcharcode",
--
@@ -74,8 +84,10 @@ return {
--
"bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode",
"vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode",
- "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode",
- "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode",
+ "discretionarygroupcode", "insertgroupcode", "vadjustgroupcode", "vcentergroupcode", "mathabovegroupcode",
+ "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode",
+ "localboxgroupcode", "splitoffgroupcode", "splitkeepgroupcode", "preamblegroupcode",
+ "alignsetgroupcode", "finrowgroupcode", "discretionarygroupcode",
--
"charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode",
"adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode",
@@ -89,7 +101,7 @@ return {
"fontexheight", "fontemwidth", "fontextraspace", "slantperpoint",
"mathexheight", "mathemwidth",
"interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace",
- "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight",
+ "mathaxisheight",
"muquad",
--
-- maybe a different class
@@ -145,6 +157,23 @@ return {
"startlmtxmode", "stoplmtxmode", "startmkivmode", "stopmkivmode",
--
"wildcardsymbol",
+ --
+ "normalhyphenationmodecode", "automatichyphenationmodecode", "explicithyphenationmodecode",
+ "syllablehyphenationmodecode", "uppercasehyphenationmodecode", "completehyphenationmodecode",
+ "compoundhyphenationmodecode", "strictstarthyphenationmodecode", "strictendhyphenationmodecode",
+ "automaticpenaltyhyphenationmodecode", "explicitpenaltyhyphenationmodecode",
+ "permitgluehyphenationmodecode", "permitallhyphenationmodecode", "permitmathreplacehyphenationmodecode",
+ "forcecheckhyphenationmodecode", "lazyligatureshyphenationmodecode",
+ --
+ "normalizelinecode", "parindentskipcode", "swaphangindentcode", "swapparsshapecode", "breakafterdircode", "removemarginkernscode", "clipwidthcode",
+ --
+ "noligaturingcode", "nokerningcode", "noleftligaturecode", "noleftkerncode", "norightligaturecode", "norightkerncode",
+ "noexpansioncode", "noprotrusioncode",
+ --
+ "frozenflagcode", "tolerantflagcode", "protectedflagcode", "primitiveflagcode", "permanentflagcode", "noalignedflagcode", "immutableflagcode", "mutableflagcode",
+ "globalflagcode", "overloadedflagcode", "immediateflagcode", "conditionalflagcode", "valueflagcode", "instanceflagcode",
+ --
+ "continuewhenlmtxmode"
},
["helpers"] = {
--
@@ -179,6 +208,7 @@ return {
--
"strippedcsname","checkedstrippedcsname",
--
+ "nofarguments",
"firstargumentfalse", "firstargumenttrue",
"secondargumentfalse", "secondargumenttrue",
"thirdargumentfalse", "thirdargumenttrue",
@@ -187,7 +217,7 @@ return {
"sixthargumentfalse", "sixthargumenttrue",
"seventhargumentfalse", "seventhargumenttrue",
--
- "vkern", "hkern",
+ "vkern", "hkern", "vpenalty", "hpenalty",
--
"doglobal", "dodoglobal", "redoglobal", "resetglobal",
--
@@ -199,6 +229,7 @@ return {
--
"mathortext",
--
+ "thebox",
"htdp",
"unvoidbox",
"hfilll", "vfilll",
@@ -222,12 +253,18 @@ return {
--
"filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk",
--
+ "scratchstring", "scratchstringone", "scratchstringtwo", "tempstring",
"scratchcounter", "globalscratchcounter", "privatescratchcounter",
"scratchdimen", "globalscratchdimen", "privatescratchdimen",
"scratchskip", "globalscratchskip", "privatescratchskip",
"scratchmuskip", "globalscratchmuskip", "privatescratchmuskip",
"scratchtoks", "globalscratchtoks", "privatescratchtoks",
"scratchbox", "globalscratchbox", "privatescratchbox",
+ "scratchmacro", "scratchmacroone", "scratchmacrotwo",
+ --
+ "scratchconditiontrue", "scratchconditionfalse", "ifscratchcondition",
+ "scratchconditiononetrue", "scratchconditiononefalse", "ifscratchconditionone",
+ "scratchconditiontwotrue", "scratchconditiontwofalse", "ifscratchconditiontwo",
--
"globalscratchcounterone", "globalscratchcountertwo", "globalscratchcounterthree",
--
@@ -235,14 +272,14 @@ return {
"triggergroupedcommand", "triggergroupedcommandcs",
"simplegroupedcommand", "pickupgroupedcommand",
--
- "normalbaselineskip", "normallineskip", "normallineskiplimit",
+ "usedbaselineskip", "usedlineskip", "usedlineskiplimit",
--
"availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction",
--
"next", "nexttoken",
--
"nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "flushnextbox",
- "boxisempty",
+ "boxisempty", "boxtostring", "contentostring", "prerolltostring",
--
"givenwidth", "givenheight", "givendepth", "scangivendimensions",
--
@@ -297,12 +334,18 @@ return {
"quitcondition", "truecondition", "falsecondition",
--
"tracingall", "tracingnone", "loggingall",
+ "showluatokens",
+ --
+ "aliasmacro",
--
"removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to",
--
- "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "crlf",
- "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage",
- "normalspace",
+ -- "everyendpar",
+ --
+ "endgraf", "endpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "crlf",
+ "obeyspaces", "obeylines", "obeytabs", "obeypages", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage",
+ "normalspace", "naturalspace", "controlspace", "normalspaces",
+ "ignoretabs", "ignorelines", "ignorepages", "ignoreeofs", "setcontrolspaces",
--
"executeifdefined",
--
@@ -324,8 +367,8 @@ return {
"getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue",
"resetvalue", "undefinevalue", "ignorevalue",
"setuvalue", "setuevalue", "setugvalue", "setuxvalue",
- --
- "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique",
+ -- glet
+ "globallet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique",
--
"getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters",
--
@@ -335,7 +378,7 @@ return {
"processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist",
"processaction", "processallactions", "processfirstactioninset", "processallactionsinset",
--
- "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect",
+ "unexpanded", "expanded", "startexpanded", "stopexpanded", "protect", "unprotect",
--
"firstofoneargument",
"firstoftwoarguments", "secondoftwoarguments",
@@ -352,9 +395,10 @@ return {
"gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals",
--
"dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "fastloopindex", "fastloopfinal", "dowith",
+ "doloopovermatch", "doloopovermatched", "doloopoverlist",
--
"newconstant", "setnewconstant", "setconstant", "setconstantvalue",
- "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue",
+ "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "setconditional",
--
"newmacro", "setnewmacro", "newfraction",
"newsignal",
@@ -413,8 +457,11 @@ return {
"startdmath", "stopdmath", "normalstartdmath", "normalstopdmath",
"normalsuperscript", "normalsubscript", "normalnosuperscript", "normalnosubscript",
"superscript", "subscript", "nosuperscript", "nosubscript",
+ "superprescript", "subprescript", "nosuperprescript", "nosubsprecript",
--
- "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette",
+ "uncramped", "cramped",
+ "mathstyletrigger", "triggermathstyle",
+ "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette",
"mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox",
"mathtext", "setmathsmalltextbox", "setmathtextbox",
"pushmathstyle", "popmathstyle",
@@ -433,7 +480,7 @@ return {
"ctxlua", "luacode", "lateluacode", "directluacode",
"registerctxluafile", "ctxloadluafile",
"luaversion", "luamajorversion", "luaminorversion",
- "ctxluacode", "luaconditional", "luaexpanded",
+ "ctxluacode", "luaconditional", "luaexpanded", "ctxluamatch",
"startluaparameterset", "stopluaparameterset", "luaparameterset",
"definenamedlua",
"obeylualines", "obeyluatokens",
@@ -444,11 +491,15 @@ return {
"cldprocessfile", "cldloadfile", "cldloadviafile", "cldcontext", "cldcommand",
--
"carryoverpar",
+ "freezeparagraphproperties", "defrostparagraphproperties",
+ "setparagraphfreezing", "forgetparagraphfreezing",
+ "updateparagraphproperties", "updateparagraphpenalties", "updateparagraphdemerits", "updateparagraphshapes", "updateparagraphlines",
+ --
"lastlinewidth",
--
"assumelongusagecs",
--
- "Umathbotaccent",
+ "Umathbotaccent", "Umathtopaccent",
--
"righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop",
"rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop",
@@ -459,6 +510,7 @@ return {
"dirlre", "dirrle", "dirlro", "dirrlo",
--
"lesshyphens", "morehyphens", "nohyphens", "dohyphens",
+ "compounddiscretionary",
--
"Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath",
--
@@ -469,6 +521,8 @@ return {
"naturalhbox", "naturalvbox", "naturalvtop", "naturalhpack", "naturalvpack", "naturaltpack",
"reversehbox", "reversevbox", "reversevtop", "reversehpack", "reversevpack", "reversetpack",
--
+ "hcontainer", "vcontainer", "tcontainer",
+ --
"frule",
--
"compoundhyphenpenalty",
@@ -476,5 +530,34 @@ return {
"start", "stop",
--
"unsupportedcs",
+ --
+ "openout", "closeout", "write", "openin", "closein", "read", "readline", "readfromterminal",
+ --
+ "boxlines", "boxline", "setboxline", "copyboxline",
+ "boxlinewd","boxlineht", "boxlinedp",
+ "boxlinenw","boxlinenh", "boxlinend",
+ "boxlinels", "boxliners", "boxlinelh", "boxlinerh",
+ "boxlinelp", "boxlinerp", "boxlinein",
+ "boxrangewd", "boxrangeht", "boxrangedp",
+ --
+ "bitwiseset", "bitwiseand", "bitwiseor", "bitwisexor", "bitwisenot", "bitwisenil",
+ "ifbitwiseand", "bitwise", "bitwiseshift", "bitwiseflip",
+ -- old ... very low level
+ "textdir", "linedir", "pardir", "boxdir",
+ --
+ "prelistbox", "postlistbox", "prelistcopy", "postlistcopy", "setprelistbox", "setpostlistbox",
+ --
+ "noligaturing", "nokerning", "noexpansion", "noprotrusion",
+ "noleftkerning", "noleftligaturing", "norightkerning", "norightligaturing",
+ --
+ "futureletnexttoken", "defbackslashbreak", "letbackslashbreak",
+ --
+ "pushoverloadmode", "popoverloadmode", "pushrunstate", "poprunstate",
+ --
+ "suggestedalias",
+ --
+ "newlocalcount", "newlocaldimen", "newlocalskip", "newlocalmuskip", "newlocaltoks", "newlocalbox",
+ "newlocalwrite", "newlocalread",
+ "setnewlocalcount", "setnewlocaldimen", "setnewlocalskip", "setnewlocalmuskip", "setnewlocaltoks", "setnewlocalbox",
}
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-mes.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-mes.lua
index 299f1a404ae..65ae022c0bb 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-mes.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-mes.lua
@@ -1159,6 +1159,9 @@ return {
no = "slutten av blokk %a (seksjon)",
ro = "sfarsit de bloc sectiune %a",
},
+ ["structures:3"] = {
+ en = "title to bookmark: %s",
+ },
["symbols:1"] = {
cs = "nacita se soubor symbolu %a",
de = "Lade Symboldatei %a",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-mps.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-mps.lua
index 6385d3fe51f..a2a74b3b316 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-mps.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-mps.lua
@@ -27,7 +27,6 @@ return {
"shipout", "show", "showdependencies", "showtoken", "showvariable",
"special",
"begingroup", "endgroup", "of", "curl", "tension", "and", "controls",
- "interpath", "on", "off",
"def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary",
"tertiary", "primarydef", "secondarydef", "tertiarydef",
"randomseed", "also", "contour", "doublepath",
@@ -68,11 +67,14 @@ return {
"fontpart", "fontsize", "glyph", "restoreclipcolor", "troffmode",
--
"runscript", "maketext", "numbersystem",
+ "overloadmode", "setproperty",
},
commands = {
+ "on", "off",
+ "interpath",
"upto", "downto",
"beginfig", "endfig",
- "beginglyph", "endglyph", -- actually a mult-fun one
+ "beginglyph", "endglyph", "beginfont", "endfont", -- actually a mult-fun one
"rotatedaround", "reflectedabout",
"arrowhead",
"currentpen", "currentpicture", "cuttings",
@@ -119,6 +121,9 @@ return {
--
"triplet", "quadruplet", "totransform", "bymatrix",
--
+ "primitive", "permanent", "immutable", "mutable", "frozen",
+ --
+ "showproperty", "showhashentry",
},
internals = { -- we need to remove duplicates above
--
@@ -131,6 +136,10 @@ return {
"join_radius",
"charscale", -- actually a mult-fun one
--
+ "inicatcoderegime", "texcatcoderegime", "luacatcoderegime", "notcatcoderegime",
+ "vrbcatcoderegime", "prtcatcoderegime", "ctxcatcoderegime", "txtcatcoderegime",
+ "catcoderegime",
+ --
"ditto", "EOF", -- maybe also down etc
--
"pen_lft", "pen_rt", "pen_top", "pen_bot", -- "pen_count_",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-prm.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-prm.lua
index 279de60e2d6..250a5dfc18d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-prm.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-prm.lua
@@ -32,11 +32,14 @@ return {
"iffontchar",
"interactionmode",
"interlinepenalties",
+ "lastchkdim",
+ "lastchknum",
"lastlinefit",
"lastnodetype",
"marks",
"muexpr",
"mutoglue",
+ "numericscale",
"numexpr",
"pagediscards",
"parshapedimen",
@@ -44,7 +47,6 @@ return {
"parshapelength",
"predisplaydirection",
"protected",
- "readline",
"savinghyphcodes",
"savingvdiscards",
"scantokens",
@@ -55,16 +57,22 @@ return {
"splitdiscards",
"splitfirstmarks",
"topmarks",
+ "tracingalignments",
"tracingassigns",
"tracinggroups",
"tracingifs",
"tracingnesting",
- "tracingscantokens",
"unexpanded",
"unless",
"widowpenalties",
},
["luatex"]={
+ "UUskewed",
+ "UUskewedwithdelims",
+ "Uabove",
+ "Uabovewithdelims",
+ "Uatop",
+ "Uatopwithdelims",
"Uchar",
"Udelcode",
"Udelcodenum",
@@ -74,6 +82,7 @@ return {
"Uhextensible",
"Uleft",
"Umathaccent",
+ "Umathaccentbaseheight",
"Umathaxis",
"Umathbinbinspacing",
"Umathbinclosespacing",
@@ -90,6 +99,7 @@ return {
"Umathcharnum",
"Umathcharnumdef",
"Umathcharslot",
+ "Umathclass",
"Umathclosebinspacing",
"Umathcloseclosespacing",
"Umathcloseinnerspacing",
@@ -179,6 +189,8 @@ return {
"Umathskewedfractionhgap",
"Umathskewedfractionvgap",
"Umathspaceafterscript",
+ "Umathspacebeforescript",
+ "Umathspacingmode",
"Umathstackdenomdown",
"Umathstacknumup",
"Umathstackvgap",
@@ -197,9 +209,13 @@ return {
"Umathunderdelimiterbgap",
"Umathunderdelimitervgap",
"Umiddle",
+ "Unosubprescript",
"Unosubscript",
+ "Unosuperprescript",
"Unosuperscript",
+ "Uover",
"Uoverdelimiter",
+ "Uoverwithdelims",
"Uradical",
"Uright",
"Uroot",
@@ -210,7 +226,10 @@ return {
"Ustartmath",
"Ustopdisplaymath",
"Ustopmath",
+ "Ustyle",
+ "Usubprescript",
"Usubscript",
+ "Usuperprescript",
"Usuperscript",
"Uunderdelimiter",
"Uvextensible",
@@ -218,18 +237,22 @@ return {
"adjustspacingshrink",
"adjustspacingstep",
"adjustspacingstretch",
+ "afterassigned",
"aftergrouped",
+ "aliased",
"alignmark",
"aligntab",
+ "atendofgroup",
+ "atendofgrouped",
"attribute",
"attributedef",
"automaticdiscretionary",
- "automatichyphenmode",
"automatichyphenpenalty",
+ "automigrationmode",
"begincsname",
"beginlocalcontrol",
"boundary",
- "boxattr",
+ "boxattribute",
"boxdirection",
"boxorientation",
"boxtotal",
@@ -237,43 +260,68 @@ return {
"boxxoffset",
"boxymove",
"boxyoffset",
- "breakafterdirmode",
"catcodetable",
"clearmarks",
- "compoundhyphenmode",
"crampeddisplaystyle",
"crampedscriptscriptstyle",
"crampedscriptstyle",
"crampedtextstyle",
"csstring",
+ "defcsname",
+ "dimensiondef",
+ "directlua",
+ "edefcsname",
"efcode",
"endlocalcontrol",
+ "enforced",
"etoksapp",
"etokspre",
+ "everytab",
"exceptionpenalty",
+ "expand",
+ "expandafterpars",
+ "expandafterspaces",
+ "expandcstoken",
"expanded",
+ "expandtoken",
"explicitdiscretionary",
"explicithyphenpenalty",
"firstvalidlanguage",
- "fixupboxesmode",
"fontid",
+ "fontspecifiedsize",
"formatname",
"frozen",
+ "futuredef",
"futureexpand",
"futureexpandis",
"futureexpandisap",
+ "gdefcsname",
"gleaders",
"glet",
+ "gletcsname",
+ "gluespecdef",
"glyphdatafield",
+ "glyphoptions",
+ "glyphscale",
+ "glyphscriptfield",
+ "glyphscriptscale",
+ "glyphscriptscriptscale",
+ "glyphstatefield",
+ "glyphtextscale",
+ "glyphxoffset",
+ "glyphxscale",
+ "glyphyoffset",
+ "glyphyscale",
"gtoksapp",
"gtokspre",
"hjcode",
"hpack",
- "hyphenationbounds",
"hyphenationmin",
- "hyphenpenaltymode",
+ "hyphenationmode",
"ifabsdim",
"ifabsnum",
+ "ifarguments",
+ "ifboolean",
"ifchkdim",
"ifchknum",
"ifcmpdim",
@@ -281,27 +329,42 @@ return {
"ifcondition",
"ifcstok",
"ifdimval",
- "iffrozen",
+ "ifempty",
+ "ifflags",
+ "ifhastok",
+ "ifhastoks",
+ "ifhasxtoks",
"ifincsname",
+ "ifmathparameter",
+ "ifmathstyle",
"ifnumval",
- "ifprotected",
+ "ifparameter",
+ "ifparameters",
+ "ifrelax",
"iftok",
- "ifusercmd",
+ "ignorearguments",
"ignorepars",
- "immediateassigned",
- "immediateassignment",
+ "immediate",
+ "immutable",
"initcatcodetable",
+ "insertheights",
"insertht",
- "internalcodesmode",
+ "instance",
+ "integerdef",
+ "lastarguments",
"lastnamedcs",
"lastnodesubtype",
- "leftghost",
"leftmarginkern",
"letcharcode",
+ "letcsname",
"letfrozen",
"letprotected",
"linedirection",
+ "linepar",
+ "listcallbackmode",
"localbrokenpenalty",
+ "localcontrol",
+ "localcontrolled",
"localinterlinepenalty",
"localleftbox",
"localrightbox",
@@ -323,25 +386,35 @@ return {
"mathflattenmode",
"mathitalicsmode",
"mathnolimitsmode",
- "matholdmode",
"mathpenaltiesmode",
"mathrulesfam",
"mathrulesmode",
"mathrulethicknessmode",
+ "mathscale",
"mathscriptboxmode",
"mathscriptcharmode",
"mathscriptsmode",
"mathstyle",
"mathsurroundmode",
"mathsurroundskip",
+ "mugluespecdef",
+ "mutable",
+ "noaligned",
"noboundary",
"nohrule",
- "nokerns",
- "noligs",
+ "norelax",
+ "normalizelinemode",
"nospaces",
"novrule",
+ "orelse",
+ "orunless",
"outputbox",
+ "overloaded",
+ "overloadmode",
+ "parametercount",
+ "parattr",
"pardirection",
+ "permanent",
"postexhyphenchar",
"posthyphenchar",
"prebinoppenalty",
@@ -353,22 +426,30 @@ return {
"protrusionboundary",
"pxdimen",
"quitvmode",
- "rightghost",
"rightmarginkern",
"rpcode",
"savecatcodetable",
"scantextokens",
"setfontid",
- "shapemode",
+ "snapshotpar",
+ "supmarkmode",
+ "swapcsvalues",
"textdirection",
+ "thewithoutunit",
+ "tokenized",
"toksapp",
"tokspre",
+ "tolerant",
"tpack",
"tracingfonts",
+ "tracingmath",
+ "undent",
"unletfrozen",
"unletprotected",
"vpack",
"wordboundary",
+ "wrapuppar",
+ "xdefcsname",
"xtoksapp",
"xtokspre",
},
@@ -521,7 +602,6 @@ return {
"char",
"chardef",
"cleaders",
- "closein",
"clubpenalty",
"copy",
"count",
@@ -540,7 +620,6 @@ return {
"delimitershortfall",
"dimen",
"dimendef",
- "directlua",
"discretionary",
"displayindent",
"displaylimits",
@@ -571,7 +650,6 @@ return {
"everyjob",
"everymath",
"everypar",
- "everytab",
"everyvbox",
"exhyphenchar",
"exhyphenpenalty",
@@ -584,10 +662,12 @@ return {
"font",
"fontdimen",
"fontname",
+ "fontspecifiedname",
"futurelet",
"gdef",
"global",
"globaldefs",
+ "glyph",
"halign",
"hangafter",
"hangindent",
@@ -597,7 +677,6 @@ return {
"hfill",
"hfilneg",
"hfuzz",
- "hoffset",
"holdinginserts",
"hrule",
"hsize",
@@ -611,7 +690,6 @@ return {
"ifcase",
"ifcat",
"ifdim",
- "ifeof",
"iffalse",
"ifhbox",
"ifhmode",
@@ -653,7 +731,6 @@ return {
"looseness",
"lower",
"lowercase",
- "mag",
"mark",
"mathaccent",
"mathbin",
@@ -672,6 +749,8 @@ return {
"maxdeadcycles",
"maxdepth",
"meaning",
+ "meaningfull",
+ "meaningless",
"medmuskip",
"message",
"middle",
@@ -694,16 +773,15 @@ return {
"nullfont",
"number",
"omit",
- "openin",
"or",
"ordlimits",
- "orelse",
"outer",
"output",
"outputpenalty",
"over",
"overfullrule",
"overline",
+ "overshoot",
"overwithdelims",
"pagedepth",
"pagefilllstretch",
@@ -714,6 +792,7 @@ return {
"pagestretch",
"pagetotal",
"par",
+ "parfillleftskip",
"parfillskip",
"parindent",
"parshape",
@@ -729,13 +808,13 @@ return {
"prevgraf",
"radical",
"raise",
- "read",
"relax",
"relpenalty",
"right",
"righthyphenmin",
"rightskip",
"romannumeral",
+ "scaledfontdimen",
"scriptfont",
"scriptscriptfont",
"scriptscriptstyle",
@@ -771,11 +850,14 @@ return {
"thickmuskip",
"thinmuskip",
"time",
+ "todimension",
+ "tointeger",
"toks",
"toksdef",
"tolerance",
"topmark",
"topskip",
+ "toscaled",
"tracingcommands",
"tracinglostchars",
"tracingmacros",
@@ -790,11 +872,13 @@ return {
"underline",
"unhbox",
"unhcopy",
+ "unhpack",
"unkern",
"unpenalty",
"unskip",
"unvbox",
"unvcopy",
+ "unvpack",
"uppercase",
"vadjust",
"valign",
@@ -805,7 +889,6 @@ return {
"vfill",
"vfilneg",
"vfuzz",
- "voffset",
"vrule",
"vsize",
"vskip",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-sys.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mult-sys.mkiv
index 8f8794df71c..7e9792720ad 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/mult-sys.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/mult-sys.mkiv
@@ -34,6 +34,7 @@
\definesystemconstant {hans}
\definesystemconstant {taco}
+\definesystemconstant {wolfgang}
%D First we define some system constants used for both the multi||lingual
%D interface and multi||linguag typesetting.
@@ -46,16 +47,17 @@
\definesystemconstant {ancientgreek} \definesystemconstant {agr}
\definesystemconstant {ancientlatin} \definesystemconstant {ala}
\definesystemconstant {arabic} \definesystemconstant {ar}
+\definesystemconstant {belarussian} \definesystemconstant {be}
\definesystemconstant {bokmal} \definesystemconstant {nb}
\definesystemconstant {catalan} \definesystemconstant {ca}
\definesystemconstant {chinese} \definesystemconstant {cn}
-\definesystemconstant {chinese} \definesystemconstant {cn}
\definesystemconstant {croatian} \definesystemconstant {hr}
\definesystemconstant {czech} \definesystemconstant {cs}
\definesystemconstant {danish} \definesystemconstant {da}
\definesystemconstant {dutch} \definesystemconstant {nl}
\definesystemconstant {english} \definesystemconstant {en}
\definesystemconstant {estonian} \definesystemconstant {et}
+\definesystemconstant {esperanto} % \definesystemconstant {eo}
\definesystemconstant {farsi} \definesystemconstant {fa} % just persian
\definesystemconstant {finnish} \definesystemconstant {fi}
\definesystemconstant {french} \definesystemconstant {fr}
@@ -63,6 +65,7 @@
\definesystemconstant {german} \definesystemconstant {de}
\definesystemconstant {greek} \definesystemconstant {gr}
\definesystemconstant {hebrew} \definesystemconstant {he}
+\definesystemconstant {yiddish} \definesystemconstant {yi}
\definesystemconstant {hungarian} \definesystemconstant {hu}
\definesystemconstant {italian} \definesystemconstant {it}
\definesystemconstant {japanese} \definesystemconstant {ja}
@@ -70,6 +73,7 @@
\definesystemconstant {latin} \definesystemconstant {la}
\definesystemconstant {lithuanian} \definesystemconstant {lt}
\definesystemconstant {malayalam} \definesystemconstant {ml}
+\definesystemconstant {macedonian} \definesystemconstant {mk}
\definesystemconstant {norwegian} \definesystemconstant {no}
\definesystemconstant {nynorsk} \definesystemconstant {nn}
\definesystemconstant {persian} \definesystemconstant {pe}
@@ -79,6 +83,7 @@
\definesystemconstant {russian} \definesystemconstant {ru}
\definesystemconstant {slovak} \definesystemconstant {sk}
\definesystemconstant {slovenian} \definesystemconstant {sl}
+\definesystemconstant {serbian} \definesystemconstant {sr}
\definesystemconstant {spanish} \definesystemconstant {es}
\definesystemconstant {swedish} \definesystemconstant {sv}
\definesystemconstant {thai} \definesystemconstant {th} % mojca mentioned it at BT2013 but we need more info
@@ -274,6 +279,7 @@
\definesystemconstant {start}
\definesystemconstant {stop}
\definesystemconstant {unknown}
+\definesystemconstant {unexpanded}
% translating setups is asking for a mess so we keep them as-is:
@@ -407,8 +413,11 @@
\definesystemconstant {text}
\definesystemconstant {paragraph}
\definesystemconstant {margintext}
+\definesystemconstant {themaintextcolor}
\definesystemconstant {line}
+\definesystemconstant {itemgroupcolumns}
+\definesystemconstant {vfrac}
\definesystemconstant {number}
\definesystemconstant {symbol}
\definesystemconstant {format}
@@ -573,19 +582,19 @@
\defineinterfaceconstant {e} {e} % can go
\defineinterfaceconstant {f} {f} % can go
-\defineinterfaceconstant {s} {s}
+%defineinterfaceconstant {s} {s}
\defineinterfaceconstant {r} {r}
\defineinterfaceconstant {g} {g}
-\defineinterfaceconstant {b} {b}
-\defineinterfaceconstant {c} {c}
+%defineinterfaceconstant {b} {b}
+%defineinterfaceconstant {c} {c}
\defineinterfaceconstant {m} {m}
-\defineinterfaceconstant {y} {y}
+%defineinterfaceconstant {y} {y}
\defineinterfaceconstant {k} {k}
-\defineinterfaceconstant {a} {a} % alternative
-\defineinterfaceconstant {t} {t} % transparency
+%defineinterfaceconstant {a} {a} % alternative
+%defineinterfaceconstant {t} {t} % transparency
\defineinterfaceconstant {p} {p} % percentage
-\defineinterfaceconstant {h} {h}
-\defineinterfaceconstant {s} {s}
+%defineinterfaceconstant {h} {h}
+%defineinterfaceconstant {s} {s}
\defineinterfaceconstant {v} {v}
\defineinterfaceconstant {rgb} {rgb}
@@ -672,7 +681,7 @@
\selectinterface
-%D Ok, here are some more, because we've got ouselves some extensions to \CONTEXT.
+%D Ok, here are some more, because we've got ourselves some extensions to \CONTEXT.
\definemessageconstant {addresses}
\definemessageconstant {documents}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua b/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
index e6c6176026e..d8f4b25bf3a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
@@ -129,10 +129,9 @@ end)
-- local done = false
-- for n, id in nextnode, tonuts(head) do
-- if id == disc then
--- local r = getfield(n,"replace")
--- local p = getfield(n,"pre")
--- if r and p then
--- local str = compact(r)
+-- local pre, post, replace = getdisc(n)
+-- if replace and pre then
+-- local str = compact(replace)
-- local hsh = hyphenated[str]
-- if not hsh then
-- hsh = #codes + 1
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-aux.lua b/Master/texmf-dist/tex/context/base/mkiv/node-aux.lua
index d13db4bbaf5..d3c537a3bce 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-aux.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-aux.lua
@@ -21,8 +21,7 @@ local glyph_code = nodecodes.glyph
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local attributelist_code = nodecodes.attributelist -- temporary
-local localpar_code = nodecodes.localpar
-local ligatureglyph_code = nodes.glyphcodes.ligature
+local par_code = nodecodes.par
local nuts = nodes.nuts
local tonut = nuts.tonut
@@ -48,7 +47,6 @@ local setlink = nuts.setlink
local setlist = nuts.setlist
local setnext = nuts.setnext
local setprev = nuts.setprev
-local setcomponents = nuts.setcomponents
local setattrlist = nuts.setattrlist
local traversers = nuts.traversers
@@ -382,167 +380,11 @@ function nodes.rehpack(n,...)
rehpack(tonut(n),...)
end
-if CONTEXTLMTXMODE > 0 then
-
- local fastcopy = table.fastcopy
- local getprop = nuts.getprop
- local setprop = nuts.setprop
-
- local function set_components(base,list)
- local t = { }
- local n = 0
- while list do
- local char = isglyph(list)
- if char then
- n = n + 1
- t[n] = char
- end
- list = getnext(list)
- end
- setprop(base,"components",n > 0 and t or false)
- end
-
- local function get_components(base)
- return getprop(base,"components")
- end
-
- local function copy_no_components(base)
- local copy = copy_node(base)
- setprop(copy,"components",false) -- no metatable lookup!
- return copy
- end
-
- local function copy_only_glyphs(base)
- local t = getprop(base,"components") -- also metatable
- if t then
- return fastcopy(t)
- end
- end
-
- local function do_count(t,marks)
- local n = 0
- if t then
- for i=1,#t do
- local c = t[i]
- if type(c) == "table" then
- n = n + do_count(t,marks)
- elseif not marks[c] then
- n = n + 1
- else
- --marks don't count
- end
- end
- end
- return n
- end
-
- -- start is a mark and we need to keep that one
-
- local done = false
-
- local function count_components(base,marks)
- local char = isglyph(base)
- if char then
- if getsubtype(base) == ligatureglyph_code then
- if not done then
- logs.report("fonts","!")
- logs.report("fonts","! check count_components with mkiv !")
- logs.report("fonts","!")
- done = true
- end
- local t = getprop(base,"components")
- if t then
- return do_count(t,marks)
- end
- elseif not marks[char] then
- return 1
- end
- end
- return 0
- end
-
- nuts.set_components = set_components
- nuts.get_components = get_components
- nuts.copy_only_glyphs = copy_only_glyphs
- nuts.copy_no_components = copy_no_components
- nuts.count_components = count_components
-
-else
-
- local get_components = node.direct.getcomponents
- local set_components = node.direct.setcomponents
-
- local function copy_no_components(g,copyinjection)
- local components = get_components(g)
- if components then
- set_components(g)
- local n = copy_node(g)
- if copyinjection then
- copyinjection(n,g)
- end
- set_components(g,components)
- -- maybe also upgrade the subtype but we don't use it anyway
- return n
- else
- local n = copy_node(g)
- if copyinjection then
- copyinjection(n,g)
- end
- return n
- end
- end
-
- local function copy_only_glyphs(current)
- local head = nil
- local previous = nil
- for n in nextglyph, current do
- n = copy_node(n)
- if head then
- setlink(previous,n)
- else
- head = n
- end
- previous = n
- end
- return head
- end
-
- -- start is a mark and we need to keep that one
-
- local function count_components(start,marks)
- local char = isglyph(start)
- if char then
- if getsubtype(start) == ligatureglyph_code then
- local n = 0
- local components = get_components(start)
- while components do
- n = n + count_components(components,marks)
- components = getnext(components)
- end
- return n
- elseif not marks[char] then
- return 1
- end
- end
- return 0
- end
-
- nuts.set_components = set_components
- nuts.get_components = get_components
- nuts.copy_only_glyphs = copy_only_glyphs
- nuts.copy_no_components = copy_no_components
- nuts.count_components = count_components
-
-end
-
-nuts.setcomponents = function() report_error("unsupported: %a","setcomponents") end
-nuts.getcomponents = function() report_error("unsupported: %a","getcomponents") end
-
do
- local localparcodes = nodes.localparcodes
- local hmodepar_code = localparcodes.vmode_par
- local vmodepar_code = localparcodes.hmode_par
+ local parcodes = nodes.parcodes
+ local hmodepar_code = parcodes.vmode_par
+ local vmodepar_code = parcodes.hmode_par
local getnest = tex.getnest
local getsubtype = nuts.getsubtype
@@ -550,7 +392,7 @@ do
function nuts.setparproperty(action,...)
local tail = tonut(getnest().tail)
while tail do
- if getid(tail) == localpar_code then
+ if getid(tail) == par_code then
local s = getsubtype(tail)
if s == hmodepar_code or s == vmodepar_code then
return action(tail,...)
@@ -571,10 +413,7 @@ do
end
--- Currently only in luametatex ... experimental anyway .. if it doesn't end
--- up in luatex I'll move this to a different module.
-
-do
+if not nuts.getnormalizedline then
local nextnode = traversers.glue
local findfail = nuts.tail
@@ -617,14 +456,12 @@ do
nuts.find_node = find_node
- nodes.getnormalizeline = node.getnormalizeline or function() return 0 end
- nodes.setnormalizeline = node.setnormalizeline or function() end
-
- nuts.getnormalizedline = direct.getnormalizedline or function(h)
+ function nuts.getnormalizedline(h)
if getid(h) == hlist_code and getsubtype(h) == line_code then
local ls, rs = 0, 0
local lh, rh = 0, 0
- local is, ps = 0, 0
+ local lp, rp = 0, 0
+ local is = 0
local h = getlist(h)
local t = findtail(h)
for n, subtype in nextglue, h do
@@ -633,241 +470,21 @@ do
elseif subtype == lefthangskip_code then lh = getwidth(n)
elseif subtype == righthangskip_code then rh = getwidth(n)
elseif subtype == indentskip_code then is = getwidth(n)
- elseif subtype == parfillskip_code then ps = getwidth(n)
+ elseif subtype == parfillskip_code then rp = getwidth(n)
end
end
- return ls, rs, lh, rh, is, ps, h, t
- end
- end
-
-end
-
-if not nodes.count then
-
- local type = type
-
- local direct = node.direct
- local todirect = direct.tovaliddirect
- local tonode = direct.tonode
-
- local count = direct.count
- local length = direct.length
- local slide = direct.slide
-
- function node.count(id,first,last)
- return count(id,first and todirect(first), last and todirect(last) or nil)
- end
-
- function node.length(first,last)
- return length(first and todirect(first), last and todirect(last) or nil)
- end
-
- function node.slide(n)
- if n then
- n = slide(todirect(n))
- if n then
- return tonode(n)
- end
- end
- return nil
- end
-
- local hyphenating = direct.hyphenating
- local ligaturing = direct.ligaturing
- local kerning = direct.kerning
-
- -- kind of inconsistent
-
- function node.hyphenating(first,last)
- if first then
- local h, t = hyphenating(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
- function node.ligaturing(first,last)
- if first then
- local h, t = ligaturing(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
- function node.kerning(first,last)
- if first then
- local h, t = kerning(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
- local protect_glyph = direct.protect_glyph
- local unprotect_glyph = direct.unprotect_glyph
- local protect_glyphs = direct.protect_glyphs
- local unprotect_glyphs = direct.unprotect_glyphs
-
- function node.protect_glyphs(first,last)
- protect_glyphs(todirect(first), last and todirect(last) or nil)
- end
-
- function node.unprotect_glyphs(first,last)
- unprotect_glyphs(todirect(first), last and todirect(last) or nil)
- end
-
- function node.protect_glyph(first)
- protect_glyph(todirect(first))
- end
-
- function node.unprotect_glyph(first)
- unprotect_glyph(todirect(first))
- end
-
- local flatten_discretionaries = direct.flatten_discretionaries
- local check_discretionaries = direct.check_discretionaries
- local check_discretionary = direct.check_discretionary
-
- function node.flatten_discretionaries(first)
- local h, count = flatten_discretionaries(todirect(first))
- return tonode(h), count
- end
-
- function node.check_discretionaries(n)
- check_discretionaries(todirect(n))
- end
-
- function node.check_discretionary(n)
- check_discretionary(todirect(n))
- end
-
- local hpack = direct.hpack
- local vpack = direct.vpack
- local list_to_hlist = direct.mlist_to_hlist
-
- function node.hpack(head,...)
- local h, badness = hpack(head and todirect(head) or nil,...)
- return tonode(h), badness
- end
-
- function node.vpack(head,...)
- local h, badness = vpack(head and todirect(head) or nil,...)
- return tonode(h), badness
- end
-
- function node.mlist_to_hlist(head,...)
- return tonode(mlist_to_hlist(head and todirect(head) or nil,...))
- end
-
- local end_of_math = direct.end_of_math
- local find_attribute = direct.find_attribute
- local first_glyph = direct.first_glyph
-
- function node.end_of_math(n)
- if n then
- n = end_of_math(todirect(n))
- if n then
- return tonode(n)
- end
- end
- return nil
- end
-
- function node.find_attribute(n,a)
- if n then
- local v, n = find_attribute(todirect(n),a)
- if n then
- return v, tonode(n)
- end
+ return {
+ leftskip = ls,
+ rightskip = rs,
+ lefthangskip = lh,
+ righthangskip = rh,
+ indent = is,
+ parfillrightskip = rp,
+ parfillleftskip = lp,
+ head = h,
+ tail = t,
+ }
end
- return nil
- end
-
- function node.first_glyph(first,last)
- local n = first_glyph(todirect(first), last and todirect(last) or nil)
- return n and tonode(n) or nil
- end
-
- local dimensions = direct.dimensions
- local rangedimensions = direct.rangedimensions
- local effective_glue = direct.effective_glue
-
- function node.dimensions(a,b,c,d,e)
- if type(a) == "userdata" then
- a = todirect(a)
- if type(b) == "userdata" then
- b = todirect(b)
- end
- return dimensions(a,b)
- else
- d = todirect(d)
- if type(e) == "userdata" then
- e = todirect(e)
- end
- return dimensions(a,b,c,d,e)
- end
- return 0, 0, 0
- end
-
- function node.rangedimensions(parent,first,last)
- return rangedimenensions(todirect(parent),todirect(first),last and todirect(last))
- end
-
- function node.effective_glue(list,parent)
- return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil)
- end
-
- local uses_font = direct.uses_font
- local has_glyph = direct.has_glyph
- local protrusion_skippable = direct.protrusion_skippable
- local prepend_prevdepth = direct.prepend_prevdepth
- local make_extensible = direct.make_extensible
-
- function node.uses_font(n,f)
- return uses_font(todirect(n),f)
- end
-
- function node.has_glyph(n)
- return has_glyph(todirect(n))
- end
-
- function node.protrusion_skippable(n)
- return protrusion_skippable(todirect(n))
- end
-
- function node.prepend_prevdepth(n)
- local n, d = prepend_prevdepth(todirect(n))
- return tonode(n), d
- end
-
- function node.make_extensible(...)
- local n = make_extensible(...)
- return n and tonode(n) or nil
- end
-
- local last_node = direct.last_node
-
- function node.last_node()
- local n = last_node()
- return n and tonode(n) or nil
- end
-
- local is_zero_glue = direct.is_zero_glue
- local getglue = direct.getglue
- local setglue = direct.setglue
-
- function node.is_zero_glue(n)
- return is_zero_glue(todirect(n))
- end
-
- function node.get_glue(n)
- return get_glue(todirect(n))
- end
-
- function node.set_glue(n)
- return set_glue(todirect(n))
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-bck.lua b/Master/texmf-dist/tex/context/base/mkiv/node-bck.lua
index 53ace65e99e..ec84a3db5c3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-bck.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-bck.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['node-bck'] = {
version = 1.001,
+ optimize = true,
comment = "companion to node-bck.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -62,9 +63,6 @@ local unsetvalue = attributes.unsetvalue
local linefillers = nodes.linefillers
-local a_color = privateattributes("color")
-local a_transparency = privateattributes("transparency")
-local a_colormodel = privateattributes("colormodel")
local a_background = privateattributes("background")
local a_alignbackground = privateattributes("alignbackground")
local a_linefiller = privateattributes("linefiller")
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-bck.mkiv b/Master/texmf-dist/tex/context/base/mkiv/node-bck.mkiv
index b093274430c..0e7bbb853f3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-bck.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-bck.mkiv
@@ -34,12 +34,12 @@
\fi\fi}
\def\node_backgrounds_thecolorattr#1%
- {attr \colormodelattribute \attribute\colormodelattribute
+ {attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \lastnamedcs
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\thecolorattr#1%
- {attr \colormodelattribute \attribute\colormodelattribute
+ {attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \csname\??colorattribute#1\endcsname
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
@@ -52,19 +52,19 @@
\def\thebackgroundcolorattr#1%
{attr \backgroundattribute \plusone
- attr \colormodelattribute \attribute\colormodelattribute
+ attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \csname\??colorattribute#1\endcsname
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\node_backgrounds_thebackgroundcolorattr#1%
{attr \backgroundattribute \plusone
- attr \colormodelattribute \attribute\colormodelattribute
+ attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \lastnamedcs
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\thealignbackgroundcolorattr#1%
{attr \alignbackgroundattribute \plusone
- attr \colormodelattribute \attribute\colormodelattribute
+ attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \csname\??colorattribute#1\endcsname
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
@@ -81,9 +81,9 @@
% \dousecolorparameter{#2}%
% \normalexpanded{\endgroup#1
% attr \backgroundattribute \plusone
-% attr \colormodelattribute \the\attribute\colormodelattribute
-% attr \colorattribute \the\attribute\colorattribute
-% attr \transparencyattribute \the\attribute\transparencyattribute}}
+% attr \colormodelattribute \the\c_attr_colormodel
+% attr \colorattribute \the\c_attr_color
+% attr \transparencyattribute \the\c_attr_transparency}}
%
% more efficient:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-cmp.lua b/Master/texmf-dist/tex/context/base/mkiv/node-cmp.lua
deleted file mode 100644
index e13e93d1f14..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/node-cmp.lua
+++ /dev/null
@@ -1,232 +0,0 @@
-if node.count then
- return
-end
-
-local type = type
-
-local node = node
-local direct = node.direct
-local todirect = direct.tovaliddirect
-local tonode = direct.tonode
-
-local count = direct.count
-local length = direct.length
-local slide = direct.slide
-
-function node.count(id,first,last)
- return count(id,first and todirect(first), last and todirect(last) or nil)
-end
-
-function node.length(first,last)
- return length(first and todirect(first), last and todirect(last) or nil)
-end
-
-function node.slide(n)
- if n then
- n = slide(todirect(n))
- if n then
- return tonode(n)
- end
- end
- return nil
-end
-
-local hyphenating = direct.hyphenating
-local ligaturing = direct.ligaturing
-local kerning = direct.kerning
-
--- kind of inconsistent
-
-function node.hyphenating(first,last)
- if first then
- local h, t = hyphenating(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
-end
-
-function node.ligaturing(first,last)
- if first then
- local h, t = ligaturing(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
-end
-
-function node.kerning(first,last)
- if first then
- local h, t = kerning(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
-local protect_glyph = direct.protect_glyph
-local unprotect_glyph = direct.unprotect_glyph
-local protect_glyphs = direct.protect_glyphs
-local unprotect_glyphs = direct.unprotect_glyphs
-
-function node.protect_glyphs(first,last)
- protect_glyphs(todirect(first), last and todirect(last) or nil)
-end
-
-function node.unprotect_glyphs(first,last)
- unprotect_glyphs(todirect(first), last and todirect(last) or nil)
-end
-
-function node.protect_glyph(first)
- protect_glyph(todirect(first))
-end
-
-function node.unprotect_glyph(first)
- unprotect_glyph(todirect(first))
-end
-
-local flatten_discretionaries = direct.flatten_discretionaries
-local check_discretionaries = direct.check_discretionaries
-local check_discretionary = direct.check_discretionary
-
-function node.flatten_discretionaries(first)
- local h, count = flatten_discretionaries(todirect(first))
- return tonode(h), count
-end
-
-function node.check_discretionaries(n)
- check_discretionaries(todirect(n))
-end
-
-function node.check_discretionary(n)
- check_discretionary(todirect(n))
-end
-
-local hpack = direct.hpack
-local vpack = direct.vpack
-local list_to_hlist = direct.mlist_to_hlist
-
-function node.hpack(head,...)
- local h, badness = hpack(head and todirect(head) or nil,...)
- return tonode(h), badness
-end
-
-function node.vpack(head,...)
- local h, badness = vpack(head and todirect(head) or nil,...)
- return tonode(h), badness
-end
-
-function node.mlist_to_hlist(head,...)
- return tonode(mlist_to_hlist(head and todirect(head) or nil,...))
-end
-
-local end_of_math = direct.end_of_math
-local find_attribute = direct.find_attribute
-local first_glyph = direct.first_glyph
-
-function node.end_of_math(n)
- if n then
- n = end_of_math(todirect(n))
- if n then
- return tonode(n)
- end
- end
- return nil
-end
-
-function node.find_attribute(n,a)
- if n then
- local v, n = find_attribute(todirect(n),a)
- if n then
- return v, tonode(n)
- end
- end
- return nil
-end
-
-function node.first_glyph(first,last)
- local n = first_glyph(todirect(first), last and todirect(last) or nil)
- return n and tonode(n) or nil
-end
-
-local dimensions = direct.dimensions
-local rangedimensions = direct.rangedimensions
-local effective_glue = direct.effective_glue
-
-function node.dimensions(a,b,c,d,e)
- if type(a) == "userdata" then
- a = todirect(a)
- if type(b) == "userdata" then
- b = todirect(b)
- end
- return dimensions(a,b)
- else
- d = todirect(d)
- if type(e) == "userdata" then
- e = todirect(e)
- end
- return dimensions(a,b,c,d,e)
- end
- return 0, 0, 0
-end
-
-function node.rangedimensions(parent,first,last)
- return rangedimenensions(todirect(parent),todirect(first),last and todirect(last))
-end
-
-function node.effective_glue(list,parent)
- return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil)
-end
-
-local uses_font = direct.uses_font
-local has_glyph = direct.has_glyph
-local protrusion_skippable = direct.protrusion_skippable
-local prepend_prevdepth = direct.prepend_prevdepth
-local make_extensible = direct.make_extensible
-
-function node.uses_font(n,f)
- return uses_font(todirect(n),f)
-end
-
-function node.has_glyph(n)
- return has_glyph(todirect(n))
-end
-
-function node.protrusion_skippable(n)
- return protrusion_skippable(todirect(n))
-end
-
-function node.prepend_prevdepth(n)
- local n, d = prepend_prevdepth(todirect(n))
- return tonode(n), d
-end
-
-function node.make_extensible(...)
- local n = make_extensible(...)
- return n and tonode(n) or nil
-end
-
-local last_node = direct.last_node
-
-function node.last_node()
- local n = last_node()
- return n and tonode(n) or nil
-end
-
-local is_zero_glue = direct.is_zero_glue
-local getglue = direct.getglue
-local setglue = direct.setglue
-
-function node.is_zero_glue(n)
- return is_zero_glue(todirect(n))
-end
-
-function node.get_glue(n)
- return get_glue(todirect(n))
-end
-
-function node.set_glue(n)
- return set_glue(todirect(n))
-end
-
-node.family_font = tex.getfontoffamily
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ext.lua b/Master/texmf-dist/tex/context/base/mkiv/node-ext.lua
deleted file mode 100644
index 82ec04ee592..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/node-ext.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-if not modules then modules = { } end modules ['node-ext'] = {
- version = 1.001,
- comment = "companion to node-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
---[[ldx--
-
Serializing nodes can be handy for tracing. Also, saving and
-loading node lists can come in handy as soon we are going to
-use external applications to process node lists.
---ldx]]--
-
-function nodes.show(stack)
--- logs.writer(table.serialize(stack))
-end
-
-function nodes.save(stack,name) -- *.ltn : luatex node file
--- if name then
--- file.savedata(name,table.serialize(stack))
--- else
--- logs.writer(table.serialize(stack))
--- end
-end
-
-function nodes.load(name)
--- return file.loaddata(name)
--- -- todo
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-fin.lua b/Master/texmf-dist/tex/context/base/mkiv/node-fin.lua
index a848cef69da..373cce3ce60 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-fin.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-fin.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['node-fin'] = {
version = 1.001,
+ optimize = true,
comment = "companion to node-fin.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -375,6 +376,7 @@ local function selective(attribute,head,inheritance,default) -- two attributes
else
check = has_dimensions(stack)
end
+ else
end
if check then
local c = getattr(stack,attribute)
@@ -634,100 +636,3 @@ end
statistics.register("attribute processing time", function()
return statistics.elapsedseconds(attributes,"front- and backend")
end)
-
--- -- --
-
-do
-
- local cleaners = { }
- local trace = true -- false
-
- function attributes.cleanup()
- if next(cleaners) then
- local values = setmetatableindex("table")
-
- if trace then
- starttiming(values)
- end
-
- local function check(l)
- for n, id in nextnode, l do
- if id == hlist_code or id == vlist_code or id == glue_code then
- local l = getlist(n)
- if l then
- check(l)
- end
- end
- for a in next, cleaners do
- local v = getattr(n,a)
- if v then
- -- values[a] = values[a] + 1
- values[a][v] = true
- end
- end
- end
- end
-
- local top = texgetnest("ptr")
- for i=1,top do
- local l = texgetnest(i)
- if l then
- check(tonut(l.head))
- end
- end
-
- do local l
- l = tonut(texlists.page_ins_head) if l then check(l) end
- l = tonut(texlists.contrib_head) if l then check(l) end
- l = tonut(texlists.page_discards_head) if l then check(l) end
- l = tonut(texlists.split_discards_head) if l then check(l) end
- l = tonut(texlists.page_head) if l then check(l) end
- end
-
- -- todo: traverseboxes
-
- for i=0,65535 do
- local b = getbox(i)
- if b then
- local l = getlist(b)
- if l then
- check(l)
- end
- end
- end
-
- for a, t in next, values do
- cleaners[a](a,t)
- end
-
- if trace then
- stoptiming(values)
- local a = table.sortedkeys(values)
- local t = statistics.elapsedtime(values)
- local r = tex.getcount("realpageno")
- if #a == 0 then
- logs.report("attributes","cleaning up at page %i took %s seconds, no attributes",r,t)
- else
- logs.report("attributes","cleaning up at page %i took %s seconds, attributes: % t",r,t,a)
- end
- end
- end
- end
-
- -- not yet used but when we do ... delay a call till we enable it (attr-ini.mkiv)
-
- -- local function show(a,t) for k, v in next, t do print(a,k) end end
- --
- -- attributes.registercleaner( 1, show)
- -- attributes.registercleaner( 2, show)
-
- function attributes.registercleaner(a,f)
- cleaners[a] = f
- end
-
- implement {
- name = "cleanupattributes",
- actions = attributes.cleanup,
- }
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-fin.mkiv b/Master/texmf-dist/tex/context/base/mkiv/node-fin.mkiv
index 086b19ae5dc..2bf0e0806cd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-fin.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-fin.mkiv
@@ -19,6 +19,7 @@
\unprotect
\registerctxluafile{node-shp}{optimize}
+% \registerctxluafile{node-fin}{autosuffix,optimize} % we might generalize this one
\registerctxluafile{node-fin}{optimize} % we might generalize this one
% we might have two variants at some point (efficiency)
@@ -36,8 +37,8 @@
\newcount\c_syst_attr_trigger
-\edef\startinheritattributes{\attribute\triggerattribute\plusone}
-\edef\stopinheritattributes {\attribute\triggerattribute\attributeunsetvalue}
+\edef\startinheritattributes{\c_attr_trigger\plusone}
+\edef\stopinheritattributes {\c_attr_trigger\attributeunsetvalue}
\def\syst_attr_trigger_copy_yes{\afterassignment\syst_attr_trigger_copy_indeed\c_syst_attr_trigger}
\def\syst_attr_trigger_dump_yes{\afterassignment\syst_attr_trigger_dump_indeed\c_syst_attr_trigger}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-fnt.lua b/Master/texmf-dist/tex/context/base/mkiv/node-fnt.lua
index 1b245639b78..f3bb6228fe0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-fnt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-fnt.lua
@@ -45,13 +45,12 @@ local nuts = nodes.nuts
local getid = nuts.getid
local getsubtype = nuts.getsubtype
-local getdisc = nuts.getdisc
+local getreplace = nuts.getreplace
local getnext = nuts.getnext
local getprev = nuts.getprev
local getboth = nuts.getboth
local getdata = nuts.getdata
local getglyphdata = nuts.getglyphdata
------ getdisc = nuts.getdisc
local setchar = nuts.setchar
local setlink = nuts.setlink
@@ -139,37 +138,14 @@ fonts.hashes.processes = fontprocesses
-- inside a run which means that we need to keep track of this which in turn complicates matters
-- in a way i don't like
--- we need to deal with the basemode fonts here and can only run over ranges as we
--- otherwise get luatex craches due to all kind of asserts in the disc/lig builder
+-- we need to deal with the basemode fonts here and can only run over ranges as we otherwise get
+-- luatex craches due to all kind of asserts in the disc/lig builder
+
+-- there is no gain in merging used (dynamic 0) and dynamics apart from a bit less code
local ligaturing = nuts.ligaturing
local kerning = nuts.kerning
--- -- -- this will go away
---
--- local disccodes = nodes.disccodes
--- local explicitdisc_code = disccodes.explicit
--- local automaticdisc_code = disccodes.automatic
--- local expanders = nil
---
--- function fonts.setdiscexpansion(v)
--- if v == nil or v == true then
--- expanders = languages and languages.expanders
--- elseif type(v) == "table" then
--- expanders = v
--- else
--- expanders = false
--- end
--- end
---
--- function fonts.getdiscexpansion()
--- return expanders and true or false
--- end
---
--- fonts.setdiscexpansion(true)
---
--- -- -- till here
-
local function start_trace(head)
run = run + 1
report_fonts()
@@ -193,19 +169,15 @@ local function start_trace(head)
end
end
-local function stop_trace(u,usedfonts,a,attrfonts,b,basefonts,r,redundant,e,expanders)
+local function stop_trace(u,usedfonts,a,attrfonts,b,basefonts,r,redundant)
report_fonts()
report_fonts("statics : %s",u > 0 and concat(keys(usedfonts)," ") or "none")
report_fonts("dynamics: %s",a > 0 and concat(keys(attrfonts)," ") or "none")
report_fonts("built-in: %s",b > 0 and b or "none")
report_fonts("removed : %s",r > 0 and r or "none")
- -- if expanders then
- -- report_fonts("expanded: %s",e > 0 and e or "none")
- -- end
report_fonts()
end
-
do
local usedfonts
@@ -221,7 +193,7 @@ do
local lastproc
local lastnone
- local a, u, b, r, e
+ local a, u, b, r
local function protectnone()
protect_glyphs(firstnone,lastnone)
@@ -307,7 +279,7 @@ do
lastproc = nil
lastnone = nil
- a, u, b, r, e = 0, 0, 0, 0, 0
+ a, u, b, r = 0, 0, 0, 0
if trace_fontrun then
start_trace(head)
@@ -425,15 +397,13 @@ do
end
if force_discrun then
-
-- basefont is not supported in disc only runs ... it would mean a lot of
- -- ranges .. we could try to run basemode as a separate processor run but
- -- not for now (we can consider it when the new node code is tested
+ -- ranges .. we could try to run basemode as a separate processor run but not
+ -- for now (we can consider it when the new node code is tested
for d in nextdisc, head do
- -- we could use first_glyph, only doing replace is good enough because
- -- pre and post are normally used for hyphens and these come from fonts
- -- that part of the hyphenated word
- local _, _, r = getdisc(d)
+ -- doing only replace is good enough because pre and post are normally used
+ -- for hyphens and these come from fonts that part of the hyphenated word
+ local r = getreplace(d)
if r then
local prevfont = nil
local prevattr = nil
@@ -465,19 +435,13 @@ do
if firstnone then
protectnone()
end
- -- elseif expanders then
- -- local subtype = getsubtype(d)
- -- if subtype == automaticdisc_code or subtype == explicitdisc_code then
- -- expanders[subtype](d)
- -- e = e + 1
- -- end
end
end
end
if trace_fontrun then
- stop_trace(u,usedfonts,a,attrfonts,b,basefonts,r,redundant,e,expanders)
+ stop_trace(u,usedfonts,a,attrfonts,b,basefonts,r,redundant)
end
-- in context we always have at least 2 processors
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-gcm.lua b/Master/texmf-dist/tex/context/base/mkiv/node-gcm.lua
new file mode 100644
index 00000000000..5b598f6b033
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-gcm.lua
@@ -0,0 +1,96 @@
+if not modules then modules = { } end modules ['node-gmc'] = {
+ version = 1.001,
+ comment = "companion to node-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type, tostring = type, tostring
+
+local nodes = nodes
+local nodecodes = nodes.nodecodes
+local ligature_code = nodes.glyphcodes.ligature
+local nuts = nodes.nuts
+
+local getnext = nuts.getnext
+local getsubtype = nuts.getsubtype
+local getprev = nuts.getprev
+local setlink = nuts.setlink
+local nextglyph = nuts.traversers.glyph
+local copy_node = nuts.copy
+local isglyph = nuts.isglyph
+
+local report_error = logs.reporter("node-aux:error")
+
+local get_components = node.direct.getcomponents
+local set_components = node.direct.setcomponents
+
+local function copy_no_components(g,copyinjection)
+ local components = get_components(g)
+ if components then
+ set_components(g)
+ local n = copy_node(g)
+ if copyinjection then
+ copyinjection(n,g)
+ end
+ set_components(g,components)
+ -- maybe also upgrade the subtype but we don't use it anyway
+ return n
+ else
+ local n = copy_node(g)
+ if copyinjection then
+ copyinjection(n,g)
+ end
+ return n
+ end
+end
+
+local function copy_only_glyphs(current)
+ local head = nil
+ local previous = nil
+ for n in nextglyph, current do
+ n = copy_node(n)
+ if head then
+ setlink(previous,n)
+ else
+ head = n
+ end
+ previous = n
+ end
+ return head
+end
+
+-- start is a mark and we need to keep that one
+
+local function count_components(start,marks)
+ local char = isglyph(start)
+ if char then
+ if getsubtype(start) == ligature_code then
+ local n = 0
+ local components = get_components(start)
+ while components do
+ n = n + count_components(components,marks)
+ components = getnext(components)
+ end
+ return n
+ elseif not marks[char] then
+ return 1
+ end
+ end
+ return 0
+end
+
+local function flush_components()
+ -- this is a no-op in mkiv / generic
+end
+
+nuts.set_components = set_components
+nuts.get_components = get_components
+nuts.copy_only_glyphs = copy_only_glyphs
+nuts.copy_no_components = copy_no_components
+nuts.count_components = count_components
+nuts.flush_components = flush_components
+
+nuts.setcomponents = function() report_error("unsupported: %a","setcomponents") end
+nuts.getcomponents = function() report_error("unsupported: %a","getcomponents") end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/node-ini.lua
index 8ebec4a1c62..701e3efa92c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-ini.lua
@@ -78,19 +78,18 @@ local dircodes = mark(getsubtypes("dir"))
local glyphcodes = mark(getsubtypes("glyph"))
local disccodes = mark(getsubtypes("disc"))
local gluecodes = mark(getsubtypes("glue"))
-local leadercodes = mark(getsubtypes("leader"))
local fillcodes = mark(getsubtypes("fill"))
local boundarycodes = mark(getsubtypes("boundary"))
local penaltycodes = mark(getsubtypes("penalty"))
local kerncodes = mark(getsubtypes("kern"))
-local margincodes = CONTEXTLMTXMODE == 0 and mark(getsubtypes("marginkern")) or { }
+local margincodes = mark(getsubtypes("marginkern"))
local mathcodes = mark(getsubtypes("math"))
local noadcodes = mark(getsubtypes("noad"))
local radicalcodes = mark(getsubtypes("radical"))
local accentcodes = mark(getsubtypes("accent"))
local fencecodes = mark(getsubtypes("fence"))
----- fractioncodes = mark(getsubtypes("fraction"))
-local localparcodes = allocate { [0] = "new_graf", "local_box", "hmode_par", "penalty", "math" } -- only in luametatex now
+local parcodes = allocate { [0] = "vmode_par", "local_box", "hmode_par", "penalty", "math" }
local function simplified(t)
local r = { }
@@ -104,13 +103,13 @@ local nodecodes = simplified(node.types())
local whatcodes = simplified(node.whatsits and node.whatsits() or { })
local usercodes = allocate {
- [ 97] = "attribute", -- a
- [100] = "number", -- d
- [102] = "float", -- f
- [108] = "lua", -- l
- [110] = "node", -- n
- [115] = "string", -- s
- [116] = "token" -- t
+ [ 97] = "attribute", -- a
+ [100] = "number", -- d
+ [102] = "float", -- f
+ [108] = "lua", -- l
+ [110] = "node", -- n
+ [115] = "string", -- s
+ [116] = "token" -- t
}
local noadoptions = allocate {
@@ -125,23 +124,9 @@ local noadoptions = allocate {
right = 0x14 + 0x08,
}
--- local directionvalues = mark(getvalues("dir"))
--- local gluevalues = mark(getvalues("glue"))
--- local literalvalues = mark(getvalues("literal"))
-
local dirvalues = allocate {
- [0] = "TLT",
- [1] = "TRT",
- [2] = "LTL",
- [3] = "RTT",
-}
-
-local gluevalues = allocate {
- [0] = "normal",
- [1] = "fi",
- [2] = "fil",
- [3] = "fill",
- [4] = "filll",
+ [0] = "lefttoright",
+ [1] = "righttoleft",
}
local literalvalues = allocate {
@@ -154,6 +139,8 @@ local literalvalues = allocate {
[6] = "special",
}
+local gluevalues = mark(getvalues("glue"))
+
gluecodes = allocate(swapped(gluecodes,gluecodes))
dircodes = allocate(swapped(dircodes,dircodes))
boundarycodes = allocate(swapped(boundarycodes,boundarycodes))
@@ -171,35 +158,39 @@ margincodes = allocate(swapped(margincodes,margincodes))
disccodes = allocate(swapped(disccodes,disccodes))
accentcodes = allocate(swapped(accentcodes,accentcodes))
fencecodes = allocate(swapped(fencecodes,fencecodes))
-localparcodes = allocate(swapped(localparcodes,localparcodes))
+parcodes = allocate(swapped(parcodes,parcodes))
rulecodes = allocate(swapped(rulecodes,rulecodes))
-leadercodes = allocate(swapped(leadercodes,leadercodes))
usercodes = allocate(swapped(usercodes,usercodes))
noadoptions = allocate(swapped(noadoptions,noadoptions))
dirvalues = allocate(swapped(dirvalues,dirvalues))
gluevalues = allocate(swapped(gluevalues,gluevalues))
literalvalues = allocate(swapped(literalvalues,literalvalues))
+if not nodecodes.delimiter then
+ -- as in luametatex / lmtx
+ nodecodes.delimiter = nodecodes.delim
+ nodecodes[nodecodes.delimiter] = "delimiter"
+ nodecodes.delim = nil
+end
+
+if not nodecodes.par then
+ -- as in luametatex / lmtx
+ local p = nodecodes.localpar
+ nodecodes.par = p
+ nodecodes[p] = "par"
+end
+
if not gluecodes.indentskip then
- gluecodes.indentskip = gluecodes.userskip
- gluecodes.lefthangskip = gluecodes.userskip
- gluecodes.righthangskip = gluecodes.userskip
- gluecodes.correctionskip = gluecodes.userskip
- gluecodes.intermathskip = gluecodes.userskip
+ gluecodes.indentskip = gluecodes.userskip
+ gluecodes.lefthangskip = gluecodes.userskip
+ gluecodes.righthangskip = gluecodes.userskip
+ gluecodes.correctionskip = gluecodes.userskip
+ gluecodes.intermathskip = gluecodes.userskip
+ gluecodes.parfillleftskip = gluecodes.parfillskip
+ gluecodes.parfillrightskip = gluecodes.parfillskip
end
-if CONTEXTLMTXMODE > 0 then
- whatcodes.literal = 0x1 whatcodes[0x1] = "literal"
- whatcodes.latelua = 0x2 whatcodes[0x2] = "latelua"
- whatcodes.userdefined = 0x3 whatcodes[0x3] = "userdefined"
- whatcodes.savepos = 0x4 whatcodes[0x4] = "savepos"
- whatcodes.save = 0x5 whatcodes[0x5] = "save"
- whatcodes.restore = 0x6 whatcodes[0x6] = "restore"
- whatcodes.setmatrix = 0x7 whatcodes[0x7] = "setmatrix"
- whatcodes.open = 0x8 whatcodes[0x8] = "open"
- whatcodes.close = 0x9 whatcodes[0x9] = "close"
- whatcodes.write = 0xA whatcodes[0xA] = "write"
-elseif not whatcodes.literal then
+if not whatcodes.literal then
whatcodes.literal = whatcodes.pdfliteral
whatcodes.save = whatcodes.pdfsave
whatcodes.restore = whatcodes.pdfrestore
@@ -223,18 +214,14 @@ nodes.disccodes = disccodes
nodes.accentcodes = accentcodes
nodes.radicalcodes = radicalcodes
nodes.fencecodes = fencecodes
-nodes.localparcodes = localparcodes
+nodes.parcodes = parcodes
nodes.rulecodes = rulecodes
-nodes.leadercodes = leadercodes
nodes.usercodes = usercodes
nodes.noadoptions = noadoptions
nodes.dirvalues = dirvalues
nodes.gluevalues = gluevalues
nodes.literalvalues = literalvalues
-dirvalues.lefttoright = 0
-dirvalues.righttoleft = 1
-
nodes.subtypes = allocate {
[nodecodes.accent] = accentcodes,
[nodecodes.boundary] = boundarycodes,
@@ -245,7 +232,7 @@ nodes.subtypes = allocate {
[nodecodes.glyph] = glyphcodes,
[nodecodes.hlist] = listcodes,
[nodecodes.kern] = kerncodes,
- [nodecodes.localpar] = localparcodes,
+ [nodecodes.par] = parcodes,
-- [nodecodes.marginkern] = margincodes,
[nodecodes.math] = mathcodes,
[nodecodes.noad] = noadcodes,
@@ -255,31 +242,28 @@ nodes.subtypes = allocate {
-- [nodecodes.user] = usercodes,
[nodecodes.vlist] = listcodes,
[nodecodes.whatsit] = whatcodes,
+ [nodecodes.marginkern] = margincodes
}
-if CONTEXTLMTXMODE == 0 then
- nodes.subtypes[nodecodes.marginkern] = margincodes
-end
-
table.setmetatableindex(nodes.subtypes,function(t,k)
local v = { }
t[k] = v
return v
end)
-nodes.skipcodes = gluecodes -- more friendly
-nodes.directioncodes = dircodes -- more friendly
-nodes.whatsitcodes = whatcodes -- more official
+-- a few more friendly aliases:
+
+nodes.skipcodes = gluecodes
+nodes.directioncodes = dircodes
+nodes.whatsitcodes = whatcodes
nodes.marginkerncodes = margincodes
nodes.discretionarycodes = disccodes
-nodes.directionvalues = dirvalues -- more friendly
-nodes.skipvalues = gluevalues -- more friendly
-nodes.literalvalues = literalvalues -- more friendly
+nodes.directionvalues = dirvalues
+nodes.skipvalues = gluevalues
+nodes.literalvalues = literalvalues
glyphcodes.glyph = glyphcodes.character
-localparcodes.vmode_par = localparcodes.new_graf
-
listcodes.row = listcodes.alignment
listcodes.column = listcodes.alignment
@@ -307,7 +291,6 @@ nodes.codes = allocate { -- mostly for listing
accent = accentcodes,
fence = fencecodes,
rule = rulecodes,
- leader = leadercodes,
user = usercodes,
noadoptions = noadoptions,
}
@@ -351,18 +334,3 @@ trackers.register("system.showcodes", nodes.showcodes)
if node.fix_node_lists then
node.fix_node_lists(false)
end
-
--- We use the real node code numbers.
-
-if CONTEXTLMTXMODE > 0 then
-
- local texchardef = tex.chardef
-
- if texchardef then
- for i=0,nodecodes.glyph do
- texchardef(nodecodes[i] .. "nodecode",i)
- end
- tex.set("internalcodesmode",1)
- end
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/node-ini.mkiv
index 5bf53cd2d01..072cb319aad 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-ini.mkiv
@@ -17,16 +17,13 @@
\newcount\filterstate \filterstate\plusone % hm, public
-\ifcase\contextlmtxmode \else
- \registerctxluafile{node-cmp}{}
-\fi
-
\registerctxluafile{node-ini}{}
\registerctxluafile{node-met}{}
\registerctxluafile{node-nut}{}
\registerctxluafile{node-res}{}
%registerctxluafile{node-ppt}{} % experimental, not used so probably useless
\registerctxluafile{node-aux}{}
+\registerctxluafile{node-gcm}{}
\registerctxluafile{node-tst}{}
\registerctxluafile{node-tra}{} % we might split it off (module)
\registerctxluafile{node-snp}{}
@@ -35,7 +32,7 @@
\registerctxluafile{node-dir}{} % experimental, not yet (and maybe never) used
\registerctxluafile{node-pro}{}
\registerctxluafile{node-ser}{}
-\registerctxluafile{node-ext}{}
+%registerctxluafile{node-ext}{}
\registerctxluafile{node-acc}{} % experimental
%registerctxluafile{node-prp}{} % makes no sense (yet)
\registerctxluafile{node-scn}{}
@@ -53,14 +50,4 @@
\unexpanded\def\visualizenextnodes{\dowithnextbox{\ctxlua{nodes.visualizebox(\number\nextbox,false,true)}}}
\unexpanded\def\visualizeflatnodes{\dowithnextbox{\ctxlua{nodes.visualizebox(\number\nextbox,true,true)}}}
-\unexpanded\def\starttracingnodes[#1]{\ctxlua{nodes.tracers.characters.start("#1")}}
-\unexpanded\def\stoptracingnodes {\ctxlua{nodes.tracers.characters.stop()}}
-
-% \starttext
-% \starttracingnodes[characters]
-% \input tufte \par
-% \input tufte \par
-% \stoptracingnodes
-% \stoptext
-
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ltp.lua b/Master/texmf-dist/tex/context/base/mkiv/node-ltp.lua
index a85bdfe0128..6cb9e8d102f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-ltp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-ltp.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['node-par'] = {
version = 1.001,
+ optimize = true,
comment = "companion to node-par.mkiv",
author = "Hans Hagen",
copyright = "ConTeXt Development Team",
@@ -259,7 +260,6 @@ local nodepool = nuts.pool
local nodecodes = nodes.nodecodes
local kerncodes = nodes.kerncodes
-local margincodes = nodes.margincodes
local disccodes = nodes.disccodes
local mathcodes = nodes.mathcodes
local fillcodes = nodes.fillcodes
@@ -281,12 +281,11 @@ local unset_code = nodecodes.unset
local marginkern_code = nodecodes.marginkern
local dir_code = nodecodes.dir
local boundary_code = nodecodes.boundary
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local protrusionboundary_code = nodes.boundarycodes.protrusion
-local leaders_code = nodes.leadercodes.leaders
+local leaders_code = nodes.gluecodes.leaders
local indentlist_code = nodes.listcodes.indent
-local ligatureglyph_code = nodes.glyphcodes.ligature
local cancel_code = nodes.dircodes.cancel
local userkern_code = kerncodes.userkern
@@ -294,9 +293,6 @@ local italickern_code = kerncodes.italiccorrection
local fontkern_code = kerncodes.fontkern
local accentkern_code = kerncodes.accentkern
-local leftmargin_code = margincodes.left
------ rightmargin_code = margincodes.right
-
local automaticdisc_code = disccodes.automatic
local regulardisc_code = disccodes.regular
local firstdisc_code = disccodes.first
@@ -349,6 +345,11 @@ local new_hlist = nodepool.hlist
local getnormalizeline = nodes.getnormalizeline
+local packing_exactly = "exactly"
+local packing_additional = "additional"
+local packing_expanded = CONTEXTLMTXMODE > 0 and "expanded" or "cal_expand_ratio"
+local packing_substitute = CONTEXTLMTXMODE > 0 and "substiture" or "subst_ex_font"
+
-- helpers --
-- It makes more sense to move the somewhat messy dir state tracking
@@ -1321,7 +1322,7 @@ do
while current_break do
- -- hm, here we have head == localpar and in the engine it's a temp node
+ -- hm, here we have head == par and in the engine it's a temp node
head = inject_dirs_at_begin_of_line(dirstack,head)
@@ -1461,7 +1462,7 @@ do
p = nil
end
break
- elseif id == localpar_code then
+ elseif id == par_code then
break
elseif id == temp_code then
-- Go on.
@@ -1558,29 +1559,29 @@ do
start = insert_node_before(start,start,ls)
end
if normalize > 0 then
- local localpar = nil
- local localdir = nil
+ local par = nil
+ local dir = nil
local indent = nil
- local localpars = nil
+ local pars = nil
local notflocal = 0
for n, id, subtype in nextnode, start do
if id == hlist_code then
if normalize > 1 and subtype == indentlist_code then
indent = n
end
- elseif id == localpar_code then
+ elseif id == par_code then
if start_of_par(n) then --- maybe subtype check instead
- localpar = n
+ par = n
elseif noflocals then
noflocals = noflocals + 1
- localpars[noflocals] = n
+ pars[noflocals] = n
else
noflocals = 1
- localpars = { n }
+ pars = { n }
end
elseif id == dir_code then
- if localpar and not localdir and subtype(n) == cancel_code then
- localdir = n
+ if par and not dir and subtype(n) == cancel_code then
+ dir = n
end
end
end
@@ -1589,14 +1590,14 @@ do
setattributelist(i,start)
replace_node(indent,i)
end
- if localdir then
- local d = new_direction((getdirection(localpar)))
+ if dir then
+ local d = new_direction((getdirection(par)))
setattributelist(d,start)
- replace_node(localpar,d)
+ replace_node(par,d)
end
- if localpars then
+ if pars then
for i=1,noflocals do
- start = remove_node(start,localpars[i],true)
+ start = remove_node(start,pars[i],true)
end
end
end
@@ -1651,9 +1652,9 @@ do
local finished_line = nil
if adjust_spacing > 0 then
statistics.nofadjustedlines = statistics.nofadjustedlines + 1
- finished_line = xpack_nodes(start,cur_width,"cal_expand_ratio",par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
+ finished_line = xpack_nodes(start,cur_width,packing_expanded,par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
else
- finished_line = xpack_nodes(start,cur_width,"exactly",par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
+ finished_line = xpack_nodes(start,cur_width,packing_exactly,par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
end
if protrude_chars > 0 then
statistics.nofprotrudedlines = statistics.nofprotrudedlines + 1
@@ -1717,7 +1718,7 @@ do
local id = getid(next)
if id == glyph_code then
break
- elseif id == localpar_code then
+ elseif id == par_code then
-- nothing
elseif id < math_code then
-- messy criterium
@@ -1754,7 +1755,7 @@ par.head = head
if getnext(h) then
report_parbuilders("something is left over")
end
- if getid(h) ~= localpar_code then
+ if getid(h) ~= par_code then
report_parbuilders("no local par node")
end
end
@@ -2452,7 +2453,7 @@ par.head = head
if current then
local id = getid(current)
- if id == localpar_code then
+ if id == par_code then
par.init_internal_left_box = getfield(current,"box_left")
par.init_internal_left_box_width = getfield(current,"box_left_width")
par.internal_pen_inter = getfield(current,"pen_inter")
@@ -2615,7 +2616,7 @@ par.head = head
p_active, n_active = try_break(getpenalty(current), unhyphenated_code, par, first_p, current, checked_expansion)
elseif id == dir_code then
par.line_break_dir = checked_line_dir(dirstack,current) or par.line_break_dir
- elseif id == localpar_code then
+ elseif id == par_code then
par.internal_pen_inter = getfield(current,"pen_inter")
par.internal_pen_broken = getfield(current,"pen_broken")
par.internal_left_box = getfield(current,"box_left")
@@ -2881,7 +2882,7 @@ do
local function common_message(hlist,line,str)
write_nl("")
- if status.output_active then -- unset
+ if CONTEXTLMTXMODE > 0 and tex.getoutputactive() or status.output_active then
write(str," has occurred while \\output is active")
else
write(str)
@@ -2961,7 +2962,7 @@ do
setlist(hlist,head)
end
- local cal_expand_ratio = method == "cal_expand_ratio" or method == "subst_ex_font"
+ local cal_expand_ratio = method == packing_expanded or method == packing_substitute
direction = direction or texget("textdir")
@@ -3136,7 +3137,7 @@ do
if pre_adjust_tail then
pre_adjust_tail.next = nil -- todo
end
- if method == "additional" then
+ if method == packing_additional then
width = width + natural
end
setwhd(hlist,width,height,depth)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-met.lua b/Master/texmf-dist/tex/context/base/mkiv/node-met.lua
index db079c11628..31f9a16b28b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-met.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-met.lua
@@ -1,4 +1,4 @@
-if not modules then modules = { } end modules ['node-nut'] = {
+if not modules then modules = { } end modules ['node-MET'] = {
version = 1.001,
comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -102,7 +102,7 @@ nodes.uses_font = node.uses_font
nodes.first_glyph = node.first_glyph
nodes.has_glyph = node.has_glyph or node.first_glyph
-nodes.current_attr = node.current_attr
+nodes.current_attributes = node.current_attributes or node.current_attr
nodes.has_field = node.has_field
nodes.last_node = node.last_node
nodes.usedlist = node.usedlist
@@ -629,233 +629,3 @@ end
nodes.keys = keys -- [id][subtype]
nodes.fields = nodefields -- (n)
-
-if not nodes.count then
-
- local type = type
-
- local direct = node.direct
- local todirect = direct.tovaliddirect
- local tonode = direct.tonode
-
- local count = direct.count
- local length = direct.length
- local slide = direct.slide
-
- function node.count(id,first,last)
- return count(id,first and todirect(first), last and todirect(last) or nil)
- end
-
- function node.length(first,last)
- return length(first and todirect(first), last and todirect(last) or nil)
- end
-
- function node.slide(n)
- if n then
- n = slide(todirect(n))
- if n then
- return tonode(n)
- end
- end
- return nil
- end
-
- local hyphenating = direct.hyphenating
- local ligaturing = direct.ligaturing
- local kerning = direct.kerning
-
- -- kind of inconsistent
-
- function node.hyphenating(first,last)
- if first then
- local h, t = hyphenating(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
- function node.ligaturing(first,last)
- if first then
- local h, t = ligaturing(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
- function node.kerning(first,last)
- if first then
- local h, t = kerning(todirect(first), last and todirect(last) or nil)
- return h and tonode(h) or nil, t and tonode(t) or nil, true
- else
- return nil, false
- end
- end
-
- local protect_glyph = direct.protect_glyph
- local unprotect_glyph = direct.unprotect_glyph
- local protect_glyphs = direct.protect_glyphs
- local unprotect_glyphs = direct.unprotect_glyphs
-
- function node.protect_glyphs(first,last)
- protect_glyphs(todirect(first), last and todirect(last) or nil)
- end
-
- function node.unprotect_glyphs(first,last)
- unprotect_glyphs(todirect(first), last and todirect(last) or nil)
- end
-
- function node.protect_glyph(first)
- protect_glyph(todirect(first))
- end
-
- function node.unprotect_glyph(first)
- unprotect_glyph(todirect(first))
- end
-
- local flatten_discretionaries = direct.flatten_discretionaries
- local check_discretionaries = direct.check_discretionaries
- local check_discretionary = direct.check_discretionary
-
- function node.flatten_discretionaries(first)
- local h, count = flatten_discretionaries(todirect(first))
- return tonode(h), count
- end
-
- function node.check_discretionaries(n)
- check_discretionaries(todirect(n))
- end
-
- function node.check_discretionary(n)
- check_discretionary(todirect(n))
- end
-
- local hpack = direct.hpack
- local vpack = direct.vpack
- local list_to_hlist = direct.mlist_to_hlist
-
- function node.hpack(head,...)
- local h, badness = hpack(head and todirect(head) or nil,...)
- return tonode(h), badness
- end
-
- function node.vpack(head,...)
- local h, badness = vpack(head and todirect(head) or nil,...)
- return tonode(h), badness
- end
-
- function node.mlist_to_hlist(head,...)
- return tonode(mlist_to_hlist(head and todirect(head) or nil,...))
- end
-
- local end_of_math = direct.end_of_math
- local find_attribute = direct.find_attribute
- local first_glyph = direct.first_glyph
-
- function node.end_of_math(n)
- if n then
- n = end_of_math(todirect(n))
- if n then
- return tonode(n)
- end
- end
- return nil
- end
-
- function node.find_attribute(n,a)
- if n then
- local v, n = find_attribute(todirect(n),a)
- if n then
- return v, tonode(n)
- end
- end
- return nil
- end
-
- function node.first_glyph(first,last)
- local n = first_glyph(todirect(first), last and todirect(last) or nil)
- return n and tonode(n) or nil
- end
-
- local dimensions = direct.dimensions
- local rangedimensions = direct.rangedimensions
- local effective_glue = direct.effective_glue
-
- function node.dimensions(a,b,c,d,e)
- if type(a) == "userdata" then
- a = todirect(a)
- if type(b) == "userdata" then
- b = todirect(b)
- end
- return dimensions(a,b)
- else
- d = todirect(d)
- if type(e) == "userdata" then
- e = todirect(e)
- end
- return dimensions(a,b,c,d,e)
- end
- return 0, 0, 0
- end
-
- function node.rangedimensions(parent,first,last)
- return rangedimenensions(todirect(parent),todirect(first),last and todirect(last))
- end
-
- function node.effective_glue(list,parent)
- return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil)
- end
-
- local uses_font = direct.uses_font
- local has_glyph = direct.has_glyph
- local protrusion_skippable = direct.protrusion_skippable
- local prepend_prevdepth = direct.prepend_prevdepth
- local make_extensible = direct.make_extensible
-
- function node.uses_font(n,f)
- return uses_font(todirect(n),f)
- end
-
- function node.has_glyph(n)
- return has_glyph(todirect(n))
- end
-
- function node.protrusion_skippable(n)
- return protrusion_skippable(todirect(n))
- end
-
- function node.prepend_prevdepth(n)
- local n, d = prepend_prevdepth(todirect(n))
- return tonode(n), d
- end
-
- function node.make_extensible(...)
- local n = make_extensible(...)
- return n and tonode(n) or nil
- end
-
- local last_node = direct.last_node
-
- function node.last_node()
- local n = last_node()
- return n and tonode(n) or nil
- end
-
- local is_zero_glue = direct.is_zero_glue
- local getglue = direct.getglue
- local setglue = direct.setglue
-
- function node.is_zero_glue(n)
- return is_zero_glue(todirect(n))
- end
-
- function node.get_glue(n)
- return get_glue(todirect(n))
- end
-
- function node.set_glue(n)
- return set_glue(todirect(n))
- end
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-mig.lua b/Master/texmf-dist/tex/context/base/mkiv/node-mig.lua
index 6c10625eb64..13414c560c7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-mig.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-mig.lua
@@ -14,157 +14,174 @@ local trace_migrations = false trackers.register("nodes.migrations", function(v)
local report_nodes = logs.reporter("nodes","migrations")
-local attributes = attributes
-local nodes = nodes
-local enableaction = nodes.tasks.enableaction
+local attributes = attributes
+local nodes = nodes
-local nuts = nodes.nuts
-local tonut = nuts.tonut
+local nuts = nodes.nuts
+local tonut = nuts.tonut
-local getnext = nuts.getnext
-local getid = nuts.getid
-local getlist = nuts.getlist
------ getattr = nuts.getattr
-local getprop = nuts.getprop
+local getnext = nuts.getnext
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getprop = nuts.getprop
------ setattr = nuts.setattr
-local setprop = nuts.setprop
-local setlink = nuts.setlink
-local setlist = nuts.setlist
-local setprev = nuts.setprev
-local setnext = nuts.setnext
-local setboth = nuts.setboth
+local setprop = nuts.setprop
+local setlink = nuts.setlink
+local setlist = nuts.setlist
+local setprev = nuts.setprev
+local setnext = nuts.setnext
+local setboth = nuts.setboth
-local remove_node = nuts.remove
+local remove_node = nuts.remove
+local count = nuts.count
-local nodecodes = nodes.nodecodes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local insert_code = nodecodes.ins
-local mark_code = nodecodes.mark
+local nodecodes = nodes.nodecodes
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local insert_code = nodecodes.ins
+local mark_code = nodecodes.mark
-local a_migrated = attributes.private("migrated")
+local a_migrated = attributes.private("migrated")
+local trialtypesetting = context.trialtypesetting
-local migrate_inserts, migrate_marks, inserts_too
+local migrate_inserts = false
+local migrate_marks = false
-local t_inserts, t_marks, t_sweeps = 0, 0, 0
+local t_inserts = 0
+local t_marks = 0
+local t_sweeps = 0
-local function locate(head,first,last,ni,nm)
+local function locate(head,first,last)
local current = head
while current do
local id = getid(current)
if id == vlist_code or id == hlist_code then
local list = getlist(current)
if list then
- list, first, last, ni, nm = locate(list,first,last,ni,nm)
- setlist(current,list)
+ local l
+ l, first, last = locate(list,first,last)
+ if l ~= list then
+ setlist(current,l)
+ end
end
current = getnext(current)
- elseif migrate_inserts and id == insert_code then
- local insert
- head, current, insert = remove_node(head,current)
- if first then
- setnext(insert)
- setlink(last,insert)
- else
- setboth(insert)
- first = insert
+ elseif id == insert_code then
+ if migrate_inserts then
+ local insert
+ head, current, insert = remove_node(head,current)
+ if first then
+ setnext(insert)
+ setlink(last,insert)
+ else
+ setboth(insert)
+ first = insert
+ end
+ last = insert
end
- last = insert
- ni = ni + 1
- elseif migrate_marks and id == mark_code then
- local mark
- head, current, mark = remove_node(head,current)
- if first then
- setnext(mark)
- setlink(last,mark)
- else
- setboth(mark)
- first = mark
+ elseif id == mark_code then
+ if migrate_marks then
+ local mark
+ head, current, mark = remove_node(head,current)
+ if first then
+ setnext(mark)
+ setlink(last,mark)
+ else
+ setboth(mark)
+ first = mark
+ end
+ last = mark
end
- last = mark
- nm = nm + 1
else
current = getnext(current)
end
end
- return head, first, last, ni, nm
+ return head, first, last
end
function nodes.handlers.migrate(head,where)
- if head then
+ if head and not trialtypesetting() then
if trace_migrations then
report_nodes("migration sweep %a",where)
end
local current = head
while current do
local id = getid(current)
- -- inserts_too is a temp hack, we should only do them when it concerns
- -- newly placed (flushed) inserts
-
- -- todo: getprop / setprop
-
- -- if id == vlist_code or id == hlist_code or (inserts_too and id == insert_code) and not getattr(current,a_migrated) then
- if id == vlist_code or id == hlist_code or (inserts_too and id == insert_code) and not getprop(current,"migrated") then
- -- setattr(current,a_migrated,1)
+ if (id == vlist_code or id == hlist_code or id == insert_code) and not getprop(current,"migrated") then
setprop(current,"migrated",true)
- t_sweeps = t_sweeps + 1
local h = getlist(current)
- local first, last, ni, nm
- while h do
- local id = getid(h)
- if id == vlist_code or id == hlist_code then
- h, first, last, ni, nm = locate(h,first,last,0,0)
+ if h then
+ t_sweeps = t_sweeps + 1
+ local first, last
+ while h do
+ local id = getid(h)
+ if id == vlist_code or id == hlist_code then
+ h, first, last = locate(h,first,last)
+ end
+ h = getnext(h)
end
- h = getnext(h)
- end
- if first then
- t_inserts = t_inserts + ni
- t_marks = t_marks + nm
- if trace_migrations and (ni > 0 or nm > 0) then
- report_nodes("sweep %a, container %a, %s inserts and %s marks migrated outwards during %a",
- t_sweeps,nodecodes[id],ni,nm,where)
- end
- -- inserts after head, use insert_after
- local n = getnext(current)
- if n then
- setlink(last,n)
+ if first then
+ if trace_migrations then
+ local ni = count(insert_code,first)
+ local nm = count(mark_code,first)
+ t_inserts = t_inserts + ni
+ t_marks = t_marks + nm
+ report_nodes("sweep %a, container %a, %s inserts and %s marks migrated outwards during %a",
+ t_sweeps,nodecodes[id],ni,nm,where)
+ end
+ local n = getnext(current)
+ if n then
+ setlink(last,n)
+ end
+ setlink(current,first)
+ current = last
end
- setlink(current,first)
- current = last
end
end
current = getnext(current)
end
- return head
end
+ return head
end
--- for the moment this way, this will disappear
-
-experiments.register("marks.migrate", function(v)
- if v then
- enableaction("mvlbuilders", "nodes.handlers.migrate")
+statistics.register("node migrations", function()
+ if trace_migrations and t_sweeps > 0 then
+ return format("%s sweeps, %s inserts moved, %s marks moved",t_sweeps,t_inserts,t_marks)
end
- migrate_marks = v
end)
-experiments.register("inserts.migrate", function(v)
- if v then
- enableaction("mvlbuilders", "nodes.handlers.migrate")
- end
- migrate_inserts = v
-end)
+-- Since we started with mkiv we had it as experiment but it is about time
+-- to have a more formal interface .. it's still optional due to possible
+-- side effects.
-experiments.register("inserts.migrate.nested", function(v)
- if v then
- enableaction("mvlbuilders", "nodes.handlers.migrate")
+local enableaction = nodes.tasks.enableaction
+local disableaction = nodes.tasks.disableaction
+
+local migrations = { }
+nodes.migrations = migrations
+local enabled = false
+
+local function check()
+ if migrate_marks or migrate_inserts then
+ if not enabled then
+ enableaction("mvlbuilders", "nodes.handlers.migrate")
+ enableaction("processors", "nodes.handlers.migrate")
+ enabled = true
+ end
+ else
+ if enabled then
+ disableaction("mvlbuilders", "nodes.handlers.migrate")
+ disableaction("processors", "nodes.handlers.migrate")
+ enabled = false
+ end
end
- inserts_too = v
-end)
+end
-statistics.register("node migrations", function()
- if trace_migrations and t_sweeps > 0 then
- return format("%s sweeps, %s inserts moved, %s marks moved",t_sweeps,t_inserts,t_marks)
- end
-end)
+function migrations.setmarks(v)
+ migrate_marks = v
+ check()
+end
+
+function migrations.setinserts(v)
+ migrate_inserts = v
+ check()
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-mig.mkiv b/Master/texmf-dist/tex/context/base/mkiv/node-mig.mkiv
index 010d009b35b..0e76e479447 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-mig.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-mig.mkiv
@@ -13,9 +13,9 @@
\writestatus{loading}{ConTeXt Node Support / Migrations}
-%D This is very experimental and although it is used in a
-%D real project it mostly serves a testbed for Taco and me so
-%D as prelude to extending the inserts mechanism.
+%D This is very experimental and although it is used in a real project it mostly
+%D serves a testbed for Taco and me so as prelude to extending the inserts
+%D mechanism.
%D
%D \starttyping
%D \automigrateinserts
@@ -42,20 +42,7 @@
\registerctxluafile{node-mig}{}
-\newtoks\everyautomigratefootnotes
-\newtoks\everyautomigratemarks
-
-\def\automigrateinserts{\the\everyautomigratefootnotes} % soon default but does not work (yet) for notes in captions (themselves inserts)
-\def\automigratemarks {\the\everyautomigratemarks}
-
-\appendtoks
- \let\postponenotes\relax
- \enableexperiments[inserts.migrate,inserts.migrate.nested]%
-\to \everyautomigratefootnotes
-
-\appendtoks
- \writestatus\m!system{migration of marks is normally not needed}%
- \enableexperiments[marks.migrate]%
-\to \everyautomigratemarks
+\protected\def\automigrateinserts{\setupinsertion[\c!anchoring=\v!auto]}
+ \let\automigratemarks \relax
\protect
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-nut.lua b/Master/texmf-dist/tex/context/base/mkiv/node-nut.lua
index e722bbd66a9..9909194e7ae 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-nut.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-nut.lua
@@ -1,4 +1,4 @@
-if not modules then modules = { } end modules ['node-met'] = {
+if not modules then modules = { } end modules ['node-nut'] = {
version = 1.001,
comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -200,11 +200,11 @@ nuts.unset_attribute = direct.unset_attribute
nuts.usedlist = direct.usedlist
nuts.uses_font = direct.uses_font
nuts.vpack = direct.vpack
-nuts.writable_spec = direct.writable_spec
nuts.write = direct.write
nuts.mlist_to_hlist = direct.mlist_to_hlist
nuts.has_dimensions = direct.has_dimensions
nuts.start_of_par = direct.start_of_par
+nuts.migrate = direct.migrate
if not nuts.mlist_to_hlist then
@@ -295,6 +295,7 @@ nuts.getdepth = direct.getdepth
nuts.setdepth = direct.setdepth
nuts.getshift = direct.getshift
nuts.setshift = direct.setshift
+nuts.gettotal = direct.gettotal
-- lmtx compatibility
@@ -307,6 +308,11 @@ nuts.setglyphdata = direct.setglyphdata or function(n,d) set_attribute(n,0,d
nuts.getruledata = direct.getglyphdata and getdata or function(n) return getfield(n,"transform") end
nuts.setruledata = direct.setglyphdata and setdata or function(n,d) return setfield(n,"transform",d) end
+-- maybe some day: [g|s]etglyphoptions and then use attribute for mkiv / generic but not now
+
+nuts.getoptions = direct.getoptions or function() return 0 end
+nuts.setoptions = direct.setoptions or function() end
+
-- so far
nuts.getnucleus = direct.getnucleus
@@ -315,6 +321,10 @@ nuts.getsup = direct.getsup
nuts.setsup = direct.setsup
nuts.getsub = direct.getsub
nuts.setsub = direct.setsub
+nuts.getsuppre = direct.getsuppre
+nuts.setsuppre = direct.setsuppre
+nuts.getsubpre = direct.getsubpre
+nuts.setsubpre = direct.setsubpre
nuts.getchar = direct.getchar
nuts.setchar = direct.setchar
@@ -326,6 +336,8 @@ nuts.setfam = direct.setfam
nuts.getboth = direct.getboth
nuts.setboth = direct.setboth
nuts.setlink = direct.setlink
+nuts.exchange = direct.exchange
+nuts.reverse = direct.reverse
nuts.setsplit = direct.setsplit
nuts.getlist = direct.getlist -- only hlist and vlist !
@@ -388,7 +400,7 @@ local d_setlink = direct.setlink
local d_setboth = direct.setboth
local d_getboth = direct.getboth
-local remove = CONTEXTLMTXMODE > 0 and d_remove_node or function(head,current,free_too)
+local remove = function(head,current,free_too)
if current then
local h, c = d_remove_node(head,current)
if free_too then
@@ -406,9 +418,9 @@ end
if not nuts.start_of_par then
- local localparcodes = nodes.localparcodes
- local hmodepar_code = localparcodes.vmode_par
- local vmodepar_code = localparcodes.hmode_par
+ local parcodes = nodes.parcodes
+ local hmodepar_code = parcodes.vmode_par
+ local vmodepar_code = parcodes.hmode_par
local getsubtype = nuts.getsubtype
@@ -421,6 +433,31 @@ end
-- for now
+if not nuts.exchange then
+
+ local d_getprev = direct.getprev
+ local d_getnext = direct.getnext
+ local d_setlink = direct.setlink
+
+ function nuts.exchange(head,first,second)
+ if first then
+ if not second then
+ second = d_getnext(first)
+ end
+ if second then
+ d_setlink(d_getprev(first),second,first,d_getnext(second))
+ if first == head then
+ return second
+ end
+ end
+ end
+ return head
+ end
+
+end
+
+-- for now
+
if not nuts.getpre then
local d_getdisc = direct.getdisc
@@ -436,6 +473,17 @@ if not nuts.getpre then
end
+if not nuts.gettotal then
+
+ local d_getheight = direct.getheight
+ local d_getdepth = direct.getdepth
+
+ function nuts.gettotal(n)
+ return (d_getheight(n) or 0) + (d_getdepth(n) or 0)
+ end
+
+end
+
-- alias
nuts.getsurround = nuts.getkern
@@ -768,8 +816,6 @@ nuts.tracedslide = tracedslide
nuts.untracedslide = untracedslide
nuts.nestedtracedslide = nestedtracedslide
--- nuts.slide = tracedslide
-
-- this might move
local propertydata = direct.get_properties_table(true)
@@ -833,6 +879,7 @@ local getstate = direct.getstate
local setstate = direct.setstate
if not setstate or not getstate then
+
setstate = function(n,v)
local p = propertydata[n]
if p then
@@ -841,6 +888,7 @@ if not setstate or not getstate then
propertydata[n] = { state = v }
end
end
+
getstate = function(n,v)
local p = propertydata[n]
if p then
@@ -853,11 +901,18 @@ if not setstate or not getstate then
return nil
end
end
- nuts.setstate = setstate
- nuts.getstate = getstate
end
-nuts.isdone = function(n,k)
+nuts.setstate = setstate
+nuts.getstate = getstate
+
+local getscript = direct.getscript or function(n,v) end -- elsewhere
+local setscript = direct.setscript or function(n,v) end -- elsewhere
+
+nuts.setscript = getscript
+nuts.getscript = setscript
+
+function nuts.isdone(n,k)
local p = propertydata[n]
if not p then
propertydata[n] = { [k] = true }
@@ -871,9 +926,6 @@ nuts.isdone = function(n,k)
return v
end
--- nodes.setprop = nodes.setproperty
--- nodes.getprop = nodes.getproperty
-
function nuts.copy_properties(source,target,what)
local newprops = propertydata[source]
if not newprops then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-pag.lua b/Master/texmf-dist/tex/context/base/mkiv/node-pag.lua
deleted file mode 100644
index 9b8202042c5..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/node-pag.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-if not modules then modules = { } end modules ['node-pag'] = {
- version = 1.001,
- comment = "companion to node-pag.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- this callback might disappear and come back in the same way
--- as par builders
-
-pagebuilders = pagebuilders or { }
-
-local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
-
-local actions = nodes.tasks.actions("pagebuilders")
-
-local function processor(head,groupcode,size,packtype,maxdepth,direction)
- starttiming(pagebuilders)
- local _, done = actions(head,groupcode,size,packtype,maxdepth,direction)
- stoptiming(pagebuilders)
- return (done and head) or true
--- return vpack(head)
-end
-
---~ callbacks.register('pre_output_filter', processor, "preparing output box")
-
---~ statistics.register("output preparation time", function()
---~ return statistics.elapsedseconds(pagebuilders)
---~ end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-pag.mkiv b/Master/texmf-dist/tex/context/base/mkiv/node-pag.mkiv
deleted file mode 100644
index 970939dcf76..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/node-pag.mkiv
+++ /dev/null
@@ -1,20 +0,0 @@
-%D \module
-%D [ file=node-pag,
-%D version=2008.09.30,
-%D title=\CONTEXT\ Node Macros,
-%D subtitle=Page Building,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Node Macros / Page Building}
-
-\unprotect
-
-\registerctxluafile{node-pag}{}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-par.lua b/Master/texmf-dist/tex/context/base/mkiv/node-par.lua
index d89edf6f4ca..5a0f0d2e94f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-par.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-par.lua
@@ -25,7 +25,7 @@ end
callbacks.register("insert_local_par",everypar,"after paragraph start")
local actions = sequencers.new {
- name = "newgraf",
+ name = "paragraph",
arguments = "mode,indented",
returnvalues = "indented",
results = "indented",
@@ -35,7 +35,7 @@ sequencers.appendgroup(actions,"before") -- user
sequencers.appendgroup(actions,"system") -- private
sequencers.appendgroup(actions,"after" ) -- user
-local function newgraf(mode,indented)
+local function paragraph(mode,indented)
local runner = actions.runner
if runner then
starttiming(builders)
@@ -45,4 +45,4 @@ local function newgraf(mode,indented)
return indented
end
-callbacks.register("new_graf",newgraf,"before paragraph start")
+callbacks.register("new_graf",paragraph,"before paragraph start")
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua b/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua
index ac43a84a368..098ed50c28e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['node-ref'] = {
version = 1.001,
+ optimize = true,
comment = "companion to node-ref.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -93,10 +94,11 @@ local glue_code = nodecodes.glue
local glyph_code = nodecodes.glyph
local rule_code = nodecodes.rule
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local leftskip_code = gluecodes.leftskip
local rightskip_code = gluecodes.rightskip
+local parfillleftskip_code = gluecodes.parfillleftskip
local parfillskip_code = gluecodes.parfillskip
----- linelist_code = listcodes.line
@@ -322,7 +324,8 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
local last = find_node_tail(first)
if getid(last) == glue_code and getsubtype(last) == rightskip_code then
local prev = getprev(last)
- moveright = getid(first) == glue_code and getsubtype(first) == leftskip_code
+ -- this can be more clever
+ moveright = getid(first) == glue_code and (getsubtype(first) == leftskip_code or getsubtype(first) == parfillleftskip_code)
if prev and getid(prev) == glue_code and getsubtype(prev) == parfillskip_code then
width = dimensions(current,first,getprev(prev)) -- maybe not current as we already take care of it
else
@@ -414,16 +417,29 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx
if r then
done[r] = done[r] - 1
end
- elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left?
- --
elseif id == dir_code then
local direction, pop = getdirection(current)
txtdir = not pop and direction -- we might need a stack
- elseif id == localpar_code then
+ elseif id == par_code then
if start_of_par(current) then
pardir = getdirection(current)
end
+ elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left?
+ --
else
+ if id == glue_code then
+ local subtype = getsubtype(current)
+ -- todo in lmtx: lefthangskip and righthangskip
+ if subtype == leftskip_code or subtype == parfillleftskip_code then
+ goto NEXT
+ elseif subtype == rightskip_code or subtype == parfillskip_code then
+ if reference and (done[reference] or 0) == 0 then
+ head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir)
+ reference, first, last, firstdir = nil, nil, nil, nil
+ end
+ goto NEXT
+ end
+ end
local r = getattr(current,attribute)
if not r then
-- just go on, can be kerns
@@ -431,7 +447,7 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx
reference, first, last, firstdir = r, current, current, txtdir
elseif r == reference then
last = current
- elseif (done[reference] or 0) == 0 then -- or id == glue_code and getsubtype(current) == right_skip_code
+ elseif (done[reference] or 0) == 0 then -- or (id == glue_code and getsubtype(current) == right_skip_code) then
if not skip or r > skip then -- maybe no > test
head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir)
reference, first, last, firstdir = nil, nil, nil, nil
@@ -440,6 +456,7 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx
reference, first, last, firstdir = r, current, current, txtdir
end
end
+ ::NEXT::
current = getnext(current)
end
if reference and (done[reference] or 0) == 0 then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-res.lua b/Master/texmf-dist/tex/context/base/mkiv/node-res.lua
index 1832a0d1e1b..478a46906e0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-res.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-res.lua
@@ -26,7 +26,6 @@ local gluecodes = nodes.gluecodes
local kerncodes = nodes.kerncodes
local rulecodes = nodes.rulecodes
local nodecodes = nodes.nodecodes
-local leadercodes = nodes.leadercodes
local boundarycodes = nodes.boundarycodes
local usercodes = nodes.usercodes
@@ -36,6 +35,7 @@ local glyph_code = nodecodes.glyph
local rule_code = nodecodes.rule
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
+local gluespec_code = nodecodes.gluespec
local whatsit_code = nodecodes.whatsit
local currentfont = font.current
@@ -163,6 +163,7 @@ local fontkern = register_nut(new_nut(kern_code,kerncodes.fontkern))
local italickern = register_nut(new_nut(kern_code,kerncodes.italiccorrection))
local penalty = register_nut(new_nut(nodecodes.penalty))
local glue = register_nut(new_nut(glue_code))
+local gluespec = register_nut(new_nut(gluespec_code))
local glyph = register_nut(new_nut(glyph_code,0))
local textdir = register_nut(new_nut(nodecodes.dir))
@@ -198,7 +199,7 @@ local correctionskip = register_nut(new_nut(glue_code,gluecodes.correctionski
local temp = register_nut(new_nut(nodecodes.temp,0))
local noad = register_nut(new_nut(nodecodes.noad))
-local delimiter = register_nut(new_nut(nodecodes.delim))
+local delimiter = register_nut(new_nut(nodecodes.delimiter))
local fence = register_nut(new_nut(nodecodes.fence))
local submlist = register_nut(new_nut(nodecodes.submlist))
local accent = register_nut(new_nut(nodecodes.accent))
@@ -212,7 +213,7 @@ local choice = register_nut(new_nut(nodecodes.choice))
local boundary = register_nut(new_nut(nodecodes.boundary,boundarycodes.user))
local wordboundary = register_nut(new_nut(nodecodes.boundary,boundarycodes.word))
-local cleader = register_nut(copy_nut(glue)) setsubtype(cleader,leadercodes.cleaders) setglue(cleader,0,65536,0,2,0)
+local cleader = register_nut(copy_nut(glue)) setsubtype(cleader,gluecodes.cleaders) setglue(cleader,0,65536,0,2,0)
-- the dir field needs to be set otherwise crash:
@@ -283,6 +284,14 @@ function nutpool.italickern(k)
return n
end
+function nutpool.gluespec(width,stretch,shrink,stretch_order,shrink_order)
+ local n = copy_nut(gluespec)
+ if width or stretch or shrink or stretch_order or shrink_order then
+ setglue(n,width,stretch,shrink,stretch_order,shrink_order)
+ end
+ return n
+end
+
local function someskip(skip,width,stretch,shrink,stretch_order,shrink_order)
-- maybe setglue
local n = copy_nut(skip)
@@ -574,12 +583,17 @@ local usage = CONTEXTLMTXMODE > 0 and node.inuse or function()
return t
end
+local stock = CONTEXTLMTXMODE > 0 and node.instock or { }
+
nutpool .cleanup = cleanup
nodepool.cleanup = cleanup
nutpool .usage = usage
nodepool.usage = usage
+nutpool .stock = stock
+nodepool.stock = stock
+
-- end
statistics.register("cleaned up reserved nodes", function()
@@ -612,10 +626,10 @@ do
return v
end)
- traversers.node = nodes.traverse (glyph)
- traversers.char = nodes.traverse_char (glyph)
- if nuts.traverse_glyph then traversers.glyph = nodes.traverse_glyph(glyph) end
- if nuts.traverse_list then traversers.list = nodes.traverse_list (glyph) end
+ traversers.node = nodes.traverse (glyph)
+ traversers.char = nodes.traverse_char (glyph)
+ if nodes.traverse_glyph then traversers.glyph = nodes.traverse_glyph(glyph) end
+ if nodes.traverse_list then traversers.list = nodes.traverse_list (glyph) end
nodes.traversers = traversers
@@ -632,10 +646,11 @@ do
return v
end)
- traversers.node = nuts.traverse (glyph)
- traversers.char = nuts.traverse_char (glyph)
- if nuts.traverse_glyph then traversers.glyph = nuts.traverse_glyph(glyph) end
- if nuts.traverse_list then traversers.list = nuts.traverse_list (glyph) end
+ traversers.node = nuts.traverse (glyph)
+ traversers.char = nuts.traverse_char (glyph)
+ if nuts.traverse_glyph then traversers.glyph = nuts.traverse_glyph (glyph) end
+ if nuts.traverse_list then traversers.list = nuts.traverse_list (glyph) end
+ if nuts.traverse_content then traversers.content = nuts.traverse_content(glyph) end
nuts.traversers = traversers
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua b/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
index b904e54d616..f60fb2406a7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['node-rul'] = {
version = 1.001,
+ optimize = true,
comment = "companion to node-rul.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -74,7 +75,7 @@ local gluecodes = nodes.gluecodes
local listcodes = nodes.listcodes
local glyph_code = nodecodes.glyph
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local dir_code = nodecodes.dir
local glue_code = nodecodes.glue
local hlist_code = nodecodes.hlist
@@ -587,7 +588,7 @@ function linefillers.handler(head)
else
break
end
- elseif id == localpar_code or id == dir_code then
+ elseif id == par_code or id == dir_code then
-- go on
elseif id == hlist_code then
if getsubtype(head) == indentlist_code then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-rul.mkiv b/Master/texmf-dist/tex/context/base/mkiv/node-rul.mkiv
index 7f2093bf2c3..660c0d4e617 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-rul.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-rul.mkiv
@@ -162,14 +162,14 @@
\expandafter\let\expandafter\c_node_rules_index\csname\??barindex#1\endcsname
\advance\c_node_rules_index\plusone
\clf_enablerules % will be relaxed
- \attribute\ruledattribute\numexpr
+ \c_attr_ruled\numexpr
\plusthousand*\c_node_rules_index
% optimizing this one needs testing
+\csname\??barattribute#1\ifcsname\??bar#1:\number\c_node_rules_index\s!parent\endcsname:\number\c_node_rules_index\fi\endcsname
\relax}
\unexpanded\def\resetbar
- {\attribute\ruledattribute\attributeunsetvalue}
+ {\c_attr_ruled\attributeunsetvalue}
\unexpanded\def\nobar
{\groupedcommand
@@ -198,7 +198,7 @@
\unexpanded\def\pushbar[#1]%
{\global\advance\c_node_rules_nesting\plusone
- \expandafter\edef\csname\??barstack\number\c_node_rules_nesting\endcsname{\attribute\ruledattribute\the\attribute\ruledattribute}%
+ \expandafter\edef\csname\??barstack\number\c_node_rules_nesting\endcsname{\c_attr_ruled\the\c_attr_ruled}%
\node_rules_set{#1}}
\unexpanded\def\popbar
@@ -221,6 +221,8 @@
% \definebar[touchbar] [\c!method=0,\c!dy=-0.4,\c!offset=-0.0]
% \definebar[touchbars] [touchbar] [\c!continue=\v!yes]
+\pushoverloadmode
+
\let\normalmathoverbar \overbar
\let\normalmathunderbar \underbar
\let\normalmathoverstrike \overstrike
@@ -230,6 +232,8 @@
\definebar[\v!underbar] [\c!method=1,\c!dy=-0.4,\c!offset=-0.3,\c!continue=\v!yes]
\definebar[\v!overstrike][\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes]
+\popoverloadmode
+
\definebar
[\v!understrike]
[\c!method=0,
@@ -405,7 +409,7 @@
\expandafter\let\expandafter\c_node_shifts_index\csname\??shiftindex#1\endcsname
\advance\c_node_shifts_index\plusone
\clf_enableshifts % will be relaxed
- \attribute\shiftedattribute\numexpr
+ \c_attr_shifted\numexpr
\plusthousand*\c_node_shifts_index
+\csname\??shiftattribute#1\ifcsname\??shift#1:\number\c_node_shifts_index\s!parent\endcsname:\number\c_node_shifts_index\fi\endcsname
\relax
@@ -525,7 +529,7 @@
\expandafter\let\expandafter\c_node_linefiller_index\csname\??linefillerindex#1\endcsname
\advance\c_node_linefiller_index\plusone
\clf_enablelinefillers
- \attribute\linefillerattribute\numexpr
+ \c_attr_linefiller\numexpr
\plusthousand*\c_node_linefiller_index
+\csname\??linefillerattribute#1\ifcsname\??linefiller#1:\number\c_node_linefiller_index\s!parent\endcsname:\number\c_node_linefiller_index\fi\endcsname
\relax}
@@ -601,7 +605,7 @@
\node_linefiller_set{#3}% already sets the attribute
#1%
attr \backgroundattribute \plusone
- % attr \linefillerattribute \the\attribute\linefillerattribute
+ % attr \linefillerattribute \the\c_attr_linefiller
{\box\nextbox}%
\egroup}%
#2}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-scn.lua b/Master/texmf-dist/tex/context/base/mkiv/node-scn.lua
index 055f5e20def..0ec1ba387c9 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-scn.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-scn.lua
@@ -24,7 +24,6 @@ local setlist = nuts.setlist
local end_of_math = nuts.end_of_math
local nodecodes = nodes.nodecodes
-local leadercodes = nodes.leadercodes
local gluecodes = nodes.gluecodes
local kerncodes = nodes.kerncodes
@@ -43,8 +42,7 @@ local vlist_code = nodecodes.vlist
local userskip_code = gluecodes.userskip
local spaceskip_code = gluecodes.spaceskip
local xspaceskip_code = gluecodes.xspaceskip
-
-local leaders_code = leadercodes.leaders
+local leaders_code = gluecodes.leaders
local fontkern_code = kerncodes.fontkern
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ser.lua b/Master/texmf-dist/tex/context/base/mkiv/node-ser.lua
index 6fc2b7ea4cf..25a6dd6c39d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-ser.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-ser.lua
@@ -19,7 +19,6 @@ local context = context
local nodes = nodes
local node = node
-local traverse = nodes.traverse
local is_node = nodes.is_node
local nodecodes = nodes.nodecodes
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-shp.lua b/Master/texmf-dist/tex/context/base/mkiv/node-shp.lua
index 306e38f6a58..58dc944951a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-shp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-shp.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['node-shp'] = {
version = 1.001,
+ optimize = true,
comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -66,59 +67,61 @@ local removables = {
-- (like marks) is not saving much and removing empty boxes is even
-- dangerous because we can rely on dimensions (e.g. in references).
-local wipedisc = false -- we can use them in the export ... can be option
-
-local function cleanup_redundant(head) -- better name is: flatten_page
- local start = head
- while start do
- local id = getid(start)
- if id == disc_code then
- if getsubtype(start) == discretionarydisc_code then
- local _, _, replace, _, _ tail = getdisc(start,true)
- if replace then
- local prev, next = getboth(start)
- setfield(start,"replace",nil)
- if start == head then
- remove_node(head,start,true)
- head = replace
- else
- remove_node(head,start,true)
- end
- if next then
- setlink(tail,next)
- end
- if prev then
- setlink(prev,replace)
- else
- setprev(replace) -- to be sure
- end
- start = next
- elseif wipedisc then
- -- pre and post can have values
- head, start = remove_node(head,start,true)
- else
- start = getnext(start)
- end
- else
- start = getnext(start)
- end
- elseif id == hlist_code or id == vlist_code then
- local sl = getlist(start)
- if sl then
- local rl = cleanup_redundant(sl)
- if rl ~= sl then
- setlist(start,rl)
- end
- end
- start = getnext(start)
- else
- start = getnext(start)
- end
- end
- return head
-end
-
-handlers.cleanuppage = cleanup_redundant -- nut
+-- local wipedisc = false -- we can use them in the export ... can be option
+--
+-- local function cleanup_redundant(head) -- better name is: flatten_page
+-- local start = head
+-- while start do
+-- local id = getid(start)
+-- if id == disc_code then
+-- if getsubtype(start) == discretionarydisc_code then
+-- local _, _, replace, _, _ tail = getdisc(start,true)
+-- if replace then
+-- local prev, next = getboth(start)
+-- setfield(start,"replace",nil)
+-- if start == head then
+-- remove_node(head,start,true)
+-- head = replace
+-- else
+-- remove_node(head,start,true)
+-- end
+-- if next then
+-- setlink(tail,next)
+-- end
+-- if prev then
+-- setlink(prev,replace)
+-- else
+-- setprev(replace) -- to be sure
+-- end
+-- start = next
+-- elseif wipedisc then
+-- -- pre and post can have values
+-- head, start = remove_node(head,start,true)
+-- else
+-- start = getnext(start)
+-- end
+-- else
+-- start = getnext(start)
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local sl = getlist(start)
+-- if sl then
+-- local rl = cleanup_redundant(sl)
+-- if rl ~= sl then
+-- setlist(start,rl)
+-- end
+-- end
+-- start = getnext(start)
+-- else
+-- start = getnext(start)
+-- end
+-- end
+-- return head
+-- end
+--
+-- handlers.cleanuppage = cleanup_redundant -- nut
+
+handlers.cleanuppage = nuts.flatten_discretionaries
local function cleanup_flushed(head) -- rough
local start = head
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-syn.lua b/Master/texmf-dist/tex/context/base/mkiv/node-syn.lua
index 68a05234e90..d9c653abbb0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-syn.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-syn.lua
@@ -170,15 +170,11 @@ local new_kern = nodepool.kern
local getdimensions = nuts.dimensions
local getrangedimensions = nuts.rangedimensions
-local get_synctex_fields = nuts.get_synctex_fields
------ set_synctex_fields = nuts.set_synctex_fields
-local set_synctex_line = tex.set_synctex_line
-local set_synctex_tag = tex.set_synctex_tag
-local force_synctex_tag = tex.force_synctex_tag
-local force_synctex_line = tex.force_synctex_line
------ get_synctex_tag = tex.get_synctex_tag
-local get_synctex_line = tex.get_synctex_line
-local set_synctex_mode = tex.set_synctex_mode
+local getsynctexfields = nuts.getsynctexfields or nuts.get_synctex_fields
+local forcesynctextag = tex.forcesynctextag or tex.force_synctex_tag
+local forcesynctexline = tex.forcesynctexline or tex.force_synctex_line
+local getsynctexline = tex.getsynctexline or tex.get_synctex_line
+local setsynctexmode = tex.setsynctexmode or tex.set_synctex_mode
local foundintree = resolvers.foundintree
@@ -212,7 +208,7 @@ local paused = 0
local used = false
local never = false
--- get rid of overhead
+-- get rid of overhead in mkiv
if tex.set_synctex_no_files then
tex.set_synctex_no_files(1)
@@ -261,18 +257,18 @@ function synctex.blockfilename(name)
end
function synctex.setfilename(name,line)
- if paused == 0 and force_synctex_tag and name then
- force_synctex_tag(sttags[name])
+ if paused == 0 and name then
+ forcesynctextag(sttags[name])
if line then
- force_synctex_line(line)
+ forcesynctexline(line)
end
end
end
function synctex.resetfilename()
- if paused == 0 and force_synctex_tag then
- force_synctex_tag(0)
- force_synctex_line(0)
+ if paused == 0 then
+ forcesynctextag(0)
+ forcesynctexline(0)
end
end
@@ -284,10 +280,10 @@ do
function synctex.pushline()
nesting = nesting + 1
if nesting == 1 then
- local l = get_synctex_line()
+ local l = getsynctexline()
ignored = l and l > 0
if not ignored then
- force_synctex_line(texget("inputlineno"))
+ forcesynctexline(texget("inputlineno"))
end
end
end
@@ -295,7 +291,7 @@ do
function synctex.popline()
if nesting == 1 then
if not ignored then
- force_synctex_line()
+ forcesynctexline()
ignored = false
end
end
@@ -469,7 +465,11 @@ local x_hlist do
local doaction = doaction_1
x_hlist = function(head,current,t,l,w,h,d)
- return insert_before(head,current,new_latelua(function() doaction(t,l,w,h,d) end))
+ if filehandle then
+ return insert_before(head,current,new_latelua(function() doaction(t,l,w,h,d) end))
+ else
+ return head
+ end
end
directives.register("system.synctex.compression", function(v)
@@ -520,7 +520,7 @@ local function collect_min(head)
local line = 0
while true do
if id == glyph_code then
- local tc, lc = get_synctex_fields(current)
+ local tc, lc = getsynctexfields(current)
if tc and tc > 0 then
tag = tc
line = lc
@@ -587,7 +587,7 @@ local function collect_max(head,parent)
local line = 0
while true do
if id == glyph_code then
- local tc, lc = get_synctex_fields(current)
+ local tc, lc = getsynctexfields(current)
if tc and tc > 0 then
if tag > 0 and (tag ~= tc or line ~= lc) then
head = inject(parent,head,first,last,tag,line)
@@ -615,7 +615,7 @@ local function collect_max(head,parent)
end
elseif id == glue_code then
if tag > 0 then
- local tc, lc = get_synctex_fields(current)
+ local tc, lc = getsynctexfields(current)
if tc and tc > 0 then
if tag ~= tc or line ~= lc then
head = inject(parent,head,first,last,tag,line)
@@ -730,7 +730,7 @@ end
function synctex.enable()
if not never and not enabled then
enabled = true
- set_synctex_mode(3) -- we want details
+ setsynctexmode(3) -- we want details
if not used then
nodes.tasks.enableaction("shipouts","luatex.synctex.collect")
report_system("synctex functionality is enabled, expect 5-10 pct runtime overhead!")
@@ -744,7 +744,7 @@ end
function synctex.disable()
if enabled then
- set_synctex_mode(0)
+ setsynctexmode(0)
report_system("synctex functionality is disabled!")
enabled = false
for i=1,#disablers do
@@ -768,13 +768,13 @@ local filename = nil
function synctex.pause()
paused = paused + 1
if enabled and paused == 1 then
- set_synctex_mode(0)
+ setsynctexmode(0)
end
end
function synctex.resume()
if enabled and paused == 1 then
- set_synctex_mode(3)
+ setsynctexmode(3)
end
paused = paused - 1
end
@@ -849,12 +849,17 @@ implement {
actions = synctex.resume,
}
-interfaces.implement {
+implement {
name = "synctexpushline",
actions = synctex.pushline,
}
-interfaces.implement {
+
+implement {
name = "synctexpopline",
actions = synctex.popline,
}
+implement {
+ name = "synctexdisable",
+ actions = synctex.disable,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-tex.lua b/Master/texmf-dist/tex/context/base/mkiv/node-tex.lua
index 5857fd2e65b..cda6ff132d6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-tex.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-tex.lua
@@ -16,7 +16,6 @@ local hyphenate = lang.hyphenate
local hyphenating = nuts.hyphenating
local ligaturing = nuts.ligaturing
local kerning = nuts.kerning
-local cleanup = nuts.flush_components
function kernel.hyphenation(head)
return (hyphenate(head)) -- nodes !
@@ -34,14 +33,6 @@ function kernel.kerning(head)
return (kerning(head))
end
-if cleanup then
-
- function kernel.cleanup(head)
- return (cleanup(head))
- end
-
-end
-
callbacks.register('hyphenate' , false, "normal hyphenation routine, called elsewhere")
callbacks.register('ligaturing', false, "normal ligaturing routine, called elsewhere")
callbacks.register('kerning' , false, "normal kerning routine, called elsewhere")
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-tra.lua b/Master/texmf-dist/tex/context/base/mkiv/node-tra.lua
index c7556aba6d0..83c072c19b0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-tra.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-tra.lua
@@ -77,7 +77,7 @@ local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
local rule_code = nodecodes.rule
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local whatsit_code = nodecodes.whatsit
local dimenfactors = number.dimenfactors
@@ -115,19 +115,6 @@ function nodes.handlers.checkglyphs(head,message)
return false
end
-function nodes.handlers.checkforleaks(sparse)
- local l = { }
- local q = used_nodes()
- for p, id in nextnode, q do
- local s = table.serialize(nodes.astable(p,sparse),nodecodes[id])
- l[s] = (l[s] or 0) + 1
- end
- flush_list(q)
- for k, v in next, l do
- report_nodes("%s * %s",v,k)
- end
-end
-
local fontcharacters -- = fonts.hashes.descriptions
local function tosequence(start,stop,compact)
@@ -167,7 +154,7 @@ local function tosequence(start,stop,compact)
elseif id == dir_code then
local d, p = getdirection(start)
n = n + 1 ; t[n] = "[<" .. (p and "-" or "+") .. d .. ">]" -- todo l2r etc
- elseif id == localpar_code and start_of_par(current) then
+ elseif id == par_code and start_of_par(current) then
n = n + 1 ; t[n] = "[<" .. getdirection(start) .. ">]" -- todo l2r etc
elseif compact then
n = n + 1 ; t[n] = "[]"
@@ -315,14 +302,6 @@ local function showsimplelist(h,depth,n)
end
end
--- \startluacode
--- callbacks.register('buildpage_filter',function() nodes.show_simple_list(tex.lists.contrib_head) end)
--- \stopluacode
--- \vbox{b\footnote{n}a}
--- \startluacode
--- callbacks.register('buildpage_filter',nil)
--- \stopluacode
-
nodes.showsimplelist = function(h,depth) showsimplelist(h,depth,0) end
local function listtoutf(h,joiner,textonly,last,nodisc)
@@ -503,8 +482,8 @@ function number.tobasepoints (n,fmt) return numbertodimen(n,"bp",fmt) end
function number.topicas (n,fmt) return numbertodimen(n "pc",fmt) end
function number.todidots (n,fmt) return numbertodimen(n,"dd",fmt) end
function number.tociceros (n,fmt) return numbertodimen(n,"cc",fmt) end
-function number.tonewdidots (n,fmt) return numbertodimen(n,"nd",fmt) end
-function number.tonewciceros (n,fmt) return numbertodimen(n,"nc",fmt) end
+-------- number.tonewdidots (n,fmt) return numbertodimen(n,"nd",fmt) end
+-------- number.tonewciceros (n,fmt) return numbertodimen(n,"nc",fmt) end
function nodes.topoints (n,fmt) return nodetodimen(n,"pt",fmt) end
function nodes.toinches (n,fmt) return nodetodimen(n,"in",fmt) end
@@ -516,8 +495,8 @@ function nodes.tobasepoints (n,fmt) return nodetodimen(n,"bp",fmt) end
function nodes.topicas (n,fmt) return nodetodimen(n "pc",fmt) end
function nodes.todidots (n,fmt) return nodetodimen(n,"dd",fmt) end
function nodes.tociceros (n,fmt) return nodetodimen(n,"cc",fmt) end
-function nodes.tonewdidots (n,fmt) return nodetodimen(n,"nd",fmt) end
-function nodes.tonewciceros (n,fmt) return nodetodimen(n,"nc",fmt) end
+-------- nodes.tonewdidots (n,fmt) return nodetodimen(n,"nd",fmt) end
+-------- nodes.tonewciceros (n,fmt) return nodetodimen(n,"nc",fmt) end
-- stop redefinition
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-typ.lua b/Master/texmf-dist/tex/context/base/mkiv/node-typ.lua
index 021bfefc263..adf0d18c005 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-typ.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-typ.lua
@@ -8,33 +8,36 @@ if not modules then modules = { } end modules ['node-typ'] = {
-- code has been moved to blob-ini.lua
-local typesetters = nodes.typesetters or { }
-nodes.typesetters = typesetters
+local typesetters = nodes.typesetters or { }
+nodes.typesetters = typesetters
-local nuts = nodes.nuts
-local tonode = nuts.tonode
-local tonut = nuts.tonut
+local nuts = nodes.nuts
+local tonode = nuts.tonode
+local tonut = nuts.tonut
-local setlink = nuts.setlink
-local setchar = nuts.setchar
-local setattrlist = nuts.setattrlist
+local setlink = nuts.setlink
+local setchar = nuts.setchar
+local setattrlist = nuts.setattrlist
-local getfont = nuts.getfont
-local getattrlist = nuts.getattrlist
+local getfont = nuts.getfont
+local getattrlist = nuts.getattrlist
-local hpack_node_list = nuts.hpack
-local vpack_node_list = nuts.vpack
-local full_hpack_list = nuts.fullhpack
+local hpack_node_list = nuts.hpack
+local vpack_node_list = nuts.vpack
+local full_hpack_list = nuts.fullhpack
-local nodepool = nuts.pool
-local new_glyph = nodepool.glyph
-local new_glue = nodepool.glue
+local nodepool = nuts.pool
+local new_glyph = nodepool.glyph
+local new_glue = nodepool.glue
-local utfvalues = utf.values
+local utfvalues = utf.values
-local currentfont = font.current -- mabe nicer is fonts .current
-local currentattr = node.current_attr -- mabe nicer is attributes.current
-local fontparameters = fonts.hashes.parameters
+local currentfont = font.current -- mabe nicer is fonts .current
+local currentattributes = node.current_attributes -- mabe nicer is attributes.current
+
+local fontparameters = fonts.hashes.parameters
+
+if not currentattributes then currentattributes = node.current_attr end -- CONTEXTLMTXMODE == 0
-- when attrid == true then take from glyph or current else use the given value
@@ -51,7 +54,7 @@ local function tonodes(str,fontid,spacing,templateglyph,attrid) -- quick and dir
if templateglyph then
attrid = false -- we copy with the glyph
else
- attrid = currentattr()
+ attrid = currentattributes()
end
end
local fp = fontparameters[fontid]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-bar.mkiv b/Master/texmf-dist/tex/context/base/mkiv/pack-bar.mkiv
index b67d6f14b28..99323b43564 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-bar.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-bar.mkiv
@@ -40,7 +40,7 @@
\installcorenamespace{positionbar}
-\installsimplecommandhandler \??positionbar {positionbar}
+\installsimplecommandhandler \??positionbar {positionbar} \??positionbar
\setuppositionbar
[\c!min=1,
@@ -63,7 +63,8 @@
\unexpanded\def\verticalpositionbar[#1]%
{\vbox to \vsize
- {\setuppositionbar[#1]%
+ {\hsize\positionbarparameter\c!width
+ \setuppositionbar[#1]%
\usepositionbarstyleandcolor\c!style\c!color
\vskip\zeropoint\s!plus \positionbarparameter\c!n \s!fill
\vskip\zeropoint\s!plus-\positionbarparameter\c!min\s!fill
@@ -75,17 +76,18 @@
{\hpack to \hsize
{\setuppositionbar[#1]%
\usepositionbarstyleandcolor\c!style\c!color
- \leaders\vrule\hskip\zeropoint\s!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\s!fill
\vrule\s!width\zeropoint\s!height\positionbarparameter\c!height\s!depth\positionbarparameter\c!depth
+ \leaders\vrule\hskip\zeropoint\s!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\s!fill
\hskip\zeropoint\s!plus \positionbarparameter\c!max\s!fill
\hskip\zeropoint\s!plus-\positionbarparameter\c!n \s!fill}}
\unexpanded\def\verticalgrowingbar[#1]%
{\vpack to \vsize
- {\setuppositionbar[#1]%
+ {\hsize\positionbarparameter\c!width
+ \setuppositionbar[#1]%
\usepositionbarstyleandcolor\c!style\c!color
- \leaders\hrule\vskip\zeropoint\s!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\s!fill
\hrule\s!width\positionbarparameter\c!width\s!height\zeropoint\s!depth\zeropoint
+ \leaders\hrule\vskip\zeropoint\s!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\s!fill
\vskip\zeropoint\s!plus \positionbarparameter\c!max\s!fill
\vskip\zeropoint\s!plus-\positionbarparameter\c!n \s!fill}}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv b/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv
index 422f090f0b9..4c9a4c17d5c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-box.mkiv
@@ -337,7 +337,7 @@
\pack_boxes_collector_check_box{#1}%
\ifconditional\c_pack_boxes_collector_valid_box
\letcollectorparameter\c!voffset\zeropoint
- \letcollectorparameter\h!voffset\zeropoint
+ \letcollectorparameter\c!hoffset\zeropoint
\ifsecondargument
\setupcurrentcollector[#2]%
\fi
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-com.mkiv b/Master/texmf-dist/tex/context/base/mkiv/pack-com.mkiv
index fe622509a10..17675fa7ab6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-com.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-com.mkiv
@@ -77,11 +77,15 @@
\to \everyinsidefloat
\newcount\c_pack_combinations_nesting % local
+
\newcount\c_pack_combinations_x % global
\newcount\c_pack_combinations_y % global
\newcount\c_pack_combinations_max % global
-\newbox \b_pack_combinations_captions % global
-\newbox \b_pack_combinations_temp % global
+
+\newdimen\d_pack_combinations_ht % global
+
+\newbox \b_pack_combinations_captions % global % can go
+\newbox \b_pack_combinations_temp % global % can go
\newbox \b_pack_combinations_content % local
\newbox \b_pack_combinations_caption % local
@@ -95,6 +99,9 @@
\newcount\c_pack_combinations_x_saved
\newcount\c_pack_combinations_y_saved
\newcount\c_pack_combinations_max_saved
+
+\newdimen\d_pack_combinations_ht_saved
+
\newbox \b_pack_combinations_captions_saved
\newbox \b_pack_combinations_temp_saved
\newbox \b_pack_combinations_content_saved
@@ -108,6 +115,7 @@
\c_pack_combinations_x_saved \c_pack_combinations_x
\c_pack_combinations_y_saved \c_pack_combinations_y
\c_pack_combinations_max_saved\c_pack_combinations_max
+ \d_pack_combinations_ht_saved \d_pack_combinations_ht
\setbox\b_pack_combinations_captions_saved\box\b_pack_combinations_captions
\setbox\b_pack_combinations_temp_saved \box\b_pack_combinations_temp
\setbox\b_pack_combinations_content_saved \box\b_pack_combinations_content
@@ -121,6 +129,7 @@
\global\c_pack_combinations_x \c_pack_combinations_x_saved
\global\c_pack_combinations_y \c_pack_combinations_y_saved
\global\c_pack_combinations_max\c_pack_combinations_max_saved
+ \global\d_pack_combinations_ht \d_pack_combinations_ht_saved
\global\setbox\b_pack_combinations_captions\box\b_pack_combinations_captions_saved
\global\setbox\b_pack_combinations_temp \box\b_pack_combinations_temp_saved
\setbox\b_pack_combinations_content \box\b_pack_combinations_content_saved
@@ -360,7 +369,7 @@
\to \everydefinecombination
\def\pack_combinations_pickup
- {\dostarttagged\t!combinationpair\empty
+ {\dostarttagged\t!combinationpair\empty % better make this text
\dostarttagged\t!combinationcontent\empty
\assumelongusagecs\pack_combinations_pickup_content_indeed}
@@ -474,37 +483,72 @@
\pack_combinations_flush_captions
\egroup}
+% \def\pack_combinations_save_caption
+% {\global\setbox\b_pack_combinations_captions\hpack
+% {\hpack{\box\b_pack_combinations_caption}%
+% \unhbox\b_pack_combinations_captions}}
+%
+% \def\pack_combinations_flush_captions
+% {\noalign
+% {\ifdim\ht\b_pack_combinations_captions>\zeropoint
+% \nointerlineskip % indeed
+% \combinationparameter\c!inbetween
+% \global\c_pack_combinations_x\c_pack_combinations_max
+% \glet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_yes
+% \else
+% \global\setbox\b_pack_combinations_captions\emptybox
+% \glet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_nop
+% \fi}%
+% \pack_combinations_flush_captions_indeed
+% \crcr}
+%
+% \def\pack_combinations_flush_captions_yes
+% {\global\setbox\b_pack_combinations_captions\hpack
+% {\unhbox\b_pack_combinations_captions
+% \global\setbox\b_pack_combinations_temp\lastbox}%
+% \box\b_pack_combinations_temp
+% \global\advance\c_pack_combinations_x\minusone\relax
+% \ifnum\c_pack_combinations_x>\zerocount
+% \expandafter\pack_combinations_flush_captions_yes_followup
+% \else
+% \global\setbox\b_pack_combinations_captions\emptybox
+% \fi}
+
+\installcorenamespace{combinationcaption}
+
\def\pack_combinations_save_caption
- {\global\setbox\b_pack_combinations_captions\hpack
- {\hpack{\box\b_pack_combinations_caption}%
- \unhbox\b_pack_combinations_captions}}
+ {\ifdim\htdp\b_pack_combinations_caption>\d_pack_combinations_ht
+ \global\d_pack_combinations_ht\htdp\b_pack_combinations_caption
+ \fi
+ \savebox{\??combinationcaption:\number\c_pack_combinations_nesting}{\number\c_pack_combinations_x}{\box\b_pack_combinations_caption}}
\def\pack_combinations_flush_captions
{\noalign
- {\ifdim\ht\b_pack_combinations_captions>\zeropoint
+ {\ifdim\d_pack_combinations_ht>\zeropoint
\nointerlineskip % indeed
\combinationparameter\c!inbetween
\global\c_pack_combinations_x\c_pack_combinations_max
\glet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_yes
\else
- \global\setbox\b_pack_combinations_captions\emptybox
\glet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_nop
\fi}%
\pack_combinations_flush_captions_indeed
\crcr}
\def\pack_combinations_flush_captions_yes
- {\global\setbox\b_pack_combinations_captions\hpack
- {\unhbox\b_pack_combinations_captions
- \global\setbox\b_pack_combinations_temp\lastbox}%
- \box\b_pack_combinations_temp
- \global\advance\c_pack_combinations_x\minusone\relax
- \ifnum\c_pack_combinations_x>\zerocount
+ {\vpack to \d_pack_combinations_ht\bgroup
+ \foundbox{\??combinationcaption:\number\c_pack_combinations_nesting}{\number\c_pack_combinations_x}%
+ \vss
+ \egroup
+ \global\advance\c_pack_combinations_x\minusone
+ \ifnum\c_pack_combinations_x>\zerocount % \c_pack_combinations_max
\expandafter\pack_combinations_flush_captions_yes_followup
\else
- \global\setbox\b_pack_combinations_captions\emptybox
+ \global\d_pack_combinations_ht\zeropoint
+ \initializeboxstack{\??combinationcaption:\number-\c_pack_combinations_nesting}%
\fi}
+
\let\pack_combinations_flush_captions_nop\donothing
\def\pack_combinations_flush_captions_yes_followup
@@ -539,8 +583,15 @@
\let\stopfloatcombination\relax
+% \unexpanded\def\pack_combinations_float_hack_a#1%
+% {\strc_floats_build_box_separate_split{\getlocalfloat{#1}}%
+% \box\b_strc_floats_separate_content}
+
+% \unexpanded\def\pack_combinations_float_hack_b#1%
+% {\box\b_strc_floats_separate_caption}
+
\unexpanded\def\pack_combinations_float_hack_a#1%
- {\strc_floats_build_box_separate_split{\getlocalfloat{#1}}%
+ {\strc_floats_build_box_separate_split{#1}%
\box\b_strc_floats_separate_content}
\unexpanded\def\pack_combinations_float_hack_b#1%
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-lyr.mkxl b/Master/texmf-dist/tex/context/base/mkiv/pack-lyr.mkxl
deleted file mode 100644
index 43460092e7e..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-lyr.mkxl
+++ /dev/null
@@ -1,794 +0,0 @@
-%D \module
-%D [ file=pack-lyr,
-%D version=2000.10.20,
-%D title=\CONTEXT\ Packaging Macros,
-%D subtitle=Layers,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Packaging Macros / Layers}
-
-% todo : first / last / next / +... => page key
-% test on left/right box when no doublesided option given
-% use \ifcsname instead of doifvalue
-
-\unprotect
-
-% When being backgrounds layers get the background offset displacement. Should be
-% an option, on by default (compatibility).
-
-%D The layering mechanism implemented here is independent of the output routine, but
-%D future extensions may depend on a more close cooperation.
-%D
-%D First we overload a macro from \type {pack-rul}. From now on we accept a
-%D (optional) argument: the specific layer it will go in. This means that we can
-%D move an overlay from one background to the other using the dimensions of the
-%D parent.
-
-\ifdefined\defineoverlay \else \message{loaded to early} \wait \fi
-
-\unexpanded\def\defineoverlay
- {\dotripleempty\pack_framed_define_overlay}
-
-\def\pack_framed_define_overlay[#1][#2][#3]% overlay [layer] content
- {\ifthirdargument
- %\writestatus{BEWARE}{This (overlay definition) has changed!}% temp
- \def\pack_framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\setlayer[#2]{\executedefinedoverlay{##1}{#3}}}}%
- \else
- \def\pack_framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\executedefinedoverlay{##1}{#2}}}%
- \fi
- \processcommalist[#1]\pack_framed_define_overlay_indeed}
-
-%D We use the command handler code. The previous, more direct parameter handling was
-%D 25\% faster when no parameters were passed when adding content to a layer.
-%D However, when we pass for instance a preset, the new methos is some 10\% faster
-%D and it happens that in most cases we do pass some parameters. It would be
-%D interesting to see if we can push the preset in between the regular chain but it
-%D could also lead to unwanted side effects when nesting layer placement.
-
-\installcorenamespace{layer}
-\installcorenamespace{layerbox}
-\installcorenamespace{layerpreset}
-\installcorenamespace{layerposition} % brr, unreadable
-
-%D \macros
-%D {definelayer,setuplayer}
-%D
-%D Each layer gets its own (global) box. This also means that the data that goes
-%D into a layer, is typeset immediately. Each layer automatically gets an associated
-%D overlay, which can be used in any background assignment.
-%D
-%D After a layer is defined, you can change its characteristics.
-
-\installcommandhandler \??layer {layer} \??layer
-
-\setuplayer
- [\c!state=\v!start,
- %\c!doublesided=,
- %\c!preset=,
- %\c!option=,
- %\c!corner=,
- %\c!page=,
- %\c!rotation=, % geen 0 !
- \c!direction=\v!normal,
- \c!position=\v!no,
- \c!method=\v!overlay,
- \c!x=\zeropoint,
- \c!y=\zeropoint,
- \c!line=0,
- \c!column=0,
- \c!width=\wd\nextbox, % don't change this globally
- \c!height=\ht\nextbox, % don't change this globally
- \c!offset=\zeropoint,
- \c!hoffset=\zeropoint,
- \c!voffset=\zeropoint,
- \c!dx=\zeropoint,
- \c!dy=\zeropoint,
- \c!location=rb,
- \c!sx=1,
- \c!sy=1,
- \c!region=\layeranchor]
-
-\def\layeranchor{\currentlayer:\the\realpageno}
-
-\let\p_pack_layers_doublesided\empty
-\let\p_pack_layers_state \empty
-\let\p_pack_layers_option \empty
-\let\p_pack_layers_method \empty
-\let\p_pack_layers_preset \empty
-\let\p_pack_layers_rotation \empty
-\let\p_pack_layers_position \empty
-\let\p_pack_layers_hoffset \empty
-\let\p_pack_layers_voffset \empty
-\let\p_pack_layers_offset \empty
-\let\p_pack_layers_dx \empty
-\let\p_pack_layers_dy \empty
-\let\p_pack_layers_sx \empty
-\let\p_pack_layers_sy \empty
-\let\p_pack_layers_x \empty
-\let\p_pack_layers_y \empty
-\let\p_pack_layers_corner \empty
-\let\p_pack_layers_location \empty
-\let\p_pack_layers_line \empty
-\let\p_pack_layers_column \empty
-\let\p_pack_layers_width \empty
-\let\p_pack_layers_height \empty
-\let\p_pack_layers_direction \empty
-\let\p_pack_layers_region \empty
-
-\let\m_pack_layers_page \empty
-\let\m_pack_layers_target \empty
-\let\m_pack_layers_region \empty
-\let\m_pack_layers_anchor \empty
-
-\newconditional\c_pack_layers_repeated
-\newconditional\c_pack_layers_trace
-\newcount \c_pack_layers_current_data
-
-\newbox\b_layers
-
-\newdimen\d_pack_layers_x_size
-\newdimen\d_pack_layers_y_size
-\newdimen\d_pack_layers_x_offset
-\newdimen\d_pack_layers_y_offset
-\newdimen\d_pack_layers_x_position
-\newdimen\d_pack_layers_y_position
-
-\newdimen\layerwidth
-\newdimen\layerheight
-
-\let\lastlayerxpos\!!zeropoint
-\let\lastlayerypos\!!zeropoint
-\let\lastlayerwd \!!zeropoint
-\let\lastlayerht \!!zeropoint
-\let\lastlayerdp \!!zeropoint
-
-\appendtoks
- \edef\p_pack_layers_doublesided{\layerparameter\c!doublesided}%
- \ifx\p_pack_layers_doublesided\v!yes
- \relateparameterhandlers{layer}{\v!left \currentlayer}{layer}\currentlayer % permits left*
- \relateparameterhandlers{layer}{\v!right\currentlayer}{layer}\currentlayer % permits right*
- \pack_layers_preset_box{\v!left \currentlayer}%
- \pack_layers_preset_box{\v!right\currentlayer}%
- \fi
- \pack_layers_preset_box\currentlayer
- \normalexpanded{\defineoverlay[\currentlayer][\noexpand\composedlayer{\currentlayer}]}%
-\to \everydefinelayer
-
-\def\pack_layers_preset_box#1%
- {\ifcsname\??layerbox#1\endcsname
- \resetlayer[#1]%
- \else
- \expandafter\newbox\csname\??layerbox#1\endcsname
- \fi}
-
-%D \macros
-%D {resetlayer}
-%D
-%D This macro hardly needs an explanation (but is seldom needed anyway).
-
-\def\pack_layers_reset_box#1%
- {\ifcsname\??layerbox#1\endcsname
- %\global\setbox\csname\??layerbox#1\endcsname\emptybox
- \global\setbox\lastnamedcs\emptybox
- \fi}
-
-\def\resetlayer[#1]%
- {\pack_layers_reset_box{#1}%
- \pack_layers_reset_box{\v!left #1}%
- \pack_layers_reset_box{\v!right#1}%
- \pack_layers_reset_box{#1:\the\realpageno}}
-
-%D \macros
-%D {setlayer}
-%D
-%D Data is moved into a layer with the following macro. When \type {position} is
-%D set, relative positioning is used, with the current point as reference point.
-%D Otherwise the topleft corner is used as reference point.
-%D
-%D \starttyping
-%D \setlayer [identifier] [optional parameters] {data}
-%D \stoptyping
-
-\def\setcurrentlayerdimensions
- {\dodoubleempty\pack_layers_set_current_dimensions}
-
-\def\pack_layers_set_current_dimensions[#1][#2]% name left|right
- {\edef\currentlayerwidth {\thelayerwidth {#2#1}}%
- \edef\currentlayerheight{\thelayerheight{#2#1}}}
-
-\def\thelayerwidth #1{\the\ifcsname\??layerbox#1\endcsname\wd\lastnamedcs\else\zeropoint\fi}
-\def\thelayerheight#1{\the\ifcsname\??layerbox#1\endcsname\ht\lastnamedcs\else\zeropoint\fi}
-
-\unexpanded\def\setlayer
- {\dotripleempty\pack_layers_set}
-
-\def\pack_layers_set[#1][#2][#3]% #4 == box do \fi is ok
- {\bgroup
- \checkpositionoverlays % otherwise funny regions
- \edef\currentlayer{#1}%
- \edef\p_pack_layers_state{\layerparameter\c!state}%
- \ifx\p_pack_layers_state\v!stop
- \dowithnextboxcs\egroup\hbox % no pack ?
- \orelse\ifthirdargument
- \pack_layers_set_indeed[#1][#2][#3]%
- \else
- \ifcondition\validassignment{#2}%
- \pack_layers_set_indeed[#1][][#2]%
- \else
- \pack_layers_set_indeed[#1][#2][]%
- \fi
- \fi}
-
-\def\pack_layers_set_indeed[#1][#2][#3]% #2 = links/rechts
- {\page_backgrounds_recalculate % brrr
- \global\advance\c_pack_layers_current_data\plusone
- \forgetall
- \dontcomplain
- \edef\p_pack_layers_option{\layerparameter\c!option}%
- \ifx\p_pack_layers_option\v!test
- \settrue\c_pack_layers_trace
- \traceboxplacementtrue
- \fi
- \edef\m_pack_layers_target{#2}%
- \dowithnextbox{\pack_layers_set_finish{#3}}\hbox}
-
-\def\pack_layers_set_finish#1%
- {\ifcsname\??layerbox\currentlayer\endcsname % can move up
- \ifx\m_pack_layers_target\v!even
- \ifodd\realpageno
- % discard nextbox
- \else
- \let\m_pack_layers_target\v!left
- \pack_layers_set_content{#1}%
- \fi
- \orelse\ifx\m_pack_layers_target\v!odd
- \ifodd\realpageno
- \let\m_pack_layers_target\v!right
- \pack_layers_set_content{#1}%
- \else
- % discard nextbox
- \fi
- \else
- \pack_layers_set_content{#1}%
- \fi
- \else
- \writestatus{layer}{unknown layer \currentlayer}%
- \fi
- \egroup}
-
-% todo: left/right
-% todo: get position data in one go
-
-\def\pack_layers_set_last_position_yes % target: left|right
- {% this will become one call
- \edef\m_pack_layers_anchor{\??layerposition\the\c_pack_layers_current_data}%
- \edef\m_pack_layers_page {\MPp\m_pack_layers_anchor}%
- %edef\m_pack_layers_region{\MPr\m_pack_layers_anchor}% wrong one
- \edef\m_pack_layers_region{\layerparameter\c!region}%
- \d_pack_layers_x_position \dimexpr-\MPx\m_pack_layers_region+\MPx\m_pack_layers_anchor\relax
- \d_pack_layers_y_position \dimexpr \MPy\m_pack_layers_region-\MPy\m_pack_layers_anchor+\MPh\m_pack_layers_region\relax
- \xdef\lastlayerxpos{\the\d_pack_layers_x_position}%
- \xdef\lastlayerypos{\the\d_pack_layers_y_position}%
- % \writestatus{layering}{region: \m_pack_layers_region=>\MPxywhd\m_pack_layers_region}%
- % \writestatus {}{anchor: \m_pack_layers_anchor=>\MPxywhd\m_pack_layers_anchor}%
- % \writestatus {}{offset: \c!dx,\c!dy =>\lastlayerxpos,\lastlayerypos}%
- \global\letlayerparameter\c!state\v!start % needed ?
- \setbox\b_layers\vpack to \d_pack_layers_y_size
- {\hpack to \d_pack_layers_x_size
- {\xypos\m_pack_layers_anchor\hss}%
- \vss}}
-
-\def\pack_layers_set_last_position_nop
- {\setbox\b_layers\emptybox
- \d_pack_layers_x_position\p_pack_layers_sx\dimexpr\p_pack_layers_x\relax
- \d_pack_layers_y_position\p_pack_layers_sy\dimexpr\p_pack_layers_y\relax
- \glet\lastlayerxpos\!!zeropoint
- \glet\lastlayerypos\!!zeropoint
- \doifinset\v!bottom\p_pack_layers_corner\pack_layers_set_bottom_positions
- \doifinset\v!right \p_pack_layers_corner\pack_layers_set_right_positions
- \doifinset\v!middle\p_pack_layers_corner\pack_layers_set_middle_positions
- \edef\m_pack_layers_page{\layerparameter\c!page}}
-
-\unexpanded\def\definelayerpreset
- {\dodoubleargument\pack_layers_define_preset}
-
-\def\pack_layers_define_preset[#1][#2]%
- {\doifelseassignment{#2}
- {\setvalue{\??layerpreset#1}{\setupcurrentlayer[#2]}}
- {\setvalue{\??layerpreset#1}{\csname\??layerpreset#2\endcsname}}}
-
-\def\pack_layers_set_content#1%
- {\layerwidth \layerparameter\c!width % global (local later)
- \layerheight\layerparameter\c!height % global (local later)
- \d_pack_layers_x_size\layerwidth
- \d_pack_layers_y_size\layerheight
- %
- \setupcurrentlayer[#1]% preroll
- %
- \edef\p_pack_layers_preset {\layerparameter\c!preset }%
- %
- \ifcsname\??layerpreset\p_pack_layers_preset\endcsname
- \lastnamedcs
- \setupcurrentlayer[#1]% postroll
- \fi
- %
- \edef\p_pack_layers_rotation {\layerparameter\c!rotation }%
- \edef\p_pack_layers_position {\layerparameter\c!position }%
- \edef\p_pack_layers_hoffset {\layerparameter\c!hoffset }%
- \edef\p_pack_layers_voffset {\layerparameter\c!voffset }%
- \edef\p_pack_layers_offset {\layerparameter\c!offset }%
- \edef\p_pack_layers_dx {\layerparameter\c!dx }%
- \edef\p_pack_layers_dy {\layerparameter\c!dy }%
- \edef\p_pack_layers_sx {\layerparameter\c!sx }%
- \edef\p_pack_layers_sy {\layerparameter\c!sy }%
- \edef\p_pack_layers_x {\layerparameter\c!x }%
- \edef\p_pack_layers_y {\layerparameter\c!y }%
- \edef\p_pack_layers_corner {\layerparameter\c!corner }%
- \edef\p_pack_layers_location {\layerparameter\c!location }%
- \edef\p_pack_layers_line {\layerparameter\c!line }%
- \edef\p_pack_layers_column {\layerparameter\c!column }%
- \edef\p_pack_layers_width {\layerparameter\c!width }% local ones
- \edef\p_pack_layers_height {\layerparameter\c!height }% local ones
- \edef\p_pack_layers_direction{\layerparameter\c!direction}%
- %
- \ifx\p_pack_layers_position\v!overlay
- \let\p_pack_layers_width \zeropoint
- \let\p_pack_layers_height \zeropoint
- \let\p_pack_layers_position\v!yes
- \fi
- \ifx\p_pack_layers_rotation\empty \else
- % use direct call
- \setbox\nextbox\hpack
- {\rotate[\c!location=\v!high,\c!rotation=\layerparameter\c!rotation]{\box\nextbox}}%
- \fi
- \d_pack_layers_x_offset\p_pack_layers_sx\dimexpr
- \ifx\p_pack_layers_hoffset\v!max\d_pack_layers_x_size\else\p_pack_layers_hoffset\fi+\p_pack_layers_offset+\p_pack_layers_dx
- \relax
- \d_pack_layers_y_offset\p_pack_layers_sy\dimexpr
- \ifx\p_pack_layers_voffset\v!max\d_pack_layers_y_size\else\p_pack_layers_voffset\fi+\p_pack_layers_offset+\p_pack_layers_dy
- \relax
- \ifx\p_pack_layers_position\v!yes
- \pack_layers_set_last_position_yes
- \else
- \pack_layers_set_last_position_nop
- \fi
- %
- \ifx\m_pack_layers_page\empty \else % is expanded
- \edef\m_pack_layers_page{:\m_pack_layers_page}%
- \ifcsname\??layerbox\m_pack_layers_target\currentlayer\m_pack_layers_page\endcsname \else
- \expandafter\newbox\csname\??layerbox\m_pack_layers_target\currentlayer\m_pack_layers_page\endcsname
- \fi
- \fi
- \chardef\layerpagebox\csname\??layerbox\m_pack_layers_target\currentlayer\m_pack_layers_page\endcsname
- \ifvoid\layerpagebox
- \gsetboxllx\layerpagebox\zeropoint
- \gsetboxlly\layerpagebox\zeropoint
- \fi
- \global\setbox\layerpagebox\vpack %to \layerparameter\c!height % new, otherwise no negative y possible
- {\offinterlineskip
- \ifvoid\layerpagebox
- \let\lastlayerwidth \zeropoint
- \let\lastlayerheight\zeropoint
- \else
- \edef\lastlayerwidth {\the\wd\layerpagebox}%
- \edef\lastlayerheight{\the\ht\layerpagebox}%
- \ht\layerpagebox\zeropoint
- \dp\layerpagebox\zeropoint
- \wd\layerpagebox\zeropoint
- \ifx\p_pack_layers_direction\v!reverse\else
- \box\layerpagebox
- \fi
- \fi
- % don't move
- \xdef\lastlayerwd{\the\wd\nextbox}%
- \xdef\lastlayerht{\the\ht\nextbox}% % not entirely ok when grid !
- \xdef\lastlayerdp{\the\dp\nextbox}% % not entirely ok when grid !
- % this code
- \ifx\p_pack_layers_location\v!grid
- \ht\nextbox\strutheight
- \dp\nextbox\strutdepth
- \else
- \setbox\nextbox\hpack
- {\alignedbox[\p_pack_layers_location]\vpack{\box\nextbox}}%
- \fi
- \ifnum\p_pack_layers_line=\zerocount\else % no \ifcase, can be negative
- \advance\d_pack_layers_y_position\dimexpr\p_pack_layers_line\lineheight+\topskip-\lineheight-\ht\nextbox\relax
- \fi
- \ifnum\p_pack_layers_column=\zerocount\else % no \ifcase, can be negative
- \advance\d_pack_layers_x_position\layoutcolumnoffset\p_pack_layers_column\relax
- \fi
- \ifx\p_pack_layers_location\v!grid
- \setbox\nextbox\hpack
- {\alignedbox[rb]\vpack{\box\nextbox}}%
- \fi
- % ll registration
- \scratchdimen\dimexpr\d_pack_layers_x_position+\d_pack_layers_x_offset\relax
- \ifdim\scratchdimen<\getboxllx\layerpagebox
- \gsetboxllx\layerpagebox\scratchdimen
- \fi
- \advance\scratchdimen\wd\nextbox
- \wd\nextbox\ifdim\scratchdimen>\lastlayerwidth \scratchdimen \else \lastlayerwidth \fi
- \scratchdimen\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax
- \ifdim\scratchdimen<\getboxlly\layerpagebox
- \gsetboxlly\layerpagebox\scratchdimen
- \fi
- % ll compensation
- \advance\scratchdimen\dimexpr\ht\nextbox+\dp\nextbox\relax
- \ht\nextbox\ifdim\scratchdimen>\lastlayerheight \scratchdimen \else \lastlayerheight \fi
- \dp\nextbox\zeropoint
- % placement
- \hsize\p_pack_layers_width
- \vpack to \p_pack_layers_height \bgroup
- \smashbox\nextbox
- \vskip\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax
- \hskip\dimexpr\d_pack_layers_x_position+\d_pack_layers_x_offset\relax
- % or maybe instead of the \vskip
- % \raise-\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax
- \box\nextbox
- \ifvoid\layerpagebox
- % already flushed
- \else
- % the reverse case % check !
- \vskip-\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax
- \box\layerpagebox
- \fi
- \egroup}%
- % when position is true, the layerbox holds the compensation and needs
- % to be placed; never change this !
- \ifvoid\b_layers \else
- \box\b_layers
- \fi}
-
-\def\pack_layers_set_bottom_positions
- {\ifnum\p_pack_layers_line=\zerocount\else % can be < 0
- \edef\p_pack_layers_line{\the\numexpr-\p_pack_layers_line+\layoutlines+\plusone\relax}% use counter instead ?
- \fi
- \ifdim\d_pack_layers_y_size>\zeropoint
- \advance\d_pack_layers_y_position-\d_pack_layers_y_size
- \d_pack_layers_y_position-\d_pack_layers_y_position
- \d_pack_layers_y_offset-\d_pack_layers_y_offset
- \fi}
-
-\def\pack_layers_set_right_positions
- {\ifnum\p_pack_layers_column=\zerocount\else % can be < 0
- \edef\p_pack_layers_column{\the\numexpr-\layerparameter\c!column+\layoutcolumns+\plusone\relax}% use counter instead ?
- \fi
- \ifdim\d_pack_layers_x_size>\zeropoint
- \advance\d_pack_layers_x_position-\d_pack_layers_x_size
- \d_pack_layers_x_position-\d_pack_layers_x_position
- \d_pack_layers_x_offset-\d_pack_layers_x_offset
- \fi}
-
-\def\pack_layers_set_middle_positions
- {\ifdim\d_pack_layers_x_size>\zeropoint \advance\d_pack_layers_x_position.5\d_pack_layers_x_size \fi
- \ifdim\d_pack_layers_y_size>\zeropoint \advance\d_pack_layers_y_position.5\d_pack_layers_y_size \fi}
-
-%D Given the task to be accomplished, the previous macro is not even that
-%D complicated. It mainly comes down to skipping to the right place and placing a
-%D box on top of or below the existing content. In the case of position tracking,
-%D another reference point is chosen.
-
-%D \macros
-%D {doifelselayerdata}
-
-\def\doifelselayerdata#1%
- {\ifcsname\??layerbox#1\endcsname
- %\ifvoid\csname\??layerbox#1\endcsname
- \ifvoid\lastnamedcs
- \doubleexpandafter\secondoftwoarguments
- \else
- \doubleexpandafter\firstoftwoarguments
- \fi
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doiflayerdataelse\doifelselayerdata
-
-%D \macros
-%D {flushlayer}
-%D
-%D When we flush a layer, we flush both the main one and the page dependent one
-%D (when defined). This feature is more efficient in \ETEX\ since there testing for
-%D an undefined macro does not takes hash space.
-
-% todo: setups before flush, handy hook
-
-\unexpanded\def\flushlayer[#1]% quite core, so optimized (todo: check for void)
- {\begingroup
- \forgetall
- \edef\currentlayer{#1}%
- \edef\p_pack_layers_state{\layerparameter\c!state}%
- \ifx\p_pack_layers_state\v!stop
- % nothing
- \orelse\ifx\p_pack_layers_state\v!next
- \global\letlayerparameter\c!state\v!start % dangerous, stack-built-up
- \orelse\ifx\p_pack_layers_state\v!continue
- \global\letlayerparameter\c!state\v!repeat % dangerous, stack-built-up
- \else
- \edef\p_pack_layers_doublesided{\layerparameter\c!doublesided}%
- \ifx\p_pack_layers_doublesided\v!yes
- \ifcsname\??layerbox#1\endcsname
- % we can make a dedicated one for this
- \doifbothsidesoverruled
- {\pack_layers_flush_double\v!left }%
- {\pack_layers_flush_double\v!right}%
- {\pack_layers_flush_double\v!left }%
- \else
- \pack_layers_flush_single
- \fi
- \else
- \pack_layers_flush_single
- \fi
- \fi
- \endgroup}
-
-% \def\pack_layers_flush_single
-% {\startoverlay
-% {\ifcsname\??layerbox \currentlayer \endcsname\pack_layers_flush_indeed\plusone \currentlayer \fi}%
-% {\ifcsname\??layerbox \currentlayer:\the\realpageno\endcsname\pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\fi}%
-% \stopoverlay}
-%
-% \def\pack_layers_flush_double#1%
-% {\startoverlay
-% {\ifcsname\??layerbox \currentlayer \endcsname\pack_layers_flush_indeed\plusone \currentlayer \fi}%
-% {\ifcsname\??layerbox \currentlayer:\the\realpageno\endcsname\pack_layers_flush_indeed\zerocount {\currentlayer:\the\realpageno}\fi}%
-% {\ifcsname\??layerbox#1\currentlayer \endcsname\pack_layers_flush_indeed\plusone {#1\currentlayer }\fi}%
-% {\ifcsname\??layerbox#1\currentlayer:\the\realpageno\endcsname\pack_layers_flush_indeed\zerocount{#1\currentlayer:\the\realpageno}\fi}%
-% \stopoverlay}
-
-% optimized:
-
-\def\pack_layers_flush_single
- {\ifcsname\??layerbox\currentlayer\endcsname
- \ifvoid\lastnamedcs
- \ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname
- \ifvoid\lastnamedcs\else
- \chardef\b_layer_two\lastnamedcs
- \pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two
- \fi
- \fi
- \else
- \chardef\b_layer_one\lastnamedcs
- \ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname
- \ifvoid\lastnamedcs\else
- \chardef\b_layer_two\lastnamedcs
- \startoverlay
- {\pack_layers_flush_indeed\plusone \currentlayer \b_layer_one}%
- {\pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two}%
- \stopoverlay
- \fi
- \else
- \pack_layers_flush_indeed\plusone\currentlayer\b_layer_one
- \fi
- \fi
- \orelse\ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname
- \ifvoid\lastnamedcs
- % nothing
- \else
- \chardef\b_layer_two\lastnamedcs
- \pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two
- \fi
- \fi}
-
-% less optimized:
-
-\def\pack_layers_flush_double#1%
- {\startoverlay
- {\ifcsname\??layerbox\currentlayer\endcsname
- \ifvoid\lastnamedcs\else \chardef\b_layer_two\lastnamedcs
- \pack_layers_flush_indeed\plusone\currentlayer\b_layer_two
- \fi
- \fi}%
- {\ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname
- \ifvoid\lastnamedcs\else \chardef\b_layer_two\lastnamedcs
- \pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two
- \fi
- \fi}%
- {\ifcsname\??layerbox#1\currentlayer\endcsname
- \ifvoid\lastnamedcs\else \chardef\b_layer_two\lastnamedcs
- \pack_layers_flush_indeed\plusone{#1\currentlayer}\b_layer_two
- \fi
- \fi}%
- {\ifcsname\??layerbox#1\currentlayer:\the\realpageno\endcsname
- \ifvoid\lastnamedcs\else \chardef\b_layer_two\lastnamedcs
- \pack_layers_flush_indeed\zerocount{#1\currentlayer:\the\realpageno}\b_layer_two
- \fi
- \fi}%
- \stopoverlay}
-
-\let\pack_layers_top_fill \relax
-\let\pack_layers_bottom_fill\vss
-
-%def\pack_layers_flush_indeed#1#2%
-\def\pack_layers_flush_indeed#1#2#3%
- {\begingroup % already grouped
- \offinterlineskip
- \edef\p_pack_layers_preset{\layerparameter\c!preset}%
- \ifcsname\??layerpreset\p_pack_layers_preset\endcsname
- \lastnamedcs
- \fi
- \edef\p_pack_layers_method{\layerparameter\c!method}%
- \edef\p_pack_layers_option{\layerparameter\c!option}%
- \ifx\p_pack_layers_option\v!test
- \settrue\c_pack_layers_trace
- \traceboxplacementtrue
- \fi
- \ifcase#1\relax
- \setfalse\c_pack_layers_repeated
- \else
- \edef\p_pack_layers_position{\layerparameter\c!position}%
- \ifx\p_pack_layers_position\v!yes
- \setfalse\c_pack_layers_repeated
- \else
- \edef\p_pack_layers_repeat{\layerparameter\c!repeat}%
- \ifx\p_pack_layers_repeat\v!yes
- \settrue\c_pack_layers_repeated
- \orelse\ifx\p_pack_layers_state\v!repeat
- \settrue\c_pack_layers_repeated
- \else
- \setfalse\c_pack_layers_repeated
- \fi
- \fi
- \fi
- %chardef\b_layers\csname\??layerbox#2\endcsname % trick
- \let\b_layers#3%
- % we need to copy in order to retain the negative offsets for a next
- % stage of additions, i.e. llx/lly accumulate in repeat mode and the
- % compensation may differ each flush depending on added content
- \setbox\nextbox
- \ifx\p_pack_layers_method\v!fit
- \pack_layers_positioned_box_yes
- \else
- \pack_layers_positioned_box_nop
- \fi
- % todo: method=offset => overlayoffset right/down (handy for backgrounds with offset)
- \doifelseoverlay{#2}%
- {\setlayoutcomponentattribute{\v!layer:#2}}%
- \resetlayoutcomponentattribute
- % we have conflicting demands: some mechanisms want ll anchoring .. I need to figure this out
- % and maybe we will have 'origin=bottom' or so
- \setbox\nextbox
- \ifx\p_pack_layers_option\v!test \ruledvbox \else \vpack \fi \ifx\p_pack_layers_method\v!overlay to \d_overlay_height \fi \layoutcomponentboxattribute
- {\pack_layers_top_fill
-%
-% \hpack \ifx\p_pack_layers_method\v!overlay to \d_overlay_width \fi
-% {\box\nextbox
-% \hss}%
-%
- \ifx\p_pack_layers_method\v!overlay \wd\nextbox\d_overlay_width\fi
- \box\nextbox
-%
- \pack_layers_bottom_fill}%
- % \edef\currentlayer{#2}% :\the\realpageno}% local .. check \anchor
- % \edef\p_pack_layers_position{\layerparameter\c!position}% local
- \ifx\p_pack_layers_position\v!yes
- \edef\p_pack_layers_region{\layerparameter\c!region}%
- \ifx\p_pack_layers_region\empty
- \else
- \anch_mark_tagged_box\nextbox\p_pack_layers_region % was \layeranchor
- \fi
- \fi
- \box\nextbox
- %
- \ifconditional\c_pack_layers_repeated\else
- \gsetboxllx\b_layers\zeropoint
- \gsetboxlly\b_layers\zeropoint
- \fi
- \endgroup}
-
-\def\pack_layers_positioned_box_yes
- {\vpack
- {\vskip-\getboxlly\b_layers
- \hskip-\getboxllx\b_layers
- \hsize-\dimexpr\getboxllx\b_layers-\wd\b_layers\relax
- \ifconditional\c_pack_layers_repeated\copy\else\box\fi\b_layers}}
-
-\def\pack_layers_positioned_box_nop
- {\ifconditional\c_pack_layers_repeated\copy\else\box\fi\b_layers}
-
-% \definelayer[test][method=fit] \setupcolors[state=start,option=test]
-%
-% \framed[framecolor=red,offset=overlay]{\setlayer[test]{aa}\setlayer[test][x=10pt]{g}\flushlayer[test]}
-% \framed[framecolor=red,offset=overlay]{\setlayer[test]{aa}\setlayer[test][x=-10pt]{bb}\flushlayer[test]}
-% \framed[framecolor=red,offset=overlay]{\setlayer[test][x=-20pt]{cccccc}\flushlayer[test]}
-% \framed[framecolor=red,offset=overlay]{\setlayer[test]{dd}\setlayer[test][x=-20pt,y=-3pt]{eeeeee}\flushlayer[test]}
-
-%D \macros
-%D {composedlayer,placelayer,tightlayer}
-%D
-%D This is a handy shortcut, which saves a couple of braces when we use it as
-%D parameter. This name also suits better to other layering commands.
-
-\unexpanded\def\composedlayer#1{\flushlayer[#1]}
-
-\unexpanded\def\tightlayer[#1]%
- {\hpack
- {\def\currentlayer{#1}% todo: left/right
- \setbox\nextbox\emptybox
- \d_overlay_width \layerparameter\c!width
- \d_overlay_height\layerparameter\c!height
- \composedlayer{#1}}}
-
-\let\placelayer\flushlayer
-
-%D \macros
-%D {setMPlayer}
-%D
-%D The following layer macro uses the positions that are registered by \METAPOST.
-%D
-%D \starttyping
-%D \definelayer[test]
-%D
-%D \setMPlayer [test] [somepos-1] {Whatever we want here!}
-%D \setMPlayer [test] [somepos-2] {Whatever we need there!}
-%D \setMPlayer [test] [somepos-3] {\externalfigure[cow.mps][width=2cm]}
-%D
-%D \startuseMPgraphic{oeps}
-%D draw fullcircle scaled 10cm withcolor red ;
-%D register ("somepos-1",2cm,3cm,center currentpicture) ;
-%D register ("somepos-2",8cm,5cm,(-1cm,-2cm)) ;
-%D register ("somepos-3",0cm,0cm,(-2cm,2cm)) ;
-%D \stopuseMPgraphic
-%D
-%D \getMPlayer[test]{\useMPgraphic{oeps}}
-%D \stoptyping
-%D
-%D The last line is equivalent to
-%D
-%D \starttyping
-%D \framed
-%D [background={foreground,test},offset=overlay]
-%D {\useMPgraphic{oeps}}
-%D \stoptyping
-
-\unexpanded\def\setMPlayer
- {\dotripleempty\pack_layers_set_MP}
-
-\def\MPlayerwidth {\hsize}
-\def\MPlayerheight{\vsize}
-
-\def\pack_layers_set_MP[#1][#2][#3]%
- {\edef\MPlayerwidth {\MPw{#2}}%
- \edef\MPlayerheight{\MPh{#2}}%
- \setlayer[#1][\c!x=\MPx{#2},\c!y=\MPy{#2},\c!position=\v!no,#3]}
-
-\unexpanded\def\getMPlayer
- {\dodoubleempty\pack_layers_get_MP}
-
-\def\pack_layers_get_MP[#1][#2]%
- {\framed[\c!background={\v!foreground,#1},\c!frame=\v!off,\c!offset=\v!overlay,#2]} % takes argument
-
-%D Watch out, a redefinition:
-
-\ifdefined\settextpagecontent \else
- \writestatus\m!system{error in page-lyr.tex} \wait
-\fi
-
-\definelayer
- [OTRTEXT]
-
-\setuplayer
- [OTRTEXT]
- [\c!width=\innermakeupwidth,
- \c!height=\textheight]
-
-\let\normalsettextpagecontent\settextpagecontent % will be overloaded in page-spr
-
-\unexpanded\def\settextpagecontent#1#2#3% #2 and #3 will disappear
- {\doifelselayerdata{OTRTEXT}
- {\setbox#1\hpack to \makeupwidth
- {\startoverlay
- {\tightlayer[OTRTEXT]} % first, otherwise problems with toc
- {\normalsettextpagecontent{#1}{#2}{#3}\box#1}
- \stopoverlay}%
- \dp#1\zeropoint}%
- {\normalsettextpagecontent{#1}{#2}{#3}}}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-mrl.mkiv b/Master/texmf-dist/tex/context/base/mkiv/pack-mrl.mkiv
index e5d19d3b3de..1b7d4eb3018 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-mrl.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-mrl.mkiv
@@ -36,7 +36,7 @@
\installcorenamespace{blackrules}
-\installsimplecommandhandler \??blackrules {blackrules}
+\installsimplecommandhandler \??blackrules {blackrules} \??blackrules
\unexpanded\def\blackrule
{\hpack\bgroup
@@ -810,9 +810,9 @@
%D a piece of text, like
%D
%D \startbuffer
-%D
-%D \stopbuffer\fillinline \input reich \par
+%D \fillinline \input reich \par
%D \fillinline[margin=0cm] \input reich \par
+%D \stopbuffer
%D
%D \startexample
%D \getbuffer
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-obj.lua b/Master/texmf-dist/tex/context/base/mkiv/pack-obj.lua
index ea36b10de7a..445085776f3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-obj.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-obj.lua
@@ -176,6 +176,7 @@ function objects.restore(ns,id) -- why not just pass a box number here too (ok,
number = index,
page = getcount("realpageno"),
}
+ -- list is a rule
setlink(list,page)
end
setbox("objectbox",hbox)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-ori.lua b/Master/texmf-dist/tex/context/base/mkiv/pack-ori.lua
deleted file mode 100644
index a786b19ef13..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-ori.lua
+++ /dev/null
@@ -1,70 +0,0 @@
-if not modules then modules = { } end modules ['pack-ori'] = {
- version = 1.001,
- comment = "companion to supp-box.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-local context = context
-local implement = interfaces.implement
-local variables = interfaces.variables
-
-local settings_to_array = utilities.parsers.settings_to_array
-
-local orientation = {
- [variables.up] = 0x000,
- [variables.left] = 0x001,
- [variables.down] = 0x002,
- [variables.right] = 0x003,
- [variables.top] = 0x004,
- [variables.bottom] = 0x005,
-}
-local vertical = {
- [variables.line] = 0x000,
- [variables.top] = 0x010,
- [variables.bottom] = 0x020,
- [variables.middle] = 0x030,
-}
-local horizontal = {
- [variables.middle] = 0x000,
- [variables.flushleft] = 0x100,
- [variables.flushright] = 0x200,
- [variables.left] = 0x300,
- [variables.right] = 0x400,
-}
-
-implement {
- name = "toorientation",
- public = true,
- arguments = {
- {
- { "horizontal", "string" },
- { "vertical", "string" },
- { "orientation", "string" },
- }
- },
- actions = function(t)
- local n = 0
- local m = t.horizontal if m then n = n | (horizontal [m] or 0) end
- local m = t.vertical if m then n = n | (vertical [m] or 0) end
- local m = t.orientation if m then n = n | (orientation[m] or 0) end
- -- logs.report("orientation","0x%03X : %s",n,table.sequenced(t))
- context(n)
- end,
-}
-
-implement {
- name = "stringtoorientation",
- public = true,
- arguments = "string",
- actions = function(s)
- local n = 0
- local t = settings_to_array(s)
- local m = t[1] if m then n = n | (horizontal [m] or 0) end
- local m = t[2] if m then n = n | (vertical [m] or 0) end
- local m = t[3] if m then n = n | (orientation[m] or 0) end
- -- logs.report("orientation","0x%03X : %s",n,s)
- context(n)
- end,
-}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-ori.mkxl b/Master/texmf-dist/tex/context/base/mkiv/pack-ori.mkxl
deleted file mode 100644
index 061768f94f9..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-ori.mkxl
+++ /dev/null
@@ -1,88 +0,0 @@
-%D \module
-%D [ file=pack-ori, % was experimental
-%D version=2019.07.30,
-%D title=\CONTEXT\ Packaging Macros,
-%D subtitle=Anchoring,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Packaging Macros / Anchoring}
-
-\registerctxluafile{pack-ori}{}
-
-\unprotect
-
-%D Possible options are:
-%D
-%D \starttabulate[|T|T|]
-%D \NC orientation \NC up left down right top bottom
-%D \NC vertical \NC line top bottom middle
-%D \NC horizontal \NC middle flushleft flushright left right
-%D \stoptabulate
-
-\installcorenamespace{orientation}
-\installcorenamespace{orientations}
-
-\installcommandhandler \??orientation {orientation} \??orientation
-
-\setuporientation
- [\c!orientation=\v!normal,
- \c!horizontal=\v!normal,
- \c!vertical=\v!normal]
-
-\appendtoks
- \expandafter\chardef\csname\??orientations\currentorientation\endcsname\toorientation
- orientation {\orientationparameter\c!orientation}
- horizontal {\orientationparameter\c!horizontal}
- vertical {\orientationparameter\c!vertical}
- \relax\relax
-\to \everydefineorientation
-
-\defineorientation[\v!normal]
-
-\defineorientation[\v!up] [\c!orientation=\v!up]
-\defineorientation[\v!down] [\c!orientation=\v!down]
-\defineorientation[\v!left] [\c!orientation=\v!left]
-\defineorientation[\v!right] [\c!orientation=\v!right]
-\defineorientation[\v!top] [\c!orientation=\v!top]
-\defineorientation[\v!bottom][\c!orientation=\v!bottom]
-
-%D There will be some more helpers here.
-
-\def\theorientation#1%
- {\numexpr
- \ifcsname\??orientations#1\endcsname
- \lastnamedcs
- \else
- \zerocount
- \fi
- \relax}
-
-\def\autoorientation#1%
- {\numexpr
- \ifcsname\??orientations#1\endcsname
- \lastnamedcs
- \else
- \auto_orientation{#1}%
- \fi
- \relax}
-
-\def\auto_orientation#1%
- {\immediateassignment\global\expandafter\chardef\csname\??orientations#1\endcsname\stringtoorientation{#1}%
- \csname\??orientations#1\endcsname}
-
-\unexpanded\def\doifelseorientation#1%
- {\ifcsname\??orientations#1\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-% \def\iforientationcsname#1{\ifcsname\??orientations}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-rul.lua b/Master/texmf-dist/tex/context/base/mkiv/pack-rul.lua
index ef8d8136f48..8e410f0cfc0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-rul.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-rul.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['pack-rul'] = {
version = 1.001,
+ optimize = true,
comment = "companion to pack-rul.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -122,6 +123,7 @@ local function doreshapeframedbox(n)
if hdone then
for h, id, subtype, list in nextlist, list do
if list and id == hlist_code then
+ -- called a lot so maybe a simple case is needed
if subtype == boxlist_code or subtype == linelist_code then
-- getdirection is irrelevant here so it will go
-- somehow a parfillskip also can get influenced
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkiv b/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkiv
index 8732c7e6b7c..e06949ed80e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkiv
@@ -1542,7 +1542,7 @@
\d_framed_linewidth
\fi
\ifconditional\c_framed_has_offset
- \advance\d_framed_applied_offset\localoffset
+ \advance\d_framed_applied_offset\localoffset\relax
\fi
\ifconditional\c_framed_has_extra_offset
\pack_framed_apply_extra_offsets % includes \d_framed_applied_offset
@@ -1900,7 +1900,7 @@
{\iffirstargument
\setupcurrentmathframed[#1]%
\fi
- \c_framed_mstyle\mathstyle
+ \c_framed_mstyle\normalmathstyle
\edef\m_framed_location{\mathframedparameter\c!location}%
\ifx\m_framed_location\v!mathematics
\let\normalstrut\pack_framed_math_pos
@@ -2693,7 +2693,7 @@
% \edef\p_framed_text_strut{\letframedtextparameter\c!strut}% to be used
\letframedtextparameter\c!strut\v!no
\inheritedframedtextframed\bgroup
- \let\\=\endgraf
+ \let\\\endgraf
\edef\p_framed_text_depthcorrection{\framedtextparameter\c!depthcorrection}%
\ifx\p_framed_text_depthcorrection\v!on
\pack_framed_text_start_depth_correction
@@ -2814,7 +2814,7 @@
\letframedtextparameter\c!strut\v!no
\inheritedframedtextframed\bgroup
\blank[\v!disable]%
- \let\\=\endgraf
+ \let\\\endgraf
\useframedtextstyleandcolor\c!style\c!color
\vskip-\strutdp % brrr why is this needed ... needs to be sorted out, see testcase 1
\framedtextparameter\c!inner
@@ -3007,8 +3007,6 @@
%D A Goodie:
-\def\v!unframed{unframed}
-
\defineframed
[\v!unframed]
[\c!frame=\v!off,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkxl b/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkxl
deleted file mode 100644
index 8fd23fbb1b7..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/pack-rul.mkxl
+++ /dev/null
@@ -1,3089 +0,0 @@
-%D \module
-%D [ file=pack-rul, % was core-rul,
-%D version=1998.10.16,
-%D title=\CONTEXT\ Packaging Macros,
-%D subtitle=Ruled Content,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Packaging Macros / Ruled Content}
-
-%D The code here is expanded lots of time as framed is used in many places. This is
-%D why the code here is (and gets) optimized as much as possible. Also, by avoiding
-%D packaging and expansion we also keep tracing reasonable. For instance, multiple
-%D stacked backgrounds can slow down a run if not optimized this way.
-
-\registerctxluafile{pack-rul}{optimize}
-
-\unprotect
-
-% \definesystemvariable {ol} % OmLijnd -> check scrn-fld too
-
-%D \macros
-%D {linewidth, setuplinewidth}
-%D
-%D This module deals with rules (lines) in several ways. First we introduce two
-%D macros that can be used to set some common characteristics.
-%D
-%D \showsetup{setuplinewidth}
-%D
-%D The linewidth is available in \type{\linewidth}. The preset value of .4pt equals
-%D the default hard coded \TEX\ rule width.
-
-\newdimen\linewidth
-
-\unexpanded\def\setuplinewidth
- {\dosingleargument\pack_framed_setup_line_width}
-
-\def\pack_framed_setup_line_width[#1]%
- {\assigndimension{#1}\linewidth{.2\points}{.4\points}{.6\points}}
-
-%D The parameter handler:
-
-\installcorenamespace{framed}
-\installcorenamespace{framedtop}
-\installcorenamespace{framedbottom}
-\installcorenamespace{framedleft}
-\installcorenamespace{framedright}
-
-\installcorenamespace{regularframed}
-\installcorenamespace{simplifiedframed}
-
-\installcommandhandler \??framed {framed} \??framed
-
-\let\pack_framed_framedparameter \framedparameter
-\let\pack_framed_framedparameterhash\framedparameterhash
-\let\pack_framed_setupcurrentframed \setupcurrentframed
-
-\def\pack_framed_initialize
- {\let\framedparameter \pack_framed_framedparameter
- \let\framedparameterhash\pack_framed_framedparameterhash
- \let\setupcurrentframed \pack_framed_setupcurrentframed
- \inframedtrue}
-
-%D A helper:
-
-\def\frameddimension#1{\the\dimexpr\framedparameter{#1}\relax}
-
-%D Inheritance:
-
-\def\installinheritedframed#1%
- {\normalexpanded{\doinstallinheritedframed
- \expandafter\noexpand\csname current#1\endcsname
- \expandafter\noexpand\csname #1parameter\endcsname
- \expandafter\noexpand\csname #1parameterhash\endcsname
- \expandafter\noexpand\csname do#1parameter\endcsname
- \expandafter\noexpand\csname do#1parentparameter\endcsname
- \expandafter\noexpand\csname do#1rootparameter\endcsname
- \expandafter\noexpand\csname setupcurrent#1\endcsname
- \expandafter\noexpand\csname inherited#1framed\endcsname
- \expandafter\noexpand\csname inherited#1framedbox\endcsname}} % new
-
-\unexpanded\def\doinstallinheritedframed#1#2#3#4#5#6#7#8#9%
- {\def#5##1##2{\ifx##1\relax#6{##2}\else#4{##1}{##2}\fi}%
- %\def#6##1{\ifcsname\??framed:##1\endcsname\??framed:##1\else\s!empty\fi}% root
- \def#6##1{\ifcsname\??framed:##1\endcsname\??framed:##1\else\??empty\fi}% root
- \unexpanded\def#8%
- {\bgroup
- \bgroup
- \inframedtrue
- \let\currentframed #1%
- \let\framedparameter #2%
- \let\framedparameterhash#3%
- \let\setupcurrentframed #7%
- \pack_framed_process_indeed}%
- \unexpanded\def#9%
- {\bgroup
- \inframedtrue
- \let\currentframed #1%
- \let\framedparameter #2%
- \let\framedparameterhash#3%
- \let\setupcurrentframed #7%
- \pack_framed_process_box_indeed}}
-
-\unexpanded\def\installframedcommandhandler#1#2#3%
- {\installcommandhandler{#1}{#2}{#3}%
- \installinheritedframed{#2}}
-
-\unexpanded\def\installframedautocommandhandler#1#2#3%
- {\installautocommandhandler{#1}{#2}{#3}%
- \installinheritedframed{#2}}
-
-\unexpanded\def\installsimpleframedcommandhandler#1#2#3%
- {\installsimplecommandhandler{#1}{#2}{#3}%
- \installinheritedframed{#2}}
-
-% for regular framed
-
-\setupframed
- [\c!width=\v!fit,
- \c!height=\v!broad,
- %\c!minheight=\zeropoint,
- %\c!lines=,
- \c!offset=.25\exheight, % \defaultframeoffset
- \c!empty=\v!no,
- \c!frame=\v!on,
- %\c!topframe=,
- %\c!bottomframe=,
- %\c!leftframe=,
- %\c!rightframe=,
- \c!radius=.5\bodyfontsize,
- \c!rulethickness=\linewidth,
- \c!corner=\v!rectangular,
- \c!depth=\zeropoint,
- %\c!foregroundcolor=,
- %\c!foregroundstyle=,
- %\c!background=,
- %\c!backgroundcolor=,
- \c!backgroundoffset=\zeropoint,
- %\c!framecolor=,
- \c!frameoffset=\zeropoint,
- \c!backgroundcorner=\framedparameter\c!corner, % use \p_ here
- \c!backgroundradius=\framedparameter\c!radius,
- \c!backgrounddepth=\framedparameter\c!depth,
- \c!framecorner=\framedparameter\c!corner,
- \c!frameradius=\framedparameter\c!radius,
- \c!framedepth=\framedparameter\c!depth,
- %\c!component=,
- %\c!region=,
- %\c!align=,
- \c!bottom=\vss,
- %\c!top=,
- \c!strut=\v!yes,
- \c!autostrut=\v!yes,
- \c!location=\v!normal,
- %\c!orientation=,
- %\c!anchoring=,
- \c!autowidth=\v!yes,
- %\c!setups=,
- \c!loffset=\zeropoint,
- \c!roffset=\zeropoint,
- \c!toffset=\zeropoint,
- \c!boffset=\zeropoint]
-
-%D For backgrounds and such:
-
-\defineframed
- [\??simplifiedframed]
- [\c!frame=\v!off,
- \c!depth=\zeropoint,
- \c!offset=\v!overlay,
- \c!component=,
- \c!region=,
- \c!radius=.5\bodyfontsize,
- \c!rulethickness=\linewidth,
- \c!corner=\v!rectangular,
- \c!backgroundoffset=\zeropoint,
- \c!frameoffset=\zeropoint,
- \c!backgroundcorner=\framedparameter\c!corner, % use \p_ here
- \c!backgroundradius=\framedparameter\c!radius,
- \c!backgrounddepth=\framedparameter\c!depth,
- \c!framecorner=\framedparameter\c!corner,
- \c!frameradius=\framedparameter\c!radius,
- \c!framedepth=\framedparameter\c!depth,
- \c!location=\v!normal,
- \c!loffset=\zeropoint,
- \c!roffset=\zeropoint,
- \c!toffset=\zeropoint,
- \c!boffset=\zeropoint]
-
-\unexpanded\def\definesimplifiedframed[#1]% no settings
- {\defineframed[#1][\??simplifiedframed]%
- \expandafter\let\csname#1\endcsname\undefined}
-
-\expandafter\let\csname\??simplifiedframed\endcsname\undefined
-
-%D We will communicate through module specific variables, current framed
-%D parameters and some reserved dimension registers.
-
-\newdimen\d_framed_target_wd
-\newdimen\d_framed_target_ht
-\newdimen\d_framed_target_dp
-\newdimen\d_framed_linewidth \let\ruledlinewidth\d_framed_linewidth % needed at lua end
-
-\let\p_framed_frame \empty % \framedparameter\c!frame
-\let\p_framed_backgroundoffset\empty
-\let\p_framed_foregroundstyle \empty
-\let\p_framed_autostrut \empty
-\let\p_framed_location \empty
-\let\p_framed_orientation \empty
-\let\p_framed_anchoring \empty
-\let\p_framed_autowidth \empty
-\let\p_framed_franalyze \empty
-\let\p_framed_backgroundcorner\empty
-\let\p_framed_backgroundradius\empty
-\let\p_framed_framecorner \empty
-\let\p_framed_frameradius \empty
-\let\p_framed_lines \empty
-\let\p_framed_empty \empty
-\let\p_framed_backgroundcolor \empty
-\let\p_framed_framecolor \empty
-\let\p_framed_component \empty
-\let\p_framed_background \empty
-\let\p_framed_rulethickness \empty
-\let\p_framed_foregroundcolor \empty
-\let\p_framed_setups \empty
-
-%D We don't have to stick to a \TEX\ drawn rule, but also can use rounded
-%D or even fancier shapes, as we will see later on.
-
-\def\pack_framed_filled_box
- {\edef\p_framed_backgroundcorner{\framedparameter\c!backgroundcorner}%
- \ifx\p_framed_backgroundcorner\v!rectangular
- \pack_framed_filled_box_normal
- \else
- \pack_framed_filled_box_radius
- \fi}
-
-\def\pack_framed_filled_box_normal
- {\vrule
- \s!width \d_framed_target_wd
- \s!height\d_framed_target_ht
- \s!depth \d_framed_target_dp
- \relax}
-
-\def\pack_framed_filled_box_radius
- {\edef\p_framed_backgroundradius{\framedparameter\c!backgroundradius}%
- \ifzeropt\dimexpr\p_framed_backgroundradius\relax % just in case of .x\bodyfontsize
- \pack_framed_filled_box_normal
- \else
- \pack_framed_filled_box_round
- \fi}
-
-\def\pack_framed_filled_box_round
- {\raise\d_framed_target_dp\hpack{\frule
- type fill
- width \d_framed_target_wd
- height \d_framed_target_ht
- depth \d_framed_target_dp
- line \d_framed_linewidth
- radius \p_framed_backgroundradius\space
- corner {\p_framed_backgroundcorner}
- \relax}}
-
-\def\pack_framed_stroked_box
- {\edef\p_framed_framecorner{\framedparameter\c!framecorner}%
- \ifx\p_framed_framecorner\v!rectangular
- \pack_framed_stroked_box_normal
- \else
- \pack_framed_stroked_box_radius
- \fi}
-
-\def\pack_framed_stroked_box_radius
- {\edef\p_framed_frameradius{\framedparameter\c!frameradius}%
- \ifzeropt\dimexpr\p_framed_frameradius\relax % just in case of .x\bodyfontsize
- \pack_framed_stroked_box_normal
- \orelse\ifx\p_framed_frame\v!on
- \pack_framed_stroked_box_round
- \fi}
-
-% \pack_framed_stroked_box_normal % later
-
-\def\pack_framed_stroked_box_round
- {\raise\d_framed_target_dp\hpack{\frule
- width \d_framed_target_wd
- height \d_framed_target_ht
- depth \d_framed_target_dp
- line \d_framed_linewidth
- radius \p_framed_frameradius\space
- corner {\p_framed_framecorner}
- \relax}}
-
-% a lot of weird corners
-%
-% \startTEXpage
-% \dontleavehmode\framed
-% [corner=0,frame=on,framecolor=green,
-% background=color,backgroundcolor=yellow]{\tttf TEST \twodigits\recurselevel}%
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse {1} {4}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green,
-% background=color,backgroundcolor=yellow]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse {5} {8}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green,
-% background=color,backgroundcolor=yellow]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse {1} {4}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse {5} {8}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse {9}{12}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse{13}{16}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse{17}{20}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse{21}{24}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \vskip1em
-% \dontleavehmode\dostepwiserecurse{25}{28}{1}{\framed
-% [corner=\recurselevel,frame=on,framecolor=green]{\tttf TEST \twodigits\recurselevel}%
-% \quad}
-% \stopTEXpage
-
-%D It won't be a surprise that we not only provide gray boxes, but also colored
-%D ones. Here it is:
-
-\def\pack_framed_background_box_color
- {\edef\p_framed_backgroundcolor{\framedparameter\c!backgroundcolor}%
- \ifx\p_framed_backgroundcolor\empty \else
- \doifcolor\p_framed_backgroundcolor\pack_framed_background_box_color_indeed
- \fi}
-
-\def\pack_framed_background_box_color_indeed
- {\hpack{\dousecolorparameter\p_framed_backgroundcolor\pack_framed_filled_box}}
-
-%D \macros
-%D {defineoverlay, doifoverlayelse, overlayoffset,
-%D overlaywidth, overlayheight, overlaydepth,
-%D overlaycolor, overlaylinecolor, overlaylinewidth}
-%D
-%D Before we define the macro that actually takes card of the backgrounds, we
-%D introduce overlays. An overlay is something that contrary to its name lays {\em
-%D under} the text. An example of an overlay definition is:
-%D
-%D \startbuffer[tmp-1]
-%D \defineoverlay
-%D [fancy]
-%D [{\externalfigure
-%D [mp-cont.502]
-%D [width=\overlaywidth,
-%D height=\overlayheight]}]
-%D \stopbuffer
-%D
-%D \typebuffer[tmp-1]
-%D
-%D That for instance can be uses in:
-%D
-%D \startbuffer[tmp-2]
-%D \framed[backgroundachtergrond=fancy]{How Fancy!}
-%D \framed[backgroundachtergrond=fancy,frame=off]{Even More Fancy!}
-%D \stopbuffer
-%D
-%D and looks like:
-%D
-%D \startlinecorrection
-%D \vbox{\baselineskip24pt\getbuffer[tmp-1]\getbuffer[tmp-2]}
-%D \stoplinecorrection
-%D
-%D The formal definition is:
-%D
-%D \showsetup{defineoverlay}
-%D
-%D This macro's definition is a bit obscure, due the many non||used arguments and
-%D the two step call that enable the setting of the width, height and depth
-%D variables. Multiple backgrounds are possible and are specified as:
-%D
-%D \starttyping
-%D \framed[background={one,two,three}]{Three backgrounds!}
-%D \stoptyping
-%D
-%D Most drawing packages only know width and height. Therefore the dimensions have a
-%D slightly different meaning here:
-%D
-%D \startitemize[packed]
-%D \item \type{\overlaywidth }: width of the overlay
-%D \item \type{\overlayheight}: height plus depth of the overlay
-%D \item \type{\overlaydepth }: depth of the overlay
-%D \stopitemize
-%D
-%D The resulting box is lowered to the right depth.
-
-%def\overlaywidth {\the\hsize\space} % We preset the variables
-%def\overlayheight {\the\vsize\space} % to some reasonable default
-%def\overlaydepth {0pt } % values. The attributes
-%let\overlayoffset \overlaydepth % of the frame can be (are)
-%let\overlaylinewidth \overlaydepth % set somewhere else.
-\let\overlaycolor \empty
-\let\overlaylinecolor \empty
-
-\def\overlayradius{\framedparameter\c!frameradius}
-
-\newdimen\d_overlay_width
-\newdimen\d_overlay_height
-\newdimen\d_overlay_depth
-\newdimen\d_overlay_offset
-\newdimen\d_overlay_linewidth
-
-\let\m_overlay_region\empty
-
-% expandable ... in a future version the space will go (in mp one can use Overlay*)
-
-\def\overlaywidth {\the\d_overlay_width \space} % We preset the variables
-\def\overlayheight {\the\d_overlay_height \space} % to some reasonable default
-\def\overlaydepth {\the\d_overlay_depth \space} % values.
-\def\overlayoffset {\the\d_overlay_offset \space} % of the frame can be (are)
-\def\overlaylinewidth {\the\d_overlay_linewidth\space} % set somewhere else.
-\def\overlayregion {\m_overlay_region}
-
-% public but kind of protected
-
-\def\usedoverlaywidth {\dimexpr\d_overlay_width \relax}
-\def\usedoverlayheight {\dimexpr\d_overlay_height \relax}
-\def\usedoverlaydepth {\dimexpr\d_overlay_depth \relax}
-\def\usedoverlayoffset {\dimexpr\d_overlay_offset \relax}
-\def\usedoverlaylinewidth{\dimexpr\d_overlay_linewidth\relax}
-
-%D The next register is used to initialize overlays.
-
-\newtoks\everyoverlay
-
-%D An example of an initialization is the following (overlays can contain text
-%D and be executed under an regime where interlineskip is off).
-
-\installcorenamespace{overlay}
-\installcorenamespace{overlaybuiltin}
-
-\appendtoks
- \oninterlineskip
-\to \everyoverlay
-
-\prependtoks
- \hsize\d_overlay_width
- \vsize\d_overlay_height
-\to \everyoverlay
-
-\unexpanded\def\defineoverlay
- {\dodoubleargument\pack_framed_define_overlay}
-
-\def\pack_framed_define_overlay[#1][#2]%
- {\def\pack_framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\executedefinedoverlay{##1}{#2}}}%
- \processcommalist[#1]\pack_framed_define_overlay_indeed}
-
-% \unexpanded\def\executedefinedoverlay#1#2% we can share the definitions
-% {\bgroup % redundant grouping
-% \setbox\scratchbox\hbox\bgroup
-% \ifzeropt\d_framed_target_dp
-% \the\everyoverlay#2% saves wrapping (and lua call)
-% \else
-% \lower\d_framed_target_dp
-% \hbox{\the\everyoverlay#2}%
-% \fi
-% \egroup
-% \setlayoutcomponentattribute{\v!overlay:#1}%
-% \setbox\scratchbox\hpack \layoutcomponentboxattribute
-% {\kern -.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width
-% \raise-.5\dimexpr\ht\scratchbox-\d_framed_target_ht\relax % not \d_overlay_height !
-% \box\scratchbox}%
-% \wd\scratchbox\d_framed_target_wd
-% \ht\scratchbox\d_framed_target_ht
-% \dp\scratchbox\d_framed_target_dp
-% \box\scratchbox
-% \egroup}
-
-% 20191231: moved from cont-exp:
-
-\unexpanded\def\executedefinedoverlay#1#2% we can share the definitions
- {\bgroup % redundant grouping
- \setlayoutcomponentattribute{\v!overlay:#1}%
- \setbox\scratchbox\hbox \layoutcomponentboxattribute{\the\everyoverlay#2}%
- \boxxoffset\scratchbox-.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width
- \boxyoffset\scratchbox-.5\dimexpr\ht\scratchbox-\d_framed_target_ht+\d_framed_target_dp\relax % not \d_overlay_height !
- \wd\scratchbox\d_framed_target_wd
- \ht\scratchbox\d_framed_target_ht
- \dp\scratchbox\d_framed_target_dp
- \box\scratchbox
- \egroup}
-
-%D \macros
-%D {overlayfakebox}
-
-% \unexpanded\def\overlayfakebox
-% {\hpack
-% {\setbox\scratchbox\emptyhbox
-% \wd\scratchbox\d_overlay_width
-% \ht\scratchbox\d_overlay_height
-% \box\scratchbox}}
-
-\unexpanded\def\overlayfakebox
- {\hpack % redundant but needs testing
- {\novrule
- \s!width \d_overlay_width
- \s!height\d_overlay_height
- \s!depth \zeropoint}}
-
-%D For testing we provide:
-
-\def\doifelseoverlay#1% only tests external overlays
- {\ifcsname\??overlay#1\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifoverlayelse\doifelseoverlay
-
-%D The content of the box will be (temporary) saved in a box. We also have an
-%D extra box for backgrounds.
-
-\newbox\b_framed_normal
-\newbox\b_framed_extra
-
-\newtoks\everybackgroundbox
-
-\let\m_framed_background\empty % we might need a public name
-
-\def\pack_framed_process_background
- {\ifcsname\??overlaybuiltin\m_framed_background\endcsname
- \expandafter\pack_framed_process_background_indeed_internal\lastnamedcs
- \orelse\ifcsname\??overlay\m_framed_background\endcsname
- \expandafter\pack_framed_process_background_indeed_external\lastnamedcs
- \fi}
-
-\def\pack_framed_process_background_indeed_internal#1% % : in name
- {\bgroup
- \setbox\b_framed_extra\hpack\bgroup
- \ifzeropt\framedbackgroundoffset\else
- \kern-\framedbackgroundoffset
- \fi
- \hbox\bgroup#1\egroup
- \egroup
- \wd\b_framed_extra\zeropoint
- \ht\b_framed_extra\framedbackgroundheight
- \dp\b_framed_extra\framedbackgrounddepth
- \box\b_framed_extra
- \egroup}
-
-\def\pack_framed_process_background_indeed_external
- {\pack_framed_overlay_initialize
- \pack_framed_process_background_indeed_internal}
-
-\def\pack_framed_process_backgrounds#1,#2% #2 gobbles spaces (we could avoid one catch if we have nextbackground)
- {\edef\m_framed_background{#1}%
- \ifx\m_framed_background\s!unknown\else
- \pack_framed_process_background
- \expandafter\pack_framed_process_backgrounds
- \fi#2}
-
-%D Beware, a backgroundbox can be empty which is another reason why we set the
-%D width to zero instead of back-skipping.
-
-\newdimen\framedbackgroundwidth
-\newdimen\framedbackgroundheight
-\newdimen\framedbackgrounddepth
-\newdimen\framedbackgroundoffset
-
-\def\pack_framed_background_box_content% fuzzy but needed hack, this \vss, otherwise
- {\vpack to \framedbackgroundheight{\vss\box\b_framed_normal\vss}} % vertical shift \backgroundheight
-
-\def\pack_framed_set_region % experiment
- {\ifx\m_overlay_region\v!yes
- \edef\m_overlay_region{\reservedautoregiontag}%
- \fi}
-
-\def\pack_framed_add_region % experiment
- {\anch_mark_tagged_box\b_framed_normal\m_overlay_region}
-
-\def\pack_framed_add_background
- {\setbox\b_framed_normal\hpack % was vbox % see also *1*
- {%\pack_framed_forgetall % can be relaxed
- \boxmaxdepth\maxdimen
- \framedbackgroundoffset\d_framed_backgroundoffset
- \framedbackgroundwidth \wd\b_framed_normal
- \framedbackgroundheight\ht\b_framed_normal
- \framedbackgrounddepth \dp\b_framed_normal
- \d_framed_target_wd\dimexpr\framedbackgroundwidth +2\framedbackgroundoffset\relax
- \d_framed_target_ht\dimexpr\framedbackgroundheight+ \framedbackgroundoffset\relax
- \d_framed_target_dp\dimexpr\framedbackgrounddepth + \framedbackgroundoffset+\framedparameter\c!backgrounddepth\relax
- \let\pack_framed_overlay_initialize\pack_framed_overlay_initialize_indeed
- \ifx\p_framed_component\empty
- \resetlayoutcomponentattribute
- \else
- \setlayoutcomponentattribute{\v!background:\p_framed_component}%
- \fi
- \let\foregroundbox\pack_framed_background_box_content
- \hpack \layoutcomponentboxattribute to \framedbackgroundwidth\bgroup % width in case 'foreground' is used as overlay
- \the\everybackgroundbox % moved
- \expandafter\pack_framed_process_backgrounds\p_framed_background,\s!unknown,\relax % hm, messy .. look into it
- \box\b_framed_normal
- \hss
- \egroup}}
-
-\def\pack_framed_overlay_initialize_indeed
- {\d_overlay_width \d_framed_target_wd
- \d_overlay_height \dimexpr\d_framed_target_ht+\d_framed_target_dp\relax
- \d_overlay_depth \d_framed_target_dp
- \d_overlay_linewidth \d_framed_linewidth
- \d_overlay_offset \framedbackgroundoffset\relax
- \edef\overlaycolor {\framedparameter\c!backgroundcolor}% let ?
- \edef\overlaylinecolor{\framedparameter\c!framecolor}% only needed for layers
- %\edef\overlaycorner {\framedparameter\c!backgroundcorner}%
- %\edef\overlayradius {\framedparameter\c!backgroundradius}%
- \let\pack_framed_overlay_initialize\relax}
-
-%D One can explictly insert the foreground box. For that purpose we introduce the
-%D overlay \type {foreground}.
-%D
-%D We predefine two already familiar backgrounds:
-
-%letvalue{\??overlaybuiltin\v!screen }\pack_framed_background_box_gray
-\letvalue{\??overlaybuiltin\v!color }\pack_framed_background_box_color
-\letvalue{\??overlaybuiltin\v!foreground}\pack_framed_background_box_content % replaces: \defineoverlay[\v!foreground][\foregroundbox]
-
-%D We can specify overlays as a comma separated list of overlays, a sometimes
-%D handy feature.
-%D
-%D Besides backgrounds (overlays) we also need some macros to draw outlines (ruled
-%D borders). Again we have to deal with square and round corners. The first category
-%D can be handled by \TEX\ itself, the latter one depends on the driver. This macro
-%D also support a negative offset.
-
-\def\pack_framed_add_outline
- {\setbox\b_framed_normal\hpack % rules on top of box
- {\d_framed_target_wd\dimexpr\wd\b_framed_normal+2\d_framed_frameoffset\relax
- \d_framed_target_ht\dimexpr\ht\b_framed_normal+ \d_framed_frameoffset\relax
- \d_framed_target_dp\dimexpr\dp\b_framed_normal+ \d_framed_frameoffset+\framedparameter\c!framedepth\relax
- \ifdim\d_framed_target_dp<\zeropoint
- \advance\d_framed_target_ht \d_framed_target_dp
- \scratchdimen-\d_framed_target_dp
- \d_framed_target_dp\zeropoint
- \else
- \scratchdimen\zeropoint
- \fi
- \edef\overlaylinecolor{\framedparameter\c!framecolor}% twice, also in background
- \setbox\b_framed_extra\hpack
- {\kern-\d_framed_frameoffset
- \raise\scratchdimen
- \hpack{\ifx\overlaylinecolor\empty\else\dousecolorparameter\overlaylinecolor\fi\pack_framed_stroked_box}}%
- \wd\b_framed_extra\wd\b_framed_normal
- \ht\b_framed_extra\ht\b_framed_normal
- \dp\b_framed_extra\dp\b_framed_normal
- \wd\b_framed_normal\zeropoint
- \box\b_framed_normal
- \box\b_framed_extra}}
-
-\def\pack_framed_stroked_box_normal_opened
- {\setbox\scratchbox\vpack \bgroup
- \csname\??framedtop\p_framed_frame\framedparameter\c!topframe\endcsname
- \nointerlineskip % new (needed for fences)
- \hpack \bgroup
- \csname\??framedleft\p_framed_frame\framedparameter\c!leftframe\endcsname
- \novrule
- \s!width \d_framed_target_wd
- \s!height\d_framed_target_ht
- \s!depth \d_framed_target_dp
- \csname\??framedright\p_framed_frame\framedparameter\c!rightframe\endcsname
- \egroup
- \nointerlineskip % new (needed for fences)
- \csname\??framedbottom\p_framed_frame\framedparameter\c!bottomframe\endcsname
- \egroup
- \wd\scratchbox\d_framed_target_wd
- \ht\scratchbox\d_framed_target_ht
- \dp\scratchbox\d_framed_target_dp
- \box\scratchbox}
-
-\def\pack_framed_stroked_box_normal_closed
- {\hpack\bgroup
- \scratchdimen.5\d_framed_linewidth
- \hskip\scratchdimen
- \clf_framedoutline
- \dimexpr\d_framed_target_wd-\d_framed_linewidth\relax
- \dimexpr\d_framed_target_ht-\scratchdimen\relax
- \dimexpr\d_framed_target_dp-\scratchdimen\relax
- \d_framed_linewidth
- \relax
- \egroup}
-
-\def\pack_framed_stroked_box_normal
- {\ifx\p_framed_frame\v!closed
- \pack_framed_stroked_box_normal_closed
- \else
- \pack_framed_stroked_box_normal_opened
- \fi}
-
-\def\pack_framed_t_rule{\hrule\s!height\d_framed_linewidth\kern-\d_framed_linewidth}
-\def\pack_framed_b_rule{\kern-\d_framed_linewidth\hrule\s!height\d_framed_linewidth}
-\def\pack_framed_r_rule{\kern-\d_framed_linewidth\vrule\s!width\d_framed_linewidth}
-\def\pack_framed_l_rule{\vrule\s!width\d_framed_linewidth\kern-\d_framed_linewidth}
-
-\letvalue{\??framedtop \v!on \v!on}\pack_framed_t_rule
-\letvalue{\??framedtop \v!off\v!on}\pack_framed_t_rule
-\letvalue{\??framedtop \v!on }\pack_framed_t_rule
-
-\letvalue{\??framedbottom\v!on \v!on}\pack_framed_b_rule
-\letvalue{\??framedbottom\v!off\v!on}\pack_framed_b_rule
-\letvalue{\??framedbottom\v!on }\pack_framed_b_rule
-
-\letvalue{\??framedleft \v!on \v!on}\pack_framed_l_rule
-\letvalue{\??framedleft \v!off\v!on}\pack_framed_l_rule
-\letvalue{\??framedleft \v!on }\pack_framed_l_rule
-
-\letvalue{\??framedright \v!on \v!on}\pack_framed_r_rule
-\letvalue{\??framedright \v!off\v!on}\pack_framed_r_rule
-\letvalue{\??framedright \v!on }\pack_framed_r_rule
-
-% no overlapping rules
-
-\def\pack_framed_t_rules{\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}\nointerlineskip\kern-\d_framed_linewidth}
-\def\pack_framed_b_rules{\kern-\d_framed_linewidth\nointerlineskip\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}}
-\def\pack_framed_r_rules{\kern-\d_framed_linewidth\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth}
-\def\pack_framed_l_rules{\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth\kern-\d_framed_linewidth}
-
-\letvalue{\??framedtop \v!small\v!small}\pack_framed_t_rules
-\letvalue{\??framedtop \v!off \v!small}\pack_framed_t_rules
-\letvalue{\??framedtop \v!small }\pack_framed_t_rules
-
-\letvalue{\??framedbottom\v!small\v!small}\pack_framed_b_rules
-\letvalue{\??framedbottom\v!off \v!small}\pack_framed_b_rules
-\letvalue{\??framedbottom\v!small }\pack_framed_b_rules
-
-\letvalue{\??framedleft \v!small\v!small}\pack_framed_l_rules
-\letvalue{\??framedleft \v!off \v!small}\pack_framed_l_rules
-\letvalue{\??framedleft \v!small }\pack_framed_l_rules
-
-\letvalue{\??framedright \v!small\v!small}\pack_framed_r_rules
-\letvalue{\??framedright \v!off \v!small}\pack_framed_r_rules
-\letvalue{\??framedright \v!small }\pack_framed_r_rules
-
-% \framed
-% [width=4cm,height=3cm,rulethickness=3mm,
-% frame=off,rightframe=on,leftframe=on,topframe=on,bottomframe=on]
-% {}
-% \framed
-% [width=4cm,height=3cm,rulethickness=3mm,
-% frame=off,rightframe=small,leftframe=small,topframe=small,bottomframe=small]
-% {}
-% \framed
-% [width=4cm,height=3cm,rulethickness=3mm,
-% frame=off,rightframe=small,leftframe=small,topframe=small,bottomframe=on]
-% {}
-
-%D The next few macros are probably the most misused ones in \CONTEXT. They deal
-%D with putting rules around boxes, provide backgrounds, offer alignment features,
-%D and some more. We start with defining some booleans. These give an impression of
-%D what we are going to take into account.
-
-% todo : \c_framed_hasoffset
-% faster : \let\c_framed_hasoffset\falseconditional
-
-\newconditional\c_framed_has_offset
-\newconditional\c_framed_has_width
-\newconditional\c_framed_has_height
-\newconditional\c_framed_has_format
-\newconditional\c_framed_is_overlaid
-\newconditional\c_framed_has_frame
-\newconditional\c_framed_has_extra_offset
-\newconditional\c_framed_text_location_none
-
-\newconstant \c_framed_has_strut % 0=relaxes 1=pseudostruts 2=realstruts
-
-%D \macros
-%D {framed, setupframed}
-%D
-%D Ruled boxes are typeset using \type{\framed}. This command is quite versatile
-%D and, although some users will probably seldom use it, one cannot overlook its
-%D features.
-%D
-%D \showsetup{setupframed}
-%D \showsetup{framed}
-%D
-%D This general macro is a special version of an even more general case, that can
-%D easily be linked into other macros that need some kind of framing. The local
-%D version is called with an extra parameter: the variable identifier. The reason
-%D for passing this identifier between brackets lays in the mere fact that this way
-%D we can use the optional argument grabbers.
-
-\def\defaultframeoffset{.25\exheight}
-
-\installcorenamespace{regularframedlevel}
-
-\unexpanded\def\installregularframed#1%
- {\defineframed[#1]}
-
-\unexpanded\def\presetlocalframed[#1]%
- {\defineframed[#1]}
-
-% \presetlocalframed[\??framed]
-
-\newcount\c_pack_framed_nesting
-
-\unexpanded\def\pack_framed_process_framed[#1]%
- {\bgroup
- \iffirstargument % faster
- \setupcurrentframed[#1]% here !
- \fi
- \pack_framed_process_indeed}
-
-\unexpanded\def\framed
- {\bgroup
- \advance\c_pack_framed_nesting\plusone
- \expandafter\let\csname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed
- \edef\currentframed{>\the\c_pack_framed_nesting}%
- \pack_framed_initialize
- \dosingleempty\pack_framed_process_framed}
-
-\unexpanded\def\startframed
- {\dosingleempty\pack_framed_start_framed}
-
-\def\pack_framed_start_framed[#1]%
- {\bgroup
- \doifelseassignment{#1}\pack_framed_start_framed_yes\pack_framed_start_framed_nop{#1}}
-
-\def\pack_framed_start_framed_yes#1%
- {\advance\c_pack_framed_nesting\plusone
- \expandafter\let\csname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed
- \iffirstargument\secondargumenttrue\fi % dirty trick
- \edef\currentframed{>\the\c_pack_framed_nesting}%
- \pack_framed_initialize
- \bgroup
- \iffirstargument
- \secondargumenttrue % dirty trick
- \setupcurrentframed[#1]% here !
- \fi
- \pack_framed_process_indeed
- \bgroup
- \ignorespaces}
-
-\def\pack_framed_start_framed_nop#1%
- {\edef\currentframed{#1}%
- \dosingleempty\pack_framed_start_framed_nop_indeed}
-
-\def\pack_framed_start_framed_nop_indeed[#1]%
- {\pack_framed_initialize
- \bgroup
- \iffirstargument
- \setupcurrentframed[#1]% here !
- \fi
- \pack_framed_process_indeed
- \bgroup
- \ignorespaces}
-
-% till here
-
-\unexpanded\def\stopframed
- {\removeunwantedspaces
- \egroup}
-
-\unexpanded\def\normalframedwithsettings[#1]%
- {\bgroup
- \advance\c_pack_framed_nesting\plusone
- \expandafter\let\csname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed
- \bgroup
- \edef\currentframed{>\the\c_pack_framed_nesting}%
- \pack_framed_initialize
- \setupcurrentframed[#1]%
- \pack_framed_process_indeed}
-
-%D \startbuffer
-%D \setupframed [framecolor=yellow] \framed{A}
-%D \defineframed[myframed] [framecolor=blue] \myframed{B}
-%D \setupframed [myframed] [framecolor=red] \myframed{C}
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D \startbuffer
-%D \presetlocalframed[myframed]
-%D \localframed[myframed][framecolor=green]{oeps}
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-%D \macros
-%D {ifinframed}
-%D
-%D The normal case first presets all parameters and next starts looking for the user
-%D supplied ones. The first step is omitted in the local case, because these are
-%D preset at declaration time and keep their values unless explictly changed. By
-%D presetting the variables everytime the normal command is called, we can use this
-%D command nested, without the unwanted side effect of inheritance. The boolean is
-%D used to speed up the color stack.
-
-\newif\ifinframed
-
-%D The next one is faster on multiple backgrounds per page. No
-%D dimensions can be set, only frames and backgrounds.
-
-\unexpanded\def\fastlocalframed[#1]#2[#3]#4% 3-4
- {\bgroup
- \edef\currentframed{#1}%
- \pack_framed_initialize
- \setbox\b_framed_normal\hbox{#4}%
- \iftrialtypesetting \else
- \edef\m_overlay_region{\framedparameter\c!region}%
- \ifx\m_overlay_region\empty\else
- \pack_framed_set_region
- \fi
- \fi
- \setupcurrentframed[#3]%
- \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}% also used in backgrounds
- \d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds
- \edef\p_framed_frame{\framedparameter\c!frame}%
- \edef\p_framed_background{\framedparameter\c!background}%
- % not here, in calling macro: setups
- \pack_framed_remove_depth
- \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else
- \ifx\p_framed_rulethickness\empty\else
- \d_framed_linewidth\p_framed_rulethickness\relax
- \fi
- \pack_framed_add_outline % real or invisible frame
- \fi
- \ifx\p_framed_background\empty \else
- \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
- \d_framed_backgroundoffset
- \ifx\p_framed_backgroundoffset\v!frame
- \d_framed_frameoffset
- \else
- \p_framed_backgroundoffset
- \fi
- \edef\p_framed_component{\framedparameter\c!component}%
- \pack_framed_add_background
- \fi
- \pack_framed_restore_depth
- \iftrialtypesetting\orelse\ifx\m_overlay_region\empty\else
- \pack_framed_add_region
- \fi
- \box\b_framed_normal
- \egroup}
-
-%D The next macro uses a box and takes its natural width and height so these
-%D can better be correct.
-
-\unexpanded\def\pack_framed_process_box_indeed#1#2% component box (assumes parameters set and grouped usage)
- {\setbox\b_framed_normal\box#2% could actually be \let\b_framed_normal#2
- \edef\m_overlay_region{\framedparameter\c!region}%
- \ifx\m_overlay_region\empty\else
- \pack_framed_set_region
- \fi
- \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}% also used in backgrounds
- \d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds
- \edef\p_framed_frame{\framedparameter\c!frame}%
- \edef\p_framed_background{\framedparameter\c!background}%
- \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else
- \ifx\p_framed_rulethickness\empty \else
- \d_framed_linewidth\p_framed_rulethickness\relax
- \fi
- \pack_framed_add_outline % real or invisible frame
- \fi
- \ifx\p_framed_background\empty \else
- \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
- \d_framed_backgroundoffset
- \ifx\p_framed_backgroundoffset\v!frame
- \d_framed_frameoffset
- \else
- \p_framed_backgroundoffset
- \fi
- \edef\p_framed_component{#1}%
- \pack_framed_add_background
- \fi
- \ifx\m_overlay_region\empty\else
- \pack_framed_add_region
- \fi
- \box\b_framed_normal
- \egroup}
-
-\unexpanded\def\localbackgroundframed#1% namespace component box
- {\bgroup
- \edef\currentframed{#1}%
- \pack_framed_initialize
- \pack_framed_process_box_indeed} % group ends here
-
-\let\postprocessframebox\relax
-
-%D A nice example by Aditya:
-%D
-%D \starttyping
-%D \setupframed
-%D [loffset=\framedparameter{hoffset},
-%D roffset=\framedparameter{hoffset},
-%D hoffset=\zeropoint]
-%D
-%D \defineframed[test][hoffset=1cm]
-%D \stoptyping
-
-\newdimen\d_framed_width
-\newdimen\d_framed_height
-\newdimen\d_framed_frameoffset
-\newdimen\d_framed_backgroundoffset
-\newdimen\d_framed_local_offset
-
-% todo: protect local \framednames
-
-\unexpanded\def\localframed
- {\bgroup
- \dodoubleempty\pack_framed_local}
-
-\unexpanded\def\pack_framed_local[#1][#2]%
- {\bgroup
- \edef\currentframed{#1}%
- \pack_framed_initialize
- \ifsecondargument % faster
- \setupcurrentframed[#2]% here !
- \fi
- \pack_framed_process_indeed}
-
-\unexpanded\def\directlocalframed[#1]% no optional
- {\bgroup
- \bgroup
- \edef\currentframed{#1}%
- \pack_framed_initialize
- \pack_framed_process_indeed}
-
-\unexpanded\def\localframedwithsettings[#1][#2]% no checking (so no spaces between)
- {\bgroup
- \bgroup
- \edef\currentframed{#1}%
- \pack_framed_initialize
- \setupcurrentframed[#2]% here !
- \pack_framed_process_indeed}
-
-% done
-
-\def\c!fr!analyze{fr:analyze} % private option
-
-\let\delayedbegstrut\relax
-\let\delayedendstrut\relax
-\let\delayedstrut \relax
-
-\let\localoffset\empty
-\let\localwidth \empty
-\let\localheight\empty
-\let\localformat\empty
-\let\localstrut \empty
-
-\unexpanded\def\pack_framed_process_indeed
- {\d_framed_frameoffset\framedparameter\c!frameoffset
- \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}%
- \d_framed_backgroundoffset
- \ifx\p_framed_backgroundoffset\v!frame
- \d_framed_frameoffset
- \else
- \p_framed_backgroundoffset
- \fi
- % new, experimental dirty hook
- \framedparameter\c!extras
- % to get the right spacing
- \edef\p_framed_foregroundstyle{\framedparameter\c!foregroundstyle}%
- \ifx\p_framed_foregroundstyle\empty\else\dousestyleparameter\p_framed_foregroundstyle\fi
- % beware, both the frame and background offset can be overruled
- %
- \edef\p_framed_setups{\framedparameter\c!setups}%
- % the next macros are visible
- \edef\localoffset{\framedparameter\c!offset}%
- \edef\localwidth {\framedparameter\c!width}%
- \edef\localheight{\framedparameter\c!height}%
- \edef\localformat{\framedparameter\c!align}%
- \edef\localstrut {\framedparameter\c!strut}%
- % these are not
- \edef\p_framed_autostrut {\framedparameter\c!autostrut}%
- \edef\p_framed_frame {\framedparameter\c!frame}%
- \edef\p_framed_location {\framedparameter\c!location}%
- \edef\p_framed_orientation{\framedparameter\c!orientation}%
- \edef\p_framed_anchoring {\framedparameter\c!anchoring}%
- %
- \edef\p_framed_autowidth {\framedparameter\c!autowidth}%
- \edef\p_framed_franalyze {\framedparameter\c!fr!analyze}% experimental option
- %
- \ifx\p_framed_frame\v!overlay % no frame, no offset, no framewidth
- \setfalse\c_framed_has_frame
- \let\localoffset\v!overlay
- \orelse\ifx\p_framed_frame\v!none % no frame, no framewidth
- \setfalse\c_framed_has_frame
- \else
- \settrue\c_framed_has_frame
- \fi
- \ifconditional\c_framed_has_frame
- \edef\p_framed_rulethickness{\framedparameter\c!rulethickness}%
- \ifx\p_framed_rulethickness\empty\else
- \d_framed_linewidth\p_framed_rulethickness\relax
- \fi
- \else
- \d_framed_linewidth\zeropoint
- \fi
- % 2013/03/12: a change of order (sizes before align
- \ifx\localwidth\v!local
- \setlocalhsize
- \fi
- %
- \forgetall % should happen after \localwidth but before align
- %
- \ifx\localformat\empty
- \setfalse\c_framed_has_format
- \else
- \settrue\c_framed_has_format
- \dosetraggedcommand\localformat % not that fast
- \fi
- %
- \ifcsname\??framedoffsetalternative\localoffset\endcsname
- \lastnamedcs
- \else
- \framed_offset_alternative_unknown
- \fi
- \ifcsname\??framedwidthalternative\localwidth\endcsname
- \lastnamedcs
- \else
- \framed_width_alternative_unknown
- \fi
- \ifcsname\??framedheightalternative\localheight\endcsname
- \lastnamedcs
- \else
- \framed_height_alternative_unknown
- \fi
- % the next check could move to heightalternative
- \ifconditional\c_framed_has_height
- % obey user set height, also downward compatible
- \else
- \edef\p_framed_lines{\framedparameter\c!lines}%
- \ifx\p_framed_lines\empty
- \orelse\ifcase\p_framed_lines
- \else
- \d_framed_height\p_framed_lines\lineheight
- \edef\localheight{\the\d_framed_height}%
- \settrue\c_framed_has_height
- \fi
- \fi
- % this is now an option: width=local
- %
- % \ifdim\d_framed_width=\hsize
- % \parindent\zeropoint
- % \setlocalhsize
- % \d_framed_width\localhsize
- % \fi
- % i.e. disable (colsetbackgroundproblemintechniek)
- \advance\d_framed_width -2\d_framed_local_offset
- \advance\d_framed_height -2\d_framed_local_offset
- \ifcsname\??framedstrutalternative\localstrut\endcsname
- \lastnamedcs
- \else
- \framed_offset_alternative_unknown
- \fi
- % the next check could move to strutalternative
- \ifcase\c_framed_has_strut % none (not even noindent)
- \let\localbegstrut\relax
- \let\localendstrut\relax
- \let\localstrut \relax
- \or % no / overlay
- \let\localbegstrut\pseudobegstrut
- \let\localendstrut\pseudoendstrut
- \let\localstrut \pseudostrut
- \else
- \let\localbegstrut\begstrut
- \let\localendstrut\endstrut
- \let\localstrut \strut
- \fi
- \ifx\p_framed_autostrut\v!yes
- \let\delayedbegstrut\relax
- \let\delayedendstrut\relax
- \let\delayedstrut \relax
- \else
- \let\delayedbegstrut\localbegstrut
- \let\delayedendstrut\localendstrut
- \let\delayedstrut \localstrut
- \let\localbegstrut \relax
- \let\localendstrut \relax
- \let\localstrut \relax
- \fi
- \ifconditional\c_framed_has_height
- \let\\\pack_framed_vboxed_newline
- \ifconditional\c_framed_has_width
- \let\hairline\pack_framed_vboxed_hairline
- \ifconditional\c_framed_has_format
- \let\next\pack_framed_format_format_yes
- \else
- \let\next\pack_framed_format_format_nop
- \fi
- \else
- \let\hairline\pack_framed_hboxed_hairline
- \ifconditional\c_framed_has_format
- \let\next\pack_framed_format_format_height
- \else
- \let\next\pack_framed_format_format_vsize
- \fi
- \fi
- \orelse\ifconditional\c_framed_has_width
- \ifconditional\c_framed_has_format
- \let\hairline\pack_framed_vboxed_hairline
- \let\\\pack_framed_vboxed_newline
- \let\next\pack_framed_format_format_width
- \else
- \let\hairline\pack_framed_hboxed_hairline
- \let\\\pack_framed_hboxed_newline
- \let\next\pack_framed_format_format_hsize
- \fi
- \else
- \let\hairline\pack_framed_hboxed_hairline
- \let\\\pack_framed_hboxed_newline
- \let\next\pack_framed_format_format_no_size
- \fi
- \pack_framed_check_extra_offsets
- \edef\p_framed_background{\framedparameter\c!background}%
-% \ifx\p_framed_background\empty
-% \let\pack_framed_forgetall\forgetall
-% \else
-% \let\pack_framed_forgetall\relax
-% \forgetall
-% \fi
- \edef\framedwidth {\the\ifdim\d_framed_width >\zeropoint \d_framed_width \else\zeropoint\fi}% public
- \edef\framedheight{\the\ifdim\d_framed_height>\zeropoint \d_framed_height\else\zeropoint\fi}% public
- \edef\framedoffset{\the\dimexpr\ifconditional\c_framed_has_offset\localoffset \else\zeropoint\fi}% public
- \ifx\p_framed_orientation\empty
- \let\pack_framed_stop_orientation\relax
- \else
- \pack_framed_start_orientation
- \fi
- \afterassignment\pack_framed_restart
- \setbox\b_framed_normal\next}
-
-% alternatives for width, height, strut and offset
-
-\installcorenamespace{framedwidthalternative}
-\installcorenamespace{framedheightalternative}
-\installcorenamespace{framedstrutalternative}
-\installcorenamespace{framedoffsetalternative}
-
-% widths
-
-\setvalue{\??framedwidthalternative\empty}%
- {\ifconditional\c_framed_has_format
- \settrue\c_framed_has_width
- \d_framed_width\hsize
- \else
- \setfalse\c_framed_has_width
- \d_framed_width\zeropoint
- \fi}
-
-\setvalue{\??framedwidthalternative\v!fit}%
- {\ifconditional\c_framed_has_format
- \settrue\c_framed_has_width
- \d_framed_width\hsize
- \else
- \setfalse\c_framed_has_width
- \d_framed_width\zeropoint
- \fi}
-
-\setvalue{\??framedwidthalternative\v!fixed}% equals \v!fit but no shapebox
- {\ifconditional\c_framed_has_format
- \settrue\c_framed_has_width
- \d_framed_width\hsize
- \else
- \setfalse\c_framed_has_width
- \d_framed_width\zeropoint
- \fi}
-
-\setvalue{\??framedwidthalternative\v!broad}%
- {\settrue\c_framed_has_width
- \d_framed_width\hsize}
-
-\setvalue{\??framedwidthalternative\v!max}% idem broad
- {\settrue\c_framed_has_width
- \d_framed_width\hsize}
-
-\setvalue{\??framedwidthalternative\v!local}%
- {\settrue\c_framed_has_width
- %\setlocalhsize
- \d_framed_width\localhsize}
-
-\setvalue{\??framedwidthalternative\s!unknown}%
- {\settrue\c_framed_has_width
- \d_framed_width\localwidth}
-
-\def\framed_width_alternative_unknown
- {\settrue\c_framed_has_width
- \d_framed_width\localwidth}
-
-% heights
-
-\setvalue{\??framedheightalternative\empty}%
- {\setfalse\c_framed_has_height
- \d_framed_height\zeropoint}
-
-\setvalue{\??framedheightalternative\v!fit}%
- {\setfalse\c_framed_has_height
- \d_framed_height\zeropoint}
-
-\setvalue{\??framedheightalternative\v!broad}%
- {\setfalse\c_framed_has_height
- \d_framed_height\zeropoint}
-
-\setvalue{\??framedheightalternative\v!max}%
- {\settrue\c_framed_has_height
- \d_framed_height\vsize}
-
-\setvalue{\??framedheightalternative\s!unknown}%
- {\settrue\c_framed_has_height
- \d_framed_height\localheight}
-
-\def\framed_height_alternative_unknown
- {\settrue\c_framed_has_height
- \d_framed_height\localheight}
-
-% struts (use let instead?)
-
-\setvalue{\??framedstrutalternative\v!no}%
- {\c_framed_has_strut\plusone}
-
-\setvalue{\??framedstrutalternative\v!global}%
- {\setstrut}
-
-\setvalue{\??framedstrutalternative\v!local}%
- {\setfontstrut}
-
-\setvalue{\??framedstrutalternative\v!yes}%
- {\setstrut}
-
-\setvalue{\??framedstrutalternative\s!unknown}%
- {\setstrut}
-
-\def\framed_strut_alternative_unknown
- {\setstrut}
-
-\setvalue{\??framedstrutalternative\v!none}% not even pseudo struts
- {\c_framed_has_strut\zerocount}
-
-% offsets
-
-\setvalue{\??framedoffsetalternative\v!none}%
- {\setfalse\c_framed_has_offset
- \c_framed_has_strut\plusone
- \setfalse\c_framed_is_overlaid
- \d_framed_local_offset\d_framed_linewidth}
-
-\setvalue{\??framedoffsetalternative\v!overlay}%
- {% \ifx\p_framed_frame\v!no \setfalse\c_framed_has_frame \fi % test first
- \setfalse\c_framed_has_offset
- \c_framed_has_strut\plusone
- \settrue\c_framed_is_overlaid
- \d_framed_local_offset\zeropoint}
-
-% \setvalue{\??framedoffsetalternative\v!strut}%
-% {\setfalse\c_framed_has_offset
-% \c_framed_has_strut\plustwo
-% \settrue\c_framed_is_overlaid
-% \d_framed_local_offset\zeropoint}
-
-\setvalue{\??framedoffsetalternative\v!default}% new per 2-6-2000
- {\settrue \c_framed_has_offset
- \c_framed_has_strut\plustwo
- \setfalse\c_framed_is_overlaid
- \let\localoffset\defaultframeoffset
- \letframedparameter\c!offset\defaultframeoffset % brrr
- \d_framed_local_offset\dimexpr\localoffset+\d_framed_linewidth\relax}
-
-\def\framed_offset_alternative_unknown
- {\settrue \c_framed_has_offset
- \c_framed_has_strut\plustwo
- \setfalse\c_framed_is_overlaid
- \let\defaultframeoffset\localoffset
- \d_framed_local_offset\dimexpr\localoffset+\d_framed_linewidth\relax}
-
-\letvalue{\??framedoffsetalternative\s!unknown}\framed_offset_alternative_unknown
-
-% so far for alternatives
-
-\let\pack_framed_stop_orientation\relax
-
-\def\pack_framed_restart
- {\aftergroup\pack_framed_finish}
-
-\def\pack_framed_do_top
- {\raggedtopcommand
- \framedparameter\c!top
- \edef\p_blank{\framedparameter\c!blank}%
- \ifx\p_blank\v!yes\else % auto or no
- \doinhibitblank
- \fi}
-
-\def\pack_framed_do_bottom
- {\framedparameter\c!bottom
- \raggedbottomcommand}
-
-%D Careful analysis of this macro will learn us that not all branches in the last
-%D conditionals can be encountered, that is, some assignments to \type{\next} will
-%D never occur. Nevertheless we implement the whole scheme, if not for future
-%D extensions.
-
-%D \macros
-%D {doassigncheckedframeoffset}
-%D
-%D Offset helper (see menus):
-
-\def\doassigncheckedframeoffset#1#2% could be a fast \csname .. \endcsname
- {\edef\checkedframeoffset{#2}%
- #1%
- \ifx\checkedframeoffset\empty \zeropoint\orelse
- \ifx\checkedframeoffset\v!overlay\zeropoint\orelse
- \ifx\checkedframeoffset\v!none \zeropoint\orelse
- \ifx\checkedframeoffset\v!frame \zeropoint\orelse
- \ifx\checkedframeoffset\v!default\zeropoint\else
- #2%
- \fi
- \relax}
-
-%D \macros
-%D {ifreshapeframebox}
-%D
-%D The last few lines tell what to do after the content of the box is collected and
-%D passed to the next macro. In the case of a fixed width and centered alignment,
-%D the content is evaluated and used to determine the most natural width. The rest
-%D of the code deals with backgrounds and frames.
-
-\newif\ifreshapeframebox \reshapeframeboxtrue
-
-%D Beware: setting \type {top} and \type {bottom} to nothing, may
-%D result in a frame that is larger that the given height! try:
-%D
-%D \starttyping
-%D \framed
-%D [height=3cm,top=,bottom=,offset=overlay]
-%D {\strut test \shapefill \strut test}
-%D \stoptyping
-%D
-%D This is intended behaviour and not a bug! One can always set
-%D
-%D \starttyping
-%D ...,bottom=\kern0pt,...
-%D \stoptyping
-
-% experiment ... \p_framed_franalyze -> we could support 'first' as location key
-% option but then we will always do an analysis and reimplement the location
-% options (btw, beware of location settings of derived functionality that bleed
-% into this
-
-\def\pack_framed_finish_a
- {\ifreshapeframebox
- \pack_framed_reshape_process
- \orelse\ifx\p_framed_franalyze\v!yes
- \pack_framed_reshape_analyze
- \else
- \pack_framed_reshape_reset
- \fi
- \setfalse\c_framed_has_width}
-
-\def\pack_framed_finish_b
- {\ifx\p_framed_franalyze\v!yes
- \pack_framed_reshape_analyze
- \else
- \pack_framed_reshape_reset
- \fi
- \setfalse\c_framed_has_width}
-
-\def\pack_framed_finish_c
- {\ifx\p_framed_franalyze\v!yes
- \pack_framed_reshape_analyze
- \else
- \pack_framed_reshape_reset
- \fi}
-
-\def\pack_framed_profile_box
- {\profilegivenbox\p_profile\b_framed_normal
- \setbox\b_framed_normal\vpack{\unvbox\b_framed_normal}}
-
-\unexpanded\def\pack_framed_finish
- {%\pack_framed_stop_orientation % hm, wrong place ! should rotate the result (after reshape) .. moved down
- \pack_framed_locator_before\p_framed_location
- \ifconditional\c_framed_has_format
- %\ifconditional\c_framed_has_height \else
- % \edef\p_profile{\framedparameter\c!profile}%
- % \ifx\p_profile\empty\else
- % \pack_framed_profile_box
- % \fi
- %\fi
- \ifx\p_framed_autowidth\v!force
- \pack_framed_finish_a
- \orelse\ifx\localwidth\v!fit
- \ifx\p_framed_autowidth\v!yes
- \pack_framed_finish_a
- \else
- \pack_framed_finish_b
- \fi
- \orelse\ifx\localwidth\v!fixed
- \pack_framed_finish_b
- \else
- \pack_framed_finish_c
- \fi
- \ifconditional\c_framed_has_height \else
- \edef\p_profile{\framedparameter\c!profile}%
- \ifx\p_profile\empty\else
- \pack_framed_profile_box
- \fi
- \fi
- \ifconditional\page_postprocessors_needed_box
- % quite late
- \page_postprocessors_linenumbers_box\b_framed_normal
- \fi
- \else
- \pack_framed_finish_c
- \fi
- \ifconditional\c_framed_has_width
- \wd\b_framed_normal\d_framed_width
- \fi
- \ifconditional\c_framed_has_height
- \ht\b_framed_normal\d_framed_height
- \else
- \edef\p_framed_minheight{\framedparameter\c!minheight}%
- \ifx\p_framed_minheight\empty \else
- \ifdim\ht\b_framed_normal<\p_framed_minheight
- \ht\b_framed_normal\p_framed_minheight
- \fi
- \fi
- \fi
- \edef\p_framed_empty{\framedparameter\c!empty}%
- \ifx\p_framed_empty\v!yes
- \pack_framed_fake_box
- \fi
- \ifx\p_framed_anchoring\empty\else
- \pack_framed_handle_anchoring
- \fi
- \pack_framed_stop_orientation % moved here at 2014-05-25
- \iftrialtypesetting \else
- \edef\m_overlay_region{\framedparameter\c!region}%
- \ifx\m_overlay_region\empty\else
- \pack_framed_set_region
- \fi
- \fi
- \d_framed_applied_offset
- \ifconditional\c_framed_is_overlaid
- \zeropoint
- \else
- \d_framed_linewidth
- \fi
- \ifconditional\c_framed_has_offset
- \advance\d_framed_applied_offset\localoffset
- \fi
- \ifconditional\c_framed_has_extra_offset
- \pack_framed_apply_extra_offsets % includes \d_framed_applied_offset
- \else
- \ifzeropt\d_framed_applied_offset
- \else
- \pack_framed_widen_box
- \fi
- \fi
- %
- \ifx\postprocessframebox\relax \else
- \let\next\postprocessframebox
- \let\postprocessframebox\relax % prevent nesting
- \next\b_framed_normal
- \fi
- \iftrialtypesetting
- % new
- \else
- \ifconditional\c_framed_has_frame % real or invisible frame
- \pack_framed_add_outline
- \fi
- \ifx\p_framed_background\empty \else
- \edef\p_framed_component{\framedparameter\c!component}%
- \pack_framed_add_background
- \fi
- \fi
- \pack_framed_locator_after\p_framed_location
- \iftrialtypesetting \else
- \ifx\m_overlay_region\empty\else
- \pack_framed_add_region
- \fi
- \fi
- \box\b_framed_normal
- \global\frameddimensionstate % global so to be used directly afterwards !
- \ifconditional\c_framed_has_width
- \ifconditional\c_framed_has_height \plusthree \else \plusone \fi
- \else
- \ifconditional\c_framed_has_height \plustwo \else \zerocount \fi
- \fi
- \egroup
- \egroup}
-
-%D Anchoring is experimental and was prototyped around the ctx meeting in 2018 but
-%D never mede it into the core yet. It operates independent of the orientation
-%D mechanism already present. It's a rather efficient feature. Best is to use
-%D predefined orientations, like:
-%D
-%D \starttyping
-%D \defineorientation[leftflushleft] [orientation=left,horizontal=flushleft]
-%D
-%D \framed [anchoring={leftflushleft}] {anchoring}
-%D \stoptyping
-%D
-%D But this also works:
-%D
-%D \starttyping
-%D \framed [anchoring={flushleft,top,up}] {anchoring}
-%D \stoptyping
-%D
-%D When an anchoring is given (use \type {normal} for the default) you can also
-%D use the \type {xanchor} and \type {yanchor} offsets.
-
-% because we mess with the width later on, we need double wrapping:
-
-\def\pack_framed_handle_anchoring
- {\scratchcounter\autoorientation\p_framed_anchoring\relax
- \edef\p_xanchor{\framedparameter\c!xanchor}%
- \edef\p_yanchor{\framedparameter\c!yanchor}%
- \setbox\b_framed_normal\hpack{\hpack % here
- % using the keyword approachs works ok, don't mess with orientation
- % directly here using \boxorientation ... it doesn't work that well
- \s!orientation\scratchcounter
- \ifx\p_xanchor\empty\else \s!xoffset \p_xanchor\fi
- \ifx\p_yanchor\empty\else \s!yoffset \p_yanchor\fi
- {\box\b_framed_normal}}}
-
-\installcorenamespace{framedlocatorbefore}
-\installcorenamespace{framedlocatorafter}
-
-\newconstant\frameddimensionstate % global state: 0=unknown 1=width 2=height 3=both
-
-\def\pack_framed_fake_box
- {\setbox\scratchbox\emptyhbox
- \wd\scratchbox\wd\b_framed_normal
- \ht\scratchbox\ht\b_framed_normal
- \dp\scratchbox\dp\b_framed_normal
- \setbox\b_framed_normal\box\scratchbox}
-
-\def\installframedlocator#1#2#3%
- {\setvalue{\??framedlocatorbefore#1}{#2}%
- \setvalue{\??framedlocatorafter #1}{#3}}
-
-\def\pack_framed_locator_before#1{\begincsname\??framedlocatorbefore#1\endcsname}
-\def\pack_framed_locator_after #1{\begincsname\??framedlocatorafter #1\endcsname}
-
-\newdimen\d_framed_locator_ht
-\newdimen\d_framed_locator_dp
-\newdimen\d_framed_locator_lo
-\newdimen\d_framed_locator_ro
-
-\def\pack_framed_locator_set#1%
- {\d_framed_locator_ht\dimexpr
- #1+\d_framed_linewidth
- \ifconditional\c_framed_has_offset
- +\framedparameter\c!offset
- \fi
- +\framedparameter\c!toffset
- \relax
- \d_framed_locator_dp\dimexpr\ht\b_framed_normal-\d_framed_locator_ht\relax}
-
-\def\pack_framed_locator_set_lo
- {\global\d_framed_locator_lo\dimexpr
- \d_framed_linewidth
- \ifconditional\c_framed_has_offset
- +\framedparameter\c!offset
- \fi
- +\framedparameter\c!loffset
- \relax}
-
-\def\pack_framed_locator_set_ro
- {\global\d_framed_locator_ro\dimexpr
- \d_framed_linewidth
- \ifconditional\c_framed_has_offset
- +\framedparameter\c!offset
- \fi
- +\framedparameter\c!roffset
- \relax}
-
-% \ruledhbox
-% {A
-% \framed[width=2cm,align=middle,location=hanging]{location\\equals\\hanging}
-% \framed[width=2cm,align=middle,location=depth] {location\\equals\\depth}
-% \framed[width=2cm,align=middle,location=height] {location\\equals\\height}
-% B}
-% \vskip2cm
-% \ruledhbox
-% {A
-% \framed[width=2cm,align=middle,location=low] {location\\equals\\low}
-% \framed[width=2cm,align=middle,location=line] {location\\equals\\line}
-% \framed[width=2cm,align=middle,location=high] {location\\equals\\high}
-% B}
-% \vskip2cm
-% \ruledhbox
-% {A
-% \framed[width=2cm,align=middle,location=top] {location\\equals\\top}
-% \framed[width=2cm,align=middle,location=bottom] {location\\equals\\bottom}
-% \framed[width=2cm,align=middle,location=lohi] {location\\equals\\lohi}
-% \framed[width=2cm,align=middle,location=middle] {location\\equals\\middle}
-% B}
-
-% \installframedlocator \v!hanging % best with strut=no
-% {}
-% {\dp\b_framed_normal\ht\b_framed_normal
-% \ht\b_framed_normal\zeropoint}
-%
-% \installframedlocator \v!depth
-% {}
-% {\ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
-% \dp\b_framed_normal\strutdp
-% \box\b_framed_normal}
-%
-% \installframedlocator \v!height
-% {}
-% {\dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
-% \ht\b_framed_normal\strutht
-% \box\b_framed_normal}
-
-\installframedlocator \v!hanging % best with strut=no *1* / see mail to list by SB
- {}
- {\scratchdimen\ht\b_framed_normal
- \setbox\b_framed_normal\hpack{\lower\scratchdimen\box\b_framed_normal}%
- \dp\b_framed_normal\scratchdimen
- \ht\b_framed_normal\zeropoint
- \box\b_framed_normal}
-
-\installframedlocator \v!depth % *1*
- {}
- {\setbox\b_framed_normal\hpack{\lower\strutdp\box\b_framed_normal}%
- \ht\b_framed_normal\dimexpr\ht\b_framed_normal-\strutdp\relax
- \dp\b_framed_normal\strutdp
- \box\b_framed_normal}
-
-\installframedlocator \v!height % *1*
- {}
- {\scratchdimen\dimexpr \ht\b_framed_normal - \strutht \relax
- \setbox\b_framed_normal\hpack{\lower\scratchdimen\box\b_framed_normal}%
- \dp\b_framed_normal\dimexpr\ht\b_framed_normal-\strutht\relax
- \ht\b_framed_normal\strutht
- \box\b_framed_normal}
-
-\installframedlocator \v!high
- {}
- {\pack_framed_locator_set\strutht
- \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}%
- \ht\b_framed_normal\strutht
- \dp\b_framed_normal\strutdp
- \hpack{\box\b_framed_normal}} % why do we pack .. dange of loosing?
-
-\installframedlocator \v!line
- {}
- {\setbox\b_framed_normal\hpack{\lower.5\ht\b_framed_normal\box\b_framed_normal}%
- \ht\b_framed_normal.5\lineheight
- \dp\b_framed_normal.5\lineheight
- \hpack{\box\b_framed_normal}} % why do we pack .. dange of loosing?
-
-\installframedlocator \v!low
- {}
- {\pack_framed_locator_set\strutdp
- \setbox\b_framed_normal\hpack{\lower\d_framed_locator_ht\box\b_framed_normal}%
- \ht\b_framed_normal\strutht
- \dp\b_framed_normal\strutdp
- \box\b_framed_normal}
-
-\installframedlocator \v!top
- {}
- {\pack_framed_locator_set\strutht
- \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}%
- \ht\b_framed_normal\d_framed_locator_ht
- \dp\b_framed_normal\d_framed_locator_dp
- \hpack{\box\b_framed_normal}} % why do we pack .. dange of loosing?
-
-\installframedlocator \v!middle
- {}
- {\scratchdimen.5\ht\b_framed_normal
- \setbox\b_framed_normal\hpack{\lower\scratchdimen\box\b_framed_normal}%
- \ht\b_framed_normal\scratchdimen
- \dp\b_framed_normal\scratchdimen
- \hpack{\box\b_framed_normal}} % why do we pack .. dange of loosing?
-
-\installframedlocator \v!lohi % maybe also \v!center
- {\pack_framed_locator_before\v!middle}
- {\pack_framed_locator_after \v!middle}
-
-\installframedlocator \v!bottom
- {}
- {\pack_framed_locator_set\strutdp
- \setbox\b_framed_normal\hpack{\lower\d_framed_locator_ht\box\b_framed_normal}%
- \ht\b_framed_normal\d_framed_locator_dp
- \dp\b_framed_normal\d_framed_locator_ht
- \hpack{\box\b_framed_normal}} % why do we pack .. dange of loosing?
-
-\installframedlocator \v!keep % retains height/depth
- {\pack_framed_remove_depth}
- {\pack_framed_restore_depth}
-
-\newdimen\d_framed_formula
-
-\installframedlocator \v!formula % private, will become a more generic name
- {}
- {\pack_framed_locator_set\d_framed_formula
- \setbox\b_framed_normal\hpack{\lower\d_framed_locator_dp\box\b_framed_normal}%
- \ht\b_framed_normal\d_framed_locator_ht
- \dp\b_framed_normal\d_framed_locator_dp
- \hpack{\box\b_framed_normal}} % why do we pack .. danger of loosing?
-
-% also used in fastlocalframed
-
-\newdimen\d_framed_original_wd
-\newdimen\d_framed_original_ht
-\newdimen\d_framed_original_dp
-
-\def\pack_framed_remove_depth
- {\d_framed_original_wd\wd\b_framed_normal
- \d_framed_original_ht\ht\b_framed_normal
- \d_framed_original_dp\dp\b_framed_normal
- \ifzeropt\d_framed_original_dp\else
- \setbox\b_framed_normal\hpack{\raise\d_framed_original_dp\box\b_framed_normal}%
- \fi
- \wd\b_framed_normal\d_framed_original_wd
- \ht\b_framed_normal\dimexpr\d_framed_original_ht+\d_framed_original_dp\relax
- \dp\b_framed_normal\zeropoint}
-
-\def\pack_framed_restore_depth
- {\ifzeropt\d_framed_original_dp \else
- \setbox\b_framed_normal\hpack{\lower\d_framed_original_dp\box\b_framed_normal}%
- \fi
- \wd\b_framed_normal\d_framed_original_wd
- \ht\b_framed_normal\d_framed_original_ht
- \dp\b_framed_normal\d_framed_original_dp}
-
-% \framed[width=12cm,height=3cm,orientation=0]{\input ward\relax}
-% \framed[width=12cm,height=3cm,orientation=90]{\input ward\relax}
-% \framed[width=12cm,height=3cm,orientation=180]{\input ward\relax}
-% \framed[width=12cm,height=3cm,orientation=270]{\input ward\relax}
-% \framed[width=12cm,height=3cm,orientation=-90]{\input ward\relax}
-% \framed[width=12cm,height=3cm,orientation=-180]{\input ward\relax}
-% \framed[width=12cm,height=3cm,orientation=-270]{\input ward\relax}
-
-\def\pack_framed_start_orientation
- {\ifcase\p_framed_orientation
- \let\pack_framed_stop_orientation\relax
- \else
- \let\pack_framed_stop_orientation\pack_framed_stop_orientation_indeed
- \fi}
-
-\def\pack_framed_stop_orientation_indeed
- {\setbox\b_framed_normal\hpack{\dorotatebox\p_framed_orientation\hpack{\box\b_framed_normal}}%
- \d_framed_height\ht\b_framed_normal
- \d_framed_width \wd\b_framed_normal}
-
-%D The last conditional takes care of the special situation of in||line \inframed
-%D [height=3cm] {framed} boxes. Such boxes have to be \inframed {aligned} with the
-%D running text.
-
-\unexpanded\def\inframed
- {\dosingleempty\pack_framed_inline}
-
-% \def\pack_framed_inline[#1]%
-% {\framed[\c!location=\v!low,#1]}
-%
-% or:
-
-\def\pack_framed_inline[%
- {\framed[\c!location=\v!low,}
-
-%D When we set \type{empty} to \type{yes}, we get ourselves a frame and/or background,
-%D but no content, so actually we have a sort of phantom framed box.
-
-%D \macros
-%D {mframed, minframed}
-%D
-%D When Tobias asked how to frame mathematical elements in formulas, Taco's posted the
-%D next macro:
-%D
-%D \starttyping
-%D \def\mframed#1%
-%D {\relax
-%D \ifmmode
-%D \vcenter{\hbox{\framed{$\ifinner\else\displaystyle\fi#1$}}}%
-%D \else
-%D \framed{$#1$}%
-%D \fi}
-%D \stoptyping
-%D
-%D Because \type {\ifinner} does not (always) reports what one would expect, we move the
-%D test to the outer level. We also want to pass arguments,
-%D
-%D \starttyping
-%D \def\mframed%
-%D {\dosingleempty\domframed}
-%D
-%D \def\domframed[#1]#2% % tzt \dowithnextmathbox ?
-%D {\relax
-%D \ifmmode
-%D \ifinner
-%D \inframed[#1]{$#2$}%
-%D \else
-%D \vcenter{\hbox{\framed[#1]{$\displaystyle#2$}}}%
-%D \fi
-%D \else
-%D \inframed[#1]{$#2$}%
-%D \fi}
-%D \stoptyping
-%D
-%D Still better is the next alternative, if only because it takes care of setting the super-
-%D and subscripts styles
-
-\newcount\c_framed_mstyle
-
-\unexpanded\def\pack_framed_math_strut
- {\Ustartmath
- \triggermathstyle\c_framed_mstyle
- \vphantom{(}%
- \Ustopmath}
-
-\installcorenamespace{mathframed}
-
-\installframedcommandhandler \??mathframed {mathframed} \??mathframed
-
-\appendtoks
- \setuevalue{\currentmathframed}{\pack_framed_mathframed{\currentmathframed}}%
-\to \everydefinemathframed
-
-\unexpanded\def\pack_framed_mathframed#1%
- {\begingroup
- \edef\currentmathframed{#1}%
- \dosingleempty\pack_framed_mathframed_indeed}
-
-\newcount\c_pack_framed_mathframed
-\newtoks \t_pack_framed_mathframed
-
-\def\pack_framed_math_pos
- {\global\advance\c_pack_framed_mathframed\plusone
- \xdef\pack_framed_mc_one{mcf:1:\number\c_pack_framed_mathframed}%
- \xdef\pack_framed_mc_two{mcf:2:\number\c_pack_framed_mathframed}%
- \xypos\pack_framed_mc_two}
-
-\def\pack_framed_mathframed_indeed[#1]#2% no fancy nesting supported here
- {\iffirstargument
- \setupcurrentmathframed[#1]%
- \fi
- \c_framed_mstyle\mathstyle
- \edef\m_framed_location{\mathframedparameter\c!location}%
- \ifx\m_framed_location\v!mathematics
- \let\normalstrut\pack_framed_math_pos
- \orelse\ifx\m_framed_location\v!low\else
- \let\normalstrut\pack_framed_math_strut
- \fi
- \inheritedmathframedframed\bgroup
- \Ustartmath
- \triggermathstyle\c_framed_mstyle
- \the\t_pack_framed_mathframed
- #2%
- \Ustopmath
- \egroup
- \endgroup}
-
-\appendtoks
- \mathraggedstatus\plustwo % makes \startalign work
- \eqalignmode \zerocount % makes \startalign fit
-\to \t_pack_framed_mathframed
-
-\installframedlocator \v!mathematics
- {}
- {\lower\dimexpr\MPy\pack_framed_mc_two-\MPy\pack_framed_mc_one\relax
- \hpack{\xypos\pack_framed_mc_one\box\b_framed_normal}}
-
-\definemathframed[mframed]
-\definemathframed[inmframed][\c!location=\v!low]
-\definemathframed[mcframed] [\c!location=\v!mathematics]
-
-%D So instead of the rather versatile \type {\framed}, we use \type {\mframed}:
-%D
-%D \startbuffer
-%D \startformula
-%D x \times \mframed{y} \times y^{z_z}
-%D x \times \inmframed{y} \times y^{z_z}
-%D \stopformula
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D And:
-%D
-%D \startbuffer
-%D \startformula
-%D x \times \mframed{y} \times y^{\mframed{z}_{\mframed{z}}}
-%D \stopformula
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D As usual, one can specify in what way the text should be framed. One should be
-%D aware of the fact that, inorder to preserve the proper spacing, the \type
-%D {offset} is set to \type {overlay} and \type {frameoffset} is used used instead.
-%D
-%D \startbuffer
-%D \startformula
-%D x \times y^{\mframed[framecolor=red]{z}_{z}}
-%D \stopformula
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D For inline use, we also provide the \type {\inmframed} alternative: we want $x
-%D \times \inmframed{y}$ in inline math, right?
-
-%D This previous framing macros needs a lot of alternatives for putting rules around
-%D boxes, inserting offsets and aligning text. Each step is handled by separate macros.
-
-\newdimen\d_framed_applied_offset
-\newdimen\d_framed_loffset
-\newdimen\d_framed_roffset
-\newdimen\d_framed_toffset
-\newdimen\d_framed_boffset
-
-\def\pack_framed_check_extra_offsets % we could check h and v indepently
- {\setfalse\c_framed_has_extra_offset
- \d_framed_loffset\framedparameter\c!loffset\relax
- \d_framed_roffset\framedparameter\c!roffset\relax
- \d_framed_toffset\framedparameter\c!toffset\relax
- \d_framed_boffset\framedparameter\c!boffset\relax
- \ifzeropt\d_framed_loffset\else \advance\d_framed_width -\d_framed_loffset \settrue\c_framed_has_extra_offset \fi
- \ifzeropt\d_framed_roffset\else \advance\d_framed_width -\d_framed_roffset \settrue\c_framed_has_extra_offset \fi
- \ifzeropt\d_framed_toffset\else \advance\d_framed_height-\d_framed_toffset \settrue\c_framed_has_extra_offset \fi
- \ifzeropt\d_framed_boffset\else \advance\d_framed_height-\d_framed_boffset \settrue\c_framed_has_extra_offset \fi}
-
-\def\pack_framed_apply_extra_offsets
- {\setbox\b_framed_normal\vpack\bgroup
- \advance\d_framed_toffset\d_framed_applied_offset
- \advance\d_framed_boffset\d_framed_applied_offset
- \advance\d_framed_loffset\d_framed_applied_offset
- \advance\d_framed_roffset\d_framed_applied_offset
- \kern\d_framed_toffset
- \hpack\bgroup
- \kern\d_framed_loffset
- \box\b_framed_normal
- \kern\d_framed_roffset
- \egroup
- \kern\d_framed_boffset
- \egroup}
-
-\def\pack_framed_widen_box
- {\setbox\b_framed_normal\vpack
- {\kern\d_framed_applied_offset
- \hpack{\kern\d_framed_applied_offset\box\b_framed_normal\kern\d_framed_applied_offset}%
- \kern\d_framed_applied_offset}}
-
-%D Let's hope that the next few examples show us enough of what needs to be
-%D done by the auxiliary macros.
-%D
-%D \startbuffer
-%D \framed[height=1cm,offset=.5cm] {rule based learning}
-%D \framed[height=1cm,offset=0cm] {rule based learning}
-%D \framed[height=1cm,offset=none] {rule based learning}
-%D \framed[height=1cm,offset=overlay]{rule based learning}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlinecorrection
-%D \hbox{\getbuffer}
-%D \stoplinecorrection
-%D
-%D \startbuffer
-%D \framed[offset=.5cm] {rule based learning}
-%D \framed[offset=0cm] {rule based learning}
-%D \framed[offset=none] {rule based learning}
-%D \framed[offset=overlay]{rule based learning}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlinecorrection
-%D \hbox{\getbuffer}
-%D \stoplinecorrection
-%D
-%D \startbuffer
-%D \framed[strut=no,offset=.5cm] {rule based learning}
-%D \framed[strut=no,offset=0cm] {rule based learning}
-%D \framed[strut=no,offset=none] {rule based learning}
-%D \framed[strut=no,offset=overlay]{rule based learning}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlinecorrection
-%D \hbox{\getbuffer}
-%D \stoplinecorrection
-%D
-%D \startbuffer
-%D \framed[width=3cm,align=left] {rule\\based\\learning}
-%D \framed[width=3cm,align=middle] {rule\\based\\learning}
-%D \framed[width=3cm,align=right] {rule\\based\\learning}
-%D \framed[width=fit,align=middle] {rule\\based\\learning}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlinecorrection
-%D \hbox{\dontcomplain\getbuffer}
-%D \stoplinecorrection
-%D
-%D So now we're ready for the complicated stuff. We distinguish between borders with
-%D straight lines and those with round corners. When using the first alternative it
-%D is possible to turn off one or more lines. More fancy shapes are also possible by
-%D specifying dedicated backgrounds. Turning lines on and off is implemented as
-%D efficient as possible and as a result is interface language dependant. This next
-%D implementation evolved from simpler ones. It puts for instance the rules on top
-%D of the content and provides additional offset capabilities. The lot of calls to
-%D other macros makes this mechanism not that easy to comprehend.
-%D
-%D We handle left, right or middle alignment as well as fixed or free widths and
-%D heights. Each combination gets its own macro.
-%D
-%D The following code handles one-liners: \type {align={line,flushright}}. Beware,
-%D since we entered a group and either or not grab the next bgroup token, we need to
-%D finish the group in the oneliner mode.
-
-\ifdefined\raggedonelinerstate \else \newconditional\raggedonelinerstate \fi
-
-\def\doformatonelinerbox % beware: assumes explicit preceding bgroup
- {\ifconditional\raggedonelinerstate
- \expandafter\dodoformatonelinerbox
- \else
- \expandafter\nodoformatonelinerbox
- \fi}
-
-\def\dodoformatonelinerbox
- {\afterassignment\redoformatonelinerbox
- \setbox\nextbox\hbox} % maybe \hpack
-
-\def\redoformatonelinerbox
- {\aftergroup\dododoformatonelinerbox
- \ignorespaces}
-
-\def\dododoformatonelinerbox
- {\hpack to \hsize % was \hbox
- {\ifcase\raggedstatus\or\hss\or\hss \fi
- \unhbox\nextbox \removeunwantedspaces
- \ifcase\raggedstatus\or \or\hss\or\hss\fi}%
- \egroup}
-
-\def\nodoformatonelinerbox % grabs {
- {\let\next=}
-
-%D The handlers:
-
-% Beware, we have a \noindent so an empty line is indeed an empty line and
-% the \synchronizeinlinedirection triggers a vbox instead of a line.
-%
-% \startTEXpage[offset=0.5ex,align={lohi,middle}]
-%
-% \vbox{\hbox{x}}
-% \stopTEXpage
-%
-% \startTEXpage[offset=0.5ex,align={lohi,middle}]
-% \vbox{\hbox{x}}
-% \stopTEXpage
-
-% \def\pack_framed_forgetall{\forgetall}
-
-\def\pack_framed_set_foregroundcolor
- {\edef\p_framed_foregroundcolor{\framedparameter\c!foregroundcolor}%
- \ifx\p_framed_foregroundcolor\empty\else\dousecolorparameter\p_framed_foregroundcolor\fi}
-
-\def\pack_framed_do_setups
- {\ifx\p_framed_setups\empty \else
- \setups[\p_framed_setups]% \texsetup (or only one!)
- % \fastsetup\p_framed_setup % singular would have been better
- \fi}
-
-\def\pack_framed_format_format_yes
- {\vbox to \d_framed_height
- \bgroup
- \let\postprocessframebox\relax
- % \pack_framed_forgetall
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \oninterlineskip
- \hsize\d_framed_width
- \vsize\d_framed_height
- \pack_framed_do_setups
- \raggedcommand
- \pack_framed_do_top
- \bgroup
- \synchronizeinlinedirection
- \localbegstrut
- \aftergroup\localendstrut
- \aftergroup\pack_framed_do_bottom
- \aftergroup\egroup
- \doformatonelinerbox}
-
-\def\pack_framed_format_format_nop
- {\vbox to \d_framed_height
- \bgroup
- \let\postprocessframebox\relax
- % \pack_framed_forgetall
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \oninterlineskip
- \hsize\d_framed_width
- \vsize\d_framed_height
- \pack_framed_do_setups
- \raggedcenter
- \vss
- \bgroup
- \synchronizeinlinedirection
- \localbegstrut
- \aftergroup\localendstrut
- \aftergroup\vss
- \aftergroup\egroup
- \doformatonelinerbox}
-
-\def\pack_framed_format_format_height
- {\vbox to \d_framed_height
- \bgroup
- \let\postprocessframebox\relax
- % \pack_framed_forgetall
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \oninterlineskip
- \pack_framed_do_setups
- \raggedcommand
- \vss
- \bgroup
- \aftergroup\localendstrut
- \aftergroup\vss
- \aftergroup\egroup
- \synchronizeinlinedirection
- \localbegstrut
- \doformatonelinerbox}
-
-\def\pack_framed_format_format_width
- {\vbox
- \bgroup
- \let\postprocessframebox\relax
- % \pack_framed_forgetall
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \oninterlineskip
- \hsize\d_framed_width
- \pack_framed_do_setups
- \raggedcommand
- \pack_framed_do_top
- \bgroup
- \synchronizeinlinedirection
- \localbegstrut
- \aftergroup\localendstrut
- \aftergroup\pack_framed_do_bottom
- \aftergroup\egroup
- \doformatonelinerbox}
-
-\def\pack_framed_format_format_vsize
- {\vbox to \d_framed_height % no vpack .. maybe grid
- \bgroup
- \let\postprocessframebox\relax
- % \pack_framed_forgetall
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \vsize\d_framed_height
- \pack_framed_do_setups
- \vss
- \bgroup
- \aftergroup\vss
- \aftergroup\egroup
- \hbox
- \bgroup
- \aftergroup\egroup
- \synchronizeinlinedirection
- \localstrut
- \doformatonelinerbox}
-
-\def\pack_framed_format_format_hsize
- {\hbox to \d_framed_width
- \bgroup
- \let\postprocessframebox\relax
- % \pack_framed_forgetall
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \pack_framed_do_setups
- \hss
- \synchronizeinlinedirection
- \localstrut
- \bgroup
- \aftergroup\hss
- \aftergroup\egroup
- \doformatonelinerbox}
-
-\def\pack_framed_format_format_no_size
- {\hbox
- \bgroup
- \iftrialtypesetting \else
- \pack_framed_set_foregroundcolor
- \fi
- \let\postprocessframebox\relax
- \pack_framed_do_setups
- \synchronizeinlinedirection
- \localstrut
- \doformatonelinerbox}
-
-%D On the next page we show some examples of how these macros come into action. The
-%D examples show us how \type {fit}, \type {broad} dimensions influence the
-%D formatting. Watch the visualized struts. \footnote {Here we used \type
-%D {\showstruts}.}
-%D
-%D \startpostponing
-%D \bgroup
-%D \showstruts
-%D \dontcomplain
-%D \starttabulate[|c|c|c|c|c|c|]
-%D % \HL
-%D \NC \framed[width=.2\hsize, height=.2\hsize, align=] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=broad, align=] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=fit, align=] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=.2\hsize, align=] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=broad, align=] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=fit, align=] {a\endgraf b\endgraf c}
-%D \NC \NR
-%D % \HL
-%D \NC \framed[width=.2\hsize, height=.2\hsize, align=yes] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=broad, align=yes] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=fit, align=yes] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=.2\hsize, align=yes] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=broad, align=yes] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=fit, align=yes] {a\endgraf b\endgraf c}
-%D \NC \NR
-%D % \HL
-%D \NC \framed[width=.2\hsize, height=.2\hsize, align=right] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=broad, align=right] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=fit, align=right] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=.2\hsize, align=right] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=broad, align=right] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=fit, align=right] {a\endgraf b\endgraf c}
-%D \NC \NR
-%D % \HL
-%D \NC \framed[width=.2\hsize, height=.2\hsize, align=left] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=broad, align=left] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=fit, align=left] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=.2\hsize, align=left] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=broad, align=left] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=fit, align=left] {a\endgraf b\endgraf c}
-%D \NC \NR
-%D % \HL
-%D \NC \framed[width=.2\hsize, height=.2\hsize, align=middle] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=broad, align=middle] {a\endgraf b\endgraf c}
-%D \NC \framed[width=.2\hsize, height=fit, align=middle] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=.2\hsize, align=middle] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=broad, align=middle] {a\endgraf b\endgraf c}
-%D \NC \framed[width=fit, height=fit, align=middle] {a\endgraf b\endgraf c}
-%D \NC \NR
-%D % \HL
-%D \stoptabulate
-%D \egroup
-%D \stoppostponing
-
-%D \macros
-%D {framednoflines, framedlastlength}
-%D
-%D It is possible to let the frame macro calculate the width of a centered box
-%D automatically (\type {fit}). When doing so, we need to reshape the box:
-
-\newcount\framednoflines
-\newdimen\framedfirstheight
-\newdimen\framedlastdepth
-\newdimen\framedminwidth
-\newdimen\framedmaxwidth
-\newdimen\framedaveragewidth
-
-\def\pack_framed_reshape_reset
- {\framednoflines \zerocount
- \framedfirstheight \zeropoint
- \framedlastdepth \zeropoint
- \framedminwidth \zeropoint
- \framedmaxwidth \zeropoint
- \framedaveragewidth\zeropoint}
-
-\def\pack_framed_reshape_process{\ifvbox\b_framed_normal\clf_doreshapeframedbox\b_framed_normal\relax\fi}
-\def\pack_framed_reshape_analyze{\ifvbox\b_framed_normal\clf_doanalyzeframedbox\b_framed_normal\relax\fi}
-
-% torture test / strange case (much depth) / method 2 needed
-%
-% \startTEXpage[frame=on]
-% \startformula \startalign \NC A \NC B \NR \intertext{test} \NC C \NC D \NR \stopalign \stopformula
-% test outside formula
-% \startformula \startalign \NC A \NC B \NR \intertext{test} \NC C \NC D \NR \stopalign \stopformula
-% \blank[big]
-% \startformula \startalign \NC \int_01 \NC B \NR \intertext{test} \NC \int_01 \NC D \NR \stopalign \stopformula
-% test outside formula
-% \startformula \startalign \NC \int_01 \NC B \NR \intertext{test} \NC \int_01 \NC D \NR \stopalign \stopformula
-% \stopTEXpage
-
-%D The examples on the next page show how one can give the frame as well as the
-%D background an additional offset and even a bit more depth. The blue outline is
-%D the frame, the red box is the background and the small black outline is the
-%D visualization of the resulting box, that is, we applied \type {\ruledhbox} to
-%D the result.
-%D
-%D \startpostponing
-%D \bgroup
-%D \unprotect
-%D \dontcomplain
-%D
-%D \startbuffer
-%D \unprotect
-%D \vbox to \vsize
-%D \bgroup
-%D \startalignment[middle]
-%D \vss
-%D \dontleavehmode\vbox to .8\vsize
-%D \bgroup
-%D \hsize=300pt
-%D \setupframed
-%D [background=color,
-%D backgroundcolorachtergrondkleur=darkred,
-%D width=300pt,
-%D height=60pt,
-%D framecolorkaderkleur=DemoBlue,
-%D rulethickness=2pt]
-%D \def\status%
-%D {backgroundoffset=\the\dimexpr\framedparameter\c!backgroundoffset\relax\\
-%D frameoffset=\the\dimexpr\framedparameter\c!frameoffset\relax\\
-%D depth=\the\dimexpr\framedparameter\c!depth\relax}
-%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=0pt,frameoffset=0pt]{\status}}
-%D \vss
-%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=5pt,frameoffset=0pt]{\status}}
-%D \vss
-%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=0pt,frameoffset=5pt]{\status}}
-%D \vss
-%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=2pt,frameoffset=5pt]{\status}}
-%D \vss
-%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=5pt,frameoffset=2pt]{\status}}
-%D \vss
-%D \dontleavehmode \ruledhbox{\framed[backgroundoffset=5pt,frameoffset=5pt]{\status}}
-%D \egroup
-%D \vss
-%D \stopalignment
-%D \egroup
-%D \protect
-%D \stopbuffer
-%D
-%D \getbuffer \page
-%D
-%D {\setupframed[depth=4pt]\getbuffer} \page
-%D
-%D \protect
-%D \egroup
-%D \stoppostponing
-
-%D We can draw lines from left to right and top to bottom by using the normal \type
-%D {\hairline} command. Both directions need a different treatment.
-%D
-%D \startbuffer
-%D \framed[width=4cm] {alfa\hairline beta\hairline gamma}
-%D \framed[height=2cm] {alfa\hairline beta\hairline gamma}
-%D \framed[width=4cm,height=2cm]{alfa\hairline beta\hairline gamma}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlinecorrection
-%D \hbox{\getbuffer}
-%D \stoplinecorrection
-%D
-%D These macros try to adapt their behaviour as good as possible to the circumstances
-%D and act as natural as possible.
-
-\unexpanded\def\pack_framed_vboxed_hairline % nasty overlay mess .. needed for autowidth
- {\begingroup
- \scratchoffset\ifconditional\c_framed_has_offset \localoffset \else \zeropoint \fi
- \scratchwidth \dimexpr\scratchoffset+\d_framed_linewidth\relax
- \par
- \nointerlineskip
- \kern\scratchoffset
- \dontleavehmode
- \hrule\s!height\d_framed_linewidth\s!depth\zeropoint
- \par
- \kern-\d_framed_linewidth
- \dontleavehmode
- \hpack to \zeropoint{\hss\vrule\s!height\d_framed_linewidth\s!depth\zeropoint\s!width\scratchwidth}%
- \hfill
- \hpack to \zeropoint{\vrule\s!height\d_framed_linewidth\s!depth\zeropoint\s!width\scratchwidth\hss}%
- \par
- \nointerlineskip
- \kern\scratchoffset
- \nointerlineskip
- \endgraf
- \nointerlineskip
- \localbegstrut
- \endgroup}
-
-\unexpanded\def\pack_framed_hboxed_hairline % use framed dimen
- {\bgroup
- \scratchoffset\ifconditional\c_framed_has_offset \localoffset \else \zeropoint \fi
- \ifconditional\c_framed_has_height
- \dimen\scratchheight\dimexpr\localheight/\plustwo+\strutdp-\plustwo\d_framed_linewidth\relax
- \dimen\scratchdepth \dimexpr\localheight/\plustwo-\strutdp+\plustwo\d_framed_linewidth\relax
- \else
- \dimen\scratchheight\dimexpr\strutht+\scratchoffset\relax
- \dimen\scratchdepth \dimexpr\strutdp+\scratchoffset\relax
- \fi
- \unskip
- \setbox\scratchbox\hpack
- {\kern\scratchoffset
- \vrule\s!height\dimen\scratchheight\s!depth\dimen\scratchdepth\s!width\d_framed_linewidth
- \kern\scratchoffset}%
- \ht\scratchbox\strutht
- \dp\scratchbox\strutdp
- \box\scratchbox
- \ignorespaces
- \egroup}
-
-%D The argument of the frame command accepts \type{\\} as a sort of newline signal. In
-%D horizontal boxes it expands to a space.
-
-\unexpanded\def\pack_framed_vboxed_newline
- {\endgraf\ignorespaces}
-
-\unexpanded\def\pack_framed_hboxed_newline
- {\unskip\normalspace\ignorespaces}
-
-%D We can set each rule on or off. The default setting is inherited from
-%D \type {frame}. An earlier implementation use a bit different approach, but the new
-%D one seems more natural:
-%D
-%D \bgroup
-%D \setuptyping[margin=0pt]
-%D \startlinecorrection
-%D \startbuffer
-%D \framed[offset=overlay,frame=on]{\darkred\blackrule}
-%D \stopbuffer
-%D \hbox{\getbuffer\vbox{\typebuffer}}
-%D
-%D \startbuffer
-%D \framed[offset=overlay,frame=on,bottomframe=off]{\darkred\blackrule}
-%D \stopbuffer
-%D \hbox{\getbuffer\vbox{\typebuffer}}
-%D
-%D \startbuffer
-%D \framed[offset=overlay,frame=on,bottomframe=on]{\darkred\blackrule}
-%D \stopbuffer
-%D \hbox{\getbuffer\vbox{\typebuffer}}
-%D
-%D \startbuffer
-%D \framed[offset=overlay,frame=off]{\darkred\blackrule}
-%D \stopbuffer
-%D \hbox{\getbuffer\vbox{\typebuffer}}
-%D
-%D \startbuffer
-%D \framed[offset=overlay,frame=off,bottomframe=off]{\darkred\blackrule}
-%D \stopbuffer
-%D \hbox{\getbuffer\vbox{\typebuffer}}
-%D
-%D \startbuffer
-%D \framed[offset=overlay,frame=off,bottomframe=on]{\darkred\blackrule}
-%D \stopbuffer
-%D \hbox{\getbuffer\vbox{\typebuffer}}
-%D \stoplinecorrection
-%D \egroup
-
-%D \macros
-%D {startframedtext, setupframedtexts, defineframedtext}
-%D
-%D The general framing command we discussed previously, is not entirely suited for
-%D what we call framed texts, as for instance used in intermezzo's. The next
-%D examples show what we have in mind.
-%D
-%D \startbuffer[framed-0]
-%D \setupframedtexts
-%D [frame=off,
-%D width=\hsize,
-%D background=screen]
-%D
-%D \startframedtext
-%D By default the framed text is centered \dots
-%D \stopframedtext
-%D
-%D \startframedtext[right]
-%D \dots\ but we can also align left, middle and right.
-%D \stopframedtext
-%D \stopbuffer
-%D
-%D \startbuffer[framed-1]
-%D \defineframedtext
-%D [Example]
-%D [width=6cm,
-%D height=5cm]
-%D
-%D \startExample
-%D \typebuffer[framed-1]
-%D \stopExample
-%D \stopbuffer
-%D
-%D \startbuffer[framed-2]
-%D \defineframedtext
-%D [Example]
-%D [width=6cm]
-%D
-%D \startExample
-%D \typebuffer[framed-2]
-%D \stopExample
-%D \stopbuffer
-%D
-%D \startbuffer[framed-3]
-%D \defineframedtext
-%D [Example]
-%D [height=5cm]
-%D
-%D \startExample
-%D \typebuffer[framed-3]
-%D \stopExample
-%D \stopbuffer
-%D
-%D \startbuffer[framed-4]
-%D \defineframedtext
-%D [Example]
-%D [width=fit,height=broad]
-%D
-%D \Example{a very exciting example}
-%D \stopbuffer
-%D
-%D \bgroup \setuptyping[margin=0pt] \getbuffer[framed-0] \egroup
-%D \bgroup \setuptyping[margin=0pt] \getbuffer[framed-1] \egroup
-%D \bgroup \setuptyping[margin=0pt] \getbuffer[framed-2] \egroup
-%D \bgroup \setuptyping[margin=0pt] \getbuffer[framed-3] \egroup
-%D \bgroup \setuptyping[margin=0pt] \getbuffer[framed-4] \egroup
-%D
-%D Here we can see that we have a predefined framed text class as well as the
-%D tools for defining our own. So we have:
-%D
-%D \showsetup{setupframedtexts}
-%D
-%D as well as the definition command:
-%D
-%D \showsetup{defineframedtext}
-%D
-%D that generates two commands:
-%D
-%D \showsetup{start<>}
-%D \showsetup{<>}
-%D
-%D The next definition shows the defaults.
-
-\installcorenamespace{framedtext}
-\installcorenamespace{framedtextlocation}
-
-\installframedcommandhandler \??framedtext {framedtext} \??framedtext
-
-\let\setupframedtexts\setupframedtext
-
-\setupframedtext
- [\c!width=.75\hsize,
- \c!height=\v!fit,
- \c!align=\v!yes,
- %\c!top=,
- \c!bottom=\vfill,
- \c!offset=1em,
- %\c!bodyfont=,
- %\c!style=,
- %\c!color=,
- %\c!left=,
- \c!right=\hfill,
- \c!before=\blank,
- \c!after=\blank,
- %\c!inner=,
- \c!frame=\v!on,
- %\c!topframe=,
- %\c!bottomframe=,
- %\c!leftframe=,
- %\c!rightframe=,
- \c!radius=.5\bodyfontsize,
- \c!corner=\v!rectangular,
- %\c!orientation=,
- %\c!indenting=,
- %\c!foregroundcolor=,
- %\c!foregroundstyle=,
- %\c!background=,
- %\c!backgroundcolor=,
- \c!linecorrection=\v!on,
- \c!depthcorrection=\v!on,
- \c!margin=\v!standard]
-
-\appendtoks
- \setuevalue{\e!start\currentframedtext}{\pack_framed_text_start {\currentframedtext}}%
- \setuevalue{\e!stop \currentframedtext}{\pack_framed_text_stop }%
- \setuevalue {\currentframedtext}{\pack_framed_text_direct{\currentframedtext}}%
-\to \everydefineframedtext
-
-\setvalue{\??framedtextlocation\v!left }{\letframedtextparameter\c!left \relax
- \letframedtextparameter\c!right\hfill}
-
-\setvalue{\??framedtextlocation\v!right }{\letframedtextparameter\c!left \hfill
- \letframedtextparameter\c!right\relax}
-
-\setvalue{\??framedtextlocation\v!middle}{\letframedtextparameter\c!left \hfill
- \letframedtextparameter\c!right\hfill}
-
-\setvalue{\??framedtextlocation\v!none }{\letframedtextparameter\c!left \relax
- \letframedtextparameter\c!right\relax
- \settrue\c_framed_text_location_none}
-
-\unexpanded\def\pack_framed_text_start#1%
- {\bgroup
- \edef\currentframedtext{#1}%
- \dodoubleempty\pack_framed_text_start_indeed}
-
-\def\pack_framed_text_start_indeed[#1][#2]%
- {\doifelseassignment{#1}
- {\pack_framed_text_start_continue\empty{#1}}
- {\pack_framed_text_start_continue{#1}{#2}}}
-
-% todo: sort out first/lastline ht/dp
-
-\def\pack_framed_text_start_continue#1#2%
- {\setupframedtexts[\currentframedtext][#2]%
- \doifsomething{#1}{\setframedtextparameter\c!location{#1}}% does not listen to #3
- \setfalse\c_framed_text_location_none
- \csname\??framedtextlocation\framedtextparameter\c!location\endcsname
- \resetframedtextparameter\c!location
- \pack_framed_text_check
- \setbox\b_framed_normal\vbox % \vpack
- \startboxedcontent
- \hsize\localhsize
- % \insidefloattrue % ? better
- \usebodyfontparameter\framedtextparameter
- % \edef\p_framed_text_strut{\letframedtextparameter\c!strut}% to be used
- \letframedtextparameter\c!strut\v!no
- \inheritedframedtextframed\bgroup
- \let\\=\endgraf
- \edef\p_framed_text_depthcorrection{\framedtextparameter\c!depthcorrection}%
- \ifx\p_framed_text_depthcorrection\v!on
- \pack_framed_text_start_depth_correction
- \else
- \bgroup
- \fi
- \vskip-\strutdp % brrr why is this needed ... needs to be sorted out, see testcase 1
- \doinhibitblank
- \useindentingparameter\framedtextparameter
- \useframedtextstyleandcolor\c!style\c!color
- \framedtextparameter\c!inner
- \ignorespaces}
-
-% testcase 1:
-%
-% \showstruts
-% \startframedtext[align={normal,tolerant},offset=0pt] \input tufte \stopframedtext
-% \startframedtext[align={normal,tolerant},offset=0pt,depthcorrection=off] \input tufte \stopframedtext
-% \startframedtext[align={normal,tolerant},offset=0pt,depthcorrection=off] \inframed{x} \stopframedtext
-% \framed[align={normal,tolerant},offset=0pt]{\input tufte }
-
-%D The \type {none} option is handy for nested usage, as in the presentation
-%D styles, where we don't want interference.
-
-\defineplacement[\??framedtext][\s!parent=\??framedtext\currentframedtext]
-
-\unexpanded\def\pack_framed_text_stop % no \baselinecorrection, see faq docs
- {\endgraf
- \removelastskip
- \ifx\p_framed_text_depthcorrection\v!on
- \pack_framed_text_stop_depth_correction
- \else
- \egroup
- \fi
- \stopboxedcontent
- \ifconditional\c_framed_text_location_none
- \egroup
- \box\b_framed_normal
- \orelse\ifinsidefloat
- \egroup
- \box\b_framed_normal
- \else
- \egroup
- \placement[\??framedtext][\c!depthcorrection=\v!off]{\box\b_framed_normal}%
- \fi
- \egroup}
-
-%D We define the general (and original) case by just saying:
-
-\def\pack_framed_text_check % messy dependency
- {\localhsize\hsize
- \ifinsidefloat \orelse \ifdim\d_page_sides_vsize>\zeropoint % also possible: \c_page_sides_checks_done>\zeropoint
- % \strut % rather clean way to invoke the sidefloat OTR
- % \setbox0=\lastbox % and get the widths set, so from now on we
- % \setlocalhsize % can have framed texts alongside sidefloats
- \checksidefloat
- \setlocalhsize
- \fi}
-
-\def\pack_framed_text_start_depth_correction
- {\bgroup
- \ifhmode
- \par
- \fi
- \ifvmode
- \verticalstrut
- % we need \nowhitespace in case of setups setting whitespace
- % nb, not safe, text vs \vbox as next
- \vskip-\struttotal
- \nowhitespace
- \fi} % na vskip ! new 20/05/2004, fails with next content being box (\scale{..})
-
-\def\pack_framed_text_stop_depth_correction
- {\ifhmode
- \par
- \fi
- \ifvmode
- \forgetall
- \vskip-\struttotal
- \verticalstrut
- \egroup
- \forgetall % brrr too often
- \vskip-\lineheight
- \verticalstrut
- \else
- \egroup
- \fi}
-
-%D Placement can be ignored:
-%D
-%D \starttyping
-%D \hbox to \hsize \bgroup
-%D \startframedtext[none][width=.5\textwidth] \input tufte \stopframedtext
-%D \startframedtext[none][width=.5\textwidth] \input zapf \stopframedtext
-%D \egroup
-%D
-%D \hbox to \hsize \bgroup
-%D \setupframedtexts[location=none]%
-%D \startframedtext[width=.5\textwidth] \input zapf \stopframedtext
-%D \startframedtext[width=.5\textwidth] \input tufte \stopframedtext
-%D \egroup
-%D \stoptyping
-
-%D The simple brace (or group) delimited case is typeset slightly different
-%D and is not aligned.
-
-\unexpanded\def\pack_framed_text_direct#1%
- {\bgroup
- \edef\currentframedtext{#1}%
- \dosingleempty\pack_framed_text_start_direct}
-
-\def\pack_framed_text_start_direct[#1]%
- {\usebodyfontparameter\framedtextparameter
- \iffirstargument
- \setupcurrentframedtext[#1]%
- \fi
- \edef\p_framed_text_strut{\framedtextparameter\c!strut}%
- \letframedtextparameter\c!strut\v!no
- \inheritedframedtextframed\bgroup
- \blank[\v!disable]%
- \let\\=\endgraf
- \useframedtextstyleandcolor\c!style\c!color
- \vskip-\strutdp % brrr why is this needed ... needs to be sorted out, see testcase 1
- \framedtextparameter\c!inner
- \ifx\p_framed_text_strut\v!no
- \let\pack_framed_strut\relax
- \else
- \let\pack_framed_strut\strut
- \fi
- \bgroup
- \aftergroup\pack_framed_text_stop_direct
- \afterassignment\ignorespaces
- \afterassignment\pack_framed_strut
- \let\next=}
-
-\def\pack_framed_text_stop_direct
- {\removelastskip
- \egroup
- \egroup}
-
-\defineframedtext
- [\v!framedtext]
-
-%D \macros
-%D {defineframed}
-%D
-%D One can also define simple framed texts, using:
-%D
-%D \showsetup{defineframed}
-%D
-%D As suggested by Wolfgang we can now use the new \MKIV\ inheritance model instead
-%D of passing a combination of arguments. This also also simplified the \type
-%D {\setupframed} command. There are certainly more places where such improvements
-%D can be made.
-
-\appendtoks
- \ifcsname\??regularframedlevel\currentframed\endcsname
- % already defined, keeps settings
- \else
- \expandafter\newcount\csname\??regularframedlevel\currentframed\endcsname
- \fi
-\to \everypresetframed
-
-\appendtoks
- \setuevalue\currentframed{\pack_framed_defined_process[\currentframed]}%
-\to \everydefineframed
-
-\newcount\c_temp_framed_crap
-
-\unexpanded\def\pack_framed_defined_process[#1]% official (not much checking, todo: parent)
- {\bgroup
- \ifcsname\??regularframedlevel#1\endcsname
- %\expandafter\let\expandafter\c_pack_framed_temp\csname\??regularframedlevel#1\endcsname
- \expandafter\let\expandafter\c_pack_framed_temp\lastnamedcs
- \else
- \let\c_pack_framed_temp\c_temp_framed_crap
- \fi
- \advance\c_pack_framed_temp\plusone
- \expandafter\def\csname\??framed#1>\the\c_pack_framed_temp:\s!parent\endcsname{\??framed#1}% \inheritlocalframed
- \bgroup
- \edef\currentframed{#1>\the\c_pack_framed_temp}%
- \pack_framed_initialize
- \dosingleempty\pack_framed_defined_process_indeed}
-
-\def\pack_framed_defined_process_indeed[#1]%
- {\iffirstargument % faster
- \setupcurrentframed[#1]% here !
- \fi
- \pack_framed_process_indeed}
-
-\let\placeframed\pack_framed_defined_process % new per 2012/04/23
-
-%D We can do:
-%D
-%D \starttyping
-%D \defineframed[\v!framed]
-%D \stoptyping
-%D
-%D but the existing one is ok as well (less csname messy too).
-
-%D New, for the moment private; let's see when GB finds out about this one and its
-%D obscure usage. It's used in:
-%D
-%D \startbuffer
-%D \defineframedtext
-%D [tabulateframe]
-%D [offset=overlay,
-%D backgroundoffset=3pt,
-%D background=color,
-%D backgroundcolor=green]
-%D
-%D \setuptabulate
-%D [tabulate]
-%D [frame=tabulateframe]
-%D
-%D \setuptables
-%D [frame=tabulateframe]
-%D
-%D \input tufte
-%D
-%D \starttabulate[|l|l|]
-%D \NC test \NC test \NC \NR \NC test \NC test \NC \NR
-%D \NC test \NC test \NC \NR \NC test \NC test \NC \NR
-%D \stoptabulate
-%D
-%D \input tufte
-%D
-%D \starttable[|l|l|]
-%D \NC test \NC test \NC \AR \NC test \NC test \NC \AR
-%D \NC test \NC test \NC \AR \NC test \NC test \NC \AR
-%D \stoptable
-%D \stopbuffer
-%D
-%D \typebuffer
-
-\installcorenamespace{framedcontent}
-
-\installframedcommandhandler \??framedcontent {framedcontent} \??framedcontent
-
-\setupframedcontent
- [\c!leftoffset=\zeropoint,
- %\c!rightoffset=\framedcontentparameter\c!leftoffset,
- \c!rightoffset=\scratchleftoffset,
- \c!topoffset=\zeropoint,
- %\c!bottomoffset=\framedcontentparameter\c!topoffset,
- \c!bottomoffset=\scratchtopoffset,
- \c!strut=\v!no,
- %\c!linecorrection=\v!no,
- %\c!left=,
- %\c!right=,
- %\c!width=\v!fit,
- \c!offset=\v!overlay]
-
-\unexpanded\def\startframedcontent
- {\dosingleempty\pack_framed_start_content}
-
-\def\pack_framed_start_content[#1]%
- {\bgroup
- \edef\currentframedcontent{#1}%
- \ifx\currentframedcontent\v!off
- \let\stopframedcontent\egroup
- \else
- \checkframedcontentparent
- \let\stopframedcontent\pack_framed_stop_content_indeed
- \expandafter\pack_framed_start_content_indeed
- \fi}
-
-\def\pack_framed_start_content_indeed
- {\setbox\b_framed_normal\hpack\bgroup
- \setlocalhsize
- \hsize\localhsize
- \scratchleftoffset \framedcontentparameter\c!leftoffset \relax
- \scratchrightoffset \framedcontentparameter\c!rightoffset \relax
- \scratchtopoffset \framedcontentparameter\c!topoffset \relax
- \scratchbottomoffset\framedcontentparameter\c!bottomoffset\relax
- \advance\hsize\dimexpr-\scratchleftoffset-\scratchrightoffset \relax
- \advance\vsize\dimexpr-\scratchtopoffset -\scratchbottomoffset\relax
- \kern\scratchleftoffset
- \vpack\bgroup
- \vskip\scratchtopoffset
- \vbox\bgroup
- \forgetall
- \blank[\v!disable]}
-
-\def\pack_framed_stop_content_indeed
- {\removelastskip
- \egroup
- \vskip\scratchbottomoffset
- \egroup
- \kern\scratchrightoffset
- \egroup
- \doif{\framedcontentparameter\c!width}\v!fit
- {\letframedcontentparameter\c!width\v!fixed}% no shapebox
- \ifinsidefloat
- \donefalse
- \else
- \doifelse{\framedcontentparameter\c!linecorrection}\v!yes\donetrue\donefalse
- \fi
- % plaats ?
- \ifdone\startlinecorrection\fi
- \framedcontentparameter\c!left % new
- \inheritedframedcontentframed{\box\b_framed_normal}% hm
- \framedcontentparameter\c!right % new
- \ifdone\stoplinecorrection\fi
- \egroup}
-
-% A shared setting.
-
-\setuplinewidth
- [\v!medium]
-
-%D A Goodie:
-
-\def\v!unframed{unframed}
-
-\defineframed
- [\v!unframed]
- [\c!frame=\v!off,
- \c!rulethickness=\zeropoint,
- \c!foregroundstyle=\framedparameter\c!style,
- \c!foregroundcolor=\framedparameter\c!color]
-
-%D Bonus (as defined in \type {pack-rul.lua}):
-%D
-%D \starttyping
-%D \setbox\scratchbox\vbox{a\par aa\par aaa\par}
-%D \the\dimexpr\themaxboxwidth\scratchbox\relax
-%D \stoptyping
-
-\let\themaxboxwidth\clf_themaxboxwidth
-
-%D New: slow but ok for most cases:
-
-\unexpanded\def\doifelseframed#1%
- {\ifcase\numexpr\zerocount
- \immediateassignment\edef\tempstring{#1\c!frame }\ifx\tempstring\v!on +\plusone\fi
- \immediateassignment\edef\tempstring{#1\c!topframe }\ifx\tempstring\v!on +\plusone\fi
- \immediateassignment\edef\tempstring{#1\c!bottomframe}\ifx\tempstring\v!on +\plusone\fi
- \immediateassignment\edef\tempstring{#1\c!leftframe }\ifx\tempstring\v!on +\plusone\fi
- \immediateassignment\edef\tempstring{#1\c!rightframe }\ifx\tempstring\v!on +\plusone\fi
- \immediateassignment\edef\tempstring{#1\c!background }\ifx\tempstring\empty\else+\plusone\fi
- \relax\expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments\fi}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-bck.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-bck.mkiv
index 1ec7cdbb86e..1af681049ac 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-bck.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-bck.mkiv
@@ -269,14 +269,14 @@
\def\page_backgrounds_set_boxes_b
{\ifconditional\c_page_backgrounds_new_left
% \showmessage\m!layouts8\empty
- \page_backgrounds_set_box\leftbackground % \conditionalfalse
+ \page_backgrounds_set_box\leftbackground
\global\setfalse\c_page_backgrounds_new_left
\fi}
\def\page_backgrounds_set_boxes_c
{\ifconditional\c_page_backgrounds_new_right
% \showmessage\m!layouts8\empty
- \page_backgrounds_set_box\rightbackground % \conditionaltrue
+ \page_backgrounds_set_box\rightbackground
\global\setfalse\c_page_backgrounds_new_right
\fi}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-box.mkvi b/Master/texmf-dist/tex/context/base/mkiv/page-box.mkvi
index 4804e83706a..02c190e6558 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-box.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-box.mkvi
@@ -252,7 +252,6 @@
{\setbox#1\vpack to \paperheight
{\hsize\paperwidth
\vkern\topspace
-% \parfillskip\zeropoint
\hkern\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}%
\box#1}%
\dp#1\zeropoint}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-brk.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-brk.mkiv
index e18c0d9232a..e275c8b41eb 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-brk.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-brk.mkiv
@@ -290,6 +290,13 @@
\installpagebreakmethod \v!start {\global\settrue \c_otr_shipout_enabled}
\installpagebreakmethod \v!stop {\global\setfalse\c_otr_shipout_enabled}
+\installpagebreakmethod{xy}% for Mojca
+ {\page_breaks_handle_direct\v!yes
+ \scratchcounterone \numexpr\rootlayouttargetparameter\c!nx*\rootlayouttargetparameter\c!ny\relax
+ \scratchcountertwo \luaexpr{math.mod(\the\realpageno-1,\the\scratchcounterone)}\relax
+ \scratchcounterthree\numexpr\scratchcounterone-\scratchcountertwo\relax
+ \dorecurse\scratchcounterthree{\page_breaks_handle_direct\v!empty}}
+
% Column breaks.
\installcorenamespace{columnbreakmethod}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-col.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-col.mkiv
index 272ffe18168..a51406cd900 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-col.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-col.mkiv
@@ -22,7 +22,7 @@
%D We reserve a counter for the number of columns as well as the current
%D column. Both are not to be changed by users!
-\newcount\nofcolumns \nofcolumns\plusone
+%newcount\nofcolumns \nofcolumns\plusone % already in core-ini.mkiv
\newcount\mofcolumns \mofcolumns\plusone
\newconstant\columndirection % 0:lr 1:rl
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-ffl.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-ffl.mkiv
index 176c4a185e7..b02b908a921 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-ffl.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-ffl.mkiv
@@ -23,6 +23,8 @@
%D \setupfacingfloat
%D [whatever]
%D [style=bold,
+%D width=frame,
+%D offset=10pt,
%D color=white]
%D
%D \setupfacingfloat
@@ -56,6 +58,12 @@
\unprotect
+% width:
+%
+% -- fit : do nothing
+% -- dimension : use that
+% -- frame : use hsize minus frame offsets (based on preroll)
+
\installcorenamespace {facingfloat}
\installframedcommandhandler \??facingfloat {facingfloat} \??facingfloat
@@ -63,6 +71,7 @@
\setupfacingfloat
[\c!spaceinbetween=\v!big,
\c!inbetween={\blank[\v!big]},
+ \c!width=\v!fit,
%\c!style,
%\c!color,
\c!page=\v!left]
@@ -82,7 +91,7 @@
\let\m_strc_floats_state\relax
-\def\strc_floats_facing_flush
+\unexpanded\def\strc_floats_facing_flush
{\ifnum\c_strc_floats_facing_flushed<\c_strc_floats_facing_saved
\ifodd\c_strc_floats_facing_flushed
\ifodd\realpageno
@@ -121,6 +130,8 @@
\resetboxesincache{\currentfacingfloat}%
\fi}
+\let\flushfacingfloats\strc_floats_facing_flush
+
\unexpanded\def\strc_floats_facing_setup
{\edef\currentfacingfloat{\currentfacingfloat:\m_strc_floats_state}%
\usefacingfloatstyleandcolor\c!style\v!color}
@@ -175,9 +186,19 @@
% \page[\p_page]%
% \fi
%
+ \edef\currentfacingfloat{#1}%
+ \edef\p_width{\facingfloatparameter\c!width}%
+ \letfacingfloatparameter\c!width\v!fit
+ \ifx\p_width\v!frame
+ \setbox\scratchbox\hpack{\inheritedfacingfloatframed{}}%
+ \advance\hsize-\wd\scratchbox
+ \else\ifx\p_width\v!fit
+ % whatever
+ \else
+ \hsize\p_width
+ \fi\fi
\let\startcontent\bgroup
\let\stopcontent\egroup
- \def\currentfacingfloat{#1}%
\let\m_strc_floats_state\v!left
\strc_floats_facing_handle}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-flt.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-flt.mkiv
index 01ee8b689e8..87476adeb3f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-flt.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-flt.mkiv
@@ -48,7 +48,7 @@
\def\page_floats_report_flushed
{\showmessage\m!floatblocks3%
- {\the\numexpr\totalnoffloats-\savednoffloats\relax}}
+ {\the\numexpr\totalnoffloats-\savednoffloats\relax}}
%D Extra float registers.
@@ -131,7 +131,7 @@
\unexpanded\def\page_floats_collect#1#2#3%
{\clf_collectfloat{#1}\dimexpr#2\relax\dimexpr#3\relax}
-\def\nofstackedfloatincategory#1%
+\def\nofstackedfloatsincategory#1%
{\clf_nofstackedfloats{#1}}
\let\page_floats_column_push_saved\page_floats_push_saved % overloaded in page-mul
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-imp.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-imp.mkiv
index a7ef6ca38f7..829ed24f427 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-imp.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-imp.mkiv
@@ -167,8 +167,13 @@
% \def\page_shipout_box#1{\normalshipout\box#1\relax} % takes a number
+\def\page_shipout_show_box{\scratchcounter}
+
\unexpanded\def\page_shipout_box#1%
- {\clf_shipoutpage#1\relax
+ {\ifcase\tracingoutput\else
+ \page_shipout_show_box#1\relax
+ \fi
+ \clf_shipoutpage#1\relax
\global\setbox#1\emptybox
\global\deadcycles\zerocount}
@@ -322,13 +327,14 @@
\gdef\arrangedrotationO{0}%
\gdef\arrangedrotationE{180}%
\processcommalist[#1]\doinstalledarrangedoption
- \ifx\handlearrangedpage\undefined
+ \ifdefined\handlearrangedpage\else
\global\arrangingpagesfalse
\fi
\setuppapersize
\ifarrangingpages
\ifconditional\c_page_shipouts_use_objects\else
\clf_disablejobsave
+ \clf_synctexdisable
%\disabledirective[job.save]%
\fi
\fi
@@ -356,6 +362,15 @@
\installpagearrangement {\v!normal}
{\global\arrangingpagesfalse}
+%D (WS:) Watch out with 2UP and A4/A5:
+%D
+%D \definepapersize [A4] [width=210mm,height=297mm]
+%D \definepapersize [A5] [width=148mm,height=210mm]
+%D
+%D 297 mm - 2 * 148 mm = 1 mm
+%D
+%D This is only visible when we have a full background.
+
\installpagearrangement 2*16
{\dosetuparrangement{4}{4}{16}{5}{5}%
\pusharrangedpageTHIRTYTWO\poparrangedpagesAB\relax}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/page-ini.lua
index 17f4c44dadd..924e01b2aa8 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-ini.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['page-ini'] = {
local tonumber, rawget, rawset, type, next = tonumber, rawget, rawset, type, next
local match = string.match
-local sort, tohash, insert, remove = table.sort, table.tohash, table.insert, table.remove
+local sort, tohash, insert, remove, sortedkeys = table.sort, table.tohash, table.insert, table.remove, table.sortedkeys
local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash
local texgetcount = tex.getcount
@@ -87,10 +87,23 @@ function pages.mark(name,list)
end
end
+local tobemarked = { }
+
+function pages.markedlist(realpage)
+ if realpage then
+ local m = rawget(tobemarked,realpage) or rawget(data,realpage)
+ return m and next(m) and sortedkeys(m)
+ end
+end
+
local function marked(name)
local realpage = texgetcount("realpageno")
for i=last,realpage-1 do
- rawset(data,i,nil)
+ local di = data[i]
+ if di then
+ tobemarked[i] = di
+ rawset(data,i,nil)
+ end
end
local pagedata = rawget(data,realpage)
return pagedata and pagedata[name] and true or false
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-inj.mkvi b/Master/texmf-dist/tex/context/base/mkiv/page-inj.mkvi
index b1a2913cf6f..f1b520f5e3e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-inj.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-inj.mkvi
@@ -149,7 +149,7 @@
\stopsetups
\startsetups[\??pageinjectionrenderings:\s!setup]
- \setups[\dummyparameter\c!setup]% kind of redundant but fits in
+ \setups[\dummyparameter\c!setups]% kind of redundant but fits in
\stopsetups
\startsetups[\??pageinjectionrenderings:\v!buffer]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-ins.lua b/Master/texmf-dist/tex/context/base/mkiv/page-ins.lua
index 0323952d00f..8a68e16ddaa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-ins.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-ins.lua
@@ -19,6 +19,7 @@ inserts.data = inserts.data or allocate { } -- bytecode storage pool
local variables = interfaces.variables
local v_page = variables.page
+local v_auto = variables.auto
local context = context
local implement = interfaces.implement
@@ -111,3 +112,10 @@ implement {
arguments = "string"
}
+implement {
+ name = "setinsertmigration",
+ arguments = "string",
+ actions = function(state)
+ nodes.migrations.setinserts(state == v_auto)
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-ins.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-ins.mkiv
index 3b473343afe..6f2b56f8285 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-ins.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-ins.mkiv
@@ -1,6 +1,6 @@
%D \module
-%D [ file=core-ins,
-%D version=2002.04.16,
+%D [ file=page-ins,
+%D version=2002.04.16, % was core-ins
%D title=\CONTEXT\ Insertion Macros,
%D subtitle=Insertions,
%D author=Hans Hagen,
@@ -38,6 +38,26 @@
%c!factor=\plusthousand,
\c!location=\v!page]
+\newconstant\insertionmigrationmode
+
+\def\page_inserts_check_anchoring
+ {\edef\p_anchoring{\namedinsertionparameter\empty\c!anchoring}%
+ \insertionmigrationmode\ifx\p_anchoring\v!auto\plusone\else\zerocount\fi
+ \clf_setinsertmigration{\p_anchoring}}
+
+\appendtoks
+ \ifx\currentinsertionparent\empty
+ \page_inserts_check_anchoring
+ \fi
+\to \everysetupinsertion
+
+\setupinsertion
+ [\c!anchoring=\v!none]
+
+\appendtoks
+ \page_inserts_check_anchoring
+\to \everystarttext % or \everyjob
+
\newcount\currentinsertionnumber % This is a count and not a macro !
\newtoks\t_page_inserts_list
@@ -63,7 +83,9 @@
% \floatingpenalty\zerocount
\appendtoks
- \page_inserts_synchronize_registers
+ \ifx\currentinsertionparent\empty \else
+ \page_inserts_synchronize_registers
+ \fi
\to \everysetupinsertion
\unexpanded\def\page_inserts_process#1% beware, this adapts currentinsertion !
@@ -131,12 +153,14 @@
\to \everydefineinsertion
\appendtoks
- \clf_setupinsertion
- {\currentinsertion}
- {%
- location {\insertionparameter\c!location}%
- }%
- \relax
+ \ifx\currentinsertionparent\empty \else
+ \clf_setupinsertion
+ {\currentinsertion}
+ {%
+ location {\insertionparameter\c!location}%
+ }%
+ \relax
+ \fi
\to \everysetupinsertion
\unexpanded\def\page_inserts_set_location#1#2% fast one
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-lay.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-lay.mkiv
index d115b588d6f..6f41f3bd85e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-lay.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-lay.mkiv
@@ -521,6 +521,8 @@
\edef\currentlayouttarget{#1}%
\fi}
+\newdimen\d_page_minimum_paper_size \d_page_minimum_paper_size\luaexpr{math.pi}\onebasepoint
+
\unexpanded\def\page_paper_set_current_indeed[#1][#2]%
{\edef\m_page_asked_paper{#1}% can be the restores
\edef\m_page_asked_print{#2}%
@@ -539,18 +541,18 @@
\processcommacommand[\m_page_asked_paper]\page_paper_handle_page_option
\global\paperwidth \layouttargetparameter\c!width \relax
\global\paperheight\layouttargetparameter\c!height\relax
- \ifdim\paperwidth<\onepoint
- \global\paperwidth\onepoint
+ \ifdim\paperwidth<\d_page_minimum_paper_size
+ \global\paperwidth\d_page_minimum_paper_size
\fi
- \ifdim\paperheight<\onepoint
- \global\paperheight\onepoint
+ \ifdim\paperheight<\d_page_minimum_paper_size
+ \global\paperheight\d_page_minimum_paper_size
\fi
\ifconditional\c_page_target_paper_landscape
\doglobal\swapdimens\paperwidth\paperheight
\fi
\ifinpagebody % local freeze
- \normalexpanded{\setlayouttargetparemeter\c!height{\the\paperheight}}%
- \normalexpanded{\setlayouttargetparemeter\c!width {\the\paperwidth }}%
+ \normalexpanded{\setlayouttargetparameter\c!height{\the\paperheight}}%
+ \normalexpanded{\setlayouttargetparameter\c!width {\the\paperwidth }}%
\fi
%
\page_paper_set_offsets
@@ -1363,7 +1365,6 @@
\fetchruntimecommand \showsetups \f!page_run
\fetchruntimecommand \showmargins \f!page_run
\fetchruntimecommand \showgrid \f!page_run
-\fetchruntimecommand \showusage \f!page_run
\glet\page_grids_add_to_box\gobbleoneargument
\glet\page_grids_add_to_one\gobbleoneargument
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-lin.lua b/Master/texmf-dist/tex/context/base/mkiv/page-lin.lua
index 5ad660460c1..06983ef5c6f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-lin.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-lin.lua
@@ -485,15 +485,6 @@ function boxed.stage_two(n,m)
local m = li[2]
local ti = t[i]
if ti then
- -- local d = getdirection(n)
- -- local l = getlist(n)
- -- if d == 1 then
- -- local w = getwidth(n)
- -- ti = hpack_nodes(linked_nodes(new_kern(-w),ti,new_kern(w)))
- -- end
- -- setnext(ti,l)
- -- setprev(l,ti)
- -- setlist(n,ti)
addtoline(n,ti)
resolve(n,m)
else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-lin.mkvi b/Master/texmf-dist/tex/context/base/mkiv/page-lin.mkvi
index 6a03d12e45b..e355e3e6017 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-lin.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-lin.mkvi
@@ -16,6 +16,9 @@
%
% to be redone (was experiment) .. can be hooked into margin code
% reshuffle arguments
+%
+% this is early luatex code, 2007 or even before that, and it shows ... we
+% have better tricks now
\writestatus{loading}{ConTeXt Core Macros / Line Numbering}
@@ -43,14 +46,15 @@
\definesystemattribute[linereference][public]
\appendtoksonce
- \attribute\linenumberattribute\attributeunsetvalue
+ \c_attr_linenumber\attributeunsetvalue
\to \everyforgetall
\appendtoks
- \attribute\linenumberattribute \attributeunsetvalue
+ \c_attr_linenumber\attributeunsetvalue
\to \everyinsidefloat
-\newcount \linenumber % not used
+\mutable\let\linenumber\!!zerocount
+
\newbox \b_page_lines_scratch
\newcount \c_page_lines_reference
\newconstant\c_page_lines_nesting
@@ -127,7 +131,7 @@
\unexpanded\def\page_lines_some_reference#1#2#3%
{\dontleavehmode\begingroup
\global\advance\c_page_lines_reference\plusone
- \attribute\linereferenceattribute\c_page_lines_reference
+ \c_attr_linereference\c_page_lines_reference
#3% todo: #3{#1} as there is no need to pass #1 as part of #3
% for the moment we use a simple system i.e. no prefixes etc .. todo: store as number
\c_strc_references_bind_state\zerocount % we don't want the prewordbreak and manage it here
@@ -312,11 +316,11 @@
\or
\page_lines_start_define % only when assignment
\fi
- \attribute\linenumberattribute\csname\??linenumberinginstance\currentlinenumbering\endcsname\relax}
+ \c_attr_linenumber\csname\??linenumberinginstance\currentlinenumbering\endcsname\relax}
\unexpanded\def\stoplinenumbering
{\ifconditional\c_pages_lines_nesting=\plusone
- \attribute\linenumberattribute\attributeunsetvalue
+ \c_attr_linenumber\attributeunsetvalue
\the\aftereverylinenumbering
\ifconditional\c_page_lines_auto_narrow\par\fi
\fi
@@ -348,6 +352,7 @@
\def\page_lines_add_numbers_to_box#box#column#max#nesting%
{\bgroup
+ \strc_tags_enable_indeed
\b_page_lines_number #box\relax
\c_page_lines_column #column\relax
\c_page_lines_last_column#max\relax
@@ -459,24 +464,34 @@
% \def\dodollap{\hbox to \zeropoint{\normalhss\box\nextbox}\endgroup}
\def\page_line_handle_left#align#width#distance%
- {\llap
+ {\dostarttagged\t!linenumber\empty
+ \llap
{\page_lines_number_inject#align#width%
+ \dostarttagged\t!ignore\empty
\kern\dimexpr
#distance+\d_page_lines_distance
\ifconditional\c_page_lines_dir_left_to_right\else+\d_page_lines_line_width\fi
\relax
\the\everylinenumber
- \hss}}
+ \hss
+ \dostoptagged}%
+ \dostoptagged}
\def\page_line_handle_right#align#width#distance%
- {\rlap
- {\kern\dimexpr
+ {\dostarttagged\t!linenumber\empty
+ \rlap
+ {\dostarttagged\t!ignore\empty
+ \kern\dimexpr
#distance+\d_page_lines_distance
\ifconditional\c_page_lines_dir_left_to_right+\d_page_lines_line_width\fi
\relax
+ \dostoptagged
\page_lines_number_inject#align#width%
+ \dostarttagged\t!ignore\empty
\the\everylinenumber
- \hss}}
+ \hss
+ \dostoptagged}%
+ \dostoptagged}
\setuvalue{\??linenumberinghandler\v!left}%
{\page_line_handle_left\p_align\leftmarginwidth\leftmargindistance}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-mix.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-mix.mkiv
index f54b8ec71d4..e38ad74068d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-mix.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-mix.mkiv
@@ -125,6 +125,7 @@
\setnewconstant\c_page_mix_routine_error \plusfour
\newconditional\c_page_mix_process_notes
+\newconditional\c_page_mix_grid_snapping
%D The main environment is called as follows:
%D
@@ -253,9 +254,15 @@
%D The error routine is there but unlikely to be called. It is a left-over from
%D the traditional routine that might come in handy some day.
+\def\page_mix_construct_and_shipout#1#2#3%
+ {\ifconditional\c_page_mix_grid_snapping\else\gridsnappingfalse\fi % maybe only for notes (bottom alignment)
+ \page_otr_construct_and_shipout#1#2#3%
+ \ifconditional\c_page_mix_grid_snapping \gridsnappingtrue \fi}
+
+
\def\page_mix_routine_error
{\showmessage\m!columns3\empty
- \page_otr_construct_and_shipout\unvbox\normalpagebox\zerocount} % three arguments
+ \page_mix_construct_and_shipout\unvbox\normalpagebox\zerocount} % three arguments
%D Some settings (and actions) depend on the current output routine and setting the
%D hsize and vsize is among them. The calculation of the hsize is done elsewhere.
@@ -300,9 +307,11 @@
\def\page_mix_enable_grid_snapping
{\edef\p_grid{\mixedcolumnsparameter\c!grid}%
+ \setfalse\c_page_mix_grid_snapping
\ifx\p_grid\empty
% just follow the default grid settings
\else
+ \ifgridsnapping\settrue\c_page_mix_grid_snapping\fi
\gridsnappingtrue
\setsystemmode\v!grid
\spac_grids_snap_value_set\p_grid
@@ -795,7 +804,6 @@
% \hss
% \egroup}
-
\unexpanded\def\page_mix_routine_continue
{\bgroup
\forgetall
@@ -803,7 +811,7 @@
\setbox\b_page_mix_collected\vpack{\unvbox\normalpagebox}% brrr we need to make a tight box (combine this in lua)
\page_mix_routine_construct\v!no
\page_mix_routine_package
- \page_otr_construct_and_shipout\box\b_page_mix_collected\zerocount % three arguments
+ \page_mix_construct_and_shipout\box\b_page_mix_collected\zerocount % three arguments
\clf_mixflushrest
\clf_mixcleanup
\egroup}
@@ -841,7 +849,7 @@
% 1 = we have stuff left, so flush and rebalance
%writestatus\m!columns{flush continue}%
\page_mix_routine_package
- \page_otr_construct_and_shipout\box\b_page_mix_collected\zerocount % three arguments
+ \page_mix_construct_and_shipout\box\b_page_mix_collected\zerocount % three arguments
\setbox\b_page_mix_collected\vpack{\clf_mixflushrest}% we could avoid this
\clf_mixcleanup
\ifdim\ht\b_page_mix_collected=\zeropoint
@@ -1005,7 +1013,7 @@
{\page_one_place_float_force}
\unexpanded\def\page_mix_command_side_float_output
- {\page_otr_construct_and_shipout\unvbox\normalpagebox\zerocount} % three arguments
+ {\page_mix_construct_and_shipout\unvbox\normalpagebox\zerocount} % three arguments
\unexpanded\def\page_mix_command_synchronize_side_floats
{\page_sides_forget_floats}
@@ -1029,7 +1037,7 @@
\begingroup
\scratchdimen\dimexpr#1\lineheight\ifsecondargument+#2\fi\relax
\ifdim\scratchdimen>\zeropoint
- \attribute\checkedbreakattribute\number\scratchdimen
+ \c_attr_checkedbreak\number\scratchdimen % why \number
\penalty\c_page_mix_break_forced\relax
\fi
\endgroup}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-mul.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-mul.mkiv
index f1d68827ab7..a0a02543e95 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-mul.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-mul.mkiv
@@ -690,17 +690,17 @@
\else
\unvcopy#4%
\fi
- \fuzzysnappedbox\unvbox\scratchbox
+ \unvbox\scratchbox
\fakecolumnfootnotes{#1}}%
\else\ifcase\c_strc_notes_page_location
\global\setbox#1\vsplit#2 to #3%
\global\setbox#1\vbox
- {\fuzzysnappedbox\unvbox{#1}}% % or \box ?
+ {\unvbox{#1}}% % or \box ?
\else
\columnfootnotecorrection{#1}{#3}%
\setbox\scratchbox\vsplit#2 to #3%
\global\setbox#1\vbox to #3%
- {\fuzzysnappedbox\unvbox\scratchbox
+ {\unvbox\scratchbox
\fakecolumnfootnotes{#1}}%
\fi \fi
\egroup}
@@ -714,7 +714,7 @@
\def\page_mul_split_last_column#1#2%
{\global\setbox\lastcolumnbox\vbox
{\unvcopy\lasttopcolumnbox
- \fuzzysnappedbox\unvbox{#1}%
+ \unvbox{#1}%
\fakecolumnfootnotes\lastcolumnbox}}
%D NEW: still to be documented.
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-not.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-not.mkiv
index d6f63846f6e..6d71539d5dc 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-not.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-not.mkiv
@@ -22,23 +22,6 @@
\unprotect
-% \def\checkbegincolumnfootnotes % should happen inside otr
-% {\ifcase\c_strc_notes_page_location
-% \erasenotebackup
-% \else
-% \flushnotes
-% \savenotecontent
-% \fi
-% \savenotedata}
-
-% \def\checkendcolumnfootnotes
-% {\restorenotedata
-% \ifcase\c_strc_notes_page_location\else
-% \restorenotecontent
-% \fi}
-
-\let\checksinglecolumnfootnotes\relax
-
\newdimen\totalinsertionheight
\unexpanded\def\settotalinsertionheight
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-one.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-one.mkiv
index 85ed76da180..54e53035f51 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-one.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-one.mkiv
@@ -82,7 +82,12 @@
% 1 = partial page, 2 = whole page, 3 = partial page
-\setnewconstant\kindofpagetextareas\plustwo % \plusone can become default some day
+% We really need a setting! Todo, what key to use?
+
+\pushoverloadmode
+ \setnewconstant\kindofpagetextareas\plustwo % \plusone can become default some day
+ \overloaded\let\kindofpagetextareas\kindofpagetextareas
+\popoverloadmode
\def\page_one_registered_text_area_a % two arguments: (un)vbox n
{\ifconditional\c_page_areas_enabled
@@ -184,8 +189,7 @@
\scratchoffset\ht\b_page_one_contents
\fi
\setbox\b_page_one_bottom_notes\hpack
- {\checksinglecolumnfootnotes % why this check? ***
- \lower\scratchoffset\vbox{\placebottomnotes\par\kern\zeropoint}}% kerns makes notes sit on bottom % pack ?
+ {\lower\scratchoffset\vbox{\placebottomnotes\par\kern\zeropoint}}% kerns makes notes sit on bottom % pack ?
\smashbox\b_page_one_bottom_notes
\ht\b_page_one_contents\zeropoint
\page_one_registered_text_area_b
@@ -486,11 +490,24 @@
\fi\fi
\fi}
+% \def\page_one_place_float_here_indeed
+% {\ifgridsnapping
+% % otherwise real bad outcome
+% \else
+% \baselinecorrection % this has to be done better (and definitely not in column mode)
+% \fi
+% \doplacefloatbox
+% \page_floats_report_total
+% \dohandlenextfloatindent}
+
\def\page_one_place_float_here_indeed
{\ifgridsnapping
% otherwise real bad outcome
\else
- \baselinecorrection % this has to be done better (and definitely not in column mode)
+ % this was not really applied (delayed)
+ % \baselinecorrection % this has to be done better (and definitely not in column mode)
+ % so we now use this:
+ \checkprevdepth
\fi
\doplacefloatbox
\page_floats_report_total
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-otr.lua b/Master/texmf-dist/tex/context/base/mkiv/page-otr.lua
index 30715868426..c87f419b4ff 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-otr.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-otr.lua
@@ -7,6 +7,6 @@ if not modules then modules = { } end modules ['page-otr'] = {
}
interfaces.implement {
- name = "triggerpagebuilder",
- actions = tex.triggerbuildpage,
+ name = "triggerpagebuilder",
+ actions = tex.triggerbuildpage,
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-otr.mkvi b/Master/texmf-dist/tex/context/base/mkiv/page-otr.mkvi
index 6feb15a9d61..0627612610f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-otr.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-otr.mkvi
@@ -25,8 +25,6 @@
\let\triggerpagebuilder\clf_triggerpagebuilder
-\def\m!otr{otr} % todo
-
\installcorenamespace{outputroutine}
\installswitchcommandhandler \??outputroutine {outputroutine} \??outputroutine
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-pcl.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-pcl.mkiv
index 09368c53746..43ba4feb326 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-pcl.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-pcl.mkiv
@@ -173,8 +173,7 @@
\scratchoffset\ht\b_page_one_contents
\fi
\setbox\b_page_one_bottom_notes\hpack
- {\checksinglecolumnfootnotes % ?
- \hsize\d_page_col_column_width
+ {\hsize\d_page_col_column_width
\setupnotes[\c!width=\textwidth]%
\lower\scratchoffset\vbox{\placebottomnotes\par\kern\zeropoint}}%
\ht\b_page_one_contents \zeropoint
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-run.lua b/Master/texmf-dist/tex/context/base/mkiv/page-run.lua
index cb8cf03117f..7ad9c8d9fe0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-run.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-run.lua
@@ -186,38 +186,4 @@ function commands.showlayout(options)
end
-local report = logs.reporter("usage")
-
-function commands.showusage()
- report("")
- report("status after shipping out page %s",tex.getcount("realpageno"))
- report("")
- report(" filename : %s", status.filename)
- report(" inputid : %s", status.inputid)
- report(" linenumber : %s", status.linenumber)
- report(" input pointer : %s", status.input_ptr)
- report("")
- report(" string pointer : %s of %s", status.str_ptr, status.max_strings + status.init_str_ptr)
- report(" pool size : %s", status.pool_size)
- report("")
- report(" node memory usage : %s of %s", status.var_used, status.var_mem_max)
- report(" token memory usage : %s of %s", status.dyn_used, status.fix_mem_max)
- report("")
- report(" cs count : %s of %s", status.cs_count, status.hash_size + status.hash_extra)
- report("")
- report(" stack size : %s of %s", status.max_in_stack, status.stack_size)
- report(" nest size : %s of %s", status.max_nest_stack, status.nest_size)
- report(" parameter size : %s of %s", status.max_param_stack, status.param_size)
- report(" buffer size : %s of %s", status.max_buf_stack, status.buf_size)
- report(" save size : %s of %s", status.max_save_stack, status.save_size)
- report("")
- report(" luabytecode bytes : %s in %s registers", status.luabytecode_bytes, status.luabytecodes)
- report(" luastate bytes : %s of %s", status.luastate_bytes, status.luastate_bytes_max or "unknown")
- report("")
- report(" callbacks : %s", status.callbacks)
- report(" indirect callbacks : %s", status.indirect_callbacks)
- report(" saved callbacks : %s", status.saved_callbacks)
- report(" direct callbacks : %s", status.direct_callbacks)
- report(" function callbacks : %s", status.function_callbacks)
- report("")
-end
+commands.showusage = statistics.showusage
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-run.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-run.mkiv
index d3efe169816..fc46d8236fb 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-run.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-run.mkiv
@@ -215,10 +215,4 @@
\global\setbox#1\vpack{\noindent\backgroundline[layout:mix]{\box#1}}%
\endgroup}
-%D The next command shows some statistics (we might add more in due time):
-
-\unexpanded\gdef\showusage
- {\gtoksapp\everyaftershipout{\ctxcommand{showusage()}}%
- \glet\showusage\relax}
-
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-spr.mkiv b/Master/texmf-dist/tex/context/base/mkiv/page-spr.mkiv
index bb95ee467b1..2d9e488f558 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-spr.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-spr.mkiv
@@ -121,8 +121,8 @@
\unexpanded\def\page_spread_stop_yes
{\kern\zeropoint
\page
- \setuplayout[\c!textwidth=\textwidth]
- \page[\v!left]
+ \setuplayout[\c!textwidth=\textwidth]%
+ \page[\v!left]%
\egroup}
\unexpanded\def\page_spread_start_nop
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-txt.mklx b/Master/texmf-dist/tex/context/base/mkiv/page-txt.mklx
deleted file mode 100644
index b8184e44367..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/page-txt.mklx
+++ /dev/null
@@ -1,969 +0,0 @@
-% macros=mkvi
-
-%D \module
-%D [ file=page-txt, % copied from main-001,
-%D version=1997.03.31,
-%D title=\CONTEXT\ Page Macros,
-%D subtitle=Texts,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Page Macros / Texts}
-
-\unprotect
-
-\newtoks\toptextcontent \newtoks\leftedgetextcontent
-\newtoks\headertextcontent \newtoks\leftmargintextcontent
-\newtoks\footertextcontent \newtoks\rightmargintextcontent
-\newtoks\bottomtextcontent \newtoks\rightedgetextcontent
-
-\newtoks\texttextcontent
-
-%D \macros
-%D {setuptop, setupheader, setuptext,setupfooter, setupbottom}
-%D
-%D The macros in this module sometimes look a bit more complicated than needed,
-%D which is a direct result of the fact that their ancestors are quite old and
-%D upward compatibility is a must.
-%D
-%D \showsetup{setuptop}
-%D \showsetup{setupheader}
-%D \showsetup{setuptext}
-%D \showsetup{setupfooter}
-%D \showsetup{setupbottom}
-
-\installcorenamespace{layouttexts}
-\installcorenamespace{layouttextsline}
-\installcorenamespace{layouttextsreset}
-\installcorenamespace{layouttextssynchronize}
-\installcorenamespace{layouttextstrut}
-\installcorenamespace{layouttextspecial}
-\installcorenamespace{layouttextcontent}
-
-\installcommandhandler \??layouttexts {layoutelement} \??layouttexts
-
-% \appendtoks
-% \resetlayoutelementparameter\c!lefttext % resolves better
-% \resetlayoutelementparameter\c!middletext
-% \resetlayoutelementparameter\c!righttext
-% \to \everydefinelayoutelement
-
-\definelayoutelement[\v!top ]
-\definelayoutelement[\v!header]
-\definelayoutelement[\v!text ]
-\definelayoutelement[\v!footer]
-\definelayoutelement[\v!bottom]
-
-\definelayoutelement[\v!top :\v!text] [\v!top ][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!header:\v!text] [\v!header][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!text :\v!text] [\v!text ][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!footer:\v!text] [\v!footer][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!bottom:\v!text] [\v!bottom][\c!lefttext=,\c!middletext=,\c!righttext=]
-
-\definelayoutelement[\v!top :\v!margin][\v!top ][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!header:\v!margin][\v!header][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!text :\v!margin][\v!text ][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!footer:\v!margin][\v!footer][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!bottom:\v!margin][\v!bottom][\c!lefttext=,\c!middletext=,\c!righttext=]
-
-\definelayoutelement[\v!top :\v!edge] [\v!top ][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!header:\v!edge] [\v!header][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!text :\v!edge] [\v!text ][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!footer:\v!edge] [\v!footer][\c!lefttext=,\c!middletext=,\c!righttext=]
-\definelayoutelement[\v!bottom:\v!edge] [\v!bottom][\c!lefttext=,\c!middletext=,\c!righttext=]
-
-\unexpanded\def\setuplayouttext
- {\dotripleempty\page_layouts_setup_text}
-
-\def\page_layouts_setup_text[#vertical][#horizontal][#settings]%
- {\ifthirdargument
- \setuplayoutelement[#vertical:#horizontal][#settings]%
- \else
- \setuplayoutelement[#vertical][#horizontal]%
- \fi}
-
-\appendtoks
- \ifx\currentlayoutelement\empty\else
- \page_layouts_synchronize_element\currentlayoutelement % brr, can be vertical:horizontal
- \fi
-\to \everysetuplayoutelement
-
-\def\page_layouts_reset_element_status#vertical%
- {\expandafter\normalgdef\csname\??layouttextsreset#vertical\endcsname{\page_layouts_set_element_status_normal#vertical}}
-
-\def\page_layouts_set_element_status_normal#vertical%
- {\expandafter\glet\csname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal
- \expandafter\glet\csname\??layouttextsreset#vertical\endcsname\relax
- \page_layouts_synchronize_element{#vertical}}
-
-\def\page_layouts_synchronize_element#vertical%
- {\xdef\previoustextstate{\csname\??layouttextssynchronize#vertical\endcsname}% can be a let
- \edef\currenttextstate {\namedlayoutelementparameter{#vertical}\c!state}%
- %\writestatus{>>}{[#vertical:\currenttextstate/\previoustextstate]}%
- \ifx\currenttextstate\previoustextstate \else
- \page_layouts_synchronize_element_indeed{#vertical}%
- \fi}
-
-\def\page_layouts_synchronize_element_indeed#vertical%
- {\ifx\currenttextstate \v!high \calculatevsizes\page_backgrounds_recalculate \orelse
- \ifx\previoustextstate\v!high \calculatevsizes\page_backgrounds_recalculate \orelse
- \ifx\currenttextstate \v!none \calculatevsizes\page_backgrounds_recalculate \orelse
- \ifx\previoustextstate\v!none \calculatevsizes\page_backgrounds_recalculate \fi
- \letgvalue{\??layouttextssynchronize#vertical}\currenttextstate}
-
-\unexpanded\def\setuptop {\dotripleempty\page_layouts_setup_text[\v!top ]}
-\unexpanded\def\setupheader{\dotripleempty\page_layouts_setup_text[\v!header]}
-\unexpanded\def\setuptext {\dotripleempty\page_layouts_setup_text[\v!text ]}
-\unexpanded\def\setupfooter{\dotripleempty\page_layouts_setup_text[\v!footer]}
-\unexpanded\def\setupbottom{\dotripleempty\page_layouts_setup_text[\v!bottom]}
-
-%D We inherit some settings:
-
-\setuplayoutelement
- [ \c!leftstyle=\layoutelementparameter\c!style,
- \c!middlestyle=\layoutelementparameter\c!style,
- \c!rightstyle=\layoutelementparameter\c!style,
- \c!leftcolor=\layoutelementparameter\c!color,
- \c!middlecolor=\layoutelementparameter\c!color,
- \c!rightcolor=\layoutelementparameter\c!color,
- \c!leftwidth=\layoutelementparameter\c!width,
- \c!middlewidth=\layoutelementparameter\c!width,
- \c!rightwidth=\layoutelementparameter\c!width]
-
-%D \macros
-%D {noheaderandfooterlines,notopandbottomlines}
-%D
-%D Although not really needed, the following shortcuts sometimes come in handy.
-%D
-%D \showsetup{noheaderandfooterlines}
-%D \showsetup{notopandbottomlines}
-
-\unexpanded\def\noheaderandfooterlines
- {\setuplayoutelement[\v!header][\c!state=\v!empty]%
- \setuplayoutelement[\v!footer][\c!state=\v!empty]}
-
-\unexpanded\def\notopandbottomlines
- {\setuplayoutelement[\v!top ][\c!state=\v!empty]%
- \setuplayoutelement[\v!bottom][\c!state=\v!empty]}
-
-%D \macros
-%D {setuptoptexts,setupheadertexts,setuptexttexts,setupfootertexts,setupbottomtexts}
-%D
-%D The next macros take one or more arguments. The exact setup depends on the number
-%D of arguments. Although not that intuitive, the current scheme evolved out of the
-%D original. When margin and edge texts as well as middle texts showed up, the
-%D current odd|/|even scheme surfaced.
-%D
-%D \showsetup{setuptoptexts}
-%D \showsetup{setupheadertexts}
-%D \showsetup{setuptexttexts}
-%D \showsetup{setupfootertexts}
-%D \showsetup{setupbottomtexts}
-%D
-%D Only the following have checking for pagenumber, date and mark built in, so when
-%D someone uses the key|/|value interface these things have to be set explicitly as
-%D part of the text.
-
-\unexpanded\def\setuptoptexts {\dosixtupleempty\page_layouts_setup_texts[\v!top ]}
-\unexpanded\def\setupheadertexts{\dosixtupleempty\page_layouts_setup_texts[\v!header]}
-\unexpanded\def\setuptexttexts {\dosixtupleempty\page_layouts_setup_texts[\v!text ]}
-\unexpanded\def\setupfootertexts{\dosixtupleempty\page_layouts_setup_texts[\v!footer]}
-\unexpanded\def\setupbottomtexts{\dosixtupleempty\page_layouts_setup_texts[\v!bottom]}
-
-\unexpanded\def\page_layouts_setup_text_six[#vertical][#horizontal][#a][#b][#c][#d]%
- {\edef\currentlayoutelement{#vertical:#horizontal}%
- \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_double{#a}{#d}}%
- \setlayoutelementparameter\c!righttext{\page_layouts_process_element_double{#b}{#c}}}
-
-\unexpanded\def\page_layouts_setup_text_five[#vertical][#horizontal][#a][#b][#c][#d]%
- {\edef\currentlayoutelement{#vertical:\v!text}%
- \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_double{#horizontal}{#c}}%
- \setlayoutelementparameter\c!righttext{\page_layouts_process_element_double{#a}{#b}}}
-
-\unexpanded\def\page_layouts_setup_text_four[#vertical][#horizontal][#a][#b][#c][#d]%
- {\edef\currentlayoutelement{#vertical:#horizontal}%
- \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_single{#a}}%
- \setlayoutelementparameter\c!righttext{\page_layouts_process_element_single{#b}}}
-
-\unexpanded\def\page_layouts_setup_text_three[#vertical][#horizontal][#a][#b][#c][#d]%
- {\edef\currentlayoutelement{#vertical:\v!text}%
- \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_single{#horizontal}}%
- \setlayoutelementparameter\c!righttext{\page_layouts_process_element_single{#a}}}
-
-\unexpanded\def\page_layouts_setup_text_two[#vertical][#horizontal][#a][#b][#c][#d]%
- {\edef\currentlayoutelement{#vertical:\v!text}%
- \resetlayoutelementparameter\c!lefttext
- \resetlayoutelementparameter\c!righttext
- \setlayoutelementparameter \c!middletext{\page_layouts_process_element_single{#horizontal}}}
-
-\unexpanded\def\page_layouts_setup_text_one[#vertical][#horizontal][#a][#b][#c][#d]%
- {\edef\currentlayoutelement{#vertical:\v!text}%
- \resetlayoutelementparameter\c!lefttext
- \resetlayoutelementparameter\c!righttext
- \resetlayoutelementparameter\c!middletext
- \edef\currentlayoutelement{#vertical:\v!margin}%
- \resetlayoutelementparameter\c!lefttext
- \resetlayoutelementparameter\c!righttext
- \resetlayoutelementparameter\c!middletext
- \edef\currentlayoutelement{#vertical:\v!edge}%
- \resetlayoutelementparameter\c!lefttext
- \resetlayoutelementparameter\c!righttext
- \resetlayoutelementparameter\c!middletext}
-
-\unexpanded\def\page_layouts_setup_texts
- {\ifsixthargument \expandafter\page_layouts_setup_text_six \orelse
- \iffifthargument \expandafter\page_layouts_setup_text_five \orelse
- \iffourthargument\expandafter\page_layouts_setup_text_four \orelse
- \ifthirdargument \expandafter\page_layouts_setup_text_three\orelse
- \ifsecondargument\expandafter\page_layouts_setup_text_two \else
- \expandafter\page_layouts_setup_text_one \fi}
-
-%D Left and right texts are swapped on odd and even pages, but only when double
-%D sided typesetting is enabled.
-
-\setvalue{\??layouttextstrut\v!yes}{\setstrut\strut} % maybe more variants
-
-\let\m_page_layouts_element_content\empty
-
-\unexpanded\def\page_layouts_process_element_single#content%
- {\edef\m_page_layouts_element_content{\detokenize{#content}}% so no \v!xxx
- \ifcsname\??layouttextspecial\m_page_layouts_element_content\endcsname
- \lastnamedcs
- \else
- \doifelsemarking\m_page_layouts_element_content
- {\getmarking[\m_page_layouts_element_content][\v!first]}%
- {#content}%
- \fi}
-
-\unexpanded\def\page_layouts_process_element_double#first#second%
- {\doifelseoddpage
- {\page_layouts_process_element_single{#first}}
- {\page_layouts_process_element_single{#second}}}
-
-\unexpanded\def\page_layouts_process_element_indeed#style#color#width%
- {\begingroup
- \uselayoutelementstyleandcolor#style#color%
- \begincsname\??layouttextstrut\layoutelementparameter\c!strut\endcsname
- \ignorecrlf
- \edef\currentlayoutelementwidth{\layoutelementparameter#width}%
- \ifx\currentlayoutelementwidth\empty\else
- \expandafter\page_layouts_process_element_limited
- \fi\p_text
- \endgroup}
-
-\def\page_layouts_process_element_limited#content% are the {}{}{} still needed?
-% {\limitatetext{#content{}{}{}}\currentlayoutelementwidth\unknown}
- {\limitated
- left \currentlayoutelementwidth
- text {#content}
- sentinel {\unknown}
- \relax}
-
-\setvalue{\??layouttextspecial\v!pagenumber}{\page_layouts_place_page_number}
-\setvalue{\??layouttextspecial\v!date }{\currentdate}
-
-%D When specified, the texts are automatically limited in length.
-
-\appendtoks \page_layouts_place_text_line\v!top \topheight \to \toptextcontent
-\appendtoks \page_layouts_place_text_line\v!header\headerheight \to \headertextcontent
-\appendtoks \page_layouts_place_text_line\v!text \textheight \to \texttextcontent
-\appendtoks \page_layouts_place_text_line\v!footer\footerheight \to \footertextcontent
-\appendtoks \page_layouts_place_text_line\v!bottom\bottomheight \to \bottomtextcontent
-
-%D Texts can be disabled, moved up and ignored, depending in the \type {status}
-%D variable. This is handled by the next couple of macros.
-
-\newcount\c_page_layouts_element_state_n
-
-\def\page_layouts_set_element_status#vertical%
- {\c_page_layouts_element_state_n=0\namedlayoutelementparameter#vertical\c!n\relax
- \ifcase\c_page_layouts_element_state_n
- \edef\textlinestatus{\namedlayoutelementparameter#vertical\c!state}%
- \else
- \setxvalue{\namedlayoutelementhash#vertical\c!n}{\the\numexpr\c_page_layouts_element_state_n+\minusone}%
- \let\textlinestatus\v!stop
- \fi}
-
-\appendtoks
- \doifinset\v!header\floatspecification{\setxvalue{\namedlayoutelementhash\v!header\c!n}{1}}%
- \doifinset\v!footer\floatspecification{\setxvalue{\namedlayoutelementhash\v!footer\c!n}{1}}%
-\to \everybeforeflushedpagefloat
-
-\unexpanded\def\page_layouts_place_text_line#vertical%
- {\page_layouts_set_element_status#vertical\relax
- \ifcsname\??layouttextsline\textlinestatus\endcsname
- \expandafter\lastnamedcs
- \else
- \expandafter\page_layouts_place_text_line_unknown
- \fi#vertical}
-
-\unexpanded\def\doifelselayouttextline#vertical% shown or not
- {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}%
- \ifx\currentlayoutelementstate\v!normal
- \expandafter\firstoftwoarguments
- \orelse\ifx\currentlayoutelementstate\v!start
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\doifelselayoutsomeline#vertical% present or not
- {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}%
- \ifx\currentlayoutelementstate\v!none
- \expandafter\secondoftwoarguments
- \orelse\ifx\currentlayoutelementstate\v!high
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\let\doiflayouttextlineelse\doifelselayouttextline
-\let\doiflayoutsomelineelse\doifelselayoutsomeline
-
-\newconditional\resyncaftertextline
-
-\setvalue{\??layouttextsline\v!normal}{\page_layouts_place_text_line_indeed}
-\setvalue{\??layouttextsline\empty }{\page_layouts_place_text_line_indeed}
-
-\letvalue{\??layouttextsline\v!none}\gobbletwoarguments
-\letvalue{\??layouttextsline\v!stop}\gobbletwoarguments
-
-\setvalue{\??layouttextsline\v!high}#vertical#height%
- {\global\settrue\resyncaftertextline
- \page_layouts_reset_element_status#vertical}
-
-\setvalue{\??layouttextsline\v!empty}#vertical#height%
- {\page_layouts_reset_element_status#vertical}
-
-\setvalue{\??layouttextsline\v!start}#vertical#height%
- {\page_layouts_reset_element_status#vertical%
- \page_layouts_place_text_line_indeed#vertical#height}
-
-\setvalue{\??layouttextsline\v!nomarking}#vertical#height%
- {\bgroup
- \page_layouts_reset_element_status#vertical%
- \settrue\inhibitgetmarking
- \page_layouts_place_text_line_indeed#vertical#height%
- \egroup}
-
-% \setupheadertexts [11]
-% \definetext [title] [header] [aa]
-% \setupheadertexts [11] [22]
-% \definetext [title] [header] [aa] [bb]
-% \setupheadertexts [text] [11] [22]
-% \definetext [title] [header] [text] [aa] [bb]
-% \setupheadertexts [11] [22] [33] [44]
-% \definetext [title] [header] [aa] [bb] [cc] [dd]
-% \setupheadertexts [text] [11] [22] [33] [44]
-% \definetext [title] [header] [text] [aa] [bb] [cc] [dd]
-
-\def\page_layouts_place_text_line_unknown#vertical#height%
- {\global\settrue\resyncaftertextline
- \begingroup % new
- \page_layouts_reset_element_status#vertical%
- \begincsname\namedlayoutelementhash{#vertical}\textlinestatus\endcsname
- \begincsname\namedlayoutelementhash{#vertical:\v!text}\textlinestatus\endcsname
- \begincsname\namedlayoutelementhash{#vertical:\v!margin}\textlinestatus\endcsname
- \begincsname\namedlayoutelementhash{#vertical:\v!edge}\textlinestatus\endcsname
- \page_layouts_place_text_line_indeed#vertical#height%
- \endgroup}
-
-\letvalue{\??layouttextsline\s!unknown}\page_layouts_place_text_line_unknown
-
-%D The following macro has to be called after a page is flushed.
-
-\unexpanded\def\resetlayouttextlines % public
- {\begincsname\??layouttextsreset\v!top \endcsname
- \begincsname\??layouttextsreset\v!header\endcsname
- \begincsname\??layouttextsreset\v!text \endcsname
- \begincsname\??layouttextsreset\v!footer\endcsname
- \begincsname\??layouttextsreset\v!bottom\endcsname
- \ifconditional\resyncaftertextline
- \calculateglobalvsizes
- \page_backgrounds_recalculate
- \global\setfalse\resyncaftertextline
- \fi}
-
-\def\getspecificlayouttext#vertical#horizontal#what%
- {\begincsname\namedlayoutelementhash{#vertical:#horizontal}#what\endcsname}
-
-% \settext[header][text][middle][xxx][yyy]
-
-\unexpanded\def\settextcontent
- {\doquintupleempty\page_layouts_set_text_content}
-
-\def\page_layouts_set_text_content[#vertical][#horizontal][#one][#two][#three]% header text middle text/text
- {\iffifthargument
- \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext}%
- {\page_layouts_process_element_double{#two}{#three}}%
- \orelse\iffourthargument
- \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext}%
- {\page_layouts_process_element_double{#two}{#two}}%
- \orelse\ifthirdargument
- \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\c!middletext}%
- {\page_layouts_process_element_double{#one}{#one}}%
- \fi}
-
-\let\currentlayoutelement\relax
-
-\unexpanded\def\resettextcontent
- {\dotripleempty\page_layouts_reset_text_content}
-
-\def\page_layouts_reset_text_content[#vertical][#horizontal][#tag]% header text middle
- {\edef\currentlayoutelement{#vertical:#horizontal}%
- \ifthirdargument
- \letvalueempty{\layoutelementhash\begincsname\??layouttextcontent\v!text:#tag\endcsname\c!middletext}%
- \orelse\ifsecondargument
- \resetlayoutelementparameter\c!lefttext
- \resetlayoutelementparameter\c!middletext
- \resetlayoutelementparameter\c!righttext
- \fi}
-
-\letvalue{\??layouttextcontent\v!text:\c!middle}\c!middletext
-\letvalue{\??layouttextcontent\v!text:\c!left }\c!lefttext
-\letvalue{\??layouttextcontent\v!text:\c!right }\c!righttext
-
-%D The placement of a whole line is handled by the next two macros. These are hooked
-%D into the general purpose token list registers mentioned before.
-
-\let\currentlayouttextline\relax
-
-\def\page_layouts_place_text_line_indeed#vertical#height%
- {\let\currentlayouttextline#vertical%
- \ifdim#height>\zeropoint\relax % prevents pagenumbers when zero height
- \page_layouts_place_text_line_left_or_right{#height}%
- \fi}
-
-\def\page_layouts_place_text_line_left_or_right#height%
- {\goleftonpage
- \setbox\b_page_layouts_element\vbox to #height
- {\vsize#height\relax
- %\hsize\zeropoint % hack so that e.g. after=\hairline gives predictable results
- \hsize\totaltextwidth
- \normalbaselines
- \let\\\ignoredlinebreak
- \let\crlf\ignoredlinebreak
- \namedlayoutelementparameter\currentlayouttextline\c!before
- \doifbothsidesoverruled
- \page_layouts_place_text_line_right
- \page_layouts_place_text_line_right
- \page_layouts_place_text_line_left
- \namedlayoutelementparameter\currentlayouttextline\c!after
- \vkern\zeropoint}% keep the \dp, beware of \vtops, never change this!
- \dp\b_page_layouts_element\zeropoint
- \box\b_page_layouts_element
- \vkern-#height\relax}
-
-\let\page_layouts_place_extra_text_left \empty % historic
-\let\page_layouts_place_extra_text_right\empty % historic
-
-\def\page_layouts_place_text_line_right
- {\hpack
- {\ifdim\leftedgewidth>\zeropoint
- \page_layouts_left_edge_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth
- \fi
- \ifdim\leftmarginwidth>\zeropoint
- \page_layouts_left_margin_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth\zerocount
- \fi
- \ifdim\makeupwidth>\zeropoint
- \page_layouts_text_body_element_l_m_r_e
- \fi
- \ifdim\rightmarginwidth>\zeropoint
- \page_layouts_right_margin_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth\plusone
- \fi
- \ifdim\rightedgewidth>\zeropoint
- \page_layouts_right_edge_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth
- \fi}}
-
-\def\page_layouts_place_text_line_left
- {\hpack
- {\ifdim\leftedgewidth>\zeropoint
- \page_layouts_left_edge_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth
- \fi
- \ifdim\leftmarginwidth>\zeropoint
- \page_layouts_left_margin_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth\zerocount
- \fi
- \ifdim\makeupwidth>\zeropoint
- \page_layouts_text_body_element_e_r_m_l
- \fi
- \ifdim\rightmarginwidth>\zeropoint
- \page_layouts_right_margin_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth\plusone
- \fi
- \ifdim\rightedgewidth>\zeropoint
- \page_layouts_right_edge_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth
- \fi}}
-
-\def\page_layouts_left_edge_element_indeed#text#style#color#width%
- {\letfromlayoutelementparameter\p_text#text%
- \ifx\p_text\empty
- \kern\leftedgewidth
- \else
- \hbox to \leftedgewidth\bgroup
- \hss
- \page_layouts_process_element_indeed#style#color#width%
- \egroup
- \fi}
-
-\def\page_layouts_left_edge_element#text#style#color#width%
- {\edef\currentlayoutelement{\currentlayouttextline:\v!edge}%
- \page_layouts_place_element_indeed\leftedgewidth
- {\page_layouts_left_edge_element_indeed#text#style#color#width}%
- \kern\leftedgedistance}
-
-\def\page_layouts_right_edge_element_indeed#text#style#color#width%
- {\letfromlayoutelementparameter\p_text#text%
- \ifx\p_text\empty
- \kern\rightedgewidth
- \else
- \hbox to \rightedgewidth\bgroup
- \page_layouts_process_element_indeed#style#color#width%
- \hss
- \egroup
- \fi}
-
-\def\page_layouts_right_edge_element#text#style#color#width%
- {\edef\currentlayoutelement{\currentlayouttextline:\v!edge}%
- \kern\rightedgedistance
- \page_layouts_place_element_indeed\rightedgewidth
- {\page_layouts_right_edge_element_indeed#text#style#color#width}}
-
-% margin needs checking!
-
-\def\page_layouts_left_margin_element_indeed#text#style#color#width#margintoo%
- {\letfromlayoutelementparameter\p_text#text%
- \ifx\p_text\empty
- \kern\leftmarginwidth
- \else
- \hbox to \leftmarginwidth\bgroup
- \hss
- \page_layouts_process_element_indeed#style#color#width%
- \egroup
- \fi
- \ifcase#margintoo\or
- \letfromlayoutelementparameter\p_text\c!margintext
- \ifx\p_text\empty\else
- \kern-\leftmarginwidth
- \hbox to \leftmarginwidth\bgroup
- \hss
- \p_text % styling ?
- \egroup
- \fi
- \fi}
-
-\def\page_layouts_left_margin_element#text#style#color#width#margintoo%
- {\edef\currentlayoutelement{\currentlayouttextline:\v!margin}%
- \page_layouts_place_element_indeed\leftmarginwidth
- {\page_layouts_left_margin_element_indeed#text#style#color#width#margintoo}%
- \kern\leftmargindistance}
-
-\def\page_layouts_right_margin_element_indeed#text#style#color#width#margintoo%
- {\letfromlayoutelementparameter\p_text#text%
- \ifx\p_text\empty
- \kern\rightmarginwidth
- \else
- \hbox to \rightmarginwidth\bgroup
- \page_layouts_process_element_indeed#style#color#width%
- \hss
- \egroup
- \fi
- \ifcase#margintoo\or
- \letfromlayoutelementparameter\p_text\c!margintext
- \ifx\p_text\empty\else
- \kern-\rightmarginwidth
- \hbox to \rightmarginwidth\bgroup
- \p_text % ? styling
- \hss
- \egroup
- \fi
- \fi}
-
-\def\page_layouts_right_margin_element#text#style#color#width#margintoo%
- {\edef\currentlayoutelement{\currentlayouttextline:\v!margin}%
- \kern\rightmargindistance
- \page_layouts_place_element_indeed\rightmarginwidth
- {\page_layouts_right_margin_element_indeed#text#style#color#width#margintoo}}
-
-\def\page_layouts_text_body_element_indeed_l_m_r_e
- {\letfromlayoutelementparameter\p_text\c!lefttext
- \ifx\p_text\empty
- \ifx\page_layouts_place_extra_text_left\empty\else
- \hbox to \makeupwidth\bgroup
- \page_layouts_place_extra_text_left
- \hss
- \egroup
- \kern-\makeupwidth
- \fi
- \else
- \hbox to \makeupwidth\bgroup
- \page_layouts_place_extra_text_left
- \page_layouts_process_element_indeed\c!leftstyle\c!leftcolor\c!leftwidth
- \hss
- \egroup
- \kern-\makeupwidth
- \fi
- \letfromlayoutelementparameter\p_text\c!middletext
- \ifx\p_text\empty\else
- \hbox to \makeupwidth\bgroup
- \hss
- \page_layouts_process_element_indeed\c!middlestyle\c!middlecolor\c!middlewidth
- \hss
- \egroup
- \kern-\makeupwidth
- \fi
- \letfromlayoutelementparameter\p_text\c!righttext
- \ifx\p_text\empty
- \kern\makeupwidth
- \else
- \hbox to \makeupwidth\bgroup
- \hss
- \page_layouts_process_element_indeed\c!rightstyle\c!rightcolor\c!rightwidth
- \egroup
- \fi}
-
-\def\page_layouts_text_body_element_indeed_e_r_m_l
- {\letfromlayoutelementparameter\p_text\c!righttext
- \ifx\p_text\empty\else
- \hbox to \makeupwidth\bgroup
- \page_layouts_process_element_indeed\c!rightstyle\c!rightcolor\c!rightwidth
- \hss
- \egroup
- \kern-\makeupwidth
- \fi
- \letfromlayoutelementparameter\p_text\c!middletext
- \ifx\p_text\empty\else
- \hbox to \makeupwidth\bgroup
- \hss
- \page_layouts_process_element_indeed\c!middlestyle\c!middlecolor\c!middlewidth
- \hss
- \egroup
- \kern-\makeupwidth
- \fi
- \letfromlayoutelementparameter\p_text\c!lefttext
- \ifx\p_text\empty
- \ifx\page_layouts_place_extra_text_right\empty
- \kern\makeupwidth
- \else
- \hbox to \makeupwidth\bgroup
- \hss
- \page_layouts_place_extra_text_right
- \egroup
- \fi
- \else
- \hbox to \makeupwidth\bgroup
- \hss
- \page_layouts_process_element_indeed\c!leftstyle\c!leftcolor\c!leftwidth
- \page_layouts_place_extra_text_right
- \egroup
- \fi}
-
-\def\page_layouts_text_body_element_l_m_r_e
- {\edef\currentlayoutelement{\currentlayouttextline:\v!text}%
- \page_layouts_place_element_indeed\makeupwidth\page_layouts_text_body_element_indeed_l_m_r_e}
-
-\def\page_layouts_text_body_element_e_r_m_l
- {\edef\currentlayoutelement{\currentlayouttextline:\v!text}%
- \page_layouts_place_element_indeed\makeupwidth\page_layouts_text_body_element_indeed_e_r_m_l}
-
-\def\page_layouts_place_element_indeed#width#content%
- {\vbox % to \vsize
- {\hsize#width\relax
- \layoutelementparameter\c!before
- \setlayoutcomponentattribute\currentlayoutelement
- \hbox \layoutcomponentboxattribute to #width{#content}%
- \layoutelementparameter\c!after}}
-
-%D Although it is far better to use backgrounds for this purpose, one can add a rule
-%D in the following way. This method makes the rules disappear in case of an empty
-%D text line. Consider this a feature.
-%D
-%D \starttyping
-%D \setupheadertexts[left][right]
-%D
-%D \setupheader[text][after=\hrule,style=bold]
-%D
-%D \starttext
-%D \input tufte \page
-%D \setupheader[state=empty]
-%D \input tufte \page
-%D \stoptext
-%D \stoptyping
-
-%D This code will move to \type {page-flt.tex}.
-
-\appendtoks \placerightmarginblock \kern-\rightmarginwidth \to \rightmargintextcontent
-\appendtoks \placeleftmarginblock \kern-\leftmarginwidth \to \leftmargintextcontent
-
-%D \macros
-%D {definetext}
-%D
-%D Some macros ago, we implemented the \type {status} option \type {unknown}. This
-%D one is used to take care of symbolic texts handlers.
-%D
-%D \showsetup{definetext}
-%D
-%D The next example demonstrates how we can use this mechanism to provide page
-%D (event) dependent text lines.
-%D
-%D \starttyping
-%D \definetext[chapter][footer][pagenumber]
-%D \setuphead[chapter][header=high,footer=chapter]
-%D \setupheadertexts[pagenumber]
-%D \setupfootertexts[left][right]
-%D \chapter{eerste} \dorecurse{20}{\input tufte \relax}
-%D \chapter{tweede} \dorecurse{20}{\input tufte \relax}
-%D \stoptyping
-
-\unexpanded\def\definetext
- {\doseventupleempty\page_layouts_define_text}
-
-\def\page_layouts_define_text[#tag][#vertical][#horizontal][#a][#b][#c][#d]%
- {\ifseventhargument
- \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\page_layouts_setup_text_six [#vertical][#horizontal][#a][#b][#c][#d]}%
- \orelse\ifsixthargument
- \setvalue{\namedlayoutelementhash {#vertical}#tag}{\page_layouts_setup_text_five [#vertical][#horizontal][#a][#b][#c][]}%
- \orelse\iffifthargument
- \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\page_layouts_setup_text_four [#vertical][#horizontal][#a][#b][][]}%
- \orelse\iffourthargument
- \setvalue{\namedlayoutelementhash {#vertical}#tag}{\page_layouts_setup_text_three[#vertical][#horizontal][#a][][][]}%
- \else
- \setvalue{\namedlayoutelementhash {#vertical}#tag}{\page_layouts_setup_text_two [#vertical][#horizontal][][][][]}%
- \fi}
-
-%D A few more page breakers:
-
-\installpagebreakmethod \v!empty
- {\page_otr_flush_all_floats
- \page_otr_command_next_page
- \doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}%
- \doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}%
- \page_otr_insert_dummy_page}
-
-\installpagebreakmethod \v!header
- {\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}}
-
-\installpagebreakmethod \v!footer
- {\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}}
-
-%D While the header and footer lines are moved away from the main text, the top and
-%D bottom lines are centered.
-
-\setuplayoutelement[\v!top ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
-\setuplayoutelement[\v!header][\c!state=\v!normal,\c!n=0,\c!before=, \c!after=\vss,\c!strut=\v!yes]
-\setuplayoutelement[\v!text ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
-\setuplayoutelement[\v!footer][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=, \c!strut=\v!yes]
-\setuplayoutelement[\v!bottom][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=]
-
-%D Moved here from strc-pag:
-%D
-%D We reset a previous location but only when it has a pagenumber associated. This
-%D is a rather messy test but better than the MkII way where we use states and keep
-%D settings.
-
-\let\m_page_layouts_page_number_location \relax
-\let\m_page_layouts_page_number_location_v\relax
-\let\m_page_layouts_page_number_location_h\relax
-\let\m_page_layouts_page_number_location_x\relax
-
-\def\page_layouts_place_page_number % also elsewhere .. beware, not \unexpanded else
- {\strc_pagenumbers_place_location} % test below fails
-
-\def\page_layouts_reset_page_number_location
- {\ifx\m_page_layouts_page_number_location_v\relax\else
- \edef\currentlayoutelement{\m_page_layouts_page_number_location_v:\m_page_layouts_page_number_location_h}%
- \edef\page_layouts_previous_page_number_locator{\detokenizedlayoutelementparameter\m_page_layouts_page_number_location_x}%
- \doif{\meaning\page_layouts_previous_page_number_locator}{\meaning\page_layouts_place_page_number}
- {\resetlayoutelementparameter\m_page_layouts_page_number_location_x}%
- \fi}
-
-\def\page_layouts_set_page_number_location
- {\edef\currentlayoutelement{\m_page_layouts_page_number_location_v:\m_page_layouts_page_number_location_h}%
- \letlayoutelementparameter\m_page_layouts_page_number_location_x\page_layouts_place_page_number
- \ifx\m_page_layouts_page_number_location_x\c!marginedgetext
- \let\page_layouts_place_extra_text_left \page_layouts_place_page_number_left
- \let\page_layouts_place_extra_text_right\page_layouts_place_page_number_right
- \else
- \let\page_layouts_place_extra_text_left \empty
- \let\page_layouts_place_extra_text_right\empty
- \fi}
-
-\def\page_layouts_identify_page_number_location
- {\let\m_page_layouts_page_number_location_v\v!footer
- \let\m_page_layouts_page_number_location_h\v!text
- \let\m_page_layouts_page_number_location_x\c!middletext
- \processallactionsinset[\directpagenumberingparameter\c!location]
- [ \v!header=>\let\m_page_layouts_page_number_location_v\v!header,
- \v!footer=>\let\m_page_layouts_page_number_location_v\v!footer,
- \v!middle=>\let\m_page_layouts_page_number_location_h\v!text
- \let\m_page_layouts_page_number_location_x\c!middletext,
- \v!left=>\let\m_page_layouts_page_number_location_h\v!text
- \let\m_page_layouts_page_number_location_x\c!lefttext,
- \v!right=>\let\m_page_layouts_page_number_location_h\v!text
- \let\m_page_layouts_page_number_location_x\c!righttext,
- \v!inleft=>\let\m_page_layouts_page_number_location_h\v!margin
- \let\m_page_layouts_page_number_location_x\c!lefttext,
- \v!inright=>\let\m_page_layouts_page_number_location_h\v!margin
- \let\m_page_layouts_page_number_location_x\c!righttext,
- \v!inmargin=>\let\m_page_layouts_page_number_location_h\v!margin
- \def\m_page_layouts_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi},
- \v!margin=>\let\m_page_layouts_page_number_location_h\v!margin
- \def\m_page_layouts_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi},
- \v!atmargin=>\let\m_page_layouts_page_number_location_h\v!text
- \let\m_page_layouts_page_number_location_x\c!marginedgetext,
- \v!marginedge=>\let\m_page_layouts_page_number_location_h\v!text
- \let\m_page_layouts_page_number_location_x\c!marginedgetext]}
-
-\unexpanded\def\strc_pagenumbers_set_location
- {\edef\p_strc_pagenumbers_location{\directpagenumberingparameter\c!location}%
- \ifx\p_strc_pagenumbers_location\m_page_layouts_page_number_location
- % unchanged
- \else
- \let\m_page_layouts_page_number_location\p_strc_pagenumbers_location
- \page_layouts_reset_page_number_location
- \ifx\p_strc_pagenumbers_location\empty
- % set otherwise
- \orelse\ifx\p_strc_pagenumbers_location\v!none
- % set otherwise
- \else
- \page_layouts_identify_page_number_location
- \page_layouts_set_page_number_location
- \fi
- \fi}
-
-\def\page_layouts_place_page_number_left % historic
- {\begingroup
- \setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}%
- \ifzeropt\wd\scratchbox\else
- \edef\p_strc_pagenumbers_width{\directpagenumberingparameter\c!width}%
- \ifx\p_strc_pagenumbers_width\empty
- \box\scratchbox\tfskip
- \else
- \hpack to \p_strc_pagenumbers_width{\box\scratchbox\hss}%
- \fi
- \fi
- \endgroup}
-
-\def\page_layouts_place_page_number_right % historic
- {\begingroup
- \setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}%
- \ifzeropt\wd\scratchbox\else
- \edef\p_strc_pagenumbers_width{\directpagenumberingparameter\c!width}%
- \ifx\p_strc_pagenumbers_width\empty
- \tfskip\box\scratchbox
- \else
- \hpack to \p_strc_pagenumbers_width{\hss\box\scratchbox}%
- \fi
- \fi
- \endgroup}
-
-\strc_pagenumbers_set_location % initializes
-
-\newbox\b_page_layouts_element
-
-\def\page_layouts_insert_elements
- {\ifcase\pageornamentstate
- \page_layouts_place_elements_indeed % we could have a special flag for always ignored
- \fi}
-
-\def\page_layouts_place_elements_indeed
- {\setbox\b_page_layouts_element\vpack
- {\dontcomplain
- \calculatereducedvsizes
- \swapmargins
- \offinterlineskip
- \vkern\dimexpr-\topheight-\topdistance\relax
- \the\toptextcontent
- \vkern\dimexpr\topheight+\topdistance\relax
- \the\headertextcontent
- \vkern\dimexpr\headerheight+\headerdistance+\textdistance\relax
- \anch_positions_place_anchors
- \vkern\dimexpr-\textdistance-\textheight\relax
- \the\texttextcontent
- \vkern\textheight
- \the\everyendoftextbody
- \vkern\footerdistance
- \the\footertextcontent
- \vkern\dimexpr\footerheight+\bottomdistance\relax
- \the\bottomtextcontent
- \vkern\bottomheight
- \vfilll}%
- \smashbox\b_page_layouts_element
- \box\b_page_layouts_element}
-
-% \ifdefined\page_prepare_backgrounds\else
-% \let\page_prepare_backgrounds\gobbleoneargument
-% \fi
-
-% only for very special controlled cases or experiments:
-
-\let\page_scale_text_box\gobbleoneargument
-
-\def\page_insert_body#1#2%
- {\setbox\b_page_layouts_element\vpack
- {\offinterlineskip
- \calculatereducedvsizes
- \calculatehsizes
- \swapmargins
- \vkern\dimexpr\headerheight+\headerdistance+\textdistance\relax
- \dontleavehmode
- %\page_prepare_backgrounds{#2}%
- \hpack to \makeupwidth
- {\begingroup
- \swapmargins
- \goleftonpage
- \ifdim\leftedgewidth>\zeropoint
- \the\leftedgetextcontent
- \kern\dimexpr\leftedgewidth+\leftedgedistance\relax
- \fi
- \ifdim\leftmarginwidth>\zeropoint
- \the\leftmargintextcontent
- \kern\dimexpr\leftmarginwidth+\leftmargindistance\relax
- \fi
- \endgroup
- \page_apply_postprocessors_page{#2}%
- \settextpagecontent\b_page_layouts_element{#1}{#2}%
- \page_backgrounds_add_to_text\b_page_layouts_element
- \page_grids_add_to_box\b_page_layouts_element
- \page_scale_text_box\b_page_layouts_element
- \box\b_page_layouts_element
- \begingroup
- \ifdim\rightmarginwidth>\zeropoint
- \kern\rightmargindistance
- \the\rightmargintextcontent
- \kern\rightmarginwidth
- \fi
- \ifdim\rightedgewidth>\zeropoint
- \kern\rightedgedistance
- \the\rightedgetextcontent
- \kern\rightedgewidth
- \fi
- \endgroup
- \hss}}%
- \smashbox\b_page_layouts_element
- \box\b_page_layouts_element}
-
-%D The main text area has to be combined with some additional (tracing) information.
-%D
-%D This will be stored as normal and overloaded in page-lyr and later in page-spr we
-%D overload the the stored version .. evenatually i will clear up the experimental
-%D mess.
-
-\def\settextpagecontent#1#2#3% #2 and #3 will disappear / is overloaded
- {\setbox#1\hpack to \makeupwidth
- {\hss % so don't change this
- \setlayoutcomponentattribute{\v!page:\v!text}%
- \vpack \layoutcomponentboxattribute to \textheight
- {\offinterlineskip
- \freezetextwidth
- \hsize\textwidth % local variant of \sethsize <<< in columns?
- \boxmaxdepth\maxdepth
- \noindent % content can be < \hsize
- \page_otr_command_package_contents#2#3}% this will vbox
- \hss}%
- \dp#1\zeropoint}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/page-txt.mkvi b/Master/texmf-dist/tex/context/base/mkiv/page-txt.mkvi
index 8b021acca5d..9bc78ec9298 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/page-txt.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/page-txt.mkvi
@@ -463,10 +463,19 @@
\unexpanded\def\resettextcontent
{\dotripleempty\page_layouts_reset_text_content}
+% \def\page_layouts_reset_text_content[#vertical][#horizontal][#tag]% header text middle
+% {\edef\currentlayoutelement{#vertical:#horizontal}%
+% \ifthirdargument
+% \letvalueempty{\layoutelementhash\executeifdefined{\??layouttextcontent\v!text:#tag}\c!middletext}%
+% \else\ifsecondargument
+% \resetlayoutelementparameter\c!lefttext
+% \resetlayoutelementparameter\c!middletext
+% \resetlayoutelementparameter\c!righttext
+% \fi\fi}
+
\def\page_layouts_reset_text_content[#vertical][#horizontal][#tag]% header text middle
- {\edef\currentlayoutelement{#vertical:#horizontal}%
- \ifthirdargument
- \letvalueempty{\layoutelementhash\executeifdefined{\??layouttextcontent\v!text:#tag}\c!middletext}%
+ {\ifthirdargument
+ \letvalueempty{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??layouttextcontent\v!text:#tag}\c!middletext}%
\else\ifsecondargument
\resetlayoutelementparameter\c!lefttext
\resetlayoutelementparameter\c!middletext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/phys-dim.lua b/Master/texmf-dist/tex/context/base/mkiv/phys-dim.lua
index 363b4a79cc4..e0cea7babde 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/phys-dim.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/phys-dim.lua
@@ -41,7 +41,7 @@ if not modules then modules = { } end modules ['phys-dim'] = {
local rawset, next = rawset, next
local V, P, S, R, C, Cc, Cs, matchlpeg = lpeg.V, lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.match
-local format, lower = string.format, string.lower
+local format, lower, gsub = string.format, string.lower, string.gsub
local appendlpeg = lpeg.append
local utfchartabletopattern = lpeg.utfchartabletopattern
local mergetable, mergedtable, keys, loweredkeys = table.merge, table.merged, table.keys, table.loweredkeys
@@ -68,7 +68,10 @@ local math_one = Cs((P("$") /"") * (1-P("$"))^1 * (P("$")/"")) / contex
local math_two = Cs((P("\\m {")/"") * (1-P("}"))^1 * (P("}")/"")) / context.m -- watch the space after \m
local digit = R("09")
-local sign = S("+-")
+local plus = P("+")
+local minus = P("-")
+local plusminus = P("±")
+local sign = plus + minus
local power = S("^e")
local digitspace = S("~@_")
local comma = P(",")
@@ -80,8 +83,6 @@ local positive = P("++") -- was p
local negative = P("--") -- was n
local highspace = P("//") -- was s
local padding = P("=")
-local plus = P("+")
-local minus = P("-")
local space = P(" ")
local lparent = P("(")
local rparent = P(")")
@@ -111,6 +112,7 @@ local dnegative = negative / "" / context.digitsnegative
local dhighspace = highspace / "" / context.digitshighspace
local dsomesign = plus / "" / context.digitsplus
+ minus / "" / context.digitsminus
+ + plusminus / "" / context.digitsplusminus
local dpower = power / "" * ( powerdigits + lbrace * powerdigits * rbrace )
local dpadding = padding / "" / context.digitszeropadding -- todo
@@ -152,7 +154,8 @@ local c_p = (ddigitspace^1 * dskipcomma)^0 -- ___,
* (ddigitspace^0 * ddigit * dintercomma)^0 -- _00, 000,
* ddigitspace^0 * ddigit^0 -- _00 000
* (
- dfinalperiod * ddigit * (dintercomma * ddigit)^0 -- .00
+ dfinalperiod * ddigit^1 * dpadding^1 -- .0=
+ + dfinalperiod * ddigit * (dintercomma * ddigit)^0 -- .00
+ dskipperiod * dpadding^1 -- .==
+ dsemiperiod * ddigit * (dintercomma * ddigit)^0 -- :00
+ dsemiperiod * dpadding^1 -- :==
@@ -163,7 +166,8 @@ local p_c = (ddigitspace^1 * dskipperiod)^0 -- ___.
* (ddigitspace^0 * ddigit * dinterperiod)^0 -- _00. 000.
* ddigitspace^0 * ddigit^0 -- _00 000
* (
- dfinalcomma * ddigit * (dinterperiod * ddigit)^0 -- 00
+ dfinalcomma * ddigit^1 * dpadding^1 -- ,0=
+ + dfinalcomma * ddigit * (dinterperiod * ddigit)^0 -- 00
+ dskipcomma * dpadding^1 -- ,==
+ dsemicomma * ddigit * (dinterperiod * ddigit)^0 -- :00
+ dsemicomma * dpadding^1 -- :==
@@ -265,7 +269,7 @@ local long_units = {
Celsius = "celsius",
Lumen = "lumen",
Lux = "lux",
- Bequerel = "bequerel",
+ Becquerel = "becquerel",
Gray = "gray",
Sievert = "sievert",
Katal = "katal",
@@ -531,9 +535,14 @@ local ctx_unitsO = context.unitsO
local ctx_unitsN = context.unitsN
local ctx_unitsC = context.unitsC
local ctx_unitsQ = context.unitsQ
+local ctx_unitsRPM = context.unitsRPM
+local ctx_unitsRTO = context.unitsRTO
+local ctx_unitsRabout = context.unitsRabout
local ctx_unitsNstart = context.unitsNstart
local ctx_unitsNstop = context.unitsNstop
local ctx_unitsNspace = context.unitsNspace
+local ctx_unitsPopen = context.unitsPopen
+local ctx_unitsPclose = context.unitsPclose
local labels = languages.data.labels
@@ -599,7 +608,7 @@ labels.units = allocate {
celsius = { labels = { en = [[\checkedtextcelsius]] } }, -- 0x2103
lumen = { labels = { en = [[lm]] } },
lux = { labels = { en = [[lx]] } },
- bequerel = { labels = { en = [[Bq]] } },
+ becquerel = { labels = { en = [[Bq]] } },
gray = { labels = { en = [[Gy]] } },
sievert = { labels = { en = [[Sv]] } },
katal = { labels = { en = [[kat]] } },
@@ -856,35 +865,60 @@ local function update_parsers() -- todo: don't remap utf sequences
)^1,
}
+ -- todo: avoid \ctx_unitsNstart\ctx_unitsNstop (weird that it can happen .. now catched at tex end)
+ local letter = R("az","AZ")
+ local bound = #(1-letter)
-- local number = lpeg.patterns.number
-
local number = Cs( P("$") * (1-P("$"))^1 * P("$")
+ P([[\m{]]) * (1-P("}"))^1 * P("}")
- + (1-R("az","AZ")-P(" "))^1 -- todo: catch { } -- not ok
+ + (1-letter-P(" "))^1 -- todo: catch { } -- not ok
) / ctx_unitsN
- local start = Cc(nil) / ctx_unitsNstart
- local stop = Cc(nil) / ctx_unitsNstop
- local space = Cc(nil) / ctx_unitsNspace
-
- -- todo: avoid \ctx_unitsNstart\ctx_unitsNstop (weird that it can happen .. now catched at tex end)
-
- local p_c_combinedparser = P { "start",
- number = start * dleader * (p_c_dparser + number) * stop,
- rule = V("number")^-1 * unitparser,
- space = space,
- start = V("rule") * (V("space") * V("rule"))^0 + V("number")
- }
-
- local c_p_combinedparser = P { "start",
- number = start * dleader * (c_p_dparser + number) * stop,
- rule = V("number")^-1 * unitparser,
- space = space,
- start = V("rule") * (V("space") * V("rule"))^0 + V("number")
- }
+ local start = Cc(nil) / ctx_unitsNstart
+ local stop = Cc(nil) / ctx_unitsNstop
+ local space = P(" ") * Cc(nil) / ctx_unitsNspace
+ local open = P("(") * Cc(nil) / ctx_unitsPopen
+ local close = P(")") * Cc(nil) / ctx_unitsPclose
+
+ local range = somespace
+ * ( (P("±") + P("pm") * bound) / "" / ctx_unitsRPM
+ + (P("–") + P("to") * bound) / "" / ctx_unitsRTO )
+ * somespace
+
+ local about = (P("±") + P("pm") * bound) / "" / ctx_unitsRabout
+ * somespace
+
+ -- todo: start / stop
+
+ local function combine(parser)
+ return P { "start",
+ number = start * dleader * (parser + number) * stop,
+ anumber = space
+ * open
+ * V("about")^-1
+ * V("number")
+ * close,
+ rule = V("number")^-1
+ * (V("range") * V("number") + V("anumber"))^-1,
+ unit = unitparser,
+ about = about,
+ range = range,
+ space = space,
+ start = V("rule")
+ * V("unit")
+ * (V("space") * V("rule") * V("unit"))^0
+ + open
+ * V("number")
+ * (V("range") * V("number"))^-1
+ * close
+ * dtrailer^-1
+ * V("unit")
+ + V("number")
+ }
+ end
- return p_c_combinedparser, c_p_combinedparser
+ return combine(p_c_dparser), combine(c_p_dparser)
end
local p_c_parser = nil
@@ -967,3 +1001,15 @@ implement { name = "digits_reverse", actions = makedigits, arguments = { "stri
implement { name = "unit_normal", actions = makeunit, arguments = "string"}
implement { name = "unit_reverse", actions = makeunit, arguments = { "string", true } }
implement { name = "registerunit", actions = registerunit, arguments = "2 strings" }
+
+implement {
+ name = "hyphenateddigits",
+ public = true,
+ protected = true,
+ arguments = { "optional", "string" },
+ actions = function(filler, digits)
+ digits = gsub(digits,"(%d)","%1\\digitsbreak")
+ digits = gsub(digits,"\\-$",filler)
+ context(digits)
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/phys-dim.mkiv b/Master/texmf-dist/tex/context/base/mkiv/phys-dim.mkiv
index 1eb1f37f76b..b390ce64aef 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/phys-dim.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/phys-dim.mkiv
@@ -86,7 +86,6 @@
%D the grouped call.
%D
%D \starttabulate[|l|l|l|]
-%D \starttabulate[|l|l|l|]
%D \NC \type{.} \NC , . \NC comma or period \NC \NR
%D \NC \type{,} \NC , . \NC comma or period \NC \NR
%D \NC \type{:} \NC \NC invisible period \NC \NR
@@ -100,7 +99,6 @@
%D \NC \type{++} \NC $\positive$ \NC high plus sign \NC \NR
%D \NC \type{=} \NC $\zeroamount$ \NC zero padding \NC \NR
%D \stoptabulate
-%D \stoptabulate
%D
%D These triggers are used in the following examples.
%D
@@ -172,10 +170,10 @@
% \definesymbol[units][times][\ifmmode\cdot\else\kern.2\emwidth\cdot\kern.2\emwidth\fi]
\unexpanded\def\digitstextbinop#1% assumes preceding
- {\fourperemspace\nobreak\times\fourperemspace}
+ {\ifmmode#1\else\fourperemspace\nobreak#1\fourperemspace\fi}
%def\digitstimessymbol{\ifmmode\cdot\else\digitstextbinop\cdot\fi}
-\def\digitstimessymbol{\ifmmode\times\else\digitstextbinop\times\fi}
+\def\digitstimessymbol{\digitstextbinop\times}
\unexpanded\def\digitszeropadding {\hphantom{0}}
\unexpanded\def\digitsnegative {\phys_digits_normalized{0}{\phys_digits_raised{\textminus}}}
@@ -185,7 +183,8 @@
%unexpanded\def\digitsminus {\phys_digits_normalized{0}{\mathematics{-}}}
%unexpanded\def\digitsplus {\phys_digits_normalized{0}{\mathematics{+}}}
\unexpanded\def\digitsminus {\phys_digits_normalized{0}{\mathminus}}
-\unexpanded\def\digitsplus {\phys_digits_normalized{0}{\mathplus }}
+\unexpanded\def\digitsplus {\phys_digits_normalized{0}{\mathplus}}
+\unexpanded\def\digitsplusminus {\phys_digits_normalized{0}{\mathplusminus}}
\unexpanded\def\digitsspace {\hphantom{0}}
\unexpanded\def\digitsseparatorspace{\hphantom{.}}
\unexpanded\def\digitssignspace {\hphantom{\digitsminus}}
@@ -522,6 +521,9 @@
{\edef\p_order{\unitparameter\c!order}%
\ifx\p_order\v!reverse\expandafter\clf_unit_reverse\else\expandafter\clf_unit_normal\fi{\detokenize{#1}}}
+\unexpanded\def\digitstextbinnop#1%
+ {\ifmmode#1\else#1\fourperemspace\fi}
+
\unexpanded\def\unitsPUS#1#2#3{\phys_units_next\prefixtext{#1}\unittext{#2}\unitsraise{\suffixtext{#3}}\c_phys_units_state\plusone} % suffix
\unexpanded\def\unitsPU #1#2{\phys_units_next\prefixtext{#1}\unittext{#2}\c_phys_units_state\plusthree} % unit
\unexpanded\def\unitsPS #1#2{\phys_units_next\prefixtext{#1}\unitsraise{\suffixtext{#2}}\c_phys_units_state\plusone} % suffix
@@ -531,8 +533,28 @@
\unexpanded\def\unitsS #1{\phys_units_start{}\unitsraise{\suffixtext{#1}}\c_phys_units_state\plusone} % suffix
\unexpanded\def\unitsO #1{\phys_units_start\operatortext{#1}\c_phys_units_state\plustwo} % operator
\unexpanded\def\unitsN #1{\phys_units_start#1\c_phys_units_state\plusfive} % number
-\unexpanded\def\unitsC #1{\removeunwantedspaces\unittext{#1}\c_phys_units_state\plussix} % connected
-\unexpanded\def\unitsQ #1{\removeunwantedspaces\unitslower{#1}\c_phys_units_state\zerocount} %
+\unexpanded\def\unitsC #1{\removeunwantedspaces\unittext{#1}\c_phys_units_state\plussix} % connected
+\unexpanded\def\unitsQ #1{\removeunwantedspaces\unitslower{#1}\c_phys_units_state\zerocount}
+\unexpanded\def\unitsR #1#2{% todo: tagging
+ \ifmmode
+ #2%
+ \else\ifnum#1=\plusone
+ \digitstextbinop{#2}% before and after
+ \else
+ \digitstextbinnop{#2}% after
+ \fi\fi
+ \c_phys_units_state\zerocount
+ \setfalse\c_phys_units_dospace
+ \setfalse\c_phys_units_number
+ \setfalse\c_phys_units_quantity}
+
+\unexpanded\def\unitsRPM {\unitsR\plusone {±}} % todo: symbols
+\unexpanded\def\unitsRTO {\unitsR\plusone {–}} % todo: symbols
+\unexpanded\def\unitsRabout {\unitsR\zerocount{±}} % todo: symbols
+\unexpanded\def\unitsPopen {(}
+\unexpanded\def\unitsPclose {)}
+
+\unexpanded\def\unitrange#1{}
% Fonts can have a celsius and lack a fahrenheit symbol and as we want
% to be consistent so we check for the counterparts as well. It's slow
@@ -610,7 +632,7 @@
\def\phys_units_start
{\ifmmode
- \dostarttagged\t!mathaction\t!unit
+ \dostarttagged\t!maction\t!unit
\bgroup % make an mrow
\else
\dostarttagged\t!unit\empty
diff --git a/Master/texmf-dist/tex/context/base/mkiv/prop-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/prop-ini.mkiv
deleted file mode 100644
index 3b1c59b245c..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/prop-ini.mkiv
+++ /dev/null
@@ -1,64 +0,0 @@
-%D \module
-%D [ file=prop-ini,
-%D version=2003.04.20,
-%D title=\CONTEXT\ Property Macros,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Property Macros / Initialization}
-
-%D This module is replaced by dedicated mechanisms. Originally properties were
-%D a sort of attributes in \MKII, but now we do things different anyway. We keep
-%D a surrogate mechanism around for compatibility reasons but even this will
-%D become obsolete some day.
-
-\unprotect
-
-\installcorenamespace{propertytypes}
-\installcorenamespace{propertydefiners}
-\installcorenamespace{propertystarters}
-
-\def\properties_obsolete_message
- {\writestatus\m!system{properties are obsolete, use dedicated commands}%
- \glet\properties_obsolete_message\donothing}
-
-\setvalue{\??propertydefiners\v!layer }[#1][#2][#3]{\defineviewerlayer[#1][#3]}
-\setvalue{\??propertydefiners\s!effect }[#1][#2][#3]{\defineeffect [#1][#3]}
-\setvalue{\??propertydefiners\v!negative}[#1][#2][#3]{}
-
-\unexpanded\def\defineproperty
- {\dotripleempty\properties_define}
-
-\def\properties_define[#1][#2][#3]%
- {\properties_obsolete_message
- \setevalue{\??propertytypes#1}{#2}%
- \getvalue{\??propertydefiners#2}[#1][#2][#3]}
-
-\setvalue{\??propertystarters\v!layer }#1{\let\properties_stop\stopviewerlayer\startviewerlayer[#1]}
-\setvalue{\??propertystarters\s!effect }#1{\let\properties_stop\stopeffect \starteffect [#1]}
-\setvalue{\??propertystarters\v!negative}#1{\let\properties_stop\stopnegative \startnegative }
-
-\unexpanded\def\property[#1]%
- {\groupedcommand{\properties_start{#1}}\properties_stop}
-
-\unexpanded\def\startproperty[#1]%
- {\properties_start{#1}}
-
-\unexpanded\def\stopproperty
- {\properties_stop}
-
-\unexpanded\def\properties_start#1%
- {\pushmacro\properties_stop
- \getvalue{\??propertystarters\getvalue{\??propertytypes#1}}{#1}}
-
-\unexpanded\def\properties_stop
- {\properties_stop
- \popmacro\properties_stop}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-aut.lua b/Master/texmf-dist/tex/context/base/mkiv/publ-aut.lua
index e74c7ee18b5..123a67009d4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-aut.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-aut.lua
@@ -530,9 +530,9 @@ implement {
name = "btxauthor",
actions = btxauthor,
arguments = {
- "string",
- "string",
- "string",
+ "argument",
+ "argument",
+ "argument",
{
{ "combiner" },
{ "kind" },
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-apa.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-apa.mkvi
index 5603b79a5f1..c7c00fd1436 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-apa.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-apa.mkvi
@@ -846,7 +846,7 @@
% #title can be title or booktitle
-\starttexdefinition unexpanded btx:apa:translated-title #title
+\starttexdefinition mutable protected btx:apa:translated-title #title
\ifx\currentbtxlanguage\empty
% no need for an extra
\else\ifx\mainbtxlanguage\currentbtxlanguage
@@ -865,7 +865,7 @@
\fi\fi
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:composed-title #title
+\starttexdefinition mutable protected btx:apa:composed-title #title
\btxstartstyleandcolor[apa:\s!list:#title:\currentbtxcategory]
\begingroup
\language[\currentbtxlanguage]
@@ -884,7 +884,7 @@
\btxstopstyleandcolor
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:title
+\starttexdefinition mutable protected btx:apa:title
\setmode{btx:apa:title-placed}
% we make the title active, opening "file"
\btxdoifelse {file} {
@@ -925,7 +925,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:title-if-not-placed
+\starttexdefinition mutable protected btx:apa:title-if-not-placed
\doifelsemode {btx:apa:title-placed} {
\resetmode{btx:apa:title-placed}
} {
@@ -940,7 +940,7 @@
\btxlabeltext{apa:nd}
\stopsetups
-\starttexdefinition unexpanded btx:apa:suffixedyear
+\starttexdefinition mutable protected btx:apa:suffixedyear
\btxdoifelse {year} {
\btxflush{year}
\btxflushsuffix
@@ -965,7 +965,7 @@
% #author may be author(set) or editor
-\starttexdefinition unexpanded btx:apa:author-or-editor #author
+\starttexdefinition mutable protected btx:apa:author-or-editor #author
\btxdoifelse {#author} {
\btxstartstyleandcolor[apa:\s!list:#author]
\btxusecommand[apa:\s!list:#author]{
@@ -1048,7 +1048,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:authoryear
+\starttexdefinition mutable protected btx:apa:authoryear
% we make the authoryear active, pointing to the citation
\texdefinition{btx:format:inject}
{internal(\currentbtxinternal)}
@@ -1073,7 +1073,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:editor-in
+\starttexdefinition mutable protected btx:apa:editor-in
\btxdoif {booktitle} {
\btxlabeltext{In}
\btxspace
@@ -1086,7 +1086,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:organization-if-not-author
+\starttexdefinition mutable protected btx:apa:organization-if-not-author
\btxdoif {organization} {
\doifnot {\btxfoundname{author}} {organization} {
\btxspace
@@ -1099,7 +1099,7 @@
% TODO: The title is terminated with period. However,
% we probably don't want this before the parenthesis.
-\starttexdefinition unexpanded btx:apa:leftparenthesis-or-comma
+\starttexdefinition mutable protected btx:apa:leftparenthesis-or-comma
\doifelsemode {btx:apa:editionset-is-empty} {
\btxleftparenthesis
\resetmode{btx:apa:editionset-is-empty}
@@ -1108,7 +1108,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:editionset
+\starttexdefinition mutable protected btx:apa:editionset
\setmode{btx:apa:editionset-is-empty}
\doif {\currentbtxcategory} {techreport} {
\texdefinition{btx:apa:leftparenthesis-or-comma}
@@ -1157,7 +1157,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:journal
+\starttexdefinition mutable protected btx:apa:journal
\btxstartstyleandcolor[apa:\s!list:journal]
\btxusecommand [apa:\s!list:journal] {
\btxflush{journal}
@@ -1165,7 +1165,7 @@
\btxstopstyleandcolor
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:volume
+\starttexdefinition mutable protected btx:apa:volume
\btxstartstyleandcolor[apa:\s!list:volume]
\btxflush{volume}
\btxstopstyleandcolor
@@ -1173,7 +1173,7 @@
% this could be simplified!
-\starttexdefinition unexpanded btx:apa:journal-volume-number-pages
+\starttexdefinition mutable protected btx:apa:journal-volume-number-pages
\btxdoif {journal} {
\btxspace
\texdefinition{btx:apa:journal}
@@ -1222,7 +1222,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:wherefrom-publisher
+\starttexdefinition mutable protected btx:apa:wherefrom-publisher
\btxdoifelse {address} {
\btxflush{address}
\btxdoif {country} {
@@ -1256,7 +1256,7 @@
% use \btxentry here?
-\starttexdefinition unexpanded btx:apa:url
+\starttexdefinition mutable protected btx:apa:url
\begingroup
\setbreakpoints[doi]
\ifconditional\btxinteractive
@@ -1273,7 +1273,7 @@
% use \btxentry here?
-\starttexdefinition unexpanded btx:apa:doi
+\starttexdefinition mutable protected btx:apa:doi
\begingroup
\setbreakpoints[doi]
\ifconditional\btxinteractive
@@ -1288,7 +1288,7 @@
\endgroup
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:note
+\starttexdefinition mutable protected btx:apa:note
\btxdoif {note} {
\btxleftparenthesis
\btxflush{note}
@@ -1296,7 +1296,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:url-doi-note
+\starttexdefinition mutable protected btx:apa:url-doi-note
\doif {\btxfoundname{doi}} {url} {
\btxspace
\btxlabeltext{apa:Retrieved}
@@ -1311,7 +1311,7 @@
\removeunwantedspaces
\stoptexdefinition
-\starttexdefinition unexpanded btx:apa:type
+\starttexdefinition mutable protected btx:apa:type
\btxdoif {type} {
\btxleftbracket
\btxflush{type}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-aps.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-aps.mkvi
index d085b96eb63..e16279222a6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-aps.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-aps.mkvi
@@ -596,7 +596,7 @@
%D returned. In lua syntax, it can be understood as
%D author or editor or publisher or title or ""
-\starttexdefinition unexpanded btx:aps:composed-title #title
+\starttexdefinition mutable protected btx:aps:composed-title #title
\btxstartstyleandcolor [aps:\s!list:title:\currentbtxcategory]
\begingroup
\language[\currentbtxlanguage]
@@ -611,7 +611,7 @@
\btxstopstyleandcolor
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:title
+\starttexdefinition mutable protected btx:aps:title
\btxdoif {title} {
% we make the title active, opening file
\btxdoifelse {file} {
@@ -627,13 +627,13 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:optional-title
+\starttexdefinition mutable protected btx:aps:optional-title
\doif{\btxparameter{\c!title}}\v!yes {
\texdefinition {btx:aps:title}
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:year
+\starttexdefinition mutable protected btx:aps:year
\btxdoifelse {year} {
\btxflush{year}
} {
@@ -643,7 +643,7 @@
% #author may be author(set) or editor
-\starttexdefinition unexpanded btx:aps:author-or-editor #author
+\starttexdefinition mutable protected btx:aps:author-or-editor #author
\btxdoif {#author} {
\btxflush{#author}
\doifelse {\btxfoundname{#author}} {editor} {
@@ -664,14 +664,14 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:author
+\starttexdefinition mutable protected btx:aps:author
\btxdoif {author} {
\btxflush{author}
\btxcomma
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:organization-if-not-author
+\starttexdefinition mutable protected btx:aps:organization-if-not-author
\btxdoif {organization} {
\doifnot {\btxfoundname{author}} {organization} {
\btxspace
@@ -681,7 +681,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:editor-in
+\starttexdefinition mutable protected btx:aps:editor-in
\btxdoif {booktitle} {
\btxlabeltext{In}
\doifnot {\btxfoundname{author}} {editor} {
@@ -694,7 +694,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:editionset
+\starttexdefinition mutable protected btx:aps:editionset
\doif {\currentbtxcategory} {techreport} {
\btxdoifelse {type} {
\btxusecommand [\currentbtx:type] {
@@ -739,7 +739,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:journal-volume-year
+\starttexdefinition mutable protected btx:aps:journal-volume-year
\btxdoif {journal} {
\btxspace
\btxstartstyleandcolor [aps:\s!list:journal]
@@ -773,7 +773,7 @@
\btxrightparenthesis
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:publisher-wherefrom-year
+\starttexdefinition mutable protected btx:aps:publisher-wherefrom-year
\removeunwantedspaces
\removepunctuation
\btxleftparenthesis
@@ -797,7 +797,7 @@
\btxrightparenthesis
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:note
+\starttexdefinition mutable protected btx:aps:note
\btxperiod
\btxdoif {note} {
\btxleftparenthesis
@@ -806,7 +806,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:aps:doi-url #text
+\starttexdefinition mutable protected btx:aps:doi-url #text
\ifconditional\btxinteractive
\btxdoifelse {doi} {
\goto {#text} [url(http://dx.doi.org/\btxflush{doi})]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-author.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-author.mkvi
index b524331867c..8ee7835996f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-author.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-author.mkvi
@@ -23,7 +23,7 @@
% \currentbtxsurnames : \btxauthorfield{surnames}
% \currentbtxjuniors : \btxauthorfield{juniors}
-\starttexdefinition unexpanded \s!btx:\s!cite:\s!author:\s!de
+\starttexdefinition mutable protected \s!btx:\s!cite:\s!author:\s!de
\ifx\currentbtxlanguage\s!de
\setmode{\s!btx:\s!de}
\fi
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-chicago.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-chicago.mkvi
index 867535ca6be..315d686129d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-chicago.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-chicago.mkvi
@@ -702,20 +702,20 @@
chicago:edition={Utgåva},
chicago:Editor=Redaktör,
chicago:Editors=Redaktörer,
- chicago:Volume=Band,
+ chicago:Volume=Band,
chicago:Volumes=Band,
chicago:nd={u.å.}, % utan årtal
chicago:supplement=Bilaga, % Supplement
chicago:MotionPicture=Spelfilm, % ?
chicago:Writer={Manusförfattare}, % Assuming for a movie
- chicago:Writers={Manusförfattare}, %
+ chicago:Writers={Manusförfattare}, %
chicago:Producer=Producent, % Assuming for a movie
- chicago:Producers=Producenter, %
+ chicago:Producers=Producenter, %
chicago:Director={Regissör}, % Assuming for a movie
- chicago:Directors={Regissörer}, %
+ chicago:Directors={Regissörer}, %
chicago:Recordedby={Inspelad av}, % Assuming for a movie
chicago:Author={Författare},
- chicago:Translator={Översättare},
+ chicago:Translator={Översättare},
chicago:Advanced={Avancerad onlinepublikation}, % ?
chicago:Retrieved={Hämtad från}]
@@ -845,7 +845,7 @@
% #title can be title or booktitle
-\starttexdefinition unexpanded btx:chicago:translated-title #title
+\starttexdefinition mutable protected btx:chicago:translated-title #title
\ifx\currentbtxlanguage\empty
% no need for an extra
\else\ifx\mainbtxlanguage\currentbtxlanguage
@@ -864,7 +864,7 @@
\fi\fi
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:composed-title #title
+\starttexdefinition mutable protected btx:chicago:composed-title #title
\btxstartstyleandcolor[chicago:\s!list:#title:\currentbtxcategory]
\begingroup
\language[\currentbtxlanguage]
@@ -883,7 +883,7 @@
\btxstopstyleandcolor
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:title
+\starttexdefinition mutable protected btx:chicago:title
\setmode{btx:chicago:title-placed}
% we make the title active, opening "file"
\btxdoifelse {file} {
@@ -924,7 +924,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:title-if-not-placed
+\starttexdefinition mutable protected btx:chicago:title-if-not-placed
\doifelsemode {btx:chicago:title-placed} {
\resetmode{btx:chicago:title-placed}
} {
@@ -939,7 +939,7 @@
\btxlabeltext{chicago:nd}
\stopsetups
-\starttexdefinition unexpanded btx:chicago:suffixedyear
+\starttexdefinition mutable protected btx:chicago:suffixedyear
\btxdoifelse {year} {
\btxflush{year}
\btxflushsuffix
@@ -964,7 +964,7 @@
% #author may be author(set) or editor
-\starttexdefinition unexpanded btx:chicago:author-or-editor #author
+\starttexdefinition mutable protected btx:chicago:author-or-editor #author
\btxdoifelse {#author} {
\btxstartstyleandcolor[chicago:\s!list:#author]
\btxusecommand[chicago:\s!list:#author]{
@@ -1047,7 +1047,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:authoryear
+\starttexdefinition mutable protected btx:chicago:authoryear
% we make the authoryear active, pointing to the citation
\texdefinition{btx:format:inject}
{internal(\currentbtxinternal)}
@@ -1070,7 +1070,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:editor-in
+\starttexdefinition mutable protected btx:chicago:editor-in
\btxdoif {booktitle} {
\btxlabeltext{In}
\btxspace
@@ -1083,7 +1083,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:organization-if-not-author
+\starttexdefinition mutable protected btx:chicago:organization-if-not-author
\btxdoif {organization} {
\doifnot {\btxfoundname{author}} {organization} {
\btxspace
@@ -1096,7 +1096,7 @@
% TODO: The title is terminated with period. However,
% we probably don't want this before the parenthesis.
-\starttexdefinition unexpanded btx:chicago:leftparenthesis-or-comma
+\starttexdefinition mutable protected btx:chicago:leftparenthesis-or-comma
\doifelsemode {btx:chicago:editionset-is-empty} {
\btxleftparenthesis
\resetmode{btx:chicago:editionset-is-empty}
@@ -1105,7 +1105,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:editionset
+\starttexdefinition mutable protected btx:chicago:editionset
\setmode{btx:chicago:editionset-is-empty}
\doif {\currentbtxcategory} {techreport} {
\texdefinition{btx:chicago:leftparenthesis-or-comma}
@@ -1154,7 +1154,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:journal
+\starttexdefinition mutable protected btx:chicago:journal
\btxstartstyleandcolor[chicago:\s!list:journal]
\btxusecommand [chicago:\s!list:journal] {
\btxflush{journal}
@@ -1162,7 +1162,7 @@
\btxstopstyleandcolor
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:volume
+\starttexdefinition mutable protected btx:chicago:volume
\btxstartstyleandcolor[chicago:\s!list:volume]
\btxflush{volume}
\btxstopstyleandcolor
@@ -1170,7 +1170,7 @@
% this could be simplified!
-\starttexdefinition unexpanded btx:chicago:journal-volume-number-pages
+\starttexdefinition mutable protected btx:chicago:journal-volume-number-pages
\btxdoif {journal} {
\btxspace
\texdefinition{btx:chicago:journal}
@@ -1219,7 +1219,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:wherefrom-publisher
+\starttexdefinition mutable protected btx:chicago:wherefrom-publisher
\btxdoifelse {address} {
\btxflush{address}
\btxdoif {country} {
@@ -1253,7 +1253,7 @@
% use \btxentry here?
-\starttexdefinition unexpanded btx:chicago:url
+\starttexdefinition mutable protected btx:chicago:url
\begingroup
\setbreakpoints[doi]
\ifconditional\btxinteractive
@@ -1270,7 +1270,7 @@
% use \btxentry here?
-\starttexdefinition unexpanded btx:chicago:doi
+\starttexdefinition mutable protected btx:chicago:doi
\begingroup
\setbreakpoints[doi]
\ifconditional\btxinteractive
@@ -1285,7 +1285,7 @@
\endgroup
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:note
+\starttexdefinition mutable protected btx:chicago:note
\btxdoif {note} {
\btxleftparenthesis
\btxflush{note}
@@ -1293,7 +1293,7 @@
}
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:url-doi-note
+\starttexdefinition mutable protected btx:chicago:url-doi-note
\doif {\btxfoundname{doi}} {url} {
\btxspace
\btxlabeltext{chicago:Retrieved}
@@ -1308,7 +1308,7 @@
\removeunwantedspaces
\stoptexdefinition
-\starttexdefinition unexpanded btx:chicago:type
+\starttexdefinition mutable protected btx:chicago:type
\btxdoif {type} {
\btxleftbracket
\btxflush{type}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-cite.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-cite.mkvi
index 3a01b219a65..721985499b6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-cite.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-cite.mkvi
@@ -13,7 +13,7 @@
\unprotect
-\starttexdefinition unexpanded btx:cite:inject #content
+\starttexdefinition mutable protected btx:cite:inject #content
\ifconditional\btxinteractive
\ifx\currentbtxinternal\empty
#content
@@ -29,7 +29,7 @@
\fi
\stoptexdefinition
-\starttexdefinition unexpanded btx:cite:checkconcat
+\starttexdefinition mutable protected btx:cite:checkconcat
\ifnum\currentbtxcount>\zerocount
\let\currentbtxinternal\empty
\let\currentbtxbacklink\empty
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-commands.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-commands.mkvi
index 281b8324a3e..a5e6bd6de43 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-commands.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-commands.mkvi
@@ -2,6 +2,8 @@
% for tugboat
+\mutable\protected\def\acro#1{\dontleavehmode{\smallcaps#1}} % can be redefined
+
\definebtxcommand\hbox {\hbox}
\definebtxcommand\vbox {\vbox}
\definebtxcommand\llap {\llap}
@@ -9,7 +11,7 @@
\definebtxcommand\url #1{\hyphenatedurl{#1}}
\definebtxcommand\acro #1{\dontleavehmode{\smallcaps#1}}
-\let\<<
-\let\>>
+\mutable\let\<< % for now \mutable, maybe \definebtxcommand\<{<}
+\mutable\let\>> % for now \mutable, maybe \definebtxcommand\>{>}
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-default.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-default.mkvi
index fef993fe052..8d9d24b5947 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-default.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-default.mkvi
@@ -365,7 +365,7 @@
[\s!default:and=och,
\s!default:number={nr.},
\s!default:edition={Utgåva},
- \s!default:Editor=Redaktör,
+ \s!default:Editor=Redaktör,
\s!default:Editors=Redaktörer,
\s!default:Volume=Band,
\s!default:Volumes=Band,
@@ -374,7 +374,7 @@
% First some helpers:
-\starttexdefinition btx:default:composed-title
+\starttexdefinition mutable protected btx:default:composed-title
\begingroup
\language[\currentbtxlanguage]
\btxflush{title}
@@ -385,7 +385,7 @@
\endgroup
\stoptexdefinition
-\starttexdefinition btx:default:title
+\starttexdefinition mutable protected btx:default:title
\btxdoif {title} {
\btxspace
\btxstartstyleandcolor [default:list:title:\currentbtxcategory]
@@ -397,7 +397,7 @@
}
\stoptexdefinition
-\starttexdefinition btx:default:author
+\starttexdefinition mutable protected btx:default:author
\btxdoif {author} {
\btxflush{author}
\doif {\btxfoundname{author}} {editor} {
@@ -412,12 +412,12 @@
}
\stoptexdefinition
-\starttexdefinition btx:default:year
+\starttexdefinition mutable protected btx:default:year
\btxflush{year}
\btxflushsuffix
\stoptexdefinition
-\starttexdefinition btx:default:journal
+\starttexdefinition mutable protected btx:default:journal
\btxdoif {journal} {
\btxspace
\btxstartstyleandcolor [default:list:journal]
@@ -450,7 +450,7 @@
}
\stoptexdefinition
-\starttexdefinition btx:default:editionset
+\starttexdefinition mutable protected btx:default:editionset
\btxdoif {editionset} {
\removeunwantedspaces
\removepunctuation
@@ -483,7 +483,7 @@
}
\stoptexdefinition
-\starttexdefinition btx:default:publisher
+\starttexdefinition mutable protected btx:default:publisher
\btxdoif {publisher} {
\btxflush{publisher}
\btxcomma
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-definitions.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-definitions.mkvi
index 295586f60fb..1e9f8ea9bb1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-definitions.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-definitions.mkvi
@@ -27,7 +27,7 @@
\btxfield{short}
\stopxmlsetups
-\starttexdefinition unexpanded btx:format:inject #link #content
+\starttexdefinition mutable protected btx:format:inject #link #content
\ifx\currentbtxinternal\empty
#content
\else\ifconditional\btxinteractive
@@ -86,7 +86,7 @@
% macros:
-\starttexdefinition unexpanded btx:style:italic #content
+\starttexdefinition mutable protected btx:style:italic #content
\dontleavehmode
\begingroup
\it
@@ -95,7 +95,7 @@
\endgroup
\stoptexdefinition
-\starttexdefinition unexpanded btx:style:bold #content
+\starttexdefinition mutable protected btx:style:bold #content
\dontleavehmode
\begingroup
\bf
@@ -103,14 +103,14 @@
\endgroup
\stoptexdefinition
-\starttexdefinition unexpanded btx:style:quote #content
+\starttexdefinition mutable protected btx:style:quote #content
\dontleavehmode
\startquote
#content
\stopquote
\stoptexdefinition
-\starttexdefinition unexpanded btx:style #style #content
+\starttexdefinition mutable protected btx:style #style #content
\doifelsedefined {btx:style:#style} {
\texdefinition{btx:style:#style} {
#content
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-list.mkvi b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-list.mkvi
index b00c4bd4012..eec63e515c6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-imp-list.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-imp-list.mkvi
@@ -13,7 +13,7 @@
\unprotect
-\starttexdefinition unexpanded btx:list:inject:text #content
+\starttexdefinition mutable protected btx:list:inject:text #content
\ifconditional\btxinteractivetext
\ifx\currentbtxinternal\empty
#content
@@ -39,7 +39,7 @@
}
\stopsetups
-\starttexdefinition unexpanded btx:list:inject:number #content
+\starttexdefinition mutable protected btx:list:inject:number #content
\ifconditional\btxinteractivenumber
\ifx\currentbtxinternal\empty
#content
@@ -55,7 +55,7 @@
\fi
\stoptexdefinition
-\starttexdefinition unexpanded btx:list:helpers:concat
+\starttexdefinition mutable protected btx:list:helpers:concat
\space
\stoptexdefinition
@@ -66,7 +66,7 @@
}
\stopsetups
-\starttexdefinition unexpanded btx:list:numbering #variant
+\starttexdefinition mutable protected btx:list:numbering #variant
\btxstartstyleandcolor [\currentbtxspecification:\s!list:\s!numbering:#variant]
\btxusecommand[\currentbtxspecification:\s!list:\s!numbering:#variant] {
\fastsetup{\s!btx:\s!list:\s!numbering}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/publ-ini.lua
index da6c74b2e46..ec36be89ad7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-ini.lua
@@ -3500,7 +3500,7 @@ do
function publications.prerollcmdstring(str)
btxstring = str or ""
- tex.runtoks("t_btx_cmd")
+ tex.runlocal("t_btx_cmd")
return nodes.toutf(tex.getbox("b_btx_cmd").list) or str
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv
index 996b6d3cab7..dfed53c7374 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv
@@ -59,22 +59,24 @@
\startcontextdefinitioncode
-\def\s!btx {btx}
-
-\def\v!btxcite {btxcite}
-\def\v!btxlist {btxlist}
-\def\v!btxrendering {btxrendering}
-
-\def\s!btxset {btxset}
-\def\s!btxref {btxref}
-\def\s!btxint {btxint}
-\def\s!btxltx {btxltx}
-\def\s!btxrtx {btxrtx}
-\def\s!btxatx {btxatx}
-\def\s!btxbtx {btxbtx}
-\def\s!btxspc {btxspc}
-\def\s!btxlst {btxlst}
-\def\s!btxcom {btxcom}
+%D These are currently not interfaced.
+
+\definesystemconstant {btx}
+
+\definesystemconstant {btxset}
+\definesystemconstant {btxref}
+\definesystemconstant {btxint}
+\definesystemconstant {btxltx}
+\definesystemconstant {btxrtx}
+\definesystemconstant {btxatx}
+\definesystemconstant {btxbtx}
+\definesystemconstant {btxspc}
+\definesystemconstant {btxlst}
+\definesystemconstant {btxcom}
+
+\defineinterfacevariable {btxcite} {btxcite}
+\defineinterfacevariable {btxlist} {btxlist}
+\defineinterfacevariable {btxrendering} {btxrendering}
\definelabelclass[btxlabel][2]
@@ -394,6 +396,10 @@
\let\btxsetup\fastsetup
+% This fails when we check field values:
+
+\let\btxrawfield\btxfield
+
\def\btxfield #1{\dostarttagged\t!pubfld{#1}\clf_btxfield {\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\def\btxdetail #1{\dostarttagged\t!pubfld{#1}\clf_btxdetail{\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\def\btxflush #1{\dostarttagged\t!pubfld{#1}\clf_btxflush {\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
@@ -679,7 +685,7 @@
\dostarttagged\t!publication\empty
\dotagpublication\currentbtxdataset\currentbtxtag
\redoconvertfont % see (**) in strc-lst, this will become an configuration option
- \edef\currentbtxcategory{\btxfield{category}}%
+ \edef\currentbtxcategory{\btxrawfield{category}}%
\ignorespaces
\ifconditional\c_btx_list_texts
\dostarttagged\t!listtext\s!left
@@ -917,7 +923,7 @@
%D \starttyping
%D % #1 is number of entries
%D
-%D \starttexdefinition unexpanded btx:for:alan:wrapper #1
+%D \starttexdefinition mutable protected btx:for:alan:wrapper #1
%D \bTABLE
%D % we can have a command or setups
%D \flushbtxentries[command=\texdefinition{btx:for:alan:content}]
@@ -926,7 +932,7 @@
%D
%D % #1 is tag
%D
-%D \starttexdefinition unexpanded btx:for:alan:content #1
+%D \starttexdefinition mutable protected btx:for:alan:content #1
%D \bTR
%D \bTD
%D \btxsettag{#1}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-usr.mkiv b/Master/texmf-dist/tex/context/base/mkiv/publ-usr.mkiv
deleted file mode 100644
index cb078f424d5..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/publ-usr.mkiv
+++ /dev/null
@@ -1,2 +0,0 @@
-% todo
-
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-bar.mkvi b/Master/texmf-dist/tex/context/base/mkiv/scrn-bar.mkvi
index c089eb94576..4b50a437d00 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrn-bar.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-bar.mkvi
@@ -343,13 +343,13 @@
\ifnum\scratchcounterthree<\plusone \scratchcounterthree\plusone \fi
\scratchcounterfive\zerocount
\dostepwiserecurse\firstsubpage\lastsubpage\plusone
- {\!!doneafalse
+ {\donefalse
\advance\scratchcounterfive \plusone
- \ifnum\recurselevel=\firstsubpage\relax \!!doneatrue \fi
- \ifnum\recurselevel=\lastsubpage \relax \!!doneatrue \fi
+ \ifnum\recurselevel=\firstsubpage\relax \donetrue \fi
+ \ifnum\recurselevel=\lastsubpage \relax \donetrue \fi
\scratchcountersix\therealsubpageno\recurselevel\relax
\c_scrn_bar_mode
- \if!!donea
+ \ifdone
\ifnum\scratchcountersix<\realpageno
\zerocount
\else\ifnum\scratchcountersix>\realpageno
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi b/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi
index 0c9b4cfb51b..6c279dfc487 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi
@@ -155,7 +155,7 @@
\def\scrn_button_make#currentparameter#inheritedframed#letparameter#setparameter#text#action%
{\begingroup
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\global\setfalse\c_scrn_button_skipped
\chardef\locationboxpagestate\csname\??buttonlocation#currentparameter\c!samepage\endcsname % ?? bt: todo
\doifelsereferencefound{#action}\scrn_button_make_yes\scrn_button_make_nop
@@ -337,7 +337,7 @@
\let\scrn_menu_define_original\defineinteractionmenu
-\unexpanded\def\defineinteractionmenu
+\unexpanded\overloaded\def\defineinteractionmenu
{\dotripleempty\scrn_menu_define}
\def\scrn_menu_define[#tag][#category][#settings]% category reflects location, settings can be parent
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-fld.mkvi b/Master/texmf-dist/tex/context/base/mkiv/scrn-fld.mkvi
index 7710a32dcb5..6c0e97a9af0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrn-fld.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-fld.mkvi
@@ -235,7 +235,7 @@
fontsize {\fontbody}%
fontsymbol {\fieldbodyparameter\c!symbol}%
color {\fieldbodyparameter\c!color}%
- colorvalue \attribute\colorattribute
+ colorvalue \c_attr_color
\ifx\currentfieldbackgroundcolor\empty \else
backgroundcolor {\currentfieldbackgroundcolor}%
backgroundcolorvalue \numexpr\currentfieldbackgroundcolorvalue\relax
@@ -390,6 +390,8 @@
\installparameterhandler \??fieldcontent {fieldcontentframed}
\installparameterhandler \??fieldtotal {fieldtotalframed}
+\installparametersethandler \??fieldcontent {fieldcontentframed}
+
\installsetuphandler \??fieldlabel {fieldlabelframed}
\installsetuphandler \??fieldcontent {fieldcontentframed}
\installsetuphandler \??fieldtotal {fieldtotalframed}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-ini.mkvi b/Master/texmf-dist/tex/context/base/mkiv/scrn-ini.mkvi
index 557ceb5631a..39fef740c24 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrn-ini.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-ini.mkvi
@@ -231,7 +231,7 @@
% this comes before starttext
\def\scrn_identity_document#1#2%
- {\doifvariable{document}{metadata:#1}{\setupinteraction[#2=\documentvariable{metadata:#1}]}}
+ {\doifdocumentvariable{metadata:#1}{\setupinteraction[#2=\documentvariable{metadata:#1}]}}
\appendtoks % not interfaced i.e. english
\scrn_identity_document {title}\c!title
@@ -242,7 +242,7 @@
\scrn_identity_document {keyword}\c!keyword
\scrn_identity_document{keywords}\c!keyword
\scrn_identity_document {date}\c!date
-\to \everysetupdocument
+\to \everystartdocument % or stop
\setupinteraction
[\c!title=,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-wid.mkvi b/Master/texmf-dist/tex/context/base/mkiv/scrn-wid.mkvi
index 6808bd0b3e4..d0b0fb006a2 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrn-wid.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-wid.mkvi
@@ -202,7 +202,7 @@
height \dimexpr\currentattachmentheight\relax
depth \dimexpr\currentattachmentdepth \relax
color {\attachmentparameter\c!color}%
- colormodel \attribute\colormodelattribute
+ colormodel \c_attr_colormodel
colorvalue \numexpr\thecolorattribute{\attachmentparameter\c!color}\relax % or are these chardefs
transparencyvalue \numexpr\thetransparencyattribute{\attachmentparameter\c!color}\relax % or are these chardefs
symbol {\currentattachmentsymbol}%
@@ -501,7 +501,7 @@
depth \dimexpr\currentcommentdepth\relax
nx {\commentparameter\c!nx}%
ny {\commentparameter\c!ny}%
- colormodel \attribute\colormodelattribute
+ colormodel \c_attr_colormodel
colorvalue \numexpr\thecolorattribute{\commentparameter\c!color}\relax
transparencyvalue \numexpr\thetransparencyattribute{\commentparameter\c!color}\relax
option {\commentparameter\c!option}% % todo
@@ -605,7 +605,7 @@
{\iflocation
\clf_insertsoundclip
tag {#tag}%
- repeat {\directexternalsoundtrackparameter\c!option}%
+ repeat {\directexternalsoundtracksparameter\c!option}%
\relax
\fi}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua b/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua
index 83eecf6a3b3..9e6e24f4d02 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua
@@ -30,7 +30,6 @@ local getprev = nuts.getprev
local getfont = nuts.getfont
local getchar = nuts.getchar
local getid = nuts.getid
-local getattr = nuts.getattr
local getsubtype = nuts.getsubtype
local getwidth = nuts.getwidth
@@ -51,13 +50,11 @@ local userskip_code = gluecodes.userskip
local spaceskip_code = gluecodes.spaceskip
local xspaceskip_code = gluecodes.xspaceskip
-local a_scriptstatus = attributes.private('scriptstatus')
-local a_scriptinjection = attributes.private('scriptinjection')
-
-local categorytonumber = scripts.categorytonumber
-local numbertocategory = scripts.numbertocategory
local hash = scripts.hash
-local numbertodataset = scripts.numbertodataset
+
+local getscriptstatus = scripts.getstatus
+local getscriptdata = scripts.getdata
+local scriptcolors = scripts.colors
local fonthashes = fonts.hashes
local quaddata = fonthashes.quads
@@ -440,6 +437,21 @@ local injectors = { -- [previous] [current]
half_width_close = korean_5,
}
+scriptcolors.korean = "trace:0"
+scriptcolors.chinese = "trace:0"
+scriptcolors.katakana = "trace:0"
+scriptcolors.hiragana = "trace:0"
+scriptcolors.full_width_open = "trace:1"
+scriptcolors.full_width_close = "trace:2"
+scriptcolors.half_width_open = "trace:3"
+scriptcolors.half_width_close = "trace:4"
+scriptcolors.full_width_punct = "trace:5"
+------------.hyphen = "trace:5"
+scriptcolors.non_starter = "trace:6"
+scriptcolors.jamo_initial = "trace:7"
+scriptcolors.jamo_medial = "trace:8"
+scriptcolors.jamo_final = "trace:9"
+
local function process(head,first,last)
if first ~= last then
local lastfont = nil
@@ -449,8 +461,7 @@ local function process(head,first,last)
local upcoming = getnext(first)
local id = getid(first)
if id == glyph_code then
- local a = getattr(first,a_scriptstatus)
- local current = numbertocategory[a]
+ local current = getscriptstatus(first)
local action = injectors[previous]
if action then
action = action[current]
@@ -458,7 +469,7 @@ local function process(head,first,last)
local font = getfont(first)
if font ~= lastfont then
lastfont = font
- set_parameters(font,numbertodataset[getattr(first,a_scriptinjection)])
+ set_parameters(font,getscriptdata(first))
end
action(head,first)
end
@@ -471,10 +482,8 @@ local function process(head,first,last)
local pid = getid(p)
local nid = getid(n)
if pid == glyph_code and nid == glyph_code then
- local pa = getattr(p,a_scriptstatus)
- local na = getattr(n,a_scriptstatus)
- local pcjk = pa and numbertocategory[pa]
- local ncjk = na and numbertocategory[na]
+ local pcjk = getscriptstatus(p)
+ local ncjk = getscriptstatus(n)
if not pcjk or not ncjk
or pcjk == "korean" or ncjk == "korean"
or pcjk == "other" or ncjk == "other"
@@ -711,8 +720,7 @@ local function process(head,first,last)
local upcoming = getnext(first)
local id = getid(first)
if id == glyph_code then
- local a = getattr(first,a_scriptstatus)
- local current = numbertocategory[a]
+ local current = getscriptstatus(first)
local action = injectors[previous]
if action then
action = action[current]
@@ -720,7 +728,7 @@ local function process(head,first,last)
local font = getfont(first)
if font ~= lastfont then
lastfont = font
- set_parameters(font,numbertodataset[getattr(first,a_scriptinjection)])
+ set_parameters(font,getscriptdata(first))
end
action(head,first)
end
@@ -733,10 +741,8 @@ local function process(head,first,last)
local pid = getid(p)
local nid = getid(n)
if pid == glyph_code and nid == glyph_code then
- local pa = getattr(p,a_scriptstatus)
- local na = getattr(n,a_scriptstatus)
- local pcjk = pa and numbertocategory[pa]
- local ncjk = na and numbertocategory[na]
+ local pcjk = getscriptstatus(p)
+ local ncjk = getscriptstatus(n)
if not pcjk or not ncjk
or pcjk == "korean" or ncjk == "korean"
or pcjk == "other" or ncjk == "other"
@@ -940,8 +946,7 @@ local function process(head,first,last)
local upcoming = getnext(first)
local id = getid(first)
if id == glyph_code then
- local a = getattr(first,a_scriptstatus)
- local current = numbertocategory[a]
+ local current = getscriptstatus(first)
local action = injectors[previous]
if action then
action = action[current]
@@ -949,7 +954,7 @@ local function process(head,first,last)
local font = getfont(first)
if font ~= lastfont then
lastfont = font
- set_parameters(font,numbertodataset[getattr(first,a_scriptinjection)])
+ set_parameters(font,getscriptdata(first))
end
action(head,first)
end
@@ -965,10 +970,8 @@ local function process(head,first,last)
local pid = getid(p)
local nid = getid(n)
if pid == glyph_code and nid == glyph_code then
- local pa = getattr(p,a_scriptstatus)
- local na = getattr(n,a_scriptstatus)
- local pcjk = pa and numbertocategory[pa]
- local ncjk = na and numbertocategory[na]
+ local pcjk = getscriptstatus(p)
+ local ncjk = getscriptstatus(n)
if not pcjk or not ncjk
or pcjk == "korean" or ncjk == "korean"
or pcjk == "other" or ncjk == "other"
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrp-eth.lua b/Master/texmf-dist/tex/context/base/mkiv/scrp-eth.lua
index f6a994b884b..f20d4b9f50b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrp-eth.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrp-eth.lua
@@ -18,10 +18,10 @@ local getattr = nuts.getattr
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
-local a_scriptstatus = attributes.private('scriptstatus')
+local getscriptstatus = scripts.getstatus
-local numbertocategory = scripts.numbertocategory
local inserters = scripts.inserters
+local colors = scripts.colors
-- syllable [zerowidthspace] syllable
-- syllable [zerowidthspace] word
@@ -33,7 +33,6 @@ local inserters = scripts.inserters
-- sentence [space] word
-- sentence [space] sentence
-
local injectors = { -- [previous] [current]
ethiopic_syllable = {
ethiopic_syllable = inserters.zerowidthspace_before,
@@ -52,6 +51,10 @@ local injectors = { -- [previous] [current]
},
}
+colors.ethiopic_syllable = "trace:1"
+colors.ethiopic_word = "trace:2"
+colors.ethiopic_sentence = "trace:3"
+
local function process(head,first,last)
if first ~= last then
local injector = false
@@ -59,8 +62,7 @@ local function process(head,first,last)
while current do
local char, id = ischar(current)
if char then
- local scriptstatus = getattr(current,a_scriptstatus)
- local category = numbertocategory[scriptstatus]
+ local category = getscriptstatus(current)
if injector then
local action = injector[category]
if action then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.lua
index 3d3aa44066e..ab6fca4dbef 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.lua
@@ -10,6 +10,9 @@ if not modules then modules = { } end modules ['scrp-ini'] = {
-- is finished.
local tonumber, next = tonumber, next
+local setmetatableindex = table.setmetatableindex
+local utfbyte, utfsplit = utf.byte, utf.split
+local gmatch = string.gmatch
local trace_analyzing = false trackers.register("scripts.analyzing", function(v) trace_analyzing = v end)
local trace_injections = false trackers.register("scripts.injections", function(v) trace_injections = v end)
@@ -19,17 +22,12 @@ local trace_splitdetails = false trackers.register("scripts.splitting.details",
local report_preprocessing = logs.reporter("scripts","preprocessing")
local report_splitting = logs.reporter("scripts","splitting")
-local utfbyte, utfsplit = utf.byte, utf.split
-local gmatch = string.gmatch
local attributes = attributes
local nodes = nodes
local context = context
-local texsetattribute = tex.setattribute
-
local nodecodes = nodes.nodecodes
-local unsetvalue = attributes.unsetvalue
local implement = interfaces.implement
@@ -39,14 +37,11 @@ local glue_code = nodecodes.glue
local emwidths = fonts.hashes.emwidths
local exheights = fonts.hashes.exheights
-local a_scriptinjection = attributes.private('scriptinjection')
-local a_scriptsplitting = attributes.private('scriptsplitting')
-local a_scriptstatus = attributes.private('scriptstatus')
+local a_script = attributes.private('script')
local fontdata = fonts.hashes.identifiers
local allocate = utilities.storage.allocate
local setnodecolor = nodes.tracers.colors.set
-local setmetatableindex = table.setmetatableindex
local enableaction = nodes.tasks.enableaction
local disableaction = nodes.tasks.disableaction
@@ -58,9 +53,7 @@ local getchar = nuts.getchar
local getfont = nuts.getfont
local getid = nuts.getid
local getglyphdata = nuts.getglyphdata
-
-local getattr = nuts.getattr
-local setattr = nuts.setattr
+local setglyphdata = nuts.setglyphdata
local isglyph = nuts.isglyph
@@ -69,8 +62,6 @@ local insert_node_before = nuts.insert_before
local first_glyph = nuts.first_glyph
------ traverse_id = nuts.traverse_id
------ traverse_char = nuts.traverse_char
local nextglyph = nuts.traversers.glyph
local nextchar = nuts.traversers.char
@@ -95,6 +86,36 @@ scripts.injectors = handlers
local splitters = allocate()
scripts.splitters = splitters
+-- we need to fake it in luatex
+
+local getscript = node.direct.getscript
+local texsetglyphscript = tex.setglyphscript
+
+if not getscript then
+
+ local getattr = nuts.getattr
+ local texsetattribute = tex.setattribute
+ local unsetvalue = attributes.unsetvalue
+
+ getscript = function(n)
+ local a = getattr(n,a_script)
+ if a and a ~= unsetvalue and a > 0 then
+ return a
+ end
+ end
+
+ texsetglyphscript = function(a)
+ if not a or a == 0 then
+ a = unsetvalue
+ end
+ texsetattribute(a_script,a)
+ end
+
+ nuts.getscript = getscript
+ tex .setglyphscript = texsetglyphscript
+
+end
+
local hash = { -- we could put these presets in char-def.lua
--
-- half width opening parenthesis
@@ -200,10 +221,12 @@ local hash = { -- we could put these presets in char-def.lua
[0x30A5] = "non_starter", [0x30A7] = "non_starter", [0x30A9] = "non_starter", [0x30C3] = "non_starter", [0x30E3] = "non_starter",
[0x30E5] = "non_starter", [0x30E7] = "non_starter", [0x30EE] = "non_starter", [0x30F5] = "non_starter", [0x30F6] = "non_starter",
[0x30FC] = "non_starter", [0x30FD] = "non_starter", [0x30FE] = "non_starter", [0x31F0] = "non_starter", [0x31F1] = "non_starter",
- [0x30F2] = "non_starter", [0x30F3] = "non_starter", [0x30F4] = "non_starter", [0x31F5] = "non_starter", [0x31F6] = "non_starter",
- [0x30F7] = "non_starter", [0x30F8] = "non_starter", [0x30F9] = "non_starter", [0x31FA] = "non_starter", [0x31FB] = "non_starter",
- [0x30FC] = "non_starter", [0x30FD] = "non_starter", [0x30FE] = "non_starter", [0x31FF] = "non_starter",
+ [0x31F2] = "non_starter", [0x31F3] = "non_starter", [0x31F4] = "non_starter", [0x31F5] = "non_starter", [0x31F6] = "non_starter",
+ [0x31F7] = "non_starter", [0x31F8] = "non_starter", [0x31F9] = "non_starter", [0x31FA] = "non_starter", [0x31FB] = "non_starter",
+ [0x31FC] = "non_starter", [0x31FD] = "non_starter", [0x31FE] = "non_starter", [0x31FF] = "non_starter",
--
+ [0x301C] = "non_starter", [0x303B] = "non_starter", [0x303C] = "non_starter", [0x309B] = "non_starter", [0x30FB] = "non_starter",
+ [0x30FE] = "non_starter",
-- hyphenation
--
[0x2026] = "hyphen", -- … ellipsis
@@ -270,6 +293,8 @@ local defaults = {
scripts.defaults = defaults -- so we can add more
+-- todo: copy more efficient than metatable
+
function scripts.installmethod(handler)
local name = handler.name
handlers[name] = handler
@@ -283,20 +308,18 @@ function scripts.installmethod(handler)
for k, v in next, datasets do
setmetatableindex(v,defaults)
end
- setmetatable(attributes, {
- __index = function(t,k)
- local v = datasets[k] or datasets.default
- local a = unsetvalue
- if v then
- v.name = name -- for tracing
- a = #numbertodataset + 1
- numbertodataset[a] = v
- numbertohandler[a] = handler
- end
- t[k] = a
- return a
+ setmetatableindex(attributes, function(t,k)
+ local v = datasets[k] or datasets.default
+ local a = 0
+ if v then
+ v.name = name -- for tracing
+ a = #numbertodataset + 1
+ numbertodataset[a] = v
+ numbertohandler[a] = handler
end
- } )
+ t[k] = a
+ return a
+ end)
handler.attributes = attributes
end
@@ -346,96 +369,124 @@ end
local injectorenabled = false
local splitterenabled = false
+local function getscriptdata(n)
+ local s = getscript(n)
+ if s then
+ return s and numbertodataset[s]
+ end
+end
+
+local function getinjector(n)
+ local s = getscript(n)
+ if s then
+ s = numbertohandler[s]
+ return s and s.injector
+ end
+end
+
+local function getsplitter(n)
+ local s = getscript(n)
+ if s then
+ s = numbertodataset[s]
+ return s and s.splitter
+ end
+end
+
+scripts.getdata = getscriptdata
+scripts.getinjector = getinjector
+scripts.getsplitter = getsplitter
+
function scripts.set(name,method,preset)
local handler = handlers[method]
if handler then
+ local index = handler.attributes[preset]
if handler.injector then
if not injectorenabled then
enableaction("processors","scripts.injectors.handler")
injectorenabled = true
end
- texsetattribute(a_scriptinjection,handler.attributes[preset] or unsetvalue)
end
if handler.splitter then
if not splitterenabled then
enableaction("processors","scripts.splitters.handler")
splitterenabled = true
end
- texsetattribute(a_scriptsplitting,handler.attributes[preset] or unsetvalue)
end
if handler.initializer then
handler.initializer(handler)
handler.initializer = nil
end
+ texsetglyphscript(index)
else
- texsetattribute(a_scriptinjection,unsetvalue)
- texsetattribute(a_scriptsplitting,unsetvalue)
+ texsetglyphscript()
end
end
function scripts.reset()
- texsetattribute(a_scriptinjection,unsetvalue)
- texsetattribute(a_scriptsplitting,unsetvalue)
+ texsetglyphscript()
end
--- the following tables will become a proper installer (move to cjk/eth)
---
-- 0=gray 1=red 2=green 3=blue 4=yellow 5=magenta 6=cyan 7=x-yellow 8=x-magenta 9=x-cyan
-local scriptcolors = allocate { -- todo: just named colors
- korean = "trace:0",
- chinese = "trace:0",
- katakana = "trace:0",
- hiragana = "trace:0",
- full_width_open = "trace:1",
- full_width_close = "trace:2",
- half_width_open = "trace:3",
- half_width_close = "trace:4",
- full_width_punct = "trace:5",
- hyphen = "trace:5",
- non_starter = "trace:6",
- jamo_initial = "trace:7",
- jamo_medial = "trace:8",
- jamo_final = "trace:9",
- ethiopic_syllable = "trace:1",
- ethiopic_word = "trace:2",
- ethiopic_sentence = "trace:3",
- breaking_tsheg = "trace:1",
- nonbreaking_tsheg = "trace:2",
+-- local categories = allocate { -- rather bound to cjk ... will be generalized
+-- "korean",
+-- "chinese",
+-- "katakana",
+-- "hiragana",
+-- "full_width_open",
+-- "full_width_close",
+-- "half_width_open",
+-- "half_width_close",
+-- "full_width_punct",
+-- "hyphen",
+-- "non_starter",
+-- "jamo_initial",
+-- "jamo_medial",
+-- "jamo_final",
+-- "ethiopic_syllable",
+-- "ethiopic_word",
+-- "ethiopic_sentence",
+-- "breaking_tsheg",
+-- "nonbreaking_tsheg",
+-- }
+--
+-- scripts.categories = categories
+
+local scriptcolors = allocate {
+ -- todo: just named colors
+ hyphen = "trace:5",
}
scripts.colors = scriptcolors
-local numbertocategory = allocate { -- rather bound to cjk ... will be generalized
- "korean",
- "chinese",
- "katakana",
- "hiragana",
- "full_width_open",
- "full_width_close",
- "half_width_open",
- "half_width_close",
- "full_width_punct",
- "hyphen",
- "non_starter",
- "jamo_initial",
- "jamo_medial",
- "jamo_final",
- "ethiopic_syllable",
- "ethiopic_word",
- "ethiopic_sentence",
- "breaking_tsheg",
- "nonbreaking_tsheg",
-}
+-- this can become setprop ...
-local categorytonumber = allocate(table.swapped(numbertocategory)) -- could be one table
+local propertydata = nodes.properties.data
-scripts.categorytonumber = categorytonumber
-scripts.numbertocategory = numbertocategory
+local function setscriptstatus(n,s)
+ local p = propertydata[n]
+ if p then
+ p.scriptstatus = s
+ else
+ propertydata[n] = { scriptstatus = s }
+ end
+end
+
+function getscriptstatus(n)
+ local p = propertydata[n]
+ if p then
+ return p.scriptstatus
+ end
+end
+
+scripts.setstatus = setscriptstatus
+scripts.getstatus = getscriptstatus
+
+--
local function colorize(start,stop)
for n in nextglyph, start do
- local kind = numbertocategory[getattr(n,a_scriptstatus)]
+ local kind = getscriptstatus(n)
if kind then
local ac = scriptcolors[kind]
if ac then
@@ -459,13 +510,6 @@ local function traced_process(head,first,last,process,a)
end
end
--- eventually we might end up with more extensive parsing
--- todo: pass t[start..stop] == original
---
--- one of the time consuming functions:
-
--- we can have a fonts.hashes.originals
-
function scripts.injectors.handler(head)
local start = first_glyph(head) -- we already have glyphs here (subtype 1)
if not start then
@@ -476,7 +520,8 @@ function scripts.injectors.handler(head)
while start do
local char, id = isglyph(start)
if char then
- local a = getattr(start,a_scriptinjection)
+ -- local a = getinjector(start)
+ local a = getscript(start)
if a then
if a ~= last_a then
if first then
@@ -494,8 +539,8 @@ function scripts.injectors.handler(head)
first, last = nil, nil
end
last_a = a
- local handler = numbertohandler[a]
- normal_process = handler.injector
+ -- normal_process = a
+ normal_process = getinjector(start)
end
if normal_process then
-- id == font
@@ -513,7 +558,7 @@ function scripts.injectors.handler(head)
end
local h = hash[char]
if h then
- setattr(start,a_scriptstatus,categorytonumber[h])
+ setscriptstatus(start,h)
if not first then
first, last = start, start
else
@@ -750,13 +795,13 @@ function splitters.handler(head) -- todo: also first_glyph test
local current = head
while current do
if getid(current) == glyph_code then
- local a = getattr(current,a_scriptsplitting)
+ local a = getsplitter(current)
if a then
if a ~= attr then
local handler = numbertohandler[a]
tree = handler.tree or { }
attr = a
- proc = handler.splitter
+ proc = a
end
if proc then
local root = tree[getchar(current)]
@@ -813,10 +858,10 @@ end
local last_a, last_f, last_s, last_q
function splitters.insertafter(handler,head,first,last,detail)
- local a = getattr(first,a_scriptsplitting)
+ local a = getscriptdata(first)
local f = getfont(first)
- if a ~= last_a or f ~= last_f then
- last_s = emwidths[f] * numbertodataset[a].inter_word_stretch_factor
+ if a and a ~= last_a or f ~= last_f then
+ last_s = emwidths[f] * data.inter_word_stretch_factor
last_a = a
last_f = f
end
@@ -892,7 +937,7 @@ setmetatableindex(cache_nop,function(t,k) local v = { } t[k] = v return v end)
function autofontfeature.handler(head)
for n, char, font in nextchar, head do
- -- if getattr(n,a_scriptinjection) then
+ -- if getscript(n) then
-- -- already tagged by script feature, maybe some day adapt
-- else
local script = otfscripts[char]
@@ -923,7 +968,7 @@ function autofontfeature.handler(head)
end
end
if attr ~= 0 then
- setattr(n,0,attr)
+ setglyphdata(n,attr)
-- maybe set scriptinjection when associated
end
end
@@ -965,7 +1010,6 @@ implement {
-- some common helpers
-
do
local parameters = fonts.hashes.parameters
@@ -977,7 +1021,8 @@ do
local inter_character_shrink_factor = 1
local function space_glue(current)
- local data = numbertodataset[getattr(current,a_scriptinjection)]
+ -- local data = numbertodataset[getattr(current,a_scriptinjection)]
+ local data = getscriptdata(current)
if data then
inter_character_space_factor = data.inter_character_space_factor or 1
inter_character_stretch_factor = data.inter_character_stretch_factor or 1
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.mkiv
index f2d1da62741..4eb3f29e373 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrp-ini.mkiv
@@ -11,7 +11,30 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% here we collect code from other places (was organized differently)
+%D The script handler has been upgraded mid June 2020 so there might be issues as I
+%D didn't test everything (yet). It should all be a bit more efficient now in
+%D \LUAMETATEX, although not spectacular. We use no attributes in \LUAMETATEX\ and
+%D only one in \LUATEX\ now.
+%D
+%D A glyph can have (an dget) all kind of properties. Except from the state, these
+%D are assigned within \TEX's grouping model!
+%D
+%D \startitemize
+%D \startitem font \stopitem
+%D \startitem character \stopitem
+%D \startitem language (4 properties packed in an unsigned integer) \stopitem
+%D \startitem data (used for dynamics) \stopitem
+%D \startitem script (used for special script processing) \stopitem
+%D \startitem state (used for analyzing, related to font features) \stopitem
+%D \stopitemize
+%D
+%D Additional properties are set via node list handlers. The state is stored in the
+%D glyph, but additional properties are stored in a node's property table. In the
+%D future the state might get used for something else, in which case we will stire
+%D the state in the property table too. On the other hand, we can now (if we want)
+%D influence the state at the\TEX\ end (not that we do that yet).
+
+%D Todo: as in bidi mode we need a way to globally keep the setting.
\registerctxluafile{scrp-ini}{}
\registerctxluafile{scrp-cjk}{}
@@ -19,13 +42,10 @@
\registerctxluafile{scrp-tha}{}
\registerctxluafile{scrp-tib}{}
-\definesystemattribute[scriptinjection][public,pickup]
-\definesystemattribute[scriptsplitting][public,pickup]
-\definesystemattribute[scriptstatus] [public,pickup]
+\definesystemattribute[script][public,pickup]
-%D Since scripts need specific \LUA\ code we use hard coded attribute
-%D values, but we might have more tricks at some time, so we use a
-%D proper define macro too.
+%D Since scripts need specific \LUA\ code we use hard coded attribute values, but we
+%D might have more tricks at some time, so we use a proper define macro too.
\unprotect
@@ -37,23 +57,17 @@
% presets are global and are currently defined in lua
-\appendtoks
- \setuevalue\currentscript{\setscript[\currentscript]}%
-\to \everydefinescript
+% \appendtoks
+% \setuevalue\currentscript{\setscript[\currentscript]}%
+% \to \everydefinescript
\unexpanded\def\scripts_basics_set
{\clf_setscript{\currentscript}{\scriptparameter\c!method}{\scriptparameter\c!preset}}
-% \unexpanded\def\setscript[#1]%
-% {\edef\currentscript{#1}%
-% \scripts_basics_set}
-
\unexpanded\def\setglobalscript[#1]%
{\edef\currentscript{#1}%
\scripts_basics_set
- \pickupscriptinjectionattribute
- \pickupscriptsplittingattribute
- \pickupscriptstatusattribute}
+ \pickupscriptattribute}
\unexpanded\def\setlocalscript[#1]%
{\edef\currentscript{#1}%
@@ -80,7 +94,7 @@
% \def\scripts_basics_set_splitter_list[#1][#2]%
% {\ctxcommand{setscriptsplitterlist("#1","#2")}
-% \setscript[hangul] \hangul \startscript[hangul]
+% \setscript[hangul] \startscript[hangul]
\definescript [hangul] [\c!method=hangul]
\definescript [hanzi] [\c!method=hanzi]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrp-tib.lua b/Master/texmf-dist/tex/context/base/mkiv/scrp-tib.lua
index b67f6964800..b1d50a469a4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/scrp-tib.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/scrp-tib.lua
@@ -12,25 +12,17 @@ local getnext = nuts.getnext
local getattr = nuts.getattr
local ischar = nuts.ischar
-local a_scriptstatus = attributes.private('scriptstatus')
+local getscriptstatus = scripts.getstatus
-local numbertocategory = scripts.numbertocategory
local inserters = scripts.inserters
+local colors = scripts.colors
local injectors = {
- breaking_tsheg = inserters.space_after,
+ breaking_tsheg = inserters.space_after
}
--- more efficient is to check directly
---
--- local b_tsheg = 0x0F0B -- breaking
--- local n_tsheg = 0x0F0C -- nonbreaking
---
--- if char == b_tsheg then
--- head, current = insert_space_after(head,current)
--- end
---
--- but this is more general
+colors.breaking_tsheg = "trace:1"
+colors.nonbreaking_tsheg = "trace:2"
local function process(head,first,last)
if first ~= last then
@@ -38,14 +30,11 @@ local function process(head,first,last)
while current do
local char, id = ischar(current)
if char then
- local scriptstatus = getattr(current,a_scriptstatus)
- if scriptstatus and scriptstatus > 0 then
- local category = numbertocategory[scriptstatus]
- if category then
- local injector = injectors[category]
- if injector then
- head, current = injector(head,current)
- end
+ local category = getscriptstatus(current)
+ if category then
+ local injector = injectors[category]
+ if injector then
+ head, current = injector(head,current)
end
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/sort-lan.lua b/Master/texmf-dist/tex/context/base/mkiv/sort-lan.lua
index b277989664b..35116f1f648 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/sort-lan.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/sort-lan.lua
@@ -11,10 +11,9 @@ if not modules then modules = { } end modules ['sort-lan'] = {
-- to finish in winter.
-- todo: U+1E9E (german SS)
--- Many vectors were supplied by Wolfgang Schuster and Philipp
--- Gesang. However this is a quite adapted and reformatted variant
--- so it needs some checking. Other users provides tables and
--- corrections as well.
+-- Many vectors were supplied by Wolfgang Schuster and Philipp Gesang. However this is
+-- a quite adapted and reformatted variant so it needs some checking. Other users
+-- provides tables and corrections as well.
local utfchar, utfbyte = utf.char, utf.byte
local sorters = sorters
@@ -973,3 +972,42 @@ definitions["jp"] = {
"ら", "り", "る", "れ", "ろ", "わ", "ゐ", "ゑ", "を", "ん",
}
}
+
+-- Hebrew and Jiddish (Marc Trius)
+
+definitions['he'] = {
+ entries = {
+ ['א'] = 'א', ['ב'] = 'ב', ['ג'] = 'ג', ['ד'] = 'ד', ['ה'] = 'ה',
+ ['ו'] = 'ו', ['ז'] = 'ז', ['ח'] = 'ח', ['ט'] = 'ט', ['י'] = 'י',
+ ['כ'] = 'כ', ['ל'] = 'ל', ['מ'] = 'מ', ['נ'] = 'נ', ['ס'] = 'ס',
+ ['ע'] = 'ע', ['פ'] = 'פ', ['צ'] = 'צ', ['ק'] = 'ק', ['ר'] = 'ר',
+ ['ש'] = 'ש', ['ת'] = 'ת',
+ },
+ orders = {
+ "א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "כ",
+ "ל", "מ", "נ", "ס", "ע", "פ", "צ", "ק", "ר", "ש", "ת",
+ }
+}
+
+definitions["yi"] = {
+ parent = "he",
+ entries = {
+ ['א'] = 'א', ['ב'] = 'ב', ['בֿ'] = 'בֿ', ['ג'] = 'ג', ['ד'] = 'ד',
+ ['ה'] = 'ה', ['ו'] = 'ו', ['ז'] = 'ז', ['ח'] = 'ח', ['ט'] = 'ט',
+ ['י'] = 'י', ['כּ'] = 'כּ', ['כ'] = 'כ', ['ל'] = 'ל', ['מ'] = 'מ',
+ ['נ'] = 'נ', ['ס'] = 'ס', ['ע'] = 'ע', ['פ'] = 'פ', ['פֿ'] = 'פֿ',
+ ['צ'] = 'צ', ['ק'] = 'ק', ['ר'] = 'ר', ['ש'] = 'ש', ['שׂ'] = 'שׂ',
+ ['תּ'] = 'תּ', ['ת'] = 'ת',
+ },
+ orders = {
+ "א", "ב", "בֿ", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "כּ", "כ", "ל",
+ "מ", "נ", "ס", "ע", "פּ", "פֿ", "צ", "ק", "ר", "ש", "שׂ", "תּ", "ת",
+ },
+ replacements = {
+ { "אַ", "א" }, { "אָ", "א" }, { "בּ", "ב" }, { "בֿ", "בֿ" }, { "וּ", "ו" },
+ { "װ", "וו" }, { "ױ", "וי" }, { "יִ", "י" }, { "ײ", "יי" }, { "ײַ", "יי" },
+ { "כּ", "כּ" }, { "ך", "כ" }, { "ם", "מ" }, { "ן", "נ" }, { "פּ", "פּ" },
+ { "פ", "פּ" }, { "פֿ", "פֿ" }, { "ף", "פֿ" }, { "ץ", "צ" }, { "שׁ", "ש" },
+ { "שׂ", "שׂ" }, { "תּ", "תּ" },
+ },
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-ali.lua b/Master/texmf-dist/tex/context/base/mkiv/spac-ali.lua
index c30a4fa942d..2e2650f3b7a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-ali.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-ali.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['spac-ali'] = {
version = 1.001,
+ optimize = true,
comment = "companion to spac-ali.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -111,7 +112,7 @@ local function handler(head,leftpage,realpageno) -- traverse_list
local head = setlink(new_stretch(3),list) -- prepend
setlist(current,hpack_nodes(head,getwidth(current),"exactly",direction))
if trace_realign then
- report_realign("flushing right. align %a, page %a, realpage %a",align,pageno,realpageno)
+ report_realign("flushing right, align %a, page %a, realpage %a",align,pageno,realpageno)
end
elseif trace_realign then
report_realign("invalid flushing, align %a, page %a, realpage %a",align,pageno,realpageno)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-ali.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-ali.mkiv
index 8451e2494f9..2467f83525b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-ali.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-ali.mkiv
@@ -33,11 +33,11 @@
\definesystemattribute[alignstate][public] % will make a single attributes for several states
\appendtoks
- \attribute\realignattribute \attributeunsetvalue
- \attribute\alignstateattribute\attributeunsetvalue
+ \c_attr_realign \attributeunsetvalue
+ \c_attr_alignstate\attributeunsetvalue
\to \everyforgetall
-\unexpanded\def\resetrealignsignal{\attribute\realignattribute\attributeunsetvalue}
+\unexpanded\def\resetrealignsignal{\c_attr_realign\attributeunsetvalue}
\unexpanded\def\signalinnerrealign{\clf_setrealign\plustwo}
\unexpanded\def\signalouterrealign{\clf_setrealign\plusone}
@@ -293,7 +293,7 @@
\unexpanded\def\spac_align_set_horizontal_none % should also relax \updateraggedskips
{\raggedstatus\zerocount
- \attribute\alignstateattribute\attributeunsetvalue
+ \c_attr_alignstate\attributeunsetvalue
\leftskip \plusone\leftskip
\rightskip \plusone\rightskip
\spaceskip \zeropoint
@@ -305,7 +305,7 @@
\unexpanded\def\spac_align_set_horizontal_left
{\setraggedness\spac_align_set_raggedness_left
\raggedstatus\plusone
- \attribute\alignstateattribute\plusone
+ \c_attr_alignstate\plusone
\leftskip \plusone\leftskip \s!plus\spac_align_set_raggedness_left
\rightskip \plusone\rightskip\s!plus\zeropoint
\spaceskip \v_spac_align_space_amount
@@ -317,7 +317,7 @@
\unexpanded\def\spac_align_set_horizontal_center
{\setraggedness\spac_align_set_raggedness_middle
\raggedstatus\plustwo
- \attribute\alignstateattribute\plustwo
+ \c_attr_alignstate\plustwo
\leftskip \plusone\leftskip \s!plus\spac_align_set_raggedness_middle
\rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_middle
\spaceskip \v_spac_align_space_amount
@@ -329,7 +329,7 @@
\unexpanded\def\spac_align_set_horizontal_right
{\setraggedness\spac_align_set_raggedness_right
\raggedstatus\plusthree
- \attribute\alignstateattribute\plusthree
+ \c_attr_alignstate\plusthree
\leftskip \plusone\leftskip \s!plus\zeropoint
\rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_right
\spaceskip \v_spac_align_space_amount
@@ -340,7 +340,7 @@
\unexpanded\def\spac_align_set_horizontal_very_left
{\raggedstatus\plusone
- \attribute\alignstateattribute\plusone
+ \c_attr_alignstate\plusone
\leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount
\rightskip \plusone\rightskip\s!plus\zeropoint
\spaceskip \v_spac_align_space_amount
@@ -351,7 +351,7 @@
\unexpanded\def\spac_align_set_horizontal_very_center
{\raggedstatus\plustwo
- \attribute\alignstateattribute\plustwo
+ \c_attr_alignstate\plustwo
\leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount
\rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount
\spaceskip \v_spac_align_space_amount
@@ -362,7 +362,7 @@
\unexpanded\def\spac_align_set_horizontal_very_right
{\raggedstatus\plusthree
- \attribute\alignstateattribute\plusthree
+ \c_attr_alignstate\plusthree
\leftskip \plusone\leftskip \s!plus\zeropoint
\rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount
\spaceskip \v_spac_align_space_amount
@@ -374,7 +374,7 @@
\unexpanded\def\spac_align_set_horizontal_wide_center
{\setraggedness\spac_align_set_raggedness_middle
\raggedstatus\plustwo
- \attribute\alignstateattribute\plustwo
+ \c_attr_alignstate\plustwo
\leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount_half
\rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount_half
\spaceskip \v_spac_align_space_amount
@@ -385,7 +385,7 @@
\unexpanded\def\spac_align_set_horizontal_centered_last_line
{\raggedstatus\zerocount
- \attribute\alignstateattribute\attributeunsetvalue
+ \c_attr_alignstate\attributeunsetvalue
\leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount\relax
\rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount_negative\relax
\spaceskip \zeropoint\relax
@@ -396,7 +396,7 @@
\unexpanded\def\spac_align_set_horizontal_flushedright_last_line
{\raggedstatus\zerocount
- \attribute\alignstateattribute\attributeunsetvalue
+ \c_attr_alignstate\attributeunsetvalue
\leftskip \plusone\leftskip \s!plus\v_spac_align_fill_amount\relax
\rightskip \plusone\rightskip\s!plus\v_spac_align_fill_amount_negative\relax
\spaceskip \zeropoint\relax
@@ -410,7 +410,7 @@
\unexpanded\def\spac_align_set_horizontal_right_tt % a plain command
{\tttf % brrr
\raggedstatus\plusthree
- \attribute\alignstateattribute\plusthree
+ \c_attr_alignstate\plusthree
\leftskip \plusone\leftskip \s!plus\zeropoint\relax
\rightskip \plusone\rightskip\s!plus\spac_align_set_raggedness_right\relax
\spaceskip \zeropoint\relax
@@ -797,7 +797,7 @@
\unexpanded\def\ibox
{\vbox\bgroup
\forgetall
- \let\\=\endgraf
+ \let\\\endgraf
\ifdoublesided\signalinnerrealign\fi
\doifelserightpage\spac_align_set_horizontal_right\spac_align_set_horizontal_left
\let\next}
@@ -805,9 +805,9 @@
\unexpanded\def\obox
{\vbox\bgroup
\forgetall
- \let\\=\endgraf
+ \let\\\endgraf
\ifdoublesided\signalouterrealign\fi
- \doifelserightpage\c_spac_align_state_horizontal_left\spac_align_set_horizontal_right
+ \doifelserightpage\spac_align_set_horizontal_left\spac_align_set_horizontal_right
\let\next}
\let\raggedbox\relax
@@ -882,7 +882,7 @@
\xspaceskip #5\relax
\parfillskip \zeropoint\s!plus#6\relax
\parindent #7\relax
- \attribute\alignstateattribute\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi}
+ \c_attr_alignstate\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi}
% older (context) names:
@@ -956,7 +956,7 @@
\dontleavehmode % added in marrakesch at TUG 2006\begingroup
\begingroup
\setlocalhsize % new
- \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}%
+ \protected\def\\{\egroup\par\doalignline{#1}{#2}\bgroup}%
\dowithnextbox
{\hbox to \localhsize
{\ifcase\alignstrutmode\or\strut\fi
@@ -1036,7 +1036,7 @@
\dontleavehmode % added in marrakesch at TUG 2006\begingroup
\begingroup
\setlocalhsize
- \def\\{\egroup\par\doxalignline#1#2#3#4#5#6\bgroup}% inefficient
+ \protected\def\\{\egroup\par\doxalignline#1#2#3#4#5#6\bgroup}% inefficient
\dowithnextbox
{\hbox to \localhsize
{#1\hskip\ifdone#2\else#3\fi#4%
@@ -1230,10 +1230,6 @@
\setvalue{\??reverse\v!normal }{\ifconditional\inlinelefttoright\else\s!reverse\fi}
\setvalue{\??reverse\v!reverse}{\ifconditional\inlinelefttoright \s!reverse\fi}
-\ifcase\contextlmtxmode
- \let\usedirectionparameterreverse\gobbleoneargument
-\else
- \def\usedirectionparameterreverse#1{\begincsname\??reverse#1\c!direction\endcsname}
-\fi
+\let\usedirectionparameterreverse\gobbleoneargument
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-chr.lua b/Master/texmf-dist/tex/context/base/mkiv/spac-chr.lua
index 9b8453ca690..fa6eb18a576 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-chr.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-chr.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['spac-chr'] = {
version = 1.001,
+ optimize = true,
comment = "companion to spac-chr.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -32,12 +33,11 @@ local getnext = nuts.getnext
local getprev = nuts.getprev
local getattr = nuts.getattr
local setattr = nuts.setattr
-local getlang = nuts.getlang
+local getlanguage = nuts.getlanguage
local setchar = nuts.setchar
local setattrlist = nuts.setattrlist
local getfont = nuts.getfont
local setsubtype = nuts.setsubtype
-local setdisc = nuts.setdisc
local isglyph = nuts.isglyph
local setcolor = nodes.tracers.colors.set
@@ -57,7 +57,6 @@ local new_penalty = nodepool.penalty
local new_glue = nodepool.glue
local new_kern = nodepool.kern
local new_rule = nodepool.rule
-local new_disc = nodepool.disc
local nodecodes = nodes.nodecodes
local gluecodes = nodes.gluecodes
@@ -82,7 +81,7 @@ local fontquads = fonthashes.quads
local setmetatableindex = table.setmetatableindex
-local a_character = attributes.private("characters")
+local a_character = attributes.private("characters") -- this will become a property (or maybe even a field)
local a_alignstate = attributes.private("alignstate")
local c_zero = byte('0')
@@ -130,7 +129,8 @@ end
local function nbsp(head,current)
local para = fontparameters[getfont(current)]
- if getattr(current,a_alignstate) == 1 then -- flushright
+ local attr = getattr(current,a_alignstate) or 0
+ if attr >= 1 or attr <= 3 then -- flushright
head, current = inject_nobreak_space(0x00A0,head,current,para.space,0,0)
else
head, current = inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink)
@@ -295,30 +295,6 @@ local methods = {
characters.methods = methods
--- function characters.handler(head) -- todo: use traverse_id
--- local current = head
--- while current do
--- local char, id = isglyph(current)
--- if char then
--- local next = getnext(current)
--- local method = methods[char]
--- if method then
--- if trace_characters then
--- report_characters("replacing character %C, description %a",char,lower(chardata[char].description))
--- end
--- local h = method(head,current)
--- if h then
--- head = remove_node(h,current,true)
--- end
--- end
--- current = next
--- else
--- current = getnext(current)
--- end
--- end
--- return head
--- end
-
-- this also works ok in math as we run over glyphs and these stay glyphs ... not sure
-- about scripts and such but that is not important anyway ... some day we can consider
-- special definitions in math
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-chr.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-chr.mkiv
index 23f4ac8dd64..9113dc6a110 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-chr.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-chr.mkiv
@@ -29,7 +29,7 @@
%D them in a string. So this needs thinking. Not that we can compare the
%D nobreakspace now anyway.
-% \unexpanded\def\specialspacecharacter#1{\begingroup\attribute\charactersattribute#1\ \endgroup}
+% \unexpanded\def\specialspacecharacter#1{\begingroup\c_attr_characters#1\ \endgroup}
%
% \unexpanded\edef\nobreakspace {\specialspacecharacter{"00A0}} % 1 = left
% \unexpanded\edef\ideographicspace {\specialspacecharacter{"2000}}
@@ -54,6 +54,8 @@
% Making them active is also not an option unless we do that in every
% catcode vector.
+\pushoverloadmode
+
% \nobreakspace {\begingroup\setalignstateattribute\normalUchar"00A0\endgroup} % 1 = left
\edef\nobreakspace {\normalUchar"00A0} % space
\edef\softhyphen {\normalUchar"00AD} % softhyohen
@@ -63,6 +65,9 @@
\let\ideographicspace \enquad
\let\ideographichalffillspace \emquad
+\unletfrozen\hairspace
+\unletfrozen\sixperemspace
+
\edef\twoperemspace {\normalUchar"2002} % quad/2
% % "2003 % quad == \quad == \hskip\emwidth
\edef\threeperemspace {\normalUchar"2004} % quad/3
@@ -88,6 +93,8 @@
\let\zwj \zerowidthjoiner
\let\nbsp \nobreakspace
+\popoverloadmode
+
\chardef\optionalspace"1F % will be space unless before punctuation
% Shortcuts:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-flr.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-flr.mkiv
index 4c3c0c0421f..a64171247e3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-flr.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-flr.mkiv
@@ -168,6 +168,23 @@
[\c!alternative=\v!space,
\c!distance=3\emwidth]
+% bonus:
+
+\definefiller
+ [dotfill]
+ [\c!symbol=\textperiod,
+ \c!style=\v!normal,
+ \c!method=\v!middle,
+ \c!width=.5\emwidth,
+ \c!leftmargin=.2\emwidth,
+ \c!rightmargin=.2\emwidth]
+
+\let\mathdotfill\dotfill
+
+\unexpanded\def\textdotfill{\filler[dotfill]}
+
+\unexpanded\def\dotfill{\mathortext\mathdotfill\textdotfill}
+
% maybe box -> symbol
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-grd.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-grd.mkiv
index 72d017836f6..482d0cf2ef6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-grd.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-grd.mkiv
@@ -300,6 +300,14 @@
\normalstartbaselinecorrection
\fi}
+%D Different in LMTX, maybe here we can use this in \MKIV:
+%D
+%D \let\checkprevdepth\forcestrutdepth % mlv only
+%D
+%D as we have sync issues that makes it not work otherwise.
+
+\let\checkprevdepth\baselinecorrection
+
% This is new (and experimental) and might replace some of the above. beware it doesn't always work
% out well, e.g. when used grouped and such (e.g. before display math doesn't work out well).
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv
index 0f65eea3310..16a1a0d4e9a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv
@@ -210,12 +210,12 @@
%D Here come the handlers (still rather messy ... we need states).
-\newif\ifindentation \indentationtrue % will become a mode
+%newif\ifindentation \indentationtrue % will become a mode
\let\checkindentation\relax
\installmacrostack\checkindentation
-\installmacrostack\ifindentation
+%installmacrostack\ifindentation
\def\spac_indentation_remove
{\ifzeropt\parindent \else
@@ -225,20 +225,20 @@
\fi}
\def\spac_indentation_kill_indeed
- {\global\indentationfalse
+ {%\global\indentationfalse
\spac_indentation_remove}
\def\spac_indentation_do_toggle_indeed
- {\global\indentationfalse
+ {%\global\indentationfalse
\glet\checkindentation\spac_indentation_no_toggle_indeed
\spac_indentation_remove}
\def\spac_indentation_no_toggle_indeed
- {\global\indentationtrue
+ {%\global\indentationtrue
\glet\checkindentation\spac_indentation_do_toggle_indeed}
\def\spac_indentation_do_indeed
- {\global\indentationtrue}
+ {}%\global\indentationtrue}
\def\spac_indentation_do_toggle
{\glet\checkindentation\spac_indentation_do_toggle_indeed}
@@ -264,13 +264,13 @@
\def\spac_indentation_variant_no % made global
{\ifinpagebody \else
- \global\indentationfalse
+ %\global\indentationfalse
\glet\checkindentation\spac_indentation_no_next_check
\fi}
\def\nonoindentation % bv bij floats
{\ifinpagebody \else
- \global\indentationtrue
+ %\global\indentationtrue
\glet\checkindentation\spac_indentation_do_indeed
\fi}
@@ -478,11 +478,20 @@
%D from now on we treat it as a normal space and not as a space with \type
%D {sfcode} 1000.
+% \unexpanded\def\specialspaceprimitive
+% {\begingroup
+% % so, no fancy extra spacing after: foo i.e.\ bar
+% \nonfrenchspacing\normalspaceprimitive
+% \endgroup}
+
\unexpanded\def\specialspaceprimitive
- {\begingroup
- % so, no fancy extra spacing after: foo i.e.\ bar
- \nonfrenchspacing\normalspaceprimitive
- \endgroup}
+ {% is a current state, set explicitly or when a character is appended
+ \ifhmode
+ \spacefactor\plusthousand
+ \else
+ \dontleavehmode
+ \fi
+ \normalspaceprimitive}
\unexpanded\def\normalnotobeyedspace
{\mathortext\normalspaceprimitive\specialspaceprimitive} % no \dontleavehmode\space (else no frenchspacing)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-lin.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-lin.mkiv
index d862f6d8109..aaa73d19490 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-lin.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-lin.mkiv
@@ -74,6 +74,42 @@
\let\spac_lines_break \relax
\let\spac_after_first_obeyed_line\relax
+\let\spac_lines_indent \relax
+
+%D See \type {indentation-005.tex}:
+%D
+%D \starttyping
+%D \setuplines[indentlist={0pt,10pt,15pt,20pt}]
+%D
+%D \setupindenting[yes,1em]
+%D \setuplines[indentlist={0pt,*,*}]
+%D
+%D \setuplines[indentlist={0pt,1em,*}]
+%D \starttyping
+
+\newcount\c_spac_lines_indent_cnt
+\newcount\c_spac_lines_indent_max
+\newdimen\d_spac_lines_indent
+
+\def\spac_lines_indent_indeed
+ {\ifnum\c_spac_lines_indent_cnt=\c_spac_lines_indent_max
+ \c_spac_lines_indent_cnt\plusone
+ \else
+ \advance\c_spac_lines_indent_cnt\plusone
+ \fi
+ \getfromcommacommand[\m_spac_lines_indentlist][\c_spac_lines_indent_cnt]%
+ \ifx\commalistelement\wildcardsymbol
+ \hskip\d_spac_lines_indent
+ \else
+ \scratchdimen\dimexpr\commalistelement\relax
+ \hskip\ifdim\scratchdimen=\zeropoint
+ \zeropoint
+ \else
+ \scratchdimen
+ \d_spac_lines_indent\scratchdimen
+ \fi
+ \fi
+ \relax}
\def\spac_lines_start_indeed[#1]% new: optional second argument (WS)
{\iffirstargument
@@ -96,23 +132,38 @@
\typesettinglinestrue
\setupwhitespace[\v!none]% todo use fast variant
%\obeylines % move upwards to keep spaces in the first line due to optional argument
+ %
+ \edef\m_spac_lines_indentlist{\linesparameter\c!indentlist}%
+ \getcommacommandsize[\m_spac_lines_indentlist]%
+ \c_spac_lines_indent_max\commalistsize
+ \c_spac_lines_indent_cnt\zerocount
+ \ifnum\c_spac_lines_indent_max>\plusone
+ \let\spac_lines_indent\spac_lines_indent_indeed
+ \d_spac_lines_indent\d_spac_indentation_par
+ \else
+ \let\spac_lines_indent\relax
+ \fi
+ %
\ignorespaces
\glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_a
- \let\obeyedline\spac_lines_obeyed_line
+ \enforced\let\obeyedline\spac_lines_obeyed_line
\activatespacehandler{\linesparameter\c!space}%
\dostarttagged\t!line\empty
- \GotoPar} % this will become a nice lowercased helper
+ \ignorepars}
+
% we could have states instead and handle option in there
\def\spac_lines_after_first_obeyed_line_a % tzt two pass, like itemize
{\linesparameter\c!command
+ \spac_lines_indent
\linesparameter\c!left
\glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_b}
\def\spac_lines_after_first_obeyed_line_b
{\spac_lines_break
\linesparameter\c!command
+ \spac_lines_indent
\linesparameter\c!left}
\def\spac_lines_obeyed_line
@@ -120,7 +171,7 @@
\dostoptagged % can be a dummy one as we don't look ahead
\par
\dostarttagged\t!line\empty
- \futurelet\next\spac_lines_between}
+ \futurelet\nexttoken\spac_lines_between}
\unexpanded\def\spac_lines_stop
{\dostoptagged
@@ -131,10 +182,10 @@
\egroup}
\def\spac_lines_between
- {\ifx\next\spac_lines_stop
+ {\ifx\nexttoken\spac_lines_stop
\donefalse
\else
- \doifelsemeaning\next\obeyedline % brrr
+ \doifelsemeaning\nexttoken\obeyedline % brrr
{\donefalse\linesparameter\c!inbetween}
{\donetrue\spac_after_first_obeyed_line}%
\fi}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-par.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-par.mkiv
index 7678cc34bdd..752d5c05904 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-par.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-par.mkiv
@@ -15,13 +15,19 @@
\unprotect
-%D The dreadful sequence \type {\bgroup} \unknown\
-%D \type {\carryoverpar} \unknown\ \type {\egroup} is needed
-%D when for instance sidefloats are used in combination with
-%D something that starts with a group. This is because
-%D otherwise the indentation as set (by the output routine)
-%D inside the group are forgotten afterwards. (I must
-%D not forget its existence).
+%D The dreadful sequence \type {\bgroup} \unknown\ \type {\carryoverpar} \unknown\
+%D \type {\egroup} is needed when for instance sidefloats are used in combination
+%D with something that starts with a group. This is because otherwise the
+%D indentation as set (by the output routine) inside the group are forgotten
+%D afterwards. (I must not forget its existence).
+
+% Todo (maybe):
+%
+% \parshape \getparshape\relax
+% \interlinepenalties \getinterlinepenalties\relax
+% \clubpenalties \getclubpenalties\relax
+% \widowpenalties \getwidowpenalties\relax
+% \displaywidowpenalties\getdisplaywidowpenalties\relax
\def\carryoverpar#1% #1 can be \endgroup or \egroup or ... expandable !
{\normalexpanded
@@ -30,7 +36,8 @@
\hangafter \the\hangafter
\parskip \the\parskip
\leftskip \the\leftskip
- \rightskip \the\rightskip}}
+ \rightskip \the\rightskip
+ \relax}}
\unexpanded\def\pushparagraphproperties
{\edef\currentparagraphproperties{\carryoverpar\relax}%
@@ -43,8 +50,27 @@
\unexpanded\def\flushparagraphproperties
{\popmacro\currentparagraphproperties}
-% Beware, changing this will break some code (like pos/backgrounds) but
-% it has been changed anyway so let's see where things go wrong.
+%D New experimental stuff, not supported in \MKIV:
+
+\let\freezeparagraphproperties \relax
+\let\defrostparagraphproperties\relax
+\let\setparagraphfreezing \relax
+\let\forgetparagraphfreezing \relax
+\let\updateparagraphproperties \relax
+\let\updateparagraphpenalties \relax
+\let\updateparagraphdemerits \relax
+\let\updateparagraphshapes \relax
+
+\let\updateparwrapper \relax
+\let\forgetparwrapper \relax
+\let\registerparwrapper\gobblethreearguments
+\let\directparwrapper \gobbletwoarguments
+
+\let\spac_paragraph_wrap \relax
+\let\spac_paragraph_freeze\relax
+
+%D Beware, changing this will break some code (like pos/backgrounds) but it has been
+%D changed anyway so let's see where things go wrong.
\installcorenamespace{paragraphintro}
@@ -133,11 +159,11 @@
\gtoksapp\t_spac_paragraphs_intro_first{#1}%
\glet\insertparagraphintro\spac_paragraphs_flush_intro}
-%D Here comes the flusher (we misuse the one level expansion of token
-%D registers to feed a nice stream into the paragraph.)
+%D Here comes the flusher (we misuse the one level expansion of token registers to
+%D feed a nice stream into the paragraph.)
-\unexpanded\def\spac_paragraphs_flush_intro % we make sure that the token lists expand directly after another
- {\normalexpanded{% % so the first code is there twice
+\unexpanded\def\spac_paragraphs_flush_intro % we make sure that the token lists expand directly
+ {\normalexpanded{% % after another so the first code is there twice
\ifconditional\c_spac_paragraphs_intro_each
\ifconditional\c_spac_paragraphs_intro_next
\glet\insertparagraphintro\spac_paragraphs_flush_intro_next
@@ -180,8 +206,8 @@
%D \macros
%D {flushatnextpar}
%D
-%D This macro collects data that will be flushed at the next paragraph.
-%D By using this macro you can avoid interfering nodes (writes, etc).
+%D This macro collects data that will be flushed at the next paragraph. By using
+%D this macro you can avoid interfering nodes (writes, etc).
\let\flushpostponednodedata\relax % hook into everypar
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-prf.lua b/Master/texmf-dist/tex/context/base/mkiv/spac-prf.lua
index 7731b21f7e1..2223c77302d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-prf.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-prf.lua
@@ -17,7 +17,6 @@ local formatters = string.formatters
local nodecodes = nodes.nodecodes
local gluecodes = nodes.gluecodes
local listcodes = nodes.listcodes
-local leadercodes = nodes.leadercodes
local glyph_code = nodecodes.glyph
local disc_code = nodecodes.disc
@@ -31,8 +30,7 @@ local math_code = nodecodes.math
local rule_code = nodecodes.rule
local marginkern_code = nodecodes.marginkern
-local leaders_code = leadercodes.leaders
-
+local leaders_code = gluecodes.leaders
local lineskip_code = gluecodes.lineskip
local baselineskip_code = gluecodes.baselineskip
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-prf.mkvi b/Master/texmf-dist/tex/context/base/mkiv/spac-prf.mkvi
index 9a00da395e2..ac0a2f4e15c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-prf.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-prf.mkvi
@@ -70,7 +70,7 @@
\relax}
\unexpanded\def\resetprofile
- {\attribute\profilemethodattribute\attributeunsetvalue}
+ {\c_attr_profilemethod\attributeunsetvalue}
\unexpanded\def\useprofileparameter#getparameter%
{\edef\m_spac_profile_asked{#getparameter\c!profile}%
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
index 33b81e5c7e8..2fc9263213c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['spac-ver'] = {
version = 1.001,
+ optimize = true,
comment = "companion to spac-ver.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -38,6 +39,7 @@ local unpack = unpack or table.unpack
local allocate = utilities.storage.allocate
local todimen = string.todimen
local formatters = string.formatters
+local abs = math.abs
local nodes = nodes
local trackers = trackers
@@ -180,11 +182,10 @@ local gluecodes = nodes.gluecodes
local penalty_code = nodecodes.penalty
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
-local insert_code = nodecodes.ins
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local rule_code = nodecodes.rule
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local userskip_code = gluecodes.userskip
local lineskip_code = gluecodes.lineskip
@@ -292,7 +293,7 @@ end
local function validvbox(parentid,list)
if parentid == hlist_code then
local id = getid(list)
- if id == localpar_code and start_of_par(list) then
+ if id == par_code and start_of_par(list) then
list = getnext(list)
if not next then
return nil
@@ -328,7 +329,7 @@ local function already_done(parentid,list,a_snapmethod) -- todo: done when only
-- problem: any snapped vbox ends up in a line
if list and parentid == hlist_code then
local id = getid(list)
- if id == localpar_code and start_of_par(list) then
+ if id == par_code and start_of_par(list) then
list = getnext(list)
if not list then
return false
@@ -1262,7 +1263,7 @@ do
end
end
-- in fact, we could try again later ... so then no remove (a few tries)
- return remove_node(head, current, true)
+ return remove_node(head,current,true)
end
local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also pass tail
@@ -1500,7 +1501,7 @@ do
-- if trace then
-- trace_done("removed penalty",current)
-- end
- -- head, current = remove_node(head, current, true)
+ -- head, current = remove_node(head,current,true)
current = getnext(current)
elseif id == kern_code then
if snap and trace_vsnapping and getkern(current) ~= 0 then
@@ -1538,7 +1539,7 @@ do
if trace then
trace_skip("penalty in skip",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif not sc then -- if not sc then
if glue_data then
if trace then
@@ -1561,7 +1562,7 @@ do
if trace then
trace_natural("removed",current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
if trace then
trace_natural("collapsed",previous)
end
@@ -1586,7 +1587,7 @@ do
if trace then
trace_skip(sc == disable and "disable" or "enable",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
else
current = next
end
@@ -1595,12 +1596,12 @@ do
trace_skip("packed",sc,so,sp,current)
end
-- can't happen !
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif sc == nowhite then
local next = getnext(current)
if next then
ignore_whitespace = true
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
else
current = next
end
@@ -1608,7 +1609,7 @@ do
if trace then
trace_skip("discard",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif sc == overlay then
-- todo (overlay following line over previous
if trace then
@@ -1621,20 +1622,20 @@ do
if trace then
trace_skip("disabled",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif not glue_data then
if trace then
trace_skip("assign",sc,so,sp,current)
end
glue_order = so
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
elseif glue_order < so then
if trace then
trace_skip("force",sc,so,sp,current)
end
glue_order = so
flush_node(glue_data)
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
elseif glue_order == so then
-- is now exclusive, maybe support goback as combi, else why a set
if sc == largest then
@@ -1650,7 +1651,7 @@ do
if trace then
trace_skip("remove smallest",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
elseif sc == goback then
if trace then
@@ -1665,34 +1666,34 @@ do
trace_skip("force",sc,so,sp,current)
end
flush_node(glue_data)
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
elseif sc == penalty then
if trace then
trace_skip("penalty",sc,so,sp,current)
end
flush_node(glue_data)
glue_data = nil
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif sc == add then
if trace then
trace_skip("add",sc,so,sp,current)
end
local cwidth, cstretch, cshrink = getglue(current)
local gwidth, gstretch, gshrink = getglue(glue_data)
- setglue(old,gwidth + cwidth, gstretch + cstretch, gshrink + cshrink)
+ setglue(glue_data,gwidth + cwidth, gstretch + cstretch,gshrink + cshrink)
-- toto: order
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
else
if trace then
trace_skip("unknown",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
else
if trace then
trace_skip("unknown",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
if sc == force then
force_glue = true
@@ -1747,7 +1748,7 @@ do
if trace then
trace_natural("ignored parskip",current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif glue_data then
local w = getwidth(current)
if (w ~= 0) and (w > getwidth(glue_data)) then
@@ -1755,18 +1756,18 @@ do
if trace then
trace_natural("taking parskip",current)
end
- head, current = remove_node(head, current)
+ head, current = remove_node(head,current)
else
if trace then
trace_natural("removed parskip",current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
else
if trace then
trace_natural("honored parskip",current)
end
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
end
elseif subtype == topskip_code or subtype == splittopskip_code then
local next = getnext(current)
@@ -1901,18 +1902,6 @@ do
return head
end
- -- alignment after_output end box new_graf vmode_par hmode_par insert penalty before_display after_display
- -- \par -> vmode_par
- --
- -- status.best_page_break
- -- tex.lists.best_page_break
- -- tex.lists.best_size (natural size to best_page_break)
- -- tex.lists.least_page_cost (badness of best_page_break)
- -- tex.lists.page_head
- -- tex.lists.contrib_head
-
- -- do
-
local stackhead, stacktail, stackhack = nil, nil, false
local function report(message,where,lst)
@@ -1929,7 +1918,6 @@ do
local forceflush = false
function vspacing.pagehandler(newhead,where)
- -- local newhead = texlists.contrib_head
if newhead then
local newtail = find_node_tail(newhead) -- best pass that tail, known anyway
local flush = false
@@ -1971,11 +1959,9 @@ do
if stackhack then
stackhack = false
if trace_collect_vspacing then report("%s > processing %s nodes: %s",where,newhead) end
- -- texlists.contrib_head = collapser(newhead,"page",where,trace_page_vspacing,true,a_snapmethod)
newhead = collapser(newhead,"page",where,trace_page_vspacing,true,a_snapmethod)
else
if trace_collect_vspacing then report("%s > flushing %s nodes: %s",where,newhead) end
- -- texlists.contrib_head = newhead
end
return newhead
else
@@ -1992,20 +1978,6 @@ do
return nil
end
- -- function vspacing.flushpagestack()
- -- if stackhead then
- -- local head = texlists.contrib_head
- -- if head then
- -- local tail = find_node_tail(head)
- -- setlink(tail,stackhead)
- -- else
- -- texlists.contrib_head = tonode(stackhead)
- -- end
- -- stackhead, stacktail = nil, nil
- -- end
- --
- -- end
-
function vspacing.pageoverflow()
local h = 0
if stackhead then
@@ -2156,32 +2128,49 @@ do
end
end
- local trace = false
+ local trace = false
+ local last = nil
+ local vmode_code = tex.modelevels.vertical
+ local temp_code = nodecodes.temp
+ local getnest = tex.getnest
+ local getlist = tex.getlist
trackers.register("vspacing.forcestrutdepth",function(v) trace = v end)
- local last = nil
+ -- abs : negative is inner
- -- function vspacing.forcestrutdepth(n,depth,trace_mode,plus)
- -- local box = texgetbox(n)
- -- if box then
- -- box = tonut(box)
- -- local head = getlist(box)
- -- if head then
- -- local tail = find_node_tail(head)
- -- if tail and getid(tail) == hlist_code then
- -- local dp = getdepth(tail)
- -- if dp < depth then
- -- setdepth(tail,depth)
- -- outer.prevdepth = depth
- -- if trace or trace_mode > 0 then
- -- nuts.setvisual(tail,"depth")
- -- end
- -- end
- -- end
- -- end
- -- end
- -- end
+ function vspacing.checkstrutdepth(depth)
+ local nest = getnest()
+ if abs(nest.mode) == vmode_code and nest.head then
+ local tail = nest.tail
+ local id = tail.id
+ if id == hlist_code then
+ if tail.depth < depth then
+ tail.depth = depth
+ end
+ nest.prevdepth = depth
+ elseif id == temp_code and getnest("ptr") == 0 then
+ local head = getlist("page_head")
+ if head then
+ tail = nodes.tail(head)
+ if tail and tail.id == hlist_code then
+ if tail.depth < depth then
+ tail.depth = depth
+ end
+ nest.prevdepth = depth
+ -- only works in lmtx
+ texset("pagedepth",depth)
+ end
+ end
+ end
+ end
+ end
+
+ interfaces.implement {
+ name = "checkstrutdepth",
+ arguments = "dimension",
+ actions = vspacing.checkstrutdepth,
+ }
function vspacing.forcestrutdepth(n,depth,trace_mode,plus)
local box = texgetbox(n)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkiv
index 6ed1847c577..3f330a267f4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkiv
@@ -66,7 +66,7 @@
\def\normalskipamount
{\openlineheight
- \ifgridsnapping \else \ifblankflexible
+ \ifgridsnapping \else \ifconditional\c_spac_whitespace_flexible
\s!plus \skipgluefactor\openlineheight
\s!minus\skipgluefactor\openlineheight
\fi \fi
@@ -166,17 +166,11 @@
\installmacrostack\currentinterlinespace
\unexpanded\def\setupinterlinespace
- {\dodoubleempty\spac_linespacing_setup}
+ {\dosingleempty\spac_linespacing_setup}
-\ifdefined\setupinterlinespace_double \else
- \let\setupinterlinespace_double\setup_interlinespace % for a while
-\fi
-
-\def\spac_linespacing_setup[#1][#2]%
+\def\spac_linespacing_setup[#1]%
{\settrue\interlinespaceisset % reset has to be done when needed
- \ifsecondargument
- \setupinterlinespace_double[#1][#2]%
- \else\iffirstargument
+ \iffirstargument
\ifcsname\namedinterlinespacehash{#1}\s!parent\endcsname
\edef\currentinterlinespace{#1}%
\spac_linespacing_setup_specified_interline_space
@@ -187,7 +181,7 @@
\else
\let\currentinterlinespace\empty
\spac_linespacing_synchronize_local
- \fi\fi}
+ \fi}
\def\spac_linespacing_setup_specified_or_relative[#1]%
{\doifelseassignment{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]%
@@ -738,19 +732,19 @@
\unexpanded\def\setmaxdepth
{\maxdepth\systemmaxdepthfactor\globalbodyfontsize}
-\let\normalbaselineskip \relax \newskip \normalbaselineskip % these got lost in the transition to mkiv due
-\let\normallineskip \relax \newskip \normallineskip % to auto-\normal* definitions and registers
-\let\normallineskiplimit\relax \newdimen\normallineskiplimit % being protected
+\newskip \usedbaselineskip
+\newskip \usedlineskip
+\newdimen\usedlineskiplimit
\unexpanded\def\normalbaselines
- {\baselineskip \normalbaselineskip
- \lineskip \normallineskip
- \lineskiplimit\normallineskiplimit}
+ {\baselineskip \usedbaselineskip
+ \lineskip \usedlineskip
+ \lineskiplimit\usedlineskiplimit}
\unexpanded\def\flexiblebaselines
- {\baselineskip \normalbaselineskip
- \lineskip 1\normallineskip \s!plus 1\s!fill
- \lineskiplimit\normallineskiplimit}
+ {\baselineskip \usedbaselineskip
+ \lineskip 1\usedlineskip \s!plus 1\s!fill
+ \lineskiplimit\usedlineskiplimit}
\unexpanded\def\setnormalbaselines
{\ifdim\normallineheight>\zeropoint
@@ -770,13 +764,13 @@
\ifdim\dimexpr\minimumstrutdepth+\minimumstrutheight\relax>\zeropoint
\openlineheight\dimexpr\openstrutheight+\openstrutdepth\relax % new
\fi
- \normalbaselineskip\openlineheight
+ \usedbaselineskip\openlineheight
\ifgridsnapping\else
\s!plus \m_spac_vertical_baseline_stretch_factor\openlineheight
\s!minus\m_spac_vertical_baseline_shrink_factor \openlineheight
\fi
- \normallineskip\minimumlinedistance\relax % \onepoint\relax
- \normallineskiplimit\zeropoint\relax
+ \usedlineskip\minimumlinedistance\relax % \onepoint\relax
+ \usedlineskiplimit\zeropoint\relax
\normalbaselines}
\unexpanded\def\spacing#1% vertical
@@ -818,9 +812,9 @@
\openstrutheight \the\openstrutheight
\openstrutdepth \the\openstrutdepth
\openlineheight \the\openlineheight
- \normalbaselineskip \the\normalbaselineskip
- \normallineskip \the\normallineskip
- \normallineskiplimit\the\normallineskiplimit
+ \usedbaselineskip \the\usedbaselineskip
+ \usedlineskip \the\usedlineskip
+ \usedlineskiplimit \the\usedlineskiplimit
\noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}%
\noexpand\normalbaselines}}
@@ -1351,11 +1345,6 @@
\let\oninterlineskip\relax
-\unexpanded\def\leaveoutervmode
- {\ifvmode\ifinner\else
- \leavevmode
- \fi\fi}
-
\unexpanded\def\resetpenalties#1%
{\ifdefined#1%
#1\minusone
@@ -1500,14 +1489,14 @@
\newdimen \globalbodyfontstrutheight
\newdimen \globalbodyfontstrutdepth
-\def\snappedvboxattribute{\ifgridsnapping attr \snapvboxattribute \attribute\snapmethodattribute\fi}
-\def\setlocalgridsnapping{\ifgridsnapping \attribute \snapvboxattribute \attribute\snapmethodattribute\fi}
+\def\snappedvboxattribute{\ifgridsnapping attr\snapvboxattribute\c_attr_snapmethod\fi}
+\def\setlocalgridsnapping{\ifgridsnapping \c_attr_snapvbox \c_attr_snapmethod\fi}
\def\spac_grids_set_local_snapping#1%
{\ifgridsnapping
\doifsomething{#1}%
{\spac_grids_snap_value_set{#1}%
- \attribute \snapvboxattribute \attribute\snapmethodattribute}%
+ \c_attr_snapvbox\c_attr_snapmethod}%
\fi}
% \unexpanded\def\installsnapvalues#1#2% todo: a proper define
@@ -1515,7 +1504,7 @@
% \ifcsname\??gridsnapperattributes\currentsnapper\endcsname \else
% \setevalue{\??gridsnapperattributes\currentsnapper}{\clf_definesnapmethod{#1}{#2}}%
% \fi
-% \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\csname\??gridsnapperattributes\currentsnapper\endcsname\space}}
+% \setevalue{\??gridsnappers#1}{\c_attr_snapmethod\csname\??gridsnapperattributes\currentsnapper\endcsname\space}}
\def\spac_grids_expand_snapper#1%
{\edef\m_spac_snapper
@@ -1534,7 +1523,7 @@
\scratchcounter\clf_definesnapmethod{#1}{\m_spac_snapper}%
\setevalue{\??gridsnapperattributes\currentsnapper}{\the\scratchcounter}%
\fi
- \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\the\scratchcounter\relax}%
+ \setevalue{\??gridsnappers#1}{\c_attr_snapmethod\the\scratchcounter\relax}%
\letvalue{\??gridsnappersets#1}\m_spac_snapper}
\def\theexpandedsnapperset#1{\begincsname\??gridsnappersets#1\endcsname} % only for manuals
@@ -1542,10 +1531,10 @@
\unexpanded\def\usegridparameter#1% no checking here
{\edef\m_spac_grid_asked{#1\c!grid}%
\ifx\m_spac_grid_asked\empty
- \attribute \snapvboxattribute\attributeunsetvalue
+ \c_attr_snapvbox\attributeunsetvalue
\else
\spac_grids_snap_value_set\m_spac_grid_asked
- \attribute \snapvboxattribute\attribute\snapmethodattribute
+ \c_attr_snapvbox\c_attr_snapmethod
\fi}
\unexpanded\def\definegridsnapping
@@ -1556,7 +1545,7 @@
\edef\spac_grids_snap_value_reset
{%\gridsnappingfalse
- \attribute\snapmethodattribute\attributeunsetvalue}
+ \c_attr_snapmethod\attributeunsetvalue}
\def\spac_grids_snap_value_set#1%
{%\gridsnappingtrue
@@ -1605,9 +1594,9 @@
%D We're not downward compatible with \MKII ! Not yet in interface file:
-\definegridsnapping[\v!normal] [\v!maxheight,\v!maxdepth,\v!strut]
-\definegridsnapping[\v!standard] [\v!maxheight,\v!maxdepth,\v!strut]
-\definegridsnapping[\v!yes] [\v!maxheight,\v!maxdepth,\v!strut]
+\definegridsnapping[\v!normal] [\v!maxheight,\v!maxdepth,\v!strut]
+\definegridsnapping[\v!standard] [\v!maxheight,\v!maxdepth,\v!strut]
+\definegridsnapping[\v!yes] [\v!maxheight,\v!maxdepth,\v!strut]
\definegridsnapping[\v!strict] [\v!maxdepth:0.8,\v!maxheight:0.8,\v!strut]
\definegridsnapping[\v!tolerant] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut]
@@ -1717,7 +1706,7 @@
\clf_vspacingcollapse\nextbox\relax % isn't that already done?
\fi
\doifelsenothing{#1}{\spac_grids_snap_value_set\v!normal}{\spac_grids_snap_value_set{#1}}%
- \clf_vspacingsnap\nextbox\attribute\snapmethodattribute\relax
+ \clf_vspacingsnap\nextbox\c_attr_snapmethod\relax
\ifvbox\nextbox\vbox\else\hbox\fi attr \snapmethodattribute \zerocount {\box\nextbox}% no pack (?), we snap
\egroup}
@@ -1883,11 +1872,8 @@
%D This has become obsolete:
-\def\fuzzysnappedbox#1#2% \box \unvbox
- {#1#2}
-
-\def\moveboxontogrid#1#2#3% will become obsolete, but it needs checking
- {}
+% \def\moveboxontogrid#1#2#3% will become obsolete, but it needs checking
+% {}
%D Helper:
@@ -1948,7 +1934,7 @@
\clf_vspacingsetamount{#1}}
\def\spac_vspacing_no_topskip % use grouped
- {\attribute\skipcategoryattribute\plusten}
+ {\c_attr_skipcategory\pluseleven}
% \installcorenamespace{vspacingamountnormal}
% \installcorenamespace{vspacingamountgrid}
@@ -1979,9 +1965,9 @@
\appendtoks
\s_spac_vspacing_temp\zeropoint
- \attribute\skipcategoryattribute\plusone
- \attribute\skippenaltyattribute \attributeunsetvalue
- \attribute\skiporderattribute \attributeunsetvalue
+ \c_attr_skipcategory\plusone
+ \c_attr_skippenalty \attributeunsetvalue
+ \c_attr_skiporder \attributeunsetvalue
\ifgridsnapping
\settrue\c_space_vspacing_fixed
\else
@@ -2003,10 +1989,10 @@
\unexpanded\def\setblankcategory#1%
{\settrue\c_space_vspacing_done
- \attribute\skipcategoryattribute#1\relax}
+ \c_attr_skipcategory#1\relax}
\unexpanded\def\setblankorder#1%
- {\attribute\skiporderattribute#1\relax}
+ {\c_attr_skiporder#1\relax}
\unexpanded\def\fixedblankskip
{\settrue\c_space_vspacing_fixed}
@@ -2021,8 +2007,8 @@
\unexpanded\def\setblankpenalty#1%
{\flushblankhandling
\settrue\c_space_vspacing_done
- \attribute\skipcategoryattribute \plusthree
- \attribute\skippenaltyattribute #1\relax
+ \c_attr_skipcategory\plusthree
+ \c_attr_skippenalty #1\relax
\flushblankhandling}
\unexpanded\def\startblankhandling % move this to \vspacing
@@ -2181,17 +2167,17 @@
\unexpanded\def\directvpenalty#1%
{\begingroup
- \attribute\skipcategoryattribute \plusthree
- \attribute\skippenaltyattribute #1\relax
- \attribute\skiporderattribute \attributeunsetvalue
+ \c_attr_skipcategory\plusthree
+ \c_attr_skippenalty #1\relax
+ \c_attr_skiporder \attributeunsetvalue
\vskip\zeropoint
\endgroup}
\unexpanded\def\directvskip#1%
{\begingroup
- \attribute\skipcategoryattribute \plusone
- \attribute\skippenaltyattribute \attributeunsetvalue
- \attribute\skiporderattribute \attributeunsetvalue
+ \c_attr_skipcategory\plusone
+ \c_attr_skippenalty \attributeunsetvalue
+ \c_attr_skiporder \attributeunsetvalue
\vskip#1\relax
\endgroup}
@@ -2343,7 +2329,7 @@
\unexpanded\def\inhibitblank
{\ifvmode
\begingroup
- \attribute\skipcategoryattribute\plusfive
+ \c_attr_skipcategory\plusfive
\vskip\zeropoint
\endgroup
\fi}
@@ -2655,6 +2641,8 @@
% test \par
% test \par
+% only main vertical list
+
\unexpanded\def\ignoreparskip{\c_spac_vspacing_ignore_parskip\plusone}
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkxl b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkxl
deleted file mode 100644
index c56352077f3..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.mkxl
+++ /dev/null
@@ -1,2605 +0,0 @@
-%D \module
-%D [ file=spac-ver,
-%D version=2009.10.16, % 1997.03.31, was core-spa.tex
-%D title=\CONTEXT\ Spacing Macros,
-%D subtitle=Vertical,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Spacing Macros / Vertical}
-
-\unprotect
-
-\registerctxluafile{spac-ver}{optimize}
-
-% todo: use usernodes ?
-
-% todo: itemize : intro ... only when there is one or two lines preceding and then
-% keep these together i.e. \blank[intro]
-
-% Isn't it about time to get rid of topskip i.e. make it equivalent to
-% \openstrutheight so that we can remove delta code.
-%
-% There might be more namespace protection.
-
-%D There are two ways to influence the interline spacing. The most general and often
-%D most consistent way is using
-%D
-%D \showsetup{setupinterlinespace}
-%D
-%D For instance
-%D
-%D \starttyping
-%D \setupinterlinespace[line=2.8ex]
-%D \stoptyping
-%D
-%D This setting adapts itself to the bodyfontsize, while for instance saying
-%D
-%D \starttyping
-%D \setupinterlinespace[line=12pt]
-%D \stoptyping
-%D
-%D sets things fixed for all sizes, which is definitely not what we want. Therefore
-%D one can also say:
-%D
-%D \starttyping
-%D \definebodyfontenvironment[9pt][interlinespace=11pt]
-%D \stoptyping
-%D
-%D One can still use \type {\setupinterlinespace} (without arguments) to set the
-%D interline space according to the current font, e.g. a \type {\bfa}.
-
-% will be cleaned up but it will stay messy because we accept so
-% many variants
-
-\newif\iflocalinterlinespace
-
-\newskip \s_spac_vspacing_temp \s_spac_vspacing_temp\bigskipamount
-
-\def\skipfactor {.75}
-\def\skipgluefactor{.25}
-
-% \def\normalskipamount
-% {\openlineheight
-% \ifgridsnapping \else \ifblankflexible
-% \s!plus \skipgluefactor\openlineheight
-% \s!minus\skipgluefactor\openlineheight
-% \fi \fi
-% \relax}
-
-\def\normalskipamount
- {\openlineheight
- \ifgridsnapping \orelse \ifblankflexible
- \s!plus \skipgluefactor\openlineheight
- \s!minus\skipgluefactor\openlineheight
- \fi
- \relax}
-
-\ifdefined\bodyfontinterlinespace \else
- \let\bodyfontinterlinespace\empty
-\fi
-
-\unexpanded\def\presetnormallineheight % each bodyfont
- {\edef\normallineheight{\interlinespaceparameter\c!line}%
- \iflocalinterlinespace \else
- \edef\m_spac_normallineheight{\bodyfontinterlinespace}%
- \ifx\m_spac_normallineheight\empty \else
- \let\normallineheight\m_spac_normallineheight
- \fi
- \fi}
-
-\unexpanded\def\setupspecifiedinterlinespace[#1]%
- {\setupcurrentinterlinespace[#1]%
- \spac_linespacing_setup_specified_interline_space}
-
-\def\spac_linespacing_setup_specified_interline_space
- {\edef\strutheightfactor {\interlinespaceparameter\c!height }%
- \edef\strutdepthfactor {\interlinespaceparameter\c!depth }%
- \edef\minimumstrutheight {\interlinespaceparameter\c!minheight}%
- \edef\minimumstrutdepth {\interlinespaceparameter\c!mindepth }%
- \edef\minimumlinedistance {\interlinespaceparameter\c!distance }%
- \edef\normallineheight {\interlinespaceparameter\c!line }%
- \edef\topskipfactor {\interlinespaceparameter\c!top }%
- \edef\maxdepthfactor {\interlinespaceparameter\c!bottom }%
- \edef\m_spac_vertical_baseline_stretch_factor{\interlinespaceparameter\c!stretch }%
- \edef\m_spac_vertical_baseline_shrink_factor {\interlinespaceparameter\c!shrink }%
- % often topskip does more bad than good, so:
- \ifx\topskipfactor\v!height
- \let\topskipfactor\strutheightfactor
- \fi
- \setfontparameters % redundant, can be \setstrut, test first
- \updateraggedskips} % yes indeed
-
-\installcorenamespace{interlinespacerelative}
-
-\let\setrelativeinterlinespace \relax % used elsewhere
-\let\currentrelativeinterlinespace\empty
-
-\setvalue{\??interlinespacerelative\v!on }{\oninterlineskip}
-\setvalue{\??interlinespacerelative\v!off }{\offinterlineskip}
-\setvalue{\??interlinespacerelative\v!reset}{\let\currentrelativeinterlinespace\empty
- \let\setrelativeinterlinespace\relax
- \setfontparameters}
-\setvalue{\??interlinespacerelative\v!auto }{\let\setrelativeinterlinespace\spac_linespacing_set_relative_interlinespace}
-
-\def\spac_linespacing_set_specified_relative_interlinespace#1% fragile?
- {\doifelsedimenstring{#1}
- {\setupspecifiedinterlinespace[\c!line=#1]}
- {\assignvalue{#1}\currentrelativeinterlinespace{1.00}{1.25}{1.50}%
- \spacing\currentrelativeinterlinespace}}
-
-\unexpanded\def\setuprelativeinterlinespace[#1]%
- {\processcommalist[#1]\spac_linespacing_setup_relative_interlinespace}
-
-\def\spac_linespacing_setup_relative_interlinespace#1%
- {\ifcsname\??interlinespacerelative#1\endcsname
- \lastnamedcs
- \else
- \spac_linespacing_set_specified_relative_interlinespace{#1}%
- \fi}
-
-\def\spac_linespacing_set_relative_interlinespace
- {\ifx\currentrelativeinterlinespace\empty\else
- \spacing\currentrelativeinterlinespace
- \fi}
-
-\unexpanded\def\spac_linespacing_setup_use
- {\ifcsname\namedinterlinespacehash\m_spac_interlinespace\s!parent\endcsname
- \let\currentinterlinespace\m_spac_interlinespace
- \spac_linespacing_setup_specified_interline_space
- % \else
- % we only support named interlinespaces
- \fi}
-
-\unexpanded\def\useinterlinespaceparameter#1% see footnotes
- {\edef\m_spac_interlinespace{#1\c!interlinespace}%
- \ifx\m_spac_interlinespace\empty \else
- \spac_linespacing_setup_use
- \fi}
-
-\newtoks\everysetupglobalinterlinespace
-\newtoks\everysetuplocalinterlinespace
-
-\newconditional\interlinespaceisset
-
-\installcorenamespace{interlinespace}
-
-\installcommandhandler \??interlinespace {interlinespace} \??interlinespace
-
-\installmacrostack\currentinterlinespace
-
-\unexpanded\def\setupinterlinespace
- {\dodoubleempty\spac_linespacing_setup}
-
-\ifdefined\setupinterlinespace_double \else
- \let\setupinterlinespace_double\setup_interlinespace % for a while
-\fi
-
-\def\spac_linespacing_setup[#1][#2]%
- {\settrue\interlinespaceisset % reset has to be done when needed
- \ifsecondargument
- \setupinterlinespace_double[#1][#2]%
- \orelse\iffirstargument
- \ifcsname\namedinterlinespacehash{#1}\s!parent\endcsname
- \edef\currentinterlinespace{#1}%
- \spac_linespacing_setup_specified_interline_space
- %\dosetupspecifiedinterlinespaceindeed
- \else
- \spac_linespacing_setup_specified_or_relative[#1]%
- \fi
- \else
- \let\currentinterlinespace\empty
- \spac_linespacing_synchronize_local
- \fi}
-
-\def\spac_linespacing_setup_specified_or_relative[#1]%
- {\doifelseassignment{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]%
- \the\iflocalinterlinespace\everysetuplocalinterlinespace\else\everysetupglobalinterlinespace\fi}
-
-\def\spac_linespacing_synchronize_local % adapts to the font
- {\localinterlinespacetrue
- \setfontparameters
- \updateraggedskips % funny one here
- \the\everysetuplocalinterlinespace
- \localinterlinespacefalse}
-
-\unexpanded\def\dosetupcheckedinterlinespace#1% often a chain
- {\edef\p_spac_checked_interlinespace{#1}%
- \ifx\p_spac_checked_interlinespace\empty
- \spac_linespacing_synchronize_local
- \orelse\ifcsname\namedinterlinespacehash\p_spac_checked_interlinespace\s!parent\endcsname % we could have a \s!check
- \push_macro_currentinterlinespace
- \let\currentinterlinespace\p_spac_checked_interlinespace
- \spac_linespacing_setup_specified_interline_space % \dosetupspecifiedinterlinespaceindeed
- \iflocalinterlinespace
- \the\everysetuplocalinterlinespace
- \else
- \localinterlinespacetrue
- \the\everysetuplocalinterlinespace
- \localinterlinespacefalse
- \fi
- \pop_macro_currentinterlinespace
- \else
- \normalexpanded{\noexpand\doifelseassignment{\p_spac_checked_interlinespace}%
- \setupspecifiedinterlinespace\setuprelativeinterlinespace[\p_spac_checked_interlinespace]}%
- \iflocalinterlinespace
- \the\everysetuplocalinterlinespace
- \else
- \localinterlinespacetrue
- \the\everysetuplocalinterlinespace
- \localinterlinespacefalse
- \fi
- \fi}
-
-\unexpanded\def\setuplocalinterlinespace[#1]%
- {\localinterlinespacetrue
- \push_macro_currentinterlinespace
- \setupinterlinespace[#1]%
- \pop_macro_currentinterlinespace
- \localinterlinespacefalse}
-
-\let\switchtointerlinespace\setuplocalinterlinespace
-
-%D Helpers
-
-\newskip \s_spac_lastskip
-\newdimen\d_spac_prevdepth
-\newcount\c_spac_spacefactor
-\newdimen\d_spac_prevcontent % set by lua
-
-\unexpanded\def\removelastskip
- {\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi}
-
-\def\doifoutervmode
- {\ifvmode
- \ifinner
- \doubleexpandafter\gobbleoneargument
- \else
- \doubleexpandafter\firstofoneargument
- \fi
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\dosomebreak#1%
- {\doifoutervmode
- {\s_spac_lastskip\lastskip
- \removelastskip
- #1\relax
- \ifzeropt\s_spac_lastskip
- % avoid interference with footnotes
- \else
- \vskip\s_spac_lastskip
- \fi}}
-
-\unexpanded\def\packed
- {\nointerlineskip}
-
-\unexpanded\def\godown[#1]%
- {\relax
- \ifhmode\endgraf\fi
- \ifvmode\nointerlineskip\vskip#1\relax\fi}
-
-\unexpanded\def\smallskip{\vskip\smallskipamount}
-\unexpanded\def\medskip {\vskip\medskipamount}
-\unexpanded\def\bigskip {\vskip\bigskipamount}
-
-\unexpanded\def\smallbreak
- {\par
- \ifvmode\ifdim\lastskip<\smallskipamount
- \removelastskip
- \penalty-\plusfifty
- \smallskip
- \fi\fi}
-
-\unexpanded\def\medbreak
- {\par
- \ifvmode\ifdim\lastskip<\medskipamount
- \removelastskip
- \penalty-\plusonehundred
- \medskip
- \fi\fi}
-
-\unexpanded\def\bigbreak
- {\par
- \ifvmode\ifdim\lastskip<\bigskipamount
- \removelastskip
- \penalty-\plustwohundred
- \bigskip
- \fi\fi}
-
-\unexpanded\def\break {\penalty-\plustenthousand} % can be hmode or vmode
-\unexpanded\def\nobreak {\penalty \plustenthousand} % can be hmode or vmode
-\unexpanded\def\allowbreak{\penalty \zerocount} % can be hmode or vmode
-
-\unexpanded\def\goodbreak {\par\ifvmode\penalty-\plusfivehundred\relax\fi} % forces vmode
-\unexpanded\def\filbreak {\par\ifvmode\vfil\penalty-\plustwohundred\vfilneg\fi} % forces vmode
-
-%D Made slightly more readable:
-
-\unexpanded\def\vglue {\afterassignment\spac_helpers_vglue_indeed\s_spac_lastskip=}
-\unexpanded\def\hglue {\afterassignment\spac_helpers_hglue_indeed\s_spac_lastskip=}
-\unexpanded\def\topglue{\par\ifvmode\nointerlineskip\vglue-\topskip\vglue\fi}
-
-\def\spac_helpers_vglue_indeed
- {\par
- \ifvmode
- \d_spac_prevdepth\prevdepth
- \hrule\s!height\zeropoint
- \nobreak
- \vskip\s_spac_lastskip
- \prevdepth\d_spac_prevdepth
- \fi}
-
-\def\spac_helpers_hglue_indeed
- {\dontleavehmode
- \c_spac_spacefactor\spacefactor
- \vrule\s!width\zeropoint
- \nobreak
- \hskip\s_spac_lastskip
- \spacefactor\c_spac_spacefactor}
-
-%D We adapt plain's \type {\removelastskip} a bit:
-
-\unexpanded\def\removelastskip % also in supp-box
- {\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi}
-
-% The whitespace handler. We could cache settings but normally there are not
-% that many in a set.
-
-\installcorenamespace{whitespacemethod}
-
-\newskip \s_spac_whitespace_parskip \s_spac_whitespace_parskip\zeropoint
-\newconditional\c_spac_whitespace_flexible \settrue\c_spac_whitespace_flexible
-\newconstant \c_spac_whitespace_grid_mode % option in layout / 1=permit_half_lines
-
-%def\v_spac_whitespace_current{\zeropoint}
-\let\v_spac_whitespace_current\v!none
-
-\unexpanded\def\setupwhitespace
- {\doifelsenextoptionalcs\spac_whitespace_setup_yes\spac_whitespace_setup_nop}
-
-\def\spac_whitespace_setup_nop
- {\ifx\v_spac_whitespace_current\v!none\else
- \spac_whitespace_setup
- \fi}
-
-\let\synchronizewhitespace\spac_whitespace_setup_nop
-
-\def\spac_whitespace_setup_yes[#1]%
- {\edef\m_spac_whitespace_asked{#1}%
- \ifx\m_spac_whitespace_asked\empty
- \spac_whitespace_setup_nop
- \else
- \let\v_spac_whitespace_current\m_spac_whitespace_asked
- \spac_whitespace_setup
- \fi}
-
-\def\spac_whitespace_setup % quick test for no list
- {\ifcsname\??whitespacemethod\v_spac_whitespace_current\endcsname
- \lastnamedcs
- \else
- \expandafter\processcommalist\expandafter[\v_spac_whitespace_current]\spac_whitespace_setup_method % can be raw
- \fi\relax
- \ifgridsnapping
- \spac_whitespace_setup_grid
- \else
- \spac_whitespace_setup_normal
- \fi
- \parskip\s_spac_whitespace_parskip}
-
-\def\spac_whitespace_setup_normal
- {\ifconditional\c_spac_whitespace_flexible \else
- \s_spac_whitespace_parskip\plusone\s_spac_whitespace_parskip
- \fi}
-
-\def\spac_whitespace_setup_grid
- {\setfalse\c_spac_whitespace_flexible
- \ifdim\s_spac_whitespace_parskip>\zeropoint
- \s_spac_whitespace_parskip
- \ifcase\c_spac_whitespace_grid_mode
- \baselineskip
- \or
- \ifdim\scratchdimen=\baselineskip % maybe range
- \baselineskip
- \else
- \numexpr\s_spac_whitespace_parskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax
- \fi
- \else
- \baselineskip
- \fi
- \fi}
-
-\unexpanded\def\installwhitespacemethod#1#2%
- {\setvalue{\??whitespacemethod#1}{#2}}
-
-\installwhitespacemethod \v!fix {}
-\installwhitespacemethod \v!fixed {\setfalse\c_spac_whitespace_flexible}
-\installwhitespacemethod \v!flexible {\settrue \c_spac_whitespace_flexible}
-
-\installwhitespacemethod \v!line {\s_spac_whitespace_parskip \baselineskip}
-\installwhitespacemethod \v!halfline {\s_spac_whitespace_parskip .5\baselineskip}
-\installwhitespacemethod \v!quarterline {\s_spac_whitespace_parskip.25\baselineskip}
-\installwhitespacemethod \v!none {\s_spac_whitespace_parskip \zeropoint}
-\installwhitespacemethod \v!big {\s_spac_whitespace_parskip \bigskipamount}
-\installwhitespacemethod \v!medium {\s_spac_whitespace_parskip \medskipamount}
-\installwhitespacemethod \v!small {\s_spac_whitespace_parskip \smallskipamount}
-
-\installwhitespacemethod \s!default {\spac_whitespace_setup_nop} % also covers none
-
-\def\spac_whitespace_setup_method#1%
- {\ifcsname\??whitespacemethod#1\endcsname
- \lastnamedcs
- \else
- \s_spac_whitespace_parskip#1\fi
- \relax}
-
-\unexpanded\def\forgetparskip
- {\s_spac_whitespace_parskip\zeropoint
- \parskip\zeropoint
- \let\v_spac_whitespace_current\v!none}
-
-\appendtoks
- \forgetparskip
-\to \everyforgetall
-
-% \installwhitespacemethod \s!unknown {\s_spac_whitespace_parskip\commalistelement\relax}
-%
-% \def\spac_whitespace_setup_method#1%
-% {\csname\??whitespacemethod\ifcsname\??whitespacemethod#1\endcsname#1\else\s!unknown\endcsname\relax}
-
-\unexpanded\def\nowhitespace{\directcheckedvspacing\v!nowhite} % {\vspacing[\v!nowhite]}
-\unexpanded\def\whitespace {\directcheckedvspacing\v!white} % {\vspacing[\v!white]}
-
-\setupwhitespace
- [\v!none]
-
-% Packed:
-
-% todo: when packed blocks blank, we need to enable forced
-
-\newconditional\c_spac_packed_blank \settrue\c_spac_packed_blank
-\newcount \c_spac_packed_level
-
-\unexpanded\def\startpacked
- {\dosingleempty\spac_packed_start}
-
-\def\spac_packed_start[#1]% nesting afvangen
- {\global\advance\c_spac_packed_level\plusone
- \par
- \ifnum\c_spac_packed_level=\plusone \ifvmode
- \begingroup
- \whitespace % not combined
- \directcheckedvspacing\v!disable % \blank[\v!disable]% or \inhibitblank
- \doifelse{#1}\v!blank\settrue\setfalse\c_spac_packed_blank
- \setupwhitespace[\v!none]% or \forgetparskip
- \fi \fi}
-
-\unexpanded\def\stoppacked
- {\par
- \ifnum\c_spac_packed_level=\plusone \ifvmode
- \endgroup
- \fi \fi
- \global\advance\c_spac_packed_level\minusone}
-
-\unexpanded\def\startunpacked
- {\directdefaultvspacing % \blank
- \begingroup}
-
-\unexpanded\def\stopunpacked
- {\endgroup
- \directdefaultvspacing}% \blank}
-
-% \prevdepth crosses pageboundaries!
-%
-% todo: a version that works ok inside a box
-
-% global : outer hsize + keep skips
-% local : inner hsize + reset skips
-
-\installcorenamespace{linesaround}
-
-\let\spac_lines_vbox\vbox
-
-\installtextracker
- {linecorrection.boxes}
- {\let\spac_lines_vbox\ruledvbox}
- {\let\spac_lines_vbox\vbox}
-
-\let\v_spac_lines_around_action_set\relax
-\let\m_spac_lines_around \empty
-
-\newconstant\c_spac_lines_correction_mode
-
-\setvalue{\??linesaround\v!blank }{\blank}
-\letvalue{\??linesaround\empty }\relax
-\setvalue{\??linesaround\s!unknown}{\directcheckedvspacing\m_spac_lines_around} % \blank[\m_spac_lines_around]}
-
-\def\spac_lines_action_around % we used to let this one but it's cleaner this way
- {\csname\??linesaround % i.e. do it twice
- \ifcsname\??linesaround\m_spac_lines_around\endcsname\m_spac_lines_around\else\s!unknown\fi
- \endcsname}
-
-\unexpanded\def\startlinecorrection
- {\endgraf
- \begingroup
- \setconstant\c_spac_lines_correction_mode\plusone
- \dosingleempty\spac_lines_start_correction}
-
-\unexpanded\def\startlocallinecorrection
- {\endgraf
- \begingroup
- \setconstant\c_spac_lines_correction_mode\plustwo
- \dosingleempty\spac_lines_start_correction}
-
-\unexpanded\def\spac_lines_start_correction[#1]%
- {\edef\m_spac_lines_around{#1}%
- \spac_lines_action_around
- \d_spac_prevdepth\prevdepth
- \spac_lines_initialize_corrections
- \offbaselinecorrection % ???
- \setbox\scratchbox\spac_lines_vbox\bgroup
- \ifcase\c_spac_lines_correction_mode
- % nothing
- \or
- % global
- \or
- % local
- \setlocalhsize
- \hsize\localhsize
- \forgetbothskips
- \fi
- \ignorespaces}
-
-\unexpanded\def\spac_lines_stop_correction
- {\removeunwantedspaces
- \egroup
- \ifgridsnapping
- \spac_lines_stop_correction_ongrid
- \else
- \spac_lines_stop_correction_normal
- \fi
- \endgroup}
-
-\unexpanded\def\spac_lines_stop_correction_ongrid
- {\directcheckedvspacing\v!white % \blank[\v!white]%
- \spac_lines_action_around
- \snaptogrid\hpack{\box\scratchbox}%
- \directcheckedvspacing\v!white
- \spac_lines_action_around}
-
-\unexpanded\def\spac_lines_stop_correction_normal
- {\directcheckedvspacing\v!nowhite % \blank[\v!nowhite]%
- \ifdim\parskip>\zeropoint
- % too fuzzy otherwise
- \else
- % doesn't like whitespace
- \ifdim\d_spac_prevdepth<\maxdimen
- \unless\ifdim\d_spac_prevdepth<\zeropoint
- \ifdim\d_spac_prevdepth<\strutdp \relax
- \pushlastnode
- \ifdim\d_spac_prevdepth>\zeropoint
- \kern-\d_spac_prevdepth
- \fi
- \kern\strutdp
- \prevdepth\strutdp
- \poplastnode
- \fi
- \fi
- \fi
- \fi
- \ifdim\pagegoal<\maxdimen
- % \blank[\v!white,\the\d_spac_lines_correction_before]% \blank[\v!white]\dotopbaselinecorrection
- \directcheckedvspacing{\v!white,\the\d_spac_lines_correction_before}% \blank[\v!white]\dotopbaselinecorrection
- \fi
- \nointerlineskip % new
- \noindent % not \dontleavehmode !
- \ifcase\c_spac_lines_correction_mode
- % nothing
- \or
- % global
- \hskip-\leftskip % more tricky would be hangindent so we ignore that one
- \or
- % local
- \fi
- \box\scratchbox
- \endgraf
- %
- % eventually i'll get it right ... (i also need to check all whitespace code elsewhere)
- %
- % \blank[\the\d_spac_lines_correction_after]% \dobotbaselinecorrection
- % \directcheckedvspacing{\the\d_spac_lines_correction_after}% \dobotbaselinecorrection
- \directcheckedvspacing{\v!white,\the\d_spac_lines_correction_after}% \dobotbaselinecorrection
- % \allowbreak % new, otherwise problems when many in a row
- \prevdepth\strutdp
- \spac_lines_action_around}
-
-\let\stoplinecorrection \spac_lines_stop_correction
-\let\stoplocallinecorrection\spac_lines_stop_correction
-
-% todo:
-
-\unexpanded\def\correctwhitespace
- {\dowithnextboxcs\correctwhitespacefinish\vbox}
-
-\unexpanded\def\correctwhitespacefinish
- {\startbaselinecorrection
- \flushnextbox
- \stopbaselinecorrection}
-
-\unexpanded\def\verticalstrut {\vpack{\hsize\zeropoint\forgetall\strut}}
-\unexpanded\def\horizontalstrut{\hpack {\strut}}
-
-%D Here follow some presets related to interline spacing and therefore also struts.
-%D The values 2.8, 0.07, 0.72 and 0.28 originate in \INRSTEX, a package that we used
-%D a while after we decided that \LATEX\ was not flexible enough. After that
-%D \CONTEXT\ evolved, from some wrapper code around (old) \LATEX\ (on a floppy
-%D disk), to using modules from \INRSTEX\ (which also fit on a floppy) and finally
-%D all written from scratch. I simply didn't understand all that \TEX\ code at that
-%D time, and it was easier to figure it out myself. But \unknown\ some settings
-%D stayed, as the height|/|depth ratios, and they never proved to be bad ones! The
-%D same is true for the font size relations.
-
-%D \starttabulate
-%D \NC \type {\lineheight} \NC the height of a line \NC \NR
-%D \NC \type {\spacing{number}} \NC adapting the interline space \NC \NR
-%D \NC \type {\normalbaselines} \NC initialize the interline spacing \NC \NR
-%D \NC \type {\setstrut} \NC initialize \type {\strut} \NC \NR
-%D \NC \type {\setnostrut} \NC disable the \type {\strut}, \type {\endstrut}, \type {\begstrut} \NC \NR
-%D \NC \type {\setteststrut} \NC initialize the visual \type {\strut} \NC \NR
-%D \NC \type {\resetteststrut} \NC disable the visual \type {\strut} \NC \NR
-%D \NC \type {\setfontparameters} \NC synchronize parameters with foints \NC \NR
-%D \stoptabulate
-%D
-%D \unknown\ and many more (this is a decades old list).
-%D
-%D The lineheight is the sum of the height and depth of \type {strut}, which is
-%D an invisible blob that can be used to enforce the proper dimensions.
-%D
-%D Such a blob, when placed at the beginning of a paragraph can have side effects
-%D that can be prevented with \type {\dontleavehmode}. Never use \type
-%D {\leavevmode}!
-
-\newdimen\strutdimen
-\newdimen\lineheight
-\newdimen\openlineheight
-\newdimen\openstrutheight
-\newdimen\openstrutdepth
-\newdimen\topskipgap
-\newdimen\struttotal
-
-\def\strutheightfactor {.72}
-\def\strutdepthfactor {.28}
-
-\def\baselinefactor {2.8}
-
-\let\m_spac_vertical_baseline_stretch_factor \zerocount
-\let\m_spac_vertical_baseline_shrink_factor \zerocount
-
-\def\minimumstrutheight {\zeropoint}
-\def\minimumstrutdepth {\zeropoint}
-
-\def\normallineheight {\baselinefactor\exheight}
-\def\minimumlinedistance {\lineskip}
-
-\def\strutheight {\zeropoint}
-\def\strutdepth {\zeropoint}
-\def\strutwidth {\zeropoint}
-
-\let\spacingfactor \plusone
-
-\def\topskipfactor {1.0}
-\def\maxdepthfactor {0.5}
-
-\def\systemtopskipfactor {\topskipfactor}
-\def\systemmaxdepthfactor {\maxdepthfactor}
-
-\ifdefined\globalbodyfontsize \else
- \newdimen\globalbodyfontsize
- \globalbodyfontsize=12pt
-\fi
-
-\ifdefined\normalizedbodyfontsize \else
- \def\normalizedbodyfontsize{12pt}
-\fi
-
-\unexpanded\def\topskipcorrection
- {\simpletopskipcorrection
- \vskip-\struttotal
- \verticalstrut}
-
-\unexpanded\def\simpletopskipcorrection
- {\ifdim\topskip>\openstrutheight
- % == \vskip\topskipgap
- \vskip\topskip
- \vskip-\openstrutheight
- \fi}
-
-\unexpanded\def\settopskip % the extra test is needed for the lbr family
- {\topskip
- \ifgridsnapping
- \zeropoint
- \else
- \systemtopskipfactor\globalbodyfontsize
- \ifcase\bottomraggednessmode % ragged bottom
- \s!plus5\globalbodyfontsize
- \fi
- \fi
- %\relax
- \topskipgap\topskip
- \advance\topskipgap -\openstrutheight\relax
- \ifdim\minimumstrutheight>\zeropoint
- \ifdim\topskip<\minimumstrutheight
- \topskip\minimumstrutheight\relax
- \fi
- \else
- \ifdim\topskip<\strutheightfactor\openlineheight
- \topskip\strutheightfactor\openlineheight\relax
- \fi
- \fi}
-
-\unexpanded\def\setmaxdepth
- {\maxdepth\systemmaxdepthfactor\globalbodyfontsize}
-
-\let\normalbaselineskip \relax \newskip \normalbaselineskip % these got lost in the transition to mkiv due
-\let\normallineskip \relax \newskip \normallineskip % to auto-\normal* definitions and registers
-\let\normallineskiplimit\relax \newdimen\normallineskiplimit % being protected
-
-\unexpanded\def\normalbaselines
- {\baselineskip \normalbaselineskip
- \lineskip \normallineskip
- \lineskiplimit\normallineskiplimit}
-
-\unexpanded\def\flexiblebaselines
- {\baselineskip \normalbaselineskip
- \lineskip 1\normallineskip \s!plus 1\s!fill
- \lineskiplimit\normallineskiplimit}
-
-\unexpanded\def\setnormalbaselines
- {\ifdim\normallineheight>\zeropoint
- \lineheight\normallineheight
- \fi
- \openlineheight\spacingfactor\lineheight
- \openstrutheight \ifdim\minimumstrutheight>\zeropoint
- \minimumstrutheight % new
- \else
- \strutheightfactor\openlineheight
- \fi
- \openstrutdepth \ifdim\minimumstrutdepth>\zeropoint
- \minimumstrutdepth % new
- \else
- \strutdepthfactor \openlineheight
- \fi
- \ifdim\dimexpr\minimumstrutdepth+\minimumstrutheight\relax>\zeropoint
- \openlineheight\dimexpr\openstrutheight+\openstrutdepth\relax % new
- \fi
- \normalbaselineskip\openlineheight
- \ifgridsnapping\else
- \s!plus \m_spac_vertical_baseline_stretch_factor\openlineheight
- \s!minus\m_spac_vertical_baseline_shrink_factor \openlineheight
- \fi
- \normallineskip\minimumlinedistance\relax % \onepoint\relax
- \normallineskiplimit\zeropoint\relax
- \normalbaselines}
-
-\unexpanded\def\spacing#1% vertical
- {\ifgridsnapping
- \let\spacingfactor\plusone
- \else
- \edef\spacingfactor{#1}%
- \fi
- \edef\systemtopskipfactor {\withoutpt\the\dimexpr#1\dimexpr\topskipfactor \points}%
- \edef\systemmaxdepthfactor{\withoutpt\the\dimexpr#1\dimexpr\maxdepthfactor\points}%
- \setnormalbaselines
- \setstrut}
-
-% \unexpanded\def\forgetverticalstretch % \forgetspacing
-% {\spacing\plusone}
-
-\unexpanded\def\forgetverticalstretch
- {\let\spacingfactor \plusone
- \let\systemtopskipfactor \topskipfactor
- \let\systemmaxdepthfactor\maxdepthfactor
- \setnormalbaselines
- \setstrut}
-
-\appendtoks
- \forgetverticalstretch
-\to \everyforgetall % needed in otr
-
-%D Sometimes one needs to freeze the interlinespacing
-%D
-%D \starttyping
-%D \rm \saveinterlinespace .... {\ss \restoreinterlinespace .... \endgraf}
-%D \stoptyping
-
-\let\restoreinterlinespace\relax
-
-\unexpanded\def\saveinterlinespace
- {\unexpanded\edef\restoreinterlinespace
- {\lineheight \the\lineheight
- \openstrutheight \the\openstrutheight
- \openstrutdepth \the\openstrutdepth
- \openlineheight \the\openlineheight
- \normalbaselineskip \the\normalbaselineskip
- \normallineskip \the\normallineskip
- \normallineskiplimit\the\normallineskiplimit
- \noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}%
- \noexpand\normalbaselines}}
-
-%D This is the plain definition:
-%D
-%D \starttyping
-%D \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi}
-%D \stoptyping
-%D
-%D which could be:
-%D
-%D \starttyping
-%D \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox}
-%D \stoptyping
-%D
-%D But we do things differently.
-
-\newbox\strutbox
-
-\setbox\strutbox\hpack{\vrule\s!height8.5pt\s!depth3.5pt\s!width\zeropoint} % just a start
-
-\def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox}
-
-% \unexpanded\def\strut
-% {\relax
-% \ifmmode\copy\else\dontleavehmode\unhcopy\fi\strutbox}
-
-\let\normalstrut\strut
-
-%D The double \type {\hbox} construction enables us to backtrack boxes.
-
-\let\strutht\undefined \newdimen\strutht
-\let\strutdp\undefined \newdimen\strutdp
-
-\unexpanded\def\setstrut
- {\ifgridsnapping
- \setstrutgridyes
- \else
- \setstrutgridnop
- \fi}
-
-\unexpanded\def\setstrutgridyes
- {\strutht\spacingfactor\dimexpr
- \ifdim\minimumstrutheight>\zeropoint
- \minimumstrutheight
- \else
- \strutheightfactor\dimexpr\normallineheight
- \fi
- \strutdp\dimexpr
- \ifdim\minimumstrutdepth>\zeropoint
- \minimumstrutdepth
- \else
- \normallineheight-\strutht
- \fi
- \dosetstrut}
-
-\unexpanded\def\setstrutgridnop
- {\strutht\spacingfactor\dimexpr
- \ifdim\minimumstrutheight>\zeropoint
- \minimumstrutheight
- \else
- \strutheightfactor\dimexpr\normallineheight
- \fi
- \strutdp\spacingfactor\dimexpr
- \ifdim\minimumstrutdepth>\zeropoint
- \minimumstrutdepth
- \else
- \strutdepthfactor\dimexpr\normallineheight
- \fi
- \dosetstrut}
-
-\unexpanded\def\setcharstrut#1%
- {\setbox\strutbox\hbox{#1}% no \hpack, in case we have smallcaps
- \strutht\ht\strutbox
- \strutdp\dp\strutbox
- \dosetstrut}
-
-\unexpanded\def\settightstrut
- {\setcharstrut{(}}
-
-\unexpanded\def\setfontstrut
- {\setcharstrut{(gplQT}}
-
-\unexpanded\def\setcapstrut% could be M, but Q has descender
- {\setcharstrut{Q}}
-
-%D Handy for math (used in mathml):
-
-\unexpanded\def\charhtstrut
- {\begingroup
- \setcharstrut{GJY}%
- \vrule\s!width\zeropoint\s!depth\zeropoint\s!height\strutht
- \endgroup}
-
-\unexpanded\def\chardpstrut
- {\begingroup
- \setcharstrut{gjy}%
- \vrule\s!width\zeropoint\s!depth\strutdp\s!height\zeropoint
- \endgroup}
-
-%D Because of all the callbacks in mkiv, we avoid unnecessary boxes ... maybe use an
-%D attribute so that we can tag boxes that don't need a treatment; tests with using
-%D an attribute so far have shown that it's slower because testing the attribute
-%D takes time too.
-
-\unexpanded\def\dosetstrut
- {\let\strut\normalstrut
- \ifabsnum\dimexpr\strutht+\strutdp-\lineheight\relax<\plustwo
- % compensate rounding error /- 1sp to avoid too many
- % 1sp baselineskips in for instance verbatim
- % \strutht\dimexpr\lineheight-\strutdp\relax
- % better:
- \strutdp\dimexpr\lineheight-\strutht\relax
- \struttotal\lineheight
- \else
- \struttotal\dimexpr\strutht+\strutdp\relax
- \fi
- \edef\strutheight{\the\strutht}%
- \edef\strutdepth {\the\strutdp}%
- \ifdim\strutwidth=\zeropoint
- \spac_struts_set_hide
- \else
- \spac_struts_set_vide
- \fi}
-
-\def\spac_struts_set_hide
- {\setbox\strutbox\hpack
- {\vrule
- \s!width \zeropoint
- \s!height\strutht
- \s!depth \strutdp}}
-
-\newconstant\c_strut_visual_mode
-
-\def\spac_struts_set_vide
- {\setbox\strutbox\hpack % at some time this extra wrapping was needed
- {\spac_struts_vide_hbox to \zeropoint
- {\ifcase\c_strut_visual_mode
- \spac_struts_black
- \or
- \spac_struts_color
- \else
- \spac_struts_black
- \fi}}}
-
-\def\spac_struts_black
- {\vrule
- \s!width \strutwidth
- \s!height\strutht
- \s!depth \strutdp
- \hss}
-
-\def\spac_struts_color
- {\hss % new, will be option
- \scratchwidth.1\struthtdp
- \begingroup
- \directcolor[f:b:t]%
- \vrule
- \s!width \scratchwidth
- \s!height\strutht
- \s!depth \strutdp
- \kern-\scratchwidth
- \vrule
- \s!width \scratchwidth
- \s!height\zeropoint
- \s!depth \strutdp
- \endgroup
- \kern-.625\scratchwidth
- \vrule
- \s!width .25\scratchwidth
- \s!height\strutht
- \s!depth \strutdp
- \hss}
-
-\let\spac_struts_vide_hbox\hbox % overloaded in trac-vis.mkiv
-
-%D The dimen \type {\struttotal} holds the exact size of the strut; occasionally a
-%D one scaled point difference can show up with the lineheight. This is more
-%D efficient (less callbacks):
-
-\newbox\b_spac_struts_empty \setbox\b_spac_struts_empty\emptyhbox
-
-\def\spac_struts_set_hide
- {\setbox\strutbox\copy\b_spac_struts_empty
- \ht\strutbox\strutht
- \dp\strutbox\strutdp}
-
-\unexpanded\def\strut % still callbacks for \hbox{\strut}
- {\relax
- \dontleavehmode
- \copy\strutbox}
-
-% \unexpanded\def\strut % slightly faster
-% {\relax
-% \ifmmode\copy\else\dontleavehmode\unhcopy\fi\strutbox}
-
-\let\normalstrut\strut
-
-\unexpanded\def\halfstrut
- {\relax
- \dontleavehmode
- \begingroup
- \setbox\scratchbox\copy\strutbox
- \ht\scratchbox\dimexpr\strutht/\plustwo\relax
- \dp\scratchbox\dimexpr\strutdp/\plustwo\relax
- \box\scratchbox
- \endgroup}
-
-\unexpanded\def\quarterstrut
- {\relax
- \dontleavehmode
- \begingroup
- \setbox\scratchbox\copy\strutbox
- \ht\scratchbox\dimexpr\strutht/\plusfour\relax
- \dp\scratchbox\dimexpr\strutdp/\plusfour\relax
- \box\scratchbox
- \endgroup}
-
-\unexpanded\def\depthstrut
- {\relax
- \dontleavehmode
- \begingroup
- \setbox\scratchbox\copy\strutbox
- \ht\scratchbox\dimexpr\strutht-\struthtdp/\plustwo\relax % assumes that ht > lineheight/2
- \box\scratchbox
- \endgroup}
-
-\unexpanded\def\halflinestrut
- {\relax
- \dontleavehmode
- \begingroup
- \setbox\scratchbox\copy\strutbox
- \ht\scratchbox\dimexpr\strutht-.5\strutht-.5\strutdp\relax
- \box\scratchbox
- \endgroup}
-
-\unexpanded\def\noheightstrut
- {\relax
- \dontleavehmode
- \begingroup
- \setbox\scratchbox\copy\strutbox
- \ht\scratchbox\zeropoint
- \box\scratchbox
- \endgroup}
-
-%D Sometimes a capstrut comes in handy
-%D
-%D \starttabulate[|Tl|l|l|]
-%D \NC yes \NC normal strut \NC {\showstruts\setupstrut[yes]\strut} \NC \NR
-%D \NC no \NC no strut \NC {\showstruts\setupstrut[no]\strut} \NC \NR
-%D \NC kap \NC a capital strut (i.e. Q) \NC {\showstruts\setupstrut[cap]\strut} \NC \NR
-%D \NC A B \unknown \NC a character strut (e.g. A) \NC {\showstruts\setupstrut[A]\strut} \NC \NR
-%D \NC \NC a normal strut \NC {\showstruts\setupstrut\strut} \NC \NR
-%D \stoptabulate
-%D
-%D Beware: using an unknown value results in char struts.
-
-\installcorenamespace{struts}
-
-\unexpanded\def\setupstrut
- {\dosingleempty\spac_struts_setup}
-
-\def\spac_struts_setup[#1]%
- {\edef\m_strut{#1}%
- \ifcsname\??struts\m_strut\endcsname
- \lastnamedcs
- \else
- \setcharstrut\m_strut
- \fi}
-
-\unexpanded\def\synchronizestrut#1% no [] parsing, faster for internal
- {\edef\m_strut{#1}%
- \ifcsname\??struts\m_strut\endcsname
- \lastnamedcs
- \else
- \setcharstrut\m_strut
- \fi}
-
-\unexpanded\def\dosynchronizestrut#1% no [] parsing, faster for internal
- {\ifcsname\??struts#1\endcsname
- \lastnamedcs
- \else
- \setcharstrut{#1}%
- \fi}
-
-\unexpanded\def\showstruts % adapts .. is wrong
- {\c_strut_visual_mode\zerocount
- \setteststrut
- \settestcrlf}
-
-\unexpanded\def\showcolorstruts % adapts .. is wrong
- {\c_strut_visual_mode\plusone
- \setteststrut
- \settestcrlf}
-
-\unexpanded\def\setteststrut
- {\def\strutwidth{.8pt}%
- \setstrut}
-
-\unexpanded\def\dontshowstruts
- {\unsetteststrut
- \settestcrlf}
-
-\unexpanded\def\unsetteststrut
- {\let\strutwidth\zeropoint
- \setstrut}
-
-\def\autostrutfactor{1.1}
-
-\unexpanded\def\setautostrut
- {\begingroup
- \setbox\scratchbox\copy\strutbox
- \setstrut
- \ifdim\strutht>\autostrutfactor\ht\scratchbox
- \endgroup \setstrut
- \orelse\ifdim\strutdp>\autostrutfactor\dp\scratchbox
- \endgroup \setstrut
- \else
- \endgroup
- \fi}
-
-\newbox\nostrutbox \setbox\nostrutbox\emptyhbox
-
-\newtoks\everysetnostrut
-
-\unexpanded\def\setnostrut
- {\the\everysetnostrut}
-
-\appendtoks
- \setbox\strutbox\copy\nostrutbox
- \let\strut\empty
- \let\endstrut\empty
- \let\begstrut\empty
-\to \everysetnostrut
-
-%D When enabled, sigstruts will remove themselves if nothing goes inbetween. For
-%D practical reasons we define some boundary characters here.
-
-\unexpanded\def\leftboundary {\protrusionboundary\plusone}
-\unexpanded\def\rightboundary {\protrusionboundary\plustwo}
-\unexpanded\def\signalcharacter{\boundary\plusone\char\zerocount\boundary\plustwo} % not the same as strut signals
-
-\newsignal\strutsignal \setfalse\sigstruts
-
-\unexpanded\def\begstrut
- {\relax\ifcase\strutht
- % \ignorespaces % maybe
- \else
- \spac_struts_beg
- \fi}
-
-\def\spac_struts_beg
- {\ifconditional\sigstruts
- \spac_struts_beg_signal
- \else
- \spac_struts_beg_normal
- \fi
- \ignorespaces}
-
-\def\spac_struts_beg_signal
- {\noindent\horizontalstrut
- \penalty\plustenthousand
- \hskip-\strutsignal
- \hskip\strutsignal}
-
-\def\spac_struts_beg_normal
- {\boundary\plusone
- \strut
- %\boundary\plusone
- \penalty\plustenthousand
- %\boundary\plusone
- \hskip\zeropoint}
-
-\unexpanded\def\endstrut
- {\relax\ifhmode
- \ifcase\strutht
- % \removeunwantedspaces % maybe
- \else
- \spac_struts_end
- \fi
- \fi}
-
-\def\spac_struts_end
- {\ifconditional\sigstruts
- \spac_struts_end_signal
- \else
- \spac_struts_end_normal
- \fi}
-
-\def\spac_struts_end_signal
- {\ifdim\lastskip=\strutsignal
- \unskip
- \unskip
- \unpenalty
- \setbox\scratchbox\lastbox
- \else
- \penalty\plustenthousand
- \hskip\zeropoint
- \strut
- \fi}
-
-\def\spac_struts_end_normal
- {\removeunwantedspaces
- \penalty\plustenthousand
- %\boundary\plustwo
- \hskip\zeropoint
- %\boundary\plustwo
- \strut
- \boundary\plustwo}
-
-% unsave:
-%
-% \def\pseudostrut
-% {\bgroup
-% \setnostrut
-% \normalstrut
-% \egroup}
-%
-% try:
-%
-% \startchemie
-% \chemie[ONE,Z0,SB15,MOV1,SB15,Z0][C,C]
-% \stopchemie
-%
-% so:
-
-\unexpanded\def\pseudostrut
- {\noindent} % better: \dontleavehmode
-
-\let\pseudobegstrut\pseudostrut
-\let\pseudoendstrut\removeunwantedspaces
-
-\unexpanded\def\resetteststrut
- {\def\strutwidth{\zeropoint}% no let
- \setstrut}
-
-\ifdefined\setfontparameters \else
- \def\setfontparameters{\the\everybodyfont}
-\fi
-
-%D Keyword based strutting:
-
-\letvalue{\??struts\v!yes }\setstrut
-\letvalue{\??struts\v!auto }\setautostrut
-\letvalue{\??struts\v!no }\setnostrut
-\letvalue{\??struts\v!cap }\setcapstrut
-\letvalue{\??struts\v!fit }\setfontstrut
-\letvalue{\??struts\v!line }\setstrut
-\letvalue{\??struts\s!default}\setstrut
-\letvalue{\??struts\empty }\setstrut
-
-%D Handy:
-
-\def\baselinedistance{\the\lineheight}
-
-%D We need \type {\normaloffinterlineskip} because the new definition contains an
-%D assignment, and |<|don't ask me why|>| this assignment gives troubles in for
-%D instance the visual debugger.
-
-\unexpanded\def\offinterlineskip
- {\baselineskip-\thousandpoint
- \lineskip \zeropoint
- \lineskiplimit\maxdimen
- % We also need this here now; thanks to taco for figuring that out!
- \def\minimumlinedistance{\zeropoint}}
-
-\unexpanded\def\nointerlineskip
- {\prevdepth-\thousandpoint}
-
-\let\normaloffinterlineskip\offinterlineskip % knuth's original
-
-%D This is tricky. The prevdepth value is still set to the last one even if there is
-%D nothing on the page. The same is true for prevgraf, which doesn't resemble the
-%D value on the current page.
-%D
-%D So, here we kick in a checker but it has to happen after the output group and it
-%D only has to be done once (output can trigger itself!).
-%D
-%D However, prevgraf is somehow bound to hangindent so we can get very nasty side
-%D effects. So, in tne end we use our own variable!
-
-\ifdefined\getnofpreviouslines
- % defined public at the lua end
-\else
- \let\getnofpreviouslines\!!zerocount
-\fi
-
-\unexpanded\def\page_otr_synchronize_page_yes
- {\aftergroup\page_otr_synchronize_page_indeed
- \glet\page_otr_synchronize_page\relax}
-
-% \unexpanded\def\page_otr_synchronize_page_indeed
-% {\clf_synchronizepage
-% \glet\page_otr_synchronize_page\page_otr_synchronize_page_yes}
-%
-% This has to become an otr method: \s!page_otr_command_synchonize_page
-
-\unexpanded\def\page_otr_synchronize_page_indeed
- {\ifx\currentoutputroutine\s!multicolumn\else\clf_synchronizepage\fi
- \glet\page_otr_synchronize_page\page_otr_synchronize_page_yes}
-
-\let\page_otr_synchronize_page\page_otr_synchronize_page_yes
-
-\appendtoks
- \page_otr_synchronize_page
-\to \everyaftershipout
-
-%D My own one:
-
-\unexpanded\def\spac_helpers_push_interlineskip_yes
- {\edef\oninterlineskip
- {\baselineskip \the\baselineskip
- \lineskip \the\lineskip
- \lineskiplimit\the\lineskiplimit
- \noexpand\edef\noexpand\minimumlinedistance{\the\dimexpr\minimumlinedistance}%
- \let\noexpand\offinterlineskip\noexpand\normaloffinterlineskip}} % \noexpand not needed
-
-\unexpanded\def\spac_helpers_push_interlineskip_nop
- {\let\oninterlineskip\setnormalbaselines}
-
-\unexpanded\def\offinterlineskip
- {\ifdim\baselineskip>\zeropoint
- \spac_helpers_push_interlineskip_yes
- \else
- \spac_helpers_push_interlineskip_nop
- \fi
- \normaloffinterlineskip}
-
-\let\oninterlineskip\relax
-
-\unexpanded\def\leaveoutervmode
- {\ifvmode\ifinner\else
- \leavevmode
- \fi\fi}
-
-\unexpanded\def\resetpenalties#1%
- {\ifdefined#1%
- #1\minusone
- \fi}
-
-\unexpanded\def\setpenalties#1#2#3%
- {\ifdefined#1% space before #3 prevents lookahead problems, needed when #3=text
- #1\numexpr#2+\plusone\relax\space\doexpandedrecurse{\the\numexpr#2\relax}{ #3}\zerocount\relax
- \fi}
-
-%D \macros
-%D {keeplinestogether}
-%D
-%D Dirty hack, needed in margin content that can run of a page.
-
-% just before margintexts ... will eventually be done differently in mkiv using
-% attributes
-
-\newcount\c_spac_keep_lines_together
-\let\restoreinterlinepenalty\relax
-
-\unexpanded\def\spac_penalties_restore
- {\glet\restoreinterlinepenalty\relax
- \global\resetpenalties\interlinepenalties
- \global\c_spac_keep_lines_together\zerocount}
-
-\unexpanded\def\keeplinestogether#1%
- {\ifnum#1>\c_spac_keep_lines_together
- \global\c_spac_keep_lines_together#1%
- \global\setpenalties\interlinepenalties\c_spac_keep_lines_together\plustenthousand
- \glet\restoreinterlinepenalty\spac_penalties_restore
- \fi}
-
-\def\defaultdisplaywidowpenalty {50}
-\def\defaultwidowpenalty {2000} % was: 1000
-\def\defaultclubpenalty {2000} % was: 800
-\def\defaultbrokenpenalty {100}
-\def\defaultdoublehyphendemerits {10000}
-\def\defaultfinalhyphendemerits {5000}
-\def\defaultadjdemerits {10000}
-
-\def\defaultgriddisplaywidowpenalty {0}
-\def\defaultgridwidowpenalty {0}
-\def\defaultgridclubpenalty {0}
-\def\defaultgridbrokenpenalty {0}
-\def\defaultgriddoublehyphendemerits{10000} % always was so
-\def\defaultgridfinalhyphendemerits {5000} % always was so
-\def\defaultgridadjdemerits {10000} % always was so
-
-\unexpanded\def\nopenalties
- {\widowpenalty \zerocount
- \clubpenalty \zerocount
- \brokenpenalty \zerocount
- \doublehyphendemerits\zerocount
- \finalhyphendemerits \zerocount
- \adjdemerits \zerocount}
-
-\unexpanded\def\setdefaultpenalties
- {\directsetup{\systemsetupsprefix\s!default}}
-
-\startsetups [\systemsetupsprefix\s!reset]
- \resetpenalties\widowpenalties
- \resetpenalties\clubpenalties
- \resetpenalties\interlinepenalties
-\stopsetups
-
-%D We use \directsetup because it's faster and we know there is no csl:
-
-\startsetups [\systemsetupsprefix\s!default]
-
- \directsetup{\systemsetupsprefix\s!reset}
-
- \widowpenalty \defaultwidowpenalty
- \clubpenalty \defaultclubpenalty
- \displaywidowpenalty \defaultdisplaywidowpenalty
- \brokenpenalty \defaultbrokenpenalty
- \doublehyphendemerits\defaultdoublehyphendemerits
- \finalhyphendemerits \defaultfinalhyphendemerits
- \adjdemerits \defaultadjdemerits
-
-\stopsetups
-
-\startsetups [\v!grid] [\systemsetupsprefix\s!default]
-
- \directsetup{\systemsetupsprefix\s!reset}
-
- \widowpenalty \defaultgridwidowpenalty
- \clubpenalty \defaultgridclubpenalty
- \displaywidowpenalty \defaultgriddisplaywidowpenalty
- \brokenpenalty \defaultgridbrokenpenalty
- \doublehyphendemerits\defaultgriddoublehyphendemerits
- \finalhyphendemerits \defaultgridfinalhyphendemerits
- \adjdemerits \defaultgridadjdemerits
-
-\stopsetups
-
-%D As an illustration:
-
-\startsetups [\systemsetupsprefix\v!strict]
-
- \directsetup{\systemsetupsprefix\s!reset}
-
- \setpenalties \widowpenalties \plustwo \maxdimen
- \setpenalties \clubpenalties \plustwo \maxdimen
- \brokenpenalty \maxdimen
- \doublehyphendemerits \defaultdoublehyphendemerits
- \finalhyphendemerits \defaultfinalhyphendemerits
- \adjdemerits \defaultadjdemerits
-
-\stopsetups
-
-\setdefaultpenalties % will happen later in \setuplayout
-
-%D To be checked:
-
-\newbox\b_spac_struts_saved
-
-\unexpanded\def\savestrut {\setbox\b_spac_struts_saved\copy\strutbox}
-\unexpanded\def\savedstrut{\copy \b_spac_struts_saved}
-
-%D Good old blank redone:
-
-%definesystemattribute[kernchars] [public]
-\definesystemattribute[skipcategory] [public]
-\definesystemattribute[skippenalty] [public]
-\definesystemattribute[skiporder] [public]
-\definesystemattribute[snapmethod] [public]
-\definesystemattribute[snapvbox] [public]
-%definesystemattribute[snapcategory] [public]
-
-% TODO: NAMED SNAPPERS
-
-\installcorenamespace{gridsnappers}
-\installcorenamespace{gridsnapperattributes}
-\installcorenamespace{gridsnappersets}
-
-\newskip \bodyfontlineheight
-\newdimen \bodyfontstrutheight
-\newdimen \bodyfontstrutdepth
-
-\newskip \globalbodyfontlineheight % why a skip
-\newdimen \globalbodyfontstrutheight
-\newdimen \globalbodyfontstrutdepth
-
-\def\snappedvboxattribute{\ifgridsnapping attr \snapvboxattribute \attribute\snapmethodattribute\fi}
-\def\setlocalgridsnapping{\ifgridsnapping \attribute \snapvboxattribute \attribute\snapmethodattribute\fi}
-
-\def\spac_grids_set_local_snapping#1%
- {\ifgridsnapping
- \doifsomething{#1}%
- {\spac_grids_snap_value_set{#1}%
- \attribute \snapvboxattribute \attribute\snapmethodattribute}%
- \fi}
-
-\def\spac_grids_expand_snapper#1%
- {\edef\m_spac_snapper
- {\ifx\m_spac_snapper\empty\else\m_spac_snapper,\fi
- \ifcsname\??gridsnappersets#1\endcsname
- \lastnamedcs\else#1%
- \fi}}
-
-\unexpanded\def\installsnapvalues#1#2%
- {\let\m_spac_snapper\empty
- \rawprocesscommacommand[#2]\spac_grids_expand_snapper
- \edef\currentsnapper{#1:\m_spac_snapper}%
- \ifcsname\??gridsnapperattributes\currentsnapper\endcsname
- \scratchcounter\lastnamedcs % already defined
- \else
- \scratchcounter\clf_definesnapmethod{#1}{\m_spac_snapper}%
- \setevalue{\??gridsnapperattributes\currentsnapper}{\the\scratchcounter}%
- \fi
- \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\the\scratchcounter\relax}%
- \letvalue{\??gridsnappersets#1}\m_spac_snapper}
-
-\def\theexpandedsnapperset#1{\begincsname\??gridsnappersets#1\endcsname} % only for manuals
-
-\unexpanded\def\usegridparameter#1% no checking here
- {\edef\m_spac_grid_asked{#1\c!grid}%
- \ifx\m_spac_grid_asked\empty
- \attribute \snapvboxattribute\attributeunsetvalue
- \else
- \spac_grids_snap_value_set\m_spac_grid_asked
- \attribute \snapvboxattribute\attribute\snapmethodattribute
- \fi}
-
-\unexpanded\def\definegridsnapping
- {\dodoubleargument\spac_grids_define}
-
-\def\spac_grids_define[#1][#2]%
- {\installsnapvalues{#1}{#2}}
-
-\edef\spac_grids_snap_value_reset
- {%\gridsnappingfalse
- \attribute\snapmethodattribute\attributeunsetvalue}
-
-\def\spac_grids_snap_value_set#1%
- {%\gridsnappingtrue
- \begincsname\??gridsnappers#1\endcsname}
-
-% maybe:
-%
-% \def\spac_grids_snap_value_set#1%
-% {%\gridsnappingtrue
-% \ifcsname\??gridsnappers#1\endcsname
-% \lastnamedcs
-% \else
-% \definegridsnapping[#1][#1]%
-% \begincsname\??gridsnappers#1\endcsname
-% \fi}
-
-\def\spac_grids_snap_value_auto#1%
- {\ifcsname\??gridsnappers#1\endcsname
- \lastnamedcs
- \else
- \installsnapvalues\s!dummy{#1}%
- \csname\??gridsnappers\s!dummy\endcsname
- \fi}
-
-% \installsnapvalues{loose} {\v!maxdepth:0.8,\v!maxheight:0.8,\v!strut}
-% \installsnapvalues{normal}{\v!maxdepth:1.0,\v!maxheight:1.0,\v!strut}
-% \installsnapvalues{tight} {\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut}
-
-% none don't enlarge
-% halfline enlarge by halfline/halfline
-% line enlarge by line/line
-% strut enlarge by ht/dp (default)
-% first align to top line
-% last align to bottom line
-% mindepth round depth down
-% maxdepth round depth up
-% minheight round height down
-% maxheight round height up
-% local use local interline space
-% offset:-3tp vertical shift within box
-% bottom:lines
-% top:lines
-% box centers a box rounded upwards (box:.5 -> tolerance)
-% min centers a box rounded downwards
-% max centers a box rounded upwards
-
-%D We're not downward compatible with \MKII ! Not yet in interface file:
-
-\definegridsnapping[\v!normal] [\v!maxheight,\v!maxdepth,\v!strut]
-\definegridsnapping[\v!standard] [\v!maxheight,\v!maxdepth,\v!strut]
-\definegridsnapping[\v!yes] [\v!maxheight,\v!maxdepth,\v!strut]
-
-\definegridsnapping[\v!strict] [\v!maxdepth:0.8,\v!maxheight:0.8,\v!strut]
-\definegridsnapping[\v!tolerant] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut]
-\definegridsnapping[\v!verytolerant] [\v!maxdepth:1.4,\v!maxheight:1.4,\v!strut]
-
-\definegridsnapping[\v!tolerant:10] [\v!maxdepth:1.1,\v!maxheight:1.1,\v!strut] % 10 pct tolerance
-\definegridsnapping[\v!tolerant:20] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut] % 20 pct tolerance
-\definegridsnapping[\v!tolerant:30] [\v!maxdepth:1.3,\v!maxheight:1.3,\v!strut] % 30 pct tolerance
-\definegridsnapping[\v!tolerant:40] [\v!maxdepth:1.4,\v!maxheight:1.4,\v!strut] % 40 pct tolerance
-
-\definegridsnapping[\v!top] [\v!minheight,\v!maxdepth,\v!strut]
-\definegridsnapping[\v!bottom] [\v!maxheight,\v!mindepth,\v!strut]
-\definegridsnapping[\v!both] [\v!minheight,\v!mindepth,\v!strut]
-
-\definegridsnapping[\v!broad] [\v!maxheight,\v!maxdepth,\v!strut,0.8] % maybe 0.85
-\definegridsnapping[\v!fit] [\v!maxheight,\v!maxdepth,\v!strut,1.2] % tight 0.15
-
-\definegridsnapping[\v!first] [\v!first]
-\definegridsnapping[\v!last] [\v!last]
-\definegridsnapping[\v!high] [\v!minheight,\v!maxdepth,\v!none]
-\definegridsnapping[\v!one] [\v!minheight,\v!mindepth]
-\definegridsnapping[\v!low] [\v!maxheight,\v!mindepth,\v!none]
-\definegridsnapping[\v!none] [\v!none]
-\definegridsnapping[\v!line] [\v!line]
-\definegridsnapping[\v!strut] [\v!strut]
-\definegridsnapping[\v!box] [\v!box]
-\definegridsnapping[\v!min] [\v!min]
-\definegridsnapping[\v!max] [\v!max]
-
-\definegridsnapping[\v!middle] [\v!maxheight,\v!maxdepth] % used in placement
-
-\definegridsnapping[\v!math] [\v!maxdepth:1.05,\v!maxheight:1.05,\v!strut] % experimental, maybe 1.1
-\definegridsnapping[\v!math:\v!line] [\v!math,\v!line,\v!split]
-\definegridsnapping[\v!math:\v!halfline] [\v!math,\v!halfline,\v!split]
-\definegridsnapping[\v!math:-\v!line] [\v!math,-\v!line,\v!split]
-\definegridsnapping[\v!math:-\v!halfline][\v!math,-\v!halfline,\v!split]
-
-\unexpanded\def\synchronizelocallinespecs
- {\bodyfontlineheight \normallineheight
- \bodyfontstrutheight\strutht
- \bodyfontstrutdepth \strutdp}
-
-\unexpanded\def\synchronizegloballinespecs
- {\global\globalbodyfontlineheight \normallineheight
- \global\globalbodyfontstrutheight\strutht
- \global\globalbodyfontstrutdepth \strutdp}
-
-\appendtoks
- \synchronizegloballinespecs
- \synchronizelocallinespecs
-\to \everysetupglobalinterlinespace
-
-\appendtoks
- \synchronizelocallinespecs
-\to \everysetuplocalinterlinespace
-
-%D We still have to synchronize these:
-
-\unexpanded\def\synchronizeskipamounts
- {\bigskipamount
- \skipfactor\baselineskip
- \s!plus\skipgluefactor\baselineskip
- \s!minus\skipgluefactor\baselineskip
- \relax
- \medskipamount \bigskipamount \divide\medskipamount \plustwo
- \smallskipamount\bigskipamount \divide\smallskipamount\plusfour}
-
-%D Snapping.
-
-\newif\ifgridsnapping
-
-%unexpanded\def\moveongrid {\dosingleempty\spac_grids_move_on}
-\unexpanded\def\snaptogrid {\dosingleempty\spac_grids_snap_to}
-\unexpanded\def\placeongrid{\dosingleempty\spac_grids_place_on}
-
-\unexpanded\def\startgridsnapping
- {\dosingleempty\spac_grids_start_snapping}
-
-\unexpanded\def\spac_grids_start_snapping[#1]%
- {\snaptogrid[#1]\vbox\bgroup}
-
-\unexpanded\def\stopgridsnapping
- {\egroup}
-
-% \def\spac_grids_move_on[#1]%
-% {[obsolete]} % gone, unless we set an attribute
-
-\def\spac_grids_place_on[#1]%
- {\snaptogrid[#1]\vbox} % mark as done
-
-\def\spac_grids_snap_to[#1]% list or predefined
- {\ifgridsnapping
- \expandafter\spac_grids_snap_to_indeed
- \else
- \expandafter\gobbleoneargument
- \fi{#1}}
-
-\def\spac_grids_snap_to_indeed#1%
- {\bgroup
- \spac_grids_snap_value_reset
- \dowithnextbox{\spac_grids_snap_to_finish{#1}}}
-
-% eventually there will always be a line snap
-
-\def\spac_grids_snap_to_finish#1%
- {\ifvbox\nextbox % this will go away
- \clf_vspacingcollapse\nextbox\relax % isn't that already done?
- \fi
- \doifelsenothing{#1}{\spac_grids_snap_value_set\v!normal}{\spac_grids_snap_value_set{#1}}%
- \clf_vspacingsnap\nextbox\attribute\snapmethodattribute\relax
- \ifvbox\nextbox\vbox\else\hbox\fi attr \snapmethodattribute \zerocount {\box\nextbox}% no pack (?), we snap
- \egroup}
-
-\def\spac_grids_check_nop
- {\gridsnappingfalse
- \resetsystemmode\v!grid
- \spac_grids_snap_value_reset}
-
-\def\spac_grids_check_yes
- {\gridsnappingtrue
- \setsystemmode\v!grid
- \spac_grids_snap_value_set\askedgridmode}
-
-\unexpanded\def\synchronizegridsnapping
- {\edef\askedgridmode{\layoutparameter\c!grid}%
- \ifx\askedgridmode\v!no % official
- \spac_grids_check_nop
- \orelse\ifx\askedgridmode\v!off % for taco and luigi
- \spac_grids_check_nop
- \orelse\ifx\askedgridmode\empty % to be sure
- \spac_grids_check_nop
- \else
- \spac_grids_check_yes
- \fi}
-
-\unexpanded\def\setupgridsnapping[#1]% less overhead than setuplayout (needs testing)
- {\setlayoutparameter\c!grid{#1}\synchronizegridsnapping}
-
-\unexpanded\def\checkgridmethod#1%
- {\edef\p_grid{#1}%
- \ifx\p_grid\empty
- \let\checkedgridmethod\empty
- \let\checkedgridscope \v!local
- \else
- \splitatcolon\p_grid\checkedgridscope\checkedgridmethod
- \ifx\checkedgridmethod\empty
- \ifx\checkedgridscope\v!local\orelse\ifx\checkedgridscope\v!global\else
- \let\checkedgridmethod\checkedgridscope
- \let\checkedgridscope \v!local
- \fi
- \fi
- \fi}
-
-\unexpanded\def\applygridmethod#1#2#3% content localsettings (used in head rendering)
- {\checkgridmethod{#1}%
- \ifx\checkedgridscope\v!global
- \ifx\checkedgridmethod\empty \else
- % we assume that the call is grouped because grouping here has the side
- % effect that the eventually constructed line will get the value outside
- % the group
- %
- % overkill: \setupgridsnapping[\checkedgridmethod]%
- % maybe : \spac_grids_snap_value_auto\checkedgridmethod
- \spac_grids_snap_value_set\checkedgridmethod
- \fi
- \hbox{#3}%
- \else
- % the extra hbox will trigger the global snapper on top of the local and
- % we really need that in this case (compatibility etc etc) so here we don't
- % het an already done hit (otherwise we would not snap)
- \hbox\bgroup
- \ifx\checkedgridmethod\empty\orelse\ifconditional\headisdisplay
- #2%
- \fi
- \snaptogrid[\checkedgridmethod]\hbox{#3}%
- \egroup
- \fi}
-
-\unexpanded\gdef\page_layouts_calculate_overshoot
- {\ifgridsnapping\ifcase\layoutlines
- \getnoflines\textheight
- \textovershoot\dimexpr\noflines\globalbodyfontlineheight-\textheight\relax
- \fi\fi}
-
-\unexpanded\def\page_layouts_report_overshoot
- {\page_layouts_calculate_overshoot
- \ifdim\textovershoot>\zeropoint
- \writestatus\m!layouts{gridmode,\space
- noflines: \the\noflines,\space
- textheight: \the\textheight,\space
- textovershoot: \the\textovershoot\space
- (maybe set number of lines instead)%
- }%
- \fi
- \glet\page_layouts_report_overshoot\page_layouts_calculate_overshoot}
-
-\appendtoks
- \page_layouts_report_overshoot
-\to \everybeforepagebody
-
-%D Visualization:
-
-\definepalet
- [grid]
- [ one=red,
- two=green,
- three=blue,
- four=gray]
-
-\unexpanded\def\setgridtracebox#1[#2]% % maybe reverse the order
- {\setbox\nextbox#1%
- {\hbox
- {\hbox to \zeropoint
- {\setlayoutcomponentattribute{\v!grid:\v!test}%
- \color[grid:#2]{\ruledhbox \layoutcomponentboxattribute {\fakebox\nextbox}}%
- \hss}%
- \flushnextbox}}}
-
-\setnewconstant\gridboxlinenomode\plusone % 0:nothing 1:all 2:lines 3:frame 4:l/r
-\setnewconstant\gridboxlinemode \plusone
-
-\unexpanded\def\gridboxvbox
- {\ifcase\gridboxlinemode
- \vpack
- \or
- \ruledvpack
- \or
- \vpack
- \or
- \ruledvpack
- \else
- \ruledvpack
- \fi}
-
-\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\linewidth}
-
-\unexpanded\def\setgridbox#1#2#3% maybe ifgridsnapping at outer level
- {\setbox#1\gridboxvbox to #3 % given size
- {\forgetall
- \resetvisualizers
- \resetteststrut
- \offinterlineskip
- \hsize#2%
- \ifcase\gridboxlinenomode\or\or\or
- \gridboxlinenomode\doifoddpageelse\plusone\plustwo % 3: outer
- \or
- \gridboxlinenomode\doifoddpageelse\plustwo\plusone % 4: inner
- \fi
- \topskipcorrection
- \gridboxvbox % calculated size
- {\getrawnoflines{#3}% \getnoflines{#3}%
- \scratchdimen\dimexpr#2+\lineheight\relax
- \dorecurse\noflines
- {\strut
- \hskip-.5\lineheight\relax
- \ifcase\gridboxlinenomode\or
- \rlap
- {\hskip\dimexpr.2\bodyfontsize+\scratchdimen\relax
- \infofont\hbox to \emwidth{\hss\recurselevel}}%
- \or
- \llap
- {\infofont\hbox to \emwidth{\hss\recurselevel}%
- \hskip.2\bodyfontsize}%
- \fi
- \vrule
- \s!height \gridboxwidth
- \s!depth \gridboxwidth
- \s!width \scratchdimen
- \par}}
- \vfill}}
-
-%D This has become obsolete:
-
-\def\fuzzysnappedbox#1#2% \box \unvbox
- {#1#2}
-
-\def\moveboxontogrid#1#2#3% will become obsolete, but it needs checking
- {}
-
-%D Helper:
-
-\unexpanded\def\spac_helpers_assign_skip#1#2% ook nog \v!halfline+fuzzysnap
- {\doifelse{#2}\v!line
- {#1\ifgridsnapping
- \bodyfontlineheight
- \else
- \openlineheight
- \fi}
- {\ifgridsnapping
- \assigndimension{#2}{#1}{.25\bodyfontlineheight}{.5\bodyfontlineheight}\bodyfontlineheight
- \else
- \assigndimension{#2}{#1}\smallskipamount\medskipamount\bigskipamount
- \fi}%
- \relax}
-
-% \start \dosetstretch{.25em} \setuptolerance[tolerant,stretch] \input tufte \endgraf \stop
-% \start \dosetstretch{.5em} effe flink doorfietsen \stop
-
-% experimental code, not yet interfaced:
-
-% category:
-%
-% 0 == discard discard
-% 1 == only if larger largest
-% 2 == force even if smaller force
-% 3 == only take penalty component penalty
-% 4 == add to existing skip add
-% 5 == disable (ignore following) disable
-% 6 == kill whitespace nowhite
-% 7 == discard previous back
-% 10 == no topskip
-%
-% penalty: larger wins
-% order: larger wins
-% category:2,order:5,penalty:10000,skip:value|kw
-%
-% \defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi}
-
-% todo, in grid mode: builders.vspacing.fixed = false
-%
-% \ifgridsnapping will go
-
-\installcorenamespace{vspacingamount}
-
-\unexpanded\def\definevspacingamount
- {\dotripleempty\spac_vspacing_define_amount}
-
-\def\spac_vspacing_define_amount[#1][#2][#3]% can be combined
- {\ifthirdargument
- \setvalue{\??vspacingamount#1}{\ifgridsnapping#3\else#2\fi}%
- \orelse\ifsecondargument
- \setvalue{\??vspacingamount#1}{\ifgridsnapping\lineheight\else#2\fi}%
- \else
- \setvalue{\??vspacingamount#1}{\lineheight}%
- \fi
- \clf_vspacingsetamount{#1}}
-
-\def\spac_vspacing_no_topskip % use grouped
- {\attribute\skipcategoryattribute\plusten}
-
-% \installcorenamespace{vspacingamountnormal}
-% \installcorenamespace{vspacingamountgrid}
-
-% \def\spac_vspacing_define_amount[#1][#2][#3]% can be combined
-% {\ifcsname n>#1\endcsname\else
-% \expandafter\newtoks\csname n>#1\endcsname
-% \expandafter\newtoks\csname g>#1\endcsname
-% \fi
-% \csname n>#1\endcsname{#2}%
-% \csname g>#1\endcsname{#3}%
-% \clf_vspacingsetamount{#1}}
-
-\unexpanded\def\definevspacing
- {\dodoubleempty\spac_vspacing_define}
-
-\def\spac_vspacing_define[#1][#2]%
- {\clf_vspacingdefine{#1}{#2}}
-
-%D The injector code (generated at the \LUA\ end):
-
-\newtoks\everybeforeblankhandling
-\newtoks\everyafterblankhandling
-
-\newconditional\c_space_vspacing_done
-\newconditional\c_space_vspacing_fixed
-\newconditional\c_space_ignore_parskip
-
-\appendtoks
- \s_spac_vspacing_temp\zeropoint
- \attribute\skipcategoryattribute\plusone
- \attribute\skippenaltyattribute \attributeunsetvalue
- \attribute\skiporderattribute \attributeunsetvalue
- \ifgridsnapping
- \settrue\c_space_vspacing_fixed
- \else
- \setfalse\c_space_vspacing_fixed
- \fi
-\to \everybeforeblankhandling
-
-\appendtoks
- \s_spac_vspacing_temp\plusone\s_spac_vspacing_temp
- \ifconditional\c_space_vspacing_fixed \else
- \s!plus \skipgluefactor\s_spac_vspacing_temp
- \s!minus\skipgluefactor\s_spac_vspacing_temp
- \fi
- \relax
-\to \everyafterblankhandling
-
-\unexpanded\def\setblankpacked
- {\settrue\c_space_ignore_parskip}
-
-\unexpanded\def\setblankcategory#1%
- {\settrue\c_space_vspacing_done
- \attribute\skipcategoryattribute#1\relax}
-
-\unexpanded\def\setblankorder#1%
- {\attribute\skiporderattribute#1\relax}
-
-\unexpanded\def\fixedblankskip
- {\settrue\c_space_vspacing_fixed}
-
-\unexpanded\def\flexibleblankskip
- {\setfalse\c_space_vspacing_fixed}
-
-% \unexpanded\def\addblankskip#1#2#3%
-% {\settrue\c_space_vspacing_done
-% \advance\s_spac_vspacing_temp#1\dimexpr\ifgridsnapping#3\else#2\fi\relax\relax}
-
-\unexpanded\def\setblankpenalty#1%
- {\flushblankhandling
- \settrue\c_space_vspacing_done
- \attribute\skipcategoryattribute \plusthree
- \attribute\skippenaltyattribute #1\relax
- \flushblankhandling}
-
-\unexpanded\def\startblankhandling % move this to \vspacing
- {\par
- \ifvmode
- \expandafter\dostartblankhandling
- \else
- \expandafter\nostartblankhandling
- \fi}
-
-\unexpanded\def\nostartblankhandling#1\stopblankhandling
- {}
-
-\def\dostartblankhandling
- {\begingroup
- \setfalse\c_space_vspacing_done
- \setfalse\c_space_ignore_parskip
- \the\everybeforeblankhandling}
-
-\unexpanded\def\stopblankhandling
- {\the\everyafterblankhandling
- \ifconditional\c_space_vspacing_done
- \vskip\s_spac_vspacing_temp
- \fi
- \ifconditional\c_space_ignore_parskip
- \endgroup\ignoreparskip
- \else
- \endgroup
- \fi}
-
-\unexpanded\def\flushblankhandling
- {\the\everyafterblankhandling
- \ifconditional\c_space_vspacing_done
- \vskip\s_spac_vspacing_temp
- \fi
- \setfalse\c_space_vspacing_done
- \the\everybeforeblankhandling}
-
-\unexpanded\def\addpredefinedblankskip#1#2%
- {\settrue\c_space_vspacing_done
- \advance\s_spac_vspacing_temp#1\dimexpr\csname\??vspacingamount#2\endcsname\relax}
-
-% \unexpanded\def\addpredefinedblankskip#1#2%
-% {\settrue\c_space_vspacing_done
-% \advance\s_spac_vspacing_temp#1\dimexpr\the\csname\ifgridsnapping g\else n\fi>#2\endcsname\relax}
-
-\unexpanded\def\addaskedblankskip#1#2%
- {\settrue\c_space_vspacing_done
- \advance\s_spac_vspacing_temp#1\dimexpr#2\relax}
-
-% The main spacer:
-
-\unexpanded\def\vspacing
- {\doifelsenextoptionalcs\spac_vspacing_yes\spac_vspacing_nop}
-
-\def\spac_vspacing_yes
- {\ifinpagebody % somewhat weird
- \expandafter\spac_vspacing_yes_indeed
- \orelse\ifconditional\c_spac_packed_blank
- \expandafter\spac_vspacing_yes_indeed
- \else
- \expandafter\spac_vspacing_yes_ignore
- \fi}
-
-\def\spac_vspacing_nop
- {\ifinpagebody % somewhat weird
- \expandafter\spac_vspacing_nop_indeed
- \orelse\ifconditional\c_spac_packed_blank
- \expandafter\spac_vspacing_nop_indeed
- \else
- \expandafter\spac_vspacing_nop_ignore
- \fi}
-
-\def\spac_vspacing_yes_indeed[#1]%
- {\ifmmode\else\par\clf_vspacing{#1}\fi}
-
-\def\spac_vspacing_yes_ignore[#1]%
- {\ifmmode\else\par\fi}
-
-\def\spac_vspacing_nop_indeed
- {\ifmmode\else\par\clf_vspacing{\currentvspacing}\fi}
-
-\def\spac_vspacing_nop_ignore
- {\ifmmode\else\par\fi}
-
-\installcorenamespace{vspacing}
-
-\unexpanded\def\directvspacing#1%
- {\par
- \ifchkdim#1\or
- \spac_vspacing_dim_preset{\the\dimexpr#1}%
- \orelse\ifcsname\??vspacing#1\endcsname
- \lastnamedcs
- \else
- \spac_vspacing_yes_preset{#1}%
- \fi}
-
-\def\spac_vspacing_dim_preset#1%
- {\ifcsname\??vspacing#1\endcsname
- \lastnamedcs
- \else
- \spac_vspacing_yes_preset{#1}%
- \fi}
-
-\def\spac_vspacing_yes_preset#1%
- {\setxvalue{\??vspacing#1}{\clf_vspacing{#1}}%
- %\writestatus{}{}%
- %\writestatus{#1}{\expandafter\meaning\csname\??vspacing#1\endcsname}%
- %\writestatus{}{}%
- \csname\??vspacing#1\endcsname}
-
-\def\spac_vspacing_yes_indeed[#1]%
- {\ifmmode\else
- \directvspacing{#1}%
- \fi}
-
-\def\spac_vspacing_nop_indeed
- {\ifmmode\else
- \directvspacing\currentvspacing
- \fi}
-
-\def\directdefaultvspacing
- {\ifinpagebody % somewhat weird
- \directvspacing\currentvspacing
- \orelse\ifconditional\c_spac_packed_blank
- \directvspacing\currentvspacing
- \fi}
-
-\def\directcheckedvspacing
- {\ifinpagebody % somewhat weird
- \expandafter\directvspacing
- \orelse\ifconditional\c_spac_packed_blank
- \expandafter\directvspacing
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\useblankparameter#1% faster local variant
- {\edef\m_spac_blank_asked{#1\c!blank}%
- \ifx\m_spac_blank_asked\empty\else
- \directvspacing\m_spac_blank_asked
- \fi}
-
-%D Handy (and faster):
-
-\unexpanded\def\directvpenalty#1%
- {\begingroup
- \attribute\skipcategoryattribute \plusthree
- \attribute\skippenaltyattribute #1\relax
- \attribute\skiporderattribute \attributeunsetvalue
- \vskip\zeropoint
- \endgroup}
-
-\unexpanded\def\directvskip#1%
- {\begingroup
- \attribute\skipcategoryattribute \plusone
- \attribute\skippenaltyattribute \attributeunsetvalue
- \attribute\skiporderattribute \attributeunsetvalue
- \vskip#1\relax
- \endgroup}
-
-%D These depend on bigskipamount cum suis so we'd better sync them:
-
-\unexpanded\def\setupvspacing
- {\doifelsenextoptionalcs\setupvspacing_yes\setupvspacing_nop}
-
-\let\currentvspacing\s!default % hm, default, standard ...
-
-\def\setupvspacing_yes[#1]%
- {\edef\currentvspacing{#1}%
- \spac_whitespace_setup_nop % yes or no, was forgotten
- }
-
-\def\setupvspacing_nop
- {\ifx\empty\currentvspacing % mistakenly had an \else
- \let\currentvspacing\s!default
- \fi
- \spac_whitespace_setup_nop}
-
-\unexpanded\def\restorestandardblank % or default ?
- {\let\currentvspacing\v!standard}
-
-\let\synchronizevspacing\setupvspacing_nop
-
-%D The \type {category:4} is default.
-
-\definevspacingamount[\v!none] [\zeropoint] [\zeropoint]
-\definevspacingamount[\v!big] [\bigskipamount] [\bodyfontlineheight]
-\definevspacingamount[\v!medium] [\medskipamount] [.5\bodyfontlineheight]
-\definevspacingamount[\v!small] [\smallskipamount] [.25\bodyfontlineheight]
-\definevspacingamount[\v!line] [\openlineheight] [\bodyfontlineheight]
-\definevspacingamount[\v!halfline] [.5\openlineheight] [.5\bodyfontlineheight]
-\definevspacingamount[\v!quarterline] [.25\openlineheight] [.25\bodyfontlineheight]
-\definevspacingamount[\v!formula] [\medskipamount] [.5\bodyfontlineheight]
-\definevspacingamount[\v!white] [\parskip] [\bodyfontwhitespace]
-\definevspacingamount[\v!height] [\strutht] [\bodyfontstrutheight]
-\definevspacingamount[\v!depth] [\strutdp] [\bodyfontstrutdepth]
-
-\definevspacingamount[\v!standard] [.75\openlineheight] [.75\openlineheight] % mkii compatible
-
-\def\bodyfontwhitespace
- {\dimexpr
- \ifzeropt\parskip
- \zeropoint
- \orelse\ifgridsnapping
- \bodyfontlineheight
- \else
- \parskip
- \fi
- \relax}
-
-%D used in itemize \unknown\ always test this:
-
-\newdimen\d_spac_overlay
-
-\def\spac_overlay_lines
- {\directcheckedvspacing{\v!back,\v!overlay}% \blank[\v!back,\v!overlay]%
- \nointerlineskip}
-
-% \startitemize[n]
-% \item \input zapf
-% \item \startitemize[a]
-% \item \input knuth
-% \stopitemize
-% \stopitemize
-%
-% \strut \hfill first line \blank[overlay] second line \hfill \strut
-%
-% \ruledvbox {
-% \strut \hfill line 1 \blank[overlay]
-% line 2 \hfill \strut \blank[overlay]
-% \strut \hfill line 3 \hfill \strut
-% }
-%
-% \dorecurse{50}
-% {\startitemize[n] \startitem \startitemize[a] \item #1 \stopitemize \stopitem \stopitemize}
-
-\definevspacing[\v!preference][penalty:-500] % goodbreak
-\definevspacing[\v!samepage] [penalty:10000] % nobreak
-
-\definevspacing[\v!always] [category:0] % hm, internally it's discard
-\definevspacing[\v!max] [category:1]
-\definevspacing[\v!force] [category:2]
-\definevspacing[\v!disable] [category:5]
-\definevspacing[\v!nowhite] [category:6]
-\definevspacing[\v!back] [category:7]
-\definevspacing[\v!packed] [category:8] % noparskip (kind of special)
-\definevspacing[\v!overlay] [category:9]
-\definevspacing[\v!enable] [category:10]
-
-%definevspacing[\v!noparskip] [category:8]
-%definevspacing[\v!notopskip] [category:11]
-
-\definevspacing[\v!weak] [order:0]
-\definevspacing[\v!strong] [order:100]
-
-\definevspacing[\s!default] [\v!white] % was big for a while
-
-\newcount\c_spac_vspacing_special_base \c_spac_vspacing_special_base = 32250 % 4000
-\newcount\c_spac_vspacing_special_step \c_spac_vspacing_special_step = 10 % 250
-\newcount\c_spac_vspacing_special_done
-
-% 2019-05-31 : upgraded a bit to more distinctive samepage-[level]-[0|1|2] names
-
-\unexpanded\def\spac_vspacing_define_same_step#1#2% alternatively we could have samepage-n-m
- {\begingroup
- \scratchcounterone\numexpr\plusthree*#1+#2\relax
- \scratchcountertwo\numexpr\c_spac_vspacing_special_base+\c_spac_vspacing_special_step*\scratchcounterone\relax
- %\writestatus{defined}{\v!samepage-\number#1-\number#2\space=>\space penalty:\the\scratchcountertwo}%
- \normalexpanded{\definevspacing[\v!samepage-\number#1-\number#2][penalty:\the\scratchcountertwo]}%
- \endgroup}
-
-\unexpanded\def\spac_vspacing_define_same_page#1%
- {\dostepwiserecurse\c_spac_vspacing_special_done{#1}\plusone
- {\spac_vspacing_define_same_step\recurselevel\zerocount % before
- \spac_vspacing_define_same_step\recurselevel\plusone % after
- \spac_vspacing_define_same_step\recurselevel\plustwo}% % whatever
- \global\c_spac_vspacing_special_done#1\relax}
-
-\spac_vspacing_define_same_page{12} % 12 levels should be more than enough as a start
-
-\def\spac_vspacing_same_page#1#2% level offset (starts at 0)
- {\ifnum#1>\c_spac_vspacing_special_done
- \spac_vspacing_define_same_page{#1}%
- \fi
- %\writestatus{used}{\v!samepage-\number#1-\number#2}%
- \vspacing[\v!samepage-\number#1-\number#2]}
-
-\definevspacing[\v!default] [\v!big] % todo: needs to adapt to \setupblank
-\definevspacing[\v!before] [\v!default] % but we need to avoid circular references
-\definevspacing[\v!inbetween][\v!default] % then
-\definevspacing[\v!after] [\v!before]
-
-\setupvspacing
- [\v!big] % alternatively [\v!standard]
-
-%D Maybe at some point we will differ between \type {\vspacing} and \type {\blank}
-%D (we needed the first one while playing with the new code).
-
-% We keep this one as reference
-%
-% \unexpanded\def\inhibitblank
-% {\vspacing[\v!disable]}
-%
-% but use the following more efficient variant instead:
-
-\unexpanded\def\inhibitblank
- {\ifvmode
- \begingroup
- \attribute\skipcategoryattribute\plusfive
- \vskip\zeropoint
- \endgroup
- \fi}
-
-\let\doinhibitblank\inhibitblank % keep this command, used in styles
-
-\let\defineblank \definevspacing
-\let\setupblank \setupvspacing
-\let\blank \vspacing
-\let\synchronizeblank \synchronizevspacing
-\let\defineblankmethod\definevspacingamount
-
-%D The following command is for Wolfgang. It has to be used with care as it does
-%D {\em not} work in tandem with the other spacing commands.
-
-\installcorenamespace{vspace}
-
-\unexpanded\def\definevspace
- {\dotripleempty\spac_vspace_define}
-
-\def\spac_vspace_define[#1][#2][#3]%
- {\ifthirdargument
- \setvalue{\??vspace#1:#2}{#3}%
- \else
- \setvalue{\??vspace:#1}{#2}%
- \fi}
-
-\letvalue{\??vspace:\s!unknown}\zeropoint
-
-\unexpanded\def\vspace
- {\dodoubleempty\spac_vspace_inject}
-
-\def\spac_vspace_unknown
- {\csname\??vspace:\s!unknown\endcsname}
-
-\def\spac_vspace_inject[#1][#2]% use \lastnamedcs
- {\par
- \ifvmode
- \removelastskip
- \vskip
- \ifsecondargument
- \ifcsname\??vspace#1:#2\endcsname
- \lastnamedcs
- \orelse\ifcsname\??vspace:#2\endcsname
- \lastnamedcs
- \else
- \spac_vspace_unknown
- \fi
- \orelse\iffirstargument
- \ifcsname\??vspace:#1\endcsname
- \lastnamedcs
- \else
- \spac_vspace_unknown
- \fi
- \else
- \ifcsname\??vspace:\s!default\endcsname
- \lastnamedcs
- \else
- \spac_vspace_unknown
- \fi
- \fi
- \relax
- \fi}
-
-%D Some preliminary code: a simple and fast hanger, for usage in macros.
-
-\installcorenamespace {hanging}
-
-\installdirectcommandhandler \??hanging {hanging}
-
-\setuphanging
- [\c!distance=.5\emwidth,
- \c!location=\v!left,
- \c!n=\zerocount]
-
-\unexpanded\def\starthanging
- {\dontleavehmode\bgroup
- \dosingleempty\spac_hanging_start}
-
-\unexpanded\def\stophanging
- {\endgraf
- \egroup}
-
-\let\m_spac_hanging_location\empty
-
-\def\spac_hanging_start[#1]%
- {\doifelseassignment{#1}
- {\let\m_spac_hanging_location\empty
- \setupcurrenthanging[#1]}%
- {\edef\m_spac_hanging_location{#1}}%
- \ifx\m_spac_hanging_location\empty
- \edef\m_spac_hanging_location{\directhangingparameter\c!location}%
- \fi
- \dowithnextboxcs\spac_hanging_finish\hbox}
-
-\def\spac_hanging_finish
- {\scratchdistance\directhangingparameter\c!distance\relax
- \ifdim\ht\nextbox>\strutht
- \setbox\nextbox\tbox{\box\nextbox}%
- \fi
- \scratchcounter\directhangingparameter\c!n\relax
- \ifnum\scratchcounter>\zerocount
- \hangafter-\scratchcounter
- \else
- \getboxheight\scratchdimen\of\box\nextbox
- \getnoflines\scratchdimen
- \hangafter-\noflines
- \fi
- \ht\nextbox\strutht
- \dp\nextbox\strutdp
- \scratchwidth\dimexpr\wd\nextbox+\scratchdistance\relax
- \ifx\m_spac_hanging_location\v!right
- \hangindent\ifconditional\displaylefttoright-\fi\scratchwidth
- \rlap{\hskip\dimexpr\hsize-\leftskip-\wd\nextbox\relax\box\nextbox}% \leftskip is new
- \else
- \hangindent\ifconditional\displaylefttoright\else-\fi\scratchwidth
- \llap{\box\nextbox\hskip\scratchdistance}%
- \fi
- \ignorespaces}
-
-
-%D \macros
-%D {startfixed}
-%D
-%D \starttyping
-%D \startitemize
-%D \startitem \externalfigure[cow][height=1cm] \stopitem
-%D \startitem \externalfigure[cow][height=1cm] \stopitem
-%D
-%D \startitem \startfixed \externalfigure[cow][height=1cm]\stopfixed \stopitem
-%D \startitem \startfixed[high]\externalfigure[cow][height=1cm]\stopfixed \stopitem
-%D \startitem \startfixed[low] \externalfigure[cow][height=1cm]\stopfixed \stopitem
-%D \startitem \startfixed[lohi]\externalfigure[cow][height=1cm]\stopfixed \stopitem
-%D
-%D \startitem test \par \startfixed \externalfigure[koe][height=1cm]\stopfixed \stopitem
-%D \startitem test \par \startfixed[high]\externalfigure[koe][height=1cm]\stopfixed \stopitem
-%D \startitem test \par \startfixed[low] \externalfigure[koe][height=1cm]\stopfixed \stopitem
-%D \startitem test \par \startfixed[lohi]\externalfigure[koe][height=1cm]\stopfixed \stopitem
-%D \stopitemize
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\installcorenamespace{fixedalternatives}
-
-\unexpanded\def\startfixed
- {\bgroup
- \dosingleempty\typo_fixed_start}
-
-\def\typo_fixed_start
- {\ifhmode
- \expandafter\typo_fixed_start_h
- \else
- \expandafter\typo_fixed_start_v
- \fi}
-
-\def\typo_fixed_start_h[#1]%
- {\let\stopfixed\typo_fixed_stop_h
- \dowithnextbox{\typo_fixed_finish{#1}}%
- \vbox\bgroup
- %ignorespaces
- \setlocalhsize}
-
-\unexpanded\def\typo_fixed_stop_h
- {%removeunwantedspaces
- \egroup
- \egroup}
-
-\def\typo_fixed_start_v[#1]%
- {\let\stopfixed\typo_fixed_stop_v
- \startbaselinecorrection}
-
-\unexpanded\def\typo_fixed_stop_v
- {\stopbaselinecorrection
- \egroup}
-
-\letvalue{\??fixedalternatives \v!high}\bbox
-\letvalue{\??fixedalternatives \v!low}\tbox
-\letvalue{\??fixedalternatives \v!middle}\vcenter
-\letvalue{\??fixedalternatives \v!lohi}\vcenter
-\letvalue{\??fixedalternatives\s!unknown}\tbox
-\letvalue{\??fixedalternatives\s!default}\tbox
-
-\unexpanded\def\typo_fixed_finish#1%
- {\expandnamespacevalue\??fixedalternatives{#1}\s!default{\box\nextbox}}
-
-% %D Forgotten already:
-%
-% \def\shapefill{\vskip\zeropoint\s!plus\lineheight\s!minus\lineheight\relax}
-
-%D Nasty:
-
-% \writestatus{1}{\the\prevdepth} \blank[force,5*big] { \writestatus{1}{\the\prevdepth} \baselineskip1cm xxxxxxxxx \par } \page
-% \writestatus{2}{\the\prevdepth} \blank[force,5*big] { \writestatus{2}{\the\prevdepth} \baselineskip1cm xxxxxxxxx \par } \page
-% \writestatus{3}{\the\prevdepth} \blank[force,5*big] { \writestatus{3}{\the\prevdepth} \baselineskip5cm xxxxxxxxx \par } \page
-% \writestatus{4}{\the\prevdepth} \input tufte \page
-% \writestatus{5}{\the\prevdepth} \input tufte \page
-% \writestatus{6}{\the\prevdepth} \blank[force,5*big] { \writestatus{6}{\the\prevdepth} \baselineskip1cm xxxxxxxxx \par } \page
-
-% \writestatus{1}{\the\prevdepth} \null\vskip4cm { \writestatus{1}{\the\prevdepth} \baselineskip1cm xxxxxxxxx \par } \page
-% \writestatus{2}{\the\prevdepth} \null\vskip4cm { \writestatus{2}{\the\prevdepth} \baselineskip1cm xxxxxxxxx \par } \page
-% \writestatus{3}{\the\prevdepth} \null\vskip4cm { \writestatus{3}{\the\prevdepth} \baselineskip5cm xxxxxxxxx \par } \page
-% \writestatus{4}{\the\prevdepth} \input tufte \page
-% \writestatus{5}{\the\prevdepth} \input tufte \page
-% \writestatus{6}{\the\prevdepth} \null\vskip4cm { \writestatus{6}{\the\prevdepth} \baselineskip1cm xxxxxxxxx \par } \page
-
-\appendtoks
- \ifvmode\prevdepth\zeropoint\fi % consistent, else first page -1000pt .. needed for fixed,3*big first/successive pages consistency
-\to \everystarttext
-
-\prevdepth\zeropoint
-
-%D Helper:
-
-\unexpanded\def\checkedblank[#1]%
- {\edef\p_blank{#1}%
- \ifx\p_blank\empty
- % ignore
- \orelse\ifx\p_blank\v!none
- % ignore
- \else
- \blank[\p_blank]%
- \fi}
-
-% \setupwhitespace[line]
-% \prerollblank[2*line] \the\prerolledblank
-% \prerollblank[-2*line] \the\prerolledblank
-
-\newskip\prerolledblank
-
-\unexpanded\def\prerollblank[#1]%
- {\begingroup
- \edef\p_blank{#1}%
- \ifx\p_blank\empty
- \global\prerolledblank\zeropoint
- \orelse\ifx\p_blank\v!none
- \global\prerolledblank\zeropoint
- \else
- % don't mess with \arskip here!
- \scratchskip\plusten\lineheight
- \setbox\scratchbox\vbox
- {\vskip\scratchskip
- \kern\zeropoint
- \blank[\p_blank]}%
- % \dimexpr doesn't work well with skips
- \advance\scratchskip-\ht\scratchbox
- \global\prerolledblank-\scratchskip
- \fi
- \endgroup}
-
-\newcount\c_spac_vspacing_ignore_parskip
-
-% \setupwhitespace[line]
-% \setuphead[subject][after={\blank[packed]},style=\bfb]
-% \subject{foo}
-% test \par
-% test \par
-% \blank[packed] % \ignoreparskip
-% test \par
-% test \par
-% \ignoreparskip
-% test \par
-% test \par
-% \setuphead[subject][after={\blank[nowhite]},style=\bfb]
-% \subject{foo}
-% test \par
-% test \par
-
-\unexpanded\def\ignoreparskip{\c_spac_vspacing_ignore_parskip\plusone}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf b/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf
index 01dde89ff97..e890fa88c93 100644
Binary files a/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf and b/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf differ
diff --git a/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf b/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf
index 105405cc41e..ffeb01fef65 100644
Binary files a/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf and b/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf differ
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-con.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-con.mkvi
index 8c75eb6df5e..81e28f67fd5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-con.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-con.mkvi
@@ -226,7 +226,7 @@
{\begingroup
\iftrialtypesetting \else
\currentconstructionsynchronize
- \attribute\destinationattribute\currentconstructionattribute\relax
+ \c_attr_destination\currentconstructionattribute\relax
\fi
#1%
\endgroup}
@@ -235,7 +235,7 @@
{\begingroup
\iftrialtypesetting \else
\currentconstructionsynchronize
- \attribute\destinationattribute\currentconstructionattribute\relax
+ \c_attr_destination\currentconstructionattribute\relax
\fi
\currentconstructiontext
\endgroup}
@@ -244,7 +244,7 @@
{\iftrialtypesetting \else
\begingroup
\currentconstructionsynchronize % reinstated
- \attribute\destinationattribute\currentconstructionattribute\relax % todo, whole text
+ \c_attr_destination\currentconstructionattribute\relax % todo, whole text
\signalcharacter
\endgroup
\fi#1}
@@ -418,6 +418,8 @@
%
\dostoptagged % tag
\dostarttagged\t!constructioncontent\empty
+ %\freezeparagraphproperties
+ \updateparagraphshapes
\ignorespaces} % args not needed
\unexpanded\setvalue{\??constructionstophandler\v!construction}%
@@ -433,7 +435,7 @@
\dorechecknextindentation}
\unexpanded\def\boxedconstructionhead#1%
- {\vtop
+ {\doifelse{\constructionalternativeparameter\c!alignbottom}{\v!yes}\vbox\vtop
{\hsize\constructionsheadwidth
\edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}%
\ifx\p_strc_constructions_headalign\empty \else
@@ -618,7 +620,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!left:\v!none]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\strc_constructions_set_pure_box\v!flushleft
\leftskip\dimexpr\leftconstructionskip+\constructionsheadwidth+\constructionsheaddistance\relax
@@ -644,7 +646,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!right:\v!none]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\leftskip\leftconstructionskip
\rightskip\dimexpr\rightconstructionskip+\constructionsheadwidth\relax
@@ -670,7 +672,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!left:\v!margin]%
- \let\\=\crlf
+ \let\\\crlf
\noindent
\strc_constructions_set_pure_box\v!flushleft
\llap {
@@ -685,7 +687,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!right:\v!margin]%
- \let\\=\crlf
+ \let\\\crlf
\noindent
\strc_constructions_set_pure_box\v!flushright
\rlap {
@@ -700,7 +702,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!left:\v!hanging]%
- \let\\=\crlf
+ \let\\\crlf
\dontcomplain
\advance\constructionsheadwidth \constructionsheaddistance
\strc_constructions_set_hang_box\v!flushleft
@@ -717,7 +719,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!right:\v!hanging]%
- \let\\=\crlf
+ \let\\\crlf
\dontcomplain
\advance\constructionsheadwidth \constructionsheaddistance
\strc_constructions_set_hang_box\v!flushright
@@ -738,7 +740,7 @@
\startsetups[\??constructionrenderings:\v!top]
% \strc_sectioning_prevent_page_break % commented per 31/5/2019
- \let\\=\space
+ \let\\\space
\noindent
\copy\constructionheadbox % why copy ?
\par
@@ -756,7 +758,7 @@
% why copy? historic reason?
\startsetups[\??constructionrenderings:\v!margin]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\inmargin[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
@@ -764,7 +766,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!leftmargin]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\inleft[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
@@ -772,7 +774,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!rightmargin]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\inright[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
@@ -780,7 +782,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!innermargin]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\ininner[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
@@ -788,7 +790,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!outermargin]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\inouter[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
@@ -818,7 +820,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!serried:\v!fit]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\flushconstructionheadbox
\nobreak
@@ -828,7 +830,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!serried:\v!broad]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\flushconstructionheadbox
\ifconditional\c_strc_constructions_distance_none \else
@@ -847,7 +849,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!serried:\v!wide]
- \let\\=\crlf
+ \let\\\crlf
\noindent
\hbox to \constructionsheadwidth {
\flushconstructionheadbox
@@ -861,7 +863,7 @@
\startsetups[\??constructionrenderings:\v!hanging]
% tricky: leftskipadaption is somewhat unpredictable
- \let\\=\crlf
+ \let\\\crlf
\noindent
\advance\leftskip-\leftskipadaption\relax
\ifdim\leftskipadaption=\zeropoint
@@ -919,6 +921,43 @@
\endgroup
\stopsetups
+\ifcase\contextlmtxmode \else
+ % just an empty check so that we can grep for contextlmtxmode in mkiv files
+\fi
+
+% \definedescription[whatever][alternative=right:bottom]
+%
+% \startwhatever{just a small\\example}
+% \input ward
+% \stopwhatever
+
+\defineconstructionalternative
+ [\v!right:\v!bottom]
+ [%\c!width=7em,
+ %\c!distance=1em,
+ \c!alignbottom=\v!yes,
+ \c!renderingsetup=\??constructionrenderings:\v!right:\v!bottom]
+
+\startsetups[\??constructionrenderings:\v!right:\v!bottom]
+ \let\\\crlf
+ \noindent
+ \leftskip\leftconstructionskip
+ \rightskip\dimexpr\rightconstructionskip+\constructionsheadwidth+\constructionsheaddistance\relax
+ \parfillskip\zeropoint
+ \strc_constructions_set_pure_box\v!flushright
+ \directparwrapper \relax {%
+ \hfilll
+ \rlap
+ {\kern\constructionsheaddistance
+ \copy\constructionheadbox}%
+ }%
+ \useconstructionstyleandcolor\c!style\c!color
+ \ignorespaces
+\stopsetups
+
+%D This next feature will get an lmtx implementation (probably by using a new generic
+%D close mechanism).
+
% you can use \placeclosesymbol or \qed to place a symbol at the end of a
% construction
@@ -1013,7 +1052,7 @@
\begingroup
\simplifycommands
\xdef\currentconstructionbookmark{\detokenize\expandafter{\normalexpanded{\constructionparameter\c!title}}}%
- \endgroup
+ \endgroup
\fi \fi
\fi
\ifx\currentconstructionlist\empty
@@ -1085,7 +1124,7 @@
\relax
% \writestatus{constructions}{registering \currentconstruction: \number\scratchcounter}%
\clf_setinternalreference
- prefix {\referenceprefix}%
+ prefix {\currentconstructionreferenceprefix}%
reference {\currentconstructionreference}%
internal \locationcount
view {\interactionparameter\c!focus}%
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-des.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-des.mkvi
index 76f878f5f03..5ae4c25eb97 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-des.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-des.mkvi
@@ -221,8 +221,8 @@
{\csname\??constructionstophandler \v!construction\endcsname\endgroup}}
\unexpanded\setvalue{\??constructionstarthandler\v!description}%
- {\BeforePar{\csname\??constructionstarthandler\v!construction\endcsname}%
- \GotoPar}
+ {\dogotopar
+ {\csname\??constructionstarthandler\v!construction\endcsname}}
\unexpanded\setvalue{\??constructionstophandler\v!description}%
{\csname\??constructionstophandler\v!construction\endcsname
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-doc.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-doc.lua
index 9877a0f9c0e..5cb207c38bf 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-doc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-doc.lua
@@ -1103,9 +1103,9 @@ implement { name = "namedstructureuservariable", actions = sections.userdata,
implement { name = "setstructurelevel", actions = sections.setlevel, arguments = "2 strings" }
implement { name = "getstructurelevel", actions = sections.getcurrentlevel, arguments = "string" }
implement { name = "setstructurenumber", actions = sections.setnumber, arguments = { "integer", "string" } } -- string as we support +-
-implement { name = "getstructurenumber", actions = sections.getnumber, arguments = { "integer" } }
+implement { name = "getstructurenumber", actions = sections.getnumber, arguments = "integer" }
implement { name = "getsomestructurenumber", actions = sections.getnumber, arguments = { "integer", "string" } }
-implement { name = "getfullstructurenumber", actions = sections.fullnumber, arguments = { "integer" } }
+implement { name = "getfullstructurenumber", actions = sections.fullnumber, arguments = "integer" }
implement { name = "getsomefullstructurenumber", actions = sections.fullnumber, arguments = { "integer", "string" } }
implement { name = "getspecificstructuretitle", actions = sections.structuredata, arguments = { "string", "'titledata.title'",false,"string" } }
@@ -1160,6 +1160,7 @@ implement {
{ "bookmark" },
{ "marking" },
{ "list" },
+ { "reference" },
}
},
{ "numberdata", {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-flt.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-flt.lua
index e3a0ea30edb..59c67efa1ad 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-flt.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-flt.lua
@@ -31,13 +31,13 @@ function builders.checksidefloat(mode,indented)
return indented
end
-appendaction ("newgraf","system","builders.checksidefloat")
-disableaction("newgraf","builders.checksidefloat")
+appendaction ("paragraph","system","builders.checksidefloat")
+disableaction("paragraph","builders.checksidefloat")
interfaces.implement {
name = "enablesidefloatchecker",
onlyonce = true,
actions = function()
- enableaction("newgraf","builders.checksidefloat")
+ enableaction("paragraph","builders.checksidefloat")
end,
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-flt.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-flt.mkvi
index d6a6723d7be..d9fd359c668 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-flt.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-flt.mkvi
@@ -211,7 +211,7 @@
\let\strc_floats_define_saved\definefloat
-\unexpanded\def\definefloat
+\unexpanded\overloaded\def\definefloat
{\dotripleempty\strc_floats_define}
\def\strc_floats_define[#1][#2][#3]% name+plural+parent | name+parent+settings
@@ -397,7 +397,7 @@
\glet\currentfloatsynchronize\m_strc_counters_last_registered_synchronize
%
% \iflocation
- % \attribute\destinationattribute\currentfloatattribute\relax
+ % \c_attr_destination\currentfloatattribute\relax
% \fi
\currentfloatsynchronize
\strc_floats_make_complete_caption
@@ -844,7 +844,8 @@
{\strc_floats_set_local_hsize
\floatparameter\c!inner
\postponenotes} % new
- {\dostoptagged
+ {\page_postprocessors_linenumbers_box\nextbox % for aditya
+ \dostoptagged
\strc_floats_finish_placement}
\vbox}
@@ -1229,7 +1230,7 @@
\let\doifoddpagefloatelse \doifelseoddpagefloat
\appendtoks
- \let\rightorleftpageaction\doifelserightpagefloat
+ \overloaded\frozen\let\rightorleftpageaction\doifelserightpagefloat
\to \everyinsidefloat
% \let\movesidefloat\gobbleoneargument
@@ -1623,7 +1624,7 @@
\setbox\b_strc_floats_caption\hbox % text
{\floatcaptionparameter\c!command{\box\b_strc_floats_caption}}%
\strc_floats_set_caption_dimensions\b_strc_floats_caption
- \moveboxontogrid\b_strc_floats_caption{\floatcaptionparameter\c!grid}\d_strc_floats_caption_height
+ %\moveboxontogrid\b_strc_floats_caption{\floatcaptionparameter\c!grid}\d_strc_floats_caption_height
%\page_backgrounds_add_local_to_box\b_strc_floats_caption
\strc_floats_build_box
\fi
@@ -2202,6 +2203,8 @@
{\box\floatbox}}}
% special purpose: used in floatcombinations
+%
+% todo : keep float content and caption separated in local
\newbox\b_strc_floats_separate_content
\newbox\b_strc_floats_separate_caption
@@ -2210,37 +2213,44 @@
{\settrue\c_floats_adapt_to_caption_width
\settrue\c_floats_store_minimal_package}
+% \def\strc_floats_build_box_separate_make
+% {\offinterlineskip
+% \vpack to \onepoint{\box\b_strc_floats_content}\break
+% \vpack to \onepoint{\box\b_strc_floats_caption}}
+
+%D Remark for \LMTX: we don't want to migrate inserts here so we unpack
+%D (could be a flag). When migrated, the inserts end up in the vertical
+%D list and we no longer have just a box (but inserts and lines again).
+
+% \def\strc_floats_build_box_separate_split#1%
+% {\setbox\scratchbox\vpack{#1}%
+% \setbox\scratchbox\vbox\bgroup
+% \unvpack\scratchbox
+% \setbox\scratchbox\lastbox % can have (unmigrated) inserts
+% \unvpack\scratchbox
+% \setbox\scratchbox\lastbox % can have (unmigrated) inserts
+% \unvpack\scratchbox
+% \setbox\scratchbox\lastbox % can have (unmigrated) inserts
+% \splittopskip\zeropoint
+% \global\setbox\b_strc_floats_separate_content\vsplit\scratchbox to \onepoint
+% \global\setbox\b_strc_floats_separate_caption\vsplit\scratchbox to \onepoint
+% \egroup
+% \global\setbox\b_strc_floats_separate_content\vpack
+% {\unvbox\b_strc_floats_separate_content
+% \setbox\scratchbox\lastbox
+% \unvbox\scratchbox}%
+% \global\setbox\b_strc_floats_separate_caption\tpack
+% {\unvbox\b_strc_floats_separate_caption
+% \setbox\scratchbox\lastbox
+% \unvbox\scratchbox}}
+
\def\strc_floats_build_box_separate_make
- {\offinterlineskip
- \vpack to \onepoint{\box\b_strc_floats_content}\break
- \vpack to \onepoint{\box\b_strc_floats_caption}}
-
-\def\strc_floats_build_box_separate_split#1%
- {\setbox\scratchbox\vbox\bgroup
- \setbox\scratchbox\vpack{#1}%
- \unvbox\scratchbox\relax
- \setbox\scratchbox\lastbox
- %\doloop{%
- \unvbox\scratchbox
- \setbox\scratchbox\lastbox
- % \ifdim\ht\scratchbox=2\onepoint
- \unvbox\scratchbox
- \setbox\scratchbox\lastbox
- % \exitloop
- % \fi
- %}%
- \splittopskip\zeropoint
- \global\setbox\b_strc_floats_separate_content\vsplit\scratchbox to \onepoint
- \global\setbox\b_strc_floats_separate_caption\vsplit\scratchbox to \onepoint
- \egroup
- \global\setbox\b_strc_floats_separate_content\vpack
- {\unvbox\b_strc_floats_separate_content
- \setbox\scratchbox\lastbox
- \unvbox\scratchbox}%
- \global\setbox\b_strc_floats_separate_caption\tpack
- {\unvbox\b_strc_floats_separate_caption
- \setbox\scratchbox\lastbox
- \unvbox\scratchbox}}
+ {\savebox\??localfloatstack{\number\numexpr\c_strc_localfloats_n+1\relax:a}{\box\b_strc_floats_content}%
+ \savebox\??localfloatstack{\number\numexpr\c_strc_localfloats_n+1\relax:b}{\box\b_strc_floats_caption}}
+
+\unexpanded\def\strc_floats_build_box_separate_split#1%
+ {\global\setbox\b_strc_floats_separate_content\vpack{\foundbox\??localfloatstack{\number#1:a}}%
+ \global\setbox\b_strc_floats_separate_caption\tpack{\foundbox\??localfloatstack{\number#1:b}}}
% \def\strc_floats_build_box_step#1%
% {\doifdefined{\??floatbuilder#1}{\def\floatcaptionarrangement{#1}\quitcommalist}}
@@ -2339,7 +2349,7 @@
\strc_floats_check_caption_content
\strc_floats_prepare_side_caption
\setbox\b_strc_floats_caption\hbox{\floatcaptionparameter\c!command{\box\b_strc_floats_caption}}% \hpack ?
- \moveboxontogrid\b_strc_floats_caption{\floatcaptionparameter\c!grid}\d_strc_floats_caption_height
+ %\moveboxontogrid\b_strc_floats_caption{\floatcaptionparameter\c!grid}\d_strc_floats_caption_height
%\page_backgrounds_add_local_to_box\b_strc_floats_caption
\strc_floats_build_side_box
\fi
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mklx b/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mklx
deleted file mode 100644
index 60fe3ee746a..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mklx
+++ /dev/null
@@ -1,1882 +0,0 @@
-%D \module
-%D [ file=strc-itm,
-%D version=2008.10.20,
-%D title=\CONTEXT\ Structure Macros,
-%D subtitle=Itemgroups,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Structure Macros / Itemgroups}
-
-\registerctxluafile{strc-itm}{}
-
-%D As we analyze/register widths and such we could as well push and pop the numbers
-%D at the \LUA\ end (which saves a few calls).
-%D
-%D Cleaning up this module happened around the time when Kate Bush came up with the
-%D nicest numbered list of words: 50 Words For Snow. It's therefore no surprise that
-%D I had that cd running several times when updating this code. One of the
-%D highlights of 2011.
-%D
-%D This module needs to be rewritten but that is tricky with respect to
-%D compatibilitity. Basically each major variant (regular, text, columns,
-%D horizontal, etc) needs to be on its own.
-
-% todo: check breaks
-% todo: check grouping
-% todo: fixedconversion
-
-% \startitemize[n,packed]
-% \item test \item test \item test
-% \stopitemize
-%
-% \startitemize[n,packed,reverse]
-% \item test \item test \item test
-% \stopitemize
-%
-% \startitemize[n,packed,reverse] \item test \item test \stopitemize
-% \startitemize[continue]
-% \item test \startitemize[n,packed] \item test \item test \stopitemize
-% \item test
-% \item test
-% \stopitemize
-% \startitemize[continue] \item test \stopitemize
-%
-% \startitemize[n,packed] \item test \item test \stopitemize
-% \startitemize[continue] \item test \stopitemize
-% \startitemize[continue] \item test \stopitemize
-%
-% \setupwhitespace[big]
-% \starttext
-% test \startitemize[joinedup] \item test \item test \stopitemize test \par
-% test \startitemize[joinedup,nowhite] \item test \item test \stopitemize test \par
-% test \startitemize[joinedup,nowhite,before] \item test \item test \stopitemize test \par
-% test \startitemize[joinedup,nowhite,after] \item test \item test \stopitemize test \par
-% \stoptext
-%
-% test / example
-%
-% \startnarrower[left] \startcolumns[n=3] \startitemize
-% \item \input ward \item \input ward \item \input ward
-% \stopitemize \stopcolumns\stopnarrower \blank
-%
-% \startnarrower[left] \startitemize[columns,three]
-% \item \input ward \item \input ward \item \input ward
-% \stopitemize \stopnarrower \blank
-%
-% \setupitemize[leftmargin=1.5em] \startitemize[columns,three]
-% \item \input ward \item \input ward \item \input ward
-% \stopitemize \blank
-%
-% beware, we don't group (yet) as we want to keep the left/right skip
-%
-% \startitemize
-% \startitem \stopitem
-% some intermediate text that will properly indent
-% \startitem \stopitem
-% \stopitem
-%
-% so we need to keep that property
-%
-% \startitemize
-% \starthead {xx} test \stophead
-% \startitem test \stopitem
-% \startitem test \stopitem
-% \stopitemize
-%
-% Sometimes the user demands get pretty weird:
-%
-% \startitemize
-% \item test
-% \item test
-% \headsym{xx} test \par test
-% \stopitemize
-%
-% aligned items
-%
-% \startitemize[n,fit,broad][itemalign=flushright]
-% \dorecurse{100}{\item The first item.}
-% \stopitemize
-%
-% \setupitemgroup[itemize][each][fit]
-% \setupitemgroup[itemize][each][distance=.5em,factor=1,itemalign=flushright]
-%
-% \startitemize[n]
-% \dorecurse{100}{\item The first item.}
-% \stopitemize
-%
-% \defineitemgroup[gbitemize]
-% \setupitemgroup[gbitemize][each][headstyle=bold]
-%
-% \startgbitemize
-% \txt{italian} some italians like this kind of cross||breed between
-% an itemize and a description
-% \txt{sicilians} i wonder how many sicilian mathematicians do a thesis
-% on the math involved in predicting the next big bang of the vulcano
-% \stopgbitemize
-%
-% \startitemize[n,repeat]
-% \noitem \startitemize[a] \item Item 1.a. \item Item 1.b. \stopitemize
-% \noitem \startitemize[a] \item Item 2.a. \item Item 2.b. \stopitemize
-% \stopitemize
-%
-% \startitemize[n,repeat][width=0pt]
-% \noitem \startitemize[a][width=2em] \item Item 1.a. \item Item 1.b. \stopitemize
-% \noitem \startitemize[a][width=2em] \item Item 2.a. \item Item 2.b. \stopitemize
-% \stopitemize
-%
-% \startbuffer
-% \item
-% \startitemize[n]
-% \item item 1.1
-% \item item 1.2
-% \startitemize[n] \item item 1.2.1 \item item 1.2.2 \stopitemize
-% \item item 1.3
-% \stopitemize
-% \item
-% \startitemize[n] \item item 2.1 \item item 2.2 \stopitemize
-% \item item 3
-% \startitemize[n] \item item 3.1 \item item 3.2 \stopitemize
-% \item
-% \startitemize[n] \item item 4.1 \item item 4.2 \stopitemize
-% \stopbuffer
-%
-% \startitemize[n,repeat,6*broad,packed] \getbuffer \stopitemize \blank[3*big]
-% \startitemize[n,repeat,packed] \getbuffer \stopitemize \blank[3*big]
-% \setupitemize[each][atmargin][width=3em]
-% \startitemize[n,repeat,packed] \getbuffer \stopitemize
-%
-% todo: assume startitem ... stopitem and do an autostopitem .. cleaner for
-% elements
-%
-% \startitemize[text][space=medium]
-% \item one \item two \item three
-% \stopitemize
-%
-% For Giuseppe "Oblomov" Bilotta, inspired on a suggestion by Taco
-% Hoekwater.
-%
-% \def\MyItemCommand#1{{\bf#1}\quad}
-% \setupitemgroup[itemize][command=\MyItemCommand]
-%
-% \startitemize
-% \item {test} is this okay?
-% \item {test} is this okay?
-% \item {test} is this okay?
-% \stopitemize
-
-\unprotect
-
-\newconditional\c_strc_itemgroups_sub
-\newconditional\c_strc_itemgroups_head
-\newconditional\c_strc_itemgroups_intro
-\newconditional\c_strc_itemgroups_randomize
-\newconditional\c_strc_itemgroups_horizontal
-\newconditional\c_strc_itemgroups_collecting
-\newconditional\c_strc_itemgroups_auto_intro
-\newconditional\c_strc_itemgroups_pack
-\newconditional\c_strc_itemgroups_paragraph
-\newconditional\c_strc_itemgroups_text
-\newconditional\c_strc_itemgroups_text_saved
-\newconditional\c_strc_itemgroups_first
-\newconditional\c_strc_itemgroups_before
-\newconditional\c_strc_itemgroups_after
-\newconditional\c_strc_itemgroups_nowhite
-\newconditional\c_strc_itemgroups_joined
-\newconditional\c_strc_itemgroups_reverse
-\newconditional\c_strc_itemgroups_continue
-\newconditional\c_strc_itemgroups_fitting
-\newconditional\c_strc_itemgroups_indented_first
-\newconditional\c_strc_itemgroups_inline
-\newconditional\c_strc_itemgroups_columns
-\newconditional\c_strc_itemgroups_concat
-\newconditional\c_strc_itemgroups_txt
-\newconditional\c_strc_itemgroups_extra
-\newconditional\c_strc_itemgroups_repeat
-\newconditional\c_strc_itemgroups_inline_head
-
-% 0 = before/after
-% 1 = between unless before
-% 2 = between
-
-\newconstant \c_strc_itemgroups_spacing_mode \c_strc_itemgroups_spacing_mode\plustwo
-\newconditional\c_strc_itemgroups_optimize \settrue\c_strc_itemgroups_optimize
-\newconditional\c_strc_itemgroups_auto_concat \settrue\c_strc_itemgroups_auto_concat
-
-\newsignal \d_strc_itemgroups_signal
-
-\newbox \b_strc_itemgroups
-
-\newdimen \d_strc_itemgroups_list_width
-\newdimen \d_strc_itemgroups_asked_width
-
-\newdimen \d_strc_itemgroups_max_width % multipass
-\newcount \c_strc_itemgroups_max_items % multipass
-
-\newcount \c_strc_itemgroups_n_of_items
-\newcount \c_strc_itemgroups_nesting
-\newcount \c_strc_itemgroups_column_depth
-
-\def \v_strc_itemgroups_counter {itemgroup:\currentparentitemgroup}
-\let \m_strc_itemgroups_repeat_start \empty
-\def \v_strc_itemgroups_unknown_symbol {?}
-\let \m_strc_itemgroups_indenting \empty
-\let \m_strc_itemgroups_destination \empty
-
-\let \currentitemlevel \!!zerocount % public
-\def \currentnofitems {\the\c_strc_itemgroups_max_items}
-\def \currentitemnumber {\strc_counters_raw_sub\v_strc_itemgroups_counter\currentitemlevel} % public
-
-\newtoks \itemgroupcommands % maybe public
-
-\def \currentitemgroupsymbol {n} % here we cannot use a _ in the name
-\let \currentitemgroupconversionset \empty % here we cannot use a _ in the name
-\let \currentitemgroupsegments \empty
-
-\def\strc_itemgroups_register_status
- {\clf_registeritemgroup{\currentparentitemgroup}\c_strc_itemgroups_nesting\c_strc_itemgroups_n_of_items\dimexpr\itemgroupparameter\c!maxwidth\relax}
-
-\def\strc_itemgroups_check_n_of_items % we could do this at the lua end and save a call (i.e. will be dimen and counter)
- {\clf_analyzeitemgroup{\currentparentitemgroup}\c_strc_itemgroups_nesting\relax
- \edef\currentnofitems{\the\c_strc_itemgroups_max_items}}
-
-% todo: \dodosetreference -> \strc_counters_register_component (to be checked)
-
-\def\strc_itemgroups_insert_reference % we will make a decent number helper
- {\iftrialtypesetting \orelse \ifx\currentitemreference \empty \else
- \strc_itemgroups_insert_reference_indeed
- \fi}
-
-\def\strc_itemgroups_insert_extra_reference
- {\iftrialtypesetting \orelse \ifx\currentitemreference \empty \else
- \normalexpanded{\textreference[\currentitemreference]{\strc_itemgroups_extra_symbol}}%
- \fi}
-
-\def\strc_itemgroups_insert_reference_indeed % maybe we need a 'frozen counter' numberdata blob / quick hack .. .mive this to strc-ref
- {% needs testing, gave problems:
- \setnextinternalreference
- % no need to collect nodes in \b_strc_destination_nodes here ... maybe at some point
- \strc_references_start_destination_nodes
- % this is somewhat over the top ... we should use the counter's reference
- \clf_setdestinationattribute
- {%
- metadata {%
- kind {item}% was item, why?
- \ifx\currentreferencecoding\s!xml
- xmlroot {\xmldocument}% only useful when text
- \fi
- catcodes \catcodetable
- }%
- references {%
- internal \locationcount % no: this spoils references
- % block {\currentsectionblock}%
- view {\interactionparameter\c!focus}%
- prefix {\referenceprefix}%
- reference {\currentitemreference}%
- }%
- prefixdata {%
- prefix {\namedcounterparameter\v_strc_itemgroups_counter\c!prefix}%
- separatorset {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixseparatorset}%
- conversion {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversion}%
- conversionset {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversionset}%
- set {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixset}%
- segments {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixsegments}%
- % segments {\askedprefixsegments}%
- connector {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconnector}%
- }%
- numberdata {%
- numbers {\v_strc_itemgroups_counter}%
- separatorset {\namedcounterparameter\v_strc_itemgroups_counter\c!numberseparatorset}%
- % conversion {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversion}%
- % conversionset {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversionset}%
- % fixedconversion {\currentitemgroupconversionset}%
- conversionset {fixed::\currentitemgroupconversionset}% temp hack
- %
- % for the moment no stopper, we need to make references configurable first
- % stopper {\namedcounterparameter\v_strc_itemgroups_counter\c!numberstopper}%
- segments {\namedcounterparameter\v_strc_itemgroups_counter\c!numbersegments}%
- }%
- }%
- \relax
- \strc_references_stop_destination_nodes
- \xdef\currentdestinationattribute{\number\lastdestinationattribute}%
- % will become an option:
- \ifnum\lastdestinationattribute>\zerocount
- \dontleavehmode\hbox attr \destinationattribute\lastdestinationattribute\bgroup
- \strc_references_flush_destination_nodes
- \egroup
- \fi}
-
-%D Defining and setup:
-
-\installcorenamespace{itemgroup}
-\installcorenamespace{itemgroupoption}
-\installcorenamespace{itemgroupsetting}
-\installcorenamespace{itemgroupkeyword}
-\installcorenamespace{itemgroupalign}
-\installcorenamespace{itemgrouplocal}
-\installcorenamespace{itemgroupglobal}
-\installcorenamespace{itemgroupdistance}
-\installcorenamespace{itemgroupstack}
-\installcorenamespace{itemgroupfirst}
-\installcorenamespace{itemgroupstart}
-
-\installcommandhandler \??itemgroup {itemgroup} \??itemgroup
-
-\let\setupitemgroups\setupitemgroup
-
-\appendtoks
- \setuevalue{\e!start\currentitemgroup}{\startitemgroup[\currentitemgroup]}%
- \setuevalue{\e!stop \currentitemgroup}{\stopitemgroup}%
- \setuevalue{\e!setup\currentitemgroup\e!endsetup}{\setupitemgroup[\currentitemgroup]}% obsolete
- \let\currentparentitemgroup\currentitemgroup
- \definecounter[\v_strc_itemgroups_counter]%
- % beware ... we cannot use _ as the conversion set is not expanded
- % \defineconversionset[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]%
-\to \everydefineitemgroup
-
-%D Global states
-
-\def\strc_itemgroups_store_continue_state#options#settings%
- {\setxvalue{\??itemgroupoption \currentitemgroup}{\strc_itemgroups_process_options{#options}}%
- \setgvalue{\??itemgroupsetting\currentitemgroup}{\setupcurrentitemgroup[#settings]}}
-
-\def\strc_itemgroups_fetch_continue_state
- {\csname\??itemgroupoption \currentitemgroup\endcsname
- \csname\??itemgroupsetting\currentitemgroup\endcsname}
-
-\def\strc_itemgroups_reset_continue_state
- {\expandafter\glet\csname\??itemgroupoption \currentitemgroup\endcsname\relax
- \expandafter\glet\csname\??itemgroupsetting\currentitemgroup\endcsname\relax}
-
-% These will become keywords. We will also add a feature to keep the while set
-% together.
-
-\definevspacing[\v!item @0] [penalty:0] % allow
-\definevspacing[\v!item @10000] [penalty:10000] % no
-\definevspacing[\v!item @-5] [penalty:-5]
-\definevspacing[\v!item @5] [penalty:5]
-\definevspacing[\v!item @500] [penalty:500] % discourage .. too low, 5000 is better
-
-\def\strc_itemgroups_insert_break_when_needed#break%
- {\ifconditional\c_strc_itemgroups_optimize
- \ifconditional\c_strc_itemgroups_text \else
- #break\relax
- \fi
- \fi}
-
-\def\strc_itemgroups_insert_breakallow {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_breakallow_indeed}
-\def\strc_itemgroups_insert_breakno {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_breakno_indeed }
-\def\strc_itemgroups_insert_break {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_break_indeed }
-\def\strc_itemgroups_insert_nobreak {\strc_itemgroups_insert_break_when_needed\strc_itemgroups_insert_nobreak_indeed }
-
-\def\strc_itemgroups_insert_breakallow_indeed{\vspacing[\v!item @0]}
-\def\strc_itemgroups_insert_breakno_indeed {\vspacing[\v!item @10000]}
-\def\strc_itemgroups_insert_break_indeed {\flushnotes
- \vspacing[\v!item @-5]}
-\def\strc_itemgroups_insert_nobreak_indeed {\flushnotes
- \ifinsidecolumns % todo
- \vspacing[\v!item @5]%
- \else
- \vspacing[\v!item @500]%
- \fi}
-
-\unexpanded\def\strc_itemgroups_process_options#options%
- {\processcommacommand[#options]\strc_itemgroups_process_option} % expansion of options is handy for xml
-
-% \installcommalistprocessorcommand \strc_itemgroups_process_option_list \strc_itemgroups_process_option
-%
-% \unexpanded\def\strc_itemgroups_process_options#options%
-% {\normalexpanded{\strc_itemgroups_process_option_list[#options]}} % expansion of options is handy for xml
-
-\def\strc_itemgroups_process_option#option%
- {\edef\itemgroupconstantvalue{#option}%
- \ifx\itemgroupconstantvalue\empty\else
- \splitatasterisk\itemgroupconstantvalue\itemgroupfirst\itemgroupsecond
- \ifx\itemgroupsecond\empty
- \let\itemgroupsecond\itemgroupfirst
- \let\itemgroupfirst\!!plusone
- \fi
- \ifcsname\??itemgroupkeyword\itemgroupsecond\endcsname
- \lastnamedcs
- \else
- \strc_itemgroups_set_symbol\itemgroupconstantvalue
- \fi
- \fi}
-
-\def\strc_itemgroups_process_set_option_pack
- {\ifcase\c_strc_itemgroups_nesting \else
- \settrue\c_strc_itemgroups_pack
- \fi}
-
-\def\strc_itemgroups_process_set_option_unpack
- {\ifcase\c_strc_itemgroups_nesting\else
- \setfalse\c_strc_itemgroups_pack
- \fi}
-
-\setvalue{\??itemgroupkeyword\!!zerocount }{} % ignore 0
-\setvalue{\??itemgroupkeyword\v!packed }{\strc_itemgroups_process_set_option_pack}
-\setvalue{\??itemgroupkeyword\v!unpacked }{\strc_itemgroups_process_set_option_unpack}
-\setvalue{\??itemgroupkeyword\v!intro }{\settrue\c_strc_itemgroups_intro} % here? not set to false
-\setvalue{\??itemgroupkeyword\v!autointro }{\settrue\c_strc_itemgroups_auto_intro}
-\setvalue{\??itemgroupkeyword\v!broad }{\ifx\itemgroupfirst\empty
- \let\itemgroupfirst\!!plusone
- \fi
- \letitemgroupparameter\c!factor\itemgroupfirst}
-\setvalue{\??itemgroupkeyword\v!text }{\settrue\c_strc_itemgroups_text
- \settrue\c_strc_itemgroups_inline
- \settrue\c_strc_itemgroups_joined
- \strc_itemgroups_process_set_option_pack}
-\setvalue{\??itemgroupkeyword\v!before }{\settrue\c_strc_itemgroups_before}
-\setvalue{\??itemgroupkeyword\v!after }{\settrue\c_strc_itemgroups_after}
-\setvalue{\??itemgroupkeyword\v!nowhite }{\settrue\c_strc_itemgroups_nowhite}
-\setvalue{\??itemgroupkeyword\v!margin }{\setitemgroupparameter\c!width{-2em}} % signal
-\setvalue{\??itemgroupkeyword\v!inmargin }{\setitemgroupparameter\c!width{-2em}} % signal
-\setvalue{\??itemgroupkeyword\v!atmargin }{\ifnum\c_strc_itemgroups_nesting>\plusone
- \setitemgroupparameter\c!width{0em}%
- \fi} % signal
-\setvalue{\??itemgroupkeyword\v!intext }{\settrue\c_strc_itemgroups_inline}
-\setvalue{\??itemgroupkeyword\v!headintext }{\settrue\c_strc_itemgroups_inline_head}
-\setvalue{\??itemgroupkeyword\v!loose }{\setfalse\c_strc_itemgroups_optimize}
-\setvalue{\??itemgroupkeyword\v!fit }{\settrue\c_strc_itemgroups_fitting}
-\setvalue{\??itemgroupkeyword\v!nofit }{\setfalse\c_strc_itemgroups_fitting}
-\setvalue{\??itemgroupkeyword\v!paragraph }{\settrue\c_strc_itemgroups_paragraph
- \strc_itemgroups_process_set_option_pack}
-\setvalue{\??itemgroupkeyword\v!joinedup }{\settrue\c_strc_itemgroups_joined
- \strc_itemgroups_process_set_option_pack}
-\setvalue{\??itemgroupkeyword\v!notjoinedup}{\setfalse\c_strc_itemgroups_joined}
-\setvalue{\??itemgroupkeyword\v!serried }{\edef\itemgroupfirst{-\ifx\itemgroupfirst\empty1\else\itemgroupfirst\fi}%
- \letitemgroupparameter\c!factor\itemgroupfirst}
-\setvalue{\??itemgroupkeyword\v!stopper }{\letitemgroupparameter\c!placestopper\v!yes} % keep {}
-\setvalue{\??itemgroupkeyword\v!nostopper }{\letitemgroupparameter\c!placestopper\v!no} % keep {}
-\setvalue{\??itemgroupkeyword\v!repeat }{\settrue\c_strc_itemgroups_repeat}
-\setvalue{\??itemgroupkeyword\v!norepeat }{\setfalse\c_strc_itemgroups_repeat}
-\setvalue{\??itemgroupkeyword\v!reverse }{\settrue\c_strc_itemgroups_reverse}
-\setvalue{\??itemgroupkeyword\v!columns }{\settrue\c_strc_itemgroups_columns}
-\setvalue{\??itemgroupkeyword\v!one }{\letitemgroupparameter\c!n\plusone}
-\setvalue{\??itemgroupkeyword\v!two }{\letitemgroupparameter\c!n\plustwo}
-\setvalue{\??itemgroupkeyword\v!three }{\letitemgroupparameter\c!n\plusthree}
-\setvalue{\??itemgroupkeyword\v!four }{\letitemgroupparameter\c!n\plusfour}
-\setvalue{\??itemgroupkeyword\v!five }{\letitemgroupparameter\c!n\plusfive}
-\setvalue{\??itemgroupkeyword\v!six }{\letitemgroupparameter\c!n\plussix}
-\setvalue{\??itemgroupkeyword\v!seven }{\letitemgroupparameter\c!n\plusseven}
-\setvalue{\??itemgroupkeyword\v!eight }{\letitemgroupparameter\c!n\pluseight}
-\setvalue{\??itemgroupkeyword\v!nine }{\letitemgroupparameter\c!n\plusnine}
-\setvalue{\??itemgroupkeyword\v!standard }{\setitemgroupparameter\c!width {1.5\emwidth}%
- \setitemgroupparameter\c!distance {.5\emwidth}%
- %\letitemgroupparameter\c!factor \!!zerocount
- \letitemgroupparameter\c!factor {\zerocount}%
- \setitemgroupparameter\c!packcriterium{\zerocount}%
- \letitemgroupparameter\c!inner \empty
- \letitemgroupparameter\c!beforehead \empty
- \letitemgroupparameter\c!afterhead \blank
- \letitemgroupparameter\c!before \blank
- \letitemgroupparameter\c!inbetween \blank
- \letitemgroupparameter\c!after \blank}
-
-\def\strc_itemgroups_initialize_local
- {\setfalse\c_strc_itemgroups_inline
- \setfalse\c_strc_itemgroups_concat
- \setfalse\c_strc_itemgroups_txt
- %
- \setfalse\c_strc_itemgroups_reverse
- \setfalse\c_strc_itemgroups_intro
- \setfalse\c_strc_itemgroups_auto_intro
- \setfalse\c_strc_itemgroups_before
- \setfalse\c_strc_itemgroups_after
- \setfalse\c_strc_itemgroups_nowhite
- \setfalse\c_strc_itemgroups_randomize
- \setfalse\c_strc_itemgroups_horizontal
- \setfalse\c_strc_itemgroups_collecting
- \setfalse\c_strc_itemgroups_intro
- \setfalse\c_strc_itemgroups_continue
- % this will be a constant
- \setfalse\c_strc_itemgroups_head
- \setfalse\c_strc_itemgroups_sub
- \setfalse\c_strc_itemgroups_symbol
- \setfalse\c_strc_itemgroups_columns
- % to be checked
- \let\m_strc_itemgroups_destination\empty
- \let\strc_itemgroups_used_symbol \empty % ** start value
- \let\strc_itemgroups_margin_symbol\empty
- \let\strc_itemgroups_extra_symbol \empty
- %
- \global\letitemgroupparameter\c!maxwidth\!!zeropoint
- }
-
-\setvalue{\??itemgroupfirst\v!intro }{\settrue\c_strc_itemgroups_intro}
-\setvalue{\??itemgroupfirst\v!continue }{\settrue\c_strc_itemgroups_continue}
-\setvalue{\??itemgroupfirst\v!random }{\settrue\c_strc_itemgroups_randomize
- \settrue\c_strc_itemgroups_collecting}
-\setvalue{\??itemgroupkeyword\v!horizontal}{\settrue\c_strc_itemgroups_horizontal
- \settrue\c_strc_itemgroups_collecting
- \settrue\c_strc_itemgroups_inline
- \settrue\c_strc_itemgroups_joined
- \strc_itemgroups_process_set_option_pack}
-
-\def\strc_itemgroups_preset_stage_one#options%
- {\processcommacommand[#options]\strc_itemgroups_preset_stage_one_indeed}
-
-% \installcommalistprocessorcommand \strc_itemgroups_preset_stage_one_list \strc_itemgroups_preset_stage_one_indeed
-%
-% \def\strc_itemgroups_preset_stage_one#options%
-% {\normalexpanded{\strc_itemgroups_preset_stage_one_list[#options]}}
-
-\def\strc_itemgroups_preset_stage_one_indeed#option%
- {\ifcsname\??itemgroupfirst#option\endcsname
- \lastnamedcs
- \fi}
-
-\ifdefined\dotagsetitemgroup \else \let\dotagsetitemgroup\relax \fi
-\ifdefined\dotagsetitem \else \let\dotagsetitem \gobbleoneargument \fi
-
-\def\strc_itemgroups_tag_start_group
- {\dostarttaggedchained\t!itemgroup\currentparentitemgroup\??itemgroup
- \dotagsetitemgroup}
-
-\def\strc_itemgroups_tag_stop_group
- {\dostoptagged}
-
-\def\strc_itemgroups_before_command
- {\ifconditional\c_strc_itemgroups_nowhite
- \ifconditional\c_strc_itemgroups_before
- \ifcase\c_strc_itemgroups_nesting\or\itemgroupparameter\c!before\fi
- \else
- \nowhitespace
- \fi
- \orelse\ifconditional\c_strc_itemgroups_joined
- % \empty
- \else
- \itemgroupparameter\c!before
- \fi}
-
-\def\strc_itemgroups_after_command
- {\ifconditional\c_strc_itemgroups_nowhite
- \ifconditional\c_strc_itemgroups_after
- \ifcase\c_strc_itemgroups_nesting\or\itemgroupparameter\c!after\fi
- \else
- \nowhitespace
- \fi
- \orelse\ifconditional\c_strc_itemgroups_joined
- % \empty
- \else
- \itemgroupparameter\c!after
- \fi}
-
-\def\strc_itemgroups_between_command
- {\ifconditional\c_strc_itemgroups_nowhite
- \nowhitespace
- \orelse\ifconditional\c_strc_itemgroups_joined
- % \empty
- \else
- \itemgroupparameter\c!inbetween
- \fi}
-
-\def\strc_itemgroups_before_head_command
- {\ifconditional\c_strc_itemgroups_nowhite
- \nowhitespace
- \orelse\ifconditional\c_strc_itemgroups_joined
- % \empty
- \else
- \itemgroupparameter\c!beforehead
- \fi}
-
-\def\strc_itemgroups_after_head_command
- {\ifconditional\c_strc_itemgroups_nowhite
- \nowhitespace
- \orelse\ifconditional\c_strc_itemgroups_joined
- % \empty
- \else
- \itemgroupparameter\c!afterhead
- \fi}
-
-% compatible setup command:
-
-\let\strc_itemgroups_normal_setup\setupitemgroup
-
-\unexpanded\def\setupitemgroup
- {\doquadrupleempty\strc_itemgroups_setup}
-
-\def\strc_itemgroups_setup[#category][#levels][#options][#settings]% category level|each options|settings settings|options
- {\edef\strc_itemgroups_setup_what{#levels}%
- \iffourthargument
- \ifx\strc_itemgroups_setup_what\v!each
- \strc_itemgroups_setup_each{#category}{#options}%
- \strc_itemgroups_setup_each{#category}{#settings}%
- \else
- \strc_itemgroups_setup_list{#levels}{#category}{#options}%
- \strc_itemgroups_setup_list{#levels}{#category}{#settings}%
- \fi
- \orelse\ifthirdargument
- \ifx\strc_itemgroups_setup_what\v!each
- \strc_itemgroups_setup_each{#category}{#options}%
- \else
- \strc_itemgroups_setup_list{#levels}{#category}{#options}%
- \fi
- \orelse\ifsecondargument
- \strc_itemgroups_setup_each{#category}{#levels}%
- \else
- \strc_itemgroups_normal_setup[#category]% == settings
- \fi}
-
-% can be made a bit faster
-
-% \def\strc_itemgroups_setup_each#category#whatever%
-% {\doifelseassignment{#whatever}
-% {\strc_itemgroups_normal_setup[#category][#whatever]}
-% {\strc_itemgroups_normal_setup[#category][\c!option={#whatever}]}}
-
-\def\strc_itemgroups_setup_each#category#whatever%
- {\ifcondition\validassignment{#whatever}%
- \strc_itemgroups_normal_setup[#category][#whatever]%
- \else
- \strc_itemgroups_normal_setup[#category][\c!option={#whatever}]%
- \fi}
-
-\def\strc_itemgroups_setup_list_level_a#category#whatever#level%
- {\strc_itemgroups_normal_setup[#category:#level][#whatever]}
-
-\def\strc_itemgroups_setup_list_level_b#category#whatever#level%
- {\strc_itemgroups_normal_setup[#category:#level][\c!option={#whatever}]}
-
-% \def\strc_itemgroups_setup_list#subcategories#category#whatever%
-% {\doifelseassignment{#whatever}
-% {\processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_a{#category}{#whatever}}}
-% {\processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_b{#category}{#whatever}}}}
-
-\def\strc_itemgroups_setup_list#subcategories#category#whatever%
- {\ifcondition\validassignment{#whatever}%
- \processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_a{#category}{#whatever}}%
- \else
- \processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_b{#category}{#whatever}}%
- \fi}
-
-\def\strc_itemgroups_increment_item_counter
- {\ifconditional\c_strc_itemgroups_sub \else
- \ifconditional\c_strc_itemgroups_symbol \else % \ifx\strc_itemgroups_extra_symbol\empty
- \strc_counters_increment_sub\v_strc_itemgroups_counter\currentitemlevel
- \fi
- \fi}
-
-\unexpanded\def\strc_itemgroups_insert_item_counter
- {\ifconditional\c_strc_itemgroups_repeat
- \ifcase\c_strc_itemgroups_nesting
- % skip
- \or
- \strc_itemgroups_insert_item_counter_indeed % this could become an option
- \else
- \strc_itemgroups_insert_item_counter_indeed
- \fi
- \else
- \strc_itemgroups_insert_item_counter_indeed
- \fi}
-
-\def\strc_itemgroups_insert_item_counter_indeed % quite slow ... every time this setup .. but it
- {\begingroup % can be optimized ... best move some to strc-num
- \setupcounter
- [\v_strc_itemgroups_counter]%
- [\c!prefix=\itemgroupparameter\c!prefix,
- \c!prefixstopper=\itemgroupparameter\c!prefixstopper,
- \c!prefixseparatorset=\itemgroupparameter\c!prefixseparatorset,
- \c!prefixconversion=\itemgroupparameter\c!prefixconversion,
- \c!prefixconversionset=\itemgroupparameter\c!prefixseparatorset,
- \c!prefixset=\itemgroupparameter\c!prefixset,
- \c!prefixsegments=\itemgroupparameter\c!prefixsegments,
- \c!prefixconnector=\itemgroupparameter\c!prefixconnector,
- \c!criterium=\itemgroupparameter\c!criterium,
- \c!numberorder=\ifconditional\c_strc_itemgroups_reverse\v!reverse\else\v!normal\fi,
- \c!numberstopper=\expdoif{\itemgroupparameter\c!placestopper}\v!yes{\itemgroupparameter\c!stopper},
- \c!numberconversionset=\v_strc_itemgroups_counter,
- \c!numbersegments=\currentitemgroupsegments]%
- % there will be a fixedconversion key
- %\normalexpanded{\defineconversionset[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
- \normalexpanded{\strc_sets_define_conversion_set[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
- %
- \convertedcounter[\v_strc_itemgroups_counter]% [\number\currentitemlevel]%
- \strc_itemgroups_insert_reference
- \endgroup}
-
-% needs testing (maybe it need to happen later)
-%
-% \appendtoks
-% \setupcounter
-% [\v_strc_itemgroups_counter]%
-% [\c!prefix=\itemgroupparameter\c!prefix,
-% \c!prefixstopper=\itemgroupparameter\c!prefixstopper,
-% \c!prefixseparatorset=\itemgroupparameter\c!prefixseparatorset,
-% \c!prefixconversion=\itemgroupparameter\c!prefixconversion,
-% \c!prefixconversionset=\itemgroupparameter\c!prefixseparatorset,
-% \c!prefixset=\itemgroupparameter\c!prefixset,
-% \c!prefixsegments=\itemgroupparameter\c!prefixsegments,
-% \c!prefixconnector=\itemgroupparameter\c!prefixconnector,
-% \c!criterium=\itemgroupparameter\c!criterium,
-% \c!numberorder=\ifconditional\c_strc_itemgroups_reverse\v!reverse\else\v!normal\fi,
-% \c!numberstopper=\expdoif{\itemgroupparameter\c!placestopper}\v!yes{\itemgroupparameter\c!stopper},
-% \c!numberconversionset=\v_strc_itemgroups_counter,
-% \c!numbersegments=\currentitemgroupsegments]%
-% \to\itemgroupcommands
-%
-% \def\strc_itemgroups_insert_item_counter_indeed % quite slow ... every time this setup .. but it
-% {\begingroup % can be optimized ... best move some to strc-num
-% % there will be a fixedconversion key
-% %\normalexpanded{\defineconversionset[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
-% \normalexpanded{\strc_sets_define_conversion_set[\v_strc_itemgroups_counter][\currentitemgroupconversionset][\currentitemgroupsymbol]}%
-% %
-% \convertedcounter[\v_strc_itemgroups_counter]% [\number\currentitemlevel]%
-% \strc_itemgroups_insert_reference
-% \endgroup}
-
-\def\strc_itemgroups_set_symbol#symbol%
- {\edef\strc_itemgroups_tmp_symbol{#symbol}%
- \ifx\strc_itemgroups_tmp_symbol\empty \else
- \doifelsesymboldefined\strc_itemgroups_tmp_symbol
- \strc_itemgroups_set_symbol_symbol
- {\doifelseconversiondefined\strc_itemgroups_tmp_symbol
- \strc_itemgroups_set_symbol_conversion
- \donothing}%
- \fi}
-
-\def\strc_itemgroups_set_symbol_symbol
- {\let\currentitemgroupsymbol\strc_itemgroups_tmp_symbol
- \strc_itemgroups_store_global_symbol\currentitemgroupsymbol
- \strc_itemgroups_store_local_symbol\v_strc_itemgroups_unknown_symbol
- \let\strc_itemgroups_used_symbol\strc_itemgroups_set_symbol_symbol_item
- \let\strc_itemgroups_asked_symbol\empty}
-
-\def\strc_itemgroups_set_symbol_conversion
- {\let\currentitemgroupsymbol\strc_itemgroups_tmp_symbol
- \strc_itemgroups_store_global_symbol\currentitemgroupsymbol
- \strc_itemgroups_store_local_symbol\strc_itemgroups_insert_item_counter
- \let\strc_itemgroups_used_symbol\strc_itemgroups_set_symbol_conversion_item
- \let\strc_itemgroups_asked_symbol\empty}
-
-\def\strc_itemgroups_set_symbol_symbol_item
- {\symbol[\currentitemgroupsymbol]}
-
-\def\strc_itemgroups_set_symbol_conversion_item
- {\ifconditional\c_strc_itemgroups_text
- % maybe block stopper here, but one can as well clone an itemgroup then
- \itemgroupparameter\c!lefttext
- \strc_itemgroups_fetch_local_symbol
- \itemgroupparameter\c!righttext
- \else
- \itemgroupparameter\c!left
- \strc_itemgroups_fetch_local_symbol
- \itemgroupparameter\c!right
- \fi}
-
-\def\strc_itemgroups_calculate_list_width#level%
- {\let\savedcurrentitemgroup\currentitemgroup
- \edef\currentitemgroup{\currentparentitemgroup:\number#level}%
- \ifdim\d_strc_itemgroups_max_width>\zeropoint
- \d_strc_itemgroups_list_width\d_strc_itemgroups_max_width
- \orelse\ifnum\itemgroupparameter\c!factor>\zerocount
- \d_strc_itemgroups_list_width\itemgroupparameter\c!step\relax
- \ifzeropt\d_strc_itemgroups_list_width \d_strc_itemgroups_list_width=.5em\fi
- \multiply\d_strc_itemgroups_list_width \itemgroupparameter\c!factor
- \advance\d_strc_itemgroups_list_width\itemgroupparameter\c!width\relax
- \else
- \d_strc_itemgroups_list_width\itemgroupparameter\c!width\relax
- \fi
- \advance\d_strc_itemgroups_list_width\itemgroupparameter\c!distance\relax
- \let\currentitemgroup\savedcurrentitemgroup}
-
-\unexpanded\def\startitemgroup
- {\dotripleempty\strc_itemgroups_start}
-
-\def\strc_itemgroups_start[#category][#options][#settings]%
- {\begingroup % (1)
- \def\currentitemgroup{#category}% no nested mixing of itemgroups
- \let\currentparentitemgroup\currentitemgroup
- \global\advance\c_strc_itemgroups_nesting\plusone
- \def\currentitemlevel{\number\c_strc_itemgroups_nesting}%
- \normalexpanded{\chaintocurrentitemgroup{\currentparentitemgroup:\currentitemlevel}}%
- \edef\currentitemgroup{\currentparentitemgroup:\currentitemlevel}%
- %
- \ifthirdargument
- \strc_itemgroups_start_indeed[#options][#settings]%
- \orelse\ifsecondargument
- \ifcondition\validassignment{#options}%
- \strc_itemgroups_start_indeed[][#options]%
- \else
- \strc_itemgroups_start_indeed[#options][]%
- \fi
- \else
- \strc_itemgroups_start_indeed[][]%
- \fi}
-
-\def\strc_itemgroups_start_indeed[#options][#settings]%
- {\edef\itemgroupoptions{\itemgroupparameter\c!option}%
- \edef\itemgroupextraoptions{#options}%
- \ifx\itemgroupoptions\empty
- \let\itemgroupoptions\itemgroupextraoptions
- \orelse\ifx\itemgroupextraoptions\empty
- % ok
- \else
- \edef\itemgroupoptions{\itemgroupoptions,\itemgroupextraoptions}%
- \fi
- \begingroup % (2)
- \the\itemgroupcommands
- \let\c_strc_itemgroups_text_saved\c_strc_itemgroups_text
- \strc_itemgroups_initialize_local
- \strc_itemgroups_preset_stage_one\itemgroupoptions
-%
-% \ifhmode
-% \ifconditional\c_strc_itemgroups_auto_concat
-% \ifdim\lastskip=\d_strc_itemgroups_signal
-% \settrue\c_strc_itemgroups_concat
-% \fi
-% \fi
-% \ifconditional\c_strc_itemgroups_text_saved \else
-% \ifconditional\c_strc_itemgroups_text \else
-% \par
-% \fi
-% \fi
-% \fi
-%
- \iftrialtypesetting
- \strc_counters_save\v_strc_itemgroups_counter
- \fi
- \c_strc_itemgroups_n_of_items\zerocount
- \strc_itemgroups_check_n_of_items
- \ifx\itemgroupoptions\empty
- \strc_itemgroups_setup_symbol_default
- \strc_itemgroups_reset_continue_state
- \setupcurrentitemgroup[#settings]%
- \else
- \strc_itemgroups_process_options\itemgroupoptions
- \setupcurrentitemgroup[#settings]%
- \ifconditional\c_strc_itemgroups_continue
- \strc_itemgroups_setup_symbol_continue
- \strc_itemgroups_fetch_continue_state
- \else
- \strc_itemgroups_setup_symbol_asked
- \strc_itemgroups_store_continue_state\itemgroupoptions{#settings}%
- \fi
- \fi
- %
- \ifhmode
- \ifconditional\c_strc_itemgroups_auto_concat
- \ifdim\lastskip=\d_strc_itemgroups_signal
- \settrue\c_strc_itemgroups_concat
- \fi
- \fi
- \ifconditional\c_strc_itemgroups_text_saved \else
- \ifconditional\c_strc_itemgroups_text \else
- \par
- \fi
- \fi
- \fi
- %
- \ifconditional\c_strc_itemgroups_pack
- \ifnum\currentnofitems>\itemgroupparameter\c!packcriterium\relax\else
- \setfalse\c_strc_itemgroups_pack
- \fi
- \fi
- %
- \ifnum\c_strc_itemgroups_nesting=\plusone % NIEUW
- \doadaptleftskip {\itemgroupparameter\c!margin}%
- \doadaptleftskip {\itemgroupparameter\c!leftmargin}%
- \doadaptrightskip{\itemgroupparameter\c!rightmargin}%
- \fi
- %
- \doadaptleftskip {\itemgroupparameter\c!leftmargindistance}%
- \doadaptrightskip{\itemgroupparameter\c!rightmargindistance}%
- %
- \usealignparameter\itemgroupparameter
- \edef\m_strc_itemgroups_indenting{\itemgroupparameter\c!indenting}%
- \ifnum\c_strc_itemgroups_nesting>\zerocount
- \settrue\c_strc_itemgroups_first
- \ifconditional\c_strc_itemgroups_continue \else
- \strc_counters_restart_sub\v_strc_itemgroups_counter\currentitemlevel{\numexpr\itemgroupparameter\c!start-\plusone\relax}%
- \fi
- \fi
- \ifx\strc_itemgroups_used_symbol\empty
- \strc_itemgroups_set_symbol\strc_itemgroups_asked_symbol % ** default value
- \ifx\strc_itemgroups_used_symbol\empty
- \let\currentitemgroupsymbol\currentitemlevel % ** fall back
- \fi
- \fi
- \ifconditional\c_strc_itemgroups_auto_intro\ifnum\prevgraf<\plusthree
- \settrue\c_strc_itemgroups_intro
- \fi\fi
- \ifconditional\c_strc_itemgroups_paragraph
- \ifnum\c_strc_itemgroups_nesting>\plusone
- \letitemgroupparameter\c!inbetween\empty
- \fi
- \fi
- \ifconditional\c_strc_itemgroups_pack
- \letitemgroupparameter\c!inbetween\empty
- \fi
- \ifconditional\c_strc_itemgroups_columns
- \ifinsidecolumns\else\ifcase\c_strc_itemgroups_column_depth
- \global\c_strc_itemgroups_column_depth\c_strc_itemgroups_nesting % global ?
- \strc_itemgroups_before_command
- \strc_itemgroups_tag_start_group
- \strc_itemgroups_start_columns
- \fi\fi
- \fi
- \ifconditional\c_strc_itemgroups_fitting
- \ifdim\d_strc_itemgroups_max_width>\zeropoint
- \letitemgroupparameter\c!width\d_strc_itemgroups_max_width
- \fi
- \fi
- \strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting
- \ifdim\d_strc_itemgroups_list_width>\zeropoint\relax
- \ifconditional\c_strc_itemgroups_inline\else
- \advance\leftskip\d_strc_itemgroups_list_width\relax
- \fi
- \fi
- \ifx\m_strc_itemgroups_repeat_start\empty
- \let\currentitemgroupconversionset \currentitemgroupsymbol
- \edef\currentitemgroupsegments {\currentitemlevel}%
- \else
- \edef\currentitemgroupconversionset{\currentitemgroupconversionset,\currentitemgroupsymbol}%
- \edef\currentitemgroupsegments {\m_strc_itemgroups_repeat_start:\currentitemlevel}%
- \fi
- \d_strc_itemgroups_asked_width\itemgroupparameter\c!width\relax
- \startcollectitems}
-
-\let\startcollectitems\relax
-\let\stopcollectitems \relax
-
-\letvalue{\??itemgroupalign\v!flushleft }\relax
-\letvalue{\??itemgroupalign\v!right }\relax
-\letvalue{\??itemgroupalign\v!flushright}\hfill
-\letvalue{\??itemgroupalign\v!left }\hfill
-\letvalue{\??itemgroupalign\v!middle }\hfil
-\letvalue{\??itemgroupalign\v!center }\hfil
-
-\def\strc_itemgroups_left_sym_filler
- {\csname\??itemgroupalign\itemgroupparameter\c!symalign\endcsname}
-
-% symbols + states
-
-\def\strc_itemgroups_store_global_symbol#symbol%
- {\letgvalue{\??itemgroupglobal\currentitemgroup:\currentitemlevel}#symbol}
-
-\def\strc_itemgroups_store_local_symbol#symbol%
- {\letgvalue{\??itemgrouplocal\currentitemgroup:\currentitemlevel}#symbol}
-
-\def\strc_itemgroups_fetch_global_symbol
- {\csname\??itemgroupglobal\currentitemgroup:\currentitemlevel\endcsname}
-
-\def\strc_itemgroups_fetch_local_symbol
- {\csname\??itemgrouplocal\currentitemgroup:\currentitemlevel\endcsname}
-
-\def\strc_itemgroups_setup_symbol_default
- {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}%
- \strc_itemgroups_store_global_symbol\empty}
-
-\def\strc_itemgroups_setup_symbol_continue
- {\ifcsname\??itemgroupglobal\currentitemgroup:\currentitemlevel\endcsname
- \let\strc_itemgroups_asked_symbol\strc_itemgroups_fetch_global_symbol
- \else
- \let\strc_itemgroups_asked_symbol\currentitemlevel
- \fi}
-
-\def\strc_itemgroups_setup_symbol_asked
- {\edef\strc_itemgroups_asked_symbol{\itemgroupparameter\c!symbol}}
-
-\ifdefined\strc_itemgroups_start_columns
-
- % already defined in page-mix
-
-\else
-
- % will be redefined in page-mix
-
- \ifdefined\startcolumns \else
- \unexpanded\def\startcolumns[#settings]{}
- \unexpanded\def\stopcolumns {}
- \fi
-
- \def\strc_itemgroups_start_columns
- {\startcolumns
- [\c!n=\itemgroupparameter\c!n,
- \c!height=,
- \c!rule=\v!off,
- \c!balance=\v!yes,
- \c!align=\v!no]}
-
- \def\strc_itemgroups_stop_columns
- {\stopcolumns}
-
-\fi
-
-\unexpanded\def\stopitemgroup
- {\stopcollectitems
- \ifconditional\c_strc_itemgroups_text
- \removeunwantedspaces
- \space
- \ignorespaces
- \else
- \par
- \fi
- \strc_itemgroups_register_status
- \ifconditional\c_strc_itemgroups_first \else
- \dostoptagged
- \dostoptagged
- % \endgroup % (3)
- \fi
- \ifnum\c_strc_itemgroups_column_depth=\c_strc_itemgroups_nesting\relax
- \strc_itemgroups_stop_columns
- \global\c_strc_itemgroups_column_depth\zerocount % global ?
- \strc_itemgroups_tag_stop_group
- \strc_itemgroups_after_command
- \dontrechecknextindentation
- \orelse\ifnum\c_strc_itemgroups_nesting=\plusone
- \strc_itemgroups_insert_breakallow
- \strc_itemgroups_tag_stop_group
- \strc_itemgroups_after_command
- \useindentnextparameter\itemgroupparameter
- \else
- % nieuw, not yet nobreak handling
- \strc_itemgroups_tag_stop_group
- \ifcase\c_strc_itemgroups_spacing_mode
- \strc_itemgroups_after_command
- \or
- \strc_itemgroups_after_command
- \fi
- \dontrechecknextindentation
- \fi
- % new test, needed in sidefloats (surfaced in volker's proceedings)
- \iftrialtypesetting
- \strc_counters_restore\v_strc_itemgroups_counter % could happen in LUA
- \fi
- \global\advance\c_strc_itemgroups_nesting\minusone
- \xdef\currentitemlevel{\number\c_strc_itemgroups_nesting}%
- %\ifconditional\c_strc_itemgroups_text
- \endgroup % (2)
- \endgroup % (1)
- %\else
- % \endgroup % (2)
- % \endgroup % (1)
- % \par % hm, already done, and dangerous as \c_strc_itemgroups_text is already forgotten
- %\fi
- \dorechecknextindentation}
-
-% The items.
-
-\unexpanded\def\startitemgroupitem
- {\dosingleempty\strc_itemgroups_start_item}
-
-\def\strc_itemgroups_start_item_first
- {\setfalse\c_strc_itemgroups_first
- % \begingroup % (3)
- \ifcase\c_strc_itemgroups_nesting
- % 0
- \or
- \strc_itemgroups_start_item_first_one % 1
- \else
- \strc_itemgroups_start_item_first_two % 2+
- \fi}
-
-\def\strc_itemgroups_start_item_first_one
- {\ifcase\c_strc_itemgroups_column_depth
- \ifconditional\c_strc_itemgroups_intro\strc_itemgroups_insert_breakno\fi
- \strc_itemgroups_before_command
- \strc_itemgroups_tag_start_group
- \ifconditional\c_strc_itemgroups_intro\strc_itemgroups_insert_breakno\fi
- \fi}
-
-\def\strc_itemgroups_start_item_first_two
- {\ifconditional\c_strc_itemgroups_paragraph\else
- \edef\previtemlevel{\the\numexpr\c_strc_itemgroups_nesting-\plusone}%
- \ifcase\c_strc_itemgroups_spacing_mode
- \strc_itemgroups_before_command
- \or
- \doifelsenothing\strc_itemgroups_before_command % should possibly expand to empty
- {\nameditemgroupparameter{\currentparentitemgroup:\previtemlevel}\c!inbetween}%
- \strc_itemgroups_before_command
- \else
- \nameditemgroupparameter{\currentparentitemgroup:\previtemlevel}\c!inbetween
- \fi
- \strc_itemgroups_tag_start_group
- \fi}
-
-\def\strc_itemgroups_start_item_next
- {\dostoptagged % ok? what do we stop here?
- \dostoptagged % ok? what do we stop here?
- \ifconditional\c_strc_itemgroups_text
- \ifhmode
- % WS: make the distance between items customizable, think about better default values -> see itemize-1.tex
- \strc_itemgroups_set_text_item_distance% HH: moved out and made configurable (sort of)
- \removeunwantedspaces
- \hskip\m_strc_itemgroups_text_distance\relax
- \fi
- \else
- \strc_itemgroups_between_command
- \fi}
-
-% c_strc_itemgroups_concat:
-%
-% the problem is that we use leftskip so concat cannot reliable take the height into
-% account; it's .. rather tricky when white space in there anyway (due to \par) .. so
-% we rely on a special blank method
-%
-% \startitemize[n]
-% \item bla
-% \item \startitemize[a]
-% \item bla $\displaystyle\int^{x^{y^4}}$ \item bla
-% \stopitemize
-% \stopitemize
-
-\unexpanded\def\strc_itemgroups_start_item[#reference]% we can reuse more
- {\def\currentitemreference{#reference}%
- \ifconditional\c_strc_itemgroups_text
- % begin of item
- \else
- \par
- \fi
- \ifconditional\c_strc_itemgroups_concat
- \strc_itemgroups_insert_breakno
- \fi
- \strc_itemgroups_increment_item_counter
- \ifconditional\c_strc_itemgroups_first
- \strc_itemgroups_start_item_first
- \else
- \strc_itemgroups_start_item_next
- \fi
- \ifconditional\c_strc_itemgroups_concat
- \spac_overlay_lines % see spac-ver.mkvi ... a typical potential problem
- \setfalse\c_strc_itemgroups_concat
- \fi
- \dostarttagged\t!item\empty
- % \dotagsetitem\empty
- \dostarttagged\t!itemtag\empty
- \strc_itemgroups_insert_item
- \dostoptagged
- \ifconditional\c_strc_itemgroups_pack
- \setupwhitespace[\v!none]%
- \fi
- \itemgroupparameter\c!inner % will become obsolete (better use setups)
- \strc_itemgroups_margin_symbol
- \let\strc_itemgroups_margin_symbol\relax
- \dostarttagged\t!itemcontent\empty
- \begstrut % \strut
- \nobreak % else problems with intext items
- \seteffectivehsize % NEW !
- \hskip\d_strc_itemgroups_signal % concat
- \itemgroupparameter\c!command}
-
-\unexpanded\def\stopitemgroupitem
- {\ifhmode
- \endstrut % new per 2017-12-15
- \fi
- \ifconditional\c_strc_itemgroups_text
- % nothing
- \else
- \endgraf
- \fi}
-\unexpanded\def\startitemgrouphead
- {\dosingleempty\strc_itemgroups_start_head}
-
-\unexpanded\def\strc_itemgroups_start_head[#reference]%
- {\ifconditional\c_strc_itemgroups_first \else
- \strc_itemgroups_insert_breakallow
- \fi
- \ifconditional\c_strc_itemgroups_pack \else
- \strc_itemgroups_before_head_command
- \fi
- \ifconditional\c_strc_itemgroups_first
- \ifconditional\c_strc_itemgroups_intro \else
- \ifcase\c_strc_itemgroups_nesting
- \strc_itemgroups_insert_breakallow
- \fi
- \fi
- \fi
- \strc_itemgroups_start_item[#reference]%
- \pickupgroupedcommand
- \strc_itemgroups_start_head_indeed
- \strc_itemgroups_stop_head_indeed
- \strc_itemgroups_head_body_indeed}
-
-\unexpanded\def\stopitemgrouphead
- {\dostoptagged
- \stopitemgroupitem}
-
-\unexpanded\def\strc_itemgroups_start_head_indeed
- {\settrue\c_strc_itemgroups_head
- \dotagsetitem\s!head% % weird place
- \dostarttagged\t!itemhead\empty
- \useitemgroupstyleandcolor\c!headstyle\c!headcolor\ignorespaces}
-
-\unexpanded\def\strc_itemgroups_stop_head_indeed
- {\removeunwantedspaces
- \dostoptagged
- \ifconditional\c_strc_itemgroups_inline_head
- \space
- \ignorespaces
- \else
- \ifconditional\c_strc_itemgroups_text
- \space
- \ignorespaces
- \else
- \par
- \fi
- \strc_itemgroups_insert_breakno
- \ifconditional\c_strc_itemgroups_pack\else\strc_itemgroups_after_head_command\fi
- \strc_itemgroups_insert_breakno
- \fi}
-
-\unexpanded\def\strc_itemgroups_head_body_indeed
- {\dostarttagged\t!itembody\empty
- \noindentation
- \ignorespaces}
-
-% Simple commands.
-
-\unexpanded\def\strc_itemgroups_start_do_item
- {\startitemgroupitem}
-
-\unexpanded\def\strc_itemgroups_start_no_item
- {\let\currentitemreference\empty
- \strc_itemgroups_increment_item_counter
- %\advance\c_strc_itemgroups_n_of_items\plusone
- \setbox\b_strc_itemgroups\emptyhbox
- \strc_itemgroups_check_for_repeated
- \ignorespaces}
-
-\unexpanded\def\strc_itemgroups_start_button[#destination]%
- {\edef\m_strc_itemgroups_destination{#destination}%
- \startitemgroupitem}
-
-\unexpanded\def\strc_itemgroups_start_symbol#text%
- {\def\strc_itemgroups_extra_symbol{#text}%
- \settrue\c_strc_itemgroups_symbol
- \startitemgroupitem
- \dotagsetitem\s!symbol}
-
-\unexpanded\def\strc_itemgroups_start_dummy
- {\strc_itemgroups_start_symbol
- %\strut\strut} % two ?
- \begstrut}
-
-\unexpanded\def\strc_itemgroups_start_subitem
- {\settrue\c_strc_itemgroups_sub
- \startitemgroupitem
- \dotagsetitem\s!sub}
-
-\unexpanded\def\strc_itemgroups_start_edge#text%
- {\strc_itemgroups_start_symbol
- {\strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting
- \dostarttagged\t!ignore\empty % for the moment, maybe an attribute
- \hbox to \d_strc_itemgroups_list_width
- {#text\hskip\itemgroupparameter\c!distance}%
- \dostoptagged}}
-
-\unexpanded\def\strc_itemgroups_start_margin#text%
- {\def\strc_itemgroups_margin_symbol % brrr
- {\dostarttagged\t!ignore\empty % for the moment, maybe an attribute
- \llap
- {\begingroup
- \useitemgroupstyleandcolor\c!marstyle\c!marcolor
- #text% keep em/ex local
- \endgroup
- \hskip\dimexpr\leftskip+\leftmargindistance\relax}%
- \dostoptagged}%
- \startitemgroupitem
- \dotagsetitem\s!margin}
-
-\unexpanded\def\strc_itemgroups_start_text#text%
- {\def\strc_itemgroups_extra_symbol{#text}%
- \settrue\c_strc_itemgroups_symbol
- \settrue\c_strc_itemgroups_txt
- \startitemgroupitem}
-
-% \unexpanded\def\strc_itemgroups_start_head
-% {\settrue\c_strc_itemgroups_head
-% \startitemgrouphead}
-
-\unexpanded\def\strc_itemgroups_start_items
- {\dosingleempty\strc_itemgroups_start_items_indeed}
-
-\unexpanded\def\strc_itemgroups_start_items_indeed[#whatever]% something got lost
- {\strc_itemgroups_start_edge
- {\dorecurse{0\itemgroupparameter\c!items}{\strc_itemgroups_used_symbol\hss}%
- \unskip}}
-
-% \unexpanded\def\startspecialitemgroupitem[#name]%
-% {\csname\??itemgroupstart\ifcsname\??itemgroupstart#name\endcsname#name\else\v!item\fi\endcsname}
-
-\unexpanded\def\startspecialitemgroupitem[#name]%
- {\ifcsname\??itemgroupstart#name\endcsname
- \expandafter\lastnamedcs
- \else
- \expandafter\strc_itemgroups_start_do_item
- \fi}
-
-\unexpanded\def\stopspecialitemgroupitem
- {\stopitemgroupitem}
-
-\letvalue{\??itemgroupstart\v!item}\strc_itemgroups_start_do_item
-\letvalue{\??itemgroupstart\v!sub }\strc_itemgroups_start_subitem
-\letvalue{\??itemgroupstart\v!sym }\strc_itemgroups_start_symbol
-\letvalue{\??itemgroupstart\v!ran }\strc_itemgroups_start_edge
-\letvalue{\??itemgroupstart\v!its }\strc_itemgroups_start_items
-\letvalue{\??itemgroupstart\v!mar }\strc_itemgroups_start_margin
-
-\def\optimizelistitemsbreak
- {\ifcase\c_strc_itemgroups_column_depth
- \ifconditional\c_strc_itemgroups_optimize
- \ifcase\c_strc_itemgroups_max_items
- \orelse\ifnum\c_strc_itemgroups_max_items=\plusthree
- \ifnum\c_strc_itemgroups_n_of_items>\plusone
- \strc_itemgroups_insert_nobreak
- \fi
- \orelse\ifnum\c_strc_itemgroups_max_items>\plusthree
- \ifnum\c_strc_itemgroups_n_of_items=\plustwo
- \ifconditional\c_strc_itemgroups_intro
- \strc_itemgroups_insert_breakno
- \else
- \strc_itemgroups_insert_nobreak
- \fi
- \orelse\ifnum\c_strc_itemgroups_max_items=\c_strc_itemgroups_n_of_items\relax
- \strc_itemgroups_insert_nobreak
- \orelse\ifnum\c_strc_itemgroups_n_of_items>\plustwo
- \strc_itemgroups_insert_break
- \else
- \ifconditional\c_strc_itemgroups_intro\else\strc_itemgroups_insert_break\fi
- \fi
- \fi
- \fi
- \fi}
-
-\def\strc_itemgroups_handle_text_item
- {\scratchdimen\wd\b_strc_itemgroups
- \advance \scratchdimen \itemgroupparameter\c!distance\relax
- \ifdim\scratchdimen>\d_strc_itemgroups_list_width
- \advance\scratchdimen -\d_strc_itemgroups_list_width
- \else
- \scratchdimen\zeropoint
- \fi
- \llap{\hbox to \d_strc_itemgroups_list_width{\ifconditional\c_strc_itemgroups_sub\llap{+\enspace}\fi\box\b_strc_itemgroups\hss}}% was: \hfill
- \hskip\scratchdimen}
-
-\def\strc_itemgroups_handle_lapped_item_positive
- {\llap
- {\dontcomplain
- \hbox to \d_strc_itemgroups_list_width
- {\ifconditional\c_strc_itemgroups_sub
- \dostarttagged\t!ignore\empty
- \llap{+\enspace}%
- \dostoptagged
- \fi
- \strc_itemgroups_left_sym_filler
- \box\b_strc_itemgroups % can already have a forced widt, only factor handled here
- \hfil
- \hskip\itemgroupparameter\c!distance}}}
-
-\def\strc_itemgroups_handle_lapped_item_negative
- {\llap
- {\ifconditional\c_strc_itemgroups_sub
- \dostarttagged\t!ignore\empty
- \llap{+\enspace}%
- \dostoptagged
- \fi
- \box\b_strc_itemgroups
- \hskip\leftmargindistance}}
-
-\def\strc_itemgroups_handle_groups_text_item
- {\hbox
- {\ifconditional\c_strc_itemgroups_sub
- \dostarttagged\t!ignore\empty
- +\enspace
- \dostoptagged
- \fi
- \box\b_strc_itemgroups
- \hskip\interwordspace}%
- \nobreak}
-
-\def\strc_itemgroups_handle_groups_inline_item
- {\hbox to \d_strc_itemgroups_list_width
- {\ifconditional\c_strc_itemgroups_sub
- \dostarttagged\t!ignore\empty
- \llap{+\enspace}%
- \dostoptagged
- \fi
- \box\b_strc_itemgroups
- \hss}} % was: \hfill
-
-\unexpanded\def\strc_itemgroups_start_head_sym#text%
- {\def\strc_itemgroups_extra_symbol{#text}%
- \settrue\c_strc_itemgroups_symbol
- \settrue\c_strc_itemgroups_head
- \strc_itemgroups_start_head}
-
-\def\strc_itemgroups_make_symbol_box
- {\setbox\b_strc_itemgroups\autodirhbox
- {\ifconditional\c_strc_itemgroups_head
- \ifconditional\c_strc_itemgroups_symbol
- \strc_itemgroups_insert_extra_reference
- \useitemgroupstyleandcolor\c!symstyle\c!symcolor
- \strc_itemgroups_extra_symbol
- \else
- \useitemgroupstyleandcolor\c!headstyle\c!headcolor
- \strc_itemgroups_used_symbol
- \fi
- \else
- \ifconditional\c_strc_itemgroups_symbol
- \strc_itemgroups_insert_extra_reference
- \useitemgroupstyleandcolor\c!symstyle\c!symcolor
- \strc_itemgroups_extra_symbol
- \else
- \useitemgroupstyleandcolor\c!style\c!color
- \strc_itemgroups_used_symbol
- \fi
- \fi}%
- \let\strc_itemgroups_extra_symbol\empty
- \setfalse\c_strc_itemgroups_symbol}
-
-\def\strc_itemgroups_make_fitting_box
- {\ifdim\wd\b_strc_itemgroups>\itemgroupparameter\c!maxwidth\relax
- \normalexpanded{\global\setitemgroupparameter{\c!maxwidth}{\the\wd\b_strc_itemgroups}}%
- \fi
- \ifdim\d_strc_itemgroups_max_width>\zeropoint
- \setbox\b_strc_itemgroups\simplealignedbox
- {\dimexpr\d_strc_itemgroups_max_width+\itemgroupparameter\c!distance\relax}
- {\itemgroupparameter\c!itemalign}
- {\box\b_strc_itemgroups\hskip\itemgroupparameter\c!distance}%
- \fi}
-
-\def\strc_itemgroups_make_aligned_box
- {\doifsomething{\itemgroupparameter\c!itemalign}
- {\setbox\b_strc_itemgroups\simplealignedbox
- {\dimexpr\d_strc_itemgroups_asked_width+\itemgroupparameter\c!distance\relax}
- {\itemgroupparameter\c!itemalign}
- {\box\b_strc_itemgroups\hskip\itemgroupparameter\c!distance}}}
-
-\def\strc_itemgroups_make_destination_box
- {\iftrialtypesetting \orelse \ifx\m_strc_itemgroups_destination\empty \else
- \setbox\b_strc_itemgroups\hbox{\directgotobox{\box\b_strc_itemgroups}[\m_strc_itemgroups_destination]}%
- \fi}
-
-\def\strc_itemgroups_check_indenting
- {\setfalse\c_strc_itemgroups_indented_first
- \ifx\m_strc_itemgroups_indenting\empty \else
- \normalexpanded{\setupindenting[\v!reset,\v!yes,\m_strc_itemgroups_indenting]}%
- \ifconditional\c_spac_indentation_indent_first % better is to have a mode
- \doifnot{\itemgroupparameter\c!alignsymbol}\v!yes
- {\settrue\c_strc_itemgroups_indented_first}%
- \fi
- \fi}
-
-\def\strc_itemgroups_check_for_repeated
- {\ifconditional\c_strc_itemgroups_repeat
- \ifx\m_strc_itemgroups_repeat_start\empty
- \edef\m_strc_itemgroups_repeat_start{\currentitemlevel}%
- \fi
- \else
- \let\m_strc_itemgroups_repeat_start\empty
- \fi}
-
-\def\strc_itemgroups_insert_item
- {\ifconditional\c_strc_itemgroups_text % again?
- % begin of item
- \else
- \par % done twice?
- \fi
- \advance\c_strc_itemgroups_n_of_items\plusone
- \optimizelistitemsbreak
- \strc_itemgroups_check_indenting
- \dontleavehmode
- \ifconditional\c_strc_itemgroups_indented_first
- \hskip-\parindent
- \fi
- \strc_itemgroups_make_symbol_box
- \strc_itemgroups_make_destination_box
- \ifconditional\c_strc_itemgroups_fitting
- \strc_itemgroups_make_fitting_box
- \else\ifdim\d_strc_itemgroups_asked_width>\zeropoint
- \strc_itemgroups_make_aligned_box
- \fi\fi
- \let\m_strc_itemgroups_destination\empty
- \ht\b_strc_itemgroups\strutheight % just in case a symbols is not yet available in
- \dp\b_strc_itemgroups\strutdepth % the current run (more a mkii mp side artifact)
- \strc_itemgroups_check_for_repeated
- \ifdim\d_strc_itemgroups_asked_width<\zeropoint\relax
- \strc_itemgroups_handle_lapped_item_negative
- \else
- \ifzeropt\d_strc_itemgroups_asked_width
- \strc_itemgroups_calculate_list_width\plusone
- \else
- \strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting
- \fi
- \ifconditional\c_strc_itemgroups_text
- \strc_itemgroups_handle_groups_text_item
- \orelse\ifconditional\c_strc_itemgroups_inline
- \strc_itemgroups_handle_groups_inline_item
- \orelse\ifconditional\c_strc_itemgroups_txt
- \strc_itemgroups_handle_text_item
- \else
- \strc_itemgroups_handle_lapped_item_positive
- \fi
- \fi
- \setfalse\c_strc_itemgroups_head
- \setfalse\c_strc_itemgroups_sub
- \ifconditional\c_strc_itemgroups_indented_first
- \hskip\parindent
- \fi
- \ignorespaces}
-
-\def\strc_itemgroups_start_item_nop
- {\let\currentitemreference\empty
- \strc_itemgroups_increment_item_counter
- \advance\c_strc_itemgroups_n_of_items\plusone
- \setbox\b_strc_itemgroups\hbox
- {\useitemgroupstyleandcolor\c!style\c!color
- \strc_itemgroups_used_symbol}%
- \strc_itemgroups_check_for_repeated
- \ignorespaces}
-
-\setvalue{\??itemgroupdistance\v!none}%
- {\let\m_strc_itemgroups_text_distance\zeropoint}
-
-\setvalue{\??itemgroupdistance\v!space}%
- {\def\m_strc_itemgroups_text_distance{\interwordspace\!!plus\interwordstretch\!!minus\interwordshrink}}
-
-\setvalue\??itemgroupdistance % catches empty value
- {\let\m_strc_itemgroups_text_distance\zeropoint}
-
-\unexpanded\def\strc_itemgroups_set_text_item_distance
- {\edef\m_strc_itemgroups_text_distance{\itemgroupparameter\c!textdistance}%
- \ifx\m_strc_itemgroups_text_distance\empty
- %
- \orelse\ifcsname\??itemgroupdistance\m_strc_itemgroups_text_distance\endcsname
- \lastnamedcs
- \else
- \strc_itemgroups_set_text_item_distance_indeed
- \fi}
-
-\def\strc_itemgroups_set_text_item_distance_indeed
- {\assignvalue
- \m_strc_itemgroups_text_distance
- \m_strc_itemgroups_text_distance
- {.5\interwordspace\!!plus.5\emwidth}%
- {\interwordspace \!!plus \emwidth}%
- {\emwidth \!!plus \interwordstretch\!!minus\interwordshrink}}
-
-% \unexpanded\def\strc_itemgroups_default_command
-% {\EveryPar{\ignorespaces}% needed ?
-% \ignorespaces}
-
-\unexpanded\def\strc_itemgroups_default_command
- {\ignorespaces}
-
-%D Special case:
-
-\unexpanded\def\strc_itemgroups_head#text\par
- {\startitemgrouphead{#text}}
-
-%D The local commands:
-
-\appendtoks
- \let\item \strc_itemgroups_start_do_item
- \let\noitem \strc_itemgroups_start_no_item
- \let\itm \strc_itemgroups_start_do_item
- \let\but \strc_itemgroups_start_button
- \let\nop \strc_itemgroups_start_dummy
- \let\txt \strc_itemgroups_start_text
- \let\head \strc_itemgroups_head
- \let\headsym \strc_itemgroups_start_head_sym
- \let\startitem \startitemgroupitem
- \let\stopitem \stopitemgroupitem
- \let\starthead \startitemgrouphead
- \let\stophead \stopitemgroupitemhead
- \let\startspecialitem\startspecialitemgroupitem
- \let\stopspecialitem \stopspecialitemgroupitem
-\to \itemgroupcommands
-
-\ifx\currentinterface \v!english \else
-
- \appendtoks
- \expandafter\let\csname\v!item \endcsname\strc_itemgroups_start_do_item
- \expandafter\let\csname\v!sub \endcsname\strc_itemgroups_start_subitem
- \expandafter\let\csname\v!sym \endcsname\strc_itemgroups_start_symbol
- \expandafter\let\csname\v!ran \endcsname\strc_itemgroups_start_edge
- \expandafter\let\csname\v!head \endcsname\strc_itemgroups_head
- \expandafter\let\csname\v!its \endcsname\strc_itemgroups_start_items
- \expandafter\let\csname\v!mar \endcsname\strc_itemgroups_start_margin
- \expandafter\let\csname\v!txt \endcsname\strc_itemgroups_start_text
- \expandafter\let\csname\e!start\v!item\endcsname\startitemgroupitem
- \expandafter\let\csname\e!stop \v!item\endcsname\stopitemgroupitem
- \expandafter\let\csname\e!start\v!head\endcsname\startitemgrouphead
- \expandafter\let\csname\e!stop \v!head\endcsname\stopitemgrouphead
- \to \itemgroupcommands
-
-\fi
-
-\relaxvalueifundefined \v!item
-\relaxvalueifundefined \v!sub
-\relaxvalueifundefined \v!sym
-\relaxvalueifundefined \v!ran
-\relaxvalueifundefined \v!head
-\relaxvalueifundefined \v!its
-\relaxvalueifundefined \v!mar
-\relaxvalueifundefined \v!txt
-\relaxvalueifundefined {\e!start\v!item}
-\relaxvalueifundefined {\e!stop \v!item}
-\relaxvalueifundefined {\e!start\v!head}
-\relaxvalueifundefined {\e!stop \v!head}
-
-%D A nice example of a plugin:
-%D
-%D \startbuffer
-%D \startitemize[a,random,packed]
-%D \startitem first \stopitem \startitem second \stopitem
-%D \startitem third \stopitem \startitem fourth \stopitem
-%D \stopitemize
-%D
-%D \startitemize[a,random,packed]
-%D \startitem first \stopitem \startitem second \stopitem
-%D \startitem third \stopitem \startitem fourth \stopitem
-%D \stopitemize
-%D
-%D \startitemize[a,packed]
-%D \startitem first \stopitem \startitem second \stopitem
-%D \startitem third \stopitem \startitem fourth \stopitem
-%D \stopitemize
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-% better collectitems als conditional and a real plugin mechanism (some day)
-
-\newcount\c_strc_itemgroups_collected_stored
-\newcount\c_strc_itemgroups_collected_done
-\newcount\c_strc_itemgroups_collected_current
-
-% \expandafter\def\expandafter\strc_itemgroups_collected_store\expandafter#\expandafter1\csname\e!stop\v!item\endcsname % use grabuntil
-% {\advance\c_strc_itemgroups_collected_stored\plusone
-% \setvalue{\??itemgroupstack\number\c_strc_itemgroups_collected_stored}{\startitemgroupitem#1\stopitemgroupitem}}
-
-\let\strc_itemgroups_collected_store\relax
-
-\normalexpanded{\def\strc_itemgroups_collected_store#1\csname\e!stop\v!item\endcsname}%
- {\advance\c_strc_itemgroups_collected_stored\plusone
- \setvalue{\??itemgroupstack\number\c_strc_itemgroups_collected_stored}{\startitemgroupitem#1\stopitemgroupitem}}
-
-\def\strc_itemgroups_collected_flush_randomize
- {\collecteditemgroupitem}
-
-\def\strc_itemgroups_collected_flush_horizontal
- {\begingroup
- \scratchcounter\itemgroupparameter\c!n\relax
- \ifnum\c_strc_itemgroups_collected_done>\plusone
- \ifcase\modulonumber\scratchcounter\c_strc_itemgroups_collected_done\relax
- % compensate for rounding errors
- \hfill % \hskip\zeropoint plus \scaledpoint minus \scaledpoint
- \allowbreak
- \fi
- \fi
- \noindent % no \dontleavehmode
- \hbox to \dimexpr\availablehsize/\scratchcounter\relax{\collecteditemgroupitem\hss}%
- \endgroup}
-
-% \def\strc_itemgroups_collected_flush_indeed
-% {\collecteditemgroupitem
-% \iftrialtypesetting
-% \undefinevalue{\??itemgroupstack\number\c_strc_itemgroups_collected_current}%
-% \fi}
-
-\def\strc_itemgroups_collected_flush_indeed
- {\collecteditemgroupitem
- \undefinevalue{\??itemgroupstack\number\c_strc_itemgroups_collected_current}}
-
-\def\strc_itemgroups_collected_flush
- {\ifconditional\c_strc_itemgroups_randomize
- \getrandomcount\c_strc_itemgroups_collected_current\plusone\c_strc_itemgroups_collected_stored
- \else
- \advance\c_strc_itemgroups_collected_current\plusone
- \fi
- \ifcsname\??itemgroupstack\number\c_strc_itemgroups_collected_current\endcsname
- \edef\collecteditemgroupitem{\lastnamedcs}%
- \ifconditional\c_strc_itemgroups_horizontal
- \strc_itemgroups_collected_flush_horizontal
- \else
- \strc_itemgroups_collected_flush_indeed
- \fi
- \advance\c_strc_itemgroups_collected_done\plusone
- \fi
- \ifnum\c_strc_itemgroups_collected_done<\c_strc_itemgroups_collected_stored
- \expandafter\strc_itemgroups_collected_flush
- \fi}
-
-\unexpanded\def\stopcollectitems
- {\ifconditional\c_strc_itemgroups_collecting
- \c_strc_itemgroups_collected_done \zerocount
- \c_strc_itemgroups_collected_current\zerocount
- \ifnum\c_strc_itemgroups_collected_stored>\zerocount
- \ifconditional\c_strc_itemgroups_horizontal
- \strc_itemgroups_before_command
- \setfalse\c_strc_itemgroups_first
- \strc_itemgroups_collected_flush
- %\strc_itemgroups_after_command % triggered elsewhere
- \else
- \strc_itemgroups_collected_flush
- \fi
- \fi
- \fi}
-
-\unexpanded\def\startcollectitems
- {\ifconditional\c_strc_itemgroups_collecting
- \c_strc_itemgroups_collected_stored\zerocount
- \letvalue{\e!start\v!item}\strc_itemgroups_collected_store
- \fi}
-
-%D Left-overs:
-
-\unexpanded\def\item
- {\strc_itemgroups_item_alone}
-
-\def\strc_itemgroups_item_alone[#category]#text\par
- {\doifelsesomething{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}%
- \startitem#text\stopitem
- \stopitemgroup}
-
-\unexpanded\def\head
- {\strc_itemgroups_head_alone}
-
-\def\strc_itemgroups_head_alone[#category]#head\par#body\par
- {\doifelsesomething{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}%
- \starthead{#head}#body\stophead
- \stopitemgroup}
-
-\setuvalue{\e!start\v!item}%
- {\startitemgroup[\v!itemize]%
- \startitemgroupitem
- \setuvalue{\e!stop\v!item}{\stopitemgroupitem\stopitemgroup}}
-
-% \def\sym#text%
-% {\noindent
-% \begingroup
-% \setbox\scratchbox\hbox{\settrialtypesetting#text}%
-% \setbox\scratchbox\hbox\ifdim\wd\scratchbox<1em to 1.5\else spread 1\fi em{#text\hfil}%
-% \normalexpanded{\box\scratchbox\endgroup\hangindent\the\wd\scratchbox}%
-% \ignorespaces}
-
-%D End of plugin.
-
-%D Something for tables:
-
-\unexpanded\def\itemtag
- {\dosingleempty\strc_itemgroups_item_tag}
-
-\unexpanded\def\strc_itemgroups_item_tag[#reference]% we can reuse more
- {\def\currentitemreference{#reference}%
- \iftrialtypesetting
- \strc_counters_save\v_strc_itemgroups_counter
- \strc_itemgroups_increment_item_counter
- \strc_itemgroups_insert_item_tag_indeed
- \strc_counters_restore\v_strc_itemgroups_counter
- \else
- \strc_itemgroups_increment_item_counter
- \strc_itemgroups_insert_item_tag_indeed
- \fi}
-
-\def\strc_itemgroups_insert_item_tag_indeed
- {\letitemgroupparameter\c!distance\zeropoint
- %letitemgroupparameter\c!width\zeropoint
- \strc_itemgroups_make_symbol_box
- \strc_itemgroups_make_destination_box
- \let\m_strc_itemgroups_destination\empty
- \ht\b_strc_itemgroups\strutheight
- \dp\b_strc_itemgroups\strutdepth
- \box\b_strc_itemgroups
- \ignorespaces}
-
-%D Done again.
-
-\setupitemgroup
- [\c!margin=\zeropoint,
- \c!leftmargin=\zeropoint,
- \c!rightmargin=\zeropoint,
- \c!leftmargindistance=\zeropoint,
- \c!rightmargindistance=\zeropoint,
- \c!indentnext=\v!yes,
- \c!width=1.5\emwidth,
- \c!factor=0,
- %\c!distance=.5em, % is now:
- \c!step=.5\emwidth, % deals with broad
- \c!distance=\zeropoint,
- %\c!align=\v!normal, % definitely not \v!normal !
- %\c!symalign=,
- %\c!color=,
- %\c!indenting=, % untouched if empty
- %\c!style=,
- \c!marstyle=\v!type,
- %\c!symstyle=,
- %\c!headstyle=,
- %\c!marcolor=,
- %\c!symcolor=,
- %\c!headcolor=,
- %\c!beforehead=,
- \c!symcolor=\itemgroupparameter\c!color, % new per 2012.01.17
- \c!symstyle=\itemgroupparameter\c!style, % new per 2012.01.17
- \c!afterhead=\blank,
- \c!before=\blank,
- \c!inbetween=\blank,
- \c!after=\blank,
- %\c!stopper=.,
- \c!placestopper=\v!yes,
- \c!stopper=.,
- %\c!inner=,
- \c!n=2,
- \c!items=4,
- \c!levels=10,
- \c!lefttext=(,
- \c!righttext=),
- \c!start=1,
- \c!packcriterium=\zerocount,
- \c!criterium=\v!all, % permits 0 and negative numbers
- %\c!option=,
- \c!textdistance=\v!space, % none big medium small
- \c!command=\strc_itemgroups_default_command,
- \c!indenting=\v!next,
- %\c!alignsymbol=v!no,
- \c!symbol=\currentitemlevel,
- \c!prefix=\v!no,
- %\c!prefixstopper=.,
- %\c!prefixseparatorset=,
- %\c!prefixconversion=,
- %\c!prefixconversionset=,
- %\c!prefixset=,
- %\c!prefixsegments=1:100,
- \c!prefixconnector=.,
- \c!numberseparatorset=,
- \c!numberconversionset=,
- \c!numberstopper=.,
- \c!numbersegments=1]
-
-\defineitemgroup
- [\v!itemize]
-
-%D This is really ugly I should get rid of the global mess, whuch is a side
-%D effect of the simple \type {\item} interface that we're stuck with for
-%D compatibility reasons. See footnotes for usage. It's probablynot robust
-%D for mixed itemgroups so in the end I need to get rid of the globals. One
-%D problem is that counters are set.
-
-\defineitemgroup
- [\v!itemize:\v!note]
-
-\def\strc_itemgroups_push
- {\edef\strc_itemgroups_pop
- {\xdef\noexpand\currentitemlevel{\currentitemlevel}%
- \global\c_strc_itemgroups_nesting \the\c_strc_itemgroups_nesting \relax
- \global\c_strc_itemgroups_column_depth\the\c_strc_itemgroups_column_depth\relax}%
- \global\c_strc_itemgroups_column_depth\zerocount
- \global\c_strc_itemgroups_nesting \zerocount
- \glet\currentitemlevel\!!zerocount
- \unexpanded\def\startitemize{\startitemgroup[\v!itemize:\v!note]}%
- \unexpanded\def\stopitemize {\stopitemgroup}}
-
-\let\strc_itemgroups_pop\relax
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mkvi
index cbbefd5dbcc..a46923d3eb5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-itm.mkvi
@@ -676,6 +676,12 @@
\strc_itemgroups_insert_item_counter_indeed
\fi}
+\installcorenamespace{itemstopper}
+
+\setvalue{\??itemstopper\v!yes }{\itemgroupparameter\c!stopper}
+\setvalue{\??itemstopper\v!display}{\ifconditional\c_strc_itemgroups_inline\else\itemgroupparameter\c!stopper\fi}
+\setvalue{\??itemstopper\v!inline }{\ifconditional\c_strc_itemgroups_inline\itemgroupparameter\c!stopper\fi}
+
\def\strc_itemgroups_insert_item_counter_indeed % quite slow ... every time this setup .. but it
{\begingroup % can be optimized ... best move some to strc-num
\setupcounter
@@ -690,7 +696,7 @@
\c!prefixconnector=\itemgroupparameter\c!prefixconnector,
\c!criterium=\itemgroupparameter\c!criterium,
\c!numberorder=\ifconditional\c_strc_itemgroups_reverse\v!reverse\else\v!normal\fi,
- \c!numberstopper=\expdoif{\itemgroupparameter\c!placestopper}\v!yes{\itemgroupparameter\c!stopper},
+ \c!numberstopper=\begincsname\??itemstopper\itemgroupparameter\c!placestopper\endcsname,
\c!numberconversionset=\v_strc_itemgroups_counter,
\c!numbersegments=\currentitemgroupsegments]%
% there will be a fixedconversion key
@@ -1321,6 +1327,7 @@
\letvalue{\??itemgroupstart\v!ran }\strc_itemgroups_start_edge
\letvalue{\??itemgroupstart\v!its }\strc_itemgroups_start_items
\letvalue{\??itemgroupstart\v!mar }\strc_itemgroups_start_margin
+\letvalue{\??itemgroupstart\v!txt }\strc_itemgroups_start_text
\def\optimizelistitemsbreak
{\ifcase\c_strc_itemgroups_column_depth \ifconditional\c_strc_itemgroups_optimize
@@ -1538,7 +1545,7 @@
{\let\m_strc_itemgroups_text_distance\zeropoint}
\setvalue{\??itemgroupdistance\v!space}%
- {\def\m_strc_itemgroups_text_distance{\interwordspace\!!plus\interwordstretch\!!minus\interwordshrink}}
+ {\def\m_strc_itemgroups_text_distance{\interwordspace\s!plus\interwordstretch\s!minus\interwordshrink}}
\setvalue\??itemgroupdistance % catches empty value
{\let\m_strc_itemgroups_text_distance\zeropoint}
@@ -1557,9 +1564,9 @@
{\assignvalue
\m_strc_itemgroups_text_distance
\m_strc_itemgroups_text_distance
- {.5\interwordspace\!!plus.5\emwidth}%
- {\interwordspace \!!plus \emwidth}%
- {\emwidth \!!plus \interwordstretch\!!minus\interwordshrink}}
+ {.5\interwordspace\s!plus.5\emwidth}%
+ {\interwordspace \s!plus \emwidth}%
+ {\emwidth \s!plus \interwordstretch\s!minus\interwordshrink}}
% \unexpanded\def\strc_itemgroups_default_command
% {\EveryPar{\ignorespaces}% needed ?
@@ -1577,6 +1584,11 @@
\appendtoks
\let\item \strc_itemgroups_start_do_item
+ \let\sub \strc_itemgroups_start_subitem
+ \let\sym \strc_itemgroups_start_symbol
+ \let\ran \strc_itemgroups_start_edge
+ \let\its \strc_itemgroups_start_items
+ \let\mar \strc_itemgroups_start_margin
\let\noitem \strc_itemgroups_start_no_item
\let\itm \strc_itemgroups_start_do_item
\let\but \strc_itemgroups_start_button
@@ -1587,27 +1599,29 @@
\let\startitem \startitemgroupitem
\let\stopitem \stopitemgroupitem
\let\starthead \startitemgrouphead
- \let\stophead \stopitemgroupitemhead
+ \let\stophead \stopitemgrouphead
\let\startspecialitem\startspecialitemgroupitem
\let\stopspecialitem \stopspecialitemgroupitem
\to \itemgroupcommands
-\ifx\currentinterface \v!english \else
-
- \appendtoks
- \expandafter\let\csname\v!item \endcsname\strc_itemgroups_start_do_item
- \expandafter\let\csname\v!sub \endcsname\strc_itemgroups_start_subitem
- \expandafter\let\csname\v!sym \endcsname\strc_itemgroups_start_symbol
- \expandafter\let\csname\v!ran \endcsname\strc_itemgroups_start_edge
- \expandafter\let\csname\v!head \endcsname\strc_itemgroups_head
- \expandafter\let\csname\v!its \endcsname\strc_itemgroups_start_items
- \expandafter\let\csname\v!mar \endcsname\strc_itemgroups_start_margin
- \expandafter\let\csname\v!txt \endcsname\strc_itemgroups_start_text
- \expandafter\let\csname\e!start\v!item\endcsname\startitemgroupitem
- \expandafter\let\csname\e!stop \v!item\endcsname\stopitemgroupitem
- \expandafter\let\csname\e!start\v!head\endcsname\startitemgrouphead
- \expandafter\let\csname\e!stop \v!head\endcsname\stopitemgrouphead
- \to \itemgroupcommands
+\ifx\currentinterface \s!english \else
+
+ \def\next#1#2{\ifcsname#1\endcsname\else\let\csname#1\endcsname#2\fi}
+
+ \etoksapp\itemgroupcommands{%
+ \next{\v!item }\strc_itemgroups_start_do_item
+ \next{\v!sub }\strc_itemgroups_start_subitem
+ \next{\v!sym }\strc_itemgroups_start_symbol
+ \next{\v!ran }\strc_itemgroups_start_edge
+ \next{\v!head }\strc_itemgroups_head
+ \next{\v!its }\strc_itemgroups_start_items
+ \next{\v!mar }\strc_itemgroups_start_margin
+ \next{\v!txt }\strc_itemgroups_start_text
+ \next{\e!start\v!item}\startitemgroupitem
+ \next{\e!stop \v!item}\stopitemgroupitem
+ \next{\e!start\v!head}\startitemgrouphead
+ \next{\e!stop \v!head}\stopitemgrouphead
+ }
\fi
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lnt.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-lnt.mkvi
index ad8c80d93e6..0d35be90cdc 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-lnt.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lnt.mkvi
@@ -234,17 +234,15 @@
\let\strc_linenotes_traced\gobbleoneargument
\def\strc_linenotes_traced_indeed#1%
- {\iftracelinenotes
- \hpack to \zeropoint
- {\forgetall
- \hsize\zeropoint
- \hss
- \vpack to \strutheight{\llap{\red\infofont\setstrut\the\c_strc_linenotes}\vss}%
- {\color[blue]{\vl}}%
- \vpack to \strutheight{\rlap{\red\infofont\setstrut#1}\vss}%
- \hss}%
- \prewordbreak
- \fi}
+ {\hpack to \zeropoint
+ {\forgetall
+ \hsize\zeropoint
+ \hss
+ \vpack to \strutheight{\llap{\red\infofont\setstrut\the\c_strc_linenotes}\vss}%
+ {\color[blue]{\vl}}%
+ \vpack to \strutheight{\rlap{\red\infofont\setstrut#1}\vss}%
+ \hss}%
+ \prewordbreak}
\unexpanded\def\tracelinenotes
{\let\strc_linenotes_traced\strc_linenotes_traced_indeed}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lst.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-lst.lua
index bc6135e7242..a6799d80f1a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-lst.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lst.lua
@@ -835,14 +835,18 @@ function lists.getresult(r)
end
function lists.process(specification)
- lists.result = filtercollected(specification)
- local specials = settings_to_set(specification.extras or "")
- specials = next(specials) and specials or nil
- for i=1,#lists.result do
- local r = lists.result[i]
- local m = r.metadata
- local s = specials and r.numberdata and specials[zerostrippedconcat(r.numberdata.numbers,".")] or ""
- context.strclistsentryprocess(m.name,m.kind,i,s)
+ local result = filtercollected(specification)
+ local total = #result
+ lists.result = result
+ if total > 0 then
+ local specials = settings_to_set(specification.extras or "")
+ specials = next(specials) and specials or nil
+ for i=1,total do
+ local r = result[i]
+ local m = r.metadata
+ local s = specials and r.numberdata and specials[zerostrippedconcat(r.numberdata.numbers,".")] or ""
+ context.strclistsentryprocess(m.name,m.kind,i,s)
+ end
end
end
@@ -1050,6 +1054,7 @@ implement {
{ "bookmark" },
{ "marking" },
{ "list" },
+ { "reference" },
}
},
{ "prefixdata", {
@@ -1212,7 +1217,7 @@ implement {
implement { name = "doifelselisthastitle", actions = { lists.hastitledata, commands.doifelse }, arguments = { "string", "integer" } }
implement { name = "doifelselisthaspage", actions = { lists.haspagedata, commands.doifelse }, arguments = { "string", "integer" } }
implement { name = "doifelselisthasnumber", actions = { lists.hasnumberdata, commands.doifelse }, arguments = { "string", "integer" } }
-implement { name = "doifelselisthasentry", actions = { lists.iscached, commands.doifelse }, arguments = { "integer" } }
+implement { name = "doifelselisthasentry", actions = { lists.iscached, commands.doifelse }, arguments = "integer" }
local function savedlisttitle(name,n,tag)
local data = cached[tonumber(n)]
@@ -1270,7 +1275,7 @@ implement {
implement {
name = "discardfromlist",
actions = lists.discard,
- arguments = { "integer" }
+ arguments = "integer"
}
-- new and experimental and therefore off by default
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi
index d29b1f6fdae..e3a466656c3 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi
@@ -76,7 +76,7 @@
%\c!inbetween=,
%\c!symbol=,
%\c!expansion=,
- \c!limittext=\languageparameter\c!limittext] % not used currently
+ \c!limittext=\languageparameter\c!limittext] % not used currently
%D Helpers:
@@ -242,7 +242,7 @@
%D When placing a list either one or a set can be giving. This makes
%D it possible to flush for instance an nested (or merged) table of
%D contents. Keep in mind that placing a list is what we do most (think
-%D of tables of contents, figures, etc.\ but other usag eis also possible
+%D of tables of contents, figures, etc.\ but other usage is also possible
%D in which case low level commands have to be used.
\newtoks\everystructurelist
@@ -367,6 +367,17 @@
\unexpanded\def\savedlisttitle #1#2{\clf_savedlisttitle {#1}\numexpr#2\relax}
\unexpanded\def\savedlistprefixednumber#1#2{\clf_savedlistprefixednumber{#1}\numexpr#2\relax}
+\newconditional\c_lists_show_realpage
+
+\installcorenamespace {listpagenumber}
+
+\setvalue{\??listpagenumber\v!always }{\settrue\c_lists_show_page\settrue\c_lists_has_page}
+\setvalue{\??listpagenumber\v!yes }{\settrue\c_lists_show_page}
+\setvalue{\??listpagenumber\s!realpage}{\settrue\c_lists_show_page\settrue\c_lists_show_realpage}
+
+\def\strc_lists_process_pagenumber#1%
+ {\begincsname\??listpagenumber#1\endcsname}
+
\def\structurelistlocation
{\clf_listlocation\numexpr\currentlistindex\relax}
@@ -375,23 +386,27 @@
\unexpanded\def\structurelistpagenumber
{\dostarttagged\t!listpage\empty
- \clf_listprefixedpage
- {\currentlist}%
- \currentlistindex
- {
- separatorset {\listparameter\c!pageprefixseparatorset}
- conversionset {\listparameter\c!pageprefixconversionset}
- set {\listparameter\c!pageprefixset}
- segments {\listparameter\c!pageprefixsegments}
- connector {\listparameter\c!pageprefixconnector}
- }%
- {
- prefix {\listparameter\c!pageprefix}
- conversionset {\listparameter\c!pageconversionset}
- starter {\listparameter\c!pagestarter}
- stopper {\listparameter\c!pagestopper}
- }%
- \relax
+ \ifconditional\c_lists_show_realpage
+ \clf_listrealpage{\currentlist}\numexpr\currentlistindex\relax
+ \else
+ \clf_listprefixedpage
+ {\currentlist}%
+ \currentlistindex
+ {
+ separatorset {\listparameter\c!pageprefixseparatorset}
+ conversionset {\listparameter\c!pageprefixconversionset}
+ set {\listparameter\c!pageprefixset}
+ segments {\listparameter\c!pageprefixsegments}
+ connector {\listparameter\c!pageprefixconnector}
+ }%
+ {
+ prefix {\listparameter\c!pageprefix}
+ conversionset {\listparameter\c!pageconversionset}
+ starter {\listparameter\c!pagestarter}
+ stopper {\listparameter\c!pagestopper}
+ }%
+ \relax
+ \fi
\dostoptagged}
\unexpanded\def\structurelistuservariable#name%
@@ -402,8 +417,8 @@
\def\rawstructurelistuservariable#name%
{\clf_listuserdata{\currentlist}\currentlistindex{#name}}
-\unexpanded\def\structurelistfirst {\structurelistuservariable\s!first } % s!
-\unexpanded\def\structurelistsecond {\structurelistuservariable\s!second} % s!
+\unexpanded\def\structurelistfirst {\structurelistuservariable\s!first } % s!
+\unexpanded\def\structurelistsecond{\structurelistuservariable\s!second} % s!
\def\rawstructurelistfirst {\rawstructurelistuservariable\s!first } % s! % was \unexpanded
\def\rawstructurelistsecond{\rawstructurelistuservariable\s!second} % s! % was \unexpanded
@@ -612,14 +627,14 @@
{\strut\symbol[bullet]}
\unexpanded\def\strc_lists_symbol_two
- {\vrule\!!width\emwidth\!!height\exheight\!!depth\zeropoint}
+ {\vrule\s!width\emwidth\s!height\exheight\s!depth\zeropoint\relax}
\unexpanded\def\strc_lists_symbol_three
{\begingroup
\strc_lists_assign_dimen\scratchwidth \c!width {1.5\emwidth}%
\strc_lists_assign_dimen\scratchheight\c!height\exheight
\strc_lists_assign_dimen\scratchdepth \c!depth \zeropoint
- \vrule\!!width\scratchwidth\!!height\scratchheight\!!depth\scratchdepth
+ \vrule\s!width\scratchwidth\s!height\scratchheight\s!depth\scratchdepth
\endgroup}
\unexpanded\def\strc_lists_symbol_unknown
@@ -877,7 +892,7 @@
\appendtoks
% better is to use a special list entry but we keep this for compatibility
- \let\\=\space
+ \enforced\let\\\space
% so expanding this token register has to come *after* the font switch
\dontconvertfont % (**) this has to become an option (see publ)
\to \t_lists_every_renderingtext
@@ -891,17 +906,22 @@
% because these tests happen often and because we're dealing with
% rather complex composed data we have special conditionals; keep
% in mind that testing for empty fails do to tagging being applied
- \edef\p_pagenumber{\listparameter\c!pagenumber}%
- \ifx\p_pagenumber\v!always
- \settrue\c_lists_has_page
- \settrue\c_lists_show_page
- \else
+% \edef\p_pagenumber{\listparameter\c!pagenumber}%
+% \ifx\p_pagenumber\v!always
+% \settrue\c_lists_has_page
+% \settrue\c_lists_show_page
+% \else
+% \doifelsestructurelisthaspage\settrue\setfalse\c_lists_has_page
+% \ifx\p_pagenumber\v!yes
+% \settrue\c_lists_show_page
+% \else
+% \setfalse\c_lists_show_page
+% \fi
+% \fi
+ \setfalse\c_lists_show_page % necessary?
+ \processcommacommand[\listparameter\c!pagenumber]\strc_lists_process_pagenumber
+ \ifconditional\c_lists_has_page \else
\doifelsestructurelisthaspage\settrue\setfalse\c_lists_has_page
- \ifx\p_pagenumber\v!yes
- \settrue\c_lists_show_page
- \else
- \setfalse\c_lists_show_page
- \fi
\fi
% always forces number placement (in bib we use a forced number)
\edef\p_headnumber{\listparameter\c!headnumber}%
@@ -933,6 +953,7 @@
\setfalse\c_lists_has_page
\setfalse\c_lists_has_number
\setfalse\c_lists_show_page
+ \setfalse\c_lists_show_realpage
\setfalse\c_lists_show_number
\to \t_lists_every_renderingcleanup
@@ -1118,7 +1139,7 @@
\hangafter\ifx\p_hang\v!no\zerocount\else\plusone\fi
\scratchdimen\listalternativeparameter\c!distance\relax
\ifzeropt\wd\b_strc_lists_page \else \ifdim\scratchdimen>\zeropoint\relax
- \rightskip\scratchdimen\!!plus\listalternativeparameter\c!stretch\relax
+ \rightskip\scratchdimen\s!plus\listalternativeparameter\c!stretch\relax
\parfillskip-\rightskip
\fi \fi
\else
@@ -1241,9 +1262,9 @@
\endgroup
\scratchdistance\listparameter\c!distance\relax
\ifdim\scratchdistance<\emwidth
- \hskip\emwidth\!!plus\emwidth\!!minus.25\emwidth\relax
+ \hskip\emwidth\s!plus\emwidth\s!minus.25\emwidth\relax
\else
- \hskip\scratchdistance\!!plus.5\scratchdistance\!!minus.25\scratchdistance\relax
+ \hskip\scratchdistance\s!plus.5\scratchdistance\s!minus.25\scratchdistance\relax
\fi
\endgroup
\endgroup
@@ -1346,7 +1367,8 @@
%D such (for now). No interaction either as that is dealt with elsewhere.
%D
%D \currentlistsymbol
-%D \currentlistentry
+%D \currentlistentrynumber
+%D \currentlistentrytitle
%D \currentlistentrypagenumber % not really used
\definelistalternative
@@ -1522,14 +1544,14 @@
\def\strc_lists_set_reference_attribute_indeed#element%
{\ifx#element\p_interaction_forward
- \attribute\referenceattribute\a_strc_lists_reference
+ \c_attr_reference\a_strc_lists_reference
\fi}
\def\strc_lists_get_destination_attribute_indeed
{attr \destinationattribute\number\a_strc_lists_destination}
\def\strc_lists_set_destination_attribute_indeed
- {\attribute\destinationattribute\a_strc_lists_destination}
+ {\c_attr_destination\a_strc_lists_destination}
\unexpanded\def\strc_lists_set_style_color_normal#style#color#element%
{\useliststyleandcolor#style#color}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-mar.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-mar.lua
index b5fd2667b1a..f7953c416e0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-mar.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-mar.lua
@@ -122,7 +122,7 @@ end
local function sweep(head,first,last)
for n, id, subtype in nextnode, head do
-- we need to handle empty heads so we test for latelua
- if id == glyph_code or (id == whatsit_code and subtype == lateluawhatsit_code) then
+ if id == glyph_code or (id == whatsit_code and subtype == lateluawhatsit_code) then -- brrr
local a = getattr(n,a_marks)
if not a then
-- next
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-mat.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-mat.mkiv
index 0b80a26cd63..7f5a1915445 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-mat.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-mat.mkiv
@@ -1,5 +1,4 @@
%D \module
-%D \module
%D [ file=strc-mat,
%D version=2008.10.20,
%D title=\CONTEXT\ Structure Macros,
@@ -315,7 +314,7 @@
\def\theformuladestinationattribute#1%
{\iflocation\ifx#1\relax\else\ifx#1\empty\else
- \attribute\destinationattribute#1%
+ \c_attr_destination#1%
\glet#1\relax
\fi\fi\fi}
@@ -500,6 +499,8 @@
%D
%D Otherwise we get a missing \type {$$} error reported.
+\pushoverloadmode
+
\let\reqno\eqno % no longer valid as we just nil it
\let\math_native_leqno\leqno
@@ -514,6 +515,8 @@
\let\reqno\normaleqno
\let\eqno \normaleqno
+\popoverloadmode
+
%D \macros
%D {startsubformulas}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-not.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-not.lua
index b2c8106e153..a18b3bd5e4a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-not.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-not.lua
@@ -32,7 +32,8 @@ notes.states = notes.states or { }
lists.enhancers = lists.enhancers or { }
notes.numbers = notes.numbers or { }
-storage.register("structures/notes/states", notes.states, "structures.notes.states")
+storage.register("structures/notes/states", notes.states, "structures.notes.states")
+storage.register("structures/notes/numbers", notes.numbers, "structures.notes.numbers")
local notestates = notes.states
local notedata = table.setmetatableindex("table")
@@ -492,6 +493,7 @@ local texgetglue = tex.getglue
local texsetglue = tex.setglue
local function check_spacing(n,i)
+ -- we can also check for tex.insertheights > 0 (instead of i > 1)
local gn, pn, mn = texgetglue(n)
local gi, pi, mi = texgetglue(i > 1 and "s_strc_notes_inbetween" or "s_strc_notes_before")
local gt, pt, mt = gn + gi, pn + pi, mn + mi
@@ -508,7 +510,7 @@ notes.check_spacing = check_spacing
callback.register("build_page_insert", function(n,i)
local state = notes.numbers[n]
if state then
- -- only notes, kind of hardcoded .. bah
+ -- only notes, kind of hardcoded .. bah
local gt, pt, mt = check_spacing(n,i)
texsetglue(0,gt,pt,mt) -- for the moment we use skip register 0
return 0
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-not.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-not.mkvi
index 05aa1eb6bbe..f29cb38ba16 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-not.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-not.mkvi
@@ -27,39 +27,50 @@
\unexpanded\def\unvboxed {\ifvmode\unvbox \else\box \fi} % will change or used more often
\unexpanded\def\unvcopied{\ifvmode\unvcopy\else\copy\fi} % will change or used more often
-%D Notes have two handlers: notations and notes. Although notations can
-%D be defined independently it makes not much sense. In principle we can
-%D treat notes as lists but they are currently done as a variant on
-%D enumerations. I will provide a list variant as well. One complication is
-%D that for page related notes inserts are used and therefore notes are
-%D typeset immediately and descriptions are better suited for that. For
-%D instance endnotes can as well be typeset using lists.
+%D \LMTX\ testcase:
+%D
+%D \starttyping
+%D \hbox {\hbox{\footnote{HH1}\footnote{HH2}}} \par
+%D \hbox {\hbox{x\footnote{XHH1}x\footnote{XHH2}}} \par
+%D \vbox {\setbox0\hbox{\footnote{VH1}\footnote{VH2}}\box0} \par
+%D \vbox {\hbox{\footnote{VH1}xxx\footnote{VH2}}} \par
+%D \vbox {\hbox{\footnote{VH1}\footnote{VH2}}
+%D \hbox{\footnote{VH1}\footnote{VH2}}} \par
+%D \vbox {\hbox{x\footnote{XVH1}x\footnote{XVH2}}} \par
+%D \vbox {\vbox{\footnote{VV1}\footnote{VV2}}} \par % two lines
+%D \vbox {\vbox{x\footnote{XVV1}x\footnote{XVV2}}} \par
+%D \stoptyping
+
+%D Notes have two handlers: notations and notes. Although notations can be defined
+%D independently it makes not much sense. In principle we can treat notes as lists
+%D but they are currently done as a variant on enumerations. I will provide a list
+%D variant as well. One complication is that for page related notes inserts are used
+%D and therefore notes are typeset immediately and descriptions are better suited
+%D for that. For instance endnotes can as well be typeset using lists.
% textcommand/textstyle/textcolor : set by note commandhandler and used for inline number
%D \macros
%D {setupnote,setupnotation}
%D
-%D We can influence footnote typesetting with the setup
-%D command:
+%D We can influence footnote typesetting with the setup command:
%D
%D \showsetup{setupnotation}
%D \showsetup{setupnote}
%D
-%D The definition command indicate that we can frame the footnote
-%D area. The footnotes themselves are treated as descriptions.
+%D The definition command indicate that we can frame the footnote area. The
+%D footnotes themselves are treated as descriptions.
%D
%D \showsetup{definenote}
%D
-%D It's sort of a custom to precede footnotes by a horizontal
-%D rule and although fancy rules like
+%D It's sort of a custom to precede footnotes by a horizontal rule and although
+%D fancy rules like
%D
%D \starttyping
%D \hbox to 10em{\hskip-3em\dotfill}
%D \stoptyping
%D
-%D Are quite ligitimate, we default to a simple one 20\% of the
-%D text width.
+%D Are quite ligitimate, we default to a simple one 20\% of the text width.
% \c!headstyle=\noteparameter\c!style,
% \c!headcolor=\noteparameter\c!color,
@@ -211,11 +222,10 @@
\fi
\fi}
-%D Notations (we simply needed a word that relates to notes and is
-%D and sounds like description and enumeration) are a special case
-%D in the sense that they are stored, rendered elsewhere and referered
-%D to from where they are specified. For that reason they have a different
-%D set op main commands.
+%D Notations (we simply needed a word that relates to notes and is and sounds like
+%D description and enumeration) are a special case in the sense that they are
+%D stored, rendered elsewhere and referered to from where they are specified. For
+%D that reason they have a different set op main commands.
% \notation[ref]{title}
% \notation[reference=,title=]
@@ -305,10 +315,10 @@
\unexpanded\def\strc_notations_stop
{}
-%D A complication is that we need to set up rather specific properties
-%D of e.g. footnotes. It is for this reason that we introduce an extra
-%D level of indirectness. This way notations don't bark on undefined
-%D macros when used in combination.
+%D A complication is that we need to set up rather specific properties of e.g.
+%D footnotes. It is for this reason that we introduce an extra level of
+%D indirectness. This way notations don't bark on undefined macros when used in
+%D combination.
\unexpanded\setvalue{\??constructionnotehandler\v!notation}%
{\csname\??constructionnotehandler\currentconstructionhandler:\constructionparameter\c!type\endcsname}
@@ -338,8 +348,7 @@
\let\setupnotes\setupnote
-% These only concern the inline symbol/number and wrapping of the
-% whole list.
+% These only concern the inline symbol/number and wrapping of the whole list.
\setupnotes % not all make sense here
[\c!location=\v!page,
@@ -437,7 +446,7 @@
{\iftrialtypesetting \else
\begingroup
\currentconstructionsynchronize
- \attribute\destinationattribute\currentconstructionattribute\relax % todo, whole text
+ \c_attr_destination\currentconstructionattribute\relax % todo, whole text
\signalcharacter
\endgroup
\fi#following}
@@ -486,20 +495,19 @@
\kern\notesignal\relax % \relax is needed to honor spaces
\fi}
-%D Interaction in notes is somewhat complex due to the way notes get
-%D flushed. In principle it is more or less the same as lists but where
-%D in lists we pack whole entries, in notes this doesn't happen. Okay,
-%D in retrospect we could have made descriptions lists but that will be
-%D a backward compatibility mess. At some point a completely new mechanism
-%D might show up, but not now. Also, as notes are inserts there is some
-%D extra mess to be kept in mind and it's easier to maintain two mechanisms
-%D than to combine too much.
+%D Interaction in notes is somewhat complex due to the way notes get flushed. In
+%D principle it is more or less the same as lists but where in lists we pack whole
+%D entries, in notes this doesn't happen. Okay, in retrospect we could have made
+%D descriptions lists but that will be a backward compatibility mess. At some point
+%D a completely new mechanism might show up, but not now. Also, as notes are inserts
+%D there is some extra mess to be kept in mind and it's easier to maintain two
+%D mechanisms than to combine too much.
%D
-%D Interaction is also complicated because we want to provide several variants.
-%D For simple reference there is no need for anything special, as page references
-%D will do and we store them in the list anyway. But if we want a destination with
-%D dimensions we will use an additional destination because we can have only
-%D one with the same name and we always have the number as one.
+%D Interaction is also complicated because we want to provide several variants. For
+%D simple reference there is no need for anything special, as page references will
+%D do and we store them in the list anyway. But if we want a destination with
+%D dimensions we will use an additional destination because we can have only one
+%D with the same name and we always have the number as one.
% interaction:
%
@@ -579,25 +587,6 @@
\let\strc_notes_set_destination_attribute_text\donothing
\let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_nop}
-% \def\strc_references_prepare_display_references_yes_number
-% {\let\strc_notes_set_reference_attribute_text\donothing
-% \strc_references_get_simple_reference{symb:\currentnote:\currentnotenumber}% reference
-% \edef\strc_notes_set_reference_attribute_number{\attribute\referenceattribute\currentreferenceattribute}%
-% \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes}
-
-% \def\strc_references_prepare_display_references_yes_text
-% {\strc_references_get_simple_reference{symb:\currentnote:\currentnotenumber}% reference
-% \edef\strc_notes_set_reference_attribute_text{\attribute\referenceattribute\currentreferenceattribute}%
-% \let\strc_notes_set_reference_attribute_number\donothing
-% \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes}
-
-% \def\strc_references_prepare_display_references_yes_all
-% {\strc_references_get_simple_reference{symb:\currentnote:\currentnotenumber}% reference
-% \edef\strc_notes_set_reference_attribute_text{\attribute\referenceattribute\currentreferenceattribute}%
-% \strc_references_get_simple_reference{symb:\currentnote:\currentnotenumber}% reference
-% \edef\strc_notes_set_reference_attribute_number{\attribute\referenceattribute\currentreferenceattribute}%
-% \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes}
-
\def\strc_references_prepare_display_references_yes_number
{\edef\currentnoteinternal{\clf_noteinternal{\currentnote}\currentnotenumber}%
\ifcase\currentnoteinternal\relax
@@ -605,7 +594,7 @@
\else
\let\strc_notes_set_reference_attribute_text\donothing
\strc_references_get_simple_reference{*\currentnoteinternal}% reference
- \edef\strc_notes_set_reference_attribute_number{\attribute\referenceattribute\currentreferenceattribute}%
+ \edef\strc_notes_set_reference_attribute_number{\c_attr_reference\currentreferenceattribute}%
\let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes
\fi}
@@ -615,7 +604,7 @@
\strc_references_prepare_display_references_nop
\else
\strc_references_get_simple_reference{*\currentnoteinternal}% reference
- \edef\strc_notes_set_reference_attribute_text{\attribute\referenceattribute\currentreferenceattribute}%
+ \edef\strc_notes_set_reference_attribute_text{\c_attr_reference\currentreferenceattribute}%
\let\strc_notes_set_reference_attribute_number\donothing
\let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes
\fi}
@@ -626,9 +615,9 @@
\strc_references_prepare_display_references_nop
\else
\strc_references_get_simple_reference{*\currentnoteinternal}% reference
- \edef\strc_notes_set_reference_attribute_text{\attribute\referenceattribute\currentreferenceattribute}%
+ \edef\strc_notes_set_reference_attribute_text{\c_attr_reference\currentreferenceattribute}%
\strc_references_get_simple_reference{*\currentnoteinternal}% reference
- \edef\strc_notes_set_reference_attribute_number{\attribute\referenceattribute\currentreferenceattribute}%
+ \edef\strc_notes_set_reference_attribute_number{\c_attr_reference\currentreferenceattribute}%
\let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes
\fi}
@@ -802,26 +791,23 @@
%D Footnotes are can be characterized by three components:
%D
%D \startitemize[packed]
-%D \item a small number \footnote {a footnote number} or
-%D symbol {\setupfootnotes [conversion=set 2]\footnote
-%D {a footnote}}
+%D \item a small number \footnote {a footnote number} or symbol {\setupfootnotes
+%D [conversion=set 2]\footnote {a footnote}}
%D \item and a similar mark at the bottom of the page
%D \item followed by some additional text
%D \stopitemize
%D
-%D Because footnotes are declared at the location of their
-%D reference they can be seen as a special kind of
-%D floating bodies. Their placement is postponed but has to be
-%D taken into account in the pagebreak calculations. This kind
-%D of calculations are forced by using \type{\insert}s and dealing
-%D with all cases is not trivial.
+%D Because footnotes are declared at the location of their reference they can be
+%D seen as a special kind of floating bodies. Their placement is postponed but has
+%D to be taken into account in the pagebreak calculations. This kind of calculations
+%D are forced by using \type{\insert}s and dealing with all cases is not trivial.
%D \macros
%D {notesenabled}
%D
-%D We need a couple of states because at some moments we don't want
-%D to mess around with inserts at all. Take for instance a table
-%D of contents. And so we can temporary disable footnotes by saying
+%D We need a couple of states because at some moments we don't want to mess around
+%D with inserts at all. Take for instance a table of contents. And so we can
+%D temporary disable footnotes by saying
%D
%D \starttyping
%D \notesenabledfalse
@@ -837,8 +823,8 @@
\appendtoks \notesenabledfalse \to \everysimplifycommands % quick hack
\appendtoks \notesenabledfalse \to \everypreroll % quick hack
-%D Often we need to process the whole set of notes and to make that
-%D fast, we use a token register:
+%D Often we need to process the whole set of notes and to make that fast, we use a
+%D token register:
% we have several synchronizers:
%
@@ -943,27 +929,6 @@
\letvalue{\??notepenalty\v!verystrict}\notepenaltyverystrict
\letvalue{\??notepenalty }\notepenaltytolerant
-% \def\strc_notes_set_width
-% {\edef\p_width{\noteparameter\c!width}%
-% \ifx\p_width\empty
-% \setnoteparameter\c!width{\hsize}%
-% \fi}
-
-\setupnotes
- [\c!width=\v!auto]
-
-\def\strc_notes_set_width
- {\edef\p_width{\noteparameter\c!width}%
- \ifx\p_width\v!auto
- \setnoteparameter\c!width{\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}%
- \else\ifx\p_width\empty
- \setnoteparameter\c!width{\hsize}%
- \fi\fi}
-
-\appendtoks
- \strc_notes_set_width
-\to \everysynchronizenote
-
%D The following switch can be used to disable limiting the height of the footnote
%D area, something that is needed in multi column balancing. Use this switch with
%D care.
@@ -1112,12 +1077,21 @@
\c_strc_notes_columns\plusone
\fi}
+% \def\strc_notes_set_location_page
+% {\setfalse\c_strc_notes_delayed
+% \strc_notes_set_distance
+% \strc_notes_set_columns
+% \page_inserts_set_location\currentnoteinsertion\v!page % \setupinsertion[\currentnote][\c!location=\v!page]%
+% \global\count\currentnoteinsertionnumber\numexpr\plusthousand/\c_strc_notes_columns\relax
+% \global\dimen\currentnoteinsertionnumber\ifnotelimit\dimexpr\noteparameter\c!height*\c_strc_notes_columns\relax\else\maxdimen\fi
+% \global\skip \currentnoteinsertionnumber\s_strc_notes_distance\relax}
+
\def\strc_notes_set_location_page
{\setfalse\c_strc_notes_delayed
\strc_notes_set_distance
\strc_notes_set_columns
\page_inserts_set_location\currentnoteinsertion\v!page % \setupinsertion[\currentnote][\c!location=\v!page]%
- \global\count\currentnoteinsertionnumber\numexpr\plusthousand/\c_strc_notes_columns\relax
+ \global\count\currentnoteinsertionnumber\numexpr(\plusthousand/\c_strc_notes_columns)*\nofmulticolumns\relax
\global\dimen\currentnoteinsertionnumber\ifnotelimit\dimexpr\noteparameter\c!height*\c_strc_notes_columns\relax\else\maxdimen\fi
\global\skip \currentnoteinsertionnumber\s_strc_notes_distance}
@@ -1195,12 +1169,9 @@
% \dorecurse{10}{test \mynote{one one one one one one} \input zapf \mynote{one one one one one one} }
% \stoptext
-%D The noterule can be a graphic and therefore calling this
-%D setup macro at every skipswitch is tricky (many many MP
-%D runs). Let's just reserve a few points, that probably match
-%D those of the stretch component.
-
-%D A bit messy:
+%D The noterule can be a graphic and therefore calling this setup macro at every
+%D skipswitch is tricky (many many MP runs). Let's just reserve a few points, that
+%D probably match those of the stretch component. A bit messy:
\unexpanded\def\placenoterule
{\begingroup
@@ -1220,14 +1191,8 @@
\kern\strutdepth
\fi}
-\ifdefined\setnotehsize \else
-
- \unexpanded\def\setnotehsize{\hsize\noteparameter\c!width\relax} % can be overloaded
-
-\fi
-
-%D The formatting depends on the width of the table, so we
-%D have to set \type {n} to zero.
+%D The formatting depends on the width of the table, so we have to set \type {n} to
+%D zero.
%D
%D \starttyping
%D \startbuffer
@@ -1245,21 +1210,19 @@
%D \macros
%D {footnote}
%D
-%D A footnote can have a reference as optional argument and
-%D therefore its formal specification looks like:
+%D A footnote can have a reference as optional argument and therefore its formal
+%D specification looks like:
%D
%D \showsetup{footnote}
%D
-%D This command has one optional command: the reference. By
-%D saying \type{[-]} the number is omitted. The footnote
-%D command is not that sensitive to spacing, so it's quite
-%D legal to say:
+%D This command has one optional command: the reference. By saying \type{[-]} the
+%D number is omitted. The footnote command is not that sensitive to spacing, so it's
+%D quite legal to say:
%D
%D \startbuffer
-%D Users of \CONTEXT\ must keep both feet \footnote{Given they
-%D have two.} on the ground and not get confused \footnote{Or
-%D even crazy.} by all those obscure \footnote{But fortunately
-%D readable.} parameters.
+%D Users of \CONTEXT\ must keep both feet \footnote {Given they have two.} on the
+%D ground and not get confused \footnote {Or even crazy.} by all those obscure
+%D \footnote {But fortunately readable.} parameters.
%D \stopbuffer
%D
%D \typebuffer
@@ -1274,15 +1237,11 @@
%D \stopnarrower
%D \egroup
%D
-%D Typesetting footnotes is, at least for the moment, disabled
-%D when reshaping boxes.
-%D
-%D The additional macro \type {\footnotetext} and the
-%D associated \type {\note} macro were implemented at
-%D request of users on the mailing list and a suggestion by
-%D taco to split of the symbol placement. I decided to
-%D merge this functionality with the existing \type {\note}
-%D functionality.
+%D Typesetting footnotes is, at least for the moment, disabled when reshaping boxes.
+%D The additional macro \type {\footnotetext} and the associated \type {\note} macro
+%D were implemented at request of users on the mailing list and a suggestion by taco
+%D to split of the symbol placement. I decided to merge this functionality with the
+%D existing \type {\note} functionality.
\newconditional\c_strc_notes_symbol \settrue\c_strc_notes_symbol % not used
\newconditional\c_strc_notes_skip
@@ -1357,6 +1316,13 @@
\newtoks\everyinsidenoteinsert
\newtoks\everyafternoteinsert
+\unexpanded\def\doifelseinnote
+ {\ifconditional\processingnote
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
\appendtoks
\let\flushnotes\relax
\let\postponenotes\relax
@@ -1410,17 +1376,35 @@
% \setfalse\inhibitmargindata
% \to \everyinsidenoteinsert
+\setupnotes
+ [\c!width=\v!auto]
+
+\unexpanded\def\setnotehsize
+ {\ifinsidemulticolumns
+ \setnoteparameter\c!width{\makeupwidth}%
+ \else
+ \edef\p_width{\noteparameter\c!width}%
+ \ifx\p_width\v!auto
+ % \ifinsidecolumns
+ \setnoteparameter\c!width{\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}%
+ % \else
+ % \setnoteparameter\c!width{\makeupwidth}%
+ % \fi
+ \else\ifx\p_width\empty
+ \setnoteparameter\c!width{\hsize}%
+ \fi\fi
+ \fi
+ \hsize\noteparameter\c!width\relax}
+
\appendtoks
% only needed when columns (could be three \set...)
+ \setnotehsize
\setsimplecolumnshsize[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%
\to \everyinsidenoteinsert
-% not: \appendtoks \setnotehsize \to \everyinsidenoteinsert (spoils columns)
-
-%D Normally footnotes are saved as inserts that are called upon
-%D as soon as the pagebody is constructed. The footnote
-%D insertion routine looks just like the \PLAIN\ \TEX\ one,
-%D except that we check for the end note state.
+%D Normally footnotes are saved as inserts that are called upon as soon as the
+%D pagebody is constructed. The footnote insertion routine looks just like the
+%D \PLAIN\ \TEX\ one, except that we check for the end note state.
% testcase for split bottom alignment see (a) below
%
@@ -1506,9 +1490,12 @@
\obeydepth} % (a) added , since split footnotes will not align properly
\def\strc_notes_flush_inserts_columns
- {\startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%
+ {\begingroup
+ \setnotehsize % probably still not ok for columns
+ \startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]%
\strc_notes_flush_global
- \stopsimplecolumns}
+ \stopsimplecolumns
+ \endgroup}
% idea: tag with attr and then just flush them again
@@ -1523,10 +1510,9 @@
{\iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteinsertionnumber}%
\endgroup}
-%D Supporting end notes is surprisingly easy. Even better, we
-%D can combine this feature with solving the common \TEX\
-%D problem of disappearing inserts when they're called for in
-%D deeply nested boxes. The general case looks like:
+%D Supporting end notes is surprisingly easy. Even better, we can combine this
+%D feature with solving the common \TEX\ problem of disappearing inserts when
+%D they're called for in deeply nested boxes. The general case looks like:
%D
%D \starttyping
%D \postponenotes
@@ -1534,9 +1520,8 @@
%D \flushnotes
%D \stoptyping
%D
-%D This alternative can be used in headings, captions, tables
-%D etc. The latter one sometimes calls for notes local to
-%D the table, which can be realized by saying
+%D This alternative can be used in headings, captions, tables etc. The latter one
+%D sometimes calls for notes local to the table, which can be realized by saying
%D
%D \starttyping
%D \setlocalfootnotes
@@ -1544,26 +1529,28 @@
%D \placelocalfootnotes
%D \stoptyping
%D
-%D Postponing is accomplished by simply redefining the (local)
-%D insert operation. A not too robust method uses the
-%D \type{\insert} primitive when possible. This method fails in
-%D situations where it's not entirely clear in what mode \TEX\
-%D is. Therefore the auto method can is to be overruled when
-%D needed.
+%D Postponing is accomplished by simply redefining the (local) insert operation. A
+%D not too robust method uses the \type{\insert} primitive when possible. This
+%D method fails in situations where it's not entirely clear in what mode \TEX\ is.
+%D Therefore the auto method can is to be overruled when needed.
\newconditional\postponingnotes
% we need a proper state: normal, postponing, flushing
\unexpanded\def\postponenotes
- {\ifconditional\postponingnotes\else
- \global\settrue\postponingnotes
- \glet\flushnotes\doflushnotes
- \clf_postponenotes
+ {\ifcase\insertionmigrationmode
+ \ifconditional\postponingnotes\else
+ \global\settrue\postponingnotes
+ \glet\flushnotes\doflushnotes
+ \clf_postponenotes
+ \fi
\fi}
\let\flushnotes\relax
+% also \ifcase\insertionmigrationmode here, needs testing:
+
\unexpanded\def\startpostponingnotes % experimental, page-mix
{\ifconditional\postponingnotes\else
\global\settrue\postponingnotes
@@ -1595,8 +1582,8 @@
%D \macros
%D {startlocalfootnotes,placelocalfootnotes}
%D
-%D The next two macros can be used in for instance tables, as
-%D we'll demonstrate later on.
+%D The next two macros can be used in for instance tables, as we'll demonstrate
+%D later on.
%D
%D \showsetup{startlocalfootnotes}
%D \showsetup{placelocalfootnotes}
@@ -1678,19 +1665,17 @@
%D
%D \typebuffer
%D
-%D Because this table placement macro expect box content, and
-%D thanks to the grouping of the local footnotes, we don't need
-%D additional braces.
+%D Because this table placement macro expect box content, and thanks to the grouping
+%D of the local footnotes, we don't need additional braces.
%D
%D \getbuffer
%D \macros
%D {placefootnotes}
%D
-%D We still have no decent command for placing footnotes
-%D somewhere else than at the bottom of the page (for which no
-%D user action is needed). Footnotes (endnotes) can be
-%D placed by using
+%D We still have no decent command for placing footnotes somewhere else than at the
+%D bottom of the page (for which no user action is needed). Footnotes (endnotes) can
+%D be placed by using
%D
%D \showsetup{placefootnotes}
@@ -1866,22 +1851,20 @@
\def\calculatetotalclevernoteheight{\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalclevernoteheight}
\def\calculatetotalpagenoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalpagenoteheight}
-%D Now how can this mechanism be hooked into \CONTEXT\ without
-%D explictly postponing footnotes? The solution turned out to
-%D be rather simple:
+%D Now how can this mechanism be hooked into \CONTEXT\ without explictly postponing
+%D footnotes? The solution turned out to be rather simple:
%D
%D \starttyping
%D \everypar {...\flushnotes...}
%D \neverypar {...\postponenotes}
%D \stoptyping
%D
-%D We can use \type{\neverypar} because in most commands
-%D sensitive to footnote gobbling we disable \type{\everypar}
-%D in favor for \type{\neverypar}. In fact, this footnote
-%D implementation is the first to use this scheme.
+%D We can use \type {\neverypar} because in most commands sensitive to footnote
+%D gobbling we disable \type {\everypar} in favor for \type {\neverypar}. In fact,
+%D this footnote implementation is the first to use this scheme.
-%D This is a nasty and new secondary footnote flusher. It
-%D can be hooked into \type {\everypar} like:
+%D This is a nasty and new secondary footnote flusher. It can be hooked into \type
+%D {\everypar} like:
%D
%D \starttyping
%D \appendtoks \synchronizenotes \to \everypar
@@ -1895,10 +1878,9 @@
\let\synchronizenotes\relax
-%D When typesetting footnotes, we have to return to the
-%D footnote specific bodyfont size, which is in most cases derived
-%D from the global document bodyfont size. In the previous macros
-%D we already used a footnote specific font setting macro.
+%D When typesetting footnotes, we have to return to the footnote specific bodyfont
+%D size, which is in most cases derived from the global document bodyfont size. In
+%D the previous macros we already used a footnote specific font setting macro.
\def\strc_notes_set_bodyfont
{\let\strc_notes_set_bodyfont\relax
@@ -1906,9 +1888,23 @@
\usebodyfontparameter\noteparameter
\usealignparameter\noteparameter}
-%D The footnote mechanism defaults to a traditional one
-%D column way of showing them. By default we precede them by
-%D a small line.
+%D The footnote mechanism defaults to a traditional one column way of showing them.
+%D By default we precede them by a small line.
+
+% end notes in the margin:
+%
+% \setuptexttexts
+% [margin]
+% [] [{\directsetup{notabene}}]
+%
+% \startsetups notabene
+% \vbox to \textheight \bgroup
+% \setupalign[tolerant]
+% \topskipcorrection
+% \placenotes[endnote][before=,after=]
+% \vfilll
+% \egroup
+% \stopsetups
\definenote [\v!footnote]
\definenote [\v!endnote ] [\c!location=\v!none] % else no break
@@ -1954,8 +1950,7 @@
%D \macros
%D {note}
%D
-%D Refering to a note is accomplished by the rather short
-%D command:
+%D Refering to a note is accomplished by the rather short command:
%D
%D \showsetup{note}
%D
@@ -2031,5 +2026,10 @@
% a\footnote{\input tufte\par\input ward\relax}
% \stoptext
-\protect \endinput
+%D Bonus:
+\appendtoks
+ \setsystemmode\currentnote
+\to \everysynchronizenote
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
index 9b3a77e741f..9c040104db4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
@@ -35,6 +35,8 @@ local stopapplyprocessor = processors.stopapply
local texsetcount = tex.setcount
local texgetcount = tex.getcount
+local texconditionals = tex.conditionals
+
local ctx_convertnumber = context.convertnumber
-- storage
@@ -82,6 +84,7 @@ function pages.save(prefixdata,numberdata,extradata)
block = sections.currentblock(),
prefixdata = prefixdata and helpers.simplify(prefixdata),
numberdata = numberdata and helpers.simplify(numberdata),
+ marked = pages.markedlist(realpage), -- not yet defined
}
tobesaved[realpage] = data
if not collected[realpage] then
@@ -319,6 +322,10 @@ function pages.on_right(n)
end
end
+function pages.has_changed()
+ return texconditionals.layouthaschanged
+end
+
function pages.in_body(n)
return texgetcount("pagebodymode") > 0
end
@@ -440,6 +447,6 @@ implement { -- weird place
interfaces.implement {
name = "pageofinternal",
- arguments = { "integer" },
+ arguments = "integer",
actions = helpers.pageofinternal,
}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.mkiv
index 01361e2c53b..909c418f956 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.mkiv
@@ -21,14 +21,14 @@
% Allocation:
-\countdef\realpageno \zerocount \realpageno \plusone
-\countdef\userpageno \plusone \userpageno \plusone
-\countdef\subpageno \plustwo \subpageno \plusone % was \zerocount but that doesn't work well with bytext
-\countdef\arrangeno \plusthree \arrangeno \zerocount % !
-\countdef\pagenoshift\plusfour \pagenoshift\zerocount % !
-\countdef\lastpageno \plusfive \lastpageno \zerocount % !
+\ifdefined\realpageno \else \countdef\realpageno \zerocount \fi \realpageno \plusone
+\ifdefined\userpageno \else \countdef\userpageno \plusone \fi \userpageno \plusone
+\ifdefined\subpageno \else \countdef\subpageno \plustwo \fi \subpageno \plusone % was \zerocount but that doesn't work well with bytext
+\ifdefined\arrangeno \else \countdef\arrangeno \plusthree \fi \arrangeno \zerocount % !
+\ifdefined\pagenoshift \else \countdef\pagenoshift\plusfour \fi \pagenoshift\zerocount % !
+\ifdefined\lastpageno \else \countdef\lastpageno \plusfive \fi \lastpageno \zerocount % !
-\let\pageno\userpageno
+\ifdefined\pageno \else \let\pageno\userpageno \fi
\def\realfolio{\the\realpageno}
\def\userfolio{\the\userpageno}
@@ -268,8 +268,8 @@
% States:
-\newif\ifdoublesided \newconditional\layoutisdoublesided
-\newif\ifsinglesided \newconditional\layoutissinglesided
+\newconditional\layoutisdoublesided % already defined: \newif\ifdoublesided
+\newconditional\layoutissinglesided % already defined: \newif\ifsinglesided
% Realpage and subpage numbers:
@@ -316,7 +316,8 @@
\doublesidedfalse \setfalse\layoutissinglesided
\resetsystemmode\v!singlesided
\resetsystemmode\v!doublesided
- \processallactionsinset[\directpagenumberingparameter\c!alternative]
+ \processallactionsinset
+ [\directpagenumberingparameter\c!alternative]%
[ \v!singlesided=>\setsystemmode\v!singlesided\singlesidedtrue\settrue\layoutissinglesided,
\v!doublesided=>\setsystemmode\v!doublesided\doublesidedtrue\settrue\layoutisdoublesided]%
\the\everysidedswitch
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua
index c85b3338a32..bca36ccef43 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua
@@ -2289,7 +2289,7 @@ function genericfilters.title(data)
if data then
local titledata = data.titledata or data.useddata
if titledata then
- helpers.title(titledata.title or "?",data.metadata)
+ helpers.title(titledata.reference or titledata.title or "?",data.metadata)
end
end
end
@@ -2614,6 +2614,18 @@ implement {
-- -- arguments = "string" -- hm, weird
-- }
+implement {
+ name = "askedreference",
+ public = true,
+ protected = true,
+ actions = function()
+ local actions = references.currentset
+ if actions then
+ context("[p=%s,r=%s]",actions.prefix or "",actions.reference)
+ end
+ end
+}
+
implement {
name = "referencerealpage",
actions = function()
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi
index e774117fa50..3bf33963851 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi
@@ -167,7 +167,7 @@
\def\strc_references_placeholder
{\ifx\dotaggedplaceholder\empty\else
- \attribute\destinationattribute\lastdestinationattribute
+ \c_attr_destination\lastdestinationattribute
\dotaggedplaceholder
\fi}
@@ -373,7 +373,7 @@
\unexpanded\def\vboxreference[#1]{\boxreference[#1]\vbox}
% \ifx\currentdestinationattribute\empty
-% \begingroup\attribute\destinationattribute\currentdestinationattribute\emptyhbox\endgroup % todo
+% \begingroup\c_attr_destination\currentdestinationattribute\emptyhbox\endgroup % todo
% \fi
\def\defaultreferencepage#text{[[[#text]]]}
@@ -737,6 +737,29 @@
\def\dummyreference{{\tttf ??}}
\def\emptyreference{{\tttf !!}}
+\installtextracker
+ {structures.referencing.show}
+ {\let\strc_references_dummy\strc_references_dummy_yes}
+ {\let\strc_references_dummy\strc_references_dummy_nop}
+
+\def\strc_references_dummy_nop
+ {\dummyreference}
+
+\def\strc_references_dummy_yes
+ {\dummyreference
+ \margindata
+ [\referencingparameter\c!labelalternative]% alternative?
+ [\c!style=\referencingparameter\c!labelstyle,
+ \c!color=\referencingparameter\c!labelcolor]
+ {\askedreference}}
+
+\let\strc_references_dummy\strc_references_dummy_nop
+
+\setupreferencing
+ [\c!labelalternative=\v!inleft,
+ \c!labelcolor=darkred,
+ \c!labelstyle=\smallinfofont]
+
%D To prevent repetitive messages concerning a reference being defined, we set such
%D an unknown reference to an empty one after the first encounter.
%D
@@ -971,9 +994,9 @@
\def\strc_references_get_reference[#key][#label]% #key = number page title text default realpage ...
{\ifsecondargument
- \doifelsereferencefound{#label}{\clf_filterreference{#key}}\dummyreference
+ \doifelsereferencefound{#label}{\clf_filterreference{#key}}\strc_references_dummy
\else
- \dummyreference
+ \strc_references_dummy
\fi}
\let\ref\getreference
@@ -983,8 +1006,8 @@
\unexpanded\def\strc_references_about[#label]%
{\dontleavehmode
\begingroup
- \let\crlf\space
- \let\\\space
+ \enforced\let\crlf\space
+ \enforced\let\\\space
\postponenotes % might go
\referencingparameter\c!left
\doifelsereferencefound{#label}
@@ -1143,12 +1166,12 @@
\unexpanded\def\atpage[#label]% todo
{\doifcheckedpagestate{#label}%
- {\goto{\labeltext \v!precedingpage }[#label]}%
- {\goto{\labeltext \v!hencefore }[#label]}%
+ {\goto{\labeltext\v!precedingpage}[#label]}%
+ {\goto{\labeltext\v!hencefore}[#label]}%
{\ignorespaces}%
- {\goto{\labeltext \v!hereafter }[#label]}%
- {\goto{\labeltext \v!followingpage }[#label]}%
- {\goto{\labeltexts\v!page\dummyreference}[#label]}}
+ {\goto{\labeltext\v!hereafter}[#label]}%
+ {\goto{\labeltext\v!followingpage}[#label]}%
+ {\goto{\labeltexts\v!page\strc_references_dummy}[#label]}}
% Someone requested this but in retrospect didn't need it so we keep it as example.
% Beware: a node is injected which is why we add ignorespaces!
@@ -1262,7 +1285,7 @@
% inefficient: double resolve
\doifelsereferencefound{#label} % we need to resolve the text
{\goto{\referencesequence}[#label]}
- {\let\currentreferencecontent\dummyreference
+ {\let\currentreferencecontent\strc_references_dummy
\goto{\referencesequence}[#label]}%
\strc_references_stop_goto}
@@ -1452,12 +1475,12 @@
\newbox\referencebox
\def\revivesavedreferenceattribute % sometimes handy as no test etc needed
- {\attribute\referenceattribute\lastsavedreferenceattribute}
+ {\c_attr_reference\lastsavedreferenceattribute}
\def\strc_references_direct_goto#content[#label]% no test for valid references
{\dontleavehmode
\begingroup
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\global\lastsavedreferenceattribute\attributeunsetvalue
\iflocation
\clf_injectreference
@@ -1472,7 +1495,7 @@
\setlocationattributes
\setstrut % can be option
\global\lastsavedreferenceattribute\lastreferenceattribute
- \attribute\referenceattribute\lastreferenceattribute
+ \c_attr_reference\lastreferenceattribute
\dostarttagged\t!link\empty % not here
#content%
\dostoptagged
@@ -1485,7 +1508,7 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_injectreference
{\referenceprefix}%
@@ -1497,7 +1520,7 @@
}%
\relax
\setlocationattributes
- \attribute\referenceattribute\lastreferenceattribute
+ \c_attr_reference\lastreferenceattribute
\global\lastsavedreferenceattribute\lastreferenceattribute
\dostarttagged\t!link\empty
#content%
@@ -1512,7 +1535,7 @@
\begingroup
%\setbox\referencebox\hbox\bgroup % experiment, might change again to non \par support
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}%
{\expandtexincurrentreference
@@ -1523,7 +1546,7 @@
\setlocationattributes
\setstrut % can be option
\global\lastsavedreferenceattribute\lastreferenceattribute
- \attribute\referenceattribute\lastreferenceattribute
+ \c_attr_reference\lastreferenceattribute
\dostarttagged\t!link\empty
#content%
\dostoptagged}%
@@ -1538,12 +1561,12 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\setstrut % can be option
\strc_references_get_simple_reference{#internal}%
\global\lastsavedreferenceattribute\currentreferenceattribute
- \attribute\referenceattribute\currentreferenceattribute
+ \c_attr_reference\currentreferenceattribute
\setlocationattributes
\dostarttagged\t!link\empty
#content%
@@ -1579,7 +1602,7 @@
\setlocationattributes
\setstrut % can be option
\global\lastsavedreferenceattribute\lastreferenceattribute
- \attribute\referenceattribute\lastreferenceattribute
+ \c_attr_reference\lastreferenceattribute
\dostarttagged\t!link\empty
\let\stopgoto\strc_references_stop_goto_yes}
@@ -1591,7 +1614,7 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}%
{\expandtexincurrentreference
@@ -1601,7 +1624,7 @@
\relax
\setlocationattributes
\global\lastsavedreferenceattribute\lastreferenceattribute
- \attribute\referenceattribute\lastreferenceattribute
+ \c_attr_reference\lastreferenceattribute
\dostarttagged\t!link\empty
#content%
\dostoptagged}%
@@ -1615,7 +1638,7 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_injectreference
{\referenceprefix}%
@@ -1636,7 +1659,7 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_injectreference
{\referenceprefix}%
@@ -1657,7 +1680,7 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_injectreference
{\referenceprefix}%
@@ -1677,7 +1700,7 @@
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\iflocation
\clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}%
{\expandtexincurrentreference
@@ -1700,7 +1723,7 @@
\wd\scratchbox#width%
\ht\scratchbox#height%
\global\lastsavedreferenceattribute\attributeunsetvalue
- \attribute\referenceattribute\attributeunsetvalue
+ \c_attr_reference\attributeunsetvalue
\clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}%
{\clf_injectcurrentreference
\global\lastsavedreferenceattribute\lastreferenceattribute
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua
index 6873f89eb72..6e26f6f3701 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua
@@ -460,6 +460,7 @@ local function preprocessentries(rawdata)
local processors = rawdata.processors
local et = entries.entries
local kt = entries.keys
+ local pt = entries.processors
local entryproc = processors and processors.entry
local pageproc = processors and processors.page
local coding = rawdata.metadata.coding
@@ -483,16 +484,20 @@ local function preprocessentries(rawdata)
end
kt = lpegmatch(coding == "xml" and entrysplitter_xml or entrysplitter_tex,k)
end
+ if not pt then
+ pt = { }
+ end
--
entries = { }
local ok = false
for k=#et,1,-1 do
local etk = et[k]
local ktk = kt[k]
+ local ptk = pt[k]
if not ok and etk == "" then
entries[k] = nil
else
- entries[k] = { etk or "", ktk ~= "" and ktk or nil }
+ entries[k] = { etk or "", ktk ~= "" and ktk or false, ptk ~= "" and ptk or false }
ok = true
end
end
@@ -677,31 +682,33 @@ implement {
{ "catcodes", "integer" },
{ "own" },
{ "xmlroot" },
- { "xmlsetup" }
+ { "xmlsetup" },
}
},
{ "entries", {
{ "entries", "list" },
{ "keys", "list" },
+ { "processors", "list" },
{ "entry" },
- { "key" }
+ { "key" },
+ { "processor" },
}
},
{ "references", {
{ "internal", "integer" },
{ "section", "integer" },
{ "view" },
- { "label" }
+ { "label" },
}
},
{ "seeword", {
- { "text" }
+ { "text" },
}
},
{ "processors", {
{ "entry" },
{ "key" },
- { "page" }
+ { "page" },
}
},
{ "userdata" },
@@ -1258,6 +1265,7 @@ function registers.flush(data,options,prefixspec,pagespec)
while d < #data do
d = d + 1
local entry = data[d]
+-- inspect(entry)
local metadata = entry.metadata
local kind = metadata.kind
local list = entry.list
@@ -1266,8 +1274,9 @@ function registers.flush(data,options,prefixspec,pagespec)
e[i] = false
end
for i=1,maxlevel do
+ local li = list[i]
if list[i] then
- e[i] = list[i][1]
+ e[i] = li[1]
end
if e[i] == done[i] then
-- skip
@@ -1309,7 +1318,7 @@ function registers.flush(data,options,prefixspec,pagespec)
local processors = entry.processors
local internal = references.internal or 0
local seeparent = references.seeparent or ""
- local processor = processors and processors[1] or ""
+ local processor = (li and li[3]) or (processors and processors[1]) or ""
-- so, we need to keep e as is (local), or we need local title = e[i] ... which might be
-- more of a problem
ctx_startregisterentry(0) -- will become a counter
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv
index e955c700ba7..1e632eebc39 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv
@@ -48,7 +48,7 @@
\let\strc_registers_setup_saved\setupregister
-\unexpanded\def\setupregister % maybe we should drop the plural form
+\unexpanded\overloaded\def\setupregister % maybe we should drop the plural form
{\dotripleempty\strc_registers_setup}
\def\strc_registers_setup[#1][#2][#3]%
@@ -311,7 +311,7 @@
% needs thinking ... bla\index{bla}. will break before the . but adding a
% penalty is also no solution
\dostarttagged\t!registerlocation\currentregister
- \attribute\destinationattribute\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup
+ \c_attr_destination\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup
\dotagregisterlocation
\dostoptagged
\endgroup}
@@ -344,7 +344,7 @@
\xdef\currentregistersynchronize{\clf_deferredenhanceregister{\currentregister}\number\currentregisternumber}%
\currentregistersynchronize % here?
\dostarttagged\t!registerlocation\currentregister
- \attribute\destinationattribute\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup
+ \c_attr_destination\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup
\dotagregisterlocation
\dostoptagged
\endgroup}
@@ -564,7 +564,7 @@
view {\interactionparameter\c!focus}%
\relax % this will change
\dostarttagged\t!registerlocation\currentregister
- \attribute\destinationattribute\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup
+ \c_attr_destination\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup
\dotagregisterlocation
\dostoptagged
\endgroup}
@@ -618,7 +618,7 @@
\edef\currentregister{\firstinset{#1}}%
\the\everyplaceregister
\ifnum\namedmixedcolumnsparameter\currentregister\c!n>\plusone
- \startmixedcolumns[\currentregister]
+ \startmixedcolumns[\currentregister]%
\strc_registers_place_indeed{#1}%
\stopmixedcolumns
\else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-ren.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-ren.mkiv
index 59f3a9256ee..359bd6aecc0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-ren.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-ren.mkiv
@@ -90,9 +90,9 @@
\def\setinlineheadreferenceattributes
{\ifconditional\headisdisplay \else \iflocation
- \attribute\destinationattribute\currentstructureattribute
- \attribute\referenceattribute \currentstructurereferenceattribute
- % \attribute\internalattribute \locationcount
+ \c_attr_destination\currentstructureattribute
+ \c_attr_reference \currentstructurereferenceattribute
+ % \c_attr_internal \locationcount
\fi \fi}
\def\docheckheadreference
@@ -187,7 +187,7 @@
\ifx\p_strut\v!no
\setnostrut
\fi
- \let\\\strc_rendering_shortcut_backslash}
+ \enforced\let\\\strc_rendering_shortcut_backslash}
\unexpanded\def\strc_rendering_shortcut_backslash
{\crlf
@@ -745,8 +745,8 @@
\vbox {
\headsetupspacing
\veryraggedcenter
- \let\\\endgraf
- \let\crlf\endgraf
+ \enforced\let\\\endgraf
+ \enforced\let\crlf\endgraf
\ifconditional\headshownumber
\strut
\headnumbercontent
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv
index 0e30d92fa03..8d326e30022 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv
@@ -145,6 +145,7 @@
\xdef\currentstructureshownumber {\structureparameter\c!number}%
\xdef\currentstructuresaveinlist {\structureparameter\c!saveinlist}%
\xdef\currentstructureincrementnumber{\structureparameter\c!incrementnumber}%
+ \xdef\currentstructureplaceholder {\structureparameter\c!placeholder}%
\ifx\currentstructureexpansion\s!xml
\xmlstartraw
\xdef\currentstructuretitle {\structureparameter\c!title}%
@@ -797,7 +798,7 @@
\glet\currentstructuresynchronize\donothing
\to \everyheadsynchronization
-\unexpanded\def\theheadsynchonization
+\unexpanded\def\theheadsynchronization
{% no, interferes: \signalcharacter
\the\everyheadsynchronization}
@@ -926,7 +927,7 @@
\strc_sectioning_register{#1}{#2}{#3}% after optional \page
\strc_sectioning_report
\dostarttagged\t!sectioncaption\empty
- \let\getheadsyncs\theheadsynchonization
+ \let\getheadsyncs\theheadsynchronization
\let\getheadtitle\fullheadtitle
\ifconditional\headshownumber
\let\getheadnumber\fullheadnumber
@@ -940,7 +941,7 @@
\strc_sectioning_register{#1}{#2}{#3}% after optional \page
\strc_sectioning_report
\dostarttagged\t!sectioncaption\empty
- \let\getheadsyncs\theheadsynchonization
+ \let\getheadsyncs\theheadsynchronization
\ifconditional\c_strc_sectioning_section
\strc_rendering_place_head_section
\else
@@ -952,7 +953,7 @@
\strc_sectioning_register{#1}{#2}{#3}% after optional \page
\strc_sectioning_report
\dostarttagged\t!sectioncaption\empty
- \let\getheadsyncs\theheadsynchonization
+ \let\getheadsyncs\theheadsynchronization
\strc_rendering_place_head_empty % just flush 'm
\dostoptagged
\strc_sectioning_after_nop
@@ -963,7 +964,7 @@
\strc_sectioning_register{#1}{#2}{#3}% after optional \page
\strc_sectioning_report
\dostarttagged\t!sectioncaption\empty
- \let\getheadsyncs\theheadsynchonization
+ \let\getheadsyncs\theheadsynchronization
\let\getheadtitle\fullheadtitle
\strc_rendering_place_head_text
\dostoptagged
@@ -971,7 +972,7 @@
\else\ifconditional\c_strc_sectioning_hidden
\strc_sectioning_register{#1}{#2}{#3}% after optional \page
\strc_sectioning_report
- \let\getheadsyncs\theheadsynchonization
+ \let\getheadsyncs\theheadsynchronization
\dostarttagged\t!sectioncaption\empty
\ifconditional\c_strc_sectioning_section
\strc_rendering_place_head_section
@@ -985,7 +986,7 @@
\strc_sectioning_register{#1}{#2}{#3}% after optional \page
\strc_sectioning_report
\dostarttagged\t!sectioncaption\empty
- \let\getheadsyncs\theheadsynchonization
+ \let\getheadsyncs\theheadsynchronization
\strc_rendering_place_head_empty % just flush 'm
\dostoptagged
\strc_sectioning_after_nop
@@ -997,12 +998,26 @@
\setfalse\c_strc_sectioning_ignore_page
% ignorespaces prevents spaces creeping in when after=\dontleavehmode
\dostarttagged\t!sectioncontent\empty
- \ifconditional\headisdisplay
- \ignorespaces
+ \ifx\currentstructureplaceholder\empty
+ \ifconditional\headisdisplay
+ \doubleexpandafter\ignorespaces
+ \else
+ \doubleexpandafter\ignorepars
+ \fi
\else
- \expandafter\GotoPar
+ \expandafter\strc_sectioning_placeholder
\fi}
+%D \starttyping
+%D \startsubject[placeholder=todo,title=one]
+%D whatever one
+%D \stopsubject
+%D \stoptyping
+
+\def\strc_sectioning_placeholder
+ {\placeholder[\currentstructureplaceholder]%
+ \gobblenested{\e!start\currenthead}{\e!stop\currenthead}{\e!stop\currenthead}}
+
% typesetting (the getters are public)
\unexpanded\def\strc_rendering_place_head_number_and_text
@@ -1029,14 +1044,14 @@
\def\strc_sectioning_delayed_flush
{\ifvoid\b_sectioning_delayed\else
- \smashboxed\b_sectioning_delayed
+ \smashedbox\b_sectioning_delayed
\fi}
\unexpanded\def\strc_rendering_place_head_section % see hidden below
{\global\setbox\b_sectioning_delayed\hpack\bgroup
\setmarking[\currentheadcoupling]{li::\currentstructurelistnumber}%
\hpack\headreferenceattributes{}% also does the mark
- \theheadsynchonization
+ \theheadsynchronization
\egroup}
\unexpanded\def\strc_rendering_place_head_hidden % maybe trialtypesetting check
@@ -1046,7 +1061,7 @@
{\noexpand\letgvalue{\??hiddenheadsync\currenthead}\relax
\noexpand\setmarking[\currentheadcoupling]{li::\currentstructurelistnumber}%
\hpack\headreferenceattributes{}% otherwise no destination ... maybe tag ref as hidden and fall back on page reference
- \theheadsynchonization}} % and it's a node anyway
+ \theheadsynchronization}} % and it's a node anyway
\def\synchronizehead #1{\csname\??hiddenheadsync#1\endcsname}
\def\theheadreferenceattributes#1{\csname\??hiddenheadattr#1\endcsname}
@@ -1283,6 +1298,14 @@
\fi
\glet\previoushead\currenthead}
+\def\strc_sectioning_depth_correction
+ {\ifvmode
+ \edef\p_depthcorrection{\headparameter\c!depthcorrection}%
+ \ifx\p_depthcorrection\v!strut
+ \prevdepth\strutdepth
+ \fi
+ \fi}
+
\def\strc_sectioning_after_yes
{\ifconditional\headisdisplay
\ifconditional\c_strc_sectioning_auto_break
@@ -1290,6 +1313,7 @@
\fi
\strc_sectioning_empty_correction
\headparameter\c!after
+ \strc_sectioning_depth_correction
\fi}
\unexpanded\def\strc_sectioning_prevent_page_break % see strc-con
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-syn.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-syn.lua
index eec025593d7..c0ebb556cc7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-syn.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-syn.lua
@@ -37,6 +37,20 @@ end
local function finalizer()
for entry, data in next, tobesaved do
data.hash = nil
+ -- being sparse can be an option but often we actually do want the
+ -- whole list so we don't do this ... only as possible option
+ --
+ -- local entries = data.entries
+ -- local t = { }
+ -- local n = 0
+ -- for i=1,#entries do
+ -- local e = entries[i]
+ -- if e.definition.shown then
+ -- n = n + 1
+ -- t[n] = e
+ -- end
+ -- end
+ -- data.entries = t
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-syn.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-syn.mkiv
index 7f71e88f52f..cdede1d0da0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-syn.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-syn.mkiv
@@ -383,6 +383,7 @@
\startsetups[\??simplelistrenderings::\v!text]
\begingroup
+ \usehyphensparameter\simplelistparameter
\usesimpleliststyleandcolor\c!textstyle\c!textcolor
\simplelistparameter\c!textcommand{\currentsynonymmeaning}%
\endgroup
@@ -663,7 +664,8 @@
\setupsynonyms
[\v!abbreviation]
- [\c!textstyle=\v!capital]
+ [\c!hyphens=\v!no, % new, not yet in setup definitions
+ \c!textstyle=\v!capital]
\definesorting
[\v!logo]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
index 88e0f108dc9..83ff515e30c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
@@ -104,6 +104,7 @@ local properties = allocate { -- todo: more "record = true" to improve forma
lines = { pdf = "Code", nature = "display" },
line = { pdf = "Code", nature = "mixed" },
+ linenumber = { pdf = "Span", nature = "inline" },
synonym = { pdf = "Span", nature = "inline" },
sorting = { pdf = "Span", nature = "inline" },
@@ -265,8 +266,8 @@ end
function structures.atlocation(str)
local specification = taglist[texgetattribute(a_tagged)]
if specification then
+ local list = specification.taglist
if list then
- local taglist = specification.taglist
local pattern = patterns[str]
for i=#list,1,-1 do
if find(list[i],pattern) then
@@ -362,7 +363,9 @@ function tags.start(tag,specification)
metadata = nil
end
local userdata = specification.userdata
- if userdata ~= "" and type(userdata) == "string" then
+ if userdata == "" then
+ specification.userdata = nil
+ elseif type(userdata) == "string" then
specification.userdata = settings_to_hash(userdata)
end
local detail = specification.detail
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-tag.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-tag.mkiv
index 83ee030902a..bae04461243 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-tag.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-tag.mkiv
@@ -20,168 +20,173 @@
\unprotect
-%D Eventually these labels will either move to the modules
-%D where they're used, or they will en dup in mult-tag.
-
-\def\t!document {document} % Div
-
-\def\t!division {division} % Div
-\def\t!paragraph {paragraph} % P
-\def\t!p {p} % P
-\def\t!construct {construct} % Span
-\def\t!highlight {highlight} % Span
-
-\def\t!section {section} % Sect
-\def\t!sectioncaption {sectioncaption} % Div
-\def\t!sectiontitle {sectiontitle} % H
-\def\t!sectionnumber {sectionnumber} % H
-\def\t!sectioncontent {sectioncontent} % Div
-
-\def\t!itemgroup {itemgroup} % L
-\def\t!item {item} % Li
-\def\t!itemtag {itemtag} % Lbl
-\def\t!itemcontent {itemcontent} % LBody
-\def\t!itemhead {itemhead} % Div
-\def\t!itembody {itembody} % Div
-
-\def\t!description {description} % Li
-\def\t!descriptiontag {descriptiontag} % Lbl
-\def\t!descriptioncontent {descriptioncontent} % LBody
-\def\t!descriptionsymbol {descriptionsymbol} % Span
-
-\let\t!construction \t!description
-\let\t!constructiontag \t!descriptiontag
-\let\t!constructioncontent \t!descriptioncontent
-\let\t!constructionsymbol \t!descriptionsymbol
-
-\def\t!verbatimblock {verbatimblock} % Code
-\def\t!verbatimlines {verbatimlines} % Code
-\def\t!verbatimline {verbatimline} % Code
-\def\t!verbatim {verbatim} % Code
-
-\def\t!lines {lines} % Code
-\def\t!line {line} % Code
-
-\def\t!sorting {sorting} % Span
-\def\t!synonym {synonym} % Span
-
-\def\t!register {register} % Div
-\def\t!registerlocation {registerlocation} % Span
-\def\t!registersection {registersection} % Div
-\def\t!registertag {registertag} % Span
-\def\t!registerentries {registerentries} % Div
-\def\t!registerentry {registerentry} % Span
-\def\t!registercontent {registercontent} % Span
-\def\t!registersee {registersee} % Span
-\def\t!registersection {registersection} % Span
-\def\t!registerpages {registerpages} % Span
-\def\t!registerpage {registerpage} % Span
-\def\t!registerpagerange {registerpagerange} % Span
-\def\t!registerfrompage {registerfrompage} % Span
-\def\t!registertopage {registertopage} % Span
-\def\t!registerseparator {registerseparator} % Span
-
-\def\t!table {table} % Table
-\def\t!tablerow {tablerow} % TR
-\def\t!tablecell {tablecell} % TD
-\def\t!tableheadcell {tableheadcell} % TH
-\def\t!tablehead {tablehead} % THEAD
-\def\t!tablebody {tablebody} % TBODY
-\def\t!tablefoot {tablefoot} % TFOOT
-
-
-\def\t!tabulate {tabulate} % Table
-\def\t!tabulaterow {tabulaterow} % TR
-\def\t!tabulatecell {tabulatecell} % TD
-\def\t!tabulateheadcell {tabulateheadcell} % TH
-\def\t!tabulatehead {tabulatehead} % THEAD
-\def\t!tabulatebody {tabulatebody} % TBODY
-\def\t!tabulatefoot {tabulatefoot} % TFOOT
-
-\def\t!math {math} % math
-\def\t!mathtable {mtable} % Table
-\def\t!mathtablerow {mtr} % TR
-\def\t!mathtablecell {mtd} % TD
-\def\t!mathaction {maction} %
-\def\t!mathstacker {mstacker}
-\def\t!mathstackertop {mstackertop}
-\def\t!mathstackermid {mstackermid}
-\def\t!mathstackerbot {mstackerbot}
-
-\def\t!munderover {munderover} % special cases
-\def\t!munder {munder} % special cases
-\def\t!mover {mover} % special cases
-
-\def\t!list {list} % TOC
-\def\t!listitem {listitem} % TOCI
-\def\t!listtag {listtag} % Lbl
-\def\t!listcontent {listcontent} % P
-\def\t!listdata {listdata} % P
-\def\t!listpage {listpage} % Reference
-\def\t!listtext {listtext} % Span
-
-\def\t!delimitedblock {delimited} % BlockQuote
-\def\t!delimited {delimited} % Quote
-\def\t!delimitedsymbol {delimitedsymbol} % Span
-\def\t!delimitedcontent {delimitedcontent} % Span
-\def\t!subsentence {subsentence} % Span
-\def\t!subsentencecontent {subsentencecontent} % Span
-\def\t!subsentencesymbol {subsentencesymbol} % Span
-
-\def\t!float {float} % Div
-\def\t!floatcaption {floatcaption} % Caption
-\def\t!floatlabel {floatlabel} % Span
-\def\t!floattext {floattext} % Span
-\def\t!floatnumber {floatnumber} % Span
-\def\t!floatcontent {floatcontent} % P
-
-\def\t!image {image} % P
-
-\def\t!mpgraphic {mpgraphic} % P
-
-\def\t!formulaset {formulaset} % Div
-\def\t!formula {formula} % Div
-\def\t!formulacaption {formulacaption} % Span
-\def\t!formulalabel {formulalabel} % Span
-\def\t!formulanumber {formulanumber} % P
-\def\t!formulacontent {formulacontent} % P
-\def\t!subformula {subformula} % Div
-
-\def\t!link {link} % Link
-\def\t!reference {reference} % Span
-
-\def\t!margintext {margintext} % Span
-\def\t!margintextblock {margintextblock} % Div
-\def\t!marginanchor {marginanchor} % Span
+%D Eventually these labels will either move to the modules where they're used, or
+%D they will en dup in mult-tag.
+
+\definetagconstant{document} % Div
+
+\definetagconstant{division} % Div
+\definetagconstant{paragraph} % P
+\definetagconstant{p} % P
+\definetagconstant{construct} % Span
+\definetagconstant{highlight} % Span
+
+\definetagconstant{section} % Sect
+\definetagconstant{sectioncaption} % Div
+\definetagconstant{sectiontitle} % H
+\definetagconstant{sectionnumber} % H
+\definetagconstant{sectioncontent} % Div
+
+\definetagconstant{itemgroup} % L
+\definetagconstant{item} % Li
+\definetagconstant{itemtag} % Lbl
+\definetagconstant{itemcontent} % LBody
+\definetagconstant{itemhead} % Div
+\definetagconstant{itembody} % Div
+
+\definetagconstant{description} % Li
+\definetagconstant{descriptiontag} % Lbl
+\definetagconstant{descriptioncontent} % LBody
+\definetagconstant{descriptionsymbol} % Span
+
+\aliastagconstant{construction} {description}
+\aliastagconstant{constructiontag} {descriptiontag}
+\aliastagconstant{constructioncontent}{descriptioncontent}
+\aliastagconstant{constructionsymbol} {descriptionsymbol}
+
+\definetagconstant{verbatimblock} % Code
+\definetagconstant{verbatimlines} % Code
+\definetagconstant{verbatimline} % Code
+\definetagconstant{verbatim} % Code
+
+\definetagconstant{lines} % Code
+\definetagconstant{line} % Code
+\definetagconstant{linenumber} % Span
+
+\definetagconstant{sorting} % Span
+\definetagconstant{synonym} % Span
+
+\definetagconstant{register} % Div
+\definetagconstant{registerlocation} % Span
+\definetagconstant{registersection} % Div
+\definetagconstant{registertag} % Span
+\definetagconstant{registerentries} % Div
+\definetagconstant{registerentry} % Span
+\definetagconstant{registercontent} % Span
+\definetagconstant{registersee} % Span
+\definetagconstant{registerpages} % Span
+\definetagconstant{registerpage} % Span
+\definetagconstant{registerpagerange} % Span
+\definetagconstant{registerfrompage} % Span
+\definetagconstant{registertopage} % Span
+\definetagconstant{registerseparator} % Span
+
+\definetagconstant{table} % Table
+\definetagconstant{tablerow} % TR
+\definetagconstant{tablecell} % TD
+\definetagconstant{tableheadcell} % TH
+\definetagconstant{tablehead} % THEAD
+\definetagconstant{tablebody} % TBODY
+\definetagconstant{tablefoot} % TFOOT
+
+\definetagconstant{tabulate} % Table
+\definetagconstant{tabulaterow} % TR
+\definetagconstant{tabulatecell} % TD
+\definetagconstant{tabulateheadcell} % TH
+\definetagconstant{tabulatehead} % THEAD
+\definetagconstant{tabulatebody} % TBODY
+\definetagconstant{tabulatefoot} % TFOOT
+
+\definetagconstant{math} % math
+\definetagconstant{mtable} % Table
+\definetagconstant{mtr} % TR
+\definetagconstant{mtd} % TD
+\definetagconstant{maction} %
+\definetagconstant{mstacker}
+\definetagconstant{mstackertop}
+\definetagconstant{mstackermid}
+\definetagconstant{mstackerbot}
+
+\aliastagconstant{mtablerow} {mtr}
+\aliastagconstant{mtablecell}{mtd}
+
+\definetagconstant{munderover} % special cases
+\definetagconstant{munder} % special cases
+\definetagconstant{mover} % special cases
+
+\definetagconstant{list} % TOC
+\definetagconstant{listitem} % TOCI
+\definetagconstant{listtag} % Lbl
+\definetagconstant{listcontent} % P
+\definetagconstant{listdata} % P
+\definetagconstant{listpage} % Reference
+\definetagconstant{listtext} % Span
+
+\definetagconstant{delimited} % BlockQuote
+%definetagconstant{delimited} % Quote
+\definetagconstant{delimitedsymbol} % Span
+\definetagconstant{delimitedcontent} % Span
+
+\aliastagconstant{delimitedblock}{delimited}
+
+\definetagconstant{subsentence} % Span
+\definetagconstant{subsentencecontent} % Span
+\definetagconstant{subsentencesymbol} % Span
+
+\definetagconstant{float} % Div
+\definetagconstant{floatcaption} % Caption
+\definetagconstant{floatlabel} % Span
+\definetagconstant{floattext} % Span
+\definetagconstant{floatnumber} % Span
+\definetagconstant{floatcontent} % P
+
+\definetagconstant{image} % P
+
+\definetagconstant{mpgraphic} % P
+
+\definetagconstant{formulaset} % Div
+\definetagconstant{formula} % Div
+\definetagconstant{formulacaption} % Span
+\definetagconstant{formulalabel} % Span
+\definetagconstant{formulanumber} % P
+\definetagconstant{formulacontent} % P
+\definetagconstant{subformula} % Div
+
+\definetagconstant{link} % Link
+\definetagconstant{reference} % Span
+
+\definetagconstant{margintext} % Span
+\definetagconstant{margintextblock} % Div
+\definetagconstant{marginanchor} % Span
% we might opt for verbose variants so this is experimental:
-\def\t!label {label} % Span
-\def\t!number {number} % Span
+\definetagconstant{label} % Span
+\definetagconstant{number} % Span
-\def\t!ignore {ignore} % Span
-\def\t!private {private} % Span
+\definetagconstant{ignore} % Span
+\definetagconstant{private} % Span
-\def\t!mid {mid} % Span
-\def\t!sub {sub} % Span
-\def\t!sup {sup} % Span
-\def\t!subsup {subsup} % Span
+\definetagconstant{mid} % Span
+\definetagconstant{sub} % Span
+\definetagconstant{sup} % Span
+\definetagconstant{subsup} % Span
-\def\t!unit {unit} % Span
-\def\t!quantity {quantity} % Span
-\def\t!number {number} % Span
+\definetagconstant{unit} % Span
+\definetagconstant{quantity} % Span
+%definetagconstant{number} % Span
-\def\t!combination {combination} % Span
-\def\t!combinationpair {combinationpair} % Span
-\def\t!combinationcontent {combinationcontent} % Span
-\def\t!combinationcaption {combinationcaption} % Span
+\definetagconstant{combination} % Span
+\definetagconstant{combinationpair} % Span
+\definetagconstant{combinationcontent} % Span
+\definetagconstant{combinationcaption} % Span
-\def\t!publications {publications} % Span
-\def\t!publication {publication} % Span
-\def\t!pubfld {pubfld} % Span
+\definetagconstant{publications} % Span
+\definetagconstant{publication} % Span
+\definetagconstant{pubfld} % Span
-\def\t!block {block} % Div
-\def\t!userdata {userdata} % Div
+\definetagconstant{block} % Div
+\definetagconstant{userdata} % Div
% \setuptaglabeltext
% [en]
@@ -329,11 +334,8 @@
\chardef\strc_tags_placeholder_char\zerocount % "FFFC
-\unexpanded\def\strc_tags_enable
- {% once enable one is toast
- \global\settrue\c_strc_tags_enabled
- % and gets:
- \let\dotaggedplaceholder \strc_tags_placeholder_char
+\unexpanded\def\strc_tags_enable_indeed
+ {\let\dotaggedplaceholder \strc_tags_placeholder_char
\let\dostarttagged \strc_tags_enabled_start_detail
\let\dostarttaggednodetail\strc_tags_enabled_start_no_detail
\let\dostarttaggedchained \strc_tags_enabled_start_chained
@@ -341,6 +343,12 @@
\let\dostartignoretagging \strc_tags_start_yes_ignore
\let\dostopignoretagging \strc_tags_stop_yes_ignore}
+\unexpanded\def\strc_tags_enable
+ {% once enable one is toast
+ \global\settrue\c_strc_tags_enabled
+ % and gets:
+ \strc_tags_enable_indeed}
+
\unexpanded\def\strc_tags_disable
{\ifconditional\c_strc_tags_enabled
% so now all are artifacts
@@ -411,7 +419,7 @@
\to \everysetuptagging
\unexpanded\def\forgettagging
- {\attribute\taggedattribute\attributeunsetvalue}
+ {\c_attr_tagged\attributeunsetvalue}
\setuptagging
[\c!state=\v!stop,
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-box.lua b/Master/texmf-dist/tex/context/base/mkiv/supp-box.lua
index e547c8710d6..4914b6818f1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-box.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-box.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['supp-box'] = {
version = 1.001,
+ optimize = true,
comment = "companion to supp-box.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -28,6 +29,11 @@ local vlist_code = nodecodes.vlist
local glue_code = nodecodes.glue
local penalty_code = nodecodes.penalty
local glyph_code = nodecodes.glyph
+local par_code = nodecodes.par
+
+local indent_code = nodes.listcodes.indent
+
+local hmode_code = tex.modelevels.horizontal
local nuts = nodes.nuts
local tonut = nuts.tonut
@@ -39,11 +45,13 @@ local getprev = nuts.getprev
local getboth = nuts.getboth
local getdisc = nuts.getdisc
local getid = nuts.getid
+local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
local getattribute = nuts.getattribute
local getbox = nuts.getbox
local getdirection = nuts.getdirection
local getwidth = nuts.getwidth
+local getwhd = nuts.getwhd
local takebox = nuts.takebox
----- setfield = nuts.setfield
@@ -70,6 +78,7 @@ local getdimensions = nuts.dimensions
local hpack = nuts.hpack
local vpack = nuts.vpack
local traverse_id = nuts.traverse_id
+local traverse = nuts.traverse
local free = nuts.free
local findtail = nuts.tail
@@ -89,6 +98,7 @@ local setlistcolor = nodes.tracers.colors.setlist
local texget = tex.get
local texgetbox = tex.getbox
local texsetdimen = tex.setdimen
+local texgetnest = tex.getnest
local function hyphenatedlist(head,usecolor)
local current = head and tonut(head)
@@ -825,3 +835,68 @@ implement {
context(limitate(t))
end,
}
+
+implement {
+ name = "doifelseindented",
+ public = true,
+ protected = true,
+ actions = function()
+ local n = texgetnest()
+ local b = false
+ if n.mode == hmode_code then
+ n = tonut(n.head)
+ while n do
+ n = getnext(n)
+ if n then
+ local id = getid(n)
+ if id == hlist_code then
+ if getsubtype(n) == indent_code then
+ b = getwidth(n) > 0
+ break
+ end
+ elseif id ~= par_code then
+ break
+ end
+ end
+ end
+ end
+ commands.doifelse(b)
+ end,
+}
+
+implement {
+ name = "noflinesinbox",
+ public = true,
+ protected = false,
+ arguments = "integer",
+ actions = function(n)
+ local c = 0
+ local b = getbox(n)
+ if b then
+ b = getlist(b)
+ if b then
+ for n, id in traverse(b) do
+ if id == hlist_code or id == vlist_code then
+ c = c + 1
+ end
+ end
+ end
+ end
+ context(c)
+ end,
+}
+
+do
+
+ local takebox = tex.takebox
+
+ interfaces.implement {
+ name = "thebox",
+ public = true,
+ arguments = "integer",
+ actions = function(n)
+ context(takebox(n))
+ end
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv b/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv
index d43459c631b..16f09302301 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv
@@ -66,7 +66,7 @@
%D The next macro suppresses over- and underfull messages which often makes sense
%D when we deal with boxes.
-\unexpanded\def\dontcomplain
+\protected\def\dontcomplain
{\hbadness\plustenthousand
\vbadness\plustenthousand
\hfuzz \maxdimen
@@ -112,16 +112,16 @@
%D Smashing is introduced in \PLAIN\ \TEX, and stands for reducing the dimensions of
%D a box to zero. The most resolute one is presented first.
-\unexpanded\def\smashbox#1%
- {\wd#1\zeropoint
- \ht#1\zeropoint
- \dp#1\zeropoint}
+% \protected\def\smashbox#1%
+% {\wd#1\zeropoint
+% \ht#1\zeropoint
+% \dp#1\zeropoint}
-\unexpanded\def\smashboxed#1%
- {\wd#1\zeropoint
- \ht#1\zeropoint
- \dp#1\zeropoint
- \box#1\relax}
+% \protected\def\smashboxed#1%
+% {\wd#1\zeropoint
+% \ht#1\zeropoint
+% \dp#1\zeropoint
+% \box#1\relax}
%D \macros
%D {hsmashbox,vsmashbox}
@@ -129,10 +129,10 @@
%D Smashing can be used for overlaying boxes. Depending on the mode, horizontal or
%D vertical, one can use:
-\unexpanded\def\hsmashbox#1%
+\protected\def\hsmashbox#1%
{\wd#1\zeropoint}
-\unexpanded\def\vsmashbox#1%
+\protected\def\vsmashbox#1%
{\ht#1\zeropoint
\dp#1\zeropoint}
@@ -140,7 +140,7 @@
\newcount\c_boxes_register
-\unexpanded\def\smashbox
+\protected\def\smashbox
{\afterassignment\syst_boxes_smash_boxes_register\c_boxes_register}
\def\syst_boxes_smash_boxes_register
@@ -148,28 +148,30 @@
\ht\c_boxes_register\zeropoint
\dp\c_boxes_register\zeropoint}
-\unexpanded\def\hsmashbox
+\protected\def\hsmashbox
{\afterassignment\syst_boxes_hsmashed_boxes_register\c_boxes_register}
\def\syst_boxes_hsmashed_boxes_register
{\wd\c_boxes_register\zeropoint}
-\unexpanded\def\vsmashbox
+\protected\def\vsmashbox
{\afterassignment\syst_boxes_vsmashed_boxes_register\c_boxes_register}
\def\syst_boxes_vsmashed_boxes_register
{\ht\c_boxes_register\zeropoint
\dp\c_boxes_register\zeropoint}
-\unexpanded\def\smashedbox
+\protected\def\smashedbox
{\afterassignment\syst_boxes_smashed_boxes_register\c_boxes_register}
-\unexpanded\def\syst_boxes_smashed_boxes_register
+\protected\def\syst_boxes_smashed_boxes_register
{\wd\c_boxes_register\zeropoint
\ht\c_boxes_register\zeropoint
\dp\c_boxes_register\zeropoint
\box\c_boxes_register}
+\let\smashboxed\smashedbox
+
%D \macros
%D {hsmash,vsmash,
%D hsmashed,vsmashed}
@@ -178,23 +180,23 @@
%D some subtle differences betreen the smash and smashed alternatives. The later
%D ones reduce all dimensions to zero.
-\unexpanded\def\hsmash {\bgroup\dowithnextboxcs\syst_boxes_hsmashed_nextbox\hbox}
-\unexpanded\def\vsmash {\bgroup\dowithnextboxcs\syst_boxes_vsmashed_nextbox\vbox}
-\unexpanded\def\hsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \hbox}
-\unexpanded\def\vsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \vbox}
+\protected\def\hsmash {\bgroup\dowithnextboxcs\syst_boxes_hsmashed_nextbox\hbox}
+\protected\def\vsmash {\bgroup\dowithnextboxcs\syst_boxes_vsmashed_nextbox\vbox}
+\protected\def\hsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \hbox}
+\protected\def\vsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \vbox}
-\unexpanded\def\syst_boxes_hsmashed_nextbox
+\protected\def\syst_boxes_hsmashed_nextbox
{\wd\nextbox\zeropoint
\box\nextbox
\egroup}
-\unexpanded\def\syst_boxes_vsmashed_nextbox
+\protected\def\syst_boxes_vsmashed_nextbox
{\ht\nextbox\zeropoint
\dp\nextbox\zeropoint
\box\nextbox
\egroup}
-\unexpanded\def\syst_boxes_smashed_nextbox
+\protected\def\syst_boxes_smashed_nextbox
{\ht\nextbox\zeropoint
\dp\nextbox\zeropoint
\wd\nextbox\zeropoint
@@ -211,16 +213,16 @@
%D \smashedvbox to ... {...}
%D \stoptyping
-\unexpanded\def\smashedhbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\hbox}
-\unexpanded\def\smashedvbox{\vpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\vbox}
+\protected\def\smashedhbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\hbox}
+\protected\def\smashedvbox{\vpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\vbox}
%D First we define a helper. We use a \LUATEX\ feature in order to avoid
%D mathpalettes.
\newcount\c_boxes_math_style
-\unexpanded\def\syst_boxes_math_set_nextbox#1%
- {\c_boxes_math_style\mathstyle
+\protected\def\syst_boxes_math_set_nextbox#1%
+ {\c_boxes_math_style\normalmathstyle
\setbox\nextbox\hbox{\normalstartimath\mathsurround\zeropoint\triggermathstyle\c_boxes_math_style{#1}\normalstopimath}}
%D \macros
@@ -230,7 +232,7 @@
%D catcode safer. It is needed by the math module (although the \type {\leavevmode}
%D is not added here).
-\unexpanded\def\smash
+\protected\def\smash
{\begingroup
\futurelet\nexttoken\syst_boxes_smash}
@@ -309,9 +311,9 @@
%D {\mathchoice}, the next macro looks ugly. We also take care of non||braced
%D arguments.
-\unexpanded\def\phantom {\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed }
-\unexpanded\def\vphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_v}
-\unexpanded\def\hphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_h}
+\protected\def\phantom {\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed }
+\protected\def\vphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_v}
+\protected\def\hphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_h}
\def\syst_boxes_phantom_math #1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make }
\def\syst_boxes_phantom_math_v#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_v}
@@ -375,7 +377,7 @@
%D We also define plain's \type {\mathstrut}.
-\unexpanded\def\mathstrut{\vphantom(} % can be made faster by inlining
+\protected\def\mathstrut{\vphantom(} % can be made faster by inlining
%D \macros
%D {getboxheight}
@@ -409,7 +411,7 @@
%D The next alternative is slightly more clever, since it accepts \type {{12}} as
%D well as \type {12} as box number.
-\unexpanded\def\getboxheight#1\of#2\box#3%
+\protected\def\getboxheight#1\of#2\box#3%
{\def\next{#1\dimexpr\ht\c_boxes_register+\dp\c_boxes_register\relax}%
\afterassignment\next\c_boxes_register=#3}
@@ -458,7 +460,7 @@
\newcount\noflines
\newdimen\noflinesheight
-\unexpanded\def\getnoflines#1%
+\protected\def\getnoflines#1%
{\noflinesheight#1\relax
\ifzeropt\noflinesheight
\noflines\zerocount
@@ -474,7 +476,7 @@
\advance\noflines\minusone
\fi\fi}
-\unexpanded\def\getroundednoflines#1%
+\protected\def\getroundednoflines#1%
{\noflinesheight#1\relax
\ifzeropt\noflinesheight
\noflines\zerocount
@@ -488,7 +490,7 @@
\noflines\noflinesheight
\fi\fi}
-\unexpanded\def\getrawnoflines#1%
+\protected\def\getrawnoflines#1%
{\noflinesheight#1\relax
\ifzeropt\noflinesheight
\noflines\zerocount
@@ -541,15 +543,18 @@
%D \determinenoflines{\definedfont[Sans at 40pt]test\\test}
%D \stoptyping
-\def\syst_boxes_determine_noflines % can be mkiv'd
- {\beginofshapebox
- \unvbox\nextbox
- \endofshapebox
- \globalscratchcounter\zerocount
- \reshapebox{\global\advance\globalscratchcounter\plusone}%
- \expandafter\egroup\expandafter\noflines\the\globalscratchcounter\relax}
+% \def\syst_boxes_determine_noflines % can be mkiv'd
+% {\beginofshapebox
+% \unvbox\nextbox
+% \endofshapebox
+% \globalscratchcounter\zerocount
+% \reshapebox{\global\advance\globalscratchcounter\plusone}%
+% \expandafter\egroup\expandafter\noflines\the\globalscratchcounter\relax}
-\unexpanded\def\determinenoflines
+\def\syst_boxes_determine_noflines
+ {\expandafter\egroup\expandafter\noflines\noflinesinbox\nextbox\relax}
+
+\protected\def\determinenoflines
{\bgroup
\forgetall
\let\crlf\endgraf
@@ -567,7 +572,7 @@
%D \doiftext {data} {then branch}
%D \stoptyping
-\unexpanded\def\doifelsetext#1%
+\protected\def\doifelsetext#1%
{\begingroup
\setbox\scratchbox\hbox % no \hpack because we can have fallbacks
{\settrialtypesetting
@@ -580,7 +585,7 @@
\let\doiftextelse\doifelsetext
-\unexpanded\def\doiftext#1%
+\protected\def\doiftext#1%
{\begingroup
\setbox\scratchbox\hbox % no \hpack because we can have fallbacks
{\settrialtypesetting
@@ -624,7 +629,7 @@
%D In this implementation the \type {\aftergroup} construction is needed because
%D \type {\afterassignment} is executed inside the box.
-\unexpanded\def\dowithnextbox#1%
+\protected\def\dowithnextbox#1%
{\def\syst_boxes_with_next_box{#1}%
\afterassignment\syst_boxes_with_next_box_indeed
\setbox\nextbox}
@@ -632,7 +637,7 @@
\def\syst_boxes_with_next_box_indeed
{\aftergroup\syst_boxes_with_next_box}
-\unexpanded\def\dowithnextboxcs#1%
+\protected\def\dowithnextboxcs#1%
{\let\syst_boxes_with_next_box#1%
\afterassignment\syst_boxes_with_next_box_indeed
\setbox\nextbox}
@@ -652,7 +657,7 @@
%D A slower but more versatile implementation is:
%D
%D \starttyping
-%D \unexpanded\def\dowithnextbox#1#2%
+%D \protected\def\dowithnextbox#1#2%
%D {\def\syst_boxes_with_next_box{#1}%
%D \ifx#2\hbox
%D \afterassignment\syst_boxes_with_next_box_indeed
@@ -682,7 +687,7 @@
\def\nextboxdp {\dp\nextbox}
\def\nextboxhtdp{\dimexpr\ht\nextbox+\dp\nextbox\relax}
-\unexpanded\def\flushnextbox{\box\nextbox}
+\protected\def\flushnextbox{\box\nextbox}
%D \macros
%D {dowithnextboxcontent}
@@ -696,13 +701,13 @@
%D
%D {\em todo: Search source for potential usage!}
-\unexpanded\def\dowithnextboxcontent#1#2% inside, after
+\protected\def\dowithnextboxcontent#1#2% inside, after
{\def\syst_boxes_with_next_box_one{#2}%
\def\syst_boxes_with_next_box_two{#1}%
\afterassignment\syst_boxes_with_next_box_content_indeed
\setbox\nextbox}
-\unexpanded\def\dowithnextboxcontentcs#1#2% inside, after
+\protected\def\dowithnextboxcontentcs#1#2% inside, after
{\let\syst_boxes_with_next_box_one#2%
\let\syst_boxes_with_next_box_two#1%
\afterassignment\syst_boxes_with_next_box_content_indeed
@@ -729,15 +734,15 @@
\def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
\def\domathrlap{\mathpalette\dodomathrlap} \def\dodomathrlap#1#2{\dorlap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
-\unexpanded\def\rlap{\mathortext\domathrlap\dorlap}
-\unexpanded\def\llap{\mathortext\domathllap\dollap}
-\unexpanded\def\clap{\mathortext\domathclap\doclap}
+\protected\def\rlap{\mathortext\domathrlap\dorlap}
+\protected\def\llap{\mathortext\domathllap\dollap}
+\protected\def\clap{\mathortext\domathclap\doclap}
\def\dodotlap{\vpack to \zeropoint{\vss\box\nextbox}\endgroup}
\def\dodoblap{\vpack to \zeropoint{\box\nextbox\vss}\endgroup}
-\unexpanded\def\tlap{\begingroup\dowithnextboxcs\dodotlap\vbox}
-\unexpanded\def\blap{\begingroup\dowithnextboxcs\dodoblap\vbox}
+\protected\def\tlap{\begingroup\dowithnextboxcs\dodotlap\vbox}
+\protected\def\blap{\begingroup\dowithnextboxcs\dodoblap\vbox}
%D \macros
%D {beginofshapebox,
@@ -871,7 +876,7 @@
\def\shapesignal{.12345678pt} % or 12345sp
-\unexpanded\def\reshapebox#1%
+\protected\def\reshapebox#1%
{\doreshapebox
{#1}%
{\penalty\shapepenalty}%
@@ -895,11 +900,11 @@
% We will turn this into a \MKIV\ variant (we can use \type {\vpack} too).
-\unexpanded\def\insertshapesignal
+\protected\def\insertshapesignal
{\hpack to \shapesignal{\strut\hss}% plus \strut
\prevdepth\strutdp} % never \nointerlineskip
-\unexpanded\def\restoreshapebox % compensates for the signal
+\protected\def\restoreshapebox % compensates for the signal
{\global\setbox\tmpshapebox\vbox{\vskip-\lineheight\unvcopy\oldshapebox}}
\def\dodoreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip
@@ -936,21 +941,21 @@
\advance\shapecounter \plusone
\fi}
-\unexpanded\def\beginofshapebox
+\protected\def\beginofshapebox
{\setbox\oldshapebox\vbox
\bgroup
\reshapingboxtrue
\the\everyshapebox
\insertshapesignal}
-\unexpanded\def\endofshapebox
+\protected\def\endofshapebox
{\endgraf
\egroup}
\let\beginshapebox\beginofshapebox
\let\endshapebox \endofshapebox
-\unexpanded\def\flushshapebox
+\protected\def\flushshapebox
{\bgroup
\ifzeropt\ht\newshapebox
\else
@@ -1001,7 +1006,7 @@
%
% \omlijnd[offset=0pt,hoogte=8mm,uitlijnen={rechts,laho}]{\bfa test}
-\unexpanded\def\innerflushshapebox
+\protected\def\innerflushshapebox
{\ifzeropt\ht\newshapebox \else
\unvcopy\newshapebox\relax % unvcopy ! else spacing problem
% \kern-\dp\newshapebox\relax
@@ -1024,7 +1029,7 @@
%D use \type {\shapedhbox} instead of \type {\hbox}, since it manages the height and
%D depth of the line.
-\unexpanded\def\shapedhbox % lines with non strutted dimensions have
+\protected\def\shapedhbox % lines with non strutted dimensions have
{\expanded{\dowithnextbox % interlineskip so if we want the original
{\ht\nextbox\the\ht\shapebox % spacing, we need to preserve the original
\dp\nextbox\the\dp\shapebox % height and depth which is definitely
@@ -1044,10 +1049,10 @@
%D \showhyphens{dohyphenatedword}
%D \stoptyping
-\unexpanded\def\doshowhyphenatednextbox
+\protected\def\doshowhyphenatednextbox
{\clf_showhyphenatedinlist\nextbox}
-\unexpanded\def\showhyphens % hpack: so no processing (we hyphenate in lua)
+\protected\def\showhyphens % hpack: so no processing (we hyphenate in lua)
{\dowithnextboxcs\doshowhyphenatednextbox\hpack}
%D The following macros are seldom used but handy for tracing.
@@ -1058,19 +1063,19 @@
%D \hyphenatedfile{tufte}
%D \stoptyping
-\unexpanded\def\dohyphenatednextbox
+\protected\def\dohyphenatednextbox
{\clf_hyphenatedlist\nextbox false\relax
\unhbox\nextbox}
-\unexpanded\def\hyphenatedword {\dowithnextboxcs\dohyphenatednextbox\hbox}
-\unexpanded\def\hyphenatedpar {\dowithnextboxcs\dohyphenatednextbox\hbox}
-\unexpanded\def\hyphenatedfile#1{\dowithnextboxcs\dohyphenatednextbox\hbox{\readfile{#1}\donothing\donothing}}
+\protected\def\hyphenatedword {\dowithnextboxcs\dohyphenatednextbox\hbox}
+\protected\def\hyphenatedpar {\dowithnextboxcs\dohyphenatednextbox\hbox}
+\protected\def\hyphenatedfile#1{\dowithnextboxcs\dohyphenatednextbox\hbox{\readfile{#1}\donothing\donothing}}
-\unexpanded\def\dohyphenatednextboxcolor
+\protected\def\dohyphenatednextboxcolor
{\clf_hyphenatedlist\nextbox true\relax
\unhbox\nextbox}
-\unexpanded\def\hyphenatedcoloredword{\dowithnextboxcs\dohyphenatednextboxcolor\hbox}
+\protected\def\hyphenatedcoloredword{\dowithnextboxcs\dohyphenatednextboxcolor\hbox}
%D \macros
%D {processtokens}
@@ -1099,11 +1104,11 @@
%D The list of tokens may contain spaces, while \type {\\}, \type {{}} and \type {\
%D } are handled as space too.
-\unexpanded\def\processtokens#1#2#3#4#5%
+\protected\def\processtokens#1#2#3#4#5%
{\begingroup
\def\lastcharacter{\lastcharacter}% hm, recursive ?
+ \let\\\space
\def\space{ }%
- \let\\=\space
\def\before {#1}%
\def\between{#2}%
\def\after {#3}%
@@ -1188,7 +1193,7 @@
\ifdefined\fakecompoundhyphen\else \let\fakecompoundhyphen\relax \fi
\ifdefined\veryraggedright \else \def\veryraggedright{\raggedright} \fi
-\unexpanded\def\limitatetext
+\protected\def\limitatetext
{\bgroup % evt \setstrut
\forgetall % otherwise indentation and so
\let\limitatetext\firstofthreearguments
@@ -1285,7 +1290,7 @@
\ifdim\wd\scratchboxtwo<\wd\scratchboxone #1\else\unhbox\scratchboxone\fi
\egroup}
-\unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16
+\protected\def\limitatetext#1#2#3% \expanded added 2003/01/16
{\splitatcomma{#2}\leftlimit\rightlimit
\ifx\rightlimit\empty
\normallimitatetext {#1}\leftlimit {#3}%
@@ -1299,7 +1304,7 @@
%D \limitatefirstline{\input tufte\relax}{10cm}{\unknown}
%D \stoptyping
-\unexpanded\def\limitatefirstline#1#2#3%
+\protected\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut % \hpack
\setbox\scratchbox\hbox{\begstrut#1\endstrut}%
\ifdim\wd\scratchbox>#2\relax
@@ -1342,7 +1347,7 @@
% todo: provide variant with #1 picked up as box
-\unexpanded\def\processisolatedchars#1#2%
+\protected\def\processisolatedchars#1#2%
{\dontleavehmode
\begingroup
\setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}%
@@ -1355,7 +1360,7 @@
\relax
\endgroup}
-\unexpanded\def\processisolatedwords#1#2%
+\protected\def\processisolatedwords#1#2%
{\dontleavehmode
\begingroup
\setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}%
@@ -1370,7 +1375,7 @@
%D A variant:
-\unexpanded\def\applytocharacters#1%
+\protected\def\applytocharacters#1%
{\dontleavehmode
\dowithnextbox{\clf_applytobox
method {char}%
@@ -1380,7 +1385,7 @@
\relax}%
\hbox}
-\unexpanded\def\applytowords#1%
+\protected\def\applytowords#1%
{\dontleavehmode
\dowithnextbox{\clf_applytobox
method {word}%
@@ -1392,33 +1397,33 @@
%D The old call:
-\unexpanded\def\processwords#1%
+\protected\def\processwords#1%
{\processisolatedwords{#1}\processword}
\let\processword\relax
-\unexpanded\def\applytosplitstringchar#1#2%
+\protected\def\applytosplitstringchar#1#2%
{\dontleavehmode\clf_processsplit
data {#2}%
command {\csstring#1}%
method {char}%
\relax}
-\unexpanded\def\applytosplitstringword#1#2%
+\protected\def\applytosplitstringword#1#2%
{\dontleavehmode\clf_processsplit
data {#2}%
command {\csstring#1}%
method {word}%
\relax}
-\unexpanded\def\applytosplitstringline#1#2%
+\protected\def\applytosplitstringline#1#2%
{\dontleavehmode\clf_processsplit
data {#2}%
command {\csstring#1}%
method {line}%
\relax}
-\unexpanded\def\applytosplitstringcharspaced#1#2%
+\protected\def\applytosplitstringcharspaced#1#2%
{\dontleavehmode\clf_processsplit
data {#2}%
command {\csstring#1}%
@@ -1426,7 +1431,7 @@
spaced true%
\relax}
-\unexpanded\def\applytosplitstringwordspaced#1#2%
+\protected\def\applytosplitstringwordspaced#1#2%
{\dontleavehmode\clf_processsplit
data {#2}%
command {\csstring#1}%
@@ -1434,7 +1439,7 @@
spaced true%
\relax}
-\unexpanded\def\applytosplitstringlinespaced#1#2%
+\protected\def\applytosplitstringlinespaced#1#2%
{\dontleavehmode\clf_processsplit
data {#2}%
command {\csstring#1}%
@@ -1467,11 +1472,11 @@
%D would have ended up in the text. This macro can be useful when building
%D complicated menus, headers and footers and|/|or margin material.
-\unexpanded\def\sbox
+\protected\def\sbox
{\vpack\bgroup
\dowithnextboxcs\syst_boxes_sbox_finish\vbox}
-\unexpanded\def\syst_boxes_sbox_finish
+\protected\def\syst_boxes_sbox_finish
{\setbox\nextbox\hpack
{\strut % not needed
\dp\nextbox\zeropoint % not needed
@@ -1487,7 +1492,7 @@
%D xx \ruledhbox{\inlinedbox{\tfd test}} xx
%D \stoptyping
-\unexpanded\def\inlinedbox
+\protected\def\inlinedbox
{\bgroup
\dowithnextbox
{\setbox\nextbox\hpack
@@ -1505,7 +1510,7 @@
%D
%D This boxing macro limits the height and depth to those of a strut.
-\unexpanded\def\struttedbox
+\protected\def\struttedbox
{\hpack\bgroup
\dowithnextboxcs\syst_boxes_struttedbox_finish\hbox}
@@ -1521,7 +1526,7 @@
%D This macro compensates the difference between the topskip and strutheight. Watch
%D how we preserve the depth when it equals strutdepth.
-\unexpanded\def\topskippedbox
+\protected\def\topskippedbox
{\hpack\bgroup\dowithnextboxcs\syst_boxes_topskippedbox_finish\hbox}
\def\syst_boxes_topskippedbox_finish
@@ -1573,7 +1578,7 @@
%D The dimensions of the surrounding box are kept intact. This commands handles
%D positive and negative dimensions (which is why we need two boxes with rules).
-\unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen
+\protected\def\centeredbox#1#% height +/-dimen width +/-dimen
{\bgroup
\setbox\scratchboxone\vpack to \vsize
\bgroup
@@ -1613,7 +1618,7 @@
%D
%D Do you see what we call this one \type {next}?
-\unexpanded\def\centerednextbox#1#%
+\protected\def\centerednextbox#1#%
{\bgroup
\dowithnextbox
{\hsize\wd\nextbox
@@ -1634,7 +1639,7 @@
%D When omitted, the current \type {\hsize} and \type {\vsize} are used. Local
%D dimensions are supported.
-\unexpanded\def\centerbox#1#% optional height +/-dimen width +/-dimen
+\protected\def\centerbox#1#% optional height +/-dimen width +/-dimen
{\bgroup
\dowithnextbox
{\setlocalhsize
@@ -1664,7 +1669,7 @@
\newif\ifstretchrigidcolumns
\newif\iftightrigidcolumns % if true: just a vbox, no depth/noflines/gridsnap corrrections
-\unexpanded\def\setrigidcolumnhsize#1#2#3% todo: \dimexpr
+\protected\def\setrigidcolumnhsize#1#2#3% todo: \dimexpr
{\xdef\savedrigidhsize{\the\hsize}%
\hsize#1\relax
\global\chardef\rigidcolumns#3\relax
@@ -1685,7 +1690,7 @@
\let\rigidcolumnlines\!!zerocount
-\unexpanded\def\rigidcolumnbalance#1%
+\protected\def\rigidcolumnbalance#1%
{\ifnum\rigidcolumns=1 % tzt ook h/d correctie
\ifinner\ifhmode\box\else\unvbox\fi\else\unvbox\fi#1\relax
\else
@@ -1776,7 +1781,7 @@
%D Create line and fake height of paragraph by messign with heights: a nice hack by
%D DEK himself.
-%\unexpanded\def\setvboxtohbox
+%\protected\def\setvboxtohbox
% {\bgroup
% \ifdim\baselineskip<16pt \relax
% \scratchdimen\baselineskip
@@ -1790,13 +1795,13 @@
% \xdef\vboxtohboxfactor{\withoutpt\the\scratchdimen}%
% \egroup}
%
-% \unexpanded\def\startvboxtohbox
+% \protected\def\startvboxtohbox
% {\bgroup
% \setvboxtohbox
% \setbox\scratchbox\hbox\bgroup}
%
-% \unexpanded\def\stopvboxtohbox
-% {\ifcase\vboxtohboxslack\else\hskip\zeropoint\!!minus\vboxtohboxslack\fi
+% \protected\def\stopvboxtohbox
+% {\ifcase\vboxtohboxslack\else\hskip\zeropoint\s!minus\vboxtohboxslack\fi
% \egroup
% \dp\scratchbox\zeropoint
% \ht\scratchbox\vboxtohboxfactor\wd\scratchbox
@@ -1810,17 +1815,17 @@
%newbox\d_syst_boxes_vboxtohbox
\newbox\d_syst_boxes_separator
-\unexpanded\def\startvboxtohboxseparator
+\protected\def\startvboxtohboxseparator
{\setbox\d_syst_boxes_separator\hbox attr \vboxtohboxseparatorattribute\plusone\bgroup}
-\unexpanded\def\stopvboxtohboxseparator
+\protected\def\stopvboxtohboxseparator
{\egroup}
-\unexpanded\def\startvboxtohbox
+\protected\def\startvboxtohbox
{\begingroup
\setbox\scratchbox\hbox\bgroup}
-\unexpanded\def\stopvboxtohbox
+\protected\def\stopvboxtohbox
{\ifvoid\d_syst_boxes_separator
\hskip\zeropoint\ifcase\vboxtohboxslack\else\s!minus\vboxtohboxslack\fi % we really need a skip
\else
@@ -1833,12 +1838,12 @@
% A possible reconstruction:
-\unexpanded\def\convertvboxtohbox
+\protected\def\convertvboxtohbox
{\makehboxofhboxes
\setbox\scratchboxone\hpack{\unhbox\scratchboxone\removehboxes}% \hpack
\noindent\unhbox\scratchboxone\par}
-\unexpanded\def\makehboxofhboxes
+\protected\def\makehboxofhboxes
{\setbox\scratchboxone\emptyhbox
\loop % \doloop { .. \exitloop .. }
\setbox\scratchboxtwo\lastbox
@@ -1846,7 +1851,7 @@
\setbox\scratchboxone\hpack{\box\scratchboxtwo\unhbox\scratchboxone}%
\repeat}
-\unexpanded\def\removehboxes
+\protected\def\removehboxes
{\setbox\scratchboxone\lastbox
\ifhbox\scratchboxone
{\removehboxes}\unhbox\scratchboxone
@@ -1854,16 +1859,16 @@
% And one special for notes:
-% \unexpanded\def\starthboxestohbox
+% \protected\def\starthboxestohbox
% {\bgroup
% \beginofshapebox}
%
-% \unexpanded\def\stophboxestohbox
+% \protected\def\stophboxestohbox
% {\endofshapebox
% \doreshapebox
% {\hbox\bgroup
% \unhbox\shapebox
-% \ifcase\hboxestohboxslack\else\hskip\zeropoint\!!minus\hboxestohboxslack\fi
+% \ifcase\hboxestohboxslack\else\hskip\zeropoint\s!minus\hboxestohboxslack\fi
% \egroup}%
% \donothing
% \donothing
@@ -1875,11 +1880,11 @@
% More modern:
-\unexpanded\def\starthboxestohbox
+\protected\def\starthboxestohbox
{\bgroup
\setbox\scratchbox\vbox\bgroup}
-\unexpanded\def\stophboxestohbox
+\protected\def\stophboxestohbox
{\egroup
\clf_vboxlisttohbox\scratchbox\nextbox\dimexpr\hboxestohboxslack\relax
\dontleavehmode
@@ -1899,7 +1904,7 @@
\newdimen \lasthhboxwidth
\newskip \hhboxindent
-\unexpanded\def\unhhbox#1\with#2%
+\protected\def\unhhbox#1\with#2%
{\bgroup
\nopenalties
\dontcomplain
@@ -1930,7 +1935,7 @@
\unhbox1
\egroup}
-\unexpanded\def\hboxofvbox
+\protected\def\hboxofvbox
{\bgroup
\afterassignment\dohboxofvbox
\scratchcounter=}
@@ -1973,7 +1978,7 @@
%D dimension of this box suggest some content, the resulting box is unboxed and
%D surrounded by the first two arguments, else the third arguments is executed.
-\unexpanded\def\doifcontent#1#2#3%
+\protected\def\doifcontent#1#2#3%
{\dowithnextbox
{\ifhbox\nextbox
\ifdim\wd\nextbox>\zeropoint
@@ -2019,7 +2024,7 @@
% \newbox\processbox % public : this is the one where \nextbox's end up in
%
-% \unexpanded\def\processboxes#1%
+% \protected\def\processboxes#1%
% {\bgroup
% \def\syst_boxes_process_indeed{#1}% #1 can be redefined halfway
% \setbox\processbox\emptybox
@@ -2042,7 +2047,7 @@
% \afterassignment\syst_boxes_process
% \let\nexttoken}
%
-% \unexpanded\def\syst_boxes_process_nop
+% \protected\def\syst_boxes_process_nop
% {\removeunwantedspaces
% \box\processbox
% \nexttoken % messy as we are still in the group
@@ -2050,7 +2055,7 @@
\newbox\processbox % public : this is the one where \nextbox's end up in
-\unexpanded\def\processboxes#1%
+\protected\def\processboxes#1%
{\bgroup
\def\syst_boxes_process_indeed{#1}% #1 can be redefined halfway
\setbox\processbox\emptybox
@@ -2064,7 +2069,7 @@
\syst_boxes_process_indeed % takes \nextbox makes \processbox
\doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop}
-\unexpanded\def\syst_boxes_process_nop
+\protected\def\syst_boxes_process_nop
{\removeunwantedspaces
\box\processbox
\egroup}
@@ -2124,7 +2129,7 @@
\kern-\scratchwidth
\hpack to \scratchwidth{\hss\box\nextbox \hss}}}
-\unexpanded\def\startoverlay
+\protected\def\startoverlay
{\bgroup
\let\stopoverlay\egroup
\processboxes\syst_boxes_overlay_process}
@@ -2142,7 +2147,7 @@
%D
%D returns an empty box with the dimensions of the box specified, here being zero.
-\unexpanded\def\fakebox
+\protected\def\fakebox
{\bgroup
\afterassignment\syst_boxes_fakebox_finish\scratchcounter}
@@ -2171,13 +2176,13 @@
\def\syst_boxes_lrc_process#1{\bgroup\forgetall\let\\\endgraf#1\let\next}
-\unexpanded\def\lbox#1#{\vbox#1\syst_boxes_lrc_process\raggedleft }
-\unexpanded\def\cbox#1#{\vbox#1\syst_boxes_lrc_process\raggedcenter}
-\unexpanded\def\rbox#1#{\vbox#1\syst_boxes_lrc_process\raggedright }
+\protected\def\lbox#1#{\vbox#1\syst_boxes_lrc_process\raggedleft }
+\protected\def\cbox#1#{\vbox#1\syst_boxes_lrc_process\raggedcenter}
+\protected\def\rbox#1#{\vbox#1\syst_boxes_lrc_process\raggedright }
-\unexpanded\def\ltop#1#{\vtop#1\syst_boxes_lrc_process\raggedleft }
-\unexpanded\def\ctop#1#{\vtop#1\syst_boxes_lrc_process\raggedcenter}
-\unexpanded\def\rtop#1#{\vtop#1\syst_boxes_lrc_process\raggedright }
+\protected\def\ltop#1#{\vtop#1\syst_boxes_lrc_process\raggedleft }
+\protected\def\ctop#1#{\vtop#1\syst_boxes_lrc_process\raggedcenter}
+\protected\def\rtop#1#{\vtop#1\syst_boxes_lrc_process\raggedright }
%D The alternatives \type {\tbox} and \type {\bbox} can be used to properly align
%D boxes, like in:
@@ -2199,8 +2204,8 @@
%D
%D \getbuffer
-\unexpanded\def\tbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox}
-\unexpanded\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox}
+\protected\def\tbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox}
+\protected\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox}
\def\syst_boxes_tbox_finish
{\scratchdepth\dimexpr\ht\nextbox+\dp\nextbox-\ht\strutbox\relax
@@ -2231,9 +2236,9 @@
\def\dodomhbox{\hpack to \hsize{\hss\box\nextbox\hss}}
\def\dodorhbox{\hpack to \hsize{\hss\box\nextbox }}
-\unexpanded\def\lhbox{\dowithnextboxcs\dodolhbox\hbox}
-\unexpanded\def\mhbox{\dowithnextboxcs\dodomhbox\hbox}
-\unexpanded\def\rhbox{\dowithnextboxcs\dodorhbox\hbox}
+\protected\def\lhbox{\dowithnextboxcs\dodolhbox\hbox}
+\protected\def\mhbox{\dowithnextboxcs\dodomhbox\hbox}
+\protected\def\rhbox{\dowithnextboxcs\dodorhbox\hbox}
\let\lefthbox \lhbox
\let\midhbox \mhbox
@@ -2254,15 +2259,15 @@
\newdimen\sizeofbox
-\unexpanded\def\boxofsize#1%
+\protected\def\boxofsize#1%
{\bgroup
\sizeofbox\zeropoint
\scratchdimen\zeropoint
\def\docommand
{\advance\sizeofbox\scratchdimen
- \futurelet\next\dodocommand}%
+ \futurelet\nexttoken\dodocommand}%
\def\dodocommand
- {\ifx\next\bgroup
+ {\ifx\nexttoken\bgroup
\expanded{\egroup#1 to \the\sizeofbox}%
\else
\expandafter\afterassignment\expandafter\docommand\expandafter\scratchdimen
@@ -2276,7 +2281,7 @@
% \limitvbox
% \limithbox
-\unexpanded\def\limitatelines#1#2% size sentinel
+\protected\def\limitatelines#1#2% size sentinel
{\dowithnextbox
{\scratchdimen#1\hsize
\ifdim\wd\nextbox>\scratchdimen
@@ -2287,7 +2292,7 @@
\unhbox\nextbox}
\hbox}
-\unexpanded\def\fittoptobaselinegrid % weg hier
+\protected\def\fittoptobaselinegrid % weg hier
{\dowithnextbox
{\bgroup
\par
@@ -2316,7 +2321,7 @@
\setbox\fakedboxcursor\hpack
{\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint}
-\unexpanded\def\boxcursor % overloaded in core-vis
+\protected\def\boxcursor % overloaded in core-vis
{\iftraceboxplacement
\bgroup
\scratchdimen2\onepoint
@@ -2333,21 +2338,21 @@
\copy\fakedboxcursor
\fi}
-\unexpanded\def\placedbox
+\protected\def\placedbox
{\iftraceboxplacement\ruledhbox\else\hbox\fi}
\newdimen\boxoffset
\newdimen\boxhdisplacement
\newdimen\boxvdisplacement
-\unexpanded\def\rightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbox_finish \placedbox}
-\unexpanded\def\leftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbox_finish \placedbox}
-\unexpanded\def\topbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_topbox_finish \placedbox}
-\unexpanded\def\bottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_bottombox_finish \placedbox}
-\unexpanded\def\lefttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_lefttopbox_finish \placedbox}
-\unexpanded\def\righttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_righttopbox_finish \placedbox}
-\unexpanded\def\leftbottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox}
-\unexpanded\def\rightbottombox{\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox}
+\protected\def\rightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbox_finish \placedbox}
+\protected\def\leftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbox_finish \placedbox}
+\protected\def\topbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_topbox_finish \placedbox}
+\protected\def\bottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_bottombox_finish \placedbox}
+\protected\def\lefttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_lefttopbox_finish \placedbox}
+\protected\def\righttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_righttopbox_finish \placedbox}
+\protected\def\leftbottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox}
+\protected\def\rightbottombox{\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox}
\let\topleftbox \lefttopbox
\let\toprightbox \righttopbox
@@ -2413,10 +2418,10 @@
\boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox
\egroup}
-\unexpanded\def\middlebox {\hpack\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox}
-\unexpanded\def\baselinemiddlebox{\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinemiddlebox_finish\placedbox}
-\unexpanded\def\baselineleftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox}
-\unexpanded\def\baselinerightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox}
+\protected\def\middlebox {\hpack\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox}
+\protected\def\baselinemiddlebox{\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinemiddlebox_finish\placedbox}
+\protected\def\baselineleftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox}
+\protected\def\baselinerightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox}
\def\syst_boxes_middlebox_finish
{\global\boxhdisplacement-.5\wd\nextbox
@@ -2450,7 +2455,7 @@
%D
%D Experimental, not yet frozen:
-\unexpanded\def\lrtbbox#1#2#3#4% l r t b
+\protected\def\lrtbbox#1#2#3#4% l r t b
{\bgroup
\dowithnextboxcontent
{\advance\hsize-#1\advance\hsize-#2\relax
@@ -2463,7 +2468,7 @@
%D
%D See core-tbl.tex for an example of its usage:
-\unexpanded\def\toplinebox
+\protected\def\toplinebox
{\dowithnextboxcs\syst_boxes_toplinebox_finish\tbox}
\def\syst_boxes_toplinebox_finish
@@ -2502,20 +2507,20 @@
\installcorenamespace {stackbox}
\installcorenamespace {stacklst}
-\unexpanded\def\setstackbox#1#2%
+\protected\def\setstackbox#1#2%
{\ifcsname\??stackbox#1:#2\endcsname\else
\expandafter\newbox\csname\??stackbox#1:#2\endcsname
\fi
\global\setbox\csname\??stackbox#1:#2\endcsname\vbox}
-\unexpanded\def\initializeboxstack#1%
+\protected\def\initializeboxstack#1%
{\def\docommand##1{\setstackbox{#1}{##1}{}}%
\ifcsname\??stacklst#1\endcsname
\expandafter\processcommacommand\expandafter[\lastnamedcs]\docommand
\fi
\letgvalueempty{\??stacklst#1}}
-\unexpanded\def\savebox#1#2% stack name
+\protected\def\savebox#1#2% stack name
{% beware, \setxvalue defines the cs beforehand so we cannot use the
% test inside the { }
\ifcsname\??stacklst#1\endcsname
@@ -2526,27 +2531,27 @@
\fi
\setstackbox{#1}{#2}}
-\unexpanded\def\flushbox#1#2% unwrapped
+\protected\def\flushbox#1#2% unwrapped
{\ifcsname\??stackbox#1:#2\endcsname
\box\lastnamedcs
\else
\emptybox
\fi}
-\unexpanded\def\restorebox#1#2% unwrapped
+\protected\def\restorebox#1#2% unwrapped
{\ifcsname\??stackbox#1:#2\endcsname
\copy\lastnamedcs
\else
\emptybox
\fi}
-\unexpanded\def\foundbox#1#2% wrapped
+\protected\def\foundbox#1#2% wrapped
{\vpack
{\ifcsname\??stackbox#1:#2\endcsname
\copy\lastnamedcs
\fi}}
-\unexpanded\def\doifelsebox#1#2%
+\protected\def\doifelsebox#1#2%
{\ifcsname\??stackbox#1:#2\endcsname
\ifvoid\lastnamedcs
\doubleexpandafter\secondoftwoarguments
@@ -2566,11 +2571,11 @@
\newcount\c_syst_boxes_stack
\let \b_syst_boxes_stack\relax
-\unexpanded\def\syst_boxes_stack_allocate
+\protected\def\syst_boxes_stack_allocate
{\newbox\b_syst_boxes_stack
\expandafter\let\csname\??boxstack\number\c_syst_boxes_stack\endcsname\b_syst_boxes_stack}
-\unexpanded\def\syst_boxes_push#1#2%
+\protected\def\syst_boxes_push#1#2%
{\global\advance\c_syst_boxes_stack\plusone
\expandafter\let\expandafter\b_syst_boxes_stack\csname\??boxstack\number\c_syst_boxes_stack\endcsname
\ifx\b_syst_boxes_stack\relax % cheaper then csname check as in most cases it's defined
@@ -2578,15 +2583,15 @@
\fi
#1\setbox\b_syst_boxes_stack\box#2\relax}
-\unexpanded\def\syst_boxes_pop#1#2%
+\protected\def\syst_boxes_pop#1#2%
{#1\setbox#2\box\csname\??boxstack\number\c_syst_boxes_stack\endcsname
\global\advance\c_syst_boxes_stack\minusone}
-\unexpanded\def\localpushbox {\syst_boxes_push\relax}
-\unexpanded\def\localpopbox {\syst_boxes_pop \relax}
+\protected\def\localpushbox {\syst_boxes_push\relax}
+\protected\def\localpopbox {\syst_boxes_pop \relax}
-\unexpanded\def\globalpushbox{\syst_boxes_push\global}
-\unexpanded\def\globalpopbox {\syst_boxes_pop \global}
+\protected\def\globalpushbox{\syst_boxes_push\global}
+\protected\def\globalpopbox {\syst_boxes_pop \global}
%D And here is a more modern one (not yet in i-*):
%D
@@ -2604,15 +2609,15 @@
%D \resetboxesincache{foo}
%D \stoptyping
-\unexpanded\def\putboxincache #1#2#3{\clf_putboxincache {#1}{#2}#3\relax}
-\unexpanded\def\getboxfromcache #1#2#3{\clf_getboxfromcache {#1}{#2}#3\relax}
-\unexpanded\def\doifelseboxincache #1#2{\clf_doifelseboxincache {#1}{#2}}
-\unexpanded\def\copyboxfromcache #1#2#3{\clf_copyboxfromcache {#1}{#2}#3\relax}
-\unexpanded\def\directboxfromcache #1#2{\clf_directboxfromcache {#1}{#2}}
-\unexpanded\def\directcopyboxfromcache#1#2{\clf_directcopyboxfromcache{#1}{#2}}
-\unexpanded\def\resetboxesincache #1{\clf_resetboxesincache {#1}}
+\protected\def\putboxincache #1#2#3{\clf_putboxincache {#1}{#2}#3\relax}
+\protected\def\getboxfromcache #1#2#3{\clf_getboxfromcache {#1}{#2}#3\relax}
+\protected\def\doifelseboxincache #1#2{\clf_doifelseboxincache {#1}{#2}}
+\protected\def\copyboxfromcache #1#2#3{\clf_copyboxfromcache {#1}{#2}#3\relax}
+\protected\def\directboxfromcache #1#2{\clf_directboxfromcache {#1}{#2}}
+\protected\def\directcopyboxfromcache#1#2{\clf_directcopyboxfromcache{#1}{#2}}
+\protected\def\resetboxesincache #1{\clf_resetboxesincache {#1}}
-\unexpanded\def\putnextboxincache#1#2%
+\protected\def\putnextboxincache#1#2%
{\dowithnextbox{\putboxincache{#1}{#2}\nextbox}}
%D \macros
@@ -2621,21 +2626,21 @@
%D While \type {\removedepth} removes the preceding depth, \type {\obeydepth} makes
%D sure we have depth. Both macros leave the \type {\prevdepth} untouched.
-\unexpanded\def\removedepth
+\protected\def\removedepth
{\ifvmode
\ifdim\prevdepth>\zeropoint
\kern-\prevdepth
\fi
\fi}
-\unexpanded\def\obeydepth
+\protected\def\obeydepth
{\par % watch out for changes in math formulas
\ifvmode\ifdim\prevdepth<\zeropoint\else\ifdim\prevdepth<\strutdp
\kern\dimexpr\strutdp-\prevdepth\relax
\prevdepth\strutdp
\fi\fi\fi}
-\unexpanded\def\undepthed
+\protected\def\undepthed
{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\hbox}
%D \macros
@@ -2643,10 +2648,10 @@
%D
%D A funny (but rather stupid) one, plus a redefinition.
-\unexpanded\def\removebottomthings
+\protected\def\removebottomthings
{\dorecurse\plusfive{\unskip\unkern\unpenalty}}
-\unexpanded\def\removelastskip % \ifvmode the plain tex one \fi
+\protected\def\removelastskip % \ifvmode the plain tex one \fi
{\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi}
%D \macros
@@ -2655,7 +2660,7 @@
%D This macro sets the dimensions of a box to those of a strut. Sort of obsolete so
%D it will go away.
-\unexpanded\def\makestrutofbox % not used
+\protected\def\makestrutofbox % not used
{\afterassignment\syst_boxes_makestrutofbox\c_boxes_register}
\def\syst_boxes_makestrutofbox
@@ -2674,8 +2679,8 @@
%D \hsmash{\raisebox{100pt}\hbox{test}}
%D \stoptyping
-\unexpanded\def\raisebox#1{\bgroup\afterassignment\syst_boxes_raise_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted
-\unexpanded\def\lowerbox#1{\bgroup\afterassignment\syst_boxes_lower_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted
+\protected\def\raisebox#1{\bgroup\afterassignment\syst_boxes_raise_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted
+\protected\def\lowerbox#1{\bgroup\afterassignment\syst_boxes_lower_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted
\def\syst_boxes_raise_indeed{\dowithnextboxcs\syst_boxes_raise_finish}
\def\syst_boxes_lower_indeed{\dowithnextboxcs\syst_boxes_lower_finish}
@@ -2696,7 +2701,7 @@
% vcenter in text, we kunnen vcenter overloaden
-\unexpanded\def\halfwaybox
+\protected\def\halfwaybox
{\hpack\bgroup
\dowithnextboxcs\syst_boxes_halfwaybox_finish\hbox}
@@ -2705,7 +2710,7 @@
\lower.5\ht\nextbox\box\nextbox
\egroup}
-\unexpanded\def\depthonlybox
+\protected\def\depthonlybox
{\tpack\bgroup
\dowithnextboxcs\syst_boxes_depthonlybox_finish\vbox}
@@ -2728,7 +2733,9 @@
%D
%D Also new: tex mode \type {\vcenter}.
-\unexpanded\def\vcenter
+% not in lmtxmode:
+
+\protected\def\vcenter
{\vbox\bgroup
\dowithnextboxcs\syst_boxes_vcenter_finish\vbox}
@@ -2748,7 +2755,7 @@
%D
%D A not so well unhboxable box can be made with:
-\unexpanded\def\frozenhbox
+\protected\def\frozenhbox
{\hpack\bgroup
\dowithnextboxcs\syst_boxes_frozenhbox_finish\hbox}
@@ -2764,11 +2771,11 @@
\installcorenamespace {box_x}
\installcorenamespace {box_y}
-\unexpanded\def\setboxllx #1#2{\expandafter\edef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
-\unexpanded\def\setboxlly #1#2{\expandafter\edef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
+\protected\def\setboxllx #1#2{\expandafter\edef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
+\protected\def\setboxlly #1#2{\expandafter\edef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
-\unexpanded\def\gsetboxllx#1#2{\expandafter\xdef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
-\unexpanded\def\gsetboxlly#1#2{\expandafter\xdef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
+\protected\def\gsetboxllx#1#2{\expandafter\xdef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
+\protected\def\gsetboxlly#1#2{\expandafter\xdef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
%def\getboxllx#1{\ifcsname\??box_x\number#1\endcsname\csname\??box_x\number#1\endcsname\else\zeropoint\fi}
%def\getboxlly#1{\ifcsname\??box_y\number#1\endcsname\csname\??box_y\number#1\endcsname\else\zeropoint\fi}
@@ -2791,7 +2798,7 @@
%D \shownextbox\vbox{\setupwhitespace[big]test\endgraf\thinrule}
%D \stoptyping
-\unexpanded\def\shownextbox % seldom used
+\protected\def\shownextbox % seldom used
{\dowithnextbox
{\bgroup
\showboxbreadth\maxdimen
@@ -2803,7 +2810,7 @@
\interactionmode\scratchcounter
\egroup}}
-\unexpanded\def\spreadhbox#1% rebuilds \hbox{}
+\protected\def\spreadhbox#1% rebuilds \hbox{}
{\bgroup
\ifhbox#1\relax
\setbox\scratchboxtwo\emptybox
@@ -2835,7 +2842,7 @@
%D \minimalhbox 100pt {test}
%D \stoptyping
-\unexpanded\def\minimalhbox#1#%
+\protected\def\minimalhbox#1#%
{\dowithnextbox
{\bgroup
\setbox\scratchbox\hpack#1{\hss}%
@@ -2846,7 +2853,7 @@
%D A bit dirty:
-\unexpanded\def\nodestostring#1#2% more tolerant for #2=\cs
+\protected\def\nodestostring#1#2% more tolerant for #2=\cs
{\begingroup
\setbox\nextbox\hbox{#2}%
\normalexpanded{\endgroup\edef\noexpand#1{\clf_boxtostring\nextbox}}}
@@ -2877,7 +2884,7 @@
\let\getnaturalwd\clf_getnaturalwd % no intermediate
\let\setnaturalwd\clf_setnaturalwd % no intermediate
-\unexpanded\def\doifelserighttoleftinbox{\clf_doifelserighttoleftinbox}
+\protected\def\doifelserighttoleftinbox{\clf_doifelserighttoleftinbox}
\let\doifrighttoleftinboxelse\doifelserighttoleftinbox
@@ -2886,23 +2893,23 @@
\definesystemattribute [runningtext] [public]
%unexpanded\def\runninghbox{\hbox attr \runningtextattribute \plusone} % not yet in i-*
-\unexpanded\def\runninghbox{\hbox attr \runningtextattribute \fontid\font} % not yet in i-*
+\protected\def\runninghbox{\hbox attr \runningtextattribute \fontid\font} % not yet in i-*
%D To complement lua (yet undocumented):
-\unexpanded\def\beginhbox{\hbox\bgroup} \let\endhbox\egroup
-\unexpanded\def\beginvbox{\vbox\bgroup} \let\endvbox\egroup
-\unexpanded\def\beginvtop{\vtop\bgroup} \let\endvtop\egroup
+\protected\def\beginhbox{\hbox\bgroup} \let\endhbox\egroup
+\protected\def\beginvbox{\vbox\bgroup} \let\endvbox\egroup
+\protected\def\beginvtop{\vtop\bgroup} \let\endvtop\egroup
-\unexpanded\def\sethboxregister#1{\setbox#1\hbox}
-\unexpanded\def\setvboxregister#1{\setbox#1\vbox}
-\unexpanded\def\setvtopregister#1{\setbox#1\vtop}
+\protected\def\sethboxregister#1{\setbox#1\hbox}
+\protected\def\setvboxregister#1{\setbox#1\vbox}
+\protected\def\setvtopregister#1{\setbox#1\vtop}
-\unexpanded\def\flushboxregister#1{\box\numexpr#1\relax}
+\protected\def\flushboxregister#1{\box\numexpr#1\relax}
-\unexpanded\def\starthboxregister#1{\setbox#1\hbox\bgroup} \let\stophboxregister\egroup
-\unexpanded\def\startvboxregister#1{\setbox#1\vbox\bgroup} \let\stopvboxregister\egroup
-\unexpanded\def\startvtopregister#1{\setbox#1\vtop\bgroup} \let\stopvtopregister\egroup
+\protected\def\starthboxregister#1{\setbox#1\hbox\bgroup} \let\stophboxregister\egroup
+\protected\def\startvboxregister#1{\setbox#1\vbox\bgroup} \let\stopvboxregister\egroup
+\protected\def\startvtopregister#1{\setbox#1\vtop\bgroup} \let\stopvtopregister\egroup
%D For whatever third party package needs it:
%D
@@ -2918,7 +2925,7 @@
\installcorenamespace{localbox}
-\unexpanded\def\newlocalbox#1%
+\protected\def\newlocalbox#1%
{\expandafter\let\expandafter#1\csname\??localbox\string#1\endcsname
\ifx#1\relax
\syst_aux_new_localbox#1%
@@ -2930,26 +2937,26 @@
%D Who knows when this comes in handy:
-\unexpanded\def\lastlinewidth{\dimexpr\clf_lastlinewidth\scaledpoint\relax}
+\protected\def\lastlinewidth{\dimexpr\clf_lastlinewidth\scaledpoint\relax}
%D Keep as reference:
-% \unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox}
-% \unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop}
+% \protected\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox}
+% \protected\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop}
%D This one keeps dimensions and sets the shift field (and so it's more for testing
%D than for real usage):
-\unexpanded\def\shiftbox {\clf_shiftbox}
-\unexpanded\def\vpackbox {\clf_vpackbox}
-\unexpanded\def\hpackbox {\clf_hpackbox}
-\unexpanded\def\vpackedbox{\clf_vpackedbox}
-\unexpanded\def\hpackedbox{\clf_hpackedbox}
+\protected\def\shiftbox {\clf_shiftbox}
+\protected\def\vpackbox {\clf_vpackbox}
+\protected\def\hpackbox {\clf_hpackbox}
+\protected\def\vpackedbox{\clf_vpackedbox}
+\protected\def\hpackedbox{\clf_hpackedbox}
%D This one has been moved from a 2 decade old file. It makes something boxed
%D sit on the baseline.
-\unexpanded\def\linebox
+\protected\def\linebox
{\hpack\bgroup\dowithnextbox
{\scratchdimen\dimexpr\dimexpr\htdp\nextbox-\lineheight\relax/2+\dp\strutbox\relax
\setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}%
@@ -3000,10 +3007,10 @@
%
% \unprotect
%
-% \unexpanded\def\withwordsinstring#1#2% command str
+% \protected\def\withwordsinstring#1#2% command str
% {\ctxcommand{withwords(\!!bs#1\!!es,\!!bs#2\!!es)}}
%
-% \unexpanded\def\withwordsinfile#1#2% command name
+% \protected\def\withwordsinfile#1#2% command name
% {\ctxcommand{withwords(\!!bs#1\!!es,io.loaddata(resolvers.findfile("#2")))}}
%
% \protect
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkxl b/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkxl
deleted file mode 100644
index e6ab96e8929..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkxl
+++ /dev/null
@@ -1,2952 +0,0 @@
-%D \module
-%D [ file=supp-box,
-%D version=1995.10.10,
-%D title=\CONTEXT\ Support Macros,
-%D subtitle=Boxes,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Support Macros / Boxes}
-
-\unprotect
-
-\registerctxluafile{supp-box}{optimize}
-
-% This file is partially cleaned up.
-
-%D First some defaults:
-
-\fixupboxesmode\plusone
-
-%D And some dimensions:
-
-\newdimen\givenwidth
-\newdimen\givenheight
-\newdimen\givendepth
-
-%D \macros
-%D {dontcomplain}
-%D
-%D The next macro suppresses over- and underfull messages which often makes sense
-%D when we deal with boxes.
-
-\unexpanded\def\dontcomplain
- {\hbadness\plustenthousand
- \vbadness\plustenthousand
- \hfuzz \maxdimen
- \vfuzz \maxdimen}
-
-%D This module implements some box manipulation macros. Some are quite simple, some
-%D are more advanced and when understood well, all can be of use.
-%D
-%D \macros
-%D {strutdp,strutht,strutwd}
-%D
-%D The next shortcuts save memory and keying. The width is normally zero points (if
-%D not, you're in trouble). These shortcuts can be used like a dimension, opposite
-%D to the core macros \type {\strutdepth} and alike, which are values.
-
-\def\strutdp {\dp\strutbox}
-\def\strutht {\ht\strutbox}
-\def\strutwd {\wd\strutbox}
-\def\struthtdp{\htdp\strutbox}
-\def\strutgap {\dimexpr\ht\strutbox-\dp\strutbox\relax}
-
-%D \macros
-%D {voidbox,nextbox}
-%D
-%D Let's start with an easy one. The next macro hides the ugly \type {@} in \type
-%D {\voidb@x}.
-
-\ifdefined\voidbox \else \newbox\voidbox \fi
-\ifdefined\nextbox \else \newbox\nextbox \fi
-
-%D \macros
-%D {nextdepth}
-%D
-%D Let's start with a rather simple declaration. Sometimes we need to save the \TEX\
-%D \DIMENSION\ \type{\prevdepth} and append it later on. The name \type {\nextdepth}
-%D suits this purpose well.
-
-\newdimen\nextdepth
-
-%D \macros
-%D {smashbox, smashedbox}
-%D
-%D Smashing is introduced in \PLAIN\ \TEX, and stands for reducing the dimensions of
-%D a box to zero. The most resolute one is presented first.
-
-\unexpanded\def\smashbox#1%
- {\wd#1\zeropoint
- \ht#1\zeropoint
- \dp#1\zeropoint}
-
-\unexpanded\def\smashboxed#1%
- {\wd#1\zeropoint
- \ht#1\zeropoint
- \dp#1\zeropoint
- \box#1\relax}
-
-%D \macros
-%D {hsmashbox,vsmashbox}
-%D
-%D Smashing can be used for overlaying boxes. Depending on the mode, horizontal or
-%D vertical, one can use:
-
-\unexpanded\def\hsmashbox#1%
- {\wd#1\zeropoint}
-
-\unexpanded\def\vsmashbox#1%
- {\ht#1\zeropoint
- \dp#1\zeropoint}
-
-%D The next implementation is less sensitive for spurious spaces.
-
-\newcount\c_boxes_register
-
-\unexpanded\def\smashbox
- {\afterassignment\syst_boxes_smash_boxes_register\c_boxes_register}
-
-\def\syst_boxes_smash_boxes_register
- {\wd\c_boxes_register\zeropoint
- \ht\c_boxes_register\zeropoint
- \dp\c_boxes_register\zeropoint}
-
-\unexpanded\def\hsmashbox
- {\afterassignment\syst_boxes_hsmashed_boxes_register\c_boxes_register}
-
-\def\syst_boxes_hsmashed_boxes_register
- {\wd\c_boxes_register\zeropoint}
-
-\unexpanded\def\vsmashbox
- {\afterassignment\syst_boxes_vsmashed_boxes_register\c_boxes_register}
-
-\def\syst_boxes_vsmashed_boxes_register
- {\ht\c_boxes_register\zeropoint
- \dp\c_boxes_register\zeropoint}
-
-\unexpanded\def\smashedbox
- {\afterassignment\syst_boxes_smashed_boxes_register\c_boxes_register}
-
-\unexpanded\def\syst_boxes_smashed_boxes_register
- {\wd\c_boxes_register\zeropoint
- \ht\c_boxes_register\zeropoint
- \dp\c_boxes_register\zeropoint
- \box\c_boxes_register}
-
-%D \macros
-%D {hsmash,vsmash,
-%D hsmashed,vsmashed}
-%D
-%D While the previous macros expected a \BOX, the next act on a content. They are
-%D some subtle differences betreen the smash and smashed alternatives. The later
-%D ones reduce all dimensions to zero.
-
-\unexpanded\def\hsmash {\bgroup\dowithnextboxcs\syst_boxes_hsmashed_nextbox\hbox}
-\unexpanded\def\vsmash {\bgroup\dowithnextboxcs\syst_boxes_vsmashed_nextbox\vbox}
-\unexpanded\def\hsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \hbox}
-\unexpanded\def\vsmashed{\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox \vbox}
-
-\unexpanded\def\syst_boxes_hsmashed_nextbox
- {\wd\nextbox\zeropoint
- \box\nextbox
- \egroup}
-
-\unexpanded\def\syst_boxes_vsmashed_nextbox
- {\ht\nextbox\zeropoint
- \dp\nextbox\zeropoint
- \box\nextbox
- \egroup}
-
-\unexpanded\def\syst_boxes_smashed_nextbox
- {\ht\nextbox\zeropoint
- \dp\nextbox\zeropoint
- \wd\nextbox\zeropoint
- \box\nextbox
- \egroup}
-
-%D \macros
-%D {smashedhbox,smashedvbox}
-%D
-%D Also handy (all dimensions zeroed):
-%D
-%D \starttyping
-%D \smashedhbox to ... {...}
-%D \smashedvbox to ... {...}
-%D \stoptyping
-
-\unexpanded\def\smashedhbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\hbox}
-\unexpanded\def\smashedvbox{\vpack\bgroup\dowithnextboxcs\syst_boxes_smashed_nextbox\vbox}
-
-%D First we define a helper. We use a \LUATEX\ feature in order to avoid
-%D mathpalettes.
-
-\newcount\c_boxes_math_style
-
-\unexpanded\def\syst_boxes_math_set_nextbox#1%
- {\c_boxes_math_style\mathstyle
- \setbox\nextbox\hbox{\normalstartimath\mathsurround\zeropoint\triggermathstyle\c_boxes_math_style{#1}\normalstopimath}}
-
-%D \macros
-%D {smash}
-%D
-%D This smash alternative takes an optional arg [whdtb] as well as is potentially
-%D catcode safer. It is needed by the math module (although the \type {\leavevmode}
-%D is not added here).
-
-\unexpanded\def\smash
- {\begingroup
- \futureexpandis[\syst_boxes_smash_yes\syst_boxes_smash_nop}
-
-\def\syst_boxes_smash_nop
- {\edef\m_boxes_smash_options{hd}%
- \futurelet\nexttoken\syst_boxes_smash_indeed}
-
-\def\syst_boxes_smash_yes[#1]%
- {\edef\m_boxes_smash_options{#1}%
- \futurelet\nexttoken\syst_boxes_smash_indeed}
-
-\def\syst_boxes_smash_indeed
- {\ifmmode
- \expandafter\syst_boxes_smash_math
- \orelse\ifx\nexttoken\bgroup
- \expandafter\syst_boxes_smash_hbox
- \else
- \expandafter\syst_boxes_smash_text
- \fi}
-
-\def\syst_boxes_smash_math#1%
- {\syst_boxes_math_set_nextbox{#1}%
- \syst_boxes_smash_process}
-
-\def\syst_boxes_smash_hbox
- {\dowithnextboxcs\syst_boxes_smash_process\hbox}
-
-\def\syst_boxes_smash_text#1%
- {\setbox\nextbox\hbox{#1}%
- \syst_boxes_smash_process}
-
-\def\syst_boxes_smash_process
- {\expandafter\syst_boxes_smash_process_option\m_boxes_smash_options\relax
- \box\nextbox
- \endgroup}
-
-\installcorenamespace {smashoptions}
-
-\setvalue{\??smashoptions w}{\wd\nextbox\zeropoint}
-\setvalue{\??smashoptions h}{\ht\nextbox\zeropoint}
-\setvalue{\??smashoptions d}{\dp\nextbox\zeropoint}
-\setvalue{\??smashoptions t}{\ht\nextbox\zeropoint}
-\setvalue{\??smashoptions b}{\dp\nextbox\zeropoint}
-
-\def\syst_boxes_smash_process_option#1%
- {\ifx#1\relax\else
- \begincsname\??smashoptions#1\endcsname
- \expandafter\syst_boxes_smash_process_option
- \fi}
-
-\def\syst_boxes_lower_nextbox_dp
- {\setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}}
-
-%D \starttabulate[|l|l|]
-%D \NC w \NC \ruledhbox{\smash [w]{This is some great smashing, isn't it?}} \NC \NR
-%D \NC h \NC \ruledhbox{\smash [h]{This is some great smashing, isn't it?}} \NC \NR
-%D \NC d \NC \ruledhbox{\smash [d]{This is some great smashing, isn't it?}} \NC \NR
-%D \NC tb \NC \ruledhbox{\smash [tb]{This is some great smashing, isn't it?}} \NC \NR
-%D \NC whd \NC \ruledhbox{\smash[whd]{This is some great smashing, isn't it?}} \NC \NR
-%D \stoptabulate
-
-%D \macros
-%D {phantom, hphantom, vphantom, mathstrut}
-%D
-%D The next implementation of \type {\phantom} cum suis does not grab an argument in
-%D the non||math case, which is better.
-%D
-%D Due to a complicated call to \type {\mathpallete} and thereby \type
-%D {\mathchoice}, the next macro looks ugly. We also take care of non||braced
-%D arguments.
-
-\unexpanded\def\phantom {\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed }
-\unexpanded\def\vphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_v}
-\unexpanded\def\hphantom{\begingroup\futurelet\nexttoken\syst_boxes_phantom_indeed_h}
-
-\def\syst_boxes_phantom_math #1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make }
-\def\syst_boxes_phantom_math_v#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_v}
-\def\syst_boxes_phantom_math_h#1{\syst_boxes_math_set_nextbox{#1}\syst_boxes_phantom_make_h}
-
-\def\syst_boxes_phantom_hbox {\dowithnextboxcs\syst_boxes_phantom_make \hbox} % always hbox
-\def\syst_boxes_phantom_hbox_v{\dowithnextboxcs\syst_boxes_phantom_make_v\hbox} % always hbox
-\def\syst_boxes_phantom_hbox_h{\dowithnextboxcs\syst_boxes_phantom_make_h\hbox} % always hbox
-
-\def\syst_boxes_phantom_text #1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make } % always hbox
-\def\syst_boxes_phantom_text_v#1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make_v} % always hbox
-\def\syst_boxes_phantom_text_h#1{\setbox\nextbox\hbox{#1}\syst_boxes_phantom_make_h} % always hbox
-
-\def\syst_boxes_phantom_indeed
- {\ifmmode
- \expandafter\syst_boxes_phantom_math
- \orelse\ifx\nexttoken\bgroup
- \expandafter\syst_boxes_phantom_hbox
- \else
- \expandafter\syst_boxes_phantom_text
- \fi}
-
-\def\syst_boxes_phantom_indeed_v
- {\ifmmode
- \expandafter\syst_boxes_phantom_math_v
- \orelse\ifx\nexttoken\bgroup
- \expandafter\syst_boxes_phantom_hbox_v
- \else
- \expandafter\syst_boxes_phantom_text_v
- \fi}
-
-\def\syst_boxes_phantom_indeed_h
- {\ifmmode
- \expandafter\syst_boxes_phantom_math_h
- \orelse\ifx\nexttoken\bgroup
- \expandafter\syst_boxes_phantom_hbox_h
- \else
- \expandafter\syst_boxes_phantom_text_h
- \fi}
-
-\def\syst_boxes_phantom_make
- {\setbox\scratchbox\emptyhbox
- \ht\scratchbox\ht\nextbox
- \dp\scratchbox\dp\nextbox
- \wd\scratchbox\wd\nextbox
- \box\scratchbox
- \endgroup}
-
-\def\syst_boxes_phantom_make_v
- {\setbox\scratchbox\emptyhbox
- \ht\scratchbox\ht\nextbox
- \dp\scratchbox\dp\nextbox
- \box\scratchbox
- \endgroup}
-
-\def\syst_boxes_phantom_make_h
- {\setbox\scratchbox\emptyhbox
- \wd\scratchbox\wd\nextbox
- \box\scratchbox
- \endgroup}
-
-%D We also define plain's \type {\mathstrut}.
-
-\unexpanded\def\mathstrut{\vphantom(} % can be made faster by inlining
-
-%D \macros
-%D {getboxheight}
-%D
-%D Although often needed, \TEX\ does not support arithmics like:
-%D
-%D \starttyping
-%D \dimen0 = \ht0 + \dp0
-%D \stoptyping
-%D
-%D so we implemented:
-%D
-%D \starttyping
-%D \getboxheight ... \of \box...
-%D \stoptyping
-%D
-%D For instance,
-%D
-%D \starttyping
-%D \getboxheight \dimen0 \of \box0
-%D \getboxheight \someheight \of \box \tempbox
-%D \stoptyping
-%D
-%D The implementation is rather stupid:
-%D
-%D \starttyping
-%D \def\getboxheight#1\of#2\box#3%
-%D {#1\ht#3\advance#1\dp#3\relax}
-%D \stoptyping
-%D
-%D The next alternative is slightly more clever, since it accepts \type {{12}} as
-%D well as \type {12} as box number.
-
-\unexpanded\def\getboxheight#1\of#2\box#3%
- {\def\next{#1\htdp\c_boxes_register}%
- \afterassignment\next\c_boxes_register=#3}
-
-%D For a long time the following three macros were part of the grid snapping core
-%D module, but it makes more sense to have them here so that users can see them.
-%D
-%D \macros
-%D {getnoflines, getroundednoflines, getrawnoflines}
-%D
-%D Het commando \type {\getnoflines} converteert een hoogte (dimensie) in een aantal
-%D regels en kent dit toe aan \type {\noflines}.
-%D
-%D \starttyping
-%D \getnoflines{dimensie}
-%D \stoptyping
-%D
-%D Er wordt gedeeld door \type {\openlineheight} en een hoogte van~0pt komt overeen
-%D met 0~regels. The raw alternative does not round.
-%D
-%D For a long time we had:
-%D
-%D \starttyping
-%D \newcount\noflines
-%D \newdimen\noflinesheight
-%D
-%D \def\dogetnoflines#1#2%
-%D {\noflinesheight#2\relax
-%D \ifzeropt\noflinesheight
-%D \noflines\zerocount
-%D \else
-%D \divide\noflinesheight \openlineheight
-%D \noflines\noflinesheight
-%D #1\ifdim\noflines\openlineheight=#2\relax \else
-%D \advance\noflines\ifdim#2>\zeropoint\plusone\else\minusone\fi
-%D \fi\fi
-%D \fi}
-%D
-%D \def\getnoflines {\dogetnoflines\iftrue } % compensated
-%D \def\getrawnoflines{\dogetnoflines\iffalse} % no compensation
-%D \stoptyping
-%D
-%D A more recent variant is:
-
-\ifx\roundingeps\undefined \newdimen\roundingeps \roundingeps=10sp \fi
-
-\newcount\noflines
-\newdimen\noflinesheight
-
-\unexpanded\def\getnoflines#1%
- {\noflinesheight#1\relax
- \ifzeropt\noflinesheight
- \noflines\zerocount
- \orelse\ifdim\noflinesheight>\zeropoint
- \advance\noflinesheight-\roundingeps
- \divide\noflinesheight\openlineheight
- \noflines\noflinesheight
- \advance\noflines\plusone
- \else
- \advance\noflinesheight\roundingeps
- \divide\noflinesheight\openlineheight
- \noflines\noflinesheight
- \advance\noflines\minusone
- \fi}
-
-\unexpanded\def\getroundednoflines#1%
- {\noflinesheight#1\relax
- \ifzeropt\noflinesheight
- \noflines\zerocount
- \orelse\ifdim\noflinesheight>\zeropoint
- \advance\noflinesheight\roundingeps
- \divide\noflinesheight\openlineheight
- \noflines\noflinesheight
- \else
- \advance\noflinesheight-\roundingeps
- \divide\noflinesheight\openlineheight
- \noflines\noflinesheight
- \fi}
-
-\unexpanded\def\getrawnoflines#1%
- {\noflinesheight#1\relax
- \ifzeropt\noflinesheight
- \noflines\zerocount
- \orelse\ifdim\noflinesheight>\zeropoint
- \advance\noflinesheight\roundingeps
- \advance\noflinesheight.5\openlineheight
- \divide\noflinesheight\openlineheight
- \noflines\noflinesheight
- \else
- \advance\noflinesheight-\roundingeps
- \advance\noflinesheight-.5\openlineheight
- \divide\noflinesheight\openlineheight
- \noflines\noflinesheight
- \fi}
-
-%D Let's proof that it works:
-%D
-%D \startbuffer
-%D \scratchdimen\dimexpr(3pt) \getnoflines\scratchdimen 1=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight) \getnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10.1\lineheight) \getnoflines\scratchdimen 11=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10.5\lineheight) \getnoflines\scratchdimen 11=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10.9\lineheight) \getnoflines\scratchdimen 11=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight+3pt) \getnoflines\scratchdimen 11=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight+3sp) \getnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight-3sp) \getnoflines\scratchdimen 10=\the\noflines \endgraf
-%D
-%D \scratchdimen\dimexpr(3pt) \getrawnoflines\scratchdimen 0=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight) \getrawnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10.1\lineheight) \getrawnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10.5\lineheight) \getrawnoflines\scratchdimen 11=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10.9\lineheight) \getrawnoflines\scratchdimen 11=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight+3pt) \getrawnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight+3sp) \getrawnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \scratchdimen\dimexpr(10\lineheight-3sp) \getrawnoflines\scratchdimen 10=\the\noflines \endgraf
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-%D \macros
-%D {determinenoflines}
-%D
-%D The next macro determines the number of lines and returns it it \type
-%D {\noflines}. The macro works reasonable well as long as the content can be
-%D unboxed.
-%D
-%D \starttyping
-%D \determinenoflines{test\\test}
-%D \determinenoflines{\bfd test\\test}
-%D \determinenoflines{\definedfont[Sans at 40pt]test\\test}
-%D \stoptyping
-
-\def\syst_boxes_determine_noflines % can be mkiv'd
- {\beginofshapebox
- \unvbox\nextbox
- \endofshapebox
- \globalscratchcounter\zerocount
- \reshapebox{\global\advance\globalscratchcounter\plusone}%
- \expandafter\egroup\expandafter\noflines\the\globalscratchcounter\relax}
-
-\unexpanded\def\determinenoflines
- {\bgroup
- \forgetall
- \let\crlf\endgraf
- \let\\\endgraf
- \dowithnextboxcs\syst_boxes_determine_noflines\vbox}
-
-%D \macros
-%D {doiftextelse, doiftext}
-%D
-%D When \type {\doifelse} cum suis hopelessly fail, for instance because we pass
-%D data, we can fall back on the next macro:
-%D
-%D \starttyping
-%D \doiftextelse {data} {then branch} {else branch}
-%D \doiftext {data} {then branch}
-%D \stoptyping
-
-\unexpanded\def\doifelsetext#1%
- {\begingroup
- \setbox\scratchbox\hbox % no \hpack because we can have fallbacks
- {\settrialtypesetting
- \ignorespaces#1\removeunwantedspaces}%
- \ifzeropt\wd\scratchbox
- \endgroup\expandafter\secondoftwoarguments
- \else
- \endgroup\expandafter\firstoftwoarguments
- \fi}
-
-\unexpanded\def\doiftext#1%
- {\begingroup
- \setbox\scratchbox\hbox % no \hpack because we can have fallbacks
- {\settrialtypesetting
- \ignorespaces#1\removeunwantedspaces}%
- \ifzeropt\wd\scratchbox
- \endgroup\expandafter\gobbleoneargument
- \else
- \endgroup\expandafter\firstofoneargument
- \fi}
-
-% more efficient but maybe fragile:
-%
-% \nospacing#1}%
-
-\let\doiftextelse\doifelsetext
-
-%D \macros
-%D {dowithnextbox,nextbox}
-%D
-%D Sometimes we want a macro to grab a box and do something on the content. One
-%D could pass an argument to a box, but this can violate the specific \CATCODES\ of
-%D its content and leads to unexpected results. The next macro treats the following
-%D braced text as the content of a box and manipulates it afterwards in a predefined
-%D way.
-%D
-%D The first argument specifies what to do with the content. This content is
-%D available in \type {\nextbox}. The second argument is one of \type {\hbox}, \type
-%D {\vbox} or \type {\vtop}. The third argument must be grouped with \type {\bgroup}
-%D and \type {\egroup}, \type {{...}} or can be a \type {\box} specification.
-%D
-%D In \CONTEXT\ this macro is used for picking up a box and treating it according to
-%D earlier specifications. We use for instance something like:
-%D
-%D \starttyping
-%D \def\getfloat%
-%D {\def\handlefloat{...\box\nextbox...}
-%D \dowithnextboxcs\handlefloat\vbox}
-%D \stoptyping
-%D
-%D instead of:
-%D
-%D \starttyping
-%D \def\getfloat#1%
-%D {...#1...}
-%D \stoptyping
-%D
-%D In this implementation the \type {\aftergroup} construction is needed because
-%D \type {\afterassignment} is executed inside the box.
-
-\unexpanded\def\dowithnextbox#1%
- {\def\syst_boxes_with_next_box{#1}%
- \afterassignment\syst_boxes_with_next_box_indeed
- \setbox\nextbox}
-
-\def\syst_boxes_with_next_box_indeed
- {\aftergroup\syst_boxes_with_next_box}
-
-\unexpanded\def\dowithnextboxcs#1%
- {\let\syst_boxes_with_next_box#1%
- \afterassignment\syst_boxes_with_next_box_indeed
- \setbox\nextbox}
-
-%D So in fact we get:
-%D
-%D \starttyping
-%D \setbox\nextbox { \aftergroup\syst_boxes_with_next_box ... }
-%D \stoptyping
-%D
-%D or
-%D
-%D \starttyping
-%D \setbox\nextbox { ... } \syst_boxes_with_next_box
-%D \stoptyping
-%D
-%D A slower but more versatile implementation is:
-%D
-%D \starttyping
-%D \unexpanded\def\dowithnextbox#1#2%
-%D {\def\syst_boxes_with_next_box{#1}%
-%D \ifx#2\hbox
-%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else\ifx#2\vbox
-%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else\ifx#2\vtop
-%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else\ifx#2\normalvcenter
-%D \afterassignment\syst_boxes_with_next_box_indeed
-%D \else
-%D \afterassignment\syst_boxes_with_next_box
-%D \fi\fi\fi\fi
-%D \setbox\nextbox#2}
-%D \stoptyping
-%D
-%D This alternative also accepts \type {\box0} and alike, but we don't really need
-%D this functionality now.
-
-%D \macros
-%D {nextboxht,nextboxwd,nextboxdp,flushnextbox}
-%D
-%D The next couple of shortcuts saves us memory as well as \type {{}}'s in passing
-%D parameters.
-
-\def\nextboxht {\ht\nextbox}
-\def\nextboxwd {\wd\nextbox}
-\def\nextboxdp {\dp\nextbox}
-\def\nextboxhtdp{\htdp\nextbox}
-
-\unexpanded\def\flushnextbox{\box\nextbox}
-
-%D \macros
-%D {dowithnextboxcontent}
-%D
-%D But, occasionally we do need to pass some local settings without wanting to use
-%D additional grouping. Therefore we provide:
-%D
-%D \starttyping
-%D \dowithnextboxcontent{inside}{after}{box content}
-%D \stoptyping
-%D
-%D {\em todo: Search source for potential usage!}
-
-\unexpanded\def\dowithnextboxcontent#1#2% inside, after
- {\def\syst_boxes_with_next_box_one{#2}%
- \def\syst_boxes_with_next_box_two{#1}%
- \afterassignment\syst_boxes_with_next_box_content_indeed
- \setbox\nextbox}
-
-\unexpanded\def\dowithnextboxcontentcs#1#2% inside, after
- {\let\syst_boxes_with_next_box_one#2%
- \let\syst_boxes_with_next_box_two#1%
- \afterassignment\syst_boxes_with_next_box_content_indeed
- \setbox\nextbox}
-
-\def\syst_boxes_with_next_box_content_indeed
- {\syst_boxes_with_next_box_two\aftergroup\syst_boxes_with_next_box_one}
-
-%D \macros
-%D {llap, rlap, tlap, blap, clap}
-%D
-%D Some well known friends, but we implement them our own way. We want the macros to
-%D work in both math and text mode.
-
-\def\dodorlap{\hpack to \zeropoint{\box\nextbox\hss}\endgroup}
-\def\dodollap{\hpack to \zeropoint{\hss\box\nextbox}\endgroup}
-\def\dodoclap{\hpack to \zeropoint{\hss\box\nextbox\hss}\endgroup}
-
-\def\dorlap{\begingroup\dowithnextboxcs\dodorlap\hbox}
-\def\dollap{\begingroup\dowithnextboxcs\dodollap\hbox}
-\def\doclap{\begingroup\dowithnextboxcs\dodoclap\hbox}
-
-\def\domathclap{\mathpalette\dodomathclap} \def\dodomathclap#1#2{\doclap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
-\def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
-\def\domathrlap{\mathpalette\dodomathrlap} \def\dodomathrlap#1#2{\dorlap{\normalstartimath\mathsurround\zeropoint#1#2\normalstopimath}}
-
-\unexpanded\def\rlap{\mathortext\domathrlap\dorlap}
-\unexpanded\def\llap{\mathortext\domathllap\dollap}
-\unexpanded\def\clap{\mathortext\domathclap\doclap}
-
-\def\dodotlap{\vpack to \zeropoint{\vss\box\nextbox}\endgroup}
-\def\dodoblap{\vpack to \zeropoint{\box\nextbox\vss}\endgroup}
-
-\unexpanded\def\tlap{\begingroup\dowithnextboxcs\dodotlap\vbox}
-\unexpanded\def\blap{\begingroup\dowithnextboxcs\dodoblap\vbox}
-
-%D \macros
-%D {beginofshapebox,
-%D reshapebox, doreshapebox,
-%D flushshapebox,
-%D innerflushshapebox,
-%D shapebox,
-%D ifreshapingbox}
-%D
-%D The next utility macro originates from some linenumbering mechanism. Due to
-%D \TEX's advanced way of typesetting paragraphs, it's not easy to do things on a
-%D line||by||line basis. This macro is able to reprocess a given box and can act
-%D upon its vertical boxed components, such as lines. The unwinding sequence in this
-%D macro is inspired by a \NTG\ workshop of David Salomon in June 1992.
-%D
-%D First we have to grab the piece of text we want to act upon. This is done by
-%D means of the duo macros:
-%D
-%D \starttyping
-%D \beginofshapebox
-%D a piece of text
-%D \endofshapebox
-%D \stoptyping
-%D
-%D When all texts is collected, we can call \type {\reshapebox} and do something
-%D with it's vertical components. We can make as much passes as needed. When we're
-%D done, the box can be unloaded with \type {\flushshapebox}. The only condition in
-%D this scheme is that \type {\reshapebox} must somehow unload the \BOX\ \type
-%D {\shapebox}.
-%D
-%D An important aspect is that the content is unrolled bottom||up. The next example
-%D illustrates this maybe unexpected characteristic.
-%D
-%D \startbuffer
-%D \beginofshapebox
-%D \em \input tufte
-%D \endofshapebox
-%D
-%D \newcounter\LineNumber
-%D
-%D \reshapebox
-%D {\doglobal\increment\LineNumber
-%D \hbox{\llap{\LineNumber\hskip2em}\box\shapebox}}
-%D
-%D \flushshapebox
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \getbuffer
-%D
-%D As we can see, when some kind of numbering is done, we have to add a second pass.
-%D
-%D \startbuffer
-%D \newcounter\LineNumber
-%D \newcounter\NumberOfLines
-%D
-%D \reshapebox
-%D {\doglobal\increment\NumberOfLines
-%D \box\shapebox}
-%D
-%D \reshapebox
-%D {\doglobal\increment\LineNumber
-%D \hbox
-%D {\llap{\LineNumber\ (\NumberOfLines)\hskip2em}%
-%D \box\shapebox}%
-%D \doglobal\decrement\NumberOfLines}
-%D
-%D \flushshapebox
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \getbuffer
-%D
-%D This example shows that the content of the box is still available after flushing.
-%D Another feature is that only the last reshaping counts. Multiple reshaping can be
-%D done by:
-%D
-%D \startbuffer
-%D \beginofshapebox
-%D \flushshapebox
-%D \endofshapebox
-%D
-%D \reshapebox
-%D {\doglobal\increment\LineNumber
-%D \hbox{\llap{$\star$\hskip1em}\box\shapebox}%
-%D \doglobal\decrement\NumberOfLines}
-%D
-%D \flushshapebox
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \getbuffer
-%D
-%D The macros are surprisingly easy to follow and in fact introduce no new concepts.
-%D Nearly all books on \TEX\ show similar solutions for unwinding \BOXES.
-%D
-%D Some macros, like footnote ones, can be sensitive for reshaping, which can result
-%D in an endless loop. We therefore offer:
-%D
-%D \starttyping
-%D \ifreshapingbox
-%D \stoptyping
-%D
-%D Some \CONTEXT\ commands are protected this way. Anyhow, reshaping is aborted
-%D after 100 dead cycles.
-%D
-%D By the way, changing the height and depth of \BOX\ \type {\shapebox} results in
-%D bad spacing. This means that for instance linenumbers etc. should be given zero
-%D height and depth before being lapped into the margin. The previous examples
-%D ignore this side effect, but beware!
-
-\newif \ifsomeshapeleft
-\newif \ifreshapingbox
-\newif \ifreshapingfailed % may save redundant runs
-
-\newbox \shapebox
-\newcount \shapepenalty
-\newdimen \shapekern
-\newskip \shapeskip
-
-\newbox \newshapebox
-\newbox \oldshapebox
-\newbox \tmpshapebox
-
-\newcount \shapecounter
-
-\newevery \everyshapebox \relax
-
-\def\shapesignal{.12345678pt} % or 12345sp
-
-\unexpanded\def\reshapebox#1%
- {\doreshapebox
- {#1}%
- {\penalty\shapepenalty}%
- {\kern \shapekern }%
- {\vskip \shapeskip }}
-
-\def\doreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip
- {\global\reshapingfailedfalse
- \ifzeropt\ht\oldshapebox
- \setbox\newshapebox\emptyvbox
- \else
- \setbox\newshapebox\vbox % can be \vpack
- {\unvcopy\oldshapebox
- \setbox\newshapebox\emptybox
- \shapecounter\zerocount
- \doloop{\dodoreshapebox{#1}{#2}{#3}{#4}}}%
- \setbox\newshapebox\box\tmpshapebox
- \fi}
-
-\ifx\originalshapebox\undefined \let\originalshapebox\oldshapebox \fi
-
-% We will turn this into a \MKIV\ variant (we can use \type {\vpack} too).
-
-\unexpanded\def\insertshapesignal
- {\hpack to \shapesignal{\strut\hss}% plus \strut
- \prevdepth\strutdp} % never \nointerlineskip
-
-\unexpanded\def\restoreshapebox % compensates for the signal
- {\global\setbox\tmpshapebox\vbox{\vskip-\lineheight\unvcopy\oldshapebox}}
-
-\def\dodoreshapebox#1#2#3#4% \shapebox, \shapepenalty, \shapekern, \shapeskip
- {\ifnum\lastnodetype=\gluenodecode
- \shapeskip\lastskip
- \global\setbox\tmpshapebox\vbox{#4\unvbox\tmpshapebox}%
- \unskip
- \orelse\ifnum\lastnodetype=\kernnodecode
- \shapekern\lastkern
- \global\setbox\tmpshapebox\vbox{#3\unvbox\tmpshapebox}%
- \unkern
- \orelse\ifnum\lastnodetype=\penaltynodecode
- \shapepenalty\lastpenalty
- \global\setbox\tmpshapebox\vbox{#2\unvbox\tmpshapebox}%
- \unpenalty
- \orelse\ifnum\lastnodetype<\zeropoint
- \exitloop
- \else
- \setbox\shapebox\lastbox
- \ifvoid\shapebox
- \orelse\ifdim\wd\shapebox=\shapesignal\relax
- \exitloop
- \else
- \shapecounter\zerocount
- \global\setbox\tmpshapebox\vbox{#1\unvbox\tmpshapebox}%
- \fi
- \fi
- \ifnum\shapecounter>100 % can be less
- \global\reshapingfailedtrue
- \message{!!forced exit from shapebox \the\lastnodetype !!}%
- \restoreshapebox
- \exitloop
- \else
- \advance\shapecounter \plusone
- \fi}
-
-\unexpanded\def\beginofshapebox
- {\setbox\oldshapebox\vbox
- \bgroup
- \reshapingboxtrue
- \the\everyshapebox
- \insertshapesignal}
-
-\unexpanded\def\endofshapebox
- {\endgraf
- \egroup}
-
-\let\beginshapebox\beginofshapebox
-\let\endshapebox \endofshapebox
-
-\unexpanded\def\flushshapebox
- {\bgroup
- \ifzeropt\ht\newshapebox
- \else
- % make \prevdepth legal
- % \par before the next \vskip gives far worse results
- \ifdim\parskip>\zeropoint\vskip\parskip\else\par\fi
- % and take a look
- \ifdim\prevdepth=-\thousandpoint
- \prevdepth\zeropoint
- \fi
- \ifdim\prevdepth<\zeropoint\relax
- % something like a line or a signal or ...
- \donetrue
- \orelse\ifinner
- % not watertight and not ok
- \donefalse
- \orelse\ifdim\pagegoal=\maxdimen
- \donetrue
- \else
- % give the previous line a normal depth
- \donetrue
- {\forgeteverypar\verticalstrut}\nobreak
- \kern-\struttotal % geen \vskip
- \kern-\parskip
- % \vskip-\strutdp
- \fi
- \scratchdimen\dp\newshapebox
- \unvbox\newshapebox
- % \prevdepth=0pt and \dp\newshapebox depend on last line
- \kern-\scratchdimen % ??
- % now \prevdepth=0pt
- \ifdone
- \kern\strutdp
- \prevdepth\strutdp
- \fi
- \fi
- \egroup}
-
-%D In real inner situations we can use:
-%D
-%D \starttyping
-%D \flushinnershapebox
-%D \stoptyping
-%D
-%D This one is used in \type{\framed}.
-
-% The kern fails on for instance:
-%
-% \omlijnd[offset=0pt,hoogte=8mm,uitlijnen={rechts,laho}]{\bfa test}
-
-\unexpanded\def\innerflushshapebox
- {\ifzeropt\ht\newshapebox \else
- \unvcopy\newshapebox\relax % unvcopy ! else spacing problem
- % \kern-\dp\newshapebox\relax
- \fi}
-
-%D For absolute control, one can use \type {\doreshapebox} directly. This macro
-%D takes four arguments, that take care of:
-%D
-%D \startitemize[n,packed]
-%D \item \type{\shapebox}
-%D \item \type{\shapepenalty}
-%D \item \type{\shapekern}
-%D \item \type{\shapeskip}
-%D \stopitemize
-
-%D \macros
-%D {shapedhbox}
-%D
-%D When constructing a new box, using the content of \type {\shapebox}, one can best
-%D use \type {\shapedhbox} instead of \type {\hbox}, since it manages the height and
-%D depth of the line.
-
-\unexpanded\def\shapedhbox % lines with non strutted dimensions have
- {\expanded{\dowithnextbox % interlineskip so if we want the original
- {\ht\nextbox\the\ht\shapebox % spacing, we need to preserve the original
- \dp\nextbox\the\dp\shapebox % height and depth which is definitely
- \box\nextbox}} % needed if we apply struts to the 'new'
- \hbox} % box or do something that changed ist size
-
-%D \macros
-%D {hyphenatedword,
-%D hyphenatedpar,
-%D hyphenatedfile,
-%D dohyphenateword}
-%D
-%D We no longer use the pure \TEX\ variant. In due time we will report some more
-%D advanced statistics.
-%D
-%D \starttyping
-%D \showhyphens{dohyphenatedword}
-%D \stoptyping
-
-\unexpanded\def\doshowhyphenatednextbox
- {\clf_showhyphenatedinlist\nextbox}
-
-\unexpanded\def\showhyphens % hpack: so no processing (we hyphenate in lua)
- {\dowithnextboxcs\doshowhyphenatednextbox\hpack}
-
-%D The following macros are seldom used but handy for tracing.
-%D
-%D \starttyping
-%D \hyphenatedword{dohyphenatedword}
-%D \hyphenatedpar {\dorecurse{10}{dohyphenatedword }}
-%D \hyphenatedfile{tufte}
-%D \stoptyping
-
-\unexpanded\def\dohyphenatednextbox
- {\clf_hyphenatedlist\nextbox false\relax
- \unhbox\nextbox}
-
-\unexpanded\def\hyphenatedword {\dowithnextboxcs\dohyphenatednextbox\hbox}
-\unexpanded\def\hyphenatedpar {\dowithnextboxcs\dohyphenatednextbox\hbox}
-\unexpanded\def\hyphenatedfile#1{\dowithnextboxcs\dohyphenatednextbox\hbox{\readfile{#1}\donothing\donothing}}
-
-\unexpanded\def\dohyphenatednextboxcolor
- {\clf_hyphenatedlist\nextbox true\relax
- \unhbox\nextbox}
-
-\unexpanded\def\hyphenatedcoloredword{\dowithnextboxcs\dohyphenatednextboxcolor\hbox}
-
-%D \macros
-%D {processtokens}
-%D
-%D We fully agree with (most) typographers that inter||letter spacing is only
-%D permitted in fancy titles, we provide a macro that can be used to do so. Because
-%D this is (definitely and fortunately) no feature of \TEX, we have to step through
-%D the token list ourselves.
-%D
-%D \starttyping
-%D \processtokens {before} {between} {after} {space} {tokens}
-%D \stoptyping
-%D
-%D An example of a call is:
-%D
-%D \startbuffer
-%D \processtokens {[} {+} {]} {\space} {hello world}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D This results in:
-%D
-%D \getbuffer
-%D
-%D The list of tokens may contain spaces, while \type {\\}, \type {{}} and \type {\
-%D } are handled as space too.
-
-\unexpanded\def\processtokens#1#2#3#4#5%
- {\begingroup
- \def\lastcharacter{\lastcharacter}% hm, recursive ?
- \def\space{ }%
- \let\\=\space
- \def\before {#1}%
- \def\between{#2}%
- \def\after {#3}%
- \def\white {#4}%
- \let\savedbefore\before
- \doprocesstokens#5\lastcharacter
- \endgroup}
-
-\def\doprocesstokens% the space after = is essential
- {\afterassignment\dodoprocesstokens\let\nextprocessedtoken= }
-
-\def\redoprocessedtoken
- {\dowithnextbox
- {\before{\copy\nextbox}% \before can use nextbox several times
- \let\before\between
- \doprocesstokens}
- \hbox\bgroup}
-
-\def\dodoprocesstokens
- {\ifx\nextprocessedtoken\lastcharacter
- \after
- \orelse\ifx\nextprocessedtoken\bgroup
- \expandafter\redoprocessedtoken
- \else
- \expandafter\if\space\nextprocessedtoken
- \after\white
- \let\before\savedbefore
- \else
- \before\nextprocessedtoken
- \let\before\between
- \fi
- \expandafter\doprocesstokens
- \fi}
-
-%D \macros
-%D {doboundtext}
-%D
-%D Sometimes there is not enough room to show the complete (line of) text. In such a
-%D situation we can strip of some characters by using \type {\doboundtext}. When the
-%D text is wider than the given width, it's split and the third argument is
-%D appended. When the text to be checked is packed in a command, we'll have to use
-%D \type {\expandafter}.
-%D
-%D \starttyping
-%D \doboundtext{a very, probably to long, text}{3cm}{...}
-%D \stoptyping
-%D
-%D When calculating the room needed, we take the width of the third argument into
-%D account, which leads to a bit more complex macro than needed at first sight.
-
-\def\dodoboundtext#1%
- {\setbox\scratchboxone\hbox{#1}%
- \advance\scratchdimen -\wd\scratchboxone
- \ifdim\scratchdimen>\zeropoint\relax#1\fi}
-
-\def\doboundtext#1#2#3% still used?
- {\hbox
- {\setbox\scratchbox\hbox{#1}%
- \scratchdimen#2\relax
- \ifdim\wd\scratchbox>\scratchdimen
- \setbox\scratchbox\hbox{#3}%
- \advance\scratchdimen -\wd\scratchbox
- \handletokens#1\with\dodoboundtext
- \fi
- \box\scratchbox}}
-
-%D \macros
-%D {limitatetext}
-%D
-%D A bit more beautiful alternative for the previous command is the next one. This
-%D command is more robust because we let \TEX\ do most of the job. The previous
-%D command works better on text that cannot be hyphenated.
-%D
-%D \starttyping
-%D \limitatetext {text} {width} {sentinel}
-%D \limitatetext {text} {-width} {prelude}
-%D \stoptyping
-%D
-%D When no width is given, the whole text comes available. The sentinel is optional.
-%D This is about the third version.
-
-\ifdefined\fakecompoundhyphen\else \let\fakecompoundhyphen\relax \fi
-\ifdefined\veryraggedright \else \def\veryraggedright{\raggedright} \fi
-
-% \unexpanded\def\limitatetext
-% {\bgroup % evt \setstrut
-% \forgetall % otherwise indentation and so
-% \let\limitatetext\firstofthreearguments
-% \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! !
-% \dowithnextboxcs\syst_boxes_limitate_text\hbox}
-%
-% \def\syst_boxes_limitate_text#1% #2
-% {\doifelsenothing{#1}\syst_boxes_limitate_text_nop\syst_boxes_limitate_text_yes{#1}} % {#2}
-%
-% \def\syst_boxes_limitate_text_nop#1#2%
-% {\unhbox\nextbox
-% \egroup}
-%
-% \def\syst_boxes_limitate_text_yes#1#2%
-% {\nopenalties
-% \scratchdimen#1\relax
-% \ifdim\scratchdimen<\zeropoint\relax % we'll take the last line
-% \donefalse
-% \scratchdimen-\scratchdimen
-% \else
-% \donetrue
-% \fi
-% \ifdim\wd\nextbox>\scratchdimen
-% \setbox\scratchbox\hbox{\ifdone\space#2\else#2\space\fi}%
-% \advance\scratchdimen -\wd\scratchbox
-% \setbox\scratchboxone\box\nextbox
-% \setbox\nextbox\vbox
-% {\hsize\scratchdimen
-% \hfuzz\maxdimen
-% \veryraggedright
-% \strut
-% \ifdone \else
-% \parfillskip\zeropoint
-% \rightskip\zeropoint
-% \hskip\zeropoint \s!plus 1\s!fill % \hsize
-% \fi
-% \unhcopy\scratchboxone}%
-% \ifdim\ht\nextbox>\strutht
-% \setbox\nextbox\vbox % if omitted: missing brace reported
-% {\splittopskip\openstrutheight
-% \ifdone
-% \setbox\nextbox\vsplit\nextbox to \strutht
-% \else
-% \doloop
-% {\setbox\scratchboxone\vsplit\nextbox to \strutht
-% \ifdim\ht\nextbox>\strutht \else \exitloop \fi}%
-% \fi
-% \unvbox\nextbox
-% \setbox\nextbox\lastbox
-% \global\setbox1\hpack
-% {\ifdone
-% \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox
-% \else
-% \box\scratchbox\unhbox\nextbox
-% \fi
-% \unskip}}%
-% \unhbox1
-% \else
-% \unhbox0%
-% \fi
-% \else
-% \unhbox\nextbox
-% \fi
-% \egroup}
-%
-% %D We can also limit a text with more control:
-% %D
-% %D \startbuffer
-% %D \limitatetext {\input tufte } {2cm,5mm} {\unknown}
-% %D \limitatetext {ton en hans} {2cm,5mm} {\unknown}
-% %D \limitatetext {ton en hans zijn eikels} {2cm,5mm} {\unknown}
-% %D \limitatetext {ton} {2cm,5mm} {\unknown}
-% %D \stopbuffer
-% %D
-% %D \typebuffer \getbuffer
-% %D
-% %D We build this feature on top of the previous macro.
-%
-% % we could move the text argument to the end
-%
-% \let\normallimitatetext\limitatetext
-%
-% \def\speciallimitatetext#1#2#3#4% text left right placeholder
-% {%\dontleavehmode
-% \bgroup
-% \let\speciallimitatetext\firstoffourarguments
-% \setbox\scratchboxone\hbox
-% {\nohyphens
-% \normallimitatetext{#1}{+#2}{}#4%
-% \normallimitatetext{#1}{-#3}{}}%
-% \setbox\scratchboxtwo\hbox
-% {#1}%
-% \ifdim\wd\scratchboxtwo<\wd\scratchboxone #1\else\unhbox\scratchboxone\fi
-% \egroup}
-%
-% \unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16
-% {\splitatcomma{#2}\leftlimit\rightlimit
-% \ifx\rightlimit\empty
-% \normallimitatetext {#1}\leftlimit {#3}%
-% \else
-% \speciallimitatetext{#1}\leftlimit\rightlimit{#3}%
-% \fi}
-
-\unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16
- {\splitatcomma{#2}\leftlimit\rightlimit
- \limitated
- left \leftlimit
- \ifx\rightlimit\empty\else
- right \rightlimit
- \fi
- strip true
- sentinel {#3}
- text {#1}
- \relax}
-
-%D Undocumented bonus (see wiki):
-%D
-%D \starttyping
-%D \limitatefirstline{\input tufte\relax}{10cm}{\unknown}
-%D \stoptyping
-
-\unexpanded\def\limitatefirstline#1#2#3%
- {\hbox\bgroup\strut % \hpack
- \setbox\scratchbox\hbox{\begstrut#1\endstrut}%
- \ifdim\wd\scratchbox>#2\relax
- \setbox\scratchbox\hbox{#3}%
- \hsize#2\relax
- \advance\hsize-\wd\scratchbox
- \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}%
- \setbox\scratchbox\vsplit\scratchbox to \lineheight
- \vbox
- {\unvbox\scratchbox
- \global\setbox\plusone\lastbox
- \global\setbox\plusone\hbox{\strut\unhbox\plusone}%
- \hbox % to #2 % \hpack
- {\ifx\clip\undefined
- \box\plusone
- \orelse\ifdim\wd\plusone>\hsize
- \lower\strutdepth\hpack{\clip[\c!width=\hsize,\c!height=\lineheight]{\hpack{\raise\strutdepth\box\plusone}}}%
- \else
- \box\plusone
- \fi
- \removeunwantedspaces#3}}% \removeunwantedspaces\hss#3}}%
- \else
- #1%
- \fi
- \egroup}
-
-%D \macros
-%D {processisolatedwords,processisolatedchars}
-%D
-%D \startbuffer
-%D \processisolatedchars{some more words} \ruledhbox \par
-%D \processisolatedchars{and some $x + y = z$ math} \ruledhbox \par
-%D \processisolatedchars{and a \hbox{$x + y = z$}} \ruledhbox \par
-%D \processisolatedwords{some more words} \ruledhbox \par
-%D \processisolatedwords{and some $x + y = z$ math} \ruledhbox \par
-%D \processisolatedwords{and a \hbox{$x + y = z$}} \ruledhbox \par
-%D \stopbuffer
-%D
-%D \typebuffer \blank \getbuffer \blank
-
-% todo: provide variant with #1 picked up as box
-
-\unexpanded\def\processisolatedchars#1#2%
- {\dontleavehmode
- \begingroup
- \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}%
- \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}%
- \clf_applytobox
- method {char}%
- box \scratchbox
- command {\csstring#2}%
- nested true%
- \relax
- \endgroup}
-
-\unexpanded\def\processisolatedwords#1#2%
- {\dontleavehmode
- \begingroup
- \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}%
- \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}%
- \clf_applytobox
- method {word}%
- box \scratchbox
- command {\csstring#2}%
- nested true%
- \relax
- \endgroup}
-
-%D A variant:
-
-\unexpanded\def\applytocharacters#1%
- {\dontleavehmode
- \dowithnextbox{\clf_applytobox
- method {char}%
- box \nextbox
- command {\csstring#1}%
- nested true%
- \relax}%
- \hbox}
-
-\unexpanded\def\applytowords#1%
- {\dontleavehmode
- \dowithnextbox{\clf_applytobox
- method {word}%
- box \nextbox
- command {\csstring#1}%
- nested true%
- \relax}%
- \hbox}
-
-%D The old call:
-
-\unexpanded\def\processwords#1%
- {\processisolatedwords{#1}\processword}
-
-\let\processword\relax
-
-\unexpanded\def\applytosplitstringchar#1#2%
- {\dontleavehmode\clf_processsplit
- data {#2}%
- command {\csstring#1}%
- method {char}%
- \relax}
-
-\unexpanded\def\applytosplitstringword#1#2%
- {\dontleavehmode\clf_processsplit
- data {#2}%
- command {\csstring#1}%
- method {word}%
- \relax}
-
-\unexpanded\def\applytosplitstringline#1#2%
- {\dontleavehmode\clf_processsplit
- data {#2}%
- command {\csstring#1}%
- method {line}%
- \relax}
-
-\unexpanded\def\applytosplitstringcharspaced#1#2%
- {\dontleavehmode\clf_processsplit
- data {#2}%
- command {\csstring#1}%
- method {char}%
- spaced true%
- \relax}
-
-\unexpanded\def\applytosplitstringwordspaced#1#2%
- {\dontleavehmode\clf_processsplit
- data {#2}%
- command {\csstring#1}%
- method {word}%
- spaced true%
- \relax}
-
-\unexpanded\def\applytosplitstringlinespaced#1#2%
- {\dontleavehmode\clf_processsplit
- data {#2}%
- command {\csstring#1}%
- method {line}%
- spaced true%
- \relax}
-
-%D \macros
-%D {sbox}
-%D
-%D This is a rather strange command. It grabs some box content and and limits the
-%D size to the height and depth of a \type {\strut}. The resulting bottom||alligned
-%D box can be used aside other ones, without disturbing the normal baseline
-%D distance.
-%D
-%D \startbuffer
-%D \ruledhbox to .5\hsize{\sbox{eerste\par tweede \par derde}}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D Shows up as:
-%D
-%D \startexample
-%D \vskip3\baselineskip
-%D \getbuffer
-%D \stopexample
-%D
-%D Before displaying the result we added some skip, otherwise the first two lines
-%D would have ended up in the text. This macro can be useful when building
-%D complicated menus, headers and footers and|/|or margin material.
-
-\unexpanded\def\sbox
- {\vpack\bgroup
- \dowithnextboxcs\syst_boxes_sbox_finish\vbox}
-
-\unexpanded\def\syst_boxes_sbox_finish
- {\boxyoffset\nextbox-\strutdp
- \dp\nextbox\strutdp
- \ht\nextbox\strutht
- \box\nextbox
- \egroup}
-
-%D A variant on this:
-%D
-%D \starttyping
-%D xx \ruledhbox{\inlinedbox{\tfd test}} xx
-%D \stoptyping
-
-\unexpanded\def\inlinedbox
- {\bgroup
- \dowithnextboxcs\syst_boxes_inlined_finish\hbox}
-
-\unexpanded\def\syst_boxes_inlined_finish
- {\boxyoffset\nextbox-\dimexpr(\htdp\nextbox-\lineheight)/\plustwo+\strutdp\relax
- \ht\nextbox\strutht
- \dp\nextbox\strutdp
- \box\nextbox
- \egroup}
-
-%D \macros
-%D {struttedbox}
-%D
-%D This boxing macro limits the height and depth to those of a strut.
-
-\unexpanded\def\struttedbox
- {\hpack\bgroup
- \dowithnextboxcs\syst_boxes_struttedbox_finish\hbox}
-
-\def\syst_boxes_struttedbox_finish
- {\dp\nextbox\strutdepth
- \ht\nextbox\strutheight
- \box\nextbox
- \egroup}
-
-%D \macros
-%D {topskippedbox}
-%D
-%D This macro compensates the difference between the topskip and strutheight. Watch
-%D how we preserve the depth when it equals strutdepth.
-
-\unexpanded\def\topskippedbox
- {\hpack\bgroup\dowithnextboxcs\syst_boxes_topskippedbox_finish\hbox}
-
-\def\syst_boxes_topskippedbox_finish
- {\edef\m_boxes_tmp{\ifdim\strutdepth=\dp\nextbox\dp\nextbox\the\dp\nextbox\fi}%
- \lower\topskip\hpack{\raise\strutheight\box\nextbox}%
- \m_boxes_tmp
- \egroup}
-
-%D \macros
-%D {centeredbox, centerednextbox}
-%D
-%D Here is another strange one. This one offers a sort of overlay with positive or
-%D negative offsets. This command can be used in well defined areas where no offset
-%D options are available. We first used it when building a button inside the margin
-%D footer, where the button should have a horizontal offset and should be centered
-%D with respect to the surrounding box. The last of the three examples we show below
-%D says:
-%D
-%D \starttyping
-%D \vsize=3cm
-%D \hsize=3cm
-%D \ruledvbox to \vsize
-%D {\centeredbox height .5cm width -1cm
-%D {\vrule width \hsize height \vsize}}}
-%D \stoptyping
-%D
-%D Here the \type {\ruledvbox} just shows the surrounding box and \type {\vrule} is
-%D used to show the centered box.
-%D
-%D \def\AnExample#1#2%
-%D {\vsize=3cm
-%D \hsize=3cm
-%D \ruledvbox to \vsize
-%D {\centeredbox height #1 width #2
-%D {\color[green]{\vrule width \hsize height \vsize}}}}
-%D
-%D \startlinecorrection
-%D \startcombination[3*1]
-%D {\AnExample {-1cm} {.5cm}} {}
-%D {\AnExample {.5cm} {-1cm}} {}
-%D {\AnExample {-1cm} {-.5cm}} {}
-%D \stopcombination
-%D \stoplinecorrection
-%D
-%D This command takes two optional arguments: \type {width} and \type {height}.
-%D Observing readers can see that we use \TEX's own scanner for grabbing these
-%D arguments: \type {#1#} reads everyting till the next brace and passes it to both
-%D rules. The setting of the box dimensions at the end is needed for special cases.
-%D The dimensions of the surrounding box are kept intact. This commands handles
-%D positive and negative dimensions (which is why we need two boxes with rules).
-
-\unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen
- {\bgroup
- \dontcomplain
- \forgetall
- \scangivendimensions#1\relax
- \advance\vsize\givenheight
- \advance\hsize\givenwidth
- \dowithnextboxcs\syst_boxes_centered_finish
- \hbox}
-
-\def\syst_boxes_centered_finish
- {\boxxoffset\nextbox.5\dimexpr
- \hsize
- -\wd\nextbox
- -\givenwidth
- \relax
- \boxyoffset\nextbox.5\dimexpr
- \vsize
- -\ht\nextbox
- +\dp\nextbox
- -\givenheight
- \relax
- \wd\nextbox\dimexpr\hsize-\givenwidth \relax
- \ht\nextbox\dimexpr\vsize-\givenheight\relax
- \dp\nextbox\zeropoint
- \box\nextbox
- \egroup}
-
-%D For those who don't want to deal with \type {\hsize} and \type {\vsize}, we have:
-%D
-%D \starttyping
-%D \centerednextbox width 2bp height 2bp
-%D {\framed[width=100bp,height=100bp]{}}
-%D \stoptyping
-%D
-%D Do you see why we call this one \type {next}?
-
-\unexpanded\def\centerednextbox#1#%
- {\bgroup
- \dowithnextbox
- {\hsize\wd\nextbox
- \vsize\ht\nextbox
- \centeredbox#1{\box\nextbox}%
- \egroup}
- \hbox}
-
-%D \macros
-%D {centerbox}
-%D
-%D Centering on the available space is done by:
-%D
-%D \starttyping
-%D \centerbox {content}
-%D \stoptyping
-%D
-%D When omitted, the current \type {\hsize} and \type {\vsize} are used. Local
-%D dimensions are supported.
-
-\unexpanded\def\centerbox#1#% optional height +/-dimen width +/-dimen
- {\bgroup
- \dowithnextbox
- {\setlocalhsize
- \setbox\scratchbox\hpack{\vrule\s!width \zeropoint#1}%
- \ifzeropt\wd\scratchbox\else\hsize\wd\scratchbox\fi
- \setbox\scratchbox\vpack{\hrule\s!height\zeropoint#1}%
- \ifzeropt\ht\scratchbox\else\vsize\ht\scratchbox\fi
- \vpack to \vsize{\vss\hpack to \hsize{\hss\box\nextbox\hss}\vss}%
- \egroup}%
- \hbox}
-
-%D \macros
-%D {setrigidcolumnhsize,rigidcolumnbalance,rigidcolumnlines}
-%D
-%D These macros are copied from the \TEX book, page~397, and extended by a macro
-%D that sets the \type {\hsize}.
-%D
-%D \starttyping
-%D \setrigidcolumnhsize {total width} {distance} {n}
-%D \rigidcolumnbalance {box}
-%D \stoptyping
-%D
-%D Both these macros are for instance used in typesetting footnotes. The following
-%D flags influence the process.
-
-\newif\ifalignrigidcolumns
-\newif\ifstretchrigidcolumns
-\newif\iftightrigidcolumns % if true: just a vbox, no depth/noflines/gridsnap corrrections
-
-\unexpanded\def\setrigidcolumnhsize#1#2#3% todo: \dimexpr
- {\xdef\savedrigidhsize{\the\hsize}%
- \hsize#1\relax
- \global\chardef\rigidcolumns#3\relax
- \scratchdimen -#2\relax
- \multiply\scratchdimen #3\relax
- \advance\scratchdimen #2\relax
- \advance\hsize \scratchdimen
- \divide\hsize #3\relax}
-
-% ==
-%
-% \def\setrigidcolumnhsize#1#2#3%
-% {\xdef\savedrigidhsize{\the\hsize}%
-% \global\chardef\rigidcolumns#3\relax
-% \hsize=\dimexpr(#1-\numexpr#3-1\relax\dimexpr#2\relax)/#3\relax}
-
-\newbox\rigidcolumnbox
-
-\let\rigidcolumnlines\!!zerocount
-
-\unexpanded\def\rigidcolumnbalance#1%
- {\ifnum\rigidcolumns=1 % tzt ook h/d correctie
- \ifinner\ifhmode\box\else\unvbox\fi\else\unvbox\fi#1\relax
- \else
- \vbox % \vpack
- {\forgetall
- \nopenalties
- \dontcomplain
- \setbox\rigidcolumnbox\vbox
- {\line{}\goodbreak\unvbox#1\removebottomthings}%
- \splittopskip\openstrutheight
- \setbox\scratchbox\vsplit\rigidcolumnbox to \zeropoint
- \ifcase\rigidcolumnlines\relax
- % \iffalse
- % % maybe some day an option
- % \scratchskip\ht\rigidcolumnbox
- % \advance\scratchskip\dp\rigidcolumnbox
- % \getnoflines\scratchskip
- % \ifodd\noflines
- % \advance\noflines\plusone
- % \fi
- % \divide\noflines\rigidcolumns
- %\else
- \scratchdimen\ht\rigidcolumnbox
- \divide\scratchdimen \rigidcolumns
- \getnoflines\scratchdimen
- %\fi
- \else
- \noflines\rigidcolumnlines % to be sure
- \fi
- \scratchdimen\noflines\lineheight
- % new: we now loop so that we don't loose content
- % since in practice we also use this macro for
- % funny lineheights and border cases
- \setbox0=\box\rigidcolumnbox
- \doloop
- {\setbox\rigidcolumnbox=\copy0
- \setbox\scratchbox\hpack to \savedrigidhsize
- {\dorecurse\rigidcolumns
- {\setbox\scratchbox\vsplit\rigidcolumnbox to \scratchdimen
- \dp\scratchbox\openstrutdepth
- \setbox\scratchbox\vtop
- \ifalignrigidcolumns to
- \ifstretchrigidcolumns\vsize\else\scratchdimen\fi
- \fi
- {\unvbox\scratchbox}%
- \wd\scratchbox\hsize
- \box\scratchbox
- \hfill}%
- \hfillneg}%
- \ifvoid\rigidcolumnbox\exitloop\else\advance\scratchdimen\lineheight\fi}%
- \iftightrigidcolumns
- \setbox\scratchbox\hpack{\raise\dp\scratchbox\box\scratchbox}%
- \else
- \advance\scratchdimen -\openstrutdepth
- \setbox\scratchbox\hpack{\raise\scratchdimen\box\scratchbox}%
- \dp\scratchbox\openstrutdepth
- \ht\scratchbox\scratchdimen
- \fi
- \box\scratchbox}%
- \fi}
-
-%D \macros
-%D {startvboxtohbox,stopvboxtohbox,convertvboxtohbox}
-%D
-%D Here is another of Knuth's dirty tricks, as presented on pages 398 and 399 of the
-%D \TEX book. These macros can be used like:
-%D
-%D \starttyping
-%D \vbox
-%D \bgroup
-%D \startvboxtohbox ... \stopvboxtohbox
-%D \startvboxtohbox ... \stopvboxtohbox
-%D \startvboxtohbox ... \stopvboxtohbox
-%D \egroup
-%D
-%D \vbox
-%D \bgroup
-%D \convertvboxtohbox
-%D \egroup
-%D \stoptyping
-%D
-%D These macros are used in reformatting footnotes, so they do what they're meant
-%D for.
-
-\newdimen\vboxtohboxslack
-\newdimen\hboxestohboxslack
-
-%D Create line and fake height of paragraph by messign with heights: a nice hack by
-%D DEK himself.
-
-%\unexpanded\def\setvboxtohbox
-% {\bgroup
-% \ifdim\baselineskip<16pt \relax
-% \scratchdimen\baselineskip
-% \multiply\scratchdimen 1024
-% \else
-% \message{cropping \baselineskip to 16pt}%
-% \scratchdimen\maxdimen
-% \fi
-% \divide\scratchdimen \hsize
-% \multiply\scratchdimen 64
-% \xdef\vboxtohboxfactor{\withoutpt\the\scratchdimen}%
-% \egroup}
-%
-% \unexpanded\def\startvboxtohbox
-% {\bgroup
-% \setvboxtohbox
-% \setbox\scratchbox\hbox\bgroup}
-%
-% \unexpanded\def\stopvboxtohbox
-% {\ifcase\vboxtohboxslack\else\hskip\zeropoint\!!minus\vboxtohboxslack\fi
-% \egroup
-% \dp\scratchbox\zeropoint
-% \ht\scratchbox\vboxtohboxfactor\wd\scratchbox
-% \box\scratchbox
-% \egroup}
-
-% More modern:
-
-% \definesystemattribute[vboxtohboxseparator][public]
-
-%newbox\d_syst_boxes_vboxtohbox
-\newbox\d_syst_boxes_separator
-
-\unexpanded\def\startvboxtohboxseparator
- {\setbox\d_syst_boxes_separator\hbox attr \vboxtohboxseparatorattribute\plusone\bgroup}
-
-\unexpanded\def\stopvboxtohboxseparator
- {\egroup}
-
-\unexpanded\def\startvboxtohbox
- {\begingroup
- \setbox\scratchbox\hbox\bgroup}
-
-\unexpanded\def\stopvboxtohbox
- {\ifvoid\d_syst_boxes_separator
- \hskip\zeropoint\ifcase\vboxtohboxslack\else\s!minus\vboxtohboxslack\fi % we really need a skip
- \else
- \box\d_syst_boxes_separator
- \fi
- \egroup
- \clf_hboxtovbox\scratchbox
- \box\scratchbox
- \endgroup}
-
-% A possible reconstruction:
-
-\unexpanded\def\convertvboxtohbox
- {\makehboxofhboxes
- \setbox\scratchboxone\hpack{\unhbox\scratchboxone\removehboxes}% \hpack
- \noindent\unhbox\scratchboxone\par}
-
-\unexpanded\def\makehboxofhboxes
- {\setbox\scratchboxone\emptyhbox
- \loop % \doloop { .. \exitloop .. }
- \setbox\scratchboxtwo\lastbox
- \ifhbox\scratchboxtwo
- \setbox\scratchboxone\hpack{\box\scratchboxtwo\unhbox\scratchboxone}%
- \repeat}
-
-\unexpanded\def\removehboxes
- {\setbox\scratchboxone\lastbox
- \ifhbox\scratchboxone
- {\removehboxes}\unhbox\scratchboxone
- \fi}
-
-% And one special for notes:
-
-\unexpanded\def\starthboxestohbox
- {\bgroup
- \setbox\scratchbox\vbox\bgroup}
-
-\unexpanded\def\stophboxestohbox
- {\egroup
- \clf_vboxlisttohbox\scratchbox\nextbox\dimexpr\hboxestohboxslack\relax
- \dontleavehmode
- \unhbox\nextbox
- \removeunwantedspaces
- \par
- \egroup}
-
-%D \macros
-%D {unhhbox}
-%D
-%D The next macro is used in typesetting inline headings. Let's first look at the
-%D macro and then show an example.
-
-\newbox \unhhedbox
-\newbox \hhbox
-\newdimen \lasthhboxwidth
-\newskip \hhboxindent
-
-\unexpanded\def\unhhbox#1\with#2%
- {\bgroup
- \nopenalties
- \dontcomplain
- \forgetall
- \setbox\unhhedbox\vbox{\hskip\hhboxindent\strut\unhbox#1}% => \hsize
- \doloop
- {\setbox\hhbox\vsplit\unhhedbox to \lineheight
- \ifvoid\unhhedbox
- \setbox\hhbox\hbox{\strut\hboxofvbox\hhbox}% \hpack
- \fi
- \ht\hhbox\strutht
- \dp\hhbox\strutdp
- \ifzeropt\hhboxindent\else
- \setbox\hhbox\hpack{\kern-\hhboxindent\box\hhbox}%
- \hhboxindent\zeropoint
- \fi
- \global\lasthhboxwidth\wd\hhbox
- #2\relax
- \ifvoid\unhhedbox
- \exitloop
- \else
- \hskip\zeropoint \s!plus \zeropoint
- \fi}%
- \egroup}
-
-\def\dohboxofvbox
- {\setbox0\vpack{\unvbox\scratchcounter\global\setbox1\lastbox}%
- \unhbox1
- \egroup}
-
-\unexpanded\def\hboxofvbox
- {\bgroup
- \afterassignment\dohboxofvbox
- \scratchcounter=}
-
-%D This macro can be used to break a paragraph apart and treat each line seperately,
-%D for instance, making it clickable. The main complication is that we want to be
-%D able to continue the paragraph, something that's needed in the in line section
-%D headers.
-%D
-%D \startbuffer
-%D \setbox0=\hbox{\input tufte \relax}
-%D \setbox2=\hbox{\input knuth \relax}
-%D \unhhbox0\with{\ruledhbox{\box\hhbox}}
-%D \hskip1em plus 1em minus 1em
-%D \hhboxindent=\lasthhboxwidth
-%D \advance\hhboxindent by \lastskip
-%D \unhhbox2\with{\ruledhbox{\box\hhbox}}
-%D \stopbuffer
-%D
-%D \getbuffer
-%D
-%D This piece of text was typeset by saying:
-%D
-%D \typebuffer
-%D
-%D Not that nice a definition, but effective. Note the stretch we've build in the
-%D line that connects the two paragraphs.
-
-%D \macros
-%D {doifcontent}
-%D
-%D When processing depends on the availability of content, one can give the next
-%D macro a try.
-%D
-%D \starttyping
-%D \doifcontent{pre content}{post content}{no content}\somebox
-%D \stoptyping
-%D
-%D Where \type {\somebox} is either a \type {\hbox} or \type {\vbox}. If the
-%D dimension of this box suggest some content, the resulting box is unboxed and
-%D surrounded by the first two arguments, else the third arguments is executed.
-
-\unexpanded\def\doifcontent#1#2#3%
- {\dowithnextbox
- {\ifhbox\nextbox
- \ifdim\wd\nextbox>\zeropoint
- #1\unhbox\nextbox#2\relax
- \else
- #3\relax
- \fi
- \else
- \ifdim\ht\nextbox>\zeropoint
- #1\unvbox\nextbox#2\relax
- \else
- #3\relax
- \fi
- \fi}}
-
-%D So when we say:
-%D
-%D \startbuffer
-%D \doifcontent{[}{]}{}\hbox{content sensitive typesetting}
-%D
-%D \doifcontent{}{\page}{}\vbox{content sensitive typesetting}
-%D
-%D \doifcontent{}{}{\message{Didn't you forget something?}}\hbox{}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D We get:
-%D
-%D \getbuffer
-%D
-%D Where the last call of course does not show up in this document, but definitely
-%D generates a confusing message.
-
-%D \macros
-%D {processboxes}
-%D
-%D The next macro gobble boxes and is for instance used for overlays. First we show
-%D the general handler.
-
-\newbox\processbox % public : this is the one where \nextbox's end up in
-
-\unexpanded\def\processboxes#1%
- {\bgroup
- \def\syst_boxes_process_indeed{#1}% #1 can be redefined halfway
- \setbox\processbox\emptybox
- \doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop}
-
-\def\syst_boxes_process_yes
- {\dowithnextboxcs\syst_boxes_process_content\hbox}
-
-\def\syst_boxes_process_content
- {\removeunwantedspaces
- \syst_boxes_process_indeed % takes \nextbox makes \processbox
- \doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop}
-
-\unexpanded\def\syst_boxes_process_nop
- {\removeunwantedspaces
- \box\processbox
- \egroup}
-
-%D \macros
-%D {startoverlay}
-%D
-%D We can overlay boxes by saying:
-%D
-%D \startbuffer
-%D \startoverlay
-%D {\framed{hans}}
-%D {\framed[width=3cm]{ton}}
-%D {\framed[height=2cm]{oeps}}
-%D \stopoverlay
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D shows up as:
-%D
-%D \leavevmode\getbuffer
-
-\def\boxisempty#1%
- {\ifdim\wd#1=\zeropoint
- \ifdim\ht#1=\zeropoint
- \ifdim\dp#1=\zeropoint
- \zerocount
- \else
- \plusone
- \fi
- \else
- \plusone
- \fi
- \else
- \plusone
- \fi}
-
-\def\syst_boxes_overlay_process
- {\ifcase\boxisempty\nextbox\else
- \syst_boxes_overlay_process_indeed
- \fi}
-
-\def\syst_boxes_overlay_process_indeed
- {%\removeunwantedspaces % already done
- \scratchdepth\dp\ifdim\dp\nextbox>\dp\processbox\nextbox\else\processbox\fi
- \ifdim\ht\nextbox>\ht\processbox
- \setbox\processbox\vpack to \ht\nextbox {\dp\processbox\zeropoint\vss\box\processbox\vss}%
- \else
- \setbox\nextbox \vpack to \ht\processbox{\dp\nextbox \zeropoint\vss\box\nextbox \vss}%
- \fi
- \dp\nextbox \scratchdepth
- \dp\processbox\scratchdepth
- \scratchwidth\wd\ifdim\wd\nextbox>\wd\processbox\nextbox\else\processbox\fi
- \setbox\processbox\hpack to \scratchwidth
- {\hpack to \scratchwidth{\hss\box\processbox\hss}%
- \kern-\scratchwidth
- \hpack to \scratchwidth{\hss\box\nextbox \hss}}}
-
-\unexpanded\def\startoverlay
- {\bgroup
- \let\stopoverlay\egroup
- \processboxes\syst_boxes_overlay_process}
-
-\let\stopoverlay\relax
-
-%D \macros
-%D {fakebox}
-%D
-%D The next macro is a rather silly one, but saves space.
-%D
-%D \starttyping
-%D \hbox{\fakebox0}
-%D \stoptyping
-%D
-%D returns an empty box with the dimensions of the box specified, here being zero.
-
-\unexpanded\def\fakebox
- {\bgroup
- \afterassignment\syst_boxes_fakebox_finish\scratchcounter}
-
-\def\syst_boxes_fakebox_finish
- {\setbox\scratchbox\ifhbox\scratchcounter\emptyhbox\else\emptyvbox\fi
- \wd\scratchbox\wd\scratchcounter
- \ht\scratchbox\ht\scratchcounter
- \dp\scratchbox\dp\scratchcounter
- \box\scratchbox
- \egroup}
-
-%D \macros
-%D {lbox,rbox,cbox,tbox,bbox}
-%D
-%D Here are some convenient alternative box types:
-%D
-%D \starttyping
-%D \lbox{text ...}
-%D \cbox{text ...}
-%D \rbox{text ...}
-%D \stoptyping
-%D
-%D Are similar to \type {\vbox}, which means that they also accept something like
-%D \type {to 3cm}, but align to the left, middle and right. These box types can be
-%D used to typeset paragraphs.
-
-\def\syst_boxes_lrc_process#1{\bgroup\forgetall\let\\\endgraf#1\let\next}
-
-\unexpanded\def\lbox#1#{\vbox#1\syst_boxes_lrc_process\raggedleft }
-\unexpanded\def\cbox#1#{\vbox#1\syst_boxes_lrc_process\raggedcenter}
-\unexpanded\def\rbox#1#{\vbox#1\syst_boxes_lrc_process\raggedright }
-
-\unexpanded\def\ltop#1#{\vtop#1\syst_boxes_lrc_process\raggedleft }
-\unexpanded\def\ctop#1#{\vtop#1\syst_boxes_lrc_process\raggedcenter}
-\unexpanded\def\rtop#1#{\vtop#1\syst_boxes_lrc_process\raggedright }
-
-%D The alternatives \type {\tbox} and \type {\bbox} can be used to properly align
-%D boxes, like in:
-%D
-%D \setupexternalfigures[directory={../sample}]
-%D \startbuffer
-%D \starttable[|||]
-%D \HL
-%D \VL \tbox{\externalfigure[cow][height=3cm,frame=on]} \VL top aligned \VL\SR
-%D \HL
-%D \VL \bbox{\externalfigure[cow][height=3cm,frame=on]} \VL bottom aligned \VL\SR
-%D \HL
-%D \stoptable
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D The positioning depends on the strut settings:
-%D
-%D \getbuffer
-
-\unexpanded\def\tbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox}
-\unexpanded\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox}
-
-\def\syst_boxes_tbox_finish
- {\scratchheight\ht\strutbox
- \scratchdepth\dimexpr\htdp\nextbox-\scratchheight\relax
- \ht\nextbox\scratchheight
- \dp\nextbox\scratchdepth
- \boxyoffset\nextbox-\scratchdepth
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_bbox_finish
- {\scratchdepth\dp\strutbox
- \scratchheight\dimexpr\htdp\nextbox-\scratchdepth\relax
- \dp\nextbox\scratchdepth
- \ht\nextbox\scratchheight
- \boxyoffset\nextbox-\scratchdepth
- \box\nextbox
- \egroup}
-
-%D \macros
-%D {lhbox,mhbox,rhbox}
-%D
-%D A few more boxes.
-
-\def\dodolhbox{\hpack to \hsize{\box\nextbox\hss }}
-\def\dodomhbox{\hpack to \hsize{\hss\box\nextbox\hss}}
-\def\dodorhbox{\hpack to \hsize{\hss\box\nextbox }}
-
-\unexpanded\def\lhbox{\dowithnextboxcs\dodolhbox\hbox}
-\unexpanded\def\mhbox{\dowithnextboxcs\dodomhbox\hbox}
-\unexpanded\def\rhbox{\dowithnextboxcs\dodorhbox\hbox}
-
-\let\lefthbox \lhbox
-\let\midhbox \mhbox
-\let\righthbox\rhbox
-
-%D \macros
-%D {boxofsize}
-%D
-%D Sometimes we need to construct a box with a height or width made up of several
-%D dimensions. Instead of cumbersome additions, we can use:
-%D
-%D \starttyping
-%D \boxofsize \vbox 10cm 3cm -5cm {the text to be typeset}
-%D \stoptyping
-%D
-%D This example demonstrates that one can use positive and negative values.
-%D Dimension registers are also accepted.
-
-\newdimen\sizeofbox
-
-\unexpanded\def\boxofsize#1%
- {\bgroup
- \sizeofbox\zeropoint
- \scratchdimen\zeropoint
- \def\docommand
- {\advance\sizeofbox\scratchdimen
- \futurelet\next\dodocommand}%
- \def\dodocommand
- {\ifx\next\bgroup
- \expanded{\egroup#1 to \the\sizeofbox}%
- \else
- \expandafter\afterassignment\expandafter\docommand\expandafter\scratchdimen
- \fi}%
- \docommand}
-
-%D Some new, still undocumented features:
-
-% limitatetext -> beter {text} als laatste !!
-%
-% \limitvbox
-% \limithbox
-
-\unexpanded\def\limitatelines#1#2% size sentinel
- {\dowithnextbox
- {\scratchdimen#1\hsize
- \ifdim\wd\nextbox>\scratchdimen
- \setbox\nextbox\hbox
- {\advance\scratchdimen -.1\hsize
- \limitatetext{\unhbox\nextbox}{\scratchdimen}{\nobreak#2}}%
- \fi
- \unhbox\nextbox}
- \hbox}
-
-\unexpanded\def\fittoptobaselinegrid % weg hier
- {\dowithnextbox
- {\bgroup
- \par
- \scratchdimen\ht\nextbox
- \ht\nextbox\strutht
- \dp\nextbox\strutdp
- \hpack{\box\nextbox}
- \prevdepth\strutdp
- \doloop
- {\advance\scratchdimen -\lineheight
- \ifdim\scratchdimen<\zeropoint
- \exitloop
- \else
- \nobreak
- \hpack{\strut}
- \fi}
- \egroup}
- \vbox}
-
-%D Some more undocumented macros (used in m-chart).
-
-\newif\iftraceboxplacement % \traceboxplacementtrue
-
-\newbox\fakedboxcursor
-
-\setbox\fakedboxcursor\hpack
- {\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint}
-
-\unexpanded\def\boxcursor % overloaded in core-vis
- {\iftraceboxplacement
- \bgroup
- \scratchdimen2\onepoint
- \setbox\scratchbox\hpack to \zeropoint
- {\hss
- \vrule
- \s!width \scratchdimen
- \s!height\scratchdimen
- \s!depth \scratchdimen
- \hss}%
- \smashedbox\scratchbox
- \egroup
- \else
- \copy\fakedboxcursor
- \fi}
-
-\unexpanded\def\placedbox
- {\iftraceboxplacement\ruledhbox\else\hbox\fi}
-
-\newdimen\boxoffset
-\newdimen\boxhdisplacement
-\newdimen\boxvdisplacement
-
-\unexpanded\def\rightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbox_finish \placedbox}
-\unexpanded\def\leftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbox_finish \placedbox}
-\unexpanded\def\topbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_topbox_finish \placedbox}
-\unexpanded\def\bottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_bottombox_finish \placedbox}
-\unexpanded\def\lefttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_lefttopbox_finish \placedbox}
-\unexpanded\def\righttopbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_righttopbox_finish \placedbox}
-\unexpanded\def\leftbottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox}
-\unexpanded\def\rightbottombox{\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox}
-
-\let\topleftbox \lefttopbox
-\let\toprightbox \righttopbox
-\let\bottomleftbox \leftbottombox
-\let\bottomrightbox\rightbottombox
-
-\def\syst_boxes_rightbox_finish
- {\global\boxhdisplacement\boxoffset
- \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_leftbox_finish
- {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax
- \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_topbox_finish
- {\global\boxhdisplacement-.5\wd\nextbox
- \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_bottombox_finish
- {\global\boxhdisplacement-.5\wd\nextbox
- \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_lefttopbox_finish
- {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax
- \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_righttopbox_finish
- {\global\boxhdisplacement\boxoffset
- \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_leftbottombox_finish
- {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax
- \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_rightbottombox_finish
- {\global\boxhdisplacement\boxoffset
- \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\unexpanded\def\middlebox {\hpack\bgroup\dowithnextboxcs\syst_boxes_middlebox_finish \placedbox}
-\unexpanded\def\baselinemiddlebox{\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinemiddlebox_finish\placedbox}
-\unexpanded\def\baselineleftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox}
-\unexpanded\def\baselinerightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox}
-
-\def\syst_boxes_middlebox_finish
- {\global\boxhdisplacement-.5\wd\nextbox
- \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_baselinemiddlebox_finish
- {\global\boxhdisplacement\dimexpr-.5\wd\nextbox-\boxoffset\relax
- \global\boxvdisplacement-\boxoffset
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_baselineleftbox_finish
- {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax
- \global\boxvdisplacement-\boxoffset
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_baselinerightbox_finish
- {\global\boxhdisplacement\boxoffset
- \global\boxvdisplacement-\boxoffset
- \boxcursor
- \boxxmove\nextbox \boxhdisplacement
- \boxymove\nextbox-\boxvdisplacement
- \box\nextbox
- \egroup}
-
-%D \macros
-%D {obox}
-%D
-%D Experimental, not yet frozen:
-
-\unexpanded\def\lrtbbox#1#2#3#4% l r t b
- {\bgroup
- \dowithnextboxcontent
- {\advance\hsize-#1\advance\hsize-#2\relax
- \advance\vsize-#3\advance\vsize-#4\relax}
- {\forgetall\vpack to \vsize{\vskip#3\hpack to \hsize{\hskip#1\box\nextbox\hss}\vss}\egroup}
- \vbox}
-
-%D \macros
-%D {toplinebox}
-%D
-%D See core-tbl.tex for an example of its usage:
-
-\unexpanded\def\toplinebox
- {\dowithnextboxcs\syst_boxes_toplinebox_finish\tbox}
-
-\def\syst_boxes_toplinebox_finish
- {\ifdim\dp\nextbox>\strutdepth
- \scratchdimen\dp\nextbox
- \advance\scratchdimen-\strutdepth
- \getnoflines\scratchdimen
- \struttedbox{\box\nextbox}%
- \dorecurse\noflines\verticalstrut
- \else
- \box\nextbox
- \fi}
-
-%D \macros
-%D {initializeboxstack,savebox,foundbox}
-%D
-%D At the cost of some memory, but saving box registers, we have implemented a box
-%D repository.
-%D
-%D \starttyping
-%D \initializeboxstack{one}
-%D
-%D \savebox{one}{a}{test a}
-%D \savebox{one}{p}{test p}
-%D \savebox{one}{q}{test q}
-%D
-%D \hbox{a:\foundbox{one}{a}} \par
-%D \hbox{q:\foundbox{one}{q}} \par
-%D \hbox{p:\foundbox{one}{p}} \par
-%D \hbox{x:\foundbox{one}{x}} \par
-%D \hbox{y:\foundbox{two}{a}} \par
-%D \stoptyping
-
-%D Kind of obsolete:
-
-\installcorenamespace {stackbox}
-\installcorenamespace {stacklst}
-
-\unexpanded\def\setstackbox#1#2%
- {\ifcsname\??stackbox#1:#2\endcsname\else
- \expandafter\newbox\csname\??stackbox#1:#2\endcsname
- \fi
- \global\setbox\csname\??stackbox#1:#2\endcsname\vbox}
-
-\unexpanded\def\initializeboxstack#1%
- {\def\docommand##1{\setstackbox{#1}{##1}{}}%
- \ifcsname\??stacklst#1\endcsname
- \expandafter\processcommacommand\expandafter[\lastnamedcs]\docommand
- \fi
- \letgvalueempty{\??stacklst#1}}
-
-\unexpanded\def\savebox#1#2% stack name
- {% beware, \setxvalue defines the cs beforehand so we cannot use the
- % test inside the { }
- \ifcsname\??stacklst#1\endcsname
- %\setxvalue{\??stacklst#1}{\csname\??stacklst#1\endcsname,#2}%
- \expandafter\xdef\csname\??stacklst#1\expandafter\endcsname\expandafter{\lastnamedcs,#2}%
- \else
- \expandafter\xdef\csname\??stacklst#1\endcsname{#2}%
- \fi
- \setstackbox{#1}{#2}}
-
-\unexpanded\def\flushbox#1#2% unwrapped
- {\ifcsname\??stackbox#1:#2\endcsname
- \box\lastnamedcs
- \else
- \emptybox
- \fi}
-
-\unexpanded\def\restorebox#1#2% unwrapped
- {\ifcsname\??stackbox#1:#2\endcsname
- \copy\lastnamedcs
- \else
- \emptybox
- \fi}
-
-\unexpanded\def\foundbox#1#2% wrapped
- {\vpack
- {\ifcsname\??stackbox#1:#2\endcsname
- \copy\lastnamedcs
- \fi}}
-
-\unexpanded\def\doifelsebox#1#2%
- {\ifcsname\??stackbox#1:#2\endcsname
- \ifvoid\lastnamedcs
- \doubleexpandafter\secondoftwoarguments
- \else
- \doubleexpandafter\firstoftwoarguments
- \fi
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifboxelse\doifelsebox
-
-%D This one is cheaper (the above is no longer used that much):
-
-\installcorenamespace {boxstack}
-
-\newcount\c_syst_boxes_stack
-\let \b_syst_boxes_stack\relax
-
-\unexpanded\def\syst_boxes_stack_allocate
- {\newbox\b_syst_boxes_stack
- \expandafter\let\csname\??boxstack\number\c_syst_boxes_stack\endcsname\b_syst_boxes_stack}
-
-\unexpanded\def\syst_boxes_push#1#2%
- {\global\advance\c_syst_boxes_stack\plusone
- \expandafter\let\expandafter\b_syst_boxes_stack\csname\??boxstack\number\c_syst_boxes_stack\endcsname
- \ifx\b_syst_boxes_stack\relax % cheaper then csname check as in most cases it's defined
- \syst_boxes_stack_allocate
- \fi
- #1\setbox\b_syst_boxes_stack\box#2\relax}
-
-\unexpanded\def\syst_boxes_pop#1#2%
- {#1\setbox#2\box\csname\??boxstack\number\c_syst_boxes_stack\endcsname
- \global\advance\c_syst_boxes_stack\minusone}
-
-\unexpanded\def\localpushbox {\syst_boxes_push\relax}
-\unexpanded\def\localpopbox {\syst_boxes_pop \relax}
-
-\unexpanded\def\globalpushbox{\syst_boxes_push\global}
-\unexpanded\def\globalpopbox {\syst_boxes_pop \global}
-
-%D And here is a more modern one (not yet in i-*):
-%D
-%D \starttyping
-%D \dorecurse {100} {
-%D \setbox\zerocount\hbox{test \recurselevel}
-%D \putboxincache{foo}{\recurselevel}\zerocount
-%D \copyboxfromcache{foo}{\recurselevel}\zerocount
-%D \iftrue
-%D \setbox\zerocount\hbox{\directboxfromcache{foo}{\recurselevel}}%
-%D \else
-%D \getboxfromcache{foo}{\recurselevel}\zerocount
-%D \fi
-%D }
-%D \resetboxesincache{foo}
-%D \stoptyping
-
-\unexpanded\def\putboxincache #1#2#3{\clf_putboxincache {#1}{#2}#3\relax}
-\unexpanded\def\getboxfromcache #1#2#3{\clf_getboxfromcache {#1}{#2}#3\relax}
-\unexpanded\def\doifelseboxincache #1#2{\clf_doifelseboxincache {#1}{#2}}
-\unexpanded\def\copyboxfromcache #1#2#3{\clf_copyboxfromcache {#1}{#2}#3\relax}
-\unexpanded\def\directboxfromcache #1#2{\clf_directboxfromcache {#1}{#2}}
-\unexpanded\def\directcopyboxfromcache#1#2{\clf_directcopyboxfromcache{#1}{#2}}
-\unexpanded\def\resetboxesincache #1{\clf_resetboxesincache {#1}}
-
-\unexpanded\def\putnextboxincache#1#2%
- {\dowithnextbox{\putboxincache{#1}{#2}\nextbox}}
-
-%D \macros
-%D {removedepth, obeydepth}
-%D
-%D While \type {\removedepth} removes the preceding depth, \type {\obeydepth} makes
-%D sure we have depth. Both macros leave the \type {\prevdepth} untouched.
-
-\unexpanded\def\removedepth
- {\ifvmode
- \ifdim\prevdepth>\zeropoint
- \kern-\prevdepth
- \fi
- \fi}
-
-\unexpanded\def\obeydepth
- {\par % watch out for changes in math formulas
- \ifvmode\ifdim\prevdepth<\zeropoint\orelse\ifdim\prevdepth<\strutdp
- \kern\dimexpr\strutdp-\prevdepth\relax
- \prevdepth\strutdp
- \fi\fi}
-
-\unexpanded\def\undepthed
- {\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\hbox}
-
-%D \macros
-%D {removebottomthings, removelastskip}
-%D
-%D A funny (but rather stupid) one, plus a redefinition.
-
-\unexpanded\def\removebottomthings
- {\dorecurse\plusfive{\unskip\unkern\unpenalty}}
-
-\unexpanded\def\removelastskip % \ifvmode the plain tex one \fi
- {\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi}
-
-%D \macros
-%D {makestrutofbox}
-%D
-%D This macro sets the dimensions of a box to those of a strut. Sort of obsolete so
-%D it will go away.
-
-\unexpanded\def\makestrutofbox % not used
- {\afterassignment\syst_boxes_makestrutofbox\c_boxes_register}
-
-\def\syst_boxes_makestrutofbox
- {\ht\c_boxes_register\strutht
- \dp\c_boxes_register\strutdp
- \wd\c_boxes_register\zeropoint}
-
-%D \macros
-%D {raisebox,lowerbox}
-%D
-%D Some more box stuff, related to positioning (under construction). Nice stuff for
-%D a tips and tricks maps article.
-%D
-%D \starttyping
-%D \raisebox{100pt}\hbox{test}
-%D \hsmash{\raisebox{100pt}\hbox{test}}
-%D \stoptyping
-
-\unexpanded\def\raisebox#1{\bgroup\afterassignment\syst_boxes_raise_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted
-\unexpanded\def\lowerbox#1{\bgroup\afterassignment\syst_boxes_lower_indeed\scratchdimen#1} % so both 10pt and {10pt} is accepted
-
-\def\syst_boxes_raise_indeed{\dowithnextboxcs\syst_boxes_raise_finish}
-\def\syst_boxes_lower_indeed{\dowithnextboxcs\syst_boxes_lower_finish}
-
-\def\syst_boxes_raise_finish
- {\boxyoffset\nextbox\scratchdimen
- \ht\nextbox\strutht
- \dp\nextbox\strutdp
- \box\nextbox
- \egroup}
-
-\def\syst_boxes_lower_finish
- {\boxyoffset\nextbox-\scratchdimen
- \ht\nextbox\strutht
- \dp\nextbox\strutdp
- \box\nextbox
- \egroup}
-
-% vcenter in text, we kunnen vcenter overloaden
-
-\unexpanded\def\halfwaybox
- {\hpack\bgroup
- \dowithnextboxcs\syst_boxes_halfwaybox_finish\hbox}
-
-\def\syst_boxes_halfwaybox_finish
- {\dp\nextbox\zeropoint
- \lower.5\ht\nextbox\box\nextbox
- \egroup}
-
-\unexpanded\def\depthonlybox
- {\tpack\bgroup
- \dowithnextboxcs\syst_boxes_depthonlybox_finish\vbox}
-
-\def\syst_boxes_depthonlybox_finish
- {\hsize\wd\nextbox
- \kern\zeropoint\box\nextbox
- \egroup}
-
-%D New:
-
-\def\setdimentoatleast#1#2{\ifdim#1>\zeropoint\else#1=#2\fi}
-\def\setdimentoatmost #1#2{\ifdim#1>#2\relax \else#1=#2\fi}
-
-%D And even rawer:
-
-\let\naturalvcenter\normalvtop % will go away
-
-%D \macros
-%D {vcenter}
-%D
-%D Also new: tex mode \type {\vcenter}.
-
-\unexpanded\def\vcenter
- {\vbox\bgroup
- \dowithnextboxcs\syst_boxes_vcenter_finish\vbox}
-
-\def\syst_boxes_vcenter_finish
- {\hpack{\normalstartimath\vcenter{\box\nextbox}\normalstopimath}%
- \egroup}
-
-% could be \everymathematics
-
-\prependtoks \let\vcenter\normalvcenter \to \everymath
-\prependtoks \let\vcenter\normalvcenter \to \everydisplay
-
-% \appendtoks \let\vcenter\normalvcenter \to \everymathematics
-
-%D \macros
-%D {frozenhbox}
-%D
-%D A not so well unhboxable box can be made with:
-
-\unexpanded\def\frozenhbox
- {\hpack\bgroup
- \dowithnextboxcs\syst_boxes_frozenhbox_finish\hbox}
-
-\def\syst_boxes_frozenhbox_finish
- {\hpack{\hpack{\box\nextbox}}%
- \egroup}
-
-%D \macros
-%D {setboxllx,setboxlly,gsetboxllx,gsetboxlly,getboxllx,getboxlly}
-%D
-%D A prelude to an extended \TEX\ feature:
-
-\installcorenamespace {box_x}
-\installcorenamespace {box_y}
-
-\unexpanded\def\setboxllx #1#2{\expandafter\edef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
-\unexpanded\def\setboxlly #1#2{\expandafter\edef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
-
-\unexpanded\def\gsetboxllx#1#2{\expandafter\xdef\csname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}}
-\unexpanded\def\gsetboxlly#1#2{\expandafter\xdef\csname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}}
-
-%def\getboxllx#1{\ifcsname\??box_x\number#1\endcsname\csname\??box_x\number#1\endcsname\else\zeropoint\fi}
-%def\getboxlly#1{\ifcsname\??box_y\number#1\endcsname\csname\??box_y\number#1\endcsname\else\zeropoint\fi}
-\def\getboxllx#1{\ifcsname\??box_x\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
-\def\getboxlly#1{\ifcsname\??box_y\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
-
-\def\directgetboxllx#1{\csname\??box_x\number#1\endcsname} % use when sure existence
-\def\directgetboxlly#1{\csname\??box_y\number#1\endcsname} % use when sure existence
-
-%D \macros
-%D {shownextbox}
-%D
-%D Handy for tracing
-%D
-%D \starttyping
-%D \shownextbox\vbox{test}
-%D \shownextbox\vbox{test\endgraf}
-%D \shownextbox\vbox{test\endgraf\strut\endgraf}
-%D \shownextbox\vbox{test\endgraf\thinrule}
-%D \shownextbox\vbox{\setupwhitespace[big]test\endgraf\thinrule}
-%D \stoptyping
-
-\unexpanded\def\shownextbox % seldom used
- {\dowithnextbox
- {\bgroup
- \showboxbreadth\maxdimen
- \showboxdepth \maxdimen
- \scratchcounter\interactionmode
- \batchmode
- \showbox\nextbox
- \box\nextbox
- \interactionmode\scratchcounter
- \egroup}}
-
-\unexpanded\def\spreadhbox#1% rebuilds \hbox{}
- {\bgroup
- \ifhbox#1\relax
- \setbox\scratchboxtwo\emptybox
- \unhbox#1%
- \doloop
- {\unpenalty\unskip\unpenalty\unskip\unpenalty\unskip
- \setbox\scratchboxone\lastbox
- \ifvoid\scratchboxone
- \exitloop
- \else
- \setbox\scratchboxtwo\hbox
- {\ifhbox\scratchboxone \spreadhbox\scratchboxone\else\box\scratchboxone\fi
- \ifvoid\scratchboxtwo \else\hss\unhbox\scratchboxtwo\fi}%
- \fi}%
- \ifvoid\scratchboxtwo\else\unhbox\scratchboxtwo\fi
- \else
- \box#1%
- \fi
- \egroup}
-
-% makes sense but too much log for overfull boxes:
-%
-% \showboxbreadth\maxdimen
-% \showboxdepth \maxdimen
-
-%D Moved from cont-new:
-%D
-%D \starttyping
-%D \minimalhbox 100pt {test}
-%D \stoptyping
-
-\unexpanded\def\minimalhbox#1#%
- {\dowithnextbox
- {\bgroup
- \setbox\scratchbox\hpack#1{\hss}%
- \ifdim\wd\nextbox<\wd\scratchbox\wd\nextbox\wd\scratchbox\fi
- \box\nextbox
- \egroup}
- \hbox}
-
-%D A bit dirty:
-
-\unexpanded\def\nodestostring#1#2% more tolerant for #2=\cs
- {\begingroup
- \setbox\nextbox\hbox{#2}%
- \normalexpanded{\endgroup\edef\noexpand#1{\clf_boxtostring\nextbox}}}
-
-%D Even more dirty:
-
-\let\hyphenatedhbox\hbox
-
-%D We can do this:
-%D
-%D \starttyping
-%D \setbox0\hbox to 10cm{foo} \setbox2\hbox{\unhbox0} \the\wd2
-%D \stoptyping
-%D
-%D But this saves a copy (and hpack pass):
-%D
-%D \starttyping
-%D \setbox0\hbox to 10cm{foo} \the\naturalwd0
-%D \stoptyping
-
-\newdimen\lastnaturalboxwd
-\newdimen\lastnaturalboxht
-\newdimen\lastnaturalboxdp
-
-\let\getnaturaldimensions\clf_getnaturaldimensions % sets three dimensions
-\let\naturalwd \clf_naturalwd % calculates and returns wd
-
-\let\getnaturalwd\clf_getnaturalwd % no intermediate
-\let\setnaturalwd\clf_setnaturalwd % no intermediate
-
-\unexpanded\def\doifelserighttoleftinbox{\clf_doifelserighttoleftinbox}
-
-\let\doifrighttoleftinboxelse\doifelserighttoleftinbox
-
-%D New, used in high/low:
-
-\definesystemattribute [runningtext] [public]
-
-%unexpanded\def\runninghbox{\hbox attr \runningtextattribute \plusone} % not yet in i-*
-\unexpanded\def\runninghbox{\hbox attr \runningtextattribute \fontid\font} % not yet in i-*
-
-%D To complement lua (yet undocumented):
-
-\unexpanded\def\beginhbox{\hbox\bgroup} \let\endhbox\egroup
-\unexpanded\def\beginvbox{\vbox\bgroup} \let\endvbox\egroup
-\unexpanded\def\beginvtop{\vtop\bgroup} \let\endvtop\egroup
-
-\unexpanded\def\sethboxregister#1{\setbox#1\hbox}
-\unexpanded\def\setvboxregister#1{\setbox#1\vbox}
-\unexpanded\def\setvtopregister#1{\setbox#1\vtop}
-
-\unexpanded\def\flushboxregister#1{\box\numexpr#1\relax}
-
-\unexpanded\def\starthboxregister#1{\setbox#1\hbox\bgroup} \let\stophboxregister\egroup
-\unexpanded\def\startvboxregister#1{\setbox#1\vbox\bgroup} \let\stopvboxregister\egroup
-\unexpanded\def\startvtopregister#1{\setbox#1\vtop\bgroup} \let\stopvtopregister\egroup
-
-%D For whatever third party package needs it:
-%D
-%D \starttyping
-%D \newlocalbox\BoxOne
-%D \newlocalbox\BoxTwo
-%D
-%D \setbox\BoxOne\hbox{Box One}
-%D \setbox\BoxTwo\hbox{Box Two}
-%D
-%D [\box\BoxTwo] [\box\BoxOne]
-%D \stoptyping
-
-\installcorenamespace{localbox}
-
-\unexpanded\def\newlocalbox#1%
- {\expandafter\let\expandafter#1\csname\??localbox\string#1\endcsname
- \ifx#1\relax
- \syst_aux_new_localbox#1%
- \fi}
-
-\def\syst_aux_new_localbox#1%
- {\expandafter\newbox\csname\??localbox\string#1\endcsname
- \newlocalbox#1}
-
-%D Who knows when this comes in handy:
-
-\unexpanded\def\lastlinewidth{\dimexpr\clf_lastlinewidth\scaledpoint\relax}
-
-%D Keep as reference:
-
-% \unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox}
-% \unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop}
-
-%D This one keeps dimensions and sets the shift field (and so it's more for testing
-%D than for real usage):
-
-\unexpanded\def\shiftbox {\clf_shiftbox}
-\unexpanded\def\vpackbox {\clf_vpackbox}
-\unexpanded\def\hpackbox {\clf_hpackbox}
-\unexpanded\def\vpackedbox{\clf_vpackedbox}
-\unexpanded\def\hpackedbox{\clf_hpackedbox}
-
-%D This one has been moved from a 2 decade old file. It makes something boxed
-%D sit on the baseline.
-
-\unexpanded\def\linebox
- {\hpack\bgroup\dowithnextbox
- {\scratchdimen\dimexpr\dimexpr\htdp\nextbox-\lineheight\relax/2+\dp\strutbox\relax
- \setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}%
- \ht\nextbox\ht\strutbox
- \dp\nextbox\dp\strutbox
- \box\nextbox
- \egroup}
- \hbox}
-
-\protect \endinput
-
-% a bit of test code:
-
-% \hbox \bgroup
-% \ruledvbox {\hbox{\strut gans}}
-% \ruledvbox to \lineheight {\hbox{\strut gans}}
-% \ruledvbox to \lineheight {\hbox {gans}}
-% \ruledvbox to \strutheight{\hbox {gans}}
-% \ruledvbox to \strutheight{\hbox{\strut gans}}
-% \ruledvbox to \strutheight{\vss\hbox{gans}}
-% \egroup
-
-% to be considered
-
-% \startluacode
-%
-% local spacer = lpeg.patterns.spacer
-%
-% function commands.withwords(command,str)
-% if str then
-% command = command or "ruledhbox"
-% local done = false
-% local function apply(s)
-% if done then
-% context.space()
-% done = true
-% else
-% context.dontleavehmode()
-% end
-% context[command](s)
-% end
-% lpeg.match(lpeg.splitter(spacer,apply),str)
-% end
-%
-% end
-%
-% \stopluacode
-%
-% \unprotect
-%
-% \unexpanded\def\withwordsinstring#1#2% command str
-% {\ctxcommand{withwords(\!!bs#1\!!es,\!!bs#2\!!es)}}
-%
-% \unexpanded\def\withwordsinfile#1#2% command name
-% {\ctxcommand{withwords(\!!bs#1\!!es,io.loaddata(resolvers.findfile("#2")))}}
-%
-% \protect
-%
-% \starttext
-%
-% \defineframed[colored][foregroundcolor=red,foregroundstyle=\bfc\underbar,location=low]
-%
-% \withwordsinstring{colored}{bla bla}
-% \withwordsinfile{colored}{ward.tex}
-%
-% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-dir.mkiv b/Master/texmf-dist/tex/context/base/mkiv/supp-dir.mkiv
index 277f2b7cac2..0b643709916 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-dir.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-dir.mkiv
@@ -13,41 +13,34 @@
\unprotect
-\chardef\directionlefttoright\zerocount
-\chardef\directionrighttoleft\plusone
-
-\edef\??bdir{\ifdefined\bodydir bdir\else direction\fi}
-
-\unexpanded\edef\naturalhbox {\hbox \??bdir\directionlefttoright}
-\unexpanded\edef\naturalvbox {\vbox \??bdir\directionlefttoright}
-\unexpanded\edef\naturalvtop {\vtop \??bdir\directionlefttoright}
-\unexpanded\edef\naturalhpack {\hpack \??bdir\directionlefttoright}
-\unexpanded\edef\naturalvpack {\vpack \??bdir\directionlefttoright}
-\unexpanded\edef\naturaltpack {\tpack \??bdir\directionlefttoright}
-
-\unexpanded\edef\reversehbox {\hbox \??bdir\directionrighttoleft}
-\unexpanded\edef\reversevbox {\vbox \??bdir\directionrighttoleft}
-\unexpanded\edef\reversevtop {\vtop \??bdir\directionrighttoleft}
-\unexpanded\edef\reversehpack {\hpack \??bdir\directionrighttoleft}
-\unexpanded\edef\reversevpack {\vpack \??bdir\directionrighttoleft}
-\unexpanded\edef\reversetpack {\tpack \??bdir\directionrighttoleft}
-
-\ifdefined\bodydir
- \let\bodydir \undefined \let\normalbodydir \undefined
- \let\bodydirection\undefined \let\normalbodydirection\undefined
-\fi
-
-\ifdefined\pagedir
- \let\pagedir \undefined \let\normalpagedir \undefined
- \let\pagedirection\undefined \let\normalpagedirection\undefined
-\fi
+% \immutable\chardef\directionlefttoright\zerocount
+% \immutable\chardef\directionrighttoleft\plusone
+
+\setnewconstant\directionlefttoright\zerocount
+\setnewconstant\directionrighttoleft\plusone
+
+\immutable\edef\??bdir{\ifdefined\bodydir bdir\else direction\fi}
+
+\permanent\protected\edef\naturalhbox {\hbox \??bdir\directionlefttoright}
+\permanent\protected\edef\naturalvbox {\vbox \??bdir\directionlefttoright}
+\permanent\protected\edef\naturalvtop {\vtop \??bdir\directionlefttoright}
+\permanent\protected\edef\naturalhpack {\hpack \??bdir\directionlefttoright}
+\permanent\protected\edef\naturalvpack {\vpack \??bdir\directionlefttoright}
+\permanent\protected\edef\naturaltpack {\tpack \??bdir\directionlefttoright}
+
+\permanent\protected\edef\reversehbox {\hbox \??bdir\directionrighttoleft}
+\permanent\protected\edef\reversevbox {\vbox \??bdir\directionrighttoleft}
+\permanent\protected\edef\reversevtop {\vtop \??bdir\directionrighttoleft}
+\permanent\protected\edef\reversehpack {\hpack \??bdir\directionrighttoleft}
+\permanent\protected\edef\reversevpack {\vpack \??bdir\directionrighttoleft}
+\permanent\protected\edef\reversetpack {\tpack \??bdir\directionrighttoleft}
% \expanded{\defineactivecharacter \number"2000E} {\textdirection\directionrighttoleft\relax}
% \expanded{\defineactivecharacter \number"2000F} {\textdirection\directionlefttoright\relax}
\def\syst_direction_string#1{\ifcase#1=\plusone r2l\else l2r\fi}
-\unexpanded\def\showdirsinmargin
+\permanent\protected\def\showdirsinmargin
{\normalexpanded{\inleft{\naturalhbox
{\ttxx[\syst_direction_string\pardirection,\syst_direction_string\textdirection]}}}}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-mat.mkiv b/Master/texmf-dist/tex/context/base/mkiv/supp-mat.mkiv
index f3b94f73522..8f49ac25453 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-mat.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-mat.mkiv
@@ -53,7 +53,7 @@
% \let\normalstartdmath \Ustartdisplaymath
% \let\normalstopdmath \Ustopdisplaymath
-% \unexpanded\def\Ustartdisplaymath
+% \protected\def\Ustartdisplaymath
% {\ifinner
% \ifhmode
% \normalUstartmath
@@ -67,7 +67,7 @@
% \let\Ustopdisplaymath\normalUstopdisplaymath
% \fi}
-\unexpanded\def\Ucheckedstartdisplaymath
+\protected\def\Ucheckedstartdisplaymath
{\ifinner
\ifhmode
\normalUstartmath
@@ -93,16 +93,16 @@
\let\startdmath \Ustartdisplaymath % \Ucheckedstartdisplaymath
\let\stopdmath \Ustopdisplaymath % \Ucheckedstopdisplaymath
-\unexpanded\def\mathematics#1{\relax \ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
-\unexpanded\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi}
-\unexpanded\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
-\unexpanded\def\textmath #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint
+\protected\def\mathematics#1{\relax \ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
+\protected\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi}
+\protected\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
+\protected\def\textmath #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint
\let\m\mathematics
\let\stopmathmode\relax
-\unexpanded\def\startmathmode % nested variant
+\protected\def\startmathmode % nested variant
{\relax\ifmmode
\begingroup
\let\stopmathmode\endgroup
@@ -111,7 +111,7 @@
\let\stopmathmode\normalstopimath
\fi}
-\unexpanded\def\nomathematics#1%
+\protected\def\nomathematics#1%
{\relax\ifmmode\hbox{#1}\else#1\fi}
\let\math\mathematics
@@ -126,13 +126,13 @@
\def\strc_formulas_stop_formula {\normalstopdmath }
\fi
-\unexpanded\def\displaymathematics#1{\relax\ifmmode#1\else\strc_formulas_start_formula{}#1\strc_formulas_stop_formula\fi}
-\unexpanded\def\inlinemathematics {\dontleavehmode\mathematics}
-\unexpanded\def\automathematics {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi}
+\protected\def\displaymathematics#1{\relax\ifmmode#1\else\strc_formulas_start_formula{}#1\strc_formulas_stop_formula\fi}
+\protected\def\inlinemathematics {\dontleavehmode\mathematics}
+\protected\def\automathematics {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi}
% better, esp when used in bTABLE ... eTABLE
-\unexpanded\def\automathematics
+\protected\def\automathematics
{\relax
\ifhmode
\expandafter\inlinemathematics
@@ -157,7 +157,7 @@
\def\dimensiontypeface {\tf}
\def\dimensionhalfspace {\,}
-\unexpanded\def\dimension#1%
+\protected\def\dimension#1%
{\pushmacro\dodimensionsignal
\gdef\dodimensionsignal{\kern\dimensionsignal}%
\ifzeropt\lastskip
@@ -178,7 +178,7 @@
\dodimensionsignal
\popmacro\dodimensionsignal}
-\unexpanded\def\nodimension#1%
+\protected\def\nodimension#1%
{\unskip#1\glet\dodimensionsignal\relax}
%D \macros
@@ -193,7 +193,7 @@
%D
%D \typebuffer \getbuffer
-\unexpanded\def\cramped
+\protected\def\cramped
{\mathpalette\math_cramped}
%D We force a cramped style by issuing a non||existing radical (box).
@@ -294,9 +294,9 @@
%D Notice that \type {\clap{\cramped ... }} would also work,
%D but it requires \TEX\ to typeset it arguments 16 times.
-\unexpanded\def\crampedllap{\mathpalette\math_cramped_llap}
-\unexpanded\def\crampedrlap{\mathpalette\math_cramped_rlap}
-\unexpanded\def\crampedclap{\mathpalette\math_cramped_clap}
+\protected\def\crampedllap{\mathpalette\math_cramped_llap}
+\protected\def\crampedrlap{\mathpalette\math_cramped_rlap}
+\protected\def\crampedclap{\mathpalette\math_cramped_clap}
\def\math_cramped_llap#1#2{{}\dollap{\math_cramped #1{#2}}}
\def\math_cramped_rlap#1#2{{}\dorlap{\math_cramped #1{#2}}}
@@ -304,7 +304,7 @@
% experiment, not yet to be used
-% \unexpanded\def\displaybreak
+% \protected\def\displaybreak
% {\ifhmode
% \removeunwantedspaces
% \ifcase\raggedstatus\hfill\fi
@@ -319,4 +319,11 @@
\let\nosuperscript\Unosuperscript
\let\nosubscript \Unosubscript
+% only in luametatex:
+
+\let\superprescript \Usuperprescript
+\let\subprescript \Usubprescript
+\let\nosuperprescript\Unosuperprescript
+\let\nosubsprecript \Unosubprescript
+
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-ran.lua b/Master/texmf-dist/tex/context/base/mkiv/supp-ran.lua
index 1a2d10bea72..7946370d727 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-ran.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-ran.lua
@@ -53,6 +53,9 @@ end
math.setrandomseedi = setrandomseedi
local function getrandomnumber(min,max)
+ if min > max then
+ min, max = max, min
+ end
last = random(min,max)
if trace_details then
report_system("number %s",last)
@@ -80,7 +83,8 @@ end
-- maybe stack
local function pushrandomseed()
- insert(stack,last)
+ -- insert(stack,last) -- doesn't work okay
+ insert(stack,randomseed(last) or last)
if trace_random or trace_details then
report_system("pushing seed %s",last)
end
@@ -132,6 +136,8 @@ utilities.randomizer = {
reuseseed = reuserandomseed,
popseed = poprandomseed,
get = getrandom,
+ -- the original, only for testing
+ -- mathrandom = random,
}
-- todo: also open up in utilities.randomizer.*
@@ -139,10 +145,9 @@ utilities.randomizer = {
implement { name = "getrandomnumber", actions = { getrandomnumber, context }, arguments = { "integer", "integer" } }
implement { name = "getrandomdimen", actions = { getrandomnumber, context }, arguments = { "dimen", "dimen" } }
implement { name = "getrandomfloat", actions = { getrandomnumber, context }, arguments = { "number", "number" } }
---------- { name = "getmprandomnumber", actions = { getmprandomnumber, context } }
-implement { name = "setrandomseed", actions = { setrandomseed }, arguments = { "integer" } }
-implement { name = "getrandomseed", actions = { getrandomseed, context } }
-implement { name = "pushrandomseed", actions = { pushrandomseed } }
-implement { name = "poprandomseed", actions = { poprandomseed } }
-implement { name = "reuserandomseed", actions = { reuserandomseed } }
+implement { name = "getrandomseed", actions = { getrandomseed, context } }
+implement { name = "setrandomseed", actions = setrandomseed, arguments = "integer" }
+implement { name = "pushrandomseed", actions = pushrandomseed, public = true, }
+implement { name = "poprandomseed", actions = poprandomseed, public = true, }
+implement { name = "reuserandomseed", actions = reuserandomseed, public = true, }
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-ran.mkiv b/Master/texmf-dist/tex/context/base/mkiv/supp-ran.mkiv
index 59707836aeb..52a45cf9cd0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-ran.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-ran.mkiv
@@ -13,27 +13,40 @@
\writestatus{loading}{ConTeXt Support Macros / Random Number Generation}
-%D This module is downward compatible in the sense that we've kept
-%D the user interface (which uses intermediate variables).
+%D This module is downward compatible in the sense that we've kept the user
+%D interface (which uses intermediate variables).
+%D
+%D \starttyping
+%D \type{new}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \setrandomseed{24}\type{set}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \setrandomseed{24}\type{set}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \setrandomseed{24}\type{set}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \pushrandomseed \type{new}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \poprandomseed \type{old}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \type{new}: \dorecurse{10}{\randomnumber{1}{100} }\par
+%D \stoptyping
\registerctxluafile{supp-ran}{}
\unprotect
-\unexpanded\def\getrandomcount #1#2#3{#1=\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax\relax}
-\unexpanded\def\getrandomdimen #1#2#3{#1=\clf_getrandomdimen\dimexpr#2\relax\dimexpr#3\relax\scaledpoint\relax}
-\unexpanded\def\getrandomnumber#1#2#3{\edef#1{\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax}}
-\unexpanded\def\getrandomfloat #1#2#3{\edef#1{\clf_getrandomfloat\dimexpr#2\relax\dimexpr#3\relax}}
-\unexpanded\def\setrandomseed #1{\clf_setrandomseed\numexpr#1\relax}
-\unexpanded\def\getrandomseed #1{\edef#1{\clf_getrandomseed}}
-\unexpanded\def\pushrandomseed {\clf_pushrandomseed}
-\unexpanded\def\poprandomseed {\clf_poprandomseed}
-\unexpanded\def\reuserandomseed {\clf_reuserandomseed} % within push/pop
+\protected\def\getrandomcount #1#2#3{#1=\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax\relax}
+\protected\def\getrandomdimen #1#2#3{#1=\clf_getrandomdimen\dimexpr#2\relax\dimexpr#3\relax\scaledpoint\relax}
+\protected\def\getrandomnumber#1#2#3{\edef#1{\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax}}
+\protected\def\getrandomfloat #1#2#3{\edef#1{\clf_getrandomfloat\dimexpr#2\relax\dimexpr#3\relax}}
+\protected\def\setrandomseed #1{\clf_setrandomseed\numexpr#1\relax}
+\protected\def\getrandomseed #1{\edef#1{\clf_getrandomseed}}
+\protected\def\newrandomseed {\clf_getrandomseed}
+%protected\def\pushrandomseed {\clf_pushrandomseed}
+%protected\def\poprandomseed {\clf_poprandomseed}
+%protected\def\reuserandomseed {\clf_reuserandomseed} % within push/pop
\let\freezerandomseed \pushrandomseed
\let\defrostrandomseed\poprandomseed
+\setnewconstant \mpscaledmax 4095 % for old times sake
+
\def\randomnumber #1#2{\clf_getrandomnumber\numexpr#1\relax\numexpr#2\relax}
-\let\mprandomnumber \clf_getmprandomnumber
+\def\mprandomnumber {\clf_getrandomnumber\zerocount\mpscaledmax}
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-vis.mkiv b/Master/texmf-dist/tex/context/base/mkiv/supp-vis.mkiv
index 23dfcb5fa75..f32f21ae0fa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/supp-vis.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/supp-vis.mkiv
@@ -97,7 +97,7 @@
%D unwanted results. We can therefore turn all those things
%D off with \type{\dontinterfere}.
-\unexpanded\def\dontinterfere % or maybe just forgetall
+\protected\def\dontinterfere % or maybe just forgetall
{\reseteverypar
\parindent\zeropoint
\parskip \zeropoint
@@ -114,7 +114,7 @@
\ifdefined\dontcomplain \else
- \unexpanded\def\dontcomplain
+ \protected\def\dontcomplain
{\hbadness\plustenthousand
\vbadness\plustenthousand
\hfuzz \maxdimen
@@ -316,7 +316,7 @@
\let\dowithruledbox\relax % hook
-\unexpanded\def\makeruledbox#1%
+\protected\def\makeruledbox#1%
{\boxruleht\ht#1%
\boxruledp\dp#1%
\boxrulewd\wd#1%
@@ -397,7 +397,7 @@
%D
%D \ShowBufferedExampleBox
-\unexpanded\def\ruledhbox
+\protected\def\ruledhbox
{\normalhbox\bgroup
\dowithnextboxcs\supp_visualizers_hbox_finish\normalhbox}
@@ -419,7 +419,7 @@
%D
%D \ShowBufferedExampleBox
-\unexpanded\def\ruledvbox
+\protected\def\ruledvbox
{\normalvbox\bgroup
\dowithnextboxcs\supp_visualizers_vbox_finish\normalvbox}
@@ -441,7 +441,7 @@
%D
%D \ShowBufferedExampleBox
-\unexpanded\def\ruledvtop
+\protected\def\ruledvtop
{\normalvtop\bgroup
\dowithnextboxcs\supp_visualizers_vtop_finish\normalvtop}
@@ -462,7 +462,7 @@
%D
%D \ShowBufferedExampleBox
-\unexpanded\def\ruledvcenter
+\protected\def\ruledvcenter
{\normalvbox\bgroup
\dontinterfere
\dowithnextboxcs\supp_visualizers_vcenter_finish\normalvbox}
@@ -499,7 +499,7 @@
%D At the cost of some extra macros we can implement a
%D variant that does not need the~\type{=}, but we stick to:
-\unexpanded\def\ruledbox
+\protected\def\ruledbox
{\dowithnextboxcs\supp_visualizers_box_finish}
\def\supp_visualizers_box_finish
@@ -811,11 +811,11 @@
%D All five substitutions use the same auxiliary macro. Watch
%D the positive first -- negative next approach.
-\unexpanded\def\ruledhss {\doruledhfiller\normalhss \normalhfilneg {0}{0}}
-\unexpanded\def\ruledhfil {\doruledhfiller\normalhfil \normalhfilneg {10}{-6}}
-\unexpanded\def\ruledhfill {\doruledhfiller\normalhfill \normalhfillneg{18}{-14}}
-\unexpanded\def\ruledhfilneg {\doruledhfiller\normalhfilneg \normalhfil {-6}{10}}
-\unexpanded\def\ruledhfillneg{\doruledhfiller\normalhfillneg\normalhfill {-14}{18}}
+\protected\def\ruledhss {\doruledhfiller\normalhss \normalhfilneg {0}{0}}
+\protected\def\ruledhfil {\doruledhfiller\normalhfil \normalhfilneg {10}{-6}}
+\protected\def\ruledhfill {\doruledhfiller\normalhfill \normalhfillneg{18}{-14}}
+\protected\def\ruledhfilneg {\doruledhfiller\normalhfilneg \normalhfil {-6}{10}}
+\protected\def\ruledhfillneg{\doruledhfiller\normalhfillneg\normalhfill {-14}{18}}
%D \macros
%D {ruledvss,
@@ -889,11 +889,11 @@
%D Keep in mind that \type{\vfillneg} is not part of \PLAIN\
%D \TEX, but are mimmicked by a macro.
-\unexpanded\def\ruledvss {\doruledvfiller\normalvss \normalvfilneg {2}}
-\unexpanded\def\ruledvfil {\doruledvfiller\normalvfil \normalvfilneg {-4}}
-\unexpanded\def\ruledvfill {\doruledvfiller\normalvfill \normalvfillneg{-12}}
-\unexpanded\def\ruledvfilneg {\doruledvfiller\normalvfilneg \normalvfil {8}}
-\unexpanded\def\ruledvfillneg{\doruledvfiller\normalvfillneg\normalvfill {16}}
+\protected\def\ruledvss {\doruledvfiller\normalvss \normalvfilneg {2}}
+\protected\def\ruledvfil {\doruledvfiller\normalvfil \normalvfilneg {-4}}
+\protected\def\ruledvfill {\doruledvfiller\normalvfill \normalvfillneg{-12}}
+\protected\def\ruledvfilneg {\doruledvfiller\normalvfilneg \normalvfil {8}}
+\protected\def\ruledvfillneg{\doruledvfiller\normalvfillneg\normalvfill {16}}
%D \macros
%D {ruledhskip}
@@ -999,7 +999,7 @@
\fi
\egroup}
-\unexpanded\def\ruledhskip
+\protected\def\ruledhskip
{\bgroup
\afterassignment\supp_visualizers_hskip_indeed
\scratchskip=}
@@ -1149,7 +1149,7 @@
\fi
\egroup}
-\unexpanded\def\ruledvskip
+\protected\def\ruledvskip
{\bgroup
\afterassignment\doruledvskip
\scratchskip=}
@@ -1228,7 +1228,7 @@
\afterwards\scratchskip
\egroup}
-\unexpanded\def\ruledhkern#1%
+\protected\def\ruledhkern#1%
{\bgroup
\let\afterwards#1%
\afterassignment\supp_visualizers_hkern_indeed
@@ -1317,13 +1317,13 @@
\afterwards\scratchskip
\egroup}
-\unexpanded\def\ruledvkern#1%
+\protected\def\ruledvkern#1%
{\bgroup
\let\afterwards#1\relax
\afterassignment\supp_visualizers_vkern_indeed
\scratchskip=}
-\unexpanded\def\ruledkern
+\protected\def\ruledkern
{\ifvmode
\expandafter\ruledvkern
\else
@@ -1334,7 +1334,7 @@
%D A a bit more \TEX nice solution is:
%D
%D \starttyping
-%D \unexpanded\def\ruledkern%
+%D \protected\def\ruledkern%
%D {\csname ruled\ifvmode v\else h\fi kern\endcsname\normalkern}
%D \stoptyping
@@ -1370,7 +1370,7 @@
\spacefactor\scratchcounter
\egroup}
-\unexpanded\def\ruledhglue
+\protected\def\ruledhglue
{\bgroup
\afterassignment\supp_visualizers_hglue_indeed\scratchskip=}
@@ -1400,7 +1400,7 @@
\prevdepth\nextdepth
\egroup}
-\unexpanded\def\ruledvglue
+\protected\def\ruledvglue
{\bgroup
\afterassignment\supp_visualizers_vglue_indeed\scratchskip=}
@@ -1461,7 +1461,7 @@
%D
%D \ShowBufferedExample
-\unexpanded\def\ruledmkern
+\protected\def\ruledmkern
{\bgroup
\afterassignment\supp_visualizers_mkern_indeed
\scratchmuskip=}
@@ -1485,7 +1485,7 @@
\flexibletrue
\supp_visualizers_mkern_finish\normalmskip}
-\unexpanded\def\ruledmskip
+\protected\def\ruledmskip
{\bgroup
\afterassignment\supp_visualizers_mskip_indeed
\scratchmuskip=}
@@ -1589,7 +1589,7 @@
\fi}%
\smashbox#1}
-\unexpanded\def\ruledhpenalty
+\protected\def\ruledhpenalty
{\bgroup
\afterassignment\supp_visualizers_hpenalty_indeed
\scratchcounter=}
@@ -1639,7 +1639,7 @@
%D
%D \ShowBufferedExample
-\unexpanded\def\ruledvpenalty
+\protected\def\ruledvpenalty
{\bgroup
\afterassignment\supp_visualizers_vpenalty_indeed
\scratchcounter=}
@@ -1682,7 +1682,7 @@
%D This comes together in:
-\unexpanded\def\ruledpenalty
+\protected\def\ruledpenalty
{\ifvmode
\expandafter\ruledvpenalty
\else
@@ -1698,7 +1698,7 @@
%D For those who want to manipulate the visual cues in detail,
%D we have grouped them.
-\unexpanded\def\showfils
+\protected\def\showfils
{\showingcompositiontrue
\let\hss \ruledhss
\let\hfil \ruledhfil
@@ -1711,7 +1711,7 @@
\let\vfilneg \ruledvfilneg
\let\vfillneg \ruledvfillneg}
-\unexpanded\def\dontshowfils
+\protected\def\dontshowfils
{\let\hss \normalhss
\let\hfil \normalhfil
\let\hfill \normalhfill
@@ -1723,7 +1723,7 @@
\let\vfilneg \normalvfilneg
\let\vfillneg \normalvfillneg}
-\unexpanded\def\showboxes
+\protected\def\showboxes
{\showingcompositiontrue
\baselineruletrue
\let\hbox \ruledhbox
@@ -1731,13 +1731,13 @@
\let\vtop \ruledvtop
\let\vcenter \ruledvcenter}
-\unexpanded\def\dontshowboxes
+\protected\def\dontshowboxes
{\let\hbox \normalhbox
\let\vbox \normalvbox
\let\vtop \normalvtop
\let\vcenter \normalvcenter}
-\unexpanded\def\showskips
+\protected\def\showskips
{\showingcompositiontrue
\let\hskip \ruledhskip
\let\vskip \ruledvskip
@@ -1747,7 +1747,7 @@
\let\hglue \ruledhglue
\let\vglue \ruledvglue}
-\unexpanded\def\dontshowskips
+\protected\def\dontshowskips
{\let\hskip \normalhskip
\let\vskip \normalvskip
\let\kern \normalkern
@@ -1756,11 +1756,11 @@
\let\hglue \normalhglue
\let\vglue \normalvglue}
-\unexpanded\def\showpenalties
+\protected\def\showpenalties
{\showingcompositiontrue
\let\penalty \ruledpenalty}
-\unexpanded\def\dontshowpenalties
+\protected\def\dontshowpenalties
{\let\penalty \normalpenalty}
%D \macros
@@ -1787,7 +1787,7 @@
\newif\ifshowingcomposition
-\unexpanded\def\showcomposition
+\protected\def\showcomposition
{\ifshowingcomposition
\showfils
\showboxes
@@ -1795,7 +1795,7 @@
\showpenalties
\fi}
-\unexpanded\def\dontshowcomposition
+\protected\def\dontshowcomposition
{\ifshowingcomposition
\dontshowfils
\dontshowboxes
@@ -1829,7 +1829,7 @@
\def\defaulttestrulewidth{.02\bodyfontsize}
\fi
-\unexpanded\def\showmakeup
+\protected\def\showmakeup
{\testrulewidth\defaulttestrulewidth
\showingcompositiontrue
\showcomposition}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/symb-emj.mkiv b/Master/texmf-dist/tex/context/base/mkiv/symb-emj.mkiv
index e063b6a7a13..7bfe4c0232a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/symb-emj.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/symb-emj.mkiv
@@ -23,5 +23,4 @@
\unexpanded\def\emoji #1{\dontleavehmode{\setdirectsymbolicfont{emoji}\clf_resolvedemoji{#1}}}
\unexpanded\def\robustemoji #1{\dontleavehmode{\setdirectsymbolicfont{emoji}\clf_checkedemoji {#1}}}
-
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/symb-imp-cc.mkiv b/Master/texmf-dist/tex/context/base/mkiv/symb-imp-cc.mkiv
index e753d695f8c..d9f596b9c72 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/symb-imp-cc.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/symb-imp-cc.mkiv
@@ -69,8 +69,8 @@
\unexpanded\def\creativecommons#1%
{\dontleavehmode\lower.15\exheight\hbox\bgroup
- \let\inbetween\relax
- \processseparatedlist[#1][-]{\inbetween\let\inbetween\enspace\directsymbol{cc}}%
+ \overloaded\let\inbetween\relax
+ \processseparatedlist[#1][-]{\inbetween\overloaded\let\inbetween\enspace\directsymbol{cc}}%
\egroup}
\definesymbol [cc-by-sa-nc] [\creativecommons{cc-by-sa-nc}]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/symb-imp-mis.mkiv b/Master/texmf-dist/tex/context/base/mkiv/symb-imp-mis.mkiv
index 2320ea59ae0..b02233baaf0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/symb-imp-mis.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/symb-imp-mis.mkiv
@@ -72,9 +72,9 @@
\definesymbol [numero] [\textnumero]
\definesymbol [euro] [\texteuro]
-\let\euro\texteuro
+\aliased\let\euro\texteuro
-\def\Numero{\symbol[Numero]} % obsolete
-\def\numero{\symbol[numero]} % obsolete
+\permanent\protected\def\Numero{\symbol[Numero]} % obsolete
+\permanent\protected\def\numero{\symbol[numero]} % obsolete
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/symb-imp-nav.mkiv b/Master/texmf-dist/tex/context/base/mkiv/symb-imp-nav.mkiv
index 6e2f2c1f034..ce5b1d76afa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/symb-imp-nav.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/symb-imp-nav.mkiv
@@ -24,7 +24,7 @@
\definefontsynonym [ContextNavigation] [contnav]
-\def\ContextNavigationGlyph{\getnamedglyphdirect{ContextNavigation}} % #1
+\permanent\protected\def\ContextNavigationGlyph{\getnamedglyphdirect{ContextNavigation}} % #1
\startsymbolset [navigation 1]
@@ -122,8 +122,15 @@
\stopsymbolset
-%D \showsymbolset[navigation 1]
-%D \showsymbolset[navigation 2]
-%D \showsymbolset[navigation 3]
+\protect
-\protect \endinput
+\continueifinputfile{symb-imp-nav.mkiv}
+
+\starttext
+ \showsymbolset[navigation 1]\page
+ \showsymbolset[navigation 2]\page
+ \showsymbolset[navigation 3]\page
+ \ContextNavigationGlyph{char03}\quad
+ \ContextNavigationGlyph{char67}\quad
+ \ContextNavigationGlyph{charcb}
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkiv/symb-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/symb-ini.lua
index 588e5d2ab5c..c0e717f465b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/symb-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/symb-ini.lua
@@ -21,7 +21,6 @@ local report_symbols = logs.reporter ("fonts","symbols")
local status_symbols = logs.messenger("fonts","symbols")
local patterns = {
- CONTEXTLMTXMODE > 0 and "symb-imp-%s.mkxl" or "",
"symb-imp-%s.mkiv",
"symb-imp-%s.tex",
-- obsolete:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-aux.lua b/Master/texmf-dist/tex/context/base/mkiv/syst-aux.lua
index 46bb8e3f748..85604a2327d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-aux.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-aux.lua
@@ -1,4 +1,4 @@
-if not modules then modules = { } end modules ['syst-aux'] = {
+ if not modules then modules = { } end modules ['syst-aux'] = {
version = 1.001,
comment = "companion to syst-aux.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -11,20 +11,19 @@ if not modules then modules = { } end modules ['syst-aux'] = {
-- utfmatch(str,"(.?)(.*)$")
-- utf.sub(str,1,1)
-local tonumber, next = tonumber, next
+local tonumber, next, type = tonumber, next, type
local utfsub = utf.sub
local P, S, R, C, Cc, Cs, Carg, lpegmatch = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Carg, lpeg.match
-local next = next
-local find = string.find
+local find, formatters = string.find, string.formatters
local context = context
local implement = interfaces.implement
-local formatters = string.formatters
+local setmacro = interfaces.setmacro
local setcatcode = tex.setcatcode
+local texget = tex.get
local utf8character = lpeg.patterns.utf8character
local settings_to_array = utilities.parsers.settings_to_array
local settings_to_set = utilities.parsers.settings_to_set
-local setmacro = interfaces.setmacro
local pattern = C(utf8character^-1) * C(P(1)^0)
@@ -131,115 +130,14 @@ local sentinel = spaces * (nohash^1 / "\\%0")
local sargument = (single * digit)^1
local dargument = (double * digit)^1
--- first variant:
---
--- local texpreamble = nil
--- local usespaces = nil
---
--- local pattern = Cs( -- ^-1
--- ( P("spaces") / function() usespaces = true return "" end )^0
--- * spaces
--- * ( P("nospaces") / function() usespaces = false return "" end )^0
--- * spaces
--- * ( P("global") / "\\global" )^0
--- * spaces
--- * ( P("unexpanded") / "\\unexpanded" )^0
--- * spaces
--- * Cc("\\expandafter\\")
--- * spaces
--- * ( P("expanded") / "e" )^0
--- * spaces
--- * ( P((1-S(" #"))^1) / "def\\csname %0\\endcsname" )
--- * spaces
--- * (
--- -- (double * digit)^1 * sentinel^-1 * double^-1
--- -- + (single * digit)^1 * sentinel^-1 * single^-1
--- ( P("[") * dargument * P("]") + dargument)^1 * sentinel^-1 * double^-1
--- + ( P("[") * sargument * P("]") + sargument)^1 * sentinel^-1 * single^-1
--- + sentinel^-1 * (double+single)^-1
--- )
--- )
---
--- local ctx_dostarttexdefinition = context.dostarttexdefinition
---
--- local function texdefinition_one(str)
--- usespaces = nil
--- texpreamble = lpegmatch(pattern,str)
--- if usespaces == true then
--- setcatcode(32,10) -- space
--- setcatcode(13, 5) -- endofline
--- elseif usespaces == false then
--- setcatcode(32, 9) -- ignore
--- setcatcode(13, 9) -- ignore
--- else
--- -- this is default
--- -- setcatcode(32,10) -- space
--- -- setcatcode(13, 9) -- ignore
--- end
--- ctx_dostarttexdefinition()
--- end
---
--- local function texdefinition_two()
--- context(texpreamble)
--- end
-
--- second variant:
---
--- -- default:
--- --
--- -- setcatcode(32,10) -- space
--- -- setcatcode(13, 9) -- ignore
---
--- local function catcodes_s()
--- setcatcode(32,10) -- space
--- setcatcode(13, 5) -- endofline
--- return ""
--- end
---
--- local function catcodes_n()
--- setcatcode(32, 9) -- ignore
--- setcatcode(13, 9) -- ignore
--- return ""
--- end
---
--- local pattern = Cs( -- ^-1
--- ( P("spaces") * space / catcodes_s )^0
--- * spaces * ( P("nospaces") * space / catcodes_n )^0
--- * spaces * ( P("global") * space / "\\global" )^0
--- * spaces * ( P("unexpanded") * space / "\\unexpanded" )^0
--- * spaces * Cc("\\expandafter\\")
--- * spaces * ( P("expanded") / "e" )^0
--- * spaces * ( P((1-S(" #["))^1) / "def\\csname %0\\endcsname" )
--- * spaces * (
--- -- (double * digit)^1 * sentinel^-1 * double^-1
--- -- + (single * digit)^1 * sentinel^-1 * single^-1
--- ( P("[") * dargument * P("]") + dargument)^1 * sentinel^-1 * double^-1
--- + ( P("[") * sargument * P("]") + sargument)^1 * sentinel^-1 * single^-1
--- + sentinel^-1 * (double+single)^-1
--- )
--- )
---
--- local texpreamble = nil
---
--- local ctx_dostarttexdefinition = context.dostarttexdefinition
---
--- local function texdefinition_one(str)
--- texpreamble = lpegmatch(pattern,str)
--- ctx_dostarttexdefinition()
--- end
---
--- local function texdefinition_two()
--- context(texpreamble)
--- end
-
-- third variant:
-local global = nil
-local unexpanded = nil
-local expanded = nil
-local optional = nil
-local csname = nil
-local rest = nil
+local global = nil
+local protected = nil
+local expanded = nil
+local optional = nil
+local csname = nil
+local rest = nil
local function catcodes_s()
setcatcode(32,10) -- space
@@ -264,12 +162,23 @@ local option = (
) * (P("empty") + P("argument"))
local pattern = (
- ( P("spaces") * space / catcodes_s )^0
- * spaces * ( P("nospaces") * space / catcodes_n )^0
- * spaces * ( P("global") * space * Cc(true) + Cc(false) )
- * spaces * ( P("unexpanded") * space * Cc(true) + Cc(false) )
- * spaces * ( P("expanded") * space * Cc(true) + Cc(false) )
- * spaces * ( C(option) * space + Cc(false) )
+ (
+ spaces * (
+ ( P("spaces") * space / catcodes_s )
+ + ( P("nospaces") * space / catcodes_n )
+ + ( P("global") * space / function() global = true end )
+ + ( P("protected") * space / function() protected = true end)
+ + ( P("permanent") * space )
+ + ( P("expanded") * space / function() expanded = true end)
+ + ( P("tolerant") * space )
+ + ( P("instance") * space )
+ + ( P("frozen") * space )
+ + ( P("mutable") * space )
+ + ( P("immutable") * space )
+ + ( P("unexpanded") * space / function() protected = true end)
+ + ( C(option) * space / function(s) optional = s end)
+ )
+ )^0
* spaces * ( C((1-S(" #["))^1) )
* spaces * Cs(
( P("[") * dargument * P("]") + dargument)^1 * sentinel^-1 * double^-1
@@ -281,40 +190,29 @@ local pattern = (
local ctx_dostarttexdefinition = context.dostarttexdefinition
local function texdefinition_one(str)
- global, unexpanded, expanded, optional, csname, rest = lpegmatch(pattern,str)
+ global = false
+ protected = false
+ expanded = false
+ optional = false
+ csname, rest = lpegmatch(pattern,str)
ctx_dostarttexdefinition()
end
local function texdefinition_two()
if optional then
context (
- [[\unexpanded\expandafter]] ..
- (global and [[\xdef]] or [[\edef]]) ..
- [[\csname ]] ..
- csname ..
- [[\endcsname{\expandafter\noexpand\expandafter\do]] ..
- optional ..
- [[\csname _do_]] ..
- csname ..
- -- [[_\endcsname}\unexpanded\expandafter]] ..
- [[_\endcsname}\expandafter]] ..
- (global and [[\gdef]] or [[\edef]]) ..
- [[\csname _do_]] ..
- csname ..
- [[_\endcsname ]] ..
+ (protected and [[\protected]] or "") ..
+ [[\expandafter]] .. (global and [[\xdef]] or [[\edef]]) ..
+ [[\csname ]] .. csname .. [[\endcsname{\expandafter\noexpand\expandafter\do]] .. optional ..
+ [[\csname _do_]] .. csname .. [[_\endcsname}\expandafter]] .. (global and [[\gdef]] or [[\edef]]) ..
+ [[\csname _do_]] .. csname .. [[_\endcsname ]] ..
rest
)
else
context (
- [[\unexpanded\expandafter]] ..
- ( global and (
- expanded and [[\xdef]] or [[\gdef]]
- ) or (
- expanded and [[\edef]] or [[\def]]
- ) ) ..
- [[\csname ]] ..
- csname ..
- [[\endcsname ]] ..
+ (protected and [[\protected]] or "") ..
+ [[\expandafter]] .. (global and (expanded and [[\xdef]] or [[\gdef]]) or (expanded and [[\edef]] or [[\def]])) ..
+ [[\csname ]] .. csname .. [[\endcsname ]] ..
rest
)
end
@@ -404,6 +302,20 @@ implement {
end
}
+implement {
+ name = "elapsedsteptime",
+ arguments = "integer",
+ actions = function(n)
+ statistics.stoptiming("whatever")
+ local t = statistics.elapsed("whatever")/(n > 0 and n or 1)
+ if t > 0 then
+ context("%0.9f",t)
+ else
+ context(0)
+ end
+ end
+}
+
local accuracy = table.setmetatableindex(function(t,k)
local v = formatters["%0." ..k .. "f"]
t[k] = v
@@ -771,15 +683,58 @@ implement {
local bp = number.dimenfactors.bp
-interfaces.implement {
+implement {
name = "tobigpoints",
actions = function(d) context("%.5F",bp * d) end,
arguments = "dimension",
}
-interfaces.implement {
+implement {
name = "towholebigpoints",
actions = function(d) context("%r",bp * d) end,
arguments = "dimension",
}
+-- for now here:
+
+local function getshape(s)
+ local t = texget(s)
+ local n = t and #t or 0
+ context(n)
+ if n > 0 then
+ for i=1,n do
+ local ti = t[i]
+ if type(ti) == "table" then
+ context(" %isp %isp",ti[1],ti[2])
+ else
+ context(" %i",ti)
+ end
+ end
+ end
+end
+
+implement {
+ name = "getparshape",
+ public = true,
+ actions = function() getshape("parshape") end,
+}
+implement {
+ name = "getclubpenalties",
+ public = true,
+ actions = function() getshape("clubpenalties") end,
+}
+implement {
+ name = "getinterlinepenalties",
+ public = true,
+ actions = function() getshape("interlinepenalties") end,
+ }
+implement {
+ name = "getdisplaywidowpenalties",
+ public = true,
+ actions = function() getshape("displaywidowpenalties") end,
+}
+implement {
+ name = "getwidowpenalties",
+ public = true,
+ actions = function() getshape("widowpenalties") end,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkiv
index 255f0746c39..194f1de2cb1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkiv
@@ -12,6 +12,7 @@
%C details.
\registerctxluafile{syst-aux}{}
+\registerctxluafile{syst-mac}{}
% A dedicated primitive \ifvoidmacro\cs == \ifx\cs\empty is some 10% faster but
% probably not that noticeable in practice. An \ifvoidtoks might make sense but we
@@ -47,7 +48,7 @@
%D code.
%D
%D \starttyping
-%D \unexpanded\def\somecommand{... ... ...}
+%D \protected\def\somecommand{... ... ...}
%D \stoptyping
%D
%D This overloads the \ETEX\ primitive but as we already had an \MKII\ solution we
@@ -55,21 +56,10 @@
\let\unexpanded\normalprotected
-\ifcase\contextlmtxmode
-
- \def\startlmtxmode#1\stoplmtxmode{}
- \let\stoplmtxmode \relax
- \let\startmkivmode\relax
- \let\stopmkivmode \relax
-
-\else
-
- \let\startlmtxmode\relax
- \let\stoplmtxmode \relax
- \def\startmkivmode#1\stopmkivmode{}
- \let\stopmkivmode \relax
-
-\fi
+\def\startlmtxmode#1\stoplmtxmode{}
+\let\stoplmtxmode \relax
+\let\startmkivmode\relax
+\let\stopmkivmode \relax
%D As we don't have namespace definers yet, we use a special one:
@@ -86,7 +76,7 @@
\fi
-\unexpanded\def\installsystemnamespace#1% maybe move this to syst-ini
+\protected\def\installsystemnamespace#1% maybe move this to syst-ini
{\ifcsname ??#1\endcsname
\writestatus\m!system{duplicate system namespace '#1'}\wait
\else
@@ -198,10 +188,10 @@
\let\m_syst_helpers_expanded\empty
-\unexpanded\def\expanded#1%
+\protected\def\expanded#1%
{\xdef\m_syst_helpers_expanded{\noexpand#1}\m_syst_helpers_expanded}
-\unexpanded\def\startexpanded#1\stopexpanded
+\protected\def\startexpanded#1\stopexpanded
{\xdef\m_syst_helpers_expanded{#1}\m_syst_helpers_expanded}
\let\stopexpanded\relax
@@ -296,13 +286,13 @@
\expandafter\m_syst_action_nop
\fi}
-\unexpanded\def\doifelsenextchar#1#2#3% #1 should not be {} !
+\protected\def\doifelsenextchar#1#2#3% #1 should not be {} !
{\let\charactertoken=#1% = needed here
\def\m_syst_action_yes{#2}%
\def\m_syst_action_nop{#3}%
\futurelet\nexttoken\syst_helpers_inspect_next_character}
-\unexpanded\def\doifelsenextcharcs#1#2#3% #1 should not be {} !
+\protected\def\doifelsenextcharcs#1#2#3% #1 should not be {} !
{\let\charactertoken=#1% = needed here
\let\m_syst_action_yes#2%
\let\m_syst_action_nop#3%
@@ -343,13 +333,13 @@
\expandafter\m_syst_action_nop
\fi}
-\unexpanded\def\doifelsenextoptional#1#2%
+\protected\def\doifelsenextoptional#1#2%
{\def\m_syst_action_yes{#1}%
\def\m_syst_action_nop{#2}%
\let\if_next_blank_space_token\iffalse
\futurelet\nexttoken\syst_helpers_inspect_next_optional_character}
-\unexpanded\def\doifelsenextoptionalcs#1#2% \cs \cs (upto 10% faster)
+\protected\def\doifelsenextoptionalcs#1#2% \cs \cs (upto 10% faster)
{\let\m_syst_action_yes#1%
\let\m_syst_action_nop#2%
\let\if_next_blank_space_token\iffalse
@@ -360,14 +350,14 @@
% fails on assignments
%
-% \unexpanded\def\doifelsenextoptional {\afterassignment\doifelsenextoptional_n \def\m_syst_action_yes}
-% \def\doifelsenextoptional_n {\afterassignment\doifelsenextoptional_n_n\def\m_syst_action_nop}
-% \def\doifelsenextoptional_n_n {\let\if_next_blank_space_token\iffalse
+% \protected\def\doifelsenextoptional {\afterassignment\doifelsenextoptional_n \def\m_syst_action_yes}
+% \def\doifelsenextoptional_n {\afterassignment\doifelsenextoptional_n_n\def\m_syst_action_nop}
+% \def\doifelsenextoptional_n_n {\let\if_next_blank_space_token\iffalse
% \futurelet\nexttoken\syst_helpers_inspect_next_optional_character}
%
-% \unexpanded\def\doifelsenextoptionalcs {\afterassignment\doifelsenextoptionalcs_n \let\m_syst_action_yes}
-% \def\doifelsenextoptionalcs_n {\afterassignment\doifelsenextoptionalcs_n_n\let\m_syst_action_nop}
-% \def\doifelsenextoptionalcs_n_n{\let\if_next_blank_space_token\iffalse
+% \protected\def\doifelsenextoptionalcs {\afterassignment\doifelsenextoptionalcs_n \let\m_syst_action_yes}
+% \def\doifelsenextoptionalcs_n {\afterassignment\doifelsenextoptionalcs_n_n\let\m_syst_action_nop}
+% \def\doifelsenextoptionalcs_n_n{\let\if_next_blank_space_token\iffalse
% \futurelet\nexttoken\syst_helpers_inspect_next_optional_character}
\let\syst_helpers_next_bgroup_character_token\bgroup
@@ -386,13 +376,13 @@
\expandafter\m_syst_action_nop
\fi}
-\unexpanded\def\doifelsenextbgroup#1#2%
+\protected\def\doifelsenextbgroup#1#2%
{\def\m_syst_action_yes{#1}%
\def\m_syst_action_nop{#2}%
\let\if_next_blank_space_token\iffalse
\futurelet\nexttoken\syst_helpers_inspect_next_bgroup_character}
-\unexpanded\def\doifelsenextbgroupcs#1#2%
+\protected\def\doifelsenextbgroupcs#1#2%
{\let\m_syst_action_yes#1%
\let\m_syst_action_nop#2%
\let\if_next_blank_space_token\iffalse
@@ -417,7 +407,7 @@
\expandafter\m_syst_action_nop
\fi}
-\unexpanded\def\doifelsenextparenthesis#1#2%
+\protected\def\doifelsenextparenthesis#1#2%
{\def\m_syst_action_yes{#1}%
\def\m_syst_action_nop{#2}%
\let\if_next_blank_space_token\iffalse
@@ -434,12 +424,12 @@
\expandafter\m_syst_action_nop
\fi}
-\unexpanded\def\doifelsefastoptionalcheck#1#2%
+\protected\def\doifelsefastoptionalcheck#1#2%
{\def\m_syst_action_yes{#1}%
\def\m_syst_action_nop{#2}%
\futurelet\nexttoken\syst_helpers_do_if_fast_optional_check_else}
-\unexpanded\def\doifelsefastoptionalcheckcs#1#2% \cs \cs
+\protected\def\doifelsefastoptionalcheckcs#1#2% \cs \cs
{\let\m_syst_action_yes#1%
\let\m_syst_action_nop#2%
\futurelet\nexttoken\syst_helpers_do_if_fast_optional_check_else}
@@ -455,7 +445,7 @@
%D {a few lines later}
%D \stoptyping
-% \unexpanded\def\assumelongusagecs#1%
+% \protected\def\assumelongusagecs#1%
% {\let\m_syst_action#1%
% \futurelet\nexttoken\syst_helpers_ignore_par_character}
%
@@ -476,7 +466,7 @@
% \def\syst_helpers_ignore_par_partoken
% {\afterassignment\m_syst_action\let\nexttoken}
-\unexpanded\def\assumelongusagecs#1%
+\protected\def\assumelongusagecs#1%
{\let\m_syst_action#1%
\futurelet\nexttoken\syst_helpers_ignore_spacing}
@@ -590,12 +580,12 @@
\def\undefinevalue#1{\expandafter\let \csname#1\endcsname\undefined}
\def\ignorevalue#1#2{\expandafter\let \csname#1\endcsname\empty}
-\def\setuvalue #1{\normalprotected\expandafter \def\csname#1\endcsname}
-\def\setuevalue #1{\normalprotected\expandafter\edef\csname#1\endcsname}
-\def\setugvalue #1{\normalprotected\expandafter\gdef\csname#1\endcsname}
-\def\setuxvalue #1{\normalprotected\expandafter\xdef\csname#1\endcsname}
+\def\setuvalue #1{\protected\expandafter \def\csname#1\endcsname}
+\def\setuevalue #1{\protected\expandafter\edef\csname#1\endcsname}
+\def\setugvalue #1{\protected\expandafter\gdef\csname#1\endcsname}
+\def\setuxvalue #1{\protected\expandafter\xdef\csname#1\endcsname}
-\unexpanded\def\getuvalue#1{\csname#1\endcsname}
+\protected\def\getuvalue#1{\csname#1\endcsname}
%D \macros
%D {globallet,glet}
@@ -670,13 +660,13 @@
%D {\undefined}! In \ETEX\ we have \type {\ifcsname} and that way of testing on
%D existance is not the same as the one described here. Therefore we introduce:
-\unexpanded\def\letbeundefined#1% potential stack buildup when used \global
+\protected\def\letbeundefined#1% potential stack buildup when used \global
{\expandafter\let\csname#1\endcsname\undefined} % or use \undefinevalue to match \setvalue
-\unexpanded\def\localundefine#1% conditional
+\protected\def\localundefine#1% conditional
{\ifcsname#1\endcsname\expandafter\let\csname#1\endcsname\undefined\fi}
-\unexpanded\def\globalundefine#1% conditional
+\protected\def\globalundefine#1% conditional
{\ifcsname#1\endcsname\expandafter\glet\csname#1\endcsname\undefined\fi}
%D Beware, being \type {\undefined} in \ETEX\ means that the macro {\em is} defined!
@@ -685,7 +675,7 @@
%D behavior in text and math mode, which was due to this grouping subtilities. We
%D therefore decided to use \type{\begingroup} instead of \type{\bgroup}.
-\unexpanded\def\doifelsealldefined#1%
+\protected\def\doifelsealldefined#1%
{\begingroup
\donetrue % we could use a reserved one and avoid the group
\processcommalist[#1]\syst_helpers_do_if_all_defined_else
@@ -720,7 +710,7 @@
%D \doifelse {string1} {string2} {then ...}{else ...}
%D \stoptyping
-\unexpanded\def\doif#1#2%
+\protected\def\doif#1#2%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -729,7 +719,7 @@
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifnot#1#2%
+\protected\def\doifnot#1#2%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -738,7 +728,7 @@
\expandafter\firstofoneargument
\fi}
-\unexpanded\def\doifelse#1#2%
+\protected\def\doifelse#1#2%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -760,7 +750,7 @@
%D
%D This time, the string is not expanded.
-\unexpanded\def\doifelseempty#1%
+\protected\def\doifelseempty#1%
{\def\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\firstoftwoarguments
@@ -770,7 +760,7 @@
\let\doifemptyelse\doifelseempty
-\unexpanded\def\doifempty#1%
+\protected\def\doifempty#1%
{\def\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\firstofoneargument
@@ -778,7 +768,7 @@
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifnotempty#1%
+\protected\def\doifnotempty#1%
{\def\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\gobbleoneargument
@@ -835,7 +825,7 @@
% \def\syst_helpers_re_do_if_in_set {\expandafter\syst_helpers_do_check_if_item_in_set \m_syst_string_two,],\relax}
% \def\syst_helpers_re_do_if_not_in_set {\expandafter\syst_helpers_do_check_if_item_not_in_set \m_syst_string_two,],\relax}
%
-% \unexpanded\def\doifelseinset#1% make this two step too
+% \protected\def\doifelseinset#1% make this two step too
% {\edef\m_syst_string_one{#1}%
% \ifx\m_syst_string_one\empty
% \expandafter\thirdofthreearguments
@@ -853,7 +843,7 @@
% \expandafter\syst_helpers_re_do_if_in_set_else
% \fi}
%
-% \unexpanded\def\doifinset#1%
+% \protected\def\doifinset#1%
% {\edef\m_syst_string_one{#1}%
% \ifx\m_syst_string_one\empty
% \expandafter\gobbletwoarguments
@@ -869,7 +859,7 @@
% \expandafter\syst_helpers_re_do_if_in_set
% \fi}
%
-% \unexpanded\def\doifnotinset#1%
+% \protected\def\doifnotinset#1%
% {\edef\m_syst_string_one{#1}%
% \ifx\m_syst_string_one\empty
% \expandafter\secondoftwoarguments
@@ -951,9 +941,9 @@
% \expandafter\syst_helpers_do_check_if_item_not_in_set
% \fi}
-\unexpanded\def\doifelseinset#1#2{\clf_doifelseinset{#1}{#2}}
-\unexpanded\def\doifinset #1#2{\clf_doifinset {#1}{#2}}
-\unexpanded\def\doifnotinset #1#2{\clf_doifnotinset {#1}{#2}}
+\protected\def\doifelseinset#1#2{\clf_doifelseinset{#1}{#2}}
+\protected\def\doifinset #1#2{\clf_doifinset {#1}{#2}}
+\protected\def\doifnotinset #1#2{\clf_doifnotinset {#1}{#2}}
% \let\firstinset \clf_firstinset
\let\doifinsetelse\doifelseinset
@@ -1042,15 +1032,15 @@
% \fi\fi
% #1#2}
-% \unexpanded\def\doifelsecommon{\syst_helpers_do_do_if_common_else\firstoftwoarguments\secondoftwoarguments}
-% \unexpanded\def\doifcommon {\syst_helpers_do_do_if_common_else\firstofoneargument \gobbleoneargument }
-% \unexpanded\def\doifnotcommon {\syst_helpers_do_do_if_common_else\gobbleoneargument \firstofoneargument }
+% \protected\def\doifelsecommon{\syst_helpers_do_do_if_common_else\firstoftwoarguments\secondoftwoarguments}
+% \protected\def\doifcommon {\syst_helpers_do_do_if_common_else\firstofoneargument \gobbleoneargument }
+% \protected\def\doifnotcommon {\syst_helpers_do_do_if_common_else\gobbleoneargument \firstofoneargument }
%
% \let\doifcommonelse\doifelsecommon
-\unexpanded\def\doifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}}
-\unexpanded\def\doifcommon #1#2{\clf_doifcommon {#1}{#2}}
-\unexpanded\def\doifnotcommon #1#2{\clf_doifnotcommon {#1}{#2}}
+\protected\def\doifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}}
+\protected\def\doifcommon #1#2{\clf_doifcommon {#1}{#2}}
+\protected\def\doifnotcommon #1#2{\clf_doifnotcommon {#1}{#2}}
\let\doifcommonelse\doifelsecommon
@@ -1122,7 +1112,7 @@
%D Empty arguments are not processed. Empty items (\type {,,}) however are
%D treated. We have to check for the special case \type {[{a,b,c}]}.
-\unexpanded\def\processcommalist[%
+\protected\def\processcommalist[%
{\futurelet\nexttoken\syst_helpers_do_check_comma_item}
\def\syst_helpers_do_check_comma_item
@@ -1151,13 +1141,13 @@
%D One way of quitting a commalist halfway is:
-\unexpanded\def\quitcommalist
+\protected\def\quitcommalist
{\begingroup\let\syst_helpers_do_process_comma_item\syst_helpers_do_quit_comma_list}
\def\syst_helpers_do_quit_comma_list#1]%
{\endgroup}
-\unexpanded\def\quitprevcommalist
+\protected\def\quitprevcommalist
{\begingroup\let\syst_helpers_do_process_comma_item\syst_helpers_do_quit_prev_comma_list}
\def\syst_helpers_do_quit_prev_comma_list#1]%
@@ -1208,7 +1198,7 @@
%D Commands that are part of the list are expanded, so the use of this macro has its
%D limits.
-\unexpanded\def\processcommacommand[#1]%
+\protected\def\processcommacommand[#1]%
{\normalexpanded{\processcommalist[#1]}}
%D The argument to \type{\command} is not delimited. Because we often use \type {[]}
@@ -1224,7 +1214,7 @@
%D \def\command[#1]{... #1 ...}
%D \stoptyping
-\unexpanded\def\processcommalistwithparameters[#1]#2%
+\protected\def\processcommalistwithparameters[#1]#2%
{\def\syst_helpers_do_process_comma_list_with_parameters##1{#2[##1]}%
\processcommalist[#1]\syst_helpers_do_process_comma_list_with_parameters}
@@ -1235,11 +1225,11 @@
\let\syst_helpers_comma_list_step\relax
-\unexpanded\def\startprocesscommalist[#1]#2\stopprocesscommalist
+\protected\def\startprocesscommalist[#1]#2\stopprocesscommalist
{\def\syst_helpers_comma_list_step##1{\def\currentcommalistitem{##1}#2}%
\processcommalist[#1]\syst_helpers_comma_list_step}
-\unexpanded\def\startprocesscommacommand[#1]#2\stopprocesscommacommand
+\protected\def\startprocesscommacommand[#1]#2\stopprocesscommacommand
{\def\syst_helpers_comma_list_step##1{\def\currentcommalistitem{##1}#2}%
\normalexpanded{\processcommalist[#1]}\syst_helpers_comma_list_step}
@@ -1287,7 +1277,7 @@
% obsolete: \def\expandactions{\let\expandedaction\edef} \expandactions (see mkii)
-\unexpanded\def\syst_helpers_do_compare_process_action_a[#1=>#2][#3]%
+\protected\def\syst_helpers_do_compare_process_action_a[#1=>#2][#3]%
{\edef\m_syst_string_two{#1}%
\ifx\m_syst_string_two\s!default
\let\commalistelement\empty
@@ -1296,7 +1286,7 @@
% met \quitcommalist tot meer dan 25\% sneller
-\unexpanded\def\syst_helpers_do_compare_process_action_b[#1=>#2][#3]%
+\protected\def\syst_helpers_do_compare_process_action_b[#1=>#2][#3]%
{\edef\m_syst_string_two{#1}%
\ifx\m_syst_string_one\m_syst_string_two
\def\commalistelement{#3}%
@@ -1307,7 +1297,7 @@
#2%
\fi\fi}
-\unexpanded\def\processaction[#1]#2[%
+\protected\def\processaction[#1]#2[%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\let\syst_helpers_do_compare_process_action\syst_helpers_do_compare_process_action_a
@@ -1317,7 +1307,7 @@
\edef\syst_helpers_do_process_action##1{\syst_helpers_do_compare_process_action[##1][#1]}% expands #1
\processnextcommalist\relax\relax\syst_helpers_do_process_action[}
-\unexpanded\def\syst_helpers_do_compare_process_action_c[#1=>#2][#3]%
+\protected\def\syst_helpers_do_compare_process_action_c[#1=>#2][#3]%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#3}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -1332,7 +1322,7 @@
\fi
\fi}
-\unexpanded\def\processfirstactioninset[#1]%
+\protected\def\processfirstactioninset[#1]%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\processaction
@@ -1341,13 +1331,13 @@
\fi
[#1]}
-\unexpanded\def\syst_helpers_process_first_action_in_set_indeed[#1]#2[#3]%
+\protected\def\syst_helpers_process_first_action_in_set_indeed[#1]#2[#3]%
{\def\syst_helpers_do_process_action##1%
{\def\syst_helpers_do_do_process_action####1{\syst_helpers_do_compare_process_action_c[####1][##1]}%
\processcommalist[#3]\syst_helpers_do_do_process_action}%
\normalexpanded{\processcommalist[#1]}\syst_helpers_do_process_action}
-\unexpanded\def\syst_helpers_do_compare_process_action_d[#1=>#2][#3]%
+\protected\def\syst_helpers_do_compare_process_action_d[#1=>#2][#3]%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#3}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -1364,10 +1354,10 @@
\installsystemnamespace{nextactionlevel}
-\unexpanded\def\syst_helpers_do_process_all_actions_in_set
+\protected\def\syst_helpers_do_process_all_actions_in_set
{\csname\??nextactionlevel\the\processlevel\endcsname}
-\unexpanded\def\processallactionsinset[#1]%
+\protected\def\processallactionsinset[#1]%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\processaction
@@ -1376,7 +1366,7 @@
\fi
[#1]}
-\unexpanded\def\syst_helpers_process_all_actions_in_set_indeed[#1]#2[#3]%
+\protected\def\syst_helpers_process_all_actions_in_set_indeed[#1]#2[#3]%
{\advance\processlevel \plusone
\expandafter\def\csname\??nextactionlevel\the\processlevel\endcsname##1%
{\def\syst_helpers_do_do_process_action####1{\syst_helpers_do_compare_process_action_d[####1][##1]}%
@@ -1386,7 +1376,7 @@
%D These macros use:
-\unexpanded\def\processnextcommalist#1#2#3[#4#5]%
+\protected\def\processnextcommalist#1#2#3[#4#5]%
{#1%
\let\nexttoken#4%
\global\advance\commalevel \plusone
@@ -1412,10 +1402,10 @@
\let\firstcharacter \empty
\let\remainingcharacters\empty
-\unexpanded\def\getfirstcharacter #1{\clf_getfirstcharacter{#1}}
-\unexpanded\def\doifelsefirstchar #1#2{\clf_doifelsefirstchar{#1}{#2}}
-\unexpanded\def\thefirstcharacter #1{\clf_thefirstcharacter{#1}}
-\unexpanded\def\theremainingcharacters#1{\clf_theremainingcharacters{#1}}
+\protected\def\getfirstcharacter #1{\clf_getfirstcharacter{#1}}
+\protected\def\doifelsefirstchar #1#2{\clf_doifelsefirstchar{#1}{#2}}
+\protected\def\thefirstcharacter #1{\clf_thefirstcharacter{#1}}
+\protected\def\theremainingcharacters#1{\clf_theremainingcharacters{#1}}
\let\doiffirstcharelse\doifelsefirstchar
@@ -1430,7 +1420,7 @@
\let\m_syst_sub_string\empty
-\unexpanded\def\doifelseinstring#1%
+\protected\def\doifelseinstring#1%
{\edef\m_syst_sub_string{#1}% expand #1 here
\ifx\m_syst_sub_string\empty
\expandafter\thirdofthreearguments
@@ -1440,14 +1430,14 @@
\let\doifinstringelse\doifelseinstring
-\unexpanded\def\syst_helpers_do_if_in_string_else_indeed#1%
+\protected\def\syst_helpers_do_if_in_string_else_indeed#1%
{\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}%
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-\unexpanded\def\doifinstring#1%%
+\protected\def\doifinstring#1%%
{\edef\m_syst_sub_string{#1}% expand #1 here
\ifx\m_syst_sub_string\empty
\expandafter\gobbletwoarguments
@@ -1455,22 +1445,23 @@
\expandafter\syst_helpers_do_if_in_string_indeed
\fi}
-\unexpanded\def\syst_helpers_do_if_in_string_indeed#1%
+\protected\def\syst_helpers_do_if_in_string_indeed#1%
{\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}%
\expandafter\firstofoneargument
\else
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifnotinstring#1%%
+\protected\def\doifnotinstring#1%%
{\edef\m_syst_sub_string{#1}% expand #1 here
\ifx\m_syst_sub_string\empty
- \expandafter\gobbletwoarguments
+ %\expandafter\gobbletwoarguments
+ \expandafter\secondoftwoarguments
\else
\expandafter\syst_helpers_do_if_not_in_string_indeed
\fi}
-\unexpanded\def\syst_helpers_do_if_not_in_string_indeed#1%
+\protected\def\syst_helpers_do_if_not_in_string_indeed#1%
{\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}%
\expandafter\gobbleoneargument
\else
@@ -1479,7 +1470,7 @@
% replaces prev
-\unexpanded\def\syst_helpers_do_if_in_string_else#1#2% ##2 can be {abc}
+\protected\def\syst_helpers_do_if_in_string_else#1#2% ##2 can be {abc}
{\expandafter\def\expandafter\syst_helpers_do_do_if_in_string_else
\expandafter##\expandafter1#1##2##3^^^^0004{\unless\if##2@}% expand #1 here
\expandafter\syst_helpers_do_do_if_in_string_else\normalexpanded{#2#1}@@^^^^0004} % expand #2 here
@@ -1495,12 +1486,12 @@
%D Where \type {\doifinstringelse} does as much expansion as possible, the latter
%D alternative does minimal (one level) expansion.
-\unexpanded\def\syst_helpers_do_if_in_csname_else#1#2%
+\protected\def\syst_helpers_do_if_in_csname_else#1#2%
{\def\syst_helpers_do_do_if_in_csname_else##1#1##2##3^^^^0004%
{\unless\if##2@}%
\expandafter\syst_helpers_do_do_if_in_csname_else#2#1@@^^^^0004}
-\unexpanded\def\doifelseincsname#1#2%
+\protected\def\doifelseincsname#1#2%
{\normalexpanded{\syst_helpers_do_if_in_csname_else{#1}}{#2}%
\expandafter\firstoftwoarguments
\else
@@ -1558,7 +1549,7 @@
\def\percentdimen#1#2% dimen percentage (with %)
{\dimexpr\clf_percentageof{#2}\dimexpr#1\relax}
-\unexpanded\def\setpercentdimen#1#2% dimen percentage (with %)
+\protected\def\setpercentdimen#1#2% dimen percentage (with %)
{#1=\clf_percentageof{#2}\dimexpr#1\relax}
%D \macros
@@ -1586,7 +1577,7 @@
%D The gain in speed depends on the length of the argument (the longer the argument,
%D the less we gain).
-\unexpanded\def\makerawcommalist[#1]#2% use \processnext ... here
+\protected\def\makerawcommalist[#1]#2% use \processnext ... here
{\def\syst_helpers_do_make_raw_comma_list##1% we don't expand ##1
{\ifx#2\empty
\def#2{##1}%
@@ -1602,28 +1593,28 @@
\expandafter\syst_helpers_raw_process_comma_item
\fi#2}
-\unexpanded\def\rawprocesscommalist[#1]#2% accepteert ook [\cs]
+\protected\def\rawprocesscommalist[#1]#2% accepteert ook [\cs]
{\global\advance\commalevel \plusone
\expandafter\let\csname\??nextcommalevel\the\commalevel\endcsname#2%
\expandafter\syst_helpers_raw_process_comma_item#1,],% \relax
\global\advance\commalevel \minusone }
-\unexpanded\def\rawprocesscommacommand[#1]% not really needed
+\protected\def\rawprocesscommacommand[#1]% not really needed
{\normalexpanded{\rawprocesscommalist[#1]}}
%D Here is one without nesting:
-\unexpanded\def\syst_helpers_fast_process_comma_item#1,#2% #2 eats up preceding space
+\protected\def\syst_helpers_fast_process_comma_item#1,#2% #2 eats up preceding space
{\if]#1\else
\syst_helpers_fast_process_comma_command{#1}%
\expandafter\syst_helpers_fast_process_comma_item
\fi#2}
-\unexpanded\def\fastprocesscommalist[#1]#2% accepteert ook [\cs]
+\protected\def\fastprocesscommalist[#1]#2% accepteert ook [\cs]
{\let\syst_helpers_fast_process_comma_command#2%
\expandafter\syst_helpers_fast_process_comma_item#1,],}% \relax
-\unexpanded\def\fastprocesscommacommand[#1]#2% accepteert ook [\cs]
+\protected\def\fastprocesscommacommand[#1]#2% accepteert ook [\cs]
{\let\syst_helpers_fast_process_comma_command#2%
\normalexpanded{\syst_helpers_fast_process_comma_item#1},],}% \relax
@@ -1632,7 +1623,7 @@
\def\m_syst_two_commas{,,}
-\unexpanded\def\rawdoifelseinset#1%
+\protected\def\rawdoifelseinset#1%
{\edef\m_syst_sub_string{,#1,}% expand #1 here
\ifx\m_syst_sub_string\m_syst_two_commas
\expandafter\thirdofthreearguments
@@ -1640,16 +1631,16 @@
\expandafter\syst_helpers_raw_do_if_in_set_else
\fi}
-\let\rawdoifinsetelse\rawdoifinsetelse
+\let\rawdoifinsetelse\rawdoifelseinset
-\unexpanded\def\syst_helpers_raw_do_if_in_set_else#1%
+\protected\def\syst_helpers_raw_do_if_in_set_else#1%
{\syst_helpers_do_if_in_string_else\m_syst_sub_string{,#1,}%
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-\unexpanded\def\rawdoifinset#1%
+\protected\def\rawdoifinset#1%
{\edef\m_syst_sub_string{,#1,}% expand #1 here
\ifx\m_syst_sub_string\m_syst_two_commas
\expandafter\gobbletwoarguments
@@ -1657,7 +1648,7 @@
\expandafter\syst_helpers_raw_do_if_in_set
\fi}
-\unexpanded\def\syst_helpers_raw_do_if_in_set#1%%
+\protected\def\syst_helpers_raw_do_if_in_set#1%%
{\syst_helpers_do_if_in_string_else\m_syst_sub_string{,#1,}%
\expandafter\firstofoneargument
\else
@@ -1673,7 +1664,7 @@
\fi}%
\syst_helpers_do_do_raw_process_action,#2,#1=>,@^^^^0004}
-\unexpanded\def\rawprocessaction[#1]#2[#3]%
+\protected\def\rawprocessaction[#1]#2[#3]%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{undefined}% better \!!undefined
\let\m_syst_helpers_process_action\m_syst_string_two
@@ -1731,6 +1722,14 @@
\def\docopyvalue#1#2#3%
{\expandafter\def\csname#1#3\endcsname{\csname#2#3\endcsname}}
+%D Experiment:
+
+\edef\m_syst_protected{\detokenize{protected}}
+
+\protected\def\aliasmacro#1#2%
+ {\doifinstring{\m_syst_protected}{\meaning#2}\protected
+ \def#1{#2}}
+
%D \macros
%D {doassign,undoassign,doassignempty}
%D
@@ -1763,10 +1762,10 @@
%D will redefine this macro later on, when a more advanced message mechanism is
%D implemented.
-\unexpanded\def\showassignerror#1#2%
+\protected\def\showassignerror#1#2%
{\writestatus{setup}{missing or ungrouped '=' after '#1' in line #2}}
-\unexpanded\def\doassignempty[#1][#2=#3]%
+\protected\def\doassignempty[#1][#2=#3]%
{\ifcsname#1#2\endcsname\else\dosetvalue{#1}{#2}{#3}\fi}
%D \macros
@@ -1836,15 +1835,15 @@
\let\currentvalue\empty
-\unexpanded\def\getparameters {\dogetparameters\dosetvalue}
-\unexpanded\def\geteparameters {\dogetparameters\dosetevalue}
-\unexpanded\def\getgparameters {\dogetparameters\dosetgvalue}
-\unexpanded\def\getxparameters {\dogetparameters\dosetxvalue}
-\unexpanded\def\forgetparameters{\dogetparameters\doignorevalue}
+\protected\def\getparameters {\dogetparameters\dosetvalue}
+\protected\def\geteparameters {\dogetparameters\dosetevalue}
+\protected\def\getgparameters {\dogetparameters\dosetgvalue}
+\protected\def\getxparameters {\dogetparameters\dosetxvalue}
+\protected\def\forgetparameters{\dogetparameters\doignorevalue}
\let\getexpandedparameters\geteparameters
-\unexpanded\def\dogetparameters#1[#2]#3[#4%
+\protected\def\dogetparameters#1[#2]#3[#4%
{\if\noexpand#4]%
\expandafter\gobbleoneargument
\else
@@ -1896,9 +1895,9 @@
\let\syst_helpers_get_parameters_assign_indeed\syst_helpers_get_parameters_assign_normal
-\unexpanded\def\doassign [#1][#2]{\let\setsomevalue\dosetvalue \syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
-\unexpanded\def\doeassign [#1][#2]{\let\setsomevalue\dosetevalue \syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
-\unexpanded\def\undoassign[#1][#2]{\let\setsomevalue\doresetvalue\syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
+\protected\def\doassign [#1][#2]{\let\setsomevalue\dosetvalue \syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
+\protected\def\doeassign [#1][#2]{\let\setsomevalue\dosetevalue \syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
+\protected\def\undoassign[#1][#2]{\let\setsomevalue\doresetvalue\syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
%D \macros
%D {processassignmentlist,processassignmentcommand,
@@ -1914,18 +1913,18 @@
%D We can optimize this one if needed but it's not a core macro so hardly worth the
%D trouble and tokens.
-\unexpanded\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
+\protected\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
{\def\syst_helpers_process_assignment_entry##1{#2}% {##2}{##3} % namespace is ignored
\dogetparameters\syst_helpers_process_assignment_entry[][#1]}
-\unexpanded\def\processassignmentcommand[#1]%
+\protected\def\processassignmentcommand[#1]%
{\normalexpanded{\processassignmentlist[#1]}}
-\unexpanded\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist
+\protected\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist
{\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}%
\processassignmentlist[#1]\currentassignmentlistcommand}
-\unexpanded\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand
+\protected\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand
{\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}%
\normalexpanded{\processassignmentlist[#1]}\currentassignmentlistcommand}
@@ -1979,7 +1978,7 @@
\let\syst_helpers_get_parameters\syst_helpers_get_parameters_normal % **
-\unexpanded\def\expandparameters
+\protected\def\expandparameters
{\let\syst_helpers_get_parameters\syst_helpers_get_parameters_expanded}
%D \macros
@@ -1992,7 +1991,7 @@
%D \getemptyparameters [label] [...=...,...=...]
%D \stoptyping
-\unexpanded\def\getemptyparameters[#1]#2[#3]%
+\protected\def\getemptyparameters[#1]#2[#3]%
{\def\syst_helpers_get_empty_parameters##1{\doassignempty[#1][##1]}%
\processcommalist[#3]\syst_helpers_get_empty_parameters}
@@ -2025,7 +2024,7 @@
%D By using \type {\docopyvalue} we've prepared this command for use in a
%D multi||lingual environment.
-\unexpanded\def\copyparameters[#1]#2[#3]#4[#5]%
+\protected\def\copyparameters[#1]#2[#3]#4[#5]%
{\doifnot{#1}{#3}
{\def\syst_helpers_copy_parameter{\docopyvalue{#1}{#3}}% ##1
\processcommalist[#5]\syst_helpers_copy_parameter}}
@@ -2048,7 +2047,7 @@
\def\syst_helpers_check_parameters#1=#2#3^^^^0004%
{\if#2^^^^0003\parametersfalse\else\parameterstrue\fi}
-\unexpanded\def\checkparameters[#1]%
+\protected\def\checkparameters[#1]%
{\syst_helpers_check_parameters#1=^^^^0003^^^^0003^^^^0004}
%D \macros
@@ -2085,7 +2084,7 @@
\def\syst_helpers_get_comma_list_size#1%
{\advance\commalistcounter\plusone}
-\unexpanded\def\getcommalistsize#1]% don't loose [{#1}]
+\protected\def\getcommalistsize#1]% don't loose [{#1}]
{\commalistcounter\zerocount
\processcommalist#1]\syst_helpers_get_comma_list_size % was [{#1}]
\edef\commalistsize{\the\commalistcounter}}
@@ -2095,7 +2094,7 @@
% \scratchtoks\expandafter{\expandafter[\commacommand]}%
% \expandafter\getcommalistsize\the\scratchtoks }
-\unexpanded\def\getcommacommandsize[#1]%
+\protected\def\getcommacommandsize[#1]%
{\normalexpanded{\getcommalistsize[#1]}}
\def\syst_helpers_get_from_comma_list#1%
@@ -2105,12 +2104,12 @@
\expandafter\quitcommalist
\fi}
-\unexpanded\def\getfromcommalist[#1]#2[#3]%
+\protected\def\getfromcommalist[#1]#2[#3]%
{\let\commalistelement\empty
\commalistcounter#3\relax
\processcommalist[#1]\syst_helpers_get_from_comma_list}
-\unexpanded\def\getfromcommacommand[#1]%
+\protected\def\getfromcommacommand[#1]%
{\normalexpanded{\getfromcommalist[#1]}}
%D Watertight (and efficient) solutions are hard to find, due to the handling of
@@ -2176,7 +2175,7 @@
%D \def\dosetupsomething[#1][#2]%
%D {... #1 ... #2 ...}
%D
-%D \unexpanded\def\setupsomething
+%D \protected\def\setupsomething
%D {\dodoubleargument\dosetupsomething}
%D \stoptyping
%D
@@ -2204,13 +2203,13 @@
% no longer a message:
%
-% \unexpanded\def\dosingleargument {\let\expectedarguments\plusone \dosingleempty }
-% \unexpanded\def\dodoubleargument {\let\expectedarguments\plustwo \dodoubleempty }
-% \unexpanded\def\dotripleargument {\let\expectedarguments\plusthree \dotripleempty }
-% \unexpanded\def\doquadrupleargument {\let\expectedarguments\plusfour \doquadrupleempty }
-% \unexpanded\def\doquintupleargument {\let\expectedarguments\plusfive \doquintupleempty }
-% \unexpanded\def\dosixtupleargument {\let\expectedarguments\plussix \dosixtupleempty }
-% \unexpanded\def\doseventupleargument{\let\expectedarguments\plusseven \doseventupleempty}
+% \protected\def\dosingleargument {\let\expectedarguments\plusone \dosingleempty }
+% \protected\def\dodoubleargument {\let\expectedarguments\plustwo \dodoubleempty }
+% \protected\def\dotripleargument {\let\expectedarguments\plusthree \dotripleempty }
+% \protected\def\doquadrupleargument {\let\expectedarguments\plusfour \doquadrupleempty }
+% \protected\def\doquintupleargument {\let\expectedarguments\plusfive \doquintupleempty }
+% \protected\def\dosixtupleargument {\let\expectedarguments\plussix \dosixtupleempty }
+% \protected\def\doseventupleargument{\let\expectedarguments\plusseven \doseventupleempty}
%D \macros
%D {iffirstagument,ifsecondargument,ifthirdargument,
@@ -2259,16 +2258,16 @@
% \setnewconstant\noexpectedarguments\zerocount
% \setnewconstant\expectedarguments \zerocount
%
-% \unexpanded\def\showargumenterror#1#2%
+% \protected\def\showargumenterror#1#2%
% {\writestatus{system}{\number#1 argument(s) expected in line #2}}
%
-% \unexpanded\def\syst_helpers_argument_error
+% \protected\def\syst_helpers_argument_error
% {\ifnum\expectedarguments>\noexpectedarguments
% \showargumenterror{\number\expectedarguments}{\number\inputlineno}%
% \fi
% \syst_helpers_argument_reset}
%
-% \unexpanded\def\syst_helpers_argument_reset
+% \protected\def\syst_helpers_argument_reset
% {\let\expectedarguments\noexpectedarguments}
% \def\test[#1]{(#1)}
@@ -2316,7 +2315,7 @@
%
% with
%
-% \unexpanded\def\dodoubleempty#1%
+% \protected\def\dodoubleempty#1%
% {\syst_helpers_argument_reset
% \let\m_syst_aux_do#1% alias
% \let\m_syst_action_yes\syst_helpers_double_empty_one_yes
@@ -2357,7 +2356,7 @@
%D Single:
-% \unexpanded\def\dosingleempty#1%
+% \protected\def\dosingleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\firstargumenttrue#1}%
@@ -2367,7 +2366,7 @@
% {\firstargumentfalse
% #1[]}
-\unexpanded\def\dosingleempty#1%
+\protected\def\dosingleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_single_empty_one_yes
@@ -2381,7 +2380,7 @@
%D Double
-% \unexpanded\def\dodoubleempty#1%
+% \protected\def\dodoubleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_double_empty_one_yes#1}%
@@ -2409,7 +2408,7 @@
% \def\syst_helpers_double_empty_one_spaced#1#2{#1[{#2}][] }
% \def\syst_helpers_double_empty_one_normal#1#2{#1[{#2}][]}
-\unexpanded\def\dodoubleempty#1%
+\protected\def\dodoubleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_double_empty_one_yes
@@ -2440,7 +2439,7 @@
% Triple
-% \unexpanded\def\dotripleempty#1%
+% \protected\def\dotripleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_triple_empty_one_yes#1}%
@@ -2486,7 +2485,7 @@
% \def\syst_helpers_triple_empty_three_spaced#1#2#3{#1[{#2}][{#3}][] }
% \def\syst_helpers_triple_empty_three_normal#1#2#3{#1[{#2}][{#3}][]}
-\unexpanded\def\dotripleempty#1%
+\protected\def\dotripleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_triple_empty_one_yes
@@ -2535,7 +2534,7 @@
%D Quadruple:
-% \unexpanded\def\doquadrupleempty#1%
+% \protected\def\doquadrupleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_quadruple_empty_one_yes#1}%
@@ -2600,7 +2599,7 @@
% \def\syst_helpers_quadruple_empty_four_spaced #1#2#3#4{#1[{#2}][{#3}][{#4}][] }
% \def\syst_helpers_quadruple_empty_four_normal #1#2#3#4{#1[{#2}][{#3}][{#4}][]}
-\unexpanded\def\doquadrupleempty#1%
+\protected\def\doquadrupleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_quadruple_empty_one_yes
@@ -2668,7 +2667,7 @@
%D Quintuple:
-% \unexpanded\def\doquintupleempty#1%
+% \protected\def\doquintupleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_quintuple_empty_one_yes#1}%
@@ -2753,7 +2752,7 @@
% \def\syst_helpers_quintuple_empty_five_spaced #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][] }
% \def\syst_helpers_quintuple_empty_five_normal #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][]}
-\unexpanded\def\doquintupleempty#1%
+\protected\def\doquintupleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_quintuple_empty_one_yes
@@ -2841,7 +2840,7 @@
%D Sixtuple:
-% \unexpanded\def\dosixtupleempty#1%
+% \protected\def\dosixtupleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_sixtuple_empty_one_yes#1}
@@ -2947,7 +2946,7 @@
% \def\syst_helpers_sixtuple_empty_six_spaced #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][] }
% \def\syst_helpers_sixtuple_empty_six_normal #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][]}
-\unexpanded\def\dosixtupleempty#1%
+\protected\def\dosixtupleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_sixtuple_empty_one_yes
@@ -3056,7 +3055,7 @@
%D Seventuple:
-% \unexpanded\def\doseventupleempty#1%
+% \protected\def\doseventupleempty#1%
% {\syst_helpers_argument_reset
% \doifelsenextoptional
% {\syst_helpers_seventuple_empty_one_yes#1}%
@@ -3184,7 +3183,7 @@
% \def\syst_helpers_seventuple_empty_seven_spaced#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][] }
% \def\syst_helpers_seventuple_empty_seven_normal#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][]}
-\unexpanded\def\doseventupleempty#1%
+\protected\def\doseventupleempty#1%
{%syst_helpers_argument_reset
\t_syst_aux{#1}%
\let\m_syst_action_yes\syst_helpers_seventuple_empty_one_yes
@@ -3378,13 +3377,13 @@
%D Many \CONTEXT\ commands started as complex or simple ones, but changed into more
%D versatile (more object oriented) ones using the \type {\get..argument} commands.
-\unexpanded\def\complexorsimple#1%
+\protected\def\complexorsimple#1%
{% \relax % prevents lookahead, brrr
\doifelsenextoptional
{\firstargumenttrue \csname\s!complex\csstring#1\endcsname}
{\firstargumentfalse\csname\s!simple \csstring#1\endcsname}}
-\unexpanded\def\complexorsimpleempty#1%
+\protected\def\complexorsimpleempty#1%
{% \relax % prevents lookahead, brrr
\doifelsenextoptional
{\firstargumenttrue \csname\s!complex\csstring#1\endcsname}
@@ -3396,19 +3395,19 @@
%D The previous commands are used that often that we found it worthwile to offer two
%D more alternatives. Watch the build in protection.
-\unexpanded\def\syst_helpers_complex_or_simple#1#2%
+\protected\def\syst_helpers_complex_or_simple#1#2%
{\doifelsenextoptional{\firstargumenttrue#1}{\firstargumentfalse#2}}
-\unexpanded\def\syst_helpers_complex_or_simple_empty#1%
+\protected\def\syst_helpers_complex_or_simple_empty#1%
{\doifelsenextoptional{\firstargumenttrue#1}{\firstargumentfalse#1[]}}
-\unexpanded\def\definecomplexorsimple#1%
- {\unexpanded\edef#1{\syst_helpers_complex_or_simple
+\protected\def\definecomplexorsimple#1%
+ {\protected\edef#1{\syst_helpers_complex_or_simple
\expandafter\noexpand\csname\s!complex\csstring#1\endcsname
\expandafter\noexpand\csname\s!simple \csstring#1\endcsname}}
-\unexpanded\def\definecomplexorsimpleempty#1%
- {\unexpanded\edef#1{\syst_helpers_complex_or_simple_empty
+\protected\def\definecomplexorsimpleempty#1%
+ {\protected\edef#1{\syst_helpers_complex_or_simple_empty
\expandafter\noexpand\csname\s!complex\csstring#1\endcsname}}
%D These commands are called as:
@@ -3446,8 +3445,8 @@
\newconditional\c_syst_helpers_permit_spaces_between_groups
-\unexpanded\def \permitspacesbetweengroups{\settrue \c_syst_helpers_permit_spaces_between_groups}
-\unexpanded\def\dontpermitspacesbetweengroups{\setfalse\c_syst_helpers_permit_spaces_between_groups}
+\protected\def \permitspacesbetweengroups{\settrue \c_syst_helpers_permit_spaces_between_groups}
+\protected\def\dontpermitspacesbetweengroups{\setfalse\c_syst_helpers_permit_spaces_between_groups}
\dontpermitspacesbetweengroups
@@ -3456,7 +3455,7 @@
%D \type {conditional} token. Okay, these macros are not called that often but it
%D saves crap when tracing.
-\unexpanded\def\syst_helpers_get_grouped_argument#1#2%
+\protected\def\syst_helpers_get_grouped_argument#1#2%
{\let\syst_helpers_get_grouped_argument_yes#1%
\let\syst_helpers_get_grouped_argument_nop#2%
\futurelet\nextargument\syst_helpers_get_grouped_argument_indeed}
@@ -3495,13 +3494,13 @@
\expandafter\syst_helpers_get_grouped_argument_d % h
\fi}
-\unexpanded\def\dosinglegroupempty#1%
+\protected\def\dosinglegroupempty#1%
{\def\syst_helpers_get_grouped_argument_nested
{\dontpermitspacesbetweengroups
#1}%
\syst_helpers_get_grouped_argument\firstargumenttrue\firstargumentfalse}
-\unexpanded\def\dodoublegroupempty#1%
+\protected\def\dodoublegroupempty#1%
{\def\syst_helpers_get_grouped_argument_nested##1%
{\def\syst_helpers_get_grouped_argument_nested
{\dontpermitspacesbetweengroups
@@ -3509,7 +3508,7 @@
\syst_helpers_get_grouped_argument\secondargumenttrue\secondargumentfalse}%
\syst_helpers_get_grouped_argument\firstargumenttrue\firstargumentfalse}
-\unexpanded\def\dotriplegroupempty#1%
+\protected\def\dotriplegroupempty#1%
{\def\syst_helpers_get_grouped_argument_nested##1%
{\def\syst_helpers_get_grouped_argument_nested####1%
{\def\syst_helpers_get_grouped_argument_nested
@@ -3519,7 +3518,7 @@
\syst_helpers_get_grouped_argument\secondargumenttrue\secondargumentfalse}%
\syst_helpers_get_grouped_argument\firstargumenttrue\firstargumentfalse}
-\unexpanded\def\doquadruplegroupempty#1%
+\protected\def\doquadruplegroupempty#1%
{\def\syst_helpers_get_grouped_argument_nested##1%
{\def\syst_helpers_get_grouped_argument_nested####1%
{\def\syst_helpers_get_grouped_argument_nested########1%
@@ -3531,7 +3530,7 @@
\syst_helpers_get_grouped_argument\secondargumenttrue\secondargumentfalse}%
\syst_helpers_get_grouped_argument\firstargumenttrue\firstargumentfalse}
-\unexpanded\def\doquintuplegroupempty#1%
+\protected\def\doquintuplegroupempty#1%
{\def\syst_helpers_get_grouped_argument_nested##1%
{\def\syst_helpers_get_grouped_argument_nested####1%
{\def\syst_helpers_get_grouped_argument_nested########1%
@@ -3599,14 +3598,14 @@
\def\fifthofsixarguments #1#2#3#4#5#6{#5}
\def\sixthofsixarguments #1#2#3#4#5#6{#6}
-\unexpanded\def\firstofoneunexpanded #1{#1}
+\protected\def\firstofoneunexpanded #1{#1}
-\unexpanded\def\firstoftwounexpanded #1#2{#1}
-\unexpanded\def\secondoftwounexpanded #1#2{#2}
+\protected\def\firstoftwounexpanded #1#2{#1}
+\protected\def\secondoftwounexpanded #1#2{#2}
-\unexpanded\def\firstofthreeunexpanded #1#2#3{#1}
-\unexpanded\def\secondofthreeunexpanded#1#2#3{#2}
-\unexpanded\def\thirdofthreeunexpanded #1#2#3{#3}
+\protected\def\firstofthreeunexpanded #1#2#3{#1}
+\protected\def\secondofthreeunexpanded#1#2#3{#2}
+\protected\def\thirdofthreeunexpanded #1#2#3{#3}
%D \macros
%D {globalletempty,letempty,
@@ -3615,15 +3614,15 @@
%D
%D Trivial:
-\unexpanded\def\letempty #1{\let #1\empty}
-\unexpanded\def\globalletempty#1{\glet#1\empty}
+\protected\def\letempty #1{\let #1\empty}
+\protected\def\globalletempty#1{\glet#1\empty}
-\unexpanded\def\letvalueempty #1{\expandafter\let \csname#1\endcsname\empty}
-\unexpanded\def\letgvalueempty#1{\expandafter\glet\csname#1\endcsname\empty}
-\unexpanded\def\letvaluerelax #1{\expandafter\let \csname#1\endcsname\relax}
-\unexpanded\def\letgvalurelax #1{\expandafter\glet\csname#1\endcsname\relax}
+\protected\def\letvalueempty #1{\expandafter\let \csname#1\endcsname\empty}
+\protected\def\letgvalueempty#1{\expandafter\glet\csname#1\endcsname\empty}
+\protected\def\letvaluerelax #1{\expandafter\let \csname#1\endcsname\relax}
+\protected\def\letgvalurelax #1{\expandafter\glet\csname#1\endcsname\relax}
-\unexpanded\def\relaxvalueifundefined#1%
+\protected\def\relaxvalueifundefined#1%
{\ifcsname#1\endcsname \else
\expandafter\let\csname#1\endcsname\relax
\fi}
@@ -3634,7 +3633,7 @@
%D The next macro hardly needs explanation. Because no nesting is to be expected, we
%D can reuse \type {\wait} within \type {\wait} itself.
-\unexpanded\def\wait
+\protected\def\wait
{\begingroup
\read16 to \wait
\endgroup}
@@ -3661,12 +3660,12 @@
\ifdefined\writestring \else
- \unexpanded\def\writestring{\immediate\write\statuswrite}
- \unexpanded\def\writeline {\writestring{}}
+ \protected\def\writestring{\immediate\write\statuswrite}
+ \protected\def\writeline {\writestring{}}
\fi
-\unexpanded\def\normalwritestatus#1#2%
+\protected\def\normalwritestatus#1#2%
{\writestring{\expandafter\syst_helpers_split_status_yes\expandafter\statuswidth#1%
\space\space\space\space\space\space\space
\space\space\space\space\space\space\space
@@ -3692,13 +3691,13 @@
%D
%D A raw and dirty alternative for \type {\getparameters}; no checking is done!
-\unexpanded\def\rawsetparameter#1=#2,%
+\protected\def\rawsetparameter#1=#2,%
{\if]#1\else
\expandafter\def\csname\rawparameterprefix#1\endcsname{#2}%
\expandafter\rawsetparameter
\fi}
-\unexpanded\def\rawgetparameters[#1][#2% some 5-10% faster
+\protected\def\rawgetparameters[#1][#2% some 5-10% faster
{\ifx#2]% test is needed, else bomb on [#1][]
\expandafter\gobbleoneargument
\else
@@ -3719,13 +3718,13 @@
%D all preceding ones with \type {\redoglobal}. When using only alternatives, one
%D can reset this mechanism with \type {\resetglobal}.
-\unexpanded\def\resetglobal
+\protected\def\resetglobal
{\let\redoglobal\relax
\let\dodoglobal\relax}
\resetglobal
-\unexpanded\def\doglobal
+\protected\def\doglobal
{\ifx\redoglobal\relax
\let\redoglobal\global
\let\dodoglobal\syst_helpers_dodo_global
@@ -3759,7 +3758,7 @@
%D
%D Apart from the prefixes, a few more \type {\expandafters} are needed:
-% \unexpanded\def\newif#1% uses the original plain \@if
+% \protected\def\newif#1% uses the original plain \@if
% {\privatescratchcounter\escapechar
% \escapechar\minusone
% \expandafter\expandafter\expandafter
@@ -3771,7 +3770,7 @@
% \dodoglobal\@if#1{false}%
% \escapechar\privatescratchcounter}
-\normalprotected\def\newif#1% see syst-ini.mkiv
+\protected\def\newif#1% see syst-ini.mkiv
{\let\new_if_saved\newif
\let\newif\new_if_check
\expandafter\redoglobal\expandafter\def\csname\expandafter\newif\csstring#1true\endcsname {\let#1\iftrue }%
@@ -3781,26 +3780,26 @@
%D Also new:
-\unexpanded\def\define#1%
+\protected\def\define#1%
{\ifdefined#1%
\message{[\noexpand#1is already defined]}%
- \unexpanded\expandafter\def\expandafter\gobbleddefinition
+ \protected\expandafter\def\expandafter\gobbleddefinition
\else
- \unexpanded\expandafter\def
+ \protected\expandafter\def
\fi#1}
-\unexpanded\def\redefine#1%
+\protected\def\redefine#1%
{\ifdefined#1%
\message{[\noexpand#1is redefined]}%
\fi
- \unexpanded\def#1}
+ \protected\def#1}
-\unexpanded\def\definemacro#1%
+\protected\def\definemacro#1%
{\ifdefined#1%
\message{[\noexpand#1is already defined]}%
- \unexpanded\expandafter\def\expandafter\gobbleddefinition
+ \protected\expandafter\def\expandafter\gobbleddefinition
\else
- \unexpanded\expandafter\def
+ \protected\expandafter\def
\fi#1}
% \define\hans{hans}
@@ -3831,7 +3830,7 @@
%
% \glet\stoptexdefinition\relax
%
-% \unexpanded\gdef\starttexdefinition%
+% \protected\gdef\starttexdefinition%
% {\bgroup%
% \obeylines%
% \syst_helpers_start_tex_definition}
@@ -3854,7 +3853,7 @@
% \gdef\syst_helpers_start_tex_definition_yes_unexpanded#1#2 #3
% #4\stoptexdefinition%
% {\egroup% #1=unexpanded
-% \unexpanded\expandafter\def\csname#2\endcsname#3{#4}}
+% \protected\expandafter\def\csname#2\endcsname#3{#4}}
%
% \gdef\syst_helpers_start_tex_definition_yes_normal#1#2
% #3\stoptexdefinition%
@@ -3888,7 +3887,7 @@
%
% \glet\stoptexdefinition\relax
%
-% \unexpanded\gdef\starttexdefinition%
+% \protected\gdef\starttexdefinition%
% {\bgroup%
% \obeylines%
% \syst_helpers_start_tex_definition_one}
@@ -3907,7 +3906,7 @@
\glet\stoptexdefinition\relax
-\unexpanded\gdef\starttexdefinition%
+\protected\gdef\starttexdefinition%
{\bgroup%
\obeylines%
\syst_helpers_start_tex_definition}
@@ -3922,14 +3921,14 @@
\egroup
-% \unexpanded\def\texdefinition#1{\csname\ifcsname#1\endcsname#1\else donothing\fi\endcsname} % todo: a nop cs: char 0 or some corenamespace
+% \protected\def\texdefinition#1{\csname\ifcsname#1\endcsname#1\else donothing\fi\endcsname} % todo: a nop cs: char 0 or some corenamespace
-\unexpanded\def\texdefinition#1{\begincsname#1\endcsname}
+\protected\def\texdefinition#1{\begincsname#1\endcsname}
% This is a first variant, more might be added:
-\unexpanded\def\starttexcode{\unprotect}
-\unexpanded\def\stoptexcode {\protect}
+\protected\def\starttexcode{\unprotect}
+\protected\def\stoptexcode {\protect}
%D \macros
%D {newcounter,
@@ -3984,7 +3983,7 @@
\def\zerocountervalue{0}
-\unexpanded\def\newcounter#1%
+\protected\def\newcounter#1%
{\dodoglobal\let#1\zerocountervalue}
%D Nowadays we don't mind a few more tokens if we can gain a bit of speed.
@@ -4005,14 +4004,14 @@
\def\m_syst_action_nop{\syst_helpers_do_do_do_decrement#1,\plusone}%
\doifelsenextcharcs,\m_syst_action_yes\m_syst_action_nop}
-\unexpanded\def\increment{\doifelsenextcharcs(\syst_helpers_do_do_increment\syst_helpers_do_increment}
-\unexpanded\def\decrement{\doifelsenextcharcs(\syst_helpers_do_do_decrement\syst_helpers_do_decrement}
+\protected\def\increment{\doifelsenextcharcs(\syst_helpers_do_do_increment\syst_helpers_do_increment}
+\protected\def\decrement{\doifelsenextcharcs(\syst_helpers_do_do_decrement\syst_helpers_do_decrement}
-\unexpanded\def\fastincrement#1{\dodoglobal\edef#1{\the\numexpr#1+\plusone \relax}}
-\unexpanded\def\fastdecrement#1{\dodoglobal\edef#1{\the\numexpr#1+\minusone\relax}}
+\protected\def\fastincrement#1{\dodoglobal\edef#1{\the\numexpr#1+\plusone \relax}}
+\protected\def\fastdecrement#1{\dodoglobal\edef#1{\the\numexpr#1+\minusone\relax}}
-\unexpanded\def\incrementvalue#1{\expandafter\increment\csname#1\endcsname}
-\unexpanded\def\decrementvalue#1{\expandafter\decrement\csname#1\endcsname}
+\protected\def\incrementvalue#1{\expandafter\increment\csname#1\endcsname}
+\protected\def\decrementvalue#1{\expandafter\decrement\csname#1\endcsname}
%D \macros
%D {newsignal}
@@ -4031,7 +4030,7 @@
\newdimen\maximumsignal % step is about 0.00025pt
-\unexpanded\def\newsignal#1%
+\protected\def\newsignal#1%
{\ifdefined#1\else
\advance\maximumsignal 2\scaledpoint % to be save in rounding
\edef#1{\the\maximumsignal}%
@@ -4060,7 +4059,7 @@
%D
%D We will use this one in:
-\unexpanded\def\savenormalmeaning#1%
+\protected\def\savenormalmeaning#1%
{\ifcsname normal\csstring#1\endcsname \else
\expandafter\let\csname normal\csstring#1\endcsname#1%
\fi}
@@ -4113,7 +4112,7 @@
\installsystemnamespace{recurseindex}
\installsystemnamespace{recurseaction}
-\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
+\protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
{\global\advance\outerrecurse \plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname{#4}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
@@ -4135,7 +4134,7 @@
\fi
\fi\normalexpanded{\syst_helpers_stepwise_next{\number#1}{\number#2}{\number#3}}}
-\unexpanded\def\syst_helpers_stepwise_recurse#1#2#3% from to step
+\protected\def\syst_helpers_stepwise_recurse#1#2#3% from to step
{\ifnum#1>#2\relax
\expandafter\syst_helpers_stepwise_recurse_nop
\else
@@ -4143,14 +4142,14 @@
\doubleexpandafter\syst_helpers_stepwise_recurse_yes\expandafter
\fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}}
-\unexpanded\def\syst_helpers_recurse_content
+\protected\def\syst_helpers_recurse_content
{\csname\??recurseaction\the\outerrecurse\endcsname}
-\unexpanded\def\syst_helpers_stepwise_recurse_yes
+\protected\def\syst_helpers_stepwise_recurse_yes
{\syst_helpers_recurse_content
\syst_helpers_stepwise_recurse}
-\unexpanded\def\syst_helpers_stepwise_reverse#1#2#3% from to step
+\protected\def\syst_helpers_stepwise_reverse#1#2#3% from to step
{\ifnum#1<#2\relax
\expandafter\syst_helpers_stepwise_recurse_nop
\else
@@ -4160,22 +4159,22 @@
\doubleexpandafter\syst_helpers_stepwise_reverse_yes\expandafter
\fi\expandafter{\the\innerrecurse}{#2}{#3}}
-\unexpanded\def\syst_helpers_stepwise_reverse_yes
+\protected\def\syst_helpers_stepwise_reverse_yes
{\syst_helpers_recurse_content
\syst_helpers_stepwise_reverse}
-\unexpanded\def\syst_helpers_stepwise_exit
+\protected\def\syst_helpers_stepwise_exit
{\syst_helpers_stepwise_recurse_nop\relax}
-\unexpanded\def\syst_helpers_stepwise_recurse_nop#1#2#3#4%
+\protected\def\syst_helpers_stepwise_recurse_nop#1#2#3#4%
{\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
\global\advance\outerrecurse\minusone}
-% \unexpanded\def\nonostepwiserecurse#1#2#3%
+% \protected\def\nonostepwiserecurse#1#2#3%
% {\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
% \global\advance\outerrecurse\minusone}
-\unexpanded\def\dorecurse#1%
+\protected\def\dorecurse#1%
{\dostepwiserecurse\plusone{#1}\plusone}
\def\doexpandedrecurse#1#2% user macro (also was \doxprecurse)
@@ -4200,7 +4199,7 @@
%D
%D Because the simple case is used often, we implement it more efficiently:
-\unexpanded\def\dorecurse#1%
+\protected\def\dorecurse#1%
{\ifcase#1\relax
\expandafter\gobbletwoarguments
\or
@@ -4209,13 +4208,13 @@
\expandafter\syst_helpers_recurse_x
\fi{#1}}
-\unexpanded\def\syst_helpers_recurse_x#1#2%
+\protected\def\syst_helpers_recurse_x#1#2%
{\global\advance\outerrecurse \plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname{#2}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
\expandafter\syst_helpers_recurse_indeed\expandafter1\expandafter{\number#1}}
-\unexpanded\def\syst_helpers_recurse_y#1#2%
+\protected\def\syst_helpers_recurse_y#1#2%
{\global\advance\outerrecurse \plusone
\expandafter\glet\csname\??recurseindex\the\outerrecurse\endcsname\recurselevel
\let\recurselevel\!!plusone
@@ -4223,7 +4222,7 @@
\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
\global\advance\outerrecurse \minusone}
-\unexpanded\def\syst_helpers_recurse_indeed#1#2% from to
+\protected\def\syst_helpers_recurse_indeed#1#2% from to
{\ifnum#1>#2\relax
\expandafter\syst_helpers_recurse_indeed_nop
\else
@@ -4231,7 +4230,7 @@
\doubleexpandafter\syst_helpers_recurse_indeed_yes
\fi\expandafter{\the\numexpr\recurselevel+\plusone\relax}{#2}}
-\unexpanded\def\syst_helpers_recurse_indeed#1#2% from to
+\protected\def\syst_helpers_recurse_indeed#1#2% from to
{\ifnum#1>#2\relax
\expandafter\syst_helpers_recurse_indeed_nop
\else
@@ -4240,11 +4239,11 @@
\doubleexpandafter\syst_helpers_recurse_indeed_yes
\fi\expandafter{\the\innerrecurse}{#2}}
-\unexpanded\def\syst_helpers_recurse_indeed_yes
+\protected\def\syst_helpers_recurse_indeed_yes
{\syst_helpers_recurse_content
\syst_helpers_recurse_indeed}
-\unexpanded\def\syst_helpers_recurse_indeed_nop#1#2#3%
+\protected\def\syst_helpers_recurse_indeed_nop#1#2#3%
{\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
\global\advance\outerrecurse \minusone }
@@ -4257,7 +4256,7 @@
%D \dowith{a,b,c}{[#1]}
%D \stoptyping
-\unexpanded\def\dowith#1#2%
+\protected\def\dowith#1#2%
{\def\syst_helpers_with##1{#2}%
\normalexpanded{\processcommalist[#1]}\syst_helpers_with}
@@ -4279,30 +4278,30 @@
\let\endofloop\donothing % maybe \syst_helpers_loop_end
-\unexpanded\def\doloop#1%
+\protected\def\doloop#1%
{\global\advance\outerrecurse \plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname{#1}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
\let\endofloop\syst_helpers_loop
\syst_helpers_loop1} % no \plusone else \recurselevel wrong
-\unexpanded\def\syst_helpers_loop#1%
+\protected\def\syst_helpers_loop#1%
{\def\recurselevel{#1}%
\expandafter\syst_helpers_loop_yes\expandafter{\the\numexpr\recurselevel+\plusone\relax}}
-\unexpanded\def\syst_helpers_loop_yes
+\protected\def\syst_helpers_loop_yes
{\syst_helpers_recurse_content
\endofloop}
-\unexpanded\def\syst_helpers_loop_nop#1%
+\protected\def\syst_helpers_loop_nop#1%
{\let\endofloop\syst_helpers_loop % new, permits nested \doloop's
\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
\global\advance\outerrecurse\minusone}
-\unexpanded\def\exitloop % \exitloop quits at end
+\protected\def\exitloop % \exitloop quits at end
{\let\endofloop\syst_helpers_loop_nop}
-\unexpanded\def\exitloopnow#1\endofloop % \exitloopnow quits directly
+\protected\def\exitloopnow#1\endofloop % \exitloopnow quits directly
{\syst_helpers_loop_nop}
%D The loop is executed at least once, so beware of situations
@@ -4345,13 +4344,13 @@
{\csname\??recurseaction\the\outerrecurse\expandafter\expandafter\expandafter\endcsname
\expandafter\expandafter\expandafter{\expandafter\recurselevel\expandafter}\expandafter{\the\outerrecurse}}
-\unexpanded\def\syst_helpers_recurse_x#1#2%
+\protected\def\syst_helpers_recurse_x#1#2%
{\global\advance\outerrecurse \plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#2}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
\expandafter\syst_helpers_recurse_indeed\expandafter1\expandafter{\number#1}}
-\unexpanded\def\syst_helpers_recurse_y#1#2%
+\protected\def\syst_helpers_recurse_y#1#2%
{\global\advance\outerrecurse \plusone
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
\let\recurselevel\!!plusone
@@ -4360,7 +4359,7 @@
\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
\global\advance\outerrecurse \minusone}
-\unexpanded\def\doloop#1%
+\protected\def\doloop#1%
{\global\advance\outerrecurse \plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#1}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
@@ -4369,7 +4368,7 @@
% for instance:
%
-% \unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
+% \protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
% {\global\advance\outerrecurse \plusone
% \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#4}%
% \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
@@ -4393,7 +4392,7 @@
%
% faster:
%
-% \unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
+% \protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
% {\global\advance\outerrecurse \plusone
% \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#4}%
% \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
@@ -4413,7 +4412,7 @@
\installsystemnamespace{recursestepwise}
-\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
+\protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
{\global\advance\outerrecurse \plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#4}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
@@ -4423,6 +4422,8 @@
\ifnum#2<#1x\else d\fi
\else\ifnum#3<\zerocount
\ifnum#1<#2x\else r\fi
+ \else
+ x%
\fi\fi
\expandafter\endcsname\normalexpanded{{\number#1}{\number#2}{\number#3}}}
% \expandafter\endcsname\expandafter{\number#1\expandafter}\expandafter{\number#2\expandafter}\expandafter{\number#3}}
@@ -4463,7 +4464,7 @@
\let\m_syst_helpers_fast_loop_cs\relax
-\unexpanded\def\dofastloopcs#1%
+\protected\def\dofastloopcs#1%
{\fastloopfinal#1\relax
\ifcase\fastloopfinal
\expandafter\gobbleoneargument
@@ -4471,12 +4472,12 @@
\expandafter\syst_helpers_fast_loop_cs
\fi}
-\unexpanded\def\syst_helpers_fast_loop_cs#1%
+\protected\def\syst_helpers_fast_loop_cs#1%
{\let\m_syst_helpers_fast_loop_cs#1%
\fastloopindex\plusone
\syst_helpers_fast_loop_cs_step}
-\unexpanded\def\syst_helpers_fast_loop_cs_step
+\protected\def\syst_helpers_fast_loop_cs_step
{\ifnum\fastloopindex>\fastloopfinal
\let\m_syst_helpers_fast_loop_cs\relax
\else
@@ -4487,9 +4488,11 @@
% Helper:
-\unexpanded\def\resetrecurselevel{\let\recurselevel\!!zerocount}
+\protected\def\resetrecurselevel{\let\recurselevel\!!zerocount}
-\let\recurselevel\!!zerocount
+\let\recurselevel \!!zerocount
+\let\recurseaction\relax
+\let\recursestring\empty
% \appendtoks \resetrecurselevel \to \everydump
@@ -4516,7 +4519,7 @@
%D }
%D \stoptyping
-\unexpanded\def\doloopoverlist#1#2%
+\protected\def\doloopoverlist#1#2%
{\global\advance\outerrecurse\plusone
\expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1{\edef\recursestring{##1}#2}%
\expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recursestring
@@ -4548,26 +4551,26 @@
\installsystemnamespace{extraevery}
-% \unexpanded\def\newevery#1#2%
+% \protected\def\newevery#1#2%
% {\ifx#1\everypar\else\newtoks#1\fi% we test for redefinition elsewhere
% \ifx#2\relax\else\ifdefined#2\else
% \expandafter\newtoks\csname\??extraevery\csstring#1\endcsname
% \def#2{\syst_helpers_every#1}%
% \fi\fi}
%
-% \unexpanded\def\syst_helpers_every#1%
+% \protected\def\syst_helpers_every#1%
% {\expandafter\removetoks\expandafter\the\csname\??extraevery\csstring#1\endcsname\from#1%
% \expandafter\appendtoks\expandafter\the\csname\??extraevery\csstring#1\endcsname\to #1%
% \csname\??extraevery\csstring#1\endcsname}
-\unexpanded\def\newevery#1#2%
+\protected\def\newevery#1#2%
{\ifx#1\everypar\else\newtoks#1\fi% we test for redefinition elsewhere
\ifx#2\relax\else\ifdefined#2\else
\expandafter\newtoks\csname\??extraevery\csstring#1\endcsname
\edef#2{\syst_helpers_every#1\csname\??extraevery\csstring#1\endcsname}%
\fi\fi}
-\unexpanded\def\syst_helpers_every#1#2%
+\protected\def\syst_helpers_every#1#2%
{\removetoks\the#2\from#1%
\appendtoks\the#2\to #1%
#2}
@@ -4582,19 +4585,19 @@
% \newtoks \neverypar
% \newtoks \neveryendpar
%
-% \normalprotected\def\syst_helpers_forgotten_endpar
+% \protected\def\syst_helpers_forgotten_endpar
% {\the\neveryendpar\normalpar}
%
-% \unexpanded\def\forgeteverypar
+% \protected\def\forgeteverypar
% {\everypar{\the\neverypar}%
% \let\endpar\syst_helpers_forgotten_endpar}
%
-% \unexpanded\def\finishpar
+% \protected\def\finishpar
% {\ifvmode\else\par\fi}
\newtoks \neverypar
-\unexpanded\def\forgeteverypar
+\protected\def\forgeteverypar
{\everypar{\the\neverypar}}
%D Which we're going to use indeed! When the second argument equals \type {\relax},
@@ -4660,10 +4663,10 @@
%D
%D Both commands accept the prefix \type{\doglobal} for global assignments.
-\unexpanded\def\convertvalue#1\to
+\protected\def\convertvalue#1\to
{\expandafter\convertcommand\csname#1\endcsname\to}
-\unexpanded\def\defconvertedvalue#1#2% less sensitive for \to
+\protected\def\defconvertedvalue#1#2% less sensitive for \to
{\expandafter\defconvertedcommand\expandafter#1\csname#2\endcsname}
%D \macros
@@ -4687,14 +4690,14 @@
\def\syst_helpers_check_if_assignment_else#1=#2#3^^^^0004{\if#2^^^^0003}%
\def\syst_helpers_check_else_assignment_if#1=#2#3^^^^0004{\unless\if#2^^^^0003}%
-\unexpanded\def\doifelseassignment#1%
+\protected\def\doifelseassignment#1%
{\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004%
\expandafter\secondoftwoarguments
\else
\expandafter\firstoftwoarguments
\fi}
-\unexpanded\def\doifelseassignmentcs#1#2#3%
+\protected\def\doifelseassignmentcs#1#2#3%
{\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004%
\expandafter#3%
\else
@@ -4706,7 +4709,7 @@
\newif\ifassignment
-\unexpanded\def\docheckassignment#1%
+\protected\def\docheckassignment#1%
{\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004%
\assignmentfalse
\else
@@ -4715,10 +4718,10 @@
%D These can be used for cases where we want less tracing noise.
-\unexpanded\def\validassignment#1%
+\protected\def\validassignment#1%
{\expandafter\syst_helpers_check_else_assignment_if\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
-\unexpanded\def\novalidassignment#1%
+\protected\def\novalidassignment#1%
{\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
%D In \ETEX\ we can use \type {\detokenize} and gain some speed, but in general far
@@ -4726,16 +4729,16 @@
%D This macro is more robust than the pure \TEX\ one, something I found out when
%D primitives like \type {\jobname} were fed (or something undefined).
-\unexpanded\def\convertargument#1\to#2{\dodoglobal\edef#2{\detokenize{#1}}}
-\unexpanded\def\convertcommand #1\to#2{\dodoglobal\edef#2{\expandafter\detokenize\expandafter{#1}}} % hm, only second is also ok
+\protected\def\convertargument#1\to#2{\dodoglobal\edef#2{\detokenize{#1}}}
+\protected\def\convertcommand #1\to#2{\dodoglobal\edef#2{\expandafter\detokenize\expandafter{#1}}} % hm, only second is also ok
-\unexpanded\def\defconvertedargument #1#2{\edef#1{\detokenize{#2}}}
-\unexpanded\def\defconvertedcommand #1#2{\edef#1{\detokenize\expandafter{#2}}}
-\unexpanded\def\edefconvertedargument#1#2{\edef#1{#2}%
+\protected\def\defconvertedargument #1#2{\edef#1{\detokenize{#2}}}
+\protected\def\defconvertedcommand #1#2{\edef#1{\detokenize\expandafter{#2}}}
+\protected\def\edefconvertedargument#1#2{\edef#1{#2}%
\edef#1{\detokenize\expandafter{#1}}}
-\unexpanded\def\gdefconvertedargument#1#2{\xdef#1{\detokenize{#2}}}
-\unexpanded\def\gdefconvertedcommand #1#2{\xdef#1{\detokenize\expandafter{#2}}}
-\unexpanded\def\xdefconvertedargument#1#2{\xdef#1{#2}%
+\protected\def\gdefconvertedargument#1#2{\xdef#1{\detokenize{#2}}}
+\protected\def\gdefconvertedcommand #1#2{\xdef#1{\detokenize\expandafter{#2}}}
+\protected\def\xdefconvertedargument#1#2{\xdef#1{#2}%
\xdef#1{\detokenize\expandafter{#1}}}
%D When you try to convert a primitive command, you'll find out that the \ETEX\
@@ -4759,7 +4762,7 @@
%D
%D Ahandy macro, for testing purposes only:
-\unexpanded\def\showvalue#1%
+\protected\def\showvalue#1%
{\ifcsname#1\endcsname
\expandafter\show\csname#1\endcsname
\else
@@ -4779,7 +4782,7 @@
%D
%D Watch the one level expansion of the second argument.
-\unexpanded\def\doifelsemeaning#1#2%
+\protected\def\doifelsemeaning#1#2%
{\edef\m_syst_string_one{\normalmeaning#1}%
\def \m_syst_string_two{#2}%
\edef\m_syst_string_two{\normalmeaning\m_syst_string_two}%
@@ -4808,9 +4811,9 @@
\edef\m_syst_string_two{\detokenize\expandafter{\normalexpanded{#4}}}%
\ifx\m_syst_string_one\m_syst_string_two\expandafter#1\else\expandafter#2\fi}
-\unexpanded\def\doifelsesamestring{\syst_helpers_if_samestring_else\firstoftwoarguments\secondoftwoarguments}
-\unexpanded\def\doifsamestring {\syst_helpers_if_samestring_else\firstofoneargument \gobbleoneargument }
-\unexpanded\def\doifnotsamestring {\syst_helpers_if_samestring_else\gobbleoneargument \firstofoneargument }
+\protected\def\doifelsesamestring{\syst_helpers_if_samestring_else\firstoftwoarguments\secondoftwoarguments}
+\protected\def\doifsamestring {\syst_helpers_if_samestring_else\firstofoneargument \gobbleoneargument }
+\protected\def\doifnotsamestring {\syst_helpers_if_samestring_else\gobbleoneargument \firstofoneargument }
\let\doifsamestringelse\doifelsesamestring
@@ -4838,7 +4841,7 @@
%D
%D In examples~2 and~3 both arguments equal, in~1 and~4 they differ.
-\unexpanded\def\ConvertToConstant#1#2#3%
+\protected\def\ConvertToConstant#1#2#3%
{\edef\m_syst_string_one{\expandafter\detokenize\expandafter{#2}}%
\edef\m_syst_string_two{\expandafter\detokenize\expandafter{#3}}%
#1{\m_syst_string_one}{\m_syst_string_two}}
@@ -4868,14 +4871,14 @@
%D
%D where \type {...} can be anything legally \TEX.
-\unexpanded\def\CheckConstantAfter#1#2%
+\protected\def\CheckConstantAfter#1#2%
{\expandafter\convertargument\v!prefix!\to\ascii
\convertargument#1\to#2\relax
\doifelseinstring\ascii{#2}
{\expandafter\convertargument#1\to#2}
{}}
-\unexpanded\def\ConvertConstantAfter#1#2#3%
+\protected\def\ConvertConstantAfter#1#2#3%
{\CheckConstantAfter{#2}\asciia
\CheckConstantAfter{#3}\asciib
#1{\asciia}{\asciib}}
@@ -4891,8 +4894,8 @@
%D
%D We don't explicitly test if the macro is defined.
-\unexpanded\def\assignifempty#1#2% can be sped up
- {\doifsomething{#1}{\def#1{#2}}} % {\doifnot{#1}{}{\def#1{#2}}}
+\protected\def\assignifempty#1#2% can be sped up
+ {\doifnothing{#1}{\def#1{#2}}}
%D \macros
%D {gobbleuntil,grabuntil,gobbleuntilrelax,
@@ -4904,7 +4907,7 @@
%D In \CONTEXT\ we use a lot of \type {\start}||\type {\stop} like constructions.
%D Sometimes, the \type {\stop} is used as a hard coded delimiter like in: %D
%D \starttyping
-%D \unexpanded\def\startcommand#1\stopcommand%
+%D \protected\def\startcommand#1\stopcommand%
%D {... #1 ...}
%D \stoptyping
%D
@@ -4922,7 +4925,7 @@
%D {\stop}. This means that:
%D
%D \starttyping
-%D \unexpanded\def\starthello%
+%D \protected\def\starthello%
%D {\grabuntil{stophello}\message}
%D
%D \starthello Hello world!\stophello
@@ -4932,10 +4935,10 @@
\let\syst_helpers_grab_indeed\relax
-\unexpanded\def\syst_helpers_grab#1#2%
+\protected\def\syst_helpers_grab#1#2%
{\def\syst_helpers_grab_indeed##1#1{#2{##1}}\syst_helpers_grab_indeed}
-\unexpanded\def\grabuntil#1%
+\protected\def\grabuntil#1%
{\expandafter\syst_helpers_grab\expandafter{\csname#1\endcsname}}
%D The next command build on this mechanism:
@@ -4962,15 +4965,21 @@
\let\syst_helpers_gobble_indeed\relax
-\unexpanded\def\processbetween#1#2%
+\protected\def\processbetween#1#2%
{\setvalue{\s!start#1}{\grabuntil{\s!stop#1}{#2}}}
-\unexpanded\def\gobbleuntil#1%
+\protected\def\gobbleuntil#1%
{\def\syst_helpers_gobble_indeed##1#1{}\syst_helpers_gobble_indeed}
-\unexpanded\def\gobbleuntilrelax#1\relax
+\protected\def\gobbleuntilrelax#1\relax
{}
+% experimental
+
+\protected\def\gobblenested#1#2#3%
+ {\normalexpanded{\def\noexpand\next##1\csname#2\endcsname}{\csname#3\endcsname}%
+ \next}%
+
%D The next one simply expands the pickup up tokens.
%D
%D \starttyping
@@ -4979,7 +4988,7 @@
\let\syst_helpers_until_indeed\relax
-\unexpanded\def\processuntil#1%
+\protected\def\processuntil#1%
{\def\syst_helpers_until_indeed##1#1{##1}\syst_helpers_until_indeed}
%D \macros
@@ -5051,14 +5060,14 @@
% keep:
%
-% \unexpanded\def\syst_helpers_handle_group_normal#1#2%
+% \protected\def\syst_helpers_handle_group_normal#1#2%
% {\bgroup
% \def\m_syst_helpers_handle_group_before{\bgroup#1\bgroup\aftergroup\m_syst_helpers_handle_group_after}% can't we remove the second \bgroup
% \def\m_syst_helpers_handle_group_after {#2\egroup\egroup}% and one \egroup here?
% \afterassignment\m_syst_helpers_handle_group_before
% \let\next=}
-% \unexpanded\def\syst_helpers_handle_group_normal#1#2%
+% \protected\def\syst_helpers_handle_group_normal#1#2%
% {\bgroup
% \def\m_syst_helpers_handle_group_before{#1}%
% \def\m_syst_helpers_handle_group_after {#2}%
@@ -5076,7 +5085,7 @@
% \egroup
% \egroup}
%
-% \unexpanded\def\syst_helpers_handle_group_simple#1#2% no inner group (so no kerning interference)
+% \protected\def\syst_helpers_handle_group_simple#1#2% no inner group (so no kerning interference)
% {\bgroup
% \def\m_syst_helpers_handle_group_before{#1}%
% \def\m_syst_helpers_handle_group_after {#2}%
@@ -5092,7 +5101,7 @@
% {\m_syst_helpers_handle_group_after
% \egroup}%
%
-% \unexpanded\def\syst_helpers_handle_group_pickup#1#2#3% no inner group (so no kerning interference)
+% \protected\def\syst_helpers_handle_group_pickup#1#2#3% no inner group (so no kerning interference)
% {\bgroup
% \def\m_syst_helpers_handle_group_before{#1}%
% \def\m_syst_helpers_handle_group_after {#2\egroup#3}%
@@ -5104,7 +5113,7 @@
% \aftergroup\m_syst_helpers_handle_group_after
% \m_syst_helpers_handle_group_before}
%
-% \unexpanded\def\syst_helpers_handle_group_nop
+% \protected\def\syst_helpers_handle_group_nop
% {\ifnum\currentgrouptype=\semisimplegroupcode
% \expandafter\syst_helpers_handle_group_nop_a
% \else
@@ -5123,7 +5132,7 @@
% \aftergroup\m_syst_helpers_handle_group_after
% #1}
-\unexpanded\def\syst_helpers_handle_group_nop
+\protected\def\syst_helpers_handle_group_nop
{\ifnum\currentgrouptype=\semisimplegroupcode
\expandafter\syst_helpers_handle_group_nop_a
\else
@@ -5142,7 +5151,7 @@
\aftergroup\egroup
\m_syst_helpers_handle_group_b}
-\unexpanded\def\syst_helpers_handle_group_normal
+\protected\def\syst_helpers_handle_group_normal
{\bgroup
\afterassignment\m_syst_helpers_handle_group_normal_before
\let\next=}
@@ -5155,7 +5164,7 @@
\aftergroup\egroup
\aftergroup\egroup}
-\unexpanded\def\syst_helpers_handle_group_simple% no inner group (so no kerning interference)
+\protected\def\syst_helpers_handle_group_simple% no inner group (so no kerning interference)
{\bgroup
\afterassignment\m_syst_helpers_handle_group_simple_before
\let\next=}
@@ -5169,7 +5178,7 @@
{\m_syst_helpers_handle_group_a
\egroup}%
-\unexpanded\def\syst_helpers_handle_group_pickup% no inner group (so no kerning interference)
+\protected\def\syst_helpers_handle_group_pickup% no inner group (so no kerning interference)
{\bgroup
\afterassignment\m_syst_helpers_handle_group_pickup_before
\let\next=}
@@ -5181,7 +5190,7 @@
\aftergroup\m_syst_helpers_handle_group_p
\m_syst_helpers_handle_group_b}
-\unexpanded\def\syst_helpers_handle_group_nop_x
+\protected\def\syst_helpers_handle_group_nop_x
{\ifnum\currentgrouptype=\semisimplegroupcode
\begingroup
\aftergroup\endgroup
@@ -5191,7 +5200,7 @@
\fi
\m_syst_helpers_handle_group_b}
-\unexpanded\def\syst_helpers_handle_group_normal_x
+\protected\def\syst_helpers_handle_group_normal_x
{\bgroup
\afterassignment\m_syst_helpers_handle_group_normal_before_x
\let\next=}
@@ -5214,50 +5223,50 @@
%D {\futurelet} obeys blank spaces, and a line||ending token is treated as a blank
%D space. So the final implementation became:
-% \unexpanded\def\groupedcommand#1#2%
+% \protected\def\groupedcommand#1#2%
% {\doifelsenextbgroup{\syst_helpers_handle_group_normal{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}}
%
-% \unexpanded\def\groupedcommandcs#1#2%
+% \protected\def\groupedcommandcs#1#2%
% {\doifelsenextbgroup{\syst_helpers_handle_group_normal{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}}
%
-% \unexpanded\def\triggergroupedcommand#1%
+% \protected\def\triggergroupedcommand#1%
% {\doifelsenextbgroup{\syst_helpers_handle_group_normal{#1}{}}{\syst_helpers_handle_group_nop{#1}{}}}
%
-% \unexpanded\def\triggergroupedcommandcs#1%
+% \protected\def\triggergroupedcommandcs#1%
% {\doifelsenextbgroup{\syst_helpers_handle_group_normal{#1}{}}{\syst_helpers_handle_group_nop{#1}{}}}
%
-% \unexpanded\def\simplegroupedcommand#1#2%
+% \protected\def\simplegroupedcommand#1#2%
% {\doifelsenextbgroup{\syst_helpers_handle_group_simple{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}}
%
-% \unexpanded\def\pickupgroupedcommand#1#2#3%
+% \protected\def\pickupgroupedcommand#1#2#3%
% {\doifelsenextbgroup{\syst_helpers_handle_group_pickup{#1}{#2}{#3}}{\syst_helpers_handle_group_nop{#1}{#2}}}
-\unexpanded\def\groupedcommand#1#2%
+\protected\def\groupedcommand#1#2%
{\def\m_syst_helpers_handle_group_b{#1}%
\def\m_syst_helpers_handle_group_a{#2}%
\doifelsenextbgroupcs\syst_helpers_handle_group_normal\syst_helpers_handle_group_nop}
-\unexpanded\def\groupedcommandcs#1#2%
+\protected\def\groupedcommandcs#1#2%
{\let\m_syst_helpers_handle_group_b#1%
\let\m_syst_helpers_handle_group_a#2%
\doifelsenextbgroupcs\syst_helpers_handle_group_normal\syst_helpers_handle_group_nop}
-\unexpanded\def\simplegroupedcommand#1#2%
+\protected\def\simplegroupedcommand#1#2%
{\def\m_syst_helpers_handle_group_b{#1}%
\def\m_syst_helpers_handle_group_a{#2}%
\doifelsenextbgroupcs\syst_helpers_handle_group_simple\syst_helpers_handle_group_nop}
-\unexpanded\def\pickupgroupedcommand#1#2#3%
+\protected\def\pickupgroupedcommand#1#2#3%
{\def\m_syst_helpers_handle_group_b{#1}%
\def\m_syst_helpers_handle_group_a{#2}%
\def\m_syst_helpers_handle_group_p{#3}%
\doifelsenextbgroupcs\syst_helpers_handle_group_pickup\syst_helpers_handle_group_nop}
-\unexpanded\def\triggergroupedcommand#1%
+\protected\def\triggergroupedcommand#1%
{\def\m_syst_helpers_handle_group_b{#1}%
\doifelsenextbgroupcs\syst_helpers_handle_group_normal_x\syst_helpers_handle_group_nop_x}
-\unexpanded\def\triggergroupedcommandcs#1%
+\protected\def\triggergroupedcommandcs#1%
{\let\m_syst_helpers_handle_group_b#1%
\doifelsenextbgroupcs\syst_helpers_handle_group_normal_x\syst_helpers_handle_group_nop_x}
@@ -5286,10 +5295,10 @@
%D The user is warned with the suggestion to use \type {CAPITALS}. This suggestion
%D is feasible, because \CONTEXT only defines lowcased macros.
-\unexpanded\def\showdefinederror#1#2%
+\protected\def\showdefinederror#1#2%
{\writestatus\m!system{#1 #2 replaces a macro, use CAPITALS!}}
-\unexpanded\def\checkdefined#1#2#3%
+\protected\def\checkdefined#1#2#3%
{\doifdefined{#3}{\showdefinederror{#2}{#3}}}
%D \macros
@@ -5344,25 +5353,29 @@
\newtoks\BeforePar
\newtoks\AfterPar
-\def\redowithpar\par
+\protected\def\redowithpar\par
{\doifelsenextchar\par\redowithpar\dodowithpar}%
-\def\dowithpar#1#2%
+\protected\def\dowithpar#1#2%
{\def\dodowithpar##1\par{#1##1#2}%
\redowithpar\par}
-\def\redogotopar\par
+\protected\def\redogotopar\par
{\doifelsenextchar\par\redogotopar\dodogotopar}%
-\def\dogotopar#1%
+\protected\def\dogotopar#1%
{\def\dodogotopar{#1}%
\redogotopar\par}
-\def\dogotoparcs#1%
+\protected\def\dogotoparcs#1%
{\let\dodogotopar#1%
\redogotopar\par}
-\unexpanded\def\GetPar
+\ifdefined \ignorepars \else
+ \protected\def\ignorepars{\dogotoparcs\relax}
+\fi
+
+\protected\def\GetPar
{\expanded
{\dowithpar
{\the\BeforePar
@@ -5371,7 +5384,7 @@
\BeforePar\emptytoks
\AfterPar\emptytoks}}}
-\unexpanded\def\GotoPar
+\protected\def\GotoPar
{\expanded
{\dogotopar
{\the\BeforePar
@@ -5410,7 +5423,7 @@
\let\syst_helpers_next_par\relax
\let\syst_helpers_next_arg\relax
-\unexpanded\def\dowithpargument#1%
+\protected\def\dowithpargument#1%
{\def\syst_helpers_next_par##1 \par{#1{##1}}%
\def\syst_helpers_next_arg##1{#1{##1}}%
\doifelsenextbgroup\syst_helpers_next_arg{\doifelsenextchar\par{#1{}}\syst_helpers_next_par}}
@@ -5438,7 +5451,7 @@
\let\syst_helpers_next_war\relax
\let\syst_helpers_next_arg\relax
-\unexpanded\def\dowithwargument#1%
+\protected\def\dowithwargument#1%
{\def\syst_helpers_next_war##1 {#1{##1}}%
\def\syst_helpers_next_arg##1{#1{##1}}%
\doifelsenextbgroup\syst_helpers_next_arg\syst_helpers_next_war}
@@ -5472,7 +5485,7 @@
%D commands, the \type {n*} is optional. When this specification is missing, the
%D command executes once.
-\unexpanded\def\dorepeatwithcommand[#1]%
+\protected\def\dorepeatwithcommand[#1]%
{\syst_helpers_repeat_with_command#1*\empty*\relax}
\def\syst_helpers_repeat_with_command#1*#2#3*#4\relax#5%
@@ -5563,10 +5576,10 @@
% no longer \def but \let to target toks .. the space gobbling \relax will go
-% \unexpanded\def\appendtoks {\syst_helpers_append_toks \relax}
-% \unexpanded\def\prependtoks {\syst_helpers_prepend_toks \relax}
-% \unexpanded\def\appendtoksonce {\syst_helpers_append_toks_once \relax}
-% \unexpanded\def\prependtoksonce{\syst_helpers_prepend_toks_once\relax}
+% \protected\def\appendtoks {\syst_helpers_append_toks \relax}
+% \protected\def\prependtoks {\syst_helpers_prepend_toks \relax}
+% \protected\def\appendtoksonce {\syst_helpers_append_toks_once \relax}
+% \protected\def\prependtoksonce{\syst_helpers_prepend_toks_once\relax}
%
% \def\syst_helpers_append_toks_indeed
% {\dodoglobal\m_syst_helpers_scratch\doubleexpandafter{\expandafter\the\expandafter\m_syst_helpers_scratch\the\t_syst_helpers_scratch}}
@@ -5598,13 +5611,13 @@
% \donothing
% \syst_helpers_prepend_toks_indeed}
-% \unexpanded\def\appendtoks#1\to#2%
+% \protected\def\appendtoks#1\to#2%
% {\toksapp#2{#1}%
% \ifx\dodoglobal\relax\else
% \dodoglobal#2#2%
% \fi}
%
-% \unexpanded\def\prependtoks#1\to#2%
+% \protected\def\prependtoks#1\to#2%
% {\tokspre#2{#1}%
% \ifx\dodoglobal\relax\else
% \dodoglobal#2#2%
@@ -5622,7 +5635,7 @@
% \dodoglobal\m_syst_helpers_scratch\m_syst_helpers_scratch
% \fi}
-\unexpanded\def\appendtoks#1\to#2%
+\protected\def\appendtoks#1\to#2%
{\ifx\dodoglobal\relax
\expandafter\toksapp
\else
@@ -5630,7 +5643,7 @@
\expandafter\gtoksapp
\fi#2{#1}}
-\unexpanded\def\prependtoks#1\to#2%
+\protected\def\prependtoks#1\to#2%
{\ifx\dodoglobal\relax
\expandafter\tokspre
\else
@@ -5654,14 +5667,14 @@
\expandafter\gtokspre
\fi\m_syst_helpers_scratch\t_syst_helpers_scratch}
-\unexpanded\def\appendtoksonce#1\to#2%
+\protected\def\appendtoksonce#1\to#2%
{\let\m_syst_helpers_scratch#2%
\t_syst_helpers_scratch{#1}%
\doifelseintoks\t_syst_helpers_scratch\m_syst_helpers_scratch
\donothing
\syst_helpers_append_toks_indeed}
-\unexpanded\def\prependtoksonce#1\to#2%
+\protected\def\prependtoksonce#1\to#2%
{\let\m_syst_helpers_scratch#2%
\t_syst_helpers_scratch{#1}%
\doifelseintoks\t_syst_helpers_scratch\m_syst_helpers_scratch
@@ -5670,7 +5683,7 @@
%D The test macro:
-\unexpanded\def\doifelseintoks#1#2% #1 en #2 zijn toks
+\protected\def\doifelseintoks#1#2% #1 en #2 zijn toks
{\edef\asciia{\detokenize\expandafter{\the#1}}%
\edef\asciib{\detokenize\expandafter{\the#2}}%
\doifelsestringinstring\asciia\asciib}
@@ -5698,14 +5711,14 @@
\newtoks \collectingtoks
-\unexpanded\def\startcollect #1\stopcollect {\toksapp \collectingtoks{#1}}
-\unexpanded\def\startexpandedcollect#1\stopexpandedcollect{\etoksapp\collectingtoks{#1}}
+\protected\def\startcollect #1\stopcollect {\toksapp \collectingtoks{#1}}
+\protected\def\startexpandedcollect#1\stopexpandedcollect{\etoksapp\collectingtoks{#1}}
-\unexpanded\def\startcollecting{\collectingtoks\emptytoks}
-\unexpanded\def\stopcollecting {\the\collectingtoks}
+\protected\def\startcollecting{\collectingtoks\emptytoks}
+\protected\def\stopcollecting {\the\collectingtoks}
-\unexpanded\def\collect {\toksapp \collectingtoks}
-\unexpanded\def\collectexpanded{\etoksapp\collectingtoks}
+\protected\def\collect {\toksapp \collectingtoks}
+\protected\def\collectexpanded{\etoksapp\collectingtoks}
%D A nice one too:
@@ -5715,7 +5728,7 @@
% {\scratchtoks{xaa} \removetoks x\from\scratchtoks [\the\scratchtoks]}
% {\scratchtoks{a\relax b} \removetoks \relax\from\scratchtoks [\showthe\scratchtoks]}
-\unexpanded\def\removetoks#1\from#2%
+\protected\def\removetoks#1\from#2%
{\def\syst_helpers_remove_toks##1#1##2\empty\empty\empty##3^^^^0004%
{\def\m_syst_string_one{##3}%
\ifx\m_syst_string_one\empty#2{##1}\else#2{##1##2}\fi}%
@@ -5723,22 +5736,22 @@
%D Also:
-% \unexpanded\def\appendetoks #1\to{\normalexpanded{\appendtoks #1}\to}
-% \unexpanded\def\prependetoks#1\to{\normalexpanded{\prependtoks#1}\to}
+% \protected\def\appendetoks #1\to{\normalexpanded{\appendtoks #1}\to}
+% \protected\def\prependetoks#1\to{\normalexpanded{\prependtoks#1}\to}
-% \unexpanded\def\appendetoks#1\to#2%
+% \protected\def\appendetoks#1\to#2%
% {\etoksapp#2{#1}%
% \ifx\dodoglobal\relax\else
% \global#2#2%
% \fi}
%
-% \unexpanded\def\prependetoks#1\to#2%
+% \protected\def\prependetoks#1\to#2%
% {\etokspre#2{#1}%
% \ifx\dodoglobal\relax\else
% \global#2#2%
% \fi}
-\unexpanded\def\appendetoks#1\to#2%
+\protected\def\appendetoks#1\to#2%
{\ifx\dodoglobal\relax
\expandafter\etoksapp
\else
@@ -5746,7 +5759,7 @@
\expandafter\xtoksapp
\fi#2{#1}}
-\unexpanded\def\prependetoks#1\to#2%
+\protected\def\prependetoks#1\to#2%
{\ifx\dodoglobal\relax
\expandafter\etokspre
\else
@@ -5756,7 +5769,7 @@
%D Hm.
-\unexpanded\def\flushtoks#1% nb: can reassign to #1 again, hence the indirectness
+\protected\def\flushtoks#1% nb: can reassign to #1 again, hence the indirectness
{\t_syst_helpers_scratch#1\relax
\dodoglobal#1\emptytoks
\the\t_syst_helpers_scratch\relax}
@@ -5783,12 +5796,12 @@
\let\syst_helpers_split_string\relax
-\unexpanded\def\beforesplitstring#1\at#2\to#3%
+\protected\def\beforesplitstring#1\at#2\to#3%
{\def\syst_helpers_split_string##1#2##2#2##3\\%
{\def#3{##1}}%
\expandafter\syst_helpers_split_string#1#2#2\\}
-\unexpanded\def\aftersplitstring#1\at#2\to#3%
+\protected\def\aftersplitstring#1\at#2\to#3%
{\def\syst_helpers_split_string##1#2##2@@@##3\\%
{\def#3{##2}}%
\expandafter\syst_helpers_split_string#1@@@#2@@@\\}
@@ -5798,7 +5811,7 @@
%D
%D A bonus macro.
-\unexpanded\def\splitstring#1\at#2\to#3\and#4%
+\protected\def\splitstring#1\at#2\to#3\and#4%
{\def\syst_helpers_split_string##1#2##2\empty\empty\empty##3\\%
{\def#3{##1}%
\def\syst_helpers_split_string{##3}%
@@ -5809,7 +5822,7 @@
\fi}%
\expandafter\syst_helpers_split_string#1\empty\empty\empty#2\empty\empty\empty\\}
-\unexpanded\def\greedysplitstring#1\at#2\to#3\and#4%
+\protected\def\greedysplitstring#1\at#2\to#3\and#4%
{\edef\asciib{#1}%
\let\asciic\asciib
\let#3\empty
@@ -5831,12 +5844,12 @@
%D aftertestandsplitstring,
%D testandsplitstring}
-\unexpanded\def\beforetestandsplitstring#1\at#2\to#3%
+\protected\def\beforetestandsplitstring#1\at#2\to#3%
{\def\syst_helpers_split_string##1#2##2#2##3##4\\%
{\ifx##3\empty\let#3\empty\else\def#3{##1}\fi}%
\expandafter\syst_helpers_split_string#1#2#2\empty\\}
-\unexpanded\def\aftertestandsplitstring#1\at#2\to#3%
+\protected\def\aftertestandsplitstring#1\at#2\to#3%
{\def\syst_helpers_split_string ##1#2##2@@@##3##4\\%
{\ifx##3\empty\let#3\empty\else\def#3{##2}\fi}%
\expandafter\syst_helpers_split_string #1@@@#2@@@\empty\\}
@@ -5853,17 +5866,17 @@
%D splitatcolon,
%D splitatcolons}
-\unexpanded\def\splitatperiod #1{\normalexpanded{\syst_helpers_splitatperiod #1}..\relax}
-\unexpanded\def\splitatcomma #1{\normalexpanded{\syst_helpers_splitatcomma #1},,\relax} % not at ", "
-\unexpanded\def\splitatasterisk#1{\normalexpanded{\syst_helpers_splitatasterisk#1}**\relax}
-\unexpanded\def\splitatcolon #1{\normalexpanded{\syst_helpers_splitatcolon #1}::\relax}
-\unexpanded\def\splitatcolons #1{\normalexpanded{\syst_helpers_splitatcolons #1}::::\relax}
+\protected\def\splitatperiod #1{\normalexpanded{\syst_helpers_splitatperiod #1}..\relax}
+\protected\def\splitatcomma #1{\normalexpanded{\syst_helpers_splitatcomma #1},,\relax} % not at ", "
+\protected\def\splitatasterisk#1{\normalexpanded{\syst_helpers_splitatasterisk#1}**\relax}
+\protected\def\splitatcolon #1{\normalexpanded{\syst_helpers_splitatcolon #1}::\relax}
+\protected\def\splitatcolons #1{\normalexpanded{\syst_helpers_splitatcolons #1}::::\relax}
-\unexpanded\def\syst_helpers_splitatperiod #1.#2.#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatcomma #1,#2,#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatasterisk #1*#2*#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatcolon #1:#2:#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatcolons #1::#2::#3\relax#4#5{\edef#4{#1}\edef#5{#2}}
+\protected\def\syst_helpers_splitatperiod #1.#2.#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\protected\def\syst_helpers_splitatcomma #1,#2,#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\protected\def\syst_helpers_splitatasterisk #1*#2*#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\protected\def\syst_helpers_splitatcolon #1:#2:#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\protected\def\syst_helpers_splitatcolons #1::#2::#3\relax#4#5{\edef#4{#1}\edef#5{#2}}
%D \macros
%D {removesubstring}
@@ -5876,7 +5889,7 @@
%D
%D Which in terms of \TEX\ looks like:
-\unexpanded\def\removesubstring#1\from#2\to#3%
+\protected\def\removesubstring#1\from#2\to#3%
{\splitstring#2\to\m_syst_string_one\and\m_syst_string_two
\dodoglobal#3{\m_syst_string_one\m_syst_string_two}}
@@ -5933,36 +5946,36 @@
%D
%D The faster alternatives are:
-\unexpanded\def\appendtocommalist#1#2%
+\protected\def\appendtocommalist#1#2%
{\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}
-\unexpanded\def\prependtocommalist#1#2%
+\protected\def\prependtocommalist#1#2%
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}
-\unexpanded\def\addtocommalist#1#2% {item} \cs
+\protected\def\addtocommalist#1#2% {item} \cs
{\rawdoifelseinset{#1}#2\resetglobal
{\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
-\unexpanded\def\pretocommalist#1#2% {item} \cs
+\protected\def\pretocommalist#1#2% {item} \cs
{\rawdoifelseinset{#1}#2\resetglobal
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
-\unexpanded\def\robustdoifelseinset#1#2%
+\protected\def\robustdoifelseinset#1#2%
{\edef\m_syst_string_one{\detokenize\expandafter{\normalexpanded{#1}}}%
\edef\m_syst_string_two{\detokenize\expandafter{\normalexpanded{#2}}}%
\rawdoifelseinset\m_syst_string_one\m_syst_string_two}
\let\robustdoifinsetelse\robustdoifelseinset
-\unexpanded\def\robustaddtocommalist#1#2% {item} \cs
+\protected\def\robustaddtocommalist#1#2% {item} \cs
{\robustdoifelseinset{#1}#2\resetglobal
{\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
-\unexpanded\def\robustpretocommalist#1#2% {item} \cs
+\protected\def\robustpretocommalist#1#2% {item} \cs
{\robustdoifelseinset{#1}#2\resetglobal
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
-\unexpanded\def\xsplitstring#1#2% \cs {str}
+\protected\def\xsplitstring#1#2% \cs {str}
{\def\syst_helpers_split_string##1,#2,##2,#2,##3\\%
{\edef\m_syst_string_one{\bcleanedupcommalist##1\empty\empty\relax}%
\edef\m_syst_string_two{\acleanedupcommalist##2,,\relax}}%
@@ -5972,7 +5985,7 @@
\def\bcleanedupcommalist#1#2\relax{\if#1,\else#1\fi#2}
\def\acleanedupcommalist#1,,#2\relax{#1}
-\unexpanded\def\removefromcommalist#1#2% to be sped up
+\protected\def\removefromcommalist#1#2% to be sped up
{\rawdoifelseinset{#1}#2%
{\normalexpanded{\xsplitstring\noexpand#2{#1}}%
\dodoglobal\edef#2%
@@ -5983,10 +5996,10 @@
\fi}}
\resetglobal}
-% \unexpanded\def\addtocommalist#1#2% upto 3 times slower
+% \protected\def\addtocommalist#1#2% upto 3 times slower
% {\dodoglobal\edef#2{\ctxcommand{addtocommalist(\!!bs#1\!!es,\!!bs#2\!!es)}}}
%
-% \unexpanded\def\removefromcommalist#1#2% faster and more robust
+% \protected\def\removefromcommalist#1#2% faster and more robust
% {\dodoglobal\edef#2{\ctxcommand{addtocommalist(\!!bs#1\!!es,\!!bs#2\!!es)}}}
%D \macros
@@ -6008,7 +6021,7 @@
\edef\m_syst_string_four{\ifx\m_syst_string_four\empty\else\m_syst_string_four,\fi#1}%
\fi}
-\unexpanded\def\substituteincommalist#1#2#3% old, new, list (slooow)
+\protected\def\substituteincommalist#1#2#3% old, new, list (slooow)
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#2}%
\let\m_syst_string_four\empty
@@ -6071,7 +6084,7 @@
\fi
\advance\commalistcounter\plusone}
-\unexpanded\def\replaceincommalist#1#2% #1 = commalistelement #2 = position starts at 1
+\protected\def\replaceincommalist#1#2% #1 = commalistelement #2 = position starts at 1
{\c_syst_helpers_comma_list_index#2\relax
\let\m_syst_helpers_comma_list_target\empty
\let\commalistelement\empty
@@ -6095,7 +6108,7 @@
\expandafter\syst_helpers_comma_list_command_global_step
\fi}
-\unexpanded\def\globalprocesscommalist[#1]#2%
+\protected\def\globalprocesscommalist[#1]#2%
{\glet\m_syst_helpers_comma_list_command_global#2%
\expandafter\syst_helpers_comma_list_command_global_step#1,],}
@@ -6142,23 +6155,26 @@
\def\numberofpoints #1{\the\numexpr\dimexpr#1\relax/\maxcard\relax}
%D \macros
-%D {swapdimens,swapcounts,swapmacros,
+%D {swapdimens,swapskips,swapcounts,swapmacros,
%D globalswapdimens,globalswapcounts,globalswapmacros}
%D
%D Simple but effective are the next two macros. There name exactly states their
%D purpose.
\newdimen\d_syst_helpers_swapped
+\newskip \s_syst_helpers_swapped
\newcount\c_syst_helpers_swapped
\let \m_syst_helpers_swapped\relax
-\unexpanded\def\swapdimens#1#2{\d_syst_helpers_swapped #1\relax#1#2\relax#2\d_syst_helpers_swapped}
-\unexpanded\def\swapcounts#1#2{\c_syst_helpers_swapped #1\relax#1#2\relax#2\c_syst_helpers_swapped}
-\unexpanded\def\swapmacros#1#2{\let\m_syst_helpers_swapped#1\let #1#2\let #2\m_syst_helpers_swapped}
+\protected\def\swapdimens#1#2{\d_syst_helpers_swapped #1\relax#1#2\relax#2\d_syst_helpers_swapped}
+\protected\def\swapskips #1#2{\s_syst_helpers_swapped #1\relax#1#2\relax#2\s_syst_helpers_swapped}
+\protected\def\swapcounts#1#2{\c_syst_helpers_swapped #1\relax#1#2\relax#2\c_syst_helpers_swapped}
+\protected\def\swapmacros#1#2{\let\m_syst_helpers_swapped#1\let #1#2\let #2\m_syst_helpers_swapped}
-\unexpanded\def\globalswapdimens#1#2{\d_syst_helpers_swapped #1\global#1#2\global#2\d_syst_helpers_swapped}
-\unexpanded\def\globalswapcounts#1#2{\c_syst_helpers_swapped #1\global#1#2\global#2\c_syst_helpers_swapped}
-\unexpanded\def\globalswapmacros#1#2{\let\m_syst_helpers_swapped#1\glet #1#2\glet #2\m_syst_helpers_swapped}
+\protected\def\globalswapdimens#1#2{\d_syst_helpers_swapped #1\global#1#2\global#2\d_syst_helpers_swapped}
+\protected\def\globalswapskips #1#2{\s_syst_helpers_swapped #1\global#1#2\global#2\s_syst_helpers_swapped}
+\protected\def\globalswapcounts#1#2{\c_syst_helpers_swapped #1\global#1#2\global#2\c_syst_helpers_swapped}
+\protected\def\globalswapmacros#1#2{\let\m_syst_helpers_swapped#1\glet #1#2\glet #2\m_syst_helpers_swapped}
%D \macros
%D {pushmacro,popmacro}
@@ -6177,7 +6193,7 @@
% \let\m_syst_helpers_push_macro\empty
%
-% \unexpanded\def\globalpushmacro#1%
+% \protected\def\globalpushmacro#1%
% {\xdef\m_syst_helpers_push_macro{\string#1}%
% \ifcsname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname \else
% \expandafter\newcount\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname
@@ -6185,12 +6201,12 @@
% \global\advance\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname \plusone
% \expandafter\glet\csname\the\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname\m_syst_helpers_push_macro\endcsname#1}
%
-% \unexpanded\def\globalpopmacro#1%
+% \protected\def\globalpopmacro#1%
% {\xdef\m_syst_helpers_push_macro{\string#1}%
% \expandafter\glet\expandafter#1\csname\the\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname\m_syst_helpers_push_macro\endcsname
% \global\advance\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname \minusone}
%
-% \unexpanded\def\localpushmacro#1% this one can be used to push a value over an \egroup
+% \protected\def\localpushmacro#1% this one can be used to push a value over an \egroup
% {\xdef\m_syst_helpers_push_macro{\string#1}%
% \ifcsname\??localpushedmacro\m_syst_helpers_push_macro\endcsname \else
% \expandafter\newcount\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
@@ -6198,7 +6214,7 @@
% \global\advance\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname \plusone
% \expandafter\glet\csname\the\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname\m_syst_helpers_push_macro\endcsname#1}
%
-% \unexpanded\def\localpopmacro#1%
+% \protected\def\localpopmacro#1%
% {\xdef\m_syst_helpers_push_macro{\string#1}%
% \expandafter\let\expandafter#1\csname\the\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname\m_syst_helpers_push_macro\endcsname
% \global\advance\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname \minusone }
@@ -6222,7 +6238,7 @@
{\expandafter\newcount\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
\global\advance\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname\plusone}
-\unexpanded\def\globalpushmacro#1%
+\protected\def\globalpushmacro#1%
{\xdef\m_syst_helpers_push_macro{\csstring#1}%
\ifcsname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname
\global\advance\lastnamedcs\plusone
@@ -6231,7 +6247,7 @@
\fi
\expandafter\glet\csname\the\lastnamedcs\m_syst_helpers_push_macro\endcsname#1}
-\unexpanded\def\localpushmacro#1% this one can be used to push a value over an \egroup
+\protected\def\localpushmacro#1% this one can be used to push a value over an \egroup
{\xdef\m_syst_helpers_push_macro{\csstring#1}%
\ifcsname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
\global\advance\lastnamedcs\plusone
@@ -6240,13 +6256,13 @@
\fi
\expandafter\glet\csname\the\lastnamedcs\m_syst_helpers_push_macro\endcsname#1}
-\unexpanded\def\globalpopmacro#1%
+\protected\def\globalpopmacro#1%
{\xdef\m_syst_helpers_push_macro{\csstring#1}%
\c_syst_helpers_pop_count\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname
\global\advance\lastnamedcs \minusone
\expandafter\glet\expandafter#1\csname\the\c_syst_helpers_pop_count\m_syst_helpers_push_macro\endcsname}
-\unexpanded\def\localpopmacro#1%
+\protected\def\localpopmacro#1%
{\xdef\m_syst_helpers_push_macro{\csstring#1}%
\c_syst_helpers_pop_count\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
\global\advance\lastnamedcs \minusone
@@ -6273,7 +6289,7 @@
\newdimen\localhsize
-\unexpanded\def\setlocalhsize % don't change !
+\protected\def\setlocalhsize % don't change !
{\doifelsenextoptional
\syst_helpers_set_local_hsize_yes
\syst_helpers_set_local_hsize_nop}
@@ -6309,7 +6325,7 @@
%D three tokens per call. Anyone familiar with the not||values ones, can derive
%D their meaning from the definitions.
-\unexpanded\def\doifvalue#1#2%
+\protected\def\doifvalue#1#2%
{\edef\m_syst_string_one{\csname#1\endcsname}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -6318,7 +6334,7 @@
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifnotvalue#1#2%
+\protected\def\doifnotvalue#1#2%
{\edef\m_syst_string_one{\csname#1\endcsname}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -6327,7 +6343,7 @@
\expandafter\firstofoneargument
\fi}
-\unexpanded\def\doifelsevalue#1#2%
+\protected\def\doifelsevalue#1#2%
{\edef\m_syst_string_one{\csname#1\endcsname}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two
@@ -6336,7 +6352,7 @@
\expandafter\secondoftwoarguments
\fi}
-\unexpanded\def\doifnothing#1%
+\protected\def\doifnothing#1%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\firstofoneargument
@@ -6344,7 +6360,7 @@
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifsomething#1%
+\protected\def\doifsomething#1%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\gobbleoneargument
@@ -6352,7 +6368,7 @@
\expandafter\firstofoneargument
\fi}
-\unexpanded\def\doifelsenothing#1%
+\protected\def\doifelsenothing#1%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\firstoftwoarguments
@@ -6360,7 +6376,7 @@
\expandafter\secondoftwoarguments
\fi}
-\unexpanded\def\doifelsesomething#1%
+\protected\def\doifelsesomething#1%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty
\expandafter\secondoftwoarguments
@@ -6368,7 +6384,7 @@
\expandafter\firstoftwoarguments
\fi}
-\unexpanded\def\doifvaluenothing#1%
+\protected\def\doifvaluenothing#1%
{\edef\m_syst_string_one{\csname#1\endcsname}%
\ifx\m_syst_string_one\empty
\expandafter\firstofoneargument
@@ -6376,7 +6392,7 @@
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\doifvaluesomething#1%
+\protected\def\doifvaluesomething#1%
{\edef\m_syst_string_one{\csname#1\endcsname}%
\ifx\m_syst_string_one\empty
\expandafter\gobbleoneargument
@@ -6384,7 +6400,7 @@
\expandafter\firstofoneargument
\fi}
-\unexpanded\def\doifelsevaluenothing#1%
+\protected\def\doifelsevaluenothing#1%
{\edef\m_syst_string_one{\csname#1\endcsname}%
\ifx\m_syst_string_one\empty
\expandafter\firstoftwoarguments
@@ -6439,9 +6455,9 @@
\processcommalist[#3]\syst_helpers_do_common_check_all
\ifdone\expandafter#1\else\expandafter#2\fi}
-\unexpanded\def\doifelseallcommon{\syst_helpers_do_if_all_common_else\firstoftwoarguments\secondoftwoarguments}
-\unexpanded\def\doifallcommon {\syst_helpers_do_if_all_common_else\firstofonearguments\gobbleoneargument }
-\unexpanded\def\doifnotallcommon {\syst_helpers_do_if_all_common_else\gobbleoneargument \firstofonearguments }
+\protected\def\doifelseallcommon{\syst_helpers_do_if_all_common_else\firstoftwoarguments\secondoftwoarguments}
+\protected\def\doifallcommon {\syst_helpers_do_if_all_common_else\firstofonearguments\gobbleoneargument }
+\protected\def\doifnotallcommon {\syst_helpers_do_if_all_common_else\gobbleoneargument \firstofonearguments }
\let\doifallcommonelse\doifelseallcommon
@@ -6464,38 +6480,38 @@
%D These might end up as \LUA based helpers (i.e. consider these
%D obsolete:
-\unexpanded\def\syst_helpers_do_IF#1#2%
+\protected\def\syst_helpers_do_IF#1#2%
{\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
\expandafter\firstofoneargument
\else
\expandafter\gobbleoneargument
\fi}
-\unexpanded\def\syst_helpers_do_IF_NOT#1#2%
+\protected\def\syst_helpers_do_IF_NOT#1#2%
{\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
\expandafter\gobbleoneargument
\else
\expandafter\firstofoneargument
\fi}
-\unexpanded\def\syst_helpers_do_IF_ELSE#1#2%
+\protected\def\syst_helpers_do_IF_ELSE#1#2%
{\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-\unexpanded\def\syst_helpers_do_IF_INSTRING_ELSE#1#2%
+\protected\def\syst_helpers_do_IF_INSTRING_ELSE#1#2%
{\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-\unexpanded\def\DOIF #1#2{\normalexpanded{\syst_helpers_do_IF {#1}{#2}}}% will become obsolete
-\unexpanded\def\DOIFNOT #1#2{\normalexpanded{\syst_helpers_do_IF_NOT {#1}{#2}}}% will become obsolete
-\unexpanded\def\DOIFELSE #1#2{\normalexpanded{\syst_helpers_do_IF_ELSE {#1}{#2}}}% will become obsolete
-\unexpanded\def\DOIFINSTRINGELSE #1#2{\normalexpanded{\syst_helpers_do_IF_INSTRING_ELSE{#1}{#2}}}% will become obsolete
+\protected\def\DOIF #1#2{\normalexpanded{\syst_helpers_do_IF {#1}{#2}}}% will become obsolete
+\protected\def\DOIFNOT #1#2{\normalexpanded{\syst_helpers_do_IF_NOT {#1}{#2}}}% will become obsolete
+\protected\def\DOIFELSE #1#2{\normalexpanded{\syst_helpers_do_IF_ELSE {#1}{#2}}}% will become obsolete
+\protected\def\DOIFINSTRINGELSE #1#2{\normalexpanded{\syst_helpers_do_IF_INSTRING_ELSE{#1}{#2}}}% will become obsolete
%D \macros
%D {dosingleargumentwithset,
@@ -6520,7 +6536,7 @@
%D \def\dodefinesomething[#1][#2]%
%D {\getparameters[\??xx#1][#2]}
%D
-%D \unexpanded\def\definesomething%
+%D \protected\def\definesomething%
%D {\dodoubleargumentwithset\dodefinesomething}
%D \stoptyping
%D
@@ -6574,7 +6590,7 @@
\let\m_syst_helpers_strip_character\empty
-\unexpanded\def\stripcharacter#1\from#2\to#3%
+\protected\def\stripcharacter#1\from#2\to#3%
{\def\syst_helpers_strip_character##1#1##2\end
{\edef\m_syst_helpers_strip_character{\m_syst_helpers_strip_character##1}%
\doifnotempty{##2}{\syst_helpers_strip_character##2\end}}%
@@ -6583,7 +6599,7 @@
\expandafter\syst_helpers_strip_character\m_syst_string_one#1\end
\dodoglobal\let#3\m_syst_helpers_strip_character}
-\unexpanded\def\stripspaces\from#1\to#2% will become \unspacestring#1\from#2
+\protected\def\stripspaces\from#1\to#2% will become \unspacestring#1\from#2
{\stripcharacter{ }\from#1\to#2}
%D \macros
@@ -6592,7 +6608,7 @@
%D The next macro does the same but is more compatible with other macros, like \type
%D {\convert...}.
-\unexpanded\def\unspacestring#1\to#2%
+\protected\def\unspacestring#1\to#2%
{\stripcharacter{ }\from#1\to#2}
%D \macros
@@ -6697,7 +6713,7 @@
\syst_helpers_process_separated_list_step}%
\expandafter\syst_helpers_process_separated_list_step\gobbleoneargument#1#3]#3}
-\unexpanded\def\processseparatedlist[%
+\protected\def\processseparatedlist[%
{\syst_helpers_process_separated_list\relax}
%D \macros
@@ -6720,7 +6736,7 @@
\let\syst_helpers_process_any_list_indeed\relax
\let\syst_helpers_process_any_list_step \relax
-\unexpanded\def\processlist#1#2#3#4% no blank skipping !
+\protected\def\processlist#1#2#3#4% no blank skipping !
{\def\syst_helpers_process_any_list_indeed##1#2%
{\def\syst_helpers_process_any_list_step####1####2#3%
{\ifx#2####1%
@@ -6749,7 +6765,7 @@
%D This command can be integrated in \type {\getparameters}, but we decided best not
%D to do so.
-\unexpanded\def\processassignlist#1[#2]#3%
+\protected\def\processassignlist#1[#2]#3%
{\def\syst_helpers_process_assign_list_assign[##1=##2=##3]%
{\doif{##3}\relax{#3{##1}}}%
\def\syst_helpers_process_assign_list_step##1%
@@ -6772,7 +6788,7 @@
\let\m_syst_helpers_untexed\empty
-\unexpanded\def\untexsomething
+\protected\def\untexsomething
{\begingroup
\catcode\leftbraceasciicode \ignorecatcode
\catcode\rightbraceasciicode\ignorecatcode
@@ -6784,8 +6800,8 @@
\endgroup
\let#3\m_syst_helpers_untexed}
-\unexpanded\def\untexargument{\untexsomething\convertargument}
-\unexpanded\def\untexcommand {\untexsomething\convertcommand}
+\protected\def\untexargument{\untexsomething\convertargument}
+\protected\def\untexcommand {\untexsomething\convertcommand}
%D \macros
%D {ScaledPointsToBigPoints,ScaledPointsToWholeBigPoints}
@@ -6801,16 +6817,16 @@
%D
%D In pure \TEX:
-% \unexpanded\def\PointsToBigPoints#1#2%
+% \protected\def\PointsToBigPoints#1#2%
% {\edef#2{\withoutpt\the\dimexpr.996264\dimexpr#1\relax\relax}}
%
-% \unexpanded\def\PointsToWholeBigPoints#1#2%
+% \protected\def\PointsToWholeBigPoints#1#2%
% {\edef#2{\the\numexpr\dimexpr.996264\dimexpr#1\relax\relax/\maxcard\relax}}
%
-% \unexpanded\def\ScaledPointsToBigPoints#1% % #2
+% \protected\def\ScaledPointsToBigPoints#1% % #2
% {\PointsToBigPoints{\number#1\scaledpoint}} % {#2}
%
-% \unexpanded\def\ScaledPointsToWholeBigPoints#1% % #2
+% \protected\def\ScaledPointsToWholeBigPoints#1% % #2
% {\PointsToWholeBigPoints{\number#1\scaledpoint}} % {#2}
%D This is slower but cleaner and more accurate too. The only place these are still
@@ -6819,10 +6835,10 @@
\let\tobigpoints \clf_tobigpoints
\let\towholebigpoints\clf_towholebigpoints
-\unexpanded\def\PointsToBigPoints #1#2{\edef#2{\tobigpoints #1}} % can be avoided
-\unexpanded\def\PointsToWholeBigPoints #1#2{\edef#2{\towholebigpoints#1}} % can be avoided
-\unexpanded\def\ScaledPointsToBigPoints #1#2{\edef#2{\tobigpoints #1\scaledpoint}} % obsolete
-\unexpanded\def\ScaledPointsToWholeBigPoints#1#2{\edef#2{\towholebigpoints#1\scaledpoint}} % obsolete
+\protected\def\PointsToBigPoints #1#2{\edef#2{\tobigpoints #1}} % can be avoided
+\protected\def\PointsToWholeBigPoints #1#2{\edef#2{\towholebigpoints#1}} % can be avoided
+\protected\def\ScaledPointsToBigPoints #1#2{\edef#2{\tobigpoints #1\scaledpoint}} % obsolete
+\protected\def\ScaledPointsToWholeBigPoints#1#2{\edef#2{\towholebigpoints#1\scaledpoint}} % obsolete
%D \macros
%D {PointsToReal}
@@ -6834,7 +6850,7 @@
%D \PointsToReal {dimension} \target
%D \stoptyping
-\unexpanded\def\PointsToReal#1#2%
+\protected\def\PointsToReal#1#2%
{\edef#2{\withoutpt\the\dimexpr#1}}
%D \macros
@@ -6869,7 +6885,7 @@
%D \starttyping
%D \newbox\b_syst_helpers_dlh
%D
-%D \unexpanded\def\dontleavehmode
+%D \protected\def\dontleavehmode
%D {\ifhmode\else \ifmmode\else
%D \setbox\b_syst_helpers_dlh\hbox{\mathsurround\zeropoint\everymath\emptytoks$ $}\unhbox\b_syst_helpers_dlh
%D \fi \fi}
@@ -6891,10 +6907,10 @@
%D
%D The first argument may be a \type{\macro}.
-% \unexpanded\def\uppercasestring#1\to#2%
+% \protected\def\uppercasestring#1\to#2%
% {\uppercase\expandafter{\expandafter\dodoglobal\expandafter\edef\expandafter#2\expandafter{\normalexpanded{#1}}}}
%
-% \unexpanded\def\lowercasestring#1\to#2%
+% \protected\def\lowercasestring#1\to#2%
% {\lowercase\expandafter{\expandafter\dodoglobal\expandafter\edef\expandafter#2\expandafter{\normalexpanded{#1}}}}
%D These macros are sort of obsolete as we never use uppercase this way. But
@@ -6903,8 +6919,8 @@
\def\utfupper#1{\clf_upper{#1}} % expandable
\def\utflower#1{\clf_lower{#1}} % expandable
-\unexpanded\def\uppercasestring#1\to#2{\dodoglobal\edef#2{\clf_upper{#1}}}
-\unexpanded\def\lowercasestring#1\to#2{\dodoglobal\edef#2{\clf_lower{#1}}}
+\protected\def\uppercasestring#1\to#2{\dodoglobal\edef#2{\clf_upper{#1}}}
+\protected\def\lowercasestring#1\to#2{\dodoglobal\edef#2{\clf_lower{#1}}}
%D \macros
%D {handletokens}
@@ -6949,14 +6965,14 @@
\expandafter\syst_helpers_count_token
\fi}
-\unexpanded\def\counttoken#1\in#2\to#3%
+\protected\def\counttoken#1\in#2\to#3%
{\privatescratchcounter\zerocount
\def\m_syst_string_one{#1}%
\def\m_syst_string_two{\end}%
\syst_helpers_count_token#2\end
\dodoglobal#3\privatescratchcounter}
-\unexpanded\def\counttokens#1\to#2%
+\protected\def\counttokens#1\to#2%
{\privatescratchcounter\zerocount
\def\syst_helpers_count_token##1{\advance\privatescratchcounter\plusone}%
\handletokens#1\with\syst_helpers_count_token
@@ -6968,7 +6984,7 @@
%D Running this one not always gives the expected results. Consider for instance the
%D macro for which I originally wrote this token handler.
-\unexpanded\def\splitofftokens#1\from#2\to#3% slow but hardly used
+\protected\def\splitofftokens#1\from#2\to#3% slow but hardly used
{\ifnum#1>\zerocount
\privatescratchcounter#1\relax
\def\syst_helpers_split_off_tokens##1%
@@ -7012,7 +7028,7 @@
%D assignment, this time by using \type {\futurelet}, and grabbing an argument as
%D well. That way we can handle the sentinal, a blank space and grouped tokens.
-\unexpanded\def\syst_helpers_handle_tokens % \nexthandledtoken is part of interface
+\protected\def\syst_helpers_handle_tokens % \nexthandledtoken is part of interface
{\futurelet\nexthandledtoken\syst_helpers_handle_tokens_indeed}
\def\handletokens#1\with#2%
@@ -7064,8 +7080,8 @@
\newtoks\everysettrialtypesetting
\newtoks\everyresettrialtypesetting
-\unexpanded\def\settrialtypesetting {\the\everysettrialtypesetting } % obeys grouping so
-\unexpanded\def\resettrialtypesetting{\the\everyresettrialtypesetting} % this one is seldom needed
+\protected\def\settrialtypesetting {\the\everysettrialtypesetting } % obeys grouping so
+\protected\def\resettrialtypesetting{\the\everyresettrialtypesetting} % this one is seldom needed
\let\iftrialtypesetting\iffalse % so we have no \trialtypesettingtrue|false in mkiv !
@@ -7104,15 +7120,15 @@
%D This macro is first used in the tabulation macros.
%D
%D \starttyping
-%D \unexpanded\def\starthans%
+%D \protected\def\starthans%
%D {\processcontent{stophans}\test{\message{\test}\wait}}
%D \stoptyping
-\unexpanded\def\processcontent#1%
+\protected\def\processcontent#1%
{\begingroup\expandafter\syst_helpers_process_content\csname#1\endcsname}
-\unexpanded\def\syst_helpers_process_content#1#2#3%
- {\unexpanded\def\syst_helpers_process_content##1#1%
+\protected\def\syst_helpers_process_content#1#2#3%
+ {\protected\def\syst_helpers_process_content##1#1%
{\endgroup\def#2{##1}#3}%
\syst_helpers_process_content}
@@ -7158,10 +7174,10 @@
%D As an alternative for the next macro we can use a global assignment inside a box.
%D The \type {\empty}'s permits gobbling while preventing spurious \type {\relax}'s.
-\unexpanded\def\setdimensionwithunit#1#2#3% number unit dimension / nice trick
+\protected\def\setdimensionwithunit#1#2#3% number unit dimension / nice trick
{\afterassignment\gobblefourarguments#1=#2#3pt\relax\empty\empty\empty\empty}
-\unexpanded\def\freezedimensionwithunit#1#2%
+\protected\def\freezedimensionwithunit#1#2%
{\setdimensionwithunit\privatescratchdimen#1{#2}\edef#1{\the\privatescratchdimen}}
%D \macros
@@ -7169,7 +7185,7 @@
%D
%D Not that fast I guess, but here's a way to test for token registers being empty.
-\unexpanded\def\doifelsesometoks#1%
+\protected\def\doifelsesometoks#1%
{\edef\m_syst_string_one{\the#1}% one level expansion so quite ok
\ifx\m_syst_string_one\empty
\expandafter\secondoftwoarguments
@@ -7177,7 +7193,7 @@
\expandafter\firstoftwoarguments
\fi}
-\unexpanded\def\doifsometoks#1%
+\protected\def\doifsometoks#1%
{\edef\m_syst_string_one{\the#1}% one level expansion so quite ok
\ifx\m_syst_string_one\empty
\expandafter\gobbleoneargument
@@ -7185,7 +7201,7 @@
\expandafter\firstofoneargument
\fi}
-\unexpanded\def\doifemptytoks#1%
+\protected\def\doifemptytoks#1%
{\edef\m_syst_string_one{\the#1}% one level expansion so quite ok
\ifx\m_syst_string_one\empty
\expandafter\firstofoneargument
@@ -7209,7 +7225,7 @@
\expandafter\m_syst_action_nop
\fi}
-\unexpanded\def\strictdoifelsenextoptional#1#2%
+\protected\def\strictdoifelsenextoptional#1#2%
{\def\m_syst_action_yes{#1}%
\def\m_syst_action_nop{#2}%
\futurelet\nexttoken\syst_helpers_strict_inspect_next_character}
@@ -7258,7 +7274,7 @@
\def\syst_helpers_serialize_comma_list_step#1%
{\edef\serializedcommalist{\serializedcommalist#1}}
-\unexpanded\def\serializecommalist[#1]%
+\protected\def\serializecommalist[#1]%
{\let\serializedcommalist\empty
\processcommacommand[#1]\syst_helpers_serialize_comma_list_step}
@@ -7353,22 +7369,22 @@
\installsystemnamespace{measure}
-\unexpanded\def\definemeasure
+\protected\def\definemeasure
{\dodoubleargument\syst_helpers_define_measure}
\def\syst_helpers_define_measure[#1][#2]%
{\expandafter\def\csname\??measure#1\endcsname{#2}}
-\unexpanded\def\freezemeasure
+\protected\def\freezemeasure
{\dodoubleargument\syst_helpers_freeze_measure}
\def\syst_helpers_freeze_measure[#1][#2]%
{\expandafter\edef\csname\??measure#1\endcsname{\the\dimexpr#2}}
-\unexpanded\def\setmeasure #1#2{\expandafter\def \csname\??measure#1\endcsname{#2}} % quick way
-\unexpanded\def\setgmeasure#1#2{\expandafter\gdef\csname\??measure#1\endcsname{#2}} % quick way
-\unexpanded\def\setemeasure#1#2{\expandafter\edef\csname\??measure#1\endcsname{\the\dimexpr#2}} % quick way
-\unexpanded\def\setxmeasure#1#2{\expandafter\xdef\csname\??measure#1\endcsname{\the\dimexpr#2}} % quick way
+\protected\def\setmeasure #1#2{\expandafter\def \csname\??measure#1\endcsname{#2}} % quick way
+\protected\def\setgmeasure#1#2{\expandafter\gdef\csname\??measure#1\endcsname{#2}} % quick way
+\protected\def\setemeasure#1#2{\expandafter\edef\csname\??measure#1\endcsname{\the\dimexpr#2}} % quick way
+\protected\def\setxmeasure#1#2{\expandafter\xdef\csname\??measure#1\endcsname{\the\dimexpr#2}} % quick way
\def\measure
{\the\measured}
@@ -7393,22 +7409,22 @@
\installsystemnamespace{quantity}
-\unexpanded\def\definequantity
+\protected\def\definequantity
{\dodoubleargument\syst_helpers_define_quantity}
\def\syst_helpers_define_quantity[#1][#2]%
{\expandafter\def\csname\??quantity#1\endcsname{#2}}
-\unexpanded\def\freezequantity
+\protected\def\freezequantity
{\dodoubleargument\syst_helpers_freeze_quantity}
\def\syst_helpers_freeze_quantity[#1][#2]%
{\expandafter\edef\csname\??quantity#1\endcsname{\the\numexpr#2}}
-\unexpanded\def\setquantity #1#2{\expandafter\def \csname\??quantity#1\endcsname{#2}} % quick way
-\unexpanded\def\setgquantity#1#2{\expandafter\gdef\csname\??quantity#1\endcsname{#2}} % quick way
-\unexpanded\def\setequantity#1#2{\expandafter\edef\csname\??quantity#1\endcsname{\the\numexpr#2}} % quick way
-\unexpanded\def\setxquantity#1#2{\expandafter\xdef\csname\??quantity#1\endcsname{\the\numexpr#2}} % quick way
+\protected\def\setquantity #1#2{\expandafter\def \csname\??quantity#1\endcsname{#2}} % quick way
+\protected\def\setgquantity#1#2{\expandafter\gdef\csname\??quantity#1\endcsname{#2}} % quick way
+\protected\def\setequantity#1#2{\expandafter\edef\csname\??quantity#1\endcsname{\the\numexpr#2}} % quick way
+\protected\def\setxquantity#1#2{\expandafter\xdef\csname\??quantity#1\endcsname{\the\numexpr#2}} % quick way
\def\quantity
{\the\quantitied}
@@ -7538,9 +7554,9 @@
\def\comparedimension#1#2%
{\compresult
- \ifdim#1<#2%
+ \ifdim#1<#2 % space wil be skipped
\zerocount
- \else\ifdim#1<#2%
+ \else\ifdim#1<#2 % space wil be skipped
\plusone
\else
\plustwo
@@ -7552,7 +7568,7 @@
\zerocount
\else\ifdim\dimexpr#2-#1\relax<\roudingeps
\zerocount
- \else\ifdim#1<#2%
+ \else\ifdim#1<#2 % space wil be skipped
\plusone
\else
\plustwo
@@ -7562,19 +7578,19 @@
% \copycsname xxx\endcsname\csname ..\endcsname
-\unexpanded\def\copycsname{\expandafter\expandafter\expandafter\let\expandafter\expandafter\csname}
+\protected\def\copycsname{\expandafter\expandafter\expandafter\let\expandafter\expandafter\csname}
% \letcscsname \crap \csname ..\endcsname
% \letcsnamecs \csname ..\endcsname\crap
% \letcsnamecsname\csname ..\endcsname\csname ..\endcsname
-\unexpanded\def\letcscsname {\expandafter\let\expandafter}
-\unexpanded\def\letcsnamecs {\expandafter\let}
-\unexpanded\def\letcsnamecsname{\expandafter\expandafter\expandafter\let\expandafter\expandafter}
+\protected\def\letcscsname {\expandafter\let\expandafter}
+\protected\def\letcsnamecs {\expandafter\let}
+\protected\def\letcsnamecsname{\expandafter\expandafter\expandafter\let\expandafter\expandafter}
% another one, add an item to a commalist
-\unexpanded\def\addvalue#1#2% cs item
+\protected\def\addvalue#1#2% cs item
{\ifcsname#1\endcsname\else\expandafter\let\csname#1\endcsname\empty\fi
\normalexpanded{\noexpand\addtocommalist{#2}\expandafter\noexpand\csname#1\endcsname}}
@@ -7589,25 +7605,25 @@
\fi
\syst_helpers_unspaced}
-\unexpanded\def\unspaceargument#1\to#2%
+\protected\def\unspaceargument#1\to#2%
{\privatescratchcounter\catcode\spaceasciicode
\catcode\spaceasciicode\ignorecatcode
\scantextokens{\edef#2{#1}}%
\catcode\spaceasciicode\privatescratchcounter}
-\unexpanded\def\unspaceafter#1#2%
+\protected\def\unspaceafter#1#2%
{\unspaceargument#2\to\ascii
\expandafter#1\expandafter{\ascii}}
% sometimes handy:
-\unexpanded\def\doifelsehasspace#1%
+\protected\def\doifelsehasspace#1%
{\edef\m_syst_string_one{#1}%
\normalexpanded{\syst_helpers_if_has_space_else#1\space}\empty\relax}
\let\doifhasspaceelse\doifelsehasspace
-\unexpanded\def\syst_helpers_if_has_space_else#1 #2#3\relax % \space\empty\relax
+\protected\def\syst_helpers_if_has_space_else#1 #2#3\relax % \space\empty\relax
{\ifx\m_syst_string_one\space
\expandafter\firstoftwoarguments
\else\ifx#2\empty
@@ -7620,8 +7636,8 @@
\installsystemnamespace{flag}
-\unexpanded\def\setflag #1{\expandafter\dodoglobal\expandafter\let\csname\??flag#1\endcsname\zerocount}
-\unexpanded\def\resetflag#1{\expandafter\dodoglobal\expandafter\let\csname\??flag#1\endcsname\plusone}
+\protected\def\setflag #1{\expandafter\dodoglobal\expandafter\let\csname\??flag#1\endcsname\zerocount}
+\protected\def\resetflag#1{\expandafter\dodoglobal\expandafter\let\csname\??flag#1\endcsname\plusone}
\def\flag#1{\csname\??flag#1\endcsname}
@@ -7645,7 +7661,7 @@
\doubleexpandafter\firstofoneargument
\fi\fi}
-\unexpanded\def\inheritparameter[#1]#2[#3]#4[#5]% tag tokey fromkey
+\protected\def\inheritparameter[#1]#2[#3]#4[#5]% tag tokey fromkey
{\expandafter\def\csname#1#3\expandafter\endcsname\expandafter{\csname#1#5\endcsname}}
\def\syst_helpers_if_non_zero_positive_else#1#2\end % #3#4%
@@ -7671,50 +7687,56 @@
% here ?
-\unexpanded\def\dosetrawvalue #1#2#3{\expandafter \def\csname#1#2\endcsname{#3}}
-\unexpanded\def\dosetrawevalue#1#2#3{\expandafter\edef\csname#1#2\endcsname{#3}}
-\unexpanded\def\dosetrawgvalue#1#2#3{\expandafter\gdef\csname#1#2\endcsname{#3}}
-\unexpanded\def\dosetrawxvalue#1#2#3{\expandafter\xdef\csname#1#2\endcsname{#3}}
+\protected\def\dosetrawvalue #1#2#3{\expandafter \def\csname#1#2\endcsname{#3}}
+\protected\def\dosetrawevalue#1#2#3{\expandafter\edef\csname#1#2\endcsname{#3}}
+\protected\def\dosetrawgvalue#1#2#3{\expandafter\gdef\csname#1#2\endcsname{#3}}
+\protected\def\dosetrawxvalue#1#2#3{\expandafter\xdef\csname#1#2\endcsname{#3}}
-\unexpanded\def\getrawparameters {\dogetparameters\dosetrawvalue }
-\unexpanded\def\getraweparameters {\dogetparameters\dosetrawevalue}
-\unexpanded\def\getrawgparameters {\dogetparameters\dosetrawgvalue}
-\unexpanded\def\getrawxparameters {\dogetparameters\dosetrawxvalue}
+\protected\def\getrawparameters {\dogetparameters\dosetrawvalue }
+\protected\def\getraweparameters {\dogetparameters\dosetrawevalue}
+\protected\def\getrawgparameters {\dogetparameters\dosetrawgvalue}
+\protected\def\getrawxparameters {\dogetparameters\dosetrawxvalue}
-\unexpanded\def\globalgetrawparameters{\dogetparameters\dosetrawgvalue} % obsolete
+\protected\def\globalgetrawparameters{\dogetparameters\dosetrawgvalue} % obsolete
%D Sort of obsolete:
\newcount\c_syst_helpers_mod
-\unexpanded\def\dosetmodulo#1#2#3%
+\protected\def\dosetmodulo#1#2#3%
{\c_syst_helpers_mod#1\divide\c_syst_helpers_mod#2\multiply\c_syst_helpers_mod#2%
#3#1\advance#3-\c_syst_helpers_mod}
-\unexpanded\def\dosetdivision#1#2#3%
+\protected\def\dosetdivision#1#2#3%
{#3#1\divide#3 #2\relax}
-\unexpanded\def\DoMod#1by#2to#3{\dosetmodulo {#1}{#2}{#3}}
-\unexpanded\def\DoDiv#1by#2to#3{\dosetdivision{#1}{#2}{#3}}
+\protected\def\DoMod#1by#2to#3{\dosetmodulo {#1}{#2}{#3}}
+\protected\def\DoDiv#1by#2to#3{\dosetdivision{#1}{#2}{#3}}
\def\syst_helpers_unprotected#1\par
{#1\protect}
-\unexpanded\def\unprotected
+\protected\def\unprotected
{\unprotect
\syst_helpers_unprotected}
\let\resettimer \clf_resettimer
\let\elapsedtime \clf_elapsedtime
-\let\elapsedseconds \elapsedtime
+\let\elapsedseconds\elapsedtime
+
+\let\elapsedsteps\!!zerocount
+
+\protected\def\elapsedsteptime % unexpanded ! a bit useless but who knows ...
+ {\clf_elapsedsteptime\elapsedsteps\relax}
\newcount\c_syst_helpers_test_feature_n
\newcount\c_syst_helpers_test_feature_m
\def\currentfeaturetest{\number\c_syst_helpers_test_feature_n}
-\unexpanded\def\testfeature#1#2%
+\protected\def\testfeature#1#2%
{\c_syst_helpers_test_feature_m#1\relax
+ \xdef\elapsedsteps{\number\c_syst_helpers_test_feature_m}%
\def\syst_helpers_test_feature_yes
{\advance\c_syst_helpers_test_feature_n\plusone
\ifnum\c_syst_helpers_test_feature_n>\c_syst_helpers_test_feature_m\else
@@ -7727,7 +7749,7 @@
\fi}%
\retestfeature}
-\unexpanded\def\retestfeature % timer support is new per 10/5/2005
+\protected\def\retestfeature % timer support is new per 10/5/2005
{\bgroup
\ifcase\interactionmode\let\wait\relax\fi
\clf_resettimer
@@ -7741,10 +7763,10 @@
\wait
\egroup}
-\unexpanded\def\showtimer#1%
+\protected\def\showtimer#1%
{\writestatus{runtime}{\elapsedseconds\space s / #1}}
-\unexpanded\def\testfeatureonce#1#2%
+\protected\def\testfeatureonce#1#2%
{\begingroup
\let\wait\relax
\testfeature{#1}{#2}%
@@ -7759,7 +7781,7 @@
%D \freezedimenmacro\leftmargindistance
%D \stoptyping
-\unexpanded\def\freezedimenmacro#1%
+\protected\def\freezedimenmacro#1%
{\edef#1{\the\dimexpr#1}}
%D The next macro negates a macro (dimension or number, or actually, whatever. It's
@@ -7777,17 +7799,17 @@
\def\assigndimen#1#2%
{\afterassignment\gobbleassigndimen#1=#2\zeropoint\\}
-\unexpanded\def\appended#1#2#3{\expandafter#1\expandafter#2\expandafter{#2#3}}
-\unexpanded\def\appendvalue #1{\expandafter\appended\expandafter \def\csname#1\endcsname}
-\unexpanded\def\appendgvalue#1{\expandafter\appended\expandafter\gdef\csname#1\endcsname}
+\protected\def\appended#1#2#3{\expandafter#1\expandafter#2\expandafter{#2#3}}
+\protected\def\appendvalue #1{\expandafter\appended\expandafter \def\csname#1\endcsname}
+\protected\def\appendgvalue#1{\expandafter\appended\expandafter\gdef\csname#1\endcsname}
-\unexpanded\def\prepended#1#2#3%
+\protected\def\prepended#1#2#3%
{\t_syst_helpers_scratch{#3}%
\expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter#2\expandafter\expandafter\expandafter
{\expandafter\the\expandafter\t_syst_helpers_scratch#2}}
-\unexpanded\def\prependvalue #1{\expandafter\prepended\expandafter \def\csname#1\endcsname}
-\unexpanded\def\prependgvalue#1{\expandafter\prepended\expandafter\gdef\csname#1\endcsname}
+\protected\def\prependvalue #1{\expandafter\prepended\expandafter \def\csname#1\endcsname}
+\protected\def\prependgvalue#1{\expandafter\prepended\expandafter\gdef\csname#1\endcsname}
%D \macros
%D {dowithrange}
@@ -7809,11 +7831,11 @@
\ifx\m_syst_helpers_range_to\empty\let\m_syst_helpers_range_to\m_syst_helpers_range_from\fi
\dostepwiserecurse\m_syst_helpers_range_from\m_syst_helpers_range_to\plusone{\m_helpers_range_action{##1}}}%
-\unexpanded\def\processranges[#1]#2% #1= n:m,p,q:r
+\protected\def\processranges[#1]#2% #1= n:m,p,q:r
{\def\m_helpers_range_action{#2}%
\processcommacommand[#1]\syst_helpers_with_range}
-\unexpanded\def\dowithrange#1#2%
+\protected\def\dowithrange#1#2%
{\def\m_helpers_range_action{#2}%
\processcommacommand[#1]\syst_helpers_with_range}
@@ -7832,7 +7854,7 @@
%D
%D \typebuffer \getbuffer
-\unexpanded\def\ignoreimplicitspaces
+\protected\def\ignoreimplicitspaces
{\doifelsenextchar\relax\relax\relax}
%D \macros
@@ -7859,11 +7881,11 @@
\newbox\b_syst_helpers_no_interference
-\unexpanded\def\startnointerference % not even grouped !
+\protected\def\startnointerference % not even grouped !
{\setbox\b_syst_helpers_no_interference\vbox
\bgroup}
-\unexpanded\def\stopnointerference
+\protected\def\stopnointerference
{\egroup
\setbox\b_syst_helpers_no_interference\emptybox}
@@ -7878,9 +7900,9 @@
%D Signal. Some fonts have a char0 rendering so we need to make sure that it is not
%D set in the font! (This will be overloaded)
-\unexpanded\def\signalcharacter{\char\zerocount} % \zwj
+\protected\def\signalcharacter{\char\zerocount} % \zwj
-% \unexpanded\def\signalcharacter
+% \protected\def\signalcharacter
% {\scratchcounter\normallanguage
% \normallanguage\zerocount
% \char\zerocount
@@ -7914,9 +7936,9 @@
%D \typebuffer \startlines \getbuffer \stoplines
\def\docheckedpair#1%
- {\syst_helpers_checked_pair#1,,\_o_e_p_}
+ {\syst_helpers_checked_pair#1,,\_e_o_p_}
-\def\syst_helpers_checked_pair#1,#2,#3\_o_e_p_
+\def\syst_helpers_checked_pair#1,#2,#3\_e_o_p_
{#1,#2}
%D Here are some nasty helpers. They can be used to fill often expanded token
@@ -8046,7 +8068,7 @@
% {title} {\texdefinition{btx:apa:title-subtitle-type}}
% {default} {\btxflush{author}}
-% \unexpanded\def\doifcase#1%
+% \protected\def\doifcase#1%
% {\edef\m_case_asked{#1}%
% \syst_aux_case}
%
@@ -8093,8 +8115,8 @@
%D Not that useful:
-% \unexpanded\def\doifelsestringbefore{\clf_doifelsestringbefore}
-% \unexpanded\def\doifelsestringafter {\clf_doifelsestringafter}
+% \protected\def\doifelsestringbefore{\clf_doifelsestringbefore}
+% \protected\def\doifelsestringafter {\clf_doifelsestringafter}
% Could have been useful but not faster that addtocommalist and also expansion mess:
%
@@ -8102,30 +8124,30 @@
%D Experiment (sometimes looks nicer in code):
-\unexpanded\def\sameargumentscondition#1#2%
+\protected\def\sameargumentscondition#1#2%
{\edef\m_syst_string_one{#1}%
\edef\m_syst_string_two{#2}%
\ifx\m_syst_string_one\m_syst_string_two}
-\unexpanded\def\emptyargumentcondition#1%
+\protected\def\emptyargumentcondition#1%
{\edef\m_syst_string_one{#1}%
\ifx\m_syst_string_one\empty}
-% \unexpanded\def\hascommonargumentcondition#1#2{\clf_hascommonargumentcondition{#1}{#2}}
+% \protected\def\hascommonargumentcondition#1#2{\clf_hascommonargumentcondition{#1}{#2}}
% \let\hascommonargumentcondition \clf_hascommonargumentcondition
-% \unexpanded\def\hascommonargumentcondition{\clf_hascommonargumentcondition}
+% \protected\def\hascommonargumentcondition{\clf_hascommonargumentcondition}
\protect \endinput
% \edef\choicetokenyes{+}
% \edef\choicetokennop{-}
%
-% \unexpanded\def\startchoice#1%
+% \protected\def\startchoice#1%
% {\pushmacro\currentchoicevalue
% \edef\currentchoicevalue{#1}%
% \checkchoicetoken}
%
-% \unexpanded\def\checkchoicetoken#1%
+% \protected\def\checkchoicetoken#1%
% {\edef\choicetoken{#1}%
% \ifx\choicetoken\choicetokenyes
% \singleexpandafter\checkchoiceyes
@@ -8210,7 +8232,7 @@
%
% \showvalue{mylist}
-% \unexpanded\def\showtokenlist#1%
+% \protected\def\showtokenlist#1%
% {\begingroup
% \edef\tempstring{\the#1}%
% \tx\ttbf\string#1: \tttf\meaning\tempstring
@@ -8220,7 +8242,7 @@
%
% \chardef\_E_O_T_0
%
-% \unexpanded\def\doifelsetokens#1%
+% \protected\def\doifelsetokens#1%
% {\dodoifelsetokens#1\_E_O_T_\_e_o_t_}
%
% \def\dodoifelsetokens#1#2\_e_o_t_
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkxl b/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkxl
deleted file mode 100644
index 7ade250d970..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-aux.mkxl
+++ /dev/null
@@ -1,6587 +0,0 @@
-%D \module
-%D [ file=syst-aux, % merge of syst-gen cum suis
-%D version=1996.03.20,
-%D title=\CONTEXT\ System Macros,
-%D subtitle=General,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\registerctxluafile{syst-aux}{}
-
-%D This fils is a follow up in \type {syst-aux.mkii} and \type {syst-aux.mkiv}
-%D where you can find some more pure \TEX\ or \LUATEX| variants.
-
-\unprotect
-
-%D \macros
-%D {unexpanded}
-%D
-%D Because we use this module only in \MKIV, we have removed the old protection
-%D code.
-%D
-%D \starttyping
-%D \unexpanded\def\somecommand{... ... ...}
-%D \stoptyping
-%D
-%D This overloads the \ETEX\ primitive but as we already had an \MKII\ solution we
-%D keep the same name for a similar mechanism.
-
-\let\unexpanded\normalprotected
-
-\ifcase\contextlmtxmode
-
- \def\startlmtxmode#1\stoplmtxmode{}
- \let\stoplmtxmode \relax
- \let\startmkivmode\relax
- \let\stopmkivmode \relax
-
-\else
-
- \let\startlmtxmode\relax
- \let\stoplmtxmode \relax
- \def\startmkivmode#1\stopmkivmode{}
- \let\stopmkivmode \relax
-
-\fi
-
-%D As we don't have namespace definers yet, we use a special one:
-
-\ifdefined\c_syst_helpers_n_of_namespaces
-
- % lets plug in a better error message
-
-\else
-
- \newcount\c_syst_helpers_n_of_namespaces \c_syst_helpers_n_of_namespaces\pluseight % 1-8 reserved for catcodes
-
- \def\v_interfaces_prefix_template_system{\number \c_syst_helpers_n_of_namespaces>>}
- %def\v_interfaces_prefix_template_system{\characters\c_syst_helpers_n_of_namespaces>>} % no \characters yet
-
-\fi
-
-\unexpanded\def\installsystemnamespace#1% maybe move this to syst-ini
- {\ifcsname ??#1\endcsname
- \writestatus\m!system{duplicate system namespace '#1'}\wait
- \else
- \global\advance\c_syst_helpers_n_of_namespaces\plusone
- \expandafter\edef\csname ??#1\endcsname{\v_interfaces_prefix_template_system}%
- \fi}
-
-%D \macros
-%D {normalspace}
-%D
-%D There is already \type{\space} but just to be sure we also provide:
-
-\def\normalspace{ }
-
-%D \macros
-%D {!!count, !!toks, !!dimen, !!box,
-%D !!width, !!height, !!depth, !!string, !!done}
-%D
-%D We define some more \COUNTERS\ and \DIMENSIONS. We also define some shortcuts to
-%D the local scatchregisters~0, 2, 4, 6 and~8.
-
-\newcount\!!counta \newtoks\!!toksa \newdimen\!!dimena \newbox\!!boxa
-\newcount\!!countb \newtoks\!!toksb \newdimen\!!dimenb \newbox\!!boxb
-\newcount\!!countc \newtoks\!!toksc \newdimen\!!dimenc \newbox\!!boxc
-\newcount\!!countd \newtoks\!!toksd \newdimen\!!dimend \newbox\!!boxd
-\newcount\!!counte \newtoks\!!tokse \newdimen\!!dimene \newbox\!!boxe
-\newcount\!!countf \newtoks\!!toksf \newdimen\!!dimenf \newbox\!!boxf
- \newdimen\!!dimeng
- \newdimen\!!dimenh
- \newdimen\!!dimeni
- \newdimen\!!dimenj
- \newdimen\!!dimenk
-
-\let\!!stringa\empty \let\!!stringb\empty \let\!!stringc\empty
-\let\!!stringd\empty \let\!!stringe\empty \let\!!stringf\empty
-
-\newdimen\!!widtha \newdimen\!!heighta \newdimen\!!deptha
-\newdimen\!!widthb \newdimen\!!heightb \newdimen\!!depthb
-\newdimen\!!widthc \newdimen\!!heightc \newdimen\!!depthc
-\newdimen\!!widthd \newdimen\!!heightd \newdimen\!!depthd
-
-\newif\if!!donea \newif\if!!doneb \newif\if!!donec
-\newif\if!!doned \newif\if!!donee \newif\if!!donef
-
-\def\!!zerocount {0} % alongside \zerocount
-\def\!!minusone {-1} % ...
-\def\!!plusone {1} % ...
-\def\!!plustwo {2} % ...
-\def\!!plusthree {3} % ...
-\def\!!plusfour {4} % ...
-\def\!!plusfive {5} % ...
-\def\!!plussix {6} % ...
-\def\!!plusseven {7} % ...
-\def\!!pluseight {8} % ...
-\def\!!plusnine {9} % alongside \plusnine
-
-\setnewconstant \uprotationangle 0
-\setnewconstant\rightrotationangle 90
-\setnewconstant \downrotationangle 180
-\setnewconstant \leftrotationangle 270
-
-\ifdefined\data \else \let\data \relax \fi % dep checker
-
-%D \macros
-%D {s!,c!,e!,p!,v!,@@,??}
-%D
-%D To save memory, we use constants (sometimes called variables). Redefining these
-%D constants can have disastrous results.
-
-\def\v!prefix! {v!}
-\def\c!prefix! {c!}
-\def\s!prefix! {s!}
-
-\def\s!next {next}
-\def\s!default {default}
-\def\s!dummy {dummy}
-\def\s!unknown {unknown}
-
-\def\s!do {do}
-\def\s!dodo {dodo}
-
-\def\s!complex {complex}
-\def\s!start {start}
-\def\s!simple {simple}
-\def\s!stop {stop}
-
-\def\s!empty {empty}
-
-%D Sometimes we pass macros as arguments to commands that don't expand them
-%D before interpretation. Such commands can be enclosed with \type {\expanded},
-%D like:
-%D
-%D \starttyping
-%D \expanded{\setupsomething[\alfa]}
-%D \stoptyping
-%D
-%D Such situations occur for instance when \type{\alfa} is a commalist or when data
-%D stored in macros is fed to index of list commands. If needed, one should use
-%D \type{\noexpand} inside the argument. Later on we will meet some more clever
-%D alternatives to this command. Beware, only the simple one has \type {\noexpand}
-%D before its argument.
-
-\let\m_syst_helpers_expanded\empty
-
-\unexpanded\def\expanded#1%
- {\xdef\m_syst_helpers_expanded{\noexpand#1}\m_syst_helpers_expanded}
-
-\unexpanded\def\startexpanded#1\stopexpanded
- {\xdef\m_syst_helpers_expanded{#1}\m_syst_helpers_expanded}
-
-\let\stopexpanded\relax
-
-%D Recent \TEX\ engines have a primitive \type {\expanded} and we will use that when
-%D possible. After all, we can make not expandable macros now.
-
-% We cannot use the next variant as first we need to adapt \type {##}'s in callers:
-%
-% \def\expanded#1%
-% {\normalexpanded{\noexpand#1}}
-%
-% \def\startexpanded#1\stopexpanded
-% {\normalexpanded{#1}}
-
-%D \macros
-%D {gobbleoneargument,gobble...arguments}
-%D
-%D The next set of macros just do nothing, except that they get rid of a number of
-%D arguments.
-
-\def\gobbleoneargument #1{}
-\def\gobbletwoarguments #1#2{}
-\def\gobblethreearguments#1#2#3{}
-\def\gobblefourarguments #1#2#3#4{}
-\def\gobblefivearguments #1#2#3#4#5{}
-\def\gobblesixarguments #1#2#3#4#5#6{}
-\def\gobblesevenarguments#1#2#3#4#5#6#7{}
-\def\gobbleeightarguments#1#2#3#4#5#6#7#8{}
-\def\gobbleninearguments #1#2#3#4#5#6#7#8#9{}
-\def\gobbletenarguments #1{\gobbleninearguments}
-
-\def\gobbleoneoptional [#1]{}
-\def\gobbletwooptionals [#1][#2]{}
-\def\gobblethreeoptionals[#1][#2][#3]{}
-\def\gobblefouroptionals [#1][#2][#3][#4]{}
-\def\gobblefiveoptionals [#1][#2][#3][#4][#5]{}
-
-%D Reserved macros for tests:
-
-\let\donothing\empty
-
-\let\m_syst_string_one \empty
-\let\m_syst_string_two \empty
-\let\m_syst_string_three\empty
-\let\m_syst_string_four \empty
-
-\let\m_syst_action_yes \empty
-\let\m_syst_action_nop \empty
-
-%D \macros
-%D {doifnextcharelse}
-%D
-%D When we started using \TEX\ in the late eighties, our first experiences with
-%D programming concerned a simple shell around \LATEX. The commands probably use
-%D most at \PRAGMA, are the itemizing ones. One of those few shell commands took
-%D care of an optional argument, that enabled us to specify what kind of item symbol
-%D we wanted. Without understanding anything we were able to locate a \LATEX\ macro
-%D that could be used to inspect the next character.
-%D
-%D It's this macro that the ancester of the next one presented here. It executes one
-%D of two actions, dependant of the next character. Disturbing spaces and line
-%D endings, which are normally interpreted as spaces too, are skipped.
-%D
-%D \starttyping
-%D \doifnextcharelse {karakter} {then ...} {else ...}
-%D \stoptyping
-%D
-%D This macro differs from the original in the use of \type {\localnext} because we
-%D don't want clashes with \type {\next}.
-
-\let\next \relax
-\let\nextnext \relax
-\let\nextnextnext \relax
-\let\nexttoken \relax
-\let\charactertoken\relax
-
-\let\m_syst_action_yes\relax
-\let\m_syst_action_nop\relax
-
-% \def\syst_helpers_inspect_next_character
-% {\ifx\nexttoken\blankspace
-% \expandafter\syst_helpers_reinspect_next_character
-% \else
-% \expandafter\syst_helpers_inspect_next_character_indeed
-% \fi}
-%
-% \def\syst_helpers_inspect_next_character_indeed
-% {\ifx\nexttoken\charactertoken
-% \expandafter\m_syst_action_yes
-% \else
-% \expandafter\m_syst_action_nop
-% \fi}
-
-\unexpanded\def\doifelsenextchar#1#2#3% #1 should not be {} !
- {\def\m_syst_action_yes{#2}%
- \def\m_syst_action_nop{#3}%
- \futureexpandis#1\m_syst_action_yes\m_syst_action_nop}
-
-\unexpanded\def\doifelsenextcharcs % #1#2#3% #1 should not be {} !
- {\futureexpandis}
-
-\let\doifnextcharelse \doifelsenextchar
-\let\doifnextcharcselse\doifelsenextcharcs
-
-%D Because we will mostly use this macro for testing if the next character is \type
-%D {[}, we also make a slightly faster variant as it is not uncommon to have tens of
-%D thousands of calls to this test in a run. Of course it also is more convenient to
-%D read a trace then.
-
-% \newif\if_next_blank_space_token
-
-% \let\syst_helpers_next_optional_character_token=[
-%
-% \def\syst_helpers_inspect_next_optional_character
-% {\ifx\nexttoken\blankspace
-% \expandafter\syst_helpers_reinspect_next_optional_character
-% \else
-% \expandafter\syst_helpers_inspect_next_optional_character_indeed
-% \fi}
-%
-% \def\syst_helpers_inspect_next_optional_character_indeed
-% {\ifx\nexttoken\syst_helpers_next_optional_character_token
-% \expandafter\m_syst_action_yes
-% \else
-% \expandafter\m_syst_action_nop
-% \fi}
-
-\unexpanded\def\doifelsenextoptional#1#2%
- {\def\m_syst_action_yes{#1}%
- \def\m_syst_action_nop{#2}%
- \futureexpandis[\m_syst_action_yes\m_syst_action_nop}
-
-\unexpanded\def\doifelsenextoptionalcs
- {\futureexpandis[}
-
-\let\doifnextoptionalelse \doifelsenextoptional
-\let\doifnextoptionalcselse\doifelsenextoptionalcs
-
-% \let\syst_helpers_next_bgroup_character_token\bgroup
-%
-% \def\syst_helpers_inspect_next_bgroup_character
-% {\ifx\nexttoken\blankspace
-% \expandafter\syst_helpers_reinspect_next_bgroup_character
-% \else
-% \expandafter\syst_helpers_inspect_next_bgroup_character_indeed
-% \fi}
-%
-% \def\syst_helpers_inspect_next_bgroup_character_indeed
-% {\ifx\nexttoken\syst_helpers_next_bgroup_character_token
-% \expandafter\m_syst_action_yes
-% \else
-% \expandafter\m_syst_action_nop
-% \fi}
-
-\unexpanded\def\doifelsenextbgroup#1#2%
- {\def\m_syst_action_yes{#1}%
- \def\m_syst_action_nop{#2}%
- \futureexpandis\bgroup\m_syst_action_yes\m_syst_action_nop}
-
-\unexpanded\def\doifelsenextbgroupcs % #1#2
- {\futureexpandis\bgroup}
-
-\let\doifnextbgroupelse \doifelsenextbgroup
-\let\doifnextbgroupcselse\doifelsenextbgroupcs
-
-% \let\syst_helpers_next_parenthesis_character_token(
-%
-% \def\syst_helpers_inspect_next_parenthesis_character
-% {\ifx\nexttoken\blankspace
-% \expandafter\syst_helpers_reinspect_next_parenthesis_character
-% \else
-% \expandafter\syst_helpers_inspect_next_parenthesis_character_indeed
-% \fi}
-%
-% \def\syst_helpers_inspect_next_parenthesis_character_indeed
-% {\ifx\nexttoken\syst_helpers_next_parenthesis_character_token
-% \expandafter\m_syst_action_yes
-% \else
-% \expandafter\m_syst_action_nop
-% \fi}
-
-\unexpanded\def\doifelsenextparenthesis#1#2%
- {\def\m_syst_action_yes{#1}%
- \def\m_syst_action_nop{#2}%
- \futureexpandis(\m_syst_action_yes\m_syst_action_nop}
-
-\let\doifnextparenthesiselse\doifelsenextparenthesis
-
-%D The next one is handy in predictable situations:
-
-\def\syst_helpers_do_if_fast_optional_check_else
- {\ifx\nexttoken\syst_helpers_next_optional_character_token
- \expandafter\m_syst_action_yes
- \else
- \expandafter\m_syst_action_nop
- \fi}
-
-\unexpanded\def\doifelsefastoptionalcheck#1#2%
- {\def\m_syst_action_yes{#1}%
- \def\m_syst_action_nop{#2}%
- \futureexpandis[\m_syst_action_yes\m_syst_action_nop}
-
-\unexpanded\def\doifelsefastoptionalcheckcs
- {\futureexpandis[}
-
-\let\doiffastoptionalcheckelse \doifelsefastoptionalcheck
-\let\doiffastoptionalcheckcselse\doifelsefastoptionalcheckcs
-
-%D Here's one for skipping spaces and pars, handy for:
-%D
-%D \starttyping
-%D \hbox
-%D
-%D {a few lines later}
-%D \stoptyping
-%D
-%D like:
-%D
-%D \starttyping
-%D \def\somecommand{\dowithnextbox{\box\nextbox}\ruledhbox}
-%D
-%D \assumelongusagecs\somecommand
-%D
-%D \bgroup
-%D oeps
-%D \egroup
-%D \stoptyping
-
-%D The cumbersome original:
-
-% \unexpanded\def\assumelongusagecs#1%
-% {\let\m_syst_action#1%
-% \futurelet\nexttoken\syst_helpers_ignore_spacing}
-%
-% \def\syst_helpers_ignore_spacing
-% {\ifx\nexttoken\blankspace
-% \expandafter\syst_helpers_ignore_spacing_blankspace
-% \orelse\ifx\nexttoken\par
-% \expandafter\syst_helpers_ignore_spacing_partoken
-% \else
-% \expandafter\m_syst_action
-% \fi}
-%
-% \def\syst_helpers_ignore_spacing_partoken\par
-% {\futurelet\nexttoken\syst_helpers_ignore_spacing}
-
-%D A bit less tracing noise:
-
-% \def\assume_long_usage_cs
-% {\futureexpandis\par\assume_long_usage_par\m_syst_action}
-%
-% \def\assume_long_usage_par\par%
-% {\assume_long_usage_cs}
-%
-% \unexpanded\def\assumelongusagecs#1{\let\m_syst_action#1\assume_long_usage_cs}
-
-%D Ok, using \type {\futureexpandisap} is maybe feature creep but I'd like to experiment
-%D with more tolerant user input. It might go away in which case we use the above.
-
-\unexpanded\def\assumelongusagecs#1%
- {\futureexpandisap\relax#1#1}
-
-% D These macros use some auxiliary macros. Although we were able to program quite
-% D complicated things, I only understood these after rereading the \TEX book. The
-% D trick is in using a command with a one character name. Such commands differ from
-% D the longer ones in the fact that trailing spaces are {\em not} skipped. This
-% D enables us to indirectly define a long named macro that gobbles a space. In the
-% D first line we define \type {\blankspace}. Next we make \type {\:} equivalent to
-% D \type {\reinspect...}. This one||character command is expanded before the next
-% D \type {\def} comes into action. This way the space after \type {\:} becomes a
-% D delimiter of the longer named \type {\reinspectnextcharacter}.
-
-\let\next\:
-
-\def\:{\let\blankspace= } \:
-
-% \def\:{\syst_helpers_reinspect_next_character}
-% \expandafter\def\: {\let\if_next_blank_space_token\iftrue\futurelet\nexttoken\syst_helpers_inspect_next_character}
-%
-% \def\:{\syst_helpers_reinspect_next_optional_character}
-% \expandafter\def\: {\let\if_next_blank_space_token\iftrue\futurelet\nexttoken\syst_helpers_inspect_next_optional_character}
-%
-% \def\:{\syst_helpers_reinspect_next_bgroup_character}
-% \expandafter\def\: {\let\if_next_blank_space_token\iftrue\futurelet\nexttoken\syst_helpers_inspect_next_bgroup_character}
-%
-% \def\:{\syst_helpers_reinspect_next_parenthesis_character}
-% \expandafter\def\: {\let\if_next_blank_space_token\iftrue\futurelet\nexttoken\syst_helpers_inspect_next_parenthesis_character}
-%
-% \def\:{\syst_helpers_ignore_spacing_blankspace}
-% \expandafter\def\: {\futurelet\nexttoken\syst_helpers_ignore_spacing}
-
-\let\:\next
-
-%D \macros
-%D {setvalue,setgvalue,setevalue,setxvalue,
-%D letvalue,letgvalue,getvalue,resetvalue,
-%D undefinevalue,ignorevalue}
-%D
-%D \TEX's primitive \type {\csname} can be used to construct all kind of commands
-%D that cannot be defined with \type {\def} and \type {\let}. Every macro programmer
-%D sooner or later wants macros like these.
-%D
-%D \starttyping
-%D \setvalue {name}{...} = \def\name{...}
-%D \setgvalue {name}{...} = \gdef\name{...}
-%D \setevalue {name}{...} = \edef\name{...}
-%D \setxvalue {name}{...} = \xdef\name{...}
-%D \letvalue {name}=\... = \let\name=\...
-%D \letgvalue {name}=\... = \glet\name=\...
-%D \getvalue {name} = \name
-%D \resetvalue {name} = \def\name{}
-%D \stoptyping
-%D
-%D As we will see, \CONTEXT\ uses these commands many times, which is mainly due to
-%D its object oriented and parameter driven character.
-
-\def\setvalue #1{\expandafter\def \csname#1\endcsname}
-\def\setgvalue #1{\expandafter\gdef\csname#1\endcsname}
-\def\setevalue #1{\expandafter\edef\csname#1\endcsname}
-\def\setxvalue #1{\expandafter\xdef\csname#1\endcsname}
-\def\getvalue #1{\csname#1\endcsname} % maybe: \begincsname#1\endcsname
-\def\letvalue #1{\expandafter\let \csname#1\endcsname}
-\def\letgvalue #1{\expandafter\glet\csname#1\endcsname}
-\def\resetvalue #1{\expandafter\let \csname#1\endcsname\empty}
-\def\undefinevalue#1{\expandafter\let \csname#1\endcsname\undefined}
-\def\ignorevalue#1#2{\expandafter\let \csname#1\endcsname\empty}
-
-\def\setuvalue #1{\normalprotected\expandafter \def\csname#1\endcsname}
-\def\setuevalue #1{\normalprotected\expandafter\edef\csname#1\endcsname}
-\def\setugvalue #1{\normalprotected\expandafter\gdef\csname#1\endcsname}
-\def\setuxvalue #1{\normalprotected\expandafter\xdef\csname#1\endcsname}
-
-\unexpanded\def\getuvalue#1{\csname#1\endcsname}
-
-%D \macros
-%D {globallet,glet}
-%D
-%D In \CONTEXT\ of May 2000 using \type {\globallet} instead of the two tokens will
-%D save us some $300\times4=1200$ bytes of format file on a 32~bit system. Not that
-%D it matters much today. This shortcut is already defined:
-
-\let\globallet\glet
-
-%D \macros
-%D {doifundefined,doifdefined,
-%D doifundefinedelse,doifdefinedelse,
-%D doifalldefinedelse}
-%D
-%D The standard way of testing if a macro is defined is comparing its meaning with
-%D another undefined one, usually \type{\undefined}. To garantee correct working of
-%D the next set of macros, \type{\undefined} may never be defined!
-%D
-%D \starttyping
-%D \doifundefined {string} {...}
-%D \doifdefined {string} {...}
-%D \doifundefinedelse {string} {then ...} {else ...}
-%D \doifdefinedelse {string} {then ...} {else ...}
-%D \doifalldefinedelse {commalist} {then ...} {else ...}
-%D \stoptyping
-%D
-%D Every macroname that \TEX\ builds gets an entry in the hash table, which is of
-%D limited size. It is expected that \ETEX\ will offer a less memory||consuming
-%D alternative.
-
-%D Although it will probably never be a big problem, it is good to be aware of the
-%D difference between testing on a macro name to be build by using \type{\csname} and
-%D \type{\endcsname} and testing the \type{\name} directly.
-%D
-%D \starttyping
-%D \expandafter\ifx\csname NameA\endcsname\relax ... \else ... \fi
-%D
-%D \ifundefined\NameB ... \else ... \fi
-%D \stoptyping
-
-% \suppressifcsnameerror\plusone % already set
-
-\def\doifelseundefined#1%
- {\ifcsname#1\endcsname
- \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments
- \fi}
-
-\def\doifelsedefined#1%
- {\ifcsname#1\endcsname
- \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments
- \fi}
-
-\def\doifundefined#1%
- {\ifcsname#1\endcsname
- \expandafter\gobbleoneargument\else\expandafter\firstofoneargument
- \fi}
-
-\def\doifdefined#1%
- {\ifcsname#1\endcsname
- \expandafter\firstofoneargument\else\expandafter\gobbleoneargument
- \fi}
-
-\let\doifundefinedelse\doifelseundefined
-\let\doifdefinedelse \doifelsedefined
-
-%D \macros
-%D {letbeundefined}
-%D
-%D Testing for being undefined comes down to testing on \type {\relax} when we use
-%D \type {\csname}, but when using \type {\ifx}, we test on being \type
-%D {\undefined}! In \ETEX\ we have \type {\ifcsname} and that way of testing on
-%D existance is not the same as the one described here. Therefore we introduce:
-
-\unexpanded\def\letbeundefined#1% potential stack buildup when used \global
- {\expandafter\let\csname#1\endcsname\undefined} % or use \undefinevalue to match \setvalue
-
-\unexpanded\def\localundefine#1% conditional
- {\ifcsname#1\endcsname\expandafter\let\csname#1\endcsname\undefined\fi}
-
-\unexpanded\def\globalundefine#1% conditional
- {\ifcsname#1\endcsname\expandafter\glet\csname#1\endcsname\undefined\fi}
-
-%D Beware, being \type {\undefined} in \ETEX\ means that the macro {\em is} defined!
-%D
-%D When we were developing the scientific units module, we encountered different
-%D behavior in text and math mode, which was due to this grouping subtilities. We
-%D therefore decided to use \type{\begingroup} instead of \type{\bgroup}.
-
-\unexpanded\def\doifelsealldefined#1%
- {\begingroup
- \donetrue % we could use a reserved one and avoid the group
- \processcommalist[#1]\syst_helpers_do_if_all_defined_else
- \ifdone
- \endgroup\expandafter\firstoftwoarguments
- \else
- \endgroup\expandafter\secondoftwoarguments
- \fi}
-
-\let\doifalldefinedelse\doifelsealldefined
-
-\def\syst_helpers_do_if_all_defined_else#1%
- {\ifcsname#1\endcsname\else
- \donefalse
- \expandafter\quitcommalist % added
- \fi}
-
-%D \macros
-%D {doif,doifelse,doifnot}
-%D
-%D Programming in \TEX\ differs from programming in procedural languages like
-%D \MODULA. This means that one --- well, let me speek for myself --- tries to do
-%D the things in the well known way. Therefore the next set of \type{\ifthenelse}
-%D commands were between the first ones we needed. A few years later, the opposite
-%D became true: when programming in \MODULA, I sometimes miss handy things like
-%D grouping, runtime redefinition, expansion etc. While \MODULA\ taught me to
-%D structure, \TEX\ taught me to think recursive.
-%D
-%D \starttyping
-%D \doif {string1} {string2} {...}
-%D \doifnot {string1} {string2} {...}
-%D \doifelse {string1} {string2} {then ...}{else ...}
-%D \stoptyping
-
-\unexpanded\def\doifelse#1#2%
- {\iftok{#1}{#2}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\doif#1#2%
- {\iftok{#1}{#2}%
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifnot#1#2%
- {\iftok{#1}{#2}%
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-%D \macros
-%D {doifempty,doifemptyelse,doifnotempty}
-%D
-%D We complete our set of conditionals with:
-%D
-%D \starttyping
-%D \doifempty {string} {...}
-%D \doifnotempty {string} {...}
-%D \doifemptyelse {string} {then ...} {else ...}
-%D \stoptyping
-%D
-%D This time, the string is not expanded.
-
-\unexpanded\def\doifelseempty#1%
- {\def\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifemptyelse\doifelseempty
-
-\unexpanded\def\doifempty#1%
- {\def\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifnotempty#1%
- {\def\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-%D \macros
-%D {doifinset,doifnotinset,doifinsetelse}
-%D
-%D We can check if a string is present in a comma separated set of strings.
-%D Depending on the result, some action is taken.
-%D
-%D \starttyping
-%D \doifinset {string} {string,...} {...}
-%D \doifnotinset {string} {string,...} {...}
-%D \doifinsetelse {string} {string,...} {then ...} {else ...}
-%D \stoptyping
-
-% !0nop=\doifinsetelse{ccc}{,}{yes}{nop}
-% !0nop=\doifinsetelse{ccc}{,,}{yes}{nop}
-% !0nop=\doifinsetelse{ccc}{,,,}{yes}{nop}
-
-% !1nop=\doifinsetelse{}{}{yes}{nop}
-% !2yes=\doifinsetelse{aaa}{bbb,ccc,ddd,aaa,eee}{yes}{nop}
-% !3nop=\doifinsetelse{aaa}{bbb}{yes}{nop}
-% !4yes=\doifinsetelse{aaa}{aaa}{yes}{nop}
-% !5nop=\doifinsetelse{aaaa}{bbb,ccc,ddd,aaa,eee}{yes}{nop}
-% !6nop=\doifinsetelse{}{}{yes}{nop}
-% !7nop=\doifinsetelse{}{aaa}{yes}{nop}
-% !8nop=\doifinsetelse{aaa}{}{yes}{nop}
-
-% !1=\doifinset{}{}{yes}
-% !2yes=\doifinset{aaa}{bbb,ccc,ddd,aaa,eee}{yes}
-% !3=\doifinset{aaa}{bbb}{yes}
-% !4yes=\doifinset{aaa}{aaa}{yes}
-% !5=\doifinset{}{}{yes}
-% !6=\doifinset{aaa}{}{yes}
-
-% !1yes=\doifnotinset{}{}{yes}
-% !2=\doifnotinset{aaa}{bbb,ccc,ddd,aaa,eee}{yes}
-% !3yes=\doifnotinset{aaa}{bbb}{yes}
-% !4=\doifnotinset{aaa}{aaa}{yes}
-% !5yes=\doifnotinset{}{}{yes}
-% !6yes=\doifnotinset{aaa}{}{yes}
-
-\unexpanded\def\doifelseinset#1#2{\clf_doifelseinset{#1}{#2}}
-\unexpanded\def\doifinset #1#2{\clf_doifinset {#1}{#2}}
-\unexpanded\def\doifnotinset #1#2{\clf_doifnotinset {#1}{#2}}
- % \let\firstinset \clf_firstinset
-
-\let\doifinsetelse\doifelseinset
-
-%D \macros
-%D {doifcommon,doifnotcommon,doifcommonelse}
-%D
-%D Probably the most time consuming tests are those that test for overlap in sets
-%D of strings.
-%D
-%D \starttyping
-%D \doifcommon {string,...} {string,...} {...}
-%D \doifnotcommon {string,...} {string,...} {...}
-%D \doifcommonelse {string,...} {string,...} {then ...} {else ...}
-%D \stoptyping
-
-% !1yes=\doifcommonelse{aaa,bbb,ccc}{aaa,bbb,ccc}{yes}{nop}
-% !2nop=\doifcommonelse{aaa,bbb,ccc}{ddd,eee,fff}{yes}{nop}
-% !3nop=\doifcommonelse{aaa}{ddd,eee,fff}{yes}{nop}
-% !4yes=\doifcommonelse{aaa}{aaa}{yes}{nop}
-% !5nop=\doifcommonelse{bbb}{aaa}{yes}{nop}
-% !6nop=\doifcommonelse{}{aaa,bbb,ccc}{yes}{nop}
-% !7nop=\doifcommonelse{aaa,bbb,ccc}{}{yes}{nop}
-% !8nop=\doifcommonelse{}{}{yes}{nop}
-
-% !9nop=\doifcommonelse{,,}{,,}{yes}{nop}
-% !9yes=\doifcommonelse{,a,}{,a,}{yes}{nop}
-% !9yes=\doifcommonelse{,,a,}{,a,}{yes}{nop}
-% !9yes=\doifcommonelse{,a,}{,,a,}{yes}{nop}
-% !9yes=\doifcommonelse{,a,}{,,,a,}{yes}{nop}
-% !9yes=\doifcommonelse{,,a,}{,,,a,}{yes}{nop}
-
-\unexpanded\def\doifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}}
-\unexpanded\def\doifcommon #1#2{\clf_doifcommon {#1}{#2}}
-\unexpanded\def\doifnotcommon #1#2{\clf_doifnotcommon {#1}{#2}}
-
-\let\doifcommonelse\doifelsecommon
-
-%D \macros
-%D {processcommalist,processcommacommand,quitcommalist,
-%D processcommalistwithparameters}
-%D
-%D We've already seen some macros that take care of comma separated lists. Such
-%D list can be processed with
-%D
-%D \starttyping
-%D \processcommalist[string,string,...]\commando
-%D \stoptyping
-%D
-%D The user supplied command \type{\commando} receives one argument: the string.
-%D This command permits nesting and spaces after commas are skipped. Empty sets
-%D are no problem.
-%D
-%D \startbuffer
-%D \def\dosomething#1{(#1)}
-%D
-%D 1: \processcommalist [\hbox{$a,b,c,d,e,f$}] \dosomething \par
-%D 2: \processcommalist [{a,b,c,d,e,f}] \dosomething \par
-%D 3: \processcommalist [{a,b,c},d,e,f] \dosomething \par
-%D 4: \processcommalist [a,b,{c,d,e},f] \dosomething \par
-%D 5: \processcommalist [a{b,c},d,e,f] \dosomething \par
-%D 6: \processcommalist [{a,b}c,d,e,f] \dosomething \par
-%D 7: \processcommalist [] \dosomething \par
-%D 8: \processcommalist [{[}] \dosomething \par
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D Before we show the result, we present the macro's:
-
-\newcount\commalevel
-
-\installsystemnamespace{nextcommalevel}
-
-\def\syst_helpers_do_do_do_process_comma_item
- {\csname\??nextcommalevel\the\commalevel\endcsname}
-
-% \ifcase\contextlmtxmode
-
- \def\syst_helpers_do_process_comma_item
- {\futurelet\nexttoken\syst_helpers_do_do_process_comma_item}
-
- \def\syst_helpers_do_do_process_comma_item
- {\ifx\nexttoken\blankspace
- \expandafter\syst_helpers_re_do_process_comma_item
- \else
- \expandafter\syst_helpers_do_do_process_comma_item_indeed
- \fi}
-
- \def\syst_helpers_do_do_process_comma_item_indeed
- {\ifx\nexttoken]%
- \expandafter\gobbleoneargument
- \else
- \expandafter\syst_helpers_do_do_do_process_comma_item
- \fi}
-
-% \else
-%
-% \def\syst_helpers_do_process_comma_item
-% {\futureexpandis]\gobbleoneargument\syst_helpers_do_do_do_process_comma_item}
-%
-% \fi
-
-%D Empty arguments are not processed. Empty items (\type {,,}) however are
-%D treated. We have to check for the special case \type {[{a,b,c}]}.
-
-\unexpanded\def\processcommalist[%
- {\futurelet\nexttoken\syst_helpers_do_check_comma_item}
-
-\def\syst_helpers_do_check_comma_item
- {\ifx\nexttoken]%
- \expandafter\gobblethreearguments
- \else
- \expandafter\syst_helpers_do_process_comma_list
- \fi
- \relax} % this one preserved the next {}
-
-\def\syst_helpers_do_process_comma_list#1]#2%
- {\global\advance\commalevel \plusone
- \expandafter\def\csname\??nextcommalevel\the\commalevel\endcsname##1,%
- {#2{##1}\syst_helpers_do_process_comma_item}%
- \syst_helpers_do_do_process_comma_item_gobble#1,]\relax
- \global\advance\commalevel \minusone }
-
-\def\syst_helpers_do_do_process_comma_item_gobble#1{\syst_helpers_do_do_process_comma_item}
-
-%D One way of quitting a commalist halfway is:
-
-\unexpanded\def\quitcommalist
- {\begingroup\let\syst_helpers_do_process_comma_item\syst_helpers_do_quit_comma_list}
-
-\def\syst_helpers_do_quit_comma_list#1]%
- {\endgroup}
-
-\unexpanded\def\quitprevcommalist
- {\begingroup\let\syst_helpers_do_process_comma_item\syst_helpers_do_quit_prev_comma_list}
-
-\def\syst_helpers_do_quit_prev_comma_list#1]%
- {\let\syst_helpers_do_process_comma_item\syst_helpers_do_quit_comma_list}
-
-%D The hack we used for checking the next character \type {\doifnextcharelse}
-%D is also used here.
-
-% \ifcase\contextlmtxmode
-
- \let\next\:
-
- \def\:{\syst_helpers_re_do_process_comma_item} % \:not saved ?
-
- \expandafter\def\: {\futurelet\nexttoken\syst_helpers_do_do_process_comma_item}
-
- \let\:\next
-
-% \fi
-
-%D The previous examples lead to:
-%D
-%D \getbuffer
-
-%D When a list is saved in a macro, we can use a construction like:
-%D
-%D \starttyping
-%D \expandafter\processcommalist\expandafter[\list]\command
-%D \stoptyping
-%D
-%D Such solutions suit most situations, but we wanted a bit more.
-%D
-%D \starttyping
-%D \processcommacommand[string,\stringset,string]\commando
-%D \stoptyping
-%D
-%D where \type{\stringset} is a predefined set, like:
-%D
-%D \starttyping
-%D \def\first{aap,noot,mies}
-%D \def\second{laatste}
-%D
-%D \processcommacommand[\first]\message
-%D \processcommacommand[\first,second,third]\message
-%D \processcommacommand[\first,between,\second]\message
-%D \stoptyping
-%D
-%D Commands that are part of the list are expanded, so the use of this macro has its
-%D limits.
-
-\unexpanded\def\processcommacommand[#1]%
- {\normalexpanded{\processcommalist[#1]}}
-
-%D The argument to \type{\command} is not delimited. Because we often use \type {[]}
-%D as delimiters, we also have:
-%D
-%D \starttyping
-%D \processcommalistwithparameters[string,string,...]\command
-%D \stoptyping
-%D
-%D where \type{\command} looks like:
-%D
-%D \starttyping
-%D \def\command[#1]{... #1 ...}
-%D \stoptyping
-
-\unexpanded\def\processcommalistwithparameters[#1]#2%
- {\def\syst_helpers_do_process_comma_list_with_parameters##1{#2[##1]}%
- \processcommalist[#1]\syst_helpers_do_process_comma_list_with_parameters}
-
-%D \macros
-%D {startprocesscommalist,startprocesscommacommand}
-%D
-%D Two more:
-
-\let\syst_helpers_comma_list_step\relax
-
-\unexpanded\def\startprocesscommalist[#1]#2\stopprocesscommalist
- {\def\syst_helpers_comma_list_step##1{\def\currentcommalistitem{##1}#2}%
- \processcommalist[#1]\syst_helpers_comma_list_step}
-
-\unexpanded\def\startprocesscommacommand[#1]#2\stopprocesscommacommand
- {\def\syst_helpers_comma_list_step##1{\def\currentcommalistitem{##1}#2}%
- \normalexpanded{\processcommalist[#1]}\syst_helpers_comma_list_step}
-
-\let\stopprocesscommalist \relax
-\let\stopprocesscommacommand\relax
-
-%D \macros
-%D {processaction,
-%D processfirstactioninset,
-%D processallactionsinset}
-%D
-%D \CONTEXT\ makes extensive use of a sort of case or switch command. Depending of
-%D the presence of one or more provided items, some actions is taken. These macros
-%D can be nested without problems.
-%D
-%D \starttyping
-%D \processaction [x] [a=>\a,b=>\b,c=>\c]
-%D \processfirstactioninset [x,y,z] [a=>\a,b=>\b,c=>\c]
-%D \processallactionsinset [x,y,z] [a=>\a,b=>\b,c=>\c]
-%D \stoptyping
-%D
-%D We can supply both a \type {default} action and an action to be undertaken when
-%D an \type {unknown} value is met:
-%D
-%D \starttyping
-%D \processallactionsinset
-%D [x,y,z]
-%D [ a=>\a,
-%D b=>\b,
-%D c=>\c,
-%D default=>\default,
-%D unknown=>\unknown{... \commalistelement ...}]
-%D \stoptyping
-%D
-%D When \type {#1} is empty, this macro scans list \type {#2} for the keyword \type
-%D {default} and executed the related action if present. When \type {#1} is non
-%D empty and not in the list, the action related to \type {unknown} is executed.
-%D Both keywords must be at the end of list \type{#2}. Afterwards, the actually
-%D found keyword is available in \type {\commalistelement}. An advanced example of
-%D the use of this macro can be found in \PPCHTEX, where we completely rely on \TEX\
-%D for interpreting user supplied keywords like \type {SB}, \type {SB1..6}, \type
-%D {SB125} etc.
-
-\newcount\processlevel
-
-\unexpanded\def\syst_helpers_do_compare_process_action_a[#1=>#2][#3]%
- {\edef\m_syst_string_two{#1}%
- \ifx\m_syst_string_two\s!default
- \let\commalistelement\empty
- #2%
- \fi}
-
-% met \quitcommalist tot meer dan 25\% sneller
-
-\unexpanded\def\syst_helpers_do_compare_process_action_b[#1=>#2][#3]%
- {\edef\m_syst_string_two{#1}%
- \ifx\m_syst_string_one\m_syst_string_two
- \def\commalistelement{#3}%
- #2%
- \expandafter\quitcommalist
- \orelse\ifx\m_syst_string_two\s!unknown
- \def\commalistelement{#3}% beware of loops
- #2%
- \fi}
-
-\unexpanded\def\processaction[#1]#2[%
- {\edef\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty
- \let\syst_helpers_do_compare_process_action\syst_helpers_do_compare_process_action_a
- \else
- \let\syst_helpers_do_compare_process_action\syst_helpers_do_compare_process_action_b
- \fi
- \edef\syst_helpers_do_process_action##1{\syst_helpers_do_compare_process_action[##1][#1]}% expands #1
- \processnextcommalist\relax\relax\syst_helpers_do_process_action[}
-
-\unexpanded\def\syst_helpers_do_compare_process_action_c[#1=>#2][#3]%
- {\edef\m_syst_string_one{#1}%
- \edef\m_syst_string_two{#3}%
- \ifx\m_syst_string_one\m_syst_string_two
- \def\commalistelement{#3}%
- #2%
- \expandafter\quitprevcommalist
- \else
- \edef\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\s!unknown
- \def\commalistelement{#3}%
- #2%
- \fi
- \fi}
-
-\unexpanded\def\processfirstactioninset[#1]%
- {\edef\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty
- \expandafter\processaction
- \else
- \expandafter\syst_helpers_process_first_action_in_set_indeed
- \fi
- [#1]}
-
-\unexpanded\def\syst_helpers_process_first_action_in_set_indeed[#1]#2[#3]%
- {\def\syst_helpers_do_process_action##1%
- {\def\syst_helpers_do_do_process_action####1{\syst_helpers_do_compare_process_action_c[####1][##1]}%
- \processcommalist[#3]\syst_helpers_do_do_process_action}%
- \normalexpanded{\processcommalist[#1]}\syst_helpers_do_process_action}
-
-\unexpanded\def\syst_helpers_do_compare_process_action_d[#1=>#2][#3]%
- {\edef\m_syst_string_one{#1}%
- \edef\m_syst_string_two{#3}%
- \ifx\m_syst_string_one\m_syst_string_two
- \def\commalistelement{#3}%
- #2%
- \expandafter\quitcommalist
- \else
- \edef\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\s!unknown
- \def\commalistelement{#3}%
- #2%
- \fi
- \fi}
-
-\installsystemnamespace{nextactionlevel}
-
-\unexpanded\def\syst_helpers_do_process_all_actions_in_set
- {\csname\??nextactionlevel\the\processlevel\endcsname}
-
-\unexpanded\def\processallactionsinset[#1]%
- {\edef\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty
- \expandafter\processaction
- \else
- \expandafter\syst_helpers_process_all_actions_in_set_indeed
- \fi
- [#1]}
-
-\unexpanded\def\syst_helpers_process_all_actions_in_set_indeed[#1]#2[#3]%
- {\advance\processlevel \plusone
- \expandafter\def\csname\??nextactionlevel\the\processlevel\endcsname##1%
- {\def\syst_helpers_do_do_process_action####1{\syst_helpers_do_compare_process_action_d[####1][##1]}%
- \processcommalist[#3]\syst_helpers_do_do_process_action}%
- \normalexpanded{\processcommalist[#1]}\syst_helpers_do_process_all_actions_in_set
- \advance\processlevel\minusone}
-
-%D These macros use:
-
-\unexpanded\def\processnextcommalist#1#2#3[#4#5]%
- {#1%
- \let\nexttoken#4%
- \global\advance\commalevel \plusone
- \expandafter\def\csname\??nextcommalevel\the\commalevel\endcsname##1,%
- {#3{##1}\syst_helpers_do_process_comma_item}%
- \syst_helpers_do_do_process_comma_item#4#5,]\relax
- \global\advance\commalevel\minusone
- #2}
-
-%D \macros
-%D {getfirstcharacter, firstcharacter, remainingcharacters, doiffirstcharacter}
-%D
-%D Sometimes the action to be undertaken depends on the next character. This macro
-%D get this character and puts it in \type {\firstcharacter}.
-%D
-%D \starttyping
-%D \getfirstcharacter {string}
-%D \stoptyping
-%D
-%D A two step expansion is used to prevent problems with complicated arguments, for
-%D instance arguments that consist of two or more expandable tokens.
-
-\let\firstcharacter \empty
-\let\remainingcharacters\empty
-
-\unexpanded\def\getfirstcharacter #1{\clf_getfirstcharacter{#1}}
-\unexpanded\def\doifelsefirstchar #1#2{\clf_doifelsefirstchar{#1}{#2}}
-\unexpanded\def\thefirstcharacter #1{\clf_thefirstcharacter{#1}}
-\unexpanded\def\theremainingcharacters#1{\clf_theremainingcharacters{#1}}
-
-\let\doiffirstcharelse\doifelsefirstchar
-
-%D \macros
-%D {doifinstringelse, doifincsnameelse}
-%D
-%D We can check for the presence of a substring in a given sequence of characters.
-%D
-%D \starttyping
-%D \doifinsetelse {substring} {string} {then ...} {else ...}
-%D \stoptyping
-
-\let\m_syst_sub_string\empty
-
-\unexpanded\def\doifelseinstring#1%
- {\edef\m_syst_sub_string{#1}% expand #1 here
- \ifx\m_syst_sub_string\empty
- \expandafter\thirdofthreearguments
- \else
- \expandafter\syst_helpers_do_if_in_string_else_indeed
- \fi}
-
-\let\doifinstringelse\doifelseinstring
-
-\unexpanded\def\syst_helpers_do_if_in_string_else_indeed#1%
- {\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\doifinstring#1%%
- {\edef\m_syst_sub_string{#1}% expand #1 here
- \ifx\m_syst_sub_string\empty
- \expandafter\gobbletwoarguments
- \else
- \expandafter\syst_helpers_do_if_in_string_indeed
- \fi}
-
-\unexpanded\def\syst_helpers_do_if_in_string_indeed#1%
- {\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}%
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifnotinstring#1%%
- {\edef\m_syst_sub_string{#1}% expand #1 here
- \ifx\m_syst_sub_string\empty
- \expandafter\gobbletwoarguments
- \else
- \expandafter\syst_helpers_do_if_not_in_string_indeed
- \fi}
-
-\unexpanded\def\syst_helpers_do_if_not_in_string_indeed#1%
- {\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}%
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-% replaces prev
-
-\unexpanded\def\syst_helpers_do_if_in_string_else#1#2% ##2 can be {abc}
- {\expandafter\def\expandafter\syst_helpers_do_do_if_in_string_else
- \expandafter##\expandafter1#1##2##3^^^^0004{\unless\if##2@}% expand #1 here
- \expandafter\syst_helpers_do_do_if_in_string_else\normalexpanded{#2#1}@@^^^^0004} % expand #2 here
-
-%D The next alternative proved to be upto twice as fast on tasks like checking
-%D reserved words in pretty verbatim typesetting! This is mainly due to the fact
-%D that passing (expanded) strings is much slower that passing a macro.
-%D
-%D \starttyping
-%D \doifincsnameelse {substring} {\string} {then ...} {else ...}
-%D \stoptyping
-%D
-%D Where \type {\doifinstringelse} does as much expansion as possible, the latter
-%D alternative does minimal (one level) expansion.
-
-\unexpanded\def\syst_helpers_do_if_in_csname_else#1#2%
- {\def\syst_helpers_do_do_if_in_csname_else##1#1##2##3^^^^0004%
- {\unless\if##2@}%
- \expandafter\syst_helpers_do_do_if_in_csname_else#2#1@@^^^^0004}
-
-\unexpanded\def\doifelseincsname#1#2%
- {\normalexpanded{\syst_helpers_do_if_in_csname_else{#1}}{#2}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifincsnameelse\doifelseincsname
-
-%D \macros
-%D {doifnumberelse,doifnumber,doifnotnumber}
-%D
-%D The next macro executes a command depending of the outcome of a test on numerals.
-%D This is probably one of the fastest test possible, exept from a less robust
-%D 10||step \type {\if}||ladder or some tricky \type {\lcode} checking.
-%D
-%D \starttyping
-%D \doifnumberelse {string} {then ...} {else ...}
-%D \stoptyping
-%D
-%D The macro accepts \type {123}, \type {abc}, \type {{}}, \type {\getal} and \type
-%D {\the\count...}. This macro is a rather dirty one.
-
-\def\doifelsenumber#1%
- {\ifchknum#1\or
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\def\doifnumber#1%
- {\ifchknum#1\or
- \expandafter\firstoftwoarguments
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\def\doifnotnumber#1%
- {\ifchknum#1\or
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\let\doifnumberelse\doifelsenumber
-
-%D \macros
-%D {setpercentdimen}
-%D
-%D \starttyping
-%D \scratchdimen=100pt \setpercentdimen\scratchdimen{10\letterpercent}
-%D \scratchdimen=100pt \setpercentdimen\scratchdimen{5pt}
-%D \scratchdimen \percentdimen \hsize {10\letterpercent}
-%D \stoptyping
-
-\def\percentdimen#1#2% dimen percentage (with %)
- {\dimexpr\clf_percentageof{#2}\dimexpr#1\relax}
-
-\unexpanded\def\setpercentdimen#1#2% dimen percentage (with %)
- {#1=\clf_percentageof{#2}\dimexpr#1\relax}
-
-%D \macros
-%D {makerawcommalist,
-%D rawdoinsetelse,
-%D rawprocesscommalist,
-%D rawprocessaction}
-%D
-%D Some of the commands mentioned earlier are effective but slow. When one is
-%D desperately in need of faster alternatives and when the conditions are
-%D predictable safe, the \type {\raw} alternatives come into focus. A major drawback
-%D is that they do not take \type {\c!constants} into account, simply because no
-%D expansion is done. This is no problem with \type {\rawprocesscommalist}, because
-%D this macro does not compare anything. Expandable macros are permitted as search
-%D string.
-%D
-%D \starttyping
-%D \makerawcommalist[string,string,...]\stringlist
-%D \rawdoifelseinset{string}{string,...}{...}{...}
-%D \rawprocesscommalist[string,string,...]\commando
-%D \rawprocessaction[x][a=>\a,b=>\b,c=>\c]
-%D \stoptyping
-%D
-%D Spaces embedded in the list, for instance after commas, spoil the search process.
-%D The gain in speed depends on the length of the argument (the longer the argument,
-%D the less we gain).
-
-\unexpanded\def\makerawcommalist[#1]#2% use \processnext ... here
- {\def\syst_helpers_do_make_raw_comma_list##1% we don't expand ##1
- {\ifx#2\empty
- \def#2{##1}%
- \else
- \expandafter\def\expandafter#2\expandafter{#2,##1}%
- \fi}%
- \let#2\empty
- \processcommalist[#1]\syst_helpers_do_make_raw_comma_list}
-
-\def\syst_helpers_raw_process_comma_item#1,#2% #2 eats up preceding space
- {\if]#1\else
- \csname\??nextcommalevel\the\commalevel\endcsname{#1}%
- \expandafter\syst_helpers_raw_process_comma_item
- \fi#2}
-
-\unexpanded\def\rawprocesscommalist[#1]#2% accepteert ook [\cs]
- {\global\advance\commalevel \plusone
- \expandafter\let\csname\??nextcommalevel\the\commalevel\endcsname#2%
- \expandafter\syst_helpers_raw_process_comma_item#1,],% \relax
- \global\advance\commalevel \minusone }
-
-\unexpanded\def\rawprocesscommacommand[#1]% not really needed
- {\normalexpanded{\rawprocesscommalist[#1]}}
-
-%D Here is one without nesting:
-
-\unexpanded\def\syst_helpers_fast_process_comma_item#1,#2% #2 eats up preceding space
- {\if]#1\else
- \syst_helpers_fast_process_comma_command{#1}%
- \expandafter\syst_helpers_fast_process_comma_item
- \fi#2}
-
-\unexpanded\def\fastprocesscommalist[#1]#2% accepteert ook [\cs]
- {\let\syst_helpers_fast_process_comma_command#2%
- \expandafter\syst_helpers_fast_process_comma_item#1,],}% \relax
-
-\unexpanded\def\fastprocesscommacommand[#1]#2% accepteert ook [\cs]
- {\let\syst_helpers_fast_process_comma_command#2%
- \normalexpanded{\syst_helpers_fast_process_comma_item#1},],}% \relax
-
-% \def\rawdoifelseinset#1#2{\doifinstringelse{,#1,}{,#2,}}
-% \def\rawdoifinset #1#2{\doifinstring {,#1,}{,#2,}}
-
-\def\m_syst_two_commas{,,}
-
-\unexpanded\def\rawdoifelseinset#1%
- {\edef\m_syst_sub_string{,#1,}% expand #1 here
- \ifx\m_syst_sub_string\m_syst_two_commas
- \expandafter\thirdofthreearguments
- \else
- \expandafter\syst_helpers_raw_do_if_in_set_else
- \fi}
-
-\let\rawdoifinsetelse\rawdoifinsetelse
-
-\unexpanded\def\syst_helpers_raw_do_if_in_set_else#1%
- {\syst_helpers_do_if_in_string_else\m_syst_sub_string{,#1,}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\rawdoifinset#1%
- {\edef\m_syst_sub_string{,#1,}% expand #1 here
- \ifx\m_syst_sub_string\m_syst_two_commas
- \expandafter\gobbletwoarguments
- \else
- \expandafter\syst_helpers_raw_do_if_in_set
- \fi}
-
-\unexpanded\def\syst_helpers_raw_do_if_in_set#1%%
- {\syst_helpers_do_if_in_string_else\m_syst_sub_string{,#1,}%
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-%D Some more raw material:
-
-\def\syst_helpers_do_raw_process_action[#1][#2]%
- {\def\syst_helpers_do_do_raw_process_action##1,#1=>##2,##3^^^^0004%
- {\if##3@\else
- \def\m_syst_helpers_process_action{##2}%
- \fi}%
- \syst_helpers_do_do_raw_process_action,#2,#1=>,@^^^^0004}
-
-\unexpanded\def\rawprocessaction[#1]#2[#3]%
- {\edef\m_syst_string_one{#1}%
- \edef\m_syst_string_two{undefined}% better \!!undefined
- \let\m_syst_helpers_process_action\m_syst_string_two
- \ifx\m_syst_string_one\empty
- \expandafter\syst_helpers_do_raw_process_action\expandafter[\s!default][#3]%
- \else
- \expandafter\syst_helpers_do_raw_process_action\expandafter[\m_syst_string_one][#3]%
- \ifx\m_syst_helpers_process_action\m_syst_string_two
- \expandafter\syst_helpers_do_raw_process_action\expandafter[\s!unknown][#3]%
- \fi
- \fi
- \ifx\m_syst_helpers_process_action\m_syst_string_two
- \else
- \m_syst_helpers_process_action
- \fi}
-
-%D When we process the list \type {a,b,c,d,e}, the raw routine takes over 30\% less
-%D time, when we feed $20+$ character strings we gain about 20\%. Alternatives which
-%D use \type {\futurelet} perform worse. Part of the speedup is due to the \type
-%D {\let} and \type {\expandafter} in the test.
-%D
-%D \macros
-%D {dosetvalue,dosetevalue,dosetgvalue,docopyvalue,doresetvalue,
-%D dogetvalue}
-%D
-%D When we are going to do assignments, we have to take multi||linguality into account.
-%D For the moment we keep things simple and single||lingual.
-%D
-%D \starttyping
-%D \dosetvalue {label} {variable} {value}
-%D \dosetevalue {label} {variable} {value}
-%D \dosetgvalue {label} {variable} {value}
-%D \docopyvalue {to label} {from label} {variable}
-%D \doresetvalue {label} {variable}
-%D \stoptyping
-%D
-%D These macros are in fact auxiliary ones and are not meant for use outside the
-%D assignment macros.
-
-\def\dosetvalue#1#2% #3
- {\expandafter\def\csname#1#2\endcsname} % {#3}}
-
-\def\dosetevalue#1#2% #3
- {\expandafter\edef\csname#1#2\endcsname} % {#3}}
-
-\def\dosetgvalue#1#2% #3
- {\expandafter\gdef\csname#1#2\endcsname} % {#3}}
-
-\def\doresetvalue#1#2%
- {\expandafter\let\csname#1#2\endcsname\empty}
-
-\def\doignorevalue#1#2#3%
- {\expandafter\let\csname#1#2\endcsname\empty}
-
-\def\docopyvalue#1#2#3%
- {\expandafter\def\csname#1#3\endcsname{\csname#2#3\endcsname}}
-
-%D \macros
-%D {doassign,undoassign,doassignempty}
-%D
-%D Assignments are the backbone of \CONTEXT. Abhorred by the concept of style file
-%D hacking, we took a considerable effort in building a parameterized system.
-%D Unfortunately there is a price to pay in terms of speed. Compared to other
-%D packages and taking the functionality of \CONTEXT\ into account, the total size
-%D of the format file is still very acceptable. Now how are these assignments done.
-%D
-%D Assignments can be realized with:
-%D
-%D \starttyping
-%D \doassign[label][variable=value]
-%D \undoassign[label][variable=value]
-%D \stoptyping
-%D
-%D and:
-%D
-%D \starttyping
-%D \doassignempty[label][variable=value]
-%D \stoptyping
-%D
-%D Assignments like \type{\doassign} are compatible with:
-%D
-%D \starttyping
-%D \def\labelvariable{value}
-%D \stoptyping
-%D
-%D We do check for the presence of an \type{=} and loudly complain of it's missed. We
-%D will redefine this macro later on, when a more advanced message mechanism is
-%D implemented.
-
-\unexpanded\def\showassignerror#1#2%
- {\writestatus{setup}{missing or ungrouped '=' after '#1' in line #2}}
-
-\unexpanded\def\doassignempty[#1][#2=#3]%
- {\ifcsname#1#2\endcsname\else\dosetvalue{#1}{#2}{#3}\fi}
-
-%D \macros
-%D {getparameters,geteparameters,getgparameters,
-%D forgetparameters}
-%D
-%D Using the assignment commands directly is not our ideal of user friendly interfacing,
-%D so we take some further steps.
-%D
-%D \starttyping
-%D \getparameters [label] [...=...,...=...]
-%D \forgetparameters [label] [...=...,...=...]
-%D \stoptyping
-%D
-%D Again, the label identifies the category a variable belongs to. The second argument
-%D can be a comma separated list of assignments.
-%D
-%D \starttyping
-%D \getparameters
-%D [demo]
-%D [alfa=1,
-%D beta=2]
-%D \stoptyping
-%D
-%D is equivalent to
-%D
-%D \starttyping
-%D \def\demoalfa{1}
-%D \def\demobeta{2}
-%D \stoptyping
-%D
-%D
-%D In the pre||multi||lingual stadium \CONTEXT\ took the next approach. With
-%D
-%D \starttyping
-%D \def\??demo {@@demo}
-%D \def\!!alfa {alfa}
-%D \def\!!beta {beta}
-%D \stoptyping
-%D
-%D calling
-%D
-%D \starttyping
-%D \getparameters
-%D [\??demo]
-%D [\!!alfa=1,
-%D \!!beta=2]
-%D \stoptyping
-%D
-%D lead to:
-%D
-%D \starttyping
-%D \def\@@demoalfa{1}
-%D \def\@@demobeta{2}
-%D \stoptyping
-%D
-%D Because we want to be able to distinguish the \type{!!} pre||tagged user supplied
-%D variables from internal counterparts, we will introduce a slightly different tag
-%D in the multi||lingual modules. There we will use \type{c!} or \type{v!},
-%D depending on the context.
-%D
-%D By calling \type{doassign} directly, we save ourselves some argument passing
-%D and gain some speed. Whatever optimizations we do, this command will always be
-%D one of the bigger bottlenecks. The alternative \type{\geteparameters} --- it's
-%D funny to see that this alternative saw the light so lately --- can be used to do
-%D expanded assigments.
-
-\let\currentvalue\empty
-
-\unexpanded\def\getparameters {\dogetparameters\dosetvalue}
-\unexpanded\def\geteparameters {\dogetparameters\dosetevalue}
-\unexpanded\def\getgparameters {\dogetparameters\dosetgvalue}
-\unexpanded\def\getxparameters {\dogetparameters\dosetxvalue}
-\unexpanded\def\forgetparameters{\dogetparameters\doignorevalue}
-
-\let\getexpandedparameters\geteparameters
-
-\unexpanded\def\dogetparameters#1[#2]#3[#4%
- {\if\noexpand#4]%
- \expandafter\gobbleoneargument
- \else
- \let\setsomevalue#1%
- \def\syst_helpers_get_parameters_assign{\syst_helpers_get_parameters_assign_indeed#2}%
- \expandafter\syst_helpers_get_parameters
- \fi#4}
-
-\def\syst_helpers_get_parameters#1]%
- {\xprocesscommaitem#1,],^^^^0004}
-
-\def\syst_helpers_process_comma_item#1,#2% #2 takes space before ,
- {\if,#1,% dirty trick for testing #1=empty
- \expandafter\syst_helpers_process_comma_item
- \orelse\if]#1%
- \expandafter\gobbleoneargument
- \else
- \syst_helpers_get_parameters_assign^^^^0004#1==\empty^^^^0004%
- \expandafter\syst_helpers_process_comma_item
- \fi#2}
-
-\def\syst_helpers_assign_error#1#2#3%
- {\showassignerror{#2}{\the\inputlineno\space(#1)}}
-
-\def\syst_helpers_get_parameters_assign_normal#1^^^^0004#2=#3=#4#5^^^^0004%
- {\ifx\empty#2\empty
- \expandafter\syst_helpers_assign_error
- \orelse\ifx#4\empty
- \expandafter\syst_helpers_assign_error
- \else
- \expandafter\setsomevalue
- \fi
- {#1}{#2}{#3}}
-
-\def\syst_helpers_get_parameters_assign_error#1^^^^0004#2=#3=#4#5^^^^0004%
- {\ifx\empty#2\empty
- \expandafter\syst_helpers_assign_error
- \orelse\ifx#4\empty
- \expandafter\syst_helpers_assign_error
- \orelse\ifcsname#1#2\endcsname
- \expandafter\let\expandafter\currentvalue\csname#1#2\endcsname
- \expandafter\setsomevalue
- \else
- \let\currentvalue\empty
- \expandafter\setsomevalue
- \fi
- {#1}{#2}{#3}}
-
-\let\syst_helpers_get_parameters_assign_indeed\syst_helpers_get_parameters_assign_normal
-
-\unexpanded\def\doassign [#1][#2]{\let\setsomevalue\dosetvalue \syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
-\unexpanded\def\doeassign [#1][#2]{\let\setsomevalue\dosetevalue \syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
-\unexpanded\def\undoassign[#1][#2]{\let\setsomevalue\doresetvalue\syst_helpers_get_parameters_assign_indeed#1^^^^0004#2==\empty^^^^0004}
-
-%D \macros
-%D {processassignmentlist,processassignmentcommand,
-%D startprocessassignmentlist,startprocessassignmentcommand}
-%D
-%D For Wolfgang:
-%D
-%D \starttyping
-%D \def\showpair#1#2{key:#1, value:#2\par}
-%D \processassignmentlist[a=1,b=2]\showpair
-%D \stoptyping
-%D
-%D We can optimize this one if needed but it's not a core macro so hardly worth the
-%D trouble and tokens.
-
-\unexpanded\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
- {\def\syst_helpers_process_assignment_entry##1{#2}% {##2}{##3} % namespace is ignored
- \dogetparameters\syst_helpers_process_assignment_entry[][#1]}
-
-\unexpanded\def\processassignmentcommand[#1]%
- {\normalexpanded{\processassignmentlist[#1]}}
-
-\unexpanded\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist
- {\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}%
- \processassignmentlist[#1]\currentassignmentlistcommand}
-
-\unexpanded\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand
- {\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}%
- \normalexpanded{\processassignmentlist[#1]}\currentassignmentlistcommand}
-
-%D \macros{currentvalue}
-%D
-%D Just in case a \type{\getparameter} argument itself ends up inside a \type
-%D {\write} or other expandable location, our new macro needs a default value.
-%D
-%D \starttyping
-%D \getparameters[xxx][aaa=bbb]\par
-%D \getparameters[xxx][=bbb]\par
-%D \getparameters[xxx][aaa=]\par
-%D \getparameters[xxx][=]\par
-%D \getparameters[xxx][aaa]\par
-%D \stoptyping
-
-%D \macros
-%D {expandparameters}
-%D
-%D Example usage:
-%D
-%D \startbuffer
-%D \getparameters[taco][name=taco]
-%D \convertcommand\taconame\to\ascii \ascii
-%D \expandparameters \getparameters[taco][name=\currentvalue\space hoekwater]
-%D \convertcommand\taconame\to\ascii \ascii
-%D \getparameters[taco][name=\currentvalue\space hoekwater]
-%D \convertcommand\taconame\to\ascii \ascii
-%D \stopbuffer
-%D
-%D \typebuffer
-%D \startlines
-%D \getbuffer
-%D \stoplines
-%D
-%D Here we hook in the code (beware, this is the optimized get **):
-
-\def\syst_helpers_get_parameters_normal#1]%
- {\syst_helpers_process_comma_item#1,],^^^^0004}
-
-\def\syst_helpers_get_parameters_expanded#1]%
- {\let\dosetnvalue\setsomevalue
- \let\setsomevalue\dosetevalue
- \let\syst_helpers_get_parameters_assign_indeed\syst_helpers_get_parameters_assign_error
- \let\setsomevalue\dosetevalue
- \syst_helpers_process_comma_item#1,],^^^^0004%
- \let\syst_helpers_get_parameters_assign_indeed\syst_helpers_get_parameters_assign_normal
- \let\setsomevalue\dosetnvalue
- \let\syst_helpers_get_parameters\syst_helpers_get_parameters_normal
- \let\currentvalue\empty}
-
-\let\syst_helpers_get_parameters\syst_helpers_get_parameters_normal % **
-
-\unexpanded\def\expandparameters
- {\let\syst_helpers_get_parameters\syst_helpers_get_parameters_expanded}
-
-%D \macros
-%D {getemptyparameters}
-%D
-%D Sometimes we explicitly want variables to default to an empty string, so we
-%D welcome:
-%D
-%D \starttyping
-%D \getemptyparameters [label] [...=...,...=...]
-%D \stoptyping
-
-\unexpanded\def\getemptyparameters[#1]#2[#3]%
- {\def\syst_helpers_get_empty_parameters##1{\doassignempty[#1][##1]}%
- \processcommalist[#3]\syst_helpers_get_empty_parameters}
-
-%D \macros
-%D {copyparameters}
-%D
-%D Some \CONTEXT\ commands take their default setups from others. All commands that
-%D are able to provide backgounds or rules around some content, for instance default
-%D to the standard command for ruled boxes. Is situations like this we can use:
-%D
-%D \starttyping
-%D \copyparameters [to-label] [from-label] [name1,name2,...]
-%D \stoptyping
-%D
-%D For instance
-%D
-%D \starttyping
-%D \copyparameters
-%D [internal][external]
-%D [alfa,beta]
-%D \stoptyping
-%D
-%D Leads to:
-%D
-%D \starttyping
-%D \def\internalalfa {\externalalfa}
-%D \def\internalbeta {\externalbeta}
-%D \stoptyping
-%D
-%D By using \type {\docopyvalue} we've prepared this command for use in a
-%D multi||lingual environment.
-
-\unexpanded\def\copyparameters[#1]#2[#3]#4[#5]%
- {\doifnot{#1}{#3}
- {\def\syst_helpers_copy_parameter{\docopyvalue{#1}{#3}}% ##1
- \processcommalist[#5]\syst_helpers_copy_parameter}}
-
-%D \macros
-%D {ifparameters,checkparameters}
-%D
-%D A slightly different one is \type {\checkparameters}, which also checks on the
-%D presence of a~\type {=}.
-%D
-%D The boolean \type {\ifparameters} can be used afterwards. Combining both in one
-%D \type {\if}||macro would lead to problems with nested \type {\if}'s.
-%D
-%D \starttyping
-%D \checkparameters[argument]
-%D \stoptyping
-
-\newif\ifparameters
-
-\def\syst_helpers_check_parameters#1=#2#3^^^^0004%
- {\if#2^^^^0003\parametersfalse\else\parameterstrue\fi}
-
-\unexpanded\def\checkparameters[#1]%
- {\syst_helpers_check_parameters#1=^^^^0003^^^^0003^^^^0004}
-
-%D \macros
-%D {getfromcommalist,getfromcommacommand,
-%D commalistelement,
-%D getcommalistsize,getcommacommandsize}
-%D
-%D It's possible to get an element from a commalist or a command representing
-%D a commalist.
-%D
-%D \starttyping
-%D \getfromcommalist [string] [n]
-%D \getfromcommacommand [string,\strings,string,...] [n]
-%D \stoptyping
-%D
-%D The difference betwee the two of them is the same as the difference between
-%D \type {\processcomma...}. The found string is stored in \type
-%D {\commalistelement}.
-%D
-%D We can calculate the size of a comma separated list by using:
-%D
-%D \starttyping
-%D \getcommalistsize [string,string,...]
-%D \getcommacommandsize [string,\strings,string,...]
-%D \stoptyping
-%D
-%D Afterwards, the length is available in the macro \type {\commalistsize}
-%D (not a \COUNTER).
-
-\newcount\commalistcounter
-
-\def\commalistsize{0}
-
-\def\syst_helpers_get_comma_list_size#1%
- {\advance\commalistcounter\plusone}
-
-\unexpanded\def\getcommalistsize#1]% don't loose [{#1}]
- {\commalistcounter\zerocount
- \processcommalist#1]\syst_helpers_get_comma_list_size % was [{#1}]
- \edef\commalistsize{\the\commalistcounter}}
-
-% \def\getcommacommandsize[#1]%
-% {\edef\commacommand{#1}%
-% \scratchtoks\expandafter{\expandafter[\commacommand]}%
-% \expandafter\getcommalistsize\the\scratchtoks }
-
-\unexpanded\def\getcommacommandsize[#1]%
- {\normalexpanded{\getcommalistsize[#1]}}
-
-\def\syst_helpers_get_from_comma_list#1%
- {\advance\commalistcounter \minusone
- \ifcase\commalistcounter
- \def\commalistelement{#1}%
- \expandafter\quitcommalist
- \fi}
-
-\unexpanded\def\getfromcommalist[#1]#2[#3]%
- {\let\commalistelement\empty
- \commalistcounter#3\relax
- \processcommalist[#1]\syst_helpers_get_from_comma_list}
-
-\unexpanded\def\getfromcommacommand[#1]%
- {\normalexpanded{\getfromcommalist[#1]}}
-
-%D Watertight (and efficient) solutions are hard to find, due to the handling of
-%D braces during parameters passing and scanning. Nevertheless:
-%D
-%D \startbuffer
-%D \def\dosomething#1{(#1=\commalistsize) }
-%D
-%D \getcommalistsize [\hbox{$a,b,c,d,e,f$}] \dosomething 1
-%D \getcommalistsize [{a,b,c,d,e,f}] \dosomething 1
-%D \getcommalistsize [{a,b,c},d,e,f] \dosomething 4
-%D \getcommalistsize [a,b,{c,d,e},f] \dosomething 4
-%D \getcommalistsize [a{b,c},d,e,f] \dosomething 4
-%D \getcommalistsize [{a,b}c,d,e,f] \dosomething 4
-%D \getcommalistsize [] \dosomething 0
-%D \getcommalistsize [{[}] \dosomething 1
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D reports:
-%D
-%D \getbuffer
-
-%D \macros
-%D {dogetcommalistelement,dogetcommacommandelement}
-%D
-%D For low level (fast) purposes, we can also use the next alternative, which can
-%D handle 8~elements at most.
-%D
-%D \starttyping
-%D \dogetcommalistelement1\from a,b,c\to\commalistelement
-%D \stoptyping
-
-\def\syst_helpers_get_comma_list_element#1\from#2,#3,#4,#5,#6,#7,#8\to#9%
- {\edef#9{\ifcase#1\relax\or#2\or#3\or#4\or#5\or#6\or#7\or#8\fi}}
-
-\def\dogetcommacommandelement#1\from#2\to%
- {\expandafter\syst_helpers_get_comma_list_element\expandafter#1\expandafter\from#2,,,,,,\to}
-
-%D \macros
-%D {dosingleargument,dodoubleargument,dotripleargument,
-%D doquadrupleargument,doquintupleargument,dosixtupleargument,
-%D doseventupleargument}
-%D
-%D When working with delimited arguments, spaces and lineendings can interfere. The
-%D next set of macros uses \TEX' internal scanner for grabbing everything between
-%D arguments. Forgive me the funny names.
-%D
-%D \starttyping
-%D \dosingleargument\commando = \commando[#1]
-%D \dodoubleargument\commando = \commando[#1][#2]
-%D \dotripleargument\commando = \commando[#1][#2][#3]
-%D \doquadrupleargument\commando = \commando[#1][#2][#3][#4]
-%D \doquintupleargument\commando = \commando[#1][#2][#3][#4][#5]
-%D \dosixtupleargument\commando = \commando[#1][#2][#3][#4][#5][#6]
-%D \doseventupleargument\command = \commando[#1][#2][#3][#4][#5][#6][#7]
-%D \stoptyping
-%D
-%D These macros are used in the following way:
-%D
-%D \starttyping
-%D \def\dosetupsomething[#1][#2]%
-%D {... #1 ... #2 ...}
-%D
-%D \unexpanded\def\setupsomething
-%D {\dodoubleargument\dosetupsomething}
-%D \stoptyping
-%D
-%D The implementation can be surprisingly simple and needs no
-%D further explanation, like:
-%D
-%D \starttyping
-%D \def\dosingleargument#1[#2]%
-%D {#1[#2]}
-%D \def\dotripleargument#1[#2]#3[#4]#5[#6]%
-%D {#1[#2][#4][#6]}
-%D \def\doquintupleargument#1%
-%D {\def\dodoquintupleargument[##1]##2[##3]##4[##5]##6[##7]##8[##9]%
-%D {#1[##1][##3][##5][##7][##9]}%
-%D \dodoquintupleargument}
-%D \stoptyping
-%D
-%D Because \TEX\ accepts 9~arguments at most, we have to use two||step solution when
-%D getting five or more arguments.
-%D
-%D When developing more and more of the real \CONTEXT, we started using some
-%D alternatives that provided empty arguments (in fact optional ones) whenever the
-%D user failed to supply them. Because this more complicated macros enable us to do
-%D some checking, we reimplemented the non||empty ones.
-
-%D \macros
-%D {iffirstagument,ifsecondargument,ifthirdargument,
-%D iffourthargument,iffifthargument,ifsixthargument,
-%D ifseventhargument}
-%D
-%D We use some signals for telling the calling macros if all wanted arguments are
-%D indeed supplied by the user.
-
-\newif\iffirstargument
-\newif\ifsecondargument
-\newif\ifthirdargument
-\newif\iffourthargument
-\newif\iffifthargument
-\newif\ifsixthargument
-\newif\ifseventhargument
-
-%D \macros
-%D {dosingleempty,dodoubleempty,dotripleempty,
-%D doquadrupleempty,doquintupleempty,dosixtupeempty,
-%D doseventupleempty}
-%D
-%D The empty argument supplying macros mentioned before, look like:
-%D
-%D \starttyping
-%D \dosingleempty \command
-%D \dodoubleempty \command
-%D \dotripleempty \command
-%D \doquadrupleempty \command
-%D \doquintupleempty \command
-%D \dosixtuple_empty \command
-%D \doseventupleempty\command
-%D \stoptyping
-%D
-%D So \type{\dodoubleempty} leads to:
-%D
-%D \starttyping
-%D \command[#1][#2]
-%D \command[#1][]
-%D \command[][]
-%D \stoptyping
-%D
-%D Depending of the generousity of the user. Afterwards one can use the \type
-%D {\if...argument} boolean. For novice: watch the stepwise doubling of \type {#}'s.
-
-%D Common:
-
-\newtoks\t_syst_aux
-
-\def\syst_helpers_single_empty_one_yes {\firstargumenttrue \the\t_syst_aux}
-\def\syst_helpers_double_empty_two_yes {\secondargumenttrue \the\t_syst_aux}
-\def\syst_helpers_triple_empty_three_yes {\thirdargumenttrue \the\t_syst_aux}
-\def\syst_helpers_quadruple_empty_four_yes {\fourthargumenttrue \the\t_syst_aux}
-\def\syst_helpers_quintuple_empty_five_yes {\fifthargumenttrue \the\t_syst_aux}
-\def\syst_helpers_sixtuple_empty_six_yes {\sixthargumenttrue \the\t_syst_aux}
-\def\syst_helpers_seventuple_empty_seven_yes{\seventhargumenttrue\the\t_syst_aux}
-
-%D Single:
-
-\unexpanded\def\dosingleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_single_empty_one_yes\syst_helpers_single_empty_one_nop}
-
-\def\syst_helpers_single_empty_one_nop
- {\firstargumentfalse
- \the\t_syst_aux[]}
-
-%D Double
-
-\unexpanded\def\dodoubleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_double_empty_one_yes\syst_helpers_double_empty_one_nop}
-
-\def\syst_helpers_double_empty_one_yes[#1]%
- {\firstargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_double_empty_two_yes\syst_helpers_double_empty_two_nop}
-
-\def\syst_helpers_double_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \the\t_syst_aux[][]}
-
-\def\syst_helpers_double_empty_two_nop
- {\secondargumentfalse
- \the\t_syst_aux[]}
-
-% Triple
-
-\unexpanded\def\dotripleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_triple_empty_one_yes\syst_helpers_triple_empty_one_nop}
-
-\def\syst_helpers_triple_empty_one_yes[#1]%
- {\firstargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_triple_empty_two_yes\syst_helpers_triple_empty_two_nop}
-
-\def\syst_helpers_triple_empty_two_yes[#1]%
- {\secondargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_triple_empty_three_yes\syst_helpers_triple_empty_three_nop}
-
-\def\syst_helpers_triple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \the\t_syst_aux[][][]}
-
-\def\syst_helpers_triple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \the\t_syst_aux[][]}
-
-\def\syst_helpers_triple_empty_three_nop
- {\thirdargumentfalse
- \the\t_syst_aux[]}
-
-%D Quadruple:
-
-\unexpanded\def\doquadrupleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_quadruple_empty_one_yes\syst_helpers_quadruple_empty_one_nop}
-
-\def\syst_helpers_quadruple_empty_one_yes[#1]%
- {\firstargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quadruple_empty_two_yes\syst_helpers_quadruple_empty_two_nop}
-
-\def\syst_helpers_quadruple_empty_two_yes[#1]%
- {\secondargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quadruple_empty_three_yes\syst_helpers_quadruple_empty_three_nop}
-
-\def\syst_helpers_quadruple_empty_three_yes[#1]%
- {\thirdargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quadruple_empty_four_yes\syst_helpers_quadruple_empty_four_nop}
-
-\def\syst_helpers_quadruple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \the\t_syst_aux[][][][]}
-
-\def\syst_helpers_quadruple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \the\t_syst_aux[][][]}
-
-\def\syst_helpers_quadruple_empty_three_nop
- {\thirdargumentfalse
- \fourthargumentfalse
- \the\t_syst_aux[][]}
-
-\def\syst_helpers_quadruple_empty_four_nop
- {\fourthargumentfalse
- \the\t_syst_aux[]}
-
-%D Quintuple:
-
-\unexpanded\def\doquintupleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_quintuple_empty_one_yes\syst_helpers_quintuple_empty_one_nop}
-
-\def\syst_helpers_quintuple_empty_one_yes[#1]%
- {\firstargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quintuple_empty_two_yes\syst_helpers_quintuple_empty_two_nop}
-
-\def\syst_helpers_quintuple_empty_two_yes[#1]%
- {\secondargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quintuple_empty_three_yes\syst_helpers_quintuple_empty_three_nop}
-
-\def\syst_helpers_quintuple_empty_three_yes[#1]%
- {\thirdargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quintuple_empty_four_yes\syst_helpers_quintuple_empty_four_nop}
-
-\def\syst_helpers_quintuple_empty_four_yes[#1]%
- {\fourthargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_quintuple_empty_five_yes\syst_helpers_quintuple_empty_five_nop}
-
-\def\syst_helpers_quintuple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux[][][][][]}
-
-\def\syst_helpers_quintuple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux[][][][]}
-
-\def\syst_helpers_quintuple_empty_three_nop
- {\thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux[][][]}
-
-\def\syst_helpers_quintuple_empty_four_nop
- {\fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux[][]}
-
-\def\syst_helpers_quintuple_empty_five_nop
- {\fifthargumentfalse
- \the\t_syst_aux[]}
-
-%D Sixtuple:
-
-\unexpanded\def\dosixtupleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_sixtuple_empty_one_yes\syst_helpers_sixtuple_empty_one_nop}
-
-\def\syst_helpers_sixtuple_empty_one_yes[#1]%
- {\firstargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_sixtuple_empty_two_yes\syst_helpers_sixtuple_empty_two_nop}
-
-\def\syst_helpers_sixtuple_empty_two_yes[#1]%
- {\secondargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_sixtuple_empty_three_yes\syst_helpers_sixtuple_empty_three_nop}
-
-\def\syst_helpers_sixtuple_empty_three_yes[#1]%
- {\thirdargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_sixtuple_empty_four_yes\syst_helpers_sixtuple_empty_four_nop}
-
-\def\syst_helpers_sixtuple_empty_four_yes[#1]%
- {\fourthargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_sixtuple_empty_five_yes\syst_helpers_sixtuple_empty_five_nop}
-
-\def\syst_helpers_sixtuple_empty_five_yes[#1]%
- {\fifthargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_sixtuple_empty_six_yes\syst_helpers_sixtuple_empty_six_nop}
-
-\def\syst_helpers_sixtuple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \the\t_syst_aux[][][][][][]}
-
-\def\syst_helpers_sixtuple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \the\t_syst_aux[][][][][]}
-
-\def\syst_helpers_sixtuple_empty_three_nop
- {\thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \the\t_syst_aux[][][][]}
-
-\def\syst_helpers_sixtuple_empty_four_nop
- {\fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \the\t_syst_aux[][][]}
-
-\def\syst_helpers_sixtuple_empty_five_nop
- {\fifthargumentfalse
- \sixthargumentfalse
- \the\t_syst_aux[][]}
-
-\def\syst_helpers_sixtuple_empty_six_nop
- {\sixthargumentfalse
- \the\t_syst_aux[]}
-
-%D Seventuple:
-
-\unexpanded\def\doseventupleempty#1%
- {%syst_helpers_argument_reset
- \t_syst_aux{#1}%
- \futureexpand[\syst_helpers_seventuple_empty_one_yes\syst_helpers_seventuple_empty_one_nop}
-
-\def\syst_helpers_seventuple_empty_one_yes[#1]%
- {\firstargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_seventuple_empty_two_yes\syst_helpers_seventuple_empty_two_nop}
-
-\def\syst_helpers_seventuple_empty_two_yes[#1]%
- {\secondargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_seventuple_empty_three_yes\syst_helpers_seventuple_empty_three_nop}
-
-\def\syst_helpers_seventuple_empty_three_yes[#1]%
- {\thirdargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_seventuple_empty_four_yes\syst_helpers_seventuple_empty_four_nop}
-
-\def\syst_helpers_seventuple_empty_four_yes[#1]%
- {\fourthargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_seventuple_empty_five_yes\syst_helpers_seventuple_empty_five_nop}
-
-\def\syst_helpers_seventuple_empty_five_yes[#1]%
- {\fifthargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_seventuple_empty_six_yes\syst_helpers_seventuple_empty_six_nop}
-
-\def\syst_helpers_seventuple_empty_six_yes[#1]%
- {\sixthargumenttrue
- \toksapp\t_syst_aux{[{#1}]}%
- \futureexpand[\syst_helpers_seventuple_empty_seven_yes\syst_helpers_seventuple_empty_seven_nop}
-
-\def\syst_helpers_seventuple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \seventhargumentfalse
- \the\t_syst_aux[][][][][][][]}
-
-\def\syst_helpers_seventuple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \seventhargumentfalse
- \the\t_syst_aux[][][][][][]}
-
-\def\syst_helpers_seventuple_empty_three_nop
- {\thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \seventhargumentfalse
- \the\t_syst_aux[][][][][]}
-
-\def\syst_helpers_seventuple_empty_four_nop
- {\fourthargumentfalse
- \fifthargumentfalse
- \sixthargumentfalse
- \seventhargumentfalse
- \the\t_syst_aux[][][][]}
-
-\def\syst_helpers_seventuple_empty_five_nop
- {\fifthargumentfalse
- \sixthargumentfalse
- \seventhargumentfalse
- \the\t_syst_aux[][][]}
-
-\def\syst_helpers_seventuple_empty_six_nop
- {\sixthargumentfalse
- \seventhargumentfalse
- \the\t_syst_aux[][]}
-
-\def\syst_helpers_seventuple_empty_seven_nop
- {\seventhargumentfalse
- \the\t_syst_aux[]}
-
-%D Aliases:
-
-\let\dosingleargument \dosingleempty
-\let\dodoubleargument \dodoubleempty
-\let\dotripleargument \dotripleempty
-\let\doquadrupleargument \doquadrupleempty
-\let\doquintupleargument \doquintupleempty
-\let\dosixtupleargument \dosixtupleempty
-\let\doseventupleargument\doseventupleempty
-
-%D \macros
-%D {strippedcsname}
-%D
-%D The next macro can be very useful when using \type{\csname} like in:
-%D
-%D \starttyping
-%D \csname if\strippedcsname\something\endcsname
-%D \stoptyping
-%D
-%D This expands to \type{\ifsomething}.
-
-% \def\strippedcsname
-% {\expandafter\gobbleoneargument\string}
-
-\let\strippedcsname\csstring
-
-%D \macros
-%D {complexorsimple,complexorsimpleempty}
-%D
-%D Setups can be optional. A command expecting a setup is prefixed by \type
-%D {\complex}, a command without one gets the prefix \type {\simple}. Commands like
-%D this can be defined by:
-%D
-%D \starttyping
-%D \complexorsimple\command
-%D \stoptyping
-%D
-%D When \type{\command} is followed by a \type{[setup]}, then
-%D
-%D \starttyping
-%D \complexcommand [setup]
-%D \stoptyping
-%D
-%D executes, else we get
-%D
-%D \starttyping
-%D \simplecommand
-%D \stoptyping
-%D
-%D An alternative for \type{\complexorsimple} is:
-%D
-%D \starttyping
-%D \complexorsimpleempty {command}
-%D \stoptyping
-%D
-%D Depending on the presence of \type{[setup]}, this one leads to one of:
-%D
-%D \starttyping
-%D \complexcommando [setup]
-%D \complexcommando []
-%D \stoptyping
-%D
-%D Many \CONTEXT\ commands started as complex or simple ones, but changed into more
-%D versatile (more object oriented) ones using the \type {\get..argument} commands.
-
-\unexpanded\def\complexorsimple#1%
- {% \relax % prevents lookahead, brrr
- \doifelsenextoptional
- {\firstargumenttrue \csname\s!complex\csstring#1\endcsname}
- {\firstargumentfalse\csname\s!simple \csstring#1\endcsname}}
-
-\unexpanded\def\complexorsimpleempty#1%
- {% \relax % prevents lookahead, brrr
- \doifelsenextoptional
- {\firstargumenttrue \csname\s!complex\csstring#1\endcsname}
- {\firstargumentfalse\csname\s!complex\csstring#1\endcsname[]}}
-
-%D \macros
-%D {definecomplexorsimple,definecomplexorsimpleempty}
-%D
-%D The previous commands are used that often that we found it worthwile to offer two
-%D more alternatives. Watch the build in protection.
-
-\unexpanded\def\syst_helpers_complex_or_simple#1#2%
- {\doifelsenextoptional{\firstargumenttrue#1}{\firstargumentfalse#2}}
-
-\unexpanded\def\syst_helpers_complex_or_simple_empty#1%
- {\doifelsenextoptional{\firstargumenttrue#1}{\firstargumentfalse#1[]}}
-
-\unexpanded\def\definecomplexorsimple#1%
- {\unexpanded\edef#1{\syst_helpers_complex_or_simple
- \expandafter\noexpand\csname\s!complex\csstring#1\endcsname
- \expandafter\noexpand\csname\s!simple \csstring#1\endcsname}}
-
-\unexpanded\def\definecomplexorsimpleempty#1%
- {\unexpanded\edef#1{\syst_helpers_complex_or_simple_empty
- \expandafter\noexpand\csname\s!complex\csstring#1\endcsname}}
-
-%D These commands are called as:
-%D
-%D \starttyping
-%D \definecomplexorsimple\command
-%D \stoptyping
-%D
-%D Of course, we must have available
-%D
-%D \starttyping
-%D \def\complexcommand[#1]{...}
-%D \def\simplecommand {...}
-%D \stoptyping
-%D
-%D Using this construction saves a few string now and then.
-
-%D \macros
-%D {dosinglegroupempty,dodoublegroupempty,dotriplegroupempty,
-%D doquadruplegroupempty, doquintuplegroupempty}
-%D
-%D We've already seen some commands that take care of
-%D optional arguments between \type{[]}. The next two commands
-%D handle the ones with \type{{}}. They are called as:
-%D
-%D \starttyping
-%D \dosinglegroupempty \ineedONEargument
-%D \dodoublegroupempty \ineedTWOarguments
-%D \dotriplegroupempty \ineedTHREEarguments
-%D \doquadruplegroupempty \ineedFOURarguments
-%D \doquintuplegroupempty \ineedFIVEarguments
-%D \stoptyping
-%D
-%D We can add additional definitions later when we have defined \type {\appendtoks}.
-
-\newconditional\c_syst_helpers_permit_spaces_between_groups
-
-\unexpanded\def \permitspacesbetweengroups{\settrue \c_syst_helpers_permit_spaces_between_groups}
-\unexpanded\def\dontpermitspacesbetweengroups{\setfalse\c_syst_helpers_permit_spaces_between_groups}
-
-\dontpermitspacesbetweengroups
-
-%D We can avoid the nasty if handling in \type {syst-gen} by splitting the lot in
-%D pieces so that we have no nested \type {\nextarguments} potentially being an
-%D \type {conditional} token. Okay, these macros are not called that often but it
-%D saves crap when tracing.
-
-\unexpanded\def\dosinglegroupempty#1%
- {\t_syst_aux{#1}%
- \futureexpand\bgroup\syst_helpers_single_empty_one_yes\syst_helpers_single_group_empty_one_nop}
-
-\def\syst_helpers_single_group_empty_one_nop
- {\firstargumentfalse
- \the\t_syst_aux{}}
-
-\unexpanded\def\dodoublegroupempty#1%
- {\t_syst_aux{#1}%
- \futureexpand\bgroup\syst_helpers_group_double_empty_one_yes\syst_helpers_group_double_empty_one_nop}
-
-\def\syst_helpers_group_double_empty_one_yes#1%
- {\firstargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_double_empty_two_yes\syst_helpers_group_double_empty_two_nop}
-
-\def\syst_helpers_group_double_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \the\t_syst_aux{}{}}
-
-\def\syst_helpers_group_double_empty_two_nop
- {\secondargumentfalse
- \the\t_syst_aux{}}
-
-\unexpanded\def\dotriplegroupempty#1%
- {\t_syst_aux{#1}%
- \futureexpand\bgroup\syst_helpers_group_triple_empty_one_yes\syst_helpers_group_triple_empty_one_nop}
-
-\def\syst_helpers_group_triple_empty_one_yes#1%
- {\firstargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_group_triple_empty_two_yes\syst_helpers_group_triple_empty_two_nop}
-
-\def\syst_helpers_group_triple_empty_two_yes#1%
- {\secondargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_triple_empty_three_yes\syst_helpers_group_triple_empty_three_nop}
-
-\def\syst_helpers_group_triple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \the\t_syst_aux{}{}{}}
-
-\def\syst_helpers_group_triple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \the\t_syst_aux{}{}}
-
-\def\syst_helpers_group_triple_empty_three_nop
- {\thirdargumentfalse
- \the\t_syst_aux{}}
-
-\unexpanded\def\doquadruplegroupempty#1%
- {\t_syst_aux{#1}%
- \futureexpand\bgroup\syst_helpers_group_quadruple_empty_one_yes\syst_helpers_group_quadruple_empty_one_nop}
-
-\def\syst_helpers_group_quadruple_empty_one_yes#1%
- {\firstargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_group_quadruple_empty_two_yes\syst_helpers_group_quadruple_empty_two_nop}
-
-\def\syst_helpers_group_quadruple_empty_two_yes#1%
- {\secondargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_group_quadruple_empty_three_yes\syst_helpers_group_quadruple_empty_three_nop}
-
-\def\syst_helpers_group_quadruple_empty_three_yes#1%
- {\thirdargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_quadruple_empty_four_yes\syst_helpers_group_quadruple_empty_four_nop}
-
-\def\syst_helpers_group_quadruple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \the\t_syst_aux{}{}{}{}}
-
-\def\syst_helpers_group_quadruple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \the\t_syst_aux{}{}{}}
-
-\def\syst_helpers_group_quadruple_empty_three_nop
- {\thirdargumentfalse
- \fourthargumentfalse
- \the\t_syst_aux{}{}}
-
-\def\syst_helpers_group_quadruple_empty_four_nop
- {\fourthargumentfalse
- \the\t_syst_aux{}}
-
-\unexpanded\def\doquintuplegroupempty#1%
- {\t_syst_aux{#1}%
- \futureexpand\bgroup\syst_helpers_group_quintuple_empty_one_yes\syst_helpers_group_quintuple_empty_one_nop}
-
-\def\syst_helpers_group_quintuple_empty_one_yes#1%
- {\firstargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_group_quintuple_empty_two_yes\syst_helpers_group_quintuple_empty_two_nop}
-
-\def\syst_helpers_group_quintuple_empty_two_yes#1%
- {\secondargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_group_quintuple_empty_three_yes\syst_helpers_group_quintuple_empty_three_nop}
-
-\def\syst_helpers_group_quintuple_empty_three_yes#1%
- {\thirdargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_group_quintuple_empty_four_yes\syst_helpers_group_quintuple_empty_four_nop}
-
-\def\syst_helpers_group_quintuple_empty_four_yes#1%
- {\fourthargumenttrue
- \toksapp\t_syst_aux{{#1}}%
- \futureexpand\bgroup\syst_helpers_quintuple_empty_five_yes\syst_helpers_group_quintuple_empty_five_nop}
-
-\def\syst_helpers_group_quintuple_empty_one_nop
- {\firstargumentfalse
- \secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux{}{}{}{}{}}
-
-\def\syst_helpers_group_quintuple_empty_two_nop
- {\secondargumentfalse
- \thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux{}{}{}{}}
-
-\def\syst_helpers_group_quintuple_empty_three_nop
- {\thirdargumentfalse
- \fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux{}{}{}}
-
-\def\syst_helpers_group_quintuple_empty_four_nop
- {\fourthargumentfalse
- \fifthargumentfalse
- \the\t_syst_aux{}{}}
-
-\def\syst_helpers_group_quintuple_empty_five_nop
- {\fifthargumentfalse
- \the\t_syst_aux{}}
-
-%D These macros can explictly take care of spaces, which means that the next
-%D definition and calls are valid:
-%D
-%D \starttyping
-%D \def\test#1#2#3{[#1#2#3]}
-%D
-%D \dotriplegroupempty\test {a}{b}{c}
-%D \dotriplegroupempty\test {a}{b}
-%D \dotriplegroupempty\test {a}
-%D \dotriplegroupempty\test
-%D \dotriplegroupempty\test {a} {b} {c}
-%D \dotriplegroupempty\test {a} {b}
-%D \dotriplegroupempty\test
-%D {a}
-%D {b}
-%D \stoptyping
-%D
-%D And alike.
-
-%D \macros
-%D {firstofoneargument, firstoftwoarguments, firstofthreearguments
-%D secondoftwoarguments, secondofthreearguments,
-%D thirdofthreearguments}
-%D
-%D The next six macros (dedicated to Taco) can conveniently used to select
-%D arguments. Their names explain their functionality.
-
-\def\firstofoneargument #1{#1}
-
-\def\firstoftwoarguments #1#2{#1}
-\def\secondoftwoarguments #1#2{#2}
-
-\def\firstofthreearguments #1#2#3{#1}
-\def\secondofthreearguments #1#2#3{#2}
-\def\thirdofthreearguments #1#2#3{#3}
-
-\def\firstoffourarguments #1#2#3#4{#1}
-\def\secondoffourarguments #1#2#3#4{#2}
-\def\thirdoffourarguments #1#2#3#4{#3}
-\def\fourthoffourarguments #1#2#3#4{#4}
-
-\def\firstoffivearguments #1#2#3#4#5{#1}
-\def\secondoffivearguments #1#2#3#4#5{#2}
-\def\thirdoffivearguments #1#2#3#4#5{#3}
-\def\fourthoffivearguments #1#2#3#4#5{#4}
-\def\fifthoffivearguments #1#2#3#4#5{#5}
-
-\def\firstofsixarguments #1#2#3#4#5#6{#1}
-\def\secondofsixarguments#1#2#3#4#5#6{#2}
-\def\thirdofsixarguments #1#2#3#4#5#6{#3}
-\def\fourthofsixarguments#1#2#3#4#5#6{#4}
-\def\fifthofsixarguments #1#2#3#4#5#6{#5}
-\def\sixthofsixarguments #1#2#3#4#5#6{#6}
-
-\unexpanded\def\firstofoneunexpanded #1{#1}
-
-\unexpanded\def\firstoftwounexpanded #1#2{#1}
-\unexpanded\def\secondoftwounexpanded #1#2{#2}
-
-\unexpanded\def\firstofthreeunexpanded #1#2#3{#1}
-\unexpanded\def\secondofthreeunexpanded#1#2#3{#2}
-\unexpanded\def\thirdofthreeunexpanded #1#2#3{#3}
-
-%D \macros
-%D {globalletempty,letempty,
-%D letvalueempty,letgvalueempty,
-%D letvaluerelax,letgvaluerelax}
-%D
-%D Trivial:
-
-\unexpanded\def\letempty #1{\let #1\empty}
-\unexpanded\def\globalletempty#1{\glet#1\empty}
-
-\unexpanded\def\letvalueempty #1{\expandafter\let \csname#1\endcsname\empty}
-\unexpanded\def\letgvalueempty#1{\expandafter\glet\csname#1\endcsname\empty}
-\unexpanded\def\letvaluerelax #1{\expandafter\let \csname#1\endcsname\relax}
-\unexpanded\def\letgvalurelax #1{\expandafter\glet\csname#1\endcsname\relax}
-
-\unexpanded\def\relaxvalueifundefined#1%
- {\ifcsname#1\endcsname \else
- \expandafter\let\csname#1\endcsname\relax
- \fi}
-
-%D \macros
-%D {wait}
-%D
-%D The next macro hardly needs explanation. Because no nesting is to be expected, we
-%D can reuse \type {\wait} within \type {\wait} itself.
-
-\unexpanded\def\wait
- {\begingroup
- \read16 to \wait
- \endgroup}
-
-%D \macros
-%D {writestring,writeline,
-%D writestatus,statuswidth,normalwritestatus}
-%D
-%D Maybe one didn't notice, but we've already introduced a macro for showing
-%D messages. In the multi||lingual modules, we will also introduce a mechanism for
-%D message passing. For the moment we stick to the core macros:
-%D
-%D \starttyping
-%D \writestring {string}
-%D \writeline
-%D \writestatus {category} {message}
-%D \stoptyping
-%D
-%D Messages are formatted. One can provide the maximum with of the identification
-%D string with the macro \type {\statuswidth}.
-
-\setnewconstant\statuswidth 15
-\setnewconstant\statuswrite 128 % \pluscxxviii
-
-\ifdefined\writestring \else
-
- \unexpanded\def\writestring{\immediate\write\statuswrite}
- \unexpanded\def\writeline {\writestring{}}
-
-\fi
-
-\unexpanded\def\normalwritestatus#1#2%
- {\writestring{\expandafter\syst_helpers_split_status_yes\expandafter\statuswidth#1%
- \space\space\space\space\space\space\space
- \space\space\space\space\space\space\space
- \space\space\space\space\space\space\end
- \space:\space#2}}
-
-\def\syst_helpers_split_status_yes#1#2%
- {\ifcase#1 \expandafter\syst_helpers_split_status_nop\fi#2%
- \expandafter\syst_helpers_split_status_yes\expandafter{\the\numexpr#1+\minusone\relax}}
-
-\def\syst_helpers_split_status_nop#1\end
- {}
-
-%D \macros
-%D {immediatemessage}
-%D
-%D A fully expandable message:
-
-\let\immediatemessage\clf_immediatemessage % {} mandate
-
-%D \macros
-%D {rawgetparameters}
-%D
-%D A raw and dirty alternative for \type {\getparameters}; no checking is done!
-
-\unexpanded\def\rawsetparameter#1=#2,%
- {\if]#1\else
- \expandafter\def\csname\rawparameterprefix#1\endcsname{#2}%
- \expandafter\rawsetparameter
- \fi}
-
-\unexpanded\def\rawgetparameters[#1][#2% some 5-10% faster
- {\ifx#2]% test is needed, else bomb on [#1][]
- \expandafter\gobbleoneargument
- \else
- \def\rawparameterprefix{#1}%
- \expandafter\dorawgetparameters
- \fi#2}
-
-\def\dorawgetparameters#1]%
- {\expandafter\rawsetparameter#1,]=,}
-
-%D \macros
-%D {doglobal,
-%D redoglobal,dodoglobal,resetglobal}
-%D
-%D The two macros \type {\redoglobal} and \type{\dodoglobal} are used in this and
-%D some other modules to enforce a user specified \type {\doglobal} action. The last
-%D and often only global assignment in a macro is done with \type {\dodoglobal}, but
-%D all preceding ones with \type {\redoglobal}. When using only alternatives, one
-%D can reset this mechanism with \type {\resetglobal}.
-
-\unexpanded\def\resetglobal
- {\let\redoglobal\relax
- \let\dodoglobal\relax}
-
-\resetglobal
-
-\unexpanded\def\doglobal
- {\ifx\redoglobal\relax
- \let\redoglobal\global
- \let\dodoglobal\syst_helpers_dodo_global
- \fi}
-
-\def\syst_helpers_dodo_global
- {\resetglobal\global}
-
-\def\saveglobal
- {\let\syst_helpers_dodo_global\dodoglobal
- \let\syst_helpers_redo_global\redoglobal}
-
-\def\restoreglobal
- {\let\redoglobal\syst_helpers_redo_global
- \let\dodoglobal\syst_helpers_dodo_global}
-
-%D A very useful application of this macro is \type {\newif}, \TEX's fake boolean
-%D type. Not being a primitive, \type {\global} hopelessly fails here. But a slight
-%D adaption of Knuth's original macro permits:
-%D
-%D \starttyping
-%D \doglobal\newif\iftest
-%D \stoptyping
-%D
-%D Of course one can still say:
-%D
-%D \starttyping
-%D \global\testtrue
-%D \global\testfalse
-%D \stoptyping
-%D
-%D Apart from the prefixes, a few more \type {\expandafters} are needed:
-
-% \unexpanded\def\newif#1% uses the original plain \@if
-% {\privatescratchcounter\escapechar
-% \escapechar\minusone
-% \expandafter\expandafter\expandafter
-% \redoglobal\expandafter\expandafter\expandafter
-% \edef\@if#1{true}{\let\noexpand#1\noexpand\iftrue}%
-% \expandafter\expandafter\expandafter
-% \redoglobal\expandafter\expandafter\expandafter
-% \edef\@if#1{false}{\let\noexpand#1\noexpand\iffalse}%
-% \dodoglobal\@if#1{false}%
-% \escapechar\privatescratchcounter}
-
-\normalprotected\def\newif#1% see syst-ini.mkiv
- {\let\new_if_saved\newif
- \let\newif\new_if_check
- \expandafter\redoglobal\expandafter\def\csname\expandafter\newif\csstring#1true\endcsname {\let#1\iftrue }%
- \expandafter\redoglobal\expandafter\def\csname\expandafter\newif\csstring#1false\endcsname{\let#1\iffalse}%
- \dodoglobal\csname\expandafter\newif\csstring#1false\endcsname
- \let\newif\new_if_saved}
-
-%D Also new:
-
-\unexpanded\def\define#1%
- {\ifdefined#1%
- \message{[\noexpand#1is already defined]}%
- \unexpanded\expandafter\def\expandafter\gobbleddefinition
- \else
- \unexpanded\expandafter\def
- \fi#1}
-
-\unexpanded\def\redefine#1%
- {\ifdefined#1%
- \message{[\noexpand#1is redefined]}%
- \fi
- \unexpanded\def#1}
-
-\unexpanded\def\definemacro#1%
- {\ifdefined#1%
- \message{[\noexpand#1is already defined]}%
- \unexpanded\expandafter\def\expandafter\gobbleddefinition
- \else
- \unexpanded\expandafter\def
- \fi#1}
-
-% \define\hans{hans}
-% \redefine\hans{hans}
-% \define\hans#1[]#2#3{hans}
-
-%D The next variant fits nicely in the setups syntax:
-%D
-%D \starttyping
-%D \starttexdefinition bagger [#1] #2
-%D oeps
-%D #1
-%D oeps
-%D \stoptexdefinition
-%D
-%D \bagger [a] {b}
-%D \stoptyping
-
-% \starttexdefinition test
-% oeps
-% \stoptexdefinition
-%
-% [\test]
-
-\def\s!unexpanded{unexpanded}
-
-\bgroup \obeylines
-
-\glet\stoptexdefinition\relax
-
-\unexpanded\gdef\starttexdefinition%
- {\bgroup%
- \obeylines%
- \syst_helpers_start_tex_definition}
-
-\gdef\syst_helpers_start_tex_definition#1
- {\catcode\endoflineasciicode\ignorecatcode%
- \clf_texdefinition_one{#1}}
-
-\gdef\dostarttexdefinition#1\stoptexdefinition%
- {\egroup%
- \clf_texdefinition_two{#1}}
-
-\egroup
-
-% \unexpanded\def\texdefinition#1{\csname\ifcsname#1\endcsname#1\else donothing\fi\endcsname} % todo: a nop cs: char 0 or some corenamespace
-
-\unexpanded\def\texdefinition#1{\begincsname#1\endcsname}
-
-% This is a first variant, more might be added:
-
-\unexpanded\def\starttexcode{\unprotect}
-\unexpanded\def\stoptexcode {\protect}
-
-%D \macros
-%D {newcounter,
-%D increment,decrement}
-%D
-%D Unfortunately the number of \COUNTERS\ in \TEX\ is limited, but fortunately we
-%D can store numbers in a macro. We can increment such pseudo \COUNTERS\ with \type
-%D {\increment}.
-%D
-%D \starttyping
-%D \increment(\counter,20)
-%D \increment(\counter,-4)
-%D \increment(\counter)
-%D \increment\counter
-%D \stoptyping
-%D
-%D After this sequence of commands, the value of \type {\counter} is 20, 16, 17
-%D and~18. Of course there is also the complementary command \type {\decrement}.
-%D
-%D Global assignments are possible too, using \type{\doglobal}:
-%D
-%D \starttyping
-%D \doglobal\increment\counter
-%D \stoptyping
-%D
-%D When \type {\counter} is undefined, it's value is initialized at~0. It is
-%D nevertheless better to define a \COUNTER\ explicitly. One reason could be that
-%D the \COUNTER\ can be part of a test with \type {\ifnum} and this conditional does
-%D not accept undefined macro's. The \COUNTER\ in our example can for instance be
-%D defined with:
-%D
-%D \starttyping
-%D \newcounter\counter
-%D \stoptyping
-%D
-%D The command \type {\newcounter} must not be confused with \type {\newcount}! Of
-%D course this mechanism is much slower than using \TEX's \COUNTERS\ directly. In
-%D practice \COUNTERS\ (and therefore our pseudo counters too) are seldom the
-%D bottleneck in the processing of a text. Apart from some other incompatilities we
-%D want to mention a pitfal when using \type {\ifnum}.
-%D
-%D \starttyping
-%D \ifnum\normalcounter=\pseudocounter \doif \else \doelse \fi
-%D \ifnum\pseudocounter=\normalcounter \doif \else \doelse \fi
-%D \stoptyping
-%D
-%D In the first test, \TEX\ continues it's search for the second number after
-%D reading \type {\pseudocounter}, while in the second test, it stops reading after
-%D having encountered a real one. Tests like the first one therefore can give
-%D unexpected results, for instance execution of \type {\doif} even if both numbers
-%D are unequal.
-
-\def\zerocountervalue{0}
-
-\unexpanded\def\newcounter#1%
- {\dodoglobal\let#1\zerocountervalue}
-
-%D Nowadays we don't mind a few more tokens if we can gain a bit of speed.
-
-\def\syst_helpers_do_increment#1{\dodoglobal\edef#1{\the\numexpr\ifdefined#1\ifx#1\relax\else#1\fi\fi+\plusone \relax}}
-\def\syst_helpers_do_decrement#1{\dodoglobal\edef#1{\the\numexpr\ifdefined#1\ifx#1\relax\else#1\fi\fi+\minusone\relax}}
-
-\def\syst_helpers_do_do_do_increment#1,#2){\dodoglobal\edef#1{\the\numexpr\ifdefined#1\ifx#1\relax\else#1\fi\fi+#2\relax}}
-\def\syst_helpers_do_do_do_decrement#1,#2){\dodoglobal\edef#1{\the\numexpr\ifdefined#1\ifx#1\relax\else#1\fi\fi-#2\relax}}
-
-\def\syst_helpers_do_do_increment(#1%
- {\def\m_syst_action_yes{\syst_helpers_do_do_do_increment#1}%
- \def\m_syst_action_nop{\syst_helpers_do_do_do_increment#1,\plusone}%
- \doifelsenextcharcs,\m_syst_action_yes\m_syst_action_nop}
-
-\def\syst_helpers_do_do_decrement(#1%
- {\def\m_syst_action_yes{\syst_helpers_do_do_do_decrement#1}%
- \def\m_syst_action_nop{\syst_helpers_do_do_do_decrement#1,\plusone}%
- \doifelsenextcharcs,\m_syst_action_yes\m_syst_action_nop}
-
-\unexpanded\def\increment{\doifelsenextcharcs(\syst_helpers_do_do_increment\syst_helpers_do_increment}
-\unexpanded\def\decrement{\doifelsenextcharcs(\syst_helpers_do_do_decrement\syst_helpers_do_decrement}
-
-\unexpanded\def\fastincrement#1{\dodoglobal\edef#1{\the\numexpr#1+\plusone \relax}}
-\unexpanded\def\fastdecrement#1{\dodoglobal\edef#1{\the\numexpr#1+\minusone\relax}}
-
-\unexpanded\def\incrementvalue#1{\expandafter\increment\csname#1\endcsname}
-\unexpanded\def\decrementvalue#1{\expandafter\decrement\csname#1\endcsname}
-
-%D \macros
-%D {newsignal}
-%D
-%D When writing advanced macros, we cannot do without signaling. A signal is a small
-%D (invisible) kern or penalty that signals the next macro that something just
-%D happened. This macro can take any action depending on the previous signal.
-%D Signals must be unique and the next macro takes care of that.
-%D
-%D \starttyping
-%D \newsignal\somesignal
-%D \stoptyping
-%D
-%D Signals old dimensions and can be used in skips, kerns and tests like \type
-%D {\ifdim}.
-
-\newdimen\maximumsignal % step is about 0.00025pt
-
-\unexpanded\def\newsignal#1%
- {\ifdefined#1\else
- \advance\maximumsignal 2\scaledpoint % to be save in rounding
- \edef#1{\the\maximumsignal}%
- \fi}
-
-%D \macros
-%D {strippedcsname}
-%D
-%D The next macro can be very useful when using \type {\csname} like in:
-%D
-%D \starttyping
-%D \csname if\strippedcsname\something\endcsname
-%D \stoptyping
-
-\let\checkedstrippedcsname\csstring
-
-%D \macros
-%D {savenormalmeaning}
-%D
-%D We will use this one in:
-
-\unexpanded\def\savenormalmeaning#1%
- {\ifcsname normal\csstring#1\endcsname \else
- \expandafter\let\csname normal\csstring#1\endcsname#1%
- \fi}
-
-%D \macros
-%D {dorecurse,recurselevel,recursedepth,
-%D dostepwiserecurse}
-%D
-%D \TEX\ does not offer us powerfull for||loop mechanisms. On the other hand its
-%D recursion engine is quite unique. We therefore identify the for||looping macros
-%D by this method. The most simple alternative is the one that only needs a number.
-%D
-%D \starttyping
-%D \dorecurse {n} {whatever we want}
-%D \stoptyping
-%D
-%D This macro can be nested without problems and therefore be used in situations
-%D where \PLAIN\ \TEX's \type {\loop} macro ungracefully fails. The current value of
-%D the counter is available in \type {\recurselevel}, before as well as after the
-%D \typ {whatever we wat} stuff.
-%D
-%D \starttyping
-%D \dorecurse % inner loop
-%D {10}
-%D {\recurselevel: % outer value
-%D \dorecurse % inner loop
-%D {\recurselevel} % outer value
-%D {\recurselevel} % inner value
-%D \dorecurse % inner loop
-%D {\recurselevel} % outer value
-%D {\recurselevel} % inner value
-%D \endgraf}
-%D \stoptyping
-%D
-%D In this example the first, second and fourth \type {\recurselevel} concern the
-%D outer loop, while the third and fifth one concern the inner loop. The depth of
-%D the nesting is available for inspection in \type {\recursedepth}.
-%D
-%D Both \type {\recurselevel} and \type {\recursedepth} are macros. The real
-%D \COUNTERS\ are hidden from the user because we don't want any interference.
-
-\newcount\outerrecurse
-\newcount\innerrecurse
-
-\def\recursedepth{\the\outerrecurse}
-\def\recurselevel{0}
-
-\let\syst_helpers_stepwise_next\relax
-
-\installsystemnamespace{recurseindex}
-\installsystemnamespace{recurseaction}
-
-\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
- {\global\advance\outerrecurse \plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname{#4}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \ifnum#3>\zerocount\relax
- \ifnum#2<#1\relax
- \let\syst_helpers_stepwise_next\syst_helpers_stepwise_exit
- \else
- \let\syst_helpers_stepwise_next\syst_helpers_stepwise_recurse
- \fi
- \orelse\ifnum#3<\zerocount\relax
- \ifnum#1<#2\relax
- \let\syst_helpers_stepwise_next\syst_helpers_stepwise_exit
- \else
- \let\syst_helpers_stepwise_next\syst_helpers_stepwise_reverse
- \fi
- \else
- \let\syst_helpers_stepwise_next\syst_helpers_stepwise_exit
- \fi\normalexpanded{\syst_helpers_stepwise_next{\number#1}{\number#2}{\number#3}}}
-
-\unexpanded\def\syst_helpers_stepwise_recurse#1#2#3% from to step
- {\ifnum#1>#2\relax
- \expandafter\syst_helpers_stepwise_recurse_nop
- \else
- \def\recurselevel{#1}%
- \doubleexpandafter\syst_helpers_stepwise_recurse_yes\expandafter
- \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}}
-
-\unexpanded\def\syst_helpers_recurse_content
- {\csname\??recurseaction\the\outerrecurse\endcsname}
-
-\unexpanded\def\syst_helpers_stepwise_recurse_yes
- {\syst_helpers_recurse_content
- \syst_helpers_stepwise_recurse}
-
-\unexpanded\def\syst_helpers_stepwise_reverse#1#2#3% from to step
- {\ifnum#1<#2\relax
- \expandafter\syst_helpers_stepwise_recurse_nop
- \else
- \def\recurselevel{#1}%
- \innerrecurse#1\relax
- \advance\innerrecurse#3\relax
- \doubleexpandafter\syst_helpers_stepwise_reverse_yes\expandafter
- \fi\expandafter{\the\innerrecurse}{#2}{#3}}
-
-\unexpanded\def\syst_helpers_stepwise_reverse_yes
- {\syst_helpers_recurse_content
- \syst_helpers_stepwise_reverse}
-
-\unexpanded\def\syst_helpers_stepwise_exit
- {\syst_helpers_stepwise_recurse_nop\relax}
-
-\unexpanded\def\syst_helpers_stepwise_recurse_nop#1#2#3#4%
- {\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
- \global\advance\outerrecurse\minusone}
-
-\unexpanded\def\dorecurse#1%
- {\dostepwiserecurse\plusone{#1}\plusone}
-
-\def\doexpandedrecurse#1#2% user macro (also was \doxprecurse)
- {\ifnum#1>\zerocount
- #2\expandafter\doexpandedrecurse\expandafter{\the\numexpr#1-\plusone\relax}{#2}%
- \fi}
-
-%D As we can see here, the simple command \type{\dorecurse} is a special case of the
-%D more general:
-%D
-%D \starttyping
-%D \dostepwiserecurse {from} {to} {step} {action}
-%D \stoptyping
-%D
-%D This commands accepts positive and negative steps. Illegal values are handles as
-%D good as possible and the macro accepts numbers and \COUNTERS.
-%D
-%D \starttyping
-%D \dostepwiserecurse {1} {10} {2} {...}
-%D \dostepwiserecurse {10} {1} {-2} {...}
-%D \stoptyping
-%D
-%D Because the simple case is used often, we implement it more efficiently:
-
-\unexpanded\def\dorecurse#1%
- {\ifcase#1\relax
- \expandafter\gobbletwoarguments
- \or
- \expandafter\syst_helpers_recurse_y
- \else
- \expandafter\syst_helpers_recurse_x
- \fi{#1}}
-
-\unexpanded\def\syst_helpers_recurse_x#1#2%
- {\global\advance\outerrecurse \plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname{#2}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \expandafter\syst_helpers_recurse_indeed\expandafter1\expandafter{\number#1}}
-
-\unexpanded\def\syst_helpers_recurse_y#1#2%
- {\global\advance\outerrecurse \plusone
- \expandafter\glet\csname\??recurseindex\the\outerrecurse\endcsname\recurselevel
- \let\recurselevel\!!plusone
- #2%
- \expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
- \global\advance\outerrecurse \minusone}
-
-\unexpanded\def\syst_helpers_recurse_indeed#1#2% from to
- {\ifnum#1>#2\relax
- \expandafter\syst_helpers_recurse_indeed_nop
- \else
- \def\recurselevel{#1}%
- \doubleexpandafter\syst_helpers_recurse_indeed_yes
- \fi\expandafter{\the\numexpr\recurselevel+\plusone\relax}{#2}}
-
-\unexpanded\def\syst_helpers_recurse_indeed#1#2% from to
- {\ifnum#1>#2\relax
- \expandafter\syst_helpers_recurse_indeed_nop
- \else
- \def\recurselevel{#1}%
- \innerrecurse#1\advance\innerrecurse\plusone
- \doubleexpandafter\syst_helpers_recurse_indeed_yes
- \fi\expandafter{\the\innerrecurse}{#2}}
-
-\unexpanded\def\syst_helpers_recurse_indeed_yes
- {\syst_helpers_recurse_content
- \syst_helpers_recurse_indeed}
-
-\unexpanded\def\syst_helpers_recurse_indeed_nop#1#2#3%
- {\expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
- \global\advance\outerrecurse \minusone }
-
-%D \macros
-%D {dowith}
-%D
-%D Here's a loop over whatever is in a list:
-%D
-%D \starttyping
-%D \dowith{a,b,c}{[#1]}
-%D \stoptyping
-
-\unexpanded\def\dowith#1#2%
- {\def\syst_helpers_with##1{#2}%
- \normalexpanded{\processcommalist[#1]}\syst_helpers_with}
-
-%D \macros
-%D {doloop,exitloop}
-%D
-%D Sometimes loops are not determined by counters, but by (a combinations of)
-%D conditions. We therefore implement a straightforward loop, which can only be left
-%D when we explictly exit it. Nesting is supported. First we present a more
-%D extensive alternative.
-%D
-%D \starttyping
-%D \doloop
-%D {Some kind of typesetting punishment \par
-%D \ifnum\pageno>100 \exitloop \fi}
-%D \stoptyping
-%D
-%D When needed, one can call for \type {\looplevel} and \type {\loopdepth}.
-
-\let\endofloop\donothing % maybe \syst_helpers_loop_end
-
-\unexpanded\def\doloop#1%
- {\global\advance\outerrecurse \plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname{#1}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \let\endofloop\syst_helpers_loop
- \syst_helpers_loop1} % no \plusone else \recurselevel wrong
-
-\unexpanded\def\syst_helpers_loop#1%
- {\def\recurselevel{#1}%
- \expandafter\syst_helpers_loop_yes\expandafter{\the\numexpr\recurselevel+\plusone\relax}}
-
-\unexpanded\def\syst_helpers_loop_yes
- {\syst_helpers_recurse_content
- \endofloop}
-
-\unexpanded\def\syst_helpers_loop_nop#1%
- {\let\endofloop\syst_helpers_loop % new, permits nested \doloop's
- \expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
- \global\advance\outerrecurse\minusone}
-
-\unexpanded\def\exitloop % \exitloop quits at end
- {\let\endofloop\syst_helpers_loop_nop}
-
-\unexpanded\def\exitloopnow#1\endofloop % \exitloopnow quits directly
- {\syst_helpers_loop_nop}
-
-%D The loop is executed at least once, so beware of situations
-%D like:
-%D
-%D \starttyping
-%D \doloop {\exitloop some commands}
-%D \stoptyping
-%D
-%D It's just a matter of putting the text into the \type {\if} statement that should
-%D be there anyway, like in:
-%D
-%D \starttyping
-%D \doloop {\ifwhatever \exitloop \else some commands\fi}
-%D \stoptyping
-%D
-%D You can also quit a loop immediately, by using \type
-%D {\exitloopnow} instead. Beware, this is more sensitive
-%D for conditional errors.
-
-%D Krzysztof Leszczynski suggested to provide access to the level by means of a
-%D \type {#1}. I decided to pass the more frequently used level as \type {#1} and
-%D the less favoured depth as \type {#2}. The intended usage is:
-%D
-%D \starttyping
-%D \dorecurse{3}{\definesymbol[test-#1][xx-#1]}
-%D
-%D \def\test{\dorecurse{3}{\definesymbol[test-##1][xx-##1]}} \test
-%D
-%D \symbol[test-1]\quad\symbol[test-2]\quad\symbol[test-3]
-%D \stoptyping
-%D
-%D Since the hashed arguments are expanded, we don't need tricky expansion here.
-%D
-%D \starttyping
-%D \dorecurse{3}{\expanded{\definesymbol[test-\recurselevel][xx-\recurselevel]}}
-%D \stoptyping
-
-\def\syst_helpers_recurse_content
- {\csname\??recurseaction\the\outerrecurse\expandafter\expandafter\expandafter\endcsname
- \expandafter\expandafter\expandafter{\expandafter\recurselevel\expandafter}\expandafter{\the\outerrecurse}}
-
-\unexpanded\def\syst_helpers_recurse_x#1#2%
- {\global\advance\outerrecurse \plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#2}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \expandafter\syst_helpers_recurse_indeed\expandafter1\expandafter{\number#1}}
-
-\unexpanded\def\syst_helpers_recurse_y#1#2%
- {\global\advance\outerrecurse \plusone
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \let\recurselevel\!!plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#2}%
- \syst_helpers_recurse_content
- \expandafter\let\expandafter\recurselevel\csname\??recurseindex\the\outerrecurse\endcsname
- \global\advance\outerrecurse \minusone}
-
-\unexpanded\def\doloop#1%
- {\global\advance\outerrecurse \plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#1}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \let\endofloop\syst_helpers_loop
- \syst_helpers_loop1} % no \plusone else \recurselevel wrong
-
-\installsystemnamespace{recursestepwise}
-
-\unexpanded\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
- {\global\advance\outerrecurse \plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1##2{#4}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recurselevel
- \csname\??recursestepwise
- % we need the x in order to avoid the \relax that tex adds
- \ifnum#3>\zerocount
- \ifnum#2<#1x\else d\fi
- \orelse\ifnum#3<\zerocount
- \ifnum#1<#2x\else r\fi
- \fi
- \expandafter\endcsname\normalexpanded{{\number#1}{\number#2}{\number#3}}}
- % \expandafter\endcsname\expandafter{\number#1\expandafter}\expandafter{\number#2\expandafter}\expandafter{\number#3}}
-
-\letvalue{\??recursestepwise x}\syst_helpers_stepwise_exit
-\letvalue{\??recursestepwise d}\syst_helpers_stepwise_recurse
-\letvalue{\??recursestepwise r}\syst_helpers_stepwise_reverse
-
-\newcount\fastloopindex
-\newcount\fastloopfinal
-
-\let\m_syst_helpers_fast_loop_cs\relax
-
-\unexpanded\def\dofastloopcs#1%
- {\fastloopfinal#1\relax
- \ifcase\fastloopfinal
- \expandafter\gobbleoneargument
- \else
- \expandafter\syst_helpers_fast_loop_cs
- \fi}
-
-\unexpanded\def\syst_helpers_fast_loop_cs#1%
- {\let\m_syst_helpers_fast_loop_cs#1%
- \fastloopindex\plusone
- \syst_helpers_fast_loop_cs_step}
-
-\unexpanded\def\syst_helpers_fast_loop_cs_step
- {\ifnum\fastloopindex>\fastloopfinal
- \let\m_syst_helpers_fast_loop_cs\relax
- \else
- \m_syst_helpers_fast_loop_cs
- \advance\fastloopindex\plusone
- \expandafter\syst_helpers_fast_loop_cs_step
- \fi}
-
-% Helper:
-
-\unexpanded\def\resetrecurselevel{\let\recurselevel\!!zerocount}
-
-\let\recurselevel\!!zerocount
-
-% \appendtoks \resetrecurselevel \to \everydump
-
-%D \macros
-%D {doloopoverlist}
-%D
-%D \starttyping
-%D \doloopoverlist {red,green,blue} {
-%D \setuppalet[\recursestring]
-%D \doloopoverlist {light,normal,dark} {
-%D \blackrule[color=\recursestring,width=20cm,height=2cm,depth=0cm]\par
-%D }
-%D }
-%D \stoptyping
-%D
-%D or:
-%D
-%D \starttyping
-%D \doloopoverlist {red,green,blue} {
-%D \setuppalet[#1]
-%D \doloopoverlist {light,normal,dark} {
-%D \blackrule[color=##1,width=20cm,height=2cm,depth=0cm]\par
-%D }
-%D }
-%D \stoptyping
-
-\unexpanded\def\doloopoverlist#1#2%
- {\global\advance\outerrecurse\plusone
- \expandafter\gdef\csname\??recurseaction\the\outerrecurse\endcsname##1{\edef\recursestring{##1}#2}%
- \expandafter\glet\csname\??recurseindex \the\outerrecurse\endcsname\recursestring
- \normalexpanded{\processcommalist[#1]{\expandafter\noexpand\csname\??recurseaction\the\outerrecurse\endcsname}}%
- \expandafter\let\expandafter\recursestring\csname\??recurseindex\the\outerrecurse\endcsname
- \global\advance\outerrecurse\minusone}
-
-%D \macros
-%D {newevery,everyline,EveryLine,EveryPar}
-%D
-%D Lets skip to something quite different. It's common use to use \type {\everypar}
-%D for special purposes. In \CONTEXT\ we use this primitive for locating sidefloats.
-%D This means that when user assignments to \type {\everypar} can interfere with
-%D those of the package. We therefore introduce \type {\EveryPar}.
-%D
-%D The same goes for \type {\EveryLine}. Because \TEX\ offers no \type {\everyline}
-%D primitive, we have to call for \type {\everyline} when we are working on a line
-%D by line basis. Just by calling \type {\EveryPar{}} and \type {\EveryLine{}} we
-%D restore the old situation.
-
-% \dorecurse{2}{
-% \expanded{\everypar{before \recurselevel\space}}
-% \EveryPar{x } [before \recurselevel\space x] \par
-% \EveryPar{y } [before \recurselevel\space y] \par
-% \EveryPar{} [before \recurselevel] \par
-% \EveryPar{x } \EveryPar{y } \EveryPar{} [before \recurselevel] \par
-% \EveryPar{y } \everypar{before } [before] \par
-% }
-
-\installsystemnamespace{extraevery}
-
-\unexpanded\def\newevery#1#2%
- {\ifx#1\everypar\else\newtoks#1\fi% we test for redefinition elsewhere
- \ifx#2\relax\orelse\ifdefined#2\else
- \expandafter\newtoks\csname\??extraevery\csstring#1\endcsname
- \edef#2{\syst_helpers_every#1\csname\??extraevery\csstring#1\endcsname}%
- \fi}
-
-\unexpanded\def\syst_helpers_every#1#2%
- {\removetoks\the#2\from#1%
- \appendtoks\the#2\to #1%
- #2}
-
-%D This one permits definitions like:
-
-\newevery \everypar \EveryPar % we get a warning which is ok
-\newevery \everyline \EveryLine
-
-%D and how about:
-
-\newtoks \neverypar
-
-\unexpanded\def\forgeteverypar
- {\everypar{\the\neverypar}}
-
-%D Which we're going to use indeed! When the second argument equals \type {\relax},
-%D the first token list is created unless it is already defined.
-%D
-%D Technically spoken we could have used the method we are going to present in the
-%D visual debugger. First we save the primitive \type{\everypar}:
-%D
-%D \starttyping
-%D \let\normaleverypar=\everypar
-%D \stoptyping
-%D
-%D Next we allocate a \TOKENLIST\ named \type{\everypar}, which means that
-%D \type{\everypar} is no longer a primitive but something like \type{\toks44}.
-%D
-%D \starttyping
-%D \newtoks\everypar
-%D \stoptyping
-%D
-%D Because \TEX\ now executes \type{\normaleverypar} instead of \type{\everypar}, we
-%D are ready to assign some tokens to this internally known and used \TOKENLIST.
-%D
-%D \starttyping
-%D \normaleverypar={all the things the system wants to do \the\everypar}
-%D \stoptyping
-%D
-%D Where the user can provide his own tokens to be expanded every time he expects
-%D them to expand.
-%D
-%D \starttyping
-%D \everypar={something the user wants to do}
-%D \stoptyping
-%D
-%D We don't use this method because it undoubtly leads to confusing situations,
-%D especially when other packages are used, but it's this kind of tricks that make
-%D \TEX\ so powerful.
-
-%D \macros
-%D {convertargument,convertcommand,convertvalue}
-%D
-%D Some persistent experimenting led us to the next macro. This macro converts a
-%D parameter or an expanded macro to it's textual meaning.
-%D
-%D \starttyping
-%D \convertargument ... \to \command
-%D \stoptyping
-%D
-%D For example,
-%D
-%D \starttyping
-%D \convertargument{one \two \three{four}}\to\ascii
-%D \stoptyping
-%D
-%D The resulting macro \type{\ascii} can be written to a file or the terminal
-%D without problems. In \CONTEXT\ we use this macro for generating registers and
-%D tables of contents.
-%D
-%D The second conversion alternative accepts a command:
-%D
-%D \starttyping
-%D \convertcommand\command\to\ascii
-%D \stoptyping
-%D
-%D Both commands accept the prefix \type{\doglobal} for global assignments.
-
-\unexpanded\def\convertvalue#1\to
- {\expandafter\convertcommand\csname#1\endcsname\to}
-
-\unexpanded\def\defconvertedvalue#1#2% less sensitive for \to
- {\expandafter\defconvertedcommand\expandafter#1\csname#2\endcsname}
-
-%D \macros
-%D {doifassignmentelse}
-%D
-%D A lot of \CONTEXT\ commands take optional arguments, for instance:
-%D
-%D \starttyping
-%D \dothisorthat[alfa,beta]
-%D \dothisorthat[first=foo,second=bar]
-%D \dothisorthat[alfa,beta][first=foo,second=bar]
-%D \stoptyping
-%D
-%D Although a combined solution is possible, we prefer a seperation. The next
-%D command takes care of propper handling of such multi||faced commands.
-%D
-%D \starttyping
-%D \doifassignmentelse {...} {then ...} {else ...}
-%D \stoptyping
-
-\def\syst_helpers_check_if_assignment_else#1=#2#3^^^^0004{\if#2^^^^0003}%
-\def\syst_helpers_check_else_assignment_if#1=#2#3^^^^0004{\unless\if#2^^^^0003}%
-
-\unexpanded\def\doifelseassignment#1%
- {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004%
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\unexpanded\def\doifelseassignmentcs#1#2#3%
- {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004%
- \expandafter#3%
- \else
- \expandafter#2%
- \fi}
-
-\let\doifassignmentelse \doifelseassignment
-\let\doifassignmentelsecs\doifelseassignmentcs
-
-\newif\ifassignment
-
-\unexpanded\def\docheckassignment#1%
- {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004%
- \assignmentfalse
- \else
- \assignmenttrue
- \fi}
-
-%D These can be used for cases where we want less tracing noise.
-
-\unexpanded\def\validassignment#1%
- {\expandafter\syst_helpers_check_else_assignment_if\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
-
-\unexpanded\def\novalidassignment#1%
- {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
-
-%D In \ETEX\ we can use \type {\detokenize} and gain some speed, but in general far
-%D less that 1\% for \type {\convertargument} and nil for \type {\convertcommand}.
-%D This macro is more robust than the pure \TEX\ one, something I found out when
-%D primitives like \type {\jobname} were fed (or something undefined).
-
-\unexpanded\def\convertargument#1\to#2{\dodoglobal\edef#2{\detokenize{#1}}}
-\unexpanded\def\convertcommand #1\to#2{\dodoglobal\edef#2{\expandafter\detokenize\expandafter{#1}}} % hm, only second is also ok
-
-\unexpanded\def\defconvertedargument #1#2{\edef#1{\detokenize{#2}}}
-\unexpanded\def\defconvertedcommand #1#2{\edef#1{\detokenize\expandafter{#2}}}
-\unexpanded\def\edefconvertedargument#1#2{\edef#1{#2}%
- \edef#1{\detokenize\expandafter{#1}}}
-\unexpanded\def\gdefconvertedargument#1#2{\xdef#1{\detokenize{#2}}}
-\unexpanded\def\gdefconvertedcommand #1#2{\xdef#1{\detokenize\expandafter{#2}}}
-\unexpanded\def\xdefconvertedargument#1#2{\xdef#1{#2}%
- \xdef#1{\detokenize\expandafter{#1}}}
-
-%D When you try to convert a primitive command, you'll find out that the \ETEX\
-%D method fails on for instance \type {\jobname} in the sense that it returns the
-%D filename instead of just \type {\jobname}. So far this does not give real
-%D problems.
-
-%D This is typically a macro that one comes to after reading the \TEX book
-%D carefully. Even then, the definite solution was found after rereading the \TEX
-%D book. The first implementation was:
-%D
-%D \starttyping
-%D \def\doconvertargument#1->#2\\\\{#2}
-%D \stoptyping
-%D
-%D The \type {-}, the delimiter \type {\\\\} and the the second argument are
-%D completely redundant.
-
-%D \macros
-%D {showvalue}
-%D
-%D Ahandy macro, for testing purposes only:
-
-\unexpanded\def\showvalue#1%
- {\ifcsname#1\endcsname
- \expandafter\show\csname#1\endcsname
- \else
- \show\undefined
- \fi}
-
-%D \macros
-%D {doifmeaningelse}
-%D
-%D We can use both commands in testing, but alas, not all meanings expand to
-%D something \type {->}. This is no problem in the \ETEX\ implementation, but since
-%D we want compatibility, we need:
-%D
-%D \starttyping
-%D \doifmeaningelse {\next} {\something} {true} {false}
-%D \stoptyping
-%D
-%D Watch the one level expansion of the second argument.
-
-\unexpanded\def\doifelsemeaning#1#2%
- {\edef\m_syst_string_one{\normalmeaning#1}%
- \def \m_syst_string_two{#2}%
- \edef\m_syst_string_two{\normalmeaning\m_syst_string_two}%
- \ifx\m_syst_string_one\m_syst_string_two
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifmeaningelse\doifelsemeaning
-
-%D \macros
-%D {doifsamestringselse,doifsamestring,doifnotsamestring}
-%D
-%D The next comparison macro converts the arguments into expanded strings. This
-%D command can be used to compare for instance \type {\jobname} with a name stored
-%D in a macro.
-%D
-%D \starttyping
-%D \doifelse {\jobname}{oeps}{YES}{NO}
-%D \doifsamestringelse{\jobname}{oeps}{YES}{NO}
-%D \stoptyping
-
-\def\syst_helpers_if_samestring_else#1#2#3#4%
- {\edef\m_syst_string_one{\detokenize\expandafter{\normalexpanded{#3}}}%
- \edef\m_syst_string_two{\detokenize\expandafter{\normalexpanded{#4}}}%
- \ifx\m_syst_string_one\m_syst_string_two\expandafter#1\else\expandafter#2\fi}
-
-\unexpanded\def\doifelsesamestring{\syst_helpers_if_samestring_else\firstoftwoarguments\secondoftwoarguments}
-\unexpanded\def\doifsamestring {\syst_helpers_if_samestring_else\firstofoneargument \gobbleoneargument }
-\unexpanded\def\doifnotsamestring {\syst_helpers_if_samestring_else\gobbleoneargument \firstofoneargument }
-
-\let\doifsamestringelse\doifelsesamestring
-
-%D \macros
-%D {ConvertToConstant,ConvertConstantAfter}
-%D
-%D When comparing arguments with a constant, we can get into trouble when this
-%D argument consists of tricky expandable commands. One solution for this is
-%D converting the argument to a string of unexpandable characters. To make
-%D comparison possible, we have to convert the constant too.
-%D
-%D \starttyping
-%D \ConvertToConstant\doifelse {...} {...} {then ...} {else ...}
-%D \stoptyping
-%D
-%D This construction is only needed when the first argument can give troubles.
-%D Misuse can slow down processing.
-%D
-%D \starttyping
-%D \ConvertToConstant\doifelse{\c!alfa} {\c!alfa}{...}{...}
-%D \ConvertToConstant\doifelse{alfa} {\c!alfa}{...}{...}
-%D \ConvertToConstant\doifelse{alfa} {alfa} {...}{...}
-%D \ConvertToConstant\doifelse{alfa \alfa test}{\c!alfa}{...}{...}
-%D \stoptyping
-%D
-%D In examples~2 and~3 both arguments equal, in~1 and~4 they differ.
-
-\unexpanded\def\ConvertToConstant#1#2#3%
- {\edef\m_syst_string_one{\expandafter\detokenize\expandafter{#2}}%
- \edef\m_syst_string_two{\expandafter\detokenize\expandafter{#3}}%
- #1{\m_syst_string_one}{\m_syst_string_two}}
-
-%D When the argument \type{#1} consists of commands, we had better use
-%D
-%D \starttyping
-%D \ConvertConstantAfter\processaction[#1][...]
-%D \ConvertConstantAfter\doifelse{#1}{\v!something}{}{}
-%D \stoptyping
-%D
-%D This commands accepts things like:
-%D
-%D \starttyping
-%D \v!constant
-%D constant
-%D \hbox to \hsize{\rubish}
-%D \stoptyping
-%D
-%D As we will see in the core modules, this macro permits constructions like:
-%D
-%D \starttyping
-%D \setupfootertexts[...][...]
-%D \setupfootertexts[margin][...][...]
-%D \setupfootertexts[\v!margin][...][...]
-%D \stoptyping
-%D
-%D where \type {...} can be anything legally \TEX.
-
-\unexpanded\def\CheckConstantAfter#1#2%
- {\expandafter\convertargument\v!prefix!\to\ascii
- \convertargument#1\to#2\relax
- \doifelseinstring\ascii{#2}
- {\expandafter\convertargument#1\to#2}
- {}}
-
-\unexpanded\def\ConvertConstantAfter#1#2#3%
- {\CheckConstantAfter{#2}\asciia
- \CheckConstantAfter{#3}\asciib
- #1{\asciia}{\asciib}}
-
-%D \macros
-%D {assignifempty}
-%D
-%D We can assign a default value to an empty macro using:
-%D
-%D \starttyping
-%D \assignifempty \macros {default value}
-%D \stoptyping
-%D
-%D We don't explicitly test if the macro is defined.
-
-\unexpanded\def\assignifempty#1#2% can be sped up
- {\doifsomething{#1}{\def#1{#2}}} % {\doifnot{#1}{}{\def#1{#2}}}
-
-%D \macros
-%D {gobbleuntil,grabuntil,gobbleuntilrelax,
-%D processbetween,processuntil}
-%D
-%D In \TEX\ gobbling usually stand for skipping arguments, so here are our gobbling
-%D macros.
-%D
-%D In \CONTEXT\ we use a lot of \type {\start}||\type {\stop} like constructions.
-%D Sometimes, the \type {\stop} is used as a hard coded delimiter like in: %D
-%D \starttyping
-%D \unexpanded\def\startcommand#1\stopcommand%
-%D {... #1 ...}
-%D \stoptyping
-%D
-%D In many cases the \type {\start}||\type {\stop} pair is defined at format
-%D generation time or during a job. This means that we cannot hardcode the \type
-%D {\stop} criterium. Only after completely understanding \type {\csname} and \type
-%D {\expandafter} I was able to to implement a solution, starting with:
-%D
-%D \starttyping
-%D \grabuntil{stop}\command
-%D \stoptyping
-%D
-%D This commands executes, after having encountered \type {\stop} the command \type
-%D {\command}. This command receives as argument the text preceding the \type
-%D {\stop}. This means that:
-%D
-%D \starttyping
-%D \unexpanded\def\starthello%
-%D {\grabuntil{stophello}\message}
-%D
-%D \starthello Hello world!\stophello
-%D \stoptyping
-%D
-%D results in: \type{\message{Hello world!}}.
-
-\let\syst_helpers_grab_indeed\relax
-
-\unexpanded\def\syst_helpers_grab#1#2%
- {\def\syst_helpers_grab_indeed##1#1{#2{##1}}\syst_helpers_grab_indeed}
-
-\unexpanded\def\grabuntil#1%
- {\expandafter\syst_helpers_grab\expandafter{\csname#1\endcsname}}
-
-%D The next command build on this mechanism:
-%D
-%D \starttyping
-%D \processbetween{string}\command
-%D \stoptyping
-%D
-%D Here:
-%D
-%D \starttyping
-%D \processbetween{hello}\message
-%D \starthello Hello again!\stophello
-%D \stoptyping
-%D
-%D leads to: \type{\message{Hello again!}}. The command
-%D
-%D \starttyping
-%D \gobbleuntil{sequence}
-%D \stoptyping
-%D
-%D is related to these commands. This one simply throws away
-%D everything preceding \type{\command}.
-
-\let\syst_helpers_gobble_indeed\relax
-
-\unexpanded\def\processbetween#1#2%
- {\setvalue{\s!start#1}{\grabuntil{\s!stop#1}{#2}}}
-
-\unexpanded\def\gobbleuntil#1%
- {\def\syst_helpers_gobble_indeed##1#1{}\syst_helpers_gobble_indeed}
-
-\unexpanded\def\gobbleuntilrelax#1\relax
- {}
-
-%D The next one simply expands the pickup up tokens.
-%D
-%D \starttyping
-%D \processuntil{sequence}
-%D \stoptyping
-
-\let\syst_helpers_until_indeed\relax
-
-\unexpanded\def\processuntil#1%
- {\def\syst_helpers_until_indeed##1#1{##1}\syst_helpers_until_indeed}
-
-%D \macros
-%D {groupedcommand}
-%D
-%D Commands often manipulate argument as in:
-%D
-%D \starttyping
-%D \def\doezomaarwat#1{....#1....}
-%D \stoptyping
-%D
-%D A disadvantage of this approach is that the tokens that form \type{#1} are fixed
-%D the the moment the argument is read in. Normally this is no problem, but for
-%D instance verbatim environments adapt the \CATCODES\ of characters and therefore
-%D are not always happy with already fixed tokens.
-%D
-%D Another problem arises when the argument is grouped not by \type {{}} but by
-%D \type {\bgroup} and \type {\egroup}. Such an argument fails, because the \type
-%D {\bgroup} is een as the argument (which is quite normal).
-%D
-%D The next macro offers a solution for both unwanted situations:
-%D
-%D \starttyping
-%D \groupedcommand {before} {after}
-%D \stoptyping
-%D
-%D Which can be used like:
-%D
-%D \starttyping
-%D \def\cite%
-%D {\groupedcommand{\rightquote\rightquote}{\leftquote\leftquote}}
-%D \stoptyping
-%D
-%D This command is equivalent to, but more 'robust' than:
-%D
-%D \starttyping
-%D \def\cite#1%
-%D {\rightquote\rightquote#1\leftquote\leftquote}
-%D \stoptyping
-%D
-%D \starttyping
-%D \def\rightword%
-%D {\groupedcommand{\hfill\hbox}{\parfillskip\zeropoint}}
-%D
-%D .......... \rightword{the right way}
-%D \stoptyping
-%D
-%D Here \TEX\ typesets \type {\bf the right way} unbreakable at the end of the line.
-%D The solution mentioned before does not work here. We also handle
-%D
-%D \starttyping
-%D to be \bold{bold} or not, that's the question
-%D \stoptyping
-%D
-%D and
-%D
-%D \starttyping
-%D to be {\bold bold} or not, that's the question
-%D \stoptyping
-%D
-%D This alternative checks for a \type {\bgroup} token first. The internal
-%D alternative does not accept the box handling mentioned before, but further
-%D nesting works all right. The extra \type {\bgroup}||\type {\egroup} is needed to
-%D keep \type {\m_syst_helpers_handle_group_after} both into sight and local.
-
-\let\m_syst_helpers_handle_group_after \relax
-\let\m_syst_helpers_handle_group_before\relax
-
-\unexpanded\def\syst_helpers_handle_group_nop
- {\ifnum\currentgrouptype=\semisimplegroupcode
- \expandafter\syst_helpers_handle_group_nop_a
- \else
- \expandafter\syst_helpers_handle_group_nop_b
- \fi}
-
-\def\syst_helpers_handle_group_nop_a
- {\begingroup
- \aftergroup\m_syst_helpers_handle_group_a
- \aftergroup\endgroup
- \m_syst_helpers_handle_group_b}
-
-\def\syst_helpers_handle_group_nop_b
- {\bgroup
- \aftergroup\m_syst_helpers_handle_group_a
- \aftergroup\egroup
- \m_syst_helpers_handle_group_b}
-
-\unexpanded\def\syst_helpers_handle_group_normal
- {\bgroup
- \afterassignment\m_syst_helpers_handle_group_normal_before
- \let\next=}
-
-\def\m_syst_helpers_handle_group_normal_before
- {\bgroup
- \m_syst_helpers_handle_group_b
- \bgroup
- \aftergroup\m_syst_helpers_handle_group_a
- \aftergroup\egroup
- \aftergroup\egroup}
-
-\unexpanded\def\syst_helpers_handle_group_simple% no inner group (so no kerning interference)
- {\bgroup
- \afterassignment\m_syst_helpers_handle_group_simple_before
- \let\next=}
-
-\def\m_syst_helpers_handle_group_simple_before
- {\bgroup
- \aftergroup\m_syst_helpers_handle_group_simple_after
- \m_syst_helpers_handle_group_b}
-
-\def\m_syst_helpers_handle_group_simple_after
- {\m_syst_helpers_handle_group_a
- \egroup}%
-
-\unexpanded\def\syst_helpers_handle_group_pickup% no inner group (so no kerning interference)
- {\bgroup
- \afterassignment\m_syst_helpers_handle_group_pickup_before
- \let\next=}
-
-\def\m_syst_helpers_handle_group_pickup_before
- {\bgroup
- \aftergroup\m_syst_helpers_handle_group_a
- \aftergroup\egroup
- \aftergroup\m_syst_helpers_handle_group_p
- \m_syst_helpers_handle_group_b}
-
-\unexpanded\def\syst_helpers_handle_group_nop_x
- {\ifnum\currentgrouptype=\semisimplegroupcode
- \begingroup
- \aftergroup\endgroup
- \else
- \bgroup
- \aftergroup\egroup
- \fi
- \m_syst_helpers_handle_group_b}
-
-\unexpanded\def\syst_helpers_handle_group_normal_x
- {\bgroup
- \afterassignment\m_syst_helpers_handle_group_normal_before_x
- \let\next=}
-
-\def\m_syst_helpers_handle_group_normal_before_x
- {\bgroup
- \m_syst_helpers_handle_group_b
- \bgroup
- \aftergroup\egroup
- \aftergroup\egroup}
-
-%D I considered it a nuisance that
-%D
-%D \starttyping
-%D \color[green]
-%D {as grass}
-%D \stoptyping
-%D
-%D was not interpreted as one would expect. This is due to the fact that \type
-%D {\futurelet} obeys blank spaces, and a line||ending token is treated as a blank
-%D space. So the final implementation became:
-
-\unexpanded\def\groupedcommand#1#2%
- {\def\m_syst_helpers_handle_group_b{#1}%
- \def\m_syst_helpers_handle_group_a{#2}%
- \futureexpandis\bgroup\syst_helpers_handle_group_normal\syst_helpers_handle_group_nop}
-
-\unexpanded\def\groupedcommandcs#1#2%
- {\let\m_syst_helpers_handle_group_b#1%
- \let\m_syst_helpers_handle_group_a#2%
- \futureexpandis\bgroup\syst_helpers_handle_group_normal\syst_helpers_handle_group_nop}
-
-\unexpanded\def\simplegroupedcommand#1#2%
- {\def\m_syst_helpers_handle_group_b{#1}%
- \def\m_syst_helpers_handle_group_a{#2}%
- \futureexpandis\bgroup\syst_helpers_handle_group_simple\syst_helpers_handle_group_nop}
-
-\unexpanded\def\pickupgroupedcommand#1#2#3%
- {\def\m_syst_helpers_handle_group_b{#1}%
- \def\m_syst_helpers_handle_group_a{#2}%
- \def\m_syst_helpers_handle_group_p{#3}%
- \futureexpandis\bgroup\syst_helpers_handle_group_pickup\syst_helpers_handle_group_nop}
-
-\unexpanded\def\triggergroupedcommand#1%
- {\def\m_syst_helpers_handle_group_b{#1}%
- \futureexpandis\bgroup\syst_helpers_handle_group_normal_x\syst_helpers_handle_group_nop_x}
-
-\unexpanded\def\triggergroupedcommandcs#1%
- {\let\m_syst_helpers_handle_group_b#1%
- \futureexpandis\bgroup\syst_helpers_handle_group_normal_x\syst_helpers_handle_group_nop_x}
-
-%D Users should be aware of the fact that grouping can interfere with ones paragraph
-%D settings that are executed after the paragraph is closed. One should therefore
-%D explictly close the paragraph with \type {\par}, else the settings will be
-%D forgotten and not applied. So it's:
-%D
-%D \starttyping
-%D \def\BoldRaggedCenter%
-%D {\groupedcommand{\raggedcenter\bf}{\par}}
-%D \stoptyping
-
-%D \macros
-%D {checkdefined}
-%D
-%D The bigger the system, the greater the change that user defined commands collide
-%D with those that are part of the system. The next macro gives a warning when a
-%D command is already defined. We considered blocking the definition, but this is
-%D not always what we want.
-%D
-%D \starttyping
-%D \checkdefined {category} {class} {command}
-%D \stoptyping
-%D
-%D The user is warned with the suggestion to use \type {CAPITALS}. This suggestion
-%D is feasible, because \CONTEXT only defines lowcased macros.
-
-\unexpanded\def\showdefinederror#1#2%
- {\writestatus\m!system{#1 #2 replaces a macro, use CAPITALS!}}
-
-\unexpanded\def\checkdefined#1#2#3%
- {\doifdefined{#3}{\showdefinederror{#2}{#3}}}
-
-%D \macros
-%D {GotoPar,GetPar}
-%D
-%D Typesetting a paragraph in a special way can be done by first grabbing the
-%D contents of the paragraph and processing this contents grouped. The next macro
-%D for instance typesets a paragraph in boldface.
-%D
-%D \starttyping
-%D \def\remark#1\par%
-%D {\bgroup\bf#1\egroup}
-%D \stoptyping
-%D
-%D This macro has to be called like
-%D
-%D \starttyping
-%D \remark some text ... ending with \par
-%D \stoptyping
-%D
-%D Instead of \type {\par} we can of course use an empty line. When we started
-%D typesetting with \TEX, we already had produced lots of text in plain \ASCII. In
-%D producing such simple formatted texts, we adopted an open layout, and when
-%D switching to \TEX, we continued this open habit. Although \TEX\ permits a cramped
-%D and badly formatted source, it adds to confusion and sometimes introduces errors.
-%D So we prefer:
-%D
-%D \starttyping
-%D \remark
-%D
-%D some text ... ending with an empty line
-%D \stoptyping
-%D
-%D We are going to implement a mechanism that allows such open specifications. The
-%D definition of the macro handling \type {\remark} becomes:
-%D
-%D \starttyping
-%D \def\remark%
-%D {\BeforePar{\bgroup\bf}%
-%D \AfterPar{\egroup}%
-%D \GetPar}
-%D \stoptyping
-%D
-%D A macro like \type {\GetPar} can be defined in several ways. The recent version,
-%D the fourth one in a row, originally was far more complicated, but some
-%D functionality has been moved to other macros.
-%D
-%D We start with the more simple but in some cases more appropriate alternative is
-%D \type {\GotoPar}. This one leaves \type {\par} unchanged and is therefore more
-%D robust. On the other hand, \type {\AfterPar} is not supported.
-
-\newtoks\BeforePar
-\newtoks\AfterPar
-
-\def\redowithpar\par
- {\doifelsenextchar\par\redowithpar\dodowithpar}%
-
-\def\dowithpar#1#2%
- {\def\dodowithpar##1\par{#1##1#2}%
- \redowithpar\par}
-
-\def\redogotopar\par
- {\doifelsenextchar\par\redogotopar\dodogotopar}%
-
-\def\dogotopar#1%
- {\def\dodogotopar{#1}%
- \redogotopar\par}
-
-\def\dogotoparcs#1%
- {\let\dodogotopar#1%
- \redogotopar\par}
-
-\unexpanded\def\GetPar
- {\expanded
- {\dowithpar
- {\the\BeforePar
- \BeforePar\emptytoks}
- {\the\AfterPar
- \BeforePar\emptytoks
- \AfterPar\emptytoks}}}
-
-\unexpanded\def\GotoPar
- {\expanded
- {\dogotopar
- {\the\BeforePar
- \BeforePar\emptytoks}}}
-
-%D \macros
-%D {dowithpargument,dowithwargument}
-%D
-%D The next macros are a variation on \type {\GetPar}. When macros expect an
-%D argument, it interprets a grouped sequence of characters a one token. While this
-%D adds to robustness and less ambiguous situations, we sometimes want to be a bit
-%D more flexible, or at least want to be a bit more tolerant to user input.
-%D
-%D We start with a commands that acts on paragraphs. This
-%D command is called as:
-%D
-%D \starttyping
-%D \dowithpargument\command
-%D \dowithpargument{\command ... }
-%D \stoptyping
-%D
-%D In \CONTEXT\ we use this one to read in the titles of chapters, sections etc. The
-%D commands responsible for these activities accept several alternative ways of
-%D argument passing. In these examples, the \type {\par} can be omitted when an
-%D empty line is present.
-%D
-%D \starttyping
-%D \command{...}
-%D \command ... \par
-%D \command
-%D {...}
-%D \command
-%D ... \par
-%D \stoptyping
-
-\let\syst_helpers_next_par\relax
-\let\syst_helpers_next_arg\relax
-
-\unexpanded\def\dowithpargument#1%
- {\def\syst_helpers_next_par##1 \par{#1{##1}}%
- \def\syst_helpers_next_arg##1{#1{##1}}%
- \doifelsenextbgroup\syst_helpers_next_arg{\doifelsenextchar\par{#1{}}\syst_helpers_next_par}}
-
-%D The \type {p} in the previous command stands for paragraph. When we want to act
-%D upon words we can use the \type{w} alternative.
-%D
-%D \starttyping
-%D \dowithwargument\command
-%D \dowithwargument{... \command ...}
-%D \stoptyping
-%D
-%D The main difference bwteen two alternatives is in the handling of \type {\par}'s.
-%D This time the space token acts as a delimiter.
-%D
-%D \starttyping
-%D \command{...}
-%D \command ...
-%D \command
-%D {...}
-%D \command
-%D ...
-%D \stoptyping
-
-\let\syst_helpers_next_war\relax
-\let\syst_helpers_next_arg\relax
-
-\unexpanded\def\dowithwargument#1%
- {\def\syst_helpers_next_war##1 {#1{##1}}%
- \def\syst_helpers_next_arg##1{#1{##1}}%
- \doifelsenextbgroup\syst_helpers_next_arg\syst_helpers_next_war}
-
-%D \macros
-%D {dorepeat,dorepeatwithcommand}
-%D
-%D When doing repetitive tasks, we stromgly advice to use \type {\dorecurse}. The
-%D next alternative however, suits better some of the \CONTEXT\ interface commands.
-%D
-%D \starttyping
-%D \dorepeat[n*\command]
-%D \stoptyping
-%D
-%D The value of the used \COUNTER\ can be called within
-%D \type{\command} by \type{\repeater}.
-%D
-%D A slightly different alternative is:
-%D
-%D \starttyping
-%D \dorepeatwithcommand[n*{...}]\command
-%D \stoptyping
-%D
-%D When we call for something like:
-%D
-%D \starttyping
-%D \dorepeatwithcommand[3*{Hello}]\message
-%D \stoptyping
-%D
-%D we get ourselves three \type {\message{Hello}} messages in a row. In both
-%D commands, the \type {n*} is optional. When this specification is missing, the
-%D command executes once.
-
-\unexpanded\def\dorepeatwithcommand[#1]%
- {\syst_helpers_repeat_with_command#1*\empty*\relax}
-
-\def\syst_helpers_repeat_with_command#1*#2#3*#4\relax#5%
- {\ifx#2\empty\syst_helpers_repeat_with_command_again[#1]#5\else\syst_helpers_repeat_with_command_indeed{#1}{#2}{#3}#5\fi}
-
-\def\syst_helpers_repeat_with_command_indeed#1#2#3#4%
- {\ifx#2\empty % redundant but gives cleaner extensions
- #4{#1}%
- \orelse\ifnum#1<\zerocount
- %\normalexpanded{\dorecurse{\number-\number#1}}{#4{-#2#3}}%
- \dorecurse{-#1}{#4{-#2#3}}%
- \orelse\ifx#2+%
- \dorecurse{#1}{#4{#3}}%
- \else
- \dorecurse{#1}{#4{#2#3}}%
- \fi}
-
-\def\syst_helpers_repeat_with_command_again[#1]#2%
- {#2{#1}}
-
-%D The extension hook permits something like:
-%D
-%D \starttyping
-%D \bgroup
-%D
-%D \catcode`\*=\superscriptcatcode
-%D
-%D \gdef\syst_helpers_repeat_with_command_again[#1]%
-%D {\redodorepeatwithcommand#1*\empty*\relax}
-%D
-%D \gdef\redodorepeatwithcommand#1*#2#3*#4\relax#5%
-%D {\syst_helpers_repeat_with_command_indeed{#1}{#2}{#3}#5}
-%D
-%D \egroup
-%D \stoptyping
-%D
-%D although one may wonder if changing the catcode of \type {*} is wise.
-
-%D \macros
-%D {doifstringinstringelse}
-%D
-%D The next macro is meant for situations where both strings are macros. This save
-%D some unneeded expansion.
-%D
-%D \starttyping
-%D \def\doifstringinstringelse#1#2%
-%D {\syst_helpers_do_if_in_string_else#1#2%
-%D \expandafter\firstoftwoarguments
-%D \else
-%D \expandafter\secondoftwoarguments
-%D \fi}
-%D \stoptyping
-%D
-%D A bit faster is:
-
-\def\syst_helpers_if_instring_else_indeed#1%
- {\if#1@%
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\def\doifelsestringinstring#1#2%
- {\expandafter\def\expandafter\syst_helpers_if_instring_else\expandafter##\expandafter1#1##2##3^^^^0004%
- {\syst_helpers_if_instring_else_indeed##2}%
- \expandafter\expandafter\expandafter\syst_helpers_if_instring_else\expandafter#2#1@@^^^^0004}
-
-\let\doifstringinstringelse\doifelsestringinstring
-
-%D \macros
-%D {appendtoks,prependtoks,appendtoksonce,prependtoksonce,
-%D doifintokselse,flushtoks,dotoks}
-%D
-%D We use tokenlists sparsely within \CONTEXT, because the comma separated lists are
-%D more suitable for the user interface. Nevertheless we have:
-%D
-%D \starttyping
-%D (\doglobal) \appendtoks ... \to\tokenlist
-%D (\doglobal) \prependtoks ... \to\tokenlist
-%D (\doglobal) \flushtoks\tokenlist
-%D \dotoks\tokenlist
-%D \stoptyping
-%D
-%D These macros are clones of the ones implemented in page~378 of Knuth's \TEX book.
-
-\newtoks\t_syst_helpers_scratch
-\let \m_syst_helpers_scratch\empty
-
-\unexpanded\def\appendtoks#1\to#2%
- {\ifx\dodoglobal\relax
- \expandafter\toksapp
- \else
- \resetglobal
- \expandafter\gtoksapp
- \fi#2{#1}}
-
-\unexpanded\def\prependtoks#1\to#2%
- {\ifx\dodoglobal\relax
- \expandafter\tokspre
- \else
- \resetglobal
- \expandafter\gtokspre
- \fi#2{#1}}
-
-\def\syst_helpers_append_toks_indeed
- {\ifx\dodoglobal\relax
- \expandafter\toksapp
- \else
- \resetglobal
- \expandafter\gtoksapp
- \fi\m_syst_helpers_scratch\t_syst_helpers_scratch}
-
-\def\syst_helpers_prepend_toks_indeed
- {\ifx\dodoglobal\relax
- \expandafter\tokspre
- \else
- \resetglobal
- \expandafter\gtokspre
- \fi\m_syst_helpers_scratch\t_syst_helpers_scratch}
-
-\unexpanded\def\appendtoksonce#1\to#2%
- {\let\m_syst_helpers_scratch#2%
- \t_syst_helpers_scratch{#1}%
- \doifelseintoks\t_syst_helpers_scratch\m_syst_helpers_scratch
- \donothing
- \syst_helpers_append_toks_indeed}
-
-\unexpanded\def\prependtoksonce#1\to#2%
- {\let\m_syst_helpers_scratch#2%
- \t_syst_helpers_scratch{#1}%
- \doifelseintoks\t_syst_helpers_scratch\m_syst_helpers_scratch
- \donothing
- \syst_helpers_prepend_toks_indeed}
-
-%D The test macro:
-
-\unexpanded\def\doifelseintoks#1#2% #1 en #2 zijn toks
- {\edef\asciia{\detokenize\expandafter{\the#1}}%
- \edef\asciib{\detokenize\expandafter{\the#2}}%
- \doifelsestringinstring\asciia\asciib}
-
-\let\doifintokselse\doifelseintoks
-
-%D Moved from \type {lxml-ini.tex} to here. This one is for generators that collect
-%D stuff piecewise, which is sometimes hard on mechanisms that grab content using
-%D delimiters:
-%D
-%D \starttyping
-%D \startcollecting
-%D \startcollect \bTABLE \stopcollect
-%D \startcollect \bTR \stopcollect
-%D \startcollect \bTD \stopcollect
-%D \startcollect foo\stopcollect
-%D \startcollect \eTD \stopcollect
-%D \startcollect \bTD \stopcollect
-%D \startcollect bar\stopcollect
-%D \startcollect \eTD \stopcollect
-%D \startcollect \eTR \stopcollect
-%D \startcollect \eTABLE \stopcollect
-%D \stopcollecting
-%D \stoptyping
-
-\newtoks \collectingtoks
-
-\unexpanded\def\startcollect #1\stopcollect {\toksapp \collectingtoks{#1}}
-\unexpanded\def\startexpandedcollect#1\stopexpandedcollect{\etoksapp\collectingtoks{#1}}
-
-\unexpanded\def\startcollecting{\collectingtoks\emptytoks}
-\unexpanded\def\stopcollecting {\the\collectingtoks}
-
-\unexpanded\def\collect {\toksapp \collectingtoks}
-\unexpanded\def\collectexpanded{\etoksapp\collectingtoks}
-
-%D A nice one too:
-
-% {\scratchtoks{abc} \removetoks b\from\scratchtoks [\the\scratchtoks]}
-% {\scratchtoks{abc} \removetoks x\from\scratchtoks [\the\scratchtoks]}
-% {\scratchtoks{} \removetoks x\from\scratchtoks [\the\scratchtoks]}
-% {\scratchtoks{xaa} \removetoks x\from\scratchtoks [\the\scratchtoks]}
-% {\scratchtoks{a\relax b} \removetoks \relax\from\scratchtoks [\showthe\scratchtoks]}
-
-\unexpanded\def\removetoks#1\from#2%
- {\def\syst_helpers_remove_toks##1#1##2\empty\empty\empty##3^^^^0004%
- {\def\m_syst_string_one{##3}%
- \ifx\m_syst_string_one\empty#2{##1}\else#2{##1##2}\fi}%
- \expandafter\syst_helpers_remove_toks\the#2\empty\empty\empty#1\empty\empty\empty^^^^0004}
-
-%D Also:
-
-\unexpanded\def\appendetoks#1\to#2%
- {\ifx\dodoglobal\relax
- \expandafter\etoksapp
- \else
- \resetglobal
- \expandafter\xtoksapp
- \fi#2{#1}}
-
-\unexpanded\def\prependetoks#1\to#2%
- {\ifx\dodoglobal\relax
- \expandafter\etokspre
- \else
- \resetglobal
- \expandafter\xtokspre
- \fi#2{#1}}
-
-%D Hm.
-
-\unexpanded\def\flushtoks#1% nb: can reassign to #1 again, hence the indirectness
- {\t_syst_helpers_scratch#1\relax
- \dodoglobal#1\emptytoks
- \the\t_syst_helpers_scratch\relax}
-
-\let\dotoks\the
-
-%D \macros
-%D {beforesplitstring,aftersplitstring}
-%D
-%D These both commands split a string at a given point in two
-%D parts, so \type{x.y} becomes \type{x} or \type{y}.
-%D
-%D \starttyping
-%D \beforesplitstring test.tex\at.\to\filename
-%D \aftersplitstring test.tex\at.\to\extension
-%D \stoptyping
-%D
-%D The first routine looks (and is indeed) a bit simpler than the second one. The
-%D alternative looking more or less like the first one did not always give the
-%D results we needed. Both implementations show some insight in the manipulation of
-%D arguments.
-
-\let\syst_helpers_split_string\relax
-
-\unexpanded\def\beforesplitstring#1\at#2\to#3%
- {\def\syst_helpers_split_string##1#2##2#2##3\\%
- {\def#3{##1}}%
- \expandafter\syst_helpers_split_string#1#2#2\\}
-
-\unexpanded\def\aftersplitstring#1\at#2\to#3%
- {\def\syst_helpers_split_string##1#2##2@@@##3\\%
- {\def#3{##2}}%
- \expandafter\syst_helpers_split_string#1@@@#2@@@\\}
-
-%D \macros
-%D {splitstring,greedysplitstring}
-%D
-%D A bonus macro.
-
-\unexpanded\def\splitstring#1\at#2\to#3\and#4%
- {\def\syst_helpers_split_string##1#2##2\empty\empty\empty##3\\%
- {\def#3{##1}%
- \def\syst_helpers_split_string{##3}%
- \ifx\syst_helpers_split_string\empty
- \let#4\empty
- \else
- \def#4{##2}%
- \fi}%
- \expandafter\syst_helpers_split_string#1\empty\empty\empty#2\empty\empty\empty\\}
-
-\unexpanded\def\greedysplitstring#1\at#2\to#3\and#4%
- {\edef\asciib{#1}%
- \let\asciic\asciib
- \let#3\empty
- \let#4\empty
- \doloop
- {\expandafter\splitstring\asciib\at#2\to\asciia\and\asciib
- \ifx\asciib\empty
- \exitloop
- \else
- % not \edef#3{\ifx#3\empty\else#3#2\fi\asciia} else
- % /root/path fails because then #3==empty
- \edef#3{\ifcase\recurselevel\or\else#3#2\fi\asciia}%
- \let#4\asciib
- \fi}%
- \ifx#3\empty\let#3\asciic\fi}
-
-%D \macros
-%D {beforetestandsplitstring,
-%D aftertestandsplitstring,
-%D testandsplitstring}
-
-\unexpanded\def\beforetestandsplitstring#1\at#2\to#3%
- {\def\syst_helpers_split_string##1#2##2#2##3##4\\%
- {\ifx##3\empty\let#3\empty\else\def#3{##1}\fi}%
- \expandafter\syst_helpers_split_string#1#2#2\empty\\}
-
-\unexpanded\def\aftertestandsplitstring#1\at#2\to#3%
- {\def\syst_helpers_split_string ##1#2##2@@@##3##4\\%
- {\ifx##3\empty\let#3\empty\else\def#3{##2}\fi}%
- \expandafter\syst_helpers_split_string #1@@@#2@@@\empty\\}
-
-\def\testandsplitstring#1\at#2\to#3\and#4%
- {\def\syst_helpers_split_string##1#2##2#2##3##4\\%
- {\ifx##3\empty\let#3\empty\let#4\empty\else\def#3{##1}\def#4{##2}\fi}%
- \expandafter\syst_helpers_split_string#1#2#2\empty\\}
-
-%D \macros
-%D {splitatperiod,
-%D {splitatcomma,
-%D splitatasterisk,
-%D splitatcolon,
-%D splitatcolons}
-
-\unexpanded\def\splitatperiod #1{\normalexpanded{\syst_helpers_splitatperiod #1}..\relax}
-\unexpanded\def\splitatcomma #1{\normalexpanded{\syst_helpers_splitatcomma #1},,\relax} % not at ", "
-\unexpanded\def\splitatasterisk#1{\normalexpanded{\syst_helpers_splitatasterisk#1}**\relax}
-\unexpanded\def\splitatcolon #1{\normalexpanded{\syst_helpers_splitatcolon #1}::\relax}
-\unexpanded\def\splitatcolons #1{\normalexpanded{\syst_helpers_splitatcolons #1}::::\relax}
-
-\unexpanded\def\syst_helpers_splitatperiod #1.#2.#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatcomma #1,#2,#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatasterisk #1*#2*#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatcolon #1:#2:#3\relax#4#5{\def#4{#1}\def#5{#2}}
-\unexpanded\def\syst_helpers_splitatcolons #1::#2::#3\relax#4#5{\edef#4{#1}\edef#5{#2}}
-
-%D \macros
-%D {removesubstring}
-%D
-%D A first application of the two routines defined above is:
-%D
-%D \starttyping
-%D \removesubstring-\from first-last\to\nothyphenated
-%D \stoptyping
-%D
-%D Which in terms of \TEX\ looks like:
-
-\unexpanded\def\removesubstring#1\from#2\to#3%
- {\splitstring#2\to\m_syst_string_one\and\m_syst_string_two
- \dodoglobal#3{\m_syst_string_one\m_syst_string_two}}
-
-%D \macros
-%D {appendtocommalist,prependtocommalist,
-%D addtocommalist,removefromcommalist}
-%D
-%D When working with comma separated lists, one sooner or later want the tools to
-%D append or remove items from such a list. When we add an item, we first check if
-%D it's already there. This means that every item in the list is unique.
-%D
-%D \starttyping
-%D \addtocommalist {alfa} \name
-%D \addtocommalist {beta} \name
-%D \addtocommalist {gamma} \name
-%D \removefromcommalist {beta} \name
-%D \stoptyping
-%D
-%D These commands can be prefixed with \type {\doglobal}. The implementation of the
-%D second command is more complecated, because we have to take leading spaces into
-%D account. Keep in mind that users may provide lists with spaces after the commas.
-%D When one item is left, we also have to get rid of trailing spaces.
-%D
-%D \starttyping
-%D \def\words{alfa, beta, gamma, delta}
-%D \def\words{alfa,beta,gamma,delta}
-%D \stoptyping
-%D
-%D Removing an item takes more time than adding one. A fast appending alternative,
-%D without any testing, is also provided:
-%D
-%D \starttyping
-%D \appendtocommalist {something} \name
-%D \prependtocommalist {something} \name
-%D \stoptyping
-%D
-%D This can be implemented as follows:
-%D
-%D \starttyping
-%D \def\appendtocommalist#1#2%
-%D {\ifx#2\empty
-%D \dodoglobal\edef#2{#1}%
-%D \else % no test on empty
-%D \dodoglobal\edef#2{#2,#1}%
-%D \fi}
-%D
-%D \def\prependtocommalist#1#2%
-%D {\ifx#2\empty
-%D \dodoglobal\edef#2{#1}%
-%D \else % no test on empty
-%D \dodoglobal\edef#2{#1,#2}%
-%D \fi}
-%D \stoptyping
-%D
-%D The faster alternatives are:
-
-\unexpanded\def\appendtocommalist#1#2%
- {\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}
-
-\unexpanded\def\prependtocommalist#1#2%
- {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}
-
-\unexpanded\def\addtocommalist#1#2% {item} \cs
- {\rawdoifelseinset{#1}#2\resetglobal
- {\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
-
-\unexpanded\def\pretocommalist#1#2% {item} \cs
- {\rawdoifelseinset{#1}#2\resetglobal
- {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
-
-\unexpanded\def\robustdoifelseinset#1#2%
- {\edef\m_syst_string_one{\detokenize\expandafter{\normalexpanded{#1}}}%
- \edef\m_syst_string_two{\detokenize\expandafter{\normalexpanded{#2}}}%
- \rawdoifelseinset\m_syst_string_one\m_syst_string_two}
-
-\let\robustdoifinsetelse\robustdoifelseinset
-
-\unexpanded\def\robustaddtocommalist#1#2% {item} \cs
- {\robustdoifelseinset{#1}#2\resetglobal
- {\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
-
-\unexpanded\def\robustpretocommalist#1#2% {item} \cs
- {\robustdoifelseinset{#1}#2\resetglobal
- {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
-
-\unexpanded\def\xsplitstring#1#2% \cs {str}
- {\def\syst_helpers_split_string##1,#2,##2,#2,##3\\%
- {\edef\m_syst_string_one{\bcleanedupcommalist##1\empty\empty\relax}%
- \edef\m_syst_string_two{\acleanedupcommalist##2,,\relax}}%
- \expandafter\syst_helpers_split_string\expandafter,#1,,#2,,#2,\\}
-
-\def\bcleanedupcommalist#1#2#3\relax{\if#1,\else#1\fi\if#2,\else#2\fi#3}
-\def\bcleanedupcommalist#1#2\relax{\if#1,\else#1\fi#2}
-\def\acleanedupcommalist#1,,#2\relax{#1}
-
-\unexpanded\def\removefromcommalist#1#2% to be sped up
- {\rawdoifelseinset{#1}#2%
- {\normalexpanded{\xsplitstring\noexpand#2{#1}}%
- \dodoglobal\edef#2%
- {\ifx\m_syst_string_one\empty
- \m_syst_string_two
- \else
- \m_syst_string_one\ifx\m_syst_string_two\empty\else,\m_syst_string_two\fi
- \fi}}
- \resetglobal}
-
-%D \macros
-%D {substituteincommalist}
-%D
-%D Slow but seldom used, so for the moment we stick to this implementation.
-%D
-%D \starttyping
-%D \substituteincommalist{old}{new}{list}
-%D \stoptyping
-
-\def\syst_helpers_substitute_in_comma_list_step#1%
- {\edef\m_syst_string_three{#1}%
- \ifx\m_syst_string_one\m_syst_string_three
- \ifx\m_syst_string_two\empty \else
- \edef\m_syst_string_four{\ifx\m_syst_string_four\empty\else\m_syst_string_four,\fi\m_syst_string_two}%
- \fi
- \else
- \edef\m_syst_string_four{\ifx\m_syst_string_four\empty\else\m_syst_string_four,\fi#1}%
- \fi}
-
-\unexpanded\def\substituteincommalist#1#2#3% old, new, list (slooow)
- {\edef\m_syst_string_one{#1}%
- \edef\m_syst_string_two{#2}%
- \let\m_syst_string_four\empty
- \normalexpanded{\rawprocesscommacommand[#3]}\syst_helpers_substitute_in_comma_list_step
- \let#3\m_syst_string_four}
-
-%D \macros
-%D {replaceincommalist}
-%D
-%D The next macro can be used to replace an indexed element in a commalist:
-%D
-%D \starttyping
-%D \replaceincommalist\MyList{2}
-%D \stoptyping
-%D
-%D Element~2 will be replaced by the current meaning of the macro \type
-%D {\newcommalistelement}. The old meaning is saved in \type {\commalistelement}.
-%D The replacement honors grouped items, like in:
-%D
-%D \starttyping
-%D \def\MyList{a,b,c,d,e,f} \replaceincommalist\MyList{3}
-%D \def\MyList{a,b,c,d,e,f} \replaceincommalist\MyList{3}
-%D \def\MyList{a,{b,c},d,e,f} \replaceincommalist\MyList{3}
-%D \def\MyList{a,b,c,{d,e,f}} \replaceincommalist\MyList{3}
-%D \stoptyping
-%D
-%D This macro was used in the bibtex code (and is probably no longer needed).
-
-\newcount\c_syst_helpers_comma_list_index
-\let \m_syst_helpers_comma_list_target\empty
-
-\let\newcommalistelement\empty
-
-\def\syst_helpers_replace_in_comma_list_step#1%
- {\ifnum\commalistcounter=\c_syst_helpers_comma_list_index\relax
- \ifx\newcommalistelement\empty\else
- \ifx\m_syst_helpers_comma_list_target\empty
- \let\m_syst_helpers_comma_list_target\newcommalistelement
- \else
- \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter
- \m_syst_helpers_comma_list_target\expandafter\expandafter\expandafter
- {\expandafter\m_syst_helpers_comma_list_target\expandafter,\newcommalistelement}%
- \fi
- \fi
- \def\commalistelement{#1}%
- \else
- \ifx\m_syst_helpers_comma_list_target\empty
- \ifx\nexttoken\bgroup % is known -)
- \def\m_syst_helpers_comma_list_target{{#1}}%
- \else
- \def\m_syst_helpers_comma_list_target{#1}%
- \fi
- \else
- \ifx\nexttoken\bgroup % is known -)
- \expandafter\def\expandafter\m_syst_helpers_comma_list_target\expandafter{\m_syst_helpers_comma_list_target,{#1}}%
- \else
- \expandafter\def\expandafter\m_syst_helpers_comma_list_target\expandafter{\m_syst_helpers_comma_list_target,#1}%
- \fi
- \fi
- \fi
- \advance\commalistcounter\plusone}
-
-\unexpanded\def\replaceincommalist#1#2% #1 = commalistelement #2 = position starts at 1
- {\c_syst_helpers_comma_list_index#2\relax
- \let\m_syst_helpers_comma_list_target\empty
- \let\commalistelement\empty
- \commalistcounter\plusone
- \expandafter\processcommalist\expandafter[#1]\syst_helpers_replace_in_comma_list_step
- \dodoglobal\let#1\m_syst_helpers_comma_list_target}
-
-%D \macros
-%D {globalprocesscommalist}
-%D
-%D The commalist processing commands are characterized by the fact that the way they
-%D handle expansion as well as the fact that they can be nested. This makes them
-%D kind of useless for handling comma lists in alignments. In these situations the
-%D next macro can be of use.
-
-\let\m_syst_helpers_comma_list_command_global\empty
-
-\def\syst_helpers_comma_list_command_global_step#1,%
- {\if]#1\else
- \m_syst_helpers_comma_list_command_global{#1}%
- \expandafter\syst_helpers_comma_list_command_global_step
- \fi}
-
-\unexpanded\def\globalprocesscommalist[#1]#2%
- {\glet\m_syst_helpers_comma_list_command_global#2%
- \expandafter\syst_helpers_comma_list_command_global_step#1,],}
-
-%D \macros
-%D {withoutpt,PtToCm,
-%D numberofpoints,dimensiontocount}
-%D
-%D We can convert point into centimeters with:
-%D
-%D \starttyping
-%D \PtToCm{dimension}
-%D \stoptyping
-
-{\catcode`\.=\othercatcode
- \catcode`\p=\othercatcode
- \catcode`\t=\othercatcode
- \gdef\WITHOUTPT#1pt{#1}}
-
-\def\withoutpt#1%
- {\expandafter\WITHOUTPT#1}
-
-%D The capitals are needed because \type {p} and \type {t} have catcode~12, while
-%D macronames only permit tokens with the catcode~11. As a result we cannot use the
-%D \type {.group} primitives. Those who want to know more about this kind of
-%D manipulations, we advice to study the \TEX book in detail. Because this macro
-%D does not do any assignment, we can use it in the following way too.
-
-\def\PtToCm#1%
- {\withoutpt\the\dimexpr0.0351459804\dimexpr#1\relax\relax cm}
-
-%D We also support:
-%D
-%D \starttyping
-%D \numberofpoints {dimension}
-%D \dimensiontocount {dimension} {\count}
-%D \stoptyping
-%D
-%D Both macros return a rounded number.
-
-% \dimensiontocount{10.49pt}\scratchcounter \the\scratchcounter / \numberofpoints{10.49pt}
-% \dimensiontocount{10.51pt}\scratchcounter \the\scratchcounter / \numberofpoints{10.51pt}
-
-\def\dimensiontocount#1#2{#2\numexpr\dimexpr#1\relax/\maxcard\relax}
-\def\numberofpoints #1{\the\numexpr\dimexpr#1\relax/\maxcard\relax}
-
-%D \macros
-%D {swapdimens,swapcounts,swapmacros,
-%D globalswapdimens,globalswapcounts,globalswapmacros}
-%D
-%D Simple but effective are the next two macros. There name exactly states their
-%D purpose.
-
-\newdimen\d_syst_helpers_swapped
-\newcount\c_syst_helpers_swapped
-\let \m_syst_helpers_swapped\relax
-
-\unexpanded\def\swapdimens#1#2{\d_syst_helpers_swapped#1#1#2#2\d_syst_helpers_swapped}
-\unexpanded\def\swapcounts#1#2{\c_syst_helpers_swapped#1#1#2#2\c_syst_helpers_swapped}
-\unexpanded\def\swapmacros#1#2{\let\m_syst_helpers_swapped#1\let#1#2\let#2\m_syst_helpers_swapped}
-
-\unexpanded\def\globalswapdimens#1#2{\d_syst_helpers_swapped#1\global#1#2\global#2\d_syst_helpers_swapped}
-\unexpanded\def\globalswapcounts#1#2{\c_syst_helpers_swapped#1\global#1#2\global#2\c_syst_helpers_swapped}
-\unexpanded\def\globalswapmacros#1#2{\let\m_syst_helpers_swapped#1\glet#1#2\glet#2\m_syst_helpers_swapped}
-
-%D \macros
-%D {pushmacro,popmacro}
-%D
-%D Premature and a bit of beta, we offer:
-%D
-%D \starttyping
-%D \pushmacro\macro
-%D \popmacro\macro
-%D \stoptyping
-%D
-%D Beware: global!
-
-\installsystemnamespace{localpushedmacro}
-\installsystemnamespace{globalpushedmacro}
-
-\let\m_syst_helpers_push_macro\empty
-
-\newcount\c_syst_helpers_pop_count
-
-\def\syst_helpers_push_macro_new_global
- {\expandafter\newcount\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname
- \global\advance\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname\plusone}
-
-\def\syst_helpers_push_macro_new_local
- {\expandafter\newcount\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
- \global\advance\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname\plusone}
-
-\unexpanded\def\globalpushmacro#1%
- {\xdef\m_syst_helpers_push_macro{\csstring#1}%
- \ifcsname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname
- \global\advance\lastnamedcs\plusone
- \else
- \syst_helpers_push_macro_new_global
- \fi
- \expandafter\glet\csname\the\lastnamedcs\m_syst_helpers_push_macro\endcsname#1}
-
-\unexpanded\def\localpushmacro#1% this one can be used to push a value over an \egroup
- {\xdef\m_syst_helpers_push_macro{\csstring#1}%
- \ifcsname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
- \global\advance\lastnamedcs\plusone
- \else
- \syst_helpers_push_macro_new_local
- \fi
- \expandafter\glet\csname\the\lastnamedcs\m_syst_helpers_push_macro\endcsname#1}
-
-\unexpanded\def\globalpopmacro#1%
- {\xdef\m_syst_helpers_push_macro{\csstring#1}%
- \c_syst_helpers_pop_count\csname\??globalpushedmacro\m_syst_helpers_push_macro\endcsname
- \global\advance\lastnamedcs \minusone
- \expandafter\glet\expandafter#1\csname\the\c_syst_helpers_pop_count\m_syst_helpers_push_macro\endcsname}
-
-\unexpanded\def\localpopmacro#1%
- {\xdef\m_syst_helpers_push_macro{\csstring#1}%
- \c_syst_helpers_pop_count\csname\??localpushedmacro\m_syst_helpers_push_macro\endcsname
- \global\advance\lastnamedcs \minusone
- \expandafter\let\expandafter#1\csname\the\c_syst_helpers_pop_count\m_syst_helpers_push_macro\endcsname}
-
-\let\pushmacro\localpushmacro
-\let\popmacro \localpopmacro
-
-%D \macros
-%D {setlocalhsize,distributedhsize}
-%D
-%D Sometimes we need to work with the \type{ \hsize} that is corrected for
-%D indentation and left and right skips. The corrected value is available in \type
-%D {\localhsize}, which needs to be calculated with \type {\setlocalhsize} first. %D
-%D
-%D \starttyping
-%D \setlocalhsize \hbox to \localhsize{...}
-%D \setlocalhsize[-1em] \hbox to \localhsize{...}
-%D \setlocalhsize[.5ex] \hbox to \localhsize{...}
-%D \stoptyping
-%D
-%D These examples show us that an optional can be used. The value provided is added
-%D to \type {\localhsize}.
-
-\newdimen\localhsize
-
-\unexpanded\def\setlocalhsize % don't change !
- {\doifelsenextoptional
- \syst_helpers_set_local_hsize_yes
- \syst_helpers_set_local_hsize_nop}
-
-\def\syst_helpers_set_local_hsize_nop
- {\localhsize\availablehsize}
-
-\def\syst_helpers_set_local_hsize_yes[#1]%
- {\syst_helpers_set_local_hsize_nop
- \advance\localhsize#1\relax}
-
-\def\availablehsize
- {\dimexpr
- \hsize-\leftskip-\rightskip
- \ifnum\hangafter<\zerocount
- \ifdim\hangindent>\zeropoint-\else+\fi\hangindent
- \fi
- \relax}
-
-\def\distributedhsize#1#2#3%
- {\dimexpr(#1-\numexpr#3-1\relax\dimexpr#2\relax)/#3\relax}
-
-\def\hsizefraction#1#2%
- {\dimexpr#1/#2\relax}
-
-%D \macros
-%D {doifvalue,doifnotvalue,doifelsevalue,
-%D doifnothing,doifsomething,doifelsenothing,
-%D doifvaluenothing,doifvaluesomething,doifelsevaluenothing}
-%D
-%D These \type {\if} commands can be used to access macros (or variables) that are
-%D normally accessed by using \type {\getvalue}. Using these alternatives safes us
-%D three tokens per call. Anyone familiar with the not||values ones, can derive
-%D their meaning from the definitions.
-
-\unexpanded\def\doifvalue#1#2%
- {\iftok{\csname#1\endcsname}{#2}%
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifnotvalue#1#2%
- {\iftok{\csname#1\endcsname}{#2}%
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\doifelsevalue#1#2%
- {\iftok{\csname#1\endcsname}{#2}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\doifnothing#1%
- {\iftok{#1}\emptytoks
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifsomething#1%
- {\iftok{#1}\emptytoks
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\doifelsenothing#1%
- {\iftok{#1}\emptytoks
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\doifelsesomething#1%
- {\iftok{#1}\emptytoks
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\unexpanded\def\doifvaluenothing#1%
- {\iftok{\csname#1\endcsname}\emptytoks
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\doifvaluesomething#1%
- {\iftok{\csname#1\endcsname}\emptytoks
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\doifelsevaluenothing#1%
- {\iftok{\csname#1\endcsname}\emptytoks
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifvalueelse \doifelsevalue
-\let\doifnothingelse \doifelsenothing
-\let\doifsomethingelse \doifelsesomething
-\let\doifvaluenothingelse\doifelsevaluenothing
-
-%D \macros
-%D {doifemptyelsevalue, doifemptyvalue, doifnotemptyvalue}
-%D
-%D Also handy:
-
-\def\doifelseemptyvalue#1%
- {\expandafter\ifx\csname#1\endcsname\empty
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifemptyvalueelse\doifelseemptyvalue
-
-\def\doifemptyvalue#1%
- {\expandafter\ifx\csname#1\endcsname\empty
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\def\doifnotemptyvalue#1%
- {\expandafter\ifx\csname#1\endcsname\empty
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-%D \macros
-%D {doifallcommonelse}
-%D
-%D A complete match of two sets can be tested with \type {\doifallcommonelse}, where
-%D the first two arguments are sets.
-
-\def\syst_helpers_do_if_all_common_else#1#2#3#4% slow
- {\def\syst_helpers_do_common_check_all##1%
- {\doifnotinset{##1}{#4}\donefalse
- \ifdone\else\expandafter\quitcommalist\fi}%
- \donetrue
- \processcommalist[#3]\syst_helpers_do_common_check_all
- \ifdone\expandafter#1\else\expandafter#2\fi}
-
-\unexpanded\def\doifelseallcommon{\syst_helpers_do_if_all_common_else\firstoftwoarguments\secondoftwoarguments}
-\unexpanded\def\doifallcommon {\syst_helpers_do_if_all_common_else\firstofonearguments\gobbleoneargument }
-\unexpanded\def\doifnotallcommon {\syst_helpers_do_if_all_common_else\gobbleoneargument \firstofonearguments }
-
-\let\doifallcommonelse\doifelseallcommon
-
-%D \macros
-%D {DOIF,DOIFELSE,DOIFNOT}
-%D
-%D \TEX\ is case sensitive. When comparing arguments, this feature sometimes is less
-%D desirable, for instance when we compare filenames. The next three alternatives
-%D upcase their arguments before comparing them.
-%D
-%D \starttyping
-%D \DOIF {string1} {string2} {...}
-%D \DOIFNOT {string1} {string2} {...}
-%D \DOIFELSE {string1} {string2} {then ...}{else ...}
-%D \stoptyping
-%D
-%D We have to use a two||step implementation, because the
-%D expansion has to take place outside \type{\uppercase}.
-%D
-%D These might end up as \LUA based helpers (i.e. consider these
-%D obsolete:
-
-\unexpanded\def\syst_helpers_do_IF#1#2%
- {\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\unexpanded\def\syst_helpers_do_IF_NOT#1#2%
- {\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\syst_helpers_do_IF_ELSE#1#2%
- {\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\syst_helpers_do_IF_INSTRING_ELSE#1#2%
- {\uppercase{\syst_helpers_do_if_in_string_else{$#1$}{$#2$}}%
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\unexpanded\def\DOIF #1#2{\normalexpanded{\syst_helpers_do_IF {#1}{#2}}}% will become obsolete
-\unexpanded\def\DOIFNOT #1#2{\normalexpanded{\syst_helpers_do_IF_NOT {#1}{#2}}}% will become obsolete
-\unexpanded\def\DOIFELSE #1#2{\normalexpanded{\syst_helpers_do_IF_ELSE {#1}{#2}}}% will become obsolete
-\unexpanded\def\DOIFINSTRINGELSE #1#2{\normalexpanded{\syst_helpers_do_IF_INSTRING_ELSE{#1}{#2}}}% will become obsolete
-
-%D \macros
-%D {dosingleargumentwithset,
-%D dodoubleargumentwithset,dodoubleemptywithset,
-%D dotripleargumentwithset,dotripleemptywithset}
-%D
-%D These maybe too mysterious macros enable us to handle more than one setup at once.
-%D
-%D \starttyping
-%D \dosingleargumentwithset \command[#1]
-%D \dodoubleargumentwithset \command[#1][#2]
-%D \dotripleargumentwithset \command[#1][#2][#3]
-%D \dodoubleemptywithset \command[#1][#2]
-%D \dotripleemptywithset \command[#1][#2][#3]
-%D \stoptyping
-%D
-%D The first macro calls \type {\command[##1]} for each string in the set~\type
-%D {#1}. The second one calls for \typ {\command [##1][#2]} and the third, well one
-%D may guess. These commands support constructions like:
-%D
-%D \starttyping
-%D \def\dodefinesomething[#1][#2]%
-%D {\getparameters[\??xx#1][#2]}
-%D
-%D \unexpanded\def\definesomething%
-%D {\dodoubleargumentwithset\dodefinesomething}
-%D \stoptyping
-%D
-%D Which accepts calls like:
-%D
-%D \starttyping
-%D \definesomething[alfa,beta,...][variable=...,...]
-%D \stoptyping
-
-\let\m_syst_helpers_with_set_command\empty
-\let\syst_helpers_with_set_step \relax
-
-\def\syst_helpers_with_set_double[#1][#2]%
- {\doifsomething{#1}%
- {\def\syst_helpers_with_set_step##1{\m_syst_helpers_with_set_command[##1][#2]}%
- \processcommalist[#1]\syst_helpers_with_set_step}}
-
-\def\syst_helpers_with_set_triple[#1][#2][#3]%
- {\doifsomething{#1}%
- {\def\syst_helpers_with_set_step##1{\m_syst_helpers_with_set_command[##1][#2][#3]}%
- \processcommalist[#1]\syst_helpers_with_set_step}}
-
-\def\dodoubleemptywithset #1{\let\m_syst_helpers_with_set_command#1\dodoubleempty \syst_helpers_with_set_double} % \command
-\def\dodoubleargumentwithset#1{\let\m_syst_helpers_with_set_command#1\dodoubleargument\syst_helpers_with_set_double} % \command
-
-\def\dotripleemptywithset #1{\let\m_syst_helpers_with_set_command#1\dotripleempty \syst_helpers_with_set_triple} % \command
-\def\dotripleargumentwithset#1{\let\m_syst_helpers_with_set_command#1\dotripleargument\syst_helpers_with_set_triple} % \command
-
-%D \macros
-%D {stripcharacters,stripspaces}
-%D
-%D The next command was needed first when we implemented the \CONTEXT\ interactivity
-%D macros. When we use labeled destinations, we often cannot use all the characters
-%D we want. We therefore strip some of the troublemakers, like spaces, from the
-%D labels before we write them to the \DVI||file, which passes them to for instance
-%D a \POSTSCRIPT\ file.
-%D
-%D \starttyping
-%D \stripspaces\from\one\to\two
-%D \stoptyping
-%D
-%D Both the old string \type{\one} and the new one \type{\two}
-%D are expanded. This command is a special case of:
-%D
-%D \starttyping
-%D \stripcharacter\char\from\one\to\two
-%D \stoptyping
-%D
-%D As we can see below, spaces following a control sequence are to enclosed in \type
-%D {{}}.
-
-\let\m_syst_helpers_strip_character\empty
-
-\unexpanded\def\stripcharacter#1\from#2\to#3%
- {\def\syst_helpers_strip_character##1#1##2\end
- {\edef\m_syst_helpers_strip_character{\m_syst_helpers_strip_character##1}%
- \doifnotempty{##2}{\syst_helpers_strip_character##2\end}}%
- \let\m_syst_helpers_strip_character\empty
- \edef\m_syst_string_one{#2}%
- \expandafter\syst_helpers_strip_character\m_syst_string_one#1\end
- \dodoglobal\let#3\m_syst_helpers_strip_character}
-
-\unexpanded\def\stripspaces\from#1\to#2% will become \unspacestring#1\from#2
- {\stripcharacter{ }\from#1\to#2}
-
-%D \macros
-%D {unspacestring}
-%D
-%D The next macro does the same but is more compatible with other macros, like \type
-%D {\convert...}.
-
-\unexpanded\def\unspacestring#1\to#2%
- {\stripcharacter{ }\from#1\to#2}
-
-%D \macros
-%D {executeifdefined}
-%D
-%D \CONTEXT\ uses one auxiliary file for all data concerning tables of contents,
-%D references, two||pass optimizations, sorted lists etc. This file is loaded as
-%D many times as needed. During such a pass we skip the commands thate are of no use
-%D at that moment. Because we don't want to come into trouble with undefined
-%D auxiliary commands, we call the macros in a way similar to \type {\getvalue}. The
-%D next macro take care of such executions and when not defined, gobbles the
-%D unwanted arguments.
-%D
-%D \starttyping
-%D \executeifdefined{name}\gobbleoneargument
-%D \stoptyping
-%D
-%D We can of course gobble more arguments using the appropriate gobbling command.
-
-\def\executeifdefined#1% #2 / never change this one again
- {\ifcsname#1\endcsname
- % \csname#1\expandafter\expandafter\expandafter\endcsname\expandafter\gobbleoneargument
- \expandafter\expandafter\expandafter\lastnamedcs\expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-%D This one also has the advantage that it is fully expandable and that it can be
-%D used after an assignment.
-
-%D \macros
-%D {doifsomespaceelse}
-%D
-%D The next command checks a string on the presence of a space and executed a
-%D command accordingly.
-%D
-%D \starttyping
-%D \doifsomespaceelse {tekst} {then ...} {else ...}
-%D \stoptyping
-%D
-%D We use this command in \CONTEXT\ for determing if an argument must be broken into
-%D words when made interactive. Watch the use of \type {\noexpand}.
-
-%D Is this one still needed?
-
-\def\syst_helpers_if_some_space_else#1 #2#3^^^^0004{\if\noexpand#2@}
-
-\def\doifelsesomespace#1% % #2#3%
- {\syst_helpers_if_some_space_else#1 @ @^^^^0004% #3\else#2\fi}
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\let\doifsomespaceelse\doifelsesomespace
-
-%D \macros
-%D {processseparatedlist}
-%D
-%D Maybe a bit late, but here is a more general version of the \type
-%D {\processcommalist} command. This time we don't handle nesting but accept
-%D arbitrary seperators.
-%D
-%D \starttyping
-%D \processseparatedlist[list][separator]\command
-%D \stoptyping
-%D
-%D One can think of things like:
-%D
-%D \starttyping
-%D \processseparatedlist[alfa+beta+gamma][+]\message
-%D \stoptyping
-%D
-%D We want to handle all situations, like:
-%D
-%D \startbuffer
-%D \processseparatedlist[{aap noot}] [ ]{\def\xxx} \convertcommand\xxx\to\ascii {\tttf\ascii}
-%D \processseparatedlist[{aap} {noot}][ ]{\def\xxx} \convertcommand\xxx\to\ascii {\tttf\ascii}
-%D \processseparatedlist[aap {noot}] [ ]{\def\xxx} \convertcommand\xxx\to\ascii {\tttf\ascii}
-%D \processseparatedlist[aap noot] [ ]{\def\xxx} \convertcommand\xxx\to\ascii {\tttf\ascii}
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D Therefore we smuggle a \type {\relax} in front of the argument, which we remove
-%D afterwards.
-
-\let\syst_helpers_process_separated_list_step\relax
-
-\def\syst_helpers_process_separated_list#1]#2[#3]#4%
- {\def\syst_helpers_process_separated_list_step##1##2#3%
- {\def\m_syst_string_one{##2}% suggested by VZ
- \if]##1%
- \let\syst_helpers_process_separated_list_step\relax
- \orelse\ifx\blankspace\m_syst_string_one
- #4{##1}%
- \orelse\if]##2%
- \let\syst_helpers_process_separated_list_step\relax
- \else
- #4{##1##2}%
- \fi
- \syst_helpers_process_separated_list_step}%
- \expandafter\syst_helpers_process_separated_list_step\gobbleoneargument#1#3]#3}
-
-\unexpanded\def\processseparatedlist[%
- {\syst_helpers_process_separated_list\relax}
-
-%D \macros
-%D {processlist}
-%D
-%D An even more general list processing macro is the following one:
-%D
-%D \starttyping
-%D \processlist{beginsym}{endsym}{separator}\docommand list
-%D \stoptyping
-%D
-%D This one supports arbitrary open and close symbols as well as user defined
-%D separators.
-%D
-%D \starttyping
-%D \processlist(){=>}\docommand(a=>b=>c=>d)
-%D \stoptyping
-
-\let\syst_helpers_process_any_list \relax
-\let\syst_helpers_process_any_list_indeed\relax
-\let\syst_helpers_process_any_list_step \relax
-
-\unexpanded\def\processlist#1#2#3#4% no blank skipping !
- {\def\syst_helpers_process_any_list_indeed##1#2%
- {\def\syst_helpers_process_any_list_step####1####2#3%
- {\ifx#2####1%
- \let\syst_helpers_process_any_list_step\relax
- \orelse\ifx#2####2%
- \let\syst_helpers_process_any_list_step\relax
- \else
- #4{####1####2}%
- \fi
- \syst_helpers_process_any_list_step}%
- \expandafter\syst_helpers_process_any_list_step\gobbleoneargument##1#3#2#3}%
- \def\syst_helpers_process_any_list#1%
- {\syst_helpers_process_any_list_indeed\relax}%
- \syst_helpers_process_any_list}
-
-%D \macros
-%D {processassignlist}
-%D
-%D Is possible to combine an assignment list with one containing keywords.
-%D Assignments are treated accordingly, keywords are treated by \type {\command}.
-%D
-%D \starttyping
-%D \processassignlist[...=...,...=...,...]\commando
-%D \stoptyping
-%D
-%D This command can be integrated in \type {\getparameters}, but we decided best not
-%D to do so.
-
-\unexpanded\def\processassignlist#1[#2]#3%
- {\def\syst_helpers_process_assign_list_assign[##1=##2=##3]%
- {\doif{##3}\relax{#3{##1}}}%
- \def\syst_helpers_process_assign_list_step##1%
- {\syst_helpers_process_assign_list_assign[##1==\relax]}%
- \processcommalist[#2]\syst_helpers_process_assign_list_step}
-
-%D \macros
-%D {untextargument
-%D untexcommand}
-%D
-%D When manipulating data(bases) and for instance generating index entries, the next
-%D three macros can be of help:
-%D
-%D \starttyping
-%D \untextargument{...}\to\name
-%D \untexcommand {...}\to\name
-%D \stoptyping
-%D
-%D They remove braces and backslashes and give us something to sort.
-
-\let\m_syst_helpers_untexed\empty
-
-\unexpanded\def\untexsomething
- {\begingroup
- \catcode\leftbraceasciicode \ignorecatcode
- \catcode\rightbraceasciicode\ignorecatcode
- \escapechar\minusone
- \syst_helpers_untex_something}
-
-\def\syst_helpers_untex_something#1#2\to#3%
- {\doglobal#1#2\to\m_syst_helpers_untexed
- \endgroup
- \let#3\m_syst_helpers_untexed}
-
-\unexpanded\def\untexargument{\untexsomething\convertargument}
-\unexpanded\def\untexcommand {\untexsomething\convertcommand}
-
-%D \macros
-%D {ScaledPointsToBigPoints,ScaledPointsToWholeBigPoints}
-%D
-%D One characteristic of \POSTSCRIPT\ and \PDF\ is that both used big points (\TEX's
-%D bp). The next macros convert points and scaled points into big points. The magic
-%D factor $72/72.27$ can be found in most \TEX\ related books.
-%D
-%D \starttyping
-%D \ScaledPointsToBigPoints {number} \target
-%D \ScaledPointsToWholeBigPoints {number} \target
-%D \stoptyping
-
-\let\tobigpoints \clf_tobigpoints
-\let\towholebigpoints\clf_towholebigpoints
-
-\unexpanded\def\PointsToBigPoints #1#2{\edef#2{\tobigpoints #1}} % can be avoided
-\unexpanded\def\PointsToWholeBigPoints #1#2{\edef#2{\towholebigpoints#1}} % can be avoided
-\unexpanded\def\ScaledPointsToBigPoints #1#2{\edef#2{\tobigpoints #1\scaledpoint}} % obsolete
-\unexpanded\def\ScaledPointsToWholeBigPoints#1#2{\edef#2{\towholebigpoints#1\scaledpoint}} % obsolete
-
-%D \macros
-%D {PointsToReal}
-%D
-%D Points can be stripped from their suffix by using \type {\withoutpt}. The next
-%D macro enveloppes this macro.
-%D
-%D \starttyping
-%D \PointsToReal {dimension} \target
-%D \stoptyping
-
-\unexpanded\def\PointsToReal#1#2%
- {\edef#2{\withoutpt\the\dimexpr#1}}
-
-%D \macros
-%D {dontleavehmode}
-%D
-%D Sometimes when we enter a paragraph with some command, the first token gets the
-%D whole first line. We can prevent this by saying:
-%D
-%D \starttyping
-%D \dontleavehmode
-%D \stoptyping
-%D
-%D This command is used in for instance the language module \type {lang-ini}. The
-%D first version was:
-%D
-%D \starttyping
-%D \def\dontleavehmode{\ifhmode\else\ifmmode\else$ $\fi\fi}
-%D \stoptyping
-%D
-%D Next, Taco came with a better alternative (using mathsurround):
-%D
-%D \starttyping
-%D \def\dontleavehmode
-%D {\ifhmode\else \ifmmode\else
-%D {\mathsurround\zeropoint\everymath\emptytoks$ $}%
-%D \fi \fi}
-%D \stoptyping
-%D
-%D And finaly we got the following alternative, one that avoids interfering grouping
-%D at the cost of a box.
-%D
-%D \starttyping
-%D \newbox\b_syst_helpers_dlh
-%D
-%D \unexpanded\def\dontleavehmode
-%D {\ifhmode\else \ifmmode\else
-%D \setbox\b_syst_helpers_dlh\hbox{\mathsurround\zeropoint\everymath\emptytoks$ $}\unhbox\b_syst_helpers_dlh
-%D \fi \fi}
-%D \stoptyping
-%D
-%D But, as we run a recent version of \TEX, we can use the new primitive:
-
-\ifdefined\normalquitvmode \let\dontleavehmode\normalquitvmode \fi
-
-%D \macros
-%D {utfupper, utflower, uppercasestring, lowercasestring}
-%D
-%D The names tell what they do:
-%D
-%D \starttyping
-%D \uppercasestring somestring\to\somestring
-%D \lowercasestring somestring\to\somestring
-%D \stoptyping
-%D
-%D The first argument may be a \type{\macro}.
-%D
-%D These macros are sort of obsolete as we never use uppercase this way. But
-%D nevertheless we provide them:
-
-\def\utfupper#1{\clf_upper{#1}} % expandable
-\def\utflower#1{\clf_lower{#1}} % expandable
-
-\unexpanded\def\uppercasestring#1\to#2{\dodoglobal\edef#2{\clf_upper{#1}}}
-\unexpanded\def\lowercasestring#1\to#2{\dodoglobal\edef#2{\clf_lower{#1}}}
-
-%D \macros
-%D {handletokens}
-%D
-%D With the next macro we enter a critical area of macro expansion. What we want is
-%D a macro that looks like:
-%D
-%D \starttyping
-%D \handletokens some tokens\with \somemacro
-%D \stoptyping
-%D
-%D A bonus example:
-%D
-%D \starttyping
-%D \hbox{\handletokens tekst en meer tekst\with\ruledhbox}
-%D
-%D \def\weetikveel#1{\if#1\blankspace\space\else\ruledhbox{#1}\fi}
-%D
-%D \hbox{\handletokens tekst en meer tekst\with\weetikveel}
-%D \stoptyping
-
-%D \macros
-%D {counttoken,counttokens}
-%D
-%D For the few occasions that we want to know the number of specific tokens in a
-%D string, we can use:
-%D
-%D \starttyping
-%D \counttoken token\in string\to \somecount
-%D \counttokens string\to \somecount
-%D \stoptyping
-%D
-%D This macro, that for instance is used in \type {cont-tab}, takes a real counter.
-%D The macro can be preceded by \type {\doglobal}.
-
-\def\syst_helpers_count_token#1% obeys {}
- {\def\m_syst_string_three{#1}%
- \ifx\m_syst_string_two\m_syst_string_three \else
- \ifx\m_syst_string_one\m_syst_string_three
- \advance\privatescratchcounter\plusone
- \fi
- \expandafter\syst_helpers_count_token
- \fi}
-
-\unexpanded\def\counttoken#1\in#2\to#3%
- {\privatescratchcounter\zerocount
- \def\m_syst_string_one{#1}%
- \def\m_syst_string_two{\end}%
- \syst_helpers_count_token#2\end
- \dodoglobal#3\privatescratchcounter}
-
-\unexpanded\def\counttokens#1\to#2%
- {\privatescratchcounter\zerocount
- \def\syst_helpers_count_token##1{\advance\privatescratchcounter\plusone}%
- \handletokens#1\with\syst_helpers_count_token
- \dodoglobal#2\privatescratchcounter}
-
-%D \macros
-%D {splitofftokens}
-%D
-%D Running this one not always gives the expected results. Consider for instance the
-%D macro for which I originally wrote this token handler.
-
-\unexpanded\def\splitofftokens#1\from#2\to#3% slow but hardly used
- {\ifnum#1>\zerocount
- \privatescratchcounter#1\relax
- \def\syst_helpers_split_off_tokens##1%
- {\ifnum\privatescratchcounter>\zerocount
- \advance\privatescratchcounter \minusone
- \edef#3{#3##1}%
- \fi}%
- % \let#3\empty % #3 can be #2, so:
- \expandafter\let\expandafter#3\expandafter\empty
- \expandafter\handletokens#2\with\syst_helpers_split_off_tokens
- \else
- \edef#3{#2}%
- \fi}
-
-%D This macro can be called like:
-%D
-%D \startbuffer[example]
-%D \splitofftokens10\from01234567 890123456789\to\test [\test]
-%D \stopbuffer
-%D
-%D up there. The reason for this is not that logical but follows from \TEX's
-%D However, the characters that we expect to find in \type {\test} just don't show
-%D sometimes mysterious way of expanding. Look at this:
-%D
-%D \startbuffer[next]
-%D \def\next{a} \edef\test{\next} [\test]
-%D \let\next=b \edef\test{\test\next} [\test]
-%D \let\next=c \edef\test{\next} [\test]
-%D \let\next=d \edef\test{\test\next} [\test]
-%D \let\next=e \expandafter\edef\expandafter\test\expandafter{\test\next} [\test]
-%D \stopbuffer
-%D
-%D \typebuffer[next]
-%D
-%D Careful reading shows that inside an \type {\edef} macro's that are \type {\let}
-%D are not expanded!
-%D
-%D \unprotect\getbuffer[next]\protect
-%D
-%D That's why we finally end up with a macro that looks ahead by using an
-%D assignment, this time by using \type {\futurelet}, and grabbing an argument as
-%D well. That way we can handle the sentinal, a blank space and grouped tokens.
-
-\unexpanded\def\syst_helpers_handle_tokens % \nexthandledtoken is part of interface
- {\futurelet\nexthandledtoken\syst_helpers_handle_tokens_indeed}
-
-\def\handletokens#1\with#2%
- {\gdef\syst_helpers_handle_tokens_command{#2}% permits more complex #2's
- \syst_helpers_handle_tokens#1\end}
-
-\def\syst_helpers_handle_tokens_indeed
- {\ifx\nexthandledtoken\blankspace
- \expandafter\syst_helpers_handle_tokens_indeed_one
- \orelse\ifx\nexthandledtoken\end
- \expandafter\gobbletwoarguments % also gobble the \end
- \else
- \expandafter\syst_helpers_handle_tokens_indeed_two
- \fi *}
-
-\def\syst_helpers_handle_tokens_indeed_one * %
- {\syst_helpers_handle_tokens_command{ }\syst_helpers_handle_tokens}
-
-\def\syst_helpers_handle_tokens_indeed_two *#1%
- {\syst_helpers_handle_tokens_command{#1}\syst_helpers_handle_tokens}
-
-%D This macro is tested on:
-%D
-%D \def\xxx#1{[#1]}
-%D
-%D \startlines
-%D \handletokens abc\with\xxx
-%D \handletokens a b c\with\xxx
-%D \handletokens a b c\with\xxx
-%D \handletokens a{bc}d\with\xxx
-%D \handletokens a\space bc \with\xxx
-%D \stoplines
-%D
-%D And our previous example shows up as:
-%D
-%D \getbuffer[example]
-
-%D \macros
-%D {iftrialtypesetting, ifvisible}
-%D
-%D The next boolean is at first sight a strange one. Sometimes one does a trial
-%D typesetting run, for instance to determine dimensions. Some mechanisms, like
-%D object inclusion, can fail on such trials. Temporary setting the next boolean to
-%D true, helps a lot. The second boolena can be used to inhibit processing
-%D completely.
-
-\newif\ifvisible \visibletrue
-
-\newtoks\everysettrialtypesetting
-\newtoks\everyresettrialtypesetting
-
-\unexpanded\def\settrialtypesetting {\the\everysettrialtypesetting } % obeys grouping so
-\unexpanded\def\resettrialtypesetting{\the\everyresettrialtypesetting} % this one is seldom needed
-
-\let\iftrialtypesetting\iffalse % so we have no \trialtypesettingtrue|false in mkiv !
-
-\appendtoks \let\iftrialtypesetting\iftrue \to \everysettrialtypesetting
-\appendtoks \let\iftrialtypesetting\iffalse \to \everyresettrialtypesetting
-
-%D \macros
-%D {twodigitrounding}
-%D
-%D When using \type {\special}s or \type {\pdfliteral}s, it sometimes makes sense to
-%D limit the precission. The next macro rounds a real number to two digits. It takes
-%D one argument and only works in \ETEX.
-
-\def\integerrounding #1{\clf_rounded\zerocount\numexpr#1\relax}
-\def\onedigitrounding #1{\clf_rounded\plusone \numexpr#1\relax}
-\def\twodigitrounding #1{\clf_rounded\plustwo \numexpr#1\relax}
-\def\threedigitrounding#1{\clf_rounded\plusthree\numexpr#1\relax}
-
-%D \macros
-%D {processcontent}
-%D
-%D This macro is first used in the tabulation macros.
-%D
-%D \starttyping
-%D \unexpanded\def\starthans%
-%D {\processcontent{stophans}\test{\message{\test}\wait}}
-%D \stoptyping
-
-\unexpanded\def\processcontent#1%
- {\begingroup\expandafter\syst_helpers_process_content\csname#1\endcsname}
-
-\unexpanded\def\syst_helpers_process_content#1#2#3%
- {\unexpanded\def\syst_helpers_process_content##1#1%
- {\endgroup\def#2{##1}#3}%
- \syst_helpers_process_content}
-
-%D \macros
-%D {dogobblesingleempty, dogobbledoubleempty}
-%D
-%D These two macros savely grab and dispose two arguments.
-
-\def\dogobblesingleempty{\dosingleempty\syst_helpers_gobble_single_empty}
-\def\dogobbledoubleempty{\dodoubleempty\syst_helpers_gobble_double_empty}
-
-\def\syst_helpers_gobble_single_empty [#1]{}
-\def\syst_helpers_gobble_double_empty[#1][#2]{}
-
-\let\gobblesingleempty\dogobblesingleempty % also used
-\let\gobbledoubleempty\dogobbledoubleempty % also used
-
-%D \macros
-%D {setdimensionwithunit, freezedimensionwithunit}
-%D
-%D The next assignments are all valid:
-%D
-%D \starttyping
-%D \setdimensionwithunit\scratchdimen{10} {cm}
-%D \setdimensionwithunit\scratchdimen{10cm}{cm}
-%D \setdimensionwithunit\scratchdimen{10cm}{}
-%D \freezedimensionwithunit\SomeWidth{\textwidth}
-%D \freezedimensionwithunit\SomeDepth{\dp\strutbox}
-%D \stoptyping
-%D
-%D As an alternative for the next macro we can use a global assignment inside a box.
-%D The \type {\empty}'s permits gobbling while preventing spurious \type {\relax}'s.
-
-\unexpanded\def\setdimensionwithunit#1#2#3% number unit dimension / nice trick
- {\afterassignment\gobblefourarguments#1=#2#3pt\relax\empty\empty\empty\empty}
-
-\unexpanded\def\freezedimensionwithunit#1#2%
- {\setdimensionwithunit\privatescratchdimen#1{#2}\edef#1{\the\privatescratchdimen}}
-
-%D \macros
-%D {doifsometokselse, doifsometoks}
-%D
-%D Not that fast I guess, but here's a way to test for token registers being empty.
-
-\unexpanded\def\doifelsesometoks#1%
- {\iftok#1\emptytoks
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\unexpanded\def\doifsometoks#1%
- {\iftok#1\emptytoks
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\doifemptytoks#1%
- {\iftok#1\emptytoks
- \expandafter\firstofoneargument
- \else
- \expandafter\gobbleoneargument
- \fi}
-
-\let\doifsometokselse\doifelsesometoks
-
-%D \macros
-%D {startstrictinspectnextcharacter}
-%D
-%D This one is for the bibliography module (still?):
-
-\let\syst_helpers_strict_inspect_next_character[
-
-\def\syst_helpers_strict_inspect_next_character% no user macro !
- {\ifx\nexttoken[%
- \expandafter\m_syst_action_yes
- \else
- \expandafter\m_syst_action_nop
- \fi}
-
-\unexpanded\def\strictdoifelsenextoptional#1#2%
- {\def\m_syst_action_yes{#1}%
- \def\m_syst_action_nop{#2}%
- \futurelet\nexttoken\syst_helpers_strict_inspect_next_character}
-
-\let\strictdoifnextoptionalelse\strictdoifelsenextoptional
-
-%D \macros
-%D {gobblespacetokens}
-%D
-%D This macro needs a speed-up!
-
-%\def\gobblespacetokens
-% {\doifnextcharelse\empty\donothing\donothing} % no {}\do\do !
-
-\def\gobblespacetokens
- {\afterassignment\nexttoken\let\nexttoken=}
-
-%D \macros
-%D {verbatimargument}
-%D
-%D As the name says, this macro converts its argument to a (rather safe) string.
-
-\let\verbatimstring\detokenize
-
-%D These are needed in ordinal number conversions:
-
-\def\lastdigit#1%
- {\expandafter\thelastdigit\number#1\relax}
-
-\def\thelastdigit#1#2%
- {\ifx#2\relax#1\else\expandafter\thelastdigit\expandafter#2\fi}
-
-\def\lasttwodigits#1%
- {\expandafter\thelasttwodigits\expandafter0\number#1\relax}
-
-\def\thelasttwodigits#1#2#3% 0 dig ... \relax
- {\ifx#3\relax#1#2\else\expandafter\thelasttwodigits\expandafter#2\expandafter#3\fi}
-
-%D \macros
-%D {serializecommalist}
-%D
-%D Concatenate commalists:
-
-\let\syst_helpers_serialize_comma_list_step\relax
-
-\def\syst_helpers_serialize_comma_list_step#1%
- {\edef\serializedcommalist{\serializedcommalist#1}}
-
-\unexpanded\def\serializecommalist[#1]%
- {\let\serializedcommalist\empty
- \processcommacommand[#1]\syst_helpers_serialize_comma_list_step}
-
-%D \macros
-%D {purenumber}
-%D
-%D Sometimes we need control over when \TEX\ stops reading a number, especially in
-%D full expandable macros where using \type {\relax} would lead to disasters.
-%D
-%D \starttyping
-%D \ifodd\purenumber{...}\space ... \else ... \fi
-%D \stoptyping
-%D
-%D Here we use a space as number delimiter in combination with a space- and
-%D relax-less \type {\purenumber}. This macro works ok with \type {\the}, \type
-%D {\number} as well as \ETEX's \type {\numexpr}.
-
-\def\purenumber#1{\expandafter\firstofoneargument\expandafter{\number#1}}
-
-%D \macros
-%D {filterfromvalue}
-%D
-%D \starttyping
-%D \setvalue{xx}{{A}{B}{C}}
-%D
-%D \filterfromvalue{xx}{3}{3}
-%D \filterfromvalue{xx}{3}{2}
-%D \filterfromvalue{xx}{3}{1}
-%D \stoptyping
-%D
-%D An alternative is to store 'max' in the list, say:
-%D
-%D \starttyping
-%D \setvalue{xx}{3{A}{B}{C}}
-%D
-%D \filterfromvalues{3}{xx}{3}
-%D \filterfromvalues{3}{xx}{2}
-%D \filterfromvalues{3}{xx}{1}
-%D \stoptyping
-%D
-%D I'll implement this when I'm in \quotation {writing dirty macros mood}.
-
-\def\dofilterfromstr#1#2% max n % no need to be fast
- {\expandafter \expandafter \expandafter \csstring
- \ifcase#1\or \ifcase#2\or
- \firstofoneargument \else
- \gobbleoneargument \fi
- \or \ifcase#2\or
- \firstoftwoarguments \or
- \secondoftwoarguments \else
- \gobbletwoarguments \fi
- \or \ifcase#2\or
- \firstofthreearguments \or
- \secondofthreearguments \or
- \thirdofthreearguments \else
- \gobblethreearguments \fi
- \or \ifcase#2\or
- \firstoffourarguments \or
- \secondoffourarguments \or
- \thirdoffourarguments \or
- \fourthoffourarguments \else
- \gobblefourarguments \fi
- \or \ifcase#2\or
- \firstoffivearguments \or
- \secondoffivearguments \or
- \thirdoffivearguments \or
- \fourthoffivearguments \or
- \fifthoffivearguments \else
- \gobblefivearguments \fi
- \fi}
-
-\def\filterfromvalue#1#2#3% value max n
- {\expandafter\doubleexpandafter\csname % we use the fact that an
- \expandafter\ifx\csname#1\endcsname\relax % undefined cs has become \relax
- \csstring\gobbleoneargument % which we then gobble here
- \else
- \dofilterfromstr{#2}{#3}%
- \fi
- \endcsname\csname#1\endcsname}
-
-\def\filterfromnext#1#2% max n {..}{..}{..}{..}
- {\csname\dofilterfromstr{#1}{#2}\endcsname}
-
-%D \macros
-%D {definemeasure}
-%D
-%D \starttyping
-%D \definemeasure[mywidth][\dimexpr(\textwidth-1cm)]
-%D
-%D ... \measure{mywidth} ...
-%D \stoptyping
-
-\installsystemnamespace{measure}
-
-\unexpanded\def\definemeasure
- {\dodoubleargument\syst_helpers_define_measure}
-
-\def\syst_helpers_define_measure[#1][#2]%
- {\expandafter\def\csname\??measure#1\endcsname{#2}}
-
-\unexpanded\def\freezemeasure
- {\dodoubleargument\syst_helpers_freeze_measure}
-
-\def\syst_helpers_freeze_measure[#1][#2]%
- {\expandafter\edef\csname\??measure#1\endcsname{\the\dimexpr#2}}
-
-\unexpanded\def\setmeasure #1#2{\expandafter\def \csname\??measure#1\endcsname{#2}} % quick way
-\unexpanded\def\setgmeasure#1#2{\expandafter\gdef\csname\??measure#1\endcsname{#2}} % quick way
-\unexpanded\def\setemeasure#1#2{\expandafter\edef\csname\??measure#1\endcsname{\the\dimexpr#2}} % quick way
-\unexpanded\def\setxmeasure#1#2{\expandafter\xdef\csname\??measure#1\endcsname{\the\dimexpr#2}} % quick way
-
-\def\measure
- {\the\measured}
-
-\def\measured#1%
- %{\dimexpr\ifcsname\??measure#1\endcsname\csname\??measure#1\endcsname\else\zeropoint\fi\relax}
- {\dimexpr\ifcsname\??measure#1\endcsname\lastnamedcs\else\zeropoint\fi\relax}
-
-% #2 could be omitted, but we want to support spaces
-%
-% \setmeasure {x} {1cm}
-% \setmeasure {xx} {1cm}
-% \setmeasure {xxx}{1cm}
-
-%D \macros
-%D {definequantity}
-%D
-%D These do the same but for numbers.
-
-\installsystemnamespace{quantity}
-
-\unexpanded\def\definequantity
- {\dodoubleargument\syst_helpers_define_quantity}
-
-\def\syst_helpers_define_quantity[#1][#2]%
- {\expandafter\def\csname\??quantity#1\endcsname{#2}}
-
-\unexpanded\def\freezequantity
- {\dodoubleargument\syst_helpers_freeze_quantity}
-
-\def\syst_helpers_freeze_quantity[#1][#2]%
- {\expandafter\edef\csname\??quantity#1\endcsname{\the\numexpr#2}}
-
-\unexpanded\def\setquantity #1#2{\expandafter\def \csname\??quantity#1\endcsname{#2}} % quick way
-\unexpanded\def\setgquantity#1#2{\expandafter\gdef\csname\??quantity#1\endcsname{#2}} % quick way
-\unexpanded\def\setequantity#1#2{\expandafter\edef\csname\??quantity#1\endcsname{\the\numexpr#2}} % quick way
-\unexpanded\def\setxquantity#1#2{\expandafter\xdef\csname\??quantity#1\endcsname{\the\numexpr#2}} % quick way
-
-\def\quantity
- {\the\quantitied}
-
-\def\quantitied#1%
- {\numexpr\ifcsname\??quantity#1\endcsname\lastnamedcs\else\zeropoint\fi\relax}
-
-\def\directquantity#1%
- {\the\numexpr#1\relax}
-
-% let\quantified\quantitied
-
-%D \macros
-%D {dividedsize}
-%D
-%D This one can be used inside a measure (used in m4all):
-%D
-%D \starttyping
-%D \definemeasure[columnwidth][\dividedsize\textwidth{1em}{3}]
-%D \stoptyping
-
-\def\dividedsize#1#2#3% size gap n
- {\dimexpr
- \ifnum\dimexpr#1\relax>\plusone
- (\dimexpr#1\relax-\numexpr#3-\plusone\relax\dimexpr#2\relax)/#3\else#1%
- \fi
- \relax}
-
-%D \macros
-%D {doifdimensionelse}
-%D
-%D This is a dirty one: we simply append a unit and discard it when needed.
-
-\def\doifelsedimension#1%
- {\ifchkdim#1\or
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifdimensionelse\doifelsedimension
-
-%D Ok, here's another one, slower but seldom used. This one scans the text.
-%D
-%D \starttabulate[|Tc|Tc|]
-%D \NC pt \NC \doifdimenstringelse {pt}{yes}{no} \NC \NR
-%D \NC 12pt \NC \doifdimenstringelse {-12pt}{yes}{no} \NC \NR
-%D \NC 1pt \NC \doifdimenstringelse {1pt}{yes}{no} \NC \NR
-%D \NC 12pt \NC \doifdimenstringelse {12pt}{yes}{no} \NC \NR
-%D \NC 12.0pt \NC \doifdimenstringelse {12.0pt}{yes}{no} \NC \NR
-%D \NC -.12pt \NC \doifdimenstringelse {-.12pt}{yes}{no} \NC \NR
-%D \NC .12pt \NC \doifdimenstringelse {.12pt}{yes}{no} \NC \NR
-%D \NC -12pt \NC \doifdimenstringelse {-12pt}{yes}{no} \NC \NR
-%D \NC -12.0pt \NC \doifdimenstringelse{-12.0pt}{yes}{no} \NC \NR
-%D \NC big \NC \doifdimenstringelse {big}{yes}{no} \NC \NR
-%D \NC 10 \NC \doifdimenstringelse {10}{yes}{no} \NC \NR
-%D \NC 1 \NC \doifdimenstringelse {1}{yes}{no} \NC \NR
-%D \stoptabulate
-
-\let\doifelsedimenstring\doifelsedimension
-\let\doifdimenstringelse\doifelsedimenstring
-
-%D \macros
-%D {comparedimension,comparedimensioneps}
-%D
-%D This is a dirty one: we simply append a unit and discard it when needed.
-
-\newdimen \roundingeps \roundingeps=10sp
-\newconstant\compresult
-
-\def\comparedimension#1#2%
- {\compresult
- \ifdim#1<#2%
- \zerocount
- \orelse\ifdim#1<#2%
- \plusone
- \else
- \plustwo
- \fi}
-
-\def\comparedimensioneps#1#2% todo: use eps feature
- {\compresult
- \ifdim\dimexpr#1-#2\relax<\roudingeps
- \zerocount
- \orelse\ifdim\dimexpr#2-#1\relax<\roudingeps
- \zerocount
- \orelse\ifdim#1<#2%
- \plusone
- \else
- \plustwo
- \fi}
-
-% pretty ugly but fast
-
-% \copycsname xxx\endcsname\csname ..\endcsname
-
-\unexpanded\def\copycsname{\expandafter\expandafter\expandafter\let\expandafter\expandafter\csname}
-
-% \letcscsname \crap \csname ..\endcsname
-% \letcsnamecs \csname ..\endcsname\crap
-% \letcsnamecsname\csname ..\endcsname\csname ..\endcsname
-
-\unexpanded\def\letcscsname {\expandafter\let\expandafter}
-\unexpanded\def\letcsnamecs {\expandafter\let}
-\unexpanded\def\letcsnamecsname{\expandafter\expandafter\expandafter\let\expandafter\expandafter}
-
-% another one, add an item to a commalist
-
-\unexpanded\def\addvalue#1#2% cs item
- {\ifcsname#1\endcsname\else\expandafter\let\csname#1\endcsname\empty\fi
- \normalexpanded{\noexpand\addtocommalist{#2}\expandafter\noexpand\csname#1\endcsname}}
-
-\def\unspaced#1%
- {\syst_helpers_unspaced#1\end}
-
-\def\syst_helpers_unspaced#1%
- {\ifx#1\end
- \expandafter\gobbleoneargument
- \orelse\ifx#1\blankspace
- % go on
- \else
- #1%
- \fi
- \syst_helpers_unspaced}
-
-\unexpanded\def\unspaceargument#1\to#2%
- {\privatescratchcounter\catcode\spaceasciicode
- \catcode\spaceasciicode\ignorecatcode
- \scantextokens{\edef#2{#1}}%
- \catcode\spaceasciicode\privatescratchcounter}
-
-\unexpanded\def\unspaceafter#1#2%
- {\unspaceargument#2\to\ascii
- \expandafter#1\expandafter{\ascii}}
-
-% sometimes handy:
-
-\unexpanded\def\doifelsehasspace#1%
- {\edef\m_syst_string_one{#1}%
- \normalexpanded{\syst_helpers_if_has_space_else#1\space}\empty\relax}
-
-\let\doifhasspaceelse\doifelsehasspace
-
-\unexpanded\def\syst_helpers_if_has_space_else#1 #2#3\relax % \space\empty\relax
- {\ifx\m_syst_string_one\space
- \expandafter\firstoftwoarguments
- \orelse\ifx#2\empty
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-% this will replace loadfile once and alike !!! todo
-
-\installsystemnamespace{flag}
-
-\unexpanded\def\setflag #1{\expandafter\dodoglobal\expandafter\let\csname\??flag#1\endcsname\zerocount}
-\unexpanded\def\resetflag#1{\expandafter\dodoglobal\expandafter\let\csname\??flag#1\endcsname\plusone}
-
-\def\flag#1{\csname\??flag#1\endcsname}
-
-\def\doifelseflagged#1%
- {\expandafter\ifx\csname\??flag#1\endcsname\relax
- \expandafter\secondoftwoarguments
- \orelse\ifcase\csname\??flag#1\endcsname
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
-
-\let\doifflaggedelse\doifelseflagged
-
-\def\doifnotflagged#1%
- {\expandafter\ifx\csname\??flag#1\endcsname\relax
- \expandafter\firstofoneargument
- \orelse\ifcase\csname\??flag#1\endcsname
- \expandafter\gobbleoneargument
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\inheritparameter[#1]#2[#3]#4[#5]% tag tokey fromkey
- {\expandafter\def\csname#1#3\expandafter\endcsname\expandafter{\csname#1#5\endcsname}}
-
-\def\syst_helpers_if_non_zero_positive_else#1#2\end % #3#4%
- {\ifx#1\relax
- \ifcase\privatescratchcounter
- \endgroup
- \doubleexpandafter\secondoftwoarguments
- \else
- \endgroup
- \doubleexpandafter\firstoftwoarguments
- \fi
- \else
- \endgroup
- \expandafter\secondoftwoarguments
- \fi}
-
-% used ?
-
-\def\doifelsenonzeropositive#1%
- {\begingroup\afterassignment\syst_helpers_if_non_zero_positive_else\privatescratchcounter=0#1\relax\empty\end}
-
-\let\doifnonzeropositiveelse\doifelsenonzeropositive
-
-% here ?
-
-\unexpanded\def\dosetrawvalue #1#2#3{\expandafter \def\csname#1#2\endcsname{#3}}
-\unexpanded\def\dosetrawevalue#1#2#3{\expandafter\edef\csname#1#2\endcsname{#3}}
-\unexpanded\def\dosetrawgvalue#1#2#3{\expandafter\gdef\csname#1#2\endcsname{#3}}
-\unexpanded\def\dosetrawxvalue#1#2#3{\expandafter\xdef\csname#1#2\endcsname{#3}}
-
-\unexpanded\def\getrawparameters {\dogetparameters\dosetrawvalue }
-\unexpanded\def\getraweparameters {\dogetparameters\dosetrawevalue}
-\unexpanded\def\getrawgparameters {\dogetparameters\dosetrawgvalue}
-\unexpanded\def\getrawxparameters {\dogetparameters\dosetrawxvalue}
-
-\unexpanded\def\globalgetrawparameters{\dogetparameters\dosetrawgvalue} % obsolete
-
-%D Sort of obsolete:
-
-\newcount\c_syst_helpers_mod
-
-\unexpanded\def\dosetmodulo#1#2#3%
- {\c_syst_helpers_mod#1\divide\c_syst_helpers_mod#2\multiply\c_syst_helpers_mod#2%
- #3#1\advance#3-\c_syst_helpers_mod}
-
-\unexpanded\def\dosetdivision#1#2#3%
- {#3#1\divide#3 #2\relax}
-
-\unexpanded\def\DoMod#1by#2to#3{\dosetmodulo {#1}{#2}{#3}}
-\unexpanded\def\DoDiv#1by#2to#3{\dosetdivision{#1}{#2}{#3}}
-
-\def\syst_helpers_unprotected#1\par
- {#1\protect}
-
-\unexpanded\def\unprotected
- {\unprotect
- \syst_helpers_unprotected}
-
-\let\resettimer \clf_resettimer
-\let\elapsedtime \clf_elapsedtime
-\let\elapsedseconds \elapsedtime
-
-\newcount\c_syst_helpers_test_feature_n
-\newcount\c_syst_helpers_test_feature_m
-
-\def\currentfeaturetest{\number\c_syst_helpers_test_feature_n}
-
-\unexpanded\def\testfeature#1#2%
- {\c_syst_helpers_test_feature_m#1\relax
- \def\syst_helpers_test_feature_yes
- {\advance\c_syst_helpers_test_feature_n\plusone
- \ifnum\c_syst_helpers_test_feature_n>\c_syst_helpers_test_feature_m\else
- #2\expandafter\syst_helpers_test_feature_yes
- \fi}%
- \def\syst_helpers_test_feature_nop
- {\advance\c_syst_helpers_test_feature_n\plusone
- \ifnum\c_syst_helpers_test_feature_n>\c_syst_helpers_test_feature_m\else
- \expandafter\syst_helpers_test_feature_nop
- \fi}%
- \retestfeature}
-
-\unexpanded\def\retestfeature % timer support is new per 10/5/2005
- {\bgroup
- \ifcase\interactionmode\let\wait\relax\fi
- \clf_resettimer
- \c_syst_helpers_test_feature_n\zerocount
- \syst_helpers_test_feature_nop
- \clf_benchmarktimer
- \writestatus\m!system{starting feature test (n=\number\c_syst_helpers_test_feature_m)}\wait
- \c_syst_helpers_test_feature_n\zerocount
- \syst_helpers_test_feature_yes
- \writestatus\m!system{\number\c_syst_helpers_test_feature_m\space feature tests done (\elapsedseconds s)}%
- \wait
- \egroup}
-
-\unexpanded\def\showtimer#1%
- {\writestatus{runtime}{\elapsedseconds\space s / #1}}
-
-\unexpanded\def\testfeatureonce#1#2%
- {\begingroup
- \let\wait\relax
- \testfeature{#1}{#2}%
- \endgroup}
-
-%D \macros
-%D {freezedimenmacro}
-%D
-%D This macro is use as:
-%D
-%D \starttyping
-%D \freezedimenmacro\leftmargindistance
-%D \stoptyping
-
-\unexpanded\def\freezedimenmacro#1%
- {\edef#1{\the\dimexpr#1}}
-
-%D The next macro negates a macro (dimension or number, or actually, whatever. It's
-%D a typical example of \type {\if} usage:
-%D
-%D \starttyping
-%D \if-\whatever \else-\whatever\fi => else => -whatever
-%D \if--\whatever\else-\whatever\fi => then => whatever
-%D \stoptyping
-
-\def\negated#1{\if-#1\else-#1\fi} % does only work in macros or text
-
-\def\gobbleassigndimen#1\\{}
-
-\def\assigndimen#1#2%
- {\afterassignment\gobbleassigndimen#1=#2\zeropoint\\}
-
-\unexpanded\def\appended#1#2#3{\expandafter#1\expandafter#2\expandafter{#2#3}}
-\unexpanded\def\appendvalue #1{\expandafter\appended\expandafter \def\csname#1\endcsname}
-\unexpanded\def\appendgvalue#1{\expandafter\appended\expandafter\gdef\csname#1\endcsname}
-
-\unexpanded\def\prepended#1#2#3%
- {\t_syst_helpers_scratch{#3}%
- \expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter#2\expandafter\expandafter\expandafter
- {\expandafter\the\expandafter\t_syst_helpers_scratch#2}}
-
-\unexpanded\def\prependvalue #1{\expandafter\prepended\expandafter \def\csname#1\endcsname}
-\unexpanded\def\prependgvalue#1{\expandafter\prepended\expandafter\gdef\csname#1\endcsname}
-
-%D \macros
-%D {dowithrange}
-%D
-%D This one is for Mojca Miklavec, who made me aware of the fact that \type
-%D {page-imp.tex} was not the best place to hide it.
-%D
-%D \startbuffer
-%D \def\DoSomething#1{ [item #1] }
-%D
-%D \processranges[1,4:5]\DoSomething \par
-%D \dowithrange {1,4:5}\DoSomething \par
-%D \stopbuffer
-%D
-%D \typebuffer \blank \getbuffer \blank
-
-\def\syst_helpers_with_range#1%
- {\splitstring#1\at:\to\m_syst_helpers_range_from\and\m_syst_helpers_range_to
- \ifx\m_syst_helpers_range_to\empty\let\m_syst_helpers_range_to\m_syst_helpers_range_from\fi
- \dostepwiserecurse\m_syst_helpers_range_from\m_syst_helpers_range_to\plusone{\m_helpers_range_action{##1}}}%
-
-\unexpanded\def\processranges[#1]#2% #1= n:m,p,q:r
- {\def\m_helpers_range_action{#2}%
- \processcommacommand[#1]\syst_helpers_with_range}
-
-\unexpanded\def\dowithrange#1#2%
- {\def\m_helpers_range_action{#2}%
- \processcommacommand[#1]\syst_helpers_with_range}
-
-% \def\DoSomething#1{ [item #1] }
-% \dowithrange[1,4:5]\DoSomething
-
-%D \macros
-%D {ignoreimplicitspaces}
-%D
-%D \startbuffer
-%D \def\whatever[#1]{\expanded{\definedfont[#1 at 12pt]}\ignorespaces}
-%D {a\whatever[Serif]b a\whatever[Serif] b a\whatever[Serif]\space b}
-%D \def\whatever[#1]{\expanded{\definedfont[#1 at 12pt]}\ignoreimplicitspaces}
-%D {a\whatever[Serif]b a\whatever[Serif] b a\whatever[Serif]\space b}
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\unexpanded\def\ignoreimplicitspaces
- {\doifelsenextchar\relax\relax\relax}
-
-%D \macros
-%D {processwords}
-%D
-%D Not that sophisticated but sometimes users (like in metafun).
-
-\def\syst_helpers_process_word#1 #2\_e_o_w_
- {\doifsomething{#1}{\processword{#1} \syst_helpers_process_word#2 \_e_o_w_}}
-
-\def\processwords#1%
- {\syst_helpers_process_word#1 \_e_o_w_}% no \unskip
-
-\let\processword\relax
-
-%D \macros
-%D {startnointerference}
-%D
-%D \starttyping
-%D \startnointerference
-%D all kind of code
-%D \stopnointerference
-%D \stoptyping
-
-\newbox\b_syst_helpers_no_interference
-
-\unexpanded\def\startnointerference % not even grouped !
- {\setbox\b_syst_helpers_no_interference\vbox
- \bgroup}
-
-\unexpanded\def\stopnointerference
- {\egroup
- \setbox\b_syst_helpers_no_interference\emptybox}
-
-%D A variant for \type {\executeifdefined}:
-
-\def\expandcheckedcsname#1#2% #2 is often a \xxxparameter so let's expand it once
- {\normalexpanded{\noexpand\syst_helpers_expand_checked_csname{#1}{#2}}}
-
-\def\syst_helpers_expand_checked_csname#1#2#3%
- {\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname}
-
-%D Signal. Some fonts have a char0 rendering so we need to make sure that it is not
-%D set in the font! (This will be overloaded)
-
-\unexpanded\def\signalcharacter{\char\zerocount} % \zwj
-
-%D A few secial variants of commands defined here. Some more will be moved here (e.g.
-%D from table modules.
-
-\def\dodirectdoubleempty#1#2% used in math (lookahead issues)
- {\ifx#2[%
- \expandafter\syst_helpers_direct_double_empty_one_yes
- \else
- \expandafter\syst_helpers_direct_double_empty_one_nop
- \fi#1#2}
-
-\def\syst_helpers_direct_double_empty_one_yes#1[#2]#3%
- {\ifx#3[\else\expandafter\syst_helpers_direct_double_empty_two_nop\fi#1[#2]#3}
-
-\def\syst_helpers_direct_double_empty_one_nop#1{#1[][]}
-\def\syst_helpers_direct_double_empty_two_nop#1[#2]{#1[#2][]}
-
-%D Used in math definitions (in an \type {\edef}):
-
-%D \startbuffer
-%D [\docheckedpair{}]
-%D [\docheckedpair{a}]
-%D [\docheckedpair{a,b}]
-%D [\docheckedpair{a,b,c}]
-%D \stopbuffer
-%D
-%D \typebuffer \startlines \getbuffer \stoplines
-
-\def\docheckedpair#1%
- {\syst_helpers_checked_pair#1,,\_o_e_p_}
-
-\def\syst_helpers_checked_pair#1,#2,#3\_o_e_p_
- {#1,#2}
-
-%D Here are some nasty helpers. They can be used to fill often expanded token
-%D lists efficiently (see tabulate for an example).
-
-\def\constantnumber#1%
- {\ifcase#1\zerocount
- \or \plusone
- \or \plustwo
- \or \plusthree
- \or \plusfour
- \or \plusfive
- \or \plussix
- \or \plusseven
- \or \pluseight
- \or \plusnine
- \or \plusten
- \else \number#1\relax\fi}
-
-\def\constantnumberargument#1%
- {\ifcase#1\zerocount
- \or \plusone
- \or \plustwo
- \or \plusthree
- \or \plusfour
- \or \plusfive
- \or \plussix
- \or \plusseven
- \or \pluseight
- \or \plusnine
- \or \plusten
- \else {\number#1}\fi}
-
-\def\constantdimen#1%
- {\ifdim#1=\zeropoint
- \zeropoint
- \else
- \the#1\relax
- \fi}
-
-\def\constantdimenargument#1%
- {\ifdim#1=\zeropoint
- \zeropoint
- \else
- {\the#1}%
- \fi}
-
-\def\constantemptyargument#1%
- {\ifx#1\empty
- \noexpand\empty
- \else
- {#1}%
- \fi}
-
-%D \macros
-%D {getsubstring}
-%D \startbuffer
-%D
-%D \getsubstring{4}{}{Who Wants This}
-%D \getsubstring{4}{9}{Who Wants This}
-%D \getsubstring{9}{-2}{Who Wants This}
-%D \getsubstring{1}{5}{Who Wants This}
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startlines
-%D \getbuffer
-%D \stoplines
-
-% expandable:
-
-\def\getsubstring#1#2#3{\clf_getsubstring{#3}{#1}{#2}}
-
-%D Other dimensions than pt (used in mb-mp)
-
-\def\converteddimen#1#2{\clf_converteddimen\dimexpr#1\relax{#2}}
-
-%D Maybe (looks ugly):
-%D
-%D \starttyping
-%D \doifcase {foo}
-%D {bar} {BAR}
-%D {foo} {FOO}
-%D {default} {DEFAULT}
-%D
-%D \doifcase {foo}
-%D {bar} {BAR}
-%D {foo} {\doifcase {bar}
-%D {bar} {BAR}
-%D {foo} {FOO}
-%D {default} {DEFAULT}
-%D }
-%D {default} {DEFAULT}
-%D \stoptyping
-
-% \doifcase {\btxfoundname{author}}
-% {author} {\btxflush{author}}
-% {editor} {\texdefinition{btx:apa:editor-or-editors}}
-% {title} {\texdefinition{btx:apa:title-subtitle-type}}
-% {default} {\btxflush{author}}
-
-% \unexpanded\def\doifcase#1%
-% {\edef\m_case_asked{#1}%
-% \syst_aux_case}
-%
-% \def\syst_aux_case#1%
-% {\edef\m_case_temp{#1}%
-% \ifx\m_case_temp\m_case_asked
-% \expandafter\syst_aux_case_yes
-% \orelse\ifx\m_case_temp\s!default
-% \expandafter\firstofoneargument
-% \else
-% \expandafter\syst_aux_case_nop
-% \fi}
-%
-% \def\syst_aux_skip#1#2%
-% {\edef\m_case_temp{#1}%
-% \ifx\m_case_temp\s!default
-% \expandafter\syst_aux_done
-% \else
-% \expandafter\syst_aux_skip
-% \fi}
-%
-% \def\syst_aux_case_yes#1%
-% {\def\syst_aux_done{#1}%
-% \syst_aux_skip}
-%
-% \def\syst_aux_case_nop#1%
-% {\syst_aux_case}
-
-%D \macros
-%D {ntimes}
-%D
-%D some repetition:
-%D
-%D \startbuffer
-%D \ntimes{*}{20}
-%D \stopbuffer
-%D
-%D \typebuffer \blank gives: \getbuffer \blank
-%D
-%D This is not real fast but quite okay:
-
-%def\ntimes#1#2{\ifnum#2>\zerocount#1\ntimes{#1}{\numexpr#2-\plusone\relax}\fi} % 1.72
-\def\ntimes#1#2{\clf_ntimes{#1}\numexpr#2\relax} % 0.33
-
-%D Experiment (sometimes looks nicer in code):
-
-\unexpanded\def\sameargumentscondition#1#2%
- {\edef\m_syst_string_one{#1}%
- \edef\m_syst_string_two{#2}%
- \ifx\m_syst_string_one\m_syst_string_two}
-
-\unexpanded\def\emptyargumentcondition#1%
- {\edef\m_syst_string_one{#1}%
- \ifx\m_syst_string_one\empty}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-con.lua b/Master/texmf-dist/tex/context/base/mkiv/syst-con.lua
index 1af2d9a5d5e..6e998bdfd5e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-con.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-con.lua
@@ -30,12 +30,18 @@ function converters.octstringtonumber(n) tonumber(n, 8) end
function converters.rawcharacter (n) utfchar(0x110000+n) end
-local lchexnumber = formatters["%x"]
-local uchexnumber = formatters["%X"]
-local lchexnumbers = formatters["%02x"]
-local uchexnumbers = formatters["%02X"]
-local octnumber = formatters["%03o"]
-local nicenumber = formatters["%0.6F"]
+local f_lchexnumber = formatters["%x"]
+local f_uchexnumber = formatters["%X"]
+local f_lchexnumbers = formatters["%02x"]
+local f_uchexnumbers = formatters["%02X"]
+local f_octnumber = formatters["%03o"]
+local nicenumber = formatters["%0.6F"]
+
+local lchexnumber = function(n) if n < 0 then n = 0x100000000 + n end return f_lchexnumber (n) end
+local uchexnumber = function(n) if n < 0 then n = 0x100000000 + n end return f_uchexnumber (n) end
+local lchexnumbers = function(n) if n < 0 then n = 0x100000000 + n end return f_lchexnumbers(n) end
+local uchexnumbers = function(n) if n < 0 then n = 0x100000000 + n end return f_uchexnumbers(n) end
+local octnumber = function(n) if n < 0 then n = 0x100000000 + n end return f_octnumber (n) end
converters.lchexnumber = lchexnumber
converters.uchexnumber = uchexnumber
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkiv
index 56155460a90..ddd65865d22 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkiv
@@ -84,14 +84,14 @@
%D \macros{setcalculatedsin,setcalculatedcos,setcalculatedtan}
-\unexpanded\def\setcalculatedsin#1#2{\edef#1{\clf_sind#2}}
-\unexpanded\def\setcalculatedcos#1#2{\edef#1{\clf_cosd#2}}
-\unexpanded\def\setcalculatedtan#1#2{\edef#1{\clf_tand#2}}
+\protected\def\setcalculatedsin#1#2{\edef#1{\clf_sind#2}}
+\protected\def\setcalculatedcos#1#2{\edef#1{\clf_cosd#2}}
+\protected\def\setcalculatedtan#1#2{\edef#1{\clf_tand#2}}
%D \macros{formatted,format}
- \def\formatted#1{\ctxcommand{format(#1)}} % not clf
-\unexpanded\def\format #1{\ctxcommand{format(#1)}} % not clf
+ \def\formatted#1{\ctxcommand{format(#1)}} % not clf
+\protected\def\format #1{\ctxcommand{format(#1)}} % not clf
%D The \type {\modulatednumber} and \type {\realnumber} macros have been removed.
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkxl b/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkxl
deleted file mode 100644
index c3293b221f8..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-con.mkxl
+++ /dev/null
@@ -1,93 +0,0 @@
-%D \module
-%D [ file=syst-con,
-%D version=2006.09.16, % real old stuff ... 2000.12.10
-%D title=\CONTEXT\ System Macros,
-%D subtitle=Conversions,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\registerctxluafile{syst-con}{}
-
-\unprotect
-
-%D \macros{lchexnumber,uchexnumber,lchexnumbers,uchexnumbers}
-%D
-%D In addition to the uppercase hex conversion, as needed in math families, we
-%D occasionally need a lowercase one.
-
-\def\lchexnumber #1{\clf_lchexnumber \numexpr#1\relax}
-\def\uchexnumber #1{\clf_uchexnumber \numexpr#1\relax}
-\def\lchexnumbers#1{\clf_lchexnumbers\numexpr#1\relax}
-\def\uchexnumbers#1{\clf_uchexnumbers\numexpr#1\relax}
-
-\let\hexnumber\uchexnumber
-
-%D \macros{octnumber}
-%D
-%D For \UNICODE\ remapping purposes, we need octal numbers.
-
-\def\octnumber#1{\clf_octnumber\numexpr#1\relax}
-
-%D \macros{hexstringtonumber,octstringtonumber}
-%D
-%D This macro converts a two character hexadecimal number into a decimal number,
-%D thereby taking care of lowercase characters as well.
-
-\def\hexstringtonumber#1{\clf_hexstringtonumber\numexpr#1\relax}
-\def\octstringtonumber#1{\clf_octstringtonumber\numexpr#1\relax}
-
-%D \macros{rawcharacter}
-%D
-%D This macro can be used to produce proper 8 bit characters that we sometimes need
-%D in backends and round||trips.
-
-\def\rawcharacter#1{\clf_rawcharacter\numexpr#1\relax}
-
-%D \macros{twodigits, threedigits}
-%D
-%D These macros provides two or three digits always:
-
-\def\twodigits #1{\ifnum #1<10 0\fi\number#1}
-\def\threedigits#1{\ifnum#1<100 \ifnum#1<10 0\fi0\fi\number#1}
-
-%D \macros{modulonumber}
-%D
-%D In the conversion macros described in \type {core-con} we need a wrap||around
-%D method. The following solution is provided by Taco.
-%D
-%D The \type {modulonumber} macro expands to the mathematical modulo of a positive
-%D integer. It is crucial for it's application that this macro is fully exandable.
-%D
-%D The expression inside the \type {\numexpr} itself is somewhat bizarre because
-%D \ETEX\ uses a rounding division instead of truncation. If \ETEX's division would
-%D have behaved like \TEX's normal\type {\divide}, then the expression could have
-%D been somewhat simpler, like \type {#2-(#2/#1)*#1}. This works just as well, but a
-%D bit more complex.
-%D
-%D \starttyping
-%D \def\modulonumber#1#2{\the\numexpr#2-((((#2+(#1/2))/#1)-1)*#1)\relax}
-%D \stoptyping
-%D
-%D But \unknown\ now we can also do this:
-
-\def\modulonumber#1#2{\the\numexpr#2-(#2:#1)*#1\relax}
-
-%D \macros{setcalculatedsin,setcalculatedcos,setcalculatedtan}
-
-\unexpanded\def\setcalculatedsin#1#2{\edef#1{\clf_sind#2}}
-\unexpanded\def\setcalculatedcos#1#2{\edef#1{\clf_cosd#2}}
-\unexpanded\def\setcalculatedtan#1#2{\edef#1{\clf_tand#2}}
-
-%D \macros{formatted,format}
-
- \def\formatted#1{\ctxcommand{format(#1)}} % not clf
-\unexpanded\def\format #1{\ctxcommand{format(#1)}} % not clf
-
-%D The \type {\modulatednumber} and \type {\realnumber} macros have been removed.
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-fnt.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-fnt.mkiv
index cacc5f51740..83b57f5f726 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-fnt.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-fnt.mkiv
@@ -15,28 +15,23 @@
\unprotect
-\def\fontslantperpoint {\fontdimen\plusone }
-\def\fontinterwordspace {\fontdimen\plustwo }
-\def\fontinterwordstretch{\fontdimen\plusthree}
-\def\fontinterwordshrink {\fontdimen\plusfour }
-\def\fontexheight {\fontdimen\plusfive }
-\def\fontemwidth {\fontdimen\plussix }
-\def\fontextraspace {\fontdimen\plusseven}
-
-\def\slantperpoint {\fontdimen\plusone \font}
-\def\interwordspace {\fontdimen\plustwo \font}
-\def\interwordstretch {\fontdimen\plusthree\font}
-\def\interwordshrink {\fontdimen\plusfour \font}
-\def\exheight {\fontdimen\plusfive \font}
-\def\emwidth {\fontdimen\plussix \font}
-\def\extraspace {\fontdimen\plusseven\font}
-
-\def\mathsupdisplay {\fontdimen13 } % to be remapped
-\def\mathsupnormal {\fontdimen14 } % to be remapped
-\def\mathsupcramped {\fontdimen15 } % to be remapped
-\def\mathsubnormal {\fontdimen16 } % to be remapped
-\def\mathsubcombined {\fontdimen17 } % to be remapped
-\def\mathaxisheight {\fontdimen22 } % to be remapped
+\protected\def\fontslantperpoint {\fontdimen\plusone }
+\protected\def\fontinterwordspace {\fontdimen\plustwo }
+\protected\def\fontinterwordstretch{\fontdimen\plusthree}
+\protected\def\fontinterwordshrink {\fontdimen\plusfour }
+\protected\def\fontexheight {\fontdimen\plusfive }
+\protected\def\fontemwidth {\fontdimen\plussix }
+\protected\def\fontextraspace {\fontdimen\plusseven}
+
+\protected\def\slantperpoint {\fontdimen\plusone \font}
+\protected\def\interwordspace {\fontdimen\plustwo \font}
+\protected\def\interwordstretch {\fontdimen\plusthree\font}
+\protected\def\interwordshrink {\fontdimen\plusfour \font}
+\protected\def\exheight {\fontdimen\plusfive \font}
+\protected\def\emwidth {\fontdimen\plussix \font}
+\protected\def\extraspace {\fontdimen\plusseven\font}
+
+\let \mathaxisheight \Umathaxis % takes style
\def\currentspaceskip {\interwordspace\s!plus\interwordstretch\s!minus\interwordshrink\relax}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkiv
index 0dd1fe29cf6..aafbc787e5e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkiv
@@ -58,7 +58,9 @@
\chardef\primeasciicode 39 % '
\chardef\leftparentasciicode 40
\chardef\rightparentasciicode 41
+\chardef\commaasciicode 44
\chardef\hyphenasciicode 45
+\chardef\periodasciicode 46
\chardef\forwardslashasciicode 47 % /
\chardef\colonasciicode 58
\chardef\lessthanasciicode 60 % < used as alternative verbatim {
@@ -233,21 +235,21 @@
%D The allocators share a common helper macro.
-\normalprotected\def\newcount {\syst_basics_allocate\c_syst_last_allocated_count \count \countdef \c_syst_max_allocated_register}
-\normalprotected\def\newdimen {\syst_basics_allocate\c_syst_last_allocated_dimen \dimen \dimendef \c_syst_max_allocated_register}
-\normalprotected\def\newskip {\syst_basics_allocate\c_syst_last_allocated_skip \skip \skipdef \c_syst_max_allocated_register}
-\normalprotected\def\newmuskip {\syst_basics_allocate\c_syst_last_allocated_muskip \muskip \muskipdef \c_syst_max_allocated_register}
-\normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \mathchardef\c_syst_max_allocated_register}
-\normalprotected\def\newtoks {\syst_basics_allocate\c_syst_last_allocated_toks \toks \toksdef \c_syst_max_allocated_register}
-\normalprotected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \chardef \c_syst_max_allocated_read}
-\normalprotected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \chardef \c_syst_max_allocated_write}
-\normalprotected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \mathchardef\c_syst_max_allocated_register}
-\normalprotected\def\newinsert {\syst_basics_allocate\c_syst_last_allocated_insertion\insert \chardef \c_syst_max_allocated_insert}
+\protected\def\newcount {\syst_basics_allocate\c_syst_last_allocated_count \count \countdef \c_syst_max_allocated_register}
+\protected\def\newdimen {\syst_basics_allocate\c_syst_last_allocated_dimen \dimen \dimendef \c_syst_max_allocated_register}
+\protected\def\newskip {\syst_basics_allocate\c_syst_last_allocated_skip \skip \skipdef \c_syst_max_allocated_register}
+\protected\def\newmuskip {\syst_basics_allocate\c_syst_last_allocated_muskip \muskip \muskipdef \c_syst_max_allocated_register}
+\protected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \mathchardef\c_syst_max_allocated_register}
+\protected\def\newtoks {\syst_basics_allocate\c_syst_last_allocated_toks \toks \toksdef \c_syst_max_allocated_register}
+\protected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \chardef \c_syst_max_allocated_read}
+\protected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \chardef \c_syst_max_allocated_write}
+\protected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \mathchardef\c_syst_max_allocated_register}
+\protected\def\newinsert {\syst_basics_allocate\c_syst_last_allocated_insertion\insert \chardef \c_syst_max_allocated_insert}
%D We don't need these in \CONTEXT:
-\normalprotected\def\newlanguage{\syst_basics_allocate\c_syst_last_allocated_language \language\chardef \c_syst_max_allocated_language}
-\normalprotected\def\newfamily {\syst_basics_allocate\c_syst_last_allocated_family \fam \chardef \c_syst_max_allocated_family}
+\protected\def\newlanguage{\syst_basics_allocate\c_syst_last_allocated_language \language\chardef \c_syst_max_allocated_language}
+\protected\def\newfamily {\syst_basics_allocate\c_syst_last_allocated_family \fam \chardef \c_syst_max_allocated_family}
\let\newfam\newfamily
@@ -256,10 +258,10 @@
% Watch out, for the moment we disable the check for already being defined
% later we will revert this but first all chardefs must be replaced.
-\normalprotected\def\newconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1}
-\normalprotected\def\setnewconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1#1} % just a number
-\normalprotected\def\setconstant {} % dummy, no checking, so it warns
-\normalprotected\def\setconstantvalue#1#2{\csname#1\endcsname\numexpr#2\relax}
+\protected\def\newconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1}
+\protected\def\setnewconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1#1} % just a number
+\protected\def\setconstant {} % dummy, no checking, so it warns
+\protected\def\setconstantvalue#1#2{\csname#1\endcsname\numexpr#2\relax}
% maybe setconstant with check
@@ -274,8 +276,8 @@
%D as all engines now provide many registers we removed all traces.
\ifdefined\writestatus \else
- %\normalprotected\def\writestatus#1#2{\immediate\write\statuswrite{#1: #2}}
- \normalprotected\def\writestatus#1#2{\message{#1: #2}}
+ %\protected\def\writestatus#1#2{\immediate\write\statuswrite{#1: #2}}
+ \protected\def\writestatus#1#2{\message{#1: #2}}
\fi
\def\syst_basics_allocate_yes#1#2#3#4#5% last class method max name
@@ -302,8 +304,8 @@
%D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of
%D the more limited \type {\mathchardef}.
-\normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \chardef\c_syst_max_allocated_register}
-\normalprotected\def\newmarks{\syst_basics_allocate\c_syst_last_allocated_marks\marks\chardef\c_syst_max_allocated_register}
+\protected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \chardef\c_syst_max_allocated_register}
+\protected\def\newmarks{\syst_basics_allocate\c_syst_last_allocated_marks\marks\chardef\c_syst_max_allocated_register}
%D Attributes are something very \LUATEX. In \CONTEXT\ you are not supposed to use
%D the attributes directly but always allocate then first. For instance attribute~0
@@ -312,14 +314,14 @@
\let\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone
-\normalprotected\def\newattribute{\syst_basics_allocate\c_syst_last_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register}
+\protected\def\newattribute{\syst_basics_allocate\c_syst_last_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register}
%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a trick to force
%D strings instead of tokens that take more memory. It's a trick to trick to force
%D strings. This macro is never used in \CONTEXT.
-%normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}}
-\normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\detokenize{#2}}}
+%protected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}}
+\protected\def\newhelp#1#2{\newtoks#1#1\expandafter{\detokenize{#2}}}
%D \macros
%D {scratchcounter,
@@ -442,6 +444,8 @@
\chardef \pluseight 8
\chardef \plusnine 9
\chardef \plusten 10
+\chardef \pluseleven 11
+\chardef \plustwelve 12
\chardef \plussixteen 16
\chardef \plusfifty 50
\chardef \plushundred 100
@@ -488,7 +492,7 @@
%D
%D We need this one soon:
-\normalprotected\def\dontcomplain
+\protected\def\dontcomplain
{\hbadness\plustenthousand
\vbadness\plustenthousand
\hfuzz \maxdimen
@@ -522,7 +526,7 @@
%D creates \type {\footrue}, \type {\foofalse} to go with \type {\iffoo}.
%D \stopnarrower
-% \normalprotected\def\newif#1%
+% \protected\def\newif#1%
% {\count@\escapechar
% \escapechar\minusone
% \expandafter\expandafter\expandafter\def\new_if #1{true}{\let#1\iftrue }%
@@ -540,7 +544,7 @@
% We use \csstring so there is no need to push/pop escapechar.
% We use different names so that we get a better error message.
%
-% \normalprotected\def\newif#1%
+% \protected\def\newif#1%
% {\let\new_if_saved\newif
% \let\newif\new_if_check
% \expandafter\expandafter\expandafter\def\new_if_cs #1{true}{\let#1\iftrue }%
@@ -548,12 +552,12 @@
% \new_if_cs#1{false}%
% \let\newif\new_if_saved}
%
-% \normalprotected\def\new_if_cs#1#2%
+% \protected\def\new_if_cs#1#2%
% {\csname\expandafter\newif\csstring#1#2\endcsname}
%
% We wrap all into one macro:
-\normalprotected\def\newif#1%
+\protected\def\newif#1%
{\let\new_if_saved\newif
\let\newif\new_if_check
\expandafter\def\csname\expandafter\newif\csstring#1true\endcsname {\let#1\iftrue }%
@@ -574,10 +578,21 @@
%D A few shortcuts:
-\normalprotected\def\udef {\normalprotected\def }
-\normalprotected\def\ugdef{\normalprotected\gdef}
-\normalprotected\def\uedef{\normalprotected\edef}
-\normalprotected\def\uxdef{\normalprotected\xdef}
+\protected\def\udef {\protected\def }
+\protected\def\ugdef{\protected\gdef}
+\protected\def\uedef{\protected\edef}
+\protected\def\uxdef{\protected\xdef}
+
+% For now:
+
+\protected\def\defUmathtopaccent #1#2#3#4{\global\instance\protected\def#1{\Umathaccent "#2 "#3 "#4 }}
+\protected\def\defUmathbotaccent #1#2#3#4{\global\instance\protected\def#1{\Umathbotaccent "#2 "#3 "#4 }}
+\protected\def\defUdelimiterover #1#2#3#4{\global\instance\protected\def#1{\Udelimiterover "#2 "#3 }}
+\protected\def\defUdelimiterunder #1#2#3#4{\global\instance\protected\def#1{\Udelimiterunder "#2 "#3 }}
+\protected\def\defUdelimiter #1#2#3#4{\global\instance\protected\def#1{\Udelimiter "#2 "#2 "#4 }}
+\protected\def\defUradical #1#2#3{\global\instance\protected\def#1{\Uradical "#2 "#3 }}
+\protected\def\defUroot #1#2#3{\global\instance\protected\def#1{\Uroot "#2 "#3 }}
+\protected\def\defUmathchar #1#2#3#4{\global\instance\Umathchardef #1 "#2 "#3 "#4 }
%D For a while we keep the following, as systems like tikz need it. Best
%D not use that one \CONTEXT.
@@ -694,7 +709,7 @@
% no longer \errorstopmode cf. plain tex 3.141592653
-\normalprotected\def\tracingall
+\protected\def\tracingall
{\tracingonline \plusone
\tracingcommands \plusthree
\tracingstats \plustwo
@@ -712,11 +727,11 @@
\tracingnesting \plustwo
\tracingassigns \plustwo}
-\normalprotected\def\loggingall
+\protected\def\loggingall
{\tracingall
\tracingonline \zerocount}
-\normalprotected\def\tracingnone
+\protected\def\tracingnone
{\tracingassigns \zerocount
\tracingnesting \zerocount
\tracingscantokens\zerocount
@@ -759,7 +774,7 @@
\newtoks\everydump
-\def\dump{\the\everydump\normaldump}
+\def\dump{\the\everydump\global\everydump\emptytoks\glet\dump\relax\normaldump}
%D The same applies for the startup actions.
@@ -809,11 +824,11 @@
\let\conditionalfalse\plusone % maybe we will have a dedicated count/chardef
\let\conditionaltrue \zerocount % maybe we will have a dedicated count/chardef
-\normalprotected\def\settrue #1{\let#1\conditionaltrue }
-\normalprotected\def\setfalse#1{\let#1\conditionalfalse}
+\protected\def\settrue #1{\let#1\conditionaltrue }
+\protected\def\setfalse#1{\let#1\conditionalfalse}
-\normalprotected\def\settruevalue #1{\expandafter\let\csname#1\endcsname\conditionaltrue }
-\normalprotected\def\setfalsevalue#1{\expandafter\let\csname#1\endcsname\conditionalfalse}
+\protected\def\settruevalue #1{\expandafter\let\csname#1\endcsname\conditionaltrue }
+\protected\def\setfalsevalue#1{\expandafter\let\csname#1\endcsname\conditionalfalse}
\let\newconditional\setfalse
\let\ifconditional \ifcase
@@ -829,13 +844,13 @@
%D Let's be complete and also introduce some definers. These are not mandate
%D but handy for grepping.
-\normalprotected\def\newmacro #1{\let#1\empty}
-\normalprotected\def\setnewmacro#1{\let#1}
+\protected\def\newmacro #1{\let#1\empty}
+\protected\def\setnewmacro#1{\let#1}
\def\!!zerocount{0}
\def\!!plusone {1}
-\normalprotected\def\newfraction#1{\let#1\!!plusone}
+\protected\def\newfraction#1{\let#1\!!plusone}
%D It would be handy to have a primitive \type {\unless\ifcase} because then we
%D could use nicer values. Anyhow, this conditional code used to be in the \type
@@ -857,19 +872,19 @@
%
% we assume a \cs. not toks0 or so
%
-% \normalprotected\def\appendtotoks #1#{\def\temp{#1}\afterassignment\doappendtotoks \scratchtoks=}
-% \normalprotected\def\prependtotoks#1#{\def\temp{#1}\afterassignment\doprependtotoks\scratchtoks=}
+% \protected\def\appendtotoks #1#{\def\temp{#1}\afterassignment\doappendtotoks \scratchtoks=}
+% \protected\def\prependtotoks#1#{\def\temp{#1}\afterassignment\doprependtotoks\scratchtoks=}
\newtoks\t_syst_toks_temp \let\m_syst_toks_temp\t_syst_toks_temp
-\normalprotected\def\appendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_l \t_syst_toks_temp=}
-\normalprotected\def\prependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_l\t_syst_toks_temp=}
+\protected\def\appendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_l \t_syst_toks_temp=}
+\protected\def\prependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_l\t_syst_toks_temp=}
% \def\syst_toks_append {\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\m_syst_toks_temp\the\t_syst_toks_temp}}}
% \def\syst_toks_prepend{\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\t_syst_toks_temp\the\m_syst_toks_temp}}}
-\normalprotected\def\globalappendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_g \t_syst_toks_temp=}
-\normalprotected\def\globalprependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_g\t_syst_toks_temp=}
+\protected\def\globalappendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_g \t_syst_toks_temp=}
+\protected\def\globalprependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_g\t_syst_toks_temp=}
\def\syst_toks_append_l {\normalexpanded{\m_syst_toks_temp{\the\m_syst_toks_temp\the\t_syst_toks_temp}}}
\def\syst_toks_prepend_l{\normalexpanded{\m_syst_toks_temp{\the\t_syst_toks_temp\the\m_syst_toks_temp}}}
@@ -877,14 +892,14 @@
\def\syst_toks_append_g {\global\syst_toks_append_l }
\def\syst_toks_prepend_g{\global\syst_toks_prepend_l}
-\normalprotected\def\addtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_l\let\next}
-\normalprotected\def\globaladdtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_g\let\next}
+\protected\def\addtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_l\let\next}
+\protected\def\globaladdtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_g\let\next}
\def\syst_toks_add_l{\m_syst_toks_temp\expandafter\bgroup\the\m_syst_toks_temp}
\def\syst_toks_add_g{\global\syst_toks_add_l}
-\normalprotected\def\addtotokscs #1#2{#1{\the#1#2}} % saves a few bytes
-\normalprotected\def\globaladdtotokscs#1#2{\global#1{\the#1#2}} % saves a few bytes
+\protected\def\addtotokscs #1#2{#1{\the#1#2}} % saves a few bytes
+\protected\def\globaladdtotokscs#1#2{\global#1{\the#1#2}} % saves a few bytes
%D \macros
%D {begcsname}
@@ -903,20 +918,20 @@
%
% \newtoks\everyendpar
%
-% \normalprotected\def\endpar{\the\everyendpar\normalpar}
-% \normalprotected\def\par {\endpar}
+% \protected\def\endpar{\the\everyendpar\normalpar}
+% \protected\def\par {\endpar}
%
-% \normalprotected\def\reseteverypar
+% \protected\def\reseteverypar
% {\everypar \emptytoks
% \everyendpar\emptytoks}
-\normalprotected\def\reseteverypar
+\protected\def\reseteverypar
{\everypar\emptytoks}
\let\endgraf\par
\let\endline\cr
-\normalprotected\def\null{\hpack{}}
+\protected\def\null{\hpack{}}
%D The following two might be overloaded later on but some modules need then
%D earlier. These functionality is reflected in the name and will not change.
@@ -995,8 +1010,11 @@
%D Sometimes kerns make more sense than glue but we need to be in the
%D right mode:
-\normalprotected\def\vkern{\ifhmode\par \fi\kern}
-\normalprotected\def\hkern{\ifvmode\dontleavehmode\fi\kern}
+\protected\def\vkern {\ifhmode\par \fi\kern}
+\protected\def\hkern {\ifvmode\dontleavehmode\fi\kern}
+
+\protected\def\vpenalty{\ifhmode\par \fi\penalty}
+\protected\def\hpenalty{\ifvmode\dontleavehmode\fi\penalty}
%D Again a few kind-of-extensions the core. These come from plain \TEX\ but
%D are probably not used in \CONTEXT.
@@ -1132,9 +1150,34 @@
\matheqnogapstep\zerocount % for now
-%D Experiment:
-
-\ifdefined\frozen \else \def\frozen{} \let\normalfrozen\frozen \fi
+%D For as long as we share code between \MKIV\ and \LMTX\ we need these:
+
+\ifdefined\overloadmode \else
+ \newcount\overloadmode
+ %
+ \let\frozen \empty
+ \let\tolerant \empty
+ \let\overloaded\empty
+ \let\aliased \empty
+ \let\permanent \empty
+ \let\immutable \empty
+ \let\mutable \empty
+ \let\instance \empty
+ \let\noaligned \empty
+ \let\enforced \empty
+ %
+ \let\unletfrozen\gobbleoneargument
+ \let\letfrozen \gobbleoneargument
+ \def\letcsname {\expandafter\let \csname}
+ \def\defcsname {\expandafter\def \csname}
+ \def\edefcsname {\expandafter\edef\csname}
+ %
+ \let\pushoverloadmode\relax
+ \let\popoverloadmode\relax
+
+ \let\pushrunstate\relax
+ \let\poprunstate \relax
+\fi
%D Now we define a few helpers that we need in a very early stage. We have no
%D message system yet but redundant definitions are fatal anyway.
@@ -1144,7 +1187,7 @@
\def\v_interfaces_prefix_template_system{\number \c_syst_helpers_n_of_namespaces>>}
%def\v_interfaces_prefix_template_system{\characters\c_syst_helpers_n_of_namespaces>>} % no \characters yet
-\normalprotected\def\installsystemnamespace#1%
+\protected\def\installsystemnamespace#1%
{\ifcsname ??#1\endcsname
\immediate\write\statuswrite{fatal error: duplicate system namespace '#1'}%
\expandafter\normalend
@@ -1174,4 +1217,27 @@
\let\eTeXglueshrinkorder \undefined
\let\eTeXgluestretchorder\undefined
+%D Experiment:
+
+\ifdefined\glyphdimensionsmode \else \newcount\glyphdimensionsmode \fi
+
+\glyphdimensionsmode\plusone
+
+%D For completeness (tokenizer commands have complements), so this one complements
+%D \type {\detokenize}, like \type {\expanded} and \type {\unexpanded}. Not that we
+%D ever needed this one:
+
+\ifdefined \tokenized \else
+ \def\tokenized#1{\scantextokens\expandafter{\normalexpanded{#1}}}
+\fi
+
+\ifdefined \unhpack \else
+ \let\unhpack\unhbox
+ \let\unvpack\unvbox
+\fi
+
+%D Needed:
+
+\let\nexttoken\relax
+
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkxl b/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkxl
deleted file mode 100644
index 9394807c8da..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-ini.mkxl
+++ /dev/null
@@ -1,1116 +0,0 @@
-%D \module
-%D [ file=syst-ini,
-%D version=2008.11.04, % 2001.11.16, % 1999.03.17, % an oldie: 1995.10.10
-%D title=\CONTEXT\ System Macros,
-%D subtitle=Bootstrapping \TEX,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D We used to load plain \TEX\ in a special way, but redefining a couple of
-%D primitives so that for instance font loading was ignored. For those interested,
-%D this loader is found in \type {syst-tex.tex}. Some of the comment's are Don
-%D Knuths and more of it can be found in the plain \TEX\ format.
-%D
-%D Characters can have special states, that can be triggered by setting their
-%D category coded. Some are preset, others are to be set as soon as possible,
-%D otherwise we cannot define any useful macros.
-%D
-%D First we define a bunch of constants. Normally we would \type {\setconstant}
-%D but we're prestine and have no macros defined yet. Abstraction also makes it
-%D possible to avoid the \type {^^} in the input.
-
-\chardef\escapecatcode 0
-\chardef\begingroupcatcode 1
-\chardef\endgroupcatcode 2
-\chardef\mathshiftcatcode 3
-\chardef\alignmentcatcode 4
-\chardef\endoflinecatcode 5
-\chardef\parametercatcode 6
-\chardef\superscriptcatcode 7
-\chardef\subscriptcatcode 8
-\chardef\ignorecatcode 9
-\chardef\spacecatcode 10
-\chardef\lettercatcode 11
-\chardef\othercatcode 12 % finally obsolete: \let\other \othercatcode
-\chardef\activecatcode 13 % finally obsolete: \let\active\activecatcode
-\chardef\commentcatcode 14
-\chardef\invalidcatcode 15
-
-%chardef\zeroasciicode 0
-\chardef\tabasciicode 9
-\chardef\newlineasciicode 10 % don't confuse this one with \endoflineasciicode
-\chardef\formfeedasciicode 12
-\chardef\endoflineasciicode 13 % somewhat messy but this can be the active \par
-\chardef\endoffileasciicode 26
-\chardef\spaceasciicode 32
-\chardef\exclamationmarkasciicode 33 % ! used in namespace protection
-\chardef\doublequoteasciicode 34 % "
-\chardef\hashasciicode 35
-\chardef\dollarasciicode 36
-\chardef\commentasciicode 37
-\chardef\ampersandasciicode 38
-\chardef\singlequoteasciicode 39 % '
-\chardef\primeasciicode 39 % '
-\chardef\leftparentasciicode 40
-\chardef\rightparentasciicode 41
-\chardef\hyphenasciicode 45
-\chardef\forwardslashasciicode 47 % /
-\chardef\colonasciicode 58
-\chardef\lessthanasciicode 60 % < used as alternative verbatim {
-\chardef\morethanasciicode 62 % > used as alternative verbatim }
-\chardef\questionmarkasciicode 63 % ? used in namespace protection
-\chardef\atsignasciicode 64 % @ used in namespace protection
-\chardef\backslashasciicode 92 % `\\
-\chardef\circumflexasciicode 94
-\chardef\underscoreasciicode 95
-\chardef\leftbraceasciicode 123 % `\{
-\chardef\barasciicode 124 % `\|
-\chardef\rightbraceasciicode 125 % `\}
-\chardef\tildeasciicode 126 % `\~
-\chardef\delasciicode 127
-
-%catcode\zeroasciicode \ignorecatcode % `\^^@ ascii null is ignored
-\catcode\tabasciicode \spacecatcode % `\^^I ascii tab is a blank space
-\catcode\formfeedasciicode \activecatcode % `\^^L ascii form-feed (active, set later)
-%catcode\endoflineasciicode \endoflinecatcode % `\^^M ascii return is end-line
-\catcode\endoffileasciicode \ignorecatcode % `\^^Z endoffile (ignored in ConTeXt)
-%catcode\spaceasciicode \spacecatcode % `\ ascii space is blank space
-\catcode\hashasciicode \parametercatcode % `\# hash mark is macro parameter character
-\catcode\dollarasciicode \mathshiftcatcode % `\$ dollar sign is math shift
-%catcode\commentasciicode \commentcatcode % `\% percent sign is comment character
-\catcode\ampersandasciicode \alignmentcatcode % `\& ampersand is alignment tab
-%catcode\backslashasciicode \escapecatcode % `\\ backslash is TeX escape character
-\catcode\circumflexasciicode \superscriptcatcode % `\^ circumflex and uparrow are for superscripts
-\catcode\underscoreasciicode \subscriptcatcode % `\_ underline and downarrow are for subscripts
-\catcode\leftbraceasciicode \begingroupcatcode % `\{ left brace is begin-group character
-\catcode\rightbraceasciicode \endgroupcatcode % `\} right brace is end-group character
-\catcode\tildeasciicode \activecatcode % `\~ tilde is active
-%catcode\delasciicode \invalidcatcode % `\^^? ascii delete is invalid
-
-\chardef\statuswrite 128
-
-%D First we need to initialization the primitives. Because \CONTEXT\ is already a
-%D pretty old macro package, we have a couple of issues with respect to primitives.
-%D The \ETEX\ engine added a few as did \PDFTEX. The \LUATEX\ engine added even
-%D more. This means that there can be a potential clash between primitives and
-%D existing macros. The most noticeable ones are:
-%D
-%D \starttyping
-%D \protected
-%D \expanded
-%D \unexpanded
-%D \stoptyping
-%D
-%D Because we had macros like that before the primitives showed up. The protection
-%D related macros were there before we even knew about extensions to the engine.
-%D When the expansion related ones were introduced, we originally came up with
-%D different names but due to requests we used the current names, somethng that in
-%D retrospect was a bad idea: they should have gotten different names in \LUATEX, if
-%D only because at that time only \CONTEXT\ was using them in rolling releases.
-%D Anyway, we're now stuck with this situation, and it means that one should use the
-%D \type {\normal...} variants in low level code:
-%D
-%D \starttyping
-%D \normalexpanded
-%D \normalprotected
-%D \normalunexpanded
-%D \stoptyping
-%D
-%D In the end not using different names in \LUATEX\ for these kind of backfires. It
-%D makes not much sense to fix this in \LUAMETATEX\ because we're now to long on the
-%D road. It is actually the reason why we have the option in \LUATEX\ to alias all
-%D primitives in one go using a prefix. Actually this trick could be used to recover
-%D a primitive meaning: just enable it with some prefix and \type {\let} the
-%D original to that. But \unknown\ we prevent that trick below.
-%D
-%D The code below differs from \LUATEX: in \LUAMETATEX\ all primitives are already
-%D available; it cannot limit itself to being \TEX\ or \ETEX. It could not do that
-%D anyway because there are differences (no backend, to mention one).
-
-\directlua {
- local primitives = tex.extraprimitives() % "tex","etex","luatex"
- tex.enableprimitives("normal",primitives) % could default to everything
- function tex.enableprimitives() end % so we kind of protect what's there
-}
-
-\def\space{ }
-\def\empty{}
-
-\letcharcode \formfeedasciicode \par % \def ^^L{\par} formfeed
-\letcharcode \tildeasciicode \ % tilde
-\letcharcode \spaceasciicode \space % space
-
-\expandafter\def\csname\Uchar\tabasciicode \endcsname {\ } % \def\^^I{\ } tab
-\expandafter\def\csname\Uchar\formfeedasciicode \endcsname {\par} % \def\^^L{\par} formfeed
-\expandafter\def\csname\Uchar\endoflineasciicode\endcsname {\ } % \def\^^M{\ } return
-
-%D For now:
-
-\def\gobbleoneargument#1{} % will be defined later on anyway
-
-%D First we define a simplified version of the \CONTEXT\ protection mechanism.
-%D Later we will implement a better variant.
-
-\def\unprotect
- {\edef\protect
- {\catcode\atsignasciicode \the\catcode\atsignasciicode \relax
- \catcode\exclamationmarkasciicode\the\catcode\exclamationmarkasciicode\relax
- \catcode\questionmarkasciicode \the\catcode\questionmarkasciicode \relax
- \catcode\underscoreasciicode \the\catcode\underscoreasciicode \relax
- \let\protect\relax}%
- \catcode\atsignasciicode \lettercatcode
- \catcode\exclamationmarkasciicode\lettercatcode
- \catcode\questionmarkasciicode \lettercatcode
- \catcode\underscoreasciicode \lettercatcode}
-
-\let\protect\relax
-
-\unprotect
-
-%D Some pretty important definitions:
-
-\let\bgroup={
-\let\egroup=}
-
-%D \macros
-%D {normalbgroup,normalgroup}
-%D
-%D No comment.
-
-%D Allocation of registers is done slightly different than in plain \TEX. First of
-%D all we use different reserved counters. We also don't implement a family handler
-%D because users are not supposed to implement their own math. We reserve the lowest
-%D 31 registers for scratch purposes. Keep in mind that in the core engine some
-%D registers are reserved: counters 0 upto 9, and counter 255.
-%D
-%D As with plain \TEX\ we recommend that macro designers always use \type {\global}
-%D assignments with respect to registers numbered 1, 3, 5 \unknown\ 31, and always
-%D non||\type {\global} assignments with respect to registers 0, 2, 4, \unknown\ 30.
-%D This will prevent \quote {save stack buildup} that might otherwise occur.
-%D
-%D We reserve some registers for special (management) purposes:
-
-% 0 - 20 : scratch
-% 21 - 127 : internal
-% 128 - 254 : inserts
-% 255 : page
-% 256 - : user
-
-\countdef \c_syst_min_allocated_register = 52 \c_syst_min_allocated_register = 256 % can change
-\countdef \c_syst_max_allocated_register = 53 \c_syst_max_allocated_register = 32767
-\countdef \c_syst_min_allocated_read = 54 \c_syst_min_allocated_read = -1
-\countdef \c_syst_max_allocated_read = 55 \c_syst_max_allocated_read = 16
-\countdef \c_syst_min_allocated_language = 56 \c_syst_min_allocated_language = 0
-\countdef \c_syst_max_allocated_language = 57 \c_syst_max_allocated_language = 255
-\countdef \c_syst_min_allocated_insert = 58 \c_syst_min_allocated_insert = 128
-\countdef \c_syst_max_allocated_insert = 59 \c_syst_max_allocated_insert = 254
-\countdef \c_syst_min_allocated_family = 60 \c_syst_min_allocated_family = 128
-\countdef \c_syst_max_allocated_family = 61 \c_syst_max_allocated_family = 255
-\countdef \c_syst_min_allocated_attribute = 62 \c_syst_min_allocated_attribute = 1024 % 0-1023 : private
-\countdef \c_syst_min_allocated_write = 63 \c_syst_min_allocated_write = 0
-\countdef \c_syst_max_allocated_write = 64 \c_syst_max_allocated_write = 127
-
-\countdef \c_syst_last_allocated_count = 32 \c_syst_last_allocated_count = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_dimen = 33 \c_syst_last_allocated_dimen = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_skip = 34 \c_syst_last_allocated_skip = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_muskip = 35 \c_syst_last_allocated_muskip = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_box = 36 \c_syst_last_allocated_box = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_toks = 37 \c_syst_last_allocated_toks = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_read = 38 \c_syst_last_allocated_read = \c_syst_min_allocated_read
-\countdef \c_syst_last_allocated_write = 39 \c_syst_last_allocated_write = \c_syst_min_allocated_write
-\countdef \c_syst_last_allocated_marks = 40 \c_syst_last_allocated_marks = \c_syst_min_allocated_register
-\countdef \c_syst_last_allocated_language = 41 \c_syst_last_allocated_language = \c_syst_min_allocated_language % not used in context
-\countdef \c_syst_last_allocated_insertion = 42 \c_syst_last_allocated_insertion = \c_syst_min_allocated_insert
-\countdef \c_syst_last_allocated_family = 43 \c_syst_last_allocated_family = \c_syst_min_allocated_family % not used in context
-\countdef \c_syst_last_allocated_attribute = 44 \c_syst_last_allocated_attribute = \c_syst_min_allocated_attribute % not used in context
-
-\countdef \c_syst_min_counter_value = 125 \c_syst_min_counter_value = -"7FFFFFFF % beware, we use index 125 at the lua end
-\countdef \c_syst_max_counter_value = 126 \c_syst_max_counter_value = "7FFFFFFF % beware, we use index 126 at the lua end
-
-\countdef \zerocount = 120 \zerocount = 0
-\countdef \plusone = 121 \plusone = 1
-\countdef \minusone = 122 \minusone = -1
-
-\countdef \normalpagebox = 127 \normalpagebox = 255 % hardcoded in pdftex/xetex
-
-% Only to be used by developers in very special cases!
-
-% \def\lastallocatedcount {\the\c_syst_last_allocated_count}
-% \def\lastallocateddimen {\the\c_syst_last_allocated_dimen}
-% \def\lastallocatedskip {\the\c_syst_last_allocated_skip}
-% \def\lastallocatedmuskip {\the\c_syst_last_allocated_muskip}
-% \def\lastallocatedbox {\the\c_syst_last_allocated_dimen}
-% \def\lastallocatedtoks {\the\c_syst_last_allocated_toks}
-% \def\lastallocatedattribute{\the\c_syst_last_allocated_attribute}
-
-% A few traditional allocations (these might go):
-
-\countdef \count@ 255 % hm, used in \newif .. todo: replace it there
-\dimendef \dimen@ 0
-\dimendef \dimen@i 1 % global only
-\dimendef \dimen@ii 2
-
-%D So, effectively we start allocating from 256 and upwards. The inserts sit in the
-%D range 128 upto 254. Page numbers use the counters 0 upto 9 and the pagebox is
-%D 255. Users can use the scratch registers upto 31 without problem but all others
-%D are reserved.
-
-\let\wlog\gobbleoneargument % Let's get rid of this one.
-
-%D The allocators share a common helper macro.
-
-\normalprotected\def\newcount {\syst_basics_allocate\c_syst_last_allocated_count \count \countdef \c_syst_max_allocated_register}
-\normalprotected\def\newdimen {\syst_basics_allocate\c_syst_last_allocated_dimen \dimen \dimendef \c_syst_max_allocated_register}
-\normalprotected\def\newskip {\syst_basics_allocate\c_syst_last_allocated_skip \skip \skipdef \c_syst_max_allocated_register}
-\normalprotected\def\newmuskip {\syst_basics_allocate\c_syst_last_allocated_muskip \muskip \muskipdef \c_syst_max_allocated_register}
-\normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \mathchardef\c_syst_max_allocated_register}
-\normalprotected\def\newtoks {\syst_basics_allocate\c_syst_last_allocated_toks \toks \toksdef \c_syst_max_allocated_register}
-\normalprotected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \chardef \c_syst_max_allocated_read}
-\normalprotected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \chardef \c_syst_max_allocated_write}
-\normalprotected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \mathchardef\c_syst_max_allocated_register}
-\normalprotected\def\newinsert {\syst_basics_allocate\c_syst_last_allocated_insertion\insert \chardef \c_syst_max_allocated_insert}
-
-%D We don't need these in \CONTEXT:
-
-\normalprotected\def\newlanguage{\syst_basics_allocate\c_syst_last_allocated_language \language\chardef \c_syst_max_allocated_language}
-\normalprotected\def\newfamily {\syst_basics_allocate\c_syst_last_allocated_family \fam \chardef \c_syst_max_allocated_family}
-
-\let\newfam\newfamily
-
-\firstvalidlanguage\plusone
-
-% Watch out, for the moment we disable the check for already being defined
-% later we will revert this but first all chardefs must be replaced.
-
-\normalprotected\def\newconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1}
-\normalprotected\def\setnewconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1#1} % just a number
-\normalprotected\def\setconstant {} % dummy, no checking, so it warns
-\normalprotected\def\setconstantvalue#1#2{\csname#1\endcsname\numexpr#2\relax}
-
-% maybe setconstant with check
-
-% %D The next definitions are really needed (in \CONTEXT):
-
-\newlinechar\newlineasciicode \edef\outputnewlinechar{\Uchar\newlineasciicode} % {^^J}
-
-%D One reason to start high with allocation is that it permits us to allocate
-%D consecutive ranges more easily, for instance if for \MPLIB\ we want to allocate a
-%D continuous range of boxes. It also permits us to do a proper upward allocation
-%D for inserts. The current code evolved from code that dealt with older engines but
-%D as all engines now provide many registers we removed all traces.
-
-\ifdefined\writestatus \else
- %\normalprotected\def\writestatus#1#2{\immediate\write\statuswrite{#1: #2}}
- \normalprotected\def\writestatus#1#2{\message{#1: #2}}
-\fi
-
-\def\syst_basics_allocate_yes#1#2#3#4#5% last class method max name
- {\ifnum#1<#4\relax
- \global\advance#1\plusone
- \global#3#5=#1\relax
- \else
- \writestatus{warning}{no room for \string#2\space \string#5\space (max: \number#4)}%
- \fi}
-
-\def\syst_basics_allocate_nop#1#2#3#4#5% last class method max name
- {\writestatus{warning}{\string#2 \string#5 is already defined (\string\relax\space it first)}}
-
-\def\syst_basics_allocate#1#2#3#4#5% last class method max name
- {\ifx#5\undefined
- \expandafter\syst_basics_allocate_yes
- \else\ifx#5\relax
- \expandafter\expandafter\expandafter\syst_basics_allocate_yes
- \else
- \expandafter\expandafter\expandafter\syst_basics_allocate_nop
- \fi\fi
- #1#2#3#4#5}
-
-%D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of
-%D the more limited \type {\mathchardef}.
-
-\normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \chardef\c_syst_max_allocated_register}
-\normalprotected\def\newmarks{\syst_basics_allocate\c_syst_last_allocated_marks\marks\chardef\c_syst_max_allocated_register}
-
-%D Attributes are something very \LUATEX. In \CONTEXT\ you are not supposed to use
-%D the attributes directly but always allocate then first. For instance attribute~0
-%D is reserved for special purposes (this might change). Attributes in the range
-%D 128-1023 are private and should not be touched.
-
-\let\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone
-
-\normalprotected\def\newattribute{\syst_basics_allocate\c_syst_last_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register}
-
-%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a trick to force
-%D strings instead of tokens that take more memory. It's a trick to trick to force
-%D strings. This macro is never used in \CONTEXT.
-
-%normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}}
-\normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\detokenize{#2}}}
-
-%D \macros
-%D {scratchcounter,
-%D scratchdimen,scratchskip,scratchmuskip,
-%D scratchbox,
-%D scratchtoks}
-%D
-%D We now define a few scratch registers, so that successive loads at least have
-%D some available. The private ones are used in cases where we don't want to
-%D intrude on normal scratch ones.
-
-\newcount \scratchcounter \newcount \globalscratchcounter \newcount \privatescratchcounter
-\newdimen \scratchdimen \newdimen \globalscratchdimen \newdimen \privatescratchdimen
-\newskip \scratchskip \newskip \globalscratchskip \newskip \privatescratchskip
-\newmuskip\scratchmuskip \newmuskip\globalscratchmuskip \newmuskip\privatescratchmuskip
-\newtoks \scratchtoks \newtoks \globalscratchtoks \newtoks \privatescratchtoks
-\newbox \scratchbox \newbox \globalscratchbox \newbox \privatescratchbox
-
-\newcount\scratchcounterone \newcount\scratchcountertwo \newcount\scratchcounterthree
-\newdimen \scratchdimenone \newdimen \scratchdimentwo \newdimen \scratchdimenthree
-\newskip \scratchskipone \newskip \scratchskiptwo \newskip \scratchskipthree
-\newmuskip\scratchmuskipone \newmuskip\scratchmuskiptwo \newmuskip\scratchmuskipthree
-\newtoks \scratchtoksone \newtoks \scratchtokstwo \newtoks \scratchtoksthree
-\newbox \scratchboxone \newbox \scratchboxtwo \newbox \scratchboxthree
-
-\newcount\scratchcounterfour \newcount\scratchcounterfive \newcount\scratchcountersix
-\newdimen \scratchdimenfour \newdimen \scratchdimenfive \newdimen \scratchdimensix
-\newskip \scratchskipfour \newskip \scratchskipfive \newskip \scratchskipsix
-\newmuskip\scratchmuskipfour \newmuskip\scratchmuskipfive \newmuskip\scratchmuskipsix
-\newtoks \scratchtoksfour \newtoks \scratchtoksfive \newtoks \scratchtokssix
-\newbox \scratchboxfour \newbox \scratchboxfive \newbox \scratchboxsix
-
-\newcount\globalscratchcounterone
-\newcount\globalscratchcountertwo
-\newcount\globalscratchcounterthree
-
-%D \macros
-%D {tempstring}
-
-\let\tempstring\empty
-
-%D \macros
-%D {scratchwidth, scratchheight, scratchdepth, scratchoffset, scratchdistance}
-%D
-%D A few more scratch dimensions:
-
-\newdimen\scratchwidth
-\newdimen\scratchheight
-\newdimen\scratchdepth
-\newdimen\scratchtotal
-
-\newdimen\scratchoffset
-\newdimen\scratchleftoffset
-\newdimen\scratchrightoffset
-\newdimen\scratchtopoffset
-\newdimen\scratchbottomoffset
-
-\newdimen\scratchdistance
-
-\newdimen\scratchhsize
-\newdimen\scratchvsize
-
-\newdimen\scratchxoffset
-\newdimen\scratchyoffset
-\newdimen\scratchhoffset
-\newdimen\scratchvoffset
-
-\newdimen\scratchxposition
-\newdimen\scratchyposition
-
-\newcount\scratchnx
-\newcount\scratchny
-
-\newcount\scratchmx
-\newcount\scratchmy
-
-\newcount\scratchmin
-\newcount\scratchmax
-
-\newcount\scratchunicode
-
-\newdimen\scratchleftskip
-\newdimen\scratchrightskip
-\newdimen\scratchtopskip
-\newdimen\scratchbottomskip
-
-%D More allocations:
-
-\newskip \zeroskip \zeroskip 0pt plus 0pt minus 0pt
-\newdimen \zeropoint \zeropoint 0pt
-\newdimen \onepoint \onepoint 1pt
-\newdimen \halfapoint \halfapoint 0.5pt
-\newdimen \maxdimen \maxdimen 16383.99999pt % 1073741823sp
-\newcount \maxcount \maxcount 2147483647
-\newdimen \onebasepoint \onebasepoint 1bp
-\newdimen \scaledpoint \scaledpoint 1sp
-\newdimen \thousandpoint \thousandpoint 1000pt
-\newmuskip\zeromuskip \zeromuskip 0mu
-\newmuskip\onemuskip \onemuskip 1mu
-
-\newmuskip\muquad \muquad 18mu
-
-\let\points \onepoint
-\let\halfpoint\halfapoint
-
-\newtoks \emptytoks
-
-%D And even more: (todo: countdefs 60+)
-
-%newcount\minusone \minusone -1
-\newcount\minustwo \minustwo -2
-%chardef \zerocount 0
-%chardef \plusone 1
-\chardef \plustwo 2
-\chardef \plusthree 3
-\chardef \plusfour 4
-\chardef \plusfive 5
-\chardef \plussix 6
-\chardef \plusseven 7
-\chardef \pluseight 8
-\chardef \plusnine 9
-\chardef \plusten 10
-\chardef \plussixteen 16
-\chardef \plusfifty 50
-\chardef \plushundred 100
-\chardef \plusonehundred 100
-\chardef \plustwohundred 200
-\chardef \plusfivehundred 500
-\chardef \pluscxxvii 127
-\chardef \pluscxxviii 128
-\chardef \pluscclv 255
-\chardef \pluscclvi 256
-\chardef \plusthousand 1000
-\chardef \plustenthousand 10000
-\chardef \plustwentythousand 20000
-\chardef \medcard 32768
-\chardef \maxcard 65536 % pdftex has less mathchars
-\chardef \maxcardminusone 65535
-
-%D \macros
-%D {doubleexpandafter,tripleexpandafter,expanded,startexpanded}
-%D
-%D A few handy shortcuts
-
-\let\singleexpandafter \expandafter
-\def\doubleexpandafter{\expandafter\expandafter\expandafter}
-\def\tripleexpandafter{\expandafter\doubleexpandafter\expandafter}
-
-%D We prefer the more readable variant than in plain \TEX. User should only
-%D use \type {\emptybox}:
-
-\newbox\voidbox % public
-
-\let\normalhbox\hbox
-\let\normalvbox\vbox
-
-\def\unvoidbox{\unhbox\voidbox}
-\def\emptybox {\box \voidbox} % used in initializations so no attributes
-\def\emptyvbox{\normalvpack{}} % no copy as we need to set attributes
-\def\emptyhbox{\normalhpack{}} % no copy as we need to set attributes
-
-\let\leavevmode\unvoidbox % we prefer to use \dontleavehmode
-
-%D \macros
-%D {dontcomplain}
-%D
-%D We need this one soon:
-
-\normalprotected\def\dontcomplain
- {\hbadness\plustenthousand
- \vbadness\plustenthousand
- \hfuzz \maxdimen
- \vfuzz \maxdimen}
-
-%D Some expected plain variants follow. We don't reuse registers because we
-%D don't want clashes.
-
-\let \p@ \onepoint
-\let \m@ne \minusone
-\let \z@ \zeropoint
-\let \@ne \plusone
-\let \tw@ \plustwo
-\let \thr@@ \plusthree
-\let \sixt@@n \plussixteen
-\let \@cclv \pluscclv
-\let \@cclvi \pluscclvi
-\let \voidb@x \voidbox
-\newtoks \toks@ % \scratchtoks
-
-%D We define \type {\newif} a la plain \TEX, but will redefine it later. As
-%D Knuth says:
-%D
-%D \startnarrower
-%D And here's a different sort of allocation: for example,
-%D
-%D \starttyping
-%D \newif\iffoo
-%D \stoptyping
-%D
-%D creates \type {\footrue}, \type {\foofalse} to go with \type {\iffoo}.
-%D \stopnarrower
-
-% \normalprotected\def\newif#1%
-% {\count@\escapechar
-% \escapechar\minusone
-% \expandafter\expandafter\expandafter\def\new_if #1{true}{\let#1\iftrue }%
-% \expandafter\expandafter\expandafter\def\new_if#1{false}{\let#1\iffalse}%
-% \new_if#1{false}% the condition starts out false
-% \escapechar\count@}
-%
-% \def\new_if#1#2%
-% {\csname\expandafter\if@\string#1#2\endcsname}
-%
-% \bgroup % `if' is required
-% \uccode`1=`i \uccode`2=`f \uppercase{\gdef\if@12{}}
-% \egroup
-
-% We use \csstring so there is no need to push/pop escapechar.
-% We use different names so that we get a better error message.
-%
-% \normalprotected\def\newif#1%
-% {\let\new_if_saved\newif
-% \let\newif\new_if_check
-% \expandafter\expandafter\expandafter\def\new_if_cs #1{true}{\let#1\iftrue }%
-% \expandafter\expandafter\expandafter\def\new_if_cs#1{false}{\let#1\iffalse}%
-% \new_if_cs#1{false}%
-% \let\newif\new_if_saved}
-%
-% \normalprotected\def\new_if_cs#1#2%
-% {\csname\expandafter\newif\csstring#1#2\endcsname}
-%
-% We wrap all into one macro:
-
-\normalprotected\def\newif#1%
- {\let\new_if_saved\newif
- \let\newif\new_if_check
- \expandafter\def\csname\expandafter\newif\csstring#1true\endcsname {\let#1\iftrue }%
- \expandafter\def\csname\expandafter\newif\csstring#1false\endcsname{\let#1\iffalse}%
- \csname\expandafter\newif\csstring#1false\endcsname
- \let\newif\new_if_saved}
-
-\bgroup
- \normalexpanded{\gdef\noexpand\new_if_check\string i\string f{}}
-\egroup
-
-%D Let's test this one:
-
-\newif\ifdone
-\newif\iffound
-
-\let\htdp\boxtotal
-
-%D A few shortcuts:
-
-\normalprotected\def\udef {\normalprotected\def }
-\normalprotected\def\ugdef{\normalprotected\gdef}
-\normalprotected\def\uedef{\normalprotected\edef}
-\normalprotected\def\uxdef{\normalprotected\xdef}
-
-%D For a while we keep the following, as systems like tikz need it. Best
-%D not use that one \CONTEXT.
-
-\let\active\activecatcode
-
-%D Constants to be used with \type {\currentgrouptype}.
-
-\chardef\bottomlevelgroupcode = 0
-\chardef\simplegroupcode = 1
-\chardef\hboxgroupcode = 2
-\chardef\adjustedhboxgroupcode = 3
-\chardef\vboxgroupcode = 4
-\chardef\vtopgroupcode = 5
-\chardef\aligngroupcode = 6
-\chardef\noaligngroupcode = 7
-\chardef\outputgroupcode = 8
-\chardef\mathgroupcode = 9
-\chardef\discretionarygroupcode = 10
-\chardef\insertgroupcode = 11
-\chardef\vcentergroupcode = 12
-\chardef\mathchoicegroupcode = 13
-\chardef\semisimplegroupcode = 14
-\chardef\mathshiftgroupcode = 15
-\chardef\mathleftgroupcode = 16
-\chardef\vadjustgroupcode = \insertgroupcode
-
-%D Constants to be used with \type {\interactionmode}.
-
-\chardef\batchmodecode \zerocount
-\chardef\nonstopmodecode \plusone
-\chardef\scrollmodecode \plustwo
-\chardef\errorstopmodecode \plusthree
-
-%D Constants to be used with \type {\lastnodetype}. The \type {\lastnodetype}
-%D primitive is \ETEX\ compliant. The valid range is still -1 .. 15 and glyph nodes
-%D have number 0 (used to be char node) and ligature nodes are mapped to 7. That way
-%D macro packages can use the same symbolic names as in traditional \ETEX. Keep in
-%D mind that the internal node numbers are different and that there are more node
-%D types that 15. The mode parameter forces \LUAMETATEX\ to use the real node
-%D numbers.
-
-\internalcodesmode\plusone
-
-%D Constants to be used with \type {\currentiftype}. I wonder if we will ever
-%D use these in \CONTEXT. We have a few more anyway and in \LUAMETATEX\ we
-%D have different numbers. So for now let's just not define them. The
-%D previously mentioned mode parameters enables the real numbers (we have
-%D some more and they are therefore ordered differently).
-
-% \chardef\charifcode = 1
-% \chardef\catifcode = 2
-% \chardef\numifcode = 3
-% \chardef\dimifcode = 4
-% \chardef\oddifcode = 5
-% \chardef\vmodeifcode = 6
-% \chardef\hmodeifcode = 7
-% \chardef\mmodeifcode = 8
-% \chardef\innerifcode = 9
-% \chardef\voidifcode = 10
-% \chardef\hboxifcode = 11
-% \chardef\vboxifcode = 12
-% \chardef\xifcode = 13
-% \chardef\eofifcode = 14
-% \chardef\trueifcode = 15
-% \chardef\falseifcode = 16
-% \chardef\caseifcode = 17
-% \chardef\definedifcode = 18
-% \chardef\csnameifcode = 19
-% \chardef\fontcharifcode = 20
-%
-% % there are some more in luametatex
-
-%D Of course we want even bigger log files, so we copied this from the \ETEX\
-%D source files.
-%D
-%D When watching such logs, beware of nasty side effects of \type {\scantokens},
-%D as in:
-%D
-%D \starttyping
-%D \bgroup
-%D \lccode`a=12\lowercase{\xdef\whatever{a}}\egroup
-%D \def\whatever{test \whatever test}
-%D \scantokens\expandafter{\whatever}
-%D \egroup
-%D \stoptyping
-%D
-%D In \LUATEX\ we have ways around this.
-
-% no longer \errorstopmode cf. plain tex 3.141592653
-
-\normalprotected\def\tracingall
- {\tracingonline \plusone
- \tracingcommands \plusthree
- \tracingstats \plustwo
- \tracingpages \plusone
- \tracingoutput \plusone
- \tracinglostchars \plustwo
- \tracingmacros \plustwo
- \tracingparagraphs\plusone
- \tracingrestores \plusone
- \showboxbreadth \maxdimen
- \showboxdepth \maxdimen
- \tracinggroups \plusone
- \tracingifs \plusone
- \tracingscantokens\plusone
- \tracingnesting \plustwo
- \tracingassigns \plustwo}
-
-\normalprotected\def\loggingall
- {\tracingall
- \tracingonline \zerocount}
-
-\normalprotected\def\tracingnone
- {\tracingassigns \zerocount
- \tracingnesting \zerocount
- \tracingscantokens\zerocount
- \tracingifs \zerocount
- \tracinggroups \zerocount
- \showboxdepth \plusthree
- \showboxbreadth \plusfive
- \tracingrestores \zerocount
- \tracingparagraphs\zerocount
- \tracingmacros \zerocount
- \tracinglostchars \plusone
- \tracingoutput \zerocount
- \tracingpages \zerocount
- \tracingstats \zerocount
- \tracingcommands \zerocount
- \tracingonline \zerocount}
-
-%D When we want to see a box we can as well show all of it.
-
-\showboxdepth \maxdimen
-\showboxbreadth\maxdimen
-
-%D Just for tracing purposes we set:
-
-\tracingstats\plusone
-
-%D Here we also save \type {\input}, more will be saved later.
-
-\ifdefined\normalinput \else \let\normalinput\input \fi
-
-%D We don't like outer commands, and we always want access to the original
-%D \type {\input} primitive.
-
-\let\normalouter\outer \def\outer{} % no longer \relax
-
-%D To circumvent dependencies, we can postpone certain initializations to
-%D dumping time, by appending them to the \type {\everydump} token register.
-
-\ifdefined\normaldump \else \let\normaldump\dump \fi
-
-\newtoks\everydump
-
-\def\dump{\the\everydump\normaldump}
-
-%D The same applies for the startup actions.
-
-\ifdefined\normaleveryjob \else \let\normaleveryjob\everyjob \fi
-
-\let\everyjob\relax \newtoks\everyjob
-
-\normaleveryjob{\the\everyjob}
-
-%D \macros
-%D {newconditional,
-%D settrue, setfalse,
-%D ifconditional,then}
-%D
-%D \TEX's lacks boolean variables, although the \PLAIN\ format implements \type
-%D {\newif}. The main disadvantage of this scheme is that it takes three hash table
-%D entries. A more memory saving alternative is presented here. A conditional is
-%D defined by:
-%D
-%D \starttyping
-%D \newconditional\doublesided
-%D \setfalse
-%D \stoptyping
-%D Setting a conditional is done by \type{\settrue} and
-%D \type{\setfalse}:
-%D
-%D \starttyping
-%D \settrue\doublesided
-%D \setfalse
-%D \stoptyping
-%D while testing is accomplished by:
-%D
-%D \starttyping
-%D \ifconditional\doublesided ... \else ... \fi
-%D \setfalse
-%D \stoptyping
-%D We cannot use the simple scheme:
-%D
-%D \starttyping
-%D \def\settrue #1{\let#1=\iftrue}
-%D \def\setfalse#1{\let#1=\iffalse}
-%D \stoptyping
-%D
-%D Such an implementation gives problems with nested conditionals. The next
-%D implementation is about as fast and just as straightforward:
-
-\let\conditionalfalse\plusone % maybe we will have a dedicated count/chardef
-\let\conditionaltrue \zerocount % maybe we will have a dedicated count/chardef
-
-\normalprotected\def\settrue #1{\let#1\conditionaltrue }
-\normalprotected\def\setfalse#1{\let#1\conditionalfalse}
-
-\normalprotected\def\settruevalue #1{\expandafter\let\csname#1\endcsname\conditionaltrue }
-\normalprotected\def\setfalsevalue#1{\expandafter\let\csname#1\endcsname\conditionalfalse}
-
-\let\newconditional\setfalse
-\let\ifconditional \ifcase
-
-\let\then\relax % so that we can say: \ifnum1>2\then -)
-
-\def\truecondition {\iftrue}
-\def\falsecondition{\iffalse}
-
-% This one has to be unprotected otherwise we get a files-ends-to-soon but it's ok
-% as conditions expand anyway.
-
-\def\quitcondition{\orelse\iffalse}
-
-%D \macros
-%D {newmacro,setnewmacro,newfraction}
-%D
-%D Let's be complete and also introduce some definers. These are not mandate
-%D but handy for grepping.
-
-\normalprotected\def\newmacro #1{\let#1\empty}
-\normalprotected\def\setnewmacro#1{\let#1}
-
-\def\!!zerocount{0}
-\def\!!plusone {1}
-
-\normalprotected\def\newfraction#1{\let#1\!!plusone}
-
-%D It would be handy to have a primitive \type {\unless\ifcase} because then we
-%D could use nicer values. Anyhow, this conditional code used to be in the \type
-%D {syst-aux} module but is now promoted to here.
-
-%D \macros
-%D {ifzeropt}
-%D
-%D The next macro is both cosmetic and byte saving. It is pretty \type
-%D {\if}||safe too. It can be used in cases like:
-%D
-%D \starttyping
-%D \ifzeropt \somedimen ... \else ... \fi
-%D \stoptyping
-
-\let\ifzeropt\ifcase
-
-% these token list helpers might move to syst-aux.mkiv
-%
-% we assume a \cs. not toks0 or so
-%
-% \normalprotected\def\appendtotoks #1#{\def\temp{#1}\afterassignment\doappendtotoks \scratchtoks=}
-% \normalprotected\def\prependtotoks#1#{\def\temp{#1}\afterassignment\doprependtotoks\scratchtoks=}
-
-\newtoks\t_syst_toks_temp \let\m_syst_toks_temp\t_syst_toks_temp
-
-\normalprotected\def\appendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_l \t_syst_toks_temp=}
-\normalprotected\def\prependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_l\t_syst_toks_temp=}
-
-% \def\syst_toks_append {\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\m_syst_toks_temp\the\t_syst_toks_temp}}}
-% \def\syst_toks_prepend{\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\t_syst_toks_temp\the\m_syst_toks_temp}}}
-
-\normalprotected\def\globalappendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_g \t_syst_toks_temp=}
-\normalprotected\def\globalprependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_g\t_syst_toks_temp=}
-
-\def\syst_toks_append_l {\normalexpanded{\m_syst_toks_temp{\the\m_syst_toks_temp\the\t_syst_toks_temp}}}
-\def\syst_toks_prepend_l{\normalexpanded{\m_syst_toks_temp{\the\t_syst_toks_temp\the\m_syst_toks_temp}}}
-
-\def\syst_toks_append_g {\global\syst_toks_append_l }
-\def\syst_toks_prepend_g{\global\syst_toks_prepend_l}
-
-\normalprotected\def\addtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_l\let\next}
-\normalprotected\def\globaladdtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_g\let\next}
-
-\def\syst_toks_add_l{\m_syst_toks_temp\expandafter\bgroup\the\m_syst_toks_temp}
-\def\syst_toks_add_g{\global\syst_toks_add_l}
-
-\normalprotected\def\addtotokscs #1#2{#1{\the#1#2}} % saves a few bytes
-\normalprotected\def\globaladdtotokscs#1#2{\global#1{\the#1#2}} % saves a few bytes
-
-%D \macros
-%D {begcsname}
-%D
-%D Handy for \ETEX-only usage (avoids making \type {\relax}'s:
-
-% \def\begcsname#1\endcsname{\ifcsname#1\endcsname\csname#1\endcsname\fi}
-
-\let\begcsname\begincsname
-
-%D Now come a few macros that might be needed in successive loading. We redefine the
-%D \type {\par} primitive pretty soon so that we get the equivalents right.
-
-% too tricky: \par is use more often than a par starts so we have too much change
-% that we get assymetrical behaviour
-%
-% \newtoks\everyendpar
-%
-% \normalprotected\def\endpar{\the\everyendpar\normalpar}
-% \normalprotected\def\par {\endpar}
-%
-% \normalprotected\def\reseteverypar
-% {\everypar \emptytoks
-% \everyendpar\emptytoks}
-
-\normalprotected\def\reseteverypar
- {\everypar\emptytoks}
-
-\let\endgraf\par
-\let\endline\cr
-
-\normalprotected\def\null{\hpack{}}
-
-%D The following two might be overloaded later on but some modules need then
-%D earlier. These functionality is reflected in the name and will not change.
-
-% \bgroup
-% \catcode`\^^M=\activecatcode%
-% \gdef\obeylines{\catcode`\^^M\activecatcode \let^^M\par}%
-% \glet^^M\par%
-% \egroup
-%
-% \bgroup
-% \gdef\obeyspaces{\catcode`\ \activecatcode}%
-% \obeyspaces\glet =\space%
-% \egroup
-
-\def\obeylines {\catcode\endoflineasciicode\activecatcode\letcharcode\endoflineasciicode\par}
-\def\obeyspaces{\catcode\spaceasciicode \activecatcode\letcharcode\spaceasciicode \space}
-
-% %D A constant:
-%
-% \let\endoflinetoken=^^M
-
-%D Also needed might be a simple loop structure and we borrow plain \TEX's one
-%D as it is often expected to be present and it is about the fastest you can
-%D get. Beware: this macro does not support nested loops. We use a namespace
-%D prefix \type {@@pln}.
-
-\def\loop#1\repeat{\def\@@plnbody{#1}\@@plniterate} % might go
-
-%D The following makes \type {\loop} \unknown\ \type {\if} \unknown\ \type
-%D {\repeat} skippable (clever trick):
-
-\let\repeat\fi % so both \loop and \repeat are reserved words!
-
-%D The original (no \type {@@pln} there):
-%D
-%D \starttyping
-%D \def\@@plniterate{\@@plnbody\let\next\@@plniterate\else\let\next\relax\fi\next}
-%D \stoptyping
-%D
-%D A more efficient alternative:
-%D
-%D \starttyping
-%D \def\@@plniterate{\@@plnbody\expandafter\@@plniterate\else\expandafter\relax\fi}
-%D \stoptyping
-%D
-%D An even more efficient one:
-
-\def\@@plniterate{\@@plnbody\expandafter\@@plniterate\else\fi}
-
-%D We don't define a real output routine yet but at least get rid of pages:
-
-\output{\shipout\box\normalpagebox}
-
-%D Although we don't add pagenumbers yet we alias the default register used
-%D for counting pages:
-
-\countdef\pageno\zerocount \pageno\plusone % first page is number 1
-
-%D Beside the raw counter \type {\pageno} the \type {\folio} macro provides
-%D the value.
-
-\def\folio{\the\pageno} % kind of expected and therefore reserved
-
-%D The following registers are kind of standard and (for the moment) we define
-%D them here. This might change.
-
-\newskip \bigskipamount \bigskipamount = 12pt plus 4pt minus 4pt
-\newskip \medskipamount \medskipamount = 6pt plus 2pt minus 2pt
-\newskip \smallskipamount \smallskipamount = 3pt plus 1pt minus 1pt
-
-\baselineskip = 12pt
-\lineskip = 1pt
-\lineskiplimit = 0pt
-
-%D Sometimes kerns make more sense than glue but we need to be in the
-%D right mode:
-
-\normalprotected\def\vkern{\ifhmode\par \fi\kern}
-\normalprotected\def\hkern{\ifvmode\dontleavehmode\fi\kern}
-
-%D Again a few kind-of-extensions the core. These come from plain \TEX\ but
-%D are probably not used in \CONTEXT.
-
-\newskip \hideskip \hideskip = -1000pt plus 1fill
-\newskip \centering \centering = 0pt plus 1000pt minus 1000pt
-
-\def\hidewidth % for alignment entries that can stick out
- {\hskip\hideskip}
-
-\def\ialign % initialized \halign
- {\everycr\emptytoks
- \tabskip\zeroskip
- \halign}
-
-\newcount \mscount
-
-\def\spanomit{\span\omit} % bypass error message
-
-\def\multispan#1%
- {\omit
- \mscount#1\relax
- \loop
- \ifnum\mscount>\plusone
- \spanomit \advance\mscount\minusone
- \repeat}
-
-\let\nopdfcompression \relax
-\let\onlypdfobjectcompression\relax
-\let\maximumpdfcompression \relax
-\let\normalpdfcompression \relax
-
-%D Basic status stuff.
-
-\newif\ifproductionrun
-
-%D For those who expect this \unknown
-
-\ifx\fmtname \undefined \def\fmtname {ConTeXt Initial TeX} \fi
-\ifx\fmtversion\undefined \def\fmtversion{3.1415926} \fi
-
-%D A few bonus macros:
-
-\def\modulonumber#1#2{\the\numexpr#2-((((#2+(#1/2))/#1)-1)*#1)\relax}
-\def\dividenumber#1#2{\the\numexpr(#2-(#1/2))/#1\relax}
-
-%D These could be set at the \LUA\ end instead:
-
-\edef\texenginename {\directlua{tex.print(LUATEXENGINE)}}
-\edef\texengineversion {\directlua{tex.print(LUATEXVERSION)}}
-\edef\texenginefunctionality{\directlua{tex.print(LUATEXFUNCTIONALITY)}}
-
-%D We have no reason not to enable this:
-
-\savingvdiscards\plusone
-
-%D We only can set this one via directives (system.synctex) and we only support
-%D the context variant. This will go away completely.
-
-\newcount\synctex \let\normalsynctex\synctex
-
-%D We get rid of the funny \TEX\ offset defaults of one inch by setting them to zero.
-
-\voffset\zeropoint \let\voffset\relax \newdimen\voffset \let\normalvoffset\voffset
-\hoffset\zeropoint \let\hoffset\relax \newdimen\hoffset \let\normalhoffset\hoffset
-
-\matheqnogapstep\zerocount % for now
-
-%D Now we define a few helpers that we need in a very early stage. We have no
-%D message system yet but redundant definitions are fatal anyway.
-
-\newcount\c_syst_helpers_n_of_namespaces \c_syst_helpers_n_of_namespaces\pluseight % 1-8 reserved for catcodes
-
-\def\v_interfaces_prefix_template_system{\number \c_syst_helpers_n_of_namespaces>>}
-%def\v_interfaces_prefix_template_system{\characters\c_syst_helpers_n_of_namespaces>>} % no \characters yet
-
-\normalprotected\def\installsystemnamespace#1%
- {\ifcsname ??#1\endcsname
- \immediate\write\statuswrite{fatal error: duplicate system namespace '#1'}%
- \expandafter\normalend
- \else
- \global\advance\c_syst_helpers_n_of_namespaces\plusone
- \expandafter\edef\csname ??#1\endcsname{\v_interfaces_prefix_template_system}%
- \fi}
-
-%D It makes more sense to have these here:
-
-\let\normalsuperscript \Usuperscript
-\let\normalsubscript \Usubscript
-\let\normalnosuperscript\Unosuperscript
-\let\normalnosubscript \Unosubscript
-\let\normalstartimath \Ustartmath
-\let\normalstopimath \Ustopmath
-\let\normalstartdmath \Ustartdisplaymath
-\let\normalstopdmath \Ustopdisplaymath
-
-%D Also better here:
-
-\def\wildcardsymbol{*}
-
-%D For a while we will keep these useless numbers as for instance tikz checks for them:
-
-\chardef\eTeXversion 2
-\def \eTeXrevision {2}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-lua.lua b/Master/texmf-dist/tex/context/base/mkiv/syst-lua.lua
index 5911d7f0059..085f75eca92 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-lua.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-lua.lua
@@ -6,13 +6,43 @@ if not modules then modules = { } end modules ['syst-lua'] = {
license = "see context related readme files"
}
+local load, type, tonumber = load, type, tonumber
+local concat = table.concat
+local utfchar = utf.char
local find = string.find
local S, C, P, lpegmatch, lpegtsplitat = lpeg.S, lpeg.C, lpeg.P, lpeg.match, lpeg.tsplitat
-commands = commands or { }
-local commands = commands
-local context = context
-local implement = interfaces.implement
+local xmath = xmath or math
+local xcomplex = xcomplex or { }
+
+local cmd = tokens.commands
+
+local scan_next = token.scan_next or token.get_next
+local scan_cmdchr = token.scan_cmdchr_expanded
+
+local get_command = token.get_command
+local get_mode = token.get_mode
+local get_index = token.get_index
+local get_csname = token.get_csname
+local get_macro = token.get_macro
+
+local put_next = token.put_next
+
+local scan_token = token.scan_token or token.get_token
+
+local getdimen = tex.getdimen
+local getglue = tex.getglue
+local getcount = tex.getcount
+local gettoks = tex.gettoks
+local gettex = tex.get
+
+local context = context
+local dimenfactors = number.dimenfactors
+
+commands = commands or { }
+local commands = commands
+local context = context
+local implement = interfaces.implement
local ctx_protected_cs = context.protected.cs -- more efficient
local ctx_firstoftwoarguments = context.firstoftwoarguments
@@ -20,11 +50,9 @@ local ctx_secondoftwoarguments = context.secondoftwoarguments
local ctx_firstofoneargument = context.firstofoneargument
local ctx_gobbleoneargument = context.gobbleoneargument
-local two_strings = interfaces.strings[2]
-
implement { -- will be overloaded later
name = "writestatus",
- arguments = two_strings,
+ arguments = "2 strings",
actions = logs.status,
}
@@ -123,7 +151,7 @@ implement {
implement {
name = "doifelsesame",
- arguments = two_strings,
+ arguments = "2 strings",
actions = function(a,b)
if a == b then
ctx_firstoftwoarguments()
@@ -135,7 +163,7 @@ implement {
implement {
name = "doifsame",
- arguments = two_strings,
+ arguments = "2 strings",
actions = function(a,b)
if a == b then
ctx_firstofoneargument()
@@ -147,7 +175,7 @@ implement {
implement {
name = "doifnotsame",
- arguments = two_strings,
+ arguments = "2 strings",
actions = function(a,b)
if a == b then
ctx_gobbleoneargument()
@@ -164,237 +192,107 @@ implement {
-- stick to the next gimmick. It looks inefficient but performance is actually quite
-- efficient.
-local concat = table.concat
-local utfchar = utf.char
-local load, type, tonumber = load, type, tonumber
-
-local xmath = xmath or math
-local xcomplex = xcomplex or { }
+do
-local cmd = tokens.commands
+ local result = { "return " }
+ local word = { }
+ local r = 1
+ local w = 0
-local get_next = token.get_next
-local get_command = token.get_command
-local get_mode = token.get_mode
-local get_index = token.get_index
-local get_csname = token.get_csname
-local get_macro = token.get_macro
+ local report = logs.reporter("system","expression")
-local put_next = token.put_next
-
-local scan_token = token.scan_token
-
-local getdimen = tex.getdimen
-local getglue = tex.getglue
-local getcount = tex.getcount
-local gettoks = tex.gettoks
-local gettex = tex.get
-
-local context = context
-local dimenfactors = number.dimenfactors
-
-local result = { "return " }
-local word = { }
-local r = 1
-local w = 0
-
-local report = logs.reporter("system","expression")
-
-local function unexpected(c)
- report("unexpected token %a",c)
-end
+ local function unexpected(c)
+ report("unexpected token %a",c)
+ end
-local function expression()
- local w = 0
- local r = 1
- while true do
- local t = get_next()
- local n = get_command(t)
- local c = cmd[n]
- -- todo, helper: returns number
- if c == "letter" then
- w = w + 1 ; word[w] = utfchar(get_mode(t))
- else
- if w > 0 then
- local s = concat(word,"",1,w)
- local d = dimenfactors[s]
- if d then
- r = r + 1 ; result[r] = "*"
- r = r + 1 ; result[r] = 1/d
- else
- if xmath[s] then
- r = r + 1 ; result[r] = "xmath."
- elseif xcomplex[s] then
- r = r + 1 ; result[r] = "xcomplex."
+ local function expression()
+ local w = 0
+ local r = 1
+ while true do
+ local t = scan_next()
+ local n = get_command(t)
+ local c = cmd[n]
+ -- todo, helper: returns number
+ if c == "letter" then
+ w = w + 1 ; word[w] = utfchar(get_mode(t))
+ else
+ if w > 0 then
+ local s = concat(word,"",1,w)
+ local d = dimenfactors[s]
+ if d then
+ r = r + 1 ; result[r] = "*"
+ r = r + 1 ; result[r] = 1/d
+ else
+ if xmath[s] then
+ r = r + 1 ; result[r] = "xmath."
+ elseif xcomplex[s] then
+ r = r + 1 ; result[r] = "xcomplex."
+ end
+ r = r + 1 ; result[r] = s
end
- r = r + 1 ; result[r] = s
+ w = 0
end
- w = 0
- end
- if c == "other_char" then
- r = r + 1 ; result[r] = utfchar(get_mode(t))
- elseif c == "spacer" then
- -- r = r + 1 ; result[r] = " "
- elseif c == "relax" then
- break
- elseif c == "assign_int" then
- r = r + 1 ; result[r] = getcount(get_index(t))
- elseif c == "assign_dimen" then
- r = r + 1 ; result[r] = getdimen(get_index(t))
- elseif c == "assign_glue" then
- r = r + 1 ; result[r] = getglue(get_index(t))
- elseif c == "assign_toks" then
- r = r + 1 ; result[r] = gettoks(get_index(t))
- elseif c == "char_given" or c == "math_given" or c == "xmath_given" then
- r = r + 1 ; result[r] = get_mode(t)
- elseif c == "last_item" then
- local n = get_csname(t)
- if n then
- local s = gettex(n)
- if s then
- r = r + 1 ; result[r] = s
+ if c == "other_char" then
+ r = r + 1 ; result[r] = utfchar(get_mode(t))
+ elseif c == "spacer" then
+ -- r = r + 1 ; result[r] = " "
+ elseif c == "relax" then
+ break
+ elseif c == "assign_int" then
+ r = r + 1 ; result[r] = getcount(get_index(t))
+ elseif c == "assign_dimen" then
+ r = r + 1 ; result[r] = getdimen(get_index(t))
+ elseif c == "assign_glue" then
+ r = r + 1 ; result[r] = getglue(get_index(t))
+ elseif c == "assign_toks" then
+ r = r + 1 ; result[r] = gettoks(get_index(t))
+ elseif c == "char_given" or c == "math_given" or c == "xmath_given" then
+ r = r + 1 ; result[r] = get_mode(t)
+ elseif c == "last_item" then
+ local n = get_csname(t)
+ if n then
+ local s = gettex(n)
+ if s then
+ r = r + 1 ; result[r] = s
+ else
+ unexpected(c)
+ end
else
unexpected(c)
end
- else
- unexpected(c)
- end
- elseif c == "call" then
- local n = get_csname(t)
- if n then
- local s = get_macro(n)
- if s then
- r = r + 1 ; result[r] = s
+ elseif c == "call" then
+ local n = get_csname(t)
+ if n then
+ local s = get_macro(n)
+ if s then
+ r = r + 1 ; result[r] = s
+ else
+ unexpected(c)
+ end
else
unexpected(c)
end
+ elseif c == "the" or c == "convert" or c == "lua_expandable_call" then
+ put_next(t)
+ scan_token() -- expands
else
unexpected(c)
end
- elseif c == "the" or c == "convert" or c == "lua_expandable_call" then
- put_next(t)
- scan_token() -- expands
- else
- unexpected(c)
end
end
+ local code = concat(result,"",1,r)
+ local func = load(code)
+ if type(func) == "function" then
+ context(func())
+ else
+ report("invalid lua %a",code)
+ end
end
- local code = concat(result,"",1,r)
- local func = load(code)
- if type(func) == "function" then
- context(func())
- else
- report("invalid lua %a",code)
- end
-end
--- local letter_code = cmd.letter
--- local other_char_code = cmd.other_char
--- local spacer_code = cmd.spacer
--- local other_char_code = cmd.other_char
--- local relax_code = cmd.relax
--- local assign_int_code = cmd.assign_int
--- local assign_dimen_code = cmd.assign_dimen
--- local assign_glue_code = cmd.assign_glue
--- local assign_toks_code = cmd.assign_toks
--- local char_given_code = cmd.char_given
--- local math_given_code = cmd.math_given
--- local xmath_given_code = cmd.xmath_given
--- local last_item_code = cmd.last_item
--- local call_code = cmd.call
--- local the_code = cmd.the
--- local convert_code = cmd.convert
--- local lua_expandable_call_code = cmd.lua_expandable_call
---
--- local function unexpected(c)
--- report("unexpected token %a",c)
--- end
---
--- local function expression()
--- local w = 0
--- local r = 1
--- while true do
--- local t = get_next()
--- local n = get_command(t)
--- if n == letter_code then
--- w = w + 1 ; word[w] = utfchar(get_mode(t))
--- else
--- if w > 0 then
--- -- we could use a metatable for all math, complex and factors
--- local s = concat(word,"",1,w)
--- local d = dimenfactors[s]
--- if d then
--- r = r + 1 ; result[r] = "*"
--- r = r + 1 ; result[r] = 1/d
--- else
--- if xmath[s] then
--- r = r + 1 ; result[r] = "xmath."
--- elseif xcomplex[s] then
--- r = r + 1 ; result[r] = "xcomplex."
--- end
--- r = r + 1 ; result[r] = s
--- end
--- w = 0
--- end
--- if n == other_char_code then
--- r = r + 1 ; result[r] = utfchar(get_mode(t))
--- elseif n == spacer_code then
--- -- r = r + 1 ; result[r] = " "
--- elseif n == relax_code then
--- break
--- elseif n == assign_int_code then
--- r = r + 1 ; result[r] = getcount(get_index(t))
--- elseif n == assign_dimen_code then
--- r = r + 1 ; result[r] = getdimen(get_index(t))
--- elseif n == assign_glue_code then
--- r = r + 1 ; result[r] = getglue(get_index(t))
--- elseif n == assign_toks_code then
--- r = r + 1 ; result[r] = gettoks(get_index(t))
--- elseif n == char_given_code or n == math_given_code or n == xmath_given_code then
--- r = r + 1 ; result[r] = get_mode(t)
--- elseif n == last_item_code then
--- local n = get_csname(t)
--- if n then
--- local s = gettex(n)
--- if s then
--- r = r + 1 ; result[r] = s
--- else
--- unexpected(c)
--- end
--- else
--- unexpected(c)
--- end
--- elseif n == call_code then
--- local n = get_csname(t)
--- if n then
--- local s = get_macro(n)
--- if s then
--- r = r + 1 ; result[r] = s
--- else
--- unexpected(c)
--- end
--- else
--- unexpected(c)
--- end
--- elseif n == the_code or n == convert_code or n == lua_expandable_call_code then
--- put_next(t)
--- scan_token() -- expands
--- else
--- unexpected(c)
--- end
--- end
--- end
--- local code = concat(result,"",1,r)
--- local func = load(code)
--- if type(func) == "function" then
--- context(func())
--- else
--- report("invalid lua %a",code)
--- end
--- end
+ implement {
+ public = true,
+ name = "expression",
+ actions = expression,
+ }
-implement {
- public = true,
- name = "expression",
- actions = expression,
-}
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkiv
index d275acd7dd1..f0902eaf58b 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkiv
@@ -57,8 +57,8 @@
\def\expdoifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}}
\def\expdoifelseinset #1#2{\clf_doifelseinset {#1}{#2}}
-\def\expdoifcommonelse\expdoifelsecommon
-\def\expdoifinsetelse \expdoifelseinset
+\let\expdoifcommonelse\expdoifelsecommon
+\let\expdoifinsetelse \expdoifelseinset
%D We define these here, just in case. This permits \typefile {self} otherwise
%D nested b|/|e sep problems.
@@ -68,7 +68,7 @@
\edef\!!bs{[\luastringsep[}
\edef\!!es{]\luastringsep]}
-\unexpanded\def\writestatus#1#2{\clf_writestatus{#1}{#2}}
+\protected\def\writestatus#1#2{\clf_writestatus{#1}{#2}}
%D We can omit the tex.ctxcatcodes here as nowadays we seldom change the regime at
%D the \TEX\ end:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkxl b/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkxl
deleted file mode 100644
index cf20c3341f8..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-lua.mkxl
+++ /dev/null
@@ -1,100 +0,0 @@
-%D \module
-%D [ file=syst-lua,
-%D version=2008.01.25,
-%D title=\CONTEXT\ System Macros,
-%D subtitle=Helper macros based on \LUA,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\registerctxluafile{syst-lua}{}
-
-\unprotect
-
-\def\expdoifelse#1#2{\clf_doifelsesame{#1}{#2}}
-\def\expdoif #1#2{\clf_doifsame {#1}{#2}}
-\def\expdoifnot #1#2{\clf_doifnotsame {#1}{#2}}
-
-%D Here is variant using a brainwave of the 12\high{+} hour \quotation {Long Road
-%D Out of Eden}\footnote {Eden being Backo\TeX\ 2018, where the virtues of the \type
-%D {\expanded} primitive were mentioned in talks.} trip. For now I don't really see
-%D other useful applications.
-
-\def\expandeddoifelse#1#2{\iftok{#1}{#2}\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
-\def\expandeddoif #1#2{\iftok{#1}{#2}\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi}
-\def\expandeddoifnot #1#2{\iftok{#1}{#2}\expandafter\gobbleoneargument \else\expandafter\firstofoneargument \fi}
-
-% \testfeatureonce{100000}{\doifelse{hello world}{here i am}{}} % 0.3
-% \testfeatureonce{100000}{\expandabledoifelse{hello world}{here i am}{}} % 1.5
-
-\def\expdoifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}}
-\def\expdoifelseinset #1#2{\clf_doifelseinset {#1}{#2}}
-
-\def\expdoifcommonelse\expdoifelsecommon
-\def\expdoifinsetelse \expdoifelseinset
-
-%D We define these here, just in case. This permits \typefile {self} otherwise
-%D nested b|/|e sep problems.
-
-\def\luastringsep{===}
-
-\edef\!!bs{[\luastringsep[}
-\edef\!!es{]\luastringsep]}
-
-\unexpanded\def\writestatus#1#2{\clf_writestatus{#1}{#2}}
-
-%D We can omit the tex.ctxcatcodes here as nowadays we seldom change the regime at
-%D the \TEX\ end:
-
-%def\luaexpr#1{\ctxlua{context (tostring(#1))}} % more efficient:
-\def\luaexpr#1{\ctxlua{tex.print(tostring(#1))}} % no use is shortcutting has to be compiled
-
-%D But as we only use write 16 we could as well do all in \LUA\ and ignore the rest.
-%D Okay, we still can do writes here but only when not blocked.
-
-\let\syst_write_execute\clf_execute % always {...}
-
-%D There is a probably rather useless \type {\expression} command that can mix \LUA\ numeric
-%D expressions with \TEX\ commands (for as far that makes sense) that works like this:
-%D
-%D \starttyping
-%D \mathchardef\foooo 1234
-%D \def \mymacro {123.45}
-%D \scratchdimen 123pt
-%D \scratchskip 123pt
-%D \scratchtoks {34}
-%D
-%D \testfeatureonce{10000}{\edef\foo{\expression
-%D round(
-%D 12.3 * \scratchdimen
-%D - (12.3 * \scratchskip) / 2
-%D + 2 ^ 3
-%D * (
-%D - sqrt(12)
-%D - 10pt
-%D - \foooo
-%D + \luatexversion
-%D - \mymacro
-%D + \scratchtoks
-%D + \the\scratchcounter
-%D + \number\scratchcounter
-%D )
-%D )
-%D \relax}}
-%D
-%D \expression string.format("\letterpercent f",\elapsedtime/50000) \relax
-%D \stoptyping
-%D
-%D The final \type {\relax} is mandate because we also accept spaces. Of course we
-%D could have avoided it by using outer parenthesis but this is cleaner anyway.
-%D
-%D The \LMTX\ version supports te \type {xmath} and \type {xcomplex} functions and
-%D therefore one can have expressions that don't work in \MKIV.
-
-% maybe: \let\texexpr\expression
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-mac.lua b/Master/texmf-dist/tex/context/base/mkiv/syst-mac.lua
new file mode 100644
index 00000000000..b7c36817c50
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-mac.lua
@@ -0,0 +1,9 @@
+if not modules then modules = { } end modules ['syst-mac'] = {
+ version = 1.001,
+ comment = "companion to syst-aux.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- empty
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-mes.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-mes.mkiv
index 4ed2697f15a..ff7ab1ce39f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-mes.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-mes.mkiv
@@ -11,8 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\normalprotected\def\writestring {\immediate\write\statuswrite}
-\normalprotected\def\writeline {\writestring{}}
- \let\message \normalmessage
+\protected\def\writestring{\immediate\write\statuswrite}
+\protected\def\writeline {\writestring{}}
+% \let\message \normalmessage
\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/syst-pln.mkiv b/Master/texmf-dist/tex/context/base/mkiv/syst-pln.mkiv
index 2481131209f..38ec9c4c1c5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/syst-pln.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/syst-pln.mkiv
@@ -13,10 +13,9 @@
\unprotect
-%D This module set a couple of variables to the plain \TEX\
-%D values. Later they might be overloaded. There is not much
-%D difference between \MKII\ and \MKIV\ but at some point they
-%D might diverge.
+%D This module set a couple of variables to the plain \TEX\ values. Later they might
+%D be overloaded. There is not much difference between \MKII\ and \MKIV\ but at some
+%D point they might diverge.
%D Build||in numeric variables.
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-ltb.mkiv b/Master/texmf-dist/tex/context/base/mkiv/tabl-ltb.mkiv
index de90d658528..0650cf9ce72 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-ltb.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-ltb.mkiv
@@ -503,7 +503,7 @@
\fi
\global\d_tabl_lines_width\wd\b_tabl_lines_cell
\tabl_lines_start_part
- \if!!doneb \else \ifcase\c_tabl_lines_repeat \else
+ \if!!donea \else \ifcase\c_tabl_lines_repeat \else
% check for left/right page
\ifcase\c_tabl_lines_page\donetrue\or\donetrue\or\donefalse\fi\ifdone
% insert repeater
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-mis.mkiv b/Master/texmf-dist/tex/context/base/mkiv/tabl-mis.mkiv
index b2af1993eac..d9022b06d7a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-mis.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-mis.mkiv
@@ -130,7 +130,7 @@
\let\typo_paragraphs_setup_saved\setupparagraphs
-\unexpanded\def\setupparagraphs
+\unexpanded\overloaded\def\setupparagraphs
{\dotripleempty\typo_paragraphs_setup}
\def\typo_paragraphs_setup[#1][#2][#3]% we are downward compatible with [each] and [1,3]
@@ -193,7 +193,7 @@
\fi
\parindent\zeropoint
\c_typo_paragraphs_n\zerocount
- \let\\=\typo_paragraphs_next % downward compatible
+ \enforced\let\\\typo_paragraphs_next % downward compatible
\edef\p_offset{\paragraphsparameter\c!offset}%
\doifelsedimension\p_offset
{\scratchoffset\p_offset}%
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkiv b/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkiv
index 8ff02330a9a..45f746f3a08 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkiv
@@ -243,12 +243,18 @@
\tabl_ntb_next_level % go to level 1
+%D This is for the special cases where for instance a table is in a header or footer
+%D line and we have a split table in progress. (See mail to list from Taco.)
+
\installcorenamespace{naturaltable} % was tbl
\installcorenamespace{naturaltablelocal} % was tbltbl
\installdirectcommandhandler \??naturaltable {naturaltable} % \??naturaltable
\installsimpleframedcommandhandler \??naturaltablelocal {naturaltablelocal} \??naturaltablelocal
+\unexpanded\def\bTABLEnested{\tabl_ntb_next_level\bTABLE}
+\unexpanded\def\eTABLEnested{\eTABLE\tabl_ntb_prev_level}
+
\installcorenamespace{naturaltabletal}
\installcorenamespace{naturaltablegal}
\installcorenamespace{naturaltablenob}
@@ -1505,7 +1511,7 @@
\advance\scratchcounter\plusone}%
\fi
% cell
- \setbox\scratchbox\hbox attr \taggedattribute \attribute\taggedattribute \bgroup
+ \setbox\scratchbox\hbox attr \taggedattribute \c_attr_tagged \bgroup
\dotagTABLEsignal % maybe we need to add some packaging in this case
\tabl_ntb_get_txt{#1}{#2}%
\egroup
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkxl b/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkxl
deleted file mode 100644
index 6b84411b2a9..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-ntb.mkxl
+++ /dev/null
@@ -1,2202 +0,0 @@
-%D \module
-%D [ file=tabl-ntb,
-%D version=2000.04.18,
-%D title=\CONTEXT\ Table Macros,
-%D subtitle=Natural Tables,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D This module has a more modern variant in xtables but as we follow a bit different
-%D approach with settings there, this mechanism will stay. In fact each of them has
-%D its advantages. This module could be sped up a bit and made more efficient by
-%D delegating some housekeeping to \LUA\ but it's not worth the effort. The code
-%D could me made more readable but again, there is no real purpose in it. If needed
-%D I can squeeze out a few more percentages runtime.
-
-% columndistance 'optimized' ... needs checking
-%
-% we don't need the alignment mechanism .. we can just pack the row in a box
-
-\writestatus{loading}{ConTeXt Table Macros / Natural Tables}
-
-% sometimes this helps (with nc going wild): \setupTABLE[maxwidth=100cm]
-%
-% bug: width 3cm is not honored and column becomes too wide as given width is added
-% to distributed width
-%
-% \bTABLE
-% \bTR
-% \bTD test \eTD
-% \bTD \framed[height=3cm]{test} \eTD
-% \bTD[width=3cm] \dorecurse{30}{a } \eTD
-% \bTD \input ward \eTD
-% \eTR
-% \bTR
-% \bTD test \eTD
-% \bTD \framed[height=3cm]{test} \eTD
-% \bTD \dorecurse{30}{a } \eTD
-% \bTD \input ward \eTD
-% \eTR
-% \eTABLE
-
-% \unexpanded\def\startrow {\bTR}
-% \unexpanded\def\stoprow {\eTR}
-% \unexpanded\def\startcell#1\stopcell{\bTD#1\eTD}
-% \let\stopcell \relax
-% \let\startcelltable \bTABLE
-% \let\stopcelltable \eTABLE
-
-% \starttext
-% \startcelltable
-% \startrow \startcell a \stopcell \stoprow
-% \startrow \startcell a \stopcell \stoprow
-% \startrow \startcell a \stopcell \stoprow
-% \startrow \startcell a \stopcell \stoprow
-% \stopcelltable
-% \stoptext
-
-%D As always, this is the n\high{th} version. Much time went in trying to speed up
-%D the many cell calculations, some optimizations were rejected in order not to
-%D complicate this module too much (and in order to prevail extensibility). In the
-%D meantime we've sacrified some speed for readability.
-
-\unprotect
-
-%D The next alternative also takes care of preceding and following white space.
-%D
-%D \startbuffer
-%D \bTABLE[left={(},right={)},top=\startnarrower,bottom=\stopnarrower]
-%D \bTR \bTD something \eTD \eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\ifdefined\dotagTABLEcell \else \let\dotagTABLEcell \relax \fi % todo: namespace
-\ifdefined\dotagTABLEsignal \else \let\dotagTABLEsignal\relax \fi % todo: namespace
-
-\let\tabl_ntb_next_level\relax
-
-\newtoks\t_tabl_ntb_cell_start
-\newtoks\t_tabl_ntb_cell_stop
-
-\appendtoks
- \naturaltablelocalparameter\c!left
- \delayedbegstrut
-\to \t_tabl_ntb_cell_start
-
-\appendtoks
- \delayedendstrut
- \naturaltablelocalparameter\c!right
-\to \t_tabl_ntb_cell_stop
-
-\appendtoks
- \flushpostponednodedata
- % maybe: \the\neverypar
-\to \t_tabl_ntb_cell_start
-
-\unexpanded\def\tabl_ntb_cell_start
- {% \inhibitblank
- \dotagTABLEcell
- %\tabl_ntb_next_level
- \font_styles_math_reset
- \usenaturaltablelocalstyleandcolor\c!style\c!color
- \everypar\t_tabl_ntb_cell_start
- \font_styles_math_start}
-
-\unexpanded\def\tabl_ntb_cell_stop
- {\font_styles_math_stop
- \ifhmode
- \the\t_tabl_ntb_cell_stop
- \par % added 13/4/2006
- \orelse\ifdim\prevdepth<\zeropoint % =-1000pt ?
- % not sure yet:\naturaltablelocalparameter\c!right
- \vskip-\strutdp
- \else
- \removebottomthings
- \fi}
-
-% maybe:
-%
-% \unexpanded\def\tabl_ntb_cell_stop
-% {\ifhmode
-% \the\t_tabl_ntb_cell_stop
-% \par % added 13/4/2006
-% \else
-% % not sure yet:\naturaltablelocalparameter\c!right
-% \par
-% \ifhmode
-% % \removeunwantedspaces
-% \else\ifdim\prevdepth<\zeropoint % =-1000pt ?
-% \vskip-\strutdp
-% \else
-% \removebottomthings
-% \fi\fi
-% \fi}
-
-\newcount\c_tabl_ntb_row
-\newcount\c_tabl_ntb_col
-\newcount\c_tabl_ntb_spn
-
-\newcount\c_tabl_ntb_nx
-\newcount\c_tabl_ntb_ny
-
-\setnewconstant\c_tabl_ntb_cell \plusone
-\setnewconstant\c_tabl_ntb_none \plustwo
-
-\newcount\c_tabl_ntb_current_row
-\newcount\c_tabl_ntb_current_col
-\newcount\c_tabl_ntb_current_row_one
-\newcount\c_tabl_ntb_current_col_one
-\newcount\c_tabl_ntb_current_row_two
-\newcount\c_tabl_ntb_current_col_two
-\newcount\c_tabl_ntb_current_row_three
-\newcount\c_tabl_ntb_current_col_three
-\newcount\c_tabl_ntb_current_row_four
-\newcount\c_tabl_ntb_current_col_four
-
-\newcount\c_tabl_ntb_running_col
-\newcount\c_tabl_ntb_maximum_row
-\newcount\c_tabl_ntb_maximum_col
-\newcount\c_tabl_ntb_maximum_row_span
-\newcount\c_tabl_ntb_maximum_col_span
-
-\newcount\c_tabl_ntb_encountered_col
-\newcount\c_tabl_ntb_encountered_max
-
-\newtoks\t_tabl_ntb
-\newtoks\t_tabl_ntb_row
-
-\newconstant\c_tabl_tbl_pass
-
-\newtoks\t_tabl_ntb_head
-\newtoks\t_tabl_ntb_next
-\newtoks\t_tabl_ntb_body
-\newtoks\t_tabl_ntb_foot
-
-\newcount\c_tabl_ntb_n_of_head_lines
-\newcount\c_tabl_ntb_n_of_next_lines
-\newcount\c_tabl_ntb_n_of_hdnx_lines
-
-\newdimen\d_tabl_ntb_height
-\newdimen\d_tabl_ntb_width
-
-\newdimen\d_tabl_ntb_leftmargindistance
-\newdimen\d_tabl_ntb_rightmargindistance
-\newdimen\d_tabl_ntb_columndistance
-\newdimen\d_tabl_ntb_maxwidth
-
-\newtoks\everyTABLEpass % public
-
-\newcount\tablecellrows % public (needs checking)
-\newcount\tablecellcolumns % public (needs checking)
-
-\newbox\b_tabl_ntb_final
-
-%D For tagging and export:
-
-\newconstant \c_tabl_ntb_head
-\newconstant \c_tabl_ntb_body
-\newconstant \c_tabl_ntb_foot
-\newconditional \c_tabl_ntb_okay
-
-%D We have already prepared the previous macros for nesting, so we only have to pop
-%D in the right ones:
-
-\newcount\c_tabl_level
-
-\installglobalmacrostack\m_tabl_ntb_saved_row
-\installglobalmacrostack\m_tabl_ntb_saved_col
-
-\unexpanded\def\tabl_ntb_table_push
- {\ifnum\m_tabl_tbl_level>\plusone
- \tabl_ntb_parameters_reset
- % we need a proper count push/pop
- \xdef\m_tabl_ntb_saved_row{\the\c_tabl_ntb_row}\push_macro_m_tabl_ntb_saved_row
- \xdef\m_tabl_ntb_saved_col{\the\c_tabl_ntb_col}\push_macro_m_tabl_ntb_saved_col
- \else
- \global\intabletrue
- \fi}
-
-\unexpanded\def\tabl_ntb_table_pop
- {\ifnum\m_tabl_tbl_level>\plusone
- \pop_macro_m_tabl_ntb_saved_row\global\c_tabl_ntb_row\m_tabl_ntb_saved_row
- \pop_macro_m_tabl_ntb_saved_col\global\c_tabl_ntb_col\m_tabl_ntb_saved_col
- \else
- \global\intablefalse
- \fi}
-
-\unexpanded\def\tabl_ntb_next_level
- {\advance\c_tabl_level\plusone
- \edef\m_tabl_tbl_level{\the\c_tabl_level}}
-
-\unexpanded\def\tabl_ntb_prev_level
- {\advance\c_tabl_level\minusone
- \edef\m_tabl_tbl_level{\the\c_tabl_level}}
-
-\tabl_ntb_next_level % go to level 1
-
-\installcorenamespace{naturaltable} % was tbl
-\installcorenamespace{naturaltablelocal} % was tbltbl
-
-\installdirectcommandhandler \??naturaltable {naturaltable} % \??naturaltable
-\installsimpleframedcommandhandler \??naturaltablelocal {naturaltablelocal} \??naturaltablelocal
-
-\installcorenamespace{naturaltabletal}
-\installcorenamespace{naturaltablegal}
-\installcorenamespace{naturaltablenob}
-\installcorenamespace{naturaltabletag}
-\installcorenamespace{naturaltablecol}
-\installcorenamespace{naturaltablerow}
-\installcorenamespace{naturaltablewd}
-\installcorenamespace{naturaltableht}
-\installcorenamespace{naturaltabledp}
-\installcorenamespace{naturaltablewid}
-\installcorenamespace{naturaltablehei}
-\installcorenamespace{naturaltabledis}
-\installcorenamespace{naturaltableaut}
-\installcorenamespace{naturaltablebck}
-%installcorenamespace{naturaltablefwd} % forcedwidth
-\installcorenamespace{naturaltabletxt}
-\installcorenamespace{naturaltablespn}
-\installcorenamespace{naturaltableref}
-\installcorenamespace{naturaltableset}
-\installcorenamespace{naturaltablecell}
-\installcorenamespace{naturaltablesqueeze}
-\installcorenamespace{naturaltabletok}
-
-\letvalue{\??naturaltablesqueeze }\donefalse
-\letvalue{\??naturaltablesqueeze\v!fit }\donetrue
-\letvalue{\??naturaltablesqueeze\v!fixed}\donetrue
-\letvalue{\??naturaltablesqueeze\v!broad}\donetrue
-\letvalue{\??naturaltablesqueeze\v!local}\donetrue
-
-\def\tabl_ntb_let_gal{\expandafter\glet\csname\??naturaltablegal\m_tabl_tbl_level\endcsname}
-\def\tabl_ntb_get_gal{\csname\??naturaltablegal\m_tabl_tbl_level\endcsname}
-
-\def\tabl_ntb_let_tal#1{\expandafter\glet\csname\??naturaltabletal\m_tabl_tbl_level:\number#1\endcsname}
-\def\tabl_ntb_get_tal#1{\csname\??naturaltabletal\m_tabl_tbl_level:\number#1\endcsname}
-
-\def\tabl_ntb_set_nob#1{\expandafter\let\csname\??naturaltablenob\m_tabl_tbl_level:\number#1\endcsname\plusone}
-\def\tabl_ntb_get_nob#1{\ifcsname\??naturaltablenob\m_tabl_tbl_level:\number#1\endcsname\plusone\else\zerocount\fi}
-
-%def\tabl_ntb_set_tag#1#2{\expandafter\edef\csname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_set_col#1#2{\expandafter\edef\csname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_set_row#1#2{\expandafter\edef\csname\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-\def\tabl_ntb_let_tag#1#2{\expandafter\let\csname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_let_col#1#2{\expandafter\let\csname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_let_row#1#2{\expandafter\let\csname\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-%def\tabl_ntb_set_wd#1#2{\expandafter\xdef\csname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global !
-\def\tabl_ntb_set_ht#1#2{\expandafter\xdef\csname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global !
-
-%def\tabl_ntb_let_wd#1#2{\expandafter\glet\csname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global !
-\def\tabl_ntb_let_ht#1#2{\expandafter\glet\csname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global !
-
-\def\tabl_ntb_get_tag#1#2{\csname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_get_col#1#2{\csname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_get_row#1#2{\csname\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-%def\tabl_ntb_get_wd#1#2{\csname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_get_ht#1#2{\csname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-\def\tabl_ntb_set_wid#1{\expandafter\xdef\csname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-\def\tabl_ntb_set_hei#1{\expandafter\xdef\csname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-\def\tabl_ntb_set_dis#1{\expandafter\xdef\csname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-\def\tabl_ntb_set_aut#1{\expandafter\xdef\csname\??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-
-\def\tabl_ntb_let_wid#1{\expandafter\glet\csname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-\def\tabl_ntb_let_hei#1{\expandafter\glet\csname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-\def\tabl_ntb_let_dis#1{\expandafter\glet\csname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-\def\tabl_ntb_let_aut#1{\expandafter\glet\csname\??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} % {#2} global !
-
-\def\tabl_ntb_get_wid#1{\ifcsname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
-\def\tabl_ntb_get_hei#1{\ifcsname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
-\def\tabl_ntb_get_dis#1{\ifcsname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname\lastnamedcs\else\zeropoint\fi}
-\def\tabl_ntb_get_aut#1{\csname \??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname}
-
-\def\tabl_ntb_let_bck#1#2{\global\expandafter\chardef\csname\??naturaltablebck\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-\def\tabl_ntb_get_bck#1#2{\csname\??naturaltablebck\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-\def\tabl_ntb_tag_pattern#1#2{\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2}
-\def\tabl_ntb_row_pattern#1#2{\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2}
-\def\tabl_ntb_col_pattern#1#2{\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2}
-
-\def\tabl_ntb_tag_doif #1#2{\ifcsname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi}
-\def\tabl_ntb_tag_doifnot #1#2{\ifcsname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname\expandafter\gobbleoneargument \else\expandafter\firstofoneargument \fi}
-\def\tabl_ntb_tag_doifelse#1#2{\ifcsname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
-\def\tabl_ntb_row_doif #1#2{\ifcsname\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi}
-\def\tabl_ntb_col_doif #1#2{\ifcsname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi}
-\def\tabl_ntb_col_doifnot #1#2{\ifcsname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname\expandafter\gobbleoneargument \else\expandafter\firstofoneargument \fi}
-
-%D If we ever run into memory issues we can do:
-%
-% \def\tabl_ntb_let_tag#1#2#3%
-% {\ifx#3\c_tabl_ntb_none\else
-% \expandafter\let\csname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname#3%
-% \fi}
-%
-% \def\tabl_ntb_get_tag#1#2%
-% {\ifcsname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname
-% \lastnamedcs
-% \else
-% \c_tabl_ntb_none
-% \fi}
-
-% not used
-%
-% \def\tabl_ntb_tag_state#1#2{\ifcsname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname\zerocount\else\plusone\fi}
-% \def\tabl_ntb_row_state#1#2{\ifcsname\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2\endcsname\zerocount\else\plusone\fi}
-% \def\tabl_ntb_col_state#1#2{\ifcsname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname\zerocount\else\plusone\fi}
-
-%def\tabl_ntb_set_spn #1{\expandafter\let\csname\??naturaltablespn\m_tabl_tbl_level:\number#1\endcsname \!!plusone}
-%def\tabl_ntb_spn_doifelse#1{\doifelse {\csname\??naturaltablespn\m_tabl_tbl_level:\number#1\endcsname}\!!plusone}
-
-%def\tabl_ntb_set_spn #1{\setvalue {\??naturaltablespn\m_tabl_tbl_level:\number#1}{1}}
-%def\tabl_ntb_spn_doifelse#1{\doifelsevalue{\??naturaltablespn\m_tabl_tbl_level:\number#1}{1}}
-
-\def\tabl_ntb_let_ref #1#2{\expandafter\glet\csname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-\def\tabl_ntb_set_ref #1#2{\expandafter\xdef\csname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-%def\tabl_ntb_get_ref #1#2{\ifcsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname\csname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname\fi}
-\def\tabl_ntb_get_ref #1#2{\begincsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-\def\tabl_ntb_set_spn #1{\expandafter\let\csname\??naturaltablespn\m_tabl_tbl_level:\number#1\endcsname \!!plusone}
-\def\tabl_ntb_spn_doifelse#1{\ifcase0\csname\??naturaltablespn\m_tabl_tbl_level:\number#1\endcsname\relax % could be inlined
- \expandafter\secondoftwoarguments % unset
- \else
- \expandafter\firstoftwoarguments % a span
- \fi}
-
-% keep for a while:
-%
-% \unexpanded\def\tabl_ntb_set_txt_process#1#2#3#4#5#6% nasty: we restore the level
-% {\expandafter\def\csname\??naturaltabletxt\m_tabl_tbl_level:\number#1:\number#2\expandafter\endcsname\expandafter
-% {\expandafter\def\expandafter\m_tabl_tbl_level\expandafter{\m_tabl_tbl_level}\tabl_ntb_cell_process{#3}{#4}[#5]{#6}}}
-
-\unexpanded\def\tabl_ntb_set_txt_process#1#2#3#4#5#6%
- {\expandafter\def\csname\??naturaltabletxt\m_tabl_tbl_level:\number#1:\number#2\endcsname
- {\tabl_ntb_cell_process{#3}{#4}[#5]{\tabl_ntb_next_level#6\tabl_ntb_prev_level}}}
-
-\def\tabl_ntb_get_txt#1#2%
- {\csname\??naturaltabletxt\m_tabl_tbl_level:\number#1:\number#2\endcsname}
-
-% to be changed:
-
-\newif\ifsqueezeTBLspan \squeezeTBLspantrue % spans one column cell over multi column par cells
-\newif\ifautosqueezeTBLspan \autosqueezeTBLspantrue % unless explicit widths are given
-\newif\ifautoTBLspread \autoTBLspreadfalse
-\newif\ifautoTBLhsize \autoTBLhsizetrue
-\newif\ifautoTBLrowspan \autoTBLrowspantrue
-\newif\ifautoTBLemptycell \autoTBLemptycelltrue
-\newif\ifautoTBLcheckwidth \autoTBLcheckwidthtrue
-\newif\ifappendTBLsetups \appendTBLsetupstrue
-\newif\ifenableTBLbreak \enableTBLbreakfalse
-\newif\ifmultipleTBLheads \multipleTBLheadsfalse
-\newif\iftightTBLrowspan \tightTBLrowspantrue
-\newif\iftightTBLcolspan \tightTBLcolspanfalse
-
-\newconditional \c_tabl_ntb_trace_widths
-
-\installtextracker
- {tables.natural.widths}
- {\settrue \c_tabl_ntb_trace_widths}
- {\setfalse\c_tabl_ntb_trace_widths}
-
-% so far
-
-\unexpanded\def\tabl_ntb_cell_process#1#2[#3]{}
-
-\unexpanded\def\bTC#1\eTC{\bTD#1\eTD} \let\eTC\relax
-\unexpanded\def\bTX#1\eTX{\bTD#1\eTD} \let\eTX\relax
-\unexpanded\def\bTY#1\eTY{\bTR#1\eTR} \let\eTY\relax
-
-\unexpanded\def\setupTABLE
- {\dotripleempty\tabl_ntb_setup}
-
-\let\tabl_ntb_parameters_get\setupcurrentnaturaltablelocal
-
-\def\tabl_ntb_setup
- {\ifthirdargument
- \expandafter\tabl_ntb_setup_three
- \orelse\ifsecondargument
- \doubleexpandafter\tabl_ntb_setup_two
- \else
- \doubleexpandafter\tabl_ntb_setup_one
- \fi}
-
-\def\tabl_ntb_setup_one[#1][#2][#3]%
- {\setupcurrentnaturaltablelocal[#1]}
-
-\def\tabl_ntb_setup_xy[#1][#2][#3]%
- {\def\tabl_ntb_setup_step##1{\tabl_ntb_parameters_set[#1##1][#3]}%
- \processcommalist[#2]\tabl_ntb_setup_step}
-
-\def\tabl_ntb_setup_un[#1][#2][#3]%
- {\def\tabl_ntb_setup_step##1%
- {\def\tabl_ntb_setup_step_step####1{\tabl_ntb_parameters_set[\c!x##1\c!y####1][#3]}%
- \processcommalist[#2]\tabl_ntb_setup_step_step}%
- \processcommalist[#1]\tabl_ntb_setup_step}
-
-\def\tabl_ntb_setup_each[#1][#2][#3]% ignores #3
- {\tabl_ntb_parameters_set[#1\v!each][#2]}
-
-\def\tabl_ntb_setup_ux[#1][#2][#3]% ignores #3
- {\def\tabl_ntb_setup_step##1{\tabl_ntb_parameters_set[\c!x##1][#2]}%
- \processcommalist[#1]\tabl_ntb_setup_step}
-
-\installcorenamespace{naturaltablesetupthree}
-\installcorenamespace{naturaltablesetuptwo}
-
-%def\tabl_ntb_setup_three[#1]{\csname\??naturaltablesetupthree\ifcsname\??naturaltablesetupthree#1\endcsname#1\else\s!unknown\fi\endcsname[#1]}
-%def\tabl_ntb_setup_two [#1]{\csname\??naturaltablesetuptwo \ifcsname\??naturaltablesetuptwo #1\endcsname#1\else\s!unknown\fi\endcsname[#1]}
-
-\def\tabl_ntb_setup_three[#1]{\ifcsname\??naturaltablesetupthree#1\endcsname\expandafter\lastnamedcs\else\expandafter\tabl_ntb_setup_un\fi[#1]}
-\def\tabl_ntb_setup_two [#1]{\ifcsname\??naturaltablesetuptwo #1\endcsname\expandafter\lastnamedcs\else\expandafter\tabl_ntb_setup_ux\fi[#1]}
-
-\setvalue{\??naturaltablesetupthree \v!row}[#1]{\tabl_ntb_setup_xy [\c!y]}
-\setvalue{\??naturaltablesetupthree \v!column}[#1]{\tabl_ntb_setup_xy [\c!x]}
-\setvalue{\??naturaltablesetupthree \v!start}[#1]{\tabl_ntb_setup_xy [\v!start]}
-\setvalue{\??naturaltablesetupthree \v!header}[#1]{\tabl_ntb_setup_xy [\v!header]}
-
-\setvalue{\??naturaltablesetuptwo \v!row}[#1]{\tabl_ntb_setup_each[\c!y]}
-\setvalue{\??naturaltablesetuptwo \v!column}[#1]{\tabl_ntb_setup_each[\c!x]}
-\setvalue{\??naturaltablesetuptwo \v!start}[#1]{\tabl_ntb_setup_each[\v!start]}
-\setvalue{\??naturaltablesetuptwo \v!header}[#1]{\tabl_ntb_setup_each[\v!header]}
-
-\letvalue{\??naturaltablesetupthree\s!unknown}\tabl_ntb_setup_un
-\letvalue{\??naturaltablesetuptwo \s!unknown}\tabl_ntb_setup_ux
-
-\letcsnamecsname\csname\??naturaltablesetupthree r\endcsname\csname\??naturaltablesetupthree \v!row\endcsname
-\letcsnamecsname\csname\??naturaltablesetupthree c\endcsname\csname\??naturaltablesetupthree\v!column\endcsname
-\letcsnamecsname\csname\??naturaltablesetupthree y\endcsname\csname\??naturaltablesetupthree \v!row\endcsname
-\letcsnamecsname\csname\??naturaltablesetupthree x\endcsname\csname\??naturaltablesetupthree\v!column\endcsname
-
-\letcsnamecsname\csname\??naturaltablesetuptwo r\endcsname\csname\??naturaltablesetuptwo \v!row\endcsname
-\letcsnamecsname\csname\??naturaltablesetuptwo c\endcsname\csname\??naturaltablesetuptwo \v!column\endcsname
-\letcsnamecsname\csname\??naturaltablesetuptwo y\endcsname\csname\??naturaltablesetuptwo \v!row\endcsname
-\letcsnamecsname\csname\??naturaltablesetuptwo x\endcsname\csname\??naturaltablesetuptwo \v!column\endcsname
-
-\def\tabl_ntb_parameters_set[#1][#2]%
- {\ifappendTBLsetups
- \ifcsname\??naturaltableset\m_tabl_tbl_level:#1\endcsname
- \def\tabl_ntb_parameters_get[##1]%
- {\setvalue{\??naturaltableset\m_tabl_tbl_level:#1}{\tabl_ntb_parameters_get[##1,#2]}}%
- \csname\??naturaltableset\m_tabl_tbl_level:#1\endcsname
- \let\tabl_ntb_parameters_get\setupcurrentnaturaltablelocal
- \else
- \setvalue{\??naturaltableset\m_tabl_tbl_level:#1}{\tabl_ntb_parameters_get[#2]}%
- \fi
- \else
- \setvalue{\??naturaltableset\m_tabl_tbl_level:#1}{\tabl_ntb_parameters_get[#2]}%
- \fi}
-
-% % \setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white]
-% \setupTABLE [first][first][backgroundcorner=2,corner=10,frame=on]
-% \setupTABLE [last] [first][backgroundcorner=4,corner=12,frame=on]
-%
-% \setupTABLE [row] [each] [background=color,backgroundcolor=blue,frame=on,framecolor=white]
-% \setupTABLE [first][2] [corner=8]
-% \setupTABLE [last] [2] [corner=5]
-% \setupTABLE [first][last] [corner=7]
-% \setupTABLE [last] [last] [corner=6]
-%
-% \startTEXpage
-% \bTABLE[frame=off,align=middle]
-% \bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR
-% \bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR
-% \bTR \bTD alpha \eTD \bTD beta \eTD \bTD gamma \eTD \eTR
-% \eTABLE
-% \stopTEXpage
-%
-% \setupTABLE [first] [two][corner=2] % special case
-% \setupTABLE [last] [two][corner=4] % special case
-%
-% % % \setupTABLE [one] [first] ... special case of span
-%
-% \startTEXpage
-% \bTABLE[frame=off,align=middle]
-% \bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR
-% \bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR
-% \eTABLE
-% \stopTEXpage
-
-%D By default rowspans are tight but you can change that:
-%D
-%D \startbuffer
-%D \bTABLE
-%D \bTR[height=20pt] \bTH 1. col \eTH \bTH 2. col \eTH \eTR
-%D \bTR[height=20pt] \bTD 1 row in 1. col \eTD \bTD[nr=2] 2 rows in 2. col \eTD \eTR
-%D \bTR[height=20pt] \bTD[nr=2] 2 rows in 1. col\eTD \eTR
-%D \bTR[height=20pt] \bTD[nr=3] 3 rows in 2. col \eTD \eTR
-%D \bTR[height=20pt] \bTD 1 row in 1. col \eTD \eTR
-%D \bTR[height=20pt] \bTD 1 row in 1. col \eTD \eTR
-%D \eTABLE
-%D
-%D \bTABLE
-%D \bTR[height=20pt] \bTH 2. col \eTH \bTH 1. col \eTH \eTR
-%D \bTR[height=20pt] \bTD[nr=2] 2 rows in 2. col \eTD \bTD 1 row in 1. col \eTD \eTR
-%D \bTR[height=20pt] \bTD[nr=2] 2 rows in 1. col\eTD \eTR
-%D \bTR[height=20pt] \bTD[nr=3] 3 rows in 2. col \eTD \eTR
-%D \bTR[height=20pt] \bTD 1 row in 1. col \eTD \eTR
-%D \bTR[height=20pt] \bTD 1 row in 1. col \eTD \eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \getbuffer
-%D
-%D With \type {\tightTBLrowspanfalse} we get:
-%D
-%D \start \tightTBLrowspanfalse \getbuffer \stop
-
-\let\tabl_ntb_setup_section\relax
-
-\unexpanded\def\tabl_ntb_setup_cell#1#2% cell over col over row
- {\tabl_ntb_setup_section % already forgotten
- \edef\m_tabl_ntb_positive_row{\number#1}%
- \edef\m_tabl_ntb_positive_col{\number#2}%
- \edef\m_tabl_ntb_negative_row{\the\numexpr-\c_tabl_ntb_maximum_row+#1+\minusone\relax}%
- \edef\m_tabl_ntb_negative_col{\the\numexpr-\c_tabl_ntb_maximum_col+#2+\minusone\relax}%
- % saves tokens (no speed gain)
- \edef\m_tabl_ntb_prefix{\??naturaltableset\m_tabl_tbl_level:}%
- % each each
- \begincsname\m_tabl_ntb_prefix\c!x\v!each\c!y\v!each\endcsname
- \begincsname\m_tabl_ntb_prefix\c!y\v!each\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\v!each\endcsname
- % odd even
- \begincsname\m_tabl_ntb_prefix\c!y\v!oddeven\m_tabl_ntb_positive_row\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\v!oddeven\m_tabl_ntb_positive_col\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\v!oddeven\m_tabl_ntb_positive_col\c!y\v!oddeven\m_tabl_ntb_positive_row\endcsname
- % row/col number combinations
- \begincsname\m_tabl_ntb_prefix\c!y\m_tabl_ntb_positive_row\endcsname
- \begincsname\m_tabl_ntb_prefix\c!y\m_tabl_ntb_negative_row\endcsname
- \naturaltablelocalparameter\c!extras
- \letnaturaltablelocalparameter\c!extras\relax % new, see x-fo
- \begincsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_positive_col\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_negative_col\endcsname
- \naturaltablelocalparameter\c!extras
- \letnaturaltablelocalparameter\c!extras\relax % new, see x-fo
- % first/last combinations
- \ifnum\m_tabl_ntb_positive_row=\plusone
- \begincsname\m_tabl_ntb_prefix\c!y\v!first\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_positive_col\c!y\v!first\endcsname
- \fi
- \ifnum\m_tabl_ntb_positive_col=\plusone
- \begincsname\m_tabl_ntb_prefix\c!x\v!first\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\v!first\c!y\m_tabl_ntb_positive_row\endcsname
- \fi
- \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax
- \begincsname\m_tabl_ntb_prefix\c!y\v!last\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_positive_col\c!y\v!last\endcsname
- \fi
- \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax
- \begincsname\m_tabl_ntb_prefix\c!x\v!last\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\v!last\c!y\m_tabl_ntb_positive_row\endcsname
- \fi
- \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax
- \begincsname\m_tabl_ntb_prefix\c!x\v!last\c!y\v!last\endcsname
- \fi\fi
- \ifnum\m_tabl_ntb_positive_row=\plusone \ifnum\m_tabl_ntb_positive_col=\plusone
- \begincsname\m_tabl_ntb_prefix\c!x\v!first\c!y\v!first\endcsname
- \fi\fi
- \ifnum\m_tabl_ntb_positive_row=\plusone \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax
- \begincsname\m_tabl_ntb_prefix\c!x\v!last\c!y\v!first\endcsname
- \fi\fi
- \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\plusone
- \begincsname\m_tabl_ntb_prefix\c!x\v!first\c!y\v!last\endcsname
- \fi\fi
- % special case: two rows and last row : two&first and two&last (round corners)
- \ifnum\c_tabl_ntb_maximum_row=\plustwo\relax
- \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\plusone
- \begincsname\m_tabl_ntb_prefix\c!x\v!first\c!y\v!two\endcsname
- \fi\fi
- \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax
- \begincsname\m_tabl_ntb_prefix\c!x\v!last\c!y\v!two\endcsname
- \fi\fi
- \fi
- \ifnum\tabl_ntb_get_col\m_tabl_ntb_positive_row\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax % top span over whole width
- \ifnum\m_tabl_ntb_positive_row=\plusone
- \begincsname\m_tabl_ntb_prefix\c!x\v!one\c!y\v!first\endcsname
- \fi
- \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax
- \begincsname\m_tabl_ntb_prefix\c!x\v!one\c!y\v!last\endcsname
- \fi
- \fi
- % header things
- \ifnum#1>\c_tabl_ntb_n_of_hdnx_lines\else
- \begincsname\m_tabl_ntb_prefix\v!header\v!each\endcsname
- \begincsname\m_tabl_ntb_prefix\v!header\m_tabl_ntb_positive_col\endcsname
- \fi
- % explicit cells
- \begincsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_positive_col\c!y\m_tabl_ntb_positive_row\endcsname
- \begincsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_negative_col\c!y\m_tabl_ntb_negative_row\endcsname
- % local
- \begincsname\m_tabl_ntb_prefix\c!y++\m_tabl_ntb_positive_row\endcsname
- % done
- \relax}
-
-% we cannot use +n (checking on number/last/first would slow down too much)
-%
-% \setupTABLE[r] [2][color=red]
-% \setupTABLE[r] [-2][color=red]
-% \setupTABLE[c] [2][color=green]
-% \setupTABLE[c] [-2][color=green]
-% \setupTABLE[4] [4][color=blue]
-% \setupTABLE[-4][-4][color=blue]
-%
-% \bTABLE
-% \dorecurse{10}{\bTR \dorecurse{6}{\bTD xxx \eTD} \eTR}
-% \eTABLE
-
-\let\m_tabl_ntb_before_split\empty
-\let\m_tabl_ntb_after_split \empty
-\let\m_tabl_ntb_same_page \empty
-
-% split + page:
-%
-% \bTABLE[split=yes]
-% \bTR \bTD left \eTD\bTD right \eTD\eTR
-% \bTR[after=\page] \bTD left \eTD\bTD right \eTD\eTR
-% \bTR \bTD left \eTD\bTD right \eTD\eTR
-% \eTABLE
-
-\unexpanded\def\tabl_ntb_tr
- {\c_tabl_ntb_running_col\zerocount
- \c_tabl_ntb_encountered_col\zerocount
- \advance\c_tabl_ntb_maximum_row\plusone
- \iffirstargument
- \expandafter\tabl_ntb_tr_yes
- \else
- \expandafter\gobbleoneoptional
- \fi}
-
-\def\tabl_ntb_tr_yes[#1]%
- {\setvalue{\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_ntb_maximum_row}{\setupcurrentnaturaltablelocal[#1]}}
-
-\def\m_tabl_ntb_default_nr{\naturaltableparameter\c!nr}
-\def\m_tabl_ntb_default_nc{\naturaltableparameter\c!nc}
-
-\unexpanded\def\tabl_ntb_td
- {\advance\c_tabl_ntb_encountered_col\plusone
- \iffirstargument
- \expandafter\tabl_ntb_td_yes
- \else
- \expandafter\tabl_ntb_td_nop
- \fi}
-
-\def\tabl_ntb_td_yes[#1]#2\eTD
- {\letnaturaltableparameter\c!ny \m_tabl_ntb_default_nr
- \letnaturaltableparameter\c!nx \m_tabl_ntb_default_nc
- \letnaturaltableparameter\c!nc \plusone
- \letnaturaltableparameter\c!nr \plusone
- \letnaturaltableparameter\c!n \c_tabl_ntb_running_col
- \letnaturaltableparameter\c!m \empty
- \letnaturaltableparameter\c!action\empty % not that important
- \setupcurrentnaturaltable[#1]%
- %
- \c_tabl_ntb_nx\naturaltableparameter\c!nx\relax
- \c_tabl_ntb_ny\naturaltableparameter\c!ny\relax
- % goto first cell n/m=cellnumber
- \edef\m_tabl_ntb_n{\naturaltableparameter\c!n}%
- \edef\m_tabl_ntb_m{\naturaltableparameter\c!m}%
- %
- \ifx\m_tabl_ntb_n\empty
- \global\advance\c_tabl_ntb_spn\c_tabl_ntb_nx\relax
- \orelse\ifnum\m_tabl_ntb_n=\c_tabl_ntb_running_col\else
- \tabl_ntb_td_pass_n{#1}%
- \fi
- \ifx\m_tabl_ntb_m\empty \else
- \ifnum\m_tabl_ntb_m=\c_tabl_ntb_running_col\else
- \tabl_ntb_td_pass_m{#1}%
- \fi
- \fi
- \doloop % skip over columns that result from earlier span
- {\advance\c_tabl_ntb_running_col\plusone
- \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\endcsname \else
- \exitloop
- \fi}%
- % fill r*c cells and set span
- \c_tabl_ntb_nx\naturaltableparameter\c!nx\relax
- \c_tabl_ntb_ny\naturaltableparameter\c!ny\relax
- \ifnum\c_tabl_ntb_nx=\plusone
- \ifnum\c_tabl_ntb_ny=\plusone
- \ifnum\c_tabl_ntb_running_col>\c_tabl_ntb_maximum_col\relax
- \c_tabl_ntb_maximum_col\c_tabl_ntb_running_col
- \fi
- \else
- \tabl_ntb_cell_preset
- \fi
- \else
- \tabl_ntb_cell_preset
- \fi
- % set values
- \tabl_ntb_let_tag\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\c_tabl_ntb_cell
- \tabl_ntb_set_col\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_nx}%
- \tabl_ntb_set_row\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_ny}%
- % the action key will change!
- \tabl_ntb_set_ref\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\naturaltableparameter\c!action}%
- % save text
- \normalexpanded
- {\tabl_ntb_set_txt_process\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_maximum_row}{\the\c_tabl_ntb_running_col}}%
- {#1}{#2}%
- \ifnum\c_tabl_ntb_encountered_col>\c_tabl_ntb_encountered_max
- \c_tabl_ntb_encountered_max\c_tabl_ntb_encountered_col
- \fi}
-
-\def\tabl_ntb_td_nop[#1]#2\eTD
- {\global\advance\c_tabl_ntb_spn\plusone\relax
- \doloop
- {\advance\c_tabl_ntb_running_col\plusone
- \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\endcsname \else
- \exitloop
- \fi}%
- \c_tabl_ntb_nx\plusone
- \c_tabl_ntb_ny\plusone
- \ifnum\c_tabl_ntb_running_col>\c_tabl_ntb_maximum_col\relax
- \c_tabl_ntb_maximum_col\c_tabl_ntb_running_col
- \fi
- \tabl_ntb_let_tag\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\c_tabl_ntb_cell
- \tabl_ntb_set_col\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_nx}%
- \tabl_ntb_set_row\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_ny}%
- \tabl_ntb_let_ref\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\empty
- \normalexpanded
- {\tabl_ntb_set_txt_process\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_maximum_row}{\the\c_tabl_ntb_running_col}}%
- {#1}{#2}%
- \ifnum\c_tabl_ntb_encountered_col>\c_tabl_ntb_encountered_max
- \c_tabl_ntb_encountered_max\c_tabl_ntb_encountered_col
- \fi}
-
-\def\tabl_ntb_td_pass_n#1%
- {\scratchcounter\numexpr\m_tabl_ntb_n-\c_tabl_ntb_running_col+\minusone-\c_tabl_ntb_spn\relax
- \ifnum\scratchcounter>\zerocount
- \normalexpanded{\tabl_ntb_td[\c!nx=\the\scratchcounter,\c!n=,\c!m=,*sq=\v!no]}\eTD
- \fi
- \letnaturaltableparameter\c!ny\m_tabl_ntb_default_nr
- \letnaturaltableparameter\c!nx\m_tabl_ntb_default_nc
- \letnaturaltableparameter\c!nc\plusone
- \letnaturaltableparameter\c!nr\plusone
- \setupcurrentnaturaltable[#1]%
- \letnaturaltableparameter\c!n \empty
- \letnaturaltableparameter\c!m \empty}
-
-\def\tabl_ntb_td_pass_m#1%
- {\scratchcounter\numexpr\m_tabl_ntb_m-\c_tabl_ntb_running_col+\minusone-\c_tabl_ntb_spn\relax
- \dorecurse\scratchcounter{\normalexpanded{\tabl_ntb_td[\c!n=,\c!m=]}\eTD}%
- % can be sped up
- \letnaturaltableparameter\c!ny\m_tabl_ntb_default_nr
- \letnaturaltableparameter\c!nx\m_tabl_ntb_default_nc
- \letnaturaltableparameter\c!nc\plusone
- \letnaturaltableparameter\c!nr\plusone
- \setupcurrentnaturaltable[#1]%
- \letnaturaltableparameter\c!n \empty
- \letnaturaltableparameter\c!m \empty}
-
-\def\tabl_ntb_cell_preset
- {\c_tabl_ntb_current_row\c_tabl_ntb_maximum_row
- \c_tabl_ntb_current_col\c_tabl_ntb_running_col
- \dorecurse\c_tabl_ntb_ny\tabl_ntb_cell_preset_rows
- % check max column
- \advance\c_tabl_ntb_current_col\minusone
- \ifnum\c_tabl_ntb_current_col>\c_tabl_ntb_maximum_col\relax
- \c_tabl_ntb_maximum_col\c_tabl_ntb_current_col
- \fi}
-
-\def\tabl_ntb_cell_preset_rows
- {\c_tabl_ntb_current_col\c_tabl_ntb_running_col
- \tabl_ntb_set_col\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_nx}%
- \ifnum\c_tabl_ntb_nx>\c_tabl_ntb_maximum_row_span\relax
- \c_tabl_ntb_maximum_row_span\c_tabl_ntb_nx
- \fi
- \dorecurse\c_tabl_ntb_nx\tabl_ntb_cell_preset_cells
- \advance\c_tabl_ntb_current_row\plusone}
-
-\def\tabl_ntb_cell_preset_cells
- {\tabl_ntb_let_tag\c_tabl_ntb_current_row\c_tabl_ntb_current_col\c_tabl_ntb_none
- \advance\c_tabl_ntb_current_col\plusone}
-
-%D The usage of n and m:
-%D
-%D \startbuffer
-%D \bTABLE[width=3em]
-%D \bTR\bTD d1 \eTD\bTD[n=2] d2 \eTD\bTD[n=5] d5 \eTD\bTD[n=7] d7 \eTD\eTR
-%D \bTR\bTD f1 \eTD\bTD[n=4] f4 \eTD\bTD[n=5] f5 \eTD\bTD[n=7] f7 \eTD\eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D \startbuffer
-%D \bTABLE[width=3em]
-%D \bTR\bTD d1 \eTD\bTD[m=2] d2 \eTD\bTD[m=5] d5 \eTD\bTD[m=7] d7 \eTD\eTR
-%D \bTR\bTD f1 \eTD\bTD[m=4] f4 \eTD\bTD[m=5] f5 \eTD\bTD[m=7] f7 \eTD\eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D \startbuffer
-%D \bTABLE[frame=on]
-%D \bTR \bTH[nc=3] One \eTH \bTH[m=4] Four \eTH\eTR
-%D \bTR \bTD a \eTD\bTD b \eTD\bTD c \eTD\bTD d \eTD\eTR
-%D \eTABLE
-%D
-%D \bTABLE[frame=on]
-%D \bTR \bTH[nr=2] One \eTH \bTH[m=3] Three \eTH\eTR
-%D \bTR \bTD[m=3] a \eTD\bTD b \eTD\bTD c \eTD\bTD d \eTD\eTR
-%D \bTR \bTD[m=3] a \eTD\bTD b \eTD\bTD c \eTD\bTD d \eTD\eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\def\tabl_ntb_th[#1]#2\eTH
- {\tabl_ntb_td[#1,\c!color=\naturaltablelocalparameter\c!headcolor,\c!style=\naturaltablelocalparameter\c!headstyle,\c!aligncharacter=\v!no]#2\eTD}
-
-\def\tabl_ntb_tn[#1]#2\eTN
- {\tabl_ntb_td[#1]\digits#2\relax\eTD}
-
-%D Vit Zyka needed the option to create a distance between columns, so I added
-%D support for individual column distances.
-%D
-%D \startbuffer
-%D % \setupTABLE[c][each][distance=2em]
-%D \setupTABLE[c][1][distance=2em]
-%D \setupTABLE[c][2][distance=3em]
-%D
-%D \bTABLE
-%D \bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR
-%D \bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR
-%D \bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR
-%D \eTABLE
-%D
-%D \bTABLE[option=stretch]
-%D \bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR
-%D \bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR
-%D \bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR
-%D \eTABLE
-%D \stopbuffer
-%D
-%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection
-%D
-%D and he provided patches for the global left and right margin distances as well as
-%D the columndistance (although i changed the names -). Here is his testcase:
-%D
-%D \startbuffer
-%D \framed[offset=overlay]\bgroup
-%D \setupTABLE[column][2][align=left]%
-%D \setupTABLE[column][3][align=right]%
-%D \bTABLE[columndistance=2cm,leftmargindistance=.3cm,rightmargindistance=.5cm]
-%D \bTR \bTH[nc=3] Table head\eTH \eTR
-%D \bTR \bTD[nc=2] AB\eTD \bTD C\eTD \eTR
-%D \bTR \bTD[nc=2,align=left] AB\eTD \bTD C\eTD \eTR
-%D \bTR \bTD[nc=2,align=middle] AB\eTD \bTD C\eTD \eTR
-%D \bTR \bTD A\eTD \bTD B\eTD \bTD C\eTD \eTR
-%D \bTR \bTD Aa\eTD \bTD Bb\eTD \bTD Cccc\eTD \eTR
-%D \bTR \bTD[nc=3,align=middle] ABC\eTD \eTR
-%D \eTABLE
-%D \egroup
-%D \stopbuffer
-%D
-%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection
-
-% to be done: head foot, dus state var
-
-\unexpanded\def\bTABLEhead{\dosingleempty\tabl_ntb_head} \let\eTABLEhead\relax
-\unexpanded\def\bTABLEnext{\dosingleempty\tabl_ntb_next} \let\eTABLEnext\relax
-\unexpanded\def\bTABLEbody{\dosingleempty\tabl_ntb_body} \let\eTABLEbody\relax
-\unexpanded\def\bTABLEfoot{\dosingleempty\tabl_ntb_foot} \let\eTABLEfoot\relax
-
-\def\tabl_ntb_head[#1]#2\eTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head}
-\def\tabl_ntb_next[#1]#2\eTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next}
-\def\tabl_ntb_body[#1]#2\eTABLEbody{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_body}
-\def\tabl_ntb_foot[#1]#2\eTABLEfoot{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_foot}
-
-\def\tabl_ntb_section[#1]#2% also used in tabl-nte
- {\unexpanded\def\tabl_ntb_setup_section{\setupcurrentnaturaltablelocal[#1]}%
- #2%
- \let\tabl_ntb_setup_section\relax}
-
-\def\tabl_ntb_preset_parameters% each odd|even level / can be sped up but only once per table
- {\begincsname\??naturaltableset\m_tabl_tbl_level:\v!start\v!each\endcsname
- \begincsname\??naturaltableset\m_tabl_tbl_level:\v!start\v!oddeven\m_tabl_tbl_level\endcsname
- \begincsname\??naturaltableset\m_tabl_tbl_level:\v!start\m_tabl_tbl_level\endcsname}
-
-\unexpanded\def\bTABLE
- {\dosingleempty\tabl_ntb_table}
-
-\def\tabl_ntb_table[#1]%
- {\tabl_ntb_table_push
- % box not here
- \bgroup
- \pushpostponednodedata
- \t_tabl_ntb_head\emptytoks
- \t_tabl_ntb_next\emptytoks
- \t_tabl_ntb_body\emptytoks
- \t_tabl_ntb_foot\emptytoks
- \ifhmode\kern\zeropoint\fi % blocks \removeunwantedspaces: check this on icare handelingsschema
- \resetcharacteralign % new
- \setupcurrentnaturaltablelocal[\c!align={\v!right,\v!broad,\v!high},#1]%
- %
- \d_tabl_ntb_leftmargindistance \naturaltablelocalparameter\c!leftmargindistance\relax
- \d_tabl_ntb_rightmargindistance\naturaltablelocalparameter\c!rightmargindistance\relax
- \d_tabl_ntb_columndistance \naturaltablelocalparameter\c!columndistance\relax
- \d_tabl_ntb_maxwidth \naturaltablelocalparameter\c!maxwidth\relax
- %
- \usesetupsparameter\naturaltablelocalparameter
- \doifelse{\naturaltablelocalparameter\c!textwidth}\v!local
- {\hsize\availablehsize}
- {\hsize\naturaltablelocalparameter\c!textwidth}%
- \enableTBLbreakfalse
- \multipleTBLheadsfalse
- \autoTBLspreadfalse
- \tightTBLcolspanfalse
- \processaction
- [\naturaltablelocalparameter\c!split]
- [ \v!yes=>\enableTBLbreaktrue,
- \v!repeat=>\enableTBLbreaktrue\multipleTBLheadstrue,
- \v!auto=>\ifinsidesplitfloat\enableTBLbreaktrue\fi]
- \processaction
- [\naturaltablelocalparameter\c!header]
- [\v!repeat=>\multipleTBLheadstrue]%
- \tabl_ntb_preset_parameters
- \processallactionsinset
- [\naturaltablelocalparameter\c!option]
- [\v!stretch=>\autoTBLspreadtrue,%
- \v!tight=>\tightTBLcolspantrue]%
- \linewidth\naturaltablelocalparameter\c!rulethickness % needs to be frozen
- \dontcomplain
- \c_tabl_ntb_running_col \zerocount
- \c_tabl_ntb_maximum_col \zerocount
- \c_tabl_ntb_maximum_row \zerocount
- \c_tabl_ntb_maximum_row_span\plusone
- \let\currentTABLErow \tabl_ntb_current_row
- \let\currentTABLEcolumn\tabl_ntb_current_column
- \let\nofTABLErows \tabl_ntb_n_of_rows
- \let\nofTABLEcolumns \tabl_ntb_n_of_columns
- \let\bTR\dobTR
- \let\bTD\dobTD
- \let\bTH\dobTH
- \let\bTN\dobTN}
-
-\def\tabl_ntb_current_row {\m_tabl_ntb_positive_row}
-\def\tabl_ntb_current_column{\m_tabl_ntb_positive_col}
-\def\tabl_ntb_n_of_rows {\number\c_tabl_ntb_maximum_row}
-\def\tabl_ntb_n_of_columns {\number\c_tabl_ntb_maximum_col}
-
-\let\currentTABLErow \!!zerocount
-\let\currentTABLEcolumn\!!zerocount
-\let\nofTABLErows \!!zerocount
-\let\nofTABLEcolumns \!!zerocount
-
-% there is no gain in a \doifelsenextoptionalcs variant
-
-\unexpanded\def\dobTR{\dosingleempty\tabl_ntb_tr} % also used in tabl-nte
-\unexpanded\def\dobTD{\dosingleempty\tabl_ntb_td} % also used in tabl-nte
-\unexpanded\def\dobTH{\dosingleempty\tabl_ntb_th} % also used in tabl-nte
-\unexpanded\def\dobTN{\dosingleempty\tabl_ntb_tn} % also used in tabl-nte
-
-% permits \expanded{\bTD ... \eTD}
-
-\let\bTR\relax \unexpanded\def\eTR{\ignorespaces} % handy in case we use a macro to generate rows
-\let\bTD\relax \unexpanded\def\eTD{\ignorespaces}
-\let\bTH\relax \unexpanded\def\eTH{\ignorespaces}
-\let\bTN\relax \unexpanded\def\eTN{\ignorespaces}
-
-\unexpanded\def\eTABLE % beware, we need to get rid of spurious spaces when in hmode
- {% tricky and dirty order -)
- \setfalse\c_tabl_ntb_okay
- % head
- \doifelsesometoks\t_tabl_ntb_head % slow, better a flag
- {\c_tabl_ntb_head\numexpr\c_tabl_ntb_maximum_row+\plusone\relax
- \the\t_tabl_ntb_head
- \c_tabl_ntb_n_of_head_lines\c_tabl_ntb_maximum_row\relax
- \doifelsesometoks\t_tabl_ntb_next
- {\the\t_tabl_ntb_next
- \c_tabl_ntb_n_of_next_lines\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_n_of_head_lines\relax}%
- {\c_tabl_ntb_n_of_next_lines\zerocount}% was 1
- \c_tabl_ntb_n_of_hdnx_lines\c_tabl_ntb_maximum_row}
- {\c_tabl_ntb_head\zerocount
- \c_tabl_ntb_n_of_head_lines\zerocount % was 1
- \c_tabl_ntb_n_of_next_lines\zerocount
- \c_tabl_ntb_n_of_hdnx_lines\zerocount}%
- % body
- \c_tabl_ntb_body\numexpr\c_tabl_ntb_maximum_row+\plusone\relax
- \the\t_tabl_ntb_body
- % foot
- \doifelsesometoks\t_tabl_ntb_foot
- {\c_tabl_ntb_foot\numexpr\c_tabl_ntb_maximum_row+\plusone\relax
- \the\t_tabl_ntb_foot}%
- {\c_tabl_ntb_foot\zerocount}%
- % done
- \removeunwantedspaces % only if hmode
- % finish cells
- \tabl_ntb_loop_one
- % to be sure
- \tabl_ntb_loop_two
- % check and do
- \ifcase\c_tabl_ntb_maximum_col\else
- \startTBLprocessing
- \tabl_ntb_table_start
- \dorecurse\c_tabl_ntb_maximum_row
- {\tabl_ntb_row_start
- \c_tabl_ntb_current_row\recurselevel\relax
- \dorecurse\c_tabl_ntb_maximum_col
- {\c_tabl_ntb_current_col\recurselevel\relax
- \normalexpanded{\tabl_ntb_cell{\the\c_tabl_ntb_current_row}{\the\c_tabl_ntb_current_col}}}%
- \tabl_ntb_row_stop}%
- \removeunwantedspaces % only if hmode
- \tabl_ntb_table_stop
- \stopTBLprocessing
- % wrong ! ! ! better to have an auto-offset-overlay
- % \ifnum\m_tabl_tbl_level>1
- % \vskip-\strutdp
- % \fi
- \fi
- % tracing
- % \iftrue
- % \blank \tttf
- % \dorecurse\c_tabl_ntb_maximum_row
- % {\c_tabl_ntb_current_row\recurselevel\relax
- % \dorecurse\c_tabl_ntb_maximum_col
- % {\c_tabl_ntb_current_col\recurselevel\relax
- % [r=\the\c_tabl_ntb_current_row,c=\the\c_tabl_ntb_current_col,h=\the\dimexpr\tabl_ntb_get_ht\c_tabl_ntb_current_row\c_tabl_ntb_current_col,w=\the\dimexpr\tabl_ntb_get_wd\c_tabl_ntb_current_row\c_tabl_ntb_current_col]}%
- % \par}%
- % \blank
- % \fi
- \poppostponednodedata
- \egroup
- \tabl_ntb_table_pop}
-
-\def\tabl_ntb_loop_one
- {\dorecurse\c_tabl_ntb_maximum_row{\tabl_ntb_loop_one_rows}}
-
-\def\tabl_ntb_loop_one_rows
- {\c_tabl_ntb_current_row\recurselevel\relax
- \dorecurse\c_tabl_ntb_maximum_col\tabl_ntb_loop_one_cells}
-
-\def\tabl_ntb_loop_one_cells
- {\c_tabl_ntb_current_col\recurselevel\relax
- \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname \else
- \tabl_ntb_loop_one_cells_indeed
- \fi}
-
-\def\tabl_ntb_loop_one_cells_indeed
- {\c_tabl_ntb_current_col_two\c_tabl_ntb_current_col
- \c_tabl_ntb_current_row_two\c_tabl_ntb_current_row
- \c_tabl_ntb_current_row_one\c_tabl_ntb_current_row
- \doloop
- {\c_tabl_ntb_current_col_one\c_tabl_ntb_current_col
- \doloop
- {\ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_current_row_one\c_tabl_ntb_current_col_one\endcsname
- \exitloop
- \else
- \advance\c_tabl_ntb_current_col_one\plusone
- \ifnum\c_tabl_ntb_current_col_one>\c_tabl_ntb_maximum_col\relax
- \exitloop
- \fi
- \fi}%
- \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_current_row_one\c_tabl_ntb_current_col_one\endcsname
- \exitloop
- \else
- \c_tabl_ntb_current_row_two\c_tabl_ntb_current_row_one
- \c_tabl_ntb_current_col_two\c_tabl_ntb_current_col_one
- \advance\c_tabl_ntb_current_row_one\plusone
- \ifnum\c_tabl_ntb_current_row_one>\c_tabl_ntb_maximum_row
- \exitloop
- \fi
- \fi}%
- \ifnum\c_tabl_ntb_current_row_two>\c_tabl_ntb_maximum_row\c_tabl_ntb_current_row_two\c_tabl_ntb_maximum_row\fi
- \ifnum\c_tabl_ntb_current_col_two>\c_tabl_ntb_maximum_col\c_tabl_ntb_current_col_two\c_tabl_ntb_maximum_col\fi
- \c_tabl_ntb_current_row_two\numexpr\c_tabl_ntb_current_row_two-\c_tabl_ntb_current_row+\plusone\relax
- \c_tabl_ntb_current_col_two\numexpr\c_tabl_ntb_current_col_two-\c_tabl_ntb_current_col+\plusone\relax
- \c_tabl_ntb_current_row_one\c_tabl_ntb_current_row
- \dorecurse\c_tabl_ntb_current_row_two
- {\c_tabl_ntb_current_col_one\c_tabl_ntb_current_col
- \tabl_ntb_set_col\c_tabl_ntb_current_row_one\c_tabl_ntb_current_col_one{\the\c_tabl_ntb_current_col_two}%
- \dorecurse\c_tabl_ntb_current_col_two
- {\tabl_ntb_let_tag\c_tabl_ntb_current_row_one\c_tabl_ntb_current_col_one\c_tabl_ntb_none
- \advance\c_tabl_ntb_current_col_one\plusone}%
- \advance\c_tabl_ntb_current_row_one\plusone}%
- \tabl_ntb_let_tag\c_tabl_ntb_current_row\c_tabl_ntb_current_col\c_tabl_ntb_cell
- \tabl_ntb_set_col\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_current_col_two}%
- \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_current_row_two}%
- \ifautoTBLemptycell
- \normalexpanded
- {\tabl_ntb_set_txt_process\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_current_row}{\the\c_tabl_ntb_current_col}}%
- {\c!option=\v!tight}{\strut\kern\scaledpoint}% the kern forces the tight
- \fi}
-
-\def\tabl_ntb_loop_two
- {\dorecurse\c_tabl_ntb_maximum_row\tabl_ntb_loop_two_rows}
-
-\def\tabl_ntb_loop_two_rows
- {\c_tabl_ntb_current_row\recurselevel\relax
- \dorecurse\c_tabl_ntb_maximum_col\tabl_ntb_loop_two_cells}
-
-\def\tabl_ntb_loop_two_cells
- {\c_tabl_ntb_current_col\recurselevel\relax
- \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname
- \scratchcounter\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_current_row+\plusone\relax
- \ifnum\tabl_ntb_get_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col>\scratchcounter
- \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\scratchcounter}%
- \fi
- \fi
- \tabl_ntb_let_ht\c_tabl_ntb_current_row\c_tabl_ntb_current_col\zeropoint
- %tabl_ntb_let_wd\c_tabl_ntb_current_row\c_tabl_ntb_current_col\zeropoint
- \ifcsname\tabl_ntb_col_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname \else
- \tabl_ntb_let_col\c_tabl_ntb_current_row\c_tabl_ntb_current_col\zerocount
- \fi
- \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname \else
- \tabl_ntb_let_tag\c_tabl_ntb_current_row\c_tabl_ntb_current_col\c_tabl_ntb_none
- \fi}
-
-\let\startTBLprocessing\relax % public
-\let\stopTBLprocessing \relax % public
-
-\newcount\c_tabl_prelocated_rows % \prelocateTBLrows{1000} may speed up large tables
-
-% \def\tabl_ntb_row_start{\t_tabl_ntb_row\emptytoks}
-% \def\tabl_ntb_row_stop {\normalexpanded{\t_tabl_ntb{\the\t_tabl_ntb\noexpand\tabl_ntb_row_align_start\the\t_tabl_ntb_row\tabl_ntb_row_align_stop}}}
-
-\def\tabl_ntb_row_start
- {\t_tabl_ntb_row\emptytoks}
-
-\def\tabl_ntb_row_stop
- {\ifenableTBLbreak
- \tabl_ntb_row_stop_split
- \else
- \tabl_ntb_row_stop_boxed
- \fi}
-
-\def\tabl_ntb_row_stop_boxed
- {% \noindent % no, else double leftskip in narrower
- \etoksapp\t_tabl_ntb
- {% no need for init
- \tabl_ntb_row_align_start
- \the\t_tabl_ntb_row
- \tabl_ntb_row_align_stop}}
-
-\def\tabl_ntb_row_stop_split
- {\ifcsname\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_ntb_current_row\endcsname
- \tabl_ntb_row_stop_split_yes
- \else
- \tabl_ntb_row_stop_split_nop
- \fi}
-
-\def\tabl_ntb_row_stop_split_nop
- {\etoksapp\t_tabl_ntb
- {\tabl_ntb_row_align_reset
- \tabl_ntb_row_align_start
- \the\t_tabl_ntb_row
- \tabl_ntb_row_align_stop}}
-
-\def\tabl_ntb_row_stop_split_yes
- {\begingroup
- \csname\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_ntb_current_row\endcsname
- \xdef\m_tabl_ntb_before_split{\naturaltablelocalparameter\c!before}% to be checked
- \xdef\m_tabl_ntb_after_split {\naturaltablelocalparameter\c!after}% to be checked
- \xdef\m_tabl_ntb_same_page {\naturaltablelocalparameter\c!samepage}%
- \endgroup
- \etoksapp\t_tabl_ntb
- {\tabl_ntb_row_align_set{\m_tabl_ntb_before_split}{\m_tabl_ntb_after_split}{\m_tabl_ntb_same_page}%
- \tabl_ntb_row_align_start
- \the\t_tabl_ntb_row
- \tabl_ntb_row_align_stop}}
-
-\unexpanded\def\tabl_ntb_row_align_set#1#2#3%
- {\xdef\m_tabl_ntb_before_split{#1}%
- \xdef\m_tabl_ntb_after_split {#2}%
- \xdef\m_tabl_ntb_same_page {#3}}
-
-\unexpanded\def\tabl_ntb_row_align_reset
- {\glet\m_tabl_ntb_before_split\empty
- \glet\m_tabl_ntb_after_split \empty
- \glet\m_tabl_ntb_same_page \empty}
-
-\def\tabl_ntb_prelocate_error
- {\writestatus\m!TABLE{fatal error: use \string\prelocateTBLrows\space to increase table memory (now: \the\c_tabl_prelocated_rows)}}
-
-% \prelocateTBLrows{1000} % may speed up large tables
-
-\def\prelocateTBLrows#1% we start at zero so we have one to much, better play safe anyway
- {\dostepwiserecurse\c_tabl_prelocated_rows{#1}\plusone
- {\expandafter\newtoks\csname\??naturaltabletok\recurselevel\endcsname}%
- \def\tabl_ntb_row_start
- {\ifnum\c_tabl_ntb_row<\c_tabl_prelocated_rows\relax
- \tabl_ntb_prelocate_okay
- \else
- \tabl_ntb_prelocate_error
- \fi}%
- \def\tabl_ntb_row_stop
- {\etoksapp\t_tabl_ntb
- {\tabl_ntb_row_align_start
- \the\csname\??naturaltabletok\the\c_tabl_ntb_row\endcsname
- \tabl_ntb_row_align_stop}}%
- \global\c_tabl_prelocated_rows#1\relax}
-
-\def\tabl_ntb_prelocate_okay
- {\expandafter\let\expandafter\t_tabl_ntb_row\csname\??naturaltabletok\the\c_tabl_ntb_row\endcsname\t_tabl_ntb_row\emptytoks}
-
-%D We use aligments to handle the empty (skipped) columns, so that we don't have to
-%D (re|)|calculate these.
-
-\let\m_tabl_ntb_saved_row\!!zerocount
-\let\m_tabl_ntb_saved_col\!!zerocount
-
-\def\tabl_ntb_start_tagged
- {\scratchcounter\numexpr\c_tabl_ntb_row+\plusone\relax
- \ifnum\scratchcounter=\c_tabl_ntb_head
- \ifconditional\c_tabl_ntb_okay
- \dostoptagged
- \else
- \settrue\c_tabl_ntb_okay
- \fi
- \dostarttagged\t!tablehead\empty
- \orelse\ifnum\scratchcounter=\c_tabl_ntb_body
- \ifconditional\c_tabl_ntb_okay
- \dostoptagged
- \else
- \settrue\c_tabl_ntb_okay
- \fi
- \dostarttagged\t!tablebody\empty
- \orelse\ifnum\scratchcounter=\c_tabl_ntb_foot
- \ifconditional\c_tabl_ntb_okay
- \dostoptagged
- \else
- \settrue\c_tabl_ntb_okay
- \fi
- \dostarttagged\t!tablefoot\empty
- \fi
- \dostarttagged\t!tablerow\empty}
-
-\def\tabl_ntb_stop_tagged
- {\dostoptagged
- \ifconditional\c_tabl_ntb_okay
- \scratchcounter\numexpr\c_tabl_ntb_row+\plustwo\relax
- \ifnum\scratchcounter=\c_tabl_ntb_body
- \dostoptagged
- \setfalse\c_tabl_ntb_okay
- \orelse\ifnum\scratchcounter=\c_tabl_ntb_foot
- \dostoptagged
- \setfalse\c_tabl_ntb_okay
- \orelse\ifnum\scratchcounter>\c_tabl_ntb_maximum_row
- \dostoptagged
- \setfalse\c_tabl_ntb_okay
- \fi
- \fi}
-
-\unexpanded\def\tabl_ntb_row_align_start
- {\global\advance\c_tabl_ntb_row\plusone
- \global\c_tabl_ntb_col\plusone
- \global\c_tabl_ntb_spn\zerocount
- \tabl_ntb_row_align_start_inject
- \ifconditional\c_strc_tags_enabled
- \tabl_ntb_start_tagged
- \fi
- \hbox\bgroup
- \kern\dimexpr\d_tabl_ntb_leftmargindistance\relax}
-
-\unexpanded\def\tabl_ntb_row_align_stop
- {\kern\dimexpr\d_tabl_ntb_rightmargindistance-\d_tabl_ntb_columndistance\relax
- \egroup
- \ifconditional\c_strc_tags_enabled
- \tabl_ntb_stop_tagged
- \fi
- \tabl_ntb_row_align_stop_inject}
-
-\unexpanded\def\tabl_ntb_before_page
- {\ifx\m_tabl_ntb_same_page\v!before
- % \blank[\v!samepage,\v!strong]%
- \unpenalty
- \nobreak
- \orelse\ifx\m_tabl_ntb_same_page\v!both
- % \blank[\v!samepage,\v!strong]%
- \unpenalty
- \nobreak
- \fi}
-
-\unexpanded\def\tabl_ntb_after_page
- {\ifnum\c_tabl_ntb_row>\c_tabl_ntb_n_of_head_lines
- \ifnum\tabl_ntb_get_nob\c_tabl_ntb_row=\zerocount
- \unpenalty
- \ifx\m_tabl_ntb_same_page\v!after
- % \blank[\v!samepage,\v!strong]%
- \nobreak
- \orelse\ifx\m_tabl_ntb_same_page\v!both
- % \blank[\v!samepage,\v!strong]%
- \nobreak
- \else
- % \blank[\v!preference,\v!weak]%
- \allowbreak
- \fi
- \fi
- \else
- % \blank[\v!preference,\v!weak]%
- \allowbreak % else no proper head split off
- \fi}
-
-\unexpanded\def\tabl_ntb_inbetween
- {\scratchcounter\numexpr\c_tabl_ntb_row+\plusone\relax
- \ifnum\scratchcounter>\c_tabl_ntb_n_of_hdnx_lines\relax
- \ifnum\scratchcounter<\c_tabl_ntb_maximum_row\relax
- \edef\p_spaceinbetween{\naturaltablelocalparameter\c!spaceinbetween}%
- \ifx\p_spaceinbetween\empty\else
- \blank[\p_spaceinbetween]%
- \fi
- \fi
- \fi}
-
-\unexpanded\def\tabl_ntb_row_align_start_inject
- {\bgroup % protect local vars
- \m_tabl_ntb_before_split
- \egroup
- \ifenableTBLbreak
- \tabl_ntb_before_page
- \fi}
-
-\unexpanded\def\tabl_ntb_row_align_stop_inject
- {\par
- \nointerlineskip
- \ifenableTBLbreak
- \tabl_ntb_after_page
- \fi
- \bgroup % protect local vars
- \m_tabl_ntb_after_split
- \egroup
- \bgroup % protect local vars
- \tabl_ntb_inbetween
- \egroup}
-
-\def\tabl_ntb_flush_content
- {\the\everyTABLEpass
- \global\c_tabl_ntb_spn\zerocount
- \global\c_tabl_ntb_col\zerocount
- \global\c_tabl_ntb_row\zerocount
- \global\advance\c_tabl_ntb_row\minusone
- \dostarttaggedchained\t!table\empty\??naturaltable
- %\registerparoptions % (*) triggers max hsize
- \the\t_tabl_ntb
- \dostoptagged}
-
-\unexpanded\def\tabl_ntb_span#1%
- {\hskip\tabl_ntb_get_dis\c_tabl_ntb_col
- \dorecurse{#1}
- {\hskip\tabl_ntb_get_wid\c_tabl_ntb_col\relax
- \global\advance\c_tabl_ntb_col\plusone}}
-
-\unexpanded\def\tabl_ntb_skip#1%
- {\global\advance\c_tabl_ntb_col#1\relax}
-
-\unexpanded\def\tabl_ntb_plus
- {\global\advance\c_tabl_ntb_col\plusone
- \kern\d_tabl_ntb_columndistance}
-
-\setvalue{\??naturaltablecell\the\c_tabl_ntb_none}#1#2%
- {\scratchcounter\tabl_ntb_get_col{#1}{#2}\relax
- \ifnum\scratchcounter>\zerocount
- \etoksapp\t_tabl_ntb_row
- {\tabl_ntb_span{\the\scratchcounter}}%
- \fi}
-
-\setvalue{\??naturaltablecell\the\c_tabl_ntb_cell}#1#2%
- {\toksapp\t_tabl_ntb_row{\tabl_ntb_pass #1 #2 }% space delimited -> less tokens
- \scratchcounter\tabl_ntb_get_col{#1}{#2}\relax
- \ifnum\scratchcounter>\zerocount
- \etoksapp\t_tabl_ntb_row
- {\ifnum\scratchcounter=\plusone
- \tabl_ntb_plus
- \else
- \tabl_ntb_skip{\the\scratchcounter}%
- \fi}%
- \fi}
-
-\unexpanded\def\tabl_ntb_cell#1#2%
- {\csname\??naturaltablecell\the\tabl_ntb_get_tag{#1}{#2}\endcsname{#1}{#2}}
-
-\unexpanded\def\tabl_ntb_table_start
- {\global\c_tabl_ntb_spn\zerocount
- \global\c_tabl_ntb_row\zerocount
- \global\c_tabl_ntb_col\zerocount
- \c_tabl_tbl_pass\zerocount
- \t_tabl_ntb\emptytoks}
-
-\def\tabl_ntb_pass_one#1 #2 %
- {\tabl_ntb_get_txt{#1}{#2}}%
-
-\def\tabl_ntb_pass_two#1 #2 % meer in cellD
- {\d_tabl_ntb_width\zeropoint
- \scratchcounter\c_tabl_ntb_col
- \!!counta\tabl_ntb_get_col{#1}{#2}\relax
- \ifcase\!!counta\or
- \advance\d_tabl_ntb_width\dimexpr
- \tabl_ntb_get_wid\scratchcounter
- \relax
- \advance\scratchcounter\plusone
- \else
- \dorecurse\!!counta
- {\advance\d_tabl_ntb_width\dimexpr
- \tabl_ntb_get_wid\scratchcounter
- \ifnum\recurselevel<\!!counta
- +\d_tabl_ntb_columndistance
- +\tabl_ntb_get_dis\scratchcounter
- \fi
- \relax
- \advance\scratchcounter\plusone}%
- \fi
- \setbox\scratchbox\hbox{\tabl_ntb_get_txt{#1}{#2}}%
- \tabl_ntb_set_ht{#1}{#2}{\the\ht\scratchbox}%
- %tabl_ntb_set_wd{#1}{#2}{\the\wd\scratchbox}%
- \ifdim\ht\scratchbox>\tabl_ntb_get_hei{#1}\relax
- \tabl_ntb_set_hei{#1}{\the\ht\scratchbox}%
- \fi}%
-
-\def\tabl_ntb_pass_three#1 #2 %
- {% height
- \dostarttagged\t!tablecell\empty
- \!!counta \tabl_ntb_get_col{#1}{#2}\relax
- \!!countb \tabl_ntb_get_row{#1}{#2}\relax
- \!!heighta\tabl_ntb_get_ht {#1}{#2}\relax
- \tablecellcolumns\!!counta % used later so don't adapt these
- \tablecellrows \!!countb % used later so don't adapt these
- \d_tabl_ntb_height\zeropoint
- \ifnum\!!counta=\c_tabl_ntb_maximum_col\relax
- % case: nc=maxcolumns
- \else
- \scratchcounter#1\relax
- \dorecurse\!!countb
- {\advance\d_tabl_ntb_height\tabl_ntb_get_hei\scratchcounter
- \advance\scratchcounter\plusone}%
- \ifdim\d_tabl_ntb_height<\!!heighta\relax
- \d_tabl_ntb_height\!!heighta
- \fi
- \fi
- % width
- \d_tabl_ntb_width\zeropoint
- \scratchcounter\c_tabl_ntb_col
- \ifcase\!!counta\or
- \advance\d_tabl_ntb_width\dimexpr
- \tabl_ntb_get_wid\scratchcounter
- \relax
- \advance\scratchcounter\plusone
- \else
- \dorecurse\!!counta
- {\advance\d_tabl_ntb_width\dimexpr
- \tabl_ntb_get_wid\scratchcounter
- \ifnum\recurselevel<\!!counta
- +\d_tabl_ntb_columndistance
- +\tabl_ntb_get_dis\scratchcounter
- \fi
- \relax
- \advance\scratchcounter\plusone}%
- \fi
- % cell
- \setbox\scratchbox\hbox attr \taggedattribute \attribute\taggedattribute \bgroup
- \dotagTABLEsignal % maybe we need to add some packaging in this case
- \tabl_ntb_get_txt{#1}{#2}%
- \egroup
- \ifnum\!!counta=\c_tabl_ntb_maximum_col\relax
- % case: nc=maxcolumns
- \else
- \scratchdimen\tabl_ntb_get_hei{#1}%
- \setbox\scratchbox\hpack
- {\lower\ht\scratchbox\hpack{\raise\scratchdimen\box\scratchbox}}%
- \ht\scratchbox\scratchdimen
- \fi
- \dp\scratchbox\zeropoint
- \edef\!!stringa{\tabl_ntb_get_ref{#1}{#2}}%
- \ifx\!!stringa\empty
- \box\scratchbox
- \else
- \normalexpanded{\noexpand\directgotobox{\box\scratchbox}[\!!stringa]}% to be checked
- \fi
- \dostoptagged} % right spot
-
-% \def\tabl_ntb_cell_finalize
-% {\doifnotinset\localwidth{\v!fit,\v!broad}% user set
-% {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax
-% \ifdim\localwidth>\scratchdimen
-% \tabl_ntb_set_aut\c_tabl_ntb_col{\the\dimexpr\localwidth}%
-% \fi}}
-
-\def\tabl_ntb_cell_finalize
- {\ifx\localwidth\v!fit
- % nothing
- \orelse\ifx\localwidth\v!broad
- % nothing
- \orelse\ifx\localwidth\empty
- % nothing (safeguard)
- \else
- \tabl_ntb_cell_finalize_indeed
- \fi}
-
-\def\tabl_ntb_cell_finalize_indeed
- {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax
- \ifdim\localwidth>\scratchdimen
- \tabl_ntb_set_aut\c_tabl_ntb_col{\the\dimexpr\localwidth}%
- \fi}
-
-\let\tabl_ntb_preroll\relax
-
-\def\tabl_ntb_table_get_max_width
- {\scratchdimen\wd\scratchbox\relax}
-
-% enable dper 2018-02-22
-
-\def\tabl_ntb_table_get_max_width_step
- {\advance\scratchdimen\tabl_ntb_get_wid\fastloopindex
- \advance\scratchdimen\tabl_ntb_get_dis\fastloopindex}
-
-\def\tabl_ntb_table_get_max_width
- {\scratchdimen\zeropoint
- \dofastloopcs\c_tabl_ntb_maximum_col\tabl_ntb_table_get_max_width_step
- \ifdim\scratchdimen<\wd\scratchbox\relax
- \scratchdimen\wd\scratchbox\relax
- \fi}
-
-\def\tabl_ntb_table_stop
- {\forgetall % new, here see narrower-004.tex
- %\setbox\scratchbox\hbox
- % {\letnaturaltablelocalparameter\c!frame\v!off
- % \letnaturaltablelocalparameter\c!background\empty
- % \letnaturaltablelocalparameter\c!align\v!no
- % \inheritednaturaltablelocalframed{\strut}}%
- %\edef\minimalcellheight{\the\ht\scratchbox}% not used
- \dorecurse\c_tabl_ntb_maximum_col
- {\tabl_ntb_let_aut\recurselevel\zeropoint
- % new
- \c_tabl_ntb_current_col_one\recurselevel\relax
- \dorecurse\c_tabl_ntb_maximum_row
- {%tabl_ntb_let_wd\recurselevel\c_tabl_ntb_current_col_one\zeropoint
- \tabl_ntb_let_ht\recurselevel\c_tabl_ntb_current_col_one\zeropoint}%
- % till here
- \tabl_ntb_let_tal\recurselevel\zerocount
- \tabl_ntb_let_wid\recurselevel\zeropoint
- \tabl_ntb_let_dis\recurselevel\zeropoint}%
- \dorecurse\c_tabl_ntb_maximum_row
- {\tabl_ntb_let_hei\recurselevel\maxdimen}%
- \tabl_ntb_let_gal\zerocount
- \tabl_ntb_preroll\relax
- \c_tabl_tbl_pass\plusone
- \let\tabl_ntb_pass\tabl_ntb_pass_one
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_a
- \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}%
- \ifcase\tabl_ntb_get_gal\or
- % \c_tabl_tbl_pass\plusone
- % \let\tabl_ntb_pass\tabl_ntb_pass_one
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_a_extra
- \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}%
- \fi
- \tabl_ntb_let_dis\c_tabl_ntb_maximum_col\zeropoint
- %
- \tabl_ntb_table_get_max_width % \scratchdimen\scratchbox
- %
- \ifautoTBLspread
- % experimental, stretch non fixed cells to \hsize
- \tabl_ntb_check_widths_one % trial run
- \tabl_ntb_check_widths_two % real run
- \tabl_ntb_stretch_widths
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_b
- \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}%
- % \orelse\ifdim\wd\scratchbox>\hsize
- \orelse\ifdim\scratchdimen>\hsize
- \ifautoTBLhsize
- \tabl_ntb_check_widths_one % trial run
- \tabl_ntb_check_widths_two % real run
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_b
- \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}%
- \fi
- \orelse\ifautoTBLrowspan
- \ifnum\c_tabl_ntb_maximum_row_span>\plusone % max ?
- % added jan 2002 because nx=* did no longer work
- \ifnum\c_tabl_ntb_encountered_max<\c_tabl_ntb_maximum_col
- % added jun 2014 because someone had less columns than nx .. sigh / see *nx*
- \writestatus\m!TABLE{missing\space\number\numexpr\c_tabl_ntb_maximum_col-\c_tabl_ntb_encountered_max\relax\space column(s), guessing widths}%
- \fi
- \edef\savedhsize{\the\hsize}%
- % \hsize\wd\scratchbox\relax % new per 17/04/2006
- \hsize\scratchdimen\relax % new per 17/04/2006
- \tabl_ntb_check_widths_one % trial run
- \tabl_ntb_check_widths_two % real run
- \hsize\savedhsize
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_c
- \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}%
- \fi
- \fi
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_d
- \c_tabl_tbl_pass\plustwo
- \let\tabl_ntb_pass\tabl_ntb_pass_two
- \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}%
- \tabl_ntb_check_heights_one
- \tabl_ntb_check_heights_two
- \let\tabl_ntb_cell_process\tabl_ntb_cell_process_e
- \c_tabl_tbl_pass\plusthree
- \let\tabl_ntb_pass\tabl_ntb_pass_three
- \ifnum\m_tabl_tbl_level>\plusone
- \tabl_tbl_split_nop
- \orelse\ifenableTBLbreak
- \tabl_tbl_split_yes
- \else
- \tabl_tbl_split_nop
- \fi}
-
-\def\tabl_ntb_stretch_widths % more variants, e.g. a max to \dimend
- {\ifcase\c_tabl_ntb_maximum_col\else % else division by zero
- \!!dimend\zeropoint
- \!!dimene\dimexpr
- \hsize
- -\d_tabl_ntb_leftmargindistance
- -\d_tabl_ntb_rightmargindistance
- +\d_tabl_ntb_columndistance
- \relax
- \dorecurse\c_tabl_ntb_maximum_col
- {\advance\!!dimend\dimexpr
- \tabl_ntb_get_wid\recurselevel
- \relax
- \advance\!!dimene\dimexpr
- -\tabl_ntb_get_dis\recurselevel
- -\d_tabl_ntb_columndistance
- \relax}%
- \relax
- % distribute width (stretch)
- \ifdim\!!dimend<\!!dimene
- \advance\!!dimend-\!!dimene
- \divide\!!dimend\c_tabl_ntb_maximum_col
- \dorecurse\c_tabl_ntb_maximum_col
- {\tabl_ntb_set_wid\recurselevel{\the\dimexpr\tabl_ntb_get_wid\recurselevel-\!!dimend\relax}}%
- \fi
- \fi}
-
-\def\tabl_tbl_split_nop
- {\setbox\b_tabl_ntb_final\vbox{\tabl_ntb_flush_content}%
- \postprocessTABLEbox\b_tabl_ntb_final
- \beforeTABLEbox
- % packaging prevents max hsized box
- % \hbox{\registerparoptions\box\b_tabl_ntb_final}% (*) better here
- % better :
- \ifinsidefloat
- % no \dontleavehmode else too wide, otherwise we get a \hsized box
- \else
- \registerparoptions % (*) better here (also does a \dontleavehmode)
- \ifhmode\else\dontleavehmode\fi
- \fi
- \box\b_tabl_ntb_final
- \afterTABLEbox}
-
-\def\tabl_tbl_split_yes
- {\ifinsidesplitfloat
- \donetrue
- \orelse\ifinsidefloat
- \donefalse
- \else
- \donetrue
- \fi
- \ifdone
- \expandafter\tabl_ntb_split_box
- \else
- \expandafter\tabl_tbl_split_nop
- \fi}
-
-\newbox\TABLEsplitbox % public, don't change
-
-\let\extratblsplitheight\zeropoint % additional space taken by before/afterTABLEsplitbox
-
-\def\tabl_ntb_split_box
- {\resettsplit
- \def\tsplitminimumfreelines{2}%
- \def\tsplitminimumfreespace{\dimexpr\extratblsplitheight+\naturaltablelocalparameter\c!splitoffset\relax}%
- \def\tsplitbeforeresult {\beforeTABLEsplitbox}%
- \def\tsplitafterresult {\afterTABLEsplitbox}%
- \def\tsplitafter {\m_tabl_ntb_after_split}%
- \def\tsplitbefore {\m_tabl_ntb_before_split}% supported ?
- \setbox\tsplitcontent\vbox{\tabl_ntb_flush_content}%
- \ifmultipleTBLheads
- \dorecurse\c_tabl_ntb_n_of_head_lines
- {\setbox\scratchbox\vsplit\tsplitcontent to \lineheight
- \setbox\tsplithead\vbox{\unvcopy\tsplithead\unvcopy\scratchbox}}% \vpack ?
- \dorecurse\c_tabl_ntb_n_of_next_lines
- {\setbox\scratchbox\vsplit\tsplitcontent to \lineheight
- \setbox\tsplitnext\vbox{\unvcopy\tsplitnext\unvcopy\scratchbox}}% \vpack ?
- \fi
- \edef\p_spaceinbetween{\naturaltablelocalparameter\c!spaceinbetween}%
- \ifx\p_spaceinbetween\empty\else
- \blank[\p_spaceinbetween]%
- \fi
- \def\postprocesstsplit{\postprocessTABLEsplitbox{\box\tsplitresult}}%
- \handletsplit}
-
-% ! ! ! ! TODO: naast \postprocessTABLEsplitbox ook evt \postprocessTABLEbox voor niet split
-
-\let\postprocessTABLEsplitbox\gobbleoneargument
-\let\postprocessTABLEbox \gobbleoneargument
-
-\let\beforeTABLEsplitbox\relax
-\let\afterTABLEsplitbox \relax
-\let\beforeTABLEbox \relax
-\let\afterTABLEbox \relax
-
-\def\tabl_ntb_check_widths_one{\tabl_ntb_check_widths_indeed\zerocount} % 0 = trial run
-\def\tabl_ntb_check_widths_two{\tabl_ntb_check_widths_indeed\plusone } % 1 = real run
-
-\def\tabl_ntb_check_widths_indeed#1%
- {\ifconditional\c_tabl_ntb_trace_widths\tabl_ntb_show_widths B#1\fi
- \!!counta\zerocount
- \!!dimena\dimexpr
- \hsize
- -\d_tabl_ntb_leftmargindistance
- -\d_tabl_ntb_rightmargindistance
- -\d_tabl_ntb_columndistance
- \relax
- \dorecurse\c_tabl_ntb_maximum_col
- {\scratchdimen\tabl_ntb_get_aut\recurselevel\relax
- \advance\!!dimena\dimexpr
- -\tabl_ntb_get_dis\recurselevel
- -\d_tabl_ntb_columndistance
- \relax
- \ifdim\scratchdimen>\zeropoint\relax
- \advance\!!dimena -\scratchdimen
- \else
- \scratchdimen\tabl_ntb_get_wid\recurselevel\relax
- \ifdim\scratchdimen>\d_tabl_ntb_maxwidth\relax
- \ifcase#1\else\tabl_ntb_let_wid\recurselevel\zeropoint\fi
- \advance\!!counta \plusone
- \orelse\ifdim\scratchdimen>\zeropoint\relax
- \advance\!!dimena -\scratchdimen
- \else
- % eigenlijk moet dit alleen als de kolom wordt overspannen door een
- % vorige, maw extra dubbele loop en status var
- \ifnum\c_tabl_ntb_encountered_max=\c_tabl_ntb_maximum_col % *nx* bah
- \advance\!!counta \plusone % setting maxwidth to a large value also works
- \fi
- \fi
- \fi}%
- \ifconditional\c_tabl_ntb_trace_widths\tabl_ntb_show_widths M#1\fi
- \ifcase\!!counta \else \divide\!!dimena \!!counta \fi
- \dorecurse\c_tabl_ntb_maximum_col
- {\scratchdimen\tabl_ntb_get_wid\recurselevel\relax
- \ifcase#1\relax
- \ifdim\scratchdimen<\!!dimena % take natural width
- \tabl_ntb_set_aut\recurselevel{\the\scratchdimen}%
- \fi
- \else
- \ifzeropt\scratchdimen % auto set width
- \tabl_ntb_set_wid\recurselevel{\the\!!dimena}%
- \fi
- \fi}%
- \ifconditional\c_tabl_ntb_trace_widths\tabl_ntb_show_widths E#1\fi}
-
-% todo: use scratchcounters, not !! ones
-
-\def\tabl_ntb_check_heights_one_indeed
- {\!!countb\tabl_ntb_get_row\c_tabl_ntb_current_row_three\c_tabl_ntb_current_col_three\relax
- % check row span
- \ifnum\!!countb>\plusone
- % current height in row
- \dimen0=\tabl_ntb_get_ht\c_tabl_ntb_current_row_three\c_tabl_ntb_current_col_three
- % find nearest height in row
- \dimen2=\zeropoint
- \dorecurse\c_tabl_ntb_maximum_col
- {\ifnum\recurselevel=\c_tabl_ntb_current_col_three\else
- \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row_three\recurselevel\endcsname
- \!!countc=\tabl_ntb_get_row\c_tabl_ntb_current_row_three\recurselevel\relax
- \ifnum\!!countc=\plusone
- \dimen4=\tabl_ntb_get_ht\c_tabl_ntb_current_row_three\recurselevel\relax
- \ifdim\dimen2<\dimen4
- \dimen2=\dimen4
- \fi
- \fi
- \fi
- \fi}%
- \c_tabl_ntb_current_row_four\c_tabl_ntb_current_row_three
- % calculate cummulative height
- \dimen4=\dimen2
- \!!countc\c_tabl_ntb_current_row_three
- \advance\!!countc\minusone
- \dorecurse\!!countb
- {\ifnum\c_tabl_ntb_current_row_four=\c_tabl_ntb_current_row_three\else
- \advance\dimen4 \tabl_ntb_get_hei\c_tabl_ntb_current_row_four
- \fi
- \ifnum\recurselevel=\!!countb\else
- \tabl_ntb_set_nob\!!countc
- \advance\!!countc\plusone
- \fi
- \advance\c_tabl_ntb_current_row_four\plusone}%
- % distribute overshoot equally
- \ifdim\dimen2>\zeropoint % new: test on natural-003
- \ifdim\dimen4<\dimen0
- \advance\dimen0 -\dimen4
- \divide\dimen0 \!!countb
- \c_tabl_ntb_current_row_four\c_tabl_ntb_current_row_three
- \tabl_ntb_set_hei\c_tabl_ntb_current_row_three{\the\dimen2}%
- \dorecurse\!!countb
- {\dorecurse\c_tabl_ntb_maximum_col
- {\ifnum\recurselevel=\c_tabl_ntb_current_col_three\else
- \scratchdimen\dimexpr\tabl_ntb_get_ht\c_tabl_ntb_current_row_four\recurselevel+\dimen0\relax
- \tabl_ntb_set_ht\c_tabl_ntb_current_row_four\recurselevel{\the\scratchdimen}%
- \ifdim\tabl_ntb_get_hei\c_tabl_ntb_current_row_four<\scratchdimen
- \tabl_ntb_set_hei\c_tabl_ntb_current_row_four{\the\scratchdimen}%
- \fi
- \fi}%
- \advance\c_tabl_ntb_current_row_four\plusone}%
- \orelse\ifdim\dimen4>\dimen0
- \iftightTBLrowspan
- \tabl_ntb_set_hei\c_tabl_ntb_current_row_three{\the\dimen2}%
- \fi
- \fi
- \fi
- \fi}
-
-\def\tabl_ntb_check_heights_one
- {\dorecurse\c_tabl_ntb_maximum_row
- {\c_tabl_ntb_current_row_three\recurselevel\relax
- \dorecurse\c_tabl_ntb_maximum_col
- {\c_tabl_ntb_current_col_three\recurselevel\relax
- \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row_three\c_tabl_ntb_current_col_three\endcsname
- \tabl_ntb_check_heights_one_indeed
- \fi}}}
-
-\def\tabl_ntb_check_heights_two
- {}
-
-\def\tabl_ntb_show_widths#1#2%
- {\begingroup
- \scratchdimen\zeropoint
- \dorecurse\c_tabl_ntb_maximum_col
- {\advance\scratchdimen\tabl_ntb_get_wid\recurselevel\relax}%
- \writestatus\m!TABLE{#1 \ifcase#2trial\else real\fi: hsize: \the\hsize, total: \the\scratchdimen}%
- \dorecurse\c_tabl_ntb_maximum_col
- {\writestatus\m!TABLE{\space\space\recurselevel: \the\dimexpr\tabl_ntb_get_wid\recurselevel}}%
- \endgroup}
-
-\def\tabl_ntb_char_align % called often
- {\edef\p_characteralign{\naturaltablelocalparameter\c!aligncharacter}%
- \ifx\p_characteralign\v!yes
- \ifcase\c_tabl_tbl_pass\or
- \tabl_ntb_let_tal\currentTABLEcolumn\plusone
- \tabl_ntb_let_gal\plusone
- \fi
- \expandafter\tabl_ntb_char_align_indeed
- \else
- \expandafter\gobbletwoarguments
- \fi}
-
-\def\tabl_ntb_char_align_indeed#1#2% row column
- {\ifcase\c_tabl_tbl_pass \or
- \setcharacteralign{#2}{\naturaltablelocalparameter\c!alignmentcharacter}% we could store the character in tal
- \fi
- \typo_charalign_adapt_font
- \signalcharacteralign{#2}{#1}}
-
-\unexpanded\def\tabl_ntb_cell_process_a_extra#1#2%
- {\ifcase\tabl_ntb_get_tal{#2}\relax
- \expandafter\tabl_ntb_cell_process_x
- \else
- \expandafter\tabl_ntb_cell_process_a
- \fi{#1}{#2}}
-
-\unexpanded\def\tabl_ntb_cell_process_x#1#2[#3]#4%
- {}
-
-% problem: when span doesn't break we can have a span that is the sum of cells but
-% still to small .. chicken egg problem ... for that we should also have a smallest
-% width run
-%
-% nilling the background makes a run upto 25% faster
-
-\def\tabl_ntb_cell_process_a_check_span_one
- {\ifautosqueezeTBLspan
- \edef\p_width{\naturaltablelocalparameter\c!width}%
- \ifcsname\??naturaltablesqueeze\p_width\endcsname\lastnamedcs\else\donefalse\fi
- \else
- \donetrue
- \fi
- \ifdone % brr, 0
- \ifnum\scratchcounter>\plusone
- \tabl_ntb_set_spn\c_tabl_ntb_col
- \fi
- \fi}
-
-\let\tabl_ntb_cell_process_a_check_span_two_yes\relax
-
-\def\tabl_ntb_cell_process_a_check_span_two_nop
- {\ifdim\tabl_ntb_get_wid\c_tabl_ntb_col<\wd\scratchbox
- \tabl_ntb_set_wid\c_tabl_ntb_col{\the\wd\scratchbox}%
- \fi}
-
-\unexpanded\def\tabl_ntb_cell_process_a#1#2[#3]#4% grouping added ! ! !
- {\bgroup
- \letnaturaltablelocalparameter\c!option\empty
- \tabl_ntb_setup_cell{#1}{#2}%
- \setupcurrentnaturaltablelocal[#3]%
- \letnaturaltablelocalparameter\c!background\empty
- \letnaturaltablelocalparameter\c!frame\v!off
- \scratchcounter\tabl_ntb_get_col{#1}{#2}\relax
- \setbox\scratchbox\hbox
- {\scratchdimen\naturaltablelocalparameter\c!distance\relax
- \ifdim\scratchdimen>\tabl_ntb_get_dis{#2}\relax
- \tabl_ntb_set_dis{#2}{\the\scratchdimen}%
- \fi
- \anch_backgrounds_text_level_start
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#1}{#2}#4\tabl_ntb_cell_stop\tabl_ntb_cell_finalize}%
- \anch_backgrounds_text_level_stop
- \ifcase\c_anch_backgrounds_text_count\else
- \tabl_ntb_let_bck{#1}{#2}\c_anch_backgrounds_text_state
- \fi
- }%
- \scratchdimen\tabl_ntb_get_wid\c_tabl_ntb_col\relax
- \ifdim\wd\scratchbox>\scratchdimen
- \ifsqueezeTBLspan
- \tabl_ntb_cell_process_a_check_span_one
- \fi
- \tabl_ntb_spn_doifelse\c_tabl_ntb_col
- \tabl_ntb_cell_process_a_check_span_two_yes
- \tabl_ntb_cell_process_a_check_span_two_nop
- \fi
- \scratchcounter\numexpr\c_tabl_ntb_row+\plusone\relax
- \scratchdimen\tabl_ntb_get_hei\scratchcounter\relax
- \ifdim\ht\scratchbox<\scratchdimen
- \tabl_ntb_set_hei\scratchcounter{\the\ht\scratchbox}% auto set
- \fi
- \tabl_ntb_set_ht{#1}{#2}{\the\ht\scratchbox}%
- %tabl_ntb_set_wd{#1}{#2}{\the\wd\scratchbox}%
- \ifautoTBLcheckwidth
- \ifdim\wd\scratchbox<.75\hsize % fuzzy guess
- \ifdim\ht\scratchbox>2\openlineheight % honor width since this
- \scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax % can be a figure or so
- \ifzeropt\scratchdimen
- % side effect: when width is set to 0pt,
- % we can force a span that fits the sum of spans widths
- \tabl_ntb_set_aut\c_tabl_ntb_col{\the\scratchdimen}%
- \orelse\ifdim\wd\scratchbox>\scratchdimen
- % unless span
- \tabl_ntb_set_aut\c_tabl_ntb_col{\the\wd\scratchbox}%
- % to be translated
- \writestatus\m!TABLE{no auto width in (\number#1,\number#2)\space\the\wd\scratchbox/\the\hsize}%
- \fi
- \fi
- \fi
- \fi
- \setbox\scratchboxone\emptyhbox
- \wd\scratchboxone\wd\scratchbox
- \ht\scratchboxone\ht\scratchbox
- \dp\scratchboxone\dp\scratchbox
- \box\scratchboxone
- \egroup}
-
-\unexpanded\def\tabl_ntb_cell_process_b_c#1#2#3[#4]#5%
- {\setbox\scratchbox\hbox
- {\tabl_ntb_setup_cell{#2}{#3}%
- \setupcurrentnaturaltablelocal[#4,#1]%
- \letnaturaltablelocalparameter\c!background\empty
- \letnaturaltablelocalparameter\c!frame\v!off
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start#5\tabl_ntb_cell_stop}}%
- \setbox2\emptyhbox % todo: \scratchboxtwo
- \wd2\wd\scratchbox
- \ht2\ht\scratchbox
- \dp2\dp\scratchbox
- \ifautoTBLrowspan
- \scratchcounter\numexpr\c_tabl_ntb_row+\plusone\relax
- \ifcsname\tabl_ntb_row_pattern\scratchcounter\c_tabl_ntb_col\endcsname
- \scratchdimen\tabl_ntb_get_hei\scratchcounter\relax
- \ifnum\tabl_ntb_get_row\scratchcounter\c_tabl_ntb_col>\plusone
- \ifdim\ht\scratchbox>\scratchdimen
- \ht2\dimexpr-\scratchdimen-\ht\scratchbox\relax
- \fi
- \fi
- \fi
- \fi
- \box2 }
-
-\unexpanded\def\tabl_ntb_cell_process_b#1#2[#3]#4%
- {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax
- \ifdim\scratchdimen>\zeropoint\relax
- \else
- \scratchdimen\tabl_ntb_get_wid\c_tabl_ntb_col\relax
- \ifdim\scratchdimen>\zeropoint\relax
- \ifnum\tabl_ntb_get_col{#1}{#2}=\c_tabl_ntb_maximum_col\relax
- \scratchdimen\hsize
- \fi
- \fi
- \fi
- \normalexpanded{\tabl_ntb_cell_process_b_c{\ifdim\scratchdimen>\zeropoint \c!width=\the\scratchdimen\fi}}%
- {#1}{#2}[#3]{\tabl_ntb_char_align{#1}{#2}#4}}
-
-\unexpanded\def\tabl_ntb_cell_process_c
- {\tabl_ntb_cell_process_b_c{}}
-
-\unexpanded\def\tabl_ntb_cell_process_d#1#2[#3]#4%
- {\tabl_ntb_setup_cell{#1}{#2}%
- \bgroup
- \setupcurrentnaturaltablelocal[#3]%
- \letnaturaltablelocalparameter\c!background\empty
- \letnaturaltablelocalparameter\c!frame\v!off
- \setnaturaltablelocalparameter\c!width{\d_tabl_ntb_width}%
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#1}{#2}#4\tabl_ntb_cell_stop}%
- \egroup}
-
-\unexpanded\def\tabl_ntb_cell_process_e#1#2[#3]#4%
- {\tabl_ntb_setup_cell{#1}{#2}%
- \setupcurrentnaturaltablelocal[#3]% to get the color right, the way we
- \color % handle color here prevents interference due to whatsit nodes
- [\naturaltablelocalparameter\c!color] % as well as permits local colors to take precedence
- {\letnaturaltablelocalparameter\c!color\empty
- \setnaturaltablelocalparameter\c!width{\d_tabl_ntb_width}%
- \ifzeropt\d_tabl_ntb_height % case: nc=maxcolumns
- \else
- \setnaturaltablelocalparameter\c!height{\d_tabl_ntb_height}%
- \fi
- \ifcase\c_anch_backgrounds_text_count\else
- \edef\p_region{\naturaltablelocalparameter\c!region}%
- \ifx\p_region\empty\ifnum\tabl_ntb_get_bck{#1}{#2}>\zerocount
- \letnaturaltablelocalparameter\c!region\v!yes
- \fi\fi
- \fi
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#1}{#2}#4\tabl_ntb_cell_stop}}%
- \hskip\tabl_ntb_get_dis{#2}}
-
-\newtoks\everyresetTABLEyes
-\newtoks\everyresetTABLEnop
-
-\appendtoks
- \setupTABLE [%
- %
- % framed defaults
- %
- \c!width=\v!fit,%
- \c!height=\v!fit,%
- \c!lines=,%
- \c!offset=.25\exheight,%
- \c!empty=\v!no,%
- \c!frame=\v!on,%
- \c!topframe=,%
- \c!bottomframe=,%
- \c!leftframe=,%
- \c!rightframe=,%
- \c!radius=.5\bodyfontsize,%
- \c!rulethickness=\linewidth,%
- \c!corner=\v!rectangular,%
- \c!depth=\zeropoint,%
- \c!foregroundcolor=,%
- \c!foregroundstyle=,%
- \c!background=,%
- \c!backgroundcolor=,%
- \c!backgroundoffset=\v!frame,%
- \c!framecolor=,%
- \c!frameoffset=.5\linewidth,%
- % \c!backgroundcorner=\framedparameter\c!corner,%
- % \c!backgrounddepth=\framedparameter\c!depth,%
- % \c!backgroundradius=\framedparameter\c!radius,%
- % \c!framecorner=\framedparameter\c!corner,%
- % \c!framedepth=\framedparameter\c!depth,%
- % \c!frameradius=\framedparameter\c!radius,%
- \c!component=,%
- \c!region=,%
- \c!align=,%
- \c!bottom=\vss,%
- \c!top=,%
- \c!strut=\v!yes,%
- \c!autostrut=\v!no,%
- \c!location=\v!normal,%
- \c!orientation=,%
- \c!autowidth=\v!yes,%
- \c!setups=,%
- \c!loffset=\zeropoint,%
- \c!roffset=\zeropoint,%
- \c!toffset=\zeropoint,%
- \c!boffset=\zeropoint,%
- %
- % table specific
- %
- \c!aligncharacter=\v!no,%
- \c!alignmentcharacter={,},%
- \c!color=,%
- \c!columndistance=\zeropoint,% each column (whole table)
- \c!distance=\zeropoint,% individual column
- \c!headcolor=,%
- \c!header=,%
- \c!headstyle=\v!bold,%
- \c!left=,%
- \c!leftmargindistance=\zeropoint,% whole table
- \c!maxwidth=8\emwidth,%
- \c!option=,% \v!stretch
- \c!right=,%
- \c!rightmargindistance=\zeropoint,% whole table
- \c!spaceinbetween=,%
- \c!split=\v!auto,%
- \c!splitoffset=\zeropoint,%
- \c!style=,%
- \c!textwidth=\v!local,% was \hsize
- ]%
-\to \everyresetTABLEyes
-
-\appendtoks
- \setupTABLE [%
- \c!width=\v!fit,%
- \c!height=\v!fit%
- ]%
-\to \everyresetTABLEnop
-
-\the\everyresetTABLEyes
-
-% \bgroup
-% \setupTABLE[column][1][aligncharacter=yes, alignmentcharacter={,}]
-% \bTABLE
-% \bTR \bTD 1,2 \eTD \bTD 2 \eTD \eTR
-% \bTR \bTD 11,2 \eTD \bTD
-% {\setupTABLE[column][1][aligncharacter=yes, alignmentcharacter={,}]
-% \bTABLE
-% \bTR \bTD 1,2 \eTD \bTD 2 \eTD \eTR
-% \bTR \bTD 11,22 \eTD \bTD 2 \eTD \eTR
-% \bTR \bTD 11,2 \eTD \bTD 2 \eTD \eTR \eTABLE} \eTD \eTR
-% \bTR \bTD 11,22 \eTD \bTD 2 \eTD \eTR
-% \eTABLE
-% \egroup
-
-\newconditional\resetTABLEmode \settrue\resetTABLEmode
-
-\def\tabl_ntb_parameters_reset % we can use setters instead
- {\ifnum\m_tabl_tbl_level>\plusone % in ieder geval
- \ifconditional\resetTABLEmode
- \the\everyresetTABLEyes
- \else
- \the\everyresetTABLEnop
- \fi
- \fi}
-
-% new (for Olivier Turlier)
-%
-% \defineTABLEsetup [xx] [foregroundcolor=red]
-%
-% \bTABLE
-% \bTR \bTD oeps \eTD \bTD oeps \eTD \eTR
-% \bTR \bTDs[xx] oeps \eTDs \bTD oeps \eTD \eTR
-% \bTRs[xx] \bTD oeps \eTD \bTD oeps \eTD \eTRs
-% \eTABLE
-
-\installcorenamespace{naturaltablesetup}
-
-\unexpanded\def\defineTABLEsetup
- {\dodoubleargument\tabl_ntb_define_setup}
-
-\def\tabl_ntb_define_setup[#1][#2]%
- {\setvalue{\??naturaltablesetup#1}{#2}}
-
-\let\eTDs\relax
-\let\eTRs\relax
-
-\unexpanded\def\bTDs[#1]#2\eTDs
- {\normalexpanded{\bTD[\begincsname\??naturaltablesetup#1\endcsname]}#2\eTD}
-
-\unexpanded\def\bTRs[#1]#2\eTRs
- {\normalexpanded{\bTR[\begincsname\??naturaltablesetup#1\endcsname]}#2\eTR}
-
-\protect \endinput
-
-% todo: mode: first|next (of niets)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-nte.mkiv b/Master/texmf-dist/tex/context/base/mkiv/tabl-nte.mkiv
index af74a2abe9b..2a8c4c7dd89 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-nte.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-nte.mkiv
@@ -81,10 +81,10 @@
\setfalse\c_tabl_nte_in_nc}
\unexpanded\def\tabl_nte_start_nc
- {\futurelet\next\tabl_nte_start_nc_indeed}
+ {\futurelet\nexttoken\tabl_nte_start_nc_indeed}
\def\tabl_nte_start_nc_indeed
- {\ifx\next\tabl_nte_start_nr \else
+ {\ifx\nexttoken\tabl_nte_start_nr \else
\expandafter\tabl_nte_start_nc_finish
\fi}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-tab.mkiv b/Master/texmf-dist/tex/context/base/mkiv/tabl-tab.mkiv
index 3799964c9f8..e646a1a184f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-tab.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-tab.mkiv
@@ -1739,7 +1739,7 @@
%D elsewhere. Here we only check for inconsistent spacing. Due to the way \TEX\
%D handles alignments, we cannot automate spacing for colored rows and columns.
-\setnewconstant\tablerowzero\zerocount
+\tablerowzero\zerocount
\appendtoks
\let\SR\tabl_table_SR
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.lua b/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.lua
index 13d899de647..aa4d5051f97 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.lua
@@ -18,13 +18,16 @@ local commands = commands
local texsetcount = tex.setcount
-local separator = P("|")
-local nested = lpeg.patterns.nested
-local pattern = Ct((separator * (C(nested) + Cc("")) * C((1-separator)^0))^0)
+local separator = P("|") -- keep { }
+----- nested = C(lpeg.patterns.nested) -- remove { }
+local nested = lpeg.patterns.argument
+local pattern = Ct((separator * (nested + Cc("")) * C((1-separator)^0))^0)
local ctx_settabulatelastentry = context.settabulatelastentry
local ctx_settabulateentry = context.settabulateentry
+-- the lmtx raw processor handles {} like the normal one so we need to prune
+
local function presettabulate(preamble)
preamble = gsub(preamble,"~","d") -- let's get rid of ~ mess here
if find(preamble,"*",1,true) then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkiv b/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkiv
index 434b260950c..2ed104adf38 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkiv
@@ -224,6 +224,9 @@
\newconstant \c_tabl_tabulate_localcolorspan
\newconstant \c_tabl_tabulate_modus
+%newconditional \c_tabl_pre_is_set
+\newconditional \c_tabl_post_is_set
+
\let\tabulatesplitlinemode\c_tabl_tabulate_splitlinemode % temp hack, we need an interface
\let \m_tabl_tabulate_separator_factor \empty % fraction
@@ -424,9 +427,9 @@
\fi\fi}
% \unexpanded % we can expand this one
-\def\tabl_tabulate_inject_post_skip#1%
+\def\tabl_tabulate_inject_post_skip#1#2%
{\ifdim#1>\zeropoint
- \kern#1\relax % was \hskip
+ \kern\ifnum\c_tabl_tabulate_columns=\c_tabl_tabulate_nofcolumns#2\else#1\fi\relax
\else\ifnum\c_tabl_tabulate_columns=\c_tabl_tabulate_nofcolumns
\ifconditional\c_tabl_tabulate_autorulespacing
\ifcase\c_tabl_tabulate_has_rule_spec_last\else
@@ -516,7 +519,9 @@
\egroup
\aligntab
\noexpand\dostoptagged
- \tabl_tabulate_inject_post_skip{\the\dimexpr\s_tabl_tabulate_post}% get rid of plus
+ \tabl_tabulate_inject_post_skip
+ {\the\ifconditional\c_tabl_post_is_set\s_tabl_tabulate_post\else\s_tabl_tabulate_last\fi}%
+ {\the\s_tabl_tabulate_post}%
\alignmark\alignmark
}%
\toksapp\t_tabl_tabulate_dummy{\NC}%
@@ -527,7 +532,9 @@
\s_tabl_tabulate_post\zeropoint
\fi
%\let\gettabulateexit\dogettabulateexit % still needed ?
- \d_tabl_tabulate_width\zeropoint}
+ \d_tabl_tabulate_width\zeropoint
+ %setfalse\c_tabl_pre_is_set
+ \setfalse\c_tabl_post_is_set}
\unexpanded\def\installtabulatepreambleoption#1#2%
{\setvalue{\??tabulatepreamble\string#1}{#2}}%
@@ -622,17 +629,21 @@
\tabl_tabulate_set_preamble}
\def\tabl_tabulate_set_preskip#1%
- {\doifelsenumber{#1}%
+ {%settrue\c_tabl_pre_is_set
+ \doifelsenumber{#1}%
{\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble }%
{\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}}
\def\tabl_tabulate_set_posskip#1%
- {\doifelsenumber{#1}%
+ {\settrue\c_tabl_post_is_set
+ \doifelsenumber{#1}%
{\s_tabl_tabulate_post#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble }%
{\s_tabl_tabulate_post.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}}
\def\tabl_tabulate_set_preposskip#1%
- {\doifelsenumber{#1}%
+ {%settrue\c_tabl_pre_is_set
+ \settrue\c_tabl_post_is_set
+ \doifelsenumber{#1}%
{\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble }%
{\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble#1}}
@@ -803,6 +814,8 @@
\c_tabl_tabulate_modus\zerocount
\setfalse\c_tabl_tabulate_pwidth_set
\setfalse\c_tabl_tabulate_reshape
+ %setfalse\c_tabl_pre_is_set
+ \setfalse\c_tabl_post_is_set
\t_tabl_tabulate_before\emptytoks
\t_tabl_tabulate_after\emptytoks
\t_tabl_tabulate_bmath\emptytoks
@@ -2112,7 +2125,7 @@
\stoptabulatenoalign}
\def\spac_vspacing_no_topskip % use grouped
- {\attribute\skipcategoryattribute\plusten}
+ {\c_attr_skipcategory\plusten}
\unexpanded\def\tabl_tabulate_ML_second_indeed
{\tabl_tabulate_break_no
@@ -2264,7 +2277,7 @@
\s_tabl_tabulate_first.5\d_tabl_tabulate_unit
\s_tabl_tabulate_last\s_tabl_tabulate_first
\s_tabl_tabulate_pre\zeropoint
- \s_tabl_tabulate_post\s_tabl_tabulate_first % was: \zeropoint
+ \s_tabl_tabulate_post\zeropoint
\global\c_tabl_tabulate_columns\zerocount
\global\c_tabl_tabulate_nofauto\zerocount
\global\c_tabl_tabulate_noflines\zerocount
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkxl b/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkxl
deleted file mode 100644
index dc8ae0214c4..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-tbl.mkxl
+++ /dev/null
@@ -1,3022 +0,0 @@
-%D \module
-%D [ file=core-tbl,
-%D version=1998.11.03,
-%D title=\CONTEXT\ Table Macros,
-%D subtitle=Text Flow Tabulation,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Table Macros / Tabulation}
-
-\unprotect
-
-\registerctxluafile{tabl-tbl}{} % experiment
-
-%D I can probably reimplement this using a \LUATEX\ combination but it does not pay
-%D of in development time. If I need something else I will write it from scratch
-%D anyway. This module looks a bit complex which is a consequence of it dealing with
-%D paragraphs being split over pages and that there are several passes over the data
-%D set. We can probably do some cleanup (combine/split).
-%D
-%D Caching the preamble does not save much (compared to other bits and pieces of
-%D \CONTEXT). There are not that many ways to deal with preambles and this is just
-%D one of them. The keys are somewhat similar to those of the \TABLE\ package.
-
-% |p2|p3| 2:3 -> spanning (maybe)
-%
-% In-text tabbing environment
-%
-% \starttabulate[| separated template] % eg [|l|p|] or [|l|p|p|]
-% \NC ... \NC ... \NC\NR
-% \stoptabulate
-%
-% with: two pass auto width calculation when no p-width
-% specified, even with multiple p's, see examples.
-%
-% TaBlE compatible specifications:
-%
-% l align column/paragraph left
-% r align column/paragraph right
-% c align column/paragraph center
-% p p(dimen) of automatisch als alleen p
-% w column width
-% f font#1
-% A {alignmentoptions}
-% B bold
-% I italic
-% S slanted
-% T type
-% R roman
-% m math
-% M display math
-% h hook (inner level or par lines)
-% b before (may be command#1)
-% a after
-% i i skip left of column
-% j i skip right of column
-% k i skip around column
-% d digits (~)
-%
-% C [LMRT] {color} % T is text color
-%
-% | {color,n}
-%
-% s setups
-%
-% g g{char} align at char
-% . align at .
-% , align at ,
-%
-% Still to be done
-%
-% N math numbers (best hook into existing digits mechanism)
-% n numbers (best hook into existing digits mechanism)
-% Q math numbers (best hook into existing digits mechanism)
-% q numbers (best hook into existing digits mechanism)
-% ~ \hskip.5em
-% | check
-%
-% nesting
-%
-% 10 evt auto stack; dan wel andere signal dan void nodig
-%
-% present but not yet 100% ok
-%
-% \TL [width,color] bottom hrule
-% \FL [width,color] first hrule
-% \ML [width,color] mid hrule (with auto split)
-% \LL [width,color] bottom hrule
-% \BL [width,color] last hrule
-%
-% \HL [width,color] top rule
-% \VL [width,color]
-%
-% \CC \CL \CM \CR color
-%
-% \EQ \RQ \HQ equal (raw, hook)
-% \NC \RC \HC normal (raw, hook)
-%
-% \NR checked break
-% \NB no break
-%
-% \HR : rule with lineheight
-%
-% \autotabulaterule : with lineheight, not first/last
-% \autotabulateline : spaced, not first/last
-% \tabulaterule : with lineheight
-% \tabulateline : spaced
-%
-% tricky: align scans ahead, over # and expands ones before
-% while doing
-%
-% new:
-%
-% \starttabulate[|cg{.}|cg{,}|cg{,}|]
-% \NC period \NC comma \NC comma \NC\NR
-% \NG 100.000,00 \NG 100.000,00 \NG 100,00 \NC\NR
-% \NG 10.000,00 \NG 10.000,00 \NG 1000,00 \NC\NR
-% \NG 100,00 \NG 100,00 \NG 10,00 \NC\NR
-% \NG 10 \NG 10 \NG 0,00 \NC\NR
-% \stoptabulate
-%
-% \starttabulate[|c.|c,|c,|]
-% \NC period \NC comma \NC comma \NC\NR
-% \NG 100.000,00 \NG 100.000,00 \NG 100,00 \NC\NR
-% \NG 10.000,00 \NG 10.000,00 \NG 1000,00 \NC\NR
-% \NG 100,00 \NG 100,00 \NG 10,00 \NC\NR
-% \NG 10 \NG 10 \NG 0,00 \NC\NR
-% \stoptabulate
-
-% nice demo (for BG)
-%
-% \starttabulate[|r|b{$\star$}|ra{\percent}|b{=}|r|]
-% \NC 500 \NC \NC 60 \NC \NC 300 \NC \NR
-% \NC 500 \NC \NC 55 \NC \NC 275 \NC \NR
-% \NC 500 \NC \NC 50 \NC \NC 250 \NC \NR
-% \NC 500 \NC \NC 45 \NC \NC 225 \NC \NR
-% \NC 500 \NC \NC 40 \NC \NC 200 \NC \NR
-% \NC 500 \NC \NC 35 \NC \NC 175 \NC \NR
-% \NC 500 \NC \NC 30 \NC \NC 150 \NC \NR
-% \NC 500 \NC \NC 25 \NC \NC 125 \NC \NR
-% \NC 500 \NC \NC 20 \NC \NC 100 \NC \NR
-% \stoptabulate
-
-\newtoks \t_tabl_tabulate_preamble
-\newtoks \t_tabl_tabulate_before
-\newtoks \t_tabl_tabulate_after
-\newtoks \t_tabl_tabulate_bmath
-\newtoks \t_tabl_tabulate_emath
-\newtoks \t_tabl_tabulate_font
-\newtoks \t_tabl_tabulate_settings
-\newtoks \t_tabl_tabulate_dummy
-\newtoks \t_tabl_tabulate_every_row
-\newtoks \t_tabl_tabulate_every_after_row
-\newtoks \t_tabl_tabulate_every_real_row
-
-\newtoks \t_tabl_tabulate_initializers_first
-\newtoks \t_tabl_tabulate_initializers_second
-
-\newcount \c_tabl_tabulate_nofauto
-\newcount \c_tabl_tabulate_columns
-\newcount \c_tabl_tabulate_column
-\newcount \c_tabl_tabulate_plines_min
-\newcount \c_tabl_tabulate_plines_max
-\newcount \c_tabl_tabulate_max_colorcolumn
-\newcount \c_tabl_tabulate_max_vrulecolumn
-\newcount \c_tabl_tabulate_repeathead
-\newcount \c_tabl_tabulate_noflines
-\newcount \c_tabl_tabulate_totalnoflines
-\newcount \c_tabl_tabulate_minusnoflines
-\newcount \c_tabl_tabulate_align
-\newcount \c_tabl_tabulate_nofrealrows
-\newcount \c_tabl_tabulate_autocolor
-
-\newcount \c_tabl_tabulate_nofcolumns % set at the lua end by parser
-\newcount \c_tabl_tabulate_has_rule_spec_first % set at the lua end by parser (for the moment a count)
-\newcount \c_tabl_tabulate_has_rule_spec_last % set at the lua end by parser (for the moment a count)
-
-\newconditional \c_tabl_tabulate_nopbreak
-\newconditional \c_tabl_tabulate_firstflushed
-\newconditional \c_tabl_tabulate_equal
-\newconditional \c_tabl_tabulate_split \settrue\c_tabl_tabulate_split
-\newconditional \c_tabl_tabulate_automode
-\newconditional \c_tabl_tabulate_handlepbreak \settrue\c_tabl_tabulate_handlepbreak
-\newconditional \c_tabl_tabulate_autorulespacing \settrue\c_tabl_tabulate_autorulespacing
-\newconditional \c_tabl_tabulate_someamble
-\newconditional \c_tabl_tabulate_tolerant_break
-\newconditional \c_tabl_tabulate_splitoff_whitespace
-\newconditional \c_tabl_tabulate_pwidth_set
-\newconditional \c_tabl_tabulate_reshape
-
-\newdimen \d_tabl_tabulate_width_p
-\newdimen \d_tabl_tabulate_width_w
-\newdimen \d_tabl_tabulate_width
-\newdimen \d_tabl_tabulate_unit
-\newdimen \d_tabl_tabulate_height_p_max
-\newdimen \d_tabl_tabulate_vrulethickness_default
-\newdimen \d_tabl_tabulate_hrulethickness_default
-\newdimen \d_tabl_tabulate_vrulethickness
-\newdimen \d_tabl_tabulate_hrulethickness % not used
-\newdimen \d_tabl_tabulate_vrulethickness_local
-\newdimen \d_tabl_tabulate_hrulethickness_local
-\newdimen \d_tabl_tabulate_indent
-\newdimen \d_tabl_tabulate_splitoff_betweenskip
-\newdimen \d_tabl_tabulate_margin
-
-\newskip \s_tabl_tabulate_pre
-\newskip \s_tabl_tabulate_post
-\newskip \s_tabl_tabulate_first
-\newskip \s_tabl_tabulate_last
-\newskip \s_tabl_tabulate_separator
-
-\newbox \b_tabl_tabulate
-
-\newconstant \c_tabl_tabulate_pass
-\newconstant \c_tabl_tabulate_type
-\newconstant \c_tabl_tabulate_kind % 1=strong 2=equals
-\newconstant \c_tabl_tabulate_splitlinemode \c_tabl_tabulate_splitlinemode\plusone
-\newconstant \c_tabl_tabulate_colorspan
-\newconstant \c_tabl_tabulate_localcolorspan
-\newconstant \c_tabl_tabulate_modus
-
-\let\tabulatesplitlinemode\c_tabl_tabulate_splitlinemode % temp hack, we need an interface
-
-\let \m_tabl_tabulate_separator_factor \empty % fraction
-
-\newtoks \everytabulatepar % where used ?
-\newtoks \everytabulate % public ?
-
-\unexpanded\def\tolerantTABLEbreaktrue {\settrue \c_tabl_tabulate_tolerant_break} % used in styles !
-\unexpanded\def\handletabulatepbreakfalse{\setfalse\c_tabl_tabulate_handlepbreak } % depricated
-
-\def\noftabulaterows{\number\c_tabl_tabulate_noflines} % handy for testing if a table is empty
-
-\installcorenamespace{tabulatebox}
-\installcorenamespace{tabulatesetup}
-\installcorenamespace{tabulatehook}
-\installcorenamespace{tabulatesplit}
-\installcorenamespace{tabulateseparator}
-\installcorenamespace{tabulatecolor}
-\installcorenamespace{tabulateheader}
-\installcorenamespace{tabulatealigning}
-\installcorenamespace{tabulatepreamble}
-\installcorenamespace{tabulatevrule}
-
-\installcorenamespace{tabulatehead}
-\installcorenamespace{tabulatefoot}
-\installcorenamespace{tabulatenext}
-
-\prependtoks
- \global\c_tabl_tabulate_nofrealrows\zerocount
-\to \t_tabl_tabulate_initializers_first
-
-\prependtoks
- \global\c_tabl_tabulate_nofrealrows\zerocount
-\to \t_tabl_tabulate_initializers_second
-
-\prependtoks
- \global\advance\c_tabl_tabulate_nofrealrows\plusone
-\to \t_tabl_tabulate_every_real_row
-
-\def\b_tabl_tabulate_current#1%
- {\csname\??tabulatebox\number#1\endcsname} % beware, a synonym
-
-\def\tabl_tabulate_initialize_boxes#1%
- {\scratchcounter#1\relax
- \tabl_tabulate_initialize_boxes_step}
-
-\def\tabl_tabulate_initialize_boxes_step
- {\ifnum\scratchcounter>\zerocount
- \tabl_tabulate_initialize_box\scratchcounter
- \advance\scratchcounter\minusone
- \expandafter\tabl_tabulate_initialize_boxes_step
- \fi}
-
-\def\tabl_tabulate_initialize_box#1% also used elsewhere
- {\ifcsname\??tabulatebox\number#1\endcsname
- \tabl_tabulate_initialize_box_yes
- \else
- \tabl_tabulate_initialize_box_nop#1%
- \fi}
-
-\def\tabl_tabulate_initialize_box_yes {\global \setbox\lastnamedcs\emptybox}
-\def\tabl_tabulate_initialize_box_nop#1{\expandafter\newbox\csname\??tabulatebox\number#1\endcsname}
-
-\tabl_tabulate_initialize_boxes{16} % not really needed
-
-\let\initializetablebox \tabl_tabulate_initialize_box % used elsewhere, will change
-\let\initializetableboxes\tabl_tabulate_initialize_boxes % used elsewhere, will change
-\let\tablebox \b_tabl_tabulate_current
-
-% 0 = NC column next EQ equal column
-% 1 = RC column raw RQ equal column raw
-% 2 = HC column hook HQ equal column hook
-
-% handy helper
-
-\def\tabulatenoalign % public ?
- {\noalign
- \bgroup
- \let\noalign\relax
- \let\tabulatenoalign\relax
- \let\next=}
-
-\def\starttabulatenoalign % public ?
- {\tabulatenoalign\bgroup}
-
-\let\stoptabulatenoalign\egroup
-
-% [|lg{.}|] => \NG 12.34 \NC
-
-\def\tabl_tabulate_nobreak_inject_tracer
- {\red % maybe use the fast color switcher here
- \hrule\s!height.5\linewidth\s!depth.5\linewidth
- \par
- \kern-\linewidth
- \tabl_tabulate_break_no}
-
-\installtextracker
- {tables.tabulate.breaks}
- {\let\tabl_tabulate_break_no_tracer\tabl_tabulate_nobreak_inject_tracer}
- {\let\tabl_tabulate_break_no_tracer\donothing}
-
-\let\tabl_tabulate_break_no_tracer\donothing
-
-\def\tabl_tabulate_nobreak_inject_indeed
- {\tabl_tabulate_break_no
- \tabl_tabulate_break_no_tracer}
-
-\def\tabl_tabulate_nobreak_inject
- {\tabulatenoalign{\tabl_tabulate_nobreak_inject_indeed}}
-
-\unexpanded\def\tabl_tabulate_hook_check
- {\ifnum\c_tabl_tabulate_type<\plustwo
- \glet\tabl_tabulate_hook\tabl_tabulate_hook_nop
- \else
- \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
- \fi}
-
-\unexpanded\def\tabl_tabulate_setups_check
- {\begincsname\??tabulatesetup\the\c_tabl_tabulate_column\endcsname}
-
-\unexpanded\def\tabl_tabulate_entry_before{\ignorespaces\tabl_tabulate_hook}
-\unexpanded\def\tabl_tabulate_entry_after {\unskip\unskip\ifmmode\else\endgraf\fi}
-
-\unexpanded\def\tabl_tabulate_shaped_par_begin
- {\dowithnextboxcs\tabl_tabulate_shaped_par_finish\vbox\bgroup}
-
-\def\tabl_tabulate_shaped_par_finish
- {\clf_doreshapeframedbox\nextbox\relax
- \ifvmode\unvbox\else\box\fi\nextbox}
-
-\let\tabl_tabulate_shaped_par_end\egroup
-
-\ifdefined\dotagtabulatecell \else \let\dotagtabulatecell \relax \fi
-\ifdefined\dotagtabulatesignal \else \let\dotagtabulatesignal\relax \fi
-
-\unexpanded\def\tabl_tabulate_check_local_color_first#1#2%
- {\relax}
-
-\unexpanded\def\tabl_tabulate_check_local_color_second#1#2%
- {\relax
- \ifx\m_tabl_tabulate_color_local\empty
- \xdef\m_tabl_tabulate_color{#1}%
- \else
- \glet\m_tabl_tabulate_color\m_tabl_tabulate_color_local
- \glet\m_tabl_tabulate_color_local\empty
- \fi
- \ifcase\c_tabl_tabulate_localcolorspan
- \global\c_tabl_tabulate_colorspan#2\relax
- \else
- \global\c_tabl_tabulate_colorspan\c_tabl_tabulate_localcolorspan
- \global\c_tabl_tabulate_localcolorspan\zerocount
- \fi}
-
-\unexpanded\def\tabl_tabulate_check_local_vrule_thickness#1%
- {\relax
- \ifcase\d_tabl_tabulate_vrulethickness_local
- \global\d_tabl_tabulate_vrulethickness#1\relax
- \else
- \global\d_tabl_tabulate_vrulethickness\d_tabl_tabulate_vrulethickness_local
- \global\d_tabl_tabulate_vrulethickness_local\zeropoint
- \fi}
-
-\unexpanded\def\tabl_tabulate_check_local_vrule_color_first#1%
- {\relax}
-
-\unexpanded\def\tabl_tabulate_check_local_vrule_color_second#1%
- {\relax
- \ifx\m_tabl_tabulate_vrule_color_local\empty
- \xdef\m_tabl_tabulate_vrule_color{#1}%
- \else
- \glet\m_tabl_tabulate_vrule_color\m_tabl_tabulate_vrule_color_local
- \glet\m_tabl_tabulate_vrule_color_local\empty
- \fi}
-
-\let\tabl_tabulate_check_local_color \gobbletwoarguments
-\let\tabl_tabulate_check_local_vrule_color\gobbleoneargument
-
-\appendtoks
- \let\tabl_tabulate_check_local_color \tabl_tabulate_check_local_color_first
- \let\tabl_tabulate_check_local_vrule_color\tabl_tabulate_check_local_vrule_color_first
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \let\tabl_tabulate_check_local_color \tabl_tabulate_check_local_color_second
- \let\tabl_tabulate_check_local_vrule_color\tabl_tabulate_check_local_vrule_color_second
-\to \t_tabl_tabulate_initializers_second
-
-% \unexpanded % we can expand this one
-\def\tabl_tabulate_inject_pre_skip#1%
- {\ifdim#1>\zeropoint
- \kern#1\relax % was \hskip
- \orelse\ifnum\c_tabl_tabulate_column=\zerocount
- \ifconditional\c_tabl_tabulate_autorulespacing
- \ifcase\c_tabl_tabulate_has_rule_spec_first\else
- \kern\s_tabl_tabulate_first\relax % was \hskip
- \fi
- \fi
- \fi}
-
-% \unexpanded % we can expand this one
-\def\tabl_tabulate_inject_post_skip#1%
- {\ifdim#1>\zeropoint
- \kern#1\relax % was \hskip
- \orelse\ifnum\c_tabl_tabulate_columns=\c_tabl_tabulate_nofcolumns
- \ifconditional\c_tabl_tabulate_autorulespacing
- \ifcase\c_tabl_tabulate_has_rule_spec_last\else
- \kern\s_tabl_tabulate_last\relax % was \hskip
- \fi
- \fi
- \fi}
-
-\let\tabl_tabulate_hook_b\donothing
-\let\tabl_tabulate_hook_e\donothing
-
-\let\tabl_tabulate_hook_g\donothing
-
-\def\tabl_tabulate_set_preamble_step#1#2% only makes sense for many tabulates
- {\etoksapp\t_tabl_tabulate_preamble{%
- \tabl_tabulate_check_local_vrule_thickness\constantdimenargument\d_tabl_tabulate_vrulethickness
- \tabl_tabulate_check_local_vrule_color\constantemptyargument\m_tabl_tabulate_vrule_color
- \tabl_tabulate_check_local_color\constantemptyargument\m_tabl_tabulate_color\constantnumberargument\c_tabl_tabulate_colorspan
- \tabl_tabulate_color_side_right
- \aligntab
- \tabl_tabulate_column_vrule_inject
- \tabl_tabulate_color_side_left
- \tabl_tabulate_inject_pre_skip{\the\dimexpr\s_tabl_tabulate_pre}% get rid of plus
- \alignmark\alignmark
- \aligntab
- \tabl_tabulate_color_side_both
- \global\c_tabl_tabulate_colorspan\zerocount
- \global\c_tabl_tabulate_column\constantnumber\c_tabl_tabulate_columns
- \tabl_tabulate_hook_g
- \tabl_tabulate_setups_check % unexpandable
- \tabl_tabulate_hook_check % unexpandable
- \ifzeropt\d_tabl_tabulate_width
- \ifcase\c_tabl_tabulate_modus\else
- \settrue\c_tabl_tabulate_automode
- \fi
- \else
- \ifcase\c_tabl_tabulate_modus
- \hbox to
- \else
- \hsize
- \fi
- \the\d_tabl_tabulate_width
- \fi
- \bgroup
- \tabl_tabulate_bbskip
- \bgroup % we cannot combine the if because a cell may have only one ##
- \tabl_tabulate_hook_b
- \c_tabl_tabulate_align\constantnumber\c_tabl_tabulate_align % needed in tag passing
- \ifx\m_tabl_tabulate_alignment\empty \else
- \spac_align_use_now{\m_tabl_tabulate_alignment}%
- \fi
- \noexpand\dostarttagged\noexpand\t!tabulatecell\noexpand\empty
- \noexpand\dotagtabulatecell
- \noexpand#1%
- \ifconditional\c_tabl_tabulate_reshape
- \tabl_tabulate_shaped_par_begin
- \fi
- \dotagtabulatesignal % empty cells .. todo (can be removed as soon as build)
- \noexpand\ifnum\noexpand\c_tabl_tabulate_type=\plusone\noexpand\else
- \the\t_tabl_tabulate_bmath % maybe later? can interfere with char 0
- \the\t_tabl_tabulate_font
- \the\t_tabl_tabulate_settings
- \the\t_tabl_tabulate_before
- \ifx\m_tabl_tabulate_text_color\empty
- \expandafter\gobbleoneargument
- \else
- \expandafter\dofastcoloractivation
- \fi\m_tabl_tabulate_text_color
- \noexpand\fi
- % grouping needs to be outside macros (or expandable), nice test
- % example \NC \string \aligntab \NC which will fail otherwise (mk)
- \bgroup
- \tabl_tabulate_entry_before
- \alignmark\alignmark
- \tabl_tabulate_entry_after
- \egroup
- \noexpand\ifnum\noexpand\c_tabl_tabulate_type=\plusone\noexpand\else
- \the\t_tabl_tabulate_after
- \the\t_tabl_tabulate_emath
- \noexpand\fi
- \ifconditional\c_tabl_tabulate_reshape
- \tabl_tabulate_shaped_par_end
- \fi
- \noexpand#2%
- \tabl_tabulate_hook_e
- \egroup
- \egroup
- \aligntab
- \noexpand\dostoptagged
- \tabl_tabulate_inject_post_skip{\the\dimexpr\s_tabl_tabulate_post}% get rid of plus
- \alignmark\alignmark
- }%
- \toksapp\t_tabl_tabulate_dummy{\NC}%
- \s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\relax
- \ifnum\c_tabl_tabulate_columns<\numexpr\c_tabl_tabulate_nofcolumns-\plusone\relax
- \s_tabl_tabulate_post\s_tabl_tabulate_pre
- \else
- \s_tabl_tabulate_post\zeropoint
- \fi
- %\let\gettabulateexit\dogettabulateexit % still needed ?
- \d_tabl_tabulate_width\zeropoint}
-
-\unexpanded\def\installtabulatepreambleoption#1#2%
- {\setvalue{\??tabulatepreamble\string#1}{#2}}%
-
-\installtabulatepreambleoption{x}{\c_tabl_tabulate_align\zerocount
- \tabl_tabulate_set_preamble} % internal
-\installtabulatepreambleoption{l}{\c_tabl_tabulate_align\plusone
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{r}{\c_tabl_tabulate_align\plustwo
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{c}{\c_tabl_tabulate_align\plusthree
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{p}{\tabl_tabulate_set_paragraph}
-\installtabulatepreambleoption{s}{\tabl_tabulate_set_setups}
-\installtabulatepreambleoption{w}{\tabl_tabulate_set_width}
-\installtabulatepreambleoption{f}{\tabl_tabulate_set_font}
-\installtabulatepreambleoption{B}{\t_tabl_tabulate_font{\bf}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{I}{\t_tabl_tabulate_font{\it}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{S}{\t_tabl_tabulate_font{\sl}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{T}{\t_tabl_tabulate_font{\tt}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{R}{\t_tabl_tabulate_font{\rm}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{m}{\t_tabl_tabulate_bmath{\normalstartimath}%
- \t_tabl_tabulate_emath{\normalstopimath}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{M}{\t_tabl_tabulate_bmath{\normalstartimath\displaystyle}%
- \t_tabl_tabulate_emath{\normalstopimath}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{h}{\tabl_tabulate_set_hook}
-\installtabulatepreambleoption{b}{\tabl_tabulate_set_before}
-\installtabulatepreambleoption{a}{\tabl_tabulate_set_after}
-\installtabulatepreambleoption{i}{\tabl_tabulate_set_preskip}
-\installtabulatepreambleoption{j}{\tabl_tabulate_set_posskip}
-\installtabulatepreambleoption{k}{\tabl_tabulate_set_preposskip}
-\installtabulatepreambleoption{e}{\toksapp\t_tabl_tabulate_settings{\global\settrue\c_tabl_tabulate_equal}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{g}{\tabl_tabulate_set_align}
-\installtabulatepreambleoption{.}{\tabl_tabulate_set_align.}
-\installtabulatepreambleoption{,}{\tabl_tabulate_set_align,}
-\installtabulatepreambleoption{C}{\tabl_tabulate_set_color_span}
-\installtabulatepreambleoption{d}{\toksapp\t_tabl_tabulate_settings{\fixedspaces}%
- \tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{ }{\tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{A}{\tabl_tabulate_set_alignment}
-
-%D We no longer deal with \type {~} here but map it onto \type {d} instead. Of
-%D course we could prefix a key with \type {\meaning} instead, which works ok (and
-%D is needed in order to pseudo expand \type {\next}, but is ugly at the same time.
-%D The type {d} stands for digitspace.
-
-%D \starttyping
-%D \installtabulatepreambleoption{~}{...} % see 'd'
-%D \stoptyping
-%D
-%D Also, as there is always a key, we no longer do some after assigment or future
-%D let but just pick up the key.
-
-% \installtabulatepreambleoption \s!unknown %
-% {\writestatus{tabulate}{unknown preamble key [\normalmeaning\next]}%
-% \tabl_tabulate_set_preamble}
-%
-% \def\tabl_tabulate_set_preamble
-% {\afterassignment\dosettabulatepreamble\let\next=}
-%
-% \def\dosettabulatepreamble
-% {\ifx\next\relax \else
-% \csname\??tabulatepreamble
-% \ifcsname\??tabulatepreamble\next\endcsname\next\else\s!unknown\fi
-% \expandafter\endcsname
-% \fi}
-
-\installtabulatepreambleoption\relax
- {} % finished
-
-\def\tabl_tabulate_set_preamble#1%
- {\ifcsname\??tabulatepreamble\string#1\endcsname
- %\expandafter\tabl_tabulate_set_preamble_yes
- \expandafter\expandafter\expandafter\lastnamedcs\expandafter\gobbleoneargument
- \else
- \expandafter\tabl_tabulate_set_preamble_nop
- \fi{#1}}
-
-\def\tabl_tabulate_set_preamble_yes#1%
- {\csname\??tabulatepreamble\string#1\expandafter\endcsname}
-
-\def\tabl_tabulate_set_preamble_nop#1%
- {\writestatus{tabulate}{unknown preamble key: #1}%
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_preskip#1%
- {\doifelsenumber{#1}%
- {\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble }%
- {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}}
-
-\def\tabl_tabulate_set_posskip#1%
- {\doifelsenumber{#1}%
- {\s_tabl_tabulate_post#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble }%
- {\s_tabl_tabulate_post.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}}
-
-\def\tabl_tabulate_set_preposskip#1%
- {\doifelsenumber{#1}%
- {\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble }%
- {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble#1}}
-
-\def\tabl_tabulate_set_setups#1%
- {\setvalue{\??tabulatesetup\the\c_tabl_tabulate_columns}{\setups[#1]}%
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_hook#1%
- {\setvalue{\??tabulatehook\the\c_tabl_tabulate_columns}{#1}%
- \tabl_tabulate_set_preamble}
-
-% begin of character align plugin
-
-\newconditional\c_tabl_auto_align_mode % reset later
-
-\def\tabl_tabulate_hook_g % partly expanded
- {\ifconditional\c_tabl_auto_align_mode
- \signalcharacteralign\c_tabl_tabulate_column{\c_tabl_tabulate_noflines+\plusone}%
- \typo_charalign_adapt_font
- \fi}
-
-\def\tabl_tabulate_set_align#1%
- {\global\settrue\c_tabl_auto_align_mode
- \setcharacteralign\c_tabl_tabulate_columns{#1}%
- \tabl_tabulate_set_preamble}
-
-% end of character align plugin
-
-\def\tabl_tabulate_set_before#1%
- {\t_tabl_tabulate_before{#1}%
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_after#1%
- {\t_tabl_tabulate_after{#1}%
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_font#1%
- {\t_tabl_tabulate_font{#1}%
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_pickup_width
- {\doifelsenextparenthesis\tabl_tabulate_set_width_indeed\tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_width
- {\setfalse\c_tabl_tabulate_pwidth_set
- \c_tabl_tabulate_modus\zerocount
- \tabl_tabulate_pickup_width}
-
-\def\tabl_tabulate_set_alignment#1%
- {\edef\m_tabl_tabulate_alignment{#1}%
- \spac_align_use_later\m_tabl_tabulate_alignment
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_paragraph
- {\doifelsenextparenthesis
- {\c_tabl_tabulate_modus\plusone
- \settrue\c_tabl_tabulate_pwidth_set
- \tabl_tabulate_pickup_width}
- {\c_tabl_tabulate_modus\plustwo
- \setfalse\c_tabl_tabulate_pwidth_set
- \tabl_tabulate_set_preamble}}
-
-% \startbuffer
-% \toplinebox{\framed[width=3cm,height=2cm]{tufte}}
-% \stopbuffer
-% \starttabulate[|p(fixed)|p|]
-% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
-% \stoptabulate
-% \starttabulate[|p(fit)|p|]
-% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
-% \stoptabulate
-
-\def\tabl_tabulate_set_width_indeed(#1)%
- {\processallactionsinset % can be made faster
- [#1]%
- [ \v!fit=>\c_tabl_tabulate_modus\plusthree,
- \v!fixed=>\c_tabl_tabulate_modus\plusthree
- \settrue\c_tabl_tabulate_nopbreak,
- \v!auto=>\c_tabl_tabulate_modus\plusthree
- \settrue\c_tabl_tabulate_reshape,
- \s!unknown=>\d_tabl_tabulate_width#1\relax]%
- \ifconditional\c_tabl_tabulate_pwidth_set
- \global\advance\d_tabl_tabulate_width_p\d_tabl_tabulate_width % accumulated parwidth
- \fi
- \tabl_tabulate_set_preamble}
-
-% faster but seldom used
-%
-% \installcorenamespace{tabulatewidth}
-%
-% \setvalue{\??tabulatewidth\v!fit }{\c_tabl_tabulate_modus\plusthree}
-% \setvalue{\??tabulatewidth\v!fixed}{\c_tabl_tabulate_modus\plusthree\settrue\c_tabl_tabulate_nopbreak}
-% \setvalue{\??tabulatewidth\v!auto }{\c_tabl_tabulate_modus\plusthree\settrue\c_tabl_tabulate_reshape}
-%
-% \def\tabl_tabulate_set_width_step#1%
-% {\ifcsname\??tabulatewidth#1\endcsname
-% \lastnamedcs
-% \else
-% \d_tabl_tabulate_width#1\relax
-% \fi}
-%
-% \def\tabl_tabulate_set_width_indeed(#1)%
-% {\rawprocesscommacommand[#1]\tabl_tabulate_set_width_step
-% \ifconditional\c_tabl_tabulate_pwidth_set
-% \global\advance\d_tabl_tabulate_width_p\d_tabl_tabulate_width % accumulated parwidth
-% \fi
-% \tabl_tabulate_set_preamble}
-%
-\def\tabl_tabulate_set_raggedright {\ifnum\c_tabl_tabulate_type=\plusone \else\raggedright \fi}
-\def\tabl_tabulate_set_raggedcenter{\ifnum\c_tabl_tabulate_type=\plusone \else\raggedcenter\fi}
-\def\tabl_tabulate_set_raggedleft {\ifnum\c_tabl_tabulate_type=\plusone \else\raggedleft \fi}
-\def\tabl_tabulate_set_notragged {\ifnum\c_tabl_tabulate_type=\plusone \else\notragged \fi}
-\def\tabl_tabulate_set_hss {\ifnum\c_tabl_tabulate_type=\plusone \else\hss \fi} % never change this to a fill
-
-\def\tabl_tabulate_bskip_raggedright {\tabl_tabulate_bskip\tabl_tabulate_set_raggedright }
-\def\tabl_tabulate_bskip_raggedleft {\tabl_tabulate_bskip\tabl_tabulate_set_raggedleft }
-\def\tabl_tabulate_bskip_raggedcenter{\tabl_tabulate_bskip\tabl_tabulate_set_raggedcenter}
-
-\def\tabl_tabulate_set_width_normal
- {\ifcase\c_tabl_tabulate_align\relax
- \tabl_tabulate_set_preamble_step\empty \tabl_tabulate_set_hss \or
- \tabl_tabulate_set_preamble_step\empty \tabl_tabulate_set_hss \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_set_hss\empty \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_set_hss\tabl_tabulate_set_hss \fi}
-
-\def\tabl_tabulate_set_width_fixed
- {\ifcase\c_tabl_tabulate_align\relax
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip \tabl_tabulate_eskip \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedright \tabl_tabulate_eskip \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedleft \tabl_tabulate_eskip \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedcenter\tabl_tabulate_eskip \fi}
-
-\def\tabl_tabulate_set_width_auto
- {\global\advance\c_tabl_tabulate_nofauto\plusone
- \ifcase\c_tabl_tabulate_align\relax
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip \tabl_tabulate_eskip \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedright \tabl_tabulate_eskip \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedleft \tabl_tabulate_eskip \or
- \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedcenter\tabl_tabulate_eskip \fi}
-
-\def\tabl_tabulate_set_width_simple
- {\tabl_tabulate_set_preamble_step\tabl_tabulate_xbskip\tabl_tabulate_xeskip}
-
-% \def\tabl_tabulate_set_color_span#1#2%
-% {\xdef\m_tabl_tabulate_color{#2}%
-% \global\c_tabl_tabulate_colorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax
-% \tabl_tabulate_set_preamble}
-
-\installcorenamespace{tabulatecolorspec}
-
-\setvalue{\??tabulatecolorspec C}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\zerocount}
-\setvalue{\??tabulatecolorspec L}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plusone }
-\setvalue{\??tabulatecolorspec M}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plustwo }
-\setvalue{\??tabulatecolorspec R}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plusthree}
-\setvalue{\??tabulatecolorspec T}#1{\xdef\m_tabl_tabulate_text_color{#1}}
-
-\def\tabl_tabulate_set_color_span#1#2%
- {\csname\??tabulatecolorspec#1\endcsname{#2}%
- \tabl_tabulate_set_preamble}
-
-\def\tabl_tabulate_set_vrule_command#1%
- {\doifelsenumber{#1}
- {\global\d_tabl_tabulate_vrulethickness#1\d_tabl_tabulate_vrulethickness_default}
- {\xdef\m_tabl_tabulate_vrule_color{#1}}}
-
-\def\tabl_tabulate_set_entry#1#2% rulespec template
- {\c_tabl_tabulate_align\v_tabl_tabulate_align
- \c_tabl_tabulate_modus\zerocount
- \setfalse\c_tabl_tabulate_pwidth_set
- \setfalse\c_tabl_tabulate_reshape
- \t_tabl_tabulate_before\emptytoks
- \t_tabl_tabulate_after\emptytoks
- \t_tabl_tabulate_bmath\emptytoks
- \t_tabl_tabulate_emath\emptytoks
- \t_tabl_tabulate_font\emptytoks
- \t_tabl_tabulate_settings\emptytoks
- \glet\m_tabl_tabulate_alignment\empty
- \glet\m_tabl_tabulate_color\empty
- \glet\m_tabl_tabulate_text_color\empty
- \glet\m_tabl_tabulate_vrule_color\empty
- \global\c_tabl_tabulate_colorspan\zerocount
- \global\setfalse\c_tabl_auto_align_mode
- \global\advance\c_tabl_tabulate_columns\plusone
- \expandafter\let\csname\??tabulatesetup\the\c_tabl_tabulate_columns\endcsname\donothing % here ?
- \edef\currenttabulationtrulespec{#1}%
- \ifx\currenttabulationtrulespec\empty
- \global\d_tabl_tabulate_vrulethickness\zeropoint
- \else
- \global\d_tabl_tabulate_vrulethickness\d_tabl_tabulate_vrulethickness_default
- \rawprocesscommalist[#1]\tabl_tabulate_set_vrule_command
- \fi
- \tabl_tabulate_set_preamble#2\relax\relax % permits i without n
- \ifcase\c_tabl_tabulate_modus\relax
- \tabl_tabulate_set_width_normal
- \or % fixed width
- \tabl_tabulate_set_width_fixed
- \or % auto width
- \tabl_tabulate_set_width_auto
- \or % simple
- \tabl_tabulate_set_width_simple
- \fi}
-
-\def\tabl_tabulate_set_last_entry#1% rulespec
- {\glet\m_tabl_tabulate_color\empty
- \glet\m_tabl_tabulate_vrule_color\empty
- \edef\currenttabulationtrulespec{#1}%
- \ifx\currenttabulationtrulespec\empty
- \global\d_tabl_tabulate_vrulethickness\zeropoint
- \else
- \global\d_tabl_tabulate_vrulethickness\d_tabl_tabulate_vrulethickness_default
- \rawprocesscommalist[#1]\tabl_tabulate_set_vrule_command
- \fi
- \etoksapp\t_tabl_tabulate_preamble{%
- \tabl_tabulate_check_local_vrule_thickness\constantdimenargument\d_tabl_tabulate_vrulethickness
- \tabl_tabulate_check_local_vrule_color\constantemptyargument\m_tabl_tabulate_vrule_color
- \tabl_tabulate_column_vrule_inject}}
-
-\let\settabulateentry \tabl_tabulate_set_entry % used at the lua end
-\let\settabulatelastentry\tabl_tabulate_set_last_entry % used at the lua end
-
-\def\tabl_tabulate_normalize_splitline
- {\ifcase\c_tabl_tabulate_splitlinemode
- % nothing
- \or
- \ht\b_tabl_tabulate\strutht
- \dp\b_tabl_tabulate\strutdp
- \or
- \ifdim\ht\b_tabl_tabulate<\strutht
- \ht\b_tabl_tabulate\strutht
- \fi
- \ifdim\dp\b_tabl_tabulate<\strutdp
- \dp\b_tabl_tabulate\strutdp
- \fi
- \fi}
-
-\def\tabl_tabulate_whitespace
- {\ifdim\d_tabl_tabulate_splitoff_betweenskip>\zeropoint
- \vskip\d_tabl_tabulate_splitoff_betweenskip
- \global\d_tabl_tabulate_splitoff_betweenskip\zeropoint
- \fi}
-
-\def\tabl_tabulate_check_whitespace
- {\setbox\scratchbox\vpack
- {\splitdiscards
- \unskip
- \ifdim\lastskip>\d_tabl_tabulate_splitoff_betweenskip
- \global\d_tabl_tabulate_splitoff_betweenskip\lastskip
- \fi}}
-
-\installtexdirective
- {tabulate.linenumbers}
- {\def\tabl_tabulate_check_linenumbers{\page_postprocessors_linenumbers_deepbox\b_tabl_tabulate}}
- {\let\tabl_tabulate_check_linenumbers\relax}
-
-\let\tabl_tabulate_check_linenumbers\relax
-
-\def\tabl_tabulate_splitoff_box
- {\dontcomplain
- \global\setbox\b_tabl_tabulate\vsplit\b_tabl_tabulate_current\c_tabl_tabulate_column to \lineheight % % % global ? % % %
- \setbox\b_tabl_tabulate\vbox
- {\unvbox\b_tabl_tabulate}%
- \ifconditional\c_tabl_tabulate_splitoff_whitespace
- \tabl_tabulate_check_whitespace
- \fi
- \tabl_tabulate_color_repeat % needs to end up in a cell
- \setbox\b_tabl_tabulate\hpack to \wd\b_tabl_tabulate
- {\hss\tabl_tabulate_hook_yes{\box\b_tabl_tabulate}\hss}%
- \tabl_tabulate_normalize_splitline
- \tabl_tabulate_check_linenumbers
- \box\b_tabl_tabulate}
-
-\unexpanded\def\tabl_tabulate_hook_nop
- {}
-
-\let\tabl_tabulate_hook\tabl_tabulate_hook_nop
-
-\def\tabl_tabulate_hook_yes{\begincsname\??tabulatehook\the\c_tabl_tabulate_column\endcsname}
-
-\def\tabl_tabulate_pheight_reset
- {\global\c_tabl_tabulate_plines_min\plusone
- \ifdim\d_tabl_tabulate_height_p_max>\zeropoint
- \getnoflines\d_tabl_tabulate_height_p_max
- \global\c_tabl_tabulate_plines_max\noflines
- \else
- \global\c_tabl_tabulate_plines_max\zerocount
- \fi
- \global\d_tabl_tabulate_height_p_max\zeropoint}
-
-\def\tabl_tabulate_pheight_set
- {\scratchdimen\ht\b_tabl_tabulate_current\c_tabl_tabulate_column\relax
- \ifdim\scratchdimen>\d_tabl_tabulate_height_p_max
- \global\d_tabl_tabulate_height_p_max\scratchdimen
- \fi}
-
-\def\tabl_tabulate_pbreak_inject
- {\ifconditional\c_tabl_tabulate_handlepbreak
- \ifconditional\c_tabl_tabulate_nopbreak
- \tabl_tabulate_nobreak_inject
- \orelse\ifnum\c_tabl_tabulate_plines_max>\plusone
- \ifnum\c_tabl_tabulate_plines_min=\plusone
- \tabl_tabulate_nobreak_inject
- \fi
- \global\advance\c_tabl_tabulate_plines_min\plusone
- \ifnum\c_tabl_tabulate_plines_min=\c_tabl_tabulate_plines_max\relax
- \tabl_tabulate_nobreak_inject
- \fi
- \fi
- \fi}
-
-\def\tabl_tabulate_pbreak_check
- {\starttabulatenoalign
- \tabl_tabulate_pbreak_inject
- \ifconditional\c_tabl_tabulate_splitoff_whitespace
- \tabl_tabulate_whitespace
- \fi
- \stoptabulatenoalign}
-
-%D \startbuffer
-%D \starttabulate[|c|p|p|]
-%D \NC \bf Alpha \NC \bf Beta \NC \bf Gamma \NC\NR
-%D \NC 1 \NC right indeed \NC definitely wrong \NC\NR
-%D \NC 2 \NC \thinrules[n=3] \NC \thinrules[n=3] \NC\NR
-%D \NC 3 \NC oh yes \NC simply no \NC\NR
-%D \NC 4 \NC very true \NC as false as can be \NC\NR
-%D \NC 5 \NC \thinrules[n=5] \NC \thinrules[n=5] \NC\NR
-%D \NC 6 \NC \thinrules[n=3] \NC \thinrules[n=4] \NC\NR
-%D \stoptabulate
-%D \stopbuffer
-%D
-%D \typebuffer {\tracetabulatetrue\getbuffer}
-%D
-%D \startbuffer
-%D \starttabulate[|c|p|p|]
-%D \NC \bf Alpha \NC \bf Beta \NC \bf Gamma \NC\NR
-%D \NC 1 \NC right indeed \NC definitely wrong \NC\NR
-%D \NC 2 \NC oh yes \NC simply no \NC\NR
-%D \NC 3 \NC very true \NC as false as can be \NC\NR
-%D \NC 4 \NC the whole truth \NC but the truth \NC\NR
-%D \stoptabulate
-%D \stopbuffer
-%D
-%D \typebuffer {\tracetabulatetrue\getbuffer}
-
-%D Because we want to be compatible we use an indirect way to implement the
-%D definers. The next examples demonstrate the difference:
-%D
-%D \starttyping
-%D \definetabulate[test][|l|c|r|]
-%D \definetabulate[test][two][|r|c|l|]
-%D
-%D \definetabulation[more][format={|l|c|r|}]
-%D \definetabulation[more:two][format={|r|c|l|}]
-%D
-%D \starttest
-%D \NC t \NC t \NC t \NC \NR
-%D \NC te \NC te \NC te \NC \NR
-%D \NC tes \NC tes \NC tes \NC \NR
-%D \NC test \NC test \NC test \NC \NR
-%D \stoptest
-%D
-%D \starttest[two]
-%D \NC t \NC t \NC t \NC \NR
-%D \NC te \NC te \NC te \NC \NR
-%D \NC tes \NC tes \NC tes \NC \NR
-%D \NC test \NC test \NC test \NC \NR
-%D \stoptest
-%D \startmore
-%D \NC t \NC t \NC t \NC \NR
-%D \NC te \NC te \NC te \NC \NR
-%D \NC tes \NC tes \NC tes \NC \NR
-%D \NC test \NC test \NC test \NC \NR
-%D \stopmore
-%D
-%D \startmore[two]
-%D \NC t \NC t \NC t \NC \NR
-%D \NC te \NC te \NC te \NC \NR
-%D \NC tes \NC tes \NC tes \NC \NR
-%D \NC test \NC test \NC test \NC \NR
-%D \stopmore
-%D \stoptyping
-
-\installcorenamespace {tabulation}
-
-\installcommandhandler \??tabulation {tabulation} \??tabulation
-
-\setuptabulation
- [\c!unit=1em,
- EQ={:},
- \c!format={|l|p|},
- \c!frame=\v!off,
- %\c!bodyfont=,
- \c!rule=\v!normal,
- %\c!rulecolor=,
- \c!rulethickness=\linewidth,
- %\c!inner=,
- \c!before=\blank,
- \c!after=\blank,
- \c!distance={\v!depth,\v!medium},
- \c!align=\v!normal,
- \c!margin=\!!zeropoint,
- \c!split=\v!auto,
- \c!header=\v!yes,
- %\c!title=,
- \c!indenting=\v!no]
-
-\unexpanded\def\definetabulate
- {\dotripleempty\tabl_tabulate_define}
-
-\def\tabl_tabulate_define[#1][#2][#3]%
- {\ifthirdargument
- % [tag] [sub] [template]
- \ifcsname\namedtabulationhash{#1}\s!check\endcsname \else
- \definetabulation[#1][\c!format={#3},\s!check=]%
- \fi
- \definetabulation[#1:#2][#1][\c!format={#3},\s!check=]%
- \orelse\ifsecondargument
- % [tag] [template]
- \definetabulation[#1][\c!format={#2},\s!check=]%
- \else
- % [tag]
- \definetabulation[#1][\c!format={|l|p|},\s!check=]%
- \fi}
-
-\unexpanded\def\setuptabulate
- {\dotripleempty\tabl_tabulate_setup}
-
-\def\tabl_tabulate_setup[#1][#2][#3]%
- {\ifthirdargument
- % [tag] [sub] [settings]
- \setuptabulation[#1:#2][#3]%
- \orelse\ifsecondargument
- % [tag] [settings]
- \setuptabulation[#1][#2]%
- \else
- % [tag]
- \setuptabulation[#1]%
- \fi}
-
-\appendtoks
- \setuevalue{\e!start\currenttabulation}{\tabl_start_defined[\currenttabulation]}%
- \letvalue{\e!stop\currenttabulation}\relax
- \letvalue{\??tabulatehead\currenttabulation}\empty
- \letvalue{\??tabulatefoot\currenttabulation}\empty
-\to \everydefinetabulation
-
-\let\tabulateparameter\tabulationparameter % will stay for a while
-\def\currenttabulate {\currenttabulation} % will stay for a while
-
-% Here begins the implementation.
-
-\let\tabl_tabulate_insert_head\empty
-\let\tabl_tabulate_insert_body\empty
-\let\tabl_tabulate_insert_foot\empty
-
-\def\tabl_tabulate_insert_head_content
- {\tabulatenoalign{\global\settrue\c_tabl_tabulate_someamble}%
- \begincsname\??tabulatehead\currenttabulation\endcsname
- \tabulatenoalign{\global\setfalse\c_tabl_tabulate_someamble}}%
-
-\def\tabl_tabulate_insert_foot_content
- {\tabulatenoalign{\global\settrue\c_tabl_tabulate_someamble}%
- \begincsname\??tabulatefoot\currenttabulation\endcsname
- \tabulatenoalign{\global\setfalse\c_tabl_tabulate_someamble}}%
-
-\def\tabl_tabulate_check_full_content % - needed, else confusion with \c!header
- {\ifcsname\??tabulatehead\currenttabulation\endcsname
- %\expandafter\ifx\csname\??tabulatehead\currenttabulation\endcsname\empty
- \expandafter\ifx\lastnamedcs\empty
- \let\tabl_tabulate_insert_head\empty
- \else
- \let\tabl_tabulate_insert_head\tabl_tabulate_insert_head_content
- \fi
- \else
- \let\tabl_tabulate_insert_head\empty
- \fi
- \ifcsname\??tabulatefoot\currenttabulation\endcsname
- \expandafter\ifx\csname\??tabulatefoot\currenttabulation\endcsname\empty
- %\expandafter\ifx\lastnamedcs\empty
- \let\tabl_tabulate_insert_foot\empty
- \else
- \let\tabl_tabulate_insert_foot\tabl_tabulate_insert_foot_content
- \fi
- \else
- \let\tabl_tabulate_insert_foot\empty
- \fi}
-
-\def\tabl_tabulate_insert_content
- {\tabl_tabulate_insert_head
- \ifcase\c_tabl_tabulate_repeathead \else
- \tabulatenoalign{\penalty\zerocount}% added 7/5/2014 WS mail
- \fi
- \tabl_tabulate_insert_body
- \tabl_tabulate_insert_foot
- \tabl_tabulate_remove_funny_line}
-
-\def\tabl_tabulate_remove_funny_line
- {\ifhmode
- \strut\crcr
- \tabulatenoalign{\kern-\lineheight}%
- \fi}
-
-% todo: make footer synonym to tail
-
-\setuvalue{\e!start\v!tabulatehead}{\doifelsenextoptionalcs\tabl_tabulate_start_head_yes\tabl_tabulate_start_head_nop}
-\setuvalue{\e!start\v!tabulatetail}{\doifelsenextoptionalcs\tabl_tabulate_start_foot_yes\tabl_tabulate_start_foot_nop}
-
-\let\m_tabl_tabulate_data\empty
-
-\def\tabl_tabulate_start_head_yes[#1]%
- {\processcontent{\e!stop\v!tabulatehead}\m_tabl_tabulate_data{\letvalue{\??tabulatehead#1}\m_tabl_tabulate_data}}
-
-\def\tabl_tabulate_start_foot_yes[#1]%
- {\processcontent{\e!stop\v!tabulatetail}\m_tabl_tabulate_data{\letvalue{\??tabulatefoot#1}\m_tabl_tabulate_data}}
-
-\def\tabl_tabulate_start_head_nop{\tabl_tabulate_start_head_yes[\v!tabulate]}
-\def\tabl_tabulate_start_foot_nop{\tabl_tabulate_start_foot_yes[\v!tabulate]}
-
-\unexpanded\def\tabl_start_defined[#1]%
- {\bgroup
- \edef\currenttabulationparent{#1}%
- \let\currenttabulation\currenttabulationparent
- \edef\p_format{\tabulationparameter\c!format}%
- \ifx\p_format\v!none
- % this is special case: we need to define the generic english
- % \starttabulate in other interfaces as well
- \expandafter\dodoubleempty \expandafter\tabl_start_regular
- \else
- \expandafter\dodoubleargument\expandafter\tabl_start_defined_indeed
- \fi}
-
-\def\tabl_start_defined_indeed
- {\iffirstargument
- \ifsecondargument
- \doubleexpandafter\tabl_start_defined_two
- \else
- \doubleexpandafter\tabl_start_defined_one
- \fi
- \else
- \singleexpandafter\tabl_start_defined_zero
- \fi}
-
-\def\tabl_start_defined_one[#1][#2]%
- {\ifcondition\validassignment{#1}%
- \setuptabulation[\currenttabulation][#1]%
- \else
- \edef\currenttabulation{\currenttabulation:#1}%
- \fi
- \tabl_tabulate_start_building}
-
-\def\tabl_start_defined_two[#1][#2]%
- {\edef\currenttabulation{\currenttabulation:#1}%
- \setuptabulation[\currenttabulation][#2]%
- \tabl_tabulate_start_building}
-
-\def\tabl_start_defined_zero[#1][#2]%
- {\tabl_tabulate_start_building}
-
-% \definetabulate[\v!tabulate][|l|p|] % we need to get rid of this one
-
-\unexpanded\setuvalue{\e!start\v!tabulate}%
- {\bgroup % whole thing
- \let\currenttabulationparent\empty
- \dodoubleempty\tabl_start_regular}
-
-\def\tabl_start_regular
- {\let\currenttabulation\currenttabulationparent
- \ifsecondargument
- \expandafter\tabl_start_regular_two
- \else
- \expandafter\tabl_start_regular_one
- \fi}
-
-\def\tabl_default_format{|l|p|}
-
-\def\tabl_start_regular_one[#1][#2]%
- {\ifcondition\validassignment{#1}%
- \lettabulationparameter\c!format\tabl_default_format
- \setupcurrenttabulation[#1]%
- \else
- \def\p_format{#1}%
- \ifx\p_format\empty
- \def\p_format{|l|p|}%
- \fi
- \lettabulationparameter\c!format\p_format
- \fi
- \tabl_tabulate_start_building}
-
-\def\tabl_start_regular_two[#1][#2]%
- {\def\p_format{#1}%
- \ifx\p_format\empty
- \let\p_format\tabl_default_format
- \fi
- \lettabulationparameter\c!format\p_format
- \setupcurrenttabulation[#2]%
- \tabl_tabulate_start_building}
-
-\letvalue{\e!stop\v!tabulate }\relax
-\letvalue{\e!stop\v!tabulatehead}\relax
-\letvalue{\e!stop\v!tabulatetail}\relax
-
-\unexpanded\def\tabl_tabulate_start_ignore
- {\em Nested tabulate is not (yet) supported.\relax
- \expandafter\gobbleuntil\csname\ifconditional\c_tabl_generic stoptabulate\else\e!stop\v!tabulate\fi\endcsname}
-
-\appendtoks
- \letvalue{\e!start\v!tabulate}\tabl_tabulate_start_ignore % only the main one
-\to \everytabulate
-
-\setvalue{\??tabulatesplit\v!yes }{\settrue\c_tabl_tabulate_split}
-\setvalue{\??tabulatesplit\v!repeat}{\settrue\c_tabl_tabulate_split}
-\setvalue{\??tabulatesplit\v!no }{\setfalse\c_tabl_tabulate_split}
-\setvalue{\??tabulatesplit\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\c_tabl_tabulate_split\fi\fi}
-
-% todo: spacing around tabulate when bodyfont is set
-
-% \let\tabl_tabulate_inside_before \relax
-% \let\tabl_tabulate_inside_after \relax
-% \let\tabl_tabulate_inside_inbetween\relax
-%
-% \def\tabl_tabulate_outside_before
-% {\whitespace
-% \tabulationparameter\c!before}
-%
-% \def\tabl_tabulate_outside_after
-% {\tabulationparameter\c!after}
-
-% \showboxes
-%
-% \startcombination
-% {\insidefloattrue \starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
-% {\insidefloattrue \starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
-% \stopcombination
-%
-% \startcombination
-% {\vbox{\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate}} {}
-% {\vbox{\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate}} {}
-% \stopcombination
-%
-% \startcombination
-% {\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
-% {\starttabulate[|||] \NC test \NC test \NC \NR \stoptabulate} {}
-% \stopcombination
-
-\let\tabl_tabulate_inside_after \relax
-\let\tabl_tabulate_outside_after \relax
-\let\tabl_tabulate_inside_inbetween \relax
-\let\tabl_tabulate_outside_inbetween\relax
-
-\unexpanded\def\tabl_tabulate_inside_before
- {\ifhmode\par\fi
- \ifhmode
- \ifinsidesplitfloat
- \let\tabl_tabulate_inside_after\relax
- \else
- \vbox\bgroup
- \let\tabl_tabulate_inside_after\egroup
- \fi
- \else
- \let\tabl_tabulate_inside_after\relax
- \fi}
-
-\unexpanded\def\tabl_tabulate_outside_before
- {\ifhmode\par\fi
- \ifhmode
- \vbox\bgroup
- \let\tabl_tabulate_outside_after \egroup
- \let\tabl_tabulate_outside_inbetween\relax
- \orelse\ifinner
- \let\tabl_tabulate_outside_after \relax
- \let\tabl_tabulate_outside_inbetween\relax
- \else
- \whitespace
- \tabulationparameter\c!before
- \relax
- \let\tabl_tabulate_outside_after \tabl_tabulate_outside_after_indeed
- \let\tabl_tabulate_outside_inbetween\tabl_tabulate_outside_inbetween_indeed
- \fi}
-
-\def\tabl_tabulate_outside_after_indeed
- {\tabulationparameter\c!after}
-
-\def\tabl_tabulate_outside_inbetween_indeed
- {\doifempty{\tabulationparameter\c!after}
- {\vskip\strutdp
- \verticalstrut
- \vskip-\struttotal}}
-
-\def\tabl_tabulate_inside_inbetween % needs checking
- {\doifempty{\tabulationparameter\c!after}
- {\vskip\strutdp
- \verticalstrut
- \vskip-\struttotal}}
-
-\unexpanded\def\tabl_tabulate_start_building
- {\ifinsidefloat
- \tabl_tabulate_inside_before
- \else
- \tabl_tabulate_outside_before
- \fi
- \bgroup % settings
- %
- \t_tabl_tabulate_preamble\emptytoks
- \t_tabl_tabulate_dummy \emptytoks
- %
- \resetcharacteralign
- %
- \edef\p_distance {\tabulationparameter\c!distance}%
- \edef\p_align {\tabulationparameter\c!align}%
- \edef\p_line {\tabulationparameter\c!rule}%
- \edef\p_rulecolor {\tabulationparameter\c!rulecolor}%
- \edef\p_rulethickness{\tabulationparameter\c!rulethickness}%
- \edef\p_bodyfont {\tabulationparameter\c!bodyfont}
- \edef\p_indenting {\tabulationparameter\c!indenting}%
- \edef\p_keeptogether {\tabulationparameter\c!keeptogether}%
- \edef\p_blank {\tabulationparameter\c!blank}%
- %
- \ifx\p_keeptogether\v!no
- \settrue \c_tabl_tabulate_tolerant_break
- %\setfalse\c_tabl_tabulate_handlepbreak
- \else
- \setfalse\c_tabl_tabulate_tolerant_break
- %\settrue \c_tabl_tabulate_handlepbreak
- \fi
- %
- \settrue\c_tabl_tabulate_split
- \begincsname\??tabulatesplit\tabulationparameter\c!split\endcsname
- %
- \let\m_tabl_tabulate_blank_default\p_blank
- %
- \d_tabl_tabulate_unit\tabulationparameter\c!unit
- \d_tabl_tabulate_margin\tabulationparameter\c!margin
- \let\m_tabl_tabulate_vrule_color_default\p_rulecolor
- \let\m_tabl_tabulate_hrule_color_default\p_rulecolor
- \d_tabl_tabulate_vrulethickness_default\p_rulethickness
- \d_tabl_tabulate_hrulethickness_default\p_rulethickness
- \ifx\p_bodyfont\empty\else
- \switchtobodyfont[\p_bodyfont]%
- \fi
- \postponenotes % new, to be tested / will be configurable
- \widowpenalty\zerocount % otherwise lines are not broken
- \clubpenalty \zerocount % but overlap in funny ways
- \the\everytabulate
- \tabulationparameter\c!inner
- \d_tabl_tabulate_indent\dimexpr\leftskip+\hangindent\ifx\p_indenting\v!yes+\parindent\fi\relax
- \global\c_tabl_tabulate_column\zerocount
- \processcontent
- {\ifconditional\c_tabl_generic stoptabulate\else\e!stop\ifx\currenttabulationparent\empty\v!tabulate\else\currenttabulationparent\fi\fi}
- \tabl_tabulate_insert_body
- \tabl_tabulate_process}
-
-\def\tabulateEQ
- {\ifconditional\c_tabl_tabulate_firstflushed\else
- \dostarttaggedchained\t!ignore\empty\empty
- \dostarttagged\t!ignore\empty
- \tabulationparameter{EQ}%
- \dostoptagged
- \dostoptagged
- \fi
- \global\setfalse\c_tabl_tabulate_equal}
-
-% The next ones will be token registers
-
-\let\tabulatenormalpos\relax % hooks, todo
-\let\tabulateequalpos \relax % hooks, todo
-
-% color columns
-
-\let\m_tabl_tabulate_color_previous \empty
-\let\m_tabl_tabulate_color \empty
-\let\m_tabl_tabulate_text_color \empty
-\let\m_tabl_tabulate_color_local \empty
-\let\m_tabl_tabulate_vrule_color \empty
-\let\m_tabl_tabulate_vrule_color_local \empty
-\let\m_tabl_tabulate_vrule_color_default\empty % used local
-\let\m_tabl_tabulate_hrule_color_default\empty % used local
-\let\m_tabl_tabulate_blank_default \empty
-
-\appendtoks
- \glet\m_tabl_tabulate_color_previous \empty
- \glet\m_tabl_tabulate_color \empty
- \glet\m_tabl_tabulate_text_color \empty
- \glet\m_tabl_tabulate_color_local \empty
- \glet\m_tabl_tabulate_vrule_color \empty
- \glet\m_tabl_tabulate_vrule_color_local \empty
- \global \d_tabl_tabulate_vrulethickness_local\zeropoint
-\to \t_tabl_tabulate_every_row
-
-\unexpanded\def\tabl_tabulate_color_side_right_second
- {\ifx\m_tabl_tabulate_color_previous\empty \else
- \tabl_tabulate_color_set\m_tabl_tabulate_color_previous
- \glet\m_tabl_tabulate_color_previous\empty
- \fi}
-
-\unexpanded\def\tabl_tabulate_color_side_left_second
- {\ifx\m_tabl_tabulate_color\empty \else
- \ifcase\c_tabl_tabulate_colorspan
- \or
- \tabl_tabulate_color_set\m_tabl_tabulate_color
- \or
- \tabl_tabulate_color_set\m_tabl_tabulate_color
- \fi
- \fi}
-
-\unexpanded\def\tabl_tabulate_color_side_both_second
- {\ifx\m_tabl_tabulate_color\empty \else
- \tabl_tabulate_color_set\m_tabl_tabulate_color
- \ifcase\c_tabl_tabulate_colorspan
- %\glet\m_tabl_tabulate_color_previous\empty
- \or
- \glet\m_tabl_tabulate_color_previous\empty
- \or
- \glet\m_tabl_tabulate_color_previous\m_tabl_tabulate_color
- \or
- \glet\m_tabl_tabulate_color_previous\m_tabl_tabulate_color
- \fi
- \fi}
-
-\let\tabl_tabulate_color_side_right \relax
-\let\tabl_tabulate_color_side_left \relax
-\let\tabl_tabulate_color_side_both \relax
-
-\appendtoks
- \let\tabl_tabulate_color_side_right\tabl_tabulate_color_side_right_second
- \let\tabl_tabulate_color_side_left \tabl_tabulate_color_side_left_second
- \let\tabl_tabulate_color_side_both \tabl_tabulate_color_side_both_second
-\to \t_tabl_tabulate_initializers_second
-
-\def\tabl_tabulate_set_color_column#1% overloaded
- {\unskip
- \doifelsefastoptionalcheck{\tabl_tabulate_set_color_column_yes#1}{\tabl_tabulate_set_color_column_nop#1}}
-
-\def\tabl_tabulate_set_color_column_nop
- {\tabl_tabulate_column_normal\zerocount}
-
-\def\tabl_tabulate_set_color_column_yes#1[#2]%
- {\xdef\m_tabl_tabulate_color_local{#2}%
- \tabl_tabulate_column_normal\zerocount#1}
-
-% normal columns:
-
-\def\tabl_tabulate_column_normal#1#2%
- {\unskip
- \aligntab
- \ifconditional\c_tabl_tabulate_equal\tabulateequalpos\else\tabulatenormalpos\fi
- \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_max_vrulecolumn\else
- \tabl_tabulate_column_vrule_setup
- \fi
- \aligntab
- \global\c_tabl_tabulate_kind#1%
- \global\c_tabl_tabulate_type#2%
- \aligntab}
-
-% equal columns
-
-\def\tabl_tabulate_column_equal#1#2%
- {\unskip
- \aligntab
- \tabulateequalpos
- \aligntab
- \global\c_tabl_tabulate_kind#1%
- \global\c_tabl_tabulate_type#2%
- \aligntab}
-
-% ruled columns
-
-\def\tabl_tabulate_column_vruled_preset
- {\glet\m_tabl_tabulate_vrule_color_local\m_tabl_tabulate_vrule_color_default
- \global\d_tabl_tabulate_vrulethickness_local\d_tabl_tabulate_vrulethickness_default}
-
-\def\tabl_tabulate_column_vruled#1#2%
- {\unskip % 0-n
- %\ifnum\c_tabl_tabulate_column=\plusone
- % \global\c_tabl_tabulate_has_rule_spec_first\plusone
- %\orelse\ifnum\c_tabl_tabulate_column=\c_tabl_tabulate_nofcolumns
- % \global\c_tabl_tabulate_has_rule_spec_last\plusone
- %\fi
- \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_max_vrulecolumn
- \global\c_tabl_tabulate_max_vrulecolumn\c_tabl_tabulate_column
- \fi
- \doifelsefastoptionalcheck{\tabl_tabulate_column_vruled_yes#1#2}{\tabl_tabulate_column_vruled_nop#1#2}}
-
-\def\tabl_tabulate_column_vrule_setup
- {\begincsname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname}
-
-\def\tabl_tabulate_column_vruled_nop
- {\expandafter\glet\csname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname\tabl_tabulate_column_vruled_preset
- \tabl_tabulate_column_normal}
-
-\def\tabl_tabulate_column_vruled_step#1%
- {\doifelsenumber{#1}
- {\global\d_tabl_tabulate_vrulethickness_local#1\d_tabl_tabulate_vrulethickness_default}
- {\xdef\m_tabl_tabulate_vrule_color_local{#1}}}
-
-\def\tabl_tabulate_column_vruled_yes#1#2[#3]%
- {\expandafter\gdef\csname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname
- {\tabl_tabulate_column_vruled_preset
- \rawprocesscommalist[#3]\tabl_tabulate_column_vruled_step}%
- \tabl_tabulate_column_normal#1#2}
-
-\def\tabl_tabulate_vrule_reset
- {\ifcase\c_tabl_tabulate_max_vrulecolumn\else
- \tabl_tabulate_vrule_reset_indeed
- \fi}
-
-\def\tabl_tabulate_vrule_reset_indeed
- {\dofastloopcs\c_tabl_tabulate_max_vrulecolumn\tabl_tabulate_vrule_reset_step
- \global\c_tabl_tabulate_max_vrulecolumn\zerocount}
-
-\def\tabl_tabulate_vrule_reset_step % undefined or relax
- {\expandafter\glet\csname\??tabulatevrule\the\fastloopindex\endcsname\undefined}
-
-\appendtoks
- \tabl_tabulate_vrule_reset
-\to \t_tabl_tabulate_every_after_row
-
-% sometimes more efficient:
-%
-% \def\tabl_tabulate_column_vruled_yes#1#2[#3]%
-% {\rawprocesscommalist[#3]\tabl_tabulate_column_vruled_step
-% \expandafter\xdef\csname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname
-% {\global\d_tabl_tabulate_vrulethickness_local\the\d_tabl_tabulate_vrulethickness_default
-% \noexpand\xdef\noexpand\m_tabl_tabulate_vrule_color_local{\m_tabl_tabulate_vrule_color_local}}%
-% \tabl_tabulate_column_normal#1#2}
-
-\def\tabl_tabulate_column_vruled_normal
- {\vrule\s!width\d_tabl_tabulate_vrulethickness\relax}
-
-\def\tabl_tabulate_column_vruled_colored
- {\dousecolorparameter\m_tabl_tabulate_vrule_color
- \vrule\s!width\d_tabl_tabulate_vrulethickness\relax}
-
-\unexpanded\def\tabl_tabulate_column_vrule_inject_first
- {\ifcase\d_tabl_tabulate_vrulethickness\else
- \tabl_tabulate_column_vruled_normal % could be a skip instead
- \fi
- \global\d_tabl_tabulate_vrulethickness\zeropoint} % nils second one
-
-\unexpanded\def\tabl_tabulate_column_vrule_inject_second
- {\ifcase\d_tabl_tabulate_vrulethickness\else
- \ifx\m_tabl_tabulate_vrule_color\empty
- \tabl_tabulate_column_vruled_normal
- \else
- \tabl_tabulate_column_vruled_colored
- \fi
- \fi
- \global\d_tabl_tabulate_vrulethickness\zeropoint} % nils second one
-
-\let\tabl_tabulate_column_vrule_inject\relax
-
-\appendtoks
- \let\tabl_tabulate_column_vrule_inject\tabl_tabulate_column_vrule_inject_first
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \let\tabl_tabulate_column_vrule_inject\tabl_tabulate_column_vrule_inject_second
-\to \t_tabl_tabulate_initializers_second
-
-% auto columns
-
-\def\tabl_tabulate_column_inject_auto
- {\tabl_tabulate_column_normal\zerocount\zerocount
- \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_columns\relax
- \expandafter\NR
- \else
- \expandafter\ignorespaces % interferes with the more tricky hooks
- \fi}
-
-\unexpanded\def\setquicktabulate#1% see \startlegend \startgiven (for the moment still public)
- {\let#1\tabl_tabulate_column_inject_auto
- \let\\\tabl_tabulate_column_inject_auto} % brrr, will go
-
-\setvalue{\??tabulateseparator\v!blank }{\s_tabl_tabulate_separator\bigskipamount}
-\setvalue{\??tabulateseparator\v!depth }{\s_tabl_tabulate_separator\strutdp}
-\setvalue{\??tabulateseparator\v!small }{\def\m_tabl_tabulate_separator_factor{.25}}
-\setvalue{\??tabulateseparator\v!medium}{\def\m_tabl_tabulate_separator_factor{.5}}
-\setvalue{\??tabulateseparator\v!big }{}
-\setvalue{\??tabulateseparator\v!none }{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount}
-\setvalue{\??tabulateseparator\v!grid }{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount}
-
-\def\tabl_tabulate_column_rule_separator_step#1%
- {\ifcsname\??tabulateseparator#1\endcsname
- \lastnamedcs
- \else
- \s_tabl_tabulate_separator#1\relax
- \fi}
-
-\def\tabl_tabulate_column_rule_separator_inject % can be sped up (will do when used frequently)
- {\bgroup
- \s_tabl_tabulate_separator\strutdp
- \ifx\p_distance\empty\else
- \let\m_tabl_tabulate_separator_factor\plusone
- \processcommacommand[\p_distance]\tabl_tabulate_column_rule_separator_step
- \s_tabl_tabulate_separator\m_tabl_tabulate_separator_factor\s_tabl_tabulate_separator
- \fi
- % someamble: footer or header: unfortunately a skip can trigger a page break (weird
- % as we have lots of nobreaks)
- % \ifconditional\c_tabl_tabulate_someamble\kern\else\vskip\fi\s_tabl_tabulate_separator % new
- % \directvspacing{\the\s_tabl_tabulate_separator}% new
- \directvskip\s_tabl_tabulate_separator
- \egroup}
-
-\def\tabl_tabulate_hrule_spec_ignore#1%
- {%\glet\currenttabulationlocalhrulecolor\empty
- %\global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default
- \doifelsefastoptionalcheck#1#1}
-
-\def\tabl_tabulate_hrule_spec_pickup#1%
- {\glet\currenttabulationlocalhrulecolor\m_tabl_tabulate_hrule_color_default
- \global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default
- \doifelsefastoptionalcheck{\tabl_tabulate_hrule_preset#1}#1}
-
-\def\tabl_tabulate_hrule_preset_step#1%
- {\doifelsenumber{#1}
- {\global\d_tabl_tabulate_hrulethickness_local#1\d_tabl_tabulate_hrulethickness_default}
- {\xdef\currenttabulationlocalhrulecolor{#1}}}
-
-\def\tabl_tabulate_hrule_preset#1[#2]%
- {\rawprocesscommalist[#2]\tabl_tabulate_hrule_preset_step
- #1}
-
-\def\tabl_tabulate_hrule_inject_normal
- {\autorule
- \s!height.5\d_tabl_tabulate_hrulethickness_local
- \s!depth .5\d_tabl_tabulate_hrulethickness_local
- \s!left \d_tabl_tabulate_indent
- \relax}
-
-\def\tabl_tabulate_hrule_inject_colored
- {\dousecolorparameter\currenttabulationlocalhrulecolor
- \tabl_tabulate_hrule_inject_normal}
-
-\unexpanded\def\tabl_tabulate_hrule_inject_first
- {\ifcase\d_tabl_tabulate_hrulethickness_local\else
- \tabl_tabulate_hrule_inject_normal
- \fi}
-
-\unexpanded\def\tabl_tabulate_hrule_inject_second
- {\ifcase\d_tabl_tabulate_hrulethickness_local\else
- \ifx\currenttabulationlocalhrulecolor\empty
- \tabl_tabulate_hrule_inject_normal
- \else
- \tabl_tabulate_hrule_inject_colored
- \fi
- \fi}
-
-\let\tabl_tabulate_hrule_inject\relax
-
-\appendtoks
- \let\tabl_tabulate_hrule_inject\tabl_tabulate_hrule_inject_first
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \let\tabl_tabulate_hrule_inject\tabl_tabulate_hrule_inject_second
-\to \t_tabl_tabulate_initializers_second
-
-%D Color:
-
-% \starttabulate[||p||]
-% \NC test \NC test \NC test \NC \NR
-% \NC test \CC[green] \input tufte \CC[yellow] test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \CC[blue] test \CC[red] test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \CC[gray] test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \CC[blue] test \NC test \NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \NC test \CC[magenta] test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \CC[cyan] \dorecurse{10}{\input ward }\NC test \NC \NR
-% \NC test \NC test \NC test \NC \NR
-% \NC test \CC[yellow] test \NC test \NC \NR
-% \stoptabulate
-
-\unexpanded\def\tabl_tabulate_color_set#1% we could store the attributes at the cost of a lua call
- {\begingroup
- \clf_enablebackgroundalign % was \node_backgrounds_align_initialize
- \glet\tabl_tabulate_color_repeat\tabl_tabulate_color_repeat_second
- \global\settrue\c_tabl_tabulate_has_colors
- \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_max_colorcolumn
- \global\c_tabl_tabulate_max_colorcolumn\c_tabl_tabulate_column
- \fi
- \expandafter\xdef\csname\??tabulatecolor\the\c_tabl_tabulate_column\endcsname{#1}%
- \hpack \thealignbackgroundcolorattr{#1}{}% pack ?
- \endgroup}
-
-\def\tabl_tabulate_color_repeat_second % for split off lines
- {\begingroup
- \scratchcounter\numexpr\c_tabl_tabulate_column-\plusone\relax % ugly !
- \ifcsname\??tabulatecolor\the\scratchcounter\endcsname
- % \hbox \thealignbackgroundcolorattr{\csname\??tabulatecolor\the\scratchcounter\endcsname}{}% pack ?
- \hpack \expandafter\thealignbackgroundcolorattr\expandafter{\lastnamedcs}{}% pack ?
- \fi
- \endgroup}
-
-\let\tabl_tabulate_color_repeat\relax
-
-\appendtoks
- \let\tabl_tabulate_color_repeat\relax
-\to \everytabulate
-
-\def\tabl_tabulate_color_reset
- {\ifcase\c_tabl_tabulate_max_colorcolumn\else
- \tabl_tabulate_color_reset_indeed
- \fi}
-
-% \def\tabl_tabulate_color_reset_indeed
-% {\dorecurse\c_tabl_tabulate_max_colorcolumn{\letgvalue{\??tabulatecolor\recurselevel}\undefined}} % slow
-
-\def\tabl_tabulate_color_reset_indeed
- {\dofastloopcs\c_tabl_tabulate_max_colorcolumn\tabl_tabulate_color_reset_step}
-
-\def\tabl_tabulate_color_reset_step % undefined or empty?
- {\expandafter\glet\csname\??tabulatecolor\number\fastloopindex\endcsname\undefined}
-
-\appendtoks
- \tabl_tabulate_color_reset
-\to \t_tabl_tabulate_every_after_row
-
-% \def\tabl_tabulate_register_par_options_indeed
-% {\iftrialtypesetting \else
-% \registerparoptions
-% \ifinsidefloat
-% % that is, an unbreakable one
-% \glet\tabl_tabulate_register_par_options\empty
-% \else
-% % unsafe in crossing pages, at each b...
-% % \glet\tabl_tabulate_register_par_options\empty
-% \fi
-% \fi}
-%
-% \appendtoks
-% \glet\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_indeed
-% \to \everytabulate
-
-\def\tabl_tabulate_register_par_options_first % maybe track here if needed
- {}
-
-\def\tabl_tabulate_register_par_options_second
- {\registerparoptions
- \ifinsidefloat
- % that is, an unbreakable one
- \glet\tabl_tabulate_register_par_options\empty
- \else
- % unsafe in crossing pages, at each b...
- % \glet\tabl_tabulate_register_par_options\empty
- \fi}
-
-\let\tabl_tabulate_register_par_options\relax
-
-\appendtoks
- \let\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_first
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \let\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_second
-\to \t_tabl_tabulate_initializers_second
-
-\appendtoks
- \tabl_tabulate_register_par_options
-\to \t_tabl_tabulate_every_row
-
-\def\tabl_tabulate_flush_indent_indeed
- {\hbox to \d_tabl_tabulate_indent % pack ?
- {% we now have a local hsize, and since we want to
- % register positional info (i.e. real hsizes) we
- % need to reconstitute the original hsize
- \advance\hsize\d_tabl_tabulate_indent
- % this is indeed rather messy and took a few hours
- % to dis/uncover
- \the\t_tabl_tabulate_every_row
- \hss}}
-
-\def\tabl_tabulate_flush_indent
- {\ifnum\c_tabl_tabulate_column=\zerocount
- \tabl_tabulate_flush_indent_indeed
- \fi}
-
-\def\tabl_tabulate_digits{\digits}
-
-%D Beware, we cannot use \type {\unexpanded} on \type {\HL} cum suis, since \TEX's
-%D hard coded noalign lookahead fails on it! I mistakenly added this for a while.
-
-\setvalue{\??tabulatealigning\v!normal}{0}
-\setvalue{\??tabulatealigning\v!right }{1}
-\setvalue{\??tabulatealigning\v!left }{2}
-\setvalue{\??tabulatealigning\v!middle}{3}
-
-\setvalue{\??tabulateheader\v!repeat}{\plusone}
-\setvalue{\??tabulateheader\v!text }{\plustwo}
-
-\unexpanded\def\tabl_tabulate_bskip_first {\setbox\b_tabl_tabulate\vbox\bgroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_nop}
-\unexpanded\def\tabl_tabulate_eskip_first {\par\egroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_yes}
-\unexpanded\def\tabl_tabulate_xbskip_first{\hpack\bgroup\vbox\bgroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_nop}
-\unexpanded\def\tabl_tabulate_xeskip_first{\par\egroup\egroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_yes}
-
-\let\tabl_tabulate_bbskip\relax
-\let\tabl_tabulate_eeskip\relax
-\let\tabl_tabulate_bskip \relax
-\let\tabl_tabulate_eskip \relax
-\let\tabl_tabulate_xbskip\relax
-\let\tabl_tabulate_xeskip\relax
-
-\appendtoks
- \let\tabl_tabulate_bbskip\relax
- %\let\tabl_tabulate_eeskip\relax % adapted by bskip
- \let\tabl_tabulate_bskip \tabl_tabulate_bskip_first
- \let\tabl_tabulate_eskip \tabl_tabulate_eskip_first
- \let\tabl_tabulate_xbskip\tabl_tabulate_xbskip_first
- \let\tabl_tabulate_xeskip\tabl_tabulate_xeskip_first
-\to \t_tabl_tabulate_initializers_first
-
-\def\tabl_tabulate_baselinecorrection % keep an eye on this one
- {\def\dobaselinecorrection{\vskip\dimexpr-\prevdepth+\strutdp+\strutdp\relax}% todo: mkiv
- \baselinecorrection}
-
-% some hack to prevent an allowbreak ... actually we could set up a system then
-% that is dealt with atthe lua end in the skip handler: turn penalties with attributes
-% values into other penalties that get removed
-
-\installcorenamespace{tabulatenobreak}
-
-\def\tabl_tabulate_break_allow{\directvpenalty\zerocount}
-\def\tabl_tabulate_break_maybe{\directvpenalty\zerocount}
-\def\tabl_tabulate_break_no {\directvpenalty\plustenthousand} % ,order:2}}
-
-\let\tabl_tabulate_break_state_set \relax
-\let\tabl_tabulate_break_state_reset \relax
-\let\tabl_tabulate_break_state_allowbreak\tabl_tabulate_break_maybe
-
-% so far
-
-\unexpanded\def\tabl_tabulate_VL_first{\tabl_tabulate_column_vruled\zerocount\zerocount}
-\unexpanded\def\tabl_tabulate_NC_first{\tabl_tabulate_column_normal\zerocount\zerocount}
-\unexpanded\def\tabl_tabulate_RC_first{\tabl_tabulate_column_normal\zerocount\plusone}
-\unexpanded\def\tabl_tabulate_HC_first{\tabl_tabulate_column_normal\zerocount\plustwo}
-\unexpanded\def\tabl_tabulate_EQ_first{\tabl_tabulate_column_equal \plustwo \zerocount}
-\unexpanded\def\tabl_tabulate_RQ_first{\tabl_tabulate_column_equal \zerocount\plusone}
-\unexpanded\def\tabl_tabulate_HQ_first{\tabl_tabulate_column_equal \zerocount\plustwo}
-
-\unexpanded\def\tabl_tabulate_NG_first{\tabl_tabulate_column_normal\zerocount\zerocount}
-\unexpanded\def\tabl_tabulate_NN_first{\tabl_tabulate_column_normal\zerocount\zerocount\tabl_tabulate_digits} % new, undocumented, test first
-\unexpanded\def\tabl_tabulate_ND_first{\tabl_tabulate_column_normal\zerocount\zerocount\tabl_tabulate_digits} % same, for old times sake
-
-\unexpanded\def\tabl_tabulate_NR_first {\tabl_tabulate_NR_common\conditionaltrue \tabl_tabulate_check_penalties} % next row
-\unexpanded\def\tabl_tabulate_NB_first {\tabl_tabulate_NR_common\conditionaltrue \tabl_tabulate_nobreak_inject } % next row no break
-
-\unexpanded\def\tabl_tabulate_NR_second{\tabl_tabulate_NR_common\conditionalfalse\tabl_tabulate_check_penalties} % next row
-\unexpanded\def\tabl_tabulate_NB_second{\tabl_tabulate_NR_common\conditionalfalse\tabl_tabulate_nobreak_inject } % next row no break
-
-\unexpanded\def\tabl_tabulate_CC_first{\global\c_tabl_tabulate_localcolorspan\zerocount\tabl_tabulate_set_color_column\zerocount}
-\unexpanded\def\tabl_tabulate_CL_first{\global\c_tabl_tabulate_localcolorspan\plusone \tabl_tabulate_set_color_column\zerocount}
-\unexpanded\def\tabl_tabulate_CM_first{\global\c_tabl_tabulate_localcolorspan\plustwo \tabl_tabulate_set_color_column\zerocount}
-\unexpanded\def\tabl_tabulate_CR_first{\global\c_tabl_tabulate_localcolorspan\plusthree\tabl_tabulate_set_color_column\zerocount}
-
-%D Sort of special:
-%D
-%D \startbuffer
-%D \startitemize[n]
-%D \starttabulate[|||||]
-%D \NC p \NC \itemtag \NC q \NC r \NC \NR
-%D \NC p \NC \itemtag \NC q \NC r \NC \NR
-%D \NC p \NC \itemtag \NC q \NC r \NC \NR
-%D \NC p \NC \itemtag \NC q \NC r \NC \NR
-%D \stoptabulate
-%D \stopitemize
-%D
-%D \startitemize[n]
-%D \starttabulate[|||||]
-%D \NI b \NC c \NC d \NC \NR
-%D \NC a \NI c \NC d \NC \NR
-%D \NC a \NC b \NI d \NC \NR
-%D \NC a \NC b \NC c \NI \NR
-%D \stoptabulate
-%D \stopitemize
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\unexpanded\def\tabl_tabulate_NI_first{\doifelsefastoptionalcheck\tabl_tbl_NI_yes\tabl_tbl_NI_nop}
-
-\def\tabl_tbl_NI_yes[#1]{\NC \itemtag[#1]\NC}
-\def\tabl_tbl_NI_nop {\NC \itemtag \NC}
-
-%D The following shortcut is handy for tables where one needs bold headers:
-
-\unexpanded\def\tabl_tabulate_BC_first
- {\tabl_tabulate_column_normal\plusone\zerocount
- \let\fontstyle\globalfontstyle
- \bf}
-
-\appendtoks
- \let\VL\tabl_tabulate_VL_first
- \let\NC\tabl_tabulate_NC_first
- \let\BC\tabl_tabulate_BC_first
- \let\RC\tabl_tabulate_RC_first
- \let\HC\tabl_tabulate_HC_first
- \let\EQ\tabl_tabulate_EQ_first
- \let\RQ\tabl_tabulate_RQ_first
- \let\HQ\tabl_tabulate_HQ_first
- \let\NG\tabl_tabulate_NG_first
- \let\NN\tabl_tabulate_NN_first
- \let\ND\tabl_tabulate_ND_first
- \let\NR\tabl_tabulate_NR_first
- \let\NB\tabl_tabulate_NB_first
- \let\CC\tabl_tabulate_CC_first
- \let\CL\tabl_tabulate_CL_first
- \let\CM\tabl_tabulate_CM_first
- \let\CR\tabl_tabulate_CR_first
- \let\NI\tabl_tabulate_NI_first
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \let\NR\tabl_tabulate_NR_second
- \let\NB\tabl_tabulate_NB_second
-\to \t_tabl_tabulate_initializers_second
-
-\appendtoks
- \let\SR\NR
- \let\FR\NR
- \let\MR\NR
- \let\LR\NR
- \let\AR\NR
-\to \t_tabl_tabulate_initializers_first
-
-\unexpanded\def\tabl_tabulate_NR_common#1#2%
- {\global\advance\c_tabl_tabulate_noflines\plusone
- \global\setfalse\c_tabl_tabulate_firstflushed
- \global\setfalse\c_tabl_tabulate_equal
- \global\c_tabl_tabulate_column\zerocount
- \ifconditional#1\relax
- \tabl_tabulate_break_state_reset
- \fi
- \tabl_tabulate_pheight_reset
- \unskip\unskip\crcr\tabl_tabulate_flush_collected
- % can we omit the next one in the first run? probably
- \starttabulatenoalign
- \the\t_tabl_tabulate_every_after_row
- #2%
- \stoptabulatenoalign}
-
-\def\tabl_tabulate_check_penalties
- {\ifconditional\c_tabl_tabulate_tolerant_break\else
- \ifnum\c_tabl_tabulate_totalnoflines=\plusone
- % \tabl_tabulate_break_allow
- \else
- \ifconditional\c_tabl_tabulate_someamble \ifcase\c_tabl_tabulate_repeathead \else
- \tabl_tabulate_break_allow
- \fi \fi
- \ifnum\c_tabl_tabulate_noflines=\plusone
- \tabl_tabulate_nobreak_inject
- \orelse\ifnum\c_tabl_tabulate_noflines=\c_tabl_tabulate_minusnoflines
- \ifnum\c_tabl_tabulate_plines_max<\plustwo
- \tabl_tabulate_nobreak_inject
- \else
- \tabl_tabulate_break_allow % needed with pbreak prevention
- \fi
- \else
- \tabl_tabulate_break_state_allowbreak
- \fi
- \fi
- \fi
- \global\setfalse\c_tabl_tabulate_firstflushed}
-
-\unexpanded\def\tabl_tabulate_bbskip_second_split_yes
- {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
- \ifx\tabl_tabulate_flush_collected_indeed\empty\else
- \setbox0\hbox
- \fi
- \fi}
-
-\unexpanded\def\tabl_tabulate_eskip_second
- {\par\egroup
- \tabl_tabulate_pheight_set
- \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
- \tabl_tabulate_splitoff_box}
-
-\unexpanded\def\tabl_tabulate_bskip_second_split_yes
- {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
- % first line
- \global\setbox\b_tabl_tabulate_current\c_tabl_tabulate_column\vbox
- \bgroup
- \glet\tabl_tabulate_hook\tabl_tabulate_hook_nop
- \ifconditional\c_tabl_tabulate_automode\hsize\d_tabl_tabulate_width\fi
- % \begstrut % interferes with pre-\pars
- % evt: \appendtoks\begstrut\to\everypar
- \ignorespaces
- \let\tabl_tabulate_eskip\tabl_tabulate_eskip_second
- \else
- % successive lines
- \let\tabl_tabulate_eskip\empty
- \dontcomplain
- \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
- \expandafter\tabl_tabulate_splitoff_box
- \fi}
-
-\unexpanded\def\tabl_tabulate_xbskip_second{\tabl_tabulate_bskip}
-\unexpanded\def\tabl_tabulate_xeskip_second{\tabl_tabulate_eskip}
-
-\unexpanded\def\tabl_tabulate_flush_second_indeed
- {\glet\tabl_tabulate_flush_collected_indeed\empty
- \global\c_tabl_tabulate_column\zerocount
- \tabl_tabulate_pbreak_check
- \dofastloopcs\c_tabl_tabulate_columns\tabl_tabulate_flush_second_step
- \global\settrue\c_tabl_tabulate_firstflushed}
-
-\unexpanded\def\tabl_tabulate_flush_second_step
- {\ifvoid\b_tabl_tabulate_current\fastloopindex\else
- \gdef\tabl_tabulate_flush_collected_indeed{\the\t_tabl_tabulate_dummy}%
- \fi}
-
-\def\tabl_tabulate_flush_second
- {\tabulatenoalign{\tabl_tabulate_flush_second_indeed}%
- \tabl_tabulate_flush_collected_indeed}
-
-\unexpanded\def\tabl_tabulate_bskip_second_split_nop
- {\vtop\bgroup
- \ifconditional\c_tabl_tabulate_automode\hsize\d_tabl_tabulate_width\fi
- % \begstrut % interferes with pre-\pars
- % evt: \appendtoks\begstrut\to\everypar
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_eskip_second_split_nop % vertical strut added august 2003
- {\par\verticalstrut
- \vskip-\struttotal
- \egroup}
-
-% \let\tabl_tabulate_eskip \relax % adapted by bskip
-% \let\tabl_tabulate_eeskip\relax % adapted by bskip
-
-\appendtoks
- \let\tabl_tabulate_xbskip\tabl_tabulate_xbskip_second
- \let\tabl_tabulate_xeskip\tabl_tabulate_xeskip_second
- \ifconditional\c_tabl_tabulate_split
- \let\tabl_tabulate_bskip \tabl_tabulate_bskip_second_split_yes
- \let\tabl_tabulate_bbskip\tabl_tabulate_bbskip_second_split_yes
- \else
- \let\tabl_tabulate_bskip \tabl_tabulate_bskip_second_split_nop
- \let\tabl_tabulate_eskip \tabl_tabulate_eskip_second_split_nop
- \fi
-\to \t_tabl_tabulate_initializers_second
-
-% see ***
-%
-% \enabletrackers[nodes.page_vspacing]
-% \starttext
-% \starttabulate[||] \dorecurse{100}{\NC Eins \NC \NR \HL} \stoptabulate
-% \stoptext
-
-\def\tabl_tabulate_XX_none
- {\starttabulatenoalign
- \tabl_tabulate_break_state_set
- \tabl_tabulate_hrule_spec_ignore
- \stoptabulatenoalign}
-
-\def\tabl_tabulate_FL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_FL_second_indeed}
-\def\tabl_tabulate_ML_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_ML_second_indeed}
-\def\tabl_tabulate_LL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_LL_second_indeed}
-\def\tabl_tabulate_TL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_TL_second_indeed}
-\def\tabl_tabulate_BL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_BL_second_indeed}
-
-\unexpanded\def\tabl_tabulate_FL_second_indeed
- {\ifinsidefloat\else
- \doifempty{\tabulationparameter\c!before}\tabl_tabulate_baselinecorrection % no expansion
- \fi
- \tabl_tabulate_hrule_inject
- \tabl_tabulate_nobreak_inject
- \tabl_tabulate_column_rule_separator_inject
- \prevdepth\strutdp
- \tabl_tabulate_nobreak_inject
- \stoptabulatenoalign}
-
-\def\spac_vspacing_no_topskip % use grouped
- {\attribute\skipcategoryattribute\plusten}
-
-\unexpanded\def\tabl_tabulate_ML_second_indeed
- {\tabl_tabulate_break_no
- \tabl_tabulate_column_rule_separator_inject
- \tabl_tabulate_break_no
- \tabl_tabulate_hrule_inject
- \vskip-\p_rulethickness\relax
- \begingroup
- \spac_vspacing_no_topskip
- \tabl_tabulate_hrule_inject
- \endgroup
- \tabl_tabulate_break_no
- \tabl_tabulate_column_rule_separator_inject
- \stoptabulatenoalign}
-
-\unexpanded\def\tabl_tabulate_LL_second_indeed
- {\tabl_tabulate_nobreak_inject
- \tabl_tabulate_column_rule_separator_inject
- \tabl_tabulate_nobreak_inject
- \tabl_tabulate_hrule_inject
- \ifinsidefloat
- \tabl_tabulate_inside_inbetween
- \else
- \tabl_tabulate_outside_inbetween
- \fi
- \stoptabulatenoalign}
-
-\unexpanded\def\tabl_tabulate_TL_second_indeed
- {\tabl_tabulate_nobreak_inject
- \tabl_tabulate_column_rule_separator_inject
- \tabl_tabulate_nobreak_inject
- \tabl_tabulate_hrule_inject
- \tabl_tabulate_nobreak_inject
- \tabl_tabulate_column_rule_separator_inject
- %\prevdepth\strutdp % todo, might differ between TL and BL
- \tabl_tabulate_nobreak_inject
- \stoptabulatenoalign}
-
-\let\tabl_tabulate_BL_second_indeed\tabl_tabulate_TL_second_indeed
-
-\def\tabl_tabulate_HL_second
- {\csname
- \ifnum\c_tabl_tabulate_noflines=\zerocount F\orelse
- \ifnum\c_tabl_tabulate_noflines=\c_tabl_tabulate_totalnoflines L\else
- M\fi
- L\endcsname}
-
-\appendtoks
- \let\FL\tabl_tabulate_XX_none
- \let\ML\tabl_tabulate_XX_none
- \let\LL\tabl_tabulate_XX_none
- \let\TL\tabl_tabulate_XX_none
- \let\BL\tabl_tabulate_XX_none
- \let\HL\tabl_tabulate_XX_none
- \let\HR\tabl_tabulate_XX_none
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \let\FL\tabl_tabulate_FL_second
- \let\ML\tabl_tabulate_ML_second
- \let\LL\tabl_tabulate_LL_second
- \let\TL\tabl_tabulate_TL_second
- \let\BL\tabl_tabulate_BL_second
- \let\HL\tabl_tabulate_HL_second
- \let\HR\tabl_tabulate_HL_second
-\to \t_tabl_tabulate_initializers_second
-
-% \def\tabulatedoHRfive % horizontal rule line (break untested)
-% {\starttabulatenoalign
-% \glet\dotabulateautoline\dotabulatelinerule
-% %\ifcase#1\or % todo: check what this does
-% \ifnum\noftabulatelines=\zerocount
-% \glet\dotabulateautoline\donothing
-% \else\ifnum\noftabulatelines=\totalnoftabulatelines
-% \glet\dotabulateautoline\donothing
-% \fi\fi
-% %\fi
-% \dotabulatenobreak
-% \stoptabulatenoalign
-% \dotabulateautoline
-% \starttabulatenoalign
-% \tabl_tabulate_break_no
-% \ifx\dotabulateautoline\dotabulatelinerule\kern-\lineheight\fi
-% \ifnum\noftabulatelines=\totalnoftabulatelines
-% \expandafter\dotabulatenobreak
-% \else
-% \expandafter\tabl_tabulate_break_allow
-% \fi
-% \stoptabulatenoalign
-% \dotabulateautoline
-% \starttabulatenoalign
-% \dotabulatenobreak
-% \stoptabulatenoalign}
-
-% \dorecurse{10}{
-% \starttabulate[|l|]
-% \FL
-% \NC first line, bound to next rule \NC \NR
-% \TL
-% \NC bound to previous rule \NC \NR
-% \NC some line \NC \NR
-% \NC some line \NC \NR
-% \NC some line \NC \NR
-% \NC bound to next rule \NC \NR
-% \ML
-% \NC bound to previous rule \NC \NR
-% \NC bound to next rule \NC \NR
-% \BL
-% \NC last line, bound to previous rule \NC \NR
-% \LL
-% \stoptabulate
-% }
-
-% This needs checking:
-
-\def\tabulaterule {\HR} % a rule with lineheight
-\def\tabulateline {\HL} % just a spaced rule
-\def\tabulateautorule{\HR}%
-\def\tabulateautoline{\HL} % no longer different (to be looked into)
-
-%D When support for vertical rules we needed a way to pick up the specification for
-%D the final rule and a \type {|{}} interface was chosen. As a result parsing had to
-%D become more complex and I was not in the mood for messing up the code too much.
-%D Therefore from now on the preamble is split by \LUA. There are definitely more
-%D places where we can use \LUA\ code (for instance in alignment of numbers. The
-%D repeat parser is replace at the \LUA\ end as well.
-
-\let\tabl_tabulate_flush_collected \empty
-\let\tabl_tabulate_flush_collected_indeed\empty
-
-\let\v_tabl_tabulate_align\!!zerocount
-
-\def\tabl_tabulate_check_side_float % new per 29-07-2016
- {\ifdefined\page_sides_check_floats_indeed
- \page_sides_check_floats_indeed
- \ifdim\hangindent>\zeropoint
- \advance\d_tabl_tabulate_indent\hangindent
- \fi
- \fi}
-
-\def\tabl_tabulate_set_local_hsize
- {\setlocalhsize
- \hsize\localhsize}
-
-\def\tabl_tabulate_process
- {\c_tabl_tabulate_pass\plusone
- \tabl_tabulate_check_full_content
- \edef\v_tabl_tabulate_align{\ifcsname\??tabulatealigning\p_align\endcsname\lastnamedcs\else0\fi}%
- \s_tabl_tabulate_first.5\d_tabl_tabulate_unit
- \s_tabl_tabulate_last\s_tabl_tabulate_first
- \s_tabl_tabulate_pre\zeropoint
- \s_tabl_tabulate_post\s_tabl_tabulate_first % was: \zeropoint
- \global\c_tabl_tabulate_columns\zerocount
- \global\c_tabl_tabulate_nofauto\zerocount
- \global\c_tabl_tabulate_noflines\zerocount
- \c_tabl_tabulate_totalnoflines\zerocount
- \c_tabl_tabulate_minusnoflines\zerocount
- \global\d_tabl_tabulate_width_p\zeropoint
- \global\d_tabl_tabulate_width_w\zeropoint
- \global\setfalse\c_tabl_tabulate_equal
- \tabl_tabulate_pheight_reset
- \tabskip\zeropoint
- \ifinsidesplitfloat
- \donetrue
- \orelse\ifinsidefloat
- \donefalse
- \else
- \donetrue
- \fi
- \global\c_tabl_tabulate_repeathead
- \ifdone
- \ifcsname\??tabulateheader\tabulationparameter\c!header\endcsname
- \lastnamedcs
- \else
- \zerocount
- \fi
- \else
- \zerocount
- \fi
- %
- \the\t_tabl_tabulate_initializers_first % collect more here
- %
- \glet\tabl_tabulate_flush_collected\empty
- \ifdim\d_tabl_tabulate_margin>\zeropoint
- \t_tabl_tabulate_preamble
- {\aligntab
- \tabl_tabulate_flush_indent
-% \global\advance\c_tabl_tabulate_noflines\plusone
- \strut
- \alignmark\alignmark
- \tabskip\d_tabl_tabulate_margin
- \strut
- \aligntab
- \alignmark\alignmark
- \tabskip\zeropoint}%
- \else
- \t_tabl_tabulate_preamble
- {\aligntab
- \tabl_tabulate_flush_indent
-% \global\advance\c_tabl_tabulate_noflines\plusone
- \strut
- \alignmark\alignmark
- \aligntab
- \alignmark\alignmark
- \tabskip\zeropoint}%
- \fi
- \d_tabl_tabulate_width\zeropoint
- % these counters are set at the lua end
- \c_tabl_tabulate_nofcolumns \zerocount
- \c_tabl_tabulate_has_rule_spec_first\zerocount
- \c_tabl_tabulate_has_rule_spec_last \zerocount
- \clf_presettabulate{\detokenizedtabulationparameter\c!format}%
- %
- % \edef\totaltabulatecolumns{\the\numexpr3*\c_tabl_tabulate_columns+\plusfour}%
- \d_tabl_tabulate_width\zeropoint
- \tabl_tabulate_initialize_boxes\c_tabl_tabulate_columns
- \toksapp\t_tabl_tabulate_preamble{%
- \aligntab\alignmark\alignmark
- \global\advance\c_tabl_tabulate_column\plusone % maybe just set it already
- }%
- \toksapp\t_tabl_tabulate_dummy{%
- \NC\unskip\unskip\crcr\tabl_tabulate_flush_collected % no count
- }%
- \global\c_tabl_tabulate_column\zerocount
- \tabl_tabulate_pheight_reset
- \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
- \ifx\p_indenting\v!no
- \forgetparindent
- \fi
- \ifinsidefloat
- \d_tabl_tabulate_indent\zeropoint
- \else
- \tabl_tabulate_check_side_float
- \tabl_tabulate_set_local_hsize
- \fi
- \dontcomplain
- \forgetall % hm, interference with preceding \forgetparindent probably bug, to be solved
- \everypar\everytabulatepar
- \setbox\scratchbox\vbox % outside \if because of line counting
- {\notesenabledfalse
- \d_tabl_tabulate_indent\zeropoint
- \settrialtypesetting % very important
- \anch_backgrounds_text_level_start
- \expandafter\halign\expandafter{\the\t_tabl_tabulate_preamble\crcr\tabl_tabulate_insert_content\crcr}}%
- \anch_backgrounds_text_level_stop
- \ifcase\c_anch_backgrounds_text_state\else
- \global\settrue\tablehaspositions
- \fi
- \ifnum\c_tabl_tabulate_nofauto>\zerocount
- % so, even if the natural size is larger, in the final run, we force the calculated width
- \d_tabl_tabulate_width\dimexpr\hsize-\wd\scratchbox-\d_tabl_tabulate_width_p-\d_tabl_tabulate_width_w\relax
- \ifnum\c_tabl_tabulate_nofauto>\zerocount
- \divide\d_tabl_tabulate_width \c_tabl_tabulate_nofauto\relax
- \fi
- \fi
- \setbox\scratchbox\emptybox % free memory
- \ifconditional\c_tabl_tabulate_split
- \splittopskip\strutht
- \glet\tabl_tabulate_flush_collected_indeed\empty
- \glet\tabl_tabulate_flush_collected\tabl_tabulate_flush_second
- \fi
- \c_tabl_tabulate_totalnoflines\c_tabl_tabulate_noflines
- \c_tabl_tabulate_minusnoflines\numexpr\c_tabl_tabulate_noflines+\minusone\relax
- \global\c_tabl_tabulate_noflines\zerocount
- %
- \c_tabl_tabulate_pass\plustwo % final pass
- \the\t_tabl_tabulate_initializers_second % collect more here
- %
- \ifx\p_line\v!line
- \let\HL\HR
- \let\tabulateautoline\tabulateautorule
- \let\tabulateline\tabulaterule
- \fi
- %
- \ifcase\c_tabl_tabulate_repeathead
- \ifinsidesplitfloat
- \global\setbox\b_tabl_tabulate\vbox \bgroup
- \else
- \startframedcontent[\tabulationparameter\c!frame]%
- \fi
- \else
- \global\setbox\b_tabl_tabulate\vbox \bgroup
- \fi
- %
- \dostarttaggedchained\t!tabulate\empty\??tabulation
- \dostarttagged\t!tabulaterow\empty
- \setfalse\inhibitmargindata % new per 2012.06.13 ... really needed
- % \everycr\expandafter{\the\everycr\noalign{\the\t_tabl_tabulate_every_real_row}\dostoptagged\dostarttagged\t!tabulaterow\empty}%
- \toksapp\everycr{\noalign{\the\t_tabl_tabulate_every_real_row}\dostoptagged\dostarttagged\t!tabulaterow\empty}%
- \expandafter\halign\expandafter{\the\t_tabl_tabulate_preamble\crcr\tabl_tabulate_insert_content\crcr}%
- \dostoptagged
- \dostoptagged
- \ifhmode\par\prevdepth\strutdp\fi % nog eens beter, temporary hack
- \ifx\p_distance\v!grid
- \vskip-\strutdp % experimental tm-prikkels
- \fi
- %
- \ifcase\c_tabl_tabulate_repeathead
- \ifinsidesplitfloat
- \egroup % box
- \egroup % settings
- \tabl_split_box\b_tabl_tabulate
- \else
- \stopframedcontent
- \egroup
- \fi
- \else
- \egroup % box
- \egroup % settings
- \tabl_split_box\b_tabl_tabulate
- \fi
- %
- \ifinsidefloat
- \tabl_tabulate_inside_after
- \else
- \tabl_tabulate_outside_after
- \fi
- \egroup} % whole thing
-
-% \egroup
-
-% \setuptabulate[split=yes,header=text,title=Vervolg van Tabel]
-%
-% % \starttabulatehead
-% % \NC test \NC hans\NC \NR
-% % \stoptabulatehead
-%
-% \starttabulate
-% \NC test \NC \input tufte \relax \NC \NR
-% \NC test \NC \input knuth \relax \NC \NR
-% \NC test \NC \input knuth \relax \NC \NR
-% \NC test \NC \input tufte \relax \NC \NR
-% \NC test \NC \input tufte \relax \NC \NR
-% \NC test \NC \input tufte \relax \NC \NR
-% \stoptabulate
-
-\def\tabl_split_box#1% #1 <> 0/2 / derived from the one in core-ntb.tex
- {\ifinsidesplitfloat
- \tabl_split_box_indeed#1%
- \orelse\ifinsidefloat
- \unvbox#1%
- \else
- \tabl_split_box_indeed#1%
- \fi}
-
-\def\tabl_split_box_indeed#1%
- {\resettsplit
- \def\tsplitminimumfreelines{2}%
- \def\tsplitminimumfreespace{0pt}%
- \setbox\tsplitcontent\box#1%
- \ifcase\c_tabl_tabulate_repeathead\or
- \setbox\tsplithead\vsplit\tsplitcontent to \lineheight
- \setbox\tsplithead\vbox{\unvbox\tsplithead}%
- \or
- \setbox\tsplithead\vbox{\hbox{\strut\tabulationparameter\c!title}}%
- \fi
- \handletsplit}
-
-%D \starttyping
-%D \setuptabulate[split=no,rule=line]
-%D
-%D \starttabulate
-%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
-%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
-%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
-%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
-%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
-%D \NC tufte \NC \input tufte \NC \NR \tabulateautorule
-%D \stoptabulate
-%D \stoptyping
-
-%D Spacing:
-%
-% \starttabulate
-% \NC text \NC text \NC \NR
-% \TB[small]
-% \NC text \NC text \NC \NR
-% \TB[4*big]
-% \NC text \NC text \NC \NR
-% \stoptabulate
-
-\def\tabl_tabulate_TB
- {\starttabulatenoalign
- \dosingleempty\tabl_tabulate_TB_indeed}
-
-\def\tabl_tabulate_TB_indeed[#1]%
- {\iffirstargument
- \blank[#1]
- \orelse\ifx\m_tabl_tabulate_blank_default\empty
- \blank
- \else
- \blank[\m_tabl_tabulate_blank_default]%
- \fi
- \stoptabulatenoalign}
-
-% to be tested:
-%
-% \def\tabl_tabulate_TB
-% {\starttabulatenoalign
-% \doiffastoptionalcheckelse\tabl_tabulate_TB_yes\tabl_tabulate_TB_nop}
-%
-% \def\tabl_tabulate_TB_yes[#1]%
-% {\blank[#1]
-% \stoptabulatenoalign}
-%
-% \def\tabl_tabulate_TB_nop[#1]%
-% {\blank
-% \stoptabulatenoalign}
-
-\appendtoks
- \let\TB\tabl_tabulate_TB
-\to \everytabulate
-
-% %D Between alignment lines certain rules apply, and even a simple test can mess
-% %D up a table, which is why we have a special test facilityL
-% %D
-% %D \startbuffer
-% %D \starttabulate[|l|p|]
-% %D \NC 1test \NC test \NC \NR
-% %D \tableifelse{\doifelse{a}{a}}{\NC Xtest \NC test \NC \NR}{}%
-% %D \stoptabulate
-% %D \stopbuffer
-% %D
-% %D \typebuffer \getbuffer
-%
-% \def\tableifelse#1% should be tabulatenoalign then
-% {\tablenoalign
-% {#1%
-% {\aftergroup \firstoftwoarguments}%
-% {\aftergroup\secondoftwoarguments}}}
-%
-% \def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}}
-
-%D Some new trickery:
-%D
-%D \startbuffer
-%D \settrue\c_tabl_tabulate_splitoff_whitespace
-%D
-%D \starttabulate[|p(2cm)|p(2cm)|p(2cm)|]
-%D \NC test 1a \NC test 2a \NC test 3a
-%D \par
-%D test 3b \NC \NR
-%D \NC test 1a \NC test 2a \NC test 3a
-%D \blank[line]
-%D test 3b \NC \NR
-%D \NC test 1a \NC test 2a \NC test 3a
-%D \blank[halfline]
-%D test 3b
-%D \blank[halfline]
-%D test 3c \NC \NR
-%D \NC \blank \NC \blank \NC \blank \NC \NR
-%D \NC test 1a \NC test 2a \NC test 3a
-%D \blank[halfline]
-%D test 3b
-%D \blank[halfline]
-%D test 3c \NC \NR
-%D \NC \blank \NC \blank \NC \NC \NR
-%D \NC test 1a
-%D \par
-%D test 1b
-%D \par
-%D test 1b \NC test 2a
-%D \par
-%D test 2b
-%D \par
-%D test 2b \NC test 3a \NC \NR
-%D \NC test 1a
-%D \blank
-%D test 1b
-%D \par
-%D test 1b \NC test 2a
-%D \par
-%D test 2b
-%D \blank
-%D test 2b \NC test 3a \NC \NR
-%D \stoptabulate
-%D \stopbuffer
-%D
-%D \typebuffer \start \getbuffer \stop
-
-% \starttabulatie[|mc|]
-% \NC \digits{100.000,00} \NC\NR
-% \NC \digits{@10.000,00} \NC\NR
-% \NC \digits{@@@.100,00} \NC\NR
-% \NC \digits{@@@.@10,@@} \NC\NR
-% \NC \digits{@@@.@@1,@@} \NC\NR
-% \stoptabulatie
-%
-% \starttabulatie[|mc|]
-% \ND 100.000,00 \NC\NR
-% \ND @10.000,00 \NC\NR
-% \ND @@@.100,00 \NC\NR
-% \ND @@@.@10,@@ \NC\NR
-% \ND @@@.@@1,@@ \NC\NR
-% \stoptabulatie
-%
-% \starttabulatie[|c|]
-% \ND $100.000,00$ \NC\NR
-% \ND $@10.000,00$ \NC\NR
-% \ND $@@@.100,00$ \NC\NR
-% \ND $@@@.@10,@@$ \NC\NR
-% \ND $@@@.@@1,@@$ \NC\NR
-% \stoptabulatie
-%
-% \starttabulatie[|c|]
-% \NC $\digits 100.000,00 $ \NC\NR
-% \NC $\digits @10.000,00 $ \NC\NR
-% \NC $\digits @@@.100,00 $ \NC\NR
-% \NC $\digits @@@.@10,@@ $ \NC\NR
-% \NC $\digits @@@.@@1,@@ $ \NC\NR
-% \stoptabulatie
-%
-% \starttabulatie[|c|]
-% \NC \digits $100.000,00$ \NC\NR
-% \NC \digits $@10.000,00$ \NC\NR
-% \NC \digits $@@@.100,00$ \NC\NR
-% \NC \digits $@@@.@10,@@$ \NC\NR
-% \NC \digits $@@@.@@1,@@$ \NC\NR
-% \stoptabulatie
-
-%D Predefined categories (moved from core-mis):
-
-\definetabulate
- [\v!legend]
- [|emj1|i1|mR|]
-
-\setuptabulate
- [\v!legend]
- [\c!unit=.75em,\c!inner=\setquicktabulate\leg,EQ={=}]
-
-\definetabulate
- [\v!legend][\v!two]
- [|emj1|emk1|i1|mR|]
-
-\definetabulate
- [\v!fact]
- [|R|ecmj1|i1mR|]
-
-\setuptabulate
- [\v!fact]
- [\c!unit=.75em,\c!inner=\setquicktabulate\fact,EQ={=}]
-
-%D Another example:
-%D
-%D \starttyping
-%D \definetabulate
-%D [whatever]
-%D [|l|r|]
-%D
-%D \definetabulate
-%D [whatever][else]
-%D [|l|c|r|]
-%D
-%D \startwhatever
-%D \NC l \NC r \NC \NR
-%D \NC left \NC right \NC \NR
-%D \stopwhatever
-%D
-%D \startwhatever[else]
-%D \NC l \NC m \NC r \NC \NR
-%D \NC left \NC middle \NC right \NC \NR
-%D \stopwhatever
-%D
-%D \startwhatever[else][format={|c|c|c|c|}]
-%D \NC l \NC m \NC m \NC r \NC \NR
-%D \NC left \NC middle \NC middle \NC right \NC \NR
-%D \stopwhatever
-%D \stoptyping
-
-%D This is needed because we sometimes use the english command in tracing macros. In
-%D fact, most detailed tracing macros that are done with \LUA\ only work in the
-%D english interface anyway.
-
-% \definetabulate[tabulate] \setuptabulate[tabulate][\c!format=\v!none] % so no \v! here
-
-\newconditional\c_tabl_generic
-
-\unexpanded\setuvalue{starttabulate}%
- {\bgroup % whole thing
- \settrue\c_tabl_generic
- \let\currenttabulationparent\empty
- \dodoubleempty\tabl_start_regular}
-
-\letvalue{stoptabulate}\relax
-
-%D The following helpers are just there because we also have them at the \LUA\ end:
-%D
-%D \startbuffer
-%D \starttabulate[|l|c|r|]
-%D \tabulaterow {a,b,c}
-%D \tabulaterowbold{aa,bb,cc}
-%D \tabulaterowtype{aaa,bbb,ccc}
-%D \tabulaterowtyp {aaaa,bbbb,cccc}
-%D \stoptabulate
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-
-\def\tabl_tabulate_compact_row#1#2%
- {\NC\tabl_tabulate_compact_step#1#2,\end,}
-
-\def\tabl_tabulate_compact_step#1#2#3,%
- {\ifx#2\end
- \NR
- \expandafter\gobbleoneargument
- \else
- #1{#2#3}\NC
- \expandafter\tabl_tabulate_compact_step
- \fi#1}
-
-\unexpanded\def\tabulaterow {\tabl_tabulate_compact_row\relax}
-\unexpanded\def\tabulaterowbold{\tabl_tabulate_compact_row\bold}
-\unexpanded\def\tabulaterowtype{\tabl_tabulate_compact_row\type}
-\unexpanded\def\tabulaterowtyp {\tabl_tabulate_compact_row\typ}
-
-%D Here we plug in a row background feature. As we only have support for
-%D \type {frame=name} we can use these variables.
-%D
-%D \starttyping
-%D \startuseMPgraphic{foo}
-%D fill unitsquare
-%D xyscaled (RuleWidth,RuleHeight+RuleDepth) enlarged (ExHeight/4,ExHeight/8)
-%D randomized ExHeight
-%D shifted (-ExHeight/8,ExHeight/16)
-%D withcolor RuleColor ;
-%D \stopuseMPgraphic
-%D
-%D \setuptabulate % wel only have frame=name so we can use these:
-%D [background=foo,
-%D backgroundcolor=darkred,
-%D foregroundcolor=white]
-%D
-%D \definelinefiller[foo][mp=foo,color=darkgreen]
-%D \definelinefiller[bar][mp=foo,color=darkred]
-%D
-%D \starttabulate[|||]
-%D \DB foo \BC bar \BC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \stoptabulate
-%D
-%D \starttabulate[|||]
-%D \PB foo \BC bar \BC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \stoptabulate
-%D
-%D \starttabulate[|||]
-%D \FB[bar] foo \BC bar \BC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \stoptabulate
-%D
-%D \startnarrower
-%D \starttabulate[|||]
-%D \DB foo \DB bar \BC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \stoptabulate
-%D \stopnarrower
-%D
-%D \starttabulate[|||]
-%D \BC foo \BC bar \BC \NR
-%D \NL[magenta] foo \NC bar \NC \NR
-%D \NL[yellow] foo \NC bar \NC \NR
-%D \NL[cyan] foo \NC bar \NC \NR
-%D \NL[gray] foo \NC bar \NC \NR
-%D \stoptabulate
-%D
-%D \starttabulate
-%D \NL[red] foo \NC bar \NC \NR
-%D \NL[green] foo \NL[red] bar \NC \NR
-%D \NC foo \NC bar \NC \NR
-%D \NL[blue] foo \NC \input tufte \NC \NR
-%D \NL[gray] foo \NC bar \NC \NR
-%D \NL[yellow] foo \NC bar \NC \NR
-%D \stoptabulate
-%D \stoptyping
-
-% \setuptabulate
-% [\c!background=,
-% \c!backgroundcolor=,
-% \c!foregroundcolor=,
-% \c!foregroundstyle=]
-
-\let\m_table_current_row_background \empty
-\let\m_table_current_row_background_default \empty
-\let\m_table_current_row_background_filler \empty
-\let\m_table_current_row_background_defaultfiller\empty
-\let\m_table_current_row_background_auto \empty
-
-\unexpanded\def\tabl_register_row_background#1%
- {\xdef\m_table_current_row_background{#1}}
-
-\unexpanded\def\tabl_register_row_background_filler#1%
- {\xdef\m_table_current_row_background_filler{#1}}
-
-\unexpanded\def\tabl_synchronize_row_background
- {\iftrialtypesetting\else
- \ifx\m_table_current_row_background_filler\empty
- \ifx\m_table_current_row_background\empty
- % nothing
- \tabl_synchronize_row_background_dummy
- \else
- \tabl_synchronize_row_background_indeed\m_table_current_row_background
- \fi
- \else
- \tabl_synchronize_row_background_filler_indeed\m_table_current_row_background_filler
- \fi
- \fi}
-
-\unexpanded\def\tabl_synchronize_row_background_dummy
- {\iftrialtypesetting\else
- \begingroup
- %\clf_setbackgroundrowdata\numexpr\c_tabl_tabulate_nofrealrows+\minusone\relax\zerocount\zeropoint
- \clf_setbackgroundrowdata\c_tabl_tabulate_nofrealrows\zerocount\zeropoint
- \endgroup
- \fi}
-
-\unexpanded\def\tabl_synchronize_row_background_indeed#1%
- {\iftrialtypesetting\else
- \begingroup
- \clf_enablebackgroundalign % can be moved into \clf_setbackgroundrowdata
- \dousecolorparameter{#1}%
- \setbox\scratchbox\hpack{}%
- %\clf_setbackgroundrowdata\numexpr\c_tabl_tabulate_nofrealrows+\minusone\relax\scratchbox\d_tabl_tabulate_indent
- \clf_setbackgroundrowdata\c_tabl_tabulate_nofrealrows\scratchbox\d_tabl_tabulate_indent
- \endgroup
- \fi}
-
-\unexpanded\def\tabl_synchronize_row_background_filler_indeed#1%
- {\iftrialtypesetting\else
- \begingroup
- \clf_enablebackgroundalign % can be moved into \clf_setbackgroundrowdata
- \node_linefiller_set{#1}%
- \setbox\scratchbox\hpack{}%
- %\clf_setbackgroundrowdata\numexpr\c_tabl_tabulate_nofrealrows+\minusone\relax\scratchbox\d_tabl_tabulate_indent
- \clf_setbackgroundrowdata\c_tabl_tabulate_nofrealrows\scratchbox\d_tabl_tabulate_indent
- \endgroup
- \fi}
-
-\appendtoks
- \glet\m_table_current_row_background\empty
- \glet\m_table_current_row_background_filler\empty
- \global\c_tabl_tabulate_nofrealrows\zerocount
- \global\c_tabl_tabulate_autocolor\zerocount
- \clf_resetbackgroundrowdata
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \glet\m_table_current_row_background\empty
- \glet\m_table_current_row_background_filler\empty
- \global\c_tabl_tabulate_nofrealrows\zerocount
- \global\c_tabl_tabulate_autocolor\zerocount
- \clf_resetbackgroundrowdata
-\to \t_tabl_tabulate_initializers_second
-
-\appendtoks
- \tabl_synchronize_row_background
-\to \t_tabl_tabulate_every_real_row
-
-\appendtoks
- \glet\m_table_current_row_background\empty
- \glet\m_table_current_row_background_filler\empty
-\to \t_tabl_tabulate_every_after_row
-
-\unexpanded\def\tabl_tabulate_NL_first[#1]%
- {\tabl_tabulate_column_normal\zerocount\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background{#1}%
- \fi
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_ND_first
- {\tabl_tabulate_column_normal\zerocount\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background\m_table_current_row_background_default
- \fi
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_LB_first[#1]%
- {\tabl_tabulate_column_normal\plusone\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background{#1}%
- \fi
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_DB_first
- {\tabl_tabulate_column_normal\plusone\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background\m_table_current_row_background_default
- \fi
- \let\fontstyle\globalfontstyle
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_NF_first[#1]%
- {\tabl_tabulate_column_normal\zerocount\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background_filler{#1}%
- \fi
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_NP_first
- {\tabl_tabulate_column_normal\zerocount\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background_filler\m_table_current_row_background_default_filler
- \fi
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_FB_first[#1]%
- {\tabl_tabulate_column_normal\plusone\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background_filler{#1}%
- \fi
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_PB_first
- {\tabl_tabulate_column_normal\plusone\zerocount\relax
- \ifcase\c_tabl_tabulate_column\or
- \tabl_register_row_background_filler\m_table_current_row_background_default_filler
- \fi
- \let\fontstyle\globalfontstyle
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_BC_first % overloaded
- {\tabl_tabulate_column_normal\plusone\zerocount
- \let\fontstyle\globalfontstyle
- \ifx\m_table_current_row_background\empty
- \ifx\m_table_current_row_background_filler\empty
- \usetabulationstyleandcolor\c!headstyle\c!headcolor
- \else
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \fi
- \else
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \fi}
-
-\unexpanded\def\tabl_tabulate_A_first
- {\global\advance\c_tabl_tabulate_autocolor\plusone
- \edef\m_table_current_row_background_auto{\tabulateparameter{\c!backgroundcolor:\number\c_tabl_tabulate_autocolor}}%
- \ifx\m_table_current_row_background_auto\empty
- \global\c_tabl_tabulate_autocolor\plusone
- \edef\m_table_current_row_background_auto{\tabulateparameter{\c!backgroundcolor:\number\c_tabl_tabulate_autocolor}}%
- \fi
- \ifx\m_table_current_row_background_auto\empty
- \let\m_table_current_row_background_auto\empty % \m_table_current_row_background_default
- \fi
- \tabl_register_row_background{\m_table_current_row_background_auto}}
-
-\unexpanded\def\tabl_tabulate_NA_first
- {\tabl_tabulate_column_normal\zerocount\zerocount\relax
- \iftrialtypesetting\else
- \ifcase\c_tabl_tabulate_column\or
- \tabl_tabulate_A_first
- \fi
- \fi
- \ignorespaces}
-
-\unexpanded\def\tabl_tabulate_BA_first
- {\tabl_tabulate_column_normal\plusone\zerocount\relax
- \iftrialtypesetting\else
- \ifcase\c_tabl_tabulate_column\or
- \tabl_tabulate_A_first
- \fi
- \fi
- \usetabulationstyleandcolor\c!foregroundstyle\c!foregroundcolor
- \ignorespaces}
-
-\appendtoks
- \let\NL\tabl_tabulate_NL_first % NC with Line
- \let\ND\tabl_tabulate_ND_first % NC with Default Line
- \let\LB\tabl_tabulate_LB_first % BC with Line
- \let\DB\tabl_tabulate_DB_first % BC with Default Line
- \let\NF\tabl_tabulate_NF_first % NC with Filler
- \let\NP\tabl_tabulate_NP_first % NC with Predefined Filler
- \let\FB\tabl_tabulate_FB_first % BC with Filler
- \let\PB\tabl_tabulate_PB_first % BC with Predefined Filler
- \let\NA\tabl_tabulate_NA_first % NC with Auto Line
- \let\BA\tabl_tabulate_BA_first % NC with Auto Line
-\to \t_tabl_tabulate_initializers_first
-
-\appendtoks
- \edef\m_table_current_row_background_default {\tabulateparameter\c!backgroundcolor}%
- \edef\m_table_current_row_background_default_filler{\tabulateparameter\c!background}%
- \let \m_table_current_row_background_auto \empty
-\to \everytabulate
-
-\setuptabulate
- [\c!headcolor=,
- \c!headstyle=\bf,
- \c!backgroundcolor=\tabulationparameter\c!rulecolor,
- \c!foregroundcolor=,
- \c!foregroundstyle=\tabulationparameter\c!headstyle]
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.lua b/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.lua
index 2ff87e21abe..c9dd1e4e519 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.lua
@@ -900,7 +900,7 @@ function xtables.construct()
end
nofr = nofr + 1
local rp = rowproperties[r]
- -- we have a direction issue here but hpack_node_list(list,0,"exactly","TLT") cannot be used
+ -- we have a direction issue here but hpack_node_list(list,0,"exactly") cannot be used
-- due to the fact that we need the width
local hbox = hpack_node_list(list)
setdirection(hbox,lefttoright_code)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.mkvi b/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.mkvi
index e8279589276..c5042a405bd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/tabl-xtb.mkvi
@@ -67,7 +67,7 @@
%
% cells: option=fixed : nils autostretch (not yet complete)
-% \setbox\scratchbox\hbox attr \taggedattribute \attribute\taggedattribute {...}
+% \setbox\scratchbox\hbox attr \taggedattribute \c_attr_tagged {...}
%
% \let\tsplitbeforeresult\donothing
% \let\tsplitafterresult \donothing
diff --git a/Master/texmf-dist/tex/context/base/mkiv/task-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/task-ini.lua
index 19fff66b8f4..3e78fb2f9c8 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/task-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/task-ini.lua
@@ -53,7 +53,7 @@ appendaction("processors", "fonts", "typesetters.fontkerns.handler",
appendaction("processors", "fonts", "nodes.handlers.protectglyphs", nil, "nonut", "enabled" )
appendaction("processors", "fonts", "builders.kernel.ligaturing", nil, "nut", "disabled" )
appendaction("processors", "fonts", "builders.kernel.kerning", nil, "nut", "disabled" )
-appendaction("processors", "fonts", "builders.kernel.cleanup", nil, "nut", "enabled" )
+appendaction("processors", "fonts", "nodes.handlers.show", nil, "nut", "disabled" )
appendaction("processors", "fonts", "nodes.handlers.stripping", nil, "nut", "disabled" )
appendaction("processors", "fonts", "nodes.handlers.flatten", nil, "nut", "disabled" )
appendaction("processors", "fonts", "fonts.goodies.colorschemes.coloring", nil, "nut", "disabled" )
@@ -66,11 +66,17 @@ appendaction("processors", "lists", "typesetters.digits.handler",
appendaction("processors", "lists", "typesetters.italics.handler", nil, "nut", "disabled" )
appendaction("processors", "lists", "languages.visualizediscretionaries", nil, "nut", "disabled" )
+if CONTEXTLMTXMODE == 0 then
+
+appendaction("processors", "lists", "nodes.handlers.migrate", nil, "nut", "disabled" )
+
+end
+
appendaction("processors", "after", "typesetters.marksuspects", nil, "nut", "disabled" )
+appendaction("shipouts", "normalizers", "nodes.handlers.cleanuppage", nil, "nut", "production")
appendaction("shipouts", "normalizers", "typesetters.showsuspects", nil, "nut", "disabled" )
appendaction("shipouts", "normalizers", "typesetters.margins.finalhandler", nil, "nut", "disabled" )
-------------("shipouts", "normalizers", "nodes.handlers.cleanuppage", nil, "nut", "disabled" )
appendaction("shipouts", "normalizers", "builders.paragraphs.expansion.trace", nil, "nut", "disabled" )
appendaction("shipouts", "normalizers", "typesetters.alignments.handler", nil, "nut", "disabled" )
appendaction("shipouts", "normalizers", "nodes.references.handler", nil, "nut", "production")
@@ -89,6 +95,7 @@ appendaction("shipouts", "finishers", "attributes.transparencies.handler",
appendaction("shipouts", "finishers", "attributes.colorintents.handler", nil, "nut", "disabled" )
appendaction("shipouts", "finishers", "attributes.negatives.handler", nil, "nut", "disabled" )
appendaction("shipouts", "finishers", "attributes.effects.handler", nil, "nut", "disabled" )
+appendaction("shipouts", "finishers", "attributes.alternates.handler", nil, "nut", "disabled" )
appendaction("shipouts", "finishers", "attributes.viewerlayers.handler", nil, "nut", "disabled" )
appendaction("shipouts", "wrapup", "nodes.handlers.export", nil, "nut", "disabled" ) -- always last
@@ -118,7 +125,12 @@ appendaction("math", "builders", "typesetters.directions.processmath"
appendaction("math", "builders", "noads.handlers.makeup", nil, "nonut", "disabled" )
appendaction("math", "builders", "noads.handlers.align", nil, "nonut", "enabled" )
+if CONTEXTLMTXMODE == 0 then
+
appendaction("finalizers", "lists", "typesetters.paragraphs.normalize", nil, "nut", "enabled" ) -- "disabled"
+
+end
+
appendaction("finalizers", "lists", "typesetters.margins.localhandler", nil, "nut", "disabled" )
appendaction("finalizers", "lists", "builders.paragraphs.keeptogether", nil, "nut", "disabled" )
appendaction("finalizers", "fonts", "builders.paragraphs.solutions.splitters.optimize", nil, "nonut", "disabled" )
diff --git a/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua
index eef26574e0e..7120b47c3cd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua
@@ -18,63 +18,53 @@ local printtable = table.print
local concat = table.concat
local format = string.format
-if token.commands then
-
- local commands = token.commands()
-
- tokens.commands = utilities.storage.allocate(table.swapped(commands,commands))
-
-else
-
- tokens.commands = { }
-
-end
-
-local scan_toks = token.scan_toks
-local scan_string = token.scan_string
-local scan_argument = token.scan_argument
-local scan_tokenlist = token.scan_tokenlist
-local scan_int = token.scan_int
-local scan_code = token.scan_code
-local scan_token_code = token.scan_token_code
-local scan_dimen = token.scan_dimen
-local scan_glue = token.scan_glue
-local scan_keyword = token.scan_keyword
-local scan_keyword_cs = token.scan_keyword_cs or scan_keyword
-local scan_token = token.scan_token
-local scan_box = token.scan_box
-local scan_word = token.scan_word
-local scan_key = token.scan_key
-local scan_value = token.scan_value
-local scan_char = token.scan_char
-local scan_number = token.scan_number
-local scan_csname = token.scan_csname
-local scan_real = token.scan_real
-local scan_float = token.scan_float
-
-local get_next = token.get_next
-local get_next_token = token.get_next_token
-local skip_next = token.skip_next
-local peek_next_char = token.peek_next_char
-local is_next_char = token.is_next_char
-
-local set_macro = token.set_macro
-local get_macro = token.get_macro
-local get_meaning = token.get_meaning
-local get_cmdname = token.get_cmdname
-local set_char = token.set_char
-local set_lua = token.set_lua
-
-local create_token = token.create
-local new_token = token.new
-local is_defined = token.is_defined
-local is_token = token.is_token
-
-tokens.new = new_token
-tokens.create = create_token
-tokens.istoken = is_token
-tokens.isdefined = is_defined
-tokens.defined = is_defined
+local commands = token.commands()
+tokens.commands = utilities.storage.allocate(table.swapped(commands,commands))
+tokens.values = { }
+
+local scan_toks = token.scan_toks
+local scan_string = token.scan_string
+local scan_argument = token.scan_argument
+local scan_delimited = token.scan_delimited
+local scan_tokenlist = token.scan_tokenlist or scan_string
+local scan_integer = token.scan_integer or token.scan_int
+local scan_cardinal = token.scan_cardinal
+local scan_code = token.scan_code
+local scan_token_code = token.scan_token_code
+local scan_dimen = token.scan_dimen
+local scan_glue = token.scan_glue
+local scan_skip = token.scan_skip
+local scan_keyword = token.scan_keyword
+local scan_keyword_cs = token.scan_keyword_cs or scan_keyword
+local scan_token = token.scan_token
+local scan_box = token.scan_box
+local scan_word = token.scan_word
+local scan_letters = token.scan_letters or scan_word -- lmtx
+local scan_key = token.scan_key
+local scan_value = token.scan_value
+local scan_char = token.scan_char
+local scan_number = token.scan_number -- not defined
+local scan_csname = token.scan_csname
+local scan_real = token.scan_real
+local scan_float = token.scan_float
+local scan_luanumber = token.scan_luanumber or scan_float -- only lmtx
+local scan_luainteger = token.scan_luainteger or scan_integer -- only lmtx
+local scan_luacardinal = token.scan_luacardinal or scan_cardinal -- only lmtx
+
+local set_macro = token.set_macro
+local set_char = token.set_char
+local set_lua = token.set_lua
+
+local create_token = token.create
+local new_token = token.new
+local is_defined = token.is_defined
+local is_token = token.is_token
+
+tokens.new = new_token
+tokens.create = create_token
+tokens.istoken = is_token
+tokens.isdefined = is_defined
+tokens.defined = is_defined
local bits = {
escape = 0x00000001, -- 2^00
@@ -147,6 +137,7 @@ if not scan_box then
if s == "hbox" or s == "vbox" or s == "vtop" then
put_next(create_token(s))
end
+ return scan_list()
end
token.scan_box = scan_box
@@ -154,45 +145,65 @@ if not scan_box then
end
tokens.scanners = { -- these expand
- token = scan_token,
- toks = scan_toks,
- tokens = scan_toks,
- box = scan_box,
- hbox = function() return scan_box("hbox") end,
- vbox = function() return scan_box("vbox") end,
- vtop = function() return scan_box("vtop") end,
- dimen = scan_dimen,
- dimension = scan_dimen,
- glue = scan_glue,
- skip = scan_glue,
- integer = scan_int,
- real = scan_real,
- float = scan_float,
- count = scan_int,
- string = scan_string,
- argument = scan_argument,
- tokenlist = scan_tokenlist,
- verbatim = scan_verbatim,
- code = scan_code,
- tokencode = scan_token_code,
- word = scan_word,
- key = scan_key,
- value = scan_value,
- char = scan_char,
- number = scan_number,
- boolean = scan_boolean,
- keyword = scan_keyword,
- keywordcs = scan_keyword_cs,
- csname = scan_csname,
- peek = peek_next_char,
- skip = skip_next,
- ischar = is_next_char,
+ token = scan_token,
+ toks = scan_toks,
+ tokens = scan_toks,
+ box = scan_box,
+ hbox = function() return scan_box("hbox") end,
+ vbox = function() return scan_box("vbox") end,
+ vtop = function() return scan_box("vtop") end,
+ dimen = scan_dimen,
+ dimension = scan_dimen,
+ glue = scan_glue,
+ gluevalues = function() return scan_glue(false,false,true) end,
+ gluespec = scan_skip,
+ integer = scan_integer,
+ cardinal = scan_cardinal,
+ real = scan_real,
+ float = scan_float,
+ luanumber = scan_luanumber,
+ luainteger = scan_luainteger,
+ luacardinal = scan_luacardinal,
+ count = scan_integer,
+ string = scan_string,
+ argument = scan_argument,
+ delimited = scan_delimited,
+ tokenlist = scan_tokenlist,
+ verbatim = scan_verbatim, -- detokenize
+ code = scan_code,
+ tokencode = scan_token_code,
+ word = scan_word,
+ letters = scan_letters,
+ key = scan_key,
+ value = scan_value,
+ char = scan_char,
+ number = scan_number,
+ boolean = scan_boolean,
+ keyword = scan_keyword,
+ keywordcs = scan_keyword_cs,
+ csname = scan_csname,
+
+ next = token.scan_next,
+ nextexpanded = token.scan_next_expanded,
+
+ peek = token.peek_next,
+ peekexpanded = token.peek_next_expanded,
+ peekchar = token.peek_next_char,
+
+ skip = token.skip_next,
+ skipexpanded = token.skip_next_expanded,
+
+ cmdchr = token.scan_cmdchr,
+ cmdchrexpanded = token.scan_cmdchr_expanded,
+
+ ischar = token.is_next_char,
}
tokens.getters = { -- these don't expand
- meaning = get_meaning,
- macro = get_macro,
- token = get_next,
+ meaning = token.get_meaning,
+ macro = token.get_macro,
+ token = token.scan_next or token.get_next, -- not here, use scanners.next or token
+ cstoken = token.get_cstoken,
count = tex.getcount,
dimen = tex.getdimen,
skip = tex.getglue,
@@ -215,6 +226,23 @@ tokens.setters = {
box = tex.setbox,
}
+token.accessors = {
+ command = token.get_command,
+ cmd = token.get_command,
+ cmdname = token.get_cmdname,
+ name = token.get_cmdname,
+ csname = token.get_csname,
+ index = token.get_index,
+ active = token.get_active,
+ frozen = token.get_frozen,
+ protected = token.get_protected,
+ expandable = token.get_protected,
+ user = token.get_user,
+ cmdchrcs = token.get_cmdchrcs,
+ active = token.get_active,
+ range = token.get_range,
+}
+
-- static int run_scan_token(lua_State * L)
-- {
-- saved_tex_scanner texstate;
@@ -240,12 +268,13 @@ if setinspector then
local simple = { letter = "letter", other_char = "other" }
- local function astable(t)
+ local astable = function(t)
if t and is_token(t) then
local cmdname = t.cmdname
local simple = simple[cmdname]
if simple then
return {
+ id = t.id,
category = simple,
character = utfchar(t.mode) or nil,
}
@@ -261,6 +290,7 @@ if setinspector then
frozen = t.frozen,
mode = t.mode,
index = t.index,
+ user = t.user,
cmdname = cmdname,
}
end
@@ -281,3 +311,18 @@ tokens.cache = table.setmetatableindex(function(t,k)
t[k] = v
return v
end)
+
+if LUATEXVERSION < 114 then
+
+ local d = tokens.defined
+ local c = tokens.create
+
+ function tokens.defined(s,b)
+ if b then
+ return d(s)
+ else
+ return c(s).cmd_name == "undefined_cmd"
+ end
+ end
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/toks-scn.lua b/Master/texmf-dist/tex/context/base/mkiv/toks-scn.lua
index 2d20d5a8b31..98d2f66c08d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/toks-scn.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/toks-scn.lua
@@ -22,17 +22,24 @@ local tokenbits = tokens.bits
local scanstring = scanners.string
local scanargument = scanners.argument
+local scandelimited = scanners.delimited -- lmtx
local scanverbatim = scanners.verbatim
local scantokenlist = scanners.tokenlist
+local scantoks = scanners.toks
local scaninteger = scanners.integer
+local scancardinal = scanners.cardinal
local scannumber = scanners.number
local scankeyword = scanners.keyword
local scankeywordcs = scanners.keywordcs
local scanword = scanners.word
+local scanletters = scanners.letters
local scankey = scanners.key
local scancode = scanners.code
local scanboolean = scanners.boolean
local scandimen = scanners.dimen
+local scanglue = scanners.glue
+local scangluevalues = scanners.gluevalues
+local scangluespec = scanners.gluespec
local scancsname = scanners.csname
local todimen = number.todimen
@@ -113,22 +120,24 @@ local function scantable(t,data)
if not data then
data = { }
end
- local wrapped = scanopen()
- while true do
- local key = scanword()
- if key then
- local get = t[key]
- if get then
- data[key] = get()
+ if t then
+ local wrapped = scanopen()
+ while true do
+ local key = scanword(true)
+ if key then
+ local get = t[key]
+ if get then
+ data[key] = get()
+ else
+ -- catch all we can get
+ end
else
- -- catch all we can get
+ break
end
- else
- break
end
- end
- if wrapped then
- scanclose()
+ if wrapped then
+ scanclose()
+ end
end
return data
end
@@ -165,42 +174,89 @@ function scanners.whd()
end
end
+-- begin lmtx
+
+local l = utf.byte("[")
+local r = utf.byte("]")
+
+local function scanbracketed()
+ local s = scandelimited(l, r)
+ if s then
+ return s
+ else
+ local readstate = status.getreadstate()
+ report_scan("missing argument in line %i of %a", readstate.linenumber, readstate.filename)
+ return ""
+ end
+end
+
+local function scanoptional()
+ return scandelimited(l, r) or ""
+end
+
+local function scanbracketedasis()
+ return scandelimited(l, r, false)
+end
+
+local function scanargumentasis()
+ return scanargument(false)
+end
+
+scanners.bracketed = scanbracketed
+scanners.optional = scanoptional
+scanners.bracketedasis = scanbracketedasis
+scanners.argumentasis = scanargumentasis
+
+-- end lmtx
+
local shortcuts = {
- tokens = tokens,
- bits = tokenbits,
- open = open,
- close = close,
- scanners = scanners,
- scanstring = scanstring,
- scanargument = scanargument,
- scanverbatim = scanverbatim,
- scantokenlist = scantokenlist,
- scaninteger = scaninteger,
- scannumber = scannumber,
- scantable = scantable,
- scankeyword = scankeyword,
- scankeywordcs = scankeywordcs,
- scanword = scanword,
- -- scankey = scankey,
- scancode = scancode,
- scanboolean = scanboolean,
- scandimen = scandimen,
- scandimension = scandimen,
- scanbox = scanners.box,
- scanhbox = scanners.hbox,
- scanvbox = scanners.vbox,
- scanvtop = scanners.vtop,
- scanconditional = scanconditional,
- scanopen = scanopen,
- scanclose = scanclose,
- scanlist = scanlist,
- scancsname = scancsname,
- todimen = todimen,
- tonumber = tonumber,
- tostring = tostring,
- toboolean = toboolean,
- inspect = inspect,
- report = report_scan,
+ tokens = tokens,
+ bits = tokenbits,
+ open = open,
+ close = close,
+ scanners = scanners,
+ scanstring = scanstring,
+ scanargument = scanargument,
+ scanverbatim = scanverbatim,
+ scantokenlist = scantokenlist,
+ scantoks = scantoks,
+ scaninteger = scaninteger,
+ scancardinal = scancardinal,
+ scannumber = scannumber,
+ scantable = scantable, -- not directly useable
+ scankeyword = scankeyword,
+ scankeywordcs = scankeywordcs,
+ scanword = scanword,
+ scanletters = scanletters,
+ -- scankey = scankey,
+ scancode = scancode,
+ scanboolean = scanboolean,
+ scanglue = scanglue, -- list
+ scangluespec = scangluespec,
+ scangluevalues = scangluevalues,
+ scandimen = scandimen,
+ scandimension = scandimen,
+ scanbox = scanners.box,
+ scanhbox = scanners.hbox,
+ scanvbox = scanners.vbox,
+ scanvtop = scanners.vtop,
+ scanconditional = scanconditional,
+ scanopen = scanopen,
+ scanclose = scanclose,
+ scanlist = scanlist,
+ scancsname = scancsname,
+ todimen = todimen,
+ tonumber = tonumber,
+ tostring = tostring,
+ toboolean = toboolean,
+ inspect = inspect,
+ report = report_scan,
+ -- lmtx
+ scandelimited = scandelimited, -- not directly useable
+ scanbracketed = scanbracketed,
+ scanoptional = scanoptional,
+ scanbracketedasis = scanbracketedasis,
+ scanargumentasis = scanargumentasis,
}
tokens.shortcuts = shortcuts
@@ -221,22 +277,20 @@ tokens.converters = {
toglue = "todimen",
}
--- We could just pickup a keyword but then we really need to make sure
--- that no number follows it when that is the assignment and adding
--- an optional = defeats the gain in speed. Currently we have sources
--- with no spaces (\startcontextdefinitioncode ...) so it fails there.
+-- We could just pickup a keyword but then we really need to make sure that no number
+-- follows it when that is the assignment and adding an optional = defeats the gain
+-- in speed. Currently we have sources with no spaces (\startcontextdefinitioncode
+-- ...) so it fails there.
--
--- Another drawback is that we then need to use { } instead of ending
--- with \relax (as we can do now) but that is no big deal. It's just
--- that I then need to check the TeX end. More pain than gain and a bit
--- risky too.
+-- Another drawback is that we then need to use { } instead of ending with \relax (as
+-- we can do now) but that is no big deal. It's just that I then need to check the TeX
+-- end. More pain than gain and a bit risky too. Using scanletters works better, but
+-- the gain is only some 10 percent but if we don't have keywords with numbers it might
+-- make sense in the end, some day.
local f_if = formatters[ " if scankeywordcs('%s') then data['%s'] = scan%s()"]
local f_elseif = formatters[" elseif scankeywordcs('%s') then data['%s'] = scan%s()"]
------ f_if = formatters[" local key = scanword() if key == '' then break elseif key == '%s' then data['%s'] = scan%s()"]
------ f_elseif = formatters[" elseif key == '%s' then data['%s'] = scan%s()"]
-
----- f_if_x = formatters[ " if not data['%s'] and scankeywordcs('%s') then data['%s'] = scan%s()"]
----- f_elseif_x = formatters[" elseif not data['%s'] and scankeywordcs('%s') then data['%s'] = scan%s()"]
@@ -249,52 +303,23 @@ local f_elseif_c = formatters[" elseif scankeywordcs('%s') then data['%s'] = %s
local f_scan_c = formatters["%s(scan%s())"]
-- see above
---
------ f_if_c = formatters[" local key = scanword() if key == '' then break elseif key == '%s' then data['%s'] = %s(scan%s())"]
------ f_elseif_c = formatters[" elseif k == '%s' then data['%s'] = %s(scan%s())"]
-local f_any = formatters[" else local key = scanword() if key then data[key] = scan%s() else break end end"]
-local f_any_c = formatters[" else local key = scanword() if key then data[key] = %s(scan%s()) else break end end"]
+local f_any = formatters[" else local key = scanword(true) if key then data[key] = scan%s() else break end end"]
+local f_any_c = formatters[" else local key = scanword(true) if key then data[key] = %s(scan%s()) else break end end"]
local s_done = " else break end"
-local f_any_all = formatters[" local key = scanword() if key then data[key] = scan%s() else break end"]
-local f_any_all_c= formatters[" local key = scanword() if key then data[key] = %s(scan%s()) else break end"]
+local f_any_all = formatters[" local key = scanword(true) if key then data[key] = scan%s() else break end"]
+local f_any_all_c= formatters[" local key = scanword(true) if key then data[key] = %s(scan%s()) else break end"]
local f_table = formatters["%\nt\nreturn function()\n local data = { }\n%s\n return %s\nend\n"]
local f_sequence = formatters["%\nt\n%\nt\n%\nt\nreturn function()\n return %s\nend\n"]
+local f_singular = formatters["%\nt\n%\nt\n\nreturn function(%s)\n return %s\nend\n"]
local f_simple = formatters["%\nt\nreturn function()\n return %s\nend\n"]
local f_string = formatters["%q"]
local f_action_f = formatters["action%s(%s)"]
local f_action_s = formatters["local action%s = tokens._action[%s]"]
local f_nested = formatters["local function scan%s()\n local data = { }\n%s\n return data\nend\n"]
--- local f_check = formatters[ [[
--- local wrapped = false
--- while true do
--- local c = scancode(open)
--- if c == 123 then
--- wrapped = true
--- break
--- elseif c ~= 32 then
--- break
--- end
--- end
--- while true do
--- ]] .. "%\nt\n" .. [[
--- %s
--- end
--- if wrapped then
--- while true do
--- local c = scancode(close)
--- if c == 125 then
--- break
--- elseif c ~= 32 then
--- break
--- end
--- end
--- end
--- ]] ]
-
local f_check = formatters[ [[
local wrapped = scanopen()
while true do
@@ -317,6 +342,11 @@ local presets = {
["6 strings"] = { "string", "string", "string", "string", "string", "string" },
["7 strings"] = { "string", "string", "string", "string", "string", "string", "string" },
["8 strings"] = { "string", "string", "string", "string", "string", "string", "string", "string" },
+
+ ["1 argument" ] = { "argument" },
+ ["2 arguments"] = { "argument", "argument" },
+ ["3 arguments"] = { "argument", "argument", "argument" },
+ ["4 arguments"] = { "argument", "argument", "argument", "argument" },
}
tokens.presets = presets
@@ -331,6 +361,7 @@ function tokens.compile(specification)
a = { a }
end
local code
+ local args
local function compile(t,nested)
local done = s_done
local r = { }
@@ -437,6 +468,23 @@ function tokens.compile(specification)
else
return scanners[ti]
end
+ elseif #t == 0 then
+ if specification.usage == "value" then
+ code = "b"
+ args = "_,b"
+ else
+ code = ""
+ args = ""
+ end
+ if a then
+ tokens._action = a
+ for i=1,#a do
+ code = f_action_f(i,code)
+ n = n + 1
+ f[n] = f_action_s(i,i)
+ end
+ end
+ code = f_singular(c,f,args,code)
else
local r = { }
local p = { }
@@ -522,7 +570,7 @@ end
-- { "nature", "boolean" },
-- { "escape", "string" },
-- { "escape" },
--- }
+-- },
-- "boolean",
-- }
--
diff --git a/Master/texmf-dist/tex/context/base/mkiv/toks-scn.mkiv b/Master/texmf-dist/tex/context/base/mkiv/toks-scn.mkiv
index 49edf0c242a..12abf0cb85f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/toks-scn.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/toks-scn.mkiv
@@ -19,4 +19,8 @@
\registerctxluafile{cldf-scn}{}
\registerctxluafile{cldf-stp}{}
+\ifcase \contextlmtxmode \else
+ \registerctxluafile{cldf-lmt}{}
+\fi
+
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/toks-tra.lua b/Master/texmf-dist/tex/context/base/mkiv/toks-tra.lua
deleted file mode 100644
index 3a5bc130635..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/toks-tra.lua
+++ /dev/null
@@ -1,293 +0,0 @@
-if not modules then modules = { } end modules ['toks-ini'] = {
- version = 1.001,
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- this will become a module
-
-local utfbyte, utfchar, utfvalues = utf.byte, utf.char, utf.values
-local format, gsub = string.format, string.gsub
-local tostring = tostring
-
-local tokens = tokens
-local token = token -- the built in one
-local tex = tex
-local context = context
-local commands = commands
-
-tokens.collectors = tokens.collectors or { }
-local collectors = tokens.collectors
-
-collectors.data = collectors.data or { }
-local collectordata = collectors.data
-
-collectors.registered = collectors.registered or { }
-local registered = collectors.registered
-
-local report = logs.reporter("tokens","collectors")
-
--- todo:
---
--- register : macros that will be expanded (only for demo-ing)
--- flush : print back to tex
--- test : fancy stuff
-
-local get_next = token.get_next
-local create_token = token.create
-
-function collectors.install(tag,end_cs)
- local data, d = { }, 0
- collectordata[tag] = data
- end_cs = gsub(end_cs,"^\\","")
- while true do
- local t = get_next()
- if t.csname == end_cs then
- context[end_cs]()
- return
- else
- d = d + 1
- data[d] = t
- end
- end
-end
-
-local simple = { letter = "letter", other_char = "other" }
-
-function collectors.show(data)
- -- We no longer have methods as we only used (in demos) method a
- -- so there is no need to burden the core with this. We have a
- -- different table anyway.
- if type(data) == "string" then
- data = collectordata[data]
- end
- if not data then
- return
- end
- local ctx_NC = context.NC
- local ctx_NR = context.NR
- local ctx_bold = context.bold
- local ctx_verbatim = context.verbatim
- context.starttabulate { "|Tl|Tc|Tl|" }
- ctx_NC() ctx_bold("cmd")
- ctx_NC() ctx_bold("meaning")
- ctx_NC() ctx_bold("properties")
- ctx_NC() ctx_NR()
- context.HL()
- for i=1,#data do
- local token = data[i]
- local cmdname = token.cmdname
- local simple = simple[cmdname]
- ctx_NC()
- ctx_verbatim(simple or cmdname)
- ctx_NC()
- ctx_verbatim(simple and utfchar(token.mode) or token.csname)
- ctx_NC()
- if token.active then context("active ") end
- if token.expandable then context("expandable ") end
- if token.protected then context("protected ") end
- ctx_NC()
- ctx_NR()
- end
- context.stoptabulate()
-end
-
-local function printlist(data)
- if data and #data > 0 then
- report("not supported (yet): printing back to tex")
- end
-end
-
-tokens.printlist = printlist -- will change to another namespace
-
-function collectors.flush(tag)
- printlist(collectordata[tag])
-end
-
-function collectors.test(tag,handle)
- report("not supported (yet): testing")
-end
-
-function collectors.register(name)
- report("not supported (yet): registering")
-end
-
--- -- old token code
---
--- -- 1 = command, 2 = modifier (char), 3 = controlsequence id
---
--- local create = token.create
--- local csname_id = token.csname_id
--- local command_id = token.command_id
--- local command_name = token.command_name
--- local get_next = token.get_next
--- local expand = token.expand
--- local csname_name = token.csname_name
---
--- local function printlist(data)
--- if data and #data > 0 then
--- callbacks.push('token_filter', function ()
--- callbacks.pop('token_filter') -- tricky but the nil assignment helps
--- return data
--- end)
--- end
--- end
---
--- tokens.printlist = printlist -- will change to another namespace
---
--- function collectors.flush(tag)
--- printlist(collectordata[tag])
--- end
---
--- function collectors.register(name)
--- registered[csname_id(name)] = name
--- end
---
--- local call = command_id("call")
--- local letter = command_id("letter")
--- local other = command_id("other_char")
---
--- function collectors.install(tag,end_cs)
--- local data, d = { }, 0
--- collectordata[tag] = data
--- end_cs = gsub(end_cs,"^\\","")
--- local endcs = csname_id(end_cs)
--- while true do
--- local t = get_next()
--- local a, b = t[1], t[3]
--- if b == endcs then
--- context[end_cs]()
--- return
--- elseif a == call and registered[b] then
--- expand()
--- else
--- d = d + 1
--- data[d] = t
--- end
--- end
--- end
---
--- function collectors.show(data)
--- -- We no longer have methods as we only used (in demos) method a
--- -- so there is no need to burden the core with this.
--- if type(data) == "string" then
--- data = collectordata[data]
--- end
--- if not data then
--- return
--- end
--- local ctx_NC = context.NC
--- local ctx_NR = context.NR
--- local ctx_bold = context.bold
--- local ctx_verbatim = context.verbatim
--- context.starttabulate { "|T|Tr|cT|Tr|T|" }
--- ctx_NC() ctx_bold("cmd")
--- ctx_NC() ctx_bold("chr")
--- ctx_NC()
--- ctx_NC() ctx_bold("id")
--- ctx_NC() ctx_bold("name")
--- ctx_NC() ctx_NR()
--- context.HL()
--- for i=1,#data do
--- local token = data[i]
--- local cmd = token[1]
--- local chr = token[2]
--- local id = token[3]
--- local name = command_name(token)
--- ctx_NC()
--- ctx_verbatim(name)
--- ctx_NC()
--- if tonumber(chr) >= 0 then
--- ctx_verbatim(chr)
--- end
--- ctx_NC()
--- if cmd == letter or cmd == other then
--- ctx_verbatim(utfchar(chr))
--- end
--- ctx_NC()
--- if id > 0 then
--- ctx_verbatim(id)
--- end
--- ctx_NC()
--- if id > 0 then
--- ctx_verbatim(csname_name(token) or "")
--- end
--- ctx_NC() ctx_NR()
--- end
--- context.stoptabulate()
--- end
---
--- function collectors.test(tag,handle)
--- local t, w, tn, wn = { }, { }, 0, 0
--- handle = handle or collectors.defaultwords
--- local tagdata = collectordata[tag]
--- for k=1,#tagdata do
--- local v = tagdata[k]
--- if v[1] == letter then
--- wn = wn + 1
--- w[wn] = v[2]
--- else
--- if wn > 0 then
--- handle(t,w)
--- wn = 0
--- end
--- tn = tn + 1
--- t[tn] = v
--- end
--- end
--- if wn > 0 then
--- handle(t,w)
--- end
--- collectordata[tag] = t
--- end
-
--- Interfacing:
-
-commands.collecttokens = collectors.install
-commands.showtokens = collectors.show
-commands.flushtokens = collectors.flush
-commands.testtokens = collectors.test
-commands.registertoken = collectors.register
-
--- Redundant:
-
--- function collectors.test(tag)
--- printlist(collectordata[tag])
--- end
-
--- For old times sake:
-
-collectors.dowithwords = collectors.test
-
--- This is only used in old articles ... will move to a module:
-
-tokens.vbox = create_token("vbox")
-tokens.hbox = create_token("hbox")
-tokens.vtop = create_token("vtop")
-tokens.bgroup = create_token(utfbyte("{"),1)
-tokens.egroup = create_token(utfbyte("}"),2)
-
-tokens.letter = function(chr) return create_token(utfbyte(chr),11) end
-tokens.other = function(chr) return create_token(utfbyte(chr),12) end
-
-tokens.letters = function(str)
- local t, n = { }, 0
- for chr in utfvalues(str) do
- n = n + 1
- t[n] = create_token(chr, 11)
- end
- return t
-end
-
-function collectors.defaultwords(t,str)
- if t then
- local n = #t
- n = n + 1 ; t[n] = tokens.bgroup
- n = n + 1 ; t[n] = create_token("red")
- for i=1,#str do
- n = n + 1 ; t[n] = tokens.other('*')
- end
- n = n + 1 ; t[n] = tokens.egroup
- end
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/toks-tra.mkiv b/Master/texmf-dist/tex/context/base/mkiv/toks-tra.mkiv
deleted file mode 100644
index 04f837f1cf9..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/toks-tra.mkiv
+++ /dev/null
@@ -1,34 +0,0 @@
-%D \module
-%D [ file=toks-tra, % was toks-ini
-%D version=2007.03.03,
-%D title=\CONTEXT\ Token Support,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Token Support / Tracing}
-
-\registerctxluafile{toks-tra}{}
-
-\unprotect
-
-%D Handy for manuals \unknown\ but not really used in practice, so it might
-%D become a runtime loaded module instead.
-
-\unexpanded\def\starttokens [#1]{\ctxcommand{collecttokens("#1","stoptokens")}}
- \let\stoptokens \relax
-\unexpanded\def\flushtokens [#1]{\ctxcommand{flushtokens("#1")}}
-\unexpanded\def\showtokens [#1]{\ctxcommand{showtokens("#1")}}
-\unexpanded\def\testtokens [#1]{\ctxcommand{testtokens("#1")}}
-\unexpanded\def\registertoken #1{\ctxcommand{registertoken("#1")}}
-
-\let\toks_show\showtokens % we also support the primitive
-
-\unexpanded\def\showtokens{\doifelsenextoptional\toks_show\normalshowtokens}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.lua
index 6681be51c5f..a808778b316 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.lua
@@ -8,18 +8,21 @@ if not modules then modules = { } end modules ['trac-ctx'] = {
local next = next
-local context = context
-local implement = interfaces.implement
-local register = trackers.register
+local context = context
+local implement = interfaces.implement
+local register = trackers.register
-local textrackers = tex.trackers or { }
-local texdirectives = tex.directives or { }
+local textrackers = tex.trackers or { }
+local texdirectives = tex.directives or { }
+local texexperiments = tex.experiments or { }
-tex.trackers = textrackers
-tex.directives = texdirectives
+tex.trackers = textrackers
+tex.directives = texdirectives
+tex.experiments = texexperiments
-storage.register("tex/trackers", textrackers, "tex.trackers")
-storage.register("tex/directives",texdirectives,"tex.directives")
+storage.register("tex/trackers", textrackers, "tex.trackers")
+storage.register("tex/directives", texdirectives, "tex.directives")
+storage.register("tex/experiments",texexperiments,"tex.experiments")
local function doit(category,tag,v)
local tt = category[tag]
@@ -55,6 +58,13 @@ implement {
end
}
+implement {
+ name = "initializetexexperiments",
+ actions = function()
+ initialize(texexperiments,experiments.register)
+ end
+}
+
implement {
name = "installtextracker",
arguments = "3 strings",
@@ -71,6 +81,14 @@ implement {
end,
}
+implement {
+ name = "installtexexperiment",
+ arguments = "3 strings",
+ actions = function(tag,enable,disable)
+ install(texexperiments,experiments.register,tag,enable,disable)
+ end,
+}
+
-- this one might move
interfaces.implement {
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.mkiv b/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.mkiv
index 66b5ef1ee7a..77e4a4f0ff7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-ctx.mkiv
@@ -23,9 +23,13 @@
\unexpanded\def\installtexdirective#1#2#3%
{\clf_installtexdirective{#1}{\detokenize{#2}}{\detokenize{#3}}}
+\unexpanded\def\installtexexperiment#1#2#3%
+ {\clf_installtexexperiment{#1}{\detokenize{#2}}{\detokenize{#3}}}
+
\appendtoks
\clf_initializetextrackers
\clf_initializetexdirectives
+ \clf_initializetexexperiments
\to \everyjob
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-deb.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-deb.lua
index 71055eafac9..07865e4bf50 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-deb.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-deb.lua
@@ -13,100 +13,13 @@ local status = status
local tonumber, tostring, type = tonumber, tostring, type
local format, concat, match, find, gsub = string.format, table.concat, string.match, string.find, string.gsub
-local lpegmatch = lpeg.match
--- maybe tracers -> tracers.tex (and tracers.lua for current debugger)
+local report_nl = logs.newline
+local report_str = logs.writer
------ report_tex = logs.reporter("tex error")
------ report_lua = logs.reporter("lua error")
-local report_nl = logs.newline
-local report_str = logs.writer
-
-tracers = tracers or { }
-local tracers = tracers
-
-tracers.lists = { }
-local lists = tracers.lists
-
-tracers.strings = { }
-local strings = tracers.strings
-
-local texgetdimen = tex.getdimen
-local texgettoks = tex.gettoks
-local texgetcount = tex.getcount
-local texgethelp = tex.gethelptext or function() end
-local fatalerror = tex.fatalerror
-
-local implement = interfaces.implement
-
--- this is used in lmx files but needs to be redone
-
-strings.undefined = "undefined"
-
-function tracers.dimen(name)
- local d = texgetdimen(name)
- return d and number.topoints(d) or strings.undefined
-end
-
-function tracers.count(name)
- return texgetcount(name) or strings.undefined
-end
-
-function tracers.toks(name,limit)
- local t = texgettoks(name)
- return t and string.limit(t,tonumber(limit) or 40) or strings.undefined
-end
-
-function tracers.primitive(name)
- return tex[name] or strings.undefined
-end
-
-lists.scratch = {
- 0, 2, 4, 6, 8
-}
-
-lists.internals = {
- 'p:hsize', 'p:parindent', 'p:leftskip','p:rightskip',
- 'p:vsize', 'p:parskip', 'p:baselineskip', 'p:lineskip', 'p:topskip'
-}
-
-lists.context = {
- 'd:lineheight',
- 'c:realpageno', 'c:userpageno', 'c:pageno', 'c:subpageno'
-}
-
-local types = {
- ['d'] = tracers.dimen,
- ['c'] = tracers.count,
- ['t'] = tracers.toks,
- ['p'] = tracers.primitive
-}
-
-local splitboth = lpeg.splitat(":")
-
-function tracers.type(csname)
- local tag, name = lpegmatch(splitboth,csname)
- return tag or ""
-end
-
-function tracers.name(csname)
- local tag, name = lpegmatch(splitboth,csname)
- return name or csname
-end
-
-function tracers.cs(csname)
- local tag, name = lpegmatch(splitboth,csname)
- if name and types[tag] then
- return types[tag](name)
- else
- return tracers.primitive(csname)
- end
-end
-
-function tracers.knownlist(name)
- local l = lists[name]
- return l and #l > 0
-end
+tracers = tracers or { }
+local tracers = tracers
+local implement = interfaces.implement
local savedluaerror = nil
local usescitelexer = nil
@@ -179,19 +92,12 @@ end
-- todo: some nested errors have two line numbers
-- todo: collect errorcontext in string (after code cleanup)
-- todo: have a separate status.lualinenumber
-
-- todo: \starttext bla \blank[foo] bla \stoptext
local nop = function() end
local resetmessages = status.resetmessages or nop
-local function processerror(offset)
- -- print("[[ last tex error: " .. tostring(status.lasterrorstring or "") .. " ]]")
- -- print("[[ last lua error: " .. tostring(status.lastluaerrorstring or "") .. " ]]")
- -- print("[[ last warning : " .. tostring(status.lastwarningstring or "") .. " ]]")
- -- print("[[ last location : " .. tostring(status.lastwarninglocation or "") .. " ]]")
- -- print("[[ last context : " .. tostring(status.lasterrorcontext or "") .. " ]]")
-
+local function processerror(offset,eof)
local filename = status.filename
local linenumber = tonumber(status.linenumber) or 0
local lastcontext = status.lasterrorcontext
@@ -211,26 +117,15 @@ local function processerror(offset)
luaerrorline = luaerrorline,
lastcontext = lastcontext,
lasttexhelp = tex.gethelptext and tex.gethelptext() or nil,
+ endoffile = eof,
}
-end
-
--- so one can overload the printer if (really) needed
-
-if fatalerror then
- callback.register("terminal_input",function(what)
- if what == "*" then
- fatalerror("some kind of input expected, file ends too soon, quitting now")
- else
- fatalerror("bad input, quitting now")
- end
- end)
-else
- -- tex.print("\\nonstopmode")
+ if job and type(job.disablesave) == "function" then
+ job.disablesave()
+ end
end
directives.register("system.quitonerror",function(v)
quitonerror = toboolean(v)
- -- tex.print("\\errorstopmode")
end)
directives.register("system.usescitelexer",function(v)
@@ -251,9 +146,15 @@ function tracers.printerror(specification)
local luaerrorline = specification.luaerrorline
local errortype = specification.errortype
local offset = specification.offset
+ local endoffile = specification.endoffile
local report = errorreporter(luaerrorline)
- if not filename then
- report("error not related to input file:")
+ if endoffile then
+ report("runaway error: %s",lasttexerror or "-")
+ if not quitonerror and texio.terminal then
+ texio.terminal() -- not well tested
+ end
+ elseif not filename then
+ report("fuzzy error:")
report(" tex: %s",lasttexerror or "-")
report(" lua: %s",lastluaerror or "-")
report(" mps: %s",lastmpserror or "-")
@@ -281,6 +182,10 @@ function tracers.printerror(specification)
report_nl()
tex.show_context()
end
+ if lastluaerror and not match(lastluaerror,"^%s*[%?]*%s*$") then
+ print("\nlua error:\n\n",lastluaerror,"\n")
+ quitonerror = true
+ end
end
report_nl()
report_str(tracers.showlines(filename,linenumber,offset,tonumber(luaerrorline)))
@@ -322,9 +227,9 @@ directives.register("system.errorcontext", function(v)
local register = callback.register
if v then
register('show_error_message', nop)
- register('show_warning_message',function() processwarning(v) end)
- register('show_error_hook', function() processerror(v) end)
- register('show_lua_error_hook', function() processerror(v) end)
+ register('show_warning_message',function() processwarning(v) end)
+ register('show_error_hook', function(eof) processerror(v,eof) end)
+ register('show_lua_error_hook', function() processerror(v) end)
else
register('show_error_message', nil)
register('show_error_hook', nil)
@@ -351,15 +256,6 @@ local function reportback(lmxname,default,variables)
end
end
-function lmx.showdebuginfo(lmxname)
- local variables = {
- ['title'] = 'ConTeXt Debug Information',
- ['color-background-one'] = lmx.get('color-background-green'),
- ['color-background-two'] = lmx.get('color-background-blue'),
- }
- reportback(lmxname,"context-debug.lmx",variables)
-end
-
local function showerror(lmxname)
local filename, linenumber, errorcontext = status.filename, tonumber(status.linenumber) or 0, ""
if not filename then
@@ -390,6 +286,7 @@ function lmx.overloaderror(v)
end
callback.register('show_error_hook', function() showerror() end) -- prevents arguments being passed
callback.register('show_lua_error_hook', function() showerror() end) -- prevents arguments being passed
+ callback.register('show_tex_error_hook', function() showerror() end) -- prevents arguments being passed
end
directives.register("system.showerror", lmx.overloaderror)
@@ -429,8 +326,6 @@ directives.register("system.showerror", lmx.overloaderror)
-- end
-- end)
-local implement = interfaces.implement
-
implement { name = "showtrackers", actions = trackers.show }
implement { name = "enabletrackers", actions = trackers.enable, arguments = "string" }
implement { name = "disabletrackers", actions = trackers.disable, arguments = "string" }
@@ -444,7 +339,6 @@ implement { name = "showexperiments", actions = experiments.show }
implement { name = "enableexperiments", actions = experiments.enable, arguments = "string" }
implement { name = "disableexperiments", actions = experiments.disable, arguments = "string" }
-implement { name = "showdebuginfo", actions = lmx.showdebuginfo }
implement { name = "overloaderror", actions = lmx.overloaderror }
implement { name = "showlogcategories", actions = logs.show }
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-deb.mkiv b/Master/texmf-dist/tex/context/base/mkiv/trac-deb.mkiv
index b5366d88c73..fcbacfb9e24 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-deb.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-deb.mkiv
@@ -13,12 +13,10 @@
\writestatus{loading}{ConTeXt Tracing Macros / Debugger}
-\unprotect
-
%registerctxluafile{trac-lmx}{}
-\registerctxluafile{trac-deb}{}
+\registerctxluafile{trac-deb}{autosuffix}
-\unexpanded\def\breakpoint {\showdebuginfo\wait}
+\unprotect
\unexpanded\def\showtrackers {\clf_showtrackers}
\unexpanded\def\enabletrackers [#1]{\clf_enabletrackers{#1}}
@@ -33,7 +31,6 @@
\unexpanded\def\enableexperiments [#1]{\clf_enableexperiments{#1}}
\unexpanded\def\disableexperiments[#1]{\clf_disableexperiments{#1}}
-\unexpanded\def\showdebuginfo {\clf_showdebuginfo}
\unexpanded\def\overloaderror {\clf_overloaderror}
\unexpanded\def\showlogcategories {\clf_showlogcategories}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-inf.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-inf.lua
index 244ba4604a3..e2736cfb6eb 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-inf.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-inf.lua
@@ -129,10 +129,8 @@ local function stoptiming(instance)
timer.loadtime = timer.loadtime + loadtime
timer.timing = 0
timer.starttime = 0
- return loadtime
end
end
- return 0
end
local function benchmarktimer(instance)
@@ -223,21 +221,11 @@ function statistics.show()
return format("%s, type: %s, binary subtree: %s",
os.platform or "unknown",os.type or "unknown", environment.texos or "unknown")
end)
- -- register("luatex banner", function()
- -- return lower(status.banner)
- -- end)
- if LUATEXENGINE == "luametatex" then
- register("used engine", function()
- return format("%s version: %s, functionality level: %s, format id: %s, compiler: %s",
- LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, LUATEXFORMATID, status.used_compiler)
- end)
- else
- register("used engine", function()
- return format("%s version: %s, functionality level: %s, banner: %s",
- LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, lower(status.banner))
- end)
- end
- register("control sequences", function()
+ register("used engine", function()
+ return format("%s version: %s, functionality level: %s, banner: %s",
+ LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, lower(status.banner))
+ end)
+ register("used hash slots", function()
return format("%s of %s + %s", status.cs_count, status.hash_size,status.hash_extra)
end)
register("callbacks", statistics.callbacks)
@@ -251,17 +239,11 @@ function statistics.show()
end
end
-- so far
- -- collectgarbage("collect")
register("lua properties",function()
- local hashchar = tonumber(status.luatex_hashchars)
- local mask = lua.mask or "ascii"
+ local hash = 2^status.luatex_hashchars
+ local mask = load([[τεχ = 1]]) and "utf" or "ascii"
return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
- jit and "luajit" or "lua",
- LUAVERSION,
- statistics.memused(),
- hashchar and 2^hashchar or "unknown",
- mask,
- mask == "utf" and "τεχ" or "tex")
+ jit and "luajit" or "lua", LUAVERSION, statistics.memused(), hash, mask, mask == "utf" and "τεχ" or "tex")
end)
register("runtime",statistics.runtime)
logs.newline() -- initial newline
@@ -328,3 +310,12 @@ function statistics.tracefunction(base,tag,...)
statistics.register(formatters["%s.%s"](tag,name),function() return serialize(stat,"calls") end)
end
end
+
+function status.getreadstate()
+ return {
+ filename = status.filename or "?",
+ linenumber = status.linenumber or 0,
+ iocode = status.inputid or 0,
+ }
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua
index bb154067f70..96b69a73e0f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-log.lua
@@ -8,6 +8,11 @@ if not modules then modules = { } end modules ['trac-log'] = {
-- In fact all writes could go through lua and we could write the console and
-- terminal handler in lua then. Ok, maybe it's slower then, so a no-go.
+--
+-- This is the version for mtxrun. The alternative functions for the TeX engines
+-- have been separated. In order to keep in sync we use tex specific witer names.
+--
+-- Todo: some cleanup (less local needed).
local next, type, select, print = next, type, select, print
local format, gmatch, find = string.format, string.gmatch, string.find
@@ -17,30 +22,16 @@ local utfchar = utf.char
local datetime = os.date
local openfile = io.open
-local runningtex = tex and (tex.jobname or tex.formatname)
--- local write_nl = texio and texio.write_nl or print
--- local write = texio and texio.write or io.write
-
-local write_nl = runningtex and texio and texio.write_nl or print
-local write = runningtex and texio and texio.write or io.write
+local write_nl = print
+local write = io.write
local setmetatableindex = table.setmetatableindex
local formatters = string.formatters
local settings_to_hash = utilities.parsers.settings_to_hash
local sortedkeys = table.sortedkeys
--- variant is set now
-
local variant = "default"
--- local variant = "ansi"
-
--- todo: less categories, more subcategories (e.g. nodes)
--- todo: split into basics and ctx specific
-
---[[ldx--
-
This is a prelude to a more extensive logging module. We no longer
-provide based logging as parsing is relatively easy anyway.
---ldx]]--
+----- variant = "ansi"
logs = logs or { }
local logs = logs
@@ -53,23 +44,6 @@ webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
wiki : http://contextgarden.net
]]
--- -- we extend the formatters:
---
--- function utilities.strings.unichr(s) return "U+" .. format("%05X",s) .. " (" .. utfchar(s) .. ")" end
--- function utilities.strings.chruni(s) return utfchar(s) .. " (U+" .. format("%05X",s) .. ")" end
---
--- utilities.strings.formatters.add (
--- string.formatters, "unichr",
--- [[unichr(%s)]],
--- [[local unichr = utilities.strings.unichr]]
--- )
---
--- utilities.strings.formatters.add (
--- string.formatters, "chruni",
--- [[chruni(%s)]],
--- [[local chruni = utilities.strings.chruni]]
--- )
-
formatters.add (
formatters, "unichr",
[["U+" .. format("%%05X",%s) .. " (" .. utfchar(%s) .. ")"]]
@@ -80,26 +54,6 @@ formatters.add (
[[utfchar(%s) .. " (U+" .. format("%%05X",%s) .. ")"]]
)
--- function utilities.strings.unichk(s) return s <= 0xFFFF and ("U+" .. format("%05X",s) .. " (" .. utfchar(s) .. ")") or ("U+" .. format("%05X",s)) end
--- function utilities.strings.chkuni(s) return s <= 0xFFFF and (utfchar(s) .. " (U+" .. format("%05X",s) .. ")") or ("U+" .. format("%05X",s)) end
---
--- utilities.strings.formatters.add (
--- string.formatters, "unichk",
--- [[unichk(%s)]],
--- [[local unichk = utilities.strings.unichk]]
--- )
---
--- utilities.strings.formatters.add (
--- string.formatters, "chkuni",
--- [[chkuni(%s)]],
--- [[local chkuni = utilities.strings.chkuni]]
--- )
---
--- print(formatters["Missing character %!chruni! in font."](234))
--- print(formatters["Missing character %!unichr! in font."](234))
--- print(formatters["Missing character %!chkuni! in font."](234))
--- print(formatters["Missing character %!unichk! in font."](234))
-
-- basic loggers
local function ignore() end
@@ -124,322 +78,7 @@ local function ansisupported(specification)
end
end
-if runningtex and texio then
-
- if texio.setescape then
- texio.setescape(0) -- or (false)
- end
-
- if arg and ansisupported then
- -- we're don't have environment.arguments yet
- for k, v in next, arg do -- k can be negative !
- if v == "--ansi" or v == "--c:ansi" then
- if ansisupported("ansi") then
- variant = "ansi"
- end
- break
- elseif v == "--ansilog" or v == "--c:ansilog" then
- if ansisupported("ansilog") then
- variant = "ansilog"
- end
- break
- end
- end
- end
-
- local function useluawrites()
-
- -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2)
- -- still needed for luajittex .. luatex should not have that ^^ mess
-
- local texio_write_nl = texio.write_nl
- local texio_write = texio.write
- local io_write = io.write
-
- write_nl = function(target,...)
- if not io_write then
- io_write = io.write
- end
- if target == "term and log" then
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- elseif target == "log" then
- texio_write_nl("log",...)
- elseif target == "term" then
- texio_write_nl("term","")
- io_write(...)
- elseif type(target) == "number" then
- texio_write_nl(target,...) -- a tex output channel
- elseif target ~= "none" then
- texio_write_nl("log",target,...)
- texio_write_nl("term","")
- io_write(target,...)
- end
- end
-
- write = function(target,...)
- if not io_write then
- io_write = io.write
- end
- if target == "term and log" then
- texio_write("log",...)
- io_write(...)
- elseif target == "log" then
- texio_write("log",...)
- elseif target == "term" then
- io_write(...)
- elseif type(target) == "number" then
- texio_write(target,...) -- a tex output channel
- elseif target ~= "none" then
- texio_write("log",target,...)
- io_write(target,...)
- end
- end
-
- texio.write = write
- texio.write_nl = write_nl
-
- useluawrites = ignore
-
- end
-
- -- local format = string.formatter
-
- local whereto = "both"
- local target = nil
- local targets = nil
-
- local formats = table.setmetatableindex("self")
- local translations = table.setmetatableindex("self")
-
- local report_yes, subreport_yes, direct_yes, subdirect_yes, status_yes
- local report_nop, subreport_nop, direct_nop, subdirect_nop, status_nop
-
- local variants = {
- default = {
- formats = {
- report_yes = formatters["%-15s > %s\n"],
- report_nop = formatters["%-15s >\n"],
- direct_yes = formatters["%-15s > %s"],
- direct_nop = formatters["%-15s >"],
- subreport_yes = formatters["%-15s > %s > %s\n"],
- subreport_nop = formatters["%-15s > %s >\n"],
- subdirect_yes = formatters["%-15s > %s > %s"],
- subdirect_nop = formatters["%-15s > %s >"],
- status_yes = formatters["%-15s : %s\n"],
- status_nop = formatters["%-15s :\n"],
- },
- targets = {
- logfile = "log",
- log = "log",
- file = "log",
- console = "term",
- terminal = "term",
- both = "term and log",
- },
- },
- ansi = {
- formats = {
- report_yes = formatters["[0;33m%-15s [0;1m>[0m %s\n"],
- report_nop = formatters["[0;33m%-15s [0;1m>[0m\n"],
- direct_yes = formatters["[0;33m%-15s [0;1m>[0m %s"],
- direct_nop = formatters["[0;33m%-15s [0;1m>[0m"],
- subreport_yes = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m %s\n"],
- subreport_nop = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m\n"],
- subdirect_yes = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m %s"],
- subdirect_nop = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m"],
- status_yes = formatters["[0;33m%-15s [0;1m:[0m %s\n"],
- status_nop = formatters["[0;33m%-15s [0;1m:[0m\n"],
- },
- targets = {
- logfile = "none",
- log = "none",
- file = "none",
- console = "term",
- terminal = "term",
- both = "term",
- },
- }
- }
-
- variants.ansilog = {
- formats = variants.ansi.formats,
- targets = variants.default.targets,
- }
-
- logs.flush = io.flush
-
- writer = function(...)
- write_nl(target,...)
- end
-
- newline = function()
- write_nl(target,"\n")
- end
-
- report = function(a,b,c,...)
- if c ~= nil then
- write_nl(target,report_yes(translations[a],formatters[formats[b]](c,...)))
- elseif b then
- write_nl(target,report_yes(translations[a],formats[b]))
- elseif a then
- write_nl(target,report_nop(translations[a]))
- else
- write_nl(target,"\n")
- end
- end
-
- direct = function(a,b,c,...)
- if c ~= nil then
- return direct_yes(translations[a],formatters[formats[b]](c,...))
- elseif b then
- return direct_yes(translations[a],formats[b])
- elseif a then
- return direct_nop(translations[a])
- else
- return ""
- end
- end
-
- subreport = function(a,s,b,c,...)
- if c ~= nil then
- write_nl(target,subreport_yes(translations[a],translations[s],formatters[formats[b]](c,...)))
- elseif b then
- write_nl(target,subreport_yes(translations[a],translations[s],formats[b]))
- elseif a then
- write_nl(target,subreport_nop(translations[a],translations[s]))
- else
- write_nl(target,"\n")
- end
- end
-
- subdirect = function(a,s,b,c,...)
- if c ~= nil then
- return subdirect_yes(translations[a],translations[s],formatters[formats[b]](c,...))
- elseif b then
- return subdirect_yes(translations[a],translations[s],formats[b])
- elseif a then
- return subdirect_nop(translations[a],translations[s])
- else
- return ""
- end
- end
-
- status = function(a,b,c,...)
- if c ~= nil then
- write_nl(target,status_yes(translations[a],formatters[formats[b]](c,...)))
- elseif b then
- write_nl(target,status_yes(translations[a],formats[b]))
- elseif a then
- write_nl(target,status_nop(translations[a]))
- else
- write_nl(target,"\n")
- end
- end
-
- settarget = function(askedwhereto)
- whereto = askedwhereto or whereto or "both"
- target = targets[whereto]
- if not target then
- whereto = "both"
- target = targets[whereto]
- end
- if target == "term" or target == "term and log" then
- logs.flush = io.flush
- else
- logs.flush = ignore
- end
- end
-
- local stack = { }
-
- pushtarget = function(newtarget)
- insert(stack,target)
- settarget(newtarget)
- end
-
- poptarget = function()
- if #stack > 0 then
- settarget(remove(stack))
- end
- end
-
- setformats = function(f)
- formats = f
- end
-
- settranslations = function(t)
- translations = t
- end
-
- setprocessor = function(f)
- local writeline = write_nl
- write_nl = function(target,...)
- writeline(target,f(...))
- end
- end
-
- setformatters = function(specification)
- local t = nil
- local f = nil
- local d = variants.default
- if not specification then
- --
- elseif type(specification) == "table" then
- t = specification.targets
- f = specification.formats or specification
- else
- if not ansisupported(specification) then
- specification = "default"
- end
- local v = variants[specification]
- if v then
- t = v.targets
- f = v.formats
- variant = specification
- end
- end
- targets = t or d.targets
- target = targets[whereto] or target
- if f then
- d = d.formats
- else
- f = d.formats
- d = f
- end
- setmetatableindex(f,d)
- report_yes = f.report_yes
- report_nop = f.report_nop
- subreport_yes = f.subreport_yes
- subreport_nop = f.subreport_nop
- direct_yes = f.direct_yes
- direct_nop = f.direct_nop
- subdirect_yes = f.subdirect_yes
- subdirect_nop = f.subdirect_nop
- status_yes = f.status_yes
- status_nop = f.status_nop
- if variant == "ansi" or variant == "ansilog" then
- useluawrites() -- because tex escapes ^^, not needed in lmtx
- end
- settarget(whereto)
- end
-
- setformatters(variant)
-
- setlogfile = ignore
- settimedlog = ignore
-
- -- settimedlog = function()
- -- local localtime = os.localtime
- -- local writeline = write_nl
- -- write_nl = function(f,...)
- -- writeline(f,localtime() .. " | " .. concat { ... })
- -- end
- -- settimedlog = ignore
- -- end
-
-else
+do
local report_yes, subreport_yes, status_yes
local report_nop, subreport_nop, status_nop
@@ -788,56 +427,6 @@ directives.register("logs.target", function(v)
settarget(v)
end)
--- tex specific loggers (might move elsewhere)
-
-if tex then
-
- local report = logs.reporter("pages") -- not needed but saves checking when we grep for it
- local texgetcount = tex and tex.getcount
-
- local real, user, sub = 0, 0, 0
-
- function logs.start_page_number()
- real = texgetcount("realpageno")
- user = texgetcount("userpageno")
- sub = texgetcount("subpageno")
- end
-
- local timing = false
- local lasttime = nil
-
- trackers.register("pages.timing", function(v) -- only for myself (diagnostics)
- timing = ""
- end)
-
- function logs.stop_page_number() -- the first page can includes the initialization so we omit this in average
- if timing then
- local elapsed = statistics.currenttime(statistics)
- local average, page
- if not lasttime or real < 2 then
- average = elapsed
- page = elapsed
- else
- average = elapsed / (real - 1)
- page = elapsed - lasttime
- end
- lasttime = elapsed
- timing = formatters[", total %0.03f, page %0.03f, average %0.03f"](elapsed,page,average)
- end
- if real <= 0 then
- report("flushing page%s",timing)
- elseif user <= 0 then
- report("flushing realpage %s%s",real,timing)
- elseif sub <= 0 then
- report("flushing realpage %s, userpage %s%s",real,user,timing)
- else
- report("flushing realpage %s, userpage %s, subpage %s%s",real,user,sub,timing)
- end
- logs.flush()
- end
-
-end
-
-- we don't have show_open and show_close callbacks yet
----- report_files = logs.reporter("files")
@@ -864,14 +453,6 @@ logs.help = ignore -- obsolete
-- applications
--- local function reportlines(t,str)
--- if str then
--- for line in gmatch(str,"([^\n\r]*)[\n\r]") do
--- t.report(line)
--- end
--- end
--- end
-
local Carg, C, lpegmatch = lpeg.Carg, lpeg.C, lpeg.match
local p_newline = lpeg.patterns.newline
@@ -926,12 +507,12 @@ local function reportexport(t,method)
end
local reporters = {
- lines = reportlines, -- not to be overloaded
- banner = reportbanner,
- version = reportversion,
- help = reporthelp,
- info = reportinfo,
- export = reportexport,
+ lines = reportlines, -- not to be overloaded
+ banner = reportbanner,
+ version = reportversion,
+ help = reporthelp,
+ info = reportinfo,
+ export = reportexport,
}
local exporters = {
@@ -1000,47 +581,10 @@ end
local report_system = logs.reporter("system","logs")
-function logs.obsolete(old,new)
- local o = loadstring("return " .. new)()
- if type(o) == "function" then
- return function(...)
- report_system("function %a is obsolete, use %a",old,new)
- loadstring(old .. "=" .. new .. " return ".. old)()(...)
- end
- elseif type(o) == "table" then
- local t, m = { }, { }
- m.__index = function(t,k)
- report_system("table %a is obsolete, use %a",old,new)
- m.__index, m.__newindex = o, o
- return o[k]
- end
- m.__newindex = function(t,k,v)
- report_system("table %a is obsolete, use %a",old,new)
- m.__index, m.__newindex = o, o
- o[k] = v
- end
- if libraries then
- libraries.obsolete[old] = t -- true
- end
- setmetatable(t,m)
- return t
- end
-end
-
if utilities then
utilities.report = report_system
end
-if tex and tex.error then
- function logs.texerrormessage(...) -- for the moment we put this function here
- tex.error(format(...))
- end
-else
- function logs.texerrormessage(...)
- print(format(...))
- end
-end
-
-- this is somewhat slower but prevents out-of-order messages when print is mixed
-- with texio.write
@@ -1053,104 +597,3 @@ end
if package.helpers.report then
package.helpers.report = logs.reporter("package loader") -- when used outside mtxrun
end
-
-if tex then
-
- local finalactions = { }
- local fatalerrors = { }
- local possiblefatal = { }
- local loggingerrors = false
-
- function logs.loggingerrors()
- return loggingerrors
- end
-
- directives.register("logs.errors",function(v)
- loggingerrors = v
- if type(v) == "string" then
- fatalerrors = settings_to_hash(v)
- else
- fatalerrors = { }
- end
- end)
-
- function logs.registerfinalactions(...)
- insert(finalactions,...) -- so we can force an order if needed
- end
-
- local what = nil
- local report = nil
- local state = nil
- local target = nil
-
- local function startlogging(t,r,w,s)
- target = t
- state = force
- force = true
- report = type(r) == "function" and r or logs.reporter(r)
- what = w
- pushtarget(target)
- newline()
- if s then
- report("start %s: %s",what,s)
- else
- report("start %s",what)
- end
- if target == "logfile" then
- newline()
- end
- return report
- end
-
- local function stoplogging()
- if target == "logfile" then
- newline()
- end
- report("stop %s",what)
- if target == "logfile" then
- newline()
- end
- poptarget()
- state = oldstate
- end
-
- function logs.startfilelogging(...)
- return startlogging("logfile", ...)
- end
-
- logs.stopfilelogging = stoplogging
-
- local done = false
-
- function logs.starterrorlogging(r,w,...)
- if not done then
- pushtarget("terminal")
- newline()
- logs.report("error logging","start possible issues")
- poptarget()
- done = true
- end
- if fatalerrors[w] then
- possiblefatal[w] = true
- end
- return startlogging("terminal",r,w,...)
- end
-
- logs.stoperrorlogging = stoplogging
-
- function logs.finalactions()
- if #finalactions > 0 then
- for i=1,#finalactions do
- finalactions[i]()
- end
- if done then
- pushtarget("terminal")
- newline()
- logs.report("error logging","stop possible issues")
- poptarget()
- end
- return next(possiblefatal) and sortedkeys(possiblefatal) or false
- end
- end
-
-end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-set.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-set.lua
index 960c4ef84a6..3974830fab0 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-set.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-set.lua
@@ -33,7 +33,7 @@ local data = { }
local trace_initialize = false -- only for testing during development
local frozen = true -- this needs checking
-function setters.initialize(filename,name,values) -- filename only for diagnostics
+local function initialize_setter(filename,name,values) -- filename only for diagnostics
local setter = data[name]
if setter then
-- trace_initialize = true
@@ -81,8 +81,8 @@ end
-- user interface code
local function set(t,what,newvalue)
- local data = t.data
- if not data.frozen then
+ local data = t.data -- somehow this can be nil
+ if data and not data.frozen then
local done = t.done
if type(what) == "string" then
what = settings_to_hash(what) -- inefficient but ok
@@ -120,7 +120,7 @@ end
local function reset(t)
local data = t.data
- if not data.frozen then
+ if data and not data.frozen then
for name, functions in sortedthash(data) do
for i=1,#functions do
functions[i](false)
@@ -144,7 +144,7 @@ local function disable(t,what)
end
end
-function setters.register(t,what,...)
+local function register_setter(t,what,...)
local data = t.data
what = lower(what)
local functions = data[what]
@@ -182,26 +182,27 @@ function setters.register(t,what,...)
return false -- so we can use it in an assignment
end
-function setters.enable(t,what)
+local function enable_setter(t,what)
local e = t.enable
t.enable, t.done = enable, { }
+ set(t,what,true)
enable(t,what)
t.enable, t.done = e, { }
end
-function setters.disable(t,what)
+local function disable_setter(t,what)
local e = t.disable
t.disable, t.done = disable, { }
disable(t,what)
t.disable, t.done = e, { }
end
-function setters.reset(t)
+local function reset_setter(t)
t.done = { }
reset(t)
end
-function setters.list(t) -- pattern
+local function list_setter(t) -- pattern
local list = table.sortedkeys(t.data)
local user, system = { }, { }
for l=1,#list do
@@ -215,8 +216,8 @@ function setters.list(t) -- pattern
return user, system
end
-function setters.show(t)
- local list = setters.list(t)
+local function show_setter(t)
+ local list = list_setter(t)
t.report()
for k=1,#list do
local name = list[k]
@@ -253,44 +254,56 @@ end
-- we could make this into a module but we also want the rest avaliable
-local enable, disable, register, list, show = setters.enable, setters.disable, setters.register, setters.list, setters.show
-
function setters.report(setter,fmt,...)
- print(formatters["%-15s : %s\n"](setter.name,formatters[fmt](...)))
+ if fmt then
+ print(formatters["%-15s : %s"](setter.name,formatters[fmt](...)))
+ else
+ print("")
+ end
end
-local function default(setter,name)
+local function setter_default(setter,name)
local d = setter.data[name]
return d and d.default
end
-local function value(setter,name)
+local function setter_value(setter,name)
local d = setter.data[name]
return d and (d.value or d.default)
end
-function setters.new(name) -- we could use foo:bar syntax (but not used that often)
+local function new_setter(name) -- we could use foo:bar syntax (but not used that often)
local setter -- we need to access it in setter itself
setter = {
data = allocate(), -- indexed, but also default and value fields
name = name,
- report = function(...) setters.report (setter,...) end,
- enable = function(...) enable (setter,...) end,
- disable = function(...) disable (setter,...) end,
- reset = function(...) reset (setter,...) end, -- can be dangerous
- register = function(...) register(setter,...) end,
- list = function(...) return list (setter,...) end,
- show = function(...) show (setter,...) end,
- default = function(...) return default (setter,...) end,
- value = function(...) return value (setter,...) end,
+ report = function(...) setters.report (setter,...) end, -- setters.report gets implemented later
+ enable = function(...) enable_setter (setter,...) end,
+ disable = function(...) disable_setter (setter,...) end,
+ reset = function(...) reset_setter (setter,...) end, -- can be dangerous
+ register = function(...) register_setter(setter,...) end,
+ list = function(...) return list_setter (setter,...) end,
+ show = function(...) show_setter (setter,...) end,
+ default = function(...) return setter_default (setter,...) end,
+ value = function(...) return setter_value (setter,...) end,
}
data[name] = setter
return setter
end
-trackers = setters.new("trackers")
-directives = setters.new("directives")
-experiments = setters.new("experiments")
+setters.enable = enable_setter
+setters.disable = disable_setter
+-------.report = report_setter -- todo: adapt after call (defaults to print)
+setters.register = register_setter
+setters.list = list_setter
+setters.show = show_setter
+setters.reset = reset_setter
+setters.new = new_setter
+setters.initialize = initialize_setter
+
+trackers = new_setter("trackers")
+directives = new_setter("directives")
+experiments = new_setter("experiments")
local t_enable, t_disable = trackers .enable, trackers .disable
local d_enable, d_disable = directives .enable, directives .disable
@@ -361,12 +374,12 @@ if environment then
if engineflags then
local list = engineflags["c:trackers"] or engineflags["trackers"]
if type(list) == "string" then
- setters.initialize("commandline flags","trackers",settings_to_hash(list))
+ initialize_setter("commandline flags","trackers",settings_to_hash(list))
-- t_enable(list)
end
local list = engineflags["c:directives"] or engineflags["directives"]
if type(list) == "string" then
- setters.initialize("commandline flags","directives", settings_to_hash(list))
+ initialize_setter("commandline flags","directives", settings_to_hash(list))
-- d_enable(list)
end
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-vis.lua b/Master/texmf-dist/tex/context/base/mkiv/trac-vis.lua
index 0ca50899bf6..fb5ef98d939 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-vis.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-vis.lua
@@ -1,12 +1,13 @@
if not modules then modules = { } end modules ['trac-vis'] = {
version = 1.001,
+ optimize = true,
comment = "companion to trac-vis.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
-local node, nodes, attributes, fonts, tex = node, nodes, attributes, fonts, tex
+local node, nodes, attributes, tex = node, nodes, attributes, tex
local type, tonumber, next, rawget = type, tonumber, next, rawget
local gmatch = string.gmatch
local formatters = string.formatters
@@ -27,14 +28,13 @@ local round = math.round
-- todo: maybe also xoffset, yoffset of glyph
-- todo: inline concat (more efficient)
-- todo: tags can also be numbers (just add to hash)
+-- todo: make a lmtx variant (a few more efficient fetchers)
local nodecodes = nodes.nodecodes
local nuts = nodes.nuts
local tonut = nuts.tonut
-local tonode = nuts.tonode
------ setfield = nuts.setfield
local setboth = nuts.setboth
local setlink = nuts.setlink
local setdisc = nuts.setdisc
@@ -63,6 +63,8 @@ local getwidth = nuts.getwidth
local getdepth = nuts.getdepth
local getshift = nuts.getshift
local getexpansion = nuts.getexpansion
+local getdirection = nuts.getdirection
+local getstate = nuts.getstate
local isglyph = nuts.isglyph
@@ -77,8 +79,6 @@ local apply_to_nodes = nuts.apply
local find_tail = nuts.tail
local effectiveglue = nuts.effective_glue
-local nextnode = nuts.traversers.node
-
local hpack_string = nuts.typesetters.tohpack
local texgetattribute = tex.getattribute
@@ -166,10 +166,14 @@ local modes = {
space = 0x040000,
depth = 0x080000,
marginkern = 0x100000,
+ mathlistkern = 0x200000,
+ dir = 0x400000,
+ par = 0x800000,
}
local usedfont, exheight, emwidth
-local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth
+local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_mathlistkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth,
+ l_dir, l_whatsit
local enabled = false
local layers = { }
@@ -178,7 +182,9 @@ local preset_boxes = modes.hbox + modes.vbox + modes.origin
local preset_makeup = preset_boxes
+ modes.kern + modes.glue + modes.penalty
local preset_all = preset_makeup
- + modes.fontkern + modes.marginkern + modes.whatsit + modes.glyph + modes.user + modes.math
+ + modes.fontkern + modes.marginkern + modes.mathlistkern
+ + modes.whatsit + modes.glyph + modes.user + modes.math
+ + modes.dir + modes.whatsit
function visualizers.setfont(id)
usedfont = id or current_font()
@@ -223,12 +229,15 @@ local function initialize()
l_math = layers.math
l_italic = layers.italic
l_marginkern = layers.marginkern
+ l_mathlistkern = layers.mathlistkern
l_origin = layers.origin
l_discretionary = layers.discretionary
l_expansion = layers.expansion
l_line = layers.line
l_space = layers.space
l_depth = layers.depth
+ l_dir = layers.dir
+ l_par = layers.par
--
if not userrule then
userrule = nuts.rules.userrule
@@ -366,10 +375,6 @@ for mode, value in next, modes do
trackers.register(formatters["visualizers.%s"](mode), function(v) set(mode,v) end)
end
-local raisepenalties = false
-
-directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end)
-
local fraction = 10
trackers .register("visualizers.reset", function(v) set("reset", v) end)
@@ -389,10 +394,10 @@ local c_skip_b = "trace:m"
local c_glyph = "trace:o"
local c_ligature = "trace:s"
local c_white = "trace:w"
-local c_math = "trace:s"
-local c_origin = "trace:o"
-local c_discretionary = "trace:d"
-local c_expansion = "trace:o"
+----- c_math = "trace:s"
+----- c_origin = "trace:o"
+----- c_discretionary = "trace:d"
+----- c_expansion = "trace:o"
local c_depth = "trace:o"
local c_indent = "trace:s"
@@ -410,8 +415,9 @@ local c_white_d = "trace:dw"
local c_math_d = "trace:dr"
local c_origin_d = "trace:do"
local c_discretionary_d = "trace:dd"
-local c_expansion_d = "trace:do"
-local c_depth_d = "trace:do"
+----- c_expansion_d = "trace:do"
+----- c_depth_d = "trace:do"
+----- c_indent_d = "trace:ds"
local function sometext(str,layer,color,textcolor,lap) -- we can just paste verbatim together .. no typesteting needed
local text = hpack_string(str,usedfont)
@@ -463,11 +469,12 @@ end
local caches = setmetatableindex("table")
-local fontkern, italickern, marginkern do
+local fontkern, italickern, marginkern, mathlistkern do
local f_cache = caches["fontkern"]
local i_cache = caches["italickern"]
local m_cache = caches["marginkern"]
+ local l_cache = caches["mathlistkern"]
local function somekern(head,current,cache,color,layer)
local width = getkern(current)
@@ -509,6 +516,10 @@ local fontkern, italickern, marginkern do
return somekern(head,current,m_cache,c_glyph_d,l_marginkern)
end
+ mathlistkern = function(head,current)
+ return somekern(head,current,l_cache,c_glyph_d,l_mathlistkern)
+ end
+
end
local glyphexpansion do
@@ -549,6 +560,8 @@ local kernexpansion do
local f_cache = caches["kernexpansion"]
+ -- in mkiv we actually need to reconstruct but let's not do that now
+
kernexpansion = function(head,current)
local extra = getexpansion(current)
if extra ~= 0 then
@@ -604,9 +617,7 @@ local whatsit do
if info then
-- print("hit whatsit")
else
- local tag = whatsitcodes[what]
- -- maybe different text colors per tag
- info = sometext(formatters["W:%s"](tag and tags[tag] or what),usedfont,nil,c_white)
+ info = sometext(formatters["W:%s"](what),usedfont,nil,c_white)
setattr(info,a_layer,l_whatsit)
w_cache[what] = info
end
@@ -616,6 +627,59 @@ local whatsit do
end
+local dir, par do
+
+ local dircodes = nodes.dircodes
+ local dirvalues = nodes.dirvalues
+
+ local cancel_code = dircodes.cancel
+ local l2r_code = dirvalues.l2r
+ local r2l_code = dirvalues.r2l
+
+ local d_cache = caches["dir"]
+
+ local tags = {
+ l2r = "L2R",
+ r2l = "R2L",
+ cancel = "CAN",
+ par = "PAR",
+ }
+
+ par = function(head,current)
+ local what = "par" -- getsubtype(current)
+ local info = d_cache[what]
+ if info then
+ -- print("hit par")
+ else
+ info = sometext(formatters["L:%s"](what),usedfont,nil,c_white)
+ setattr(info,a_layer,l_dir)
+ d_cache[what] = info
+ end
+ return head, current
+ end
+
+ dir = function(head,current)
+ local what = getsubtype(current)
+ if what == cancelcode then
+ what = "cancel"
+ elseif getdirection(current) == r2l_code then
+ what = "r2l"
+ else
+ what = "l2r"
+ end
+ local info = d_cache[what]
+ if info then
+ -- print("hit dir")
+ else
+ info = sometext(formatters["D:%s"](what),usedfont,nil,c_white)
+ setattr(info,a_layer,l_dir)
+ d_cache[what] = info
+ end
+ return head, current
+ end
+
+end
+
local user do
local u_cache = caches["user"]
@@ -865,26 +929,26 @@ end
local ruledglue do
- local gluecodes = nodes.gluecodes
- local leadercodes = nodes.gluecodes
+ local gluecodes = nodes.gluecodes
- local userskip_code = gluecodes.userskip
- local spaceskip_code = gluecodes.spaceskip
- local xspaceskip_code = gluecodes.xspaceskip
- local leftskip_code = gluecodes.leftskip
- local rightskip_code = gluecodes.rightskip
- local parfillskip_code = gluecodes.parfillskip
- local indentskip_code = gluecodes.indentskip
- local correctionskip_code = gluecodes.correctionskip
-
- local cleaders_code = leadercodes.cleaders
+ local userskip_code = gluecodes.userskip
+ local spaceskip_code = gluecodes.spaceskip
+ local xspaceskip_code = gluecodes.xspaceskip
+ local zerospaceskip_code = gluecodes.zerospaceskip or gluecodes.userskip
+ -- local keepskip_code = gluecodes.keepskip or gluecodes.userskip
+ local leftskip_code = gluecodes.leftskip
+ local rightskip_code = gluecodes.rightskip
+ local parfillleftskip_code = gluecodes.parfillleftskip or parfillskip_code
+ local parfillrightskip_code = gluecodes.parfillrightskip or parfillskip_code
+ local indentskip_code = gluecodes.indentskip
+ local correctionskip_code = gluecodes.correctionskip
local g_cache_v = caches["vglue"]
local g_cache_h = caches["hglue"]
local tags = {
-- [userskip_code] = "US",
- [gluecodes.lineskip] = "LS",
+ [gluecodes.lineskip] = "LI",
[gluecodes.baselineskip] = "BS",
[gluecodes.parskip] = "PS",
[gluecodes.abovedisplayskip] = "DA",
@@ -900,18 +964,21 @@ local ruledglue do
[gluecodes.medmuskip] = "MM",
[gluecodes.thickmuskip] = "ML",
[gluecodes.intermathskip] = "IM",
+ [gluecodes.keepskip or 99] = "KS",
[gluecodes.mathskip] = "MT",
- [leadercodes.leaders] = "NL",
- [leadercodes.cleaders] = "CL",
- [leadercodes.xleaders] = "XL",
- [leadercodes.gleaders] = "GL",
+ [gluecodes.leaders] = "NL",
+ [gluecodes.cleaders] = "CL",
+ [gluecodes.xleaders] = "XL",
+ [gluecodes.gleaders] = "GL",
-- true = "VS",
-- false = "HS",
[leftskip_code] = "LS",
[rightskip_code] = "RS",
[spaceskip_code] = "SP",
[xspaceskip_code] = "XS",
- [parfillskip_code] = "PF",
+ [zerospaceskip_code] = "ZS",
+ [parfillleftskip_code] = "PL",
+ [parfillrightskip_code] = "PR",
[indentskip_code] = "IN",
[correctionskip_code] = "CS",
}
@@ -926,11 +993,11 @@ local ruledglue do
if info then
-- print("glue hit")
else
- if subtype == spaceskip_code or subtype == xspaceskip_code then
+ if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then
info = sometext(amount,l_glue,c_space)
elseif subtype == leftskip_code or subtype == rightskip_code then
info = sometext(amount,l_glue,c_skip_a)
- elseif subtype == parfillskip_code or subtype == indentskip_code or subtype == correctionskip_code then
+ elseif subtype == parfillleftskip_code or subtype == parfillrightskip_code or subtype == indentskip_code or subtype == correctionskip_code then
info = sometext(amount,l_glue,c_indent)
elseif subtype == userskip_code then
if width > 0 then
@@ -955,7 +1022,7 @@ local ruledglue do
-- ruledspace = function(head,current,parent)
-- local subtype = getsubtype(current)
- -- if subtype == spaceskip_code or subtype == xspaceskip_code then
+ -- if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then
-- local width = effectiveglue(current,parent)
-- local amount = formatters["%s:%0.3f"](tags[subtype] or "HS",width*pt_factor)
-- local info = g_cache_h[amount]
@@ -978,7 +1045,7 @@ local ruledglue do
ruledspace = function(head,current,parent)
local subtype = getsubtype(current)
- if subtype == spaceskip_code or subtype == xspaceskip_code then -- not yet all space
+ if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then -- not yet all space
local width = effectiveglue(current,parent)
local info
if subtype == spaceskip_code then
@@ -1084,6 +1151,31 @@ local ruledmarginkern do
end
+local ruledmathlistkern do
+
+ local l_cache = caches["mathlistkern"]
+
+ ruledmathlistkern = function(head,current)
+ local kern = getkern(current)
+ local info = l_cache[kern]
+ if not info then
+ local amount = formatters["%s:%0.3f"]("LK",kern*pt_factor)
+ if kern > 0 then
+ info = sometext(amount,l_mathlistkern,c_positive)
+ elseif kern < 0 then
+ info = sometext(amount,l_mathlistkern,c_negative)
+ else
+ info = sometext(amount,l_mathlistkern,c_zero)
+ end
+ l_cache[kern] = info
+ end
+ info = copy_list(info)
+ head, current = insert_node_before(head,current,info)
+ return head, getnext(current)
+ end
+
+end
+
local ruleddiscretionary do
local d_cache = caches["discretionary"]
@@ -1111,6 +1203,10 @@ local ruledpenalty do
local p_cache_v = caches["vpenalty"]
local p_cache_h = caches["hpenalty"]
+ local raisepenalties = false
+
+ directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end)
+
ruledpenalty = function(head,current,vertical)
local penalty = getpenalty(current)
local info = (vertical and p_cache_v or p_cache_h)[penalty]
@@ -1141,27 +1237,31 @@ end
do
- local disc_code = nodecodes.disc
- local kern_code = nodecodes.kern
- local glyph_code = nodecodes.glyph
- local glue_code = nodecodes.glue
- local penalty_code = nodecodes.penalty
- local whatsit_code = nodecodes.whatsit
- local user_code = nodecodes.user
- local math_code = nodecodes.math
- local hlist_code = nodecodes.hlist
- local vlist_code = nodecodes.vlist
- local marginkern_code = nodecodes.marginkern
+ local disc_code = nodecodes.disc
+ local kern_code = nodecodes.kern
+ local glyph_code = nodecodes.glyph
+ local glue_code = nodecodes.glue
+ local penalty_code = nodecodes.penalty
+ local whatsit_code = nodecodes.whatsit
+ local user_code = nodecodes.user
+ local math_code = nodecodes.math
+ local hlist_code = nodecodes.hlist
+ local vlist_code = nodecodes.vlist
+ local marginkern_code = nodecodes.marginkern
+ local mathlistkern_code = nodecodes.mathlistkern
+ local dir_code = nodecodes.dir
+ local par_code = nodecodes.par
local kerncodes = nodes.kerncodes
local fontkern_code = kerncodes.fontkern
local italickern_code = kerncodes.italiccorrection
local leftmarginkern_code = kerncodes.leftmarginkern
local rightmarginkern_code = kerncodes.rightmarginkern
+ local mathlistkern_code = kerncodes.mathlistkern
----- userkern_code = kerncodes.userkern
- local listcodes = nodes.listcodes
- local linelist_code = listcodes.line
+ local listcodes = nodes.listcodes
+ local linelist_code = listcodes.line
local cache
@@ -1186,73 +1286,27 @@ do
local trace_line = false
local trace_space = false
local trace_depth = false
+ local trace_dir = false
+ local trace_par = false
local current = head
local previous = nil
local attr = unsetvalue
local prev_trace_fontkern = nil
- local prev_trace_marginkern = nil
local prev_trace_italic = nil
+ local prev_trace_marginkern = nil
+-- local prev_trace_mathlist = nil
local prev_trace_expansion = nil
- -- local function setthem(t,k)
- -- local v_trace_hbox = band(k, 1) ~= 0
- -- local v_trace_vbox = band(k, 2) ~= 0
- -- local v_trace_vtop = band(k, 4) ~= 0
- -- local v_trace_kern = band(k, 8) ~= 0
- -- local v_trace_glue = band(k, 16) ~= 0
- -- local v_trace_penalty = band(k, 32) ~= 0
- -- local v_trace_fontkern = band(k, 64) ~= 0
- -- local v_trace_strut = band(k, 128) ~= 0
- -- local v_trace_whatsit = band(k, 256) ~= 0
- -- local v_trace_glyph = band(k, 512) ~= 0
- -- local v_trace_simple = band(k, 1024) ~= 0
- -- local v_trace_user = band(k, 2048) ~= 0
- -- local v_trace_math = band(k, 4096) ~= 0
- -- local v_trace_italic = band(k, 8192) ~= 0
- -- local v_trace_origin = band(k, 16384) ~= 0
- -- local v_trace_discretionary = band(k, 32768) ~= 0
- -- local v_trace_expansion = band(k, 65536) ~= 0
- -- local v_trace_line = band(k,131072) ~= 0
- -- local v_trace_space = band(k,262144) ~= 0
- -- local v_trace_depth = band(k,524288) ~= 0
- -- local v = function()
- -- trace_hbox = v_trace_hbox
- -- trace_vbox = v_trace_vbox
- -- trace_vtop = v_trace_vtop
- -- trace_kern = v_trace_kern
- -- trace_glue = v_trace_glue
- -- trace_penalty = v_trace_penalty
- -- trace_fontkern = v_trace_fontkern
- -- trace_strut = v_trace_strut
- -- trace_whatsit = v_trace_whatsit
- -- trace_glyph = v_trace_glyph
- -- trace_simple = v_trace_simple
- -- trace_user = v_trace_user
- -- trace_math = v_trace_math
- -- trace_italic = v_trace_italic
- -- trace_origin = v_trace_origin
- -- trace_discretionary = v_trace_discretionary
- -- trace_expansion = v_trace_expansion
- -- trace_line = v_trace_line
- -- trace_space = v_trace_space
- -- trace_depth = v_trace_depth
- -- end
- -- t[k] = v
- -- return v
- -- end
- --
- -- if not cache then
- -- cache = setmetatableindex(setthem)
- -- end
-
while current do
local id = getid(current)
local a = forced or getattr(current,a_visual) or unsetvalue
+ local subtype
if a ~= attr then
- prev_trace_fontkern = trace_fontkern
- prev_trace_italic = trace_italic
- prev_trace_marginkern = trace_marginkern
- prev_trace_expansion = trace_expansion
+ prev_trace_fontkern = trace_fontkern
+ prev_trace_italic = trace_italic
+ prev_trace_marginkern = trace_marginkern
+-- prev_trace_mathlistkern = trace_mathlistkern
+ prev_trace_expansion = trace_expansion
attr = a
if a == unsetvalue then
trace_hbox = false
@@ -1276,7 +1330,14 @@ do
trace_space = false
trace_depth = false
trace_marginkern = false
- goto list
+ trace_mathlistkern = false
+ trace_dir = false
+ trace_par = false
+ if id == kern_code then
+ goto kern
+ else
+ goto list
+ end
else -- dead slow:
-- cache[a]()
trace_hbox = band(a,0x000001) ~= 0
@@ -1300,6 +1361,9 @@ do
trace_space = band(a,0x040000) ~= 0
trace_depth = band(a,0x080000) ~= 0
trace_marginkern = band(a,0x100000) ~= 0
+ trace_mathlistkern = band(a,0x200000) ~= 0
+ trace_dir = band(a,0x400000) ~= 0
+ trace_whatsit = band(a,0x800000) ~= 0
end
elseif a == unsetvalue then
goto list
@@ -1329,31 +1393,7 @@ do
end
setdisc(current,pre,post,replace)
elseif id == kern_code then
- local subtype = getsubtype(current)
- if subtype == fontkern_code then
- if trace_fontkern or prev_trace_fontkern then
- head, current = fontkern(head,current)
- end
- if trace_expansion or prev_trace_expansion then
- head, current = kernexpansion(head,current)
- end
- elseif subtype == italickern_code then
- if trace_italic or prev_trace_italic then
- head, current = italickern(head,current)
- elseif trace_kern then
- head, current = ruleditalic(head,current)
- end
- elseif subtype == leftmarginkern_code or subtype == rightmarginkern_code then
- if trace_marginkern or prev_trace_marginkern then
- head, current = marginkern(head,current)
- elseif trace_kern then
- head, current = ruledmarginkern(head,current)
- end
- else
- if trace_kern then
- head, current = ruledkern(head,current,vertical)
- end
- end
+ goto kern
elseif id == glue_code then
local content = getleader(current)
if content then
@@ -1385,8 +1425,49 @@ do
if trace_kern then
head, current = ruledkern(head,current,vertical,true)
end
+ elseif id == dir_code then
+ if trace_dir then
+ head, current = dir(head,current)
+ end
+ elseif id == par_code then
+ if trace_par then
+ head, current = par(head,current)
+ end
end
goto next
+ ::kern::
+ subtype = getsubtype(current)
+ if subtype == fontkern_code then
+ if trace_fontkern or prev_trace_fontkern then
+ head, current = fontkern(head,current)
+ end
+ if trace_expansion or prev_trace_expansion then
+ head, current = kernexpansion(head,current)
+ end
+ elseif subtype == italickern_code then
+ if trace_italic or prev_trace_italic then
+ head, current = italickern(head,current)
+ elseif trace_kern then
+ head, current = ruleditalic(head,current)
+ end
+ elseif subtype == leftmarginkern_code or subtype == rightmarginkern_code then
+ if trace_marginkern or prev_trace_marginkern then
+ head, current = marginkern(head,current)
+ elseif trace_kern then
+ head, current = ruledmarginkern(head,current)
+ end
+ elseif subtype == mathlistkern_code then
+ if trace_mathlist then -- or prev_trace_mathlist then
+ head, current = mathlistkern(head,current)
+ elseif trace_kern then
+ head, current = ruledmathlistkern(head,current)
+ end
+ else
+ if trace_kern then
+ head, current = ruledkern(head,current,vertical)
+ end
+ end
+ goto next;
::list::
if id == hlist_code then
local content = getlist(current)
@@ -1430,7 +1511,9 @@ do
end
end
- local function handler(head)
+ luatex.registerstopactions(cleanup)
+
+ function visualizers.handler(head)
if usedfont then
starttiming(visualizers)
head = visualize(head,true)
@@ -1441,10 +1524,6 @@ do
end
end
- visualizers.handler = handler
-
- luatex.registerstopactions(cleanup)
-
function visualizers.box(n)
if usedfont then
starttiming(visualizers)
@@ -1465,6 +1544,7 @@ do
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
+ local nextnode = nuts.traversers.node
local last = nil
local used = nil
diff --git a/Master/texmf-dist/tex/context/base/mkiv/trac-vis.mkiv b/Master/texmf-dist/tex/context/base/mkiv/trac-vis.mkiv
index 570e6a7c730..5357c841470 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/trac-vis.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/trac-vis.mkiv
@@ -44,15 +44,16 @@
% no, but can become an option:
%
% \appendtoks
-% \attribute\visualattribute\attributeunsetvalue
+% \c_attr_visual\attributeunsetvalue
% \to \everybeforepagebody
%D We only provide box visualizers as they can come in handy for testing
%D macros. In due time we will move some of the m-visual code here too.
-\let\syst_visualizers_hbox\hbox
-\let\syst_visualizers_vbox\vbox
-\let\syst_visualizers_vtop\vtop
+\let\syst_visualizers_hbox \hbox
+\let\syst_visualizers_vbox \vbox
+\let\syst_visualizers_vtop \vtop
+\let\syst_visualizers_vcenter\vcenter
\let\syst_visualizers_hpack\hpack
\let\syst_visualizers_vpack\vpack
@@ -69,6 +70,19 @@
\unexpanded\def\ruledmbox#1{\ruledhbox{\startimath#1\stopimath}}
+\unexpanded\def\sys_ruled_vcenter{\syst_visualizers_vcenter attr \visualattribute \clf_getvisual {simplevbox}}
+
+\unexpanded\def\ruledvcenter
+ {\ruledvbox\bgroup
+ \dowithnextboxcs\syst_boxes_ruled_vcenter_finish\ruledvbox}
+
+\def\syst_boxes_ruled_vcenter_finish
+ {\ruledhpack{\normalstartimath\ruledvcenter{\box\nextbox}\normalstopimath}%
+ \egroup}
+
+\prependtoks \let\ruledvcenter\sys_ruled_vcenter \to \everymath
+\prependtoks \let\ruledvcenter\sys_ruled_vcenter \to \everydisplay
+
\appendtoks
\ifcase\c_syst_visualizers_state\else
\syst_visualizers_speedup
@@ -140,7 +154,7 @@
\endgroup}
\unexpanded\def\resetvisualizers
- {\attribute\visualattribute\attributeunsetvalue}
+ {\c_attr_visual\attributeunsetvalue}
%D New (these might also be a visualizers):
diff --git a/Master/texmf-dist/tex/context/base/mkiv/type-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/type-ini.lua
index a2e19725ed0..771cf39c056 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/type-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/type-ini.lua
@@ -17,9 +17,6 @@ local implement = interfaces.implement
local uselibrary = resolvers.uselibrary
-local name_one = nil
-local name_two = nil
-
local p_strip = Cs((P("type-") * (P("imp-")^0))^0/"" * P(1)^0)
local report = logs.reporter("fonts","typescripts")
@@ -29,6 +26,7 @@ local function action(name,foundname)
end
local patterns = {
+ "type-imp-%s.mkxl",
"type-imp-%s.mkiv",
"type-imp-%s.tex"
}
@@ -56,6 +54,7 @@ implement {
}
local patterns = {
+ "type-imp-%s.mkxl",
"type-imp-%s.mkiv",
"type-imp-%s.tex",
-- obsolete
@@ -63,6 +62,9 @@ local patterns = {
"type-%s.tex"
}
+-- local name_one = nil
+-- local name_two = nil
+--
-- local function failure_two(name)
-- report("unknown library %a or %a",name_one,name_two)
-- end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/type-ini.mklx b/Master/texmf-dist/tex/context/base/mkiv/type-ini.mklx
deleted file mode 100644
index 5470c9016ce..00000000000
--- a/Master/texmf-dist/tex/context/base/mkiv/type-ini.mklx
+++ /dev/null
@@ -1,618 +0,0 @@
-%D \module
-%D [ file=type-ini,
-%D version=2001.03.05,
-%D title=\CONTEXT\ Typescript Macros,
-%D subtitle=Initialization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Typescript Macros / Initialization}
-
-\registerctxluafile{type-ini}{}
-
-%D The default fontclass is empty. We could demand always using fontclasses, and
-%D then make the calling macros simplier (always assume fontclass) but apart from
-%D downward compatibility issues, it would make global, class spanning definitions a
-%D pain. Some day we will introduce a default class.
-%D
-%D The \type {type-ini} and \type {font-ini} modules come as a pair and have mutual
-%D dependencies.
-%D
-%D At some point we will only store in memory so some code can go away.
-
-\unprotect
-
-\definesystemvariable {ts} % TypeScript / for the moment we keep this one
-
-\newcount \c_font_typescripts_n_of_preloaded
-\newconditional\c_font_typescripts_quit
-\newtoks \c_font_typescripts_document
-\newconditional\c_font_typescripts_preload
-\newconditional\c_font_typescripts_first_pass \settrue\c_font_typescripts_first_pass
-
-\newif \iftypescriptfound % will become a mode
-\newif \iftracetypescripts
-
-\newtoks \everybeforedefinetypeface
-\newtoks \everyafterdefinetypeface
-
-\let\typescriptfiles \empty
-\let\currenttypescripts\empty
-\let\currenttypefile \empty
-
-\installmacrostack\currenttypefile
-
-\let\typescriptone \empty % public, used in typescripts
-\let\typescripttwo \empty % public, used in typescripts
-\let\typescriptthree\empty % public, used in typescripts
-
-\installmacrostack\typescriptone
-\installmacrostack\typescripttwo
-\installmacrostack\typescriptthree
-
-\let\fontclassstyle \empty
-
-\installmacrostack\fontclassstyle
-
-\let\m_font_typescripts_one \empty
-\let\m_font_typescripts_two \empty
-\let\m_font_typescripts_three\empty
-\let\m_font_typescripts_check\empty
-\let\m_font_typescripts_match\empty
-
-\installmacrostack\m_font_typescripts_one
-\installmacrostack\m_font_typescripts_two
-\installmacrostack\m_font_typescripts_three
-
-\let\t_font_typescripts\relax % uses as synonym
-
-\installcorenamespace{typescriptcache}
-\installcorenamespace{typescriptfiles}
-\installcorenamespace{typescriptonce}
-\installcorenamespace{typescriptsynonyms}
-\installcorenamespace{typescriptprefix}
-\installcorenamespace{typescriptinheritances}
-\installcorenamespace{typescriptdefaultstyles}
-\installcorenamespace{typescriptrelatives}
-
-\definesystemvariable{ts} % TypeScript
-
-% tricky ... here we push/pop ... so \let
-
-\let\typescriptmethod\plusone % 1: empty==all==true 2: empty==false
-\let\typescriptstate \plustwo % 1: process 2: store
-
-\installmacrostack\typescriptmethod
-\installmacrostack\typescriptstate
-
-\unexpanded\def\starttypescriptcollection
- {\dosingleempty\font_typescripts_collection_start}
-
-\def\font_typescripts_collection_start[#tag]%
- {}
-
-\let\stoptypescriptcollection\relax
-
-\unexpanded\def\usetypescriptfile[#filename]%
- {\doifelse{#filename}\v!reset
- {\let\typescriptfiles\empty}
- {\splitfilename{#filename}%
- \addtocommalist\splitoffbase\typescriptfiles}}
-
-\unexpanded\def\usetypescript {\dotripleempty\font_typescripts_use_one}
-\unexpanded\def\usetypescriptexact{\dotripleempty\font_typescripts_use_two}
-
-\def\font_typescripts_use_one{\let\typescriptmethod\plusone\font_typescripts_use}
-\def\font_typescripts_use_two{\let\typescriptmethod\plustwo\font_typescripts_use}
-
-\installmacrostack\stoptypescript
-
-\unexpanded\def\font_typescripts_use[#one][#two][#three]%
- {\push_macro_m_font_typescripts_one
- \push_macro_m_font_typescripts_two
- \push_macro_m_font_typescripts_three
- \edef\m_font_typescripts_one {\truetypescript{#one}}%
- \edef\m_font_typescripts_two {\truetypescript{#two}}%
- \edef\m_font_typescripts_three{\truetypescript{#three}}%
- \push_macro_typescriptone
- \push_macro_typescripttwo
- \push_macro_typescriptthree
- \push_macro_typescriptmethod
- \push_macro_typescriptstate
- \push_macro_stoptypescript
- \typescriptfoundfalse
- \let\typescriptstate\plusone % why
- \iftracetypescripts
- \writestatus\m!fonts{request: [\m_font_typescripts_one] [\m_font_typescripts_two] [\m_font_typescripts_three]}%
- \fi
- \ifhmode
- \font_typescripts_use_inline
- \else
- \font_typescripts_use_display
- \fi
- \setfalse\c_font_typescripts_first_pass
- \pop_macro_stoptypescript
- \pop_macro_typescriptstate
- \pop_macro_typescriptmethod
- \pop_macro_typescriptthree
- \pop_macro_typescripttwo
- \pop_macro_typescriptone
- \pop_macro_m_font_typescripts_three
- \pop_macro_m_font_typescripts_two
- \pop_macro_m_font_typescripts_one}
-
-\def\font_typescripts_use_display
- {\processcommacommand[\typescriptfiles]\font_typescripts_load_file
- \the\c_font_typescripts_document}
-
-\let\font_typescripts_use_inline\font_typescripts_use_display
-
-\unexpanded\def\preloadtypescripts
- {\ifproductionrun\settrue\c_font_typescripts_preload\fi}
-
-\prependtoks
- \preloadtypescripts
-\to \everyjob
-
-\unexpanded\def\loadtypescriptfile[#1]%
- {\push_macro_typescriptstate
- \let\typescriptstate\plustwo % assumes 2 at the outer level
- \clf_loadtypescriptfile{#1}%
- \pop_macro_typescriptstate}
-
-\unexpanded\def\loadfoundtypescriptfile#1#2% name foundname / not a user command
- {\startreadingfile
- \unprotect
- \pushendofline
- \input{#2}%
- \popendofline
- \protect
- \stopreadingfile}
-
-\unexpanded\def\quittypescriptscanning
- {\settrue\c_font_typescripts_quit} % public
-
-\def\font_typescripts_start_store#definitions\stoptypescript
- {\global\advance\c_font_typescripts_n_of_preloaded\plusone
- \expandafter\normalgdef\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname
- {\starttypescript#definitions\stoptypescript}%
- \gtoksapp\t_font_typescripts\expandafter
- {\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}}
-
-\def\font_typescripts_collection_start_store#definitions\stoptypescriptcollection
- {\global\advance\c_font_typescripts_n_of_preloaded\plusone
- \expandafter\normalgdef\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname
- {\starttypescriptcollection#definitions\stoptypescriptcollection}%
- \gtoksapp\t_font_typescripts\expandafter
- {\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}}
-
-\def\font_typescripts_load_file#filename%
- {\setfalse\c_font_typescripts_quit
- \push_macro_currenttypefile
- \def\currenttypefile{#filename}%
- \ifconditional\c_font_typescripts_preload
- \font_typescript_process_typescript_file_and_store
- \else
- \font_typescript_process_typescript_file
- \fi
- \pop_macro_currenttypefile
- \ifconditional\c_font_typescripts_quit
- \quitcommalist
- \setfalse\c_font_typescripts_quit
- \fi}
-
-\def\font_typescript_process_typescript_file_and_store
- {\expandafter\let\expandafter\t_font_typescripts\csname\??typescriptfiles\currenttypefile\endcsname
- \ifx\t_font_typescripts\relax
- \font_typescript_process_typescript_store_indeed
- \fi
- \the\t_font_typescripts}
-
-\def\font_typescript_process_typescript_store_indeed
- {\newtoks\t_font_typescripts % is \relaxed elsewhere
- \begingroup
- \let\starttypescript \font_typescripts_start_store
- \let\starttypescriptcollection\font_typescripts_collection_start_store
- \font_typescript_process_typescript_file
- \endgroup
- \expandafter\let\csname\??typescriptfiles\currenttypefile\endcsname\t_font_typescripts}
-
-\def\font_typescript_process_typescript_file
- {\clf_doprocesstypescriptfile{\currenttypefile}}
-
-\unexpanded\def\usetypescriptonce
- {\dotripleempty\font_typescripts_use_once}
-
-\def\font_typescripts_use_once[#one][#two][#three]%
- {\ifcsname\??typescriptonce#one:#two:#three\endcsname
- \writestatus\m!fonts{once (#one) (#two) (#three)}%
- \else
- \expandafter\let\csname\??typescriptonce#one:#two:#three\endcsname\relax
- \font_typescripts_use[#one][#two][#three]%
- \fi}
-
-% \definetypescriptsynonym[lbr][cmr]
-
-\unexpanded\def\definetypescriptsynonym
- {\dodoubleempty\font_typescripts_synonym_define}
-
-\def\font_typescripts_synonym_define[#name][#synonym]%
- {\ifsecondargument\setevalue{\??typescriptsynonyms#name}{#synonym}\fi}
-
-\def\truetypescript#name% recursive so no \lastnamedcs
- {\ifcsname\??typescriptsynonyms#name\endcsname
- %\expandafter\truetypescript\csname\??typescriptsynonyms#name\endcsname
- \expandafter\truetypescript\lastnamedcs
- \else
- #name%
- \fi}
-
-% script [serif] [default] [size]
-% script [serif] [computer-modern] [size]
-% script [serif] [computer-modern] [ec]
-% script [serif] [computer-modern] [name]
-% script [serif] [computer-modern] [special]
-
-\prependtoks
- \settrue\c_font_typescripts_first_pass
-\to \everyjob
-
-\unexpanded\def\starttypescript
- {\ifcase\typescriptstate
- % 0 = skip
- \expandafter\font_typescripts_start_gobble
- \or
- % 1 = process
- \expandafter\font_typescripts_start_process
- \or
- % 2 = store
- \expandafter\font_typescripts_start_document
- \else
- % ? = skip
- \expandafter\font_typescripts_start_gobble
- \fi}
-
-\def\font_typescripts_start_gobble#definitions\stoptypescript{}
-
-\def\font_typescripts_start_document#definitions\stoptypescript
- {\toksapp\c_font_typescripts_document{\starttypescript#definitions\stoptypescript}}
-
-\def\font_typescripts_start_process % could be a faster \doifelsenextoptionalif needed
- {\let\typescriptone \m_font_typescripts_one
- \let\typescripttwo \m_font_typescripts_two
- \let\typescriptthree\m_font_typescripts_three
- \let\m_font_typescripts_match\empty
- \doifelsenextoptionalcs\font_typescripts_start_process_one\font_typescripts_start_process_all}
-
-\def\font_typescripts_start_process_all % could be a \let
- {\ifconditional\c_font_typescripts_first_pass
- \expandafter\font_typescripts_start_process_indeed
- \else
- % skip this since it may do unwanted resets, like
- % setting symbolic font names to unknown, especially
- % in run time user type scripts
- \expandafter\font_typescripts_start_gobble
- \fi}
-
-\def\font_typescripts_show_match
- {\writestatus\m!fonts{match:\ifx\currenttypefile\relax\space *\fi \m_font_typescripts_match}}
-
-\def\font_typescripts_start_process_yes
- {\ifdone
- \typescriptfoundtrue
- \iftracetypescripts\font_typescripts_show_match\fi
- \expandafter\font_typescripts_start_process_indeed
- \else
- \expandafter\font_typescripts_start_gobble
- \fi}
-
-\def\font_typescripts_start_process_one
- {\font_typescripts_check\m_font_typescripts_one\typescriptone\font_typescripts_start_process_again_one}
-
-\def\font_typescripts_start_process_two
- {\font_typescripts_check\m_font_typescripts_two\typescripttwo\font_typescripts_start_process_again_two}
-
-\def\font_typescripts_start_process_three
- {\font_typescripts_check\m_font_typescripts_three\typescriptthree\font_typescripts_start_process_again_three}
-
-\def\font_typescripts_start_process_again_one
- {\doifelsenextoptionalcs\font_typescripts_start_process_two\font_typescripts_start_process_yes}
-
-\def\font_typescripts_start_process_again_two
- {\doifelsenextoptionalcs\font_typescripts_start_process_three\font_typescripts_start_process_yes}
-
-\let\font_typescripts_start_process_again_three\font_typescripts_start_process_yes
-
-\def\font_typescripts_start_process_indeed
- {\push_macro_fontclass}
-
-\unexpanded\def\stoptypescript
- {\pop_macro_fontclass}
-
-\def\font_typescripts_check#asked#target#followup[#value]% script use value next
- {\donefalse
- \edef\m_font_typescripts_check{#value}%
- \ifx\m_font_typescripts_check\empty % no longer needed / met
- \ifcase\typescriptmethod\or\donetrue\fi
- \orelse\ifx#asked\s!all
- \donetrue
- \orelse\ifx\m_font_typescripts_check\s!all
- \donetrue
- \orelse\ifx#asked\m_font_typescripts_check % saves 10% trace so probably faster too
- \donetrue
- \let#target\m_font_typescripts_check
- \else
- \doifelsecommon\m_font_typescripts_check#asked\donetrue\donefalse
- \ifdone
- \let#target\commalistelement
- \fi
- \fi
- \ifdone
- \iftracetypescripts\extendtypescriptmatch\fi
- \expandafter#followup%
- \else
- \expandafter\font_typescripts_start_gobble
- \fi}
-
-\def\extendtypescriptmatch
- {\edef\m_font_typescripts_match{\m_font_typescripts_match\space[\m_font_typescripts_check]}}
-
-%D Map files will go away in \LUATEX, but till that happens we use stripped down
-%D support for loading them.
-
-\unexpanded\def\loadmapfile{\dosingleempty\font_map_load_file}
-\unexpanded\def\loadmapline{\dodoubleempty\font_map_load_line}
-
-\def\font_map_load_file[#filename]%
- {\clf_loadmapfile{#filename}}
-
-\def\font_map_load_line[#kind][#data]%
- {\clf_loadmapline{#kind}{#data}}
-
-\unexpanded\def\forgetmapfiles
- {\clf_resetmapfiles}
-
-% \prependtoks
-% \loadmapfile[mkiv-base.map]% can't we preload this one?
-% \to \everystarttext
-
-%D A handy shortcut:
-
-% \definetypescriptprefix[serif][Serif]
-% \definetypescriptprefix[sans] [Sans]
-% \definetypescriptprefix[mono] [Mono]
-%
-% \starttypescript [serif,sans,mono] [handling,hanging,hz] [pure,normal,hz,quality]
-% \setupfontsynonym [\typescriptprefix\typescriptone] [handling=\typescriptthree]
-% \stoptypescript
-
-\unexpanded\def\definetypescriptprefix
- {\dodoubleargument\font_typescripts_define_prefix}
-
-\def\font_typescripts_define_prefix[#name][#prefix]%
- {\setgvalue{\??typescriptprefix#name}{#prefix}} % made global
-
-\def\typescriptprefix#name%
- %{\ifcsname\??typescriptprefix#name\endcsname\csname\??typescriptprefix#name\endcsname\else#name\fi}
- {\ifcsname\??typescriptprefix#name\endcsname\lastnamedcs\else#name\fi}
-
-% defining typefaces:
-%
-% \definetypeface [joke] [rm]
-% \definetypeface [joke] [rm] [settings]
-% \definetypeface [joke] [rm] [serif] [lucida]
-% \definetypeface [joke] [rm] [serif] [lucida] [size]
-% \definetypeface [joke] [rm] [serif] [lucida] [size] [settings]
-% \definetypeface [joke] [specification]
-
-\unexpanded\def\definetypeface
- {\dosixtupleargument\font_typefaces_define}
-
-\appendtoks
- \font_helpers_reset_fontclass_math_families\fontclass
-\to \everybeforedefinetypeface
-
-%D This hooks into the font switcher:
-
-\settrue\autotypescripts
-
-\unexpanded\def\trycurrentfontclass#typeface%
- {\ifconditional\autotypescripts
- \usetypescript[#typeface]%
- \ifcsname\??fontclassyes#typeface\endcsname
- \edef\fontclass{#typeface}%
- \else
- \iftracetypescripts\writestatus\m!fonts{auto load typescript file 1: [#typeface]}\fi
- \usetypescriptfile[#typeface]%
- \usetypescript[#typeface]%
- \ifcsname\??fontclassyes#typeface\endcsname
- \edef\fontclass{#typeface}%
- \else
- % todo: message
- \letvalueempty{\??fontclassnop#typeface}%
- \fi
- \fi
- \else
- % todo: message
- \letvalueempty{\??fontclassnop#typeface}%
- \fi}
-
-%D Now we define:
-
-\def\font_typefaces_define
- {\iffifthargument
- \expandafter\font_typefaces_define_a
- \orelse\iffourthargument
- \expandafter\font_typefaces_define_b
- \orelse\ifthirdargument
- \expandafter\font_typefaces_define_c
- \else
- \expandafter\font_typefaces_define_d
- \fi}
-
-\def\font_typefaces_define_a[#name][#style][#fontshape][#fontname][#fontsize][#settings]%
- {\iftracetypescripts\writestatus\m!fonts{define: [#name] [#style] [#fontshape] [#fontname]}\fi
- \font_typefaces_define_indeed[#name][#style]%
- \font_typefaces_defining_start{#name}{#style}{#settings}%
- \font_typescripts_use_one[#fontshape][#fontname][\s!name]% [\s!name,\s!default]%
- \iftypescriptfound
- % we're okay
- \orelse\ifconditional\autotypescripts
- \iftracetypescripts\writestatus\m!fonts{auto load typescript file 2: [#fontname]}\fi
- \usetypescriptfile[#fontname]%
- \font_typescripts_use_one[#fontshape][#fontname][\s!name]% [\s!name,\s!default]%
- \fi
- \font_typescripts_use_one[#fontshape][#fontsize][\s!size]%
- \font_typefaces_defining_stop}
-
-\def\font_typefaces_define_b[#name][#style][#fontshape][#fontname][#dummya][#dummyb]%
- {\font_typefaces_define_a[#name][#style][#fontshape][#fontname][\s!default][#dummyb]}
-
-\def\font_typefaces_define_c[#name][#style][#dummya][#dummyb][#dummyc][#dummyd]%
- {\font_typefaces_define_indeed[#name][#style]}
-
-\def\font_typefaces_define_d[#name][#specification][#dummya][#dummyb][#dummyc][#dummyd]% use definitions in lfg file
- {\clf_definetypeface{#name}{#specification}}
-
-\def\font_typefaces_define_indeed[#name][#style]% saveguard against redefinition
- {\doifsomething{#name}
- {\ifcsname\??typescriptdefaultstyles#name\endcsname \else
- \registerfontclass{#name}%
- \setxvalue{\??typescriptdefaultstyles#name}{#style}%
- \fi
- \ifcsname#name\endcsname \else
- \setugvalue{#name}{\switchtotypeface[#name][#style]}%
- \fi}}
-
-\def\font_typefaces_defining_start#name#style#settings%
- {\let\@@tsrscale \!!plusone % as we push/pop
- \let\@@tsfeatures \empty
- \let\@@tsfallbacks \empty
- \let\@@tsgoodies \empty
- \let\@@tsdirection \empty
- \let\@@tsdesignsize\empty
- \geteparameters[\??ts][#settings]% todo raw
- \push_macro_fontclass
- \push_macro_fontclassstyle
- \setcurrentfontclass{#name}%
- \savefontclassparameters{#style}\@@tsrscale\@@tsfeatures\@@tsfallbacks\@@tsgoodies\@@tsdesignsize\@@tsdirection
- \the\everybeforedefinetypeface}
-
-\def\tsvar#key#default% undocumented and unofficial
- {\expandafter\ifx\csname\??ts#key\endcsname\empty
- #default%
- \else
- \csname\??ts#key\endcsname
- \fi}
-
-\def\font_typefaces_defining_stop
- {\the\everyafterdefinetypeface
- \pop_macro_fontclassstyle
- \pop_macro_fontclass}
-
-\def\dofastdefinetypeface#name#style#fontshape#fontsize#settings% called from the lua end (via case d)
- {\font_typefaces_define_indeed[#name][#style]%
- \font_typefaces_defining_start{#name}{#style}{#settings}%
- \font_typescripts_use_one[#fontshape][#fontsize][\s!size]%
- \font_typefaces_defining_stop}
-
-\unexpanded\def\setuptypeface% [class] [settings]
- {\dodoubleempty\font_typefaces_setup}
-
-\unexpanded\def\switchtotypeface% [class] [settings]
- {\dodoubleempty\font_typefaces_switch}
-
-\def\font_typefaces_setup[#class][#settings]%
- {\setcurrentfontclass{#class}%
- \let\globalfontclass\fontclass
- \ifsecondargument
- \setupbodyfont[#settings]%
- \orelse\ifx\fontclass\empty
- \setupbodyfont[\s!rm]%
- \orelse\ifcsname\??typescriptdefaultstyles\fontclass\endcsname
- %\setupbodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]%
- \expandafter\setupbodyfont\expandafter[\lastnamedcs]%
- \else
- \setupbodyfont[\s!rm]%
- \fi
- \ifmmode\mr\else\tf\fi} % needed ?
-
-\def\font_typefaces_switch[#class][#settings]%
- {\setcurrentfontclass{#class}%
- \let\globalfontclass\globalfontclass
- \ifsecondargument
- \switchtobodyfont[#settings]%
- \orelse\ifx\fontclass\empty
- \switchtobodyfont[\s!rm]%
- \orelse\ifcsname\??typescriptdefaultstyles\fontclass\endcsname
- %\switchtobodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]%
- \expandafter\switchtobodyfont\expandafter[\lastnamedcs]%
- \else
- \switchtobodyfont[\s!rm]%
- \fi
- \ifmmode\mr\else\tf\fi} % needed ?
-
-%D For Taco:
-%D
-%D \starttyping
-%D \inherittypeface[palatino][rm][postscript]
-%D \inherittypeface[palatino][rm][\fontclass]
-%D \inherittypeface[palatino][rm] % == \fontclass
-%D \inherittypeface[palatino] % == [rm,ss,tt,mm]
-%D \stoptyping
-
-\unexpanded\def\inherittypeface
- {\dotripleempty\font_typescripts_inherit_indeed}
-
-\def\font_typescripts_inherit_indeed[#name][#styles][#parentclass]%
- {\doifelsenothing{#styles}
- {\font_typescripts_inherit_indeed[#name][\s!rm,\s!ss,\s!tt,\s!mm][\fontclass]}
- {\doifnot{#name}{#parentclass}
- {\glet\font_typescripts_inherit_check\font_typescripts_inherit_check_indeed
- \def\font_typescripts_inherit_check_step#style{\setevalue{\??typescriptinheritances#name:#style}{#parentclass}}%
- \processcommalist[#styles]\font_typescripts_inherit_check_step}}}
-
-\let\font_typescripts_inherit_check_step\relax
-
-%D This hooks into the font mechanism with:
-
-\def\font_typescripts_inherit_check_indeed#name% called often
- {\ifcsname\??typescriptinheritances\fontclass:#name\endcsname
- %\expandafter\let\expandafter\fontclass\csname\??typescriptinheritances\fontclass:#name\endcsname
- \expandafter\let\expandafter\fontclass\lastnamedcs
- \fi}
-
-\let\font_typescripts_inherit_check\gobbleoneargument
-
-% not yet:
-%
-% \def\font_helpers_check_relative_font_id
-% {\ifcsname\??typescriptrelatives\fontclass\endcsname
-% \expandafter\let\expandafter\relativefontid\csname\??typescriptrelatives\fontclass\endcsname
-% \else
-% \expandafter\normalxdef\csname\??typescriptrelatives\fontclass\endcsname{\the\lastfontid}%
-% \let\relativefontid\minusone
-% \fi}
-
-\def\v_font_string_d % default fontstyle (expands to \s!Serif in font-ini)
- {\expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!rm \s!Serif \else
- \expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!ss \s!Sans \else
- \expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!tt \s!Mono \else
- \s!Serif \fi\fi\fi}
-
-\unexpanded\def\font_helpers_set_fontstyle_of_fontclass
- {\ifx\fontclass\empty
- \let\fontstyle\s!rm
- \orelse\ifcsname\??typescriptdefaultstyles\fontclass\endcsname
- %\edef\fontstyle{\csname\??typescriptdefaultstyles\fontclass\endcsname}%
- \edef\fontstyle{\lastnamedcs}%
- \else
- \let\fontstyle\s!rm
- \fi}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-bld.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-bld.lua
index 6874d385a9b..30503277212 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-bld.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-bld.lua
@@ -243,10 +243,9 @@ end
-- the check can go away
function builders.buildpage_filter(groupcode)
- -- the next check saves 1% runtime on 1000 tufte pages
local head = texlists.contrib_head
- local done = false
if head then
+ local done = false
-- called quite often ... maybe time to remove timing
starttiming(builders)
if trace_page_builder then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-brk.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-brk.lua
index d670c53196f..89eb7e52d33 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-brk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-brk.lua
@@ -33,7 +33,7 @@ local getid = nuts.getid
----- getattr = nuts.getattr
local getattrlist = nuts.getattrlist
local takeattr = nuts.takeattr
-local getlang = nuts.getlang
+local getlanguage = nuts.getlanguage
local isglyph = nuts.isglyph
local setattr = nuts.setattr
@@ -168,7 +168,7 @@ methods[2] = function(head,start) -- ( => (-
head, start, replace = remove_node(head,start)
local post = copy_node(replace)
local hyphen = copy_node(post)
- setchar(hyphen,languages.prehyphenchar(getlang(post)))
+ setchar(hyphen,languages.prehyphenchar(getlanguage(post)))
setlink(post,hyphen)
head, start = insert_node_before(head,start,new_disc(nil,post,replace))
setattrlist(start,replace)
@@ -184,7 +184,7 @@ methods[3] = function(head,start) -- ) => -)
head, start, replace = remove_node(head,start)
local pre = copy_node(replace)
local hyphen = copy_node(pre)
- setchar(hyphen,languages.prehyphenchar(getlang(pre)))
+ setchar(hyphen,languages.prehyphenchar(getlanguage(pre)))
setlink(hyphen,pre)
head, start = insert_node_before(head,start,new_disc(hyphen,nil,replace)) -- so not pre !
setattrlist(start,tmp)
@@ -264,7 +264,7 @@ function breakpoints.handler(head)
-- setattr(current,a_breakpoints,unsetvalue) -- should not be needed
-- for now we collect but when found ok we can move the handler here
-- although it saves nothing in terms of performance
- local lang = getlang(current)
+ local lang = getlanguage(current)
local smap = lang and lang >= 0 and lang < 0x7FFF and (cmap[languages.numbers[lang]] or cmap[""])
if smap then
local skip = smap.skip
@@ -322,7 +322,7 @@ function breakpoints.handler(head)
local cmap = data[3]
local smap = data[4]
-- we do a sanity check for language
- -- local lang = getlang(start)
+ -- local lang = getlanguage(start)
-- local smap = lang and lang >= 0 and lang < 0x7FFF and (cmap[numbers[lang]] or cmap[""])
-- if smap then
local nleft = smap.nleft
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-brk.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-brk.mkiv
index 6071221dd43..23ab414fe03 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-brk.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-brk.mkiv
@@ -64,7 +64,7 @@
\unexpanded\def\resetbreakpoints
{\exhyphenchar\hyphenasciicode % 2020.03.05
- \attribute\breakpointattribute\attributeunsetvalue}
+ \c_attr_breakpoint\attributeunsetvalue}
\definebreakpoints[compound]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-cap.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-cap.lua
index c1666a9f119..3d0d6055a77 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-cap.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-cap.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['typo-cap'] = {
version = 1.001,
+ optimize = true,
comment = "companion to typo-cap.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-cap.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-cap.mkiv
index 20e2eb7a945..3dea50c99e1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-cap.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-cap.mkiv
@@ -228,8 +228,11 @@
\unexpanded\def\autocap{\ifmmode\expandafter\normalcap\else\expandafter\smallcapped\fi}
-\appendtoks
+\prependtoks
\let\normalcap\cap % mathmode cap
+\to \everydump
+
+\appendtoks
\let\cap\autocap
\to \everydump
@@ -298,9 +301,9 @@
%
% \definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=]
-% \unexpanded\def\randomizetext{\groupedcommand{\attribute\caseattribute\pluseight}{}}
+% \unexpanded\def\randomizetext{\groupedcommand{\c_attr_case\pluseight}{}}
-\unexpanded\def\randomizetext{\triggergroupedcommand{\attribute\caseattribute\pluseight}}
+\unexpanded\def\randomizetext{\triggergroupedcommand{\c_attr_case\pluseight}}
\definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=]
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-chr.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-chr.lua
index 7a0f1fd7521..bb3883b3308 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-chr.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-chr.lua
@@ -91,7 +91,7 @@ local boundarycodes = nodes.boundarycodes
local subtypes = nodes.subtypes
local glyph_code = nodecodes.glyph
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local boundary_code = nodecodes.boundary
local wordboundary_code = boundarycodes.word
@@ -175,7 +175,7 @@ local function pickup(head,tail,str)
while true do
local prev = first.prev
if prev and prev[a_marked] == attr then
- if prev.id == localpar_code then -- and start_of_par(prev)
+ if prev.id == par_code then -- and start_of_par(prev)
break
else
first = prev
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-cln.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-cln.mkiv
index efc278cfa05..bdda1942410 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-cln.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-cln.mkiv
@@ -27,7 +27,7 @@
{\clf_setcharactercleaning{#1}} % also accepts "reset"
% \appendtoks
-% \attribute\cleanerattribute\attributeunsetvalue
+% \c_attr_cleaner\attributeunsetvalue
% \to \everyforgetall
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-del.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-del.mkiv
index 9320c37ee6f..9720326be14 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-del.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-del.mkiv
@@ -142,8 +142,8 @@
[\c!rightsubsentence]
[\rightboundarycharacter\c!rightsubsentence{sentence}]
-\newsignal \d_typo_subsentence_signal
-\newcount \c_typo_subsentence_nesting
+\newsignal\d_typo_subsentence_signal
+\newcount \c_typo_subsentence_nesting
\let\beforesubsentence\donothing
\let\aftersubsentence \donothing
@@ -179,7 +179,7 @@
\fi
\global\advance\c_typo_subsentence_nesting\plusone
\ifnum\c_typo_subsentence_nesting=\plusone
- \dontleavehmode % was \leaveoutervmode
+ \dontleavehmode
\fi
\dostarttagged\t!subsentence\empty % no chain
\dostarttagged\t!subsentencesymbol\empty
@@ -420,7 +420,7 @@
\typo_delimited_push{#1}{#2}%
\dostarttaggedchained\t!delimitedblock\currentdelimitedtext\??delimitedtext
\edef\p_delimited_method{\delimitedtextparameter\c!method}%
- \ifx\p_delimited_method\s!font
+ \ifx\p_delimited_method\v!font
\expandafter\typo_delimited_start_font
\else
\expandafter\typo_delimited_start_other
@@ -524,6 +524,7 @@
\begingroup
\usedelimitedtextstyleandcolor\c!style\c!color
%
+ \begingroup
\edef\p_delimited_left {\delimitedtextparameter{\c!left}}%
\edef\p_delimited_right {\delimitedtextparameter{\c!right}}%
\edef\p_delimited_nextleft {\delimitedtextparameter{\c!nextleft}}%
@@ -539,7 +540,10 @@
\def\typo_delimited_stop_par
{\typo_delimited_stop_content
\rightdelimitedtextmark
- \carryoverpar\endgroup % new per 2013-01-21 ... please left floats
+ \rightdelimitedtextmark
+ \carryoverpar\endgroup
+ \endgraf
+ \endgroup
\pop_macro_checkindentation
\typo_delimited_stop_par_indeed
\delimitedtextparameter\c!after
@@ -575,7 +579,7 @@
{\dontleavehmode % following ones can be omited
\typo_delimited_push{#1}{#2}%
\edef\p_delimited_method{\delimitedtextparameter\c!method}%
- \ifx\p_delimited_method\s!font
+ \ifx\p_delimited_method\v!font
\expandafter\typo_delimited_fontdriven
\else
\expandafter\typo_delimited_other
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-dha.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-dha.lua
index 7d5c7751b35..ac72ae39488 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-dha.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-dha.lua
@@ -14,12 +14,12 @@ if not modules then modules = { } end modules ['typo-dha'] = {
--
-- Then we have, with input: LATIN ARAB
--
--- \textdir TLT LATIN ARAB => LATIN BARA
--- \textdir TRT LATIN ARAB => LATIN BARA
--- \textdir TRT LRO LATIN ARAB => LATIN ARAB
--- \textdir TLT LRO LATIN ARAB => LATIN ARAB
--- \textdir TLT RLO LATIN ARAB => NITAL ARAB
--- \textdir TRT RLO LATIN ARAB => NITAL ARAB
+-- \textdirection 1 LATIN ARAB => LATIN BARA
+-- \textdirection 1 LATIN ARAB => LATIN BARA
+-- \textdirection 1 LRO LATIN ARAB => LATIN ARAB
+-- \textdirection 1 LRO LATIN ARAB => LATIN ARAB
+-- \textdirection 1 RLO LATIN ARAB => NITAL ARAB
+-- \textdirection 1 RLO LATIN ARAB => NITAL ARAB
-- elseif d == "es" then -- European Number Separator
-- elseif d == "et" then -- European Number Terminator
@@ -78,7 +78,7 @@ local math_code = nodecodes.math
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local dirvalues = nodes.dirvalues
local lefttoright_code = dirvalues.lefttoright
@@ -272,12 +272,12 @@ local function process(start)
stack[top] = { override, embedded }
override = 1
obsolete[#obsolete+1] = current
- elseif direction == "lre" then -- Left-to-Right Embedding -> TLT
+ elseif direction == "lre" then -- Left-to-Right Embedding -> lefttoright_code
top = top + 1
stack[top] = { override, embedded }
embedded = 1
obsolete[#obsolete+1] = current
- elseif direction == "rle" then -- Right-to-Left Embedding -> TRT
+ elseif direction == "rle" then -- Right-to-Left Embedding -> righttoleft_code
top = top + 1
stack[top] = { override, embedded }
embedded = -1
@@ -332,7 +332,7 @@ local function process(start)
end
textdir = autodir
setprop(current,"direction",true)
- elseif id == localpar_code and start_of_par(current) then
+ elseif id == par_code and start_of_par(current) then
local direction = getdirection(current)
if direction == righttoleft_code then
autodir = -1
@@ -382,7 +382,7 @@ local function process(start)
if cp == "n" then
local swap = state == "r"
if swap then
- head = insert_node_before(head,current,startdir("TLT"))
+ head = insert_node_before(head,current,startdir(lefttoright_code))
end
setprop(current,"direction",true)
while true do
@@ -395,14 +395,14 @@ local function process(start)
end
end
if swap then
- head, current = insert_node_after(head,current,stopdir("TLT"))
+ head, current = insert_node_after(head,current,stopdir(lefttoright_code))
end
elseif cp == "l" then
if state ~= "l" then
if state == "r" then
- head = insert_node_before(head,last or current,stopdir("TRT"))
+ head = insert_node_before(head,last or current,stopdir(righttoleft_code))
end
- head = insert_node_before(head,current,startdir("TLT"))
+ head = insert_node_before(head,current,startdir(lefttoright_code))
state = "l"
done = true
end
@@ -410,9 +410,9 @@ local function process(start)
elseif cp == "r" then
if state ~= "r" then
if state == "l" then
- head = insert_node_before(head,last or current,stopdir("TLT"))
+ head = insert_node_before(head,last or current,stopdir(lefttoright_code))
end
- head = insert_node_before(head,current,startdir("TRT"))
+ head = insert_node_before(head,current,startdir(righttoleft_code))
state = "r"
done = true
end
@@ -425,9 +425,9 @@ local function process(start)
end
else
if state == "r" then
- head = insert_node_before(head,current,stopdir("TRT"))
+ head = insert_node_before(head,current,stopdir(righttoleft_code))
elseif state == "l" then
- head = insert_node_before(head,current,stopdir("TLT"))
+ head = insert_node_before(head,current,stopdir(lefttoright_code))
end
state = false
last = false
@@ -438,7 +438,7 @@ local function process(start)
if next then
current = next
else
- local sd = (state == "r" and stopdir("TRT")) or (state == "l" and stopdir("TLT"))
+ local sd = (state == "r" and stopdir(righttoleft_code)) or (state == "l" and stopdir(lefttoright_code))
if sd then
if id == glue_code and getsubtype(current) == parfillskip_code then
head = insert_node_before(head,current,sd)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-dig.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-dig.lua
index 175fc0cc7ef..a9294a38dae 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-dig.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-dig.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['typo-dig'] = {
version = 1.001,
+ optimize = true,
comment = "companion to typo-dig.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-dig.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-dig.mkiv
index 0f957fbc1d6..26e35c19928 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-dig.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-dig.mkiv
@@ -42,7 +42,7 @@
{\clf_setdigitsmanipulation{#1}}
\unexpanded\def\resetdigitsmanipulation
- {\attribute\digitsattribute\attributeunsetvalue}
+ {\c_attr_digits\attributeunsetvalue}
\appendtoks
\resetdigitsmanipulation
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-dir.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-dir.mkiv
index 7449a705323..d9fb3b050a7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-dir.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-dir.mkiv
@@ -45,7 +45,7 @@
% is in fact:
\unexpanded\def\resetdirection
- {\attribute\directionsattribute\attributeunsetvalue}
+ {\c_attr_directions\attributeunsetvalue}
\newconstant\directionsbidimode % this one might become pivate
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
index 50eb765f221..ddc6d68ae82 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
@@ -82,7 +82,7 @@ local glyph_code = nodecodes.glyph
local hlist_code = nodecodes.hlist
local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local actions = { }
initials.actions = actions
@@ -270,7 +270,7 @@ actions[v_default] = function(head,setting)
end
-- We pack so that successive handling cannot touch the dropped cap. Packaging
-- in a hlist is also needed because we cannot locally adapt e.g. parindent (not
- -- yet stored in with localpar).
+ -- yet stored in with par).
local prev = getprev(first)
local next = getnext(last)
--
@@ -334,7 +334,7 @@ end
-- we can count ... when all done, we can disable ...
function initials.handler(head)
- if getid(head) == localpar_code and start_of_par(head) then
+ if getid(head) == par_code and start_of_par(head) then
local settings = getprop(head,a_initial)
if settings then
disableaction("processors","typesetters.initials.handler")
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-drp.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-drp.mkiv
index 25b006b2f0f..e774b6796c4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-drp.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-drp.mkiv
@@ -22,7 +22,7 @@
\definesystemattribute[initial][public]
\appendtoks
- \attribute\initialattribute\attributeunsetvalue
+ \c_attr_initial\attributeunsetvalue
\to \everyforgetall
%D For the moment here: dropped caps redone. In addition to the
@@ -59,9 +59,9 @@
\c!n=3,
\c!m=1,
\c!method=\v!none,
- % \s!font=Bold sa 4,
- % \s!font=Bold ht \measure{initial:n},
- \s!font=Bold cp \measure{initial:n},
+ % \c!font=Bold sa 4,
+ % \c!font=Bold ht \measure{initial:n},
+ \c!font=Bold cp \measure{initial:n},
\c!distance=.125\emwidth,
\c!hoffset=\zeropoint,
\c!voffset=\v!line, % \dimexp\lineheight*\initialparameter\c!n-\lineheight\relax]
@@ -90,7 +90,7 @@
\setupcurrentinitial[#2]%
\resetfontfeature % might be needed in more places
\doifelsenothing{\initialparameter\c!style}
- {\definedfont[\initialparameter\s!font]}
+ {\definedfont[\initialparameter\c!font]}
{\useinitialstyleparameter\c!style}%
\useinitialcolorparameter\c!color
\edef\p_voffset{\initialparameter\c!voffset}%
@@ -105,13 +105,13 @@
distance \dimexpr\initialparameter\c!distance\relax
hoffset \dimexpr\initialparameter\c!hoffset\relax
voffset \scratchvoffset
- ma \attribute\colormodelattribute
- ca \attribute\colorattribute
- ta \attribute\transparencyattribute
+ ma \c_attr_colormodel
+ ca \c_attr_color
+ ta \c_attr_transparency
font \fontid\font
dynamic \font_dynamic_value % it's a bit over the top to support this here
\relax
- \attribute\initialattribute\plusone
+ \c_attr_initial\plusone
\initialparameter\c!text
\endgroup
\glet\typo_initial_handle\relax}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-dua.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-dua.lua
index 0cec0e08e1e..5e1d4c109ae 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-dua.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-dua.lua
@@ -99,7 +99,7 @@ local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local parfillskip_code = gluecodes.parfillskip
@@ -337,18 +337,12 @@ local function get_baselevel(head,list,size,direction)
-- This is an adapted version:
if direction == lefttoright_code or direction == righttoleft_code then
return direction, true
- elseif getid(head) == localpar_code and start_of_par(head) then
+ elseif getid(head) == par_code and start_of_par(head) then
direction = getdirection(head)
if direction == lefttoright_code or direction == righttoleft_code then
return direction, true
end
end
- -- for old times sake we we handle strings too
- if direction == "TLT" then
- return lefttoright_code, true
- elseif direction == "TRT" then
- return righttoleft_code, true
- end
-- P2, P3
for i=1,size do
local entry = list[i]
@@ -775,8 +769,8 @@ local function apply_to_list(list,size,head,pardir)
enddir = false
end
elseif begindir then
- if id == localpar_code and start_of_par(current) then
- -- localpar should always be the 1st node
+ if id == par_code and start_of_par(current) then
+ -- par should always be the 1st node
local d = new_direction(begindir)
-- setprop(d,"directions",true)
-- setattrlist(d,current)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-dub.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-dub.lua
index f1bd38fcc5d..88b3361da4a 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-dub.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-dub.lua
@@ -87,7 +87,7 @@ local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local parfillskip_code = gluecodes.parfillskip
@@ -398,18 +398,12 @@ end
local function get_baselevel(head,list,size,direction)
if direction == lefttoright_code or direction == righttoleft_code then
return direction, true
- elseif getid(head) == localpar_code and start_of_par(head) then
+ elseif getid(head) == par_code and start_of_par(head) then
direction = getdirection(head)
if direction == lefttoright_code or direction == righttoleft_code then
return direction, true
end
end
- -- for old times sake we we handle strings too
- if direction == "TLT" then
- return lefttoright_code, true
- elseif direction == "TRT" then
- return righttoleft_code, true
- end
-- P2, P3
for i=1,size do
local entry = list[i]
@@ -908,8 +902,8 @@ local function apply_to_list(list,size,head,pardir)
enddir = false
end
elseif begindir then
- if id == localpar_code and start_of_par(current) then
- -- localpar should always be the 1st node
+ if id == par_code and start_of_par(current) then
+ -- par should always be the 1st node
local d = new_direction(begindir)
-- setprop(d,"directions",true)
-- setattrlist(d,current)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-duc.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-duc.lua
index d4c56e3008d..6e4f27de257 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-duc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-duc.lua
@@ -51,70 +51,73 @@ local utfchar = utf.char
local setmetatable = setmetatable
local formatters = string.formatters
-local directiondata = characters.directions
-local mirrordata = characters.mirrors
-local textclassdata = characters.textclasses
+local directiondata = characters.directions
+local mirrordata = characters.mirrors
+local textclassdata = characters.textclasses
-local nuts = nodes.nuts
+local nuts = nodes.nuts
-local getnext = nuts.getnext
-local getid = nuts.getid
-local getsubtype = nuts.getsubtype
-local getlist = nuts.getlist
-local getchar = nuts.getchar
-local getattr = nuts.getattr
-local getprop = nuts.getprop
-local getdirection = nuts.getdirection
-local isglyph = nuts.isglyph
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getsubtype = nuts.getsubtype
+local getlist = nuts.getlist
+local getchar = nuts.getchar
+local getattr = nuts.getattr
+local getprop = nuts.getprop
+local getdirection = nuts.getdirection
+local isglyph = nuts.isglyph
-local setprop = nuts.setprop
-local setchar = nuts.setchar
-local setdirection = nuts.setdirection
-local setattrlist = nuts.setattrlist
+local setprop = nuts.setprop
+local setchar = nuts.setchar
+local setdirection = nuts.setdirection
+local setattrlist = nuts.setattrlist
-local properties = nodes.properties.data
+local properties = nodes.properties.data
-local remove_node = nuts.remove
-local insert_node_after = nuts.insert_after
-local insert_node_before = nuts.insert_before
-local start_of_par = nuts.start_of_par
+local remove_node = nuts.remove
+local insert_node_after = nuts.insert_after
+local insert_node_before = nuts.insert_before
+local start_of_par = nuts.start_of_par
-local nodepool = nuts.pool
-local new_direction = nodepool.direction
+local nodepool = nuts.pool
+local new_direction = nodepool.direction
-local nodecodes = nodes.nodecodes
-local gluecodes = nodes.gluecodes
+local nodecodes = nodes.nodecodes
+local gluecodes = nodes.gluecodes
-local glyph_code = nodecodes.glyph
-local glue_code = nodecodes.glue
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local math_code = nodecodes.math
-local dir_code = nodecodes.dir
-local localpar_code = nodecodes.localpar
+local glyph_code = nodecodes.glyph
+local glue_code = nodecodes.glue
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local math_code = nodecodes.math
+local dir_code = nodecodes.dir
+local par_code = nodecodes.par
+local penalty_code = nodecodes.penalty
-local parfillskip_code = gluecodes.parfillskip
+local parfillskip_code = gluecodes.parfillskip
+local parfillleftskip_code = gluecodes.parfillleftskip
-local dirvalues = nodes.dirvalues
-local lefttoright_code = dirvalues.lefttoright
-local righttoleft_code = dirvalues.righttoleft
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
-local maximum_stack = 0xFF
+local maximum_stack = 0xFF
-local a_directions = attributes.private('directions')
+local a_directions = attributes.private('directions')
-local directions = typesetters.directions
-local setcolor = directions.setcolor
-local getfences = directions.getfences
+local directions = typesetters.directions
+local setcolor = directions.setcolor
+local getfences = directions.getfences
-local remove_controls = true directives.register("typesetters.directions.removecontrols",function(v) remove_controls = v end)
------ analyze_fences = true directives.register("typesetters.directions.analyzefences", function(v) analyze_fences = v end)
+local remove_controls = true directives.register("typesetters.directions.removecontrols",function(v) remove_controls = v end)
+----- analyze_fences = true directives.register("typesetters.directions.analyzefences", function(v) analyze_fences = v end)
-local report_directions = logs.reporter("typesetting","directions three")
+local report_directions = logs.reporter("typesetting","directions three")
-local trace_directions = false trackers.register("typesetters.directions", function(v) trace_directions = v end)
-local trace_details = false trackers.register("typesetters.directions.details", function(v) trace_details = v end)
-local trace_list = false trackers.register("typesetters.directions.list", function(v) trace_list = v end)
+local trace_directions = false trackers.register("typesetters.directions", function(v) trace_directions = v end)
+local trace_details = false trackers.register("typesetters.directions.details", function(v) trace_details = v end)
+local trace_list = false trackers.register("typesetters.directions.list", function(v) trace_list = v end)
-- strong (old):
--
@@ -413,18 +416,12 @@ end
local function get_baselevel(head,list,size,direction)
if direction == lefttoright_code or direction == righttoleft_code then
return direction, true
- elseif getid(head) == localpar_code and start_of_par(head) then
+ elseif getid(head) == par_code and start_of_par(head) then
direction = getdirection(head)
if direction == lefttoright_code or direction == righttoleft_code then
return direction, true
end
end
- -- for old times sake we we handle strings too
- if direction == "TLT" then
- return lefttoright_code, true
- elseif direction == "TRT" then
- return righttoleft_code, true
- end
-- P2, P3
for i=1,size do
local entry = list[i]
@@ -949,14 +946,25 @@ local function apply_to_list(list,size,head,pardir)
elseif id == hlist_code or id == vlist_code then
setdirection(current,pardir) -- is this really needed?
elseif id == glue_code then
+ -- Maybe I should also fix dua and dub but on the other hand ... why?
if enddir and getsubtype(current) == parfillskip_code then
-- insert the last enddir before \parfillskip glue
- head = insert_node_before(head,current,new_direction(enddir,true))
+ local c = current
+ local p = getprev(c)
+ if p and getid(p) == glue_code and getsubtype(p) == parfillleftskip_code then
+ c = p
+ p = getprev(c)
+ end
+ if p and getid(p) == penalty_code then -- linepenalty
+ c = p
+ end
+ -- there is always a par nodes so head will stay
+ head = insert_node_before(head,c,new_direction(enddir,true))
enddir = false
end
elseif begindir then
- if id == localpar_code and start_of_par(current) then
- -- localpar should always be the 1st node
+ if id == par_code and start_of_par(current) then
+ -- par should always be the 1st node
head, current = insert_node_after(head,current,new_direction(begindir))
begindir = nil
end
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-fkr.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-fkr.mkiv
index 7444db511eb..ec1b2907f3e 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-fkr.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-fkr.mkiv
@@ -29,7 +29,7 @@
{\clf_setextrafontkerns{#1}}
\unexpanded\def\resetextrafontkerns
- {\attribute\extrafontkernattribute\attributeunsetvalue}
+ {\c_attr_extrafontkern\attributeunsetvalue}
\appendtoks
\resetextrafontkerns
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua
index 326d3acf570..3941e65efaa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua
@@ -56,7 +56,7 @@ local glyph_code = nodecodes.glyph
local disc_code = nodecodes.disc
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local spaceskip_code = nodes.gluecodes.spaceskip
@@ -136,7 +136,7 @@ actions[v_line] = function(head,setting)
local temp = copy_node_list(head)
local linebreaks = { }
- set = function(head)
+ local set = function(head)
for g in nextglyph, head do
if dynamic > 0 then
setglyphdata(g,dynamic)
@@ -180,9 +180,9 @@ actions[v_line] = function(head,setting)
-- nodes.handlers.protectglyphs(temp) -- not needed as we discard
-- temp = typesetters.spacings.handler(temp) -- maybe when enabled
-- temp = typesetters.kerns.handler(temp) -- maybe when enabled
--- temp = typesetters.cases.handler(temp) -- maybe when enabled
-flush_node_list(temp);
+ -- temp = typesetters.cases.handler(temp) -- maybe when enabled
local width = getdimensions(temp)
+ flush_node_list(temp)
return width
end
@@ -372,7 +372,7 @@ end
actions[v_default] = actions[v_line]
function firstlines.handler(head)
- if getid(head) == localpar_code and start_of_par(head) then
+ if getid(head) == par_code and start_of_par(head) then
local settings = getprop(head,a_firstline)
if settings then
disableaction("processors","typesetters.firstlines.handler")
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-fln.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-fln.mkiv
index 6cca39f91c2..64ec092d6ea 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-fln.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-fln.mkiv
@@ -55,7 +55,7 @@
\definesystemattribute[firstline][public]
\appendtoks
- \attribute\firstlineattribute\attributeunsetvalue
+ \c_attr_firstline\attributeunsetvalue
\to \everyforgetall
\installcorenamespace {firstline}
@@ -81,9 +81,9 @@
\usefirstlinestyleandcolor\c!style\c!color
\clf_setfirstline
alternative {\firstlineparameter\c!alternative}%
- ma \attribute\colormodelattribute
- ca \attribute\colorattribute
- ta \attribute\transparencyattribute
+ ma \c_attr_colormodel
+ ca \c_attr_color
+ ta \c_attr_transparency
n \numexpr\firstlineparameter\c!n\relax
font \fontid\font
dynamic \font_dynamic_value
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-itc.mkvi b/Master/texmf-dist/tex/context/base/mkiv/typo-itc.mkvi
index 5aeb6723971..2bde63857f7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-itc.mkvi
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-itc.mkvi
@@ -35,10 +35,14 @@
\fi
\unexpanded\def\italiccorrection
- {\ifnum\attribute\italicsattribute<\plusone\normalitaliccorrection\fi}
+ {\ifnum\c_attr_italics<\plusone\normalitaliccorrection\fi}
+
+\pushoverloadmode
\let\/\italiccorrection
+\popoverloadmode
+
% 1 = end of word
% 2 = end of word and end of a list
@@ -57,7 +61,7 @@
{\clf_setupitaliccorrection{#settings}}
\appendtoks
- \attribute\italicsattribute\attributeunsetvalue
+ \c_attr_italics\attributeunsetvalue
\to \everymathematics
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-itm.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-itm.mkiv
index 0bb8170c721..18619957bd7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-itm.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-itm.mkiv
@@ -122,7 +122,7 @@
\edef\p_typo_items_n{\itemsparameter\c!n}%
\ifx\p_typo_items_n\empty
\getcommalistsize[#2]%
- \c_typo_items_n\commalistsize\relax
+ \c_typo_items_n\commalistsize\relax % \commalistcounter
\else
\c_typo_items_n\p_typo_items_n\relax
\fi
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-krn.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-krn.mkiv
index fedbce4d15b..80c71932f94 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-krn.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-krn.mkiv
@@ -41,7 +41,7 @@
\clf_setcharacterkerning{\characterkerningparameter\c!factor}}
\unexpanded\def\resetcharacterkerning % fast one
- {\attribute\kernattribute\attributeunsetvalue}
+ {\c_attr_kern\attributeunsetvalue}
\appendtoks
\resetcharacterkerning
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-lig.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-lig.mkiv
index 6171441d6d3..ea1b27b73b2 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-lig.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-lig.mkiv
@@ -24,7 +24,7 @@
\unexpanded\def\noligature#1%
{\dontleavehmode
\begingroup
- \attribute\noligatureattribute\plusone
+ \c_attr_noligature\plusone
#1%
\endgroup}
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua
index 15e543c52e5..84d622e1e9c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua
@@ -38,7 +38,7 @@ if not modules then modules = { } end modules ['typo-lin'] = {
-- But, maybe there are good reasons for having just that anchor (mostly for educational purposes
-- I guess.)
--
--- At this stage the localpar node is no longer of any use so we remove it (each line has the
+-- At this stage the par node is no longer of any use so we remove it (each line has the
-- direction attached). We might at some point also strip the disc nodes as they no longer serve
-- a purpose but that can better be a helper. Anchoring left has advantage of keeping page
-- stream.
@@ -65,7 +65,7 @@ local hlist_code = nodecodes.hlist
local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
local linelist_code = listcodes.line
------ localpar_code = nodecodes.localpar
+----- par_code = nodecodes.par
local leftskip_code = gluecodes.leftskip
local rightskip_code = gluecodes.rightskip
local parfillskip_code = gluecodes.parfillskip
@@ -123,10 +123,10 @@ local getreserved = jobpositions.getreserved
local paragraphs = { }
typesetters.paragraphs = paragraphs
-local addskips = false
+local addskips = false -- todo: use engine normalizer
local noflines = 0
--- This is the third version, a mix between immediate (prestice lines) and delayed
+-- This is the third version, a mix between immediate (prestine lines) and delayed
-- as we don't want anchors that are not used.
-- I will make a better variant once lmtx is stable i.e. less clutter.
@@ -185,7 +185,7 @@ local function normalize(line,islocal) -- assumes prestine lines, nothing pre/ap
id = getid(current)
end
-- no:
- -- if id == localpar_code then
+ -- if id == par_code then
-- head = remove_node(head,head,true)
-- end
local tail = find_tail(head)
@@ -236,6 +236,8 @@ function paragraphs.checkline(n)
return getprop(n,"line") or normalize(n,true)
end
+-- do we still need this:
+
function paragraphs.normalize(head,islocal)
if texgetcount("pagebodymode") > 0 then
-- can be an option, maybe we need a proper state in lua itself ... is this check still needed?
@@ -482,7 +484,7 @@ function paragraphs.calculatedelta(n,width,delta,atleft,islocal,followshape,area
addanchortoline(line,setanchor(number))
line.hanchor = true
end
- local blob = getposition(s_anchor,number)
+ local blob = getposition("md:h",number)
if blob then
local reference = getreserved(area,blob.c)
if reference then
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-mar.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-mar.mkiv
index 921f1f230c3..95010ab8eaa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-mar.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-mar.mkiv
@@ -161,8 +161,6 @@
% trialtypesetting: no need for margin stuff while trialing as
% is has no dimensions
-\definesystemconstant{margintext}
-
\newcount\nofmargintexts
\definepagestate[\s!margintext]
@@ -337,7 +335,7 @@
{\endgraf\ifhmode\space\fi}
\appendtoks
- \let\\\spaceorpar
+ \enforced\let\\\spaceorpar
\to \everymargindatacontent
%D Another one:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-ovl.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-ovl.mkiv
index 025ae8a8f9c..767ba3569d4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-ovl.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-ovl.mkiv
@@ -55,7 +55,7 @@
{\ifcsname\??overloads#1\endcsname\else
\typo_overloads_define{#1}%
\fi
- \attribute\overloadsattribute\csname\??overloads#1\endcsname}
+ \c_attr_overloads\csname\??overloads#1\endcsname}
\unexpanded\def\registeroverloads[#1]%
{\ifcsname\??overloads#1\endcsname\else
@@ -63,7 +63,7 @@
\fi}
\unexpanded\def\resetoverloads
- {\overloadsattribute\attributeunsetvalue}
+ {\c_attr_overloads\attributeunsetvalue}
%D We hook this into the replacement module, probably the only place where it makes
%D sense. Here is an adapted version of an example:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-plc.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-plc.mkiv
new file mode 100644
index 00000000000..dbc9f081db6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-plc.mkiv
@@ -0,0 +1,39 @@
+%D \module
+%D [ file=typo-plc,
+%D version=2020.07.01,
+%D title=\CONTEXT\ Typesetting Macros,
+%D subtitle=Placeholders,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Typesetting Macros / Placeholders}
+
+\unprotect
+
+\installcorenamespace {placeholder}
+
+\installcommandhandler \??placeholder {placeholder} \??placeholder
+
+\unexpanded\def\placeholder[#1]%
+ {\begingroup
+ \edef\currentplaceholder{#1}%
+ \placeholderparameter\c!before
+ \useplaceholderstyleandcolor\c!style\c!color
+ \placeholderparameter\c!text
+ \placeholderparameter\c!after
+ \endgroup}
+
+\defineplaceholder
+ [todo]
+ %[\c!text={Still to be written!},
+ [\c!text=todo, % labeltext ?
+ \c!style=\v!bold,
+ \c!before=\blank,
+ \c!after=\blank]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.mkiv
index 39d0c85f438..f2c588912f4 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.mkiv
@@ -39,7 +39,7 @@
{\clf_setperiodkerning{\periodkerningparameter\c!factor}}
\unexpanded\def\resetperiodkerning % fast one
- {\attribute\periodkernattribute\attributeunsetvalue}
+ {\c_attr_periodkern\attributeunsetvalue}
\appendtoks
\resetperiodkerning
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-rep.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-rep.mkiv
index df840899914..71ab9ffa9d1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-rep.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-rep.mkiv
@@ -41,7 +41,7 @@
{\clf_setcharacterstripping{#1}}
\unexpanded\def\resetcharacterstripping
- {\attribute\strippingattribute\attributeunsetvalue}
+ {\c_attr_stripping\attributeunsetvalue}
% maybe .. this might disappear, but is handy for testing
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-rub.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-rub.lua
index da63d7b64e9..6c6ab9a3334 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-rub.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-rub.lua
@@ -63,7 +63,7 @@ local glue_code = nodecodes.glue
local penalty_code = nodecodes.penalty
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local dir_code = nodecodes.dir
local kerncodes = nodes.kerncodes
@@ -310,7 +310,7 @@ local function whatever(current)
-- go on
elseif id == hlist_code and getwidth(c) == 0 then
-- go on
- elseif id == whatsit_code or id == localpar_code or id == dir_code then
+ elseif id == whatsit_code or id == par_code or id == dir_code then
-- go on
else
l = false
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-spa.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-spa.mkiv
index fc73ef02185..682830150fb 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-spa.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-spa.mkiv
@@ -58,7 +58,7 @@
{\clf_setcharacterspacing{#1}}
\unexpanded\def\resetcharacterspacing % fast one
- {\attribute\spacingattribute\attributeunsetvalue}
+ {\c_attr_spacing\attributeunsetvalue}
\appendtoks
\resetcharacterspacing
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-tal.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-tal.lua
index ff10fb12103..db605a4916d 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-tal.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-tal.lua
@@ -51,7 +51,6 @@ local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local nextglyph = nuts.traversers.glyph
local getdimensions = nuts.dimensions
-local first_glyph = nuts.first_glyph
local setglue = nuts.setglue
@@ -174,7 +173,6 @@ function characteralign.handler(head,where)
if not datasets then
return head
end
- -- local first = first_glyph(head) -- we could do that once
local first
for n in nextglyph, head do
first = n
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-tal.mkiv b/Master/texmf-dist/tex/context/base/mkiv/typo-tal.mkiv
index 33e071e7537..36e78aee05c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-tal.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-tal.mkiv
@@ -56,10 +56,10 @@
% D
% D \typebuffer \blank \getbuffer \blank
-\unexpanded\def\signalcharacteralign #1#2{\attribute\characteralignattribute\numexpr#1*\maxcardminusone+#2\relax} % 0xFFFF
+\unexpanded\def\signalcharacteralign #1#2{\c_attr_characteralign\numexpr#1*\maxcardminusone+#2\relax} % 0xFFFF
\unexpanded\def\setcharacteralign #1#2{\clf_setcharacteralign#1{#2}}
\unexpanded\def\resetcharacteralign {\clf_resetcharacteralign}
-\unexpanded\def\nocharacteralign {\attribute\characteralignattribute\attributeunsetvalue}
+\unexpanded\def\nocharacteralign {\c_attr_characteralign\attributeunsetvalue}
\unexpanded\def\setcharacteraligndetail#1#2#3#4{\clf_setcharacteraligndetail#1{#2}#3#4\relax}
%D Mostly downward compatible:
diff --git a/Master/texmf-dist/tex/context/base/mkiv/unic-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/unic-ini.mkiv
index 684e3aa0491..a48bd6ad7f5 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/unic-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/unic-ini.mkiv
@@ -17,7 +17,7 @@
\unprotect
-\def\unicodenumber #1{\the \numexpr#1\relax} % no lookahead
+\def\unicodenumber #1{\the\numexpr#1\relax} % no lookahead
\def\unicodehexnumber#1{\cldcontext{number.toevenhex(\number#1))}}
%D \startbuffer
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-dim.lua b/Master/texmf-dist/tex/context/base/mkiv/util-dim.lua
index 76b5fd20bb3..bb9eca96688 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-dim.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-dim.lua
@@ -44,8 +44,8 @@ local dimenfactors = allocate {
["pc"] = ( 1/ 12)/65536,
["dd"] = ( 1157/ 1238)/65536,
["cc"] = ( 1157/14856)/65536,
- ["nd"] = (20320/21681)/65536,
- ["nc"] = ( 5080/65043)/65536
+ -- ["nd"] = (20320/21681)/65536,
+ -- ["nc"] = ( 5080/65043)/65536
}
-- print(table.serialize(dimenfactors))
@@ -61,9 +61,9 @@ local dimenfactors = allocate {
-- ["ex"]=6.103515625e-005,
-- ["in"]=2.1113586636917117e-007,
-- ["mm"]=5.3628510057769473e-008,
--- ["nc"]=1.1917446679504327e-006,
--- ["nd"]=1.4300936015405194e-005,
--- ["pc"]=1.2715657552083333e-006,
+-- --["nc"]=1.1917446679504327e-006,
+-- --["nd"]=1.4300936015405194e-005,
+-- --["pc"]=1.2715657552083333e-006,
-- ["pt"]=1.52587890625e-005,
-- ["sp"]=1,
-- }
@@ -79,8 +79,8 @@ local dimenfactors = allocate {
-- ["ex"]=0.00006103515625,
-- ["in"]=0.00000021113587,
-- ["mm"]=0.00000005362851,
--- ["nc"]=0.00000119174467,
--- ["nd"]=0.00001430093602,
+-- --["nc"]=0.00000119174467,
+-- --["nd"]=0.00001430093602,
-- ["pc"]=0.00000127156576,
-- ["pt"]=0.00001525878906,
-- ["sp"]=1,
@@ -128,8 +128,8 @@ function number.tobasepoints (n,fmt) return numbertodimen(n,"bp",fmt) end
function number.topicas (n,fmt) return numbertodimen(n "pc",fmt) end
function number.todidots (n,fmt) return numbertodimen(n,"dd",fmt) end
function number.tociceros (n,fmt) return numbertodimen(n,"cc",fmt) end
-function number.tonewdidots (n,fmt) return numbertodimen(n,"nd",fmt) end
-function number.tonewciceros (n,fmt) return numbertodimen(n,"nc",fmt) end
+-------- number.tonewdidots (n,fmt) return numbertodimen(n,"nd",fmt) end
+-------- number.tonewciceros (n,fmt) return numbertodimen(n,"nc",fmt) end
--[[ldx--
More interesting it to implement a (sort of) dimen datatype, one
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua b/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua
index 79af277437b..183f7bea81f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['util-fil'] = {
version = 1.001,
+ optimize = true,
comment = "companion to luat-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-lib.lua b/Master/texmf-dist/tex/context/base/mkiv/util-lib.lua
index a49507c6060..be763d92e91 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-lib.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-lib.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['util-lib'] = {
license = "see context related readme files",
}
+-- not used in context any more
+
--[[
The problem with library bindings is manyfold. They are of course platform
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua b/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua
index 3154bf6c28d..6d2f8c19e06 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua
@@ -10,7 +10,7 @@ local lpeg, table, string = lpeg, table, string
local P, R, V, S, C, Ct, Cs, Carg, Cc, Cg, Cf, Cp = lpeg.P, lpeg.R, lpeg.V, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.Cp
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
local concat, gmatch, find = table.concat, string.gmatch, string.find
-local tostring, type, next, rawset = tostring, type, next, rawset
+local tonumber, tostring, type, next, rawset = tonumber, tostring, type, next, rawset
local mod, div = math.mod, math.div
utilities = utilities or {}
@@ -373,6 +373,8 @@ hashes.settings_to_set = table.setmetatableindex(function(t,k) -- experiment, n
return v
end)
+-- as we use a next, we are not sure when the gc kicks in
+
getmetatable(hashes.settings_to_set).__mode = "kv" -- could be an option (maybe sharing makes sense)
function parsers.simple_hash_to_string(h, separator)
@@ -538,13 +540,15 @@ function parsers.csvsplitter(specification)
specification = specification and setmetatableindex(specification,defaultspecification) or defaultspecification
local separator = specification.separator
local quotechar = specification.quote
+ local numbers = specification.numbers
local separator = S(separator ~= "" and separator or ",")
local whatever = C((1 - separator - newline)^0)
if quotechar and quotechar ~= "" then
local quotedata = nil
for chr in gmatch(quotechar,".") do
local quotechar = P(chr)
- local quoteword = quotechar * C((1 - quotechar)^0) * quotechar
+ local quoteitem = (1 - quotechar)^0
+ local quoteword = quotechar * (numbers and (quoteitem/tonumber) or C(quoteitem)) * quotechar
if quotedata then
quotedata = quotedata + quoteword
else
@@ -559,29 +563,29 @@ function parsers.csvsplitter(specification)
end
end
--- and this is a slightly patched version of a version posted by Philipp Gesang
-
--- local mycsvsplitter = parsers.rfc4180splitter()
-
-- local crap = [[
-- first,second,third,fourth
-- "1","2","3","4"
--- "a","b","c","d"
--- "foo","bar""baz","boogie","xyzzy"
+-- "5","6","7","8"
-- ]]
+--
+-- local mycsvsplitter = parsers.csvsplitter { numbers = true }
+--
+-- local list = mycsvsplitter(crap) inspect(list)
--- local list, names = mycsvsplitter(crap,true) inspect(list) inspect(names)
--- local list, names = mycsvsplitter(crap) inspect(list) inspect(names)
+-- and this is a slightly patched version of a version posted by Philipp Gesang
function parsers.rfc4180splitter(specification)
specification = specification and setmetatableindex(specification,defaultspecification) or defaultspecification
+ local numbers = specification.numbers
local separator = specification.separator --> rfc: COMMA
local quotechar = P(specification.quote) --> DQUOTE
local dquotechar = quotechar * quotechar --> 2DQUOTE
/ specification.quote
local separator = S(separator ~= "" and separator or ",")
+ local whatever = (dquotechar + (1 - quotechar))^0
local escaped = quotechar
- * Cs((dquotechar + (1 - quotechar))^0)
+ * (numbers and (whatever/tonumber) or Cs(whatever))
* quotechar
local non_escaped = C((1 - quotechar - newline - separator)^1)
local field = escaped + non_escaped + Cc("")
@@ -601,6 +605,18 @@ function parsers.rfc4180splitter(specification)
end
end
+-- local mycsvsplitter = parsers.rfc4180splitter { numbers = true }
+--
+-- local crap = [[
+-- first,second,third,fourth
+-- "1","2","3","4"
+-- "a","b","c","d"
+-- "foo","bar""baz","boogie","xyzzy"
+-- ]]
+--
+-- local list, names = mycsvsplitter(crap,true) inspect(list) inspect(names)
+-- local list, names = mycsvsplitter(crap) inspect(list) inspect(names)
+
-- parsers.stepper("1,7-",9,function(i) print(">>>",i) end)
-- parsers.stepper("1-3,7,8,9")
-- parsers.stepper("1-3,6,7",function(i) print(">>>",i) end)
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua b/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua
index 47c753ab18b..a8851f4c835 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['util-sac'] = {
version = 1.001,
+ optimize = true,
comment = "companion to luat-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-soc-imp-http.lua b/Master/texmf-dist/tex/context/base/mkiv/util-soc-imp-http.lua
index c3a28be822a..d8f45880e7f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-soc-imp-http.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-soc-imp-http.lua
@@ -59,7 +59,7 @@ local function receiveheaders(sock, headers)
headers = { }
end
-- get first line
- local line, err = sock:receive()
+ local line, err = sock:receive("*l") -- this seems to be wrong!
if err then
return nil, err
end
@@ -72,14 +72,14 @@ local function receiveheaders(sock, headers)
end
name = lower(name)
-- get next line (value might be folded)
- line, err = sock:receive()
+ line, err = sock:receive("*l")
if err then
return nil, err
end
-- unfold any folded values
while find(line, "^%s") do
value = value .. line
- line = sock:receive()
+ line = sock:receive("*l")
if err then
return nil, err
end
@@ -103,7 +103,7 @@ socket.sourcet["http-chunked"] = function(sock, headers)
dirty = function() return sock:dirty() end,
}, {
__call = function()
- local line, err = sock:receive()
+ local line, err = sock:receive("*l")
if err then
return nil, err
end
@@ -114,7 +114,7 @@ socket.sourcet["http-chunked"] = function(sock, headers)
if size > 0 then
local chunk, err, part = sock:receive(size)
if chunk then
- sock:receive()
+ sock:receive("*a")
end
return chunk, err
else
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-str.lua b/Master/texmf-dist/tex/context/base/mkiv/util-str.lua
index aba7859c31e..0d1f39de9d7 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-str.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-str.lua
@@ -70,27 +70,63 @@ local function points(n)
n = n * ptf
if n % 1 == 0 then
return format("%ipt",n)
+ else
+ return lpegmatch(stripzeros,format("%.5fpt",n)) -- plural as we need to keep the pt
+ end
+end
+
+local function nupoints(n)
+ if n == 0 then
+ return "0"
+ end
+ n = tonumber(n)
+ if not n or n == 0 then
+ return "0"
+ end
+ n = n * ptf
+ if n % 1 == 0 then
+ return format("%i",n)
+ else
+ return format("%.5f",n) -- no strip
end
- return lpegmatch(stripzeros,format("%.5fpt",n)) -- plural as we need to keep the pt
end
local function basepoints(n)
if n == 0 then
- return "0pt"
+ return "0bp"
end
n = tonumber(n)
if not n or n == 0 then
- return "0pt"
+ return "0bp"
end
n = n * bpf
if n % 1 == 0 then
return format("%ibp",n)
+ else
+ return lpegmatch(stripzeros,format("%.5fbp",n)) -- plural as we need to keep the pt
end
- return lpegmatch(stripzeros,format("%.5fbp",n)) -- plural as we need to keep the pt
end
-number.points = points
-number.basepoints = basepoints
+local function nubasepoints(n)
+ if n == 0 then
+ return "0"
+ end
+ n = tonumber(n)
+ if not n or n == 0 then
+ return "0"
+ end
+ n = n * bpf
+ if n % 1 == 0 then
+ return format("%i",n)
+ else
+ return format("%.5f",n) -- no strip
+ end
+end
+
+number.points = points
+number.nupoints = nupoints
+number.basepoints = basepoints
+number.nubasepoints = nubasepoints
-- str = " \n \ntest \n test\ntest "
-- print("["..string.gsub(string.collapsecrlf(str),"\n","+").."]")
@@ -357,7 +393,9 @@ end
-- U+hexadecimal %...u character number
-- U+HEXADECIMAL %...U character number
-- points %p number (scaled points)
+-- nupoints %P number (scaled points) / without unit / always 5 decimals
-- basepoints %b number (scaled points)
+-- nubasepoints %B number (scaled points) / without unit / always 5 decimals
-- table concat %...t table
-- table concat %{.}t table
-- serialize %...T sequenced (no nested tables)
@@ -616,7 +654,9 @@ local environment = {
concat = table.concat,
signed = number.signed,
points = number.points,
+ nupoints = number.nupoints,
basepoints = number.basepoints,
+ nubasepoints = number.nubasepoints,
utfchar = utf.char,
utfbyte = utf.byte,
lpegmatch = lpeg.match,
@@ -879,11 +919,21 @@ local format_p = function()
return format("points(a%s)",n)
end
+local format_P = function()
+ n = n + 1
+ return format("nupoints(a%s)",n)
+end
+
local format_b = function()
n = n + 1
return format("basepoints(a%s)",n)
end
+local format_B = function()
+ n = n + 1
+ return format("nubasepoints(a%s)",n)
+end
+
local format_t = function(f)
n = n + 1
if f and f ~= "" then
@@ -1057,76 +1107,44 @@ local format_rest = function(s)
return format("%q",s) -- catches " and \n and such
end
--- local format_extension = function(extensions,f,name)
--- local extension = extensions[name] or "tostring(%s)"
--- local f = tonumber(f) or 1
--- local w = find(extension,"%.%.%.")
--- if f == 0 then
--- if w then
--- extension = gsub(extension,"%.%.%.","")
--- end
--- return extension
--- elseif f == 1 then
--- if w then
--- extension = gsub(extension,"%.%.%.","%%s")
--- end
--- n = n + 1
--- local a = "a" .. n
--- return format(extension,a,a) -- maybe more times?
--- elseif f < 0 then
--- local a = "a" .. (n + f + 1)
--- return format(extension,a,a)
--- else
--- if w then
--- extension = gsub(extension,"%.%.%.",rep("%%s,",f-1).."%%s")
--- end
--- -- we could fill an array and then n = n + 1 unpack(t,n,n+f) but as we
--- -- cache we don't save much and there are hardly any extensions anyway
--- local t = { }
--- for i=1,f do
--- n = n + 1
--- -- t[#t+1] = "a" .. n
--- t[i] = "a" .. n
--- end
--- return format(extension,unpack(t))
--- end
--- end
-
local format_extension = function(extensions,f,name)
local extension = extensions[name] or "tostring(%s)"
local f = tonumber(f) or 1
local w = find(extension,"%.%.%.")
- if w then
- -- we have a wildcard
- if f == 0 then
+ if f == 0 then
+ if w then
extension = gsub(extension,"%.%.%.","")
- return extension
- elseif f == 1 then
+ end
+ return extension
+ elseif f == 1 then
+ if w then
extension = gsub(extension,"%.%.%.","%%s")
- n = n + 1
- local a = "a" .. n
- return format(extension,a,a) -- maybe more times?
- elseif f < 0 then
+ end
+ n = n + 1
+ local a = "a" .. n
+ return format(extension,a,a) -- maybe more times?
+ elseif f < 0 then
+ if w then
+ -- not supported
+ extension = gsub(extension,"%.%.%.","")
+ return extension
+ else
local a = "a" .. (n + f + 1)
return format(extension,a,a)
- else
- extension = gsub(extension,"%.%.%.",rep("%%s,",f-1).."%%s")
- -- we could fill an array and then n = n + 1 unpack(t,n,n+f) but as we
- -- cache we don't save much and there are hardly any extensions anyway
- local t = { }
- for i=1,f do
- n = n + 1
- -- t[#t+1] = "a" .. n
- t[i] = "a" .. n
- end
- return format(extension,unpack(t))
end
else
- extension = gsub(extension,"%%s",function()
+ if w then
+ extension = gsub(extension,"%.%.%.",rep("%%s,",f-1).."%%s")
+ end
+ -- we could fill an array and then n = n + 1 unpack(t,n,n+f) but as we
+ -- cache we don't save much and there are hardly any extensions anyway
+ local t = { }
+ for i=1,f do
n = n + 1
- return "a" .. n
- end)
- return extension
+ -- t[#t+1] = "a" .. n
+ t[i] = "a" .. n
+ end
+ return format(extension,unpack(t))
end
end
@@ -1157,7 +1175,7 @@ local builder = Cs { "start",
--
+ V("r")
+ V("h") + V("H") + V("u") + V("U")
- + V("p") + V("b")
+ + V("p") + V("P") + V("b") + V("B")
+ V("t") + V("T")
+ V("l") + V("L")
+ V("I")
@@ -1206,8 +1224,10 @@ local builder = Cs { "start",
["H"] = (prefix_any * P("H")) / format_H, -- %H => 0x0A1B2 (when - no 0x) was V
["u"] = (prefix_any * P("u")) / format_u, -- %u => u+0a1b2 (when - no u+)
["U"] = (prefix_any * P("U")) / format_U, -- %U => U+0A1B2 (when - no U+)
- ["p"] = (prefix_any * P("p")) / format_p, -- %p => 12.345pt / maybe: P (and more units)
- ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp / maybe: B (and more units)
+ ["p"] = (prefix_any * P("p")) / format_p, -- %p => 12.345pt
+ ["P"] = (prefix_any * P("P")) / format_P, -- %p => 12.345
+ ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp
+ ["B"] = (prefix_any * P("B")) / format_B, -- %b => 12.342
["t"] = (prefix_tab * P("t")) / format_t, -- %t => concat
["T"] = (prefix_tab * P("T")) / format_T, -- %t => sequenced
["l"] = (prefix_any * P("l")) / format_l, -- %l => boolean
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-tab.lua b/Master/texmf-dist/tex/context/base/mkiv/util-tab.lua
index 4dafb2acd65..9f7112eb915 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-tab.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-tab.lua
@@ -961,3 +961,12 @@ function table.ordered(t)
return function() end
end
end
+
+-- function table.randomremove(t,n)
+-- if not n then
+-- n = #t
+-- end
+-- if n > 0 then
+-- return remove(t,random(1,n))
+-- end
+-- end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-bar.mkxl b/Master/texmf-dist/tex/context/base/mkxl/anch-bar.mkxl
new file mode 100644
index 00000000000..3587eb8a052
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-bar.mkxl
@@ -0,0 +1,220 @@
+%D \module
+%D [ file=anch-bar,
+%D version=2003.03.16,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Margin Bars and alike,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Margin Bars}
+
+\unprotect
+
+%D This can be done better now ...
+
+%D We will implement a sidebar mechanism using the functionality from
+%D \type {core-pos}.
+%D
+%D \starttyping
+%D \definesidebar[whow][rulecolor=green,distance=0pt]
+%D
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar[whow]
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte \par
+%D \input tufte
+%D \stopsidebar \par
+%D \input tufte \par
+%D \input tufte \par
+%D \startsidebar
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \input tufte
+%D \stopsidebar
+%D \stoptyping
+
+\installcorenamespace{sidebar}
+
+\installcommandhandler \??sidebar {sidebar} \??sidebar
+
+\newcount\c_anch_sidebars_n
+\newcount\c_anch_sidebars_current % local
+\newdimen\d_anch_sidebars_distance
+\newcount\c_anch_sidebars_level
+
+% \setupMPvariables
+% [mpos:sidebar]
+% [linecolor=red,
+% linewidth=2pt,
+% distance=5pt]
+
+\setupsidebar
+ [\c!rulethickness=\dimexpr\bodyfontsize/6\relax, % 2pt default
+ \c!rulecolor=\s!black,
+ \c!alternative=0,
+ \c!topoffset=\zeropoint,
+ \c!bottomoffset=\zeropoint,
+ \c!distance=.5\bodyfontsize,
+ \c!level=,
+ \c!leftmargindistance=\zeropoint]
+
+\aliased\let\setupsidebars\setupsidebar
+
+\permanent\tolerant\protected\def\startsidebar[#1]#*[#2]%
+ {\bgroup
+ \dontleavehmode
+ \advance\c_anch_sidebars_level\plusone
+ \global\advance\c_anch_sidebars_n\plusone
+ \c_anch_sidebars_current\c_anch_sidebars_n\relax % relax needed
+ \ifhastok={#1}%
+ \edef\currentsidebar{\the\c_anch_sidebars_level}%
+ \checksidebarparent
+ \setupcurrentsidebar[#1]%
+ \else
+ \def\currentsidebar{#1}%
+ \setupcurrentsidebar[#2]%
+ \fi
+ \scratchdistance\sidebarparameter\c!distance\relax
+ \scratchdimen\sidebarparameter\c!leftmargindistance\relax
+ \edef\m_level{\sidebarparameter\c!level}%
+ \ifempty\m_level
+ \ifnum\c_anch_sidebars_level=\plusone
+ \ifzeropt\scratchdimen
+ \advance\d_anch_sidebars_distance\scratchdistance\relax
+ \else
+ \d_anch_sidebars_distance\scratchdimen
+ \fi
+ \else
+ \advance\d_anch_sidebars_distance\scratchdistance\relax
+ \fi
+ \else
+ \ifnum\m_level=\plusone
+ \ifzeropt\scratchdimen
+ \advance\d_anch_sidebars_distance\scratchdistance\relax
+ \else
+ \d_anch_sidebars_distance\scratchdimen
+ \fi
+ \else
+ \d_anch_sidebars_distance\dimexpr\scratchdimen+\numexpr\m_level-\plusone\relax\dimexpr\scratchdistance\relax\relax
+ \fi
+ \fi
+ \startpositionoverlay{\v!text-1}%
+ \normalexpanded{\setMPpositiongraphicrange % maybe expand in definition
+ {b:sidebar:\the\c_anch_sidebars_n}%
+ {e:sidebar:\the\c_anch_sidebars_n}%
+ {mpos:sidebar}%
+ {self=sidebar:\the\c_anch_sidebars_n,
+ linewidth=\sidebarparameter\c!rulethickness,
+ linecolor=\sidebarparameter\c!rulecolor,
+ alternative=\sidebarparameter\c!alternative,
+ topoffset=\the\dimexpr\sidebarparameter\c!topoffset,
+ bottomoffset=\the\dimexpr\sidebarparameter\c!bottomoffset,
+ distance=\the\d_anch_sidebars_distance}%
+ }%
+ \stoppositionoverlay
+ \bpos{sidebar:\the\c_anch_sidebars_current}%
+ \ignorespaces}
+
+\permanent\protected\def\stopsidebar
+ {\removelastspace
+ \epos{sidebar:\the\c_anch_sidebars_current}
+ \carryoverpar\egroup}
+
+%D Let's keep this nice and simple (okay, we could pass the 6 variables in
+%D one lua call).
+
+\startMPpositionmethod{mpos:sidebar}
+ \startMPpositiongraphic{mpos:sidebar}{linecolor,linewidth,distance,alternative}%
+ anch_sidebars_draw (
+ \MPp\MPbself,\MPp\MPeself,\MPy\MPbself,\MPy\MPeself,\MPh\MPbself,\MPd\MPeself,
+ \MPx{\textanchor},\MPy{\textanchor},\MPw{\textanchor},\MPh{\textanchor},
+ \MPvar{alternative},\MPvar{distance},\MPvar{linewidth},\MPvar{linecolor},
+ \MPvar{topoffset}, \MPvar{bottomoffset}
+ ) ;
+ \stopMPpositiongraphic
+ \MPpositiongraphic{mpos:sidebar}{}%
+\stopMPpositionmethod
+
+%D We now reimplement the \MKII\ margin rules handler in a more
+%D modern way.
+%D
+%D \setupmarginrules
+%D [rulecolor=darkred,
+%D rulethickness=2pt]
+%D
+%D \setupmarginrules % sidebar
+%D [2]
+%D [rulecolor=darkblue]
+%D
+%D \startmarginrule[1]
+%D \input ward
+%D \startmarginrule[2]
+%D \input ward
+%D \startmarginrule[3]
+%D \input ward
+%D \startmarginrule[level=6,rulecolor=darkgreen]
+%D \input ward
+%D \stopmarginrule
+%D \input ward
+%D \stopmarginrule
+%D \input ward
+%D \stopmarginrule
+%D \input ward
+%D \stopmarginrule
+%D
+%D Compared to the old mechanism we now can pass settings too.
+
+\definesidebar
+ [\v!margin]
+ [\c!leftmargindistance=\dimexpr\leftmargindistance+\sidebarparameter\c!rulethickness/2\relax]
+
+\dorecurse{5}{\definesidebar[\v!margin:#1][\v!margin]} % let's be nice and predefine 5 levels
+
+\permanent\tolerant\protected\def\setupmarginrule[#1]#*[#2]%
+ {\ifarguments\or
+ \setupsidebar[\v!margin][#1]%
+ \or
+ \setupsidebar[\v!margin:#1][#2]%
+ \fi}
+
+\aliased\let\setupmarginrules\setupmarginrule
+
+\permanent\tolerant\protected\def\startmarginrule[#1]% pretty inefficient checking
+ {\edef\m_anch_marginrules_kind{#1}%
+ \ifempty\m_anch_marginrules_kind
+ \startsidebar[\v!margin][]%
+ \orelse\ifhastok={\m_anch_marginrules_kind}%
+ \startsidebar[\v!margin][#1]%
+ \else
+ \anch_marginrules_check{#1}%
+ \startsidebar[\v!margin:#1][\c!level=#1]%
+ \fi}
+
+\def\anch_marginrules_check#1%
+ {\doifnotcommandhandler\??sidebar{\v!margin:#1}{\definesidebar[\v!margin:#1][\v!margin]}}
+
+\aliased\let\stopmarginrule\stopsidebar
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-bck.mklx b/Master/texmf-dist/tex/context/base/mkxl/anch-bck.mklx
new file mode 100644
index 00000000000..36416c93da3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-bck.mklx
@@ -0,0 +1,775 @@
+%D \module
+%D [ file=anch-bck, % moved from anch-pgr (1999.08.01)
+%D version=2011.12.19,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Backgrounds,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% when tested for a while: \MPgetmultipars -> getmultipars
+% when tested for a while: \MPvar -> mpvar
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Backgrounds}
+
+%D This module is quite okay but at some point I might add methods that use
+%D attributes although not too much is to be expected, apart from better anchoring.
+%D In fact better anchoring can be done independent of that.
+
+\unprotect
+
+% This might be overloaded later on:
+
+% \defineoverlay[\v!text-2][\positionoverlay{\v!text-2}]
+% \defineoverlay[\v!text-1][\positionoverlay{\v!text-1}]
+% \defineoverlay[\v!text+1][\positionoverlay{\v!text+1}]
+% \defineoverlay[\v!text+2][\positionoverlay{\v!text+2}]
+
+% Paragraph positions:
+
+\newcount\c_anch_backgrounds_text_n
+
+\def\v_anch_backgrounds_text_current {tbg:0}
+\def\v_anch_backgrounds_anchor_current_b{b:\v_anch_backgrounds_text_current}
+\def\v_anch_backgrounds_anchor_current_e{e:\v_anch_backgrounds_text_current}
+
+\def\anch_backgrounds_text_initialize_next
+ {\global\advance\c_anch_backgrounds_text_n\plusone
+ \edef\v_anch_backgrounds_text_current{tbg:\number\c_anch_backgrounds_text_n}}
+
+% The first position can be used in the middle of a paragraph in which case we're
+% too late with initializing par positions. Therefore we check if positions are
+% used at all.
+%
+% tricky: we need to catch newly set! otherwise an old run can have positions
+
+\protected\def\anch_backgrounds_text_initialize
+ {\doifelsepositionsused\enableparpositions\donothing
+ \glet\anch_backgrounds_text_initialize\relax}
+
+\appendtoks
+ \anch_backgrounds_text_initialize
+\to \everystarttext
+
+%D Some MP
+
+\newcount\MPparcounter
+
+\permanent\def\MPself {\MPvar{self}}
+\permanent\def\MPbself {b:\MPvar{self}}
+\permanent\def\MPeself {e:\MPvar{self}}
+\permanent\def\MPparanchor{p:\number\MPparcounter}
+
+% \carryoverpar is needed for left/right floats
+
+% \definetextbackground[more][state=start,backgroundcolor=red] % location=paragraph
+% \definetextbackground[test][state=start,backgroundcolor=green]
+%
+% \page \placefigure[left]{}{}
+%
+% \starttextbackground[test]
+% \readfile{ward}{}{}
+% \starttextbackground[more]
+% \readfile{ward}{}{}
+% \stoptextbackground
+% \readfile{ward}{}{}
+% \stoptextbackground
+%
+% \page \placefigure[right]{}{}
+%
+% \starttextbackground[test]
+% \readfile{ward}{}{}
+% \starttextbackground[more]
+% \readfile{ward}{}{}
+% \stoptextbackground
+% \readfile{ward}{}{}
+% \stoptextbackground
+
+\newcount\c_anch_backgrounds_text_level
+
+\installcorenamespace{textbackground}
+\installcorenamespace{textbackgroundlevel}
+
+\installcommandhandler \??textbackground {textbackground} \??textbackground
+
+\appendtoks
+ \frozen\instance\setuevalue{\currenttextbackground}{\groupedcommand{\starttextbackground[\currenttextbackground]}{\stoptextbackground}}%
+ \frozen\instance\setuevalue{\e!start\currenttextbackground}{\starttextbackground[\currenttextbackground]}%
+ \frozen\instance\setuevalue{\e!stop \currenttextbackground}{\stoptextbackground}%
+\to \everydefinetextbackground
+
+\newconstant \c_anch_backgrounds_pos_state
+\newconditional\c_anch_backgrounds_pos_no_shape
+
+\def\anch_backgrounds_bpos
+ {\ifconditional\c_anch_backgrounds_pos_no_shape
+ \bposkind\v_anch_backgrounds_text_current\plusthree
+ \else
+ \bposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state
+ \fi}
+
+\def\anch_backgrounds_epos
+ {\ifconditional\c_anch_backgrounds_pos_no_shape
+ \eposkind\v_anch_backgrounds_text_current\plusthree
+ \else
+ \eposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state
+ \fi}
+
+% \permanent\tolerant\protected\def\starttextbackground[#tag]#spacer[#settings]%
+% {\begingroup
+% \advance\c_anch_backgrounds_text_level\plusone
+% \def\currenttextbackground{#tag}%
+% \anch_backgrounds_text_initialize_next
+% \ifparameter#settings\or
+% \setupcurrenttextbackground[#settings]%
+% \fi
+% \doifelse{\textbackgroundparameter\c!state}\v!start
+% \anch_backgrounds_text_preset_yes
+% \anch_backgrounds_text_preset_nop
+% \anch_backgrounds_text_start_indeed}
+
+% ugly hack to register usage
+
+\newcount \c_anch_backgrounds_text_count
+\newcount \c_anch_backgrounds_text_check
+\newconstant\c_anch_backgrounds_text_state
+
+\permanent\tolerant\protected\def\starttextbackground[#tag]#spacer[#settings]%
+ {\begingroup
+ \global\advance\c_anch_backgrounds_text_count\plusone
+ \advance\c_anch_backgrounds_text_level\plusone
+ \def\currenttextbackground{#tag}%
+ \anch_backgrounds_text_initialize_next
+ \ifparameter#settings\or
+ \setupcurrenttextbackground[#settings]%
+ \fi
+ \doifelse{\textbackgroundparameter\c!state}\v!start
+ \anch_backgrounds_text_preset_yes
+ \anch_backgrounds_text_preset_nop
+ \anch_backgrounds_text_start_indeed}
+
+\def\anch_backgrounds_text_level_start
+ {\c_anch_backgrounds_text_check\c_anch_backgrounds_text_count}
+
+\def\anch_backgrounds_text_level_stop
+ {\c_anch_backgrounds_text_state
+ \ifnum\c_anch_backgrounds_text_count>\c_anch_backgrounds_text_check
+ \plusone
+ \else
+ \zerocount
+ \fi}
+
+% todo \backgroundvariable\c!variant
+
+% criterium determines when we fall back on text
+% always is always forcing paragraphs
+
+\let\anch_backgrounds_text_start_indeed\relax
+\let\anch_backgrounds_text_stop_indeed \relax
+
+\setvalue{\??textbackgroundlevel\v!text}%
+ {\let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_txt
+ \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_txt}
+
+\setvalue{\??textbackgroundlevel\v!paragraph}%
+ {\ifnum\c_anch_backgrounds_text_level>\textbackgroundparameter\c!criterium\relax
+ \let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_txt
+ \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_txt
+ \else
+ \let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_par
+ \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_par
+ \fi}
+
+\setvalue{\??textbackgroundlevel\v!always}%
+ {\let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_par
+ \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_par}
+
+\setvalue{\??textbackgroundlevel\v!none}%
+ {\anch_backgrounds_text_preset_nop}
+
+\def\anch_backgrounds_text_preset_nop
+ {\let\anch_backgrounds_text_start_indeed\relax
+ \let\anch_backgrounds_text_stop_indeed \relax}
+
+\def\anch_backgrounds_text_preset_yes
+ {\anch_backgrounds_text_preset_nop
+ \csname\??textbackgroundlevel\textbackgroundparameter\c!location\endcsname
+ \edef\p_anch_backgrounds_text_frame {\textbackgroundparameter\c!frame}%
+ \edef\p_anch_backgrounds_text_corner {\textbackgroundparameter\c!corner}%
+ \edef\p_anch_backgrounds_text_background{\textbackgroundparameter\c!background}%
+ \ifx\p_anch_backgrounds_text_frame\v!on
+ \ifx\p_anch_backgrounds_text_corner\v!round
+ \let\p_anch_backgrounds_text_frame\!!plustwo
+ \else
+ \let\p_anch_backgrounds_text_frame\!!plusone
+ \fi
+ \else
+ \let\p_anch_backgrounds_text_frame\!!zerocount
+ \fi
+ \ifx\p_anch_backgrounds_text_background\v!color
+ \let\p_anch_backgrounds_text_background\!!plusone
+ \else
+ \let\p_anch_backgrounds_text_background\!!zerocount
+ \fi
+ \startpositionoverlay{\textbackgroundoverlay{\textbackgroundparameter\c!level}}%
+ \anch_backgrounds_text_meta_graphic % gets expanded directly
+ \stoppositionoverlay}
+
+\def\anch_backgrounds_text_meta_graphic
+ {\normalexpanded
+ {\setMPpositiongraphicrange % needs to be optimized
+ {\v_anch_backgrounds_anchor_current_b}%
+ {\v_anch_backgrounds_anchor_current_e}%
+ {\textbackgroundparameter\c!method}%
+ {self=\v_anch_backgrounds_text_current,
+ mp=\textbackgroundparameter\c!mp,
+ gridtype=\textbackgroundparameter\c!alternative,
+ filltype=\p_anch_backgrounds_text_background,
+ linetype=\p_anch_backgrounds_text_frame,
+ dashtype=\textbackgroundparameter\c!dash,
+ gridcolor=\textbackgroundparameter\c!framecolor,
+ linecolor=\textbackgroundparameter\c!framecolor,
+ lineoffset=\textbackgroundparameter\c!frameoffset,
+ fillcolor=\textbackgroundparameter\c!backgroundcolor,
+ filloffset=\textbackgroundparameter\c!backgroundoffset,
+ gridwidth=\textbackgroundparameter\c!rulethickness,
+ gridshift=\textbackgroundparameter\c!voffset,
+ linewidth=\textbackgroundparameter\c!rulethickness,
+ lineradius=\textbackgroundparameter\c!radius}}}
+
+\permanent\protected\def\stoptextbackground
+ {\anch_backgrounds_text_stop_indeed
+ \carryoverpar\endgroup} % why doesn't this work ?
+
+\permanent\protected\def\starttextbackgroundmanual
+ {\begingroup
+ \c_anch_backgrounds_pos_state\plusone
+ \usetextbackgroundstyleandcolor\c!style\c!color
+ \anch_backgrounds_bpos}
+
+\permanent\protected\def\stoptextbackgroundmanual
+ {\anch_backgrounds_epos
+ \carryoverpar\endgroup}
+
+\def\anch_backgrounds_text_start_txt
+ {\ifvmode \dontleavehmode \fi
+ \begingroup
+ \c_anch_backgrounds_pos_state\plusone
+ \usetextbackgroundstyleandcolor\c!style\c!color
+ \anch_backgrounds_bpos}
+
+\def\anch_backgrounds_text_stop_txt
+ {\anch_backgrounds_epos
+ \carryoverpar\endgroup}
+
+\newskip\textbackgroundskip
+
+% maybe we should have a resetter for such compensation struts
+
+\def\anch_backgrounds_reset_attributes
+ {\scratchcounter\c_attr_snapmethod
+ \resetallattributes % \c_attr_linenumber\attributeunsetvalue
+ \c_attr_snapmethod\scratchcounter}
+
+\def\anch_backgrounds_text_start_par % beware .. background shapes
+ {\endgraf % new
+ \textbackgroundparameter\c!before
+ \begingroup
+ \c_anch_backgrounds_pos_state\plustwo
+ \begingroup
+ \anch_backgrounds_reset_attributes
+ \noindent
+ \ifgridsnapping
+ \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!topoffset}%
+ \ifdim\textbackgroundskip>\zeropoint
+ \struttedbox % not always ok (e.g. setups)
+ {\hpack{\raise\textbackgroundskip\hpack{\anch_backgrounds_bpos}}}%
+ \else
+ \anch_backgrounds_bpos
+ \fi
+ \else
+ \anch_backgrounds_bpos
+ \fi
+ \endgraf % we need a vertical nobreak - 29/06/2004
+ \endgroup
+ \nobreak
+ \vskip-\lineheight
+ \nobreak
+ \ifgridsnapping \else
+ \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!topoffset}%
+ \ifdim\textbackgroundskip>\zeropoint
+ \kern\textbackgroundskip\nobreak
+ \fi
+ \fi
+ \dosetleftskipadaption{\textbackgroundparameter\c!leftoffset}%
+ \advance\leftskip\leftskipadaption
+ \dosetleftskipadaption{\textbackgroundparameter\c!rightoffset}%
+ \advance\rightskip\leftskipadaption
+ % new
+ \dosetraggedcommand{\textbackgroundparameter\c!align}%
+ \raggedcommand
+ %
+ \usetextbackgroundstyleandcolor\c!style\c!color
+ \nowhitespace
+ \seteffectivehsize
+ \doinhibitblank % \blank[\v!disable]% new
+ \par}
+
+\def\anch_backgrounds_text_stop_par
+ {\par
+ \removelastskip % new
+ \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!bottomoffset}%
+ \ifdim\lastskip>\zeropoint
+ \advance\textbackgroundskip-\lastskip
+ \fi
+ \ifgridsnapping
+ \orelse\ifdim\textbackgroundskip>\zeropoint
+ \kern\textbackgroundskip\nobreak
+ \fi
+ \nobreak
+ \vskip-\dimexpr\lineheight+\parskip\relax % problem: we loose the hangindent
+ \nobreak
+ \endgroup
+ \begingroup
+ \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM
+ \anch_backgrounds_reset_attributes
+ \nobreak \noindent \strut \hfill \kern\zeropoint
+ % so far
+ \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!bottomoffset}%
+ \ifgridsnapping % experimental, pascal (todo: topoffset in same way)
+ \ifdim\textbackgroundskip>\zeropoint
+ \struttedbox % not always ok (e.g. setups)
+ {\hpack{\lower\textbackgroundskip\hpack{\anch_backgrounds_epos}}}%
+ \else
+ \anch_backgrounds_epos
+ \fi
+ \else
+ \anch_backgrounds_epos
+ \fi
+ \endgraf
+ \carryoverpar\endgroup
+ \endgraf % new
+ \textbackgroundparameter\c!after}
+
+\permanent\protected\def\checkpositionoverlays % overloads \relax in anch-pgr
+ {\ifproductionrun
+ \enabletextarearegistration
+ \enablehiddenbackground
+ \enforced\glet\checkpositionoverlays\relax
+ \fi}
+
+% shape handling
+
+\definesystemattribute[textbackground][public]
+
+% \def\page_prepare_backgrounds#1%
+% {\clf_collectbackgrounds\realpageno#1\relax}
+
+\def\anch_backgrounds_bpos
+ {\ifconditional\c_anch_backgrounds_pos_no_shape
+ \c_attr_textbackground\attributeunsetvalue
+ \bposkind\v_anch_backgrounds_text_current\plusthree
+ \orelse\ifnum\c_anch_backgrounds_pos_state=\plusone
+ \bposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state
+ \clf_registerbackground{\v_anch_backgrounds_text_current}%
+ \else
+ \bposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state
+ \c_attr_textbackground\attributeunsetvalue
+ \fi}
+
+% plugs into other code
+
+\def\strc_floats_wrap_free_region
+ {\global\setbox\floatbox\hpack % we always need to wrap
+ {\ifconditional\c_strc_floats_trace_free
+ \strc_floats_show_free_region
+ \fi
+ \box\floatbox}}
+
+\startuseMPgraphic{floatfree}
+ draw_free_region(
+ \the\wd\floatbox,
+ \the\ht\floatbox,
+ \the\dp\floatbox,
+ \the\d_free_offset_left,
+ \the\d_free_offset_right,
+ \the\d_free_offset_top,
+ \the\d_free_offset_bottom
+ ) ;
+\stopuseMPgraphic
+
+\def\strc_floats_show_free_region
+ {\lower\dp\floatbox\hpack to \zeropoint {\useMPgraphic{floatfree}}}
+
+\newconditional\c_strc_floats_mark_as_free
+\newconditional\c_strc_floats_trace_free
+\newconstant \c_free_offset_kind
+\newdimen \d_free_offset_left
+\newdimen \d_free_offset_right
+\newdimen \d_free_offset_top
+\newdimen \d_free_offset_bottom
+
+\installtextracker{floats.freeregion}
+ {\settrue \c_strc_floats_trace_free}
+ {\setfalse\c_strc_floats_trace_free}
+
+\def\strc_floats_mark_as_free#1#2#3#4#5%
+ {\c_free_offset_kind #1%
+ \d_free_offset_left #2%
+ \d_free_offset_right #3%
+ \d_free_offset_top #4%
+ \d_free_offset_bottom#5%
+ \strc_floats_wrap_free_region
+ \anch_mark_tagged_box_free
+ \floatbox
+ \c_free_offset_kind
+ \d_free_offset_left
+ \d_free_offset_right
+ \d_free_offset_top
+ \d_free_offset_bottom}
+
+\ifrelax\strc_floats_mark_pag_as_free \else
+ \writestatus{error}{wrong place for pag_as_free}\wait
+\fi
+
+\ifrelax\strc_floats_mark_par_as_free \else
+ \writestatus{error}{wrong place for par_as_free}\wait
+\fi
+
+\def\strc_floats_mark_pag_as_free
+ {\ifpositioning
+ \ifconditional\c_strc_floats_mark_as_free
+ \strc_floats_mark_as_free
+ \plusone
+ \zeropoint
+ \zeropoint
+ \d_strc_floats_top
+ \d_strc_floats_bottom
+ \fi
+ \fi}
+
+\def\strc_floats_mark_par_as_free
+ {\ifpositioning
+ \ifconditional\c_strc_floats_mark_as_free
+ \ifcase\c_page_sides_float_type
+ \or % backspace
+ \strc_floats_mark_as_free
+ \plustwo
+ \zeropoint
+ \d_page_sides_rightoffset
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % leftedge
+ \strc_floats_mark_as_free
+ \plustwo
+ \zeropoint
+ \d_page_sides_rightoffset
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % leftmargin
+ \strc_floats_mark_as_free
+ \plustwo
+ \zeropoint
+ \d_page_sides_rightoffset
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % leftside
+ \strc_floats_mark_as_free
+ \plustwo
+ \d_page_sides_leftskip % maybe too
+ \d_page_sides_margin
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % rightside
+ \strc_floats_mark_as_free
+ \plusthree
+ \d_page_sides_margin
+ \d_page_sides_rightskip % maybe too
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % rightmargin
+ \strc_floats_mark_as_free
+ \plusthree
+ \d_page_sides_leftoffset
+ \zeropoint
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % rightedge
+ \strc_floats_mark_as_free
+ \plusthree
+ \d_page_sides_leftoffset
+ \zeropoint
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \or % cutspace
+ \strc_floats_mark_as_free
+ \plusthree
+ \d_page_sides_leftoffset
+ \zeropoint
+ \d_page_sides_topskip
+ \d_page_sides_bottomskip
+ \fi
+ \fi
+ \fi}
+
+% so far
+
+\setuptextbackground
+ [\c!mp=mpos:region:draw,
+ \c!method=mpos:region,
+ \c!state=\v!start,
+ \c!location=\v!text,
+ \c!leftoffset=\!!zeropoint, % 1em,
+ \c!rightoffset=\textbackgroundparameter\c!leftoffset,
+ \c!topoffset=\!!zeropoint, % \v!medium,
+ \c!bottomoffset=\textbackgroundparameter\c!topoffset,
+ \c!criterium=\plusone,
+ \c!level=-1,
+ \c!alternative=0,
+ \c!align=,
+ \c!dash=0, % to be internationalized
+ \c!background=\v!color,
+ \c!backgroundcolor=lightgray,
+ \c!backgroundoffset=\!!zeropoint,
+ \c!corner=\v!rectangular,
+ \c!radius=.5\bodyfontsize,
+ \c!voffset=\!!zeropoint,
+ \c!frame=\v!on,
+ \c!framecolor=blue,
+ \c!frameoffset=\!!zeropoint,
+ \c!rulethickness=\linewidth]
+
+%D The \METAPOST\ connection:
+
+% gridtype = 1 => baseline
+% gridtype = 2 => betweenline
+
+\setupMPvariables
+ [mpos:region]
+ [mp=mpos:region:unset,
+ gridtype=0,
+ linetype=1,
+ filltype=1,
+ dashtype=0, % 1 = dashed, 2 = dashed with background
+ gridcolor=red,
+ linecolor=blue,
+ fillcolor=lightgray,
+ filloffset=\!!zeropoint,
+ linewidth=\linewidth,
+ gridwidth=\linewidth,
+ gridshift=\!!zeropoint,
+ lineradius=.5\bodyfontsize,
+ lineoffset=\!!zeropoint,
+ dashtype=1]
+
+\startuseMPgraphic{mpos:region:setup}
+ boxgridtype := \MPvar{gridtype} ;
+ boxlinetype := \MPvar{linetype} ;
+ boxfilltype := \MPvar{filltype} ;
+ boxdashtype := \MPvar{dashtype} ;
+ boxfilloffset := \MPvar{filloffset} ;
+ boxlinewidth := \MPvar{linewidth} ;
+ boxgridwidth := \MPvar{gridwidth} ;
+ boxgridshift := \MPvar{gridshift} ;
+ boxlineradius := \MPvar{lineradius} ;
+ boxlineoffset := \MPvar{lineoffset} ;
+ %
+ def boxgridcolor = \MPvar{gridcolor} enddef ;
+ def boxlinecolor = \MPvar{linecolor} enddef ;
+ def boxfillcolor = \MPvar{fillcolor} enddef ;
+ %
+ def boxgridoptions = withcolor boxgridcolor enddef ;
+ def boxlineoptions = withcolor boxlinecolor enddef ;
+ def boxfilloptions = withcolor boxfillcolor enddef ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:region:extra}
+ % user stuff
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:region:anchor}
+ setbounds currentpicture to multibox ;
+\stopuseMPgraphic
+
+\startMPpositiongraphic{mpos:region}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset}
+ \includeMPgraphic{mpos:region:setup} ;
+ \includeMPgraphic{mpos:region:extra} ;
+ % \getmultipars("self","anchor") ;
+ \MPgetmultipars{\MPvar{self}}{\MPanchorid} ;
+ \includeMPgraphic{\MPvar{mp}} ;
+ \includeMPgraphic{mpos:region:anchor} ;
+\stopMPpositiongraphic
+
+%D For old times sake:
+
+\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth}
+ string tag; tag := "\MPvar{self}" ;
+ path box ; box := positionbox(tag) ;
+
+ box := box enlarged \MPvar{filloffset} ;
+ fill box withcolor \MPvar{fillcolor} ;
+ draw box withcolor \MPvar{linecolor} withpen pencircle scaled \MPvar{linewidth} ;
+
+ positioninregion;
+\stopMPpositiongraphic
+
+\startMPpositionmethod{mpos:region}
+ \MPpositiongraphic{mpos:region}{}%
+\stopMPpositionmethod
+
+\startuseMPgraphic{mpos:region:draw}
+ draw_multi_pars
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:region:show}
+ show_multi_pars
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:region:kind}
+ show_multi_kind
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:region:sideline}
+ draw_multi_side
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:region:sideline:dashed}
+ draw_multi_side_path dashed evenly ;
+\stopuseMPgraphic
+
+%D As an example we define a grid background:
+
+\pushoverloadmode
+
+\definetextbackground
+ [\v!grid]
+ [\c!state=\v!stop,
+ \c!location=\v!paragraph,
+ \c!frame=\v!off,
+ \c!framecolor=red,
+ \c!background=,
+ \c!alternative=1]
+
+\ifdefined\basegrid
+ \aliased\letcsname\v!grid\endcsname\basegrid
+\fi
+
+\popoverloadmode
+
+%D Some examples (that might become modules anch-imp-whatever):
+
+\setupMPvariables
+ [mpos:encircle]
+ [fillcolor=lightgray,
+ filloffset=\!!zeropoint,
+ linecolor=blue,
+ lineoffset=5pt,
+ linewidth=1pt]
+
+% \startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset}
+% getposboxes("self","anchor") ;
+% if nofposboxes = 1 :
+% posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered \MPvar{lineoffset} ;
+% fill posboxes[1] withcolor \MPvar{fillcolor} ;
+% draw posboxes[1] withpen pencircle scaled \MPvar{linewidth} withcolor \MPvar{linecolor} ;
+% fi ;
+% \stopMPpositiongraphic
+
+\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset}
+ getposboxes("self","anchor") ;
+ if nofposboxes = 1 :
+ posboxes[1] := (posboxes[1] enlarged mpvar "lineoffset") cornered mpvar "lineoffset" ;
+ fill posboxes[1] withcolor mpvar "fillcolor" ;
+ draw posboxes[1] withpen pencircle scaled mpvar "linewidth" withcolor mpvar "linecolor" ;
+ fi ;
+\stopMPpositiongraphic
+
+\setupMPvariables
+ [mpos:connect]
+ [linecolor=red,
+ lineoffset=.25ex,
+ linewidth=1pt]
+
+% \startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth}
+% boxlinewidth := \MPvar{linewidth} ;
+% boxlineoffset := \MPvar{lineoffset} ;
+% def boxlineoptions = withcolor \MPvar{linecolor} enddef ;
+% getposboxes("from,to","anchor") ;
+% connect_positions ;
+% \stopMPpositiongraphic
+
+\startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth}
+ boxlinewidth := mpvar "linewidth" ;
+ boxlineoffset := mpvar "lineoffset" ;
+ def boxlineoptions = withcolor mpvar "linecolor" enddef ;
+ getposboxes("from,to","anchor") ;
+ connect_positions ;
+\stopMPpositiongraphic
+
+\protect \endinput
+
+\definetextbackground[underline] [location=text,alternative=1,background=,frame=off]
+\definetextbackground[overstrike] [location=text,alternative=2,background=,frame=off]
+\definetextbackground[exlines] [location=text,alternative=3,background=,frame=off]
+\definetextbackground[strikethrough][location=text,alternative=4,background=,frame=off]
+
+\definestartstop [underline]
+ [before={\starttextbackground[underline]},
+ after=\stoptextbackground]
+
+\definestartstop
+ [overstrike]
+ [before={\starttextbackground[overstrike]},
+ after=\stoptextbackground]
+
+\definestartstop
+ [exlines]
+ [before={\starttextbackground[exlines]},
+ after=\stoptextbackground]
+
+\definestartstop
+ [strikethrough]
+ [before={\starttextbackground[strikethrough]},
+ after=\stoptextbackground]
+
+\definetextbackground
+ [sideline]
+ [mp=mpos:region:sideline,
+ location=paragraph,
+ framecolor=red,
+ frameoffset=5mm]
+
+\definestartstop [sideline]
+ [before={\starttextbackground[sideline]},
+ after=\stoptextbackground]
+
+\starttext
+
+ \startunderline \input tufte \stopunderline \blank
+ \startoverstrike \input tufte \stopoverstrike \blank
+ \startexlines \input tufte \stopexlines \blank
+ \startstrikethrough \input tufte \stopstrikethrough \blank
+ \startsideline \input tufte \stopsideline \blank
+
+ \page
+
+ \startpositionoverlay{text-1}
+ \setMPpositiongraphic{connect-1-b}{mpos:connect}{from=connect-1-b,to=connect-1-e}
+ \setMPpositiongraphic{connect-1-e}{mpos:connect}{from=connect-1-b,to=connect-1-e}
+ \stoppositionoverlay
+
+ \startpositionoverlay{text-1}
+ \setMPpositiongraphic{encircle-1}{mpos:encircle}{self=encircle-1}
+ \stoppositionoverlay
+
+ test \hpos{connect-1-b}{START}
+ \dorecurse{10}{\input ward}
+ \hpos{encircle-1}{\strut HERE}
+ \dorecurse{10}{\input ward}
+ \hpos{connect-1-e}{STOP} test
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-pgr.lmt b/Master/texmf-dist/tex/context/base/mkxl/anch-pgr.lmt
new file mode 100644
index 00000000000..5b750d80e7a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-pgr.lmt
@@ -0,0 +1,1325 @@
+if not modules then modules = { } end modules ['anch-pgr'] = {
+ version = 1.001,
+ comment = "companion to anch-pgr.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is a bit messy module but backgrounds are messy anyway. Especially when we want to
+-- follow shapes. This will always be work in progress as it also depends on new features
+-- in context.
+--
+-- Alas, shapes and inline didn't work as expected end of 2016 so I had to pick up this
+-- thread again. But with regular excursions to listening to Brad Mehldau's Mehliana I
+-- could keep myself motivated. Some old stuff has been removed, some suboptimal code has
+-- been replaced. Background code is still not perfect, but some day ... the details manual
+-- will discuss this issue.
+
+local tonumber = tonumber
+local sort, concat = table.sort, table.concat
+local splitter = lpeg.splitat(":")
+local lpegmatch = lpeg.match
+
+local jobpositions = job.positions
+local formatters = string.formatters
+local setmetatableindex = table.setmetatableindex
+local settings_to_array = utilities.parsers.settings_to_array
+
+local enableaction = nodes.tasks.enableaction
+
+local commands = commands
+local context = context
+
+local implement = interfaces.implement
+
+local getmacro = tokens.getters.macro
+local scanmpstring = mp.scan.string
+local mpgnamespace = getmacro("??graphicvariable")
+
+local report_graphics = logs.reporter("backgrounds")
+local report_shapes = logs.reporter("backgrounds","shapes")
+local report_free = logs.reporter("backgrounds","free")
+
+local trace_shapes = false trackers.register("backgrounds.shapes", function(v) trace_shapes = v end)
+local trace_ranges = false trackers.register("backgrounds.shapes.ranges",function(v) trace_ranges = v end)
+local trace_free = false trackers.register("backgrounds.shapes.free", function(v) trace_free = v end)
+
+local f_b_tag = formatters["b:%s"]
+local f_e_tag = formatters["e:%s"]
+local f_p_tag = formatters["p:%s"]
+
+local f_tag_two = formatters["%s:%s"]
+
+local f_point = formatters["%p"]
+local f_pair = formatters["(%p,%p)"]
+local f_path = formatters["%--t--cycle"]
+local f_pair_i = formatters["(%r,%r)"] -- rounded
+
+graphics = graphics or { }
+local backgrounds = { }
+graphics.backgrounds = backgrounds
+
+-- -- -- these can go -- -- --
+
+backgrounds.point = f_point
+backgrounds.pair = f_pair
+backgrounds.path = f_path
+
+-- -- --
+
+local texsetattribute = tex.setattribute
+
+local a_textbackground = attributes.private("textbackground")
+
+local nuts = nodes.nuts
+
+local new_latelua = nuts.pool.latelua
+local new_rule = nuts.pool.rule
+local new_kern = nuts.pool.kern
+local new_hlist = nuts.pool.hlist
+
+local getbox = nuts.getbox
+local getid = nuts.getid
+----- getlist = nuts.getlist
+local setlink = nuts.setlink
+local getheight = nuts.getheight
+local getdepth = nuts.getdepth
+
+local nodecodes = nodes.nodecodes
+local par_code = nodecodes.par
+
+local start_of_par = nuts.start_of_par
+local insert_before = nuts.insert_before
+local insert_after = nuts.insert_after
+
+local processranges = nuts.processranges
+
+local unsetvalue = attributes.unsetvalue
+
+local jobpositions = job.positions
+local getpos = jobpositions.getpos
+local getfree = jobpositions.getfree
+
+local data = { }
+local realpage = 1
+local recycle = 1000 -- only tables can overflow this
+local enabled = false
+
+-- Freeing the data is somewhat tricky as we can have backgrounds spanning
+-- many pages but for an arbitrary background shape that is not so common.
+
+local function check(specification)
+ local a = specification.attribute
+ local index = specification.index
+ local depth = specification.depth
+ local d = specification.data
+ local where = specification.where
+ local ht = specification.ht
+ local dp = specification.dp
+ -- this is not yet r2l ready
+ local w = d.shapes[realpage]
+ local x, y = getpos()
+ if trace_ranges then
+ report_shapes("attribute %i, index %i, depth %i, location %s, position (%p,%p)",
+ a,index,depth,where,x,y)
+ end
+ local n = #w
+ if d.index ~= index then
+ n = n + 1
+ d.index = index
+ d.depth = depth
+ -- w[n] = { x, x, y, ht, dp }
+ w[n] = { y, ht, dp, x, x }
+ else
+ local wn = w[n]
+ local wh = wn[2]
+ local wd = wn[3]
+ if depth < d.depth then
+ local wy = wn[1]
+ wn[1] = y
+ d.depth = depth
+ local dy = wy - y
+ wh = wh - dy
+ wd = wd - dy
+ end
+ if where == "r" then
+ if x > wn[5] then
+ wn[5] = x
+ end
+ else
+ if x < wn[4] then
+ wn[4] = x
+ end
+ end
+ if ht > wh then
+ wn[2] = ht
+ end
+ if dp > wd then
+ wn[3] = dp
+ end
+ end
+ -- inspect(w)
+end
+
+local index = 0
+
+local function flush(head,f,l,a,parent,depth)
+ local d = data[a]
+ if d then
+ local ix = index
+ local ht = getheight(parent)
+ local dp = getdepth(parent)
+ local ln = new_latelua { action = check, attribute = a, index = ix, depth = depth, data = d, where = "l", ht = ht, dp = dp }
+ local rn = new_latelua { action = check, attribute = a, index = ix, depth = depth, data = d, where = "r", ht = ht, dp = dp }
+ if trace_ranges then
+ ln = new_hlist(setlink(new_rule(65536,65536*4,0),new_kern(-65536),ln))
+ rn = new_hlist(setlink(new_rule(65536,0,65536*4),new_kern(-65536),rn))
+ end
+ if getid(f) == par_code and start_of_par(f) then -- we need to clean this mess
+ insert_after(head,f,ln)
+ else
+ head, f = insert_before(head,f,ln)
+ end
+ insert_after(head,l,rn)
+ end
+ return head, true
+end
+
+local function registerbackground(name)
+ local n = #data + 1
+ if n > recycle then
+ -- we could also free all e: that are beyond a page but we don't always
+ -- know the page so a recycle is nicer and the s lists are kept anyway
+ -- so the amount of kept data is not that large
+ n = 1
+ end
+ local b = jobpositions.tobesaved["b:"..name]
+ if b then
+ local s = setmetatableindex("table")
+ b.s = s
+ data[n] = {
+ bpos = b,
+ name = name,
+ n = n,
+ shapes = s,
+ count = 0,
+ sindex = 0,
+ }
+ texsetattribute(a_textbackground,n)
+ if not enabled then
+ enableaction("contributers", "nodes.handlers.textbackgrounds")
+ enabled = true
+ end
+ else
+ texsetattribute(a_textbackground,unsetvalue)
+ end
+end
+
+-- local function collectbackgrounds(r,n)
+-- if enabled then
+-- local parent = getbox(n)
+-- local head = getlist(parent)
+-- realpage = r
+-- processranges(a_textbackground,flush,head) -- ,parent)
+-- end
+-- end
+--
+-- interfaces.implement {
+-- name = "collectbackgrounds",
+-- actions = collectbackgrounds,
+-- arguments = { "integer", "integer" }
+-- }
+
+nodes.handlers.textbackgrounds = function(head,where,parent) -- we have hlistdir and local dir
+ -- todo enable action in register
+ index = index + 1
+ return processranges(a_textbackground,flush,head,parent)
+end
+
+interfaces.implement {
+ name = "registerbackground",
+ actions = registerbackground,
+ arguments = "string",
+}
+
+-- optimized already but we can assume a cycle i.e. prune the last point and then
+-- even less code .. we could merge some loops but his is more robust
+
+-- use idiv here
+
+local function topairs(t,n)
+ local r = { }
+ for i=1,n do
+ local ti = t[i]
+ r[i] = f_pair_i(ti[1]/65556,ti[2]/65536)
+ end
+ return concat(r," ")
+end
+
+local eps = 65536 / 4
+local pps = eps
+local nps = - pps
+
+local function unitvector(x,y)
+ if x < pps and x > nps then
+ x = 0
+ elseif x < 0 then
+ x = -1
+ else
+ x = 1
+ end
+ if y < pps and y > nps then
+ y = 0
+ elseif y < 0 then
+ y = -1
+ else
+ y = 1
+ end
+ return x, y
+end
+
+local function finish(t)
+ local tm = #t
+ if tm < 2 then
+ return
+ end
+ if trace_ranges then
+ report_shapes("initial list: %s",topairs(t,tm))
+ end
+ -- remove similar points
+ local n = 1
+ local tn = tm
+ local tf = t[1]
+ local tx = tf[1]
+ local ty = tf[2]
+ for i=2,#t do
+ local ti = t[i]
+ local ix = ti[1]
+ local iy = ti[2]
+ local dx = ix - tx
+ local dy = iy - ty
+ if dx > eps or dx < - eps or dy > eps or dy < - eps then
+ n = n + 1
+ t[n] = ti
+ tx = ix
+ ty = iy
+ end
+ end
+ if trace_shapes then
+ report_shapes("removing similar points: %s",topairs(t,n))
+ end
+ if n > 2 then
+ -- remove redundant points
+ repeat
+ tn = n
+ n = 0
+ local tm = t[tn]
+ local tmx = tm[1]
+ local tmy = tm[2]
+ local tp = t[1]
+ local tpx = tp[1]
+ local tpy = tp[2]
+ for i=1,tn do -- while and only step when done
+ local ti = tp
+ local tix = tpx
+ local tiy = tpy
+ if i == tn then
+ tp = t[1]
+ else
+ tp = t[i+1]
+ end
+ tpx = tp[1]
+ tpy = tp[2]
+
+ local vx1, vx2 = unitvector(tix - tmx,tpx - tix)
+ if vx1 ~= vx2 then
+ n = n + 1
+ t[n] = ti
+ else
+ local vy1, vy2 = unitvector(tiy - tmy,tpy - tiy)
+ if vy1 ~= vy2 then
+ n = n + 1
+ t[n] = ti
+ end
+ end
+
+ tmx = tix
+ tmy = tiy
+ end
+ until n == tn or n <= 2
+ if trace_shapes then
+ report_shapes("removing redundant points: %s",topairs(t,n))
+ end
+ -- remove spikes
+ if n > 2 then
+ repeat
+ tn = n
+ n = 0
+ local tm = t[tn]
+ local tmx = tm[1]
+ local tmy = tm[2]
+ local tp = t[1]
+ local tpx = tp[1]
+ local tpy = tp[2]
+ for i=1,tn do -- while and only step when done
+ local ti = tp
+ local tix = tpx
+ local tiy = tpy
+ if i == tn then
+ tp = t[1]
+ else
+ tp = t[i+1]
+ end
+ tpx = tp[1]
+ tpy = tp[2]
+
+ local vx1, vx2 = unitvector(tix - tmx,tpx - tix)
+ if vx1 ~= - vx2 then
+ n = n + 1
+ t[n] = ti
+ else
+ local vy1, vy2 = unitvector(tiy - tmy,tpy - tiy)
+ if vy1 ~= - vy2 then
+ n = n + 1
+ t[n] = ti
+ end
+ end
+
+ tmx = tix
+ tmy = tiy
+ end
+ until n == tn or n <= 2
+ if trace_shapes then
+ report_shapes("removing spikes: %s",topairs(t,n))
+ end
+ end
+ end
+ -- prune trailing points
+ if tm > n then
+ for i=tm,n+1,-1 do
+ t[i] = nil
+ end
+ end
+ if n > 1 then
+ local tf = t[1]
+ local tl = t[n]
+ local dx = tf[1] - tl[1]
+ local dy = tf[2] - tl[2]
+ if dx > eps or dx < - eps or dy > eps or dy < - eps then
+ -- different points
+ else
+ -- saves a point (as we -- cycle anyway)
+ t[n] = nil
+ n = n -1
+ end
+ if trace_shapes then
+ report_shapes("removing cyclic endpoints: %s",topairs(t,n))
+ end
+ end
+ return t
+end
+
+local eps = 65536
+
+-- The next function can introduce redundant points but these are removed later on
+-- in the unspiker. It makes checking easier.
+
+local function shape(kind,b,p,realpage,xmin,xmax,ymin,ymax,fh,ld)
+ local s = b.s
+ if not s then
+ if trace_shapes then
+ report_shapes("calculating %s area, no shape",kind)
+ end
+ return
+ end
+ s = s[realpage]
+ if not s then
+ if trace_shapes then
+ report_shapes("calculating %s area, no shape for page %s",kind,realpage)
+ end
+ return
+ end
+ local ns = #s
+ if ns == 0 then
+ if trace_shapes then
+ report_shapes("calculating %s area, empty shape for page %s",kind,realpage)
+ end
+ return
+ end
+ --
+ if trace_shapes then
+ report_shapes("calculating %s area, using shape for page %s",kind,realpage)
+ end
+ -- it's a bit inefficient to use the par values and later compensate for b and
+ -- e but this keeps the code (loop) cleaner
+ local ph = p and p.h or 0
+ local pd = p and p.d or 0
+ --
+ xmax = xmax + eps
+ xmin = xmin - eps
+ ymax = ymax + eps
+ ymin = ymin - eps
+ local ls = { } -- left shape
+ local rs = { } -- right shape
+ local pl = nil -- previous left x
+ local pr = nil -- previous right x
+ local n = 0
+ local xl = nil
+ local xr = nil
+ local mh = ph -- min
+ local md = pd -- min
+ for i=1,ns do
+ local si = s[i]
+ local y = si[1]
+ local ll = si[4] -- can be sparse
+ if ll then
+ xl = ll
+ local rr = si[5] -- can be sparse
+ if rr then
+ xr = rr
+ end
+ end
+ if trace_ranges then
+ report_shapes("original : [%02i] xl=%p xr=%p y=%p",i,xl,xr,y)
+ end
+ if xl ~= xr then -- could be catched in the finalizer
+ local xm = xl + (xr - xl)/2 -- midpoint should be in region
+ if xm >= xmin and xm <= xmax and y >= ymin and y <= ymax then
+ local ht = si[2] -- can be sparse
+ if ht then
+ ph = ht
+ local dp = si[3] -- can be sparse
+ if dp then
+ pd = dp
+ end
+ end
+ local h = y + (ph < mh and mh or ph)
+ local d = y - (pd < md and md or pd)
+ if pl then
+ n = n + 1
+ ls[n] = { pl, h }
+ rs[n] = { pr, h }
+ if trace_ranges then
+ report_shapes("paragraph : [%02i] xl=%p xr=%p y=%p",i,pl,pr,h)
+ end
+ end
+ n = n + 1
+ ls[n] = { xl, h }
+ rs[n] = { xr, h }
+ if trace_ranges then
+ report_shapes("height : [%02i] xl=%p xr=%p y=%p",i,xl,xr,h)
+ end
+ n = n + 1
+ ls[n] = { xl, d }
+ rs[n] = { xr, d }
+ if trace_ranges then
+ report_shapes("depth : [%02i] xl=%p xr=%p y=%p",i,xl,xr,d)
+ end
+ end
+ pl, pr = xl, xr
+ else
+ if trace_ranges then
+ report_shapes("ignored : [%02i] xl=%p xr=%p y=%p",i,xl,xr,y)
+ end
+ end
+ end
+ --
+ if true and n > 0 then
+ -- use height of b and depth of e, maybe check for weird border
+ -- cases here
+ if fh then
+ local lsf = ls[1]
+ local rsf = rs[1]
+ if lsf[2] < fh then
+ lsf[2] = fh
+ end
+ if rsf[2] < fh then
+ rsf[2] = fh
+ end
+ end
+ if fd then
+ local lsl = ls[n]
+ local rsl = rs[n]
+ if lsl[2] > fd then
+ lsl[2] = fd
+ end
+ if rsl[2] > fd then
+ rsl[2] = fd
+ end
+ end
+ end
+ --
+ for i=n,1,-1 do
+ n = n + 1 rs[n] = ls[i]
+ end
+ return rs
+end
+
+local function singlepart(b,e,p,realpage,r,left,right)
+ local bx = b.x
+ local by = b.y
+ local ex = e.x
+ local ey = e.y
+ local rx = r.x
+ local ry = r.y
+ local bh = by + b.h
+ local bd = by - b.d
+ local eh = ey + e.h
+ local ed = ey - e.d
+ local rh = ry + r.h
+ local rd = ry - r.d
+ local rw = rx + r.w
+ if left then
+ rx = rx + left
+ rw = rw - right
+ end
+ if ex == rx then
+ -- We probably have a strut at the next line so we force a width
+ -- although of course it is better to move up. But as we have whitespace
+ -- (at least visually) injected then it's best to stress the issue.
+ ex = rw
+ end
+ local area
+ if by == ey then
+ if trace_shapes then
+ report_shapes("calculating single area, partial line")
+ end
+ area = {
+ { bx, bh },
+ { ex, eh },
+ { ex, ed },
+ { bx, bd },
+ }
+ elseif b.k == 2 then
+ area = {
+ { rx, bh },
+ { rw, bh },
+ { rw, ed },
+ { rx, ed },
+ }
+ else
+ area = shape("single",b,p,realpage,rx,rw,rd,rh,bh,ed)
+ end
+ if not area then
+ area = {
+ { bx, bh },
+ { rw, bh },
+ { rw, eh },
+ { ex, eh },
+ { ex, ed },
+ { rx, ed },
+ { rx, bd },
+ { bx, bd },
+ }
+ end
+ return {
+ location = "single",
+ region = r,
+ area = finish(area),
+ }
+end
+
+local function firstpart(b,e,p,realpage,r,left,right)
+ local bx = b.x
+ local by = b.y
+ local rx = r.x
+ local ry = r.y
+ local bh = by + b.h
+ local bd = by - b.d
+ local rh = ry + r.h
+ local rd = ry - r.d
+ local rw = rx + r.w
+ if left then
+ rx = rx + left
+ rw = rw - right
+ end
+ local area = shape("first",b,p,realpage,rx,rw,rd,rh,bh,false)
+ if not area then
+ if b.k == 2 then
+ area = {
+ { rx, bh },
+ { rw, bh },
+ { rw, rd },
+ { rx, rd },
+ }
+ else
+ area = {
+ { bx, bh },
+ { rw, bh },
+ { rw, rd }, -- { rw, eh },
+ { rx, rd }, -- { rx, ed },
+ { rx, bd },
+ { bx, bd },
+ }
+ end
+ end
+ return {
+ location = "first",
+ region = r,
+ area = finish(area),
+ }
+end
+
+local function middlepart(b,e,p,realpage,r,left,right)
+ local rx = r.x
+ local ry = r.y
+ local rh = ry + r.h
+ local rd = ry - r.d
+ local rw = rx + r.w
+ if left then
+ rx = rx + left
+ rw = rw - right
+ end
+ local area = shape("middle",b,p,realpage,rx,rw,rd,rh,false,false)
+ if not area then
+ area = {
+ { rw, rh },
+ { rw, rd },
+ { rx, rd },
+ { rx, rh },
+ }
+ end
+ return {
+ location = "middle",
+ region = r,
+ area = finish(area),
+ }
+end
+
+local function lastpart(b,e,p,realpage,r,left,right)
+ local ex = e.x
+ local ey = e.y
+ local rx = r.x
+ local ry = r.y
+ local eh = ey + e.h
+ local ed = ey - e.d
+ local rh = ry + r.h
+ local rd = ry - r.d
+ local rw = rx + r.w
+ if left then
+ rx = rx + left
+ rw = rw - right
+ end
+ local area = shape("last",b,p,realpage,rx,rw,rd,rh,false,ed)
+ if not area then
+ if b.k == 2 then
+ area = {
+ { rw, rh },
+ { rw, ed },
+ { rx, ed },
+ { rx, rh },
+ }
+ else
+ area = {
+ { rw, rh }, -- { rw, bh },
+ { rw, eh },
+ { ex, eh },
+ { ex, ed },
+ { rx, ed },
+ { rx, rh }, -- { rx, bd },
+ }
+ end
+ end
+ return {
+ location = "last",
+ region = r,
+ area = finish(area),
+ }
+end
+
+local function calculatemultipar(tag)
+ local collected = jobpositions.collected
+ local b = collected[f_b_tag(tag)]
+ local e = collected[f_e_tag(tag)]
+ if not b or not e then
+ report_shapes("invalid tag %a",tag)
+ return { }
+ end
+ local br = b.r
+ local er = e.r
+ if not br or not er then
+ report_shapes("invalid region for %a",tag)
+ return { }
+ end
+ local btag, bindex = lpegmatch(splitter,br)
+ local etag, eindex = lpegmatch(splitter,er)
+ if not bindex or not eindex or btag ~= etag then
+ report_shapes("invalid indices for %a",tag)
+ return { }
+ end
+ local bindex = tonumber(bindex)
+ local eindex = tonumber(eindex)
+ -- Here we compensate for columns (in tables): a table can have a set of column
+ -- entries and these are shared. We compensate left/right based on the columns
+ -- x and w but need to take the region into acount where the specification was
+ -- flushed and not the begin pos's region, because otherwise we get the wrong
+ -- compensation for asymetrical doublesided layouts.
+ local left = 0
+ local right = 0
+ local bc = b.c
+ local rc = bc and collected[bc]
+ if rc then
+ local tb = collected[rc.r]
+ if tb then
+ left = -(tb.x - rc.x)
+ right = (tb.w - rc.w - left)
+ end
+ end
+ -- Obeying intermediate changes of left/rightskip makes no sense as it will
+ -- look bad, so we only look at the begin situation.
+ local bn = b.n
+ local p = bn and collected[f_p_tag(bn)] -- par
+ if p then
+ left = left + (p.ls or 0)
+ right = right + (p.rs or 0)
+ end
+ --
+ local bp = b.p -- page
+ if trace_shapes then
+ report_shapes("tag %a, left %p, right %p, par %s, page %s, column %s",
+ tag,left,right,bn or "-",bp or "-",bc or "-")
+ end
+ --
+ if bindex == eindex then
+ return {
+ list = { [bp] = { singlepart(b,e,p,bp,collected[br],left,right) } },
+ bpos = b,
+ epos = e,
+ }
+ else
+ local list = {
+ [bp] = { firstpart(b,e,p,bp,collected[br],left,right) },
+ }
+ for i=bindex+1,eindex-1 do
+ br = f_tag_two(btag,i)
+ local r = collected[br]
+ if not r then
+ report_graphics("invalid middle for %a",br)
+ else
+ local rp = r.p -- page
+ local pp = list[rp]
+ local mp = middlepart(b,e,p,rp,r,left,right)
+ if pp then
+ pp[#pp+1] = mp
+ else
+ list[rp] = { mp }
+ end
+ end
+ end
+ local ep = e.p -- page
+ local pp = list[ep]
+ local lp = lastpart(b,e,p,ep,collected[er],left,right)
+ if pp then
+ pp[#pp+1] = lp
+ else
+ list[ep] = { lp }
+ end
+ return {
+ list = list,
+ bpos = b,
+ epos = e,
+ }
+ end
+end
+
+local pbg = { } -- will move to pending
+
+local multilocs = {
+ single = 1, -- maybe 0
+ first = 1,
+ middle = 2,
+ last = 3,
+}
+
+-- if unknown context_abck : input mp-abck.mpiv ; fi ;
+
+local f_template_a = formatters[ [[
+path multiregs[], multipars[], multibox ;
+string multikind[] ;
+numeric multilocs[], nofmultipars ;
+nofmultipars := %s ;
+multibox := unitsquare xyscaled (%p,%p) ;
+numeric par_strut_height, par_strut_depth, par_line_height ;
+par_strut_height := %p ;
+par_strut_depth := %p ;
+par_line_height := %p ;
+]] ]
+
+local f_template_b = formatters[ [[
+multilocs[%s] := %s ;
+multikind[%s] := "%s" ;
+multipars[%s] := (%--t--cycle) shifted - (%p,%p) ;
+]] ]
+
+-- unspiked(simplified(%--t--cycle)) shifted - (%p,%p) ;
+
+local f_template_c = formatters[ [[
+setbounds currentpicture to multibox ;
+]] ]
+
+local function freemultipar(pagedata,frees) -- ,k
+ -- if k == 3 then
+ -- -- tables have local regions
+ -- return
+ -- end
+ if not frees then
+ return
+ end
+ local nfree = #frees
+ if nfree == 0 then
+ return
+ end
+ for i=1,#pagedata do
+ local data = pagedata[i]
+ local area = data.area
+
+ if area then
+
+ local region = data.region
+ local y = 0 -- region.y
+ -- local x = region.x
+ local areas = { }
+ data.areas = areas
+
+ local f_1 = { }
+ local n_1 = 0
+ local f_2 = { }
+ local n_2 = 0
+ for i=1,#frees do
+ local f = frees[i]
+ local k = f.k
+ if k == 1 then -- pag
+ n_1 = n_1 + 1
+ f_1[n_1] = f
+ elseif k == 2 or k == 3 then -- par
+ n_2 = n_2 + 1
+ f_2[n_2] = f
+ end
+ end
+
+ local lineheight = tex.dimen.lineheight
+
+ -- page floats
+
+ local function check_one(free1,free2)
+ local temp = { }
+ local some = false
+ local top = (free2 and (y + free2.y + free2.h + (free2.to or 0))) or false
+ local bot = (free1 and (y + free1.y - free1.d - (free1.bo or 0))) or false
+ for i=1,#area do
+ local a = area[i]
+ local x = a[1]
+ local y = a[2]
+ if free2 and y <= top then
+ y = top
+ end
+ if free1 and y >= bot then
+ y = bot
+ end
+ if not some then
+ some = y
+ elseif some == true then
+ -- done
+ elseif y ~= some then
+ some = true
+ end
+ temp[i] = { x, y }
+ end
+ if some == true then
+ areas[#areas+1] = temp
+ end
+ end
+
+ if n_1 > 0 then
+ check_one(false,f_1[1])
+ for i=2,n_1 do
+ check_one(f_1[i-1],f_1[i])
+ end
+ check_one(f_1[n_1],false)
+ end
+
+ -- par floats
+
+ if #areas == 0 then
+ areas[1] = area
+ end
+
+ -- we can collect the coordinates first
+
+ local function check_two(area,frees)
+ local ul = area[1]
+ local ur = area[2]
+ local lr = area[3]
+ local ll = area[4]
+ local ulx = ul[1]
+ local uly = ul[2]
+ local urx = ur[1]
+ local ury = ur[2]
+ local lrx = lr[1]
+ local lry = lr[2]
+ local llx = ll[1]
+ local lly = ll[2]
+
+ local temp = { }
+ local n = 0
+ local done = false
+
+ for i=1,#frees do
+ local free = frees[i]
+ local fx = free.x
+ local fy = free.y
+ local ymax = y + fy + free.h + (free.to or 0)
+ local ymin = y + fy - free.d - (free.bo or 0)
+ local xmin = fx - (free.lo or 0)
+ local xmax = fx + free.w + (free.ro or 0)
+ if free.k == 3 then
+ if uly <= ymax and uly >= ymin and lly <= ymin then
+ if trace_free then
+ report_free("case 1, top, right") -- ok
+ end
+ n = n + 1 temp[n] = { xmin, ury }
+ n = n + 1 temp[n] = { xmin, ymin }
+ n = n + 1 temp[n] = { lrx, ymin }
+ n = n + 1 temp[n] = { lrx, lry }
+ done = true
+ elseif uly >= ymax and lly <= ymin then
+ if trace_free then
+ report_free("case 2, outside, right") -- ok
+ end
+ if uly - ymax < lineheight then
+ n = n + 1 temp[n] = { xmin, ury }
+ else
+ n = n + 1 temp[n] = { urx, ury }
+ n = n + 1 temp[n] = { urx, ymax }
+ end
+ n = n + 1 temp[n] = { xmin, ymax }
+ n = n + 1 temp[n] = { xmin, ymin }
+ n = n + 1 temp[n] = { lrx, ymin }
+ n = n + 1 temp[n] = { lrx, lry }
+ done = true
+ elseif lly <= ymax and lly >= ymin and uly >= ymax then
+ if trace_free then
+ report_free("case 3, bottom, right")
+ end
+ if uly - ymax < lineheight then
+ n = n + 1 temp[n] = { xmin, ury }
+ else
+ n = n + 1 temp[n] = { urx, ury }
+ n = n + 1 temp[n] = { urx, ymax }
+ end
+ n = n + 1 temp[n] = { xmin, ymax }
+ n = n + 1 temp[n] = { xmin, lry }
+ done = true
+ elseif uly <= ymax and lly >= ymin then
+ if trace_free then
+ report_free("case 4, inside, right")
+ end
+ n = n + 1 temp[n] = { xmin, uly }
+ n = n + 1 temp[n] = { xmin, lly }
+ done = true
+ else
+ -- case 0
+ if trace_free then
+ report_free("case 0, nothing")
+ end
+ end
+ end
+ end
+
+ if not done then
+ if trace_free then
+ report_free("no right shape")
+ end
+ n = n + 1 temp[n] = { urx, ury }
+ n = n + 1 temp[n] = { lrx, lry }
+ n = n + 1 temp[n] = { llx, lly }
+ else
+ done = false
+ end
+
+ for i=#frees,1,-1 do
+ local free = frees[i]
+ local fx = free.x
+ local fy = free.y
+ local ymax = y + fy + free.h + (free.to or 0)
+ local ymin = y + fy - free.d - (free.bo or 0)
+ local xmin = fx - (free.lo or 0)
+ local xmax = fx + free.w + (free.ro or 0)
+ if free.k == 2 then
+ if uly <= ymax and uly >= ymin and lly <= ymin then
+ if trace_free then
+ report_free("case 1, top, left") -- ok
+ end
+ n = n + 1 temp[n] = { ulx, ymin }
+ n = n + 1 temp[n] = { xmax, ymin }
+ n = n + 1 temp[n] = { xmax, uly }
+ done = true
+ elseif uly >= ymax and lly <= ymin then
+ if trace_free then
+ report_free("case 2, outside, left") -- ok
+ end
+ n = n + 1 temp[n] = { llx, lly }
+ n = n + 1 temp[n] = { llx, ymin }
+ n = n + 1 temp[n] = { xmax, ymin }
+ n = n + 1 temp[n] = { xmax, ymax }
+ if uly - ymax < lineheight then
+ n = n + 1 temp[n] = { xmax, uly }
+ else
+ n = n + 1 temp[n] = { llx, ymax }
+ n = n + 1 temp[n] = { llx, uly }
+ end
+ done = true
+ elseif lly <= ymax and lly >= ymin and uly >= ymax then
+ if trace_free then
+ report_free("case 3, bottom, left")
+ end
+ n = n + 1 temp[n] = { xmax, lly }
+ n = n + 1 temp[n] = { xmax, ymax }
+ if uly - ymax < lineheight then
+ n = n + 1 temp[n] = { xmax, uly }
+ else
+ n = n + 1 temp[n] = { llx, ymax }
+ n = n + 1 temp[n] = { llx, uly }
+ end
+ done = true
+ elseif uly <= ymax and lly >= ymin then
+ if trace_free then
+ report_free("case 4, inside, left")
+ end
+ n = n + 1 temp[n] = { xmax, lly }
+ n = n + 1 temp[n] = { xmax, uly }
+ done = true
+ else
+ -- case 0
+ end
+ end
+ end
+
+ if not done then
+ if trace_free then
+ report_free("no left shape")
+ end
+ n = n + 1 temp[n] = { llx, lly }
+ end
+ n = n + 1 temp[n] = { ulx, uly }
+
+ return temp
+ end
+
+ if n_2 > 0 then
+ for i=1,#areas do
+ local area = areas[i]
+ if #area == 4 then -- and also check type, must be pargaraph
+ areas[i] = check_two(area,f_2)
+ else
+ -- message that not yet supported
+ end
+ end
+ end
+
+ for i=1,#areas do
+ finish(areas[i]) -- again
+ end
+
+ end
+
+ end
+end
+
+local function fetchmultipar(n,anchor,page)
+ local a = jobpositions.collected[anchor]
+ if not a then
+ report_graphics("missing anchor %a",anchor)
+ else
+ local data = pbg[n]
+ if not data then
+ data = calculatemultipar(n)
+ pbg[n] = data -- can be replaced by register
+ -- register(data.list,n,anchor)
+ end
+ local list = data and data.list
+ if list then
+ local pagedata = list[page]
+ if pagedata then
+ local k = data.bpos.k
+ if k ~= 3 then
+ -- to be checked: no need in txt mode
+ freemultipar(pagedata,getfree(page))
+ end
+ local nofmultipars = #pagedata
+ if trace_shapes then
+ report_graphics("fetching %a at page %s using anchor %a containing %s multipars",
+ n,page,anchor,nofmultipars)
+ end
+ local x = a.x
+ local y = a.y
+ local w = a.w
+ local h = a.h
+ local d = a.d
+ local bpos = data.bpos
+ local bh = bpos.h
+ local bd = bpos.d
+ local result = { false } -- slot 1 will be set later
+ local n = 0
+ for i=1,nofmultipars do
+ local data = pagedata[i]
+ local location = data.location
+ local region = data.region
+ local areas = data.areas
+ if not areas then
+ areas = { data.area }
+ end
+ for i=1,#areas do
+ local area = areas[i]
+ for i=1,#area do
+ local a = area[i]
+ area[i] = f_pair(a[1],a[2])
+ end
+ n = n + 1
+ result[n+1] = f_template_b(n,multilocs[location],n,location,n,area,x,y)
+ end
+ end
+ data[page] = nil
+ result[1] = f_template_a(n,w,h+d,bh,bd,bh+bd) -- was delayed
+ result[n+2] = f_template_c()
+ return concat(result,"\n")
+ end
+ end
+ end
+ return f_template_a(0,0,0,0,0,0);
+end
+
+backgrounds.fetchmultipar = fetchmultipar
+
+local function getwhatever(action)
+ local tags = scanmpstring()
+ local anchor = scanmpstring()
+ local page = nil
+ if tags == "self" then
+ tags = getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":self",true) -- Isn't it already edef'd?
+ elseif type(tags) == "string" then
+ tags = settings_to_array(tags)
+ for i=1,#tags do
+ tags[i] = getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. tags[i],true) -- Isn't it already edef'd?
+ end
+ end
+ if anchor == "anchor" then
+ anchor = getmacro("MPanchorid") -- brrr
+ end
+ if tags and anchor then
+ return action(tags,anchor,page)
+ end
+end
+
+metapost.registerscript("getmultipars", function()
+ return getwhatever(fetchmultipar)
+end)
+
+-- n anchor page
+
+implement {
+ name = "fetchmultipar",
+ actions = { fetchmultipar, context },
+ arguments = { "string", "string", "integer" }
+}
+
+-- todo: use inject
+
+do
+
+ local f_template_a = formatters[ [[
+ path posboxes[], posregions[] ;
+ numeric pospages[] ;
+ numeric nofposboxes ;
+ nofposboxes := %s ;
+ %t
+ ]] ]
+
+ local f_template_b = formatters[ [[
+ pospages[%s] := %s ;
+ posboxes[%s] := (%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle ;
+ posregions[%s] := (%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle ;
+ ]] ]
+
+ local function getposboxes(tags,anchor,page) -- no caching (yet) / page
+ local collected = jobpositions.collected
+ if type(tags) == "string" then
+ tags = settings_to_array(tags)
+ end
+ local list = { }
+ local nofboxes = 0
+ for i=1,#tags do
+ local tag= tags[i]
+ local c = collected[tag]
+ if c then
+ local r = c.r
+ if anchor ~= r then
+ r = anchor
+ end
+ if r then
+ r = collected[r]
+ if r then
+ local rx = r.x
+ local ry = r.y
+ local rw = r.w
+ local rh = r.h
+ local rd = r.d
+ local cx = c.x - rx
+ local cy = c.y - ry
+ local cw = cx + c.w
+ local ch = cy + c.h
+ local cd = cy - c.d
+ nofboxes = nofboxes + 1
+ list[nofboxes] = f_template_b(
+ nofboxes,c.p,
+ nofboxes,cx,ch,cw,ch,cw,cd,cx,cd,
+ nofboxes,0,rh,rw,rh,rw,rd,0,rd
+ )
+ end
+ end
+ else
+ -- print("\n missing",tag)
+ end
+ end
+ return f_template_a(nofboxes,list)
+ end
+
+ metapost.registerscript("getposboxes", function()
+ return getwhatever(getposboxes)
+ end)
+
+ implement {
+ name = "fetchposboxes",
+ arguments = { "string", "string", "integer" },
+ actions = { getposboxes, context },
+ }
+
+end
+
+do
+
+ local doifelse = commands.doifelse
+
+ implement {
+ name = "doifelserangeonpage",
+ arguments = { "string", "string", "integer" },
+ actions = function(first,last,page)
+ local c = jobpositions.collected
+ local f = c[first]
+ if f then
+ f = f.p
+ if f and f ~= true and page >= f then
+ local l = c[last]
+ if l then
+ l = l.p
+ doifelse(l and l ~= true and page <= l)
+ return
+ end
+ end
+ end
+ doifelse(false)
+ end
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-pgr.mkxl b/Master/texmf-dist/tex/context/base/mkxl/anch-pgr.mkxl
new file mode 100644
index 00000000000..ec8f0e549f2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-pgr.mkxl
@@ -0,0 +1,444 @@
+%D \module
+%D [ file=anch-pgr, % split off core-pos
+%D version=1999.08.01,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Positioning Graphics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Grapics}
+
+%D Before we come to graphics support, we have to make sure of the reference point
+%D on the page. The next macros do so and are hooked into the page building routine.
+
+\registerctxluafile{anch-pgr}{autosuffix}
+
+\unprotect
+
+%D A few more low level macros take care of defining and recalling actions. Actions
+%D are saved globally! The lists can become quite long because there can be lots of
+%D parameters passed on so we clean up the list afterwards.
+
+\newtoks\everypositionaction
+\newtoks\everyinsertpositionaction
+\newtoks\everycleanpositionaction
+
+\installcorenamespace{positionaction}
+\installcorenamespace{positioncleanup}
+
+\protected\def\anch_positions_set_action#1%
+ {\gdefcsname\??positionaction#1\endcsname} % nicely gobbles spaces
+
+\permanent\protected\def\doifpositionaction#1%
+ {\ifcsname\??positionaction#1\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\permanent\protected\def\doifelsepositionaction#1%
+ {\ifcsname\??positionaction#1\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifpositionactionelse\doifelsepositionaction
+
+\permanent\protected\def\dopositionaction#1%
+ {\edef\currentpositionaction{#1}%
+ \ifcsname\??positionaction\currentpositionaction\endcsname
+ \anch_positions_action_indeed
+ \fi}
+
+\def\anch_positions_action_indeed
+ {\doifelseposition\currentpositionaction
+ \anch_positions_action_indeed_yes
+ \anch_positions_action_indeed_nop}
+
+\def\anch_positions_action_indeed_nop
+ {\anch_positions_trace_action_nop}
+
+\def\anch_positions_action_indeed_yes % we need a way to figure out if we have actions
+ {\begingroup
+ \setbox\scratchbox\hbox % \hpack
+ {\anch_positions_trace_action_yes
+ \the\everyinsertpositionaction
+ \the\everypositionaction
+ \begincsname\??positionaction\currentpositionaction\endcsname
+ \anch_positions_cleanup_action}%
+ \smashedbox\scratchbox % smashing is really needed else we get problems with too big overlays
+ \endgroup}
+
+\protected\def\anch_positions_trace_action_nop_indeed
+ {\anch_positions_trace\clap\darkred{<\currentpositionaction>}}
+
+\protected\def\anch_positions_trace_action_yes_indeed
+ {\anch_positions_trace\clap\darkgreen{<\currentpositionaction>}}
+
+\let\anch_positions_trace_action_nop\relax
+\let\anch_positions_trace_action_yes\relax
+
+\appendtoks
+ \let\anch_positions_trace_action_nop\anch_positions_trace_action_nop_indeed
+ \let\anch_positions_trace_action_yes\anch_positions_trace_action_yes_indeed
+\to \t_anch_positions_tracers
+
+%D Here the complication has to do with collecting actions for later execution. This
+%D collection is especially handy when we want to move actions to a specific layer.
+%D Such series of actions are stored in a macro that is cleaned up after each
+%D invocation.
+
+\def\anch_positions_cleanup_action % not in trialtypesetting
+ {\ifcsname\??positioncleanup\currentpositionaction\endcsname
+ \the\everycleanpositionaction
+ \xdefcsname\??positioncleanup\currentpositionaction\endcsname{\csname\??positioncleanup\currentpositionaction\endcsname}%
+ \fi}
+
+\permanent\protected\def\handlepositionaction#1\with#2\on#3% ugly, will change
+ {\begingroup
+ \edef\currentpositionanchor{\ifempty\currentpositionoverlay#3\else\currentpositionoverlay::\MPanchoridentifier\fi}%
+ \normalexpanded{\anch_positions_set_action{\currentpositionanchor}{\noexpand\csname\??positioncleanup\currentpositionanchor\endcsname}}%
+ \let#1\relax
+ \ifcsname\??positioncleanup\currentpositionanchor\endcsname
+ \xdefcsname\??positioncleanup\currentpositionanchor\endcsname{\csname\??positioncleanup\currentpositionanchor\endcsname#1#2}%
+ \else
+ \xdefcsname\??positioncleanup\currentpositionanchor\endcsname{#1#2}%
+ \fi
+ \endgroup}
+
+%D The first version of this module implemented head and tail anchors. Currently we
+%D stick to just one anchor and derive the head and tail anchors from this one. We
+%D set these anchors before and after each page.
+
+\newdimen\c_anch_page_width
+\newdimen\c_anch_page_height
+
+\protected\def\anch_positions_register_page#1% this one is flushed first ! ... can't we avoid this one
+ {\ifpositioning\ifcase\realpageno\or
+ \ifdim\c_anch_page_height=\paperheight
+ \ifdim\c_anch_page_width=\paperwidth
+ % no change
+ \else
+ \c_anch_page_width \paperwidth
+ \c_anch_page_height\paperheight
+ \anch_make_page_box{#1}% \ifvbox#1\setbox#1\hpack{\box#1}\fi
+ \fi
+ \else
+ \c_anch_page_width \paperwidth
+ \c_anch_page_height\paperheight
+ \anch_make_page_box{#1}% \ifvbox#1\setbox#1\hpack{\box#1}\fi
+ \fi
+ \fi\fi}
+
+\protected\def\anch_positions_place_anchors
+ {\ifpositioning
+ \anch_positions_place_anchors_yes
+ \else
+ \anch_positions_place_anchors_nop
+ \fi}
+
+\def\anch_positions_place_anchors_yes % todo : depth pagebox
+ {\begingroup
+ \setbox\scratchbox\emptyhbox
+ \ht\scratchbox\textheight
+ \dp\scratchbox\zeropoint % redundant
+ \wd\scratchbox\makeupwidth
+ \anch_mark_text_box\scratchbox
+ \box\scratchbox
+ \endgroup}
+
+\def\anch_positions_place_anchors_nop
+ {\vkern\textheight}
+
+%D \macros
+%D {positionoverlay,startpositionoverlay}
+%D
+%D As long as we're dealing with graphics it makes much sense to use the available
+%D overlay mechanism. For this purpose, we define some dedicated overlay extensions.
+%D
+%D \startbuffer[sample]
+%D \defineoverlay [sample] [\positionoverlay{sample}]
+%D
+%D \startpositionoverlay{sample}
+%D \setMPpositiongraphic{A-1}{connectcenter}{from=A-1,to=A-2}
+%D \stoppositionoverlay
+%D \stopbuffer
+%D
+%D \typebuffer[sample]
+%D
+%D \startbuffer[graphic]
+%D \startMPpositiongraphic{connectcenter}
+%D path pa, pb ; pair ca, cb ;
+%D initialize_box(\MPpos{\MPvar{from}}) ; pa := pxy ; ca := cxy ;
+%D initialize_box(\MPpos{\MPvar{to}}) ; pb := pxy ; cb := cxy ;
+%D draw pa withcolor red ;
+%D draw pb withcolor red ;
+%D draw ca -- cb withcolor blue ;
+%D anchor_box(\MPanchor{\MPvar{from}}) ;
+%D \stopMPpositiongraphic
+%D \stopbuffer
+%D
+%D We can best demonstrate this in an example, say:
+%D
+%D \startbuffer[text]
+%D \framed
+%D [backgroundachtergrond=sample,align=middle,width=7cm]
+%D {We want to connect \hpos {A-1} {this} word with its
+%D grammatical cousin \hpos {A-2} {that}.}
+%D \stopbuffer
+%D
+%D \typebuffer[text]
+%D
+%D \startlinecorrection
+%D %\getbuffer[graphic,sample,text]
+%D \stoplinecorrection
+%D
+%D The graphic is defined in the following way, using some macros defined in an
+%D auxiliary \METAPOST\ module that is preloaded.
+%D
+%D \typebuffer[graphic]
+
+\immutable\def\MPanchoridentifier{mpa} % {mp-anchor}
+\mutable \def\MPanchornumber {\the\realpageno}
+\mutable \let\MPanchorid \empty
+
+%D The rest of the definitions concerning such overlays may look complicated,
+
+\mutable\let\currentpositionoverlay\empty
+
+%D Position actions are automatically executed when a position is set.
+
+\immutable\def\textbackgroundoverlay#1{\v!text#1}
+
+\permanent\protected\def\positionoverlay % the test prevents too many redundant positions
+ {\ifpositioning % in (not used) text* position layers
+ \expandafter\anch_positions_overlay_indeed
+ \else % also \iftrialtypesetting test here?
+ \expandafter\gobbleoneargument
+ \fi}
+
+\def\anch_positions_overlay_indeed#1%
+ {\begingroup
+ \edef\currentpositionoverlay{#1}%
+ \ifcsname\??positionaction\currentpositionoverlay::\MPanchoridentifier\endcsname
+ \anch_positions_overlay_compose
+ \fi
+ \endgroup}
+
+\permanent\def\MPoverlayanchor#1{\MPpos\MPanchorid}
+
+\def\anch_positions_overlay_compose
+ {\vpack to \d_overlay_height
+ {%\writestatus{!!!}{\currentpositionoverlay/\MPanchoridentifier/\MPanchornumber}%
+ \edef\MPanchorid{\currentpositionoverlay::\MPanchoridentifier:\MPanchornumber}% realpageno
+ % \edef\MPanchor##1{\MPpos\MPanchorid}%
+ \enforced\let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used
+ \the\everyinsertpositionaction
+ \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid
+ \setbox\scratchbox\hbox to \d_overlay_width % \hpack
+ {\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}%
+ \ht\scratchbox\d_overlay_height
+ \dp\scratchbox\zeropoint
+ \anch_mark_tagged_box\scratchbox\MPanchorid % needs an hbox
+ \box\scratchbox
+ \vfill}}
+
+\permanent\protected\def\positionregionoverlay % shares regions
+ {\ifpositioning
+ \expandafter\anch_positions_region_overlay_indeed
+ \else % also \iftrialtypesetting test here?
+ \expandafter\gobbletwoarguments
+ \fi}
+
+\let\currentpositionregion\empty
+
+\def\anch_positions_region_overlay_indeed#1#2%
+ {\begingroup
+ \edef\currentpositionregion {#1}%
+ \edef\currentpositionoverlay{#2}%
+ \ifcsname\??positionaction\currentpositionoverlay::\MPanchoridentifier\endcsname
+ \anch_positions_region_overlay_compose
+ \fi
+ \endgroup}
+
+\def\anch_positions_region_overlay_compose
+ {\vpack to \d_overlay_height
+ {\let\MPanchorid\currentpositionregion
+ \enforced\let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used
+ \the\everyinsertpositionaction
+ \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid
+ \setbox\scratchbox\hbox to \d_overlay_width % \hpack
+ {\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}%
+ \ht\scratchbox\d_overlay_height
+ \dp\scratchbox\zeropoint
+ \box\scratchbox
+ \vfill}}
+
+% \let\anch_positions_overlay_nop\gobbleoneargument
+
+\permanent\protected\def\startpositionoverlay
+ {\iftrialtypesetting
+ \expandafter\anch_positions_overlay_start_nop
+ \else
+ \expandafter\anch_positions_overlay_start_yes
+ \fi}
+
+\def\anch_positions_overlay_start_nop#1\stoppositionoverlay
+ {}
+
+\ifdefined\checkpositionoverlays \else \let\checkpositionoverlays\relax \fi
+
+\mutable\let\currentpositionoverlay\empty
+
+\def\anch_positions_overlay_start_yes#1%
+ {\checkpositionoverlays
+ \edef\currentpositionoverlay{#1}}
+
+\permanent\protected\def\stoppositionoverlay
+ {\let\currentpositionoverlay\empty}
+
+%D A position graphic is a normal (non||reused) \METAPOST\ graphic, used
+%D immediately, with zero dimensions, so that a sequence of them does not harm.
+
+\installcorenamespace{positiongraphic}
+\installcorenamespace{positionmethod}
+%installcorenamespace{graphicvariable}
+
+\newbox\b_anch_positions_graphic
+
+\permanent\tolerant\protected\def\startMPpositiongraphic#=#*#=#:#3\stopMPpositiongraphic % tag list mpcode
+ {\gdefcsname\??positiongraphic#1\endcsname{\anch_positions_meta_graphic_use{#1}{#2}{#3}}}
+
+\aliased\let\stopMPpositiongraphic\relax
+
+\def\anch_positions_meta_graphic_prepare
+ {\ifcsname\??graphicvariable\currentmpvariableclass:self\endcsname \else
+ \letcsname\??graphicvariable\currentmpvariableclass:self\endcsname\currentposition
+ \fi
+ \ifcsname\??graphicvariable\currentmpvariableclass:from\endcsname \else
+ \letcsname\??graphicvariable\currentmpvariableclass:from\endcsname\currentposition
+ \fi}
+
+\def\anch_positions_meta_graphic_use#1#2#3%
+ {\begingroup
+ \meta_prepare_variables{#2}%
+ \anch_positions_meta_graphic_prepare
+ \startMPcode#3\stopMPcode
+ \endgroup}
+
+\permanent\tolerant\protected\def\MPpositiongraphic#=#*#=%
+ {\ifcsname\??positionmethod#1\endcsname % method
+ \expandafter\anch_positions_meta_graphic_direct_method
+ \orelse\ifcsname\??positiongraphic#1\endcsname
+ \expandafter\anch_positions_meta_graphic_direct_normal
+ \else
+ \expandafter\gobbletwoarguments
+ \fi{#1}{#2}}
+
+\def\anch_positions_meta_graphic_direct_method{\anch_positions_meta_graphic_direct\??positionmethod }
+\def\anch_positions_meta_graphic_direct_normal{\anch_positions_meta_graphic_direct\??positiongraphic}
+
+\def\anch_positions_meta_graphic_direct#1#2#3% what tag setups
+ {\begingroup
+ \setupMPvariables[#2][#3]%
+ \edef\currentmpvariableclass{#2}%
+ \anch_positions_meta_graphic_prepare
+ \obeyMPboxorigin % do we also set the size ? when needed this must be done in mp ... might change
+ \enforced\tolerant\protected\def\MPpositiongraphic##=##*##={\anch_positions_meta_graphic_nested{#3}{##1}{##2}}% takes two extra arguments
+ % \def\anch_positions_meta_graphic_direct{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments
+ \setbox\b_anch_positions_graphic\hbox % \hpack
+ {\ignorespaces\begincsname#1#2\endcsname\removelastspace}%
+ \smashbox\b_anch_positions_graphic
+ \box\b_anch_positions_graphic
+ \endgroup}
+
+\def\anch_positions_meta_graphic_nested#1#2#3% nesting used in prikkels / pascal (might go away)
+ {\begingroup
+ \setupMPvariables[#2][#1,#3]%
+ \edef\currentmpvariableclass{#2}%
+ \anch_positions_meta_graphic_prepare
+ \begincsname\??positiongraphic#2\endcsname
+ \endgroup}%
+
+\permanent\def\startMPpositionmethod#1#2\stopMPpositionmethod
+ {\gdefcsname\??positionmethod#1\endcsname{#2}} % todo: var list here
+
+\aliased\let\stopMPpositionmethod\relax
+
+%D Simple one position graphics.
+
+\permanent\tolerant\protected\def\setMPpositiongraphic#=#*#=#*#=%
+ {\ifempty\currentpositionoverlay
+ \anch_positions_set_action{#1}{\MPpositiongraphic{#2}{#3}}%
+ \else % silly can be one
+ \anch_positions_meta_graphic_handle{#1}{#2}{#3}%
+ \fi}
+
+\def\anch_positions_meta_graphic_handle#1#2#3% combine with boxes
+ {\handlepositionaction\anch_positions_meta_graphic_handle_indeed\with{#1}{#2}{#3}\on{#2}}
+
+\def\anch_positions_meta_graphic_insert#1#2#3% pos tag setups
+ {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard
+ \def\currentposition{#1}\MPpositiongraphic{#2}{#3}%
+ \fi}
+
+\let\anch_positions_meta_graphic_handle_indeed\relax
+
+\appendtoks
+ \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_insert
+\to \everyinsertpositionaction
+
+\def\anch_positions_meta_graphic_cleanup#1#2#3% pos tag setups
+ {\ifnum\MPp{#1}<\realpageno \else
+ \noexpand\anch_positions_meta_graphic_handle_indeed{#1}{#2}{#3}%
+ \fi}
+
+\appendtoks
+ \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_cleanup
+\to \everycleanpositionaction
+
+%D Graphics that span two positions (beware, does not cross pages).
+
+\permanent\tolerant\protected\def\setMPpositiongraphicrange#=#*#=#*#=#*#=%
+ {\ifempty\currentpositionoverlay
+ \anch_positions_set_action{#1}{\MPpositiongraphic{#3}{#4}}%
+ \else
+ \anch_positions_meta_graphic_handle_range{#1}{#2}{#3}{#4}%
+ \fi}
+
+\def\anch_positions_meta_graphic_handle_range#1#2#3#4%
+ {\handlepositionaction\anch_positions_meta_graphic_handle_range_indeed\with{#1}{#2}{#3}{#4}\on{#2}}
+
+\def\anch_positions_meta_graphic_insert_range#1#2#3#4% pos pos tag setups
+ {\clf_doifelserangeonpage{#1}{#2}\realpageno
+ {\def\currentposition{#1}%
+ \MPpositiongraphic{#3}{#4}}%
+ {}}
+
+\appendtoks
+ \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_insert_range
+\to \everyinsertpositionaction
+
+\def\anch_positions_meta_graphic_cleanup_range#1#2#3#4% pos tag setups
+ {\ifnum\MPp{#2}<\realpageno \else
+ \noexpand \anch_positions_meta_graphic_handle_range_indeed{#1}{#2}{#3}{#4}%
+ \fi}
+
+\appendtoks
+ \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_cleanup_range
+\to \everycleanpositionaction
+
+\let\anch_positions_meta_graphic_handle_range_indeed\gobblefourarguments
+
+% Helpers:
+
+\permanent\def\MPgetposboxes #1#2{\clf_fetchposboxes{#1}{#2}\realpageno}
+\permanent\def\MPgetmultipars#1#2{\clf_fetchmultipar{#1}{#2}\realpageno}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-pos.lmt b/Master/texmf-dist/tex/context/base/mkxl/anch-pos.lmt
new file mode 100644
index 00000000000..67d1657f20d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-pos.lmt
@@ -0,0 +1,1636 @@
+if not modules then modules = { } end modules ['anch-pos'] = {
+ version = 1.001,
+ comment = "companion to anch-pos.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+--[[ldx--
+
We save positional information in the main utility table. Not only
+can we store much more information in but it's also
+more efficient.
+--ldx]]--
+
+-- plus (extra) is obsolete but we will keep it for a while
+--
+-- maybe replace texsp by our own converter (stay at the lua end)
+-- eventually mp will have large numbers so we can use sp there too
+--
+-- this is one of the first modules using scanners and we need to replace it by
+-- implement and friends
+--
+-- we could have namespaces, like p, page, region, columnarea, textarea but then
+-- we need virtual table accessors as well as have tag/id accessors ... we don't
+-- save much here (at least not now)
+--
+-- This was the last module that got rid of directly setting scanners, with a little
+-- performance degradation but not that noticeable.
+
+local tostring, next, setmetatable, tonumber = tostring, next, setmetatable, tonumber
+local sort = table.sort
+local format, gmatch = string.format, string.gmatch
+local lpegmatch = lpeg.match
+local insert, remove = table.insert, table.remove
+local allocate = utilities.storage.allocate
+
+local report = logs.reporter("positions")
+
+local scanners = tokens.scanners
+local scanstring = scanners.string
+local scaninteger = scanners.integer
+local scandimen = scanners.dimen
+
+local implement = interfaces.implement
+
+local commands = commands
+local context = context
+
+local ctx_latelua = context.latelua
+
+local tex = tex
+local texgetcount = tex.getcount
+local texgetinteger = tex.getintegervalue or tex.getcount
+local texsetcount = tex.setcount
+local texget = tex.get
+local texsp = tex.sp
+----- texsp = string.todimen -- because we cache this is much faster but no rounding
+
+local setmetatableindex = table.setmetatableindex
+local setmetatablenewindex = table.setmetatablenewindex
+
+local nuts = nodes.nuts
+
+local setlink = nuts.setlink
+local getlist = nuts.getlist
+local setlist = nuts.setlist
+local getbox = nuts.getbox
+local getid = nuts.getid
+local getwhd = nuts.getwhd
+
+local hlist_code = nodes.nodecodes.hlist
+
+local find_tail = nuts.tail
+----- hpack = nuts.hpack
+
+local new_latelua = nuts.pool.latelua
+
+local variables = interfaces.variables
+local v_text = variables.text
+local v_column = variables.column
+
+local pt = number.dimenfactors.pt
+local pts = number.pts
+local formatters = string.formatters
+
+local collected = allocate()
+local tobesaved = allocate()
+
+local jobpositions = {
+ collected = collected,
+ tobesaved = tobesaved,
+}
+
+job.positions = jobpositions
+
+local default = { -- not r and paragraphs etc
+ __index = {
+ x = 0, -- x position baseline
+ y = 0, -- y position baseline
+ w = 0, -- width
+ h = 0, -- height
+ d = 0, -- depth
+ p = 0, -- page
+ n = 0, -- paragraph
+ ls = 0, -- leftskip
+ rs = 0, -- rightskip
+ hi = 0, -- hangindent
+ ha = 0, -- hangafter
+ hs = 0, -- hsize
+ pi = 0, -- parindent
+ ps = false, -- parshape
+ dir = 0,
+ }
+}
+
+local f_b_tag = formatters["b:%s"]
+local f_e_tag = formatters["e:%s"]
+local f_p_tag = formatters["p:%s"]
+local f_w_tag = formatters["w:%s"]
+
+local f_region = formatters["region:%s"]
+
+local f_tag_three = formatters["%s:%s:%s"]
+local f_tag_two = formatters["%s:%s"]
+
+local nofregular = 0
+local nofspecial = 0
+local splitter = lpeg.splitat(":",true)
+
+local pagedata = { }
+local columndata = setmetatableindex("table") -- per page
+local freedata = setmetatableindex("table") -- per page
+
+local function initializer()
+ tobesaved = jobpositions.tobesaved
+ collected = jobpositions.collected
+ for tag, data in next, collected do
+ local prefix, rest = lpegmatch(splitter,tag)
+ if prefix == "p" then
+ nofregular = nofregular + 1
+ elseif prefix == "page" then
+ nofregular = nofregular + 1
+ pagedata[tonumber(rest) or 0] = data
+ elseif prefix == "free" then
+ nofspecial = nofspecial + 1
+ local t = freedata[data.p or 0]
+ t[#t+1] = data
+ elseif prefix == "columnarea" then
+ columndata[data.p or 0][data.c or 0] = data
+ end
+ setmetatable(data,default)
+ end
+ --
+ local pages = structures.pages.collected
+ if pages then
+ local last = nil
+ for p=1,#pages do
+ local region = "page:" .. p
+ local data = pagedata[p]
+ local free = freedata[p]
+ if free then
+ sort(free,function(a,b) return b.y < a.y end) -- order matters !
+ end
+ if data then
+ last = data
+ last.free = free
+ elseif last then
+ local t = setmetatableindex({ free = free, p = p },last)
+ if not collected[region] then
+ collected[region] = t
+ else
+ -- something is wrong
+ end
+ pagedata[p] = t
+ end
+ end
+ end
+ jobpositions.pagedata = pagedata
+end
+
+function jobpositions.used()
+ return next(collected) -- we can safe it
+end
+
+function jobpositions.getfree(page)
+ return freedata[page]
+end
+
+-- we can gain a little when we group positions but then we still have to
+-- deal with regions and cells so we either end up with lots of extra small
+-- tables pointing to them and/or assembling/disassembling so in the end
+-- it makes no sense to do it (now) and still have such a mix
+--
+-- proof of concept code removed ... see archive
+
+local function finalizer()
+ -- We make the (possible extensive) shape lists sparse working
+ -- from the end. We could also drop entries here that have l and
+ -- r the same which saves testing later on.
+ for k, v in next, tobesaved do
+ local s = v.s
+ if s then
+ for p, data in next, s do
+ local n = #data
+ if n > 1 then
+ local ph = data[1][2]
+ local pd = data[1][3]
+ local xl = data[1][4]
+ local xr = data[1][5]
+ for i=2,n do
+ local di = data[i]
+ local h = di[2]
+ local d = di[3]
+ local l = di[4]
+ local r = di[5]
+ if r == xr then
+ di[5] = nil
+ if l == xl then
+ di[4] = nil
+ if d == pd then
+ di[3] = nil
+ if h == ph then
+ di[2] = nil
+ else
+ ph = h
+ end
+ else
+ pd, ph = d, h
+ end
+ else
+ ph, pd, xl = h, d, l
+ end
+ else
+ ph, pd, xl, xr = h, d, l, r
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+job.register('job.positions.collected', tobesaved, initializer, finalizer)
+
+local regions = { }
+local nofregions = 0
+local region = nil
+
+local columns = { }
+local nofcolumns = 0
+local column = nil
+
+local nofpages = nil
+
+-- beware ... we're not sparse here as lua will reserve slots for the nilled
+
+local getpos, gethpos, getvpos, getrpos
+
+function jobpositions.registerhandlers(t)
+ getpos = t and t.getpos or function() return 0, 0 end
+ getrpos = t and t.getrpos or function() return 0, 0, 0 end
+ gethpos = t and t.gethpos or function() return 0 end
+ getvpos = t and t.getvpos or function() return 0 end
+end
+
+function jobpositions.getpos () return getpos () end
+function jobpositions.getrpos() return getrpos() end
+function jobpositions.gethpos() return gethpos() end
+function jobpositions.getvpos() return getvpos() end
+
+-------- jobpositions.getcolumn() return column end
+
+jobpositions.registerhandlers()
+
+local function setall(name,p,x,y,w,h,d,extra)
+ tobesaved[name] = {
+ p = p,
+ x = x ~= 0 and x or nil,
+ y = y ~= 0 and y or nil,
+ w = w ~= 0 and w or nil,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ e = extra ~= "" and extra or nil,
+ r = region,
+ c = column,
+ r2l = texgetinteger("inlinelefttoright") == 1 and true or nil,
+ }
+end
+
+local function enhance(data)
+ if not data then
+ return nil
+ end
+ if data.r == true then -- or ""
+ data.r = region
+ end
+ if data.x == true then
+ if data.y == true then
+ local x, y = getpos()
+ data.x = x ~= 0 and x or nil
+ data.y = y ~= 0 and y or nil
+ else
+ local x = gethpos()
+ data.x = x ~= 0 and x or nil
+ end
+ elseif data.y == true then
+ local y = getvpos()
+ data.y = y ~= 0 and y or nil
+ end
+ if data.p == true then
+ data.p = texgetcount("realpageno") -- we should use a variable set in otr
+ end
+ if data.c == true then
+ data.c = column
+ end
+ if data.w == 0 then
+ data.w = nil
+ end
+ if data.h == 0 then
+ data.h = nil
+ end
+ if data.d == 0 then
+ data.d = nil
+ end
+ return data
+end
+
+-- analyze some files (with lots if margindata) and then when one key optionally
+-- use that one instead of a table (so, a 3rd / 4th argument: key, e.g. "x")
+
+local function set(name,index,value) -- ,key
+ -- officially there should have been a settobesaved
+ local data = enhance(value or {})
+ if value then
+ container = tobesaved[name]
+ if not container then
+ tobesaved[name] = {
+ [index] = data
+ }
+ else
+ container[index] = data
+ end
+ else
+ tobesaved[name] = data
+ end
+end
+
+local function setspec(specification)
+ local name = specification.name
+ local index = specification.index
+ local value = specification.value
+ local data = enhance(value or {})
+ if value then
+ container = tobesaved[name]
+ if not container then
+ tobesaved[name] = {
+ [index] = data
+ }
+ else
+ container[index] = data
+ end
+ else
+ tobesaved[name] = data
+ end
+end
+
+local function get(id,index)
+ if index then
+ local container = collected[id]
+ return container and container[index]
+ else
+ return collected[id]
+ end
+end
+
+------------.setdim = setdim
+jobpositions.setall = setall
+jobpositions.set = set
+jobpositions.setspec = setspec
+jobpositions.get = get
+
+implement {
+ name = "dosaveposition",
+ public = true,
+ protected = true,
+ arguments = { "argument", "integerargument", "dimenargument", "dimenargument" },
+ actions = setall, -- name p x y
+}
+
+implement {
+ name = "dosavepositionwhd",
+ public = true,
+ protected = true,
+ arguments = { "argument", "integerargument", "dimenargument", "dimenargument", "dimenargument", "dimenargument", "dimenargument" },
+ actions = setall, -- name p x y w h d
+}
+
+implement {
+ name = "dosavepositionplus",
+ public = true,
+ protected = true,
+ arguments = { "argument", "integerargument", "dimenargument", "dimenargument", "dimenargument", "dimenargument", "dimenargument", "argument" },
+ actions = setall, -- name p x y w h d extra
+}
+
+-- will become private table (could also become attribute driven but too nasty
+-- as attributes can bleed e.g. in margin stuff)
+
+-- not much gain in keeping stack (inc/dec instead of insert/remove)
+
+local function b_column(specification)
+ local tag = specification.tag
+ local x = gethpos()
+ tobesaved[tag] = {
+ r = true,
+ x = x ~= 0 and x or nil,
+ -- w = 0,
+ }
+ insert(columns,tag)
+ column = tag
+end
+
+local function e_column()
+ local t = tobesaved[column]
+ if not t then
+ -- something's wrong
+ else
+ local x = gethpos() - t.x
+ t.w = x ~= 0 and x or nil
+ t.r = region
+ end
+ remove(columns)
+ column = columns[#columns]
+end
+
+jobpositions.b_column = b_column
+jobpositions.e_column = e_column
+
+implement {
+ name = "bposcolumn",
+ arguments = "string",
+ actions = function(tag)
+ insert(columns,tag)
+ column = tag
+ end
+}
+
+implement {
+ name = "bposcolumnregistered",
+ arguments = "string",
+ actions = function(tag)
+ insert(columns,tag)
+ column = tag
+ ctx_latelua { action = b_column, tag = tag }
+ end
+}
+
+implement {
+ name = "eposcolumn",
+ actions = function()
+ remove(columns)
+ column = columns[#columns]
+ end
+}
+
+implement {
+ name = "eposcolumnregistered",
+ actions = function()
+ ctx_latelua { action = e_column }
+ remove(columns)
+ column = columns[#columns]
+ end
+}
+
+-- regions
+
+local function b_region(specification)
+ local tag = specification.tag or specification
+ local last = tobesaved[tag]
+ local x, y = getpos()
+ last.x = x ~= 0 and x or nil
+ last.y = y ~= 0 and y or nil
+ last.p = texgetcount("realpageno")
+ insert(regions,tag) -- todo: fast stack
+ region = tag
+end
+
+local function e_region(specification)
+ local last = tobesaved[region]
+ local y = getvpos()
+ local x, y = getpos()
+ if specification.correct then
+ local h = (last.y or 0) - y
+ last.h = h ~= 0 and h or nil
+ end
+ last.y = y ~= 0 and y or nil
+ remove(regions) -- todo: fast stack
+ region = regions[#regions]
+end
+
+jobpositions.b_region = b_region
+jobpositions.e_region = e_region
+
+local lastregion
+
+local function setregionbox(n,tag,k,lo,ro,to,bo,column) -- kind
+ if not tag or tag == "" then
+ nofregions = nofregions + 1
+ tag = f_region(nofregions)
+ end
+ local box = getbox(n)
+ local w, h, d = getwhd(box)
+ tobesaved[tag] = {
+ -- p = texgetcount("realpageno"), -- we copy them
+ x = 0,
+ y = 0,
+ w = w ~= 0 and w or nil,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ k = k ~= 0 and k or nil,
+ lo = lo ~= 0 and lo or nil,
+ ro = ro ~= 0 and ro or nil,
+ to = to ~= 0 and to or nil,
+ bo = bo ~= 0 and bo or nil,
+ c = column or nil,
+ }
+ lastregion = tag
+ return tag, box
+end
+
+local function markregionbox(n,tag,correct,...) -- correct needs checking
+ local tag, box = setregionbox(n,tag,...)
+ -- todo: check if tostring is needed with formatter
+ local push = new_latelua { action = b_region, tag = tag }
+ local pop = new_latelua { action = e_region, correct = correct }
+ -- maybe we should construct a hbox first (needs experimenting) so that we can avoid some at the tex end
+ local head = getlist(box)
+ -- no, this fails with \framed[region=...] .. needs thinking
+ -- if getid(box) ~= hlist_code then
+ -- -- report("mark region box assumes a hlist, fix this for %a",tag)
+ -- head = hpack(head)
+ -- end
+ if head then
+ local tail = find_tail(head)
+ setlink(push,head)
+ setlink(tail,pop)
+ else -- we can have a simple push/pop
+ setlink(push,pop)
+ end
+ setlist(box,push)
+end
+
+jobpositions.markregionbox = markregionbox
+jobpositions.setregionbox = setregionbox
+
+function jobpositions.enhance(name)
+ enhance(tobesaved[name])
+end
+
+function jobpositions.gettobesaved(name,tag)
+ local t = tobesaved[name]
+ if t and tag then
+ return t[tag]
+ else
+ return t
+ end
+end
+
+function jobpositions.settobesaved(name,tag,data)
+ local t = tobesaved[name]
+ if t and tag and data then
+ t[tag] = data
+ end
+end
+
+local nofparagraphs = 0
+
+implement {
+ name = "parpos",
+ actions = function()
+ nofparagraphs = nofparagraphs + 1
+ texsetcount("global","c_anch_positions_paragraph",nofparagraphs)
+ local box = getbox("strutbox")
+ local w, h, d = getwhd(box)
+ local t = {
+ p = true,
+ c = true,
+ r = true,
+ x = true,
+ y = true,
+ h = h,
+ d = d,
+ hs = texget("hsize"), -- never 0
+ }
+ local leftskip = texget("leftskip",false)
+ local rightskip = texget("rightskip",false)
+ local hangindent = texget("hangindent")
+ local hangafter = texget("hangafter")
+ local parindent = texget("parindent")
+ local parshape = texget("parshape")
+ if leftskip ~= 0 then
+ t.ls = leftskip
+ end
+ if rightskip ~= 0 then
+ t.rs = rightskip
+ end
+ if hangindent ~= 0 then
+ t.hi = hangindent
+ end
+ if hangafter ~= 1 and hangafter ~= 0 then -- can not be zero .. so it needs to be 1 if zero
+ t.ha = hangafter
+ end
+ if parindent ~= 0 then
+ t.pi = parindent
+ end
+ if parshape and #parshape > 0 then
+ t.ps = parshape
+ end
+ local name = f_p_tag(nofparagraphs)
+ tobesaved[name] = t
+ ctx_latelua { action = enhance, specification = t }
+ end
+}
+
+implement {
+ name = "dosetposition",
+ arguments = "argument",
+ public = true,
+ protected = true,
+ actions = function(name)
+ local spec = {
+ p = true,
+ c = column,
+ r = true,
+ x = true,
+ y = true,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ r2l = texgetinteger("inlinelefttoright") == 1 or nil,
+ }
+ tobesaved[name] = spec
+ ctx_latelua { action = enhance, specification = spec }
+ end
+}
+
+implement {
+ name = "dosetpositionwhd",
+ arguments = { "argument", "dimenargument", "dimenargument", "dimenargument" },
+ public = true,
+ protected = true,
+ actions = function(name,w,h,d)
+ local spec = {
+ p = true,
+ c = column,
+ r = true,
+ x = true,
+ y = true,
+ w = w ~= 0 and w or nil,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ r2l = texgetinteger("inlinelefttoright") == 1 or nil,
+ }
+ tobesaved[name] = spec
+ ctx_latelua { action = enhance, specification = spec }
+ end
+}
+
+implement {
+ name = "dosetpositionbox",
+ arguments = { "argument", "integerargument" },
+ public = true,
+ protected = true,
+ actions = function(name,n)
+ local box = getbox(n)
+ local w, h, d = getwhd(box)
+ local spec = {
+ p = true,
+ c = column,
+ r = true,
+ x = true,
+ y = true,
+ w = w ~= 0 and w or nil,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ r2l = texgetinteger("inlinelefttoright") == 1 or nil,
+ }
+ tobesaved[name] = spec
+ ctx_latelua { action = enhance, specification = spec }
+ end
+}
+
+implement {
+ name = "dosetpositionplus",
+ arguments = { "argument", "dimenargument", "dimenargument", "dimenargument" },
+ public = true,
+ protected = true,
+ actions = function(name,w,h,d)
+ local spec = {
+ p = true,
+ c = column,
+ r = true,
+ x = true,
+ y = true,
+ w = w ~= 0 and w or nil,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ e = scanstring(),
+ r2l = texgetinteger("inlinelefttoright") == 1 or nil,
+ }
+ tobesaved[name] = spec
+ ctx_latelua { action = enhance, specification = spec }
+ end
+}
+
+implement {
+ name = "dosetpositionstrut",
+ arguments = "argument",
+ public = true,
+ protected = true,
+ actions = function(name)
+ local box = getbox("strutbox")
+ local w, h, d = getwhd(box)
+ local spec = {
+ p = true,
+ c = column,
+ r = true,
+ x = true,
+ y = true,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ r2l = texgetinteger("inlinelefttoright") == 1 or nil,
+ }
+ tobesaved[name] = spec
+ ctx_latelua { action = enhance, specification = spec }
+ end
+}
+
+implement {
+ name = "dosetpositionstrutkind",
+ arguments = { "argument", "integerargument" },
+ public = true,
+ protected = true,
+ actions = function(name,kind)
+ local box = getbox("strutbox")
+ local w, h, d = getwhd(box)
+ local spec = {
+ k = kind,
+ p = true,
+ c = column,
+ r = true,
+ x = true,
+ y = true,
+ h = h ~= 0 and h or nil,
+ d = d ~= 0 and d or nil,
+ n = nofparagraphs > 0 and nofparagraphs or nil,
+ r2l = texgetinteger("inlinelefttoright") == 1 or nil,
+ }
+ tobesaved[name] = spec
+ ctx_latelua { action = enhance, specification = spec }
+ end
+}
+
+function jobpositions.getreserved(tag,n)
+ if tag == v_column then
+ local fulltag = f_tag_three(tag,texgetcount("realpageno"),n or 1)
+ local data = collected[fulltag]
+ if data then
+ return data, fulltag
+ end
+ tag = v_text
+ end
+ if tag == v_text then
+ local fulltag = f_tag_two(tag,texgetcount("realpageno"))
+ return collected[fulltag] or false, fulltag
+ end
+ return collected[tag] or false, tag
+end
+
+function jobpositions.copy(target,source)
+ collected[target] = collected[source]
+end
+
+function jobpositions.replace(id,p,x,y,w,h,d)
+ collected[id] = { p = p, x = x, y = y, w = w, h = h, d = d } -- c g
+end
+
+local function getpage(id)
+ local jpi = collected[id]
+ return jpi and jpi.p
+end
+
+local function getcolumn(id)
+ local jpi = collected[id]
+ return jpi and jpi.c or false
+end
+
+local function getparagraph(id)
+ local jpi = collected[id]
+ return jpi and jpi.n
+end
+
+local function getregion(id)
+ local jpi = collected[id]
+ if jpi then
+ local r = jpi.r
+ if r then
+ return r
+ end
+ local p = jpi.p
+ if p then
+ return "page:" .. p
+ end
+ end
+ return false
+end
+
+jobpositions.page = getpage
+jobpositions.column = getcolumn
+jobpositions.paragraph = getparagraph
+jobpositions.region = getregion
+
+jobpositions.p = getpage -- not used, kind of obsolete
+jobpositions.c = getcolumn -- idem
+jobpositions.n = getparagraph -- idem
+jobpositions.r = getregion -- idem
+
+function jobpositions.x(id)
+ local jpi = collected[id]
+ return jpi and jpi.x
+end
+
+function jobpositions.y(id)
+ local jpi = collected[id]
+ return jpi and jpi.y
+end
+
+function jobpositions.width(id)
+ local jpi = collected[id]
+ return jpi and jpi.w
+end
+
+function jobpositions.height(id)
+ local jpi = collected[id]
+ return jpi and jpi.h
+end
+
+function jobpositions.depth(id)
+ local jpi = collected[id]
+ return jpi and jpi.d
+end
+
+function jobpositions.whd(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.h, jpi.h, jpi.d
+ end
+end
+
+function jobpositions.leftskip(id)
+ local jpi = collected[id]
+ return jpi and jpi.ls
+end
+
+function jobpositions.rightskip(id)
+ local jpi = collected[id]
+ return jpi and jpi.rs
+end
+
+function jobpositions.hsize(id)
+ local jpi = collected[id]
+ return jpi and jpi.hs
+end
+
+function jobpositions.parindent(id)
+ local jpi = collected[id]
+ return jpi and jpi.pi
+end
+
+function jobpositions.hangindent(id)
+ local jpi = collected[id]
+ return jpi and jpi.hi
+end
+
+function jobpositions.hangafter(id)
+ local jpi = collected[id]
+ return jpi and jpi.ha or 1
+end
+
+function jobpositions.xy(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.x, jpi.y
+ else
+ return 0, 0
+ end
+end
+
+function jobpositions.lowerleft(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.x, jpi.y - jpi.d
+ else
+ return 0, 0
+ end
+end
+
+function jobpositions.lowerright(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.x + jpi.w, jpi.y - jpi.d
+ else
+ return 0, 0
+ end
+end
+
+function jobpositions.upperright(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.x + jpi.w, jpi.y + jpi.h
+ else
+ return 0, 0
+ end
+end
+
+function jobpositions.upperleft(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.x, jpi.y + jpi.h
+ else
+ return 0, 0
+ end
+end
+
+function jobpositions.position(id)
+ local jpi = collected[id]
+ if jpi then
+ return jpi.p, jpi.x, jpi.y, jpi.w, jpi.h, jpi.d
+ else
+ return 0, 0, 0, 0, 0, 0
+ end
+end
+
+local splitter = lpeg.splitat(",")
+
+function jobpositions.extra(id,n,default) -- assume numbers
+ local jpi = collected[id]
+ if jpi then
+ local e = jpi.e
+ if e then
+ local split = jpi.split
+ if not split then
+ split = lpegmatch(splitter,jpi.e)
+ jpi.split = split
+ end
+ return texsp(split[n]) or default -- watch the texsp here
+ end
+ end
+ return default
+end
+
+local function overlapping(one,two,overlappingmargin) -- hm, strings so this is wrong .. texsp
+ one = collected[one]
+ two = collected[two]
+ if one and two and one.p == two.p then
+ if not overlappingmargin then
+ overlappingmargin = 2
+ end
+ local x_one = one.x
+ local x_two = two.x
+ local w_two = two.w
+ local llx_one = x_one - overlappingmargin
+ local urx_two = x_two + w_two + overlappingmargin
+ if llx_one > urx_two then
+ return false
+ end
+ local w_one = one.w
+ local urx_one = x_one + w_one + overlappingmargin
+ local llx_two = x_two - overlappingmargin
+ if urx_one < llx_two then
+ return false
+ end
+ local y_one = one.y
+ local y_two = two.y
+ local d_one = one.d
+ local h_two = two.h
+ local lly_one = y_one - d_one - overlappingmargin
+ local ury_two = y_two + h_two + overlappingmargin
+ if lly_one > ury_two then
+ return false
+ end
+ local h_one = one.h
+ local d_two = two.d
+ local ury_one = y_one + h_one + overlappingmargin
+ local lly_two = y_two - d_two - overlappingmargin
+ if ury_one < lly_two then
+ return false
+ end
+ return true
+ end
+end
+
+local function onsamepage(list,page)
+ for id in gmatch(list,"(, )") do
+ local jpi = collected[id]
+ if jpi then
+ local p = jpi.p
+ if not p then
+ return false
+ elseif not page then
+ page = p
+ elseif page ~= p then
+ return false
+ end
+ end
+ end
+ return page
+end
+
+local function columnofpos(realpage,xposition)
+ local p = columndata[realpage]
+ if p then
+ for i=1,#p do
+ local c = p[i]
+ local x = c.x or 0
+ local w = c.w or 0
+ if xposition >= x and xposition <= (x + w) then
+ return i
+ end
+ end
+ end
+ return 1
+end
+
+jobpositions.overlapping = overlapping
+jobpositions.onsamepage = onsamepage
+jobpositions.columnofpos = columnofpos
+
+-- interface
+
+implement {
+ name = "replacepospxywhd",
+ arguments = { "argument", "integerargument", "dimenargument", "dimenargument", "dimenargument", "dimenargument", "dimenargument" },
+ public = true,
+ protected = true,
+ actions = function(name,page,x,y,w,h,d)
+ collected[name] = {
+ p = page,
+ x = x,
+ y = y,
+ w = w,
+ h = h,
+ d = d,
+ }
+ end
+}
+
+implement {
+ name = "copyposition",
+ arguments = "2 arguments",
+ public = true,
+ protected = true,
+ actions = function(target,source)
+ collected[target] = collected[source]
+ end
+}
+
+implement {
+ name = "MPp",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local p = jpi.p
+ if p and p ~= true then
+ context(p)
+ return
+ end
+ end
+ context('0')
+ end
+}
+
+implement {
+ name = "MPx",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local x = jpi.x
+ if x and x ~= true and x ~= 0 then
+ context("%.5Fpt",x*pt)
+ return
+ end
+ end
+ context('0pt')
+ end
+}
+
+implement {
+ name = "MPy",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local y = jpi.y
+ if y and y ~= true and y ~= 0 then
+ context("%.5Fpt",y*pt)
+ return
+ end
+ end
+ context('0pt')
+ end
+}
+
+implement {
+ name = "MPw",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local w = jpi.w
+ if w and w ~= 0 then
+ context("%.5Fpt",w*pt)
+ return
+ end
+ end
+ context('0pt')
+ end
+}
+
+implement {
+ name = "MPh",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local h = jpi.h
+ if h and h ~= 0 then
+ context("%.5Fpt",h*pt)
+ return
+ end
+ end
+ context('0pt')
+ end
+}
+
+implement {
+ name = "MPd",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local d = jpi.d
+ if d and d ~= 0 then
+ context("%.5Fpt",d*pt)
+ return
+ end
+ end
+ context('0pt')
+ end
+}
+
+implement {
+ name = "MPxy",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context('(%.5Fpt,%.5Fpt)',
+ jpi.x*pt,
+ jpi.y*pt
+ )
+ else
+ context('(0,0)')
+ end
+ end
+}
+
+implement {
+ name = "MPwhd",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local w = jpi.w or 0
+ local h = jpi.h or 0
+ local d = jpi.d or 0
+ if w ~= 0 or h ~= 0 or d ~= 0 then
+ context("%.5Fpt,%.5Fpt,%.5Fpt",w*pt,h*pt,d*pt)
+ return
+ end
+ end
+ context('0pt,0pt,0pt')
+ end
+}
+
+implement {
+ name = "MPll",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context('(%.5Fpt,%.5Fpt)',
+ jpi.x *pt,
+ (jpi.y-jpi.d)*pt
+ )
+ else
+ context('(0,0)') -- for mp only
+ end
+ end
+}
+
+implement {
+ name = "MPlr",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context('(%.5Fpt,%.5Fpt)',
+ (jpi.x + jpi.w)*pt,
+ (jpi.y - jpi.d)*pt
+ )
+ else
+ context('(0,0)') -- for mp only
+ end
+ end
+}
+
+implement {
+ name = "MPur",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context('(%.5Fpt,%.5Fpt)',
+ (jpi.x + jpi.w)*pt,
+ (jpi.y + jpi.h)*pt
+ )
+ else
+ context('(0,0)') -- for mp only
+ end
+ end
+}
+
+implement {
+ name = "MPul",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context('(%.5Fpt,%.5Fpt)',
+ jpi.x *pt,
+ (jpi.y + jpi.h)*pt
+ )
+ else
+ context('(0,0)') -- for mp only
+ end
+ end
+}
+
+local function MPpos(id)
+ local jpi = collected[id]
+ if jpi then
+ local p = jpi.p
+ if p then
+ context("%s,%.5Fpt,%.5Fpt,%.5Fpt,%.5Fpt,%.5Fpt",
+ p,
+ jpi.x*pt,
+ jpi.y*pt,
+ jpi.w*pt,
+ jpi.h*pt,
+ jpi.d*pt
+ )
+ return
+ end
+ end
+ context('0,0,0,0,0,0') -- for mp only
+end
+
+implement {
+ name = "MPpos",
+ arguments = "argument",
+ public = true,
+ actions = MPpos
+}
+
+implement {
+ name = "MPn",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local n = jpi.n
+ if n then
+ context(n)
+ return
+ end
+ end
+ context(0)
+ end
+}
+
+implement {
+ name = "MPc",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local c = jpi.c
+ if c and c ~= true then
+ context(c)
+ return
+ end
+ end
+ context('0') -- okay ?
+ end
+}
+
+implement {
+ name = "MPr",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ local r = jpi.r
+ if r and r ~= true then
+ context(r)
+ return
+ end
+ local p = jpi.p
+ if p and p ~= true then
+ context("page:" .. p)
+ end
+ end
+ end
+}
+
+local function MPpardata(id)
+ local t = collected[id]
+ if not t then
+ local tag = f_p_tag(id)
+ t = collected[tag]
+ end
+ if t then
+ context("%.5Fpt,%.5Fpt,%.5Fpt,%.5Fpt,%s,%.5Fpt",
+ t.hs*pt,
+ t.ls*pt,
+ t.rs*pt,
+ t.hi*pt,
+ t.ha,
+ t.pi*pt
+ )
+ else
+ context("0,0,0,0,0,0") -- for mp only
+ end
+end
+
+implement {
+ name = "MPpardata",
+ arguments = "argument",
+ public = true,
+ actions = MPpardata
+}
+
+implement {
+ name = "MPposset",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local b = f_b_tag(name)
+ local e = f_e_tag(name)
+ local w = f_w_tag(name)
+ local p = f_p_tag(getparagraph(b))
+ MPpos(b) context(",") MPpos(e) context(",") MPpos(w) context(",") MPpos(p) context(",") MPpardata(p)
+ end
+}
+
+implement {
+ name = "MPls",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context("%.5Fpt",jpi.ls*pt)
+ else
+ context("0pt")
+ end
+ end
+}
+
+implement {
+ name = "MPrs",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context("%.5Fpt",jpi.rs*pt)
+ else
+ context("0pt")
+ end
+ end
+}
+
+local splitter = lpeg.tsplitat(",")
+
+implement {
+ name = "MPplus",
+ arguments = { "argument", "integerargument", "argument" },
+ public = true,
+ actions = function(name,n,default)
+ local jpi = collected[name]
+ if jpi then
+ local e = jpi.e
+ if e then
+ local split = jpi.split
+ if not split then
+ split = lpegmatch(splitter,jpi.e)
+ jpi.split = split
+ end
+ context(split[n] or default)
+ return
+ end
+ end
+ context(default)
+ end
+}
+
+implement {
+ name = "MPrest",
+ arguments = { "argument", "argument" },
+ public = true,
+ actions = function(name,default)
+ local jpi = collected[name]
+ context(jpi and jpi.e or default)
+ end
+}
+
+implement {
+ name = "MPxywhd",
+ arguments = "argument",
+ public = true,
+ actions = function(name)
+ local jpi = collected[name]
+ if jpi then
+ context("%.5Fpt,%.5Fpt,%.5Fpt,%.5Fpt,%.5Fpt",
+ jpi.x*pt,
+ jpi.y*pt,
+ jpi.w*pt,
+ jpi.h*pt,
+ jpi.d*pt
+ )
+ else
+ context("0,0,0,0,0") -- for mp only
+ end
+ end
+}
+
+local doif = commands.doif
+local doifelse = commands.doifelse
+
+implement {
+ name = "doifelseposition",
+ arguments = "argument",
+ public = true,
+ protected = true,
+ actions = function(name)
+ doifelse(collected[name])
+ end
+}
+
+implement {
+ name = "doifposition",
+ arguments = "argument",
+ public = true,
+ protected = true,
+ actions = function(name)
+ doif(collected[name])
+ end
+}
+
+implement {
+ name = "doifelsepositiononpage",
+ arguments = { "string", "integerargument" },
+ public = true,
+ protected = true,
+ actions = function(name,p)
+ local c = collected[name]
+ doifelse(c and c.p == p)
+ end
+}
+
+implement {
+ name = "doifelseoverlapping",
+ arguments = { "argument", "argument" },
+ public = true,
+ protected = true,
+ actions = function(one,two)
+ doifelse(overlapping(one,two))
+ end
+}
+
+implement {
+ name = "doifelsepositionsonsamepage",
+ arguments = "argument", -- string
+ public = true,
+ protected = true,
+ actions = function(list)
+ doifelse(onsamepage(list))
+ end
+}
+
+implement {
+ name = "doifelsepositionsonthispage",
+ arguments = "argument", -- string
+ public = true,
+ protected = true,
+ actions = function(list)
+ doifelse(onsamepage(list,tostring(texgetcount("realpageno"))))
+ end
+}
+
+implement {
+ name = "doifelsepositionsused",
+ public = true,
+ protected = true,
+ actions = function()
+ doifelse(next(collected))
+ end
+}
+
+implement {
+ name = "markregionbox",
+ arguments = "integer",
+ actions = markregionbox
+}
+
+implement {
+ name = "setregionbox",
+ arguments = "integer",
+ actions = setregionbox
+}
+
+implement {
+ name = "markregionboxtagged",
+ arguments = { "integer", "string" },
+ actions = markregionbox
+}
+
+implement {
+ name = "markregionboxtaggedn",
+ arguments = { "integer", "string", "integer" },
+ actions = function(box,tag,n)
+ markregionbox(box,tag,nil,nil,nil,nil,nil,nil,n)
+ end
+}
+
+implement {
+ name = "setregionboxtagged",
+ arguments = { "integer", "string" },
+ actions = setregionbox
+}
+
+implement {
+ name = "markregionboxcorrected",
+ arguments = { "integer", "string", true },
+ actions = markregionbox
+}
+
+implement {
+ name = "markregionboxtaggedkind",
+ arguments = { "integer", "string", "integer", "dimen", "dimen", "dimen", "dimen" },
+ actions = function(box,tag,n,d1,d2,d3,d4)
+ markregionbox(box,tag,nil,n,d1,d2,d3,d4)
+ end
+}
+
+implement {
+ name = "reservedautoregiontag",
+ public = true,
+ actions = function()
+ nofregions = nofregions + 1
+ context(f_region(nofregions))
+ end
+}
+
+-- statistics (at least for the moment, when testing)
+
+-- statistics.register("positions", function()
+-- local total = nofregular + nofusedregions + nofmissingregions
+-- if total > 0 then
+-- return format("%s collected, %s regulars, %s regions, %s unresolved regions",
+-- total, nofregular, nofusedregions, nofmissingregions)
+-- else
+-- return nil
+-- end
+-- end)
+
+statistics.register("positions", function()
+ local total = nofregular + nofspecial
+ if total > 0 then
+ return format("%s collected, %s regular, %s special",total,nofregular,nofspecial)
+ else
+ return nil
+ end
+end)
+
+-- We support the low level positional commands too:
+
+local newsavepos = nodes.pool.savepos
+
+jobpositions.lastx = 0
+jobpositions.lasty = 0
+
+implement { name = "savepos", actions = function() context(newsavepos()) end }
+implement { name = "lastxpos", actions = function() context(jobpositions.lastx) end }
+implement { name = "lastypos", actions = function() context(jobpositions.lasty) end }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-pos.mkxl b/Master/texmf-dist/tex/context/base/mkxl/anch-pos.mkxl
new file mode 100644
index 00000000000..d217f2cac3f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-pos.mkxl
@@ -0,0 +1,506 @@
+%D \module
+%D [ file=anch-pos, % was core-pos
+%D version=1999.08.01,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Positioning Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Positioning}
+
+%D In \MKIV\ there was already a different housekeeping model for positions quite
+%D early, but starting in 2012 more dramatic changes started to happen, especially
+%D in relation to background graphics. It will probably take some time to settle.
+
+\registerctxluafile{anch-pos}{autosuffix}
+
+\unprotect
+
+%D The first application of positional information was embedded graphics. Since we
+%D are interacting with text, it made sense to take the current line height and
+%D depth into account too. This is why we have position macros for simple positions
+%D and one boxes.
+%D
+%D \starttyping
+%D \dosetposition {identifier}
+%D \dosetpositionwhd {identifier} {width} {height} {depth}
+%D \dosetpositionplus {identifier} {width} {height} {depth} {list}
+%D \stoptyping
+
+% \dosaveposition #1#2#3#4 % defined at lua end
+% \dosavepositionwhd #1#2#3#4#5#6#7 % defined at lua end
+% \dosavepositionplus #1#2#3#4#5#6#7#8 % defined at lua end
+
+% \dosetposition #1 % defined at lua end
+% \dosetpositionwhd #1#2#3#4 % defined at lua end
+% \dosetpositionplus #1#2#3#4#5 % defined at lua end
+% \dosetpositionbox #1#2 % defined at lua end
+% \dosetpositionstrut #1 % defined at lua end
+% \dosetpositionstrutkind #1#2 % defined at lua end
+
+\newbox\b_anch_position
+\newif \ifpositioning % sort of public
+
+\mutable\let\currentposition \empty
+\mutable\let\currentpositionaction\empty
+\mutable\let\currentpositionanchor\empty
+\mutable\let\currentpositionregion\empty
+
+%D Sometimes we want to trick the position handler a bit:
+
+% \replacepospxywhd #1#2#3#4#5#6#7 % defined at lua end
+
+%D \macros
+%D {MPp, MPx, MPy, MPw, MPh, MPd, MPxy, MPll, MPlr, MPur, MPul, MPpos, MPanchor}
+%D
+%D Access to the positional information is provided by macros with short names
+%S that are clearly meant for \METAPOST\ but nowadays also used for other purposes.
+
+% \MPp : defined at lua end
+% \MPr : defined at lua end
+% \MPc : defined at lua end
+% \MPn : defined at lua end
+% \MPx : defined at lua end
+% \MPy : defined at lua end
+% \MPw : defined at lua end
+% \MPh : defined at lua end
+% \MPd : defined at lua end
+% \MPxy : defined at lua end
+% \MPwhd : defined at lua end
+% \MPll : defined at lua end
+% \MPlr : defined at lua end
+% \MPur : defined at lua end
+% \MPul : defined at lua end
+% \MPpos : defined at lua end
+% \MPls : defined at lua end
+% \MPrs : defined at lua end
+% \MPpardata : defined at lua end
+% \MPxywhd : defined at lua end
+% \MPposset : defined at lua end
+
+\aliased\let\MPpage \MPp
+\aliased\let\MPregion \MPr
+\aliased\let\MPcolumn \MPc
+\aliased\let\MPparagraph\MPn
+\aliased\let\MPanchor \MPpos % overloaded locally when needed (todo: LMTX)
+
+\aliased\let\MPleftskip \MPls % compatible feature
+\aliased\let\MPrightkip \MPrs % compatible feature
+
+%D \macros
+%D {MPplus, MPrest, MPv, MPvv}
+%D
+%D Since we will probably keep on extending, we provide a general extension
+%D macro. The plus alternative takes an extra argument, denoting what additional
+%D parameter to pick up. So, the third extra is fetched with,
+%D
+%D \starttyping
+%D \MPplus{identifier}{3}{default}
+%D \stoptyping
+%D
+%D All extras (comma separated) are fetched with:
+%D
+%D \starttyping
+%D \MPrest{identifier}
+%D \stoptyping
+%D
+%D The extra parameters are not treated.
+
+% \MPplus #1#2#3 % defined at lua end
+% \MPrest #1 % defined at lua end
+
+\aliased\let\MPv \MPplus
+\aliased\let\MPvv\MPrest
+
+%D There are two low level positioning macros. Both store the position as well
+%D as execute an action associated with that position.
+
+\let\dopositionaction\gobbleoneargument % implemented later
+
+\def\anch_positions_initialize
+ {\ifpositioning \else
+ \global\positioningtrue
+ \fi}
+
+\permanent\protected\def\setpositiononly
+ {\iftrialtypesetting
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\anch_positions_set_only_indeed
+ \fi}
+
+\def\anch_positions_set_only_indeed#1%
+ {\anch_positions_initialize
+ \edef\currentposition{#1}%
+ \dosetposition\currentposition}
+
+\permanent\protected\def\setposition
+ {\iftrialtypesetting
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\anch_positions_set_indeed
+ \fi}
+
+\def\anch_positions_set_indeed#1%
+ {\anch_positions_initialize
+ \edef\currentposition{#1}%
+ \dosetposition\currentposition
+ \anch_positions_trace_left
+ \dopositionaction\currentposition}
+
+\permanent\protected\def\setpositiondata
+ {\iftrialtypesetting
+ \expandafter\gobblefourarguments
+ \else
+ \expandafter\anch_positions_set_data_indeed
+ \fi}
+
+\def\anch_positions_set_data_indeed#1#2#3#4%
+ {\anch_positions_initialize
+ \hbox % \hpack
+ {\edef\currentposition{#1}%
+ \dosetpositionwhd\currentposition{#2}{#3}{#4}% already \the\dimexpr
+ \anch_positions_trace_left
+ \dopositionaction\currentposition
+ \hss}}
+
+\permanent\protected\def\setpositionbox
+ {\iftrialtypesetting
+ \expandafter\anch_positions_set_box_nop
+ \else
+ \expandafter\anch_positions_set_box_yes
+ \fi}
+
+\def\anch_positions_set_box_nop#1%
+ {\dowithnextboxcs\flushnextbox}
+
+\def\anch_positions_set_box_yes#1%
+ {\dowithnextbox{\anch_positions_set_box_finish{#1}}}
+
+\def\anch_positions_set_box_finish#1%
+ {\anch_positions_initialize
+ \hbox to \wd\nextbox % \hpack
+ {\edef\currentposition{#1}%
+ \dosetpositionbox\currentposition\nextbox
+ \anch_positions_trace_left
+ \setbox\b_anch_position\box\nextbox
+ \dopositionaction\currentposition
+ \box\b_anch_position
+ \hss}}
+
+\permanent\protected\def\setpositionstrut
+ {\iftrialtypesetting
+ \expandafter\anch_positions_set_strut_nop
+ \else
+ \expandafter\anch_positions_set_strut_yes
+ \fi}
+
+\def\anch_positions_set_strut_nop#1%
+ {\strut}
+
+\def\anch_positions_set_strut_yes#1%
+ {\anch_positions_initialize
+ \hbox to \zeropoint % \hpack
+ {\edef\currentposition{#1}%
+ \dosetpositionstrut\currentposition
+ \anch_positions_trace_left
+ \dopositionaction\currentposition
+ \strut
+ \hss}}
+
+\permanent\protected\def\setpositionstrutkind
+ {\iftrialtypesetting
+ \expandafter\anch_positions_set_strut_kind_nop
+ \else
+ \expandafter\anch_positions_set_strut_kind_yes
+ \fi}
+
+\def\anch_positions_set_strut_kind_yes#1#2%
+ {\anch_positions_initialize
+ \hbox to \zeropoint % \hpack
+ {\edef\currentposition{#1}%
+ \dosetpositionstrutkind\currentposition{#2}%
+ \anch_positions_trace_left
+ \dopositionaction\currentposition
+ \strut
+ \hss}}
+
+\def\anch_positions_set_strut_kind_nop#1#2%
+ {\strut}
+
+\permanent\protected\def\setpositiondataplus
+ {\iftrialtypesetting
+ \expandafter\gobblefivearguments
+ \else
+ \expandafter\anch_positions_set_plus_indeed
+ \fi}
+
+\def\anch_positions_set_plus_indeed#1#2#3#4#5%
+ {\anch_positions_initialize
+ \hbox % \hpack
+ {\edef\currentposition{#1}%
+ \dosetpositionplus\currentposition{#2}{#3}{#4}{#5}% already \the\dimexpr
+ \anch_positions_trace_right
+ \dopositionaction\currentposition
+ \hss}}
+
+\permanent\protected\def\setpositionplus
+ {\iftrialtypesetting
+ \expandafter\anch_positions_set_plus_nop
+ \else
+ \expandafter\anch_positions_set_plus_yes
+ \fi}
+
+\def\anch_positions_set_plus_nop#1#2%
+ {\dowithnextboxcs\flushnextbox}
+
+\def\anch_positions_set_plus_yes#1#2%
+ {\dowithnextbox{\anch_positions_set_plus_yes_finish{#1}{#2}}}
+
+\def\anch_positions_set_plus_yes_finish#1#2%
+ {\anch_positions_initialize
+ \hbox to \nextboxwd % \hpack
+ {\edef\currentposition{#1}%
+ \dosetpositionplus\currentposition{\wd\nextbox}{\ht\nextbox}{\dp\nextbox}{#2}%
+ \anch_positions_trace_right
+ \setbox\b_anch_position\flushnextbox
+ \dopositionaction\currentposition
+ \box\b_anch_position
+ \hss}}
+
+\let\currentposition\s!unknown
+
+%D A few special ones .. will be cleaned up
+
+\permanent\def\pageanchor {page:\the\realpageno} % for the moment only one pagesize
+\permanent\def\textanchor {text:\the\realpageno}
+\permanent\def\regionanchor{region:0}
+
+\newcount\c_anch_column % will be delegated to lua
+\newcount\c_anch_text % will be delegated to lua
+
+% beware we need to pass \somethingexpanded or { }
+
+\protected\def\anch_mark_column_box#1#2% box n
+ {\global\advance\c_anch_column\plusone
+ \clf_markregionboxtaggedn#1{columnarea:\the\c_anch_column}#2\relax} % extra height
+
+\protected\def\anch_mark_region_box
+ {\iftrialtypesetting
+ \expandafter\gobbleoneargument
+ \orelse\ifpositioning
+ \expandafter\anch_mark_region_box_indeed
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\protected\def\anch_mark_region_box_indeed#1%
+ {\clf_markregionbox#1\relax}
+
+\protected\def\anch_mark_flow_box#1% will be extended / renamed
+ {\hpack\bgroup
+ \global\advance\c_anch_text\plusone
+ \clf_markregionboxtagged#1{textarea:\the\c_anch_text}%
+ \box#1%
+ \egroup}
+
+\protected\def\anch_mark_tagged_box#1#2%
+ {\clf_markregionboxtagged#1{#2}}
+
+\protected\def\anch_mark_flow_only#1% will be extended / renamed
+ {\global\advance\c_anch_text\plusone
+ \clf_markregionboxcorrected#1{textarea:\the\c_anch_text}}
+
+\protected\def\anch_make_page_box#1% maybe like text
+ {\clf_setregionboxtagged#1{page:\the\realpageno}}
+
+\protected\def\anch_mark_text_box#1%
+ {\clf_markregionboxtagged#1{text:\the\realpageno}} % needs an hbox
+
+\newcount\c_anch_free
+
+\protected\def\anch_mark_tagged_box_free#1#2#3#4#5#6% only needed when positions
+ {\ifpositioning
+ \global\advance\c_anch_free\plusone % could be done at the lua end
+ \clf_markregionboxtaggedkind
+ #1%
+ {free:\number\c_anch_free}%
+ #2\space % kind
+ #3\space % leftoffset
+ #4\space % rightoffset
+ #5\space % topoffset
+ #6\relax % bottomoffset
+ \fi}
+
+% \reservedautoregiontag % define at lua end
+
+%D We can copy a position with:
+%D
+%D \starttyping
+%D \copyposition {to} {from}
+%D \stoptyping
+%D
+%D Again, this is a global operation.
+
+% \copyposition #1#2 % defined at lua end
+
+%D The fact that handling positions is a two pass operation, is one of the
+%D reasons why we need to be able to test for existence, using:
+%D
+%D \starttyping
+%D \doifpositionelse {identifier} {found action} {not found action}
+%D \stoptyping
+
+% \doifposition #1 % defined at lua end
+% \doifelseposition #1#2 % defined at lua end
+% \doifelsepositiononpage #1#2 % defined at lua end
+
+\aliased\let\doifpositionelse \doifelseposition
+\aliased\let\doifpositiononpageelse\doifelsepositiononpage
+
+%D \macros
+%D {xypos}
+%D
+%D We have several macros available to save positions. Later we will see
+%D applications.
+%D
+%D \starttabulate[|l|l||]
+%D \NC \type {\xypos} \NC \NC simple position with no dimensions \NC \NR
+%D \NC \type {\hpos} \NC \NC position and characteristics of a \type {\hbox} \NC \NR
+%D \NC \type {\vpos} \NC \NC position and characteristics of a \type {\vbox} \NC \NR
+%D \NC \type {\bpos} \NC b: \NC begin point in a line \NC \NR
+%D \NC \type {\epos} \NC e: \NC end point in a line \NC \NR
+%D \stoptabulate
+%D
+%D Each macro takes an identifier as argument, and the \type {\hpos} and
+%D \type {\vpos} also expect box content.
+
+\aliased\let\xypos\setpositiononly
+
+\permanent\protected\def\hpos #1{\dontleavehmode\setpositionbox{#1}\hbox}
+\permanent\protected\def\vpos #1{\setpositionbox{#1}\vbox}
+\permanent\protected\def\bpos #1{\dontleavehmode\setpositionstrut{b:#1}\ignorespaces}
+\permanent\protected\def\epos #1{\removeunwantedspaces\setpositionstrut{e:#1}}
+\permanent\protected\def\bposkind#1#2{\dontleavehmode\setpositionstrutkind{b:#1}{#2}\ignorespaces} % not public, used in backgrounds
+\permanent\protected\def\eposkind#1#2{\removeunwantedspaces\setpositionstrutkind{e:#1}{#2}} % not public, used in backgrounds
+
+%D When we want to calculate more complex backgrounds, we need to know what the
+%D current indentation scheme is. At the cost of many positions and memory, we
+%D can keep track of them. This mechanism is activated automatically based on
+%D information collected in the previous pass.
+
+\newtoks \t_anch_positions_tracers
+\newcount\c_anch_positions_paragraph
+
+\permanent\protected\def\tracepositions
+ {\the\t_anch_positions_tracers}
+
+\permanent\protected\def\enableparpositions % global
+ {\enforced\aliased\glet\registerparoptions\doregisterparoptions
+ \global\positioningtrue}
+
+\permanent\let\disableparpositions\relax
+
+\aliased\let\registerparoptions\relax
+
+\permanent\protected\def\doregisterparoptions
+ {\iftrialtypesetting \orelse\ifinpagebody \orelse\ifmmode \orelse\ifinformula \else
+ \anch_positions_register_par_options
+ \fi}
+
+\def\anch_positions_register_par_options_normal
+ {\dontleavehmode\clf_parpos}
+
+\def\anch_positions_register_par_options_traced
+ {\anch_positions_register_par_options_normal
+ \smashedhbox to \zeropoint
+ {\hss
+ \startcolor[blue]%
+ \llap{\infofont\number\c_anch_positions_paragraph}%
+ \vrule
+ \s!width 4\onepoint
+ \s!height2\onepoint
+ \s!depth 2\onepoint
+ \stopcolor
+ \hss}}
+
+\let\anch_positions_register_par_options\anch_positions_register_par_options_normal
+
+\appendtoks
+ \let\anch_positions_register_par_options\anch_positions_register_par_options_traced
+\to \t_anch_positions_tracers
+
+\protected\def\anch_positions_trace#1#2#3%
+ {\smashedhbox
+ {#1{\infofont#2#3}%
+ \kern-\onepoint
+ \vrule\s!width2\onepoint\s!height\halfapoint\s!depth\halfapoint}}
+
+\protected\def\anch_positions_trace_left_indeed
+ {\anch_positions_trace\llap\darkmagenta{\currentposition>}}
+
+\protected\def\anch_positions_trace_right_indeed
+ {\anch_positions_trace\rlap\darkcyan{<\currentposition}}
+
+\let\anch_positions_trace_left \relax
+\let\anch_positions_trace_right\relax
+
+\appendtoks
+ \let\anch_positions_trace_left \anch_positions_trace_left_indeed
+ \let\anch_positions_trace_right \anch_positions_trace_right_indeed
+\to \t_anch_positions_tracers
+
+% \appendtoks \registerparoptions \to \everypar
+
+%D \macros
+%D {doifoverlappingelse}
+%D
+%D A first application of positional information, is to determine if two boxes do
+%D overlap:
+%D
+%D \starttyping
+%D \doifoverlappingelse{point a}{point b}
+%D {action when overlapping}
+%D {action when not overlapping}
+%D \stoptyping
+
+% \doifelseoverlapping #1#2#3#4 % defined at lua end
+
+\aliased\let\doifoverlappingelse\doifelseoverlapping
+
+%D \macros
+%D {doifpositionsonsamepageelse,
+%D doifpositionsonthispageelse}
+%D
+%D Instead of letting the user handle fuzzy expansion, we provide a simple test on
+%D positions being on the same page.
+%D
+%D \starttyping
+%D \doifpositionsonsamepageelse{point a}{point b}
+%D {action when on same page}
+%D {action when not on same page}
+%D \doifpositionsonthispageelse{point a}{point b}
+%D {action when on this page}
+%D {action when not on this page}
+%D \stoptyping
+
+% \doifelsepositionsonsamepage #1 % defined at lua end
+% \doifelsepositionsonthispage #1 % defined at lua end
+% \doifelsepositionsused % defined at lua end
+
+\aliased\let\doifpositionsonsamepageelse\doifelsepositionsonsamepage
+\aliased\let\doifpositionsonthispageelse\doifelsepositionsonthispage
+\aliased\let\doifpositionsusedelse \doifelsepositionsused
+
+%D Moved here:
+
+\permanent\protected\def\savepos {\clf_savepos}
+\permanent\protected\def\lastxpos{\numexpr\clf_lastxpos\relax}
+\permanent\protected\def\lastypos{\numexpr\clf_lastypos\relax}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-snc.mkxl b/Master/texmf-dist/tex/context/base/mkxl/anch-snc.mkxl
new file mode 100644
index 00000000000..e186e024f96
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-snc.mkxl
@@ -0,0 +1,157 @@
+%D \module
+%D [ file=anch-snc,
+%D version=2003.12.01, % actually 1999 so real old
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Synchronization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The original is in the mkii file. It does more at the \TEX\ end and
+%D has some more magic. If we really need that I'll add it. After all,
+%D in mkiv we can do things different.
+
+%D TODO: bleed : + left , minus right oro check if it touches page ... autobleed
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Synchronization}
+
+\registerctxluafile{anch-snc}{}
+
+\unprotect
+
+\ifdefined\??syncposcounter \else \installcorenamespace{syncposcounter} \fi
+\ifdefined\s!syncpos \else \def\s!syncpos {syncpos} \fi
+
+\let\c_sync_n\relax
+
+\permanent\protected\def\definesyncpositions[#1]%
+ {\ifcsname\??syncposcounter:#1\endcsname \else
+ \expandafter\newcount\csname\??syncposcounter:#1\endcsname
+ \fi}
+
+\permanent\tolerant\protected\def\syncposition[#1]#*[#2]% we could actually use par positions
+ {\dontleavehmode
+ \ifcsname\??syncposcounter:#1\endcsname
+ \let\c_sync_n\lastnamedcs
+ \global\advance\c_sync_n\plusone
+ \enabletextarearegistration
+ \setpositionplus{\s!syncpos:#1:\the\c_sync_n}{#2}\hpack{\strut}%
+ \else
+ \strut
+ \fi
+ \ignorespaces}
+
+\protect
+
+\continueifinputfile{anch-snc.mkiv}
+
+\starttext
+
+% \setuppapersize[A4][A3]
+
+\setuplayout[location=middle]
+
+\setupbodyfont[dejavu]
+
+\definesyncpositions[1]
+\definesyncpositions[2]
+
+% \enabletrackers[metapost.lua]
+
+\startMPdefinitions
+ input "mp-asnc.mpiv" ;
+
+ SetSyncColor(1,0,"magenta") ;
+ SetSyncColor(1,1,"red") ;
+ SetSyncColor(1,2,"green") ;
+ SetSyncColor(1,3,"blue") ;
+ SetSyncColor(1,4,"yellow") ;
+
+ SetSyncColor(2,0,"magenta") ;
+ SetSyncColor(2,1,"red") ;
+ SetSyncColor(2,2,"green") ;
+ SetSyncColor(2,3,"blue") ;
+ SetSyncColor(2,4,"yellow") ;
+\stopMPdefinitions
+
+\startuseMPgraphic{sync1}
+ StartPage ;
+ StartSync(1) ;
+ SyncHOffset := 0 ;
+ SyncWidth := BackSpace - LeftMarginDistance;
+ CollectSyncDataPage ;
+ % ExtendSyncPaths ; % to top of text area
+ PruneSyncPaths ; % clip top / bottom
+ CollapseSyncPaths ;
+ MakeSyncPaths ;
+ % DrawSyncPaths ;
+ FillSyncPaths ;
+ StopSync ;
+ clip currentpicture to Page ;
+ setbounds currentpicture to Page ;
+ StopPage ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{sync2}
+ StartSync(2) ;
+ SyncHOffset := -1cm ;
+ SyncWidth := 1cm ;
+ CollectSyncDataRegion(OverlayRegion) ;
+ ExtendSyncPaths ; % to top of text area
+ MakeSyncPaths ;
+ FillSyncPaths ;
+ StopSync ;
+ clip currentpicture to OverlayBox leftenlarged 1cm;
+ setbounds currentpicture to OverlayBox ;
+\stopuseMPgraphic
+
+\defineoverlay[tempoverlay1][\useMPgraphic{sync1}]
+\defineoverlay[tempoverlay2][\useMPgraphic{sync2}]
+
+\setupbackgrounds[page][background=tempoverlay1]
+
+\framed[region=yes,background=tempoverlay2,width=14cm,align=normal]{
+ \syncposition[2][1]\samplefile{ward}\endgraf
+ \syncposition[2][2]\samplefile{ward}\endgraf
+ \syncposition[2][3]\samplefile{ward}\endgraf
+}
+
+
+\vskip1cm \hskip1cm \framed[region=yes,background=tempoverlay2,width=16cm,align=normal]{
+ \syncposition[2][1]\samplefile{ward}\endgraf
+ \syncposition[2][2]\samplefile{ward}\endgraf
+ \syncposition[2][3]\samplefile{ward}\endgraf
+}
+
+\vskip1cm \hskip1cm \framed[region=yes,background=tempoverlay2,width=10cm,align=normal]{
+ \syncposition[2][1]\samplefile{ward}\endgraf
+ \syncposition[2][2]\samplefile{ward}\endgraf
+ \syncposition[2][3]\samplefile{ward}\endgraf
+}
+
+
+\dorecurse {100} {
+% \dorecurse {1} {
+ \startchapter[title={Test #1}]
+ \syncposition[1][1,reset]\dorecurse{20}{\samplefile{ward}\endgraf}
+ \syncposition[1][2]\dorecurse {4}{\samplefile{ward}\endgraf}
+ \syncposition[1][3]\dorecurse {7}{\samplefile{ward}\endgraf}
+ \syncposition[1][4]\dorecurse {3}{\samplefile{ward}\endgraf}
+ \stopchapter
+}
+
+\dorecurse {100} {
+% \dorecurse {1} {
+ \startchapter[title={Test #1}]
+ \syncposition[1][1]\dorecurse{1}{\samplefile{ward}\endgraf}
+ \syncposition[1][2]\dorecurse{1}{\samplefile{ward}\endgraf}
+ \syncposition[1][3]\dorecurse{1}{\samplefile{ward}\endgraf}
+ \syncposition[1][4]\dorecurse{1}{\samplefile{ward}\endgraf}
+ \stopchapter
+}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/anch-tab.mkxl b/Master/texmf-dist/tex/context/base/mkxl/anch-tab.mkxl
new file mode 100644
index 00000000000..11e9598d9c2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/anch-tab.mkxl
@@ -0,0 +1,387 @@
+%D \module
+%D [ file=anch-pgr, % moved from anch-pgr (1999.08.01)
+%D version=2011.12.19, % 1999.08.01,
+%D title=\CONTEXT\ Anchoring Macros,
+%D subtitle=Table Extensions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Anchoring Macros / Table Extensions}
+
+%D This is just a playground and functionality might change or even dissappear in
+%D favour of better solutions. Anyway, it now has been aroudn too long to bother.
+
+\unprotect
+
+\newcount\c_anch_tabs
+
+\protected\def\tabl_tabulate_hook_b
+ {\iftrialtypesetting\else
+ \ifpositioning
+ \ifconditional\tablehaspositions
+ \ifcase\c_tabl_tabulate_noflines % \ifnum\c_tabl_tabulate_noflines=\c_tabl_tabulate_totalnoflines
+ \tabl_tabulate_hook_b_first
+ \else
+ \tabl_tabulate_hook_b_next
+ \fi
+ \fi
+ \fi
+ \fi}
+
+\protected\def\tabl_tabulate_hook_e
+ {\iftrialtypesetting\else
+ \ifpositioning
+ \ifconditional\tablehaspositions
+ \ifcase\c_tabl_tabulate_noflines % \ifnum\c_tabl_tabulate_noflines=\c_tabl_tabulate_totalnoflines
+ \tabl_tabulate_hook_e_first
+ \else
+ \tabl_tabulate_hook_e_next
+ \fi
+ \fi
+ \fi
+ \fi}
+
+\protected\def\tabl_tabulate_hook_b_first{\clf_bposcolumnregistered{tabulate:\the\c_anch_tabs:\the\c_tabl_tabulate_column}}
+\protected\def\tabl_tabulate_hook_b_next {\clf_bposcolumn{tabulate:\the\c_anch_tabs:\the\c_tabl_tabulate_column}}
+\protected\def\tabl_tabulate_hook_e_first{\clf_eposcolumnregistered}
+\protected\def\tabl_tabulate_hook_e_next {\clf_eposcolumn}
+
+% \appendtoks \registerparoptions \to \everypar
+
+\appendtoks
+ \global\advance\c_anch_tabs\plusone
+\to \everytabulate
+
+% for text backgrounds
+
+\appendtoks
+ \settrue\c_anch_backgrounds_pos_no_shape
+\to \everytabulate
+
+%D Beware, the following code is somewhat weird and experimental and might be
+%D dropped or become a loadable module.
+
+%D \macros
+%D {GFC, GTC, GSC}
+%D
+%D The next macros extend tables and tabulation with backgrounds and position
+%D related features. Areas are specified with symbolic names, and symbolic
+%D references to the graphics involved. Each table has its own namespace.
+
+\newconditional\tablehaspositions
+\newcount \noftabpositions
+\newtoks \posXCtoks
+
+\protected\def\anch_tabulate_bpos{\bpos}
+\protected\def\anch_tabulate_epos{\epos}
+
+\installcorenamespace{positiontables}
+
+\permanent\def\tbPOSprefix{\??positiontables\number\noftabpositions:}
+
+\permanent\protected\def\tablepos
+ {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}}
+
+\permanent\protected\def\tbXC {\anch_table_checked\anch_tables_indeed_XC }
+\permanent\protected\def\tbGSC{\anch_table_checked\anch_tables_indeed_GSC}
+\permanent\protected\def\tbGFC{\anch_table_checked\anch_tables_indeed_GFC}
+\permanent\protected\def\tbGTC{\anch_table_checked\anch_tables_indeed_GTC}
+
+\tolerant\def\anch_table_checked#1[#2]%
+ {\iftrialtypesetting
+ \global\settrue\tablehaspositions
+ \expandafter\anch_tables_indeed_NC
+ \orelse\ifparameter#2\or
+ \expandafter#1%
+ \else
+ \expandafter\anch_tables_indeed_NC
+ \fi[#2]}
+
+\def\anch_tables_indeed_NC[#1]%
+ {\NC}
+
+\def\anch_tables_indeed_XC[#1]%
+ {{\enforced\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}}
+
+\def\anch_tables_step_XC#1%
+ {\anch_tables_step_indeed_XC[#1]}
+
+\def\anch_tables_step_indeed_XC[#1#2]%
+ {\if#1>\anch_tables_indeed_GFC[#2:#2]\orelse
+ \if#1+\anch_tables_indeed_GFC[#2:#2]\orelse
+ \if#1<\anch_tables_indeed_GTC[#2:#2]\orelse
+ \if#1-\anch_tables_indeed_GTC[#2:#2]\orelse
+ \if#1=\anch_tables_indeed_GSC[#2:#2]\orelse
+ \anch_tables_indeed_GSC[#1#2:#1#2]\fi}
+
+\def\anch_tables_indeed_GSC[#1]%
+ {\processcommalist[#1]\anch_tables_step_GSC}
+
+\def\anch_tables_step_GSC#1%
+ {\anch_tables_append_GSC[#1:#1]}
+
+\def\anch_tables_append_GSC[#1:#2:#3]%
+% {\doglobal\appendtoks\anch_tables_process_GSC[#1:#2]\to\posXCtoks\NC}
+ {\gtoksapp\posXCtoks{\anch_tables_process_GSC[#1:#2]}\NC}
+
+\def\anch_tables_process_GSC[#1:#2]%
+ {\remappositionframed{#2}{\tbPOSprefix#1}%
+ \anch_tabulate_bpos{\tbPOSprefix#1}%
+ \doglobal\appendtoks\expandafter\anch_tabulate_epos\expandafter{\tbPOSprefix#1}\to\posXCtoks}
+% \xtoksapp\posXCtoks{\anch_tabulate_epos{\tbPOSprefix#1}}}
+
+\def\anch_tables_indeed_GFC[#1]%
+ {\doglobal\appendtoks\anch_tables_delayed_GFC[#1]\to\posXCtoks\NC}
+% {\gtoksapp\posXCtoks{\anch_tables_delayed_GFC[#1]}\NC}
+
+\def\anch_tables_delayed_GFC[#1]%
+ {\processcommalist[#1]\anch_tables_step_GFC}
+
+\def\anch_tables_step_GFC#1%
+ {\anch_tables_process_GFC[#1:#1]}
+
+\def\anch_tables_process_GFC[#1:#2:#3]%
+ {\remappositionframed{#2}{\tbPOSprefix#1}%
+ \anch_tabulate_bpos{\tbPOSprefix#1}}
+
+\def\anch_tables_indeed_GTC[#1]%
+ {\doglobal\appendtoks\anch_tables_delayed_GTC[#1]\to\posXCtoks\NC}
+% {\gtoksapp\posXCtoks{\anch_tables_delayed_GTC[#1]}\NC}
+
+\def\anch_tables_delayed_GTC[#1]%
+ {\doglobal\appendtoks\anch_tables_process_GTC[#1]\to\posXCtoks}
+% {\gtoksapp\posXCtoks{\anch_tables_process_GTC[#1]}\NC}
+
+\def\anch_tables_process_GTC[#1]%
+ {\processcommalist[#1]\anch_tables_step_GTC}
+
+\def\anch_tables_step_GTC#1%
+ {\anch_tables_step_indeed_GTC[#1:#1]}
+
+\def\anch_tables_step_indeed_GTC[#1:#2]%
+ {\anch_tabulate_epos{\tbPOSprefix#1}}
+
+%D The amount of code to support tables and tabulation is rather minimalistic.
+
+\aliased\let\tabulatepos\tablepos
+
+\permanent\protected\def\tabulatenormalpos
+ {\iftrialtypesetting
+ % nothing
+ \orelse\ifconditional\tablehaspositions
+ \hss\tabulatepos\hss
+ \else
+ % nothing
+ \fi}
+
+\permanent\protected\def\tabulateequalpos
+ {\iftrialtypesetting
+ \tabulateEQ
+ \orelse\ifconditional\tablehaspositions
+ \tabulateEQpos
+ \else
+ \tabulateEQ
+ \fi}
+
+\permanent\protected\def\tabulateEQpos
+ {\setbox\scratchbox\hbox{\tabulateEQ}%
+ \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}% hpack
+ \kern-\wd\scratchbox
+ \box\scratchbox}
+
+\appendtoks
+ \global\advance\noftabpositions\plusone
+ \global\setfalse\tablehaspositions
+\to \everytabulate
+
+% We need to handle paragraphs as well.
+
+\let\anch_tabulate_flush_epos\relax
+
+\protected\def\anch_tabulate_bpos_indeed
+ {\bpos}
+
+\protected\def\anch_tabulate_epos_indeed#1%
+ {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
+ \epos{#1}%
+ \glet\anch_tabulate_flush_epos\relax
+ \else
+ \gdef\anch_tabulate_flush_epos{\epos{#1}}%
+ \fi}
+
+\permanent\def\flushtabulatesplitbox
+ {\box\b_tabl_tabulate
+ \iftrialtypesetting\orelse\ifconditional\tablehaspositions\anch_tabulate_flush_epos\fi}
+
+\appendtoks
+ \let\anch_tabulate_bpos\anch_tabulate_bpos_indeed % ?
+ \let\anch_tabulate_epos\anch_tabulate_epos_indeed % ?
+ \glet\anch_tabulate_flush_epos\relax
+\to \everytabulate
+
+%D In order to prevent potential clashes with abbreviations, postpone the mapping and
+%D make them mutable.
+
+\mutable\let\GSC\empty
+\mutable\let\GFC\empty
+\mutable\let\GTC\empty
+
+\appendtoks
+ \enforced\let\GSC\tbGSC
+ \enforced\let\GFC\tbGFC
+ \enforced\let\GTC\tbGTC
+ \enforced\let\XC \tbXC
+\to \everytabulate
+
+%D \macros
+%D {definepositionframed}
+%D
+%D The next example show how to provide backgrounds to table cells. First we define
+%D some framed backgrounds.
+%D
+%D \startbuffer
+%D \definepositionframed[x][background=color,backgroundcolor=red]
+%D \definepositionframed[y][background=color,backgroundcolor=green]
+%D \definepositionframed[z][background=color,backgroundcolor=blue]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D % \getbuffer
+%D
+%D \startbuffer
+%D \starttabulate[|c|c|c|]
+%D \GFC[f:x] this is a small \NC table \NC in which we \NC \FR
+%D \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
+%D \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D The table itself defines three areas (a, b and~c) using these frames.
+%D
+%D \typebuffer
+%D % \getbuffer
+%D
+%D Tables (based on \TABLE) are supported by:
+
+\permanent\def\normalTABLEsimplebar {\unskip\!ttRightGlue&\tablepos&} % |
+\permanent\def\normalTABLEcomplexbar{\unskip\!ttRightGlue&\omit\tablepos\!ttAlternateVrule} % \|
+\permanent\def\normalTABLEquote {\unskip\!ttRightGlue&\omit\tablepos&} % "
+
+\appendtoks
+ \global\advance\noftabpositions\plusone
+ \global\setfalse\tablehaspositions
+\to \everytable
+
+%D Since we don't want nameclashes:
+
+\appendtoks
+ \enforced\let\GSC\tbGSC
+ \enforced\let\GFC\tbGFC
+ \enforced\let\GTC\tbGTC
+ \enforced\let\XC \tbXC
+\to \everytable
+
+%D In the previous example, we could have provided an overlay to the framed definition.
+%D A more direct approach is demonstrated below:
+%D
+%D \startbuffer
+%D \def\cw#1{\color[white]{#1}}
+%D
+%D \startMPpositiongraphic{tableshade}
+%D initialize_area(\MPpos{\MPvar{from}},\MPpos{\MPvar{to}}) ;
+%D color c ; c := \MPvar{color} ;
+%D linear_shade(pxy,0,.4c,.9c) ;
+%D anchor_area(\MPanchor{\MPvar{from}}) ;
+%D \stopMPpositiongraphic
+%D
+%D \setMPpositiongraphic{b:x}{tableshade}{from=b:x,to=e:x,color=red}
+%D \setMPpositiongraphic{b:y}{tableshade}{from=b:y,to=e:y,color=green}
+%D \setMPpositiongraphic{b:z}{tableshade}{from=b:z,to=e:z,color=blue}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D The definition of the table looks about the same as the previous one:
+%D
+%D \startbuffer
+%D \starttable[|c|c|c|]
+%D \GFC[b:z] \cw{this is a small} \NC \cw{table} \NC in which we \NC \FR
+%D \NC \cw{will demonstrate} \GFC[c:y] \cw{that this} \GTC[c] \cw{positioning} \NC \MR
+%D \GSC[a:x] \cw{mechanism also} \GTC[b] \cw{works quite well} \NC in tables \NC \LR
+%D \stoptable
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer
+
+% \definepositionframed[w][background=color,backgroundcolor=yellow]
+% \definepositionframed[x][background=color,backgroundcolor=red]
+% \definepositionframed[y][background=color,backgroundcolor=green]
+% \definepositionframed[z][background=color,backgroundcolor=blue]
+%
+% \starttabulate[|c|c|c|]
+% \NC this is a small \NC table \NC in which we \NC \FR
+% \NC will demonstrate \NC that this \NC positioning \NC \MR
+% \NC mechanism also \NC works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \GFC[f:x] this is a small \GTC table \NC in which we \NC \FR
+% \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
+% \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \GFC[f:x,d:w] this is a small \GTC[d] table \NC in which we \NC \FR
+% \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
+% \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \XC[+f:x] this is a small \XC table \NC in which we \NC \FR
+% \NC will demonstrate \XC[+g:z] that this \XC[-g] positioning \NC \MR
+% \XC[=e:y] mechanism also \XC[-f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \XC[+f:x,+d:w] this is a small \XC[-d] table \NC in which we \NC \FR
+% \NC will demonstrate \XC[+g:z] that this \XC[-g] positioning \NC \MR
+% \XC[=e:y] mechanism also \XC[-f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+
+% evt [b:x]
+%
+% \definepositionframed[x][background=color,fillcolor=red]
+% \definepositionframed[y][background=color,fillcolor=green]
+% \definepositionframed[z][background=color,fillcolor=blue]
+
+\permanent\protected\def\remappositionframed#1#2% from to
+ {\copyposition{b:#1}{b:#2}%
+ \copyposition{e:#1}{e:#2}%
+ \anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}}
+
+\permanent\tolerant\protected\def\definepositionframed[#1]#*[#2]%
+ {\anch_positions_set_action{b:#1}{\anch_framed_handle[#1][#2]}}
+
+\protected\def\anch_framed_handle
+ {\bgroup
+ \positionframed}
+
+\permanent\tolerant\protected\def\positionframed[#1]#*[#2]%
+ {\setbox\scratchbox\hpack
+ {\scratchwidth \dimexpr\MPx{e:#1}-\MPx{b:#1}\relax
+ \scratchdepth \dimexpr\MPy{b:#1}-\MPy{e:#1}+\MPd{e:#1}\relax
+ \scratchheight\dimexpr\scratchdepth+\MPh{b:#1}\relax
+ \lower\scratchdepth\hpack
+ {\framed[\c!width=\scratchwidth,\c!height=\scratchheight,\c!offset=\v!overlay,#2]{}}}%
+ \smashedbox\scratchbox
+ \egroup}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-alt.lmt b/Master/texmf-dist/tex/context/base/mkxl/attr-alt.lmt
new file mode 100644
index 00000000000..9d85920741d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-alt.lmt
@@ -0,0 +1,111 @@
+if not modules then modules = { } end modules ['attr-eff'] = {
+ version = 1.001,
+ comment = "companion to attr-eff.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local attributes, nodes, backends, utilities = attributes, nodes, backends, utilities
+local tex = tex
+
+local states = attributes.states
+local enableaction = nodes.tasks.enableaction
+local nodeinjections = backends.nodeinjections
+local texsetattribute = tex.setattribute
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+
+local interfaces = interfaces
+local implement = interfaces.implement
+
+attributes.alternates = attributes.alternates or { }
+local alternates = attributes.alternates
+
+local a_alternate = attributes.private('alternate')
+
+alternates.data = allocate()
+alternates.values = alternates.values or { }
+alternates.registered = alternates.registered or { }
+alternates.attribute = a_alternate
+
+local data = alternates.data
+local registered = alternates.registered
+local values = alternates.values
+
+storage.register("attributes/alternates/registered", registered, "attributes.alternates.registered")
+storage.register("attributes/alternates/values", values, "attributes.alternates.values")
+
+local function extender(alternates,key)
+ if key == "none" then
+ local d = nodeinjections.stopalternate()
+ alternates.none = d
+ return d
+ end
+end
+
+local function reviver(data,n)
+ local d = values[n] and nodeinjections.startalternate(values[n]) or nodeinjections.stopalternate()
+ data[n] = d
+ return d
+end
+
+setmetatableindex(alternates, extender)
+setmetatableindex(alternates.data, reviver)
+
+alternates.handler = nodes.installattributehandler {
+ name = "alternate",
+ namespace = alternates,
+ initializer = states.initialize,
+ finalizer = states.finalize,
+ processor = states.simple,
+}
+
+local function register(specification)
+ local text = specification.text or "unknown"
+ local n = registered[text]
+ if not n then
+ n = #values + 1
+ values[n] = text
+ registered[text] = n
+ end
+ return n
+end
+
+local enabled = false
+
+local function enable()
+ if not enabled then
+ enableaction("shipouts","attributes.alternates.handler")
+ enabled = true
+ end
+end
+
+alternates.register = register
+alternates.enable = enable
+
+-- interface
+
+implement {
+ name = "setalternate",
+ actions = function(specification)
+ if not enabled then
+ enable()
+ end
+ texsetattribute(a_alternate,register(specification))
+ end,
+ arguments = {
+ {
+ { "text", "string" },
+ }
+ }
+}
+
+implement {
+ name = "resetalternate",
+ actions = function()
+ if enabled then
+ texsetattribute(a_alternate)
+ end
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-alt.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-alt.mkxl
new file mode 100644
index 00000000000..3881d929e1c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-alt.mkxl
@@ -0,0 +1,55 @@
+%D \module
+%D [ file=attr-alt,
+%D version=2007.06.06,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Alternates,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Alternates}
+
+\registerctxluafile{attr-alt}{autosuffix}
+
+%D The main reason for providing this is that we need to make sure we have no
+%D dangling end markers when we cross a page. Public viewers don't seem to support
+%D actual text at all and acrobat has some funny selection issues.
+%D
+%D \starttyping
+%D test
+%D \startalternate[text={A}]
+%D \dorecurse{10}{A }
+%D \startalternate[text={B}]
+%D \dorecurse{10}{B }
+%D \stopalternate
+%D \dorecurse{10}{A }
+%D \stopalternate
+%D test \par
+%D \stoptyping
+%D
+%D \starttyping
+%D test \startalternate[text={e=mc^2}]!$e=mc^2$\stopalternate\par
+%D test \alternate{e=mc^2}{copy:}\nbsp$e=mc^2$\par
+%D \stoptyping
+
+\unprotect
+
+\permanent\protected\def\startalternate[#1]% maybe better/also: [text={...}]
+ {\begingroup
+ \getdummyparameters[\c!text=,#1]%
+ \clf_setalternate text {\dummyparameter\c!text}\relax}
+
+\permanent\protected\def\stopalternate
+ {\endgroup}
+
+\permanent\protected\def\alternate#1%
+ {\groupedcommand{\clf_setalternate text {#1}\relax}{}}
+
+\permanent\protected\def\setalternate #1{\clf_setalternate text {#1}\relax}
+\permanent\protected\def\resetalternate {\clf_resetalternate}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-col.lmt b/Master/texmf-dist/tex/context/base/mkxl/attr-col.lmt
new file mode 100644
index 00000000000..9c542a94293
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-col.lmt
@@ -0,0 +1,666 @@
+if not modules then modules = { } end modules ['attr-col'] = {
+ version = 1.001,
+ comment = "companion to attr-col.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- this module is being reconstructed and code will move to other places
+-- we can also do the nsnone via a metatable and then also se index 0
+
+-- list could as well refer to the tables (instead of numbers that
+-- index into another table) .. depends on what we need
+
+local type, tonumber = type, tonumber
+local concat = table.concat
+local min, max, floor, mod = math.min, math.max, math.floor, math.mod
+
+local attributes = attributes
+local nodes = nodes
+local utilities = utilities
+local logs = logs
+local backends = backends
+local storage = storage
+local context = context
+local tex = tex
+
+local variables = interfaces.variables
+local v_yes = variables.yes
+local v_no = variables.no
+
+local p_split_comma = lpeg.tsplitat(",")
+local p_split_colon = lpeg.splitat(":")
+local lpegmatch = lpeg.match
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+
+local report_attributes = logs.reporter("attributes","colors")
+local report_colors = logs.reporter("colors","support")
+local report_transparencies = logs.reporter("transparencies","support")
+
+-- todo: document this but first reimplement this as it reflects the early
+-- days of luatex / mkiv and we have better ways now
+
+-- nb: attributes: color etc is much slower than normal (marks + literals) but ...
+-- nb. too many "0 g"s
+
+local states = attributes.states
+local nodeinjections = backends.nodeinjections
+local registrations = backends.registrations
+local unsetvalue = attributes.unsetvalue
+
+local enableaction = nodes.tasks.enableaction
+local setaction = nodes.tasks.setaction
+
+local registerstorage = storage.register
+local formatters = string.formatters
+
+local interfaces = interfaces
+local implement = interfaces.implement
+
+local texgetattribute = tex.getattribute
+
+-- We can distinguish between rules and glyphs but it's not worth the trouble. A
+-- first implementation did that and while it saves a bit for glyphs and rules, it
+-- costs more resourses for transparencies. So why bother.
+
+--
+-- colors
+--
+
+-- we can also collapse the two attributes: n, n+1, n+2 and then
+-- at the tex end add 0, 1, 2, but this is not faster and less
+-- flexible (since sometimes we freeze color attribute values at
+-- the lua end of the game)
+--
+-- we also need to store the colorvalues because we need then in mp
+--
+-- This is a compromis between speed and simplicity. We used to store the
+-- values and data in one array, which made in neccessary to store the
+-- converters that need node constructor into strings and evaluate them
+-- at runtime (after reading from storage). Think of:
+--
+-- colors.strings = colors.strings or { }
+--
+-- if environment.initex then
+-- colors.strings[color] = "return colors." .. colorspace .. "(" .. concat({...},",") .. ")"
+-- end
+--
+-- registerstorage("attributes/colors/data", colors.strings, "attributes.colors.data") -- evaluated
+--
+-- We assume that only processcolors are defined in the format.
+
+attributes.colors = attributes.colors or { }
+local colors = attributes.colors
+
+local a_color = attributes.private('color')
+local a_selector = attributes.private('colormodel')
+
+colors.data = allocate()
+colors.values = colors.values or { }
+colors.registered = colors.registered or { }
+colors.weightgray = true
+colors.attribute = a_color
+colors.selector = a_selector
+colors.default = 1
+colors.main = nil
+colors.triggering = true
+colors.supported = true
+colors.model = "all"
+
+local data = colors.data
+local values = colors.values
+local registered = colors.registered
+
+local cmykrgbmode = 0 -- only for testing, already defined colors are not affected
+
+local numbers = attributes.numbers
+local list = attributes.list
+
+registerstorage("attributes/colors/values", values, "attributes.colors.values")
+registerstorage("attributes/colors/registered", registered, "attributes.colors.registered")
+
+directives.register("colors.cmykrgbmode", function(v) cmykrgbmode = tonumber(v) or 0 end)
+
+local f_colors = {
+ rgb = formatters["r:%s:%s:%s"],
+ cmyk = formatters["c:%s:%s:%s:%s"],
+ gray = formatters["s:%s"],
+ spot = formatters["p:%s:%s:%s:%s"],
+}
+
+local models = {
+ [interfaces.variables.none] = unsetvalue,
+ black = unsetvalue,
+ bw = unsetvalue,
+ all = 1,
+ gray = 2,
+ rgb = 3,
+ cmyk = 4,
+}
+
+local function rgbtocmyk(r,g,b) -- we could reduce
+ if not r then
+ return 0, 0, 0
+ else
+ return 1-r, 1-g, 1-b, 0
+ end
+end
+
+local function cmyktorgb(c,m,y,k)
+ if not c then
+ return 0, 0, 0, 1
+ elseif cmykrgbmode == 1 then
+ local d = 1.0 - k
+ return 1.0 - min(1.0,c*d+k), 1.0 - min(1.0,m*d+k), 1.0 - min(1.0,y*d+k)
+ else
+ return 1.0 - min(1.0,c +k), 1.0 - min(1.0,m +k), 1.0 - min(1.0,y +k)
+ end
+end
+
+local function rgbtogray(r,g,b)
+ if not r then
+ return 0
+ end
+ local w = colors.weightgray
+ if w == true then
+ return .30*r + .59*g + .11*b
+ elseif not w then
+ return r/3 + g/3 + b/3
+ else
+ return w[1]*r + w[2]*g + w[3]*b
+ end
+end
+
+local function cmyktogray(c,m,y,k)
+ return rgbtogray(cmyktorgb(c,m,y,k))
+end
+
+-- http://en.wikipedia.org/wiki/HSI_color_space
+-- http://nl.wikipedia.org/wiki/HSV_(kleurruimte)
+
+-- h /= 60; // sector 0 to 5
+-- i = floor( h );
+-- f = h - i; // factorial part of h
+
+local function hsvtorgb(h,s,v)
+ if s > 1 then
+ s = 1
+ elseif s < 0 then
+ s = 0
+ elseif s == 0 then
+ return v, v, v
+ end
+ if v > 1 then
+ s = 1
+ elseif v < 0 then
+ v = 0
+ end
+ if h < 0 then
+ h = 0
+ elseif h >= 360 then
+ h = mod(h,360)
+ end
+ local hd = h / 60
+ local hi = floor(hd)
+ local f = hd - hi
+ local p = v * (1 - s)
+ local q = v * (1 - f * s)
+ local t = v * (1 - (1 - f) * s)
+ if hi == 0 then
+ return v, t, p
+ elseif hi == 1 then
+ return q, v, p
+ elseif hi == 2 then
+ return p, v, t
+ elseif hi == 3 then
+ return p, q, v
+ elseif hi == 4 then
+ return t, p, v
+ elseif hi == 5 then
+ return v, p, q
+ else
+ print("error in hsv -> rgb",h,s,v)
+ return 0, 0, 0
+ end
+end
+
+local function rgbtohsv(r,g,b)
+ local offset, maximum, other_1, other_2
+ if r >= g and r >= b then
+ offset, maximum, other_1, other_2 = 0, r, g, b
+ elseif g >= r and g >= b then
+ offset, maximum, other_1, other_2 = 2, g, b, r
+ else
+ offset, maximum, other_1, other_2 = 4, b, r, g
+ end
+ if maximum == 0 then
+ return 0, 0, 0
+ end
+ local minimum = other_1 < other_2 and other_1 or other_2
+ if maximum == minimum then
+ return 0, 0, maximum
+ end
+ local delta = maximum - minimum
+ return (offset + (other_1-other_2)/delta)*60, delta/maximum, maximum
+end
+
+local function graytorgb(s) -- unweighted
+ return 1-s, 1-s, 1-s
+end
+
+local function hsvtogray(h,s,v)
+ return rgb_to_gray(hsv_to_rgb(h,s,v))
+end
+
+local function graytohsv(s)
+ return 0, 0, s
+end
+
+local function hwbtorgb(hue,black,white)
+ local r, g, b = hsvtorgb(hue,1,.5)
+ local f = 1 - white - black
+ return f * r + white, f * g + white , f * b + white
+end
+
+colors.rgbtocmyk = rgbtocmyk
+colors.rgbtogray = rgbtogray
+colors.cmyktorgb = cmyktorgb
+colors.cmyktogray = cmyktogray
+colors.rgbtohsv = rgbtohsv
+colors.hsvtorgb = hsvtorgb
+colors.hwbtorgb = hwbtorgb
+colors.hsvtogray = hsvtogray
+colors.graytohsv = graytohsv
+
+-- we can share some *data by using s, rgb and cmyk hashes, but
+-- normally the amount of colors is not that large; storing the
+-- components costs a bit of extra runtime, but we expect to gain
+-- some back because we have them at hand; the number indicates the
+-- default color space
+
+function colors.gray(s)
+ return { 2, s, s, s, s, 0, 0, 0, 1-s }
+end
+
+function colors.rgb(r,g,b)
+ local s = rgbtogray(r,g,b)
+ local c, m, y, k = rgbtocmyk(r,g,b)
+ return { 3, s, r, g, b, c, m, y, k }
+end
+
+function colors.cmyk(c,m,y,k)
+ local s = cmyktogray(c,m,y,k)
+ local r, g, b = cmyktorgb(c,m,y,k)
+ return { 4, s, r, g, b, c, m, y, k }
+end
+
+--~ function colors.spot(parent,f,d,p)
+--~ return { 5, .5, .5, .5, .5, 0, 0, 0, .5, parent, f, d, p }
+--~ end
+
+function colors.spot(parent,f,d,p)
+ -- inspect(parent) inspect(f) inspect(d) inspect(p)
+ if type(p) == "number" then
+ local n = list[numbers.color][parent] -- hard coded ref to color number
+ if n then
+ local v = values[n]
+ if v then
+ -- the via cmyk hack is dirty, but it scales better
+ local c, m, y, k = p*v[6], p*v[7], p*v[8], p*v[9]
+ local r, g, b = cmyktorgb(c,m,y,k)
+ local s = cmyktogray(c,m,y,k)
+ return { 5, s, r, g, b, c, m, y, k, parent, f, d, p }
+ end
+ end
+ else
+ -- todo, multitone (maybe p should be a table)
+ local ps = lpegmatch(p_split_comma,p)
+ local ds = lpegmatch(p_split_comma,d)
+ local c, m, y, k = 0, 0, 0, 0
+ local done = false
+ for i=1,#ps do
+ local p = tonumber(ps[i])
+ local d = ds[i]
+ if p and d then
+ local n = list[numbers.color][d] -- hard coded ref to color number
+ if n then
+ local v = values[n]
+ if v then
+ c = c + p*v[6]
+ m = m + p*v[7]
+ y = y + p*v[8]
+ k = k + p*v[9]
+ done = true
+ end
+ end
+ end
+ end
+ if done then
+ local r, g, b = cmyktorgb(c,m,y,k)
+ local s = cmyktogray(c,m,y,k)
+ local f = tonumber(f)
+ return { 5, s, r, g, b, c, m, y, k, parent, f, d, p }
+ end
+ end
+ return { 5, .5, .5, .5, .5, 0, 0, 0, .5, parent, f, d, p }
+end
+
+local function graycolor(...) graycolor = nodeinjections.graycolor return graycolor(...) end
+local function rgbcolor (...) rgbcolor = nodeinjections.rgbcolor return rgbcolor (...) end
+local function cmykcolor(...) cmykcolor = nodeinjections.cmykcolor return cmykcolor(...) end
+local function spotcolor(...) spotcolor = nodeinjections.spotcolor return spotcolor(...) end
+
+local function extender(colors,key)
+ if colors.supported and key == "none" then
+ local d = graycolor(0)
+ colors.none = d
+ return d
+ end
+end
+
+local function reviver(data,n)
+ if colors.supported then
+ local v = values[n]
+ local d
+ if not v then
+ local gray = graycolor(0)
+ d = { gray, gray, gray, gray }
+ report_attributes("unable to revive color %a",n)
+ else
+ local model = colors.forcedmodel(v[1])
+ if model == 2 then
+ local gray = graycolor(v[2])
+ d = { gray, gray, gray, gray }
+ elseif model == 3 then
+ local gray = graycolor(v[2])
+ local rgb = rgbcolor(v[3],v[4],v[5])
+ local cmyk = cmykcolor(v[6],v[7],v[8],v[9])
+ d = { rgb, gray, rgb, cmyk }
+ elseif model == 4 then
+ local gray = graycolor(v[2])
+ local rgb = rgbcolor(v[3],v[4],v[5])
+ local cmyk = cmykcolor(v[6],v[7],v[8],v[9])
+ d = { cmyk, gray, rgb, cmyk }
+ elseif model == 5 then
+ local spot = spotcolor(v[10],v[11],v[12],v[13])
+ -- d = { spot, gray, rgb, cmyk }
+ d = { spot, spot, spot, spot }
+ end
+ end
+ data[n] = d
+ return d
+ end
+end
+
+setmetatableindex(colors, extender)
+setmetatableindex(colors.data, reviver)
+
+function colors.filter(n)
+ return concat(data[n],":",5)
+end
+
+-- unweighted (flat) gray could be another model but a bit work as we need to check:
+--
+-- attr-col colo-ini colo-run
+-- grph-inc grph-wnd
+-- lpdf-col lpdf-fmt lpdf-fld lpdf-grp
+-- meta-pdf meta-pdh mlib-pps
+--
+-- but as we never needed it we happily delay that.
+
+function colors.setmodel(name,weightgray)
+ if weightgray == true or weightgray == v_yes then
+ weightgray = true
+ elseif weightgray == false or weightgray == v_no then
+ weightgray = false
+ else
+ local r, g, b = lpegmatch(p_split_colon,weightgray)
+ if r and g and b then
+ weightgray = { r, g, b }
+ else
+ weightgray = true
+ end
+ end
+ local default = models[name] or 1
+
+ colors.model = name -- global, not useful that way
+ colors.default = default -- global
+ colors.weightgray = weightgray -- global
+
+ -- avoid selective checking is no need for it
+
+ local forced = colors.forced
+
+ if forced == nil then
+ -- unset
+ colors.forced = default
+ elseif forced == false then
+ -- assumed mixed
+ elseif forced ~= default then
+ -- probably mixed
+ colors.forced = false
+ else
+ -- stil the same
+ end
+ return default
+end
+
+function colors.register(name, colorspace, ...) -- passing 9 vars is faster (but not called that often)
+ local stamp = f_colors[colorspace](...)
+ local color = registered[stamp]
+ if not color then
+ color = #values + 1
+ values[color] = colors[colorspace](...)
+ registered[stamp] = color
+ -- colors.reviver(color)
+ end
+ if name then
+ list[a_color][name] = color -- not grouped, so only global colors
+ end
+ return registered[stamp]
+end
+
+function colors.value(id)
+ return values[id]
+end
+
+attributes.colors.handler = nodes.installattributehandler {
+ name = "color",
+ namespace = colors,
+ initializer = states.initialize,
+ finalizer = states.finalize,
+ processor = states.selective,
+ resolver = function() return colors.main end,
+}
+
+function colors.enable(value)
+ setaction("shipouts","attributes.colors.handler",not (value == false or not colors.supported))
+end
+
+function colors.forcesupport(value) -- can move to attr-div
+ colors.supported = value
+ report_colors("color is %ssupported",value and "" or "not ")
+ colors.enable(value)
+end
+
+function colors.toattributes(name)
+ local mc = list[a_color][name]
+ local mm = texgetattribute(a_selector)
+ return (mm == unsetvalue and 1) or mm or 1, mc or list[a_color][1] or unsetvalue
+end
+
+-- transparencies
+
+local a_transparency = attributes.private('transparency')
+
+attributes.transparencies = attributes.transparencies or { }
+local transparencies = attributes.transparencies
+transparencies.registered = transparencies.registered or { }
+transparencies.data = allocate()
+transparencies.values = transparencies.values or { }
+transparencies.triggering = true
+transparencies.attribute = a_transparency
+transparencies.supported = true
+
+local registered = transparencies.registered -- we could use a 2 dimensional table instead
+local data = transparencies.data
+local values = transparencies.values
+local f_transparency = formatters["%s:%s"]
+
+registerstorage("attributes/transparencies/registered", registered, "attributes.transparencies.registered")
+registerstorage("attributes/transparencies/values", values, "attributes.transparencies.values")
+
+local function inject_transparency(...)
+ inject_transparency = nodeinjections.transparency
+ return inject_transparency(...)
+end
+
+local function register_transparency(...)
+ register_transparency = registrations.transparency
+ return register_transparency(...)
+end
+
+function transparencies.register(name,a,t,force) -- name is irrelevant here (can even be nil)
+ -- Force needed here for metapost converter. We could always force
+ -- but then we'd end up with transparencies resources even if we
+ -- would not use transparencies (but define them only). This is
+ -- somewhat messy.
+ local stamp = f_transparency(a,t)
+ local n = registered[stamp]
+ if not n then
+ n = #values + 1
+ values[n] = { a, t }
+ registered[stamp] = n
+ if force then
+ register_transparency(n,a,t)
+ end
+ elseif force and not data[n] then
+ register_transparency(n,a,t)
+ end
+ if name then
+ list[a_transparency][name] = n -- not grouped, so only global transparencies
+ end
+ return registered[stamp]
+end
+
+local function extender(transparencies,key)
+ if colors.supported and key == "none" then
+ local d = inject_transparency(0)
+ transparencies.none = d
+ return d
+ end
+end
+
+local function reviver(data,n)
+ if n and transparencies.supported then
+ local v = values[n]
+ local d
+ if not v then
+ d = inject_transparency(0)
+ else
+ d = inject_transparency(n)
+ register_transparency(n,v[1],v[2])
+ end
+ data[n] = d
+ return d
+ else
+ return ""
+ end
+end
+
+setmetatableindex(transparencies,extender)
+setmetatableindex(transparencies.data,reviver) -- register if used
+
+-- check if there is an identity
+
+function transparencies.value(id)
+ return values[id]
+end
+
+attributes.transparencies.handler = nodes.installattributehandler {
+ name = "transparency",
+ namespace = transparencies,
+ initializer = states.initialize,
+ finalizer = states.finalize,
+ processor = states.process,
+}
+
+function transparencies.enable(value) -- nil is enable
+ setaction("shipouts","attributes.transparencies.handler",not (value == false or not transparencies.supported))
+end
+
+function transparencies.forcesupport(value) -- can move to attr-div
+ transparencies.supported = value
+ report_transparencies("transparency is %ssupported",value and "" or "not ")
+ transparencies.enable(value)
+end
+
+function transparencies.toattribute(name)
+ return list[a_transparency][name] or unsetvalue
+end
+
+--- colorintents: overprint / knockout
+
+attributes.colorintents = attributes.colorintents or { }
+local colorintents = attributes.colorintents
+colorintents.data = allocate() -- colorintents.data or { }
+colorintents.attribute = attributes.private('colorintent')
+
+colorintents.registered = allocate {
+ overprint = 1,
+ knockout = 2,
+}
+
+local data, registered = colorintents.data, colorintents.registered
+
+local function extender(colorintents,key)
+ if key == "none" then
+ local d = data[2]
+ colorintents.none = d
+ return d
+ end
+end
+
+local function reviver(data,n)
+ if n == 1 then
+ local d = nodeinjections.overprint() -- called once
+ data[1] = d
+ return d
+ elseif n == 2 then
+ local d = nodeinjections.knockout() -- called once
+ data[2] = d
+ return d
+ end
+end
+
+setmetatableindex(colorintents, extender)
+setmetatableindex(colorintents.data, reviver)
+
+function colorintents.register(stamp)
+ return registered[stamp] or registered.overprint
+end
+
+colorintents.handler = nodes.installattributehandler {
+ name = "colorintent",
+ namespace = colorintents,
+ initializer = states.initialize,
+ finalizer = states.finalize,
+ processor = states.process,
+}
+
+function colorintents.enable()
+ enableaction("shipouts","attributes.colorintents.handler")
+end
+
+-- interface
+
+implement { name = "enablecolor", onlyonce = true, actions = colors.enable }
+implement { name = "enabletransparency", onlyonce = true, actions = transparencies.enable }
+implement { name = "enablecolorintents", onlyonce = true, actions = colorintents.enable }
+
+--------- { name = "registercolor", actions = { colors .register, context }, arguments = "string" }
+--------- { name = "registertransparency", actions = { transparencies.register, context }, arguments = "string" }
+implement { name = "registercolorintent", actions = { colorintents .register, context }, arguments = "string" }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-col.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-col.mkxl
new file mode 100644
index 00000000000..0c23f2ce384
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-col.mkxl
@@ -0,0 +1,22 @@
+%D \module
+%D [ file=attr-col,
+%D version=2007.06.06,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Color,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Color}
+
+\registerctxluafile{attr-col}{autosuffix}
+
+\unprotect
+
+% We implement this elsewhere but some code might end up here.
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-eff.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-eff.mkxl
new file mode 100644
index 00000000000..42aadf9a278
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-eff.mkxl
@@ -0,0 +1,60 @@
+%D \module
+%D [ file=attr-eff,
+%D version=2007.06.06,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Effects,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Effects}
+
+\registerctxluafile{attr-eff}{}
+
+\unprotect
+
+\installcorenamespace{effect}
+
+\installcommandhandler \??effect {effect} \??effect
+
+\setupeffect
+ [\c!method=\v!none,
+ \c!stretch=\zerocount,
+ \c!rulethickness=\zeropoint,
+ \c!alternative=\v!normal]
+
+\appendtoks
+ \edef\p_method{\effectparameter\c!method}%
+ \ifx\p_method\v!command
+ \frozen\protected\xdefcsname\e!start\currenteffect\endcsname{\starteffect[#1]}%
+ \frozen\protected\xdefcsname\e!stop \currenteffect\endcsname{\stopeffect}%
+ \fi
+\to \everydefineeffect
+
+\permanent\protected\def\starteffect[#1]%
+ {\clf_seteffect
+ alternative {\namedeffectparameter{#1}\c!alternative}
+ stretch \numexpr\namedeffectparameter{#1}\c!stretch\relax
+ rulethickness \dimexpr\namedeffectparameter{#1}\c!rulethickness\relax
+ \relax}
+
+\permanent\protected\def\stopeffect % can be special
+ {\clf_reseteffect} % v!normal 0 0
+
+\permanent\protected\def\effect[#1]%
+ {\groupedcommand{\starteffect[#1]}{\stopeffect}}
+
+% yes or no grouped
+
+\defineeffect [\v!inner] [\c!alternative=\v!inner,\c!rulethickness=.25pt]
+\defineeffect [\v!outer] [\c!alternative=\v!outer,\c!rulethickness=.25pt]
+\defineeffect [\v!both] [\c!alternative=\v!both, \c!rulethickness=.25pt]
+\defineeffect [\v!normal] [\c!alternative=\v!normal]
+\defineeffect [\v!hidden] [\c!alternative=\v!hidden]
+\defineeffect [\v!stretch] [\c!alternative=\v!stretch,\c!stretch=1]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-ini.mkxl
new file mode 100644
index 00000000000..e707a478f1f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-ini.mkxl
@@ -0,0 +1,141 @@
+%D \module
+%D [ file=attr-ini,
+%D version=2007.06.06,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Initialization}
+
+\unprotect
+
+\registerctxluafile{attr-ini}{}
+
+\installcorenamespace{attributecount} % the counter representing the attribute (attrdef'd)
+\installcorenamespace{attributeid} % the internal number
+\installcorenamespace{attributestack} % the attribute specific stack
+\installcorenamespace{attributepickup}
+
+\permanent\protected\def\pushattribute#1%
+ {\global\advance\csname\??attributestack\string#1\endcsname\plusone
+ \gdefcsname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname{\number\attribute#1}}
+
+\permanent\protected\def\popattribute#1%
+ {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\relax
+ \global\advance\csname\??attributestack\string#1\endcsname\minusone}
+
+\permanent\protected\def\installattributestack#1%
+ {\ifcsname\??attributestack\string#1\endcsname \else
+ \expandafter\newcount\csname\??attributestack\string#1\endcsname
+ \fi}
+
+\newtoks \t_attr_list_global
+\newtoks \t_attr_list_local
+\newtoks \t_attr_list_pickup
+\newtoks \t_attr_list_nomath
+
+\ifdefined \s!global \else \immutable\def\s!global {global} \fi % for metatex % or hard check later
+\ifdefined \s!public \else \immutable\def\s!public {public} \fi % for metatex % or hard check later
+\ifdefined \s!private \else \immutable\def\s!private {private} \fi % for metatex % or hard check later
+\ifdefined \s!attribute \else \immutable\def\s!attribute{attribute} \fi % for metatex % or hard check later
+\ifdefined \s!pickup \else \immutable\def\s!pickup {pickup} \fi % for metatex % or hard check later
+\ifdefined \s!forget \else \immutable\def\s!forget {forget} \fi % for metatex % or hard check later
+
+\immutable\def\??attributeprefix{c_attr_}
+
+\permanent\protected\def\defineattribute {\attr_basics_define_indeed[\s!public ]}
+\permanent\protected\def\definesystemattribute{\attr_basics_define_indeed[\s!private]}
+
+\tolerant\def\attr_basics_define_indeed[#1]#*[#2]#*[#3]%
+ {\ifcsname\??attributeprefix#2\endcsname\else
+ \scratchcounter\clf_defineattribute{#2}{#1}\relax
+ %\writestatus\m!system{defining #1 attribute #2 with number \number\scratchcounter}%
+ \global\permanent\expandafter\attributedef\csname\??attributeprefix#2\endcsname\scratchcounter % \foo = 123
+ \global\permanent\expandafter\integerdef \csname\??attributeid #2\endcsname\scratchcounter % \attribute\foo = 123
+ % some attributes are always global
+ \doifelseinset\s!global{#3}%
+ {\xtoksapp\t_attr_list_global{\csname\??attributeprefix#2\endcsname\attributeunsetvalue}}% \c_attr_foo
+ {\xtoksapp\t_attr_list_local {\csname\??attributeprefix#2\endcsname\attributeunsetvalue}}%
+ \doifinset\s!nomath{#3}%
+ {\xtoksapp\t_attr_list_nomath{\csname\??attributeprefix#2\endcsname\attributeunsetvalue}}%
+ \doifinset\s!public{#3}%
+ {\aliased\gletcsname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% \attribute\fooattribute
+ % used to sync in the page builder .. used for directions and scripts ... i start forgetting these details .. (seldom used)
+ \doifinset\s!pickup{#3}%
+ {\global\expandafter\integerdef\csname\??attributepickup#2\endcsname\attributeunsetvalue
+ \xtoksapp\t_attr_list_pickup{\csname\??attributeprefix#2\endcsname\csname\??attributepickup#2\endcsname}%
+ \ifcsname#2\s!attribute\endcsname
+ \permanent\xdefcsname\s!pickup#2\s!attribute\endcsname{\expandafter\integerdef\csname\??attributepickup#2\endcsname\csname\??attributeprefix#2\endcsname}%
+ \permanent\xdefcsname\s!forget#2\s!attribute\endcsname{\expandafter\integerdef\csname\??attributepickup#2\endcsname\attributeunsetvalue}%
+ \fi}%
+ \fi}
+
+\permanent\protected\def\pickupattributes
+ {\the\t_attr_list_pickup\relax}
+
+\permanent\protected\def\newattribute#1%
+ {\attr_basics_define_indeed[\s!public][\csstring#1][]%
+ \expandafter\glet\expandafter#1\csname\??attributeid\csstring#1\endcsname}
+
+% expandable so we can \edef them for speed
+
+\permanent\def\dosetattribute#1#2{\csname\??attributeprefix#1\endcsname#2\relax}
+\permanent\def\doresetattribute#1{\csname\??attributeprefix#1\endcsname\attributeunsetvalue}
+\permanent\def\dogetattribute #1{\number\csname\??attributeprefix#1\endcsname}
+\permanent\def\dogetattributeid#1{\number\csname\??attributeid #1\endcsname}
+
+\aliased\let\dompattribute\gobbletwoarguments
+
+\permanent\protected\def\resetglobalattributes{\the\t_attr_list_global\glyphdatafield\zerocount\glyphscriptfield\zerocount}
+\permanent\protected\def\resetlocalattributes {\the\t_attr_list_local \glyphdatafield\zerocount\glyphscriptfield\zerocount}
+
+\aliased\let\resetallattributes\resetlocalattributes
+
+%D Rather special.
+
+\permanent\protected\def\savecurrentattributes #1{\clf_savecurrentattributes {#1}}
+\permanent\protected\def\restorecurrentattributes#1{\clf_restorecurrentattributes{#1}}
+
+%D For the moment we put this here. The order of definition matters a bit because
+%D performance is better when we put frequently accessed attributes at the front.
+%D So, we might move more here.
+
+%definesystemattribute [state] % nomath
+\definesystemattribute [color] [public] % global
+\definesystemattribute [colormodel] [public,global]
+%definesystemattribute [skip]
+%definesystemattribute [penalty]
+\definesystemattribute [transparency] [public]
+\definesystemattribute [reference] [public]
+\definesystemattribute [destination] [public]
+\definesystemattribute [case] [public]
+\definesystemattribute [visual] [public,global]
+\definesystemattribute [viewerlayer] [public]
+\definesystemattribute [background] [public]
+\definesystemattribute [alignbackground] [public]
+\definesystemattribute [colorintent] [public]
+\definesystemattribute [negative] [public]
+\definesystemattribute [effect] [public]
+\definesystemattribute [layoutcomponent] [public]
+\definesystemattribute [internal] [public]
+\definesystemattribute [ruled] [public]
+\definesystemattribute [shifted] [public]
+\definesystemattribute [checkedbreak] [public]
+\definesystemattribute [alternate] [public]
+\definesystemattribute [vboxtohboxseparator] [public]
+
+\permanent\protected\let\showattributes\clf_showattributes % maybe at lua end
+
+%D Todo:
+
+% \appendtoks
+% \clf_cleanupattributes
+% \to \everyafterpagebreak
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-lay.lmt b/Master/texmf-dist/tex/context/base/mkxl/attr-lay.lmt
new file mode 100644
index 00000000000..d0febb9eefb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-lay.lmt
@@ -0,0 +1,311 @@
+if not modules then modules = { } end modules ['attr-lay'] = {
+ version = 1.001,
+ comment = "companion to attr-lay.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- layers (ugly code, due to no grouping and such); currently we use exclusive layers
+-- but when we need it stacked layers might show up too; the next function based
+-- approach can be replaced by static (metatable driven) resolvers
+
+-- maybe use backends.registrations here too
+
+local type = type
+local insert, remove = table.insert, table.remove
+
+local attributes = attributes
+local nodes = nodes
+local utilities = utilities
+local logs = logs
+local backends = backends
+
+local context = context
+local interfaces = interfaces
+local tex = tex
+
+local implement = interfaces.implement
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local report_viewerlayers = logs.reporter("viewerlayers")
+
+-- todo: document this but first reimplement this as it reflects the early
+-- days of luatex / mkiv and we have better ways now
+
+-- nb: attributes: color etc is much slower than normal (marks + literals) but ...
+-- nb. too many "0 g"s
+-- nb: more local tables
+
+attributes.viewerlayers = attributes.viewerlayers or { }
+local viewerlayers = attributes.viewerlayers
+
+local variables = interfaces.variables
+local v_local = variables["local"]
+local v_global = variables["global"]
+local v_start = variables["start"]
+local v_yes = variables["yes"]
+
+local a_viewerlayer = attributes.private("viewerlayer")
+
+viewerlayers = viewerlayers or { }
+viewerlayers.data = allocate()
+viewerlayers.registered = viewerlayers.registered or { }
+viewerlayers.values = viewerlayers.values or { }
+viewerlayers.scopes = viewerlayers.scopes or { }
+viewerlayers.listwise = allocate()
+viewerlayers.attribute = a_viewerlayer
+viewerlayers.supported = true
+viewerlayers.hasorder = true
+
+local states = attributes.states
+local enableaction = nodes.tasks.enableaction
+local disableaction = nodes.tasks.disableaction
+local nodeinjections = backends.nodeinjections
+local codeinjections = backends.codeinjections
+
+local texsetattribute = tex.setattribute
+local texgetattribute = tex.getattribute
+local texsettokenlist = tex.settoks
+local unsetvalue = attributes.unsetvalue
+
+local data = viewerlayers.data
+local values = viewerlayers.values
+local listwise = viewerlayers.listwise
+local registered = viewerlayers.registered
+local scopes = viewerlayers.scopes
+
+local f_stamp = formatters["%s"]
+
+storage.register("attributes/viewerlayers/registered", registered, "attributes.viewerlayers.registered")
+storage.register("attributes/viewerlayers/values", values, "attributes.viewerlayers.values")
+storage.register("attributes/viewerlayers/scopes", scopes, "attributes.viewerlayers.scopes")
+
+local layerstacker = utilities.stacker.new("layers") -- experiment
+
+layerstacker.mode = "stack"
+layerstacker.unset = attributes.unsetvalue
+
+viewerlayers.resolve_reset = layerstacker.resolve_reset
+viewerlayers.resolve_begin = layerstacker.resolve_begin
+viewerlayers.resolve_step = layerstacker.resolve_step
+viewerlayers.resolve_end = layerstacker.resolve_end
+
+-- stacked
+
+local function startlayer(...) startlayer = nodeinjections.startlayer return startlayer(...) end
+local function stoplayer (...) stoplayer = nodeinjections.stoplayer return stoplayer (...) end
+
+local function extender(viewerlayers,key)
+ if viewerlayers.supported and key == "none" then
+ local d = stoplayer()
+ viewerlayers.none = d
+ return d
+ end
+end
+
+local function reviver(data,n)
+ if viewerlayers.supported then
+ local v = values[n]
+ if v then
+ local d = startlayer(v)
+ data[n] = d
+ return d
+ else
+ report_viewerlayers("error: unknown reference %a",tostring(n))
+ end
+ end
+end
+
+setmetatableindex(viewerlayers,extender)
+setmetatableindex(viewerlayers.data,reviver)
+
+-- !!!! TEST CODE !!!!
+
+layerstacker.start = function(...) local f = nodeinjections.startstackedlayer layerstacker.start = f return f(...) end
+layerstacker.stop = function(...) local f = nodeinjections.stopstackedlayer layerstacker.stop = f return f(...) end
+layerstacker.change = function(...) local f = nodeinjections.changestackedlayer layerstacker.change = f return f(...) end
+
+local function initializer(...)
+ return states.initialize(...)
+end
+
+attributes.viewerlayers.handler = nodes.installattributehandler {
+ name = "viewerlayer",
+ namespace = viewerlayers,
+ initializer = initializer,
+ finalizer = states.finalize,
+ processor = states.stacker,
+ -- processor = states.stacked,
+}
+
+local stack, enabled, global = { }, false, false
+
+function viewerlayers.enable(value)
+ if value == false or not viewerlayers.supported then
+ if enabled then
+ disableaction("shipouts","attributes.viewerlayers.handler")
+ end
+ enabled = false
+ else
+ if not enabled then
+ enableaction("shipouts","attributes.viewerlayers.handler")
+ end
+ enabled = true
+ end
+end
+
+function viewerlayers.forcesupport(value)
+ viewerlayers.supported = value
+ report_viewerlayers("viewerlayers are %ssupported",value and "" or "not ")
+ viewerlayers.enable(value)
+end
+
+local function register(name,lw) -- if not inimode redefine data[n] in first call
+ if not enabled then
+ viewerlayers.enable(true)
+ end
+ local stamp = f_stamp(name)
+ local n = registered[stamp]
+ if not n then
+ n = #values + 1
+ values[n] = name
+ registered[stamp] = n
+ listwise[n] = lw or false -- lw forces a used
+ end
+ return registered[stamp] -- == n
+end
+
+viewerlayers.register = register
+
+function viewerlayers.setfeatures(hasorder)
+ viewerlayers.hasorder = hasorder
+end
+
+local usestacker = true -- new, experimental
+
+function viewerlayers.start(name)
+ local a
+ if usestacker then
+ a = layerstacker.push(register(name) or unsetvalue)
+ else
+ insert(stack,texgetattribute(a_viewerlayer))
+ a = register(name) or unsetvalue
+ end
+ if global or scopes[name] == v_global then
+ scopes[a] = v_global -- messy but we don't know the attributes yet
+ texsetattribute("global",a_viewerlayer,a)
+ else
+ texsetattribute(a_viewerlayer,a)
+ end
+ -- or macro
+ texsettokenlist("currentviewerlayertoks",name)
+end
+
+function viewerlayers.stop()
+ local a
+ if usestacker then
+ a = layerstacker.pop()
+ else
+ a = remove(stack)
+ end
+ if not a then
+ -- error
+ elseif a >= 0 then
+ if global or scopes[a] == v_global then
+ texsetattribute("global",a_viewerlayer,a)
+ else
+ texsetattribute(a_viewerlayer,a)
+ end
+ texsettokenlist("currentviewerlayertoks",values[a] or "")
+ else
+ if global or scopes[a] == v_global then
+ texsetattribute("global",a_viewerlayer,unsetvalue)
+ else
+ texsetattribute(a_viewerlayer,unsetvalue)
+ end
+ texsettokenlist("currentviewerlayertoks","")
+ end
+end
+
+function viewerlayers.define(settings)
+ local tag = settings.tag
+ if not tag or tag == "" then
+ -- error
+ elseif not scopes[tag] then -- prevent duplicates
+ local title = settings.title
+ if not title or title == "" then
+ settings.title = tag
+ end
+ scopes[tag] = settings.scope or v_local
+ codeinjections.defineviewerlayer(settings)
+ end
+end
+
+function viewerlayers.definedlayoutcomponent(tag)
+ viewerlayers.define {
+ tag = tag,
+ title = utilities.strings.nice(tag),
+ visible = v_start,
+ editable = v_yes,
+ printable = v_yes,
+ }
+ return register(tag,true) -- true forces a use
+end
+
+function viewerlayers.cleanup()
+ layerstacker.clean()
+ -- todo
+end
+
+implement {
+ name = "cleanuplayers",
+ actions = viewerlayers.cleanup
+}
+
+implement {
+ name = "defineviewerlayer",
+ actions = viewerlayers.define,
+ arguments = {
+ {
+ { "tag" },
+ { "title" },
+ { "visible" },
+ { "editable" },
+ { "export" },
+ { "printable" },
+ { "scope" },
+ },
+ true
+ }
+}
+
+implement {
+ name = "definedlayoutcomponent",
+ actions = { viewerlayers.definedlayoutcomponent, context },
+ arguments = "string"
+}
+
+implement {
+ name = "startviewerlayer",
+ public = true,
+ protected = true,
+ actions = viewerlayers.start,
+ arguments = "optional",
+}
+
+implement {
+ name = "stopviewerlayer",
+ public = true,
+ protected = true,
+ actions = viewerlayers.stop
+}
+
+implement {
+ name = "registeredviewerlayer",
+ actions = { register, context },
+ arguments = { "string", true } -- true forces a use
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-lay.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-lay.mkxl
new file mode 100644
index 00000000000..00c6335337a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-lay.mkxl
@@ -0,0 +1,107 @@
+%D \module
+%D [ file=attr-lay,
+%D version=2007.06.06,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Viewerlayers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Viewerlayers}
+
+%D Currently there is a limitation in mixed inline usage. This has to do with the fact
+%D that we have a stacked model but cannot determine where to revert to (as we can
+%D have AABBCCAA ranges). Maybe I'll solve that one day. It only affects nested inline
+%D layers and these make not much sense anyway. We'd have to store the complete nesting
+%D stack in the attribute in order to be able to cross pages and that demands a new
+%D mechanism.
+
+\unprotect
+
+\registerctxluafile{attr-lay}{autosuffix}
+
+% needs to work over stopitemize grouping etc
+
+\installcorenamespace{viewerlayer}
+
+\installcommandhandler \??viewerlayer {viewerlayer} \??viewerlayer
+
+\setupviewerlayer
+ [\c!state=\v!start,
+ \c!title=,
+ \c!export=\v!yes, % exportable is ugly
+ \c!printable=\v!yes,
+ \c!scope=\v!local, % maybe global but needs checking with layout
+ \c!method=\v!none]
+
+\appendtoks
+ \clf_defineviewerlayer
+ tag {\currentviewerlayer}%
+ title {\viewerlayerparameter\c!title}%
+ visible {\viewerlayerparameter\c!state}%
+ editable {\v!yes}%
+ export {\viewerlayerparameter\c!export}%
+ printable {\viewerlayerparameter\c!printable}%
+ scope {\viewerlayerparameter\c!scope}%
+ \relax
+ \doif{\viewerlayerparameter\c!method}\v!command
+ {\frozen\instance\setuxvalue{\e!start#1}{\startviewerlayer[\currentviewerlayer]}%
+ \frozen\instance\setuxvalue{\e!stop #1}{\stopviewerlayer}}%
+\to \everydefineviewerlayer
+
+% \startviewerlayer[#1] % defined at lua end
+% \stopviewerlayer % defined at lua end
+
+\permanent\protected\def\viewerlayer[#1]%
+ {\groupedcommand{\startviewerlayer[#1]}{\stopviewerlayer}}
+
+% some day we will keep this at the lua end as the info is only needed there
+
+\newtoks\currentviewerlayertoks % soon we can set macros at the lua end
+
+\def\currentviewerlayer{\the\currentviewerlayertoks}
+
+\appendtoks
+ \let\currentviewerlayer\empty
+\to \everybeforepagebody
+
+% layout components are implemented rather directly (speed)
+
+\installcorenamespace{layoutcomponentattribute}
+
+\mutable\let\layoutcomponentboxattribute\empty
+
+\permanent\def\attr_layoutcomponent_initialize#1%
+ {\edef\layoutcomponentboxattribute{\clf_definedlayoutcomponent{#1}}%
+ \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}%
+ \gletcsname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute}
+
+\permanent\def\attr_layoutcomponent_set#1% make this faster
+ {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??layoutcomponentattribute#1\endcsname
+ \ifrelax\layoutcomponentboxattribute
+ \attr_layoutcomponent_initialize{#1}% get rid of { }
+ \fi}
+
+\permanent\def\attr_layoutcomponent_reset
+ {\let\layoutcomponentboxattribute\empty}
+
+\permanent\let\setlayoutcomponentattribute \gobbleoneargument
+\permanent\let\resetlayoutcomponentattribute\relax
+ \let\layoutcomponentboxattribute \empty
+
+\permanent\protected\def\showlayoutcomponents
+ {\enforced\let\setlayoutcomponentattribute \attr_layoutcomponent_set
+ \enforced\let\resetlayoutcomponentattribute\attr_layoutcomponent_reset}
+
+\protected\def\attr_layoutcomponent_cleanup
+ {\clf_cleanuplayers}
+
+\appendtoks
+ \attr_layoutcomponent_cleanup
+\to \everyshipout
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-mkr.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-mkr.mkxl
new file mode 100644
index 00000000000..2209af24157
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-mkr.mkxl
@@ -0,0 +1,25 @@
+%D \module
+%D [ file=attr-mkr,
+%D version=2013.01.09,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Markers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Markers}
+
+\unprotect
+
+\registerctxluafile{attr-mkr}{}
+
+\permanent \protected\def\definemarker [#1]{\defineattribute[\s!marker:#1]}
+\permanent\tolerant\protected\def\setmarker [#1]#*[#2]{\dosetattribute{\s!marker:#1}{#2}}
+\permanent \protected\def\resetmarker [#1]{\dogetattribute{\s!marker:#1}}
+\permanent \def\boxmarker #1#2{attr \numexpr\dogetattributeid{\s!marker:#1}\numexpr \numexpr#2\relax}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/attr-neg.mkxl b/Master/texmf-dist/tex/context/base/mkxl/attr-neg.mkxl
new file mode 100644
index 00000000000..c849e6bf6db
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/attr-neg.mkxl
@@ -0,0 +1,28 @@
+%D \module
+%D [ file=attr-neg,
+%D version=2007.06.06,
+%D title=\CONTEXT\ Attribute Macros,
+%D subtitle=Negation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Attribute Macros / Negation}
+
+\registerctxluafile{attr-neg}{}
+
+\unprotect
+
+% positive and negative are preregistered
+
+\permanent\protected\def\startnegative{\clf_setnegative{\v!negative}}
+\permanent\protected\def\stopnegative {\clf_setnegative{\v!positive}}
+
+\permanent\protected\def\startpositive{\clf_setnegative{\v!positive}}
+\permanent\protected\def\stoppositive {\clf_setnegative{\v!negative}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-mth.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-mth.lmt
new file mode 100644
index 00000000000..73c09d79ecf
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-mth.lmt
@@ -0,0 +1,742 @@
+if not modules then modules = { } end modules ['back-exp-imp-mth'] = {
+ version = 1.001,
+ comment = "companion to back-exp.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local sub = string.sub
+local utfchar, utfvalues = utf.char, utf.values
+local setmetatableindex, concat = table.setmetatableindex, table.concat
+
+local structurestags = structures.tags
+local specifications = structurestags.specifications
+local locatedtag = structurestags.locatedtag
+
+local backend = structurestags.backend
+
+local setattribute = backend.setattribute
+local extras = backend.extras
+local checks = backend.checks
+local finalizers = backend.finalizers
+
+local implement = interfaces.implement
+
+do
+
+ local automathrows = true directives.register("export.math.autorows", function(v) automathrows = v end)
+ local automathapply = true directives.register("export.math.autoapply", function(v) automathapply = v end)
+ local automathnumber = true directives.register("export.math.autonumber", function(v) automathnumber = v end)
+ local automathstrip = true directives.register("export.math.autostrip", function(v) automathstrip = v end)
+
+ local functions = mathematics.categories.functions
+
+ local function collapse(di,i,data,ndata,detail,element)
+ local collapsing = di.data
+ if data then
+ di.element = element
+ di.detail = nil
+ i = i + 1
+ while i <= ndata do
+ local dn = data[i]
+ if dn.detail == detail then
+ collapsing[#collapsing+1] = dn.data[1]
+ dn.skip = "ignore"
+ i = i + 1
+ else
+ break
+ end
+ end
+ end
+ return i
+ end
+
+ local function collapse_mn(di,i,data,ndata)
+ -- this is tricky ... we need to make sure that we wrap in mrows if we want
+ -- to bypass this one
+ local collapsing = di.data
+ if data then
+ i = i + 1
+ while i <= ndata do
+ local dn = data[i]
+ local tg = dn.tg
+ if tg == "mn" then
+ collapsing[#collapsing+1] = dn.data[1]
+ dn.skip = "ignore"
+ i = i + 1
+ elseif tg == "mo" then
+ local d = dn.data[1]
+ if d == "." then
+ collapsing[#collapsing+1] = d
+ dn.skip = "ignore"
+ i = i + 1
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ end
+ return i
+ end
+
+ -- maybe delay __i__ till we need it
+
+ local apply_function = {
+ {
+ element = "mo",
+ -- comment = "apply function",
+ -- data = { utfchar(0x2061) },
+ data = { "" },
+ nature = "mixed",
+ }
+ }
+
+ local functioncontent = { }
+
+ setmetatableindex(functioncontent,function(t,k)
+ local v = { { content = k } }
+ t[k] = v
+ return v
+ end)
+
+ local dummy_nucleus = {
+ element = "mtext",
+ data = { content = "" },
+ nature = "inline",
+ comment = "dummy nucleus",
+ fulltag = "mtext>0"
+ }
+
+ local function accentchar(d)
+ for i=1,3 do
+ d = d.data
+ if not d then
+ return
+ end
+ d = d[1]
+ if not d then
+ return
+ end
+ local tg = d.tg
+ if tg == "mover" then
+ local s = specifications[d.fulltag]
+ local t = s.top
+ if t then
+ d = d.data[1]
+ local d1 = d.data[1]
+ d1.content = utfchar(t)
+ d.data = { d1 }
+ return d
+ end
+ elseif tg == "munder" then
+ local s = specifications[d.fulltag]
+ local b = s.bottom
+ if b then
+ d = d.data[1]
+ local d1 = d.data[1]
+ d1.content = utfchar(b)
+ d.data = { d1 }
+ return d
+ end
+ end
+ end
+ end
+
+ local no_mrow = {
+ mrow = true,
+ mfenced = true,
+ mfrac = true,
+ mroot = true,
+ msqrt = true,
+ mtable = true,
+ mi = true,
+ mo = true,
+ mn = true,
+ }
+
+ local function checkmath(root) -- we can provide utf.toentities as an option
+ local data = root.data
+ if data then
+ local ndata = #data
+ local roottg = root.tg
+ if roottg == "msubsup" then
+ -- kind of tricky: we have a diufferent order in display mode
+ local nucleus, superscript, subscript
+ if ndata > 3 then
+ -- error
+ else
+ for i=1,ndata do
+ local di = data[i]
+ if not di then
+ -- weird
+ elseif di.content then
+ -- text
+ else
+ local s = specifications[di.fulltag]
+ if s.subscript then
+ subscript = i
+ elseif s.superscript then
+ superscript = i
+ else
+ nucleus = i
+ end
+ end
+ end
+ if superscript or subscript then
+ -- we probably always have 3 anyway ... needs checking
+ local nuc = nucleus and data[nucleus]
+ local sub = subscript and data[subscript]
+ local sup = superscript and data[superscript]
+ local n = 0 -- play safe
+ if nuc then n = n + 1 ; data[n] = nuc end
+ if sub then n = n + 1 ; data[n] = sub end
+ if sup then n = n + 1 ; data[n] = sup end
+ end
+ end
+ -- elseif roottg == "msup" or roottg == "msub" then
+ -- -- m$^2$
+ -- if ndata == 1 then
+ -- local d = data[1]
+ -- data[2] = d
+ -- d.__i__ = 2
+ -- data[1] = dummy_nucleus
+ -- end
+ elseif roottg == "mfenced" then
+ local s = specifications[root.fulltag]
+ local l, m, r = s.left, s.middle, s.right
+ if l then
+ l = utfchar(l)
+ end
+ if m then
+ local t = { }
+ for i=1,#m do
+ t[i] = utfchar(m[i])
+ end
+ m = concat(t)
+ end
+ if r then
+ r = utfchar(r)
+ end
+ root.attributes = {
+ open = l,
+ separators = m,
+ close = r,
+ }
+ end
+ if ndata == 0 then
+ root.skip = "comment" -- get rid of weird artefacts
+ root.nota = "weird"
+ return
+ elseif ndata == 1 then
+ local d = data[1]
+ if not d or d == "" then
+ root.skip = "comment"
+ return
+ elseif d.content then
+ return
+ else -- if ndata == 1 then
+ local tg = d.tg
+ if automathrows and (roottg == "mrow" or roottg == "mtext") then
+ -- maybe just always ! check spec first
+ -- or we can have chesks.* for each as we then can flatten
+ if no_mrow[tg] then
+ root.skip = "comment"
+ end
+ elseif roottg == "mo" then
+ if tg == "mo" then
+ root.skip = "comment"
+ end
+ end
+ end
+ end
+ local i = 1
+ while i <= ndata do -- -- -- TOO MUCH NESTED CHECKING -- -- --
+ local di = data[i]
+ if di and not di.content then
+ local tg = di.tg
+ if tg == "math" then
+ -- di.element = "mrow" -- when properties
+ di.skip = "comment"
+ checkmath(di)
+ i = i + 1
+ elseif tg == "mover" then
+ local s = specifications[di.fulltag]
+ if s.accent then
+ local t = s.top
+ local d = di.data
+ -- todo: accent = "false" (for scripts like limits)
+ di.attributes = {
+ accent = "true",
+ }
+ -- todo: p.topfixed
+ if t then
+ -- mover
+ d[1].data[1].content = utfchar(t)
+ di.data = { d[2], d[1] }
+ end
+ else
+ -- can't happen
+ end
+ checkmath(di)
+ i = i + 1
+ elseif tg == "munder" then
+ local s = specifications[di.fulltag]
+ if s.accent then
+ local b = s.bottom
+ local d = di.data
+ -- todo: accent = "false" (for scripts like limits)
+ di.attributes = {
+ accent = "true",
+ }
+ -- todo: p.bottomfixed
+ if b then
+ -- munder
+ d[2].data[1].content = utfchar(b)
+ end
+ else
+ -- can't happen
+ end
+ checkmath(di)
+ i = i + 1
+ elseif tg == "munderover" then
+ local s = specifications[di.fulltag]
+ if s.accent then
+ local t = s.top
+ local b = s.bottom
+ local d = di.data
+ -- todo: accent = "false" (for scripts like limits)
+ -- todo: accentunder = "false" (for scripts like limits)
+ di.attributes = {
+ accent = "true",
+ accentunder = "true",
+ }
+ -- todo: p.topfixed
+ -- todo: p.bottomfixed
+ if t and b then
+ -- munderover
+ d[1].data[1].content = utfchar(t)
+ d[3].data[1].content = utfchar(b)
+ di.data = { d[2], d[3], d[1] }
+ else
+ -- can't happen
+ end
+ else
+ -- can't happen
+ end
+ checkmath(di)
+ i = i + 1
+ elseif tg == "mstacker" then
+ local d = di.data
+ local d1 = d[1]
+ local d2 = d[2]
+ local d3 = d[3]
+ local t1 = d1 and d1.tg
+ local t2 = d2 and d2.tg
+ local t3 = d3 and d3.tg
+ local m = nil -- d1.data[1]
+ local t = nil
+ local b = nil
+ -- only accent when top / bot have stretch
+ -- normally we flush [base under over] which is better for tagged pdf
+ if t1 == "mstackermid" then
+ m = accentchar(d1) -- or m
+ if t2 == "mstackertop" then
+ if t3 == "mstackerbot" then
+ t = accentchar(d2)
+ b = accentchar(d3)
+ di.element = "munderover"
+ di.data = { m or d1.data[1], b or d3.data[1], t or d2.data[1] }
+ else
+ t = accentchar(d2)
+ di.element = "mover"
+ di.data = { m or d1.data[1], t or d2.data[1] }
+ end
+ elseif t2 == "mstackerbot" then
+ if t3 == "mstackertop" then
+ b = accentchar(d2)
+ t = accentchar(d3)
+ di.element = "munderover"
+ di.data = { m or d1.data[1], t or d3.data[1], m, b or d2.data[1] }
+ else
+ b = accentchar(d2)
+ di.element = "munder"
+ di.data = { m or d1.data[1], b or d2.data[1] }
+ end
+ else
+ -- can't happen
+ end
+ else
+ -- can't happen
+ end
+ if t or b then
+ di.attributes = {
+ accent = t and "true" or nil,
+ accentunder = b and "true" or nil,
+ }
+ di.detail = nil
+ end
+ checkmath(di)
+ i = i + 1
+ elseif tg == "mroot" then
+ local data = di.data
+ local size = #data
+ if size == 1 then
+ -- else firefox complains ... code in math-tag (for pdf tagging)
+ di.element = "msqrt"
+ elseif size == 2 then
+ data[1], data[2] = data[2], data[1]
+ end
+ checkmath(di)
+ i = i + 1
+ elseif tg == "break" then
+ di.skip = "comment"
+ i = i + 1
+ elseif tg == "mtext" then
+ -- this is only needed for unboxed mtexts ... all kind of special
+ -- tex border cases and optimizations ... trial and error
+ local data = di.data
+ if #data > 1 then
+ for i=1,#data do
+ local di = data[i]
+ local content = di.content
+ if content then
+ data[i] = {
+ element = "mtext",
+ nature = "inline",
+ data = { di },
+ n = 0,
+ }
+ elseif di.tg == "math" then
+ local di = di.data[1]
+ if di then
+ data[i] = di
+ checkmath(di)
+ end
+ end
+ end
+ di.element = "mrow"
+ -- di.tg = "mrow"
+ -- di.nature = "inline"
+ end
+ checkmath(di)
+ i = i + 1
+ elseif tg == "mrow" and detail then -- hm, falls through
+ di.detail = nil
+ checkmath(di)
+ di = {
+ element = "maction",
+ nature = "display",
+ attributes = { actiontype = detail },
+ data = { di },
+ n = 0,
+ }
+ data[i] = di
+ i = i + 1
+ else
+ local category = di.mathcategory
+ if category then
+ -- no checkmath(di) here
+ if category == 1 then -- mo
+ i = collapse(di,i,data,ndata,detail,"mo")
+ elseif category == 2 then -- mi
+ i = collapse(di,i,data,ndata,detail,"mi")
+ elseif category == 3 then -- mn
+ i = collapse(di,i,data,ndata,detail,"mn")
+ elseif category == 4 then -- ms
+ i = collapse(di,i,data,ndata,detail,"ms")
+ elseif category >= 1000 then
+ local apply = category >= 2000
+ if apply then
+ category = category - 1000
+ end
+ if tg == "mi" then -- function
+ if roottg == "mrow" then
+ root.skip = "comment"
+ root.element = "function"
+ end
+ i = collapse(di,i,data,ndata,detail,"mi")
+ local tag = functions[category]
+ if tag then
+ di.data = functioncontent[tag]
+ end
+ if apply then
+ di.after = apply_function
+ elseif automathapply then -- make function
+ local following
+ if i <= ndata then
+ -- normally not the case
+ following = data[i]
+ else
+ local parent = di.__p__ -- == root
+ if parent.tg == "mrow" then
+ parent = parent.__p__
+ end
+ local index = parent.__i__
+ following = parent.data[index+1]
+ end
+ if following then
+ local tg = following.tg
+ if tg == "mrow" or tg == "mfenced" then -- we need to figure out the right condition
+ di.after = apply_function
+ end
+ end
+ end
+ else -- some problem
+ checkmath(di)
+ i = i + 1
+ end
+ else
+ checkmath(di)
+ i = i + 1
+ end
+ elseif automathnumber and tg == "mn" then
+ checkmath(di)
+ i = collapse_mn(di,i,data,ndata)
+ else
+ checkmath(di)
+ i = i + 1
+ end
+ end
+ else -- can be string or boolean
+ if parenttg ~= "mtext" and di == " " then
+ data[i] = false
+ end
+ i = i + 1
+ end
+ end
+ end
+ end
+
+ local function stripmath(di)
+ if not di then
+ --
+ elseif di.content then
+ return di
+ else
+ local tg = di.tg
+ if tg == "mtext" or tg == "ms" then
+ return di
+ else
+ local data = di.data
+ local ndata = #data
+ local n = 0
+ for i=1,ndata do
+ local d = data[i]
+ if d and not d.content then
+ d = stripmath(d)
+ end
+ if d then
+ local content = d.content
+ if not content then
+ n = n + 1
+ d.__i__ = n
+ data[n] = d
+ elseif content == " " or content == "" then
+ if di.tg == "mspace" then
+ -- we append or prepend a space to a preceding or following mtext
+ local parent = di.__p__
+ local index = di.__i__ -- == i
+ local data = parent.data
+ if index > 1 then
+ local d = data[index-1]
+ if d.tg == "mtext" then
+ local dd = d.data
+ local dn = dd[#dd]
+ local dc = dn.content
+ if dc then
+ dn.content = dc .. content
+ end
+ end
+ elseif index < ndata then
+ local d = data[index+1]
+ if d.tg == "mtext" then
+ local dd = d.data
+ local dn = dd[1]
+ local dc = dn.content
+ if dc then
+ dn.content = content .. dc
+ end
+ end
+ end
+ end
+ else
+ n = n + 1
+ data[n] = d
+ end
+ end
+ end
+ for i=ndata,n+1,-1 do
+ data[i] = nil
+ end
+ if #data > 0 then
+ return di
+ end
+ end
+ end
+ end
+
+ function checks.math(di)
+ if di.skip == "comment" then
+ -- already done, kind of weird, happens in mathmatrix, maybe some collapse
+ -- issue that i need to look into
+ else
+ local specification = specifications[di.fulltag]
+ local mode = specification and specification.mode == "display" and "block" or "inline"
+ di.attributes = {
+ ["display"] = mode,
+ ["xmlns:m"] = mathmlns,
+ }
+ -- can be option if needed:
+ if mode == "inline" then
+ -- di.nature = "mixed" -- else spacing problem (maybe inline)
+ di.nature = "inline" -- we need to catch x$X$x and x $X$ x
+ else
+ di.nature = "display"
+ end
+ if automathstrip then
+ stripmath(di)
+ end
+ checkmath(di)
+ end
+ end
+
+ -- this one can replace some of the previous code .. todo (test on mathmatrix)
+
+ -- ignore with no data can be removed
+
+ local function checked(d)
+ local n = #d
+ if n == 1 then
+ local di = d[1]
+ local tg = di.tg
+ if tg == "ignore" then
+ -- todo: we can move ignore's data one level up
+ return 1
+ elseif di.content then
+ return 1
+ else
+ local dd = di.data
+ if #dd > 0 and checked(dd) > 0 then
+ return 1
+ else
+ return 0
+ end
+ end
+ else
+ local m = 0
+ for i=1,n do
+ local di = d[i]
+ local tg = di.tg
+ if tg == "ignore" then
+ -- skip
+ elseif di.content then
+ m = m + 1
+ d[m] = di
+ else
+ local dd = di.data
+ if #dd > 0 and checked(dd) > 0 then
+ m = m + 1
+ d[m] = di
+ end
+ end
+ end
+ if m < n then
+ for i=n,m+1,-1 do
+ d[i] = nil
+ end
+ end
+ return m
+ end
+ end
+
+ function checks.mrow(di)
+ -- local d = di.data
+ -- if d then
+ -- checked(d)
+ -- end
+ end
+
+ -- we can move more checks here
+
+ local function flatten(di)
+ local r = di.__p__
+ while r do
+ local d = r.data
+ local n = #d
+ if d and n > 1 then
+ n = checked(d)
+ end
+ local tg = r.tg
+ if n == 1 and (tg == "mtext" or tg == "mrow") then
+ r.skip = "comment" -- weird error
+ r = r.__p__
+ else
+ break
+ end
+ end
+ end
+
+ function checks.mtable(di)
+ flatten(di)
+ local d = di.data
+ for i=1,#d do
+ local d = d[i]
+ if d.tg == "mtr" then
+ local d = d.data
+ for i=1,#d do
+ local d = d[i]
+ if d.tg == "mtd" then
+ -- okay
+ elseif d.content then
+ d.content = ""
+ else
+ d.skip = "comment" -- weird error
+ end
+ end
+ elseif d.content then
+ d.content = ""
+ else
+ d.skip = "comment" -- weird error
+ end
+ end
+ end
+
+ do
+
+ local a, z, A, Z = 0x61, 0x7A, 0x41, 0x5A
+
+ function extras.mi(di,element,n,fulltag) -- check with content
+ local str = di.data[1].content
+ if str and sub(str,1,1) ~= "&" then -- hack but good enough (maybe gsub op eerste)
+ for v in utfvalues(str) do
+ if (v >= a and v <= z) or (v >= A and v <= Z) then
+ local a = di.attributes
+ if a then
+ a.mathvariant = "normal"
+ else
+ di.attributes = { mathvariant = "normal" }
+ end
+ end
+ end
+ end
+ end
+
+ end
+
+ function extras.msub(di,element,n,fulltag)
+ -- m$^2$
+ local data = di.data
+ if #data == 1 then
+ local d = data[1]
+ data[2] = d
+ d.__i__ = 2
+ data[1] = dummy_nucleus
+ end
+ end
+
+ extras.msup = extras.msub
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-ref.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-ref.lmt
new file mode 100644
index 00000000000..25682f8edfa
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-ref.lmt
@@ -0,0 +1,261 @@
+if not modules then modules = { } end modules ['back-exp-imp-ref'] = {
+ version = 1.001,
+ comment = "companion to back-exp.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- quite some code deals with exporting references --
+
+-- links:
+--
+-- url :
+-- file :
+-- internal : automatic location
+-- location : named reference
+
+-- references:
+--
+-- implicit : automatic reference
+-- explicit : named reference
+
+local tonumber = tonumber
+local lpegmatch = lpeg.match
+local insert = table.insert
+
+local references = structures.references
+
+local structurestags = structures.tags
+local specifications = structurestags.specifications
+local locatedtag = structurestags.locatedtag
+
+local backend = structurestags.backend
+
+local setattribute = backend.setattribute
+local extras = backend.extras
+local fixes = backend.fixes
+local referencehash = backend.referencehash
+local destinationhash = backend.destinationhash
+
+local implement = interfaces.implement
+
+local evaluators = { }
+local specials = { }
+local explicits = { }
+
+evaluators.inner = function(di,var)
+ local inner = var.inner
+ if inner then
+ setattribute(di,"location",inner,true)
+ end
+end
+
+evaluators.outer = function(di,var)
+ local file, url = references.checkedfileorurl(var.outer,var.outer)
+ if url then
+ setattribute(di,"url",url,true)
+ elseif file then
+ setattribute(di,"file",file,true)
+ end
+end
+
+evaluators["outer with inner"] = function(di,var)
+ local file = references.checkedfile(var.f)
+ if file then
+ setattribute(di,"file",file,true)
+ end
+ local inner = var.inner
+ if inner then
+ setattribute(di,"inner",inner,true)
+ end
+end
+
+evaluators.special = function(di,var)
+ local handler = specials[var.special]
+ if handler then
+ handler(di,var)
+ end
+end
+
+do
+
+ evaluators["special outer with operation"] = evaluators.special
+ evaluators["special operation"] = evaluators.special
+ evaluators["special operation with arguments"] = evaluators.special
+
+ function specials.url(di,var)
+ local url = references.checkedurl(var.operation)
+ if url and url ~= "" then
+ setattribute(di,"url",url,true)
+ end
+ end
+
+ function specials.file(di,var)
+ local file = references.checkedfile(var.operation)
+ if file and file ~= "" then
+ setattribute(di,"file",file,true)
+ end
+ end
+
+ function specials.fileorurl(di,var)
+ local file, url = references.checkedfileorurl(var.operation,var.operation)
+ if url and url ~= "" then
+ setattribute(di,"url",url,true)
+ elseif file and file ~= "" then
+ setattribute(di,"file",file,true)
+ end
+ end
+
+ function specials.internal(di,var)
+ local internal = references.checkedurl(var.operation)
+ if internal then
+ setattribute(di,"location",internal)
+ end
+ end
+
+ local function adddestination(di,references) -- todo: specials -> exporters and then concat
+ if references then
+ local reference = references.reference
+ if reference and reference ~= "" then
+ local prefix = references.prefix
+ if prefix and prefix ~= "" then
+ setattribute(di,"prefix",prefix,true)
+ end
+ setattribute(di,"destination",reference,true)
+ for i=1,#references do
+ local r = references[i]
+ local e = evaluators[r.kind]
+ if e then
+ e(di,r)
+ end
+ end
+ end
+ end
+ end
+
+ function extras.addimplicit(di,references)
+ if references then
+ local internal = references.internal
+ if internal then
+ setattribute(di,"implicit",internal)
+ end
+ end
+ end
+
+ function extras.addinternal(di,references)
+ if references then
+ local internal = references.internal
+ if internal then
+ setattribute(di,"internal",internal)
+ end
+ end
+ end
+
+ local p_firstpart = lpeg.Cs((1-lpeg.P(","))^0)
+
+ local function addreference(di,references)
+ if references then
+ local reference = references.reference
+ if reference and reference ~= "" then
+ local prefix = references.prefix
+ if prefix and prefix ~= "" then
+ setattribute(di,"prefix",prefix)
+ end
+ setattribute(di,"reference",reference,true)
+ setattribute(di,"explicit",lpegmatch(p_firstpart,reference),true)
+ end
+ local internal = references.internal
+ if internal and internal ~= "" then
+ setattribute(di,"implicit",internal)
+ end
+ end
+ end
+
+ local function link(di,element,n,fulltag)
+ -- for instance in lists a link has nested elements and no own text
+ local reference = referencehash[fulltag]
+ if reference then
+ adddestination(di,structures.references.get(reference))
+ return true
+ else
+ local data = di.data
+ if data then
+ for i=1,#data do
+ local di = data[i]
+ if di then
+ local fulltag = di.fulltag
+ if fulltag and link(di,element,n,fulltag) then
+ return true
+ end
+ end
+ end
+ end
+ end
+ end
+
+ local function reference(di,element,n,fulltag)
+ local destination = destinationhash[fulltag]
+ if destination then
+ local d = structures.references.internals[destination]
+ if d then
+ addreference(di,d.references)
+ return true
+ else
+ return false
+ end
+ else
+ local data = di.data
+ if data then
+ for i=1,#data do
+ local di = data[i]
+ if di then
+ local fulltag = di.fulltag
+ if fulltag and reference(di,element,n,fulltag) then
+ return true
+ end
+ end
+ end
+ end
+ end
+ end
+
+ extras.adddestination = adddestination
+ extras.addreference = addreference
+
+ extras.link = link
+ extras.reference = reference
+
+end
+
+do
+
+ function fixes.linenumber(di,data,i)
+ local ni = data[i+1]
+ if ni then
+ if ni.data then
+ while true do
+ local d = ni.data[1]
+ if d then
+ local e = d.element
+ if e then
+ if e == "line" or e == "verbatimline" then
+ insert(d.data,1,di)
+ data[i] = false
+ return
+ else
+ ni = d
+ end
+ else
+ return
+ end
+ else
+ return
+ end
+ end
+ end
+ end
+ end
+
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-tag.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-tag.lmt
new file mode 100644
index 00000000000..73b7b5b47e6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-exp-imp-tag.lmt
@@ -0,0 +1,846 @@
+if not modules then modules = { } end modules ['back-exp-imp-tag'] = {
+ version = 1.001,
+ comment = "companion to back-exp.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Because we run into the 200 locals limit we now split the file into smaller
+-- parts.
+
+local tonumber = tonumber
+local todimen = number.todimen
+local sortedhash, setmetatableindex, concat, insert = table.sortedhash, table.setmetatableindex, table.concat, table.insert
+local settings_to_hash = utilities.parsers.settings_to_hash
+local lpegmatch = lpeg.match
+local formatters = string.formatters
+
+local references = structures.references
+local structurestags = structures.tags
+local taglist = structurestags.taglist
+local specifications = structurestags.specifications
+local properties = structurestags.properties
+local locatedtag = structurestags.locatedtag
+
+local backend = structurestags.backend
+
+local setattribute = backend.setattribute
+local extras = backend.extras
+local checks = backend.checks
+local fixes = backend.fixes
+local listdata = backend.listdata
+local finalizers = backend.finalizers
+local usedstyles = backend.usedstyles -- for now
+local usedimages = backend.usedimages -- for now
+local referencehash = backend.referencehash
+local destinationhash = backend.destinationhash
+
+local implement = interfaces.implement
+
+do
+
+ local itemgroups = { }
+
+ local function setitemgroup(packed,level,symbol)
+ itemgroups[locatedtag("itemgroup")] = {
+ packed = packed,
+ symbol = symbol,
+ level = level,
+ }
+ end
+
+ local function setitem(kind)
+ itemgroups[locatedtag("item")] = {
+ kind = kind,
+ }
+ end
+
+ function extras.itemgroup(di,element,n,fulltag)
+ local hash = itemgroups[fulltag]
+ if hash then
+ setattribute(di,"packed",hash.packed and "yes" or nil)
+ setattribute(di,"symbol",hash.symbol)
+ setattribute(di,"level",hash.level)
+ end
+ end
+
+ function extras.item(di,element,n,fulltag)
+ local hash = itemgroups[fulltag]
+ if hash then
+ local kind = hash.kind
+ if kind and kind ~= "" then
+ setattribute(di,"kind",kind)
+ end
+ end
+ end
+
+ implement {
+ name = "settagitemgroup",
+ actions = setitemgroup,
+ arguments = { "boolean", "integer", "string" }
+ }
+
+ implement {
+ name = "settagitem",
+ actions = setitem,
+ arguments = "string"
+ }
+
+ structurestags.setitemgroup = setitemgroup
+ structurestags.setitem = setitem
+
+end
+
+do
+
+ local registered = structures.sections.registered
+
+ local function resolve(di,element,n,fulltag)
+ local data = listdata[fulltag]
+ if data then
+ extras.addreference(di,data.references)
+ return true
+ else
+ local data = di.data
+ if data then
+ for i=1,#data do
+ local di = data[i]
+ if di then
+ local ft = di.fulltag
+ if ft and resolve(di,element,n,ft) then
+ return true
+ end
+ end
+ end
+ end
+ end
+ end
+
+ function extras.section(di,element,n,fulltag)
+ local r = registered[specifications[fulltag].detail]
+ if r then
+ setattribute(di,"level",r.level)
+ end
+ resolve(di,element,n,fulltag)
+ end
+
+ local floats = { }
+
+ local function setfloat(options,method)
+ floats[locatedtag("float")] = {
+ options = options,
+ method = method,
+ }
+ end
+
+ function extras.float(di,element,n,fulltag)
+ local hash = floats[fulltag]
+ if hash then
+ local method = hash.method
+ if not method or method == "" then
+ method = "here"
+ end
+ setattribute(di,"method",method)
+ local options = hash.options
+ if options and options ~= "" then
+ options = settings_to_hash(options)
+ options[method] = nil
+ options = concat(sortedkeys(options),",")
+ if #options > 0 then
+ setattribute(di,"options",options)
+ end
+ end
+ end
+ resolve(di,element,n,fulltag)
+ end
+
+ implement {
+ name = "settagfloat",
+ actions = setfloat,
+ arguments = "2 strings",
+ }
+
+ structurestags.setfloat = setfloat
+
+end
+
+do
+
+ local registered = { }
+
+ local function setformulacontent(n)
+ registered[locatedtag("formulacontent")] = {
+ n = n,
+ }
+ end
+
+ function extras.formulacontent(di,element,n,fulltag)
+ local r = registered[fulltag]
+ if r then
+ setattribute(di,"n",r.n)
+ end
+ end
+
+ implement {
+ name = "settagformulacontent",
+ actions = setformulacontent,
+ arguments = "integer",
+ }
+
+ structurestags.setformulacontent = setformulacontent
+
+end
+
+do
+
+ local symbols = { }
+
+ local function settagdelimitedsymbol(symbol)
+ symbols[locatedtag("delimitedsymbol")] = {
+ symbol = symbol,
+ }
+ end
+
+ function extras.delimitedsymbol(di,element,n,fulltag)
+ local hash = symbols[fulltag]
+ if hash then
+ setattribute(di,"symbol",hash.symbol or nil)
+ end
+ end
+
+ implement {
+ name = "settagdelimitedsymbol",
+ actions = settagdelimitedsymbol,
+ arguments = "string"
+ }
+
+ structurestags.settagdelimitedsymbol = settagdelimitedsymbol
+
+end
+
+
+do
+
+ local symbols = { }
+
+ local function settagsubsentencesymbol(symbol)
+ symbols[locatedtag("subsentencesymbol")] = {
+ symbol = symbol,
+ }
+ end
+
+ function extras.subsentencesymbol(di,element,n,fulltag)
+ local hash = symbols[fulltag]
+ if hash then
+ setattribute(di,"symbol",hash.symbol or nil)
+ end
+ end
+
+ implement {
+ name = "settagsubsentencesymbol",
+ actions = settagsubsentencesymbol,
+ arguments = "string"
+ }
+
+ structurestags.settagsubsentencesymbol = settagsubsentencesymbol
+
+end
+
+do
+
+ local synonyms = { }
+ local sortings = { }
+
+ local function setsynonym(tag)
+ synonyms[locatedtag("synonym")] = tag
+ end
+
+ function extras.synonym(di,element,n,fulltag)
+ local tag = synonyms[fulltag]
+ if tag then
+ setattribute(di,"tag",tag)
+ end
+ end
+
+ local function setsorting(tag)
+ sortings[locatedtag("sorting")] = tag
+ end
+
+ function extras.sorting(di,element,n,fulltag)
+ local tag = sortings[fulltag]
+ if tag then
+ setattribute(di,"tag",tag)
+ end
+ end
+
+ implement {
+ name = "settagsynonym",
+ actions = setsynonym,
+ arguments = "string"
+ }
+
+ implement {
+ name = "settagsorting",
+ actions = setsorting,
+ arguments = "string"
+ }
+
+ structurestags.setsynonym = setsynonym
+ structurestags.setsorting = setsorting
+
+end
+
+do
+
+ local descriptions = { }
+ local symbols = { }
+ local linked = { }
+
+ -- we could move the notation itself to the first reference (can be an option)
+
+ local function setnotation(tag,n) -- needs checking (is tag needed)
+ -- we can also use the internals hash or list
+ local nd = structures.notes.get(tag,n)
+ if nd then
+ local references = nd.references
+ descriptions[references and references.internal] = locatedtag("description")
+ end
+ end
+
+ local function setnotationsymbol(tag,n) -- needs checking (is tag needed)
+ local nd = structures.notes.get(tag,n) -- todo: use listdata instead
+ if nd then
+ local references = nd.references
+ symbols[references and references.internal] = locatedtag("descriptionsymbol")
+ end
+ end
+
+ function finalizers.descriptions(tree)
+ local n = 0
+ for id, tag in sortedhash(descriptions) do
+ local sym = symbols[id]
+ if sym then
+ n = n + 1
+ linked[tag] = n
+ linked[sym] = n
+ end
+ end
+ end
+
+ function extras.description(di,element,n,fulltag)
+ local id = linked[fulltag]
+ if id then
+ setattribute(di,"insert",id)
+ end
+ end
+
+ function extras.descriptionsymbol(di,element,n,fulltag)
+ local id = linked[fulltag]
+ if id then
+ setattribute(di,"insert",id)
+ end
+ end
+
+ implement {
+ name = "settagnotation",
+ actions = setnotation,
+ arguments = { "string", "integer" }
+ }
+
+ implement {
+ name = "settagnotationsymbol",
+ actions = setnotationsymbol,
+ arguments = { "string", "integer" }
+ }
+
+ structurestags.setnotation = setnotation
+ structurestags.setnotationsymbol = setnotationsymbol
+
+end
+
+
+do
+
+ local strippedtag = structurestags.strip -- we assume global styles
+
+ local highlight = { }
+ local construct = { }
+
+ usedstyles.highlight = highlight
+ usedstyles.construct = construct
+
+ local function sethighlight(name,style,color,mode)
+ if not highlight[name] then
+ highlight[name] = {
+ style = style,
+ color = color,
+ mode = mode == 1 and "display" or nil,
+ }
+ end
+ end
+
+ local function setconstruct(name,style,color,mode)
+ if not construct[name] then
+ construct[name] = {
+ style = style,
+ color = color,
+ mode = mode == 1 and "display" or nil,
+ }
+ end
+ end
+
+ implement {
+ name = "settagconstruct",
+ actions = setconstruct,
+ arguments = { "string", "string", "integer", "integer" }
+ }
+
+ implement {
+ name = "settaghighlight",
+ actions = sethighlight,
+ arguments = { "string", "string", "integer", "integer" }
+ }
+
+ structurestags.sethighlight = sethighlight
+ structurestags.setconstruct = setconstruct
+
+end
+
+do
+
+ local f_id = formatters["%s-%s"]
+ local image = { }
+ usedimages.image = image
+
+ structurestags.usewithcare.images = image
+
+ local function setfigure(name,used,page,width,height,label)
+ local fulltag = locatedtag("image")
+ local spec = specifications[fulltag]
+ if spec then
+ local page = tonumber(page)
+ image[fulltag] = {
+ id = f_id(spec.tagname,spec.tagindex),
+ name = name,
+ used = used,
+ page = page and page > 1 and page or nil,
+ width = todimen(width, "cm","%0.3F%s"),
+ height = todimen(height,"cm","%0.3F%s"),
+ label = label,
+ }
+ else
+ -- we ignore images in layers in the background / pagebody
+ end
+ end
+
+ function extras.image(di,element,n,fulltag)
+ local data = image[fulltag]
+ if data then
+ setattribute(di,"name",data.name)
+ setattribute(di,"page",data.page)
+ setattribute(di,"id",data.id)
+ setattribute(di,"width",data.width)
+ setattribute(di,"height",data.height)
+ setattribute(di,"label",data.height)
+ end
+ end
+
+ implement {
+ name = "settagfigure",
+ actions = setfigure,
+ arguments = { "string", "string", "string", "dimen", "dimen", "string" }
+ }
+
+ structurestags.setfigure = setfigure
+
+end
+
+do
+
+ local combinations = { }
+
+ local function setcombination(nx,ny)
+ combinations[locatedtag("combination")] = {
+ nx = nx,
+ ny = ny,
+ }
+ end
+
+ function extras.combination(di,element,n,fulltag)
+ local data = combinations[fulltag]
+ if data then
+ setattribute(di,"nx",data.nx)
+ setattribute(di,"ny",data.ny)
+ end
+ end
+
+ implement {
+ name = "settagcombination",
+ actions = setcombination,
+ arguments = { "integer", "integer" }
+ }
+
+ structurestags.setcombination = setcombination
+
+end
+
+do
+
+ local function hascontent(data)
+ for i=1,#data do
+ local di = data[i]
+ if not di or di.tg == "ignore" then
+ --
+ else
+ local content = di.content
+ if content == " " then
+ --
+ elseif content then
+ return true
+ else
+ local d = di.data
+ if d and #d > 0 and hascontent(d) then
+ return true
+ end
+ end
+ end
+ end
+ end
+
+ local tabledata = { }
+
+ local function settablecell(rows,columns,align)
+ if align > 0 or rows > 1 or columns > 1 then -- or kind > 0
+ tabledata[locatedtag("tablecell")] = {
+ rows = rows,
+ columns = columns,
+ align = align,
+ }
+ end
+ end
+
+ local function gettablecell(fulltag)
+ return tabledata[fulltag]
+ end
+
+ function extras.tablecell(di,element,n,fulltag)
+ local hash = tabledata[fulltag]
+ if hash then
+ local columns = hash.columns
+ if columns and columns > 1 then
+ setattribute(di,"columns",columns)
+ end
+ local rows = hash.rows
+ if rows and rows > 1 then
+ setattribute(di,"rows",rows)
+ end
+ local align = hash.align
+ if not align or align == 0 then
+ -- normal
+ elseif align == 1 then -- use numbertoalign here
+ setattribute(di,"align","flushright")
+ elseif align == 2 then
+ setattribute(di,"align","middle")
+ elseif align == 3 then
+ setattribute(di,"align","flushleft")
+ end
+ end
+ end
+
+ local tabulatedata = { }
+
+ local function settabulatecell(align,kind)
+ if align > 0 or kind > 0 then
+ tabulatedata[locatedtag("tabulatecell")] = {
+ align = align,
+ kind = kind, -- 1 = bold head
+ }
+ end
+ end
+
+ local function gettabulatecell(fulltag)
+ return tabulatedata[fulltag]
+ end
+
+ function extras.tabulate(di,element,n,fulltag)
+ local data = di.data
+ for i=1,#data do
+ local di = data[i]
+ if di.tg == "tabulaterow" and not hascontent(di.data) then
+ di.element = "" -- or simply remove
+ end
+ end
+ end
+
+ function extras.tabulatecell(di,element,n,fulltag)
+ local hash = tabulatedata[fulltag]
+ if hash then
+ local align = hash.align
+ if not align or align == 0 then
+ -- normal
+ elseif align == 1 then
+ setattribute(di,"align","flushleft")
+ elseif align == 2 then
+ setattribute(di,"align","flushright")
+ elseif align == 3 then
+ setattribute(di,"align","middle")
+ end
+ local kind = hash.kind
+ if kind == 1 then
+ setattribute(di,"kind","strong")
+ elseif kind == 2 then
+ setattribute(di,"kind","equals")
+ end
+ end
+ end
+
+ implement {
+ name = "settagtablecell",
+ actions = settablecell,
+ arguments = { "integer", "integer", "integer" }
+ }
+
+ implement {
+ name = "settagtabulatecell",
+ actions = settabulatecell,
+ arguments = { "integer", "integer" },
+ }
+
+ structurestags.settablecell = settablecell
+ structurestags.gettablecell = gettablecell
+ structurestags.settabulatecell = settabulatecell
+ structurestags.gettabulatecell = gettabulatecell
+
+end
+
+do
+
+ -- todo: internal is already hashed
+
+ local p_stripper = lpeg.patterns.stripper
+
+ local function setregister(tag,n) -- check if tag is needed
+ local data = structures.registers.get(tag,n)
+ if data then
+ referencehash[locatedtag("registerlocation")] = data
+ end
+ end
+
+ function extras.registerlocation(di,element,n,fulltag)
+ local data = referencehash[fulltag]
+ if type(data) == "table" then
+ extras.addinternal(di,data.references)
+ return true
+ else
+ -- needs checking, probably bookmarks
+ end
+ end
+
+ function extras.registerpages(di,element,n,fulltag) -- ignorebreaks
+ local data = di.data
+ for i=1,#data do
+ local d = data[i]
+ if d.content == " " then
+ d.content = ""
+ end
+ end
+ end
+
+ function extras.registerseparator(di,element,n,fulltag) -- ignorespaces
+ local data = di.data
+ for i=1,#data do
+ local d = data[i]
+ local c = d.content
+ if type(c) == "string" then
+ d.content = lpegmatch(p_stripper,c)
+ end
+ end
+ end
+
+ implement {
+ name = "settagregister",
+ actions = setregister,
+ arguments = { "string", "integer" }
+ }
+
+ structurestags.setregister = setregister
+
+end
+
+do
+
+ -- todo: internal is already hashed
+
+ local function setlist(n)
+ local data = structures.lists.getresult(n)
+ if data then
+ referencehash[locatedtag("listitem")] = data
+ end
+ end
+
+ function extras.listitem(di,element,n,fulltag)
+ local data = referencehash[fulltag]
+ if data then
+ extras.addinternal(di,data.references)
+ return true
+ end
+ end
+
+ implement {
+ name = "settaglist",
+ actions = setlist,
+ arguments = "integer"
+ }
+
+ structurestags.setlist = setlist
+
+end
+
+do
+
+ local usedpublications = { }
+ local tagsindatasets = setmetatableindex("table")
+ local serialize = false
+
+ local function setpublication(dataset,tag,rendering)
+ usedpublications[locatedtag("publication")] = {
+ dataset = dataset,
+ tag = tag,
+ rendering = rendering
+ }
+ tagsindatasets[dataset][tag] = true
+ if not serialize then
+ structures.tags.registerextradata("btx",function()
+ local t = { ""}
+ for dataset, used in sortedhash(tagsindatasets) do
+ t[#t+1] = publications.converttoxml(dataset,true,false,true,false,true,true)
+ end
+ t[#t+1] = ""
+ return concat(t,"\n")
+ end)
+ end
+ end
+
+ function extras.publication(di,element,n,fulltag)
+ local hash = usedpublications[fulltag]
+ if hash then
+ setattribute(di,"dataset",hash.dataset)
+ setattribute(di,"tag",hash.tag)
+ end
+ end
+
+ implement {
+ name = "settagpublication",
+ actions = setpublication,
+ arguments = "2 strings"
+ }
+
+ structurestags.setpublication = setpublication
+
+end
+
+do
+
+ local usedparagraphs = { }
+
+ local function setparagraph(align)
+ if align ~= "" then
+ usedparagraphs[locatedtag("paragraph")] = {
+ align = align,
+ }
+ end
+ end
+
+ function extras.paragraph(di,element,n,fulltag)
+ local hash = usedparagraphs[fulltag]
+ if hash then
+ setattribute(di,"align",hash.align)
+ end
+ end
+
+ implement {
+ name = "settagparagraph",
+ actions = setparagraph,
+ arguments = "string"
+ }
+
+ structurestags.setparagraph = setparagraph
+
+end
+
+do
+
+ local marginanchors = { }
+ local margincontent = { }
+
+ function checks.margintext(di)
+ local i = marginanchors[di.fulltag]
+ margincontent[i] = di
+ end
+
+ function checks.marginanchor(di)
+ local i = marginanchors[di.fulltag]
+ local d = margincontent[i]
+ --
+ di.attribute = d.attribute
+ di.data = d.data
+ di.detail = d.detail
+ di.element = d.element
+ di.fulltag = d.fulltag
+ di.nature = d.nature
+ di.samepar = true
+ di.tg = d.tg
+ --
+ d.skip = "ignore"
+ end
+
+ implement {
+ name = "settagmargintext",
+ arguments = "integer",
+ actions = function(n)
+ marginanchors[locatedtag("margintext")] = n
+ end
+ }
+
+ implement {
+ name = "settagmarginanchor",
+ arguments = "integer",
+ actions = function(n)
+ marginanchors[locatedtag("marginanchor")] = n
+ end
+ }
+
+end
+
+do
+
+ function fixes.linenumber(di,data,i)
+ local ni = data[i+1]
+ if ni then
+ if ni.data then
+ while true do
+ local d = ni.data[1]
+ if d then
+ local e = d.element
+ if e then
+ if e == "line" or e == "verbatimline" then
+ insert(d.data,1,di)
+ data[i] = false
+ return
+ else
+ ni = d
+ end
+ else
+ return
+ end
+ else
+ return
+ end
+ end
+ end
+ end
+ end
+
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-exp.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-exp.lmt
new file mode 100644
index 00000000000..1375d2655c2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-exp.lmt
@@ -0,0 +1,2719 @@
+if not modules then modules = { } end modules ['back-exp'] = {
+ version = 1.001,
+ comment = "companion to back-exp.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Todo: share properties more with tagged pdf (or thge reverse)
+
+-- Because we run into the 200 local limit we quite some do .. end wrappers .. not always
+-- that nice but it has to be.
+
+-- Experiments demonstrated that mapping to
and classes is messy because we have to
+-- package attributes (some 30) into one set of (space seperatated but prefixed classes)
+-- which only makes things worse .. so if you want something else, use xslt to get there.
+
+-- language -> only mainlanguage, local languages should happen through start/stoplanguage
+-- tocs/registers -> maybe add a stripper (i.e. just don't flush entries in final tree)
+-- footnotes -> css 3
+-- bodyfont -> in styles.css
+
+-- Because we need to look ahead we now always build a tree (this was optional in
+-- the beginning). The extra overhead in the frontend is neglectable.
+--
+-- We can optimize the code ... currently the overhead is some 10% for xml + html so
+-- there is no hurry.
+
+-- todo: move critital formatters out of functions
+-- todo: delay loading (apart from basic tag stuff)
+
+-- problem : too many local variables
+
+-- check setting __i__
+
+local next, type, tonumber = next, type, tonumber
+local sub, gsub, match = string.sub, string.gsub, string.match
+local validstring = string.valid
+local lpegmatch = lpeg.match
+local utfchar, utfvalues, utflen = utf.char, utf.values, utf.len
+local concat, merge, sort, setmetatableindex = table.concat, table.merge, table.sort, table.setmetatableindex
+local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys
+local formatters = string.formatters
+local todimen = number.todimen
+local replacetemplate = utilities.templates.replace
+local settings_to_array = utilities.parsers.settings_to_array
+
+local addsuffix, joinfile, nameonly, basename, filesuffix = file.addsuffix, file.join, file.nameonly, file.basename, file.suffix
+
+local trace_export = false trackers.register ("export.trace", function(v) trace_export = v end)
+local trace_spacing = false trackers.register ("export.trace.spacing", function(v) trace_spacing = v end)
+local trace_details = false trackers.register ("export.trace.details", function(v) trace_details = v end)
+
+local less_state = false directives.register("export.lessstate", function(v) less_state = v end)
+local show_comment = true directives.register("export.comment", function(v) show_comment = v end)
+
+-- maybe we will also support these:
+--
+-- local css_hyphens = false directives.register("export.css.hyphens", function(v) css_hyphens = v end)
+-- local css_textalign = false directives.register("export.css.textalign", function(v) css_textalign = v end)
+-- local css_bodyfontsize = false directives.register("export.css.bodyfontsize", function(v) css_bodyfontsize = v end)
+-- local css_textwidth = false directives.register("export.css.textwidth", function(v) css_textwidth = v end)
+
+local report_export = logs.reporter("backend","export")
+
+local nodes = nodes
+local attributes = attributes
+
+local variables = interfaces.variables
+local v_yes = variables.yes
+local v_no = variables.no
+local v_xml = variables.xml
+local v_hidden = variables.hidden
+
+local implement = interfaces.implement
+
+local included = backends.included
+
+local tasks = nodes.tasks
+local fontchar = fonts.hashes.characters
+local fontquads = fonts.hashes.quads
+local languagenames = languages.numbers
+
+local texgetcount = tex.getcount
+
+local references = structures.references
+local structurestags = structures.tags
+local taglist = structurestags.taglist
+local specifications = structurestags.specifications
+local properties = structurestags.properties
+local locatedtag = structurestags.locatedtag
+
+structurestags.usewithcare = { }
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
+local characterdata = characters.data
+local overloads = fonts.mappings.overloads
+
+-- todo: more locals (and optimize)
+
+local exportversion = "0.35"
+local mathmlns = "http://www.w3.org/1998/Math/MathML"
+local contextns = "http://www.contextgarden.net/context/export" -- whatever suits
+local cssnamespaceurl = "@namespace context url('%namespace%') ;"
+local cssnamespace = "context|"
+----- cssnamespacenop = "/* no namespace */"
+
+local usecssnamespace = false
+
+local nofcurrentcontent = 0 -- so we don't free (less garbage collection)
+local currentcontent = { }
+local currentnesting = nil
+local currentattribute = nil
+local last = nil
+local currentparagraph = nil
+
+local noftextblocks = 0
+
+----- hyphencode = 0xAD
+local hyphen = utfchar(0xAD) -- todo: also emdash etc
+local tagsplitter = structurestags.patterns.splitter
+----- colonsplitter = lpeg.splitat(":")
+----- dashsplitter = lpeg.splitat("-")
+local threshold = 65536
+local indexing = false
+local keephyphens = false
+local exportproperties = false
+
+local finetuning = { }
+
+local treestack = { }
+local nesting = { }
+local currentdepth = 0
+
+local wrapups = { }
+
+local tree = { data = { }, fulltag == "root" } -- root
+local treeroot = tree
+local treehash = { }
+local extras = { }
+local checks = { }
+local fixes = { }
+local finalizers = { }
+local nofbreaks = 0
+local used = { }
+local exporting = false
+local restart = false
+local specialspaces = { [0x20] = " " } -- for conversion
+local somespace = { [0x20] = true, [" "] = true } -- for testing
+local entities = { ["&"] = "&", [">"] = ">", ["<"] = "<" }
+local attribentities = { ["&"] = "&", [">"] = ">", ["<"] = "<", ['"'] = "quot;" }
+
+local p_entity = lpeg.replacer(entities) -- was: entityremapper = utf.remapper(entities)
+local p_attribute = lpeg.replacer(attribentities)
+local p_escaped = lpeg.patterns.xml.escaped
+
+local f_tagid = formatters["%s-%04i"]
+
+-- local alignmapping = {
+-- flushright = "right",
+-- middle = "center",
+-- flushleft = "left",
+-- }
+
+local defaultnature = "mixed" -- "inline"
+
+setmetatableindex(used, function(t,k)
+ if k then
+ local v = { }
+ t[k] = v
+ return v
+ end
+end)
+
+local f_entity = formatters["%X;"]
+local f_attribute = formatters[" %s=%q"]
+local f_property = formatters[" %s%s=%q"]
+
+setmetatableindex(specialspaces, function(t,k)
+ local v = utfchar(k)
+ t[k] = v
+ entities[v] = f_entity(k)
+ somespace[k] = true
+ somespace[v] = true
+ return v
+end)
+
+
+local namespaced = {
+ -- filled on
+}
+
+local namespaces = {
+ msubsup = "m",
+ msub = "m",
+ msup = "m",
+ mn = "m",
+ mi = "m",
+ ms = "m",
+ mo = "m",
+ mtext = "m",
+ mrow = "m",
+ mfrac = "m",
+ mroot = "m",
+ msqrt = "m",
+ munderover = "m",
+ munder = "m",
+ mover = "m",
+ merror = "m",
+ math = "m",
+ mrow = "m",
+ mtable = "m",
+ mtr = "m",
+ mtd = "m",
+ mfenced = "m",
+ maction = "m",
+ mspace = "m",
+ -- only when testing
+ mstacker = "m",
+ mstackertop = "m",
+ mstackermid = "m",
+ mstackerbot = "m",
+}
+
+setmetatableindex(namespaced, function(t,k)
+ if k then
+ local namespace = namespaces[k]
+ local v = namespace and namespace .. ":" .. k or k
+ t[k] = v
+ return v
+ end
+end)
+
+local function attribute(key,value)
+ if value and value ~= "" then
+ return f_attribute(key,lpegmatch(p_attribute,value))
+ else
+ return ""
+ end
+end
+
+local function setattribute(di,key,value,escaped)
+ if value and value ~= "" then
+ local a = di.attributes
+ if escaped then
+ value = lpegmatch(p_escaped,value)
+ end
+ if not a then
+ di.attributes = { [key] = value }
+ else
+ a[key] = value
+ end
+ end
+end
+
+local listdata = { } -- this has to be done otherwise: each element can just point back to ...
+
+function wrapups.hashlistdata()
+ local c = structures.lists.collected
+ for i=1,#c do
+ local ci = c[i]
+ local tag = ci.references.tag
+ if tag then
+ local m = ci.metadata
+ local t = m.kind .. ">" .. tag -- todo: use internal (see strc-lst.lua where it's set)
+ listdata[t] = ci
+ end
+ end
+end
+
+function structurestags.setattributehash(attr,key,value) -- public hash
+ local specification = taglist[attr]
+ if specification then
+ specification[key] = value
+ else
+ -- some kind of error
+ end
+end
+
+local usedstyles = { }
+local usedimages = { }
+local referencehash = { } -- move ?
+local destinationhash = { } -- move ?
+
+structurestags.backend = {
+ setattribute = setattribute,
+ extras = extras,
+ checks = checks,
+ fixes = fixes,
+ listdata = listdata,
+ finalizers = finalizers,
+ usedstyles = usedstyles,
+ usedimages = usedimages,
+ referencehash = referencehash,
+ destinationhash = destinationhash,
+}
+
+local namespacetemplate = [[
+/* %what% for file %filename% */
+
+%cssnamespaceurl%
+]]
+
+do
+
+ -- experiment: styles and images
+ --
+ -- officially we should convert to bp but we round anyway
+
+ -- /* padding : ; */
+ -- /* text-justify : inter-word ; */
+ -- /* text-align : justify ; */
+
+local documenttemplate = [[
+document,
+%namespace%div.document {
+ font-size : %size% !important ;
+ max-width : %width% !important ;
+ text-align : %align% !important ;
+ hyphens : %hyphens% !important ;
+}]]
+
+local styletemplate = [[
+%element%[detail="%detail%"],
+%namespace%div.%element%.%detail% {
+ display : inline ;
+ font-style : %style% ;
+ font-variant : %variant% ;
+ font-weight : %weight% ;
+ font-family : %family% ;
+ color : %color% ;
+}]]
+
+ local numbertoallign = {
+ [0] = "justify", ["0"] = "justify", [variables.normal ] = "justify",
+ [1] = "right", ["1"] = "right", [variables.flushright] = "right",
+ [2] = "center", ["2"] = "center", [variables.middle ] = "center",
+ [3] = "left", ["3"] = "left", [variables.flushleft ] = "left",
+ }
+
+ function wrapups.allusedstyles(filename)
+ local result = { replacetemplate(namespacetemplate, {
+ what = "styles",
+ filename = filename,
+ namespace = contextns,
+ -- cssnamespaceurl = usecssnamespace and cssnamespaceurl or cssnamespacenop,
+ cssnamespaceurl = cssnamespaceurl,
+ },false,true) }
+ --
+ local bodyfont = finetuning.bodyfont
+ local width = finetuning.width
+ local hyphen = finetuning.hyphen
+ local align = finetuning.align
+ --
+ if type(bodyfont) == "number" then
+ bodyfont = todimen(bodyfont)
+ else
+ bodyfont = "12pt"
+ end
+ if type(width) == "number" then
+ width = todimen(width) or "50em"
+ else
+ width = "50em"
+ end
+ if hyphen == v_yes then
+ hyphen = "manual"
+ else
+ hyphen = "inherited"
+ end
+ if align then
+ align = numbertoallign[align]
+ end
+ if not align then
+ align = hyphen and "justify" or "inherited"
+ end
+ --
+ result[#result+1] = replacetemplate(documenttemplate,{
+ size = bodyfont,
+ width = width,
+ align = align,
+ hyphens = hyphen
+ })
+ --
+ local colorspecification = xml.css.colorspecification
+ local fontspecification = xml.css.fontspecification
+ for element, details in sortedhash(usedstyles) do
+ for detail, data in sortedhash(details) do
+ local s = fontspecification(data.style)
+ local c = colorspecification(data.color)
+ detail = gsub(detail,"[^A-Za-z0-9]+","-")
+ result[#result+1] = replacetemplate(styletemplate,{
+ namespace = usecssnamespace and cssnamespace or "",
+ element = element,
+ detail = detail,
+ style = s.style or "inherit",
+ variant = s.variant or "inherit",
+ weight = s.weight or "inherit",
+ family = s.family or "inherit",
+ color = c or "inherit",
+ display = s.display and "block" or nil,
+ })
+ end
+ end
+ return concat(result,"\n\n")
+ end
+
+end
+
+do
+
+local imagetemplate = [[
+%element%[id="%id%"], %namespace%div.%element%[id="%id%"] {
+ display : block ;
+ background-image : url('%url%') ;
+ background-size : 100%% auto ;
+ background-repeat : no-repeat ;
+ width : %width% ;
+ height : %height% ;
+}]]
+
+ local f_svgname = formatters["%s.svg"]
+ local f_svgpage = formatters["%s-page-%s.svg"]
+ local collected = { }
+
+ local function usedname(name,page)
+ if filesuffix(name) == "pdf" then
+ -- temp hack .. we will have a remapper
+ if page and page > 1 then
+ name = f_svgpage(nameonly(name),page)
+ else
+ name = f_svgname(nameonly(name))
+ end
+ end
+ local scheme = url.hasscheme(name)
+ if not scheme or scheme == "file" then
+ -- or can we just use the name ?
+ return joinfile("../images",basename(url.filename(name)))
+ else
+ return name
+ end
+ end
+
+ function wrapups.allusedimages(filename)
+ local result = { replacetemplate(namespacetemplate, {
+ what = "images",
+ filename = filename,
+ namespace = contextns,
+ -- cssnamespaceurl = usecssnamespace and cssnamespaceurl or "",
+ cssnamespaceurl = cssnamespaceurl,
+ },false,true) }
+ for element, details in sortedhash(usedimages) do
+ for detail, data in sortedhash(details) do
+ local name = data.name
+ local page = tonumber(data.page) or 1
+ local spec = {
+ element = element,
+ id = data.id,
+ name = name,
+ page = page,
+ url = usedname(name,page),
+ width = data.width,
+ height = data.height,
+ used = data.used,
+ namespace = usecssnamespace and cssnamespace or "",
+ }
+ result[#result+1] = replacetemplate(imagetemplate,spec)
+ collected[detail] = spec
+ end
+ end
+ return concat(result,"\n\n")
+ end
+
+ function wrapups.uniqueusedimages() -- todo: combine these two
+ return collected
+ end
+
+end
+
+--
+
+properties.vspace = { export = "break", nature = "display" }
+----------------- = { export = "pagebreak", nature = "display" }
+
+local function makebreaklist(list)
+ nofbreaks = nofbreaks + 1
+ local t = { }
+ local l = list and list.taglist
+ if l then
+ for i=1,#list do
+ t[i] = l[i]
+ end
+ end
+ t[#t+1] = "break>" .. nofbreaks -- maybe no number or 0
+ return { taglist = t }
+end
+
+local breakattributes = {
+ type = "collapse"
+}
+
+local function makebreaknode(attributes) -- maybe no fulltag
+ nofbreaks = nofbreaks + 1
+ return {
+ tg = "break",
+ fulltag = "break>" .. nofbreaks,
+ n = nofbreaks,
+ element = "break",
+ nature = "display",
+ attributes = attributes or nil,
+ -- data = { }, -- not needed
+ -- attribute = 0, -- not needed
+ -- parnumber = 0,
+ }
+end
+
+do
+
+ local fields = { "title", "subtitle", "author", "keywords", "url", "version" }
+
+ local ignoredelements = false
+
+ local function checkdocument(root)
+ local data = root.data
+ if data then
+ for i=1,#data do
+ local di = data[i]
+ local tg = di.tg
+ if tg == "noexport" then
+ local s = specifications[di.fulltag]
+ local u = s and s.userdata
+ if u then
+ local comment = u.comment
+ if comment then
+ di.element = "comment"
+ di.data = { { content = comment } }
+ u.comment = nil
+ else
+ data[i] = false
+ end
+ else
+ data[i] = false
+ end
+ elseif di.content then
+ -- okay
+ elseif tg == "ignore" then
+ di.element = ""
+ checkdocument(di)
+ elseif ignoredelements and ignoredelements[tg] then
+ di.element = ""
+ checkdocument(di)
+ else
+ checkdocument(di) -- new, else no noexport handling
+ end
+ end
+ end
+ end
+
+ function extras.document(di,element,n,fulltag)
+ setattribute(di,"language",languagenames[texgetcount("mainlanguagenumber")])
+ if not less_state then
+ setattribute(di,"file",tex.jobname)
+ if included.date then
+ setattribute(di,"date",os.fulltime())
+ end
+ setattribute(di,"context",environment.version)
+ setattribute(di,"version",exportversion)
+ setattribute(di,"xmlns:m",mathmlns)
+ local identity = interactions.general.getidentity()
+ for i=1,#fields do
+ local key = fields[i]
+ local value = identity[key]
+ if value and value ~= "" then
+ setattribute(di,key,value)
+ end
+ end
+ end
+ checkdocument(di)
+ end
+
+ implement {
+ name = "ignoretagsinexport",
+ arguments = "string",
+ actions = function(list)
+ for tag in string.gmatch(list,"[a-z]+") do
+ if ignoredelements then
+ ignoredelements[tag] = true
+ else
+ ignoredelements = { [tag] = true }
+ end
+ end
+ end,
+ }
+
+end
+
+-- flusher
+
+do
+
+ local f_detail = formatters[' detail="%s"']
+ local f_chain = formatters[' chain="%s"']
+ local f_index = formatters[' n="%s"']
+ local f_spacing = formatters['%s']
+
+ local f_empty_inline = formatters["<%s/>"]
+ local f_empty_mixed = formatters["%w<%s/>\n"]
+ local f_empty_display = formatters["\n%w<%s/>\n"]
+ local f_empty_inline_attr = formatters["<%s%s/>"]
+ local f_empty_mixed_attr = formatters["%w<%s%s/>"]
+ local f_empty_display_attr = formatters["\n%w<%s%s/>\n"]
+
+ local f_begin_inline = formatters["<%s>"]
+ local f_begin_mixed = formatters["%w<%s>"]
+ local f_begin_display = formatters["\n%w<%s>\n"]
+ local f_begin_inline_attr = formatters["<%s%s>"]
+ local f_begin_mixed_attr = formatters["%w<%s%s>"]
+ local f_begin_display_attr = formatters["\n%w<%s%s>\n"]
+
+ local f_end_inline = formatters["%s>"]
+ local f_end_mixed = formatters["%s>\n"]
+ local f_end_display = formatters["%w%s>\n"]
+
+ local f_begin_inline_comment = formatters["<%s>"]
+ local f_begin_mixed_comment = formatters["%w<%s>"]
+ local f_begin_display_comment = formatters["\n%w\n%w<%s>\n"]
+ local f_begin_inline_attr_comment = formatters["<%s%s>"]
+ local f_begin_mixed_attr_comment = formatters["%w<%s%s>"]
+ local f_begin_display_attr_comment = formatters["\n%w\n%w<%s%s>\n"]
+
+ local f_comment_begin_inline = formatters[""]
+ local f_comment_begin_mixed = formatters["%w"]
+ local f_comment_begin_display = formatters["\n%w\n"]
+
+ local f_comment_end_inline = formatters[""]
+ local f_comment_end_mixed = formatters["\n"]
+ local f_comment_end_display = formatters["%w\n"]
+
+ local f_metadata_begin = formatters["\n%w\n"]
+ local f_metadata = formatters["%w%s\n"]
+ local f_metadata_end = formatters["%w\n"]
+
+ local function attributes(a)
+ local r = { }
+ local n = 0
+ for k, v in next, a do
+ n = n + 1
+ r[n] = f_attribute(k,tostring(v)) -- tostring because of %q
+ end
+ sort(r)
+ return concat(r,"")
+ end
+
+ local function properties(a)
+ local r = { }
+ local n = 0
+ for k, v in next, a do
+ n = n + 1
+ r[n] = f_property(exportproperties,k,tostring(v)) -- tostring because of %q
+ end
+ sort(r)
+ return concat(r,"")
+ end
+
+ local depth = 0
+ local inline = 0
+
+ local function emptytag(result,element,nature,di) -- currently only break but at some point
+ local a = di.attributes -- we might add detail etc
+ if a then -- happens seldom
+ if nature == "display" then
+ result[#result+1] = f_empty_display_attr(depth,namespaced[element],attributes(a))
+ elseif nature == "mixed" then
+ result[#result+1] = f_empty_mixed_attr(depth,namespaced[element],attributes(a))
+ else
+ result[#result+1] = f_empty_inline_attr(namespaced[element],attributes(a))
+ end
+ else
+ if nature == "display" then
+ result[#result+1] = f_empty_display(depth,namespaced[element])
+ elseif nature == "mixed" then
+ result[#result+1] = f_empty_mixed(depth,namespaced[element])
+ else
+ result[#result+1] = f_empty_inline(namespaced[element])
+ end
+ end
+ end
+
+ -- local function stripspaces(di)
+ -- local d = di.data
+ -- local n = #d
+ -- local m = 0
+ -- for i=1,n do
+ -- local di = d[i]
+ -- if di.tg then
+ -- m = m + 1
+ -- d[m] = di
+ -- end
+ -- end
+ -- for i=n,m+1,-1 do
+ -- d[i] = nil
+ -- end
+ -- end
+ --
+ -- -- simpler:
+
+ local function stripspaces(di)
+ local d = di.data
+ for i=1,#d do
+ local di = d[i]
+ if not di.tg then
+ di.content = ""
+ end
+ end
+ end
+
+ local function begintag(result,element,nature,di,skip)
+ local index = di.n
+ local fulltag = di.fulltag
+ local specification = specifications[fulltag] or { } -- we can have a dummy
+ local comment = di.comment
+ local detail = specification.detail
+ if skip == "comment" then
+ if show_comment then
+ if nature == "inline" or inline > 0 then
+ result[#result+1] = f_comment_begin_inline(namespaced[element])
+ inline = inline + 1
+ elseif nature == "mixed" then
+ result[#result+1] = f_comment_begin_mixed(depth,namespaced[element])
+ depth = depth + 1
+ inline = 1
+ else
+ result[#result+1] = f_comment_begin_display(depth,namespaced[element])
+ depth = depth + 1
+ end
+ end
+ elseif skip then
+ -- ignore
+ else
+
+ local n = 0
+ local r = { } -- delay this
+ if detail then
+ detail = gsub(detail,"[^A-Za-z0-9]+","-")
+ specification.detail = detail -- we use it later in for the div
+ n = n + 1
+ r[n] = f_detail(detail)
+ end
+ local parents = specification.parents
+ if parents then
+ parents = gsub(parents,"[^A-Za-z0-9 ]+","-")
+ specification.parents = parents -- we use it later in for the div
+ n = n + 1
+ r[n] = f_chain(parents)
+ end
+ if indexing and index then
+ n = n + 1
+ r[n] = f_index(index)
+ end
+ --
+ local extra = extras[element]
+ if extra then
+ extra(di,element,index,fulltag)
+ end
+ --
+ if di.record then
+ stripspaces(di)
+ end
+ --
+ if exportproperties then
+ local p = specification.userdata
+ if not p then
+ -- skip
+ elseif exportproperties == v_yes then
+ n = n + 1
+ r[n] = attributes(p)
+ else
+ n = n + 1
+ r[n] = properties(p)
+ end
+ end
+ local a = di.attributes
+ if a then
+ if trace_spacing then
+ a.p = di.parnumber or 0
+ end
+ n = n + 1
+ r[n] = attributes(a)
+ elseif trace_spacing then
+ n = n + 1
+ r[n] = attributes { p = di.parnumber or 0 }
+ end
+ if n == 0 then
+ if nature == "inline" or inline > 0 then
+ if show_comment and comment then
+ result[#result+1] = f_begin_inline_comment(comment,namespaced[element])
+ else
+ result[#result+1] = f_begin_inline(namespaced[element])
+ end
+ inline = inline + 1
+ elseif nature == "mixed" then
+ if show_comment and comment then
+ result[#result+1] = f_begin_mixed_comment(depth,comment,namespaced[element])
+ else
+ result[#result+1] = f_begin_mixed(depth,namespaced[element])
+ end
+ depth = depth + 1
+ inline = 1
+ else
+ if show_comment and comment then
+ result[#result+1] = f_begin_display_comment(depth,comment,depth,namespaced[element])
+ else
+ result[#result+1] = f_begin_display(depth,namespaced[element])
+ end
+ depth = depth + 1
+ end
+ else
+ r = concat(r,"",1,n)
+ if nature == "inline" or inline > 0 then
+ if show_comment and comment then
+ result[#result+1] = f_begin_inline_attr_comment(comment,namespaced[element],r)
+ else
+ result[#result+1] = f_begin_inline_attr(namespaced[element],r)
+ end
+ inline = inline + 1
+ elseif nature == "mixed" then
+ if show_comment and comment then
+ result[#result+1] = f_begin_mixed_attr_comment(depth,comment,namespaced[element],r)
+ else
+ result[#result+1] = f_begin_mixed_attr(depth,namespaced[element],r)
+ end
+ depth = depth + 1
+ inline = 1
+ else
+ if show_comment and comment then
+ result[#result+1] = f_begin_display_attr_comment(depth,comment,depth,namespaced[element],r)
+ else
+ result[#result+1] = f_begin_display_attr(depth,namespaced[element],r)
+ end
+ depth = depth + 1
+ end
+ end
+ end
+ used[element][detail or ""] = { nature, specification.parents } -- for template css
+ -- also in last else ?
+ local metadata = specification.metadata
+ if metadata then
+ result[#result+1] = f_metadata_begin(depth)
+ for k, v in table.sortedpairs(metadata) do
+ if v ~= "" then
+ result[#result+1] = f_metadata(depth+1,k,lpegmatch(p_entity,v))
+ end
+ end
+ result[#result+1] = f_metadata_end(depth)
+ end
+ end
+
+ local function endtag(result,element,nature,di,skip)
+ if skip == "comment" then
+ if show_comment then
+ if nature == "display" and (inline == 0 or inline == 1) then
+ depth = depth - 1
+ result[#result+1] = f_comment_end_display(depth,namespaced[element])
+ inline = 0
+ elseif nature == "mixed" and (inline == 0 or inline == 1) then
+ depth = depth - 1
+ result[#result+1] = f_comment_end_mixed(namespaced[element])
+ inline = 0
+ else
+ inline = inline - 1
+ result[#result+1] = f_comment_end_inline(namespaced[element])
+ end
+ end
+ elseif skip then
+ -- ignore
+ else
+ if nature == "display" and (inline == 0 or inline == 1) then
+ depth = depth - 1
+ result[#result+1] = f_end_display(depth,namespaced[element])
+ inline = 0
+ elseif nature == "mixed" and (inline == 0 or inline == 1) then
+ depth = depth - 1
+ result[#result+1] = f_end_mixed(namespaced[element])
+ inline = 0
+ else
+ inline = inline - 1
+ result[#result+1] = f_end_inline(namespaced[element])
+ end
+ end
+ end
+
+ local function flushtree(result,data,nature)
+ local nofdata = #data
+ for i=1,nofdata do
+ local di = data[i]
+ if not di then -- hm, di can be string
+ -- whatever
+ else
+ local content = di.content
+ -- also optimize for content == "" : trace that first
+ if content then
+ -- already has breaks
+ local content = lpegmatch(p_entity,content)
+ if i == nofdata and sub(content,-1) == "\n" then -- move check
+ -- can be an end of line in par but can also be the last line
+ if trace_spacing then
+ result[#result+1] = f_spacing(di.parnumber or 0,sub(content,1,-2))
+ else
+ result[#result+1] = sub(content,1,-2)
+ end
+ result[#result+1] = " "
+ else
+ if trace_spacing then
+ result[#result+1] = f_spacing(di.parnumber or 0,content)
+ else
+ result[#result+1] = content
+ end
+ end
+ elseif not di.collapsed then -- ignore collapsed data (is appended, reconstructed par)
+ local element = di.element
+ if not element then
+ -- skip
+ elseif element == "break" then -- or element == "pagebreak"
+ emptytag(result,element,nature,di)
+ elseif element == "" or di.skip == "ignore" then
+ -- skip
+ else
+ if di.before then
+ flushtree(result,di.before,nature)
+ end
+ local natu = di.nature
+ local skip = di.skip
+ if di.breaknode then
+ emptytag(result,"break","display",di)
+ end
+ begintag(result,element,natu,di,skip)
+ flushtree(result,di.data,natu)
+ endtag(result,element,natu,di,skip)
+ if di.after then
+ flushtree(result,di.after,nature)
+ end
+ end
+ end
+ end
+ end
+ end
+
+ local function breaktree(tree,parent,parentelement) -- also removes double breaks
+ local data = tree.data
+ if data then
+ local nofdata = #data
+ local prevelement
+ local prevnature
+ local prevparnumber
+ local newdata = { }
+ local nofnewdata = 0
+ for i=1,nofdata do
+ local di = data[i]
+ if not di then
+ -- skip
+ elseif di.skip == "ignore" then
+ -- skip (new)
+elseif di.tg == "ignore" then
+ -- skip (new)
+ elseif di.content then
+ if di.samepar then
+ prevparnumber = false
+ else
+ local parnumber = di.parnumber
+ if prevnature == "inline" and prevparnumber and prevparnumber ~= parnumber then
+ nofnewdata = nofnewdata + 1
+ if trace_spacing then
+ newdata[nofnewdata] = makebreaknode { type = "a", p = prevparnumber, n = parnumber }
+ else
+ newdata[nofnewdata] = makebreaknode()
+ end
+ end
+ prevelement = nil
+ prevparnumber = parnumber
+ end
+ prevnature = "inline"
+ nofnewdata = nofnewdata + 1
+ newdata[nofnewdata] = di
+ elseif not di.collapsed then
+ local element = di.element
+ if element == "break" then -- or element == "pagebreak"
+ if prevelement == "break" then
+ di.element = ""
+ end
+ prevelement = element
+ prevnature = "display"
+ nofnewdata = nofnewdata + 1
+ newdata[nofnewdata] = di
+ elseif element == "" or di.skip == "ignore" then
+ -- skip
+ else
+ if di.samepar then
+ prevnature = "inline"
+ prevparnumber = false
+ else
+ local nature = di.nature
+ local parnumber = di.parnumber
+ if prevnature == "inline" and nature == "inline" and prevparnumber and prevparnumber ~= parnumber then
+ nofnewdata = nofnewdata + 1
+ if trace_spacing then
+ newdata[nofnewdata] = makebreaknode { type = "b", p = prevparnumber, n = parnumber }
+ else
+ newdata[nofnewdata] = makebreaknode()
+ end
+ end
+ prevnature = nature
+ prevparnumber = parnumber
+ end
+ prevelement = element
+ breaktree(di,tree,element)
+ nofnewdata = nofnewdata + 1
+ newdata[nofnewdata] = di
+ end
+ else
+ if di.samepar then
+ prevnature = "inline"
+ prevparnumber = false
+ else
+ local nature = di.nature
+ local parnumber = di.parnumber
+ if prevnature == "inline" and nature == "inline" and prevparnumber and prevparnumber ~= parnumber then
+ nofnewdata = nofnewdata + 1
+ if trace_spacing then
+ newdata[nofnewdata] = makebreaknode { type = "c", p = prevparnumber, n = parnumber }
+ else
+ newdata[nofnewdata] = makebreaknode()
+ end
+ end
+ prevnature = nature
+ prevparnumber = parnumber
+ end
+ nofnewdata = nofnewdata + 1
+ newdata[nofnewdata] = di
+ end
+ end
+ tree.data = newdata
+ end
+ end
+
+ -- also tabulaterow reconstruction .. maybe better as a checker
+ -- i.e cell attribute
+
+ local function collapsetree(tree)
+-- for tag, trees in sortedhash(treehash) do
+ for tag, trees in next, treehash do
+ local d = trees[1].data
+-- print("!!!!!!!!",tag)
+-- inspect(trees)
+ if d then
+ local nd = #d
+ if nd > 0 then
+ for i=2,#trees do
+ local currenttree = trees[i]
+ local currentdata = currenttree.data
+ local currentpar = currenttree.parnumber
+ local previouspar = trees[i-1].parnumber
+ currenttree.collapsed = true
+ -- is the next ok?
+ if previouspar == 0 or not (di and di.content) then
+ previouspar = nil -- no need anyway so no further testing needed
+ end
+ for j=1,#currentdata do
+ local cd = currentdata[j]
+ if not cd or cd == "" then
+ -- skip
+ elseif cd.skip == "ignore" then
+ -- skip
+ elseif cd.content then
+ if not currentpar then
+ -- add space ?
+ elseif not previouspar then
+ -- add space ?
+ elseif currentpar ~= previouspar then
+ nd = nd + 1
+ if trace_spacing then
+ d[nd] = makebreaknode { type = "d", p = previouspar, n = currentpar }
+ else
+ d[nd] = makebreaknode()
+ end
+ end
+ previouspar = currentpar
+ nd = nd + 1
+ d[nd] = cd
+ else
+ nd = nd + 1
+ d[nd] = cd
+ end
+ currentdata[j] = false
+ end
+ end
+ end
+ end
+ end
+ end
+
+ local function finalizetree(tree)
+ for _, finalizer in next, finalizers do
+ finalizer(tree)
+ end
+ end
+
+ -- local function showtree(data,when,where)
+ -- if data then
+ -- for i=1,#data do
+ -- local d = data[i]
+ -- if type(d) == "table" and d.element then
+ -- print(when,where,i,d.element,d.parnumber or 0)
+ -- end
+ -- end
+ -- end
+ -- end
+
+ local function indextree(tree)
+ local data = tree.data
+ if data then
+ local n, new = 0, { }
+ -- showtree(data,"before","index")
+ for i=1,#data do
+ local d = data[i]
+ if not d then
+ -- skip
+ elseif d.content then
+ n = n + 1
+ new[n] = d
+ elseif not d.collapsed then
+ n = n + 1
+ d.__i__ = n
+ d.__p__ = tree
+ indextree(d)
+ new[n] = d
+ end
+ end
+ tree.data = new
+ -- showtree(new,"after","index")
+ end
+ end
+
+ local function checktree(tree)
+ local data = tree.data
+ if data then
+ -- showtree(data,"before","check")
+ for i=1,#data do
+ local d = data[i]
+ if type(d) == "table" then
+ local check = checks[d.tg]
+ if check then
+ check(d,data,i)
+ end
+ checktree(d) -- so parts can pass twice
+ end
+ end
+ -- showtree(data,"after","check")
+ end
+ end
+
+ local function fixtree(tree)
+ local data = tree.data
+ if data then
+ -- showtree(data,"before","fix")
+ for i=1,#data do
+ local d = data[i]
+ if type(d) == "table" then
+ local fix = fixes[d.tg]
+ if fix then
+ fix(d,data,i)
+ end
+ fixtree(d) -- so parts can pass twice
+ end
+ end
+ -- showtree(data,"after","fix")
+ end
+ end
+
+ wrapups.flushtree = flushtree
+ wrapups.breaktree = breaktree
+ wrapups.collapsetree = collapsetree
+ wrapups.finalizetree = finalizetree
+ wrapups.indextree = indextree
+ wrapups.checktree = checktree
+ wrapups.fixtree = fixtree
+
+end
+
+-- collector code
+
+local function push(fulltag,depth)
+ local tg, n, detail, element, nature, record
+ local specification = specifications[fulltag]
+ if specification then
+ tg = specification.tagname
+ n = specification.tagindex
+ detail = specification.detail
+ else
+ -- a break (more efficient if we don't store those in specifications)
+ tg, n = lpegmatch(tagsplitter,fulltag)
+ n = tonumber(n) -- to tonumber in tagsplitter
+ end
+ local p = properties[tg]
+ if p then
+ element = p.export or tg
+ nature = p.nature or "inline" -- defaultnature
+ record = p.record
+ end
+ local treedata = tree.data
+ local t = { -- maybe we can use the tag table
+ tg = tg,
+ fulltag = fulltag,
+ detail = detail,
+ n = n, -- already a number
+ element = element,
+ nature = nature,
+ data = { },
+ attribute = currentattribute,
+ parnumber = currentparagraph,
+ record = record, -- we can consider storing properties
+ }
+ treedata[#treedata+1] = t
+ currentdepth = currentdepth + 1
+ nesting[currentdepth] = fulltag
+ treestack[currentdepth] = tree
+ if trace_export then
+ if detail and detail ~= "" then
+ report_export("%w<%s trigger=%q n=%q paragraph=%q index=%q detail=%q>",currentdepth-1,tg,n,currentattribute or 0,currentparagraph or 0,#treedata,detail)
+ else
+ report_export("%w<%s trigger=%q n=%q paragraph=%q index=%q>",currentdepth-1,tg,n,currentattribute or 0,currentparagraph or 0,#treedata)
+ end
+ end
+ tree = t
+ if tg == "break" then
+ -- no need for this
+ else
+ local h = treehash[fulltag]
+ if h then
+ h[#h+1] = t
+ else
+ treehash[fulltag] = { t }
+ end
+ end
+end
+
+local function pop()
+ if currentdepth > 0 then
+ local top = nesting[currentdepth]
+ tree = treestack[currentdepth]
+ currentdepth = currentdepth - 1
+ if trace_export then
+ if top then
+ report_export("%w%s>",currentdepth,match(top,"[^>]+"))
+ else
+ report_export("")
+ end
+ end
+ else
+ report_export("%w",currentdepth)
+ end
+end
+
+local function continueexport()
+ if nofcurrentcontent > 0 then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " " -- pagebreak
+ end
+end
+
+local function pushentry(current)
+ if not current then
+ -- bad news
+ return
+ end
+ current = current.taglist
+ if not current then
+ -- even worse news
+ return
+ end
+ if restart then
+ continueexport()
+ restart = false
+ end
+ local newdepth = #current
+ local olddepth = currentdepth
+ if trace_export then
+ report_export("%w",currentdepth,olddepth,newdepth,current[newdepth])
+ end
+ if olddepth <= 0 then
+ for i=1,newdepth do
+ push(current[i],i)
+ end
+ else
+ local difference
+ if olddepth < newdepth then
+ for i=1,olddepth do
+ if current[i] ~= nesting[i] then
+ difference = i
+ break
+ end
+ end
+ else
+ for i=1,newdepth do
+ if current[i] ~= nesting[i] then
+ difference = i
+ break
+ end
+ end
+ end
+ if difference then
+ for i=olddepth,difference,-1 do
+ pop()
+ end
+ for i=difference,newdepth do
+ push(current[i],i)
+ end
+ elseif newdepth > olddepth then
+ for i=olddepth+1,newdepth do
+ push(current[i],i)
+ end
+ elseif newdepth < olddepth then
+ for i=olddepth,newdepth,-1 do
+ pop()
+ end
+ elseif trace_export then
+ report_export("%w",currentdepth,newdepth,nesting[newdepth] or "?")
+ end
+ end
+ return olddepth, newdepth
+end
+
+local function pushcontent(oldparagraph,newparagraph)
+ if nofcurrentcontent > 0 then
+ if oldparagraph then
+ if currentcontent[nofcurrentcontent] == "\n" then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ nofcurrentcontent = nofcurrentcontent - 1
+ end
+ end
+ local content = concat(currentcontent,"",1,nofcurrentcontent)
+ if content == "" then
+ -- omit; when oldparagraph we could push, remove spaces, pop
+ elseif somespace[content] and oldparagraph then
+ -- omit; when oldparagraph we could push, remove spaces, pop
+ else
+ local olddepth, newdepth
+ local list = taglist[currentattribute]
+ if list then
+ olddepth, newdepth = pushentry(list)
+ end
+ if tree then
+ local td = tree.data
+ local nd = #td
+ td[nd+1] = { parnumber = oldparagraph or currentparagraph, content = content }
+ if trace_export then
+ report_export("%w",currentdepth,utflen(content))
+ report_export("%w%s",currentdepth,(gsub(content,"\n","\\n")))
+ report_export("%w",currentdepth)
+ end
+ if olddepth then
+ for i=newdepth-1,olddepth,-1 do
+ pop()
+ end
+ end
+ end
+ end
+ nofcurrentcontent = 0
+ end
+ if oldparagraph then
+ pushentry(makebreaklist(currentnesting))
+ if trace_export then
+ report_export("%w",currentdepth,oldparagraph,newparagraph)
+ end
+ end
+end
+
+local function finishexport()
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ if nofcurrentcontent > 0 then
+ if somespace[currentcontent[nofcurrentcontent]] then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ nofcurrentcontent = nofcurrentcontent - 1
+ end
+ pushcontent()
+ end
+ for i=currentdepth,1,-1 do
+ pop()
+ end
+ currentcontent = { } -- we're nice and do a cleanup
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+end
+
+-- inserts ?
+
+local collectresults do -- too many locals otherwise
+
+ local nodecodes = nodes.nodecodes
+ local gluecodes = nodes.gluecodes
+ local listcodes = nodes.listcodes
+ local whatsitcodes = nodes.whatsitcodes
+
+ local subtypes = nodes.subtypes
+
+ local hlist_code = nodecodes.hlist
+ local vlist_code = nodecodes.vlist
+ local glyph_code = nodecodes.glyph
+ local glue_code = nodecodes.glue
+ local kern_code = nodecodes.kern
+ local disc_code = nodecodes.disc
+ local whatsit_code = nodecodes.whatsit
+ local par_code = nodecodes.par
+
+ local userskip_code = gluecodes.userskip
+ local rightskip_code = gluecodes.rightskip
+ local parfillskip_code = gluecodes.parfillskip
+ local spaceskip_code = gluecodes.spaceskip
+ local xspaceskip_code = gluecodes.xspaceskip
+
+ local linelist_code = listcodes.line
+
+ local userdefinedwhatsit_code = whatsitcodes.userdefined
+
+ local privateattribute = attributes.private
+ local a_image = privateattribute('image')
+ local a_reference = privateattribute('reference')
+ local a_destination = privateattribute('destination')
+ local a_characters = privateattribute('characters')
+ local a_exportstatus = privateattribute('exportstatus')
+ local a_tagged = privateattribute('tagged')
+ local a_taggedpar = privateattribute("taggedpar")
+ local a_textblock = privateattribute("textblock")
+
+ local inline_mark = nodes.pool.userids["margins.inline"]
+
+ local nuts = nodes.nuts
+
+ local getnext = nuts.getnext
+ local getdisc = nuts.getdisc
+ local getlist = nuts.getlist
+ local getid = nuts.getid
+ local getattr = nuts.getattr
+ local setattr = nuts.setattr -- maybe use properties
+ local isglyph = nuts.isglyph
+ local getkern = nuts.getkern
+ local getwidth = nuts.getwidth
+
+ local start_of_par = nuts.start_of_par
+
+ local nexthlist = nuts.traversers.hlist
+ local nextnode = nuts.traversers.node
+
+ local function addtomaybe(maybewrong,c,case)
+ if trace_export then
+ report_export("%w",currentdepth,c,case)
+ else
+ local s = formatters["%C"](c)
+ if maybewrong then
+ maybewrong[#maybewrong+1] = s
+ else
+ maybewrong = { s }
+ end
+ return maybewrong
+ end
+ end
+
+ local function showmaybe(maybewrong)
+ if not trace_export then
+ report_export("fuzzy paragraph: % t",maybewrong)
+ end
+ end
+
+ local function showdetail(n,id,subtype)
+ local a = getattr(n,a_tagged)
+ local t = taglist[a]
+ local c = nodecodes[id]
+ local s = subtypes[id][subtype]
+ if a and t then
+ report_export("node %a, subtype %a, tag %a, element %a, tree '% t'",c,s,a,t.tagname,t.taglist)
+ else
+ report_export("node %a, subtype %a, untagged",c,s)
+ end
+ end
+
+ local function collectresults(head,list,pat,pap) -- is last used (we also have currentattribute)
+ local p
+ local paragraph
+ local maybewrong
+ local pid
+ for n, id, subtype in nextnode, head do
+ if trace_details then
+ showdetail(n,id,subtype)
+ end
+ if id == glyph_code then
+ local c, f = isglyph(n)
+ local at = getattr(n,a_tagged) or pat
+ if not at then
+ -- we need to tag the pagebody stuff as being valid skippable
+ --
+ -- report_export("skipping character: %C (no attribute)",n.char)
+ else
+ if last ~= at then
+ local tl = taglist[at]
+ local ap = getattr(n,a_taggedpar) or pap
+ if paragraph and (not ap or ap < paragraph) then
+ maybewrong = addtomaybe(maybewrong,c,1)
+ end
+ pushcontent()
+ currentnesting = tl
+ currentparagraph = ap
+ currentattribute = at
+ last = at
+ pushentry(currentnesting)
+ if trace_export then
+ report_export("%w",currentdepth,c,at)
+ end
+ -- We need to intercept this here; maybe I will also move this
+ -- to a regular setter at the tex end.
+ local r = getattr(n,a_reference)
+ if r then
+ local t = tl.taglist
+ referencehash[t[#t]] = r -- fulltag
+ end
+ local d = getattr(n,a_destination)
+ if d then
+ local t = tl.taglist
+ destinationhash[t[#t]] = d -- fulltag
+ end
+ --
+ elseif last then
+ -- we can consider tagging the pars (lines) in the parbuilder but then we loose some
+ -- information unless we inject a special node (but even then we can run into nesting
+ -- issues)
+ local ap = getattr(n,a_taggedpar) or pap
+ if ap ~= currentparagraph then
+ pushcontent(currentparagraph,ap)
+ pushentry(currentnesting)
+ currentattribute = last
+ currentparagraph = ap
+ end
+ if paragraph and (not ap or ap < paragraph) then
+ maybewrong = addtomaybe(maybewrong,c,2)
+ end
+ if trace_export then
+ report_export("%w",currentdepth,c,last)
+ end
+ else
+ if trace_export then
+ report_export("%w",currentdepth,c,at)
+ end
+ end
+ local s = getattr(n,a_exportstatus)
+ if s then
+ c = s
+ end
+ if c == 0 then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ elseif c == 0x20 then
+ local a = getattr(n,a_characters)
+ nofcurrentcontent = nofcurrentcontent + 1
+ if a then
+ if trace_export then
+ report_export("%w",currentdepth,a)
+ end
+ currentcontent[nofcurrentcontent] = specialspaces[a] -- special space
+ else
+ currentcontent[nofcurrentcontent] = " "
+ end
+ else
+ local fc = fontchar[f]
+ if fc then
+ fc = fc and fc[c]
+ if fc then
+ local u = fc.unicode
+ if not u then
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = utfchar(c)
+ elseif type(u) == "table" then
+ for i=1,#u do
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = utfchar(u[i])
+ end
+ else
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = utfchar(u)
+ end
+ elseif c > 0 then
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = utfchar(c)
+ else
+ -- we can have -1 as side effect of an explicit hyphen (unless we expand)
+ end
+ elseif c > 0 then
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = utfchar(c)
+ else
+ -- we can have -1 as side effect of an explicit hyphen (unless we expand)
+ end
+ end
+ end
+ elseif id == glue_code then
+ -- we need to distinguish between hskips and vskips
+ local ca = getattr(n,a_characters)
+ if ca == 0 then
+ -- skip this one ... already converted special character (node-acc)
+ elseif ca then
+ local a = getattr(n,a_tagged) or pat
+ if a then
+ local c = specialspaces[ca]
+ if last ~= a then
+ local tl = taglist[a]
+ if trace_export then
+ report_export("%w",currentdepth,ca,a)
+ end
+ pushcontent()
+ currentnesting = tl
+ currentparagraph = getattr(n,a_taggedpar) or pap
+ currentattribute = a
+ last = a
+ pushentry(currentnesting)
+ -- no reference check (see above)
+ elseif last then
+ local ap = getattr(n,a_taggedpar) or pap
+ if ap ~= currentparagraph then
+ pushcontent(currentparagraph,ap)
+ pushentry(currentnesting)
+ currentattribute = last
+ currentparagraph = ap
+ end
+ if trace_export then
+ report_export("%w",currentdepth,ca,last)
+ end
+ end
+ -- if somespace[currentcontent[nofcurrentcontent]] then
+ -- if trace_export then
+ -- report_export("%w",currentdepth)
+ -- end
+ -- nofcurrentcontent = nofcurrentcontent - 1
+ -- end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = c
+ end
+ elseif subtype == userskip_code then
+ if getwidth(n) > threshold then
+ if last and not somespace[currentcontent[nofcurrentcontent]] then
+ local a = getattr(n,a_tagged) or pat
+ if a == last then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ elseif a then
+ -- e.g LOGOLOGO
+ if trace_export then
+ report_export("%w",currentdepth,last,a)
+ end
+ pushcontent()
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ last = a
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ currentnesting = taglist[last]
+ pushentry(currentnesting)
+ currentattribute = last
+ end
+ end
+ end
+ elseif subtype == spaceskip_code or subtype == xspaceskip_code then
+ if not somespace[currentcontent[nofcurrentcontent]] then
+ local a = getattr(n,a_tagged) or pat
+ if a == last then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ else
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ last = a
+ pushcontent()
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ currentnesting = taglist[last]
+ pushentry(currentnesting)
+ currentattribute = last
+ end
+ end
+ elseif subtype == rightskip_code then
+ -- a line
+ if nofcurrentcontent > 0 then
+ local r = currentcontent[nofcurrentcontent]
+ if r == hyphen then
+ if not keephyphens then
+ nofcurrentcontent = nofcurrentcontent - 1
+ end
+ elseif pid == disc_code then
+ -- go on .. tricky: we should mark the glyhs as coming from a disc
+ elseif not somespace[r] then
+ local a = getattr(n,a_tagged) or pat
+ if a == last then
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ else
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ last = a
+ pushcontent()
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ currentnesting = taglist[last]
+ pushentry(currentnesting)
+ currentattribute = last
+ end
+ end
+ end
+ elseif subtype == parfillskip_code then
+ -- deal with paragraph endings (crossings) elsewhere and we quit here
+ -- as we don't want the rightskip space addition
+ if maybewrong then
+ showmaybe(maybewrong)
+ end
+ return
+ end
+ elseif id == hlist_code or id == vlist_code then
+ local ai = getattr(n,a_image)
+ if ai then
+ local at = getattr(n,a_tagged) or pat
+ if nofcurrentcontent > 0 then
+ pushcontent()
+ pushentry(currentnesting) -- ??
+ end
+ pushentry(taglist[at]) -- has an index, todo: flag empty element
+ if trace_export then
+ report_export("%w",currentdepth,kern)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ end
+ elseif a then
+ -- e.g LOGOLOGO
+ if trace_export then
+ report_export("%w",currentdepth,limit,last,a)
+ end
+ last = a
+ pushcontent()
+ if trace_export then
+ report_export("%w",currentdepth,kern)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+-- currentnesting = taglist[last]
+currentnesting = t
+ pushentry(currentnesting)
+ currentattribute = last
+ end
+ end
+ end
+end
+ end
+ elseif id == whatsit_code then
+ if subtype == userdefinedwhatsit_code then
+ -- similar to images, see above
+ local at = getattr(n,a_tagged)
+ if nofcurrentcontent > 0 then
+ pushcontent()
+ pushentry(currentnesting) -- ??
+ end
+ pushentry(taglist[at])
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ -- continueexport()
+ restart = true
+ collectresults(head)
+ if trace_export then
+ report_export("%w",currentdepth)
+ end
+ stoptiming(treehash)
+ return head
+ end
+
+ function nodes.handlers.checkparcounter(p)
+ setattr(p,a_taggedpar,texgetcount("tagparcounter") + 1)
+ return p
+ end
+
+ function builders.paragraphs.tag(head)
+ noftextblocks = noftextblocks + 1
+ for n, subtype in nexthlist, head do
+ if subtype == linelist_code then
+ setattr(n,a_textblock,noftextblocks)
+ elseif subtype == glue_code or subtype == kern_code then -- no need to set fontkerns
+ setattr(n,a_textblock,0)
+ end
+ end
+ return false
+ end
+
+end
+
+do
+
+ local xmlcollected = xml.collected
+ local xmlsetcomment = xml.setcomment
+
+local xmlpreamble = [[
+
+
+
+
+]]
+
+ local flushtree = wrapups.flushtree
+
+ local function wholepreamble(standalone)
+ return replacetemplate(xmlpreamble, {
+ standalone = standalone and "yes" or "no",
+ filename = tex.jobname,
+ date = included.date and os.fulltime(),
+ contextversion = environment.version,
+ exportversion = exportversion,
+ })
+ end
+
+
+local csspreamble = [[
+
+]]
+
+local cssheadlink = [[
+
+]]
+
+ local function allusedstylesheets(cssfiles,files,path)
+ local done = { }
+ local result = { }
+ local extras = { }
+ for i=1,#cssfiles do
+ local cssfile = cssfiles[i]
+ if type(cssfile) ~= "string" then
+ -- error
+ elseif cssfile == "export-example.css" then
+ -- ignore
+ elseif not done[cssfile] then
+ cssfile = joinfile(path,basename(cssfile))
+ report_export("adding css reference '%s'",cssfile)
+ files[#files+1] = cssfile
+ result[#result+1] = replacetemplate(csspreamble, { filename = cssfile })
+ extras[#extras+1] = replacetemplate(cssheadlink, { filename = cssfile })
+ done[cssfile] = true
+ end
+ end
+ return concat(result), concat(extras)
+ end
+
+local elementtemplate = [[
+/* element="%element%" detail="%detail%" chain="%chain%" */
+
+%element%,
+%namespace%div.%element% {
+ display: %display% ;
+}]]
+
+local detailtemplate = [[
+/* element="%element%" detail="%detail%" chain="%chain%" */
+
+%element%[detail=%detail%],
+%namespace%div.%element%.%detail% {
+ display: %display% ;
+}]]
+
+--
+
+local htmltemplate = [[
+%preamble%
+
+
+
+
+
+
+
+ %title%
+
+%style%
+
+
+
+
+
+
Rendering can be suboptimal because there is no default/fallback css loaded.
+
+%body%
+
+
+
+
+]]
+
+ local displaymapping = {
+ inline = "inline",
+ display = "block",
+ mixed = "inline",
+ }
+
+ local function allusedelements(filename)
+ local result = { replacetemplate(namespacetemplate, {
+ what = "template",
+ filename = filename,
+ namespace = contextns,
+ -- cssnamespaceurl = usecssnamespace and cssnamespaceurl or "",
+ cssnamespaceurl = cssnamespaceurl,
+ },false,true) }
+ for element, details in sortedhash(used) do
+ if namespaces[element] then
+ -- skip math
+ else
+ for detail, what in sortedhash(details) do
+ local nature = what[1] or "display"
+ local chain = what[2]
+ local display = displaymapping[nature] or "block"
+ if detail == "" then
+ result[#result+1] = replacetemplate(elementtemplate, {
+ element = element,
+ display = display,
+ chain = chain,
+ namespace = usecssnamespace and namespace or "",
+ })
+ else
+ result[#result+1] = replacetemplate(detailtemplate, {
+ element = element,
+ display = display,
+ detail = detail,
+ chain = chain,
+ namespace = usecssnamespace and cssnamespace or "",
+ })
+ end
+ end
+ end
+ end
+ return concat(result,"\n\n")
+ end
+
+ local function allcontent(tree,embed)
+ local result = { }
+ flushtree(result,tree.data,"display") -- we need to collect images
+ result = concat(result)
+ -- no need to lpeg .. fast enough
+ result = gsub(result,"\n *\n","\n")
+ result = gsub(result,"\n +([^< ])","\n%1")
+ return result
+ end
+
+ -- local xhtmlpreamble = [[
+ --
+ -- ]]
+
+ local function cleanxhtmltree(xmltree)
+ if xmltree then
+ local implicits = { }
+ local explicits = { }
+ local overloads = { }
+ for e in xmlcollected(xmltree,"*") do
+ local at = e.at
+ if at then
+ local explicit = at.explicit
+ local implicit = at.implicit
+ if explicit then
+ if not explicits[explicit] then
+ explicits[explicit] = true
+ at.id = explicit
+ if implicit then
+ overloads[implicit] = explicit
+ end
+ end
+ else
+ if implicit and not implicits[implicit] then
+ implicits[implicit] = true
+ at.id = "aut:" .. implicit
+ end
+ end
+ end
+ end
+ for e in xmlcollected(xmltree,"*") do
+ local at = e.at
+ if at then
+ local internal = at.internal
+ local location = at.location
+ if internal then
+ if location then
+ local explicit = overloads[location]
+ if explicit then
+ at.href = "#" .. explicit
+ else
+ at.href = "#aut:" .. internal
+ end
+ else
+ at.href = "#aut:" .. internal
+ end
+ else
+ if location then
+ at.href = "#" .. location
+ else
+ local url = at.url
+ if url then
+ at.href = url
+ else
+ local file = at.file
+ if file then
+ at.href = file
+ end
+ end
+ end
+ end
+ end
+ end
+ return xmltree
+ else
+ return xml.convert('\ninvalid xhtml tree')
+ end
+ end
+
+ -- maybe the reverse: be explicit about what is permitted
+
+ local private = {
+ destination = true,
+ prefix = true,
+ reference = true,
+ --
+ id = true,
+ href = true,
+ --
+ implicit = true,
+ explicit = true,
+ --
+ url = true,
+ file = true,
+ internal = true,
+ location = true,
+ --
+ name = true, -- image name
+ used = true, -- image name
+ page = true, -- image name
+ width = true,
+ height = true,
+ --
+ }
+
+ local addclicks = true
+ local f_onclick = formatters[ [[location.href='%s']] ]
+ local f_onclick = formatters[ [[location.href='%s']] ]
+
+ local p_cleanid = lpeg.replacer { [":"] = "-" }
+ local p_cleanhref = lpeg.Cs(lpeg.P("#") * p_cleanid)
+
+ local p_splitter = lpeg.Ct ( (
+ lpeg.Carg(1) * lpeg.C((1-lpeg.P(" "))^1) / function(d,s) if not d[s] then d[s] = true return s end end
+ * lpeg.P(" ")^0 )^1 )
+
+
+ local classes = table.setmetatableindex(function(t,k)
+ local v = concat(lpegmatch(p_splitter,k,1,{})," ")
+ t[k] = v
+ return v
+ end)
+
+ local function makeclass(tg,at)
+ local detail = at.detail
+ local chain = at.chain
+ local extra = nil
+ local classes = { }
+ local nofclasses = 0
+ at.detail = nil
+ at.chain = nil
+ for k, v in next, at do
+ if not private[k] then
+ nofclasses = nofclasses + 1
+ classes[nofclasses] = k .. "-" .. v
+ end
+ end
+ if detail and detail ~= "" then
+ if chain and chain ~= "" then
+ if chain ~= detail then
+ extra = classes[tg .. " " .. chain .. " " .. detail]
+ elseif tg ~= detail then
+ extra = detail
+ end
+ elseif tg ~= detail then
+ extra = detail
+ end
+ elseif chain and chain ~= "" then
+ if tg ~= chain then
+ extra = chain
+ end
+ end
+ -- in this order
+ if nofclasses > 0 then
+ sort(classes)
+ classes = concat(classes," ")
+ if extra then
+ return tg .. " " .. extra .. " " .. classes
+ else
+ return tg .. " " .. classes
+ end
+ else
+ if extra then
+ return tg .. " " .. extra
+ else
+ return tg
+ end
+ end
+ end
+
+ -- Some elements are not supported (well) in css so we need to retain them. For
+ -- instance, tablecells have no colspan so basically that renders css table div
+ -- elements quite useless. A side effect is that we nwo can have conflicts when
+ -- we mix in with other html (as there is no reset). Of course, when it eventually
+ -- gets added, there is a change then that those not using the div abstraction
+ -- will be rediculed.
+ --
+ -- a table tr td th thead tbody tfoot
+ --
+
+ local crappycss = {
+ table = "table", tabulate = "table",
+ tablehead = "thead", tabulatehead = "thead",
+ tablebody = "tbody", tabulatebody = "tbody",
+ tablefoot = "tfoot", tabulatefoot = "tfoot",
+ tablerow = "tr", tabulaterow = "tr",
+ tablecell = "td", tabulatecell = "td",
+ }
+
+ local cssmapping = false
+
+ directives.register("export.nativetags", function(v)
+ cssmapping = v and crappycss or false
+ end)
+
+ local function remap(specification,source,target)
+ local comment = nil -- share comments
+ for c in xmlcollected(source,"*") do
+ if not c.special then
+ local tg = c.tg
+ local ns = c.ns
+ if ns == "m" then
+ if false then -- yes or no
+ c.ns = ""
+ c.at["xmlns:m"] = nil
+ end
+ -- elseif tg == "a" then
+ -- c.ns = ""
+ else
+ local dt = c.dt
+ local nt = #dt
+ if nt == 0 or (nt == 1 and dt[1] == "") then
+ if comment then
+ c.dt = comment
+ else
+ xmlsetcomment(c,"empty")
+ comment = c.dt
+ end
+ end
+ local at = c.at
+ local class = nil
+ local label = nil
+ if tg == "document" then
+ at.href = nil
+ at.detail = nil
+ at.chain = nil
+ elseif tg == "metavariable" then
+ label = at.name
+ at.detail = "metaname-" .. label
+ class = makeclass(tg,at)
+ else
+ class = makeclass(tg,at)
+ end
+ local id = at.id
+ local href = at.href
+ local attr = nil
+ if id then
+ id = lpegmatch(p_cleanid, id) or id
+ if href then
+ href = lpegmatch(p_cleanhref,href) or href
+ attr = {
+ class = class,
+ id = id,
+ href = href,
+ onclick = addclicks and f_onclick(href) or nil,
+ }
+ else
+ attr = {
+ class = class,
+ id = id,
+ }
+ end
+ else
+ if href then
+ href = lpegmatch(p_cleanhref,href) or href
+ attr = {
+ class = class,
+ href = href,
+ onclick = addclicks and f_onclick(href) or nil,
+ }
+ else
+ attr = {
+ class = class,
+ }
+ end
+ end
+ c.at = attr
+ if label then
+ attr.label = label
+ end
+ c.tg = cssmapping and cssmapping[tg] or "div"
+ end
+ end
+ end
+ end
+
+ -- local cssfile = nil directives.register("backend.export.css", function(v) cssfile = v end)
+
+ local embedfile = false directives.register("export.embed",function(v) embedfile = v end)
+
+ function structurestags.finishexport()
+
+ if exporting then
+ exporting = false
+ else
+ return
+ end
+
+ local onlyxml = finetuning.export == v_xml
+
+ starttiming(treehash)
+ --
+ finishexport()
+ --
+ report_export("")
+ if onlyxml then
+ report_export("exporting xml, no other files")
+ else
+ report_export("exporting xml, xhtml, html and css files")
+ end
+ report_export("")
+ --
+ wrapups.fixtree(tree)
+ wrapups.collapsetree(tree)
+ wrapups.indextree(tree)
+ wrapups.checktree(tree)
+ wrapups.breaktree(tree)
+ wrapups.finalizetree(tree)
+ --
+ wrapups.hashlistdata()
+ --
+ local askedname = finetuning.file
+ --
+ -- we use a dedicated subpath:
+ --
+ -- ./jobname-export
+ -- ./jobname-export/images
+ -- ./jobname-export/styles
+ -- ./jobname-export/styles
+ -- ./jobname-export/jobname-export.xml
+ -- ./jobname-export/jobname-export.xhtml
+ -- ./jobname-export/jobname-export.html
+ -- ./jobname-export/jobname-specification.lua
+ -- ./jobname-export/styles/jobname-defaults.css
+ -- ./jobname-export/styles/jobname-styles.css
+ -- ./jobname-export/styles/jobname-images.css
+ -- ./jobname-export/styles/jobname-templates.css
+
+ if type(askedname) ~= "string" or askedname == "" then
+ askedname = tex.jobname
+ end
+
+ local usedname = nameonly(askedname)
+ local basepath = usedname .. "-export"
+ local imagepath = joinfile(basepath,"images")
+ local stylepath = joinfile(basepath,"styles")
+
+ local function validpath(what,pathname)
+ if lfs.isdir(pathname) then
+ report_export("using existing %s path %a",what,pathname)
+ return pathname
+ end
+ lfs.mkdir(pathname)
+ if lfs.isdir(pathname) then
+ report_export("using cretated %s path %a",what,basepath)
+ return pathname
+ else
+ report_export("unable to create %s path %a",what,basepath)
+ return false
+ end
+ end
+
+ if not (validpath("export",basepath) and validpath("images",imagepath) and validpath("styles",stylepath)) then
+ return
+ end
+
+ -- we're now on the dedicated export subpath so we can't clash names
+ --
+ -- a xhtml suffix no longer seems to be work well with browsers
+
+ local xmlfilebase = addsuffix(usedname .. "-raw","xml" )
+ local xhtmlfilebase = addsuffix(usedname .. "-tag","xhtml")
+ local htmlfilebase = addsuffix(usedname .. "-div","html")
+ local specificationfilebase = addsuffix(usedname .. "-pub","lua" )
+
+ local xmlfilename = joinfile(basepath, xmlfilebase )
+ local xhtmlfilename = joinfile(basepath, xhtmlfilebase )
+ local htmlfilename = joinfile(basepath, htmlfilebase )
+ local specificationfilename = joinfile(basepath, specificationfilebase)
+ --
+ local defaultfilebase = addsuffix(usedname .. "-defaults", "css")
+ local imagefilebase = addsuffix(usedname .. "-images", "css")
+ local stylefilebase = addsuffix(usedname .. "-styles", "css")
+ local templatefilebase = addsuffix(usedname .. "-templates","css")
+ --
+ local defaultfilename = joinfile(stylepath,defaultfilebase )
+ local imagefilename = joinfile(stylepath,imagefilebase )
+ local stylefilename = joinfile(stylepath,stylefilebase )
+ local templatefilename = joinfile(stylepath,templatefilebase)
+
+ local cssfile = finetuning.cssfile
+
+ -- we keep track of all used files
+
+ local files = {
+ }
+
+ -- we always load the defaults and optionally extra css files; we also copy the example
+ -- css file so that we always have the latest version
+
+ local cssfiles = {
+ defaultfilebase,
+ imagefilebase,
+ stylefilebase,
+ }
+
+ local cssextra = cssfile and table.unique(settings_to_array(cssfile)) or { }
+
+ -- at this point we're ready for the content; the collector also does some
+ -- housekeeping and data collecting; at this point we still have an xml
+ -- representation that uses verbose element names and carries information in
+ -- attributes
+
+ local data = tree.data
+ for i=1,#data do
+ if data[i].tg ~= "document" then
+ data[i] = { }
+ end
+ end
+
+ local result = allcontent(tree,embedmath) -- embedfile is for testing
+
+ -- ugly but so be it:
+
+ local extradata = structures.tags.getextradata()
+ if extradata then
+ local t = { "" }
+ t[#t+1] = ""
+ for name, action in sortedhash(extradata) do
+ t[#t+1] = action()
+ end
+ t[#t+1] = ""
+ t[#t+1] = ""
+ -- we use a function because otherwise we can have a bad capture index
+ result = gsub(result,"",function()
+ return concat(t,"\n")
+ end)
+ end
+
+ -- done with ugly
+
+ if onlyxml then
+
+ os.remove(defaultfilename)
+ os.remove(imagefilename)
+ os.remove(stylefilename)
+ os.remove(templatefilename)
+
+ for i=1,#cssextra do
+ os.remove(joinfile(stylepath,basename(source)))
+ end
+
+ -- os.remove(xmlfilename)
+
+ os.remove(imagefilename)
+ os.remove(stylefilename)
+ os.remove(templatefilename)
+ os.remove(xhtmlfilename)
+ os.remove(specificationfilename)
+ os.remove(htmlfilename)
+
+ result = concat {
+ wholepreamble(true),
+ "\n",
+ result,
+ }
+
+ report_export("saving xml data in %a",xmlfilename)
+ io.savedata(xmlfilename,result)
+
+ return
+
+ end
+
+ local examplefilename = resolvers.findfile("export-example.css")
+ if examplefilename then
+ local data = io.loaddata(examplefilename)
+ if not data or data == "" then
+ data = "/* missing css file */"
+ elseif not usecssnamespace then
+ data = gsub(data,cssnamespace,"")
+ end
+ io.savedata(defaultfilename,data)
+ end
+
+ if cssfile then
+ for i=1,#cssextra do
+ local source = addsuffix(cssextra[i],"css")
+ local target = joinfile(stylepath,basename(source))
+ cssfiles[#cssfiles+1] = source
+ if not lfs.isfile(source) then
+ source = joinfile("../",source)
+ end
+ if lfs.isfile(source) then
+ report_export("copying %s",source)
+ file.copy(source,target)
+ end
+ end
+ end
+
+ local x_styles, h_styles = allusedstylesheets(cssfiles,files,"styles")
+
+ local attach = backends.nodeinjections.attachfile
+
+ if embedfile and attach then
+ -- only for testing
+ attach {
+ data = concat{ wholepreamble(true), result },
+ name = basename(xmlfilename),
+ registered = "export",
+ title = "raw xml export",
+ method = v_hidden,
+ mimetype = "application/mathml+xml",
+ }
+ end
+
+ result = concat {
+ wholepreamble(true),
+ x_styles, -- adds to files
+ result,
+ }
+
+ cssfiles = table.unique(cssfiles)
+
+ -- we're now ready for saving the result in the xml file
+
+ report_export("saving xml data in %a",xmlfilename)
+ io.savedata(xmlfilename,result)
+
+ report_export("saving css image definitions in %a",imagefilename)
+ io.savedata(imagefilename,wrapups.allusedimages(usedname))
+
+ report_export("saving css style definitions in %a",stylefilename)
+ io.savedata(stylefilename,wrapups.allusedstyles(usedname))
+
+ report_export("saving css template in %a",templatefilename)
+ io.savedata(templatefilename,allusedelements(usedname))
+
+ -- additionally we save an xhtml file; for that we load the file as xml tree
+
+ report_export("saving xhtml variant in %a",xhtmlfilename)
+
+ local xmltree = cleanxhtmltree(xml.convert(result))
+
+ -- local xmltree = xml.convert(result)
+ -- for c in xml.collected(xmltree,"m:mtext[lastindex()=1]/m:mrow") do
+ -- print(c)
+ -- end
+ -- for c in xml.collected(xmltree,"mtext/mrow") do
+ -- print(c)
+ -- end
+ -- local xmltree = cleanxhtmltree(xmltree)
+
+ xml.save(xmltree,xhtmlfilename)
+
+ -- now we save a specification file that can b eused for generating an epub file
+
+ -- looking at identity is somewhat redundant as we also inherit from interaction
+ -- at the tex end
+
+ local identity = interactions.general.getidentity()
+ local metadata = structures.tags.getmetadata()
+
+ local specification = {
+ name = usedname,
+ identifier = os.uuid(),
+ images = wrapups.uniqueusedimages(),
+ imagefile = joinfile("styles",imagefilebase),
+ imagepath = "images",
+ stylepath = "styles",
+ xmlfiles = { xmlfilebase },
+ xhtmlfiles = { xhtmlfilebase },
+ htmlfiles = { htmlfilebase },
+ styles = cssfiles,
+ htmlroot = htmlfilebase,
+ language = languagenames[texgetcount("mainlanguagenumber")],
+ title = validstring(finetuning.title) or validstring(identity.title),
+ subtitle = validstring(finetuning.subtitle) or validstring(identity.subtitle),
+ author = validstring(finetuning.author) or validstring(identity.author),
+ firstpage = validstring(finetuning.firstpage),
+ lastpage = validstring(finetuning.lastpage),
+ metadata = metadata,
+ }
+
+ report_export("saving specification in %a",specificationfilename,specificationfilename)
+
+ xml.wipe(xmltree,"metadata") -- maybe optional
+
+ io.savedata(specificationfilename,table.serialize(specification,true))
+
+ -- the html export for epub is different in the sense that it uses div's instead of
+ -- specific tags
+
+ report_export("saving div based alternative in %a",htmlfilename)
+
+ remap(specification,xmltree)
+
+ -- believe it or not, but a can prevent viewing in browsers
+
+ local title = specification.title
+
+ if not title or title == "" then
+ title = metadata.title
+ if not title or title == "" then
+ title = usedname -- was: "no title"
+ end
+ end
+
+ local variables = {
+ style = h_styles,
+ body = xml.tostring(xml.first(xmltree,"/div")),
+ preamble = wholepreamble(false),
+ title = title,
+ }
+
+ io.savedata(htmlfilename,replacetemplate(htmltemplate,variables,"xml"))
+
+ -- finally we report how an epub file can be made (using the specification)
+
+ report_export("")
+ report_export('create epub with: mtxrun --script epub --make "%s" [--purge --rename --svgmath]',usedname)
+ report_export("")
+
+ stoptiming(treehash)
+ end
+
+ local enableaction = nodes.tasks.enableaction
+
+ function structurestags.initializeexport()
+ if not exporting then
+ report_export("enabling export to xml")
+ enableaction("shipouts","nodes.handlers.export")
+ enableaction("shipouts","nodes.handlers.accessibility")
+ enableaction("math", "noads.handlers.tags")
+ enableaction("everypar","nodes.handlers.checkparcounter")
+ luatex.registerstopactions(structurestags.finishexport)
+ exporting = true
+ end
+ end
+
+ function structurestags.setupexport(t)
+ merge(finetuning,t)
+ keephyphens = finetuning.hyphen == v_yes
+ exportproperties = finetuning.properties
+ if exportproperties == v_no then
+ exportproperties = false
+ end
+ end
+
+ statistics.register("xml exporting time", function()
+ if exporting then
+ return string.format("%s seconds, version %s", statistics.elapsedtime(treehash),exportversion)
+ end
+ end)
+
+end
+
+-- These are called at the tex end:
+
+implement {
+ name = "setupexport",
+ actions = structurestags.setupexport,
+ arguments = {
+ {
+ { "align" },
+ { "bodyfont", "dimen" },
+ { "width", "dimen" },
+ { "properties" },
+ { "hyphen" },
+ { "title" },
+ { "subtitle" },
+ { "author" },
+ { "firstpage" },
+ { "lastpage" },
+ { "svgstyle" },
+ { "cssfile" },
+ { "file" },
+ { "export" },
+ }
+ }
+}
+
+implement {
+ name = "finishexport",
+ actions = structurestags.finishexport,
+}
+
+implement {
+ name = "initializeexport",
+ actions = structurestags.initializeexport,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-exp.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-exp.mkxl
new file mode 100644
index 00000000000..5aebd302fdc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-exp.mkxl
@@ -0,0 +1,361 @@
+%D \module
+%D [ file=back-exp,
+%D version=2010.08.22,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=XML export,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% see t:/export/todo-fonts.tex for (future) experiment
+
+\writestatus{loading}{ConTeXt Backend Macros / XML export}
+
+\registerctxluafile{back-exp} {autosuffix}
+\registerctxluafile{back-exp-imp-tag}{autosuffix}
+\registerctxluafile{back-exp-imp-mth}{autosuffix}
+\registerctxluafile{back-exp-imp-ref}{autosuffix}
+
+%D This is an experimental exporter and a logical follow up on tagging. The
+%D exporter assumes a properly tagged document. Some elements get a couple
+%D of attributes because otherwise rendering information would get lost. In
+%D general we assume that when the \XML\ is converted to \HTML\ some stylesheet
+%D is applied anyway.
+
+\unprotect
+
+% we can replace this by a more generic attributeset mechanism where we bind
+% to any element (needed anyway, see userdata thingies)
+
+\definesystemattribute[taggedpar][public]
+
+\permanent\tolerant\protected\def\setelementexporttag[#1]#*[#2]#*[#3]%
+ {\ifarguments\or\or
+ \clf_settagproperty{#1}{export}{#2}%
+ \or
+ \clf_settagproperty{#1}{#2}{#3}%
+ \fi}
+
+% todo: no need for calls when trialtypesetting
+
+\permanent\def\taggedctxcommand
+ {\iftrialtypesetting
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\ctxcommand
+ \fi}
+
+\newcount\tagparcounter
+
+\aliased\let\dotagsetparcounter\relax
+\aliased\let\doresetparcounter \relax
+
+\appendtoks
+ \doresetparcounter
+\to \everyflushatnextpar
+
+% \appendtoks
+% \dotagsetparcounter
+% \to \everypar
+
+\prependtoks
+ \dotagsetparcounter
+\to \everypar
+
+% \appendtoks
+% \dotagsetparcounter
+% \to \neverypar
+
+\prependtoks
+ \dotagsetparcounter
+\to \neverypar
+
+\appendtoks
+ \dotagsetparcounter
+\to \everytabulatepar % tricky, maybe this should be neverypar
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagTABLEcell
+ {\iftrialtypesetting\else
+ \clf_settagtablecell
+ \numexpr\tablecellrows\relax
+ \numexpr\tablecellcolumns\relax
+ \numexpr\raggedstatus\relax
+ \fi}%
+ % brrr, we need to tag empty cells (unless we start numbering)
+ \enforced\permanent\protected\def\dotagTABLEsignal
+ {\signalcharacter}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagtabulatecell
+ {\iftrialtypesetting\else
+ \clf_settagtabulatecell\c_tabl_tabulate_align\c_tabl_tabulate_kind
+ \fi}%
+ \enforced\permanent\protected\def\dotagtabulatesignal
+ {\dontleavehmode\signalcharacter\ignorespaces}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsynonym
+ {\iftrialtypesetting\else\clf_settagsynonym{\currentsynonymtag}\fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsorting
+ {\iftrialtypesetting\else\clf_settagsorting{\currentsortingtag}\fi}%
+\to \everyenableelements
+
+\appendtoks % frozen and assumed global per highlight class
+ \enforced\permanent\protected\def\dotagconstruct
+ {\iftrialtypesetting\else
+ \clf_settagconstruct
+ {\currentstartstop}%
+ {\startstopparameter\c!style}%
+ \c_attr_color
+ \ifvmode\plusone\else\zerocount\fi
+ \relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks % frozen and assumed global per highlight class
+ \enforced\permanent\protected\def\dotaghighlight
+ {\iftrialtypesetting\else
+ \clf_settaghighlight
+ {\currenthighlight}%
+ {\highlightparameter\c!style}
+ \c_attr_color
+ \ifvmode\plusone\else\zerocount\fi
+ \relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks % we can have differently scaled images
+ \enforced\permanent\protected\def\dotagfigure
+ {\iftrialtypesetting\else
+ \clf_settagfigure
+ {\figurefileoriginal}%
+ {\figurefullname}%
+ {\figurefilepage}%
+ \dimexpr\figurewidth\relax
+ \dimexpr\figureheight\relax
+ {\figurelabel}%
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagcombination
+ {\iftrialtypesetting\else
+ \clf_settagcombination
+ \numexpr\combinationparameter\c!nx\relax
+ \numexpr\combinationparameter\c!ny\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsetparcounter
+ {\global\advance\tagparcounter\plusone\c_attr_taggedpar\tagparcounter}%
+ \enforced\permanent\protected\def\doresetparcounter
+ {\c_attr_taggedpar\attributeunsetvalue}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsetitemgroup
+ {\iftrialtypesetting\else
+ \clf_settagitemgroup
+ \ifconditional\c_strc_itemgroups_pack true\else false\fi\space
+ \numexpr\currentitemlevel\relax
+ {\currentitemgroupsymbol}%
+ \fi}%
+ \enforced\permanent\protected\def\dotagsetitem#1%
+ {\iftrialtypesetting\else
+ \clf_settagitem{#1}%
+ \fi}%
+\to \everyenableelements
+
+% \appendtoks
+% \enforced\permanent\protected\def\dotagsetdescription
+% {\iftrialtypesetting\else
+% \clf_settagdescription{\currentdescription}\currentdescriptionnumberentry\relax
+% \fi}%
+% \to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsetnotation
+ {\iftrialtypesetting\else
+ \clf_settagnotation{\currentnote}\currentnotenumber\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsetnotesymbol
+ {\iftrialtypesetting\else
+ \clf_settagnotationsymbol{\currentnote}\currentnotenumber\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagregisterlocation
+ {\iftrialtypesetting\else
+ \clf_settagregister{\currentregister}\currentregisternumber\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotaglistlocation
+ {\iftrialtypesetting\else
+ \clf_settaglist\currentlistindex\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsetdelimitedsymbol#1%
+ {\iftrialtypesetting\else
+ \clf_settagdelimitedsymbol{#1}\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagsetsubsentencesymbol#1%
+ {\iftrialtypesetting\else
+ \clf_settagsubsentencesymbol{#1}\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagregisterfloat#1#2%
+ {\iftrialtypesetting\else
+ \clf_settagfloat{#1}{#2}\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\let\specialfixedspace \explicitfixedspace
+ \enforced\let\specialobeyedspace \explicitobeyedspace
+ \enforced\let\specialstretchedspace\explicitstretchedspace
+ \enforced\let\specialcontrolspace \explicitcontrolspace
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagregisterformula#1%
+ {\iftrialtypesetting\else
+ \clf_settagformulacontent#1\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagmarginanchor#1%
+ {\iftrialtypesetting\else\clf_settagmarginanchor#1\relax\fi}%
+ \enforced\permanent\protected\def\dotagmargintext#1%
+ {\iftrialtypesetting\else\clf_settagmargintext#1\relax\fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagpublication#1#2%
+ {\iftrialtypesetting\else
+ \clf_settagpublication{#1}{#2}\relax
+ \fi}%
+\to \everyenableelements
+
+\appendtoks
+ \enforced\permanent\protected\def\dotagparagraph#1%
+ {\iftrialtypesetting\else
+ \clf_settagparagraph{#1}\relax
+ \fi}%
+\to \everyenableelements
+
+% The action: \setupbackend[export=yes] % or filename
+
+% maybe xhtml css settings will move to setupexport
+
+% maybe some day a definer
+
+\installcorenamespace{export}
+
+\installparameterhandler \??export {export}
+\installsetuphandler \??export {export}
+
+\setupexport
+ [\c!align=\number\raggedstatus,
+ \c!bodyfont=\bodyfontsize,
+ \c!width=\textwidth,
+ \c!title={\directinteractionparameter\c!title},
+ \c!subtitle={\directinteractionparameter\c!subtitle},
+ \c!author={\directinteractionparameter\c!author},
+ % \c!firstpage=, % imagename
+ % \c!lastpage=, % imagename
+ \c!properties=\v!no, % no: ignore, yes: as attribute, otherwise: use as prefix
+ \c!hyphen=\v!no,
+ \c!svgstyle=,
+ \c!cssfile=,
+ \c!file=]
+
+\resetsystemmode\v!export
+
+\permanent\protected\def\doinitializeexport
+ {\edef\p_export{\backendparameter\c!export}%
+ \ifempty\p_export \else
+ % yes | xml
+ \setuptagging[\c!state=\v!start]%
+ \clf_initializeexport
+ \setsystemmode\v!export
+ \exportingtrue
+ \writestatus\m!backend\empty % so messages will stand out a bit
+ \the\everyinitializeexport
+ \writestatus\m!backend\empty % so messages will stand out a bit
+ \enforced\glet\doinitializeexport\relax
+ \fi}
+
+\permanent\protected\def\dostartexport
+ {%\glet\dostartexport\relax
+ \let\currentexport\empty
+ \clf_setupexport
+ align {\exportparameter\c!align}%
+ bodyfont \dimexpr\exportparameter\c!bodyfont\relax
+ width \dimexpr\exportparameter\c!width\relax
+ properties {\exportparameter\c!properties}%
+ hyphen {\exportparameter\c!hyphen}%
+ title {\exportparameter\c!title}%
+ subtitle {\exportparameter\c!subtitle}%
+ author {\exportparameter\c!author}%
+ firstpage {\exportparameter\c!firstpage}%
+ lastpage {\exportparameter\c!lastpage}%
+ svgstyle {\exportparameter\c!svgstyle}%
+ cssfile {\exportparameter\c!cssfile}%
+ file {\exportparameter\c!file}%
+ export {\backendparameter\c!export}%
+ \relax}
+
+\permanent\protected\def\dostopexport
+ {\enforced\glet\dostopexport\relax
+ \clf_finishexport}
+
+\appendtoks
+ \doinitializeexport
+\to \everysetupbackend
+
+\appendtoks
+ \ifexporting
+ \dostartexport
+ \fi
+\to \everystarttext
+
+% better (before pdf gets closed, so we can embed), but it needs testing:
+
+\appendtoks
+ \ifexporting
+ \dostopexport
+ \fi
+\to \everystoptext
+
+\appendtoks
+ \ifexporting
+ \dostartexport % in case it is done inside \starttext
+ \fi
+\to \everystartdocument
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-ext.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-ext.mkxl
new file mode 100644
index 00000000000..a3d9d2633e8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-ext.mkxl
@@ -0,0 +1,95 @@
+%D \module
+%D [ file=back-ext,
+%D version=2019.02.08, % and later, merged file
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=Output,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \registerctxluafile{back-ext}{autosuffix}
+
+\unprotect
+
+% \let\normalopenout \openout
+% \let\normalwrite \write
+% \let\normalcloseout\closeout
+% \let\normallatelua \latelua
+% \let\normalspecial \special
+
+% rotation
+
+\permanent\protected\def\dostartrotation#1%
+ {\forcecolorhack
+ \clf_startrotation#1\relax} % todo: implement without Q q
+
+\permanent\protected\def\dostoprotation
+ {\clf_stoprotation
+ \forcecolorhack}
+
+% scaling
+
+\permanent\protected\def\dostartscaling#1#2%
+ {\forcecolorhack
+ \clf_startscaling rx #1 ry #2\relax}
+
+\permanent\protected\def\dostopscaling
+ {\clf_stopscaling
+ \forcecolorhack}
+
+% mirroring
+
+\permanent\protected\def\dostartmirroring
+ {\clf_startmirroring}
+
+\permanent\protected\def\dostopmirroring
+ {\clf_stopmirroring}
+
+% transform
+
+\permanent\protected\def\dotransformnextbox#1#2#3#4#5#6%
+ {\dowithnextbox{\dodotransformnextbox{#1}{#2}{#3}{#4}{#5}{#6}}}
+
+\permanent\protected\def\dodotransformnextbox#1#2#3#4#5#6%
+ {\hpack
+ {\kern #5\onebasepoint
+ \raise#6\onebasepoint
+ \hpack
+ {\clf_startmatrix rx #1 sx #2 sy #3 ry #4\relax
+ \box\nextbox
+ \clf_stopmatrix}}}
+
+%D \macros
+%D {dostartclipping,dostopclipping}
+%D
+%D Clipping is implemented in such a way that an arbitrary code can be fed.
+%D
+%D \starttyping
+%D \dostartclipping {pathname} {width} {height}
+%D \dostopclipping
+%D \stoptyping
+
+\mutable\let\MPclippath\empty
+
+\permanent\protected\def\dostartclipping#1#2#3% we can move this to lua and only set a box here
+ {\forcecolorhack
+ \meta_grab_clip_path{#1}{#2}{#3}%
+ \clf_startclipping{\MPclippath}%
+ \glet\MPclippath\empty}
+
+\permanent\protected\def\dostopclipping
+ {\clf_stopclipping}
+
+%D This wrapper is needed when you use code that messes with e.g. local color
+%D directives, invisible for the rest of the machinery. It's only needed in very
+%D special cases, like around the above scaler directives:
+
+\permanent\protected\edef\hcontainer{\hpack \s!direction\directionlefttoright \s!container\space}
+\permanent\protected\edef\vcontainer{\vpack \s!direction\directionlefttoright \s!container\space}
+\permanent\protected\edef\tcontainer{\tpack \s!direction\directionlefttoright \s!container\space}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-ini.lmt
new file mode 100644
index 00000000000..92270574249
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-ini.lmt
@@ -0,0 +1,127 @@
+if not modules then modules = { } end modules ['back-ini'] = {
+ version = 1.001,
+ comment = "companion to back-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local next, type = next, type
+local format = string.format
+
+backends = backends or { }
+local backends = backends
+
+local context = context
+
+local trace = false trackers.register("backend", function(v) trace = v end)
+local report = logs.reporter("backend")
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+local setaction = nodes.tasks.setaction
+
+local implement = interfaces.implement
+local variables = interfaces.variables
+
+local texset = tex.set
+
+local nodeinjections = { }
+local codeinjections = { }
+local registrations = { }
+local tables = allocate()
+
+local function nothing()
+ return nil
+end
+
+backends.nothing = nothing
+
+local function donothing(t,k)
+ t[k] = nothing
+ return nothing
+end
+
+setmetatableindex(nodeinjections, donothing)
+setmetatableindex(codeinjections, donothing)
+setmetatableindex(registrations, donothing)
+
+local defaults = {
+ nodeinjections = nodeinjections,
+ codeinjections = codeinjections,
+ registrations = registrations,
+ tables = tables,
+}
+
+backends.defaults = defaults
+
+backends.nodeinjections = { } setmetatableindex(backends.nodeinjections, nodeinjections)
+backends.codeinjections = { } setmetatableindex(backends.codeinjections, codeinjections)
+backends.registrations = { } setmetatableindex(backends.registrations, registrations)
+backends.tables = { } setmetatableindex(backends.tables, tables)
+
+backends.current = "unknown"
+
+function backends.install(what)
+ if type(what) == "string" then
+ local backend = backends[what]
+ if backend then
+ if trace then
+ if backend.comment then
+ report("initializing backend %a, %a",what,backend.comment)
+ else
+ report("initializing backend %a",what)
+ end
+ end
+ backends.current = what
+ for category, default in next, defaults do
+ local target = backends[category]
+ local plugin = backend [category]
+ setmetatableindex(plugin, default)
+ setmetatableindex(target, plugin)
+ end
+ elseif trace then
+ report("no backend named %a",what)
+ end
+ end
+end
+
+statistics.register("used backend", function()
+ local bc = backends.current
+ if bc ~= "unknown" then
+ return format("%s (%s)",bc,backends[bc].comment or "no comment")
+ else
+ return nil
+ end
+end)
+
+-- can best be here
+
+interfaces.implement {
+ name = "setrealspaces",
+ arguments = "string",
+ actions = function(v)
+ setaction("shipouts","nodes.handlers.accessibility",v == variables.yes)
+ end
+}
+
+-- moved to here
+
+local included = table.setmetatableindex( {
+ context = true,
+ id = true,
+ metadata = true,
+ date = true,
+ id = true,
+ pdf = true,
+}, function(t,k)
+ return true
+end)
+
+backends.included = included
+
+-- could also be codeinjections
+
+function backends.getcallbackstate()
+ return { count = status.late_callbacks or 0 }
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-ini.mkxl
new file mode 100644
index 00000000000..fad9c1e709d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-ini.mkxl
@@ -0,0 +1,74 @@
+%D \module
+%D [ file=back-ini,
+%D version=2009.04.15,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Backend Macros / Initialization}
+
+\registerctxluafile{back-ini}{autosuffix}
+
+\unprotect
+
+%D Right from the start \CONTEXT\ had a backend system based on runtime pluggable
+%D code. As most backend issues involved specials and since postprocessors had not
+%D that much in common, we ended up with a system where we could switch backend as
+%D well as output code for multiple backends at the same time.
+%D
+%D Because \LUATEX\ has the backend built in, and since some backend issues have
+%D been moved to the frontend I decided to provide new backend code for \MKIV,
+%D starting with what was actually used.
+%D
+%D At this moment \DVI\ is no longer used for advanced document output and we
+%D therefore dropped support for this format. Future versions might support more
+%D backends again, but this has a low priority.
+
+%D The exact page model depends on the backend so we just define some variables that
+%D are used. A helper at the \LUA\ end will synchronize with the internal variables.
+%D We store these in the format.
+
+\ifdefined\everybackendshipout \else \newtoks\everybackendshipout \fi
+\ifdefined\everylastbackendshipout \else \newtoks\everylastbackendshipout \fi
+\ifdefined\everybackendlastinshipout \else \newtoks\everybackendlastinshipout \fi
+
+\installcorenamespace{backend}
+
+\installsetuponlycommandhandler \??backend {backend}
+
+%D \starttyping
+%D \setupbackend[space=yes]
+%D \stoptyping
+
+\appendtoks
+ \clf_setrealspaces{\backendparameter\c!space}%
+\to \everysetupbackend
+
+%D For the moment this is an experiment (defauls is pdf, but we also
+%D have lua, json and mps).
+%D
+%D \starttyping
+%D % \setupoutput[lua]
+%D % \setupoutput[json]
+%D % \setupoutput[mps]
+%D % \setupoutput[none] % for testing only
+%D % \setupoutput[empty] % for testing only
+%D
+%D \starttext
+%D \dorecurse{1000}{
+%D {\tf \red \samplefile{tufte}} \par
+%D {\bf \green \samplefile {ward}} \par
+%D {\sl \blue \samplefile{davis}} \par
+%D }
+%D \stoptext
+%D \stoptyping
+
+\permanent\protected\def\setupoutput[#1]{\clf_enabledriver{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-lua.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-lua.lmt
new file mode 100644
index 00000000000..dc836f12bb3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-lua.lmt
@@ -0,0 +1,366 @@
+if not modules then modules = { } end modules ['back-lua'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- we can remap fonts
+
+local fontproperties = fonts.hashes.properties
+local fontparameters = fonts.hashes.parameters
+local fontshapes = fonts.hashes.shapes
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
+local bpfactor = number.dimenfactors.bp
+local texgetbox = tex.getbox
+
+local rulecodes = nodes.rulecodes
+local normalrule_code = rulecodes.normal
+----- boxrule_code = rulecodes.box
+----- imagerule_code = rulecodes.image
+----- emptyrule_code = rulecodes.empty
+----- userrule_code = rulecodes.user
+----- overrule_code = rulecodes.over
+----- underrule_code = rulecodes.under
+----- fractionrule_code = rulecodes.fraction
+----- radicalrule_code = rulecodes.radical
+local outlinerule_code = rulecodes.outline
+
+-- todo : per instance
+
+local pages = { }
+local fonts = { }
+local names = { }
+local mapping = { }
+local used = { }
+local shapes = { }
+local glyphs = { }
+local buffer = { }
+local b = 0
+local converter = nil
+
+local compact = false -- true
+local shapestoo = true
+
+local x, y, d, f, c, w, h, t, r, o
+
+local function reset()
+ buffer = { }
+ b = 0
+ t = nil
+ x = nil
+ y = nil
+ d = nil
+ f = nil
+ c = nil
+ w = nil
+ h = nil
+ r = nil
+ o = nil
+end
+
+local function result()
+ -- todo: we're now still in the pdf backend but need different codeinjections
+ local codeinjections = backends.pdf.codeinjections
+ local getvariable = codeinjections.getidentityvariable or function() end
+ local jobname = environment.jobname or tex.jobname or "unknown"
+ return {
+ metadata = {
+ unit = "bp",
+ jobname = jobname,
+ title = getvariable("title") or jobname,
+ subject = getvariable("subject"),
+ author = getvariable("author"),
+ keywords = getvariable("keywords"),
+ time = os.date("%Y-%m-%d %H:%M"),
+ engine = environment.luatexengine .. " " .. environment.luatexversion,
+ context = environment.version,
+ },
+ fonts = fonts,
+ pages = pages,
+ shapes = shapes,
+ }
+end
+
+-- actions
+
+local function outputfilename(driver)
+ return tex.jobname .. "-output.lua"
+end
+
+local function save() -- might become a driver function that already is plugged into stopactions
+ local filename = outputfilename()
+ drivers.report("saving result in %a",filename)
+ starttiming(drivers)
+ local data = result()
+ if data then
+ io.savedata(filename,table.serialize(data))
+ end
+ stoptiming(drivers)
+end
+
+local function prepare(driver)
+ converter = drivers.converters.lmtx
+ luatex.registerstopactions(1,function()
+ save()
+ end)
+end
+
+local function initialize(driver,details)
+ reset()
+end
+
+local function finalize(driver,details)
+ local n = details.pagenumber
+ local b = details.boundingbox
+ pages[n] = {
+ number = n,
+ content = buffer,
+ boundingbox = {
+ b[1] * bpfactor,
+ b[2] * bpfactor,
+ b[3] * bpfactor,
+ b[4] * bpfactor,
+ },
+ }
+end
+
+local function wrapup(driver)
+end
+
+local function cleanup(driver)
+ reset()
+end
+
+local function convert(driver,boxnumber,pagenumber)
+ converter(driver,texgetbox(boxnumber),"page",pagenumber)
+end
+
+-- flushers
+
+local function updatefontstate(id)
+ if not mapping[id] then
+ local fn = #fonts + 1
+ mapping[id] = fn
+ local properties = fontproperties[id]
+ local parameters = fontparameters[id]
+ local filename = file.basename(properties.filename)
+ local fontname = properties.fullname or properties.fontname
+ if shapestoo then
+ if not names[fontname] then
+ local sn = #shapes+1
+ names[fontname] = sn
+ shapes[sn] = { }
+ glyphs[sn] = fontshapes[id].glyphs
+ end
+ end
+ fonts[fn] = {
+ filename = filename,
+ name = fontname,
+ size = parameters.size * bpfactor,
+ shapes = shapestoo and names[fontname] or nil,
+ }
+ end
+end
+
+local function flushcharacter(current, pos_h, pos_v, pos_r, font, char)
+ local fnt = mapping[font]
+ b = b + 1
+ buffer[b] = {
+ t = "glyph" ~= t and "glyph" or nil,
+ f = font ~= f and fnt or nil,
+ c = char ~= c and char or nil,
+ x = pos_h ~= x and (pos_h * bpfactor) or nil,
+ y = pos_v ~= y and (pos_v * bpfactor) or nil,
+ d = pos_r ~= d and (pos_r == 1 and "r2l" or "l2r") or nil,
+ }
+ t = "glyph"
+ f = font
+ c = char
+ x = pos_h
+ y = pos_v
+ d = pos_r
+ if shapestoo then
+ -- can be sped up if needed
+ local sn = fonts[fnt].shapes
+ local shp = shapes[sn]
+ if not shp[char] then
+ shp[char] = glyphs[sn][char]
+ end
+ end
+end
+
+local function rule(pos_h, pos_v, pos_r, size_h, size_v, rule_s, rule_o)
+ b = b + 1
+ buffer[b] = {
+ t = "rule" ~= t and "rule" or nil,
+ r = rule_s ~= r and rule_s or nil,
+ o = rule_s == "outline" and rule_o ~= o and (rule_o * bpfactor) or nil,
+ w = size_h ~= w and (size_h * bpfactor) or nil,
+ h = size_v ~= h and (size_v * bpfactor) or nil,
+ x = pos_h ~= x and (pos_h * bpfactor) or nil,
+ y = pos_v ~= y and (pos_v * bpfactor) or nil,
+ d = pos_r ~= d and (pos_r == 1 and "r2l" or "l2r") or nil,
+ }
+ t = "rule"
+ w = size_h
+ h = size_v
+ x = pos_h
+ y = pos_v
+ d = pos_r
+end
+
+local function flushrule(current, pos_h, pos_v, pos_r, size_h, size_v, subtype)
+ local rule_s, rule_o
+ if subtype == normalrule_code then
+ rule_s = "normal"
+ elseif subtype == outlinerule_code then
+ rule_s = "outline"
+ rule_o = getdata(current)
+ else
+ return
+ end
+ return rule(pos_h, pos_v, pos_r, size_h, size_v, rule_s, rule_o)
+end
+
+local function flushsimplerule(pos_h, pos_v, pos_r, size_h, size_v)
+ return rule(pos_h, pos_v, pos_r, size_h, size_v, "normal", nil)
+end
+
+local function flushspecialrule(pos_h, pos_v, pos_r, w, h, d, l, outline)
+ -- no l support yet
+ return rule(pos_h, pos_v - d, pos_r, w, h + d, outline and "outline" or "normal")
+end
+
+-- file stuff too
+-- todo: default flushers
+-- also color (via hash)
+
+-- installer
+
+drivers.install {
+ name = "lua",
+ actions = {
+ prepare = prepare,
+ initialize = initialize,
+ finalize = finalize,
+ wrapup = wrapup,
+ cleanup = cleanup,
+ convert = convert,
+ outputfilename = outputfilename,
+ },
+ flushers = {
+ updatefontstate = updatefontstate,
+ character = flushcharacter,
+ rule = flushrule,
+ simplerule = flushsimplerule,
+ specialrule = flushspecialrule,
+ }
+}
+
+-- actions
+
+local function outputfilename(driver)
+ return tex.jobname .. "-output.json"
+end
+
+local function save() -- might become a driver function that already is plugged into stopactions
+ local filename = outputfilename()
+ drivers.report("saving result in %a",filename)
+ starttiming(drivers)
+ local data = result()
+ if data then
+ if not utilities.json then
+ require("util-jsn")
+ end
+ io.savedata(filename,utilities.json.tostring(data,not compact))
+ end
+ stoptiming(drivers)
+end
+
+local function prepare(driver)
+ converter = drivers.converters.lmtx
+ luatex.registerstopactions(1,function()
+ save()
+ end)
+end
+
+-- installer
+
+drivers.install {
+ name = "json",
+ actions = {
+ prepare = prepare,
+ initialize = initialize,
+ finalize = finalize,
+ wrapup = wrapup,
+ cleanup = cleanup,
+ convert = convert,
+ outputfilename = outputfilename,
+ },
+ flushers = {
+ updatefontstate = updatefontstate,
+ character = flushcharacter,
+ rule = flushrule,
+ simplerule = flushsimplerule,
+ specialrule = flushspecialrule,
+ }
+}
+
+-- actions
+
+local function outputfilename(driver)
+ return tex.jobname .. "-output.js"
+end
+
+local function save() -- might become a driver function that already is plugged into stopactions
+ local filename = outputfilename()
+ drivers.report("saving result in %a",filename)
+ starttiming(drivers)
+ local data = result()
+ if data then
+ if not utilities.json then
+ require("util-jsn")
+ end
+ io.savedata(filename,
+ "const JSON_CONTEXT = JSON.parse ( `" ..
+ utilities.json.tostring(data,not compact) ..
+ "` ) ;\n"
+ )
+ end
+ stoptiming(drivers)
+end
+
+local function prepare(driver)
+ converter = drivers.converters.lmtx
+ luatex.registerstopactions(1,function()
+ save()
+ end)
+end
+
+-- installer
+
+drivers.install {
+ name = "js",
+ actions = {
+ prepare = prepare,
+ initialize = initialize,
+ finalize = finalize,
+ wrapup = wrapup,
+ cleanup = cleanup,
+ convert = convert,
+ outputfilename = outputfilename,
+ },
+ flushers = {
+ updatefontstate = updatefontstate,
+ character = flushcharacter,
+ rule = flushrule,
+ simplerule = flushsimplerule,
+ specialrule = flushspecialrule,
+ }
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-lua.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-lua.mkxl
new file mode 100644
index 00000000000..0fb1bcc88ef
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-lua.mkxl
@@ -0,0 +1,16 @@
+%D \module
+%D [ file=back-lua,
+%D version=2018.07.26,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=\LUA,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{back-lua}{autosuffix,optimize}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-mps.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-mps.lmt
new file mode 100644
index 00000000000..4a2a573c459
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-mps.lmt
@@ -0,0 +1,210 @@
+if not modules then modules = { } end modules ['back-mps'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local fontproperties = fonts.hashes.properties
+local fontparameters = fonts.hashes.parameters
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
+local bpfactor = number.dimenfactors.bp
+local texgetbox = tex.getbox
+local formatters = string.formatters
+
+local rulecodes = nodes.rulecodes
+local normalrule_code = rulecodes.normal
+----- boxrule_code = rulecodes.box
+----- imagerule_code = rulecodes.image
+----- emptyrule_code = rulecodes.empty
+----- userrule_code = rulecodes.user
+----- overrule_code = rulecodes.over
+----- underrule_code = rulecodes.under
+----- fractionrule_code = rulecodes.fraction
+----- radicalrule_code = rulecodes.radical
+local outlinerule_code = rulecodes.outline
+
+local fonts = { }
+local pages = { }
+local buffer = { }
+local b = 0
+local converter = nil
+
+local function reset()
+ buffer = { }
+ b = 0
+end
+
+local f_font = formatters[ "\\definefont[%s][file:%s*none @ %sbp]\n" ]
+
+local f_glyph = formatters[ [[draw textext.drt("\%s\char%i\relax") shifted (%N,%N);]] ]
+local f_rule = formatters[ [[fill unitsquare xscaled %N yscaled %N shifted (%N,%N);]] ]
+local f_outline = formatters[ [[draw unitsquare xscaled %N yscaled %N shifted (%N,%N);]] ]
+
+-- actions
+
+local function outputfilename(driver)
+ return tex.jobname .. "-output.tex"
+end
+
+local function save() -- might become a driver function that already is plugged into stopactions
+ starttiming(drivers)
+ if #pages > 0 then
+ local filename = outputfilename()
+ drivers.report("saving result in %a",filename)
+ reset()
+ b = b + 1
+ buffer[b] = "\\starttext\n"
+ for k, v in table.sortedhash(fonts) do
+ b = b + 1
+ buffer[b] = f_font(v.name,v.filename,v.size)
+ end
+ for i=1,#pages do
+ b = b + 1
+ buffer[b] = pages[i]
+ end
+ b = b + 1
+ buffer[b] = "\\stoptext\n"
+ io.savedata(filename,table.concat(buffer,"",1,b))
+ end
+ stoptiming(drivers)
+end
+
+local function prepare(driver)
+ converter = drivers.converters.lmtx
+ luatex.registerstopactions(1,function()
+ save()
+ end)
+end
+
+local function initialize(driver,details)
+ reset()
+ b = b + 1
+ buffer[b] = "\n\\startMPpage"
+end
+
+local function finalize(driver,details)
+ b = b + 1
+ buffer[b] = "\\stopMPpage\n"
+ pages[details.pagenumber] = table.concat(buffer,"\n",1,b)
+end
+
+local function wrapup(driver)
+end
+
+local function cleanup(driver)
+ reset()
+end
+
+local function convert(driver,boxnumber,pagenumber)
+ converter(driver,texgetbox(boxnumber),"page",pagenumber)
+end
+
+-- flushers
+
+local last
+
+local function updatefontstate(id)
+ if fonts[id] then
+ last = fonts[id].name
+ else
+ last = "MPSfont" .. converters.Characters(id)
+ fonts[id] = {
+ filename = file.basename(fontproperties[id].filename),
+ size = fontparameters[id].size * bpfactor,
+ name = last,
+ }
+ end
+end
+
+local function flushcharacter(current, pos_h, pos_v, pod_r, font, char)
+ b = b + 1
+ buffer[b] = f_glyph(last,char,pos_h*bpfactor,pos_v*bpfactor)
+end
+
+local function flushrule(current, pos_h, pos_v, pod_r, size_h, size_v, subtype)
+ if subtype == normalrule_code then
+ b = b + 1
+ buffer[b] = f_rule(size_h*bpfactor,size_v*bpfactor,pos_h*bpfactor,pos_v*bpfactor)
+ elseif subtype == outlinerule_code then
+ b = b + 1
+ buffer[b] = f_outline(size_h*bpfactor,size_v*bpfactor,pos_h*bpfactor,pos_v*bpfactor)
+ end
+end
+
+local function flushsimplerule(pos_h, pos_v, pod_r, size_h, size_v)
+ flush_rule(false,pos_h,pos_v,pod_r,size_h,size_v,normalrule_code)
+end
+
+local function flushspecialrule(pos_h, pos_v, pod_r, w, h, d, l, outline)
+ flush_rule(false,pos_h,pos_v-d,pod_r,w,h+d,outline and outlinerule_code or normalrule_code)
+end
+
+-- installer
+
+drivers.install {
+ name = "mps",
+ actions = {
+ prepare = prepare,
+ initialize = initialize,
+ finalize = finalize,
+ wrapup = wrapup,
+ cleanup = cleanup,
+ convert = convert,
+ outputfilename = outputfilename,
+ },
+ flushers = {
+ updatefontstate = updatefontstate,
+ character = flushcharacter,
+ rule = flushrule,
+ simplerule = flushsimplerule,
+ specialrule = flushspecialrule,
+ }
+}
+
+-- extras
+
+-- if not mp then
+-- return
+-- end
+--
+-- local mpprint = mp.print
+-- local formatters = string.formatters
+--
+-- local f_glyph = formatters[ [[draw textext.drt("\setfontid%i\relax\char%i\relax") shifted (%N,%N);]] ]
+-- local f_rule = formatters[ [[fill unitsquare xscaled %N yscaled %N shifted (%N,%N);]] ]
+--
+-- local current = nil
+-- local size = 0
+--
+-- function mp.place_buffermake(box)
+-- drivers.convert("mps",box)
+-- current = drivers.action("mps","fetch")
+-- size = #current
+-- end
+--
+-- function mp.place_buffersize()
+-- mpprint(size)
+-- end
+--
+-- function mp.place_bufferslot(i)
+-- if i > 0 and i <= size then
+-- local b = buffer[i]
+-- local t = b[1]
+-- if t == "glyph" then
+-- mpprint(f_glyph(b[2],b[3],b[4]*bpfactor,b[5]*bpfactor))
+-- elseif t == "rule" then
+-- mpprint(f_rule(b[2]*bpfactor,b[3]*bpfactor,b[4]*bpfactor,b[5]*bpfactor))
+-- end
+-- end
+-- end
+--
+-- function mp.place_bufferwipe()
+-- current = nil
+-- size = 0
+-- end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-mps.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-mps.mkxl
new file mode 100644
index 00000000000..d4d428d4203
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-mps.mkxl
@@ -0,0 +1,16 @@
+%D \module
+%D [ file=back-mps,
+%D version=2018.07.26,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=\METAPOST,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{back-mps}{autosuffix,optimize}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-pdf.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-pdf.lmt
new file mode 100644
index 00000000000..44d0230bdd6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-pdf.lmt
@@ -0,0 +1,55 @@
+if not modules then modules = { } end modules ['back-pdf'] = {
+ version = 1.001,
+ comment = "companion to back-pdf.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- We hide the pdf table from users so that we can guarantee no interference with
+-- the way we manage resources, info, etc. Users should use the \type {lpdf}
+-- interface instead. If needed I will provide replacement functionality.
+
+local setmetatableindex = table.setmetatableindex
+
+local pdfsetcompression
+local pdfimmediateobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfsetcompression = lpdf.setcompression
+ pdfimmediateobject = lpdf.immediateobject
+end)
+
+interfaces.implement {
+ name = "setpdfcompression",
+ arguments = { "integer", "integer" },
+ actions = function(...) pdfsetcompression(...) end,
+}
+
+do
+
+ local dummy = function() end
+ local report = logs.reporter("backend")
+
+ local function unavailable(t,k)
+ report("calling unavailable pdf.%s function",k)
+ t[k] = dummy
+ return dummy
+ end
+
+ updaters.register("backend.update",function()
+ --
+ -- For now we keep this for tikz. If really needed some more can be made
+ -- accessible but it has to happen in a controlled way then, for instance
+ -- by first loading or enabling some compatibility layer so that we can
+ -- trace possible interferences.
+ --
+ pdf = {
+ immediateobj = pdfimmediateobject
+ }
+ setmetatableindex(pdf,unavailable)
+ end)
+
+end
+
+backends.install("pdf")
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-pdf.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-pdf.mkxl
new file mode 100644
index 00000000000..d59c29bc01c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-pdf.mkxl
@@ -0,0 +1,157 @@
+%D \module
+%D [ file=back-pdf,
+%D version=2009.04.15,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=\PDF,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The less there is here, the better. After a decade it is time to remove the \type
+%D {\pdf*} ones completely. For the moment I keep them commented but even that will
+%D go away.
+
+\writestatus{loading}{ConTeXt Backend Macros / PDF}
+
+\registerctxluafile{lpdf-ini}{autosuffix,optimize}
+\registerctxluafile{lpdf-lmt}{autosuffix,optimize}
+\registerctxluafile{lpdf-col}{autosuffix}
+\registerctxluafile{lpdf-xmp}{autosuffix}
+\registerctxluafile{lpdf-ano}{autosuffix}
+\registerctxluafile{lpdf-res}{autosuffix}
+\registerctxluafile{lpdf-mis}{autosuffix}
+\registerctxluafile{lpdf-ren}{autosuffix}
+\registerctxluafile{lpdf-grp}{autosuffix}
+\registerctxluafile{lpdf-wid}{autosuffix}
+\registerctxluafile{lpdf-fld}{autosuffix}
+\registerctxluafile{lpdf-mov}{autosuffix}
+\registerctxluafile{lpdf-u3d}{autosuffix} % this will become a module
+%registerctxluafile{lpdf-swf}{} % this will become a module
+\registerctxluafile{lpdf-tag}{autosuffix}
+\registerctxluafile{lpdf-fmt}{autosuffix}
+\registerctxluafile{lpdf-pde}{autosuffix}
+\registerctxluafile{lpdf-img}{autosuffix,optimize}
+\registerctxluafile{lpdf-epa}{autosuffix}
+\registerctxluafile{lpdf-emb}{autosuffix,optimize}
+\registerctxluafile{lpdf-fnt}{autosuffix}
+\registerctxluafile{lpdf-rul}{autosuffix}
+
+\registerctxluafile{back-pdp}{autosuffix}
+\registerctxluafile{back-pdf}{autosuffix} % some code will move to lpdf-*
+
+\loadmkxlfile{back-u3d} % this will become a module
+%loadmkxlfile{back-swf} % this will become a module
+
+\unprotect
+
+%D We will minimize the number of calls to \PDF\ specific primitives and delegate
+%D all management and injection of code to the backend.
+%D
+%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
+%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
+%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
+%D have bad side effects.
+
+\permanent\protected\def\pdfextension{\clf_pdfextension}
+\permanent \def\pdffeedback {\clf_pdffeedback}
+\permanent \def\pdfvariable {\clf_pdfvariable}
+
+%D For the moment we keep this for tikz but hopefully it will at some point use
+%D the proper ones. Consider them obsolete:
+
+\permanent\protected\def\pdfliteral {\clf_pdfliteral}
+\permanent\protected\def\pdfobj {\clf_pdfobj}%
+\permanent\protected\def\pdflastobj {\numexpr\clf_pdflastobj\relax}
+\permanent\protected\def\pdfrefobj {\clf_pdfrefobj}
+
+\permanent\protected\def\pdfrestore {\pdfextension restore}
+\permanent\protected\def\pdfsave {\pdfextension save}
+\permanent\protected\def\pdfsetmatrix{\pdfextension setmatrix}
+
+\permanent\let\pdfxform \saveboxresource
+\permanent\let\pdflastxform\lastsavedboxresourceindex
+\permanent\let\pdfrefxform \useboxresource
+
+%D Here are quick and dirty compression flippers, mostly used when testing something
+%D as one can best stick to the defaults that also adapt to specific standards.
+
+\permanent\protected\def\nopdfcompression {\clf_setpdfcompression\zerocount\zerocount}
+\permanent\protected\def\onlypdfobjectcompression{\clf_setpdfcompression\zerocount\plusthree}
+\permanent\protected\def\maximumpdfcompression {\clf_setpdfcompression\plusnine \plusnine }
+\permanent\protected\def\normalpdfcompression {\clf_setpdfcompression\plusthree\plusthree}
+
+%D PDF/X (maybe combine the two lua calls)
+
+\setupbackend
+ [xmpfile=]
+
+\appendtoks
+ \edef\p_file{\backendparameter{xmpfile}}%
+ \ifempty\p_file\else
+ \clf_setxmpfile{\p_file}%
+ \fi
+\to \everysetupbackend
+
+%D This will change:
+
+\appendtoks
+ \clf_setformat
+ format {\backendparameter\c!format}%
+ level {\backendparameter\c!level}%
+ option {\backendparameter\c!option}%
+ profile {\backendparameter\c!profile}%
+ intent {\backendparameter\c!intent}%
+ file {\backendparameter\c!file}%
+ \relax
+\to \everysetupbackend
+
+%D These are the only official methods to add stuff to the resources. If more is
+%D needed for third party low level code, it can be added.
+
+\permanent\protected\def\pdfbackendsetcatalog #1#2{\clf_lpdf_addtocatalog{#1}{#2}}
+\permanent\protected\def\pdfbackendsetinfo #1#2{\clf_lpdf_addtoinfo{#1}{#2}}
+\permanent\protected\def\pdfbackendsetname #1#2{\clf_lpdf_addtonames{#1}{#2}}
+
+\permanent\protected\def\pdfbackendsetpageattribute #1#2{\clf_lpdf_addtopageattributes{#1}{#2}}
+\permanent\protected\def\pdfbackendsetpagesattribute#1#2{\clf_lpdf_addtopagesattributes{#1}{#2}}
+\permanent\protected\def\pdfbackendsetpageresource #1#2{\clf_lpdf_addtopageresources{#1}{#2}}
+
+\permanent\protected\def\pdfbackendsetextgstate #1#2{\clf_lpdf_adddocumentextgstate{#1}{#2}}
+\permanent\protected\def\pdfbackendsetcolorspace #1#2{\clf_lpdf_adddocumentcolorspace{#1}{#2}}
+\permanent\protected\def\pdfbackendsetpattern #1#2{\clf_lpdf_adddocumentpattern{#1}{#2}}
+\permanent\protected\def\pdfbackendsetshade #1#2{\clf_lpdf_adddocumentshade{#1}{#2}}
+
+\permanent \def\pdfbackendcurrentresources {\clf_lpdf_collectedresources}
+\permanent \def\pdfcolor #1{\clf_lpdf_color\numexpr\rawcolorattribute{#1}\relax}
+
+%D This is a temporary hack mthat will be removed, improved or somehow can become
+%D default.
+
+\permanent\def\TransparencyHack{\setupcolors[\c!pagecolormodel=\v!auto]}
+
+%D Just in case one needs this \unknown:
+%D
+%D \starttyping
+%D text \pdfbackendactualtext{Meier}{Müller} text
+%D \stoptyping
+
+\permanent\protected\def\pdfbackendactualtext#1#2% not interfaced
+ {\clf_startactualtext{#2}%
+ #1%
+ \clf_stopactualtext}
+
+\aliased\let\pdfactualtext\pdfbackendactualtext
+
+%D Bah, this is also needed for tikz:
+
+\ifdefined\pdfsavepos\else
+ \permanent\let\pdfsavepos \savepos
+ \permanent\let\pdflastxpos\lastxpos
+ \permanent\let\pdflastypos\lastypos
+\fi
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-pdp.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-pdp.lmt
new file mode 100644
index 00000000000..1b3a1700790
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-pdp.lmt
@@ -0,0 +1,291 @@
+if not modules then modules = { } end modules ['back-pdp'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is temporary ... awaiting a better test .. basically we can
+-- always use this: pdf primitives.
+
+local context = context
+local lpdf = lpdf
+
+local pdfreserveobject
+local pdfcompresslevel
+local pdfobject
+local pdfpagereference
+local pdfgetxformname
+local pdfminorversion
+local pdfmajorversion
+
+updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+ pdfcompresslevel = lpdf.compresslevel
+ pdfobject = lpdf.object
+ pdfpagereference = lpdf.pagereference
+ pdfgetxformname = lpdf.getxformname
+ pdfminorversion = lpdf.minorversion
+ pdfmajorversion = lpdf.majorversion
+end)
+
+local tokenscanners = tokens.scanners
+local scanword = tokenscanners.word
+local scankeyword = tokenscanners.keyword
+local scanstring = tokenscanners.string
+local scaninteger = tokenscanners.integer
+local scanwhd = tokenscanners.whd
+
+local trace = false trackers.register("backend", function(v) trace = v end)
+local report = logs.reporter("backend")
+
+local nodepool = nodes.pool
+local newliteral = nodepool.literal
+local newsave = nodepool.save
+local newrestore = nodepool.restore
+local newsetmatrix = nodepool.setmatrix
+
+local implement = interfaces.implement
+local constants = interfaces.constants
+local variables = interfaces.variables
+
+-- literals
+
+local function pdf_literal()
+ context(newliteral(scanword() or "origin",scanstring()))
+end
+
+-- objects
+
+local lastobjnum = 0
+
+local function pdf_obj()
+ if scankeyword("reserveobjnum") then
+ lastobjnum = pdfreserveobject()
+ if trace then
+ report("\\pdfobj reserveobjnum: object %i",lastobjnum)
+ end
+ else
+ local immediate = true
+ local objnum = scankeyword("useobjnum") and scaninteger() or pdfreserveobject()
+ local uncompress = scankeyword("uncompressed") or pdfcompresslevel() == 0
+ local streamobject = scankeyword("stream")
+ local attributes = scankeyword("attr") and scanstring() or nil
+ local fileobject = scankeyword("file")
+ local content = scanstring()
+ local object = streamobject and {
+ type = "stream",
+ objnum = objnum,
+ immediate = immediate,
+ attr = attributes,
+ compresslevel = uncompress and 0 or nil,
+ } or {
+ type = "raw",
+ objnum = objnum,
+ immediate = immediate,
+ }
+ if fileobject then
+ object.file = content
+ -- object.filename = content
+ else
+ object.string = content
+ end
+ pdfobject(object)
+ lastobjnum = objnum
+ if trace then
+ report("\\pdfobj: object %i",lastobjnum)
+ end
+ end
+end
+
+local function pdf_lastobj()
+ context("%i",lastobjnum)
+ if trace then
+ report("\\lastobj: object %i",lastobjnum)
+ end
+end
+
+local function pdf_refobj()
+ local objnum = scaninteger()
+ if trace then
+ report("\\refobj: object %i (todo)",objnum)
+ end
+end
+
+-- annotations
+
+local lastobjnum = 0
+
+local function pdf_annot()
+ if scankeyword("reserveobjnum") then
+ lastobjnum = pdfreserveobject()
+ if trace then
+ report("\\pdfannot reserveobjnum: object %i",lastobjnum)
+ end
+ else
+ local width = false
+ local height = false
+ local depth = false
+ local data = false
+ local object = false
+ local attr = false
+ --
+ if scankeyword("useobjnum") then
+ object = scancount()
+ report("\\pdfannot useobjectnum is not (yet) supported")
+ end
+ local width, height, depth = scanwhd()
+ if scankeyword("attr") then
+ attr = scanstring()
+ end
+ data = scanstring()
+ context(backends.nodeinjections.annotation(width or 0,height or 0,depth or 0,data or ""))
+ end
+end
+
+local function pdf_dest()
+ local name = false
+ local zoom = false
+ local view = false
+ local width = false
+ local height = false
+ local depth = false
+ if scankeyword("num") then
+ report("\\pdfdest num is not (yet) supported")
+ elseif scankeyword("name") then
+ name = scanstring()
+ end
+ if scankeyword("xyz") then
+ view = "xyz"
+ if scankeyword("zoom") then
+ report("\\pdfdest zoom is ignored")
+ zoom = scancount() -- will be divided by 1000 in the backend
+ end
+ elseif scankeyword("fitbh") then
+ view = "fitbh"
+ elseif scankeyword("fitbv") then
+ view = "fitbv"
+ elseif scankeyword("fitb") then
+ view = "fitb"
+ elseif scankeyword("fith") then
+ view = "fith"
+ elseif scankeyword("fitv") then
+ view = "fitv"
+ elseif scankeyword("fitr") then
+ view = "fitr"
+ width, height, depth = scanwhd()
+ elseif scankeyword("fit") then
+ view = "fit"
+ end
+ context(backends.nodeinjections.destination(width or 0,height or 0,depth or 0,{ name or "" },view or "fit"))
+end
+
+-- management
+
+local function pdf_save()
+ context(newsave())
+end
+
+local function pdf_restore()
+ context(newrestore())
+end
+
+local function pdf_setmatrix()
+ context(newsetmatrix(scanstring()))
+end
+
+-- extras
+
+-- extensions: literal dest annot save restore setmatrix obj refobj colorstack
+-- startlink endlink startthread endthread thread outline glyphtounicode fontattr
+-- mapfile mapline includechars catalog info names trailer
+
+local extensions = {
+ literal = pdf_literal,
+ obj = pdf_obj,
+ refobj = pdf_refobj,
+ dest = pdf_dest,
+ annot = pdf_annot,
+ save = pdf_save,
+ restore = pdf_restore,
+ setmatrix = pdf_setmatrix,
+}
+
+local function pdf_extension()
+ local w = scanword()
+ if w then
+ local e = extensions[w]
+ if e then
+ e()
+ else
+ report("\\pdfextension: unsupported %a",w)
+ end
+ end
+end
+
+-- feedbacks: colorstackinit creationdate fontname fontobjnum fontsize lastannot
+-- lastlink lastobj pageref retval revision version xformname
+
+local feedbacks = {
+ lastobj = pdf_lastobj,
+ pageref = function() context(pdfpagereference()) end,
+ xformname = function() context(pdfgetxformname ()) end,
+}
+
+local function pdf_feedback()
+ local w = scanword()
+ if w then
+ local f = feedbacks[w]
+ if f then
+ f()
+ else
+ report("\\pdffeedback: unsupported %a",w)
+ end
+ end
+end
+
+-- variables: (integers:) compresslevel decimaldigits gamma gentounicode
+-- ignoreunknownimages imageaddfilename imageapplygamma imagegamma imagehicolor
+-- imageresolution inclusioncopyfonts inclusionerrorlevel majorversion minorversion
+-- objcompresslevel omitcharset omitcidset pagebox pkfixeddpi pkresolution
+-- recompress suppressoptionalinfo uniqueresname (dimensions:) destmargin horigin
+-- linkmargin threadmargin vorigin xformmargin (tokenlists:) pageattr pageresources
+-- pagesattr pkmode trailerid xformattr xformresources
+
+local variables = {
+ minorversion = function() context(pdfminorversion()) end,
+ majorversion = function() context(pdfmajorversion()) end,
+}
+
+local function pdf_variable()
+ local w = scanword()
+ if w then
+ local f = variables[w]
+ if f then
+ f()
+ else
+ report("\\pdfvariable: unsupported %a",w)
+ end
+ else
+ print("missing variable")
+ end
+end
+
+-- kept:
+
+implement { name = "pdfextension", actions = pdf_extension }
+implement { name = "pdffeedback", actions = pdf_feedback }
+implement { name = "pdfvariable", actions = pdf_variable }
+
+-- for the moment (tikz)
+
+implement { name = "pdfliteral", actions = pdf_literal }
+implement { name = "pdfobj", actions = pdf_obj }
+implement { name = "pdflastobj", actions = pdf_lastobj }
+implement { name = "pdfrefobj", actions = pdf_refobj }
+--------- { name = "pdfannot", actions = pdf_annot }
+--------- { name = "pdfdest", actions = pdf_dest }
+--------- { name = "pdfsave", actions = pdf_save }
+--------- { name = "pdfrestore", actions = pdf_restore }
+--------- { name = "pdfsetmatrix", actions = pdf_setmatrix }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-res.lmt b/Master/texmf-dist/tex/context/base/mkxl/back-res.lmt
new file mode 100644
index 00000000000..3157b37ef61
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-res.lmt
@@ -0,0 +1,177 @@
+if not modules then modules = { } end modules ['back-res'] = {
+ version = 1.001,
+ comment = "companion to back-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local context = context
+
+local trace = false trackers.register("backend", function(v) trace = v end)
+local report = logs.reporter("backend")
+
+local scanners = tokens.scanners
+local scankeyword = scanners.keyword
+local scaninteger = scanners.integer
+local scanstring = scanners.string
+local scandimension = scanners.dimension
+local scanword = scanners.word
+local scanwhd = scanners.whd
+
+local implement = interfaces.implement
+local constants = interfaces.constants
+local variables = interfaces.variables
+
+-- A box resource has an index. This happens to be an object number due to the pdf
+-- backend but in fact it's an abstraction. This is why we have explicit fetchers.
+-- The internal number (as in \Fm123) is yet another number.
+
+local tex_saveboxresource = tex.saveboxresource
+local tex_useboxresource = tex.useboxresource
+local tex_getboxresourcebox = tex.getboxresourcebox
+local tex_getboxresourcedimensions = tex.getboxresourcedimensions
+
+updaters.register("backend.update",function()
+ tex_saveboxresource = tex.saveboxresource
+ tex_useboxresource = tex.useboxresource
+ tex_getboxresourcebox = tex.getboxresourcebox
+ tex_getboxresourcedimensions = tex.getboxresourcedimensions
+end)
+
+local savebox = function(...) return tex_saveboxresource(...) end
+local usebox = function(...) return tex_useboxresource(...) end
+local getbox = function(...) return tex_getboxresourcebox(...) end
+local getwhd = function(...) return tex_getboxresourcedimensions(...) end
+
+local boxresources = {
+ save = savebox,
+ use = usebox,
+ getbox = getbox,
+ getdimensions = getwhd,
+}
+
+tex.boxresources = boxresources
+
+local lastindex = 0
+
+local function saveboxresource()
+ local immediate = true
+ local kind = scankeyword("type") and scaninteger() or 0
+ local attributes = scankeyword("attr") and scanstring() or nil
+ local resources = scankeyword("resources") and scanstring() or nil
+ local margin = scankeyword("margin") and scandimension() or 0 -- register
+ local boxnumber = scaninteger()
+ --
+ lastindex = savebox(boxnumber,attributes,resources,immediate,kind,margin)
+ if trace then
+ report("\\saveboxresource: index %i",lastindex)
+ end
+end
+
+local function lastsavedboxresourceindex()
+ if trace then
+ report("\\lastsaveboxresource: index %i",lastindex)
+ end
+ context("%i",lastindex)
+end
+
+local function useboxresource()
+ local width, height, depth = scanwhd()
+ local index = scaninteger()
+ local node = usebox(index,width,height,depth)
+ if trace then
+ report("\\useboxresource: index %i",index)
+ end
+ context(node)
+end
+
+implement { name = "saveboxresource", actions = saveboxresource }
+implement { name = "lastsavedboxresourceindex", actions = lastsavedboxresourceindex }
+implement { name = "useboxresource", actions = useboxresource }
+
+-- image resources
+
+local imageresources = { }
+local lastindex = 0
+local lastpages = 1
+
+local function saveimageresource()
+ local width, height, depth = scanwhd()
+ local page = 1
+ local immediate = true
+ local margin = 0 -- or dimension
+ local attributes = scankeyword("attr") and scanstring() or nil
+ if scankeyword("named") then
+ scanstring() -- ignored
+ elseif scankeyword("page") then
+ page = scaninteger()
+ end
+ local userpassword = scankeyword("userpassword") and scanstring() or nil
+ local ownerpassword = scankeyword("ownerpassword") and scanstring() or nil
+ local visiblefilename = scankeyword("visiblefilename") and scanstring() or nil
+ local colorspace = scankeyword("colorspace") and scaninteger() or nil
+ local pagebox = scanword() or nil
+ local filename = scanstring()
+-- pcall
+ context.getfiguredimensions( { filename }, {
+ [constants.userpassword] = userpassword,
+ [constants.ownerpassword] = ownerpassword,
+ [constants.page] = page or 1,
+ [constants.size] = pagebox,
+ })
+ context.relax()
+ lastindex = lastindex + 1
+ lastpages = 1
+ imageresources[lastindex] = {
+ filename = filename,
+ page = page or 1,
+ size = pagebox,
+ width = width,
+ height = height,
+ depth = depth,
+ attr = attributes,
+ -- margin = margin,
+ }
+end
+
+local function lastsavedimageresourceindex()
+ context("%i",lastindex or 0)
+end
+
+local function lastsavedimageresourcepages()
+ context("%i",lastpages or 0) -- todo
+end
+
+local function useimageresource()
+ local width, height, depth = scanwhd()
+ if scankeyword("keepopen") then
+ -- ignored
+ end
+ local index = scaninteger()
+ local l = imageresources[index]
+ if l then
+ if not (width or height or depth) then
+ width = l.width
+ height = l.height
+ depth = l.depth
+ end
+ -- pcall / we could use a dedicated call instead:
+ context.externalfigure( { l.filename }, {
+ [constants.userpassword] = l.userpassword,
+ [constants.ownerpassword] = l.ownerpassword,
+ [constants.width] = width and (width .. "sp") or nil,
+ [constants.height] = height and (height .. "sp") or nil,
+ [constants.page] = l.page or 1,
+ [constants.size] = pagebox,
+ })
+ context.relax()
+ else
+ report("no valid image resource %a",index)
+ end
+end
+
+implement { name = "saveimageresource", actions = saveimageresource }
+implement { name = "lastsavedimageresourceindex", actions = lastsavedimageresourceindex }
+implement { name = "lastsavedimageresourcepages", actions = lastsavedimageresourcepages }
+implement { name = "useimageresource", actions = useimageresource }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-res.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-res.mkxl
new file mode 100644
index 00000000000..8a18eef991f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-res.mkxl
@@ -0,0 +1,34 @@
+%D \module
+%D [ file=back-res,
+%D version=2019.05.23, % 2009.04.15,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=Resources,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Backend Macros / Resources}
+
+\registerctxluafile{back-res}{autosuffix}
+
+\unprotect
+
+%D We overload the primitives with our own but use a bit of indirection for the
+%D purpose of tracing. Some of these are needed for packages like tikz.
+
+% todo: public implementors (we can update the lua code anyway)
+
+\permanent\protected\def\saveboxresource {\clf_saveboxresource}
+\permanent\protected\def\lastsavedboxresourceindex {\numexpr\clf_lastsavedboxresourceindex\relax}
+\permanent\protected\def\useboxresource {\clf_useboxresource}
+
+\permanent\protected\def\saveimageresource {\clf_saveimageresource}
+\permanent\protected\def\lastsavedimageresourceindex{\numexpr\clf_lastsavedimageresourceindex\relax}
+\permanent\protected\def\lastsavedimageresourcepages{\numexpr\clf_lastsavedimageresourcepages\relax}
+\permanent\protected\def\useimageresource {\clf_useimageresource}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/back-u3d.mkxl b/Master/texmf-dist/tex/context/base/mkxl/back-u3d.mkxl
new file mode 100644
index 00000000000..297dd554579
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/back-u3d.mkxl
@@ -0,0 +1,158 @@
+%D \module
+%D [ file=back-u3d,
+%D version=2009.04.15,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=U3D Experiment,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is only a placeholder that demonstrates the usage of u3d resources. The
+%D user interface is rather messy an might be improved. The files and setup is
+%D derived from an example by Michael Vidiassov.
+
+\endinput
+
+\starttext
+
+\startluaparameterset [u3d:myset:controls:1]
+ view = {
+ name = 'default',
+ bg = {1,1,1},
+ mag = 100,
+ coo = {0,0,0},
+ c2c = {0,0,1},
+ rot = {40,0,60},
+ roo = 6,
+ lights = 'CAD'
+ },
+ js = 'cloudq.js'
+\stopluaparameterset
+
+\startluaparameterset [u3d:myset:controls:2]
+ views = {
+ {
+ name = 'AnglePositioning',
+ bg = {1,1,1},
+ azimuth = 45,
+ altitude = 45,
+ roo = 50,
+ aac = 2.5,
+ lights = 'Artwork'
+ },
+ {
+ name = 'RotationPositioning',
+ bg = {1,1,1},
+ rot = {0,45,45},
+ roo = 50,
+ aac = 2.5,
+ lights = 'Artwork'
+ },
+ {
+ name = 'VectorPositioning',
+ bg = {1,0,0},
+ c2c = {1,1,math.sqrt(2)},
+ roo = 50,
+ aac = 2.5,
+ lights = 'CAD'
+ },
+ {
+ name = 'PositionPositioning',
+ bg = {1,0,0},
+ pos = {1+25,1+25,1+50/math.sqrt(2)},
+ aac = 2.5,
+ lights = 'CAD'
+ },
+ {
+ name = 'ortho',
+ bg = {1,1,1},
+ mag = 300,
+ lights = 'CAD',
+ crossection = {}
+ }
+ },
+ view = {
+ name = 'default',
+ bg = {1,1,1},
+ c2c = {-1,-1,0},
+ roo = 50,
+ aac = 2.5,
+ roll = 45,
+ lights = 'CAD',
+ crossection = {
+ normal = {-1,-1,-1},
+ transparent = true
+ },
+ nodes = {
+ {
+ name = 'xlabel',
+ visible = false
+ },
+ {
+ name = 'ylabel',
+ opacity = 0.5
+ },
+ {
+ name = 'zlabel',
+ rendermode = 'Wireframe'
+ }
+ }
+ }
+\stopluaparameterset
+
+\useexternalfigure
+ [cloudq]
+ [cloudq.u3d]
+ [width=0.7\textwidth,
+ height=.7\textwidth,
+ display=u3d:myset:display:1,
+ controls=u3d:myset:controls:1]
+
+\useexternalfigure
+ [axes]
+ [axes.u3d]
+ [width=0.7\textwidth,
+ height=.7\textwidth,
+ controls=u3d:myset:controls:1]
+
+\startluaparameterset[u3d:myset:display:2]
+ toolbar = true,
+ preview = 'cloudq.png'
+\stopluaparameterset
+
+\startluaparameterset[u3d:myset:display:3]
+ toolbar = true,
+ tree = false,
+ preview = 'axes.png'
+\stopluaparameterset
+
+\startluaparameterset[u3d:myset:display:4]
+ toolbar = true,
+ tree = false,
+ view = {
+ name = 'view',
+ bg = {0.1,0.1,0.1},
+ c2c = {-1,-1,0},
+ roo = 50,
+ aac = 2.5,
+ roll = 45,
+ lights = 'Red'
+ }
+\stopluaparameterset
+
+\startluaparameterset[u3d:myset:display:5]
+ toolbar = true,
+ tree = false,
+ view = 'ortho'
+\stopluaparameterset
+
+\placefigure[here]{none}{\externalfigure[cloudq][display=u3d:myset:display:2]}
+\placefigure[here]{none}{\externalfigure[axes] [display=u3d:myset:display:3]}
+\placefigure[here]{none}{\externalfigure[axes] [display=u3d:myset:display:4]}
+\placefigure[here]{none}{\externalfigure[axes] [display=u3d:myset:display:5,width=0.5\textwidth,height=.5\textwidth]}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/bibl-bib.mkxl b/Master/texmf-dist/tex/context/base/mkxl/bibl-bib.mkxl
new file mode 100644
index 00000000000..20aea7bb612
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/bibl-bib.mkxl
@@ -0,0 +1,983 @@
+%D \module
+%D [ file=bibl-bib,
+%D version=2007.08.17,
+%D title=\CONTEXT\ Bibliography Support,
+%D subtitle=Initialization,
+%D author=Hans Hagen \& Taco Hoekwater,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is really obsolete in \LMTX. For now I keep it but it will either go
+%D away. The code is not upgraded, we only deal with macro protection. I will
+%D only update the bits that annoy me in grepping for possible optimizations.
+
+\writestatus{loading}{ConTeXt Bibliography Support / Experimental BibTeX}
+
+\registerctxluafile{bibl-bib}{}
+
+\unprotect
+
+% todo: et al limiters
+% todo: split: citationvariant and publicationvariant
+
+%D This interface is under development. As I don't use \BIBTEX\ myself I need some
+%D motivation to spend time on it, and an occasional question on the list can be a
+%D reason. A few examples. As \BIBTEX\ databases can be poluted by local commands,
+%D we need to catch:
+%D
+%D \startbuffer
+%D \defbibtexcommand\MF {MF}
+%D \defbibtexcommand\MP {MP}
+%D \defbibtexcommand\TUB {TUGboat}
+%D \defbibtexcommand\Mc {Mac}
+%D \defbibtexcommand\sltt{\tt}
+%D \defbibtexcommand\<#1>{\type{#1}}
+%D \defbibtexcommand\acro#1{#1}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D Let's define a session and load a few databases. We convert to \UTF\ and strip
+%D commands.
+%D
+%D \startbuffer
+%D \definebibtexsession [somebibtex]
+%D \registerbibtexfile [somebibtex] [tugboat.bib]
+%D \registerbibtexfile [somebibtex] [komoedie.bib]
+%D \preparebibtexsession [somebibtex] [convert,strip]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D This loads an mapping (work in progress):
+%D
+%D \startbuffer
+%D \def\currentbibtexformat{apa} \input bxml-\currentbibtexformat.mkiv
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D There are several ways to handle the \XML. It helps if you're a bit familiar with
+%D \XML\ processing in \MKIV.
+%D
+%D Here we regular setups. Three elements are mapped but only one is actually used
+%D and applied to root element \type {/bibtex}.
+%D
+%D \startbuffer
+%D \startxmlsetups bibtex
+%D \xmlregistereddocumentsetups{#1}{}
+%D \xmlsetsetup{#1}{bibtex|entry|field}{bibtex:*}
+%D \xmlmain{#1}
+%D \stopxmlsetups
+%D
+%D \startxmlsetups bibtex:bibtex
+%D \xmlfilter{#1}{
+%D /entry[@category='article']
+%D /field[@name='author' and (find(text(),'Hagen') or find(text(),'Hoekwater'))]
+%D /../command(bibtex:format)
+%D }
+%D \stopxmlsetups
+%D
+%D \applytobibtexsession[somebibtex][bibtex]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D A simpler setup is given next. Here we just apply a setup to the root element
+%D directly:
+%D
+%D \startbuffer
+%D \startxmlsetups bibtex:list
+%D \xmlfilter{#1}{/bibtex/entry/command(bibtex:format)}
+%D \stopxmlsetups
+%D
+%D \applytobibtexsession[somebibtex][bibtex:list]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D A slightly more complex expression:
+%D
+%D \startbuffer
+%D \startxmlsetups bibtex:filter
+%D \xmlfilter{#1}{
+%D /bibtex
+%D /entry[@category='article']
+%D /field[@name='author' and (find(text(),'Hagen') or find(text(),'Hoekwater'))]
+%D /../command(bibtex:format)
+%D }
+%D \stopxmlsetups
+%D
+%D \applytobibtexsession[somebibtex][bibtex:filter]
+%D \stopbuffer
+%D
+%D \typebuffer
+
+\newtoks \everydefinebibtexsession
+\newtoks \everypreparebibtexsession
+\newtoks \everysetupbibtexsession
+\setfalse \tracebibtexformat
+
+\protected\def\definebibtexsession {\dosingleargument\dodefinebibtexsession}
+ \def\preparebibtexsession{\dodoubleempty \dopreparebibtexsession}
+\protected\def\setupbibtexsession {\dodoubleargument\dosetupbibtexsession}
+
+\def\dodefinebibtexsession [#1]{\edef\currentbibtexsession{#1}%
+ \ctxcommand{definebibtexsession("#1")}%
+ \the\everydefinebibtexsession}
+
+\def\dopreparebibtexsession[#1][#2]{\edef\currentbibtexsession{#1}%
+ \ctxcommand{preparebibtexsession("#1","bibtex:#1","#2")}%
+ \the\everypreparebibtexsession}
+
+\def\dosetupbibtexsession [#1][#2]{\edef\currentbibtexsession{#1}%
+ \getparameters[\??pb#1][#2]%
+ \the\everysetupbibtexsession}
+
+\def\registerbibtexfile {\dodoubleargument\doregisterbibtexfile}
+\def\registerbibtexentry {\dodoubleargument\doregisterbibtexentry}
+\def\applytobibtexsession {\dodoubleargument\doapplytobibtexsession}
+
+\def\doregisterbibtexfile [#1][#2]{\ctxcommand{registerbibtexfile("#1","#2")}}
+\def\doregisterbibtexentry [#1][#2]{\ctxcommand{registerbibtexentry("#1","#2")}}
+\def\doapplytobibtexsession[#1][#2]{\xmlprocess{bibtex:#1}{#2}{#2}}
+
+\protected\def\bibtexcommand#1%
+ {\ifcsname\??pb:c:#1\endcsname \else
+ \fakebibtexcommand{#1}%
+ \fi
+ \csname\??pb:c:#1\endcsname}
+
+\def\fakebibtexcommand#1%
+ {\ifcsname#1\endcsname
+ \writestatus{bibtex}{unknown command: #1, using built-in context variant}%
+ \setugvalue{\??pb:c:#1}{\dosomebibtexcommand{#1}}%
+ \else
+ \writestatus{bibtex}{unknown command: #1}%
+ \setugvalue{\??pb:c:#1}{\dofakebibtexcommand{#1}}%
+ \fi}
+
+\let\dosomebibtexcommand \getvalue
+\def\dofakebibtexcommand#1{{\tttf#1}}
+\def\defbibtexcommand #1{\setuvalue{\strippedcsname#1}}
+
+\def\bibxmldoifelse#1{\xmldoifelse\currentbibxmlnode{/field[@name='#1']}}
+\def\bibxmldoif #1{\xmldoif \currentbibxmlnode{/field[@name='#1']}}
+\def\bibxmldoifnot #1{\xmldoifnot \currentbibxmlnode{/field[@name='#1']}}
+\def\bibxmlflush #1{\xmlcontext \currentbibxmlnode{/field[@name='#1']}}
+\def\bibxmlsetup {\xmlsetup \currentbibxmlnode} % {#1}
+
+\def\currentbibtexformat{apa} % how to interface this, maybe split loading and key
+\def\currentbibxmlnode {unset}
+\def\currentbibxmltag {unset}
+
+\startxmlsetups bibtex
+ \xmlregistereddocumentsetups{#1}{}
+ \xmlsetsetup{#1}{bibtex|entry|field}{bibtex:*}
+ \xmlmain{#1}
+\stopxmlsetups
+
+\startxmlsetups bibtex:format
+ \bibtexpublicationsparameter\c!before\relax % prevents lookahead
+ \edef\currentbibxmlnode {#1}
+ \edef\currentbibxmltag {\xmlatt{#1}{tag}}
+ \edef\currentbibxmlcategory{\xmlatt{#1}{category}}
+ \ifconditional\tracebibtexformat
+ \tracedbibxmlintro\currentbibxmltag
+ \tracedbibxmlintro\currentbibxmlcategory
+ \fi
+ \ignorespaces
+ \xmlcommand{#1}{.}{bibtex:\currentbibtexformat:\currentbibxmlcategory}
+ \removeunwantedspaces
+ \bibtexpublicationsparameter\c!after\relax % prevents lookahead
+\stopxmlsetups
+
+\startxmlsetups bibtex:list
+ \xmlfilter{#1}{/bibtex/entry/command(bibtex:format)}
+\stopxmlsetups
+
+\startxmlsetups bibtex:bibtex
+ \xmlfilter{#1}{/entry/command(bibtex:format)}
+\stopxmlsetups
+
+% formatters
+
+\let\normalbibxmlflush\bibxmlflush
+
+\definecolor[bibtextracecolor:field] [darkred]
+\definecolor[bibtextracecolor:crossref][darkblue]
+\definecolor[bibtextracecolor:key] [darkgreen]
+
+\def\tracedbibxmlintro #1{{\tttf#1 -> }}
+\def\tracedbibxmlflush #1{\color[bibtextracecolor:field] {\tttf[#1]}}
+\def\tracedbibxmltexts #1{\color[bibtextracecolor:field] {\tttf<#1>}}
+\def\tracedbibxmlcrossref#1{\color[bibtextracecolor:crossref]{\tttf#1}}
+\def\tracedbibxmlkey #1{\color[bibtextracecolor:key] {\tttf#1}}
+
+\def\tracedbibxmltext
+ {\ifconditional\tracebibtexformat
+ \expandafter\tracedbibxmltexts % plural
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+\def\bibxmlflush
+ {\ifconditional\tracebibtexformat
+ \expandafter\tracedbibxmlflush
+ \else
+ \expandafter\normalbibxmlflush
+ \fi}
+
+\startxmlsetups bibtex:format:crossref
+ \ifconditional\tracebibtexformat
+ \tracedbibxmlcrossref{\xmlfirst\currentbibxmlnode{/field[@name='crossref']/lower()}}
+ \else
+ \cite[\xmlfirst\currentbibxmlnode{/field[@name='crossref']/lower()}]
+ \fi
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:key
+ \ifconditional\tracebibtexformat
+ \tracedbibxmlkey{\normalbibxmlflush{key}}
+ \else
+ \bibxmlflush{key}
+ \fi
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:common:author
+ \ifconditional\tracebibtexformat
+ \bibxmlflush\currentbibtexvariant
+ \else
+ \xmlfilter{#1}{/field[@name='\currentbibtexvariant']/bibtexconcat('\currentbibtexvariant')}
+ \fi
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:author
+ \begingroup
+ \def\currentbibtexvariant{author}
+ \xmlsetup{#1}{bibtex:format:common:author}
+ \endgroup
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:artauthor
+ \begingroup
+ \def\currentbibtexvariant{artauthor}
+ \xmlsetup{#1}{bibtex:format:common:author}
+ \endgroup
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:editor
+ \begingroup
+ \def\currentbibtexvariant{editor}
+ \xmlsetup{#1}{bibtex:format:common:author}
+ \endgroup
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:doi
+% \bibdoifelse{\@@pb@doi}{#1\expanded{\bibgotoDOI{\@@pb@thekey}{\@@pb@doi}}#2}{#3}
+ *doi*
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:doi
+% \bibdoifelse{\@@pb@biburl}{#1\expanded{\bibgotoURL{\@@pb@thekey}{\@@pb@biburl}}#2}{#3}
+ *url*
+\stopxmlsetups
+
+\startxmlsetups bibtex:format:month
+% {\bibdoifelse\@@pb@month
+% {#1\doifnumberelse\@@pb@month
+% {\doifconversiondefinedelse\@@pbmonthconversion
+% {\convertnumber\@@pbmonthconversion\@@pb@month}{\@@pb@month}}%
+% {\@@pb@month}#2}%
+% {#3}
+ *month*
+\stopxmlsetups
+
+% lists
+
+\def\bibtexlistprocessor
+ {\ctxlua{bibtex.hacks.add(structures.lists.uservalue("\currentlist",\currentlistindex,"bibref"),\currentlistindex)}}
+
+\appendtoks
+ \definelist[\currentbibtexsession]%
+ \setuplist[\currentbibtexsession][\c!state=\v!start,\c!width=]%
+ \installstructurelistprocessor{\currentbibtexsession:userdata}{\bibtexlistprocessor}%
+\to \everydefinebibtexsession
+
+% \def\installbibtexsorter#1#2%
+% {\setvalue{\??pb:\c!sort:#1}{#2}}
+
+% \installbibtexsorter\v!no {no}
+% \installbibtexsorter\v!author {au}
+% \installbibtexsorter\v!title {ti}
+% \installbibtexsorter\v!short {ab}
+% \installbibtexsorter\empty {no}
+% \installbibtexsorter\s!default{no}
+
+% \setupbibtex
+% [\c!sorttype=\v!cite,
+% \c!sort=no]
+
+% \protected\def\startpublication#1\stoppublication
+% {\blank
+% todo
+% \blank}
+
+% \let\stoppublication\relax
+
+\protected\def\bibtexspace {\removeunwantedspaces\space}
+\protected\def\bibtexperiod {\removeunwantedspaces.\space}
+\protected\def\bibtexcomma {\removeunwantedspaces,\space}
+\protected\def\bibtexlparent {\removeunwantedspaces\space(}
+\protected\def\bibtexrparent {\removeunwantedspaces)\space}
+\protected\def\bibtexlbracket{\removeunwantedspaces\space[}
+\protected\def\bibtexrbracket{\removeunwantedspaces]\space}
+
+% interfacing
+
+% todo : lang en language
+% todo : directions
+
+% variables
+
+\ifdefined\bibtexblock \else \newcount\bibtexblock \fi \bibtexblock\plusone
+\ifdefined\bibtexcounter \else \newcount\bibtexcounter \fi
+
+\newtoks \everysetupbibtexpublications
+\newtoks \everysetupbibtexcitations
+
+\def\bibtexrefprefix{\number\bibtexblock:}
+
+\let\currentbibtexsession\s!default
+\let\currentbibtexvariant\s!default
+
+% parameters: session+variant variant session shared
+
+\def\bibtexpublicationsparameter#1%
+ {\csname
+ \ifcsname\??pb\currentbibtexsession:\currentbibtexvariant#1\endcsname
+ \??pb\currentbibtexsession:\currentbibtexvariant#1%
+ \orelse\ifcsname\??pb:\currentbibtexvariant#1\endcsname
+ \??pb:\currentbibtexvariant#1%
+ \orelse\ifcsname\??pb\currentbibtexsession#1\endcsname
+ \??pb\currentbibtexsession#1%
+ \orelse\ifcsname\??pb#1\endcsname
+ \??pb#1%
+ \else
+ \s!empty
+ \fi
+ \endcsname}
+
+\def\bibtexcitationparameter#1%
+ {\csname
+ \ifcsname\??pv\currentbibtexsession:\currentbibtexvariant#1\endcsname
+ \??pv\currentbibtexsession:\currentbibtexvariant#1%
+ \orelse\ifcsname\??pv:\currentbibtexvariant#1\endcsname
+ \??pv:\currentbibtexvariant#1%
+ \orelse\ifcsname\??pv\currentbibtexsession#1\endcsname
+ \??pv\currentbibtexsession#1%
+ \orelse\ifcsname\??pv#1\endcsname
+ \??pv#1%
+ \else
+ \s!empty
+ \fi
+ \endcsname}
+
+% setup commands
+
+\protected\def\setupbibtexpublications
+ {\let\currentpublicationclass\??pb
+ \let\everysetupbibtexwhatever\everysetupbibtexpublications
+ \dosetupbibtexwhatever}
+
+\protected\def\setupbibtexcitations
+ {\let\currentpublicationclass\??pv
+ \let\everysetupbibtexwhatever\everysetupbibtexcitations
+ \dosetupbibtexwhatever}
+
+\protected\def\setupbibtexpublicationvariants
+ {\let\currentpublicationclass\??pb
+ \let\everysetupbibtexwhatever\everysetupbibtexpublications
+ \dosetupbibtexwhatevervariant}
+
+\protected\def\setupbibtexcitationvariants
+ {\let\currentpublicationclass\??pv
+ \let\everysetupbibtexwhatever\everysetupbibtexcitations
+ \dosetupbibtexwhatevervariant}
+
+\tolerant\def\dosetupbibtexwhatever[#1]#*[#2]% [sessionlist] [setup]
+ {\ifarguments\or
+ % setups
+ \getparameters[\currentpublicationclass][#1]%
+ \the\everysetupbibtexwhatever
+ \or
+ % sessions setups
+ \def\dobtxcommand##1{\getparameters[\currentpublicationclass##1][#2]}%
+ \processcommalist[#1]\dobtxcommand
+ \fi}
+
+\tolerant\def\dosetupbibtexwhatevervariant[#1]#*[#2]#*[#3]% [sessionlist] [variantlist] [setup]
+ {\ifarguments\or
+ % setups
+ \getparameters[\currentpublicationclass][#1]%
+ \the\everysetupbibtexwhatever
+ \or
+ % variants setups
+ \def\dobtxcommand##1{\getparameters[\currentpublicationclass:##1][#2]}%
+ \processcommalist[#1]\dobtxcommand
+ \or
+ % sessions variants setups
+ \def\dobtxcommand##1%
+ {\def\dodobtxcommand####1{\getparameters[\currentpublicationclass##1:####1][#3]}%
+ \processcommalist[#2]\dodobtxcommand}%
+ \processcommalist[#1]\docbtxommand
+ \fi}
+
+% some initializations
+
+\setupbibtexcitationvariants
+ [author,authoryear,authoryears]
+ [\c!namesep={, }]
+
+% loading alternatives (apa etc)
+
+\def\doloadbibtexpublicationalternative
+ {\ifproductionrun
+ \edef\bibtexpublicationsalternative{\@@pbalternative}% parent
+ \ifempty\bibtexpublicationsalternative \else
+ \processcommacommand[\bibtexpublicationsalternative]\dodoloadbibtexpublicationalternative
+ \let\@@pbalternative\empty
+ \fi
+ \fi}
+
+\def\dodoloadbibtexpublicationalternative#1%
+ {\doonlyonce{#1}
+ {\startreadingfile
+ \readsysfile{bxml-#1.mkiv}
+ {\showmessage\m!publications{6}{bxml-#1}}
+ {\showmessage\m!publications{1}{bxml-#1}}%
+ \stopreadingfile}}
+
+\appendtoks
+ \doloadbibtexpublicationalternative
+\to \everysetupbibtexpublications
+
+% we expect at least one invocation of the setup commands
+% because otherwise we always load the apa style even if
+% no publications are used
+%
+% \appendtoks
+% \doloadbibtexpublicationalternative
+% \to \everystarttext
+
+% whatever, should be key
+
+\def\bibtexleftnumber#1{#1\hfill~}
+
+% testing
+
+% \showmessage\m!publications{5}{#1 is unknown}\secondoftwoarguments}
+
+\let\doifbibreferencefoundelse\secondofthreearguments
+
+% lists
+
+\newtoks\everysetupbibtexlistplacement
+
+% this will change as we need it too often .. we will use context.thebibtexnamesep
+
+\appendtoks
+ \ctxlua {bibtex.authors.setsettings {
+ namesep = \!!bs\bibtexpublicationsparameter\c!namesep\!!es,
+ lastnamesep = \!!bs\bibtexpublicationsparameter\c!lastnamesep\!!es,
+ finalnamesep = \!!bs\bibtexpublicationsparameter\c!finalnamesep\!!es,
+ firstnamesep = \!!bs\bibtexpublicationsparameter\c!firstnamesep\!!es,
+ juniorsep = \!!bs\bibtexpublicationsparameter\c!juniorsep\!!es,
+ vonsep = \!!bs\bibtexpublicationsparameter\c!vonsep\!!es,
+ surnamesep = \!!bs\bibtexpublicationsparameter\c!surnamesep\!!es,
+ namesep = \!!bs\bibtexpublicationsparameter\c!namesep\!!es,
+ lastnamesep = \!!bs\bibtexpublicationsparameter\c!lastnamesep\!!es,
+ finalnamesep = \!!bs\bibtexpublicationsparameter\c!finalnamesep\!!es,
+ author = {
+ etallimit = \!!bs\bibtexpublicationsparameter\c!authoretallimit\!!es,
+ etaldisplay = \!!bs\bibtexpublicationsparameter\c!authoretaldisplay\!!es,
+ etaltext = \!!bs\bibtexpublicationsparameter\c!authoretaltext\!!es,
+ },
+ editor = {
+ etallimit = \!!bs\bibtexpublicationsparameter\c!editoretallimit\!!es,
+ etaldisplay = \!!bs\bibtexpublicationsparameter\c!editoretaldisplay\!!es,
+ etaltext = \!!bs\bibtexpublicationsparameter\c!editoretaltext\!!es,
+ },
+ artauthor = {
+ etallimit = \!!bs\bibtexpublicationsparameter\c!artauthoretallimit\!!es,
+ etaldisplay = \!!bs\bibtexpublicationsparameter\c!artauthoretaldisplay\!!es,
+ etaltext = \!!bs\bibtexpublicationsparameter\c!artauthoretaltext\!!es,
+ },
+ } }%
+\to \everysetupbibtexlistplacement
+
+\def\completebibtexpublications{\dodoubleempty\docompletebibtexpublications}
+\protected\def\placebibtexpublications {\dodoubleempty\doplacebibtexpublications}
+
+\def\docompletebibtexpublications[#1][#2]% title might become obsolete, just headtext
+ {\begingroup
+ \edef\currentbibtexsession{#1}%
+ \let\currentlist\currentbibtexsession
+ \setuplist[\currentbibtexsession][\c!criterium=\v!previous,#2]
+ \edef\currentbibtexsessiontitle{\namedlistparameter\currentbibtexsession\c!title}%
+ \ifempty\currentbibtexsessiontitle
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbibtexsession,\c!title={\headtext{\currentbibtexsession}}]}%
+ \else
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbibtexsession,\c!title={\currentbibtexsessiontitle}]}%
+ \fi
+ \dodoplacebibtexpublications
+ \stopnamedsection
+ \endgroup}
+
+\def\doplacebibtexpublications[#1][#2]%
+ {\begingroup
+ \edef\currentbibtexsession{#1}%
+ \let\currentlist\currentbibtexsession
+ \setuplist[\currentbibtexsession][\c!criterium=\v!previous,#2]%
+ \dodoplacebibtexpublications
+ \endgroup}
+
+\def\dodoplacebibtexpublications
+ {\determinelistcharacteristics[\currentbibtexsession]%
+ \the\everysetupbibtexlistplacement
+ \forgetall
+ \typesetbibtexlist
+ \global\advance\bibtexblock\plusone}
+
+\setvalue{\??pb:\c!numbering:\v!short}#1% todo var s -> short tag
+ {\bibtexlistnumberbox{\bibtexpublicationsparameter\c!numbercommand{\bibtexgetshort\currentpublicationtag}}}
+
+\setvalue{\??pb:\c!numbering:\v!bib}#1% todo var n -> number
+ {\bibtexlistnumberbox{\bibtexpublicationsparameter\c!numbercommand{\bibtexgetnumber\currentpublicationtag}}}
+
+\setvalue{\??pb:\c!numbering:\s!unknown}#1%
+ {\bibtexlistnumberbox{\bibtexpublicationsparameter\c!numbercommand{#1}}}
+
+\def\@@pblimitednumber % name
+ {\csname\??pb:\c!numbering:%
+ \ifcsname\??pb:\c!numbering:\currentbibtexnumbering\endcsname
+ \currentbibtexnumbering
+ \else
+ \s!unknown
+ \fi
+ \endcsname}
+
+\appendtoks
+ \edef\currentbibtexnumbering{\bibtexpublicationsparameter\c!numbering}%
+ \ifx\currentbibtexnumbering\v!no
+ \setuplist[\currentbibtexsession][\c!numbercommand=,\c!symbol=\v!none,\c!textcommand=\outdented]%
+ \else
+ \setuplist[\currentbibtexsession][\c!numbercommand=\@@pblimitednumber]%
+ \fi
+\to \everysetupbibtexlistplacement
+
+\newdimen\bibtexnumberwidth
+
+\def\bibtexlistnumberbox{\hbox \ifcase\bibtexnumberwidth\else to \bibtexnumberwidth\fi}
+
+\appendtoks
+ \doifelse{\bibtexpublicationsparameter\c!autohang}\v!yes
+ {\ifx\currentbibtexnumbering\v!short
+ \setbox\scratchbox\hbox{\bibtexpublicationsparameter\c!numbercommand{\bibtexpublicationsparameter\c!samplesize}}%
+ \else
+ \setbox\scratchbox\hbox{\bibtexpublicationsparameter\c!numbercommand{\ctxlua{tex.write(structures.lists.size())}}}%
+ \fi
+ \bibtexnumberwidth\wd\scratchbox
+ \setuplist[\currentbibtexsession][\c!distance=\zeropoint]}
+ {\doifelsenothing{\bibtexpublicationsparameter\c!width}
+ {\bibtexnumberwidth\zeropoint}
+ {\bibtexnumberwidth\bibtexpublicationsparameter\c!width}}%
+ \setuplist[\currentbibtexsession][\c!width=\bibtexnumberwidth]%
+\to \everysetupbibtexlistplacement
+
+\appendtoks
+ \let\maybeyear\gobbleoneargument
+ \let\noopsort \gobbleoneargument
+\to \everysetupbibtexlistplacement
+
+\appendtoks
+ \doifelse{\bibtexpublicationsparameter\c!maybeyear}\v!off
+ {\let\maybeyear\gobbleoneargument}
+ {\let\maybeyear\firstofoneargument}%
+\to \everysetupbibtexlistplacement
+
+\appendtoks
+ \doifnot{\bibtexpublicationsparameter\c!option}\v!continue
+ {\global\bibtexcounter\zerocount}%
+\to \everysetupbibtexlistplacement
+
+\appendtoks
+ \edef\currentbibtexcriterium{\namedlistparameter\currentbibtexsession\c!criterium}%
+\to \everysetupbibtexlistplacement
+
+\def\typesetbibtexlist
+ {\begingroup
+ \startpacked[\v!blank]%
+ \doif{\namedlistparameter\currentbibtexsession\c!criterium}\v!cite
+ {\setuplist[\currentbibtexsession][\c!criterium=\v!here]}%
+ \doifelse{\bibtexpublicationsparameter\c!method}\v!local
+ {\ctxlua{bibtex.hacks.reset(1)}}% function can take method
+ {\ctxlua{bibtex.hacks.reset(2)}}%
+ \strc_lists_place_current
+ {\currentbibtexsession}
+ {\currentbibtexcriterium}
+ {}%
+ {\namedlistparameter\currentbibtexsession\c!extras}%
+ {\namedlistparameter\currentbibtexsession\c!order}%
+ \ctxlua{bibtex.hacks.flush("\bibtexpublicationsparameter\c!sorttype")}%
+ \stoppacked
+ \endgroup}
+
+\protected\def\typesetbibtexpublication#1%
+ {\edef\currentbibtexsessiontag{#1}%
+ \ifempty\currentbibtexsessiontag
+ % can't really happen
+ \orelse\ifx\currentbibtexcriterium\v!all
+ \dotypesetbibtexpublication % was \doplacepublicationindeed
+ \else
+ \ctxlua{bibtex.hacks.doifalreadyplaced("\currentbibtexsessiontag")}
+ \donothing
+ \dotypesetbibtexpublication
+ \fi}
+
+\def\dotypesetbibtexpublication
+ {\doifelsebibreferencefound\currentbibtexsessiontag
+ {\global\advance\bibtexcounter\plusone
+ \ctxlua{bibtex.hacks.registerplaced("\currentbibtexsessiontag")}%
+ \let\currentlist\currentbibtexsession
+ \let\currentlistentrynumber \bibtexcounter
+ \let\currentlistentrytitle \thebibtexpublicationlistelement
+ \let\currentlistentrypagenumber\empty
+ \strc_lists_apply_renderingsetup}
+ {}} % invalid
+
+\def\thebibtexpublicationlistelement
+ {\strut
+ \expanded{\reference[\bibtexrefprefix\currentbibtexsessiontag]{\number\bibtexcounter}}%
+ \dotypesetabibtexpublication\currentbibtexsessiontag
+ \strut}
+
+\def\dotypesetabibtexpublication#1%
+ {\begingroup
+ \ignorespaces
+ \xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/command(bibtex:format)}%
+ \removeunwantedspaces
+% \ignorespaces
+% \bibalternative{\bibgetvart{#1}}%
+% \removeunwantedspaces
+ \endgroup}
+
+\def\doprocessbibtexentry#1{\typesetbibtexpublication{#1}}
+
+% citations
+
+\protected\def\bibtexcitation[#1]%
+ {\edef\currentbibtexsession{#1}%
+ \strictdoifelsenextoptional\dobibtexcitation\dobibtexref}
+
+\def\dobibtexref#1%
+ {\dodobibtexcitation[#1][]}
+
+\def\dobibtexcitation[#1]%
+ {\strictdoifelsenextoptional{\dodobibtexcitation[#1]}{\dodobibtexcitation[#1][]}}
+
+\def\dodobibtexcitation[#1][#2]%
+ {\dontleavehmode
+ \begingroup
+ \doifelsenothing{#2}\secondargumentfalse\secondargumenttrue
+ \ifsecondargument
+ \dowhateverbibtexcitation{#1}{#2}%
+ \else
+ \donumberedbibtexcitation{#1}%
+ \fi
+ \endgroup}
+
+\def\dowhatevercitation#1#2%
+ {\processcommalist[#2]\dobibtexcitationindeed
+ \setupinteraction[\c!style=]% use flag instead
+ \doifelseassignment{#1}
+ {\getparameters[\??pb\??pb][\c!alternative=,\c!extras=,#1]%
+ \edef\currentbibtexvariant{\@@pb@@pbalternative}%
+ \ifempty\currentbibtexvariant
+ \edef\currentbibtexvariant{\bibtexpublicationparameter\c!refcommand}%
+ \fi
+ \ifempty\@@pb@@pbextras
+ \setupcite[\currentbibtexvariant][#1]%
+ \else
+ \edef\@@pb@@pbextras{{\@@pb@@pbextras\ifdefined\@@pb@@pbright\@@pb@@pbright\else\bibtexpublicationparameter\c!right\fi}}%
+ \expanded{\setupcite[\currentbibtexvariant][#1,\c!right=\@@pb@@pbextras]}%
+ \fi}%
+ {\def\currentbibtexvariant{#1}}%
+ \getvalue{bibtex\currentbibtexvariant ref}[#2]}
+
+\def\donumberedbibtexcitation#1%
+ {\processcommalist[#1]\dobibtexcitationindeed
+ \setupinteraction[\c!style=]%
+ \edef\currentbibtexvariant{\bibtexcitationparameter\c!refcommand}%
+ \getvalue{bibtex\currentbibtexvariant ref}[#1]}
+
+\def\dobibtexcitationindeed#1%
+ {\iftrialtypesetting \else
+ \expanded{\writedatatolist[\currentbibtexsession][bibref=#1]}%
+ \fi}
+
+\def\nobibtexcitation[#1]%
+ {\processcommalist[#1]\dobibtexcitationindeed}
+
+\def\bibtexnumref[#1]%
+ {\dontleavehmode
+ \begingroup
+ \bibtexcitationparameter\v!left
+ \penalty\plustenthousand
+ \ctxlua{bibtex.hacks.resolve("","\number\bibtexblock","#1")}%
+ \bibtexcitationparameter\v!right
+ \endgroup}
+
+\def\dowithbibtexnumrefconnector#1#2%
+ {\ifnum#1>\plusone
+ \ifnum#2>\plusone
+ \ifnum#2=#1\relax
+ \bibtexpublicationsparameter\c!lastpubsep
+ \else
+ \bibtexpublicationsparameter\c!pubsep
+ \fi
+ \fi
+ \fi}
+
+\def\dowithbibtexnumref#1#2#3#4#5% n, i, prefix block ref
+ {\dowithbibtexnumrefconnector{#1}{#2}%
+ \def\bibtexrefprefix{#4:}%
+ \inbiblink[#5]}
+
+\def\dowithbibtexnumrefrange#1#2#3#4#5#6#7% n, i, prefix block ref
+ {\dowithbibtexnumrefconnector{#1}{#2}%
+ \def\bibtexrefprefix{#4:}%
+ \inbiblink[#5]%
+ \endash
+ \def\bibtexrefprefix{#6:}%
+ \inbiblink[#7]}
+
+\def\nobibtexnumref#1%
+ {[#1]}
+
+% hm
+
+% \def\@@pbinumbercommand{\executeifdefined{\??pb:\c!numbercommand:\@@pbnumbering}\firstofoneargument}
+
+% \letvalue{\??pb:\c!numbercommand:\v!yes }\firstofoneargument
+% \letvalue{\??pb:\c!numbercommand:\v!no }\gobbleoneargument
+% \setvalue{\??pb:\c!numbercommand:\v!short}{\bibtexgetshort\currentpublicationtag\gobbleoneargument}
+% \setvalue{\??pb:\c!numbercommand:\v!bib }{\bibtexgetnumber\currentpublicationtag\gobbleoneargument}
+
+% \def\bibalternative#1{\csname\??pv\@@currentalternative#1\endcsname}
+
+% basic setup
+
+% parent -> publicationlist
+%
+% \setuplist
+% [\currentbibtexsession]
+% [\c!samplesize={AA99},
+% \c!alternative=a,
+% \c!interaction=,
+% \c!pagenumber=\v!no,
+% #1,
+% \c!command=]
+
+% \setuppublicationlist
+% [\c!title=,
+% \c!command=\dospecialbibinsert,
+% \c!maybeyear=\v!on]
+
+\setupbibtexpublications
+ [\c!monthconversion=,
+ \c!alternative=apa,
+ \c!method=\v!global,
+ \c!refcommand=num,
+ \c!numbercommand=\bibtexleftnumber]
+
+\setupbibtexcitations % command ?
+ [\c!refcommand=num]
+
+% helpers
+
+\protected\def\doifelsebibtexinteraction
+ {\iflocation
+ \edef\temp{\bibtexcitationparameter\c!interaction}%
+ \ifx\temp\v!stop
+ \doubleexpandafter\secondoftwoarguments
+ \else
+ \doubleexpandafter\firstoftwoarguments
+ \fi
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\let\doifbibtexinteractionelse\doifelsebibtexinteraction
+
+% variants
+
+% todo: lastsep here
+
+\newconditional\firstbibtexrefsep
+
+\def\bibtexresetrefsep
+ {\settrue\firstbibtexrefsep}
+
+\def\bibtexinsertrefsep
+ {\ifconditional\firstbibtexrefsep
+ \setfalse\firstbibtexrefsep
+ \else
+ \bibtexcitationparameter\c!pubsep
+ \fi}
+
+\def\inbibtexlink#1#2%
+ {\doifelsereferencefound{\bibtexrefprefix#1}
+ {\goto{#2}[\bibtexrefprefix#1]}
+ {!#1!}}
+
+\def\dobibtexgotolink#1#2%
+ {\doifelsereferencefound{\bibtexrefprefix#1}
+ {\goto{#2}[\bibtexrefprefix#1]}
+ {!#1!}}
+
+\def\dobibattexlink#1#2%
+ {\doifelsereferencefound{\bibtexrefprefix#1}
+ {\at{#2}[\bibtexrefprefix#1]}
+ {!#1!}}
+
+\def\dobibtexurllink#1#2%
+ {\expanded{\useURL[bibtex:url:#1][#2]}%
+ \doifelsebibtexinteraction
+ {\goto{\url[bibtex:url:#1]}[url(bibtex:url:#1)]}
+ {\url[bibtex:url:#1]}}
+
+% todo: style, color
+
+\protected\def\bibtexdataref {\dodoubleargument\dobibtexdataref}
+\protected\def\bibtextyperef {\dodoubleargument\dobibtextyperef}
+\protected\def\bibtexkeyref {\dodoubleargument\dobibtexkeyref}
+\protected\def\bibtexserialref {\dodoubleargument\dobibtexserialref}
+\protected\def\bibtexurlref {\dodoubleargument\dobibtexurlref}
+\protected\def\bibtexdoiref {\dodoubleargument\dobibtexdoiref}
+\protected\def\bibtexpageref {\dodoubleargument\dobibtexpageref}
+\protected\def\bibtexnoneref {\dodoubleargument\dobibtexnoneref}
+\protected\def\bibtexshortref {\dodoubleargument\dobibtexshortref}
+\protected\def\bibtexyearref {\dodoubleargument\dobibtexyearref}
+\protected\def\bibtexauthorref {\dodoubleargument\dobibtexauthorref}
+\protected\def\bibtexauthoryearref {\dodoubleargument\dobibtexauthoryearref}
+\protected\def\bibtexauthoryearsref{\dodoubleargument\dobibtexauthoryearsref}
+
+\def\dobibtexdataref {\doprocessbibtexref\dodobibtexdataref {ref}} % [#1][#2]
+\def\dobibtextyperef {\doprocessbibtexref\dodobibtextyperef {type}} % [#1][#2]
+\def\dobibtexkeyref {\doprocessbibtexref\dodobibtexkeyref {key}} % [#1][#2]
+\def\dobibtexserialref {\doprocessbibtexref\dodobibtexserialref {serial}} % [#1][#2]
+\def\dobibtexurlref {\doprocessbibtexref\dodobibtexurlref {url}} % [#1][#2]
+\def\dobibtexdoiref {\doprocessbibtexref\dodobibtexdoiref {doi}} % [#1][#2]
+\def\dobibtexpageref {\doprocessbibtexref\dodobibtexpageref {page}} % [#1][#2]
+\def\dobibtexnoneref {\doprocessbibtexref\dodobibtexnoneref {none}} % [#1][#2]
+\def\dobibtexshortref {\doprocessbibtexref\dodobibtexshortref {short}} % [#1][#2]
+\def\dobibtexyearref {\doprocessbibtexref\dodobibtexyearref {year}} % [#1][#2]
+\def\dobibtexauthorref {\doprocessbibtexref\dodobibtexauthorref {author}} % [#1][#2]
+\def\dobibtexauthoryearref {\doprocessbibtexref\dodobibtexauthoryearref {authoryear}} % [#1][#2]
+\def\dobibtexauthoryearsref{\doprocessbibtexref\dodobibtexauthoryearsref{authoryears}} % [#1][#2]
+
+\def\doprocessbibtexref#1#2[#3][#4]%
+ {\edef\currentbibtexsession{#3}%
+ \edef\currentbibtexvariant{#2}%
+ \def\dodoprocessbibtexref##1%
+ {% test for existence
+ \edef\currentbibtextag{##1}%
+ \bibtexinsertrefsep
+ #1{##1}}%
+ \bibtexresetrefsep
+ \bibtexcitationparameter\v!left
+ \processcommalist[#4]\dodoprocessbibtexref\relax
+ \bibtexcitationparameter\v!right}
+
+\def\dodobibtexdataref#1%
+ {\dotypesetabibtexpublication{#1}}
+
+\def\dodobibtextyperef#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/attribute('category')}}%
+ \bibtexrefcontent}
+
+\def\dodobibtexkeyref#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='key']/context()}}%
+ \dobibtexgotolink{#1}{\bibtexrefcontent}}
+
+\def\dodobibtexserialref#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/match()}}%
+ \dobibtexgotolink{#1}{\bibtexrefcontent}}
+
+\def\dodobibtexurlref#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/field[@name='url']/context()}}%
+ \dobibtexurllink{#1}{\bibtexrefcontent}}
+
+\def\dodobibtexdoiref#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/field[@name='doi']/context()}}%
+ \dobibtexurllink{#1}{http://dx.doi.org/\bibtexrefcontent}}
+
+\def\dodobibtexpageref#1%
+ {\dobibtexatlink{#1}{}} % second argument can become 'page'
+
+\def\dodobibtexnoneref#1%
+ {}
+
+\def\dodobibtexshortref#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/bibtexshort()}}%
+ \dobibtexgotolink{#1}{\bibtexrefcontent}}
+
+\def\dodobibtexyearref#1%
+ {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{/bibtex/entry[@tag='#1']/field[@name='year']/context()}}%
+ \bibtexrefcontent}
+
+% \def\bibmaybeinteractive#1#2%
+% {\doifelsevalue{@@pv\@@currentalternative\c!compress}
+% {\ifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}}
+% {#2}}
+
+% \def\bibauthornumref[#1]%
+% {\getcommalistsize[#1]%
+% \global\bibitemcounter\commalistsize
+% \bibresetrefsep
+% \processcommalist[#1]\dobibauthornumref }
+%
+% \def\dobibauthornumref#1%
+% {\bibinsertrefsep
+% \doifbibreferencefoundelse{#1}
+% {\begingroup
+% \bibgetvara{#1}%
+% \bibalternative\c!inbetween
+% \setuppublications[\c!refcommand=num]%
+% \cite[#1]%
+% \endgroup}
+% {}}
+
+% compress years
+% andtext namesep
+% otherstext authoretallimit
+
+% we will use context.* instead at the lua end because it saves us passing settings
+
+% \def\thebibtexpubsep {\bibtexpublicationsparameter\c!pubsep}
+% \def\thebibtexlastpubsep {\bibtexpublicationsparameter\c!lastpubsep}
+% \def\thebibtexfinalpubseparator{\bibtexpublicationsparameter\c!lastpubsep}
+
+\def\dodobibtexauthorref #1{\ctxlua{bibtex.authorref ("bibtex:\currentbibtexsession","#1","normal","author")}}
+\def\dodobibtexauthoryearref #1{\ctxlua{bibtex.authoryearref ("bibtex:\currentbibtexsession","#1","normal","author")}}
+\def\dodobibtexauthoryearsref#1{\ctxlua{bibtex.authoryearsref("bibtex:\currentbibtexsession","#1","normal","author")}}
+
+\protected\def\bibtexsingularplural#1#2{\ctxlua{bibtex.singularorplural(\!!bs#1\!!es,\!!bs#2\!!es)}}
+
+\protect \endinput
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/bibl-tra.mkxl b/Master/texmf-dist/tex/context/base/mkxl/bibl-tra.mkxl
new file mode 100644
index 00000000000..536de8d31c9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/bibl-tra.mkxl
@@ -0,0 +1,1508 @@
+%D \module
+%D [ file=bibl-tra,
+%D version=2009.08.22,
+%D title=\CONTEXT\ Publication Module,
+%D subtitle=Publications,
+%D author=Taco Hoekwater,
+%D date=\currentdate,
+%D copyright={Public Domain}]
+%C
+%C Donated to the public domain.
+
+%D This is really obsolete in \LMTX. For now I keep it but it will either go
+%D away. The code is not upgraded, we only deal with macro protection. I will
+%D only update the bits that annoy me in grepping for possible optimizations.
+
+% % % % watch out ... bibl-tra-new.mkiv is work in progress % % % %
+
+% % % % mlbibtex also supports context and we can run that instead of bibtex % % % %
+
+%D This module has been adapted to \MKIV\ by Hans Hagen so if things go wrong, he is
+%D to blame. The changes concern references and lists but teh rendering itself is
+%D unchanged. Future versions might provide variants as we have plans for an
+%D upgrade.
+%D
+%D We use a still somewhat experimental extension to the list mechanism. Eventually
+%D the bibtex module will use the bibl loader and access the data by means of lpath
+%D expressions. In that case we don't need to process the bibliography but still
+%D need to track usage as done here.
+%D
+%D A bit ongoing: make more local macros prefixed with bib, i.e. the bib namespace
+%D is reserved.
+
+%D Todo: commandhandler
+
+\writestatus{loading}{ConTeXt Bibliography Support / BibTeX}
+
+\definefilesynonym[bib][obsolete]
+
+\registerctxluafile{bibl-tra}{}
+
+%D The original was developed independantly by Taco Hoekwater while still working
+%D for Kluwer Academic publishers (it still used the dutch interface then).
+%D Development continued after he left Kluwer, and in Januari 2005, the then already
+%D internationalized file was merged with the core distribution by Hans Hagen. The
+%D current version is once again by Taco.
+%D
+%D More documentation and additional resources can be found on the contextgarden:
+%D \hyphenatedurl {http://wiki.contextgarden.net//Bibliography}.
+
+%D \subject{DONE (dd/mm/yyyy)}
+%D
+%D \startitemize
+%D \item add author definition (and associated system variable) (26/05/2005)
+%D \item add finalnamesep support for Oxford comma (17/09/2005)
+%D \item add \type{\insert...} for: doi, eprint, howpublished (19/09/2005)
+%D \item allow a defaulted \type{\setupcite} (19/11/2005)
+%D \item renamed citation type 'number' to 'serial' (19/11/2005)
+%D \item better definition of \type{\inverted...author} (19/11/2005)
+%D \item don't reset [numbercommand] in \type {\setuppublication} by default (20/11/2005)
+%D \item don't disable other \type {\setuppublication} keys if alternative is present (20/11/2005)
+%D \item drop \type{\sanitizeaccents} (20/11/2005)
+%D \item added \type{\nocite} and \type{\cite[none]} (21/11/2005)
+%D \item added headtext for it (23/11/2005)
+%D \item make \type{\cite[url]} and \type{\cite[doi]} interactive (23/11/2005)
+%D \item make right-aligned labels in the list work even when autohang=no
+%D \item use 'et al.' instead of 'et.al.'. Pointed out by Peter M\"unster (30/12/2005)
+%D \item added headtext for cz (31/12/2005)
+%D \item Keep whitespace after \type{\cite} with single argument (31/12/2005)
+%D \item Fix broken \type{\cite{}} support (31/12/2005)
+%D \item Use \type{\readfile} inside \type{\usepublications} instead of \type{\readsysfile} (12/01/2006)
+%D \item Use \type{\currentbibyear} and \type{\currentbibauthor} instead of \type{\YR} and \type{\AU} (05/02/2006)
+%D \item Fix compressed version of authoryear style (05/02/2006)
+%D \item Rename the clashing data fields \type{\url} and \type{\type} to \type{\biburl} and \type{\bibtype} (05/02/2006)
+%D \item Added two french bibl files from Renaud Aubin (06/02/2006)
+%D \item Five new bib class and eight extra bib fields, for IEEEtran (07/02/2006)
+%D \item French keyword translation, provided by Renaud (08/02/2006)
+%D \item fix underscores in undefined keys (22/02/2006)
+%D \item Destroy interactivity in labels of the publication list (13/03/2006)
+%D \item fix multi-cite list compression (11/4/2006)
+%D \item fix \type{\getcitedata} (11/4/2006)
+%D \item magic for chapter bibs (18-25/4/2006)
+%D \item language setting (25/4/2006)
+%D \item use \type{\hyphenatedurl} for \type{\inserturl} (25/4/2006)
+%D \item Add \type{\docitation} to \type{\nocite}(26/4/2006)
+%D \item patents can have numbers, added to bst files (26/4/2006)
+%D \item \type{\docitation} needs a \type{\iftrialtypesetting} (27/4/2006)
+%D \item \type{\filllocalpublist}'s loop is bound by definedness, not resolvedness (27/4/2006)
+%D \item \type{\setuppublications[monthconversion=]} added (15/5/2006)
+%D \item use \type{\undefinedreference} instead of bare question marks (15/5/2006)
+%D \item add grouping around \type{\placepublications} commands (16/5/2006)
+%D \item fix a bug in \type{\cite{}} (17/5/2006)
+%D \item support \type{\cite[authornum]} (18/5/2006)
+%D \item make \type{\cite} unexpandable (20/6/2006)
+%D \item allow hyperlinks in author\&year combo's
+%D (cite list compression has to be off) (20/6/2006)
+%D \item fix duplicate labels for per-chapter style (20/6/2006)
+%D \item allow \type{\setupcite[interaction=(start|stop)]}
+%D \item fix the item number in the publication list with 'numbering=yes' (22/6/2006)
+%D \item make the default criterium for \type{\placepublications} be \type{previous} (23/6/2006)
+%D \item fix \type{\normalauthor} and \type{\normalshortauthor} spacing (29/6/2006)
+%D \item do not typeset empty arguments to \type{\typesetapublication} (29/6/2006)
+%D \item add \type{symbol=none} to \type{\setuplist} in unnumbered
+%D mode to prevent typesetting of bare numbers (29/6/2006)
+%D \item remove two incorrect spaces from bibl-num.tex (1/7/2006)
+%D \item reset font styles within \type{\cite}, so that font switches
+%D in \type{left} stay in effect (12/7/2006)
+%D \item guard added against loading bbl files multiple times (13/7/2006)
+%D \item fix \type{\cite[num]} with compression is on. (14/7/2006)
+%D \item test \type{\iflocation} before deciding to use the
+%D interactive version of cite (18/7/2006)
+%D \item support \type{\setupcite[authoretallimit=1]} (18/7/2006)
+%D \item support use of \type{\cite} within titles and captions by
+%D saveguarding the list item extraction and reference placement
+%D code (19/7/2006)
+%D \item support \type{\setuppublicationlist[title=\chapter]} (4/8/2006)
+%D \item use the expansion of \type{\headtext{pubs}} (4/8/2006)
+%D \item hook added for repeated authors in publication list
+%D \type{\setuppublicationlist[artauthorcommand=\mythreeargscommand]}
+%D (4/8/2006)
+%D \item make the bracketed arguments of \type{\artauthor}, \type{\author}
+%D and \type{\editor} (bbl commands) optional (4/8/2006)
+%D \item the constants \type{sorttype}, \type{compress} and
+%D \type{autohang} have moved to the core (8/8/2006)
+%D \item bibtex is now registered as a program to be run by texexec (8/8/2006)
+%D \item fix a bug in \type{\setupcite[authoretallimit=1]} (9/8/2006)
+%D \item fix a bug inside citations that prevented lastpubsep from ever being
+%D used due to a volatile \type{\commalistsize} (25/8/2006).
+%D \item added the possibility of \type{\placepublications[option=continue]}
+%D (6/9/2006)
+%D \item Mojca translated Master's Thesis to Masterarbeit (bibl-apa-de.tex)
+%D (12/9/2006)
+%D \item Added \type{\setuppublicationlist[maybeyear=off]} by request from
+%D Thomas Schmitz (15/9/2006)
+%D \item Removed some spurious spaces pointed out by willi egger (19/9/2006)
+%D \item Add configuration of bibtex executable name (4/11/2006)
+%D \item Fix numbering=short and numbering=bib (spotted by Matthias W\"achter) (4/11/2006)
+%D \item third attempt to get a correct release (5/11/2006)
+%D \item fix a few missing dots in bibl-num.tex (7/12/2006)
+%D \item Patch for DOI's by Tobias Burnus (17/4/2007)
+%D \item Patch for \type{\insertbiburl} and \type{\insertdoi} for Tobias Burnus (18/4/2007)
+%D \item Added a missing \type{\relax} in \type{\dospecialbibinsert},
+%D that made the space before the {\it et al.} text disappear. (18/4/2007)
+%D \item Attempt to fix percent signs in bbl files. As a side-effect,
+%D this prohibits comments in \tex{startpublication} blocks! (17/4/2008)
+%D \item Patch from Matthias W\"achter that allows arbitrary .bst
+%D files to be used with \tex{setupbibtex} (25/9/2008)
+%D \item Extended for the new multilingual setups for the Oct 2008 current of ConTeXt (23/10/2008)
+%D \item Multilingual setups needed another fix (27/10/2008)
+%D \item Two fixes for bibl-apa by Michael Green (27/10/2008)
+%D \item Catalan translation of 'References' (10/11/2008)
+%D \item 'chapter' -> 'chapitre' in bibl-apa-fr (27/11/2008)
+%D \item Run bibtex via os.execute in mkiv modee (01/12/2008)
+%D \item Small correction in bibl-apa's placement of volume
+%D information in articles (05/01/2009)
+%D \item Handle multi-author (more than two) cases in \type{\cite}
+%D (02/03/2009)
+%D \item Suppress a syntax error in \type{cont-xp} mode. The output is
+%D probably not right, though (02/03/2009)
+%D \item Added a \tex{loadmarkfile} at the end, and two new files
+%D from Hans. The \type{t-bib.mkiv} is needed to make the module
+%D work with the new structure code (17/04/2009)
+%D \item Added a patch to \type{t-bib.mkiv} from Hans to make the
+%D cross referencing between multiple citations an
+%D bibliographies work (27/04/2009)
+%D \item Remove a superfluous \type{\unprotect} in t-bib.mkiv (11/05/2009).
+%D \item Patch of incollection in bibl-ams.tex from Xan (08/06/2009).
+%D \item Patch of unpublished in bibl-ams.tex from Xan (22/07/2009).
+%D \item Modified \type{\bibdogetupsometextprefix} so it works for undefined
+%D language labels, from Hans (13/08/2009).
+%D \item Adapt referencing and list insertion to \MKIV. Update some code
+%D to the latest \CONTEXT. Change some names in order to avoid conflicts
+%D with existing core names (like \type {\insertpages}).
+%D \item All constants, variables, message etc.\ are now in the core.
+%D \item Added key: \type {method} (when \type {global}, previous shown entries are
+%D not shown again, when \type {local} they are repeated).
+%D \stopitemize
+%D
+%D \subject{WISHLIST}
+%D
+%D \startitemize
+%D \item link back from publication list to citation
+%D \item export \type {\citation{}}
+%D \item support mlbibtex
+%D \item don't load the whole lot, but filter entries instead
+%D \item 9 vs 10, 19 vs 20 ... prevent extra runs when only subtle changes in wd of reference
+%D \stopitemize
+
+\unprotect
+
+\def\biblistname{pubs} % for compatibility
+
+\definelist
+ [pubs]
+
+\setuplist
+ [pubs]
+ [\c!state=\v!start,
+ \c!criterium=\@@pbcriterium,
+ \c!headnumber=\v!always, % needed as we provide our own and need to force
+ \c!width=]
+
+\installstructurelistprocessor{pubs:userdata}%
+ {\ctxlua{bibtex.hacks.add(structures.lists.uservalue("\currentlist",\currentlistindex,"bibref"),\currentlistindex)}}
+
+\ifdefined\bibtexblock \else \newcount\bibtexblock \fi \bibtexblock\plusone
+\ifdefined\bibtexcounter \else \newcount\bibtexcounter \fi
+
+%D \macros{bibdoif,bibdoifnot,bibdoifelse}
+%D
+%D Here are a few small helpers that are used a lot in all the typesetting commands
+%D (\type{\bibinsert...}) we will encounter later.
+
+\protected\def\bibdoifelse#1%
+ {\expandafter\def\expandafter\!!stringa\expandafter{#1}%
+ \ifempty\!!stringa
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\protected\def\bibdoifnot#1%
+ {\expandafter\def\expandafter\!!stringa\expandafter{#1}%
+ \ifempty\!!stringa
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\protected\def\bibdoif#1%
+ {\expandafter\def\expandafter\!!stringa\expandafter{#1}%
+ \ifempty\!!stringa
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+%D Unfortunately, \BIBTEX\ is not the best configurable program around. The names of
+%D the commands it parses as well as the \type {.aux} extension to the file name are
+%D both hardwired.
+%D
+%D This means \CONTEXT\ has to write a \LATEX-style auxiliary file, yuk! The good
+%D news is that it can be rather short. We'll just ask \BIBTEX\ to output the entire
+%D database(s) into the \type {bbl} file.
+%D
+%D The \type {\bibstyle} command controls how the \type {bbl} file will be sorted.
+%D The possibilities are:
+%D
+%D \startitemize[packed]
+%D \item by author (+year, title): cont-au.bst
+%D \item by title (+author, year): cont-ti.bst
+%D \item by short key as in abbrev.bst: cont-ab.bst
+%D \item not sorted at all: cont-no.bst
+%D \stopitemize
+
+\newtoks\everysetupbibtex
+
+\protected\def\setupbibtex
+ {\dosingleempty\dosetupbibtex}
+
+\protected\def\dosetupbibtex[#1]%
+ {\let\@@pbdatabase\empty
+ \getparameters[\??pb][#1]%
+ \the\everysetupbibtex}
+
+\protected\def\installbibtexsorter#1#2%
+ {\setvalue{\??pb:\c!sort:#1}{#2}}
+
+\installbibtexsorter\v!no {no}
+\installbibtexsorter\v!author {au}
+\installbibtexsorter\v!title {ti}
+\installbibtexsorter\v!short {ab}
+\installbibtexsorter\empty {no}
+\installbibtexsorter\s!default{no}
+
+\def\thebibtexsorter{\executeifdefined{\??pb:\c!sort:\@@pbsort}\@@pbsort}
+
+\appendtoks
+ \ifempty\@@pbdatabase\else
+ \doifmode{*\v!first}{\ctxlua{bibtex.hacks.process { style="\thebibtexsorter", database="\@@pbdatabase" }}}%
+ \fi
+\to \everysetupbibtex
+
+\setupbibtex
+ [\c!sorttype=\v!cite,
+ \c!sort=no]
+
+%D \macros{iftypesetall,ifbibcitecompress}
+%D
+%D The module needs some new \type{\if} statements.
+
+\newtoks\everysetuppublications
+
+\protected\def\setuppublications
+ {\dosingleargument\dosetuppublications}
+
+\protected\def\dosetuppublications[#1]%
+ {\getparameters[\??pb][\c!alternative=,#1]%
+ \doifsomething\@@pbalternative
+ {\readsysfile{bibl-\@@pbalternative.tex}
+ {\showmessage\m!publications{6}{bibl-\@@pbalternative}}
+ {\showmessage\m!publications{1}{bibl-\@@pbalternative}}%
+ \let\@@pbalternative\empty}%
+ \let\setuppublicationlayout\normalsetuppublicationlayout % overloaded in bibl-num ... vadjust needs to be done with option
+ \getparameters[\??pb][#1]% as bibl-* can have set things back
+ \the\everysetuppublications
+ \ignorespaces}
+
+%D We can omit already shown references (\v!global) or use fresh lists each time
+%D (\v!local).
+
+\setnewconstant\bibtexoncemode\plusone % 0=disable, 1=local, 2=global
+
+\appendtoks
+ \doifelse\@@pbmethod\v!local
+ {\bibtexoncemode\plusone}%
+ {\bibtexoncemode\plustwo}%
+\to \everysetuppublications
+
+%D Cite lists are compressed, if possible. This is set later on.
+
+\newif\ifbibcitecompress\bibcitecompresstrue
+
+\def\@@pbinumbercommand{\executeifdefined{\??pb:\c!numbercommand:\@@pbnumbering}\firstofoneargument}
+
+\setvalue{\??pb:\c!numbercommand:\v!yes }#1{#1}%
+\setvalue{\??pb:\c!numbercommand:\v!no }#1{}
+\setvalue{\??pb:\c!numbercommand:\v!short}#1{\bibgetvars\currentpublicationkey}
+\setvalue{\??pb:\c!numbercommand:\v!bib }#1{\bibgetvarn\currentpublicationkey}
+
+% to be tested
+%
+% \setvalue{\??pb:\c!numbercommand:\v!short}{\bibgetvars\currentpublicationkey\firstofoneargument}
+% \setvalue{\??pb:\c!numbercommand:\v!bib }{\bibgetvarn\currentpublicationkey\firstofoneargument}
+
+\appendtoks
+ \processaction
+ [\@@pbrefcommand]
+ [\s!default=>\edef\@@citedefault{\@@pbrefcommand},
+ \s!unknown=>\edef\@@citedefault{\@@pbrefcommand}]%
+\to \everysetuppublications
+
+\protected\def\bibleftnumber#1{#1\hfill~}
+
+%D \macros{usepublications}
+%D
+%D After discussing it with Thomas Schmitz it became clear that using external
+%D references makes no sense as one needs to refer to it in special ways and because
+%D similar numbers can be confusing. So, for the moment this is not supported in
+%D \MKIV. (So no: see reference [3-5,9] in "some other document")
+
+\protected\def\usepublications[#1]%
+ {\processcommalist[#1]\dousepublications}
+
+\protected\def\dousepublications#1%
+ {\doonlyonce{#1.\f!bibextension}{\dodousepublications{#1}}}
+
+\pushoverloadmode
+
+\protected\def\dodousepublications#1% brr, this par stuff
+ {\enforced\let\par\ignorespaces
+ \ifhmode\kern\zeropoint\fi
+ \pushcatcodetable
+ \setcatcodetable\ctxcatcodes
+ \readfile{#1.\f!bibextension}
+ {\showmessage\m!publications{4}{#1.\f!bibextension}}
+ {\showmessage\m!publications{2}{#1.\f!bibextension}}%
+ \popcatcodetable
+ \ifhmode\removeunwantedspaces\fi
+ \enforced\let\par\normalpar}
+
+\popoverloadmode
+
+%D \macros{setuppublicationlist}
+%D
+%D This will be the first command in (\BIBTEX-generated) \type {bbl} files. \quote
+%D {samplesize} is a sample value (in case of \BIBTEX|-|generated files, this will
+%D be the longest \quote {short} key). Here \quote {totalnumber} is the total number
+%D of entries that will follow in this file.
+%D
+%D Both values are only needed for the label calculation if \quote {autohang} is
+%D \quote {true}, so by default the command is not even needed, and therefore I saw
+%D no need to give it it's own system variable and it just re-uses \type {pb}.
+
+\def\publicationlistparameter#1{\csname\??pv:l:#1\endcsname}
+
+\protected\def\setuppublicationlist
+ {\dosingleempty\dosetuppublicationlist}
+
+\protected\def\dosetuppublicationlist[#1]%
+ {\getparameters[\??pv:l:][#1]%
+ \setuplist[pubs][\c!samplesize={AA99},\c!alternative=a,\c!interaction=,\c!pagenumber=\v!no,#1,\c!command=]}
+
+\protected\def\setuppublicationlayout[#1]#2%
+ {\setvalue{\??pv:l:#1}{#2}}
+
+\let\normalsetuppublicationlayout\setuppublicationlayout
+
+\setuppublicationlist
+ [\c!title=,
+ \c!command=\dospecialbibinsert,
+ \c!maybeyear=\v!on]
+
+%D \macros{bibalternative}
+%D
+%D A nice little shorthand that will be used so we don't have to key in the weird
+%D \type {\@@pv} parameter names all the time.
+
+\def\bibalternative#1%
+ {\csname\??pv\@@currentalternative#1\endcsname}
+
+%D \macros{simplebibdef,bibcommandlist}
+%D
+%D \type {\simplebibdef} defines \type {bib@#1}, which in turn will use one argument
+%D that is stored in \type {@@pb@#1}.
+%D
+%D \type {\simplebibdef} also defines \type {bibinsert#1}, which can be used in the
+%D argument of \type {\setuppublicationlayout} to fetch one of the \type {@@pb@}
+%D data entries. \type {bibinsert#1} then has three arguments: \type {#1} are
+%D commands to be executed before the data, \type {#2} are commands to be executed
+%D after the data, and \type {#3} are commands to be executed if the data is not
+%D found.
+%D
+%D \type {\bibcommandlist} is the list of commands that is affected by this
+%D approach. Later on, it will be used to do a series of assignments from \type {#1}
+%D to \type {bib@#1}: e.g \type {\title} becomes \type {\bib@title} when used within
+%D a publication.
+
+\newtoks\initializebibdefinitions % we need to prevent clashes
+
+\protected\def\simplebibdef#1% hh: funny expansion ?
+ {\expandafter\def\csname bib@#1\endcsname##1%
+ {\setvalue{\??pb @#1}{##1}\ignorespaces}%
+ \expandafter \appendtoks
+ \expandafter\let\csname insert#1\expandafter\endcsname\csname bibinsert#1\endcsname
+ \to \initializebibdefinitions
+ \expandafter\protected\expandafter\def\csname bibinsert#1\endcsname##1##2##3%
+ {\expandafter\bibdoifelse\expandafter{\csname\??pb @#1\endcsname}{##1\csname\??pb @#1\endcsname##2}{##3}}}
+
+\def\bibcommandlist
+ {abstract, annotate, arttitle, assignee, bibnumber, bibtype, biburl, chapter, city,
+ comment, country, day, dayfiled, doi, edition, eprint, howpublished, isbn, issn,
+ issue, journal, keyword, keywords, lastchecked, month, monthfiled, names, nationality,
+ note, notes, organization, pages, pubname, pubyear, revision, series, size, thekey,
+ title, volume, yearfiled}
+
+\processcommacommand[\bibcommandlist]\simplebibdef
+
+\protected\def\bibinsertdoi#1#2#3% let's see how this fails
+ {\bibdoifelse{\@@pb@doi}{#1\expanded{\bibgotoDOI{\@@pb@thekey}{\@@pb@doi}}#2}{#3}}
+
+\protected\def\bibinsertbiburl#1#2#3% let's see how this fails
+ {\bibdoifelse{\@@pb@biburl}{#1\expanded{\bibgotoURL{\@@pb@thekey}{\@@pb@biburl}}#2}{#3}}
+
+\protected\def\bibinsertmonth#1#2#3%
+ {\bibdoifelse\@@pb@month
+ {#1\doifelsenumber\@@pb@month
+ {\doifelseconversiondefined\@@pbmonthconversion
+ {\convertnumber\@@pbmonthconversion\@@pb@month}{\@@pb@month}}%
+ {\@@pb@month}#2}%
+ {#3}}
+
+\appendtoks
+ \let\inserturl \bibinsertbiburl % for backward compat.
+ \let\inserttype\bibinsertbibtype % for backward compat.
+\to\initializebibdefinitions
+
+\protected\def\newbibfield[#1]%
+ {\simplebibdef{#1}%
+ \edef\bibcommandlist{\bibcommandlist,#1}}
+
+%D \macros{complexbibdef,specialbibinsert}
+%D
+%D The commands \type {\artauthor}, \type {\author} and \type {\editor} are more
+%D complex than the other commands. Their argument lists have this form:
+%D
+%D \type{\author[junior]{firstnames}[inits]{von}{surname}}
+%D
+%D (bracketed stuff is optional)
+%D
+%D And not only that, but there also might be more than one of each of these
+%D commands. This is why a special command is needed to insert them, as well as one
+%D extra counter for each command.
+
+% todo: instead of \getvalue {bla@num} in specs we should do \bibentrynum {bla} so
+% that we can create a better namespace
+
+%D All of these \type {\expandafter}'s and \type {\csnames} make this code look far
+%D more complex than it really is. For example, the argument \type {author} defines
+%D the macro \type {\bib@author} to do two things: increment the counter \type
+%D {\author@num} (let's say to 2) and next store it's arguments in the macro \type
+%D {\@@pb@author2}. And it defines \type {\bibinsertauthors} to expand into
+%D
+%D \starttyping
+%D \specialbibinsert{author}{\author@num}{}{}{}
+%D \stoptyping
+
+\protected\def\docomplexbibdef#1%
+ {\dodoubleempty\dodocomplexbibdef[#1]}
+
+\protected\def\dodocomplexbibdef[#1][#2]#3%
+ {\doquadrupleempty\dododocomplexbibdef[#1][#2][#3]}
+
+\protected\def\dododocomplexbibdef[#1][#2][#3][#4]#5#6%
+ {\expandafter\increment\csname#1@num\endcsname % todo: bib in name
+ \setevalue{\??pb @#1\csname#1@num\endcsname}{{#3}{#5}{#6}{#4}{#2}}\ignorespaces}
+
+\protected\def\complexbibdef#1%
+ {\expandafter\newcounter\csname #1@num\endcsname
+ \expandafter\def\csname bib@#1\endcsname{\docomplexbibdef{#1}}%
+ \expandafter \appendtoks
+ \expandafter\let\csname insert#1s\expandafter\endcsname\csname bibinsert#1s\endcsname
+ \to \initializebibdefinitions
+ \expandafter\def\csname bibinsert#1s\endcsname##1##2##3{\specialbibinsert{#1}{\csname #1@num\endcsname}{##1}{\unskip ##2}{##3}}}
+
+\processcommalist[author,artauthor,editor]\complexbibdef
+
+%D Another level of indirection is needed to control the typesetting of all of these
+%D arguments.
+
+\newcount\etallimitcounter
+\newcount\etaldisplaycounter
+\newcount\todocounter
+
+\protected\def\specialbibinsert#1#2#3#4#5%
+ {\bgroup
+ \ifnum#2>\zerocount
+ \etallimitcounter =0\bibalternative{#1etallimit}\relax
+ \etaldisplaycounter=0\bibalternative{#1etaldisplay}\relax
+ \ifnum #2>\etallimitcounter
+ \todocounter\etaldisplaycounter
+ % just in case ...
+ \ifnum\todocounter>\etallimitcounter
+ \todocounter\etallimitcounter
+ \fi
+ \else
+ \todocounter#2\relax
+ \fi
+ \ifnum\todocounter>\zerocount
+ % find the current author list
+ \let\templist\empty
+ \dorecurse{#2}
+ {\scratchtoks\doubleexpandafter{\csname\??pb @#1\recurselevel\endcsname}%
+ \edef\templist{\ifempty\templist\else\templist,\fi\the\scratchtoks}}%
+ #3\publicationlistparameter\c!command{#1}{\todocounter}{\templist}#4\relax
+ \else
+ #5%
+ \fi
+ \else
+ #5%
+ \fi
+ \egroup}
+
+%D This macro does the hard work of inserting a list of people in the output, with
+%D proper regard of all the inbetween strings that can arise depending on length of
+%D the list of people.
+
+%D \#1 = type
+%D \#2 = number of items to be typeset
+%D \#3 = commacommand containing authors
+
+\protected\def\doprocessauthoritem#1#2#3%
+ {\advance\scratchcounter\plusone
+ \ifnum\numexpr\scratchcounter-\plusone\relax<#2\relax
+ \publicationlistparameter{#1}#3%
+ \ifnum\scratchcounter=#2\relax
+ \ifnum\etallimitcounter<\commalistsize\relax
+ \bibalternative{#1etaltext}%
+ \fi
+ \orelse\ifnum\numexpr\scratchcounter+\plusone\relax=#2\relax
+ \ifnum\commalistsize>\plustwo
+ \bibalternative\c!finalnamesep
+ \else
+ \bibalternative\c!lastnamesep
+ \fi
+ \else
+ \bibalternative\c!namesep
+ \fi
+ \fi}
+
+\protected\def\dospecialbibinsert#1#2#3%
+ {\getcommacommandsize[#3]%
+ \scratchcounter\zerocount
+ \processcommacommand[#3]{\doprocessauthoritem{#1}{#2}}}
+
+%D \macros{invertedauthor,normalauthor,invertedshortauthor,normalshortauthor}
+%D
+%D Just some commands that can be used in \type {\setuppublicationparameters}
+%D If you want to write an extension to the styles, you might as well define
+%D some of these commands yourself.
+%D
+%D The argument list has been reordered here, and the meanings are:
+%D
+%D \startlines
+%D \type{#1} firstnames
+%D \type{#2} von
+%D \type{#3} surname
+%D \type{#4} inits
+%D \type{#5} junior
+%D \stoplines
+
+\protected\def\normalauthor#1#2#3#4#5%
+ {\bibdoif{#1}{#1\bibalternative\c!firstnamesep}%
+ \bibdoif{#2}{#2\bibalternative\c!vonsep}%
+ #3%
+ \bibdoif{#5}{\bibalternative\c!surnamesep#5\unskip}}
+
+\protected\def\normalshortauthor#1#2#3#4#5%
+ {\bibdoif{#4}{#4\bibalternative\c!firstnamesep}%
+ \bibdoif{#2}{#2\bibalternative\c!vonsep}%
+ #3%
+ \bibdoif{#5}{\bibalternative\c!surnamesep#5\unskip}}
+
+\protected\def\invertedauthor#1#2#3#4#5%
+ {\bibdoif{#2}{#2\bibalternative\c!vonsep}%
+ #3%
+ \bibdoif{#5}{\bibalternative\c!juniorsep#5}%
+ \bibdoif{#1}{\bibalternative\c!surnamesep#1\unskip}}
+
+\protected\def\invertedshortauthor#1#2#3#4#5%
+ {\bibdoif{#2}{#2\bibalternative\c!vonsep}%
+ #3%
+ \bibdoif{#5}{\bibalternative\c!juniorsep#5}%
+ \bibdoif{#4}{\bibalternative\c!surnamesep#4\unskip}}
+
+%D \macros{clearbibitem,clearbibitemtwo,bibitemdefs}
+%D
+%D These are used in \type {\typesetapublication} to do initializations and
+%D cleanups.
+
+\protected\def\clearbibitem#1{\setvalue{\??pb @#1}{}}%
+
+\protected\def\clearbibitemtwo#1% is this reset really needed? after all we reset the counter and we are local
+ {%\dofastrecurse\plusone{\csname#1@num\endcsname}\plusone{\expandafter\let\csname\??pb @#1\recurselevel\undefined}%
+ \letvalue{#1@num}\!!zerocount}
+
+\protected\def\bibitemdefs#1%
+ {\expandafter\let\csname#1\expandafter\endcsname\csname bib@#1\endcsname}
+
+\protected\def\presetbibvariables % make a fast resetter (toks)
+ {\processcommacommand[\bibcommandlist,crossref]\clearbibitem
+ \processcommalist [artauthor,author,editor]\clearbibitemtwo
+ \processcommacommand[\bibcommandlist]\bibitemdefs
+ \processcommalist [artauthor,author,editor,crossref]\bibitemdefs}
+
+%D \macros{startpublication}
+%D
+%D We are coming to the end of this module, to the macros that do typesetting and
+%D read the \type {bbl} file.
+%D
+%D Just a \type {\dosingleempty} is the most friendly of doing this: there need not
+%D even be an argument to \type {\startpublication}. Of course, then there is no key
+%D either, and it had better be an article (otherwise the layout will be all screwed
+%D up).
+%D
+%D Only specifying the key in the argument is also legal. In storing this stuff into
+%D macros, some trickery with token registers is needed to fix the expansion
+%D problems. Even so, this appears to not always be 100\% safe, so people are
+%D urgently advised to use \ETEX\ instead of traditional \TEX.
+%D
+%D In \ETEX, all expansion problems are conveniently solved by the primitive \type
+%D {\protected}. To put that another way:
+%D
+%D It's not a bug in this module if it does not appear in \ETEX!
+%D
+%D Now prohibits comments, so % can be used for urls
+
+\pushoverloadmode
+
+\overloaded \protected\def\startpublication
+ {\dosingleempty\dostartpublication}
+
+\overloaded\let\stoppublication\relax
+
+\popoverloadmode
+
+%D This is rather memory hungry; some day i will rewrite this so that we use the
+%D database instead.
+
+%D \macros{doifbibreferencefoundelse}
+%D
+%D Some macros to fetch the information provided by \type {\startpublication}.
+%D
+%D We can consider a faster variant in the bbl file; we can also consider storing
+%D the keys in lua (and then do more in lua) and use calls to fetch the variables.
+
+% hm, we can store at the lua end ...
+
+\protected\def\dostartpublication[#1]%
+ {\begingroup
+ \doifelseassignment{#1}%
+ {\getparameters[\??pb][k=\s!unknown,t=article,n=,s=,a=,y=,o=,u=,#1]}%
+ {\getparameters[\??pb][k=#1,t=article,n=,s=,a=,y=,o=,u=]}%
+ \ctxlua{bibtex.hacks.register(\!!bs\@@pbk\!!es,\!!bs\@@pbs\!!es)}%
+ \catcode\commentasciicode\othercatcode
+ \dodostartpublication}
+
+\protected\def\dodostartpublication#1\stoppublication
+ {\setxvalue{pbd:\@@pbk}##1{\noexpand\ifcase##1\noexpand\or
+ \@@pbk\noexpand\or
+ \@@pba\noexpand\or
+ \@@pby\noexpand\or
+ \@@pbs\noexpand\or
+ \@@pbn\noexpand\or
+ \@@pbt\noexpand\or
+ \@@pbo\noexpand\or
+ \@@pbu\noexpand\or
+ \normalunexpanded{#1}\noexpand\fi}%
+ \endgroup
+ \ignorespaces}
+
+\def\bibgetvark#1{\csname pbd:#1\endcsname\plusone }
+\def\bibgetvara#1{\csname pbd:#1\endcsname\plustwo }
+\def\bibgetvary#1{\csname pbd:#1\endcsname\plusthree}
+\def\bibgetvars#1{\csname pbd:#1\endcsname\plusfour }
+\def\bibgetvarn#1{\csname pbd:#1\endcsname\plusfive }
+\def\bibgetvart#1{\csname pbd:#1\endcsname\plussix }
+\def\bibgetvaro#1{\csname pbd:#1\endcsname\plusseven}
+\def\bibgetvaru#1{\csname pbd:#1\endcsname\pluseight}
+\def\bibgetvard#1{\csname pbd:#1\endcsname\plusnine }
+
+\protected\def\doifelsebibreferencefound#1%
+ {\preloadbiblist
+ \doifelsedefined{pbd:#1}
+ \firstoftwoarguments
+ {\showmessage\m!publications{5}{#1,\the\inputlineno}\secondoftwoarguments}}
+
+\let\doifbibreferencefoundelse\doifelsebibreferencefound
+
+%D \macros{bib@crossref}
+%D
+%D \type {\crossref} is used in database files to point to another entry. Because of
+%D this special situation, it has to be defined separately. Since this command will
+%D not be seen until at \type {\placepublications}, it may force extra runs. The
+%D same is true for \type {\cite} commands inside of publications.
+
+% used in bib self
+
+\protected\def\bib@crossref#1% called via \csname \endcsname
+ {\setvalue{\??pb @crossref}{#1}\ignorespaces}
+
+\protected\def\bibinsertcrossref#1#2#3%
+ {\bibdoifelse\@@pb@crossref{#1\cite[\@@pb@crossref]#2}{#3}}
+
+\let\insertcrossref\gobblethreearguments
+
+\appendtoks\let\insertcrossref\bibinsertcrossref\to\initializebibdefinitions
+
+%D The next macro is needed because the number command of the publist sometimes
+%D needs to fetch something from the current item (like the 'short' key). For this,
+%D the ID of the current item is passed in the implict parameter \type
+%D {\currentpublicationkey}.
+
+\protected\def\doprocessbibtexentry#1{\typesetapublication{#1}}
+
+\protected\def\typesetpubslist
+ {\begingroup
+ \startpacked[\v!blank]%
+ \preloadbiblist
+ % \the\initializebibdefinitions % COMMENTED
+ \edef\currentlist{pubs}%
+ \ctxlua{bibtex.hacks.reset(\number\bibtexoncemode)}%
+ \doifelse{\listparameter\c!criterium}\v!all
+ {\showmessage\m!publications{7}{}%
+ \ctxlua{bibtex.hacks.filterall()}}
+ {\doif{\listparameter\c!criterium}\v!cite
+ {\setuplist[pubs][\c!criterium=\v!here]}%
+ \strc_lists_place_current
+ {pubs}%
+ {\listparameter\c!criterium}%
+ {}%
+ {\listparameter\c!extras}%
+ {\listparameter\c!order}}%
+ \ctxlua{bibtex.hacks.flush("\@@pbsorttype")}%
+ \stoppacked
+ \endgroup}
+
+\newif\ifinpublist
+
+\protected\def\initializepubslist
+ {\def\currentlist{pubs}%
+ \edef\@@pbnumbering{\@@pbnumbering}%
+ \doifelse\@@pbautohang\v!yes
+ {\ifx\@@pbnumbering\v!short
+ \setbox\scratchbox\hbox{\@@pbnumbercommand{\listparameter\c!samplesize}}%
+ \else
+ \doifelse{\listparameter\c!criterium}\v!all
+ {\setbox\scratchbox\hbox{\@@pbnumbercommand{\ctxlua{tex.write{bibtex.hacks.nofregistered()}}}}}
+ {\determinelistcharacteristics[pubs]%
+ \setbox\scratchbox\hbox{\@@pbnumbercommand{\structurelistsize}}}%
+ \fi
+ \edef\publistnumberbox{\hbox to \the\wd\scratchbox}%
+ \expanded{\setuplist[pubs][\c!width=\the\wd\scratchbox,\c!distance=\zeropoint]}%
+ \ifx\@@pbnumbering\v!short
+ \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvars\currentpublicationkey}}}%
+ \orelse\ifx\@@pbnumbering\v!bib
+ \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvarn\currentpublicationkey}}}%
+ \else
+ \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{##1}}}%
+ \fi}
+ {\doifelsenothing{\listparameter\c!width}
+ {\let \publistnumberbox \hbox}
+ {\edef\publistnumberbox{\hbox to \listparameter\c!width}}%
+ \ifx\@@pbnumbering\v!short
+ \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvars\currentpublicationkey}}}%
+ \orelse\ifx\@@pbnumbering\v!bib
+ \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvarn\currentpublicationkey}}}%
+ \else
+ \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{##1}}}%
+ \fi}%
+ \ifx\@@pbnumbering\v!no
+ \setuplist[pubs][\c!numbercommand=,\c!symbol=\v!none,\c!textcommand=\outdented]%
+ \else
+ \setuplist[pubs][\c!numbercommand=\@@pblimitednumber]%
+ \fi
+ \doifelse{\publicationlistparameter\c!maybeyear}{\v!off}{\def\maybeyear##1{}}{\def\maybeyear##1{##1}}%
+ \forgetall}
+
+%D The full list of publications
+
+\protected\def\completepublications
+ {\dosingleempty\docompletepublications}
+
+\protected\def\docompletepublications[#1]%
+ {\begingroup
+ \setuplist[pubs][#1]%
+ \edef\currentbibtexsessiontitle{\publicationlistparameter\c!title}%
+ \ifempty\currentbibtexsessiontitle
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=pubs,\c!title={\headtext{pubs}}]}%
+ \else
+ \normalexpanded{\startnamedsection[\v!chapter][\c!reference=pubs,\c!title={\currentbibtexsessiontitle}]}%
+ \fi
+ \dodoplacepublications
+ \stopnamedsection
+ \endgroup}
+
+%D And the portion with the entries only.
+
+\def\bibrefprefix{\number\bibtexblock:}
+
+\protected\def\placepublications
+ {\dosingleempty\doplacepublications}
+
+\protected\def\doplacepublications[#1]%
+ {\begingroup
+ \setuplist[pubs][#1]%
+ \dodoplacepublications
+ \endgroup}
+
+\protected\def\dodoplacepublications
+ {\determinelistcharacteristics[pubs]%
+ \initializepubslist
+ \doifnot{\namedlistparameter{pubs}\c!option}\v!continue
+ {\global\bibtexcounter\zerocount}%
+ \inpublisttrue
+ \typesetpubslist
+ \inpublistfalse
+ \global\advance\bibtexblock\plusone}
+
+%D \subsubject{What's in a publication}
+%D
+%D Watch out: here all means all publications in database, so use text when you want
+%D text only.
+
+\protected\def\typesetapublication#1%
+ {\doifsomething{#1}
+ {\doifelse{\namedlistparameter{pubs}\c!criterium}\v!all
+ {\doplacepublicationindeed{#1}}%
+ {\ctxlua{bibtex.hacks.doifalreadyplaced("#1")}
+ {}
+ {\doplacepublicationindeed{#1}}}%
+ }}
+
+%D For the moment we don't access the data directly but we will do that later when
+%D we get away from storing the data and only deal with references.
+
+% we'll define proper handlers later
+
+\protected\def\doplacepublicationindeed#1%
+ {\doifelsebibreferencefound{#1}
+ {\global\advance\bibtexcounter\plusone
+ \def\currentpublicationkey{#1}%
+ \ctxlua{bibtex.hacks.registerplaced("#1")}%
+ \def \currentlist {pubs}%
+ \edef\currentlistentrynumber {\number\bibtexcounter}%
+ \let \currentlistentrytitle \bibtexpubtext
+ \let \currentlistentrypagenumber\empty
+ \strc_lists_apply_renderingsetup}
+ {}} % invalid
+
+\protected\def\bibtexpubtext
+ {\expanded{\reference[\bibrefprefix\currentpublicationkey]{\number\bibtexcounter}}%
+ \strut\dotypesetapublication\currentpublicationkey\strut}
+
+\protected\def\dotypesetapublication#1%
+ {\bgroup
+ \the\initializebibdefinitions % NEW
+ \def\@@currentalternative{:l:}%
+ \presetbibvariables
+ \let\biblanguage\empty
+ \ignorespaces
+ \bibgetvard{#1}%
+ \removeunwantedspaces
+ \ignorespaces
+ \bibalternative{\bibgetvart{#1}}%
+ \removeunwantedspaces
+ \egroup}
+
+%D An few afterthoughts:
+
+\let\maybeyear\gobbleoneargument
+\let\noopsort \gobbleoneargument
+
+%D This is the result of bibtex's `language' field.
+
+\protected\def\setbiblanguage#1#2{\setvalue{\??pb\s!language#1}{#2}}
+
+\protected\def\lang#1%
+ {\edef\biblanguage{#1}%
+ \ifcsname\??pb\s!language#1\endcsname
+ \language[\getvalue{\??pb\s!language#1}]%
+ \fi
+ \ignorespaces}
+
+%D \subject{Citations}
+
+%D \macros{cite,bibref}
+%D
+%D The indirection with \type {\dobibref} allows \LATEX\ style \type {\cite}
+%D commands with a braced argument (these might appear in included data from the
+%D \type {.bib} file).
+
+\pushoverloadmode
+
+\protected\def\cite
+ {\strictdoifelsenextoptional\dodocite\dobibref}
+
+\popoverloadmode
+
+\protected\def\dobibref#1%
+ {\docite[#1][]}
+
+\protected\def\dodocite[#1]%
+ {\strictdoifelsenextoptional{\docite[#1]}{\docite[#1][]}}
+
+\protected\def\docite[#1][#2]%
+ {\begingroup
+ \doifelsesomething{#2}
+ {\dowhatevercite{#1}{#2}}%
+ {\donumberedcite{#1}}%
+ \endgroup}
+
+\protected\def\dowhatevercite#1#2%
+ {\processcommalist[#2]\docitation
+ \setupinteraction[\c!style=]%
+ \doifelseassignment
+ {#1}%
+ {\getparameters[LO][\c!alternative=,\c!extras=,#1]%
+ \edef\@@currentalternative{\LOalternative}%
+ \ifempty\@@currentalternative
+ \edef\@@currentalternative{\@@citedefault}%
+ \fi
+ \ifempty\LOextras
+ \setupcite[\@@currentalternative][#1]%
+ \else
+ \expandafter\ifrelax\csname \??pv \@@currentalternative\c!right\endcsname
+ % avoids tail recursion
+ \expandafter\let\csname \??pv \@@currentalternative\c!right\endcsname\empty
+ \fi
+ \expandafter\ifrelax\csname LOright\endcsname
+ \edef\LOextras{{\LOextras\bibalternative\c!right}}%
+ \else
+ \edef\LOextras{{\LOextras\LOright}}%
+ \fi
+ \expanded{\setupcite[\@@currentalternative][#1,\c!right=\LOextras]}%
+ \fi}%
+ {\def\@@currentalternative{#1}}%
+ \doifelsevalue{@@pv\@@currentalternative\c!compress}\v!no\bibcitecompressfalse\bibcitecompresstrue
+ \getvalue{bib\@@currentalternative ref}[#2]}
+
+\protected\def\donumberedcite#1%
+ {\processcommalist[#1]\docitation
+ \setupinteraction[\c!style=]%
+ \edef\@@currentalternative{\@@citedefault}%
+ \doifelsevalue{@@pv\@@currentalternative\c!compress}\v!no\bibcitecompressfalse\bibcitecompresstrue
+ \getvalue{bib\@@citedefault ref}[#1]}
+
+%D \macros{nocite}
+
+\pushoverloadmode
+
+\protected\def\nocite[#1]%
+ {\processcommalist[#1]\docitation}
+
+\popoverloadmode
+
+%D \macros{setupcite}
+
+\permanent\tolerant\protected\def\setupcite[#1]#*[#2]%
+ {\ifparameter#2\or
+ \def\dodosetupcite##1{\getparameters[\??pv##1][#2]}%
+ \processcommalist[#1]\dodosetupcite
+ \else % default case
+ \getparameters[\??pv\@@citedefault][#1]%
+ \fi}
+
+%D Low-level stuff
+
+\protected\def\getcitedata#1[#2]#*[#3]#*to#4%
+ {\bgroup
+ \dofetchapublication{#3}%
+ \doifelsedefined{\??pb @bib#2}%
+ {\xdef#4{\getvalue{\??pb @bib#2}}}%
+ {\xdef#4{\getvalue{\??pb @#2}}}%
+ \egroup}
+
+\protected\def\dofetchapublication#1%
+ {\def\currentpublicationkey{#1}%
+ \presetbibvariables
+ \ignorespaces\bibgetvard{#1}}
+
+\protected\def\docitation#1%
+ {\iftrialtypesetting \else
+ \expanded{\writedatatolist[pubs][bibref=#1]}%
+ \fi}
+
+\let\addthisref\gobbleoneargument % keep this for compatibility
+
+%D \macros{ixbibauthoryear,thebibauthors,thebibyears}
+%D
+%D If compression of \type {\cite}'s argument expansion is on, the macros that deal
+%D with authors and years call this internal command to do the actual typesetting.
+%D
+%D Two entries with same author but with different years may be condensed into
+%D ``Author (year1,year2)''. This is about the only optimization that makes sense
+%D for the (author,year) style of citations (years within one author have to be
+%D unique anyway so no need to test for that, and ``Author1, Author2 (year)''
+%D creates more confusion than it does good).
+%D
+%D In the code below, the macro \type {\thebibauthors} holds the names of the
+%D alternative author info fields for the current list. This is a commalist, and
+%D \type {\thebibyears} holds the (collection of) year(s) that go with this author
+%D (possibly as a nested commalist).
+%D
+%D There had better be an author for all cases, but there does not have to be year
+%D info always. \type{\thebibyears} is pre|-|initialized because this makes the
+%D insertion macros simpler.
+%D
+%D In normal \TEX, of course there are expansion problems again.
+
+%D Delegate this to \LUA.
+
+% \let\ixlastcommand \relax
+% \let\ixsecondcomman \relax
+% \let\ixfirstcommand \relax
+% \let\thebibauthors \empty
+% \let\thebibyears \empty
+% \let\authorcount \!!zerocount
+
+\let\currentbibauthor\empty
+
+\protected\def\ixbibauthoryear#1#2#3#4%
+ {\bgroup
+ \gdef\ixlastcommand {#4}%
+ \gdef\ixsecondcommand{#3}%
+ \gdef\ixfirstcommand {#2}%
+ \glet\thebibauthors \empty
+ \glet\thebibyears \empty
+ \getcommalistsize[#1]%
+ \ifbibcitecompress
+ \dorecurse\commalistsize{\xdef\thebibyears{\thebibyears,}}%
+ \processcommalist[#1]\docompressbibauthoryear
+ \else
+ \processcommalist[#1]\donormalbibauthoryear
+ \fi
+ \egroup
+ \dobibauthoryear}
+
+%D \macros{dodobibauthoryear}
+%D
+%D This macro only has to make sure that the lists \type {\thebibauthors} and \type
+%D {\thebibyears} are printed.
+
+\protected\def\dobibauthoryear
+ {\scratchcounter\zerocount
+ \getcommacommandsize[\thebibauthors]%
+ \edef\authorcount{\commalistsize}%
+ \expandafter\processcommalist\expandafter[\thebibauthors]\dodobibauthoryear}
+
+\protected\def\dodobibauthoryear#1%
+ {\advance\scratchcounter\plusone
+ \edef\wantednumber{\the\scratchcounter}%
+ \getfromcommacommand[\thebibyears][\wantednumber]%
+ \expandafter\def\expandafter\currentbibyear\expandafter{\commalistelement}%
+ \setcurrentbibauthor{#1}%
+ \ifnum\scratchcounter=\plusone
+ \ixfirstcommand
+ \orelse\ifnum \scratchcounter=\authorcount\relax
+ \ixlastcommand
+ \else
+ \ixsecondcommand
+ \fi}
+
+\protected\def\setcurrentbibauthor#1% sensitive for empty entries but I don't want to touch this
+ {\getcommacommandsize[#1]%
+ \ifcase\commalistsize
+ % anonymous?
+ \let\currentbibauthor\empty
+ \or
+ \def\currentbibauthor{#1}%
+ \or
+ \expanded{\docurrentbibauthor#1}%
+ \else
+ \handlemultiplebibauthors{\commalistsize}{#1}%
+ \fi}
+
+\newcount\citescratchcounter
+
+\protected\def\handlemultiplebibauthors#1#2%
+ {\citescratchcounter\zerocount
+ \let\currentbibauthor\empty
+ \protected\def\bibprocessauthoritem##1%
+ {\advance\citescratchcounter\plusone
+ \ifnum \citescratchcounter=#1\relax
+ \edef\currentbibauthor{\currentbibauthor##1}%
+ \orelse\ifnum\numexpr\citescratchcounter+\plusone\relax=#1\relax
+ \edef\currentbibauthor{\currentbibauthor##1\bibalternative{andtext}}%
+ \else
+ \edef\currentbibauthor{\currentbibauthor##1\bibalternative{namesep}}%
+ \fi}%
+ \processcommalist[#2]\bibprocessauthoritem}
+
+\setupcite
+ [author,authoryear,authoryears]
+ [\c!namesep={, }]
+
+%D This discovery of authoretallimit is not the best one,
+%D but it will do for now.
+
+\protected\def\docurrentbibauthor#1,#2%
+ {\doifelseempty{#2}
+ {\def\currentbibauthor{#1\bibalternative{otherstext}}}
+ {\expandafter\ifrelax\csname\??pv\@@currentalternative authoretallimit\endcsname
+ \edef\currentbibauthor{#1\bibalternative{andtext}#2}%
+ \else
+ \edef\currentbibauthor{#1%
+ \ifcase0\bibalternative{authoretallimit}\relax\or
+ \bibalternative{otherstext}\else\bibalternative{andtext}#2\fi}%
+ \fi}}
+
+%D This is not the one Hans made for me, because I need a global
+%D edef, and the \type {\robustdoifinsetelse} doesn't listen to
+%D \type {\doglobal}.
+
+\pushoverloadmode
+
+ \protected\def\robustaddtocommalist#1#2% {item} \cs
+ {\robustdoifelseinset{#1}#2\resetglobal
+ {\dodoglobal\xdef#2{\ifempty#2\else#2,\fi#1}}}
+
+\popoverloadmode
+
+%D \macros{donormalbibauthoryear}
+%D
+%D Now we get to the macros that fill the two lists. The \quote {simple} one really
+%D is quite simple.
+
+\protected\def\donormalbibauthoryear#1%
+ {\def\myauthor{Xxxxxxxxxx}%
+ \def\myyear{0000}%
+ \doifelsebibreferencefound{#1}
+ {\def\myauthor{{\bibgetvara{#1}}}%
+ \def\myyear {\bibgetvary{#1}}}%
+ {}%
+ \expandafter\doglobal\expandafter\appendtocommalist\expandafter{\myauthor}\thebibauthors
+ \expandafter\doglobal\expandafter\appendtocommalist\expandafter{\myyear }\thebibyears}
+
+%D \macros{docompressbibauthoryear}
+%D
+%D So much for the easy parts. Nothing at all will be done if the reference is not
+%D found or the reference does not contain author data. No questions marks o.s.s.
+%D (to be fixed later).
+
+\protected\def\docompressbibauthoryear#1%
+ {\def\myauthor{Xxxxxxxxxx}%
+ \def\myyear {0000}%
+ \doifelsebibreferencefound{#1}
+ {\xdef\myauthor{\bibgetvara{#1}}%
+ \xdef\myyear {\bibgetvary{#1}}}
+ {}%
+ \ifempty\myauthor\else
+ \checkifmyauthoralreadyexists
+ \findmatchingyear
+ \fi}
+
+%D Two temporary counters. One of these two can possibly be replaced by \type
+%D {\scratchcounter}.
+
+\newcount\bibitemcounter
+\newcount\bibitemwanted
+
+%D The first portion is simple enough: if this is the very first author it is quite
+%D straightforward to add it. \type {\bibitemcounter} and \type {\bibitemwanted} are
+%D needed later to insert the year information in the correct item of \type
+%D {\thebibyears}.
+
+\protected\def\checkifmyauthoralreadyexists
+ {\doifelseemptyvalue{thebibauthors}
+ {\global\bibitemwanted \plusone
+ \global\bibitemcounter\plusone
+ \xdef\thebibauthors{{\myauthor}}}
+ {% the next weirdness is because according to \getcommalistsize,
+ % the length of \type{[{{},{}}]} is 2.
+ \expandafter\getcommalistsize\expandafter[\thebibauthors,]%
+ \global\bibitemcounter\numexpr\commalistsize+\minusone\relax
+ \global\bibitemwanted \zerocount
+ \processcommacommand[\thebibauthors]\docomparemyauthor}}
+
+%D The outer \type {\ifnum} accomplishes the addition of a new author to \type
+%D {\thebibauthors}. The messing about with the two counters is again to make sure
+%D that \type {\thebibyears} will be updated correctly.If the author {\it was}
+%D found, the counters will stay at their present values and everything will be
+%D setup properly to insert the year info.
+
+\protected\def\docomparemyauthor#1%
+ {\global\advance\bibitemwanted \plusone
+ \def\mytempc{#1}%
+ \ifx\mytempc\myauthor
+ \quitcommalist
+ \orelse\ifnum\bibitemwanted=\bibitemcounter\relax
+ \global\advance\bibitemwanted \plusone
+ \global\bibitemcounter\bibitemwanted\relax
+ \expandafter\doglobal\expandafter\robustaddtocommalist\expandafter{{\myauthor}}\thebibauthors
+ \fi}
+
+%D This macro should be clear now.
+
+\protected\def\findmatchingyear
+ {\edef\wantednumber{\the\bibitemwanted}%
+ \getfromcommacommand[\thebibyears][\wantednumber]%
+ \ifempty\commalistelement
+ \edef\myyear{{\myyear}}%
+ \else
+ \edef\myyear{{\commalistelement,\myyear}}%
+ \fi
+ \edef\newcommalistelement{\myyear}%
+ \doglobal\replaceincommalist \thebibyears \wantednumber}
+
+%D \macros{gotobiblink,inbiblink,atbiblink}
+%D
+%D The final task is looping over that list until a match is found.
+
+%D Beware, we can have cites without reference match.
+
+\protected\def\gotobiblink#1[#2]{\doifelsereferencefound{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}}
+\protected\def\atbiblink [#1]{\doifelsereferencefound{\bibrefprefix#1}{\at [\bibrefprefix#1]}{#1}}
+\protected\def\inbiblink [#1]{\doifelsereferencefound{\bibrefprefix#1}{\expanded{\goto{\currentreferencetext}}[\bibrefprefix#1]}{#1}}
+
+%D \macros{bibauthoryearref,bibauthoryearsref,bibauthorref,bibyearref}
+%D
+%D Now that all the hard work has been done, these are simple. \type
+%D {\ixbibauthoryearref} stores the data in the macros \type {\currentbibauthor} and
+%D \type {\currentbibyear}.
+
+\protected\def\doifelsebibinteraction
+ {\iflocation
+ \edef\test{\bibalternative\c!interaction}%
+ \ifx\test\v!stop
+ \doubleexpandafter\secondoftwoarguments
+ \else
+ \doubleexpandafter\firstoftwoarguments
+ \fi
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\let\doifbibinteractionelse\doifelsebibinteraction
+
+\protected\def\bibmaybeinteractive#1#2%
+ {\doifelsebibinteraction{\gotobiblink{#2}[#1]}{#2}}
+
+\protected\def\bibauthoryearref[#1]%
+ {\ixbibauthoryear{#1}%
+ {\bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween
+ \bibalternative\v!left{\currentbibyear}\bibalternative\v!right}}
+ {\bibalternative\c!pubsep
+ \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween
+ \bibalternative\v!left {\currentbibyear}\bibalternative\v!right}}
+ {\bibalternative\c!lastpubsep
+ \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween
+ \bibalternative\v!left {\currentbibyear}\bibalternative\v!right}}}
+
+\protected\def\bibauthoryearsref[#1]%
+ {\bibalternative\v!left
+ \ixbibauthoryear{#1}
+ {\bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween{\currentbibyear}}}
+ {\bibalternative\c!pubsep
+ \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween{\currentbibyear}}}
+ {\bibalternative\c!lastpubsep
+ \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween{\currentbibyear}}}%
+ \bibalternative\v!right}
+
+\protected\def\bibauthorref[#1]%
+ {\bibalternative\v!left
+ \ixbibauthoryear{#1}%
+ {\bibmaybeinteractive{#1}{{\currentbibauthor}}}
+ {\bibalternative\c!pubsep \bibmaybeinteractive{#1}{{\currentbibauthor}}}
+ {\bibalternative\c!lastpubsep\bibmaybeinteractive{#1}{{\currentbibauthor}}}%
+ \bibalternative\v!right}
+
+\protected\def\bibyearref[#1]%
+ {\bibalternative\v!left
+ \ixbibauthoryear{#1}%
+ {\bibmaybeinteractive{#1}{{\currentbibyear}}}
+ {\bibalternative\c!pubsep \bibmaybeinteractive{#1}{{\currentbibyear}}}
+ {\bibalternative\c!lastpubsep\bibmaybeinteractive{#1}{{\currentbibyear}}}%
+ \bibalternative\v!right}
+
+%D \macros{bibshortref,bibkeyref,bibpageref,bibtyperef,bibserialref}
+%D
+%D There is hardly any point in trying to compress these. The only thing that needs
+%D to be done is making sure that the separations are inserted correctly. And that
+%D is what \type {\bibinsertrefsep} does.
+
+\newconditional\firstbibrefsep
+
+\protected\def\bibresetrefsep
+ {\settrue\firstbibrefsep}
+
+\protected\def\bibinsertrefsep
+ {\ifconditional\firstbibrefsep
+ \setfalse\firstbibrefsep
+ \else
+ \bibalternative\c!pubsep
+ \fi}
+
+\protected\def\bibshortref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibshortref
+ \bibalternative\v!right}
+
+\protected\def\dobibshortref#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\gotobiblink{\bibgetvars{#1}}[#1]}
+ {}}
+
+\protected\def\bibserialref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibserialref
+ \bibalternative\v!right}
+
+\protected\def\dobibserialref#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\gotobiblink{\bibgetvarn{#1}}[#1]}
+ {}}
+
+\protected\def\bibkeyref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibkeyref
+ \bibalternative\v!right}
+
+\protected\def\dobibkeyref#1%
+ {\bibinsertrefsep
+ \gotobiblink{#1}[#1]}
+
+\protected\def\bibgotoDOI#1#2%
+ {\doifelsebibinteraction
+ {\useURL[bibfooDoi#1][#2]%
+ \useURL[bibfoo#1][http://dx.doi.org/#2]%
+ \goto{\url[bibfooDoi#1]}[url(bibfoo#1)]}
+ {\hyphenatedurl{#2}}}
+
+\protected\def\bibdoiref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibdoiref
+ \bibalternative\v!right}
+
+\protected\def\dobibdoiref#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\expanded{\bibgotoDOI{#1}{\bibgetvaro{#1}}}}
+ {}}
+
+\protected\def\biburlref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobiburlref
+ \bibalternative\v!right}
+
+\protected\def\bibgotoURL#1#2%
+ {\doifelsebibinteraction
+ {\useURL[bibfoo#1][#2]\goto{\url[bibfoo#1]}[url(bibfoo#1)]}
+ {\hyphenatedurl{#2}}}
+
+\protected\def\dobiburlref#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\expanded{\bibgotoURL{#1}{\bibgetvaru{#1}}}}
+ {}}
+
+\protected\def\bibtyperef[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibtyperef
+ \bibalternative\v!right}
+
+\protected\def\dobibtyperef#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\gotobiblink{\bibgetvart{#1}}[#1]}
+ {}}
+
+\protected\def\bibpageref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibpageref
+ \bibalternative\v!right}
+
+\protected\def\dobibpageref#1%
+ {\bibinsertrefsep
+ \doifelsebibinteraction
+ {\atbiblink[#1]}
+ {{\referencingfalse\at[#1]}}}
+
+\protected\def\bibdataref[#1]%
+ {\bibalternative\v!left
+ \bibresetrefsep\processcommalist[#1]\dobibdata
+ \bibalternative\v!right}
+
+\protected\def\dobibdata#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\dotypesetapublication{#1}}
+ {}}
+
+\let\bibnoneref\nocite
+
+%D \macros{bibnumref}
+
+\protected\def\bibnumref[#1]%
+ {\begingroup
+ \bibalternative\v!left
+ \penalty\plustenthousand
+ \ctxlua{bibtex.hacks.resolve("","\number\bibtexblock","#1")}%
+ \bibalternative\v!right
+ \endgroup}
+
+\protected\def\dowithbibtexnumrefconnector#1#2%
+ {\ifnum#1>\plusone
+ \ifnum#2>\plusone
+ \ifnum#2=#1\relax
+ \bibalternative{lastpubsep}%
+ \else
+ \bibalternative{pubsep}%
+ \fi
+ \fi
+ \fi}
+
+\protected\def\dowithbibtexnumref#1#2#3#4#5% n, i, prefix block ref
+ {\dowithbibtexnumrefconnector{#1}{#2}%
+ \def\bibrefprefix{#4:}%
+ \inbiblink[#5]}
+
+\protected\def\dowithbibtexnumrefrange#1#2#3#4#5#6#7% n, i, prefix block ref
+ {\dowithbibtexnumrefconnector{#1}{#2}%
+ \def\bibrefprefix{#4:}%
+ \inbiblink[#5]%
+ \endash
+ \def\bibrefprefix{#6:}%
+ \inbiblink[#7]}
+
+%D By request from Sanjoy. This makes it easier to implement \type {\citeasnoun}.
+
+\protected\def\bibauthornumref[#1]%
+ {\getcommalistsize[#1]%
+ \global\bibitemcounter\commalistsize
+ \bibresetrefsep
+ \processcommalist[#1]\dobibauthornumref}
+
+\protected\def\dobibauthornumref#1%
+ {\bibinsertrefsep
+ \doifelsebibreferencefound{#1}
+ {\begingroup
+ \cite[\c!left=,\c!right=,\c!alternative=\v!author][#1]%
+ \bibalternative\c!inbetween
+ \cite[num][#1]%
+ \endgroup}
+ {}}
+
+%D And some defaults are loaded from bibl-apa:
+
+\setuppublications
+ [\c!monthconversion=,
+ \c!alternative=apa,
+ \c!method=\v!global,
+ %\c!criterium=\v!previous,
+ \c!criterium=\v!cite, % mojca wants this so bother her, not me
+ \c!refcommand=num,
+ \c!numbercommand=\bibleftnumber]
+
+\protected\def\preloadbiblist
+ {\glet\preloadbiblist\relax
+ \dousepublications\jobname}
+
+% \appendtoks \preloadbiblist \to \everysetuppublications
+% \appendtoks \preloadbiblist \to \everystarttext
+
+\let\ifbibinteractionelse\doifbibinteractionelse
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/blob-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/blob-ini.lmt
new file mode 100644
index 00000000000..42a18fddde0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/blob-ini.lmt
@@ -0,0 +1,210 @@
+if not modules then modules = { } end modules ['blob-ini'] = {
+ version = 1.001,
+ comment = "companion to blob-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This module is just a playground. Occasionally we need to typeset at the lua and and
+-- this is one method. In principle we can construct pages this way too which sometimes
+-- makes sense in dumb cases. Actually, if one only needs this, one does not really need
+-- tex, okay maybe the parbuilder but that one can be simplified as well then.
+
+-- set fonts, attributes
+-- rest already done in packers etc
+-- add local par whatsit (or wait till cleaned up)
+-- collapse or new pars
+-- interline spacing etc
+
+-- blob.char
+-- blob.line
+-- blob.paragraph
+-- blob.page
+
+local type, tostring = type, tostring
+local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+
+local report_blobs = logs.reporter("blobs")
+
+local flush_node_list = node.flush_list
+local hpack_node_list = node.hpack
+----- vpack_node_list = node.vpack
+local write_node = node.write
+
+local typesetters = nodes.typesetters
+local tonodes = typesetters.tonodes
+local tohpack = typesetters.tohpack
+local tovpack = typesetters.tovpack
+
+local implement = interfaces.implement
+
+-- provide copies here (nicer for manuals)
+
+blobs = blobs or { }
+local blobs = blobs
+
+blobs.tonodes = tonodes
+blobs.tohpack = tohpack
+blobs.tovpack = tovpack
+
+-- end of helpers
+
+local newline = lpeg.patterns.newline
+local space = lpeg.patterns.spacer
+local newpar = (space^0*newline*space^0)^2
+
+local ctxtextcapture = lpeg.Ct ( ( space^0 * ( newpar + lpeg.Cs(((space^1/" " + 1)-newpar)^1) ) )^0)
+
+function blobs.new()
+ return {
+ list = { },
+ }
+end
+
+function blobs.dispose(t)
+ local list = t.list
+ for i=1,#list do
+ local li = list[i]
+ local pack = li.pack
+ if pack then
+ flush_node_list(pack)
+ li.pack = nil
+ end
+ end
+end
+
+function blobs.append(t,str) -- compare concat and link
+ local typ = type(str)
+ local dummy = nil
+ if typ == "number" then
+ str = tostring(str)
+ typ = "string"
+ end
+ if typ == "string" then
+ local pars = lpegmatch(ctxtextcapture,str)
+ local list = t.list
+ for p=1,#pars do
+ local head, tail = tonodes(pars[p],nil,nil)
+ list[#list+1] = { head = head, tail = tail }
+ end
+ end
+end
+
+function blobs.pack(t,how)
+ local list = t.list
+ for i=1,#list do
+ local pack = list[i].pack
+ if pack then
+ flush_node_list(node.pack)
+ end
+ if how == "vertical" then
+ -- we need to prepend a local par node
+ -- list[i].pack = vpack_node_list(list[i].head,"exactly")
+ report_blobs("vpack not yet supported")
+ else
+ list[i].pack = hpack_node_list(list[i].head,"exactly")
+ end
+ end
+end
+
+function blobs.write(t)
+ local list = t.list
+ for i=1,#list do
+ local li = list[i]
+ local pack = li.pack
+ if pack then
+ write_node(pack)
+ flush_node_list(pack)
+ li.pack = nil
+ end
+ end
+end
+
+function blobs.dimensions(t)
+ local list = t.list
+ local first = list and list[1]
+ if first then
+ local pack = first.pack
+ return pack.width, pack.height, pack.depth
+ else
+ return 0, 0, 0
+ end
+end
+
+-- blob.char
+-- blob.line: head, tail
+-- blob.paragraph
+-- blob.page
+
+-- local lineblob = {
+-- type = "line",
+-- head = false,
+-- tail = false,
+-- pack = false,
+-- properties = { },
+-- end
+
+-- local parblob = {
+-- type = "line",
+-- head = false,
+-- tail = false,
+-- pack = false,
+-- properties = { },
+-- end
+
+-- for the moment here:
+
+local function strwd(str)
+ local l = tohpack(str)
+ local w = l.width
+ flush_node_list(l)
+ return w
+end
+
+local function strht(str)
+ local l = tohpack(str)
+ local h = l.height
+ flush_node_list(l)
+ return h
+end
+
+local function strdp(str)
+ local l = tohpack(str)
+ local d = l.depth
+ flush_node_list(l)
+ return d
+end
+
+local function strhd(str)
+ local l = tohpack(str)
+ local s = l.height + l.depth
+ flush_node_list(l)
+ return s
+end
+
+blobs.strwd = strwd
+blobs.strht = strht
+blobs.strdp = strdp
+blobs.strhd = strhd
+
+-- upgraded
+
+local dimension_code = tokens.values.dimension
+local scan_hbox = tokens.scanners.hbox
+
+local function action(field,what)
+ local l = scan_hbox()
+ local d = l[field]
+ flush_node_list(l)
+ if what == "value" then
+ return dimension_code, d
+ else
+ context("%p",d)
+ end
+end
+
+implement { name = "widthofstring", public = true, usage = "value", actions = function(w) return action("width", w) end }
+implement { name = "heightofstring", public = true, usage = "value", actions = function(w) return action("height",w) end }
+implement { name = "depthofstring", public = true, usage = "value", actions = function(w) return action("depth", w) end }
+implement { name = "totalofstring", public = true, usage = "value", actions = function(w) return action("total", w) end }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/blob-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/blob-ini.mkxl
new file mode 100644
index 00000000000..1dcd5597254
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/blob-ini.mkxl
@@ -0,0 +1,56 @@
+%D \module
+%D [ file=blob-ini,
+%D version=2010.04.06,
+%D title=\CONTEXT\ \LUA\ Typesetting,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Typesetting / Initialization}
+
+%D This is a prelude to typesetting at the \LUA\ end. The code
+%D is already quite old but will only get nice when we are further
+%D down the road (close to version 1.00 of \LUATEX). Typesetting in
+%D pure \LUA\ sometimes makes sense.
+
+\registerctxluafile{node-typ}{} % experimental
+\registerctxluafile{blob-ini}{autosuffix}
+
+\unprotect
+
+% \widthofstring % defined in lua
+% \heightofstring % defined in lua
+% \depthofstring % defined in lua
+% \heightanddepthofstring % defined in lua
+
+\permanent\def\wdofstring#1{\dimexpr\widthofstring {#1}\relax} % assured an dimen
+\permanent\def\htofstring#1{\dimexpr\heightofstring{#1}\relax} % assured an dimen
+\permanent\def\dpofstring#1{\dimexpr\depthofstring {#1}\relax} % assured an dimen
+\permanent\def\hdofstring#1{\dimexpr\totalofstring {#1}\relax} % assured an dimen
+
+\aliased\let\heightanddepthofstring\totalofstring
+\aliased\let\htdpofstring \hdofstring
+
+% \let\hd\htdp % if yes then move this
+
+% This one takes anything that can be typeset
+
+\permanent\protected\def\setwidthof#1\to#2{\edef#2{\widthofstring{#1}}}
+
+\protect \endinput
+
+% \starttext
+%
+% \startluacode
+% local b = blobs.new()
+% blobs.append(b,"Hello world.\n Here we are.\n\n And Again!")
+% blobs.pack(b)
+% blobs.write(b)
+% \stopluacode
+%
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/buff-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/buff-ini.lmt
new file mode 100644
index 00000000000..41e8a50785e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/buff-ini.lmt
@@ -0,0 +1,900 @@
+if not modules then modules = { } end modules ['buff-ini'] = {
+ version = 1.001,
+ comment = "companion to buff-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local concat = table.concat
+local type, next, load = type, next, load
+local sub, format = string.sub, string.format
+local splitlines, validstring, replacenewlines = string.splitlines, string.valid, string.replacenewlines
+local P, Cs, patterns, lpegmatch = lpeg.P, lpeg.Cs, lpeg.patterns, lpeg.match
+local utfchar = utf.char
+local nameonly = file.nameonly
+local totable = string.totable
+local md5hex = md5.hex
+local isfile = lfs.isfile
+local savedata = io.savedata
+
+local trace_run = false trackers.register("buffers.run", function(v) trace_run = v end)
+local trace_grab = false trackers.register("buffers.grab", function(v) trace_grab = v end)
+local trace_visualize = false trackers.register("buffers.visualize", function(v) trace_visualize = v end)
+
+local report_buffers = logs.reporter("buffers","usage")
+local report_typeset = logs.reporter("buffers","typeset")
+----- report_grabbing = logs.reporter("buffers","grabbing")
+
+local context = context
+local commands = commands
+
+local implement = interfaces.implement
+
+local scanners = tokens.scanners
+local scanstring = scanners.string
+local scancsname = scanners.csname
+local scaninteger = scanners.integer
+local scanboolean = scanners.boolean
+local scancode = scanners.code
+local scantokencode = scanners.tokencode
+----- scantoken = scanners.token
+
+local getters = tokens.getters
+local gettoken = getters.token
+
+local getcommand = token.get_command
+----- getcsname = token.get_csname
+local getnextchar = token.scan_next_char or token.get_next_char
+
+local variables = interfaces.variables
+local settings_to_array = utilities.parsers.settings_to_array
+local formatters = string.formatters
+local addsuffix = file.addsuffix
+local replacesuffix = file.replacesuffix
+
+local registertempfile = luatex.registertempfile
+
+local v_yes = variables.yes
+
+local eol = patterns.eol
+local space = patterns.space
+local whitespace = patterns.whitespace
+local blackspace = whitespace - eol
+local whatever = (1-eol)^1 * eol^0
+local emptyline = space^0 * eol
+
+local catcodenumbers = catcodes.numbers
+
+local ctxcatcodes = catcodenumbers.ctxcatcodes
+local txtcatcodes = catcodenumbers.txtcatcodes
+
+local setdata = job.datasets.setdata
+local getdata = job.datasets.getdata
+
+local ctx_viafile = context.viafile
+local ctx_getbuffer = context.getbuffer
+local ctx_pushcatcodetable = context.pushcatcodetable
+local ctx_popcatcodetable = context.popcatcodetable
+local ctx_setcatcodetable = context.setcatcodetable
+local ctx_printlines = context.printlines
+
+buffers = buffers or { }
+local buffers = buffers
+
+local cache = { }
+
+local function erase(name)
+ cache[name] = nil
+end
+
+local function assign(name,str,catcodes)
+ cache[name] = {
+ data = str,
+ catcodes = catcodes,
+ typeset = false,
+ }
+end
+
+local function combine(name,str,prepend)
+ local buffer = cache[name]
+ if buffer then
+ buffer.data = prepend and (str .. buffer.data) or (buffer.data .. str)
+ buffer.typeset = false
+ else
+ cache[name] = {
+ data = str,
+ typeset = false,
+ }
+ end
+end
+
+local function prepend(name,str)
+ combine(name,str,true)
+end
+
+local function append(name,str)
+ combine(name,str)
+end
+
+local function exists(name)
+ return cache[name]
+end
+
+local function getcontent(name)
+ local buffer = name and cache[name]
+ return buffer and buffer.data or ""
+end
+
+local function getlines(name)
+ local buffer = name and cache[name]
+ return buffer and splitlines(buffer.data)
+end
+
+local function getnames(name)
+ if type(name) == "string" then
+ return settings_to_array(name)
+ else
+ return name
+ end
+end
+
+local function istypeset(name)
+ local names = getnames(name)
+ if #names == 0 then
+ return false
+ end
+ for i=1,#names do
+ local c = cache[names[i]]
+ if c and not c.typeset then
+ return false
+ end
+ end
+ return true
+end
+
+local function markastypeset(name)
+ local names = getnames(name)
+ for i=1,#names do
+ local c = cache[names[i]]
+ if c then
+ c.typeset = true
+ end
+ end
+end
+
+local function collectcontent(name,separator) -- no print
+ local names = getnames(name)
+ local nnames = #names
+ if nnames == 0 then
+ return getcontent("") -- default buffer
+ elseif nnames == 1 then
+ return getcontent(names[1])
+ else
+ local t = { }
+ local n = 0
+ for i=1,nnames do
+ local c = getcontent(names[i])
+ if c ~= "" then
+ n = n + 1
+ t[n] = c
+ end
+ end
+ -- the default separator was \r, then \n and is now os.newline because buffers
+ -- can be loaded in other applications
+ return concat(t,separator or os.newline)
+ end
+end
+
+local function loadcontent(name) -- no print
+ local content = collectcontent(name,"\n") -- tex likes \n hm, elsewhere \r
+ local ok, err = load(content)
+ if ok then
+ return ok()
+ else
+ report_buffers("invalid lua code in buffer %a: %s",name,err or "unknown error")
+ end
+end
+
+buffers.raw = getcontent
+buffers.erase = erase
+buffers.assign = assign
+buffers.prepend = prepend
+buffers.append = append
+buffers.exists = exists
+buffers.getcontent = getcontent
+buffers.getlines = getlines
+buffers.collectcontent = collectcontent
+buffers.loadcontent = loadcontent
+
+-- the context interface
+
+implement {
+ name = "assignbuffer",
+ actions = assign,
+ arguments = { "string", "string", "integer" }
+}
+
+implement {
+ name = "erasebuffer",
+ actions = erase,
+ arguments = "string"
+}
+
+-- local anything = patterns.anything
+-- local alwaysmatched = patterns.alwaysmatched
+-- local utf8character = patterns.utf8character
+--
+-- local function countnesting(b,e)
+-- local n
+-- local g = P(b) / function() n = n + 1 end
+-- + P(e) / function() n = n - 1 end
+-- -- + anything
+-- + utf8character
+-- local p = alwaysmatched / function() n = 0 end
+-- * g^0
+-- * alwaysmatched / function() return n end
+-- return p
+-- end
+
+local counters = { }
+local nesting = 0
+local autoundent = true
+local continue = false
+
+-- Beware: the first character of bufferdata has to be discarded as it's there to
+-- prevent gobbling of newlines in the case of nested buffers. The last one is
+-- a newlinechar and is removed too.
+--
+-- An \n is unlikely to show up as \r is the endlinechar but \n is more generic
+-- for us.
+
+-- This fits the way we fetch verbatim: the indentation before the sentinel
+-- determines the stripping.
+
+-- str = [[
+-- test test test test test test test
+-- test test test test test test test
+-- test test test test test test test
+--
+-- test test test test test test test
+-- test test test test test test test
+-- test test test test test test test
+-- ]]
+
+-- local function undent(str)
+-- local margin = match(str,"[\n\r]( +)[\n\r]*$") or ""
+-- local indent = #margin
+-- if indent > 0 then
+-- local lines = splitlines(str)
+-- local ok = true
+-- local pattern = "^" .. margin
+-- for i=1,#lines do
+-- local l = lines[i]
+-- if find(l,pattern) then
+-- lines[i] = sub(l,indent+1)
+-- else
+-- ok = false
+-- break
+-- end
+-- end
+-- if ok then
+-- return concat(lines,"\n")
+-- end
+-- end
+-- return str
+-- end
+
+-- how about tabs
+
+local strippers = { }
+local nofspaces = 0
+
+local normalline = space^0 / function(s) local n = #s if n < nofspaces then nofspaces = n end end
+ * whatever
+
+local getmargin = (emptyline + normalline)^1
+
+local function undent(str) -- new version, needs testing: todo: not always needed, like in xtables
+ nofspaces = #str
+ local margin = lpegmatch(getmargin,str)
+ if nofspaces == #str or nofspaces == 0 then
+ return str
+ end
+ local stripper = strippers[nofspaces]
+ if not stripper then
+ stripper = Cs(((space^-nofspaces)/"" * whatever + emptyline)^1)
+ strippers[nofspaces] = stripper
+ end
+ return lpegmatch(stripper,str) or str
+end
+
+buffers.undent = undent
+
+-- function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes,doundent) -- maybe move \\ to call
+-- local dn = getcontent(name)
+-- if dn == "" then
+-- nesting = 0
+-- continue = false
+-- end
+-- if trace_grab then
+-- if #bufferdata > 30 then
+-- report_grabbing("%s => |%s..%s|",name,sub(bufferdata,1,10),sub(bufferdata,-10,#bufferdata))
+-- else
+-- report_grabbing("%s => |%s|",name,bufferdata)
+-- end
+-- end
+-- local counter = counters[begintag]
+-- if not counter then
+-- counter = countnesting(begintag,endtag)
+-- counters[begintag] = counter
+-- end
+-- nesting = nesting + lpegmatch(counter,bufferdata)
+-- local more = nesting > 0
+-- if more then
+-- dn = dn .. sub(bufferdata,2,-1) .. endtag
+-- nesting = nesting - 1
+-- continue = true
+-- else
+-- if continue then
+-- dn = dn .. sub(bufferdata,2,-2) -- no \r, \n is more generic
+-- elseif dn == "" then
+-- dn = sub(bufferdata,2,-2)
+-- else
+-- dn = dn .. "\n" .. sub(bufferdata,2,-2) -- no \r, \n is more generic
+-- end
+-- local last = sub(dn,-1)
+-- if last == "\n" or last == "\r" then -- \n is unlikely as \r is the endlinechar
+-- dn = sub(dn,1,-2)
+-- end
+-- if doundent or (autoundent and doundent == nil) then
+-- dn = undent(dn)
+-- end
+-- end
+-- assign(name,dn,catcodes)
+-- commands.doifelse(more)
+-- end
+
+local split = table.setmetatableindex(function(t,k)
+ local v = totable(k)
+ t[k] = v
+ return v
+end)
+
+local tochar = {
+ [ 0] = "\\",
+ [ 1] = "{",
+ [ 2] = "}",
+ [ 3] = "$",
+ [ 4] = "&",
+ [ 5] = "\n",
+ [ 6] = "#",
+ [ 7] = "^",
+ [ 8] = "_",
+ [10] = " ",
+ [14] = "%",
+}
+
+local experiment = false
+local experiment = scantokencode and true
+
+local function pickup(start,stop)
+ local stoplist = split[stop] -- totable(stop)
+ local stoplength = #stoplist
+ local stoplast = stoplist[stoplength]
+ local startlist = split[start] -- totable(start)
+ local startlength = #startlist
+ local startlast = startlist[startlength]
+ local list = { }
+ local size = 0
+ local depth = 0
+-- local done = 32
+ local scancode = experiment and scantokencode or scancode
+ while true do -- or use depth
+ local char = scancode()
+ if char then
+-- if char < done then
+-- -- we skip leading control characters so that we can use them to
+-- -- obey spaces (a dirty trick)
+-- else
+-- done = 0
+ char = utfchar(char)
+ size = size + 1
+ list[size] = char
+ if char == stoplast and size >= stoplength then
+ local done = true
+ local last = size
+ for i=stoplength,1,-1 do
+ if stoplist[i] ~= list[last] then
+ done = false
+ break
+ end
+ last = last - 1
+ end
+ if done then
+ if depth > 0 then
+ depth = depth - 1
+ else
+ break
+ end
+ char = false -- trick: let's skip the next (start) test
+ end
+ end
+ if char == startlast and size >= startlength then
+ local done = true
+ local last = size
+ for i=startlength,1,-1 do
+ if startlist[i] ~= list[last] then
+ done = false
+ break
+ end
+ last = last - 1
+ end
+ if done then
+ depth = depth + 1
+ end
+ end
+-- end
+ else
+ -- local t = scantoken()
+ local t = gettoken()
+ if t then
+ -- we're skipping leading stuff, like obeyedlines and relaxes
+ if experiment and size > 0 then
+ -- we're probably in a macro
+ local char = tochar[getcommand(t)]
+ if char then
+ size = size + 1 ; list[size] = char
+ else
+-- local csname = getcsname(t)
+ local csname = scancsname(t)
+ if csname == stop then
+ stoplength = 0
+ break
+ else
+ size = size + 1 ; list[size] = "\\"
+ size = size + 1 ; list[size] = csname
+ size = size + 1 ; list[size] = " "
+ end
+ end
+ else
+ -- ignore and hope for the best
+ end
+ else
+ break
+ end
+ end
+ end
+ local start = 1
+ local stop = size - stoplength - 1
+ -- not good enough: only empty lines, but even then we miss the leading
+ -- for verbatim
+ --
+ -- the next is not yet adapted to the new scanner ... we don't need lpeg here
+ --
+ for i=start,stop do
+ local li = list[i]
+ if lpegmatch(blackspace,li) then
+ -- keep going
+ elseif lpegmatch(eol,li) then
+ -- okay
+ start = i + 1
+ else
+ break
+ end
+ end
+ for i=stop,start,-1 do
+ if lpegmatch(whitespace,list[i]) then
+ stop = i - 1
+ else
+ break
+ end
+ end
+ --
+ if start <= stop then
+ return concat(list,"",start,stop)
+ else
+ return ""
+ end
+end
+
+-- -- lmtx:
+--
+-- local function pickup(start,stop)
+-- local stoplist = split[stop] -- totable(stop)
+-- local stoplength = #stoplist
+-- local stoplast = stoplist[stoplength]
+-- local startlist = split[start] -- totable(start)
+-- local startlength = #startlist
+-- local startlast = startlist[startlength]
+-- local list = { }
+-- local size = 0
+-- local depth = 0
+-- getnextchar() -- we start with a \relax
+-- while true do -- or use depth
+-- local char = getnextchar()
+-- if char then
+-- size = size + 1
+-- list[size] = char
+-- if char == stoplast and size >= stoplength then
+-- local done = true
+-- local last = size
+-- for i=stoplength,1,-1 do
+-- if stoplist[i] ~= list[last] then
+-- done = false
+-- break
+-- end
+-- last = last - 1
+-- end
+-- if done then
+-- if depth > 0 then
+-- depth = depth - 1
+-- else
+-- break
+-- end
+-- char = false -- trick: let's skip the next (start) test
+-- end
+-- end
+-- if char == startlast and size >= startlength then
+-- local done = true
+-- local last = size
+-- for i=startlength,1,-1 do
+-- if startlist[i] ~= list[last] then
+-- done = false
+-- break
+-- end
+-- last = last - 1
+-- end
+-- if done then
+-- depth = depth + 1
+-- end
+-- end
+-- else
+-- local t = gettoken()
+-- if t then
+-- -- we're skipping leading stuff, like obeyedlines and relaxes
+-- if experiment and size > 0 then
+-- -- we're probably in a macro
+-- local char = tochar[getcommand(t)]
+-- if char then
+-- size = size + 1 ; list[size] = char
+-- else
+-- local csname = getcsname(t)
+ local csname = scancsname(t)
+-- if csname == stop then
+-- stoplength = 0
+-- break
+-- else
+-- size = size + 1 ; list[size] = "\\"
+-- size = size + 1 ; list[size] = csname
+-- size = size + 1 ; list[size] = " "
+-- end
+-- end
+-- else
+-- -- ignore and hope for the best
+-- end
+-- else
+-- break
+-- end
+-- end
+-- end
+-- local start = 1
+-- local stop = size - stoplength - 1
+-- -- not good enough: only empty lines, but even then we miss the leading
+-- -- for verbatim
+-- --
+-- -- the next is not yet adapted to the new scanner ... we don't need lpeg here
+-- --
+-- for i=start,stop do
+-- local li = list[i]
+-- if lpegmatch(blackspace,li) then
+-- -- keep going
+-- elseif lpegmatch(eol,li) then
+-- -- okay
+-- start = i + 1
+-- else
+-- break
+-- end
+-- end
+-- for i=stop,start,-1 do
+-- if lpegmatch(whitespace,list[i]) then
+-- stop = i - 1
+-- else
+-- break
+-- end
+-- end
+-- --
+-- if start <= stop then
+-- return concat(list,"",start,stop)
+-- else
+-- return ""
+-- end
+-- end
+
+-- function buffers.pickup(name,start,stop,finish,catcodes,doundent)
+-- local data = tokens.pickup(start,stop)
+-- if doundent or (autoundent and doundent == nil) then
+-- data = buffers.undent(data)
+-- end
+-- buffers.assign(name,data,catcodes)
+-- context(finish)
+-- end
+
+-- commands.pickupbuffer = buffers.pickup
+
+tokens.pickup = pickup
+
+implement {
+ name = "pickupbuffer",
+ actions = function()
+ -- let's pickup all here (no arguments)
+ local name = scanstring()
+ local start = scanstring()
+ local stop = scanstring()
+ local finish = scancsname()
+ local catcodes = scaninteger()
+ local doundent = scanboolean()
+ -- could be a scanner:
+ local data = pickup(start,stop)
+ if doundent or (autoundent and doundent == nil) then
+ data = undent(data)
+ end
+ buffers.assign(name,data,catcodes)
+ context[finish]()
+ end
+}
+
+local function savebuffer(list,name,prefix) -- name is optional
+ if not list or list == "" then
+ list = name
+ end
+ if not name or name == "" then
+ name = list
+ end
+ local content = collectcontent(list,nil) or ""
+ if content == "" then
+ content = "empty buffer"
+ end
+ if prefix == v_yes then
+ name = addsuffix(tex.jobname .. "-" .. name,"tmp")
+ end
+ io.savedata(name,replacenewlines(content))
+end
+
+implement {
+ name = "savebuffer",
+ actions = savebuffer,
+ arguments = "3 strings",
+}
+
+-- we can consider adding a size to avoid unlikely clashes
+
+local olddata = nil
+local newdata = nil
+local getrunner = sandbox.getrunner
+
+local runner = sandbox.registerrunner {
+ name = "run buffer",
+ program = "context",
+ method = "execute",
+ template = jit and "--purgeall --jit %filename%" or "--purgeall %filename%",
+ reporter = report_typeset,
+ checkers = {
+ filename = "readable",
+ }
+}
+
+local function runbuffer(name,encapsulate,runnername,suffixes)
+ if not runnername or runnername == "" then
+ runnername = "run buffer"
+ end
+ local suffix = "pdf"
+ if type(suffixes) == "table" then
+ suffix = suffixes[1]
+ elseif type(suffixes) == "string" and suffixes ~= "" then
+ suffix = suffixes
+ suffixes = { suffix }
+ else
+ suffixes = { suffix }
+ end
+ local runner = getrunner(runnername)
+ if not runner then
+ report_typeset("unknown runner %a",runnername)
+ return
+ end
+ if not olddata then
+ olddata = getdata("buffers","runners") or { }
+ local suffixes = olddata.suffixes
+ local hashes = olddata.hashes
+ if hashes and suffixes then
+ for k, hash in next, hashes do
+ for h, v in next, hash do
+ for s, v in next, suffixes do
+ local tmp = addsuffix(h,s)
+ -- report_typeset("mark for deletion: %s",tmp)
+ registertempfile(tmp)
+ end
+ end
+ end
+ end
+ end
+ if not newdata then
+ newdata = {
+ version = environment.version,
+ suffixes = { },
+ hashes = { },
+ }
+ setdata {
+ name = "buffers",
+ tag = "runners",
+ data = newdata,
+ }
+ end
+ local oldhashes = olddata.hashes or { }
+ local newhashes = newdata.hashes or { }
+ local old = oldhashes[suffix]
+ local new = newhashes[suffix]
+ if not old then
+ old = { }
+ oldhashes[suffix] = old
+ for hash, n in next, old do
+ local tag = formatters["%s-t-b-%s"](tex.jobname,hash)
+ local tmp = addsuffix(tag,"tmp")
+ -- report_typeset("mark for deletion: %s",tmp)
+ registertempfile(tmp) -- to be sure
+ end
+ end
+ if not new then
+ new = { }
+ newhashes[suffix] = new
+ end
+ local names = getnames(name)
+ local content = collectcontent(names,nil) or ""
+ if content == "" then
+ content = "empty buffer"
+ end
+ if encapsulate then
+ content = formatters["\\starttext\n%s\n\\stoptext\n"](content)
+ end
+ --
+ local hash = md5hex(content)
+ local tag = formatters["%s-t-b-%s"](nameonly(tex.jobname),hash) -- make sure we run on the local path
+ --
+ local filename = addsuffix(tag,"tmp")
+ local resultname = addsuffix(tag,suffix)
+ --
+ if new[tag] then
+ -- done
+ elseif not old[tag] or olddata.version ~= newdata.version or not isfile(resultname) then
+ if trace_run then
+ report_typeset("changes in %a, processing forced",name)
+ end
+ savedata(filename,content)
+ report_typeset("processing saved buffer %a\n",filename)
+ runner { filename = filename }
+ end
+ new[tag] = (new[tag] or 0) + 1
+ report_typeset("no changes in %a, processing skipped",name)
+ registertempfile(filename)
+ -- report_typeset("mark for persistence: %s",filename)
+ for i=1,#suffixes do
+ local suffix = suffixes[i]
+ newdata.suffixes[suffix] = true
+ local tmp = addsuffix(tag,suffix)
+ -- report_typeset("mark for persistance: %s",tmp)
+ registertempfile(tmp,nil,true)
+ end
+ --
+ return resultname -- first result
+end
+
+local f_getbuffer = formatters["buffer.%s"]
+
+local function getbuffer(name)
+ local str = getcontent(name)
+ if str ~= "" then
+ -- characters.showstring(str)
+ ctx_viafile(str,f_getbuffer(validstring(name,"noname")))
+ end
+end
+
+local function getbuffermkvi(name) -- rather direct !
+ ctx_viafile(resolvers.macros.preprocessed(getcontent(name)),formatters["buffer.%s.mkiv"](validstring(name,"noname")))
+end
+
+local function gettexbuffer(name)
+ local buffer = name and cache[name]
+ if buffer and buffer.data ~= "" then
+ ctx_pushcatcodetable()
+ if buffer.catcodes == txtcatcodes then
+ ctx_setcatcodetable(txtcatcodes)
+ else
+ ctx_setcatcodetable(ctxcatcodes)
+ end
+ -- context(function() ctx_viafile(buffer.data) end)
+ ctx_getbuffer { name } -- viafile flushes too soon
+ ctx_popcatcodetable()
+ end
+end
+
+buffers.get = getbuffer
+buffers.getmkiv = getbuffermkiv
+buffers.gettexbuffer = gettexbuffer
+buffers.run = runbuffer
+
+implement { name = "getbufferctxlua", actions = loadcontent, arguments = "string" }
+implement { name = "getbuffer", actions = getbuffer, arguments = "string" }
+implement { name = "getbuffermkvi", actions = getbuffermkvi, arguments = "string" }
+implement { name = "gettexbuffer", actions = gettexbuffer, arguments = "string" }
+
+interfaces.implement {
+ name = "getbuffercontent",
+ arguments = "string",
+ actions = { getcontent, context },
+}
+
+implement {
+ name = "typesetbuffer",
+ actions = { runbuffer, context },
+ arguments = { "string", true }
+}
+
+implement {
+ name = "runbuffer",
+ actions = { runbuffer, context },
+ arguments = { "string", false, "string" }
+}
+
+implement {
+ name = "doifelsebuffer",
+ actions = { exists, commands.doifelse },
+ arguments = "string"
+}
+
+-- This only used for mp buffers and is a kludge. Don't change the
+-- texprint into texsprint as it fails because "penddef" becomes
+-- "penddef" then.
+
+implement {
+ name = "feedback", -- bad name, maybe rename to injectbuffercontent
+ actions = { collectcontent, ctx_printlines },
+ arguments = "string"
+}
+
+do
+
+ local context = context
+ local ctxcore = context.core
+
+ local ctx_startbuffer = ctxcore.startbuffer
+ local ctx_stopbuffer = ctxcore.stopbuffer
+
+ local ctx_startcollecting = context.startcollecting
+ local ctx_stopcollecting = context.stopcollecting
+
+ function ctxcore.startbuffer(...)
+ ctx_startcollecting()
+ ctx_startbuffer(...)
+ end
+
+ function ctxcore.stopbuffer()
+ ctx_stopbuffer()
+ ctx_stopcollecting()
+ end
+
+end
+
+-- moved here:
+
+function buffers.samplefile(name)
+ if not buffers.exists(name) then
+ buffers.assign(name,io.loaddata(resolvers.findfile(name)))
+ end
+ buffers.get(name)
+end
+
+implement {
+ name = "samplefile", -- bad name, maybe rename to injectbuffercontent
+ actions = buffers.samplefile,
+ arguments = "string"
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/buff-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/buff-ini.mkxl
new file mode 100644
index 00000000000..ed62743ad89
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/buff-ini.mkxl
@@ -0,0 +1,233 @@
+%D \module
+%D [ file=buff-ini,
+%D version=2011.11.22, % previous big effort 2000.01.05,
+%D title=\CONTEXT\ Buffer Macros,
+%D subtitle=Buffers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Buffer Macros / Buffers}
+
+\registerctxluafile{buff-ini}{autosuffix}
+
+\unprotect
+
+%D There have been several iterations in \MKIV\ but here we only show the currently
+%D used one. One can always look back (and maybe learn some). It will never look
+%D pretty and never be efficient but it has served us for ages (conceptually it's
+%D as in \MKII).
+
+\mutable\let\currentbuffer\empty
+
+\permanent\def\doifelsebuffer#1{\clf_doifelsebuffer{#1}} % expandable, todo: use public implementor
+
+\aliased\let\doifbufferelse\doifelsebuffer
+
+\permanent\tolerant\protected\def\resetbuffer[#1]{\clf_erasebuffer{#1}} % todo: use public implementor
+
+\permanent\setuvalue{\e!start\v!buffer}%
+ {\begingroup % (3)
+ \obeylines
+ \buff_start}
+
+\tolerant\def\buff_start[#1]#*[#2]%
+ {\buff_start_indeed{}{#1}{\e!start\v!buffer}{\e!stop\v!buffer}}
+
+\def\buff_start_indeed#1#2#3#4%
+ {\edef\p_strip{\namedbufferparameter{#1}\c!strip}% for aditya
+ \normalexpanded{\buff_pickup
+ {#2}%
+ {#3}%
+ {#4}%
+ {}%
+ {\buff_stop{#4}}%
+ \ifx\p_strip\v!no\zerocount\else\plusone\fi}}
+
+\permanent\protected\def\grabbufferdatadirect % name start stop
+ {\begingroup % (6)
+ \buff_start_indeed\empty}
+
+\permanent\protected\def\grabbufferdata % was: \dostartbuffer
+ {\begingroup % (4)
+ \obeylines
+ \buff_grab_direct}
+
+\tolerant\def\buff_grab_direct[#1]#*[#2]#*[#3]#*[#4]% [category] [name] [start] [stop]
+ {\ifnum\lastarguments=\plusfour
+ \expandafter\buff_start_indeed
+ \else
+ \expandafter\buff_start_indeed_default
+ \fi{#1}{#2}{#3}{#4}}
+
+\def\buff_start_indeed_default#1#2#3#4{\buff_start_indeed\empty{#1}{#2}{#3}}
+
+\let\buff_finish\relax
+%let\buff_gobble\relax
+
+\protected\def\buff_pickup#1#2#3#4#5#6% name, startsequence, stopsequence, before, after, undent
+ {\begingroup % (1)
+ #4%
+ \begingroup % (2)
+ \scratchcounter\catcodetable
+ \clf_erasebuffer{#1}%
+ \setcatcodetable\vrbcatcodes
+ \protected\def\buff_finish
+ {\endgroup % (1)
+ \endgroup % (2)
+ #5}%
+ % todo: we need to skip the first lineending which is an active character
+ % but sometimes we have something different ... this is a side effect of
+ % checking for optional arguments i.e. the next token is already tokenized
+ % and for that reason we have the \relax as well as the \string
+ \clf_pickupbuffer
+ {#1}%
+ {#2}%
+ {#3}%
+% {\string\dofinishpickupbuffer}%
+ \buff_finish
+ \scratchcounter
+ \ifnum#6=\plusone\s!true\else\s!false\fi
+ % \relax}
+ \expandafter\relax\string} % maybe \normalexpanded{\relax\utfchar{7}}} signal
+
+\protected\def\buff_stop#1%
+ {\endgroup % (3 & 4 & 5 & 6)
+ \begincsname#1\endcsname}
+
+\aliased\let\endbuffer\relax
+
+\permanent\tolerant\protected\def\setbuffer[#1]#:#2\endbuffer % seldom used so we just pass #2
+ {\clf_assignbuffer{#1}{\detokenize{#2}}\catcodetable\relax}
+
+% beware, never adapt the global buffer settings, actually we might introduce
+% a broken parent chain for this purpose but on the other hand it's not that
+% different from framed cum suis
+
+\installcorenamespace{buffer}
+
+\installcommandhandler \??buffer {buffer} \??buffer
+
+\setupbuffer
+ [\c!before=,
+ \c!after=]
+
+\newcount\c_buff_n_of_defined
+
+\mutable\let\currentdefinedbuffer\s!dummy
+
+\appendtoks
+ \global\advance\c_buff_n_of_defined\plusone
+ \setexpandedbufferparameter\c!number{\number\c_buff_n_of_defined}%
+ \edef\currentdefinedbuffer{def-\number\c_buff_n_of_defined}%
+ \frozen\instance\setuevalue{\e!start\currentbuffer}{\buff_start_defined{\currentbuffer}{\currentdefinedbuffer}{\e!start\currentbuffer}{\e!stop\currentbuffer}}%
+ \frozen\instance\setuevalue{\e!get \currentbuffer}{\buff_get_stored {\currentbuffer}{\currentdefinedbuffer}}%
+\to \everydefinebuffer
+
+\protected\def\buff_start_defined
+ {\begingroup % (5)
+ \buff_start_indeed}
+
+\permanent\def\thebuffernumber #1{\namedbufferparameter{#1}\c!number}
+\permanent\def\thedefinedbuffer#1{def-\namedbufferparameter{#1}\c!number}
+
+\permanent\tolerant\protected\def\getbuffer[#1]% [name]
+ {\namedbufferparameter\empty\c!before\relax
+ \doifelsenothing{#1}
+ {\buff_get_stored_indeed\empty}
+ {\processcommalist[#1]\buff_get_stored_indeed}%
+ \namedbufferparameter\empty\c!after\relax}
+
+\protected\def\buff_get_stored#1#2%
+ {\namedbufferparameter{#1}\c!before\relax
+ \buff_get_stored_indeed{#2}%
+ \namedbufferparameter{#1}\c!after\relax}
+
+\protected\def\buff_get_stored_indeed#1%
+ {\clf_getbuffer{#1}}
+
+\permanent\protected\def\getdefinedbuffer[#1]%
+ {\buff_get_stored{#1}{\thedefinedbuffer{#1}}}%
+
+\permanent\tolerant\protected\def\inlinebuffer[#1]% [name]
+ {\doifelsenothing{#1}
+ {\buff_get_stored_inline_indeed\empty}
+ {\processcommalist[#1]\buff_get_stored_inline_indeed}}
+
+\protected\def\buff_get_stored_inline_indeed#1%
+ {\ignorespaces\clf_getbuffer{#1}\removeunwantedspaces}
+
+\permanent\def\rawbuffer#1% expandable
+ {\clf_getbuffer{#1}}
+
+\definebuffer
+ [\v!hiding]
+
+\setupbuffer
+ [\v!hiding]
+ [\c!before=,
+ \c!after=]
+
+\permanent\protected\protected\def\processTEXbuffer[#1]% keep case, maybe also lower
+ {\pushcatcodetable
+ \catcodetable\ctxcatcodes % \setcatcodetable
+ \buff_get_stored_indeed{#1}%
+ \popcatcodetable}
+
+% only mkiv:
+%
+% \startbuffer[x]
+% x
+% \stopbuffer
+%
+% \savebuffer[x] [temp] % gets name: jobname-temp.tmp
+% \savebufferinfile[x][temp.log] % gets name: temp.log
+
+\installcorenamespace{savebuffer}
+
+\installsetuponlycommandhandler \??savebuffer {savebuffer}
+
+\setupsavebuffer
+ [\c!list=,
+ \c!file=,
+ \c!prefix=\v!yes]
+
+\permanent\tolerant\protected\def\savebuffer[#1]#*[#2]%
+ {\begingroup
+ \ifhastok={#1}%
+ \setupcurrentsavebuffer[#1]%
+ \else
+ \setupcurrentsavebuffer[\c!list={#1},\c!file=#2]%
+ \fi
+ \clf_savebuffer{\directsavebufferparameter\c!list}{\directsavebufferparameter\c!file}{\directsavebufferparameter\c!prefix}%
+ \endgroup}
+
+%D Experimental: no expansion of commands in buffer!
+
+% \startbuffer[what]
+% context("WHAT")
+% \stopbuffer
+% \startbuffer
+% context("JOBNAME")
+% \stopbuffer
+%
+% \ctxluabuffer[what] \ctxluabuffer
+
+\permanent\tolerant\protected\def\ctxluabuffer[#1]{\clf_getbufferctxlua{#1}} % todo: use public implementor
+\permanent\tolerant\protected\def\mkvibuffer [#1]{\clf_getbuffermkvi {#1}} % todo: use public implementor
+
+% maybe still used elsewhere
+
+% \aliased\doprocesstexbuffer\mkvibuffer
+
+\aliased\let\dostartbuffer\grabbufferdata % for old times sake, this will go away
+
+% new (expandable):
+
+\permanent\def\getbufferdata[#1]{\buff_get_stored_indeed{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/buff-par.mklx b/Master/texmf-dist/tex/context/base/mkxl/buff-par.mklx
new file mode 100644
index 00000000000..b6ffa3f534e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/buff-par.mklx
@@ -0,0 +1,186 @@
+%D \module
+%D [ file=buff-par,
+%D version=2010.12.05,
+%D title=\CONTEXT\ Buffer Macros,
+%D subtitle=Parallel,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Buffer Macros / Parallel}
+
+\registerctxluafile{buff-par}{}
+
+%D This module is made for Thomas Schmitz as part of a project. There is
+%D no documentation yet. Also, this code is unfinished and not tested well.
+%D
+%D \starttyping
+%D \defineparallel[main][one,two]
+%D
+%D \startmain
+%D \startone
+%D first 0
+%D [reference] first 1
+%D first 2
+%D first 3
+%D \stopone
+%D \starttwo
+%D second 1
+%D second 2
+%D \stoptwo
+%D \stopmain
+%D
+%D \startmain
+%D \startone
+%D first 4
+%D first 4
+%D \stopone
+%D \starttwo
+%D second 3
+%D second 4
+%D \stoptwo
+%D \stopmain
+%D
+%D \placeparallel[main][one][criterium=all]
+%D
+%D \placeparallel[main][two][criterium=all]
+%D \stoptyping
+
+%D criterium=all start= n=
+
+\unprotect
+
+\installcorenamespace{parallel}
+\installcorenamespace{parallelhandler}
+
+\installcommandhandler \??parallel {parallel} \??parallel
+
+\setupparallel
+ [\c!setups=parallel:place:default]
+
+\pushoverloadmode
+
+\let\buff_parallel_define_saved \defineparallel
+\let\buff_process_parallel_instance\relax
+
+\permanent\tolerant\protected\overloaded\def\defineparallel[#name]#spacer[#instances]%
+ {\buff_parallel_define_saved[#name][\c!list={#instances}]% list is internal
+ \clf_defineparallel{#name}{#instances}%
+ \expandafter\newtoks\csname\??parallelhandler#name\endcsname
+ \processcommacommand[#instances]{\buff_parallel_define_instance{#name}}%
+ \frozen\instance\setuevalue{\e!start#name}{\buff_parallel_start{#name}}%
+ \frozen\instance\setuevalue{\e!stop #name}{\buff_parallel_stop}}
+
+\popoverloadmode
+
+\def\buff_process_parallel_instances
+ {\the\csname\??parallelhandler\currentparallel\endcsname}
+
+\def\buff_parallel_define_instance#name#instance%
+ {\normalexpanded{\buff_parallel_define_saved[#instance][#name]}%
+ \definebuffer[#instance]%
+ \toksapp
+ \csname\??parallelhandler#name\endcsname
+ {\edef\currentparallelinstance{#instance}\buff_process_parallel_instance\relax}%
+ \setuevalue{\e!stop#instance}{\buff_parallel_save{#instance}}}
+
+\pushoverloadmode
+
+\let\buff_parallel_setup_saved \setupparallel
+
+\permanent\tolerant\protected\def\setupparallel[#name]#spacer[#instances]#spacer[#setups]%
+ {\processcommalist[#instances]{\buff_parallel_setup_instance{#name}{#setups}}}
+
+\popoverloadmode
+
+\def\buff_parallel_setup_instance#name#setups#instance%
+ {\buff_parallel_setup_saved[#name:#instance][#setups]}
+
+\protected\def\buff_parallel_start#name%
+ {\pushmacro\currentparallel
+ \edef\currentparallel{#name}%
+ \clf_nextparallel{\currentparallel}}
+
+\protected\def\buff_parallel_stop
+ {\popmacro\currentparallel}
+
+\protected\def\buff_parallel_save#instance% defined moet ook aan de lua kant kunnen
+ {\clf_saveparallel
+ {\currentparallel}%
+ {#instance}%
+ {\thedefinedbuffer{#instance}}%
+ \relax}
+
+\permanent\tolerant\protected\def\placeparallel[#name]#spacer[#instance]#spacer[#settings]%
+ {\begingroup
+ \edef\currentparallel{#name}%
+ \setupcurrentparallel[#settings]%
+ \clf_placeparallel
+ {\currentparallel}%
+ {#instance}%
+ {%
+ % setups {\parallelparameter\c!setups}%
+ start {\parallelparameter\c!start}%
+ n {\parallelparameter\c!n}%
+ criterium {\parallelparameter\c!criterium}%
+ }%
+ \relax
+ \endgroup}
+
+\mutable\let\currentparallelinstance\empty
+\mutable\let\currentparallelnumber \empty
+\mutable\let\currentparallelline \empty
+\mutable\let\currentparallellabel \empty
+\mutable\let\currentparallelcontent \empty
+
+\permanent\protected\def\doflushparallel#instance#status#line#label#content% called at lua end
+ {\begingroup
+ \def\currentparallelinstance{#instance}%
+ \def\currentparallelnumber {#status}%
+ \def\currentparallelline {#line}%
+ \def\currentparallellabel {#label}%
+ \def\currentparallelcontent {#content}% can be kep at the lua end .. no need to use a virtual file
+ \ifcase#status\relax
+ \expandafter\buff_parallel_flush_nop
+ \or
+ \expandafter\buff_parallel_flush_yes
+ \fi
+ \endgroup}
+
+\def\buff_parallel_flush_nop
+ {}
+
+\def\buff_parallel_flush_yes
+ %{\directsetup{\namedparallelparameter{\currentparallel:\currentparallelinstance}\c!setups}}
+ {\directsetup{\namedparallelparameter{\currentparallelinstance}\c!setups}}
+
+\permanent\protected\def\doifelseparallel#name#instance%
+ {\clf_doifelseparallel{#name}{#instance}}
+
+\aliased\let\doifparallelelse\doifelseparallel
+
+\permanent\tolerant\protected\def\resetparallel[#name]#spacer[#instance]%
+ {\clf_resetparallel{#name}{#instance}}
+
+\startsetups parallel:place:default
+ \hangafter\plusone
+ \hangindent4\emwidth
+ \dontleavehmode
+ \hbox to 3\emwidth \bgroup
+ \hss
+ \bf
+ \doifsomething \currentparallellabel {
+ \textreference[\currentparallellabel]{\currentparallelline}
+ }
+ \currentparallelline
+ \quad
+ \egroup
+ \currentparallelcontent
+ \par
+\stopsetups
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/buff-ver.mkxl b/Master/texmf-dist/tex/context/base/mkxl/buff-ver.mkxl
new file mode 100644
index 00000000000..68a07df60be
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/buff-ver.mkxl
@@ -0,0 +1,1000 @@
+%D \module
+%D [ file=buff-ver, % was core-ver
+%D version=2000.05.09,
+%D title=\CONTEXT\ Buffer Macros,
+%D subtitle=Verbatim,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% check after-first and before-last breaks
+
+\writestatus{loading}{ConTeXt Buffer Macros / Verbatim}
+
+\registerctxluafile{buff-ver}{}
+
+\unprotect
+
+\startcontextdefinitioncode
+
+\definesystemattribute[verbatimline][public]
+
+\appendtoksonce
+ \c_attr_verbatimline\attributeunsetvalue
+\to \everyforgetall
+
+%D Initializations.
+
+\installcorenamespace{typinglines}
+\installcorenamespace{typingspace}
+\installcorenamespace{typingblank} % needs checking ... used?
+
+\newtoks\everyinitializeverbatim
+
+\appendtoks
+ \the\everyresettypesetting
+ \resetfontfeature
+ \resetcharacterspacing
+ \resetbreakpoints
+\to \everyinitializeverbatim
+
+\permanent\protected\def\setverbatimspaceskip % to be checked: must happen after font switch
+ {\spaceskip\fontcharwd\font`x\relax
+ \xspaceskip\spaceskip}
+
+\defcsname\??typinglines\v!no \endcsname{\buff_verbatim_ignore_hyphens}
+\defcsname\??typinglines\v!normal \endcsname{\buff_verbatim_ignore_hyphens}
+\defcsname\??typinglines\v!yes \endcsname{\buff_verbatim_obey_breakpoints}
+\defcsname\??typinglines\v!hyphenated\endcsname{\buff_verbatim_obey_hyphens}
+
+\defcsname\??typingspace\v!on \endcsname{\enforced\let\obeyedspace\specialcontrolspace}
+\defcsname\??typingspace\v!stretch \endcsname{\enforced\let\obeyedspace\specialstretchedspace}
+\defcsname\??typingspace\v!normal \endcsname{}
+\defcsname\??typingspace\v!fixed \endcsname{\enforced\let\obeyedspace\specialfixedspace}
+
+\defcsname\??typingblank\v!standard \endcsname{\s_spac_whitespace_parskip}
+\defcsname\??typingblank\v!small \endcsname{\smallskipamount}
+\defcsname\??typingblank\v!medium \endcsname{\medskipamount}
+\defcsname\??typingblank\v!big \endcsname{\bigskipamount}
+\defcsname\??typingblank\v!halfline \endcsname{.5\baselineskip}
+\defcsname\??typingblank\v!line \endcsname{\baselineskip}
+\defcsname\??typingblank\v!none \endcsname{\zeropoint}
+
+\protected\def\buff_verbatim_obey_hyphens
+ {}
+
+\protected\def\buff_verbatim_obey_breakpoints
+ {\nohyphens
+ \veryraggedright}
+
+\protected\def\buff_verbatim_ignore_hyphens
+ {\nohyphens}
+
+\def\buff_verbatim_initialize_type_one
+ {\enforced\let\obeylines\ignorelines
+ \edef\p_buff_option{\typeparameter\c!option}%
+ \ifx\p_buff_option\v!none
+ \usetypestyleandcolor\c!style\c!color
+ \orelse\ifempty\p_buff_option
+ \usetypestyleandcolor\c!style\c!color
+ \else
+ \usetypestyleparameter\c!style % no color
+ \fi
+ \setcatcodetable\vrbcatcodes}
+
+\def\buff_verbatim_initialize_type_two
+ {\spaceskip.5\emwidth\relax
+ \enforced\let\obeyedspace\specialobeyedspace
+ \enforced\let\controlspace\specialcontrolspace
+ \edef\p_buff_lines{\typeparameter\c!lines}%
+ \begincsname\??typinglines\p_buff_lines\endcsname
+ \edef\p_buff_space{\typeparameter\c!space}%
+ \begincsname\??typingspace\p_buff_space\endcsname
+ \relax\the\everyinitializeverbatim\relax}
+
+\permanent\protected\def\doinitializeverbatim % for use elsewhere .. temp hack (see lxml-ini)
+ {\buff_verbatim_initialize_type_one
+ \buff_verbatim_initialize_type_two}
+
+\let\buff_verbatim_set_line_margin\relax
+
+\def\buff_verbatim_set_line_margin_indeed
+ {\hskip\doifelseoddpage{\typingparameter\c!oddmargin}{\typingparameter\c!evenmargin}\relax}
+
+\def\buff_verbatim_initialize_typing_one
+ {\usebodyfontparameter\typingparameter
+ \scratchskip\typingparameter\c!oddmargin\relax
+ \ifzeropt\scratchskip \else
+ \let\buff_verbatim_set_line_margin\buff_verbatim_set_line_margin_indeed
+ \fi
+ \scratchskip\typingparameter\c!evenmargin\relax
+ \ifzeropt\scratchskip \else
+ \let\buff_verbatim_set_line_margin\buff_verbatim_set_line_margin_indeed
+ \fi
+ \ifrelax\buff_verbatim_set_line_margin
+ \doadaptleftskip{\typingparameter\c!margin}%
+ \fi
+ \edef\p_buff_option{\typingparameter\c!option}%
+ \ifx\p_buff_option\v!none
+ \usetypingstyleandcolor\c!style\c!color
+ \orelse\ifempty\p_buff_option
+ \usetypingstyleandcolor\c!style\c!color
+ \else
+ \usetypingstyleparameter\c!style % no color !
+ \fi
+ \usealignparameter\typingparameter}
+
+\def\buff_verbatim_initialize_typing_two
+ {\spaceskip.5\emwidth\relax
+ \enforced\let\obeyedspace\specialobeyedspace
+ \enforced\let\controlspace\specialcontrolspace
+ \edef\p_buff_lines{\typingparameter\c!lines}%
+ \begincsname\??typinglines\p_buff_lines\endcsname
+ \edef\p_buff_space{\typingparameter\c!space}%
+ \begincsname\??typingspace\p_buff_space\endcsname
+ \relax\the\everyinitializeverbatim\relax}
+
+%D \macros
+%D {definetype,setuptype}
+%D
+%D Specific inline verbatim commands can be defined with the following command.
+
+\installcorenamespace{type}
+
+\installcommandhandler \??type {type} \??type
+
+\appendtoks
+ \frozen\instance\setuevalue{\currenttype}{\buff_verbatim_type{\currenttype}}%
+\to \everydefinetype
+
+\appendtoks
+ \buff_verbatim_initialize_visualizer{\typeparameter\c!option}%
+\to \everysetuptype
+
+%D \macros
+%D {definetyping,setuptyping}
+%D
+%D For most users the standard \type {\start}||\type {\stop}||pair will suffice, but
+%D for documentation purposes the next definition command can be of use:
+%D
+%D \starttyping
+%D \definetyping[extratyping][margin=3em]
+%D
+%D \startextratyping
+%D these extra ones are indented by 1 em
+%D \stopextratyping
+%D \stoptyping
+%D
+%D The definitions default to the standard typing values.
+
+\installcorenamespace{typing}
+
+\installcommandhandler \??typing {typing} \??typing
+
+\appendtoks
+ \frozen\instance\setuevalue{\e!start\currenttyping}{\buff_verbatim_typing_start{\currenttyping}}%
+ \frozen\instance\setuevalue{\e!stop \currenttyping}{\buff_verbatim_typing_stop {\currenttyping}}%
+ \ifempty\currenttypingparent
+ \normalexpanded{\definelinenumbering[\currenttyping]}%
+ \else
+ \normalexpanded{\definelinenumbering[\currenttyping][\currenttypingparent]}%
+ \fi
+\to \everydefinetyping
+
+\appendtoks
+ \buff_verbatim_initialize_visualizer{\typingparameter\c!option}% we can check at the tex end
+\to \everysetuptyping
+
+\def\buff_verbatim_initialize_visualizer#1%
+ {\ifproductionrun\clf_loadvisualizer{#1}\fi}
+
+\permanent\protected\def\doifelsevisualizer#1%
+ {\clf_doifelsevisualizer{#1}}
+
+\aliased\let\doifvisualizerelse\doifelsevisualizer
+
+%D Verbatim command are very sensitive to argument processing, which is a direct
+%D result of the \CATCODES\ being fixed at reading time.
+%D
+%D Typesetting inline verbatim can be accomplished by \type {\type}, which in this
+%D sentence was typeset by saying just \type {\type {\type}}, which in turn was
+%D typeset by \unknown. Using the normal grouping characters \type {{}} is the most
+%D natural way of using this command.
+%D
+%D A second, more or less redundant, alternative is delimiting the argument with an
+%D own character. This method was implemented in the context of a publication in the
+%D \MAPS, where this way of delimiting is recognized by \LATEX\ users.
+%D
+%D The third, more original alternative, is the one using \type {<<} and \type {>>}
+%D as delimiters. This alternative can be used in situations where slanted
+%D typeseting is needed.
+%D
+%D \macros
+%D {type}
+%D
+%D We define \type {\type} as a protected command. This command has several
+%D invocations: grouped, wirt boundary characters, and with font switches.
+%D
+%D \starttyping
+%D normal: \par \type{xx<<..xx..<> >>..>>xx} \par \type<<....>> \par \type<<..<>..>> \par
+%D normal: \par \type{xx<..xx.. >..>xx} \par \type{<....>} \par \type{<....>}
+%D \setuptype[option=slanted]
+%D slanted: \par \type{xx<<..sl..<> xx>>..sl..>>xx} \par \type<<..xx..>> \par \type<<..<>..>> \par
+%D slanted: \par \type{xx<<..sl.. xx>..sl..>>xx} \par \type<<..xx..>> \par \type<<....>> \par
+%D \setuptype[option=none]
+%D none: \par \type{xx<<..xx..<> >>..>>xx} \par \type<<....>> \par \type<<..<>..>> \par
+%D \stoptyping
+%D
+%D When writing the manual to \CONTEXT\ and documenting this source we needed to
+%D typeset \type {<<} and \type {>>}. Because we wanted to do this in the natural
+%D way, we've adapted the original definition a bit. This implementation went
+%D through several live cycles. The final implementation looks a bit further and
+%D treats the lone \type {<<} and \type {>>} a bit different. The \type {\null}
+%D prevents ligatures, which unfortunately turn up in Lucida fonts.
+%D
+%D The following lines show what happens when we set \type {option=commands}.
+%D
+%D \startbuffer
+%D \starttyping
+%D test//test test/BTEX \footnote{test test test}/ETEX test
+%D test//test test/BTEX \footnote{test test test}/ETEX test
+%D test test test/BTEX \bf(nota bene)/ETEX test
+%D test test test /BTEX \bf(nota bene)/ETEX test
+%D \stoptyping
+%D \stopbuffer
+%D
+%D % \bgroup\setuptyping[option=commands]\getbuffer\egroup
+%D
+%D this was keyed in as:
+%D
+%D \typebuffer
+
+% Beware, the command is supposed to do something like \framed and not manipulate
+% content i.e. it gets no argument but something b/egrouped instead:
+
+\def\buff_verbatim_left_of_type
+ {\typeparameter\c!left
+ \typeparameter\c!command\bgroup}
+
+\def\buff_verbatim_right_of_type
+ {\egroup
+ \typeparameter\c!right}
+
+\permanent\protected\def\type{\buff_verbatim_type\empty}
+\permanent\protected\def\typ {\buff_verbatim_typ \empty}
+
+\protected\def\buff_verbatim_type#1%
+ {\dontleavehmode
+ \bgroup
+ \edef\currenttype{#1}%
+ \buff_verbatim_type_indeed}
+
+\def\buff_verbatim_typ#1%
+ {\dontleavehmode
+ \bgroup
+ \edef\currenttype{#1}%
+ \lettypeparameter\c!lines\v!hyphenated
+ \enforced\let\specialobeyedspace\specialstretchedspace
+ \buff_verbatim_type_indeed}
+
+\tolerant\def\buff_verbatim_type_indeed[#1]%
+ {\ifarguments\or\setupcurrenttype[#1]\fi
+ \buff_verbatim_left_of_type
+ \futureexpand\bgroup\buff_verbatim_type_a\buff_verbatim_type_one}
+
+\def\buff_verbatim_type_one
+ {\catcode`<=\othercatcode % old precaution
+ \catcode`>=\othercatcode % old precaution
+ \futureexpandis<\buff_verbatim_type_b\buff_verbatim_type_c}
+
+\def\buff_verbatim_type_three
+ {\if\next<%
+ \expandafter\buff_verbatim_type_b
+ \else
+ \expandafter\buff_verbatim_type_c
+ \fi}
+
+\def\buff_verbatim_type_a
+ {\buff_verbatim_initialize_type_one
+ \setcatcodetable\tpacatcodes
+ \buff_verbatim_type_normal}
+
+\def\buff_verbatim_type_b#1%
+ {\buff_verbatim_initialize_type_one
+ \setcatcodetable\tpbcatcodes
+ \buff_verbatim_type_nested}
+
+\def\buff_verbatim_type_c#1%
+ {\buff_verbatim_initialize_type_one
+ \setcatcodetable\vrbcatcodes
+ \def\next##1#1{\buff_verbatim_type_normal{##1}}%
+ \next}
+
+\def\buff_verbatim_type_normal#1%
+ {\buff_verbatim_initialize_type_two
+ \dostarttaggedchained\t!verbatim\currenttype\??type
+ \clf_type
+ data {\detokenize{#1}}%
+ tab {\typeparameter\c!tab}%
+ method {\p_buff_option}%
+ compact {\typeparameter\c!compact}% % none | all | last (all needed in tabulate etc for manuals)
+ escape {\typeparameter\c!escape}% % new but rather useless imo (escaping in general is not used much)
+ % nature {inline}% is default
+ \relax
+ \dostoptagged
+ \buff_verbatim_right_of_type
+ \egroup}
+
+\def\buff_verbatim_type_nested#1%
+ {\buff_verbatim_initialize_type_two
+ \dostarttaggedchained\t!verbatim\currenttype\??type
+ \clf_type
+ data {\detokenize{#1}}%
+ tab {\typeparameter\c!tab}%
+ method {\p_buff_option}% % extra visualizer (maybe: nested,\typeparameter\c!option)
+ escape {\typeparameter\c!escape}% % new but rather useless imo (escaping in general is not used much)
+ % nature {inline}% is default
+ method {nested}%
+ \relax
+ \dostoptagged
+ \buff_verbatim_right_of_type
+ \egroup
+ \gobbleoneargument} % grab last >
+
+%D The \type {compact} option can come in handy in the case of inline argument passing
+%D
+%D \starttyping
+%D \definetype[TeXcodeA][option=TEX]
+%D \definetype[TeXcodeB][option=TEX,compact=all]
+%D \definetype[TeXcodeC][option=TEX,compact=absolute]
+%D
+%D \def\argA#1{\TeXcodeA{{#1}}}
+%D \def\argB#1{\TeXcodeB{{#1}}}
+%D \def\argC#1{\TeXcodeC{{#1}}}
+%D \stoptyping
+
+%D \macros
+%D {obeyhyphens,obeybreakpoints}
+%D
+%D Although it's not clear from the macros, one character trait of this macros,
+%D which are build on top of the support module, is that they don't hyphenate. We
+%D therefore offer the alternative \type{\typ}. The current implementation works all
+%D right, but a decent hyphenation support of \type{\tt} text will be implemented
+%D soon.
+
+\permanent\protected\def\specialfixedspace {\kern\interwordspace\relax}
+\permanent\protected\def\specialobeyedspace {\hskip\interwordspace\relax} % better than spaceskip
+\permanent\protected\def\specialstretchedspace {\hskip.5\interwordspace\s!plus.125\interwordspace\relax} % \interwordstretch can be zero
+\permanent\protected\def\specialcontrolspace {\normalcontrolspace\allowbreak} % uses fallback
+
+\permanent\protected\def\explicitfixedspace {\asciispacechar}
+\permanent\protected\def\explicitobeyedspace {\asciispacechar\allowbreak}
+\permanent\protected\def\explicitstretchedspace{\asciispacechar\hskip\zeropoint\s!plus.125\interwordspace\relax}%
+\permanent\protected\def\explicitcontrolspace {\optionalcontrolspace\allowbreak} % uses asciispace
+
+\appendtoks
+ \enforced\protected\def\obeyedspace{\hskip\zeropoint\relax\asciispacechar\hskip\zeropoint\relax}%
+\to \everyenableelements
+
+\permanent\protected\def\obeyhyphens
+ {\enforced\let\obeyedspace \specialobeyedspace % maybe \specialstretchedspace
+ \enforced\let\controlspace\specialcontrolspace
+ \spaceskip.25\emwidth\relax} % hm a bit of stretch !
+
+\permanent\protected\def\obeybreakpoints
+ {\ignorehyphens
+ \veryraggedright}
+
+\permanent\protected\def\ignorehyphens
+ {\nohyphens
+ \enforced\let\obeyedspace \specialobeyedspace
+ \enforced\let\controlspace\specialcontrolspace
+ \spaceskip.5\emwidth\relax}
+
+%D \macros
+%D {tex,arg,mat,dis,astype}
+%D
+%D Sometimes, for instance when we pass verbatim text as an argument, the fixed
+%D \CATCODES\ interfere with our wishes. An experimental implementation of character
+%D by character processing of verbatim text did overcome this limitation, but we've
+%D decided not to use that slow and sometimes troublesome solution. Instead we stick
+%D to some 'old' \CONTEXT\ macros for typesetting typical \TEX\ characters.
+
+\immutable\def\lesscharacter {<} % obsolete
+\immutable\def\morecharacter {>} % obsolete
+
+\immutable\let\texescape \textbackslash
+\immutable\let\leftargument \textbraceleft
+\immutable\let\rightargument \textbraceright
+\immutable\let\inlinemathmarker \textdollar
+\immutable\def\displaymathmarker{\textdollar\textdollar}
+
+\def\buff_verbatim_special_type#1#2#% # gobbles spaces
+ {\dontleavehmode\bgroup
+ \buff_verbatim_initialize_type_one
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode\endgroupcatcode
+ #1%
+ \bgroup % else wrong font for #2
+ \aftergroup#2%
+ \aftergroup\egroup
+ \let\nexttoken}
+
+\mutable\protected\def\tex{\buff_verbatim_special_type\texescape \relax}
+\mutable\protected\def\arg{\buff_verbatim_special_type\leftargument \rightargument}
+\mutable\protected\def\mat{\buff_verbatim_special_type\inlinemathmarker \inlinemathmarker}
+\mutable\protected\def\dis{\buff_verbatim_special_type\displaymathmarker\displaymathmarker}
+
+\aliased\let\normaltexttex\tex
+\aliased\let\normaltextarg\arg
+\aliased\let\normaltextmat\mat
+\aliased\let\normaltextdis\dis
+
+\permanent\protected\def\astype
+ {\dontleavehmode
+ \bgroup\usetypestyleandcolor\c!style\c!color\let\nexttoken}
+
+\permanent\protected\def\asciistr#1% used in some old styles
+ {\dontleavehmode\begingroup
+ \dostarttagged\t!verbatim\empty
+ \usetypestyleandcolor\c!style\c!color\detokenize{#1}%
+ \dostoptagged
+ \endgroup}
+
+%D The basic display verbatim commands are defined in an indirect way. As we
+%D will see, they are a specific case of a more general mechanism.
+
+\mutable\let\beginofverbatimlines\relax % hooks
+\mutable\let\endofverbatimlines \relax % hooks
+
+\protected\def\buff_verbatim_typing_start#1% tricky non standard lookahead
+ {\begingroup
+ \edef\currenttyping{#1}%
+ \obeylines
+ \futureexpandis[\buff_verbatim_typing_start_yes\buff_verbatim_typing_start_nop}
+
+\def\buff_verbatim_typing_start_nop
+ {\typingparameter\c!before\relax
+ \startpacked[\v!blank]%
+ \buff_verbatim_setup_line_numbering
+ \buff_verbatim_initialize_typing_one
+ \buff_verbatim_setup_keep_together
+ \normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}}
+
+\def\buff_verbatim_typing_start_yes[#1]%
+ {\typingparameter\c!before\relax
+ \startpacked[\v!blank]%
+ \ifcondition\validassignment{#1}%
+ \setupcurrenttyping[#1]%
+ \else
+ \doif\v!continue{#1}{\lettypingparameter\c!continue\v!yes}%
+ \fi
+ \buff_verbatim_setup_line_numbering
+ \buff_verbatim_initialize_typing_one
+ \buff_verbatim_setup_keep_together
+ \normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}}
+
+% \startnamedtyping[#1]
+
+\protected\def\buff_verbatim_setup_keep_together
+ {\edef\p_keeptogether{\typingparameter\c!keeptogether}%
+ \ifx\p_keeptogether\v!yes
+ \settrue \c_buff_optimize_linebreaks
+ \else
+ \setfalse\c_buff_optimize_linebreaks
+ \fi}
+
+\protected\def\buff_verbatim_type_block#1#2%
+ {\edef\p_strip{\typingparameter\c!strip}%
+ \normalexpanded{\buff_pickup
+ {_typing_}%
+ {#1}%
+ {#2}%
+ {}%
+ {\buff_verbatim_type_block_verbatim_indeed{#1}{#2}}%
+ \ifx\p_strip\v!no\zerocount\else\plusone\fi}}
+
+\protected\def\buff_verbatim_type_block_verbatim_indeed#1#2%
+ {\buff_verbatim_initialize_typing_two
+ \dostarttaggedchained\t!verbatimblock\currenttyping\??typing
+ \beginofverbatimlines
+ \dostarttagged\t!verbatimlines\empty
+ \clf_typebuffer
+ name {_typing_}%
+ strip {\typingparameter\c!strip}%
+ range {\typingparameter\c!range}%
+ tab {\typingparameter\c!tab}%
+ method {\p_buff_option}%
+ escape {\typingparameter\c!escape}%
+ nature {display}%
+ \relax
+ \dostoptagged
+ \endofverbatimlines
+ \dostoptagged
+ \begincsname#2\endcsname}
+
+\protected\def\buff_verbatim_typing_stop#1% hm, currenttyping
+ {\stoppacked
+ \typingparameter\c!after\relax
+ \useindentnextparameter\typingparameter
+ \endgroup
+ \dorechecknextindentation}
+
+%D Line numbering for files is combined with filtering, while display verbatim has
+%D the ability to continue.
+%D
+%D \starttyping
+%D \typefile[numbering=file,start=10,stop=12]{test.tex}
+%D
+%D \definetyping[code][numbering=line]
+%D
+%D \starttext
+%D \startcode
+%D ...
+%D ...
+%D \stopcode
+%D
+%D \startcode[start=continue]
+%D ...
+%D ...
+%D \stopcode
+%D
+%D \startcode[start=10]
+%D ...
+%D \stopcode
+%D \stoptyping
+
+%D Ranges:
+%D
+%D \starttyping
+%D % label:start:one
+%D
+%D \def\MyMacro
+%D {just an example}
+%D
+%D % label:stop:one
+%D
+%D \starttext
+%D
+%D % \typefile[file][range={3,6}] {whatever.tex}
+%D % \typefile[file][range={3,+2}]{whatever.tex}
+%D
+%D \typefile[file][range={label:start:one,label:stop:one}]{whatever.tex}
+%D
+%D \stoptext
+%D \stoptyping
+
+%D \macros
+%D {typefile}
+%D
+%D Typesetting files verbatim (for the moment) only supports colorization of \TEX\
+%D sources as valid option. The other setup values are inherited from display
+%D verbatim. The implementation of \type {\typefile} is straightforward:
+
+% [category] [settings] {name} % for historic reasons, all filenames are {}
+
+\mutable\let\currenttypingfile\empty
+
+\appendtoks
+ \frozen\instance\setuevalue{\e!type\currenttyping\v!file}{\typefile[\currenttyping]}%
+\to \everydefinetyping
+
+\permanent\tolerant\protected\def\typefile[#1]#*[#2]#:#3%
+ {\begingroup
+ \ifparameter#2\or
+ \setuptyping[#1][#2]%
+ \buff_verbatim_type_file_checked{#1}{#3}%
+ \orelse\ifparameter#1\or
+ \ifhastok={#1}%
+ \setuptyping[\v!file][#1]%
+ \buff_verbatim_type_file_checked\v!file{#3}%
+ \else
+ \buff_verbatim_type_file_checked{#1}{#3}%
+ \fi
+ \else
+ \buff_verbatim_type_file_checked\v!file{#3}%
+ \fi
+ \useindentnextparameter\typingparameter % needs checking
+ \endgroup
+ \dorechecknextindentation} % needs checking
+
+\def\buff_verbatim_type_file_checked#1#2%
+ {\doifelsetypingfile{#2}
+ {\buff_verbatim_type_file_indeed{#1}\currenttypingfile}
+ {\showmessage\m!verbatims1{#2}}}
+
+\permanent\protected\def\doifelsetypingfile#1%
+ {\edef\currenttypingfile{\locfilename{#1}}%
+ \ifempty\currenttypingfile
+ \edef\currenttypingfile{\locfilename{#1.tex}}% downward compatible
+ \fi
+ \ifempty\currenttypingfile
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\aliased\let\doiftypingfileelse\doifelsetypingfile
+
+\def\buff_verbatim_type_file_indeed#1#2% category name
+ {\edef\currenttyping{#1}%
+ \typingparameter\c!before\relax
+ \startpacked[\v!blank]
+ \buff_verbatim_setup_line_numbering
+ \buff_verbatim_initialize_typing_one
+ \buff_verbatim_initialize_typing_two
+ \dostarttaggedchained\t!verbatimblock\currenttyping\??typing
+ \beginofverbatimlines
+ \dostarttagged\t!verbatimlines\empty
+ \clf_typefile
+ name {#2}%
+ strip {\typingparameter\c!strip}%
+ range {\typingparameter\c!range}%
+ regime {\currentregime}%
+ tab {\typingparameter\c!tab}%
+ method {\p_buff_option}%
+ nature {display}%
+ \relax
+ \dostoptagged
+ \endofverbatimlines
+ \dostoptagged
+ \stoppacked
+ \typingparameter\c!after\relax}
+
+%D Line numbering:
+
+\newconditional\verbatimnumberinglines
+
+\permanent\protected\def\beginofverbatimlinenumbering
+ {\startlinenumbering
+ [\currenttyping]%
+ [\c!continue=\typingparameter\c!continue,
+ \c!method=\v!type,
+ \c!start=\typingparameter\c!start,
+ \c!stop=\typingparameter\c!stop, % ?
+ \c!step=\typingparameter\c!step]}
+
+\permanent\protected\def\endofverbatimlinenumbering
+ {\stoplinenumbering}
+
+\def\buff_verbatim_setup_line_numbering
+ {\ifdefined\startlinenumbering
+ \edef\p_numbering{\typingparameter\c!numbering}%
+ \ifx\p_numbering\v!file
+ \setuplinenumbering[\currenttyping][\c!method=\v!file]%
+ \settrue\verbatimnumberinglines
+ \orelse\ifx\p_numbering\v!line
+ \settrue\verbatimnumberinglines
+ \else
+ \setfalse\verbatimnumberinglines
+ \fi
+ \ifconditional\verbatimnumberinglines
+ \enforced\let\beginofverbatimlines\beginofverbatimlinenumbering
+ \enforced\let\endofverbatimlines \endofverbatimlinenumbering
+ \fi
+ \fi}
+
+%D \macros
+%D {filename}
+%D
+%D Typesetting filenames in monospaced fonts is possible with
+%D
+%D \starttyping
+%D \filename{here/there/filename.suffix}
+%D \stoptyping
+%D
+%D The definition is not that spectacular.
+
+\permanent\protected\def\filename#1{{\tttf\hyphenatedfilename{#1}}}
+
+%D \macros
+%D {verbatim}
+%d
+%D And a bonus macro, an unexpanded detokenize:
+
+\permanent\protected\def\verbatim#1{\detokenize{#1}}
+
+%D The setups for display verbatim and file verbatim are shared. One can adapt the
+%D extra defined typing environments, but they also default to the values below.
+%D Watch the alternative escape character.
+
+% \tttf gives problems with {\tx \type...}
+% \tt\tf does not adapt to e.g. \bf
+
+\setuptyping
+ [\c!before=\blank,
+ \c!after=\blank,
+ %\c!keeptogether=yes, % this will become default (when tested enough)
+ %\c!bodyfont=,
+ %\c!color=,
+ \c!space=\v!off,
+ \c!lines=\v!no,
+ \c!page=\v!no,
+ \c!tab=\v!yes, % what is this: \s!ascii ?
+ \c!option=\v!none,
+ \c!text=\v!no,
+ \c!style=\tt,
+ \c!indentnext=\v!yes,
+ \c!margin=\zeropoint,
+ \c!evenmargin=\zeropoint,
+ \c!oddmargin=\zeropoint,
+ \c!blank=\v!line,
+ %\c!escape=, % yes | no | {START,STOP} | default when yes: {BTEX,ETEX}
+ \c!numbering=\v!no,
+ %\c!range=,
+ \c!start=1,
+ %\c!stop=,
+ \c!step=1,
+ %\c!continue=,
+ \c!strip=\v!no] % auto or number
+
+\definetyping[\v!typing]
+
+% the \zeropoint forces the number to the margin but also works ok in text
+
+\setuplinenumbering[\v!typing][\c!location=\v!left,\c!width=\zeropoint]
+
+\setuptyping [\v!file] [\s!parent=\??typing \v!typing] % we don't want \start..\stop overload
+\setuplinenumbering[\v!file] [\s!parent=\??linenumbering\v!typing]
+
+\setuptyping [\v!buffer][\s!parent=\??typing \v!file] % we don't want \start..\stop overload
+\setuplinenumbering[\v!buffer][\s!parent=\??linenumbering\v!file]
+
+%D The setups for inline verbatim default to:
+
+\setuptype
+ [\c!space=\v!off,
+ \c!lines=\v!no,
+ %\c!color=,
+ \c!style=\tt,
+ %\c!option=\v!normal,
+ \c!page=\v!no,
+ \c!tab=\v!yes,
+ \c!compact=\v!all]
+
+%D Buffers
+
+% [name] [settings] | [name] | [settings]
+
+\permanent\protected\def\typebuffer
+ {\begingroup
+ \let\currenttyping\v!buffer
+ \buff_verbatim_type_buffer}
+
+\permanent\protected\def\typedefinedbuffer[#1]%
+ {\buff_verbatim_type_defined_buffer[\v!buffer][\thedefinedbuffer{#1}]}%
+
+\appendtoks
+ \frozen\instance\setuevalue{\e!type\currentbuffer}{\buff_verbatim_type_defined_buffer[\v!buffer][\currentdefinedbuffer]}%
+\to \everydefinebuffer
+
+\appendtoks % \e!buffer
+ \frozen\instance\setuevalue{\e!type\currenttyping\v!buffer}{\buff_verbatim_type_buffer_class{\currenttyping}}%
+\to \everydefinetyping
+
+\tolerant\protected\def\buff_verbatim_type_buffer[#1]#*[#2]%
+ {\ifarguments
+ \buff_verbatim_type_buffer_indeed\currenttyping\empty% []
+ \or
+ \ifhastok={#1}%
+ \setupcurrenttyping[#1]%
+ \buff_verbatim_type_buffer_indeed\currenttyping\empty% [settings]
+ \else
+ \processcommalist[#1]{\buff_verbatim_type_buffer_indeed\currenttyping}% [name]
+ \fi
+ \or
+ \setupcurrenttyping[#2]%
+ \processcommalist[#1]{\buff_verbatim_type_buffer_indeed\currenttyping}% [name] [settings]
+ \fi
+ \useindentnextparameter\typingparameter
+ \endgroup
+ \dorechecknextindentation}
+
+\protected\def\buff_verbatim_type_buffer_class#1%
+ {\begingroup
+ \edef\currenttyping{#1}%
+ \buff_verbatim_type_buffer}
+
+\tolerant\protected\def\buff_verbatim_type_defined_buffer[#1]#*[#2]#*[#3]% category name settings
+ {\begingroup
+ \ifarguments\or\or\or
+ \setuptyping[#1][#3]%
+ \fi
+ \buff_verbatim_type_buffer_indeed{#1}{#2}%
+ \useindentnextparameter\typingparameter
+ \endgroup
+ \dorechecknextindentation}
+
+\protected\def\buff_verbatim_type_buffer_indeed#1#2% category name
+ {\edef\currenttyping{#1}%
+ \typingparameter\c!before\relax
+ \startpacked[\v!blank]
+ \buff_verbatim_setup_line_numbering
+ \buff_verbatim_initialize_typing_one
+ \buff_verbatim_initialize_typing_two
+ \dostarttaggedchained\t!verbatimblock{#1}\??typing
+ \beginofverbatimlines
+ \dostarttagged\t!verbatimlines\empty
+ \clf_typebuffer
+ name {#2}%
+ strip {\typingparameter\c!strip}%
+ range {\typingparameter\c!range}%
+ regime {\currentregime}%
+ tab {\typingparameter\c!tab}%
+ method {\p_buff_option}%
+ escape {\typingparameter\c!escape}%
+ nature {display}%
+ \relax
+ \dostoptagged
+ \endofverbatimlines
+ \dostoptagged
+ \stoppacked
+ \typingparameter\c!after\relax}
+
+\permanent\protected\def\typeinlinebuffer
+ {\dontleavehmode
+ \begingroup
+ \enforced\let\buff_verbatim_type_buffer_indeed\buff_verbatim_type_buffer_indeed_inline
+ \enforced\let\setupcurrenttyping\setupcurrenttype % a terrible hack but it saves code
+ \let\currenttype\empty
+ \buff_verbatim_type_buffer}
+
+\protected\def\buff_verbatim_type_buffer_indeed_inline#1#2% category name
+ {\edef\currenttype{#1}%
+ \buff_verbatim_initialize_type_one
+ \dostarttaggedchained\t!verbatim\currenttype\??type
+ \clf_typebuffer
+ name {#2}%
+ strip {\v!yes}%
+ regime {\currentregime}%
+ method {\p_buff_option}%
+ nature {inline}% is default anyway
+ \relax
+ \dostoptagged}
+
+% get : before/after of buffer
+% typing : before/after of typing
+% process : no before/after (special case anyway)
+
+% the next one is obsolete (bad name and used nowhere) so if it stays
+% the name will change
+
+\permanent\tolerant\protected\def\processbuffer[#1]#*[#2]%
+ {\writestatus{nota bene}{\string\processbuffer\space is obsolete}%
+ \begingroup
+ \ifarguments
+ \buff_verbatim_process_indeed\v!buffer\empty% []
+ \or
+ %\ifcondition\validassignment{#1}%
+ \ifhastok={#1}%
+ \setuptyping[\v!buffer][#1]%
+ \buff_verbatim_process_indeed\v!buffer\empty% [settings]
+ \else
+ \processcommalist[#1]{\buff_verbatim_process_indeed\v!buffer}% [name]
+ \fi
+ \or
+ \setuptyping[\v!buffer][#2]%
+ \processcommalist[#1]{\buff_verbatim_process_indeed\v!buffer}% [name] [settings]
+ \fi
+ \endgroup}
+
+\def\buff_verbatim_process_indeed#1#2%
+ {\edef\currenttyping{#1}%
+ \clf_processbuffer
+ name {#2}%
+ strip {\typingparameter\c!strip}%
+ tab {\typingparameter\c!tab}%
+ % method {\p_buff_option}%
+ nature {direct}%
+ \relax}
+
+% so far for obsolete
+
+% line numbering, keep broken lines together
+
+\newcount\nofverbatimlines
+
+\protected\def\buff_verbatim_begin_of_line
+ {\ifconditional\verbatimnumberinglines
+ \global\advance\nofverbatimlines\plusone
+ \c_attr_verbatimline\nofverbatimlines
+ \fi
+ \noindent
+ \buff_verbatim_set_line_margin
+ \the\everyline % maybe also after starttagged
+ \strut % after starttagged, else break !
+ \dostarttagged\t!verbatimline\empty}
+
+\protected\def\buff_verbatim_end_of_line
+ {\dostoptagged
+ \obeyedline % still needed?
+ \par
+ \ifconditional\verbatimnumberinglines
+ \c_attr_verbatimline\attributeunsetvalue
+ \fi}
+
+\protected\def\buff_verbatim_empty_line
+ {\dostoptagged
+ \ifconditional\verbatimnumberinglines
+ \par\strut\par % this will be an option where we use a signal instead of a strut
+ \else
+ \blank[\typingparameter\c!blank]%
+ \fi
+ \dostarttagged\t!verbatimlines\empty}
+
+% hooks (todo: frozen):
+
+\newcount \c_buff_verbatim_noflines
+\newcount \c_buff_verbatim_current
+\newconditional\c_buff_optimize_linebreaks
+
+\permanent\protected\def\doverbatimspace {\obeyedspace}
+
+\permanent\protected\def\doinlineverbatimstart {}
+\permanent\protected\def\doinlineverbatimstop {}
+\permanent\protected\def\doinlineverbatimbeginline {}
+\permanent\protected\def\doinlineverbatimnewline {\obeyedspace}
+\permanent\protected\def\doinlineverbatimemptyline {\obeyedspace}
+
+\permanent\protected\def\dodisplayverbatimstart {\advance\c_buff_verbatim_current\plusone
+ \buff_verbatim_begin_of_line}
+\permanent\protected\def\dodisplayverbatimstop {\buff_verbatim_end_of_line}
+\permanent\protected\def\dodisplayverbatimbeginline{\advance\c_buff_verbatim_current\plusone
+ \buff_verbatim_begin_of_line}
+\permanent\protected\def\dodisplayverbatimnewline {\buff_verbatim_end_of_line
+ \par
+ \ifconditional\c_buff_optimize_linebreaks
+ \buff_verbatim_inject_breaks
+ \fi}
+\permanent\protected\def\dodisplayverbatimemptyline{\buff_verbatim_empty_line}
+
+\protected\def\buff_verbatim_inject_breaks
+ {\ifnum\c_buff_verbatim_current=\plusone
+ \nobreak
+ \orelse\ifnum\c_buff_verbatim_noflines=\plusthree
+ \nobreak
+ \orelse\ifnum\c_buff_verbatim_current=\numexpr\c_buff_verbatim_noflines-\plusone\relax
+ \nobreak
+ \fi}
+
+\permanent\protected\def\dodisplayverbatiminitialize#1%
+ {\forgetparindent % maybe more
+ \c_buff_verbatim_noflines#1\relax
+ \c_buff_verbatim_current\zerocount}
+
+\loadmarkfile{buff-imp-default} % preloaded as otherwise spurious spaces inline due to loading
+\loadmarkfile{buff-imp-nested} % preloaded as otherwise spurious spaces inline due to loading
+\loadmarkfile{buff-imp-escaped} % for completeness
+
+%D To be considered:
+
+% \installcorenamespace{visualizer}
+%
+% \installcommandhandler \??visualizer {visualizer} \??visualizer
+%
+% \appendtoks
+% \frozen\instance\setuevalue{\currentvisualizer}{\buff_verbatim_visualize{\currentvisualizer}}%
+% \to \everydefinevisualizer
+%
+% \protected\def\buff_verbatim_visualize#1%
+% {\bgroup
+% \def\currentvisualizer{#1}%
+% \usevisualizerstyleandcolor\c!style\c!color
+% \let\next}
+
+\appendtoks
+ \enforced\def\type#1{\detokenize\expandafter{\csstring#1}}% or maybe detokenize
+ \enforced\def\tex #1{\letterbackslash#1}%
+\to \everysimplifycommands
+
+\stopcontextdefinitioncode
+
+%D This is \type {\asciimode} without the double comment hackery:
+
+\permanent\protected\def\literalmode{\setcatcodetable\txtcatcodes}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/catc-act.mkxl b/Master/texmf-dist/tex/context/base/mkxl/catc-act.mkxl
new file mode 100644
index 00000000000..4ccf22a7f68
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/catc-act.mkxl
@@ -0,0 +1,51 @@
+%D \module
+%D [ file=catc-act,
+%D version=2006.09.18,
+%D title=\CONTEXT\ Catcode Macros,
+%D subtitle=Default Catcode Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+%D \macros
+%D {installactivecharacter, defineactivecharacter}
+%D
+%D This module deals with some active character handling and I still need to
+%D update it to use \typ {\letcharcode = \something}. This module
+%D will be simplified stepwise. Look into the \MKIV\ variant for originals.
+%D
+%D There was a time when we had active double quotes and such but we no longer
+%D do that. In fact, only the tilde and bar can be active in \CONTEXT.
+%D
+%D For those who love the more obscure features of \TEX: whenever you see
+%D uppercase magic with active characters, keep in mind that this is something
+%D deep down in the engine: handling of that specific case. The code here is
+%D not used and not really tested.
+
+\permanent\protected\def\installactivecharacter#1 %
+ {\ifchknum#1\or
+ \scratchcounter #1\edef\scratchmacro{\expandtoken\othercatcode\scratchcounter}%
+ \else
+ \scratchcounter`#1\let \scratchmacro #1%
+ \fi
+ \normalexpanded{\startextendcatcodetable\ctxcatcodes\catcode\the\scratchcounter\activecatcode\stopextendcatcodetable}%
+ \letcatcodecommand \ctxcatcodes \scratchcounter \scratchmacro
+ \ifnum\currentcatcodetable=\ctxcatcodes \setcatcodetable\ctxcatcodes \fi}
+
+\permanent\protected\def\defineactivecharacter #1 #2%
+ {\ifchknum#1\or\letcharcode#1=#2\relax\else\letcharcode`#1=#2\relax\fi}
+
+\permanent\protected\def\makecharacteractive #1 %
+ {\catcode`#1\activecatcode}
+
+\permanent\protected\def\installanddefineactivecharacter #1 #2%
+ {\normalexpanded{\installactivecharacter \utfchar{#1} }%
+ \defineactivecharacter #1 #2}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/catc-def.mkxl b/Master/texmf-dist/tex/context/base/mkxl/catc-def.mkxl
new file mode 100644
index 00000000000..a7d48714a5c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/catc-def.mkxl
@@ -0,0 +1,273 @@
+%D \module
+%D [ file=catc-def,
+%D version=2006.09.18,
+%D title=\CONTEXT\ Catcode Macros,
+%D subtitle=Default Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Contrary to \MKIV\ we define the catcode tables in one file. The original split
+%D was a prelude to a split approach where context would run on top of a basic layer
+%D (so that we could make smaller alternative formats) but that idea (from the early
+%D days of \LUATEX) was dropped when I realized that there is not common ground to
+%D cover between formats. It is simply not worth the trouble.
+
+\ifdefined\nilcatcodes \else \newcatcodetable \nilcatcodes \fi
+\ifdefined\texcatcodes \else \newcatcodetable \texcatcodes \fi
+\ifdefined\luacatcodes \else \newcatcodetable \luacatcodes \fi
+\ifdefined\notcatcodes \else \newcatcodetable \notcatcodes \fi
+\ifdefined\rlncatcodes \else \newcatcodetable \rlncatcodes \fi
+\ifdefined\vrbcatcodes \else \newcatcodetable \vrbcatcodes \fi
+\ifdefined\prtcatcodes \else \newcatcodetable \prtcatcodes \fi
+\ifdefined\ctxcatcodes \else \newcatcodetable \ctxcatcodes \fi
+\ifdefined\txtcatcodes \else \newcatcodetable \txtcatcodes \fi
+\ifdefined\tpacatcodes \else \newcatcodetable \tpacatcodes \fi % { }
+\ifdefined\tpbcatcodes \else \newcatcodetable \tpbcatcodes \fi % < >
+\ifdefined\ctdcatcodes \else \newcatcodetable \ctdcatcodes \fi % context definitions
+
+\startcatcodetable \nilcatcodes
+ \catcode\tabasciicode \spacecatcode
+ \catcode\endoflineasciicode \endoflinecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\spaceasciicode \spacecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+\stopcatcodetable
+
+\startcatcodetable \texcatcodes
+ \catcode\tabasciicode \spacecatcode
+ \catcode\endoflineasciicode \endoflinecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\spaceasciicode \spacecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ \catcode\circumflexasciicode\superscriptcatcode
+ \catcode\underscoreasciicode\subscriptcatcode
+ \catcode\ampersandasciicode \alignmentcatcode
+ \catcode\backslashasciicode \escapecatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode\endgroupcatcode
+ \catcode\dollarasciicode \mathshiftcatcode
+ \catcode\hashasciicode \parametercatcode
+ \catcode\commentasciicode \commentcatcode
+\stopcatcodetable
+
+\startcatcodetable \luacatcodes
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode \othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ \catcode\circumflexasciicode\othercatcode
+ \catcode\underscoreasciicode\othercatcode
+ \catcode\ampersandasciicode \othercatcode
+ \catcode\backslashasciicode \escapecatcode
+ \catcode\commentasciicode \othercatcode
+ \catcode\hashasciicode \othercatcode
+ \catcode\barasciicode \othercatcode
+ \catcode\leftbraceasciicode \othercatcode
+ \catcode\rightbraceasciicode\othercatcode
+ \catcode\tildeasciicode \othercatcode
+ \catcode\dollarasciicode \othercatcode
+\stopcatcodetable
+
+\startcatcodetable \notcatcodes % probably less needed
+ \catcode\tabasciicode \spacecatcode
+ \catcode\endoflineasciicode \endoflinecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\spaceasciicode \spacecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ \catcode\circumflexasciicode \othercatcode
+ \catcode\underscoreasciicode \othercatcode
+ \catcode\ampersandasciicode \othercatcode
+ \catcode\tildeasciicode \othercatcode
+ \catcode\hashasciicode \othercatcode
+ \catcode\dollarasciicode \othercatcode
+ \catcode\commentasciicode \othercatcode
+ \catcode\lessthanasciicode \othercatcode
+ \catcode\morethanasciicode \othercatcode
+ \catcode\leftbraceasciicode \othercatcode
+ \catcode\rightbraceasciicode \othercatcode
+ \catcode\doublequoteasciicode \othercatcode
+ \catcode\singlequoteasciicode \othercatcode
+ \catcode\forwardslashasciicode\othercatcode
+ \catcode\backslashasciicode \othercatcode
+ \catcode\barasciicode \othercatcode
+\stopcatcodetable
+
+\startcatcodetable \rlncatcodes
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode \othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \spacecatcode % maybe we also need a vector with space being other
+ \catcode\endoffileasciicode \othercatcode
+ \catcode\circumflexasciicode \othercatcode
+ \catcode\underscoreasciicode \othercatcode
+ \catcode\ampersandasciicode \othercatcode
+ \catcode\tildeasciicode \othercatcode
+ \catcode\hashasciicode \othercatcode
+ \catcode\dollarasciicode \othercatcode
+ \catcode\commentasciicode \othercatcode
+ \catcode\lessthanasciicode \othercatcode
+ \catcode\morethanasciicode \othercatcode
+ \catcode\leftbraceasciicode \othercatcode
+ \catcode\rightbraceasciicode \othercatcode
+ \catcode\doublequoteasciicode \othercatcode
+ \catcode\singlequoteasciicode \othercatcode
+ \catcode\forwardslashasciicode\othercatcode
+ \catcode\backslashasciicode \othercatcode
+ \catcode\barasciicode \othercatcode
+\stopcatcodetable
+
+\startcatcodetable \vrbcatcodes % probably less needed
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode\othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\endoffileasciicode\othercatcode
+\stopcatcodetable
+
+\startcatcodetable \prtcatcodes
+ \catcode\tabasciicode \spacecatcode
+ \catcode\endoflineasciicode \endoflinecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\spaceasciicode \spacecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ \catcode\circumflexasciicode \superscriptcatcode
+ %catcode\underscoreasciicode \subscriptcatcode
+ \catcode\underscoreasciicode \lettercatcode
+ \catcode\ampersandasciicode \alignmentcatcode
+ \catcode\backslashasciicode \escapecatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode \endgroupcatcode
+ \catcode\dollarasciicode \mathshiftcatcode
+ \catcode\hashasciicode \parametercatcode
+ \catcode\commentasciicode \commentcatcode
+ \catcode\atsignasciicode \lettercatcode
+ \catcode\exclamationmarkasciicode\lettercatcode
+ \catcode\questionmarkasciicode \lettercatcode
+ \catcode\tildeasciicode \activecatcode
+ \catcode\barasciicode \activecatcode
+\stopcatcodetable
+
+\startcatcodetable \ctxcatcodes
+ \catcode\tabasciicode \spacecatcode
+ \catcode\endoflineasciicode \endoflinecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\spaceasciicode \spacecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ % \catcode\circumflexasciicode\superscriptcatcode
+ % \catcode\underscoreasciicode\subscriptcatcode
+ % \catcode\ampersandasciicode \alignmentcatcode
+ \catcode\underscoreasciicode\othercatcode
+ \catcode\circumflexasciicode\othercatcode
+ \catcode\ampersandasciicode \othercatcode
+ \catcode\backslashasciicode \escapecatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode\endgroupcatcode
+ \catcode\dollarasciicode \mathshiftcatcode
+ \catcode\hashasciicode \parametercatcode
+ \catcode\commentasciicode \commentcatcode
+ \catcode\tildeasciicode \activecatcode
+ \catcode\barasciicode \activecatcode
+\stopcatcodetable
+
+\startcatcodetable \tpacatcodes
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode \othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\endoffileasciicode \othercatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode\endgroupcatcode
+\stopcatcodetable
+
+\startcatcodetable \tpbcatcodes
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode \othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\endoffileasciicode \othercatcode
+ \catcode\lessthanasciicode \begingroupcatcode
+ \catcode\morethanasciicode \endgroupcatcode
+\stopcatcodetable
+
+\setnewconstant \doublecommentsignal "10FF25 %% < 110000 (last valid range)
+
+\startcatcodetable \txtcatcodes
+ \catcode\tabasciicode \spacecatcode
+ \catcode\endoflineasciicode \endoflinecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\spaceasciicode \spacecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ \catcode\backslashasciicode \escapecatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode\endgroupcatcode
+ \catcode\doublecommentsignal\commentcatcode
+\stopcatcodetable
+
+\startcatcodetable \ctdcatcodes
+ \catcode\tabasciicode \ignorecatcode
+ \catcode\endoflineasciicode \ignorecatcode
+ \catcode\formfeedasciicode \ignorecatcode
+ \catcode\spaceasciicode \ignorecatcode
+ \catcode\endoffileasciicode \ignorecatcode
+ \catcode\circumflexasciicode \superscriptcatcode % candidate
+ \catcode\underscoreasciicode \lettercatcode
+ \catcode\ampersandasciicode \alignmentcatcode
+ % \catcode\colonasciicode \lettercatcode % candidate
+ \catcode\backslashasciicode \escapecatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode \endgroupcatcode
+ \catcode\dollarasciicode \mathshiftcatcode
+ \catcode\hashasciicode \parametercatcode
+ \catcode\commentasciicode \commentcatcode
+ \catcode\atsignasciicode \lettercatcode
+ \catcode\exclamationmarkasciicode\lettercatcode
+ \catcode\questionmarkasciicode \lettercatcode
+ \catcode\tildeasciicode \activecatcode
+ \catcode\barasciicode \activecatcode
+\stopcatcodetable
+
+%D From now on we can use the protection mechanisms.
+
+\permanent\protected\def\unprotect {\pushcatcodetable\catcodetable\prtcatcodes}
+\permanent\protected\def\protect {\popcatcodetable}
+
+\permanent\protected\def\starttexcode {\pushcatcodetable\catcodetable\prtcatcodes}
+\permanent\protected\def\stoptexcode {\popcatcodetable}
+
+\permanent\protected\def\startcontextcode {\pushcatcodetable\catcodetable\ctxcatcodes}
+\permanent\protected\def\stopcontextcode {\popcatcodetable}
+
+\permanent\protected\def\startcontextdefinitioncode {\pushcatcodetable\catcodetable\ctdcatcodes}
+\permanent\protected\def\stopcontextdefinitioncode {\popcatcodetable}
+
+%D We have a few active characters (left):
+
+\letcatcodecommand \ctxcatcodes \barasciicode \relax
+\letcatcodecommand \ctxcatcodes \tildeasciicode \relax
+
+%D Because some characters have a special meaning, we provide shortcuts to their
+%D character representation. Some will be overloaded (which might change).
+
+\permanent\chardef \^ = \circumflexasciicode
+\permanent\chardef \_ = \underscoreasciicode
+\permanent\chardef \& = \ampersandasciicode
+\permanent\chardef \% = \commentasciicode
+\permanent\chardef \# = \hashasciicode
+\permanent\chardef \$ = \dollarasciicode
+\permanent\chardef \{ = \leftbraceasciicode
+\permanent\chardef \} = \rightbraceasciicode
+\permanent\chardef \\ = \backslashasciicode
+\permanent\chardef \| = \barasciicode
+
+\pushoverloadmode
+ \catcodetable \ctxcatcodes
+ \aliased\let\defaultcatcodetable\ctxcatcodes
+\popoverloadmode
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/catc-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/catc-ini.lmt
new file mode 100644
index 00000000000..ede8216a640
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/catc-ini.lmt
@@ -0,0 +1,44 @@
+if not modules then modules = { } end modules ['catc-ini'] = {
+ version = 1.001,
+ comment = "companion to catc-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+catcodes = catcodes or { }
+catcodes.numbers = catcodes.numbers or { }
+catcodes.names = catcodes.names or { }
+
+storage.register("catcodes/numbers", catcodes.numbers, "catcodes.numbers")
+storage.register("catcodes/names", catcodes.names, "catcodes.names")
+
+local numbers = catcodes.numbers
+local names = catcodes.names
+
+-- We register the catcode tables in the \type {tex} namespace as we have been doing
+-- right from the start (when there wasn't much in that namespace). Normally
+-- registration of a table only happens when we're in so called ini mode. Also, the
+-- number of tables is rather small.
+
+function catcodes.register(name,number)
+ numbers[name] = number
+ local cnn = names[number]
+ if cnn then
+ cnn[#cnn+1] = name
+ else
+ names[number] = { name }
+ end
+ tex[name] = number -- downward compatible
+end
+
+-- At runtime we need to populate the \type {tex} namespace again.
+
+for name, number in next, numbers do
+ tex[name] = number -- downward compatible
+end
+
+-- We catch wrong usage.
+
+table.setmetatableindex(numbers,function(t,k) if type(k) == "number" then t[k] = k return k end end)
+table.setmetatableindex(names, function(t,k) if type(k) == "string" then t[k] = k return k end end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/catc-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/catc-ini.mkxl
new file mode 100644
index 00000000000..5b33db981d6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/catc-ini.mkxl
@@ -0,0 +1,274 @@
+%D \module
+%D [ file=catc-ini,
+%D version=2006.09.18,
+%D title=\CONTEXT\ System Macros,
+%D subtitle=Catcode Handling,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{catc-ini}{autosuffix}
+
+\unprotect
+
+%D A long standing wish has been the availability of catcode arrays. Because
+%D traditional \TEX\ does not provide this we implement a fake method in the \MKII\
+%D file. There is some overlap in code with \MKII\ but we take that for granted.
+%D Also, in \MKIV\ less active characters are used.
+
+% \begingroup
+% \letcharcode\newlineasciicode\relax \xdef\outputnewlinechar{\Uchar\newlineasciicode}
+% \endgroup
+
+% \endlinechar = \endoflineasciicode % appended to input lines
+% \newlinechar = \newlineasciicode % can be used in write
+
+% rather special and used in writing to file: \let\par\outputnewlinechar
+
+% \permanent\protected\def\initializenewlinechar % operating system dependent
+% {\begingroup
+% \enforced\letcharcode\newlineasciicode\relax
+% \newlinechar\newlineasciicode
+% \xdef\outputnewlinechar{\Uchar\newlineasciicode}%
+% \endgroup}
+
+%D We predefine some prefixes ahead of syst-aux and mult-sys. We reserve 8 slots for
+%D catcodes. (This active mess probably needs an update some day.)
+
+\installsystemnamespace{catcodelet} % let : \let
+\installsystemnamespace{catcodedef} % def : \def
+\installsystemnamespace{catcodeued} % ued : \protected\def
+\installsystemnamespace{catcodeget} % \meaning
+
+\installsystemnamespace{catcodetablet}
+\installsystemnamespace{catcodetablen}
+
+\newcount\c_syst_catcodes_n \c_syst_catcodes_n\zerocount % 0 = signal, so advance before allocate
+\newcount\c_syst_catcodes_a
+\newcount\c_syst_catcodes_b
+\newcount\c_syst_catcodes_c
+
+\permanent\protected\def\newcatcodetable#1% we could move the cctdefcounter to lua
+ {\global\advance\c_syst_catcodes_n\plusone
+ \gdefcsname\??catcodetablen\number\c_syst_catcodes_n\endcsname{\string#1}% logging
+ \immutable\integerdef#1\c_syst_catcodes_n
+ \ctxlua{catcodes.register("\expandafter\gobbleoneargument\string#1",\number#1)}}
+
+\newtoks\everysetdefaultcatcodes
+
+\everysetdefaultcatcodes % this might get dropped
+ {\catcode\backslashasciicode\othercatcode
+ \catcode\endoflineasciicode\othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\commentasciicode \othercatcode
+ \catcode\delasciicode \othercatcode}
+
+\permanent\protected\def\startcatcodetable#1#2\stopcatcodetable
+ {\begingroup
+ \catcodetable\inicatcodes
+ \the\everysetdefaultcatcodes
+ #2%
+ \savecatcodetable#1\relax
+ \endgroup}
+
+\permanent\let\stopcatcodetable\relax
+
+\permanent\protected\def\startextendcatcodetable#1#2\stopextendcatcodetable
+ {\begingroup
+ \catcodetable#1\relax
+ \globaldefs\plusone
+ #2%
+ \globaldefs\zerocount
+ \endgroup}
+
+\permanent\let\stopextendcatcodetable\relax
+
+\permanent\protected\def\permitcircumflexescape % to be used grouped
+ {\catcode\circumflexasciicode\superscriptcatcode}
+
+\aliased\let\permitcaretescape\permitcircumflexescape
+
+% ==
+%
+% \protected\def\startextendcatcodetable#1#2\stopextendcatcodetable
+% {\bgroup
+% \scratchcounter\the\catcodetable
+% \catcodetable #1 #2
+% \catcodetable\scratchcounter
+% \egroup}
+
+%D The next command can be defined in a cleaner way in the MkIV way but we want
+%D to have a fast one with a minimal chance for interference. Do we still need
+%D this complex mechanism? Probably not. Future versions of \MKIV\ might only use
+%D active characters for very special cases.
+
+\setnewconstant\c_syst_catcodes_hack\tildeasciicode
+
+%D Once a catcode is assigned, the next assignments will happen faster. However,
+%D redefinitions probably happen seldom so it's sort of overkill.
+
+\permanent\protected\def\letcatcodecommand{\afterassignment\syst_catcodes_let_a\c_syst_catcodes_a}
+\permanent\protected\def\defcatcodecommand{\afterassignment\syst_catcodes_def_a\c_syst_catcodes_a}
+\permanent\protected\def\uedcatcodecommand{\afterassignment\syst_catcodes_ued_a\c_syst_catcodes_a}
+
+\def\syst_catcodes_let_a{\afterassignment\syst_catcodes_let_b\c_syst_catcodes_b}
+\def\syst_catcodes_def_a{\afterassignment\syst_catcodes_def_b\c_syst_catcodes_b}
+\def\syst_catcodes_ued_a{\afterassignment\syst_catcodes_ued_b\c_syst_catcodes_b}
+
+\def\syst_catcodes_let_b % each time
+ {\ifcsname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\syst_catcodes_let_c
+ \fi}
+
+\def\syst_catcodes_def_b % each time
+ {\ifcsname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\syst_catcodes_def_c
+ \fi}
+
+\def\syst_catcodes_ued_b % each time
+ {\ifcsname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\syst_catcodes_ued_c
+ \fi}
+
+\def\syst_catcodes_let_c % only first time
+ {\frozen\enforced\gdefcsname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter
+ {\enforced\letcsname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}%
+ \syst_catcodes_reinstate_unexpanded
+ \csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
+
+\def\syst_catcodes_def_c % only first time (we could use \normalexpanded here)
+ {\frozen\enforced\gdefcsname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ \expandafter##\expandafter1\expandafter
+ {\frozen\enforced\defcsname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}%
+ \syst_catcodes_reinstate_normal
+ \csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
+
+\def\syst_catcodes_ued_c % only first time
+ {\frozen\enforced\gdefcsname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ \expandafter##\expandafter1\expandafter
+ {\frozen\enforced\protected\defcsname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}%
+ \syst_catcodes_reinstate_unexpanded
+ \csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
+
+\permanent\def\reinstatecatcodecommand{\afterassignment\syst_catcodes_reinstate_normal\c_syst_catcodes_b}
+
+%D This can be used when a direct definition has been done and the selector has been
+%D lost. A problem is that \type {\next} needs to be unique (as it gets bound) (still?).
+
+\def\syst_catcodes_reinstate_normal
+ {\begingroup
+ \edef\temp{\noexpand\catcodecommand{\number\c_syst_catcodes_b}}%
+ \global\letcharcode\c_syst_catcodes_b\temp
+ \endgroup}
+
+\def\syst_catcodes_reinstate_unexpanded
+ {\begingroup
+ \protected\edef\temp{\noexpand\catcodecommand{\number\c_syst_catcodes_b}}%
+ \global\letcharcode\c_syst_catcodes_b\temp
+ \endgroup}
+
+\newconstant\defaultcatcodetable
+
+\permanent\def\catcodecommand#1%
+ {\csname\??catcodeget\number
+ \ifcsname\??catcodeget\number\currentcatcodetable:\number#1\endcsname
+ \currentcatcodetable \else \defaultcatcodetable
+ \fi
+ :\number#1\endcsname}
+
+%D \macros
+%D {restorecatcodes,pushcatcodetable,popcatcodetable}
+%D
+%D We're not finished dealing \CATCODES\ yet. In \CONTEXT\ we use only one auxiliary
+%D file, which deals with tables of contents, registers, two pass tracking,
+%D references etc. This file, as well as files concerning graphics, is processed
+%D when needed, which can be in the mid of typesetting verbatim. However, when
+%D reading in data in verbatim mode, we should temporary restore the normal
+%D \CATCODES, and that's exactly what the next macros do. Saving the catcodes can be
+%D disabled by saying \type {\localcatcodestrue}. In \MKIV\ instead we can push and
+%D pop catcode tables and as we keep track of used tables users seldom need to deal
+%D with this themselves.
+
+\newcount\c_syst_catcodes_level
+
+\permanent\protected\def\pushcatcodetable
+ {\advance\c_syst_catcodes_level\plusone
+ \syst_catcodes_trace_push
+ \expandafter\integerdef\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname\currentcatcodetable}
+
+\permanent\protected\def\popcatcodetable
+ {\ifcase\c_syst_catcodes_level
+ \syst_catcodes_trace_nesting_error
+ \else
+ \catcodetable\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname
+ \syst_catcodes_trace_pop
+ \advance\c_syst_catcodes_level\minusone
+ \fi}
+
+\protected\def\syst_catcodes_trace_nesting_error
+ {\immediate\write\statuswrite{}%
+ \immediate\write\statuswrite{Fatal error: catcode push/pop mismatch. Fix this! (restore level: \number\c_syst_catcodes_level)}\wait\end
+ \immediate\write\statuswrite{}}
+
+\permanent\protected\def\restorecatcodes % takes previous level
+ {\ifnum\c_syst_catcodes_level>\plusone
+ \catcodetable\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname
+ \fi}
+
+\permanent\protected\def\setcatcodetable#1%
+ {\catcodetable#1%
+ \syst_catcodes_trace_set}
+
+%D Handy for debugging (not that we ever use(d) it):
+%D
+%D \starttyping
+%D \tracecatcodetables
+%D \stoptyping
+
+\permanent\protected\def\tracecatcodetables
+ {\def\syst_catcodes_trace_set {\syst_catcodes_trace{set \catcodetablename\space at \number\c_syst_catcodes_level}}%
+ \def\syst_catcodes_trace_push{\syst_catcodes_trace{push \catcodetablename\space from \syst_catcodes_prev\space at \number\c_syst_catcodes_level}}%
+ \def\syst_catcodes_trace_pop {\syst_catcodes_trace{pop \catcodetablename\space to \syst_catcodes_prev\space at \number\c_syst_catcodes_level}}}
+
+\def\syst_catcodes_trace#1{\immediate\write\statuswrite{[#1]}}
+
+\def\syst_catcodes_prev
+ {\ifnum\numexpr\c_syst_catcodes_level-1\relax>\zerocount
+ \csname\??catcodetablen\number\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname
+ \else
+ -%
+ \fi}
+
+\permanent\def\catcodetablename
+ {\ifnum\currentcatcodetable>\zerocount
+ \csname\??catcodetablen\number\currentcatcodetable\endcsname
+ \else
+ -%
+ \fi}
+
+\let\syst_catcodes_trace_set \empty
+\let\syst_catcodes_trace_push\empty
+\let\syst_catcodes_trace_pop \empty
+
+% \tracecatcodetables
+
+\protect
+
+%D We still have to define these so let's do that now:
+
+\newcatcodetable \inicatcodes
+\initcatcodetable\inicatcodes
+
+\mutable\let\currentcatcodetable\catcodetable
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/catc-sym.mkxl b/Master/texmf-dist/tex/context/base/mkxl/catc-sym.mkxl
new file mode 100644
index 00000000000..a96ffb865c0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/catc-sym.mkxl
@@ -0,0 +1,96 @@
+%D \module
+%D [ file=catc-sym,
+%D version=1997.01.03, % moved code
+%D title=\CONTEXT\ Catcode Macros,
+%D subtitle=Some Handy Constants,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The following definitions can be used for mapping special characters onto
+%D letters, although we cheat a bit: they actually are of category other but
+%D for users that distinction doesn't matter here. The definitions in \MKII\
+%D and \MKIV\ look more impressive but here we use a \LUAMETATEX\ feature
+%D that permits a more direct definition (that also looks nice with the
+%D \CONTEXT\ syntax highlighting):
+
+\immutable\edef\letterleftbrace {\expandtoken \othercatcode \leftbraceasciicode}
+\immutable\edef\letterrightbrace {\expandtoken \othercatcode \rightbraceasciicode}
+\immutable\edef\letterampersand {\expandtoken \othercatcode \ampersandasciicode}
+\immutable\edef\letterless {\expandtoken \othercatcode \lessthanasciicode}
+\immutable\edef\lettermore {\expandtoken \othercatcode \morethanasciicode}
+\immutable\edef\letterhash {\expandtoken \othercatcode \hashasciicode}
+\immutable\edef\letterdoublequote {\expandtoken \othercatcode \doublequoteasciicode}
+\immutable\edef\lettersinglequote {\expandtoken \othercatcode \singlequoteasciicode}
+\immutable\edef\letterdollar {\expandtoken \othercatcode \dollarasciicode}
+\immutable\edef\letterpercent {\expandtoken \othercatcode \percentasciicode}
+\immutable\edef\letterhat {\expandtoken \othercatcode \circumflexasciicode}
+\immutable\edef\letterunderscore {\expandtoken \othercatcode \underscoreasciicode}
+\immutable\edef\letterbar {\expandtoken \othercatcode \barasciicode}
+\immutable\edef\lettertilde {\expandtoken \othercatcode \tildeasciicode}
+\immutable\edef\letterbackslash {\expandtoken \othercatcode \backslashasciicode}
+\immutable\edef\letterslash {\expandtoken \othercatcode \forwardslashasciicode}
+\immutable\edef\letterquestionmark {\expandtoken \othercatcode \questionmarkasciicode}
+\immutable\edef\letterexclamationmark {\expandtoken \othercatcode \exclamationmarkasciicode}
+\immutable\edef\letterat {\expandtoken \othercatcode \atsignasciicode}
+\immutable\edef\lettercolon {\expandtoken \othercatcode \colonasciicode}
+\immutable\edef\letterhyphen {\expandtoken \othercatcode \hyphenasciicode}
+
+\immutable\edef\letterleftparenthesis {\expandtoken \othercatcode \leftparentasciicode}
+\immutable\edef\letterrightparenthesis {\expandtoken \othercatcode \rightparentasciicode}
+\immutable\edef\letterleftbracket {\expandtoken \othercatcode \leftbracketasciicode}
+\immutable\edef\letterrightbracket {\expandtoken \othercatcode \rightbracketasciicode}
+
+\aliased\let\letterescape \letterbackslash
+\aliased\let\letterbgroup \letterleftbrace
+\aliased\let\letteregroup \letterrightbrace
+\aliased\let\letteropenbrace \letterleftbrace
+\aliased\let\letterclosebrace\letterrightbrace
+
+\unprotect
+
+%immutable\edef\s!n_u_l_token{\expandtoken \othercatcode \zerocount} % nul(l)
+%immutable\edef\s!s_o_h_token{\expandtoken \othercatcode \plusone } % start of header ^^^^0001
+%immutable\edef\s!s_t_x_token{\expandtoken \othercatcode \plustwo } % start of text ^^^^0002
+%immutable\edef\s!e_t_x_token{\expandtoken \othercatcode \plusthree} % end of text ^^^^0003
+\immutable\edef\s!e_o_t_token{\expandtoken \othercatcode \plusfour } % end of transmission ^^^^0004
+%immutable\edef\s!e_n_q_token{\expandtoken \othercatcode \plusfive } % enquiry
+%immutable\edef\s!a_c_k_token{\expandtoken \othercatcode \plussix } % aknowledgement
+
+\protect
+
+%D \macros
+%D {uncatcodespecials,setnaturalcatcodes,setnormalcatcodes,
+%D uncatcodecharacters,uncatcodeallcharacters,
+%D uncatcodespacetokens}
+%D
+%D The following macros are more or less replaced by switching to a catcode table
+%D (which we simulate in \MKII) but we keep them for convenience and compatibility.
+%D Some old engine code has been removed. A few ar still used a few times so I need
+%D to clean that up.
+
+%permanent\protected\def\uncatcodespecials {\setcatcodetable\nilcatcodes \uncatcodespacetokens}
+%permanent\protected\def\setnaturalcatcodes {\setcatcodetable\nilcatcodes}
+\permanent\protected\def\setnormalcatcodes {\setcatcodetable\ctxcatcodes} % maybe \texcatcodes
+%permanent\protected\def\uncatcodecharacters {\setcatcodetable\nilcatcodes} % was fast version, gone now
+%permanent\protected\def\uncatcodeallcharacters{\setcatcodetable\nilcatcodes} % was slow one, with restore
+
+\permanent\protected\def\uncatcodespacetokens
+ {\catcode\spaceasciicode \spacecatcode
+ \catcode\tabasciicode \spacecatcode
+ \catcode\formfeedasciicode \endoflinecatcode
+ \catcode\endoflineasciicode\endoflinecatcode
+ \catcode\delasciicode \ignorecatcode}
+
+%D These two are probably no longer needed, but we keep them for a while. Some more
+%D explanation can be foun din the mkiv variant of this module, where we also
+%D discuss side effects. It's time to move on, so these might go away some day.
+
+\aliased \let\rescan \scantextokens
+\permanent\def\rescanwithsetup#1#2{\begingroup\directsetup{#1}\scantextokens{#2}\endgroup}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/char-act.mkxl b/Master/texmf-dist/tex/context/base/mkxl/char-act.mkxl
new file mode 100644
index 00000000000..3fb4d2da65d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/char-act.mkxl
@@ -0,0 +1,99 @@
+%D \module
+%D [ file=char-act,
+%D version=2006.12.05,
+%D title=\CONTEXT\ Character Support,
+%D subtitle=Active,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Character Support / Active}
+
+\unprotect
+
+\ifdefined\page_otr_fill_and_eject_page \else \let\page_otr_fill_and_eject_page\relax \fi % forward reference
+
+%D \macros
+%D {obeyedspace, obeyedtab, obeyedline, obeyedpage}
+%D
+%D We have followed Knuth in naming macros that make \SPACE, \NEWLINE\ and \NEWPAGE\
+%D active and assigning them \type {\obeysomething}, but first we set some default
+%D values.
+%D
+%D These are expandable:
+
+\permanent\def\obeyedspace{\space}
+\permanent\def\obeyedtab {\obeyedspace}
+\permanent\def\obeyedline {\par}
+\permanent\def\obeyedpage {\page_otr_fill_and_eject_page}
+
+%D \macros
+%D {controlspace,setcontrolspaces}
+%D
+%D First we define \type {\obeyspaces}. When we want visible spaces (control spaces)
+%D we only have to adapt the definition of \type {\obeyedspace} to:
+
+\immutable\chardef\asciispacechar\spaceasciicode % a real space character
+
+\permanent\protected\def\naturalspace{\asciispacechar}
+\permanent\protected\def\controlspace{\hbox{\asciispacechar}} % rather tex, we need the unicode value
+\permanent\protected\def\normalspaces{\catcode\spaceasciicode\spacecatcode}
+
+% \bgroup
+% \catcode\spaceasciicode\activecatcode
+% \protected\gdef\obeyspaces {\catcode\spaceasciicode\activecatcode\def {\obeyedspace }}
+% \protected\gdef\setcontrolspaces{\catcode\spaceasciicode\activecatcode\def {\controlspace}}
+% \egroup
+
+%permanent\protected\def\obeyspaces {\catcode\spaceasciicode\activecatcode\letcharcode\spaceasciicode\obeyedspace }
+%permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\letcharcode\spaceasciicode\controlspace}
+
+%D \macros
+%D {obeytabs, obeylines, obeypages,ignoretabs, ignorelines, ignorepages}
+%D
+%D Next we take care of \NEWLINE\ and \NEWPAGE\ and because we want to be able to
+%D typeset listings that contain \TAB, we have to handle those too. Because we have
+%D to redefine the \NEWPAGE\ character locally, we redefine the meaning of this
+%D (often already) active character.
+
+% \expandafter\def\activeformfeedtoken{\par}
+
+\letcharcode\formfeedasciicode\par
+
+%D The following indirect definitions enable us to implement all kind of \type
+%D {\obeyed} handlers.
+
+% \protected\def\obeytabs {\catcode\tabasciicode \activecatcode\expandafter\def\activetabtoken {\obeyedtab }}
+% \protected\def\obeylines {\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedline}}
+% \protected\def\obeypages {\catcode\formfeedasciicode \activecatcode\expandafter\def\activeformfeedtoken {\obeyedpage}}
+
+% \protected\def\ignoretabs {\catcode\tabasciicode \activecatcode\expandafter\def\activetabtoken {\obeyedspace}}
+% \protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\expandafter\def\activeendoflinetoken{\obeyedspace}}
+% \protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
+% \protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode}
+
+% but ... as we don't want to freeze to \obeyedspace etc which can be set after
+% \obeyspaces, we use an idirectness
+
+\def\syst_obeyed_space{\obeyedspace}
+\def\syst_obeyed_tab {\obeyedtab}
+\def\syst_obeyed_line {\obeyedline}
+\def\syst_obeyed_page {\obeyedpage}
+
+\permanent\protected\def\obeyspaces {\catcode\spaceasciicode \activecatcode\enforced\letcharcode\spaceasciicode \syst_obeyed_space}
+\permanent\protected\def\obeytabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \syst_obeyed_tab }
+\permanent\protected\def\obeylines {\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_line }
+\permanent\protected\def\obeypages {\catcode\formfeedasciicode \activecatcode\enforced\letcharcode\formfeedasciicode \syst_obeyed_page }
+
+\permanent\protected\def\ignoretabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \syst_obeyed_space}
+\permanent\protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_space}
+\permanent\protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode}
+\permanent\protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode}
+
+\permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\enforced\letcharcode\spaceasciicode\controlspace}
+
+\endinput \protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/char-enc.mkxl b/Master/texmf-dist/tex/context/base/mkxl/char-enc.mkxl
new file mode 100644
index 00000000000..d0dd3d20a5d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/char-enc.mkxl
@@ -0,0 +1,18 @@
+%D \module
+%D [ file=char-enc,
+%D version=2006.08.20,
+%D title=\CONTEXT\ Character Support,
+%D subtitle=Encodings,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Character Support / Encodings}
+
+\registerctxluafile{char-enc}{}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/char-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/char-ini.mkxl
new file mode 100644
index 00000000000..6965598a960
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/char-ini.mkxl
@@ -0,0 +1,126 @@
+%D \module
+%D [ file=char-ini,
+%D version=2006.08.20,
+%D title=\CONTEXT\ Character Support,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Character Support / Initialization}
+
+\registerctxluafile{char-fio}{}
+\registerctxluafile{char-map}{} % maybe we will load this someplace else
+\registerctxluafile{char-tex}{autosuffix}
+\registerctxluafile{char-ent}{}
+
+\unprotect
+
+% ¨äëïöüÿ
+% ´áćéíĺńóŕśúýź
+% ˙ċėġiż
+% ¯āēīōū
+% ˝őű
+% ˆâĉêĝĥîĵôŝûŵŷ
+% `àèìòùỳ
+% ¸çķļņŗşţ
+% ˛ąęįų
+% ˚åů
+% ˘ăĕğĭŏŭ
+% ˇčďěľňřšťž
+% ˜ãĩñõũ
+
+% \def\checkedchar#1% #2%
+% {\relax\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}
+%
+% impossible in math mode so there always fallback (till we have gyre):
+%
+% use \normalUchar when possible .. the next one is nice for documents and it also accepts
+% 0x prefixed numbers
+
+\permanent\def\utfchar #1{\clf_utfchar {#1}} % todo: define public at lua end
+\permanent\def\safechar#1{\clf_safechar{#1}} % todo: define public at lua end
+
+\permanent\protected\def\Ux #1{\Uchar\numexpr"#1\relax} % used in xml (sometimes overloaded)
+\permanent \def\eUx#1{\Uchar\numexpr"#1\relax} % used in xml (sometimes overloaded)
+
+\permanent\def\expandUx{\enforced\let\Ux\eUx}
+
+\permanent \def\checkedchar {\relax\ifmmode\expandafter\checkedmathchar\else\expandafter\checkedtextchar\fi} % #1#2
+\permanent \def\checkedmathchar#1#2{#2}
+\permanent\protected\def\checkedtextchar #1{\clf_doifelsecharinfont\numexpr#1\relax{\char#1}} % {#2}
+
+\newconditional\prefermathovertextchar
+
+\permanent\protected\def\textormathchar#1%
+ {\begingroup
+ \scratchcounter#1\relax
+ \ifmmode
+ \char\scratchcounter
+ \else
+ \ifconditional\prefermathovertextchar
+ % dirty trick .. maybe let this adapt to bf too ?
+ \setfontid\fontid\textfont\c_font_fam_mr
+ \fi
+ \iffontchar\font\scratchcounter
+ \char\scratchcounter
+ \else
+ \normalstartimath\char\scratchcounter\normalstopimath
+ \fi
+ \fi
+ \endgroup}
+
+\permanent\protected\def\textormathchars#1%
+ {{\font_text_or_mathchars#1\relax}}
+
+\protected\def\font_text_or_mathchars#1#2\relax
+ {\relax\ifmmode
+ #1#2%
+ \orelse\iffontchar\font`#1\relax
+ #1#2\relax
+ \else
+ \normalstartimath#1#2\normalstopimath
+ \fi}
+
+%D The codes are stored in the format, so we don't need to reinitialize them (unless
+%D of course we have adapted the table). It is on the agenda to do this with \type
+%D {tex.lccode} cum suis once they're available.
+
+% Is setting up vrb tpa and tpb needed?
+
+% move to lua side
+
+\clf_setlettercatcodes\texcatcodes
+\clf_setlettercatcodes\ctxcatcodes
+\clf_setlettercatcodes\notcatcodes
+%clf_setlettercatcodes\mthcatcodes
+\clf_setlettercatcodes\vrbcatcodes % hm ... we need to hyphemate
+\clf_setlettercatcodes\prtcatcodes
+\clf_setlettercatcodes\tpacatcodes % hm
+\clf_setlettercatcodes\tpbcatcodes % hm
+\clf_setlettercatcodes\txtcatcodes
+
+\clf_setothercatcodes \rlncatcodes
+
+\clf_setactivecatcodes\ctxcatcodes
+\clf_setactivecatcodes\notcatcodes
+\clf_setactivecatcodes\prtcatcodes
+
+\clf_setcharacternames\ctxcatcodes
+
+\permanent\def\chardescription#1{\clf_chardescription#1\relax}
+
+% experiment (watch out: this is global and very font dependent when used with
+% casing mechanisms)
+%
+% \overloaduppercase{0xDF}{0x1E9E}}
+% \overloaduppercase{0xDF}{0x53,0x53}
+
+\permanent\protected\def\overloaduppercase{\clf_overloaduppercase} % todo: define public at lua end
+\permanent\protected\def\overloadlowercase{\clf_overloadlowercase} % todo: define public at lua end
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/char-tex.lmt b/Master/texmf-dist/tex/context/base/mkxl/char-tex.lmt
new file mode 100644
index 00000000000..3d8f6a2598e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/char-tex.lmt
@@ -0,0 +1,994 @@
+if not modules then modules = { } end modules ['char-tex'] = {
+ version = 1.001,
+ comment = "companion to char-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local lpeg = lpeg
+local tonumber, next, type = tonumber, next, type
+local format, find, gmatch, match, gsub = string.format, string.find, string.gmatch, string.match, string.gsub
+local utfchar, utfbyte = utf.char, utf.byte
+local concat, tohash = table.concat, table.tohash
+local P, C, R, S, V, Cs, Cc = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.V, lpeg.Cs, lpeg.Cc
+
+local lpegpatterns = lpeg.patterns
+local lpegmatch = lpeg.match
+local utfchartabletopattern = lpeg.utfchartabletopattern
+
+local allocate = utilities.storage.allocate
+local mark = utilities.storage.mark
+
+local context = context
+local commands = commands
+
+local characters = characters
+local texcharacters = { }
+characters.tex = texcharacters
+local utffilters = characters.filters.utf
+
+local allocate = utilities.storage.allocate or function() return { } end
+local mark = utilities.storage.mark or allocate
+
+local is_character = characters.is_character
+local is_letter = characters.is_letter
+local is_command = characters.is_command
+local is_spacing = characters.is_spacing
+local is_mark = characters.is_mark
+local is_punctuation = characters.is_punctuation
+
+local data = characters.data if not data then return end
+local blocks = characters.blocks
+
+local trace_defining = false trackers.register("characters.defining", function(v) characters_defining = v end)
+
+local report_defining = logs.reporter("characters")
+
+--[[ldx--
+
In order to deal with 8-bit output, we need to find a way to go from to
+8-bit. This is handled in the engine itself.
+
+
This leaves us problems with characters that are specific to like
+{}, $ and alike. We can remap some chars that tex input files
+are sensitive for to a private area (while writing to a utility file) and revert then
+to their original slot when we read in such a file. Instead of reverting, we can (when
+we resolve characters to glyphs) map them to their right glyph there. For this purpose
+we can use the private planes 0x0F0000 and 0x100000.
+--ldx]]--
+
+local low = allocate()
+local high = allocate()
+local escapes = allocate()
+local special = "~#$%^&_{}\\|" -- "~#$%{}\\|"
+
+local private = {
+ low = low,
+ high = high,
+ escapes = escapes,
+}
+
+utffilters.private = private
+
+for ch in gmatch(special,".") do
+ local cb
+ if type(ch) == "number" then
+ cb, ch = ch, utfchar(ch)
+ else
+ cb = utfbyte(ch)
+ end
+ if cb < 256 then
+ escapes[ch] = "\\" .. ch
+ low[ch] = utfchar(0x0F0000 + cb)
+ if ch == "%" then
+ ch = "%%" -- nasty, but we need this as in replacements (also in lpeg) % is interpreted
+ end
+ high[utfchar(0x0F0000 + cb)] = ch
+ end
+end
+
+local tohigh = lpeg.replacer(low) -- frozen, only for basic tex
+local tolow = lpeg.replacer(high) -- frozen, only for basic tex
+
+lpegpatterns.utftohigh = tohigh
+lpegpatterns.utftolow = tolow
+
+function utffilters.harden(str)
+ return lpegmatch(tohigh,str)
+end
+
+function utffilters.soften(str)
+ return lpegmatch(tolow,str)
+end
+
+private.escape = utf.remapper(escapes) -- maybe: ,"dynamic"
+private.replace = utf.remapper(low) -- maybe: ,"dynamic"
+private.revert = utf.remapper(high) -- maybe: ,"dynamic"
+
+--[[ldx--
+
We get a more efficient variant of this when we integrate
+replacements in collapser. This more or less renders the previous
+private code redundant. The following code is equivalent but the
+first snippet uses the relocated dollars.
+
+
+[x] [$x$]
+
+--ldx]]--
+
+-- using the tree-lpeg-mapper would be nice but we also need to deal with end-of-string
+-- cases: "\"\i" and don't want "\relax" to be seen as \r e lax" (for which we need to mess
+-- with spaces
+
+local accentmapping = allocate {
+ ['"'] = { [""] = "¨",
+ A = "Ä", a = "ä",
+ E = "Ë", e = "ë",
+ I = "Ï", i = "ï", ["ı"] = "ï", ["\\i"] = "ï",
+ O = "Ö", o = "ö",
+ U = "Ü", u = "ü",
+ Y = "Ÿ", y = "ÿ",
+ },
+ ["'"] = { [""] = "´",
+ A = "Á", a = "á",
+ C = "Ć", c = "ć",
+ E = "É", e = "é",
+ I = "Í", i = "í", ["ı"] = "í", ["\\i"] = "í",
+ L = "Ĺ", l = "ĺ",
+ N = "Ń", n = "ń",
+ O = "Ó", o = "ó",
+ R = "Ŕ", r = "ŕ",
+ S = "Ś", s = "ś",
+ U = "Ú", u = "ú",
+ Y = "Ý", y = "ý",
+ Z = "Ź", z = "ź",
+ },
+ ["."] = { [""] = "˙",
+ C = "Ċ", c = "ċ",
+ E = "Ė", e = "ė",
+ G = "Ġ", g = "ġ",
+ I = "İ", i = "i", ["ı"] = "i", ["\\i"] = "i",
+ Z = "Ż", z = "ż",
+ },
+ ["="] = { [""] = "¯",
+ A = "Ā", a = "ā",
+ E = "Ē", e = "ē",
+ I = "Ī", i = "ī", ["ı"] = "ī", ["\\i"] = "ī",
+ O = "Ō", o = "ō",
+ U = "Ū", u = "ū",
+ },
+ ["H"] = { [""] = "˝",
+ O = "Ő", o = "ő",
+ U = "Ű", u = "ű",
+ },
+ ["^"] = { [""] = "ˆ",
+ A = "Â", a = "â",
+ C = "Ĉ", c = "ĉ",
+ E = "Ê", e = "ê",
+ G = "Ĝ", g = "ĝ",
+ H = "Ĥ", h = "ĥ",
+ I = "Î", i = "î", ["ı"] = "î", ["\\i"] = "î",
+ J = "Ĵ", j = "ĵ",
+ O = "Ô", o = "ô",
+ S = "Ŝ", s = "ŝ",
+ U = "Û", u = "û",
+ W = "Ŵ", w = "ŵ",
+ Y = "Ŷ", y = "ŷ",
+ },
+ ["`"] = { [""] = "`",
+ A = "À", a = "à",
+ E = "È", e = "è",
+ I = "Ì", i = "ì", ["ı"] = "ì", ["\\i"] = "ì",
+ O = "Ò", o = "ò",
+ U = "Ù", u = "ù",
+ Y = "Ỳ", y = "ỳ",
+ },
+ ["c"] = { [""] = "¸",
+ C = "Ç", c = "ç",
+ K = "Ķ", k = "ķ",
+ L = "Ļ", l = "ļ",
+ N = "Ņ", n = "ņ",
+ R = "Ŗ", r = "ŗ",
+ S = "Ş", s = "ş",
+ T = "Ţ", t = "ţ",
+ },
+ ["k"] = { [""] = "˛",
+ A = "Ą", a = "ą",
+ E = "Ę", e = "ę",
+ I = "Į", i = "į",
+ U = "Ų", u = "ų",
+ },
+ ["r"] = { [""] = "˚",
+ A = "Å", a = "å",
+ U = "Ů", u = "ů",
+ },
+ ["u"] = { [""] = "˘",
+ A = "Ă", a = "ă",
+ E = "Ĕ", e = "ĕ",
+ G = "Ğ", g = "ğ",
+ I = "Ĭ", i = "ĭ", ["ı"] = "ĭ", ["\\i"] = "ĭ",
+ O = "Ŏ", o = "ŏ",
+ U = "Ŭ", u = "ŭ",
+ },
+ ["v"] = { [""] = "ˇ",
+ C = "Č", c = "č",
+ D = "Ď", d = "ď",
+ E = "Ě", e = "ě",
+ L = "Ľ", l = "ľ",
+ N = "Ň", n = "ň",
+ R = "Ř", r = "ř",
+ S = "Š", s = "š",
+ T = "Ť", t = "ť",
+ Z = "Ž", z = "ž",
+ },
+ ["~"] = { [""] = "˜",
+ A = "Ã", a = "ã",
+ I = "Ĩ", i = "ĩ", ["ı"] = "ĩ", ["\\i"] = "ĩ",
+ N = "Ñ", n = "ñ",
+ O = "Õ", o = "õ",
+ U = "Ũ", u = "ũ",
+ },
+}
+
+texcharacters.accentmapping = accentmapping
+
+local accent_map = allocate { -- incomplete
+ ['~'] = "̃" , -- ̃ Ẽ
+ ['"'] = "̈" , -- ̈ Ë
+ ["`"] = "̀" , -- ̀ È
+ ["'"] = "́" , -- ́ É
+ ["^"] = "̂" , -- ̂ Ê
+ -- ̄ Ē
+ -- ̆ Ĕ
+ -- ̇ Ė
+ -- ̉ Ẻ
+ -- ̌ Ě
+ -- ̏ Ȅ
+ -- ̑ Ȇ
+ -- ̣ Ẹ
+ -- ̧ Ȩ
+ -- ̨ Ę
+ -- ̭ Ḙ
+ -- ̰ Ḛ
+}
+
+-- local accents = concat(table.keys(accentmapping)) -- was _map
+
+local function remap_accent(a,c,braced)
+ local m = accentmapping[a]
+ if m then
+ local n = m[c]
+ if n then
+ return n
+ end
+ end
+-- local m = accent_map[a]
+-- if m then
+-- return c .. m
+-- elseif braced then -- or #c > 0
+ if braced then -- or #c > 0
+ return "\\" .. a .. "{" .. c .. "}"
+ else
+ return "\\" .. a .. " " .. c
+ end
+end
+
+local commandmapping = allocate {
+ ["aa"] = "å", ["AA"] = "Å",
+ ["ae"] = "æ", ["AE"] = "Æ",
+ ["cc"] = "ç", ["CC"] = "Ç",
+ ["i"] = "ı", ["j"] = "ȷ",
+ ["ij"] = "ij", ["IJ"] = "IJ",
+ ["l"] = "ł", ["L"] = "Ł",
+ ["o"] = "ø", ["O"] = "Ø",
+ ["oe"] = "œ", ["OE"] = "Œ",
+ ["sz"] = "ß", ["SZ"] = "SZ", ["ss"] = "ß", ["SS"] = "ß", -- uppercase: ẞ
+}
+
+texcharacters.commandmapping = commandmapping
+
+local ligaturemapping = allocate {
+ ["''"] = "”",
+ ["``"] = "“",
+ ["--"] = "–",
+ ["---"] = "—",
+}
+
+-- Older accent handling code can be found in char-def.lua but in the meantime
+-- we moved on. First the one with commands:
+
+local untex, pattern
+
+local function toutfpattern()
+ if not untex then
+ local hash = { }
+ for k, v in next, accentmapping do
+ for kk, vv in next, v do
+ if (k >= "a" and k <= "z") or (k >= "A" and k <= "Z") then
+ hash[ "\\"..k.." "..kk ] = vv
+ hash["{\\"..k.." "..kk.."}"] = vv
+ else
+ hash["\\" ..k ..kk ] = vv
+ hash["{\\"..k ..kk.."}"] = vv
+ end
+ hash["\\" ..k.."{"..kk.."}" ] = vv
+ hash["{\\"..k.."{"..kk.."}}"] = vv
+ end
+ end
+ for k, v in next, commandmapping do
+ hash["\\"..k.." "] = v
+ hash["{\\"..k.."}"] = v
+ hash["{\\"..k.." }"] = v
+ end
+ for k, v in next, ligaturemapping do
+ hash[k] = v
+ end
+ untex = utfchartabletopattern(hash) / hash
+ end
+ return untex
+end
+
+local function prepare()
+ pattern = Cs((toutfpattern() + P(1))^0)
+ return pattern
+end
+
+local function textoutf(str,strip)
+ if str == "" then
+ return str
+ elseif not find(str,"\\",1,true) then
+ return str
+ -- elseif strip then
+ else
+ return lpegmatch(pattern or prepare(),str)
+ end
+end
+
+texcharacters.toutfpattern = toutfpattern
+texcharacters.toutf = textoutf
+
+-- print(texcharacters.toutf([[\~{Z}]],true))
+-- print(texcharacters.toutf([[\'\i]],true))
+-- print(texcharacters.toutf([[\'{\i}]],true))
+-- print(texcharacters.toutf([[\"{e}]],true))
+-- print(texcharacters.toutf([[\" {e}]],true))
+-- print(texcharacters.toutf([[{\"{e}}]],true))
+-- print(texcharacters.toutf([[{\" {e}}]],true))
+-- print(texcharacters.toutf([[{\l}]],true))
+-- print(texcharacters.toutf([[{\l }]],true))
+-- print(texcharacters.toutf([[\v{r}]],true))
+-- print(texcharacters.toutf([[fo{\"o}{\ss}ar]],true))
+-- print(texcharacters.toutf([[H{\'a}n Th\^e\llap{\raise 0.5ex\hbox{\'{\relax}}} Th{\'a}nh]],true))
+
+-- Next the ones without backslash
+
+local untex, pattern
+
+local function toutfpattern()
+ if not untex then
+ local hash = { }
+ for k, v in next, accentmapping do
+ for kk, vv in next, v do
+ hash[k..kk] = vv
+ end
+ end
+ for k, v in next, commandmapping do
+ hash[k] = v
+ end
+ for k, v in next, ligaturemapping do
+ hash[k] = v
+ end
+ untex = utfchartabletopattern(hash) / hash
+ end
+ return untex
+end
+
+local function prepare()
+ pattern = Cs((toutfpattern() + P(1))^0)
+ return pattern
+end
+
+local function textoutf(str)
+ return lpegmatch(pattern or prepare(),str)
+end
+
+texcharacters.strtoutfpattern = toutfpattern
+texcharacters.strtextoutf = textoutf
+
+local collapse = utffilters.collapse
+local combine = utffilters.combine
+
+if not interfaces then return end
+
+local implement = interfaces.implement
+
+local pattern
+
+local verbosemarks = characters.verbosemarks
+
+if verbosemarks then
+
+ mark(verbosemarks)
+
+else
+
+ verbosemarks = allocate {
+ ["stroke"] = utfchar(0x02F), ["slash"] = utfchar(0x02F),
+ ["middle dot"] = utfchar(0x0B7),
+
+ ["grave"] = utfchar(0x300),
+ ["acute"] = utfchar(0x301),
+ ["circumflex"] = utfchar(0x302),
+ ["tilde"] = utfchar(0x303),
+ ["macron"] = utfchar(0x304), ["line"] = utfchar(0x304),
+ ["overline"] = utfchar(0x305),
+ ["breve"] = utfchar(0x306),
+ ["dot"] = utfchar(0x307),
+ ["dieresis"] = utfchar(0x308), ["diaeresis"] = utfchar(0x308),
+ ["hook"] = utfchar(0x309),
+ ["ring"] = utfchar(0x30A),
+ ["double acute"] = utfchar(0x30B), ["hungarumlaut"] = utfchar(0x30B), -- tex speak
+ ["caron"] = utfchar(0x30C),
+ ["vertical line"] = utfchar(0x30D),
+ ["double vertical line"] = utfchar(0x30E),
+ ["double grave"] = utfchar(0x30F),
+ ["inverted breve"] = utfchar(0x311),
+ ["dot below"] = utfchar(0x323),
+ ["ring below"] = utfchar(0x325),
+ ["cedilla"] = utfchar(0x327), ["comma below"] = utfchar(0x327),
+ ["ogonek"] = utfchar(0x328),
+ ["caron below"] = utfchar(0x32C),
+ ["circumflex below"] = utfchar(0x32D),
+ ["tilde below"] = utfchar(0x330),
+ ["macron below"] = utfchar(0x331), ["line below"] = utfchar(0x331),
+
+ ["hook below"] = utfchar(0x1FA9D),
+ }
+
+ characters.verbosemarks = verbosemarks
+
+ if storage then
+ storage.register("characters/verbosemarks", verbosemarks, "characters.verbosemarks")
+ end
+
+end
+
+local function prepare()
+ pattern = Cs((utfchartabletopattern(verbosemarks) / verbosemarks + lpegpatterns.space/"" + lpegpatterns.utf8character)^0)
+ return pattern
+end
+
+local hash = table.setmetatableindex(function(t,k)
+ local f = ""
+ k = lpegmatch(pattern or prepare(),k) or k
+ local v = collapse(k) or k -- char specials
+-- print("collapse",k,v)
+ if k ~= v then
+ goto DONE
+ end
+ v = combine(k) or k -- with specials
+-- print("combine",k,v)
+ if k ~= v then
+ goto DONE
+ end
+ v = commandmapping[k] or k
+-- print("command",k,v)
+ if k ~= v then
+ f = "\\"
+ goto DONE
+ end
+ v = textoutf(k) or k
+-- print("utf",k,v)
+ if k ~= v then
+ f = "\\"
+ goto DONE
+ end
+ ::DONE::
+ report_defining("instead of old school '%s%s' you can input the utf sequence %s",f,k,v)
+ t[k] = v
+ return v
+end)
+
+implement {
+ name = "chr",
+ arguments = "argument",
+ public = true,
+ actions = function(str)
+ context(hash[str]) -- expandable
+ end
+}
+
+function texcharacters.safechar(n) -- was characters.safechar
+ local c = data[n]
+ if c and c.contextname then
+ return "\\" .. c.contextname
+ else
+ return utfchar(n)
+ end
+end
+
+if not context or not commands then
+ -- used in e.g. mtx-bibtex
+ return
+end
+
+-- all kind of initializations
+
+local tex = tex
+local texsetlccode = tex.setlccode
+local texsetsfcode = tex.setsfcode
+local texsetcatcode = tex.setcatcode
+
+local contextsprint = context.sprint
+local ctxcatcodes = catcodes.numbers.ctxcatcodes
+
+local texsetmacro = tokens.setters.macro
+local texsetchar = tokens.setters.char
+
+-- function texcharacters.defineaccents()
+-- local ctx_dodefineaccentcommand = context.dodefineaccent
+-- local ctx_dodefineaccent = context.dodefineaccent
+-- local ctx_dodefinecommand = context.dodefinecommand
+-- for accent, group in next, accentmapping do
+-- ctx_dodefineaccentcommand(accent)
+-- for character, mapping in next, group do
+-- ctx_dodefineaccent(accent,character,mapping)
+-- end
+-- end
+-- for command, mapping in next, commandmapping do
+-- ctx_dodefinecommand(command,mapping)
+-- end
+-- os.exit()
+-- end
+
+function texcharacters.defineaccents()
+ local ctx_dodefinecombine = context.dodefinecombine
+ local ctx_dodefinecommand = context.dodefinecommand
+ for verbose, mark in next, verbosemarks do
+ ctx_dodefinecombine((gsub(verbose," ","")),mark)
+ end
+ for command, mapping in next, commandmapping do
+ ctx_dodefinecommand(command,mapping)
+ end
+end
+
+implement { -- a waste of scanner but consistent
+ name = "defineaccents",
+ actions = texcharacters.defineaccents
+}
+
+--[[ldx--
+
Instead of using a file to define the named glyphs, we
+use the table. After all, we have this information available anyway.
+--ldx]]--
+
+local function to_number(s)
+ local n = tonumber(s)
+ if n then
+ return n
+ end
+ return tonumber(match(s,'^"(.*)$'),16) or 0
+end
+
+implement {
+ name = "utfchar",
+ actions = { to_number, utfchar, contextsprint },
+ arguments = "string"
+}
+
+implement {
+ name = "safechar",
+ actions = { to_number, texcharacters.safechar, contextsprint },
+ arguments = "string"
+}
+
+implement {
+ name = "uchar",
+ arguments = { "integer", "integer" },
+ actions = function(h,l)
+ context(utfchar(h*256+l))
+ end
+}
+
+tex.uprint = commands.utfchar
+
+-- in contect we don't use lc and uc codes (in fact in luatex we should have a hf code)
+-- so at some point we might drop this
+
+-- The following get set at the TeX end:
+
+local forbidden = tohash {
+ 0x000A0, -- zs nobreakspace
+ 0x000AD, -- cf softhyphen
+ -- 0x00600, -- cf arabicnumber
+ -- 0x00601, -- cf arabicsanah
+ -- 0x00602, -- cf arabicfootnotemarker
+ -- 0x00603, -- cf arabicsafha
+ -- 0x00604, -- cf arabicsamvat
+ -- 0x00605, -- cf arabicnumberabove
+ -- 0x0061C, -- cf arabiclettermark
+ -- 0x006DD, -- cf arabicendofayah
+ -- 0x008E2, -- cf arabicdisputedendofayah
+ 0x02000, -- zs enquad
+ 0x02001, -- zs emquad
+ 0x02002, -- zs enspace \kern .5\emwidth
+ 0x02003, -- zs emspace \hskip \emwidth
+ 0x02004, -- zs threeperemspace
+ 0x02005, -- zs fourperemspace
+ 0x02006, -- zs sixperemspace
+ 0x02007, -- zs figurespace
+ 0x02008, -- zs punctuationspace
+ 0x02009, -- zs breakablethinspace
+ 0x0200A, -- zs hairspace
+ 0x0200B, -- cf zerowidthspace
+ 0x0200C, -- cf zwnj
+ 0x0200D, -- cf zwj
+ 0x0202F, -- zs narrownobreakspace
+ 0x0205F, -- zs medspace \textormathspace +\medmuskip 2
+ -- 0x03000, -- zs ideographicspace
+ -- 0x0FEFF, -- cf zerowidthnobreakspace \penalty \plustenthousand \kern \zeropoint
+}
+
+local csletters = characters.csletters -- also a signal that we have initialized
+local activated = { }
+local sfmode = "unset" -- unset, traditional, normal
+local block_too = false
+
+directives.register("characters.blockstoo",function(v) block_too = v end)
+
+-- If this is something that is not documentwide and used a lot, then we
+-- need a more clever approach (trivial but not now).
+
+local function setuppersfcodes(v,n)
+ if sfstate ~= "unset" then
+ report_defining("setting uppercase sf codes to %a",n)
+ for u, chr in next, data do
+ if chr.category == "lu" then
+ texsetsfcode(u,n)
+ end
+ end
+ end
+ sfstate = v
+end
+
+directives.register("characters.spaceafteruppercase",function(v)
+ if v == "traditional" then
+ setuppersfcodes(v,999)
+ elseif v == "normal" then
+ setuppersfcodes(v,1000)
+ end
+end)
+
+if not csletters then
+
+ csletters = allocate()
+ characters.csletters = csletters
+
+ report_defining("setting up character related codes and commands")
+
+ if sfstate == "unset" then
+ sfstate = "traditional"
+ end
+
+ local traditional = sfstate == "traditional"
+
+ for u, chr in next, data do -- will move up
+ local contextname = chr.contextname
+ local category = chr.category
+ local isletter = is_letter[category]
+ if contextname then
+ if is_character[category] then
+ if chr.unicodeslot < 128 then
+ if isletter then
+ local c = utfchar(u)
+ csletters[c] = u
+ end
+ else
+ local c = utfchar(u)
+ if isletter and u >= 32 and u <= 65536 then
+ csletters[c] = u
+ end
+ end
+ if isletter then
+ local lc = chr.lccode
+ local uc = chr.uccode
+ if not lc then
+ chr.lccode = u
+ lc = u
+ elseif type(lc) == "table" then
+ lc = u
+ end
+ if not uc then
+ chr.uccode = u
+ uc = u
+ elseif type(uc) == "table" then
+ uc = u
+ end
+ texsetlccode(u,lc,uc)
+ if traditional and category == "lu" then
+ texsetsfcode(code,999)
+ end
+ end
+ elseif is_command[category] and not forbidden[u] then
+ -- skip
+ elseif is_mark[category] then
+ texsetlccode(u,u,u) -- for hyphenation
+ end
+ elseif isletter then
+ csletters[utfchar(u)] = u
+ local lc, uc = chr.lccode, chr.uccode
+ if not lc then
+ chr.lccode = u
+ lc = u
+ elseif type(lc) == "table" then
+ lc = u
+ end
+ if not uc then
+ chr.uccode = u
+ uc = u
+ elseif type(uc) == "table" then
+ uc = u
+ end
+ texsetlccode(u,lc,uc)
+ if traditional and category == "lu" then
+ texsetsfcode(code,999)
+ end
+ elseif is_mark[category] then
+ texsetlccode(u,u,u) -- for hyphenation
+ end
+ end
+
+ if blocks_too then
+ -- this slows down format generation by over 10 percent
+ for k, v in next, blocks do
+ if v.catcode == "letter" then
+ local first = v.first
+ local last = v.last
+ local gaps = v.gaps
+ if first and last then
+ for u=first,last do
+ csletters[utfchar(u)] = u
+ --
+ -- texsetlccode(u,u,u) -- self self
+ --
+ end
+ end
+ if gaps then
+ for i=1,#gaps do
+ local u = gaps[i]
+ csletters[utfchar(u)] = u
+ --
+ -- texsetlccode(u,u,u) -- self self
+ --
+ end
+ end
+ end
+ end
+ end
+
+ if storage then
+ storage.register("characters/csletters", csletters, "characters.csletters")
+ end
+
+ function characters.setcharacternames(ctt)
+ for u, chr in next, data do -- will move up
+ local contextname = chr.contextname
+ local category = chr.category
+ local isletter = is_letter[category]
+ if contextname then
+ if is_character[category] then
+ if chr.unicodeslot < 128 then
+ if isletter then
+ texsetmacro(contextname,utfchar(u),"immutable")
+ else
+ texsetchar(contextname,u,"immutable")
+ end
+ else
+ texsetmacro(contextname,utfchar(u),"immutable")
+ end
+ elseif is_command[category] and not forbidden[u] then
+ texsetmacro(contextname,utfchar(u),"immutable")
+ end
+ end
+ end
+ end
+
+else
+ mark(csletters)
+end
+
+lpegpatterns.csletter = utfchartabletopattern(csletters)
+
+-- The engine presets the letters to 11 (always).
+
+function characters.setlettercatcodes(cct)
+ if trace_defining then
+ report_defining("assigning letter catcodes to catcode table %a",cct)
+ end
+ local saved = tex.catcodetable
+ tex.catcodetable = cct
+ texsetcatcode(0x200C,11) -- non-joiner
+ texsetcatcode(0x200D,11) -- joiner
+ for c, u in next, csletters do
+ texsetcatcode(u,11)
+ end
+ tex.catcodetable = saved
+end
+
+function characters.setothercatcodes(cct)
+ if trace_defining then
+ report_defining("assigning other catcodes to catcode table %a",cct)
+ end
+ local saved = tex.catcodetable
+ tex.catcodetable = cct
+ for u=65,90 do
+ texsetcatcode(u,12)
+ end
+ for u=97,122 do
+ texsetcatcode(u,12)
+ end
+ tex.catcodetable = saved
+end
+
+function characters.setactivecatcodes(cct)
+ local saved = tex.catcodetable
+ tex.catcodetable = cct
+ for i=1,#activated do
+ local u = activated[i]
+ texsetcatcode(u,13)
+ if trace_defining then
+ report_defining("character %U (%s) is active in set %a",u,data[u].description,cct)
+ end
+ end
+ tex.catcodetable = saved
+end
+
+--[[ldx--
+
Setting the lccodes is also done in a loop over the data table.
+--ldx]]--
+
+implement {
+ name = "chardescription",
+ arguments = "integer",
+ actions = function(slot)
+ local d = data[slot]
+ if d then
+ context(d.description)
+ end
+ end,
+}
+
+if characters.setcharacternames then -- only in ini mode
+
+ implement { name = "setlettercatcodes", scope = "private", actions = characters.setlettercatcodes, arguments = "integer" }
+ implement { name = "setothercatcodes", scope = "private", actions = characters.setothercatcodes, arguments = "integer" }
+ implement { name = "setactivecatcodes", scope = "private", actions = characters.setactivecatcodes, arguments = "integer" }
+ implement { name = "setcharacternames", scope = "private", actions = characters.setcharacternames, arguments = "integer" }
+
+end
+
+-- experiment (some can move to char-ini.lua)
+
+local function overload(c,u,code,codes)
+ local c = tonumber(c)
+ if not c then
+ return
+ end
+ local u = utilities.parsers.settings_to_array(u)
+ local n = #u
+ if n == 0 then
+ return
+ end
+ local t = nil
+ if n == 1 then
+ t = tonumber(u[1])
+ else
+ t = { }
+ for i=1,n do
+ t[#t+1] = tonumber(u[i])
+ end
+ end
+ if t then
+ data[c][code] = t
+ characters[codes][c] = nil
+ end
+end
+
+implement {
+ name = "overloaduppercase",
+ arguments = "2 strings",
+ actions = function(c,u)
+ overload(c,u,"uccode","uccodes")
+ end
+}
+
+implement {
+ name = "overloadlowercase",
+ arguments = "2 strings",
+ actions = function(c,u)
+ overload(c,u,"lccode","lccodes")
+ end
+}
+
+-- Just for fun we support keywords:
+--
+-- \startTEXpage[offset=10pt]
+-- abg"
+-- \sl \showboxes
+-- \accent `" h%
+-- \accent `" x%
+-- \accent yoffset .2ex `" x
+-- \accent yoffset 1.1ex `x x%
+-- \stopTEXpage
+--
+-- We could do this:
+--
+-- \startTEXpage[offset=10pt]
+-- abg"
+-- \sl \showboxes
+-- \withaccent `" h%
+-- \withaccent `" x%
+-- \withaccent yoffset .2ex `" x
+-- \withaccent yoffset 1.1ex accent `x base `x%
+-- \stopTEXpage
+--
+-- But only when users demand it:
+--
+-- do
+--
+-- local new_glyph = nodes.pool.glyph
+--
+-- local scankeyword = tokens.scanners.keyword
+-- local scaninteger = tokens.scanners.integer
+-- local scandimension = tokens.scanners.dimension
+-- local scantoken = tokens.scanners.token
+--
+-- implement {
+-- name = "withaccent",
+-- public = true,
+-- protected = true,
+-- actions = function()
+-- local xoffset = 0
+-- local yoffset = 0
+-- local accent = false
+-- local base = false
+-- local zwj = 0x200D
+-- while true do
+-- if scankeyword("xoffset") then
+-- xoffset = scandimension()
+-- elseif scankeyword("yoffset") then
+-- yoffset = scandimension()
+-- elseif scankeyword("accent") then
+-- accent = scaninteger()
+-- elseif scankeyword("base") then
+-- base = scaninteger()
+-- else
+-- break
+-- end
+-- end
+-- if not accent then
+-- accent = scaninteger()
+-- end
+-- if not base then
+-- local nxttok = scantoken()
+-- base = nxttok.cmdname == "char_number" and scaninteger() or nxttok.index
+-- end
+-- if base and accent and base > 0 and accent > 0 then
+-- base = new_glyph(true,base)
+-- zwj = new_glyph(true,zwj)
+-- accent = new_glyph(true,accent)
+-- local slant = fonts.hashes.parameters[true].slant / 65536 -- a la tex
+-- local xheight = fonts.hashes.parameters[true].xheight -- hm, compensated for glyphscale?
+-- accent.xoffset = xoffset - .5*(base.width -accent.width) + .5*(base.height-accent.height) * slant
+-- accent.yoffset = yoffset - (xheight - accent.height)
+-- accent.left = accent.width
+-- accent.options = accent.options | 0x40 | 0x80
+-- context.dontleavehmode()
+-- context(base)
+-- context(zwj)
+-- context(accent)
+-- end
+-- end,
+-- }
+--
+-- end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/char-utf.mkxl b/Master/texmf-dist/tex/context/base/mkxl/char-utf.mkxl
new file mode 100644
index 00000000000..a7cbab34522
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/char-utf.mkxl
@@ -0,0 +1,44 @@
+%D \module
+%D [ file=char-utf,
+%D version=2006.12.05,
+%D title=\CONTEXT\ Character Support,
+%D subtitle=Unicode UTF,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Character Support / Unicode UTF}
+
+%D After a bit of experimenting we reached a clean state where \UTF\ 8, 16 and 32
+%D were supported as well as collapsing (combining sequences). Writing the code was
+%D a relaxed experience, not in the last place because it was accompanied by
+%D listening to those nice Vienna Teng cd's (who decided that making music was more
+%D fun than programming, but then, she may not know \TEX\ and \LUA).
+
+\unprotect
+
+\registerctxluafile{char-def}{}
+\registerctxluafile{char-ini}{}
+\registerctxluafile{char-utf}{}
+\registerctxluafile{char-cjk}{}
+
+%D We enable collapsing (combining characters) by default, but since the source
+%D files are rather simple, we postpone the initialization till runtime.
+
+% \appendtoks
+% \clf_enableutf % not needed when we create a format so we do it now
+% \to \everyjob
+
+%D The next one influences input parsing.
+%D
+%D \starttyping
+%D \definecomposedutf 318 108 126 % lcaron
+%D \stoptyping
+
+\permanent\protected\def\definecomposedutf#1 #2 #3 {\clf_addgrapheme{#1}{#2}{#3}}
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/chem-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/chem-ini.mkxl
new file mode 100644
index 00000000000..b88d4d8346e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/chem-ini.mkxl
@@ -0,0 +1,53 @@
+%D \module
+%D [ file=chem-ini,
+%D version=2008.03.06,
+%D subtitle=Chemistry,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo: \mathscriptsmode
+
+\writestatus{loading}{ConTeXt Chemistry Macros / Initialization} % might become Inline
+
+\registerctxluafile{chem-ini}{}
+
+\unprotect
+
+% todo: use \mathscriptsmode if needed
+
+%D \macros
+%D {molecule}
+%D
+%D Quick and dirty:
+%D
+%D \starttyping
+%D \permanent\protected\def\molecule#1%
+%D {$\enablesupersub\tf#1$}
+%D \stoptyping
+%D
+%D Using \LUA:
+%D
+%D \startbuffer
+%D \molecule{H_2SO_4^-2}
+%D \molecule{H_2SO_4^{-2}}
+%D \molecule{H_2SO_4^{-2{x}}}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\permanent\protected\def\molecule#1% todo: can become a public implementor
+ {\clf_molecule{#1}}
+
+%D For old times sake:
+
+\permanent\protected\def\chem#1#2#3%
+ {\dontleavehmode\begingroup#1\lohi{#2}{#3}\endgroup}
+
+\protect \endinput
+
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/chem-str.mkxl b/Master/texmf-dist/tex/context/base/mkxl/chem-str.mkxl
new file mode 100644
index 00000000000..6c591225e33
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/chem-str.mkxl
@@ -0,0 +1,751 @@
+%D \module
+%D [ file=chem-ini,
+%D version=2009.05.13,
+%D subtitle=Chemistry,
+%D author=Hans Hagen \& Alan Braslau,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The original \PPCHTEX\ code was written in pure \TEX\, although later we made
+%D the move from \PICTEX\ to \METAPOST\. The current implementation is a mix between
+%D \TEX\, \LUA\ and \METAPOST. Although the first objective is to get a compatible
+%D but better implementation, later versions might provide more,
+
+%D NOT YET LMTX'd
+
+\writestatus{loading}{ConTeXt Chemistry Macros / Structure}
+
+\registerctxluafile{chem-str}{}
+
+% We have a slightly different interface. This is unchanged:
+%
+% \startchemical[axis=on]
+% \chemical[SIX,ROT2,B,R6,SUB1,FIVE,ROT1,B][1]
+% \stopchemical
+%
+% Here we use chemicalformula instead, so no longer a mix:
+%
+% \startchemicalformula
+% \chemical{2H_2}{top}{bottom}
+% \chemical{PLUS}{top}{bottom}
+% \chemical{O_2}{top}{bottom}
+% \chemical{GIVES}{top}{bottom}
+% \chemical{2H_2O}{top}{bottom}
+% \stopchemicalformula
+%
+% \startchemicalformula
+% \chemical{2H_2}
+% \chemical{PLUS}
+% \chemical{O_2}
+% \chemical{GIVES}
+% \chemical{2H_2O}
+% \stopchemicalformula
+%
+% The inline variant has only one argument:
+%
+% \chemical{2H_2,PLUS,O_2,GIVES,2H_2O}
+
+\unprotect
+
+\installcorenamespace{chemical}
+\installcorenamespace{chemicalsymbol}
+\installcorenamespace{chemicalframed}
+\installcorenamespace{chemicalsize}
+
+% \installsimplecommandhandler \??chemical {chemical} \??chemical % no \define...
+\installcommandhandler \??chemical {chemical} \??chemical % no \define...
+
+\aliased\let\setupchemicals \setupchemical
+\aliased\let\definechemicals\definechemical
+
+%D We use a dedicated framed macro instead of inheriting one. This is both
+%D a historical and practical reason (like shared keys with different meaning
+%D that could clash, e.g.\ align).
+
+\defineMPinstance % not really needed as we set in lua
+ [chemistry]
+ [\s!format=metafun,
+ %\s!extensions=\v!yes, % Should we add extensions and initializations?
+ %\s!initializations=\v!yes, % Would this give EmWidth, etc.?
+ \c!method=\s!double]
+
+\startMPdefinitions{chemistry}
+ loadmodule "chem" ;
+\stopMPdefinitions
+
+\defineframed
+ [\??chemicalframed]
+ [\c!align=\v!normal,
+ \c!strut=\v!no]
+
+\mutable\let\currentdefinedchemical\empty
+
+\permanent\protected\def\setupchemicalframed
+ {\setupframed[\??chemicalframed]}
+
+\permanent\protected\tolerant\overloaded\def\definechemical[#1]#:#2% is global (so we don't use the commandhandler)
+ {\startnointerference
+ \edef\currentdefinedchemical{#1}%
+ \enforced\let\chemical\chem_chemical_nested
+ \clf_undefinechemical{#1}%
+ #2% flush
+ \stopnointerference}
+
+\permanent\tolerant\protected\def\chem_chemical_nested[#1]#*[#2]%
+ {\clf_definechemical{\currentdefinedchemical}{#1}{\detokenize{#2}}}
+
+% chemical symbols
+
+\permanent\tolerant\protected\def\definechemicalsymbol[#1]#*[#2]%
+ {\ifarguments\else\defcsname\??chemicalsymbol#1\endcsname{#2}\fi}
+
+\permanent\protected\def\chemicalsymbol[#1]%
+ {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname#1\else\s!unknown\fi\endcsname}
+
+\definechemicalsymbol[\s!unknown][] % \char"FFFD empty
+
+% size (small medium big)
+
+% \edef\chemicaltoplocation{t}
+% \edef\chemicalbotlocation{b}
+
+\permanent\protected\def\chemicaltext#1%
+ {\mathematics
+ {\usechemicalstyleandcolor\c!style\c!color
+ \strut
+ \ifcase\currentxfontsize\or\scriptstyle\or\scriptscriptstyle\fi
+ #1}}
+
+\setvalue{\??chemicalsize\v!small }{\txx}
+\setvalue{\??chemicalsize\v!medium}{\tx}
+\setvalue{\??chemicalsize\v!big }{}
+
+\newtoks \everychemical
+\newtoks \everystructurechemical
+%newconditional\indisplaychemical
+
+\newtoks \t_chem_every_box
+\newbox \b_chem_result
+\newconditional\c_chem_some_text
+\newdimen \d_chem_width
+\newdimen \d_chem_height
+\newdimen \d_chem_depth
+
+\permanent\tolerant\protected\def\startchemical[#1]#*[#2]%
+ {\ifmmode\vcenter\else\vbox\fi % vpack ?
+ \bgroup
+ \synchronizestrut{\chemicalparameter\c!strut}%
+ \dontcomplain
+ %\settrue\indisplaychemical
+ \forgetall
+ \ifparameter#2\or
+ \ifhastok={#1}%
+ \setupcurrentchemical[#1]% same as \currentchemical
+ \else
+ \edef\currentchemical{#1}%
+ \setupcurrentchemical[#2]%
+ \fi
+ \orelse\ifparameter#1\or
+ \ifhastok={#1}%
+ \setupcurrentchemical[#1]% same as \currentchemical
+ \else
+ \edef\currentchemical{#1}%
+ \fi
+ \fi
+ \the\everystructurechemical
+ \setbox\b_chem_result\hpack\bgroup
+ \clf_startchemical
+ width {\chemicalparameter\c!width}%
+ height {\chemicalparameter\c!height}%
+ left {\chemicalparameter\c!left}%
+ right {\chemicalparameter\c!right}%
+ top {\chemicalparameter\c!top}%
+ bottom {\chemicalparameter\c!bottom}%
+ scale {\chemicalparameter\c!scale}%
+ rotation {\chemicalparameter\c!rotation}%
+ symalign {\chemicalparameter\c!symalign}%
+ axis {\chemicalparameter\c!axis}% was \MPcolor{...}
+ framecolor {\chemicalparameter\c!framecolor}%
+ rulethickness {\number\dimexpr\chemicalparameter\c!rulethickness}%
+ offset {\number\dimexpr\chemicalparameter\c!offset}%
+ unit {\number\dimexpr\chemicalparameter\c!unit}%
+ factor {\number\chemicalparameter\c!factor}%
+ \relax
+ \startnointerference}
+
+\permanent\protected\def\stopchemical
+ {\stopnointerference
+ \clf_stopchemical
+ \egroup
+ \d_chem_width \wd\b_chem_result
+ \d_chem_height\ht\b_chem_result
+ \d_chem_depth \dp\b_chem_result
+ \the\t_chem_every_box
+ \doifelsenothing{\chemicalparameter\c!frame}\chem_framed_nop\chem_framed_yes
+ \egroup}
+
+\protected\def\chem_framed_yes
+ {\localframedwithsettings
+ [\??chemicalframed]%
+ [\c!frame=\chemicalparameter\c!frame,
+ \c!rulethickness=\chemicalparameter\c!rulethickness,
+ \c!framecolor=\chemicalparameter\c!framecolor]%
+ {\vpack{\box\b_chem_result\vss}}} % remove depth
+
+\protected\def\chem_framed_nop
+ {\directlocalframed
+ [\??chemicalframed]%
+ {\vpack{\box\b_chem_result\vss}}} % remove depth
+
+\aliased\let\startstructurechemical\startchemical
+\aliased\let\stopstructurechemical \stopchemical
+
+\appendtoks
+ \enforced\let\chemical\structurechemical
+\to\everystructurechemical
+
+\permanent\tolerant\protected\def\structurechemical[#1]#*[#2]#*[#3]%
+ {\ifparameter#3\or
+ \expandafter\strc_chem_indeed_three
+ \else
+ \expandafter\strc_chem_indeed_two
+ \fi[#1][#2][#3]}
+
+\def\strc_chem_indeed_three[#1][#2][#3]%
+ {\writestatus\m!chemicals{hyperlinked chemicals not yet supported}% todo reference, for the moment ignored
+ \clf_chemicalcomponent
+ {#2}%
+ {\detokenize{#3}}%
+ {\the\dimexpr\chemicalparameter\c!rulethickness}% todo: scaled points
+ {\chemicalparameter\c!rulecolor}%
+ \relax
+ \ignorespaces}
+
+\def\strc_chem_indeed_two[#1][#2]% why no [#3] here
+ {\clf_chemicalcomponent
+ {#1}%
+ {\detokenize{#2}}%
+ {\the\dimexpr\chemicalparameter\c!rulethickness}% todo: scaled points
+ {\chemicalparameter\c!rulecolor}%
+ \relax
+ \ignorespaces}
+
+\appendtoks
+ \setbox\b_chem_result\hpack{\raise\MPlly\box\b_chem_result}%
+ \d_chem_width \wd\b_chem_result
+ \d_chem_height\ht\b_chem_result
+ \d_chem_depth \dp\b_chem_result
+\to \t_chem_every_box
+
+% kind of compatible, but text sizes instead of math sizes (i.e. tx is larger than scriptsize)
+
+\appendtoks
+ \edef\m_bodyfont{\chemicalparameter\c!bodyfont}%
+ \ifempty\m_bodyfont
+ \switchtobodyfont[\m_bodyfont]%
+ \fi
+ \begincsname\??chemicalsize\chemicalparameter\c!size\endcsname
+% \to \everystructurechemical
+\to \everychemical
+
+\permanent\protected\def\chemicaltoptext#1{\global\settrue\c_chem_some_text\gdef\m_chem_top_text{#1}\ignorespaces}
+\permanent\protected\def\chemicalbottext#1{\global\settrue\c_chem_some_text\gdef\m_chem_bot_text{#1}\ignorespaces}
+\permanent\protected\def\chemicalmidtext#1{\global\settrue\c_chem_some_text\gdef\m_chem_mid_text{#1}\ignorespaces}
+
+\mutable\let\toptext\empty
+\mutable\let\bottext\empty
+\mutable\let\midtext\empty
+
+\appendtoks
+ \let\toptext\chemicaltoptext \glet\m_chem_top_text\empty
+ \let\bottext\chemicalbottext \glet\m_chem_bot_text\empty
+ \let\midtext\chemicalmidtext \glet\m_chem_mid_text\empty
+ \global\setfalse\c_chem_some_text
+\to \everystructurechemical
+
+\def\chem_add_texts
+ {\setbox2\hpack to \d_chem_width{\strut\hss\hbox{\strut\m_chem_mid_text}\hss}%
+ \setbox4\hpack to \d_chem_width{\strut\hss\hbox{\strut\m_chem_top_text}\hss}%
+ \setbox6\hpack to \d_chem_width{\strut\hss\hbox{\strut\m_chem_bot_text}\hss}%
+ \setbox\b_chem_result\hpack \bgroup
+ \box\b_chem_result
+ \hskip-\d_chem_width
+ \raise\d_chem_height\hpack{\lower\ht4\box4}%
+ \hskip-\d_chem_width
+ \lower.5\dimexpr\ht2-\dp2\relax\box2%
+ \hskip-\d_chem_width
+ \lower\d_chem_depth \hpack{\raise\dp6\box6}%
+ \hss
+ \egroup} % text on top of chemicals
+
+\appendtoks
+ \ifconditional\c_chem_some_text
+ \chem_add_texts
+ \d_chem_width \wd\b_chem_result
+ \d_chem_height\ht\b_chem_result
+ \d_chem_depth \dp\b_chem_result
+ \fi
+\to \t_chem_every_box
+
+% todo: enspace or emspace
+
+\definechemicalsymbol[space] [\enspace\quad\enspace]
+\definechemicalsymbol[plus] [\enspace+\enspace]
+\definechemicalsymbol[minus] [\enspace-\enspace]
+\definechemicalsymbol[gives] [\chem_arrow_construct\xrightarrow]
+\definechemicalsymbol[equilibrium] [\chem_arrow_construct\xrightoverleftarrow]
+\definechemicalsymbol[mesomeric] [\chem_arrow_construct\xleftrightarrow]
+\definechemicalsymbol[opencomplex] [\mathematics{\Bigg[}] % not yet ok
+\definechemicalsymbol[closecomplex][\mathematics{\Bigg]}] % not yet ok
+
+\definechemicalsymbol[SPACE] [{\chemicalsymbol[space]}]
+\definechemicalsymbol[PLUS] [{\chemicalsymbol[plus]}]
+\definechemicalsymbol[MINUS] [{\chemicalsymbol[minus]}]
+\definechemicalsymbol[GIVES] [{\chemicalsymbol[gives]}]
+\definechemicalsymbol[EQUILIBRIUM] [{\chemicalsymbol[equilibrium]}]
+\definechemicalsymbol[MESOMERIC] [{\chemicalsymbol[mesomeric]}]
+\definechemicalsymbol[OPENCOMPLEX] [{\chemicalsymbol[opencomplex]}]
+\definechemicalsymbol[CLOSECOMPLEX][{\chemicalsymbol[closecomplex]}]
+
+\def\chem_arrow_construct#1#2#3%
+ {\enspace
+ \mathematics{#1%
+ {\strut\hbox \s!spread 2\emwidth{\hss\clf_inlinechemical{#3}\hss}}% {\strut\hbox \s!spread 2em{\hss#3\hss}}}%
+ {\strut\hbox \s!spread 2\emwidth{\hss\clf_inlinechemical{#2}\hss}}}% {\strut\hbox \s!spread 2em{\hss#2\hss}}%
+ \enspace}
+
+% special macros (probably needs some more work)
+
+\let\chem_box_normal_yes\hbox
+\let\chem_box_visual_yes\hbox
+\let\chem_box_visual_nop\relax
+
+\installtextracker
+ {chemistry.boxes}
+ {\let\chem_box_visual_yes\ruledhbox \let\chem_box_visual_nop\ruledhbox}
+ {\let\chem_box_visual_yes\hbox \let\chem_box_visual_nop\relax }
+
+\def\chem_top_construct#1#2#3#4%
+ {\hpack\bgroup
+ \setstrut
+ \setbox\scratchboxone\chem_box_visual_yes{\strut#3}%
+ \setbox\scratchboxtwo\chem_box_visual_yes{\strut\molecule{#4}}%
+ \setbox\scratchboxone\chem_box_normal_yes{\raise\dimexpr\dp\scratchboxone+\ht\scratchboxtwo\relax\hbox to \wd\scratchboxtwo{#1\box\scratchboxone#2}}%
+ \smashbox\scratchboxone
+ \box\scratchboxone
+ \box\scratchboxtwo
+ \egroup}
+
+\def\chem_bottom_construct#1#2#3#4%
+ {\hpack\bgroup
+ \setstrut
+ \setbox\scratchboxone\chem_box_visual_yes{\strut#3}%
+ \setbox\scratchboxtwo\chem_box_visual_yes{\strut\molecule{#4}}%
+ \setbox\scratchboxone\chem_box_normal_yes{\lower\dimexpr\dp\scratchboxtwo+\ht\scratchboxone\relax\hbox to \wd\scratchboxtwo{#1\box\scratchboxone#2}}%
+ \smashbox\scratchboxone
+ \box\scratchboxone
+ \box\scratchboxtwo
+ \egroup}
+
+\permanent\protected\def\chemicalleft#1#2% redundant boxes thanks to visual
+ {\hbox\bgroup % hpack ?
+ \setstrut
+ \llap{\chem_box_visual_nop{\strut#1}}%
+ \chem_box_visual_nop{\strut#2}%
+ \egroup}
+
+\permanent\protected\def\chemicalright#1#2% redundant boxes thanks to visual
+ {\hbox\bgroup % hpack ?
+ \setstrut
+ \chem_box_visual_yes{\strut#2}%
+ \rlap{\chem_box_visual_nop{\strut#1}}%
+ \egroup}
+
+\permanent\protected\def\chemicaltop {\chem_top_construct \hss \hss }
+\permanent\protected\def\chemicallefttop {\chem_top_construct \relax\hss }
+\permanent\protected\def\chemicalrighttop {\chem_top_construct \hss \relax}
+\permanent\protected\def\chemicalbottom {\chem_bottom_construct\hss \hss }
+\permanent\protected\def\chemicalleftbottom {\chem_bottom_construct\relax\hss }
+\permanent\protected\def\chemicalrightbottom{\chem_bottom_construct\hss \relax}
+
+\permanent\protected\def\chemicaltopleft #1{\chemicalleft {\chemicalrighttop {#1}{}}}
+\permanent\protected\def\chemicalbottomleft #1{\chemicalleft {\chemicalrightbottom{#1}{}}}
+\permanent\protected\def\chemicaltopright #1{\chemicalright{\chemicallefttop {#1}{}}}
+\permanent\protected\def\chemicalbottomright#1{\chemicalright{\chemicalleftbottom {#1}{}}}
+
+% \protected\def\chemicalcentered #1{\hbox to \fontcharwd\font`C{\setstrut\strut\hss#1\hss}}
+% \protected\def\chemicalleftcentered #1{\hbox to \fontcharwd\font`C{\setstrut\strut #1\hss}}
+% \protected\def\chemicalrightcentered#1{\hbox to \fontcharwd\font`C{\setstrut\strut\hss#1}}
+
+% \let\chemicalsmashedmiddle\chemicalcentered
+% \let\chemicalsmashedleft \chemicalleftcentered
+% \let\chemicalsmashedright \chemicalrightcentered
+
+\permanent\protected\def\chemicalalignedtext
+ {\ifmmode
+ \expandafter\chem_aligned_text_math
+ \else
+ \expandafter\chem_aligned_text_text
+ \fi}
+
+\aliased\let\chemicaltighttext\relax % maybe smaller strut
+
+\def\chem_aligned_text_text#1#2#3%
+ {\dontleavehmode
+ \begingroup
+ \usechemicalstyleandcolor\c!style\c!color
+ \chem_box_visual_yes to \fontcharwd\font`C\bgroup
+ \setstrut\strut
+ #1\molecule{#3}#2%
+ \egroup
+ \endgroup}
+
+\def\chem_aligned_text_math#1#2#3%
+ {\dontleavehmode
+ \begingroup
+ \scratchcounter\normalmathstyle
+ \usechemicalstyleandcolor\c!style\c!color
+ \chem_box_visual_yes to \fontcharwd\font`C\bgroup
+ \setstrut\strut
+ #1\mathematics{\tf\triggermathstyle\scratchcounter\molecule{#3}}#2%
+ \egroup
+ \endgroup}
+
+\permanent\protected\def\chemicalcentered {\chemicalalignedtext\hss \hss }
+\permanent\protected\def\chemicalleftcentered {\chemicalalignedtext\relax\hss }
+\permanent\protected\def\chemicalrightcentered{\chemicalalignedtext\hss \relax}
+
+\aliased\let\chemicalsmashedmiddle\chemicalcentered
+\aliased\let\chemicalsmashedleft \chemicalleftcentered
+\aliased\let\chemicalsmashedright \chemicalrightcentered
+
+\permanent\protected\def\chemicaloxidation#1#2#3%
+ {\chemicaltop{\txx\ifcase#2\relax0\else#1\convertnumber{I}{#2}\fi}{#3}}
+
+\permanent\protected\def\chemicaloxidationplus {\dotriplegroupempty\chemicaloxidation{\textplus }} % {} needed!
+\permanent\protected\def\chemicaloxidationminus{\dotriplegroupempty\chemicaloxidation{\textminus}} % {} needed!
+\permanent\protected\def\chemicalforeveropen {\dotriplegroupempty\chemicalleft {$\big[$}} % {} needed!
+\permanent\protected\def\chemicalforeverclose {\dotriplegroupempty\chemicalright {$\big]$}} % {} needed!
+\permanent\protected\def\chemicaloxidationone {\chemicaloxidation\relax1}
+\permanent\protected\def\chemicaloxidationtwo {\chemicaloxidation\relax2}
+\permanent\protected\def\chemicaloxidationthree{\chemicaloxidation\relax3}
+\permanent\protected\def\chemicaloxidationfour {\chemicaloxidation\relax4}
+\permanent\protected\def\chemicaloxidationfive {\chemicaloxidation\relax5}
+\permanent\protected\def\chemicaloxidationsix {\chemicaloxidation\relax6}
+\permanent\protected\def\chemicaloxidationseven{\chemicaloxidation\relax7}
+
+\permanent\protected\def\chemicalbar
+ {\hpack \s!spread .5\emwidth \bgroup
+ \hss
+ \vrule \s!height .9\strutht \s!depth .65\strutdp \s!width .1\exheight
+ \hss
+ \egroup}
+
+\permanent\let\X\relax
+\permanent\let\T\relax
+\permanent\let\B\relax
+\permanent\let\L\relax
+\permanent\let\M\relax
+\permanent\let\R\relax
+
+\appendtoks
+ \enforced\let |\chemicalbar % \SR{N|NH}
+ \enforced\let \+\chemicaloxidationplus
+ \enforced\let \-\chemicaloxidationminus
+ \enforced\let \[\chemicalforeveropen
+ \enforced\let \]\chemicalforeverclose
+ \enforced\let \1\chemicaloxidationone
+ \enforced\let \2\chemicaloxidationtwo
+ \enforced\let \3\chemicaloxidationthree
+ \enforced\let \4\chemicaloxidationfour
+ \enforced\let \5\chemicaloxidationfive
+ \enforced\let \6\chemicaloxidationsix
+ \enforced\let \7\chemicaloxidationseven
+ \enforced\let \X\chemicaltighttext
+ \enforced\let \T\chemicaltop
+ \enforced\let \B\chemicalbottom
+ \enforced\let \L\chemicalleft
+ \enforced\let\LC\chemicalleftcentered
+ \enforced\let \R\chemicalright
+ \enforced\let\RC\chemicalrightcentered
+ \enforced\let\TL\chemicaltopleft
+ \enforced\let\BL\chemicalbottomleft
+ \enforced\let\TR\chemicaltopright
+ \enforced\let\BR\chemicalbottomright
+ \enforced\let\LT\chemicallefttop
+ \enforced\let\LB\chemicalleftbottom
+ \enforced\let\RT\chemicalrighttop
+ \enforced\let\RB\chemicalrightbottom
+ \enforced\let\SL\chemicalsmashedleft
+ \enforced\let\SM\chemicalsmashedmiddle
+ \enforced\let\SR\chemicalsmashedright
+\to \everychemical
+
+% Should these also be defined in lower case, so as to be case independent?
+
+\appendtoks
+ \the\everychemical
+\to \everystructurechemical
+
+% inline
+
+\permanent\protected\def\chemical
+ {\ifinformula
+ \expandafter\indisplaychemical
+ \else
+ \expandafter\inlinechemical
+ \fi}
+
+\permanent\protected\def\indisplaychemical
+ {\mathstylecommand\displaychemical\inlinechemical\inlinechemical}
+
+% \permanent\protected\def\inlinechemical#1%
+% {\dontleavehmode
+% \begingroup
+% \scratchcounter\normalmathstyle
+% \usechemicalstyleandcolor\c!style\c!color
+% \hbox{\mathematics{\tf\triggermathstyle\scratchcounter\clf_inlinechemical{#1}}}%
+% \endgroup}
+
+\permanent\tolerant\protected\def\displaychemical#=#=#=%
+ {\the\everychemical
+ \everychemical\emptytoks
+ \quad
+ \vcenter\bgroup
+ \usechemicalstyleandcolor\c!style\c!color
+ \ifparameter#3\or
+ \ifparameter#2\or
+ \halign{\aligntab\hss\alignmark\alignmark\hss\cr#2\cr\molecule{#1}\cr#3\cr}%
+ \else
+ \halign{\aligntab\hss\alignmark\alignmark\hss \cr\molecule{#1}\cr#2\cr}%
+ \fi
+ \else
+ \hbox{\molecule{#1}}%
+ \fi
+ \egroup
+ \quad}
+
+\permanent\protected\def\inlinechemical#1%
+ {\dontleavehmode
+ \hbox{\usechemicalstyleandcolor\c!style\c!color\clf_inlinechemical{#1}}}
+
+\permanent\protected\def\chemicalbondrule
+ {\hpack{\vrule\s!height.75\exheight\s!depth-\dimexpr.75\exheight-\linewidth\relax\s!width\emwidth\relax}}
+
+\definechemicalsymbol[i:space] [\enspace\quad\enspace]
+\definechemicalsymbol[i:plus] [\enspace\mathematics{+}\enspace]
+\definechemicalsymbol[i:minus] [\enspace\mathematics{-}\enspace]
+\definechemicalsymbol[i:equals] [\enspace\mathematics{=}\enspace]
+\definechemicalsymbol[i:gives] [\enspace\mathematics{\xrightarrow{}{}}\enspace]
+\definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightoverleftarrow{}{}}\enspace]
+\definechemicalsymbol[i:mesomeric] [\enspace\mathematics{\xleftrightarrow{}{}}\enspace]
+\definechemicalsymbol[i:single] [\chemicalbondrule]
+\definechemicalsymbol[i:double] [\hpack{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}]
+\definechemicalsymbol[i:triple] [\hpack{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}]
+
+\permanent\protected\def\chemicalsinglebond {\chemicalsymbol[i:single]}
+\permanent\protected\def\chemicaldoublebond {\chemicalsymbol[i:double]}
+\permanent\protected\def\chemicaltriplebond {\chemicalsymbol[i:triple]}
+\permanent\protected\def\chemicalgives {\chemicalsymbol[i:gives]}
+\permanent\protected\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]}
+\permanent\protected\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]}
+\permanent\protected\def\chemicalplus {\chemicalsymbol[i:plus]}
+\permanent\protected\def\chemicalminus {\chemicalsymbol[i:minus]}
+\permanent\protected\def\chemicalequals {\chemicalsymbol[i:equals]}
+\permanent\protected\def\chemicalspace {\chemicalsymbol[i:space]}
+\permanent\protected\def\chemicalinline #1{#1}
+
+% display
+
+\newconditional\c_chem_has_top
+\newconditional\c_chem_has_bot
+
+\newtoks\t_chem_top
+\newtoks\t_chem_mid
+\newtoks\t_chem_bot
+
+\newif\ifinchemicalformula
+
+\permanent\protected\def\startchemicalformula
+ {\mathortext\vcenter\vbox\bgroup
+ \forgetall
+ \inchemicalformulatrue
+ \the\everychemical
+ \everychemical\emptytoks
+ \t_chem_top\emptytoks % not needed
+ \t_chem_mid\emptytoks % not needed
+ \t_chem_bot\emptytoks % not needed
+ \enforced\let\chemical\formulachemical
+ \setfalse\c_chem_has_top
+ \setfalse\c_chem_has_bot}
+
+\permanent\protected\def\stopchemicalformula
+ {\tabskip\emwidth\relax
+ \nointerlineskip
+ \ifconditional\c_chem_has_top
+ \ifconditional\c_chem_has_bot
+ \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}%
+ \else
+ \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}%
+ \fi
+ \else
+ \ifconditional\c_chem_has_bot
+ \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}%
+ \else
+ \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr}%
+ \fi
+ \fi
+ \egroup}
+
+% for the moment we have a special set
+
+\definechemicalsymbol[d:space] [\enspace\quad\enspace]
+\definechemicalsymbol[d:plus] [\enspace+\enspace]
+\definechemicalsymbol[d:minus] [\enspace-\enspace]
+\definechemicalsymbol[d:equals] [\enspace=\enspace]
+\definechemicalsymbol[d:gives] [\rightarrowfill] % \chem_arrow_construct\xrightarrow
+\definechemicalsymbol[d:equilibrium] [\rightoverleftarrowfill] % \chem_arrow_construct\xrightoverleftarrow
+\definechemicalsymbol[d:mesomeric] [\leftarrowfill] % \chem_arrow_construct\xleftrightarrow
+\definechemicalsymbol[d:single] [\chemicalbondrule]
+\definechemicalsymbol[d:double] [\hpack{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}]
+\definechemicalsymbol[d:triple] [\hpack{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}]
+\definechemicalsymbol[d:opencomplex] [\mathematics{\Bigg[}] % not yet ok
+\definechemicalsymbol[d:closecomplex][\mathematics{\Bigg]}] % not yet ok
+
+\definechemicalsymbol[d:SPACE] [{\chemicalsymbol[d:space]}]
+\definechemicalsymbol[d:PLUS] [{\chemicalsymbol[d:plus]}]
+\definechemicalsymbol[d:MINUS] [{\chemicalsymbol[d:minus]}]
+\definechemicalsymbol[d:EQUALS] [{\chemicalsymbol[d:equals]}]
+\definechemicalsymbol[d:GIVES] [{\chemicalsymbol[d:gives]}]
+\definechemicalsymbol[d:EQUILIBRIUM] [{\chemicalsymbol[d:equilibrium]}]
+\definechemicalsymbol[d:MESOMERIC] [{\chemicalsymbol[d:mesomeric]}]
+\definechemicalsymbol[d:SINGLE] [{\chemicalsymbol[d:single]}]
+\definechemicalsymbol[d:DOUBLE] [{\chemicalsymbol[d:double]}]
+\definechemicalsymbol[d:TRIPLE] [{\chemicalsymbol[d:triple]}]
+\definechemicalsymbol[d:OPENCOMPLEX] [{\chemicalsymbol[d:opencomplex]}]
+\definechemicalsymbol[d:CLOSECOMPLEX][{\chemicalsymbol[d:closecomplex]}]
+
+\permanent\tolerant\protected\def\formulachemical#=#=#=%
+ {\relax
+ \ifarguments\or
+ \chem_formula_top_nop
+ \chem_formula_bot_nop
+ \or
+ \chem_formula_top_nop
+ \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}%
+ \or
+ \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}%
+ \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}%
+ \fi
+ \ifcsname\??chemicalsymbol d:\detokenize{#1}\endcsname
+ \toksapp\t_chem_mid{\chemicalsymbol[d:#1]\aligntab}%
+ \else
+ \toksapp\t_chem_mid{\molecule{#1}\aligntab}%
+ \fi}
+
+\def\chem_formula_mid#1%
+ {\csname\??chemicalsymbol\detokenize{#1}\endcsname}
+
+\def\chem_formula_top_nop {\toksapp\t_chem_top{\aligntab}}
+\def\chem_formula_bot_nop {\toksapp\t_chem_bot{\aligntab}}
+\def\chem_formula_top_yes#1{\toksapp\t_chem_top{\chem_formula_top_indeed{#1}\aligntab}\settrue\c_chem_has_top}
+\def\chem_formula_bot_yes#1{\toksapp\t_chem_bot{\chem_formula_bot_indeed{#1}\aligntab}\settrue\c_chem_has_bot}
+
+\def\chem_formula_top_indeed#1{\strut#1}
+\def\chem_formula_bot_indeed#1{\strut#1}
+
+% Experimental: defaults might change.
+
+\definefloat
+ [\v!chemical]
+ [\v!chemicals]
+
+\setuplabeltext
+ [\v!chemical=]
+
+\setupfloat
+ [\v!chemical]
+ [\c!location=\v!here,
+ \c!inner=\hsize.8\textwidth\dontleavehmode, % brr
+ \c!align={\v!flushleft,\v!lohi}]
+
+\setupcaption
+ [\v!chemical]
+ [\c!location=\v!right,
+ \c!distance=\zeropoint,
+ \c!width=.2\textwidth,
+ \c!align=\v!flushright]
+
+% Can be used as for displayed math: \startplaceformula... to display a chemical formula
+% or a chemical structure:
+%
+% \startplacechemical
+% \startchemicalformula
+% \chemical{2H_2}
+% \chemical{PLUS}
+% \chemical{O_2}
+% \chemical{GIVES}
+% \chemical{2H_2O}
+% \stopchemicalformula
+% \stopplacechemical
+
+% gone: state option resolution offset (now frame offset) alternative
+
+\setupchemicalframed
+ [\c!align=\v!normal,
+ \c!strut=\v!no,
+ \c!offset=\v!overlay,
+ \c!frame=\v!off]
+
+\definecolor % private color
+ [chemicalframecolor]
+ [r=.75,g=.85,b=.95]
+
+\setupchemical
+ [\c!frame=,
+ \c!width=\v!fit, % or unitless number, multiplies scale*unit
+ \c!height=\v!fit, % or unitless number, multiplies scale*unit
+ \c!left=\v!fit, % or unitless number, multiplies scale*unit
+ \c!right=\v!fit, % or unitless number, multiplies scale*unit
+ \c!top=\v!fit, % or unitless number, multiplies scale*unit
+ \c!bottom=\v!fit, % or unitless number, multiplies scale*unit
+ \c!bodyfont=,
+ \c!scale=\v!normal, % small, normal or medium, big, or unitless number (multiplies unit)
+ \c!size=\v!medium,
+ \c!textsize=\v!big, % how is textsize used??
+ \c!axis=\v!off,
+ \c!style=\rm,
+ \c!rotation=0, % unitless number (interpreted as degrees)
+ \c!symalign=\v!auto,
+ \c!location=, % not yet used (was interaction related in mkii)
+ \c!offset=.25\emwidth,
+ \c!unit=\emwidth,
+ \c!factor=3,
+ \c!color=,
+ \c!strut=\v!yes,
+ \c!framecolor=chemicalframecolor,
+ \c!rulethickness=0.6pt, %1.5\linewidth,
+ \c!rulecolor=]
+
+%D Compatibility:
+
+\definechemical[+R] {\chemical[RR]}
+\definechemical[-R] {\chemical[LR]}
+
+\definechemical[CARBON:CB] {\chemical[NEWMANSTAGGER,C,SB]}
+\definechemical[NEWMANSTAGGER:CB] {\chemical[NEWMANSTAGGER,C,SB]}
+\definechemical[NEWMANECLIPSED:CB]{\chemical[NEWMANECLIPSED,C,SB]}
+\definechemical[CARBON:CB1] {\chemical[CARBON,C,SB,Z234,1.5MOV1,MIR0,C,SB,Z234]}
+
+\definechemical[NEWMAN] {\chemical[]}
+\definechemical[STAGGER] {\chemical[NEWMANSTAGGER]}
+\definechemical[ECLIPSE] {\chemical[NEWMANECLIPSED]}
+\definechemical[ECLIPSED] {\chemical[NEWMANECLIPSED]}
+\definechemical[SIX:FRONT] {\chemical[SIXFRONT]}
+\definechemical[FIVE:FRONT] {\chemical[FIVEFRONT]}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-bas.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cldf-bas.mkxl
new file mode 100644
index 00000000000..962db5209f5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-bas.mkxl
@@ -0,0 +1,19 @@
+%D \module
+%D [ file=cldf-bas,
+%D version=2010.10.19,,
+%D title=\CONTEXT\ \LUA\ Document Functions,
+%D subtitle=Basics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Documents / Basics}
+
+\registerctxluafile{cldf-bas}{}
+\registerctxluafile{cldf-prs}{}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-com.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cldf-com.mkxl
new file mode 100644
index 00000000000..7a8f7bf5c0d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-com.mkxl
@@ -0,0 +1,19 @@
+%D \module
+%D [ file=cldf-com,
+%D version=2010.10.19,,
+%D title=\CONTEXT\ \LUA\ Document Functions,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Documents / Functions}
+
+\registerctxluafile{cldf-com}{}
+%registerctxluafile{cldf-ver}{}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cldf-ini.mkxl
new file mode 100644
index 00000000000..b393eb9b572
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-ini.mkxl
@@ -0,0 +1,45 @@
+%D \module
+%D [ file=cldf-int,
+%D version=2019.01.01,
+%D title=\CONTEXT\ Data Macros,
+%D subtitle=Integer,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Documents / Initialization}
+
+\newcount\trialtypesettingstate % gets aliased at the Lua end
+
+\registerctxluafile{cldf-ini}{autosuffix}
+
+%D With each new update of \MKIV\ we can join Within Temptation in singing:
+%D
+%D \startbuffer
+%D \startluacode
+%D context("I go faster%s",string.rep(" and faster",6))
+%D \stopluacode
+%D
+%D \cldcontext{"I go faster\letterpercent s",
+%D string.rep(" and faster",6)}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D Anyway \unknown\ the following are {\em not} user commands:
+
+% \catcode`=\activecatcode \let\luafunction % saves 10% on the call
+
+% todo: these can become implementers
+
+\permanent\protected\def\cldprocessfile#1{\directlua{context.runfile("#1")}}
+\permanent \def\cldloadfile #1{\directlua{context.loadfile("#1")}}
+\permanent \def\cldloadviafile#1{\directlua{context.loadviafile("#1")}}
+\permanent \def\cldcontext #1{\directlua{context(#1)}}
+\permanent \def\cldcommand #1{\directlua{context.#1}}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-int.lmt b/Master/texmf-dist/tex/context/base/mkxl/cldf-int.lmt
new file mode 100644
index 00000000000..4a60b469a38
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-int.lmt
@@ -0,0 +1,252 @@
+if not modules then modules = { } end modules ['cldf-int'] = {
+ version = 1.001,
+ comment = "companion to cldf-int.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- another experiment
+-- needs upgrading
+-- needs checking
+-- todo: multilingual
+
+local byte = string.byte
+local insert, remove, concat = table.insert, table.remove, table.concat
+local unpack, type = unpack or table.unpack, type
+
+local ctxcatcodes = catcodes.numbers.ctxcatcodes
+local context = context
+local contextsprint = context.sprint
+
+local trace_define = false trackers.register("context.define", function(v) trace_define = v end)
+
+interfaces = interfaces or { }
+local implement = interfaces.implement
+local estart = interfaces.elements.start
+local estop = interfaces.elements.stop
+
+local scanners = tokens.scanners
+local shortcuts = tokens.shortcuts
+
+local peekchar = scanners.peekchar
+local scankey = scanners.key
+local scanvalue = scanners.value
+local scanskip = scanners.skip
+
+local open = byte('[')
+local close = byte(']')
+local equal = byte('=')
+local comma = byte(',')
+
+local function scanhash(scanners)
+ if peekchar() == open then
+ local data = { }
+ scanskip()
+ while true do
+ local c = peekchar()
+ if c == comma then
+ scanskip()
+ elseif c == close then
+ scanskip()
+ break
+ else
+ local key = scankey(equal)
+ if key then
+ if peekchar() == equal then
+ scanskip()
+ if scanners then
+ local scanner = scanners[key]
+ if scanner then
+ data[key] = scanner()
+ else
+ data[key] = scanvalue(comma,close) or ""
+ end
+ else
+ data[key] = scanvalue(comma,close) or ""
+ end
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ end
+ return data
+ end
+end
+
+local function scanarray()
+ if peekchar() == open then
+ local data = { }
+ local d = 0
+ scanskip()
+ while true do
+ local c = peekchar()
+ if c == comma then
+ scanskip()
+ elseif c == close then
+ scanskip()
+ break
+ else
+ local v = scanvalue(comma,close) or ""
+ d = d + 1
+ data[d] = v
+ end
+ end
+ return data
+ end
+end
+
+shortcuts.scanhash = scanhash
+shortcuts.scanarray = scanarray
+
+scanners.hash = scanhash
+scanners.array = scanarray
+
+local function remap(arguments)
+ -- backward compatibility
+ if type(arguments) == "table" then
+ for i=1,#arguments do
+ local a = arguments[i]
+ if type(a) == "table" then
+ local t = a[2]
+ arguments[i] = t == "list" and "array" or t
+ end
+ end
+ return arguments
+ end
+end
+
+function interfaces.definecommand(name,specification) -- name is optional
+ if type(name) == "table" then
+ specification = name
+ name = specification.name
+ end
+ if name and specification then
+ local environment = specification.environment
+ local arguments = remap(specification.arguments)
+ if environment then
+ local starter = specification.starter
+ local stopper = specification.stopper
+ if starter and stopper then
+ implement {
+ name = estart .. name,
+ arguments = arguments,
+ public = true,
+ protected = true,
+ actions = starter,
+ }
+ implement {
+ name = estop .. name,
+ public = true,
+ protected = true,
+ actions = stopper,
+ }
+ else
+ -- message
+ end
+ end
+ if not environment or environment == "both" then
+ local macro = specification.macro
+ if macro then
+ implement {
+ name = name,
+ arguments = arguments,
+ public = true,
+ protected = true,
+ actions = macro,
+ }
+ else
+ -- message
+ end
+ end
+ else
+ -- message
+ end
+end
+
+function interfaces.tolist(t)
+ if t then
+ local r = { }
+ for i=1,#t do
+ r[i] = t[i]
+ end
+ local n = #r
+ for k,v in table.sortedhash(t) do
+ if type(k) ~= "number" then
+ n = n + 1
+ r[n] = k .. "=" .. v
+ end
+ end
+ return concat(r,", ")
+ else
+ return ""
+ end
+end
+
+-- \startluacode
+-- function test(opt_1, opt_2, arg_1)
+-- context.startnarrower()
+-- context("options 1: %s",interfaces.tolist(opt_1))
+-- context.par()
+-- context("options 2: %s",interfaces.tolist(opt_2))
+-- context.par()
+-- context("argument 1: %s",arg_1)
+-- context.stopnarrower()
+-- end
+--
+-- interfaces.definecommand {
+-- name = "test",
+-- arguments = {
+-- { "option", "list" },
+-- { "option", "hash" },
+-- { "content", "string" },
+-- },
+-- macro = test,
+-- }
+-- \stopluacode
+--
+-- test: \test[1][a=3]{whatever}
+--
+-- \startluacode
+-- local function startmore(opt_1)
+-- context.startnarrower()
+-- context("start more, options: %s",interfaces.tolist(opt_1))
+-- context.startnarrower()
+-- end
+--
+-- local function stopmore()
+-- context.stopnarrower()
+-- context("stop more")
+-- context.stopnarrower()
+-- end
+--
+-- interfaces.definecommand ( "more", {
+-- environment = true,
+-- arguments = {
+-- { "option", "list" },
+-- },
+-- starter = startmore,
+-- stopper = stopmore,
+-- } )
+-- \stopluacode
+--
+-- more: \startmore[1] one \startmore[2] two \stopmore one \stopmore
+--
+-- More modern (no need for option or content):
+--
+-- \startluacode
+-- interfaces.definecommand {
+-- name = "test",
+-- arguments = {
+-- "array", -- or list
+-- "hash",
+-- "string",
+-- "number",
+-- },
+-- macro = test,
+-- }
+-- \stopluacode
+--
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-int.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cldf-int.mkxl
new file mode 100644
index 00000000000..a564afc80ad
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-int.mkxl
@@ -0,0 +1,34 @@
+%D \module
+%D [ file=cldf-int,
+%D version=2019.01.01,
+%D title=\CONTEXT\ Data Macros,
+%D subtitle=Integer,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Multilingual Macros / Lua}
+
+\registerctxluafile{cldf-int}{autosuffix}
+
+%D These are user commands so we don't add any protection against overloading
+%D here.
+
+\unprotect
+
+\permanent\protected\def\newluatable#1{\clf_newluatable#1\atendofgrouped{\disposeluatable#1}}
+\permanent\protected\def\useluatable#1{\clf_useluatable#1\atendofgrouped{\disposeluatable#1}}
+
+\installcorenamespace{datavalue}
+
+\permanent\protected\def\setdatavalue#1#2% #2 is a number (expression)
+ {\expandafter\integerdef\csname\??datavalue#1\endcsname\numexpr#2\relax}
+
+\permanent\def\getdatavalue#1{\begincsname\??datavalue#1\endcsname}
+\permanent\def\thedatavalue#1{\the\begincsname\??datavalue#1\endcsname}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-lmt.lmt b/Master/texmf-dist/tex/context/base/mkxl/cldf-lmt.lmt
new file mode 100644
index 00000000000..f3121eadc02
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-lmt.lmt
@@ -0,0 +1,949 @@
+if not modules then modules = { } end modules ['cldf-lmt'] = {
+ version = 1.001,
+ comment = "companion to toks-scn.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local next, load = next, load
+local gmatch, gsub, byte = string.gmatch, string.gsub, string.byte
+
+local setmetatableindex = table.setmetatableindex
+local setmetatablenewindex = table.setmetatablenewindex
+local serialize = table.serialize
+local concat = table.concat
+
+local random = math.random
+local randomseed = math.randomseed
+local round = math.round
+local abs = math.abs
+
+local implement = interfaces.implement
+
+local scanners = tokens.scanners
+local scanword = scanners.word
+local scanstring = scanners.string
+local scanboolean = scanners.boolean
+local scandimen = scanners.dimen
+local scanfloat = scanners.float
+local scaninteger = scanners.integer
+local scancardinal = scanners.cardinal
+local scannumber = scanners.luanumber
+local scanluainteger = scanners.luainteger
+local scanluacardinal = scanners.luacardinal
+local scanluanumber = scanners.luanumber
+local scanargument = scanners.argument
+local scantoken = scanners.token
+local scancsname = scanners.csname
+local scankeyword = scanners.keyword
+
+local peekchar = scanners.peekchar
+local skipnext = scanners.skip
+
+local getindex = token.get_index
+
+local texsetdimen = tex.setdimen
+local texsetcount = tex.setcount
+local texgetcount = tex.getcount
+local texget = tex.get
+
+local values = tokens.values
+local none_code = values.none
+local integer_code = values.integer
+local cardinal_code = values.cardinal
+local dimension_code = values.dimension
+local skip_code = values.skip
+local boolean_code = values.boolean
+local float_code = values.float
+
+local global_code = tex.flagcodes.global
+
+local context = context
+
+-- variables --
+
+local floats = { }
+local integers = { }
+local cardinals = { }
+local numbers = { }
+
+implement {
+ name = "luafloat",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local n = scanword()
+ if b == "value" then
+ context("%.99g",floats[n] or 0)
+ else
+ floats[n] = scanluanumber(true)
+ -- floats[n] = scanfloat(true)
+ end
+ end,
+}
+
+implement {
+ name = "luainteger",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local n = scanword()
+ if b == "value" then
+ context("%i",integers[n] or 0)
+ else
+ integers[n] = scanluainteger(true)
+ end
+ end,
+}
+
+implement {
+ name = "luacount",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local n = scanword()
+ if b == "value" then
+ return integer_code, integers[n] or 0
+ else
+ integers[n] = scaninteger(true)
+ end
+ end,
+}
+
+implement {
+ name = "luadimen",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local n = scanword()
+ if b == "value" then
+ return dimension_code, integers[n] or 0
+ else
+ integers[n] = scandimen(false,false,true)
+ end
+ end,
+}
+
+implement {
+ name = "luacardinal",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local n = scanword()
+ if b == "value" then
+ context("%1.0f",cardinals[n] or 0)
+ else
+ cardinals[n] = scanluacardinal(true)
+ end
+ end,
+}
+
+implement {
+ name = "luanumber",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local n = scanword()
+ if b == "value" then
+ context("%N",floats[n] or integers[n] or cardinals[n] or 0) -- maybe %N
+ else
+ -- floats[n] = scanfloat(true)
+ floats[n] = scanluanumber(true)
+ end
+ end,
+}
+
+implement {
+ name = "luarandom",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ if b == "value" then
+ return integer_code, random(scanluainteger(),scanluainteger())
+ else
+ randomseed(scanluainteger(true))
+ end
+ end,
+}
+
+interfaces.floats = floats
+interfaces.integers = integers
+interfaces.cardinals = cardinals
+
+interfaces.numbers = table.setmetatableindex(function(t,k)
+ return floats[k] or integers[k] or cardinals[k]
+end)
+
+-- arrays --
+
+local arrays = { }
+
+interfaces.arrays = arrays
+
+local newindex = lua.newindex
+
+implement {
+ name = "newarray",
+ public = true,
+ protected = true,
+ arguments = { {
+ { "name", "string" },
+ { "nx", "integer" },
+ { "ny", "integer" },
+ { "type", "string" },
+ } },
+ actions = function(t)
+ local name = t.name
+ if t.name then
+ local nx = t.nx
+ local ny = t.ny
+ local ty = t.type or "integer"
+ local df = nil
+ if ty == "integer" or ty == "float" or ty == "dimension" then
+ df = 0
+ elseif ty == "boolean" then
+ df = false
+ else
+ ty = nil
+ end
+ if nx and ty ~= nil then
+ local data
+ if ny then
+ data = newindex(t.ny)
+ for i=1,ny do
+ data[i] = newindex(nx,df)
+ end
+ else
+ data = newindex(nx,df)
+ end
+ arrays[name] = data
+ data.nx = nx
+ data.ny = ny
+ data.type = ty
+ if ty == "integer" then
+ data.scanner = scaninteger
+ elseif ty == "boolean" then
+ data.scanner = scanboolean
+ elseif ty == "dimension" then
+ data.scanner = scandimen
+ elseif ty == "float" then
+ data.scanner = scanfloat
+ end
+ if ty == "integer" then
+ data.code = integer_code
+ elseif ty == "boolean" then
+ data.code = boolean_code
+ elseif ty == "dimension" then
+ data.code = dimension_code
+ elseif ty == "float" then
+ data.code = float_code
+ end
+ end
+ end
+ end,
+}
+
+implement {
+ name = "arrayvalue",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local name = scanstring()
+ if name then
+ local a = arrays[name]
+ if a then
+ local nx = a.nx
+ local ny = a.ny
+ local d = a
+ if ny then
+ d = d[scaninteger()]
+ end
+ local x = scaninteger()
+ if b == "value" then
+ local code = a.code
+ if code == float_code then
+ context("%.99g",d[x])
+ else
+ return code, d[x]
+ end
+ else
+ d[x] = a.scanner()
+ end
+ end
+ end
+ end,
+}
+
+implement {
+ name = "arrayequals",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local name = scanstring()
+ if name then
+ local a = arrays[name]
+ if a then
+ local nx = a.nx
+ local ny = a.ny
+ local d = a
+ if ny then
+ d = d[scaninteger()]
+ end
+ local x = scaninteger()
+ if b == "value" then
+ return boolean_code, a.scanner() == d[x]
+ end
+ end
+ end
+ end,
+}
+
+implement {
+ name = "arraycompare",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ local name = scanstring()
+ if name then
+ local a = arrays[name]
+ if a then
+ local nx = a.nx
+ local ny = a.ny
+ local d = a
+ if ny then
+ d = d[scaninteger()]
+ end
+ local x = scaninteger()
+ if b == "value" then
+ local v = a.scanner()
+ local d = d[x]
+ if d < v then
+ return integer_code, 0
+ elseif d == v then
+ return integer_code, 1
+ else
+ return integer_code, 2
+ end
+ end
+ end
+ end
+ end,
+}
+
+implement {
+ name = "showarray",
+ public = true,
+ protected = true,
+ actions = function()
+ local name = scanstring()
+ if name then
+ inspect(arrays[name])
+ end
+ end,
+}
+
+-- expressions --
+
+local cache = table.setmetatableindex(function(t,k)
+ local code = "return function() local n = interfaces.numbers local a = interfaces.arrays return " .. k .. " end"
+ code = loadstring(code)
+ if code then
+ code = code()
+ end
+ t[k] = code or false
+ return code
+end)
+
+table.makeweak(cache)
+
+implement {
+ name = "luaexpression",
+ public = true,
+ actions = function()
+ local how = scanword()
+ local code = cache[scanargument()]
+ if code then
+ local result = code()
+ if result then
+ if not how then
+ context(tostring(code()))
+ elseif how == "float" then
+ context("%.99g",result)
+ elseif how == "integer" then
+ context("%i",round(result))
+ elseif how == "cardinal" then
+ context("%d",abs(round(result)))
+ elseif how == "dimen" then
+ context("%p",result)
+ elseif how == "boolean" then
+ context("%d",result and 1 or 0)
+ elseif how == "lua" then
+ context("%q",result)
+ else
+ context(tostring(code()))
+ end
+ end
+ end
+ end
+}
+
+local dimenfactors = number.dimenfactors
+
+implement {
+ name = "nodimen",
+ public = true,
+ usage = "value",
+ actions = function(b)
+ if b == "value" then
+ local how = scanword()
+ local what = scandimen()
+ if how then
+ local factor = dimenfactors[how]
+ if factor then
+ context("%.6N%s",factor*what,how)
+ else
+ return dimension_code, what
+ end
+ else
+ return dimension_code, what
+ end
+ else
+ local t = scantoken()
+ if t then
+ local i = getindex(t)
+ if i then
+ local d = scandimen(false,false,true)
+ texsetdimen(i,d)
+ end
+ end
+ end
+ end,
+}
+
+-- experimental:
+
+local grouped = { }
+local slots = { }
+local nofslots = 0
+local nofgrouped = 0
+
+local getinteger = tokens.getinteger
+local setinteger = tokens.setinteger
+
+local report = logs.reporter("lua table")
+
+local ctxsprint = context.sprint
+
+-- we could have an extra one that collects all end of grouped actions
+-- so that we dispose more in one go but it doesn's pay off
+
+local function newluatable(name,mt,dispose)
+ local g = { }
+ local t = slots[nofslots]
+ slots[nofslots] = false
+ nofslots = nofslots - 1
+ if not t then
+ nofgrouped = nofgrouped + 1
+ t = nofgrouped
+ end
+ if mt then
+ mt = getinteger(name)
+ if mt then
+ mt = grouped[mt]
+ if mt then
+ setmetatableindex(g,mt)
+ end
+ end
+ end
+ grouped[t] = g
+ setinteger(name,t)
+ -- This is the slow part. Doing this at the TeX end saved 10% runtime. I'll
+ -- think of something that we can set it at the Lua end.
+ if dispose then
+ ctxsprint("\\atendofgrouped{\\disposeluatable\\" .. name .. "}")
+ end
+end
+
+local function disposeluatable(name)
+ local t = getinteger(name)
+ local g = grouped[t]
+ if g then
+ grouped[t] = false
+ nofslots = nofslots + 1
+ slots[nofslots] = t
+ end
+end
+
+local function setluatable(name,kv)
+ local t = getinteger(name)
+ local g = grouped[t]
+ if g and kv then
+ for k, v in next, kv do
+ g[k] = v
+ end
+ end
+end
+
+local function getfromluatable(name,k)
+ local t = getinteger(name)
+ local g = grouped[t]
+ if g then
+ local v = g[k]
+ if v then
+ context(v)
+ else
+ local n = tonumber(k)
+ if n then
+ local v = g[n]
+ if v then
+ context(v)
+ end
+ end
+ end
+ end
+end
+
+local function idxfromluatable(name,k)
+ local t = getinteger(name)
+ local g = grouped[t]
+ if g then
+ local v = g[k]
+ if v then
+ context(v)
+ end
+ end
+end
+
+local function getluatable(name,k)
+ local t = getinteger(name)
+ local g = grouped[t]
+ if g then
+ return g
+ end
+end
+
+local function inspectluatable(name)
+ local t = getinteger(name)
+ local g = grouped[t]
+ if g then
+ report("%s", serialize(g,'[grouped slot ' .. t .. ']'))
+ end
+end
+
+local function showluatables()
+ report("nofgrouped %i, nofslots %i",nofgrouped,nofslots)
+ for t=1,nofgrouped do
+ local g = grouped[t]
+ if g then
+ report("%s", serialize(g,'[grouped slot ' .. t .. ']'))
+ end
+ end
+end
+
+implement {
+ name = "newluatable",
+ protected = true,
+ arguments = "csname",
+ actions = newluatable,
+}
+
+implement {
+ name = "useluatable",
+ protected = true,
+ arguments = { "csname", true },
+ actions = newluatable,
+}
+
+implement {
+ name = "disposeluatable",
+ protected = true,
+ public = true,
+ arguments = "csname",
+ actions = disposeluatable,
+}
+
+implement {
+ name = "inspectluatable",
+ protected = true,
+ public = true,
+ arguments = "csname",
+ actions = inspectluatable,
+}
+
+implement {
+ name = "showluatables",
+ protected = true,
+ public = true,
+ actions = showluatables,
+}
+
+implement {
+ name = "setluatable",
+ protected = true,
+ public = true,
+ arguments = { "csname", "argument" },
+ actions = function(name,data)
+ data = load("return {" .. data .. "}")
+ if data then
+ data = data()
+ if data then
+ setluatable(name,data)
+ end
+ end
+ end
+}
+
+implement {
+ name = "getfromluatable",
+ protected = false,
+ public = true,
+ arguments = { "csname", "argument" },
+ actions = getfromluatable,
+}
+
+implement {
+ name = "idxfromluatable",
+ protected = false,
+ public = true,
+ arguments = { "csname", "integer" },
+ actions = idxfromluatable,
+}
+
+context.luatables = {
+ new = function(name) newluatable(name,false,true) end,
+ use = function(name) useluatable(name,true, true) end,
+ dispose = disposeluatable,
+ set = setluatable,
+ get = getluatable,
+ getfrom = getfromluatable,
+ idxfrom = idxfromluatable,
+ inspect = inspectluatable,
+ show = showluatables,
+}
+
+-- Here's another mechanism ...
+
+local tables = { }
+local stack = setmetatableindex("table")
+
+interfaces.implement {
+ name = "droptablegroup",
+ public = true,
+ actions = function()
+ local g = texget("currentgrouplevel") -- todo: tex.getgrouplevel()
+ local s = stack[g]
+ if s then
+ for t, data in next, s do
+ for k, v in next, data do
+ t[k] = v
+ end
+ end
+ stack[g] = { }
+ end
+ end,
+}
+
+local ctx_atendofgroup = context.core.cs.atendofgroup
+local ctx_droptablegroup = context.core.cs.droptablegroup
+
+local function handletable(t,b,array)
+ if b == "value" then
+ local k = array and scaninteger() or scanargument()
+ local v = t[k]
+ if v then
+ context(v)
+ end
+ else
+ local data = scanargument()
+ data = load("return {" .. data .. "}")
+ if data then
+ data = data()
+ if data then
+ local l = t.level
+ local g = texget("currentgrouplevel") -- todo: tex.getgrouplevel()
+ local s = stack[g]
+ local d = s[t]
+ if not d then
+ d = { }
+ s[t] = d
+ ctx_atendofgroup()
+ ctx_droptablegroup()
+ end
+ for k, v in next, data do
+ if not d[k] then
+ d[k] = t[k]
+ end
+ t[k] = v
+ end
+ -- if b == "global" then
+ if b and (b & 0x04) ~= 0 then -- or just band(b,0x04)
+ for k, v in next, stack do
+ local t = s[t]
+ if t then
+ for k, v in next, data do
+ if t[k] then
+ t[k] = nil
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local function newtable(array)
+ local name = scancsname(true)
+ if not tables[name] then
+ local t = { }
+ tables[name] = t
+ interfaces.implement {
+ name = name,
+ public = true,
+ usage = "value",
+ actions = function(b)
+ handletable(t,b,array)
+ end,
+ }
+ else
+ -- already defined
+ end
+end
+
+implement {
+ name = "newhashedtable",
+ protected = true,
+ public = true,
+ actions = newtable,
+}
+
+implement {
+ name = "newindexedtable",
+ protected = true,
+ public = true,
+ actions = function() newtable(true) end,
+}
+
+context.hashedtables = setmetatableindex(function(t,k) return tables[k] end)
+context.indexedtables = context.hashedtables
+
+-- I played with adding bitwise operator to the expr scanners but in the end didn't
+-- keep the code ... the problem is in what symbols ... so for now a more verbose
+-- and/or/xor is okay. Extending the expression scanner would add a little overhead
+-- to all expressions while an logical operator would gain less that 50% so for now
+-- we don't bother. Providing \ifbitwiseand makes sense for performance reasons as
+-- if a bit beter than testing the bitwise and with an \ifcase.
+
+local reporterror = logs.texerrormessage
+
+local function youcant(cmd)
+ reporterror("you can't use \\%s this way, it's an integer value", cmd)
+end
+
+implement {
+ name = "bitwiseset",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ if what == "value" then
+ return cardinal_code, a
+ else
+ youcant("bitwiseset")
+ end
+ end
+}
+
+implement {
+ name = "bitwiseand",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ scankeyword("with")
+ local b = scancardinal()
+ if what == "value" then
+ return cardinal_code, a & b
+ else
+ youcant("bitwiseand")
+ end
+ end
+}
+
+implement {
+ name = "bitwiseor",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ scankeyword("with")
+ local b = scancardinal()
+ if what == "value" then
+ return cardinal_code, a | b
+ else
+ youcant("bitwiseor")
+ end
+ end
+}
+
+implement {
+ name = "bitwisexor",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ scankeyword("with")
+ local b = scancardinal()
+ if what == "value" then
+ return cardinal_code, a ~ b
+ else
+ youcant("bitwisexor")
+ end
+ end
+}
+
+implement {
+ name = "bitwisenot",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ if what == "value" then
+ return cardinal_code, ~a & 0xFFFFFFFF
+ else
+ youcant("bitwisenot")
+ end
+ end
+}
+
+implement {
+ name = "bitwisenil",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ scankeyword("with")
+ local b = scancardinal()
+ if what == "value" then
+ return cardinal_code, a & (~b & 0xFFFFFFFF)
+ else
+ youcant("bitwisenil")
+ end
+ end
+}
+
+implement {
+ name = "bitwiseshift",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local a = scancardinal()
+ scankeyword("by")
+ local b = scaninteger()
+ if what == "value" then
+ return cardinal_code, (b < 0) and (a << -b) or (a >> b)
+ else
+ youcant("bitwiseshift")
+ end
+ end
+}
+
+implement {
+ name = "bitwiseflip",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local t = scancsname()
+ local b = scaninteger()
+ local c = texgetcount(t)
+ if c then
+ if b > 0 then
+ c = c | b
+ elseif b < 0 then
+ c = c & (~(-b) & 0xFFFFFFFF)
+ end
+ if what == "value" then
+ return cardinal_code, c
+ elseif what and (what & global_code) ~= 0 then
+ texsetcount("global",t,c)
+ else
+ texsetcount(t,c)
+ end
+ end
+ end
+}
+
+implement {
+ name = "ifbitwiseand",
+ public = true,
+ usage = "condition",
+ actions = function(what)
+ local a = scancardinal()
+ local b = scancardinal()
+ return boolean_code, (a & b) ~= 0
+ end
+}
+
+interfaces.implement {
+ name = "bitwise",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ local b = 0
+ while true do
+ local c = peekchar()
+ if c == 48 or c == 49 then
+ skipnext()
+ b = (b << 1) + (c - 48)
+ if b == 0xFFFFFFFF then
+ break
+ end
+ else
+ break
+ end
+ end
+ return 1, b
+ else
+ local b = scancardinal()
+ local t = nil
+ local n = 0
+ for i=1,32 do
+ if (b & (0x100000000 >> i)) == 0 then
+ if n > 0 then
+ n = n + 1
+ t[n] = "0"
+ end
+ elseif t then
+ n = n + 1
+ t[n] = "1"
+ else
+ n = 1
+ t = { "1" }
+ end
+ end
+ context(n > 0 and table.concat(t) or "0")
+ end
+ end,
+}
+
+-- something to play with, this might move to syst-aux.lmt when we have that
+
+local escape = function(s) return "\\" .. byte(s) end
+
+interfaces.implement {
+ name = "ctxluamatch",
+ public = true,
+ usage = "value",
+ actions = function()
+ local command = context[scancsname()]
+ local pattern = gsub(scanstring(),"\\.",escape)
+ local input = gsub(scanstring(),"\\.",escape)
+ for a, b, c, d, e, f, g, h, i in gmatch(input,pattern) do
+ command(a, b or "", c or "", d or "", e or "", f or "", g or "", h or "", i or "")
+ end
+ return none_code
+ end,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cldf-ver.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cldf-ver.mkxl
new file mode 100644
index 00000000000..0ff63810ead
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cldf-ver.mkxl
@@ -0,0 +1,18 @@
+%D \module
+%D [ file=cldf-com,
+%D version=2010.10.19,
+%D title=\CONTEXT\ \LUA\ Document Functions,
+%D subtitle=Verbatim,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Documents / Verbatim}
+
+\registerctxluafile{cldf-ver}{}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/colo-ext.mkxl b/Master/texmf-dist/tex/context/base/mkxl/colo-ext.mkxl
new file mode 100644
index 00000000000..df2d9d768a1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/colo-ext.mkxl
@@ -0,0 +1,99 @@
+%D \module
+%D [ file=colo-ext, % mostof thsi code used to be in colo-ini.tex
+%D version=1997.04.01,
+%D title=\CONTEXT\ Color Macros,
+%D subtitle=Extras,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Color Macros / Extras}
+
+\unprotect
+
+%D \macros
+%D {negatecolorcomponent, negativecolorbox}
+%D
+%D Sometimes, especially when we deal with typesetting devices, we want to reverse
+%D the color scheme. Instead of recalculating all those colors, we use a quick and
+%D dirty approach:
+%D
+%D \starttyping
+%D \negativecolorbox0
+%D \stoptyping
+%D
+%D will negate the colors in box zero.
+
+\permanent\protected\def\negatecolorbox#1% or just set attr of #1
+ {\setbox#1\hpack to \wd#1%
+ {\scratchdimen\wd#1\relax
+ \startnegative % might change
+ \blackrule[\c!color=\s!white,\c!height=\ht#1,\c!depth=\dp#1,\c!width=\scratchdimen]%
+ \hskip-\scratchdimen
+ \leaders\box#1\hfill% this triggers application to the box .. a real dirty hack!
+ \stopnegative}}
+
+%D There are in principle two ways to handle overprint: bound to colors or
+%D independent. For the moment we only support independent overprint handling. Here
+%D we deal with a per-document setting.
+
+%D We can move the stack and attribute setting to the \LUA\ end.
+
+\installcorenamespace{colorintent}
+
+\permanent\protected\def\registercolorintent#1#2% \relax is needed !
+ {\setevalue{\??colorintent#1}{\c_attr_colorintent\clf_registercolorintent{#2}\relax}}
+
+\protected\def\colo_intents_set
+ {\clf_enablecolorintents
+ \protected\gdef\colo_intents_set##1{\csname\??colorintent##1\endcsname}%
+ \colo_intents_set}
+
+\registercolorintent{knockout} {knockout}
+\registercolorintent{overprint}{overprint}
+
+\installattributestack\colorintentattribute
+
+\setevalue{\??colorintent\v!none}{\c_attr_colorintent\attributeunsetvalue} % or reset? used at all?
+
+\permanent\protected\def\startcolorintent[#1]%
+ {\pushattribute\colorintentattribute
+ \colo_intents_set{#1}}
+
+\permanent\protected\def\stopcolorintent
+ {\popattribute\colorintentattribute}
+
+\permanent\protected\def\startoverprint{\startcolorintent[\v!overprint]}
+\permanent\protected\def\startknockout {\startcolorintent[\v!knockout ]}
+
+\aliased\let\stopoverprint\stopcolorintent
+\aliased\let\stopknockout \stopcolorintent
+
+\aliased\let\starttextcolorintent\relax
+\aliased\let\stoptextcolorintent \relax
+
+\appendtoks
+ \colo_intents_set_text
+\to \everysetupcolors
+
+\let\p_colo_intent\empty
+
+\def\colo_intents_set_text
+ {\edef\p_colo_intent{\colorsparameter\c!intent}%
+ \ifx\p_colo_intent\v!none \else
+ \enforced\protected\xdef\starttextcolorintent{\colo_intents_set{\p_colo_intent}}%
+ \glet\colo_intents_set_text\relax
+ \colo_intents_set\p_colo_intent
+ \fi}
+
+\appendtoks \starttextcolorintent \to \everystarttextproperties
+\appendtoks \stoptextcolorintent \to \everystoptextproperties
+
+\setupcolors
+ [\c!intent=\v!none]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/colo-grp.mkxl b/Master/texmf-dist/tex/context/base/mkxl/colo-grp.mkxl
new file mode 100644
index 00000000000..9237952d750
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/colo-grp.mkxl
@@ -0,0 +1,163 @@
+%D \module
+%D [ file=colo-grp,
+%D version=2011.12.27, % moved from colo-ini
+%D title=\CONTEXT\ Color Macros,
+%D subtitle=Groups,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Regular colors and palets are used most, contrary to groups which is why we
+%D define their support in a separate module.
+
+\writestatus{loading}{ConTeXt Color Macros / Groups}
+
+\unprotect
+
+%D \macros
+%D {definecolorgroup}
+%D
+%D The naming of the colors in this palet suggests some ordening, which in turn is
+%D suported by color grouping.
+%D
+%D \starttyping
+%D \definecolorgroup
+%D [red]
+%D [1.00:0.90:0.90,
+%D 1.00:0.80:0.80,
+%D 1.00:0.70:0.70,
+%D 1.00:0.55:0.55,
+%D 1.00:0.40:0.40,
+%D 1.00:0.25:0.25,
+%D 1.00:0.15:0.15,
+%D 0.90:0.00:0.00]
+%D \stoptyping
+%D
+%D In such a color group colors are numbered from~$1$ to~$n$.
+%D
+%D \showsetup{definecolorgroup}
+%D
+%D This kind of specification is not only more compact than defining each color
+%D separate, it also loads faster and takes less bytes.
+
+\installcorenamespace{colorgroup}
+\installcorenamespace{colorgroupsetter}
+
+\newcount\c_colo_groups_n % scratch counter
+
+\permanent\tolerant\protected\def\definecolorgroup[#1]#*[#2]#*[#3]% % sort of obsolete, just use palets directly
+ {\ifarguments\or\or
+ \ifhastok:{#2}%
+ \colo_groups_define_normal[#1][\v!rgb][#2]
+ \else
+ \colo_groups_define_checked[#1][#2][]%
+ \fi
+ \else
+ \colo_groups_define_normal[#1][#2][#3]%
+ \fi}
+
+\def\colo_groups_define_normal[#1][#2][#3]%
+ {\c_colo_groups_n\zerocount
+ \processcommalist[#3]{\colo_groups_define_entry{#1}{#2}}}
+
+\def\colo_groups_define_checked[#1][#2][#3]%
+ {\doloop % inherited
+ {\ifcsname#2:##1\endcsname
+ \definecolor[#1:##1][#2:##1]%
+ \else
+ \exitloop
+ \fi}}
+
+\def\colo_groups_define_entry#1#2#3% name mode specification
+ {\advance\c_colo_groups_n\plusone
+ \csname\??colorgroupsetter\ifcsname\??colorgroupsetter#2\endcsname#2\else\s!rgb\fi\endcsname[#1:\the\c_colo_groups_n][#3:0:0:0:0]}
+
+\setvalue{\??colorgroupsetter\s!gray}[#1][#2:#3]{\definecolor[#1][s=#2]}
+\setvalue{\??colorgroupsetter\s!rgb }[#1][#2:#3:#4:#5]{\definecolor[#1][r=#2,g=#3,b=#4]}
+\setvalue{\??colorgroupsetter\s!cmyk}[#1][#2:#3:#4:#5:#6]{\definecolor[#1][c=#2,m=#3=,y=#4,k=#5]}
+\setvalue{\??colorgroupsetter\s!spot}[#1][#2:#3:#4]{\definespotcolor[#1][#2][p=#3]}
+
+%D \macros
+%D {showcolorgroup}
+%D
+%D We can show the group by:
+%D
+%D \startbuffer
+%D \showcolorgroup [blue] [horizontal,name,number,value]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D or in color:
+%D
+%D \startlinecorrection
+%D \getbuffer
+%D \stoplinecorrection
+%D
+%D which uses:
+%D
+%D \showsetup{showcolorgroup}
+
+\fetchmodulecommand \showcolorgroup \f!colo_run
+
+%D There are ten predefined color groups, like \color [green] {\em groen}, \color
+%D [red] {\em rood}, \color [blue] {\em blauw}, \color [cyan] {\em cyaan}, \color
+%D [magenta] {\em magenta} and \color [yellow] {\em geel}.
+%D
+%D \startlinecorrection
+%D \hbox to \hsize
+%D {\hss
+%D \showcolorgroup [red] [vertical,name,number]\hss
+%D \showcolorgroup [green] [vertical,name]\hss
+%D \showcolorgroup [blue] [vertical,name]\hss
+%D \showcolorgroup [cyan] [vertical,name]\hss
+%D \showcolorgroup [magenta][vertical,name]\hss
+%D \showcolorgroup [yellow] [vertical,name]\hss}
+%D \stoplinecorrection
+%D
+%D These groups are used to define palets {\em alfa} upto {\em zeta}. As long as we
+%D don't use colors from the same row, we get ourselves distinctive palets. By
+%D activating such a palet one gains access to its members {\em top} to {\em charm}
+%D (of course one should use more suitable names than these).
+%D
+%D \startlinecorrection
+%D \hbox to \hsize
+%D {\showpalet [alfa] [vertical,name,number]\hss
+%D \showpalet [beta] [vertical,name]\hss
+%D \showpalet [gamma] [vertical,name]\hss
+%D \showpalet [delta] [vertical,name]\hss
+%D \showpalet [epsilon] [vertical,name]\hss
+%D \showpalet [zeta] [vertical,name]}
+%D \stoplinecorrection
+%D
+%D By using the keyword \type {value} the individual color components are shown too.
+%D When printed in color, these showcases show both the colors and the gray value.
+
+%D \macros
+%D {comparecolorgroup}
+%D
+%D The similar command:
+%D
+%D \startbuffer
+%D \comparecolorgroup [blue]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D shows color groups:
+%D
+%D \startlinecorrection
+%D \getbuffer
+%D \stoplinecorrection
+%D
+%D this commands are defined as:
+%D
+%D \showsetup{comparecolorgroup}
+
+\fetchmodulecommand \comparecolorgroup \f!colo_run
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/colo-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/colo-ini.mkxl
new file mode 100644
index 00000000000..c096fe90f2c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/colo-ini.mkxl
@@ -0,0 +1,1378 @@
+%D \module
+%D [ file=colo-ini,
+%D version=2007.08.08,
+%D title=\CONTEXT\ Color Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Color Macros / Initialization}
+
+%D Todo: move color space in color attribute (last two bits)
+
+%D This module implements color. Since \MKII\ and \MKIV\ use a completely
+%D different approach, this module only implements a few generic mechanisms.
+
+\installcorenamespace{color}
+\installcorenamespace{colorattribute}
+\installcorenamespace{transparencyattribute}
+\installcorenamespace{colorsetter}
+\installcorenamespace{transparencysetter}
+\installcorenamespace{colorpaletspecification}
+\installcorenamespace{colorpalet}
+\installcorenamespace{colorstack}
+\installcorenamespace{colorconversions}
+\installcorenamespace{colornumber}
+
+\registerctxluafile{colo-ini}{}
+\registerctxluafile{colo-icc}{}
+
+\unprotect
+
+%D In \MKIV\ we have independent color, colorspace and transparency but I'm still
+%D not sure if I keep it that way as it's probably more efficient to combine them
+%D (less attributes and finalizing). If it becomes a bottleneck we can set up a more
+%D complex system with one shared attribute for colorspace, color and transparency.
+%D
+%D When typesetting for paper, we prefer using the \CMYK\ color space, but for
+%D on||screen viewing we prefer \RGB\ (the previous implementation supported only
+%D this scheme). Independant of such specifications, we support some automatic
+%D conversions:
+%D
+%D \startitemize[packed]
+%D \item convert all colors to \RGB
+%D \item convert all colors to \CMYK
+%D \item convert all colors to gray scales
+%D \stopitemize
+%D
+%D These options are communicated by means of:
+
+\newconditional\c_colo_rgb_supported
+\newconditional\c_colo_cmyk_supported
+\newconditional\c_colo_spot_supported % backend driven
+\newconditional\c_colo_convert_gray \settrue\c_colo_convert_gray
+\newconditional\c_colo_enabled
+\newconditional\c_colo_expanded
+
+\let\m_colo_weight_gray\v!yes
+
+\mutable\let\currentcolormodel \empty
+\mutable\let\currentcolorname \empty
+\mutable\let\currentcolorpalet \empty
+\mutable\let\currentcolorprefix\empty % \currentcolorpalet:
+
+%D \macros
+%D {definecolor,defineglobalcolor,definenamedcolor,definespotcolor,definemultitonecolor,
+%D definetransparency}
+%D
+%D \starttyping
+%D \definecolor [blue] [c=1,m=.38,y=0,k=.64] % pantone pms 2965 uncoated m
+%D \definecolor [yellow] [c=0,m=.28,y=1,k=.06] % pantone pms 124 uncoated m
+%D
+%D \definespotcolor [blue-100] [blue] [p=1]
+%D \definespotcolor [yellow-100] [yellow] [p=1]
+%D
+%D \definemultitonecolor [pdftoolscolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]
+%D
+%D \defineprocesscolor[myred][r=.5]
+%D \defineprocesscolor[myredish][red][a=1,t=.5]
+%D
+%D \blackrule[color=myred,width=\hsize,height=1cm] \par
+%D \blackrule[color=myredish,width=\hsize,height=1cm]
+%D
+%D \useexternalfigure[demofig][mill.png][object=no]
+%D
+%D \startcombination[4*1]
+%D {\externalfigure[demofig]} {no color}
+%D {\externalfigure[demofig][color=pdftoolscolor]} {indexed duotone}
+%D {\externalfigure[demofig][color=blue-100]} {spot color}
+%D {\externalfigure[demofig][color=yellow-100]} {spot color}
+%D \stopcombination
+%D \stoptyping
+
+\permanent\protected\def\loadfoundcolorsetfile#1#2% name foundname / not a user command
+ {\startreadingfile
+ \startcolorset[#1]%
+ \input{#2}%
+ \stopcolorset
+ \showmessage\m!colors4{#1}%
+ \stopreadingfile}
+
+%D \macros
+%D {startcolor,stopcolor,color,graycolor}
+%D
+%D The local and global commands are here just for compatibility with \MKII.
+%D
+%D \showsetup{startcolor}
+%D
+%D The simple color commands are:
+%D
+%D \showsetup{color}
+%D \showsetup{graycolor}
+
+%D We expect sane behaviour in \MKIV\ so we don't used grouped command any
+%D longer.
+
+% \testfeatureonce{100000}{\color[red]{}} % 1.046 => 0.541
+
+\permanent\protected\def\switchtocolor[#1]{\begincsname#1\endcsname}
+
+% transparency
+
+\permanent\protected\def\transparent[#1]%
+ {\bgroup
+ \edef\scratchstringone{#1}%
+ % the \relax catches a non existent csname
+ \ifx\scratchstringone\v!reset
+ \c_attr_transparency\attributeunsetvalue
+ \else
+ \begincsname\??transparencysetter\scratchstringone\endcsname\relax
+ \fi
+ \let\nexttoken}
+
+\permanent\protected\def\starttransparent[#1]%$
+ {\begingroup
+ \edef\scratchstringone{#1}%
+ \ifx\scratchstringone\v!reset
+ \c_attr_transparency\attributeunsetvalue
+ \else
+ \begincsname\??transparencysetter\scratchstringone\endcsname\relax
+ \fi}
+
+\permanent\protected\def\stoptransparent
+ {\endgroup}
+
+% color
+
+\permanent\protected\def\coloronly[#1]%
+ {\bgroup
+ \edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop_only
+ \else
+ \colo_helpers_activate_yes_only
+ \fi
+ \let\nexttoken}
+
+\permanent\protected\def\startcoloronly[#1]%$
+ {\begingroup
+ \edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop_only
+ \else
+ \colo_helpers_activate_yes_only
+ \fi}
+
+\permanent\protected\def\stopcoloronly
+ {\endgroup}
+
+% color + transparency
+
+\permanent\protected\def\color[#1]%
+ {\bgroup
+ \edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi
+ \let\nexttoken}
+
+\permanent\protected\def\graycolor[#1]%
+ {\bgroup
+ \colo_helpers_set_model\s!gray\colo_helpers_activate{#1}%
+ \let\nexttoken}
+
+\permanent\protected\def\startcolor[#1]%$
+ {\begingroup
+ \edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi}
+
+\permanent\protected\def\stopcolor
+ {\endgroup}
+
+\permanent\protected\def\colored[#1]%
+ {\bgroup
+ \colo_basics_defined_and_activated{#1}%
+ \let\nexttoken}
+
+\permanent\protected\def\fastcolored[#1]#2%
+ {\begingroup % is this command still needed?
+ \colo_basics_defined_and_activated{#1}%
+ #2%
+ \endgroup}
+
+\permanent\protected\def\directcolored[#1]%
+ {\colo_basics_defined_and_activated{#1}}
+
+\permanent\protected\def\fastcolor[#1]#2%
+ {\begingroup % is this command still needed?
+ \edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi
+ #2%
+ \endgroup}
+
+\permanent\protected\def\directcolor[#1]%
+ {\edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi}
+
+%D The following command is obsolete:
+
+\permanent\protected\def\startcolorpage{\startcolor[\ifempty\maintextcolor\defaulttextcolor\else\maintextcolor\fi]}
+\permanent\protected\def\stopcolorpage {\stopcolor}
+
+\permanent\protected\def\getcolorattributevalue#1#2% obsolete, use \thecolorattribute instead ...
+ {\begingroup
+ \colo_helpers_activate{#1}%
+ \normalexpanded{\endgroup\edef\noexpand#2{\ifnum\c_attr_color=\attributeunsetvalue\else\number\c_attr_color\fi}}}
+
+% \aliased\let\grey\graycolor % these macros are only used in tracing
+
+%D \macros
+%D {startcurrentcolor,stopcurrentcolor}
+
+\permanent\protected\def\startcurrentcolor{\startcolor[\outercolorname]}
+\permanent\protected\def\stopcurrentcolor {\stopcolor}
+
+%D \macros
+%D {setupcolor}
+%D
+%D Color definitions can be grouped in files with the name:
+%D
+%D \starttyping
+%D colo-imp-tag.tex
+%D \stoptyping
+%D
+%D Loading such a file is done by:
+%D
+%D \showsetup{usecolors}
+%D
+%D Some default colors are specified in \type {colo-imp-rgb}, which is loaded into
+%D the format by default.
+%D
+%D Some demo palets and groups are defined in \type {colo-imp-dem} which can be
+%D loaded with:
+%D
+%D \starttyping
+%D \usecolors[dem]
+%D \stoptyping
+
+\permanent\protected\def\startcolorset[#1]{\clf_startcolorset{#1}}
+\permanent\protected\def\stopcolorset {\clf_stopcolorset}
+\permanent\protected\def\usecolors [#1]{\clf_usecolors{#1}}
+
+\aliased\let\setupcolor\usecolors
+
+\installsetuponlycommandhandler \??color {colors}
+
+\let\colo_helpers_show_message\gobblethreearguments
+
+% \newtoks\everysetupcolors
+
+\let\v_colo_freeze_state\s!false
+
+\setvalue{\??colorconversions\v!yes}%
+ {\settrue \c_colo_convert_gray}
+
+\setvalue{\??colorconversions\v!always}%
+ {\settrue \c_colo_convert_gray
+ \setfalse\c_colo_rgb_supported
+ \setfalse\c_colo_cmyk_supported}
+
+\appendtoks
+ %
+ \doifelse{\directcolorsparameter\c!spot }\v!yes \settrue \setfalse\c_colo_spot_supported
+ \doifelse{\directcolorsparameter\c!expansion}\v!yes \settrue \setfalse\c_colo_expanded
+ \doifelse{\directcolorsparameter\c!rgb }\v!yes \settrue \setfalse\c_colo_rgb_supported
+ \doifelse{\directcolorsparameter\c!cmyk }\v!yes \settrue \setfalse\c_colo_cmyk_supported
+ \doifelse{\directcolorsparameter\c!state }\v!start\settrue \setfalse\c_colo_enabled
+ %
+ \edef\m_colo_weight_gray{\directcolorsparameter\c!factor}%
+ %
+ \ifconditional\c_colo_expanded
+ \let\v_colo_freeze_state\s!true
+ \else
+ \let\v_colo_freeze_state\s!false
+ \fi
+ %
+ \setfalse\c_colo_convert_gray
+ \begincsname\??colorconversions\directcolorsparameter\c!conversion\endcsname
+ % too often:
+ \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi
+ \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi
+ \colo_helpers_set_current_model
+ \ifproductionrun
+ \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}%
+ \clf_setpagecolormodel{\ifx\p_pagecolormodel\v!auto\currentcolormodel\else\p_pagecolormodel\fi}%
+ \fi
+\to \everysetupcolors
+
+\appendtoks
+ \setupcolors[\c!state=\v!start]%
+ \clf_enablecolor % this can as well happen when
+ \clf_enabletransparency % the handler is defined in lua
+ \let\colo_helpers_show_message\showmessage
+\to \everyjob
+
+%D We provide stacking independent of grouping.
+
+\newcount\c_colo_nesting
+
+\permanent\protected\def\pushcolor[#1]%
+ {\global\advance\c_colo_nesting\plusone
+ \edefcsname\??colorstack\number\c_colo_nesting\endcsname
+ {\c_attr_colormodel \the\c_attr_colormodel
+ \c_attr_color \the\c_attr_color
+ \c_attr_transparency\the\c_attr_transparency
+ \relax}% stack
+ \colo_helpers_activate{#1}}
+
+\permanent\protected\def\popcolor
+ {\csname\??colorstack\number\c_colo_nesting\endcsname
+ \global\advance\c_colo_nesting\minusone}
+
+% a simple one: assumes grouping
+
+\newcount\c_colo_saved_attribute_color
+\newcount\c_colo_saved_attribute_transparency
+
+\permanent\protected\def\savecolor
+ {\c_colo_saved_attribute_color \c_attr_color
+ \c_colo_saved_attribute_transparency\c_attr_transparency}
+
+\permanent\protected\def\restorecolor
+ {\c_attr_color \c_colo_saved_attribute_color
+ \c_attr_transparency\c_colo_saved_attribute_transparency}
+
+%D In this documentation we will not go into too much details on palets. Curious
+%D users can find more information on this topic in \from[use of color].
+%D
+%D At the moment we implemented color in \CONTEXT\ color printing was not yet on the
+%D desktop. In spite of this lack our graphics designer made colorfull
+%D illustrations. When printed on a black and white printer, distinctive colors can
+%D come out equally gray. We therefore decided to use only colors that were
+%D distinctive in colors as well as in black and white print.
+%D
+%D Although none of the graphic packages we used supported logical colors and global
+%D color redefition, we build this support into \CONTEXT. This enabled us to
+%D experiment and also prepared us for the future.
+
+%D \macros
+%D {definepalet}
+%D
+%D Colors are grouped in palets. The colors in such a palet can have colorful names,
+%D but best is to use names that specify their use, like {\em important} or {\em
+%D danger}. As a sort of example \CONTEXT\ has some palets predefined,
+%D like:\footnote{At the time I wrote the palet support, I was reading 'A hort
+%D history of time' of S.~Hawkins, so that's why we stuck to quarks.}
+%D
+%D \starttyping
+%D \definepalet
+%D [alfa]
+%D [ top=rood:7,
+%D bottom=groen:6,
+%D up=blauw:5,
+%D down=cyaan:4,
+%D strange=magenta:3,
+%D charm=geel:2]
+%D \stoptyping
+%D
+%D It's formal definition is:
+%D
+%D \showsetup{definepalet}
+%D
+%D Visualized, such a palet looks like:
+%D
+%D \startbuffer[palet]
+%D \showpalet [alfa] [horizontal,name,number,value]
+%D \stopbuffer
+%D
+%D \startlinecorrection
+%D \getbuffer[palet]
+%D \stoplinecorrection
+%D
+%D This bar shows both the color and gray alternatives of the palet components (not
+%D visible in black and white print).
+%D
+%D When needed, one can copy a palet by saying:
+%D
+%D \starttyping
+%D \definepalet [TEXcolorpretty] [colorpretty]
+%D \stoptyping
+%D
+%D This saves us some typing in for instance the modules that deal with pretty
+%D verbatim typesetting.
+
+\installcorenamespace{paletlist}
+\installcorenamespace{paletsize}
+
+\let\m_colo_palet\relax
+\let\c_colo_palet\relax
+
+\def\colo_palet_allocate#1%
+ {\letcsname\??paletlist#1\endcsname\empty
+ \ifcsname\??paletsize#1\endcsname\else
+ \expandafter\newcount\csname\??paletsize#1\endcsname
+ \fi}
+
+\def\colo_palet_prepare#1%
+ {\edef\colo_palet_name{#1}%
+ \ifcsname\??paletlist\colo_palet_name\endcsname
+ \csname\??paletsize\colo_palet_name\endcsname\zerocount
+ \else
+ \colo_palet_allocate\colo_palet_name
+ \fi
+ \enforced\expandafter\let\expandafter\c_colo_palet\csname\??paletsize\colo_palet_name\endcsname
+ \edef\m_colo_palet{\begincsname\??paletlist\colo_palet_name\endcsname}}
+
+\def\colo_palet_extend#1%
+ {\addtocommalist{#1}\m_colo_palet
+ \letcsname\??paletlist\colo_palet_name\endcsname\m_colo_palet
+ %\advance\csname\??paletsize\colo_palet_name\endcsname\plusone
+ \advance\c_colo_palet\plusone}
+
+\permanent\protected\def\doifelsecolorpalet#1%
+ {\ifcsname\??paletlist#1\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\mutable\let\paletlist\empty
+\mutable\let\paletsize\!!zerocount
+
+\permanent\protected\def\getpaletlist[#1]%
+ {\edef\paletlist{\begincsname\??paletlist#1\endcsname}}
+
+\permanent\protected\def\getpaletsize[#1]%
+ {\ifcsname\??paletsize#1\endcsname
+ \edef\paletsize{\the\lastnamedcs}%
+ \else
+ \let\paletsize\!!zerocount
+ \fi}
+
+\permanent\tolerant\protected\def\definepalet[#1]#*[#2]#*[#3]%
+ {\ifarguments
+ \expandafter\gobblethreearguments
+ \or
+ \expandafter\gobblethreearguments
+ \or
+ \expandafter\colo_palets_define_a
+ \or
+ \expandafter\colo_palets_define_b
+ \fi{#1}{#2}{#3}}
+
+\protected\def\colo_palets_define_a#1#2#3%
+ {\colo_palet_prepare{#1}%
+ \ifcondition\validassignment{#2}%
+ \edefcsname\??colorpaletspecification#1\endcsname{#2}%
+ \processcommalist[#2]{\colo_palets_define_one{#1}}%
+ \orelse\ifcsname\??colorpaletspecification#2\endcsname
+ \normalexpanded{\colo_palets_define_b{#1}{\lastnamedcs}\empty}%
+ \fi}
+
+\protected\def\colo_palets_define_b#1#2#3%
+ {\colo_palet_prepare{#1}%
+ \edefcsname\??colorpaletspecification#1\endcsname{#2}%
+ \colo_palet_extend{#2}%
+ \colo_palets_define_assign{#1}{#2}{#3}}
+
+% % or, it being not that critital, just this
+%
+% \permanent\tolerant\protected\def\definepalet[#1]#*[#2]#*[#3]%
+% {\ifarguments
+% \or
+% \or
+% \colo_palet_prepare{#1}%
+% \ifcondition\validassignment{#2}%
+% \setevalue{\??colorpaletspecification#1}{#2}%
+% \processcommalist[#2]{\colo_palets_define_one{#1}}%
+% \orelse\ifcsname\??colorpaletspecification#2\endcsname
+% \normalexpanded{\colo_palets_define_b{#1}{\lastnamedcs}{}}%
+% \fi
+% \or
+% \colo_palet_prepare{#1}%
+% \setevalue{\??colorpaletspecification#1}{#2}%
+% \colo_palet_extend{#2}%
+% \colo_palets_define_assign{#1}{#2}{#3}%
+% \fi}
+
+\def\colo_palets_define_one#1#2% get rid of { }
+ {\ifcondition\validassignment{#2}% catch empty entries
+ \colo_palets_define_two{#1}[#2]%
+ \else
+ \colo_palets_define_three{#1}{#2}%
+ \fi}
+
+\def\colo_palets_define_two#1[#2=#3]%
+ {\colo_palet_extend{#2}%
+ \colo_palets_define_set{#1}{#2}{#3}}%
+
+\def\colo_palets_define_three#1#2%
+ {\ifcsname\??colorpaletspecification#2\endcsname
+ \processcommacommand[\lastnamedcs]{\colo_palets_define_one{#1}}%
+ \fi}
+
+%D Instead of refering to colors, one can also directly specify a color:
+%D
+%D \starttyping
+%D \definepalet[test][xx=green]
+%D \definepalet[test][xx={y=.4}]
+%D \stoptyping
+
+%D \macros
+%D {setuppalet}
+%D
+%D Colors are taken from the current palet, if defined. Setting the current palet is
+%D done by:
+%D
+%D \showsetup{setuppalet}
+
+\newtoks\everysetuppalet
+
+% \newtoks\t_colo_prefix % used in mp interface
+
+\permanent\tolerant\protected\def\setuppalet[#1]%
+ {\edef\currentcolorpalet{#1}%
+ \ifempty\currentcolorpalet
+ % seems to be a reset
+ \let\currentcolorprefix\empty
+ %\t_colo_prefix\emptytoks
+ \orelse\ifcsname\??paletlist\currentcolorpalet\endcsname
+ \edef\currentcolorprefix{#1:}%
+ %\t_colo_prefix\expandafter{\currentcolorprefix}%
+ \else
+ \colo_helpers_show_message\m!colors7\currentcolorpalet
+ \let\currentcolorpalet\empty
+ \let\currentcolorprefix\empty
+ %\t_colo_prefix\emptytoks
+ \fi
+ \the\everysetuppalet
+ \colo_helpers_initialize_maintextcolor}
+
+%D \macros
+%D {showpalet}
+%D
+%D The previous visualization was typeset with:
+%D
+%D \typebuffer[palet]
+%D
+%D This commands is defined as:
+%D
+%D \showsetup{showpalet}
+
+\fetchmodulecommand \showpalet \f!colo_run
+
+%D \macros
+%D {showcolorcomponents}
+%D
+%D \starttyping
+%D \showcolorcomponents[color-1,color-2]
+%D \stoptyping
+
+\fetchmodulecommand \showcolorcomponents \f!colo_run
+
+%D \macros
+%D {comparepalet}
+%D
+%D There are some more testing macros available:
+%D
+%D \startbuffer
+%D \comparepalet [alfa]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D shows the palet colors against a background:
+%D
+%D \startlinecorrection
+%D \getbuffer
+%D \stoplinecorrection
+%D
+%D The formal definition is:
+%D
+%D \showsetup{comparepalet}
+
+\fetchmodulecommand \comparepalet \f!colo_run
+
+%D \macros
+%D {showcolor}
+%D
+%D But let's not forget that we also have the more traditional non||related colors.
+%D These show up after:
+%D
+%D \starttyping
+%D \showcolor [name]
+%D \stoptyping
+%D
+%D Where \type{name} for instance can be \type{rgb}.
+%D
+%D \showsetup{showcolor}
+
+\fetchmodulecommand \showcolor \f!colo_run
+
+%D It would make sense to put the following code in \type {colo-mps}, but it it
+%D rather low level.
+
+%D \macros
+%D {negatecolorcomponent,negatedcolorcomponent}
+%D
+%D These speak for themselves. See \type {colo-ext} for usage.
+
+\permanent\protected\def\negatecolorcomponent #1{\edef#1{\clf_negatedcolorcomponent{#1}}}
+\permanent \def\negatedcolorcomponent#1{\clf_negatedcolorcomponent{#1}}
+
+%D \macros
+%D {MPcolor}
+%D
+%D A very special macro is \type{\MPcolor}. This one can be used to pass a \CONTEXT\
+%D color to \METAPOST.
+%D
+%D \starttyping
+%D \MPcolor{my own red}
+%D \stoptyping
+%D
+%D This macro returns \METAPOST\ code that represents the
+%D color.
+%D
+%D For the moment we keep the next downward compatibility switch, i.e.\ expanded
+%D colors. However, predefined colors and palets are no longer expanded (which is
+%D what I wanted in the first place).
+%D
+%D In \MKIV\ we don't support color separation as we might now assume that printing
+%D houses have the right programs to do it themselves. If it's ever needed in \MKIV\
+%D It is relatively easy to support it in the backend code.
+
+% todo: palets in definecolor
+% todo: {\red xx} vs \red{xx}
+
+% \def\mptexcolor#1{"\dogetattributeid\s!color \somecolorattribute{#1} A"}
+%
+% \startMPpage
+% fill fullcircle scaled 10cm ;
+% fill fullcircle scaled 5cm withprescript \mptexcolor{red} withpostscript \mptexcolor{black} ;
+% fill fullcircle scaled 3cm ;
+% draw btex test etex withprescript \mptexcolor{blue} ;
+% \stopMPpage
+
+\permanent\protected\def\setcolormodel[#1]% % beware, \setupcolors will overload this, so this one is
+ {\colo_helpers_set_model{#1}} % only for local usage
+
+\def\colo_helpers_set_model#1% direct
+ {\edef\currentcolormodel{#1}%
+ \clf_setcolormodel{\currentcolormodel}{\m_colo_weight_gray}} % sets attribute at lua end
+
+\colo_helpers_set_model\s!all
+
+\def\colo_helpers_set_current_model
+ {\ifconditional\c_colo_enabled
+ \ifconditional\c_colo_rgb_supported
+ \ifconditional\c_colo_cmyk_supported
+ \colo_helpers_set_model\s!all
+ \else
+ \colo_helpers_set_model\s!rgb
+ \fi
+ \orelse\ifconditional\c_colo_cmyk_supported
+ \colo_helpers_set_model\s!cmyk
+ \orelse\ifconditional\c_colo_convert_gray
+ \colo_helpers_set_model\s!gray
+ \else
+ \colo_helpers_set_model\s!none
+ \fi
+ \orelse\ifconditional\c_colo_convert_gray
+ \colo_helpers_set_model\s!gray
+ \else
+ \colo_helpers_set_model\s!none
+ \fi}
+
+%D Currently in mkiv transparency is implemented independent of color. This costs a
+%D bit more processing time but gives the possibility to apply transparency
+%D independently in the future. Is this useful? If not we may as well combine them
+%D again in the future. By coupling we are downward compatible. When we decouple we
+%D need to do more tricky housekeeping (e.g. persist color independent
+%D transparencies when color bound ones are nil.
+
+% Since we couple definitions, we could stick to one test. Todo. Same for mpcolor.
+
+\def\v_colo_dummy_name{c_o_l_o_r}
+
+\letvalue{\??colorattribute \v_colo_dummy_name}\empty
+\letvalue{\??transparencyattribute\v_colo_dummy_name}\empty
+\letvalue{\??colorsetter \v_colo_dummy_name}\empty
+\letvalue{\??transparencysetter \v_colo_dummy_name}\empty
+
+\letvalue{\??colorsetter -}\empty % used?
+\letvalue{\??transparencysetter-}\empty % used?
+
+% new: expandable (see tbl preamble)
+
+\def\colo_helpers_direct_activate
+ {\ifempty\currentcolorprefix
+ \expandafter\colo_helpers_direct_activate_nop
+ \else
+ \expandafter\colo_helpers_direct_activate_yes
+ \fi}
+
+\def\colo_helpers_direct_activate_yes#1%
+ {\ifcsname\??colorsetter\currentcolorprefix#1\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter\currentcolorprefix#1\endcsname
+ \orelse\ifcsname\??colorsetter#1\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter#1\endcsname
+ \fi}
+
+\def\colo_helpers_direct_activate_nop#1%
+ {\ifcsname\??colorsetter#1\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter#1\endcsname
+ \fi}
+
+\def\colo_helpers_activate_dummy
+ {\begincsname\??colorsetter \v_colo_dummy_name\endcsname
+ \begincsname\??transparencysetter\v_colo_dummy_name\endcsname}
+
+% so far
+
+\permanent\protected\def\colo_helpers_activate#1% two-step is not that much faster but less tracing
+ {\edef\currentcolorname{#1}%
+ \ifempty\currentcolorprefix
+ \colo_helpers_activate_nop
+ \else
+ \colo_helpers_activate_yes
+ \fi}
+
+\def\colo_helpers_activate_yes
+ {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname
+ \orelse\ifcsname\??colorsetter\currentcolorname\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter\currentcolorname\endcsname
+ \fi}
+
+\def\colo_helpers_activate_nop
+ {\ifcsname\??colorsetter\currentcolorname\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter\currentcolorname\endcsname
+ \fi}
+
+\def\colo_helpers_activate_yes_only
+ {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??colorsetter\currentcolorname\endcsname
+ \lastnamedcs
+ \fi}
+
+\def\colo_helpers_activate_nop_only
+ {\ifcsname\??colorsetter\currentcolorname\endcsname
+ \lastnamedcs
+ \fi}
+
+\aliased\let\dousecolorparameter\colo_helpers_activate
+
+\permanent\protected\def\dousecolorhashparameter#1#2%
+ {\ifcsname#1#2\endcsname
+ \expandafter\dousecolorparameter\csname#1#2\endcsname
+ \fi}
+
+\permanent\protected\def\dousecurrentcolorparameter
+ {\let\currentcolorname\currentcolorparameter % maybe only when success
+ \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname
+ \orelse\ifcsname\??colorsetter\currentcolorparameter\endcsname
+ \lastnamedcs
+ \begincsname\??transparencysetter\currentcolorparameter\endcsname
+ \fi}
+
+\permanent\protected\def\deactivatecolor % sort of public but a bad name
+ {\let\currentcolorname\s!black
+ \c_attr_color \attributeunsetvalue
+ \c_attr_transparency\attributeunsetvalue}
+
+% todo: check if color is overloading a non-color command
+
+% \let\colo_basics_synchronize\gobbleoneargument % used in mp interface
+% \let\colo_basics_inherit \gobbletwoarguments % used in mp interface
+
+\def\colo_basics_allocate#1%
+ {\expandafter\newcount\csname\??colornumber#1\endcsname
+ \clf_synccolorcount{#1}\c_syst_last_allocated_count}
+
+\def\colo_basics_synchronize#1%
+ {\ifcsname\??colornumber#1\endcsname\else
+ \colo_basics_allocate{#1}%
+ \fi
+ \clf_synccolor{#1}%
+ %\csname\??colornumber#1\endcsname\csname\??colorattribute#1\endcsname
+ \lastnamedcs\csname\??colorattribute#1\endcsname}
+
+\let\colo_basics_inherit\clf_synccolorclone
+
+\newcount\c_colo_protection
+
+\permanent\protected\def\startprotectedcolors{\advance\c_colo_protection\plusone }
+\permanent\protected\def\stopprotectedcolors {\advance\c_colo_protection\minusone}
+
+\permanent\tolerant\protected\def\definecolor[#1]#*[#2]%
+ {\iftok{#1}{#2}%
+ % maybe a warning
+ \else
+ \clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
+ \colo_basics_synchronize{#1}%
+ \ifcase\c_colo_protection
+ \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}%
+ \fi
+ \fi}
+
+\permanent\tolerant\protected\def\defineglobalcolor[#1]#*[#2]%
+ {\iftok{#1}{#2}%
+ % maybe a warning
+ \else
+ \clf_defineprocesscolorglobal{#1}{#2}\v_colo_freeze_state\relax
+ \colo_basics_synchronize{#1}%
+ \ifcase\c_colo_protection
+ \protected\instance\setgvalue{#1}{\colo_helpers_activate{#1}}%
+ \fi
+ \fi}
+
+\aliased\let\definenamedcolor\definecolor
+
+\def\colo_basics_defined_and_activated#1%
+ {\clf_defineprocesscolordummy{#1}% we could pass dummy here too
+ \colo_basics_synchronize{\v_colo_dummy_name}%
+ \colo_helpers_activate_dummy}
+
+\permanent\tolerant\protected\def\defineprocesscolor[#1]#*[#2]#*[#3]%
+ {\ifarguments\or
+ \colo_basics_define_process_wrapup{#1}\empty
+ \or
+ \colo_basics_define_process_wrapup{#1}{#2}%
+ \or % we could just pass #3 to clf_... also when it's empty ... todo after split
+ \colo_basics_define_process_wrapup{#1}{\processcolorcomponents{#2},#3}%
+ \fi}
+
+\def\colo_basics_define_process_wrapup#1#2%
+ {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
+ \colo_basics_synchronize{#1}%
+ \ifcase\c_colo_protection
+ \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}%
+ \fi}
+
+%D Spotcolors used setxvalue but that messes up currentcolor and probably no global
+%D is needed either but they are global at the lua end (true argument) so we keep
+%D that if only because spot colors often are a document wide property
+
+\permanent\tolerant\protected\def\definespotcolor[#1]#*[#2]#*[#3]%
+ {\clf_definespotcolorglobal{#1}{#2}{#3}%
+ \colo_basics_synchronize{#1}%
+ \ifcase\c_colo_protection
+ \protected\instance\setgvalue{#1}{\colo_helpers_activate{#1}}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemultitonecolor[#1]#*[#2]#*[#3]#*[#4]%
+ {\clf_definemultitonecolorglobal{#1}{#2}{#3}{#4}%
+ \colo_basics_synchronize{#1}%
+ \ifcase\c_colo_protection
+ \protected\instance\setgvalue{#1}{\colo_helpers_activate{#1}}%
+ \fi}
+
+%D Transparencies (only):
+
+\permanent\tolerant\protected\def\definetransparency[#1]#*[#2]%
+ {\clf_definetransparency{#1}{#2}}
+
+\permanent\tolerant\protected\def\defineglobaltransparency[#1]#*[#2]%
+ {\clf_definetransparencyglobal{#1}{#2}}
+
+% A goodie that replaces the startMPcolor hackery
+
+% \definecolor[red-t] [r=1,t=0.5,a=1]
+% \definecolor[green-t][g=1,t=0.5,a=1]
+%
+% \defineintermediatecolor[mycolora][0.5,red,green]
+% \defineintermediatecolor[mycolorb][0.5,red-t,green-t]
+%
+% \definecolor[mycolorc][.5(blue,red)]
+% \definecolor[mycolord][.5(blue)]
+% \definecolor[mycolord][-.5(blue,red)] % complement
+% \definecolor[mycolord][-(blue)] % complement
+%
+% \enabledirectives[colors.pgf]
+% \definecolor[mycolorx][magenta!50!yellow]
+%
+% \starttext
+% test {\mycolora OEPS} test
+% test {\mycolorb OEPS} test
+% test {\mycolorc OEPS} test
+% test {\mycolord OEPS} test
+% test {\mycolorx OEPS} test
+% \stoptext
+%
+% Beware: if we say:
+%
+% \definecolor[one][two]
+%
+% Only color one is actually defined and two is not seen at the \LUA\ end. This
+% means that this doesn't work:
+%
+% \definecolor[ColorA][red]
+% \definecolor[ColorB][.5(ColorA)]
+% \definecolor[ColorC][.5(ColorB,white)]
+%
+% But this does work:
+%
+% \definecolor[ColorA][1.0(red)]
+% \definecolor[ColorB][0.5(ColorA)]
+% \definecolor[ColorC][0.5(ColorB,white)]
+%
+% because the fractional definition results in a new definition.
+
+\permanent\tolerant\protected\def\defineintermediatecolor[#1]#*[#2]#*[#3]
+ {\colo_basics_define_intermediate_indeed[#1][#2][#3]}
+
+\def\colo_basics_define_intermediate_indeed[#1][#2,#3,#4][#5]%
+ {\clf_defineintermediatecolor % not global
+ {#1}%
+ {#2}%
+ \rawcolorattribute{#3} %
+ \rawcolorattribute{#4} %
+ \rawtransparencyattribute{#3} %
+ \rawtransparencyattribute{#4} %
+ {#5}%
+ \v_colo_freeze_state
+ \relax
+ \colo_basics_synchronize{#1}%
+ \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}}
+
+%D Here is a more efficient helper for pgf:
+%D
+%D \starttyping
+%D \startluacode
+%D function commands.pgfxcolorspec(ca) -- {}{}{colorspace}{list}
+%D local cv = attributes.colors.values[ca]
+%D if cv then
+%D local model = cv[1]
+%D if model == 2 then
+%D context("{}{}{gray}{%1.3f}",cv[2])
+%D elseif model == 3 then
+%D context("{}{}{rgb}{%1.3f,%1.3f,%1.3f}",cv[3],cv[4],cv[5])
+%D elseif model == 4 then
+%D context("{}{}{cmyk}{%1.3f,%1.3f,%1.3f,%1.3f}",cv[6],cv[7],cv[8],cv[9])
+%D else
+%D context("{}{}{gray}{%1.3f}",cv[2])
+%D end
+%D else
+%D context("{}{}{gray}{0}")
+%D end
+%D end
+%D \stopluacode
+%D
+%D \def\pgfutil@registercolor#1%
+%D {\setevalue{\string\color@#1}{\noexpand\xcolor@\ctxcommand{pgfxcolorspec(\thecolorattribute{#1})}}}
+%D
+%D \definecolor [darkblue] [r=0,g=0,b=0.5]
+%D
+%D \starttikzpicture
+%D \fill [blue] (0,0) circle(1);
+%D \fill [darkblue] (0,0) circle(1);
+%D \stoptikzpicture
+%D \stoptyping
+%D
+%D \stopmode
+%D
+%D All this will move to m-tikz.mkxl as it doesn't belong in the core. They are
+%D mutable because \quote {who knows what gets redefined}.
+
+\mutable\let\color@ \relax
+\mutable\let\xcolor@\relax
+
+\mutable\protected\def\pgf@context@registercolor#1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}}
+\mutable\protected\def\pgf@context@registergray #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}}
+\mutable\protected\def\pgf@context@registerrgb #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}}
+\mutable\protected\def\pgf@context@registercmyk #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}}
+
+%D \starttyping
+%D \ifdefined\pgf@context@registercolor
+%D \let\pgfutil@registercolor\pgf@context@registercolor
+%D \fi
+%D \stoptyping
+
+%D \macros
+%D {doifcolorelse, doifcolor}
+%D
+%D Switching to a color is done by means of the following command. Later on we will
+%D explain the use of palets. We define ourselves a color conditional first.
+
+\permanent\def\doifelsecolor#1%
+ {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
+ \expandafter\firstoftwoarguments
+ \orelse\ifcsname\??colorattribute#1\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifcolorelse\doifelsecolor
+
+\permanent\def\doifcolor#1%
+ {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
+ \expandafter\firstofoneargument
+ \orelse\ifcsname\??colorattribute#1\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+%D \macros
+%D {startregistercolor,stopregistercolor,permitcolormode}
+%D
+%D If you only want to register a color, the switch \type {\ifpermitcolormode} can
+%D be used. That way the nested colors know where to go back to.
+%D
+%D We use these macros for implementing text colors (actually, the first application
+%D was in foreground colors).
+%D
+%D \starttyping
+%D \starttextcolor[red]
+%D \dorecurse{10}{\input tufte \color[green]{oeps} \par}
+%D \stoptextcolor
+%D \stoptyping
+%D
+%D This is more efficient than the alternative:
+%D
+%D \starttyping
+%D \setupbackgrounds[text][foregroundcolor=red]
+%D \startregistercolor[red]
+%D \dorecurse{10}{\input tufte \color[green]{oeps} \par}
+%D \stopregistercolor
+%D \stoptyping
+
+\mutable\let\maintextcolor \empty
+\mutable\def\defaulttextcolor{black}
+
+\permanent\protected\def\inheritmaintextcolor
+ {\ifempty\maintextcolor\else\colo_helpers_activate\maintextcolor\fi}
+
+\permanent\protected\def\onlyinheritmaintextcolor
+ {\ifempty\maintextcolor
+ \deactivatecolor
+ \else
+ \colo_helpers_activate\maintextcolor
+ \fi}
+
+\appendtoks
+ \deactivatecolor % public?
+ \inheritmaintextcolor
+\to \everybeforeoutput
+
+\def\colo_helpers_switch_to_maintextcolor#1%
+ {\let\maintextcolor\s!themaintextcolor
+ \definecolor[\maintextcolor][#1]% can be fast one
+ \colo_helpers_activate\maintextcolor
+ \clf_registermaintextcolor\thecolorattribute\maintextcolor\relax}
+
+\permanent\protected\def\starttextcolor[#1]%
+ {\doifsomething{#1}{\colo_helpers_switch_to_maintextcolor{#1}}}
+
+\aliased\let\stoptextcolor\relax
+
+\let\p_colo_textcolor\empty
+
+\def\colo_helpers_initialize_maintextcolor
+ {\edef\p_colo_textcolor{\directcolorsparameter\c!textcolor}%
+ \ifempty\p_colo_textcolor
+ \colo_helpers_switch_to_maintextcolor\defaulttextcolor
+ \else
+ \colo_helpers_switch_to_maintextcolor\p_colo_textcolor
+ \fi}
+
+\appendtoks \colo_helpers_initialize_maintextcolor \to \everyjob
+\appendtoks \colo_helpers_initialize_maintextcolor \to \everysetupcolors
+
+\letvalue{\??colorsetter }\empty \letvalue{\??colorattribute }\!!zerocount
+\letvalue{\??transparencysetter}\empty \letvalue{\??transparencyattribute}\!!zerocount
+
+\def\colo_helpers_inherited_direct_cs#1{\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
+\def\colo_helpers_inherited_direct_ca#1{\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_direct_ts#1{\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
+\def\colo_helpers_inherited_direct_ta#1{\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
+
+\let\colo_defcsname\defcsname
+\let\colo_endcsname\endcsname
+
+\appendtoks
+ \ifconditional\c_colo_expanded
+ \let\colo_defcsname\edefcsname
+ \else
+ \let\colo_defcsname\defcsname
+ \fi
+\to \everysetupcolors
+
+\def\colo_palets_define_set#1#2#3%
+ {\ifcondition\validassignment{#3}% \definepalet[test][xx={y=.4}]
+ \expandafter\colo_palets_define_assign
+ \orelse\ifcsname\??colorsetter#3\endcsname
+ % \definepalet[test][xx=green]
+ \expandafter\colo_palets_define_inherit
+ \else
+ % not entered when making format
+ \expandafter\colo_palets_define_undefine
+ \fi
+ {#1}{#2}{#3}}
+
+\def\colo_palets_define_inherit#1#2#3%
+ {\colo_basics_inherit{#1:#2}{#3}%
+ \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{#3}}%
+ \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{#3}}%
+ \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{#3}}%
+ \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{#3}}}
+
+\def\colo_palets_define_undefine#1#2#3%
+ {\letcsname\??colorsetter #1:#2\endcsname\undefined
+ \letcsname\??colorattribute #1:#2\endcsname\undefined
+ \letcsname\??transparencysetter #1:#2\endcsname\undefined
+ \letcsname\??transparencyattribute#1:#2\endcsname\undefined}
+
+\def\colo_palets_define_assign#1#2#3%
+ {\definecolor[\??colorpalet#1:#2][#3]%
+ \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}%
+ \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}%
+ \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}%
+ \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}}
+
+\setvalue{\??colorattribute currentcolor}{\the\c_attr_color} % for mpcolor
+\setvalue{\??transparencyattribute currentcolor}{\the\c_attr_transparency} % for mpcolor
+
+\def\colo_helpers_inherited_current_ca#1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_current_cs#1{\ifcsname\??colorsetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
+\def\colo_helpers_inherited_current_ta#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_current_ts#1{\ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
+
+%D Low level defs:
+
+\permanent\protected\def\colordefalc#1#2{\edefcsname\??colorattribute #1\endcsname{#2}%
+ \defcsname \??colorsetter #1\endcsname{\c_attr_color #2 }}
+\permanent\protected\def\colordefagc#1#2{\xdefcsname\??colorattribute #1\endcsname{#2}%
+ \gdefcsname\??colorsetter #1\endcsname{\c_attr_color #2 }} % was not g
+\permanent\protected\def\colordefalt#1#2{\edefcsname\??transparencyattribute#1\endcsname{#2}%
+ \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }}
+\permanent\protected\def\colordefagt#1#2{\xdefcsname\??transparencyattribute#1\endcsname{#2}%
+ \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }}
+
+\permanent\protected\def\colordefflc#1#2{\defcsname \??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}%
+ \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}}
+\permanent\protected\def\colordeffgc#1#2{\gdefcsname\??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}%
+ \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}}
+\permanent\protected\def\colordefflt#1#2{\defcsname \??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}%
+ \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}}
+\permanent\protected\def\colordeffgt#1#2{\gdefcsname\??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}%
+ \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}}
+
+\permanent\protected\def\colordefrlc #1{\letcsname \??colorattribute #1\endcsname\undefined
+ \letcsname \??colorsetter #1\endcsname\undefined}
+\permanent\protected\def\colordefrgc #1{\gletcsname\??colorattribute #1\endcsname\undefined
+ \gletcsname\??colorsetter #1\endcsname\undefined}
+\permanent\protected\def\colordefrlt #1{\letcsname \??transparencyattribute#1\endcsname\undefined
+ \letcsname \??transparencysetter #1\endcsname\undefined}
+\permanent\protected\def\colordefrgt #1{\gletcsname\??transparencyattribute#1\endcsname\undefined
+ \gletcsname\??transparencysetter #1\endcsname\undefined}
+
+%D \macros
+%D {colorvalue, grayvalue}
+%D
+%D We can typeset the color components using \type {\colorvalue} and \type
+%D {\grayvalue}. The commands:
+%D
+%D \startbuffer
+%D color value of SomeKindOfRed: \colorvalue{SomeKindOfRed} \crlf
+%D gray value of SomeKindOfRed: \grayvalue{SomeKindOfRed}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D show us:
+%D
+%D \startexample
+%D \getbuffer
+%D \stopexample
+
+\mutable\let\currentcolorname\s!black % todo
+\mutable\let\outercolorname \s!black % todo
+
+\mutable\let\colorformatseparator\space
+
+\permanent\def\MPcolor#1%
+ {\clf_mpcolor
+ \c_attr_colormodel
+ \colo_helpers_inherited_current_ca{#1} %
+ \colo_helpers_inherited_current_ta{#1} }
+
+\permanent\def\MPcoloronly#1%
+ {\clf_mpcolor
+ \c_attr_colormodel
+ \colo_helpers_inherited_current_ca{#1} %
+ \zerocount}
+
+\permanent\def\MPtransparency#1%
+ {\clf_mpcolor
+ \zerocount
+ \zerocount
+ \colo_helpers_inherited_current_ta{#1} }
+
+\permanent\def\MPoptions#1%
+ {\clf_mpoptions
+ \c_attr_colormodel
+ \colo_helpers_inherited_current_ca{#1} %
+ \colo_helpers_inherited_current_ta{#1} }
+
+\permanent\def\rawcolormodelattribute {\c_attr_colormodel}
+\permanent\def\thecolormodelattribute {\the\c_attr_colormodel}
+
+\permanent\def\rawcolorattribute #1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
+\permanent\def\rawtransparencyattribute#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
+
+\permanent\def\thecolorattribute #1{\number\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
+\permanent\def\thetransparencyattribute#1{\number\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
+
+\permanent\def\internalspotcolorname #1{\clf_spotcolorname \rawcolorattribute{#1}}
+\permanent\def\internalspotcolorparent #1{\clf_spotcolorparent\rawcolorattribute{#1}}
+\permanent\def\internalspotcolorsize #1{\clf_spotcolorvalue \rawcolorattribute{#1}}
+
+\permanent\def\colorcomponents #1{\clf_colorcomponents \rawcolorattribute {#1}}
+\permanent\def\transparencycomponents #1{\clf_transparencycomponents\rawtransparencyattribute{#1}}
+\permanent\def\processcolorcomponents #1{\clf_processcolorcomponents\rawcolorattribute {#1}}
+
+\permanent\def\colorvalue #1{\clf_formatcolor\rawcolorattribute{#1}{\colorformatseparator}}
+\permanent\def\grayvalue #1{\clf_formatgray \rawcolorattribute{#1}{\colorformatseparator}}
+
+\permanent\def\doifelseblack #1{\clf_doifelseblack\rawcolorattribute{#1}}
+\permanent\def\doifelsedrawingblack {\clf_doifelsedrawingblack}
+
+\aliased\let\doifblackelse \doifelseblack
+\aliased\let\doifdrawingblackelse \doifelsedrawingblack
+
+%D \macros
+%D {forcecolorhack}
+%D
+%D We can out this in front of (for instance) a special and so force color to be
+%D applied (only glyphs, rules and leaders are handled).
+%D
+%D \startbuffer
+%D \framed
+%D [background=color,backgroundcolor=yellow,framecolor=red,corner=round]
+%D {test}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+% ignores in attribute handler
+%
+% \def\forcecolorhack{\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint}
+
+% \normal added else fails in metafun manual (leaders do a hard scan)
+
+% \protected\def\forcecolorhack{\leaders\hrule\hskip\zeropoint\relax} % relax is needed !
+%
+% I really need to sort this out!
+
+\permanent\protected\def\forcecolorhack{\leaders\hrule\s!height\zeropoint\s!depth\zeropoint\hskip\zeropoint\relax} % relax is needed !
+
+%D We default to the colors defined in \type {colo-imp-rgb} and support both \RGB\
+%D and \CMYK\ output. Transparencies are defined here:
+
+\definecolor[black][s=0]
+\definecolor[white][s=1]
+
+\definetransparency [none] [0]
+\definetransparency [normal] [1]
+\definetransparency [multiply] [2]
+\definetransparency [screen] [3]
+\definetransparency [overlay] [4]
+\definetransparency [softlight] [5]
+\definetransparency [hardlight] [6]
+\definetransparency [colordodge] [7]
+\definetransparency [colorburn] [8]
+\definetransparency [darken] [9]
+\definetransparency [lighten] [10]
+\definetransparency [difference] [11]
+\definetransparency [exclusion] [12]
+\definetransparency [hue] [13]
+\definetransparency [saturation] [14]
+\definetransparency [color] [15]
+\definetransparency [luminosity] [16]
+
+%D Some common ones:
+
+\definecolor[trace:0][s=.4]
+\definecolor[trace:1][r=.6]
+\definecolor[trace:2][g=.6]
+\definecolor[trace:3][b=.6]
+\definecolor[trace:4][r=.6,g=.6]
+\definecolor[trace:5][r=.6,b=.6]
+\definecolor[trace:6][g=.6,b=.6]
+\definecolor[trace:7][r=.8,g=.4]
+\definecolor[trace:8][r=.8,b=.4]
+\definecolor[trace:9][g=.4,b=.8]
+
+\definecolor[trace:w][s=1]
+\definecolor[trace:r][r=.75,t=.5,a=1]
+\definecolor[trace:g][g=.75,t=.5,a=1]
+\definecolor[trace:b][b=.75,t=.5,a=1]
+%definecolor[trace:c][c=.75,t=.5,a=1]
+%definecolor[trace:m][m=.75,t=.5,a=1]
+%definecolor[trace:y][y=.75,t=.5,a=1]
+\definecolor[trace:c][g=.75,b=.75,t=.5,a=1]
+\definecolor[trace:m][r=.75,b=.75,t=.5,a=1]
+\definecolor[trace:y][r=.75,g=.75,t=.5,a=1]
+\definecolor[trace:s][s=.75,t=.5,a=1]
+\definecolor[trace:d][s=.25,t=.5,a=1]
+\definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1]
+
+\definecolor[trace:dw][s=1]
+\definecolor[trace:dr][r=.75,t=.75,a=1]
+\definecolor[trace:dg][g=.75,t=.75,a=1]
+\definecolor[trace:db][b=.75,t=.75,a=1]
+%definecolor[trace:dc][c=.75,t=.75,a=1]
+%definecolor[trace:dm][m=.75,t=.75,a=1]
+%definecolor[trace:dy][y=.75,t=.75,a=1]
+\definecolor[trace:dc][g=.75,b=.75,t=.75,a=1]
+\definecolor[trace:dm][r=.75,b=.75,t=.75,a=1]
+\definecolor[trace:dy][r=.75,g=.75,t=.75,a=1]
+\definecolor[trace:ds][s=.75,t=.75,a=1]
+\definecolor[trace:dd][s=.25,t=.75,a=1]
+\definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1]
+
+\setupcolors
+ [\c!state=\v!stop, % color will be enabled later on
+ \c!conversion=\v!yes,
+ \c!rgb=\v!yes,
+ \c!cmyk=\v!yes,
+ \c!spot=\v!yes,
+ \c!pagecolormodel=\v!none,
+ \c!expansion=\v!no,
+ \c!textcolor=,
+ \c!factor=\v!yes]
+
+\setupcolor
+ [\v!rgb]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/colo-nod.lmt b/Master/texmf-dist/tex/context/base/mkxl/colo-nod.lmt
new file mode 100644
index 00000000000..67487fee522
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/colo-nod.lmt
@@ -0,0 +1,40 @@
+if not modules then modules = { } end modules ['node-tra'] = {
+ version = 1.001,
+ comment = "companion to node-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local nuts = nodes.nuts
+
+local setattrs = nuts.setattrs
+
+local privateattributes = attributes.private
+
+local a_colormodel = privateattributes('colormodel')
+local a_color = privateattributes('color')
+local a_transparency = privateattributes('transparency')
+
+local colors = { }
+nuts.colors = colors
+
+function colors.set(n,ma,ca,ta) -- we could also do layers here
+ if ca then
+ if ca > 0 then
+ if not ma or ma == 0 then
+ ma = 1
+ end
+ if ta then
+ setattrs(n,a_colormodel,ma,a_color,ca,a_transparency,ta)
+ else
+ setattrs(n,a_colormodel,ma,a_color,ca)
+ end
+ end
+ elseif ta then
+ if ta > 0 then
+ setattr(n,a_transparency,ta)
+ end
+ end
+ return n
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/colo-nod.mkxl b/Master/texmf-dist/tex/context/base/mkxl/colo-nod.mkxl
new file mode 100644
index 00000000000..3cc3db03366
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/colo-nod.mkxl
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=colo-nod,
+%D version=2020.12.03,
+%D title=\CONTEXT\ Color Macros,
+%D subtitle=Nodes,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Color Macros / Nodes}
+
+%D In \LMTX\ we moved some code here.
+
+\registerctxluafile{colo-nod}{}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-cs.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-cs.mkxl
new file mode 100644
index 00000000000..2167b568f92
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-cs.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-cs,
+%D version=1998.12.02,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ Czech Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {czech}
+\immutable\def\defaultlanguagetag{cs}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-de.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-de.mkxl
new file mode 100644
index 00000000000..1f54bbb30a0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-de.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-de,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ German Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {german}
+\immutable\def\defaultlanguagetag{de}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-en.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-en.mkxl
new file mode 100644
index 00000000000..5dd02f7d472
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-en.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-en,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ English Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {english}
+\immutable\def\defaultlanguagetag{en}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-fil.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-fil.mkxl
new file mode 100644
index 00000000000..0ca3bb05acd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-fil.mkxl
@@ -0,0 +1,152 @@
+%D \module
+%D [ file=cont-fil,
+%D version=1997.11.15,
+%D title=\CONTEXT\ Miscellaneous Macros,
+%D subtitle=File Synonyms,
+%D author=J. Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Todo: use full names and remove calls at the tex end (now integrated in \LUA\
+%D library code .. then we can load it at runtime when needed. We can also remove
+%D some of the names that no longer make sense for \LMTX.
+
+\writestatus{loading}{ConTeXt File Synonyms}
+
+\definefilesynonym [chemics] [chemic]
+
+\definefilesynonym [unit] [units]
+
+\definefilesynonym [pstric] [pstricks]
+\definefilesynonym [pstrick] [pstricks]
+
+\definefilesynonym [finance] [financ]
+
+\definefilesynonym [dir-make] [dir-01]
+\definefilesynonym [dir-identify] [dir-05]
+
+\definefilesynonym [int-load] [set-11]
+\definefilesynonym [int-make] [set-12]
+
+ \definefilesynonym [fig-base] [fig-00]
+ \definefilesynonym [fig-make] [fig-01]
+ \definefilesynonym [fig-fake] [fig-02]
+ \definefilesynonym [fig-missing] [fig-06]
+
+ \definefilesynonym [exi-interface] [exi-21]
+
+ \definefilesynonym [res-make] [res-01]
+ \definefilesynonym [res-base] [res-04]
+ \definefilesynonym [res-crop] [res-07]
+ \definefilesynonym [res-trace] [res-08]
+ \definefilesynonym [res-log] [res-09]
+ \definefilesynonym [res-identify] [res-12]
+
+ \definefilesynonym [med-show] [res-50]
+
+\definefilesynonym [pre-general] [pre-00]
+\definefilesynonym [pre-original] [present-original]
+\definefilesynonym [pre-green] [present-green]
+\definefilesynonym [pre-funny] [present-funny]
+\definefilesynonym [pre-colorful] [present-colorful]
+\definefilesynonym [pre-fuzzy] [present-fuzzy]
+\definefilesynonym [pre-polish] [pre-06]
+\definefilesynonym [pre-spider] [pre-07]
+\definefilesynonym [pre-wonder] [pre-08]
+\definefilesynonym [pre-windows] [present-windows]
+\definefilesynonym [pre-grow] [present-grow]
+\definefilesynonym [pre-stack] [present-stack]
+\definefilesynonym [pre-split] [present-split]
+\definefilesynonym [pre-balls] [present-balls]
+\definefilesynonym [pre-weird] [present-weird]
+\definefilesynonym [pre-stepwise] [present-stepwise]
+\definefilesynonym [pre-stepper] [present-stepper]
+\definefilesynonym [pre-punk] [present-punk]
+\definefilesynonym [pre-random] [present-random]
+
+\definefilesynonym [pre-arrows] [pre-12]
+\definefilesynonym [pre-writing] [pre-13]
+\definefilesynonym [pre-knot] [pre-16]
+\definefilesynonym [pre-shade] [pre-18]
+\definefilesynonym [pre-organic] [pre-19]
+\definefilesynonym [pre-speckle] [pre-20]
+\definefilesynonym [pre-zoom] [pre-21]
+\definefilesynonym [pre-cycle] [pre-22]
+\definefilesynonym [pre-super] [pre-23]
+\definefilesynonym [pre-more] [pre-26]
+
+\definefilesynonym [pre-01] [present-original]
+\definefilesynonym [pre-02] [present-green]
+\definefilesynonym [pre-03] [present-funny]
+\definefilesynonym [pre-04] [present-colorful]
+\definefilesynonym [pre-05] [present-fuzzy]
+\definefilesynonym [pre-09] [present-windows]
+\definefilesynonym [pre-10] [present-grow]
+\definefilesynonym [pre-11] [present-stack]
+\definefilesynonym [pre-14] [present-split]
+\definefilesynonym [pre-15] [present-balls]
+\definefilesynonym [pre-17] [present-weird]
+\definefilesynonym [pre-41] [present-tiles]
+\definefilesynonym [pre-60] [present-stepwise]
+\definefilesynonym [pre-61] [present-stepper]
+\definefilesynonym [pre-62] [present-overlap]
+\definefilesynonym [pre-69] [present-wobbling]
+\definefilesynonym [pre-70] [present-punk]
+\definefilesynonym [pre-71] [present-random]
+
+\definefilesynonym [abr-01] [abbreviations-pseudocaps]
+\definefilesynonym [abr-02] [abbreviations-smallcaps]
+\definefilesynonym [abr-03] [abbreviations-words]
+\definefilesynonym [abr-04] [abbreviations-mixed]
+
+\definefilesynonym [art-01] [article-basic]
+\definefilesynonym [article] [article-basic]
+\definefilesynonym [mag-01] [magazine-basic]
+\definefilesynonym [magazine] [magazine-basic]
+\definefilesynonym [mod-01] [module-basic]
+\definefilesynonym [module] [module-basic]
+
+\definefilesynonym [map-10] [maps] % for a while
+
+\definefilesynonym [mml] [mathml]
+\definefilesynonym [cml] [chemml]
+
+\definefilesynonym [letter] [cor-01]
+\definefilesynonym [memo] [cor-02]
+\definefilesynonym [resume] [cor-03]
+
+\definefilesynonym [fnt-10] [fonts-complete]
+\definefilesynonym [fnt-11] [fonts-system]
+\definefilesynonym [fnt-20] [fonts-steps]
+\definefilesynonym [fnt-21] [fonts-steps]
+\definefilesynonym [fnt-22] [fonts-engines]
+\definefilesynonym [fnt-23] [fonts-shapes]
+\definefilesynonym [fnt-24] [fonts-cjk]
+\definefilesynonym [fnt-25] [math-characters]
+\definefilesynonym [fnt-28] [fonts-goodies]
+\definefilesynonym [fnt-29] [fonts-shapes]
+\definefilesynonym [fnt-31] [fonts-coverage]
+\definefilesynonym [fnt-33] [math-coverage]
+
+\definefilesynonym [mat-10] [math-characters]
+\definefilesynonym [mat-11] [math-characters]
+\definefilesynonym [mat-12] [math-parameters]
+\definefilesynonym [mat-20] [math-parameters]
+
+\definefilesynonym [syn-01] [syntax]
+
+\definefilesynonym [reg-01] [regimes-list]
+
+\definefilesynonym [set-11] [setups-basics]
+\definefilesynonym [set-12] [setups-overview]
+%definefilesynonym [set-13] [setups-proofing]
+%definefilesynonym [set-15] [setups-generate]
+
+\definefilesynonym [ecmascript] [libs-imp-mujs]
+\definefilesynonym [zint] [libs-imp-zint]
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-fr.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-fr.mkxl
new file mode 100644
index 00000000000..baee1ec71c8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-fr.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-de,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ French Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {french}
+\immutable\def\defaultlanguagetag{fr}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-gb.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-gb.mkxl
new file mode 100644
index 00000000000..0c3197a3e66
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-gb.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-uk,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ English Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {english}
+\immutable\def\defaultlanguagetag{gb}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-it.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-it.mkxl
new file mode 100644
index 00000000000..0491c2efd7a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-it.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-it,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ Italian Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {italian}
+\immutable\def\defaultlanguagetag{it}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-log.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-log.mkxl
new file mode 100644
index 00000000000..4df509f608f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-log.mkxl
@@ -0,0 +1,306 @@
+%D \module
+%D [ file=cont-log,
+%D version=1995.10.10,
+%D title=\CONTEXT\ Miscellaneous Macros,
+%D subtitle=\TEX\ Logos,
+%D author=J. Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt TeX Logos}
+
+%D The system that is used to typeset this text is called \TEX, typeset with an
+%D lowered~E. From te beginning of \TEX, authors of macro packages adapted this
+%D raising and lowering style. In this module we define some of those logos.
+
+%D We define the uppercase logo commands as (unfrozen) instances because they can be
+%D redefined in the synonyms modules.
+
+\unprotect
+
+\frozen\instance\protected\def\TeX
+ {\dontleavehmode
+ \begingroup
+ T%
+ \setbox\scratchbox\hbox{M}%
+ \kern-.1667\wd\scratchbox
+ \lower.5\exheight\hbox{E}%
+ \kern-.125\wd\scratchbox
+ X%
+ \endgroup}
+
+\frozen\instance\protected\def\TeXsuffix{\wordboundary\TeX}
+\frozen\instance\protected\def\TeXprefix{\TeX\wordboundary}
+
+\frozen\instance\protected\def\ConTeXt
+ {\dontleavehmode
+ \begingroup
+ Con%
+ \wordboundary
+ \setbox\scratchboxone\hbox{T\kern\zeropoint e}%
+ \setbox\scratchboxtwo\hbox{Te}%
+ \discretionary{-}{}{\kern\dimexpr\wd\scratchboxtwo-\wd\scratchboxone\relax}%
+ \TeX t%
+ \endgroup}
+
+\frozen\instance\protected\def\PPCHTeX{ppch\TeX}
+
+\frozen\instance\protected\def\LaTeX % requested by erik frambach
+ {\dontleavehmode
+ \begingroup
+ \setbox\scratchbox\hbox{L}%
+ \scratchdimen\ht\scratchbox
+ \setbox\scratchbox\hbox{\doresetattribute{case}\txx A}%
+ L\kern-.55\wd\scratchbox
+ \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}%
+ \kern-.2\wd\scratchbox\TeX
+ \endgroup}
+
+\frozen\instance\protected\def\TaBlE
+ {T%
+ \kern-.27\emwidth\lower.5\exheight\hbox{A}%
+ \kern-.18\emwidth B%
+ \kern-.1\emwidth\lower.5\exheight\hbox{L}%
+ \kern-.075\emwidth E}
+
+\frozen\instance\protected\def\PiCTeX
+ {P%
+ \kern-.12\emwidth\lower.5\exheight\hbox{I}%
+ \kern-.075\emwidth C%
+ \kern-.11\emwidth\TeX}
+
+\def\syst_logos_ams_script#1%
+ {\normalstartimath
+ \cal\ifdim\bodyfontsize>1.1\emwidth\scriptstyle\fi#1%
+ \normalstopimath}
+
+\frozen\instance\protected\def\AmSTeX
+ {\dontleavehmode
+ \syst_logos_ams_script A%
+ \kern-.1667\emwidth\lower.5\exheight\hbox{\syst_logos_ams_script M}%
+ \kern-.125\emwidth\syst_logos_ams_script S%
+ -\TeX}
+
+\frozen\instance\protected\def\LamSTeX
+ {L%
+ \kern-.4\emwidth\raise.3\exheight\hbox{\syst_logos_ams_script A}%
+ \kern-.25\emwidth\lower.4\exheight\hbox{\syst_logos_ams_script M}%
+ \kern-.1\emwidth{\syst_logos_ams_script S}%
+ -\TeX}
+
+%D Alternative \CONTEXT\ logo, first Idris S.~Hamid's version:
+%D
+%D \def\Context
+%D {{\sc C\kern -.0667emo\kern -.0667emn\kern -.0549emt\kern
+%D -.1667em\lower.5ex\hbox {e}\kern -.125emx\kern -.0549emt}}
+%D
+%D I changed this into one that adapts itself:
+
+\frozen\instance\protected\def\Context % wrong usage of \getscaledglyph
+ {\dontleavehmode
+ \begingroup
+ C%
+ \kern -.0667\emwidth
+ \getscaledglyph{.8}\empty{%
+ O\kern-.0667\emwidth
+ N%
+ \discretionary{-}{}{\kern-.0549\emwidth}%
+ T%
+ \doifelseitalic{\kern-.1\emwidth}{\kern-.1667\emwidth}%
+ \lower.5\exheight\hbox{E}%
+ \doifelseitalic\empty{\kern-.11em}%
+ X%
+ \kern-.055\emwidth
+ T%
+ }%
+ \endgroup}
+
+%D The \METAFONT\ and \METAPOST\ logos adapt themselves to the current fontsize, an
+%D ugly but usefull hack.
+
+\mutable\let\logofont\nullfont
+
+% \loadmapfile[original-base.map] % stil needed? not if we assume afm
+
+\permanent\protected\def\setMFPfont% more sensitive for low level changes
+ {\font\logofont=logo%
+ \ifx\fontalternative\s!bf\s!bf\orelse
+ \ifx\fontalternative\s!it\s!sl\orelse
+ \ifx\fontalternative\s!sl\s!sl\orelse
+ \ifx\fontalternative\s!bi\s!bf\orelse
+ \ifx\fontalternative\s!bs\s!bf\fi
+ 10 at \currentfontscale\bodyfontsize % there is no afm in the minimals yet
+ \logofont}
+
+\def\syst_logos_meta_hyphen % there is no hyphenchar in this font
+ {\discretionary{\vrule\s!height.33\emwidth\s!depth-.27\emwidth\s!width.33\emwidth}{}{}}
+
+\frozen\instance\protected\def\MetaFontLogo
+ {\dontleavehmode
+ \begingroup
+ \setMFPfont META\syst_logos_meta_hyphen FONT%
+ \endgroup}
+
+\protected\def\MetaPostLogo
+ {\dontleavehmode
+ \begingroup
+ \setMFPfont META\syst_logos_meta_hyphen POST%
+ \endgroup}
+
+% \protected\def\MetaFunLogo
+% {\dontleavehmode
+% \begingroup
+% \setMFPfont META\syst_logos_meta_hyphen FUN%
+% \endgroup}
+
+% As decided on the ConText Meeting 2013 the logo has been simplified:
+
+\instance\protected\def\MetaFont{MetaFont}
+\instance\protected\def\MetaPost{MetaPost}
+\instance\protected\def\MetaFun {MetaFun}
+
+%D \macros
+%D {TEX, METAFONT, METAPOST, METAFUN,
+%D PICTEX, TABLE,
+%D CONTEXT, PPCHTEX,
+%D AMSTEX, LATEX, LAMSTEX}
+%D
+%D We define the funny written ones as well as the less error prone upper case names
+%D (in \CONTEXT\ we tend to write all user defined commands, like abbreviations, in
+%D uppercase.)
+
+\instance\protected\def\METAFONT{\MetaFont}
+\instance\protected\def\METAPOST{\MetaPost}
+\instance\protected\def\PPCHTEX {\PPCHTeX}
+\instance\protected\def\CONTEXT {\ConTeXt}
+\instance\protected\def\METAFUN {\MetaFun}
+
+\instance\protected\def\TEX {\TeX}
+\instance\protected\def\LATEX {\LaTeX}
+\instance\protected\def\PICTEX {\PiCTeX}
+\instance\protected\def\TABLE {\TaBlE}
+\instance\protected\def\AMSTEX {\AmSTeX}
+\instance\protected\def\LAMSTEX {\LamSTeX}
+\instance\protected\def\INRSTEX {inrs\TeX}
+
+\instance\protected\def\PRAGMA {Pragma ADE}
+
+%D And this is how they show up: \TeX, \MetaFont, \MetaPost, \PiCTeX, \TaBlE, \ConTeXt,
+%D \PPCHTeX, \AmSTeX, \LaTeX, \LamSTeX.
+
+%D Some placeholders:
+
+%frozen\instance\protected\def\eTeX {\mathematics{\varepsilon}-\TeX}
+\frozen\instance\protected\def\eTeX {{\tf \nocap $\varepsilon$}-\TeX} % compact mode hack for epsilon
+\frozen\instance\protected\def\pdfTeX {pdf\wordboundary\TeX}
+\frozen\instance\protected\def\pdfeTeX {pdfe-\wordboundary\TeX}
+\frozen\instance\protected\def\luaTeX {lua\wordboundary\TeX}
+\frozen\instance\protected\def\Lua {Lua}
+\frozen\instance\protected\def\luajitTeX {lua\wordboundary jit\wordboundary\TeX}
+\frozen\instance\protected\def\luametaTeX{lua\wordboundary meta\wordboundary\TeX}
+\frozen\instance\protected\def\XeTeX {X\lower.5\exheight\hbox{\kern-.15\emwidth\mirror{E}}\kern-.1667\emwidth\TeX}
+
+% Adapted from a patch by Mojca:
+
+\def\syst_logos_xetex_e
+ {\setbox\scratchbox\hbox{E}%
+ \raise\dimexpr\ht\scratchbox+\dp\scratchbox\relax\hbox{\rotate[\c!rotation=180]{\box\scratchbox}}}
+
+\frozen\instance\protected\def\XeTeX
+ {X\lower.5\exheight
+ \hbox
+ {\kern-.15\emwidth
+ \iffontchar\font"018E\relax
+ \char"018E%
+ \else
+ \ifx\fontalternative\s!bf \mirror{E}\orelse
+ \ifx\fontalternative\s!it\syst_logos_xetex_e\orelse
+ \ifx\fontalternative\s!sl\syst_logos_xetex_e\orelse
+ \ifx\fontalternative\s!bi\syst_logos_xetex_e\orelse
+ \ifx\fontalternative\s!bs\syst_logos_xetex_e\else
+ \mirror{E}\fi
+ \fi}%
+ \kern-.1667\emwidth\TeX}
+
+\instance\protected\def\ETEX {\eTeX}
+\instance\protected\def\PDFTEX {\pdfTeX}
+\instance\protected\def\PDFETEX {\pdfeTeX}
+\instance\protected\def\LUATEX {\luaTeX}
+\instance\protected\def\LUAJITTEX {\luajitTeX}
+\instance\protected\def\LuaTeX {\luaTeX}
+\instance\protected\def\LuaMetaTeX{\luametaTeX}
+\instance\protected\def\LUAMETATEX{\luametaTeX}
+\instance\protected\def\XETEX {\XeTeX}
+
+\frozen\instance\protected\def\LuaTeX
+ {\dontleavehmode
+ \begingroup
+ Lua%
+ % hope for kerning, try aT
+ \setbox0\hbox{aT}%
+ \setbox2\hbox{a\kern\zeropoint T}%
+ \ifdim\wd0=\wd2 % kerns can go two ways
+ % no aT kerning, try oT as a is not symmetrical
+ \setbox0\hbox{oT}%
+ \setbox2\hbox{o\kern\zeropoint T}%
+ \ifdim\wd0=\wd2 % kerns can go two ways
+ % no aT and oT kerning, try To
+ \setbox0\hbox{To}%
+ \setbox2\hbox{T\kern\zeropoint o}%
+ % maybe we need to compensate for the angle (sl/it/bs/bi)
+ \fi
+ \ifdim\wd0=\wd2\else
+ \kern\dimexpr\wd0-\wd2\relax
+ \fi
+ \fi
+ \TeX
+ \endgroup}
+
+\frozen\instance\protected\def\LuajitTeX
+ {\dontleavehmode
+ \begingroup
+ % at this moment there is no real need for kerning tT
+ Luajit\kern\zeropoint\TeX
+ \endgroup}
+
+\frozen\instance\let\luaTeX \LuaTeX
+\frozen\instance\let\luajitTeX\LuajitTeX
+
+\instance\protected\def\LUATEX {\LuaTeX}
+\instance\protected\def\LUAJITTEX{\LuajitTeX}
+
+\instance\protected\def\MKII{MkII} % MarkTwo
+\instance\protected\def\MKIV{MkIV} % MarkFour : MKIV
+\instance\protected\def\MKVI{MkVI} % MarkSix : MKIV
+\instance\protected\def\MKXL{MkXL} % MarkFourty : LMTX
+\instance\protected\def\MKLX{MkLX} % MarkSixty : LMTX
+\instance\protected\def\MKIX{MkIX} % : MKIV / LMTX
+\instance\protected\def\MKXI{MkXI} % : MKIV / LMTX
+
+\instance\protected\def\MPII{MpII} % MarkTwo
+\instance\protected\def\MPIV{MpIV} % MarkFour : MetaFun
+\instance\protected\def\MPVI{MpVI} % MarkSix : MetaFun
+\instance\protected\def\MPXL{MpXL} % MarkFourty : LuaMetaFun
+\instance\protected\def\MPLX{MpLX} % MarkSixty : LuaMetaFun
+
+\instance\protected\def\LMTX{LMTX} % for LuaMetaTeX
+
+\appendtoks
+ \enforced\instance\def\ConTeXt {ConTeXt}%
+ \enforced\instance\def\MetaPost {MetaPost}%
+ \enforced\instance\def\MetaFont {MetaFont}%
+ \enforced\instance\def\MetaFun {MetaFun}%
+ \enforced\instance\def\TeX {TeX}%
+ \enforced\instance\let\TeXsuffix \TeX
+ \enforced\instance\let\TeXprefix \TeX
+ \enforced\instance\def\LuaTeX {LuaTeX}%
+ \enforced\instance\def\LuajitTeX {LuajitTeX}%
+ \enforced\instance\def\LuaMetaTeX{LuaMetaTeX}%
+ %\let\wordboundary\empty % primitive so we need to promote it to frozen (orjust preroll)
+\to \everysimplifycommands
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-new.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-new.mkxl
new file mode 100644
index 00000000000..b60dd2dddd4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-new.mkxl
@@ -0,0 +1,54 @@
+%D \module
+%D [ file=cont-new,
+%D version=1995.10.10,
+%D title=\CONTEXT\ Miscellaneous Macros,
+%D subtitle=New Macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \normalend % uncomment this to get the real base runtime
+
+\newcontextversion{2021.03.05 19:11}
+
+%D This file is loaded at runtime, thereby providing an excellent place for hacks,
+%D patches, extensions and new features. There can be local overloads in cont-loc
+%D (which has always been the case) and experimental code in cont-exp (which is also
+%D so old that I need to remind myself to check it occasionally, so here is the
+%D reminder).
+
+% \enabletrackers[pages.timing]
+% \enabletrackers[system.usage=summary]
+
+\unprotect
+
+\writestatus\m!system{beware: some patches loaded from cont-new.mkiv}
+
+%D I need to verify if this indeed will make it into \type {math-ini.mkiv}, that is:
+%D does Alan use it?
+
+\ifdefined\t \else \permanent\protected\def\t{\mathortext\text\mathtext} \fi
+\ifdefined\w \else \permanent\protected\def\w{\mathortext\word\mathword} \fi
+
+\appendtoks
+ \enforced\aliased\let\t\mathtext
+ \enforced\aliased\let\w\mathword
+\to \everymathematics
+
+% so we need to be able to load modules in ini mode
+
+\pushoverloadmode
+ % charts needs these
+ \overloaded\unletfrozen\name % for now
+ \mutable\let\name\name
+ \mutable\let\text\text
+ \overloaded\frozen\let\type\type
+\popoverloadmode
+
+%D We're done.
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-nl.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-nl.mkxl
new file mode 100644
index 00000000000..5e74114e5b6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-nl.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-nl,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ Dutch Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {dutch}
+\immutable\def\defaultlanguagetag{nl}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-pe.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-pe.mkxl
new file mode 100644
index 00000000000..2242c3e0dda
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-pe.mkxl
@@ -0,0 +1,22 @@
+%D \module
+%D [ file=cont-en,
+%D version=1997.08.19,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ English Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {persian}
+\immutable\def\messageinterface {english}
+\immutable\def\defaultlanguagetag{pe}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-ro.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-ro.mkxl
new file mode 100644
index 00000000000..ced28ba3d95
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-ro.mkxl
@@ -0,0 +1,21 @@
+%D \module
+%D [ file=cont-ro,
+%D version=2000.01.09,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ Romanian Format Generation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2
+
+\immutable\def\defaultinterface {romanian}
+\immutable\def\defaultlanguagetag{ro}
+
+\input context.mkxl
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-run.lmt b/Master/texmf-dist/tex/context/base/mkxl/cont-run.lmt
new file mode 100644
index 00000000000..76fd6ba249b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-run.lmt
@@ -0,0 +1,311 @@
+if not modules then modules = { } end modules ['cont-run'] = {
+ version = 1.001,
+ comment = "companion to cont-yes.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- When a style is loaded there is a good change that we never enter
+-- this code.
+
+
+local type, tostring = type, tostring
+
+local report_sandbox = logs.reporter("sandbox","call")
+local report_system = logs.reporter("system")
+local fastserialize = table.fastserialize
+local quoted = string.quoted
+local possiblepath = sandbox.possiblepath
+
+local context = context
+local implement = interfaces.implement
+
+local qualified = { }
+local writeable = { }
+local readable = { }
+local blocked = { }
+local trace_files = false
+local trace_calls = false
+local nofcalls = 0
+local nofrejected = 0
+local logfilename = "sandbox.log"
+
+local function registerstats()
+ statistics.register("sandboxing", function()
+ if trace_files then
+ return string.format("%i calls, %i rejected, logdata in '%s'",nofcalls,nofrejected,logfilename)
+ else
+ return string.format("%i calls, %i rejected",nofcalls,nofrejected)
+ end
+ end)
+ registerstats = false
+end
+
+local function logsandbox(details)
+ local comment = details.comment
+ local result = details.result
+ local arguments = details.arguments
+ for i=1,#arguments do
+ local argument = arguments[i]
+ local t = type(argument)
+ if t == "string" then
+ arguments[i] = quoted(argument)
+ if trace_files and possiblepath(argument) then
+ local q = qualified[argument]
+ if q then
+ local c = q[comment]
+ if c then
+ local r = c[result]
+ if r then
+ c[result] = r + 1
+ else
+ c[result] = r
+ end
+ else
+ q[comment] = {
+ [result] = 1
+ }
+ end
+ else
+ qualified[argument] = {
+ [comment] = {
+ [result] = 1
+ }
+ }
+ end
+ end
+ elseif t == "table" then
+ arguments[i] = fastserialize(argument)
+ else
+ arguments[i] = tostring(argument)
+ end
+ end
+ if trace_calls then
+ report_sandbox("%s(%,t) => %l",details.comment,arguments,result)
+ end
+ nofcalls = nofcalls + 1
+ if not result then
+ nofrejected = nofrejected + 1
+ end
+end
+
+local ioopen = sandbox.original(io.open) -- dummy call
+
+local function logsandboxfiles(name,what,asked,okay)
+ -- we're only interested in permitted access
+ if not okay then
+ blocked [asked] = blocked [asked] or 0 + 1
+ elseif what == "*" or what == "w" then
+ writeable[asked] = writeable[asked] or 0 + 1
+ else
+ readable [asked] = readable [asked] or 0 + 1
+ end
+end
+
+function sandbox.logcalls()
+ if not trace_calls then
+ trace_calls = true
+ sandbox.setlogger(logsandbox)
+ if registerstats then
+ registerstats()
+ end
+ end
+end
+
+function sandbox.logfiles()
+ if not trace_files then
+ trace_files = true
+ sandbox.setlogger(logsandbox)
+ sandbox.setfilenamelogger(logsandboxfiles)
+ luatex.registerstopactions(function()
+ table.save(logfilename,{
+ calls = {
+ nofcalls = nofcalls,
+ nofrejected = nofrejected,
+ filenames = qualified,
+ },
+ checkednames = {
+ readable = readable,
+ writeable = writeable,
+ blocked = blocked,
+ },
+ })
+ end)
+ if registerstats then
+ registerstats()
+ end
+ end
+end
+
+trackers.register("sandbox.tracecalls",sandbox.logcalls)
+trackers.register("sandbox.tracefiles",sandbox.logfiles)
+
+local sandboxing = environment.arguments.sandbox
+local debugging = environment.arguments.debug
+
+if sandboxing then
+
+ report_system("enabling sandbox")
+
+ sandbox.enable()
+
+ if type(sandboxing) == "string" then
+ sandboxing = utilities.parsers.settings_to_hash(sandboxing)
+ if sandboxing.calls then
+ sandbox.logcalls()
+ end
+ if sandboxing.files then
+ sandbox.logfiles()
+ end
+ end
+
+ -- Nicer would be if we could just disable write 18 and keep os.execute
+ -- which in fact we can do by defining write18 as macro instead of
+ -- primitive ... todo ... well, it has been done now.
+
+ -- We block some potential escapes from protection.
+
+ context [[\let\primitive\relax\let\normalprimitive\relax]]
+
+ debug = {
+ traceback = debug.traceback,
+ }
+
+ package.loaded.debug = debug
+
+elseif debugging then
+
+ -- we keep debug
+
+else
+
+ debug = {
+ traceback = debug.traceback,
+ getinfo = debug.getinfo,
+ sethook = debug.sethook,
+ }
+
+ package.loaded.debug = debug
+
+end
+
+local function processjob()
+
+ tokens.setters.macro("processjob","","permanent")
+
+ environment.initializefilenames() -- todo: check if we really need to pre-prep the filename
+
+ local arguments = environment.arguments
+ local suffix = environment.suffix
+ local filename = environment.filename -- hm, not inputfilename !
+
+ environment.lmtxmode = CONTEXTLMTXMODE -- should be true
+
+ if arguments.nosynctex then
+ luatex.synctex.setup {
+ state = interfaces.variables.never,
+ }
+ elseif arguments.synctex then
+ luatex.synctex.setup {
+ state = interfaces.variables.start,
+ method = interfaces.variables.max,
+ }
+ end
+
+ local overloadmode = arguments.overloadmode
+
+ if overloadmode == "warning" then
+ overloadmode = 3 -- 5
+ elseif overloadmode == "error" then
+ overloadmode = 4 -- 6
+ else
+ overloadmode = tonumber(overloadmode)
+ end
+
+ if overloadmode then
+ tex.set("overloadmode",overloadmode)
+ end
+
+ if not filename or filename == "" then
+ -- skip
+ elseif suffix == "xml" or arguments.forcexml then
+
+ -- Maybe we should move the preamble parsing here as it
+ -- can be part of (any) loaded (sub) file. The \starttext
+ -- wrapping might go away.
+
+ report_system("processing as xml: %s",filename)
+
+ context.starttext()
+ context.xmlprocess("main",filename,"")
+ context.stoptext()
+
+ elseif suffix == "cld" or arguments.forcecld then
+
+ report_system("processing as cld: %s",filename)
+
+ context.runfile(filename)
+
+ elseif suffix == "lua" or arguments.forcelua then
+
+ -- The wrapping might go away. Why is is it there in the
+ -- first place.
+
+ report_system("processing as lua: %s",filename)
+
+ context.starttext()
+ context.ctxlua(string.format('dofile("%s")',filename))
+ context.stoptext()
+
+ elseif suffix == "mp" or arguments.forcemp then
+
+ report_system("processing as metapost: %s",filename)
+
+ context.starttext()
+ context.processMPfigurefile(filename)
+ context.stoptext()
+
+ -- elseif suffix == "prep" then
+ --
+ -- -- Why do we wrap here. Because it can be xml? Let's get rid
+ -- -- of prepping in general.
+ --
+ -- context.starttext()
+ -- context.input(filename)
+ -- context.stoptext()
+
+ elseif suffix == "mps" or arguments.forcemps then
+
+ report_system("processing metapost output: %s",filename)
+
+ context.starttext()
+ context.startTEXpage()
+ context.externalfigure { filename }
+ context.stopTEXpage()
+ context.stoptext()
+
+ else
+
+ -- \writestatus{system}{processing as tex}
+ -- We have a regular tex file so no \starttext yet as we can
+ -- load fonts.
+ -- context.enabletrackers { "resolvers.*" }
+ context.input(filename)
+ -- context.disabletrackers { "resolvers.*" }
+
+ end
+
+ context.finishjob()
+
+end
+
+implement {
+ name = "processjob",
+ -- protected = true
+ public = true,
+ onlyonce = true,
+ actions = processjob,
+}
+
+texconfig.firstline = "\\processjob " -- experiment, yet undocumented
diff --git a/Master/texmf-dist/tex/context/base/mkxl/cont-run.mkxl b/Master/texmf-dist/tex/context/base/mkxl/cont-run.mkxl
new file mode 100644
index 00000000000..8944a0359e7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/cont-run.mkxl
@@ -0,0 +1,59 @@
+%D \module
+%D [ file=cont-run,
+%D version=2014.12.26,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Runner,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Runner}
+
+\registerctxluafile{cont-run}{autosuffix}
+
+% \enabletrackers[system.synctex.visualize]
+% \enabletrackers[system.synctex.xml]
+% \enabledirectives[system.synctex.details]
+% \setupsynctex[state=start]
+
+\unprotect
+
+\permanent\let\synctexsetfilename \clf_synctexsetfilename % can be public implementors
+\permanent\let\synctexresetfilename\clf_synctexresetfilename % idem
+\permanent\let\synctexblockfilename\clf_synctexblockfilename % idem
+
+\aliased\let\synctexpause \donothing
+\aliased\let\synctexresume \donothing
+\aliased\let\synctexpushline\donothing
+\aliased\let\synctexpopline \donothing
+
+\appendtoks\synctexpause \to\everybeforeoutput
+\appendtoks\synctexresume\to\everyafteroutput
+
+\permanent\protected\def\setupsynctex[#1]%
+ {\begingroup
+ \getdummyparameters[\c!state=\v!stop,\c!method=\v!max,#1]%
+ \edef\p_state{\dummyparameter\c!state}%
+ \clf_setupsynctex
+ state {\p_state}%
+ method {\dummyparameter\c!method}%
+ \relax
+ \ifx\p_state\v!start
+ % when public implementor, use conditional
+ \enforced\glet\synctexpause \clf_synctexpause
+ \enforced\glet\synctexresume \clf_synctexresume
+ \enforced\glet\synctexpushline\clf_synctexpushline
+ \enforced\glet\synctexpopline \clf_synctexpopline
+ \fi
+ \endgroup}
+
+\permanent\protected\def\blocksynctexfile[#1]%
+ {\processcommacommand{#1}\synctexblockfilename}
+
+\aliased\let\continuewhenlmtxmode\relax
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/context.mkxl b/Master/texmf-dist/tex/context/base/mkxl/context.mkxl
new file mode 100644
index 00000000000..88b99e7d4a4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/context.mkxl
@@ -0,0 +1,614 @@
+%D \module
+%D [ file=context,
+%D version=2019.07.24, % 2008.28.10, % 1995.10.10,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ Format Generation,
+%D author=Hans Hagen, % ɦɑns ɦɑˈχən
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% http://build.contextgarden.net/waterfall?tag=c/lua(meta)tex
+
+%D Welcome to context, pronounced as kontekst (rather dutch) and not as conτεχt.
+
+\catcode`\{=1 \catcode`\}=2 \catcode`\#=6
+
+%D From the next string (which is set by the script that assembles the distribution)
+%D later on we will calculate a number that can be used by use modules to identify
+%D the feature level. Starting with version 2004.8.30 the low level interface is
+%D english. Watch out and adapt your styles an modules.
+
+% \everypar{\writestatus{!!!!}{some spurious input in line \the\inputlineno}\wait}
+
+%D The order of loading will change when all modules have been cleaned up and the
+%D dependencies are more consistent. Beware, the version number has to match \type
+%D {YYYY.MM.DD HH:MM} format.
+
+\immutable\edef\contextformat {\jobname}
+\immutable\edef\contextversion{2021.03.05 19:11}
+
+%overloadmode 1 % check frozen / warning
+%overloadmode 2 % check frozen / error
+%overloadmode 3 % check frozen, primitive, permanent / warning
+\overloadmode 4 % check frozen, primitive, permanent / error
+
+%D Kind of special:
+
+\immutable\chardef\contextlmtxmode\directlua{tex.print(CONTEXTLMTXMODE or 0)}\relax
+
+%D For those who want to use this:
+
+\aliased\let\fmtname \contextformat
+\aliased\let\fmtversion\contextversion
+
+%D Loading:
+
+\immutable\edef\mksuffix {mkiv}
+\immutable\edef\contextmark{LMTX}
+
+\ifdefined\normalinput \else \aliased\let\normalinput\input \fi
+
+\permanent\protected\def\loadmarkfile#1{\normalinput{#1.\mksuffix}}
+\permanent\protected\def\loadmkivfile#1{\normalinput{#1.mkiv}}
+\permanent\protected\def\loadmkvifile#1{\normalinput{#1.mkvi}}
+\permanent\protected\def\loadmkxlfile#1{\normalinput{#1.mkxl}}
+\permanent\protected\def\loadmklxfile#1{\normalinput{#1.mklx}}
+
+%D First we load the system modules. These implement a lot of manipulation macros.
+%D We start with setting up some basic \TEX\ machinery.
+
+\loadmkxlfile{syst-ini}
+
+%D Some checking (more primitives are now defined):
+
+\ifdefined\defaultinterface \else \immutable\def\defaultinterface {english} \fi
+%ifdefined\messageinterface \else \immutable\let\messageinterface \defaultinterface \fi
+\ifdefined\defaultlanguagetag \else \immutable\def\defaultlanguagetag{en} \fi
+
+%D There is only this way to pass the version info to \LUA\ (currently). Hm, we could
+%D now put it into the environment.
+
+\newtoks\contextversiontoks \contextversiontoks\expandafter{\contextversion}
+
+% \normaleverypar{\wait} % uncomment for test of funny injections
+
+%D Now the more fundamental code gets defined.
+
+\loadmkxlfile{norm-ctx}
+\loadmkxlfile{syst-pln}
+%loadmkxlfile{syst-mes}
+
+\loadmkxlfile{luat-cod}
+\loadmkxlfile{luat-bas}
+\loadmkxlfile{luat-lib}
+\loadmkxlfile{luat-soc}
+
+\loadmkxlfile{catc-ini}
+\loadmkxlfile{catc-act}
+\loadmkxlfile{catc-def}
+\loadmkxlfile{catc-sym}
+
+\loadmkxlfile{toks-ini}
+\loadmkxlfile{cldf-ini}
+
+% \tracecatcodetables
+
+%D From here on we have \unexpanded being \normalprotected, as we already had
+%D \type {\unexpanded} long before etex came around.
+
+\loadmkxlfile{luat-ini}
+\loadmkxlfile{toks-scn}
+
+\loadmkxlfile{syst-aux}
+\loadmkxlfile{syst-lua}
+\loadmkxlfile{syst-con}
+
+\loadmkxlfile{syst-fnt}
+\loadmkxlfile{syst-rtp}
+
+\loadmkxlfile{luat-usr}
+
+\loadmklxfile{file-ini}
+\loadmklxfile{file-res}
+\loadmkxlfile{file-lib}
+
+\loadmkxlfile{core-lmt}
+
+%D This needs more checking for clashes:
+%D
+%D \starttyping
+%D \doifelsefileexists{l-macro-imp-codes-luametatex.lua}{\registerctxluafile{l-macro-imp-codes-luametatex}{}}{}
+%D \stoptyping
+
+\loadmkxlfile{supp-dir}
+
+\loadmkxlfile{char-utf}
+\loadmkxlfile{char-ini}
+\loadmkxlfile{char-act}
+
+\loadmkxlfile{mult-ini}
+\loadmkxlfile{mult-sys}
+\loadmkxlfile{mult-aux}
+\loadmkxlfile{mult-def}
+%loadmarkfile{mult-chk}
+\loadmklxfile{mult-dim}
+
+\loadmkxlfile{cldf-int} % interface
+
+\loadmkxlfile{trac-ctx} % maybe move up
+
+\loadmkxlfile{toks-aux}
+
+\loadmkxlfile{attr-ini}
+
+\loadmkxlfile{core-ini}
+\loadmkxlfile{core-env}
+
+\loadmkxlfile{layo-ini}
+
+\loadmkxlfile{node-ini}
+
+% \loadmkxlfile{cldf-bas} % basics / depends on nodes
+
+\loadmkxlfile{node-fin}
+\loadmkxlfile{node-mig}
+%loadmkxlfile{node-pag}
+
+\loadmkxlfile{driv-ini}
+
+\loadmkxlfile{back-ini}
+\loadmkxlfile{back-res}
+\loadmkxlfile{back-ext}
+
+\loadmkxlfile{cldf-bas} % basics / depends on nodes
+
+\loadmkxlfile{attr-col}
+\loadmkxlfile{attr-lay}
+\loadmkxlfile{attr-neg}
+\loadmkxlfile{attr-eff}
+\loadmkxlfile{attr-alt}
+\loadmkxlfile{attr-mkr}
+
+\loadmkxlfile{trac-tex}
+\loadmkxlfile{trac-deb} % will move up
+
+\loadmkxlfile{supp-box}
+
+\loadmkxlfile{supp-ran}
+\loadmkxlfile{supp-mat}
+
+\loadmkxlfile{core-uti}
+\loadmklxfile{file-job}
+
+\loadmkxlfile{anch-pos}
+
+\loadmkxlfile{typo-ini}
+\loadmkxlfile{typo-lin}
+\loadmkxlfile{typo-bld} % par builders
+
+\loadmkxlfile{typo-inj}
+
+\loadmklxfile{file-syn}
+\loadmklxfile{file-mod}
+
+\loadmkxlfile{core-sys}
+\loadmkxlfile{core-con}
+
+\loadmkxlfile{cont-fil}
+
+\loadmkxlfile{regi-ini}
+\loadmkxlfile{enco-ini}
+\loadmkxlfile{hand-ini}
+
+\loadmkxlfile{lang-ini}
+\loadmkxlfile{lang-hyp} % also loads dis
+\loadmkxlfile{lang-lab}
+
+\loadmkxlfile{unic-ini}
+
+\loadmkxlfile{core-two}
+\loadmkxlfile{core-dat}
+
+\loadmkxlfile{colo-ini}
+\loadmkxlfile{colo-nod}
+\loadmkxlfile{colo-grp} % optional
+\loadmkxlfile{colo-ext}
+
+\loadmkxlfile{node-bck} % overloads anch-pgr (experimental and undocumented)
+
+\loadmkxlfile{pack-cut}
+
+\loadmkxlfile{lang-mis}
+\loadmkxlfile{lang-url}
+\loadmkxlfile{lang-def}
+
+% \loadmkvifile{file-job} % why so late?
+
+\loadmkxlfile{symb-ini} % brrr depends on fonts
+
+\loadmkxlfile{sort-ini}
+
+\loadmklxfile{pack-mis}
+\loadmkxlfile{pack-ori}
+\loadmkxlfile{pack-rul}
+\loadmkxlfile{pack-mrl}
+\loadmklxfile{pack-bck}
+\loadmkxlfile{pack-fen}
+
+\loadmkxlfile{lxml-ini}
+\loadmkxlfile{lxml-sor}
+
+\loadmklxfile{typo-prc}
+\loadmkxlfile{typo-plc}
+
+\loadmklxfile{strc-ini}
+\loadmkxlfile{strc-tag}
+\loadmkxlfile{strc-doc}
+\loadmkxlfile{strc-num}
+\loadmkxlfile{strc-mar}
+\loadmkxlfile{strc-sbe}
+\loadmklxfile{strc-lst}
+\loadmkxlfile{strc-sec}
+\loadmkxlfile{strc-pag} % hm, depends on core-num
+\loadmkxlfile{strc-ren}
+%loadmarkfile{strc-xml}
+\loadmkxlfile{strc-def} % might happen later
+\loadmklxfile{strc-ref}
+%loadmarkfile{strc-reg}
+\loadmklxfile{strc-lev} % experiment
+
+\loadmkxlfile{spac-hor}
+\loadmkxlfile{spac-ali}
+\loadmkxlfile{spac-flr}
+\loadmkxlfile{spac-ver} % beware, hooks into strc-sec
+\loadmkxlfile{spac-lin}
+\loadmkxlfile{spac-pag}
+\loadmkxlfile{spac-par}
+\loadmkxlfile{spac-def}
+\loadmklxfile{spac-prf}
+\loadmkxlfile{spac-grd}
+
+\loadmklxfile{scrn-ini}
+\loadmklxfile{scrn-ref}
+
+\loadmkxlfile{pack-obj}
+
+\loadmklxfile{strc-itm}
+
+\loadmklxfile{strc-con}
+\loadmklxfile{strc-des}
+\loadmklxfile{strc-enu}
+
+\loadmkxlfile{strc-ind}
+\loadmkxlfile{strc-lab}
+\loadmkxlfile{strc-syn}
+
+% \loadmarkfile{core-sys}
+
+\loadmkxlfile{page-var}
+\loadmklxfile{page-otr}
+\loadmkxlfile{page-ini}
+\loadmkxlfile{page-ins}
+\loadmkxlfile{page-fac}
+\loadmkxlfile{page-brk}
+\loadmkxlfile{page-col}
+\loadmkxlfile{page-inf}
+\loadmkxlfile{page-flt}
+\loadmkxlfile{page-bck}
+\loadmkxlfile{page-not}
+\loadmkxlfile{page-one}
+\loadmkxlfile{page-lay}
+\loadmklxfile{page-box}
+\loadmklxfile{page-txt}
+\loadmkxlfile{page-sid}
+
+\loadmklxfile{strc-flt}
+
+\loadmkxlfile{page-pst}
+\loadmklxfile{page-mbk}
+%loadmarkfile{page-mul} % \usecolumns[old-multicolumns]
+\loadmkxlfile{page-mix}
+\loadmkxlfile{page-smp}
+\loadmkxlfile{page-cst}
+\loadmkxlfile{page-pcl} % new
+\loadmkxlfile{pack-lyr}
+\loadmkxlfile{pack-pos}
+\loadmklxfile{page-mak}
+\loadmkxlfile{page-mcl}
+
+\loadmkxlfile{strc-reg} % uses mixed columns
+
+\loadmklxfile{page-lin}
+\loadmkxlfile{page-par}
+\loadmkxlfile{typo-pag}
+\loadmkxlfile{typo-mar}
+\loadmkxlfile{typo-itm}
+
+\loadmkxlfile{buff-ini}
+\loadmkxlfile{buff-ver}
+\loadmklxfile{buff-par}
+
+\loadmarkfile{buff-imp-tex} % optional as also runtime if not loaded
+\loadmarkfile{buff-imp-mp} % optional as also runtime if not loaded
+\loadmarkfile{buff-imp-lua} % optional as also runtime if not loaded
+\loadmarkfile{buff-imp-xml} % optional as also runtime if not loaded
+
+\loadmarkfile{buff-imp-parsed-xml} % optional
+%loadmarkfile{buff-imp-parsed-lua} % optional
+
+\loadmkxlfile{strc-blk}
+
+\loadmkxlfile{page-imp}
+\loadmklxfile{page-sel} % optional
+\loadmklxfile{page-inj} % optional
+
+\loadmklxfile{scrn-pag}
+\loadmklxfile{scrn-wid}
+\loadmklxfile{scrn-but}
+\loadmklxfile{scrn-bar}
+
+\loadmkxlfile{page-com} % optional (after scrn-pag)
+
+\loadmkxlfile{strc-bkm} % bookmarks
+
+\loadmkxlfile{java-ini}
+
+\loadmklxfile{scrn-fld}
+\loadmklxfile{scrn-hlp}
+
+\loadmkxlfile{char-enc}
+
+\loadmklxfile{font-lib} % way too late but after language
+\loadmklxfile{font-fil}
+\loadmklxfile{font-var}
+\loadmklxfile{font-fea}
+\loadmklxfile{font-mat}
+\loadmklxfile{font-ini}
+\loadmklxfile{font-glf}
+\loadmklxfile{font-sym}
+\loadmklxfile{font-sty}
+\loadmklxfile{font-set}
+\loadmklxfile{font-emp}
+\loadmkxlfile{font-pre}
+\loadmkxlfile{font-unk}
+\loadmkxlfile{font-tra}
+\loadmkxlfile{font-chk}
+\loadmkxlfile{font-uni}
+\loadmklxfile{font-col}
+\loadmklxfile{font-gds}
+\loadmklxfile{font-aux}
+\loadmklxfile{font-sel}
+\loadmkxlfile{font-tex}
+
+\loadmkxlfile{typo-tal}
+\loadmkxlfile{typo-par} % par builders (uses fonts)
+
+\loadmkxlfile{tabl-com}
+%loadmarkfile{tabl-pln}
+
+\loadmkxlfile{tabl-tab} % thrd-tab stripped and merged
+
+\loadmkxlfile{tabl-tbl}
+\loadmkxlfile{tabl-ntb}
+\loadmkxlfile{tabl-nte}
+\loadmkxlfile{tabl-ltb}
+\loadmkxlfile{tabl-frm}
+\loadmkxlfile{tabl-tsp}
+\loadmklxfile{tabl-xtb}
+\loadmkxlfile{tabl-mis}
+
+\loadmkxlfile{typo-lan}
+
+\loadmkxlfile{lxml-css}
+
+\loadmkxlfile{spac-chr} % depends on fonts
+
+\loadmkxlfile{blob-ini}
+
+\loadmkxlfile{trac-vis}
+\loadmkxlfile{trac-jus}
+
+\loadmkxlfile{typo-cln}
+\loadmkxlfile{typo-wrp}
+\loadmkxlfile{typo-spa}
+\loadmkxlfile{typo-krn}
+\loadmklxfile{typo-itc}
+\loadmkxlfile{typo-dir}
+\loadmkxlfile{typo-brk}
+\loadmkxlfile{typo-cap}
+\loadmkxlfile{typo-dig}
+\loadmkxlfile{typo-rep}
+\loadmklxfile{typo-txt}
+\loadmkxlfile{typo-drp}
+\loadmkxlfile{typo-fln}
+\loadmkxlfile{typo-sus}
+\loadmkxlfile{typo-lig}
+\loadmkxlfile{typo-chr}
+\loadmkxlfile{typo-rub}
+\loadmkxlfile{typo-fkr}
+\loadmkxlfile{typo-pnc}
+
+\loadmklxfile{type-ini}
+\loadmkxlfile{type-set}
+
+\loadmkxlfile{scrp-ini}
+
+\loadmkxlfile{symb-emj}
+
+\loadmkxlfile{lang-tra} % can be optional (discussion with mm sideeffect)
+\loadmkxlfile{lang-wrd} % can be optional (discussion with mm sideeffect)
+\loadmkxlfile{lang-rep} % can be optional (bt 2013 side effect)
+
+\loadmkxlfile{mlib-ctx} % messy order
+
+\loadmkxlfile{meta-ini}
+\loadmkxlfile{meta-tex}
+\loadmkxlfile{meta-fun}
+\loadmkxlfile{meta-pag}
+\loadmkxlfile{meta-grd}
+\loadmkxlfile{meta-fnt}
+\loadmkxlfile{meta-nod}
+\loadmkxlfile{meta-lua}
+\loadmkxlfile{meta-mac}
+
+\loadmkxlfile{page-mrk} % depends on mp
+
+\loadmkxlfile{page-flw}
+\loadmkxlfile{page-spr}
+\loadmkxlfile{page-plg}
+\loadmkxlfile{page-str}
+
+\loadmkxlfile{anch-pgr} % can be moved up (nicer for dependencies)
+\loadmklxfile{anch-bck}
+\loadmkxlfile{anch-tab} % overloads tabl-tbl
+\loadmkxlfile{anch-bar}
+%loadmkxlfile{anch-snc} % when needed this one will be redone
+
+\loadmkxlfile{math-ini} % way after font-pre !
+\loadmkxlfile{math-pln}
+\loadmkxlfile{math-for}
+\loadmkxlfile{math-def} % also saves some meanings
+\loadmkxlfile{math-ali}
+\loadmklxfile{math-stc}
+\loadmkxlfile{math-frc}
+\loadmkxlfile{math-mis}
+\loadmkxlfile{math-scr}
+\loadmkxlfile{math-int}
+\loadmkxlfile{math-del}
+\loadmkxlfile{math-fen}
+\loadmklxfile{math-acc}
+\loadmklxfile{math-rad}
+\loadmkxlfile{math-inl}
+\loadmkxlfile{math-dis}
+%loadmkxlfile{math-lan}
+\loadmkxlfile{math-toy}
+
+\loadmkxlfile{strc-mat}
+
+\loadmkxlfile{chem-ini}
+\loadmkxlfile{chem-str}
+
+\loadmkxlfile{typo-scr}
+\loadmkxlfile{phys-dim}
+
+\loadmkxlfile{node-rul} % beware, defined \underbar so after math
+\loadmklxfile{font-sol} % font solutions
+
+\loadmklxfile{strc-not}
+\loadmklxfile{strc-lnt}
+\loadmkxlfile{strc-tnt}
+\loadmkxlfile{strc-usr}
+
+\loadmkxlfile{pack-com}
+\loadmkxlfile{typo-del}
+
+\loadmkxlfile{grph-trf}
+\loadmkxlfile{grph-inc}
+\loadmkxlfile{grph-fig}
+\loadmkxlfile{grph-raw}
+\loadmkxlfile{grph-rul}
+\loadmkxlfile{grph-pat}
+
+\loadmkxlfile{pack-box}
+\loadmkxlfile{pack-bar}
+\loadmkxlfile{page-app}
+\loadmkxlfile{meta-fig}
+
+\loadmkxlfile{page-ffl}
+
+\loadmkxlfile{lang-spa} % will become obsolete
+
+\loadmkxlfile{typo-ovl} % fuzzy project (tracing) code
+
+% old bibtex support: (will be m-oldbibtex.mkiv)
+
+% \loadmarkfile{bibl-bib}
+% \loadmarkfile{bibl-tra}
+
+% new bibtex support:
+
+\loadmkxlfile{publ-ini}
+%loadmkxlfile{publ-tra}
+\loadmkxlfile{publ-xml}
+\loadmkxlfile{publ-old}
+
+%loadmarkfile{x-xtag} % no longer preloaded
+
+\loadmkxlfile{meta-xml}
+
+\loadmkxlfile{cont-log}
+
+\loadmkxlfile{cldf-ver} % verbatim, this can come late
+\loadmkxlfile{cldf-com} % commands, this can come late
+
+\loadmkxlfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace
+
+\loadmkxlfile{core-def}
+
+%usemodule[x][res-04] % xml resource libraries
+%usemodule[x][res-08] % rlx runtime conversion
+%usemodule[x][res-12] % rli external indentification
+
+% now we hook in backend code (needs checking)
+
+\loadmkxlfile{driv-shp}
+
+\loadmkxlfile{back-exp}
+\loadmkxlfile{back-pdf}
+\loadmkxlfile{back-mps}
+\loadmkxlfile{back-lua}
+
+\loadmkxlfile{mlib-pdf}
+\loadmkxlfile{mlib-pps}
+\loadmkxlfile{meta-pdf}
+\loadmkxlfile{meta-blb}
+\loadmkxlfile{grph-epd}
+
+\loadmkxlfile{typo-shp}
+
+\loadmkxlfile{math-inc} % an experiment
+\loadmkxlfile{publ-inc} % an experiment
+
+\loadmkxlfile{task-ini}
+
+\loadmkxlfile{syst-cmp} % compatibility stuff moved here
+
+\loadmkxlfile{libs-ini}
+
+\loadmkxlfile{cont-run} % the main runner (used in cont-yes.mkiv)
+
+\setupcurrentlanguage[\defaultlanguagetag]
+
+\prependtoks
+ \ctxlua{statistics.starttiming(statistics)}%
+\to \everyjob
+
+\appendtoks
+ \ctxlua{statistics.stoptiming(statistics)}%
+\to \everyjob
+
+% \appendtoks
+% \ctxlua{job.prepare()}%
+% \to \everyjob
+
+% \appendtoks
+% \enabletrackers[*]%
+% \to \everyjob
+
+\appendtoks
+ \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkxl","\contextbanner")}% can become automatic
+\to \everydump
+
+% some day:
+%
+% \prependtoks
+% \overloadmode 255
+% \to \everyjob
+
+\overloadmode 0 % for now
+
+\errorstopmode \dump \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-con.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-con.mkxl
new file mode 100644
index 00000000000..df505cfee5f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-con.mkxl
@@ -0,0 +1,1002 @@
+%D \module
+%D [ file=core-con,
+%D version=1997.26.08,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Conversion,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Conversion}
+
+\registerctxluafile{core-con}{}
+
+% todo: iso date ranges (from/to)
+
+\unprotect
+
+\ifdefined\currentlanguage \else \let\currentlanguage\empty \fi
+\ifdefined\labeltext \else \let\labeltext \firstofoneargument \fi
+
+%D This module deals with all kind of conversions from numbers and dates. I
+%D considered splitting this module in a support one and a core one, but to keep
+%D things simple as well as preserve the overview, I decided against splitting.
+
+\aliased\let\spr\firstofoneargument % separator
+\aliased\let\stp\firstofoneargument % stopper
+
+% needed for arab (but can disappear as no ons used it, experiment for idris)
+
+\permanent\protected\def\isolateseparators % even works with list separator overloading
+ {\enforced\permanent\def\spr##1{{##1}}% % we can probably best mess around with zwj
+ \enforced\permanent\def\stp##1{{##1}}} % and friends
+
+%D \macros
+%D {numbers}
+%D
+%D First we deal with the dummy conversion of numbers using the \TEX\ primitive
+%D \type{\number}. The uppercase alternative is only there for compatibility with
+%D the other conversion macros. We could do without \type{#1} but this way we get
+%D rid of unwanted braces. For the savety we also define a non||sence uppercase
+%D alternative.
+%D
+%D \showsetup{numbers}
+%D
+%D \starttyping
+%D \def\numbers#1{\number#1}
+%D \def\Numbers#1{\number#1}
+%D \stoptyping
+%D
+%D Due to read ahead, as in \type{[\pagenumber\space]} the space will disappear,
+%D unless we use:
+
+\permanent\def\numbers#1{\purenumber{#1}}
+\permanent\def\Numbers#1{\purenumber{#1}}
+
+%D \macros
+%D {romannumerals,Romannumerals}
+%D
+%D \TEX\ the program uses a rather tricky conversion from numbers to their roman
+%D counterparts. This conversion could of course be programmed in \TEX\ itself, but
+%D I guess Knuth found the programming trick worth presenting.
+%D
+%D \showsetup{romannumerals}
+%D \showsetup{Romannumerals}
+
+\permanent\def\romannumerals#1{\clf_romannumerals\numexpr#1\relax}
+\permanent\def\Romannumerals#1{\clf_Romannumerals\numexpr#1\relax}
+
+%D Arabic etc:
+
+\permanent\def\abjadnumerals #1{\clf_abjadnumerals \numexpr#1\relax}
+\permanent\def\abjadnodotnumerals#1{\clf_abjadnodotnumerals\numexpr#1\relax}
+\permanent\def\abjadnaivenumerals#1{\clf_alphabetic \numexpr#1\relax{arabic}} % okay?
+
+\permanent\def\hebrewnumerals #1{\clf_hebrewnumerals\numexpr#1\relax}
+\aliased \let\yiddishnumerals \hebrewnumerals
+
+\permanent\def\languagecharacters#1{\clf_alphabetic\numexpr#1\relax{\currentlanguage}} % new
+\permanent\def\languageCharacters#1{\clf_Alphabetic\numexpr#1\relax{\currentlanguage}} % new
+
+\permanent\def\alphabeticnumerals#1{\clf_alphabetic\numexpr#1\relax{}}
+\permanent\def\Alphabeticnumerals#1{\clf_Alphabetic\numexpr#1\relax{}}
+
+\permanent\def\thainumerals #1{\clf_alphabetic\numexpr#1\relax{thai}}
+\permanent\def\devanagarinumerals#1{\clf_alphabetic\numexpr#1\relax{devanagari}}
+\permanent\def\gurmurkhinumerals #1{\clf_alphabetic\numexpr#1\relax{gurmurkhi}}
+\permanent\def\gujaratinumerals #1{\clf_alphabetic\numexpr#1\relax{gujarati}}
+\permanent\def\tibetannumerals #1{\clf_alphabetic\numexpr#1\relax{tibetan}}
+\permanent\def\greeknumerals #1{\clf_alphabetic\numexpr#1\relax{greek}}
+\permanent\def\Greeknumerals #1{\clf_Alphabetic\numexpr#1\relax{greek}}
+\permanent\def\arabicnumerals #1{\clf_alphabetic\numexpr#1\relax{arabic}}
+\permanent\def\persiannumerals #1{\clf_alphabetic\numexpr#1\relax{persian}}
+\permanent\def\arabicdecimals #1{\clf_decimals \numexpr#1\relax{arabic}}
+\permanent\def\persiandecimals #1{\clf_decimals \numexpr#1\relax{persian}}
+
+\aliased \let\arabicexnumerals \persiannumerals
+
+\permanent\def\koreannumerals #1{\clf_alphabetic\numexpr#1\relax{korean}}
+\permanent\def\koreannumeralsp #1{\clf_alphabetic\numexpr#1\relax{korean-parenthesis}}
+\permanent\def\koreannumeralsc #1{\clf_alphabetic\numexpr#1\relax{korean-circle}}
+
+\aliased \let\koreanparentnumerals \koreannumeralsp
+\aliased \let\koreanparenthesisnumerals\koreannumeralsp
+\aliased \let\koreancirclenumerals \koreannumeralsc
+
+\permanent\def\chinesenumerals #1{\clf_chinesenumerals\numexpr#1\relax{normal}}
+\permanent\def\chinesecapnumerals#1{\clf_chinesenumerals\numexpr#1\relax{cap}}
+\permanent\def\chineseallnumerals#1{\clf_chinesenumerals\numexpr#1\relax{all}}
+
+%D \macros
+%D {character,Character}
+%D
+%D Converting a number into a character can of course only be done with numbers
+%D less or equal to~26. At the cost of much more macros a faster conversion is
+%D possible, using:
+%D
+%D \starttyping
+%D \setvalue{char1}{a} \def\character#1{\getvalue{char#1}}
+%D \stoptyping
+%D
+%D But we prefer a simpel \type{\case}.
+%D
+%D \showsetup{character}
+%D \showsetup{Character}
+
+\permanent\def\character#1{\clf_character\numexpr#1\relax}
+\permanent\def\Character#1{\clf_Character\numexpr#1\relax}
+
+%D \macros
+%D {characters,Characters}
+%D
+%D Converting large numbers is supported by the next two macros. This time we
+%D just count on: $\cdots$~x, y, z, aa, ab, ac~$\cdots$.
+%D
+%D \showsetup{characters}
+%D \showsetup{Characters}
+
+\permanent\def\characters#1{\clf_characters\numexpr#1\relax}
+\permanent\def\Characters#1{\clf_Characters\numexpr#1\relax}
+
+%D \macros
+%D {greeknumerals,Greeknumerals}
+%D
+%D Why should we only honour the romans, and not the greek?
+
+% \let\greeknumerals\gobbleoneargument
+% \let\Greeknumerals\gobbleoneargument
+
+%D \macros
+%D {oldstylenumerals,oldstyleromannumerals}
+%D
+%D These conversions are dedicated to Frans Goddijn.
+
+\permanent\protected\def\oldstylenumerals#1%
+ {\begingroup
+ \os\number#1%
+ \endgroup}
+
+\permanent\protected\def\oldstyleromannumerals#1% will become obsolete
+ {\dontleavehmode
+ \hbox\bgroup
+ \ss\txx
+ \setbox\scratchbox\hbox \s!spread .15\emwidth{\hss\uppercased{\romannumerals{#1}}\hss}%
+ \scratchwidth \wd\scratchbox
+ \scratchheight\ht\scratchbox
+ \scratchdimen .1\exheight
+ \vrule\s!width\scratchwidth\s!height\dimexpr\scratchheight+\scratchdimen\relax\s!depth-\dimexpr\scratchheight-+\scratchdimen\relax
+ \hskip-\scratchwidth
+ \vrule\s!width\scratchwidth\s!height\scratchdimen\s!depth\scratchdimen
+ \hskip-\scratchwidth
+ \box\scratchbox
+ \egroup}
+
+%D \macros
+%D {normaltime,normalyear,normalmonth,normalday}
+%D
+%D The last part of this module is dedicated to converting dates. Because we want to
+%D use as meaningful commands as possible, and because \TEX\ already uses up some of
+%D those, we save the original meanings.
+
+% \savenormalmeaning\time
+% \savenormalmeaning\year
+% \savenormalmeaning\month
+% \savenormalmeaning\day
+
+%D \macros
+%D {month,MONTH}
+%D
+%D Converting the month number into a month name is done using a case statement,
+%D abstact values and the label mechanism. This way users can easily redefine a
+%D label from for instance german into austrian.
+%D
+%D \starttyping
+%D \setuplabeltext [de] [january=J\"anner]
+%D \stoptyping
+%D
+%D Anyhow, the conversion looks like:
+
+\permanent\protected\def\monthlong #1{\clf_monthname\numexpr#1\relax}
+\permanent\protected\def\monthshort#1{\clf_monthmnem\numexpr#1\relax}
+\permanent\protected\def\daylong #1{\clf_dayname\numexpr#1\relax}
+\permanent\protected\def\dayshort #1{\clf_daymnem\numexpr#1\relax}
+\aliased \let\convertmonth\monthlong % for old times sake
+
+%D We redefine the \TEX\ primitive \type{\month} as:
+%D
+%D \showsetup{month}
+%D \showsetup{MONTH}
+
+\pushoverloadmode
+
+\aliased\let\month\monthlong
+
+\popoverloadmode
+
+\permanent\protected\def\MONTH #1{\WORD{\clf_monthname\numexpr#1\relax}}
+\permanent\protected\def\MONTHLONG #1{\WORD{\clf_monthname\numexpr#1\relax}}
+\permanent\protected\def\MONTHSHORT#1{\WORD{\clf_monthmnem\numexpr#1\relax}}
+
+%D We never explicitly needed this, but Tobias Burnus pointed out that it would be
+%D handy to convert to the day of the week. In doing so, we have to calculate the
+%D total number of days, taking leapyears into account. For those who are curious:
+%D
+%D \startitemize[packed]
+%D \item years that can be divided by 4 are leapyears
+%D \item exept years that can be divided by 100
+%D \item unless years can be divided by 400
+%D \stopitemize
+
+%D \macros
+%D {weekday,WEEKDAY}
+%D
+%D The first one is sort of redundant. It takes the day number argument.
+%D
+%D \showsetup{weekday}
+%D \showsetup{WEEKDAY}
+
+\permanent\protected\def\weekday #1{\clf_dayname\numexpr#1\relax}
+\permanent\protected\def\WEEKDAY #1{\WORD{\clf_dayname\numexpr#1\relax}}
+\permanent\protected\def\DAYLONG #1{\WORD{\clf_dayname\numexpr#1\relax}}
+\permanent\protected\def\DAYSHORT#1{\WORD{\clf_daymnem\numexpr#1\relax}}
+
+%D \macros
+%D {getdayoftheweek, dayoftheweek}
+
+\newcount\normalweekday
+
+\permanent \def\dayoftheweek #1#2#3{\clf_weekdayname\numexpr#1\relax\numexpr#2\relax\numexpr#3\relax} % name
+\permanent\protected\def\getdayoftheweek#1#2#3{\normalweekday\clf_weekday\numexpr#1\relax\numexpr#2\relax\numexpr#3\relax\relax} % number
+
+%D Using this macro in
+%D
+%D \startbuffer
+%D monday: \dayoftheweek {4} {5} {1992}
+%D friday: \dayoftheweek {16} {6} {1995}
+%D monday: \dayoftheweek {25} {8} {1997}
+%D saturday: \dayoftheweek {30} {8} {1997}
+%D tuesday: \dayoftheweek {2} {1} {1996}
+%D tuesday: \dayoftheweek {7} {1} {1997}
+%D tuesday: \dayoftheweek {13} {1} {1998}
+%D friday: \dayoftheweek {1} {1} {2000}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D gives
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+%D
+%D The macro \type {\getdayoftheweek} can be used to calculate the number \type
+%D {\normalweekday}.
+
+%D \macros
+%D {doifleapyearelse,
+%D getdayspermonth}
+%D
+%D Sometimes we need to know if we're dealing with a leapyear, so here is a
+%D testmacro:
+%D
+%D \starttyping
+%D \doifleapyearelse{year}{yes}{no}
+%D \stoptyping
+%D
+%D An example of its use can be seen in the macro
+%D
+%D \starttyping
+%D \getdayspermonth{year}{month}
+%D \stoptyping
+%D
+%D The number of days is available in the macro \type {\numberofdays}.
+
+\permanent\def\doifelseleapyear#1% expandable check
+ {\clf_doifelseleapyear\numexpr#1\relax}
+
+\aliased\let\doifleapyearelse\doifelseleapyear
+
+\mutable\let\numberofdays\!!zerocount
+
+\permanent\protected\def\getdayspermonth#1#2%
+ {\edef\numberofdays{\clf_nofdays\numexpr#1\relax\numexpr#2\relax}}
+
+\permanent\def\dayspermonth#1#2%
+ {\clf_nofdays\numexpr#1\relax\numexpr#2\relax}
+
+% \dayoftheweek{2006}{9}{15}
+% \doifleapyearelse{2000}{OK}{NOT OK}
+% \doifleapyearelse{2100}{NOT OK}{OK}
+% \doifleapyearelse{2004}{OK}{NOT OK}
+% \doifleapyearelse{2003}{NOT OK}{OK}
+% \dayspermonth{2000}{2}
+% [\the\normaltime=\the\time]
+
+%D \macros
+%D {currentdate, rawdate, date}
+%D
+%D We use these conversion macros in the date formatting macro:
+%D
+%D \showsetup{currentdate}
+%D
+%D This macro takes care of proper spacing and delivers for instance:
+%D
+%D \startbuffer
+%D \currentdate[weekday,day,month,year]
+%D \currentdate[WEEKDAY,day,MONTH,year]
+%D \stopbuffer
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+%D
+%D depending of course on the keywords. Here we gave:
+%D
+%D \typebuffer
+%D
+%D If needed one can also add non||keywords, like in
+%D
+%D \startbuffer
+%D \currentdate[dd,--,mm,--,yy]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D or typeset: \getbuffer.
+%D
+%D When no argument is passed, the current date is given as specified per
+%D language (using \type{\installlanguage}).
+%D
+%D \showsetup{currentdate}
+%D
+%D \startbuffer
+%D \date
+%D \date[d=12,m=12,y=1998][weekday]
+%D \date[d=12,m=12,y=1998]
+%D \stopbuffer
+%D
+%D We can also typeset arbitrary dates, using the previous
+%D command.
+%D
+%D \typebuffer
+%D
+%D The date is specified by one character keys. When no date is given, we get the
+%D current date.
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+
+%D \starttabulate[|l|l|]
+%D \HL
+%D \NC year \NC (\currentdate[year]) \NC\NR
+%D \NC yy \NC (\currentdate[yy]) \NC\NR
+%D \NC y \NC (\currentdate[y]) \NC\NR
+%D \NC Y \NC (\currentdate[Y]) \NC\NR
+%D \HL
+%D \NC month \NC (\currentdate[month]) \NC\NR
+%D \NC mm \NC (\currentdate[mm]) \NC\NR
+%D \NC m \NC (\currentdate[m]) \NC\NR
+%D \NC M \NC (\currentdate[M]) \NC\NR
+%D \HL
+%D \NC day \NC (\currentdate[day]) \NC\NR
+%D \NC dd \NC (\currentdate[dd]) \NC\NR
+%D \NC d \NC (\currentdate[d]) \NC\NR
+%D \NC D \NC (\currentdate[D]) \NC\NR
+%D \HL
+%D \NC weekday \NC (\currentdate[weekday]) \NC\NR
+%D \NC w \NC (\currentdate[w]) \NC\NR
+%D \NC W \NC (\currentdate[W]) \NC\NR
+%D \HL
+%D \NC referral \NC (\currentdate[referral]) \NC\NR
+%D \HL
+%D \NC day:mnem \NC (\currentdate[day:mnem]) \NC\NR
+%D \NC dd:mnem \NC (\currentdate[dd:mnem]) \NC\NR
+%D \NC d:mnem \NC (\currentdate[d:mnem]) \NC\NR
+%D \NC D:mnem \NC (\currentdate[D:mnem]) \NC\NR
+%D \HL
+%D \stoptabulate
+%D
+%D \startbuffer
+%D (\currentdate[D,.,M,.,Y])
+%D (\currentdate[day,month,year])
+%D (\currentdate[day,+,month,+,year])
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D Some indirectness and abstraction:
+%D
+%D \starttyping
+%D \definedate[crap][year]
+%D \currentdate[crap]
+%D \stoptyping
+
+\installcorenamespace{date}
+
+\permanent\tolerant\protected\def\definedate[#1]#*[#2]%
+ {\ifarguments\else\setvalue{\??date#1}{#2}\fi}
+
+\def\syst_converters_check_date_specification#1%
+ {\ifcsname\??date#1\endcsname
+ \edef#1{\lastnamedcs}%
+ \fi}
+
+\newtoks\everycurrentdate
+
+\permanent\tolerant\protected\def\currentdate[#1]%
+ {\dontleavehmode
+ \begingroup
+ \the\everycurrentdate
+ \edef\m_syst_converters_date{#1}%
+ \syst_converters_check_date_specification\m_syst_converters_date
+ \syst_converters_check_date_specification\currentdatespecification
+ \clf_currentdate
+ {\m_syst_converters_date}{\currentdatespecification}{\labellanguage}%
+ \normalyear\normalmonth\normalday
+ \endgroup}
+
+\permanent\tolerant\protected\def\setdate[#1]% sets the date !
+ {\begingroup
+ \letdummyparameter\c!d\normalday
+ \letdummyparameter\c!m\normalmonth
+ \letdummyparameter\c!y\normalyear
+ \getdummyparameters[#1]%
+ \normalexpanded
+ {\endgroup
+ \iftok{\directdummyparameter\c!d}\emptytoks\else\normalday \number\directdummyparameter\c!d\relax\fi
+ \iftok{\directdummyparameter\c!m}\emptytoks\else\normalmonth\number\directdummyparameter\c!m\relax\fi
+ \iftok{\directdummyparameter\c!y}\emptytoks\else\normalyear \number\directdummyparameter\c!y\relax\fi}}
+
+\permanent\tolerant\protected\def\date[#1]#*[#2]% sets the date !
+ {\dontleavehmode
+ \begingroup
+ \setdate[#1]% sets the date !
+ \the\everycurrentdate
+ \edef\m_syst_converters_date{#2}%
+ \syst_converters_check_date_specification\m_syst_converters_date
+ \syst_converters_check_date_specification\currentdatespecification
+ \clf_currentdate
+ {\m_syst_converters_date}{\currentdatespecification}{\labellanguage}%
+ \normalyear\normalmonth\normalday
+ \endgroup}
+
+\permanent\def\rawdate[#1]% expandable and no labels
+ {\clf_currentdate
+ {#1}{\currentdatespecification}{}%
+ \normalyear\normalmonth\normalday}
+
+%D \macros
+%D {currenttime}
+%D
+%D The currenttime is actually the jobtime. You can specify a pattern similar
+%D to the previous date macro using the keys \type {h}, \type {m} and a separator.
+
+\mutable\let\currenthour \!!plusone
+\mutable\let\currentminute\!!plusone
+\mutable\let\currentsecond\!!plusone
+
+\permanent\protected\def\calculatecurrenttime
+ {\edef\currenthour {\clf_hour }%
+ \edef\currentminute{\clf_minute}%
+ \edef\currentsecond{\clf_second}}
+
+% \def\currenttimespecification{h,:,m}
+
+\permanent\protected\def\currenttime
+ {\doifelsenextoptional\syst_converters_current_time_yes\syst_converters_current_time_nop}
+
+\protected\def\syst_converters_current_time_yes[#1]%
+ {\calculatecurrenttime
+ \processallactionsinset[#1][h=>\currenthour,m=>\currentminute,\s!unknown=>\commalistelement]}
+
+\protected\def\syst_converters_current_time_nop
+ {\normalexpanded{\syst_converters_current_time_yes[\currenttimespecification]}}
+
+%D Because we're dealing with dates, we also introduce a few day loops:
+%D
+%D \starttyping
+%D \processmonth{year}{month}{command}
+%D \processyear{year}{command}{before}{after}
+%D \stoptyping
+%D
+%D The counters \type {\normalyear}, \type {\normalmonth} and \type {\normalday}
+%D can be used for for date manipulations.
+
+\permanent\protected\def\processmonth#1#2#3% year month command
+ {\begingroup
+ \getdayspermonth{#1}{#2}%
+ \dostepwiserecurse\plusone\numberofdays\plusone
+ {\normalyear #1\relax
+ \normalmonth#2\relax
+ \normalday \recurselevel\relax
+ #3}%
+ \endgroup}
+
+\permanent\protected\def\processyear#1#2#3#4% year command before after
+ {\begingroup
+ \dorecurse\plustwelve
+ {\normalyear #1\relax
+ \normalmonth\recurselevel\relax
+ #3\processmonth\normalyear\normalmonth{#2}#4}%
+ \endgroup}
+
+%D \macros
+%D {defineconversion, convertnumber}
+%D
+%D Conversion involves the macros that we implemented earlier in this module.
+%D
+%D \showsetup{defineconversion}
+%D \showsetup{convertnumber}
+%D
+%D We can feed this command with conversion macros as well as a set of conversion
+%D symbols. Both need a bit different treatment.
+%D
+%D \starttyping
+%D \defineconversion [roman] [\romannumerals]
+%D \defineconversion [set 1] [$\star$,$\bullet$,$\ast$]
+%D \stoptyping
+%D
+%D You can define a language dependent conversion with:
+%D
+%D \starttyping
+%D \defineconversion [en] [whatever] [\something]
+%D \stoptyping
+
+\installcorenamespace {conversion}
+\installcorenamespace {conversionarguments}
+\installcorenamespace {conversionwords}
+
+%D It might be better to move more to \LUA\ as we also need conversion there and
+%D doublicating logic doesn't make things cleaner. It means that all conversions
+%D will get a language argument too. However, we permit definitions at the \TEX\ end
+%D so we have to provide some hybrid method.
+
+% checkedconversion(method,n,language)
+
+\permanent\tolerant\protected\def\defineconversion[#1]#*[#2]#*[#3]% from now on global (maybe local again some day)
+ {\ifparameter#3\or
+ \syst_converters_define_conversion_indeed{#1#2}{#1:#2}{#3}%
+ \else
+ \syst_converters_define_conversion_indeed{#1}{#1}{#2}%
+ \fi}
+
+\def\syst_converters_define_conversion_indeed#1#2#3%
+ {\doifelseinstring{,}{\detokenize{#3}}
+ {\clf_defineconversion{#2}{\detokenize{#3}}% a set e.g. of symbols
+ \setgvalue{\??conversion#1}{\syst_converters_checked_conversion{#2}}}
+ {\setgvalue{\??conversion#1}{#3}}}
+
+\def\syst_converters_checked_conversion#1#2%
+ {\clf_checkedconversion{#1}\numexpr#2\relax}
+
+%D If a conversion is just a font switch then we need to make sure that the number
+%D is indeed ends up as number in the input, so we need to handle the second
+%D argument.
+
+\permanent\def\convertnumber#1#2% expandable
+ {\csname\??conversionarguments
+ \ifcsname\??conversion\currentlanguage#1\endcsname1\else
+ \ifcsname\??conversion #1\endcsname2\else
+ 3\fi\fi
+ \endcsname{#1}{\number#2}}
+
+\permanent\protected\def\uconvertnumber % unexpandable
+ {\convertnumber}
+
+\setvalue{\??conversionarguments1}#1{\csname\??conversion\currentlanguage#1\endcsname}
+\setvalue{\??conversionarguments2}#1{\csname\??conversion #1\endcsname}
+\letvalue{\??conversionarguments3}\syst_converters_checked_conversion
+
+% we can also add a \ctxcommand{doifelseconversion("#1","\currentlanguage")} to check
+% if we have definitions that are not matched at the lua end .. eventually we might do
+% that when more shows up
+
+\permanent\def\doifelseconversiondefined#1% expandable
+ {\ifcsname\??conversion\currentlanguage#1\endcsname
+ \expandafter\firstoftwoarguments
+ \orelse\ifcsname\??conversion#1\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\permanent\def\doifelseconversionnumber#1#2% expandable
+ {\ifnum#2>\numexpr\clf_nofconversions{#1}\relax
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\aliased\let\doifconversiondefinedelse\doifelseconversiondefined
+\aliased\let\doifconversionnumberelse \doifelseconversionnumber
+
+%D Handy.
+
+\setvalue{\??conversionwords\v!one }{1}
+\setvalue{\??conversionwords\v!two }{2}
+\setvalue{\??conversionwords\v!three}{3}
+\setvalue{\??conversionwords\v!four }{4}
+\setvalue{\??conversionwords\v!five }{5}
+
+%permanent\def\wordtonumber#1#2{\ifcsname\??conversionwords#1\endcsname\csname\??conversionwords#1\endcsname\else#2\fi}
+\permanent\def\wordtonumber#1#2{\ifcsname\??conversionwords#1\endcsname\lastnamedcs\else#2\fi}
+
+% \defineconversion[ctx][c,o,n,t,e,x,t]
+%
+% \doloop{\doifelseconversionnumber{ctx}{\recurselevel}{[\recurselevel]}{\exitloop}}
+
+%D \macros
+%D {ordinalnumber, highordinalstr, ordinalstr}
+%D
+%D Efficient general ordinal number converters are sometimes difficult to
+%D implement. Fortunately dates never exceed the number~31.
+
+\permanent\def\highordinalstr#1{\high{\notsmallcapped{#1}}}
+\permanent\def\ordinalstr #1{\notsmallcapped{#1}}
+\permanent\def\ordinalnumber #1{\clf_ordinal\numexpr#1\relax{\currentlanguage}}
+\permanent\def\Ordinalnumber #1{\Words{\clf_ordinal\numexpr#1\relax{\currentlanguage}}}
+
+\mutable\let\verbosenumberconnector\space
+
+\permanent\def\verbosenumber#1{\clf_verbose\numexpr#1\relax{\currentlanguage}{\verbosenumberconnector}}
+\permanent\def\VerboseNumber#1{\Words{\clf_verbose\numexpr#1\relax{\currentlanguage}{\verbosenumberconnector}}}
+
+%D As longs as symbols are linked to levels or numbers, we can also use the
+%D conversion mechanism, but in for instance the itemization macros, we prefer
+%D symbols because they can more easier be (partially) redefined. Symbols are
+%D implemented in another module.
+
+\permanent\def\smallcappedromannumerals#1{\smallcapped{\romannumerals{#1}}}
+\permanent\def\smallcappedcharacters #1{\smallcapped{\characters {#1}}}
+
+\defineconversion [] [\numbers] % the default conversion
+\defineconversion [\v!empty] [\gobbleoneargument]
+\defineconversion [\v!none] [\numbers]
+\defineconversion [\s!default] [\numbers]
+
+\defineconversion [month] [\monthlong]
+\defineconversion [month:mnem] [\monthshort]
+
+\defineconversion [\v!character] [\character]
+\defineconversion [\v!Character] [\Character]
+
+\defineconversion [\v!characters] [\characters]
+\defineconversion [\v!Characters] [\Characters]
+
+\defineconversion [a] [\alphabeticnumerals]
+\defineconversion [A] [\Alphabeticnumerals]
+\defineconversion [AK] [\smallcappedcharacters]
+\defineconversion [KA] [\smallcappedcharacters]
+
+\defineconversion [\v!alphabetic] [\alphabeticnumerals]
+\defineconversion [\v!Alphabetic] [\Alphabeticnumerals]
+
+\defineconversion [\v!number] [\numbers]
+\defineconversion [\v!numbers] [\numbers]
+\defineconversion [\v!Numbers] [\Numbers]
+\defineconversion [\v!mediaeval] [\mediaeval]
+
+\defineconversion [\v!word] [\verbosenumber]
+\defineconversion [\v!words] [\verbosenumber]
+
+\defineconversion [\v!Word] [\VerboseNumber]
+\defineconversion [\v!Words] [\VerboseNumber]
+
+\defineconversion[\v!ordinal] [\ordinalnumber]
+\defineconversion[\v!Ordinal] [\Ordinalnumber]
+
+\defineconversion [n] [\numbers]
+\defineconversion [N] [\Numbers]
+\defineconversion [m] [\mediaeval]
+\defineconversion [o] [\oldstylenumerals]
+\defineconversion [O] [\oldstylenumerals]
+\defineconversion [or] [\oldstyleromannumerals]
+
+\defineconversion [\v!romannumerals] [\romannumerals]
+\defineconversion [\v!Romannumerals] [\Romannumerals]
+
+\defineconversion [i] [\romannumerals]
+\defineconversion [I] [\Romannumerals]
+\defineconversion [r] [\romannumerals]
+\defineconversion [R] [\Romannumerals]
+
+\defineconversion [KR] [\smallcappedromannumerals]
+\defineconversion [RK] [\smallcappedromannumerals]
+
+\defineconversion [\v!greek] [\greeknumerals]
+\defineconversion [\v!Greek] [\Greeknumerals]
+
+\defineconversion [g] [\greeknumerals]
+\defineconversion [G] [\Greeknumerals]
+
+%defineconversion [ñ] [\spanishnumerals]
+%defineconversion [Ñ] [\Spanishnumerals]
+
+\defineconversion [abjadnumerals] [\abjadnumerals]
+\defineconversion [abjadnodotnumerals] [\abjadnodotnumerals]
+\defineconversion [abjadnaivenumerals] [\abjadnaivenumerals]
+
+\defineconversion [hebrewnumerals] [\hebrewnumerals]
+\defineconversion [yiddishnumerals] [\yiddishnumerals]
+
+% users can do: \defineconversion [he] [\hebrewnumerals]
+% users can do: \defineconversion [yi] [\hebrewnumerals]
+
+\defineconversion [thainumerals] [\thainumerals]
+\defineconversion [devanagarinumerals] [\devanagarinumerals]
+\defineconversion [gurmurkhinumerals] [\gurmurkhinumerals]
+\defineconversion [gujaratinumerals] [\gujaratinumerals]
+\defineconversion [tibetannumerals] [\tibetannumerals]
+\defineconversion [greeknumerals] [\greeknumerals]
+\defineconversion [Greeknumerals] [\Greeknumerals]
+\defineconversion [arabicnumerals] [\arabicnumerals]
+\defineconversion [persiannumerals] [\persiannumerals]
+\defineconversion [arabicexnumerals] [\arabicexnumerals]
+\defineconversion [arabicdecimals] [\arabicdecimals]
+\defineconversion [persiandecimals] [\persiandecimals]
+
+\defineconversion [koreannumerals] [\koreannumerals]
+\defineconversion [koreanparennumerals] [\koreanparenthesisnumerals] % for old times sake (for a while)
+\defineconversion [koreanparenthesisnumerals]
+ [\koreanparenthesisnumerals]
+\defineconversion [koreancirclenumerals] [\koreancirclenumerals]
+
+\defineconversion [kr] [\koreannumerals]
+\defineconversion [kr-p] [\koreanparentnumerals]
+\defineconversion [kr-c] [\koreancirclenumerals]
+
+\defineconversion [chinesenumerals] [\chinesenumerals]
+\defineconversion [chinesecapnumerals] [\chinesecapnumerals]
+\defineconversion [chineseallnumerals] [\chineseallnumerals]
+
+\defineconversion [cn] [\chinesenumerals]
+\defineconversion [cn-c] [\chinesecapnumerals]
+\defineconversion [cn-a] [\chineseallnumerals]
+
+%D Moved from lang-def.mkiv:
+%D
+%D Define these as the general character enumeration when language is Slovenian. If
+%D you feel uncomfortable with this, mail Mojca, since she promised to to take the
+%D heat. Pablo was next to request this. We changed characters to numerals for this
+%D feature. We do need these definitions for mechanisms like itemize that check
+%D for converters.
+
+\permanent\def\sloveniannumerals#1{\clf_alphabetic\numexpr#1\relax{sl}}
+\permanent\def\slovenianNumerals#1{\clf_Alphabetic\numexpr#1\relax{sl}}
+
+\permanent\def\spanishnumerals #1{\clf_alphabetic\numexpr#1\relax{es}}
+\permanent\def\spanishNumerals #1{\clf_Alphabetic\numexpr#1\relax{es}}
+
+\permanent\def\russiannumerals #1{\clf_alphabetic\numexpr#1\relax{ru}}
+\permanent\def\russianNumerals #1{\clf_Alphabetic\numexpr#1\relax{ru}}
+
+%defineconversion [\s!sl] [character] [\sloveniannumerals]
+%defineconversion [\s!sl] [Character] [\slovenianNumerals]
+%defineconversion [\s!sl] [characters] [\sloveniannumerals]
+%defineconversion [\s!sl] [Characters] [\slovenianNumerals]
+
+\defineconversion [\s!sl] [alphabetic] [\sloveniannumerals]
+\defineconversion [\s!sl] [Alphabetic] [\slovenianNumerals]
+
+\defineconversion [\s!sl] [a] [\sloveniannumerals]
+\defineconversion [\s!sl] [A] [\slovenianNumerals]
+\defineconversion [\s!sl] [AK] [\smallcapped\sloveniannumerals]
+\defineconversion [\s!sl] [KA] [\smallcapped\sloveniannumerals]
+
+%defineconversion [\s!es] [character] [\spanishnumerals]
+%defineconversion [\s!es] [Character] [\spanishNumerals]
+%defineconversion [\s!es] [characters] [\spanishnumerals]
+%defineconversion [\s!es] [Characters] [\spanishNumerals]
+
+\defineconversion [\s!es] [alphabetic] [\spanishnumerals]
+\defineconversion [\s!es] [Alphabetic] [\spanishNumerals]
+
+\defineconversion [\s!es] [a] [\spanishnumerals]
+\defineconversion [\s!es] [A] [\spanishNumerals]
+\defineconversion [\s!es] [AK] [\smallcapped\spanishnumerals]
+\defineconversion [\s!es] [KA] [\smallcapped\spanishnumerals]
+
+%defineconversion [\s!ru] [character] [\russiannumerals]
+%defineconversion [\s!ru] [Character] [\russianNumerals]
+%defineconversion [\s!ru] [characters] [\russiannumerals]
+%defineconversion [\s!ru] [Characters] [\russianNumerals]
+
+\defineconversion [\s!ru] [alphabetic] [\russiannumerals]
+\defineconversion [\s!ru] [Alphabetic] [\russianNumerals]
+
+\defineconversion [\s!ru] [a] [\russiannumerals]
+\defineconversion [\s!ru] [A] [\russianNumerals]
+\defineconversion [\s!ru] [AK] [\smallcapped\russiannumerals]
+\defineconversion [\s!ru] [KA] [\smallcapped\russiannumerals]
+
+\defineconversion [sloveniannumerals] [\sloveniannumerals]
+\defineconversion [slovenianNumerals] [\slovenianNumerals]
+
+\defineconversion [spanishnumerals] [\spanishnumerals]
+\defineconversion [spanishNumerals] [\spanishNumerals]
+
+\defineconversion [russiannumerals] [\russiannumerals]
+\defineconversion [russianNumerals] [\russianNumerals]
+
+%D In case a font has no greek (WS):
+
+\defineconversion [mathgreek]
+ [\m{α},\m{β},\m{γ},\m{δ},\m{ε},\m{ζ},
+ \m{η},\m{θ},\m{ι},\m{κ},\m{λ},\m{μ},
+ \m{ν},\m{ξ},\m{ο},\m{π},\m{ρ},\m{σ},
+ \m{τ},\m{υ},\m{φ},\m{χ},\m{ψ},\m{ω}]
+
+%D Handy too (expanded!):
+
+\permanent\def\unihex#1{\clf_unihex\numexpr#1\relax}
+
+%D Symbol sets:
+
+\ifdefined\symbol \else \def\symbol[#1]{#1} \fi % todo
+
+% \defineconversion
+% [set 0]
+% [{\symbol[bullet]},
+% {\symbol[dash]},
+% {\symbol[star]},
+% {\symbol[triangle]},
+% {\symbol[circle]},
+% {\symbol[medcircle]},
+% {\symbol[bigcircle]},
+% {\symbol[square]},
+% {\symbol[checkmark]}]
+
+% \defineconversion
+% [set 1]
+% [\mathematics{\star},
+% \mathematics{\star\star},
+% \mathematics{\star\star\star},
+% \mathematics{\ddagger},
+% \mathematics{\ddagger\ddagger},
+% \mathematics{\ddagger\ddagger\ddagger},
+% \mathematics{\ast},
+% \mathematics{\ast\ast},
+% \mathematics{\ast\ast\ast}]
+%
+% \defineconversion
+% [set 2]
+% [\mathematics{\ast},
+% \mathematics{\dag},
+% \mathematics{\ddag},
+% \mathematics{\ast\ast},
+% \mathematics{\dag\dag},
+% \mathematics{\ddag\ddag},
+% \mathematics{\ast\ast\ast},
+% \mathematics{\dag\dag\dag},
+% \mathematics{\ddag\ddag\ddag},
+% \mathematics{\ast\ast\ast\ast},
+% \mathematics{\dag\dag\dag\dag},
+% \mathematics{\ddag\ddag\ddag\ddag}]
+%
+% \defineconversion
+% [set 3]
+% [\mathematics{\star},
+% \mathematics{\star\star},
+% \mathematics{\star\star\star},
+% \mathematics{\ddagger},
+% \mathematics{\ddagger\ddagger},
+% \mathematics{\ddagger\ddagger\ddagger},
+% \mathematics{\P},
+% \mathematics{\P\P},
+% \mathematics{\P\P\P},
+% \mathematics{\S},
+% \mathematics{\S\S},
+% \mathematics{\S\S\S},
+% \mathematics{\ast},
+% \mathematics{\ast\ast},
+% \mathematics{\ast\ast\ast}]
+
+\defineconversion
+ [set 0]
+ [\symbol{bullet},
+ \symbol{dash},
+ \symbol{star},
+ \symbol{triangle},
+ \symbol{circle},
+ \symbol{medcircle},
+ \symbol{bigcircle},
+ \symbol{square},
+ \symbol{checkmark}]
+
+\defineconversion
+ [set 1]
+ [\textormathchars{⋆},
+ \textormathchars{⋆⋆},
+ \textormathchars{⋆⋆⋆},
+ \textormathchars{‡},
+ \textormathchars{‡‡},
+ \textormathchars{‡‡‡},
+ \textormathchars{∗},
+ \textormathchars{∗∗},
+ \textormathchars{∗∗∗}]
+
+\defineconversion
+ [set 2]
+ [\textormathchars{∗},
+ \textormathchars{†},
+ \textormathchars{‡},
+ \textormathchars{∗∗},
+ \textormathchars{††},
+ \textormathchars{‡‡},
+ \textormathchars{∗∗∗},
+ \textormathchars{†††},
+ \textormathchars{‡‡‡},
+ \textormathchars{∗∗∗∗},
+ \textormathchars{††††},
+ \textormathchars{‡‡‡‡}]
+
+\defineconversion
+ [set 3]
+ [\textormathchars{⋆},
+ \textormathchars{⋆⋆},
+ \textormathchars{⋆⋆⋆},
+ \textormathchars{‡},
+ \textormathchars{‡‡},
+ \textormathchars{‡‡‡},
+ \textormathchars{¶},
+ \textormathchars{¶¶},
+ \textormathchars{¶¶¶},
+ \textormathchars{§},
+ \textormathchars{§§},
+ \textormathchars{§§§},
+ \textormathchars{∗},
+ \textormathchars{∗∗},
+ \textormathchars{∗∗∗}]
+
+%D Iteration of suggestion by WS on mailinglist 2010.12.22:
+%D
+%D \starttyping
+%D \setupfloatsplitting[conversion=continued]
+%D \stoptyping
+
+\permanent\protected\def\continuednumber#1%
+ {\labeltext{\ifcase#1\or\else\v!continued\fi}}
+
+\defineconversion
+ [\v!continued]
+ [\continuednumber]
+
+%D Taken from x-asciimath (see digits-001.tex for an example):
+
+\mutable\let\spaceddigitsmethod \empty % alternative methods : 1 default, 2 and 3 only when > 4
+\mutable\let\spaceddigitssymbol \empty % extra splitter symbol : {,}
+\mutable\let\spaceddigitsseparator\empty % separator symbol : {\Uchar{"2008}}
+
+\permanent\protected\def\spaceddigits#1%
+ {\clf_spaceddigits
+ method {\spaceddigitsmethod}%
+ symbol {\spaceddigitssymbol}%
+ separator {\spaceddigitsseparator}%
+ data {#1}%
+ \relax}
+
+%D For those who sart counting at zero:
+%D
+%D \starttyping
+%D \defineconversionset [zero] [n,zero] [n]
+%D
+%D \setuphead [sectionconversionset=zero]
+%D
+%D \starttext
+%D \startchapter [title=Introduction]
+%D \startsection [title=First topic] \stopsection
+%D \startsection [title=Second topic] \stopsection
+%D \stopchapter
+%D \stoptext
+%D \stoptyping
+
+\permanent\def\zeronumberconversion#1{\number\numexpr#1-\plusone\relax}
+
+\defineconversion [zero] [\zeronumberconversion]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-ctx.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-ctx.mkxl
new file mode 100644
index 00000000000..8837640d442
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-ctx.mkxl
@@ -0,0 +1,29 @@
+%D \module
+%D [ file=core-ctx,
+%D version=2006.08.16, % old stuff
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Job Control,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Job Control}
+
+\registerctxluafile{core-ctx}{}
+
+\unprotect
+
+% called directly in core-def.mkiv
+%
+% \protected\def\job_options_get_commandline {\clf_setdocumentcommandline}
+% \protected\def\job_options_get_ctxfile {\clf_setdocumentctxfile}
+% \protected\def\job_options_set_modes {\clf_setdocumentmodes}
+% \protected\def\job_options_set_modules {\clf_setdocumentmodules}
+% \protected\def\job_options_set_environments{\clf_setdocumentenvironments}
+% \protected\def\job_options_set_filenames {\clf_setdocumentfilenames}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-dat.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-dat.mkxl
new file mode 100644
index 00000000000..93d0bbb7ae8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-dat.mkxl
@@ -0,0 +1,110 @@
+%D \module
+%D [ file=core-dat,
+%D version=20122.04.17, % replaces core-two from 1997.03.31,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Multipass Datasets,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Multipass Datasets}
+
+%D \starttyping
+%D \definedataset[test-1]
+%D \definedataset[test-2][delay=yes]
+%D
+%D \startlines
+%D set 1: \setdataset[test-1][whatever=this-or-that-1]
+%D set 2: \setdataset[test-2][whatever=this-or-that-2]
+%D set 3: \setdataset[test-2][whatever=this-or-that-3]
+%D \stoplines
+%D
+%D \startlines
+%D get 1: \datasetvariable{test-1}{1}{whatever} / \datasetvariable{test-1}{1}{realpage}
+%D get 2: \datasetvariable{test-2}{1}{whatever} / \datasetvariable{test-2}{1}{realpage}
+%D get 3: \datasetvariable{test-2}{2}{whatever} / \datasetvariable{test-2}{2}{realpage}
+%D \stoplines
+%D \stoptyping
+
+\unprotect
+
+\registerctxluafile{core-dat}{}
+
+\installcorenamespace{dataset}
+
+\installcommandhandler \??dataset {dataset} \??dataset
+
+\permanent\tolerant\protected\def\setdataset[#1]#*[#2]#*[#3]%
+ {\begingroup
+ \edef\currentdataset{#1}%
+ \ifparameters\or\or
+ \clf_setdataset
+ name {\currentdataset}%
+ delay {\datasetparameter\c!delay}%
+ data {#2}%
+ \relax
+ \or
+ \edef\currentdataset{#1}%
+ \clf_setdataset
+ name {\currentdataset}%
+ tag {#2}%
+ delay {\datasetparameter\c!delay}%
+ data {#3}%
+ \relax
+ \fi
+ \endgroup}
+
+\permanent\def\datasetvariable#1#2#3%
+ {\clf_datasetvariable{#1}{#2}{#3}}
+
+\installcorenamespace{pagestate}
+\installcorenamespace{pagestatecounter}
+
+\installcommandhandler \??pagestate {pagestate} \??pagestate
+
+\def\syst_pagestates_allocate
+ {\expandafter\newcount\csname\??pagestatecounter\currentpagestate\endcsname}
+
+\appendtoks
+ \syst_pagestates_allocate
+\to \everydefinepagestate
+
+\setuppagestate
+ [\c!delay=\v!yes]
+
+\permanent\tolerant\protected\def\setpagestate[#1]#*[#2]%
+ {\begingroup
+ \edef\currentpagestate{#1}%
+ \ifcsname\??pagestatecounter\currentpagestate\endcsname
+ \scratchcounter\lastnamedcs
+ \advance\scratchcounter\plusone
+ \else
+ \scratchcounter\plusone
+ \syst_pagestates_allocate
+ \fi
+ \global\csname\??pagestatecounter\currentpagestate\endcsname\scratchcounter
+ \clf_setpagestate
+ name {\currentpagestate}%
+ tag {\ifparameter#2\or#2\else\number\scratchcounter\fi}%
+ delay {\pagestateparameter\c!delay}%
+ \relax
+ \endgroup}
+
+\permanent\protected\def\autosetpagestate#1%
+ {\setpagestate[#1]\relax}
+
+\permanent\def\autopagestatenumber#1{\begincsname\??pagestatecounter#1\endcsname}
+
+\permanent\def\pagestaterealpage #1#2{\clf_pagestaterealpage {#1}{#2}}
+\permanent\def\setpagestaterealpageno#1#2{\clf_setpagestaterealpageno{#1}{#2}}
+\permanent\def\pagestaterealpageorder#1#2{\clf_pagestaterealpageorder{#1}#2\relax}
+
+\permanent\def\autopagestaterealpage #1{\clf_pagestaterealpage {#1}{\number\autopagestatenumber{#1}}}
+\permanent\def\setautopagestaterealpageno#1{\clf_setpagestaterealpageno{#1}{\number\autopagestatenumber{#1}}}
+\permanent\def\autopagestaterealpageorder#1{\clf_pagestaterealpageorder{#1}\numexpr\autopagestatenumber{#1}\relax}
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-def.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-def.mkxl
new file mode 100644
index 00000000000..96570bc366d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-def.mkxl
@@ -0,0 +1,182 @@
+%D \module
+%D [ file=core-def,
+%D version=2002.05.07,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Defaults,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Defaults}
+
+%D Here we collect settings that cannot be done earlier due to
+%D depedencies. More code will moved to this module later.
+
+\unprotect
+
+\usesymbols[mis,nav] % no longer mvs preloaded
+
+\setupsymbolset[navigation 1]
+
+\setupinteraction[\c!symbolset=navigation 1]
+
+% what a mess
+
+\everypar \emptytoks
+\neverypar \emptytoks
+
+\appendtoks
+ % \flushnotes
+ \page_otr_command_synchronize_side_floats % an otr specific command
+ \checkindentation
+ \showparagraphnumber
+ \restoreinterlinepenalty
+ % \flushmargincontents
+ % \flushcommentanchors
+ \flushnotes
+ % \synchronizenotes
+ % \OTRSETshowstatus
+ \registerparoptions
+ % \flushsyncpositions
+ \flushpostponednodedata
+ \typo_delimited_repeat
+ \spac_paragraphs_flush_intro
+ \typo_initial_handle
+ \typo_firstline_handle
+ %
+ \spac_paragraph_wrap
+ \spac_paragraph_freeze
+\to \everypar
+
+\appendtoks
+ \flushnotes
+\to \everydisplay
+
+% \appendtoks
+% \adjustsidefloatdisplaylines
+% \to \everydisplay
+
+% \appendtoks
+% \flushpostponednodedata
+% \to \neverypar
+
+% \appendtoks
+% \flushsyncpositions
+% \to \everyheadstart
+
+% \appendtoks
+% \flushsyncresets
+% \to \everyendoftextbody
+
+\appendtoks
+ \ignorespaces
+\to \everybeginofpar
+
+\appendtoks
+ \removeunwantedspaces
+ % \strut % option ?
+ % \flushsyncresets
+ % \setlastlinewidth % gone, will be done in lua
+ \endgraf
+\to \everyendofpar
+
+% initialization order:
+
+\ifdefined\font_preloads_at_every_job \else \let\font_preloads_at_every_job \relax \fi
+\ifdefined\font_preloads_at_start_text \else \let\font_preloads_at_start_text\relax \fi
+\ifdefined\font_preloads_at_stop_text \else \let\font_preloads_at_stop_text \relax \fi
+
+\appendtoks
+ \font_preloads_at_start_text
+\to \everystarttext
+
+\appendtoks
+ \font_preloads_at_stop_text
+\to \everystoptext
+
+% We made \loadoptionfile obsolete: we pass options via the command line to
+% luatex now and handle them directly instead of via a file. This also makes
+% the next obsolete:
+%
+% \directsetup{*runtime:options}
+% \directsetup{*runtime:modules}
+
+\appendtoks
+ \showcontextbanner
+ %\initializenewlinechar
+ \calculatecurrenttime
+ \syst_files_load
+ % for the moment here (before doc env)
+ \setupoutput[pdf]%
+ %
+ \clf_setdocumentcommandline
+ \clf_setdocumentctxfile
+ \clf_setdocumentfilenames
+ \font_preloads_at_every_job
+ \settopskip % brrr
+ \initializemainlanguage
+ \initializepagebackgrounds
+ \initializepagecounters
+ \clf_setdocumentmodes
+ \clf_setdocumentmodules
+ \clf_setdocumentenvironments
+\to \everyjob
+
+\appendtoks
+ \ifarrangingpages\poparrangedpages\fi
+\to \everybye
+
+\prependtoks
+ \resetallattributes
+\to \everybeforeoutput
+
+\appendtoks
+ \the\everybackendshipout
+\to \everyshipout
+
+\prependtoks
+ \the\everylastbackendshipout
+\to \everylastshipout
+
+\prependtoks
+ \lefttoright
+\to \everybeforeoutput
+
+% temporary here:
+
+\pushoverloadmode
+ \frozen\protected\def\arg{\mathortext\normalmatharg\normaltextarg} % might be overloaded
+\popoverloadmode
+
+% might move to \everydump or even disappear:
+
+\nonknuthmode
+
+% brrr
+
+\appendtoks
+ \synchronizegloballinespecs
+ \synchronizelocallinespecs
+\to \everysetupbodyfont
+
+\appendtoks
+ \synchronizelocallinespecs
+\to \everyswitchtobodyfont
+
+% who knows
+
+% \appendtoks
+% \resetcharacterspacing
+% \to \everyhyphenatedurl
+
+% \setbreakpoints[compound]
+
+%D Till we fixed all styles:
+
+\enforced\let\\\crlf % frozen or permanent?
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-env.lmt b/Master/texmf-dist/tex/context/base/mkxl/core-env.lmt
new file mode 100644
index 00000000000..388e96787a0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-env.lmt
@@ -0,0 +1,213 @@
+if not modules then modules = { } end modules ['core-env'] = {
+ version = 1.001,
+ comment = "companion to core-env.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- maybe this will move to the context name space although the
+-- plurals are unlikely to clash with future tex primitives
+--
+-- if tex.modes['xxxx'] then .... else .... end
+
+local rawset = rawset
+
+local P, C, S, lpegmatch, patterns = lpeg.P, lpeg.C, lpeg.S, lpeg.match, lpeg.patterns
+
+local context = context
+local ctxcore = context.core
+
+local texgetcount = tex.getcount
+local texgetintegervalue = token.get_integer -- todo: in tex namespace
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+local setmetatablenewindex = table.setmetatablenewindex
+local setmetatablecall = table.setmetatablecall
+
+local createtoken = token.create
+local isdefined = tokens.isdefined
+
+texmodes = allocate { } tex.modes = texmodes
+texsystemmodes = allocate { } tex.systemmodes = texsystemmodes
+texconstants = allocate { } tex.constants = texconstants
+texconditionals = allocate { } tex.conditionals = texconditionals
+texifs = allocate { } tex.ifs = texifs
+texisdefined = allocate { } tex.isdefined = texisdefined
+
+local modes = { }
+local systemmodes = { }
+
+-- we could use the built-in tex.is[count|dimen|skip|toks] here but caching
+-- at the lua end is not that bad (and we need more anyway)
+
+local cache = tokens.cache
+
+-- we can have a modes cache too
+
+local commandcodes = tokens.commands
+local iftrue = cache["iftrue"].index
+
+-- local dimencode = cache["scratchdimen"] .command -- tokens.commands.register_dimen
+-- local countcode = cache["scratchcounter"].command -- tokens.commands.register_int
+-- local tokencode = cache["scratchtoks"] .command -- tokens.commands.register_toks
+-- local skipcode = cache["scratchskip"] .command -- tokens.commands.register_glue
+-- local muskipcode = cache["scratchmuskip"] .command -- tokens.commands.register_mu_glue
+-- local conditioncode = cache["iftrue"] .command -- tokens.commands.if_test
+
+-- local types = {
+-- [dimencode] = "dimen",
+-- [countcode] = "count",
+-- [tokencode] = "token",
+-- [skipcode] = "skip",
+-- [muskipcode] = "muskip",
+-- -- [attributecode] = "attribute",
+-- [conditioncode] = "condition"
+-- }
+
+local dimencode = commandcodes.register_dimen -- cache["scratchdimen"] .command -- tokens.commands.register_dimen
+local countcode = commandcodes.register_int -- cache["scratchcounter"].command -- tokens.commands.register_int
+local tokencode = commandcodes.register_toks -- ["scratchtoks"] .command -- tokens.commands.register_toks
+local skipcode = commandcodes.register_glue -- cache["scratchskip"] .command -- tokens.commands.register_glue
+local muskipcode = commandcodes.register_mu_glue -- cache["scratchmuskip"] .command -- tokens.commands.register_mu_glue
+local conditioncode = commandcodes.if_test -- cache["iftrue"] .command -- tokens.commands.if_test
+local integercode = commandcodes.integer
+
+local types = {
+ [dimencode] = "dimen",
+ [countcode] = "count",
+ [tokencode] = "token",
+ [skipcode] = "skip",
+ [muskipcode] = "muskip",
+ -- [attributecode] = "attribute",
+ [conditioncode] = "condition",
+ [integercode] = "integer",
+}
+
+setmetatableindex(texmodes, function(t,k)
+ local m = systemmodes[k]
+ if not m then
+ local n = "mode>" .. k
+ m = function() return texgetintegervalue(n) == 1 end
+ rawset(modes,k,m)
+ end
+ return m()
+end)
+
+setmetatableindex(texsystemmodes, function(t,k)
+ local m = systemmodes[k]
+ if not m then
+ local n = "mode>*" .. k
+ m = function() return texgetintegervalue(n) == 1 end
+ rawset(modes,k,m)
+ end
+ return m()
+end)
+
+-- also a call method
+
+context.settrialtypesettingmethod(function() return texsystemmodes.trialtypesetting end)
+
+setmetatablenewindex(texmodes, function(t,k) report_mode("you cannot set the %s named %a this way","mode", k) end)
+setmetatablenewindex(texsystemmodes, function(t,k) report_mode("you cannot set the %s named %a this way","systemmode", k) end)
+setmetatablenewindex(texconstants, function(t,k) report_mode("you cannot set the %s named %a this way","constant", k) end)
+setmetatablenewindex(texconditionals, function(t,k) report_mode("you cannot set the %s named %a this way","conditional",k) end)
+setmetatablenewindex(texifs, function(t,k) end)
+
+-- if we really need performance we can have a dedicated cache for each
+-- kind of variable ... maybe we no longer have to cache anyway (in lmtx)
+
+setmetatableindex(texconstants, function(t,k)
+ -- return cache[k].command == countcode and texgetcount(k) or 0
+ return cache[k].command == integercode and texgetintegervalue(k) or 0
+end)
+
+setmetatableindex(texconditionals, function(t,k) -- 0 == true
+ -- return cache[k].command == countcode and texgetcount(k) == 0
+ return cache[k].command == integercode and texgetintegervalue(k) == 0
+end)
+
+setmetatableindex(texifs, function(t,k)
+ local c = cache[k]
+ return c.command == conditioncode and c.index == iftrue
+end)
+
+tex.isdefined = isdefined
+
+function tex.isdimen(name)
+ local hit = cache[name]
+ return hit.command == dimencode and hit.index or true
+end
+
+function tex.iscount(name)
+ local hit = cache[name]
+ return hit.command == countcode and hit.index or true
+end
+
+function tex.istoken(name)
+ local hit = cache[name]
+ return hit.command == tokencode and hit.index or true
+end
+
+function tex.isskip(name)
+ local hit = cache[name]
+ return hit.command == skipcode and hit.index or true
+end
+
+function tex.ismuskip(name)
+ local hit = cache[name]
+ return hit.command == muskipcode and hit.index or true
+end
+
+function tex.type(name)
+ return types[cache[name].command] or "macro"
+end
+
+function context.setconditional(name,value)
+ if value then
+ ctxcore.settruevalue(name)
+ else
+ ctxcore.setfalsevalue(name)
+ end
+end
+
+function context.setmode(name,value)
+ if value then
+ ctxcore.setmode(name)
+ else
+ ctxcore.resetmode(name)
+ end
+end
+
+function context.setsystemmode(name,value)
+ if value then
+ ctxcore.setsystemmode(name)
+ else
+ ctxcore.resetsystemmode(name)
+ end
+end
+
+context.modes = texmodes
+context.systemmodes = texsystemmodes
+context.conditionals = texconditionals
+-------.constants = texconstants
+-------.ifs = texifs
+
+local sep = S("), ")
+local str = C((1-sep)^1)
+local tag = P("(") * C((1-S(")" ))^1) * P(")")
+local arg = P("(") * C((1-S("){"))^1) * P("{") * C((1-P("}"))^0) * P("}") * P(")")
+
+local pattern = (
+ P("lua") * tag / ctxcore.luasetup
+ + P("xml") * arg / ctxcore.setupwithargument -- or xmlw as xmlsetup has swapped arguments
+ + (P("tex") * tag + str) / ctxcore.texsetup
+ + sep^1
+)^1
+
+interfaces.implement {
+ name = "autosetups",
+ actions = function(str) lpegmatch(pattern,str) end,
+ arguments = "string"
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-env.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-env.mkxl
new file mode 100644
index 00000000000..62e4106c574
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-env.mkxl
@@ -0,0 +1,807 @@
+%D \module
+%D [ file=core-env, % was core-new
+%D version=1995.01.01, % wrong
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=New ones,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Environments}
+
+\registerctxluafile{core-env}{autosuffix}
+
+\unprotect
+
+%D Modes:
+%D
+%D \starttyping
+%D \enablemode[screen,paper,bound]
+%D
+%D \doifmodeelse {paper} {this} {that}
+%D \doifmode {paper,screen} {this}
+%D \doifnotmode {paper,bound} {that}
+%D
+%D \startmode [list]
+%D \stopmode
+%D
+%D \startnotmode [list]
+%D \stopnotmode
+%D \stoptyping
+%D
+%D system modes have a * as prefix
+%D
+%D Sometimes, we want to prevent a mode for being set. Think of situations where a
+%D style enables a mode, but an outer level style does not want that. Preventing can
+%D be considered a permanent disabling on forehand.
+
+\aliased\let\systemmodeprefix\wildcardsymbol
+
+% we will have \installcorenamespace{mode} but need some hackery at the lua end then
+
+% TODO: make them mutable, also at the lua end
+
+\installcorenamespace{modestack}
+
+\immutable\def\??mode{mode>} % special namespace, also used at lua end
+
+\permanent\protected\def\newmode #1{\ifcsname \??mode#1\endcsname\else\resetmode{#1}\fi}
+\permanent\protected\def\setmode #1{\expandafter \integerdef\csname\??mode#1\endcsname\plusone}
+\permanent\protected\def\resetmode #1{\expandafter \integerdef\csname\??mode#1\endcsname\zerocount}
+\permanent\protected\def\globalsetmode #1{\global\expandafter\integerdef\csname\??mode#1\endcsname\plusone}
+\permanent\protected\def\globalresetmode #1{\global\expandafter\integerdef\csname\??mode#1\endcsname\zerocount}
+
+\permanent\protected\def\newsystemmode #1{\ifcsname \??mode\systemmodeprefix#1\endcsname\else\resetsystemmode{#1}\fi}
+\permanent\protected\def\setsystemmode #1{\expandafter \integerdef\csname\??mode\systemmodeprefix#1\endcsname\plusone}
+\permanent\protected\def\resetsystemmode #1{\expandafter \integerdef\csname\??mode\systemmodeprefix#1\endcsname\zerocount}
+\permanent\protected\def\globalsetsystemmode #1{\global\expandafter\integerdef\csname\??mode\systemmodeprefix#1\endcsname\plusone}
+\permanent\protected\def\globalresetsystemmode#1{\global\expandafter\integerdef\csname\??mode\systemmodeprefix#1\endcsname\zerocount}
+
+\expandafter \appendtoks
+ \expandafter\integerdef\csname\??mode\systemmodeprefix trialtypesetting\endcsname\plusone
+ \luacopyinputnodes\plusone
+\to \everysettrialtypesetting
+
+\expandafter \appendtoks
+ \expandafter\integerdef\csname\??mode\systemmodeprefix trialtypesetting\endcsname\zerocount
+ \luacopyinputnodes\zerocount
+\to \everyresettrialtypesetting
+
+\pushoverloadmode \newsystemmode{trialtypesetting} \popoverloadmode
+
+\the\everyresettrialtypesetting
+
+% user ones
+
+\mutable\let\syst_mode_prefix\relax
+
+\permanent\protected\def\preventmode{\unprotect\syst_modes_prevent}
+\permanent\protected\def\enablemode {\unprotect\syst_modes_enable }
+\permanent\protected\def\disablemode{\unprotect\syst_modes_disable}
+
+\permanent\protected\def\globalpreventmode{\let\syst_mode_prefix\global\unprotect\syst_modes_prevent}
+\permanent\protected\def\globalenablemode {\let\syst_mode_prefix\global\unprotect\syst_modes_enable }
+\permanent\protected\def\globaldisablemode{\let\syst_mode_prefix\global\unprotect\syst_modes_disable}
+
+\def\syst_modes_prevent[#1]{\protect\fastprocesscommacommand[#1]\syst_modes_prevent_indeed\let\syst_mode_prefix\relax}
+\def\syst_modes_enable [#1]{\protect\fastprocesscommacommand[#1]\syst_modes_enable_indeed \let\syst_mode_prefix\relax}
+\def\syst_modes_disable[#1]{\protect\fastprocesscommacommand[#1]\syst_modes_disable_indeed\let\syst_mode_prefix\relax}
+
+\def\syst_modes_prevent_indeed#1%
+ {\ifcsname\??mode#1\endcsname\else\setmode{#1}\fi
+ \syst_mode_prefix\expandafter\integerdef\lastnamedcs\plustwo}
+
+\def\syst_modes_enable_indeed#1% we can speed it up by moving the new outside
+ {\ifcsname\??mode#1\endcsname\else\setmode{#1}\fi
+ \ifnum\lastnamedcs=\plustwo\else
+ \syst_mode_prefix\expandafter\integerdef\lastnamedcs\plusone
+ \fi}
+
+\def\syst_modes_disable_indeed#1%
+ {\ifcsname\??mode#1\endcsname\else\setmode{#1}\fi
+ \ifnum\lastnamedcs=\plustwo\else
+ \syst_mode_prefix\expandafter\integerdef\lastnamedcs\zerocount
+ \fi}
+
+%D If you do a lot of mode testing, it makes sense to define modes (or disable them
+%D explicitly if unset. This makes testing twice as fast. Often one enables modes
+%D beforehand, in which case \type {\definemode} would reset the mode. The optional
+%D second argument \type {keep} will prevent changing the already set mode but defines
+%D it when undefined.
+
+\permanent\protected\def\definemode
+ {\unprotect
+ \syst_modes_define}
+
+\tolerant\def\syst_modes_define[#1]#*[#2]%
+ {\protect
+ \edef\m_modes_asked{#2}%
+ \fastprocesscommacommand[#1]\syst_modes_define_indeed}
+
+\def\syst_modes_define_indeed#1%
+ {\ifcsname\??mode#1\endcsname
+ % already set
+ \else
+ \newmode{#1}%
+ \fi
+ \ifx\m_modes_asked\v!keep
+ % not changes, disabled when undefined
+ \orelse\ifx\m_modes_asked\v!yes
+ \setmode{#1}%
+ \else
+ \resetmode{#1}%
+ \fi}
+
+% handy for mp
+
+\permanent\def\booleanmodevalue#1%
+ {\ifcsname\??mode#1\endcsname
+ \ifcase\lastnamedcs
+ \s!false
+ \or
+ \s!true
+ \else
+ \s!false
+ \fi
+ \else
+ \s!false
+ \fi}
+
+% check macros
+
+\newconditional\c_checked_mode
+
+% one
+
+\def\syst_modes_check_indeed#1%
+ {\ifcsname\??mode#1\endcsname
+ \ifcase\lastnamedcs\else
+ \let\syst_modes_check_step\gobbleoneargument
+ \fi
+ \fi}
+
+\def\syst_modes_check_nop#1#2#3%
+ {\let\syst_modes_check_step\syst_modes_check_indeed
+ \fastprocesscommacommand[#3]\syst_modes_check_step
+ \ifx\syst_modes_check_step\gobbleoneargument
+ \expandafter#1%
+ \else
+ \expandafter#2%
+ \fi}
+
+\def\syst_modes_check_yes#1#2#3%
+ {\ifcase\lastnamedcs
+ \expandafter#2%
+ \or
+ \expandafter#1%
+ \else
+ \expandafter#2%
+ \fi}
+
+\def\syst_modes_check_lr#1#2#3%
+ {\ifcsname\??mode#3\endcsname
+ \expandafter\syst_modes_check_yes
+ \else
+ \expandafter\syst_modes_check_nop
+ \fi#1#2{#3}}
+
+\def\syst_modes_check_ss#1#2[#3]%
+ {\ifcsname\??mode#3\endcsname
+ \expandafter\syst_modes_check_yes
+ \else
+ \expandafter\syst_modes_check_nop
+ \fi#1#2{#3}}
+
+% all
+
+\let\syst_modes_check_all_step\gobbleoneargument
+
+\def\syst_modes_check_all_indeed#1%
+ {\ifcsname\??mode#1\endcsname
+ \ifcase\lastnamedcs
+ \let\syst_modes_check_all_step\gobbleoneargument
+ \or
+ % enabled
+ \else
+ \let\syst_modes_check_all_step\gobbleoneargument
+ \fi
+ \else
+ \let\syst_modes_check_all_step\gobbleoneargument
+ \fi}
+
+\def\syst_modes_check_all_lr#1#2#3%
+ {\let\syst_modes_check_all_step\syst_modes_check_all_indeed
+ \fastprocesscommacommand[#3]\syst_modes_check_all_step
+ \ifx\syst_modes_check_all_step\gobbleoneargument
+ \expandafter#2%
+ \else
+ \expandafter#1%
+ \fi}
+
+\def\syst_modes_check_all_ss#1#2[#3]%
+ {\let\syst_modes_check_all_step\syst_modes_check_all_indeed
+ \fastprocesscommacommand[#3]\syst_modes_check_all_step
+ \ifx\syst_modes_check_all_step\gobbleoneargument
+ \expandafter#2%
+ \else
+ \expandafter#1%
+ \fi}
+
+\permanent\protected\def\doifelsemode {\syst_modes_check_lr \firstoftwoarguments \secondoftwoarguments}
+\permanent\protected\def\doifmode {\syst_modes_check_lr \firstofoneargument \gobbleoneargument}
+\permanent\protected\def\doifnotmode {\syst_modes_check_lr \gobbleoneargument \firstofoneargument}
+\permanent\protected\def\startmode {\syst_modes_check_ss \donothing \syst_modes_stop_yes}
+\permanent\protected\def\startnotmode {\syst_modes_check_ss \syst_modes_stop_nop \donothing}
+\permanent\protected\def\doifelseallmodes{\syst_modes_check_all_lr\firstoftwoarguments \secondoftwoarguments}
+\permanent\protected\def\doifallmodes {\syst_modes_check_all_lr\firstofoneargument \gobbleoneargument}
+\permanent\protected\def\doifnotallmodes {\syst_modes_check_all_lr\gobbleoneargument \firstofoneargument}
+\permanent\protected\def\startallmodes {\syst_modes_check_all_ss\donothing \syst_modes_stop_all_yes}
+\permanent\protected\def\startnotallmodes{\syst_modes_check_all_ss\syst_modes_stop_all_nop\donothing}
+
+\aliased\let\doifmodeelse \doifelsemode
+\aliased\let\doifallmodeselse\doifelseallmodes
+
+\permanent\protected\def\stopmode {} % no relax
+\permanent\protected\def\stopnotmode {} % no relax
+\permanent\protected\def\stopallmodes {} % no relax
+\permanent\protected\def\stopnotallmodes{} % no relax
+
+\def\syst_modes_stop_yes #1\stopmode {}
+\def\syst_modes_stop_nop #1\stopnotmode {}
+\def\syst_modes_stop_all_yes#1\stopallmodes {}
+\def\syst_modes_stop_all_nop#1\stopnotallmodes{}
+
+%D Pushing/popping:
+
+\permanent\protected\def\pushmode[#1]{\expandafter\pushmacro\csname\??mode#1\endcsname}
+\permanent\protected\def\popmode [#1]{\expandafter\popmacro \csname\??mode#1\endcsname}
+
+\permanent\protected\def\pushsystemmode#1{\expandafter\pushmacro\csname\??mode\systemmodeprefix#1\endcsname}
+\permanent\protected\def\popsystemmode #1{\expandafter\popmacro \csname\??mode\systemmodeprefix#1\endcsname}
+
+%D Here is a relatively new variant of mode checking:
+%D
+%D \starttyping
+%D \enablemode[two]
+%D
+%D \startmodeset
+%D [one] {1}
+%D [two] {2}
+%D [two] {2}
+%D [three] {3}
+%D [default] {?}
+%D \stopmodeset
+%D
+%D \startmodeset
+%D [one] {1}
+%D [three] {3}
+%D [default] {?}
+%D \stopmodeset
+%D
+%D \startmodeset
+%D [one] {
+%D \input tufte
+%D }
+%D [two] {
+%D \startmodeset
+%D [one] {1}
+%D [two] {2}
+%D [two] {2}
+%D [three] {3}
+%D [default] {?}
+%D \stopmodeset
+%D }
+%D [three] {
+%D \input zapf
+%D }
+%D [default] {
+%D \input ward
+%D }
+%D \stopmodeset
+%D \stoptyping
+
+\newconditional\c_syst_modes_set_done % conditionals can be pushed/popped
+
+\installmacrostack\c_syst_modes_set_done
+
+% \permanent\protected\def\startmodeset
+% {\push_macro_c_syst_modes_set_done
+% \setfalse\c_syst_modes_set_done
+% \doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit}
+%
+% \aliased\let\stopmodeset\relax
+%
+% \def\syst_modes_set_start[#1]%
+% {\edef\m_mode_case{#1}%
+% \unless\ifx\m_mode_case\s!default
+% \expandafter\syst_modes_set_check
+% \orelse\ifconditional\c_syst_modes_set_done
+% \expandafter\syst_modes_set_quit
+% \else
+% \expandafter\syst_modes_set_yes
+% \fi}
+%
+% \def\syst_modes_set_check
+% {\syst_modes_check_lr\syst_modes_set_yes\syst_modes_set_nop\m_mode_case}
+%
+% \def\syst_modes_set_yes#1%
+% {\settrue\c_syst_modes_set_done
+% #1%
+% \doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit}
+%
+% \def\syst_modes_set_nop#1%
+% {\doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit}
+%
+% \def\syst_modes_set_quit#-\stopmodeset
+% {\pop_macro_c_syst_modes_set_done}
+
+\permanent\protected\def\startmodeset
+ {\push_macro_c_syst_modes_set_done
+ \setfalse\c_syst_modes_set_done
+ \syst_modes_set_start}
+
+\aliased\let\stopmodeset\relax
+
+\tolerant\def\syst_modes_set_start#.[#1]% skip spaces and pars
+ {\edef\m_mode_case{#1}%
+ \ifempty\m_mode_case
+ \expandafter\syst_modes_set_quit
+ \orunless\ifx\m_mode_case\s!default
+ \expandafter\syst_modes_set_check
+ \orelse\ifconditional\c_syst_modes_set_done
+ \expandafter\syst_modes_set_quit
+ \else
+ \expandafter\syst_modes_set_yes
+ \fi}
+
+\def\syst_modes_set_check
+ {\syst_modes_check_lr\syst_modes_set_yes\syst_modes_set_nop\m_mode_case}
+
+\tolerant\def\syst_modes_set_yes#1%
+ {\settrue\c_syst_modes_set_done
+ #1%
+ \syst_modes_set_start}
+
+\tolerant\def\syst_modes_set_nop#1%
+ {\syst_modes_set_start}
+
+\def\syst_modes_set_quit#-\stopmodeset
+ {\pop_macro_c_syst_modes_set_done}
+
+%D Lets now set a mode:
+
+\enablemode[mkiv] \newsystemmode{mkiv} \setsystemmode{mkiv}
+
+%D Setups:
+
+\installcorenamespace{setup} % we can probably get rid of some :'s later on
+
+% \protected\def\startsetups{} % to please dep checker
+% \protected\def\stopsetups {} % to please dep checker
+%
+% \protected\def\setups{\doifelsenextbgroup\syst_setups_a\syst_setups_b} % {..} or [..]
+% \protected\def\setup {\doifelsenextbgroup\syst_setups \syst_setups_c} % {..} or [..]
+%
+% \def\syst_setups_a #1{\processcommacommand[#1]\syst_setups} % {..}
+% \def\syst_setups_b[#1]{\processcommacommand[#1]\syst_setups} % [..]
+% \def\syst_setups_c[#1]{\syst_setups{#1}} % [..]
+
+\permanent\protected\tolerant\def\setups[#1]#;#2{\processcommacommand[#1#2]\syst_setups} % {..} or [..]
+\permanent\protected\tolerant\def\setup [#1]#;#2{\syst_setups{#1#2}} % {..} or [..]
+
+\letvalue{\??setup:\??empty}\gobbleoneargument
+
+\permanent\def\syst_setups#1% the grid option will be extended to other main modes
+ {\csname\??setup
+ \ifgridsnapping
+ \ifcsname\??setup\v!grid:#1\endcsname\v!grid:#1\else:\ifcsname\??setup:#1\endcsname#1\else\??empty\fi\fi
+ \else
+ :\ifcsname\??setup:#1\endcsname#1\else\??empty\fi
+ \fi
+ \endcsname\empty} % takes one argument
+
+% no checking and we assume it being defined:
+
+\permanent\def\fastsetup #1{\csname\??setup:#1\endcsname\empty}
+\permanent\def\fastsetupwithargument #1{\csname\??setup:#1\endcsname} % swapped per 2015-08-30
+\permanent\def\fastsetupwithargumentswapped#1#2{\csname\??setup:#2\endcsname{#1}}% swapped per 2015-09-05
+
+% the next one is meant for \c!setups situations, hence the check for
+% a shortcut
+
+\let\m_syst_setups_asked\empty
+
+\permanent\protected\def\doprocesslocalsetups#1% sort of public, fast local variant
+ {\edef\m_syst_setups_asked{#1}%
+ \ifempty\m_syst_setups_asked\else
+ \expandafter\syst_setups_process_local
+ \fi}
+
+\permanent\protected\def\usesetupsparameter#1%
+ {\edef\m_syst_setups_asked{#1\c!setups}%
+ \ifempty\m_syst_setups_asked\else
+ \expandafter\syst_setups_process_local
+ \fi}
+
+% setups=S1
+% setups=lua(S2)
+% setups=S3
+% setups={S1,lua(S2),xml(test{123}),S3}
+
+\def\syst_setups_process_local
+ {\clf_autosetups{\m_syst_setups_asked}%
+ \relax} % let's prevent lookahead
+
+\permanent\def\autosetups#1{\clf_autosetups{#1}} % todo: public implementor
+
+\permanent\edef\setupwithargument#1% saves a few expansions
+ {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#1\endcsname#1\noexpand\else\??empty\noexpand\fi\endcsname}
+
+\permanent\edef\setupwithargumentswapped#1#2% saves a few expansions (can be \let)
+ {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#2\endcsname#2\noexpand\else\??empty\noexpand\fi\endcsname{#1}}
+
+\aliased\let\directsetup\syst_setups
+\aliased\let\texsetup \syst_setups % nicer than \directsetup and more en par with xmlsetup and luasetup
+
+\permanent\protected\def\doifelsesetups#1% to be done: grid
+ {\ifcsname\??setup:#1\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifsetupselse\doifelsesetups
+
+\permanent\protected\def\doifsetups#1% to be done: grid
+ {\ifcsname\??setup:#1\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\permanent\protected\def\doifnotsetups#1% to be done: grid
+ {\ifcsname\??setup:#1\endcsname
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+% maybe some day:
+%
+% \protected\def\fastsetupfallback#1#2%
+% {\ifcsname\??setup:#1\endcsname
+% \expandafter\lastnamedcs
+% \else
+% \csname\??setup:#2\expandafter\endcsname
+% \fi}
+%
+% or
+%
+% \protected\def\fastsetupfallback#1#2#3% prefix preferred fallback
+% {\ifcsname\??setup:#1#2\endcsname
+% \expandafter\lastnamedcs
+% \else
+% \csname\??setup:#1#3\expandafter\endcsname
+% \fi}
+
+% \startluasetups oeps
+% context("DONE")
+% a = 1
+% b = 1
+% \stopluasetups
+%
+% \luasetup{oeps}
+%
+% \startsetups xxx
+% ziezo
+% \stopsetups
+%
+% \directsetup{xxx}
+%
+% \startxmlsetups zzz
+% [[#1]]
+% \stopxmlsetups
+%
+% \xmlsetup{123}{zzz}
+%
+% \startbuffer[what]
+% context("DONE")
+% \stopbuffer
+%
+% \startbuffer
+% context("MORE")
+% \stopbuffer
+%
+% \ctxluabuffer[what]
+%
+% \ctxluabuffer
+
+\newtoks\t_syst_setups_tex \appendtoks
+ \catcode\endoflineasciicode \ignorecatcode
+\to \t_syst_setups_tex
+
+\newtoks\t_syst_setups_loc \appendtoks
+ \catcode\endoflineasciicode \ignorecatcode
+\to \t_syst_setups_loc
+
+\newtoks\t_syst_setups_raw \appendtoks
+ % nothing
+\to \t_syst_setups_raw
+
+\newtoks\t_syst_setups_xml \appendtoks
+ \catcode\endoflineasciicode\ignorecatcode
+ \catcode\barasciicode \othercatcode
+\to \t_syst_setups_xml
+
+\newtoks\t_syst_setups_lua \appendtoks
+ \obeylualines
+ \obeyluatokens
+\to \t_syst_setups_lua
+
+% Is doglobal still relevant? Maybe always global? Or never? Anyway, it will become obsolete.
+
+\permanent\protected\def\startluasetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_lua_yes\syst_setups_start_lua_nop} \aliased\let\stopluasetups \relax
+\permanent\protected\def\startxmlsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_xml_yes\syst_setups_start_xml_nop} \aliased\let\stopxmlsetups \relax
+\permanent\protected\def\startrawsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_raw_yes\syst_setups_start_raw_nop} \aliased\let\stoprawsetups \relax
+\permanent\protected\def\startlocalsetups{\begingroup\doifelsenextoptionalcs\syst_setups_start_loc_yes\syst_setups_start_loc_nop} \aliased\let\stoplocalsetups\relax
+\permanent\protected\def\startsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_tex_yes\syst_setups_start_tex_nop} \aliased\let\stopsetups \relax
+
+\def\syst_setups_start_lua_two#1#2#+\stopluasetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}}
+\def\syst_setups_start_xml_two#1#2#+\stopxmlsetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}}
+\def\syst_setups_start_raw_two#1#2#+\stoprawsetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}}
+\def\syst_setups_start_loc_two#1#2#+\stoplocalsetups{\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}}
+\def\syst_setups_start_tex_two#1#2#+\stopsetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}}
+
+\tolerant\def\syst_setups_start_lua_yes[#1]#*[#2]%
+ {\the\t_syst_setups_lua
+ \ifarguments\expandafter\syst_setups_start_lua_one
+ \or \expandafter\syst_setups_start_lua_one
+ \else \expandafter\syst_setups_start_lua_two
+ \fi{#1}{#2}}
+
+\tolerant\def\syst_setups_start_xml_yes[#1]#*[#2]%
+ {\the\t_syst_setups_xml
+ \ifarguments\expandafter\syst_setups_start_xml_one
+ \or \expandafter\syst_setups_start_xml_one
+ \else \expandafter\syst_setups_start_xml_two
+ \fi{#1}{#2}}
+
+\tolerant\def\syst_setups_start_raw_yes[#1]#*[#2]%
+ {\the\t_syst_setups_raw
+ \ifarguments\expandafter\syst_setups_start_raw_one
+ \or \expandafter\syst_setups_start_raw_one
+ \else \expandafter\syst_setups_start_raw_two
+ \fi{#1}{#2}}
+
+\tolerant\def\syst_setups_start_loc_yes[#1]#*[#2]%
+ {\the\t_syst_setups_loc
+ \ifarguments\expandafter\syst_setups_start_loc_one
+ \or \expandafter\syst_setups_start_loc_one
+ \else \expandafter\syst_setups_start_loc_two
+ \fi{#1}{#2}}
+
+\tolerant\def\syst_setups_start_tex_yes[#1]#*[#2]%
+ {\the\t_syst_setups_tex
+ \ifarguments\expandafter\syst_setups_start_tex_one
+ \or \expandafter\syst_setups_start_tex_one
+ \else \expandafter\syst_setups_start_tex_two
+ \fi{#1}{#2}}
+
+\def\syst_setups_start_lua_nop#1 {\the\t_syst_setups_lua\syst_setups_start_lua_two{}{#1}} % space delimited
+\def\syst_setups_start_xml_nop#1 {\the\t_syst_setups_xml\syst_setups_start_xml_two{}{#1}} % space delimited
+\def\syst_setups_start_raw_nop#1 {\the\t_syst_setups_raw\syst_setups_start_raw_two{}{#1}} % space delimited
+\def\syst_setups_start_loc_nop#1 {\the\t_syst_setups_loc\syst_setups_start_loc_two{}{#1}} % space delimited
+\def\syst_setups_start_tex_nop#1 {\the\t_syst_setups_tex\syst_setups_start_tex_two{}{#1}} % space delimited
+
+\def\syst_setups_start_lua_one#1#2{\syst_setups_start_lua_two{}{#1}} % [..]
+\def\syst_setups_start_xml_one#1#2{\syst_setups_start_xml_two{}{#1}} % [..]
+\def\syst_setups_start_raw_one#1#2{\syst_setups_start_raw_two{}{#1}} % [..]
+\def\syst_setups_start_loc_one#1#2{\syst_setups_start_loc_two{}{#1}} % [..]
+\def\syst_setups_start_tex_one#1#2{\syst_setups_start_tex_two{}{#1}} % [..]
+
+\permanent\def\luasetup#1{\ctxlua{\syst_setups{#1}}}
+
+%D System setups:
+
+\aliased\let\systemsetupsprefix\wildcardsymbol
+
+\permanent\def\systemsetups#1{\syst_setups{\systemsetupsprefix#1}}
+
+\permanent\protected\def\resetsetups[#1]% see x-fo for usage
+ {\ifcsname\??setup\ifgridsnapping\v!grid\fi:#1\endcsname
+ \dodoglobal\undefinevalue{\??setup\ifgridsnapping\v!grid\fi:#1}%
+ \else
+ \dodoglobal\undefinevalue{\??setup:#1}%
+ \fi}
+
+\permanent\tolerant\protected\def\copysetups[#1]#*[#2]%
+ {\ifcsname\??setup:#2\endcsname
+ \letcsname\??setup:#1\expandafter\endcsname\lastnamedcs
+ \fi}
+
+\permanent\protected\def\showsetupsdefinition[#1]%
+ {\showvalue{\??setup:#1}} % temp hack for debugging
+
+%D \macros
+%D {setvariables,getvariable,getvariabledefault}
+%D
+%D \starttyping
+%D \setvariables[xx][title=]
+%D \setvariables[xx][title=test test]
+%D \setvariables[xx][title=test $x=1$ test] % fatal error reported
+%D \setvariables[xx][title=test {$x=1$} test]
+%D \setvariables[xx][title] % fatal error reported
+%D \setvariables[xx][titletitel=e]
+%D \stoptyping
+
+\installcorenamespace{variables}
+
+\permanent\protected\def\setvariables {\syst_variables_set[\getrawparameters ]}
+\permanent\protected\def\setevariables{\syst_variables_set[\getraweparameters]}
+\permanent\protected\def\setgvariables{\syst_variables_set[\getrawgparameters]}
+\permanent\protected\def\setxvariables{\syst_variables_set[\getrawxparameters]}
+
+\mutable\let\currentvariableclass\empty
+
+\tolerant\def\syst_variables_set[#1]#*[#2]#*[#3]% tricky, test on s-pre-60
+ {\doifelse{#2}\currentvariableclass
+ {#1[\??variables#2:][#3]}%
+ {\pushmacro\currentvariableclass
+ \def\currentvariableclass{#2}%
+ \getvariable{#2}\s!reset
+ #1[\??variables#2:][#3]%
+ \getvariable{#2}\s!set
+ \popmacro\currentvariableclass}}
+
+\permanent\protected\def\setvariable #1#2#3{\defcsname \??variables#1:#2\endcsname{#3}}
+\permanent\protected\def\setevariable#1#2#3{\edefcsname\??variables#1:#2\endcsname{#3}}
+\permanent\protected\def\setgvariable#1#2#3{\defcsname \??variables#1:#2\endcsname{#3}}
+\permanent\protected\def\setxvariable#1#2#3{\xdefcsname\??variables#1:#2\endcsname{#3}}
+
+\permanent \def\getvariable #1#2{\begincsname\??variables#1:#2\endcsname}
+\permanent\protected\def\showvariable#1#2{\showvalue{\begincsname\??variables#1:#2\endcsname}}
+
+\let\currentvariableclass\empty
+
+%D \macros
+%D {checkvariables}
+%D
+%D I'll probably forget that this on exists.
+
+\let\m_syst_variables_temp\empty
+
+\permanent\tolerant\def\checkvariables[#1]#*[#2]%
+ {\dogetparameters\syst_variables_check_value[#1][#2]}
+
+\def\syst_variables_check_value#1#2#3%
+ {\ifcsname\??variables#1:#2\endcsname
+ \edef\m_syst_variables_temp{\lastnamedcs}%
+ \ifempty\m_syst_variables_temp
+ \defcsname\??variables#1:#2\endcsname{#3}%
+ \fi
+ \else
+ \defcsname\??variables#1:#2\endcsname{#3}%
+ \fi}
+
+%D \macros
+%D {doifelsevariable,doifvariable,doifnotvariable}
+%D
+%D A few trivial macros:
+
+\permanent\protected\def\doifelsevariable#1#2%
+ {\ifcsname\??variables#1:#2\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifvariableelse\doifelsevariable
+
+\permanent\protected\def\doifvariable#1#2%
+ {\ifcsname\??variables#1:#2\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\permanent\protected\def\doifnotvariable#1#2%
+ {\ifcsname\??variables#1:#2\endcsname
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+%D A few more (we could use a public test variable so that we only need to expand
+%D once, assuming expandable variables):
+
+\letvalue{\??variables:}\empty
+
+\permanent\protected\def\doifelseemptyvariable#1#2%
+ {\edef\m_syst_string_one{\begincsname\??variables#1:#2\endcsname}%
+ \ifempty\m_syst_string_one
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifemptyvariableelse\doifelseemptyvariable
+
+\permanent\protected\def\doifemptyvariable#1#2%
+ {\edef\m_syst_string_one{\begincsname\??variables#1:#2\endcsname}%
+ \ifempty\m_syst_string_one
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\permanent\protected\def\doifnotemptyvariable#1#2%
+ {\edef\m_syst_string_one{\begincsname\??variables#1:#2\endcsname}%
+ \ifempty\m_syst_string_one
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+\permanent\def\getvariabledefault#1#2% #3% can be command
+ {\ifcsname\??variables#1:#2\endcsname
+ \expandafter\expandafter\expandafter\lastnamedcs\expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+\permanent\tolerant\protected\def\setupenv[#1]%
+ {\syst_variables_set[\getrawparameters][\s!environment][#1]}
+
+\permanent\protected\def\doifelseenv{\doifelsevariable \s!environment}
+\permanent\protected\def\doifenv {\doifvariable \s!environment}
+\permanent\protected\def\doifnotenv {\doifnotvariable \s!environment}
+\permanent \def\env {\getvariable \s!environment}
+\permanent \def\envvar {\getvariabledefault\s!environment}
+
+\aliased\let\doifenvelse\doifelseenv
+
+%D \macros
+%D {defineselector,setupselector,select,directselect}
+%D
+%D \starttyping
+%D \defineselector[caption][max=2,n=2]
+%D
+%D \start
+%D \setupselector[caption][n=1]
+%D \placelist[figure][criterium=all]
+%D \stop
+%D
+%D \starttext
+%D \placefigure
+%D {\select{caption}{zapf}{\input zapf \relax}}
+%D {}
+%D \stoptext
+%D \stoptyping
+
+\installcorenamespace{selector}
+
+\permanent\tolerant\protected\def\defineselector[#1]#*[#2]{\getparameters[\??selector#1][\c!max=\plusone,\c!n=\plusone,#2]}
+\permanent\tolerant\protected\def\setupselector [#1]#*[#2]{\getparameters[\??selector#1][#2]}
+
+% \def\directselect#1% expandable
+% {\filterfromnext % maybe add an \expanded
+% {\csname\??selector\ifcsname\??selector#1\c!max\endcsname#1\fi\c!max\endcsname}%
+% {\csname\??selector\ifcsname\??selector#1\c!n \endcsname#1\fi\c!n \endcsname}}
+%
+% this is more efficient when the arguments are used a few times (or passed along):
+
+\permanent\def\directselect#1% expandable
+ {\expandafter\filterfromnext
+ \csname\??selector\ifcsname\??selector#1\c!max\endcsname#1\fi\c!max\expandafter\endcsname
+ \csname\??selector\ifcsname\??selector#1\c!n \endcsname#1\fi\c!n \endcsname}
+
+\permanent\protected\let\select\directselect % we promote to protected
+
+\letcsname\??selector\c!max\endcsname\plusone
+\letcsname\??selector\c!n \endcsname\plusone
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-ini.mkxl
new file mode 100644
index 00000000000..de7c645b425
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-ini.mkxl
@@ -0,0 +1,224 @@
+%D \module
+%D [ file=core-ini,
+%D version=2003.12.01,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Additional Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Additional Initialization}
+
+\unprotect
+
+%D We introduce a couple of variables that are used all over \CONTEXT. Alternatively
+%D we could define them in each module but as they are part of the bigger picture we
+%D prefer to do it here. Ideally we should hav ea proper dependency tree but it might
+%D be that we want to make versions with a smaller footprints in which case one would
+%D still need to define the token list registers (unless we could do that runtime).
+
+%D \macros
+%D {every...}
+%D
+%D A few every's.
+
+%D Output routine:
+
+\newtoks \everybeforeoutput
+\newtoks \everyafteroutput
+
+%D Shipout:
+
+\newtoks \everyshipout
+\newtoks \everybeforeshipout
+\newtoks \everyaftershipout
+\newtoks \everyfirstshipout
+\newtoks \everylastshipout
+
+%D End of run:
+
+\newtoks \everybye
+\newtoks \everygoodbye
+\newtoks \everynotabene
+
+%D Document:
+
+\newtoks \everyendoftextbody
+
+\newtoks \everystarttext
+\newtoks \everystoptext
+
+\newtoks \everystartdocument
+\newtoks \everystopdocument
+
+%D Purity:
+
+\newtoks \everyforgetall
+\newtoks \everycleanupfeatures
+\newtoks \everysimplifycommands
+%newtoks \everypreroll
+
+\aliased\let\simplifiedcommands\everysimplifycommands % backward compatible, will stay as it's used in styles
+
+\newconditional\simplifyingcommands % public
+
+\permanent\protected\def\forgetall {\the\everyforgetall}
+\permanent\protected\def\cleanupfeatures {\the\everycleanupfeatures}
+\permanent\protected\def\simplifycommands{\the\everysimplifycommands}
+
+\appendtoks
+ \settrue\simplifyingcommands
+\to \everysimplifycommands
+
+\appendtoks
+ \everypar\emptytoks % pretty important
+\to \everyforgetall
+
+%D Page building:
+
+\newtoks \everybeforepagebody
+\newtoks \everyafterpagebody
+
+\aliased\let\everypagebody\everybeforepagebody % backward compatible, will become obsolete
+
+%D Floats:
+
+\newtoks \everyinsidefloat
+
+%D Exporting:
+
+\newtoks \everyinitializeexport
+
+%D Sectioning:
+
+%newtoks \everyheadstart
+
+%D Par building (experimental, used in xml
..
)
+
+\newtoks \everybeginofpar
+\newtoks \everyendofpar
+%newtoks \everyparflush
+
+\protected\def\bpar{\the\everybeginofpar\ignorespaces} % may interfere with \everypar
+\protected\def\epar{\ifhmode\removeunwantedspaces\the\everyendofpar\fi} % test prevents problems with \bpar\epar
+
+%D Lists:
+
+\newtoks \everylistentry
+\newtoks \everysavesortkeys
+
+%D Marks:
+
+%newtoks \everymarking
+
+%D Fonts:
+
+\newtoks \everyfont
+\newtoks \everyglobalbodyfont
+\newtoks \everydefinedfont
+
+\newtoks \everybodyfont
+\newtoks \everyfontswitch
+
+\newtoks \everysetupbodyfont
+\newtoks \everyswitchtobodyfont
+
+%D Math:
+
+\newtoks \everybeforedisplayformula
+\newtoks \everymathematics
+
+\prependtoks \the\everymathematics \to \everymath
+\prependtoks \the\everymathematics \to \everydisplay
+
+%D Tables:
+
+%newtoks \everytable % we need to disstinguish kinds
+
+%D More generic (used to be pushcolor etc)
+
+\newtoks\everystarttextproperties
+\newtoks\everystoptextproperties
+
+\permanent\protected\def\starttextproperties{\the\everystarttextproperties}
+\permanent\protected\def\stoptextproperties {\the\everystoptextproperties}
+
+%D \macros
+%D {trialtypesetting}
+%D
+%D We disable trial typesetting in the output routine,
+%D just to be sure.
+
+\prependtoks
+ \resettrialtypesetting
+\to \everybeforepagebody
+
+%D \macros
+%D {ifinpagebody,ifinsidecolumns,ifdoublesided,ifsinglesided}
+%D
+%D These will become system modes and conditionals
+
+\newif \ifinpagebody
+\newif \ifinsidecolumns
+\newif \ifinsidemulticolumns % simple mixed-in-text columns
+\newif \ifdoublesided \doublesidedfalse
+\newif \ifsinglesided \singlesidedtrue
+\newif \ifinsidefloat
+\newif \ifdoingblocks
+\newif \ifgridsnapping
+\newif \ifexporting
+
+\newconstant\pageduplexmode % 0 single 1 double 2 mix
+\newconstant\pagebodymode % 0 not 1 normal pagebody 2 spread
+
+\newcount\nofcolumns \nofcolumns \plusone
+\newcount\nofmulticolumns \nofmulticolumns\plusone
+
+%D \macros
+%D {ifproductionrun}
+%D
+%D This boolean can be used to bypass certain initializations.
+
+% \newif\ifproductionrun % already defined
+
+\appendtoks
+ \productionruntrue
+\to \everydump
+
+%D \macros
+%D {everyboxedcontent, ifboxedcontent,
+%D startboxedcontent, stopboxedcontent}
+%D
+%D This one is relatively new and will be used as a more robust test for inner
+%D situations.
+
+\newif \ifboxedcontent
+\newtoks\everyboxedcontent
+
+\appendtoks
+ \boxedcontenttrue
+\to \everyboxedcontent
+
+\permanent\protected\def\startboxedcontent{\bgroup\the\everyboxedcontent}
+
+\aliased\let\stopboxedcontent\egroup
+
+% %D We store some original meanings, maybe in \type {math-ini}.
+%
+% \let\normalat \at
+% \let\normalin \in
+% \let\normalfrom \from
+% \let\normalover \over
+% \let\normalabout\about
+
+%D This will be implemented way later:
+
+\let\setlayoutcomponentattribute \gobbleoneargument
+\let\resetlayoutcomponentattribute\relax
+\let\layoutcomponentboxattribute \empty
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-lmt.lmt b/Master/texmf-dist/tex/context/base/mkxl/core-lmt.lmt
new file mode 100644
index 00000000000..ccbdcc0dff6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-lmt.lmt
@@ -0,0 +1,95 @@
+if not modules then modules = { } end modules ['core-lmt'] = {
+ version = 1.001,
+ comment = "companion to core-lmt.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Kind of obsolete ... old school directions.
+
+local implement = interfaces.implement
+local scankeyword = tokens.scanners.keyword
+local scaninteger = tokens.scanners.integer
+
+local settextdir = tex.settextdir
+local setlinedir = tex.setlinedir
+local setpardir = tex.setpardir
+local setboxdir = tex.setboxdir
+
+local gettextdir = tex.gettextdir
+local getlinedir = tex.getlinedir
+local getpardir = tex.getpardir
+local getboxdir = tex.getboxdir
+
+local none_code = tokens.values.none
+
+local context = context
+
+local function scandir()
+ if scankeyword("tlt") then
+ return 0
+ elseif scankeyword("trt") then
+ return 1
+ else
+ return 0
+ end
+end
+
+local function showdir(d)
+ context(d == 1 and "TRT" or "LTL")
+ return none_code
+end
+
+implement {
+ name = "textdir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ showdir(gettextdir())
+ else
+ settextdir(scandir())
+ end
+ end
+}
+
+implement {
+ name = "linedir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ return showdir(getlinedir())
+ else
+ setlinedir(scandir())
+ end
+ end
+}
+
+implement {
+ name = "pardir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ if what == "value" then
+ return showdir(getpardir())
+ else
+ setpardir(scandir())
+ end
+ end
+}
+
+implement {
+ name = "boxdir",
+ public = true,
+ usage = "value",
+ actions = function(what)
+ local n = scaninteger()
+ if what == "value" then
+ return showdir(getboxdir(n))
+ else
+ setboxdir(n,scandir())
+ end
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-lmt.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-lmt.mkxl
new file mode 100644
index 00000000000..77ef179669a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-lmt.mkxl
@@ -0,0 +1,28 @@
+%D \module
+%D [ file=core-lmt,
+%D version=2018.08.2,
+%D title=\CONTEXT\ System Macros,
+%D subtitle=Primitives,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt System Macros / Primitives}
+
+\registerctxluafile{core-lmt}{autosuffix}
+
+\unprotect
+
+% nothing here
+
+\protect \endinput
+
+% \starttext
+% abc{\textdir TRTdef}ghi
+% abc{\textdir trtdef}ghi
+% \boxdirection0=1
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-sys.lmt b/Master/texmf-dist/tex/context/base/mkxl/core-sys.lmt
new file mode 100644
index 00000000000..0d471133d3f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-sys.lmt
@@ -0,0 +1,83 @@
+if not modules then modules = { } end modules ['core-sys'] = {
+ version = 1.001,
+ comment = "companion to core-sys.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local lower, format, gsub = string.lower, string.format, string.gsub
+local suffixonly, basename, removesuffix = file.suffix, file.basename, file.removesuffix
+
+local environment = environment
+local context = context
+local implement = interfaces.implement
+
+local report_files = logs.reporter("system","files")
+
+function environment.initializefilenames()
+
+ local arguments = environment.arguments
+
+ local jobname = arguments.jobname or tex.jobname
+ local fulljobname = arguments.fulljobname or jobname
+ local inputfilename = arguments.input or fulljobname
+ local outputfilename = arguments.result or removesuffix(jobname)
+
+ local inputfilename = suffixonly(inputfilename) == "tex" and removesuffix(inputfilename) or inputfilename or ""
+
+ local filename = fulljobname
+ local suffix = suffixonly(filename)
+
+ local filename = ctxrunner.resolve(filename) -- in case we're prepped
+
+ local jobfilename = jobname or inputfilename or tex.jobname or ""
+ local inputfilename = inputfilename or ""
+
+ local jobfilebase = basename(jobfilename)
+ local inputfilebase = basename(inputfilename)
+
+ -- jobfilename = gsub(jobfilename, "^./","")
+ -- inputfilename = gsub(inputfilename,"^./","")
+
+ environment.jobfilefullname = fulljobname
+ environment.jobfilename = jobfilebase
+ environment.jobfilesuffix = lower(suffixonly(jobfilebase))
+
+ environment.inputfilename = inputfilename -- so here we keep e.g. ./ or explicit paths
+ environment.inputfilebarename = removesuffix(inputfilebase)
+ environment.inputfilesuffix = lower(suffixonly(inputfilebase))
+
+ environment.outputfilename = outputfilename or environment.inputfilebarename or ""
+
+ environment.filename = filename
+ environment.suffix = suffix
+
+ -- if tex then
+ -- tex.jobname = jobfilename
+ -- end
+
+ report_files("jobname %a, input %a, result %a",jobfilename,inputfilename,outputfilename)
+
+ function environment.initializefilenames() end
+end
+
+-- we could set a macro (but will that work when we're expanding? needs testing!)
+
+implement { name = "operatingsystem", public = true, actions = function() context(os.platform) end }
+implement { name = "jobfilefullname", public = true, actions = function() context(environment.jobfilefullname) end }
+implement { name = "jobfilename", public = true, actions = function() context(environment.jobfilename) end }
+implement { name = "jobfilesuffix", public = true, actions = function() context(environment.jobfilesuffix) end }
+implement { name = "inputfilebarename", public = true, actions = function() context(environment.inputfilebarename) end }
+implement { name = "inputfilerealsuffix", public = true, actions = function() context(environment.inputfilerealsuffix) end }
+implement { name = "inputfilesuffix", public = true, actions = function() context(environment.inputfilesuffix) end }
+implement { name = "inputfilename", public = true, actions = function() context(environment.inputfilename) end }
+implement { name = "outputfilename", public = true, actions = function() context(environment.outputfilename) end }
+
+implement {
+ name = "systemlog",
+ arguments = "3 strings",
+ actions = function(whereto,category,text)
+ logs.system(whereto,"context",tex.jobname,category,text)
+ end,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-sys.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-sys.mkxl
new file mode 100644
index 00000000000..c5093588eb4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-sys.mkxl
@@ -0,0 +1,451 @@
+%D \module
+%D [ file=core-sys, % moved from main-001
+%D version=1997.03.31,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=System,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% we need to mkiv-ize this file !
+
+\writestatus{loading}{ConTeXt Core Macros / System}
+
+\registerctxluafile{core-sys}{autosuffix}
+
+\unprotect
+
+%D Version checking:
+
+\permanent\protected\def\newcontextversion#1%
+ {\doifelse{#1}\contextversion
+ {\aliased\let\newcontextversion\gobbleoneargument}
+ {\writeline
+ \writestatus{Fatal Error}{Your format does not match the base files!}%
+ \writeline
+ \writestatus{Format Version}{\contextversion\space\contextmark}%
+ \writestatus{Files Version}{#1}%
+ \batchmode
+ \normalend}}
+
+%D End of lines to the output. \TEX\ will map this onto the platform specific
+%D line ending. I hate this mess.
+
+
+% \operatingsystem % defined at lua end
+
+%D The jobname is what gets loaded by the cont-yes stub file. This name also
+%D determines the name of tuc etc files.
+
+% \jobfilefullname % defined at lua end
+% \jobfilename % defined at lua end
+% \jobfilesuffix % defined at lua end
+
+%D However, that one can itself load another file.
+
+% \inputfilebarename % defined at lua end
+% \inputfilerealsuffix % defined at lua end
+% \inputfilesuffix % defined at lua end
+% \inputfilename % defined at lua end
+
+%D The output name is only used for some checking.
+
+% \outputfilename % defined at lua end
+
+\installcorenamespace{system}
+
+\installdirectcommandhandler \??system {system}
+
+\appendtoks
+% \edef\outputfilename {\directsystemparameter\c!file }%
+% \edef\inputfilename {\directsystemparameter\c!inputfile }%
+\to \everysetupsystem
+
+\appendtoks
+ \ifcase\directsystemparameter\c!n\relax
+ % % 0 : unknown
+ \or
+ \setsystemmode\v!first % 1 : first run
+ \or
+ % % 2 : successive run
+ \or
+ \setsystemmode\v!first % 3 : first and only run
+ \or
+ \setsystemmode\v!last % 4 : (extra) last run
+ \fi
+\to \everysetupsystem
+
+\newconditional\prerollrun % when true it means that we have a forced number of runs
+
+% Some mechanisms (see x-res-01) use either \jobfilename or
+% \jobfilename.somesuffix, in which case we need to use the full name if given or a
+% default (like \jobfilename.xml); this comes down to replacing the default tex
+% suffix.
+
+\permanent\def\jobfullname{\jobfilename.\jobfilesuffix}
+
+\permanent\protected\def\setjobfullname#1% #1 = default if not given
+ {\doifelsenothing\jobfilename
+ {\let\jobfullname\empty}
+ {\doif\jobfilesuffix\c!tex{\edef\jobfullname{\jobfilename.#1}}}}
+
+%D There are a couple of system states avaiable:
+%D
+%D \starttabulate [|T|T|]
+%D \NC \type{\jobname} \NC \jobname \NC \NR
+%D \NC \type{\jobfilename} \NC \jobfilename \NC \NR
+%D \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC \NR
+%D \NC \type{\inputfilename} \NC \inputfilename \NC \NR
+%D \NC \type{\inputfilebarename} \NC \inputfilebarename \NC \NR
+%D \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC \NR
+%D \NC \type{\outputfilename} \NC \outputfilename \NC \NR
+%D \NC \type{\operatingsystem} \NC \operatingsystem \NC \NR
+%D \stoptabulate
+
+% \appendtoks
+% \edef\outputresolution{\directsystemparameter\c!resolution}%
+% \to \everysetupsystem
+
+%D The system modes set by the setup command can be used in situations like:
+%D
+%D \starttyping
+%D \startmode[*first]
+%D \executesystemcommand{cleanupxml text.xml clean-text.xml}
+%D \stopmode
+%D
+%D \starttext
+%D \typefile{clean-text.xml}
+%D \stoptext
+%D \stoptyping
+
+\permanent\protected\def\setuprandomize[#1]%
+ {\doifsomething{#1}
+ {\begingroup
+ % tex's time is in minutes
+ \scratchcounter\normaltime
+ \processaction
+ [#1]
+ [ \v!small=>\divide\scratchcounter 15, % 900,
+ \v!medium=>\divide\scratchcounter 30, % 1800,
+ \v!big=>\divide\scratchcounter 60, % 3600,
+ \v!normal=>\scratchcounter\newrandomseed,
+ \s!default=>\scratchcounter\newrandomseed,
+ \s!unknown=>\scratchcounter#1]%
+ \setrandomseed\scratchcounter
+ % \writestatus\m!system{randomseed: \the\scratchcounter}%
+ \endgroup}}
+
+\setupsystem
+ [\c!directory=,
+ \c!n=0, % 0:unknown 1: one run 2: first 3: successive 4: final run
+ % \c!resolution=600,% in dpi, no unit in mkiv, not used in lmtx
+ % \c!random=, % obsolete here
+ % \c!file=\jobname,
+ % \c!inputfile=\outputfilename,
+ \c!type=unix, % windows is normally less sensitive to handle
+ \c!bodyfont=\normalizedlocalbodyfontsize] % of iets anders
+
+%D Remark: windows programs normally handle \type {cr|lf|crlf} but unix is more
+%D picky, so we default to the \type {cr}. I never understood why \type {crlf} was
+%D not used in all systems, since it makes most sense. But anyway, in \MKIV\ we
+%D avoid most of the complications anyway as we deal with much at the \LUA\ end.
+
+\permanent\tolerant\protected\def\start[#1]%
+ {\bgroup
+ \ifparameters
+ \expandafter\syst_start_nop
+ \else
+ \edef\m_syst_start_stop{#1}%
+ \expandafter\syst_start_yes
+ \fi}
+
+\let\syst_stop_indeed\donothing
+
+\def\syst_start_yes
+ {\ifempty\m_syst_start_stop
+ \let\syst_stop_indeed\donothing
+ \orelse\ifcsname\e!start\m_syst_start_stop\endcsname
+ \expandafter\let\expandafter\syst_stop_indeed\csname\e!stop\m_syst_start_stop\endcsname
+ \csname\e!start\m_syst_start_stop\expandafter\expandafter\expandafter\endcsname
+ \else
+ \let\syst_stop_indeed\donothing
+ \fi}
+
+\def\syst_start_nop
+ {\let\syst_stop_indeed\donothing}
+
+\permanent\protected\def\stop
+ {\syst_stop_indeed
+ \egroup}
+
+% \c!before \c!after \c!inbetween \c!commands \c!style \c!color
+
+\installcorenamespace{startstop}
+
+\installcommandhandler \??startstop {startstop} \??startstop
+
+\appendtoks
+ \frozen\setuevalue{\e!start\currentstartstop}{\syst_startstop_start {\currentstartstop}}%
+ \frozen\setuevalue{\e!stop \currentstartstop}{\syst_startstop_stop {\currentstartstop}}%
+ \frozen\setuevalue {\currentstartstop}{\syst_startstop_indeed{\currentstartstop}}%
+\to \everydefinestartstop
+
+\ifdefined\dotagconstruct \else \aliased\let\dotagconstruct\relax \fi
+
+\protected\def\syst_startstop_start#1%
+ {\namedstartstopparameter{#1}\c!before\relax
+ \bgroup
+ \def\currentstartstop{#1}%
+ % we will keep this for a while:
+ \startstopparameter\c!commands\relax % obsolete
+ % this is the new method:
+ \usesetupsparameter\startstopparameter\relax % only in the display version
+ \dostarttagged\t!construct\currentstartstop
+ \usestartstopstyleandcolor\c!style\c!color
+ \dotagconstruct}
+
+\protected\def\syst_startstop_stop#1%
+ {\dostoptagged
+ \egroup
+ \namedstartstopparameter{#1}\c!after\relax}
+
+\protected\def\syst_startstop_indeed#1%
+ {\groupedcommand
+ {\def\currentstartstop{#1}%
+ \startstopparameter\c!commands\relax % better: setups so that will show op soon
+ \dostarttagged\t!construct\currentstartstop
+ \usestartstopstyleandcolor\c!style\c!color
+ \startstopparameter\c!left\relax}
+ {\def\currentstartstop{#1}% safeguard, not really needed
+ \startstopparameter\c!right\relax
+ \dostoptagged
+ \startstopparameter\c!inbetween\relax}}
+
+% \definestartstop[tracing][\c!style=\tt]
+
+% \protected\def\ignorestartstop[#1]%
+% {\protected\defcsname\e!start#1\expandafter\endcsname\expandafter
+% {\expandafter\gobbleuntil\csname\e!stop#1\endcsname}}
+%
+% \ignorestartstop[bagger]
+
+\installcorenamespace{highlight}
+
+\installcommandhandler \??highlight {highlight} \??highlight % we could do with less
+
+\setuphighlight
+ [\c!define=\v!yes]
+
+\appendtoks
+ \ifcstok{\highlightparameter\c!define}\v!yes
+ \frozen\instance\setuevalue\currenthighlight{\typo_highlights_indeed{\currenthighlight}}%
+ \fi
+\to \everydefinehighlight
+
+\ifdefined\dotaghighlight \else \aliased\let\dotaghighlight\relax \fi
+
+\permanent\protected\def\typo_highlights_indeed#1% inline style/color switch
+ {\dontleavehmode\groupedcommand % otherwise wrong par number in tags
+ {\def\currenthighlight{#1}%
+ \dostarttagged\t!highlight\currenthighlight
+ \usehighlightstyleandcolor\c!style\c!color
+ \dotaghighlight}
+ {\dostoptagged}}
+
+\permanent\protected\def\highlight[#1]%
+ {\typo_highlights_indeed{#1}}
+
+\permanent\protected\def\starthighlight[#1]%
+ {\begingroup
+ \def\currenthighlight{#1}%
+ \dostarttagged\t!highlight\currenthighlight
+ \usehighlightstyleandcolor\c!style\c!color
+ \dotaghighlight}
+
+\permanent\protected\def\stophighlight
+ {\dostoptagged
+ \endgroup}
+
+\aliased\let\directhighlight\typo_highlights_indeed
+
+\permanent\protected\def\defineexpandable
+ {\doifelsenextoptional
+ {\syst_basics_define_yes\def}%
+ {\syst_basics_define_nop\def}}
+
+\permanent\protected\def\define
+ {\doifelsenextoptional
+ {\syst_basics_define_yes{\protected\def}}%
+ {\syst_basics_define_nop{\protected\def}}}
+
+\protected\def\syst_basics_define_yes#1[#2]#3#4%
+ {\ifdefined#3%
+ \showmessage\m!system4{\string#3}%
+ \fi
+ \ifcase0#2\relax
+ #1#3{#4}\or
+ #1#3##1{#4}\or
+ #1#3##1##2{#4}\or
+ #1#3##1##2##3{#4}\or
+ #1#3##1##2##3##4{#4}\or
+ #1#3##1##2##3##4##5{#4}\or
+ #1#3##1##2##3##4##5##6{#4}\or
+ #1#3##1##2##3##4##5##6##7{#4}\or
+ #1#3##1##2##3##4##5##6##7##8{#4}\or
+ #1#3##1##2##3##4##5##6##7##8##9{#4}\else
+ #1#3{#4}\fi}
+
+\protected\def\syst_basics_define_nop#1#2#3%
+ {\ifdefined#2%
+ \showmessage\m!system4{\string#2}%
+ \fi
+ #1#2{#3}}
+
+\aliased\let\redefine\define
+
+% new but maybe not needed:
+%
+% \checked\def \whatever#alpha#beta{#alpha + #beta}
+% \checked\edef\whatever#alpha#beta{#alpha + #beta}
+
+\mutable\let\gobbleddefinition\relax % only for diagnostics
+
+\permanent\protected\def\unique#1#2%
+ {\ifdefined#2%
+ \showmessage\m!system4{\string#2}%
+ \expandafter#1\expandafter\gobbleddefinition
+ \else
+ \expandafter#1%
+ \fi#2}
+
+\permanent\protected\def\checked#1#2%
+ {\ifdefined#2%
+ \showmessage\m!system4{\string#2}%
+ \fi
+ #1#2}
+
+% \startluacode
+% local formatters = string.formatters
+% local contextsprint, ctxcatcodes, prtcatcodes = context.sprint, tex.ctxcatcodes, tex.prtcatcodes
+% local match, gmatch, rep = string.match, string.gmatch, string.rep
+% local empty = {
+% "single",
+% "double",
+% "triple",
+% "quadruple",
+% "quintuple",
+% }
+% local check = {
+% "first",
+% "second",
+% "third",
+% "fourth",
+% "fifth",
+% }
+% function commands.define(str)
+% -- we could store the defaults in lua and call lua instead but why bother
+% local arg, cmd = match(str,"(.*)\\(.-)$")
+% local a = { }
+% for s in gmatch(arg,"%[(.-)%]") do
+% a[#a+1] = s
+% end
+% local n = tonumber(a[#a])
+% if n then
+% a[#a] = nil
+% else
+% n = 0
+% end
+% contextsprint(ctxcatcodes,formatters["\\protected\\def\\%s"](cmd))
+% if #a > 0 then
+% contextsprint(prtcatcodes,formatters["{\\do%sempty\\user_defined_%s}"](empty[#a],cmd))
+% contextsprint(prtcatcodes,formatters["\\def\\user_defined_%s"](cmd))
+% for i=1,#a do
+% contextsprint(ctxcatcodes,formatters["[#%s]"](i))
+% end
+% contextsprint(ctxcatcodes,"{")
+% for i=#a,1,-1 do
+% contextsprint(ctxcatcodes,formatters["\\if%sargument"](check[i]))
+% contextsprint(prtcatcodes,formatters["\\def\\next{\\user_defined_indeed_%s"](cmd))
+% for j=1,#a-i do
+% contextsprint(ctxcatcodes,formatters["[%s]"](a[j]))
+% end
+% for j=1,i do
+% contextsprint(ctxcatcodes,formatters["[#%s]"](j))
+% end
+% contextsprint(ctxcatcodes,"}")
+% if i == 1 then
+% contextsprint(ctxcatcodes,rep("\\fi",#a))
+% else
+% contextsprint(ctxcatcodes,"\\else")
+% end
+% end
+% contextsprint(ctxcatcodes,"\\next}")
+% contextsprint(prtcatcodes,formatters["\\def\\user_defined_indeed_%s"](cmd))
+% for i=1,#a do
+% contextsprint(ctxcatcodes,formatters["[#%s]"](i))
+% end
+% end
+% for i=1,n do
+% contextsprint(ctxcatcodes,formatters["#%s"](#a+i))
+% end
+% end
+% \stopluacode
+%
+% \protected\def\define#1#{\ctxcommand{define([[\detokenize{#1}]])}}
+%
+% \starttext
+% \define[2]\whatevera{#1+#2}
+% \whatevera{A}{B}
+% \define[me][too][2]\whateverb{#1+#2+#3+#4}
+% \whateverb[A]{B}{C}
+% \whateverb[A][B]{C}{D}
+% \define[alpha][beta][gamma][delta]\whateverc{#1+#2+#3+#4}
+% \whateverc[P][Q]
+% \stoptext
+
+%D This is a checked variant of \type {\getvalue}.
+
+\permanent\protected\def\macroname#1% brrr
+ {\begincsname#1\endcsname}
+
+% %D A weird one that I probably needed once, so it might as well become
+% %D obsolete.
+%
+% \protected\def\usecommands#1%
+% {\begingroup
+% \def\docommand##1{\setbox\scratchbox\hbox{\csname\string##1\endcsname##1}}%
+% \processcommalist[#1]\docommand
+% \endgroup}
+
+\permanent\protected\def\syst_log_indeed#1#2#3%
+ {\ctxcommand{systemlog("#1","#2",\!!bs#3\!!es)}}
+
+\aliased\let\systemlog\syst_log_indeed
+
+\permanent\protected\def\systemlogfirst
+ {\ifcase\directsystemparameter\c!n\relax
+ \expandafter\syst_log_indeed
+ \or
+ \expandafter\syst_log_indeed
+ \else
+ \expandafter\gobblethreearguments
+ \fi}
+
+\permanent\protected\def\systemloglast
+ {\ifcase\directsystemparameter\c!n\relax
+ \expandafter\syst_log_indeed
+ \or
+ \expandafter\gobblethreearguments
+ \or
+ \expandafter\gobblethreearguments
+ \or
+ \expandafter\gobblethreearguments
+ \or
+ \expandafter\syst_log_indeed
+ \fi}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-two.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-two.mkxl
new file mode 100644
index 00000000000..cadd9d05907
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-two.mkxl
@@ -0,0 +1,111 @@
+%D \module
+%D [ file=core-two, % moved from core-uti
+%D version=1997.03.31,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Two Pass Data,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Two Pass Data}
+
+%D This is a rather old mechanism which has not changed much over time, apart from
+%D adding a few more selectors. This code used to be part of \type {core-uti}. The
+%D following examples demonstrate the interface.
+%D
+%D \startbuffer
+%D \definetwopasslist{test-1}
+%D
+%D \gettwopassdatalist{test-1} [\twopassdatalist=]
+%D \checktwopassdata {test-1} [\twopassdata=]
+%D \checktwopassdata {test-1} [\twopassdata=]
+%D \gettwopassdata {test-1} [\twopassdata=]
+%D \gettwopassdata {test-1} [\twopassdata=]
+%D
+%D \definetwopasslist{test-2}
+%D
+%D \lazysavetwopassdata{test-2}{1}{x}
+%D \lazysavetwopassdata{test-2}{2}{y}
+%D \lazysavetwopassdata{test-2}{3}{z}
+%D
+%D \gettwopassdatalist{test-2} [\twopassdatalist=x,y,z]
+%D \checktwopassdata {test-2} [\twopassdata=x]
+%D \checktwopassdata {test-2} [\twopassdata=x]
+%D \gettwopassdata {test-2} [\twopassdata=x]
+%D \gettwopassdata {test-2} [\twopassdata=y]
+%D \gettwopassdata {test-2} [\twopassdata=z]
+%D \gettwopassdata {test-2} [\twopassdata=]
+%D
+%D \definetwopasslist{test-3}
+%D
+%D \lazysavetaggedtwopassdata{test-3}{1}{x}{a}
+%D \lazysavetaggedtwopassdata{test-3}{2}{y}{b}
+%D \lazysavetaggedtwopassdata{test-3}{3}{z}{c}
+%D
+%D \findtwopassdata{test-3}{x} [\twopassdata=a]
+%D \findtwopassdata{test-3}{y} [\twopassdata=b]
+%D \findtwopassdata{test-3}{z} [\twopassdata=c]
+%D \findtwopassdata{test-3}{w} [\twopassdata=]
+%D
+%D \definetwopasslist{test-4}
+%D
+%D \lazysavetwopassdata{test-4}{1}{A}
+%D \lazysavetwopassdata{test-4}{2}{B}
+%D \lazysavetwopassdata{test-4}{3}{C}
+%D
+%D \getfirsttwopassdata{test-4} [\twopassdata=A]
+%D \getlasttwopassdata {test-4} [\twopassdata=C]
+%D \getfirsttwopassdata{test-4} [\twopassdata=A]
+%D \getlasttwopassdata {test-4} [\twopassdata=C]
+%D \getfromtwopassdata {test-4}{1} [\twopassdata=A]
+%D \getfromtwopassdata {test-4}{3} [\twopassdata=C]
+%D \getfromtwopassdata {test-4}{2} [\twopassdata=B]
+%D \stopbuffer
+%D
+%D \getbuffer \typebuffer
+
+\unprotect
+
+\registerctxluafile{core-two}{}
+
+\permanent\def\immediatesavetwopassdata #1#2#3{\normalexpanded{\noexpand\clf_savetwopassdata{#1}{#3}}}
+\permanent\def \lazysavetwopassdata #1#2#3{\normalexpanded{\noexpand\ctxlatecommand{savetwopassdata("#1","#3")}}}
+\permanent\let \savetwopassdata \lazysavetwopassdata
+\permanent\def \savetaggedtwopassdata#1#2#3#4{\normalexpanded{\noexpand\clf_savetaggedtwopassdata{#1}{#3}{#4}}}
+\permanent\def\lazysavetaggedtwopassdata#1#2#3#4{\normalexpanded{\noexpand\ctxlatecommand{savetaggedtwopassdata("#1",'#3',"#4")}}}
+
+% temp hack: needs a proper \starteverytimeluacode
+
+\setfalse\twopassdatafound
+
+\mutable\let\twopassdata \empty
+\mutable\let\twopassdatalist\empty
+\mutable\let\noftwopassitems\!!zeropoint
+
+\def\syst_twopass_check % can be delegated to lua once obsolete is gone
+ {\ifempty\twopassdata
+ \setfalse\twopassdatafound
+ \else
+ \settrue\twopassdatafound
+ \fi}
+
+\permanent\protected\def\definetwopasslist #1{\clf_definetwopasslist{#1}}
+\permanent\protected\def\gettwopassdata #1{\edef\twopassdata {\clf_gettwopassdata {#1}}\syst_twopass_check}
+\permanent\protected\def\checktwopassdata #1{\edef\twopassdata {\clf_checktwopassdata {#1}}\syst_twopass_check}
+\permanent\protected\def\findtwopassdata #1#2{\edef\twopassdata {\clf_findtwopassdata {#1}{#2}}\syst_twopass_check}
+\permanent\protected\def\getfirsttwopassdata #1{\edef\twopassdata {\clf_getfirsttwopassdata {#1}}\syst_twopass_check}
+\permanent\protected\def\getlasttwopassdata #1{\edef\twopassdata {\clf_getlasttwopassdata {#1}}%
+ \edef\noftwopassitems{\clf_counttwopassdata {#1}}\syst_twopass_check}
+\permanent\protected\def\getnamedtwopassdatalist#1#2{\edef #1{\clf_gettwopassdatalist {#2}}}
+\permanent\protected\def\gettwopassdatalist #1{\edef\twopassdatalist{\clf_gettwopassdatalist {#1}}}
+
+\permanent\protected\def\doifelseintwopassdata #1#2{\clf_doifelseintwopassdata{#1}{#2}}
+
+\aliased\let\doifintwopassdataelse\doifelseintwopassdata
+\aliased\let\getfromtwopassdata \findtwopassdata
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-uti.lua b/Master/texmf-dist/tex/context/base/mkxl/core-uti.lua
new file mode 100644
index 00000000000..887ef9a7536
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-uti.lua
@@ -0,0 +1,470 @@
+if not modules then modules = { } end modules ['core-uti'] = {
+ version = 1.001,
+ comment = "companion to core-uti.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- todo: keep track of changes here (hm, track access, and only true when
+-- accessed and changed)
+
+--[[ldx--
+
A utility file has always been part of and with
+the move to we also moved a lot of multi-pass info
+to a table. Instead of loading a based
+utility file under different setups, we now load a table once. This
+saves much runtime but at the cost of more memory usage.
+--ldx]]--
+
+local math = math
+local format, match = string.format, string.match
+local next, type, tostring, tonumber = next, type, tostring, tonumber
+local concat = table.concat
+
+local definetable = utilities.tables.definetable
+local accesstable = utilities.tables.accesstable
+local migratetable = utilities.tables.migratetable
+local serialize = table.serialize
+local packers = utilities.packers
+local allocate = utilities.storage.allocate
+local mark = utilities.storage.mark
+
+local getrandom = utilities.randomizer.get
+local setrandomseedi = utilities.randomizer.setseedi
+local getrandomseed = utilities.randomizer.getseed
+
+local implement = interfaces.implement
+
+local texgetcount = tex.getcount
+
+local report_passes = logs.reporter("job","passes")
+
+job = job or { }
+local job = job
+
+job.version = 1.32
+job.packversion = 1.02
+
+-- some day we will implement loading of other jobs and then we need
+-- job.jobs
+
+--[[ldx--
+
Variables are saved using in the previously defined table and passed
+onto using the following method. Of course one can also
+directly access the variable using a call.
+--ldx]]--
+
+local savelist, comment = { }, { }
+
+function job.comment(key,value)
+ if type(key) == "table" then
+ for k, v in next, key do
+ comment[k] = v
+ end
+ else
+ comment[key] = value
+ end
+end
+
+job.comment("version",job.version)
+
+local enabled = true
+local initialized = false
+
+directives.register("job.save",function(v) enabled = v end)
+
+function job.disablesave()
+ enabled = false -- for instance called when an error
+end
+
+function job.initialize(loadname,savename)
+ if not initialized then
+ if not loadname or loadname == "" then
+ loadname = tex.jobname .. ".tuc"
+ end
+ if not savename or savename == "" then
+ savename = tex.jobname .. ".tua"
+ end
+ job.load(loadname) -- has to come after structure is defined !
+ luatex.registerstopactions(function()
+ if enabled then
+ job.save(savename)
+ end
+ end)
+ initialized = true
+ end
+end
+
+function job.register(collected, tobesaved, initializer, finalizer, serializer)
+ savelist[#savelist+1] = { collected, tobesaved, initializer, finalizer, serializer }
+end
+
+-- as an example we implement variables
+
+local tobesaved, collected, checksums = allocate(), allocate(), allocate()
+
+local jobvariables = {
+ collected = collected,
+ tobesaved = tobesaved,
+ checksums = checksums,
+}
+
+-- if not checksums.old then checksums.old = md5.HEX("old") end -- used in experiment
+-- if not checksums.new then checksums.new = md5.HEX("new") end -- used in experiment
+
+job.variables = jobvariables
+
+local function initializer()
+ checksums = jobvariables.checksums
+end
+
+job.register('job.variables.checksums', 'job.variables.checksums', initializer)
+
+local rmethod, rvalue
+local collectedmacros, tobesavedmacros
+
+local ctx_setxvalue = context.setxvalue
+
+local function initializer()
+ tobesaved = jobvariables.tobesaved
+ collected = jobvariables.collected
+ --
+ rvalue = collected.randomseed
+ if not rvalue then
+ rvalue = getrandom("initialize")
+ setrandomseedi(rvalue)
+ rmethod = "initialized"
+ else
+ setrandomseedi(rvalue)
+ rmethod = "resumed"
+ end
+ tobesaved.randomseed = rvalue
+ --
+ collectedmacros = collected.macros
+ tobesavedmacros = tobesaved.macros
+ if not collectedmacros then
+ collectedmacros = { }
+ collected.macros = collectedmacros
+ end
+ if not tobesavedmacros then
+ tobesavedmacros = { }
+ tobesaved.macros = tobesavedmacros
+ end
+ -- will become collected.macros
+ for cs, value in next, collectedmacros do
+ if type(value) == "string" then -- safeguard
+ ctx_setxvalue(cs,value)
+ end
+ end
+end
+
+job.register('job.variables.collected', tobesaved, initializer)
+
+function jobvariables.save(cs,value)
+ tobesavedmacros[cs] = value
+end
+
+function jobvariables.restore(cs)
+ return collectedmacros[cs] or tobesavedmacros[cs]
+end
+
+function job.getrandomseed()
+ return tobesaved.randomseed or getrandomseed()
+end
+
+-- checksums
+
+function jobvariables.getchecksum(tag)
+ return checksums[tag] -- no default
+end
+
+function jobvariables.makechecksum(data)
+ return data and md5.HEX(data) -- no default
+end
+
+function jobvariables.setchecksum(tag,checksum)
+ checksums[tag] = checksum
+end
+
+--
+
+local packlist = {
+ "numbers",
+ "ownnumbers",
+ "metadata",
+ "sectiondata",
+ "prefixdata",
+ "numberdata",
+ "pagedata",
+ "directives",
+ "specification",
+ "processors", -- might become key under directives or metadata
+-- "references", -- we need to rename of them as only one packs (not structures.lists.references)
+}
+
+local skiplist = {
+ "datasets",
+ "userdata",
+ "positions",
+}
+
+-- not ok as we can have arbitrary keys in userdata and dataset so some day we
+-- might need a bit more granularity, like skippers
+
+local jobpacker = packers.new(packlist,job.packversion,skiplist) -- jump number when changs in hash
+
+job.pack = true
+-- job.pack = false
+
+directives.register("job.pack",function(v) job.pack = v end)
+
+local _save_, _load_, _others_ = { }, { }, { } -- registers timing
+
+function job.save(filename) -- we could return a table but it can get pretty large
+ statistics.starttiming(_save_)
+ local f = io.open(filename,'w')
+ if f then
+ f:write("local utilitydata = { }\n\n")
+ f:write(serialize(comment,"utilitydata.comment",true),"\n\n")
+ for l=1,#savelist do
+ -- f:write("do\n\n") -- no solution for the jit limitatione either
+ local list = savelist[l]
+ local target = format("utilitydata.%s",list[1])
+ local data = list[2]
+ local finalizer = list[4]
+ local serializer = list[5]
+ if type(data) == "string" then
+ data = utilities.tables.accesstable(data)
+ end
+ if type(finalizer) == "function" then
+ finalizer()
+ end
+ if job.pack then
+ packers.pack(data,jobpacker,true)
+ end
+ local definer, name = definetable(target,true,true) -- no first and no last
+ if serializer then
+ f:write(definer,"\n\n",serializer(data,name,true),"\n\n")
+ else
+ f:write(definer,"\n\n",serialize(data,name,true),"\n\n")
+ end
+ -- f:write("end\n\n")
+ end
+ if job.pack then
+ packers.strip(jobpacker)
+ -- f:write("do\n\n")
+ f:write(serialize(jobpacker,"utilitydata.job.packed",true),"\n\n")
+ -- f:write("end\n\n")
+ end
+ f:write("return utilitydata")
+ f:close()
+ end
+ statistics.stoptiming(_save_)
+end
+
+local function load(filename)
+ if lfs.isfile(filename) then
+
+ local function dofile(filename)
+ local result = loadstring(io.loaddata(filename))
+ if result then
+ return result()
+ else
+ return nil
+ end
+ end
+
+ local okay, data = pcall(dofile,filename)
+ if okay and type(data) == "table" then
+ local jobversion = job.version
+ local datacomment = data.comment
+ local dataversion = datacomment and datacomment.version or "?"
+ if dataversion ~= jobversion then
+ report_passes("version mismatch: %s <> %s",dataversion,jobversion)
+ else
+ return data
+ end
+ else
+ os.remove(filename) -- probably a bad file (or luajit overflow as it cannot handle large tables well)
+ report_passes("removing stale job data file %a, restart job, message: %s%s",filename,tostring(data),
+ jit and " (try luatex instead of luajittex)" or "")
+ os.exit(true) -- trigger second run
+ end
+ end
+end
+
+function job.load(filename)
+ statistics.starttiming(_load_)
+ local utilitydata = load(filename)
+ if utilitydata then
+ local jobpacker = utilitydata.job.packed
+ local handlers = { }
+ for i=1,#savelist do
+ local list = savelist[i]
+ local target = list[1]
+ local initializer = list[3]
+ local result = accesstable(target,utilitydata)
+ if result then
+ local done = packers.unpack(result,jobpacker,true)
+ if done then
+ migratetable(target,mark(result))
+ if type(initializer) == "function" then
+ handlers[#handlers+1] = { initializer, result }
+ end
+ else
+ report_passes("pack version mismatch")
+ end
+ end
+ end
+ -- so we have all tables available (unpacked)
+ for i=1,#handlers do
+ local handler = handlers[i]
+ handler[1](handler[2])
+ end
+ end
+ statistics.stoptiming(_load_)
+end
+
+function job.loadother(filename)
+ statistics.starttiming(_load_)
+ _others_[#_others_+1] = file.nameonly(filename)
+ local utilitydata = load(filename)
+ if utilitydata then
+ local jobpacker = utilitydata.job.packed
+ local unpacked = { }
+ for l=1,#savelist do
+ local list = savelist[l]
+ local target = list[1]
+ local result = accesstable(target,utilitydata)
+ local done = packers.unpack(result,jobpacker,true)
+ if done then
+ migratetable(target,result,unpacked)
+ end
+ end
+ unpacked.job.packed = nil -- nicer in inspecting
+ return unpacked
+ end
+ statistics.stoptiming(_load_)
+end
+
+-- function job.keep(filename)
+-- local suffix = file.suffix(filename)
+-- local base = file.removesuffix(filename)
+-- if suffix == "" then
+-- suffix = "tuc"
+-- end
+-- for i=1,10 do
+-- local tmpname = format("%s-%s-%02d.tmp",base,suffix,i)
+-- if lfs.isfile(tmpname) then
+-- os.remove(tmpname)
+-- report_passes("removing %a",tmpname)
+-- end
+-- end
+-- if lfs.isfile(filename) then
+-- local tmpname = format("%s-%s-%02d.tmp",base,suffix,environment.currentrun or 1)
+-- report_passes("copying %a into %a",filename,tmpname)
+-- file.copy(filename,tmpname)
+-- else
+-- report_passes("no file %a, nothing kept",filename)
+-- end
+-- end
+
+-- eventually this will end up in strc-ini
+
+statistics.register("startup time", function()
+ return statistics.elapsedseconds(statistics,"including runtime option file processing")
+end)
+
+statistics.register("jobdata time",function()
+ if enabled then
+ if #_others_ > 0 then
+ return format("%s seconds saving, %s seconds loading, other files: %s",statistics.elapsedtime(_save_),statistics.elapsedtime(_load_),concat(_others_," "))
+ else
+ return format("%s seconds saving, %s seconds loading",statistics.elapsedtime(_save_),statistics.elapsedtime(_load_))
+ end
+ else
+ if #_others_ > 0 then
+ return format("nothing saved, %s seconds loading, other files: %s",statistics.elapsedtime(_load_),concat(_others_," "))
+ else
+ return format("nothing saved, %s seconds loading",statistics.elapsedtime(_load_))
+ end
+ end
+end)
+
+statistics.register("callbacks", function()
+ local c_internal = status.callbacks or 0
+ local c_file = status.indirect_callbacks or 0
+ local c_direct = status.direct_callbacks or 0
+ local c_late = backends.getcallbackstate().count
+ local c_function = status.function_callbacks or 0
+ local c_total = c_internal + c_file + c_direct + c_late + c_function
+ local n_pages = structures.pages.nofpages or 0
+ local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0
+ local result = format (
+ "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)",
+ c_internal, c_file, c_direct, c_late, c_function, c_total, c_average
+ )
+ statistics.callbacks = function()
+ return result
+ end
+ return result
+end)
+
+statistics.register("randomizer", function()
+ if rmethod and rvalue then
+ return format("%s with value %s",rmethod,rvalue)
+ end
+end)
+
+-- a sort of joke (for ctx meeting)
+
+-- local kg_per_watt_per_second = 1 / 15000000
+-- local watts_per_core = 50
+-- local speedup_by_other_engine = 1.2
+-- local used_wood_factor = watts_per_core * kg_per_watt_per_second / speedup_by_other_engine
+-- local used_wood_factor = (50 / 15000000) / 1.2
+
+
+function statistics.formatruntime(runtime)
+ if not environment.initex then -- else error when testing as not counters yet
+ -- stoptiming(statistics) -- to be sure
+ local shipped = texgetcount('nofshipouts')
+ local pages = texgetcount('realpageno')
+ if pages > shipped then
+ pages = shipped
+ end
+ runtime = tonumber(runtime)
+ if shipped > 0 or pages > 0 then
+ local persecond = (runtime > 0) and (shipped/runtime) or pages
+ if pages == 0 then
+ pages = shipped
+ end
+ return format("%0.3f seconds, %i processed pages, %i shipped pages, %.3f pages/second",runtime,pages,shipped,persecond)
+ else
+ return format("%0.3f seconds",runtime)
+ end
+ end
+end
+
+implement {
+ name = "savevariable",
+ actions = job.variables.save,
+ arguments = "2 strings",
+}
+
+implement {
+ name = "setjobcomment",
+ actions = job.comment,
+ arguments = { { "*" } }
+}
+
+implement {
+ name = "initializejob",
+ actions = job.initialize
+}
+
+implement {
+ name = "disablejobsave",
+ actions = job.disablesave
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/core-uti.mkxl b/Master/texmf-dist/tex/context/base/mkxl/core-uti.mkxl
new file mode 100644
index 00000000000..b8d3bf7ebed
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/core-uti.mkxl
@@ -0,0 +1,35 @@
+%D \module
+%D [ file=core-uti,
+%D version=1997.03.31, % 2006.09.19 mkiv
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Utility File Handling,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / Utility File Handling}
+
+\unprotect
+
+\registerctxluafile{core-uti}{}
+
+% savecurrentvalue#1#2% immediate, expanded, defined at lua end
+
+\appendtoks
+ \clf_setjobcomment
+ file {\jobname}%
+ format {\contextformat}%
+ stamp {\contextversion}%
+ escape {\!!bs\space...\space\!!es}%
+ \relax
+\to \everystarttext
+
+\appendtoks
+ \clf_initializejob
+\to \everyjob
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/driv-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/driv-ini.lmt
new file mode 100644
index 00000000000..729196e870d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/driv-ini.lmt
@@ -0,0 +1,375 @@
+if not modules then modules = { } end modules ['driv-ini'] = {
+ version = 1.001,
+ comment = "companion to driv-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type = type
+local addsuffix = file.addsuffix
+
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
+local report = logs.reporter("drivers")
+
+local instances = { }
+local helpers = { }
+local converters = { }
+local prepared = { }
+local wrappedup = { }
+local cleanedup = { }
+local currentdriver = "default"
+local currentinstance = nil
+
+local shipout = tex.shipout
+local texgetbox = tex.getbox
+local texgetcount = tex.getcount
+
+function converters.engine(driver,boxnumber,mode,number,specification)
+ return shipout(boxnumber)
+end
+
+local prepare = nil
+local convert = nil
+local wrapup = nil
+local cleanup = nil
+local outputfilename = nil
+
+drivers = drivers or {
+ instances = instances,
+ helpers = helpers,
+ converters = converters,
+ lmtxversion = 0.10,
+ report = report,
+}
+
+local dummy = function() end
+
+local defaulthandlers = {
+ prepare = dummy,
+ initialize = dummy,
+ finalize = dummy,
+ updatefontstate = dummy,
+ wrapup = dummy,
+ cleanup = dummy,
+ convert = dummy,
+ outputfilename = dummy,
+}
+
+local installwhatsits do
+
+ local leaderlevel = 0
+ local backends = backends
+
+ local function pushleaderlevel()
+ leaderlevel = leaderlevel + 1
+ end
+
+ local function popleaderlevel()
+ leaderlevel = leaderlevel - 1
+ end
+
+ local function flushlatelua(current,h,v)
+ -- Here we assume maganement by the lua function so currently we don't
+ -- check for leaderlevel.
+ return backends.latelua(current,h,v)
+ end
+
+ local function flushwriteout(current)
+ if leaderlevel == 0 then
+ backends.writeout(current)
+ end
+ end
+
+ local function flushopenout(current)
+ if leaderlevel == 0 then
+ backends.openout(current)
+ end
+ end
+
+ local function flushcloseout(current)
+ if leaderlevel == 0 then
+ backends.closeout(current)
+ end
+ end
+
+ local function flushsavepos(current,pos_h,pos_v)
+ local jp = job.positions
+ jp.lastx = pos_h
+ jp.lasty = pos_v
+ end
+
+ local function flushuserdefined()
+ -- nothing here
+ end
+
+ local whatsitcodes = nodes.whatsitcodes
+
+ local trace = true trackers.register("backends.whatsits",function(v) trace = v end)
+
+ installwhatsits = function(name,flushers)
+
+ -- latelua : specific
+ -- userdefined : special purpose, handled in callbacks
+ -- savepos : only used by generic packages
+ -- open : generic
+ -- close : generic
+ -- write : generic
+
+ -- An alternative is to have a first time setter.
+
+ local function checkagain(t, k)
+ local v = rawget(flushers,k) -- in case it's registered later
+ if not v then
+ if trace then
+ report("unsupported whatsit %a in driver %a",whatsitcodes[k] or k,name)
+ end
+ v = function() end
+ end
+ t[k] = v
+ return v
+ end
+
+ -- flushers.whatsit = setmetatableindex ( {
+ -- [whatsitcodes.literal] = flushers.literal,
+ -- [whatsitcodes.latelua] = flushlatelua,
+ -- [whatsitcodes.userdefined] = flushuserdefined,
+ -- [whatsitcodes.savepos] = flushsavepos,
+ -- [whatsitcodes.save] = flushers.save,
+ -- [whatsitcodes.restore] = flushers.restore,
+ -- [whatsitcodes.setmatrix] = flushers.setmatrix,
+ -- [whatsitcodes.open] = flushopenout,
+ -- [whatsitcodes.close] = flushcloseout,
+ -- [whatsitcodes.write] = flushwriteout,
+ -- [whatsitcodes.startmatrix] = flushers.startmatrix,
+ -- [whatsitcodes.stopmatrix] = flushers.stopmatrix,
+ -- [whatsitcodes.startscaling] = flushers.startscaling,
+ -- [whatsitcodes.stopscaling] = flushers.stopscaling,
+ -- [whatsitcodes.startrotation] = flushers.startrotation,
+ -- [whatsitcodes.stoprotation] = flushers.stoprotation,
+ -- [whatsitcodes.startmirroring] = flushers.startmirroring,
+ -- [whatsitcodes.stopmirroring] = flushers.stopmirroring,
+ -- [whatsitcodes.startclipping] = flushers.startclipping,
+ -- [whatsitcodes.stopclipping] = flushers.stopclipping,
+ -- [whatsitcodes.setstate] = flushers.setstate,
+ -- }, checkagain )
+
+ -- -- sparse
+
+ -- flushers.whatsit = setmetatableindex ( {
+ -- [whatsitcodes.latelua] = flushlatelua,
+ -- [whatsitcodes.userdefined] = flushuserdefined,
+ -- [whatsitcodes.savepos] = flushsavepos,
+ -- [whatsitcodes.open] = flushopenout,
+ -- [whatsitcodes.close] = flushcloseout,
+ -- [whatsitcodes.write] = flushwriteout,
+ -- }, checkagain )
+
+ -- -- delayed
+
+ local whatsit ; whatsit = setmetatableindex ( {
+ [whatsitcodes.literal] = flushers.literal or function(...) return checkagain(whatsit,whatsitcodes.literal )(...) end,
+ [whatsitcodes.latelua] = flushlatelua,
+ [whatsitcodes.userdefined] = flushuserdefined,
+ [whatsitcodes.savepos] = flushsavepos,
+ [whatsitcodes.save] = flushers.save or function(...) return checkagain(whatsit,whatsitcodes.save )(...) end,
+ [whatsitcodes.restore] = flushers.restore or function(...) return checkagain(whatsit,whatsitcodes.restore )(...) end,
+ [whatsitcodes.setmatrix] = flushers.setmatrix or function(...) return checkagain(whatsit,whatsitcodes.setmatrix )(...) end,
+ [whatsitcodes.open] = flushopenout,
+ [whatsitcodes.close] = flushcloseout,
+ [whatsitcodes.write] = flushwriteout,
+ [whatsitcodes.startmatrix] = flushers.startmatrix or function(...) return checkagain(whatsit,whatsitcodes.startmatrix )(...) end,
+ [whatsitcodes.stopmatrix] = flushers.stopmatrix or function(...) return checkagain(whatsit,whatsitcodes.stopmatrix )(...) end,
+ [whatsitcodes.startscaling] = flushers.startscaling or function(...) return checkagain(whatsit,whatsitcodes.startscaling )(...) end,
+ [whatsitcodes.stopscaling] = flushers.stopscaling or function(...) return checkagain(whatsit,whatsitcodes.stopscaling )(...) end,
+ [whatsitcodes.startrotation] = flushers.startrotation or function(...) return checkagain(whatsit,whatsitcodes.startrotation )(...) end,
+ [whatsitcodes.stoprotation] = flushers.stoprotation or function(...) return checkagain(whatsit,whatsitcodes.stoprotation )(...) end,
+ [whatsitcodes.startmirroring] = flushers.startmirroring or function(...) return checkagain(whatsit,whatsitcodes.startmirroring)(...) end,
+ [whatsitcodes.stopmirroring] = flushers.stopmirroring or function(...) return checkagain(whatsit,whatsitcodes.stopmirroring )(...) end,
+ [whatsitcodes.startclipping] = flushers.startclipping or function(...) return checkagain(whatsit,whatsitcodes.startclipping )(...) end,
+ [whatsitcodes.stopclipping] = flushers.stopclipping or function(...) return checkagain(whatsit,whatsitcodes.stopclippin )(...) end,
+ [whatsitcodes.setstate] = flushers.setstate or function(...) return checkagain(whatsit,whatsitcodes.setstate )(...) end,
+ }, checkagain)
+
+ flushers.whatsit = whatsit
+
+ flushers.pushleaderlevel = pushleaderlevel
+ flushers.popleaderlevel = popleaderlevel
+
+ end
+
+end
+
+function drivers.install(specification)
+ local name = specification.name
+ if not name then
+ report("missing driver name")
+ return
+ end
+ local actions = specification.actions
+ if not actions then
+ report("no actions for driver %a",name)
+ return
+ end
+ local flushers = specification.flushers
+ if not flushers then
+ report("no flushers for driver %a",name)
+ return
+ end
+ installwhatsits(name,flushers)
+ -- report("driver %a is installed",name)
+ setmetatableindex(actions, defaulthandlers)
+ setmetatableindex(flushers, function() return dummy end)
+ instances[name] = specification
+end
+
+function drivers.convert(boxnumber)
+ if currentinstance then
+ callbacks.functions.start_page_number()
+ starttiming(drivers)
+ convert(currentinstance,boxnumber,texgetcount("realpageno"))
+ stoptiming(drivers)
+ callbacks.functions.stop_page_number()
+ end
+end
+
+function drivers.outputfilename()
+ if currentinstance then
+ return outputfilename(currentinstance)
+ end
+end
+
+luatex.wrapup(function()
+ if currentinstance and wrapup and not wrappedup[currentdriver] then
+ starttiming(drivers)
+ wrapup(currentinstance)
+ stoptiming(drivers)
+ wrappedup[currentdriver] = true
+ cleanedup[currentdriver] = true
+ end
+end)
+
+luatex.cleanup(function()
+ if currentinstance and cleanup and not cleanedup[currentdriver] then
+ starttiming(drivers)
+ cleanup(currentinstance)
+ stoptiming(drivers)
+ wrappedup[currentdriver] = true
+ cleanedup[currentdriver] = true
+ end
+end)
+
+function drivers.enable(name)
+ if name ~= currentdriver then
+ if currentinstance then
+ starttiming(drivers)
+ cleanup(currentinstance)
+ stoptiming(drivers)
+ end
+ currentdriver = name or "default"
+ currentinstance = instances[currentdriver]
+ if currentinstance then
+ local actions = currentinstance.actions
+ prepare = actions.prepare
+ wrapup = actions.wrapup
+ cleanup = actions.cleanup
+ convert = actions.convert
+ outputfilename = actions.outputfilename
+ --
+ if prepare and not prepared[currentdriver] then
+ starttiming(drivers)
+ prepare(currentinstance)
+ stoptiming(drivers)
+ prepared[currentdriver] = true
+ end
+ else
+ report("bad driver")
+ end
+ end
+end
+
+statistics.register("driver time",function()
+ return statistics.elapsedseconds(drivers)
+end)
+
+interfaces.implement {
+ name = "shipoutpage",
+ arguments = "integer",
+ actions = drivers.convert,
+}
+
+interfaces.implement {
+ name = "enabledriver",
+ arguments = "string",
+ actions = drivers.enable,
+}
+
+-- The default driver:
+
+do
+
+ local filename = nil
+
+ drivers.install {
+ name = "default",
+ actions = {
+ convert = drivers.converters.engine,
+ outputfilename = function(driver)
+ if not filename then
+ filename = addsuffix(tex.jobname,"pdf")
+ end
+ return filename
+ end,
+ },
+ flushers = {
+ -- we always need this entry
+ },
+ }
+
+end
+
+-- No driver:
+
+do
+
+ drivers.install {
+ name = "none",
+ actions = { },
+ flushers = { },
+ }
+
+end
+
+do
+
+ local function prepare(driver)
+ converter = drivers.converters.lmtx
+ end
+
+ local function convert(driver,boxnumber,pagenumber)
+ converter(driver,texgetbox(boxnumber),"page",pagenumber)
+ end
+
+ drivers.install {
+ name = "empty",
+ actions = {
+ prepare = prepare,
+ convert = convert,
+ },
+ flushers = { },
+ }
+
+end
+
+--
+
+setmetatableindex(instances,function() return instances.default end)
+
+-- for now:
+
+drivers.enable("default")
diff --git a/Master/texmf-dist/tex/context/base/mkxl/driv-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/driv-ini.mkxl
new file mode 100644
index 00000000000..947eb37779d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/driv-ini.mkxl
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=driv-ini,
+%D version=2018.07.26,
+%D title=\CONTEXT\ Driver Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Driver Macros / Initialization}
+
+\registerctxluafile{driv-ini}{autosuffix}
+
+\unprotect
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/driv-shp.lmt b/Master/texmf-dist/tex/context/base/mkxl/driv-shp.lmt
new file mode 100644
index 00000000000..d3a47bf0d2e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/driv-shp.lmt
@@ -0,0 +1,1358 @@
+if not modules then modules = { } end modules ['driv-shp'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to driv-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type, next = type, next
+
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+local concat = table.concat
+local keys = table.keys
+local sortedhash = table.sortedhash
+local splitstring = string.split
+local find = string.find
+local stripstring = string.strip
+local idiv = number.idiv
+local sequenced = table.sequenced
+local round = math.round
+local extract = bit32.extract
+local nuts = nodes.nuts
+
+local tonut = nodes.tonut
+local tonode = nodes.tonode
+
+local getdirection = nuts.getdirection
+local getlist = nuts.getlist
+local getoffsets = nuts.getoffsets
+local getorientation = nuts.getorientation
+local getfield = nuts.getfield
+local getwhd = nuts.getwhd
+local getkern = nuts.getkern
+local getheight = nuts.getheight
+local getdepth = nuts.getdepth
+----- getwidth = nuts.getwidth
+local getnext = nuts.getnext
+local getsubtype = nuts.getsubtype
+local getid = nuts.getid
+local getleader = nuts.getleader
+----- getglue = nuts.getglue
+local getshift = nuts.getshift
+local getdata = nuts.getdata
+----- getexpansion = nuts.getexpansion
+local getreplace = nuts.getreplace
+local setreplace = nuts.setreplace
+local getfont = nuts.getfont
+local getkerndimension = nuts.getkerndimension
+
+local setdirection = nuts.setdirection
+local setfield = nuts.setfield
+local setlink = nuts.setlink
+
+local isglyph = nuts.isglyph
+local findtail = nuts.tail
+local nextdir = nuts.traversers.dir
+local nextnode = nuts.traversers.node
+
+----- rangedimensions = node.direct.rangedimensions -- nuts ?
+local effectiveglue = nuts.effective_glue
+local start_of_par = nuts.start_of_par
+local dirdimensions = nuts.dirdimensions
+
+local texget = tex.get
+
+local fonthashes = fonts.hashes
+local fontdata = fonthashes.identifiers
+local characters = fonthashes.characters
+local parameters = fonthashes.parameters
+
+local nodecodes = nodes.nodecodes
+local whatsitcodes = nodes.whatsitcodes
+local gluecodes = nodes.gluecodes
+local dircodes = nodes.dircodes
+local dirvalues = nodes.dirvalues
+local subtypes = nodes.subtypes
+
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
+
+local glyph_code = nodecodes.glyph
+local kern_code = nodecodes.kern
+local glue_code = nodecodes.glue
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local dir_code = nodecodes.dir
+local disc_code = nodecodes.disc
+local math_code = nodecodes.math
+local rule_code = nodecodes.rule
+local whatsit_code = nodecodes.whatsit
+----- penalty_code = nodecodes.penalty
+----- boundary_code = nodecodes.boundary
+
+local leaders_code = gluecodes.leaders
+local cleaders_code = gluecodes.cleaders
+local xleaders_code = gluecodes.xleaders
+local gleaders_code = gluecodes.gleaders
+
+local spaceskip_code = gluecodes.spaceskip
+
+local getpagedimensions = layouts.getpagedimensions
+
+local drivers = drivers
+local instances = drivers.instances
+
+local report = logs.reporter("drivers")
+
+---------------------------------------------------------------------------------------
+
+local lastfont = nil
+local fontcharacters = nil
+
+local magicconstants = tex.magicconstants
+local trueinch = magicconstants.trueinch
+local maxdimen = magicconstants.maxdimen
+local running = magicconstants.running
+
+local pos_h = 0
+local pos_v = 0
+local pos_r = lefttoright_code
+local shippingmode = "none"
+
+local abs_max_v = 0
+local abs_max_h = 0
+
+local shipbox_h = 0
+local shipbox_v = 0
+local page_size_h = 0
+local page_size_v = 0
+----- page_h_origin = 0 -- trueinch
+----- page_v_origin = 0 -- trueinch
+
+local initialize
+local finalize
+local updatefontstate
+local pushorientation
+local poporientation
+local flushcharacter
+local flushfontchar
+local flushrule
+local flushliteral
+local flushwhatsit
+
+-- make local
+
+function drivers.getpos () return round(pos_h), round(pos_v) end
+function drivers.getrpos() return round(pos_h), round(pos_v), pos_r end
+function drivers.gethpos() return round(pos_h) end
+function drivers.getvpos() return round(pos_v) end
+
+-- characters
+
+local flush_character do
+
+ local stack = setmetatableindex("table")
+ local level = 0
+ local nesting = 0
+ local main = 0
+
+ -- experiment (smaller page stream but might be fragile)
+
+ local tospace = false directives.register("backends.spaces", function(v) tospace = v end)
+
+ -- todo: cache streams
+
+ local default = 16384 * number.dimenfactors.bp -- 65536 // 4
+
+ local vfinjectors = fonts.helpers.vfinjectors
+
+ local function flush_vf_packet(current,pos_h,pos_v,pos_r,font,char,data,factor,vfcommands,sx,sy)
+
+ if nesting > 100 then
+ return
+ elseif nesting == 0 then
+ main = font
+ end
+
+ nesting = nesting + 1
+
+ local saved_h = pos_h
+ local saved_v = pos_v
+ local saved_r = pos_r
+ pos_r = lefttoright_code
+
+ local data = fontdata[font]
+ local fnt = font
+ local fonts = data.fonts
+ local siz = (data.parameters.factor or 1)/65536
+
+ local function flushchar(font,char,fnt,chr,f,e)
+ if fnt then
+ local nest = char ~= chr or font ~= fnt
+ if fnt == 0 then
+ fnt = main
+ end
+ return flush_character(current,fnt,chr,factor,nest,pos_h,pos_v,pos_r,f,e)
+ else
+ return 0
+ end
+ end
+
+ -- we assume resolved fonts: id mandate but maybe also size
+
+ -- we could map left, right, up, down -> offset
+ -- we could map char, font, slot to -> slot
+
+ for i=1,#vfcommands do
+ local packet = vfcommands[i]
+ local command = packet[1]
+ if command == "char" then
+ local chr = packet[2]
+ local f = packet[3]
+ local e = packet[4]
+ pos_h = pos_h + flushchar(font,char,fnt,chr,f,e)
+ elseif command == "slot" then
+ local index = packet[2]
+ local chr = packet[3]
+ local f = packet[4]
+ local e = packet[5]
+ if index == 0 then
+ pos_h = pos_h + flushchar(font,char,font,chr,f,e)
+ else
+ local okay = fonts and fonts[index]
+ if okay then
+ local fnt = okay.id
+ if fnt then
+ pos_h = pos_h + flushchar(font,char,fnt,chr,f,e)
+ end
+ else
+ -- safeguard, we assume the font itself (often index 1)
+ pos_h = pos_h + flushchar(font,char,font,chr,f,e)
+ end
+ end
+ elseif command == "use" then
+ local index = packet[2]
+ if index then
+ local fnt
+ if index == 0 then
+ fnt = font
+ else
+ local okay = fonts and fonts[index]
+ if okay then
+ fnt = okay.id
+ end
+ end
+ if fnt then
+ -- not efficient but ok for now as experiment
+ local d = characters[fnt]
+ if d then
+ for i=3,#packet do
+ local chr = packet[i]
+ local dat = d[chr]
+ if dat then
+ flushfontchar(fnt,chr,dat)
+ end
+ end
+ end
+ end
+ end
+ elseif command == "right" then
+ local h = packet[2] -- already scaled
+ if h ~= 0 then
+ if factor ~= 0 then
+ h = h + h * factor / 1000 -- expansion
+ end
+ pos_h = pos_h + h * sx
+ end
+ elseif command == "left" then
+ local h = packet[2] -- already scaled
+ if h ~= 0 then
+ if factor ~= 0 then
+ h = h + h * factor / 1000 -- expansion
+ end
+ pos_h = pos_h - h * sx
+ end
+ elseif command == "down" then
+ local v = packet[2] -- already scaled
+ if v and v ~= 0 then
+ pos_v = pos_v - v * sy
+ end
+ elseif command == "up" then
+ local v = packet[2] -- already scaled
+ if v and v ~= 0 then
+ pos_v = pos_v + v * sy
+ end
+ elseif command == "offset" then
+ local ph = pos_h
+ local pv = pos_v
+ local h = packet[2] or 0
+ local v = packet[3] or 0
+ local c = packet[4]
+ if h ~= 0 then
+ if factor ~= 0 then
+ h = h + h * factor / 1000 -- expansion
+ end
+ pos_h = pos_h + h * sx
+ end
+ if v and v ~= 0 then
+ pos_v = pos_v + v * sy
+ end
+ if c then
+ flushchar(font,char,fnt,c)
+ pos_h = ph
+ pos_v = pv
+ end
+ elseif command == "compose" then
+ local ph = pos_h
+ local pv = pos_v
+ local h = packet[2] or 0
+ local v = packet[3] or 0
+ local c = packet[4]
+ if h ~= 0 then
+ if factor ~= 0 then
+ h = h + h * factor / 1000 -- expansion
+ end
+ pos_h = pos_h + h * sx
+ end
+ if v and v ~= 0 then
+ pos_v = pos_v + v * sy
+ end
+ if c then
+ flushchar(font,char,fnt,c)
+ pos_h = ph
+ pos_v = pv
+ end
+ elseif command == "push" then
+ level = level + 1
+ local s = stack[level]
+ s[1] = pos_h
+ s[2] = pos_v
+ elseif command == "pop" then
+ if level > 0 then
+ local s = stack[level]
+ pos_h = s[1]
+ pos_v = s[2]
+ level = level - 1
+ end
+ elseif command == "rule" then
+ local size_v = packet[2]
+ local size_h = packet[3]
+ if size_h > 0 and size_v > 0 then
+ if factor ~= 0 then
+ size_h = size_h + size_h * factor / 1000
+ end
+ if size_h > 0 then
+ size_h = size_h * sx
+ size_v = size_v * sy
+ flushsimplerule(pos_h,pos_v,pos_r,size_h,size_v)
+ pos_h = pos_h + size_h
+ end
+ end
+ elseif command == "frame" then
+ -- d:width d:height d:depth d:rulethickness b:outline b:advance b:baseline s:color
+ local width = packet[2]
+ if width > 0 then
+ local height = packet[3] or 0
+ local depth = packet[4] or 0
+ local total = height + depth
+ if total > 0 then
+ if factor ~= 0 then
+ width = width + width * factor / 1000
+ end
+ if width > 0 then
+ local line = packet[5] or default
+ local outline = not packet[6]
+ local advance = not packet[7]
+ local baseline = outline and packet[8]
+ local color = packet[9] -- no longer needed probably
+ if color then
+ vfinjectors.startcolor(pos_h,pos_v,color) -- takes packet or string
+ end
+ width = width * sx
+ height = height * sy
+ depth = depth * sy
+ flushspecialrule(pos_h,pos_v,pos_r,width,height,depth,line,outline,baseline)
+ if color then
+ vfinjectors.stopcolor()
+ end
+ if advance then
+ pos_h = pos_h + width
+ end
+ end
+ end
+ end
+ elseif command == "font" then
+ local index = packet[2]
+ local okay = fonts and fonts[index]
+ if okay then
+ fnt = okay.id or fnt -- or maybe just return
+ end
+ elseif command == "lua" then
+ local code = packet[2]
+ local kind = type(code)
+ if kind ~= "function" then
+ code = loadstring(code)
+ kind = type(code)
+ end
+ if kind == "function" then
+ code(font,char,pos_h,pos_v,sx,sy)
+ end
+ elseif command == "node" then -- obsolete
+ local h = packet[2]
+ hlist_out(h,getlist(h))
+ else
+ local injector = vfinjectors[command]
+ if injector then
+ injector(pos_h,pos_v,packet)
+ end
+ end
+ -- image : not needed, maybe some day
+ -- pdfmode : not used
+ -- special : makes no sense
+ -- nop : the official ignore
+ -- scale : not supported
+ end
+
+ pos_h = saved_h
+ pos_v = saved_v
+ pos_r = saved_r
+
+ nesting = nesting - 1
+ end
+
+ local onetimemessage -- could be defined later (todo: make plug for this)
+
+ local getxyscales = nuts.getxyscales
+
+ flush_character = function(current,font,char,factor,vfcommands,pos_h,pos_v,pos_r,f,e)
+
+ if font ~= lastfont then
+ lastfont = font
+ fontcharacters = characters[font]
+ updatefontstate(font)
+ end
+
+ local data = fontcharacters[char]
+ if not data then
+ if char > 0 then
+ if not onetimemessage then
+ onetimemessage = fonts.loggers.onetimemessage
+ end
+ onetimemessage(font,char,"missing")
+ end
+ return 0, 0, 0
+ end
+ if vfcommands then
+ vfcommands = data.commands
+ end
+ local width, height, depth, naturalwidth, sx, sy
+ if current then
+ naturalwidth, height, depth, factor = getwhd(current,true) -- also get corrected width
+ sx, sy = getxyscales(current) -- maybe: getwhdfs
+ if factor == 0 then
+ width = naturalwidth
+ else
+ -- width = (1.0 + factor/1000000.0) * naturalwidth
+ width = naturalwidth + naturalwidth * factor/1000000.0
+ -- width = naturalwidth + naturalwidth * 0.000001 * factor
+ end
+ else
+ width = data.width or 0
+ height = data.height or 0
+ depth = data.depth or 0
+ naturalwidth = width
+ if not factor then
+ factor = 0
+ end
+ sx = 1
+ sy = 1
+ end
+ if pos_r == righttoleft_code then
+ pos_h = pos_h - width -- here ?
+ end
+ if vfcommands then
+ flush_vf_packet(current,pos_h,pos_v,pos_r,font,char,data,factor,vfcommands,sx,sy) -- also f ?
+ else
+ -- kind of messy that we do orientation here and offsets elsewhere .. this might change
+ local orientation = data.orientation
+ if orientation and (orientation == 1 or orientation == 3) then
+ local x = data.xoffset
+ local y = data.yoffset
+ if x then
+ pos_h = pos_h + x
+ end
+ if y then
+ pos_v = pos_v + y
+ end
+ pushorientation(orientation,pos_h,pos_v)
+ flushcharacter(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width)
+ poporientation(orientation,pos_h,pos_v)
+ else
+ flushcharacter(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width)
+ end
+ end
+ return width, height, depth
+ end
+
+end
+
+-- end of characters
+
+local function reset_state()
+ pos_h = 0
+ pos_v = 0
+ pos_r = lefttoright_code
+ shipbox_h = 0
+ shipbox_v = 0
+ shippingmode = "none"
+ page_size_h = 0
+ page_size_v = 0
+ -- page_h_origin = 0 -- trueinch
+ -- page_v_origin = 0 -- trueinch
+end
+
+-- local function dirstackentry(t,k)
+-- local v = {
+-- cur_h = 0,
+-- cur_v = 0,
+-- ref_h = 0,
+-- ref_v = 0,
+-- }
+-- t[k] = v
+-- return v
+-- end
+--
+-- local dirstack = setmetatableindex(dirstackentry)
+--
+-- local function reset_dir_stack()
+-- dirstack = setmetatableindex(dirstackentry)
+-- end
+
+local dirstack = { }
+
+local function reset_dir_stack()
+ dirstack = { }
+end
+
+local hlist_out, vlist_out do
+
+ local function applyanchor(orientation,x,y,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
+ local ot = extract(orientation, 0,4)
+ local ay = extract(orientation, 4,4)
+ local ax = extract(orientation, 8,4)
+ local of = extract(orientation,12,4)
+ if ot == 4 then
+ ot, ay = 0, 1
+ elseif ot == 5 then
+ ot, ay = 0, 2
+ end
+ if ot == 0 or ot == 2 then
+ if ax == 1 then x = x - width
+ elseif ax == 2 then x = x + width
+ elseif ax == 3 then x = x - width/2
+ elseif ax == 4 then x = x + width/2
+ end
+ if ot == 2 then
+ doffset, hoffset = hoffset, doffset
+ end
+ if ay == 1 then y = y - doffset
+ elseif ay == 2 then y = y + hoffset
+ elseif ay == 3 then y = y + (doffset + hoffset)/2 - doffset
+ end
+ elseif ot == 1 or ot == 3 then
+ if ay == 1 then y = y - height
+ elseif ay == 2 then y = y + height
+ elseif ay == 3 then y = y - height/2
+ end
+ if ot == 1 then
+ doffset, hoffset = hoffset, doffset
+ end
+ if ax == 1 then x = x - width
+ elseif ax == 2 then x = x + width
+ elseif ax == 3 then x = x - width/2
+ elseif ax == 4 then x = x + width/2
+ elseif ax == 5 then x = x - hoffset
+ elseif ax == 6 then x = x + doffset
+ end
+ end
+ return ot, x + xoffset, y - yoffset
+ end
+
+ -- to be checked: begin- or enddir kan nil zijn, weird
+
+ -- local function calculate_width_to_enddir(this_box,begindir) -- can be a helper
+ -- local dir_nest = 1
+ -- local enddir = begindir
+ -- for current, subtype in nextdir, getnext(begindir) do
+ -- if subtype == normaldir_code then -- todo
+ -- dir_nest = dir_nest + 1
+ -- else
+ -- dir_nest = dir_nest - 1
+ -- end
+ -- if dir_nest == 0 then -- does the type matter
+ -- enddir = current
+ -- local width = rangedimensions(this_box,begindir,enddir)
+ -- return enddir, width
+ -- end
+ -- end
+ -- if enddir == begindir then
+ -- local width = rangedimensions(this_box,begindir) -- ,enddir)
+ -- return enddir, width
+ -- end
+ -- return enddir, 0
+ -- end
+
+ -- check frequencies of nodes
+
+ hlist_out = function(this_box,current)
+ local ref_h = pos_h
+ local ref_v = pos_v
+ local ref_r = pos_r
+ pos_r = getdirection(this_box)
+ local boxwidth,
+ boxheight,
+ boxdepth = getwhd(this_box)
+
+ local cur_h = 0
+ local cur_v = 0
+
+ -- if not current then
+ -- current = getlist(this_box)
+ -- end
+
+ -- we can encounter par, boundary and penalty nodes but a special
+ -- iterator over content nodes won't save much
+ for current, id, subtype in nextnode, current do
+ if id == glyph_code then
+ local char, font = isglyph(current)
+ local x_offset, y_offset, left, right, raise = getoffsets(current)
+ if x_offset ~= 0 or y_offset ~= 0 then
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + x_offset)
+ else
+ pos_h = ref_h + (cur_h + x_offset)
+ end
+ pos_v = ref_v - (cur_v - y_offset)
+ -- synced
+ end
+ pos_v = pos_v + raise
+ pos_h = pos_h - left
+ local wd = flush_character(current,font,char,false,true,pos_h,pos_v,pos_r)
+ cur_h = cur_h + wd - right
+ elseif id == glue_code then
+ local gluewidth = effectiveglue(current,this_box)
+ if gluewidth ~= 0 then
+ if subtype >= leaders_code then
+ local leader = getleader(current)
+ if leader then
+ local width, height, depth = getwhd(leader)
+ if getid(leader) == rule_code then
+ if gluewidth > 0 then
+ if height == running then
+ height = boxheight
+ end
+ if depth == running then
+ depth = boxdepth
+ end
+ local total = height + depth
+ if total > 0 then
+ if pos_r == righttoleft_code then
+ pos_h = pos_h - gluewidth
+ end
+ pos_v = pos_v - depth
+ flushrule(leader,pos_h,pos_v,pos_r,gluewidth,total,getsubtype(leader))
+ end
+ cur_h = cur_h + gluewidth
+ end
+ elseif width > 0 and gluewidth > 0 then
+ local boxdir = getdirection(leader) or lefttoright_code
+ gluewidth = gluewidth + 10
+ local edge = cur_h + gluewidth
+ local lx = 0
+ if subtype == gleaders_code then
+ local save_h = cur_h
+ if pos_r == righttoleft_code then
+ cur_h = ref_h - shipbox_h - cur_h
+ cur_h = width * (cur_h / width)
+ cur_h = ref_h - shipbox_h - cur_h
+ else
+ cur_h = cur_h + ref_h - shipbox_h
+ cur_h = width * (cur_h / width)
+ cur_h = cur_h - ref_h - shipbox_h
+ end
+ if cur_h < save_h then
+ cur_h = cur_h + width
+ end
+ elseif subtype == leaders_code then
+ local save_h = cur_h
+ cur_h = width * (cur_h / width)
+ if cur_h < save_h then
+ cur_h = cur_h + width
+ end
+ else
+ lq = gluewidth / width
+ lr = gluewidth % width
+ if subtype == cleaders_code then
+ cur_h = cur_h + lr / 2
+ else
+ lx = lr / (lq + 1)
+ cur_h = cur_h + (lr - (lq - 1) * lx) / 2
+ end
+ end
+ local shift = getshift(leader)
+ pushleaderlevel()
+ while cur_h + width <= edge do
+ local basepoint_h = 0
+ -- local basepoint_v = shift
+ if boxdir ~= pos_r then
+ basepoint_h = boxwidth
+ end
+ -- synch_pos_with_cur(ref_h,ref_v,cur_h + basepoint_h,shift)
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h)
+ end
+ pos_v = ref_v - shift
+ -- synced
+ if getid(leader) == vlist_code then
+ vlist_out(leader,getlist(leader))
+ else
+ hlist_out(leader,getlist(leader))
+ end
+ cur_h = cur_h + width + lx
+ end
+ popleaderlevel()
+ cur_h = edge - 10
+ else
+ cur_h = cur_h + gluewidth
+ end
+ else
+ cur_h = cur_h + gluewidth
+ end
+ else
+ if tospace and subtype == spaceskip_code then
+ -- todo: flush_space
+ flush_character(false,getfont(current),32,false,true,pos_h,pos_v,pos_r) -- we need tp pass current for scale?
+ end
+ cur_h = cur_h + gluewidth
+ end
+ end
+ elseif id == hlist_code or id == vlist_code then
+ local width, height, depth = getwhd(current)
+ local list = getlist(current)
+ if list then
+ local boxdir = getdirection(current) or lefttoright_code
+ local shift, orientation = getshift(current)
+ if not orientation then
+ local basepoint_h = boxdir ~= pos_r and width or 0
+ -- local basepoint_v = shift
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h)
+ end
+ pos_v = ref_v - shift
+ -- synced
+ if id == vlist_code then
+ vlist_out(current,list)
+ else
+ hlist_out(current,list)
+ end
+ elseif orientation == 0x1000 then
+ local orientation, xoffset, yoffset = getorientation(current)
+ local basepoint_h = boxdir ~= pos_r and width or 0
+ -- local basepoint_v = shift
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h + xoffset)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h + xoffset)
+ end
+ pos_v = ref_v - (shift - yoffset)
+ -- synced
+ if id == vlist_code then
+ vlist_out(current,list)
+ else
+ hlist_out(current,list)
+ end
+ else
+ local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
+ local orientation, basepoint_h, basepoint_v = applyanchor(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
+ if orientation == 1 then
+ basepoint_h = basepoint_h + doffset
+ if boxdir == pos_r then
+ basepoint_v = basepoint_v - height
+ end
+ elseif orientation == 2 then
+ if boxdir == pos_r then
+ basepoint_h = basepoint_h + width
+ end
+ elseif orientation == 3 then
+ basepoint_h = basepoint_h + hoffset
+ if boxdir ~= pos_r then
+ basepoint_v = basepoint_v - height
+ end
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h)
+ end
+ pos_v = ref_v - (cur_v + basepoint_v)
+ -- synced
+ pushorientation(orientation,pos_h,pos_v,pos_r)
+ if id == vlist_code then
+ vlist_out(current,list)
+ else
+ hlist_out(current,list)
+ end
+ poporientation(orientation,pos_h,pos_v,pos_r)
+ end
+ end
+ cur_h = cur_h + width
+ elseif id == kern_code then
+ -- we can use getkerndimension(current) but then we get rounded values so for
+ -- now we calculate ourselves
+ local kern, factor = getkern(current,true)
+ if kern ~= 0 then
+ if factor ~= 0 then
+ cur_h = cur_h + (1.0 + factor/1000000.0) * kern
+ else
+ cur_h = cur_h + kern
+ end
+ end
+ elseif id == rule_code then
+ local width, height, depth = getwhd(current)
+ if width > 0 then
+ if height == running then
+ height = boxheight
+ end
+ if depth == running then
+ depth = boxdepth
+ end
+ local total = height + depth
+ if total > 0 then
+ local xoffset, yoffset, left, right = getoffsets(current) -- top bottom
+ if left ~= 0 then
+ pos_v = pos_v + left
+ total = total - left
+ end
+ if right ~= 0 then
+ depth = depth - right
+ total = total - right
+ end
+ if pos_r == righttoleft_code then
+ pos_h = pos_h - width
+ xoffset = - xoffset
+ end
+ pos_v = pos_v - depth
+ flushrule(current,pos_h + xoffset,pos_v + yoffset,pos_r,width,total,subtype)
+ end
+ end
+ cur_h = cur_h + width
+ elseif id == math_code then
+ -- local kern = getkern(current)
+ -- if kern ~= 0 then
+ -- cur_h = cur_h + kern
+ -- else
+ cur_h = cur_h + effectiveglue(current,this_box)
+ -- end
+ elseif id == dir_code then
+ -- We normally have proper begin-end pairs. A begin without end is (silently) handled
+ -- and an end without a begin will be (silently) skipped we only need to move forward
+ -- so we then have a faster calculation.
+ local dir, cancel = getdirection(current)
+ if cancel then
+ local ds = dirstack[current]
+ if ds then
+ ref_h = ds.ref_h
+ ref_v = ds.ref_v
+ cur_h = ds.cur_h
+ cur_v = ds.cur_v
+ else
+ -- pardir
+ end
+ pos_r = dir
+ else
+ local width, enddir = dirdimensions(this_box,current)
+ local new_h = cur_h + width
+ if dir ~= pos_r then
+ cur_h = new_h
+ end
+ if enddir ~= current then
+ dirstack[enddir] = {
+ cur_h = new_h,
+ cur_v = cur_v,
+ ref_h = ref_h,
+ ref_v = ref_v,
+ }
+ setdirection(enddir,pos_r)
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - cur_h
+ else
+ pos_h = ref_h + cur_h
+ end
+ pos_v = ref_v - cur_v
+ -- synced
+ ref_h = pos_h
+ ref_v = pos_v
+ cur_h = 0
+ cur_v = 0
+ pos_r = dir
+ goto synced
+ end
+ elseif id == whatsit_code then
+ flushwhatsit[subtype](current,pos_h,pos_v)
+ elseif id == disc_code then
+ local replace, tail = getreplace(current)
+ -- actually, we no longer have these select discs in the packaged list ... it's about
+ -- time to clean up the disc code a bit further
+ if replace then -- and subtype ~= select_disc_code then
+ setlink(tail,getnext(current))
+ setlink(current,replace)
+ setreplace(current)
+ end
+ -- elseif id == par_code and start_of_par(current) then
+ -- local pardir = getdirection(current) or lefttoright_code
+ -- if pardir == righttoleft_code then
+ -- end
+ -- end
+ else
+ -- penalty, boundary ... no dimensions
+ goto synced
+ end
+ -- There is no gain in skipping over this when we have zero progression
+ -- and such.
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - cur_h
+ else
+ pos_h = ref_h + cur_h
+ end
+ pos_v = ref_v - cur_v
+ ::synced::
+ end
+ pos_h = ref_h
+ pos_v = ref_v
+ pos_r = ref_r
+ end
+
+ vlist_out = function(this_box,current)
+ local ref_h = pos_h
+ local ref_v = pos_v
+ local ref_r = pos_r
+ pos_r = getdirection(this_box)
+
+ local boxwidth,
+ boxheight,
+ boxdepth = getwhd(this_box)
+
+ local cur_h = 0
+ local cur_v = - boxheight
+ local top_edge = cur_v
+
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - cur_h
+ else
+ pos_h = ref_h + cur_h
+ end
+ pos_v = ref_v - cur_v
+ -- synced
+
+ -- if not current then
+ -- current = getlist(this_box)
+ -- end
+
+ -- while current do
+ -- local id = getid(current)
+ for current, id, subtype in nextnode, current do
+ if id == glue_code then
+ local glueheight = effectiveglue(current,this_box)
+ if glueheight ~= 0 then
+ if subtype >= leaders_code then
+ local leader = getleader(current)
+ if leader then
+ local width, height, depth = getwhd(leader)
+ local total = height + depth
+ if getid(leader) == rule_code then
+ depth = 0 -- hm
+ total = glueheight -- forgotten ... needs testing
+ if total > 0 then
+ if width == running then
+ width = boxwidth
+ end
+ if width > 0 then
+ if pos_r == righttoleft_code then
+ cur_h = cur_h - width
+ end
+ flushrule(leader,pos_h,pos_v - total,pos_r,width,total,getsubtype(leader))
+ end
+ cur_v = cur_v + total
+ end
+ elseif total > 0 and glueheight > 0 then
+ glueheight = glueheight + 10
+ local edge = cur_v + glueheight
+ local ly = 0
+ if subtype == gleaders_code then
+ save_v = cur_v
+ cur_v = ref_v - shipbox_v - cur_v
+ cur_v = total * (cur_v / total)
+ cur_v = ref_v - shipbox_v - cur_v
+ if cur_v < save_v then
+ cur_v = cur_v + total
+ end
+ elseif subtype == leaders_code then -- aleader
+ save_v = cur_v
+ cur_v = top_edge + total * ((cur_v - top_edge) / total)
+ if cur_v < save_v then
+ cur_v = cur_v + total
+ end
+ else
+ lq = glueheight / total
+ lr = glueheight % total
+ if subtype == cleaders_code then
+ cur_v = cur_v + lr / 2
+ else
+ ly = lr / (lq + 1)
+ cur_v = cur_v + (lr - (lq - 1) * ly) / 2
+ end
+ end
+ local shift = getshift(leader)
+ pushleaderlevel()
+ while cur_v + total <= edge do -- todo: <= edge - total
+ -- synch_pos_with_cur(ref_h, ref_v, getshift(leader), cur_v + height)
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - shift
+ else
+ pos_h = ref_h + shift
+ end
+ pos_v = ref_v - (cur_v + height)
+ -- synced
+ if getid(leader) == vlist_code then
+ vlist_out(leader,getlist(leader))
+ else
+ hlist_out(leader,getlist(leader))
+ end
+ cur_v = cur_v + total + ly
+ end
+ popleaderlevel()
+ cur_v = edge - 10
+ else
+ cur_v = cur_v + glueheight
+ end
+ end
+ else
+ cur_v = cur_v + glueheight
+ end
+ end
+ elseif id == hlist_code or id == vlist_code then
+ local width, height, depth = getwhd(current)
+ local list = getlist(current)
+ if list then
+ local boxdir = getdirection(current) or lefttoright_code
+ local shift, orientation = getshift(current)
+ if not orientation then
+ -- local basepoint_h = shift
+ -- local basepoint_v = height
+ if boxdir ~= pos_r then
+ shift = shift + width
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - shift
+ else
+ pos_h = ref_h + shift
+ end
+ pos_v = ref_v - (cur_v + height)
+ -- synced
+ if id == vlist_code then
+ vlist_out(current,list)
+ else
+ hlist_out(current,list)
+ end
+ elseif orientation == 0x1000 then
+ local orientation, xoffset, yoffset = getorientation(current)
+ -- local basepoint_h = shift
+ -- local basepoint_v = height
+ if boxdir ~= pos_r then
+ shift = shift + width
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (shift + xoffset)
+ else
+ pos_h = ref_h + (shift + xoffset)
+ end
+ pos_v = ref_v - (cur_v + height - yoffset)
+ -- synced
+ if id == vlist_code then
+ vlist_out(current,list)
+ else
+ hlist_out(current,list)
+ end
+ else
+ local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
+ local orientation, basepoint_h, basepoint_v = applyanchor(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
+ if orientation == 1 then
+ basepoint_h = basepoint_h + width - height
+ basepoint_v = basepoint_v - height
+ elseif orientation == 2 then
+ basepoint_h = basepoint_h + width
+ basepoint_v = basepoint_v + depth - height
+ elseif orientation == 3 then -- weird
+ basepoint_h = basepoint_h + height
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - basepoint_h
+ else
+ pos_h = ref_h + basepoint_h
+ end
+ pos_v = ref_v - (cur_v + basepoint_v)
+ -- synced
+ pushorientation(orientation,pos_h,pos_v,pos_r)
+ if id == vlist_code then
+ vlist_out(current,list)
+ else
+ hlist_out(current,list)
+ end
+ poporientation(orientation,pos_h,pos_v,pos_r)
+ end
+ end
+ cur_v = cur_v + height + depth
+ elseif id == kern_code then
+ cur_v = cur_v + getkern(current)
+ elseif id == rule_code then
+ local width, height, depth = getwhd(current)
+ local total = height + depth
+ if total > 0 then
+ if width == running then
+ width = boxwidth
+ end
+ if width > 0 then
+ local xoffset, yoffset, left, right = getoffsets(current)
+ if left ~= 0 then
+ width = width - left
+ xoffset = left
+ end
+ if right ~= 0 then
+ width = width - right
+ end
+ if pos_r == righttoleft_code then
+ xoffset = - xoffset - width
+ end
+ flushrule(current,pos_h + xoffset,pos_v - total - yoffset,pos_r,width,total,subtype)
+ end
+ end
+ cur_v = cur_v + total
+ elseif id == whatsit_code then
+ flushwhatsit[subtype](current,pos_h,pos_v)
+ else
+ -- penalty
+ goto synced
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - cur_h
+ else
+ pos_h = ref_h + cur_h
+ end
+ pos_v = ref_v - cur_v
+ ::synced::
+ end
+ pos_h = ref_h
+ pos_v = ref_v
+ pos_r = ref_r
+ end
+
+end
+
+function drivers.converters.lmtx(driver,box,smode,objnum,specification)
+
+ if not driver then
+ report("error in converter, no driver")
+ return
+ end
+
+ if box then
+ box = tonut(box)
+ else
+ report("error in converter, no box")
+ return
+ end
+
+ local actions = driver.actions
+ local flushers = driver.flushers
+
+ initialize = actions.initialize
+ finalize = actions.finalize
+
+ updatefontstate = flushers.updatefontstate
+
+ pushorientation = flushers.pushorientation
+ poporientation = flushers.poporientation
+
+ pushleaderlevel = flushers.pushleaderlevel
+ popleaderlevel = flushers.popleaderlevel
+
+ flushcharacter = flushers.character
+ flushfontchar = flushers.fontchar
+ flushrule = flushers.rule
+ flushsimplerule = flushers.simplerule
+ flushspecialrule = flushers.specialrule
+ flushliteral = flushers.literal
+ flushwhatsit = flushers.whatsit
+
+ reset_dir_stack()
+ reset_state()
+
+ shippingmode = smode
+
+ local details = nil -- must be outside labels
+
+ local width, height, depth = getwhd(box)
+
+ local total = height + depth
+
+ ----- v_offset_par = 0
+ ----- h_offset_par = 0
+
+ local max_v = total -- + v_offset_par
+ local max_h = width -- + h_offset_par
+
+ if height > maxdimen or depth > maxdimen or width > maxdimen then
+ goto DONE
+ end
+
+ if max_v > maxdimen then
+ goto DONE
+ elseif max_v > abs_max_v then
+ abs_max_v = max_v
+ end
+
+ if max_h > maxdimen then
+ goto DONE
+ elseif max_h > abs_max_h then
+ abs_max_h = max_h
+ end
+
+ if shippingmode == "page" then
+
+ -- We have zero offsets in ConTeXt.
+
+ local pagewidth, pageheight = getpagedimensions()
+
+ pos_r = lefttoright_code
+
+ if pagewidth > 0 then
+ page_size_h = pagewidth
+ else
+ page_size_h = width
+ end
+
+ if page_size_h == 0 then
+ page_size_h = width
+ end
+
+ if pageheight > 0 then
+ page_size_v = pageheight
+ else
+ page_size_v = total
+ end
+
+ if page_size_v == 0 then
+ page_size_v = total
+ end
+
+ local refpoint_h = 0
+ local refpoint_v = page_size_v
+
+ pos_h = refpoint_h
+ pos_v = refpoint_v - height
+
+ else
+
+ page_size_h = width
+ page_size_v = total
+ pos_r = getdirection(box)
+ pos_v = depth
+ pos_h = pos_r == righttoleft_code and width or 0
+
+ end
+
+ shipbox_ref_h = pos_h
+ shipbox_ref_v = pos_v
+
+ details = {
+ shippingmode = smode, -- target
+ boundingbox = { 0, 0, page_size_h, page_size_v },
+ objectnumber = smode ~= "page" and objnum or nil,
+ pagenumber = smode == "page" and objnum or nil,
+ specification = specification,
+ }
+
+ initialize(driver,details)
+
+ lastfont = nil -- this forces a sync each page / object
+
+ if getid(box) == vlist_code then
+ vlist_out(box,getlist(box))
+ else
+ hlist_out(box,getlist(box))
+ end
+
+ ::DONE::
+
+ finalize(driver,details)
+
+ shippingmode = "none"
+end
+
+-- This will move to back-out.lua eventually.
+
+do
+
+ ----- sortedhash = table.sortedhash
+
+ ----- tonut = nodes.tonut
+ local properties = nodes.properties.data
+ local flush = texio.write
+ local flushline = texio.write_nl
+
+ local periods = utilities.strings.newrepeater(".")
+
+ local function showdetails(n,l)
+ local p = properties[tonut(n)]
+ if p then
+ for k, v in sortedhash(p) do
+ local t = type(v)
+ if t == "string" then
+ if find(v,"[\n\r]") then
+ v = "\n" .. stripstring(v) .. "\n"
+ end
+ elseif t == "number" or t == "boolean" then
+ v = tostring(v)
+ elseif t == "table" then
+ v = sequenced(v)
+ else
+ v = "<" .. tostring(v) .. ">"
+ end
+ flushline(periods[l+1] .. " " .. k .. " = " .. v)
+ end
+ end
+ end
+
+ local whatsittracers = {
+ latelua = showdetails,
+ literal = showdetails,
+ }
+
+ callback.register("show_whatsit",function(n,l)
+ local s = nodes.whatsitcodes[n.subtype]
+ flush(" [" .. s .. "]")
+ local w = whatsittracers[s]
+ if w then
+ w(n,l)
+ end
+ end)
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/driv-shp.mkxl b/Master/texmf-dist/tex/context/base/mkxl/driv-shp.mkxl
new file mode 100644
index 00000000000..199215a59ea
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/driv-shp.mkxl
@@ -0,0 +1,18 @@
+%D \module
+%D [ file=driv-shp,
+%D version=2018.07.26,
+%D title=\CONTEXT\ Driver Macros,
+%D subtitle=Shipout,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{driv-shp}{autosuffix,optimize}
+
+\unprotect
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/enco-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/enco-ini.mkxl
new file mode 100644
index 00000000000..c93ef7f6185
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/enco-ini.mkxl
@@ -0,0 +1,488 @@
+%D \module
+%D [ file=enco-ini,
+%D version=2007.02.19, % 2000.12.27, % 1998.12.03,
+%D title=\CONTEXT\ Encoding Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is stripped down version of the original enco-ini.tex file. For more details
+%D you might want to study the \MKII\ file but since \LUATEX\ is unicode inside we
+%D need less code. When we moved to \LMTX\ again some disappeared and the composition
+%D macros were upgraded in the process.
+%D
+%D An historic note: When dealing with characters we have four cases to take into
+%D account when moving from \MKII\ to \MKIV:
+%D
+%D \starttabulate[|l|l|]
+%D \NC \type {} \NC ref to slot 200 in current font \NC \NR
+%D \NC \type {\char 200} \NC ref to slot 200 in current font \NC \NR
+%D \NC \type {} \NC can (e.g.) map to another slot in current font \NC \NR
+%D \NC \type {\namedglyph} \NC can map to some slot in some font \NC \NR
+%D \stoptabulate
+%D
+%D Using case 2 for special characters is doomed to fail because we are not going to
+%D intercept these on the fly as happens automatically with traditional font
+%D encoding handling. We could do that in a node pass but it's not worth the effort
+%D because we seldom use this case in a document source.
+
+\writestatus{loading}{ConTeXt Encoding Macros / Initialization}
+
+\unprotect
+
+%D This one is obsolete but maybe sometimes still used in styles:
+
+\immutable\let\defaultencoding\s!default
+
+%D \macros
+%D {defineaccent, definecharacter, definecommand}
+%D
+%D Some of these are used at the \LUA\ end but the names will change.
+
+\installcorenamespace{accents}
+
+%D These might go away:
+
+\permanent\protected\def\defineaccent#1 #2 #3 %
+ {\dodefineaccentcommand{#1}%
+ \dodefineaccent{#1}{#2}{#3}}
+
+\permanent\protected\def\dodefineaccentcommand#1%
+ {\ifcsname\string#1\endcsname\else
+ \edefcsname\string#1\endcsname{\noexpand\dohandleaccent{\string#1}}%
+ \fi}
+
+\permanent\protected\def\dodefineaccent#1#2#3% no spaces, used low level
+ {\defcsname\??accents\string#1\string#2\empty\endcsname{#3}}
+
+\permanent\protected\def\dohandleaccent#1#2% expandable because we want them in the tuc file
+ {\csname\??accents
+ \ifcsname\??accents\string#1#2\empty\endcsname
+ \string#1#2\empty
+ \orelse\ifcsname\??accents\string#1\string#2\empty\endcsname
+ \string#1\string#2\empty
+ \else
+ \endcsname#2\csname\??accents % very dirty trick: ignore accent but keep char
+ \fi
+ \endcsname}
+
+\immutable\letvalue{\??accents}\empty
+
+%D Because now have this (\type {\chr} issues a one|-|time warning):
+
+\permanent\protected\def\dodefinecombine#1#2%
+ {\ifcsname\string#1\endcsname\else
+ \permanent\protected\defcsname with#1\endcsname##1{\chr{##1#2}}%
+ \fi}
+
+%D The following dirty trick is needed to catch \asciimath{\^{1/5}log}, although:
+%D do we?
+
+\permanent\protected\def\definecharacter#1 #2 %
+ {\doifelsenumber{\string#2}
+ {\edefcsname\string#1\endcsname{\Uchar#2}}
+ {\protected\defcsname\string#1\endcsname{#2}}}
+
+%D specials: \aa \ae \cc \i \ij \l \o \oe \sz \par
+%D SPECIALS: \AA \AE \CC \j \IJ \L \O \OE \SZ \par
+
+\permanent\protected\def\definecommand#1 #2 %
+ {\protected\defcsname\string#1\endcsname{#2}}
+
+\permanent\protected\def\dodefinecommand#1#2% \O \L \AE ...
+ {% not permanent as these are kind of obsolete
+ \frozen\protected\defcsname\string#1\endcsname{#2}}
+
+%D We set up some things in \LUA:
+
+\clf_defineaccents % one time
+
+%D This defined commands like \type {\withgrave} and \type {\withcaronbelow} and
+%D some of these have aliases. Below ee also alias the traditional one character
+%D accent commands.
+%D
+%D \starttabulate[||||]
+%D \NC \getvalue{agrave} \NC \withgrave {a} \NC \`{a} \NC \NR
+%D \NC \getvalue{aacute} \NC \withacute {a} \NC \'{a} \NC \NR
+%D \NC \getvalue{acircumflex} \NC \withcircumflex {a} \NC \^{a} \NC \NR
+%D \NC \getvalue{atilde} \NC \withtilde {a} \NC \~{a} \NC \NR
+%D \NC \getvalue{amacron} \NC \withmacron {a} \NC \={a} \NC \NR
+%D \NC \getvalue{ebreve} \NC \withbreve {e} \NC \u{e} \NC \NR
+%D \NC \getvalue{cdotaccent} \NC \withdot {c} \NC \.{c} \NC \NR
+%D \NC \getvalue{ediaeresis} \NC \withdieresis {e} \NC \"{e} \NC \NR
+%D \NC \getvalue{uring} \NC \withring {u} \NC \r{u} \NC \NR
+%D \NC \getvalue{uhungarumlaut} \NC \withhungarumlaut{u} \NC \H{u} \NC \NR
+%D \NC \getvalue{ecaron} \NC \withcaron {e} \NC \v{e} \NC \NR
+%D \NC \getvalue{ecedilla} \NC \withcedilla {e} \NC \c{e} \NC \NR
+%D \NC \getvalue{eogonek} \NC \withogonek {e} \NC \k{e} \NC \NR
+%D \stoptabulate
+%D
+%D Now we alias these traditional shortcuts:
+
+\pushoverloadmode
+
+\suggestedalias \` \withgrave
+\suggestedalias \' \withacute
+\suggestedalias \^ \withcircumflex
+\suggestedalias \~ \withtilde
+\suggestedalias \= \withmacron
+\suggestedalias \u \withbreve
+\suggestedalias \. \withdot
+\suggestedalias \" \withdieresis
+\suggestedalias \r \withring
+\suggestedalias \H \withdoubleacute
+\suggestedalias \v \withcaron
+\suggestedalias \c \withcedilla
+\suggestedalias \k \withogonek
+\suggestedalias \d \withdotbelow
+
+\popoverloadmode
+
+% From \type {enco-com} we had these, maybe that's better:
+
+% \aliased\let\AE\AEligature \aliased\let\ae\aeligature
+% \aliased\let\OE\OEligature \aliased\let\oe\oeligature
+% \aliased\let\IJ\IJligature \aliased\let\ij\ijligature
+% \aliased\let\AA\textAngstrom \aliased\let\aa\aring
+% \aliased\let\CC\Ccedilla \aliased\let\cc\ccedilla
+% \aliased\let\L \Lslash \aliased\let\l \lslash
+% \aliased\let\O \Oslash \aliased\let\o \oslash
+% \aliased\let\SZ\Eszett \aliased\let\sz\eszett % \aliased\let\SS\Ssharp
+
+% %D \macros
+% %D {everyuppercase, everylowercase, everysanitize}
+%
+% \newtoks \everyuppercase
+% \newtoks \everylowercase
+% \newtoks \everysanitize
+
+%D Accent handling (try to avoid this):
+
+% \buildtextaccent\greekdasia\greekalphamacron
+% \buildtextaccent\textacute q
+
+%D We can use offsets in \LMTX\ but even that makes no sense because we have
+%D a virtual feature already in \MKIV. These builders are depricated:
+
+\newbox\b_enco_accent
+
+\permanent\protected\def\buildmathaccent#1%
+ {\mathaccent#1 }
+
+\permanent\protected\def\buildtextaccent#1#2% we could do all at the lua end
+ {\dontleavehmode\begingroup % but that's no fun (yet)
+ \setbox\scratchboxone\hbox{#1}% accent
+ \setbox\scratchboxtwo\hbox{#2}% character
+ \scratchheight\dimexpr\ht\scratchboxtwo-\ht\scratchboxone\relax
+ \scratchdepth \dimexpr\dp\scratchboxtwo-\dp\scratchboxone\relax
+ \scratchwidth \wd\scratchboxtwo
+ \hbox to \wd\ifdim\wd\scratchboxone>\wd\scratchboxtwo\scratchboxone\else\scratchboxtwo\fi\bgroup
+ \hss\box\scratchboxtwo\hss
+ \hskip-\scratchwidth
+ \hss
+ \ifdim\ht\scratchboxone>\exheight
+ % top accent
+ \raise\dimexpr\scratchheight+\exheight/3\relax
+ \else
+ \lower-\dimexpr\scratchdepth+\exheight/3\relax
+ \fi
+ \box\scratchboxone
+ \hss
+ \egroup
+ \endgroup}
+
+\permanent\protected\def\bottomaccent#1#2#3#4#5% down right slantcorrection accent char
+ {\dontleavehmode % why this align mess
+ \vtop
+ {\forgetall
+ \baselineskip\zeropoint
+ \lineskip#1%
+ \everycr\emptytoks
+ \tabskip\zeropoint
+ \lineskiplimit\zeropoint
+ \setbox0\hbox{#4}%
+ \halign
+ {##\crcr\hbox{#5}\crcr
+ \hidewidth
+ \hskip#2\wd0
+ \hskip-#3\slantperpoint % in plain 1ex * dimenless value
+ \vpack to .2\exheight{\box0\vss}\hidewidth
+ \crcr}}}
+
+\permanent\protected\def\buildtextmacron {\bottomaccent{.25ex}{0}{15}{\textmacron}}
+\permanent\protected\def\buildtextbottomdot {\bottomaccent{.25ex}{0}{5}{\textbottomdot}}
+\permanent\protected\def\buildtextcedilla {\bottomaccent{0ex}{0}{5}{\textcedilla}}
+\permanent\protected\def\buildtextogonek {\bottomaccent{-.1ex}{.5}{0}{\textogonek}}
+\permanent\protected\def\buildtextbottomcomma{\bottomaccent{.15ex}{0}{5}{\tx,}}
+
+\permanent\protected\def\topaccent#1#2#3#4#5% down right slantcorrection accent char
+ {\dontleavehmode
+ \bgroup
+ \setbox0\hbox{#4}%
+ \setbox2\hbox{#5}%
+ \hbox to \wd2 \bgroup
+ \hss\copy2\hss
+ \hskip-\wd2
+ \hss\hskip#2\wd0\hskip-#3\slantperpoint\raise#1\hbox{#4}\hss
+ \egroup
+ \egroup}
+
+\permanent\protected\def\buildtextgrave
+ {\topaccent{0pt}{0}{15}{\textgrave}} % e.g.
+
+\permanent\protected\def\definemathaccent#1 #2%
+ {\setvalue{#1}{\mathaccent#2 }}
+
+% from enco-def:
+
+% \aliased\let\i\dotlessi
+% \aliased\let\j\dotlessj
+
+% \aliased\let\P\paragraphmark \aliased\let\textP\paragraphmark % obsolete (surfaced in bibliographic files)
+% \aliased\let\S\sectionmark \aliased\let\textS\sectionmark % obsolete (surfaced in bibliographic files)
+
+\immutable\def\eszett {ß} \immutable\def\Eszett {SS} \permanent\def\Ssharp{SS}
+\immutable\def\lslash {ł} \immutable\def\Lslash {Ł}
+\immutable\def\dslash {đ} \immutable\def\Dslash {Đ}
+%immutable\def\oslash {ø} %immutable\def\Oslash {Ø} % clashes with math: use \Ostroke
+\immutable\def\dcroat {đ} \immutable\def\Dcroat {Đ}
+\immutable\def\kcedilla{ķ} \immutable\def\Kcedilla{Ķ}
+\immutable\def\lcedilla{ļ} \immutable\def\Lcedilla{Ļ}
+\immutable\def\ncedilla{ņ} \immutable\def\Ncedilla{Ņ}
+\immutable\def\rcedilla{ŗ} \immutable\def\Rcedilla{Ŗ}
+\immutable\def\aumlaut {ä} \immutable\def\Aumlaut {Ä}
+\immutable\def\eumlaut {ë} \immutable\def\Eumlaut {Ë}
+\immutable\def\iumlaut {ï} \immutable\def\Iumlaut {Ï}
+\immutable\def\oumlaut {ö} \immutable\def\Oumlaut {Ö}
+\immutable\def\uumlaut {ü} \immutable\def\Uumlaut {Ü}
+
+%D For old times sake we keep these (obsolete):
+
+\immutable\def\textflorin{ƒ} \immutable\def\florin {ƒ}
+\immutable\def\pound {£} \immutable\def\sterling{£}
+\immutable\def\promille {‰} \immutable\def\permille{‰}
+
+%D These are kind of \TEX\ specific
+
+\pushoverloadmode
+
+\permanent\protected\def\ampersand{\mathortext\mathampersand\textampersand}
+
+\immutable\let\percent\textpercent
+\immutable\let\procent\textpercent
+\immutable\let\dollar \textdollar
+\immutable\let\hash \texthash
+
+\popoverloadmode
+
+%D some more: what with freezing here?
+
+\ifdefined\softhyphen \else
+ \aliased\let\softhyphen\explicitdiscretionary
+\fi
+
+%D The softhyhen is never used but we keep the definition below:
+
+\aliased\let\hyphen \softhyphen % never used
+
+% But we ditch these:
+
+% \def\hyphen {\softhyphen} % never used
+% \def\compoundwordmark {\hyphen}
+% \def\cwm {\hyphen}
+% \def\nonbreakinghyphen{\hyphen}
+% \def\breakinghyphen {\hyphen\prewordbreak}
+
+%D Quotes \unknown\ we keep these funny names because they indicate where we come
+%D from \unknown\ long long ago when we had no real useful names for them. Some
+%D ancient styles might still use them.
+
+\aliased\let\lowerleftsingleninequote \quotesinglebase % ‚
+\aliased\let\lowerleftdoubleninequote \quotedblbase % „
+\aliased\let\lowerrightsingleninequote\quotesinglebase % ‚
+\aliased\let\lowerrightdoubleninequote\quotedblbase % „
+
+\aliased\let\upperleftsingleninequote \quoteright % ’
+\aliased\let\upperleftdoubleninequote \quotedblright % ”
+\aliased\let\upperrightsingleninequote\quoteright % ’
+\aliased\let\upperrightdoubleninequote\quotedblright % ”
+
+\aliased\let\upperleftsinglesixquote \quoteleft % ‘
+\aliased\let\upperleftdoublesixquote \quotedblleft % “
+\aliased\let\upperrightsinglesixquote \quoteleft % ‘
+\aliased\let\upperrightdoublesixquote \quotedblleft % “
+
+\aliased\let\leftsubguillemot \guilsingleleft % ‹
+\aliased\let\rightsubguillemot \guilsingleright % ›
+
+% Some left-overs that will go away!
+
+\permanent\protected\def\textblacksquare{\dontleavehmode\hpack{\vrule\s!width.3\s!em\s!height.4\s!em\s!depth-.1\s!em}}
+%permanent\protected\def\schwa {\hbox{\rotate[\c!rotation=180,\c!location=\v!high]{\hbox{e}}}}
+\permanent\protected\def\schwagrave {\buildtextgrave\schwa}
+
+\installcorenamespace{controlspace}
+
+\permanent\protected\def\fallbackcontrolspace % beware, current font, we also need to honor color
+ {\hbox to \interwordspace \bgroup
+ \hss
+ \ifcsname\??controlspace\number\interwordspace\endcsname
+ \csname\??controlspace\number\interwordspace\endcsname
+ \else
+ \enco_fast_control_space_define % only regular
+ \fi
+ \textcontrolspace
+ \hss
+ \egroup}
+
+\protected\def\enco_fast_control_space_define
+ {\scratchdimen\interwordspace
+ \definedfont[LMTypewriter-Regular at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody]% see font-sym.mkiv
+ \gletcsname\??controlspace\number\scratchdimen\endcsname\lastrawfontcall}
+
+\permanent\protected\def\normalcontrolspace
+ {\iffontchar\font\numexpr\expandafter`\textcontrolspace\relax
+ \textcontrolspace
+ \else
+ \fallbackcontrolspace
+ \fi}
+
+\aliased\let\textvisiblespace\normalcontrolspace
+
+\permanent\protected\def\optionalcontrolspace
+ {\iffontchar\font\numexpr\expandafter`\textcontrolspace\relax
+ \textcontrolspace
+ \else
+ \asciispacechar % used for export !
+ \fi}
+
+%D A smaller and bolder variant, more like the math and monospaced ones.
+
+\permanent\protected\def\fakeunderscore
+ {\relax\ifmmode
+ \vrule\s!depth .12\fontexheight\mathstylefont\normalmathstyle\s!width \fontinterwordspace\mathstylefont\normalmathstyle\s!height\zeropoint\relax
+ \else
+ \dontleavehmode\hbox{\vrule\s!depth .12\fontexheight\font\s!width \fontinterwordspace\font\s!height\zeropoint}%
+ \fi}
+
+\permanent\protected\def\fakeunderscores{\enforced\let\_\fakeunderscore}
+\permanent\protected\def\textunderscores{\enforced\let\_\textunderscore}
+
+\textunderscores
+
+\ifdefined\mathunderscore \else \aliased\let\mathunderscore\fakeunderscore \fi
+\ifdefined\textunderscore \else \aliased\let\textunderscore\fakeunderscore \fi
+
+\permanent\protected\def\normalunderscore{\ifmmode\mathunderscore\else\textunderscore\fi}
+
+\pushoverloadmode
+ \enforced\let\_\normalunderscore
+\popoverloadmode
+
+%D To be sorted out:
+
+\pushoverloadmode
+
+\permanent\protected\def\textminus
+ {\char
+ \iffontchar\font"2012 "2012 \orelse % figuredash
+ \iffontchar\font"2013 "2013 \orelse % endash
+ \iffontchar\font"2212 "2212 \else % math minus
+ "002D \fi} % hyphen
+
+\permanent\protected\def\textplus
+ {\char"002B } % plus
+
+\popoverloadmode
+
+%D Moved from core-mis:
+
+% \permanent\protected\def\celsius #1{#1\mathematics{^\circ}C}
+% \permanent\protected\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax}
+% \permanent\protected\def\fraction#1#2{\mathematics{#1\over#2}}
+
+\permanent\protected\def\celsius #1{#1\iffontchar\font`℃℃\else\mathematics{^\circ}C\fi} % 0x2103
+\permanent\protected\def\inch {\iffontchar\font`″″\else\mathematics{\prime\prime}\fi} % 0x2103
+\permanent\protected\def\fraction#1#2{\mathematics{\Uabove exact .125\exheight {#1}{#2}}}
+
+%D \startbuffer
+%D \startlines
+%D x\periods x
+%D x\periods[10]x
+%D x\periods[n=10,symbol={,}]x
+%D x\periods[n=4,symbol={!!},width=1em]x
+%D x\periods[n=4,symbol={!!},width=fit]x
+%D x\periods[n=4,symbol={!!},width=fit,distance=1em]x
+%D x\unknown x
+%D \stoplines
+%D \stopbuffer
+%D
+%D \typbuffer \getbuffer
+
+\installcorenamespace {periods}
+
+\installsetuponlycommandhandler \??periods {periods}
+
+\setupperiods
+ [\c!n=3,
+ \c!width=.5\emwidth, % can also be \v!fit
+ \c!distance=.25\emwidth,
+ \c!symbol=.]
+
+\permanent\protected\def\periods
+ {\dontleavehmode
+ \hbox\bgroup
+ \doifelsenextoptional\enco_periods_yes\enco_periods_nop}
+
+\protected\def\enco_periods_yes[#1]%
+ {\doifelseassignment{#1}
+ {\setupcurrentperiods[#1]%
+ \scratchcounter\periodsparameter\c!n}
+ {\doifelsenothing{#1}
+ {\scratchcounter\periodsparameter\c!n}%
+ {\scratchcounter#1}}%
+ \enco_periods_finish}
+
+\protected\def\enco_periods_nop
+ {\scratchcounter\periodsparameter\c!n
+ \enco_periods_finish}
+
+\protected\def\enco_periods_finish
+ {\edef\p_width{\periodsparameter\c!width}%
+ \ifx\p_width\v!fit
+ \enco_periods_finish_fit
+ \else
+ \enco_periods_finish_width
+ \fi
+ \egroup}
+
+\protected\def\enco_periods_finish_width
+ {\setbox\scratchbox\hbox to \p_width
+ {\hss\periodsparameter\c!symbol\hss}%
+ \dorecurse\scratchcounter{\copy\scratchbox}}
+
+\protected\def\enco_periods_finish_fit
+ {\edef\p_symbol{\periodsparameter\c!symbol}%
+ \scratchdistance\periodsparameter\c!distance
+ \hskip\scratchdistance
+ \dorecurse\scratchcounter{\p_symbol\hskip\scratchdistance}}
+
+\permanent\protected\def\unknown
+ {\dontleavehmode
+ \hbox\bgroup
+ \enco_periods_nop}
+
+%D Left-overs:
+
+\appendtoks
+ \enforced\let\buildtextaccent\secondoftwoarguments
+\to \everysimplifycommands
+
+%D See enco-ini.mkivc for a definition of the obsolete \type {\t}.
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-ini.mklx b/Master/texmf-dist/tex/context/base/mkxl/file-ini.mklx
new file mode 100644
index 00000000000..35a49c72dd4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-ini.mklx
@@ -0,0 +1,231 @@
+%D \module
+%D [ file=file-ini, % was supp-fil,
+%D version=20110701, % 1995.10.10,
+%D title=\CONTEXT\ File Macros,
+%D subtitle=Helpers,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D \TEX\ operates on files, so one wouldn't wonder that there is a separate module
+%D for file commands. In \CONTEXT\ files are used for several purposes:
+%D
+%D \startitemize[packed]
+%D \item general textual input
+%D \item logging status information
+%D \item saving registers, lists and references
+%D \item buffering defered textual input
+%D \stopitemize
+%D
+%D When dealing with files we can load them as a whole, using the \type {\input}
+%D primitive or load them on a line||by||line basis, using \type {\read}. Writing is
+%D always done line by line, using \type {\write}.
+
+\writestatus{loading}{ConTeXt File Macros / Helpers}
+
+\registerctxluafile{file-ini}{}
+
+\unprotect
+
+%D \macros
+%D {scratchread, scratchwrite}
+%D
+%D We define a scratch file for reading. Keep in mind that the number of files is
+%D limited to~16, so use this one when possible. We also define a scratch output
+%D file. In \MKIV\ and \LMTX\ we never use these file handles.
+
+\ifdefined\scratchread \else \newread \scratchread \fi
+\ifdefined\scratchwrite \else \newwrite\scratchwrite \fi
+
+%D Seldom needed:
+
+\permanent\def\openinputfile #handle#name{\immediate\openin #handle={#name}\relax}
+\permanent\def\openoutputfile #handle#name{\immediate\openout#handle={#name}\relax}
+
+\permanent\def\closeinputfile #handle{\immediate\closein #handle\relax}
+\permanent\def\closeoutputfile#handle{\immediate\closeout#handle\relax}
+
+%D \macros
+%D {writeln}
+%D
+%D This saves a few tokens:
+
+\permanent\def\writeln#handle{\write#handle{}}
+
+%D \macros
+%D {pushendofline,popendofline}
+%D
+%D When we are loading files in the middle of the typesetting process, for instance
+%D when we load references, we have to be sure that the reading process does not
+%D generate so called 'spurious spaces'. This can be prevented by assigning the line
+%D ending character the \CATCODE\ comment. This is accomplished by
+%D
+%D \starttyping
+%D \pushendofline
+%D ... reading ...
+%D \popendofline
+%D \stoptyping
+
+\installsystemnamespace{eolstack}
+
+\newcount\c_system_files_eol_level
+
+\permanent\protected\def\pushendofline
+ {\advance\c_system_files_eol_level\plusone
+ \expandafter\chardef\csname\??eolstack\number\c_system_files_eol_level\endcsname\catcode\endoflineasciicode
+ \catcode\endoflineasciicode\commentcatcode}
+
+\permanent\protected\def\popendofline
+ {\catcode\endoflineasciicode\csname\??eolstack\number\c_system_files_eol_level\endcsname
+ \advance\c_system_files_eol_level\minusone}
+
+\permanent\protected\def\restoreendofline
+ {\catcode\endoflineasciicode\endoflinecatcode}
+
+%D \macros
+%D {startreadingfile,stopreadingfile}
+%D
+%D A low level capsule:
+
+\newcount\readingfilelevel % no longer needed
+\newtoks \everystartreadingfile
+\newtoks \everystopreadingfile
+
+\permanent\protected\def\startreadingfile% beter een every en \setnormalcatcodes
+ {\global\advance\readingfilelevel\plusone
+ \the\everystartreadingfile
+ \pushcatcodetable % saveguard
+ \setcatcodetable\ctxcatcodes
+ \clf_pushregime}% temporarily this way
+
+\permanent\protected\def\stopreadingfile
+ {\popcatcodetable % saveguard
+ \clf_popregime % temporarily this way
+ \the\everystopreadingfile
+ \global\advance\readingfilelevel\minusone}
+
+%D \macros
+%D {input, normalinput}
+%D
+%D Sometimes we run into troubles when \type {\input} wants to get expanded, e.g. in
+%D a \type {\write} (which happens in the metafun manual when we permit long MP
+%D lines). So, instead of fixing that, we go for a redefinition of \type {\input}.
+%D Of course it's better to use \type {\readfile} or \type {\processfile}.
+
+\permanent\def\inputgivenfile#name{\normalinput{#name}} % expands
+
+%D \macros
+%D {doifelsefile}
+%D
+%D The next alternative only looks if a file is present. No loading is done. This
+%D one obeys the standard \TEX\ lookup.
+%D
+%D \starttyping
+%D \doiffileelse {filename} {found} {not found}
+%D \stoptyping
+
+\permanent\protected\def\doifelsefile {\clf_doifelsefileexist}
+\permanent\protected\def\doifelsepath {\clf_doifelsepathexist}
+\permanent\protected\def\doiffile #name{\clf_doifelsefileexist{#name}\firstofoneargument\gobbleoneargument}
+\permanent\protected\def\doifnotfile #name{\clf_doifelsefileexist{#name}\gobbleoneargument\firstofoneargument}
+
+\aliased\let\doiffileelse\doifelsefile
+\aliased\let\doifpathelse\doifelsepath
+
+\aliased\let\doifelsefileexists\doifelsefile
+\aliased\let\doifelsepathexists\doifelsepath
+
+\aliased\let\doiffileexistselse\doifelsefileexists
+\aliased\let\doifpathexistselse\doifelsepathexists
+
+%D \macros
+%D {doifparentfileelse}
+%D
+%D \starttyping
+%D \doifparentfileelse{filename}{yes}{no}
+%D \stoptyping
+
+\ifdefined\outputfilename \else \def\outputfilename{\jobname} \fi
+
+\permanent\protected\def\doifelseparentfile{\clf_doifelseparentfile}
+
+\aliased\let\doifparentfileelse\doifelseparentfile
+
+%D \macros
+%D {splitfilename}
+%D
+%D \startbuffer
+%D \def\showfilesplit
+%D {\bgroup \tttf
+%D \hbox{(full: \splitofffull)}\space
+%D \hbox{(path: \splitoffpath)}\space
+%D \hbox{(base: \splitoffbase)}\space
+%D \hbox{(name: \splitoffname)}\space
+%D \hbox{(type: \splitofftype)}\space
+%D \egroup}
+%D
+%D \splitfilename{c:/aa/bb/cc/dd.ee.ff} \showfilesplit \endgraf
+%D \splitfilename{c:/aa/bb/cc/dd.ee} \showfilesplit \endgraf
+%D \splitfilename{c:/aa/bb/cc/dd} \showfilesplit \endgraf
+%D
+%D \splitfilename{dd.ee.ff} \showfilesplit \endgraf
+%D \splitfilename{dd.ee} \showfilesplit \endgraf
+%D \splitfilename{dd} \showfilesplit \endgraf
+%D \stopbuffer
+%D
+%D \start \typebuffer \getbuffer \stop
+
+\newconstant\kindoffile % 0=normal 1=full path spec (or http) / set at the lua end
+\newconstant\splitoffkind
+
+\mutable\def\splitoffroot{.}
+\mutable\let\splitofffull\empty
+\mutable\let\splitoffpath\empty
+\mutable\let\splitoffbase\empty
+\mutable\let\splitoffname\empty
+\mutable\let\splitofftype\empty
+
+\permanent\protected\def\splitfilename{\clf_splitfilename}
+
+%D \macros
+%D {doonlyonce, doinputonce, doendinputonce}
+%D
+%D Especially macropackages need only be loaded once. Repetitive loading not only
+%D costs time, relocating registers often leads to abortion of the processing
+%D because \TEX's capacity is limited. One can prevent multiple execution and
+%D loading by using one of both:
+%D
+%D \starttyping
+%D \doonlyonce{actions}
+%D \doinputonce{filename}
+%D \doendinputonce{filename}
+%D \stoptyping
+%D
+%D This command obeys the standard method for locating files. We could move this
+%D function to the \LUA\ end.
+
+\installsystemnamespace{fileonce}
+
+\permanent\protected\def\doonlyonce#whatever%
+ {\ifcsname\??fileonce#whatever\endcsname
+ \expandafter\gobbleoneargument
+ \else
+ \letgvalue{\??fileonce#whatever}\relax
+ \expandafter\firstofoneargument
+ \fi}
+
+\permanent\protected\def\doinputonce#name%
+ {\doonlyonce{#name}{\doifelsefile{#name}{\inputgivenfile{#name}}\donothing}}
+
+\permanent\protected\def\doendinputonce#name%
+ {\ifcsname\??fileonce#name\endcsname
+ \expandafter\endinput
+ \fi}
+
+\permanent\protected\def\forgetdoingonce#whatever%
+ {\global\undefinevalue{\??fileonce#whatever}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-job.lmt b/Master/texmf-dist/tex/context/base/mkxl/file-job.lmt
new file mode 100644
index 00000000000..95ad48e824b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-job.lmt
@@ -0,0 +1,1283 @@
+if not modules then modules = { } end modules ['file-job'] = {
+ version = 1.001,
+ comment = "companion to file-job.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- in retrospect dealing it's not that bad to deal with the nesting
+-- and push/poppign at the tex end
+
+local next, rawget, tostring, tonumber = next, rawget, tostring, tonumber
+local gsub, match, find = string.gsub, string.match, string.find
+local insert, remove, concat = table.insert, table.remove, table.concat
+local validstring, formatters = string.valid, string.formatters
+local sortedhash = table.sortedhash
+local setmetatableindex, setmetatablenewindex = table.setmetatableindex, table.setmetatablenewindex
+
+local commands = commands
+local resolvers = resolvers
+local context = context
+
+local ctx_doifelse = commands.doifelse
+
+local implement = interfaces.implement
+
+local trace_jobfiles = false trackers.register("system.jobfiles", function(v) trace_jobfiles = v end)
+
+local report = logs.reporter("system")
+local report_jobfiles = logs.reporter("system", "jobfiles")
+local report_functions = logs.reporter("system", "functions")
+
+local texsetcount = tex.setcount
+local elements = interfaces.elements
+local constants = interfaces.constants
+local variables = interfaces.variables
+local settings_to_array = utilities.parsers.settings_to_array
+local allocate = utilities.storage.allocate
+
+local nameonly = file.nameonly
+local suffixonly = file.suffix
+local basename = file.basename
+local addsuffix = file.addsuffix
+local removesuffix = file.removesuffix
+local dirname = file.dirname
+local is_qualified_path = file.is_qualified_path
+
+local cleanpath = resolvers.cleanpath
+local toppath = resolvers.toppath
+local resolveprefix = resolvers.resolve
+
+local hasscheme = url.hasscheme
+
+local jobresolvers = resolvers.jobs
+
+local registerextrapath = resolvers.registerextrapath
+local resetextrapaths = resolvers.resetextrapaths
+local getextrapaths = resolvers.getextrapath
+local pushextrapath = resolvers.pushextrapath
+local popextrapath = resolvers.popextrapath
+
+----- v_outer = variables.outer
+local v_text = variables.text
+local v_project = variables.project
+local v_environment = variables.environment
+local v_product = variables.product
+local v_component = variables.component
+local v_yes = variables.yes
+
+-- main code .. there is some overlap .. here we have loc://
+
+local function findctxfile(name) -- loc ? any ?
+ if is_qualified_path(name) then -- maybe when no suffix do some test for tex
+ return name
+ elseif not hasscheme(name) then
+ return resolvers.finders.byscheme("loc",name) or ""
+ else
+ return resolvers.findtexfile(name) or ""
+ end
+end
+
+resolvers.findctxfile = findctxfile
+
+implement {
+ name = "processfile",
+ arguments = "string",
+ public = true,
+ protected = true,
+ actions = function(name)
+ name = findctxfile(name)
+ if name ~= "" then
+ context.input(name)
+ end
+ end
+}
+
+implement {
+ name = "doifelseinputfile",
+ arguments = "string",
+ public = true,
+ protected = true,
+ actions = function(name)
+ ctx_doifelse(findctxfile(name) ~= "")
+ end
+}
+
+implement {
+ name = "locatefilepath",
+ arguments = "string",
+ actions = function(name)
+ context(dirname(findctxfile(name)))
+ end
+}
+
+implement {
+ name = "usepath",
+ arguments = "optional",
+ public = true,
+ protected = true,
+ actions = function(paths)
+ report_jobfiles("using path: %s",paths)
+ registerextrapath(paths)
+ end
+}
+
+implement {
+ name = "pushpath",
+ arguments = "optional",
+ public = true,
+ protected = true,
+ actions = function(paths)
+ report_jobfiles("pushing path: %s",paths)
+ pushextrapath(paths)
+ end
+}
+
+implement {
+ name = "poppath",
+ public = true,
+ protected = true,
+ actions = function(paths)
+ popextrapath()
+ report_jobfiles("popping path")
+ end
+}
+
+implement {
+ name = "usesubpath",
+ arguments = "optional",
+ public = true,
+ protected = true,
+ actions = function(subpaths)
+ report_jobfiles("using subpath: %s",subpaths)
+ registerextrapath(nil,subpaths)
+ end
+}
+
+implement {
+ name = "resetpath",
+ public = true,
+ protected = true,
+ actions = function()
+ report_jobfiles("resetting path")
+ resetextrapaths()
+ end
+}
+
+implement {
+ name = "allinputpaths",
+ public = true,
+ actions = function()
+ context(concat(getextrapaths(),","))
+ end
+}
+
+implement {
+ name = "usezipfile",
+ public = true,
+ protected = true,
+ arguments = { "optional", "optional" },
+ actions = function(name,tree)
+ if tree and tree ~= "" then
+ resolvers.usezipfile(formatters["zip:///%s?tree=%s"](name,tree))
+ else
+ resolvers.usezipfile(formatters["zip:///%s"](name))
+ end
+ end
+}
+
+-- moved from tex to lua:
+
+local texpatterns = { "%s.mkvi", "%s.mkiv", "%s.mklx", "%s.mkxl", "%s.tex" }
+local luapatterns = { "%s" .. utilities.lua.suffixes.luc, "%s.lua", "%s.lmt" }
+local cldpatterns = { "%s.cld" }
+local xmlpatterns = { "%s.xml" }
+
+local uselibrary = resolvers.uselibrary
+local input = context.input
+
+-- status
+--
+-- these need to be synced with input stream:
+
+local processstack = { }
+local processedfile = ""
+local processedfiles = { }
+
+implement {
+ name = "processedfile",
+ actions = function()
+ context(processedfile)
+ end
+}
+
+implement {
+ name = "processedfiles",
+ actions = function()
+ context(concat(processedfiles,","))
+ end
+}
+
+implement {
+ name = "dostarttextfile",
+ public = true,
+ protected = true,
+ arguments = "string",
+ actions = function(name)
+ insert(processstack,name)
+ processedfile = name
+ insert(processedfiles,name)
+ end
+}
+
+implement {
+ name = "dostoptextfile",
+ public = true,
+ protected = true,
+ actions = function()
+ processedfile = remove(processstack) or ""
+ end
+}
+
+local function startprocessing(name,notext)
+ if not notext then
+ -- report("begin file %a at line %a",name,status.linenumber or 0)
+ context.dostarttextfile(name)
+ end
+end
+
+local function stopprocessing(notext)
+ if not notext then
+ context.dostoptextfile()
+ -- report("end file %a at line %a",name,status.linenumber or 0)
+ end
+end
+
+--
+
+local typestack = { }
+local currenttype = v_text
+local nofmissing = 0
+local missing = {
+ tex = setmetatableindex("number"),
+ lua = setmetatableindex("number"),
+ cld = setmetatableindex("number"),
+ xml = setmetatableindex("number"),
+}
+
+local function reportfailure(kind,name)
+ nofmissing = nofmissing + 1
+ missing[kind][name] = true
+ report_jobfiles("unknown %s file %a",kind,name)
+end
+
+--
+
+local function action(name,foundname)
+ input(foundname)
+end
+local function failure(name,foundname)
+ reportfailure("tex",name)
+end
+local function usetexfile(name,onlyonce,notext)
+ startprocessing(name,notext)
+ uselibrary {
+ name = name,
+ patterns = texpatterns,
+ action = action,
+ failure = failure,
+ onlyonce = onlyonce,
+ }
+ stopprocessing(notext)
+end
+
+local function action(name,foundname)
+ dofile(foundname)
+end
+local function failure(name,foundname)
+ reportfailure("lua",name)
+end
+local function useluafile(name,onlyonce,notext)
+ uselibrary {
+ name = name,
+ patterns = luapatterns,
+ action = action,
+ failure = failure,
+ onlyonce = onlyonce,
+ }
+end
+
+local function action(name,foundname)
+ dofile(foundname)
+end
+local function failure(name,foundname)
+ reportfailure("cld",name)
+end
+local function usecldfile(name,onlyonce,notext)
+ startprocessing(name,notext)
+ uselibrary {
+ name = name,
+ patterns = cldpatterns,
+ action = action,
+ failure = failure,
+ onlyonce = onlyonce,
+ }
+ stopprocessing(notext)
+end
+
+local function action(name,foundname)
+ context.xmlprocess(foundname,"main","")
+end
+local function failure(name,foundname)
+ reportfailure("xml",name)
+end
+local function usexmlfile(name,onlyonce,notext)
+ startprocessing(name,notext)
+ uselibrary {
+ name = name,
+ patterns = xmlpatterns,
+ action = action,
+ failure = failure,
+ onlyonce = onlyonce,
+ }
+ stopprocessing(notext)
+end
+
+local suffixes = {
+ mkvi = usetexfile,
+ mkiv = usetexfile,
+ mklx = usetexfile,
+ mkxl = usetexfile,
+ tex = usetexfile,
+ luc = useluafile,
+ lua = useluafile,
+ cld = usecldfile,
+ xml = usexmlfile,
+ [""] = usetexfile,
+}
+
+local function useanyfile(name,onlyonce)
+ local s = suffixes[suffixonly(name)]
+ context(function() resolvers.pushpath(name) end)
+ if s then
+ -- s(removesuffix(name),onlyonce)
+ s(name,onlyonce) -- so, first with suffix, then without
+ else
+ usetexfile(name,onlyonce) -- e.g. ctx file
+ -- resolvers.readfilename(name)
+ end
+ context(resolvers.poppath)
+end
+
+implement { name = "loadtexfile", public = true, protected = true, actions = usetexfile, arguments = "optional" }
+implement { name = "loadluafile", public = true, protected = true, actions = useluafile, arguments = "optional" }
+implement { name = "loadcldfile", public = true, protected = true, actions = usecldfile, arguments = "optional" }
+implement { name = "loadxmlfile", public = true, protected = true, actions = usexmlfile, arguments = "optional" }
+
+implement { name = "loadtexfileonce", public = true, protected = true, actions = usetexfile, arguments = { "optional", true } }
+implement { name = "loadluafileonce", public = true, protected = true, actions = useluafile, arguments = { "optional", true } }
+implement { name = "loadcldfileonce", public = true, protected = true, actions = usecldfile, arguments = { "optional", true } }
+implement { name = "loadxmlfileonce", public = true, protected = true, actions = usexmlfile, arguments = { "optional", true } }
+
+implement { name = "useanyfile", actions = useanyfile, arguments = "string" }
+implement { name = "useanyfileonce", actions = useanyfile, arguments = { "string", true } }
+
+function jobresolvers.usefile(name,onlyonce,notext)
+ local s = suffixes[suffixonly(name)]
+ if s then
+ -- s(removesuffix(name),onlyonce,notext)
+ s(name,onlyonce,notext) -- so, first with suffix, then without
+ end
+end
+
+-- document structure
+
+local textlevel = 0 -- inaccessible for user, we need to define counter textlevel at the tex end
+
+local function dummyfunction() end
+
+local function startstoperror()
+ report("invalid \\%s%s ... \\%s%s structure",elements.start,v_text,elements.stop,v_text)
+ startstoperror = dummyfunction
+end
+
+local stopped
+
+local function starttext()
+ if textlevel == 0 then
+ if trace_jobfiles then
+ report_jobfiles("starting text")
+ end
+ context.dostarttext()
+ end
+ textlevel = textlevel + 1
+ texsetcount("global","textlevel",textlevel)
+end
+
+local function stoptext()
+ if not stopped then
+ if textlevel == 0 then
+ startstoperror()
+ elseif textlevel > 0 then
+ textlevel = textlevel - 1
+ end
+ texsetcount("global","textlevel",textlevel)
+ if textlevel <= 0 then
+ if trace_jobfiles then
+ report_jobfiles("stopping text")
+ end
+ context.dostoptext()
+ stopped = true
+ end
+ end
+end
+
+implement {
+ name = "starttext",
+ public = true,
+ protected = true,
+ actions = starttext
+}
+
+implement {
+ name = "stoptext",
+ public = true,
+ protected = true,
+ actions = stoptext
+}
+
+implement {
+ name = "forcequitjob",
+ arguments = "string",
+ public = true,
+ protected = true,
+ actions = function(reason)
+ if reason then
+ report("forcing quit: %s",reason)
+ else
+ report("forcing quit")
+ end
+ context.batchmode()
+ while textlevel >= 0 do
+ context.stoptext()
+ end
+ end
+}
+
+implement {
+ name = "forceendjob",
+ public = true,
+ protected = true,
+ actions = function()
+ report([[don't use \end to finish a document]])
+ context.stoptext()
+ end
+}
+
+implement {
+ name = "autostarttext",
+ public = true,
+ protected = true,
+ actions = function()
+ if textlevel == 0 then
+ report([[auto \starttext ... \stoptext]])
+ end
+ context.starttext()
+ end
+}
+
+implement {
+ name = "autostoptext",
+ public = true,
+ protected = true,
+ actions = stoptext
+}
+
+-- project structure
+
+implement {
+ name = "processfilemany",
+ public = true,
+ protected = true,
+ arguments = { "string", false },
+ actions = useanyfile
+}
+
+implement {
+ name = "processfileonce",
+ public = true,
+ protected = true,
+ arguments = { "string", true },
+ actions = useanyfile
+}
+
+implement {
+ name = "processfilenone",
+ arguments = "string",
+ public = true,
+ protected = true,
+ actions = dummyfunction,
+}
+
+local tree = { type = "text", name = "", branches = { } }
+local treestack = { }
+local top = tree.branches
+local root = tree
+
+local project_stack = { }
+local product_stack = { }
+local component_stack = { }
+local environment_stack = { }
+
+local stacks = {
+ [v_project ] = project_stack,
+ [v_product ] = product_stack,
+ [v_component ] = component_stack,
+ [v_environment] = environment_stack,
+}
+
+--
+
+local function pushtree(what,name)
+ local t = { }
+ top[#top+1] = { type = what, name = name, branches = t }
+ insert(treestack,top)
+ top = t
+end
+
+local function poptree()
+ top = remove(treestack)
+ -- inspect(top)
+end
+
+do
+
+ local function log_tree(report,top,depth)
+ report("%s%s: %s",depth,top.type,top.name)
+ local branches = top.branches
+ if #branches > 0 then
+ depth = depth .. " "
+ for i=1,#branches do
+ log_tree(report,branches[i],depth)
+ end
+ end
+ end
+
+ logs.registerfinalactions(function()
+ root.name = environment.jobname
+ --
+ logs.startfilelogging(report,"used files")
+ log_tree(report,root,"")
+ logs.stopfilelogging()
+ --
+ if nofmissing > 0 and logs.loggingerrors() then
+ logs.starterrorlogging(report,"missing files")
+ for kind, list in sortedhash(missing) do
+ for name in sortedhash(list) do
+ report("%w%s %s",6,kind,name)
+ end
+ end
+ logs.stoperrorlogging()
+ end
+ end)
+
+end
+
+local jobstructure = job.structure or { }
+job.structure = jobstructure
+jobstructure.collected = jobstructure.collected or { }
+jobstructure.tobesaved = root
+jobstructure.components = { }
+
+local function initialize()
+ local function collect(root,result)
+ local branches = root.branches
+ if branches then
+ for i=1,#branches do
+ local branch = branches[i]
+ if branch.type == "component" then
+ result[#result+1] = branch.name
+ end
+ collect(branch,result)
+ end
+ end
+ return result
+ end
+ jobstructure.components = collect(jobstructure.collected,{})
+end
+
+job.register('job.structure.collected',root,initialize)
+
+-- component: small unit, either or not components itself
+-- product : combination of components
+
+local ctx_processfilemany = context.processfilemany
+local ctx_processfileonce = context.processfileonce
+local ctx_processfilenone = context.processfilenone
+
+-- we need a plug in the nested loaded, push pop pseudo current dir
+
+local function processfilecommon(name,action)
+ -- experiment, might go away
+-- if not hasscheme(name) then
+-- local path = dirname(name)
+-- if path ~= "" then
+-- registerextrapath(path)
+-- report_jobfiles("adding search path %a",path)
+-- end
+-- end
+ -- till here
+ action(name)
+end
+
+local function processfilemany(name) processfilecommon(name,ctx_processfilemany) end
+local function processfileonce(name) processfilecommon(name,ctx_processfileonce) end
+local function processfilenone(name) processfilecommon(name,ctx_processfilenone) end
+
+local processors = utilities.storage.allocate {
+ -- [v_outer] = {
+ -- [v_text] = { "many", processfilemany },
+ -- [v_project] = { "once", processfileonce },
+ -- [v_environment] = { "once", processfileonce },
+ -- [v_product] = { "once", processfileonce },
+ -- [v_component] = { "many", processfilemany },
+ -- },
+ [v_text] = {
+ [v_text] = { "many", processfilemany },
+ [v_project] = { "once", processfileonce }, -- dubious
+ [v_environment] = { "once", processfileonce },
+ [v_product] = { "many", processfilemany }, -- dubious
+ [v_component] = { "many", processfilemany },
+ },
+ [v_project] = {
+ [v_text] = { "many", processfilemany },
+ [v_project] = { "none", processfilenone },
+ [v_environment] = { "once", processfileonce },
+ [v_product] = { "none", processfilenone },
+ [v_component] = { "none", processfilenone },
+ },
+ [v_environment] = {
+ [v_text] = { "many", processfilemany },
+ [v_project] = { "none", processfilenone },
+ [v_environment] = { "once", processfileonce },
+ [v_product] = { "none", processfilenone },
+ [v_component] = { "none", processfilenone },
+ },
+ [v_product] = {
+ [v_text] = { "many", processfilemany },
+ [v_project] = { "once", processfileonce },
+ [v_environment] = { "once", processfileonce },
+ [v_product] = { "many", processfilemany },
+ [v_component] = { "many", processfilemany },
+ },
+ [v_component] = {
+ [v_text] = { "many", processfilemany },
+ [v_project] = { "once", processfileonce },
+ [v_environment] = { "once", processfileonce },
+ [v_product] = { "none", processfilenone },
+ [v_component] = { "many", processfilemany },
+ }
+}
+
+local start = {
+ [v_text] = nil,
+ [v_project] = nil,
+ [v_environment] = context.startreadingfile,
+ [v_product] = context.starttext,
+ [v_component] = context.starttext,
+}
+
+local stop = {
+ [v_text] = nil,
+ [v_project] = nil,
+ [v_environment] = context.stopreadingfile,
+ [v_product] = context.stoptext,
+ [v_component] = context.stoptext,
+}
+
+jobresolvers.processors = processors
+
+local function topofstack(what)
+ local stack = stacks[what]
+ return stack and stack[#stack] or environment.jobname
+end
+
+local function productcomponent() -- only when in product
+ local product = product_stack[#product_stack]
+ if product and product ~= "" then
+ local component = component_stack[1]
+ if component and component ~= "" then
+ return component
+ end
+ end
+end
+
+local function justacomponent()
+ local product = product_stack[#product_stack]
+ if not product or product == "" then
+ local component = component_stack[1]
+ if component and component ~= "" then
+ return component
+ end
+ end
+end
+
+jobresolvers.productcomponent = productcomponent
+jobresolvers.justacomponent = justacomponent
+
+function jobresolvers.currentproject () return topofstack(v_project ) end
+function jobresolvers.currentproduct () return topofstack(v_product ) end
+function jobresolvers.currentcomponent () return topofstack(v_component ) end
+function jobresolvers.currentenvironment() return topofstack(v_environment) end
+
+local done = { }
+local tolerant = false -- too messy, mkii user with the wrong structure should adapt
+
+local function process(what,name)
+ local depth = #typestack
+ local process
+ --
+ name = resolveprefix(name)
+ --
+-- if not tolerant then
+ -- okay, would be best but not compatible with mkii
+ process = processors[currenttype][what]
+-- elseif depth == 0 then
+-- -- could be a component, product or (brr) project
+-- if trace_jobfiles then
+-- report_jobfiles("%s : %s > %s (case 1)",depth,currenttype,v_outer)
+-- end
+-- process = processors[v_outer][what]
+-- elseif depth == 1 and typestack[1] == v_text then
+-- -- we're still not doing a component or product
+-- if trace_jobfiles then
+-- report_jobfiles("%s : %s > %s (case 2)",depth,currenttype,v_outer)
+-- end
+-- process = processors[v_outer][what]
+-- else
+-- process = processors[currenttype][what]
+-- end
+ if process then
+ local method = process[1]
+ if method == "none" then
+ if trace_jobfiles then
+ report_jobfiles("%s : %s : %s %s %a in %s %a",depth,method,"ignoring",what,name,currenttype,topofstack(currenttype))
+ end
+ elseif method == "once" and done[name] then
+ if trace_jobfiles then
+ report_jobfiles("%s : %s : %s %s %a in %s %a",depth,method,"skipping",what,name,currenttype,topofstack(currenttype))
+ end
+ else
+ -- keep in mind that we also handle "once" at the file level
+ -- so there is a double catch
+ done[name] = true
+ local before = start[what]
+ local after = stop [what]
+ if trace_jobfiles then
+ report_jobfiles("%s : %s : %s %s %a in %s %a",depth,method,"processing",what,name,currenttype,topofstack(currenttype))
+ end
+ if before then
+ before()
+ end
+ process[2](name)
+ if after then
+ after()
+ end
+ end
+ else
+ if trace_jobfiles then
+ report_jobfiles("%s : %s : %s %s %a in %s %a",depth,"none","ignoring",what,name,currenttype,topofstack(currenttype))
+ end
+ end
+end
+
+local scan_delimited = tokens.scanners.delimited
+
+local function getname()
+ return scan_delimited(91,93) or scan_delimited(0,32) -- [name] or name
+end
+
+implement { name = "project", public = true, protected = true, actions = function() process(v_project, getname()) end }
+implement { name = "environment", public = true, protected = true, actions = function() process(v_environment,getname()) end }
+implement { name = "product", public = true, protected = true, actions = function() process(v_product, getname()) end } -- will be overloaded
+implement { name = "component", public = true, protected = true, actions = function() process(v_component, getname()) end }
+
+implement { name = "useproject", public = true, protected = true, actions = function(name) process(v_project, name) end, arguments = "optional" }
+implement { name = "useenvironment", public = true, protected = true, actions = function(name) process(v_environment,name) end, arguments = "optional" }
+implement { name = "useproduct", public = true, protected = true, actions = function(name) process(v_product, name) end, arguments = "optional" } -- will be overloaded
+implement { name = "usecomponent", public = true, protected = true, actions = function(name) process(v_component, name) end, arguments = "optional" }
+
+-- todo: setsystemmode to currenttype
+-- todo: make start/stop commands at the tex end
+
+local start = {
+ [v_project] = context.startprojectindeed,
+ [v_product] = context.startproductindeed,
+ [v_component] = context.startcomponentindeed,
+ [v_environment] = context.startenvironmentindeed,
+}
+
+local stop = {
+ [v_project] = context.stopprojectindeed,
+ [v_product] = context.stopproductindeed,
+ [v_component] = context.stopcomponentindeed,
+ [v_environment] = context.stopenvironmentindeed,
+}
+
+local function gotonextlevel(what,name) -- todo: something with suffix name
+ insert(stacks[what],name)
+ insert(typestack,currenttype)
+ currenttype = what
+ pushtree(what,name)
+ if start[what] then
+ start[what]()
+ end
+end
+
+local function gotopreviouslevel(what)
+ if stop[what] then
+ stop[what]()
+ end
+ poptree()
+ currenttype = remove(typestack) or v_text
+ remove(stacks[what]) -- not currenttype ... weak recovery
+context.endinput() -- does not work
+-- context.signalendofinput(what)
+end
+
+local function autoname()
+ local name = scan_delimited(91,93) or scan_delimited(0,32) -- [name] or name
+ if name == "*" then
+ name = nameonly(toppath() or name)
+ end
+ return name
+end
+
+implement { name = "startproject", public = true, protected = true, actions = function() gotonextlevel(v_project, autoname()) end }
+implement { name = "startproduct", public = true, protected = true, actions = function() gotonextlevel(v_product, autoname()) end }
+implement { name = "startcomponent", public = true, protected = true, actions = function() gotonextlevel(v_component, autoname()) end }
+implement { name = "startenvironment", public = true, protected = true, actions = function() gotonextlevel(v_environment,autoname()) end }
+
+implement { name = "stopproject", public = true, protected = true, actions = function() gotopreviouslevel(v_project ) end }
+implement { name = "stopproduct", public = true, protected = true, actions = function() gotopreviouslevel(v_product ) end }
+implement { name = "stopcomponent", public = true, protected = true, actions = function() gotopreviouslevel(v_component ) end }
+implement { name = "stopenvironment", public = true, protected = true, actions = function() gotopreviouslevel(v_environment) end }
+
+implement { name = "currentproject", public = true, actions = function() context(topofstack(v_project )) end }
+implement { name = "currentproduct", public = true, actions = function() context(topofstack(v_product )) end }
+implement { name = "currentcomponent", public = true, actions = function() context(topofstack(v_component )) end }
+implement { name = "currentenvironment", public = true, actions = function() context(topofstack(v_environment)) end }
+
+-- -- -- this will move -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+--
+--
+--
+-- nee
+-- standaard
+--
+--
+-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+local report_examodes = logs.reporter("system","examodes")
+
+local function convertexamodes(str)
+ local x = xml.convert(str)
+ for e in xml.collected(x,"exa:variable") do
+ local label = e.at and e.at.label
+ if label and label ~= "" then
+ local data = xml.text(e)
+ local mode = match(label,"^mode:(.+)$")
+ if mode then
+ context.enablemode { formatters["%s:%s"](mode,data) }
+ end
+ context.setvariable("exa:variables",label,(gsub(data,"([{}])","\\%1")))
+ end
+ end
+end
+
+function environment.loadexamodes(filename)
+ if not filename or filename == "" then
+ filename = removesuffix(tex.jobname)
+ end
+ filename = resolvers.findfile(addsuffix(filename,'ctm')) or ""
+ if filename ~= "" then
+ report_examodes("loading %a",filename) -- todo: message system
+ convertexamodes(io.loaddata(filename))
+ else
+ report_examodes("no mode file %a",filename) -- todo: message system
+ end
+end
+
+implement {
+ name = "loadexamodes",
+ actions = environment.loadexamodes,
+ public = true,
+ protected = true,
+ arguments = "optional"
+}
+
+-- changed in mtx-context
+-- code moved from luat-ini
+
+-- todo: locals when mtx-context is changed
+
+document = document or {
+ arguments = allocate(),
+ files = allocate(),
+ variables = allocate(), -- for templates
+ options = {
+ commandline = {
+ environments = allocate(),
+ modules = allocate(),
+ modes = allocate(),
+ },
+ ctxfile = {
+ environments = allocate(),
+ modules = allocate(),
+ modes = allocate(),
+ },
+ },
+ functions = table.setmetatablenewindex(function(t,k,v)
+ if rawget(t,k) then
+ report_functions("overloading document function %a",k)
+ end
+ rawset(t,k,v)
+ return v
+ end),
+}
+
+function document.setargument(key,value)
+ document.arguments[key] = value
+end
+
+function document.setdefaultargument(key,default)
+ local v = document.arguments[key]
+ if v == nil or v == "" then
+ document.arguments[key] = default
+ end
+end
+
+function document.setfilename(i,name)
+ if name then
+ document.files[tonumber(i)] = name
+ else
+ document.files[#document.files+1] = tostring(i)
+ end
+end
+
+function document.getargument(key,default)
+ local v = document.arguments[key]
+ if type(v) == "boolean" then
+ v = (v and "yes") or "no"
+ document.arguments[key] = v
+ end
+ return v or default or ""
+end
+
+function document.getfilename(i)
+ return document.files[tonumber(i)] or ""
+end
+
+implement {
+ name = "setdocumentargument",
+ actions = document.setargument,
+ arguments = "2 strings"
+}
+
+implement {
+ name = "setdocumentdefaultargument",
+ actions = document.setdefaultargument,
+ arguments = "2 strings"
+}
+
+implement {
+ name = "setdocumentfilename",
+ actions = document.setfilename,
+ arguments = { "integer", "string" }
+}
+
+implement {
+ name = "getdocumentargument",
+ actions = { document.getargument, context },
+ arguments = "2 strings"
+}
+
+implement {
+ name = "getdocumentfilename",
+ actions = { document.getfilename, context },
+ arguments = "integer"
+}
+
+function document.setcommandline() -- has to happen at the tex end in order to expand
+
+ -- the document[arguments|files] tables are copies
+
+ local arguments = document.arguments
+ local files = document.files
+ local options = document.options
+
+ for k, v in next, environment.arguments do
+ k = gsub(k,"^c:","") -- already done, but better be safe than sorry
+ if arguments[k] == nil then
+ arguments[k] = v
+ end
+ end
+
+ -- in the new mtx=context approach we always pass a stub file so we need to
+ -- to trick the files table which actually only has one entry in a tex job
+
+ if arguments.timing then
+ context.usemodule { "timing" }
+ end
+
+ if arguments.usage then
+ trackers.enable("system.usage")
+ end
+
+ if arguments.batchmode then
+ context.batchmode(false)
+ end
+
+ if arguments.nonstopmode then
+ context.nonstopmode(false)
+ end
+
+ if arguments.nostatistics then
+ directives.enable("system.nostatistics")
+ end
+
+ if arguments.paranoid then
+ context.setvalue("maxreadlevel",1)
+ end
+
+ if validstring(arguments.path) then
+ context.usepath { arguments.path }
+ end
+
+ if arguments.export then
+ context.setupbackend { export = v_yes }
+ end
+
+ local inputfile = validstring(arguments.input)
+
+ if inputfile and dirname(inputfile) == "." and lfs.isfile(inputfile) then
+ -- nicer in checks
+ inputfile = basename(inputfile)
+ end
+
+ local forcedruns = arguments.forcedruns
+ local kindofrun = arguments.kindofrun
+ local currentrun = arguments.currentrun
+ local maxnofruns = arguments.maxnofruns or arguments.runs
+
+ -- context.setupsystem {
+ -- [constants.directory] = validstring(arguments.setuppath),
+ -- [constants.inputfile] = inputfile,
+ -- [constants.file] = validstring(arguments.result),
+ -- [constants.random] = validstring(arguments.randomseed),
+ -- -- old:
+ -- [constants.n] = validstring(kindofrun),
+ -- [constants.m] = validstring(currentrun),
+ -- }
+
+ context.setupsystem {
+ directory = validstring(arguments.setuppath),
+ inputfile = inputfile,
+ file = validstring(arguments.result),
+ random = validstring(arguments.randomseed),
+ -- old:
+ n = validstring(kindofrun),
+ m = validstring(currentrun),
+ }
+
+ forcedruns = tonumber(forcedruns) or 0
+ kindofrun = tonumber(kindofrun) or 0
+ maxnofruns = tonumber(maxnofruns) or 0
+ currentrun = tonumber(currentrun) or 0
+
+ local prerollrun = forcedruns > 0 and currentrun > 0 and currentrun < forcedruns
+
+ environment.forcedruns = forcedruns
+ environment.kindofrun = kindofrun
+ environment.maxnofruns = maxnofruns
+ environment.currentrun = currentrun
+ environment.prerollrun = prerollrun
+
+ context.setconditional("prerollrun",prerollrun)
+
+ if validstring(arguments.arguments) then
+ context.setupenv { arguments.arguments }
+ end
+
+ if arguments.once then
+ directives.enable("system.runonce")
+ end
+
+ if arguments.noarrange then
+ context.setuparranging { variables.disable }
+ end
+
+ --
+
+ local commandline = options.commandline
+
+ commandline.environments = table.append(commandline.environments,settings_to_array(validstring(arguments.environment)))
+ commandline.modules = table.append(commandline.modules, settings_to_array(validstring(arguments.usemodule)))
+ commandline.modes = table.append(commandline.modes, settings_to_array(validstring(arguments.mode)))
+
+ --
+
+ if #files == 0 then
+ local list = settings_to_array(validstring(arguments.files))
+ if list and #list > 0 then
+ files = list
+ end
+ end
+
+ if #files == 0 then
+ files = { validstring(arguments.input) }
+ end
+
+ --
+
+ document.arguments = arguments
+ document.files = files
+
+end
+
+-- commandline wins over ctxfile
+
+local function apply(list,action)
+ if list then
+ for i=1,#list do
+ action { list[i] }
+ end
+ end
+end
+
+function document.setmodes() -- was setup: *runtime:modes
+ apply(document.options.ctxfile .modes,context.enablemode)
+ apply(document.options.commandline.modes,context.enablemode)
+end
+
+function document.setmodules() -- was setup: *runtime:modules
+ apply(document.options.ctxfile .modules,context.usemodule)
+ apply(document.options.commandline.modules,context.usemodule)
+end
+
+function document.setenvironments() -- was setup: *runtime:environments
+ apply(document.options.ctxfile .environments,context.environment)
+ apply(document.options.commandline.environments,context.environment)
+end
+
+function document.setfilenames()
+ local initialize = environment.initializefilenames
+ if initialize then
+ initialize()
+ else
+ -- fatal error
+ end
+end
+
+implement { name = "setdocumentcommandline", actions = document.setcommandline, onlyonce = true }
+implement { name = "setdocumentmodes", actions = document.setmodes, onlyonce = true }
+implement { name = "setdocumentmodules", actions = document.setmodules, onlyonce = true }
+implement { name = "setdocumentenvironments", actions = document.setenvironments, onlyonce = true }
+implement { name = "setdocumentfilenames", actions = document.setfilenames, onlyonce = true }
+
+do
+
+ logs.registerfinalactions(function()
+ local foundintrees = resolvers.foundintrees()
+ if #foundintrees > 0 then
+ logs.startfilelogging(report,"used files")
+ for i=1,#foundintrees do
+ report("%4i: % T",i,foundintrees[i])
+ end
+ logs.stopfilelogging()
+ end
+ end)
+
+ logs.registerfinalactions(function()
+ local files = document.files -- or environment.files
+ local arguments = document.arguments -- or environment.arguments
+ --
+ logs.startfilelogging(report,"commandline options")
+ if arguments and next(arguments) then
+ for argument, value in sortedhash(arguments) do
+ report("%s=%A",argument,value)
+ end
+ else
+ report("no arguments")
+ end
+ logs.stopfilelogging()
+ --
+ logs.startfilelogging(report,"commandline files")
+ if files and #files > 0 then
+ for i=1,#files do
+ report("% 4i: %s",i,files[i])
+ end
+ else
+ report("no files")
+ end
+ logs.stopfilelogging()
+ end)
+
+end
+
+if environment.initex then
+
+ logs.registerfinalactions(function()
+ local startfilelogging = logs.startfilelogging
+ local stopfilelogging = logs.stopfilelogging
+ startfilelogging(report,"stored tables")
+ for k,v in sortedhash(storage.data) do
+ report("%03i %s",k,v[1])
+ end
+ stopfilelogging()
+ startfilelogging(report,"stored modules")
+ for k,v in sortedhash(lua.bytedata) do
+ report("%03i %s %s",k,v.name)
+ end
+ stopfilelogging()
+ startfilelogging(report,"stored attributes")
+ for k,v in sortedhash(attributes.names) do
+ report("%03i %s",k,v)
+ end
+ stopfilelogging()
+ startfilelogging(report,"stored catcodetables")
+ for k,v in sortedhash(catcodes.names) do
+ report("%03i % t",k,v)
+ end
+ stopfilelogging()
+ startfilelogging(report,"stored corenamespaces")
+ for k,v in sortedhash(interfaces.corenamespaces) do
+ report("%03i %s",k,v)
+ end
+ stopfilelogging()
+ end)
+
+end
+
+implement {
+ name = "continueifinputfile",
+ public = true,
+ protected = true,
+ arguments = "string",
+ actions = function(inpname,basetoo)
+ local inpnamefull = addsuffix(inpname,"tex")
+ local inpfilefull = addsuffix(environment.inputfilename,"tex")
+ local continue = inpnamefull == inpfilefull
+ -- if basetoo and not continue then
+ if not continue then
+ continue = inpnamefull == basename(inpfilefull)
+ end
+ if continue then
+ report("continuing input file %a",inpname)
+ else
+ context.endinput()
+ end
+-- ctx_doifelse(continue)
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-job.mklx b/Master/texmf-dist/tex/context/base/mkxl/file-job.mklx
new file mode 100644
index 00000000000..9fb14c9bfc2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-job.mklx
@@ -0,0 +1,361 @@
+%D \module
+%D [ file=file-job, % copied from main-001, later core-job
+%D version=1997.03.31,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Job Handling,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt File Macros / Job Handling}
+
+\unprotect
+
+%D This module delegates most of the work to \LUA\ and therefore also let it
+%D define the commands, which is more efficient.
+
+\registerctxluafile{file-job}{autosuffix}
+
+%D Here are some helpers for processing and path control. In the following example
+%D the lookup order is \type {.}, {/foo}, \type {foo/bar} as one can always
+%D explicitly prefix a wanted file.
+%D
+%D \starttyping
+%D \pushpath[foo]
+%D \pushpath[foo/bar]
+%D \input test
+%D \poppath
+%D \poppath
+%D \stoptyping
+
+% \usepath [#path] % defined at lua end
+% \usesubpath [#path] % defined at lua end
+% \pushpath [#path] % defined at lua end
+% \poppath % defined at lua end
+% \resetpath % defined at lua end (not the pushed paths)
+% \allinputpaths % defined at lua end
+% \doifelseinputfile #name % defined at lua end
+% \processfile #name % defined at lua end
+
+\aliased\let\doifinputfileelse\doifelseinputfile
+
+% helper (not really needed nowadays)
+
+\mutable\let\locatedfilepath\empty
+
+\permanent\protected\def\locatefilepath#name%
+ {\edef\locatedfilepath{\clf_locatefilepath{#name}}} % todo: set at the lua end, catcodes and such
+
+% % maybe:
+%
+% % \dirlist{c:/data/temporary/foo}{images/bar.jpg}
+% % \dirfile{c:/data/temporary/foo}{images/bar.jpg}
+%
+% \def\dirlist#1#2{dirlist://#1/**/#2}
+% \def\dirfile#1#2{dirlist://#1/**/#2?option=fileonly}
+
+% zip files are tree'd
+% exa stuff might become obsolete:
+
+% \usezipfile [#zipname]#spacer[#subtree] % defined at lua end
+% \loadexamodes [#name] % defined at lua end
+
+\protected\def\syst_files_load
+ {\syst_files_load_indeed\f!newfilename % new code, to be integrated at some point, plus fixes posted on the list
+ \syst_files_load_indeed\f!locfilename % new code, somewhat experimental, not distributed (outside the dev group)
+ \syst_files_load_indeed\f!expfilename % new code, very experimental, can be engine specific, mostly for me only
+ \syst_files_load_indeed\f!sysfilename % local settings, but probably not that good an idea to use
+ %\syst_files_load_indeed\f!fntfilename % maybe some day, can load goodies and patches
+ }
+
+\def\syst_files_load_indeed#name% from now on we assume a suffix to be part of the name
+ {\readsysfile{#name}{\showmessage\m!system2{#name}}\donothing}
+
+% document structure
+
+\ifdefined\textlevel \else \newcount\textlevel \fi % might go away
+\ifdefined\strc_pagenumbers_flush_final_page \else \let\strc_pagenumbers_flush_final_page\relax \fi % ugly
+
+\permanent\protected\def\dostarttext
+ {\enforced\glet\dostarttext\relax
+ \the\everystarttext
+ \global\everystarttext\emptytoks}
+
+\permanent\protected\def\dostoptext
+ {\enforced\glet\dostoptext\relax
+ \strc_pagenumbers_flush_final_page
+ \page % hm, bonus
+ \the\everystoptext
+ \global\everystoptext\emptytoks
+ \the\everybye
+ \global\everybye\emptytoks
+ \the\everygoodbye
+ \global\everygoodbye\emptytoks
+ \doifelsesometoks\everynotabene{\writeline\the\everynotabene\writeline}\donothing
+ % tex's \end:
+ \normalend}
+
+% \starttext % defined at lua end
+% \stoptext % defined at lua end
+% \forcequitjob % defined at lua end
+% \autostarttext % defined at lua end
+% \autostoptext % defined at lua end
+
+\pushoverloadmode
+ \aliased\let\end\forceendjob
+\popoverloadmode
+
+\aliased\let\finishjob\stoptext % nicer in luatex call commandline
+
+\newtoks\everystartnotext
+\newtoks\everystopnotext
+
+\permanent\protected\def\startnotext{\the\everystartnotext}
+\permanent\protected\def\stopnotext {\the\everystopnotext\normalend}
+
+% protect structure
+
+% \processfilemany {#name} % defined at lua end
+% \processfileonce {#name} % defined at lua end
+% \processfilenone {#name} % defined at lua end
+
+% \useproject [#name] % defined at lua end
+% \useproduct [#name] % defined at lua end
+% \usecomponent [#name] % defined at lua end
+% \useenvironment [#name] % defined at lua end
+
+% \project [#name] or #name % defined at lua end
+% \product [#name] or #name % defined at lua end
+% \component [#name] or #name % defined at lua end
+% \environment [#name] or #name % defined at lua end
+
+% \startproject [#name] or #name % defined at lua end
+% \startproduct [#name] or #name % defined at lua end
+% \startcomponent [#name] or #name % defined at lua end
+% \startenvironment [#name] or #name % defined at lua end
+
+\newconditional\endofinput % hack, needed because \endinput happens one level down in the input when we write from lua
+
+% \protected\def\signalendofinput#1% argument just for tracing
+% {\global\settrue\endofinput}
+%
+% \protected\def\honorendofinput
+% {\ifconditional\endofinput
+% \global\setfalse\endofinput
+% \endinput
+% \fi}
+
+% \protected\def\stopproject {\clf_stopproject \honorendofinput} % todo
+% \protected\def\stopproduct {\clf_stopproduct \honorendofinput} % todo
+% \protected\def\stopcomponent {\clf_stopcomponent \honorendofinput} % todo
+% \protected\def\stopenvironment {\clf_stopenvironment\honorendofinput} % todo
+
+% \currentproject % defined at lua end
+% \currentproduct % defined at lua end
+% \currentcomponent % defined at lua end
+% \currentenvironment % defined at lua end
+% \processedfile % defined at lua end
+% \processedfiles % defined at lua end
+%
+% \dostarttextfile #name % defined at lua end
+% \dostoptextfile % defined at lua end
+%
+% \loadtexfile [#name] % defined at lua end
+% \loadluafile [#name] % defined at lua end
+% \loadcldfile [#name] % defined at lua end
+% \loadanyfile [#name] % defined at lua end
+%
+% \loadtexfileonce [#name] % defined at lua end
+% \loadluafileonce [#name] % defined at lua end
+% \loadcldfileonce [#name] % defined at lua end
+% \loadanyfileonce [#name] % defined at lua end
+
+%D Handy for modules that have a test/demo appended (true added).
+
+% \permanent\protected\def\continueifinputfile#name{\clf_doifelsecontinuewithfile{#name}\relax\endinput} % we cannot do \endinput via lua
+
+% \continueifinputfile #name % defined at lua end
+
+% \startproject test
+% 1: \startmode[*project] project \stopmode \endgraf
+% 2: \startmode[*product] product \stopmode \endgraf
+% \stopproject
+
+% A bit weird place:
+
+\neverypar\emptytoks
+
+%D Wrappers (the signal is a synchronization with lua hack):
+
+\newsystemmode\v!project
+\newsystemmode\v!product
+\newsystemmode\v!component
+\newsystemmode\v!environment
+
+\permanent\protected\def\startprojectindeed
+ {%starttext
+ \pushsystemmode\v!project
+ \setsystemmode\v!project}
+
+\permanent\protected\def\stopprojectindeed
+ {\popsystemmode\v!project
+ %stoptext
+ }%\signalendofinput\v!project}
+
+\permanent\protected\def\startproductindeed
+ {\starttext
+ \pushsystemmode\v!product
+ \setsystemmode\v!product}
+
+\permanent\protected\def\stopproductindeed
+ {\popsystemmode\v!product
+ \stoptext
+ }%\signalendofinput\v!product}
+
+\permanent\protected\def\startcomponentindeed
+ {\starttext
+ \pushreferenceprefix\currentcomponent
+ \pushsystemmode\v!component
+ \setsystemmode\v!component}
+
+\permanent\protected\def\stopcomponentindeed
+ {\popsystemmode\v!component
+ \popreferenceprefix
+ \stoptext
+ }%\signalendofinput\v!component}
+
+\permanent\protected\def\startenvironmentindeed
+ {\pushsystemmode\v!environment
+ \setsystemmode\v!environment}
+
+\permanent\protected\def\stopenvironmentindeed
+ {\popsystemmode\v!environment
+ }%\signalendofinput\v!environment}
+
+%D Upgraded after the ctx 2020 meeting:
+%D
+%D \starttyping
+%D \definedocument[thesis]
+%D
+%D \setupdocument[a=b,e=f]
+%D \setupdocument[thesis][a=x,c=d]
+%D
+%D % \startsetups[thesis:start]
+%D \startsetups[document:start]
+%D START
+%D \stopsetups
+%D
+%D \startsetups[thesis:stop]
+%D % \startsetups[document:stop]
+%D STOP
+%D \stopsetups
+%D
+%D % \startdocument[thesis]
+%D \startthesis
+%D (\currentdocument/a): \documentvariable{a}\par
+%D (\currentdocument/c): \documentvariable{c}\par
+%D (\currentdocument/e): \documentvariable{e}\par
+%D \stopthesis
+%D % \stopdocument
+%D \stoptyping
+
+\installcorenamespace {document}
+
+\installcommandhandler \??document \s!document \??document
+
+\setupdocument
+ [\c!before=\directsetup{\s!document:\v!start},
+ \c!after =\directsetup{\s!document:\v!stop}]
+
+% to be discussed:
+%
+% \setupdocument
+% [metadata:title=\documentvariable\c!title,
+% metadata:subject=\documentvariable\c!subtitle,
+% metadata:subtitle=\documentvariable\c!subtitle,
+% metadata:author=\documentvariable\c!author,
+% metadata:authors=\documentvariable\c!author,
+% metadata:keyword=\documentvariable\c!keyword,
+% metadata:keywords=\documentvariable\c!keyword,
+% metadata:date=\documentvariable\c!date]
+
+\def\syst_document_setup#1%
+ {\directsetup{\doifelsesetups{\currentdocument:\v!start}\currentdocument\s!document:\v!start}}
+
+\appendtoks
+ \normalexpanded {%
+ \startsetups[\currentdocument:\v!start]\noexpand\directsetup{\ifempty\currentdocumentparent\s!document\else\currentdocumentparent\fi:\v!start}\stopsetups
+ \startsetups[\currentdocument:\v!stop ]\noexpand\directsetup{\ifempty\currentdocumentparent\s!document\else\currentdocumentparent\fi:\v!stop }\stopsetups
+ \permanent\setvalue{\e!start\currentdocument}{\startdocument[\currentdocument]}%
+ \permanent\setvalue{\e!stop \currentdocument}{\stopdocument}
+ }%
+\to \everydefinedocument
+
+% todo: dostarttagged\t!document
+
+\permanent\tolerant\protected\def\startdocument[#namespace]#spacer[#settings]%
+ {\pushmacro\currentdocument
+ \ifparameters
+ \or
+ \ifhastok={#namespace}%
+ \let\currentdocument\empty
+ \setupcurrentdocument[#namespace]%
+ \else
+ \edef\currentdocument{#namespace}%
+ \fi
+ \or
+ \edef\currentdocument{#namespace}%
+ \setupcurrentdocument[#settings]%
+ \fi
+ \ifempty\currentdocument\else\setmode\currentdocument\fi
+ \starttext
+ \the\everystartdocument
+ \documentvariable\c!before}
+
+\permanent\protected\def\stopdocument % todo: dostoptagged\t!document
+ {\documentvariable\c!after
+ \the\everystopdocument
+ \stoptext
+ \ifempty\currentdocument\else\resetmode\currentdocument\fi
+ \popmacro\currentdocument}
+
+\aliased \let\documentvariable \documentparameter
+\permanent\protected\def\unexpandeddocumentvariable{\documentparameter}
+
+\permanent\protected\def\doifelsedocumentvariable#name{\doifelsesomething{\documentvariable{#name}}}
+\permanent\protected\def\doifdocumentvariable #name{\doifsomething {\documentvariable{#name}}}
+\permanent\protected\def\doifnotdocumentvariable #name{\doifnot {\documentvariable{#name}}}
+
+\aliased\let\doifdocumentvariableelse\doifelsedocumentvariable
+
+\permanent\tolerant\protected\def\presetdocument[#namespace]#spacer[#settings]%
+ {\pushmacro\currentdocument
+ \ifparameters
+ \or
+ \ifhastok={#namespace}%
+ \let\currentdocument\empty
+ \setupcurrentdocument[#namespace]%
+ \fi
+ \or
+ \edef\currentdocument{#namespace}%
+ \setupcurrentdocument[#settings]%
+ \fi
+ \popmacro\currentdocument}
+
+% Bonus:
+
+% \installcorenamespace{samplefile}
+%
+% \protected\def\samplefile#1%
+% {\ifcsname\??samplefile#1\endcsname \else
+% \setxvalue{\??samplefile#1}{\cldloadfile{#1}}%
+% \fi
+% \lastnamedcs}
+
+\permanent\protected\def\samplefile#1{\clf_samplefile{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-lib.mkxl b/Master/texmf-dist/tex/context/base/mkxl/file-lib.mkxl
new file mode 100644
index 00000000000..c2ec555cf2f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-lib.mkxl
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=file-lib, % was core-fil,
+%D version=20110701, % 1997.11.15,
+%D title=\CONTEXT\ File Macros,
+%D subtitle=Module Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt File Macros / Libraries}
+
+\unprotect
+
+\registerctxluafile{file-lib}{}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-mod.lmt b/Master/texmf-dist/tex/context/base/mkxl/file-mod.lmt
new file mode 100644
index 00000000000..6af5d8816e0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-mod.lmt
@@ -0,0 +1,309 @@
+if not modules then modules = { } end modules ['file-mod'] = {
+ version = 1.001,
+ comment = "companion to file-mod.mkvi",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This module will be redone! For instance, the prefixes will move to data-*
+-- as they arr sort of generic along with home:// etc/.
+
+-- context is not defined yet! todo! (we need to load tupp-fil after cld)
+-- todo: move startreadingfile to lua and push regime there
+
+--[[ldx--
+
It's more convenient to manipulate filenames (paths) in
+ than in . These methods have counterparts
+at the side.
+--ldx]]--
+
+local format, find, concat, tonumber = string.format, string.find, table.concat, tonumber
+local sortedhash = table.sortedhash
+local basename = file.basename
+
+local trace_modules = false trackers .register("modules.loading", function(v) trace_modules = v end)
+local permit_unprefixed = false directives.register("modules.permitunprefixed", function(v) permit_unprefixed = v end)
+
+local report = logs.reporter("modules")
+
+local commands = commands
+local context = context
+local implement = interfaces.implement
+
+local findbyscheme = resolvers.finders.byscheme -- use different one
+local iterator = utilities.parsers.iterator
+
+-- modules can have a specific suffix or can specify one
+
+local prefixes = {
+ "m", -- module, extends functionality
+ "p", -- private code
+ "s", -- styles
+ "x", -- xml specific modules
+ -- "v", -- an old internal one for examples
+ "t", -- third party extensions
+}
+
+-- the order might change and how about cld
+
+local suffixes = CONTEXTLMTXMODE > 0 and
+{
+ "mklx", -- preprocessed mkiv lmtx files
+ "mkxl", -- mkiv lmtx files
+ "mkvi", -- preprocessed mkiv files
+ "mkiv", -- mkiv files
+ "tex", -- normally source code files
+ "cld", -- context lua documents (often stand alone)
+ "lua", -- lua files
+}
+ or
+{
+ "mkvi",
+ "mkiv",
+ "tex",
+ "cld",
+ "lua",
+}
+
+-- This controls embedded overloads. Maybe at some point we will limit this to files in the
+-- tree but on the other hand we don't need to be that strict. It is just an extra level
+-- of protection.
+
+local setrunstate = tex.setrunstate
+local level = 0
+
+local function pushrunstate()
+ level = level + 1
+ if level == 1 then
+ setrunstate(1)
+ end
+end
+
+local function poprunstate()
+ if level == 1 then
+ setrunstate(3)
+ end
+ if level > 0 then
+ level = level - 1
+ end
+end
+
+luatex.pushrunstate = pushrunstate
+luatex.poprunstate = poprunstate
+
+tex.setrunstate = function() end
+
+implement { name = "pushrunstate", public = true, protected = true, actions = pushrunstate }
+implement { name = "poprunstate", public = true, protected = true, actions = poprunstate }
+
+-- Till here.
+
+local modstatus = { }
+local missing = false
+
+local function usemodule(name,hasscheme)
+ local foundname
+ if hasscheme then
+ -- no auto suffix as http will return a home page or error page
+ -- so we only add one if missing
+ local fullname = file.addsuffix(name,"tex")
+ if trace_modules then
+ report("checking url %a",fullname)
+ end
+ foundname = resolvers.findtexfile(fullname) or ""
+ elseif file.suffix(name) ~= "" then
+ if trace_modules then
+ report("checking file %a",name)
+ end
+ foundname = findbyscheme("any",name) or ""
+ else
+ for i=1,#suffixes do
+ local fullname = file.addsuffix(name,suffixes[i])
+ if trace_modules then
+ report("checking file %a",fullname)
+ end
+ foundname = findbyscheme("any",fullname) or ""
+ if foundname ~= "" then
+ break
+ end
+ end
+ end
+ if foundname ~= "" then
+ if trace_modules then
+ report("loading file %a",foundname)
+ end
+ context.pushrunstate()
+ context.startreadingfile()
+ resolvers.jobs.usefile(foundname,true) -- once, notext
+ -- context.input(foundname)
+ context.stopreadingfile()
+ context.poprunstate()
+ return true
+ else
+ return false
+ end
+end
+
+function environment.usemodules(prefix,askedname,truename)
+ local truename = truename or environment.truefilename(askedname) or askedname
+ if truename and truename ~= "" then
+ local hasprefix = prefix and prefix ~= ""
+ local hashname = ((hasprefix and prefix) or "*") .. "-" .. truename
+ local status = modstatus[hashname] or false -- yet unset
+ if status == 0 then
+ -- not found
+ elseif status == 1 then
+ status = status + 1
+ else
+ if trace_modules then
+ report("locating, prefix %a, askedname %a, truename %a",prefix,askedname,truename)
+ end
+ local hasscheme = url.hasscheme(truename)
+ if hasscheme then
+ -- no prefix and suffix done
+ if usemodule(truename,true) then
+ status = 1
+ else
+ status = 0
+ end
+ elseif hasprefix then
+ if usemodule(prefix .. "-" .. truename) then
+ status = 1
+ else
+ status = 0
+ end
+ else
+ for i=1,#prefixes do
+ -- todo: reconstruct name i.e. basename
+ local thename = prefixes[i] .. "-" .. truename
+ if usemodule(thename) then
+ status = 1
+ break
+ end
+ end
+ if status then
+ -- ok, don't change
+ elseif find(truename,"-",1,true) and usemodule(truename) then
+ -- assume a user namespace
+ report("using user prefixed file %a",truename)
+ status = 1
+ elseif permit_unprefixed and usemodule(truename) then
+ report("using unprefixed file %a",truename)
+ status = 1
+ else
+ status = 0
+ end
+ end
+ end
+ if status == 0 then
+ missing = true
+ report("%a is not found",askedname)
+ elseif status == 1 then
+ report("%a is loaded",trace_modules and truename or askedname)
+ else
+ report("%a is already loaded",trace_modules and truename or askedname)
+ end
+ modstatus[hashname] = status
+ end
+end
+
+statistics.register("loaded tex modules", function()
+ if next(modstatus) then
+ local t, f, nt, nf = { }, { }, 0, 0
+ for k, v in sortedhash(modstatus) do
+ local b = basename(k)
+ if v == 0 then
+ nf = nf + 1
+ f[nf] = b
+ else
+ nt = nt + 1
+ t[nt] = b
+ end
+ end
+ if nf == 0 then
+ return format("%s requested, all found (%s)",nt,concat(t," "))
+ elseif nt == 0 then
+ return format("%s requested, all missing (%s)",nf,concat(f," "))
+ else
+ return format("%s requested, %s found (%s), %s missing (%s)",nt+nf,nt,concat(t," "),nf,concat(f," "))
+ end
+ else
+ return nil
+ end
+end)
+
+logs.registerfinalactions(function()
+ logs.startfilelogging(report,"used modules")
+ for k, v in sortedhash(modstatus) do
+ report(v == 0 and "missing: %s" or "loaded : %s",basename(k))
+ end
+ logs.stopfilelogging()
+ if missing and logs.loggingerrors() then
+ logs.starterrorlogging(report,"missing modules")
+ for k, v in sortedhash(modstatus) do
+ if v == 0 then
+ report("%w%s",6,basename(k))
+ end
+ end
+ logs.stoperrorlogging()
+ end
+end)
+
+-- moved from syst-lua.lua:
+
+local lpegmatch = lpeg.match
+local splitter = lpeg.tsplitter(lpeg.S(". "),tonumber)
+
+function environment.comparedversion(one,two) -- one >= two
+ if not two or two == "" then
+ one, two = environment.version, one
+ elseif one == "" then
+ one = environment.version
+ end
+ one = lpegmatch(splitter,one)
+ two = lpegmatch(splitter,two)
+ one = (one[1] or 0) * 10000 + (one[2] or 0) * 100 + (one[3] or 0)
+ two = (two[1] or 0) * 10000 + (two[2] or 0) * 100 + (two[3] or 0)
+ if one < two then
+ return -1
+ elseif one > two then
+ return 1
+ else
+ return 0
+ end
+end
+
+environment.comparedversion = comparedversion
+
+
+function environment.useluamodule(list)
+ for filename in iterator(list) do
+ environment.loadluafile(filename)
+ end
+end
+
+implement {
+ name = "usemodules",
+ actions = environment.usemodules,
+ arguments = "2 strings",
+}
+
+implement {
+ name = "doifelseolderversion",
+ actions = function(one,two) commands.doifelse(comparedversion(one,two) >= 0) end,
+ arguments = "2 strings"
+}
+
+implement {
+ name = "useluamodule",
+ actions = environment.useluamodule,
+ arguments = "string"
+}
+
+implement {
+ name = "loadluamodule",
+ actions = function(name) dofile(resolvers.findctxfile(name)) end, -- hack
+ arguments = "string"
+}
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-mod.mklx b/Master/texmf-dist/tex/context/base/mkxl/file-mod.mklx
new file mode 100644
index 00000000000..24471e30f00
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-mod.mklx
@@ -0,0 +1,262 @@
+%D \module
+%D [ file=file-mod, % was core-fil,
+%D version=20110701, % 1997.11.15,
+%D title=\CONTEXT\ File Macros,
+%D subtitle=Module Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt File Macros / Modules}
+
+\unprotect
+
+\registerctxluafile{file-mod}{autosuffix}
+
+%D \macros
+%D {usemodule}
+%D
+%D Most of \CONTEXT is preloaded in the format file. Some very domain specific
+%D typesetting topics are however dealt with in separate modules, e.g. typesetting
+%D of chemical structure formulas. These modules are loaded by:
+%D
+%D \showsetup{usemodule}
+%D
+%D More information on the specific modules can be found in their dedicated manuals.
+%D We use \type {\next} so that we can \type {\end} in modules.
+
+\installcorenamespace{module}
+
+\mutable\let\currentmodule \s!unknown
+\mutable\let\currentmodulecategory \empty
+\mutable\let\currentmoduleparameters\empty
+
+\installmacrostack\currentmodule
+\installmacrostack\currentmodulecategory
+\installmacrostack\currentmoduleparameters
+
+\permanent\tolerant\protected\def\usemodules[#category]#spacer[#name]#spacer[#parameters]% category=t|m|x|p|...
+ {\push_macro_currentmodule
+ \push_macro_currentmodulecategory
+ \push_macro_currentmoduleparameters
+ \ifparameters
+ \let\currentmodule\empty
+ \or
+ \let \currentmodulecategory \empty
+ \edef\currentmodule {#category}%
+ \let \currentmoduleparameters\empty
+ \or
+ \ifhastok={#name}%
+ \let\currentmodulecategory \empty
+ \edef\currentmodule {#category}%
+ \edef\currentmoduleparameters{#name}%
+ \else
+ \edef\currentmodulecategory {#category}%
+ \edef\currentmodule {#name}%
+ \let \currentmoduleparameters\empty
+ \fi
+ \or
+ \edef\currentmodulecategory {#category}%
+ \edef\currentmodule {#name}%
+ \def \currentmoduleparameters{#parameters}%
+ \fi
+ \processcommacommand[\currentmodule]{\strc_modules_use\currentmodulecategory}%
+ \pop_macro_currentmoduleparameters
+ \pop_macro_currentmodulecategory
+ \pop_macro_currentmodule}
+
+\def\strc_modules_use#category#name%
+ {\ifempty\currentmoduleparameters\else
+ \scratchtoks\expandafter{\currentmoduleparameters}%
+ \normalexpanded{\getparameters[\??module#name:][\the\scratchtoks]}%
+ \fi
+ \clf_usemodules{#category}{#name}}
+
+\aliased\let\usemodule \usemodules
+\aliased\let\usetexmodule\usemodules
+
+\newcount\c_syst_modules_nesting
+\newtoks \everysetupmodule
+
+\permanent\tolerant\protected\def\startmodule[#1]#;#2 %
+ {\global\advance\c_syst_modules_nesting\plusone
+ \push_macro_currentmodule
+ \push_macro_currentmoduleparameters
+ \def\currentmodule{#1#2}}
+
+\permanent\protected\def\stopmodule
+ {\ifcase\c_syst_modules_nesting
+ \writestatus\m!system{module wrapping error in '\currentmodule'}%
+ \else
+ \pop_macro_currentmoduleparameters
+ \pop_macro_currentmodule
+ \global\advance\c_syst_modules_nesting\minusone
+ \fi}
+
+\permanent\protected\def\setupmodule % to be lmtx'd
+ {\ifempty\currentmoduleparameters
+ \expandafter\syst_modules_setup_nop
+ \else
+ \expandafter\syst_modules_setup_yes
+ \fi}
+
+\tolerant\def\syst_modules_setup_nop[#name]#spacer[#parameters]%
+ {\ifarguments
+ % nothing
+ \or
+ \doifassignmentelse{#name}{\getparameters[\??module\currentmodule:][#name]}\donothing
+ \or
+ \getparameters[\??module#name:][#parameters]% internal (defaults)
+ \fi
+ \the\everysetupmodule}
+
+\tolerant\def\syst_modules_setup_yes[#name]#spacer[#parameters]%
+ {\scratchtoks\expandafter{\currentmoduleparameters}%
+ \ifparameters
+ \normalexpanded{\getparameters[\??module\currentmodule:][\the\scratchtoks]}%
+ \or
+ \ifhastok={#name}%
+ \getparameters[\??module\currentmodule:][#name]% internal (defaults)
+ \normalexpanded{\getparameters[\??module\currentmodule:][\the\scratchtoks]}% loadtime (user)
+ \else
+ \normalexpanded{\getparameters[\??module#1:][\the\scratchtoks]}% loadtime (user)
+ \fi
+ \or
+ \getparameters[\??module#name:][#parameters]% internal (defaults)
+ \normalexpanded{\getparameters[\??module#name:][\the\scratchtoks]}% loadtime (user)
+ \fi
+ \let\currentmoduleparameters\empty
+ \the\everysetupmodule}
+
+\permanent\def\moduleparameter#name#parameter% should have been \namedmoduleparameter
+ {\begincsname\??module#name:#parameter\endcsname}
+
+\letvalue\??module\empty % so we default to empty as with all parameters
+
+\permanent\def\currentmoduleparameter{\moduleparameter\currentmodule} % no need for inlining
+
+%permanent\protected\def\useluamodule[#name]{\clf_loadluamodule{#1}} % why not use useluamodule
+
+\permanent\protected\def\useluamodule [#name]{\clf_useluamodule{#1}}
+\permanent\protected\def\luaenvironment #name {\clf_loadluamodule{#1}}
+
+% \usemodule[newmml]
+% \usemodule[newmml][a=b]
+% \usemodule[x][newmml]
+% \usemodule[x][newmml][a=b]
+%
+% \startmodule [mathml]
+% \setupmodule[a=c] \relax [\currentmoduleparameter{a}] % user vars will be set afterwards
+% \setupmodule[a=c] \relax [\currentmoduleparameter{a}] % user vars are now forgotten
+% \stopmodule
+
+% one can introduce test sections with:
+%
+% \enablemode[newmml:test:\currentmoduleparameter{test}]
+% \startmode[newmml:test:yes} ... \stopmode
+%
+% these will be ignored unless test=yes
+%
+% however, a better way is:
+
+\permanent\protected\def\startmoduletestsection
+ {\begingroup
+ \setupmodule % we need to make sure that the vars are set
+ \doifelse{\currentmoduleparameter\v!test}\v!yes
+ {\endgroup
+ \writestatus\currentmodule{loading experimental code}}
+ {\endgroup
+ \writestatus\currentmodule{skipping experimental code}%
+ \gobbleuntil\stopmoduletestsection}}
+
+\aliased\let\stopmoduletestsection\donothing
+
+% will become file-run
+
+%D \macros
+%D {doifolderversionelse}
+%D
+%D We start with a macro specially for Aditya who wants to be able
+%D to use development versions of \MKIV\ for real documents.
+%D
+%D \starttyping
+%D \doifolderversionelse\contextversion{1010.10.10} {OLDER} {OKAY} => OLDER
+%D \doifolderversionelse\contextversion{2020.20.20} {OLDER} {OKAY} => OKAY
+%D \doifolderversionelse\contextversion{2020} {OLDER} {OKAY} => OKAY
+%D \stoptyping
+%D
+%D The version pattern is \type {yyyy.mm.dd} (with mm and dd being optional).
+
+\permanent\protected\def\doifelseolderversion#parent#child{\clf_doifelseolderversion{#parent}{#child}}
+\permanent\protected\def\doifelseoldercontext #child{\clf_doifelseolderversion{#child}{}}
+
+\aliased\let\doifolderversionelse\doifelseolderversion
+\aliased\let\doifoldercontextelse\doifelseoldercontext
+
+%D Relatively new (no need for a speedup here). Can't this now be done nicer?
+
+\permanent\protected\def\syst_modules_direct_lua#1#2%
+ {\edef\m_module_command_command {#1}%
+ \edef\m_module_command_function{#2}%
+ \directsetup{module:\m_module_command_command:start}%
+ \ctxlua{\m_module_command_function()}%
+ \directsetup{module:\m_module_command_command:stop}}
+
+\permanent\protected\def\syst_modules_single_lua#1#2%
+ {\edef\m_module_command_command {#1}%
+ \edef\m_module_command_function{#2}%
+ \dosingleempty\syst_modules_single_lua_indeed}
+
+\permanent\protected\def\syst_modules_single_lua_indeed[#1]%
+ {\directsetup{module:\m_module_command_command:start}%
+ \ctxlua{\m_module_command_function(\!!bs#1\!!es)}%
+ \directsetup{module:\m_module_command_command:stop}}
+
+\permanent\protected\def\syst_modules_double_lua#1#2%
+ {\edef\m_module_command_command {#1}%
+ \edef\m_module_command_function{#2}%
+ \dodoubleempty\syst_modules_double_lua_indeed}
+
+\permanent\protected\def\syst_modules_double_lua_indeed[#1][#2]%
+ {\directsetup{module:\m_module_command_command:start}%
+ \ctxlua{\m_module_command_function(\!!bs#1\!!es,\!!bs#2\!!es)}%
+ \directsetup{module:\m_module_command_command:stop}}
+
+\permanent\protected\def\installmodulecommandlua #1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_direct_lua{\csstring#1}{#2}}}}
+\permanent\protected\def\installmodulecommandluasingle#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_single_lua{\csstring#1}{#2}}}}
+\permanent\protected\def\installmodulecommandluadouble#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_double_lua{\csstring#1}{#2}}}}
+
+\protected\def\syst_modules_one_lua#1#2#3%
+ {\directsetup{module:#1:start}%
+ \ctxlua{#2(\!!bs#3\!!es)}%
+ \directsetup{module:#1:stop}}
+
+\protected\def\syst_modules_two_lua#1#2#3#4%
+ {\directsetup{module:#1:start}%
+ \ctxlua{#2(\!!bs#3\!!es,\!!bs#4\!!es)}%
+ \directsetup{module:#1:stop}}
+
+\permanent\protected\def\installmodulecommandluaone#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_one_lua{\csstring#1}{#2}}}}
+\permanent\protected\def\installmodulecommandluatwo#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_two_lua{\csstring#1}{#2}}}}
+
+%D This replaces \type {\fetchruntimecommand}:
+%D
+%D \starttyping
+%D \fetchmodulecommand \csname {module}
+%D \stoptyping
+
+\permanent\protected\def\fetchmodulecommand#1#2%
+ {\mutable\protected\def#1{\syst_fetch_module_command#1{#2}}}
+
+\def\syst_fetch_module_command#1#2% actually a test on #1 being define would be ok as well
+ {%writestatus\m!systems{fetching \string#1}%
+ \usemodule[#2]%
+ #1}
+
+\aliased\let\fetchruntimecommand\fetchmodulecommand % obsolete
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-res.mklx b/Master/texmf-dist/tex/context/base/mkxl/file-res.mklx
new file mode 100644
index 00000000000..a123b5e2213
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-res.mklx
@@ -0,0 +1,145 @@
+%D \module
+%D [ file=file-mod, % was supp-fil,
+%D version=20110701, % 1995.10.10,
+%D title=\CONTEXT\ File Macros,
+%D subtitle=Resolvers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D We could move some more to the lua end (implementors).
+
+\writestatus{loading}{ConTeXt File Macros / Resolvers}
+
+\unprotect
+
+\registerctxluafile{file-res}{}
+
+%D \macros
+%D {readfile,ReadFile}
+%D
+%D One cannot be sure if a file exists. When no file can be found, the \type
+%D {\input} primitive gives an error message and switches to interactive mode. The
+%D macro \type {\readfile} takes care of non||existing files. This macro has two
+%D faces.
+%D
+%D \starttyping
+%D \ReadFile {filename}
+%D \readfile {filename} {before loading} {not found}
+%D \stoptyping
+%D
+%D Many \TEX\ implementations have laid out some strategy for locating files. This
+%D can lead to unexpected results, especially when one loads files that are not
+%D found in the current directory. Let's give an example of this. In \CONTEXT\
+%D illustrations can be defined in an external file. The resizing macro first looks
+%D if an illustration is defined in the local definitions file. When no such file is
+%D found, it searches for a global file and when this file is not found either, the
+%D illustration itself is scanned for dimensions. One can imagine what happens if an
+%D adapted, localy stored illustration, is scaled according to dimensions stored
+%D somewhere else.
+%D
+%D When some \TEX\ implementation starts looking for a file, it normally first looks
+%D in the current directory. When no file is found, \TEX\ starts searching on the
+%D path where format and|/|or style files are stored. Depending on the
+%D implementation this can considerably slow down processing speed.
+%D
+%D In \CONTEXT, we support a project||wise ordening of files. In such an approach it
+%D seems feasible to store common files in a lower directory. When for instance
+%D searching for a general layout file, we therefore have to backtrack.
+%D
+%D These three considerations have lead to a more advanced approach for loading
+%D files.
+%D
+%D We first present an earlier implementation of \type {\readfile}. This command
+%D backtracks parent directories, upto a predefined level. Users can change this
+%D level (on the commandline using a directive); we default to~3.
+%D
+%D We use \type {\normalinput} instead of \type {\input} because we want to be able
+%D to redefine the original \type {\input} when needed, for instance when loading
+%D third party libraries.
+
+\mutable\let\readfilename\empty
+
+\def\syst_files_read_file#protocol#path#name% #true #false
+ {\edef\readfilename{\clf_getreadfilename{#protocol}{#path}{#name}}%
+ \ifempty\readfilename
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\syst_files_read_file_indeed
+ \fi}
+
+\def\syst_files_read_file_indeed#true#false%
+ {#true%
+ \relax
+ \normalinput{\readfilename}%
+ \relax}
+
+%D \macros
+%D {readjobfile,readlocfile,readsysfile,
+%D readfixfile,readsetfile}
+%D
+%D This implementation honnors the third situation, but we still can get unwanted
+%D files loaded and/or can get involved in extensive searching.
+%D
+%D Due to different needs, we decided to offer four alternative loading commands.
+%D With \type {\readjobfile} we load a local file and do no backtracking, while
+%D \type {\readlocfile} backtracks~\number \maxreadlevel\ directories, including the
+%D current one.
+%D
+%D System files can be anywhere and therefore \type {\readsysfile} is not bound to
+%D the current directory and obeys the \TEX\ implementation.
+%D
+%D Of the last two, \type {\readfixfile} searches on the directory specified and
+%D backtracks too, while \type {\readsetfile} does only search on the specified
+%D path.
+%D
+%D The most liberal is \type {\readfile}.
+
+\permanent\protected\def\readjobfile #name{\syst_files_read_file{job} {.}{#name}} % current path, no backtracking
+\permanent\protected\def\readlocfile #name{\syst_files_read_file{loc} {.}{#name}} % current path, backtracking
+\permanent\protected\def\readsysfile #name{\syst_files_read_file{sys} {.}{#name}} % current path, obeys tex search
+\permanent\protected\def\readfixfile#path#name{\syst_files_read_file{fix}{#path}{#name}} % specified path, backtracking
+\permanent\protected\def\readsetfile#path#name{\syst_files_read_file{set}{#path}{#name}} % specified path, no backtracking
+\permanent\protected\def\readfile #name{\syst_files_read_file{any} {.}{#name}}
+\permanent\protected\def\ReadFile #name{\syst_files_read_file{any} {.}{#name}\donothing\donothing}
+
+%D So now we've got ourselves five file loading commands:
+%D
+%D \starttyping
+%D \readfile {filename} {before loading} {not found}
+%D
+%D \readjobfile {filename} {before loading} {not found}
+%D \readlocfile {filename} {before loading} {not found}
+%D \readfixfile {filename} {before loading} {not found}
+%D \readsysfile {directory} {filename} {before loading} {not found}
+%D \stoptyping
+
+\permanent\protected\def\readtexfile#name#true#false%
+ {\pushcatcodetable
+ \catcodetable\ctxcatcodes
+ \readfile{#name}{#true}{#false}%
+ \popcatcodetable}
+
+% \permanent\protected\def\readxmlfile#name#true#false%
+% {\pushcatcodetable
+% \catcodetable\xmlcatcodes
+% \readfile{#name}{#true}{#false}%
+% \popcatcodetable}
+
+%D \macros
+%D {doiflocfileelse,locfilename}
+%D
+%D \starttyping
+%D \doiflocfileelse {filename} {before loading} {not found}
+%D \stoptyping
+
+\permanent\protected\def\doifelselocfile#name{\clf_doifelselocfile{#name}}
+\permanent \def\locfilename #name{\clf_locfilename {#name}}
+
+\aliased\let\doiflocfileelse\doifelselocfile
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/file-syn.mklx b/Master/texmf-dist/tex/context/base/mkxl/file-syn.mklx
new file mode 100644
index 00000000000..25f36f742fc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/file-syn.mklx
@@ -0,0 +1,61 @@
+%D \module
+%D [ file=file-syn, % was core-fil,
+%D version=20110701, % 1997.11.15,
+%D title=\CONTEXT\ File Macros,
+%D subtitle=Module Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt File Macros / Synonyms}
+
+\unprotect
+
+\registerctxluafile{file-syn}{}
+
+%D \macros
+%D {definefilesynonym,definefilefallback}
+%D
+%D One of the problems with loading files is that their names can depend on the
+%D interface language. We therefore need a method to define filesynonyms. The actual
+%D synonyms are defined elsewhere, but look like:
+%D
+%D \starttyping
+%D \definefilesynonym [chemic] [chemie]
+%D \definefilesynonym [einheit] [unit]
+%D \definefilesynonym [unit] [unit]
+%D \stoptyping
+%D
+%D So we can say in english:
+%D
+%D \starttyping
+%D \usemodules[pictex,chemic,unit]
+%D \stoptyping
+%D
+%D and in dutch:
+%D
+%D \starttyping
+%D \usemodules[pictex,chemie,unit]
+%D \stoptyping
+
+\permanent\tolerant\def\definefilesynonym [#name]#spacer[#realname]{\clf_definefilesynonym {#name}{#realname}}
+\permanent\tolerant\def\definefilefallback[#name]#spacer[#alternatives]{\clf_definefilefallback{#name}{#alternatives}}
+
+%D \macros
+%D {truefilename}
+%D
+%D At the system level such a filename can be called upon by saying:
+%D
+%D \starttyping
+%D \truefilename{filename/filesynonym}
+%D \stoptyping
+%D
+%D The implementation shows that nesting is supported.
+
+\permanent\def\truefilename#1{\clf_truefilename{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-aux.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-aux.mklx
new file mode 100644
index 00000000000..caf32510e5c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-aux.mklx
@@ -0,0 +1,26 @@
+%D \module
+%D [ file=font-gds,
+%D version=2012.06.26,
+%D title=\CONTEXT\ Font Support,
+%D subtitle=Helpers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Support / Helpers}
+
+%D Here we collect code moved from other files, like some of the
+%D support modules.
+
+\unprotect
+
+%D Leftovers:
+
+\permanent\protected\def\xbox {\bgroup\aftergroup\egroup\hbox\bgroup\tx \let\next=}
+\permanent\protected\def\xxbox{\bgroup\aftergroup\egroup\hbox\bgroup\txx\let\next=}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-chk.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-chk.lmt
new file mode 100644
index 00000000000..6f927e09764
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-chk.lmt
@@ -0,0 +1,452 @@
+if not modules then modules = { } end modules ['font-chk'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is kind of old but it makes no real sense to upgrade it to for instance
+-- using delayed type 3 fonts in order to be lean and mean and cut'n'paste
+-- compliant. When this kicks one needs to fix the choice of fonts anyway! So,
+-- instead we just keep the method we use but slightly adapted to the backend
+-- of lmtx.
+
+local next = next
+local floor = math.floor
+
+local context = context
+
+local formatters = string.formatters
+local bpfactor = number.dimenfactors.bp
+local fastcopy = table.fastcopy
+local sortedkeys = table.sortedkeys
+local sortedhash = table.sortedhash
+
+local report = logs.reporter("fonts")
+local report_checking = logs.reporter("fonts","checking")
+
+local allocate = utilities.storage.allocate
+
+local fonts = fonts
+
+fonts.checkers = fonts.checkers or { }
+local checkers = fonts.checkers
+
+local fonthashes = fonts.hashes
+local fontdata = fonthashes.identifiers
+local fontcharacters = fonthashes.characters
+
+local currentfont = font.current
+local addcharacters = font.addcharacters
+
+local helpers = fonts.helpers
+
+local addprivate = helpers.addprivate
+local hasprivate = helpers.hasprivate
+local getprivateslot = helpers.getprivateslot
+local getprivatecharornode = helpers.getprivatecharornode
+
+local otffeatures = fonts.constructors.features.otf
+local afmfeatures = fonts.constructors.features.afm
+
+local registerotffeature = otffeatures.register
+local registerafmfeature = afmfeatures.register
+
+local is_character = characters.is_character
+local chardata = characters.data
+
+local tasks = nodes.tasks
+local enableaction = tasks.enableaction
+local disableaction = tasks.disableaction
+
+local implement = interfaces.implement
+
+local glyph_code = nodes.nodecodes.glyph
+
+local hpack_node = node.hpack
+
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+
+local isglyph = nuts.isglyph
+local setchar = nuts.setchar
+
+local nextglyph = nuts.traversers.glyph
+
+local remove_node = nuts.remove
+local insert_node_after = nuts.insert_after
+local insert_node_before = nuts.insert_before
+local copy_node = nuts.copy
+
+local actions = false
+
+-- to tfmdata.properties ?
+
+local function onetimemessage(font,char,message) -- char == false returns table
+ local tfmdata = fontdata[font]
+ local shared = tfmdata.shared
+ if not shared then
+ shared = { }
+ tfmdata.shared = shared
+ end
+ local messages = shared.messages
+ if not messages then
+ messages = { }
+ shared.messages = messages
+ end
+ local category = messages[message]
+ if not category then
+ category = { }
+ messages[message] = category
+ end
+ if char == false then
+ return sortedkeys(category), category
+ end
+ local cc = category[char]
+ if not cc then
+ report_checking("char %C in font %a with id %a: %s",char,tfmdata.properties.fullname,font,message)
+ category[char] = 1
+ else
+ category[char] = cc + 1
+ end
+end
+
+fonts.loggers.onetimemessage = onetimemessage
+
+local fakes = {
+ MissingLowercase = { width = .45, height = .55, depth = .20 },
+ MissingUppercase = { width = .65, height = .70, depth = .25 },
+ MissingMark = { width = .15, height = .70, depth = -.50 },
+ MissingPunctuation = { width = .15, height = .55, depth = .20 },
+ MissingUnknown = { width = .45, height = .20, depth = 0 },
+}
+
+local mapping = allocate {
+ lu = { "MissingUppercase", "darkred" },
+ ll = { "MissingLowercase", "darkred" },
+ lt = { "MissingUppercase", "darkred" },
+ lm = { "MissingLowercase", "darkred" },
+ lo = { "MissingLowercase", "darkred" },
+ mn = { "MissingMark", "darkgreen" },
+ mc = { "MissingMark", "darkgreen" },
+ me = { "MissingMark", "darkgreen" },
+ nd = { "MissingLowercase", "darkblue" },
+ nl = { "MissingLowercase", "darkblue" },
+ no = { "MissingLowercase", "darkblue" },
+ pc = { "MissingPunctuation", "darkcyan" },
+ pd = { "MissingPunctuation", "darkcyan" },
+ ps = { "MissingPunctuation", "darkcyan" },
+ pe = { "MissingPunctuation", "darkcyan" },
+ pi = { "MissingPunctuation", "darkcyan" },
+ pf = { "MissingPunctuation", "darkcyan" },
+ po = { "MissingPunctuation", "darkcyan" },
+ sm = { "MissingLowercase", "darkmagenta" },
+ sc = { "MissingLowercase", "darkyellow" },
+ sk = { "MissingLowercase", "darkyellow" },
+ so = { "MissingLowercase", "darkyellow" },
+}
+
+table.setmetatableindex(mapping, { "MissingUnknown", "darkgray" })
+
+checkers.mapping = mapping
+
+-- We provide access by (private) name for tracing purposes. We also need to make
+-- sure the dimensions are known at the lua and tex end. For previous variants see
+-- the mkiv files or older lmtx files. I decided to just drop the old stuff here.
+
+function checkers.placeholder(font,char)
+ local category = chardata[char].category or "lu" -- todo: unknown
+ local fakedata = mapping[category]
+ local tfmdata = fontdata[font]
+ local units = tfmdata.parameters.units or 1000
+ local slant = (tfmdata.parameters.slant or 0)/65536
+ local scale = units/1000
+ local rawdata = tfmdata.shared and tfmdata.shared.rawdata
+ local weight = (rawdata and rawdata.metadata and rawdata.metadata.pfmweight or 400)/400
+ local specification = {
+ code = "MissingGlyph",
+ scale = scale,
+ slant = slant,
+ weight = weight,
+ namespace = font,
+ shapes = { { shape = fakedata[1], color = fakedata[2] } },
+ }
+ fonts.helpers.setmetaglyphs("missing", font, char, specification)
+end
+
+function checkers.missing(head)
+ local lastfont = nil
+ local characters = nil
+ local found = nil
+ local addplaceholder = checkers.placeholder -- so we can overload
+ if actions.replace or actions.decompose then
+ for n, char, font in nextglyph, head do
+ if font ~= lastfont then
+ lastfont = font
+ characters = fontcharacters[font]
+ end
+ if font > 0 and not characters[char] and is_character[chardata[char].category or "unknown"] then
+ if actions.decompose then
+ local c = chardata[char]
+ if c then
+ local s = c.specials
+ if s and s[1] == "char" then
+ local l = #s
+ if l > 2 then
+ -- check first
+ local okay = true
+ for i=2,l do
+ if not characters[s[i]] then
+ okay = false
+ break
+ end
+ end
+ if okay then
+ -- we work backward
+ local o = n -- we're not supposed to change n (lua 5.4+)
+ onetimemessage(font,char,"missing (decomposed)")
+ setchar(n,s[l])
+ for i=l-1,2,-1 do
+ head, o = insert_node_before(head,o,copy_node(n))
+ setchar(o,s[i])
+ end
+ goto DONE
+ end
+ end
+ end
+ end
+ end
+ if actions.replace then
+ onetimemessage(font,char,"missing (replaced)")
+ local f, c = addplaceholder(font,char)
+ if f and c then
+ setchar(n, c, f)
+ end
+ goto DONE
+ end
+ if actions.remove then
+ onetimemessage(font,char,"missing (deleted)")
+ if not found then
+ found = { n }
+ else
+ found[#found+1] = n
+ end
+ goto DONE
+ end
+ onetimemessage(font,char,"missing (checked)")
+ ::DONE::
+ end
+ end
+ end
+ if found then
+ for i=1,#found do
+ head = remove_node(head,found[i],true)
+ end
+ end
+ return head
+end
+
+local relevant = {
+ "missing (decomposed)",
+ "missing (replaced)",
+ "missing (deleted)",
+ "missing (checked)",
+ "missing",
+}
+
+local function getmissing(id)
+ if id then
+ local list = getmissing(currentfont())
+ if list then
+ local _, list = next(getmissing(currentfont()))
+ return list
+ else
+ return { }
+ end
+ else
+ local t = { }
+ for id, d in next, fontdata do
+ local shared = d.shared
+ local messages = shared and shared.messages
+ if messages then
+ local filename = d.properties.filename
+ if not filename then
+ filename = tostring(d)
+ end
+ local tf = t[filename] or { }
+ for i=1,#relevant do
+ local tm = messages[relevant[i]]
+ if tm then
+ for k, v in next, tm do
+ tf[k] = (tf[k] or 0) + v
+ end
+ end
+ end
+ if next(tf) then
+ t[filename] = tf
+ end
+ end
+ end
+ local l = { }
+ for k, v in next, t do
+ l[k] = sortedkeys(v)
+ end
+ return l, t
+ end
+end
+
+checkers.getmissing = getmissing
+
+do
+
+ local reported = true
+
+ callback.register("glyph_not_found",function(font,char)
+ if font > 0 then
+ if char > 0 then
+ onetimemessage(font,char,"missing")
+ else
+ -- we have a special case
+ end
+ elseif not reported then
+ report("nullfont is used, maybe no bodyfont is defined")
+ reported = true
+ end
+ end)
+
+ local loaded = false
+
+ trackers.register("fonts.missing", function(v)
+ if v then
+ enableaction("processors","fonts.checkers.missing")
+ if v == true then
+ actions = { check = true }
+ else
+ actions = utilities.parsers.settings_to_set(v)
+ if not loaded and actions.replace then
+ metapost.simple("simplefun",'loadfile("mp-miss.mpxl");')
+ loaded = true
+ end
+ end
+ else
+ disableaction("processors","fonts.checkers.missing")
+ actions = false
+ end
+ end)
+
+ logs.registerfinalactions(function()
+ local collected, details = getmissing()
+ if next(collected) then
+ for filename, list in sortedhash(details) do
+ logs.startfilelogging(report,"missing characters",filename)
+ for u, v in sortedhash(list) do
+ report("%4i %U %c %s",v,u,u,chardata[u].description)
+ end
+ logs.stopfilelogging()
+ end
+ if logs.loggingerrors() then
+ for filename, list in sortedhash(details) do
+ logs.starterrorlogging(report,"missing characters",filename)
+ for u, v in sortedhash(list) do
+ report("%4i %U %c %s",v,u,u,chardata[u].description)
+ end
+ logs.stoperrorlogging()
+ end
+ end
+ end
+ end)
+
+end
+
+-- for the moment here
+
+local function expandglyph(characters,index,done)
+ done = done or { }
+ if not done[index] then
+ local data = characters[index]
+ if data then
+ done[index] = true
+ local d = fastcopy(data)
+ local n = d.next
+ if n then
+ d.next = expandglyph(characters,n,done)
+ end
+ local h = d.horiz_variants
+ if h then
+ for i=1,#h do
+ h[i].glyph = expandglyph(characters,h[i].glyph,done)
+ end
+ end
+ local v = d.vert_variants
+ if v then
+ for i=1,#v do
+ v[i].glyph = expandglyph(characters,v[i].glyph,done)
+ end
+ end
+ return d
+ end
+ end
+end
+
+helpers.expandglyph = expandglyph
+
+-- should not be needed as we add .notdef in the engine
+
+local dummyzero = {
+ -- width = 0,
+ -- height = 0,
+ -- depth = 0,
+ commands = { { "special", "" } },
+}
+
+local function adddummysymbols(tfmdata)
+ local characters = tfmdata.characters
+ if not characters[0] then
+ characters[0] = dummyzero
+ end
+ -- if not characters[1] then
+ -- characters[1] = dummyzero -- test only
+ -- end
+end
+
+local dummies_specification = {
+ name = "dummies",
+ description = "dummy symbols",
+ default = true,
+ manipulators = {
+ base = adddummysymbols,
+ node = adddummysymbols,
+ }
+}
+
+registerotffeature(dummies_specification)
+registerafmfeature(dummies_specification)
+
+--
+
+local function addvisualspace(tfmdata)
+ local spacechar = tfmdata.characters[32]
+ if spacechar and not spacechar.commands then
+ local w = spacechar.width
+ local h = tfmdata.parameters.xheight
+ local c = {
+ width = w,
+ commands = { { "rule", h, w } }
+ }
+ local u = addprivate(tfmdata, "visualspace", c)
+ end
+end
+
+local visualspace_specification = {
+ name = "visualspace",
+ description = "visual space",
+ default = true,
+ manipulators = {
+ base = addvisualspace,
+ node = addvisualspace,
+ }
+}
+
+registerotffeature(visualspace_specification)
+registerafmfeature(visualspace_specification)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-chk.mkxl b/Master/texmf-dist/tex/context/base/mkxl/font-chk.mkxl
new file mode 100644
index 00000000000..34d67648270
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-chk.mkxl
@@ -0,0 +1,56 @@
+%D \module
+%D [ file=font-chk,
+%D version=2009.01.02, % moved from font-tra
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Checking,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Checking}
+
+\registerctxluafile{font-chk}{autosuffix}
+
+\tracinglostchars\zerocount
+
+% Use this instead:
+%
+% \definefontfeature[default][default][missing=yes]
+% \enabletrackers[fonts.missing=replace]
+
+\permanent\protected\def\checkmissingcharacters {\enabletrackers[fonts.missing]}
+\permanent\protected\def\removemissingcharacters {\enabletrackers[fonts.missing=remove]}
+\permanent\protected\def\replacemissingcharacters{\enabletrackers[fonts.missing=replace]}
+\permanent\protected\def\handlemissingcharacters {\enabletrackers[fonts.missing={decompose,replace}]}
+
+% \enableexperiments[fonts.compact]
+
+%D \starttyping
+%D \replacemissingcharacters
+%D
+%D \startbuffer
+%D \startlines[before=,after=]
+%D \strut {\tf test \char 12345\ test \char 12346\ test}
+%D \strut {\bf test \char 12345\ test \char 12346\ test}
+%D \strut {\it test \char 12345\ test \char 12346\ test}
+%D \strut {\bi test \char 12345\ test \char 12346\ test}
+%D \strut {test ὀ ρ φ α ν ῖ ο ς test}
+%D \stoplines
+%D \stopbuffer
+%D
+%D \starttext
+%D \startTEXpage[offset=2pt,strut=no]
+%D \getbuffer
+%D \switchtobodyfont[pagella]
+%D \getbuffer
+%D \switchtobodyfont[dejavu]
+%D \getbuffer
+%D \stopTEXpage
+%D \stoptext
+%D \stoptyping
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-col.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-col.lmt
new file mode 100644
index 00000000000..41d3274008c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-col.lmt
@@ -0,0 +1,525 @@
+if not modules then modules = { } end modules ['font-col'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- possible optimization: delayed initialization of vectors
+-- we should also share equal vectors (math)
+
+local context, commands, trackers, logs = context, commands, trackers, logs
+local node, nodes, fonts, characters = node, nodes, fonts, characters
+local file, lpeg, table, string = file, lpeg, table, string
+
+local type, next, tonumber, toboolean = type, next, tonumber, toboolean
+local gmatch = string.gmatch
+local fastcopy = table.fastcopy
+local formatters = string.formatters
+
+local nuts = nodes.nuts
+
+local setfont = nuts.setfont
+
+----- traverse_char = nuts.traverse_char
+local nextchar = nuts.traversers.char
+local getscales = nuts.getscales
+local setscales = nuts.setscales
+local setprop = nuts.setprop
+
+local settings_to_hash = utilities.parsers.settings_to_hash
+
+local trace_collecting = false trackers.register("fonts.collecting", function(v) trace_collecting = v end)
+
+local report_fonts = logs.reporter("fonts","collections")
+
+local texconditionals = tex.conditionals
+
+local enableaction = nodes.tasks.enableaction
+local disableaction = nodes.tasks.disableaction
+
+local collections = fonts.collections or { }
+fonts.collections = collections
+
+local definitions = collections.definitions or { }
+collections.definitions = definitions
+
+local vectors = collections.vectors or { }
+collections.vectors = vectors
+
+local helpers = fonts.helpers
+local charcommand = helpers.commands.char
+local rightcommand = helpers.commands.right
+local addprivate = helpers.addprivate
+local hasprivate = helpers.hasprivate
+local fontpatternhassize = helpers.fontpatternhassize
+
+local hashes = fonts.hashes
+local fontdata = hashes.identifiers
+local fontquads = hashes.quads
+local chardata = hashes.characters
+local propdata = hashes.properties
+local mathparameters = hashes.mathparameters
+
+local currentfont = font.current
+local addcharacters = font.addcharacters
+
+local implement = interfaces.implement
+
+local list = { }
+local current = 0
+local enabled = false
+
+local validvectors = table.setmetatableindex(function(t,k)
+ local v = false
+ if not mathparameters[k] then
+ v = vectors[k]
+ end
+ t[k] = v
+ return v
+end)
+
+local function checkenabled()
+ -- a bit ugly but nicer than a fuzzy state while defining math
+ if next(vectors) then
+ if not enabled then
+ enableaction("processors","fonts.collections.process")
+ enabled = true
+ end
+ else
+ if enabled then
+ disableaction("processors","fonts.collections.process")
+ enabled = false
+ end
+ end
+end
+
+collections.checkenabled = checkenabled
+
+function collections.reset(name,font)
+ if font and font ~= "" then
+ local d = definitions[name]
+ if d then
+ d[font] = nil
+ if not next(d) then
+ definitions[name] = nil
+ end
+ end
+ else
+ definitions[name] = nil
+ end
+end
+
+function collections.define(name,font,ranges,details)
+ -- todo: details -> method=force|conditional rscale=
+ -- todo: remap=name
+ local d = definitions[name]
+ if not d then
+ d = { }
+ definitions[name] = d
+ end
+ if name and trace_collecting then
+ report_fonts("extending collection %a using %a",name,font)
+ end
+ details = settings_to_hash(details)
+ -- todo, combine per font start/stop as arrays
+ local offset = details.offset
+ if type(offset) == "string" then
+ offset = characters.getrange(offset,true) or false
+ else
+ offset = tonumber(offset) or false
+ end
+ local target = details.target
+ if type(target) == "string" then
+ target = characters.getrange(target,true) or false
+ else
+ target = tonumber(target) or false
+ end
+ local rscale = tonumber (details.rscale) or 1
+ local force = toboolean(details.force,true)
+ local check = toboolean(details.check,true)
+ local factor = tonumber(details.factor)
+ local features = details.features
+ for s in gmatch(ranges,"[^, ]+") do
+ local start, stop, description, gaps = characters.getrange(s,true)
+ if start and stop then
+ if trace_collecting then
+ if description then
+ report_fonts("using range %a, slots %U - %U, description %a)",s,start,stop,description)
+ end
+ for i=1,#d do
+ local di = d[i]
+ if (start >= di.start and start <= di.stop) or (stop >= di.start and stop <= di.stop) then
+ report_fonts("overlapping ranges %U - %U and %U - %U",start,stop,di.start,di.stop)
+ end
+ end
+ end
+ d[#d+1] = {
+ font = font,
+ start = start,
+ stop = stop,
+ gaps = gaps,
+ offset = offset,
+ target = target,
+ rscale = rscale,
+ force = force,
+ check = check,
+ method = details.method,
+ factor = factor,
+ features = features,
+ }
+ end
+ end
+end
+
+-- todo: provide a lua variant (like with definefont)
+
+function collections.registermain(name)
+ local last = currentfont()
+ if trace_collecting then
+ report_fonts("registering font %a with name %a",last,name)
+ end
+ list[#list+1] = last
+end
+
+-- check: when true, only set when present in font
+-- force: when false, then not set when already set
+
+local uccodes = characters.uccodes
+local lccodes = characters.lccodes
+
+local methods = {
+ lowercase = function(oldchars,newchars,vector,start,stop,cloneid)
+ for k, v in next, oldchars do
+ if k >= start and k <= stop then
+ local lccode = lccodes[k]
+ if k ~= lccode and newchars[lccode] then
+ vector[k] = { cloneid, lccode }
+ end
+ end
+ end
+ end,
+ uppercase = function(oldchars,newchars,vector,start,stop,cloneid)
+ for k, v in next, oldchars do
+ if k >= start and k <= stop then
+ local uccode = uccodes[k]
+ if k ~= uccode and newchars[uccode] then
+ vector[k] = { cloneid, uccode }
+ end
+ end
+ end
+ end,
+}
+
+function collections.clonevector(name)
+ statistics.starttiming(fonts)
+ if trace_collecting then
+ report_fonts("processing collection %a",name)
+ end
+ local definitions = definitions[name]
+ local vector = { }
+ vectors[current] = vector
+ for i=1,#definitions do
+ local definition = definitions[i]
+ local name = definition.font
+ local start = definition.start
+ local stop = definition.stop
+ local check = definition.check
+ local force = definition.force
+ local offset = definition.offset or start
+ local remap = definition.remap -- not used
+ local target = definition.target
+ local method = definition.method
+ local cloneid = list[i]
+ local oldchars = fontdata[current].characters
+ local newchars = fontdata[cloneid].characters
+ local factor = definition.factor
+ local rscale = definition.rscale
+ if factor then
+ vector.factor = factor
+ end
+ if texconditionals["c_font_compact"] and rscale then
+ vector.rscale = rscale
+ end
+ if trace_collecting then
+ if target then
+ report_fonts("remapping font %a to %a for range %U - %U, offset %X, target %U",current,cloneid,start,stop,offset,target)
+ else
+ report_fonts("remapping font %a to %a for range %U - %U, offset %X",current,cloneid,start,stop,offset)
+ end
+ end
+ if method then
+ method = methods[method]
+ end
+ if method then
+ method(oldchars,newchars,vector,start,stop,cloneid)
+ elseif check then
+ if target then
+ for unicode = start, stop do
+ local unic = unicode + offset - start
+ if not newchars[target] then
+ -- not in font
+ elseif force or (not vector[unic] and not oldchars[unic]) then
+ vector[unic] = { cloneid, target }
+ end
+ target = target + 1
+ end
+ elseif remap then
+ -- not used
+ else
+ for unicode = start, stop do
+ local unic = unicode + offset - start
+ if not newchars[unicode] then
+ -- not in font
+ elseif force or (not vector[unic] and not oldchars[unic]) then
+ vector[unic] = cloneid
+ end
+ end
+ end
+ else
+ if target then
+ for unicode = start, stop do
+ local unic = unicode + offset - start
+ if force or (not vector[unic] and not oldchars[unic]) then
+ vector[unic] = { cloneid, target }
+ end
+ target = target + 1
+ end
+ elseif remap then
+ for unicode = start, stop do
+ local unic = unicode + offset - start
+ if force or (not vector[unic] and not oldchars[unic]) then
+ vector[unic] = { cloneid, remap[unicode] }
+ end
+ end
+ else
+ for unicode = start, stop do
+ local unic = unicode + offset - start
+ if force or (not vector[unic] and not oldchars[unic]) then
+ vector[unic] = cloneid
+ end
+ end
+ end
+ end
+ end
+ if trace_collecting then
+ report_fonts("activating collection %a for font %a",name,current)
+ end
+ statistics.stoptiming(fonts)
+ -- for WS: needs checking
+ if validvectors[current] then
+ checkenabled()
+ end
+end
+
+-- we already have this parser
+--
+-- local spec = (P("sa") + P("at") + P("scaled") + P("at") + P("mo")) * P(" ")^1 * (1-P(" "))^1 * P(" ")^0 * -1
+-- local okay = ((1-spec)^1 * spec * Cc(true)) + Cc(false)
+--
+-- if lpegmatch(okay,name) then
+
+function collections.prepare(name) -- we can do this in lua now .. todo
+ current = currentfont()
+ if vectors[current] then
+ return
+ end
+ local properties = propdata[current]
+ local mathsize = properties.mathsize
+ if mathsize == 1 or mathsize == 2 or mathsize == 3 then
+ return
+ end
+ local d = definitions[name]
+ if d then
+ if trace_collecting then
+ local filename = file.basename(properties.filename or "?")
+ report_fonts("applying collection %a to %a, file %a",name,current,filename)
+ end
+ list = { }
+ context.pushcatcodes("prt") -- context.unprotect()
+ context.font_fallbacks_start_cloning()
+ for i=1,#d do
+ local f = d[i]
+ local name = f.font
+ local scale = f.rscale or 1
+ if texconditionals["c_font_compact"] then
+ scale = 1
+ end
+ if fontpatternhassize(name) then
+ context.font_fallbacks_clone_unique(name,scale)
+ else
+ context.font_fallbacks_clone_inherited(name,scale)
+ end
+ context.font_fallbacks_register_main(name)
+ end
+ context.font_fallbacks_prepare_clone_vectors(name)
+ context.font_fallbacks_stop_cloning()
+ context.popcatcodes() -- context.protect()
+ end
+end
+
+function collections.report(message)
+ if trace_collecting then
+ report_fonts("tex: %s",message)
+ end
+end
+
+local function monoslot(font,char,parent,factor)
+ local tfmdata = fontdata[font]
+ local privatename = formatters["faked mono %s"](char)
+ local privateslot = hasprivate(tfmdata,privatename)
+ if privateslot then
+ return privateslot
+ else
+ local characters = tfmdata.characters
+ local properties = tfmdata.properties
+ local width = factor * fontquads[parent]
+ local character = characters[char]
+ if character then
+ -- runtime patching of the font (can only be new characters)
+ -- instead of messing with existing dimensions
+ local data = {
+ -- no features so a simple copy
+ width = width,
+ height = character.height,
+ depth = character.depth,
+ commands = {
+ rightcommand[(width - character.width or 0)/2],
+ charcommand[char],
+ }
+ }
+ local u = addprivate(tfmdata, privatename, data)
+ addcharacters(properties.id, { characters = { [u] = data } } )
+ return u
+ else
+ return char
+ end
+ end
+end
+
+function collections.register(font,char,handler)
+ if font and char and type(handler) == "function" then
+ local vector = vectors[font]
+ if not vector then
+ vector = { }
+ vectors[font] = vector
+ end
+ vector[char] = handler
+ end
+end
+
+-- todo: also general one for missing
+
+function collections.process(head) -- this way we keep feature processing
+ for n, char, font in nextchar, head do
+ local vector = validvectors[font]
+ if vector then
+ local vect = vector[char]
+ if vect then
+ local kind = type(vect)
+ local newfont, newchar
+ if kind == "table" then
+ newfont = vect[1]
+ newchar = vect[2]
+ if trace_collecting then
+ report_fonts("remapping character %C in font %a to character %C in font %a%s",
+ char,font,newchar,newfont,not chardata[newfont][newchar] and " (missing)" or ""
+ )
+ end
+ elseif kind == "function" then
+ newfont, newchar = vect(font,char,vector)
+ if not newfont then
+ newfont = font
+ end
+ if not newchar then
+ newchar = char
+ end
+ if trace_collecting then
+ report_fonts("remapping character %C in font %a to character %C in font %a%s",
+ char,font,newchar,newfont,not chardata[newfont][newchar] and " (missing)" or ""
+ )
+ end
+ vector[char] = { newfont, newchar }
+ else
+ local fakemono = vector.factor
+ if trace_collecting then
+ report_fonts("remapping font %a to %a for character %C%s",
+ font,vect,char,not chardata[vect][char] and " (missing)" or ""
+ )
+ end
+ newfont = vect
+ if fakemono then
+ newchar = monoslot(vect,char,font,fakemono)
+ else
+ newchar = char
+ end
+ end
+ local rscale = vector.rscale
+ if rscale and rscale ~= 1 then
+ local s, x, y = getscales(n)
+ setscales(n,s*rscale,x*rscale,y*rscale)
+ end
+ setfont(n,newfont,newchar)
+ setprop(n, "original", { font = font, char = char })
+ end
+ end
+ end
+ return head
+end
+
+function collections.found(font,char) -- this way we keep feature processing
+ if not char then
+ font, char = currentfont(), font
+ end
+ if chardata[font][char] then
+ return true -- in normal font
+ else
+ local v = vectors[font]
+ return v and v[char] and true or false
+ end
+end
+
+-- interface
+
+implement {
+ name = "fontcollectiondefine",
+ actions = collections.define,
+ arguments = "4 strings",
+}
+
+implement {
+ name = "fontcollectionreset",
+ actions = collections.reset,
+ arguments = "2 strings",
+}
+
+implement {
+ name = "fontcollectionprepare",
+ actions = collections.prepare,
+ arguments = "string"
+}
+
+implement {
+ name = "fontcollectionreport",
+ actions = collections.report,
+ arguments = "string"
+}
+
+implement {
+ name = "fontcollectionregister",
+ actions = collections.registermain,
+ arguments = "string"
+}
+
+implement {
+ name = "fontcollectionclone",
+ actions = collections.clonevector,
+ arguments = "string"
+}
+
+implement {
+ name = "doifelsecharinfont",
+ actions = { collections.found, commands.doifelse },
+ arguments = "integer"
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-col.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-col.mklx
new file mode 100644
index 00000000000..e6500dd7620
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-col.mklx
@@ -0,0 +1,150 @@
+%D \module
+%D [ file=font-col,
+%D version=2008.06.11,
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Fallbacks (collections),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo : missing only, force always, multiple fallbacks with test, scale
+% beware : only english key/values
+%
+% \resetfontfallback [whatever]
+%
+% \definefontfallback [whatever] [Slanted] [0x0060-0x007F] [force=yes]
+% \definefontfallback [whatever] [Bold] [0x0080-0x00FF,0x00A0-0x00AF] [rscale=1.2]
+% \definefontfallback [whatever] [BoldSlanted] [0x00C0-0x00C7] [check=yes,force=yes]
+%
+% \definefontfeature [emboldened] [effect={width=0.1,delta=0.4,factor=0.3}]
+% \definefontsynonym [SansEmboldened] [Sans] [features=emboldened]
+% \definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
+% \definefontsynonym [SansCaps] [file:MyriadPro-Regular.otf] [fallbacks=FakeSansCaps]
+
+\writestatus{loading}{ConTeXt Font Macros / Collections}
+
+\registerctxluafile{font-col}{autosuffix}
+
+\unprotect
+
+\permanent\tolerant\protected\def\definefontfallback[#name]#spacer[#font]#spacer[#ranges]#spacer[#settings]%
+ {\let\mathsizesuffix\relax
+ \clf_fontcollectiondefine{#name}{#font}{#ranges}{#settings}%
+ \let\mathsizesuffix\empty}
+
+\permanent\tolerant\protected\def\resetfontfallback[#name]#spacer[#font]%
+ {\clf_fontcollectionreset{#name}{#font}}
+
+\def\font_fallbacks_prepare#name%
+ {\clf_fontcollectionprepare{#name}} % add fallbacks to last font
+
+% we might as well move the handling to lua but then we need to pass the
+% fallbacks, skewchar etc.
+
+\newconditional\c_font_fallbacks_in_progress
+
+\def\font_fallbacks_prepare_indeed#fallbacks%
+ {\begingroup
+ \settrue\c_font_fallbacks_in_progress
+ \lastrawfontcall % sets current font id
+ \font_fallbacks_prepare#fallbacks%
+ \endgroup}
+
+\let\m_font_fallbacks\empty % set in the font-ini
+
+\appendtoks
+ \ifconditional\c_font_fallbacks_in_progress\else
+ \ifempty\m_font_fallbacks
+ \ifempty\m_font_class_fallbacks\else
+ \font_fallbacks_prepare_indeed\m_font_class_fallbacks
+ \fi
+ \else
+ \font_fallbacks_prepare_indeed\m_font_fallbacks
+ \fi
+ \fi
+\to\everydefinefont
+
+\let\m_font_fallbacks_spec\empty
+
+\def\font_fallbacks_start_cloning
+ {\begingroup
+ \let\m_font_fallbacks_spec\somefontspec}
+
+\def\font_fallbacks_stop_cloning
+ {\endgroup}
+
+\def\font_fallbacks_clone_unique#specification#scale% kind of dododefinefont
+ {\clf_fontcollectionreport{defining #specification (relative scale: #scale)}% brrr
+ \setfalse\c_font_auto_size
+ \let\lastfontidentifier\s!dummy
+ \def\v_font_size_relative{#scale}%
+ \let\v_font_size_absolute\fontbody
+ \font_helpers_low_level_define{#specification}\v_font_identifier_basic
+ \csname\v_font_identifier_basic\endcsname
+ \setfalse\c_font_auto_size} % no \setfontcharacteristics and \the\everyfontswitch needed
+
+\def\font_fallbacks_clone_inherited#font% also a second argument
+ {\font_fallbacks_clone_unique{#font \m_font_fallbacks_spec}}
+
+\def\font_fallbacks_register_main #name{\clf_fontcollectionregister{#name}}
+\def\font_fallbacks_prepare_clone_vectors#name{\clf_fontcollectionclone{#name}}
+
+% math (experiment, todo clf_)
+
+\def\font_fallbacks_register_math#1#2#3#4%
+ {\doifelsenothing{#3}%
+ {\definedfont[#2 at #4sp]}%
+ {\definedfont[#2*#3\space at #4\scaledpoint]}%
+ \clf_registerfontfallbackid#1\space\fontid\font\space{#2}}
+
+% \def\font_fallbacks_finish_math
+% {\ctxlua{mathematics.finishfallbacks()}}
+
+% check : only replace when present in replacement font (default: no)
+% force : force replacent even when basefont has glyph (default: yes)
+
+% \definefontfallback [whatever] [Slanted] [0x0060-0x007F] [force=yes]
+% \definefontfallback [whatever] [Bold] [0x0080:0x00FF,0x00A0:0x00AF] [rscale=2.0]
+% \definefontfallback [whatever] [BoldSlanted] ["00C0-"00C7] [check=yes,force=yes]
+% \definefontfallback [whatever] [Mono] [latinextendeda] [force=yes] % 0x0100:0x017F
+% \definefontfallback [whatever] [Mono] [latin extended a] [force=yes] % 0x0100:0x017F
+%
+% \definefontsynonym[SerifPlus][Serif][fallbacks=whatever]
+%
+% \showfont[SerifPlus][all]
+
+% \definefontfeature[zh][mode=node,script=hang,lang=zhs]
+% \definefontfallback[serifwhatever] [lmroman10-regular] [0x0000-0x0400][force=yes]
+% \definefontfallback[serifboldwhatever] [lmroman10-bold] [0x0000-0x0400][force=yes]
+% \definefontfallback[serifitalicwhatever] [lmroman10-italic] [0x0000-0x0400][force=yes]
+% \definefontfallback[serifbolditalicwhatever][lmroman10-bolditalic][0x0000-0x0400][force=yes]
+%
+% \starttypescript [serif] [zhfont]
+% \definefontsynonym [zhserif] [AdobeSongStd-Light] [features=zh,fallbacks=serifwhatever]
+% \definefontsynonym [zhserifbold] [AdobeHeitiStd-Regular][features=zh,fallbacks=serifboldwhatever]
+% \definefontsynonym [zhserifitalic] [AdobeKaitiStd-Regular][features=zh,fallbacks=serifitalicwhatever]
+% \definefontsynonym [zhserifbolditalic][AdobeHeitiStd-Regular][features=zh,fallbacks=serifbolditalicwhatever]
+% \stoptypescript
+%
+% \starttypescript [serif][zhfont][name]
+% \definefontsynonym[Serif] [zhserif] % [fallbacks=serifwhatever]
+% \definefontsynonym[SerifBold] [zhserifbold] % [fallbacks=serifboldwhatever]
+% \definefontsynonym[SerifItalic] [zhserifitalic] % [fallbacks=serifitalicwhatever]
+% \definefontsynonym[SerifBoldItalic] [zhserifbolditalic] % [fallbacks=serifbolditalicwhatever]
+% \stoptypescript
+%
+% \starttypescript[myfont]
+% \definetypeface[myfont][rm][serif][zhfont]
+% \stoptypescript
+%
+% \usetypescript[myfont] \setupbodyfont[myfont,rm,12pt]
+%
+% \starttext
+% fonts {\bf fonts} {\bi fonts} {\it fonts}
+% \stoptext
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-con.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-con.lmt
new file mode 100644
index 00000000000..bebc4e4984f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-con.lmt
@@ -0,0 +1,1508 @@
+if not modules then modules = { } end modules ['font-con'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- some names of table entries will be changed (no _)
+
+local next, tostring, tonumber, rawget = next, tostring, tonumber, rawget
+local format, match, lower, gsub, find = string.format, string.match, string.lower, string.gsub, string.find
+local sort, insert, concat = table.sort, table.insert, table.concat
+local sortedkeys, sortedhash, serialize, fastcopy = table.sortedkeys, table.sortedhash, table.serialize, table.fastcopy
+local derivetable = table.derive
+local ioflush = io.flush
+local round = math.round
+local setmetatable, getmetatable, rawget, rawset = setmetatable, getmetatable, rawget, rawset
+
+local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
+local trace_scaling = false trackers.register("fonts.scaling", function(v) trace_scaling = v end)
+
+local report_defining = logs.reporter("fonts","defining")
+
+-- watch out: no negative depths and negative eights permitted in regular fonts
+
+--[[ldx--
+
Here we only implement a few helper functions.
+--ldx]]--
+
+local fonts = fonts
+local constructors = fonts.constructors or { }
+fonts.constructors = constructors
+local handlers = fonts.handlers or { } -- can have preloaded tables
+fonts.handlers = handlers
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+
+-- will be directives
+
+constructors.version = 1.01
+constructors.cache = containers.define("fonts", "constructors", constructors.version, false)
+
+constructors.privateoffset = fonts.privateoffsets.textbase or 0xF0000
+
+-- This might become an interface:
+
+local designsizes = allocate()
+constructors.designsizes = designsizes
+local loadedfonts = allocate()
+constructors.loadedfonts = loadedfonts
+
+----- scalecommands = fonts.helpers.scalecommands
+
+--[[ldx--
+
We need to normalize the scale factor (in scaled points). This has to
+do with the fact that uses a negative multiple of 1000 as
+a signal for a font scaled based on the design size.
+--ldx]]--
+
+local factors = {
+ pt = 65536.0,
+ bp = 65781.8,
+}
+
+function constructors.setfactor(f)
+ constructors.factor = factors[f or 'pt'] or factors.pt
+end
+
+constructors.setfactor()
+
+function constructors.scaled(scaledpoints, designsize) -- handles designsize in sp as well
+ if scaledpoints < 0 then
+ local factor = constructors.factor
+ if designsize then
+ if designsize > factor then -- or just 1000 / when? mp?
+ return (- scaledpoints/1000) * designsize -- sp's
+ else
+ return (- scaledpoints/1000) * designsize * factor
+ end
+ else
+ return (- scaledpoints/1000) * 10 * factor
+ end
+ else
+ return scaledpoints
+ end
+end
+
+function constructors.getprivate(tfmdata)
+ local properties = tfmdata.properties
+ local private = properties.private
+ properties.private = private + 1
+ return private
+end
+
+function constructors.setmathparameter(tfmdata,name,value)
+ local m = tfmdata.mathparameters
+ local c = tfmdata.MathConstants
+ if m then
+ m[name] = value
+ end
+ if c and c ~= m then
+ c[name] = value
+ end
+end
+
+function constructors.getmathparameter(tfmdata,name)
+ local p = tfmdata.mathparameters or tfmdata.MathConstants
+ if p then
+ return p[name]
+ end
+end
+
+--[[ldx--
+
Beware, the boundingbox is passed as reference so we may not overwrite it
+in the process; numbers are of course copies. Here 65536 equals 1pt. (Due to
+excessive memory usage in CJK fonts, we no longer pass the boundingbox.)
+--ldx]]--
+
+-- The scaler is only used for otf and afm and virtual fonts. If a virtual font has italic
+-- correction make sure to set the hasitalics flag. Some more flags will be added in the
+-- future.
+
+--[[ldx--
+
The reason why the scaler was originally split, is that for a while we experimented
+with a helper function. However, in practice the calls are too slow to
+make this profitable and the based variant was just faster. A days
+wasted day but an experience richer.
+--ldx]]--
+
+-- experimental, sharing kerns (unscaled and scaled) saves memory
+-- local sharedkerns, basekerns = constructors.check_base_kerns(tfmdata)
+-- loop over descriptions (afm and otf have descriptions, tfm not)
+-- there is no need (yet) to assign a value to chr.tonunicode
+
+-- constructors.prepare_base_kerns(tfmdata) -- optimalization
+
+-- we have target.name=metricfile and target.fullname=RealName and target.filename=diskfilename
+-- when collapsing fonts, luatex looks as both target.name and target.fullname as ttc files
+-- can have multiple subfonts
+
+function constructors.calculatescale(tfmdata,scaledpoints)
+ -- implemented in font-ctx.lmt
+end
+
+function constructors.assignmathparameters(target,original)
+ -- implemented in math-act.lua
+end
+
+function constructors.beforecopyingcharacters(target,original)
+ -- can be used for additional tweaking
+end
+
+function constructors.aftercopyingcharacters(target,original)
+ -- can be used for additional tweaking
+end
+
+function constructors.trytosharefont(target,tfmdata)
+ -- implemented in font-def.lmt
+end
+
+local synonyms = {
+ exheight = "x_height",
+ xheight = "x_height",
+ ex = "x_height",
+ emwidth = "quad",
+ em = "quad",
+ spacestretch = "space_stretch",
+ stretch = "space_stretch",
+ spaceshrink = "space_shrink",
+ shrink = "space_shrink",
+ extraspace = "extra_space",
+ xspace = "extra_space",
+ slantperpoint = "slant",
+}
+
+function constructors.enhanceparameters(parameters)
+ local mt = getmetatable(parameters)
+ local getter = function(t,k)
+ if not k then
+ return nil
+ end
+ local s = synonyms[k]
+ if s then
+ return rawget(t,s) or (mt and mt[s]) or nil
+ end
+ if k == "spacing" then
+ return {
+ width = t.space,
+ stretch = t.space_stretch,
+ shrink = t.space_shrink,
+ extra = t.extra_space,
+ }
+ end
+ return mt and mt[k] or nil
+ end
+ local setter = function(t,k,v)
+ if not k then
+ return 0
+ end
+ local s = synonyms[k]
+ if s then
+ rawset(t,s,v)
+ elseif k == "spacing" then
+ if type(v) == "table" then
+ rawset(t,"space",v.width or 0)
+ rawset(t,"space_stretch",v.stretch or 0)
+ rawset(t,"space_shrink",v.shrink or 0)
+ rawset(t,"extra_space",v.extra or 0)
+ end
+ else
+ rawset(t,k,v)
+ end
+ end
+ setmetatable(parameters, {
+ __index = getter,
+ __newindex = setter,
+ })
+end
+
+local function mathkerns(v,vdelta)
+ local k = { }
+ for i=1,#v do
+ local entry = v[i]
+ local height = entry.height
+ local kern = entry.kern
+ k[i] = {
+ height = height and vdelta*height or 0,
+ kern = kern and vdelta*kern or 0,
+ }
+ end
+ return k
+end
+
+local psfake = 0
+
+local function fixedpsname(psname,fallback)
+ local usedname = psname
+ if psname and psname ~= "" then
+ if find(psname," ",1,true) then
+ usedname = gsub(psname,"[%s]+","-")
+ else
+ -- we assume that the name is sane enough (we might sanitize completely some day)
+ end
+ elseif not fallback or fallback == "" then
+ psfake = psfake + 1
+ psname = "fakename-" .. psfake
+ else
+ -- filenames can be a mess so we do a drastic cleanup
+ psname = fallback
+ usedname = gsub(psname,"[^a-zA-Z0-9]+","-")
+ end
+ return usedname, psname ~= usedname
+end
+
+function constructors.scale(tfmdata,specification)
+ local target = { } -- the new table
+ --
+ if tonumber(specification) then
+ specification = { size = specification }
+ end
+ target.specification = specification
+ --
+ local scalecommands = fonts.helpers.scalecommands -- defined later
+ --
+ local scaledpoints = specification.size
+ local relativeid = specification.relativeid
+ --
+ local properties = tfmdata.properties or { }
+ local goodies = tfmdata.goodies or { }
+ local resources = tfmdata.resources or { }
+ local descriptions = tfmdata.descriptions or { } -- bad news if empty
+ local characters = tfmdata.characters or { } -- bad news if empty
+ local changed = tfmdata.changed or { } -- for base mode
+ local shared = tfmdata.shared or { }
+ local parameters = tfmdata.parameters or { }
+ local mathparameters = tfmdata.mathparameters or { }
+ --
+ local targetcharacters = { }
+ local targetdescriptions = derivetable(descriptions)
+ local targetparameters = derivetable(parameters)
+ local targetproperties = derivetable(properties)
+ local targetgoodies = goodies -- we need to loop so no metatable
+ target.characters = targetcharacters
+ target.descriptions = targetdescriptions
+ target.parameters = targetparameters
+ -- target.mathparameters = targetmathparameters -- happens elsewhere
+ target.properties = targetproperties
+ target.goodies = targetgoodies
+ target.shared = shared
+ target.resources = resources
+ target.unscaled = tfmdata -- the original unscaled one
+ --
+ -- specification.mathsize : 1=text 2=script 3=scriptscript
+ -- specification.textsize : natural (text)size
+ -- parameters.mathsize : 1=text 2=script 3=scriptscript >1000 enforced size (feature value other than yes)
+ --
+ local mathsize = tonumber(specification.mathsize) or 0
+ local textsize = tonumber(specification.textsize) or scaledpoints
+ local forcedsize = tonumber(parameters.mathsize ) or 0 -- can be set by the feature "mathsize"
+ local extrafactor = tonumber(specification.factor ) or 1
+ if (mathsize == 2 or forcedsize == 2) and parameters.scriptpercentage then
+ scaledpoints = parameters.scriptpercentage * textsize / 100
+ elseif (mathsize == 3 or forcedsize == 3) and parameters.scriptscriptpercentage then
+ scaledpoints = parameters.scriptscriptpercentage * textsize / 100
+ elseif forcedsize > 1000 then -- safeguard
+ scaledpoints = forcedsize
+ else
+ -- in context x and xx also use mathsize
+ end
+ targetparameters.mathsize = mathsize
+ targetparameters.textsize = textsize
+ targetparameters.forcedsize = forcedsize
+ targetparameters.extrafactor = extrafactor
+ --
+ local defaultwidth = resources.defaultwidth or 0
+ local defaultheight = resources.defaultheight or 0
+ local defaultdepth = resources.defaultdepth or 0
+ local units = parameters.units or 1000
+ --
+ -- boundary keys are no longer needed as we now have a string 'right_boundary'
+ -- that can be used in relevant tables (kerns and ligatures) ... not that I ever
+ -- used them
+ --
+ -- boundarychar_label = 0, -- not needed
+ -- boundarychar = 65536, -- there is now a string 'right_boundary'
+ -- false_boundarychar = 65536, -- produces invalid tfm in luatex
+ --
+ targetproperties.language = properties.language or "dflt" -- inherited
+ targetproperties.script = properties.script or "dflt" -- inherited
+ targetproperties.mode = properties.mode or "base" -- inherited
+ targetproperties.method = properties.method
+ --
+ local askedscaledpoints = scaledpoints
+ local scaledpoints, delta = constructors.calculatescale(tfmdata,scaledpoints,nil,specification) -- no shortcut, dan be redefined
+ --
+ local hdelta = delta
+ local vdelta = delta
+ --
+ target.designsize = parameters.designsize -- not really needed so it might become obsolete
+ target.units = units
+ --
+ target.size = scaledpoints
+ --
+ target.subfont = properties.subfont
+ target.cidinfo = properties.cidinfo
+ target.format = properties.format
+ --
+ local original = properties.original or tfmdata.original
+ local fontname = properties.fontname or tfmdata.fontname
+ local fullname = properties.fullname or tfmdata.fullname
+ local filename = properties.filename or tfmdata.filename
+ local psname = properties.psname or tfmdata.psname
+ local name = properties.name or tfmdata.name
+ --
+ -- The psname used in pdf file as well as for selecting subfont in ttc although
+ -- we don't need that subfont look up here (mapfile stuff).
+ --
+ local psname, psfixed = fixedpsname(psname,fontname or fullname or file.nameonly(filename))
+ --
+ target.original = original
+ target.fontname = fontname
+ target.fullname = fullname
+ target.filename = filename
+ target.psname = psname
+ target.name = name
+ --
+ properties.fontname = fontname
+ properties.fullname = fullname
+ properties.filename = filename
+ properties.psname = psname
+ properties.name = name
+ -- expansion (hz)
+ local expansion = parameters.expansion
+ if expansion then
+ target.stretch = expansion.stretch
+ target.shrink = expansion.shrink
+ target.step = expansion.step
+ end
+ -- slanting
+ local slantfactor = parameters.slantfactor or 0
+ if slantfactor ~= 0 then
+ target.slant = slantfactor * 1000
+ else
+ target.slant = 0
+ end
+ -- widening
+ local extendfactor = parameters.extendfactor or 0
+ if extendfactor ~= 0 and extendfactor ~= 1 then
+ hdelta = hdelta * extendfactor
+ target.extend = extendfactor * 1000
+ else
+ target.extend = 1000 -- extent ?
+ end
+ -- squeezing
+ local squeezefactor = parameters.squeezefactor or 0
+ if squeezefactor ~= 0 and squeezefactor ~= 1 then
+ vdelta = vdelta * squeezefactor
+ target.squeeze = squeezefactor * 1000
+ else
+ target.squeeze = 1000 -- extent ?
+ end
+ -- effects
+ local mode = parameters.mode or 0
+ if mode ~= 0 then
+ target.mode = mode
+ end
+ local width = parameters.width or 0
+ if width ~= 0 then
+ target.width = width * delta * 1000 / 655360
+ end
+ --
+ targetparameters.factor = delta
+ targetparameters.hfactor = hdelta
+ targetparameters.vfactor = vdelta
+ targetparameters.size = scaledpoints
+ targetparameters.units = units
+ targetparameters.scaledpoints = askedscaledpoints
+ targetparameters.mode = mode
+ targetparameters.width = width
+ --
+ local hasquality = parameters.expansion or parameters.protrusion
+ local hasitalics = properties.hasitalics
+ local autoitalicamount = properties.autoitalicamount
+ local stackmath = not properties.nostackmath
+ local haskerns = properties.haskerns or properties.mode == "base" -- we can have afm in node mode
+ local hasligatures = properties.hasligatures or properties.mode == "base" -- we can have afm in node mode
+ local realdimensions = properties.realdimensions
+ local writingmode = properties.writingmode or "horizontal"
+ --
+ if changed and not next(changed) then
+ changed = false
+ end
+ --
+ target.writingmode = writingmode == "vertical" and "vertical" or "horizontal"
+ --
+ target.postprocessors = tfmdata.postprocessors
+ --
+ local targetslant = (parameters.slant or parameters[1] or 0) * factors.pt -- per point
+ local targetspace = (parameters.space or parameters[2] or 0) * hdelta
+ local targetspace_stretch = (parameters.space_stretch or parameters[3] or 0) * hdelta
+ local targetspace_shrink = (parameters.space_shrink or parameters[4] or 0) * hdelta
+ local targetx_height = (parameters.x_height or parameters[5] or 0) * vdelta
+ local targetquad = (parameters.quad or parameters[6] or 0) * hdelta
+ local targetextra_space = (parameters.extra_space or parameters[7] or 0) * hdelta
+ --
+ targetparameters.slant = targetslant -- slantperpoint
+ targetparameters.space = targetspace
+ targetparameters.space_stretch = targetspace_stretch
+ targetparameters.space_shrink = targetspace_shrink
+ targetparameters.x_height = targetx_height
+ targetparameters.quad = targetquad
+ targetparameters.extra_space = targetextra_space
+ --
+ local hshift = parameters.hshift
+ if hshift then
+ targetparameters.hshift = delta * hshift
+ end
+ local vshift = parameters.vshift
+ if vshift then
+ targetparameters.vshift = delta * vshift
+ end
+ --
+ local ascender = parameters.ascender
+ if ascender then
+ targetparameters.ascender = delta * ascender
+ end
+ local descender = parameters.descender
+ if descender then
+ targetparameters.descender = delta * descender
+ end
+ --
+ constructors.enhanceparameters(targetparameters) -- official copies for us, now virtual
+ --
+ local scaledwidth = defaultwidth * hdelta
+ local scaledheight = defaultheight * vdelta
+ local scaleddepth = defaultdepth * vdelta
+ --
+ local hasmath = (properties.hasmath or next(mathparameters)) and true
+ --
+ if hasmath then
+ constructors.assignmathparameters(target,tfmdata) -- does scaling and whatever is needed
+
+ properties.hasmath = true
+ target.nomath = false
+ target.MathConstants = target.mathparameters
+
+ properties.compactmath = true
+ target.compactmath = true
+
+ local textscale = parameters.textscale -- or 1000
+ local scriptscale = parameters.scriptscale -- or 700
+ local scriptscriptscale = parameters.scriptscriptscale -- or 500
+
+ parameters.textscale = textscale
+ parameters.scriptscale = scriptscale
+ parameters.scriptscriptscale = scriptscriptscale
+
+ target.textscale = textscale
+ target.scriptscale = scriptscale
+ target.scriptscriptscale = scriptscriptscale
+
+ targetparameters.textscale = textscale
+ targetparameters.scriptscale = scriptscale
+ targetparameters.scriptscriptscale = scriptscriptscale
+
+ -- todo: maybe retrofit to font-con.lua
+
+ local oldmath = properties.oldmath
+ targetproperties.oldmath = oldmath
+ target.oldmath = oldmath
+
+ else
+ properties.hasmath = false
+ target.nomath = true
+ target.mathparameters = nil -- nop
+ end
+ --
+ -- During the transition to opentype the engine had troubles with italics so we had some
+ -- additional code for fixing that. In node mode (text) we don't care much if italics gets
+ -- passed because the engine does nothing with them then.
+ --
+ if hasmath then
+ local mathitalics = properties.mathitalics
+ if mathitalics == false then
+ if trace_defining then
+ report_defining("%s italics %s for font %a, fullname %a, filename %a","math",hasitalics and "ignored" or "disabled",name,fullname,filename)
+ end
+ hasitalics = false
+ autoitalicamount = false
+ end
+ else
+ local textitalics = properties.textitalics
+ if textitalics == false then
+ if trace_defining then
+ report_defining("%s italics %s for font %a, fullname %a, filename %a","text",hasitalics and "ignored" or "disabled",name,fullname,filename)
+ end
+ hasitalics = false
+ autoitalicamount = false
+ end
+ end
+ --
+ -- end of context specific trickery
+ --
+ if trace_defining then
+ report_defining("defining tfm, name %a, fullname %a, filename %a, %spsname %a, hscale %a, vscale %a, math %a, italics %a",
+ name,fullname,filename,psfixed and "(fixed) " or "",psname,hdelta,vdelta,
+ hasmath and "enabled" or "disabled",hasitalics and "enabled" or "disabled")
+ end
+ --
+ constructors.beforecopyingcharacters(target,tfmdata)
+ --
+ local sharedkerns = { }
+ --
+ -- we can have a dumb mode (basemode without math etc) that skips most
+ --
+ for unicode, character in next, characters do
+ local chr, description, index
+ if changed then
+ local c = changed[unicode]
+ if c and c ~= unicode then
+ if c then
+ description = descriptions[c] or descriptions[unicode] or character
+ character = characters[c] or character
+ index = description.index or c
+ else
+ description = descriptions[unicode] or character
+ index = description.index or unicode
+ end
+ else
+ description = descriptions[unicode] or character
+ index = description.index or unicode
+ end
+ else
+ description = descriptions[unicode] or character
+ index = description.index or unicode
+ end
+ local width = description.width
+ local height = description.height
+ local depth = description.depth
+ local isunicode = description.unicode
+ if realdimensions then
+ -- this is mostly for checking issues
+ if not height or height == 0 then
+ local bb = description.boundingbox
+ local ht = bb[4]
+ if ht ~= 0 then
+ height = ht
+ end
+ if not depth or depth == 0 then
+ local dp = -bb[2]
+ if dp ~= 0 then
+ depth = dp
+ end
+ end
+ elseif not depth or depth == 0 then
+ local dp = -description.boundingbox[2]
+ if dp ~= 0 then
+ depth = dp
+ end
+ end
+ end
+ if width then width = hdelta*width else width = scaledwidth end
+ if height then height = vdelta*height else height = scaledheight end
+ -- if depth then depth = vdelta*depth else depth = scaleddepth end
+ if depth and depth ~= 0 then
+ depth = delta*depth
+ if isunicode then
+ chr = {
+ index = index,
+ height = height,
+ depth = depth,
+ width = width,
+ unicode = isunicode,
+ }
+ else
+ chr = {
+ index = index,
+ height = height,
+ depth = depth,
+ width = width,
+ }
+ end
+ else
+ if isunicode then
+ chr = {
+ index = index,
+ height = height,
+ width = width,
+ unicode = isunicode,
+ }
+ else
+ chr = {
+ index = index,
+ height = height,
+ width = width,
+ }
+ end
+ end
+ if hasquality then
+ -- we could move these calculations elsewhere (saves calculations)
+ local ve = character.expansion_factor
+ if ve then
+ chr.expansion_factor = ve*1000 -- expansionfactor, hm, can happen elsewhere
+ end
+ local vl = character.left_protruding
+ if vl then
+ chr.left_protruding = width*vl
+ end
+ local vr = character.right_protruding
+ if vr then
+ chr.right_protruding = width*vr
+ end
+ end
+ --
+ if hasmath then
+ --
+ -- todo, just operate on descriptions.math
+ local vn = character.next
+ if vn then
+ chr.next = vn
+ else
+ local vv = character.vert_variants
+ if vv then
+ local t = { }
+ for i=1,#vv do
+ local vvi = vv[i]
+ local s = vvi["start"] or 0
+ local e = vvi["end"] or 0
+ local a = vvi["advance"] or 0
+ t[i] = { -- zero check nicer for 5.3
+ ["start"] = s == 0 and 0 or s * vdelta,
+ ["end"] = e == 0 and 0 or e * vdelta,
+ ["advance"] = a == 0 and 0 or a * vdelta,
+ ["extender"] = vvi["extender"],
+ ["glyph"] = vvi["glyph"],
+ }
+ end
+ chr.vert_variants = t
+ else
+ local hv = character.horiz_variants
+ if hv then
+ local t = { }
+ for i=1,#hv do
+ local hvi = hv[i]
+ local s = hvi["start"] or 0
+ local e = hvi["end"] or 0
+ local a = hvi["advance"] or 0
+ t[i] = { -- zero check nicer for 5.3
+ ["start"] = s == 0 and 0 or s * hdelta,
+ ["end"] = e == 0 and 0 or e * hdelta,
+ ["advance"] = a == 0 and 0 or a * hdelta,
+ ["extender"] = hvi["extender"],
+ ["glyph"] = hvi["glyph"],
+ }
+ end
+ chr.horiz_variants = t
+ end
+ end
+ -- todo also check mathitalics (or that one can go away)
+ end
+ local vi = character.vert_italic
+ if vi and vi ~= 0 then
+ chr.vert_italic = vi*hdelta
+ end
+ local va = character.accent
+ if va then
+ chr.top_accent = vdelta*va
+ end
+ if stackmath then
+ local mk = character.mathkerns
+ if mk then
+ local tr = mk.topright
+ local tl = mk.topleft
+ local br = mk.bottomright
+ local bl = mk.bottomleft
+ chr.mathkern = { -- singular -> should be patched in luatex !
+ top_right = tr and mathkerns(tr,vdelta) or nil,
+ top_left = tl and mathkerns(tl,vdelta) or nil,
+ bottom_right = br and mathkerns(br,vdelta) or nil,
+ bottom_left = bl and mathkerns(bl,vdelta) or nil,
+ }
+ end
+ end
+ if hasitalics then
+ local vi = character.italic
+ if vi and vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ end
+ elseif autoitalicamount then -- itlc feature
+ local vi = description.italic
+ if not vi then
+ local bb = description.boundingbox
+ if bb then
+ local vi = bb[3] - description.width + autoitalicamount
+ if vi > 0 then -- < 0 indicates no overshoot or a very small auto italic
+ chr.italic = vi*hdelta
+ end
+ else
+ -- report_defining("no boundingbox for character %C in font %a, fullname %a, filename %a",unicode,name,fullname,filename)
+ end
+ elseif vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ elseif hasitalics then -- unlikely
+ local vi = character.italic
+ if vi and vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ end
+ if haskerns then
+ local vk = character.kerns
+ if vk then
+ local s = sharedkerns[vk]
+ if not s then
+ s = { }
+ for k,v in next, vk do s[k] = v*hdelta end
+ sharedkerns[vk] = s
+ end
+ chr.kerns = s
+ end
+ end
+ if hasligatures then
+ local vl = character.ligatures
+ if vl then
+ if true then
+ chr.ligatures = vl -- shared
+ else
+ local tt = { }
+ for i, l in next, vl do
+ tt[i] = l
+ end
+ chr.ligatures = tt
+ end
+ end
+ end
+ local vc = character.commands
+ if vc then
+ chr.commands = scalecommands(vc,hdelta,vdelta)
+ end
+ targetcharacters[unicode] = chr
+ end
+ --
+ properties.setitalics = hasitalics -- for postprocessing
+ --
+ -- if hasmath then properties.mode = "none" end -- possible optimization but it needs testing
+ --
+ constructors.aftercopyingcharacters(target,tfmdata)
+ --
+ constructors.trytosharefont(target,tfmdata)
+ --
+ -- catch inconsistencies (for now)
+ --
+ local vfonts = target.fonts
+ if not vfonts or #vfonts == 0 then
+ target.fonts = { { id = 0 } }
+ end
+ --
+ return target
+end
+
+function constructors.finalize(tfmdata)
+ if tfmdata.properties and tfmdata.properties.finalized then
+ return
+ end
+ --
+ if not tfmdata.characters then
+ return nil
+ end
+ --
+ if not tfmdata.goodies then
+ tfmdata.goodies = { }
+ end
+ --
+ local parameters = tfmdata.parameters
+ if not parameters then
+ return nil
+ end
+ --
+ if not parameters.expansion then
+ parameters.expansion = {
+ stretch = tfmdata.stretch or 0,
+ shrink = tfmdata.shrink or 0,
+ step = tfmdata.step or 0,
+ }
+ end
+ --
+ if not parameters.size then
+ parameters.size = tfmdata.size
+ end
+ --
+ if not parameters.mode then
+ parameters.mode = 0
+ end
+ --
+ if not parameters.width then
+ parameters.width = 0
+ end
+ --
+ if not parameters.slantfactor then
+ parameters.slantfactor = (tfmdata.slant or 0)/1000
+ end
+ --
+ if not parameters.extendfactor then
+ parameters.extendfactor = (tfmdata.extend or 1000)/1000
+ end
+ --
+ if not parameters.squeezefactor then
+ parameters.squeezefactor = (tfmdata.squeeze or 1000)/1000
+ end
+ --
+ local designsize = parameters.designsize
+ if designsize then
+ parameters.minsize = tfmdata.minsize or designsize
+ parameters.maxsize = tfmdata.maxsize or designsize
+ else
+ designsize = factors.pt * 10
+ parameters.designsize = designsize
+ parameters.minsize = designsize
+ parameters.maxsize = designsize
+ end
+ parameters.minsize = tfmdata.minsize or parameters.designsize
+ parameters.maxsize = tfmdata.maxsize or parameters.designsize
+ --
+ if not parameters.units then
+ parameters.units = tfmdata.units or 1000
+ end
+ --
+ if not tfmdata.descriptions then
+ local descriptions = { } -- yes or no
+ setmetatableindex(descriptions, function(t,k) local v = { } t[k] = v return v end)
+ tfmdata.descriptions = descriptions
+ end
+ --
+ local properties = tfmdata.properties
+ if not properties then
+ properties = { }
+ tfmdata.properties = properties
+ end
+ --
+ properties.fontname = properties.fontname or tfmdata.fontname
+ properties.filename = properties.filename or tfmdata.filename
+ properties.fullname = properties.fullname or tfmdata.fullname
+ properties.name = properties.name or tfmdata.name
+ properties.psname = properties.psname or tfmdata.psname
+ --
+ properties.subfont = tfmdata.subfont or nil
+ properties.cidinfo = tfmdata.cidinfo or nil
+ properties.format = tfmdata.format or "type1"
+ properties.writingmode = tfmdata.writingmode or "horizontal"
+ properties.usedbitmap = tfmdata.usedbitmap
+ --
+ if not tfmdata.resources then
+ tfmdata.resources = { }
+ end
+ if not tfmdata.shared then
+ tfmdata.shared = { }
+ end
+ --
+ -- tfmdata.fonts
+ -- tfmdata.unscaled
+ --
+ if not properties.hasmath then
+ properties.hasmath = not tfmdata.nomath
+ end
+ --
+ tfmdata.MathConstants = nil
+ tfmdata.postprocessors = nil
+ --
+ tfmdata.fontname = nil
+ tfmdata.filename = nil
+ tfmdata.fullname = nil
+ tfmdata.name = nil -- most tricky part
+ tfmdata.psname = nil
+ --
+ tfmdata.subfont = nil
+ tfmdata.cidinfo = nil
+ tfmdata.format = nil
+ tfmdata.nomath = nil
+ tfmdata.designsize = nil
+ --
+ tfmdata.size = nil
+ tfmdata.stretch = nil
+ tfmdata.shrink = nil
+ tfmdata.step = nil
+ tfmdata.slant = nil
+ tfmdata.extend = nil
+ tfmdata.squeeze = nil
+ tfmdata.mode = nil
+ tfmdata.width = nil
+ tfmdata.units = nil
+ --
+ tfmdata.cache = nil
+ --
+ properties.finalized = true
+ --
+ return tfmdata
+end
+
+--[[ldx--
+
A unique hash value is generated by:
+--ldx]]--
+
+local hashmethods = { }
+constructors.hashmethods = hashmethods
+
+function constructors.hashfeatures(specification) -- will be overloaded
+ local features = specification.features
+ if features then
+ local t, n = { }, 0
+ for category, list in sortedhash(features) do
+ if next(list) then
+ local hasher = hashmethods[category]
+ if hasher then
+ local hash = hasher(list)
+ if hash then
+ n = n + 1
+ t[n] = category .. ":" .. hash
+ end
+ end
+ end
+ end
+ if n > 0 then
+ return concat(t," & ")
+ end
+ end
+ return "unknown"
+end
+
+hashmethods.normal = function(list)
+ local s = { }
+ local n = 0
+ for k, v in next, list do
+ if not k then
+ -- no need to add to hash
+ elseif k == "number" or k == "features" then
+ -- no need to add to hash (maybe we need a skip list)
+ else
+ n = n + 1
+ if type(v) == "table" then
+ -- table.sequenced
+ local t = { }
+ local m = 0
+ for k, v in next, v do
+ m = m + 1
+ t[m] = k .. '=' .. tostring(v)
+ end
+ sort(t)
+ s[n] = k .. '={' .. concat(t,",") .. "}"
+ else
+ s[n] = k .. '=' .. tostring(v)
+ end
+ end
+ end
+ if n > 0 then
+ sort(s)
+ return concat(s,"+")
+ end
+end
+
+--[[ldx--
+
In principle we can share tfm tables when we are in need for a font, but then
+we need to define a font switch as an id/attr switch which is no fun, so in that
+case users can best use dynamic features ... so, we will not use that speedup. Okay,
+when we get rid of base mode we can optimize even further by sharing, but then we
+loose our testcases for .
+--ldx]]--
+
+function constructors.hashinstance(specification,force)
+ -- implemented in font-ctx.lmt
+end
+
+function constructors.setname(tfmdata,specification)
+ -- dummy (still called in generic font-otl)
+end
+
+function constructors.checkedfilename(data)
+ local foundfilename = data.foundfilename
+ if not foundfilename then
+ local askedfilename = data.filename or ""
+ if askedfilename ~= "" then
+ askedfilename = resolvers.resolve(askedfilename) -- no shortcut
+ foundfilename = resolvers.findbinfile(askedfilename,"") or ""
+ if foundfilename == "" then
+ report_defining("source file %a is not found",askedfilename)
+ foundfilename = resolvers.findbinfile(file.basename(askedfilename),"") or ""
+ if foundfilename ~= "" then
+ report_defining("using source file %a due to cache mismatch",foundfilename)
+ end
+ end
+ end
+ data.foundfilename = foundfilename
+ end
+ return foundfilename
+end
+
+local formats = allocate()
+fonts.formats = formats
+
+setmetatableindex(formats, function(t,k)
+ local l = lower(k)
+ if rawget(t,k) then
+ t[k] = l
+ return l
+ end
+ return rawget(t,file.suffix(l))
+end)
+
+do
+
+ local function setindeed(mode,source,target,group,name,position)
+ local action = source[mode]
+ if not action then
+ return
+ end
+ local t = target[mode]
+ if not t then
+ report_defining("fatal error in setting feature %a, group %a, mode %a",name,group,mode)
+ os.exit()
+ elseif position then
+ -- todo: remove existing
+ insert(t, position, { name = name, action = action })
+ else
+ for i=1,#t do
+ local ti = t[i]
+ if ti.name == name then
+ ti.action = action
+ return
+ end
+ end
+ insert(t, { name = name, action = action })
+ end
+ end
+
+ local function set(group,name,target,source)
+ target = target[group]
+ if not target then
+ report_defining("fatal target error in setting feature %a, group %a",name,group)
+ os.exit()
+ end
+ local source = source[group]
+ if not source then
+ report_defining("fatal source error in setting feature %a, group %a",name,group)
+ os.exit()
+ end
+ local position = source.position
+ setindeed("node",source,target,group,name,position)
+ setindeed("base",source,target,group,name,position)
+ setindeed("plug",source,target,group,name,position)
+ end
+
+ local function register(where,specification)
+ local name = specification.name
+ if name and name ~= "" then
+ local default = specification.default
+ local description = specification.description
+ local initializers = specification.initializers
+ local processors = specification.processors
+ local manipulators = specification.manipulators
+ local modechecker = specification.modechecker
+ if default then
+ where.defaults[name] = default
+ end
+ if description and description ~= "" then
+ where.descriptions[name] = description
+ end
+ if initializers then
+ set('initializers',name,where,specification)
+ end
+ if processors then
+ set('processors', name,where,specification)
+ end
+ if manipulators then
+ set('manipulators',name,where,specification)
+ end
+ if modechecker then
+ where.modechecker = modechecker
+ end
+ end
+ end
+
+ constructors.registerfeature = register
+
+ function constructors.getfeatureaction(what,where,mode,name)
+ what = handlers[what].features
+ if what then
+ where = what[where]
+ if where then
+ mode = where[mode]
+ if mode then
+ for i=1,#mode do
+ local m = mode[i]
+ if m.name == name then
+ return m.action
+ end
+ end
+ end
+ end
+ end
+ end
+
+ local newfeatures = { }
+ constructors.newfeatures = newfeatures -- downward compatible
+ constructors.features = newfeatures
+
+ local function setnewfeatures(what)
+ local handler = handlers[what]
+ local features = handler.features
+ if not features then
+ local tables = handler.tables -- can be preloaded
+ local statistics = handler.statistics -- can be preloaded
+ features = allocate {
+ defaults = { },
+ descriptions = tables and tables.features or { },
+ used = statistics and statistics.usedfeatures or { },
+ initializers = { base = { }, node = { }, plug = { } },
+ processors = { base = { }, node = { }, plug = { } },
+ manipulators = { base = { }, node = { }, plug = { } },
+ finalizers = { base = { }, node = { }, plug = { } },
+ }
+ features.register = function(specification) return register(features,specification) end
+ handler.features = features -- will also become hidden
+ end
+ return features
+ end
+
+ setmetatable(newfeatures, {
+ __call = function(t,k) local v = t[k] return v end,
+ __index = function(t,k) local v = setnewfeatures(k) t[k] = v return v end,
+ })
+
+end
+
+do
+
+ local newhandler = { }
+ constructors.handlers = newhandler -- downward compatible
+ constructors.newhandler = newhandler
+
+ local function setnewhandler(what) -- could be a metatable newindex
+ local handler = handlers[what]
+ if not handler then
+ handler = { }
+ handlers[what] = handler
+ end
+ return handler
+ end
+
+ setmetatable(newhandler, {
+ __call = function(t,k) local v = t[k] return v end,
+ __index = function(t,k) local v = setnewhandler(k) t[k] = v return v end,
+ })
+
+end
+
+do
+ -- a pitty that we need to be generic as we have nicer mechanisms for this ...
+
+ local newenhancer = { }
+ constructors.enhancers = newenhancer
+ constructors.newenhancer = newenhancer
+
+ local function setnewenhancer(format)
+
+ local handler = handlers[format]
+ local enhancers = handler.enhancers
+
+ if not enhancers then
+
+ local actions = allocate() -- no need to allocate thee
+ local before = allocate()
+ local after = allocate()
+ local order = allocate()
+ local known = { }
+ local nofsteps = 0
+ local patches = { before = before, after = after }
+
+ local trace = false
+ local report = logs.reporter("fonts",format .. " enhancing")
+
+ trackers.register(format .. ".loading", function(v) trace = v end)
+
+ local function enhance(name,data,filename,raw)
+ local enhancer = actions[name]
+ if enhancer then
+ if trace then
+ report("apply enhancement %a to file %a",name,filename)
+ ioflush()
+ end
+ enhancer(data,filename,raw)
+ else
+ -- no message as we can have private ones
+ end
+ end
+
+ local function apply(data,filename,raw)
+ local basename = file.basename(lower(filename))
+ if trace then
+ report("%s enhancing file %a","start",filename)
+ end
+ ioflush() -- we want instant messages
+ for e=1,nofsteps do
+ local enhancer = order[e]
+ local b = before[enhancer]
+ if b then
+ for pattern, action in next, b do
+ if find(basename,pattern) then
+ action(data,filename,raw)
+ end
+ end
+ end
+ enhance(enhancer,data,filename,raw) -- we have one installed: check extra features
+ local a = after[enhancer]
+ if a then
+ for pattern, action in next, a do
+ if find(basename,pattern) then
+ action(data,filename,raw)
+ end
+ end
+ end
+ ioflush() -- we want instant messages
+ end
+ if trace then
+ report("%s enhancing file %a","stop",filename)
+ end
+ ioflush() -- we want instant messages
+ end
+
+ local function register(what,action)
+ if action then
+ if actions[what] then
+ -- overloading, e.g."check extra features"
+ else
+ nofsteps = nofsteps + 1
+ order[nofsteps] = what
+ known[what] = nofsteps
+ end
+ actions[what] = action
+ else
+ report("bad enhancer %a",what)
+ end
+ end
+
+ -- We used to have a lot of enhancers but no longer with the new font loader. The order of enhancers
+ -- is the order of definition. The before/after patches are there for old times sake and happen
+ -- before or after a (named) enhancer. An example of a set enhancer is "check extra features" so one
+ -- one set patches before or after that is applied. Unknown enhancers are auto-registered. It's a bit
+ -- messy but we keep it for compatibility reasons.
+ --
+ -- fonts.handlers.otf.enhancers.patches.register("before","some patches","somefont",function(data,filename)
+ -- print("!!!!!!!") -- before | after
+ -- end)
+ --
+ -- fonts.handlers.otf.enhancers.register("more patches",function(data,filename)
+ -- print("???????") -- enhance
+ -- end)
+
+ local function patch(what,where,pattern,action)
+ local pw = patches[what]
+ if pw then
+ local ww = pw[where]
+ if ww then
+ ww[pattern] = action
+ else
+ pw[where] = { [pattern] = action }
+ if not known[where] then
+ nofsteps = nofsteps + 1
+ order[nofsteps] = where
+ known[where] = nofsteps
+ end
+ end
+ end
+ end
+
+ enhancers = {
+ register = register,
+ apply = apply,
+ patch = patch,
+ report = report,
+ patches = {
+ register = patch,
+ report = report,
+ }, -- for old times sake
+ }
+
+ handler.enhancers = enhancers
+ end
+ return enhancers
+ end
+
+ setmetatable(newenhancer, {
+ __call = function(t,k) local v = t[k] return v end,
+ __index = function(t,k) local v = setnewenhancer(k) t[k] = v return v end,
+ })
+
+end
+
+--[[ldx--
+
We need to check for default features. For this we provide
+a helper function.
+--ldx]]--
+
+function constructors.checkedfeatures(what,features)
+ local defaults = handlers[what].features.defaults
+ if features and next(features) then
+ features = fastcopy(features) -- can be inherited (mt) but then no loops possible
+ for key, value in next, defaults do
+ if features[key] == nil then
+ features[key] = value
+ end
+ end
+ return features
+ else
+ return fastcopy(defaults) -- we can change features in place
+ end
+end
+
+-- before scaling
+
+function constructors.initializefeatures(what,tfmdata,features,trace,report)
+ if features and next(features) then
+ local properties = tfmdata.properties or { } -- brrr
+ local whathandler = handlers[what]
+ local whatfeatures = whathandler.features
+ local whatmodechecker = whatfeatures.modechecker
+ -- properties.mode can be enforces (for instance in font-otd)
+ local mode = properties.mode or (whatmodechecker and whatmodechecker(tfmdata,features,features.mode)) or features.mode or "base"
+ properties.mode = mode -- also status
+ features.mode = mode -- both properties.mode or features.mode can be changed
+ --
+ local done = { }
+ while true do
+ local redo = false
+ local initializers = whatfeatures.initializers[mode]
+ if initializers then
+ for i=1,#initializers do
+ local step = initializers[i]
+ local feature = step.name
+-- we could intercept mode here .. needs a rewrite of this whole loop then but it's cleaner that way
+ local value = features[feature]
+ if not value then
+ -- disabled
+ elseif done[feature] then
+ -- already done
+ else
+ local action = step.action
+ if trace then
+ report("initializing feature %a to %a for mode %a for font %a",feature,
+ value,mode,tfmdata.properties.fullname)
+ end
+ action(tfmdata,value,features) -- can set mode (e.g. goodies) so it can trigger a restart
+ if mode ~= properties.mode or mode ~= features.mode then
+ if whatmodechecker then
+ properties.mode = whatmodechecker(tfmdata,features,properties.mode) -- force checking
+ features.mode = properties.mode
+ end
+ if mode ~= properties.mode then
+ mode = properties.mode
+ redo = true
+ end
+ end
+ done[feature] = true
+ end
+ if redo then
+ break
+ end
+ end
+ if not redo then
+ break
+ end
+ else
+ break
+ end
+ end
+ properties.mode = mode -- to be sure
+ return true
+ else
+ return false
+ end
+end
+
+-- while typesetting
+
+function constructors.collectprocessors(what,tfmdata,features,trace,report)
+ local processes = { }
+ local nofprocesses = 0
+ if features and next(features) then
+ local properties = tfmdata.properties
+ local whathandler = handlers[what]
+ local whatfeatures = whathandler.features
+ local whatprocessors = whatfeatures.processors
+ local mode = properties.mode
+ local processors = whatprocessors[mode]
+ if processors then
+ for i=1,#processors do
+ local step = processors[i]
+ local feature = step.name
+ if features[feature] then
+ local action = step.action
+ if trace then
+ report("installing feature processor %a for mode %a for font %a",feature,mode,tfmdata.properties.fullname)
+ end
+ if action then
+ nofprocesses = nofprocesses + 1
+ processes[nofprocesses] = action
+ end
+ end
+ end
+ elseif trace then
+ report("no feature processors for mode %a for font %a",mode,properties.fullname)
+ end
+ end
+ return processes
+end
+
+-- after scaling
+
+local function apply(key,what,tfmdata,features,trace,report)
+ if features and next(features) then
+ local properties = tfmdata.properties
+ local whathandler = handlers[what]
+ local whatfeatures = whathandler.features
+ local whatactions = whatfeatures[key]
+ local mode = properties.mode
+ local actions = whatactions[mode]
+ if actions then
+ for i=1,#actions do
+ local step = actions[i]
+ local feature = step.name
+ local value = features[feature]
+ if value then
+ local action = step.action
+ if trace then
+ report("applying feature %s %a for mode %a for font %a",key,feature,mode,properties.fullname)
+ end
+ if action then
+ action(tfmdata,feature,value)
+ end
+ end
+ end
+ end
+ end
+end
+
+function constructors.applymanipulators(what,tfmdata,features,trace,report)
+ if features and next(features) then
+ apply("manipulators",what,tfmdata,features,trace,report)
+ end
+end
+
+function constructors.applyfinalizers(what,tfmdata,features,trace,report)
+ if features and next(features) then
+ apply("finalizers",what,tfmdata,features,trace,report)
+ end
+end
+
+function constructors.addcoreunicodes(unicodes) -- maybe make this a metatable if used at all
+ if not unicodes then
+ unicodes = { }
+ end
+ unicodes.space = 0x0020
+ unicodes.hyphen = 0x002D
+ unicodes.zwj = 0x200D
+ unicodes.zwnj = 0x200C
+ return unicodes
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ctx.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-ctx.lmt
new file mode 100644
index 00000000000..b735e3d2f91
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ctx.lmt
@@ -0,0 +1,3231 @@
+if not modules then modules = { } end modules ['font-ctx'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- At some point I will clean up the code here so that at the tex end
+-- the table interface is used.
+--
+-- Todo: make a proper 'next id' mechanism (register etc) or wait till 'true'
+-- in virtual fonts indices is implemented.
+--
+-- Olders code can be found in the mkiv lua variant.
+
+local tostring, next, type, rawget, tonumber = tostring, next, type, rawget, tonumber
+
+local format, gmatch, match, find, lower, upper, gsub, byte, topattern = string.format, string.gmatch, string.match, string.find, string.lower, string.upper, string.gsub, string.byte, string.topattern
+local concat, serialize, sort, fastcopy, mergedtable = table.concat, table.serialize, table.sort, table.fastcopy, table.merged
+local sortedhash, sortedkeys, sequenced = table.sortedhash, table.sortedkeys, table.sequenced
+local parsers = utilities.parsers
+local settings_to_hash, hash_to_string, settings_to_array = parsers.settings_to_hash, parsers.hash_to_string, parsers.settings_to_array
+local formatcolumns = utilities.formatters.formatcolumns
+local mergehashes = utilities.parsers.mergehashes
+local formatters = string.formatters
+local basename = file.basename
+
+local utfchar, utfbyte = utf.char, utf.byte
+local round = math.round
+
+local context, commands = context, commands
+
+local P, R, S, C, Cc, Cf, Cg, Ct, Cs, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cf, lpeg.Cg, lpeg.Ct, lpeg.Cs, lpeg.match
+
+local trace_features = false trackers.register("fonts.features", function(v) trace_features = v end)
+local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
+local trace_designsize = false trackers.register("fonts.designsize", function(v) trace_designsize = v end)
+local trace_usage = false trackers.register("fonts.usage", function(v) trace_usage = v end)
+local trace_mapfiles = false trackers.register("fonts.mapfiles", function(v) trace_mapfiles = v end)
+local trace_automode = false trackers.register("fonts.automode", function(v) trace_automode = v end)
+local trace_merge = false trackers.register("fonts.merge", function(v) trace_merge = v end)
+
+local report = logs.reporter("fonts")
+local report_features = logs.reporter("fonts","features")
+local report_cummulative = logs.reporter("fonts","cummulative")
+local report_defining = logs.reporter("fonts","defining")
+local report_status = logs.reporter("fonts","status")
+local report_mapfiles = logs.reporter("fonts","mapfiles")
+
+local setmetatableindex = table.setmetatableindex
+
+local implement = interfaces.implement
+
+local chardata = characters.data
+
+local fonts = fonts
+local handlers = fonts.handlers
+local otf = handlers.otf -- brrr
+local afm = handlers.afm -- brrr
+local tfm = handlers.tfm -- brrr
+local names = fonts.names
+local definers = fonts.definers
+local specifiers = fonts.specifiers
+local constructors = fonts.constructors
+local loggers = fonts.loggers
+local fontgoodies = fonts.goodies
+local helpers = fonts.helpers
+local hashes = fonts.hashes
+local currentfont = font.current
+local definefont = font.define
+
+local getprivateslot = helpers.getprivateslot
+
+local cleanname = names.cleanname
+
+local encodings = fonts.encodings
+----- aglunicodes = encodings.agl.unicodes
+local aglunicodes = nil -- delayed loading
+
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+
+local nextchar = nuts.traversers.char
+
+local getattr = nuts.getattr
+local setattr = nuts.setattr
+local getstate = nuts.getstate
+local setsubtype = nuts.setsubtype
+
+local texgetdimen = tex.getdimen
+local texsetcount = tex.setcount
+local texget = tex.get
+
+local texdefinefont = tex.definefont
+local texsp = tex.sp
+
+local fontdata = hashes.identifiers
+local characters = hashes.characters
+local descriptions = hashes.descriptions
+local properties = hashes.properties
+local resources = hashes.resources
+local unicodes = hashes.unicodes
+local csnames = hashes.csnames
+local lastmathids = hashes.lastmathids
+local exheights = hashes.exheights
+local emwidths = hashes.emwidths
+local parameters = hashes.parameters
+
+local designsizefilename = fontgoodies.designsizes.filename
+
+local ctx_char = context.char
+local ctx_safechar = context.safechar
+local ctx_getvalue = context.getvalue
+
+local otffeatures = otf.features
+local otftables = otf.tables
+
+local registerotffeature = otffeatures.register
+
+local sequencers = utilities.sequencers
+local appendgroup = sequencers.appendgroup
+local appendaction = sequencers.appendaction
+
+specifiers.contextsetups = specifiers.contextsetups or { }
+specifiers.contextnumbers = specifiers.contextnumbers or { }
+specifiers.contextmerged = specifiers.contextmerged or { }
+specifiers.synonyms = specifiers.synonyms or { }
+
+local setups = specifiers.contextsetups
+local numbers = specifiers.contextnumbers
+local merged = specifiers.contextmerged
+local synonyms = specifiers.synonyms
+
+storage.register("fonts/setups" , setups , "fonts.specifiers.contextsetups" )
+storage.register("fonts/numbers", numbers, "fonts.specifiers.contextnumbers")
+storage.register("fonts/merged", merged, "fonts.specifiers.contextmerged")
+storage.register("fonts/synonyms", synonyms, "fonts.specifiers.synonyms")
+
+-- inspect(setups)
+
+setmetatableindex(setups, environment.initex and
+ function(t,k)
+ return type(k) == "number" and rawget(t,numbers[k]) or nil
+ end
+or
+ function(t,k)
+ local v = type(k) == "number" and rawget(t,numbers[k])
+ if v then
+ t[k] = v
+ return v
+ end
+ end
+)
+
+-- this will move elsewhere ...
+
+local function getfontname(tfmdata)
+ return basename(type(tfmdata) == "number" and properties[tfmdata].name or tfmdata.properties.name)
+end
+
+helpers.name = getfontname
+
+local addformatter = utilities.strings.formatters.add
+
+addformatter(formatters,"font:name", [["'"..fontname(%s).."'"]], { fontname = helpers.name })
+addformatter(formatters,"font:features",[["'"..sequenced(%s," ",true).."'"]],{ sequenced = table.sequenced })
+
+-- ... like font-sfm or so
+
+constructors.resolvevirtualtoo = true -- context specific (due to resolver)
+constructors.sharefonts = true -- experimental
+constructors.nofsharedfonts = 0
+constructors.nofsharedhashes = 0
+constructors.nofsharedvectors = 0
+constructors.noffontsloaded = 0
+
+-- we can get rid of the tfm instance when we have fast access to the
+-- scaled character dimensions at the tex end, e.g. a fontobject.width
+-- actually we already have some of that now as virtual keys in glyphs
+--
+-- flushing the kern and ligature tables from memory saves a lot (only
+-- base mode) but it complicates vf building where the new characters
+-- demand this data .. solution: functions that access them
+
+-- font.getcopy = font.getfont -- we always want the table that context uses
+
+do
+
+ -- Does this still make sense?
+
+ local shares = { }
+ local hashes = { }
+ local nofinstances = 0
+ local instances = setmetatableindex(function(t,k)
+ nofinstances = nofinstances + 1
+ t[k] = nofinstances
+ return nofinstances
+ end)
+
+ function constructors.trytosharefont(target,tfmdata)
+ constructors.noffontsloaded = constructors.noffontsloaded + 1
+ if constructors.sharefonts then
+ local fonthash = target.specification.hash
+ if fonthash then
+ local properties = target.properties
+ local fullname = target.fullname
+ local fontname = target.fontname
+ local psname = target.psname
+ -- for the moment here:
+ local instance = properties.instance
+ if instance then
+ local format = tfmdata.properties.format
+ if format == "opentype" then
+ target.streamprovider = 1
+ elseif format == "truetype" then
+ target.streamprovider = 2
+ else
+ target.streamprovider = 0
+ end
+ if target.streamprovider > 0 then
+ if fullname then
+ fullname = fullname .. ":" .. instances[instance]
+ target.fullname = fullname
+ end
+ if fontname then
+ fontname = fontname .. ":" .. instances[instance]
+ target.fontname = fontname
+ end
+ if psname then
+ -- this one is used for the funny prefix in font names in pdf
+ -- so it has to be kind of unique in order to avoid subset prefix
+ -- clashes being reported
+ psname = psname .. ":" .. instances[instance]
+ target.psname = psname
+ end
+ end
+ end
+ --
+ local sharedname = hashes[fonthash]
+ if sharedname then
+ -- this is ok for context as we know that only features can mess with font definitions
+ -- so a similar hash means that the fonts are similar too
+ if trace_defining then
+ report_defining("font %a uses backend resources of font %a (%s)",target.fullname,sharedname,"common hash")
+ end
+ target.fullname = sharedname
+ properties.sharedwith = sharedname
+ constructors.nofsharedfonts = constructors.nofsharedfonts + 1
+ constructors.nofsharedhashes = constructors.nofsharedhashes + 1
+ else
+ -- the one takes more time (in the worst case of many cjk fonts) but it also saves
+ -- embedding time .. haha, this is interesting: when i got a clash on subset tag
+ -- collision i saw in the source that these tags are also using a hash like below
+ -- so maybe we should have an option to pass it from lua
+ local characters = target.characters
+ local n = 1
+ local t = { target.psname }
+ -- for the moment here:
+ if instance then
+ n = n + 1
+ t[n] = instance
+ end
+ --
+ local u = sortedkeys(characters)
+ for i=1,#u do
+ local k = u[i]
+ n = n + 1 ; t[n] = k
+ n = n + 1 ; t[n] = characters[k].index or k
+ end
+ local checksum = md5.HEX(concat(t," "))
+ local sharedname = shares[checksum]
+ local fullname = target.fullname
+ if sharedname then
+ if trace_defining then
+ report_defining("font %a uses backend resources of font %a (%s)",fullname,sharedname,"common vector")
+ end
+ fullname = sharedname
+ properties.sharedwith = sharedname
+ constructors.nofsharedfonts = constructors.nofsharedfonts + 1
+ constructors.nofsharedvectors = constructors.nofsharedvectors + 1
+ else
+ shares[checksum] = fullname
+ end
+ target.fullname = fullname
+ hashes[fonthash] = fullname
+ end
+ end
+ end
+ end
+
+end
+
+directives.register("fonts.checksharing",function(v)
+ if not v then
+ report_defining("font sharing in backend is disabled")
+ end
+ constructors.sharefonts = v
+end)
+
+function definers.resetnullfont()
+ -- resetting is needed because tikz misuses nullfont
+ local parameters = fonts.nulldata.parameters
+ --
+ parameters.slant = 0 -- 1
+ parameters.space = 0 -- 2
+ parameters.space_stretch = 0 -- 3
+ parameters.space_shrink = 0 -- 4
+ parameters.x_height = 0 -- 5
+ parameters.quad = 0 -- 6
+ parameters.extra_space = 0 -- 7
+ parameters.designsize = 655360
+ --
+ constructors.enhanceparameters(parameters) -- official copies for us
+ --
+ definers.resetnullfont = function() end
+end
+
+-- This is some initialization code and we don't want (tracing) clutter in lmtx
+-- which is why we follow a different route there. I admit that is sounds freaky.
+-- Watch out: in lmtx the font dimen array is no longer resized automatically.
+
+implement {
+ name = "resetnullfont",
+ onlyonce = true,
+ permanent = false,
+ actions = function()
+ for i=1,7 do
+ font.setfontdimen(0,i,0)
+ end
+ definers.resetnullfont()
+ end
+}
+
+-- this cannot be a feature initializer as there is no auto namespace
+-- so we never enter the loop then; we can store the defaults in the tma
+-- file (features.gpos.mkmk = 1 etc)
+
+local needsnodemode = { -- we will have node mode by default anyway
+ -- gsub_single = true,
+ gsub_multiple = true,
+ -- gsub_alternate = true,
+ -- gsub_ligature = true,
+ gsub_context = true,
+ gsub_contextchain = true,
+ gsub_reversecontextchain = true,
+ -- chainsub = true,
+ -- reversesub = true,
+ gpos_mark2base = true,
+ gpos_mark2ligature = true,
+ gpos_mark2mark = true,
+ gpos_cursive = true,
+ -- gpos_single = true,
+ -- gpos_pair = true,
+ gpos_context = true,
+ gpos_contextchain = true,
+}
+
+otftables.scripts.auto = "automatic fallback to latn when no dflt present"
+
+-- setmetatableindex(otffeatures.descriptions,otftables.features)
+
+local function checkedscript(tfmdata,resources,features)
+ local latn = false
+ local script = false
+ if resources.features then
+ for g, list in next, resources.features do
+ for f, scripts in next, list do
+ if scripts.dflt then
+ script = "dflt"
+ break
+ elseif scripts.latn then
+ latn = true
+ end
+ end
+ end
+ end
+ if not script then
+ script = latn and "latn" or "dflt"
+ end
+ if trace_automode then
+ report_defining("auto script mode, using script %a in font %!font:name!",script,tfmdata)
+ end
+ features.script = script
+ return script
+end
+
+-- basemode combined with dynamics is somewhat tricky
+
+local function checkedmode(tfmdata,resources,features)
+ local sequences = resources.sequences
+ if sequences and #sequences > 0 then
+ local script = features.script or "dflt"
+ local language = features.language or "dflt"
+ for feature, value in next, features do
+ if value then
+ local found = false
+ for i=1,#sequences do
+ local sequence = sequences[i]
+ local features = sequence.features
+ if features then
+ local scripts = features[feature]
+ if scripts then
+ local languages = scripts[script]
+ if languages and languages[language] then
+ if found then
+ -- more than one lookup
+ if trace_automode then
+ report_defining("forcing mode %a, font %!font:name!, feature %a, script %a, language %a, %s",
+ "node",tfmdata,feature,script,language,"multiple lookups")
+ end
+ features.mode = "node"
+ return "node"
+ elseif needsnodemode[sequence.type] then
+ if trace_automode then
+ report_defining("forcing mode %a, font %!font:name!, feature %a, script %a, language %a, %s",
+ "node",tfmdata,feature,script,language,"no base support")
+ end
+ features.mode = "node"
+ return "node"
+ else
+ -- at least one lookup
+ found = true
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ if trace_automode then
+ report_defining("forcing mode base, font %!font:name!",tfmdata)
+ end
+ features.mode = "base" -- new, or is this wrong?
+ return "base"
+end
+
+definers.checkedscript = checkedscript
+definers.checkedmode = checkedmode
+
+-- We only set the checker and leave other settings of the mode feature as
+-- they are.
+
+local function modechecker(tfmdata,features,mode) -- we cannot adapt features as they are shared!
+ if trace_features then
+ report_features("fontname %!font:name!, features %!font:features!",tfmdata,features)
+ end
+ local rawdata = tfmdata.shared.rawdata
+ local resources = rawdata and rawdata.resources
+ local script = features.script
+ if resources then
+ if script == "auto" then
+ script = checkedscript(tfmdata,resources,features)
+ end
+ if mode == "auto" then
+ mode = checkedmode(tfmdata,resources,features)
+ end
+ else
+ report_features("missing resources for font %!font:name!",tfmdata)
+ end
+ return mode
+end
+
+registerotffeature {
+ name = "mode",
+ modechecker = modechecker,
+}
+
+do
+
+ -- copying will end up here too
+
+ local beforecopyingcharacters = sequencers.new {
+ name = "beforecopyingcharacters",
+ arguments = "target,original",
+ }
+
+ appendgroup(beforecopyingcharacters,"before") -- user
+ appendgroup(beforecopyingcharacters,"system") -- private
+ appendgroup(beforecopyingcharacters,"after" ) -- user
+
+ function constructors.beforecopyingcharacters(original,target)
+ local runner = beforecopyingcharacters.runner
+ if runner then
+ runner(original,target)
+ end
+ end
+
+ local aftercopyingcharacters = sequencers.new {
+ name = "aftercopyingcharacters",
+ arguments = "target,original",
+ }
+
+ appendgroup(aftercopyingcharacters,"before") -- user
+ appendgroup(aftercopyingcharacters,"system") -- private
+ appendgroup(aftercopyingcharacters,"after" ) -- user
+
+ function constructors.aftercopyingcharacters(original,target)
+ local runner = aftercopyingcharacters.runner
+ if runner then
+ runner(original,target)
+ end
+ end
+
+end
+
+--[[ldx--
+
So far we haven't really dealt with features (or whatever we want
+to pass along with the font definition. We distinguish the following
+situations:
+situations:
+
+
+name:xetex like specs
+name@virtual font spec
+name*context specification
+
+--ldx]]--
+
+-- Currently fonts are scaled while constructing the font, so we have to do scaling
+-- of commands in the vf at that point using e.g. "local scale = g.parameters.factor
+-- or 1" after all, we need to work with copies anyway and scaling needs to be done
+-- at some point; however, when virtual tricks are used as feature (makes more
+-- sense) we scale the commands in fonts.constructors.scale (and set the factor
+-- there).
+
+local loadfont = definers.loadfont
+
+function definers.loadfont(specification,size,id) -- overloads the one in font-def
+ local variants = definers.methods.variants
+ local virtualfeatures = specification.features.virtual
+ if virtualfeatures and virtualfeatures.preset then
+ local variant = variants[virtualfeatures.preset]
+ if variant then
+ return variant(specification,size,id)
+ end
+ else
+ return loadfont(specification,size,id)
+ end
+end
+
+local function predefined(specification)
+ local variants = definers.methods.variants
+ local detail = specification.detail
+ if detail ~= "" and variants[detail] then
+ specification.features.virtual = { preset = detail }
+ end
+ return specification
+end
+
+definers.registersplit("@", predefined,"virtual")
+
+local normalize_features = otffeatures.normalize -- should be general
+
+local function definecontext(name,t) -- can be shared
+ local number = setups[name] and setups[name].number or 0 -- hm, numbers[name]
+ if number == 0 then
+ number = #numbers + 1
+ numbers[number] = name
+ end
+ t.number = number
+ setups[name] = t
+ return number, t
+end
+
+-- {a,b,c} as table (so we don' need to parse again when it gets applied)
+-- we will update this ... when we have foo={a,b,c} then we can keep the table
+
+-- \definefontfeature[demo][a={b,c}]
+-- \definefontfeature[demo][a={b=12,c={34,35}}]
+
+local h = setmetatableindex(function(t,k)
+ local v = "," .. k .. ","
+ t[k] = v
+ return v
+end)
+
+-- local function removefromhash(hash,key)
+-- local pattern = h[key]
+-- for k in next, hash do
+-- if k ~= key and find(h[k],pattern) then -- if find(k,",") and ...
+-- hash[k] = nil
+-- end
+-- end
+-- end
+
+local function presetcontext(name,parent,features) -- will go to con and shared
+ if features == "" and find(parent,"=",1,true) then
+ features = parent
+ parent = ""
+ end
+ if not features or features == "" then
+ features = { }
+ elseif type(features) == "string" then
+ features = normalize_features(settings_to_hash(features))
+ -- if type(value) == "string" and find(value,"[=:]") then
+ -- local t = settings_to_hash_colon_too(value) -- clashes with foo=file:bar
+ for key, value in next, features do
+ if type(value) == "string" and find(value,"[=]") then
+ local t = settings_to_hash(value)
+ if next(t) then
+ features[key] = sequenced(normalize_features(t,true),",")
+ end
+ end
+ end
+ else
+ features = normalize_features(features)
+ end
+ -- todo: synonyms, and not otf bound
+ if parent ~= "" then
+ for p in gmatch(parent,"[^, ]+") do
+ local s = setups[p]
+ if s then
+ for k, v in next, s do
+ -- no, as then we cannot overload: e.g. math,mathextra
+ -- reverted, so we only take from parent when not set
+ if features[k] == nil then
+ features[k] = v
+ end
+ end
+ else
+ -- just ignore an undefined one .. i.e. we can refer to not yet defined
+ end
+ end
+ end
+ -- these are auto set so in order to prevent redundant definitions
+ -- we need to preset them (we hash the features and adding a default
+ -- setting during initialization may result in a different hash)
+ --
+ -- for k,v in next, triggers do
+ -- if features[v] == nil then -- not false !
+ -- local vv = default_features[v]
+ -- if vv then features[v] = vv end
+ -- end
+ -- end
+ --
+ for feature,value in next, features do
+ if value == nil then -- not false !
+ local default = default_features[feature]
+ if default ~= nil then
+ features[feature] = default
+ end
+ end
+ end
+ -- sparse 'm so that we get a better hash and less test (experimental
+ -- optimization)
+ local t = { } -- can we avoid t ?
+ for k,v in next, features do
+ -- if v then t[k] = v end
+ t[k] = v
+ end
+ -- the number is needed for dynamic features; maybe number should always be
+ -- renewed as we can redefine features ... i need a test
+ local number = setups[name] and setups[name].number or 0
+ if number == 0 then
+ number = #numbers + 1
+ numbers[number] = name
+ end
+ --
+ t.number = number
+ -- there is the special case of combined features as we have in math but maybe
+ -- this has to change some day ... otherwise we mess up dynamics (ok, we could
+ -- impose a limit there: no combined features)
+ --
+ -- done elsewhere (!)
+ --
+ -- removefromhash(setups,name) -- can have changed (like foo,extramath)
+ --
+ setups[name] = t
+ return number, t
+end
+
+local function adaptcontext(pattern,features)
+ local pattern = topattern(pattern,false,true)
+ for name in next, setups do
+ if find(name,pattern) then
+ presetcontext(name,name,features)
+ end
+ end
+end
+
+-- See for old code in the lua file. We now share code.
+
+local function contextnumber(name)
+ local t = setups[name]
+ return t and t.number or 0
+end
+
+local function mergecontext(currentnumber,extraname,option) -- number string number (used in scrp-ini
+ local extra = setups[extraname]
+ if extra then
+ local current = setups[numbers[currentnumber]]
+ local mergedfeatures = { }
+ local mergedname = nil
+ if option < 0 then
+ if current then
+ for k, v in next, current do
+ if not extra[k] then
+ mergedfeatures[k] = v
+ end
+ end
+ end
+ mergedname = currentnumber .. "-" .. extraname
+ else
+ if current then
+ for k, v in next, current do
+ mergedfeatures[k] = v
+ end
+ end
+ for k, v in next, extra do
+ mergedfeatures[k] = v
+ end
+ mergedname = currentnumber .. "+" .. extraname
+ end
+ local number = #numbers + 1
+ mergedfeatures.number = number
+ numbers[number] = mergedname
+ merged[number] = option
+ setups[mergedname] = mergedfeatures
+ return number
+ else
+ return currentnumber
+ end
+end
+
+local extrasets = { }
+
+setmetatableindex(extrasets,function(t,k)
+ local v = mergehashes(setups,k)
+ t[k] = v
+ return v
+end)
+
+local function mergecontextfeatures(currentname,extraname,how,mergedname) -- string string
+ local extra = setups[extraname] or extrasets[extraname]
+ if extra then
+ local current = setups[currentname]
+ local mergedfeatures = { }
+ if how == "+" then
+ if current then
+ for k, v in next, current do
+ mergedfeatures[k] = v
+ end
+ end
+ for k, v in next, extra do
+ mergedfeatures[k] = v
+ end
+ if trace_merge then
+ report_features("merge %a, method %a, current %|T, extra %|T, result %|T",mergedname,"add",current or { },extra,mergedfeatures)
+ end
+ elseif how == "-" then
+ if current then
+ for k, v in next, current do
+ mergedfeatures[k] = v
+ end
+ end
+ for k, v in next, extra do
+ -- only boolean features
+ if v == true then
+ mergedfeatures[k] = false
+ end
+ end
+ if trace_merge then
+ report_features("merge %a, method %a, current %|T, extra %|T, result %|T",mergedname,"subtract",current or { },extra,mergedfeatures)
+ end
+ else -- =
+ for k, v in next, extra do
+ mergedfeatures[k] = v
+ end
+ if trace_merge then
+ report_features("merge %a, method %a, result %|T",mergedname,"replace",mergedfeatures)
+ end
+ end
+ local number = #numbers + 1
+ mergedfeatures.number = number
+ numbers[number] = mergedname
+ merged[number] = option
+ setups[mergedname] = mergedfeatures
+ return number
+ else
+ return numbers[currentname] or 0
+ end
+end
+
+local function registercontext(fontnumber,extraname,option)
+ local extra = setups[extraname]
+ if extra then
+ local mergedfeatures = { }
+ local mergedname = nil
+ if option < 0 then
+ mergedname = fontnumber .. "-" .. extraname
+ else
+ mergedname = fontnumber .. "+" .. extraname
+ end
+ for k, v in next, extra do
+ mergedfeatures[k] = v
+ end
+ local number = #numbers + 1
+ mergedfeatures.number = number
+ numbers[number] = mergedname
+ merged[number] = option
+ setups[mergedname] = mergedfeatures
+ return number
+ else
+ return 0
+ end
+end
+
+local function registercontextfeature(mergedname,extraname,how)
+ local extra = setups[extraname]
+ if extra then
+ local mergedfeatures = { }
+ for k, v in next, extra do
+ mergedfeatures[k] = v
+ end
+ local number = #numbers + 1 -- we somehow end up with steps of 2
+ mergedfeatures.number = number
+ numbers[number] = mergedname
+ merged[number] = how == "=" and 1 or 2 -- 1=replace, 2=combine
+ setups[mergedname] = mergedfeatures
+ return number
+ else
+ report_features("unknown feature %a cannot be merged into %a using method %a",extraname,mergedname,how)
+ return 0
+ end
+end
+
+specifiers.presetcontext = presetcontext
+specifiers.contextnumber = contextnumber
+specifiers.mergecontext = mergecontext
+specifiers.registercontext = registercontext
+specifiers.definecontext = definecontext
+
+constructors.hashmethods.normal = function(list)
+ local s = { }
+ local n = 0
+ for k, v in next, list do
+ if not k then
+ -- no need to add to hash
+ elseif k == "number" or k == "features" then
+ -- no need to add to hash (maybe we need a skip list)
+ else
+ n = n + 1
+ if type(v) == "table" then
+ -- table.sequenced
+ local t = { }
+ local m = 0
+ for k, v in next, v do
+ m = m + 1
+ t[m] = format("%q=%q",k,v)
+ end
+ sort(t)
+ s[n] = format("%q={%s}",k,concat(t,","))
+ else
+ s[n] = format("%q=%q",k,v)
+ end
+ end
+ end
+ if n > 0 then
+ sort(s)
+ return concat(s,"+")
+ end
+end
+
+constructors.hashmethods.virtual = function(list)
+ local s = { }
+ local n = 0
+ for k, v in next, list do
+ n = n + 1
+ s[n] = format("%q=%q",k,v)
+ end
+ if n > 0 then
+ sort(s)
+ return concat(s,"+")
+ end
+end
+
+-- end of redefine
+
+-- local withcache = { } -- concat might be less efficient than nested tables
+--
+-- local function withset(name,what)
+-- local zero = texgetattribute(0)
+-- local hash = zero .. "+" .. name .. "*" .. what
+-- local done = withcache[hash]
+-- if not done then
+-- done = mergecontext(zero,name,what)
+-- withcache[hash] = done
+-- end
+-- texsetattribute(0,done)
+-- end
+--
+-- local function withfnt(name,what,font)
+-- local font = font or currentfont()
+-- local hash = font .. "*" .. name .. "*" .. what
+-- local done = withcache[hash]
+-- if not done then
+-- done = registercontext(font,name,what)
+-- withcache[hash] = done
+-- end
+-- texsetattribute(0,done)
+-- end
+
+function specifiers.showcontext(name)
+ return setups[name] or setups[numbers[name]] or setups[numbers[tonumber(name)]] or { }
+end
+
+-- we need a copy as we will add (fontclass) goodies to the features and
+-- that is bad for a shared table
+
+-- local function splitcontext(features) -- presetcontext creates dummy here
+-- return fastcopy(setups[features] or (presetcontext(features,"","") and setups[features]))
+-- end
+
+-- local function splitcontext(features) -- presetcontext creates dummy here
+-- local sf = setups[features]
+-- if not sf then
+-- local n -- number
+-- if find(features,",") then
+-- -- let's assume a combination which is not yet defined but just specified (as in math)
+-- n, sf = presetcontext(features,features,"")
+-- else
+-- -- we've run into an unknown feature and or a direct spec so we create a dummy
+-- n, sf = presetcontext(features,"","")
+-- end
+-- end
+-- return fastcopy(sf)
+-- end
+
+local function splitcontext(features) -- presetcontext creates dummy here
+ local n, sf
+ -- We can have: "a=yes,b=yes" "a,b" "a" "a=yes" etc.
+ if find(features,"[,=]") then
+ --
+ -- from elsewhere (!)
+ --
+ -- this will become:
+ --
+ -- if find(features,"^reset," then
+ setups[features] = nil
+ -- end
+ -- let's assume a combination which is not yet defined but just specified (as in math)
+ n, sf = presetcontext(features,features,"")
+ else
+ sf = setups[features]
+ if not sf then
+ -- we've run into an unknown feature and or a direct spec so we create a dummy
+ n, sf = presetcontext(features,"","")
+ end
+ end
+ return fastcopy(sf)
+end
+
+-- local splitter = lpeg.splitat("=")
+--
+-- local function splitcontext(features)
+-- local setup = setups[features]
+-- if setup then
+-- return setup
+-- elseif find(features,",",1,true) then
+-- -- This is not that efficient but handy anyway for quick and dirty tests
+-- -- beware, due to the way of caching setups you can get the wrong results
+-- -- when components change. A safeguard is to nil the cache.
+-- local merge = nil
+-- for feature in gmatch(features,"[^, ]+") do
+-- if find(feature,"=",1,true) then
+-- local k, v = lpegmatch(splitter,feature)
+-- if k and v then
+-- if not merge then
+-- merge = { k = v }
+-- else
+-- merge[k] = v
+-- end
+-- end
+-- else
+-- local s = setups[feature]
+-- if not s then
+-- -- skip
+-- elseif not merge then
+-- merge = s
+-- else
+-- for k, v in next, s do
+-- merge[k] = v
+-- end
+-- end
+-- end
+-- end
+-- setup = merge and presetcontext(features,"",merge) and setups[features]
+-- -- actually we have to nil setups[features] in order to permit redefinitions
+-- setups[features] = nil
+-- end
+-- return setup or (presetcontext(features,"","") and setups[features]) -- creates dummy
+-- end
+
+specifiers.splitcontext = splitcontext
+
+function specifiers.contexttostring(name,kind,separator,yes,no,strict,omit) -- not used
+ return hash_to_string(
+ mergedtable(handlers[kind].features.defaults or {},setups[name] or {}),
+ separator, yes, no, strict, omit or { "number" }
+ )
+end
+
+local function starred(features) -- no longer fallbacks here
+ local detail = features.detail
+ if detail and detail ~= "" then
+ features.features.normal = splitcontext(detail)
+ else
+ features.features.normal = { }
+ end
+ return features
+end
+
+definers.registersplit('*',starred,"featureset")
+
+-- sort of xetex mode, but without [] and / as we have file: and name: etc
+
+local space = P(" ")
+local spaces = space^0
+local separator = S(";,")
+local equal = P("=")
+local sometext = C((1-equal-space-separator)^1)
+local truevalue = P("+") * spaces * sometext * Cc(true)
+local falsevalue = P("-") * spaces * sometext * Cc(false)
+local somevalue = sometext * spaces * Cc(true)
+local keyvalue = sometext * spaces * equal * spaces * sometext
+local pattern = Cf(Ct("") * (space + separator + Cg(falsevalue + truevalue + keyvalue + somevalue))^0, rawset)
+
+local function colonized(specification)
+ specification.features.normal = normalize_features(lpegmatch(pattern,specification.detail))
+ return specification
+end
+
+definers.registersplit(":",colonized,"direct")
+
+-- define (two steps)
+
+local sizepattern, splitpattern, specialscale do
+
+ -- todo: use lpeg.patterns
+
+ ----- space = P(" ")
+ ----- spaces = space^0
+ local digit = R('09')
+ local period = P(".")
+ local leftparent = (P"(")
+ local rightparent = (P")")
+ local leftbrace = (P"{")
+ local rightbrace = (P"}")
+ local withinparents = leftparent * (1-rightparent)^0 * rightparent
+ local withinbraces = leftbrace * (1-rightbrace )^0 * rightbrace
+ local value = C((withinparents + withinbraces + (1-space))^1)
+ -- local dimension = C((space/"" + P(1))^1)
+ local dimension = Cs((digit+period)^1 * (spaces/"") * (P(1)-digit)^0)
+-- local scaler = C((digit+period)^1)
+ local scaler = lpeg.patterns.unsigned/function(s) return round(tonumber(s)*1000) end
+ + C(lpeg.patterns.cardinal)
+ local rest = C(P(1)^0)
+ local scale_none = Cc(0)
+ local scale_at = (P("at") + P("@")) * Cc(1) * spaces * dimension -- dimension
+ local scale_sa = P("sa") * Cc(2) * spaces * dimension -- number
+ local scale_mo = P("mo") * Cc(3) * spaces * dimension -- number
+ local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- number
+ local scale_ht = P("ht") * Cc(5) * spaces * dimension -- dimension
+ local scale_cp = P("cp") * Cc(6) * spaces * dimension -- dimension
+
+ specialscale = { [5] = "ht", [6] = "cp" }
+
+ sizepattern = spaces * ((scale_at + scale_sa + scale_mo + scale_ht + scale_cp + scale_scaled) * (spaces * scaler)^0 + scale_none)
+ splitpattern = spaces * value * spaces * rest
+
+end
+
+function helpers.splitfontpattern(str)
+ local name, size = lpegmatch(splitpattern,str)
+ local kind, size = lpegmatch(sizepattern,size) -- sx, sy
+ return name, kind, size -- sx, sy
+end
+
+function helpers.fontpatternhassize(str)
+ local name, size = lpegmatch(splitpattern,str)
+ local kind, size = lpegmatch(sizepattern,size)
+ return size or false
+end
+
+local specification -- still needed as local ?
+
+local getspecification = definers.getspecification
+
+-- we can make helper macros which saves parsing (but normaly not
+-- that many calls, e.g. in mk a couple of 100 and in metafun 3500)
+
+local specifiers = { }
+
+do -- else too many locals
+
+ local starttiming = statistics.starttiming
+ local stoptiming = statistics.stoptiming
+
+ local setmacro = tokens.setters.macro
+ local ctxcatcodes = tex.ctxcatcodes
+ local texconditionals = tex.conditionals
+
+ local reported = setmetatableindex(function(t,k)
+ local v = setmetatableindex(function(t,k)
+ t[k] = true
+ return false
+ end)
+ t[k] = v
+ return v
+ end)
+
+ implement {
+ name = "definefont_one",
+ arguments = "string",
+ actions = function(str)
+ starttiming(fonts)
+ if trace_defining then
+ report_defining("memory usage before: %s",statistics.memused())
+ report_defining("start stage one: %s",str)
+ end
+ local fullname, size = lpegmatch(splitpattern,str)
+ local lookup, name, sub, method, detail = getspecification(fullname)
+ if not name then
+ report_defining("strange definition %a",str)
+ -- ctx_setdefaultfontname()
+ elseif name == "unknown" then
+ -- ctx_setdefaultfontname()
+ else
+ -- ctx_setsomefontname(name)
+ setmacro("somefontname",name,"global")
+ end
+ -- we can also use a count for the size
+ if size and size ~= "" then
+ local mode, size, sx, sy = lpegmatch(sizepattern,size)
+ if mode and size and size ~= "" then
+ texsetcount("scaledfontmode",mode)
+ -- ctx_setsomefontsize(size)
+ -- We use a catcodetable, just in case it's 1.2\exheight (a corner case that showed
+ -- up in the lmtx manual: marking that changed size in the mids of some verbatim).
+ setmacro(ctxcatcodes,"somefontsize",size)
+ if sx then
+ setmacro("somefontsizex",sx)
+ end
+ if sy then
+ setmacro("somefontsizey",sy)
+ end
+ else
+ texsetcount("scaledfontmode",0)
+ -- ctx_setemptyfontsize()
+ end
+ elseif true then
+ -- so we don't need to check in tex
+ texsetcount("scaledfontmode",2)
+ -- ctx_setemptyfontsize()
+ else
+ texsetcount("scaledfontmode",0)
+ -- ctx_setemptyfontsize()
+ end
+ specification = definers.makespecification(str,lookup,name,sub,method,detail,size)
+-- specification.original = str
+ if trace_defining then
+ report_defining("stop stage one")
+ end
+ end
+ }
+
+ local function nice_cs(cs)
+ return (gsub(cs,".->", ""))
+ end
+
+ local n = 0
+ local busy = false
+ local combinefeatures = false
+
+ directives.register("fonts.features.combine",function(v)
+ combinefeatures = v
+ end)
+
+ implement {
+ name = "definefont_two",
+ arguments = {
+ -- "boolean", "string", "string", "dimension", "integer", "string",
+ -- "string", "string", "string", "integer", "dimension", "string",
+ -- "string", "string", "string", "integer",
+ "boolean", "argument", "argument", "dimension", "integer",
+ "argument", "argument", "argument", "argument", "integer",
+ "dimension", "argument", "argument", "argument", "argument",
+ "integer",
+ },
+ actions = function (
+ global, -- \ifx\fontclass\empty\s!false\else\s!true\fi
+ cs, -- {#csname}%
+ str, -- \somefontfile
+ size, -- \d_font_scaled_font_size
+ inheritancemode, -- \c_font_feature_inheritance_mode
+ classfeatures, -- \m_font_class_features
+ fontfeatures, -- \m_font_features
+ classfallbacks, -- \m_font_class_fallbacks
+ fontfallbacks, -- \m_font_fallbacks
+ mathsize, -- \fontface
+ textsize, -- \d_font_scaled_text_face
+ classgoodies, -- \m_font_class_goodies
+ goodies, -- \m_font_goodies
+ classdesignsize, -- \m_font_class_designsize
+ fontdesignsize, -- \m_font_designsize
+ scaledfontmode -- \scaledfontmode
+ )
+ if trace_defining then
+ report_defining("start stage two: %s, size %s, features %a & %a, mode %a",str,size,classfeatures,fontfeatures,inheritancemode)
+ end
+ -- name is now resolved and size is scaled cf sa/mo
+ local lookup, name, sub, method, detail = getspecification(str or "")
+ -- new (todo: inheritancemode)
+ local designsize = fontdesignsize ~= "" and fontdesignsize or classdesignsize or ""
+ local designname = designsizefilename(name,designsize,size)
+ if designname and designname ~= "" then
+ if trace_defining or trace_designsize then
+ report_defining("remapping name %a, specification %a, size %a, designsize %a",name,designsize,size,designname)
+ end
+ -- we don't catch detail here
+ local o_lookup, o_name, o_sub, o_method, o_detail = getspecification(designname)
+ if o_lookup and o_lookup ~= "" then lookup = o_lookup end
+ if o_method and o_method ~= "" then method = o_method end
+ if o_detail and o_detail ~= "" then detail = o_detail end
+ name = o_name
+ sub = o_sub
+ end
+ if texconditionals["c_font_compact"] then
+ size = 655360
+ end
+ -- so far
+ -- some settings can have been overloaded
+ if lookup and lookup ~= "" then
+ specification.lookup = lookup
+ end
+ if relativeid and relativeid ~= "" then -- experimental hook
+ local id = tonumber(relativeid) or 0
+ specification.relativeid = id > 0 and id
+ end
+ --
+ specification.name = name
+ specification.size = size
+ specification.sub = (sub and sub ~= "" and sub) or specification.sub
+ specification.mathsize = mathsize
+ specification.textsize = textsize
+ specification.goodies = goodies
+ specification.cs = cs
+ specification.global = global
+ specification.scalemode = scaledfontmode -- context specific
+ if detail and detail ~= "" then
+ specification.method = method or "*"
+ specification.detail = detail
+ elseif specification.detail and specification.detail ~= "" then
+ -- already set
+ elseif inheritancemode == 0 then
+ -- nothing
+ elseif inheritancemode == 1 then
+ -- fontonly
+ if fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = fontfeatures
+ end
+ if fontfallbacks and fontfallbacks ~= "" then
+ specification.fallbacks = fontfallbacks
+ end
+ elseif inheritancemode == 2 then
+ -- classonly
+ if classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ end
+ if classfallbacks and classfallbacks ~= "" then
+ specification.fallbacks = classfallbacks
+ end
+ elseif inheritancemode == 3 then
+ -- fontfirst
+ if combinefeatures then
+ if classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ if fontfeatures and fontfeatures ~= "" and fontfeatures ~= classfeatures then
+ specification.detail = classfeatures .. "," .. fontfeatures
+ else
+ specification.detail = classfeatures
+ end
+ elseif fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = fontfeatures
+ end
+ else
+ if fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = fontfeatures
+ elseif classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ end
+ end
+ if fontfallbacks and fontfallbacks ~= "" then
+ specification.fallbacks = fontfallbacks
+ elseif classfallbacks and classfallbacks ~= "" then
+ specification.fallbacks = classfallbacks
+ end
+ elseif inheritancemode == 4 then
+ -- classfirst
+ if combinefeatures then
+ if fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ if classfeatures and classfeatures ~= "" and classfeatures ~= fontfeatures then
+ specification.detail = fontfeatures .. "," .. classfeatures
+ else
+ specification.detail = fontfeatures
+ end
+ elseif classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ end
+ else
+ if classfeatures and classfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = classfeatures
+ elseif fontfeatures and fontfeatures ~= "" then
+ specification.method = "*"
+ specification.detail = fontfeatures
+ end
+ end
+ if classfallbacks and classfallbacks ~= "" then
+ specification.fallbacks = classfallbacks
+ elseif fontfallbacks and fontfallbacks ~= "" then
+ specification.fallbacks = fontfallbacks
+ end
+ end
+ --
+ local tfmdata = definers.read(specification,size) -- id not yet known (size in spec?)
+ --
+ local lastfontid = 0
+ local tfmtype = type(tfmdata)
+ if tfmtype == "table" then
+ -- setting the extra characters will move elsewhere
+ local characters = tfmdata.characters
+ local parameters = tfmdata.parameters
+ local properties = tfmdata.properties
+ -- we use char0 as signal; cf the spec pdf can handle this (no char in slot)
+ characters[0] = nil
+ -- characters[0x00A0] = { width = parameters.space }
+ -- characters[0x2007] = { width = characters[0x0030] and characters[0x0030].width or parameters.space } -- figure
+ -- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period
+ --
+ local fallbacks = specification.fallbacks or ""
+ local mathsize = (mathsize == 1 or mathsize == 2 or mathsize == 3) and mathsize or nil -- can be unset so we test 1 2 3
+ if fallbacks ~= "" and mathsize and not busy then
+ busy = true
+ -- We need this ugly hack in order to resolve fontnames (at the \TEX end). Originally
+ -- math was done in Lua after loading (plugged into aftercopying).
+ --
+ -- After tl 2017 I'll also do text fallbacks this way (although backups there are done
+ -- in a completely different way.)
+ if trace_defining then
+ report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
+ name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,1)
+ end
+ mathematics.resolvefallbacks(tfmdata,specification,fallbacks)
+ context(function()
+ -- We're doing math fallbacks.
+ busy = false
+ mathematics.finishfallbacks(tfmdata,specification,fallbacks)
+ tfmdata.original = specification.specification
+ local id = definefont(tfmdata,properties.id)
+ csnames[id] = specification.cs
+ properties.id = id -- already set
+ definers.register(tfmdata,id) -- to be sure, normally already done
+ texdefinefont(global,cs,id)
+ -- texdefinefont(cs,id,global and "global")
+ constructors.finalize(tfmdata)
+ if trace_defining then
+ report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
+ name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,2)
+ end
+ -- resolved (when designsize is used):
+ local size = round(tfmdata.parameters.size or 655360)
+ setmacro("somefontsize",size.."sp")
+ -- ctx_setsomefontsize(size .. "sp")
+ texsetcount("scaledfontsize",size)
+ lastfontid = id
+ --
+ if trace_defining then
+ report_defining("memory usage after: %s",statistics.memused())
+ report_defining("stop stage two")
+ end
+ --
+ texsetcount("global","lastfontid",lastfontid)
+ specifiers[lastfontid] = { str, size }
+ if not mathsize then
+ -- forget about it (can't happen here)
+ elseif mathsize == 0 then
+ -- can't happen (here)
+ else
+ -- maybe only 1 2 3 (we already test for this)
+ lastmathids[mathsize] = lastfontid
+ end
+ stoptiming(fonts)
+ end)
+ return
+ else
+ tfmdata.original = specification.specification
+ local id = definefont(tfmdata,properties.id)
+ csnames[id] = specification.cs
+ properties.id = id -- already set
+ definers.register(tfmdata,id) -- to be sure, normally already done
+ texdefinefont(global,cs,id)
+ -- texdefinefont(cs,id,global and "global")
+ constructors.finalize(tfmdata)
+ if trace_defining then
+ report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a",
+ name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-")
+ end
+ -- resolved (when designsize is used):
+ local size = round(tfmdata.parameters.size or 655360)
+ setmacro("somefontsize",size.."sp")
+ -- ctx_setsomefontsize(size .. "sp")
+ texsetcount("scaledfontsize",size)
+ lastfontid = id
+ end
+ elseif tfmtype == "number" then
+ if trace_defining then
+ report_defining("reusing %s, id %a, target %a, features %a / %a, fallbacks %a / %a, goodies %a / %a, designsize %a / %a",
+ name,tfmdata,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies,classdesignsize,fontdesignsize)
+ end
+ csnames[tfmdata] = specification.cs
+ texdefinefont(global,cs,tfmdata)
+ -- texdefinefont(cs,tfmdata,global and "global")
+ -- resolved (when designsize is used):
+ local size = round(fontdata[tfmdata].parameters.size or 0)
+ -- ctx_setsomefontsize(size .. "sp")
+ setmacro("somefontsize",size.."sp")
+ texsetcount("scaledfontsize",size)
+ lastfontid = tfmdata
+ else
+ local nice = nice_cs(cs)
+ if not reported[name][nice] then
+ report_defining("unable to define %a as %a",name,nice)
+ end
+ lastfontid = -1
+ texsetcount("scaledfontsize",0)
+ -- ctx_letvaluerelax(cs) -- otherwise the current definition takes the previous one
+ end
+ if trace_defining then
+ report_defining("memory usage after: %s",statistics.memused())
+ report_defining("stop stage two")
+ end
+ --
+ texsetcount("global","lastfontid",lastfontid)
+ specifiers[lastfontid] = { str, size }
+ if not mathsize then
+ -- forget about it
+ elseif mathsize == 0 then
+ -- can't happen (here)
+ else
+ -- maybe only 1 2 3
+ lastmathids[mathsize] = lastfontid
+ end
+ --
+ stoptiming(fonts)
+ end
+ }
+
+ implement {
+ name = "specifiedfontspec",
+ arguments = "integer",
+ actions = function(id)
+ local f = specifiers[id]
+ if f then
+ context(f[1])
+ end
+ end
+ }
+
+ implement {
+ name = "specifiedfontsize",
+ arguments = "integer",
+ actions = function(id)
+ local f = specifiers[id]
+ if f then
+ context(f[2])
+ end
+ end
+ }
+
+ implement {
+ name = "specifiedfont",
+ arguments = { "integer", "number" },
+ actions = function(id,size)
+ local f = specifiers[id]
+ if f and size then
+ context("%s at %0.2p",f[1],size * f[2]) -- we round to 2 decimals (as at the tex end)
+ end
+ end
+ }
+ --
+
+ local function define(specification)
+ --
+ local name = specification.name
+ if not name or name == "" then
+ return -1
+ else
+ starttiming(fonts)
+ --
+ -- following calls expect a few properties to be set:
+ --
+ local lookup, name, sub, method, detail = getspecification(name or "")
+ --
+ specification.name = (name ~= "" and name) or specification.name
+ --
+ specification.lookup = specification.lookup or (lookup ~= "" and lookup) or "file"
+ specification.size = specification.size or 655260
+ specification.sub = specification.sub or (sub ~= "" and sub) or ""
+ specification.method = specification.method or (method ~= "" and method) or "*"
+ specification.detail = specification.detail or (detail ~= "" and detail) or ""
+ --
+ if type(specification.size) == "string" then
+ specification.size = texsp(specification.size) or 655260
+ end
+ --
+ specification.specification = "" -- not used
+ specification.resolved = ""
+ specification.forced = ""
+ specification.features = { } -- via detail, maybe some day
+ --
+ -- we don't care about mathsize textsize goodies fallbacks
+ --
+ local cs = specification.cs
+ if cs == "" then
+ cs = nil
+ specification.cs = nil
+ specification.global = false
+ elseif specification.global == nil then
+ specification.global = false
+ end
+ --
+ local tfmdata = definers.read(specification,specification.size)
+ if not tfmdata then
+ return -1, nil
+ elseif type(tfmdata) == "number" then
+ if cs then
+ texdefinefont(specification.global,cs,tfmdata)
+ -- texdefinefont(cs,tfmdata,specification.global and "global")
+ csnames[tfmdata] = cs
+ end
+ stoptiming(fonts)
+ return tfmdata, fontdata[tfmdata]
+ else
+ local id = definefont(tfmdata)
+ tfmdata.properties.id = id
+ definers.register(tfmdata,id)
+ if cs then
+ texdefinefont(specification.global,cs,id)
+ -- texdefinefont(cs,id,specification.global and "global")
+ csnames[id] = cs
+ end
+ constructors.finalize(tfmdata)
+ stoptiming(fonts)
+ return id, tfmdata
+ end
+ end
+ end
+
+ definers.define = define
+
+ -- local id, cs = fonts.definers.internal { }
+ -- local id, cs = fonts.definers.internal { number = 2 }
+ -- local id, cs = fonts.definers.internal { name = "dejavusans" }
+
+ local n = 0
+
+ function definers.internal(specification,cs)
+ specification = specification or { }
+ local name = specification.name
+ local size = tonumber(specification.size)
+ local number = tonumber(specification.number)
+ local id = nil
+ if not size then
+ size = texgetdimen("bodyfontsize")
+ end
+ if number then
+ id = number
+ elseif name and name ~= "" then
+ local cs = cs or specification.cs
+ if not cs then
+ n = n + 1 -- beware ... there can be many and they are often used once
+ -- cs = formatters["internal font %s"](n)
+ cs = "internal font " .. n
+ else
+ specification.cs = cs
+ end
+ id = define {
+ name = name,
+ size = size,
+ cs = cs,
+ }
+ end
+ if not id then
+ id = currentfont()
+ end
+ return id, csnames[id]
+ end
+
+ local function read(name,size)
+ return (define { name = name, size = size } or 0)
+ end
+
+ callbacks.register('define_font', read, "definition of fonts (tfmdata preparation)")
+
+ -- here
+
+ local infofont = 0
+
+ function fonts.infofont()
+ if infofont == 0 then
+ infofont = define { name = "dejavusansmono", size = texsp("6pt") }
+ end
+ return infofont
+ end
+
+ -- abstract interfacing
+
+ implement { name = "tf", actions = function() setmacro("fontalternative","tf") end }
+ implement { name = "bf", actions = function() setmacro("fontalternative","bf") end }
+ implement { name = "it", actions = function() setmacro("fontalternative","it") end }
+ implement { name = "sl", actions = function() setmacro("fontalternative","sl") end }
+ implement { name = "bi", actions = function() setmacro("fontalternative","bi") end }
+ implement { name = "bs", actions = function() setmacro("fontalternative","bs") end }
+
+end
+
+-- Not ok, we can best use a database for this. The problem is that we
+-- have delayed definitions and so we never know what style is taken
+-- as start.
+
+function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specification)
+ local parameters = tfmdata.parameters
+ local units = parameters.units or 1000
+ if specification then
+ local scalemode = specification.scalemode
+ local special = scalemode and specialscale[scalemode]
+ if special == "ht" then
+ local height = parameters.ascender / units
+ scaledpoints = scaledpoints / height
+ elseif special == "cp" then
+ local glyph = tfmdata.descriptions[utfbyte("X")]
+ local height = (glyph and glyph.height or parameters.ascender) / units
+ scaledpoints = scaledpoints / height
+ end
+ end
+ if scaledpoints < 0 then
+ scaledpoints = (- scaledpoints/1000) * (tfmdata.designsize or parameters.designsize) -- already in sp
+ end
+ -- a temp hack till we have upgraded all mechanisms
+ local delta = round(scaledpoints/units)
+ local size = round(scaledpoints)
+ texsetcount("c_font_scaled_points",size)
+ --
+ return size, delta
+end
+
+local designsizes = constructors.designsizes
+
+-- called quite often when in mp labels
+-- otf.normalizedaxis
+
+function constructors.hashinstance(specification,force)
+ local hash = specification.hash
+ local size = specification.size
+ local fallbacks = specification.fallbacks
+ if force or not hash then
+ hash = constructors.hashfeatures(specification)
+ specification.hash = hash
+ end
+ if size < 1000 and designsizes[hash] then
+ size = round(constructors.scaled(size,designsizes[hash]))
+ else
+ size = round(size)
+ end
+ specification.size = size
+ if fallbacks then
+ return hash .. ' @ ' .. size .. ' @ ' .. fallbacks
+ else
+ local scalemode = specification.scalemode
+ local special = scalemode and specialscale[scalemode]
+ if special then
+ return hash .. ' @ ' .. size .. ' @ ' .. special
+ else
+ return hash .. ' @ ' .. size
+ end
+ end
+end
+
+-- We overload the (generic) resolver:
+
+local resolvers = definers.resolvers
+local hashfeatures = constructors.hashfeatures
+
+function definers.resolve(specification) -- overload function in font-con.lua
+ if not specification.resolved or specification.resolved == "" then -- resolved itself not per se in mapping hash
+ local r = resolvers[specification.lookup]
+ if r then
+ r(specification)
+ end
+ end
+ if specification.forced == "" then
+ specification.forced = nil
+ else
+ specification.forced = specification.forced
+ end
+ -- goodies are a context specific thing and are not always defined
+ -- as feature, so we need to make sure we add them here before
+ -- hashing because otherwise we get funny goodies applied
+ local goodies = specification.goodies
+ if goodies and goodies ~= "" then
+ -- this adapts the features table so it has best be a copy
+ local normal = specification.features.normal
+ if not normal then
+ specification.features.normal = { goodies = goodies }
+ elseif not normal.goodies then
+ local g = normal.goodies
+ if g and g ~= "" then
+ normal.goodies = formatters["%s,%s"](g,goodies)
+ else
+ normal.goodies = goodies
+ end
+ end
+ end
+ -- so far for goodie hacks
+ local hash = hashfeatures(specification)
+ local name = specification.name or "badfont"
+ local sub = specification.sub
+ if sub and sub ~= "" then
+ specification.hash = lower(name .. " @ " .. sub .. ' @ ' .. hash)
+ else
+ specification.hash = lower(name .. " @ " .. ' @ ' .. hash)
+ end
+ --
+ return specification
+end
+
+-- we need an 'do after the banner hook'
+
+-- => commands
+
+local pattern = P("P")
+ * (lpeg.patterns.hexdigit^4 / function(s) return tonumber(s,16) end)
+ * P(-1)
+
+local function nametoslot(name) -- also supports PXXXXX (4+ positions)
+ local t = type(name)
+ if t == "string" then
+ local unic = unicodes[true]
+ local slot = unic[name]
+ if slot then
+ return slot
+ end
+ --
+ local slot = unic[gsub(name,"_"," ")] or unic[gsub(name,"_","-")] or
+ unic[gsub(name,"-"," ")] or unic[gsub(name,"-","_")] or
+ unic[gsub(name," ","_")] or unic[gsub(name," ","-")]
+ if slot then
+ return slot
+ end
+ --
+ if not aglunicodes then
+ aglunicodes = encodings.agl.unicodes
+ end
+ local char = characters[true]
+ local slot = aglunicodes[name]
+ if slot and char[slot] then
+ return slot
+ end
+ local slot = lpegmatch(pattern,name)
+ if slot and char[slot] then
+ return slot
+ end
+ -- not in font
+ elseif t == "number" then
+ if characters[true][name] then
+ return slot
+ else
+ -- not in font
+ end
+ end
+end
+
+local found = { }
+
+local function descriptiontoslot(name)
+ local t = type(name)
+ if t == "string" then
+ -- slow
+ local list = sortedkeys(chardata) -- can be a cache with weak tables
+ local slot = found[name]
+ local char = characters[true]
+ if slot then
+ return char[slot] and slot or nil
+ end
+ local NAME = upper(name)
+ for i=1,#list do
+ slot = list[i]
+ local c = chardata[slot]
+ local d = c.description
+ if d == NAME then
+ found[name] = slot
+ return char[slot] and slot or nil
+ end
+ end
+ for i=1,#list do
+ slot = list[i]
+ local c = chardata[slot]
+ local s = c.synonyms
+ if s then
+ for i=1,#s do
+ local si = s[i]
+ if si == name then
+ found[name] = si
+ return char[slot] and slot or nil
+ end
+ end
+ end
+ end
+ for i=1,#list do
+ slot = list[i]
+ local c = chardata[slot]
+ local d = c.description
+ if d and find(d,NAME) then
+ found[name] = slot
+ return char[slot] and slot or nil
+ end
+ end
+ for i=1,#list do
+ slot = list[i]
+ local c = chardata[slot]
+ local s = c.synonyms
+ if s then
+ for i=1,#s do
+ local si = s[i]
+ if find(s[i],name) then
+ found[name] = si
+ return char[slot] and slot or nil
+ end
+ end
+ end
+ end
+ -- not in font
+ elseif t == "number" then
+ if characters[true][name] then
+ return slot
+ else
+ -- not in font
+ end
+ end
+end
+
+local function indextoslot(font,index)
+ if not index then
+ index = font
+ font = true
+ end
+ local r = resources[font]
+ if r then
+ local indices = r.indices
+ if not indices then
+ indices = { }
+ local c = characters[font]
+ for unicode, data in next, c do
+ local di = data.index
+ if di then
+ indices[di] = unicode
+ end
+ end
+ r.indices = indices
+ end
+ return indices[tonumber(index)]
+ end
+end
+
+do -- else too many locals
+
+ local entities = characters.entities
+ local lowered = { } -- delayed initialization
+
+ setmetatableindex(lowered,function(t,k)
+ for k, v in next, entities do
+ local l = lower(k)
+ if not entities[l] then
+ lowered[l] = v
+ end
+ end
+ setmetatableindex(lowered,nil)
+ return lowered[k]
+ end)
+
+ local methods = {
+ -- entity
+ e = function(name)
+ return entities[name] or lowered[name] or name
+ end,
+ -- hexadecimal unicode
+ x = function(name)
+ local n = tonumber(name,16)
+ return n and utfchar(n) or name
+ end,
+ -- decimal unicode
+ d = function(name)
+ local n = tonumber(name)
+ return n and utfchar(n) or name
+ end,
+ -- hexadecimal index (slot)
+ s = function(name)
+ local n = tonumber(name,16)
+ local n = n and indextoslot(n)
+ return n and utfchar(n) or name
+ end,
+ -- decimal index
+ i = function(name)
+ local n = tonumber(name)
+ local n = n and indextoslot(n)
+ return n and utfchar(n) or name
+ end,
+ -- name
+ n = function(name)
+ local n = nametoslot(name)
+ return n and utfchar(n) or name
+ end,
+ -- unicode description (synonym)
+ u = function(name)
+ local n = descriptiontoslot(name,false)
+ return n and utfchar(n) or name
+ end,
+ -- all
+ a = function(name)
+ local n = nametoslot(name) or descriptiontoslot(name)
+ return n and utfchar(n) or name
+ end,
+ -- char
+ c = function(name)
+ return name
+ end,
+ }
+
+ -- -- nicer:
+ --
+ -- setmetatableindex(methods,function(t,k) return methods.c end)
+ --
+ -- local splitter = (C(1) * P(":") + Cc("c")) * C(P(1)^1) / function(method,name)
+ -- return methods[method](name)
+ -- end
+ --
+ -- -- more efficient:
+
+ local splitter = C(1) * P(":") * C(P(1)^1) / function(method,name)
+ local action = methods[method]
+ return action and action(name) or name
+ end
+
+ local function tochar(str)
+ local t = type(str)
+ if t == "number" then
+ return utfchar(str)
+ elseif t == "string" then
+ return lpegmatch(splitter,str) or str
+ else
+ return str
+ end
+ end
+
+ helpers.nametoslot = nametoslot
+ helpers.descriptiontoslot = descriptiontoslot
+ helpers.indextoslot = indextoslot
+ helpers.tochar = tochar
+
+ -- interfaces:
+
+ implement {
+ name = "fontchar",
+ actions = { nametoslot, ctx_char },
+ arguments = "string",
+ }
+
+ implement {
+ name = "fontcharbyindex",
+ actions = { indextoslot, ctx_char },
+ arguments = "integer",
+ }
+
+ implement {
+ name = "tochar",
+ actions = { tochar, ctx_safechar },
+ arguments = "string",
+ }
+
+end
+
+-- this will change ...
+
+function loggers.reportdefinedfonts()
+ if trace_usage then
+ local t, tn = { }, 0
+ for id, data in sortedhash(fontdata) do
+ local properties = data.properties or { }
+ local parameters = data.parameters or { }
+ tn = tn + 1
+ t[tn] = {
+ formatters["%03i"](id or 0),
+ formatters["%p" ](parameters.size or 0),
+ properties.format or "unknown",
+ properties.name or "",
+ properties.psname or "",
+ properties.fullname or "",
+ properties.sharedwith or "",
+ }
+ end
+ formatcolumns(t," ")
+ --
+ logs.startfilelogging(report,"defined fonts")
+ for k=1,tn do
+ report(t[k])
+ end
+ logs.stopfilelogging()
+ end
+end
+
+logs.registerfinalactions(loggers.reportdefinedfonts)
+
+function loggers.reportusedfeatures()
+ -- numbers, setups, merged
+ if trace_usage then
+ local t, n = { }, #numbers
+ for i=1,n do
+ local name = numbers[i]
+ local setup = setups[name]
+ local n = setup.number
+ setup.number = nil -- we have no reason to show this
+ t[i] = { i, name, sequenced(setup,false,true) } -- simple mode
+ setup.number = n -- restore it (normally not needed as we're done anyway)
+ end
+ formatcolumns(t," ")
+ logs.startfilelogging(report,"defined featuresets")
+ for k=1,n do
+ report(t[k])
+ end
+ logs.stopfilelogging()
+ end
+end
+
+logs.registerfinalactions(loggers.reportusedfeatures)
+
+-- maybe move this to font-log.lua:
+
+statistics.register("font engine", function()
+ local elapsed = statistics.elapsedseconds(fonts)
+ local nofshared = constructors.nofsharedfonts or 0
+ local nofloaded = constructors.noffontsloaded or 0
+ if nofshared > 0 then
+ return format("otf %0.3f, afm %0.3f, tfm %0.3f, %s instances, %s shared in backend, %s common vectors, %s common hashes, load time %s",
+ otf.version,afm.version,tfm.version,nofloaded,
+ nofshared,constructors.nofsharedvectors,constructors.nofsharedhashes,
+ elapsed)
+ elseif nofloaded > 0 and elapsed then
+ return format("otf %0.3f, afm %0.3f, tfm %0.3f, %s instances, load time %s",
+ otf.version,afm.version,tfm.version,nofloaded,
+ elapsed)
+ else
+ return format("otf %0.3f, afm %0.3f, tfm %0.3f",
+ otf.version,afm.version,tfm.version)
+ end
+end)
+
+-- experimental mechanism for Mojca:
+--
+-- fonts.definetypeface {
+-- name = "mainbodyfont-light",
+-- preset = "antykwapoltawskiego-light",
+-- }
+--
+-- fonts.definetypeface {
+-- name = "mojcasfavourite",
+-- preset = "antykwapoltawskiego",
+-- normalweight = "light",
+-- boldweight = "bold",
+-- width = "condensed",
+-- }
+
+local Shapes = {
+ serif = "Serif",
+ sans = "Sans",
+ mono = "Mono",
+}
+
+local ctx_startfontclass = context.startfontclass
+local ctx_stopfontclass = context.stopfontclass
+local ctx_definefontsynonym = context.definefontsynonym
+local ctx_dofastdefinetypeface = context.dofastdefinetypeface
+
+function fonts.definetypeface(name,t)
+ if type(name) == "table" then
+ -- {name=abc,k=v,...}
+ t = name
+ elseif t then
+ if type(t) == "string" then
+ -- "abc", "k=v,..."
+ t = settings_to_hash(name)
+ else
+ -- "abc", {k=v,...}
+ end
+ t.name = t.name or name
+ else
+ -- "name=abc,k=v,..."
+ t = settings_to_hash(name)
+ end
+ local p = t.preset and fonts.typefaces[t.preset] or { }
+ local name = t.name or "unknowntypeface"
+ local shortcut = t.shortcut or p.shortcut or "rm"
+ local size = t.size or p.size or "default"
+ local shape = t.shape or p.shape or "serif"
+ local fontname = t.fontname or p.fontname or "unknown"
+ local normalweight = t.normalweight or t.weight or p.normalweight or p.weight or "normal"
+ local boldweight = t.boldweight or t.weight or p.boldweight or p.weight or "normal"
+ local normalwidth = t.normalwidth or t.width or p.normalwidth or p.width or "normal"
+ local boldwidth = t.boldwidth or t.width or p.boldwidth or p.width or "normal"
+ Shape = Shapes[shape] or "Serif"
+ ctx_startfontclass { name }
+ ctx_definefontsynonym( { formatters["%s"] (Shape) }, { formatters["spec:%s-%s-regular-%s"] (fontname, normalweight, normalwidth) } )
+ ctx_definefontsynonym( { formatters["%sBold"] (Shape) }, { formatters["spec:%s-%s-regular-%s"] (fontname, boldweight, boldwidth ) } )
+ ctx_definefontsynonym( { formatters["%sBoldItalic"](Shape) }, { formatters["spec:%s-%s-italic-%s"] (fontname, boldweight, boldwidth ) } )
+ ctx_definefontsynonym( { formatters["%sItalic"] (Shape) }, { formatters["spec:%s-%s-italic-%s"] (fontname, normalweight, normalwidth) } )
+ ctx_stopfontclass()
+ local settings = sequenced({ features= t.features },",")
+ ctx_dofastdefinetypeface(name, shortcut, shape, size, settings)
+end
+
+implement {
+ name = "definetypeface",
+ actions = fonts.definetypeface,
+ arguments = "2 strings"
+}
+
+function fonts.current() -- todo: also handle name
+ return fontdata[currentfont()] or fontdata[0]
+end
+
+function fonts.currentid()
+ return currentfont() or 0
+end
+
+-- for the moment here, this will become a chain of extras that is
+-- hooked into the ctx registration (or scaler or ...)
+
+local dimenfactors = number.dimenfactors
+
+function helpers.dimenfactor(unit,id)
+ if unit == "ex" then
+ return id and exheights[id] or 282460 -- lm 10pt
+ elseif unit == "em" then
+ return id and emwidths [id] or 655360 -- lm 10pt
+ else
+ local du = dimenfactors[unit]
+ return du and 1/du or tonumber(unit) or 1
+ end
+end
+
+local function digitwidth(font) -- max(quad/2,wd(0..9))
+ local tfmdata = fontdata[font]
+ local parameters = tfmdata.parameters
+ local width = parameters.digitwidth
+ if not width then
+ width = round(parameters.quad/2) -- maybe tex.scale
+ local characters = tfmdata.characters
+ for i=48,57 do
+ local wd = round(characters[i].width)
+ if wd > width then
+ width = wd
+ end
+ end
+ parameters.digitwidth = width
+ end
+ return width
+end
+
+helpers.getdigitwidth = digitwidth
+helpers.setdigitwidth = digitwidth
+
+--
+
+function helpers.getparameters(tfmdata)
+ local p = { }
+ local m = p
+ local parameters = tfmdata.parameters
+ while true do
+ for k, v in next, parameters do
+ m[k] = v
+ end
+ parameters = getmetatable(parameters)
+ parameters = parameters and parameters.__index
+ if type(parameters) == "table" then
+ m = { }
+ p.metatable = m
+ else
+ break
+ end
+ end
+ return p
+end
+
+if environment.initex then
+
+ local function names(t)
+ local nt = #t
+ if nt > 0 then
+ local n = { }
+ for i=1,nt do
+ n[i] = t[i].name
+ end
+ return concat(n," ")
+ else
+ return "-"
+ end
+ end
+
+ statistics.register("font processing", function()
+ local l = { }
+ for what, handler in table.sortedpairs(handlers) do
+ local features = handler and handler.features
+ if features then
+ l[#l+1] = format("[%s (base initializers: %s) (base processors: %s) (base manipulators: %s) (node initializers: %s) (node processors: %s) (node manipulators: %s)]",
+ what,
+ names(features.initializers.base),
+ names(features.processors .base),
+ names(features.manipulators.base),
+ names(features.initializers.node),
+ names(features.processors .node),
+ names(features.manipulators.node)
+ )
+ end
+ end
+ return concat(l, " | ")
+ end)
+
+end
+
+-- redefinition
+
+-- local hashes = fonts.hashes
+-- local emwidths = hashes.emwidths
+-- local exheights = hashes.exheights
+
+setmetatableindex(dimenfactors, function(t,k)
+ if k == "ex" then
+ return 1/exheights[currentfont()]
+ elseif k == "em" then
+ return 1/emwidths[currentfont()]
+ elseif k == "pct" or k == "%" then
+ return 1/(texget("hsize")/100)
+ else
+ -- error("wrong dimension: " .. (s or "?")) -- better a message
+ return false
+ end
+end)
+
+dimenfactors.ex = nil
+dimenfactors.em = nil
+dimenfactors["%"] = nil
+dimenfactors.pct = nil
+
+--[[ldx--
+
Before a font is passed to we scale it. Here we also need
+to scale virtual characters.
+--ldx]]--
+
+do
+
+ -- can become luat-tex.lua
+
+ local texsetglyphdata = tex.setglyphdata
+ local texgetglyphdata = tex.getglyphdata
+
+ if not texsetglyphdata then
+
+ local texsetattribute = tex.setattribute
+ local texgetattribute = tex.getattribute
+
+ texsetglyphdata = function(n) return texsetattribute(0,n) end
+ texgetglyphdata = function() return texgetattribute(0) end
+
+ tex.setglyphdata = texsetglyphdata
+ tex.getglyphdata = texgetglyphdata
+
+ end
+
+ -- till here
+
+ local setmacro = tokens.setters.macro
+
+ function constructors.currentfonthasfeature(n)
+ local f = fontdata[currentfont()]
+ if not f then return end f = f.shared
+ if not f then return end f = f.rawdata
+ if not f then return end f = f.resources
+ if not f then return end f = f.features
+ return f and (f.gpos[n] or f.gsub[n])
+ end
+
+ local ctx_doifelse = commands.doifelse
+ local ctx_doif = commands.doif
+
+ implement {
+ name = "doifelsecurrentfonthasfeature",
+ actions = { constructors.currentfonthasfeature, ctx_doifelse },
+ arguments = "string"
+ }
+
+ local f_strip = formatters["%0.2fpt"] -- normally this value is changed only once
+ local stripper = lpeg.patterns.stripzeros
+
+ local cache = { }
+
+ local hows = {
+ ["+"] = "add",
+ ["-"] = "subtract",
+ ["="] = "replace",
+ }
+
+ local function setfeature(how,parent,name,font) -- 0/1 test temporary for testing
+ if not how or how == 0 then
+ if trace_features and texgetglyphdata() ~= 0 then
+ report_cummulative("font %!font:name!, reset",fontdata[font or true])
+ end
+ texsetglyphdata(0)
+ elseif how == true or how == 1 then
+ local hash = "feature > " .. parent
+ local done = cache[hash]
+ if trace_features and done then
+ report_cummulative("font %!font:name!, revive %a : %!font:features!",fontdata[font or true],parent,setups[numbers[done]])
+ end
+ texsetglyphdata(done or 0)
+ else
+ local full = parent .. how .. name
+ local hash = "feature > " .. full
+ local done = cache[hash]
+ if not done then
+ local n = setups[full]
+ if n then
+ -- already defined
+ else
+ n = mergecontextfeatures(parent,name,how,full)
+ end
+ done = registercontextfeature(hash,full,how)
+ cache[hash] = done
+ if trace_features then
+ report_cummulative("font %!font:name!, %s %a : %!font:features!",fontdata[font or true],hows[how],full,setups[numbers[done]])
+ end
+ end
+ texsetglyphdata(done)
+ end
+ end
+
+ local function resetfeature()
+ if trace_features and texgetglyphdata() ~= 0 then
+ report_cummulative("font %!font:name!, reset",fontdata[true])
+ end
+ texsetglyphdata(0)
+ end
+
+ local function setfontfeature(tag)
+ texsetglyphdata(contextnumber(tag))
+ end
+
+ local function resetfontfeature()
+ texsetglyphdata(0)
+ end
+
+ implement {
+ name = "nbfs",
+ arguments = "dimen",
+ actions = function(d)
+ context(lpegmatch(stripper,f_strip(d/65536)))
+ end
+ }
+
+ implement {
+ name = "featureattribute",
+ arguments = "string",
+ actions = { contextnumber, context }
+ }
+
+ implement {
+ name = "setfontfeature",
+ arguments = "string",
+ actions = setfontfeature,
+ }
+
+ implement {
+ name = "resetfontfeature",
+ -- arguments = { 0, 0 },
+ actions = resetfontfeature,
+ }
+
+ implement {
+ name = "setfontofid",
+ arguments = "integer",
+ actions = function(id)
+ ctx_getvalue(csnames[id])
+ end
+ }
+
+ implement {
+ name = "definefontfeature",
+ arguments = "3 strings",
+ actions = presetcontext,
+ }
+
+ implement {
+ name = "doifelsefontfeature",
+ arguments = "string",
+ actions = function(name) ctx_doifelse(contextnumber(name) > 1) end,
+ }
+
+ implement {
+ name = "doifunknownfontfeature",
+ arguments = "string",
+ actions = function(name) ctx_doif(contextnumber(name) == 0) end,
+ }
+
+ implement {
+ name = "adaptfontfeature",
+ arguments = "2 strings",
+ actions = adaptcontext
+ }
+
+ local function registerlanguagefeatures()
+ local specifications = languages.data.specifications
+ for i=1,#specifications do
+ local specification = specifications[i]
+ local language = specification.opentype
+ if language then
+ local script = specification.opentypescript or specification.script
+ if script then
+ local context = specification.context
+ if type(context) == "table" then
+ for i=1,#context do
+ definecontext(context[i], { language = language, script = script})
+ end
+ elseif type(context) == "string" then
+ definecontext(context, { language = language, script = script})
+ end
+ end
+ end
+ end
+ end
+
+ constructors.setfeature = setfeature
+ constructors.resetfeature = resetfeature
+
+ implement { name = "resetfeature", actions = resetfeature }
+ implement { name = "addfeature", actions = setfeature, arguments = { "'+'", "string", "string" } }
+ implement { name = "subtractfeature", actions = setfeature, arguments = { "'-'", "string", "string" } }
+ implement { name = "replacefeature", actions = setfeature, arguments = { "'='", "string", "string" } }
+ implement { name = "revivefeature", actions = setfeature, arguments = { true, "string" } }
+
+ implement {
+ name = "featurelist",
+ actions = { fonts.specifiers.contexttostring, context },
+ arguments = { "string", "'otf'", "string", "'yes'", "'no'", true }
+ }
+
+ implement {
+ name = "registerlanguagefeatures",
+ actions = registerlanguagefeatures,
+ }
+
+end
+
+-- a fontkern plug:
+
+-- nodes.injections.installnewkern(nuts.pool.fontkern)
+
+do
+
+ local report = logs.reporter("otf","variants")
+
+ local function replace(tfmdata,feature,value)
+ local characters = tfmdata.characters
+ local variants = tfmdata.resources.variants
+ if variants then
+ local t = { }
+ for k, v in sortedhash(variants) do
+ t[#t+1] = formatters["0x%X (%i)"](k,k)
+ end
+ value = tonumber(value) or 0xFE00 -- 917762
+ report("fontname : %s",tfmdata.properties.fontname)
+ report("available: % t",t)
+ local v = variants[value]
+ if v then
+ report("using : %X (%i)",value,value)
+ for k, v in next, v do
+ local c = characters[v]
+ if c then
+ characters[k] = c
+ end
+ end
+ else
+ report("unknown : %X (%i)",value,value)
+ end
+ end
+ end
+
+ registerotffeature {
+ name = 'variant',
+ description = 'unicode variant',
+ manipulators = {
+ base = replace,
+ node = replace,
+ }
+ }
+
+end
+
+-- here (todo: closure)
+
+-- make a closure (200 limit):
+
+do
+
+ local trace_analyzing = false trackers.register("otf.analyzing", function(v) trace_analyzing = v end)
+
+ local analyzers = fonts.analyzers
+ local methods = analyzers.methods
+
+ local unsetvalue = attributes.unsetvalue
+
+ local a_color = attributes.private('color')
+ local a_colormodel = attributes.private('colormodel')
+ local m_color = attributes.list[a_color] or { }
+
+ local glyph_code = nodes.nodecodes.glyph
+
+ local states = analyzers.states
+
+ local colornames = {
+ [states.init] = "font:1",
+ [states.medi] = "font:2",
+ [states.fina] = "font:3",
+ [states.isol] = "font:4",
+ [states.mark] = "font:5",
+ [states.rest] = "font:6",
+ [states.rphf] = "font:1",
+ [states.half] = "font:2",
+ [states.pref] = "font:3",
+ [states.blwf] = "font:4",
+ [states.pstf] = "font:5",
+ }
+
+ -- todo: traversers
+ -- todo: check attr_list so that we can use the same .. helper: setcolorattr
+
+ local function markstates(head)
+ if head then
+ head = tonut(head)
+ local model = getattr(head,a_colormodel) or 1
+ for glyph in nextchar, head do
+ local a = getstate(glyph)
+ if a then
+ local name = colornames[a]
+ if name then
+ local color = m_color[name]
+ if color then
+ setattr(glyph,a_colormodel,model)
+ setattr(glyph,a_color,color)
+ end
+ end
+ end
+ end
+ end
+ end
+
+ local function analyzeprocessor(head,font,attr)
+ local tfmdata = fontdata[font]
+ local script, language = otf.scriptandlanguage(tfmdata,attr)
+ local action = methods[script]
+ if not action then
+ return head, false
+ end
+ if type(action) == "function" then
+ local head, done = action(head,font,attr)
+ if done and trace_analyzing then
+ markstates(head)
+ end
+ return head, done
+ end
+ action = action[language]
+ if action then
+ local head, done = action(head,font,attr)
+ if done and trace_analyzing then
+ markstates(head)
+ end
+ return head, done
+ else
+ return head, false
+ end
+ end
+
+ registerotffeature { -- adapts
+ name = "analyze",
+ processors = {
+ node = analyzeprocessor,
+ }
+ }
+
+
+ function methods.nocolor(head,font,attr)
+ for n, c, f in nextchar, head do
+ if not font or f == font then
+ setattr(n,a_color,unsetvalue)
+ end
+ end
+ return head, true
+ end
+
+end
+
+
+local function purefontname(name)
+ if type(name) == "number" then
+ name = getfontname(name)
+ end
+ if type(name) == "string" then
+ return basename(name)
+ end
+end
+
+implement {
+ name = "purefontname",
+ actions = { purefontname, context },
+ arguments = "string",
+}
+
+local sharedstorage = storage.shared
+
+local list = sharedstorage.bodyfontsizes or { }
+local unknown = sharedstorage.unknownbodyfontsizes or { }
+
+sharedstorage.bodyfontsizes = list
+sharedstorage.unknownbodyfontsizes = unknown
+
+implement {
+ name = "registerbodyfontsize",
+ arguments = "string",
+ actions = function(size)
+ list[size] = true
+ end
+}
+
+interfaces.implement {
+ name = "registerunknownbodysize",
+ arguments = "string",
+ actions = function(size)
+ if not unknown[size] then
+ interfaces.showmessage("fonts",14,size)
+ end
+ unknown[size] = true
+ end,
+}
+
+implement {
+ name = "getbodyfontsizes",
+ arguments = "string",
+ actions = function(separator)
+ context(concat(sortedkeys(list),separator))
+ end
+}
+
+implement {
+ name = "processbodyfontsizes",
+ arguments = "string",
+ actions = function(command)
+ local keys = sortedkeys(list)
+ if command then
+ local action = context[command]
+ for i=1,#keys do
+ action(keys[i])
+ end
+ else
+ context(concat(keys,","))
+ end
+ end
+}
+
+implement {
+ name = "cleanfontname",
+ actions = { cleanname, context },
+ arguments = "string"
+}
+
+implement {
+ name = "fontlookupinitialize",
+ actions = names.lookup,
+ arguments = "string",
+}
+
+implement {
+ name = "fontlookupnoffound",
+ actions = { names.noflookups, context },
+}
+
+implement {
+ name = "fontlookupgetkeyofindex",
+ actions = { names.getlookupkey, context },
+ arguments = { "string", "integer"}
+}
+
+implement {
+ name = "fontlookupgetkey",
+ actions = { names.getlookupkey, context },
+ arguments = "string"
+}
+
+-- this might move to a runtime module:
+
+function commands.showchardata(n)
+ local tfmdata = fontdata[currentfont()]
+ if tfmdata then
+ if type(n) == "string" then
+ n = utfbyte(n)
+ end
+ local chr = tfmdata.characters[n]
+ if chr then
+ report_status("%s @ %s => %U => %c => %s",tfmdata.properties.fullname,tfmdata.parameters.size,n,n,serialize(chr,false))
+ end
+ end
+end
+
+function commands.showfontparameters(tfmdata)
+ -- this will become more clever
+ local tfmdata = tfmdata or fontdata[currentfont()]
+ if tfmdata then
+ local parameters = tfmdata.parameters
+ local mathparameters = tfmdata.mathparameters
+ local properties = tfmdata.properties
+ local hasparameters = parameters and next(parameters)
+ local hasmathparameters = mathparameters and next(mathparameters)
+ if hasparameters then
+ report_status("%s @ %s => text parameters => %s",properties.fullname,parameters.size,serialize(parameters,false))
+ end
+ if hasmathparameters then
+ report_status("%s @ %s => math parameters => %s",properties.fullname,parameters.size,serialize(mathparameters,false))
+ end
+ if not hasparameters and not hasmathparameters then
+ report_status("%s @ %s => no text parameters and/or math parameters",properties.fullname,parameters.size)
+ end
+ end
+end
+
+implement {
+ name = "currentdesignsize",
+ actions = function()
+ context(parameters[currentfont()].designsize)
+ end
+}
+
+implement {
+ name = "doifelsefontpresent",
+ actions = { names.exists, commands.doifelse },
+ arguments = "string"
+}
+
+-- we use 0xFE000+ and 0xFF000+ in math and for runtime (text) extensions we
+-- use 0xFD000+
+
+constructors.privateslots = constructors.privateslots or { }
+
+storage.register("fonts/constructors/privateslots", constructors.privateslots, "fonts.constructors.privateslots")
+
+do
+
+ local privateslots = constructors.privateslots
+ local lastprivateslot = 0xFD000
+
+ constructors.privateslots = setmetatableindex(privateslots,function(t,k)
+ local v = lastprivateslot
+ lastprivateslot = lastprivateslot + 1
+ t[k] = v
+ return v
+ end)
+
+ implement {
+ name = "getprivateglyphslot",
+ actions = function(name) context(privateslots[name]) end,
+ arguments = "string",
+ }
+
+end
+
+-- an extra helper
+
+function helpers.getcoloredglyphs(tfmdata)
+ if type(tfmdata) == "number" then
+ tfmdata = fontdata[tfmdata]
+ end
+ if not tfmdata then
+ tfmdata = fontdata[true]
+ end
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local collected = { }
+ for unicode, character in next, characters do
+ local description = descriptions[unicode]
+ if description and (description.colors or character.svg) then
+ collected[#collected+1] = unicode
+ end
+ end
+ table.sort(collected)
+ return collected
+end
+
+-- for the font manual
+
+statistics.register("body font sizes", function()
+ if next(unknown) then
+ return formatters["defined: % t, undefined: % t"](sortedkeys(list),sortedkeys(unknown))
+ end
+end)
+
+statistics.register("used fonts",function()
+ if trace_usage then
+ local filename = file.nameonly(environment.jobname) .. "-fonts-usage.lua"
+ if next(fontdata) then
+ local files = { }
+ local list = { }
+ for id, tfmdata in sortedhash(fontdata) do
+ local filename = tfmdata.properties.filename
+ if filename then
+ local filedata = files[filename]
+ if filedata then
+ filedata.instances = filedata.instances + 1
+ else
+ local rawdata = tfmdata.shared and tfmdata.shared.rawdata
+ local metadata = rawdata and rawdata.metadata
+ files[filename] = {
+ instances = 1,
+ filename = filename,
+ version = metadata and metadata.version,
+ size = rawdata and rawdata.size,
+ }
+ end
+ else
+ -- what to do
+ end
+ end
+ for k, v in sortedhash(files) do
+ list[#list+1] = v
+ end
+ table.save(filename,list)
+ else
+ os.remove(filename)
+ end
+ end
+end)
+
+-- new
+
+do
+
+ local settings_to_array = utilities.parsers.settings_to_array
+
+ implement {
+ name = "definefontcolorpalette",
+ arguments = "2 strings",
+ actions = function(name,set)
+ otf.registerpalette(name,settings_to_array(set))
+ end
+ }
+
+end
+
+do
+
+ local pattern = C((1-S("* "))^1) -- strips all after * or ' at'
+
+ implement {
+ name = "truefontname",
+ arguments = "string",
+ actions = function(s)
+ -- context(match(s,"[^* ]+") or s)
+ context(lpegmatch(pattern,s) or s)
+ end
+ }
+
+end
+
+do
+
+ local function getinstancespec(id)
+ local data = fontdata[id or true]
+ local shared = data.shared
+ local resources = shared and shared.rawdata.resources
+ if resources then
+ local instancespec = data.properties.instance
+ if instancespec then
+ local variabledata = resources.variabledata
+ if variabledata then
+ local instances = variabledata.instances
+ if instances then
+ for i=1,#instances do
+ local instance = instances[i]
+ if cleanname(instance.subfamily)== instancespec then
+ local values = table.copy(instance.values)
+ local axis = variabledata.axis
+ for i=1,#values do
+ for j=1,#axis do
+ if values[i].axis == axis[j].tag then
+ values[i].name = axis[j].name
+ break
+ end
+ end
+ end
+ return values
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ helpers.getinstancespec = getinstancespec
+
+ -- expandable
+
+ implement {
+ name = "currentfontinstancespec",
+ public = true,
+ actions = function()
+ local t = getinstancespec() -- current font
+ if t then
+ for i=1,#t do
+ if i > 1 then
+ context.space()
+ end
+ local ti = t[i]
+ context("%s=%s",ti.name,ti.value)
+ end
+ end
+ end
+ }
+
+end
+
+-- for the moment here (and not in font-con.lua):
+
+do
+
+ local identical = table.identical
+ local copy = table.copy
+ local fontdata = fonts.hashes.identifiers
+ local addcharacters = font.addcharacters
+
+ -- This helper is mostly meant to add last-resort (virtual) characters
+ -- or runtime generated fonts (so we forget about features and such). It
+ -- will probably take a while before it get used.
+
+ local trace_adding = false
+ local report_adding = logs.reporter("fonts","add characters")
+
+ trackers.register("fonts.addcharacters",function(v) trace_adding = v end)
+
+ function constructors.addcharacters(id,list)
+ local newchar = list.characters
+ if newchar then
+ local data = fontdata[id]
+ local newfont = list.fonts
+ local oldchar = data.characters
+ local oldfont = data.fonts
+ addcharacters(id, {
+ characters = newchar,
+ fonts = newfont,
+ nomath = not data.properties.hasmath,
+ })
+ -- this is just for tracing, as the assignment only uses the fonts list
+ -- and doesn't store it otherwise
+ if newfont then
+ if oldfont then
+ local oldn = #oldfont
+ local newn = #newfont
+ for n=1,newn do
+ local ok = false
+ local nf = newfont[n]
+ for o=1,oldn do
+ if identical(nf,oldfont[o]) then
+ ok = true
+ break
+ end
+ end
+ if not ok then
+ oldn = oldn + 1
+ oldfont[oldn] = newfont[i]
+ end
+ end
+ else
+ data.fonts = newfont
+ end
+ end
+ -- this is because we need to know what goes on and also might
+ -- want to access character data
+ for u, c in next, newchar do
+ if trace_adding then
+ report_adding("adding character %U to font %!font:name!",u,id)
+ end
+ oldchar[u] = c
+ end
+ end
+ end
+
+ implement {
+ name = "addfontpath",
+ arguments = "string",
+ actions = function(list)
+ names.addruntimepath(settings_to_array(list))
+ end
+ }
+
+end
+
+-- moved here
+
+do
+
+ local getfontoffamily = font.getfontoffamily
+ local new_glyph = nodes.pool.glyph
+ local fontproperties = fonts.hashes.properties
+
+ local function getprivateslot(id,name)
+ if not name then
+ name = id
+ id = currentfont()
+ end
+ local properties = fontproperties[id]
+ local privates = properties and properties.privates
+ return privates and privates[name]
+ end
+
+ local function getprivatenode(tfmdata,name)
+ if type(tfmdata) == "number" then
+ tfmdata = fontdata[tfmdata]
+ end
+ local properties = tfmdata.properties
+ local font = properties.id
+ local slot = getprivateslot(font,name)
+ if slot then
+ -- todo: set current attribibutes
+ local char = tfmdata.characters[slot]
+ local tonode = char.tonode
+ if tonode then
+ return tonode(font,char)
+ else
+ return new_glyph(font,slot)
+ end
+ end
+ end
+
+ local function getprivatecharornode(tfmdata,name)
+ if type(tfmdata) == "number" then
+ tfmdata = fontdata[tfmdata]
+ end
+ local properties = tfmdata.properties
+ local font = properties.id
+ local slot = getprivateslot(font,name)
+ if slot then
+ -- todo: set current attributes
+ local char = tfmdata.characters[slot]
+ local tonode = char.tonode
+ if tonode then
+ return "node", tonode(tfmdata,char)
+ else
+ return "char", slot
+ end
+ end
+ end
+
+ helpers.getprivateslot = getprivateslot
+ helpers.getprivatenode = getprivatenode
+ helpers.getprivatecharornode = getprivatecharornode
+
+ implement {
+ name = "getprivatechar",
+ arguments = "string",
+ actions = function(name)
+ local p = getprivateslot(name)
+ if p then
+ context(utfchar(p))
+ end
+ end
+ }
+
+ implement {
+ name = "getprivatemathchar",
+ arguments = "string",
+ actions = function(name)
+ local p = getprivateslot(getfontoffamily(0),name)
+ if p then
+ context(utfchar(p))
+ end
+ end
+ }
+
+ implement {
+ name = "getprivateslot",
+ arguments = "string",
+ actions = function(name)
+ local p = getprivateslot(name)
+ if p then
+ context(p)
+ end
+ end
+ }
+
+end
+
+-- handy, for now here:
+
+function fonts.helpers.collectanchors(tfmdata)
+
+ local resources = tfmdata.resources -- todo: use shared
+
+ if not resources or resources.anchors then
+ return resources.anchors
+ end
+
+ local anchors = { }
+
+ local function set(unicode,target,class,anchor)
+ local a = anchors[unicode]
+ if not a then
+ anchors[unicode] = { [target] = { anchor } }
+ return
+ end
+ local t = a[target]
+ if not t then
+ a[target] = { anchor }
+ return
+ end
+ local x = anchor[1]
+ local y = anchor[2]
+ for k, v in next, t do
+ if v[1] == x and v[2] == y then
+ return
+ end
+ end
+ t[#t+1] = anchor
+ end
+
+ local function getanchors(steps,target)
+ for i=1,#steps do
+ local step = steps[i]
+ local coverage = step.coverage
+ for unicode, data in next, coverage do
+ local class = data[1]
+ local anchor = data[2]
+ if anchor[1] ~= 0 or anchor[2] ~= 0 then
+ set(unicode,target,class,anchor)
+ end
+ end
+ end
+ end
+
+ local function getcursives(steps)
+ for i=1,#steps do
+ local step = steps[i]
+ local coverage = step.coverage
+ for unicode, data in next, coverage do
+ local class = data[1]
+ local en = data[2]
+ local ex = data[3]
+ if en then
+ set(unicode,"entry",class,en)
+ end
+ if ex then
+ set(unicode,"exit", class,ex)
+ end
+ end
+ end
+ end
+
+ local function collect(list)
+ if list then
+ for i=1,#list do
+ local entry = list[i]
+ local steps = entry.steps
+ local kind = entry.type
+ if kind == "gpos_mark2mark" then
+ getanchors(steps,"mark")
+ elseif kind == "gpos_mark2base" then
+ getanchors(steps,"base")
+ elseif kind == "gpos_mark2ligature" then
+ getanchors(steps,"ligature")
+ elseif kind == "gpos_cursive" then
+ getcursives(steps)
+ end
+ end
+ end
+ end
+
+ collect(resources.sequences)
+ collect(resources.sublookups)
+
+ local function sorter(a,b)
+ if a[1] == b[1] then
+ return a[2] < b[2]
+ else
+ return a[1] < b[1]
+ end
+ end
+
+ for unicode, old in next, anchors do
+ for target, list in next, old do
+ sort(list,sorter)
+ end
+ end
+
+ resources.anchors = anchors
+
+ return anchors
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-def.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-def.lmt
new file mode 100644
index 00000000000..614f9803606
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-def.lmt
@@ -0,0 +1,516 @@
+if not modules then modules = { } end modules ['font-def'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- We can overload some of the definers.functions so we don't local them.
+
+local lower, gsub = string.lower, string.gsub
+local tostring, next = tostring, next
+local lpegmatch = lpeg.match
+local suffixonly, removesuffix, basename = file.suffix, file.removesuffix, file.basename
+local formatters = string.formatters
+local sortedhash, sortedkeys, setmetatableindex = table.sortedhash, table.sortedkeys, table.setmetatableindex
+
+local allocate = utilities.storage.allocate
+
+local trace_defining = false trackers .register("fonts.defining", function(v) trace_defining = v end)
+local directive_embedall = false directives.register("fonts.embedall", function(v) directive_embedall = v end)
+
+trackers.register("fonts.loading", "fonts.defining", "otf.loading", "afm.loading", "tfm.loading")
+
+local report_defining = logs.reporter("fonts","defining")
+
+--[[ldx--
+
Here we deal with defining fonts. We do so by intercepting the
+default loader that only handles .
+--ldx]]--
+
+local nextfont = font.nextid
+
+local fonts = fonts
+local fontdata = fonts.hashes.identifiers
+local readers = fonts.readers
+local definers = fonts.definers
+local specifiers = fonts.specifiers
+local constructors = fonts.constructors
+local fontgoodies = fonts.goodies
+
+readers.sequence = allocate { 'otf', 'ttf', 'afm', 'tfm', 'lua' } -- dfont ttc
+
+local variants = allocate()
+specifiers.variants = variants
+
+definers.methods = definers.methods or { }
+
+local internalized = allocate() -- internal tex numbers (private)
+
+local loadedfonts = constructors.loadedfonts
+local designsizes = constructors.designsizes
+
+-- not in generic (some day I'll make two defs, one for context, one for generic)
+
+local resolvefile = fontgoodies and fontgoodies.filenames and fontgoodies.filenames.resolve or function(s) return s end
+
+--[[ldx--
+
We hardly gain anything when we cache the final (pre scaled)
+ table. But it can be handy for debugging, so we no
+longer carry this code along. Also, we now have quite some reference
+to other tables so we would end up with lots of catches.
+--ldx]]--
+
+--[[ldx--
+
We can prefix a font specification by name: or
+file:. The first case will result in a lookup in the
+synonym table.
The following function split the font specification into components
+and prepares a table that will move along as we proceed.
+--ldx]]--
+
+-- beware, we discard additional specs
+--
+-- method:name method:name(sub) method:name(sub)*spec method:name*spec
+-- name name(sub) name(sub)*spec name*spec
+-- name@spec*oeps
+
+local function makespecification(specification,lookup,name,sub,method,detail,size)
+ size = size or 655360
+ if not lookup or lookup == "" then
+ lookup = definers.defaultlookup
+ end
+ if trace_defining then
+ report_defining("specification %a, lookup %a, name %a, sub %a, method %a, detail %a",
+ specification, lookup, name, sub, method, detail)
+ end
+ local t = {
+ lookup = lookup, -- forced type
+ specification = specification, -- full specification
+ size = size, -- size in scaled points or -1000*n
+ name = name, -- font or filename
+ sub = sub, -- subfont (eg in ttc)
+ method = method, -- specification method
+ detail = detail, -- specification
+ resolved = "", -- resolved font name
+ forced = "", -- forced loader
+ features = { }, -- preprocessed features
+ }
+ return t
+end
+
+definers.makespecification = makespecification
+
+do
+
+ local splitter, splitspecifiers = nil, "" -- not so nice
+
+ local P, C, S, Cc, Cs = lpeg.P, lpeg.C, lpeg.S, lpeg.Cc, lpeg.Cs
+
+ local left = P("(")
+ local right = P(")")
+ local colon = P(":")
+ local space = P(" ")
+ local lbrace = P("{")
+ local rbrace = P("}")
+
+ definers.defaultlookup = "file"
+
+ local prefixpattern = P(false)
+
+ local function addspecifier(symbol)
+ splitspecifiers = splitspecifiers .. symbol
+ local method = S(splitspecifiers)
+ local lookup = C(prefixpattern) * colon
+ local sub = left * C(P(1-left-right-method)^1) * right
+ local specification = C(method) * C(P(1)^1)
+ local name = Cs((lbrace/"") * (1-rbrace)^1 * (rbrace/"") + (1-sub-specification)^1)
+ splitter = P((lookup + Cc("")) * name * (sub + Cc("")) * (specification + Cc("")))
+ end
+
+ local function addlookup(str)
+ prefixpattern = prefixpattern + P(str)
+ end
+
+ definers.addlookup = addlookup
+
+ addlookup("file")
+ addlookup("name")
+ addlookup("spec")
+
+ local function getspecification(str)
+ return lpegmatch(splitter,str or "") -- weird catch
+ end
+
+ definers.getspecification = getspecification
+
+ function definers.registersplit(symbol,action,verbosename)
+ addspecifier(symbol)
+ variants[symbol] = action
+ if verbosename then
+ variants[verbosename] = action
+ end
+ end
+
+ function definers.analyze(specification, size)
+ -- can be optimized with locals
+ local lookup, name, sub, method, detail = getspecification(specification or "")
+ return makespecification(specification, lookup, name, sub, method, detail, size)
+ end
+
+end
+
+--[[ldx--
+
We can resolve the filename using the next function:
+--ldx]]--
+
+definers.resolvers = definers.resolvers or { }
+local resolvers = definers.resolvers
+
+-- todo: reporter
+
+function resolvers.file(specification)
+ local name = resolvefile(specification.name) -- catch for renames
+ local suffix = lower(suffixonly(name))
+ if fonts.formats[suffix] then
+ specification.forced = suffix
+ specification.forcedname = name
+ specification.name = removesuffix(name)
+ else
+ specification.name = name -- can be resolved
+ end
+end
+
+function resolvers.name(specification)
+ local resolve = fonts.names.resolve
+ if resolve then
+ local resolved, sub, subindex, instance = resolve(specification.name,specification.sub,specification) -- we pass specification for overloaded versions
+ if resolved then
+ specification.resolved = resolved
+ specification.sub = sub
+ specification.subindex = subindex
+ -- new, needed for experiments
+ if instance then
+ specification.instance = instance
+ local features = specification.features
+ if not features then
+ features = { }
+ specification.features = features
+ end
+ local normal = features.normal
+ if not normal then
+ normal = { }
+ features.normal = normal
+ end
+ normal.instance = instance
+ end
+ --
+ local suffix = lower(suffixonly(resolved))
+ if fonts.formats[suffix] then
+ specification.forced = suffix
+ specification.forcedname = resolved
+ specification.name = removesuffix(resolved)
+ else
+ specification.name = resolved
+ end
+ end
+ else
+ resolvers.file(specification)
+ end
+end
+
+function resolvers.spec(specification)
+ local resolvespec = fonts.names.resolvespec
+ if resolvespec then
+ local resolved, sub, subindex = resolvespec(specification.name,specification.sub,specification) -- we pass specification for overloaded versions
+ if resolved then
+ specification.resolved = resolved
+ specification.sub = sub
+ specification.subindex = subindex
+ specification.forced = lower(suffixonly(resolved))
+ specification.forcedname = resolved
+ specification.name = removesuffix(resolved)
+ end
+ else
+ resolvers.name(specification)
+ end
+end
+
+function definers.resolve(specification)
+ if not specification.resolved or specification.resolved == "" then -- resolved itself not per se in mapping hash
+ local r = resolvers[specification.lookup]
+ if r then
+ r(specification)
+ end
+ end
+ if specification.forced == "" then
+ specification.forced = nil
+ specification.forcedname = nil
+ end
+ specification.hash = lower(specification.name .. ' @ ' .. constructors.hashfeatures(specification))
+ if specification.sub and specification.sub ~= "" then
+ specification.hash = specification.sub .. ' @ ' .. specification.hash
+ end
+ return specification
+end
+
+--[[ldx--
+
The main read function either uses a forced reader (as determined by
+a lookup) or tries to resolve the name using the list of readers.
+
+
We need to cache when possible. We do cache raw tfm data (from , or ). After that we can cache based
+on specificstion (name) and size, that is, only needs a number
+for an already loaded fonts. However, it may make sense to cache fonts
+before they're scaled as well (store 's with applied methods
+and features). However, there may be a relation between the size and
+features (esp in virtual fonts) so let's not do that now.
+
+
Watch out, here we do load a font, but we don't prepare the
+specification yet.
+--ldx]]--
+
+-- very experimental:
+
+function definers.applypostprocessors(tfmdata)
+ local postprocessors = tfmdata.postprocessors
+ if postprocessors then
+ local properties = tfmdata.properties
+ for i=1,#postprocessors do
+ local extrahash = postprocessors[i](tfmdata) -- after scaling etc
+ if type(extrahash) == "string" and extrahash ~= "" then
+ -- e.g. a reencoding needs this
+ extrahash = gsub(lower(extrahash),"[^a-z]","-")
+ properties.fullname = formatters["%s-%s"](properties.fullname,extrahash)
+ end
+ end
+ end
+ return tfmdata
+end
+
+-- function definers.applypostprocessors(tfmdata)
+-- return tfmdata
+-- end
+
+local function checkfeatures(tfmdata)
+ local resources = tfmdata.resources
+ local shared = tfmdata.shared
+ if resources and shared then
+ local features = resources.features
+ local usedfeatures = shared.features
+ if features and usedfeatures then
+ local usedlanguage = usedfeatures.language or "dflt"
+ local usedscript = usedfeatures.script or "dflt"
+ local function check(what)
+ if what then
+ local foundlanguages = { }
+ for feature, scripts in next, what do
+ if usedscript == "auto" or scripts["*"] then
+ -- ok
+ elseif not scripts[usedscript] then
+ -- report_defining("font %!font:name!, feature %a, no script %a",
+ -- tfmdata,feature,usedscript)
+ else
+ for script, languages in next, scripts do
+ if languages["*"] then
+ -- ok
+ elseif not languages[usedlanguage] then
+ report_defining("font %!font:name!, feature %a, script %a, no language %a",
+ tfmdata,feature,script,usedlanguage)
+ end
+ end
+ end
+ for script, languages in next, scripts do
+ for language in next, languages do
+ foundlanguages[language] = true
+ end
+ end
+ end
+ if false then
+ foundlanguages["*"] = nil
+ foundlanguages = sortedkeys(foundlanguages)
+ for feature, scripts in sortedhash(what) do
+ for script, languages in next, scripts do
+ if not languages["*"] then
+ for i=1,#foundlanguages do
+ local language = foundlanguages[i]
+ if not languages[language] then
+ report_defining("font %!font:name!, feature %a, script %a, no language %a",
+ tfmdata,feature,script,language)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ check(features.gsub)
+ check(features.gpos)
+ end
+ end
+end
+
+local reported = setmetatableindex(function(t,k)
+ t[k] = true
+ return false
+end)
+
+function definers.loadfont(specification)
+ local hash = constructors.hashinstance(specification)
+ -- todo: also hash by instance / factors
+ local tfmdata = loadedfonts[hash] -- hashes by size !
+ local name = specification.name
+ if not tfmdata then
+ -- normally context will not end up here often (if so there is an issue somewhere)
+ local forced = specification.forced or ""
+local id = nextfont(true)
+specification.id = id
+ if forced ~= "" then
+ local reader = readers[lower(forced)] -- normally forced is already lowered
+ tfmdata = reader and reader(specification)
+ if not tfmdata and not reported[name] then
+ report_defining("forced type %a of %a not found",forced,name)
+ end
+ else
+ local sequence = readers.sequence -- can be overloaded so only a shortcut here
+ for s=1,#sequence do
+ local reader = sequence[s]
+ if readers[reader] then -- we skip not loaded readers
+ if trace_defining then
+ report_defining("trying (reader sequence driven) type %a for %a with file %a",reader,specification.name,specification.filename)
+ end
+ tfmdata = readers[reader](specification)
+ if tfmdata then
+ break
+ else
+ specification.filename = nil
+ end
+ end
+ end
+ end
+ if tfmdata then
+ tfmdata = definers.applypostprocessors(tfmdata)
+ loadedfonts[hash] = tfmdata
+ designsizes[specification.hash] = tfmdata.parameters.designsize
+ checkfeatures(tfmdata)
+ end
+ end
+ if not tfmdata and not reported[name] then
+ report_defining("font with asked name %a is not found using lookup %a",name,specification.lookup)
+ end
+ return tfmdata
+end
+
+function constructors.readanddefine(name,size) -- no id -- maybe a dummy first
+ local specification = definers.analyze(name,size)
+ local method = specification.method
+ if method and variants[method] then
+ specification = variants[method](specification)
+ end
+ specification = definers.resolve(specification)
+ local hash = constructors.hashinstance(specification)
+ local id = definers.registered(hash)
+ if not id then
+ local tfmdata = definers.loadfont(specification)
+ if tfmdata then
+ tfmdata.properties.hash = hash
+ id = font.define(tfmdata)
+ definers.register(tfmdata,id)
+ else
+ id = 0 -- signal
+ end
+ end
+ return fontdata[id], id
+end
+
+--[[ldx--
+
So far the specifiers. Now comes the real definer. Here we cache
+based on id's. Here we also intercept the virtual font handler. Since
+it evolved stepwise I may rewrite this bit (combine code).
+
+In the previously defined reader (the one resulting in a
+table) we cached the (scaled) instances. Here we cache them again, but
+this time based on id. We could combine this in one cache but this does
+not gain much. By the way, passing id's back to in the callback was
+introduced later in the development.
+--ldx]]--
+
+function definers.registered(hash)
+ local id = internalized[hash]
+ return id, id and fontdata[id]
+end
+
+function definers.register(tfmdata,id)
+ if tfmdata and id then
+ local hash = tfmdata.properties.hash
+ if not hash then
+ report_defining("registering font, id %a, name %a, invalid hash",id,tfmdata.properties.filename or "?")
+ elseif not internalized[hash] then
+ internalized[hash] = id
+ if trace_defining then
+ report_defining("registering font, id %s, hash %a",id,hash)
+ end
+ fontdata[id] = tfmdata
+ end
+ end
+end
+
+function definers.read(specification,size,id) -- id can be optional, name can already be table
+ statistics.starttiming(fonts)
+ if type(specification) == "string" then
+ specification = definers.analyze(specification,size)
+ end
+ local method = specification.method
+ if method and variants[method] then
+ specification = variants[method](specification)
+ end
+ specification = definers.resolve(specification)
+ local hash = constructors.hashinstance(specification)
+ local tfmdata = definers.registered(hash) -- id
+ local name = specification.name
+ if tfmdata then
+ if trace_defining then
+ report_defining("already hashed: %s",hash)
+ end
+ else
+ tfmdata = definers.loadfont(specification) -- can be overloaded
+ if tfmdata then
+ tfmdata.original = specification.specification
+ if trace_defining then
+ report_defining("loaded and hashed: %s",hash)
+ end
+ tfmdata.properties.hash = hash
+ if id then
+ definers.register(tfmdata,id)
+ end
+ else
+ if trace_defining then
+ report_defining("not loaded and hashed: %s",hash)
+ end
+ end
+ end
+ if not tfmdata then -- or id?
+ if not reported[name] then
+ report_defining( "unknown font %a, loading aborted",name)
+ end
+ elseif trace_defining and type(tfmdata) == "table" then
+ local properties = tfmdata.properties or { }
+ local parameters = tfmdata.parameters or { }
+ report_defining("using %a font with id %a, name %a, size %a, fullname %a, filename %a",
+ properties.format or "unknown", id or "-", properties.name, parameters.size,
+ properties.fullname, basename(properties.filename))
+ end
+ statistics.stoptiming(fonts)
+ return tfmdata
+end
+
+function font.getfont(id)
+ return fontdata[id] -- otherwise issues
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-emp.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-emp.mklx
new file mode 100644
index 00000000000..1e30e701264
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-emp.mklx
@@ -0,0 +1,268 @@
+%D \module
+%D [ file=font-emp,
+%D version=20120106, % (moved from font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Emphasis,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Emphasis}
+
+\unprotect
+
+%D \macros
+%D {em,emphasistypeface,emphasisboldface}
+%D
+%D The next macro started as a copy of Donald Arseneau's \type {\em} (\TUGNEWS\
+%D Vol.~3, no.~1, 1994). His implementation was a bit more sophisticated version of
+%D the standard \LATEX\ one. We further enhanced the macro, so now it also adapts
+%D itself to boldface mode. Because we favor {\sl slanted} type over {\it italic},
+%D we made the emphasis adaptable, for instance:
+%D
+%D \starttyping
+%D \def\emphasistypeface {\it}
+%D \def\emphasisboldface {\bi}
+%D \stoptyping
+%D
+%D But we prefer:
+%D
+%D \starttyping
+%D \protected\def\emphasistypeface{\sl}
+%D \protected\def\emphasisboldface{\bs}
+%D \stoptyping
+%D
+%D or even better:
+
+\let\m_font_emphasized_typeface\empty
+
+\def\font_emphasis_checked_typeface#slanted#italic%
+ {\edef\m_font_emphasized_typeface{\font_bodyfontvariable\s!em}%
+ \ifx\m_font_emphasized_typeface\v!slanted
+ #slanted%
+ \orelse\ifx\m_font_emphasized_typeface\v!italic
+ #italic%
+ \orelse\ifempty\m_font_emphasized_typeface
+ #slanted%
+ \else
+ \csname\m_font_emphasized_typeface\endcsname
+ \fi}
+
+\permanent\protected\def\emphasistypeface{\font_emphasis_checked_typeface\sl\it}
+\permanent\protected\def\emphasisboldface{\font_emphasis_checked_typeface\bs\bi}
+
+\permanent\protected\def\normalboldface % public
+ {\relax
+ \ifx\fontalternative\s!it\bi\orelse
+ \ifx\fontalternative\s!sl\bs\else
+ \bf\fi}
+
+\permanent\protected\def\normalitalicface % public
+ {\relax
+ \ifx\fontalternative\s!tf\it\orelse
+ \ifx\fontalternative\s!bf\bi\else
+ \tf\fi}
+
+\permanent\protected\def\normalslantedface % public
+ {\relax \ifx\fontalternative\s!tf\sl
+ \orelse\ifx\fontalternative\s!bf\bs
+ \else \tf\fi}
+
+\permanent\protected\def\normaltypeface % public
+ {\relax
+ \ifx\fontalternative\s!bi \it \orelse
+ \ifx\fontalternative\s!bs \sl \else
+ \tf \fi}
+
+\permanent\protected\def\swaptypeface % public
+ {\relax
+ \ifx\fontalternative\s!it \tf \orelse
+ \ifx\fontalternative\s!sl \tf \orelse
+ \ifx\fontalternative\s!bf \emphasisboldface \orelse
+ \ifx\fontalternative\s!bs \bf \orelse
+ \ifx\fontalternative\s!bi \bf \else
+ \emphasistypeface \fi}
+
+\aliased\let\typeface \normaltypeface % public
+\aliased\let\boldface \normalboldface % public
+\aliased\let\slantedface\normalslantedface % public
+\aliased\let\italicface \normalitalicface % public
+\aliased\let\swapface \swaptypeface % public
+
+%D To be set with the default body font environment: \type {em} being \type
+%D {slanted} or \type {italic}.
+
+% maybe a \csname...\fontalternative\endcsname
+
+\newconditional\c_font_emphasis_needed
+
+\permanent\protected\def\em
+ {\relax
+ \ifdim\slantperpoint>\zeropoint
+ \settrue\c_font_emphasis_needed
+ \else
+ \setfalse\c_font_emphasis_needed
+ \fi
+ \font_emphasis_set_emphasis_boldface % new
+ \ifx\fontalternative\s!it
+ \enforced\permanent\protected\def\emphasistypeface{\it}\tf
+ \orelse\ifx\fontalternative\s!sl
+ \enforced\permanent\protected\def\emphasistypeface{\sl}\tf
+ \orelse\ifx\fontalternative\s!bf
+ \emphasisboldface
+ \orelse\ifx\fontalternative\s!bs
+ \enforced\permanent\protected\def\emphasisboldface{\bs}\bf
+ \orelse\ifx\fontalternative\s!bi
+ \enforced\permanent\protected\def\emphasisboldface{\bi}\bf
+ \else
+ \emphasistypeface
+ \fi
+ \ifconditional\c_font_emphasis_needed\else
+ \expandafter\aftergroup
+ \fi
+ \emphasiscorrection}
+
+%D The next feature was not present in previous versions. It takes care of \type
+%D {\em \bf ...} situations.
+
+\let\font_emphasis_saved_emphasis_boldface\relax
+
+\def\font_emphasis_set_emphasis_boldface
+ {\let\font_emphasis_saved_emphasis_boldface\bf
+ \let\font_emphasis_set_emphasis_boldface\relax
+ \enforced\let\bf\font_emphasis_bold_bold}
+
+\protected\def\font_emphasis_bold_bold
+ {%\relax
+ \enforced\let\bf\relax % new
+ \ifx\fontalternative\s!it
+ \bi
+ \orelse\ifx\fontalternative\s!sl
+ \bs
+ \else
+ \font_emphasis_saved_emphasis_boldface
+ \fi
+ \enforced\let\bf\font_emphasis_saved_emphasis_boldface}
+
+%D Donald's (adapted) macros take the next character into account when placing
+%D italic correction. As a bonus we also look for something that looks like a dash,
+%D in which case we don't correct.
+
+\aliased\let\normalitaliccorrection\/ % the tex primitive
+
+\let\italiccorrection\normalitaliccorrection % will be overloaded
+
+\permanent\protected\def\emphasiscorrection % public, not in raw alignment groups, else omit problem
+ {\ifhmode\ifnum\currentgrouptype=\aligngroupcode\else
+ \expandafter\expandafter\expandafter\font_emphasis_look
+ \fi\fi}
+
+\def\font_emphasis_look
+ {\begingroup
+ \futurelet\nexttoken\font_emphasis_test}
+
+\def\font_emphasis_test
+ {\ifcat\noexpand\nexttoken,% we can do better in luatex ... some day ...
+ \expandafter\font_emphasis_a
+ \else
+ \expandafter\font_emphasis_b
+ \fi}
+
+\def\font_emphasis_a
+ {\futurelet\nexttoken\font_emphasis_correction}
+
+\def\font_emphasis_correction
+ {\setbox\scratchbox\hbox{\nexttoken}% tricky as next can be a macro
+ \ifzeropt\ht\scratchbox % probably a space
+ \expandafter\font_emphasis_b
+ \orelse\ifdim\ht\scratchbox<.3\exheight
+ \expandafter\expandafter\expandafter\endgroup
+ \else
+ \expandafter\expandafter\expandafter\font_emphasis_b
+ \fi}
+
+\def\font_emphasis_b
+ {\scratchskip\lastskip
+ \ifzeropt\scratchskip
+ \italiccorrection\relax
+ \else
+ \unskip\italiccorrection\hskip\scratchskip
+ \fi
+ \endgroup}
+
+%D We end with some examples which show the behavior when some punctuation is met.
+%D We also show how the mechanism adapts itself to bold, italic and slanted typing.
+%D
+%D \startbuffer
+%D test {test}test \par
+%D test {\sl test}test \par
+%D test {\em test}test \par
+%D test {\em test}--test \par
+%D
+%D test {test}, test \par
+%D test {\em test}, test \par
+%D
+%D test {\em test {\em test {\em test} test} test} test \par
+%D test {\bf test {\em test {\em test} test} test} test \par
+%D test {\sl test {\em test {\em test} test} test} test \par
+%D test {\it test {\em test {\em test} test} test} test \par
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D We get:
+%D
+%D \startpacked
+%D \getbuffer
+%D \stoppacked
+
+%D \macros
+%D {emphbf,emphit,emphsl,emphtf}
+%D
+%D The next emphasis alternatives are for \THANH. They adapt their style as good as
+%D possible. These macros are obsolete in \MKIV.
+
+% \protected\def\emphbf{\groupedcommand{\bf\def\emphit{\bi}\def\emphsl{\bs}}{}}
+% \protected\def\emphit{\groupedcommand{\it\def\emphbf{\bi}\def\emphsl{\sl}}{}}
+% \protected\def\emphsl{\groupedcommand{\sl\def\emphbf{\bs}\def\emphit{\it}}{}}
+% \protected\def\emphtf{\groupedcommand{\tf\def\emphbf{\bf}\def\emphit{\it}\def\emphsl{\sl}}{}}
+% \protected\def\emph {\groupedcommand{\em}{}}
+
+
+\permanent\protected\def\font_tf{\tf} \permanent\protected\def\font_bf{\bf}
+\permanent\protected\def\font_sl{\sl} \permanent\protected\def\font_bs{\bs}
+\permanent\protected\def\font_it{\it} \permanent\protected\def\font_bi{\bi}
+
+\protected\def\font_emphasis_bf{\bf\enforced\aliased\let\emphit\font_bi
+ \enforced\aliased\let\emphsl\font_bs}
+\protected\def\font_emphasis_it{\it\enforced\aliased\let\emphbf\font_bi
+ \enforced\aliased\let\emphsl\font_sl}
+\protected\def\font_emphasis_sl{\sl\enforced\aliased\let\emphbf\font_bs
+ \enforced\aliased\let\emphit\font_it}
+\protected\def\font_emphasis_tf{\tf\enforced\aliased\let\emphbf\font_bf
+ \enforced\aliased\let\emphit\font_it
+ \enforced\aliased\let\emphsl\font_sl}
+
+\permanent\protected\def\emphbf{\triggergroupedcommandcs\font_emphasis_bf}
+\permanent\protected\def\emphit{\triggergroupedcommandcs\font_emphasis_it}
+\permanent\protected\def\emphsl{\triggergroupedcommandcs\font_emphasis_sl}
+\permanent\protected\def\emphtf{\triggergroupedcommandcs\font_emphasis_tf}
+\permanent\protected\def\emph {\triggergroupedcommandcs\em}
+
+\permanent\protected\def\emphasized{\bgroup\em\let\nexttoken}
+
+%D \startbuffer
+%D TEXT {\emphbf text \emphit text \emphtf text \emphsl text} TEXT
+%D TEXT \emphbf{text \emphit{text} \emphtf{text} \emphsl{text}} TEXT
+%D \stopbuffer
+%D
+%D \typebuffer
+%D \startlines
+%D \getbuffer
+%D \stoplines
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-enh.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-enh.lmt
new file mode 100644
index 00000000000..1e532d4adb3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-enh.lmt
@@ -0,0 +1,90 @@
+if not modules then modules = { } end modules ['font-enh'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This module is already stripped from old stuff but more might go away
+-- in lmtx. Stay tuned.
+
+local next = next
+
+local trace_unicoding = false
+
+trackers.register("fonts.defining", function(v) trace_unicoding = v end)
+trackers.register("fonts.unicoding", function(v) trace_unicoding = v end)
+
+local report_unicoding = logs.reporter("fonts","unicoding")
+
+local fonts = fonts
+local constructors = fonts.constructors
+
+local afmfeatures = constructors.features.afm
+local otffeatures = constructors.features.otf
+
+local registerafmfeature = afmfeatures.register
+local registerotffeature = otffeatures.register
+
+local function initialize(tfmdata)
+ local goodies = tfmdata.goodies
+ local newcoding = nil
+ for i=1,#goodies do
+ local remapping = goodies[i].remapping
+ if remapping and remapping.unicodes then
+ newcoding = remapping.unicodes -- names to unicodes
+ end
+ end
+ if newcoding then
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local oldcoding = tfmdata.resources.unicodes
+ local originals = { }
+ for name, newcode in next, newcoding do
+ local oldcode = oldcoding[name]
+ if characters[newcode] and not originals[newcode] then
+ originals[newcode] = {
+ character = characters [newcode],
+ description = descriptions[newcode],
+ }
+ end
+ if oldcode then
+ local original = originals[oldcode]
+ local character, description
+ if original then
+ character = original.character
+ description = original.description
+ else
+ character = characters [oldcode]
+ description = descriptions[oldcode]
+ end
+ characters [newcode] = character
+ descriptions[newcode] = description
+ character .unicode = newcode
+ description.unicode = newcode
+ else
+ oldcoding[name] = newcode
+ end
+ if trace_unicoding then
+ if oldcode then
+ report_unicoding("aliasing glyph %a from %U to %U",name,oldcode,newcode)
+ else
+ report_unicoding("aliasing glyph %a to %U",name,newcode)
+ end
+ end
+ end
+ end
+end
+
+local specification = {
+ name = "unicoding",
+ description = "adapt unicode table",
+ initializers = {
+ base = initialize,
+ node = initialize,
+ },
+}
+
+registerotffeature(specification)
+registerafmfeature(specification)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-fbk.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-fbk.lmt
new file mode 100644
index 00000000000..47d284c845c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-fbk.lmt
@@ -0,0 +1,350 @@
+if not modules then modules = { } end modules ['font-fbk'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local cos, tan, rad, format = math.cos, math.tan, math.rad, string.format
+local utfbyte, utfchar = utf.byte, utf.char
+local next = next
+
+--[[ldx--
+
This is very experimental code!
+--ldx]]--
+
+local trace_visualize = false trackers.register("fonts.composing.visualize", function(v) trace_visualize = v end)
+local trace_define = false trackers.register("fonts.composing.define", function(v) trace_define = v end)
+
+local report = logs.reporter("fonts","combining")
+
+local allocate = utilities.storage.allocate
+
+local fonts = fonts
+local handlers = fonts.handlers
+local constructors = fonts.constructors
+local helpers = fonts.helpers
+
+local otf = handlers.otf
+local afm = handlers.afm
+local registerotffeature = otf.features.register
+local registerafmfeature = afm.features.register
+
+local addotffeature = otf.addfeature
+
+local unicodecharacters = characters.data
+local unicodefallbacks = characters.fallbacks
+
+local vfcommands = helpers.commands
+local charcommand = vfcommands.char
+local rightcommand = vfcommands.right
+local downcommand = vfcommands.down
+local upcommand = vfcommands.up
+local push = vfcommands.push
+local pop = vfcommands.pop
+
+local force_combining = false -- just for demo purposes (see mk)
+local fraction = 0.15 -- 30 units for lucida
+
+-- todo: we also need to update the feature hashes ... i'll do that when i'm in the mood
+-- and/or when i need it
+
+local function composecharacters(tfmdata)
+ -- this assumes that slot 1 is self, there will be a proper self some day
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local parameters = tfmdata.parameters
+ local properties = tfmdata.properties
+ local Xdesc = descriptions[utfbyte("X")]
+ local xdesc = descriptions[utfbyte("x")]
+ if Xdesc and xdesc then
+ local scale = parameters.factor or 1
+ local deltaxheight = scale * (Xdesc.boundingbox[4] - xdesc.boundingbox[4])
+ local extraxheight = fraction * deltaxheight -- maybe use compose value
+ local italicfactor = parameters.italicfactor or 0
+ local red, green, blue, black
+ if trace_visualize then
+ red = { "startcolor", "red" }
+ green = { "startcolor", "green" }
+ blue = { "startcolor", "blue" }
+ black = { "stopcolor" }
+ end
+ local compose = fonts.goodies.getcompositions(tfmdata)
+ if compose and trace_visualize then
+ report("using compose information from goodies file")
+ end
+ local done = false
+ for i, c in next, unicodecharacters do -- loop over all characters ... not that efficient but a specials hash takes memory
+ if force_combining or not characters[i] then
+ local s = c.specials
+ if s and s[1] == 'char' then
+ local chr = s[2]
+ local charschr = characters[chr]
+ if charschr then
+ local cc = c.category
+ if cc == 'll' or cc == 'lu' or cc == 'lt' then -- characters.is_letter[cc]
+ local acc = s[3]
+ local t = { }
+ for k, v in next, charschr do
+ if k ~= "commands" then
+ t[k] = v
+ end
+ end
+ local charsacc = characters[acc]
+ -- local ca = charsacc.category
+ -- if ca == "mn" then
+ -- -- mark nonspacing
+ -- elseif ca == "ms" then
+ -- -- mark spacing combining
+ -- elseif ca == "me" then
+ -- -- mark enclosing
+ -- else
+ if not charsacc then -- fallback accents
+ acc = unicodefallbacks[acc]
+ charsacc = acc and characters[acc]
+ end
+ local chr_t = charcommand[chr]
+ if charsacc then
+ if trace_define then
+ report("composed %C, base %C, accent %C",i,chr,acc)
+ end
+ local acc_t = charcommand[acc]
+ local cb = descriptions[chr].boundingbox
+ local ab = descriptions[acc].boundingbox
+ -- todo: adapt height
+ if cb and ab then
+ local c_llx = scale*cb[1]
+ local c_lly = scale*cb[2]
+ local c_urx = scale*cb[3]
+ local c_ury = scale*cb[4]
+ local a_llx = scale*ab[1]
+ local a_lly = scale*ab[2]
+ local a_urx = scale*ab[3]
+ local a_ury = scale*ab[4]
+ local done = false
+ if compose then
+ local i_compose = compose[i]
+ local i_anchored = i_compose and i_compose.anchored
+ if i_anchored then
+ local c_compose = compose[chr]
+ local a_compose = compose[acc]
+ local c_anchors = c_compose and c_compose.anchors
+ local a_anchors = a_compose and a_compose.anchors
+ if c_anchors and a_anchors then
+ local c_anchor = c_anchors[i_anchored]
+ local a_anchor = a_anchors[i_anchored]
+ if c_anchor and a_anchor then
+ local cx = c_anchor.x or 0
+ local cy = c_anchor.y or 0
+ local ax = a_anchor.x or 0
+ local ay = a_anchor.y or 0
+ local dx = cx - ax
+ local dy = cy - ay
+ if trace_define then
+ report("building %C from %C and %C",i,chr,acc)
+ report(" boundingbox:")
+ report(" chr: %3i %3i %3i %3i",unpack(cb))
+ report(" acc: %3i %3i %3i %3i",unpack(ab))
+ report(" anchors:")
+ report(" chr: %3i %3i",cx,cy)
+ report(" acc: %3i %3i",ax,ay)
+ report(" delta:")
+ report(" %s: %3i %3i",i_anchored,dx,dy)
+ end
+ local right = rightcommand[scale*dx]
+ local down = upcommand[scale*dy]
+ if trace_visualize then
+ t.commands = {
+ push, right, down,
+ green, acc_t, black,
+ pop, chr_t,
+ }
+ else
+ t.commands = {
+ push, right, down,
+ acc_t, pop, chr_t,
+ }
+ end
+ done = true
+ end
+ end
+ end
+ end
+ if not done then
+ -- can be sped up for scale == 1
+ local dx = (c_urx - a_urx - a_llx + c_llx)/2
+ local dd = (c_urx - c_llx)*italicfactor
+ if a_ury < 0 then
+ local right = rightcommand[dx-dd]
+ if trace_visualize then
+ t.commands = {
+ push, right, red, acc_t,
+ black, pop, chr_t,
+ }
+ else
+ t.commands = {
+ push, right, acc_t, pop,
+ chr_t,
+ }
+ end
+ t.depth = a_ury
+ elseif c_ury > a_lly then -- messy test
+ local dy
+ if compose then
+ -- experimental: we could use sx but all that testing
+ -- takes time and code
+ dy = compose[i]
+ if dy then
+ dy = dy.dy
+ end
+ if not dy then
+ dy = compose[acc]
+ if dy then
+ dy = dy and dy.dy
+ end
+ end
+ if not dy then
+ dy = compose.dy
+ end
+ if not dy then
+ dy = - deltaxheight + extraxheight
+ elseif dy > -1.5 and dy < 1.5 then
+ -- we assume a fraction of (percentage)
+ dy = - dy * deltaxheight
+ else
+ -- we assume fontunits (value smaller than 2 make no sense)
+ dy = - dy * scale
+ end
+ else
+ dy = - deltaxheight + extraxheight
+ end
+ t.height = a_ury-dy
+ local right = rightcommand[dx+dd]
+ local down = downcommand[dy]
+ if trace_visualize then
+ t.commands = {
+ push, right, down, green,
+ acc_t, black, pop, chr_t,
+ }
+ else
+ t.commands = {
+ push, right, down, acc_t,
+ pop, chr_t,
+ }
+ end
+ else
+ local right = rightcommand[dx+dd]
+ if trace_visualize then
+ t.commands = {
+ push, right, blue, acc_t,
+ black, pop, chr_t,
+ }
+ else
+ t.commands = {
+ push, right, acc_t, pop,
+ chr_t,
+ }
+ end
+ t.height = a_ury
+ end
+ end
+ else
+ t.commands = {
+ chr_t, -- else index mess
+ }
+ end
+ else
+ if trace_define then
+ report("%C becomes simplified %C",i,chr)
+ end
+ t.commands = {
+ chr_t, -- else index mess
+ }
+ end
+ done = true
+ characters[i] = t
+ local d = { }
+ for k, v in next, descriptions[chr] do
+ d[k] = v
+ end
+ descriptions[i] = d
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local specification = {
+ name = "compose",
+ description = "additional composed characters",
+ manipulators = {
+ base = composecharacters,
+ node = composecharacters,
+ }
+}
+
+registerotffeature(specification)
+registerafmfeature(specification)
+
+addotffeature {
+ name = "char-ligatures",
+ type = "ligature",
+ data = characters.splits.char,
+ order = { "char-ligatures" },
+ prepend = true,
+}
+
+addotffeature {
+ name = "compat-ligatures",
+ type = "ligature",
+ data = characters.splits.compat,
+ order = { "compat-ligatures" },
+ prepend = true,
+}
+
+registerotffeature {
+ name = 'char-ligatures',
+ description = 'unicode char specials to ligatures',
+}
+
+registerotffeature {
+ name = 'compat-ligatures',
+ description = 'unicode compat specials to ligatures',
+}
+
+-- We now provide the composer in the helpers namespace (too):
+
+fonts.helpers.composecharacters = composecharacters
+
+-- We keep this just because we have a few demos but there often are other ways to achieve
+-- the same. This code installs the builder into the regular virtual font builder, which
+-- only makes sense as demo. It also shows a bit what the evolution is.
+
+do
+
+ local vf = handlers.vf
+ local commands = vf.combiner.commands
+
+ vf.helpers.composecharacters = composecharacters
+
+ commands["compose.trace.enable"] = function() trace_visualize = true end
+ commands["compose.trace.disable"] = function() trace_visualize = false end
+ commands["compose.force.enable"] = function() force_combining = true end
+ commands["compose.force.disable"] = function() force_combining = false end
+
+ commands["compose.trace.set"] = function(g,v)
+ if v[2] == nil then
+ trace_visualize = true
+ else
+ trace_visualize = v[2]
+ end
+ end
+
+ commands["compose.apply"] = function(g,v)
+ composecharacters(g)
+ end
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-fea.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-fea.mklx
new file mode 100644
index 00000000000..9f4d2119e99
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-fea.mklx
@@ -0,0 +1,389 @@
+%D \module
+%D [ file=font-sty,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=features,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Features}
+
+\unprotect
+
+%D Feature management.
+%D
+%D \starttyping
+%D \definefontfeature[smallcaps][smcp=yes,script=latn]
+%D \definefontfeature[smallcaps][SmallCapitals=yes,script=latn]
+%D \definefontfeature[smallcaps][Small Capitals=yes,script=latn]
+%D \definefontfeature[smallcaps][small capitals=yes,script=latn]
+%D \definefontfeature[smallcaps][smallcapitals=yes,script=latn]
+%D
+%D \definedfont[cambria*smallcaps] test
+%D
+%D \starttext
+%D \definefontfeature[basekerned][default][mode=base]
+%D \definefontfeature[nodekerned][default][mode=node]
+%D \definefontfeature[nonekerned][default][mode=base,kern=no]
+%D \setupcolors[state=start]
+%D \startoverlay
+%D {\vbox{\red \definedfont[Serif*nonekerned at 12pt]\input tufte }}
+%D {\vbox{\blue \definedfont[Serif*basekerned at 12pt]\input tufte }}
+%D {\vbox{\green\definedfont[Serif*nodekerned at 12pt]\input tufte }}
+%D \stopoverlay
+%D \stoptext
+%D
+%D \enabletrackers[otf.kerns]
+%D
+%D \definefontfeature[withkern][default][mode=node]
+%D \definefontfeature[nokern] [default][mode=node,kern=no]
+%D \definefontfeature[single] [default][mode=node,cpsp=yes]
+%D \definefontfeature[simple] [default][mode=node,cpsp=yes,kern=no]
+%D
+%D {\definedfont[Serif*default] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D {\definedfont[Serif*nokern] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D {\definedfont[Serif*single] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D {\definedfont[Serif*simple] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D \stoptyping
+
+% \definefontfeature[slanted] [default][slant=.25]
+% \definefontfeature[stretched][default][stretch=2]
+%
+% \start \definedfont[SerifBold*slanted at 20pt] \ruledhbox{Test!} \stop
+% \start \definedfont[SerifBold*stretched at 20pt] \ruledhbox{Test!} \stop
+%
+% \definefontfeature[default] [liga=yes,texligatures=yes,texquotes=yes]
+% \definefontfeature[default-caps][liga=yes,texligatures=yes,texquotes=yes,smcp=yes,script=latn]
+%
+% \starttypescript [serif] [palatino-nova-regular] [name]
+% \definefontsynonym[Serif] [palatinonova-regular][features=default]
+% \definefontsynonym[SerifCaps][palatinonova-regular][features=default-caps] % also sets Serif
+% \stoptypescript
+%
+% \starttypescript [serif] [palatino-nova-regular] [name]
+% \definefontsynonym[Serif] [palatinonova-regular*default]
+% \definefontsynonym[SerifCaps] [palatinonova-regular*default-caps]
+% \stoptypescript
+%
+% \definetypeface[mainface][rm][serif][palatino-nova-regular][default] \setupbodyfont[mainface]
+%
+% \starttext
+% ``Test'' -- --- ff fi fl \sc ``Test'' -- --- ff fi fl
+% \stoptext
+%
+% \definefontfeature
+% [default-base]
+% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes]
+% \definefontfeature
+% [default-node]
+% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes,mode=node]
+% \definefontfeature
+% [default-none]
+% [script=latn,language=dflt,liga=yes,kern=no, tlig=yes,trep=yes]
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:lmroman12regular*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:lmroman12regular*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:lmroman12regular*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \blank
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:texgyrepagella*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:texgyrepagella*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:texgyrepagella*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \blank
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:palatinonovaregular*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:palatinonovaregular*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:palatinonovaregular*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:OfficinaSerifBookITC*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:OfficinaSerifBookITC*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:OfficinaSerifBookITC*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \definefontfeature[superdefault][default][compose=yes]
+%
+% {\font\oeps=name:lmroman10regular*default at 30pt \oeps test \char7683}
+% {\font\oeps=name:lmroman10regular*superdefault at 30pt \oeps test \char7683}
+
+\permanent\tolerant\protected\def\definefontfeature[#featureset]#spacer[#parent]#spacer[#settings]%
+ {\clf_definefontfeature{#featureset}{#parent}{#settings}}
+
+\permanent\tolerant\protected\def\adaptfontfeature[#pattern]#spacer[#settings]%
+ {\clf_adaptfontfeature{#pattern}{#settings}}
+
+\permanent\protected\def\fontfeatureslist[#name]#spacer[#separator]% todo: arg voor type
+ {\clf_featurelist{#name}{\detokenize{#separator}}}
+
+\attribute\zerocount\attributeunsetvalue
+
+\glyphdatafield\zerocount
+
+\let\font_dynamic_value\glyphdatafield
+
+% beware: these are global features on top of existing font features
+
+\mutable\let\currentfeature\s!current
+
+\let\m_font_feature_list \s!current
+\let\m_font_feature_asked\empty
+
+\newconstant\c_font_feature_state
+
+\newevery\everyfontfeatureswitch
+
+% hashing at this end is slower
+
+\permanent\tolerant\protected\def\addfeature [#1]#;#2{\edef\m_font_feature_asked{#1#2}\font_feature_add}
+\permanent\tolerant\protected\def\subtractfeature [#1]#;#2{\edef\m_font_feature_asked{#1#2}\font_feature_subtract}
+\permanent\tolerant\protected\def\replacefeature [#1]#;#2{\edef\m_font_feature_asked{#1#2}\font_feature_replace}
+\permanent\tolerant\protected\def\resetandaddfeature[#1]#;#2{\edef\m_font_feature_asked{#1#2}\font_feature_reset_add}
+\permanent\tolerant\protected\def\feature [#1]#;#2{\begincsname\??featureshortcut#1#2\endcsname}
+
+% for old times sake
+
+\permanent\protected\def\doaddfeature #1{\edef\m_font_feature_asked{#1}\font_feature_add}
+\permanent\protected\def\dosubtractfeature #1{\edef\m_font_feature_asked{#1}\font_feature_subtract}
+\permanent\protected\def\doreplacefeature #1{\edef\m_font_feature_asked{#1}\font_feature_replace}
+\permanent\protected\def\doresetandaddfeature#1{\edef\m_font_feature_asked{#1}\font_feature_reset_add}
+
+\protected\def\font_feature_add
+ {\ifnum\c_font_feature_state=\plusone
+ \ifx\m_font_feature_asked\currentfeature\else
+ \font_feature_add_indeed
+ \fi
+ \else
+ \font_feature_add_indeed
+ \fi}
+
+\protected\def\font_feature_add_indeed
+ {\clf_addfeature{\m_font_feature_list}{\m_font_feature_asked}%
+ \edef\m_font_feature_list{\m_font_feature_list+\m_font_feature_asked}% also + at the lua end
+ \c_font_feature_state\plusone
+ \let\currentfeature\m_font_feature_asked
+ \the\everyfontfeatureswitch}
+
+\protected\def\font_feature_subtract
+ {\ifnum\c_font_feature_state=\minusone
+ \ifx\m_font_feature_asked\currentfeature\else
+ \font_feature_subtract_indeed
+ \fi
+ \else
+ \font_feature_subtract_indeed
+ \fi}
+
+\protected\def\font_feature_subtract_indeed
+ {\clf_subtractfeature{\m_font_feature_list}{\m_font_feature_asked}%
+ \edef\m_font_feature_list{\m_font_feature_list-\m_font_feature_asked}% also - at the lua end
+ \c_font_feature_state\minusone
+ \let\currentfeature\m_font_feature_asked
+ \the\everyfontfeatureswitch}
+
+\protected\def\font_feature_replace
+ {\ifnum\c_font_feature_state=\zerocount
+ \ifx\m_font_feature_asked\currentfeature\else
+ \font_feature_replace_indeed
+ \fi
+ \else
+ \font_feature_replace_indeed
+ \fi}
+
+\protected\def\font_feature_replace_indeed
+ {\clf_replacefeature{\m_font_feature_list}{\m_font_feature_asked}%
+ \edef\m_font_feature_list{\m_font_feature_list=\m_font_feature_asked}% also = at the lua end
+ \c_font_feature_state\zerocount
+ \let\currentfeature\m_font_feature_asked
+ \the\everyfontfeatureswitch}
+
+\permanent\protected\def\resetfeature
+ {\ifx\currentfeature\s!current \else
+ \font_feature_reset_indeed
+ \fi}
+
+\protected\def\font_feature_reset_indeed
+ {\let\m_font_feature_asked\empty
+ \let\currentfeature \s!current
+ \let\m_font_feature_list \s!current
+ \clf_resetfeature}
+
+\permanent\protected\def\revivefeature
+ {\ifx\currentfeature\s!current \else
+ \font_feature_revive_indeed
+ \fi}
+
+\protected\def\font_feature_revive_indeed
+ {\clf_revivefeature{\m_font_feature_list}}
+
+\protected\def\font_feature_reset_add
+ {\ifnum\c_font_feature_state=\plusone
+ \ifx\m_font_feature_asked\currentfeature\else
+ \font_feature_reset_add_indeed
+ \fi
+ \else
+ \font_feature_reset_add_indeed
+ \fi}
+
+\protected\def\font_feature_reset_add_indeed
+ {\clf_addfeature{\s!current}{\m_font_feature_asked}%
+ \edef\m_font_feature_list{\s!current+\m_font_feature_asked}% also + at the lua end
+ \c_font_feature_state\plusone
+ \let\currentfeature\m_font_feature_asked
+ \the\everyfontfeatureswitch}
+
+\installcorenamespace{featureshortcut}
+
+\letcsname\??featureshortcut +\endcsname\addfeature
+\letcsname\??featureshortcut -\endcsname\subtractfeature
+\letcsname\??featureshortcut =\endcsname\replacefeature
+\letcsname\??featureshortcut !\endcsname\resetandaddfeature
+\letcsname\??featureshortcut >\endcsname\revivefeature
+\letcsname\??featureshortcut <\endcsname\resetfeature
+
+\letcsname\??featureshortcut\v!more \endcsname\addfeature % add set to previous set and combine with font set
+\letcsname\??featureshortcut\v!less \endcsname\subtractfeature % subtract set from previous set and combine with font set
+\letcsname\??featureshortcut\v!new \endcsname\replacefeature % replace font set
+\letcsname\??featureshortcut\v!reset \endcsname\resetfeature % forget sets and revert to font set
+\letcsname\??featureshortcut\v!default\endcsname\revivefeature % make sure the current set is used on top of the font set
+\letcsname\??featureshortcut\v!old \endcsname\revivefeature
+\letcsname\??featureshortcut\v!local \endcsname\resetandaddfeature
+\letcsname\??featureshortcut\s!unknown\endcsname\empty
+
+% experimental bonus:
+
+% \protected\def\addfflanguage
+% {\ifnum\c_font_feature_state=\plusone
+% \ifx\currentlanguage\currentfeature\else
+% \font_feature_add_language_indeed
+% \fi
+% \else
+% \font_feature_add_language_indeed
+% \fi}
+%
+% \protected\def\font_feature_add_language_indeed
+% {\clf_addfeature{\m_font_feature_list}{\currentlanguage}%
+% \edef\m_font_feature_list{\m_font_feature_list+\currentlanguage}% also + at the lua end
+% \c_font_feature_state\plusone
+% \let\currentfeature\currentlanguage}
+%
+% some 3% slower:
+
+% \protected\def\addfflanguage
+% {\let\m_font_feature_asked\currentlanguage
+% \font_feature_add}
+
+\let\m_font_feature_language\currentlanguage
+
+\permanent\protected\def\addfflanguage
+ {\ifx\currentlanguage\m_font_feature_language\else
+ \let\m_font_feature_language\currentlanguage
+ \let\m_font_feature_asked \currentlanguage
+ \font_feature_add
+ \fi}
+
+% just for old times sake:
+
+\permanent\protected\def\featureattribute#feature%
+ {\clf_featureattribute{#feature}}
+
+\permanent\protected\def\setfontfeature#feature%
+ {\edef\currentfeature{#feature}%
+ \let\m_font_feature_list\currentfeature
+ \clf_setfontfeature{\currentfeature}}
+
+% these are obsolete (don't use them any longer)
+
+\aliased\let\resetfontfeature\resetfeature % obsolete
+
+% these are obsolete (don't use them any longer)
+
+% \let\addfontfeaturetoset \font_feature_add_nop % obsolete
+% \let\subtractfontfeaturefromset \font_feature_subtract_nop % obsolete
+% \let\addfontfeaturetofont \font_feature_add_nop % obsolete
+% \let\subtractfontfeaturefromfont\font_feature_subtract_nop % obsolete
+
+% these are obsolete (don't use them any longer)
+
+\aliased\let\setff\setfontfeature % obsolete
+\aliased\let\addfs\doaddfeature % obsolete
+\aliased\let\subfs\dosubtractfeature % obsolete
+\aliased\let\addff\doaddfeature % obsolete
+\aliased\let\subff\dosubtractfeature % obsolete
+
+%D \macros
+%D {os}
+%D
+%D In good old \TEX, the old style numerals were often taken from the math fonts. No
+%D longer.
+
+\definefontfeature
+ [just-os]
+ [mode=node,onum=yes]
+
+%frozen\protected\def\sc{\setfontfeature{smallcaps}}
+\permanent\protected\def\os{\setfontfeature{just-os}}
+
+% \doifelsecurrentfonthasfeature{smcp}{YES}{NO}
+% \doifelsecurrentfonthasfeature{crap}{YES}{NO}
+% \doifelsecurrentfonthasfeature{kern}{YES}{NO}
+
+\permanent\def\doifelsecurrentfonthasfeature#feature{\clf_doifelsecurrentfonthasfeature{#feature}} % expandable
+\permanent\def\doifelsefontfeature #feature{\clf_doifelsefontfeature {#feature}} % expandable
+\permanent\def\doifunknownfontfeature #feature{\clf_doifunknownfontfeature {#feature}} % expandable
+
+\aliased\let\doifcurrentfonthasfeatureelse\doifelsecurrentfonthasfeature
+\aliased\let\doiffontfeatureelse \doifelsefontfeature
+
+% new:
+
+\clf_registerlanguagefeatures
+
+% also new
+
+\permanent\protected\def\useaddfontfeatureparameter#namespace% faster local variant
+ {\edef\m_font_feature_asked{#namespace\c!features}%
+ \ifempty\m_font_feature_asked\else
+ \font_feature_add
+ \fi}
+
+% let's put this here:
+
+\permanent\protected\def\slashedzero
+ {\dontleavehmode
+ \begingroup
+ %\addff{zero}
+ \doaddfeature{zero}%
+ 0%
+ \endgroup}
+
+% not nice but maybe handy
+
+% \starttyping
+% \blockligatures[fi,ff] \blockligatures[fl]
+%
+% \definefontfeature[default:b][default][blockligatures=yes]
+%
+% \setupbodyfont[pagella] \showfontkerns
+%
+% \definedfont[Serif*default:b]
+%
+% \startTEXpage[offset=1em]
+% fi ff fl
+% \stopTEXpage
+% \stoptyping
+
+\permanent\protected\def\blockligatures[#1]{\clf_blockligatures{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-fil.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-fil.mklx
new file mode 100644
index 00000000000..57ed47fa287
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-fil.mklx
@@ -0,0 +1,384 @@
+%D \module
+%D [ file=font-fil,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Classes and Files,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Classes and Files}
+
+\unprotect
+
+%D Personally I think that using \TEX\ macro packages is complicated by the way
+%D fonts are handled. Apart from the many encodings, we also deal with different
+%D naming schemes. Confronted with this problem, I decided to change the definitions
+%D into:
+%D
+%D \starttyping
+%D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt]
+%D \stoptyping
+%D
+%D combined with for instance:
+%D
+%D \starttyping
+%D \definefontsynonym [Times-Roman] [tir]
+%D \stoptyping
+
+% \definetypeface[palatino][rm][serif][palatino,allbold][default]
+%
+% \startfontclass[palatino]
+% \definefontsynonym [Serif] [SerifBold]
+% \definefontsynonym [SerifItalic] [SerifBoldItalic]
+% \definefontsynonym [SerifSlanted] [SerifBoldSlanted]
+% \definefontsynonym [SerifCaps] [SerifBold]
+% \stopfontclass
+%
+% \setupbodyfont[palatino]
+
+\permanent\protected\tolerant\protected\def\startfontclass[#class]%
+ {\push_macro_fontclass
+ \doifelse{#class}\v!each
+ {\let\fontclass\empty}
+ {\doifsomething{#class}{\def\fontclass{#class}}}}
+
+\permanent\protected\def\stopfontclass
+ {\pop_macro_fontclass}
+
+\permanent\def\classfont#class#name{#class#name} % \definefont[whatever][\classfont{xx}{yy} at 10pt]
+
+%D \macros
+%D {definefontsynonym, doifelsefontsynonym,
+%D expandfontsynonym, truefontname, truefontdata}
+%D
+%D While looking for fonts, fontsynonyms are used for accessing the files!
+%D
+%D \starttyping
+%D \definefontsynonym[Serif][Lucida-Bright]
+%D \definefontsynonym[Lucida-Bright][lbr][encoding=texnansi]
+%D \stoptyping
+
+\installcorenamespace {fontfile} % file synonyms
+
+\let\m_font_name\empty
+\let\m_font_file\empty
+
+\mutable\def\defaultfontfile{\truefontname{Normal}} % was cmtt10, but that one is gone
+
+\permanent\protected\def\definefontsynonym[#name]#spacer[#file]%
+ {\edef\m_font_name{#name}%
+ \edef\m_font_file{#file}%
+ \ifempty\fontclass
+ \expandafter\font_basics_define_font_synonym_nop
+ \else
+ \expandafter\font_basics_define_font_synonym_yes
+ \fi}
+
+\protected\def\font_basics_define_font_synonym_nop
+ {\letcsname\??fontfile\m_font_name\endcsname\m_font_file
+ \doifelsenextoptionalcs\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil}
+
+\protected\def\font_basics_define_font_synonym_yes
+ {\letcsname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
+ \doifelsenextoptionalcs\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil}
+
+\permanent\protected\def\edefinefontsynonym[#name]#spacer[#file]%
+ {\edef\m_font_name{#name}%
+ \edef\m_font_file{#file}%
+ \ifempty\fontclass
+ \expandafter\font_basics_define_font_synonym_nop_expanded
+ \else
+ \expandafter\font_basics_define_font_synonym_yes_expanded
+ \fi}
+
+\protected\def\font_basics_define_font_synonym_nop_expanded#ignore[#spec]%
+ {\letcsname\??fontfile\m_font_name\endcsname\m_font_file
+ \normalexpanded{\font_basics_define_font_synonym_nop_opt[#spec]}}
+
+\protected\def\font_basics_define_font_synonym_yes_expanded#ignore[#spec]%
+ {\letcsname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
+ \normalexpanded{\font_basics_define_font_synonym_yes_opt[#spec]}}
+
+\protected\def\font_basics_define_font_synonym_nop_opt[#specification]%
+ {\let\p_features \undefined
+ \let\p_fallbacks \undefined
+ \let\p_goodies \undefined
+ \let\p_designsize\undefined
+ \expandafter\font_basics_get_font_parameter_nop#specification,\ignorearguments}
+
+\protected\def\font_basics_define_font_synonym_yes_opt[#specification]%
+ {\let\p_features \undefined
+ \let\p_fallbacks \undefined
+ \let\p_goodies \undefined
+ \let\p_designsize\undefined
+ \expandafter\font_basics_get_font_parameter_yes#specification,\ignorearguments}
+
+% todo: check if we can use \edef but then we need to protect \mathsizesuffix .. in fact that
+% can be default then: \let\mathsizesuffix\relax .. i need to play with it first
+
+\def\font_basics_get_font_parameter_nop#key=#value,%
+ {\ifarguments
+ \font_basics_get_font_parameter_nop_finish
+ \else
+ \defcsname p_#key\endcsname{#value}% % no edef as we need to keep \mathsizesuffix
+ \expandafter\font_basics_get_font_parameter_nop
+ \fi}
+
+\def\font_basics_get_font_parameter_yes#key=#value,%
+ {\ifarguments
+ \font_basics_get_font_parameter_yes_finish
+ \else
+ \defcsname p_#key\endcsname{#value}% % no edef as we need to keep \mathsizesuffix
+ \expandafter\font_basics_get_font_parameter_yes
+ \fi}
+
+% helpers, some day these will be toks and counts
+
+% \def\fntsetdefname {\glet\somefontname\defaultfontfile}
+% \def\fntsetsomename{\gdef\somefontname} % takes argument
+% \def\fntsetnopsize {\let\somefontsize\empty}
+% \def\fntsetsomesize{\def\somefontsize} % takes argument
+
+% happens later, else mkvi parsing gets into troubles
+
+% end of helpers
+
+% we could collect them in one macro (but no expansion)
+
+\def\font_basics_define_font_synonym_nop_nil
+ {\letcsname\??fontfile\m_font_name\s!features \endcsname\undefined
+ \letcsname\??fontfile\m_font_name\s!fallbacks \endcsname\undefined
+ \letcsname\??fontfile\m_font_name\s!goodies \endcsname\undefined
+ \letcsname\??fontfile\m_font_name\s!designsize\endcsname\undefined}
+
+\def\font_basics_define_font_synonym_yes_nil
+ {\gletcsname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined
+ \gletcsname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\undefined
+ \gletcsname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined
+ \gletcsname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\undefined}
+
+\def\font_basics_get_font_parameter_nop_finish
+ {\letcsname\??fontfile\m_font_name\s!features \endcsname\p_features
+ \letcsname\??fontfile\m_font_name\s!fallbacks \endcsname\p_fallbacks
+ \letcsname\??fontfile\m_font_name\s!goodies \endcsname\p_goodies
+ \letcsname\??fontfile\m_font_name\s!designsize\endcsname\p_designsize}
+
+\def\font_basics_get_font_parameter_yes_finish
+ {\gletcsname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features
+ \gletcsname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\p_fallbacks
+ \gletcsname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies
+ \gletcsname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\p_designsize}
+
+%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}]
+%\defineclassfontsynonym [KopFont] [officina] [SerifBold]
+%\definefontsynonym[#tag][\fontclassname{#class}{#fileortag}]}
+
+\permanent\tolerant\protected\def\defineclassfontsynonym[#tag]#spacer[#class]#spacer[#fileortag]% needs testing
+ {\defcsname\??fontfile\fontclass#tag\endcsname{\fontclassname{#class}{#fileortag}}%
+ \font_basics_define_font_synonym_yes_nil}
+
+\aliased\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater
+
+\permanent\tolerant\protected\def\setupfontsynonym[#name]#spacer[#settings]% not yet supported, will do when needed
+ {}
+
+% todo: replace * by ... less messy with features
+
+% no \ifempty here as #1 can be empty
+
+\permanent\def\truefontname#name%
+ {\expandafter\font_helpers_true_fontname#name*\empty*\relax}
+
+\def\font_helpers_true_fontname#name*#first#rest*#ignore\relax
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \ifx#first\empty
+ \expandafter\truefontname\lastnamedcs
+ \else
+ \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest%
+ \fi
+ \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
+ \ifx#first\empty
+ \expandafter\truefontname\lastnamedcs
+ \else
+ \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest%
+ \fi
+ \orelse\ifcsname\??fontfile#name\endcsname
+ \ifx#first\empty
+ \expandafter\truefontname\lastnamedcs
+ \else
+ \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest%
+ \fi
+ \else
+ #name\ifx#first\empty\else*#first#rest\fi
+ \fi}
+
+\def\font_helpers_true_fontname_check#name%
+ {\expandafter\font_helpers_true_fontname_check_indeed#name*\relax}
+
+\def\font_helpers_true_fontname_check_indeed#name*#ignore\relax
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \expandafter\font_helpers_true_fontname_check\lastnamedcs
+ \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
+ \expandafter\font_helpers_true_fontname_check\lastnamedcs
+ \orelse\ifcsname\??fontfile#name\endcsname
+ \expandafter\font_helpers_true_fontname_check\lastnamedcs
+ \else
+ #name%
+ \fi}
+
+% ok when the last lookup is not stripped .. we need to be able to define synonyms for symbols
+
+\permanent\def\expandfontsynonym#command#name% one level expansion
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \expandafter\normaldef\expandafter#command\expandafter{\lastnamedcs}%
+ \orelse\ifcsname\??fontfile\defaultfontclass#2\endcsname
+ \expandafter\normaldef\expandafter#command\expandafter{\lastnamedcs}%
+ \fi}
+
+\permanent\def\doifelsefontsynonym#name%
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \expandafter\firstoftwoarguments
+ \orelse\ifcsname\??fontfile\defaultfontclass#name\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doiffontsynonymelse\doifelsefontsynonym
+
+%D \macros
+%D {tracedfontname}
+%D
+%D A goody:
+
+\permanent\def\tracedfontname#name%
+ {#name\ifcsname\??fontfile\fontclass#name\endcsname
+ %\expandafter\tracedfontname\csname\??fontfile\fontclass#name\endcsname
+ \expandafter\tracedfontname\lastnamedcs
+ \orelse\ifcsname\??fontfile#name\endcsname
+ %\expandafter\tracedfontname\csname\??fontfile#name\endcsname
+ \expandafter\tracedfontname\lastnamedcs
+ \fi}
+
+%D \macros
+%D {fontclass, defaultfontclass}
+%D
+%D The fontclass model was introduced a while after we implement the basic font
+%D model and at that time we still defaulted to no model at all. Nowadays we default
+%D to the \type {modern} fontclass.
+
+\let\fontclass \empty
+\let\defaultfontclass\empty
+
+\permanent\def\fontclassname#class#name% tricky ... no lastnamedcs here due to nesting
+ {\ifcsname\??fontfile#class#name\endcsname
+ \fontclassname{#class}{\csname\??fontfile#class#name\endcsname}%
+ \orelse\ifcsname\??fontfile#name\endcsname
+ \fontclassname{#class}{\csname\??fontfile#name\endcsname}%
+ \else
+ #2%
+ \fi}
+
+\installmacrostack\fontclass
+
+%D Files or names can have properties and these need to be consulted at some point.
+%D They can inherit them.
+
+% Why these expanded and rscale not ... maybe not worth the trouble (delayed
+% expansion actually would be better i.e. macros in feature specs). Test without
+% pre-expansion.
+
+\def\font_helpers_update_font_class_parameters
+ {\edef\m_font_class_direction {\begincsname\??fontclass\fontclass\fontstyle\s!direction \endcsname}%
+ \edef\m_font_class_features {\begincsname\??fontclass\fontclass\fontstyle\s!features \endcsname}%
+ \edef\m_font_class_fallbacks {\begincsname\??fontclass\fontclass\fontstyle\s!fallbacks \endcsname}%
+ \edef\m_font_class_goodies {\begincsname\??fontclass\fontclass\fontstyle\s!goodies \endcsname}%
+ \edef\m_font_class_designsize{\begincsname\??fontclass\fontclass\fontstyle\s!designsize\endcsname}}
+
+% resolve
+
+\def\font_helpers_set_features_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\orelse % class + symbolic_name
+ \ifcsname\??fontfile #name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\orelse % symbolic_name
+ \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_features_yes\lastnamedcs \orelse % class + parent_name
+ \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_features_yes\lastnamedcs \else % parent_name
+ \let\m_font_features\empty\fi}
+
+\def\font_helpers_set_fallbacks_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\orelse
+ \ifcsname\??fontfile #name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\orelse
+ \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_fallbacks_yes\lastnamedcs \orelse
+ \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_fallbacks_yes\lastnamedcs \else
+ \let\m_font_fallbacks\empty\fi}
+
+\def\font_helpers_set_goodies_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname \edef\m_font_goodies{\lastnamedcs}\orelse
+ \ifcsname\??fontfile #name\s!goodies \endcsname \edef\m_font_goodies{\lastnamedcs}\orelse
+ \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_goodies_yes\lastnamedcs \orelse
+ \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_goodies_yes\lastnamedcs \else
+ \let\m_font_goodies\empty\fi}
+
+\def\font_helpers_set_designsize_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\orelse
+ \ifcsname\??fontfile #name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\orelse
+ \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_designsize_yes\lastnamedcs \orelse
+ \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_designsize_yes\lastnamedcs \else
+ \let\m_font_designsize\empty\fi}
+
+\def\font_helpers_set_features_nop#name%
+ {\ifcsname\??fontfile#name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\orelse
+ \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_features_nop\lastnamedcs \else
+ \let\m_font_features\empty\fi}
+
+\def\font_helpers_set_fallbacks_nop#name%
+ {\ifcsname\??fontfile#name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\orelse
+ \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_fallbacks_nop\lastnamedcs \else
+ \let\m_font_fallbacks\empty\fi}
+
+\def\font_helpers_set_goodies_nop#name%
+ {\ifcsname\??fontfile#name\s!goodies\endcsname \edef\m_font_goodies{\lastnamedcs}\orelse
+ \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_goodies_nop\lastnamedcs \else
+ \let\m_font_goodies\empty\fi}
+
+\def\font_helpers_set_designsize_nop#name%
+ {\ifcsname\??fontfile#name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\orelse
+ \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_designsize_nop\lastnamedcs \else
+ \let\m_font_designsize\empty\fi}
+
+\def\font_helpers_update_font_parameters_yes
+ {\font_helpers_set_features_yes \somefontname
+ \font_helpers_set_fallbacks_yes \somefontname
+ \font_helpers_set_goodies_yes \somefontname
+ \font_helpers_set_designsize_yes\somefontname}
+
+\def\font_helpers_update_font_parameters_nop
+ {\font_helpers_set_features_nop \somefontname
+ \font_helpers_set_fallbacks_nop \somefontname
+ \font_helpers_set_goodies_nop \somefontname
+ \font_helpers_set_designsize_nop\somefontname}
+
+\def\font_helpers_update_font_parameters
+ {\ifempty\fontclass\font_helpers_update_font_parameters_nop\else\font_helpers_update_font_parameters_yes\fi}
+
+\installcorenamespace{fontclass}
+
+% we can pack them (don't use \setxvalue!)
+
+\permanent\protected\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#designsize#direction%
+ {\gletcsname\??fontclass\fontclass#style\s!rscale \endcsname#rscale%
+ \gletcsname\??fontclass\fontclass#style\s!features \endcsname#features%
+ \gletcsname\??fontclass\fontclass#style\s!fallbacks \endcsname#fallbacks%
+ \gletcsname\??fontclass\fontclass#style\s!goodies \endcsname#goodies%
+ \gletcsname\??fontclass\fontclass#style\s!designsize\endcsname#designsize%
+ \gletcsname\??fontclass\fontclass#style\s!direction \endcsname#direction}% math
+
+% bonus
+
+% \currentfontinstancespec % define ad the lua end
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-fmp.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-fmp.lmt
new file mode 100644
index 00000000000..f35c96f49ed
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-fmp.lmt
@@ -0,0 +1,123 @@
+if not modules then modules = { } end modules ['font-fmp'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- We only need to pick up the filename and optionally the enc file as we only use
+-- them for old school virtual math fonts. We might as well drop this completely.
+-- This used to be a backend module but the code is rather generic so we just put it
+-- here now.
+
+local find, match, splitlines = string.find, string.match, string.splitlines
+
+local implement = interfaces.implement
+
+local mappings = { }
+
+local function setline(n)
+ if trace_fonts then
+ report_fonts("mapline: %s",n)
+ end
+ local name, fullname, encfile, pfbfile = match(n,"(%S+)%s+(%S+).-<(.-%.enc).-<(.-%.pfb)")
+ if name then
+ mappings[name] = { fullname, encfile, pfbfile }
+ end
+end
+
+local function setfile(n)
+ local okay, data = resolvers.loadbinfile(n,"map")
+ if okay and data then
+ data = splitlines(data)
+ for i=1,#data do
+ local d = data[i]
+ if d ~= "" and not find(d,"^[#%%]") then
+ setline(d)
+ end
+ end
+ end
+end
+
+local function getentry(n)
+ local n = file.nameonly(n)
+ local m = mappings[n]
+ if m then
+ local encfile = m[2]
+ local encoding = fonts.encodings.load(encfile)
+ if not encoding then
+ return
+ end
+ local pfbfile = resolvers.findfile(m[3],"pfb")
+ if not pfbfile or pfbfile == "" then
+ return
+ end
+ return encoding, pfbfile, encfile
+ end
+end
+
+-- soon to be obsolete:
+
+local mappings = fonts.mappings or { }
+fonts.mappings = mappings
+
+local loaded = { -- prevent loading (happens in cont-sys files)
+ -- ["original-base.map" ] = true,
+ -- ["original-ams-base.map" ] = true,
+ -- ["original-ams-euler.map"] = true,
+ -- ["original-public-lm.map"] = true,
+}
+
+function mappings.loadfile(name)
+ name = file.addsuffix(name,"map")
+ if not loaded[name] then
+ if trace_mapfiles then
+ report_mapfiles("loading map file %a",name)
+ end
+ setfile(name)
+ loaded[name] = true
+ end
+end
+
+local loaded = { -- prevent double loading
+}
+
+function mappings.loadline(how,line)
+ if line then
+ how = how .. " " .. line
+ elseif how == "" then
+ how = "= " .. line
+ end
+ if not loaded[how] then
+ if trace_mapfiles then
+ report_mapfiles("processing map line %a",line)
+ end
+ setline(how)
+ loaded[how] = true
+ end
+end
+
+function mappings.reset()
+ lpdf.setmapfile("") -- tricky ... backend related
+end
+
+mappings.getentry = getentry
+
+implement {
+ name = "loadmapfile",
+ actions = mappings.loadfile,
+ arguments = "string"
+}
+
+implement {
+ name = "loadmapline",
+ actions = mappings.loadline,
+ arguments = "string"
+}
+
+implement {
+ name = "resetmapfiles",
+ actions = mappings.reset,
+ arguments = "string"
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-gds.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-gds.mklx
new file mode 100644
index 00000000000..897478273ff
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-gds.mklx
@@ -0,0 +1,97 @@
+%D \module
+%D [ file=font-gds,
+%D version=2009.10.14,
+%D title=\CONTEXT\ Font Support,
+%D subtitle=Colorschemes,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Support / Colorschemes}
+
+%registerctxluafile{font-gds}{}
+
+\unprotect
+
+% this will become colorgroups and move to font-col or so
+
+\definecolor[colorscheme:1:1][s=.75]
+\definecolor[colorscheme:1:2][r=.75]
+\definecolor[colorscheme:1:3][g=.75]
+\definecolor[colorscheme:1:4][b=.75]
+\definecolor[colorscheme:1:5][c=.75]
+\definecolor[colorscheme:1:6][m=.75]
+\definecolor[colorscheme:1:7][y=.75]
+
+\definecolor[colorscheme:2:7][s=.75]
+\definecolor[colorscheme:2:6][r=.75]
+\definecolor[colorscheme:2:5][g=.75]
+\definecolor[colorscheme:2:4][b=.75]
+\definecolor[colorscheme:2:3][c=.75]
+\definecolor[colorscheme:2:2][m=.75]
+\definecolor[colorscheme:2:1][y=.75]
+
+\definecolor[colorscheme:3:1][r=.75]
+\definecolor[colorscheme:3:2][g=.75]
+\definecolor[colorscheme:3:3][b=.75]
+\definecolor[colorscheme:3:4][g=.75,b=.75]
+\definecolor[colorscheme:3:5][r=.75,b=.75]
+\definecolor[colorscheme:3:6][r=.75,g=.75]
+\definecolor[colorscheme:3:7][g=.75]
+
+\definecolor[colorscheme:4:1] [r=.6] % a
+\definecolor[colorscheme:4:5] [g=.6] % e
+\definecolor[colorscheme:4:9] [b=.6] % i
+\definecolor[colorscheme:4:15][g=.6,b=.6] % o
+\definecolor[colorscheme:4:21][r=.6,b=.6] % u
+\definecolor[colorscheme:4:25][r=.6,b=.6] % y
+
+\definesystemattribute[colorscheme][public]
+
+\permanent\protected\def\loadfontgoodies[#filename]{\clf_loadfontgoodies{#filename}} % todo: public implementor
+
+\permanent\protected\def\setfontcolorscheme % will move to the lua end
+ {\clf_enablefontcolorschemes
+ \enforced\permanent\protected\xdef\setfontcolorscheme[##1]{\c_attr_colorscheme##1\relax}%
+ \setfontcolorscheme}
+
+\permanent\protected\def\resetfontcolorscheme
+ {\c_attr_colorscheme\attributeunsetvalue}
+
+\protect \endinput
+
+% \definefontfeature[husayni-colored][goodies=husayni,colorscheme=default,featureset=default]
+%
+% \definedfont[husayni*husayni-colored at 36pt]
+%
+% \starttext \righttoleft
+%
+% \setfontcolorscheme[1]
+%
+% اَلْحَمْدُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
+% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
+% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
+% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
+% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
+%
+% \setfontcolorscheme[2]
+%
+% اَلْحَمْدُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
+% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
+% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
+% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
+% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
+%
+% \resetfontcolorscheme
+%
+% اَلْحَمْدُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
+% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
+% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
+% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
+% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
+%
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-glf.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-glf.mklx
new file mode 100644
index 00000000000..2c23f226eed
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-glf.mklx
@@ -0,0 +1,41 @@
+%D \module
+%D [ file=font-glf,
+%D version=2020.12.21,
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Glyph Scaling,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Glyph Scaling}
+
+\unprotect
+
+%D Experiment:
+
+\installcorenamespace{tweakedfont}
+
+\installcommandhandler \??tweakedfont {tweakedfont} \??tweakedfont
+
+\appendtoks
+ % we can optimize for zero and 1000 .. maybe also options?
+ \overloaded\frozen\protected\edefcsname\currenttweakedfont\endcsname
+ {\begincsname\tweakedfontparameter\c!style\endcsname
+ \glyphxscale \numexpr\numericscale\tweakedfontparameter\c!xscale*\glyphxscale/\plusthousand\relax
+ \glyphyscale \numexpr\numericscale\tweakedfontparameter\c!yscale*\glyphyscale/\plusthousand\relax
+ \glyphxoffset\dimexpr\glyphxoffset+\tweakedfontparameter\c!xoffset\relax
+ \glyphyoffset\dimexpr\glyphyoffset+\tweakedfontparameter\c!yoffset\relax}%
+\to \everydefinetweakedfont
+
+\setuptweakedfont
+ [\c!scale=\plusthousand,
+ \c!xscale=\tweakedfontparameter\c!scale,
+ \c!yscale=\tweakedfontparameter\c!scale,
+ \c!xoffset=\zeropoint,
+ \c!yoffset=\zeropoint]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-imp-math.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-imp-math.lmt
new file mode 100644
index 00000000000..277190f2410
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-imp-math.lmt
@@ -0,0 +1,226 @@
+if not modules then modules = { } end modules ['font-imp-math'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv and hand-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local next, type, tonumber = next, type, tonumber
+
+local fonts = fonts
+local helpers = fonts.helpers
+local registerotffeature = fonts.handlers.otf.features.register
+
+local setmetatableindex = table.setmetatableindex
+
+local texconditionals = tex.conditionals
+
+-- tfmdata.properties.mathnolimitsmode = tonumber(value) or 0
+
+local splitter = lpeg.splitat(",",tonumber)
+local lpegmatch = lpeg.match
+
+local function initialize(tfmdata,value)
+ local mathparameters = tfmdata.mathparameters
+ if mathparameters then
+ local sup, sub
+ if type(value) == "string" then
+ sup, sub = lpegmatch(splitter,value)
+ if not sup then
+ sub, sup = 0, 0
+ elseif not sub then
+ sub, sup = sup, 0
+ end
+ elseif type(value) == "number" then
+ sup, sub = 0, value
+ end
+ if sup then
+ mathparameters.NoLimitSupFactor = sup
+ end
+ if sub then
+ mathparameters.NoLimitSubFactor = sub
+ end
+ end
+end
+
+registerotffeature {
+ name = "mathnolimitsmode",
+ description = "influence nolimits placement",
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+-- this will become a mode in the engine
+
+local function initialize(tfmdata,value)
+ tfmdata.properties.nostackmath = value and true
+end
+
+registerotffeature {
+ name = "nostackmath",
+ description = "disable math stacking mechanism",
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+-- A quick and dirty and low level implementation but okay for testing:
+
+function fonts.helpers.mathscriptslots(tfmdata,textcode)
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local rawfeatures = rawresources and rawresources.features
+ local basesubstitutions = rawfeatures and rawfeatures.gsub
+ local sequences = basesubstitutions and tfmdata.resources.sequences
+ if sequences then
+ local characters = tfmdata.characters
+ if characters[textcode] then
+ for s=1,#sequences do
+ local sequence = sequences[s]
+ local sfeatures = sequence.features
+ if sfeatures and sfeatures.ssty then
+ local steps = sequence.steps
+ for i=1,#steps do
+ local coverage = steps[i].coverage
+ if coverage then
+ local okay = coverage[textcode]
+ if okay then
+ return okay
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local function manipulate(tfmdata,key,value)
+ if texconditionals["c_font_compact"] then
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local rawfeatures = rawresources and rawresources.features
+ local basesubstitutions = rawfeatures and rawfeatures.gsub
+ local sequences = basesubstitutions and tfmdata.resources.sequences
+
+ if sequences then
+ local characters = tfmdata.characters
+ for s=1,#sequences do
+ local sequence = sequences[s]
+ local sfeatures = sequence.features
+ if sfeatures and sfeatures.ssty then
+ local steps = sequence.steps
+ for i=1,#steps do
+ local coverage = steps[i].coverage
+ if coverage then
+ for textcode, v in next, coverage do
+ local textdata = characters[textcode]
+ if textdata then
+ local scriptcode = v[1]
+ local scriptscriptcode = v[2]
+ local scriptdata = characters[scriptcode]
+ local scriptscriptdata = characters[scriptscriptcode]
+ if scriptdata then
+ textdata.smaller = scriptcode
+ end
+ if scriptscriptdata then
+ scriptdata.smaller = scriptscriptcode
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local function initialize(tfmdata,key,value)
+ if texconditionals["c_font_compact"] then
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local mathconstants = rawresources.mathconstants
+ if mathconstants then
+ local parameters = tfmdata.parameters
+ parameters.textscale = 1000
+ parameters.scriptscale = mathconstants.ScriptPercentScaleDown * 10
+ parameters.scriptscriptscale = mathconstants.ScriptScriptPercentScaleDown * 10
+ end
+ end
+end
+
+local specification = {
+ name = "compactmath",
+ description = "use one math font",
+ manipulators = {
+ base = manipulate,
+ node = manipulate,
+ },
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+registerotffeature(specification)
+
+-- The problem is that the traditional code path doesn't add an italic to the subscript,
+-- simply because it assumes that the width has that already subtracted. So, we cannot
+-- compensate in the following way. We're stuck with the fact that the texgyre fonts
+-- assume a traditional tex engine.
+
+-- local function manipulate(tfmdata,key,value)
+-- if value == "correct" then
+-- local chardata = characters.data
+-- for unicode, data in next, tfmdata.characters do
+-- local italic = data.italic
+-- if italic then
+-- -- todo: only letters
+-- data.width = (data.width or 0) + italic
+-- local cd = chardata[unicode]
+-- if cd then
+-- local visual = cd.visual
+-- if visual == "it" or visual == "bi" then
+-- italic = -italic
+-- else
+-- italic = 0
+-- end
+-- else
+-- italic = 0
+-- end
+-- data.italic = italic
+-- end
+-- end
+-- end
+-- end
+
+local function initialize(tfmdata,key,value)
+ if value then
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local mathconstants = rawresources.mathconstants
+ if mathconstants then
+ tfmdata.properties.oldmath = true
+ end
+ end
+end
+
+local specification = {
+ name = "oldmath",
+ description = "deal with fake opentype fonts",
+ -- manipulators = {
+ -- base = manipulate,
+ -- node = manipulate,
+ -- },
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+registerotffeature(specification)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-imp-tracing.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-imp-tracing.lmt
new file mode 100644
index 00000000000..59603c9ddd6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-imp-tracing.lmt
@@ -0,0 +1,286 @@
+if not modules then modules = { } end modules ['font-imp-tracing'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv and hand-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local abs = math.abs
+
+local next, type = next, type
+local concat = table.concat
+local formatters = string.formatters
+
+local fonts = fonts
+
+local handlers = fonts.handlers
+local registerotffeature = handlers.otf.features.register
+local registerafmfeature = handlers.afm.features.register
+
+local settings_to_array = utilities.parsers.settings_to_array
+local setmetatableindex = table.setmetatableindex
+
+local helpers = fonts.helpers
+local appendcommandtable = helpers.appendcommandtable
+local prependcommands = helpers.prependcommands
+local charcommand = helpers.commands.char
+
+local variables = interfaces.variables
+
+local v_background = variables.background
+local v_frame = variables.frame
+local v_empty = variables.empty
+local v_none = variables.none
+
+local function initialize(tfmdata,key,value)
+ if value then
+ local vfspecials = fonts.helpers.vfspecials
+ local vfcommands = fonts.helpers.commands
+ local backgrounds = vfspecials.backgrounds
+ local outlines = vfspecials.outlines
+ local characters = tfmdata.characters
+ local rulecache = backgrounds
+ local showchar = true
+ local color = "palegray"
+ if type(value) == "string" then
+ value = settings_to_array(value)
+ for i=1,#value do
+ local v = value[i]
+ if v == v_frame then
+ rulecache = outlines
+ elseif v == v_background then
+ rulecache = backgrounds
+ elseif v == v_empty then
+ showchar = false
+ elseif v == v_none then
+ color = nil
+ else
+ color = v
+ end
+ end
+ end
+ local gray = color and { "startcolor", color } or nil
+ local black = gray and { "stopcolor" } or nil
+ for unicode, character in next, characters do
+ local width = character.width or 0
+ local height = character.height or 0
+ local depth = character.depth or 0
+ local rule = rulecache[height][depth][width]
+ if showchar then
+ local commands = character.commands
+ if commands then
+ if gray then
+ character.commands = prependcommands (
+ commands, gray, rule, black
+ )
+ else
+ character.commands = prependcommands (
+ commands, rule
+ )
+ end
+ else
+ local char = charcommand[unicode]
+ if gray then
+ character.commands = {
+ gray, rule, black, char
+ }
+ else
+ character.commands = {
+ rule, char
+ }
+ end
+ end
+ else
+ if gray then
+ character.commands = {
+ gray, rule, black
+ }
+ else
+ character.commands = {
+ rule
+ }
+ end
+ end
+ end
+ end
+end
+
+local specification = {
+ name = "boundingbox",
+ description = "show boundingbox",
+ manipulators = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+registerotffeature(specification)
+registerafmfeature(specification)
+
+local function initialize(tfmdata,key,value)
+ if value then
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local mathconstants = rawresources.mathconstants
+ if mathconstants then
+ local vfspecials = fonts.helpers.vfspecials
+ local vfcommands = fonts.helpers.commands
+ local backgrounds = vfspecials.backgrounds
+ local outlines = vfspecials.outlines
+ local characters = tfmdata.characters
+ local rulecache = backgrounds
+ local push = vfcommands.push
+ local pop = vfcommands.pop
+ local black = { "stopcolor" }
+ local itcolor = { "startcolor", "trace:0" } -- s / dd (transparent)
+ local brcolor = { "startcolor", "trace:1" } -- r / dr
+ local trcolor = { "startcolor", "trace:2" } -- g / dg
+ local blcolor = { "startcolor", "trace:3" } -- b / db
+ local tlcolor = { "startcolor", "trace:4" } -- y / dy
+ for unicode, character in next, characters do
+ local mathkern = character.mathkern
+ local italic = character.vert_italic or character.italic
+ if mathkern or (italic and italic ~= 0) then
+ local width = character.width or 0
+ local height = character.height or 0
+ local depth = character.depth or 0
+ local list = { }
+ local count = 0
+ if italic and italic ~= 0 then
+ count = count + 1 list[count] = itcolor
+ count = count + 1 list[count] = push
+ count = count + 1 list[count] = { "offset", width + (italic < 0 and -italic or 0), 0 }
+ count = count + 1 list[count] = rulecache[height][depth][abs(-italic)]
+ count = count + 1 list[count] = pop
+ count = count + 1 list[count] = black
+ end
+ if mathkern then
+ local br = mathkern.bottom_right
+ local tr = mathkern.top_right
+ local bl = mathkern.bottom_left
+ local tl = mathkern.top_left
+ if br then
+ local done = false
+ for i=1,#br do
+ local l = br[i]
+ local h = l.height or 0
+ local k = l.kern or 0
+ if k ~= 0 then
+ if h == 0 then
+ h = height + depth -- todo max
+ end
+ if not done then
+ count = count + 1 list[count] = brcolor
+ done = true
+ end
+ count = count + 1 list[count] = push
+ count = count + 1 list[count] = { "offset", width + (k < 0 and k or 0), - depth }
+ count = count + 1 list[count] = rulecache[h][0][abs(k)]
+ count = count + 1 list[count] = pop
+ end
+ end
+ if done then
+ count = count + 1 list[count] = black
+ end
+ end
+ if tr then
+ local done = false
+ for i=1,#tr do
+ local l = tr[i]
+ local h = l.height or 0
+ local k = l.kern or 0
+ if k ~= 0 then
+ if h == 0 then
+ h = height + depth -- todo max
+ end
+ if not done then
+ count = count + 1 list[count] = trcolor
+ done = true
+ end
+ count = count + 1 list[count] = push
+ count = count + 1 list[count] = { "offset", width + (k < 0 and k or 0), height - h }
+ count = count + 1 list[count] = rulecache[h][0][abs(k)]
+ count = count + 1 list[count] = pop
+ end
+ end
+ if done then
+ count = count + 1 list[count] = black
+ end
+ end
+ if bl then
+ local done = false
+ for i=1,#bl do
+ local l = bl[i]
+ local h = l.height or 0
+ local k = l.kern or 0
+ if k ~= 0 then
+ if h == 0 then
+ h = height + depth -- todo max
+ end
+ if not done then
+ count = count + 1 list[count] = blcolor
+ done = true
+ end
+ count = count + 1 list[count] = push
+ count = count + 1 list[count] = { "offset", (k < 0 and k or 0), -depth }
+ count = count + 1 list[count] = rulecache[h][0][abs(k)]
+ count = count + 1 list[count] = pop
+ end
+ end
+ if done then
+ count = count + 1 list[count] = black
+ end
+ end
+ if tl then
+ local done = false
+ for i=1,#tl do
+ local l = tl[i]
+ local h = l.height or 0
+ local k = l.kern or 0
+ if k ~= 0 then
+ if h == 0 then
+ h = height + depth -- todo max
+ end
+ if not done then
+ count = count + 1 list[count] = tlcolor
+ done = true
+ end
+ count = count + 1 list[count] = push
+ count = count + 1 list[count] = { "offset", (k < 0 and k or 0), height - h }
+ count = count + 1 list[count] = rulecache[h][0][abs(k)]
+ count = count + 1 list[count] = pop
+ end
+ end
+ if done then
+ count = count + 1 list[count] = black
+ end
+ end
+ end
+ if count > 0 then
+ local commands = character.commands
+ if commands then
+ character.commands = appendcommandtable(commands,list)
+ else
+ list[#list+1] = charcommand[unicode]
+ character.commands = list
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local specification = {
+ name = "staircase",
+ description = "show staircase kerns",
+-- position = 1,
+ manipulators = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+registerotffeature(specification)
+registerafmfeature(specification)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-ini.lmt
new file mode 100644
index 00000000000..45e8f9e18a7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ini.lmt
@@ -0,0 +1,40 @@
+if not modules then modules = { } end modules ['font-ini'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+--[[ldx--
+
Not much is happening here.
+--ldx]]--
+
+local allocate = utilities.storage.allocate
+local sortedhash = table.sortedhash
+
+fonts = fonts or { }
+local fonts = fonts
+
+local identifiers = allocate()
+
+fonts.hashes = fonts.hashes or { identifiers = identifiers }
+fonts.tables = fonts.tables or { }
+fonts.helpers = fonts.helpers or { }
+fonts.tracers = fonts.tracers or { } -- for the moment till we have move to moduledata
+fonts.specifiers = fonts.specifiers or { } -- in format !
+
+fonts.analyzers = { } -- not needed here
+fonts.readers = { }
+fonts.definers = { methods = { } }
+fonts.loggers = { register = function() end }
+
+fonts.privateoffsets = {
+ textbase = 0xF0000, -- used for hidden (opentype features)
+ textextrabase = 0xFD000, -- used for visible by name
+ mathextrabase = 0xFE000, -- used for visible by code
+ mathbase = 0xFF000, -- used for hidden (virtual math)
+ keepnames = false, -- when set to true names are always kept (not for context)
+}
+
+-- Also here now:
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ini.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-ini.mklx
new file mode 100644
index 00000000000..557ac3c49e2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ini.mklx
@@ -0,0 +1,2693 @@
+%D \module
+%D [ file=font-ini,
+%D version=1998.09.11, % (second)
+%D version=2001.02.20, % (third)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo: frozen tolerant iftok etc
+
+% todo: < 3 pt => 3pt
+% todo: check where more class usage
+% todo: split font-nam (style/alternative/size)
+% todo: split font-dim (scales etc)
+% todo: reconsider defaultfontclass
+
+%D Beware, we use a special set of parameters here:
+%D
+%D \starttabulate[|l|l|]
+%D \NC system variable (fixed) \NC \type {\s!text} \NC \NR
+%D \NC system variable (fixed) \NC \type {\s!script} \NC \NR
+%D \NC system variable (fixed) \NC \type {\s!scriptscript} \NC \NR
+%D \NC system variable (fixed) \NC \type {\s!x} \NC \NR
+%D \NC system variable (fixed) \NC \type {\s!xx} \NC \NR
+%D \NC variable (value) \NC \type {\v!big} \NC \NR
+%D \NC variable (value) \NC \type {\v!small} \NC \NR
+%D \NC constant (regular key) \NC \type {\c!interlinespace} \NC \NR
+%D \NC constant (regular key) \NC \type {\c!em} \NC \NR
+%D \stoptabulate
+%D
+%D The math related ones are similar to the ones used in \TEX\ itself,
+%D the size related ones show up as keywords in the user interface
+%D when switching sizes, and the two constants are used in key|/|value
+%D situations.
+
+%D We should consider design sizes ... maybe kick 'm out which removes
+%D the size code and simplifies things considerably. After all, there
+%D will be no latin modern math in sizes.
+
+\writestatus{loading}{ConTeXt Font Macros / Initialization}
+
+%D Documentation is somewhat messy as it contains bits and pieces of
+%D previous versions.
+
+\unprotect
+
+%D There are several ways to specify a font. Three of them are pure \TEX\ ones, the
+%D fourth one is new:
+%D
+%D \starttyping
+%D \font\name=cmr12
+%D \font\name=cmr12 at 10pt
+%D \font\name=cmr12 scaled 2
+%D \font\name=cmr12 sa 1.440
+%D \stoptyping
+%D
+%D The non||\TEX\ alternative \type{sa} stands for {\em scaled at}. This means as
+%D much as: scale the bodyfontsize with this factor. The scaled option is not that
+%D useful as one needs to know the design size.
+%D
+%D Because \type {sa} (scaled at) and \type {mo} (mapped on) are not low level \TEX\
+%D supported alternatives, we have to test for it ourselves. In doing so, we need an
+%D auxiliary \DIMENSION. We cannot use \type{\scratchdimen} because font loading can
+%D happen at any moment due to postponed loading. We could instead have used dirty
+%D grouping tricks, but this one works too.
+
+% \enableexperiments[fonts.autorscale]
+%
+% \starttypescript[mscore]
+% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default]
+% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860]
+% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065]
+% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020]
+% \stoptypescript
+%
+% \starttext
+% \setupbodyfont[mscore,12pt]
+% \startTEXpage
+% test \ss test \tt test
+% \stopTEXpage
+% \stoptext
+
+% \definetypeface[one][rm][serif][computer-roman][default]
+% \definetypeface[two][rm][serif][computer-roman][default][rscale=.9]
+%
+% {\one \bf test \two test}
+% {\one \bf test \pushcurrentfont \two \popcurrentfont test}
+
+%D \macros
+%D {rm,ss,tt,hw,cg}
+%D
+%D Fonts are defined in separate files. When we define a font, we distinguish
+%D between several styles. In most cases we will use:
+%D
+%D \startlinecorrection
+%D \starttable[|l||]
+%D \HL
+%D \NC roman regular serif \NC \type{\rm} \NC\FR
+%D \NC sansserif sans support \NC \type{\ss} \NC\MR
+%D \NC type teletype mono \NC \type{\tt} \NC\LR
+%D \HL
+%D \stoptable
+%D \stoplinecorrection
+%D
+%D The number of styles is not limited to these three. When using Lucida Bright we
+%D can for instance also define:
+%D
+%D \startlinecorrection
+%D \starttable[|l||]
+%D \HL
+%D \NC handwritten \NC \type{\hw} \NC\FR
+%D \NC calligraphic \NC \type{\cg} \NC\LR
+%D \HL
+%D \stoptable
+%D \stoplinecorrection
+%D
+%D Within such a font set (\type{cmr}) and style (\type{\rm}) we can define a number
+%D of text font alternatives:
+%D
+%D \startlinecorrection
+%D \starttable[|l||]
+%D \HL
+%D \NC typeface \NC \type{\tf} \NC\FR
+%D \NC boldface \NC \type{\bf} \NC\MR
+%D \NC slanted \NC \type{\sl} \NC\MR
+%D \NC italic \NC \type{\it} \NC\MR
+%D \NC boldslanted \NC \type{\bs} \NC\MR
+%D \NC bolditalic \NC \type{\bi} \NC\MR
+%D \NC smallcaps \NC \type{\sc} \NC\LR
+%D \HL
+%D \stoptable
+%D \stoplinecorrection
+%D
+%D Internally fonts are stored as combination of size, style
+%D and alternative, e.g. \type{12pt}+\type{\ss}+\type{\bf}. Users are not confronted
+%D with sizes, but use the style or style+alternative to activate them.
+%D
+%D During the definition of a bodyfont one can also declare the available larger
+%D alternatives:
+%D
+%D \starttyping
+%D \tf \tfa \tfb \tfc ...
+%D \bf \bfa \bfb \bfc ...
+%D \sl \sla \slb \slc ...
+%D \stoptyping
+%D
+%D The smaller ones are automatically supplied and derived from
+%D the the bodyfont environment.
+%D
+%D \starttyping
+%D \tfx \tfxx
+%D \bfx \bfxx
+%D \slx \slxx
+%D \stoptyping
+%D
+%D There are only two smaller alternatives per style. The larger alternatives on the
+%D other hand have no limitations.
+%D
+%D These larger alternatives are mostly used in chapter and section titles or on
+%D title pages. When one switches to a larger alternative, the bold an other ones
+%D automatically adapt themselves:
+%D
+%D \startbuffer
+%D \tfd Hi \bf there\sl, here \tfb I \bf am
+%D \stopbuffer
+%D
+%S \startnarrower
+%D \typebuffer
+%S \stopnarrower
+%D
+%D therefore becomes:
+%D
+%D \startexample
+%D \getbuffer
+%D \stopexample
+%D
+%D Maybe this mechanism isn't always as logic, but as said before, we tried to make
+%D it as intuitive as possible.
+%D
+%D So a specific kind of glyph can be characterized by:
+%D
+%D \startnarrower
+%D family (cmr) + bodyfont (12pt) + style (rm) + alternative (bf) + size (a)
+%D \stopnarrower
+%D
+%D The last component (the size) is optional.
+%D
+%D We introduced \type {\tf} as command to call for the current normally sized
+%D typeface. This commands results in roman, sans serif, teletype or whatever style
+%D is in charge. Such rather massive switches of style sometimes take more
+%D processing time than comfortable. Of course there is a workaround for this: we
+%D can call fonts directly by means of commands like:
+%D
+%D \starttyping
+%D \rmtf \sssl \tttf \rmbsa
+%D \stoptyping
+%D
+%D One should realize that this fast calls have limitations, they lack for instance
+%D automatic super- and subscript support.
+%D
+%D This leaves us two more commands: \type {\tx} and \type {\txx}. These activate a
+%D smaller and even more smaller font than the current one and adapt themselves to
+%D the current alternative, so when \type {\bf} is active, \type {\tx} gives a
+%D smaller boldface, which in turn can be called directly by \type {\bfx}.
+%D
+%D These two smaller alternatives are specified by the bodyfont environment and
+%D therefore not necessarily have similar sizes as \type {\scriptsize} and \type
+%D {\scriptscriptsize}. The main reason for this incompatibility (which can easily
+%D be undone) lays in the fact that we often want a bit bigger characters than in
+%D math mode. In \CONTEXT\ for instance the \type {\tx} and \type {\txx} commands
+%D are used for surrogate \cap {smallcaps} which support both nesting and
+%D alternatives, like in {\bf \cap {a \cap {small} world}}, which was typeset by
+%D
+%D \starttyping
+%D \bf\cap{a \cap{small} world}
+%D \stoptyping
+%D
+%D And compare $\rm \scriptstyle THIS$ with the slightly larger \cap {THIS}:
+%D \ruledhbox {$\rm \scriptstyle scriptstyle: THIS$} or \ruledhbox {\cap {x style:
+%D THIS}} makes a big difference.
+%D
+%D The \type {x..d} sizes should be used grouped. If you don't group them, i.e. call
+%D them in a row, \CONTEXT\ will not be able to sort out your intention (\type {x}
+%D inside \type {d} inside \type {x}. etc.). The following table demonstrates this:
+%D
+%D \def\FontState{\setstrut\ruledhbox{\strut Hello}}
+%D
+%D \starttabulate[|||||]
+%D \HL
+%D \NC \rlap{\quad\bf grouped} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR
+%D \HL
+%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR
+%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR
+%D \NC \type{\tf} \NC \tf \FontState \NC \tf \tx \FontState \NC \tf \txx \FontState \NC \NR
+%D \NC \type{\tfa} \NC \tfa \FontState \NC \tfa \tx \FontState \NC \tfa \txx \FontState \NC \NR
+%D \NC \type{\tfb} \NC \tfb \FontState \NC \tfb \tx \FontState \NC \tfb \txx \FontState \NC \NR
+%D \NC \type{\tfc} \NC \tfc \FontState \NC \tfc \tx \FontState \NC \tfc \txx \FontState \NC \NR
+%D \NC \type{\tfd} \NC \tfd \FontState \NC \tfd \tx \FontState \NC \tfd \txx \FontState \NC \NR
+%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR
+%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR
+%D \HL
+%D \stoptabulate
+%D
+%D \blank
+%D
+%D \starttabulate[|||||]
+%D \HL
+%D \NC \rlap{\quad\bf stacked} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR
+%D \HL
+%D \NC \type{\tfx}
+%D \NC \tfx \FontState
+%D \NC \tfx \tx \FontState
+%D \NC \tfx \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfxx}
+%D \NC \tfx\tfxx \FontState
+%D \NC \tfx\tfxx \tx \FontState
+%D \NC \tfx\tfxx \txx \FontState
+%D \NC \NR
+%D \NC \type{\tf}
+%D \NC \tfx\tfxx\tf \FontState
+%D \NC \tfx\tfxx\tf \tx \FontState
+%D \NC \tfx\tfxx\tf \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfa}
+%D \NC \tfx\tfxx\tf\tfa \FontState
+%D \NC \tfx\tfxx\tf\tfa \tx \FontState
+%D \NC \tfx\tfxx\tf\tfa \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfb}
+%D \NC \tfx\tfxx\tf\tfa\tfb \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb \tx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfc}
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \tx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfd}
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \tx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfx}
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \tx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \txx \FontState
+%D \NC \NR
+%D \NC \type{\tfxx}
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \tx \FontState
+%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \txx \FontState
+%D \NC \NR
+%D \HL
+%D \stoptabulate
+
+\fontslantperpoint \nullfont 0\scaledpoint
+\fontinterwordspace \nullfont 256377\scaledpoint
+\fontinterwordstretch\nullfont 128188\scaledpoint
+\fontinterwordshrink \nullfont 85459\scaledpoint
+\fontexheight \nullfont 338952\scaledpoint
+\fontemwidth \nullfont 786432\scaledpoint
+\fontextraspace \nullfont 85459\scaledpoint
+
+\appendtoks
+ \fontslantperpoint \nullfont 0\scaledpoint
+ \fontinterwordspace \nullfont 256377\scaledpoint
+ \fontinterwordstretch\nullfont 128188\scaledpoint
+ \fontinterwordshrink \nullfont 85459\scaledpoint
+ \fontexheight \nullfont 338952\scaledpoint
+ \fontemwidth \nullfont 786432\scaledpoint
+ \fontextraspace \nullfont 85459\scaledpoint
+\to \everyjob
+
+%D Tracing
+
+\newtoks\t_font_tracers_definitions
+
+\permanent\protected\def\tracefontdefinitions
+ {\the\t_font_tracers_definitions}
+
+%D Some housekeeping macros:
+
+\permanent\protected\def\setfontparameters
+ {\setfalse\c_font_synchronize
+ \the\everybodyfont
+ \settrue\c_font_synchronize}
+
+\mutable\let\savedfont\empty
+
+\installmacrostack\savedfont
+
+% \fontname\font : string
+% \fontid \font : integer
+% \the \font : token (reference to font)
+% \fontspecifiedname : string
+% \the \fontspecifiedsize : dimension
+
+\permanent\protected\def\savefont
+ {\edef\savedfont{\the\font}%
+ \push_macro_savedfont}
+
+\permanent\protected\def\restorefont
+ {\pop_macro_savedfont
+ \savedfont}
+
+\aliased\let\popcurrentfont\relax
+
+\permanent\protected\def\pushcurrentfont
+ {\enforced\permanent\protected\edef\popcurrentfont
+ {\def\noexpand\fontbody {\fontbody}%
+ \def\noexpand\fontstyle {\fontstyle}%
+ \def\noexpand\fontalternative{\fontalternative}%
+ \def\noexpand\fontsize {\fontsize}%
+ \font_helpers_check_big_math_synchronization
+ \font_helpers_synchronize_font}}
+
+%D \macros{definedfont}
+
+\mutable\let\thedefinedfont\relax % not to be confused with \everydefinefont
+
+\permanent\tolerant\protected\def\definedfont[#specification]%
+ {\ifarguments
+ \c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
+ \or
+ \c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
+ \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
+ \fi
+ \thedefinedfont
+ \the\everydefinedfont}
+
+%D \macros{startfont}
+
+\permanent\protected\def\startfont{\begingroup\definedfont}
+\permanent\protected\def\stopfont {\endgroup}
+
+%D \macros
+%D {everybodyfont,everyglobalbodyfont}
+%D
+%D Every change in bodyfont size has conseqences for the baseline distance and skips
+%D between paragraphs. These are initialized in other modules. Here we only provide
+%D the hooks that garantees their handling.
+%D
+%D At the system level one can initialize thing like:
+%D
+%D \starttyping
+%D \appendtoks \setupspacing \to \everybodyfont
+%D \stoptyping
+
+%D \macros
+%D {globalbodyfontsize,localbodyfontsize,bodyfontsize}
+%D
+%D Here we have to distinguish between the global (overal) bodyfont size and the
+%D local (sometimes in the textflow) size. We store these dimensions in two
+%D \DIMENSION\ registers. These registers are not to be misused in calculations.
+
+\ifdefined\globalbodyfontsize \else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt
+\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize
+\ifdefined\bodyfontsize \else \newdimen\bodyfontsize \fi \bodyfontsize =\globalbodyfontsize
+
+%D When we assign for instance 12pt to a \DIMENSION\ register the \type {\the}'d
+%D value comes out as 12.0pt, which is often not the way users specify the bodyfont
+%D size. Therefore we use normalized values. They are cached to save overhead in
+%D \LUA\ calls.
+
+\installcorenamespace{fontnormalizedbody}
+
+\permanent\protected\def\normalizebodyfontsize#macro#body%
+ {\expandafter\let\expandafter#macro\csname\??fontnormalizedbody\number\dimexpr#body\endcsname
+ \ifrelax#macro%
+ \normalizebodyfontsize_indeed#macro{#body}%
+ \fi}
+
+\def\normalizebodyfontsize_indeed#macro#body%
+ {\edef#macro{\clf_nbfs\dimexpr#body\relax}%
+ \gletcsname\??fontnormalizedbody\number\dimexpr#body\endcsname#macro}
+
+\permanent\def\thenormalizedbodyfontsize#body%
+ {\clf_nbfs\dimexpr#body\relax}
+
+\mutable\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}
+\mutable\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
+\mutable\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
+
+%D \macros
+%D {mapfontsize}
+%D
+%D For special purposes, like in math, you may want to use slightly different sizes
+%D than the ones given. This happens for instance with the Math Times fonts. Mapped
+%D font sizes can be specified by using the \type {mo} key instead of \type {sa} in
+%D font definitions.
+%D
+%D \startbuffer
+%D \mapfontsize[10pt][11pt]
+%D \mapfontsize[11pt][12pt]
+%D \mapfontsize[12pt][13pt]
+%D
+%D \definefont[test][Serif]\test TEST \par
+%D \definefont[test][Serif sa 5]\test TEST \par
+%D \definefont[test][Serif mo 5]\test TEST \par
+%D \definefont[test][Serif sa d]\test TEST \par
+%D \definefont[test][Serif at 60pt]\test TEST \par
+%D \definefont[test][Serif scaled 6000]\test TEST \par
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startpacked
+%D \getbuffer
+%D \stoppacked
+
+\installcorenamespace{mappedfontsize}
+
+\permanent\tolerant\protected\def\mapfontsize[#from]#spacer[#to]%
+ {\ifarguments\or\or\defcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname{#to}\fi}
+
+\def\font_basics_set_mapped_fontsize#from%
+ {\ifcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname
+ \lastnamedcs\else#from%
+ \fi}
+
+\installcorenamespace{fontbodyknown}
+\installcorenamespace{fontclassyes} % fontclass
+\installcorenamespace{fontclassnop} % nofontclass
+
+\def\font_helpers_process_relative_size_list#command% could be a toks
+ {#command\v!big
+ #command\v!small}
+
+\let\v_font_size_relative \plusone
+\def\v_font_size_absolute {\fontbody}
+
+\let\v_font_rscale_default\!!plusone
+\let\p_font_rscale \v_font_rscale_default
+
+\def\font_helpers_check_relative_font_id % can be plugged in later
+ {\let\p_font_rscale\minusone
+ \let\p_font_rscale\v_font_rscale_default}
+
+\def\font_helpers_check_relative_font_size#style%
+ {\edef\p_font_rscale
+ {\ifcsname\??fontclass\fontclass#style\s!rscale\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??fontclass\defaultfontclass#style\s!rscale\endcsname % brr
+ \lastnamedcs
+ \else
+ \v_font_rscale_default
+ \fi}%
+ % move elsewhere
+ \ifx\p_font_rscale\v!auto
+ \let\p_font_rscale\plusone
+ \font_helpers_check_relative_font_id
+ \fi}
+
+\def\font_rscale_xx#style%
+ {\ifcsname\??fontclass\fontclass#style\s!rscale\endcsname
+ \lastnamedcs
+ \else
+ \v_font_rscale_default
+ \fi}
+
+\def\font_rscale_mm
+ {\ifcsname\??fontclass\fontclass\s!mm\s!rscale\endcsname
+ \lastnamedcs
+ \else
+ \v_font_rscale_default
+ \fi}
+
+\def\font_helpers_register_fontbody#body%
+ {\letcsname\??fontbodyknown#body\endcsname\empty}
+
+%D \macros
+%D {definefontstyle,definefontsize,definefontalternative}
+%D
+%D When setting of switching the overall style we can use the short identifier like
+%D rm and ss, but when defined we can also use more verbose names like roman or
+%D sansserif. Such names are defined by:
+%D
+%D \starttyping
+%D \definefontstyle [serif,rm] [rm]
+%D \definefontstyle [sansserif,ss] [ss]
+%D \stoptyping
+
+\installcorenamespace{fontstyle} % full style prefix (roman etc)
+\installcorenamespace{fontshortstyle} % short style prefix (rm etc)
+
+\installcorenamespace{fontstyleknown}
+\installcorenamespace{fontalternativeknown}
+\installcorenamespace{fontsizeknown}
+
+\newtoks\t_font_style_commands
+\newtoks\t_font_size_commands
+\newtoks\t_font_alternative_commands
+
+\setnewmacro\m_font_style_command \gobbleoneargument
+\setnewmacro\m_font_size_command \gobbleoneargument
+\setnewmacro\m_font_alternative_command\gobbleoneargument
+
+\def\font_helpers_process_style_list #command{\def\m_font_style_command {#command}\the\t_font_style_commands}
+\def\font_helpers_process_size_list #command{\def\m_font_size_command {#command}\the\t_font_size_commands}
+\def\font_helpers_process_alternative_list#command{\def\m_font_alternative_command{#command}\the\t_font_alternative_commands}
+
+\def\font_helpers_register_style #style{\letcsname\??fontstyleknown #style\endcsname\empty}
+\def\font_helpers_register_size #size{\letcsname\??fontsizeknown #size\endcsname\empty}
+\def\font_helpers_register_alternative#alternative{\letcsname\??fontalternativeknown#alternative\endcsname\empty}
+
+\permanent\protected\def\definefontstyle[#commands]#spacer[#style]% style: rm ss tt ...
+ {\ifcsname\??fontstyleknown#style\endcsname \else % can be delayed till used (cg, hw)
+ \font_helpers_register_style{#style}%
+ \toksapp\t_font_style_commands{\m_font_style_command{#style}}%
+ \fi
+ \processcommalist[#commands]{\font_basics_define_fontstyle_indeed{#style}}}
+
+\def\font_basics_define_fontstyle_indeed#style#command%
+ {\defcsname\??fontshortstyle#command\endcsname{#style}%
+ \defcsname\??fontstyle #command\endcsname{\csname#style\endcsname}}
+
+\permanent\protected\def\definefontsize[#size]%
+ {\ifcsname\??fontsizeknown#size\endcsname \else
+ \font_helpers_register_size{#size}%
+ \toksapp\t_font_size_commands{\m_font_size_command{#size}}%
+ \fi
+ \font_helpers_check_fontname_combinations}
+
+\permanent\protected\def\definefontalternative[#alternative]%
+ {\ifcsname\??fontalternativeknown#alternative\endcsname \else
+ \font_helpers_register_alternative{#alternative}%
+ \toksapp\t_font_alternative_commands{\m_font_alternative_command{#alternative}}%
+ \fi
+ \font_helpers_check_fontname_combinations}
+
+\protected\def\font_helpers_check_fontname_combinations % we need to split math and text here ... todo (math only has mr and mb)
+ {\font_helpers_process_style_list\font_helpers_check_fontname_combinations_s}
+
+\def\font_helpers_check_fontname_combinations_s#style%
+ {\font_helpers_process_alternative_list{\font_helpers_check_fontname_combinations_indeed_s_a{#style}}}
+
+\def\font_helpers_check_fontname_combinations_indeed_s_a#style#alternative%
+ {\font_helpers_process_size_list{\font_basics_check_fontname_combination{#style}{#alternative}}}
+
+\definefontstyle [\s!mm] [\s!mm]
+\definefontstyle [\s!rm] [\s!rm]
+\definefontstyle [\s!ss] [\s!ss]
+\definefontstyle [\s!tt] [\s!tt]
+
+%D We define all the font switching commands globally. After all they are part of
+%D the formal font interface once defined. The size can be empty (so checking is
+%D needed as \type {\bf} is already defined).
+%D
+%D The \type {\normal..} variants are available as extras for cases where the \type
+%D {..} is overloaded.
+
+\newmacro\m_font_mm
+
+\def\font_basics_check_fontname_combination#style% alternative size
+ {\edef\m_font_mm{#style}%
+ \ifx\m_font_mm\s!mm % prevents \max and alike (re)defs
+ \expandafter\font_basics_check_math_bodyfont
+ \else
+ \expandafter\font_basics_check_text_bodyfont
+ \fi{#style}} % no \m_font_mm, not expanded later on
+
+\def\font_basics_check_math_bodyfont#style#alternative#size%
+ {}
+
+\def\font_basics_check_text_bodyfont_step#whatever#body% size can be empty (checking needed as \bf is already defined)
+ {\ifcsname#whatever\endcsname\else
+ \permanent\setugvalue{#whatever}{#body}%
+ \fi}
+
+\def\font_basics_check_text_bodyfont#style#alternative#size% size can be empty (checking needed as \bf is already defined)
+ {\font_basics_check_text_bodyfont_step{#style#size}{\font_helpers_set_current_font_style_size{#style}{#size}}% \rma
+ \font_basics_check_text_bodyfont_step{#alternative#size}{\font_helpers_set_current_font_alternative_size{#alternative}{#size}}% \sla
+ \font_basics_check_text_bodyfont_step{#style#alternative#size}{\font_helpers_set_current_font_style_alternative_size{#style}{#alternative}{#size}}% \rmsla
+ \font_basics_check_text_bodyfont_step{#style}{\font_helpers_set_current_font_style{#style}}% \rm
+ \font_basics_check_text_bodyfont_step{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \sl
+ \font_basics_check_text_bodyfont_step{#style\s!x }{\font_helpers_set_current_font_x_style_alternative{#style}}% \rmx
+ \font_basics_check_text_bodyfont_step{#style\s!xx}{\font_helpers_set_current_font_xx_style_alternative{#style}}% \rmxx
+ \font_basics_check_text_bodyfont_step{#alternative\s!x }{\font_helpers_set_current_font_x_alternative{#alternative}}% \slx
+ \font_basics_check_text_bodyfont_step{#alternative\s!xx}{\font_helpers_set_current_font_xx_alternative{#alternative}}% \slxx
+ \font_basics_check_text_bodyfont_step{#style#alternative}{\font_helpers_set_current_font_style_alternative{#style}{#alternative}}}% \rmsl
+
+%D Scaling macros:
+%D
+%D This system is somewhat complicated by two (possible conflicting) demands:
+%D
+%D \startitemize
+%D \item We support wildcards like \type {sa *} which will adapt to the current
+%D size. This is also the default specification.
+%D \item We support named scales like \type {sa d}; beware: \type {x} and \type {xx}
+%D are valid scales but they are not alway the same as the ones used in for
+%D instance \type {\bfx} because there the sized come from the bodyfont
+%D environment. In the future there maybe a switch that also honors the
+%D environment in named scales.
+%D \stopitemize
+%D
+%D Keep in mind that the smaller sizes are just for text super and subscripts while
+%D larger sizes can be used in titles where for instance math follows the size.
+
+% b:x{\definedfont[SerifBold sa b]x}{\bfb x $x^x$}\par
+% 1:x{\definedfont[SerifBold sa 1]x}{\bf x $x^x$}\par
+% x:x{\definedfont[SerifBold sa x]x}{\bfx x $x^x$}\par
+% xx:x{\definedfont[SerifBold sa xx]x}{\bfxx x $x^x$}\par
+%
+% *:x{\definedfont[Serif sa *]x}\par
+% 1:x{\definedfont[Serif sa 1]x}\par
+% 2:x{\definedfont[Serif sa 2]x}\par
+% 3:x{\definedfont[Serif sa 3]x}\par
+% 4:x{\definedfont[Serif sa 4]x}\par
+% 5:x{\definedfont[Serif sa 5]x}\par
+
+\permanent\def\safontscale{\number\dimexpr\v_font_size_absolute\relax}
+\permanent\def\mofontscale{\number\dimexpr\font_basics_set_mapped_fontsize\v_font_size_absolute\relax}
+
+\mutable\let\somefontname \s!unknown
+\mutable\let\somefontspec \s!unknown
+\mutable\let\somefontfile \s!unknown
+\mutable\let\somefontsize \zerocount
+\mutable\let\somefontsizex\empty
+\mutable\let\somefontsizey\empty
+
+\newcount\scaledfontmode % also used at the lua end
+\newcount\scaledfontsize % also used at the lua end
+\newcount\lastfontid % also used at the lua end / tex end
+\newtoks \everydefinefont
+
+\aliased\let\c_font_feature_inheritance_fontnone \zerocount % none
+\aliased\let\c_font_feature_inheritance_fontonly \plusone % fontonly
+\aliased\let\c_font_feature_inheritance_classonly \plustwo % classonly
+\aliased\let\c_font_feature_inheritance_fontfirst \plusthree % fontfirst
+\aliased\let\c_font_feature_inheritance_classfirst\plusfour % classfirst
+
+\aliased\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst
+
+\setnewconstant\c_font_feature_inheritance_mode \c_font_feature_inheritance_default
+
+\newdimen \d_font_scaled_text_face
+\newdimen \d_font_scaled_font_size
+\newconditional\c_font_body_scale
+\newfraction \f_font_body_scale
+
+\newconditional\c_font_compact
+\newcount \c_font_scaled_glyph_scale
+
+\immutable\dimensiondef\d_font_scaled_default 10pt
+
+\newcount\c_font_future_glyph_scale
+
+% todo: move all to lua: use localcall for resolving filename
+
+\newcount\c_font_future_glyph_scale
+\newcount\c_font_scaled_font_mode_saved
+\newcount\c_font_scaled_points
+
+\mutable\let\somefontspec \empty
+\mutable\let\lastrawfontcall \relax
+\mutable\let\lastglobalrawfontcall\relax
+
+\protected\def\font_helpers_low_level_define
+ {\ifconditional\c_font_compact
+ \expandafter\font_helpers_low_level_define_compact
+ \else
+ \expandafter\font_helpers_low_level_define_normal
+ \fi}
+
+\protected\def\font_helpers_low_level_define_normal#specification#csname%
+ {% we can now set more at the lua end
+ \glet\somefontname\defaultfontfile
+ \let\somefontsize\empty
+ \let\somefontsizex\empty
+ \let\somefontsizey\empty
+ \clf_definefont_one{\detokenize\expandafter{\normalexpanded{#specification}}}% the escapestring catches at \somedimen
+ % sets \scaledfontmode and \somefontname and \somefontsize
+ \ifcase\fontface\relax
+ % \let\v_font_size_absolute\textface % fontbody
+ \or
+ \let\v_font_size_absolute\textface
+ \or
+ \let\v_font_size_absolute\scriptface
+ \or
+ \let\v_font_size_absolute\scriptscriptface
+ \or
+ \let\v_font_size_absolute\xtextface
+ \or
+ \let\v_font_size_absolute\xxtextface
+ \fi
+ %
+ \ifcase\scaledfontmode\relax
+ % none, avoid the designsize if possible
+ \d_font_scaled_font_size-\plusthousand\scaledpoint
+ \or
+ % at
+ \d_font_scaled_font_size\somefontsize
+ \or
+ % sa
+ \d_font_scaled_font_size\v_font_size_absolute\relax
+ \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size % uses \somefontsize set by lua
+ \or
+ % mo
+ \d_font_scaled_font_size\font_basics_set_mapped_fontsize\v_font_size_absolute
+ \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
+ \or
+ % scaled, don't use this one as it's unpredictable
+ \d_font_scaled_font_size-\somefontsize\scaledpoint
+ \else % ht cp
+ % experiment, yet undocumented
+ \d_font_scaled_font_size\somefontsize
+ \fi
+ \relax
+ \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size
+ \relax
+ %
+ \ifconditional\c_font_auto_size
+ \font_helpers_check_body_scale\fontsize
+ \ifconditional\c_font_body_scale
+ \d_font_scaled_font_size\f_font_body_scale\d_font_scaled_font_size
+ \d_font_scaled_text_face\f_font_body_scale\dimexpr\textface\relax
+ \else
+ \d_font_scaled_font_size\f_font_body_scale
+ \d_font_scaled_text_face\textface
+ \fi
+ \else
+ \d_font_scaled_text_face\textface
+ \fi
+ %
+ \edef\somefontspec{at \number\d_font_scaled_font_size sp}%
+ \edef\somefontfile{\truefontname\somefontname}%
+ \ifx\somefontfile\s!unknown
+ \edef\somefontfile{\defaultfontfile}%
+ \fi
+ \font_helpers_update_font_parameters
+ \font_helpers_update_font_class_parameters
+ %\writestatus{fonts}{low level define: #csname/\somefontfile/\number\d_font_scaled_font_size/\fontface/\number\d_font_scaled_text_face}%
+% \clf_definefont_two
+% \ifempty\fontclass\s!false\else\s!true\fi
+% {#csname}%
+% {\somefontfile}%
+% \d_font_scaled_font_size
+% \c_font_feature_inheritance_mode
+% {\m_font_class_features}%
+% {\m_font_features}%
+% {\m_font_class_fallbacks}%
+% {\m_font_fallbacks}%
+% \fontface
+% \d_font_scaled_text_face
+% {\m_font_class_goodies}%
+% {\m_font_goodies}%
+% {\m_font_class_designsize}%
+% {\m_font_designsize}%
+% \scaledfontmode
+ \clf_definefont_two
+ \ifempty\fontclass\s!false\else\s!true\fi
+ {#csname}%
+ \somefontfile
+ \d_font_scaled_font_size
+ \c_font_feature_inheritance_mode
+ \m_font_class_features
+ \m_font_features
+ \m_font_class_fallbacks
+ \m_font_fallbacks
+ \fontface
+ \d_font_scaled_text_face
+ \m_font_class_goodies
+ \m_font_goodies
+ \m_font_class_designsize
+ \m_font_designsize
+ \scaledfontmode
+ \relax
+ \ifcase\scaledfontsize
+ %\scaledfontsize\plusone
+ \let\somefontspec\empty
+ \let\lastrawfontcall\relax
+ \mutable\letcsname#csname\endcsname\relax
+ \else
+ \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks)
+ \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname
+ \the\everydefinefont
+ \fi
+ \c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
+
+\protected\def\font_helpers_low_level_define_compact#specification#csname%
+ {% we can now set more at the lua end
+ \glet\somefontname\defaultfontfile
+ \let\somefontsize\empty
+ \let\somefontsizex\empty
+ \let\somefontsizey\empty
+ \clf_definefont_one{\detokenize\expandafter{\normalexpanded{#specification}}}% the escapestring catches at \somedimen
+ % sets \scaledfontmode and \somefontname and \somefontsize
+ \ifcase\fontface\relax
+ % \let\v_font_size_absolute\textface % fontbody
+ \or
+ \let\v_font_size_absolute\textface
+ \or
+ \let\v_font_size_absolute\scriptface
+ \or
+ \let\v_font_size_absolute\scriptscriptface
+ \or
+ \let\v_font_size_absolute\xtextface
+ \or
+ \let\v_font_size_absolute\xxtextface
+ \fi
+ %
+ \ifcase\scaledfontmode\relax
+ % none, avoid the designsize if possible
+ \d_font_scaled_font_size-\plusthousand\scaledpoint
+ \or
+ % at
+ \d_font_scaled_font_size\somefontsize
+ \or
+ % sa
+ \d_font_scaled_font_size\v_font_size_absolute\relax
+ \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size % uses \somefontsize set by lua
+ \or
+ % mo
+ \d_font_scaled_font_size\font_basics_set_mapped_fontsize\v_font_size_absolute
+ \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
+ \or
+ % scaled, don't use this one as it's unpredictable
+ \d_font_scaled_font_size-\somefontsize\scaledpoint
+ \else % ht cp
+ % experiment, yet undocumented
+ \d_font_scaled_font_size\somefontsize
+ \fi
+ \relax
+ \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size
+ \relax
+ %
+ \ifconditional\c_font_auto_size
+ \font_helpers_check_body_scale\fontsize
+ \ifconditional\c_font_body_scale
+ \d_font_scaled_font_size\f_font_body_scale\d_font_scaled_font_size
+ \d_font_scaled_text_face\f_font_body_scale\dimexpr\textface\relax
+ \else
+ \d_font_scaled_font_size\f_font_body_scale
+ \d_font_scaled_text_face\textface
+ \fi
+ \else
+ \d_font_scaled_text_face\textface
+ \fi
+ %
+ \ifnum\c_font_scaled_font_mode_saved>\plusfour
+ \c_font_scaled_font_mode_saved\scaledfontmode
+ \scaledfontmode\zerocount
+ \fi
+ \c_font_future_glyph_scale\numexpr\plushundred*\d_font_scaled_font_size/\maxcard\relax
+ \glyphscale\numexpr\plushundred*\d_font_scaled_font_size/\maxcard\relax % needed ? for math i guess
+ % \d_font_scaled_font_size\d_font_scaled_default
+ % \d_font_scaled_text_face\d_font_scaled_default
+ %
+ \edef\somefontspec{at \number\d_font_scaled_font_size sp}%
+ % this has to happen at the tex end ...
+ \edef\somefontfile{\truefontname\somefontname}%
+ \ifx\somefontfile\s!unknown
+ \edef\somefontfile{\defaultfontfile}%
+ \fi
+ \font_helpers_update_font_parameters
+ \font_helpers_update_font_class_parameters
+ % ... till here
+ %\writestatus{fonts}{low level define: #csname/\somefontfile/\number\d_font_scaled_font_size/\fontface/\number\d_font_scaled_text_face}%
+ \clf_definefont_two
+ \ifempty\fontclass\s!false\else\s!true\fi
+ {#csname}%
+ \somefontfile
+ \d_font_scaled_font_size
+ \c_font_feature_inheritance_mode
+ \m_font_class_features
+ \m_font_features
+ \m_font_class_fallbacks
+ \m_font_fallbacks
+ \fontface
+ \d_font_scaled_default
+ \m_font_class_goodies
+ \m_font_goodies
+ \m_font_class_designsize
+ \m_font_designsize
+ \scaledfontmode
+ \relax
+ \ifcase\scaledfontsize
+ %\scaledfontsize\plusone
+ \let\somefontspec\empty
+ \let\lastrawfontcall\relax
+ \mutable\letcsname#csname\endcsname\relax
+ \else
+ \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks)
+ %
+ \glyphscale
+ \ifnum\c_font_scaled_font_mode_saved>\plusfour
+ \numexpr\plusthousand*\dimexpr\d_font_scaled_default\relax/\c_font_scaled_points\relax
+ \else
+ \c_font_future_glyph_scale
+ \fi
+ \ifempty\somefontsizex\else
+ \edef\somefontsizex{\glyphxscale\somefontsizex\relax}% todo: inserts relax
+ \fi
+ \ifempty\somefontsizey\else
+ \edef\somefontsizey{\glyphyscale\somefontsizey\relax}%
+ \fi
+ \ifempty\fontclass\else\global\fi
+ \mutable\protected\edefcsname#csname\endcsname
+ {\setfontid\the\fontid\csname#csname\endcsname\relax
+ \glyphscale\the\glyphscale\relax
+ \somefontsizex
+ \somefontsizey}%
+ %
+ \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname
+ \the\everydefinefont
+ \fi
+ \c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
+
+\def\font_helpers_check_body_scale#fontsize% gets character (x xx a etc)
+ {\ifcsname\??fontenvironments\fontclass\fontbody#fontsize\endcsname
+ \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
+ \setfalse\c_font_body_scale % !
+ \orelse\ifcsname\??fontenvironments\fontclass\s!default#fontsize\endcsname
+ \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
+ \settrue\c_font_body_scale
+ \orelse\ifcsname\??fontenvironments\fontbody#fontsize\endcsname
+ \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
+ \setfalse\c_font_body_scale % !
+ \orelse\ifcsname\??fontenvironments\s!default#fontsize\endcsname
+ \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
+ \settrue\c_font_body_scale
+ \orelse\ifcsname\??fontenvironments\fontclass\s!default\s!text\endcsname
+ \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
+ \settrue\c_font_body_scale
+ \orelse\ifcsname\??fontenvironments\s!default\s!text\endcsname
+ \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
+ \settrue\c_font_body_scale
+ \else
+ \let\f_font_body_scale\plusone
+ \settrue\c_font_body_scale
+ \fi}
+
+\newif\ifskipfontcharacteristics \skipfontcharacteristicstrue
+
+\tracingfonts\plussix %
+
+%D When fontclasses are used, we define the font global, since namespaces are
+%D used. Otherwise we parse the specs each time.
+
+\mutable\let\fontfile\s!unknown
+
+%D Relatively new:
+
+\installcorenamespace{fonts}
+\installcorenamespace{fontslanguage}
+
+\installsetuponlycommandhandler \??fonts {fonts}
+
+\newconstant\c_fonts_auto_language
+
+\letvalue{\??fontslanguage\v!auto}\plusone % experimental
+%letvalue{\??fontslanguage\v!yes }\plustwo % less efficient, for experiments
+
+\appendtoks
+ \c_fonts_auto_language
+ \ifcsname\??fontslanguage\fontsparameter\c!language\endcsname
+ \lastnamedcs
+ \else
+ \zerocount
+ \fi
+\to \everysetupfonts
+
+\appendtoks
+ \ifcase\c_fonts_auto_language
+ % nothing
+ \or
+ \addfflanguage
+ % \or
+ % font
+ \fi
+\to \everylanguage
+
+% \setupfonts
+% [\c!language=\v!auto]
+
+%D \macros
+%D {everyfont,everyfontswitch}
+
+\ifdefined\everyfont \else \newtoks\everyfont \fi
+\ifdefined\everyfontswitch \else \newtoks\everyfontswitch \fi
+
+\permanent\def\setfontcharacteristics{\the\everyfont}
+
+% \appendtoks
+% \ifcase\c_fonts_auto_language
+% % nothing
+% \or
+% % auto
+% \or
+% \addfflanguage
+% \fi
+% \to \everyfont
+
+%D \macros
+%D {definefont}
+%D
+%D We also accept \type{sa a}||\type{sa d} as specification.
+%D
+%D Before we implement the main definition macro, we first show one for local use:
+%D
+%D \starttyping
+%D \definefont[Some][LucidaBright at 100pt] \Some some
+%D \definefont[More][LucidaBright scaled 3000] \More more
+%D \definefont[Nice][LucidaBright mo 2] \Nice nice
+%D \definefont[Text][LucidaBright sa 5.4] \Text last
+%D \stoptyping
+%D
+%D The implementation looks as follows:
+
+\permanent\tolerant\protected\def\definefont[#1]#*[#2]#*[#3]% [name][spec][1.6 | line=10pt | setup_id]
+ {\ifparameter#3\or
+ \expandafter\font_basics_define_font_a
+ \else
+ \expandafter\font_basics_define_font_b
+ \fi[#1][#2][#3]}
+
+\def\font_basics_define_font_a[#name][#specification][#settings]% [name][spec][1.6 | line=10pt | setup_id]
+ {\doifelsesetups{#settings}%
+ {\mutable\protected\defcsname#name\endcsname{\font_basics_define_font_with_setups {#name}{#specification}{#settings}}}
+ {\mutable\protected\defcsname#name\endcsname{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}}}
+
+\def\font_basics_define_font_b[#name][#specification][#dummy]%
+ {\mutable\protected\defcsname#name\endcsname{\font_basics_define_font_without_parameters{#name}{#specification}}}
+
+\def\font_basics_define_font_with_parameters#name#specification#settings%
+ {\font_basics_define_font_without_parameters{#name}{#specification}%
+ \setuplocalinterlinespace[#settings]%
+ \setupspacing\relax} % is this really needed ?
+
+\def\font_basics_define_font_with_setups#name#specification#settings%
+ {\font_basics_define_font_without_parameters{#name}{#specification}%
+ \setups[#settings]}
+
+%D Beware, in the frozen variants no settings are supported yet, but that might happen
+%D some day.
+
+\permanent\tolerant\protected\def\definefrozenfont[#name]#spacer[#specification]#spacer[#settings]%
+ {\ifparameter#name\or
+ \begingroup
+ \definefont[#name][#specification][#settings]%
+ \csname#name\endcsname
+ \glet\lastglobalrawfontcall\lastrawfontcall
+ \endgroup
+ \aliased\letcsname#name\endcsname\lastglobalrawfontcall
+ \fi}
+
+%D The instance namespace protection makes the switch local so that we can redefine a
+%D logical name and/or change the size in between.
+
+% todo: now mathsize twice in name (so it can go here)
+% todo: check when mathsize is needed
+
+\ifdefined\??fontinstanceready \else \installcorenamespace{fontinstanceready} \fi
+\ifdefined\??fontinstancebasic \else \installcorenamespace{fontinstancebasic} \fi
+\ifdefined\??fontinstanceclass \else \installcorenamespace{fontinstanceclass} \fi
+
+\newconditional\c_font_auto_size \settrue\c_font_auto_size
+
+\mutable\let\lastfontidentifier\empty
+
+\def\v_font_identifier_basic{\??fontinstancebasic \lastfontidentifier-\fontsize-\fontface}
+\def\v_font_identifier_class{\??fontinstanceclass\fontclass-\lastfontidentifier-\fontsize-\fontface}
+
+\let\v_font_identifier_basic_saved\v_font_identifier_basic
+\let\v_font_identifier_class_saved\v_font_identifier_class
+
+% \def\v_font_identifier_class{\??fontinstanceclass\fontclass-\lastfontidentifier-\fontstyle-\fontsize} % no \fontface
+
+\def\font_basics_define_font_without_parameters#identifier#2%
+ {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
+ \edef\lastfontidentifier{#identifier}%
+ \let\v_font_size_relative\v_font_rscale_default
+ \let\v_font_size_absolute\fontbody
+ \font_helpers_low_level_define{#2}\v_font_identifier_basic
+ \csname\v_font_identifier_basic\endcsname
+ \setfalse\c_font_auto_size
+ \setfontcharacteristics
+ \the\everyfontswitch
+ \let\v_font_identifier_basic\v_font_identifier_basic_saved}
+
+\protected\def\font_helpers_trigger#identifier% make a traced variant
+ {\edef\lastfontidentifier{#identifier}%
+ \ifcsname\v_font_identifier_class\endcsname
+ % \writestatus{fonts}{trigger: reusing \v_font_identifier_class}%
+ \expandafter\font_helpers_trigger_reuse
+ \else
+ % \writestatus{fonts}{trigger: defining \v_font_identifier_class}%
+ \expandafter\font_helpers_trigger_define
+ \fi}
+
+\def\font_helpers_trigger_define#relative#absolute#specification%
+ {\def\v_font_size_relative{#relative}%
+ \def\v_font_size_absolute{#absolute}%
+ \font_helpers_low_level_define{#specification}\v_font_identifier_class
+ \csname\v_font_identifier_class\endcsname
+ \setfalse\c_font_auto_size
+ \ifskipfontcharacteristics \else
+ \setfontcharacteristics
+ \the\everyfontswitch
+ \fi
+ \let\v_font_identifier_class\v_font_identifier_class_saved}
+
+\def\font_helpers_trigger_reuse#relative#absolute#specification%
+ {\csname\v_font_identifier_class\endcsname
+ \setfalse\c_font_auto_size
+ \ifskipfontcharacteristics \else
+ \setfontcharacteristics
+ \the\everyfontswitch
+ \fi
+ \let\v_font_identifier_class\v_font_identifier_class_saved}
+
+%D \macros
+%D {currentfontbodyscale}
+%D
+%D Sometimes we need to have access to the font scale including the \type {a}||\type
+%D {d} sizes. The next macro returns the current scaling factor. Take a look at
+%D \type {cont-log.tex} for an example of its use.
+
+\installcorenamespace{fontenvironments}
+
+\permanent\def\currentfontbodysize % gets number (the normal sa 1 etc)
+ {\ifcsname\??fontenvironments\fontclass\s!default\somefontsize\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??fontenvironments\s!default\somefontsize\endcsname
+ \lastnamedcs
+ \else
+ \somefontsize
+ \fi}
+
+\permanent\def\currentfontbodyscale % gets character (x xx a etc)
+ {\csname\??fontenvironments
+ \ifcsname\??fontenvironments\fontclass\s!default\fontsize\endcsname\fontclass\s!default\fontsize\orelse
+ \ifcsname\??fontenvironments \s!default\fontsize\endcsname \s!default\fontsize\orelse
+ \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\fontclass\s!default\s!text \orelse
+ \ifcsname\??fontenvironments \s!default\s!text \endcsname \s!default\s!text \else
+ \s!default \fi
+ \endcsname}
+
+\def\font_currentfontbodyscale % gets character (x xx a etc)
+ {\ifcsname\??fontenvironments\fontclass\s!default\fontsize\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments \s!default\fontsize\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else
+ \csname\??fontenvironments \s!default \endcsname \fi}
+
+\permanent\def\currentfontscale % used in default definition
+ {\csname\??fontenvironments
+ \ifcsname\??fontenvironments\fontclass\s!default\xfontsize\endcsname\fontclass\s!default\fontsize\orelse
+ \ifcsname\??fontenvironments \s!default\xfontsize\endcsname \s!default\fontsize\orelse
+ \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\fontclass\s!default\s!text \orelse
+ \ifcsname\??fontenvironments \s!default\s!text \endcsname \s!default\s!text \else
+ \s!default \fi
+ \endcsname}
+
+\def\font_currentfontscale % used in default definition
+ {\ifcsname\??fontenvironments\fontclass\s!default\xfontsize\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments \s!default\xfontsize\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else
+ \csname\??fontenvironments \s!default \endcsname \fi}
+
+\setvalue{\??fontenvironments\s!default}{1}
+
+%D In the following macros we use \type {\currentxfontsize} to hold the current
+%D x||size of the font. This enables us to support for instance \type {\sl} inside a
+%D \type {\tx} switch.
+
+\newconstant\currentxfontsize
+
+\permanent\def\xfontsize{\ifcase\currentxfontsize\fontsize\or\s!x\else\s!xx\fi}
+
+%D Now we enter the area of font switching. The switching mechanism has to take care
+%D of several situations, like:
+%D
+%D \startitemize[packed]
+%D \item changing the overal document fonts (including margins, headers and footers)
+%D \item changing local fonts (only the running text)
+%D \item smaller and even more smaller alternatives (super- and subscripts)
+%D \stopitemize
+%D
+%D \TEX\ offers a powerful family mechanism for super- and subscripts in math mode.
+%D In text mode however, we don't use families for the smaller alternatives, and
+%D therefore have to take care of it otherwise.
+%D
+%D \macros
+%D {definebodyfontenvironment,setupbodyfontenvironment}
+%D
+%D The relationship between the several sizes of a font, is
+%D defined by:
+%D
+%D \showsetup{definebodyfontenvironment}
+%D
+%D Later on we will see how these parameters are used, so for the moment we stick
+%D with an example:
+%D
+%D \starttyping
+%D \definebodyfontenvironment
+%D [12pt]
+%D [ text=12pt,
+%D script=9pt,
+%D scriptscript=7pt,
+%D x=10pt,
+%D xx=8pt,
+%D big=12pt,
+%D small=10pt]
+%D \stoptyping
+%D
+%D The first argument specifies the bodyfont size to which the settings apply. All
+%D second parameters are specified in dimensions and tell us more about related
+%D sizes.
+%D
+%D Afterwards, one can change values with
+%D
+%D \showsetup{setupbodyfontenvironment}
+%D
+%D When instead of a size the keyword \type{unknown} is
+%D passed, fractions (relations) are used instead of fixed
+%D sizes.
+
+%D {\bf Remark:} We need to cover the following cases, otherwise users can get
+%D confused:
+%D
+%D \starttyping
+%D \setupbodyfont[23pt]
+%D
+%D \definebodyfontenvironment[23pt]
+%D \setupbodyfont[23pt]
+%D
+%D \definebodyfontenvironment[23pt]
+%D \definebodyfont[23pt][rm,ss,tt][default]
+%D \setupbodyfont[23pt]
+%D \stoptyping
+%D
+%D Beware: while some font defs can be global, the bodyfont environment checks
+%D local. This means that multiple local checks resulting in definitions are not
+%D that efficient. So, apart from an occasional switch, one should define an
+%D environment at the outer level.
+
+% \definebodyfontenvironment[33pt]
+% \definebodyfontenvironment[dejavu][default][1=.5]
+% \definebodyfontenvironment[dejavu][default][x=1.2]
+% \definebodyfontenvironment[dejavu][default][a=5]
+% \definebodyfontenvironment[dejavu][33pt][x=100pt]
+
+% the lookup order is:
+%
+% [class] [dimension] [parameters]
+% [class] [default] [parameters] % factors
+% [dimension] [parameters]
+% [default] [parameters] % factors
+%
+% with defaults providing factors
+
+% todo: class:size
+% todo: make assignments global
+
+\letvalue\??fontenvironments\empty % so we default to empty
+
+\permanent\def\bodyfontvariable#parameter%
+ {\csname\??fontenvironments
+ \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\orelse
+ \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse
+ \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\orelse
+ \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi
+ \endcsname}
+
+\def\font_bodyfontvariable#parameter%
+ {\ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi}
+
+\permanent\def\bodyfontsizevariable#size#parameter%
+ {\csname\??fontenvironments
+ \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse
+ \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse
+ \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse
+ \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi
+ \endcsname}
+
+\def\font_bodyfontsizevariable#size#parameter%
+ {\ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments #size#parameter\endcsname\lastnamedcs\orelse
+ \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi}
+
+\permanent\def\bodyfontinterlinespace{\bodyfontvariable\c!interlinespace} % used elsewhere
+
+\permanent\def\bodyfontdimension#class#size#parameter#body%
+ {\the\dimexpr
+ \ifcsname\??fontenvironments #class#size#parameter\endcsname \lastnamedcs \orelse
+ \ifcsname\??fontenvironments#class\s!default#parameter\endcsname \lastnamedcs\dimexpr#body\relax\orelse % factor
+ \ifcsname\??fontenvironments #size#parameter\endcsname \lastnamedcs \else
+ \lastnamedcs\dimexpr#body\relax\fi % factor
+ \relax}
+
+\installcorenamespace{fontenvironmentknown}
+
+\def\font_helpers_register_environment#class#body%
+ {\letcsname\??fontenvironmentknown#class#body\endcsname\empty}
+
+\newmacro\m_font_body
+\newmacro\m_font_body_normalized
+
+\permanent\tolerant\protected\def\definebodyfontenvironment[#1]#*[#2]#*[#3]% todo
+ {\ifarguments
+ \expandafter\font_basics_define_body_font_environment_unset
+ \or
+ \expandafter\font_basics_define_body_font_environment_unset
+ \or
+ \expandafter\font_basics_define_body_font_environment_empty
+ \or
+ \expandafter\font_basics_define_body_font_environment_class
+ \fi[#1][#2][#3]}
+
+\aliased\let\setupbodyfontenvironment\definebodyfontenvironment
+
+%D First we handle the class specific case. Beware: you can change values before
+%D a bodyfont is loaded but changing them afterwards can be sort of tricky as
+%D values are not consulted afterwards.
+
+\permanent\def\processbodyfontenvironmentlist#1% no \protected as then we cannot use it in alignments (still?)
+ {\clf_processbodyfontsizes{\strippedcsname#1}}
+
+\permanent\def\bodyfontenvironmentlist
+ {\clf_getbodyfontsizes}
+
+\def\font_basics_define_body_font_environment_class[#class][#body][#settings]%
+ {\edef\m_font_body{#body}%
+ \ifx\m_font_body\s!default
+ % these are the last resort within a class
+ \getrawparameters[\??fontenvironments#class\s!default][#settings]%
+ \else
+ \normalizebodyfontsize\m_font_body_normalized\m_font_body
+ \font_basics_define_body_font_environment_size[#class][\m_font_body_normalized][#settings]%
+ \clf_registerbodyfontsize{\m_font_body_normalized}%
+ \fi}
+
+%D The empty case uses the same code but needs to ignore the current class settings
+%D (just to be sure, as it's not really needed).
+
+\def\font_basics_define_body_font_environment_empty[#body][#settings][#dummy]%
+ {\push_macro_fontclass
+ \let\fontclass\empty
+ \font_basics_define_body_font_environment_class[][#body][#settings]%
+ \pop_macro_fontclass}
+
+\def\font_basics_define_body_font_environment_unset[#body][#dummya][#dummyb]%
+ {\push_macro_fontclass
+ \let\fontclass\empty
+ \font_basics_define_body_font_environment_class[][#body][]%
+ \pop_macro_fontclass}
+
+%D We don't check too soon as we can refer to later definitions.
+
+\newconditional\c_font_defining_environment_state % controls messages
+
+\def\font_basics_define_body_font_environment_size[#class][#normalizedbody][#settings]% normalized body
+ {\getrawparameters[\??fontenvironments#class#normalizedbody][#settings]%
+ \ifcsname\??fontenvironmentknown#class#normalizedbody\endcsname
+ % environment and size already defined
+ \orelse\ifproductionrun
+ \push_macro_fontclass
+ \edef\fontclass{#class}%
+ \font_helpers_register_environment{#class}{#normalizedbody}%
+ \settrue\c_font_defining_environment_state
+ \font_helpers_define_unknown_font{#normalizedbody}% current class
+ \setfalse\c_font_defining_environment_state
+ \pop_macro_fontclass
+ \fi
+ \font_helpers_register_fontbody{#normalizedbody}}
+
+%D Checking
+
+\def\font_helpers_check_bodyfont_environment#normalizedbody#body%
+ {\ifcsname\??fontenvironmentknown\fontclass#normalizedbody\endcsname
+ % already defined
+ \else
+ \font_helpers_check_bodyfont_environment_indeed{#normalizedbody}{#body}%
+ \fi}
+
+\def\font_helpers_check_bodyfont_environment_indeed#normalizedbody#body%
+ {\font_helpers_register_environment\fontclass{#normalizedbody}%
+ \ifcsname\??fontbodyknown#normalizedbody\endcsname
+ \else
+ \font_helpers_define_unknown_font{#normalizedbody}%
+ \fi}
+
+%D We default all parameters to the main bodyfont size, so the next setup is valid
+%D too:
+%D
+%D \starttyping
+%D \definebodyfontenvironment[24pt]
+%D \stoptyping
+%D
+%D All parameters can be redefined when needed, so one doesnot have to stick to the
+%D default ones.
+
+%D \macros
+%D {definebodyfont}
+%D
+%D The next step in defining a bodyfont involves the actual font files, which can be
+%D recognized by their extension \type {tfm}. Installing those file is often beyond
+%D the scope of the user and up to the system administrator.
+%D
+%D \showsetup{definebodyfont}
+%D
+%D This commands takes three arguments: a (series of) bodyfont size(s), the style
+%D group to which the definitions belong, and an alternative, as specified by the
+%D \TEX\ (math) families, extended with~a, b~\unknown.
+%D
+%D We show two examples, that show all the alternative scaling options. The \type
+%D {\tfa} alternatives can be extended with \type {\bfa}, \type {\slb}, etc. or even
+%D \type {e} and higher alternatives. The magic scaled values are derived from plain
+%D \TEX's \type {\magstep}:
+%D
+%D \starttyping
+%D \definebodyfont [12pt] [rm]
+%D [tf=cmr12,
+%D bf=cmbx12,
+%D it=cmti12,
+%D sl=cmsl12,
+%D bi=cmbxti10 at 12pt,
+%D bs=cmbxsl10 at 12pt,
+%D tfa=cmr12 scaled 1.200,
+%D tfb=cmr12 scaled 1.440,
+%D tfc=cmr12 scaled 1.728,
+%D tfd=cmr12 scaled 2.074,
+%D sc=cmcsc10 at 12pt]
+%D
+%D \definebodyfont [12pt,11pt,10pt,9pt,8pt] [rm]
+%D [tf=lbr sa 1,
+%D bf=lbd sa 1,
+%D it=lbi sa 1,
+%D sl=lbsl sa 1,
+%D bi=lbdi sa 1,
+%D bs=lbdi sa 1,
+%D tfa=lbr sa 1.200,
+%D tfb=lbr sa 1.440,
+%D tfc=lbr sa 1.728,
+%D tfd=lbr sa 2.074,
+%D sc=lbr sa 0.833]
+%D \stoptyping
+%D
+%D The second example shows that we can define more sizes at once. The main
+%D difference between these examples is that the Computer Modern Roman come in many
+%D design sizes. This means that there we cannot define them in bulk using \type
+%D {sa}. Instead of \type {rm} (roman) one can define \type {ss} (sans serif), \type
+%D {tt} (teletype), \type {hw} (hand written), \type {cg} (calygraphic) and whatever
+%D styles.
+%D
+%D The first argument may be a comma separated list. This, combined with
+%D specifications using \type{sa} can save a lot of typing. Although all arguments
+%D should be specified, we treat the second argument as optional.
+%D
+%D Defining a bodyfont involves two actions: defining the specific style related
+%D alternatives, like \type {\rma}, \type {\bfa} and \type {\rmsla}, and storing the
+%D definitions of their bodyfont size related fonts. The first step is bodyfont
+%D independant but executed every time. This permits user definitions like \type
+%D {\tfw} or \type {\bfq} for real large alternatives.
+%D
+%D If we move design size info to the lfg file (after all only lm has design sizes)
+%D we can get rid of much code .. 2012 or so.
+
+\installcorenamespace{fontdefinitions}
+
+% [class] [name] [rm,ss] [settings]
+% [class] [10pt,11pt] [rm,ss] [settings]
+% [class] [10pt,11pt] [rm,ss] [name]
+
+% [class] [name] [settings] == [name] [rm] [settings]
+% [class] [10pt,11pt] [settings] == [name] [rm] [settings]
+% [class] [10pt,11pt] [name] == [10pt,11pt] [rm] [name]
+
+\permanent\tolerant\protected\def\definebodyfont[#1]#*[#2]#*[#3]#*[#4]%
+ {\ifarguments
+ \or
+ \font_basics_define_body_font[#1][\s!rm][]%
+ \or
+ \font_basics_define_body_font[#1][\s!rm][#2]%
+ \or
+ \font_basics_define_body_font[#1][#2][#3]%
+ \or
+ \processcommacommand[#1]{\font_basics_define_body_font_class_given[#2][#3][#4]}%
+ \fi}
+
+\protected\def\font_basics_define_body_font[#whatever]%
+ {\doifelsenumber{#whatever}\font_basics_define_body_font_body\font_basics_define_body_font_name[#whatever]}
+
+\protected\def\font_basics_define_body_font_class_given[#1][#2][#3]#4%
+ {\push_macro_fontclass
+ \doifelse{#4}\s!default
+ {\let\fontclass\empty}
+ {\def\fontclass{#4}}%
+ \definebodyfont[#1][#2][#3]%
+ \pop_macro_fontclass}
+
+\protected\def\font_basics_define_body_font_body[#body][#style][#specification]%
+ {\ifcondition\validassignment{#specification}%
+ \expandafter\font_basics_define_body_font_body_assignment
+ \else
+ \expandafter\font_basics_define_body_font_body_identifier
+ \fi
+ [#body][#style][#specification]}%
+
+\protected\def\font_basics_define_body_font_name[#name][#style][#specification]%
+ {\ifcondition\validassignment{#specification}%
+ \expandafter\font_basics_define_body_font_name_assignment
+ \else
+ \expandafter\font_basics_define_body_font_name_identifier
+ \fi
+ [#name][#style][#specification]}%
+
+\protected\def\font_basics_define_body_font_body_assignment[#bodylist][#stylelist][#assignments]%
+ {\processcommalist[#bodylist]{\font_basics_define_body_font_body_assignment_a{#stylelist}{#assignments}}}
+
+\protected\def\font_basics_define_body_font_body_assignment_a#stylelist#assignments#body%
+ {\normalizebodyfontsize\m_font_asked_body{#body}%
+ % normally we define quite a lot in advance, i.e global defs
+ \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body % !!
+ \processcommalist[#stylelist]{\font_basics_define_body_font_body_assignment_b{#assignments}}}
+
+\protected\def\font_basics_define_body_font_body_assignment_b#assignments#style%
+ {\edef\m_font_asked_style{#style}%
+ \processcommalist[#assignments]\font_basics_define_body_font_defs}
+
+\protected\def\font_basics_define_body_font_defs
+ {\ifempty\fontclass
+ \expandafter\font_basics_define_body_font_defs_nop
+ \else
+ \expandafter\font_basics_define_body_font_defs_yes
+ \fi}
+
+\protected\def\font_basics_define_body_font_defs_yes_normal#assignment%
+ {\ifx\m_font_asked_style\s!mm
+ \expandafter\font_basics_define_body_font_yes_mm
+ \else
+ \expandafter\font_basics_define_body_font_yes_xx
+ \fi[#assignment]}
+
+\protected\def\font_basics_define_body_font_defs_nop_normal#assignment%
+ {\ifx\m_font_asked_style\s!mm
+ \expandafter\font_basics_define_body_font_nop_mm
+ \else
+ \expandafter\font_basics_define_body_font_nop_xx
+ \fi[#assignment]}
+
+\protected\def\font_basics_define_body_font_defs_yes_traced#assignment%
+ {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}%
+ \ifx\m_font_asked_style\s!mm
+ \expandafter\font_basics_define_body_font_yes_mm
+ \else
+ \expandafter\font_basics_define_body_font_yes_xx
+ \fi[#assignment]}
+
+\protected\def\font_basics_define_body_font_defs_nop_traced#assignment%
+ {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}%
+ \ifx\m_font_asked_style\s!mm
+ \expandafter\font_basics_define_body_font_nop_mm
+ \else
+ \expandafter\font_basics_define_body_font_nop_xx
+ \fi[#assignment]}
+
+\let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_normal
+\let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_normal
+
+\appendtoks
+ \let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_traced
+ \let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_traced
+\to \t_font_tracers_definitions
+
+%D We split into two characters (first part of spec) and the rest: the first two are
+%D the style and the rest is a size, although in practice one will seldom define the
+%D size directly. We might even drop that as it gives faster code.
+
+\protected\def\font_basics_define_body_font_nop_xx[#one#two#rest=#value]% local
+ {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
+ \letcsname\??fontinstanceclass\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname\undefined
+ \protected\edefcsname\??fontinstanceready\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \letcsname\??fontinstanceclass\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname\undefined
+ \protected\edefcsname\??fontinstanceready\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \letcsname\??fontinstanceclass\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname\undefined
+ \protected\edefcsname\??fontinstanceready\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ }
+
+\protected\def\font_basics_define_body_font_yes_xx[#one#two#rest=#value]% global
+ {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
+ \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-1\endcsname\undefined
+ \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-0}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-2\endcsname\undefined
+ \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-4}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-3\endcsname\undefined
+ \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-5}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ }
+
+% \writestatus{fonts}{define \m_asked_style\space yes: {\expandafter\meaning\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}
+
+%D Here the rest concerns rl or lr so in this case it is not a size specifier but
+%D a directional one.
+
+\protected\def\font_basics_define_body_font_nop_mm[#one#two#rest=#value]% local
+ {%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi
+ \letcsname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined
+ % \letcsname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined
+ % \letcsname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined
+ \protected\xdefcsname\??fontinstanceready\m_font_asked_body-\s!mm-#one#two#rest\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\s!mm-#one#two#rest}{\noexpand\font_rscale_mm}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ }
+
+% \writestatus{fonts}{define \m_asked_style\space nop: \expandafter\meaning\csname\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}%
+
+\protected\def\font_basics_define_body_font_yes_mm[#one#two#rest=#value]% global
+ {%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi
+ \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined
+ % \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined
+ % \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined
+ \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\s!mm-#one#two#rest\endcsname
+ {\font_helpers_trigger{\m_font_asked_body-\s!mm-#one#two#rest}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ }
+
+% \writestatus{fonts}{define \m_asked_style\space yes: \expandafter\meaning\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}%
+
+\protected\def\font_basics_define_body_font_body_identifier[#bodylist][#stylelist][#name]%
+ {\processcommalist[#bodylist]{\font_basics_define_body_font_body_identifier_a{#stylelist}{#name}}}
+
+\protected\def\font_basics_define_body_font_body_identifier_a#stylelist#name#body%
+ {\normalizebodyfontsize\m_font_asked_body{#body}%
+ \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body % !!
+ \processcommalist[#stylelist]{\font_basics_define_body_font_body_identifier_b{#name}}}
+
+\protected\def\font_basics_define_body_font_body_identifier_b#name#style%
+ {\edef\m_font_asked_style{#style}%
+ %\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] => [#name]}%
+ \csname\??fontdefinitions#name:\m_font_asked_style\endcsname} % no checking
+
+\protected\def\font_basics_define_body_font_name_assignment[#name][#stylelist][#assignments]%
+ {\processcommalist[#stylelist]{\font_basics_define_body_font_name_assignment_a{#name}{#assignments}}}
+
+\protected\def\font_basics_define_body_font_name_assignment_a#name#assignments#style%
+ {%\writestatus\m!fonts{[#name:#style] => [#assignments]}%
+ \edefcsname\??fontdefinitions#name:#style\endcsname{\font_basics_define_body_font_default{#assignments}}}
+
+\protected\def\font_basics_define_body_font_name_identifier[#name][#stylelist][#identifier]%
+ {\processcommalist[#stylelist]{\font_basics_define_body_font_name_identifier_a{#name}{#identifier}}}
+
+\protected\def\font_basics_define_body_font_name_identifier_a#name#identifier#style%
+ {%\writestatus\m!fonts{[#name:#style] => [##identifier:#style]}%
+ \ifcsname\??fontdefinitions#name:#style\endcsname
+ \letcsname\??fontdefinitions#name:#style\expandafter\endcsname\csname\??fontdefinitions#identifier:#style\endcsname
+ \else
+ \defcsname\??fontdefinitions#name:#style\endcsname{\csname\??fontdefinitions#identifier:#style\endcsname}%
+ \fi}
+
+%D The unknown:
+
+\newconditional\c_font_defining_unknown
+\newconditional\c_font_defining_state
+
+\protected\def\font_helpers_define_unknown_font#body% one level only
+ {\font_helpers_register_fontbody{#body}% prevents loop, can go
+ \setfalse\c_font_defining_state
+ \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_sizes{#body}}%
+ \ifconditional\c_font_defining_state
+ \setfalse\c_font_defining_state
+ \font_helpers_process_style_list{\font_helpers_define_unknown_check_definitions{#body}}%
+ \ifconditional\c_font_defining_state
+ \ifconditional\c_font_defining_environment_state\else
+ %\showmessage\m!fonts{14}{#body}% main
+ \clf_registerunknownbodysize{#body}%
+ \fi
+ \setfalse\c_font_defining_state
+ \font_helpers_register_fontbody{#body}%
+ % needed ?
+ \ifconditional\c_font_defining_unknown
+ \else
+ \settrue\c_font_defining_unknown
+ \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_relatives{#body}}%
+ \setfalse\c_font_defining_unknown
+ \fi
+ \fi
+ \fi}
+
+\def\font_helpers_define_unknown_check_sizes#body#relativesize%
+ {\ifcsname\??fontenvironments\s!default#relativesize\endcsname % fontclass ?
+ \expandafter\normalizebodyfontsize\csname\??fontenvironments#body#relativesize\endcsname{\csname\??fontenvironments\s!default#relativesize\endcsname\dimexpr#body\relax}%
+ \settrue\c_font_defining_state
+ \fi}
+
+\def\font_helpers_define_unknown_check_definitions#body#style%
+ {\ifcsname\??fontdefinitions\s!default:#style\endcsname
+ \edef\m_font_asked_body{#body}%
+ \edef\m_font_asked_style{#style}%
+ \lastnamedcs
+ \settrue\c_font_defining_state
+ \fi}
+
+\def\font_helpers_define_unknown_check_relatives#body#relativesize%
+ {\ifcsname\??fontbodyknown\csname\??fontenvironments#body#relativesize\endcsname\endcsname \else
+ \expandafter\font_helpers_define_unknown_font\csname\??fontenvironments#body#relativesize\endcsname
+ \settrue\c_font_defining_state
+ \fi}
+
+\protected\def\font_basics_define_body_font_default#assignments%
+ {\font_helpers_check_relative_font_size\m_font_asked_style % still needed here?
+ \ifcsname\m_font_asked_style\endcsname\else
+ \normalexpanded{\definefontstyle[\m_font_asked_style][\m_font_asked_style]}%
+ \fi
+ \processcommalist[#assignments]\font_basics_define_body_font_defs
+ \let\p_font_rscale\v_font_rscale_default}
+
+%D These macros show that quite some definitions take place. Fonts are not loaded
+%D yet! This means that at format generation time, no font files are present.
+
+\protected\def\font_basics_switch_points#body%
+ {\ifcsname\??fontbodyknown#body\endcsname \else
+ % we need to check the relative sizes for this body
+ \font_helpers_define_unknown_font{#body}%
+ \fi%
+ \ifcsname\??fontbodyknown#body\endcsname % always true now
+ \font_basics_complete_switch{#body}%
+ \localbodyfontsize#body\relax
+ \normalizebodyfontsize\normalizedbodyfontsize\localbodyfontsize
+ \font_helpers_check_bodyfont_environment\normalizedbodyfontsize\normalizedbodyfontsize % !!
+ \else
+ \showmessage\m!fonts4{#body}%
+ \fi
+ \ifconditional\c_font_compact
+ \glyphscale\numexpr\plushundred*\dimexpr\normalizedbodyfontsize\relax/\maxcard\relax
+ \fi}
+
+% \prependtoks
+% \ifconditional\c_font_compact
+% % better in lua ... accuracy
+% \glyphtextscale \numexpr\plusthousand*\dimexpr\textface \relax/\d_font_scaled_default\relax
+% \glyphscriptscale \numexpr\plusthousand*\dimexpr\scriptface \relax/\d_font_scaled_default\relax
+% \glyphscriptscriptscale \numexpr\plusthousand*\dimexpr\scriptscriptface\relax/\d_font_scaled_default\relax
+% \fi
+% \to \everymathematics
+
+\protected\def\font_basics_switch_style#style%
+ {\ifcsname\??fontstyle#style\endcsname
+ \lastnamedcs
+ \edef\fontstyle{#style}%
+ \ifmmode\mr\fi % in order to be compatible with \rm in math mode
+ % \the\everybodyfont % cleaner, in setting size as well as style
+ \else
+ \showmessage\m!fonts5{#style}%
+ \fi}
+
+%D Here comes the main font switching macros. These macros handle changes in size as
+%D well as returning to the global bodyfont size.
+
+\ifdefined\font_preloads_at_definition \else \let\font_preloads_at_definition\relax \fi
+
+\def\font_helpers_set_font#method#specification%
+ {\edef\m_font_specification{#specification}%
+ \ifempty\m_font_specification \else
+ \ifx\m_font_specification\v!global % we can have all kind of presets
+ \restoreglobalbodyfont
+ \else
+ \processcommacommand[\m_font_specification]{\font_helpers_set_font_check_size}%
+ \processcommacommand[\m_font_specification]{\font_helpers_set_font_set_font{#method}}%
+ \ifproductionrun
+ \font_preloads_at_definition
+ \font_basics_switch_points\normalizedbodyfontsize
+ \font_basics_switch_style\fontstyle
+ \ifempty\defaultfontclass
+ \let\defaultfontclass\fontclass
+ \fi
+ \fi
+ \fi
+ \currentxfontsize\zerocount
+ \fi}
+
+\def\font_helpers_set_font_check_size#option%
+ {\doifelsenumber{#option}{\font_helpers_check_bodyfont_environment{#option}{#option}}\donothing}
+
+\def\font_helpers_set_font_set_font#method#option% method=1: set, method=2: switch
+ {\doifsomething{#option}{\font_helpers_set_font_set_font_option{#method}{#option}}}
+
+\def\font_helpers_set_font_set_font_option#method#option%
+ {\doifelsenumber{#option}%
+ \font_helpers_set_font_set_font_option_body
+ \font_helpers_set_font_set_font_option_keyword
+ {#method}{#option}{#option}}
+
+\newmacro\m_font_keyword
+
+\protected\def\font_helpers_set_font_set_font_option_keyword#method#keyword#message%
+ {\edef\m_font_keyword{#keyword}%
+ \ifcsname\??fontenvironments\normalizedbodyfontsize\m_font_keyword\endcsname
+ \edef\m_font_step{\font_bodyfontvariable\m_font_keyword}%
+ \normalexpanded{\font_helpers_set_font_set_font_option_body{#method}{\m_font_step}{#message}}%
+ \orelse\ifx\m_font_keyword\v!reset
+ \let\fontstyle\empty % new 31/7/2006
+ \let\fontsize \empty
+ \orelse\ifcsname\??fontstyle\m_font_keyword\endcsname
+ \let\fontstyle\m_font_keyword
+ \else
+ \setcurrentfontclass\m_font_keyword
+ \ifcase#method\relax
+ \let\globalfontclass\globalfontclass % -)
+ \else
+ \let\globalfontclass\fontclass
+ \fi
+ \font_helpers_set_fontstyle_of_fontclass
+ \fi}
+
+\def\font_helpers_set_fontstyle_of_fontclass % will be overloaded later
+ {\let\fontstyle\s!rm}
+
+\protected\def\font_helpers_set_font_set_font_option_body#method#body#message%
+ {\normalizebodyfontsize\normalizedsetfont{#body}% redundant for some calls
+ \ifcsname\??fontbodyknown\normalizedsetfont\endcsname \else
+ \font_helpers_define_unknown_font\normalizedsetfont
+ \fi
+ \ifcsname\??fontbodyknown\normalizedsetfont\endcsname
+ \localbodyfontsize\normalizedsetfont
+ \let\normalizedbodyfontsize\normalizedsetfont
+ \else
+ \showmessage\m!fonts4{#message}%
+ %\font_helpers_set_font_set_font_option_body_fallbacks{#method}{#body}%
+ \fi}
+
+% we need to check the fontclass
+
+\permanent\def\registerfontclass#class%
+ {\letgvalue{\??fontclassyes#class}\v!yes} % global ?
+
+\permanent\def\setcurrentfontclass#class%
+ {\ifcsname\??fontclassyes#class\endcsname
+ \edef\fontclass{#class}%
+ \orelse\ifcsname\??fontclassnop#class\endcsname
+ % already tried
+ \else % too messy: \ifcase\currentgrouplevel % (unpredictable)
+ \fonts_helpers_try_currentfontclass{#class}%
+ \fi}
+
+\ifdefined\fonts_helpers_try_currentfontclass \else
+
+ \protected\def\fonts_helpers_try_currentfontclass#typeface%
+ {\letcsname\??fontclassnop#typeface\endcsname\empty}
+
+\fi
+
+% \let\defaultfontstyle \s!rm
+% \let\defaultfontalternative\s!tf
+% \let\defaultfontsize \empty
+% \let\defaultfontface \!!zerocount
+
+%D So far for synchronisation. (We can inline the following macros.)
+
+\permanent\protected\def\setcurrentfont#body#style#alternative#size% not used
+ {\edef\fontbody {#body}%
+ \edef\fontstyle {#style}%
+ \edef\fontalternative{#alternative}%
+ \edef\fontsize {#size}%
+ \font_helpers_check_big_math_synchronization
+ \font_helpers_synchronize_font}
+
+\permanent\protected\def\setcurrentfontbody#body% % not used
+ {\edef\fontbody{#body}%
+ \font_helpers_synchronize_font}
+
+% For Taco: optional fall backs:
+
+\ifdefined\font_typescripts_inherit_check \else
+ \let\font_typescripts_inherit_check\gobbleoneargument % implemented in type-ini
+\fi
+
+\protected\def\font_helpers_set_current_font_style#style%
+ {\edef\fontstyle{#style}%
+ \font_typescripts_inherit_check\fontstyle
+ \ifmmode\mr\fi % otherwise \rm not downward compatible ... not adapted yet
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_xsize_alternative#xsize#alternative%
+ {\edef\fontface{#xsize}%
+ \edef\fontalternative{#alternative}%
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_font_alternative#alternative%
+ {\edef\fontalternative{#alternative}%
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_font_size#size%
+ {\edef\fontsize{#size}%
+ \font_helpers_check_big_math_synchronization % double? better in everymath?
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_font_style_alternative#style#alternative% \rmsl
+ {\edef\fontstyle {#style}%
+ \edef\fontalternative{#alternative}%
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_font_style_size#style#size% \rma
+ {\edef\fontstyle{#style}%
+ \edef\fontsize {#size}%
+ \font_helpers_check_big_math_synchronization % double? better in everymath?
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_font_alternative_size#alternative#size% \sla
+ {\edef\fontalternative{#alternative}%
+ \edef\fontsize {#size}%
+ \font_helpers_check_big_math_synchronization % double? better in everymath?
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_set_current_font_style_alternative_size#style#alternative#size% \rmsla
+ {\edef\fontstyle {#style}%
+ \edef\fontalternative{#alternative}%
+ \edef\fontsize {#size}%
+ \font_helpers_check_big_math_synchronization % double? better in everymath?
+ \font_helpers_synchronize_font}
+
+\protected\def\font_helpers_synchronize_font % we can have dups i.e. no need to let fontstrategy
+ {\ifempty\fontclass
+ \applyfontstrategies
+ \else
+ \applyfontclassstrategies
+ \fi
+ \setfalse\c_font_auto_size
+ \ifskipfontcharacteristics
+ \setfontcharacteristics
+ \the\everyfontswitch
+ \fi}
+
+%D This is the resolver for special cases (sizes) and in practice it is not called
+%D that often so further optimization makes no sense.
+
+\def\font_helpers_check_strategy_class_a % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\fontalternative-\fontsize-\fontface\endcsname
+ \setfalse\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_class_b
+ \fi}
+
+\def\font_helpers_check_strategy_class_b % --- --- --- def % pt tt bf
+ {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\fontalternative-\defaultfontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_class_c
+ \fi}
+
+\def\font_helpers_check_strategy_class_c % --- --- def --- % pt tt tf a
+ {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\defaultfontalternative-\fontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_class_d
+ \fi}
+
+\def\font_helpers_check_strategy_class_d % --- --- def def % pt tt tf
+ {\ifcsname\??fontinstanceready\fontclass-\fontbody-\fontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_class_e
+ \fi}
+
+\def\font_helpers_check_strategy_class_e % --- def def def % pt rm tf
+ {\ifcsname\??fontinstanceready\fontclass-\fontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
+ \setfalse\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_class_f
+ \fi}
+
+\def\font_helpers_check_strategy_class_f % def def def def % rm tf
+ {\ifcsname\??fontinstanceready\fontclass-\defaultfontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_a
+ \fi}
+
+% no class
+
+\def\font_helpers_check_strategy_a % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\fontalternative-\fontsize-\fontface\endcsname
+ \setfalse\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_b
+ \fi}
+
+\def\font_helpers_check_strategy_b % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\fontalternative-\defaultfontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_c
+ \fi}
+
+\def\font_helpers_check_strategy_c % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\defaultfontalternative-\fontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_d
+ \fi}
+
+\def\font_helpers_check_strategy_d % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\fontbody-\fontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_e
+ \fi}
+
+\def\font_helpers_check_strategy_e % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\fontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
+ \setfalse\c_font_auto_size
+ \lastnamedcs
+ \else
+ \expandafter\font_helpers_check_strategy_f
+ \fi}
+
+\def\font_helpers_check_strategy_f % --- --- --- --- % pt tt bf a
+ {\ifcsname\??fontinstanceready\defaultfontbody-\defaultfontstyle-\defaultfontalternative-\defaultfontsize-\fontface\endcsname
+ \settrue\c_font_auto_size
+ \lastnamedcs
+ \fi}
+
+\permanent\let\applyfontstrategies \font_helpers_check_strategy_a
+\permanent\let\applyfontclassstrategies\font_helpers_check_strategy_class_a
+
+%D Let's synchronize:
+
+\newconditional\c_font_synchronize \settrue\c_font_synchronize
+
+\prependtoks
+ \ifconditional\c_font_synchronize
+ \font_helpers_synchronize_math
+ \font_helpers_synchronize_font % problem: syncs last font
+ \fi
+\to \everybodyfont
+
+%D Setting the normal sizes as well as the x and xx smaller sizes is accomplished by
+%D the next set of macros. When in math mode, the commands \type {\tx} and \type
+%D {\txx} are just a switch to the script and double script styles, but in text mode
+%D the values defined by the bodyfontenvironment are used. Here we also set \type
+%D {\currentxfontsize}.
+
+\def\font_helpers_set_current_font_xxx_alternative#alternative#xsize#scriptstyle%
+ {\ifmmode
+ #scriptstyle%
+ \else
+ \font_helpers_set_current_xsize_alternative{#xsize}{#alternative}%
+ \fi}
+
+\def\font_helpers_reset_x_fontsize
+ {\ifcase\currentxfontsize\else
+ \currentxfontsize\zerocount
+ % also \sx and \sxx ?
+ \enforced\let\tx \normaltx
+ \enforced\let\txx\normaltxx
+ \fi}
+
+\let\font_helpers_check_nested_x_fontsize\relax
+
+\def\font_helpers_set_current_font_x_alternative#alternative%
+ {\font_helpers_check_nested_x_fontsize
+ \font_helpers_set_current_font_xxx_alternative{#alternative}{4}\scriptstyle
+ \currentxfontsize\plusone
+ \enforced\let\tx\txx}
+
+\def\font_helpers_set_current_font_xx_alternative#alternative%
+ {\font_helpers_check_nested_x_fontsize
+ \font_helpers_set_current_font_xxx_alternative{#alternative}{5}\scriptscriptstyle
+ \currentxfontsize\plustwo
+ \enforced\let\tx\empty
+ \enforced\let\txx\empty}
+
+%D This alterative is not really needed, but for old time's sake we keep it there.
+%D We can speed it up when needed.
+
+\def\font_helpers_set_current_font_x_style_alternative #alternative{\csname#alternative\endcsname\tx}
+\def\font_helpers_set_current_font_xx_style_alternative#alternative{\csname#alternative\endcsname\txx}
+
+%D These macros also show us that when we call for \type {\tx}, this macro is
+%D redefined to be \type {\txx}. Therefore calls like:
+%D
+%D \startbuffer
+%D {small \tx is \tx beautiful}
+%D {small \tx is \txx beautiful}
+%D {small \txx is \tx beautiful}
+%D {small \txx is \txx beautiful}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D result in:
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+%D
+%D Setting the main size involves the style list and therefore takes a bit more
+%D time. Keep in mind that the fontsize is represented by a character or empty.
+
+\installcorenamespace{fontscalex}
+\installcorenamespace{fontscalexx}
+
+\newconditional\c_font_inherit_scale
+
+\def\font_scale_inherit#1%
+ {\begingroup
+ \scratchcounterone\fontid\font\relax
+ \currentxfontsize\plusone
+ \normalexpanded{\definedfont[\clf_specifiedfont\scratchcounterone\font_currentfontscale\relax]}%
+ \scratchcountertwo\fontid\font\relax
+ \currentxfontsize\plustwo
+ \normalexpanded{\definedfont[\clf_specifiedfont\scratchcounterone\font_currentfontscale\relax]}%
+ \scratchcounterthree\fontid\font\relax
+ % parent -> x -> xx
+ % parent -> xx
+ %
+ % this can become \integerdef
+ %
+ \global\expandafter\chardef\csname\??fontscalex \number\scratchcounterone\endcsname\scratchcountertwo
+ \global\expandafter\chardef\csname\??fontscalexx\number\scratchcounterone\endcsname\scratchcounterthree
+ \global\expandafter\chardef\csname\??fontscalex \number\scratchcountertwo\endcsname\scratchcounterthree
+ \global\expandafter\chardef\csname\??fontscalexx\number\scratchcountertwo\endcsname\scratchcounterthree
+ \endgroup
+ \setfontid\csname#1\number\fontid\font\endcsname}
+
+\def\font_scale_inherit_x
+ {\ifcsname\??fontscalex\number\fontid\font\endcsname
+ \setfontid\lastnamedcs
+ \else
+ \font_scale_inherit\??fontscalex
+ \fi
+ \ifskipfontcharacteristics
+ \setfontcharacteristics
+ \the\everyfontswitch
+ \fi}
+
+\def\font_scale_inherit_xx
+ {\ifcsname\??fontscalexx\number\fontid\font\endcsname
+ \setfontid\lastnamedcs
+ \else
+ \font_scale_inherit\??fontscalexx
+ \fi
+ \ifskipfontcharacteristics
+ \setfontcharacteristics
+ \the\everyfontswitch
+ \fi}
+
+\def\font_scale_defined_x
+ {\let\fontface\!!plusfour
+ \let\fontalternative\fontalternative
+ \font_helpers_synchronize_font}
+
+\def\font_scale_defined_xx
+ {\let\fontface\!!plusfive
+ \let\fontalternative\fontalternative
+ \font_helpers_synchronize_font}
+
+% to freeze or not ...
+
+\permanent\protected\def\tx
+ {\currentxfontsize\plusone
+ \ifmmode
+ \scriptstyle
+ \orelse\ifconditional\c_font_inherit_scale
+ \font_scale_inherit_x
+ \else
+ \font_scale_defined_x
+ \fi
+ \enforced\let\tx\txx}
+
+\permanent\protected\def\txx
+ {\currentxfontsize\plustwo
+ \ifmmode
+ \scriptscriptstyle
+ \orelse\ifconditional\c_font_inherit_scale
+ \font_scale_inherit_xx
+ \else
+ \font_scale_defined_xx
+ \fi
+ \enforced\let\tx \empty
+ \enforced\let\txx\empty}
+
+\permanent\protected\def\sx
+ {\currentxfontsize\plusone
+ \ifmmode
+ \scriptstyle
+ \else
+ \font_scale_inherit_x
+ \fi
+ \enforced\let\tx\txx
+ \enforced\let\sx\sxx}
+
+\permanent\protected\def\sxx
+ {\currentxfontsize\plustwo
+ \ifmmode
+ \scriptscriptstyle
+ \else
+ \font_scale_inherit_xx
+ \fi
+ \enforced\let\tx \empty
+ \enforced\let\txx\empty
+ \enforced\let\sx \empty
+ \enforced\let\sxx\empty}
+
+\permanent\protected\def\useinheritxsizes{\settrue \c_font_inherit_scale} % not yet public, playground for WS and me
+\permanent\protected\def\usedefinedxsizes{\setfalse\c_font_inherit_scale} % not yet public, playground for WS and me
+
+\aliased\let\normaltx \tx
+\aliased\let\normaltxx\txx
+
+\aliased\let\normalsx \sx
+\aliased\let\normalsxx\sxx
+
+%D When asking for a complete font switch, for instance from 10 to 12~points, the
+%D next macro does the job. First we normalize the size, next we define the current
+%D range of text, script and scriptscript sizes, then we set the text fonts and the
+%D math families and finally we activate the default typeface and also set the font
+%D specific parameters assigned to \type {\everybodyfont}.
+
+\permanent\protected\def\textface {\currentbodyfontdimension\s!text }
+\permanent\protected\def\scriptface {\currentbodyfontdimension\s!script }
+\permanent\protected\def\scriptscriptface{\currentbodyfontdimension\s!scriptscript}
+\permanent\protected\def\xtextface {\currentbodyfontdimension\s!x }
+\permanent\protected\def\xxtextface {\currentbodyfontdimension\s!xx }
+
+\installcorenamespace{fontbodyfaces}
+
+\protected\def\font_basics_complete_switch#size%
+ {\bodyfontsize#size\relax
+ \normalizebodyfontsize\normalizedbodyfontsize\bodyfontsize
+ \expandafter\let\expandafter\font_basics_set_faces\csname\??fontbodyfaces\fontbody\endcsname
+ \ifrelax\font_basics_set_faces
+ \font_basics_set_faces_preset
+ \fi
+ \font_basics_set_faces}
+
+\def\font_basics_set_faces_preset
+ {\edef\font_basics_set_faces{% 0.2 sec on 10K \tfa
+ \enforced\permanent\protected\def\textface {\currentbodyfontdimension\s!text }%
+ \enforced\permanent\protected\def\scriptface {\currentbodyfontdimension\s!script }%
+ \enforced\permanent\protected\def\scriptscriptface{\currentbodyfontdimension\s!scriptscript}%
+ \enforced\permanent\protected\def\xtextface {\currentbodyfontdimension\s!x }%
+ \enforced\permanent\protected\def\xxtextface {\currentbodyfontdimension\s!xx }%
+ }%
+ \gletcsname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces}
+
+\permanent\def\currentbodyfontdimension#parameter% there can be factors here
+ {\the\dimexpr
+ \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname
+ \lastnamedcs
+ \dimexpr\normalizedbodyfontsize\relax
+ \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname
+ \lastnamedcs
+ \else
+ \csname\??fontenvironments\s!default#parameter\endcsname
+ \dimexpr\normalizedbodyfontsize\relax
+ \fi
+ \relax}
+
+%D \macros
+%D {setupbodyfont,switchtobodyfont}
+%D
+%D The next two macros are user ones. With \type {\setupbodyfont} one can set the
+%D document bodyfont size, font family, style and/or options defined in files, for
+%D example:
+%D
+%D \starttyping
+%D \setupbodyfont[modern,12pt,roman]
+%D \stoptyping
+%D
+%D This command affects the document as a whole: text, headers and footers. The
+%D second macro however affects only the text:
+%D
+%D \starttyping
+%D \switchtobodyfont[10pt]
+%D \stoptyping
+%D
+%D So we've got:
+%D
+%D \showsetup{setupbodyfont}
+%D \showsetup{switchtobodyfont}
+%D
+%D Both macros look alike. The second one also has to take all kind of keywords into
+%D account.
+
+\ifdefined\saveinterlinespace \else \let\saveinterlinespace \relax \fi
+\ifdefined\restoreinterlinespace \else \let\restoreinterlinespace\relax \fi
+
+% \newtoks \everysetupbodyfont
+% \newtoks \everyswitchtobodyfont
+
+\permanent\protected\def\setupbodyfont
+ {\doifelsenextoptionalcs\font_basics_setupbodyfont_yes\font_basics_setupbodyfont_nop}
+
+\def\font_basics_setupbodyfont_nop
+ {\restoreglobalbodyfont
+ \saveinterlinespace}
+
+\def\font_basics_setupbodyfont_yes[#specification]%
+ {\doifsomething{#specification}
+ {\font_helpers_set_font\plusone{#specification}%
+ \globalbodyfontsize\localbodyfontsize
+ \normalizebodyfontsize\normalizedglobalbodyfontsize\globalbodyfontsize
+ \let\globalfontstyle\fontstyle
+ \ifproductionrun
+ \the\everybodyfont
+ \the\everyglobalbodyfont
+ \saveinterlinespace
+ \fi
+ \the\everysetupbodyfont}}
+
+\protected\def\font_basics_switchtobodyfont#specification%
+ {\edef\m_font_step{\font_bodyfontvariable{#specification}}%
+ \ifempty\m_font_step
+ \font_helpers_set_font\zerocount{#specification}%
+ \else
+ \font_helpers_switch_bodyfont_step % so we have a fast [small] switch
+ \fi
+ \the\everybodyfont
+ \the\everyswitchtobodyfont}
+
+\permanent\protected\def\switchtobodyfont[#specification]% could become an ifx
+ {\doifsomething{#specification}{\font_basics_switchtobodyfont{#specification}}}
+
+\permanent\protected\def\usebodyfontparameter#1%
+ {\edef\m_font_bodyfont_asked{#1\c!bodyfont}%
+ \ifempty\m_font_bodyfont_asked\else
+ \font_basics_switchtobodyfont\m_font_bodyfont_asked
+ \fi}
+
+\def\font_helpers_switch_bodyfont_step
+ {\font_basics_switch_points\m_font_step
+ \font_basics_switch_style \fontstyle}
+
+%D The following alternative is meant for math||to||text switching and will be
+%D optimized.
+
+\permanent\protected\def\fastswitchtobodyfont#name%
+ {\ifcsname\??fontenvironments\normalizedbodyfontsize#name\endcsname
+ \edef\p_bodyfont{\lastnamedcs}%
+ \ifcsname\??fontbodyknown\p_bodyfont\endcsname
+ \font_basics_complete_switch\p_bodyfont
+ \localbodyfontsize\p_bodyfont\relax
+ \fi
+ \fi
+ \csname\??fontstyle\fontstyle\endcsname
+ \the\everybodyfont}
+
+%D \starttyping
+%D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$
+%D \stoptyping
+
+%D \macros
+%D {usebodyfont}
+%D
+%D This looks nicer then a switch in the preamble
+%D
+%D \starttyping
+%D \usebodyfont[pagella,10pt]
+%D \usebodyfont[termes,10pt]
+%D \usebodyfont[dejavu,10pt]
+%D
+%D \setupbodyfont[dejavu]
+%D
+%D \starttext
+%D test
+%D \stoptext
+%D \stoptyping
+
+\permanent\protected\def\usebodyfont[#1]%
+ {\ifempty\fontclass
+ \setupbodyfont[#1]%
+ \else
+ \switchtobodyfont[#1]%
+ \fullrestoreglobalbodyfont
+ \fi}
+
+\fetchmodulecommand \showbodyfontstate \f!font_run
+
+%D Handy for manuals:
+
+%D The \type {\tochar} commmand takes a specification:
+%D
+%D \starttabulate[|l|l|l|]
+%D \NC e \NC entity \NC e:eacute \NC \NR
+%D \NC x \NC hexadecimal unicode \NC x:013D \NC \NR
+%D \NC d \NC decimal unicode \NC d:123 \NC \NR
+%D \NC s \NC hexadecimal index (slot) \NC s:210D \NC \NR
+%D \NC i \NC decimal index \NC i:456 \NC \NR
+%D \NC n \NC name \NC n:eight \NC \NR
+%D \NC c \NC name \NC c:x \NC \NR
+%D \NC u \NC unicode descriptions \NC u:dog \NC \NR
+%D \NC a \NC all (also descriptions) \NC a:rewind \NC \NR
+%D \stoptabulate
+%D
+%D This is an expandable command!
+
+\permanent\protected\def\fontchar #character{\clf_fontchar{#character}}
+\permanent\protected\def\fontcharbyindex #index{\clf_fontcharbyindex#index\relax}
+\permanent \def\tochar #specifications{\clf_tochar{#specifications}} % expanded (also used in edef)
+
+%D The next auxilliary macro is an alternative to \type {\fontname}.
+
+\permanent\def\purefontname#font{\clf_purefontname{\fontname#font}}
+
+%D \macros
+%D {switchstyleonly}
+%D
+%D For switching a style but keeping the alternative, there
+%D is:
+%D
+%D \starttyping
+%D {\bf text \switchstyleonly\ss text}
+%D {\bf text \switchstyleonly[ss]text}
+%D {\sl text \switchstyleonly[sansserif]text}
+%D \stoptyping
+
+\permanent\protected\def\switchstyleonly
+ {\doifelsenextoptionalcs\font_basics_switch_style_only_opt\font_basics_switch_style_only_arg}
+
+\def\font_basics_switch_style_only_arg#name% stupid version
+ {\font_helpers_set_current_font_style{\csname\??fontshortstyle\checkedstrippedcsname#name\endcsname}%
+ \the\everybodyfont} % needed ?
+
+\def\font_basics_switch_style_only_opt[#name]% todo : check
+ {\font_helpers_set_current_font_style{\csname\??fontshortstyle#name\endcsname}%
+ \the\everybodyfont} % needed ?
+
+%D \macros
+%D {definebodyfontswitch}
+%D
+%D \PLAIN\ \TEX\ defines some macro's like \type {\tenpoint} to switch to a specific
+%D bodyfontsize. Just for the sake of compatibility we can define them like:
+%D
+%D \starttyping
+%D \definebodyfontswitch [twelvepoint] [12pt]
+%D \stoptyping
+%D
+%D We don't support language specific synonyms here.
+
+\permanent\tolerant\protected\def\definebodyfontswitch[#command]#spacer[#specification]% no longer a commalist (not useful)
+ {\frozen\protected\defcsname#command\endcsname{\switchtobodyfont[#specification]}}%
+
+%D \macros
+%D {setsmallbodyfont,setmainbodyfont,setbigbodyfont}
+%D
+%D When we're typesetting at for instance 10pt, we can call for the \type {small} as
+%D well as the \type {big} alternative, related to this main size, using \type
+%D {\switchtobodyfont[small]}. The three alternatives can be activated by the next
+%D three system calls and are defined by the bodyfontenvironment.
+
+\newmacro\m_font_step
+
+\def\font_helpers_set_bodyfont_step#step%
+ {\edef\m_font_step{\font_bodyfontvariable{#step}}% not always \cs
+ \font_basics_switch_points\m_font_step
+ \font_basics_switch_style \fontstyle}
+
+\permanent\protected\def\setsmallbodyfont{\font_helpers_set_bodyfont_step\v!small\the\everybodyfont}
+\permanent\protected\def\setbigbodyfont {\font_helpers_set_bodyfont_step\v!big \the\everybodyfont}
+
+\permanent\protected\def\setmainbodyfont
+ {\font_basics_switch_points\normalizedbodyfontsize
+ \font_basics_switch_style\fontstyle
+ \the\everybodyfont
+ \the\everyglobalbodyfont
+ \saveinterlinespace}
+
+%D \macros
+%D {restoreglobalbodyfont}
+%D
+%D Users can set whatever font available while typesetting text. Pagenumbers,
+%D footers, headers etc. however must be typeset in the main bodyfont and style of
+%D the document. Returning to the global state can be done with the next macro:
+%D
+%D This macro has to be called when entering the pagebody handling routine as well
+%D as the footnote insert routine. Users can access this feature |<|for instance
+%D when one wants to typeset tables and alike in the main bodyfont and style while
+%D the running text is temporary set to a smaller one|>| by saying \type
+%D {\switchtobodyfont [global]}.
+
+\mutable\let\globalfontstyle\s!rm
+
+\permanent\protected\def\fullrestoreglobalbodyfont
+ {\let\fontsize\defaultfontsize
+ \let\fontbody\defaultfontbody
+ \let\fontface\defaultfontface
+ \currentxfontsize\zerocount
+ \let\fontclass\globalfontclass
+ \font_basics_switch_points\normalizedglobalbodyfontsize
+ \font_basics_switch_style\globalfontstyle
+ \redoconvertfont % just in case a pagebreak occurs
+ \tf
+ \the\everybodyfont
+ \the\everyglobalbodyfont
+ \saveinterlinespace}
+
+\permanent\protected\def\partialrestoreglobalbodyfont
+ {\let\fontsize\defaultfontsize
+ \let\fontbody\defaultfontbody
+ \let\fontface\defaultfontface
+ \currentxfontsize\zerocount
+ \redoconvertfont
+ \tf
+ \the\everybodyfont % indeed needed
+ \the\everyglobalbodyfont % indeed needed
+ \saveinterlinespace}
+
+\permanent\protected\def\restoreglobalbodyfont % ook style etc
+ {\ifx\fontclass\globalfontclass
+ \ifx\fontstyle\globalfontstyle
+ \ifx\normalizedbodyfontsize\normalizedglobalbodyfontsize
+ \partialrestoreglobalbodyfont
+ \else
+ \fullrestoreglobalbodyfont
+ \fi
+ \else
+ \fullrestoreglobalbodyfont
+ \fi
+ \else
+ \fullrestoreglobalbodyfont
+ \fi}
+
+% in case of troubles: \let\restorebodyfont\fullrestoreglobalbodyfont
+
+%D Here are some fast variants that can be used in cases where no font system is
+%D needed and where fonts are frozen:
+%D
+%D \starttyping
+%D \definefont [TestA][Serif at 10pt]
+%D \predefinefont[TestB][Serif at 20pt]
+%D
+%D \testfeatureonce{1000}{{\TestA}} % .312
+%D \testfeatureonce{1000}{{\TestB}} % < .016
+%D \testfeatureonce{1000}{{\definedfont[Serif at 30pt]}} % .312
+%D \testfeatureonce{1000}{{\predefinedfont[Serif at 40pt]}} % < .016
+%D \stoptyping
+
+\installcorenamespace{predefinedfont}
+
+\permanent\protected\def\predefinefont[#1]#*[#2]% global !
+ {\protected\gdefcsname#1\endcsname{\font_basics_predefine{#1}{#2}}}
+
+\permanent\protected\def\predefinedfont[#1]% global !
+ {\ifcsname\??predefinedfont#1\endcsname
+ \lastnamedcs
+ \else
+ \font_basics_predefined{#1}%
+ \fi}
+
+\protected\def\font_basics_predefine#1#2%
+ {\definedfont[#2]%
+ \gletcsname#1\expandafter\endcsname\csname\v_font_identifier_basic\endcsname}
+
+\protected\def\font_basics_predefined#1%
+ {\font_basics_predefine{\??predefinedfont#1}{#1}}
+
+%D Handy helper:
+
+\permanent\protected\def\savedefinedfont[#1]% hm, how about scales
+ {\bgroup
+ \definedfont[#1]%
+ \xdef\saveddefinedfontid {\number\fontid\font}%
+ \xdef\saveddefinedfontname{\fontname\font}%
+ \egroup}
+
+\mutable\def\saveddefinedfontid {\number\fontid\font}
+\mutable\def\saveddefinedfontname{\fontname\font}
+
+%D Ugly helper:
+
+\permanent\protected\def\saverunningstyleandcolor
+ {\enforced\permanent\protected\edef\restorerunningstyleandcolor
+ {\setfontid \number\fontid\font
+ \c_attr_colormodel \the\c_attr_colormodel
+ \c_attr_color \the\c_attr_color
+ \c_attr_transparency\the\c_attr_transparency
+ \relax}}
+
+\aliased\let\restorerunningstyleandcolor\relax
+
+%D Handy for defining additional glyphs:
+
+% todo: public implementors
+
+\aliased\let\getprivateglyphslot\clf_getprivateglyphslot % kind of private macro
+
+\aliased\let\getprivatechar \clf_getprivatechar % gives back a utf !
+\aliased\let\getprivatemathchar \clf_getprivatemathchar % gives back a utf !
+\aliased\let\getprivateslot \clf_getprivateslot % companion to fonts.helpers.addprivate
+
+% \protected\def\getprivatemathchar#1%
+% {\begingroup\the\textfont\zerocount\getprivatechar{#1}\endgroup}
+
+\permanent\protected\def\privatechar % the text variant gets expanded to utf
+ {\ifmmode
+ \expandafter\getprivatemathchar
+ \else
+ \expandafter\getprivatechar
+ \fi}
+
+%D Some fonts can have color specifiers:
+%D
+%D \starttyping
+%D \definefontfeature[seguiemj-cl][default][colr=yes,ccmp=yes,dist=yes]
+%D \definefontsynonym[emoji][seguiemj*seguiemj-cl]
+%D
+%D \definecolor[emoji-red] [r=.4]
+%D \definecolor[emoji-gray][s=1,t=.5,a=1]
+%D
+%D %definefontcolorpalette [emoji-r] [emoji-red,emoji-gray,textcolor] % bad
+%D \definefontcolorpalette [emoji-r] [emoji-red,emoji-gray] % okay
+%D
+%D \definefontfeature[seguiemj-r][ccmp=yes,dist=yes,colr=emoji-r]
+%D
+%D \definefont[MyEmojiR][seguiemj*seguiemj-r @ 100pt]
+%D
+%D \startTEXpage[offset=10pt]
+%D \MyEmojiR\resolvedemoji{triangular ruler}
+%D \stopTEXpage
+%D \stoptyping
+
+\permanent\tolerant\protected\def\definefontcolorpalette[#1]#*[#2]%
+ {\clf_definefontcolorpalette{#1}{#2}}
+
+%D \macros
+%D {addfontpath}
+%D
+%D A way to add a path at runtime (no need to generate database):
+
+\permanent\protected\def\usefontpath[#1]%
+ {\clf_addfontpath{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-lib.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-lib.mklx
new file mode 100644
index 00000000000..72c2d4ba9f5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-lib.mklx
@@ -0,0 +1,156 @@
+%D \module
+%D [ file=font-lib,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Libraries,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Libraries}
+
+\unprotect
+
+\registerctxluafile{font-ini}{autosuffix}
+\registerctxluafile{font-log}{}
+\registerctxluafile{font-con}{autosuffix} % kind of early
+%registerctxluafile{font-cft}{}
+\registerctxluafile{font-enc}{}
+\registerctxluafile{font-fmp}{autosuffix}
+\registerctxluafile{font-agl}{} % if needed we can comment this and delay loading
+\registerctxluafile{font-cid}{} % cid maps
+\registerctxluafile{font-map}{optimize}
+
+% helpers
+
+\registerctxluafile{font-otr}{optimize} % opentype fontloader
+\registerctxluafile{font-web}{} % opentype fontloader
+\registerctxluafile{font-cff}{optimize} % quadratic outlines
+\registerctxluafile{font-ttf}{optimize} % cubic outlines
+\registerctxluafile{font-dsp}{optimize} % ... for this one
+\registerctxluafile{font-hsh}{} % hashes used by context
+\registerctxluafile{font-vir}{}
+\registerctxluafile{font-vfc}{autosuffix}
+\registerctxluafile{font-prv}{} % needs hashes
+\registerctxluafile{font-nod}{optimize}
+\registerctxluafile{font-oti}{} % otf initialization
+\registerctxluafile{font-ott}{} % otf tables (first)
+\registerctxluafile{font-otl}{}
+\registerctxluafile{font-oto}{}
+\registerctxluafile{font-otj}{autosuffix,optimize}
+\registerctxluafile{font-oup}{}
+\registerctxluafile{font-ota}{autosuffix}
+% \registerctxluafile{font-ots-pre-scale}{autosuffix,optimize}
+\registerctxluafile{font-ots}{autosuffix,optimize}
+\registerctxluafile{font-otd}{optimize}
+\registerctxluafile{font-otc}{}
+\registerctxluafile{font-oth}{}
+\registerctxluafile{font-osd}{}
+%registerctxluafile{font-osm}{}
+\registerctxluafile{font-ogr}{autosuffix}
+
+% we use otf code for type one
+
+\registerctxluafile{font-onr}{optimize}
+\registerctxluafile{font-one}{optimize}
+\registerctxluafile{font-afk}{}
+
+% tfm
+
+\registerctxluafile{font-tpk}{optimize}
+\registerctxluafile{font-tfm}{}
+
+% name database
+
+\registerctxluafile{font-syn}{}
+\registerctxluafile{font-trt}{}
+
+% shapes
+
+\registerctxluafile{font-shp}{}
+
+% so far
+
+\registerctxluafile{font-pat}{} % patchers
+
+\registerctxluafile{node-fnt}{autosuffix} % here
+
+\registerctxluafile{font-mps}{autosuffix} % outline fun
+
+\registerctxluafile{font-lua}{}
+
+\registerctxluafile{font-enh}{autosuffix}
+
+\registerctxluafile{good-ini}{}
+\registerctxluafile{good-gen}{}
+\registerctxluafile{good-ctx}{}
+\registerctxluafile{good-mth}{autosuffix}
+
+\registerctxluafile{font-def}{autosuffix}
+\registerctxluafile{font-ctx}{autosuffix} % after def as it overloads
+
+% extensions, order matters
+
+\registerctxluafile{font-imp-ligatures}{}
+\registerctxluafile{font-imp-tex}{}
+\registerctxluafile{font-imp-reorder}{}
+\registerctxluafile{font-imp-properties}{}
+\registerctxluafile{font-imp-unicode}{}
+\registerctxluafile{font-imp-math}{autosuffix}
+\registerctxluafile{font-imp-notused}{}
+\registerctxluafile{font-imp-effects}{}
+\registerctxluafile{font-imp-quality}{}
+\registerctxluafile{font-imp-italics}{}
+\registerctxluafile{font-imp-dimensions}{}
+\registerctxluafile{font-imp-spacekerns}{}
+\registerctxluafile{font-imp-tweaks}{}
+\registerctxluafile{font-imp-combining}{}
+
+\doifelsefileexists{font-imp-scripts.lua} {
+ \registerctxluafile{font-imp-scripts}{}
+} {
+ % not yet, lmtx feature
+}
+
+\registerctxluafile{font-imp-tracing}{autosuffix} % comes last!
+
+\registerctxluafile{font-fbk}{autosuffix}
+
+\registerctxluafile{font-aux}{}
+
+\registerctxluafile{font-lig}{} % only for experiments so try to avoid it
+
+%D Some low level helpers
+%D
+%D \starttyping
+%D \def\TestLookup#specification%
+%D {\dolookupfontbyspec{#specification}
+%D pattern: #specification, found: \dolookupnoffound
+%D \blank
+%D \dorecurse {\dolookupnoffound} {%
+%D \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad
+%D }%
+%D \blank}
+%D
+%D \TestLookup{familyname=helveticaneue}
+%D \TestLookup{familyname=helveticaneue,weight=bold}
+%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic}
+%D \stoptyping
+
+%D We can also move the lookups to the fonts.namespace (of commands) one can also
+%D directly use the clf calls when speed is needed.
+
+% todo: public implementors:
+
+\permanent \def\dolookupfontbyspec #1{\clf_fontlookupinitialize{#1}}
+\permanent \def\dolookupnoffound {\clf_fontlookupnoffound}
+\permanent \def\dolookupgetkeyofindex#1#2{\clf_fontlookupgetkeyofindex{#1}\numexpr#2\relax}
+\permanent \def\dolookupgetkey #1{\clf_fontlookupgetkey{#1}}
+\permanent \def\cleanfontname #1{\clf_cleanfontname{#1}}
+\permanent\protected\def\setfontofid #1{\clf_setfontofid\numexpr#1\relax}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-mat.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-mat.mklx
new file mode 100644
index 00000000000..3fc6275a65d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-mat.mklx
@@ -0,0 +1,595 @@
+%D \module
+%D [ file=font-mat,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Math,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Math}
+
+\unprotect
+
+%D Be nice:
+
+\ifdefined\??fontinstanceready \else \installcorenamespace{fontinstanceready} \fi
+\ifdefined\??fontinstancebasic \else \installcorenamespace{fontinstancebasic} \fi
+\ifdefined\??fontinstanceclass \else \installcorenamespace{fontinstanceclass} \fi
+
+%D The order 3 2 1 of size matters: needed for math-fbk relative size storage!
+
+%D \macros
+%D {textonly}
+%D
+%D Traditionally math has a big impact on font definitions, mainly because we need
+%D to define alphabet variants using families and fonts. This means that one can
+%D easily get 10 fonts loaded per math size. In \MKIV\ we use a different approach:
+%D one family which has either a virtual font made of traditional fonts, or an
+%D \OPENTYPE\ font that has it all.
+%D
+%D We currently use only one math family but in the future we might consider using a
+%D second one for bold math. For the moment we keep the \MKII\ method of using a
+%D token register for definitions but we already dropped the text and symbols ones
+%D since they now live in the same family.
+
+\newtoks \t_font_math_strategies
+\newconditional\c_font_synchronize_math_fonts \settrue\c_font_synchronize_math_fonts
+
+\protected\def\font_helpers_synchronize_math % math stuff in mmode
+ {\ifconditional\c_font_synchronize_math_fonts\the\t_font_math_strategies\fi}
+
+\permanent\protected\def\textonly{\setfalse\c_font_synchronize_math_fonts} % document this
+
+%D The main math font definer. We have removed some optimized code simply because we
+%D now always have a fontclass. We could check for fontclass being default or empty
+%D and save a few tests but it does not help us when no math is defined.
+%D
+%D Because we want to keep mr=.. and mb=... settings (read: not break downward
+%D compatibility by enforcing mrlr etc) we need a bit more code that optimal.
+
+% todo: \c_font_fam_mr
+
+\aliased\let\c_font_fam_mr \zerocount % math regular
+\aliased\let\c_font_fam_mr_lr\plusone % math regular l2r
+\aliased\let\c_font_fam_mr_rl\plustwo % math regular r2l
+
+\aliased\let\c_font_fam_mb \plusthree % math bold
+\aliased\let\c_font_fam_mb_lr\plusfour % math bold l2r
+\aliased\let\c_font_fam_mb_rl\plusfive % math bold r2l
+
+\definesystemattribute[mathfamily][public]
+
+\newconditional\c_font_bidirectional_mathstrategy % can be default, not that much overhead: \settrue\c_font_bidirectional_mathstrategy
+\newconditional\c_font_complete_bold_mathstrategy \settrue\c_font_complete_bold_mathstrategy
+
+% \frozen ...
+
+\immutable\def\mathtextsuffix {-text}
+\immutable\def\mathscriptsuffix {-script}
+\immutable\def\mathscriptscriptsuffix{-scriptscript}
+
+%D Beware: truefontname also does a fallback on defaultfontclass so there
+%D can be some interference here, which is why we use a different method
+%D for bold.
+
+\def\font_helpers_set_math_family_a
+ {\ifcsname\??fontinstanceready\fontclass -\fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
+ \lastnamedcs \orelse
+ \ifcsname\??fontinstanceready\fontclass -\fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
+ \lastnamedcs \else
+ \font_helpers_set_math_family_b
+ \fi}
+
+\def\font_helpers_set_math_family_b
+ {\ifcsname\??fontinstanceready\defaultfontclass-\fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
+ \lastnamedcs \orelse
+ \ifcsname\??fontinstanceready\defaultfontclass-\fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
+ \lastnamedcs \else
+ \font_helpers_set_math_family_c
+ \fi}
+
+\def\font_helpers_set_math_family_c
+ {\ifcsname\??fontinstanceready \fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
+ \lastnamedcs \orelse
+ \ifcsname\??fontinstanceready \fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
+ \lastnamedcs \else
+ \settrue \c_font_auto_size
+ \fi}
+
+%def\mathsizesuffix{\ifcase\fontface\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi}
+\mutable\let\mathsizesuffix\empty
+
+\mutable\let\fontfamily\relax % for now public but it is a helper
+
+\def\font_helpers_set_math_family_indeed_normal#mrtag#family% \fontface etc are also used later on
+ {\let\savedfontbody\fontbody
+ \let\fontfamily#family%
+ % the order is important as we depend on known id's when completing fonts
+ % enabling is needed when we have fallbacks which spoils the families
+ \let\mathsizesuffix\mathscriptscriptsuffix\let\fontface\!!plusthree
+ \font_helpers_set_math_family_a\scriptscriptfont#mrtag\font % defines
+ \font_helpers_set_math_family_a\scriptscriptfont#mrtag\font % enables
+ \let\mathsizesuffix\mathscriptsuffix \let\fontface\!!plustwo
+ \font_helpers_set_math_family_a\scriptfont #mrtag\font % defines
+ \font_helpers_set_math_family_a\scriptfont #mrtag\font % enables
+ \let\mathsizesuffix\mathtextsuffix \let\fontface\!!plusone
+ \font_helpers_set_math_family_a\textfont #mrtag\font % defines
+ \font_helpers_set_math_family_a\textfont #mrtag\font % enables
+ \let\mathsizesuffix\empty \let\fontface\!!zerocount
+ \let\fontbody\savedfontbody
+ \setfalse\c_font_auto_size}
+
+\def\font_helpers_set_math_family_set_scales_compact
+ {% these are used when no font setting is there, the settings come before setting the parameters
+ % and are stored with the family
+ \glyphtextscale \plusthousand
+ \glyphscriptscale \numexpr\plusthousand*\dimexpr\scriptface \relax/\dimexpr\textface\relax\relax
+ \glyphscriptscriptscale \numexpr\plusthousand*\dimexpr\scriptscriptface\relax/\dimexpr\textface\relax\relax}
+
+\def\font_helpers_set_math_family_set_scales_normal
+ {\glyphtextscale \plusthousand
+ \glyphscriptscale \plusthousand
+ \glyphscriptscriptscale\plusthousand}
+
+\def\font_helpers_set_math_family_indeed_compact#mrtag#family% \fontface etc are also used later on
+ {\let\savedfontbody\fontbody
+ \let\fontfamily#family%
+ \font_helpers_set_math_family_set_scales_compact
+ % the order is important as we depend on known id's when completing fonts
+ % enabling is needed when we have fallbacks which spoils the families
+ \let\mathsizesuffix\mathtextsuffix \let\fontface\!!plusone
+ \font_helpers_set_math_family_a\textfont #mrtag\font % defines
+ \font_helpers_set_math_family_a\textfont #mrtag\font % enables
+ \scriptfont #mrtag\font % reuses
+ \scriptscriptfont#mrtag\font % reuses
+ \let\mathsizesuffix\empty \let\fontface\!!zerocount
+ \let\fontbody\savedfontbody
+ \setfalse\c_font_auto_size}
+
+\def\font_helpers_set_math_family_indeed
+ {\ifconditional\c_font_compact
+ \expandafter\font_helpers_set_math_family_indeed_compact
+ \else
+ \expandafter\font_helpers_set_math_family_indeed_normal
+ \fi}
+
+\def\font_helpers_set_math_family_bold_indeed_normal#mbfam#familytag#mrfam% \c_font_fam_mb \s!mb \c_font_fam_mr
+ {\let\savedfontclass\defaultfontclass
+ \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one
+ \let\savedfontbody\fontbody
+ \let\fontfamily#familytag%
+ \font_helpers_set_math_family_set_scales_normal
+ \let\mathsizesuffix\mathscriptscriptsuffix\let\fontface\!!plusthree
+ \font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam% defines
+ \font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam% enables
+ \let\mathsizesuffix\mathscriptsuffix \let\fontface\!!plustwo
+ \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam% defines
+ \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam% enables
+ \let\mathsizesuffix\mathtextsuffix \let\fontface\!!plusone
+ \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% defines
+ \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% enables
+ \let\mathsizesuffix\empty \let\fontface\!!zerocount
+ \let\fontbody\savedfontbody
+ \let\defaultfontclass\savedfontclass
+ \setfalse\c_font_auto_size}
+
+\def\font_helpers_set_math_family_bold_indeed_compact#mbfam#familytag#mrfam% \c_font_fam_mb \s!mb \c_font_fam_mr
+ {\let\savedfontclass\defaultfontclass
+ \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one
+ \let\savedfontbody\fontbody
+ \let\fontfamily#familytag%
+ \let\mathsizesuffix\mathtextsuffix \let\fontface\!!plusone
+ \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% defines
+ \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam% enables
+ \scriptfont #mbfam\scriptfont #mrfam% reuses
+ \scriptscriptfont#mbfam\scriptscriptfont#mrfam% reuses
+ \let\mathsizesuffix\empty \let\fontface\!!zerocount
+ \let\fontbody\savedfontbody
+ \let\defaultfontclass\savedfontclass
+ \setfalse\c_font_auto_size}
+
+\def\font_helpers_set_math_family_bold_indeed
+ {\ifconditional\c_font_compact
+ \expandafter\font_helpers_set_math_family_bold_indeed_compact
+ \else
+ \expandafter\font_helpers_set_math_family_bold_indeed_normal
+ \fi}
+
+\def\font_helpers_set_math_family_bold_a#font#mbfam#mrfam%
+ {\ifcsname\??fontinstanceready\fontclass-\fontbody-\s!mm-\fontfamily-\fontsize\endcsname \setfalse\c_font_auto_size
+ \lastnamedcs #font#mbfam\font \orelse
+ \ifcsname\??fontinstanceready\fontclass-\fontbody-\s!mm-\fontfamily \endcsname \settrue \c_font_auto_size
+ \lastnamedcs #font#mbfam\font \else
+ #font#mbfam#font#mrfam%
+ \fi}
+
+% optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0))
+%
+% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know
+% all sizes so we postpone the optimization to the first starttext
+%
+% pitfall: we should reset 'm when a fontclass name is reused
+
+\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions
+
+\def\font_helpers_set_math_family#mrfam#familytag%
+ {\ifconditional\optimizemathfontdefinitions
+ \ifcsname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
+ % \writestatus{fonts}{math: reusing \fontclass\fontbody\s!mm#familytag\fontsize1}%
+ \font_helpers_preset_math_family_indeed#mrfam#familytag%
+ \else
+ % \writestatus{fonts}{math: defining \fontclass\fontbody\s!mm#familytag\fontsize1}%
+ \font_helpers_set_math_family_indeed#mrfam#familytag%
+ \fi
+ \else
+ \font_helpers_set_math_family_indeed#mrfam#familytag%
+ \fi}
+
+\def\font_helpers_set_math_family_bold#mbfam#familytag#mrfam%
+ {\ifconditional\optimizemathfontdefinitions
+ %\ifcsname\??fontinstanceclass\fontclass-\textface-\s!mm-#familytag-\fontsize-1\endcsname
+ \ifcsname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
+ \font_helpers_preset_math_family_indeed#mbfam#familytag%
+ \else
+ \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
+ \fi
+ \else
+ \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
+ \fi}
+
+%D It can happen that we use a bodyfont with no math in which case we have a problem
+%D with setting the global bodyfont size in the page builder. For instance in:
+%D
+%D \starttext
+%D \definetypeface[test][rm][serif][pagella][default]
+%D \setupbodyfont[test]
+%D test
+%D \stoptext
+%D
+%D This is why we need the check. At the cost of some extra checking we gain a
+%D little in restoring global states and, what's more important, we get rid of large
+%D math parameter push/pop in tracingall when not needed.
+
+% \def\font_helpers_preset_math_family_indeed#fam#familytag%
+% {\expandafter\let\expandafter\v_font_math_one\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
+% \ifrelax\v_font_math_one
+% \font_helpers_preset_math_family_warning
+% \orelse\ifnum\fontid\textfont#fam=\fontid\v_font_math_one\else
+% \font_helpers_preset_math_family_indeed_changed#fam#familytag%
+% \fi}
+
+% \def\font_helpers_preset_math_family_warning
+% {\writestatus{fonts}{math: unset for global bodyfont \fontclass\space at \fontbody}}
+
+% \def\font_helpers_preset_math_family_indeed_changed_normal#fam#familytag%
+% {\font_helpers_set_math_family_set_scales_normal
+% \scriptscriptfont#fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-3\endcsname
+% \scriptfont #fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-2\endcsname
+% \textfont #fam\v_font_math_one}
+
+% \def\font_helpers_preset_math_family_indeed_changed_compact#fam#familytag%
+% {\font_helpers_set_math_family_set_scales_compact
+% \scriptscriptfont#fam\v_font_math_one
+% \scriptfont #fam\v_font_math_one
+% \textfont #fam\v_font_math_one}
+
+% \def\font_helpers_preset_math_family_indeed_changed
+% {\ifconditional\c_font_compact
+% \expandafter\font_helpers_preset_math_family_indeed_changed_compact
+% \else
+% \expandafter\font_helpers_preset_math_family_indeed_changed_normal
+% \fi}
+
+\def\font_helpers_preset_math_family_indeed_normal#fam#familytag%
+ {\expandafter\let\expandafter\font_math_last_font\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
+ \font_math_last_font
+ \ifnum\fontid\textfont#fam=\fontid\font\else
+ \font_helpers_preset_math_family_indeed_changed_normal#fam#familytag%
+ \fi}
+
+\def\font_helpers_preset_math_family_indeed_changed_normal#fam#familytag%
+ {\font_helpers_set_math_family_set_scales_normal
+ \csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-3\endcsname\scriptscriptfont#fam\font
+ \csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-2\endcsname\scriptfont #fam\font
+ % \csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname\textfont #fam\font}
+ \font_math_last_font \textfont #fam\font}
+
+\def\font_helpers_preset_math_family_indeed_compact#fam#familytag%
+ {\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname
+ \ifnum\fontid\textfont#fam=\fontid\font\else
+ \font_helpers_preset_math_family_indeed_changed_compact#fam%
+ \fi}
+
+\def\font_helpers_preset_math_family_indeed_changed_compact#fam%
+ {\font_helpers_set_math_family_set_scales_compact
+ \scriptscriptfont#fam\font
+ \scriptfont #fam\font
+ \textfont #fam\font}
+
+\def\font_helpers_preset_math_family_indeed
+ {\ifconditional\c_font_compact
+ \expandafter\font_helpers_preset_math_family_indeed_compact
+ \else
+ \expandafter\font_helpers_preset_math_family_indeed_normal
+ \fi}
+
+\let\font_helpers_reset_fontclass_math_families\gobbleoneargument
+
+%D It would be nice if characters could be defined in a neutral way (say fam 255)
+%D and be mapped to a real family during noad list construction. However, this
+%D changes tex in critical places so for the moment we simulate this using
+%D manipulation.
+%D
+%D For tracing purposes we use three families but in l2r mode 1 and 2 are copies of
+%D 0 while in rl mode 0 is a copy of 1. There is no real overhead involved in this.
+%D This also permits different font definitions for normal and mixed.
+
+\let\m_font_class_direction\empty
+\let\m_font_class_features \empty
+\let\m_font_class_fallbacks\empty
+\let\m_font_class_goodies \empty
+
+\let\m_font_direction\empty
+\let\m_font_features \empty
+\let\m_font_fallbacks\empty
+\let\m_font_goodies \empty
+
+\appendtoks % can be analyzed once
+ % why here ..
+ %\edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\s!mm\s!direction\endcsname\csname\??fontclass\fontclass\s!mm\s!direction\endcsname\fi}%
+ \edef\m_font_class_direction{\begincsname\??fontclass\fontclass\s!mm\s!direction\endcsname}%
+ % ...
+ \ifx\m_font_class_direction\v!both
+ \settrue\c_font_bidirectional_mathstrategy
+ \else
+ \setfalse\c_font_bidirectional_mathstrategy
+ \fi
+\to \t_font_math_strategies
+
+\def\font_helpers_bidirectional_mathstrategy_yes
+ {\font_helpers_set_math_family\c_font_fam_mr_lr\s!mrlr
+ \font_helpers_set_math_family\c_font_fam_mr_rl\s!mrrl
+ \ifnum\fontid\textfont\c_font_fam_mr=\fontid\textfont\c_font_fam_mr_lr\else
+ \font_helpers_bidirectional_mathstrategy_yes_changed
+ \fi}
+
+\def\font_helpers_bidirectional_mathstrategy_yes_changed
+ {\textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr
+ \scriptfont \c_font_fam_mr\scriptfont \c_font_fam_mr_lr
+ \scriptscriptfont\c_font_fam_mr\scriptscriptfont\c_font_fam_mr_lr}
+
+\def\font_helpers_bidirectional_mathstrategy_nop
+ {\font_helpers_set_math_family\c_font_fam_mr\s!mr
+ \ifnum\fontid\textfont\c_font_fam_mr_rl=\fontid\textfont\c_font_fam_mr\else
+ \font_helpers_bidirectional_mathstrategy_nop_changed
+ \fi}
+
+\def\font_helpers_bidirectional_mathstrategy_nop_changed
+ {\textfont \c_font_fam_mr_lr\textfont \c_font_fam_mr
+ \scriptfont \c_font_fam_mr_lr\scriptfont \c_font_fam_mr
+ \scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr
+ \textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr
+ \scriptfont \c_font_fam_mr_rl\scriptfont \c_font_fam_mr
+ \scriptscriptfont\c_font_fam_mr_rl\scriptscriptfont\c_font_fam_mr}
+
+\appendtoks
+ \ifconditional\c_font_bidirectional_mathstrategy
+ \font_helpers_bidirectional_mathstrategy_yes
+ \else
+ \font_helpers_bidirectional_mathstrategy_nop
+ \fi
+\to \t_font_math_strategies
+
+\def\font_helpers_complete_bold_mathstrategy_yes_bidi
+ {\font_helpers_set_math_family_bold\c_font_fam_mb_lr\s!mblr\c_font_fam_mr_lr
+ \font_helpers_set_math_family_bold\c_font_fam_mb_rl\s!mbrl\c_font_fam_mr_rl
+ \ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mb_lr\else
+ \font_helpers_complete_bold_mathstrategy_yes_bidi_changed
+ \fi}
+
+\def\font_helpers_complete_bold_mathstrategy_yes_bidi_changed
+ {\textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr
+ \scriptfont \c_font_fam_mb\scriptfont \c_font_fam_mb_lr
+ \scriptscriptfont\c_font_fam_mb\scriptscriptfont\c_font_fam_mb_lr}
+
+\def\font_helpers_complete_bold_mathstrategy_yes
+ {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr\relax
+ \ifnum\fontid\textfont\c_font_fam_mb_rl=\fontid\textfont\c_font_fam_mb\else
+ \font_helpers_complete_bold_mathstrategy_yes_changed
+ \fi}
+
+\def\font_helpers_complete_bold_mathstrategy_yes_changed
+ {\textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb
+ \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mb
+ \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mb
+ \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mb
+ \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mb
+ \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mb}
+
+\def\font_helpers_complete_bold_mathstrategy_nop
+ {\ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mr\else
+ \font_helpers_complete_bold_mathstrategy_nop_changed
+ \fi}
+
+\def\font_helpers_complete_bold_mathstrategy_nop_changed
+ {\textfont \c_font_fam_mb \textfont \c_font_fam_mr
+ \scriptfont \c_font_fam_mb \scriptfont \c_font_fam_mr
+ \scriptscriptfont\c_font_fam_mb \scriptscriptfont\c_font_fam_mr
+ \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mr_lr
+ \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mr_lr
+ \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mr_lr
+ \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mr_rl
+ \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mr_rl
+ \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mr_rl}
+
+\def\font_helpers_apply_complete_bold_mathstrategy
+ {\ifconditional\c_font_complete_bold_mathstrategy
+ \ifconditional\c_font_bidirectional_mathstrategy
+ \font_helpers_complete_bold_mathstrategy_yes_bidi
+ \else
+ \font_helpers_complete_bold_mathstrategy_yes
+ \fi
+ \else
+ \font_helpers_complete_bold_mathstrategy_nop
+ \fi}
+
+\appendtoks
+ \font_helpers_apply_complete_bold_mathstrategy
+\to \t_font_math_strategies
+
+\ifdefined\defaultmathfamily \else
+ \setnewconstant\defaultmathfamily\zerocount
+\fi
+
+\appendtoks
+ \fam\defaultmathfamily % all characters and symbols are in this family
+\to \everymathematics
+
+\protected\def\font_helpers_synchronize_math_family_mr
+ {\c_attr_mathfamily\ifconditional\c_font_bidirectional_mathstrategy
+ \ifconditional\c_math_right_to_left
+ \plustwo
+ \else
+ \plusone
+ \fi
+ \else
+ \zerocount
+ \fi}
+
+\protected\def\font_helpers_synchronize_math_family_mb
+ {\c_attr_mathfamily\ifconditional\c_font_bidirectional_mathstrategy
+ \ifconditional\c_math_right_to_left
+ \ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi
+ \else
+ \ifconditional\c_font_pseudo_bold_math_state\plusseven\else\plusfour\fi
+ \fi
+ \else
+ \ifconditional\c_font_pseudo_bold_math_state\plussix\else\plusthree\fi
+ \fi}
+
+\installcorenamespace{fontmathsynchronizer}
+\installcorenamespace{fontmathstoredstrategy}
+
+\letvalue{\??fontmathsynchronizer\s!tf }\font_helpers_synchronize_math_family_mr
+\letvalue{\??fontmathsynchronizer\s!sl }\font_helpers_synchronize_math_family_mr
+\letvalue{\??fontmathsynchronizer\s!it }\font_helpers_synchronize_math_family_mr
+\letvalue{\??fontmathsynchronizer\s!bf }\font_helpers_synchronize_math_family_mb
+\letvalue{\??fontmathsynchronizer\s!bs }\font_helpers_synchronize_math_family_mb
+\letvalue{\??fontmathsynchronizer\s!bi }\font_helpers_synchronize_math_family_mb
+\letvalue{\??fontmathsynchronizer\empty}\font_helpers_synchronize_math_family_mr
+
+% \def\font_helpers_synchronize_math_family
+% {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname}
+
+\def\font_helpers_synchronize_math_family
+ {\ifcsname\??fontmathsynchronizer\fontalternative\endcsname
+ \lastnamedcs
+ \else
+ \font_helpers_synchronize_math_family_mr
+ \fi}
+
+\appendtoks
+ \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree
+ \letcsname\??fontmathstoredstrategy\fontclass\endcsname\font_helpers_set_math_partial_bold_strategy
+ \else
+ \letcsname\??fontmathstoredstrategy\fontclass\endcsname\font_helpers_set_math_full_bold_strategy
+ \fi
+\to \t_font_math_strategies
+
+%def\font_helpers_synchronize_math_bold_strategy{\csname\??fontmathstoredstrategy\fontclass\endcsname}
+\def\font_helpers_synchronize_math_bold_strategy{\begincsname\??fontmathstoredstrategy\fontclass\endcsname}
+
+\newconditional\c_font_pseudo_bold_math_state
+
+\def\font_helpers_set_math_partial_bold_strategy{\settrue \c_font_pseudo_bold_math_state}
+\def\font_helpers_set_math_full_bold_strategy {\setfalse\c_font_pseudo_bold_math_state}
+
+\appendtoks
+ \font_helpers_synchronize_math_bold_strategy
+\to \everymathematics
+
+%D Bold is somewhat special as we might want both full-bold-math mixed regular-math,
+%D as well as automatic adaption to outer bold (in titles and inline text bold) so
+%D we will need explicit switches as well as an automatic one. (We will use lucida
+%D as an example.)
+
+\ifdefined\mathdefault \else \let\mathdefault\relax \fi
+
+\newconditional\c_math_bold
+
+\permanent\protected\def\mr % math regular
+ {\ifmmode
+ \font_helpers_synchronize_math_family_mr
+ \else
+ \font_helpers_set_current_font_alternative\s!mr
+ \fi
+ \mathdefault
+ \setfalse\c_math_bold}
+
+\permanent\protected\def\mb % math bold
+ {\ifmmode
+ \font_helpers_synchronize_math_family_mb
+ \else
+ \font_helpers_set_current_font_alternative\s!mb
+ \fi
+ \mathdefault
+ \settrue\c_math_bold}
+
+\appendtoks
+ \font_helpers_synchronize_math_family % auto bold
+\to \everymathematics
+
+\appendtoks
+ \ifconditional\c_math_bold\mb\fi
+\to \everymathematics
+
+%D \macros
+%D {bigmath,nobigmath}
+%D
+%D We can inhibit this slow||downer with:
+
+% these can best be combined
+
+% 0=never 1=everymath 2=always
+
+\setnewconstant\synchronizebigmathflag\plusone
+
+\appendtoks
+ \ifcase\synchronizebigmathflag
+ % never
+ \or
+ \synchronizebigmath
+ \or
+ % always
+ \fi
+\to \everymathematics
+
+\permanent\protected\def\nobigmath {\synchronizebigmathflag\zerocount}
+\permanent\protected\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath}
+\permanent\protected\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath}
+
+\mutable\let\bigmathfontsize\empty
+
+\permanent\protected\def\synchronizebigmath
+ {\ifx\bigmathfontsize\fontsize
+ % already in sync
+ \else
+ \let\bigmathfontsize\fontsize
+ \font_helpers_synchronize_math
+ \fi}
+
+\protected\def\font_helpers_check_big_math_synchronization
+ {\ifcase\synchronizebigmathflag
+ % never
+ \or
+ \ifmmode \synchronizebigmath \fi
+ \or
+ \synchronizebigmath
+ \fi}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-mpf.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-mpf.lmt
new file mode 100644
index 00000000000..b1e6a00dd55
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-mpf.lmt
@@ -0,0 +1,173 @@
+if not modules then modules = { } end modules ['font-mpf'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local tonumber, unpack, type = tonumber, unpack, type
+
+local context = context
+local metapost = metapost
+
+local metafonts = { }
+metapost.metafonts = metafonts
+
+local sortedhash = table.sortedhash
+
+local addcharacters = fonts.constructors.addcharacters
+local fontdata = fonts.hashes.identifiers
+
+local otf = fonts.handlers.otf
+local otfregister = otf.features.register
+
+local getshapes = fonts.dropins.getshapes
+
+local setparameterset = metapost.setparameterset
+local simplemetapost = metapost.simple
+
+local register = fonts.collections.register
+local checkenabled = fonts.collections.checkenabled
+local newprivateslot = fonts.helpers.newprivateslot
+
+local currentfont = font.current
+
+local function setmetaglyphs(category,fontid,unicode,specification)
+ if unicode then
+ local tfmdata = fontdata[fontid]
+ local characters = tfmdata.characters
+ specification.unicode = unicode
+ specification.category = category
+ -- Generate one shape, make a use we pass the unicode as that is
+ -- the index in a picture list (normally). We could actually already
+ -- fetch the stream but for now we do that later (i.e. we delay the
+ -- serialization to pdf).
+ local code = specification.code
+ if code then
+ setparameterset("mpsfont",specification)
+ -- simplemetapost(instance,"begingroup;",true,true)
+ simplemetapost("simplefun",code)
+ -- simplemetapost(instance,"endgroup;",true,true)
+ end
+ -- We now know (hopefully) the dimensions of the image which is what
+ -- we need to pass to the engine in order to let it do its work.
+ local shapes = getshapes(category)
+ local units = shapes.parameters.units
+ local scale = tfmdata.parameters.size / units
+ local shape = shapes.glyphs[unicode]
+ --
+ local llx, lly, urx, ury = unpack(shape.boundingbox)
+ llx = llx * scale
+ urx = urx * scale
+ lly = lly * scale
+ ury = ury * scale
+ --
+ local newdata = { }
+ characters[unicode] = newdata -- so that we can register commands
+ fonts.dropins.swapone("mps",tfmdata,shape,unicode)
+ --
+ local olddata = characters[unicode]
+ newdata.width = urx - llx
+ newdata.height = ury
+ newdata.depth = -lly
+ newdata.unicode = unicode
+ -- commands = { { "offset", -llx, 0, newdata.commands[1][1], newdata.commands[1][2] } }
+ if llx ~= 0 then
+ newdata.commands = { { "offset", -llx, 0 }, newdata.commands[1] }
+ end
+ -- pass dimensions to lua
+ characters[unicode] = newdata
+ -- pass dimensions to tex
+ addcharacters(fontid, { characters = { [unicode] = newdata } })
+ return fontid, unicode
+ end
+end
+
+local function setmetaglyph(specification)
+ if specification then
+ local category = specification.category
+ local name = specification.name
+ if category and name then
+ local fontid = specification.fontid or currentfont()
+ local private = newprivateslot(name)
+ register(fontid,private,function(font,char)
+ return setmetaglyphs(category,font,char,specification) end
+ )
+ checkenabled()
+ end
+ end
+end
+
+local function initializempf(tfmdata,kind,value)
+ local metafont = metafonts[value]
+ if value then
+ local font = tfmdata.properties.id
+ for char, spec in sortedhash(metafont) do
+ if type(char) == "string" then
+ char = newprivateslot(char)
+ end
+ register(font,char,function(font,char)
+ return setmetaglyphs(value,font,char,spec)
+ end)
+ end
+ checkenabled()
+ end
+end
+
+fonts.helpers.setmetaglyphs = setmetaglyphs
+fonts.helpers.setmetaglyph = setmetaglyph
+
+otfregister {
+ name = "metafont",
+ description = "metafont glyphs",
+ manipulators = {
+ base = initializempf,
+ node = initializempf,
+ }
+}
+
+do
+
+ local scanners = tokens.scanners
+ local scanopen = scanners.scanopen
+ local scanclose = scanners.scanclose
+ local scanword = scanners.word
+ local scanstring = scanners.string
+
+ interfaces.implement {
+ name = "setmetaglyph",
+ public = true,
+ protected = true,
+ actions = function(t)
+ local t = { }
+ if scanopen() then
+ while not scanclose() do
+ local key = scanword()
+ if key == "shapes" then
+ if scanopen() then
+ local tt = { }
+ local nn = 0
+ while not scanclose() do
+ if scanopen() then
+ local ttt = { }
+ while not scanclose() do
+ local key = scanword()
+ ttt[key] = scanstring()
+ end
+ nn= nn + 1
+ tt[nn] = ttt
+ end
+ end
+ t[key] = tt
+ end
+ else
+ t[key] = scanstring()
+ end
+ end
+ end
+ setmetaglyph(t)
+ end
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-mps.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-mps.lmt
new file mode 100644
index 00000000000..8cab9cf5c8f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-mps.lmt
@@ -0,0 +1,398 @@
+if not modules then modules = { } end modules ['font-mps'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local tostring = tostring
+local concat = table.concat
+local formatters = string.formatters
+
+-- QP0 [QP1] QP2 => CP0 [CP1 CP2] CP3
+
+-- CP0 = QP0
+-- CP3 = QP2
+--
+-- CP1 = QP0 + 2/3 *(QP1-QP0)
+-- CP2 = QP2 + 2/3 *(QP1-QP2)
+
+fonts = fonts or { }
+local metapost = fonts.metapost or { }
+fonts.metapost = metapost
+
+local f_moveto = formatters["(%N,%N)"]
+local f_lineto = formatters["--(%N,%N)"]
+local f_curveto = formatters["..controls(%N,%N)and(%N,%N)..(%N,%N)"]
+local s_cycle = "--cycle"
+
+local f_nofill = formatters["nofill %s;"]
+local f_dofill = formatters["fill %s;"]
+
+local f_draw_trace = formatters["drawpathonly %s;"]
+local f_draw = formatters["draw %s;"]
+
+local f_boundingbox = formatters["((%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle)"]
+local f_vertical = formatters["((%N,%N)--(%N,%N))"]
+
+function metapost.boundingbox(d,factor)
+ local bounds = d.boundingbox
+ local factor = factor or 1
+ local llx = factor*bounds[1]
+ local lly = factor*bounds[2]
+ local urx = factor*bounds[3]
+ local ury = factor*bounds[4]
+ return f_boundingbox(llx,lly,urx,lly,urx,ury,llx,ury)
+end
+
+function metapost.widthline(d,factor)
+ local bounds = d.boundingbox
+ local factor = factor or 1
+ local lly = factor*bounds[2]
+ local ury = factor*bounds[4]
+ local width = factor*d.width
+ return f_vertical(width,lly,width,ury)
+end
+
+function metapost.zeroline(d,factor)
+ local bounds = d.boundingbox
+ local factor = factor or 1
+ local lly = factor*bounds[2]
+ local ury = factor*bounds[4]
+ return f_vertical(0,lly,0,ury)
+end
+
+function metapost.paths(d,xfactor,yfactor)
+ local sequence = d.sequence
+ local segments = d.segments
+ local list = { }
+ local path = { } -- recycled
+ local size = 0
+ local xfactor = xfactor or 1
+ local yfactor = yfactor or xfactor
+ if sequence then
+ local i = 1
+ local n = #sequence
+ while i < n do
+ local operator = sequence[i]
+ if operator == "m" then -- "moveto"
+ if size > 0 then
+ size = size + 1
+ path[size] = s_cycle
+ list[#list+1] = concat(path,"",1,size)
+ size = 1
+ else
+ size = size + 1
+ end
+ path[size] = f_moveto(xfactor*sequence[i+1],yfactor*sequence[i+2])
+ i = i + 3
+ elseif operator == "l" then -- "lineto"
+ size = size + 1
+ path[size] = f_lineto(xfactor*sequence[i+1],yfactor*sequence[i+2])
+ i = i + 3
+ elseif operator == "c" then -- "curveto"
+ size = size + 1
+ path[size] = f_curveto(xfactor*sequence[i+1],yfactor*sequence[i+2],xfactor*sequence[i+3],yfactor*sequence[i+4],xfactor*sequence[i+5],yfactor*sequence[i+6])
+ i = i + 7
+ elseif operator =="q" then -- "quadraticto"
+ size = size + 1
+ -- first is always a moveto
+ local l_x = xfactor*sequence[i-2]
+ local l_y = yfactor*sequence[i-1]
+ local m_x = xfactor*sequence[i+1]
+ local m_y = yfactor*sequence[i+2]
+ local r_x = xfactor*sequence[i+3]
+ local r_y = yfactor*sequence[i+4]
+ path[size] = f_curveto (
+ l_x + 2/3 * (m_x-l_x),
+ l_y + 2/3 * (m_y-l_y),
+ r_x + 2/3 * (m_x-r_x),
+ r_y + 2/3 * (m_y-r_y),
+ r_x, r_y
+ )
+ i = i + 5
+ else
+ -- weird
+ i = i + 1
+ end
+ end
+ elseif segments then
+ for i=1,#segments do
+ local segment = segments[i]
+ local operator = segment[#segment]
+ if operator == "m" then -- "moveto"
+ if size > 0 then
+ size = size + 1
+ path[size] = s_cycle
+ list[#list+1] = concat(path,"",1,size)
+ size = 1
+ else
+ size = size + 1
+ end
+ path[size] = f_moveto(xfactor*segment[1],yfactor*segment[2])
+ elseif operator == "l" then -- "lineto"
+ size = size + 1
+ path[size] = f_lineto(xfactor*segment[1],yfactor*segment[2])
+ elseif operator == "c" then -- "curveto"
+ size = size + 1
+ path[size] = f_curveto(xfactor*segment[1],yfactor*segment[2],xfactor*segment[3],yfactor*segment[4],xfactor*segment[5],yfactor*segment[6])
+ elseif operator =="q" then -- "quadraticto"
+ size = size + 1
+ -- first is always a moveto
+ local prev = segments[i-1]
+ local l_x = xfactor*prev[#prev-2]
+ local l_y = yfactor*prev[#prev-1]
+ local m_x = xfactor*segment[1]
+ local m_y = yfactor*segment[2]
+ local r_x = xfactor*segment[3]
+ local r_y = yfactor*segment[4]
+ path[size] = f_curveto (
+ l_x + 2/3 * (m_x-l_x),
+ l_y + 2/3 * (m_y-l_y),
+ r_x + 2/3 * (m_x-r_x),
+ r_y + 2/3 * (m_y-r_y),
+ r_x, r_y
+ )
+ else
+ -- weird
+ end
+ end
+ else
+ return
+ end
+ if size > 0 then
+ size = size + 1
+ path[size] = s_cycle
+ list[#list+1] = concat(path,"",1,size)
+ end
+ return list
+end
+
+function metapost.fill(paths)
+ local r = { }
+ local n = #paths
+ for i=1,n do
+ if i < n then
+ r[i] = f_nofill(paths[i])
+ else
+ r[i] = f_dofill(paths[i])
+ end
+ end
+ return concat(r)
+end
+
+function metapost.draw(paths,trace)
+ local r = { }
+ local n = #paths
+ for i=1,n do
+ if trace then
+ r[i] = f_draw_trace(paths[i])
+ else
+ r[i] = f_draw(paths[i])
+ end
+ end
+ return concat(r)
+end
+
+function metapost.maxbounds(data,index,factor)
+ local maxbounds = data.maxbounds
+ local factor = factor or 1
+ local glyphs = data.glyphs
+ local glyph = glyphs[index]
+ local boundingbox = glyph.boundingbox
+ local xmin, ymin, xmax, ymax
+ if not maxbounds then
+ xmin = 0
+ ymin = 0
+ xmax = 0
+ ymax = 0
+ for i=1,#glyphs do
+ local d = glyphs[i]
+ if d then
+ local b = d.boundingbox
+ if b then
+ if b[1] < xmin then xmin = b[1] end
+ if b[2] < ymin then ymin = b[2] end
+ if b[3] > xmax then xmax = b[3] end
+ if b[4] > ymax then ymax = b[4] end
+ end
+ end
+ end
+ maxbounds = { xmin, ymin, xmax, ymax }
+ data.maxbounds = maxbounds
+ else
+ xmin = maxbounds[1]
+ ymin = maxbounds[2]
+ xmax = maxbounds[3]
+ ymax = maxbounds[4]
+ end
+ local llx = boundingbox[1]
+ local lly = boundingbox[2]
+ local urx = boundingbox[3]
+ local ury = boundingbox[4]
+ local width = glyph.width
+ if llx > 0 then
+ llx = 0
+ end
+ if width > urx then
+ urx = width
+ end
+ return f_boundingbox(
+ factor*llx,factor*ymin,
+ factor*urx,factor*ymin,
+ factor*urx,factor*ymax,
+ factor*llx,factor*ymax
+ )
+end
+
+-- This is a nice example of tex, metapost and lua working in tandem. Each kicks in at the
+-- right time. It's probably why I like watching https://www.youtube.com/watch?v=c5FqpddnJmc
+-- so much: precisely (and perfectly) timed too.
+
+local texgetbox = tex.getbox
+
+local nodecodes = nodes.nodecodes -- no nuts yet
+local rulecodes = nodes.rulecodes
+
+local rule_code = nodecodes.rule
+
+local normalrule_code = rulecodes.normal
+local outlinerule_code = rulecodes.outline
+local userrule_code = rulecodes.user
+local emptyrule_code = rulecodes.empty
+
+local nuts = nodes.nuts
+local getwhd = nuts.getwhd
+local getexpansion = nuts.getexpansion
+local isglyph = nuts.isglyph
+
+local characters = fonts.hashes.characters
+local parameters = fonts.hashes.parameters
+local shapes = fonts.hashes.shapes
+local topaths = metapost.paths
+
+local f_text = formatters["mfun_do_outline_text_flush(%q,%i,%N,%N,%q)(%,t);"]
+local f_rule = formatters["mfun_do_outline_rule_flush(%q,%N,%N,%N,%N);"]
+local f_bounds = formatters["checkbounds(%N,%N,%N,%N);"]
+local s_nothing = "(origin scaled 10)"
+
+local sc = 10
+local fc = number.dimenfactors.bp
+
+local function glyph(kind,font,char,advance,shift,ex)
+ local character = characters[font][char]
+ if character then
+ local index = character.index
+ if index then
+ local shapedata = shapes[font]
+ local glyphs = shapedata.glyphs -- todo: subfonts fonts.shapes.indexed(font,sub)
+ if glyphs then
+ local glyf = glyphs[index]
+ if glyf then
+ local units = 1000 -- factor already takes shapedata.units into account
+ local yfactor = (sc/units) * parameters[font].factor / 655.36
+ local xfactor = yfactor
+ local shift = shift or 0
+ local advance = advance or 0
+ local exfactor = ex or 0
+ local wfactor = 1
+ local detail = kind == "p" and tostring(char) or ""
+ if exfactor ~= 0 then
+ wfactor = (1+(ex/units)/1000)
+ xfactor = xfactor * wfactor
+ end
+ local paths = topaths(glyf,xfactor,yfactor)
+ if paths then
+ return f_text(kind,#paths,advance,shift,detail,paths) -- , character.width * fc * wfactor
+ end
+ end
+ end
+ end
+ end
+end
+
+metapost.glyph = glyph
+
+local kind = ""
+local buffer = { }
+local b = 0
+
+local function reset()
+ buffer = { }
+ b = 0
+end
+
+local function flushcharacter(current, pos_h, pos_v, pod_r, font, char)
+ local char, font = isglyph(current)
+ local code = glyph(kind,font,char,pos_h*fc,pos_v*fc,getexpansion(current))
+ if code then
+ b = b + 1
+ buffer[b] = code
+ end
+end
+
+local function flushrule(current, pos_h, pos_v, pos_r, size_h, size_v, subtype)
+ if subtype == normalrule_code then
+ b = b + 1
+ buffer[b] = f_rule(kind,pos_h*fc,pos_v*fc,size_h*fc,size_v*fc)
+ elseif subtype == outlinerule_code then
+ b = b + 1
+ buffer[b] = f_rule("d",pos_h*fc,pos_v*fc,size_h*fc,size_v*fc)
+ elseif subtype == userrule_code then
+ -- print("USER RULE")
+ -- b = b + 1
+ -- buffer[b] = f_rule("d",size_h*fc,size_v*fc,pos_h*fc,pos_v*fc)
+ elseif subtype == emptyrule_code then
+ -- ignore
+ else
+ -- b = b + 1
+ -- buffer[b] = f_rule("f",pos_h*fc,pos_v*fc,size_h*fc,size_v*fc)
+ end
+end
+
+local function flushsimplerule(pos_h, pos_v, pos_r, size_h, size_v)
+ flushrule(false,pos_h,pos_v,pos_r,size_h,size_v,normalrule_code)
+end
+
+local function flushspecialrule(pos_h, pos_v, pos_r, w, h, d, l, outline)
+ flushrule(false,pos_h,pos_v-d,pos_r,w,h+d,outline and outlinerule_code or normalrule_code)
+end
+
+-- installer
+
+drivers.install {
+ name = "mpo",
+ actions = {
+ initialize = function()
+ reset()
+ end,
+ finalize = function(driver,details)
+ local bb = details.boundingbox
+ local llx = bb[1] * fc
+ local lly = bb[2] * fc
+ local urx = bb[3] * fc
+ local ury = bb[4] * fc
+ b = b + 1
+ buffer[b] = f_bounds(llx,lly,urx,ury)
+ -- inspect(buffer)
+ end,
+ },
+ flushers = {
+ updatefontstate = updatefontstate,
+ character = flushcharacter,
+ rule = flushrule,
+ simplerule = flushsimplerule,
+ specialrule = flushspecialrule,
+ }
+}
+
+function metapost.boxtomp(n,k)
+ kind = k
+ nodes.handlers.finalizebox(n)
+ drivers.converters.lmtx(drivers.instances.mpo,texgetbox(n),"box",1)
+ local result = concat(buffer,";")
+ reset()
+ return result
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt
new file mode 100644
index 00000000000..698593ac7e0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ogr.lmt
@@ -0,0 +1,785 @@
+if not modules then modules = { } end modules ['font-ogr'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Here we deal with graphic variants and for now also color support ends up here
+-- but that might change. It's lmtx only code.
+
+local tostring, tonumber, next, type, rawget = tostring, tonumber, next, type, rawget
+local round, max, mod, div = math.round, math.max, math.mod, math.div
+local find = string.find
+local concat, setmetatableindex, sortedhash = table.concat, table.setmetatableindex, table.sortedhash
+local utfbyte = utf.byte
+local formatters = string.formatters
+local settings_to_hash_strict, settings_to_array = utilities.parsers.settings_to_hash_strict, utilities.parsers.settings_to_array
+
+local otf = fonts.handlers.otf
+local otfregister = otf.features.register
+otf.svgenabled = true
+otf.pngenabled = true
+
+-- Just to remind me ... rewritten around the time this was posted on YT which
+-- was also around the 2019 ctx meeting:
+--
+-- Gavin Harrison - "Threatening War" by The Pineapple Thief
+-- https://www.youtube.com/watch?v=ENF9wth4kwM
+
+-- todo: svg color plugin
+-- todo: get rid of double cm in svg (tricky as also elsewhere)
+-- todo: png offsets (depth)
+-- todo: maybe collapse indices so that we have less files (harder to debug)
+-- todo: manage (read: assign) font id's in lua so we know in advance
+
+-- what here and what in backend ...
+
+do
+
+ -- This is a prelude to something better but I'm still experimenting.
+
+ local dropins = { }
+ fonts.dropins = dropins
+ local droppedin = 0
+ local identifiers = fonts.hashes.identifiers
+
+ function dropins.nextid()
+ droppedin = droppedin - 1
+ return droppedin
+ end
+
+ -- todo: pass specification table instead
+
+ function dropins.provide(method,t_tfmdata,indexdata,...)
+ local droppedin = dropins.nextid()
+ local t_characters = t_tfmdata.characters
+ local t_descriptions = t_tfmdata.descriptions
+ local t_properties = t_tfmdata.properties
+ local d_tfmdata = setmetatableindex({ },t_tfmdata)
+ local d_properties = setmetatableindex({ },t_properties)
+ d_properties.basefontname = "ContextRuntimeFont" .. droppedin
+ d_tfmdata.properties = d_properties
+ local d_characters = { } -- setmetatableindex({ },t_characters) -- hm, index vs unicode
+ local d_descriptions = { } -- setmetatableindex({ },t_descriptions) -- hm, index vs unicode
+ d_tfmdata.characters = d_characters
+ d_tfmdata.descriptions = d_descriptions
+ d_tfmdata.parentdata = t_tfmdata -- so we can access it if needed
+ d_properties.instance = - droppedin -- will become an extra element in the hash
+ identifiers[droppedin] = d_tfmdata
+ local fonts = t_tfmdata.fonts or { }
+ t_tfmdata.fonts = fonts
+ d_properties.format = "type3"
+ d_properties.method = method
+ d_properties.indexdata = { indexdata, ... } -- can take quite some memory
+ local slot = #fonts + 1
+ fonts[slot] = { id = droppedin }
+ return slot, droppedin, d_tfmdata, d_properties
+ end
+
+ -- todo: delay this, in which case we can be leaner and meaner
+
+ function dropins.clone(method,tfmdata,shapes,...) -- by index
+ if method and shapes then
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
+ local idx = 255
+ local slot = 0
+ for k, v in next, characters do
+ local index = v.index
+ if index then
+ local description = descriptions[k]
+ if description then
+ local shape = shapes[index]
+ if shape then
+ if idx >= 255 then
+ idx = 1
+ colrshapes = setmetatableindex({ },shapes)
+ slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
+ dropchars = tfmdrop.characters
+ dropdescs = tfmdrop.descriptions
+ else
+ idx = idx + 1
+ end
+ colrshapes[idx] = shape -- so not: description
+ -- todo: prepend
+ v.commands = { { "slot", slot, idx } }
+ -- hack to prevent that type 3 also gets 'use' flags .. todo
+ local c = { commands = false, index = idx, dropin = tfmdrop }
+ local d = { } -- { index = idx, dropin = tfmdrop }
+ setmetatableindex(c,v)
+ setmetatableindex(d,description)
+ dropchars[idx] = c
+ dropdescs[idx] = d -- not needed
+ end
+ end
+ end
+ end
+ else
+ -- error
+ end
+ end
+
+-- function dropins.swap(method,tfmdata,shapes,...) -- by unicode
+-- if method and shapes then
+-- local characters = tfmdata.characters
+-- local descriptions = tfmdata.descriptions
+-- local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
+-- local idx = 255
+-- local slot = 0
+-- -- we can have a variant where shaped are by unicode and not by index
+-- for k, v in next, characters do
+-- local description = descriptions[k]
+-- if description then
+-- local shape = shapes[k]
+-- if shape then
+-- if idx >= 255 then
+-- idx = 1
+-- colrshapes = setmetatableindex({ },shapes)
+-- slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
+-- dropchars = tfmdrop.characters
+-- dropdescs = tfmdrop.descriptions
+-- else
+-- idx = idx + 1
+-- end
+-- colrshapes[idx] = shape -- so not: description
+-- -- todo: prepend
+-- v.commands = { { "slot", slot, idx } }
+-- -- hack to prevent that type 3 also gets 'use' flags .. todo
+-- local c = { commands = false, index = idx, dropin = tfmdrop }
+-- local d = { } -- index = idx, dropin = tfmdrop }
+-- setmetatableindex(c,v)
+-- setmetatableindex(d,description)
+-- dropchars[idx] = c
+-- dropdescs[idx] = d -- not needed
+-- end
+-- end
+-- end
+-- else
+-- -- error
+-- end
+-- end
+
+ function dropins.swap(method,tfmdata,shapes) -- by unicode
+ if method and shapes then
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local droppedin = tfmdata.droppedin
+ local tfmdrop = tfmdata.tfmdrop
+ local dropchars = tfmdata.dropchars
+ local dropdescs = tfmdata.dropdescs
+ local colrshapes = tfmdata.colrshapes
+ local idx = tfmdata.dropindex or 255
+ local slot = tfmdata.dropslot or 0
+ -- we can have a variant where shaped are by unicode and not by index
+ for k, v in next, characters do
+ local description = descriptions[k]
+ if description then
+ local shape = shapes[k]
+ if shape then
+ if idx >= 255 then
+ idx = 1
+ colrshapes = setmetatableindex({ },shapes)
+ slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
+ dropchars = tfmdrop.characters
+ dropdescs = tfmdrop.descriptions
+ else
+ idx = idx + 1
+ end
+ colrshapes[idx] = shape -- so not: description
+ -- todo: prepend
+ v.commands = { { "slot", slot, idx } }
+ -- hack to prevent that type 3 also gets 'use' flags .. todo
+ local c = { commands = false, index = idx, dropin = tfmdrop }
+ local d = { } -- index = idx, dropin = tfmdrop }
+ setmetatableindex(c,v)
+ setmetatableindex(d,description)
+ dropchars[idx] = c
+ dropdescs[idx] = d -- not needed
+ end
+ end
+ end
+ tfmdata.droppedin = droppedin
+ tfmdata.tfmdrop = tfmdrop
+ tfmdata.dropchars = dropchars
+ tfmdata.dropdescs = dropdescs
+ tfmdata.colrshapes = colrshapes
+ tfmdata.dropindex = idx
+ tfmdata.dropslot = slot
+ else
+ -- error
+ end
+ end
+
+ function dropins.swapone(method,tfmdata,shape,unicode)
+ if method and shape then
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local droppedin = tfmdata.droppedin
+ local tfmdrop = tfmdata.tfmdrop
+ local dropchars = tfmdata.dropchars
+-- local dropdescs = tfmdata.dropdescs
+ local colrshapes = tfmdata.colrshapes
+ local idx = tfmdata.dropindex or 255
+ local slot = tfmdata.dropslot or 0
+ local character = characters[unicode]
+-- local description = descriptions[unicode] or { }
+ if character then
+ if idx >= 255 then
+ idx = 1
+ colrshapes = setmetatableindex({ },shapes)
+ slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes)
+ dropchars = tfmdrop.characters
+ dropdescs = tfmdrop.descriptions
+ else
+ idx = idx + 1
+ end
+ colrshapes[idx] = shape.code -- so not: description
+ -- todo: prepend
+ character.commands = { { "slot", slot, idx } }
+ -- hack to prevent that type 3 also gets 'use' flags .. todo
+ local c = { commands = false, index = idx, dropin = tfmdrop }
+-- local d = { } -- index = idx, dropin = tfmdrop }
+ setmetatableindex(c,character)
+-- setmetatableindex(d,description)
+ dropchars[idx] = c
+-- dropdescs[idx] = d -- not needed
+ end
+ tfmdata.droppedin = droppedin
+ tfmdata.tfmdrop = tfmdrop
+ tfmdata.dropchars = dropchars
+-- tfmdata.dropdescs = dropdescs
+ tfmdata.colrshapes = colrshapes
+ tfmdata.dropindex = idx
+ tfmdata.dropslot = slot
+ end
+ end
+
+end
+
+do -- this will move to its own module
+
+ local dropins = fonts.dropins
+
+ local shapes = setmetatableindex(function(t,k)
+ local v = {
+ glyphs = { },
+ parameters = {
+ units = 10
+ },
+ }
+ t[k] = v
+ return v
+ end)
+
+ function dropins.getshape(name,n)
+ local s = shapes[name]
+ return s and s.glyphs and s.glyphs[n]
+ end
+
+ function dropins.getshapes(name)
+ return shapes[name]
+ end
+
+ function dropins.registerglyphs(parameters)
+ local category = parameters.name
+ local target = shapes[category].parameters
+ for k, v in next, parameters do
+ if k ~= "glyphs" then
+ target[k] = v
+ end
+ end
+ end
+
+ function dropins.registerglyph(parameters)
+ local category = parameters.category
+ local unicode = parameters.unicode
+ local private = parameters.private
+ local unichar = parameters.unichar
+ if private then
+ unicode = fonts.helpers.newprivateslot(private)
+ elseif type(unichar) == "string" then
+ unicode = utfbyte(unichar)
+ else
+ local unitype = type(unicode)
+ if unitype == "string" then
+ local uninumber = tonumber(unicode)
+ if uninumber then
+ unicode = round(uninumber)
+ else
+ unicode = utfbyte(unicode)
+ end
+ elseif unitype == "number" then
+ unicode = round(unicode)
+ end
+ end
+ if unicode then
+ parameters.unicode = unicode
+ -- print(category,unicode)
+ shapes[category].glyphs[unicode] = parameters
+ else
+ -- error
+ end
+ end
+
+ -- local function hascolorspec(t)
+ -- if (t.color or "") ~= "" then
+ -- return true
+ -- elseif (t.fillcolor or "") ~= "" then
+ -- return true
+ -- elseif (t.drawcolor or "") ~= "" then
+ -- return true
+ -- elseif (t.linecolor or "") ~= "" then
+ -- return true
+ -- else
+ -- return false
+ -- end
+ -- end
+
+ local function hascolorspec(t)
+ for k, v in next, t do
+ if find(k,"color") then
+ return true
+ end
+ end
+ return false
+ end
+
+ -- list of tonumber keywords
+
+ local function initializemps(tfmdata,kind,value)
+ if value then
+ local specification = settings_to_hash_strict(value)
+ if not specification or not next(specification) then
+ specification = { category = value }
+ end
+ -- todo: multiple categories but then maybe also different
+ -- clones because of the units .. for now we assume the same
+ -- units
+ local category = specification.category
+ if category and category ~= "" then
+ local categories = settings_to_array(category)
+ local usedshapes = nil
+ local index = 0
+ local spread = tonumber(specification.spread or 0) -- hm
+ local hascolor = hascolorspec(specification)
+
+ specification.spread = spread -- now a number, maybe also for slant, weight etc
+
+ local preroll = specification.preroll
+ if preroll then
+ metapost.simple(instance,"begingroup;",true,true)
+ metapost.setparameterset("mpsfont",specification)
+ metapost.simple("simplefun",preroll)
+ metapost.setparameterset("mpsfont")
+ metapost.simple(instance,"endgroup;",true,true)
+ end
+
+ for i=1,#categories do
+ local category = categories[i]
+ local mpsshapes = shapes[category]
+ if mpsshapes then
+ local properties = tfmdata.properties
+ local parameters = tfmdata.parameters
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local mpsparameters = mpsshapes.parameters
+ local units = mpsparameters.units or 1000
+ local defaultwidth = mpsparameters.width or 0
+ local defaultheight = mpsparameters.height or 0
+ local defaultdepth = mpsparameters.depth or 0
+ local usecolor = mpsparameters.usecolor
+ local spread = spread * units
+ local defaultcode = mpsparameters.code or ""
+ local scale = parameters.size / units
+ if hascolor then
+ -- the graphic has color
+ usecolor = false
+ else
+ -- do whatever is specified
+ end
+ usedshapes = usedshapes or {
+ instance = "simplefun",
+ units = units,
+ usecolor = usecolor,
+ specification = specification,
+ shapes = mpsshapes,
+ }
+ -- todo: deal with extensibles and more properties
+ for unicode, shape in sortedhash(mpsshapes.glyphs) do
+ index = index + 1 -- todo: somehow we end up with 2 as first entry after 0
+ local wd = shape.width or defaultwidth
+ local ht = shape.height or defaultheight
+ local dp = shape.depth or defaultdepth
+ local bb = shape.boundingbox
+ local uc = shape.tounicode
+ if uc then
+ uc = round(uc) -- brrr can be 123.0
+ end
+ if bb then
+ for i=1,4 do bb[i] = scale * bb[i] end
+ end
+ local newc = {
+ index = index, -- into usedshapes -- used?
+ width = scale * (wd + spread),
+ height = scale * ht,
+ depth = scale * dp,
+ boundingbox = bb,
+ unicode = uc or unicode,
+ -- shape = shape, -- maybe a copy
+ }
+ --
+ characters [unicode] = newc
+ descriptions[unicode] = newc
+ usedshapes [unicode] = shape.code or defaultcode
+ --
+ -- This is a way to get/use randomized shapes (see punk example).
+ --
+ if uc and uc ~= unicode then
+ local c = characters[uc]
+ if c then
+ local v = c.variants
+ if v then
+ v[#v + 1] = unicode
+ else
+ c.variants = { unicode }
+ end
+ end
+ end
+ end
+ end
+ end
+ if usedshapes then
+ -- todo: different font when units and usecolor changes, maybe move into loop
+ -- above
+ dropins.swap("mps",tfmdata,usedshapes)
+ end
+ end
+ end
+ end
+
+ -- This kicks in quite late, after features have been checked. So if needed
+ -- substitutions need to be defined with force.
+
+ otfregister {
+ name = "metapost",
+ description = "metapost glyphs",
+ manipulators = {
+ base = initializemps,
+ node = initializemps,
+ }
+ }
+
+end
+
+-- This sits here for historcal reasons so for now we keep it here.
+
+local startactualtext = nil
+local stopactualtext = nil
+
+function otf.getactualtext(s)
+ if not startactualtext then
+ startactualtext = backends.codeinjections.startunicodetoactualtextdirect
+ stopactualtext = backends.codeinjections.stopunicodetoactualtextdirect
+ end
+ return startactualtext(s), stopactualtext()
+end
+
+-- This is also somewhat specific.
+
+local color_direct = function() return false end
+local color_indirect = color_direct
+
+updaters.register("backend.update",function()
+ color_direct = lpdf.fonts.color_direct
+ color_indirect = lpdf.fonts.color_indirect
+end)
+
+local sharedpalettes = { } do
+
+ local register = attributes.colors.register
+
+ local colors = attributes.list[attributes.private('color')] or { }
+ local transparencies = attributes.list[attributes.private('transparency')] or { }
+
+ function otf.registerpalette(name,values)
+ sharedpalettes[name] = values
+ for i=1,#values do
+ local v = values[i]
+ if v == "textcolor" then
+ values[i] = false
+ else
+ local c = nil
+ local t = nil
+ if type(v) == "table" then
+ c = register(name,"rgb",
+ max(round((v.r or 0)*255),255)/255,
+ max(round((v.g or 0)*255),255)/255,
+ max(round((v.b or 0)*255),255)/255
+ )
+ else
+ c = colors[v]
+ t = transparencies[v]
+ end
+ values[i] = color_indirect(c,t)
+ end
+ end
+ end
+
+end
+
+local initializeoverlay do
+
+ local function autoconvert(t,k)
+ local v = { }
+ for i=1,#k do
+ local p = k[i]
+ v[i] = color_direct(p[1]/255, p[2]/255, p[3]/255)
+ end
+ t[k] = v
+ return v
+ end
+
+ initializeoverlay = function(tfmdata,kind,value) -- we really need the id ... todo
+ if value then
+ local resources = tfmdata.resources
+ local palettes = resources.colorpalettes
+ if palettes then
+ --
+ local converted = resources.converted
+ if not converted then
+ converted = setmetatableindex(autoconvert)
+ resources.converted = converted
+ end
+ local colorvalues = sharedpalettes[value]
+ local default = false -- so the text color (bad for icon overloads)
+ if colorvalues then
+ default = colorvalues[#colorvalues]
+ else
+ colorvalues = converted[palettes[tonumber(value) or 1] or palettes[1]] or { }
+ end
+ local classes = #colorvalues
+ if classes == 0 then
+ return
+ end
+ --
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local droppedin, tfmdrop, dropchars, dropdescs, colrshapes
+ local idx = 255
+ local slot = 0
+ --
+ -- maybe delay in which case we have less fonts as we can be sparse
+ --
+ for k, v in next, characters do
+ local index = v.index
+ if index then
+ local description = descriptions[k]
+ if description then
+ local colorlist = description.colors
+ if colorlist then
+ if idx >= 255 then
+ idx = 1
+ colrshapes = { }
+ slot, droppedin, tfmdrop = fonts.dropins.provide("color",tfmdata,colrshapes,colorvalues)
+ dropchars = tfmdrop.characters
+ dropdescs = tfmdrop.descriptions
+ else
+ idx = idx + 1
+ end
+ --
+ colrshapes[idx] = description
+ -- todo: use extender
+ local u = { "use", 0 }
+ for i=1,#colorlist do
+ u[i+2] = colorlist[i].slot
+ end
+ v.commands = { u, { "slot", slot, idx } }
+ -- hack to prevent that type 3 also gets 'use' flags .. todo
+ local c = { commands = false, index = idx, dropin = tfmdata }
+ local d = { } -- index = idx, dropin = tfmdrop
+ setmetatableindex(c,v)
+ setmetatableindex(d,description)
+ dropchars[idx] = c
+ dropdescs[idx] = d -- not needed
+ end
+ end
+ end
+ end
+ return true
+ end
+ end
+ end
+
+ fonts.handlers.otf.features.register {
+ name = "colr",
+ description = "color glyphs",
+ manipulators = {
+ base = initializeoverlay,
+ node = initializeoverlay,
+ }
+ }
+
+end
+
+local initializesvg do
+
+ local report_svg = logs.reporter("fonts","svg")
+
+ local cached = true -- maybe always false (after i've optimized the lot)
+
+ directives.register("fonts.svg.cached", function(v) cached = v end)
+
+ initializesvg = function(tfmdata,kind,value) -- hm, always value
+ if value then
+ local properties = tfmdata.properties
+ local svg = properties.svg
+ local hash = svg and svg.hash
+ local timestamp = svg and svg.timestamp
+ if not hash then
+ return
+ end
+ local shapes = nil
+ local method = nil
+ local enforce = attributes.colors.model == "cmyk"
+ if cached and not enforce then
+ -- we need a different hash than for mkiv, so we append:
+ local pdfhash = hash .. "-svg"
+ local pdffile = containers.read(otf.pdfcache,pdfhash)
+ local pdfshapes = pdffile and pdffile.pdfshapes
+ local pdftarget = file.join(otf.pdfcache.writable,file.addsuffix(pdfhash,"pdf"))
+ if not pdfshapes or pdffile.timestamp ~= timestamp or not next(pdfshapes) or not lfs.isfile(pdftarget) then
+ local svgfile = containers.read(otf.svgcache,hash)
+ local svgshapes = svgfile and svgfile.svgshapes
+ pdfshapes = svgshapes and metapost.svgshapestopdf(svgshapes,pdftarget,report_svg,tfmdata.parameters.units) or { }
+ -- look at ocl: we should store scale and x and y
+ containers.write(otf.pdfcache, pdfhash, {
+ pdfshapes = pdfshapes,
+ timestamp = timestamp,
+ })
+ end
+ shapes = pdfshapes
+ method = "pdf"
+ else
+ local mpsfile = containers.read(otf.mpscache,hash)
+ local mpsshapes = mpsfile and mpsfile.mpsshapes
+ if not mpsshapes or mpsfile.timestamp ~= timestamp or not next(mpsshapes) then
+ local svgfile = containers.read(otf.svgcache,hash)
+ local svgshapes = svgfile and svgfile.svgshapes
+ -- still suboptimal
+ mpsshapes = svgshapes and metapost.svgshapestomp(svgshapes,report_svg,tfmdata.parameters.units) or { }
+ if enforce then
+ -- cheap conversion, no black component generation
+ mpsshapes.preamble = "interim svgforcecmyk := 1;"
+ end
+ containers.write(otf.mpscache, hash, {
+ mpsshapes = mpsshapes,
+ timestamp = timestamp,
+ })
+ end
+ shapes = mpsshapes
+ method = "mps"
+ end
+ if shapes then
+ shapes.fixdepth = value == "fixdepth"
+ fonts.dropins.clone(method,tfmdata,shapes)
+ end
+ return true
+ end
+ end
+
+ otfregister {
+ name = "svg",
+ description = "svg glyphs",
+ manipulators = {
+ base = initializesvg,
+ node = initializesvg,
+ }
+ }
+
+end
+
+local initializepng do
+
+ -- If this is really critical we can also use a pdf file as cache but I don't expect
+ -- png fonts to remain used.
+
+ local colors = attributes.colors
+
+ local report_png = logs.reporter("fonts","png conversion")
+
+ initializepng = function(tfmdata,kind,value) -- hm, always value
+ if value then
+ local properties = tfmdata.properties
+ local png = properties.png
+ local hash = png and png.hash
+ local timestamp = png and png.timestamp
+ if not hash then
+ return
+ end
+ local pngfile = containers.read(otf.pngcache,hash)
+ local pngshapes = pngfile and pngfile.pngshapes
+ if pngshapes then
+ if colors.model == "cmyk" then
+ pngshapes.enforcecmyk = true
+ end
+ fonts.dropins.clone("png",tfmdata,pngshapes)
+ end
+ return true
+ end
+ end
+
+ otfregister {
+ name = "sbix",
+ description = "sbix glyphs",
+ manipulators = {
+ base = initializepng,
+ node = initializepng,
+ }
+ }
+
+ otfregister {
+ name = "cblc",
+ description = "cblc glyphs",
+ manipulators = {
+ base = initializepng,
+ node = initializepng,
+ }
+ }
+
+end
+
+do
+
+ -- I need to check jpeg and such but will do that when I run into
+ -- it.
+
+ local function initializecolor(tfmdata,kind,value)
+ if value == "auto" then
+ return
+ initializeoverlay(tfmdata,kind,value) or
+ initializesvg(tfmdata,kind,value) or
+ initializepng(tfmdata,kind,value)
+ elseif value == "overlay" then
+ return initializeoverlay(tfmdata,kind,value)
+ elseif value == "svg" then
+ return initializesvg(tfmdata,kind,value)
+ elseif value == "png" or value == "bitmap" then
+ return initializepng(tfmdata,kind,value)
+ else
+ -- forget about it
+ end
+ end
+
+ otfregister {
+ name = "color",
+ description = "color glyphs",
+ manipulators = {
+ base = initializecolor,
+ node = initializecolor,
+ }
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ota.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-ota.lmt
new file mode 100644
index 00000000000..6475c57e64b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ota.lmt
@@ -0,0 +1,580 @@
+if not modules then modules = { } end modules ['font-ota'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- context only
+
+local type = type
+local setmetatableindex = table.setmetatableindex
+
+if not trackers then trackers = { register = function() end } end
+
+----- trace_analyzing = false trackers.register("otf.analyzing", function(v) trace_analyzing = v end)
+
+local fonts, nodes, node = fonts, nodes, node
+
+local allocate = utilities.storage.allocate
+
+local otf = fonts.handlers.otf
+
+local analyzers = fonts.analyzers
+local initializers = allocate()
+local methods = allocate()
+
+analyzers.initializers = initializers
+analyzers.methods = methods
+
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getprev = nuts.getprev
+local getprop = nuts.getprop
+local setprop = nuts.setprop
+local getsubtype = nuts.getsubtype
+local getchar = nuts.getchar
+local ischar = nuts.ischar
+local isnextchar = nuts.isnextchar
+----- isprevchar = nuts.isprevchar
+
+local end_of_math = nuts.end_of_math
+
+local nodecodes = nodes.nodecodes
+local disc_code = nodecodes.disc
+local math_code = nodecodes.math
+
+local fontdata = fonts.hashes.identifiers
+local descriptiondata = fonts.hashes.descriptions
+local categories = characters and characters.categories or { } -- sorry, only in context
+local chardata = characters and characters.data
+
+local otffeatures = fonts.constructors.features.otf
+local registerotffeature = otffeatures.register
+
+--[[ldx--
+
Analyzers run per script and/or language and are needed in order to
+process features right.
+--ldx]]--
+
+local setstate = nuts.setstate
+local getstate = nuts.getstate
+
+local classifiers = characters.classifiers
+
+-- never use these numbers directly
+
+local s_init = 1 local s_rphf = 7
+local s_medi = 2 local s_half = 8
+local s_fina = 3 local s_pref = 9
+local s_isol = 4 local s_blwf = 10
+local s_mark = 5 local s_pstf = 11
+local s_rest = 6
+
+local states = allocate {
+ init = s_init,
+ medi = s_medi,
+ med2 = s_medi,
+ fina = s_fina,
+ fin2 = s_fina,
+ fin3 = s_fina,
+ isol = s_isol,
+ mark = s_mark,
+ rest = s_rest,
+ rphf = s_rphf,
+ half = s_half,
+ pref = s_pref,
+ blwf = s_blwf,
+ pstf = s_pstf,
+}
+
+local features = allocate {
+ init = s_init,
+ medi = s_medi,
+ med2 = s_medi,
+ fina = s_fina,
+ fin2 = s_fina,
+ fin3 = s_fina,
+ isol = s_isol,
+ -- mark = s_mark,
+ -- rest = s_rest,
+ rphf = s_rphf,
+ half = s_half,
+ pref = s_pref,
+ blwf = s_blwf,
+ pstf = s_pstf,
+}
+
+local mappers = allocate {
+ l = s_init, -- left
+ d = s_medi, -- double
+ c = s_medi, -- joiner
+ r = s_fina, -- right
+ u = s_isol, -- nonjoiner
+}
+
+analyzers.states = states
+analyzers.features = features
+analyzers.useunicodemarks = false
+
+if not classifiers then
+
+ -- why not just always use categories[k] = "mn"
+
+ local f_arabic, l_arabic = characters.blockrange("arabic")
+ local f_syriac, l_syriac = characters.blockrange("syriac")
+ local f_mandiac, l_mandiac = characters.blockrange("mandiac")
+ local f_nko, l_nko = characters.blockrange("nko")
+ local f_ext_a, l_ext_a = characters.blockrange("arabicextendeda")
+
+ classifiers = setmetatableindex(function(t,k)
+ if type(k) == "number" then
+ local c = chardata[k]
+ local v = false
+ if c then
+ local arabic = c.arabic
+ if arabic then
+ v = mappers[arabic]
+ if not v then
+ log.report("analyze","error in mapping arabic %C",k)
+ -- error
+ v = false
+ end
+ elseif (k >= f_arabic and k <= l_arabic) or
+ (k >= f_syriac and k <= l_syriac) or
+ (k >= f_mandiac and k <= l_mandiac) or
+ (k >= f_nko and k <= l_nko) or
+ (k >= f_ext_a and k <= l_ext_a) then
+ if categories[k] == "mn" then
+ v = s_mark
+ else
+ v = s_rest
+ end
+ end
+ end
+ t[k] = v
+ return v
+ end
+ end)
+
+ characters.classifiers = classifiers
+
+end
+
+-- todo: analyzers per script/lang, cross font, so we need an font id hash -> script
+-- e.g. latin -> hyphenate, arab -> 1/2/3 analyze -- its own namespace
+
+local is_letter = characters.is_letter
+local is_mark = characters.is_mark
+
+function analyzers.setstate(head,font) -- latin
+ local useunicodemarks = analyzers.useunicodemarks
+ local descriptions = descriptiondata[font]
+ local first = false
+ local last = false
+ local current = head
+ local done = false
+ -- only letters
+ while current do
+ -- local char, id = ischar(current,font)
+ local nxt, char, id = isnextchar(current,font)
+ if char then
+ if not getstate(current) then
+ -- local d = descriptions[char]
+ -- if d then
+ -- if d.class == "mark" or (useunicodemarks and categories[char] == "mn") then
+ if is_mark[char] then
+ setstate(current,s_mark)
+ elseif is_letter[char] then
+ if first then
+ setstate(current,s_medi)
+ else
+ setstate(current,s_init)
+ first = current
+ done = true
+ end
+ last = current
+ else
+ goto PICKUP
+ end
+ goto NEXT
+ -- end
+ end
+ ::PICKUP::
+ if first then
+ setstate(last,first == last and s_isol or s_fina)
+ end
+ first = false
+ elseif char == false then
+ -- other font
+ if first then
+ setstate(last,first == last and s_isol or s_fina)
+ end
+ first = false
+ if id == math_code then
+ -- current = end_of_math(current)
+ nxt = getnext(end_of_math(current))
+ end
+ elseif id == disc_code then
+ -- always in the middle .. it doesn't make much sense to assign a property
+ -- here ... we might at some point decide to flag the components when present
+ -- but even then it's kind of bogus
+ setstate(current,s_medi)
+ last = current
+ else -- finish
+ if first then
+ setstate(last,first == last and s_isol or s_fina)
+ end
+ first = false
+ if id == math_code then
+ current = end_of_math(current)
+ end
+ end
+ ::NEXT::
+ -- current = getnext(current)
+ current = nxt
+ end
+ if first then
+ setstate(last,first == last and s_isol or s_fina)
+ end
+ return head, done
+end
+
+-- in the future we will use language/script attributes instead of the
+-- font related value, but then we also need dynamic features which is
+-- somewhat slower; and .. we need a chain of them
+
+local function analyzeinitializer(tfmdata,value) -- attr
+ local script, language = otf.scriptandlanguage(tfmdata) -- attr
+ local action = initializers[script]
+ if not action then
+ -- skip
+ elseif type(action) == "function" then
+ return action(tfmdata,value)
+ else
+ local action = action[language]
+ if action then
+ return action(tfmdata,value)
+ end
+ end
+end
+
+local function analyzeprocessor(head,font,attr)
+ local tfmdata = fontdata[font]
+ local script, language = otf.scriptandlanguage(tfmdata,attr)
+ local action = methods[script]
+ if not action then
+ -- skip
+ elseif type(action) == "function" then
+ return action(head,font,attr)
+ else
+ action = action[language]
+ if action then
+ return action(head,font,attr)
+ end
+ end
+ return head, false
+end
+
+registerotffeature {
+ name = "analyze",
+ description = "analysis of character classes",
+ default = true,
+ initializers = {
+ node = analyzeinitializer,
+ },
+ processors = {
+ position = 1,
+ node = analyzeprocessor,
+ }
+}
+
+-- latin
+
+methods.latn = analyzers.setstate
+-------.dflt = analyzers.setstate % can be an option or just the default
+
+local arab_warned = { }
+
+local function warning(current,what)
+ local char = getchar(current)
+ if not arab_warned[char] then
+ log.report("analyze","arab: character %C has no %a class",char,what)
+ arab_warned[char] = true
+ end
+end
+
+-- we can also use this trick for devanagari
+
+function methods.arab(head,font,attr)
+ local first, last, c_first, c_last
+ local current = head
+ local done = false
+ current = tonut(current)
+ while current do
+ -- local char, id = ischar(current,font)
+ local nxt, char, id = isnextchar(current,font)
+ if char and not getstate(current) then
+ done = true
+ local classifier = classifiers[char]
+ if not classifier then
+ if last then
+ if c_last == s_medi or c_last == s_fina then
+ setstate(last,s_fina)
+ else
+ warning(last,"fina")
+ setstate(last,s_error)
+ end
+ first = nil
+ last = nil
+ elseif first then
+ if c_first == s_medi or c_first == s_fina then
+ setstate(first,s_isol)
+ else
+ warning(first,"isol")
+ setstate(first,s_error)
+ end
+ first = nil
+ end
+ elseif classifier == s_mark then
+ setstate(current,s_mark)
+ elseif classifier == s_isol then
+ if last then
+ if c_last == s_medi or c_last == s_fina then
+ setstate(last,s_fina)
+ else
+ warning(last,"fina")
+ setstate(last,s_error)
+ end
+ first = nil
+ last = nil
+ elseif first then
+ if c_first == s_medi or c_first == s_fina then
+ setstate(first,s_isol)
+ else
+ warning(first,"isol")
+ setstate(first,s_error)
+ end
+ first = nil
+ end
+ setstate(current,s_isol)
+ elseif classifier == s_medi then
+ if first then
+ last = current
+ c_last = classifier
+ setstate(current,s_medi)
+ else
+ setstate(current,s_init)
+ first = current
+ c_first = classifier
+ end
+ elseif classifier == s_fina then
+ if last then
+ if getstate(last) ~= s_init then
+ setstate(last,s_medi)
+ end
+ setstate(current,s_fina)
+ first, last = nil, nil
+ elseif first then
+ -- if getstate(first) ~= s_init then
+ -- -- needs checking
+ -- setstate(first,s_medi)
+ -- end
+ setstate(current,s_fina)
+ first = nil
+ else
+ setstate(current,s_isol)
+ end
+ else -- classifier == s_rest
+ setstate(current,s_rest)
+ if last then
+ if c_last == s_medi or c_last == s_fina then
+ setstate(last,s_fina)
+ else
+ warning(last,"fina")
+ setstate(last,s_error)
+ end
+ first = nil
+ last = nil
+ elseif first then
+ if c_first == s_medi or c_first == s_fina then
+ setstate(first,s_isol)
+ else
+ warning(first,"isol")
+ setstate(first,s_error)
+ end
+ first = nil
+ end
+ end
+ else
+ if last then
+ if c_last == s_medi or c_last == s_fina then
+ setstate(last,s_fina)
+ else
+ warning(last,"fina")
+ setstate(last,s_error)
+ end
+ first = nil
+ last = nil
+ elseif first then
+ if c_first == s_medi or c_first == s_fina then
+ setstate(first,s_isol)
+ else
+ warning(first,"isol")
+ setstate(first,s_error)
+ end
+ first = nil
+ end
+ if id == math_code then -- a bit duplicate as we test for glyphs twice
+ -- current = end_of_math(current)
+ nxt = getnext(end_of_math(current))
+ end
+ end
+ -- current = getnext(current)
+ current = nxt
+ end
+ if last then
+ if c_last == s_medi or c_last == s_fina then
+ setstate(last,s_fina)
+ else
+ warning(last,"fina")
+ setstate(last,s_error)
+ end
+ elseif first then
+ if c_first == s_medi or c_first == s_fina then
+ setstate(first,s_isol)
+ else
+ warning(first,"isol")
+ setstate(first,s_error)
+ end
+ end
+ return head, done
+end
+
+methods.syrc = methods.arab
+methods.mand = methods.arab
+methods.nko = methods.arab
+
+-- a quick first attemp .. more later
+
+do
+
+ -- https://github.com/n8willis/opentype-shaping-documents/blob/master/opentype-shaping-mongolian.md#joining-properties
+ -- todo syrc
+
+ local joining = setmetatableindex(function(t,k)
+ if type(k) == "number" then
+ local c = chardata[k]
+ local v = false
+ if c then
+ local mongolian = c.mongolian
+ --
+ v = mongolian
+ end
+ t[k] = v
+ return v
+ end
+ end)
+
+ function methods.mong(head,font,attr)
+ local first, last
+ local current = head
+ local done = false
+ local prevjoin = nil
+ local prestate = nil
+ current = tonut(current)
+
+ local function wrapup()
+ if last then
+ if last ~= first then
+ local s = getstate(last)
+ if s == s_medi then
+ setstate(last,s_fina)
+ elseif s == s_init then
+ setstate(last,s_isol)
+ end
+ end
+ last = nil
+ first = nil
+ prevjoin = nil
+ prestate = nil
+ end
+ end
+
+ while current do
+ -- local char, id = ischar(current,font)
+ local nxt, char, id = isnextchar(current,font)
+ if char and not getstate(current) then
+ local currjoin = joining[char]
+ done = true
+ if not last then
+ setstate(current,s_isol)
+ prevjoin = currjoin
+ first = current
+ last = current
+ prevstate = s_isol
+ elseif currjoin == "t" then -- transparent
+ -- keep state
+ last = current
+ elseif prevjoin == "d" or prevjoin == "jc" or prevjoin == "l" then
+ if currjoin == "d" or prevjoin == "jc" or prevjoin == "r" then
+ local s = getstate(last)
+ if s == s_isol then
+ setstate(last,s_init)
+ elseif s == s_fina then
+ setstate(last,s_medi)
+ end
+ setstate(current,s_fina)
+ prevstate = s_fina
+ elseif prevjoin == "nj" or prevjoin == "l" then
+ local s = getstate(last)
+ if s == s_medi then
+ setstate(last,s_fina)
+ elseif s == s_init then
+ setstate(last,s_isol)
+ end
+ setstate(current,s_isol)
+ prevstate = s_isol
+ end
+ prevjoin = currjoin
+ last = current
+ elseif prevjoin == "nj" or prevjoin == "r" then
+ if s == s_medi then
+ setstate(last,s_fina)
+ elseif s == s_init then
+ setstate(last,s_isol)
+ end
+ setstate(current,s_isol)
+ prevjoin = currjoin
+ prevstate = s_isol
+ last = current
+ elseif last then
+ wrapup()
+ end
+ else
+ if last then
+ wrapup()
+ end
+ if id == math_code then -- a bit duplicate as we test for glyphs twice
+ -- current = end_of_math(current)
+ nxt = getnext(end_of_math(current))
+ end
+ end
+ -- current = getnext(current)
+ current = nxt
+ end
+ if last then
+ wrapup()
+ end
+ return head, done
+ end
+
+end
+
+directives.register("otf.analyze.useunicodemarks",function(v)
+ analyzers.useunicodemarks = v
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-otj.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-otj.lmt
new file mode 100644
index 00000000000..e9e9d524e4f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-otj.lmt
@@ -0,0 +1,2556 @@
+if not modules then modules = { } end modules ['font-otj'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to font-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- This property based variant is not faster but looks nicer than the attribute one. We
+-- need to use rawget (which is about 4 times slower than a direct access but we cannot
+-- get/set that one for our purpose! This version does a bit more with discretionaries
+-- (and Kai has tested it with his collection of weird fonts.)
+
+-- There is some duplicate code here (especially in the the pre/post/replace branches) but
+-- we go for speed. We could store a list of glyph and mark nodes when registering but it's
+-- cleaner to have an identification pass here. Also, I need to keep tracing in mind so
+-- being too clever here is dangerous.
+
+-- As we have a rawget on properties we don't need one on injections.
+
+-- The use_advance code was just a test and is meant for testing and manuals. There is no
+-- performance (or whatever) gain and using kerns is somewhat cleaner (at least for now).
+
+-- An alternative is to have a list per base of all marks and then do a run over the node
+-- list that resolves the accumulated l/r/x/y and then do an inject pass.
+
+-- The thing with these positioning options is that it is not clear what Uniscribe does with
+-- the 2rl flag and we keep oscillating a between experiments.
+
+-- Beware: combining advance with cursive and marks can be a problem because marks have no
+-- dimensions .. maybe we need a special field for that ... the advance also sets the apply
+-- x offset flag!
+
+if not nodes.properties then return end
+
+local next, rawget, tonumber = next, rawget, tonumber
+local fastcopy = table.fastcopy
+
+local registertracker = trackers.register
+local registerdirective = directives.register
+
+local trace_injections = false registertracker("fonts.injections", function(v) trace_injections = v end)
+local trace_marks = false registertracker("fonts.injections.marks", function(v) trace_marks = v end)
+local trace_cursive = false registertracker("fonts.injections.cursive", function(v) trace_cursive = v end)
+local trace_spaces = false registertracker("fonts.injections.spaces", function(v) trace_spaces = v end)
+
+-- local fix_cursive_marks = false
+--
+-- registerdirective("fonts.injections.fixcursivemarks", function(v)
+-- fix_cursive_marks = v
+-- end)
+
+local report_injections = logs.reporter("fonts","injections")
+local report_spaces = logs.reporter("fonts","spaces")
+
+local attributes, nodes, node = attributes, nodes, node
+
+fonts = fonts
+local hashes = fonts.hashes
+local fontdata = hashes.identifiers
+local fontmarks = hashes.marks
+local parameters = fonts.hashes.parameters -- not in generic
+----- resources = fonts.hashes.resources -- not in generic
+
+nodes.injections = nodes.injections or { }
+local injections = nodes.injections
+
+local tracers = nodes.tracers
+local setcolor = tracers and tracers.colors.set
+local resetcolor = tracers and tracers.colors.reset
+
+local nodecodes = nodes.nodecodes
+local glyph_code = nodecodes.glyph
+local disc_code = nodecodes.disc
+local kern_code = nodecodes.kern
+local glue_code = nodecodes.glue
+
+local nuts = nodes.nuts
+local nodepool = nuts.pool
+
+local tonode = nuts.tonode
+local tonut = nuts.tonut
+
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getfont = nuts.getfont
+local getchar = nuts.getchar
+local setchar = nuts.setchar
+----- getxoffset = nuts.getxoffset
+----- getyoffset = nuts.getyoffset
+local getoffsets = nuts.getoffsets
+local getxscale = nuts.getxscale
+local getyscale = nuts.getyscale
+local getxyscales = nuts.getxyscales
+local xscaled = nuts.xscaled
+local yscaled = nuts.yscaled
+local getboth = nuts.getboth
+local getdisc = nuts.getdisc
+local setdisc = nuts.setdisc
+local setoffsets = nuts.setoffsets
+local addxoffset = nuts.addxoffset
+local addyoffset = nuts.addyoffset
+local ischar = nuts.ischar
+local isnextchar = nuts.isnextchar
+local getkern = nuts.getkern
+local setkern = nuts.setkern
+local setlink = nuts.setlink
+local setwidth = nuts.setwidth
+local getwidth = nuts.getwidth
+local addxymargins = nuts.addxymargins -- we delegate scaling
+local copynode = nuts.copy
+
+local nextchar = nuts.traversers.char
+local nextglue = nuts.traversers.glue
+
+local insert_node_before = nuts.insert_before
+local insert_node_after = nuts.insert_after
+
+local properties = nodes.properties.data
+
+local fontkern = nuts.pool and nuts.pool.fontkern
+local italickern = nuts.pool and nuts.pool.italickern
+
+local useitalickerns = false
+local useadvance = false
+local usezwjkerns = true -- when useadvance
+
+directives.register("fonts.injections.useitalics", function(v)
+ if v then
+ report_injections("using italics for space kerns (tracing only)")
+ end
+ useitalickerns = v
+end)
+
+registerdirective("fonts.injections.method", function(v)
+ useadvance = v == "advance"
+end)
+
+function injections.installnewkern() end -- obsolete
+
+local nofregisteredkerns = 0
+local nofregisteredpositions = 0
+local nofregisteredmarks = 0
+local nofregisteredcursives = 0
+local keepregisteredcounts = false
+
+function injections.keepcounts()
+ keepregisteredcounts = true
+end
+
+function injections.resetcounts()
+ nofregisteredkerns = 0
+ nofregisteredpositions = 0
+ nofregisteredmarks = 0
+ nofregisteredcursives = 0
+ keepregisteredcounts = false
+end
+
+-- We need to make sure that a possible metatable will not kick in unexpectedly.
+
+function injections.reset(n)
+ local p = rawget(properties,n)
+ if p then
+ p.injections = false -- { } -- nil should work too as we use rawget
+ else
+ properties[n] = false -- { injections = { } } -- nil should work too as we use rawget
+ end
+end
+
+function injections.copy(target,source)
+ local sp = rawget(properties,source)
+ if sp then
+ local tp = rawget(properties,target)
+ local si = sp.injections
+ if si then
+ si = fastcopy(si)
+ if tp then
+ tp.injections = si
+ else
+ properties[target] = {
+ injections = si,
+ }
+ end
+ elseif tp then
+ tp.injections = false -- { }
+ else
+ properties[target] = { injections = { } }
+ end
+ else
+ local tp = rawget(properties,target)
+ if tp then
+ tp.injections = false -- { }
+ else
+ properties[target] = false -- { injections = { } }
+ end
+ end
+end
+
+function injections.setligaindex(n,index) -- todo: don't set when 0
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections
+ if i then
+ i.ligaindex = index
+ else
+ p.injections = {
+ ligaindex = index
+ }
+ end
+ else
+ properties[n] = {
+ injections = {
+ ligaindex = index
+ }
+ }
+ end
+end
+
+function injections.getligaindex(n,default)
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections
+ if i then
+ return i.ligaindex or default
+ end
+ end
+ return default
+end
+
+function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext,r2lflag)
+
+ -- The standard says something about the r2lflag related to the first in a series:
+ --
+ -- When this bit is set, the last glyph in a given sequence to which the cursive
+ -- attachment lookup is applied, will be positioned on the baseline.
+ --
+ -- But it looks like we don't need to consider it.
+
+ local dx = factor*(exit[1]-entry[1])
+ local dy = -factor*(exit[2]-entry[2])
+ local ws = tfmstart.width
+ local wn = tfmnext.width
+ nofregisteredcursives = nofregisteredcursives + 1
+ if rlmode < 0 then
+ dx = -(dx + wn)
+ else
+ dx = dx - ws
+ end
+ if dx == 0 then
+ -- get rid of funny -0
+ dx = 0
+ end
+ --
+ local p = rawget(properties,start)
+ if p then
+ local i = p.injections
+ if i then
+ i.cursiveanchor = true
+ else
+ p.injections = {
+ cursiveanchor = true,
+ }
+ end
+ else
+ properties[start] = {
+ injections = {
+ cursiveanchor = true,
+ },
+ }
+ end
+ local p = rawget(properties,nxt)
+ if p then
+ local i = p.injections
+ if i then
+ i.cursivex = dx
+ i.cursivey = dy
+ else
+ p.injections = {
+ cursivex = dx,
+ cursivey = dy,
+ }
+ end
+ else
+ properties[nxt] = {
+ injections = {
+ cursivex = dx,
+ cursivey = dy,
+ },
+ }
+ end
+ return dx, dy, nofregisteredcursives
+end
+
+-- kind: 0=single 1=first of pair, 2=second of pair
+
+function injections.setposition(kind,current,factor,rlmode,spec,injection)
+ local x = factor * (spec[1] or 0)
+ local y = factor * (spec[2] or 0)
+ local w = factor * (spec[3] or 0)
+ local h = factor * (spec[4] or 0)
+ if x ~= 0 or w ~= 0 or y ~= 0 or h ~= 0 then -- okay?
+ local yoffset = y - h
+ local leftkern = x -- both kerns are set in a pair kern compared
+ local rightkern = w - x -- to normal kerns where we set only leftkern
+ if leftkern ~= 0 or rightkern ~= 0 or yoffset ~= 0 then
+ nofregisteredpositions = nofregisteredpositions + 1
+ if rlmode and rlmode < 0 then
+ leftkern, rightkern = rightkern, leftkern
+ end
+ if not injection then
+ injection = "injections"
+ end
+ local p = rawget(properties,current)
+ if p then
+ local i = p[injection]
+ if i then
+ if leftkern ~= 0 then
+ i.leftkern = (i.leftkern or 0) + leftkern
+ end
+ if rightkern ~= 0 then
+ i.rightkern = (i.rightkern or 0) + rightkern
+ end
+ if yoffset ~= 0 then
+ i.yoffset = (i.yoffset or 0) + yoffset
+ end
+ elseif leftkern ~= 0 or rightkern ~= 0 then
+ p[injection] = {
+ leftkern = leftkern,
+ rightkern = rightkern,
+ yoffset = yoffset,
+ }
+ else
+ p[injection] = {
+ yoffset = yoffset,
+ }
+ end
+ elseif leftkern ~= 0 or rightkern ~= 0 then
+ properties[current] = {
+ [injection] = {
+ leftkern = leftkern,
+ rightkern = rightkern,
+ yoffset = yoffset,
+ },
+ }
+ else
+ properties[current] = {
+ [injection] = {
+ yoffset = yoffset,
+ },
+ }
+ end
+ return x, y, w, h, nofregisteredpositions
+ end
+ end
+ return x, y, w, h -- no bound
+end
+
+-- The next one is used for simple kerns coming from a truetype kern table. The r2l
+-- variant variant needs checking but it is unlikely that a r2l script uses thsi
+-- feature.
+
+function injections.setkern(current,factor,rlmode,x,injection)
+ local dx = factor * x
+ if dx ~= 0 then
+ nofregisteredkerns = nofregisteredkerns + 1
+ local p = rawget(properties,current)
+ if not injection then
+ injection = "injections"
+ end
+ if p then
+ local i = p[injection]
+ if i then
+ i.leftkern = dx + (i.leftkern or 0)
+ else
+ p[injection] = {
+ leftkern = dx,
+ }
+ end
+ else
+ properties[current] = {
+ [injection] = {
+ leftkern = dx,
+ },
+ }
+ end
+ return dx, nofregisteredkerns
+ else
+ return 0, 0
+ end
+end
+
+-- This one is an optimization of pairs where we have only a "w" entry. This one is
+-- potentially different from the previous one wrt r2l. It needs checking. The
+-- optimization relates to smaller tma files.
+
+function injections.setmove(current,factor,rlmode,x,injection)
+ local dx = factor * x
+ if dx ~= 0 then
+ nofregisteredkerns = nofregisteredkerns + 1
+ local p = rawget(properties,current)
+ if not injection then
+ injection = "injections"
+ end
+ if rlmode and rlmode < 0 then
+ -- we need to swap with a single so then we also need to to it here
+ -- as move is just a simple single
+ if p then
+ local i = p[injection]
+ if i then
+ i.rightkern = dx + (i.rightkern or 0)
+ else
+ p[injection] = {
+ rightkern = dx,
+ }
+ end
+ else
+ properties[current] = {
+ [injection] = {
+ rightkern = dx,
+ },
+ }
+ end
+ else
+ if p then
+ local i = p[injection]
+ if i then
+ i.leftkern = dx + (i.leftkern or 0)
+ else
+ p[injection] = {
+ leftkern = dx,
+ }
+ end
+ else
+ properties[current] = {
+ [injection] = {
+ leftkern = dx,
+ },
+ }
+ end
+ end
+ return dx, nofregisteredkerns
+ else
+ return 0, 0
+ end
+end
+
+function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase,mkmk,checkmark) -- ba=baseanchor, ma=markanchor
+ local dx = factor*(ba[1]-ma[1])
+ local dy = factor*(ba[2]-ma[2])
+ nofregisteredmarks = nofregisteredmarks + 1
+ if rlmode >= 0 then
+ dx = tfmbase.width - dx -- see later commented ox
+ end
+ local p = rawget(properties,start)
+ -- hm, dejavu serif does a sloppy mark2mark before mark2base
+ if p then
+ local i = p.injections
+ if i then
+ if i.markmark then
+ -- out of order mkmk: yes or no or option
+ else
+ -- if dx ~= 0 then
+ -- i.markx = dx
+ -- end
+ -- if y ~= 0 then
+ -- i.marky = dy
+ -- end
+ -- if rlmode then
+ -- i.markdir = rlmode
+ -- end
+ i.markx = dx
+ i.marky = dy
+ i.markdir = rlmode or 0
+ i.markbase = nofregisteredmarks
+ i.markbasenode = base
+ i.markmark = mkmk
+ i.checkmark = checkmark
+ end
+ else
+ p.injections = {
+ markx = dx,
+ marky = dy,
+ markdir = rlmode or 0,
+ markbase = nofregisteredmarks,
+ markbasenode = base,
+ markmark = mkmk,
+ checkmark = checkmark,
+ }
+ end
+ else
+ properties[start] = {
+ injections = {
+ markx = dx,
+ marky = dy,
+ markdir = rlmode or 0,
+ markbase = nofregisteredmarks,
+ markbasenode = base,
+ markmark = mkmk,
+ checkmark = checkmark,
+ },
+ }
+ end
+ return dx, dy, nofregisteredmarks
+end
+
+local function dir(n)
+ return (n and n<0 and "r-to-l") or (n and n>0 and "l-to-r") or "unset"
+end
+
+local function showchar(n,nested)
+ local char = getchar(n)
+ report_injections("%wfont %s, char %U, glyph %c",nested and 2 or 0,getfont(n),char,char)
+end
+
+local function show(n,what,nested,symbol)
+ if n then
+ local p = rawget(properties,n)
+ if p then
+ local i = p[what]
+ if i then
+ local leftkern = i.leftkern or 0
+ local rightkern = i.rightkern or 0
+ local yoffset = i.yoffset or 0
+ local markx = i.markx or 0
+ local marky = i.marky or 0
+ local markdir = i.markdir or 0
+ local markbase = i.markbase or 0
+ local cursivex = i.cursivex or 0
+ local cursivey = i.cursivey or 0
+ local ligaindex = i.ligaindex or 0
+ local cursbase = i.cursiveanchor
+ local margin = nested and 4 or 2
+ --
+ if rightkern ~= 0 or yoffset ~= 0 then
+ report_injections("%w%s pair: lx %p, rx %p, dy %p",margin,symbol,leftkern,rightkern,yoffset)
+ elseif leftkern ~= 0 then
+ report_injections("%w%s kern: dx %p",margin,symbol,leftkern)
+ end
+ if markx ~= 0 or marky ~= 0 or markbase ~= 0 then
+ report_injections("%w%s mark: dx %p, dy %p, dir %s, base %s",margin,symbol,markx,marky,markdir,markbase ~= 0 and "yes" or "no")
+ end
+ if cursivex ~= 0 or cursivey ~= 0 then
+ if cursbase then
+ report_injections("%w%s curs: base dx %p, dy %p",margin,symbol,cursivex,cursivey)
+ else
+ report_injections("%w%s curs: dx %p, dy %p",margin,symbol,cursivex,cursivey)
+ end
+ elseif cursbase then
+ report_injections("%w%s curs: base",margin,symbol)
+ end
+ if ligaindex ~= 0 then
+ report_injections("%w%s liga: index %i",margin,symbol,ligaindex)
+ end
+ end
+ end
+ end
+end
+
+local function showsub(n,what,where)
+ report_injections("begin subrun: %s",where)
+ for n in nextchar, n do
+ showchar(n,where)
+ show(n,what,where," ")
+ end
+ report_injections("end subrun")
+end
+
+local function trace(head,where)
+ report_injections()
+ report_injections("begin run %s: %s kerns, %s positions, %s marks and %s cursives registered",
+ where or "",nofregisteredkerns,nofregisteredpositions,nofregisteredmarks,nofregisteredcursives)
+ local n = head
+ while n do
+ local id = getid(n)
+ if id == glyph_code then
+ showchar(n)
+ show(n,"injections",false," ")
+ show(n,"preinjections",false,"<")
+ show(n,"postinjections",false,">")
+ show(n,"replaceinjections",false,"=")
+ show(n,"emptyinjections",false,"*")
+ elseif id == disc_code then
+ local pre, post, replace = getdisc(n)
+ if pre then
+ showsub(pre,"preinjections","pre")
+ end
+ if post then
+ showsub(post,"postinjections","post")
+ end
+ if replace then
+ showsub(replace,"replaceinjections","replace")
+ end
+ show(n,"emptyinjections",false,"*")
+ end
+ n = getnext(n)
+ end
+ report_injections("end run")
+end
+
+local function show_result(head)
+ local current = head
+ local skipping = false
+ while current do
+ local id = getid(current)
+ if id == glyph_code then
+ local w = getwidth(current)
+ local x, y = getoffsets(current)
+ report_injections("char: %C, width %p, xoffset %p, yoffset %p",getchar(current),w,x,y)
+ skipping = false
+ elseif id == kern_code then
+ report_injections("kern: %p",getkern(current))
+ skipping = false
+ elseif not skipping then
+ report_injections()
+ skipping = true
+ end
+ current = getnext(current)
+ end
+ report_injections()
+end
+
+-- G +D-pre G
+-- D-post+
+-- +D-replace+
+--
+-- G +D-pre +D-pre
+-- D-post +D-post
+-- +D-replace +D-replace
+
+-- Beware! pre/post/replace can have non glyphs too
+
+-- local function inject_kerns_only(head,where)
+-- if trace_injections then
+-- trace(head,"kerns")
+-- end
+-- local current = head
+-- local prev -- = nil
+-- local prevdisc -- = nil
+-- local pre -- = nil -- saves a lookup
+-- local post -- = nil -- saves a lookup
+-- local replace -- = nil -- saves a lookup
+-- local pretail -- = nil -- saves a lookup
+-- local posttail -- = nil -- saves a lookup
+-- local replacetail -- = nil -- saves a lookup
+-- while current do
+-- local next, char, id = isnextchar(current)
+-- if char then
+-- local p = rawget(properties,current)
+-- if p then
+-- local i = p.injections
+-- if i then
+-- -- left|glyph|right
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- if useadvance then
+-- addmargins(current,-leftkern)
+-- elseif prev and getid(prev) == glue_code then
+-- if useitalickerns then
+-- head = insert_node_before(head,current,italickern(leftkern))
+-- else
+-- setwidth(prev, getwidth(prev) + leftkern)
+-- end
+-- else
+-- head = insert_node_before(head,current,fontkern(leftkern))
+-- end
+-- end
+-- end
+-- if prevdisc then
+-- local done = false
+-- if post then
+-- local i = p.postinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- if useadvance then
+-- addmargins(posttail,false,-leftkern)
+-- else
+-- setlink(posttail,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- if replace then
+-- local i = p.replaceinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- if useadvance then
+-- addmargins(replacetail,false,-leftkern)
+-- else
+-- setlink(replacetail,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- else
+-- local i = p.emptyinjections
+-- if i then
+-- -- glyph|disc|glyph (special case)
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- -- if useadvance then
+-- -- add zwj with offset
+-- -- else
+-- replace = fontkern(leftkern)
+-- done = true
+-- -- end
+-- end
+-- end
+-- end
+-- if done then
+-- setdisc(prevdisc,pre,post,replace)
+-- end
+-- end
+-- end
+-- prevdisc = nil
+-- -- prevglyph = current
+-- elseif char == false then
+-- -- other font
+-- prevdisc = nil
+-- -- prevglyph = current
+-- elseif id == disc_code then
+-- pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+-- local done = false
+-- if pre then
+-- -- left|pre glyphs|right
+-- for n in nextchar, pre do
+-- local p = rawget(properties,n)
+-- if p then
+-- local i = p.injections or p.preinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(n,leftkern)
+-- if useadvance then
+-- addmargins(n,-leftkern)
+-- else
+-- pre = insert_node_before(pre,n,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if post then
+-- -- left|post glyphs|right
+-- for n in nextchar, post do
+-- local p = rawget(properties,n)
+-- if p then
+-- local i = p.injections or p.postinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(n,leftkern)
+-- if useadvance then
+-- addmargins(n,-leftkern)
+-- else
+-- post = insert_node_before(post,n,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if replace then
+-- -- left|replace glyphs|right
+-- for n in nextchar, replace do
+-- local p = rawget(properties,n)
+-- if p then
+-- local i = p.injections or p.replaceinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(n,leftkern)
+-- if useadvance then
+-- addmargins(n,-leftkern)
+-- else
+-- replace = insert_node_before(replace,n,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if done then
+-- setdisc(current,pre,post,replace)
+-- end
+-- -- prevglyph = nil
+-- prevdisc = current
+-- else
+-- -- prevglyph = nil
+-- prevdisc = nil
+-- end
+-- prev = current
+-- current = next
+-- end
+-- --
+-- if keepregisteredcounts then
+-- keepregisteredcounts = false
+-- else
+-- nofregisteredkerns = 0
+-- end
+-- if trace_injections then
+-- show_result(head)
+-- end
+-- return head
+-- end
+
+local function inject_kerns_only_kerns(head,where)
+ if trace_injections then
+ trace(head,"kerns")
+ end
+ local current = head
+ local prev -- = nil
+ local prevdisc -- = nil
+ local pre -- = nil -- saves a lookup
+ local post -- = nil -- saves a lookup
+ local replace -- = nil -- saves a lookup
+ local pretail -- = nil -- saves a lookup
+ local posttail -- = nil -- saves a lookup
+ local replacetail -- = nil -- saves a lookup
+ while current do
+ local next, char, id = isnextchar(current)
+ if char then
+ local p = rawget(properties,current)
+ if p then
+ local i = p.injections
+ if i then
+ -- left|glyph|right
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ leftkern = xscaled(current,leftkern)
+ if prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev,getwidth(prev) + leftkern)
+ end
+ else
+ head = insert_node_before(head,current,fontkern(leftkern))
+ end
+ end
+ end
+ if prevdisc then
+ local done = false
+ if post then
+ local i = p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ setlink(posttail,fontkern(xscaled(current,leftkern)))
+ done = true
+ end
+ end
+ end
+ if replace then
+ local i = p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ setlink(replacetail,fontkern(xscaled(current,leftkern)))
+ done = true
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ -- glyph|disc|glyph (special case)
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ replace = fontkern(xscaled(current,leftkern))
+ done = true
+ end
+ end
+ end
+ if done then
+ setdisc(prevdisc,pre,post,replace)
+ end
+ end
+ end
+ prevdisc = nil
+ -- prevglyph = current
+ elseif char == false then
+ -- other font
+ prevdisc = nil
+ -- prevglyph = current
+ elseif id == disc_code then
+ pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+ local done = false
+ if pre then
+ -- left|pre glyphs|right
+ for n in nextchar, pre do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.preinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ pre = insert_node_before(pre,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if post then
+ -- left|post glyphs|right
+ for n in nextchar, post do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ post = insert_node_before(post,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if replace then
+ -- left|replace glyphs|right
+ for n in nextchar, replace do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ replace = insert_node_before(replace,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if done then
+ setdisc(current,pre,post,replace)
+ end
+ -- prevglyph = nil
+ prevdisc = current
+ else
+ -- prevglyph = nil
+ prevdisc = nil
+ end
+ prev = current
+ current = next
+ end
+ --
+ if keepregisteredcounts then
+ keepregisteredcounts = false
+ else
+ nofregisteredkerns = 0
+ end
+ if trace_injections then
+ show_result(head)
+ end
+ return head
+end
+
+local function inject_kerns_only_margins(head,where)
+ if trace_injections then
+ trace(head,"kerns")
+ end
+ local current = head
+ local prevdisc -- = nil
+ local pre -- = nil -- saves a lookup
+ local post -- = nil -- saves a lookup
+ local replace -- = nil -- saves a lookup
+ local pretail -- = nil -- saves a lookup
+ local posttail -- = nil -- saves a lookup
+ local replacetail -- = nil -- saves a lookup
+ while current do
+ local next, char, id = isnextchar(current)
+ if char then
+ local p = rawget(properties,current)
+ if p then
+ if prevdisc then
+ if post then
+ local i = p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(posttail,false,-leftkern)
+ end
+ end
+ end
+ if replace then
+ local i = p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(replacetail,false,-leftkern)
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ if usezwjkerns then
+ replace = copynode(current)
+ setchar(replace,0x200D) -- zwj
+ addxymargins(replace,-leftkern)
+ else
+ replace = fontkern(xscaled(current,leftkern))
+ end
+ setdisc(prevdisc,pre,post,replace) -- setreplace
+ end
+ end
+ end
+ end
+ -- moved down so we can copy zwj
+ local i = p.injections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(current,-leftkern)
+ end
+ end
+ end
+ prevdisc = nil
+ elseif char == false then
+ prevdisc = nil
+ elseif id == disc_code then
+ pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+ if pre then
+ for n in nextchar, pre do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.preinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(n,-leftkern)
+ end
+ end
+ end
+ end
+ end
+ if post then
+ for n in nextchar, post do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(n,-leftkern)
+ end
+ end
+ end
+ end
+ end
+ if replace then
+ for n in nextchar, replace do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(n,-leftkern)
+ end
+ end
+ end
+ end
+ end
+ prevdisc = current
+ else
+ prevdisc = nil
+ end
+ current = next
+ end
+ if keepregisteredcounts then
+ keepregisteredcounts = false
+ else
+ nofregisteredkerns = 0
+ end
+ if trace_injections then
+ show_result(head)
+ end
+ return head
+end
+
+-- local function inject_positions_only(head,where)
+-- if trace_injections then
+-- trace(head,"positions")
+-- end
+-- local current = head
+-- local prev = nil
+-- local next = nil
+-- local prevdisc = nil
+-- local prevglyph = nil
+-- local pre = nil -- saves a lookup
+-- local post = nil -- saves a lookup
+-- local replace = nil -- saves a lookup
+-- local pretail = nil -- saves a lookup
+-- local posttail = nil -- saves a lookup
+-- local replacetail = nil -- saves a lookup
+-- while current do
+-- local next, char, id = isnextchar(current)
+-- if char then
+-- local p = rawget(properties,current)
+-- if p then
+-- local i = p.injections
+-- if i then
+-- -- left|glyph|right
+-- local yoffset = i.yoffset
+-- if yoffset and yoffset ~= 0 then
+-- -- use raise when advance
+-- addyoffset(current,yscaled(current,yoffset))
+-- end
+-- local leftkern = i.leftkern or 0
+-- local rightkern = i.rightkern or 0
+-- if leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- end
+-- if rightkern ~= 0 then
+-- rightkern = xscaled(current,rightkern)
+-- end
+-- if useadvance then
+-- if leftkern ~= 0 or rightkern ~= 0 then
+-- addmargins(current,-leftkern,-rightkern)
+-- end
+-- else
+-- if leftkern ~= 0 then
+-- if leftkern == -rightkern then
+-- addxoffset(current,leftkern)
+-- rightkern = 0
+-- elseif prev and getid(prev) == glue_code then
+-- if useitalickerns then
+-- head = insert_node_before(head,current,italickern(leftkern))
+-- else
+-- setwidth(prev,getwidth(prev)+leftkern)
+-- end
+-- else
+-- head = insert_node_before(head,current,fontkern(leftkern))
+-- end
+-- end
+-- if rightkern ~= 0 then
+-- if next and getid(next) == glue_code then
+-- if useitalickerns then
+-- insert_node_after(head,current,italickern(rightkern))
+-- else
+-- setwidth(next, getwidth(next)+rightkern)
+-- end
+-- else
+-- insert_node_after(head,current,fontkern(rightkern))
+-- end
+-- end
+-- end
+-- else
+-- local i = p.emptyinjections
+-- if i then
+-- -- glyph|disc|glyph (special case)
+-- local rightkern = i.rightkern
+-- if rightkern and rightkern ~= 0 then
+-- if next and getid(next) == disc_code then
+-- if replace then
+-- -- error, we expect an empty one
+-- else
+-- rightkern = xscaled(current,rightkern)
+-- replace = fontkern(rightkern) -- maybe also leftkern
+-- done = true --KE
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if prevdisc then
+-- local done = false
+-- if post then
+-- local i = p.postinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- if useadvance then
+-- addmargins(posttail,-leftkern)
+-- else
+-- setlink(posttail,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- if replace then
+-- local i = p.replaceinjections
+-- if i then
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- leftkern = xscaled(current,leftkern)
+-- if useadvance then
+-- addmargins(replacetail,-leftkern)
+-- else
+-- setlink(replacetail,fontkern(leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- else
+-- local i = p.emptyinjections
+-- if i then
+-- -- new .. okay?
+-- local leftkern = i.leftkern
+-- if leftkern and leftkern ~= 0 then
+-- replace = fontkern(xscaled(current,leftkern))
+-- done = true
+-- end
+-- end
+-- end
+-- if done then
+-- setdisc(prevdisc,pre,post,replace)
+-- end
+-- end
+-- end
+-- prevdisc = nil
+-- prevglyph = current
+-- elseif char == false then
+-- prevdisc = nil
+-- prevglyph = current
+-- elseif id == disc_code then
+-- pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+-- local done = false
+-- if pre then
+-- -- left|pre glyphs|right
+-- for n in nextchar, pre do
+-- local p = rawget(properties,n)
+-- if p then
+-- local i = p.injections or p.preinjections
+-- if i then
+-- local yoffset = i.yoffset
+-- local leftkern = i.leftkern or 0
+-- local rightkern = i.rightkern or 0
+-- if yoffset and yoffset ~= 0 then
+-- -- use raise when advance
+-- addyoffset(n,yscaled(n,yoffset))
+-- end
+-- if leftkern ~= 0 then
+-- leftkern = xscaled(n,leftkern)
+-- end
+-- if rightkern ~= 0 then
+-- rightkern = xscaled(n,rightkern)
+-- end
+-- if useadvance then
+-- if leftkern ~= 0 or rightkern ~= 0 then
+-- addmargins(pre,-leftkern,-rightkern)
+-- end
+-- else
+-- if leftkern ~= 0 then
+-- pre = insert_node_before(pre,n,fontkern(leftkern))
+-- done = true
+-- end
+-- if rightkern ~= 0 then
+-- insert_node_after(pre,n,fontkern(rightkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if post then
+-- -- left|post glyphs|right
+-- for n in nextchar, post do
+-- local p = rawget(properties,n)
+-- if p then
+-- local i = p.injections or p.postinjections
+-- if i then
+-- local yoffset = i.yoffset
+-- local leftkern = i.leftkern or 0
+-- local rightkern = i.rightkern or 0
+-- if yoffset and yoffset ~= 0 then
+-- -- use raise when advance
+-- addyoffset(n,yscaled(n,yoffset))
+-- end
+-- if leftkern ~= 0 then
+-- leftkern = xscaled(n,leftkern)
+-- end
+-- if rightkern ~= 0 then
+-- rightkern = xscaled(n,rightkern)
+-- end
+-- if useadvance then
+-- if leftkern ~= 0 or rightkern ~= 0 then
+-- addmargins(post,-leftkern,-rightkern)
+-- end
+-- else
+-- if leftkern ~= 0 then
+-- post = insert_node_before(post,n,fontkern(leftkern))
+-- done = true
+-- end
+-- if rightkern ~= 0 then
+-- insert_node_after(post,n,fontkern(rightkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if replace then
+-- -- left|replace glyphs|right
+-- for n in nextchar, replace do
+-- local p = rawget(properties,n)
+-- if p then
+-- local i = p.injections or p.replaceinjections
+-- if i then
+-- local yoffset = i.yoffset
+-- local leftkern = i.leftkern or 0
+-- local rightkern = i.rightkern or 0
+-- if yoffset and yoffset ~= 0 then
+-- -- use raise when advance
+-- addyoffset(n,yscaled(n,yoffset))
+-- end
+-- if leftkern ~= 0 then
+-- leftkern = xscaled(n,leftkern)
+-- end
+-- if rightkern ~= 0 then
+-- rightkern = xscaled(n,rightkern)
+-- end
+-- if useadvance then
+-- if leftkern ~= 0 or rightkern ~= 0 then
+-- addmargins(replace,-leftkern,-rightkern)
+-- end
+-- else
+-- if leftkern ~= 0 then
+-- replace = insert_node_before(replace,n,fontkern(leftkern))
+-- done = true
+-- end
+-- if rightkern ~= 0 then
+-- insert_node_after(replace,n,fontkern(rightkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if prevglyph then
+-- if pre then
+-- local p = rawget(properties,prevglyph)
+-- if p then
+-- local i = p.preinjections
+-- if i then
+-- -- glyph|pre glyphs
+-- local rightkern = i.rightkern
+-- if rightkern and rightkern ~= 0 then
+-- rightkern = xscaled(prevglyph,rightkern)
+-- if useadvance then
+-- addmargins(pre,-rightkern)
+-- else
+-- pre = insert_node_before(pre,pre,fontkern(rightkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if replace then
+-- local p = rawget(properties,prevglyph)
+-- if p then
+-- local i = p.replaceinjections
+-- if i then
+-- -- glyph|replace glyphs
+-- local rightkern = i.rightkern
+-- if rightkern and rightkern ~= 0 then
+-- rightkern = xscaled(prevglyph,rightkern)
+-- if useadvance then
+-- addmargins(replace,-rightkern)
+-- else
+-- replace = insert_node_before(replace,replace,fontkern(rightkern))
+-- done = true
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- if done then
+-- setdisc(current,pre,post,replace)
+-- end
+-- prevglyph = nil
+-- prevdisc = current
+-- else
+-- prevglyph = nil
+-- prevdisc = nil
+-- end
+-- prev = current
+-- current = next
+-- end
+-- --
+-- if keepregisteredcounts then
+-- keepregisteredcounts = false
+-- else
+-- nofregisteredpositions = 0
+-- end
+-- if trace_injections then
+-- show_result(head)
+-- end
+-- return head
+-- end
+
+local function inject_positions_only_kerns(head,where)
+ if trace_injections then
+ trace(head,"positions")
+ end
+ local current = head
+ local prev = nil
+ local next = nil
+ local prevdisc = nil
+ local prevglyph = nil
+ local pre = nil -- saves a lookup
+ local post = nil -- saves a lookup
+ local replace = nil -- saves a lookup
+ local pretail = nil -- saves a lookup
+ local posttail = nil -- saves a lookup
+ local replacetail = nil -- saves a lookup
+ while current do
+ local next, char, id = isnextchar(current)
+ if char then
+ local p = rawget(properties,current)
+ if p then
+ local i = p.injections
+ if i then
+ -- left|glyph|right
+ local yoffset = i.yoffset
+ if yoffset and yoffset ~= 0 then
+ -- use raise when advance
+ addyoffset(current,yscaled(current,yoffset))
+ end
+ local leftkern = i.leftkern or 0
+ local rightkern = i.rightkern or 0
+ if leftkern ~= 0 then
+ leftkern = xscaled(current,leftkern)
+ end
+ if rightkern ~= 0 then
+ rightkern = xscaled(current,rightkern)
+ end
+ if leftkern ~= 0 then
+ if leftkern == -rightkern then
+ addxoffset(current,leftkern)
+ rightkern = 0
+ elseif prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev,getwidth(prev)+leftkern)
+ end
+ else
+ head = insert_node_before(head,current,fontkern(leftkern))
+ end
+ end
+ if rightkern ~= 0 then
+ if next and getid(next) == glue_code then
+ if useitalickerns then
+ insert_node_after(head,current,italickern(rightkern))
+ else
+ setwidth(next, getwidth(next)+rightkern)
+ end
+ else
+ insert_node_after(head,current,fontkern(rightkern))
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ -- glyph|disc|glyph (special case)
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ if next and getid(next) == disc_code then
+ if replace then
+ -- error, we expect an empty one
+ else
+ replace = fontkern(xscaled(current,rightkern)) -- maybe also leftkern
+ done = true --KE
+ end
+ end
+ end
+ end
+ end
+ if prevdisc then
+ local done = false
+ if post then
+ local i = p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ setlink(posttail,fontkern(xscaled(current,leftkern)))
+ done = true
+ end
+ end
+ end
+ if replace then
+ local i = p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ setlink(replacetail,fontkern(xscaled(current,leftkern)))
+ done = true
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ -- new .. okay?
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ replace = fontkern(xscaled(current,leftkern))
+ done = true
+ end
+ end
+ end
+ if done then
+ setdisc(prevdisc,pre,post,replace)
+ end
+ end
+ end
+ prevdisc = nil
+ prevglyph = current
+ elseif char == false then
+ prevdisc = nil
+ prevglyph = current
+ elseif id == disc_code then
+ pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+ local done = false
+ if pre then
+ -- left|pre glyphs|right
+ for n in nextchar, pre do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.preinjections
+ if i then
+ local yoffset = i.yoffset
+ local leftkern = i.leftkern
+ local rightkern = i.rightkern
+ if yoffset and yoffset ~= 0 then
+ addyoffset(n,yscaled(n,yoffset))
+ end
+ if leftkern and leftkern ~= 0 then
+ pre = insert_node_before(pre,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ if rightkern and rightkern ~= 0 then
+ insert_node_after(pre,n,fontkern(xscaled(n,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if post then
+ -- left|post glyphs|right
+ for n in nextchar, post do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.postinjections
+ if i then
+ local yoffset = i.yoffset
+ local leftkern = i.leftkern
+ local rightkern = i.rightkern
+ if yoffset and yoffset ~= 0 then
+ addyoffset(n,yscaled(n,yoffset))
+ end
+ if leftkern and leftkern ~= 0 then
+ post = insert_node_before(post,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ if rightkern and rightkern ~= 0 then
+ insert_node_after(post,n,fontkern(xscaled(n,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if replace then
+ -- left|replace glyphs|right
+ for n in nextchar, replace do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.replaceinjections
+ if i then
+ local yoffset = i.yoffset
+ local leftkern = i.leftkern
+ local rightkern = i.rightkern
+ if yoffset and yoffset ~= 0 then
+ addyoffset(n,yscaled(n,yoffset))
+ end
+ if leftkern and leftkern ~= 0 then
+ replace = insert_node_before(replace,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ if rightkern and rightkern ~= 0 then
+ insert_node_after(replace,n,fontkern(xscaled(n,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if prevglyph then
+ -- there can only be useful properties when pre/replace start with a glyph
+ if pre then
+ local p = rawget(properties,prevglyph)
+ if p then
+ local i = p.preinjections
+ if i then
+ -- glyph|pre glyphs
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ pre = insert_node_before(pre,pre,fontkern(xscaled(prevglyph,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ if replace then
+ local p = rawget(properties,prevglyph)
+ if p then
+ local i = p.replaceinjections
+ if i then
+ -- glyph|replace glyphs
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ replace = insert_node_before(replace,replace,fontkern(xscaled(prevglyph,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if done then
+ setdisc(current,pre,post,replace)
+ end
+ prevglyph = nil
+ prevdisc = current
+ else
+ prevglyph = nil
+ prevdisc = nil
+ end
+ prev = current
+ current = next
+ end
+ --
+ if keepregisteredcounts then
+ keepregisteredcounts = false
+ else
+ nofregisteredpositions = 0
+ end
+ if trace_injections then
+ show_result(head)
+ end
+ return head
+end
+
+local function inject_positions_only_margins(head,where)
+ if trace_injections then
+ trace(head,"positions")
+ end
+ local current = head
+ local prev = nil
+ local next = nil
+ local prevdisc = nil
+ local prevglyph = nil
+ local pre = nil -- saves a lookup
+ local post = nil -- saves a lookup
+ local replace = nil -- saves a lookup
+ local pretail = nil -- saves a lookup
+ local posttail = nil -- saves a lookup
+ local replacetail = nil -- saves a lookup
+ while current do
+ local next, char, id = isnextchar(current)
+ if char then
+ local p = rawget(properties,current)
+ if p then
+ local i = p.injections
+ if i then
+ -- left|glyph|right
+ local yoffset = i.yoffset or 0
+ local leftkern = i.leftkern or 0
+ local rightkern = i.rightkern or 0
+ if leftkern ~= 0 or rightkern ~= 0 or yoffset ~= 0 then
+ addxymargins(n,-leftkern,-rightkern,yoffset) -- also scales
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ -- glyph|disc|glyph (special case)
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ if next and getid(next) == disc_code then
+ if replace then
+ -- error, we expect an empty one
+ else
+ if usezwjkerns then
+ replace = copynode(current)
+ setchar(replace,0x200D) -- zwj
+ addxymargins(replace,false,-rightkern)
+ else
+ replace = fontkern(xscaled(current,rightkern)) -- maybe also leftkern
+ end
+ done = true --KE
+ end
+ end
+ end
+ end
+ end
+ if prevdisc then
+ if post then
+ local i = p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(posttail,-leftkern)
+ end
+ end
+ end
+ if replace then
+ local i = p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ addxymargins(replacetail,-leftkern)
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ -- new .. okay?
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ if usezwjkerns then
+ replace = copynode(current)
+ setchar(replace,0x200D) -- zwj
+ addxymargins(replace,-leftkern)
+ else
+ replace = fontkern(xscaled(current,leftkern))
+ end
+ setdisc(prevdisc,pre,post,replace)
+ end
+ end
+ end
+ end
+ end
+ prevdisc = nil
+ prevglyph = current
+ elseif char == false then
+ prevdisc = nil
+ prevglyph = current
+ elseif id == disc_code then
+ pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+ if pre then
+ -- left|pre glyphs|right
+ for n in nextchar, pre do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.preinjections
+ if i then
+ local yoffset = i.yoffset or 0
+ local leftkern = i.leftkern or 0
+ local rightkern = i.rightkern or 0
+ if leftkern ~= 0 or rightkern ~= 0 or yoffset ~= 0 then
+ addxymargins(n,-leftkern,-rightkern,yoffset) -- also scales
+ end
+ end
+ end
+ end
+ end
+ if post then
+ -- left|post glyphs|right
+ for n in nextchar, post do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.postinjections
+ if i then
+ local yoffset = i.yoffset or 0
+ local leftkern = i.leftkern or 0
+ local rightkern = i.rightkern or 0
+ if leftkern ~= 0 or rightkern ~= 0 or yoffset ~= 0 then
+ addxymargins(n,-leftkern,-rightkern,yoffset) -- also scales
+ end
+ end
+ end
+ end
+ end
+ if replace then
+ -- left|replace glyphs|right
+ for n in nextchar, replace do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.replaceinjections
+ if i then
+ local yoffset = i.yoffset or 0
+ local leftkern = i.leftkern or 0
+ local rightkern = i.rightkern or 0
+ if leftkern ~= 0 or rightkern ~= 0 or yoffset ~= 0 then
+ addxymargins(n,-leftkern,-rightkern,yoffset) -- also scales
+ end
+ end
+ end
+ end
+ end
+ if prevglyph then
+ if pre then
+ local p = rawget(properties,prevglyph)
+ if p then
+ local i = p.preinjections
+ if i then
+ -- glyph|pre glyphs
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ addxymargins(pre,-rightkern,0,0)
+ end
+ end
+ end
+ end
+ if replace then
+ local p = rawget(properties,prevglyph)
+ if p then
+ local i = p.replaceinjections
+ if i then
+ -- glyph|replace glyphs
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ addxymargins(replace,-rightkern,0,0)
+ end
+ end
+ end
+ end
+ end
+ prevglyph = nil
+ prevdisc = current
+ else
+ prevglyph = nil
+ prevdisc = nil
+ end
+ prev = current
+ current = next
+ end
+ --
+ if keepregisteredcounts then
+ keepregisteredcounts = false
+ else
+ nofregisteredpositions = 0
+ end
+ if trace_injections then
+ show_result(head)
+ end
+ return head
+end
+
+local function showoffset(n,flag)
+ local x, y = getoffsets(n)
+ if x ~= 0 or y ~= 0 then
+ setcolor(n,"darkgray")
+ end
+end
+
+local function processmark(p,n,pn) -- p = basenode
+ local px, py = getoffsets(p)
+ local nx, ny = getoffsets(n)
+ local sx, sy = getxyscales(n) -- we assume n and p to have equal scales
+ local ox = 0
+ local rightkern = nil
+ local pp = rawget(properties,p)
+ if pp then
+ pp = pp.injections
+ if pp then
+ rightkern = pp.rightkern
+ end
+ end
+ local markdir = pn.markdir
+ if rightkern then -- x and w ~= 0
+ ox = px - sx * (pn.markx or 0) - rightkern
+ if markdir and markdir < 0 then
+ -- kern(w-x) glyph(p) kern(x) mark(n)
+ if not pn.markmark then
+ ox = ox + sx * (pn.leftkern or 0)
+ end
+ else
+ -- kern(x) glyph(p) kern(w-x) mark(n)
+ --
+ -- According to Kai we don't need to handle leftkern here but I'm
+ -- pretty sure I've run into a case where it was needed so maybe
+ -- some day we need something more clever here.
+ --
+ -- maybe we need to apply both then
+ --
+ if false then
+ -- a mark with kerning (maybe husayni needs it )
+ local leftkern = pp.leftkern
+ if leftkern then
+ ox = ox - sx * leftkern
+ end
+ end
+ end
+ else
+ ox = px - sx * (pn.markx or 0)
+ if markdir and markdir < 0 then
+ if not pn.markmark then
+ local leftkern = pn.leftkern
+ if leftkern then
+ ox = ox + sx * leftkern -- husayni needs it
+ end
+ end
+ end
+ if pn.checkmark then
+ local wn = getwidth(n) -- in arial marks have widths
+ if wn and wn ~= 0 then
+ wn = wn/2
+ if trace_injections then
+ report_injections("correcting non zero width mark %C",getchar(n))
+ end
+ -- -- bad: we should center
+ --
+ -- pn.leftkern = -wn
+ -- pn.rightkern = -wn
+ --
+ -- -- we're too late anyway as kerns are already injected so we do it the
+ -- -- ugly way (no checking if the previous is already a kern) .. maybe we
+ -- -- should fix the font instead
+ --
+ -- todo: head and check for prev / next kern
+ --
+ insert_node_before(n,n,fontkern(-wn))
+ insert_node_after(n,n,fontkern(-wn))
+ end
+ end
+ end
+ local oy = ny + py + sy * (pn.marky or 0)
+ if not pn.markmark then
+ local yoffset = pn.yoffset
+ if yoffset then
+ oy = oy + sy * yoffset -- husayni needs it
+ end
+ end
+ setoffsets(n,ox,oy)
+ if trace_marks then
+ showoffset(n,true)
+ end
+end
+
+local function inject_everything(head,where)
+ if trace_injections then
+ trace(head,"everything")
+ end
+ local hascursives = nofregisteredcursives > 0
+ local hasmarks = nofregisteredmarks > 0
+ --
+ local current = head
+ local last = nil
+ local prev = nil
+ local next = nil
+ local prevdisc = nil
+ local prevglyph = nil
+ local pre = nil -- saves a lookup
+ local post = nil -- saves a lookup
+ local replace = nil -- saves a lookup
+ local pretail = nil -- saves a lookup
+ local posttail = nil -- saves a lookup
+ local replacetail = nil -- saves a lookup
+ --
+ local cursiveanchor = nil
+ local minc = 0
+ local maxc = 0
+ local glyphs = { }
+ local marks = { }
+ local nofmarks = 0
+ --
+ while current do
+ local next, char, id = isnextchar(current)
+ if char then
+ local p = rawget(properties,current)
+ if p then
+ local i = p.injections
+ if i then
+ local pm = i.markbasenode
+ if pm then
+ nofmarks = nofmarks + 1
+ marks[nofmarks] = current
+ else
+ local yoffset = i.yoffset
+ if yoffset and yoffset ~= 0 then
+ addyoffset(current,yscaled(current,yoffset)) -- or just * sy
+ end
+ if hascursives then
+ local cursivex = i.cursivex
+ if cursivex then
+ if cursiveanchor then
+ if cursivex ~= 0 then
+ i.leftkern = (i.leftkern or 0) + cursivex
+ end
+ if maxc == 0 then
+ minc = 1
+ maxc = 1
+ glyphs[1] = cursiveanchor
+ else
+ maxc = maxc + 1
+ glyphs[maxc] = cursiveanchor
+ end
+ properties[cursiveanchor].cursivedy = i.cursivey -- cursiveprops
+ last = current
+ else
+ maxc = 0
+ end
+ elseif maxc > 0 then
+ local nx, ny = getoffsets(current)
+ for i=maxc,minc,-1 do
+ local ti = glyphs[i]
+ ny = ny + yscaled(current,properties[ti].cursivedy) -- stepwise increment
+ setoffsets(ti,false,ny)
+ if trace_cursive then
+ showoffset(ti)
+ end
+ end
+ maxc = 0
+ cursiveanchor = nil
+ end
+ if i.cursiveanchor then
+ cursiveanchor = current -- no need for both now
+ else
+ if maxc > 0 then
+ local nx, ny = getoffsets(current)
+ for i=maxc,minc,-1 do
+ local ti = glyphs[i]
+ ny = ny + yscaled(current,properties[ti].cursivedy) -- stepwise increment
+ setoffsets(ti,false,ny)
+ if trace_cursive then
+ showoffset(ti)
+ end
+ end
+ maxc = 0
+ end
+ cursiveanchor = nil
+ end
+ end
+ -- left|glyph|right
+ local leftkern = i.leftkern
+ local rightkern = i.rightkern
+ if leftkern and leftkern ~= 0 then
+ local opposite = rightkern and leftkern == -rightkern
+ leftkern = xscaled(current,leftkern)
+ if opposite then
+ addxoffset(current,leftkern)
+ rightkern = 0
+ elseif prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
+ else
+ head = insert_node_before(head,current,fontkern(leftkern))
+ end
+ end
+ if rightkern and rightkern ~= 0 then
+ rightkern = xscaled(current,rightkern)
+ if next and getid(next) == glue_code then
+ if useitalickerns then
+ insert_node_after(head,current,italickern(rightkern))
+ else
+ setwidth(next, getwidth(next) + rightkern)
+ end
+ else
+ insert_node_after(head,current,fontkern(rightkern))
+ end
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ -- glyph|disc|glyph (special case)
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ if next and getid(next) == disc_code then
+ if replace then
+ -- error, we expect an empty one
+ else
+ replace = fontkern(xscaled(current,rightkern))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if prevdisc then
+ if p then
+ local done = false
+ if post then
+ local i = p.postinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ setlink(posttail,fontkern(xscaled(current,leftkern)))
+ done = true
+ end
+ end
+ end
+ if replace then
+ local i = p.replaceinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ setlink(replacetail,fontkern(xscaled(current,leftkern)))
+ done = true
+ end
+ end
+ else
+ local i = p.emptyinjections
+ if i then
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ replace = fontkern(xscaled(current,leftkern))
+ done = true
+ end
+ end
+ end
+ if done then
+ setdisc(prevdisc,pre,post,replace)
+ end
+ end
+ end
+ else
+ -- cursive
+ if hascursives and maxc > 0 then
+ local nx, ny = getoffsets(current)
+ for i=maxc,minc,-1 do
+ local ti = glyphs[i]
+ ny = ny + yscaled(current,properties[ti].cursivedy)
+ setoffsets(ti,false,ny) -- can be mark, we could use properties
+ end
+ maxc = 0
+ cursiveanchor = nil
+ end
+ end
+ prevdisc = nil
+ prevglyph = current
+ elseif char == false then
+ -- base = nil
+ prevdisc = nil
+ prevglyph = current
+ elseif id == disc_code then
+ -- base = nil
+ pre, post, replace, pretail, posttail, replacetail = getdisc(current,true)
+ local done = false
+ if pre then
+ -- left|pre glyphs|right
+ for n in nextchar, pre do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.preinjections
+ if i then
+ local yoffset = i.yoffset
+ if yoffset and yoffset ~= 0 then
+ addyoffset(n,yscaled(n,yoffset))
+ end
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ pre = insert_node_before(pre,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ insert_node_after(pre,n,fontkern(xscaled(n,rightkern)))
+ done = true
+ end
+ if hasmarks then
+ local pm = i.markbasenode
+ if pm then
+ processmark(pm,n,i)
+ end
+ end
+ end
+ end
+ end
+ end
+ if post then
+ -- left|post glyphs|right
+ for n in nextchar, post do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.postinjections
+ if i then
+ local yoffset = i.yoffset
+ if yoffset and yoffset ~= 0 then
+ addyoffset(n,yscaled(n,yoffset))
+ end
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ post = insert_node_before(post,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ done = true
+ insert_node_after(post,n,fontkern(xscaled(n,rightkern)))
+ end
+ if hasmarks then
+ local pm = i.markbasenode
+ if pm then
+ processmark(pm,n,i)
+ end
+ end
+ end
+ end
+ end
+ end
+ if replace then
+ -- left|replace glyphs|right
+ for n in nextchar, replace do
+ local p = rawget(properties,n)
+ if p then
+ local i = p.injections or p.replaceinjections
+ if i then
+ local yoffset = i.yoffset
+ if yoffset and yoffset ~= 0 then
+ addyoffset(n,yscaled(n,yoffset))
+ end
+ local leftkern = i.leftkern
+ if leftkern and leftkern ~= 0 then
+ replace = insert_node_before(replace,n,fontkern(xscaled(n,leftkern)))
+ done = true
+ end
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ insert_node_after(replace,n,fontkern(xscaled(n,rightkern)))
+ done = true
+ end
+ if hasmarks then
+ local pm = i.markbasenode
+ if pm then
+ processmark(pm,n,i)
+ end
+ end
+ end
+ end
+ end
+ end
+ if prevglyph then
+ if pre then
+ local p = rawget(properties,prevglyph)
+ if p then
+ local i = p.preinjections
+ if i then
+ -- glyph|pre glyphs
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ pre = insert_node_before(pre,pre,fontkern(xscaled(prevglyph,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ if replace then
+ local p = rawget(properties,prevglyph)
+ if p then
+ local i = p.replaceinjections
+ if i then
+ -- glyph|replace glyphs
+ local rightkern = i.rightkern
+ if rightkern and rightkern ~= 0 then
+ replace = insert_node_before(replace,replace,fontkern(xscaled(prevglyph,rightkern)))
+ done = true
+ end
+ end
+ end
+ end
+ end
+ if done then
+ setdisc(current,pre,post,replace)
+ end
+ prevglyph = nil
+ prevdisc = current
+ else
+ -- base = nil
+ prevglyph = nil
+ prevdisc = nil
+ end
+ prev = current
+ current = next
+ end
+ -- cursive
+ if hascursives and maxc > 0 then
+ local nx, ny = getoffsets(last)
+ for i=maxc,minc,-1 do
+ local ti = glyphs[i]
+ ny = ny + yscaled(properties[ti].cursivedy)
+ setoffsets(ti,false,ny)
+ if trace_cursive then
+ showoffset(ti)
+ end
+ end
+ end
+ --
+ if nofmarks > 0 then
+ for i=1,nofmarks do
+ local m = marks[i]
+ local p = rawget(properties,m)
+ local i = p.injections
+ local b = i.markbasenode
+ processmark(b,m,i)
+ end
+ elseif hasmarks then
+ -- sometyhing bad happened
+ end
+ --
+ if keepregisteredcounts then
+ keepregisteredcounts = false
+ else
+ nofregisteredkerns = 0
+ nofregisteredpositions = 0
+ nofregisteredmarks = 0
+ nofregisteredcursives = 0
+ end
+ if trace_injections then
+ show_result(head)
+ end
+ return head
+end
+
+-- space triggers
+
+local triggers = false
+
+function nodes.injections.setspacekerns(font,sequence)
+ if triggers then
+ triggers[font] = sequence
+ else
+ triggers = { [font] = sequence }
+ end
+end
+
+local threshold = 1 -- todo: add a few methods for context
+
+directives.register("otf.threshold", function(v) threshold = tonumber(v) or 1 end)
+
+local getthreshold = function(font)
+ local p = parameters[font]
+ local f = p.factor
+ local s = p.spacing
+ local t = threshold * (s and s.width or p.space or 0) - 2
+ return t > 0 and t or 0, f
+end
+
+injections.getthreshold = getthreshold
+
+function injections.isspace(n,threshold,id)
+ if (id or getid(n)) == glue_code then
+ local w = getwidth(n)
+ if threshold and w > threshold then -- was >=
+ return 32
+ end
+ end
+end
+
+-- We have a plugin so that Kai can use the next in plain. Such a plugin is rather application
+-- specific.
+--
+-- local getboth = nodes.direct.getboth
+-- local getid = nodes.direct.getid
+-- local getprev = nodes.direct.getprev
+-- local getnext = nodes.direct.getnext
+--
+-- local whatsit_code = nodes.nodecodes.whatsit
+-- local glyph_code = nodes.nodecodes.glyph
+--
+-- local function getspaceboth(n) -- fragile: what it prev/next has no width field
+-- local prev, next = getboth(n)
+-- while prev and (getid(prev) == whatsit_code or (getwidth(prev) == 0 and getid(prev) ~= glyph_code)) do
+-- prev = getprev(prev)
+-- end
+-- while next and (getid(next) == whatsit_code or (getwidth(next) == 0 and getid(next) ~= glyph_code)) do
+-- next = getnext(next)
+-- end
+-- end
+--
+-- injections.installgetspaceboth(getspaceboth)
+
+local getspaceboth = getboth
+
+function injections.installgetspaceboth(gb)
+ getspaceboth = gb or getboth
+end
+
+local function injectspaces(head)
+
+ if not triggers then
+ return head
+ end
+ local lastfont = nil
+ local spacekerns = nil
+ local leftkerns = nil
+ local rightkerns = nil
+ local factor = 0
+ local threshold = 0
+ local leftkern = false
+ local rightkern = false
+ local xscale = 1
+
+ local function updatefont(font,trig)
+ leftkerns = trig.left
+ rightkerns = trig.right
+ lastfont = font
+ threshold,
+ factor = getthreshold(font)
+ end
+
+ for n in nextglue, head do
+ local prev, next = getspaceboth(n)
+ local prevchar = prev and ischar(prev)
+ local nextchar = next and ischar(next)
+ if nextchar then
+ local font = getfont(next)
+ local trig = triggers[font]
+ if trig then
+ if lastfont ~= font then
+ updatefont(font,trig)
+ end
+ if rightkerns then
+ rightkern = rightkerns[nextchar]
+ end
+ xscale = getxscale(next)
+ end
+ end
+ if prevchar then
+ local font = getfont(prev)
+ local trig = triggers[font]
+ if trig then
+ if lastfont ~= font then
+ updatefont(font,trig)
+ end
+ if leftkerns then
+ leftkern = leftkerns[prevchar]
+ end
+ xscale = getxscale(prev)
+ end
+ end
+ if leftkern then
+ local old = getwidth(n)
+ if old > threshold then
+ if rightkern then
+ if useitalickerns then
+ local lnew = leftkern * factor
+ local rnew = rightkern * factor
+ if trace_spaces then
+ report_spaces("%C [%p + %p + %p] %C",prevchar,lnew,old,rnew,nextchar)
+ end
+ lnew = lnew * xscale
+ rnew = rnew * xscale
+ head = insert_node_before(head,n,italickern(lnew))
+ insert_node_after(head,n,italickern(rnew))
+ else
+ local new = old + (leftkern + rightkern) * factor
+ if trace_spaces then
+ report_spaces("%C [%p -> %p] %C",prevchar,old,new,nextchar)
+ end
+ setwidth(n,new)
+ end
+ rightkern = false
+ else
+ if useitalickerns then
+ local new = leftkern * factor
+ if trace_spaces then
+ report_spaces("%C [%p + %p]",prevchar,old,new)
+ end
+ new = new * xscale
+ insert_node_after(head,n,italickern(new)) -- tricky with traverse but ok
+ else
+ local new = old + leftkern * factor * xscale
+ if trace_spaces then
+ report_spaces("%C [%p -> %p]",prevchar,old,new)
+ end
+ setwidth(n,new)
+ end
+ end
+ end
+ leftkern = false
+ elseif rightkern then
+ local old = getwidth(n)
+ if old > threshold then
+ local new = rightkern * factor * xscale
+ if useitalickerns then
+ if trace_spaces then
+ report_spaces("[%p + %p] %C",old,new,nextchar)
+ end
+ insert_node_after(head,n,italickern(new))
+ else
+ new = old + new
+ if trace_spaces then
+ report_spaces("[%p -> %p] %C",old,new,nextchar)
+ end
+ setwidth(n,new)
+ end
+ else
+ -- message
+ end
+ rightkern = false
+ end
+ end
+
+ triggers = false
+
+ return head
+end
+
+-- When advance is found to be okay there will be split functions (which is abit
+-- more efficient) but first we need to have scales done (we can also have addoffset
+-- and alike then)
+
+function injections.handler(head,where)
+ if triggers then
+ head = injectspaces(head)
+ end
+ if nofregisteredmarks > 0 or nofregisteredcursives > 0 then
+ if trace_injections then
+ report_injections("injection variant %a (%s)","everything","kerns")
+ end
+ -- I will do useadvance here when I am playing with fonts that follow this
+ -- injection routem, which is seldom.
+ return inject_everything(head,where)
+ elseif nofregisteredpositions > 0 then
+ if trace_injections then
+ report_injections("injection variant %a (%s)","positions",useadvance and "margins" or "kerns")
+ end
+ if useadvance then
+ return inject_positions_only_margins(head,where)
+ else
+ return inject_positions_only_kerns(head,where)
+ end
+ elseif nofregisteredkerns > 0 then
+ if trace_injections then
+ report_injections("injection variant %a (%s)","kerns",useadvance and "margins" or "kerns")
+ end
+ if useadvance then
+ return inject_kerns_only_margins(head,where)
+-- return inject_positions_only_margins(head,where)
+ else
+ return inject_kerns_only_kerns(head,where)
+ end
+ else
+ return head
+ end
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-ots.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-ots.lmt
new file mode 100644
index 00000000000..37f76b258a7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-ots.lmt
@@ -0,0 +1,4475 @@
+if not modules then modules = { } end modules ['font-ots'] = { -- sequences
+ version = 1.001,
+ optimize = true,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+--[[ldx--
+
This module is a bit more split up that I'd like but since we also want to test
+with plain it has to be so. This module is part of
+and discussion about improvements and functionality mostly happens on the
+ mailing list.
+
+
The specification of OpenType is (or at least decades ago was) kind of vague.
+Apart from a lack of a proper free specifications there's also the problem that
+Microsoft and Adobe may have their own interpretation of how and in what order to
+apply features. In general the Microsoft website has more detailed specifications
+and is a better reference. There is also some information in the FontForge help
+files. In the end we rely most on the Microsoft specification.
+
+
Because there is so much possible, fonts might contain bugs and/or be made to
+work with certain rederers. These may evolve over time which may have the side
+effect that suddenly fonts behave differently. We don't want to catch all font
+issues.
+
+
After a lot of experiments (mostly by Taco, me and Idris) the first implementation
+was already quite useful. When it did most of what we wanted, a more optimized version
+evolved. Of course all errors are mine and of course the code can be improved. There
+are quite some optimizations going on here and processing speed is currently quite
+acceptable and has been improved over time. Many complex scripts are not yet supported
+yet, but I will look into them as soon as users ask for it.
+
+
The specification leaves room for interpretation. In case of doubt the Microsoft
+implementation is the reference as it is the most complete one. As they deal with
+lots of scripts and fonts, Kai and Ivo did a lot of testing of the generic code and
+their suggestions help improve the code. I'm aware that not all border cases can be
+taken care of, unless we accept excessive runtime, and even then the interference
+with other mechanisms (like hyphenation) are not trivial.
+
+
Especially discretionary handling has been improved much by Kai Eigner who uses complex
+(latin) fonts. The current implementation is a compromis between his patches and my code
+and in the meantime performance is quite ok. We cannot check all border cases without
+compromising speed but so far we're okay. Given good test cases we can probably improve
+it here and there. Especially chain lookups are non trivial with discretionaries but
+things got much better over time thanks to Kai.
+
+
Glyphs are indexed not by unicode but in their own way. This is because there is no
+relationship with unicode at all, apart from the fact that a font might cover certain
+ranges of characters. One character can have multiple shapes. However, at the
+ end we use unicode so and all extra glyphs are mapped into a private
+space. This is needed because we need to access them and has to include
+then in the output eventually.
+
+
The initial data table is rather close to the open type specification and also not
+that different from the one produced by but we uses hashes instead.
+In that table is packed (similar tables are shared) and cached on disk
+so that successive runs can use the optimized table (after loading the table is
+unpacked).
+
+
This module is sparsely documented because it is has been a moving target. The
+table format of the reader changed a bit over time and we experiment a lot with
+different methods for supporting features. By now the structures are quite stable
+
+
Incrementing the version number will force a re-cache. We jump the number by one
+when there's a fix in the reader or processing code that can result in different
+results.
+
+
This code is also used outside context but in context it has to work with other
+mechanisms. Both put some constraints on the code here.
+
+--ldx]]--
+
+-- Remark: We assume that cursives don't cross discretionaries which is okay because it
+-- is only used in semitic scripts.
+--
+-- Remark: We assume that marks precede base characters.
+--
+-- Remark: When complex ligatures extend into discs nodes we can get side effects. Normally
+-- this doesn't happen; ff\d{l}{l}{l} in lm works but ff\d{f}{f}{f}.
+--
+-- Todo: check if we copy attributes to disc nodes if needed.
+--
+-- Todo: it would be nice if we could get rid of components. In other places we can use
+-- the unicode properties. We can just keep a lua table.
+--
+-- Remark: We do some disc juggling where we need to keep in mind that the pre, post and
+-- replace fields can have prev pointers to a nesting node ... I wonder if that is still
+-- needed.
+--
+-- Remark: This is not possible:
+--
+-- \discretionary {alpha-} {betagammadelta}
+-- {\discretionary {alphabeta-} {gammadelta}
+-- {\discretionary {alphabetagamma-} {delta}
+-- {alphabetagammadelta}}}
+--
+-- Remark: Something is messed up: we have two mark / ligature indices, one at the
+-- injection end and one here ... this is based on KE's patches but there is something
+-- fishy there as I'm pretty sure that for husayni we need some connection (as it's much
+-- more complex than an average font) but I need proper examples of all cases, not of
+-- only some.
+--
+-- Remark: I wonder if indexed would be faster than unicoded. It would be a major
+-- rewrite to have char being unicode + an index field in glyph nodes. Also more
+-- assignments have to be made in order to keep things in sync. So, it's a no-go.
+--
+-- Remark: We can provide a fast loop when there are no disc nodes (tests show a 1%
+-- gain). Smaller functions might perform better cache-wise. But ... memory becomes
+-- faster anyway, so ...
+--
+-- Remark: Some optimizations made sense for 5.2 but seem less important for 5.3 but
+-- anyway served their purpose.
+--
+-- Todo: just (0=l2r and 1=r2l) or maybe (r2l = true)
+
+-- Experiments with returning the data with the ischar are positive for lmtx but
+-- have a performance hit on mkiv because there we need to wrap ischardata (pending
+-- extensions to luatex which is unlikely to happen for such an experiment because
+-- we then can't remove it). Actually it might make generic slightly faster. Also,
+-- there are some corner cases where a data check comes before a char fetch and
+-- we're talking of millions of calls there. At some point I might make a version
+-- for lmtx that does it slightly different anyway.
+
+local type, next, tonumber = type, next, tonumber
+local random = math.random
+local formatters = string.formatters
+local insert = table.insert
+
+local registertracker = trackers.register
+
+local logs = logs
+local trackers = trackers
+local nodes = nodes
+local fonts = fonts
+
+local otf = fonts.handlers.otf
+local tracers = nodes.tracers
+
+local trace_singles = false registertracker("otf.singles", function(v) trace_singles = v end)
+local trace_multiples = false registertracker("otf.multiples", function(v) trace_multiples = v end)
+local trace_alternatives = false registertracker("otf.alternatives", function(v) trace_alternatives = v end)
+local trace_ligatures = false registertracker("otf.ligatures", function(v) trace_ligatures = v end)
+local trace_contexts = false registertracker("otf.contexts", function(v) trace_contexts = v end)
+local trace_marks = false registertracker("otf.marks", function(v) trace_marks = v end)
+local trace_kerns = false registertracker("otf.kerns", function(v) trace_kerns = v end)
+local trace_cursive = false registertracker("otf.cursive", function(v) trace_cursive = v end)
+local trace_preparing = false registertracker("otf.preparing", function(v) trace_preparing = v end)
+local trace_bugs = false registertracker("otf.bugs", function(v) trace_bugs = v end)
+local trace_details = false registertracker("otf.details", function(v) trace_details = v end)
+local trace_steps = false registertracker("otf.steps", function(v) trace_steps = v end)
+local trace_skips = false registertracker("otf.skips", function(v) trace_skips = v end)
+local trace_plugins = false registertracker("otf.plugins", function(v) trace_plugins = v end)
+local trace_chains = false registertracker("otf.chains", function(v) trace_chains = v end)
+
+local trace_kernruns = false registertracker("otf.kernruns", function(v) trace_kernruns = v end)
+----- trace_discruns = false registertracker("otf.discruns", function(v) trace_discruns = v end)
+local trace_compruns = false registertracker("otf.compruns", function(v) trace_compruns = v end)
+local trace_testruns = false registertracker("otf.testruns", function(v) trace_testruns = v end)
+
+local forcediscretionaries = false
+local forcepairadvance = false -- for testing
+
+directives.register("otf.forcediscretionaries",function(v)
+ forcediscretionaries = v
+end)
+
+directives.register("otf.forcepairadvance",function(v)
+ forcepairadvance = v
+end)
+
+local report_direct = logs.reporter("fonts","otf direct")
+local report_subchain = logs.reporter("fonts","otf subchain")
+local report_chain = logs.reporter("fonts","otf chain")
+local report_process = logs.reporter("fonts","otf process")
+local report_warning = logs.reporter("fonts","otf warning")
+local report_run = logs.reporter("fonts","otf run")
+
+registertracker("otf.substitutions", "otf.singles","otf.multiples","otf.alternatives","otf.ligatures")
+registertracker("otf.positions", "otf.marks","otf.kerns","otf.cursive")
+registertracker("otf.actions", "otf.substitutions","otf.positions")
+registertracker("otf.sample", "otf.steps","otf.substitutions","otf.positions","otf.analyzing")
+registertracker("otf.sample.silent", "otf.steps=silent","otf.substitutions","otf.positions","otf.analyzing")
+
+local nuts = nodes.nuts
+
+local getnext = nuts.getnext
+local setnext = nuts.setnext
+local getprev = nuts.getprev
+local setprev = nuts.setprev
+local getboth = nuts.getboth
+local setboth = nuts.setboth
+local getid = nuts.getid
+local getstate = nuts.getstate
+local setsubtype = nuts.setsubtype
+local getchar = nuts.getchar
+local setchar = nuts.setchar
+local getdisc = nuts.getdisc
+local setdisc = nuts.setdisc
+local getreplace = nuts.getreplace
+local setlink = nuts.setlink
+local getwidth = nuts.getwidth
+local getoptions = nuts.getoptions
+local setoptions = nuts.setoptions
+
+local getglyphdata = nuts.getglyphdata
+local getscales = nuts.getscales
+
+---------------------------------------------------------------------------------------
+
+-- Beware: In ConTeXt components no longer are real components. We only keep track of
+-- their positions because some complex ligatures might need that. For the moment we
+-- use an x_ prefix because for now generic follows the other approach.
+
+local copy_no_components = nuts.copy_no_components
+local copy_only_glyphs = nuts.copy_only_glyphs
+local count_components = nuts.count_components
+local set_components = nuts.set_components
+local get_components = nuts.get_components
+local flush_components = nuts.flush_components
+
+---------------------------------------------------------------------------------------
+
+local ischar = nuts.ischar
+local isnextchar = nuts.isnextchar -- only makes sense when we know we need next
+local isprevchar = nuts.isprevchar -- only makes sense when we know we need prev
+local usesfont = nuts.uses_font
+
+local insert_node_after = nuts.insert_after
+local copy_node = nuts.copy
+local copy_node_list = nuts.copy_list
+local remove_node = nuts.remove
+local find_node_tail = nuts.tail
+local flush_node_list = nuts.flush_list
+local flush_node = nuts.flush_node
+local end_of_math = nuts.end_of_math
+local start_of_par = nuts.start_of_par
+
+local setmetatable = setmetatable
+local setmetatableindex = table.setmetatableindex
+
+local nextnode = nuts.traversers.node
+
+----- zwnj = 0x200C
+----- zwj = 0x200D
+
+local nodecodes = nodes.nodecodes
+local glyphcodes = nodes.glyphcodes
+
+local glyph_code = nodecodes.glyph
+local glue_code = nodecodes.glue
+local disc_code = nodecodes.disc
+local math_code = nodecodes.math
+local dir_code = nodecodes.dir
+local par_code = nodecodes.par
+
+local lefttoright_code = nodes.dirvalues.lefttoright
+local righttoleft_code = nodes.dirvalues.righttoleft
+
+local discretionarydisc_code = nodes.disccodes.discretionary
+local ligatureglyph_code = glyphcodes.ligature
+
+local injections = nodes.injections
+local setmark = injections.setmark
+local setcursive = injections.setcursive
+local setkern = injections.setkern
+local setmove = injections.setmove
+local setposition = injections.setposition
+local resetinjection = injections.reset
+local copyinjection = injections.copy
+local setligaindex = injections.setligaindex
+local getligaindex = injections.getligaindex
+
+local fontdata = fonts.hashes.identifiers
+local fontfeatures = fonts.hashes.features
+
+local otffeatures = fonts.constructors.features.otf
+local registerotffeature = otffeatures.register
+
+local onetimemessage = fonts.loggers.onetimemessage or function() end
+
+local getrandom = utilities and utilities.randomizer and utilities.randomizer.get
+
+otf.defaultnodealternate = "none" -- first last
+
+-- We use a few semi-global variables. The handler can be called nested but this assumes
+-- that the same font is used.
+
+local tfmdata = false
+local characters = false
+local descriptions = false
+local marks = false
+local classes = false
+local currentfont = false
+local currentdynamic = false
+local currentscale = false
+local currentxscale = false
+local currentyscale = false
+local factor = 0
+local threshold = 0
+local checkmarks = false
+
+local discs = false
+local spaces = false
+
+local sweepnode = nil
+local sweephead = { } -- we don't nil entries but false them (no collection and such)
+
+local notmatchpre = { } -- to be checked: can we use false instead of nil / what if a == b tests
+local notmatchpost = { } -- to be checked: can we use false instead of nil / what if a == b tests
+local notmatchreplace = { } -- to be checked: can we use false instead of nil / what if a == b tests
+
+local handlers = { }
+
+local isspace = injections.isspace
+local getthreshold = injections.getthreshold
+
+local checkstep = (tracers and tracers.steppers.check) or function() end
+local registerstep = (tracers and tracers.steppers.register) or function() end
+local registermessage = (tracers and tracers.steppers.message) or function() end
+
+-- local function checkdisccontent(d)
+-- local pre, post, replace = getdisc(d)
+-- if pre then for n in traverse_id(glue_code,pre) do report("pre: %s",nodes.idstostring(pre)) break end end
+-- if post then for n in traverse_id(glue_code,post) do report("pos: %s",nodes.idstostring(post)) break end end
+-- if replace then for n in traverse_id(glue_code,replace) do report("rep: %s",nodes.idstostring(replace)) break end end
+-- end
+
+local function logprocess(...)
+ if trace_steps then
+ registermessage(...)
+ if trace_steps == "silent" then
+ return
+ end
+ end
+ report_direct(...)
+end
+
+local function logwarning(...)
+ report_direct(...)
+end
+
+local gref do
+
+ local f_unicode = formatters["U+%X"] -- was ["%U"]
+ local f_uniname = formatters["U+%X (%s)"] -- was ["%U (%s)"]
+ local f_unilist = formatters["% t"]
+
+ gref = function(n) -- currently the same as in font-otb
+ if type(n) == "number" then
+ local description = descriptions[n]
+ local name = description and description.name
+ if name then
+ return f_uniname(n,name)
+ else
+ return f_unicode(n)
+ end
+ elseif n then
+ local t = { }
+ for i=1,#n do
+ local ni = n[i]
+ if tonumber(ni) then -- later we will start at 2
+ local di = descriptions[ni]
+ local nn = di and di.name
+ if nn then
+ t[#t+1] = f_uniname(ni,nn)
+ else
+ t[#t+1] = f_unicode(ni)
+ end
+ end
+ end
+ return f_unilist(t)
+ else
+ return ""
+ end
+ end
+
+end
+
+local function cref(dataset,sequence,index)
+ if not dataset then
+ return "no valid dataset"
+ end
+ local merged = sequence.merged and "merged " or ""
+ if index then
+ return formatters["feature %a, type %a, %schain lookup %a, index %a"](
+ dataset[4],sequence.type,merged,sequence.name,index)
+ else
+ return formatters["feature %a, type %a, %schain lookup %a"](
+ dataset[4],sequence.type,merged,sequence.name)
+ end
+end
+
+local function pref(dataset,sequence)
+ return formatters["feature %a, type %a, %slookup %a"](
+ dataset[4],sequence.type,sequence.merged and "merged " or "",sequence.name)
+end
+
+local function mref(rlmode)
+ if not rlmode or rlmode >= 0 then
+ return "l2r"
+ else
+ return "r2l"
+ end
+end
+
+-- The next code is somewhat complicated by the fact that some fonts can have ligatures made
+-- from ligatures that themselves have marks. This was identified by Kai in for instance
+-- arabtype: KAF LAM SHADDA ALEF FATHA (0x0643 0x0644 0x0651 0x0627 0x064E). This becomes
+-- KAF LAM-ALEF with a SHADDA on the first and a FATHA op de second component. In a next
+-- iteration this becomes a KAF-LAM-ALEF with a SHADDA on the second and a FATHA on the
+-- third component.
+
+-- We can assume that languages that use marks are not hyphenated. We can also assume
+-- that at most one discretionary is present.
+
+-- We do need components in funny kerning mode but maybe I can better reconstruct then
+-- as we do have the font components info available; removing components makes the
+-- previous code much simpler. Also, later on copying and freeing becomes easier.
+-- However, for arabic we need to keep them around for the sake of mark placement
+-- and indices.
+
+local function flattendisk(head,disc)
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true)
+ local prev, next = getboth(disc)
+ local ishead = head == disc
+ setdisc(disc)
+ flush_node(disc)
+ if pre then
+ flush_node_list(pre)
+ end
+ if post then
+ flush_node_list(post)
+ end
+ if ishead then
+ if replace then
+ if next then
+ setlink(replacetail,next)
+ end
+ return replace, replace
+ elseif next then
+ return next, next
+ else
+ -- return -- maybe warning
+ end
+ else
+ if replace then
+ if next then
+ setlink(replacetail,next)
+ end
+ setlink(prev,replace)
+ return head, replace
+ else
+ setlink(prev,next) -- checks for next anyway
+ return head, next
+ end
+ end
+end
+
+local function appenddisc(disc,list)
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true)
+ local posthead = list
+ local replacehead = copy_node_list(list)
+ if post then
+ setlink(posttail,posthead)
+ else
+ post = posthead
+ end
+ if replace then
+ setlink(replacetail,replacehead)
+ else
+ replace = replacehead
+ end
+ setdisc(disc,pre,post,replace)
+end
+
+local function markstoligature(head,start,stop,char)
+ if start == stop and getchar(start) == char then
+ return head, start
+ else
+ local prev = getprev(start)
+ local next = getnext(stop)
+ setprev(start)
+ setnext(stop)
+ local base = copy_no_components(start,copyinjection)
+ if head == start then
+ head = base
+ end
+ resetinjection(base)
+ setchar(base,char)
+ setsubtype(base,ligatureglyph_code)
+ set_components(base,start)
+ setlink(prev,base,next)
+ flush_components(start)
+ return head, base
+ end
+end
+
+-- Remark for Kai: (some arabic fonts do mark + mark = other mark and such)
+--
+-- The hasmarks is needed for ligatures of marks that are part of a ligature in
+-- which case we assume that we can delete the marks anyway (we can always become
+-- more clever if needed) .. in fact the whole logic here should be redone. We're
+-- in the not discfound branch then. We now have skiphash too so we can be more
+-- selective if needed (todo).
+
+-- we can have more granularity here but for now we only do a simple check
+
+local no_left_ligature_code = 1
+local no_right_ligature_code = 2
+local no_left_kern_code = 4
+local no_right_kern_code = 8
+
+local has_glyph_option = nuts.has_glyph_option
+
+-- in lmtx we need to check the components and can be slightly more clever
+
+local function inhibited(start,stop)
+ for n in nextnode, start do
+ -- we asume glyph nodes
+ if n == start then
+ if has_glyph_option(n,no_right_ligature_code) then
+ return true
+ end
+ elseif n == stop then
+ if has_glyph_option(n,no_left_ligature_code) then
+ return true
+ else
+ return false
+ end
+ elseif has_glyph_option(n,no_left_ligature_code) then
+ return true
+ elseif has_glyph_option(n,no_right_ligature_code) then
+ return true
+ end
+ end
+ return false
+end
+
+local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfound,hasmarks) -- brr head
+ if start == stop and getchar(start) == char then
+ resetinjection(start)
+ setchar(start,char)
+ return head, start
+ end
+ if inhibited(start,stop) then
+ return head, start
+ end
+ local prev = getprev(start)
+ local next = getnext(stop)
+ local comp = start
+ setprev(start)
+ setnext(stop)
+ local base = copy_no_components(start,copyinjection)
+ if start == head then
+ head = base
+ end
+ resetinjection(base)
+ setchar(base,char)
+ setoptions(base,getoptions(start) | getoptions(stop)) -- maybe only lig options
+ setsubtype(base,ligatureglyph_code)
+ set_components(base,comp)
+ setlink(prev,base,next)
+ if not discfound then
+ local deletemarks = not skiphash or hasmarks
+ local components = start -- not used
+ local baseindex = 0
+ local componentindex = 0
+ local head = base
+ local current = base
+ -- first we loop over the glyphs in start ... stop
+ while start do
+ local char = getchar(start)
+ if not marks[char] then
+ baseindex = baseindex + componentindex
+ componentindex = count_components(start,marks)
+ -- we can be more clever here: "not deletemarks or (skiphash and not skiphash[char])"
+ -- and such:
+ elseif not deletemarks then
+ -- we can get a loop when the font expects otherwise (i.e. unexpected deletemarks)
+ setligaindex(start,baseindex + getligaindex(start,componentindex))
+ if trace_marks then
+ logwarning("%s: keep ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start))
+ end
+ local n = copy_node(start)
+ copyinjection(n,start) -- is this ok ? we position later anyway
+ head, current = insert_node_after(head,current,n) -- unlikely that mark has components
+ elseif trace_marks then
+ logwarning("%s: delete ligature mark %s",pref(dataset,sequence),gref(char))
+ end
+ start = getnext(start)
+ end
+ -- we can have one accent as part of a lookup and another following
+ local start = getnext(current)
+ while start do
+ local nxt, char = isnextchar(start,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ -- also something skiphash here?
+ if marks[char] then
+ setligaindex(start,baseindex + getligaindex(start,componentindex))
+ if trace_marks then
+ logwarning("%s: set ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start))
+ end
+ start = nxt
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ flush_components(components)
+ else
+ -- discfound ... forget about marks .. probably no scripts that hyphenate and have marks
+ local discprev, discnext = getboth(discfound)
+ if discprev and discnext then
+ -- we assume normalization in context, and don't care about generic ... especially
+ -- \- can give problems as there we can have a negative char but that won't match
+ -- anyway
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(discfound,true)
+ if not replace then
+ -- looks like we never come here as it's not okay
+ local prev = getprev(base)
+ -- local comp = get_components(base) -- already set
+ local copied = copy_only_glyphs(comp)
+ if pre then
+ setlink(discprev,pre)
+ else
+ setnext(discprev) -- also blocks funny assignments
+ end
+ pre = comp -- is start
+ if post then
+ setlink(posttail,discnext)
+ setprev(post) -- nil anyway
+ else
+ post = discnext
+ setprev(discnext) -- also blocks funny assignments
+ end
+ setlink(prev,discfound,next)
+ setboth(base)
+ -- here components have a pointer so we can't free it!
+ set_components(base,copied)
+ replace = base
+ if forcediscretionaries then
+ setdisc(discfound,pre,post,replace,discretionarydisc_code)
+ else
+ setdisc(discfound,pre,post,replace)
+ end
+ base = prev
+ end
+ end
+ end
+ return head, base
+end
+
+local function multiple_glyphs(head,start,multiple,skiphash,what,stop) -- what to do with skiphash matches here
+ local nofmultiples = #multiple
+ if nofmultiples > 0 then
+ resetinjection(start)
+ setchar(start,multiple[1])
+ if nofmultiples > 1 then
+ local sn = getnext(start)
+ for k=2,nofmultiples do
+ -- untested:
+ --
+ -- while ignoremarks and marks[getchar(sn)] then
+ -- local sn = getnext(sn)
+ -- end
+ local n = copy_node(start) -- ignore components
+ resetinjection(n)
+ setchar(n,multiple[k])
+ insert_node_after(head,start,n)
+ start = n
+ end
+ if what == true then
+ -- we're ok
+ elseif what > 1 then
+ local m = multiple[nofmultiples]
+ for i=2,what do
+ local n = copy_node(start) -- ignore components
+ resetinjection(n)
+ setchar(n,m)
+ insert_node_after(head,start,n)
+ start = n
+ end
+ end
+ end
+ return head, start, true
+ else
+ if trace_multiples then
+ logprocess("no multiple for %s",gref(getchar(start)))
+ end
+ return head, start, false
+ end
+end
+
+local function get_alternative_glyph(start,alternatives,value)
+ local n = #alternatives
+ if n == 1 then
+ -- we could actually change that into a gsub and save some memory in the
+ -- font loader but it makes tracing more messy
+ return alternatives[1], trace_alternatives and "1 (only one present)"
+ elseif value == "random" then
+ local r = getrandom and getrandom("glyph",1,n) or random(1,n)
+ return alternatives[r], trace_alternatives and formatters["value %a, taking %a"](value,r)
+ elseif value == "first" then
+ return alternatives[1], trace_alternatives and formatters["value %a, taking %a"](value,1)
+ elseif value == "last" then
+ return alternatives[n], trace_alternatives and formatters["value %a, taking %a"](value,n)
+ end
+ value = value == true and 1 or tonumber(value)
+ if type(value) ~= "number" then
+ return alternatives[1], trace_alternatives and formatters["invalid value %s, taking %a"](value,1)
+ end
+ -- local a = alternatives[value]
+ -- if a then
+ -- -- some kind of hash
+ -- return a, trace_alternatives and formatters["value %a, taking %a"](value,a)
+ -- end
+ if value > n then
+ local defaultalt = otf.defaultnodealternate
+ if defaultalt == "first" then
+ return alternatives[n], trace_alternatives and formatters["invalid value %s, taking %a"](value,1)
+ elseif defaultalt == "last" then
+ return alternatives[1], trace_alternatives and formatters["invalid value %s, taking %a"](value,n)
+ else
+ return false, trace_alternatives and formatters["invalid value %a, %s"](value,"out of range")
+ end
+ elseif value == 0 then
+ return getchar(start), trace_alternatives and formatters["invalid value %a, %s"](value,"no change")
+ elseif value < 1 then
+ return alternatives[1], trace_alternatives and formatters["invalid value %a, taking %a"](value,1)
+ else
+ return alternatives[value], trace_alternatives and formatters["value %a, taking %a"](value,value)
+ end
+end
+
+-- handlers
+
+function handlers.gsub_single(head,start,dataset,sequence,replacement)
+ if trace_singles then
+ logprocess("%s: replacing %s by single %s",pref(dataset,sequence),gref(getchar(start)),gref(replacement))
+ end
+ resetinjection(start)
+ setchar(start,replacement)
+ return head, start, true
+end
+
+function handlers.gsub_alternate(head,start,dataset,sequence,alternative)
+ local kind = dataset[4]
+ local what = dataset[1]
+ local value = what == true and tfmdata.shared.features[kind] or what
+ local choice, comment = get_alternative_glyph(start,alternative,value)
+ if choice then
+ if trace_alternatives then
+ logprocess("%s: replacing %s by alternative %a to %s, %s",pref(dataset,sequence),gref(getchar(start)),gref(choice),comment)
+ end
+ resetinjection(start)
+ setchar(start,choice)
+ else
+ if trace_alternatives then
+ logwarning("%s: no variant %a for %s, %s",pref(dataset,sequence),value,gref(getchar(start)),comment)
+ end
+ end
+ return head, start, true
+end
+
+function handlers.gsub_multiple(head,start,dataset,sequence,multiple,rlmode,skiphash)
+ if trace_multiples then
+ logprocess("%s: replacing %s by multiple %s",pref(dataset,sequence),gref(getchar(start)),gref(multiple))
+ end
+ return multiple_glyphs(head,start,multiple,skiphash,dataset[1])
+end
+
+-- Don't we deal with disc otherwise now? I need to check if the next one can be
+-- simplified. Anyway, it can be way messier: marks that get removed as well as
+-- marks that are kept.
+
+function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skiphash)
+ local current = getnext(start)
+ if not current then
+ return head, start, false, nil
+ end
+ local stop = nil
+ local startchar = getchar(start)
+ if skiphash and skiphash[startchar] then
+ while current do
+ local nxt, char = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ local lg = ligature[char]
+ if lg then
+ stop = current
+ ligature = lg
+ current = nxt
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ if stop then
+ local lig = ligature.ligature
+ if lig then
+ if trace_ligatures then
+ local stopchar = getchar(stop)
+ head, start = markstoligature(head,start,stop,lig)
+ logprocess("%s: replacing %s upto %s by ligature %s case 1",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(getchar(start)))
+ else
+ head, start = markstoligature(head,start,stop,lig)
+ end
+ return head, start, true, false
+ else
+ -- ok, goto next lookup
+ end
+ end
+ else
+ local discfound = false
+ local hasmarks = marks[startchar]
+ while current do
+ local nxt, char, id = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ if skiphash and skiphash[char] then
+ current = nxt
+ else
+ local lg = ligature[char]
+ if lg then
+ if marks[char] then
+ hasmarks = true
+ end
+ stop = current -- needed for fake so outside then
+ ligature = lg
+ current = nxt
+ else
+ break
+ end
+ end
+ elseif char == false then
+ -- kind of weird
+ break
+ elseif id == disc_code then
+ discfound = current
+ break
+ else
+ break
+ end
+ end
+ -- of{f-}{}{f}e o{f-}{}{f}fe o{-}{}{ff}e (oe and ff ligature)
+ -- we can end up here when we have a start run .. testruns start at a disc but
+ -- so here we have the other case: char + disc
+ --
+ -- Challenge for Kai (latinmodern): \hyphenation{fii-f-f-iif} fiiffiif
+ --
+ if discfound then
+ -- don't assume marks in a disc and we don't run over a disc (for now)
+ local pre, post, replace = getdisc(discfound)
+ local match
+ if replace then
+ local nxt, char = isnextchar(replace,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char and ligature[char] then
+ match = true
+ end
+ end
+ if not match and pre then
+ local nxt, char = isnextchar(pre,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char and ligature[char] then
+ match = true
+ end
+ end
+ -- is this test ok:
+ if not match and not pre or not replace then
+ local nxt, char = isnextchar(getnext(discfound),currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char and ligature[char] then
+ match = true
+ end
+ end
+ if match then
+ -- we force a restart
+ local ishead = head == start
+ local prev = getprev(start)
+ if stop then
+ setnext(stop)
+ local copy = copy_node_list(start)
+ local tail = stop -- was: getprev(stop) -- Kai: needs checking on your samples
+ local liat = find_node_tail(copy)
+ if pre then
+ setlink(liat,pre)
+ end
+ if replace then
+ setlink(tail,replace)
+ end
+ pre = copy
+ replace = start
+ else
+ setnext(start)
+ local copy = copy_node(start)
+ if pre then
+ setlink(copy,pre)
+ end
+ if replace then
+ setlink(start,replace)
+ end
+ pre = copy
+ replace = start
+ end
+ setdisc(discfound,pre,post,replace)
+ if prev then
+ setlink(prev,discfound)
+ else
+ setprev(discfound)
+ head = discfound
+ end
+ start = discfound
+ return head, start, true, true
+ end
+ end
+ local lig = ligature.ligature
+ if lig then
+ if stop then
+ if trace_ligatures then
+ local stopchar = getchar(stop)
+ -- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks)
+ head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks)
+ logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(lig))
+ -- we can have a rare case of multiple disc in a lig but that makes no sense language wise but if really
+ -- needed we could backtrack if we're in a disc node
+ else
+ -- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks)
+ head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks)
+ end
+ else
+ -- weird but happens (in some arabic font)
+ resetinjection(start)
+ setchar(start,lig)
+ if trace_ligatures then
+ logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(dataset,sequence),gref(startchar),gref(lig))
+ end
+ end
+ return head, start, true, false
+ else
+ -- weird but happens, pseudo ligatures ... just the components
+ end
+ end
+ return head, start, false, false
+end
+
+function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection)
+ if has_glyph_option(start,no_right_kern_code) then
+ return head, start, false
+ else
+ local startchar = getchar(start)
+ local format = step.format
+ if format == "single" or type(kerns) == "table" then -- the table check can go
+ local dx, dy, w, h = setposition(0,start,factor,rlmode,kerns,injection)
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s xy (%p,%p) and wh (%p,%p)",pref(dataset,sequence),gref(startchar),format,dx,dy,w,h)
+ end
+ else
+ local k = (format == "move" and setmove or setkern)(start,factor,rlmode,kerns,injection)
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s %p",pref(dataset,sequence),gref(startchar),format,k)
+ end
+ end
+ return head, start, true
+ end
+end
+
+function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection)
+ if has_glyph_option(start,no_right_kern_code) then
+ return head, start, false
+ else
+ local snext = getnext(start)
+ if not snext then
+ return head, start, false
+ else
+ local prev = start
+ while snext do
+ local nxt, nextchar = isnextchar(snext,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if nextchar then
+ if skiphash and skiphash[nextchar] then -- includes marks too when flag
+ prev = snext
+ snext = nxt
+ else
+ local krn = kerns[nextchar]
+ if not krn then
+ break
+ end
+ local format = step.format
+ if format == "pair" then
+ local a = krn[1]
+ local b = krn[2]
+ if a == true then
+ -- zero
+ elseif a then -- #a > 0
+ local x, y, w, h = setposition(1,start,factor,rlmode,a,injection)
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting first of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections")
+ end
+ end
+ if b == true then
+ -- zero
+ start = snext -- cf spec
+ elseif b then -- #b > 0
+ local x, y, w, h = setposition(2,snext,factor,rlmode,b,injection)
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting second of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections")
+ end
+ start = snext -- cf spec
+ elseif forcepairadvance then
+ start = snext -- for testing, not cf spec
+ end
+ return head, start, true
+ elseif krn ~= 0 then
+ local k = (format == "move" and setmove or setkern)(snext,factor,rlmode,krn,injection)
+ if trace_kerns then
+ logprocess("%s: inserting %s %p between %s and %s as %s",pref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar),injection or "injections")
+ end
+ return head, start, true
+ else -- can't happen
+ break
+ end
+ end
+ else
+ break
+ end
+ end
+ return head, start, false
+ end
+ end
+end
+
+--[[ldx--
+
We get hits on a mark, but we're not sure if the it has to be applied so
+we need to explicitly test for basechar, baselig and basemark entries.
+--ldx]]--
+
+function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode,skiphash)
+ local markchar = getchar(start)
+ if marks[markchar] then
+ local base = getprev(start) -- [glyph] [start=mark]
+ if base then
+ local prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if marks[basechar] then
+ -- todo: use prv
+ while base do
+ base = getprev(base)
+ if base then
+ prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if not marks[basechar] then
+ break
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),1)
+ end
+ return head, start, false
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),2)
+ end
+ return head, start, false
+ end
+ end
+ end
+ local ba = markanchors[1][basechar]
+ if ba then
+ local ma = markanchors[2]
+ local dx, dy, bound = setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks)
+ if trace_marks then
+ logprocess("%s, bound %s, anchoring mark %s to basechar %s => (%p,%p)",
+ pref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy)
+ end
+ return head, start, true
+ elseif trace_bugs then
+ -- onetimemessage(currentfont,basechar,"no base anchors",report_fonts)
+ logwarning("%s: mark %s is not anchored to %s",pref(dataset,sequence),gref(markchar),gref(basechar))
+ end
+ elseif trace_bugs then
+ logwarning("%s: nothing preceding, case %i",pref(dataset,sequence),1)
+ end
+ elseif trace_bugs then
+ logwarning("%s: nothing preceding, case %i",pref(dataset,sequence),2)
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s is no mark",pref(dataset,sequence),gref(markchar))
+ end
+ return head, start, false
+end
+
+function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode,skiphash)
+ local markchar = getchar(start)
+ if marks[markchar] then
+ local base = getprev(start) -- [glyph] [optional marks] [start=mark]
+ if base then
+ local prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if marks[basechar] then
+ -- todo: use prv
+ while base do
+ base = getprev(base)
+ if base then
+ prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if not marks[basechar] then
+ break
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),1)
+ end
+ return head, start, false
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),2)
+ end
+ return head, start, false
+ end
+ end
+ end
+ local ba = markanchors[1][basechar]
+ if ba then
+ local ma = markanchors[2]
+ if ma then
+ local index = getligaindex(start)
+ ba = ba[index]
+ if ba then
+ local dx, dy, bound = setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks)
+ if trace_marks then
+ logprocess("%s, index %s, bound %s, anchoring mark %s to baselig %s at index %s => (%p,%p)",
+ pref(dataset,sequence),index,bound,gref(markchar),gref(basechar),index,dx,dy)
+ end
+ return head, start, true
+ else
+ if trace_bugs then
+ logwarning("%s: no matching anchors for mark %s and baselig %s with index %a",pref(dataset,sequence),gref(markchar),gref(basechar),index)
+ end
+ end
+ end
+ elseif trace_bugs then
+ -- logwarning("%s: char %s is missing in font",pref(dataset,sequence),gref(basechar))
+ onetimemessage(currentfont,basechar,"no base anchors",report_fonts)
+ end
+ elseif trace_bugs then
+ logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),1)
+ end
+ elseif trace_bugs then
+ logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),2)
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s is no mark",pref(dataset,sequence),gref(markchar))
+ end
+ return head, start, false
+end
+
+function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode,skiphash)
+ local markchar = getchar(start)
+ if marks[markchar] then
+ local base = getprev(start) -- [glyph] [basemark] [start=mark]
+ local slc = getligaindex(start)
+ if slc then -- a rather messy loop ... needs checking with husayni
+ while base do
+ local blc = getligaindex(base)
+ if blc and blc ~= slc then
+ base = getprev(base)
+ else
+ break
+ end
+ end
+ end
+ if base then
+ local nxt, basechar = isnextchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then -- subtype test can go
+ local ba = markanchors[1][basechar] -- slot 1 has been made copy of the class hash
+ if ba then
+ local ma = markanchors[2]
+ local dx, dy, bound = setmark(start,base,factor,rlmode,ba,ma,characters[basechar],true,checkmarks)
+ if trace_marks then
+ logprocess("%s, bound %s, anchoring mark %s to basemark %s => (%p,%p)",
+ pref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy)
+ end
+ return head, start, true
+ end
+ end
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s is no mark",pref(dataset,sequence),gref(markchar))
+ end
+ return head, start, false
+end
+
+function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,skiphash,step) -- to be checked
+ local startchar = getchar(start)
+ if marks[startchar] then
+ if trace_cursive then
+ logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar))
+ end
+ else
+ local nxt = getnext(start)
+ while nxt do
+ local n, nextchar = isnextchar(nxt,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if not nextchar then
+ break
+ elseif marks[nextchar] then -- always sequence.flags[1]
+ nxt = n
+ else
+ local exit = exitanchors[3]
+ if exit then
+ local entry = exitanchors[1][nextchar]
+ if entry then
+ entry = entry[2]
+ if entry then
+ local r2lflag = sequence.flags[4] -- mentioned in the standard
+ local dx, dy, bound = setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar],r2lflag)
+ if trace_cursive then
+ logprocess("%s: moving %s to %s cursive (%p,%p) using bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,bound,mref(rlmode))
+ end
+ return head, start, true
+ end
+ end
+ end
+ break
+ end
+ end
+ end
+ return head, start, false
+end
+
+--[[ldx--
+
I will implement multiple chain replacements once I run into a font that uses
+it. It's not that complex to handle.
+--ldx]]--
+
+local chainprocs = { }
+
+local function logprocess(...)
+ if trace_steps then
+ registermessage(...)
+ if trace_steps == "silent" then
+ return
+ end
+ end
+ report_subchain(...)
+end
+
+local logwarning = report_subchain
+
+local function logprocess(...)
+ if trace_steps then
+ registermessage(...)
+ if trace_steps == "silent" then
+ return
+ end
+ end
+ report_chain(...)
+end
+
+local logwarning = report_chain
+
+-- We could share functions but that would lead to extra function calls with many
+-- arguments, redundant tests and confusing messages.
+
+-- The reversesub is a special case, which is why we need to store the replacements
+-- in a bit weird way. There is no lookup and the replacement comes from the lookup
+-- itself. It is meant mostly for dealing with Urdu.
+
+local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode,skiphash)
+ local char = getchar(start)
+ local replacement = replacements[char]
+ if replacement then
+ if trace_singles then
+ logprocess("%s: single reverse replacement of %s by %s",cref(dataset,sequence),gref(char),gref(replacement))
+ end
+ resetinjection(start)
+ setchar(start,replacement)
+ return head, start, true
+ else
+ return head, start, false
+ end
+end
+
+
+chainprocs.reversesub = reversesub
+
+--[[ldx--
+
This chain stuff is somewhat tricky since we can have a sequence of actions to be
+applied: single, alternate, multiple or ligature where ligature can be an invalid
+one in the sense that it will replace multiple by one but not neccessary one that
+looks like the combination (i.e. it is the counterpart of multiple then). For
+example, the following is valid:
Therefore we we don't really do the replacement here already unless we have the
+single lookup case. The efficiency of the replacements can be improved by deleting
+as less as needed but that would also make the code even more messy.
+--ldx]]--
+
+--[[ldx--
+
Here we replace start by a single variant.
+--ldx]]--
+
+-- To be done (example needed): what if > 1 steps
+
+-- this is messy: do we need this disc checking also in alternaties?
+
+local function reportzerosteps(dataset,sequence)
+ logwarning("%s: no steps",cref(dataset,sequence))
+end
+
+local function reportmoresteps(dataset,sequence)
+ logwarning("%s: more than 1 step",cref(dataset,sequence))
+end
+
+-- local function reportbadsteps(dataset,sequence)
+-- logwarning("%s: bad step, no proper return values",cref(dataset,sequence))
+-- end
+
+local function getmapping(dataset,sequence,currentlookup)
+ local steps = currentlookup.steps
+ local nofsteps = currentlookup.nofsteps
+ if nofsteps == 0 then
+ reportzerosteps(dataset,sequence)
+ currentlookup.mapping = false
+ return false
+ else
+ if nofsteps > 1 then
+ reportmoresteps(dataset,sequence)
+ end
+ local mapping = steps[1].coverage
+ currentlookup.mapping = mapping
+ currentlookup.format = steps[1].format
+ return mapping
+ end
+end
+
+function chainprocs.gsub_remove(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ if trace_chains then
+ logprocess("%s: removing character %s",cref(dataset,sequence,chainindex),gref(getchar(start)))
+ end
+ head, start = remove_node(head,start,true)
+ return head, getprev(start), true
+end
+
+function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local current = start
+ while current do
+ local nxt, currentchar = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if currentchar then
+ local replacement = mapping[currentchar]
+ if not replacement or replacement == "" then
+ if trace_bugs then
+ logwarning("%s: no single for %s",cref(dataset,sequence,chainindex),gref(currentchar))
+ end
+ else
+ if trace_singles then
+ logprocess("%s: replacing single %s by %s",cref(dataset,sequence,chainindex),gref(currentchar),gref(replacement))
+ end
+ resetinjection(current)
+ setchar(current,replacement)
+ end
+ return head, start, true
+ elseif currentchar == false then
+ -- can't happen
+ break
+ elseif current == stop then
+ break
+ else
+ current = nxt
+ end
+ end
+ end
+ return head, start, false
+end
+
+--[[ldx--
+
Here we replace start by new glyph. First we delete the rest of the match.
+--ldx]]--
+
+-- char_1 mark_1 -> char_x mark_1 (ignore marks)
+-- char_1 mark_1 -> char_x
+
+-- to be checked: do we always have just one glyph?
+-- we can also have alternates for marks
+-- marks come last anyway
+-- are there cases where we need to delete the mark
+
+function chainprocs.gsub_alternate(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local kind = dataset[4]
+ local what = dataset[1]
+ local value = what == true and tfmdata.shared.features[kind] or what -- todo: optimize in ctx
+ local current = start
+ while current do
+ local nxt, currentchar = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if currentchar then
+ local alternatives = mapping[currentchar]
+ if alternatives then
+ local choice, comment = get_alternative_glyph(current,alternatives,value)
+ if choice then
+ if trace_alternatives then
+ logprocess("%s: replacing %s by alternative %a to %s, %s",cref(dataset,sequence),gref(currentchar),choice,gref(choice),comment)
+ end
+ resetinjection(start)
+ setchar(start,choice)
+ else
+ if trace_alternatives then
+ logwarning("%s: no variant %a for %s, %s",cref(dataset,sequence),value,gref(currentchar),comment)
+ end
+ end
+ end
+ return head, start, true
+ elseif currentchar == false then
+ -- can't happen
+ break
+ elseif current == stop then
+ break
+ else
+ current = nxt
+ end
+ end
+ end
+ return head, start, false
+end
+
+--[[ldx--
+
Here we replace start by a sequence of new glyphs.
+--ldx]]--
+
+function chainprocs.gsub_multiple(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local startchar = getchar(start)
+ local replacement = mapping[startchar]
+ if not replacement or replacement == "" then
+ if trace_bugs then
+ logwarning("%s: no multiple for %s",cref(dataset,sequence),gref(startchar))
+ end
+ else
+ if trace_multiples then
+ logprocess("%s: replacing %s by multiple characters %s",cref(dataset,sequence),gref(startchar),gref(replacement))
+ end
+ return multiple_glyphs(head,start,replacement,skiphash,dataset[1],stop)
+ end
+ end
+ return head, start, false
+end
+
+--[[ldx--
+
When we replace ligatures we use a helper that handles the marks. I might change
+this function (move code inline and handle the marks by a separate function). We
+assume rather stupid ligatures (no complex disc nodes).
+--ldx]]--
+
+-- compare to handlers.gsub_ligature which is more complex ... why
+
+function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local startchar = getchar(start)
+ local ligatures = mapping[startchar]
+ if not ligatures then
+ if trace_bugs then
+ logwarning("%s: no ligatures starting with %s",cref(dataset,sequence,chainindex),gref(startchar))
+ end
+ else
+ local hasmarks = marks[startchar]
+ local current = getnext(start)
+ local discfound = false
+ local last = stop
+ local nofreplacements = 1
+ while current do
+ -- todo: ischar ... can there really be disc nodes here?
+-- local id = getid(current)
+-- if id == disc_code then
+-- if not discfound then
+-- discfound = current
+-- end
+-- if current == stop then
+-- break -- okay? or before the disc
+-- else
+-- current = getnext(current)
+-- end
+-- else
+-- local schar = getchar(current)
+-- if skiphash and skiphash[schar] then -- marks
+-- -- if current == stop then -- maybe add this
+-- -- break
+-- -- else
+-- current = getnext(current)
+-- -- end
+-- else
+-- local lg = ligatures[schar]
+-- if lg then
+-- ligatures = lg
+-- last = current
+-- nofreplacements = nofreplacements + 1
+-- if marks[char] then
+-- hasmarks = true
+-- end
+-- if current == stop then
+-- break
+-- else
+-- current = getnext(current)
+-- end
+-- else
+-- break
+-- end
+-- end
+-- end
+ --
+ local nxt, schar, id = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if schar then
+ if skiphash and skiphash[schar] then -- marks
+ -- if current == stop then -- maybe add this
+ -- break
+ -- else
+ current = nxt
+ -- end
+ else
+ local lg = ligatures[schar]
+ if lg then
+ ligatures = lg
+ last = current
+ nofreplacements = nofreplacements + 1
+ if marks[char] then
+ hasmarks = true
+ end
+ if current == stop then
+ break
+ else
+ current = nxt
+ end
+ else
+ break
+ end
+ end
+ elseif id == disc_code then
+ if not discfound then
+ discfound = current
+ end
+ if current == stop then
+ break -- okay? or before the disc
+ else
+ current = nxt
+ end
+ else
+ break
+ end
+ --
+ end
+ local ligature = ligatures.ligature
+ if ligature then
+ if chainindex then
+ stop = last
+ end
+ if trace_ligatures then
+ if start == stop then
+ logprocess("%s: replacing character %s by ligature %s case 3",cref(dataset,sequence,chainindex),gref(startchar),gref(ligature))
+ else
+ logprocess("%s: replacing character %s upto %s by ligature %s case 4",cref(dataset,sequence,chainindex),gref(startchar),gref(getchar(stop)),gref(ligature))
+ end
+ end
+ head, start = toligature(head,start,stop,ligature,dataset,sequence,skiphash,discfound,hasmarks)
+ return head, start, true, nofreplacements, discfound
+ elseif trace_bugs then
+ if start == stop then
+ logwarning("%s: replacing character %s by ligature fails",cref(dataset,sequence,chainindex),gref(startchar))
+ else
+ logwarning("%s: replacing character %s upto %s by ligature fails",cref(dataset,sequence,chainindex),gref(startchar),gref(getchar(stop)))
+ end
+ end
+ end
+ end
+ return head, start, false, 0, false
+end
+
+function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ -- we actually should check no_left_kern_code with next
+ if not has_glyph_option(start,no_right_kern_code) then
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local startchar = getchar(start)
+ local kerns = mapping[startchar]
+ if kerns then
+ local format = currentlookup.format
+ if format == "single" then
+ local dx, dy, w, h = setposition(0,start,factor,rlmode,kerns) -- currentlookup.flags ?
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),format,dx,dy,w,h)
+ end
+ else -- needs checking .. maybe no kerns format for single
+ local k = (format == "move" and setmove or setkern)(start,factor,rlmode,kerns,injection)
+ if trace_kerns then
+ logprocess("%s: shifting single %s by %s %p",cref(dataset,sequence),gref(startchar),format,k)
+ end
+ end
+ return head, start, true
+ end
+ end
+ end
+ return head, start, false
+end
+
+function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) -- todo: injections ?
+ -- we actually should check no_left_kern_code with next
+ if not has_glyph_option(start,no_right_kern_code) then
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local snext = getnext(start)
+ if snext then
+ local startchar = getchar(start)
+ local kerns = mapping[startchar] -- always 1 step
+ if kerns then
+ local prev = start
+ while snext do
+ local nxt, nextchar = isnextchar(snext,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if not nextchar then
+ break
+ elseif skiphash and skiphash[nextchar] then
+ prev = snext
+ snext = nxt
+ else
+ local krn = kerns[nextchar]
+ if not krn then
+ break
+ end
+ local format = currentlookup.format
+ if format == "pair" then
+ local a = krn[1]
+ local b = krn[2]
+ if a == true then
+ -- zero
+ elseif a then
+ local x, y, w, h = setposition(1,start,factor,rlmode,a,"injections") -- currentlookups flags?
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting first of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h)
+ end
+ end
+ if b == true then
+ -- zero
+ start = snext -- cf spec
+ elseif b then -- #b > 0
+ local x, y, w, h = setposition(2,snext,factor,rlmode,b,"injections")
+ if trace_kerns then
+ local startchar = getchar(start)
+ logprocess("%s: shifting second of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h)
+ end
+ start = snext -- cf spec
+ elseif forcepairadvance then
+ start = snext -- for testing, not cf spec
+ end
+ return head, start, true
+ elseif krn ~= 0 then
+ local k = (format == "move" and setmove or setkern)(snext,factor,rlmode,krn)
+ if trace_kerns then
+ logprocess("%s: inserting %s %p between %s and %s",cref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar))
+ end
+ return head, start, true
+ else
+ break
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return head, start, false
+end
+
+function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local markchar = getchar(start)
+ if marks[markchar] then
+ local markanchors = mapping[markchar] -- always 1 step
+ if markanchors then
+ local base = getprev(start) -- [glyph] [start=mark]
+ if base then
+ local prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if marks[basechar] then
+ -- todo: use prv
+ while base do
+ base = getprev(base)
+ if base then
+ local prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if not marks[basechar] then
+ break
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),1)
+ end
+ return head, start, false
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),2)
+ end
+ return head, start, false
+ end
+ end
+ end
+ local ba = markanchors[1][basechar]
+ if ba then
+ local ma = markanchors[2]
+ if ma then
+ local dx, dy, bound = setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks)
+ if trace_marks then
+ logprocess("%s, bound %s, anchoring mark %s to basechar %s => (%p,%p)",
+ cref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy)
+ end
+ return head, start, true
+ end
+ end
+ elseif trace_bugs then
+ logwarning("%s: prev node is no char, case %i",cref(dataset,sequence),1)
+ end
+ elseif trace_bugs then
+ logwarning("%s: prev node is no char, case %i",cref(dataset,sequence),2)
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s has no anchors",cref(dataset,sequence),gref(markchar))
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s is no mark",cref(dataset,sequence),gref(markchar))
+ end
+ end
+ return head, start, false
+end
+
+function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local markchar = getchar(start)
+ if marks[markchar] then
+ local markanchors = mapping[markchar] -- always 1 step
+ if markanchors then
+ local base = getprev(start) -- [glyph] [optional marks] [start=mark]
+ if base then
+ local prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if marks[basechar] then
+ -- todo: use prv
+ while base do
+ base = getprev(base)
+ if base then
+ local prv, basechar = isprevchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ if not marks[basechar] then
+ break
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",cref(dataset,sequence),markchar,1)
+ end
+ return head, start, false
+ end
+ else
+ if trace_bugs then
+ logwarning("%s: no base for mark %s, case %i",cref(dataset,sequence),markchar,2)
+ end
+ return head, start, false
+ end
+ end
+ end
+ local ba = markanchors[1][basechar]
+ if ba then
+ local ma = markanchors[2]
+ if ma then
+ local index = getligaindex(start)
+ ba = ba[index]
+ if ba then
+ local dx, dy, bound = setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks)
+ if trace_marks then
+ logprocess("%s, bound %s, anchoring mark %s to baselig %s at index %s => (%p,%p)",
+ cref(dataset,sequence),a or bound,gref(markchar),gref(basechar),index,dx,dy)
+ end
+ return head, start, true
+ end
+ end
+ end
+ elseif trace_bugs then
+ logwarning("%s, prev node is no char, case %i",cref(dataset,sequence),1)
+ end
+ elseif trace_bugs then
+ logwarning("%s, prev node is no char, case %i",cref(dataset,sequence),2)
+ end
+ elseif trace_bugs then
+ logwarning("%s, mark %s has no anchors",cref(dataset,sequence),gref(markchar))
+ end
+ elseif trace_bugs then
+ logwarning("%s, mark %s is no mark",cref(dataset,sequence),gref(markchar))
+ end
+ end
+ return head, start, false
+end
+
+function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local markchar = getchar(start)
+ if marks[markchar] then
+ local markanchors = mapping[markchar] -- always 1 step
+ if markanchors then
+ local base = getprev(start) -- [glyph] [basemark] [start=mark]
+ local slc = getligaindex(start)
+ if slc then -- a rather messy loop ... needs checking with husayni
+ while base do
+ local blc = getligaindex(base)
+ if blc and blc ~= slc then
+ base = getprev(base)
+ else
+ break
+ end
+ end
+ end
+ if base then -- subtype test can go
+ local nxt, basechar = isnextchar(base,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if basechar then
+ local ba = markanchors[1][basechar]
+ if ba then
+ local ma = markanchors[2]
+ if ma then
+ local dx, dy, bound = setmark(start,base,factor,rlmode,ba,ma,characters[basechar],true,checkmarks)
+ if trace_marks then
+ logprocess("%s, bound %s, anchoring mark %s to basemark %s => (%p,%p)",
+ cref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy)
+ end
+ return head, start, true
+ end
+ end
+ elseif trace_bugs then
+ logwarning("%s: prev node is no mark, case %i",cref(dataset,sequence),1)
+ end
+ elseif trace_bugs then
+ logwarning("%s: prev node is no mark, case %i",cref(dataset,sequence),2)
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s has no anchors",cref(dataset,sequence),gref(markchar))
+ end
+ elseif trace_bugs then
+ logwarning("%s: mark %s is no mark",cref(dataset,sequence),gref(markchar))
+ end
+ end
+ return head, start, false
+end
+
+function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
+ local mapping = currentlookup.mapping
+ if mapping == nil then
+ mapping = getmapping(dataset,sequence,currentlookup)
+ end
+ if mapping then
+ local startchar = getchar(start)
+ local exitanchors = mapping[startchar] -- always 1 step
+ if exitanchors then
+ if marks[startchar] then
+ if trace_cursive then
+ logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar))
+ end
+ else
+ local nxt = getnext(start)
+ while nxt do
+ local n, nextchar = isnextchar(nxt,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if not nextchar then
+ break
+ elseif marks[nextchar] then
+ -- should not happen (maybe warning)
+ nxt = n
+ else
+ local exit = exitanchors[3]
+ if exit then
+ local entry = exitanchors[1][nextchar]
+ if entry then
+ entry = entry[2]
+ if entry then
+ local r2lflag = sequence.flags[4] -- mentioned in the standard
+ local dx, dy, bound = setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar],r2lflag)
+ if trace_cursive then
+ logprocess("%s: moving %s to %s cursive (%p,%p) using bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,bound,mref(rlmode))
+ end
+ return head, start, true
+ end
+ end
+ elseif trace_bugs then
+ onetimemessage(currentfont,startchar,"no entry anchors",report_fonts)
+ end
+ break
+ end
+ end
+ end
+ elseif trace_cursive and trace_details then
+ logprocess("%s, cursive %s is already done",pref(dataset,sequence),gref(getchar(start)),alreadydone)
+ end
+ end
+ return head, start, false
+end
+
+-- what pointer to return, spec says stop
+-- to be discussed ... is bidi changer a space?
+-- elseif char == zwnj and sequence[n][32] then -- brrr
+
+local function show_skip(dataset,sequence,char,ck,class)
+ logwarning("%s: skipping char %s, class %a, rule %a, lookuptype %a",cref(dataset,sequence),gref(char),class,ck[1],ck[8] or ck[2])
+end
+
+-- A previous version had disc collapsing code in the (single sub) handler plus some
+-- checking in the main loop, but that left the pre/post sequences undone. The best
+-- solution is to add some checking there and backtrack when a replace/post matches
+-- but it takes a bit of work to figure out an efficient way (this is what the
+-- sweep* names refer to). I might look into that variant one day again as it can
+-- replace some other code too. In that approach we can have a special version for
+-- gub and pos which gains some speed. This method does the test and passes info to
+-- the handlers. Here collapsing is handled in the main loop which also makes code
+-- elsewhere simpler (i.e. no need for the other special runners and disc code in
+-- ligature building). I also experimented with pushing preceding glyphs sequences
+-- in the replace/pre fields beforehand which saves checking afterwards but at the
+-- cost of duplicate glyphs (memory) but it's too much overhead (runtime).
+--
+-- In the meantime Kai had moved the code from the single chain into a more general
+-- handler and this one (renamed to chaindisk) is used now. I optimized the code a
+-- bit and brought it in sycn with the other code. Hopefully I didn't introduce
+-- errors. Note: this somewhat complex approach is meant for fonts that implement
+-- (for instance) ligatures by character replacement which to some extend is not
+-- that suitable for hyphenation. I also use some helpers. This method passes some
+-- states but reparses the list. There is room for a bit of speed up but that will
+-- be done in the context version. (In fact a partial rewrite of all code can bring
+-- some more efficiency.)
+--
+-- I didn't test it with extremes but successive disc nodes still can give issues
+-- but in order to handle that we need more complex code which also slows down even
+-- more. The main loop variant could deal with that: test, collapse, backtrack.
+
+local userkern = nuts.pool and nuts.pool.newkern -- context
+
+do if not userkern then -- generic
+
+ local thekern = nuts.new("kern",1) -- userkern
+ local setkern = nuts.setkern -- not injections.setkern
+
+ userkern = function(k)
+ local n = copy_node(thekern)
+ setkern(n,k)
+ return n
+ end
+
+end end
+
+local function checked(head)
+ local current = head
+ while current do
+ if getid(current) == glue_code then
+ local kern = userkern(getwidth(current))
+ if head == current then
+ local next = getnext(current)
+ if next then
+ setlink(kern,next)
+ end
+ flush_node(current)
+ head = kern
+ current = next
+ else
+ local prev, next = getboth(current)
+ setlink(prev,kern,next)
+ flush_node(current)
+ current = next
+ end
+ else
+ current = getnext(current)
+ end
+ end
+ return head
+end
+
+local function setdiscchecked(d,pre,post,replace)
+ if pre then pre = checked(pre) end
+ if post then post = checked(post) end
+ if replace then replace = checked(replace) end
+ setdisc(d,pre,post,replace)
+end
+
+local noflags = { false, false, false, false }
+
+local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck)
+
+ local size = ck[5] - ck[4] + 1
+ local chainlookups = ck[6]
+ local done = false
+
+ -- current match
+ if chainlookups then
+ -- Lookups can be like { 1, false, 3 } or { false, 2 } or basically anything and
+ -- #lookups can be less than #current
+
+ if size == 1 then
+
+ -- if nofchainlookups > size then
+ -- -- bad rules
+ -- end
+
+ local chainlookup = chainlookups[1]
+ for j=1,#chainlookup do
+ local chainstep = chainlookup[j]
+ local chainkind = chainstep.type
+ local chainproc = chainprocs[chainkind]
+ if chainproc then
+ local ok
+ head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash)
+ if ok then
+ done = true
+ end
+ else
+ logprocess("%s: %s is not yet supported (1)",cref(dataset,sequence),chainkind)
+ end
+ end
+
+ else
+
+ -- See LookupType 5: Contextual Substitution Subtable. Now it becomes messy. The
+ -- easiest case is where #current maps on #lookups i.e. one-to-one. But what if
+ -- we have a ligature. Cf the spec we then need to advance one character but we
+ -- really need to test it as there are fonts out there that are fuzzy and have
+ -- too many lookups:
+ --
+ -- U+1105 U+119E U+1105 U+119E : sourcehansansklight: script=hang ccmp=yes
+ --
+ -- Even worse are these family emoji shapes as they can have multiple lookups
+ -- per slot (probably only for gpos).
+
+ -- It's very unlikely that we will have skip classes here but still ... we seldom
+ -- enter this branch anyway.
+
+ local i = 1
+ local laststart = start
+ local nofchainlookups = #chainlookups -- useful?
+ while start do
+ if skiphash then -- hm, so we know we skip some
+ while start do
+ local nxt, char = isnextchar(start,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ if skiphash and skiphash[char] then
+ start = nxt
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ end
+ local chainlookup = chainlookups[i]
+ if chainlookup then
+ for j=1,#chainlookup do
+ local chainstep = chainlookup[j]
+ local chainkind = chainstep.type
+ local chainproc = chainprocs[chainkind]
+ if chainproc then
+ local ok, n
+ head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,i)
+ -- messy since last can be changed !
+ if ok then
+ done = true
+ if n and n > 1 and i + n > nofchainlookups then
+ -- this is a safeguard, we just ignore the rest of the lookups
+ i = size -- prevents an advance
+ break
+ end
+ end
+ else
+ -- actually an error
+ logprocess("%s: %s is not yet supported (2)",cref(dataset,sequence),chainkind)
+ end
+ end
+ else
+ -- we skip but we could also delete as option .. what does an empty lookup actually mean
+ -- in opentype ... anyway, we could map it onto gsub_remove if needed
+ end
+ i = i + 1
+ if i > size or not start then
+ break
+ elseif start then
+ laststart = start
+ start = getnext(start)
+ end
+ end
+ if not start then
+ start = laststart
+ end
+
+ end
+ else
+ -- todo: needs checking for holes in the replacements
+ local replacements = ck[7]
+ if replacements then
+ head, start, done = reversesub(head,start,last,dataset,sequence,replacements,rlmode,skiphash)
+ else
+ done = true
+ if trace_contexts then
+ logprocess("%s: skipping match",cref(dataset,sequence))
+ end
+ end
+ end
+ return head, start, done
+end
+
+local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
+
+ if not start then
+ return head, start, false
+ end
+
+ local startishead = start == head
+ local seq = ck[3]
+ local f = ck[4]
+ local l = ck[5]
+ local s = #seq
+ local done = false
+ local sweepnode = sweepnode
+ local sweeptype = sweeptype
+ local sweepoverflow = false
+ local checkdisc = getprev(head)
+ local keepdisc = not sweepnode
+ local lookaheaddisc = nil
+ local backtrackdisc = nil
+ local current = start
+ local last = start
+ local prev = getprev(start)
+ local hasglue = false
+
+ -- fishy: so we can overflow and then go on in the sweep?
+ -- todo : id can also be glue_code as we checked spaces
+
+ local i = f
+ while i <= l do
+ local id = getid(current)
+ if id == glyph_code then
+ i = i + 1
+ last = current
+ current = getnext(current)
+ elseif id == glue_code then
+ i = i + 1
+ last = current
+ current = getnext(current)
+ hasglue = true
+ elseif id == disc_code then
+ if keepdisc then
+ keepdisc = false
+ lookaheaddisc = current
+ local replace = getreplace(current)
+ if not replace then
+ sweepoverflow = true
+ sweepnode = current
+ current = getnext(current)
+ else
+ -- we can use an iterator
+ while replace and i <= l do
+ if getid(replace) == glyph_code then
+ i = i + 1
+ end
+ replace = getnext(replace)
+ end
+ current = getnext(replace)
+ end
+ last = current
+ else
+ head, current = flattendisk(head,current)
+ end
+ else
+ last = current
+ current = getnext(current)
+ end
+ if current then
+ -- go on
+ elseif sweepoverflow then
+ -- we already are following up on sweepnode
+ break
+ elseif sweeptype == "post" or sweeptype == "replace" then
+ current = getnext(sweepnode)
+ if current then
+ sweeptype = nil
+ sweepoverflow = true
+ else
+ break
+ end
+ else
+ break -- added
+ end
+ end
+
+ if sweepoverflow then
+ local prev = current and getprev(current)
+ if not current or prev ~= sweepnode then
+ local head = getnext(sweepnode)
+ local tail = nil
+ if prev then
+ tail = prev
+ setprev(current,sweepnode)
+ else
+ tail = find_node_tail(head)
+ end
+ setnext(sweepnode,current)
+ setprev(head)
+ setnext(tail)
+ appenddisc(sweepnode,head)
+ end
+ end
+
+ if l < s then
+ local i = l
+ local t = sweeptype == "post" or sweeptype == "replace"
+ while current and i < s do
+ local id = getid(current)
+ if id == glyph_code then
+ i = i + 1
+ current = getnext(current)
+ elseif id == glue_code then
+ i = i + 1
+ current = getnext(current)
+ hasglue = true
+ elseif id == disc_code then
+ if keepdisc then
+ keepdisc = false
+ if notmatchpre[current] ~= notmatchreplace[current] then
+ lookaheaddisc = current
+ end
+ -- we assume a simple text only replace (we could use nuts.count)
+ local replace = getreplace(current)
+ while replace and i < s do
+ if getid(replace) == glyph_code then
+ i = i + 1
+ end
+ replace = getnext(replace)
+ end
+ current = getnext(current)
+ elseif notmatchpre[current] ~= notmatchreplace[current] then
+ head, current = flattendisk(head,current)
+ else
+ current = getnext(current) -- HH
+ end
+ else
+ current = getnext(current)
+ end
+ if not current and t then
+ current = getnext(sweepnode)
+ if current then
+ sweeptype = nil
+ end
+ end
+ end
+ end
+
+ if f > 1 then
+ local current = prev
+ local i = f
+ local t = sweeptype == "pre" or sweeptype == "replace"
+ if not current and t and current == checkdisc then
+ current = getprev(sweepnode)
+ end
+ while current and i > 1 do -- missing getprev added / moved outside
+ local id = getid(current)
+ if id == glyph_code then
+ i = i - 1
+ elseif id == glue_code then
+ i = i - 1
+ hasglue = true
+ elseif id == disc_code then
+ if keepdisc then
+ keepdisc = false
+ if notmatchpost[current] ~= notmatchreplace[current] then
+ backtrackdisc = current
+ end
+ -- we assume a simple text only replace (we could use nuts.count)
+ local replace = getreplace(current)
+ while replace and i > 1 do
+ if getid(replace) == glyph_code then
+ i = i - 1
+ end
+ replace = getnext(replace)
+ end
+ elseif notmatchpost[current] ~= notmatchreplace[current] then
+ head, current = flattendisk(head,current)
+ end
+ end
+ current = getprev(current)
+ if t and current == checkdisc then
+ current = getprev(sweepnode)
+ end
+ end
+ end
+ local done = false
+
+ if lookaheaddisc then
+
+ local cf = start
+ local cl = getprev(lookaheaddisc)
+ local cprev = getprev(start)
+ local insertedmarks = 0
+
+ while cprev do
+ local nxt, char = isnextchar(cf,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char and marks[char] then
+ insertedmarks = insertedmarks + 1
+ cf = cprev
+ startishead = cf == head
+ cprev = getprev(cprev)
+ else
+ break
+ end
+ end
+ setlink(cprev,lookaheaddisc)
+ setprev(cf)
+ setnext(cl)
+ if startishead then
+ head = lookaheaddisc
+ end
+ local pre, post, replace = getdisc(lookaheaddisc)
+ local new = copy_node_list(cf) -- br, how often does that happen
+ local cnew = new
+ if pre then
+ setlink(find_node_tail(cf),pre)
+ end
+ if replace then
+ local tail = find_node_tail(new)
+ setlink(tail,replace)
+ end
+ for i=1,insertedmarks do
+ cnew = getnext(cnew)
+ end
+ cl = start
+ local clast = cnew
+ for i=f,l do
+ cl = getnext(cl)
+ clast = getnext(clast)
+ end
+ if not notmatchpre[lookaheaddisc] then
+ local ok = false
+ cf, start, ok = chainrun(cf,start,cl,dataset,sequence,rlmode,skiphash,ck)
+ if ok then
+ done = true
+ end
+ end
+ if not notmatchreplace[lookaheaddisc] then
+ local ok = false
+ new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck)
+ if ok then
+ done = true
+ end
+ end
+ if hasglue then
+ setdiscchecked(lookaheaddisc,cf,post,new)
+ else
+ setdisc(lookaheaddisc,cf,post,new)
+ end
+ start = getprev(lookaheaddisc)
+ sweephead[cf] = getnext(clast) or false
+ sweephead[new] = getnext(cl) or false
+
+ elseif backtrackdisc then
+
+ local cf = getnext(backtrackdisc)
+ local cl = start
+ local cnext = getnext(start)
+ local insertedmarks = 0
+
+ while cnext do
+ local nxt, char = isnextchar(cnext,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char and marks[char] then
+ insertedmarks = insertedmarks + 1
+ cl = cnext
+ cnext = nxt
+ else
+ break
+ end
+ end
+ setlink(backtrackdisc,cnext)
+ setprev(cf)
+ setnext(cl)
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(backtrackdisc,true)
+ local new = copy_node_list(cf)
+ local cnew = find_node_tail(new)
+ for i=1,insertedmarks do
+ cnew = getprev(cnew)
+ end
+ local clast = cnew
+ for i=f,l do
+ clast = getnext(clast)
+ end
+ if not notmatchpost[backtrackdisc] then
+ local ok = false
+ cf, start, ok = chainrun(cf,start,last,dataset,sequence,rlmode,skiphash,ck)
+ if ok then
+ done = true
+ end
+ end
+ if not notmatchreplace[backtrackdisc] then
+ local ok = false
+ new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck)
+ if ok then
+ done = true
+ end
+ end
+ if post then
+ setlink(posttail,cf)
+ else
+ post = cf
+ end
+ if replace then
+ setlink(replacetail,new)
+ else
+ replace = new
+ end
+ if hasglue then
+ setdiscchecked(backtrackdisc,pre,post,replace)
+ else
+ setdisc(backtrackdisc,pre,post,replace)
+ end
+ start = getprev(backtrackdisc)
+ sweephead[post] = getnext(clast) or false
+ sweephead[replace] = getnext(last) or false
+
+ else
+
+ local ok = false
+ head, start, ok = chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck)
+ if ok then
+ done = true
+ end
+
+ end
+
+ return head, start, done
+end
+
+local function chaintrac(head,start,dataset,sequence,rlmode,skiphash,ck,match,discseen,sweepnode)
+ local rule = ck[1]
+ local lookuptype = ck[8] or ck[2]
+ local nofseq = #ck[3]
+ local first = ck[4]
+ local last = ck[5]
+ local char = getchar(start)
+ logwarning("%s: rule %s %s at char %s for (%s,%s,%s) chars, lookuptype %a, %sdisc seen, %ssweeping",
+ cref(dataset,sequence),rule,match and "matches" or "nomatch",
+ gref(char),first-1,last-first+1,nofseq-last,lookuptype,
+ discseen and "" or "no ", sweepnode and "" or "not ")
+end
+
+-- The next one is quite optimized but still somewhat slow, fonts like ebgaramond
+-- are real torture tests because they have many steps with one context (having
+-- multiple contexts makes more sense) also because we (can) reduce them. Instead of
+-- a match boolean variable and check for that I decided to use a goto with labels
+-- instead. This is one of the cases where it makes the code more readable and we
+-- might even gain a bit performance.
+
+-- when we have less replacements (lookups) then current matches we can push too much into
+-- the previous disc .. such be it ( with only f done)
+
+local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash)
+ -- optimizing for rlmode gains nothing
+ local sweepnode = sweepnode
+ local sweeptype = sweeptype
+ local postreplace
+ local prereplace
+ local checkdisc
+ local discseen -- = false
+ if sweeptype then
+ if sweeptype == "replace" then
+ postreplace = true
+ prereplace = true
+ else
+ postreplace = sweeptype == "post"
+ prereplace = sweeptype == "pre"
+ end
+ checkdisc = getprev(head)
+ end
+ -- local currentfont = currentfont -- really ?
+ -- local currentscale = currentscale -- really ?
+ -- local currentxscale = currentxscale -- really ?
+ -- local currentyscale = currentyscale -- really ?
+
+ local skipped -- = false
+
+ local startprev,
+ startnext = getboth(start)
+ local done -- = false
+
+ -- we can have multiple hits and as we scan (currently) all we need to check
+ -- if we have a match ... contextchains have no real coverage table (with
+ -- unique entries)
+
+ -- fonts can have many steps (each doing one check) or many contexts
+
+ -- todo: make a per-char cache so that we have small contexts (when we have a context
+ -- n == 1 and otherwise it can be more so we can even distingish n == 1 or more)
+
+ local nofcontexts = contexts.n -- #contexts
+
+ local startchar = nofcontext == 1 or ischar(start,currentfont) -- already checked
+ for k=1,nofcontexts do -- does this disc mess work well with n > 1
+
+ local ck = contexts[k]
+ local seq = ck[3]
+ local f = ck[4] -- first current
+ if not startchar or not seq[f][startchar] then
+ -- report("no hit in %a at %i of %i contexts",sequence.type,k,nofcontexts)
+ goto next
+ end
+ local s = seq.n -- or #seq
+ local l = ck[5] -- last current
+ local current = start
+ local last = start
+
+ if s == 1 then
+ goto next
+ end
+
+ -- current match
+
+ if l > f then
+ -- before/current/after | before/current | current/after
+ local discfound -- = nil
+ local n = f + 1
+ last = startnext -- the second in current (first already matched)
+ while n <= l do
+ if postreplace and not last then
+ last = getnext(sweepnode)
+ sweeptype = nil
+ end
+ if last then
+ local nxt, char, id = isnextchar(last,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ if skiphash and skiphash[char] then
+ skipped = true
+ if trace_skips then
+ show_skip(dataset,sequence,char,ck,classes[char])
+ end
+ last = nxt
+ elseif seq[n][char] then
+ if n < l then
+ last = nxt
+ end
+ n = n + 1
+ elseif discfound then
+ notmatchreplace[discfound] = true
+ if notmatchpre[discfound] then
+ goto next
+ else
+ break
+ end
+ else
+ goto next
+ end
+ elseif char == false then
+ if discfound then
+ notmatchreplace[discfound] = true
+ if notmatchpre[discfound] then
+ goto next
+ else
+ break
+ end
+ else
+ goto next
+ end
+ elseif id == disc_code then
+ -- elseif id == disc_code and (not discs or discs[last]) then
+ discseen = true
+ discfound = last
+ notmatchpre[last] = nil
+ notmatchpost[last] = true
+ notmatchreplace[last] = nil
+ local pre, post, replace = getdisc(last)
+ if pre then
+ local n = n
+ while pre do
+ if seq[n][getchar(pre)] then
+ n = n + 1
+ if n > l then
+ break
+ end
+ pre = getnext(pre)
+ else
+ notmatchpre[last] = true
+ break
+ end
+ end
+ if n <= l then
+ notmatchpre[last] = true
+ end
+ else
+ notmatchpre[last] = true
+ end
+ if replace then
+ -- so far we never entered this branch
+ while replace do
+ if seq[n][getchar(replace)] then
+ n = n + 1
+ if n > l then
+ break
+ end
+ replace = getnext(replace)
+ else
+ notmatchreplace[last] = true
+ if notmatchpre[last] then
+ goto next
+ else
+ break
+ end
+ end
+ end
+ -- why here again
+ if notmatchpre[last] then
+ goto next
+ end
+ end
+ -- maybe only if match
+ last = nxt
+ else
+ goto next
+ end
+ else
+ goto next
+ end
+ end
+ end
+
+ -- before
+
+ if f > 1 then
+ if startprev then
+ local prev = startprev
+ if prereplace and prev == checkdisc then
+ prev = getprev(sweepnode)
+ end
+ if prev then
+ local discfound -- = nil
+ local n = f - 1
+ while n >= 1 do
+ if prev then
+ local prv, char, id = isprevchar(prev,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ if skiphash and skiphash[char] then
+ skipped = true
+ if trace_skips then
+ show_skip(dataset,sequence,char,ck,classes[char])
+ end
+ prev = prv
+ elseif seq[n][char] then
+ if n > 1 then
+ prev = prv
+ end
+ n = n - 1
+ elseif discfound then
+ notmatchreplace[discfound] = true
+ if notmatchpost[discfound] then
+ goto next
+ else
+ break
+ end
+ else
+ goto next
+ end
+ elseif char == false then
+ if discfound then
+ notmatchreplace[discfound] = true
+ if notmatchpost[discfound] then
+ goto next
+ end
+ else
+ goto next
+ end
+ break
+ elseif id == disc_code then
+ -- elseif id == disc_code and (not discs or discs[prev]) then
+ -- the special case: f i where i becomes dottless i ..
+ discseen = true
+ discfound = prev
+ notmatchpre[prev] = true
+ notmatchpost[prev] = nil
+ notmatchreplace[prev] = nil
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(prev,true)
+ -- weird test: needs checking
+ if pre ~= start and post ~= start and replace ~= start then
+ if post then
+ local n = n
+ while posttail do
+ if seq[n][getchar(posttail)] then
+ n = n - 1
+ if posttail == post or n < 1 then
+ break
+ else
+ posttail = getprev(posttail)
+ end
+ else
+ notmatchpost[prev] = true
+ break
+ end
+ end
+ if n >= 1 then
+ notmatchpost[prev] = true
+ end
+ else
+ notmatchpost[prev] = true
+ end
+ if replace then
+ -- we seldom enter this branch (e.g. on brill efficient)
+ while replacetail do
+ if seq[n][getchar(replacetail)] then
+ n = n - 1
+ if replacetail == replace or n < 1 then
+ break
+ else
+ replacetail = getprev(replacetail)
+ end
+ else
+ notmatchreplace[prev] = true
+ if notmatchpost[prev] then
+ goto next
+ else
+ break
+ end
+ end
+ end
+ else
+ -- notmatchreplace[prev] = true -- not according to Kai
+ end
+ end
+ -- prev = getprev(prev)
+ prev = prv
+ -- elseif id == glue_code and seq[n][32] and isspace(prev,threshold,id) then
+ -- elseif seq[n][32] and spaces[prev] then
+ -- n = n - 1
+ -- prev = prv
+ elseif id == glue_code then
+ local sn = seq[n]
+ if (sn[32] and spaces[prev]) or sn[0xFFFC] then
+ n = n - 1
+ prev = prv
+ else
+ goto next
+ end
+ elseif seq[n][0xFFFC] then
+ n = n - 1
+ prev = prv
+ else
+ goto next
+ end
+ else
+ goto next
+ end
+ end
+ else
+ goto next
+ end
+ else
+ goto next
+ end
+ end
+
+ -- after
+
+ if s > l then
+ local current = last and getnext(last)
+ if not current and postreplace then
+ current = getnext(sweepnode)
+ end
+ if current then
+ local discfound -- = nil
+ local n = l + 1
+ while n <= s do
+ if current then
+ local nxt, char, id = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ if skiphash and skiphash[char] then
+ skipped = true
+ if trace_skips then
+ show_skip(dataset,sequence,char,ck,classes[char])
+ end
+ current = nxt -- was absent
+ elseif seq[n][char] then
+ if n < s then -- new test
+ current = nxt -- was absent
+ end
+ n = n + 1
+ elseif discfound then
+ notmatchreplace[discfound] = true
+ if notmatchpre[discfound] then
+ goto next
+ else
+ break
+ end
+ else
+ goto next
+ end
+ elseif char == false then
+ if discfound then
+ notmatchreplace[discfound] = true
+ if notmatchpre[discfound] then
+ goto next
+ else
+ break
+ end
+ else
+ goto next
+ end
+ elseif id == disc_code then
+ -- elseif id == disc_code and (not discs or discs[current]) then
+ discseen = true
+ discfound = current
+ notmatchpre[current] = nil
+ notmatchpost[current] = true
+ notmatchreplace[current] = nil
+ local pre, post, replace = getdisc(current)
+ -- no detailed checking here, todo ?
+ if pre then
+ local n = n
+ while pre do
+ if seq[n][getchar(pre)] then
+ n = n + 1
+ if n > s then
+ break
+ else
+ pre = getnext(pre)
+ end
+ else
+ notmatchpre[current] = true
+ break
+ end
+ end
+ if n <= s then
+ notmatchpre[current] = true
+ end
+ else
+ notmatchpre[current] = true
+ end
+ if replace then
+ -- so far we never entered this branch
+ while replace do
+ if seq[n][getchar(replace)] then
+ n = n + 1
+ if n > s then
+ break
+ else
+ replace = getnext(replace)
+ end
+ else
+ notmatchreplace[current] = true
+ if notmatchpre[current] then
+ goto next
+ else
+ break
+ end
+ end
+ end
+ else
+ -- notmatchreplace[current] = true -- not according to Kai
+ end
+ current = getnext(current)
+ elseif id == glue_code then
+ local sn = seq[n]
+ if (sn[32] and spaces[current]) or sn[0xFFFC] then
+ n = n + 1
+ current = nxt
+ else
+ goto next
+ end
+ elseif seq[n][0xFFFC] then
+ n = n + 1
+ current = nxt
+ else
+ goto next
+ end
+ else
+ goto next
+ end
+ end
+ else
+ goto next
+ end
+ end
+
+ if trace_contexts then
+ chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true,discseen,sweepnode)
+ end
+ if discseen or sweepnode then
+ head, start, done = chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck)
+ else
+ head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck)
+ end
+ if done then
+ break
+ -- else
+ -- next context
+ end
+ ::next::
+ -- if trace_chains then
+ -- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,false,discseen,sweepnode)
+ -- end
+ end
+ if discseen then
+ notmatchpre = { }
+ notmatchpost = { }
+ notmatchreplace = { }
+ -- notmatchpre = { a = 1, b = 1 } notmatchpre .a = nil notmatchpre .b = nil
+ -- notmatchpost = { a = 1, b = 1 } notmatchpost .a = nil notmatchpost .b = nil
+ -- notmatchreplace = { a = 1, b = 1 } notmatchreplace.a = nil notmatchreplace.b = nil
+ end
+ return head, start, done
+end
+
+handlers.gsub_context = handle_contextchain
+handlers.gsub_contextchain = handle_contextchain
+handlers.gsub_reversecontextchain = handle_contextchain
+handlers.gpos_contextchain = handle_contextchain
+handlers.gpos_context = handle_contextchain
+
+-- this needs testing
+
+local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
+ local steps = currentlookup.steps
+ local nofsteps = currentlookup.nofsteps
+ if nofsteps > 1 then
+ reportmoresteps(dataset,sequence)
+ end
+ -- probably wrong
+ local l = steps[1].coverage[getchar(start)]
+ if l then
+ return handle_contextchain(head,start,dataset,sequence,l,rlmode,skiphash)
+ else
+ return head, start, false
+ end
+end
+
+chainprocs.gsub_context = chained_contextchain
+chainprocs.gsub_contextchain = chained_contextchain
+chainprocs.gsub_reversecontextchain = chained_contextchain
+chainprocs.gpos_contextchain = chained_contextchain
+chainprocs.gpos_context = chained_contextchain
+
+------------------------------
+
+-- experiment (needs no handler in font-otc so not now):
+--
+-- function otf.registerchainproc(name,f)
+-- -- chainprocs[name] = f
+-- chainprocs[name] = function(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
+-- local done = currentlookup.nofsteps > 0
+-- if not done then
+-- reportzerosteps(dataset,sequence)
+-- else
+-- head, start, done = f(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
+-- if not head or not start then
+-- reportbadsteps(dataset,sequence)
+-- end
+-- end
+-- return head, start, done
+-- end
+-- end
+
+local missing = setmetatableindex("table")
+local logwarning = report_process
+local resolved = { } -- we only resolve a font,script,language pair once
+
+local function logprocess(...)
+ if trace_steps then
+ registermessage(...)
+ if trace_steps == "silent" then
+ return
+ end
+ end
+ report_process(...)
+end
+
+-- todo: pass all these 'locals' in a table
+
+local sequencelists = setmetatableindex(function(t,font)
+ local sequences = fontdata[font].resources.sequences
+ if not sequences or not next(sequences) then
+ sequences = false
+ end
+ t[font] = sequences
+ return sequences
+end)
+
+-- fonts.hashes.sequences = sequencelists
+
+do -- overcome local limit
+
+ local autofeatures = fonts.analyzers.features
+ local featuretypes = otf.tables.featuretypes
+ local defaultscript = otf.features.checkeddefaultscript
+ local defaultlanguage = otf.features.checkeddefaultlanguage
+
+ local wildcard = "*"
+ local default = "dflt"
+
+ local function initialize(sequence,script,language,enabled,autoscript,autolanguage)
+ local features = sequence.features
+ if features then
+ local order = sequence.order
+ if order then
+ local featuretype = featuretypes[sequence.type or "unknown"]
+ for i=1,#order do
+ local kind = order[i]
+ local valid = enabled[kind]
+ if valid then
+ local scripts = features[kind]
+ local languages = scripts and (
+ scripts[script] or
+ scripts[wildcard] or
+ (autoscript and defaultscript(featuretype,autoscript,scripts))
+ )
+ local enabled = languages and (
+ languages[language] or
+ languages[wildcard] or
+ (autolanguage and defaultlanguage(featuretype,autolanguage,languages))
+ )
+ if enabled then
+ return { valid, autofeatures[kind] or false, sequence, kind }
+ end
+ end
+ end
+ else
+ -- can't happen
+ end
+ end
+ return false
+ end
+
+ function otf.dataset(tfmdata,font) -- generic variant, overloaded in context
+ local shared = tfmdata.shared
+ local properties = tfmdata.properties
+ local language = properties.language or "dflt"
+ local script = properties.script or "dflt"
+ local enabled = shared.features
+ local autoscript = enabled and enabled.autoscript
+ local autolanguage = enabled and enabled.autolanguage
+ local res = resolved[font]
+ if not res then
+ res = { }
+ resolved[font] = res
+ end
+ local rs = res[script]
+ if not rs then
+ rs = { }
+ res[script] = rs
+ end
+ local rl = rs[language]
+ if not rl then
+ rl = {
+ -- indexed but we can also add specific data by key
+ }
+ rs[language] = rl
+ local sequences = tfmdata.resources.sequences
+ if sequences then
+ for s=1,#sequences do
+ local v = enabled and initialize(sequences[s],script,language,enabled,autoscript,autolanguage)
+ if v then
+ rl[#rl+1] = v
+ end
+ end
+ end
+ end
+ return rl
+ end
+
+end
+
+-- Functions like kernrun, comprun etc evolved over time and in the end look rather
+-- complex. It's a bit of a compromis between extensive copying and creating subruns.
+-- The logic has been improved a lot by Kai and Ivo who use complex fonts which
+-- really helped to identify border cases on the one hand and get insight in the diverse
+-- ways fonts implement features (not always that consistent and efficient). At the same
+-- time I tried to keep the code relatively efficient so that the overhead in runtime
+-- stays acceptable.
+
+local function report_disc(what,n)
+ report_run("%s: %s > %s",what,n,languages.serializediscretionary(n))
+end
+
+local function kernrun(disc,k_run,...)
+ --
+ -- we catch
+ --
+ if trace_kernruns then
+ report_disc("kern",disc)
+ end
+ --
+ local prev, next = getboth(disc)
+ --
+ local nextstart = next
+ local done = false
+ --
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true)
+ --
+ local prevmarks = prev
+ --
+ -- can be optional, because why on earth do we get a disc after a mark (okay, maybe when a ccmp
+ -- has happened but then it should be in the disc so basically this test indicates an error)
+ --
+ while prevmarks do
+ local prv, char = isprevchar(prevmarks,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char and marks[char] then
+ prevmarks = prv
+ else
+ break
+ end
+ end
+ --
+ if prev and not ischar(prev,currentfont) then -- and (pre or replace) -- weak test
+ prev = false
+ end
+ if next and not ischar(next,currentfont) then -- and (post or replace) -- weak test
+ next = false
+ end
+ --
+ -- we need to get rid of this nest mess some day .. has to be done otherwise
+ --
+ if pre then
+ if k_run(pre,"injections",nil,...) then
+ done = true
+ end
+ if prev then
+ setlink(prev,pre)
+ if k_run(prevmarks,"preinjections",pre,...) then -- or prev?
+ done = true
+ end
+ setprev(pre)
+ setlink(prev,disc)
+ end
+ end
+ --
+ if post then
+ if k_run(post,"injections",nil,...) then
+ done = true
+ end
+ if next then
+ setlink(posttail,next)
+ if k_run(posttail,"postinjections",next,...) then
+ done = true
+ end
+ setnext(posttail)
+ setlink(disc,next)
+ end
+ end
+ --
+ if replace then
+ if k_run(replace,"injections",nil,...) then
+ done = true
+ end
+ if prev then
+ setlink(prev,replace)
+ if k_run(prevmarks,"replaceinjections",replace,...) then -- getnext(replace))
+ done = true
+ end
+ setprev(replace)
+ setlink(prev,disc)
+ end
+ if next then
+ setlink(replacetail,next)
+ if k_run(replacetail,"replaceinjections",next,...) then
+ done = true
+ end
+ setnext(replacetail)
+ setlink(disc,next)
+ end
+ elseif prev and next then
+ setlink(prev,next)
+ if k_run(prevmarks,"emptyinjections",next,...) then
+ done = true
+ end
+ setlink(prev,disc,next)
+ end
+ if done and trace_testruns then
+ report_disc("done",disc)
+ end
+ return nextstart, done
+end
+
+-- fonts like ebgaramond do ligatures this way (less efficient than e.g. dejavu which
+-- will do the testrun variant)
+
+local function comprun(disc,c_run,...) -- vararg faster than the whole list
+ if trace_compruns then
+ report_disc("comp",disc)
+ end
+ --
+ local pre, post, replace = getdisc(disc)
+ local renewed = false
+ --
+ if pre then
+ sweepnode = disc
+ sweeptype = "pre" -- in alternative code preinjections is used (also used then for properties, saves a variable)
+ local new, done = c_run(pre,...)
+ if done then
+ pre = new
+ renewed = true
+ end
+ end
+ --
+ if post then
+ sweepnode = disc
+ sweeptype = "post"
+ local new, done = c_run(post,...)
+ if done then
+ post = new
+ renewed = true
+ end
+ end
+ --
+ if replace then
+ sweepnode = disc
+ sweeptype = "replace"
+ local new, done = c_run(replace,...)
+ if done then
+ replace = new
+ renewed = true
+ end
+ end
+ --
+ sweepnode = nil
+ sweeptype = nil
+ if renewed then
+ if trace_testruns then
+ report_disc("done",disc)
+ end
+ setdisc(disc,pre,post,replace)
+ end
+ --
+ return getnext(disc), renewed
+end
+
+-- if we can hyphenate in a lig then unlikely a lig so we
+-- could have a option here to ignore lig
+
+local test_flatten_start = 2 -- must start at 2 according to Kai
+
+directives.register("otf.testrun.forceflatten", function(v)
+ test_flatten_start = v and 1 or 2
+end)
+
+local function testrun(disc,t_run,c_run,...)
+ if trace_testruns then
+ report_disc("test",disc)
+ end
+ local prev, next = getboth(disc)
+ if not next then
+ -- weird discretionary
+ return
+ end
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true)
+ local renewed = false
+ if post or replace then -- and prev then -- hm, we can start with a disc
+ if post then
+ setlink(posttail,next)
+ else
+ post = next
+ end
+ if replace then
+ setlink(replacetail,next)
+ else
+ replace = next
+ end
+ local d_post = t_run(post,next,...)
+ local d_replace = t_run(replace,next,...)
+ if d_post > 0 or d_replace > 0 then
+ local d = d_replace > d_post and d_replace or d_post
+ local head = getnext(disc) -- is: next
+ local tail = head
+ for i=test_flatten_start,d do
+ local nx = getnext(tail)
+ local id = getid(nx)
+ if id == disc_code then
+ head, tail = flattendisk(head,nx)
+ elseif id == glyph_code then
+ tail = nx
+ else
+ -- we can have overrun into a glue
+ break
+ end
+ end
+ next = getnext(tail)
+ setnext(tail)
+ setprev(head)
+ local new = copy_node_list(head)
+ if posttail then
+ setlink(posttail,head)
+ else
+ post = head
+ end
+ if replacetail then
+ setlink(replacetail,new)
+ else
+ replace = new
+ end
+ else
+ -- we stay inside the disc
+ if posttail then
+ setnext(posttail)
+ else
+ post = nil
+ end
+ if replacetail then
+ setnext(replacetail)
+ else
+ replace = nil
+ end
+ end
+ setlink(disc,next)
+ -- pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true)
+ end
+ --
+ -- like comprun
+ --
+ if trace_testruns then
+ report_disc("more",disc)
+ end
+ --
+ if pre then
+ sweepnode = disc
+ sweeptype = "pre"
+ local new, ok = c_run(pre,...)
+ if ok then
+ pre = new
+ renewed = true
+ end
+ end
+ --
+ if post then
+ sweepnode = disc
+ sweeptype = "post"
+ local new, ok = c_run(post,...)
+ if ok then
+ post = new
+ renewed = true
+ end
+ end
+ --
+ if replace then
+ sweepnode = disc
+ sweeptype = "replace"
+ local new, ok = c_run(replace,...)
+ if ok then
+ replace = new
+ renewed = true
+ end
+ end
+ --
+ sweepnode = nil
+ sweeptype = nil
+ if renewed then
+ setdisc(disc,pre,post,replace)
+ if trace_testruns then
+ report_disc("done",disc)
+ end
+ end
+ -- next can have changed (copied list)
+ return getnext(disc), renewed
+end
+
+-- 1{2{\oldstyle\discretionary{3}{4}{5}}6}7\par
+-- 1{2\discretionary{3{\oldstyle3}}{{\oldstyle4}4}{5{\oldstyle5}5}6}7\par
+
+local nesting = 0
+
+local function c_run_single(head,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
+ local done = false
+ local sweep = sweephead[head]
+ local start
+ if sweep then
+ start = sweep
+ -- sweephead[head] = nil
+ sweephead[head] = false
+ else
+ start = head
+ end
+ while start do
+ local nxt, char, id = isnextchar(start,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ local ok
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+ if ok then
+ done = true
+ end
+ if start then
+ start = getnext(start)
+ end
+ else
+ start = nxt
+ end
+ elseif char == false then
+ return head, done
+ elseif sweep then
+ -- else we loose the rest
+ return head, done
+ else
+ -- in disc component ... really?
+ start = nxt
+ end
+ end
+ return head, done
+end
+
+local function t_run_single(start,stop,lookupcache)
+ local lastd = nil
+ while start ~= stop do
+ local nxt, char = isnextchar(start,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then -- hm, hyphens can match (tlig) so we need to really check
+ -- if we need more than ligatures we can outline the code and use functions
+ local s = nxt
+ local ss = nil
+ local sstop = s == stop
+ if not s then
+ s = ss
+ ss = nil
+ end
+ -- a bit weird: why multiple ... anyway we can't have a disc in a disc
+ -- how about post ... we can probably merge this into the while
+ while getid(s) == disc_code do
+ ss = getnext(s)
+ s = getreplace(s)
+ if not s then
+ s = ss
+ ss = nil
+ end
+ end
+ local l = nil
+ local d = 0
+ while s do
+ local nxt, char = isnextchar(s,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ local lg = lookupmatch[char]
+ if lg then
+ if sstop then
+ d = 1
+ elseif d > 0 then
+ d = d + 1
+ end
+ l = lg
+ s = nxt
+ sstop = s == stop
+ if not s then
+ s = ss
+ ss = nil
+ end
+ while getid(s) == disc_code do
+ ss = getnext(s)
+ s = getreplace(s)
+ if not s then
+ s = ss
+ ss = nil
+ end
+ end
+ lookupmatch = lg
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ if l and l.ligature then -- so we test for ligature
+ lastd = d
+ end
+ end
+ if lastd then
+ return lastd
+ else
+ start = nxt
+ end
+ else
+ break
+ end
+ end
+ return 0
+end
+
+local function k_run_single(sub,injection,last,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
+ for n in nextnode, sub do -- only gpos
+ if n == last then
+ break
+ else
+ local nxt, char = isnextchar(n,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection)
+ if ok then
+ return true
+ end
+ end
+ end
+ end
+ end
+end
+
+local function c_run_multiple(head,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
+ local done = false
+ local sweep = sweephead[head]
+ local start
+ if sweep then
+ start = sweep
+ -- sweephead[head] = nil
+ sweephead[head] = false
+ else
+ start = head
+ end
+ while start do
+ local nxt, char = isnextchar(start,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ for i=1,nofsteps do
+ local step = steps[i]
+ local lookupcache = step.coverage
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ -- we could move all code inline but that makes things even more unreadable
+ local ok
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+ if ok then
+ done = true
+ break
+ elseif not start then
+ -- don't ask why ... shouldn't happen
+ break
+ end
+ end
+ end
+ if start then
+ start = getnext(start)
+ end
+ elseif char == false then
+ -- whatever glyph
+ return head, done
+ elseif sweep then
+ -- else we loose the rest
+ return head, done
+ else
+ -- in disc component
+ start = nxt
+ end
+ end
+ return head, done
+end
+
+local function t_run_multiple(start,stop,steps,nofsteps)
+ local lastd = nil
+ while start ~= stop do
+ local startnext, char = isnextchar(start,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ for i=1,nofsteps do
+ local step = steps[i]
+ local lookupcache = step.coverage
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ -- if we need more than ligatures we can outline the code and use functions
+ local s = startnext
+ local ss = nil
+ local sstop = s == stop
+ if not s then
+ s = ss
+ ss = nil
+ end
+ while getid(s) == disc_code do
+ ss = getnext(s)
+ s = getreplace(s)
+ if not s then
+ s = ss
+ ss = nil
+ end
+ end
+ local l = nil
+ local d = 0
+ while s do
+ local nxt, char = isnextchar(s,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ local lg = lookupmatch[char]
+ if lg then
+ if sstop then
+ d = 1
+ elseif d > 0 then
+ d = d + 1
+ end
+ l = lg
+ s = nxt
+ sstop = s == stop
+ if not s then
+ s = ss
+ ss = nil
+ end
+ while getid(s) == disc_code do
+ ss = getnext(s)
+ s = getreplace(s)
+ if not s then
+ s = ss
+ ss = nil
+ end
+ end
+ lookupmatch = lg
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ if l and l.ligature then
+ lastd = d
+ end
+ end
+ end
+ if lastd then
+ return lastd
+ else
+ start = startnext
+ end
+ else
+ break
+ end
+ end
+ return 0
+end
+
+local function k_run_multiple(sub,injection,last,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
+ for n in nextnode, sub do -- only gpos
+ if n == last then
+ break
+ else
+ local nxt, char = isnextchar(n,currentfont,currentdynamic,currentscale,currentxscale,currentyscale)
+ if char then
+ for i=1,nofsteps do
+ local step = steps[i]
+ local lookupcache = step.coverage
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) -- sub was head
+ if ok then
+ return true
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local txtdirstate, pardirstate do -- this might change (no need for nxt in pardirstate)
+
+ local getdirection = nuts.getdirection
+
+ txtdirstate = function(start,stack,top,rlparmode)
+ local dir, pop = getdirection(start)
+ if pop then
+ if top == 1 then
+ return 0, rlparmode
+ else
+ top = top - 1
+ if stack[top] == righttoleft_code then
+ return top, -1
+ else
+ return top, 1
+ end
+ end
+ elseif dir == lefttoright_code then
+ top = top + 1
+ stack[top] = lefttoright_code
+ return top, 1
+ elseif dir == righttoleft_code then
+ top = top + 1
+ stack[top] = righttoleft_code
+ return top, -1
+ else
+ return top, rlparmode
+ end
+ end
+
+ pardirstate = function(start)
+ local dir = getdirection(start)
+ if dir == lefttoright_code then
+ return 1, 1
+ elseif dir == righttoleft_code then
+ return -1, -1
+ else
+ return 0, 0
+ end
+ end
+
+end
+
+-- These are non public helpers that can change without notice!
+
+otf.helpers = otf.helpers or { }
+otf.helpers.txtdirstate = txtdirstate
+otf.helpers.pardirstate = pardirstate
+
+-- This is the main loop. We run over the node list dealing with a specific font. The
+-- dynamic is a context specific thing. We could work on sub start-stop ranges instead
+-- but I wonder if there is that much speed gain (experiments showed that it made not
+-- much sense) and we need to keep track of directions anyway. Also at some point I
+-- want to play with font interactions and then we do need the full sweeps. Apart from
+-- optimizations the principles of processing the features hasn't changed much since
+-- the beginning.
+
+do
+
+ -- This is a measurable experimental speedup (only with hyphenated text and multiple
+ -- fonts per processor call), especially for fonts with lots of contextual lookups.
+
+ local fastdisc = true
+ local testdics = false
+
+ directives.register("otf.fastdisc",function(v) fastdisc = v end) -- normally enabled
+
+ -- using a merged combined hash as first test saves some 30% on ebgaramond and
+ -- about 15% on arabtype .. then moving the a test also saves a bit (even when
+ -- often a is not set at all so that one is a bit debatable
+
+ local otfdataset = nil -- todo: make an installer
+
+ local getfastdisc = { __index = function(t,k)
+ local v = usesfont(k,currentfont)
+ t[k] = v
+ return v
+ end }
+
+ local getfastspace = { __index = function(t,k)
+ -- we don't pass the id so that one can overload isspace
+ local v = isspace(k,threshold) or false
+ t[k] = v
+ return v
+ end }
+
+ function otf.featuresprocessor(head,font,dynamic,direction,n)
+
+ local sequences = sequencelists[font] -- temp hack
+
+ nesting = nesting + 1
+
+ if nesting == 1 then
+ currentfont = font
+ currentdynamic = dynamic
+ currentscale = false
+ currentxscale = false
+ currentyscale = false
+ tfmdata = fontdata[font]
+ descriptions = tfmdata.descriptions -- only needed in gref so we could pass node there instead
+ characters = tfmdata.characters -- but this branch is not entered that often anyway
+ local resources = tfmdata.resources
+ marks = resources.marks
+ classes = resources.classes
+ threshold,
+ factor = getthreshold(font)
+ checkmarks = tfmdata.properties.checkmarks
+
+ if not otfdataset then
+ otfdataset = otf.dataset
+ end
+
+ discs = fastdisc and n and n > 1 and setmetatable({},getfastdisc) -- maybe inline
+ spaces = setmetatable({},getfastspace)
+
+ elseif currentfont ~= font then
+
+ report_warning("nested call with a different font, level %s, quitting",nesting)
+ nesting = nesting - 1
+ return head, false
+
+ end
+
+ if trace_steps then
+ checkstep(head)
+ end
+
+ local initialrl = 0
+
+ if getid(head) == par_code and start_of_par(head) then
+ initialrl = pardirstate(head)
+ elseif direction == righttoleft_code then
+ initialrl = -1
+ end
+
+ local datasets = otfdataset(tfmdata,font,dynamic)
+ local dirstack = { nil } -- could move outside function but we can have local runs
+ sweephead = { }
+ -- sweephead = { a = 1, b = 1 } sweephead.a = nil sweephead.b = nil
+
+ -- Keeping track of the headnode is needed for devanagari. (I generalized it a bit
+ -- so that multiple cases are also covered.) We could prepend a temp node.
+
+ -- We don't goto the next node when a disc node is created so that we can then treat
+ -- the pre, post and replace. It's a bit of a hack but works out ok for most cases.
+
+ for s=1,#datasets do
+ local dataset = datasets[s]
+ local state = dataset[2]
+ local sequence = dataset[3] -- sequences[s] -- also dataset[5]
+ local rlparmode = initialrl
+ local topstack = 0
+ local typ = sequence.type
+ local gpossing = typ == "gpos_single" or typ == "gpos_pair" -- store in dataset
+ local forcetestrun = typ == "gsub_ligature" -- testrun is only for ligatures
+ local handler = handlers[typ] -- store in dataset
+ local steps = sequence.steps
+ local nofsteps = sequence.nofsteps
+ local skiphash = sequence.skiphash
+
+ if not steps then
+ -- This permits injection, watch the different arguments. Watch out, the arguments passed
+ -- are not frozen as we might extend or change this. Is this used at all apart from some
+ -- experiments?
+ local h, ok = handler(head,dataset,sequence,initialrl,font,dynamic) -- less arguments now
+ if h and h ~= head then
+ head = h
+ end
+ elseif typ == "gsub_reversecontextchain" then
+ --
+ -- This might need a check: if we have #before or #after > 0 then we might need to reverse
+ -- the before and after lists in the loader. But first I need to see a font that uses multiple
+ -- matches.
+ --
+ local start = find_node_tail(head)
+ local rlmode = 0 -- how important is this .. do we need to check for dir?
+ local merged = steps.merged
+ while start do
+ local prv, char, id = isprevchar(start,font,dynamic,state)
+ if char then
+ local m = merged[char]
+ if m then
+ currentscale, currentxscale, currentyscale = getscales(start)
+ for i=m[1],m[2] do
+ local step = steps[i]
+ local lookupcache = step.coverage
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ local ok
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+ if ok then
+ -- done = true
+ break
+ end
+ end
+ end
+ if start then
+ start = getprev(start)
+ end
+ else
+ start = prv
+ end
+ else
+ start = prv
+ end
+ end
+ else
+ local start = head
+ local rlmode = initialrl
+ if nofsteps == 1 then -- happens often
+ local step = steps[1]
+ local lookupcache = step.coverage
+ while start do
+ local nxt, char, id = isnextchar(start,font,dynamic,state) -- we can move the data/state checks here
+ if char then
+ if skiphash and skiphash[char] then -- we never needed it here but let's try
+ start = nxt
+ else
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ currentscale, currentxscale, currentyscale = getscales(start)
+ local ok, df
+ head, start, ok, df = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+ if df then
+ -- print("restart 1",typ)
+ elseif start then
+ start = getnext(start) -- can be a new start
+ end
+ else
+ start = nxt
+ end
+ end
+ elseif char == false or id == glue_code then
+ -- a different font|state or glue (happens often)
+ start = nxt
+ elseif id == disc_code then
+ if not discs or discs[start] == true then
+ local ok
+ if gpossing then
+ start, ok = kernrun(start,k_run_single, lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
+ elseif forcetestrun then
+ start, ok = testrun(start,t_run_single,c_run_single,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
+ else
+ start, ok = comprun(start,c_run_single, lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
+ end
+ -- if ok then
+ -- done = true
+ -- end
+ else
+ start = nxt
+ end
+ elseif id == math_code then
+ start = getnext(end_of_math(start))
+ elseif id == dir_code then
+ topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode)
+ start = nxt
+ -- elseif id == par_code and start_of_par(start) then
+ -- rlparmode, rlmode = pardirstate(start)
+ -- start = nxt
+ else
+ start = nxt
+ end
+ end
+ else
+ local merged = steps.merged
+ while start do
+ local nxt, char, id = isnextchar(start,font,dynamic,state)
+ if char then
+ if skiphash and skiphash[char] then -- we never needed it here but let's try
+ start = nxt
+ else
+ local m = merged[char]
+ if m then
+ currentscale, currentxscale, currentyscale = getscales(start)
+ local ok, df
+ for i=m[1],m[2] do
+ local step = steps[i]
+ local lookupcache = step.coverage
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ -- we could move all code inline but that makes things even more unreadable
+-- local ok, df
+ head, start, ok, df = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+ if df then
+ break
+ elseif ok then
+ break
+ elseif not start then
+ -- don't ask why ... shouldn't happen
+ break
+ end
+ end
+ end
+ if df then
+ -- print("restart 2",typ)
+ elseif start then
+ start = getnext(start) -- can be a new next
+ end
+ else
+ start = nxt
+ end
+ end
+ elseif char == false or id == glue_code then
+ -- a different font|state or glue (happens often)
+ start = nxt
+ elseif id == disc_code then
+ if not discs or discs[start] == true then
+ local ok
+ if gpossing then
+ start, ok = kernrun(start,k_run_multiple, steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
+ elseif forcetestrun then
+ start, ok = testrun(start,t_run_multiple,c_run_multiple,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
+ else
+ start, ok = comprun(start,c_run_multiple, steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
+ end
+ else
+ start = nxt
+ end
+ elseif id == math_code then
+ start = getnext(end_of_math(start))
+ elseif id == dir_code then
+ topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode)
+ start = nxt
+ -- elseif id == par_code and start_of_par(start) then
+ -- rlparmode, rlmode = pardirstate(start)
+ -- start = nxt
+ else
+ start = nxt
+ end
+ end
+ end
+ end
+
+ if trace_steps then -- ?
+ registerstep(head)
+ end
+
+ end
+
+ nesting = nesting - 1
+
+ return head
+ end
+
+ -- This is not an official helper and used for tracing experiments. It can be changed as I like
+ -- at any moment. At some point it might be used in a module that can help font development.
+
+ function otf.datasetpositionprocessor(head,font,direction,dataset)
+
+ currentfont = font
+ currentdynamic = false
+ currentscale = false
+ currentxscale = false
+ currentyscale = false
+ tfmdata = fontdata[font]
+ descriptions = tfmdata.descriptions -- only needed in gref so we could pass node there instead
+ characters = tfmdata.characters -- but this branch is not entered that often anyway
+ local resources = tfmdata.resources
+ marks = resources.marks
+ classes = resources.classes
+ threshold,
+ factor = getthreshold(font)
+ checkmarks = tfmdata.properties.checkmarks
+
+ if type(dataset) == "number" then
+ dataset = otfdataset(tfmdata,font,0)[dataset]
+ end
+
+ local sequence = dataset[3] -- sequences[s] -- also dataset[5]
+ local typ = sequence.type
+ -- local gpossing = typ == "gpos_single" or typ == "gpos_pair" -- store in dataset
+
+ -- gpos_contextchain gpos_context
+
+ -- if not gpossing then
+ -- return head, false
+ -- end
+
+ local handler = handlers[typ] -- store in dataset
+ local steps = sequence.steps
+ local nofsteps = sequence.nofsteps
+
+ local done = false
+ local dirstack = { nil } -- could move outside function but we can have local runs (maybe a few more nils)
+ local start = head
+ local initialrl = (direction == righttoleft_code) and -1 or 0
+ local rlmode = initialrl
+ local rlparmode = initialrl
+ local topstack = 0
+ local merged = steps.merged
+
+ -- local matches = false
+ local position = 0
+
+ while start do
+ local nxt, char, id = isnextchar(start,currentfont,currentdynamic)
+ if char then
+ position = position + 1
+ local m = merged[char]
+ if m then
+ if skiphash and skiphash[char] then -- we never needed it here but let's try
+ start = nxt
+ else
+ for i=m[1],m[2] do
+ local step = steps[i]
+ local lookupcache = step.coverage
+ local lookupmatch = lookupcache[char]
+ if lookupmatch then
+ currentscale, currentxscale, currentyscale = getscales(start)
+ local ok
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+ if ok then
+ -- if matches then
+ -- matches[position] = i
+ -- else
+ -- matches = { [position] = i }
+ -- end
+ break
+ elseif not start then
+ break
+ end
+ end
+ end
+ if start then
+ start = getnext(start) -- start can be new
+ end
+ end
+ else
+ -- start = getnext(start)
+ start = nxt
+ end
+ elseif char == false or id == glue_code then
+ -- a different font|state or glue (happens often)
+ start = nxt
+ elseif id == math_code then
+ start = getnext(end_of_math(start))
+ elseif id == dir_code then
+ topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode)
+ start = nxt
+ -- elseif id == par_code and start_of_par(start) then
+ -- rlparmode, rlmode = pardirstate(start)
+ -- start = nxt
+ else
+ start = nxt
+ end
+ end
+
+ return head
+ end
+
+ -- end of experiment
+
+end
+
+-- so far
+
+local plugins = { }
+otf.plugins = plugins
+
+local report = logs.reporter("fonts")
+
+function otf.registerplugin(name,f)
+ if type(name) == "string" and type(f) == "function" then
+ plugins[name] = { name, f }
+ report()
+ report("plugin %a has been loaded, please be aware of possible side effects",name)
+ report()
+ if logs.pushtarget then
+ logs.pushtarget("log")
+ end
+ report("Plugins are not officially supported unless stated otherwise. This is because")
+ report("they bypass the regular font handling and therefore some features in ConTeXt")
+ report("(especially those related to fonts) might not work as expected or might not work")
+ report("at all. Some plugins are for testing and development only and might change")
+ report("whenever we feel the need for it.")
+ report()
+ if logs.poptarget then
+ logs.poptarget()
+ end
+ end
+end
+
+function otf.plugininitializer(tfmdata,value)
+ if type(value) == "string" then
+ tfmdata.shared.plugin = plugins[value]
+ end
+end
+
+function otf.pluginprocessor(head,font,dynamic,direction) -- n
+ local s = fontdata[font].shared
+ local p = s and s.plugin
+ if p then
+ if trace_plugins then
+ report_process("applying plugin %a",p[1])
+ end
+ return p[2](head,font,dynamic,direction)
+ else
+ return head, false
+ end
+end
+
+function otf.featuresinitializer(tfmdata,value)
+ -- nothing done here any more
+end
+
+registerotffeature {
+ name = "features",
+ description = "features",
+ default = true,
+ initializers = {
+ position = 1,
+ node = otf.featuresinitializer,
+ plug = otf.plugininitializer,
+ },
+ processors = {
+ node = otf.featuresprocessor,
+ plug = otf.pluginprocessor,
+ }
+}
+
+-- Moved here (up) a bit. This doesn't really belong in generic so it will
+-- move to a context module some day.
+
+local function markinitializer(tfmdata,value)
+ local properties = tfmdata.properties
+ properties.checkmarks = value
+end
+
+registerotffeature {
+ name = "checkmarks",
+ description = "check mark widths",
+ default = true,
+ initializers = {
+ node = markinitializer,
+ },
+}
+
+-- This can be used for extra handlers, but should be used with care! We implement one
+-- here but some more can be found in the osd (script devanagary) file. Now watch out:
+-- when a handler has steps, it is called as the other ones, but when we have no steps,
+-- we use a different call:
+--
+-- function(head,dataset,sequence,initialrl,font,dynamic)
+-- return head, done
+-- end
+--
+-- Also see (!!).
+
+otf.handlers = handlers
+
+if context then
+ return
+else
+ -- todo: move the following code someplace else
+end
+
+local setspacekerns = nodes.injections.setspacekerns if not setspacekerns then os.exit() end
+
+local tag = "kern"
+
+-- if fontfeatures then
+
+-- function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,dynamic)
+-- local features = fontfeatures[font]
+-- local enabled = features and features.spacekern and features[tag]
+-- if enabled then
+-- setspacekerns(font,sequence)
+-- end
+-- return head, enabled
+-- end
+
+-- else -- generic (no hashes)
+
+ function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,dynamic)
+ local shared = fontdata[font].shared
+ local features = shared and shared.features
+ local enabled = features and features.spacekern and features[tag]
+ if enabled then
+ setspacekerns(font,sequence)
+ end
+ return head, enabled
+ end
+
+-- end
+
+-- There are fonts out there that change the space but we don't do that kind of
+-- things in TeX.
+
+local function hasspacekerns(data)
+ local resources = data.resources
+ local sequences = resources.sequences
+ local validgpos = resources.features.gpos
+ if validgpos and sequences then
+ for i=1,#sequences do
+ local sequence = sequences[i]
+ local steps = sequence.steps
+ if steps and sequence.features[tag] then
+ local kind = sequence.type
+ if kind == "gpos_pair" or kind == "gpos_single" then
+ for i=1,#steps do
+ local step = steps[i]
+ local coverage = step.coverage
+ local rules = step.rules
+ if rules then
+ -- not now: analyze (simple) rules
+ elseif not coverage then
+ -- nothing to do
+ elseif kind == "gpos_single" then
+ -- maybe a message that we ignore
+ elseif kind == "gpos_pair" then
+ local format = step.format
+ if format == "move" or format == "kern" then
+ local kerns = coverage[32]
+ if kerns then
+ return true
+ end
+ for k, v in next, coverage do
+ if v[32] then
+ return true
+ end
+ end
+ elseif format == "pair" then
+ local kerns = coverage[32]
+ if kerns then
+ for k, v in next, kerns do
+ local one = v[1]
+ if one and one ~= true then
+ return true
+ end
+ end
+ end
+ for k, v in next, coverage do
+ local kern = v[32]
+ if kern then
+ local one = kern[1]
+ if one and one ~= true then
+ return true
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return false
+end
+
+otf.readers.registerextender {
+ name = "spacekerns",
+ action = function(data)
+ data.properties.hasspacekerns = hasspacekerns(data)
+ end
+}
+
+local function spaceinitializer(tfmdata,value) -- dynamic
+ local resources = tfmdata.resources
+ local spacekerns = resources and resources.spacekerns
+ if value and spacekerns == nil then
+ local rawdata = tfmdata.shared and tfmdata.shared.rawdata
+ local properties = rawdata.properties
+ if properties and properties.hasspacekerns then
+ local sequences = resources.sequences
+ local validgpos = resources.features.gpos
+ if validgpos and sequences then
+ local left = { }
+ local right = { }
+ local last = 0
+ local feat = nil
+ for i=1,#sequences do
+ local sequence = sequences[i]
+ local steps = sequence.steps
+ if steps then
+ -- we don't support space kerns in other features
+ local kern = sequence.features[tag]
+ if kern then
+ local kind = sequence.type
+ if kind == "gpos_pair" or kind == "gpos_single" then
+ if feat then
+ for script, languages in next, kern do
+ local f = feat[script]
+ if f then
+ for l in next, languages do
+ f[l] = true
+ end
+ else
+ feat[script] = languages
+ end
+ end
+ else
+ feat = kern
+ end
+ for i=1,#steps do
+ local step = steps[i]
+ local coverage = step.coverage
+ local rules = step.rules
+ if rules then
+ -- not now: analyze (simple) rules
+ elseif not coverage then
+ -- nothing to do
+ elseif kind == "gpos_single" then
+ -- makes no sense in TeX
+ elseif kind == "gpos_pair" then
+ local format = step.format
+ if format == "move" or format == "kern" then
+ local kerns = coverage[32]
+ if kerns then
+ for k, v in next, kerns do
+ right[k] = v
+ end
+ end
+ for k, v in next, coverage do
+ local kern = v[32]
+ if kern then
+ left[k] = kern
+ end
+ end
+ elseif format == "pair" then
+ local kerns = coverage[32]
+ if kerns then
+ for k, v in next, kerns do
+ local one = v[1]
+ if one and one ~= true then
+ right[k] = one[3]
+ end
+ end
+ end
+ for k, v in next, coverage do
+ local kern = v[32]
+ if kern then
+ local one = kern[1]
+ if one and one ~= true then
+ left[k] = one[3]
+ end
+ end
+ end
+ end
+ end
+ end
+ last = i
+ end
+ else
+ -- no steps ... needed for old one ... we could use the basekerns
+ -- instead
+ end
+ end
+ end
+ left = next(left) and left or false
+ right = next(right) and right or false
+ if left or right then
+ spacekerns = {
+ left = left,
+ right = right,
+ }
+ if last > 0 then
+ local triggersequence = {
+ -- no steps, see (!!)
+ features = { [tag] = feat or { dflt = { dflt = true, } } },
+ flags = noflags,
+ name = "trigger_space_kerns",
+ order = { tag },
+ type = "trigger_space_kerns",
+ left = left,
+ right = right,
+ }
+ insert(sequences,last,triggersequence)
+ end
+ end
+ end
+ end
+ resources.spacekerns = spacekerns
+ end
+ return spacekerns
+end
+
+registerotffeature {
+ name = "spacekern",
+ description = "space kern injection",
+ default = true,
+ initializers = {
+ node = spaceinitializer,
+ },
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-pre.mkxl b/Master/texmf-dist/tex/context/base/mkxl/font-pre.mkxl
new file mode 100644
index 00000000000..e6e6930e1a8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-pre.mkxl
@@ -0,0 +1,1025 @@
+%D \module
+%D [ file=font-pre,
+%D version=2012.01.04, % moved from font-ini
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Predefined,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Predefined}
+
+\unprotect
+
+%D A basic set of features is defined here.
+
+% beware, base mode + dynamics can give weird effects
+
+% frac : with numr dnom
+%
+% vkrn valt vert vrt2 vpal : when vertical
+%
+% rtlm rtla : in r2l runs
+% ltrm ltra : in l2r runs
+%
+% rvrn : variable fonts
+%
+% rtbd lfbd : opbd
+%
+% rkrf rphf vatu vjmo tjmo rclt psts pstf ljmo haln
+% pres pref nukt
+% abvs abvm blwm blws cjct blwf akhn (indic)
+% half
+% abvf cfar (khmer)
+%
+% ccmp locl calt clig liga rlig
+%
+% mkmk mark kern (palt pwid) curs (by choice but some fonts need it)
+%
+% init medi isol fina (unicode)
+% fin3 fin2 med2 : syriac
+%
+% cpsp : percentage spacing (todo)
+%
+% dtls flac :math
+
+\definefontfeature
+ [always]
+ [mode=node, % we had 'auto', but let's try 'node' for a while and see what the impact is
+ script=auto, % on speed; 'base' just doesn't play well with dynamics; some day we can even
+ autoscript=position,
+ autolanguage=position,
+ kern=yes, % consider skipping the base passes when no base mode is used
+ mark=yes,
+ mkmk=yes,
+ curs=yes]
+
+\definefontfeature
+ [default]
+ [always]
+ [liga=yes,
+% ccmp=yes, % maybe too
+% locl=yes, % maybe too
+% calt=yes, % maybe too
+% clig=yes, % maybe too
+% rlig=yes, % maybe too
+ tlig=yes,
+ trep=yes] % texligatures=yes,texquotes=yes
+
+\definefontfeature
+ [original] % a clone of default so we can revert
+ [default]
+
+\definefontfeature
+ [smallcaps]
+ [always]
+ [smcp=yes,
+ tlig=yes,
+ trep=yes] % texligatures=yes,texquotes=yes
+
+\definefontfeature
+ [oldstyle]
+ [always]
+ [onum=yes,
+ liga=yes,
+ tlig=yes,
+ trep=yes] % texligatures=yes,texquotes=yes
+
+\definefontfeature
+ [inlinenumbers]
+ [pnum=yes,
+ tnum=no]
+
+\definefontfeature
+ [tabularnumbers]
+ [tnum=yes,
+ pnum=no]
+
+\definefontfeature
+ [oldstylenumbers]
+ [onum=yes]
+
+\definefontfeature
+ [zero]
+ [zero=yes]
+
+% \definefontfeature
+% [newstyle]
+% [onum=no]
+
+\definefontfeature % == default unless redefined
+ [ligatures]
+ [always]
+ [liga=yes,
+ tlig=yes,
+ trep=yes]
+
+\definefontfeature
+ [letterspacing]
+ [liga=no,
+ rlig=no,
+ clig=no,
+ dlig=no,
+ ccmp=yes,
+ keepligatures=auto]
+
+\definefontfeature % can be used for type1 fonts
+ [complete]
+ [always]
+ [compose=yes,
+ liga=yes,
+% ccmp=yes,
+% locl=yes,
+% calt=yes,
+% clig=yes,
+% rlig=yes,
+ tlig=yes,
+ trep=yes]
+
+\definefontfeature
+ [none]
+ [mode=none,
+ features=no]
+
+\definefontfeature
+ [semitic-complete]
+ [mode=node,analyze=yes,language=dflt,ccmp=yes,
+ autoscript=position,autolanguage=position,
+ init=yes,medi=yes,fina=yes,isol=yes,
+ % fin2=yes,fin3=yes,med2=yes,
+ mark=yes,mkmk=yes,kern=yes,curs=yes,
+ liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes]
+
+\definefontfeature
+ [semitic-simple]
+ [mode=node,analyze=yes,language=dflt,ccmp=yes,
+ autoscript=position,autolanguage=position,
+ init=yes,medi=yes,fina=yes,isol=yes,
+ % fin2=yes,fin3=yes,med2=yes,
+ mark=yes,mkmk=yes,kern=yes,curs=yes,
+ rlig=yes,calt=yes]
+
+\definefontfeature
+ [arabic]
+ [semitic-complete]
+ [script=arab]
+
+\definefontfeature
+ [syriac]
+ [arabic]
+ [fin2=yes,fin3=yes,med2=yes]
+
+\definefontfeature
+ [reordercombining]
+ [reordercombining=yes]
+
+\definefontfeature
+ [hebrew]
+ [semitic-complete]
+ [script=hebr,
+ reordercombining=yes] % seems to work best with reasonable fonts
+
+\definefontfeature
+ [simplearabic]
+ [semitic-simple]
+ [script=arab]
+
+\definefontfeature
+ [simplehebrew]
+ [semitic-simple]
+ [script=hebr]
+
+% indic
+
+\definefontfeature
+ [indic-common]
+ [mode=node,
+ language=dflt,
+ % localized
+ locl=yes,
+ % positioning
+ kern=yes,
+ dist=yes,
+ % above/below base marks
+ abvm=yes,
+ blwm=yes,
+ % basic shaping
+ nukt=yes,
+ akhn=yes,
+ rphf=yes,
+ % presentation
+ pres=yes,
+ abvs=yes,
+ blws=yes,
+ psts=yes,
+ haln=yes,
+ calt=yes]
+
+\definefontfeature
+ [devanagari-one]
+ [indic-common]
+ [script=deva,
+ % basic shaping
+ rkrf=yes,
+ blwf=yes,
+ half=yes,
+ vatu=yes,
+ cjct=yes]
+
+\definefontfeature
+ [bengali-one]
+ [indic-common]
+ [script=beng,
+ % basic shaping
+ blwf=yes,
+ half=yes,
+ pstf=yes,
+ vatu=yes,
+ cjct=yes,
+ % presentation
+ init=yes]
+
+\definefontfeature
+ [gujarati-one]
+ [indic-common]
+ [script=gujr,
+ % basic shaping
+ rkrf=yes,
+ blwf=yes,
+ half=yes,
+ vatu=yes,
+ cjct=yes]
+
+\definefontfeature
+ [gurmukhi-one]
+ [indic-common]
+ [script=guru,
+ % basic shaping
+ blwf=yes,
+ half=yes,
+ pstf=yes,
+ vatu=yes,
+ cjct=yes]
+
+\definefontfeature
+ [kannada-one]
+ [indic-common]
+ [script=knda,
+ % basic shaping
+ pref=yes,
+ blwf=yes,
+ half=yes,
+ pstf=yes,
+ cjct=yes]
+
+\definefontfeature
+ [malayalam-one]
+ [indic-common]
+ [script=mlym,
+ % basic shaping
+ pref=yes,
+ blwf=yes,
+ half=yes,
+ pstf=yes,
+ cjct=yes]
+
+\definefontfeature
+ [oriya-one]
+ [indic-common]
+ [script=orya,
+ % basic shaping
+ blwf=yes,
+ pstf=yes,
+ cjct=yes]
+
+\definefontfeature
+ [tamil-one]
+ [indic-common]
+ [script=taml,
+ % basic shaping
+ pref=yes,
+ half=yes]
+
+\definefontfeature
+ [telugu-one]
+ [indic-common]
+ [script=telu,
+ % basic shaping
+ pref=yes,
+ blwf=yes,
+ half=yes,
+ pstf=yes,
+ cjct=yes]
+
+\definefontfeature [devanagari-two] [devanagari-one] [script=dev2]
+\definefontfeature [bengali-two] [bengali-one] [script=bng2]
+\definefontfeature [gujarati-two] [gujarati-one] [script=gjr2]
+\definefontfeature [gurmukhi-two] [gurmukhi-one] [script=gur2]
+\definefontfeature [kannada-two] [kannada-one] [script=knd2]
+\definefontfeature [malayalam-two] [malayalam-one] [script=mlm2]
+\definefontfeature [oriya-two] [oriya-one] [script=ory2]
+\definefontfeature [tamil-two] [tamil-one] [script=tml2]
+\definefontfeature [telugu-two] [telugu-one] [script=tel2]
+
+% mongolian
+
+\definefontfeature
+ [mongolian]
+ [default]
+ [script=mong,
+ init=yes,medi=yes,fina=yes,isol=yes,
+ rlig=yes,rclt=yes,calt=yes,
+ %dlig=yes,cswh=yes, % optional
+ mset]
+
+% tibetan
+
+\definefontfeature
+ [tibetan]
+ [always]
+ [script=tibt,
+ language=dflt,
+ locl=yes,
+ ccmp=yes,
+ abvs=yes,
+ blws=yes,
+ calt=yes,
+ liga=yes,
+ abvm=yes,
+ blwm=yes]
+
+% cjk
+
+\definefontfeature
+ [jamoforms]
+ [ljmo=yes,
+ tjmo=yes,
+ vjmo=yes]
+
+% \definefontfeature
+% [japanese]
+% [default]
+% [language=jan]
+
+% \definefontfeature
+% [simplified-chinese]
+% [default]
+% [language=zhs]
+
+% \definefontfeature
+% [traditional-chinese]
+% [default]
+% [language=zht]
+
+% \definefontfeature
+% [chinese]
+% [simplified-chinese]
+
+% \definefontfeature
+% [korean]
+% [default]
+% [language=kor]
+
+% symbols:
+
+\definefontfeature
+ [dingbats]
+ [mode=base,
+ goodies=dingbats,
+ unicoding=yes]
+
+% math:
+
+\definefontfeature
+ [mathematics]
+ [mode=base,
+ % mode=none, % better, maybe do this last
+ kern=yes,
+ % liga=yes, % makes no sense
+ % tlig=yes, % makes no sense
+ % trep=yes, % makes no sense
+ mathnolimitsmode={0,800}, % this looks okay on the average font
+ mathalternates=yes,
+ mathitalics=yes, % we pass them
+ mathdimensions=all,
+ % mathkerns=yes,
+ % staircase=yes,
+ compactmath=yes,
+ % mathgaps=yes,
+ language=dflt,
+ script=math]
+
+\definefontfeature
+ [oldmath]
+ [oldmath=yes]
+
+\ifdefined\mathnolimitsmode
+ \mathnolimitsmode\plusone % font driven (only opentype)
+\fi
+
+\mathitalicsmode\plusone % 1 : add to simple noad
+%mathitalicsmode\plusthree % 2 : add italic kerns for diagnostics
+
+% \adaptfontfeature[*math*][mathnolimitsmode=1000] % only subscript
+
+\definefontfeature
+ [mathematics-l2r]
+ [mathematics]
+ []
+
+\definefontfeature
+ [mathematics-r2l]
+ [mathematics]
+ [rtlm=yes,
+ locl=yes]
+
+\definefontfeature[virtualmath] [mathematics]
+\definefontfeature[virtualmath-l2r] [mathematics-l2r]
+\definefontfeature[virtualmath-r2l] [mathematics-r2l]
+
+\definefontfeature[math-text] [mathematics] [ssty=no]
+\definefontfeature[math-script] [mathematics] [ssty=1,mathsize=yes]
+\definefontfeature[math-scriptscript] [mathematics] [ssty=2,mathsize=yes]
+
+\definefontfeature[math-text-l2r] [mathematics-l2r] [ssty=no]
+\definefontfeature[math-script-l2r] [mathematics-l2r] [ssty=1,mathsize=yes]
+\definefontfeature[math-scriptscript-l2r] [mathematics-l2r] [ssty=2,mathsize=yes]
+
+\definefontfeature[math-text-r2l] [mathematics-r2l] [ssty=no]
+\definefontfeature[math-script-r2l] [mathematics-r2l] [ssty=1,mathsize=yes]
+\definefontfeature[math-scriptscript-r2l] [mathematics-r2l] [ssty=2,mathsize=yes]
+
+% this will go away: could be a mode in the engine
+
+\definefontfeature[math-nostack-text] [math-text] [nostackmath=yes]
+\definefontfeature[math-nostack-script] [math-script] [nostackmath=yes]
+\definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes]
+
+% \definefontfeature[mathtext] [math-text]
+% \definefontfeature[mathscript] [math-script]
+% \definefontfeature[mathscriptscript] [math-scriptscript]
+
+% \definefontfeature
+% [missing]
+% [missing=yes]
+
+%D Nice to have too:
+
+\definefontfeature
+ [quality]
+ [expansion=quality,
+ protrusion=quality]
+
+\definefontfeature
+ [fullprotrusion]
+ [protrusion=pure]
+
+\definefontfeature
+ [slanted]
+ [slant=.2]
+
+% \definefontfeature
+% [boldened]
+% [extend=1.2]
+
+%D Neat:
+
+% By eye:
+%
+% \definefontfeature[boldened-10][effect={width=0.10,delta=1.0,hdelta=0.500,ddelta=0.150,vshift=0.125,extend=1.025,squeeze=0.99250}]
+% \definefontfeature[boldened-15][effect={width=0.15,delta=1.0,hdelta=0.500,ddelta=0.150,vshift=0.250,extend=1.050,squeeze=0.98750}]
+% \definefontfeature[boldened-20][effect={width=0.20,delta=1.0,hdelta=0.500,ddelta=0.150,vshift=0.375,extend=1.075,squeeze=0.98125}]
+% \definefontfeature[boldened-30][effect={width=0.30,delta=1.0,hdelta=0.500,ddelta=0.150,vshift=0.500,extend=1.100,squeeze=0.97500}]
+%
+% By calculation:
+%
+% \definefontfeature[boldened-10][effect={width=0.10,delta=1.0,hdelta=0.02500,ddelta=0.02500,vshift=0.02500,extend=1.050,squeeze=0.99500}]
+% \definefontfeature[boldened-15][effect={width=0.15,delta=1.0,hdelta=0.05625,ddelta=0.05625,vshift=0.05625,extend=1.075,squeeze=0.99250}]
+% \definefontfeature[boldened-20][effect={width=0.20,delta=1.0,hdelta=0.10000,ddelta=0.10000,vshift=0.10000,extend=1.100,squeeze=0.99000}]
+% \definefontfeature[boldened-30][effect={width=0.30,delta=1.0,hdelta=0.22500,ddelta=0.22500,vshift=0.22500,extend=1.150,squeeze=0.98500}]
+%
+% So we can do this:
+
+\definefontfeature[boldened-10][effect={width=0.10,auto=yes}]
+\definefontfeature[boldened-15][effect={width=0.15,auto=yes}]
+\definefontfeature[boldened-20][effect={width=0.20,auto=yes}]
+\definefontfeature[boldened-25][effect={width=0.25,auto=yes}]
+\definefontfeature[boldened-30][effect={width=0.30,auto=yes}]
+
+\definefontfeature
+ [boldened]
+ [boldened-30]
+
+%D Emoji etc:
+
+\definefontfeature[bandw:overlay][ccmp=yes,dist=yes]
+\definefontfeature[color:overlay][ccmp=yes,dist=yes,colr=yes]
+%definefontfeature[bandw:svg] [ccmp=yes,dist=yes]
+\definefontfeature[color:svg] [ccmp=yes,dist=yes,svg=yes]
+%definefontfeature[bandw:bitmap] [ccmp=yes,dist=yes,sbix=yes]
+\definefontfeature[color:bitmap] [ccmp=yes,dist=yes,sbix=yes] % also cblc
+
+% Plus an automatic one:
+
+\definefontfeature[color] [ccmp=yes,dist=yes,color=auto]
+
+%D We define some colors that are used in tracing (for instance \OPENTYPE\
+%D features). We cannot yet inherit because no colors are predefined.
+
+\definecolor[font:init][r=.75]
+\definecolor[font:medi][g=.75]
+\definecolor[font:fina][b=.75]
+\definecolor[font:isol][r=.75,g=.75] % [y=.75]
+\definecolor[font:mark][r=.75,b=.75] % [m=.75]
+\definecolor[font:rest][b=.75,g=.75] % [c=.75]
+
+\definecolor[font:0] [s=1]
+\definecolor[font:1] [r=.75]
+\definecolor[font:2] [g=.75]
+\definecolor[font:3] [b=.75]
+\definecolor[font:4] [r=.75,g=.75]
+\definecolor[font:5] [r=.75,b=.75]
+\definecolor[font:6] [b=.75,g=.75]
+\definecolor[font:7] [r=.75]
+\definecolor[font:8] [g=.75]
+\definecolor[font:9] [b=.75]
+
+\definecolor[f:r:t][a=1,t=.25,r=1]
+\definecolor[f:g:t][a=1,t=.25,g=1]
+\definecolor[f:b:t][a=1,t=.25,b=1]
+\definecolor[f:c:t][a=1,t=.25,c=1]
+\definecolor[f:m:t][a=1,t=.25,m=1]
+\definecolor[f:y:t][a=1,t=.25,y=1]
+\definecolor[f:k:t][a=1,t=.25,s=0]
+\definecolor[f:s:t][a=1,t=.25,s=0]
+
+\definepalet % weird place
+ [layout]
+ [grid=trace:dr,
+ page=trace:dg,
+ profile=f:s:t,
+ one=f:y:t,
+ mix=f:b:t]
+
+%D Now we're up to some definitions.
+
+\definebodyfontenvironment
+ [\s!default]
+ [ \s!text=1.0,
+ \s!script=0.7,
+ \s!scriptscript=0.5,
+ \s!a=1.200,
+ \s!b=1.440,
+ \s!c=1.728,
+ \s!d=2.074,
+ *=\font_currentfontscale, % wildcard
+ \s!x=0.8,
+ \s!xx=0.6,
+ \v!big=1.2,
+ \v!small=0.8,
+ \c!interlinespace=,
+ \s!em=\v!slanted]
+
+\definebodyfontenvironment
+ [20.7pt]
+ [ \s!text=20.7pt,
+ \s!script=\!!fourteenpointfour,
+ \s!scriptscript=\!!twelvepoint,
+ \s!x=17.3pt,
+ \s!xx=\!!fourteenpointfour,
+ \v!big=20.7pt, % !!!!
+ \v!small=17.3pt]
+
+\definebodyfontenvironment
+ [17.3pt]
+ [ \s!text=17.3pt,
+ \s!script=\!!twelvepoint,
+ \s!scriptscript=\!!tenpoint,
+ \s!x=\!!fourteenpointfour,
+ \s!xx=\!!twelvepoint,
+ \v!big=20.7pt,
+ \v!small=\!!fourteenpointfour]
+
+\definebodyfontenvironment
+ [\!!fourteenpointfour]
+ [ \s!text=\!!fourteenpointfour,
+ \s!script=\!!elevenpoint,
+ \s!scriptscript=\!!ninepoint,
+ \s!x=\!!twelvepoint,
+ \s!xx=\!!tenpoint,
+ \v!big=17.3pt,
+ \v!small=\!!twelvepoint]
+
+\definebodyfontenvironment
+ [\!!twelvepoint]
+ [ \s!text=\!!twelvepoint,
+ \s!script=\!!ninepoint,
+ \s!scriptscript=\!!sevenpoint,
+ \s!x=\!!tenpoint,
+ \s!xx=\!!eightpoint,
+ \v!big=\!!fourteenpointfour,
+ \v!small=\!!tenpoint]
+
+\definebodyfontenvironment
+ [\!!elevenpoint]
+ [ \s!text=\!!elevenpoint,
+ \s!script=\!!eightpoint,
+ \s!scriptscript=\!!sixpoint,
+ \s!x=\!!ninepoint,
+ \s!xx=\!!sevenpoint,
+ \v!big=\!!twelvepoint,
+ \v!small=\!!ninepoint]
+
+\definebodyfontenvironment
+ [\!!tenpoint]
+ [ \s!text=\!!tenpoint,
+ \s!script=\!!sevenpoint,
+ \s!scriptscript=\!!fivepoint,
+ \s!x=\!!eightpoint,
+ \s!xx=\!!sixpoint,
+ \v!big=\!!twelvepoint,
+ \v!small=\!!eightpoint]
+
+\definebodyfontenvironment
+ [\!!ninepoint]
+ [ \s!text=\!!ninepoint,
+ \s!script=\!!sevenpoint,
+ \s!scriptscript=\!!fivepoint,
+ \s!x=\!!sevenpoint,
+ \s!xx=\!!fivepoint,
+ \v!big=\!!elevenpoint,
+ \v!small=\!!sevenpoint]
+
+\definebodyfontenvironment
+ [\!!eightpoint]
+ [ \s!text=\!!eightpoint,
+ \s!script=\!!sixpoint,
+ \s!scriptscript=\!!fivepoint,
+ \s!x=\!!sixpoint,
+ \s!xx=\!!fivepoint,
+ \v!big=\!!tenpoint,
+ \v!small=\!!sixpoint]
+
+\definebodyfontenvironment
+ [\!!sevenpoint]
+ [ \s!text=\!!sevenpoint,
+ \s!script=\!!sixpoint,
+ \s!scriptscript=\!!fivepoint,
+ \s!x=\!!sixpoint,
+ \s!xx=\!!fivepoint,
+ \v!big=\!!ninepoint,
+ \v!small=\!!fivepoint]
+
+\definebodyfontenvironment
+ [\!!sixpoint]
+ [ \s!text=\!!sixpoint,
+ \s!script=\!!fivepoint,
+ \s!scriptscript=\!!fivepoint,
+ \s!x=\!!fivepoint,
+ \s!xx=\!!fivepoint,
+ \v!big=\!!eightpoint,
+ \v!small=\!!fivepoint]
+
+\definebodyfontenvironment
+ [\!!fivepoint]
+ [ \s!text=\!!fivepoint,
+ \s!script=\!!fivepoint,
+ \s!scriptscript=\!!fivepoint,
+ \s!x=\!!fivepoint,
+ \s!xx=\!!fivepoint,
+ \v!big=\!!sevenpoint,
+ \v!small=\!!fivepoint]
+
+\definebodyfontenvironment
+ [\!!fourpoint]
+ [ \s!text=\!!fourpoint,
+ \s!script=\!!fourpoint,
+ \s!scriptscript=\!!fourpoint,
+ \s!x=\!!fourpoint,
+ \s!xx=\!!fourpoint,
+ \v!big=\!!sixpoint,
+ \v!small=\!!fourpoint]
+
+\definebodyfontswitch [fourteenpointfour] [\!!fourteenpointfour]
+\definebodyfontswitch [twelvepoint] [\!!twelvepoint]
+\definebodyfontswitch [elevenpoint] [\!!elevenpoint]
+\definebodyfontswitch [tenpoint] [\!!tenpoint]
+\definebodyfontswitch [ninepoint] [\!!ninepoint]
+\definebodyfontswitch [eightpoint] [\!!eightpoint]
+\definebodyfontswitch [sevenpoint] [\!!sevenpoint]
+\definebodyfontswitch [sixpoint] [\!!sixpoint]
+\definebodyfontswitch [fivepoint] [\!!fivepoint]
+\definebodyfontswitch [fourpoint] [\!!fourpoint]
+
+%D So far.
+
+\definefontstyle [\s!hw] [\s!hw]
+\definefontstyle [\s!cg] [\s!cg]
+
+\definefontstyle [\v!roman,\v!serif,\v!regular] [\s!rm]
+\definefontstyle [\v!sansserif,\v!sans,\v!support] [\s!ss]
+\definefontstyle [\v!teletype,\v!type,\v!mono] [\s!tt]
+\definefontstyle [\v!handwritten] [\s!hw]
+\definefontstyle [\v!calligraphic] [\s!cg]
+\definefontstyle [\v!math,\v!mathematics] [\s!mm]
+
+\definefontalternative[\s!tf]
+\definefontalternative[\s!bf]
+\definefontalternative[\s!it]
+\definefontalternative[\s!sl]
+\definefontalternative[\s!bs]
+\definefontalternative[\s!bi]
+\definefontalternative[\s!sc]
+
+\definefontsize[\s!a] \definefontsize[\s!b]
+\definefontsize[\s!c] \definefontsize[\s!d]
+
+\definealternativestyle [\v!mediaeval] [\os] []
+\definealternativestyle [\v!normal] [\tf] []
+\definealternativestyle [\v!bold] [\bf] []
+\definealternativestyle [\v!type] [\tt] []
+\definealternativestyle [\v!mono] [\tt] []
+\definealternativestyle [\v!slanted] [\sl] []
+\definealternativestyle [\v!italic] [\it] []
+\definealternativestyle [\v!boldslanted,\v!slantedbold] [\bs] []
+\definealternativestyle [\v!bolditalic,\v!italicbold] [\bi] []
+
+\definealternativestyle [\v!small,\v!smallnormal] [\setsmallbodyfont\tf] []
+\definealternativestyle [\v!smallbold] [\setsmallbodyfont\bf] []
+\definealternativestyle [\v!smalltype] [\setsmallbodyfont\tt] []
+\definealternativestyle [\v!smallitalic,\v!smallslanted] [\setsmallbodyfont\sl] []
+\definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\setsmallbodyfont\bs] []
+\definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\setsmallbodyfont\bi] []
+
+\definealternativestyle [\v!bigger] [\setbigbodyfont \tf] []
+\definealternativestyle [\v!smaller] [\setsmallbodyfont\tf] []
+
+\definealternativestyle [\v!sans,\v!sansserif] [\ss]
+\definealternativestyle [\v!roman,\v!serif,\v!regular] [\rm]
+\definealternativestyle [\v!handwritten] [\hw]
+\definealternativestyle [\v!calligraphic] [\cg]
+
+\definealternativestyle [\v!sansnormal] [\ss\tf] []
+\definealternativestyle [\v!sansbold] [\ss\bf] []
+\definealternativestyle [\v!serifnormal] [\rm\tf] []
+\definealternativestyle [\v!serifbold] [\rm\bf] []
+\definealternativestyle [\v!mononormal] [\tt\tf] []
+\definealternativestyle [\v!monobold] [\tt\bf] []
+
+\definealternativestyle [typeface] [\typeface] [] % no translation here (quite basic)
+\definealternativestyle [boldface] [\boldface] []
+\definealternativestyle [slantedface] [\slantedface] []
+\definealternativestyle [italicface] [\italicface] []
+\definealternativestyle [swapface] [\swapface] []
+
+\definealternativestyle [emphasize] [\em] [\em] % new
+
+% For Alan:
+
+\definealternativestyle
+ [\v!camel]
+ [{\setcharactercasing[\v!camel]}]
+ [{\setcharactercasing[\v!camel]}]
+
+% % maybe we need interface neutral as well (for use in cld):
+%
+% \letcscsname\mediaeval \csname\v!mediaeval \endcsname
+% \letcscsname\normal \csname\v!normal \endcsname
+% \letcscsname\bold \csname\v!bold \endcsname
+% \letcscsname\mono \csname\v!mono \endcsname
+% \letcscsname\slanted \csname\v!slanted \endcsname
+% \letcscsname\italic \csname\v!italic \endcsname
+% \letcscsname\boldslanted \csname\v!boldslanted \endcsname
+% \letcscsname\slantedbold \csname\v!slantedbold \endcsname
+% \letcscsname\bolditalic \csname\v!bolditalic \endcsname
+% \letcscsname\italicbold \csname\v!italicbold \endcsname
+%
+% \letcscsname\small \csname\v!small \endcsname
+% \letcscsname\smallnormal \csname\v!smallnormal \endcsname
+% \letcscsname\smallbold \csname\v!smallbold \endcsname
+% \letcscsname\smalltype \csname\v!smalltype \endcsname
+% \letcscsname\smallslanted \csname\v!smallslanted \endcsname
+% \letcscsname\smallboldslanted\csname\v!smallboldslanted\endcsname
+% \letcscsname\smallslantedbold\csname\v!smallslantedbold\endcsname
+% \letcscsname\smallbolditalic \csname\v!smallbolditalic \endcsname
+% \letcscsname\smallitalicbold \csname\v!smallitalicbold \endcsname
+%
+% \letcscsname\bigger \csname\v!bigger \endcsname
+% \letcscsname\smaller \csname\v!smaller \endcsname
+%
+% \letcscsname\sans \csname\v!sans \endcsname
+% \letcscsname\sansserif \csname\v!sansserif \endcsname
+% \letcscsname\sansbold \csname\v!sansbold \endcsname
+
+%D We can go on and on and on:
+%D
+%D \starttyping
+%D \setupbodyfontenvironment[default][p=0.8,q=0.6]
+%D \definefontsize[p]
+%D \definefontsize[q]
+%D \stoptyping
+
+%D Slow but handy:
+
+\definealternativestyle [\v!smallbodyfont] [\setsmallbodyfont] []
+\definealternativestyle [\v!bigbodyfont] [\setbigbodyfont] []
+
+%D We treat {\sc Small Caps} and \cap {Pseudo Caps} a bit different. We also provide
+%D an \WORD {uppercase} style.
+
+\definealternativestyle [\v!WORD] [{\setcharactercasing[\v!WORD ]}] [{\setcharactercasing[\v!WORD ]}]
+\definealternativestyle [\v!word] [{\setcharactercasing[\v!word ]}] [{\setcharactercasing[\v!word ]}]
+\definealternativestyle [\v!Word] [{\setcharactercasing[\v!Word ]}] [{\setcharactercasing[\v!Word ]}]
+\definealternativestyle [\v!Words] [{\setcharactercasing[\v!Words ]}] [{\setcharactercasing[\v!Words ]}]
+\definealternativestyle [\v!capital] [{\setcharactercasing[\v!capital]}] [{\setcharactercasing[\v!capital]}]
+\definealternativestyle [\v!Capital] [{\setcharactercasing[\v!Capital]}] [{\setcharactercasing[\v!Capital]}]
+\definealternativestyle [\v!mixed] [{\setcharactercasing[\v!mixed ]}] [{\setcharactercasing[\v!mixed ]}]
+
+\definealternativestyle [\v!cap] [{\setcharactercasing[\v!cap ]}] [{\setcharactercasing[\v!cap ]}]
+\definealternativestyle [\v!Cap] [{\setcharactercasing[\v!Cap ]}] [{\setcharactercasing[\v!Cap ]}]
+
+%D From now (2013-03-17) on we have:
+
+\definefontfeature[f:smallcaps][smcp=yes]
+\definefontfeature[f:oldstyle] [onum=yes]
+\definefontfeature[f:tabular] [tnum=yes]
+\definefontfeature[f:superiors][sups=yes]
+\definefontfeature[f:inferiors][subs=yes]
+\definefontfeature[f:fractions][frac=yes]
+\definefontfeature[f:kern] [kern=yes]
+\definefontfeature[f:kerns] [kern=yes]
+
+\definealternativestyle [\v!smallcaps] [\setsmallcaps] [\setsmallcaps]
+\definealternativestyle [\v!oldstyle] [\setoldstyle ] [\setoldstyle ]
+\definealternativestyle [\v!fractions] [\setfractions\resetbreakpoints] [\setfractions\resetbreakpoints]
+
+\permanent\protected\def\setsmallcaps{\doaddfeature{f:smallcaps}}
+\permanent\protected\def\setoldstyle {\doaddfeature{f:oldstyle}}
+\permanent\protected\def\settabular {\doaddfeature{f:tabular}}
+\permanent\protected\def\setsuperiors{\doaddfeature{f:superiors}}
+\permanent\protected\def\setfractions{\doaddfeature{f:fractions}}
+
+% \permanent\protected\def\frc#1#2%
+% {\dontleavehmode
+% \begingroup
+% \addff{frac}%
+% \resetbreakpoints
+% #1/#2%
+% \endgroup}
+
+%D \macros
+%D {uppercasing, lowercasing}
+
+\definefontfeature[lowercasing][lowercasing=yes]
+\definefontfeature[uppercasing][uppercasing=yes]
+
+\permanent\protected\def\uppercasing{\addff{uppercasing}}
+\permanent\protected\def\lowercasing{\addff{lowercasing}}
+
+%D \macros
+%D {tinyfont}
+%D
+%D By default we load the Computer Modern Roman fonts (but not yet at this moment)
+%D and activate the 12pt roman bodyfont. Sans serif and teletype are also available
+%D and can be called for by \type {\ss} and \type {\tt}. Loading takes place
+%D elsewhere. For tracing purposes we define:
+
+\definefont[tinyfont][file:dejavusansmono at 1ex]
+
+%D \macros
+%D {infofont}
+%D
+%D The second situation occurs when we enable the info mode, and put all kind of
+%D status information in the margin. We don't want huge switches to the main
+%D bodyfont and style, so here too we use a direct method.
+
+\pushoverloadmode
+
+\let\infofont \relax
+\let\infofontbold \relax
+\let\smallinfofont \relax
+\let\smallinfofontbold\relax
+
+\definefont[infofont] [file:dejavusansmono*none at 6pt]
+\definefont[infofontbold] [file:dejavusansmono-bold*none at 6pt]
+\definefont[smallinfofont] [file:dejavusansmono*none at 3pt]
+\definefont[smallinfofontbold][file:dejavusansmono-bold*none at 3pt]
+
+%D Optimization (later we overload in math). Also needed in order to get \type {\ss}
+%D properly defined.
+
+\permanent\protected\def\normaltf{\let\fontalternative\s!tf\font_helpers_synchronize_font}
+\permanent\protected\def\normalbf{\let\fontalternative\s!bf\font_helpers_synchronize_font}
+\permanent\protected\def\normalit{\let\fontalternative\s!it\font_helpers_synchronize_font}
+\permanent\protected\def\normalsl{\let\fontalternative\s!sl\font_helpers_synchronize_font}
+\permanent\protected\def\normalbi{\let\fontalternative\s!bi\font_helpers_synchronize_font}
+\permanent\protected\def\normalbs{\let\fontalternative\s!bs\font_helpers_synchronize_font}
+
+\let\tf\normaltf
+\let\bf\normalbf
+\let\it\normalit
+\let\sl\normalsl
+\let\bi\normalbi
+\let\bs\normalbs
+
+\permanent\protected\def\normalrm{\font_helpers_set_current_font_style{\s!rm}}
+\permanent\protected\def\normalss{\font_helpers_set_current_font_style{\s!ss}}
+\permanent\protected\def\normaltt{\font_helpers_set_current_font_style{\s!tt}}
+
+\let\rm\normalrm
+\let\ss\normalss
+\let\tt\normaltt
+
+\popoverloadmode
+
+% experiment:
+
+\startsetups experiment:fonts:compact
+ \settrue\c_font_compact
+
+% \definefontfeature[virtualmath] [mathematics] [compactmath=yes]
+% \definefontfeature[virtualmath-l2r] [mathematics-l2r][compactmath=yes]
+% \definefontfeature[virtualmath-r2l] [mathematics-r2l][compactmath=yes]
+
+% \definefontfeature[math-text] [mathematics] [compactmath=yes]
+% \definefontfeature[math-script] [mathematics] [compactmath=yes]
+% \definefontfeature[math-scriptscript] [mathematics] [compactmath=yes]
+% \definefontfeature[math-text-l2r] [mathematics-l2r][compactmath=yes]
+% \definefontfeature[math-script-l2r] [mathematics-l2r][compactmath=yes]
+% \definefontfeature[math-scriptscript-l2r][mathematics-l2r][compactmath=yes]
+% \definefontfeature[math-text-r2l] [mathematics-r2l][compactmath=yes]
+% \definefontfeature[math-script-r2l] [mathematics-r2l][compactmath=yes]
+% \definefontfeature[math-scriptscript-r2l][mathematics-r2l][compactmath=yes]
+\stopsetups
+
+\installtexexperiment
+ {fonts.compact}
+ {\directsetup{experiment:fonts:compact}}
+ {}
+
+\protect \endinput
+
+% LM math vs CM math (analysis by Taco):
+%
+% Computer Modern Roman : Donald Knuth
+% Latin Modern : LM Font Revision Team
+%
+% lmex10.tfm % identical
+% lmmi5.tfm % identical
+% lmmi6.tfm % identical
+% lmmi7.tfm % identical
+% lmmi8.tfm % identical
+% lmmi9.tfm % identical
+% lmmi10.tfm % identical
+% lmmi12.tfm % identical
+% lmmib10.tfm % identical
+% lmsy5.tfm % extra chars: 254,255 (octal)
+% lmsy6.tfm % extra chars: 254,255 (octal)
+% lmsy7.tfm % extra chars: 254,255 (octal)
+% lmsy8.tfm % extra chars: 254,255 (octal)
+% lmsy9.tfm % extra chars: 254,255 (octal)
+% lmsy10.tfm % extra chars: 254,255 (octal)
+% lmbsy10.tfm % extra chars: 254,255 (octal)
+%
+% From the 'AMS' set:
+%
+% lmmib5.tfm % identical
+% lmmib7.tfm % identical
+% lmbsy5.tfm % extra chars: 254,255 (octal)
+% lmbsy7.tfm % extra chars: 254,255 (octal)
+%
+% The two extra characters are:
+%
+% /lessorequalslant
+% /greaterorequalslant
+
+% \unprotect
+%
+% \definehighlight[\v!italic ][\c!command=\v!no,\c!style=\v!italic]
+% \definehighlight[\v!bold ][\c!command=\v!no,\c!style=\v!bold]
+% \definehighlight[\v!bolditalic][\c!command=\v!no,\c!style=\v!bolditalic]
+% \definehighlight[\v!mono] [\c!command=\v!no,\c!style=\v!mono]
+% \definehighlight[\v!monobold] [\c!command=\v!no,\c!style=\v!monobold]
+%
+% \definehighlight[important] [\c!command=\v!no,\c!style=\v!bold]
+% \definehighlight[unimportant] [\c!command=\v!no,\c!color=darkgray]
+% \definehighlight[warning] [\c!command=\v!no,\c!style=\v!bold,\c!color=darkblue]
+% \definehighlight[error] [\c!command=\v!no,\c!style=\v!bold,\c!color=darkred]
+%
+% \protect
+%
+% \starttext
+% \highlight[italic] {italic}
+% \highlight[bolditalic] {bolditalic}
+% \highlight[bold] {bold}
+% \highlight[mono] {mono}
+% \highlight[monobold] {monobold}
+% \highlight[important] {important}
+% \highlight[unimportant]{unimportant}
+% \highlight[warning] {warning}
+% \highlight[error] {error}
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-sel.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-sel.mklx
new file mode 100644
index 00000000000..a25b7fab7c5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-sel.mklx
@@ -0,0 +1,282 @@
+%D \module
+%D [ file=font-sel,
+%D version=2016.08.28,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Selectfont,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D license=GNU General Public License]
+
+\writestatus{loading}{ConTeXt User Module / Selectfont}
+
+\registerctxluafile{font-sel}{}
+
+\unprotect
+
+\installcorenamespace {selectfont}
+\installsimplecommandhandler \??selectfont {selectfont}
+
+\let\selectfont_index\!!zerocount
+
+\protected\def\selectfont_register[#style][#settings]%
+ {\begingroup
+ \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}%
+ \checkselectfontparent
+ \setupcurrentselectfont[#settings]%
+ \edef\p_selectfont_preset{\selectfontparameter\c!preset}%
+ \ifempty\p_selectfont_preset \else
+ \processcommacommand[\p_selectfont_preset]\selectfont_preset_process
+ \setupcurrentselectfont[#settings]%
+ \fi
+ \font_helpers_process_alternative_list\clf_registerfontalternative
+ \setexpandedselectfontparameter\c!style{\expandnamespaceparameter\??fontshortstyle\selectfontparameter\c!style\s!rm}%
+ \xdef\selectfont_index{\clf_registerfontfamily
+ metadata {%
+ typeface {\selectfontparameter\c!label}%
+ style {\selectfontparameter\c!style}%
+ family {\selectfontparameter\c!name}%
+ }
+ options {%
+ designsize {\selectfontparameter\s!designsize}%
+ rscale {\selectfontparameter\s!rscale}%
+ goodies {\selectfontparameter\c!goodies}%
+ extras {\selectfontparameter\c!extras}%
+ features {\selectfontparameter\c!features}%
+ preset {\selectfontparameter\c!preset}%
+ range {\selectfontparameter\c!range}% fallback only
+ offset {\selectfontparameter\c!offset}% fallback only
+ check {\selectfontparameter\c!check}% fallback only
+ force {\selectfontparameter\c!force}% fallback only
+ }
+ userdata {%
+ \luaexpanded{#settings}%
+ }}%
+ \endgroup}
+
+%D \macros
+%D {definefontfamilypreset}
+
+\installcorenamespace {selectfontpreset}
+
+\permanent\tolerant\protected\def\definefontfamilypreset[#name]#spacer[#settings]%
+ {\defcsname\??selectfontpreset#name\endcsname{\setupcurrentselectfont[#settings]}%
+ \clf_definefontfamilypreset{#name}{\luaexpanded{#settings}}}
+
+\def\selectfont_preset_process#name%
+ {\ifcsname\??selectfontpreset#name\endcsname
+ \lastnamedcs
+ \else
+ % unknown preset
+ \fi}
+
+\definefontfamilypreset
+ [range:chinese]
+ [\c!range={cjkcompatibilityforms,
+ cjkcompatibilityideographs,
+ cjkcompatibilityideographssupplement,
+ cjkradicalssupplement,
+ cjkstrokes,
+ cjksymbolsandpunctuation,
+ cjkunifiedideographs,
+ cjkunifiedideographsextensiona,
+ cjkunifiedideographsextensionb,
+ halfwidthandfullwidthforms,
+ verticalforms,
+ bopomofo,
+ bopomofoextended}]
+
+\definefontfamilypreset
+ [range:japanese]
+ [\c!range={cjkcompatibilityforms,
+ cjkcompatibilityideographs,
+ cjkcompatibilityideographssupplement,
+ cjkradicalssupplement,
+ cjkstrokes,
+ cjksymbolsandpunctuation,
+ cjkunifiedideographs,
+ cjkunifiedideographsextensiona,
+ cjkunifiedideographsextensionb,
+ halfwidthandfullwidthforms,
+ verticalforms,
+ hiragana,
+ katakana}]
+
+\definefontfamilypreset
+ [range:korean]
+ [\c!range={cjkcompatibilityforms,
+ cjkcompatibilityideographs,
+ cjkcompatibilityideographssupplement,
+ cjkradicalssupplement,
+ cjkstrokes,
+ cjksymbolsandpunctuation,
+ cjkunifiedideographs,
+ cjkunifiedideographsextensiona,
+ cjkunifiedideographsextensionb,
+ halfwidthandfullwidthforms,
+ verticalforms,
+ hangulcompatibilityjamo,
+ hanguljamo,
+ hanguljamoextendeda,
+ hanguljamoextendedb,
+ hangulsyllables}]
+
+\definefontfamilypreset
+ [range:cyrillic]
+ [\c!range={cyrillic,
+ cyrillicextendeda,
+ cyrillicextendedb,
+ cyrillicsupplement}]
+
+\definefontfamilypreset
+ [range:greek]
+ [\c!range={greekandcoptic,
+ greekextended,
+ ancientgreeknumbers}]
+
+\definefontfamilypreset
+ [range:hebrew]
+ [\c!range={hebrew,
+ alphabeticpresentationforms}]
+
+\definefontfamilypreset [math:digitsnormal] [\c!range=digitsnormal]
+\definefontfamilypreset [math:digitsbold] [\c!range=digitsnormal,\c!offset=digitsbold,\s!tf=style:bold]
+
+\definefontfamilypreset [math:uppercasenormal] [\c!range=uppercasenormal]
+\definefontfamilypreset [math:uppercaseitalic] [\c!range=uppercasenormal,\c!offset=uppercaseitalic, \s!tf=style:italic]
+\definefontfamilypreset [math:uppercasebold] [\c!range=uppercasenormal,\c!offset=uppercasebold, \s!tf=style:bold]
+\definefontfamilypreset [math:uppercasebolditalic] [\c!range=uppercasenormal,\c!offset=uppercasebolditalic,\s!tf=style:bolditalic]
+
+\definefontfamilypreset [math:lowercasenormal] [\c!range=lowercasenormal]
+\definefontfamilypreset [math:lowercaseitalic] [\c!range=lowercasenormal,\c!offset=lowercaseitalic, \s!tf=style:italic]
+\definefontfamilypreset [math:lowercasebold] [\c!range=lowercasenormal,\c!offset=lowercasebold, \s!tf=style:bold]
+\definefontfamilypreset [math:lowercasebolditalic] [\c!range=lowercasenormal,\c!offset=lowercasebolditalic,\s!tf=style:bolditalic]
+
+\definefontfamilypreset [math:mathematicaloperators] [\c!range=mathematicaloperators]
+
+\definefontfamilypreset [math:lowercasegreeknormal] [\c!range=lowercasegreeknormal]
+\definefontfamilypreset [math:lowercasegreekitalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekitalic, \s!tf=style:italic]
+\definefontfamilypreset [math:lowercasegreekbold] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbold, \s!tf=style:bold]
+\definefontfamilypreset [math:lowercasegreekbolditalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbolditalic,\s!tf=style:bolditalic]
+
+\definefontfamilypreset [math:uppercasegreeknormal] [\c!range=uppercasegreeknormal]
+\definefontfamilypreset [math:uppercasegreekitalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekitalic, \s!tf=style:italic]
+\definefontfamilypreset [math:uppercasegreekbold] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbold, \s!tf=style:bold]
+\definefontfamilypreset [math:uppercasegreekbolditalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbolditalic,\s!tf=style:bolditalic]
+
+%D \macros
+%D {definefontfamily,definefallbackfamily}
+%D
+%D The \tex{definefontfamily} creates like \tex{definetypeface} a collection of font
+%D with different styles which can be later called with the \tex{setupbodyfont} command.
+%D
+%D The command takes three mandatory commands which are (a) the name of the fontclass,
+%D (b) the styles of the font and (c) the name of the font.
+%D
+%D \starttyping
+%D \definefontfamily [dejavu] [serif] [DejaVu Serif]
+%D \definefontfamily [dejavu] [sans] [DejaVu Sans]
+%D \definefontfamily [dejavu] [mono] [DejaVu Sans Mono]
+%D \definefontfamily [dejavu] [math] [XITS Math] [rscale=1.1]
+%D
+%D \definefontfamily [office] [serif] [Times New Roman]
+%D \definefontfamily [office] [sans] [Arial] [rscale=0.9]
+%D \definefontfamily [office] [mono] [Courier]
+%D \definefontfamily [office] [math] [TeX Gyre Termes Math]
+%D
+%D \definefontfamily [linux] [serif] [Linux Libertine O]
+%D \definefontfamily [linux] [sans] [Linux Biolinum O]
+%D \definefontfamily [linux] [mono] [Latin Modern Mono]
+%D \definefontfamily [linux] [math] [TeX Gyre Pagella Math] [rscale=0.9]
+%D
+%D \setupbodyfont[dejavu]
+%D
+%D \starttext
+%D
+%D \rm Serif \ss Sans \tt Mono \m{1+2=3}
+%D
+%D \switchtobodyfont[office]
+%D
+%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3}
+%D
+%D \switchtobodyfont[linux]
+%D
+%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3}
+%D
+%D \stoptext
+%D \stoptyping
+%D
+%D When a document contains different languages and the global font lacks some characters
+%D for one language, one could set a different font where these charcters are taken from.
+%D This fallback font (there can be more than one for a certain style) could be set with
+%D the \tex{definefallbackfamily} command which takes the same argument as
+%D the \tex{definefontfamily} command.
+%D
+%D \starttyping
+%D \definefallbackfamily [mainface] [serif] [DejaVu Serif] [range=cyrillic]
+%D \definefontfamily [mainface] [serif] [TeX Gyre Pagella]
+%D
+%D \setupbodyfont[mainface]
+%D
+%D \setuplanguage[en][patterns={us,ru}]
+%D
+%D \starttext
+%D
+%D \input knuth
+%D
+%D Традиционная систематика лишайников оказывается во многом условна и
+%D
+%D \stoptext
+%D \stoptyping
+%D
+%D Another feature of the module is the \type{designsize} key which allows one to enable
+%D optical sizes when they are a feature of the requested font.
+%D
+%D \starttyping
+%D \definefontfamily[mainface][serif][Latin Modern Roman][designsize=auto]
+%D
+%D \setupbodyfont[mainface]
+%D
+%D \starttext
+%D \scale[width=\textwidth]{\switchtobodyfont [6pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic}
+%D \scale[width=\textwidth]{\switchtobodyfont [8pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic}
+%D \scale[width=\textwidth]{\switchtobodyfont [10pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic}
+%D \scale[width=\textwidth]{\switchtobodyfont [12pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic}
+%D \scale[width=\textwidth]{\switchtobodyfont[17.3pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic}
+%D \stoptext
+%D \stoptyping
+
+% tf = … | * … | name:… | name:* … | file:… | file:* … | style:medium
+
+\permanent\tolerant\protected\def\definefontfamily[#typeface]#spacer[#style]#spacer[#family]#spacer[#settings]%
+ {\ifhastok={#settings}%
+ \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]%
+ \else
+ \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]%
+ \fi
+ \clf_definefontfamily\selectfont_index\relax}
+
+\permanent\tolerant\def\definefallbackfamily[#typeface]#spacer[#style]#spacer[#family]#spacer[#settings]%
+ {\ifhastok={#settings}%
+ \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]%
+ \else
+ \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]%
+ \fi
+ \clf_definefallbackfamily\selectfont_index\relax}
+
+\permanent\tolerant\protected\def\setupfontfamily[#style]#spacer[#settings]%
+ {\ifparameter#settings\or
+ \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}%
+ \setupcurrentselectfont[#settings]%
+ \else
+ \let\currentselectfont\empty
+ \setupcurrentselectfont[#style]%
+ \fi}
+
+\setupselectfont
+ [ \c!features=\s!default,
+ \s!designsize=\s!default,
+ \s!rscale=\selectfontparameter\c!scale,
+ \c!scale=1]
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-set.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-set.mklx
new file mode 100644
index 00000000000..fd6a2f1ff51
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-set.mklx
@@ -0,0 +1,158 @@
+%D \module
+%D [ file=font-set,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Initial Loading,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Initial Loading}
+
+\unprotect
+
+%D Defining fonts using \type {\definebodyfont} takes time, so we prefer to
+%D predefine at least the Computer Modern Roman fonts. However, loading all those
+%D fonts at definition time would take both time and space. But even worse, once
+%D fonts are loaded into memory, their encoding vector is fixed, which is a handicap
+%D when we want to distribute the compact \type {fmt} files. So what we want to do
+%D is defining fonts in a way that postpones the loading. We accomplish this by only
+%D loading the fonts when we switch to another bodyfont size. Among the other
+%D alternatives, such as loading the font at the moment of activation and redefining
+%D the activation macro afterwards, this proved to be the most efficient
+%D alternative.
+%D
+%D The next few macros take care of the one exeption on this scheme. When at format
+%D generation time we load the default font file, the one that defines the Computer
+%D Modern Fonts, we don't want the fonts metrics to end up in the format file, so we
+%D temporary prohibit loading. This means that at runtime we have to load the
+%D default bodyfont size just before we start typesetting.
+
+% \enablemode[lmmath]
+
+\let\m_font_fallback_name\empty
+
+% keep as reference:
+%
+% \def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont
+% {\dorecurse\plusseven{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as:
+% \clf_resetnullfont % in luatex 0.70 this will also do the previous
+% \glet\font_preloads_reset_nullfont\relax}
+
+\def\font_preload_check_mode
+ {\doifelsemode{lmmath}
+ {\def\m_font_fallback_name{modern-designsize-virtual}}% this will stay
+ {\def\m_font_fallback_name{modern-designsize}}% % this might become 'modern'
+ \glet\font_preload_check_mode\relax}
+
+\def\font_preload_default_fonts
+ {\font_preloads_reset
+ \font_preload_check_mode
+ \setupbodyfont[\m_font_fallback_name,\fontstyle,\fontbody]%
+ \showmessage\m!fonts6{fallback \m_font_fallback_name\space \fontstyle\normalspace\normalizedbodyfontsize}}
+
+\def\font_preload_default_fonts_mm
+ {\font_preload_check_mode
+ \writestatus\m!fonts{preloading \m_font_fallback_name\space (math)}%
+ \definetypeface[\fontclass][\s!mm][\s!math][\m_font_fallback_name][\s!default]%
+ \showmessage\m!fonts6{fallback \m_font_fallback_name\space mm \normalizedbodyfontsize}}
+
+\def\font_preload_default_fonts_tt
+ {\font_preload_check_mode
+ \writestatus\m!fonts{preloading \m_font_fallback_name\space (mono)}%
+ \definetypeface[\fontclass][\s!tt][\s!mono][\m_font_fallback_name][\s!default]%
+ \showmessage\m!fonts6{fallback \m_font_fallback_name\space tt \normalizedbodyfontsize}}
+
+\def\font_preloads_reset
+ {\glet\font_preload_default_fonts \relax
+ %\glet\font_preload_default_fonts_tt\relax
+ %\glet\font_preload_default_fonts_mm\relax
+ \glet\font_preloads_zero_stage \relax
+ \glet\font_preloads_first_stage \relax
+ \glet\font_preloads_second_stage \relax
+ %\glet\font_preloads_third_stage \relax
+ \global\everyhbox\emptytoks
+ \global\everyvbox\emptytoks
+ % old: \font_preloads_reset_nullfont, new:
+ \clf_resetnullfont}
+
+\appendtoks
+ \font_preloads_reset
+\to \everystartnotext
+
+\def\font_preloads_reset_checked
+ {\glet\font_preload_default_fonts_tt\relax
+ \glet\font_preload_default_fonts_mm\relax
+ \glet\font_preloads_third_stage \relax
+% \glet\font_preloads_fourth_stage \relax
+ }
+
+\def\font_preloads_zero_stage_indeed
+ {\definedfont[\s!file:lmmono10-regular sa 1]}
+
+\protected\def\font_preloads_zero_stage
+ {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}%
+ \glet\font_preloads_zero_stage\font_preloads_zero_stage_indeed
+ \font_preloads_zero_stage}
+
+\protected\def\font_preloads_first_stage % % *nofonts -> *preloadfonts
+ {\doifelsemode{*preloadfonts}
+ {\font_preload_default_fonts
+ \writestatus\m!fonts{preloading latin modern fonts (first stage)}}
+ {\writestatus\m!fonts{latin modern fonts are not preloaded}}}
+
+\protected\def\font_preloads_second_stage
+ {\writestatus\m!fonts{preloading latin modern fonts (second stage)}%
+ \font_preload_default_fonts}
+
+\protected\def\font_preloads_third_stage % always
+ {\ifempty\fontclass
+ \writestatus\m!fonts{preloading latin modern fonts (third stage)}%
+ \font_preload_default_fonts
+ \font_preloads_reset
+ \else
+ \font_preloads_reset
+ \push_macro_fontstyle
+ \ifcsname\??fontclass\fontclass\s!mm\s!features\endcsname \else
+ \font_preload_default_fonts_mm
+ \fi
+ \ifcsname\??fontclass\fontclass\s!tt\s!features\endcsname \else
+ \font_preload_default_fonts_tt
+ \fi
+ \pop_macro_fontstyle
+ \font_preloads_reset_checked % reset third, mm and tt
+ \setupbodyfont[\fontstyle]%
+ \fi}
+
+\protected\def\font_preloads_fourth_stage
+ {\begingroup
+ %ifzeropt\fontcharwd\font\number`!\relax
+ \setbox\scratchbox\hpack{\tf c o n t e x t}%
+ \ifzeropt\wd\scratchbox
+ \writeline
+ \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}%
+ \writestatus\m!fonts{!! loaded (maybe due to a missing \string\starttext).}%
+ \writeline
+ \fi
+ \font_preloads_reset
+ \endgroup}
+
+\appendtoks
+ \everyhbox{\font_preloads_zero_stage}%
+ \everyvbox{\font_preloads_zero_stage}%
+\to \everydump
+
+\protected\def\font_preloads_at_every_job {\font_preloads_first_stage }
+\protected\def\font_preloads_at_start_text{\font_preloads_second_stage}
+\protected\def\font_preloads_at_stop_text {\font_preloads_fourth_stage}
+\protected\def\font_preloads_at_definition{\font_preloads_third_stage
+ \glet\font_preloads_at_definition\relax}
+
+% \protected\def\checkpreloadedbodyfont % no \let here
+% {\font_preloads_at_start_text}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-sol.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-sol.mklx
new file mode 100644
index 00000000000..8f3d3d712cb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-sol.mklx
@@ -0,0 +1,131 @@
+%D \module
+%D [ file=font-sol,
+%D version=2009.05.19,
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Solutions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Node Support / Splitters}
+
+% todo: pass color for tracing
+
+%D This module is specially made for the oriental \TEX\ project. The working is as
+%D follows (and tuned for fonts like Idris' Husayni. The following method came to
+%D my mind after a couple of Skype sessions with Idris while working on the rough
+%D edges of the Husayni font and playing with font dynamics.
+%D
+%D \startitemize[packed]
+%D
+%D \item We define a couple of features sets, some can have stylistics variants
+%D that result in the same words getting a different width. Normally this
+%D happens in a goodies file.
+%D
+%D \item We group such features in a solution set. A solutionset can be enabled
+%D by setting an attribute.
+%D
+%D \item For each paragraph we identify words that get this set applied. We replace
+%D these words by a user node that refers to the original.
+%D
+%D \item For each word we apply the features to a copy that we associate with this
+%D original word.
+%D
+%D \item At the end we have a paragraph (node list) with user nodes that point to a
+%D cache that has originals and processed variants.
+%D
+%D \item When the paragraph is broken into lines we optimize the spacing by
+%D substituting variants.
+%D
+%D \stopitemize
+%D
+%D This approach permits us to use a dedicated paragraph builder, one that treats
+%D the user nodes special and takes the alternatives into account.
+%D
+%D Currently we assume only one solution being active. Maybe some day I'll support
+%D a mixture. This is only one way of optimizing and after several experiments this
+%D one was chosen as testcase. It took quite some experiments (and time) to get thus
+%D far.
+%D
+%D The is experimental code for the Oriental \TEX\ project and aspects of it might
+%D change.
+%D
+%D \starttyping
+%D \setupfontsolutions[method={random,preroll},criterium=1,randomseed=101]
+%D
+%D \definefontsolution % actually only the last run needs to be done this way
+%D [FancyHusayni]
+%D [goodies=husayni,
+%D solution=experimental]
+%D
+%D \definedfont[husayni*husayni-default at 24pt]
+%D \setupinterlinespace[line=36pt]
+%D \righttoleft
+%D \enabletrackers[parbuilders.solutions.splitters.colors]
+%D \setfontsolution[FancyHusayni]
+%D alb alb alb \par
+%D \resetfontsolution
+%D \disabletrackers[parbuilders.solutions.splitters.colors]
+%D \stoptyping
+
+\registerctxluafile{font-sol}{}
+
+\unprotect
+
+\definesystemattribute[splitter][public]
+
+\installcorenamespace{fontsolution}
+
+\installcommandhandler \??fontsolution {fontsolution} \??fontsolution
+
+\aliased\let\setupfontsolutions\setupfontsolution
+
+\appendtoks
+ \clf_definefontsolution
+ {\currentfontsolution}%
+ {% these are frozen
+ goodies {\fontsolutionparameter\s!goodies}%
+ solution {\fontsolutionparameter\c!solution}%
+ less {\fontsolutionparameter\c!less}%
+ more {\fontsolutionparameter\c!more}%
+ }%
+ \relax
+\to \everydefinefontsolution
+
+\permanent\protected\def\setfontsolution[#solution]% just one
+ {\edef\currentfontsolution{#solution}%
+ \clf_setfontsolution
+ {\currentfontsolution}%
+ {%
+ method {\fontsolutionparameter\c!method}%
+ criterium {\fontsolutionparameter\c!criterium}%
+ % randomseed {\fontsolutionparameter\c!random}%
+ }%
+ \relax}
+
+\let\currentfontsolution\empty
+
+\permanent\protected\def\resetfontsolution % resets all
+ {\clf_resetfontsolution
+ \let\currentfontsolution\empty}
+
+\permanent\protected\def\startfontsolution % [#1]
+ {\pushmacro\currentfontsolution
+ \setfontsolution}
+
+\permanent\protected\def\stopfontsolution
+ {\ifhmode\par\fi
+ \clf_stopfontsolution
+ \popmacro\currentfontsolution}
+
+% We initialize this module at the \LUA\ end.
+%
+% \setupfontsolutions
+% [\c!method={\v!normal,preroll},
+% \c!criterium=0]
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-sty.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-sty.mklx
new file mode 100644
index 00000000000..503356a4a88
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-sty.mklx
@@ -0,0 +1,439 @@
+%D \module
+%D [ file=font-sty,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Styles,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Styles}
+
+\unprotect
+
+%D \macros
+%D {definealternativestyle}
+%D
+%D In the main modules we are going to implement lots of parameterized commands and
+%D one of these parameters will concern the font to use. To suit consistent use of
+%D fonts we here implement a mechanism for defining the keywords that present a
+%D particular style or alternative.
+%D
+%D \starttyping
+%D \definealternativestyle [keywords] [\style] [\nostyle]
+%D \stoptyping
+%D
+%D The first command is used in the normal textflow, while the second command takes
+%D care of headings and alike. Consider the next two definitions:
+%D
+%D \starttyping
+%D \definealternativestyle [bold] [\bf] []
+%D \definealternativestyle [cap] [\cap] [\cap]
+%D \stoptyping
+%D
+%D A change \type {\bf} in a heading which is to be set in \type {\tfd} does not look
+%D that well, so therefore we leave the second argument of \type
+%D {\definealternativestyle} empty. When we capatalize characters using the pseudo
+%D small cap command \type {\cap}, we want this to take effect in both text and
+%D headings, which is accomplished by assigning both arguments.
+
+\installcorenamespace{alternativestyles} % settings
+\installcorenamespace{alternativestyle} % instances
+
+\installsetuponlycommandhandler \??alternativestyles {alternativestyles}
+
+\setnewconstant \c_font_current_alternative_style_index \plusone
+
+\permanent\tolerant\protected\def\definealternativestyle[#commands]#spacer[#variantone]#spacer[#varianttwo]%
+ {\processcommalist[#commands]{\font_basics_define_alternative_style_indeed{#variantone}{#varianttwo}}}
+
+% \let\definestyle\definealternativestyle % later redefined
+
+\newconstant\c_fonts_basics_alternative_style_method
+
+% maybe permanent
+
+\def\font_basics_define_alternative_style_indeed#variantone#varianttwo#command%
+ {\protected\defcsname\??alternativestyle#command\endcsname{\font_helpers_apply_alternative_style{#variantone}{#varianttwo}}%
+ \ifcsname#command\endcsname
+ % no redefinition
+ \orelse\ifnum\c_fonts_basics_alternative_style_method=\plusone
+ \ifparameter#command\or
+ \permanent\protected\edefcsname#command\endcsname{\triggergroupedcommandcs\begincsname\??alternativestyle#command\endcsname}%
+ \else
+ \permanent\protected\defcsname#command\endcsname{\triggergroupedcommand{#variantone}}%
+ \fi
+ \else
+ \permanent\protected\defcsname#command\endcsname{\triggergroupedcommand{#variantone}}%
+ \fi}
+
+\def\font_helpers_apply_alternative_style
+ {\ifcase\c_font_current_alternative_style_index
+ \expandafter\gobbletwoarguments
+ \or
+ \expandafter\firstoftwoarguments
+ \or
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\permanent\def\applyalternativestyle#name% public .. expandable? frozen?
+ {\begincsname\??alternativestyle#name\endcsname}
+
+\appendtoks
+ \doifelse{\alternativestylesparameter\c!method}\v!auto
+ {\c_fonts_basics_alternative_style_method\plusone}%
+ {\c_fonts_basics_alternative_style_method\zerocount}%
+\to \everysetupalternativestyles
+
+%D Maybe too generic, but probably ok is the following. (Maybe one day we will use a
+%D dedicated grouped command for styles.)
+
+% \appendtoks
+% \let\groupedcommand\thirdofthreearguments
+% \to \everysimplifycommands
+
+%D This command also defines the keyword as command. This means that the example
+%D definition of \type {bold} we gave before, results in a command \type {\bold}
+%D which can be used as:
+%D
+%D \startbuffer
+%D He's a \bold{bold} man with a {\bold head}.
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D or
+%D
+%D \startexample
+%D \definealternativestyle[bold][\bf][]\getbuffer
+%D \stopexample
+%D
+%D Such definitions are of course unwanted for \type {\cap} because this would
+%D result in an endless recursive call. Therefore we check on the existance of both
+%D the command and the substitution. The latter is needed because for instance \type
+%D {\type} is an entirely diferent command. That command handles verbatim, while the
+%D style command would just switch to teletype font. This is just an example of a
+%D tricky naming coincidence.
+%D
+%D \macros
+%D {doconvertfont,noconvertfont,
+%D dontconvertfont,redoconvertfont}
+%D
+%D After having defined such keywords, we can call for them by using
+%D
+%D \starttyping
+%D \doconvertfont{keyword}{text}
+%D \stoptyping
+%D
+%D We deliberately pass an argument. This enables us to assign converters that
+%D handle one argument, like \type {\cap}.
+%D
+%D By default the first specification is used to set the style, exept when we say
+%D \type {\dontconvertfont}, after which the second specification is used. We can
+%D also directly call for \type {\noconvertfont}. In nested calls, we can restore
+%D the conversion by saying \type {\redoconvertfont}.
+%D
+%D These commands are not grouped! Grouping is most probably done by the calling
+%D macro's and would lead to unnecessary overhead.
+
+\let\m_current_convert_font \empty
+\let\m_current_convert_font_dt\empty
+
+\permanent\protected\def\doconvertfont#specification% takes second argument / this command is obsolete
+ {\edef\m_current_convert_font{#specification}%
+ \ifempty\m_current_convert_font
+ %\expandafter\firstofoneargument
+ \else
+ \expandafter\font_helpers_do_convert_font
+ \fi}
+
+\def\font_helpers_do_convert_font
+ {\edef\m_current_convert_font_dt{\detokenize\expandafter{\m_current_convert_font}}%
+ \ifcsname\??alternativestyle\m_current_convert_font_dt\endcsname
+ \expandafter\lastnamedcs
+ \orelse\ifcsname\m_current_convert_font_dt\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\m_current_convert_font
+ \fi}
+
+%D Low level switches (downward compatible, but we keep them as one can use them in
+%D styles):
+%D
+%D \starttyping
+%D \usemodule[abr-02]
+%D \setuphead[chapter][style=\bfb]
+%D \setupfooter[style=\dontconvertfont\bf]
+%D \chapter{This is \TEX}
+%D \stoptyping
+
+\permanent\protected\def\dontconvertfont{\c_font_current_alternative_style_index\plustwo} % needs checking in usage
+\permanent\protected\def\redoconvertfont{\c_font_current_alternative_style_index\plusone} % needs checking in usage
+
+%D The new one:
+
+\setfalse\fontattributeisset
+
+\mutable\let\currentdetokenizedstyleparameter\empty
+
+\permanent\protected\def\dousestyleparameter#value%
+ {\edef\currentstyleparameter{#value}%
+ \ifempty\currentstyleparameter\else
+ \expandafter\dousecurrentstyleparameter
+ \fi}
+
+\permanent\protected\def\dousestylehashparameter#hash#parameter%
+ {\ifcsname#hash#parameter\endcsname
+ \expandafter\dousestyleparameter\lastnamedcs
+ \fi}
+
+\permanent\protected\def\dousecurrentstyleparameter % empty check outside here
+ {\edef\currentdetokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
+ \settrue\fontattributeisset % reset is done elsewhere
+ \ifcsname\??alternativestyle\currentdetokenizedstyleparameter\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\currentdetokenizedstyleparameter\endcsname
+ \lastnamedcs
+ \else
+ \currentstyleparameter
+ \fi}
+
+%D New commands (not yet interfaced):
+%D
+%D \startbuffer
+%D \definestyle[one][style=bold,color=darkblue]
+%D
+%D test \one{test} test
+%D test \style[one]{test} test
+%D test \style[color=red]{test} test
+%D test \style[Serif at 20pt]{test} test
+%D \stopbuffer
+%D
+%D \typebuffer \startlines \getbuffer \stoplines
+
+% definitions .. no tagging here
+
+\installcorenamespace{style}
+\installcorenamespace{stylecheck}
+\installcorenamespace{stylehack}
+
+\installcommandhandler \??style {style} \??style
+
+\setupstyle
+ [%\c!style=,
+ %\c!color=,
+ \c!method=\v!command]
+
+\appendtoks
+ \letvalue{\??stylecheck\currentstyle}\relax
+ \edef\p_method{\styleparameter\c!method}%
+ \ifx\p_method\v!command
+ \frozen\instance\setuevalue{\e!start\currentstyle}{\font_styles_apply_start{\currentstyle}}%
+ \frozen\instance\setuevalue{\e!stop \currentstyle}{\font_styles_apply_stop}%
+ \frozen\instance\setuevalue {\currentstyle}{\font_styles_apply_grouped{\currentstyle}}% no longer groupedcommand here
+ \fi
+\to \everydefinestyle
+
+\protected\def\font_styles_apply_start#name%
+ {\begingroup
+ \font_styles_use_defined{#name}}
+
+\protected\def\font_styles_apply_stop
+ {\endgroup}
+
+\protected\def\font_styles_apply_grouped#name% assumes that the next is { or \bgroup
+ {\bgroup
+ \def\currentstyle{\font_styles_use_defined{#name}}%
+ \afterassignment\currentstyle
+ \let\nexttoken}
+
+\protected\def\font_styles_use_defined#name%
+ {\edef\currentstyle{#name}%
+ \usestylestyleandcolor\c!style\c!color}
+
+\protected\def\font_styles_use_generic#specification%
+ {\let\currentstyle\s!unknown % reasonable generic tag
+ \letstyleparameter\c!style\empty
+ \letstyleparameter\c!color\empty
+ \setupcurrentstyle[#specification]%
+ \usestylestyleandcolor\c!style\c!color}
+
+% commands
+
+\installcorenamespace{styleargument}
+
+\permanent\protected\def\style[#name]% as this is can be a switch we use groupedcommand % frozen?
+ {\csname\??styleargument
+ \ifcsname\??stylecheck#name\endcsname
+ 2% defined as style
+ \orelse\ifcsname\??stylehack#name\endcsname
+ 4% defined as command
+ \orelse\ifcsname#name\endcsname
+ 1% defined as command
+ \else
+ 3% specification
+ \fi
+ \endcsname{#name}}
+
+\setvalue{\??styleargument1}#name%
+ {\expandafter\triggergroupedcommandcs\begincsname#name\endcsname}
+
+\setvalue{\??styleargument2}#name%
+ {\triggergroupedcommand{\font_styles_use_defined{#name}}} % or {\font_styles_apply_grouped{#name}}
+
+\setvalue{\??styleargument3}#specification%
+ {\doifelseassignment{#specification}\font_styles_assignment\font_styles_direct{#specification}}
+
+\setvalue{\??styleargument4}#name%
+ {\expandafter\triggergroupedcommandcs\begincsname\??stylehack#name\endcsname}
+
+\setvalue{\??stylehack\s!math}% dirty trick
+ {\groupedcommand\normalstartimath\normalstopimath}
+
+% \def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}}
+% \def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}}
+
+\def\font_styles_assignment#specification{\triggergroupedcommand{\font_styles_use_generic{#specification}}}
+\def\font_styles_direct #specification{\triggergroupedcommand{\definedfont[#specification]}}
+
+% environments
+
+\installcorenamespace{styleenvironment}
+
+\permanent\protected\def\startstyle[#name]%
+ {\begingroup
+ \csname\??styleenvironment
+ \ifcsname\??stylecheck#name\endcsname
+ 2% defined as style
+ \orelse\ifcsname#name\endcsname
+ 1% defined as command
+ \else
+ 3% specification
+ \fi
+ \endcsname{#name}}
+
+\permanent\protected\def\stopstyle
+ {\endgroup
+ \autoinsertnextspace} % will be configurable, maybe also in \definestartstop
+
+\setvalue{\??styleenvironment1}#name%
+ {\csname#name\endcsname}
+
+\setvalue{\??styleenvironment2}#name%
+ {\font_styles_use_defined{#name}}
+
+\setvalue{\??styleenvironment3}#specification%
+ {\doifelseassignment{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}}
+
+\def\font_styles_start_assignment#specification{\font_styles_use_generic{#specification}}
+\def\font_styles_start_direct #specification{\definedfont[#specification]\relax}
+
+%D Still experimental (might even go away).
+
+% \definestylecollection[mine]
+
+% \definestyleinstance[mine][default][sorry]
+% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl]
+% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl]
+% \definestyleinstance[mine][bf][\sl]
+% \definestyleinstance[mine][sl][\tt]
+
+% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}}
+
+\installcorenamespace{stylecollection}
+
+\permanent\tolerant\protected\def\definestylecollection[#name]%
+ {\ifarguments\or
+ \setuvalue{#name}{\styleinstance[#name]}%
+ \def\font_styles_define_style_collection_a#style%
+ {\def\font_styles_define_style_collection_b#alternative{\undefinevalue{\??stylecollection#name:#style:#alternative}}%
+ \font_helpers_process_alternative_list\font_styles_define_style_collection_b
+ \font_styles_define_style_collection_b\s!default}%
+ \font_helpers_process_style_list\font_styles_define_style_collection_a
+ \font_styles_define_style_collection_a\s!default
+ \fi}
+
+\let\font_styles_define_style_collection \relax
+\let\font_styles_define_style_collection_a\relax
+\let\font_styles_define_style_collection_b\relax
+
+\permanent\tolerant\protected\def\definestyleinstance[#instance]#*[#2]#*[#3]#*[#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever]
+ {\ifparameter#instance\or
+ \ifarguments\or\or
+ \letcsname\??stylecollection#instance::#2\endcsname\empty
+ \or
+ \defcsname\??stylecollection#instance::#2\endcsname{#3}%
+ \or
+ \defcsname\??stylecollection#instance:#2:#3\endcsname{#4}%
+ \fi
+ \ifcsname#instance\endcsname\else\font_styles_define_style_collection[#instance]\fi
+ \fi}
+
+\permanent\protected\def\styleinstance[#instance]% maybe \lastnamedcs here too
+ {\csname\??stylecollection#instance:%
+ \ifcsname\??stylecollection#instance:\fontstyle:\fontalternative\endcsname
+ \fontstyle:\fontalternative
+ \orelse\ifcsname\??stylecollection#instance:\fontstyle:\s!default\endcsname
+ \fontstyle:\s!default
+ \orelse\ifcsname\??stylecollection#instance::\fontalternative\endcsname
+ :\fontalternative
+ \else
+ :\s!default
+ \fi
+ \endcsname}
+
+%D Variant selectors
+%D
+%D \starttyping
+%D \mathematics {\vsone{\utfchar{0x2229}}}
+%D \mathematics {\utfchar{0x2229}\vsone{}}
+%D \stoptyping
+
+\permanent\protected\edef\vsone#character{#character\normalUchar"FE00 } % used
+\permanent\protected\edef\vstwo#character{#character\normalUchar"FE01 } % not used but handy for testing
+
+%D For historic reasons we keep the following around but they are no longer that
+%D relevant for \MKIV. But \unknown\ they will be dropped in \LMTX !
+
+\permanent\protected\def\doattributes#1#2#3#4%
+ {\begingroup % geen \bgroup, anders in mathmode lege \hbox
+ \dousestylehashparameter{#1}{#2}%
+ \dousecolorhashparameter{#1}{#3}%
+ #4%
+ \endgroup}
+
+\permanent\protected\def\dostartattributes#1#2#3%
+ {\begingroup % geen \bgroup, anders in mathmode lege \hbox
+ \dousestylehashparameter{#1}{#2}%
+ \dousecolorhashparameter{#1}{#3}}
+
+\aliased\let\dostopattributes\endgroup
+
+%D New but it needs to be supported explicitly (as in natural tables).
+
+\newconditional\c_font_styles_math
+
+\protected\def\font_styles_math_reset
+ {\setfalse\c_font_styles_math}
+
+\protected\def\font_styles_math_start
+ {\ifconditional\c_font_styles_math
+ \startimath
+ \fi
+ \relax}
+
+\protected\def\font_styles_math_stop
+ {\relax
+ \ifconditional\c_font_styles_math
+ \stopimath
+ \fi}
+
+\definealternativestyle[\v!math][\settrue\c_font_styles_math]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-sym.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-sym.mklx
new file mode 100644
index 00000000000..c908ad849d3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-sym.mklx
@@ -0,0 +1,250 @@
+%D \module
+%D [ file=font-mat,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Symbolic Access,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Symbolic Access}
+
+\unprotect
+
+%D \macros
+%D {getglyph, symbolicfont}
+%D
+%D Individual glyphs can be accessed by using
+%D
+%D \starttyping
+%D \getglyph{fontname}{character}
+%D \stoptyping
+%D
+%D This macro is used in for instance the symbol modules and as one can see, it does
+%D obey the small and even smaller sizes. The \type {\symbolicfont} macro can be
+%D used to switch to a font named \type {fontname} (see \type {cont-log} and \type
+%D {symb-eur} for examples of symbolic definitions.
+
+\def\v_font_string_a
+ {\ifx\fontstyle\s!rm \s!Serif \orelse
+ \ifx\fontstyle\s!ss \s!Sans \orelse
+ \ifx\fontstyle\s!tt \s!Mono \else
+ \s!Serif \fi}
+
+\def\v_font_string_b
+ {\ifx\fontstyle\s!rm \s!Regular \orelse
+ \ifx\fontstyle\s!ss \s!Support \orelse
+ \ifx\fontstyle\s!tt \s!Type \else
+ \s!Serif \fi}
+
+\def\v_font_string_c
+ {\ifx\fontalternative\s!bf \s!Bold \orelse
+ \ifx\fontalternative\s!sl \s!Slanted \orelse
+ \ifx\fontalternative\s!it \s!Italic \orelse
+ \ifx\fontalternative\s!bs \s!BoldSlanted \orelse
+ \ifx\fontalternative\s!bi \s!BoldItalic \fi}
+
+\let\v_font_string_d\s!Serif % default fontstyle (will be redefined in type-ini)
+
+\definefontsynonym
+ [CurrentFont]
+ [\noexpand\v_font_string_a\noexpand\v_font_string_c]
+
+% potential generalization:
+%
+% \letvalue{\??fontfile:t:\s!rm}\s!Serif
+% \letvalue{\??fontfile:t:\s!ss}\s!Sans
+% \letvalue{\??fontfile:t:\s!tt}\s!Mono
+%
+% \letvalue{\??fontfile:a:\s!rm}\s!Regular
+% \letvalue{\??fontfile:a:\s!ss}\s!Support
+% \letvalue{\??fontfile:a:\s!tt}\s!Type
+%
+% \letvalue{\??fontfile:s:\s!bf}\s!Bold
+% \letvalue{\??fontfile:s:\s!sl}\s!Slanted
+% \letvalue{\??fontfile:s:\s!it}\s!Italic
+% \letvalue{\??fontfile:s:\s!bs}\s!BoldSlanted
+% \letvalue{\??fontfile:s:\s!bi}\s!BoldItalic
+%
+% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
+% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
+% \def\v_font_string_b{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif}
+% \def\v_font_string_c{\executeifdefined{\??fontfile:s:\fontstyle}\empty}
+% \def\v_font_string_d{\executeifdefined{\??fontfile:t:\csname\??typescriptdefaultstyles\fontclass\endcsname}\s!Serif}
+
+%D \macros
+%D {fontstylesuffix}
+%D
+%D The next macro is used to map non latin fontnames on fonts. See \type
+%D {font-uni} for an example of its use.
+
+% \frozen ...
+
+\permanent\def\fontstylesuffix% why the \s!Regular ? see \getglyph
+ {\ifx\fontalternative\s!tf \s!Regular \orelse
+ \ifx\fontalternative\s!bf \s!Bold \orelse
+ \ifx\fontalternative\s!sl \s!Slanted \orelse
+ \ifx\fontalternative\s!it \s!Italic \orelse
+ \ifx\fontalternative\s!bs \s!BoldSlanted \orelse
+ \ifx\fontalternative\s!bi \s!BoldItalic \orelse
+ \ifx\fontalternative\s!sc \s!Caps \else
+ \s!Regular \fi}
+
+\permanent\def\glyphfontfile#base% appends
+ {#base%
+ \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname
+ \v_font_string_a\v_font_string_c
+ \orelse\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname
+ \v_font_string_b\v_font_string_c
+ \orelse\ifcsname\??fontfile#base\v_font_string_a\endcsname
+ \v_font_string_a
+ \orelse\ifcsname\??fontfile#base\v_font_string_b\endcsname
+ \v_font_string_b
+ \orelse\ifcsname\??fontfile#base\v_font_string_c\endcsname
+ \v_font_string_c
+ \fi}
+
+%D The next macro can be used to make decisions based on the shape:
+
+\permanent\def\doifelseitalic#yes#nop%
+ {\ifx\fontalternative\s!sl#yes\orelse
+ \ifx\fontalternative\s!it#yes\orelse
+ \ifx\fontalternative\s!bs#yes\orelse
+ \ifx\fontalternative\s!bi#yes\else#nop\fi}
+
+\aliased\let\doifitalicelse\doifelseitalic
+
+%D For an example of usage of the following command, see \type {cont-log.tex}.
+%D
+%D \starttyping
+%D \def\symbolicfont#specification{\definedfont[\glyphfontfile{#specification} sa *]}
+%D \stoptyping
+%D
+%D Since we know what scaling it to be applied, we can implement a much faster
+%D alternative:
+
+\installcorenamespace{symbolfont}
+
+\mutable\let\skedsymbolfont \empty % for diagnostics
+\mutable\let\currentsymbolfont\empty
+\mutable\let\askedsymbolfont \empty
+
+\permanent\protected\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
+ {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \lastnamedcs
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\permanent\protected\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
+ {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \lastnamedcs
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\permanent\protected\def\setstyledsymbolicfont#fontname% quite a slowdown, glyphfontfile
+ {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#fontname}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \lastnamedcs
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\permanent\protected\def\setdirectsymbolicfont#fontname%
+ {\edef\askedsymbolfont{\truefontname{#fontname} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \lastnamedcs
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\def\font_basics_define_symbolic_font
+ {\definefont[currentsymbolfont][\askedsymbolfont]%
+ \currentsymbolfont
+ \gletcsname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall}
+
+\permanent\protected\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_fontchar{#character}}}
+\permanent\protected\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_fontchar{#character}}}
+\permanent\protected\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}}
+\permanent\protected\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}}
+\permanent\protected\def\resolvedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_tochar{#character}}}
+\permanent\protected\def\resolvedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_tochar{#character}}}
+
+% this one is wrong:
+
+\permanent\protected\def\getscaledglyph#scale#name#content%
+ {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifelsenumber{#content}\char\donothing#content}}
+
+\aliased\let\getglyph \getglyphstyled % old, soon obsolete
+\aliased\let\getrawglyph \getglyphdirect % old, soon obsolete
+\aliased\let\symbolicsizedfont\setscaledstyledsymbolicfont % old, soon obsolete
+\aliased\let\symbolicfont \setstyledsymbolicfont % old, soon obsolete
+
+\permanent\protected\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody}
+
+%D The last implementation of \type {\getglyph} permits definitions like:
+%D
+%D \starttyping
+%D \definefontsynonym [EuroSans] [eurose]
+%D \definefontsynonym [EuroSansBold] [euroseb]
+%D \definefontsynonym [EuroSansItalic] [eurosei]
+%D \definefontsynonym [EuroSansSlanted] [eurosei]
+%D \definefontsynonym [EuroSansBoldItalic] [eurosebi]
+%D \definefontsynonym [EuroSansBoldSlanted] [eurosebi]
+%D
+%D \definesymbol [euro] [\getglyph{Euro}{\char160}]
+%D
+%D \def\euro{\symbol[euro]}
+%D \stoptyping
+%D
+%D These definitions guarantee that the next calls work okay:
+%D
+%D \starttyping
+%D \ss \tf\euro \bf\euro \sla\euro \itd\euro \bs\euro \bic\euro
+%D \stoptyping
+%D
+%D The shape as well as the size is adapted to the current environment.
+
+%D \macros
+%D {setfont}
+%D
+%D Every now and then we want to define a font directly, for instance when we
+%D typeset title pages. The next macro saves some typing:
+
+\mutable\let\nextfont\relax % this one could be more private but this is okay
+
+\permanent\protected\def\setfont% geen \font_helpers_set_font mogelijk
+ {\afterassignment\font_basics_set_font\font\nextfont=}
+
+\def\font_basics_set_font
+ {\nextfont\setupinterlinespace}% hm, we need to use \setuplocalinterlinespace
+
+%D One can call this macro as:
+%D
+%D \starttyping
+%D \setfont cmr10 at 60pt
+%D \stoptyping
+%D
+%D After which the font is active and the baselines and struts are set.
+
+%D \macros{doiffontcharelse}
+
+\permanent\protected\def\doifelsefontchar#specification#unicode% this could be a direct lua call
+ {\begingroup
+ \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
+ \iffontchar\font#unicode\relax
+ \endgroup\expandafter\firstoftwoarguments
+ \else
+ \endgroup\expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doiffontcharelse\doifelsefontchar
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-tex.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-tex.lmt
new file mode 100644
index 00000000000..c960953a700
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-tex.lmt
@@ -0,0 +1,160 @@
+if not modules then modules = { } end modules ['font-mpf'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local formatters = string.formatters
+local sortedhash = table.sortedhash
+
+local addcharacters = fonts.constructors.addcharacters
+local fontdata = fonts.hashes.identifiers
+
+local otf = fonts.handlers.otf
+local otfregister = otf.features.register
+
+----- getshapes = fonts.dropins.getshapes
+
+local register = fonts.collections.register
+local checkenabled = fonts.collections.checkenabled
+local newprivateslot = fonts.helpers.newprivateslot
+
+local currentfont = font.current
+
+-- hm, seems to gobble the first \char
+
+local makesetups = formatters["box:%s:%S"]
+
+local function makeglyphbox(char,spec)
+ token.expand_macro("makeglyphbox",true,spec.setups or tostring(char))
+ local b = tex.takebox("glyphbox")
+ spec.code = {
+ width = b.width,
+ height = b.height,
+ depth = b.depth,
+ objnum = tex.saveboxresource(b,nil,nil,true),
+ }
+end
+
+local function setboxglyphs(category,fontid,unicode,specification)
+ local box = specification.code
+ if unicode and box then
+ local tfmdata = fontdata[fontid]
+ local characters = tfmdata.characters
+ local newdata = {
+ width = box.width or 0,
+ height = box.height or 0,
+ depth = box.depth or 0,
+ unicode = unicode,
+ }
+ -- pass dimensions to lua
+ characters[unicode] = newdata
+ -- this also adapts newdata (add commands)
+ fonts.dropins.swapone("box",tfmdata,specification,unicode)
+ -- pass dimensions to tex
+ addcharacters(fontid, { characters = { [unicode] = newdata } })
+ return fontid, unicode
+ else
+ logs.report("box glyph", "invalid glyph box for %C",unicode)
+ end
+end
+
+local function setboxglyph(specification)
+ if specification then
+ local name = specification.name
+ local unicode = specification.unicode
+ local font = currentfont()
+ if not unicode and name then
+ unicode = newprivateslot(name)
+ specification.unicode = unicode
+ end
+ if unicode then
+ if not specification.setups then
+ specification.setups = name
+ end
+ -- we can actually delay font if needed
+ register(font,unicode,function(font,private)
+ makeglyphbox(unicode,specification)
+ return setboxglyphs(category,font,unicode,specification)
+ end)
+ checkenabled()
+ end
+ end
+end
+
+local boxes = table.setmetatableindex("table")
+
+function fonts.helpers.registerglyphbox(specification)
+ local category = specification.category
+ local whatever = specification.unicode or specification.name
+ if category and whatever then
+ boxes[category][whatever] = { action = makeglyphbox } -- always
+ end
+end
+
+local function initializebox(tfmdata,kind,value)
+ local boxes = boxes[value]
+ if value then
+ local font = tfmdata.properties.id
+ -- just preregister the list
+ for char, spec in sortedhash(boxes) do
+ spec.setups = makesetups(value,char)
+ if type(char) == "string" then
+ char = newprivateslot(name)
+ end
+ -- check if spec.code
+ register(font,char,function(font,char)
+ local action = spec.action
+ if type(action) == "function" then
+ action(char,spec)
+ end
+ return setboxglyphs(value,font,char,spec)
+ end)
+ end
+ checkenabled()
+ end
+end
+
+fonts.helpers.setboxglyphs = setboxglyphs
+fonts.helpers.setboxglyph = setboxglyph
+
+interfaces.implement {
+ name = "registerboxglyph", -- combine with next one
+ public = true,
+ protected = true,
+ actions = fonts.helpers.registerglyphbox,
+ arguments = { {
+ { "category" },
+ { "unicode", "integer" },
+ { "name" },
+ } },
+}
+
+interfaces.implement {
+ name = "setboxglyph",
+ public = true,
+ protected = true,
+ actions = setboxglyph,
+ arguments = { {
+ { "category" },
+ { "unicode", "integer" },
+ { "name" },
+ { "*" }
+ } },
+}
+
+fonts.handlers.otf.features.register {
+ name = "box",
+ description = "box glyphs",
+ manipulators = {
+ base = initializebox,
+ node = initializebox,
+ }
+}
+
+-- fonts.helpers.registerboxglyph { category = "demo", unicode = 103 }
+-- fonts.helpers.registerboxglyph { category = "demo", unicode = 104 }
+-- fonts.helpers.registerboxglyph { category = "demo", unicode = 105 }
+-- fonts.helpers.registerboxglyph { category = "demo", unicode = 106 }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-tex.mkxl b/Master/texmf-dist/tex/context/base/mkxl/font-tex.mkxl
new file mode 100644
index 00000000000..ae936be3190
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-tex.mkxl
@@ -0,0 +1,121 @@
+%D \module
+%D [ file=font-tex,
+%D version=2021.23.01,
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=\TEX\ Glyphs,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / TeX Glyphs}
+
+\registerctxluafile{font-tex}{autosuffix}
+
+%D This mechanism turns boxes into glyphs. Of course this assumes that the
+%D backend code supports it. It's an experiment and we can do similar things
+%D with \METAPOST. The interface is not frozen and might change and evolve.
+
+%D \starttyping
+%D \starttext
+%D
+%D \startsetups box:demo:103
+%D \externalfigure[t:/sources/cow-brown.pdf][height=12pt]
+%D \stopsetups
+%D
+%D \startsetups box:demo:104
+%D \externalfigure[t:/sources/cow-black.pdf][height=10pt]
+%D \stopsetups
+%D
+%D \startsetups box:demo:105
+%D \externalfigure[t:/sources/mill.png][height=12pt]
+%D \stopsetups
+%D
+%D \startsetups box:demo:106
+%D \externalfigure[t:/sources/hacker.jpg][height=12pt]
+%D \stopsetups
+%D
+%D \registerboxglyph category {demo} unicode 103 \relax % rather low level for now
+%D \registerboxglyph category {demo} unicode 104 \relax % rather low level for now
+%D \registerboxglyph category {demo} unicode 105 \relax % rather low level for now
+%D \registerboxglyph category {demo} unicode 106 \relax % rather low level for now
+%D
+%D \definefontfeature[whatever][box=demo]
+%D
+%D \definedfont[Serif*whatever]
+%D
+%D % \enabletrackers[fonts.collecting]
+%D
+%D \startTEXpage%[offset=0pt]
+%D %\hbox{g}%
+%D \hbox{\char103}%
+%D \hbox{\char104}%
+%D \stopTEXpage
+%D
+%D \startsetups box:demo:whatever
+%D \startMPcode
+%D picture p ; p := image (draw figure "t:/sources/hacker.jpg" ysized 10pt);
+%D fill boundingbox p enlarged .5pt randomized 2pt withcolor "darkgray" ;
+%D clip p to boundingbox p enlarged -1pt randomized 2pt ;
+%D draw p ;
+%D \stopMPcode
+%D \stopsetups
+%D
+%D % in current font!
+%D
+%D \iffontchar\font\privatecharactercode{demo:whatever}\else
+%D \setboxglyph {
+%D category {demo}
+%D name {demo:whatever}
+%D setups {box:demo:whatever}
+%D }%
+%D \fi
+%D
+%D \startTEXpage[offset=10pt]
+%D \char\privatecharactercode{demo:whatever}%
+%D \stopTEXpage
+%D
+%D \startTEXpage%[offset=0pt]
+%D \ruledhbox{\char103}
+%D \ruledhbox{\char104}
+%D \ruledhbox{\char105}
+%D \ruledhbox{\char106}
+%D \stopTEXpage
+%D
+%D \dorecurse{1000}{
+%D \char 103\relax \space
+%D \char 104\relax \space
+%D \char 105\relax \space
+%D \char 106\relax \space
+%D }
+%D
+%D \page
+%D
+%D \setupalign[verytolerant,flushleft]
+%D
+%D \dorecurse{100}{
+%D #1:
+%D \glyph yoffset -2pt `i\relax
+%D \glyph yoffset -3pt `j\relax\space
+%D }
+%D \stoptext
+%D \stoptyping
+
+\newbox\glyphbox
+
+% somehow makes the first \char disappear
+%
+% \permanent\protected\def\makeglyphbox#1%
+% {\setbox\glyphbox\hbox{\directsetup{#1}}}
+%
+% so we group:
+
+\permanent\protected\def\makeglyphbox#1%
+ {\begingroup
+ \global\setbox\glyphbox\hbox{\directsetup{#1}}%
+ \finalizeobjectbox\glyphbox
+ % \writestatus{glyphbox}{#1 => (\the\wd\glyphbox,\the\ht\glyphbox,\the\dp\glyphbox)}%
+ \endgroup}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-tra.mkxl b/Master/texmf-dist/tex/context/base/mkxl/font-tra.mkxl
new file mode 100644
index 00000000000..625e2fe0b87
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-tra.mkxl
@@ -0,0 +1,118 @@
+%D \module
+%D [ file=font-tra,
+%D version=2009.01.02, % or so
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Tracing,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\writestatus{loading}{ConTeXt Font Macros / Tracing}
+
+%D just use fontid
+
+%D \macros
+%D {showbodyfont}
+%D
+%D One can call for a rather simple overview of a bodyfont and the relations between
+%D its alternative fonts.
+%D
+%D \showsetup{showbodyfont}
+%D
+%D The current bodyfont (here we omitted the argument) looks like:
+%D
+%D \showbodyfont
+%D
+%D The implementation is rather straightforward in using \type {\halign}.
+
+\fetchmodulecommand \showbodyfont \f!font_run
+
+%D \macros
+%D {showfontstrip, showminimalbaseline}
+%D
+%D The next command can come in handy when combining different fonts into a
+%D collection (typeface) and determining optimal baseline distances.
+%D
+%D \showfontstrip \blank \showminimalbaseline
+
+\fetchmodulecommand \showfontstrip \f!font_run
+\fetchmodulecommand \showminimalbaseline \f!font_run
+
+%D \macros
+%D {showkerning}
+%D
+%D A goody is:
+%D
+%D \showkerning{Can you guess what kerning is?}
+
+\fetchmodulecommand \showkerning \f!font_run
+
+%D \macros
+%D {showbodyfontenvironment,showfont,showfontstyle,showligatures}
+%D
+%D The current bodyfontenvironment is:
+%D
+%D \showbodyfontenvironment
+%D
+%D This overview is generated using:
+%D
+%D \showsetup{showbodyfontenvironment}
+
+\fetchmodulecommand \showbodyfontenvironment \f!font_run
+
+%D The following command generates a fontmap:
+%D
+%D \startbuffer
+%D \showfont[SansBold at 12pt]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D \getbuffer
+
+\fetchmodulecommand \showfont \f!font_run
+\fetchmodulecommand \showfontstyle \f!font_run
+\fetchmodulecommand \showligature \f!font_run
+\fetchmodulecommand \showligatures \f!font_run
+\fetchmodulecommand \showcharratio \f!font_run
+\fetchmodulecommand \showfontparameters \f!font_run
+
+\permanent\protected\def\showchardata#1{\ctxcommand{showchardata("#1")}} % todo: direct implementor
+\permanent\protected\def\showfontdata {\ctxcommand{showfontparameters()}} % todo: direct implementor
+
+%D \macros
+%D {doiffontpresentelse}
+%D
+%D \starttyping
+%D \doiffontpresentelse{texnansi-lmr10}{YES}{NO}
+%D \doiffontpresentelse{adam-lindsay-modern-serif}{YES}{NO}
+%D \stoptyping
+
+\permanent\protected\def\doifelsefontpresent#1{\clf_doifelsefontpresent{#1}}
+
+\aliased\let\doiffontpresentelse\doifelsefontpresent
+
+%D The otf tracer code is now moved. If the individual commands are needed
+%D one can just load the module.
+
+\fetchmodulecommand \showotfcomposition \f!font_run
+\fetchmodulecommand \showotfcompositionlist \f!font_run
+\fetchmodulecommand \startotfsample \f!font_run
+\fetchmodulecommand \startotfcompositionlist \f!font_run
+
+% \permanent\protected\def\savefontdata[#1]% not yet in i-*.xml
+% {\begingroup
+% \getdummyparameters[#1]%
+% \clf_savefont {
+% filename {\dummyparameter\c!file}
+% fontname {\dummyparameter\c!name}
+% method {\dummyparameter\c!method}
+% }%
+% \endgroup}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-uni.mkxl b/Master/texmf-dist/tex/context/base/mkxl/font-uni.mkxl
new file mode 100644
index 00000000000..390f17468ff
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-uni.mkxl
@@ -0,0 +1,27 @@
+%D \module
+%D [ file=font-uni,
+%D version=2008.11.03, % 1999.10.10,
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=\UNICODE,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Unicode}
+
+%D In \MKIV\ we only provide the \type {\uchar} macro and implement it as just an
+%D \UTF\ converter. We expand it so best not use not use it for active characters.
+%D In practice this command is probably never used anyway but we keep if for old
+%D styles.
+
+\unprotect
+
+\permanent\def\uchar#1#2{\clf_uchar\numexpr#1\relax\numexpr#2\relax}
+
+\aliased\let\uc\uchar
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-unk.mkxl b/Master/texmf-dist/tex/context/base/mkxl/font-unk.mkxl
new file mode 100644
index 00000000000..986a5c9bfa2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-unk.mkxl
@@ -0,0 +1,150 @@
+%D \module
+%D [ file=font-unk,
+%D version=1998.09.10,
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Unknown Defaults,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module is rather important, because it enables us to define and call for not
+%D yet defined fonts in a way completely independant of real font names. First we
+%D map some meaningful names onto unknown filenames.
+
+\unprotect
+
+\definefontsynonym [Serif] [unknown]
+\definefontsynonym [SerifBold] [unknown]
+\definefontsynonym [SerifItalic] [unknown]
+\definefontsynonym [SerifSlanted] [unknown]
+\definefontsynonym [SerifBoldItalic] [unknown]
+\definefontsynonym [SerifBoldSlanted] [unknown]
+\definefontsynonym [SerifCaps] [unknown]
+
+\definefontsynonym [Sans] [unknown]
+\definefontsynonym [SansBold] [unknown]
+\definefontsynonym [SansItalic] [unknown]
+\definefontsynonym [SansSlanted] [unknown]
+\definefontsynonym [SansBoldItalic] [unknown]
+\definefontsynonym [SansBoldSlanted] [unknown]
+\definefontsynonym [SansCaps] [unknown]
+
+\definefontsynonym [Mono] [unknown]
+\definefontsynonym [MonoBold] [unknown]
+\definefontsynonym [MonoItalic] [unknown]
+\definefontsynonym [MonoSlanted] [unknown]
+\definefontsynonym [MonoBoldItalic] [unknown]
+\definefontsynonym [MonoBoldSlanted] [unknown]
+\definefontsynonym [MonoCaps] [unknown]
+
+\definefontsynonym [MathRoman] [unknown]
+\definefontsynonym [MathRomanL2R] [MathRoman]
+\definefontsynonym [MathRomanR2L] [MathRoman]
+\definefontsynonym [MathRomanBold] [MathRoman]
+\definefontsynonym [MathRomanBoldL2R] [MathRomanBold]
+\definefontsynonym [MathRomanBoldR2L] [MathRomanBold]
+
+\definefontsynonym [Handwriting] [unknown]
+\definefontsynonym [Calligraphic] [unknown]
+
+%D This permit us to define (use) fonts that refer to the default style (so, Bold
+%D may expand to SansBold or SerifBold, depending on the default style in the
+%D typeface). The \LUA\ call is used to set the current alternative in a
+%D non|-|interfering way. This make sure that the CurrentFont synonym (in font-sym)
+%D is working as expected (e.g.\ in MixedCaps). Yes, this is complicates stuff.
+
+\definefontsynonym[\s!Normal] [\noexpand\clf_tf\noexpand\v_font_string_d]
+\definefontsynonym[\s!Bold] [\noexpand\clf_bf\noexpand\v_font_string_d\noexpand\s!Bold]
+\definefontsynonym[\s!Italic] [\noexpand\clf_it\noexpand\v_font_string_d\noexpand\s!Italic]
+\definefontsynonym[\s!Slanted] [\noexpand\clf_sl\noexpand\v_font_string_d\noexpand\s!Slanted]
+\definefontsynonym[\s!BoldItalic] [\noexpand\clf_bi\noexpand\v_font_string_d\noexpand\s!BoldItalic]
+\definefontsynonym[\s!BoldSlanted][\noexpand\clf_bs\noexpand\v_font_string_d\noexpand\s!BoldSlanted]
+\definefontsynonym[\s!Caps] [\noexpand\clf_tf\noexpand\v_font_string_d\noexpand\s!Caps]
+
+%D Also handy:
+
+\definefontsynonym [Regular] [Serif]
+\definefontsynonym [RegularBold] [SerifBold]
+\definefontsynonym [RegularItalic] [SerifItalic]
+\definefontsynonym [RegularSlanted] [SerifSlanted]
+\definefontsynonym [RegularBoldItalic] [SerifBoldItalic]
+\definefontsynonym [RegularBoldSlanted] [SerifBoldSlanted]
+\definefontsynonym [RegularCaps] [SerifCaps]
+
+\definefontsynonym [Support] [Sans]
+\definefontsynonym [SupportBold] [SansBold]
+\definefontsynonym [SupportItalic] [SansItalic]
+\definefontsynonym [SupportSlanted] [SansSlanted]
+\definefontsynonym [SupportBoldItalic] [SansBoldItalic]
+\definefontsynonym [SupportBoldSlanted] [SansBoldSlanted]
+\definefontsynonym [SupportCaps] [SansCaps]
+
+%D Well, not that good an idea:
+
+\definefontsynonym [Roman] [Serif]
+\definefontsynonym [RomanBold] [SerifBold]
+\definefontsynonym [RomanItalic] [SerifItalic]
+\definefontsynonym [RomanSlanted] [SerifSlanted]
+\definefontsynonym [RomanBoldItalic] [SerifBoldItalic]
+\definefontsynonym [RomanBoldSlanted] [SerifBoldSlanted]
+\definefontsynonym [RomanCaps] [SerifCaps]
+
+\definefontsynonym [Type] [Mono]
+\definefontsynonym [TypeBold] [MonoBold]
+\definefontsynonym [TypeItalic] [MonoItalic]
+\definefontsynonym [TypeSlanted] [MonoSlanted]
+\definefontsynonym [TypeBoldItalic] [MonoBoldItalic]
+\definefontsynonym [TypeBoldSlanted] [MonoBoldSlanted]
+\definefontsynonym [TypeCaps] [MonoCaps]
+
+%D Next we define roman, sans and monospaced font sets.
+
+\definebodyfont [default] [rm]
+ [\s!tf=Serif sa 1,
+ \s!bf=SerifBold sa 1,
+ \s!it=SerifItalic sa 1,
+ \s!sl=SerifSlanted sa 1,
+ \s!bi=SerifBoldItalic sa 1,
+ \s!bs=SerifBoldSlanted sa 1,
+ \s!sc=SerifCaps sa 1]
+
+\definebodyfont [default] [ss]
+ [\s!tf=Sans sa 1,
+ \s!bf=SansBold sa 1,
+ \s!it=SansItalic sa 1,
+ \s!sl=SansSlanted sa 1,
+ \s!bi=SansBoldItalic sa 1,
+ \s!bs=SansBoldSlanted sa 1,
+ \s!sc=SansCaps sa 1]
+
+\definebodyfont [default] [tt]
+ [\s!tf=Mono sa 1,
+ \s!bf=MonoBold sa 1,
+ \s!it=MonoItalic sa 1,
+ \s!sl=MonoSlanted sa 1,
+ \s!bi=MonoBoldItalic sa 1,
+ \s!bs=MonoBoldSlanted sa 1,
+ \s!sc=MonoCaps sa 1]
+
+\definebodyfont [default] [mm]
+ [\s!mr =MathRoman mo 1,
+ \s!mrlr=MathRomanL2R mo 1,
+ \s!mrrl=MathRomanR2L mo 1,
+ \s!mb =MathRomanBold mo 1,
+ \s!mblr=MathRomanBoldL2R mo 1,
+ \s!mbrl=MathRomanBoldR2L mo 1]
+
+\definebodyfont [default] [hw]
+ [\s!tf=Handwriting sa 1]
+
+\definebodyfont [default] [cg]
+ [\s!tf=Calligraphy sa 1]
+
+%D These definitions come into action as soon as names are mapped onto real file
+%D names (or names that themselves are mapped).
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-var.mklx b/Master/texmf-dist/tex/context/base/mkxl/font-var.mklx
new file mode 100644
index 00000000000..421521f50f5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-var.mklx
@@ -0,0 +1,57 @@
+%D \module
+%D [ file=font-var,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Common Variables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Macros / Common Variables}
+
+\unprotect
+
+% some more will move here
+
+%D \macros
+%D {fontstyle,fontalternative,fontsize,fontbody}
+%D
+%D Within a bodyfont, fonts can come in different sizes. For instance \type {\tf} is
+%D accompanied by \type {\tfa}, \type {\tfb} etc. The first two characters denote
+%D the alternative, while the third character in these sequences represents the
+%D size. The actual size is saved in a macro. The styles, being roman (\type {\rm}),
+%D sans serif (\type {\ss}) etc. are also available.
+
+% fontclass % modern dejavu
+% fontbody % ... 10pt 11pt 12pt ...
+% fontstyle % rm ss tt mm hw cg ...
+% fontalternative % tf bf sl it bs bi sc ...
+% fontsize % a b c d ...
+% fontface % 0=normal 1=text 2=script 3=scriptscript 4=x 5=xx (math are temporary)
+
+\mutable\def\normalizedbodyfontsize{12pt}
+
+\immutable\def\defaultfontbody {\normalizedbodyfontsize}
+\immutable\let\defaultfontstyle \s!rm
+\immutable\let\defaultfontalternative\s!tf
+\immutable\let\defaultfontsize \empty
+\immutable\let\defaultfontface \!!zerocount
+
+\mutable\let\globalfontclass\empty
+\mutable\let\fontclass \empty
+\mutable\let\fontbody \defaultfontbody
+\mutable\let\fontstyle \defaultfontstyle
+\mutable\let\fontalternative\defaultfontalternative
+\mutable\let\fontsize \defaultfontsize
+\mutable\let\fontface \!!zerocount
+
+\installmacrostack\fontstyle
+
+% we can use an indirect mapping for fontclasses (map string onto numbers) and indeed this
+% is somewhat more efficient but also makes the code messy ... maybe some day ...
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-vfc.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-vfc.lmt
new file mode 100644
index 00000000000..9330bdea0b2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-vfc.lmt
@@ -0,0 +1,181 @@
+if not modules then modules = { } end modules ['font-vfc'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv and hand-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local select, type = select, type
+local insert = table.insert
+
+local fonts = fonts
+local helpers = fonts.helpers
+
+local setmetatableindex = table.setmetatableindex
+----- makeweak = table.makeweak
+
+-- Helpers dealing with virtual fonts: beware, these are final values so
+-- don't change the content of tables fetched from here!
+
+local push = { "push" }
+local pop = { "pop" }
+local dummy = { "comment" }
+
+function helpers.prependcommands(commands,...)
+ insert(commands,1,push)
+ for i=select("#",...),1,-1 do
+ local s = (select(i,...))
+ if s then
+ insert(commands,1,s)
+ end
+ end
+ insert(commands,pop)
+ return commands
+end
+
+function helpers.appendcommands(commands,...)
+ insert(commands,1,push)
+ insert(commands,pop)
+ for i=1,select("#",...) do
+ local s = (select(i,...))
+ if s then
+ insert(commands,s)
+ end
+ end
+ return commands
+end
+
+function helpers.prependcommandtable(commands,t)
+ insert(commands,1,push)
+ for i=#t,1,-1 do
+ local s = t[i]
+ if s then
+ insert(commands,1,s)
+ end
+ end
+ insert(commands,pop)
+ return commands
+end
+
+function helpers.appendcommandtable(commands,t)
+ insert(commands,1,push)
+ insert(commands,pop)
+ for i=1,#t do
+ local s = t[i]
+ if s then
+ insert(commands,s)
+ end
+ end
+ return commands
+end
+
+helpers.commands = utilities.storage.allocate {
+ char = setmetatableindex(function(t,k) local v = { "slot", 0, k } t[k] = v return v end),
+ right = setmetatableindex(function(t,k) local v = { "right", k } t[k] = v return v end),
+ left = setmetatableindex(function(t,k) local v = { "left", k } t[k] = v return v end),
+ down = setmetatableindex(function(t,k) local v = { "down", k } t[k] = v return v end),
+ up = setmetatableindex(function(t,k) local v = { "up", k } t[k] = v return v end),
+ push = push,
+ pop = pop,
+ dummy = dummy,
+}
+
+helpers.vfinjectors = {
+ -- backend specific: startcolor, stopcolor etc
+}
+
+-- maybe round()
+
+local defaultline = 16384
+
+helpers.vfspecials = {
+
+ backgrounds = setmetatableindex(function(t,h)
+ local v = setmetatableindex(function(t,d)
+ local v = setmetatableindex(function(t,w)
+ local v = { "frame", w, h, d, defaultline, true, true }
+ t[w] = v
+ return v
+ end)
+ t[d] = v
+ return v
+ end)
+ t[h] = v
+ return v
+ end),
+
+ outlines = setmetatableindex(function(t,h)
+ local v = setmetatableindex(function(t,d)
+ local v = setmetatableindex(function(t,w)
+ local v = { "frame", w, h, d, defaultline, false, true }
+ t[w] = v
+ return v
+ end)
+ t[d] = v
+ return v
+ end)
+ t[h] = v
+ return v
+ end),
+
+}
+
+-- In the past we only copied when we had something that got scaled but the problem
+-- is that we then run into issues when we extend a commands in the parent. This
+-- needs checking. When we go to glyph scaling, this can go away.
+--
+-- The alternative is to work with unscaled values and always do scaling at the
+-- TeX end. So, then we need accessors instead of tables and we also need to check
+-- all the context code: where do we access values?
+--
+-- On the other hand, in glyph scale mode we hardly do any scaling so we seldom
+-- call the next one.
+--
+-- What if we use named fields: then we can scale by field name.
+
+local scaled = {
+ right = true,
+ down = true,
+ left = true,
+ right = true,
+ offset = true,
+ rule = true,
+ char = false,
+ font = false,
+ slot = false,
+ use = false,
+ push = false,
+ pop = false,
+ lua = false,
+ -- obsolete
+ node = false,
+ -- additional ones are never scaled (color etc)
+}
+
+function helpers.scalecommands(list,hdelta,vdelta)
+ local n = #list
+ for i=1,n do
+ local key = list[i][1]
+ if scaled[list[i][1]] then
+ local result = { }
+ for i=1,n do
+ local cmd = list[i]
+ local key = ivc[1]
+ if key == "right" or key == "left" then
+ result[i] = { key, cmd[2]*hdelta }
+ elseif key == "down" or key == "up" then
+ result[i] = { key, cmd[2]*vdelta }
+ elseif key == "offset" or key == "rule" then
+ result[i] = { key, cmd[2]*hdelta, cmd[3]*vdelta }
+ -- elseif key == "frame" then
+ -- result[i] = cmd -- already scaled, for now
+ else
+ result[i] = cmd -- shared since in cache and untouched
+ end
+ end
+ return result
+ end
+ end
+ return list
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/font-vir.lmt b/Master/texmf-dist/tex/context/base/mkxl/font-vir.lmt
new file mode 100644
index 00000000000..f60639d6ad8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/font-vir.lmt
@@ -0,0 +1,159 @@
+if not modules then modules = { } end modules ['font-vir'] = {
+ version = 1.001,
+ comment = "companion to font-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is actually very experimental code but it has been so since we began with
+-- \LUATEX\ so \unknown. We keep it around because it's not that much code and
+-- because we have some demo's (in the test suite) that use it.
+
+local next, setmetatable, getmetatable = next, setmetatable, getmetatable
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+local fastcopy = table.fastcopy
+
+local fonts = fonts
+local constructors = fonts.constructors
+local vf = constructors.handlers.vf
+vf.version = 1.000 -- same as tfm
+
+local definers = fonts.definers
+local methods = definers.methods
+
+local variants = allocate()
+local combinations = { }
+local combiner = { }
+local whatever = allocate()
+local helpers = allocate()
+local predefined = fonts.helpers.commands
+
+methods.variants = variants -- todo .. wrong namespace
+vf.combinations = combinations
+vf.combiner = combiner
+vf.whatever = whatever
+vf.helpers = helpers
+vf.predefined = predefined
+
+setmetatableindex(whatever, function(t,k) local v = { } t[k] = v return v end)
+
+local function checkparameters(g,f)
+ if f and g and not g.parameters and #g.fonts > 0 then
+ local p = { }
+ for k,v in next, f.parameters do
+ p[k] = v
+ end
+ g.parameters = p
+ setmetatable(p, getmetatable(f.parameters))
+ end
+end
+
+function methods.install(tag, rules)
+ vf.combinations[tag] = rules
+ variants[tag] = function(specification)
+ return vf.combine(specification,tag)
+ end
+end
+
+local function combine_load(g,name)
+ return constructors.readanddefine(name or g.specification.name,g.specification.size)
+end
+
+local function combine_assign(g, name, from, to, start, force)
+ local f, id = combine_load(g,name)
+ if f and id then
+ -- optimize for whole range, then just g = f
+ if not from then from, to = 0, 0xFF00 end
+ if not to then to = from end
+ if not start then start = from end
+ local fc = f.characters
+ local gc = g.characters
+ local fd = f.descriptions
+ local gd = g.descriptions
+ local hn = #g.fonts+1
+ g.fonts[hn] = { id = id } -- no need to be sparse
+ for i=from,to do
+ if fc[i] and (force or not gc[i]) then
+ gc[i] = fastcopy(fc[i],true) -- can be optimized
+ gc[i].commands = { { "slot", hn, start } }
+ gd[i] = fd[i]
+ end
+ start = start + 1
+ end
+ checkparameters(g,f)
+ end
+end
+
+local function combine_process(g,list)
+ if list then
+ for _,v in next, list do
+ (combiner.commands[v[1]] or nop)(g,v)
+ end
+ end
+end
+
+local function combine_names(g,name,force)
+ local f, id = constructors.readanddefine(name,g.specification.size)
+ if f and id then
+ local fc = f.characters
+ local gc = g.characters
+ local fd = f.descriptions
+ local gd = g.descriptions
+ g.fonts[#g.fonts+1] = { id = id } -- no need to be sparse
+ local hn = #g.fonts
+ for k, v in next, fc do
+ if force or not gc[k] then
+ gc[k] = fastcopy(v,true)
+ gc[k].commands = { { "slot", hn, k } }
+ gd[i] = fd[i]
+ end
+ end
+ checkparameters(g,f)
+ end
+end
+
+local combine_feature = function(g,v)
+ local key = v[2]
+ local value = v[3]
+ if key then
+ if value == nil then
+ value = true
+ end
+ local specification = g.specification
+ if specification then
+ local normalfeatures = specification.features.normal
+ if normalfeatures then
+ normalfeatures[key] = value -- otf?
+ end
+ end
+ end
+end
+
+combiner.commands = allocate {
+ ["initialize"] = function(g,v) combine_assign (g,g.properties.name) end,
+ ["include-method"] = function(g,v) combine_process (g,combinations[v[2]]) end, -- name
+ -- ["copy-parameters"] = function(g,v) combine_parameters(g,v[2]) end, -- name
+ ["copy-range"] = function(g,v) combine_assign (g,v[2],v[3],v[4],v[5],true) end, -- name, from-start, from-end, to-start
+ ["copy-char"] = function(g,v) combine_assign (g,v[2],v[3],v[3],v[4],true) end, -- name, from, to
+ ["fallback-range"] = function(g,v) combine_assign (g,v[2],v[3],v[4],v[5],false) end, -- name, from-start, from-end, to-start
+ ["fallback-char"] = function(g,v) combine_assign (g,v[2],v[3],v[3],v[4],false) end, -- name, from, to
+ ["copy-names"] = function(g,v) combine_names (g,v[2],true) end,
+ ["fallback-names"] = function(g,v) combine_names (g,v[2],false) end,
+ ["feature"] = combine_feature,
+}
+
+function vf.combine(specification,tag)
+ local g = {
+ name = specification.name,
+ properties = { },
+ fonts = { },
+ characters = { },
+ descriptions = { },
+ specification = fastcopy(specification),
+ }
+ combine_process(g,combinations[tag])
+ return g
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/good-mth.lmt b/Master/texmf-dist/tex/context/base/mkxl/good-mth.lmt
new file mode 100644
index 00000000000..87b6787df6a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/good-mth.lmt
@@ -0,0 +1,464 @@
+if not modules then modules = { } end modules ['good-mth'] = {
+ version = 1.000,
+ comment = "companion to font-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type, next, tonumber, unpack = type, next, tonumber, unpack
+local ceil = math.ceil
+local match = string.match
+
+local fonts = fonts
+
+local trace_goodies = false trackers.register("fonts.goodies", function(v) trace_goodies = v end)
+local report_goodies = logs.reporter("fonts","goodies")
+
+local registerotffeature = fonts.handlers.otf.features.register
+
+local fontgoodies = fonts.goodies or { }
+
+local fontcharacters = fonts.hashes.characters
+
+local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
+
+local report_math = logs.reporter("mathematics","initializing")
+
+local nuts = nodes.nuts
+
+local setlink = nuts.setlink
+
+local nodepool = nuts.pool
+
+local new_kern = nodepool.kern
+local new_glyph = nodepool.glyph
+local new_hlist = nodepool.hlist
+local new_vlist = nodepool.vlist
+
+local insert_node_after = nuts.insert_after
+
+local helpers = fonts.helpers
+local upcommand = helpers.commands.up
+local rightcommand = helpers.commands.right
+local charcommand = helpers.commands.char
+local prependcommands = helpers.prependcommands
+
+-- experiment, we have to load the definitions immediately as they precede
+-- the definition so they need to be initialized in the typescript
+
+local function withscriptcode(tfmdata,unicode,data,action)
+ if type(unicode) == "string" then
+ local p, u = match(unicode,"^(.-):(.-)$")
+ if u then
+ u = tonumber(u)
+ if u then
+ local slots = fonts.helpers.mathscriptslots(tfmdata,u)
+ if slots then
+ if p == "*" then
+ action(u,data)
+ for i=1,#slots do
+ action(slots[i],data)
+ end
+ else
+ p = tonumber(p)
+ if p then
+ action(slots[p],data)
+ end
+ end
+ end
+ end
+ end
+ else
+ action(unicode,data)
+ end
+end
+
+local function finalize(tfmdata,feature,value)
+-- if tfmdata.mathparameters then -- funny, cambria text has this
+ local goodies = tfmdata.goodies
+ if goodies then
+ local virtualized = mathematics.virtualized
+ for i=1,#goodies do
+ local goodie = goodies[i]
+ local mathematics = goodie.mathematics
+ local dimensions = mathematics and mathematics.dimensions
+ if dimensions then
+ if trace_defining then
+ report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size)
+ end
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local parameters = tfmdata.parameters
+ local factor = parameters.factor
+ local hfactor = parameters.hfactor
+ local vfactor = parameters.vfactor
+ --
+ tfmdata.type = "virtual"
+ tfmdata.properties.virtualized = true
+ --
+ local function overloadone(unicode,data)
+ local character = characters[unicode]
+ if not character then
+ local c = virtualized[unicode]
+ if c then
+ character = characters[c]
+ end
+ end
+ if character then
+ local width = data.width
+ local height = data.height
+ local depth = data.depth
+ if trace_defining and (width or height or depth) then
+ report_math("overloading dimensions of %C, width %p, height %p, depth %p",
+ unicode,width or 0,height or 0,depth or 0)
+ end
+ if width then character.width = width * hfactor end
+ if height then character.height = height * vfactor end
+ if depth then character.depth = depth * vfactor end
+ --
+ local xoffset = data.xoffset
+ local yoffset = data.yoffset
+ if xoffset == "llx" then
+ local d = descriptions[unicode]
+ if d then
+ xoffset = - d.boundingbox[1] * hfactor
+ character.width = character.width + xoffset
+ xoffset = rightcommand[xoffset]
+ else
+ xoffset = nil
+ end
+ elseif xoffset and xoffset ~= 0 then
+ xoffset = rightcommand[xoffset * hfactor]
+ else
+ xoffset = nil
+ end
+ if yoffset and yoffset ~= 0 then
+ yoffset = upcommand[yoffset * vfactor]
+ else
+ yoffset = nil
+ end
+ if xoffset or yoffset then
+ local commands = characters.commands
+ if commands then
+ prependcommands(commands,yoffset,xoffset)
+ else
+ local slot = charcommand[unicode]
+ if xoffset and yoffset then
+ character.commands = { xoffset, yoffset, slot }
+ elseif xoffset then
+ character.commands = { xoffset, slot }
+ else
+ character.commands = { yoffset, slot }
+ end
+ end
+ end
+ elseif trace_defining then
+ report_math("no overloading dimensions of %C, not in font",unicode)
+ end
+ end
+ local function overload(dimensions)
+ for unicode, data in next, dimensions do
+ withscriptcode(tfmdata,unicode,data,overloadone)
+ end
+ end
+ if value == nil then
+ value = { "default" }
+ end
+ if value == "all" or value == true then
+ for name, value in next, dimensions do
+ overload(value)
+ end
+ else
+ if type(value) == "string" then
+ value = utilities.parsers.settings_to_array(value)
+ end
+ if type(value) == "table" then
+ for i=1,#value do
+ local d = dimensions[value[i]]
+ if d then
+ overload(d)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+registerotffeature {
+ name = "mathdimensions",
+ description = "manipulate math dimensions",
+ -- default = true,
+ manipulators = {
+ base = finalize,
+ node = finalize,
+ }
+}
+
+local function initialize(goodies)
+ local mathgoodies = goodies.mathematics
+ if mathgoodies then
+ local virtuals = mathgoodies.virtuals
+ local mapfiles = mathgoodies.mapfiles
+ local maplines = mathgoodies.maplines
+ if virtuals then
+ for name, specification in next, virtuals do
+ -- beware, they are all constructed ... we should be more selective
+ mathematics.makefont(name,specification,goodies)
+ end
+ end
+ if mapfiles then
+ for i=1,#mapfiles do
+ fonts.mappings.loadfile(mapfiles[i]) -- todo: backend function
+ end
+ end
+ if maplines then
+ for i=1,#maplines do
+ fonts.mappings.loadline(maplines[i]) -- todo: backend function
+ end
+ end
+ end
+end
+
+fontgoodies.register("mathematics", initialize)
+
+-- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end)
+
+local function initialize(tfmdata)
+-- if enabled and tfmdata.mathparameters then -- funny, cambria text has this
+ if tfmdata.mathparameters then -- funny, cambria text has this
+ local goodies = tfmdata.goodies
+ if goodies then
+ local characters = tfmdata.characters
+ if characters[0x1D44E] then -- 119886
+ -- we have at least an italic a
+ for i=1,#goodies do
+ local mathgoodies = goodies[i].mathematics
+ if mathgoodies then
+ local kerns = mathgoodies.kerns
+ if kerns then
+ local function kernone(unicode,data)
+ local chardata = characters[unicode]
+ if chardata and (not chardata.mathkerns or data.force) then
+ chardata.mathkerns = data
+ end
+ end
+ for unicode, data in next, kerns do
+ withscriptcode(tfmdata,unicode,data,kernone)
+ end
+ return
+ end
+ end
+ end
+ else
+ return -- no proper math font anyway
+ end
+ end
+ end
+end
+
+registerotffeature {
+ name = "mathkerns",
+ description = "math kerns",
+ -- default = true,
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+-- math italics (not really needed)
+--
+-- it would be nice to have a \noitalics\font option
+
+local function initialize(tfmdata)
+ local goodies = tfmdata.goodies
+ if goodies then
+ local shared = tfmdata.shared
+ for i=1,#goodies do
+ local mathgoodies = goodies[i].mathematics
+ if mathgoodies then
+ local mathitalics = mathgoodies.italics
+ if mathitalics then
+ local properties = tfmdata.properties
+ if properties.setitalics then
+ mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics
+ if mathitalics then
+ if trace_goodies then
+ report_goodies("loading mathitalics for font %a",properties.name)
+ end
+ local corrections = mathitalics.corrections
+ local defaultfactor = mathitalics.defaultfactor
+ -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change)
+ if corrections then
+ fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy)
+ -- better make a helper so that we have less code being defined
+ local properties = tfmdata.properties
+ local parameters = tfmdata.parameters
+ local characters = tfmdata.characters
+ properties.mathitalic_defaultfactor = defaultfactor
+ properties.mathitalic_defaultvalue = defaultfactor * parameters.quad
+ if trace_goodies then
+ report_goodies("assigning mathitalics for font %a",properties.name)
+ end
+ local quad = parameters.quad
+ local hfactor = parameters.hfactor
+ for k, v in next, corrections do
+ local c = characters[k]
+ if c then
+ if v > -1 and v < 1 then
+ c.italic = v * quad
+ else
+ c.italic = v * hfactor
+ end
+ else
+ report_goodies("invalid mathitalics entry %U for font %a",k,properties.name)
+ end
+ end
+ end)
+ end
+ return -- maybe not as these can accumulate
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+registerotffeature {
+ name = "mathitalics",
+ description = "additional math italic corrections",
+ -- default = true,
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+-- fontgoodies.register("mathitalics", initialize)
+
+local function mathradicalaction(n,h,v,font,mchar,echar)
+ local characters = fontcharacters[font]
+ local mchardata = characters[mchar]
+ local echardata = characters[echar]
+ local ewidth = echardata.width
+ local mwidth = mchardata.width
+ local delta = h - ewidth
+ local glyph = new_glyph(font,echar)
+ local head = glyph
+ if delta > 0 then
+ local count = ceil(delta/mwidth)
+ local kern = (delta - count * mwidth) / count
+ for i=1,count do
+ local k = new_kern(kern)
+ local g = new_glyph(font,mchar)
+ setlink(k,head)
+ setlink(g,k)
+ head = g
+ end
+ end
+ local height = mchardata.height
+ local list = new_hlist(head)
+ local kern = new_kern(height-v)
+ list = setlink(kern,list)
+ local list = new_vlist(kern)
+ insert_node_after(n,n,list)
+end
+
+local function mathhruleaction(n,h,v,font,bchar,mchar,echar)
+ local characters = fontcharacters[font]
+ local bchardata = characters[bchar]
+ local mchardata = characters[mchar]
+ local echardata = characters[echar]
+ local bwidth = bchardata.width
+ local mwidth = mchardata.width
+ local ewidth = echardata.width
+ local delta = h - ewidth - bwidth
+ local glyph = new_glyph(font,echar)
+ local head = glyph
+ if delta > 0 then
+ local count = ceil(delta/mwidth)
+ local kern = (delta - count * mwidth) / (count+1)
+ for i=1,count do
+ local k = new_kern(kern)
+ local g = new_glyph(font,mchar)
+ setlink(k,head)
+ setlink(g,k)
+ head = g
+ end
+ local k = new_kern(kern)
+ setlink(k,head)
+ head = k
+ end
+ local g = new_glyph(font,bchar)
+ setlink(g,head)
+ head = g
+ local height = mchardata.height
+ local list = new_hlist(head)
+ local kern = new_kern(height-v)
+ list = setlink(kern,list)
+ local list = new_vlist(kern)
+ insert_node_after(n,n,list)
+end
+
+local function initialize(tfmdata)
+ local goodies = tfmdata.goodies
+ if goodies then
+ local resources = tfmdata.resources
+ local ruledata = { }
+ for i=1,#goodies do
+ local mathematics = goodies[i].mathematics
+ if mathematics then
+ local rules = mathematics.rules
+ if rules then
+ for tag, name in next, rules do
+ ruledata[tag] = name
+ end
+ end
+ end
+ end
+ if next(ruledata) then
+ local characters = tfmdata.characters
+ local unicodes = resources.unicodes
+ if characters and unicodes then
+ local mathruleactions = resources.mathruleactions
+ if not mathruleactions then
+ mathruleactions = { }
+ resources.mathruleactions = mathruleactions
+ end
+ --
+ local mchar = unicodes[ruledata["radical.extender"] or false]
+ local echar = unicodes[ruledata["radical.end"] or false]
+ if mchar and echar then
+ mathruleactions.radicalaction = function(n,h,v,font)
+ mathradicalaction(n,h,v,font,mchar,echar)
+ end
+ end
+ --
+ local bchar = unicodes[ruledata["hrule.begin"] or false]
+ local mchar = unicodes[ruledata["hrule.extender"] or false]
+ local echar = unicodes[ruledata["hrule.end"] or false]
+ if bchar and mchar and echar then
+ mathruleactions.hruleaction = function(n,h,v,font)
+ mathhruleaction(n,h,v,font,bchar,mchar,echar)
+ end
+ end
+ -- not that nice but we need to register it at the tex end
+ -- context.enablemathrules("\\fontclass")
+ end
+ end
+ end
+end
+
+registerotffeature {
+ name = "mathrules",
+ description = "check math rules",
+ default = true,
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-epd.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-epd.mkxl
new file mode 100644
index 00000000000..7ff9b86756e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-epd.mkxl
@@ -0,0 +1,93 @@
+%D \module
+%D [ file=grph-epd,
+%D version=2010.07.29,
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Merging Goodies,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Graphic Macros / Merging Goodies}
+
+\unprotect
+
+\registerctxluafile{grph-epd}{}
+
+% hm, this one is globally overloaded
+
+\mutable\let\mergedfigurereference\empty
+
+\defineoverlay[system:graphics:epdf][\directsetup{system:graphics:epdf}]
+
+\startsetups system:graphics:epdf
+ \clf_figure_mergegoodies{\externalfigureparameter\c!interaction}%
+ \reference[\mergedfigurereference]{}% todo: dest area
+\stopsetups
+
+\defineframed
+ [system_graphics_epdf]
+ [\c!frame=\v!off,
+ \c!offset=\v!overlay,
+ \c!background={\v!foreground,system:graphics:epdf}]
+
+\protected\def\grph_epdf_add_overlay
+ {\global\setbox\foundexternalfigure\vbox\bgroup % vpack ?
+ \system_graphics_epdf{\box\foundexternalfigure}%
+ \egroup}
+
+\appendtoks
+ \iflocation
+ \doif\figurefiletype{pdf}{\doifnot{\externalfigureparameter\c!interaction}\v!none\grph_epdf_add_overlay}%
+ \fi
+\to \externalfigurepostprocessors
+
+\defineframed
+ [epdfstampsymbol]
+ [\c!foregroundstyle=\v!mono,
+ \c!background=\c!color,
+ \c!rulethickness=.125\exheight,
+ \c!offset=.250\exheight,
+ \c!backgroundcolor=lightgray, % can be adapted before first usage
+ \c!framecolor=darkgray, % can be adapted before first usage
+ \c!corner=\v!round]
+
+\definesymbol[Stamped] [\epdfstampsymbol{Stamped}]
+
+\definesymbol[Approved] [\epdfstampsymbol{Approved}]
+\definesymbol[Experimental] [\epdfstampsymbol{Experimental}]
+\definesymbol[NotApproved] [\epdfstampsymbol{NotApproved}]
+\definesymbol[AsIs] [\epdfstampsymbol{AsIs}]
+\definesymbol[Expired] [\epdfstampsymbol{Expired}]
+\definesymbol[NotForPublicRelease] [\epdfstampsymbol{NotForPublicRelease}]
+\definesymbol[Confidential] [\epdfstampsymbol{Confidential}]
+\definesymbol[Final] [\epdfstampsymbol{Final}]
+\definesymbol[Sold] [\epdfstampsymbol{Sold}]
+\definesymbol[Departmental] [\epdfstampsymbol{Departmental}]
+\definesymbol[ForComment] [\epdfstampsymbol{ForComment}]
+\definesymbol[TopSecret] [\epdfstampsymbol{TopSecret}]
+\definesymbol[Draft] [\epdfstampsymbol{Draft}]
+\definesymbol[ForPublicRelease] [\epdfstampsymbol{ForPublicRelease}]
+
+\protect \endinput
+
+% /Properties << /xxxx 22 0 R >>
+% 21 0 obj << /Type /OCG /Name (xxxx) >> endobj
+% 22 0 obj << /OCGs [ 21 0 R ] /Type /OCMD >> endobj
+
+% \def\setepdflayer#1#2#3#4#5#6% x y w h (in bp) 0/1 destination
+% {\setlayer
+% [epdflinks]
+% [\c!x=#1bp,\c!y=#1\s!bp,\c!preset=\v!leftbottom]
+% {\button
+% [\c!width=#3\s!bp,\c!height=#4\s!bp,\c!offset=\v!overlay,\c!frame=\ifnum#5=1 on\else\v!off]%
+% {}[#6]}}
+
+% \def\setepdflayer#1#2#3#4#5#6% x y w h (in bp) 0/1 destination
+% {\setlayer
+% [epdflinks]
+% [\c!x=#1bp,\c!y=#1\s!bp,\c!preset=\v!leftbottom]
+% {\gotowdhtbox{#3\s!bp}{#4\s!bp}[#6]}}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-fig.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-fig.mkxl
new file mode 100644
index 00000000000..92d2c7dc69a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-fig.mkxl
@@ -0,0 +1,367 @@
+%D \module
+%D [ file=grph-fig,
+%D version=2006.08.26, % overhaul of 1997.03.31
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Figure Inclusion,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% This is (yet) untested in LMTX!
+
+\unprotect
+
+%D Used in the styledesign manual:
+%
+% beware in mkiv we don't have the typeset- prefix
+%
+% \setbuffer[typeset-b]\endbuffer
+% \setbuffer[typeset-a]\endbuffer
+%
+% todo:
+%
+% \appendtoks \setbuffer[typeset-b]\endbuffer\to \everystarttext
+% \appendtoks \setbuffer[typeset-a]\endbuffer\to \everystarttext
+
+% we could use \typesetbuffer[*] to access the last one
+
+\newconstant\c_grph_buffers_mode
+
+\mutable\let\lasttypesetbuffer\empty
+
+\permanent\protected\def\typesetbuffer {\bgroup\setconstant\c_grph_buffers_mode\plusone \grph_buffers_typeset}
+\permanent\protected\def\typesetbufferonly{\bgroup\setconstant\c_grph_buffers_mode\zerocount\grph_buffers_typeset}
+
+\tolerant\permanent\protected\def\grph_buffers_typeset[#1]#*[#2]%
+ {\ifparameters
+ \grph_buffers_typeset_indeed\jobname\empty
+ \or
+ \ifhastok={#1}%
+ \grph_buffers_typeset_indeed\jobname{#1}%
+ \else
+ \grph_buffers_typeset_indeed{#1}\empty
+ \fi
+ \or
+ \grph_buffers_typeset_indeed{#1}{#2}%
+ \fi}
+
+\def\grph_buffers_typeset_indeed#1#2% we could use the via files
+ {\doifnot{#1}{*}{\xdef\lasttypesetbuffer{\clf_typesetbuffer{#1}}}%
+ \ifcase\c_grph_buffers_mode
+ % typesetonly
+ \or
+ \externalfigure[\lasttypesetbuffer][#2]%
+ \fi
+ \egroup}
+
+\tolerant\permanent\protected\def\runbuffer[#1]#*[#2]%
+ {\xdef\lasttypesetbuffer{\clf_runbuffer{#1}{#2}}}
+
+% For manuals and such:
+%
+% \definetypesetting [name] [options] [settings-a]
+%
+% \typesetfile [name] [file] [settings-b]
+% \typesetfile [file] [options] [settings-b]
+% \typesetfile [file] [settings-b]
+% \typesetfile [file]
+%
+% \enabletrackers[files.run]
+% \starttext
+% \typesetfile[oepsoeps.tex][width=10cm,frame=on]
+% \stoptext
+
+\installcorenamespace{typesettingfile}
+
+\tolerant\permanent\protected\def\definetypesetting[#1]#*[#2]#*[#3]% options settings-a
+ {\ifparameter#1\or\setuvalue{\??typesettingfile#1}{\grph_typesetting_process_indeed{#2}{#3}}\fi}
+
+\tolerant\permanent\protected\def\typesetfile[#1]#*[#2]#*[#3]% filename settings-b | filename options settings
+ {\ifcsname\??typesettingfile#1\endcsname
+ \lastnamedcs{#2}{#3}%
+ \orelse\ifparameter#3\or
+ \grph_typesetting_process_indeed{#2}{#3}{#1}{}%
+ \orelse\ifparameter#2\or % filename settings
+ \grph_typesetting_process_indeed{}{#2}{#1}{}%
+ \fi}
+
+\defineexternalfigure[typesetting] % so one can set a frame and such
+
+\def\grph_typesetting_process_indeed#1#2#3#4% options settings-a filename settings-b
+ {\begingroup
+ \edef\m_typesetting_name{\clf_runcontextjob{#3}{#1}}%
+ \ifempty\m_typesetting_name \else
+ \normalexpanded{\externalfigure[\m_typesetting_name][typesetting]}[#2,#4]%
+ \fi
+ \endgroup}
+
+%D Whatever ... hardly used ... but historic ... needs checking ... will probably
+%D become m-fig-nn.mkiv .. or I will extend it cq. clean it up when I needed it.
+%D After all, it's documented in old manuals.
+
+\newcount\c_grph_steps_reference
+\newdimen\d_grph_steps_x
+\newdimen\d_grph_steps_y
+\newbox \b_grph_steps_colorbar
+
+\ifdefined\referring\else \mutable\let\referring\relax \fi
+\ifdefined\marking \else \mutable\let\marking \relax \fi
+\ifdefined\remark \else \mutable\let\remark \relax \fi
+\ifdefined\colorbar \else \mutable\let\colorbar \relax \fi
+
+\tolerant\protected\def\grph_steps_place_figure#1#2#3#4[#5]%
+ {\hpack
+ {\setbox\scratchbox\hpack
+ {\useexternalfigure[\s!dummy][#2][#3,#5]%
+ \externalfigure[\s!dummy]}%
+ \grph_steps_calculate
+ \startpositioning
+ \enforced\let\referring\grph_steps_one_referring
+ \enforced\let\marking \grph_steps_one_marking
+ \enforced\let\remark \grph_steps_one_remark
+ \enforced\let\colorbar \grph_steps_one_colorbar
+ \position(0,0){\box\scratchbox}%
+ \linewidth\onepoint
+ \setuppositioning
+ [\c!unit=pt,%
+ \c!xscale=\withoutpt\the\d_grph_steps_x,%
+ \c!yscale=\withoutpt\the\d_grph_steps_y,%
+ \c!factor=1]%
+ \ignorespaces#4%
+ \enforced\let\referring\grph_steps_two_referring
+ \enforced\let\marking \grph_steps_two_marking
+ \enforced\let\remark \grph_steps_two_remark
+ \enforced\let\colorbar \grph_steps_two_colorbar
+ \ignorespaces#4\removeunwantedspaces % or just grab #4 unspaced
+ \stoppositioning
+ \ifvoid\b_grph_steps_colorbar\else\box\b_grph_steps_colorbar\fi}} % not really needed
+
+\protected\def\grph_steps_one_referring(#1,#2)#*(#3,#4)#*[#5]%
+ {\position(#1,#2){\grph_steps_goto(#3,#4){\externalfigureparameter\c!frames}[#5]}}
+
+\protected\def\grph_steps_one_marking(#1,#2)#*(#3,#4)#*[#5]%
+ {\position(#1,#2){\grph_steps_this_is(#3,#4){\externalfigureparameter\c!frames}[#5]}}
+
+\protected\def\grph_steps_one_remark (#-,#-)#*(#-,#-)#*[#-]#*#:#-{}% (x,y)(h,b)[...]{tekst}
+\protected\def\grph_steps_one_colorbar #-[#-]{}
+\protected\def\grph_steps_two_referring(#-,#-)#*(#-,#-)#*[#-]{}
+
+\let\grph_steps_two_marking\grph_steps_two_referring
+
+\protected\def\grph_steps_two_remark
+ {\grph_steps_comment\v!no}
+
+\protected\def\grph_steps_two_colorbar#1[#2]
+ {\begingroup
+ \global\setbox\b_grph_steps_colorbar\vpack % \vbox ?
+ {\forgetall
+ \processcommalist[#2]\grph_colorbar_make_step}%
+ \global\setbox\b_grph_steps_colorbar\vpack
+ {\hskip2\emwidth\box\b_grph_steps_colorbar}%
+ \global\wd\b_grph_steps_colorbar\zeropoint
+ \endgroup}
+
+\protected\def\grph_colorbar_make_step#1%
+ {\blackrule[\c!color=#1,\c!width=2\emwidth,\c!height=\exheight,\c!depth=\zeropoint]%
+ \endgraf}
+
+\permanent\protected\def\startfigure[#1]#*[#2]#*[#3]#:#4\stopfigure
+ {\doifelse{\externalfigureparameter\c!option}\v!test
+ {\grph_steps_test_figure{#1}{#2}{#3}{#4}%
+ \letexternalfigureparameter\c!frames\v!on}%
+ {\letexternalfigureparameter\c!frames\v!off}%
+ \setvalue{\??externalfigureinstance#1}%
+ {\grph_steps_place_figure{#1}{#2}{#3}{#4}}}
+
+\aliased\let\stopfigure\relax
+
+\ifdefined\referring \else \let\referring\relax \fi
+\ifdefined\marking \else \let\marking \relax \fi
+\ifdefined\remark \else \let\remark \relax \fi
+\ifdefined\colorbar \else \let\colorbar \relax \fi
+
+\protected\def\grph_steps_test_figure#1#2#3#4%
+ {\begingroup
+ \setbox\scratchbox\hpack
+ {\useexternalfigure[\s!dummy][#2][\c!wfactor=\v!max]%
+ \externalfigure[\s!dummy]}%
+ \let\referring\grph_steps_three_referring
+ \let\marking \grph_steps_three_marking
+ \let\remark \grph_steps_three_remark
+ \let\colorbar \grph_steps_three_colorbar
+ \c_grph_steps_reference\zerocount
+ \setbox\scratchboxone\vpack
+ {\hsize240\points
+ \startpositioning
+ \grph_steps_calculate
+ \position(0,0)
+ {\box\scratchbox}%
+ \position(0,0)
+ {\basegrid
+ [\c!nx=\externalfigureparameter\c!xmax,%
+ \c!dx=\withoutpt\the\d_grph_steps_x,%
+ \c!ny=\externalfigureparameter\c!ymax,%
+ \c!dy=\withoutpt\the\d_grph_steps_y,%
+ \c!xstep=1,%
+ \c!ystep=1,%
+ \c!scale=1,%
+ \c!offset=\v!no,%
+ \c!unit=pt]}%
+ \setuppositioning
+ [\c!unit=pt,%
+ \c!xscale=\withoutpt\the\d_grph_steps_x,%
+ \c!yscale=\withoutpt\the\d_grph_steps_y,%
+ \c!factor=1]%
+ \linewidth\onepoint
+ \ignorespaces#4\removeunwantedspaces % or just grab #4 unspaced
+ \stoppositioning
+ \vfill}%
+ \c_grph_steps_reference\zerocount
+ \enforced\let\referring\grph_steps_four_referring
+ \enforced\let\marking \grph_steps_four_marking
+ \enforced\let\remark \grph_steps_four_remark
+ \enforced\let\colorbar \grph_steps_four_colorbar
+ \setbox\scratchboxtwo\vbox % \vpack ?
+ {\forgetall
+ \begingroup
+ \tfa\doifelsenothing{#1}{#2}{#1}%
+ \endgroup
+ \blank
+ \tfxx#4%
+ \vfilll}%
+ \ifdim\ht\scratchboxone>\ht\scratchboxtwo
+ \ht\scratchboxtwo\ht\scratchboxone
+ \else
+ \ht\scratchboxone\ht\scratchboxtwo
+ \fi
+ \hpack
+ {\hskip3\emwidth
+ \tpack{\vskip12\points\box\scratchboxone\vskip6\points}%
+ \tpack{\vskip12\points\box\scratchboxtwo\vskip6\points}}%
+ \endgroup}
+
+\definesystemconstant{vwa}
+\definesystemconstant{vwb}
+
+\tolerant\protected\def\grph_steps_three_referring(#1,#2)#*(#3,#4)#*[#5]%
+ {\advance\c_grph_steps_reference\plusone
+ \position(#1,#2)
+ {\hbox{\the\c_grph_steps_reference}}%
+ \position(#1,#2)
+ {\gotosomeinternal\s!vwb{#5}\realfolio
+ {\grph_steps_marker(#3,#4)\v!on{\thisissomeinternal\s!vwa{#5}}}}}
+
+\protected\def\grph_steps_three_remark
+ {\grph_steps_comment\v!yes}
+
+\let\grph_steps_three_marking \grph_steps_three_referring
+\let\grph_steps_three_colorbar\grph_steps_one_colorbar
+
+\protected\def\grph_steps_four_referring{\grph_steps_text{\normalstartimath\rightarrow\normalstopimath}}
+\protected\def\grph_steps_four_marking {\grph_steps_text{\normalstartimath\leftarrow \normalstopimath}}
+
+\let\grph_steps_four_remark \grph_steps_one_remark
+\let\grph_steps_four_colorbar\grph_steps_one_colorbar
+
+% Helpers:
+
+\def\grph_steps_calculate
+ {\ifnum0\externalfigureparameter\c!xmax=\zerocount
+ \ifnum0\externalfigureparameter\c!ymax=\zerocount
+ \setexternalfigureparameter\c!ymax{24}%
+ \fi
+ \d_grph_steps_y\figureheight
+ \divide\d_grph_steps_y \externalfigureparameter\c!ymax
+ \d_grph_steps_x\d_grph_steps_y
+ \scratchdimen\figurewidth
+ \advance\scratchdimen\d_grph_steps_y
+ \divide \scratchdimen\d_grph_steps_y
+ \setexternalfigureparameter\c!xmax{\number\scratchdimen}%
+ \else
+ \d_grph_steps_x\figurewidth \divide\d_grph_steps_x \externalfigureparameter\c!xmax\relax
+ \d_grph_steps_y\figureheight \divide\d_grph_steps_y \externalfigureparameter\c!ymax\relax
+ \fi}
+
+\tolerant\def\grph_steps_comment#1(#2,#3)#*(#4,#5)#*[#6]#*#:#7% {kader}(x,y)(h,b)[...]{tekst}
+ {\position(#2,#3)%
+ {\setnostrut
+ \framed[\c!width=#4\d_grph_steps_x,\c!height=#5\d_grph_steps_y,\c!offset=\v!none,\c!frame=#1,#6]{#7}}}
+
+% \def\grph_steps_figure#1%
+% {\position(0,0){\getvalue{#1}}}
+
+\def\grph_steps_goto(#1,#2)#3[#4]% (h,b)kader[ref]
+ {\gotobox{\vpack{\grph_steps_area(#1,#2)#3{}}}[#4]}
+
+\tolerant\def\grph_steps_text#1(#2,#3)#*(#4,#5)#*[#6]%
+ {\advance\c_grph_steps_reference\plusone
+ \hbox % \hpack ?
+ {\quad
+ \thisissomeinternal\s!vwb{#6}%
+ \gotosomeinternal\s!vwa{#6}\realfolio{\hbox to 1.5\emwidth{\the\c_grph_steps_reference\hfill}}%
+ \quad#1 (#2,#3) (#4,#5) [#6]\hfill}%
+ \endgraf}
+
+\def\grph_steps_this_is(#1,#2)#3[#4]%
+ {\grph_steps_area(#1,#2){#3}{\dosetdirectpagereference{#4}}}
+
+\def\grph_steps_area(#1,#2)#3#4% (h,b){kader}{tekst}
+ {\bgroup
+ \setnostrut
+ \framed[\c!width=#1\d_grph_steps_x,\c!height=#2\d_grph_steps_y,\c!offset=\zeropoint,\c!frame=#3]{#4}%
+ \egroup}
+
+\def\grph_steps_marker(#1,#2)#3#4% (h,b){kader}{tekst}
+ {\framed[\c!width=#1\d_grph_steps_x,\c!height=#2\d_grph_steps_y,\c!offset=\v!none,\c!frame=#3]{#4}}
+
+\protect \endinput
+
+% \startbuffer
+% \definecolor [blue] [c=1,m=.38,y=0,k=.64]
+% \definecolor [yellow] [c=0,m=.28,y=1,k=.06]
+%
+% \definespotcolor [blue-100] [blue] [p=1]
+% \definespotcolor [yellow-100] [yellow] [p=1]
+%
+% \definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]
+%
+% \definemultitonecolor [combicolor-b] [blue=1] [c=1,m=.38,y=0,k=.64] % force multitone
+% \definemultitonecolor [combicolor-y] [yellow=1] [c=0,m=.28,y=1,k=.06] % force multitone
+%
+% \useexternalfigure[demo-a][mill.png] [object=no,width=.2\textwidth]
+% \useexternalfigure[demo-b][hacker-bw.jpg][object=no,width=.2\textwidth]
+%
+% \startbaselinecorrection \startcombination[4*1]
+% {\externalfigure[demo-a]} {no color}
+% {\externalfigure[demo-a][color=combicolor]} {indexed duotone}
+% {\externalfigure[demo-a][color=combicolor-b]} {spot color}
+% {\externalfigure[demo-a][color=combicolor-y]} {spot color}
+% \stopcombination \stopbaselinecorrection
+%
+% \startbaselinecorrection \startcombination[4*1]
+% {\externalfigure[demo-b]} {no color}
+% {\externalfigure[demo-b][color=combicolor]} {indexed duotone}
+% {\externalfigure[demo-b][color=combicolor-b]} {spot color}
+% {\externalfigure[demo-b][color=combicolor-y]} {spot color}
+% \stopcombination \stopbaselinecorrection
+%
+% \startbaselinecorrection \startcombination[4*1]
+% {\externalfigure[demo-a]} {no color}
+% {\externalfigure[demo-a][color=combicolor]} {indexed duotone}
+% {\externalfigure[demo-a][color=blue-100]} {spot color}
+% {\externalfigure[demo-a][color=yellow-100]} {spot color}
+% \stopcombination \stopbaselinecorrection
+%
+% \startbaselinecorrection \startcombination[4*1]
+% {\externalfigure[demo-b]} {no color}
+% {\externalfigure[demo-b][color=combicolor]} {indexed duotone}
+% {\externalfigure[demo-b][color=blue-100]} {spot color}
+% {\externalfigure[demo-b][color=yellow-100]} {spot color}
+% \stopcombination \stopbaselinecorrection
+% \stopbuffer
+%
+% \getbuffer \typebuffer
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-inc.lmt b/Master/texmf-dist/tex/context/base/mkxl/grph-inc.lmt
new file mode 100644
index 00000000000..4fa562cb8cd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-inc.lmt
@@ -0,0 +1,2160 @@
+if not modules then modules = { } end modules ['grph-inc'] = {
+ version = 1.001,
+ comment = "companion to grph-inc.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- todo: in pdfe: pdfe.copyappearance(document,objnum)
+--
+-- local im = createimage { filename = fullname }
+-- local on = images.flushobject(im,document.__xrefs__[AP])
+
+-- todo: files are sometimes located twice
+-- todo: empty filename or only suffix always false (not found)
+-- lowercase types
+-- mps tex tmp svg
+-- partly qualified
+-- dimensions
+-- use metatables
+-- figures.boxnumber can go as we now can use names
+-- avoid push
+-- move some to command namespace
+
+--[[
+The ConTeXt figure inclusion mechanisms are among the oldest code
+in ConTeXt and evolved into a complex whole. One reason is that we
+deal with backend in an abstract way. What complicates matters is
+that we deal with internal graphics as well: TeX code, MetaPost code,
+etc. Later on figure databases were introduced, which resulted in
+a plug in model for locating images. On top of that runs a conversion
+mechanism (with caching) and resource logging.
+
+Porting that to Lua is not that trivial because quite some
+status information is kept between al these stages. Of course, image
+reuse also has some price, and so I decided to implement the graphics
+inclusion in several layers: detection, loading, inclusion, etc.
+
+Object sharing and scaling can happen at each stage, depending on the
+way the resource is dealt with.
+
+The TeX-Lua mix is suboptimal. This has to do with the fact that we cannot
+run TeX code from within Lua. Some more functionality will move to Lua.
+]]--
+
+-- todo: store loaded pages per pdf file someplace
+
+local tonumber, tostring, next, unpack = tonumber, tostring, next, unpack
+local format, lower, find, match, gsub = string.format, string.lower, string.find, string.match, string.gsub
+local longtostring = string.longtostring
+local contains = table.contains
+local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys
+local concat, insert, remove = table.concat, table.insert, table.remove
+local todimen = string.todimen
+local collapsepath = file.collapsepath
+local formatters = string.formatters
+local odd = math.odd
+local isfile, isdir, modificationtime = lfs.isfile, lfs.isdir, lfs.modification
+
+local P, R, S, Cc, C, Cs, Ct, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.Cc, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.match
+
+local settings_to_array = utilities.parsers.settings_to_array
+local settings_to_hash = utilities.parsers.settings_to_hash
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+local replacetemplate = utilities.templates.replace
+
+local bpfactor = number.dimenfactors.bp
+
+images = images or { }
+local images = images
+
+local hasscheme = url.hasscheme
+local urlhashed = url.hashed
+
+local resolveprefix = resolvers.resolve
+
+local texgetbox = tex.getbox
+local texsetbox = tex.setbox
+
+local hpack = node.hpack
+
+local new_latelua = nodes.pool.latelua
+
+local context = context
+
+local implement = interfaces.implement
+local variables = interfaces.variables
+
+local codeinjections = backends.codeinjections
+local nodeinjections = backends.nodeinjections
+
+local trace_figures = false trackers.register ("graphics.locating", function(v) trace_figures = v end)
+local trace_bases = false trackers.register ("graphics.bases", function(v) trace_bases = v end)
+local trace_programs = false trackers.register ("graphics.programs", function(v) trace_programs = v end)
+local trace_conversion = false trackers.register ("graphics.conversion", function(v) trace_conversion = v end)
+local trace_inclusion = false trackers.register ("graphics.inclusion", function(v) trace_inclusion = v end)
+local trace_usage = false trackers.register ("graphics.usage", function(v) trace_usage = v end)
+
+local extra_check = false directives.register("graphics.extracheck", function(v) extra_check = v end)
+local auto_transform = true directives.register("graphics.autotransform", function(v) auto_transform = v end)
+
+local report = logs.reporter("graphics")
+local report_inclusion = logs.reporter("graphics","inclusion")
+
+local f_hash_part = formatters["%s->%s->%s->%s"]
+local f_hash_full = formatters["%s->%s->%s->%s->%s->%s->%s->%s"]
+
+local v_yes = variables.yes
+local v_global = variables["global"]
+local v_local = variables["local"]
+local v_default = variables.default
+local v_auto = variables.auto
+
+local maxdimen = tex.magicconstants.maxdimen -- 0x3FFFFFFF -- 2^30-1
+
+local ctx_doscalefigure = context.doscalefigure
+local ctx_relocateexternalfigure = context.relocateexternalfigure
+local ctx_startfoundexternalfigure = context.startfoundexternalfigure
+local ctx_stopfoundexternalfigure = context.stopfoundexternalfigure
+local ctx_dosetfigureobject = context.dosetfigureobject
+local ctx_doboxfigureobject = context.doboxfigureobject
+
+-- extensions
+
+function checkimage(figure)
+ if figure then
+ local width = figure.width or 0
+ local height = figure.height or 0
+ if width <= 0 or height <= 0 then
+ report_inclusion("image %a has bad dimensions (%p,%p), discarding",figure.filename or "?",width,height)
+ return false, "bad dimensions"
+ end
+ -- local xres = figure.xres
+ -- local yres = figure.yres
+ local changes = false
+ if height > width then
+ if height > maxdimen then
+ figure.height = maxdimen
+ figure.width = width * maxdimen/height
+ changed = true
+ end
+ elseif width > maxdimen then
+ figure.width = maxdimen
+ figure.height = height * maxdimen/width
+ changed = true
+ end
+ if changed then
+ report_inclusion("limiting natural dimensions of %a, old %p * %p, new %p * %p",
+ figure.filename,width,height,figure.width,figure.height)
+ end
+ if width >= maxdimen or height >= maxdimen then
+ report_inclusion("image %a is too large (%p,%p), discarding",
+ figure.filename,width,height)
+ return false, "dimensions too large"
+ end
+ return figure
+ end
+end
+
+-- This is a bit of abstraction. Fro a while we will follow the luatex image
+-- model.
+
+local imagekeys = {
+ -- only relevant ones (permitted in luatex)
+ "width", "height", "depth", "bbox",
+ "colordepth", "colorspace",
+ "filename", "filepath", "visiblefilename",
+ "imagetype", "stream",
+ "index", "objnum",
+ "pagebox", "page", "pages",
+ "rotation", "transform",
+ "xsize", "ysize", "xres", "yres",
+}
+
+local imagesizes = {
+ art = true, bleed = true, crop = true,
+ media = true, none = true, trim = true,
+}
+
+local imagetypes = { [0] =
+ "none",
+ "pdf", "png", "jpg", "jp2", "jbig2",
+ "stream",
+}
+
+imagetypes = table.swapped(imagetypes,imagetypes)
+
+images.keys = imagekeys
+images.types = imagetypes
+images.sizes = imagesizes
+
+local function createimage(specification)
+ return backends.codeinjections.newimage(specification)
+end
+
+local function copyimage(specification)
+ return backends.codeinjections.copyimage(specification)
+end
+
+local function scanimage(specification)
+ return backends.codeinjections.scanimage(specification)
+end
+
+local function embedimage(specification)
+ -- write the image to file
+ return backends.codeinjections.embedimage(specification)
+end
+
+local function wrapimage(specification)
+ -- create an image rule
+ return backends.codeinjections.wrapimage(specification)
+end
+
+images.create = createimage
+images.scan = scanimage
+images.copy = copyimage
+images.wrap = wrapimage
+images.embed = embedimage
+
+-- If really needed we can provide:
+--
+-- img = {
+-- new = createimage,
+-- scan = scanimage,
+-- copy = copyimage,
+-- node = wrapimage,
+-- write = function(specification) context(wrapimage(specification)) end,
+-- immediatewrite = embedimage,
+-- immediatewriteobject = function() end, -- not upported, experimental anyway
+-- boxes = function() return sortedkeys(imagesizes) end,
+-- fields = function() return imagekeys end,
+-- types = function() return { unpack(imagetypes,0,#imagetypes) } end,
+-- }
+
+-- end of copies / mapping
+
+local function imagetotable(imgtable)
+ if type(imgtable) == "table" then
+ return copy(imgtable)
+ end
+ local result = { }
+ for k=1,#imagekeys do
+ local key = imagekeys[k]
+ result[key] = imgtable[key]
+ end
+ return result
+end
+
+function images.serialize(i,...)
+ return table.serialize(imagetotable(i),...)
+end
+
+function images.print(i,...)
+ return table.print(imagetotable(i),...)
+end
+
+local function checkimagesize(size)
+ if size then
+ size = gsub(size,"box","")
+ return imagesizes[size] and size or "crop"
+ else
+ return "crop"
+ end
+end
+
+images.check = checkimage
+images.checksize = checkimagesize
+images.totable = imagetotable
+
+-- local indexed = { }
+--
+-- function images.ofindex(n)
+-- return indexed[n]
+-- end
+
+--- we can consider an grph-ini file
+
+figures = figures or { }
+local figures = figures
+
+figures.images = images
+figures.boxnumber = figures.boxnumber or 0
+figures.defaultsearch = true
+figures.defaultwidth = 0
+figures.defaultheight = 0
+figures.defaultdepth = 0
+figures.nofprocessed = 0
+figures.nofmissing = 0
+figures.preferquality = true -- quality over location
+
+local figures_loaded = allocate() figures.loaded = figures_loaded
+local figures_used = allocate() figures.used = figures_used
+local figures_found = allocate() figures.found = figures_found
+local figures_suffixes = allocate() figures.suffixes = figures_suffixes
+local figures_patterns = allocate() figures.patterns = figures_patterns
+local figures_resources = allocate() figures.resources = figures_resources
+
+local existers = allocate() figures.existers = existers
+local checkers = allocate() figures.checkers = checkers
+local includers = allocate() figures.includers = includers
+local remappers = allocate() figures.remappers = remappers
+local converters = allocate() figures.converters = converters
+local identifiers = allocate() figures.identifiers = identifiers
+local programs = allocate() figures.programs = programs
+
+local defaultformat = "pdf"
+local defaultprefix = "m_k_i_v_"
+
+figures.localpaths = allocate {
+ ".", "..", "../.."
+}
+
+figures.cachepaths = allocate {
+ prefix = "",
+ path = ".",
+ subpath = ".",
+}
+
+local figure_paths = allocate(table.copy(figures.localpaths))
+figures.paths = figure_paths
+
+local figures_order = allocate {
+ "pdf", "mps", "jpg", "png", "jp2", "jbig", "svg", "eps", "tif", "gif", "mov", "buffer", "tex", "cld", "auto",
+}
+
+local figures_formats = allocate { -- magic and order will move here
+ ["pdf"] = { list = { "pdf" } },
+ ["mps"] = { patterns = { "^mps$", "^%d+$" } }, -- we need to anchor
+ ["jpg"] = { list = { "jpg", "jpeg" } },
+ ["png"] = { list = { "png" } },
+ ["jp2"] = { list = { "jp2" } },
+ ["jbig"] = { list = { "jbig", "jbig2", "jb2" } },
+ ["svg"] = { list = { "svg", "svgz" } },
+ ["eps"] = { list = { "eps", "ai" } },
+ ["gif"] = { list = { "gif" } },
+ ["tif"] = { list = { "tif", "tiff" } },
+ ["mov"] = { list = { "mov", "flv", "mp4" } }, -- "avi" is not supported
+ ["buffer"] = { list = { "tmp", "buffer", "buf" } },
+ ["tex"] = { list = { "tex" } },
+ ["cld"] = { list = { "cld" } },
+ ["auto"] = { list = { "auto" } },
+}
+
+local figures_magics = allocate {
+ { format = "png", pattern = P("\137PNG\013\010\026\010") }, -- 89 50 4E 47 0D 0A 1A 0A,
+ { format = "jpg", pattern = P("\255\216\255") }, -- FF D8 FF
+ { format = "jp2", pattern = P("\000\000\000\012\106\080\032\032\013\010"), }, -- 00 00 00 0C 6A 50 20 20 0D 0A },
+ { format = "gif", pattern = P("GIF") },
+ { format = "pdf", pattern = (1 - P("%PDF"))^0 * P("%PDF") },
+}
+
+local figures_native = allocate {
+ pdf = true,
+ jpg = true,
+ jp2 = true,
+ png = true,
+}
+
+figures.formats = figures_formats -- frozen
+figures.magics = figures_magics -- frozen
+figures.order = figures_order -- frozen
+
+-- name checker
+
+local okay = P("m_k_i_v_")
+
+local pattern = (R("az","AZ") * P(":"))^-1 * ( -- a-z : | A-Z :
+ (okay + R("az","09") + S("_/") - P("_")^2)^1 * (P(".") * R("az")^1)^0 * P(-1) + -- a-z | single _ | /
+ (okay + R("az","09") + S("-/") - P("-")^2)^1 * (P(".") * R("az")^1)^0 * P(-1) + -- a-z | single - | /
+ (okay + R("AZ","09") + S("_/") - P("_")^2)^1 * (P(".") * R("AZ")^1)^0 * P(-1) + -- A-Z | single _ | /
+ (okay + R("AZ","09") + S("-/") - P("-")^2)^1 * (P(".") * R("AZ")^1)^0 * P(-1) -- A-Z | single - | /
+) * Cc(false) + Cc(true)
+
+function figures.badname(name)
+ if not name then
+ -- bad anyway
+ elseif not hasscheme(name) then
+ return lpegmatch(pattern,name)
+ else
+ return lpegmatch(pattern,file.basename(name))
+ end
+end
+
+logs.registerfinalactions(function()
+ local done = false
+ if trace_usage and figures.nofprocessed > 0 then
+ logs.startfilelogging(report,"names")
+ for _, data in sortedhash(figures_found) do
+ if done then
+ report()
+ else
+ done = true
+ end
+ report("asked : %s",data.askedname)
+ if data.found then
+ report("format : %s",data.format)
+ report("found : %s",data.foundname)
+ report("used : %s",data.fullname)
+ if data.badname then
+ report("comment : %s","bad name")
+ elseif data.comment then
+ report("comment : %s",data.comment)
+ end
+ else
+ report("comment : %s","not found")
+ end
+ end
+ logs.stopfilelogging()
+ end
+ if figures.nofmissing > 0 and logs.loggingerrors() then
+ logs.starterrorlogging(report,"missing figures")
+ for _, data in sortedhash(figures_found) do
+ report("%w%s",6,data.askedname)
+ end
+ logs.stoperrorlogging()
+ end
+end)
+
+-- We can set the order but only indirectly so that we can check for support.
+
+function figures.setorder(list) -- can be table or string
+ if type(list) == "string" then
+ list = settings_to_array(list)
+ end
+ if list and #list > 0 then
+ figures_order = allocate()
+ figures.order = figures_order
+ local done = { } -- just to be sure in case the list is generated
+ for i=1,#list do
+ local l = lower(list[i])
+ if figures_formats[l] and not done[l] then
+ figures_order[#figures_order+1] = l
+ done[l] = true
+ end
+ end
+ report_inclusion("lookup order % a",figures_order)
+ else
+ -- invalid list
+ end
+end
+
+local function guessfromstring(str)
+ if str then
+ for i=1,#figures_magics do
+ local pattern = figures_magics[i]
+ if lpegmatch(pattern.pattern,str) then
+ local format = pattern.format
+ if trace_figures then
+ report_inclusion("file %a has format %a",filename,format)
+ end
+ return format
+ end
+ end
+ end
+end
+
+figures.guessfromstring = guessfromstring
+
+function figures.guess(filename)
+ local f = io.open(filename,'rb')
+ if f then
+ local str = f:read(100)
+ f:close()
+ if str then
+ return guessfromstring(str)
+ end
+ end
+end
+
+local function setlookups() -- tobe redone .. just set locals
+ figures_suffixes = allocate()
+ figures_patterns = allocate()
+ for _, format in next, figures_order do
+ local data = figures_formats[format]
+ local list = data.list
+ if list then
+ for i=1,#list do
+ figures_suffixes[list[i]] = format -- hash
+ end
+ else
+ figures_suffixes[format] = format
+ end
+ local patterns = data.patterns
+ if patterns then
+ for i=1,#patterns do
+ figures_patterns[#figures_patterns+1] = { patterns[i], format } -- array
+ end
+ end
+ end
+ figures.suffixes = figures_suffixes
+ figures.patterns = figures_patterns
+end
+
+setlookups()
+
+figures.setlookups = setlookups
+
+function figures.registerresource(t)
+ local n = #figures_resources + 1
+ figures_resources[n] = t
+ return n
+end
+
+local function register(tag,what,target)
+ local data = figures_formats[target] -- resolver etc
+ if not data then
+ data = { }
+ figures_formats[target] = data
+ end
+ local d = data[tag] -- list or pattern
+ if d and not contains(d,what) then
+ d[#d+1] = what -- suffix or patternspec
+ else
+ data[tag] = { what }
+ end
+ if not contains(figures_order,target) then
+ figures_order[#figures_order+1] = target
+ end
+ setlookups()
+end
+
+function figures.registersuffix (suffix, target) register('list',suffix,target) end
+function figures.registerpattern(pattern,target) register('pattern',pattern,target) end
+
+implement { name = "registerfiguresuffix", actions = register, arguments = { "'list'", "string", "string" } }
+implement { name = "registerfigurepattern", actions = register, arguments = { "'pattern'", "string", "string" } }
+
+local last_locationset = last_locationset or nil
+local last_pathlist = last_pathlist or nil
+
+function figures.setpaths(locationset,pathlist)
+ if last_locationset == locationset and last_pathlist == pathlist then
+ -- this function can be called each graphic so we provide this optimization
+ return
+ end
+ local t, h = figure_paths, settings_to_hash(locationset)
+ if last_locationset ~= locationset then
+ -- change == reset (actually, a 'reset' would indeed reset
+ if h[v_local] then
+ t = table.fastcopy(figures.localpaths or { })
+ else
+ t = { }
+ end
+ figures.defaultsearch = h[v_default]
+ last_locationset = locationset
+ end
+ if h[v_global] then
+ local list = settings_to_array(pathlist)
+ for i=1,#list do
+ local s = list[i]
+ if not contains(t,s) then
+ t[#t+1] = s
+ end
+ end
+ end
+ figure_paths = t
+ last_pathlist = pathlist
+ figures.paths = figure_paths
+ if trace_figures then
+ report_inclusion("using locations %a",last_locationset)
+ report_inclusion("using paths % a",figure_paths)
+ end
+end
+
+implement { name = "setfigurepaths", actions = figures.setpaths, arguments = "2 strings" }
+
+-- check conversions and handle it here
+
+function figures.hash(data)
+ local status = data and data.status
+ return (status and status.hash or tostring(status.private)) or "nohash" -- the
+end
+
+-- interfacing to tex
+
+local function new() -- we could use metatables status -> used -> request but it needs testing
+ local request = {
+ name = false,
+ label = false,
+ format = false,
+ page = false,
+ width = false,
+ height = false,
+ preview = false,
+ ["repeat"] = false,
+ controls = false,
+ display = false,
+ mask = false,
+ conversion = false,
+ resolution = false,
+ color = false,
+ arguments = false,
+ cache = false,
+ prefix = false,
+ size = false,
+ }
+ local used = {
+ fullname = false,
+ format = false,
+ name = false,
+ path = false,
+ suffix = false,
+ width = false,
+ height = false,
+ }
+ local status = {
+ status = 0,
+ converted = false,
+ cached = false,
+ fullname = false,
+ format = false,
+ }
+ -- this needs checking because we might check for nil, the test case
+ -- is getfiguredimensions which then should return ~= 0
+ -- setmetatableindex(status, used)
+ -- setmetatableindex(used, request)
+ return {
+ request = request,
+ used = used,
+ status = status,
+ }
+end
+
+-- use table.insert|remove
+
+local lastfiguredata = nil -- will be topofstack or last so no { } (else problems with getfiguredimensions)
+local callstack = { }
+
+function figures.initialize(request)
+ local figuredata = new()
+ if request then
+ -- request.width/height are strings and are only used when no natural dimensions
+ -- can be determined; at some point the handlers might set them to numbers instead
+ local w = tonumber(request.width) or 0
+ local h = tonumber(request.height) or 0
+ local p = tonumber(request.page) or 0
+ request.width = w > 0 and w or nil
+ request.height = h > 0 and h or nil
+ --
+ request.page = p > 0 and p or 1
+ request.keepopen = p > 0
+ request.size = checkimagesize(request.size)
+ request.object = request.object == v_yes
+ request["repeat"] = request["repeat"] == v_yes
+ request.preview = request.preview == v_yes
+ request.cache = request.cache ~= "" and request.cache
+ request.prefix = request.prefix ~= "" and request.prefix
+ request.format = request.format ~= "" and request.format
+ request.compact = request.compact == v_yes
+ table.merge(figuredata.request,request)
+ end
+ return figuredata
+end
+
+function figures.push(request)
+ statistics.starttiming(figures)
+ local figuredata = figures.initialize(request) -- we could use table.sparse but we set them later anyway
+ insert(callstack,figuredata)
+ lastfiguredata = figuredata
+ return figuredata
+end
+
+function figures.pop()
+ remove(callstack)
+ lastfiguredata = callstack[#callstack] or lastfiguredata
+ statistics.stoptiming(figures)
+end
+
+function figures.current()
+ return callstack[#callstack] or lastfiguredata
+end
+
+local function get(category,tag,default)
+ local value = lastfiguredata and lastfiguredata[category]
+ value = value and value[tag]
+ if not value or value == "" or value == true then
+ return default or ""
+ else
+ return value
+ end
+end
+
+local function setdimensions(box)
+ local status = lastfiguredata and lastfiguredata.status
+ local used = lastfiguredata and lastfiguredata.used
+ if status and used then
+ local b = texgetbox(box)
+ local w = b.width
+ local h = b.height + b.depth
+ status.width = w
+ status.height = h
+ used.width = w
+ used.height = h
+ status.status = 10
+ end
+end
+
+figures.get = get
+figures.set = setdimensions
+
+implement { name = "figurestatus", actions = { get, context }, arguments = { "'status'", "string", "string" } }
+implement { name = "figurerequest", actions = { get, context }, arguments = { "'request'", "string", "string" } }
+implement { name = "figureused", actions = { get, context }, arguments = { "'used'", "string", "string" } }
+
+implement { name = "figurefilepath", public = true, actions = { get, file.dirname, context }, arguments = { "'used'", "'fullname'" } }
+implement { name = "figurefilename", public = true, actions = { get, file.nameonly, context }, arguments = { "'used'", "'fullname'" } }
+implement { name = "figurefiletype", public = true, actions = { get, file.extname, context }, arguments = { "'used'", "'fullname'" } }
+
+implement { name = "figuresetdimensions", actions = setdimensions, arguments = "integer" }
+
+-- todo: local path or cache path
+
+local function forbiddenname(filename)
+ if not filename or filename == "" then
+ return false
+ end
+ local expandedfullname = collapsepath(filename,true)
+ local expandedinputname = collapsepath(file.addsuffix(environment.jobfilename,environment.jobfilesuffix),true)
+ if expandedfullname == expandedinputname then
+ report_inclusion("skipping graphic with same name as input filename %a, enforce suffix",expandedinputname)
+ return true
+ end
+ local expandedoutputname = collapsepath(codeinjections.getoutputfilename(),true)
+ if expandedfullname == expandedoutputname then
+ report_inclusion("skipping graphic with same name as output filename %a, enforce suffix",expandedoutputname)
+ return true
+ end
+end
+
+local function rejected(specification)
+ if extra_check then
+ local fullname = specification.fullname
+ if fullname and figures_native[file.suffix(fullname)] and not figures.guess(fullname) then
+ specification.comment = "probably a bad file"
+ specification.found = false
+ specification.error = true
+ report_inclusion("file %a looks bad",fullname)
+ return true
+ end
+ end
+end
+
+local function wipe(str)
+ if str == "" or str == "default" or str == "unknown" then
+ return nil
+ else
+ return str
+ end
+end
+
+local function register(askedname,specification)
+ if not specification then
+ specification = { askedname = askedname, comment = "invalid specification" }
+ elseif forbiddenname(specification.fullname) then
+ specification = { askedname = askedname, comment = "forbidden name" }
+ elseif specification.internal then
+ -- no filecheck needed
+ specification.found = true
+ if trace_figures then
+ report_inclusion("format %a internally supported by engine",specification.format)
+ end
+ elseif not rejected(specification) then
+ local format = specification.format
+ if format then
+ local conversion = wipe(specification.conversion)
+ local resolution = wipe(specification.resolution)
+ local arguments = wipe(specification.arguments)
+ local newformat = conversion
+ if not newformat or newformat == "" then
+ newformat = defaultformat
+ end
+ if trace_conversion then
+ report_inclusion("checking conversion of %a, fullname %a, old format %a, new format %a, conversion %a, resolution %a, arguments %a",
+ askedname,
+ specification.fullname,
+ format,
+ newformat,
+ conversion or "default",
+ resolution or "default",
+ arguments or ""
+ )
+ end
+ -- begin of quick hack
+ local remapper = remappers[format]
+ if remapper then
+ remapper = remapper[conversion]
+ if remapper then
+ specification = remapper(specification) or specification
+ format = specification.format
+ newformat = format
+ conversion = nil
+ end
+ end
+ -- end of quick hack
+ local converter = (not remapper) and (newformat ~= format or resolution or arguments) and converters[format]
+ if converter then
+ local okay = converter[newformat]
+ if okay then
+ converter = okay
+ else
+ newformat = defaultformat
+ converter = converter[newformat]
+ end
+ elseif trace_conversion then
+ report_inclusion("no converter for %a to %a",format,newformat)
+ end
+ if converter then
+ -- todo: make this a function
+ --
+ -- todo: outline as helper function
+ --
+ local oldname = specification.fullname
+ local newpath = file.dirname(oldname)
+ local oldbase = file.basename(oldname)
+ --
+ -- problem: we can have weird filenames, like a.b.c (no suffix) and a.b.c.gif
+ -- so we cannot safely remove a suffix (unless we do that for known suffixes)
+ --
+ -- local newbase = file.removesuffix(oldbase) -- assumes a known suffix
+ --
+ -- so we now have (also see *):
+ --
+ local newbase = oldbase
+ --
+ local fc = specification.cache or figures.cachepaths.path
+ if fc and fc ~= "" and fc ~= "." then
+ newpath = gsub(fc,"%*",newpath) -- so cachedir can be "/data/cache/*"
+ else
+ newbase = defaultprefix .. newbase
+ end
+ local subpath = specification.subpath or figures.cachepaths.subpath
+ if subpath and subpath ~= "" and subpath ~= "." then
+ newpath = newpath .. "/" .. subpath
+ end
+ if not isdir(newpath) then
+ dir.makedirs(newpath)
+ if not file.is_writable(newpath) then
+ if trace_conversion then
+ report_inclusion("path %a is not writable, forcing conversion path %a",newpath,".")
+ end
+ newpath = "."
+ end
+ end
+ local prefix = specification.prefix or figures.cachepaths.prefix
+ if prefix and prefix ~= "" then
+ newbase = prefix .. newbase
+ end
+ local hash = ""
+ if resolution then
+ hash = hash .. "[r:" .. resolution .. "]"
+ end
+ if arguments then
+ hash = hash .. "[a:" .. arguments .. "]"
+ end
+ if hash ~= "" then
+ newbase = newbase .. "_" .. md5.hex(hash)
+ end
+ --
+ -- see *, we had:
+ --
+ -- local newbase = file.addsuffix(newbase,newformat)
+ --
+ -- but now have (result of Aditya's web image testing):
+ --
+ -- as a side effect we can now have multiple fetches with different
+ -- original figures_formats, not that it matters much (apart from older conversions
+ -- sticking around)
+ --
+ local newbase = newbase .. "." .. newformat
+ local newname = file.join(newpath,newbase)
+ oldname = collapsepath(oldname)
+ newname = collapsepath(newname)
+ local oldtime = modificationtime(oldname) or 0
+ local newtime = modificationtime(newname) or 0
+ if newtime == 0 or oldtime > newtime then
+ if trace_conversion then
+ report_inclusion("converting %a (%a) from %a to %a",askedname,oldname,format,newformat)
+ end
+ converter(oldname,newname,resolution or "", arguments or "")
+ else
+ if trace_conversion then
+ report_inclusion("no need to convert %a (%a) from %a to %a",askedname,oldname,format,newformat)
+ end
+ end
+ if io.exists(newname) and io.size(newname) > 0 then
+ specification.foundname = oldname
+ specification.fullname = newname
+ specification.prefix = prefix
+ specification.subpath = subpath
+ specification.converted = true
+ format = newformat
+ if not figures_suffixes[format] then
+ -- maybe the new format is lowres.png (saves entry in suffixes)
+ -- so let's do this extra check
+ local suffix = file.suffix(newformat)
+ if figures_suffixes[suffix] then
+ if trace_figures then
+ report_inclusion("using suffix %a as format for %a",suffix,format)
+ end
+ format = suffix
+ end
+ end
+ specification.format = format
+ elseif io.exists(oldname) then
+ report_inclusion("file %a is bugged",oldname)
+ if format and imagetypes[format] then
+ specification.fullname = oldname
+ end
+ specification.converted = false
+ specification.bugged = true
+ end
+ end
+ end
+ if format then
+ local found = figures_suffixes[format]
+ if not found then
+ specification.found = false
+ if trace_figures then
+ report_inclusion("format %a is not supported",format)
+ end
+ elseif imagetypes[format] then
+ specification.found = true
+ if trace_figures then
+ report_inclusion("format %a natively supported by backend",format)
+ end
+ else
+ specification.found = true -- else no foo.1 mps conversion
+ if trace_figures then
+ report_inclusion("format %a supported by output file format",format)
+ end
+ end
+ else
+ specification.askedname = askedname
+ specification.found = false
+ end
+ end
+ if specification.found then
+ specification.foundname = specification.foundname or specification.fullname
+ else
+ specification.foundname = nil
+ end
+ specification.badname = figures.badname(askedname)
+ local askedhash = f_hash_part(
+ askedname,
+ specification.conversion or "default",
+ specification.resolution or "default",
+ specification.arguments or ""
+ )
+ figures_found[askedhash] = specification
+ if not specification.found then
+ figures.nofmissing = figures.nofmissing + 1
+ end
+ return specification
+end
+
+local resolve_too = false -- true
+
+local internalschemes = {
+ file = true,
+ tree = true,
+ dirfile = true,
+ dirtree = true,
+}
+
+local function locate(request) -- name, format, cache
+ -- not resolvers.cleanpath(request.name) as it fails on a!b.pdf and b~c.pdf
+ -- todo: more restricted cleanpath
+ local askedname = request.name or ""
+ local askedcache = request.cache
+ local askedconversion = request.conversion
+ local askedresolution = request.resolution
+ local askedarguments = request.arguments
+ local askedhash = f_hash_part(
+ askedname,
+ askedconversion or "default",
+ askedresolution or "default",
+ askedarguments or ""
+ )
+ local foundname = figures_found[askedhash]
+ if foundname then
+ return foundname
+ end
+ --
+ --
+ local askedformat = request.format
+ if not askedformat or askedformat == "" or askedformat == "unknown" then
+ askedformat = file.suffix(askedname) or ""
+ elseif askedformat == v_auto then
+ if trace_figures then
+ report_inclusion("ignoring suffix of %a",askedname)
+ end
+ askedformat = ""
+ askedname = file.removesuffix(askedname)
+ end
+ -- protocol check
+ local hashed = urlhashed(askedname)
+ if not hashed then
+ -- go on
+ elseif internalschemes[hashed.scheme] then
+ local path = hashed.path
+ if path and path ~= "" then
+ askedname = path
+ end
+ else
+ local foundname = resolvers.findbinfile(askedname)
+ if not foundname or not isfile(foundname) then -- foundname can be dummy
+ if trace_figures then
+ report_inclusion("unknown url %a",askedname)
+ end
+ -- url not found
+ return register(askedname)
+ end
+ local guessedformat = figures.guess(foundname)
+ if askedformat ~= guessedformat then
+ if trace_figures then
+ report_inclusion("url %a has unknown format",askedname)
+ end
+ -- url found, but wrong format
+ return register(askedname)
+ else
+ if trace_figures then
+ report_inclusion("url %a is resolved to %a",askedname,foundname)
+ end
+ return register(askedname, {
+ askedname = askedname,
+ fullname = foundname,
+ format = askedformat,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ end
+ -- we could use the hashed data instead
+ local askedpath = file.is_rootbased_path(askedname)
+ local askedbase = file.basename(askedname)
+ if askedformat ~= "" then
+ askedformat = lower(askedformat)
+ if trace_figures then
+ report_inclusion("forcing format %a",askedformat)
+ end
+ local format = figures_suffixes[askedformat]
+ if not format then
+ for i=1,#figures_patterns do
+ local pattern = figures_patterns[i]
+ if find(askedformat,pattern[1]) then
+ format = pattern[2]
+ if trace_figures then
+ report_inclusion("asked format %a matches %a",askedformat,pattern[1])
+ end
+ break
+ end
+ end
+ end
+ if format then
+ local foundname, quitscanning, forcedformat, internal = figures.exists(askedname,format,resolve_too) -- not askedformat
+ if foundname then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = foundname, -- askedname,
+ format = forcedformat or format,
+ cache = askedcache,
+ -- foundname = foundname, -- no
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ internal = internal,
+ })
+ elseif quitscanning then
+ return register(askedname)
+ end
+ askedformat = format -- new per 2013-08-05
+ elseif trace_figures then
+ report_inclusion("unknown format %a",askedformat)
+ end
+ if askedpath then
+ -- path and type given, todo: strip pieces of path
+ local foundname, quitscanning, forcedformat = figures.exists(askedname,askedformat,resolve_too)
+ if foundname then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = foundname, -- askedname,
+ format = forcedformat or askedformat,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ else
+ -- type given
+ for i=1,#figure_paths do
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
+ local check = path .. "/" .. askedname
+ -- we pass 'true' as it can be an url as well, as the type
+ -- is given we don't waste much time
+ local foundname, quitscanning, forcedformat = figures.exists(check,askedformat,resolve_too)
+ if foundname then
+ return register(check, {
+ askedname = askedname,
+ fullname = foundname, -- check,
+ format = askedformat,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ end
+ if figures.defaultsearch then
+ local check = resolvers.findfile(askedname)
+ if check and check ~= "" then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = check,
+ format = askedformat,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ end
+ end
+ elseif askedpath then
+ if trace_figures then
+ report_inclusion("using rootbased path")
+ end
+ for i=1,#figures_order do
+ local format = figures_order[i]
+ local list = figures_formats[format].list or { format }
+ for j=1,#list do
+ local suffix = list[j]
+ local check = file.addsuffix(askedname,suffix)
+ local foundname, quitscanning, forcedformat = figures.exists(check,format,resolve_too)
+ if foundname then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = foundname, -- check,
+ format = forcedformat or format,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ end
+ end
+ else
+ if figures.preferquality then
+ if trace_figures then
+ report_inclusion("unknown format, quality preferred")
+ end
+ for j=1,#figures_order do
+ local format = figures_order[j]
+ local list = figures_formats[format].list or { format }
+ for k=1,#list do
+ local suffix = list[k]
+ -- local name = file.replacesuffix(askedbase,suffix)
+ local name = file.replacesuffix(askedname,suffix)
+ for i=1,#figure_paths do
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
+ local check = path .. "/" .. name
+ local isfile = internalschemes[urlhashed(check).scheme]
+ if not isfile then
+ if trace_figures then
+ report_inclusion("warning: skipping path %a",path)
+ end
+ else
+ local foundname, quitscanning, forcedformat = figures.exists(check,format,resolve_too) -- true)
+ if foundname then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = foundname, -- check
+ format = forcedformat or format,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments
+ })
+ end
+ end
+ end
+ end
+ end
+ else -- 'location'
+ if trace_figures then
+ report_inclusion("unknown format, using path strategy")
+ end
+ for i=1,#figure_paths do
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
+ for j=1,#figures_order do
+ local format = figures_order[j]
+ local list = figures_formats[format].list or { format }
+ for k=1,#list do
+ local suffix = list[k]
+ local check = path .. "/" .. file.replacesuffix(askedbase,suffix)
+ local foundname, quitscanning, forcedformat = figures.exists(check,format,resolve_too)
+ if foundname then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = foudname, -- check,
+ format = forcedformat or format,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ end
+ end
+ end
+ end
+ if figures.defaultsearch then
+ if trace_figures then
+ report_inclusion("using default tex path")
+ end
+ for j=1,#figures_order do
+ local format = figures_order[j]
+ local list = figures_formats[format].list or { format }
+ for k=1,#list do
+ local suffix = list[k]
+ local check = resolvers.findfile(file.replacesuffix(askedname,suffix))
+ if check and check ~= "" then
+ return register(askedname, {
+ askedname = askedname,
+ fullname = check,
+ format = format,
+ cache = askedcache,
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+ end
+ end
+ end
+ end
+ end
+ return register(askedname, { -- these two are needed for hashing 'found'
+ conversion = askedconversion,
+ resolution = askedresolution,
+ arguments = askedarguments,
+ })
+end
+
+-- -- -- plugins -- -- --
+
+function identifiers.default(data)
+ local dr, du, ds = data.request, data.used, data.status
+ local l = locate(dr)
+ local foundname = l.foundname
+ local fullname = l.fullname or foundname
+ if fullname then
+ du.format = l.format or false
+ du.fullname = fullname -- can be cached
+ ds.fullname = foundname -- original
+ ds.format = l.format
+ ds.status = (l.bugged and 0) or (l.found and 10) or 0
+ end
+ return data
+end
+
+function figures.identify(data)
+ data = data or callstack[#callstack] or lastfiguredata
+ if data then
+ local list = identifiers.list -- defined at the end
+ for i=1,#list do
+ local identifier = list[i]
+ local data = identifier(data)
+-- if data and (not data.status and data.status.status > 0) then
+ if data and (not data.status and data.status.status > 0) then
+ break
+ end
+ end
+ end
+ return data
+end
+
+function figures.exists(askedname,format,resolve)
+ return (existers[format] or existers.generic)(askedname,resolve)
+end
+
+function figures.check(data)
+ data = data or callstack[#callstack] or lastfiguredata
+ return (checkers[data.status.format] or checkers.generic)(data)
+end
+
+local used_images = { }
+
+statistics.register("used graphics",function()
+ if trace_usage then
+ local filename = file.nameonly(environment.jobname) .. "-figures-usage.lua"
+ if next(figures_found) then
+ local found = { }
+ for _, data in sortedhash(figures_found) do
+ found[#found+1] = data
+ for k, v in next, data do
+ if v == false or v == "" then
+ data[k] = nil
+ end
+ end
+ end
+ for i=1,#used_images do
+ local u = used_images[i]
+ local s = u.status
+ if s then
+ s.status = nil -- doesn't say much here
+ if s.error then
+ u.used = { } -- better show that it's not used
+ end
+ end
+ for _, t in next, u do
+ for k, v in next, t do
+ if v == false or v == "" or k == "private" then
+ t[k] = nil
+ end
+ end
+ end
+ end
+ table.save(filename,{
+ found = found,
+ used = used_images,
+ } )
+ return format("log saved in '%s'",filename)
+ else
+ os.remove(filename)
+ end
+ end
+end)
+
+function figures.include(data)
+ data = data or callstack[#callstack] or lastfiguredata
+ if trace_usage then
+ used_images[#used_images+1] = data
+ end
+ return (includers[data.status.format] or includers.generic)(data)
+end
+
+function figures.scale(data) -- will become lua code
+ data = data or callstack[#callstack] or lastfiguredata
+ ctx_doscalefigure()
+ return data
+end
+
+function figures.done(data)
+ figures.nofprocessed = figures.nofprocessed + 1
+ data = data or callstack[#callstack] or lastfiguredata
+ local dr, du, ds, nr = data.request, data.used, data.status, figures.boxnumber
+ local box = texgetbox(nr)
+ ds.width = box.width
+ ds.height = box.height
+ -- somehow this fails on some of tacos files
+ -- ds.xscale = ds.width /(du.width or 1)
+ -- ds.yscale = ds.height/(du.height or 1)
+ -- du.width and du.height can be false
+ if du.width and du.height and du.width > 0 and du.height > 0 then
+ ds.xscale = ds.width /du.width
+ ds.yscale = ds.height/du.height
+ elseif du.xsize and du.ysize and du.xsize > 0 and du.ysize > 0 then
+ ds.xscale = ds.width /du.xsize
+ ds.yscale = ds.height/du.ysize
+ else
+ ds.xscale = 1
+ ds.yscale = 1
+ end
+ -- sort of redundant but can be limited
+ ds.page = ds.page or du.page or dr.page
+ return data
+end
+
+function figures.dummy(data)
+ data = data or callstack[#callstack] or lastfiguredata
+ local dr, du, nr = data.request, data.used, figures.boxnumber
+ local box = hpack(node.new("hlist")) -- we need to set the dir (luatex 0.60 buglet)
+ du.width = du.width or figures.defaultwidth
+ du.height = du.height or figures.defaultheight
+ du.depth = du.depth or figures.defaultdepth
+ box.width = du.width
+ box.height = du.height
+ box.depth = du.depth
+ texsetbox(nr,box) -- hm, should be global (to be checked for consistency)
+end
+
+-- -- -- generic -- -- --
+
+function existers.generic(askedname,resolve)
+ -- not findbinfile
+ local result
+ if hasscheme(askedname) then
+ result = resolvers.findbinfile(askedname)
+ elseif isfile(askedname) then
+ result = askedname
+ elseif resolve then
+ result = resolvers.findbinfile(askedname)
+ end
+ if not result or result == "" then
+ result = false
+ end
+ if trace_figures then
+ if result then
+ report_inclusion("%a resolved to %a",askedname,result)
+ else
+ report_inclusion("%a cannot be resolved",askedname)
+ end
+ end
+ return result
+end
+
+-- pdf : 0-3: 0 90 180 270
+-- jpeg: 0 unset 1-4: 0 90 180 270 5-8: flipped r/c
+
+local transforms = setmetatableindex (
+ {
+ ["orientation-1"] = 0, ["R0"] = 0,
+ ["orientation-2"] = 4, ["R0MH"] = 4,
+ ["orientation-3"] = 2, ["R180"] = 2,
+ ["orientation-4"] = 6, ["R0MV"] = 6,
+ ["orientation-5"] = 5, ["R270MH"] = 5,
+ ["orientation-6"] = 3, ["R90"] = 3,
+ ["orientation-7"] = 7, ["R90MH"] = 7,
+ ["orientation-8"] = 1, ["R270"] = 1,
+ },
+ function(t,k) -- transforms are 0 .. 7
+ local v = tonumber(k) or 0
+ if v < 0 or v > 7 then
+ v = 0
+ end
+ t[k] = v
+ return v
+ end
+)
+
+local function checktransform(figure,forced)
+ if auto_transform then
+
+ local orientation = (forced ~= "" and forced ~= v_auto and forced) or figure.orientation or 0
+ local transform = transforms["orientation-"..orientation]
+ figure.transform = transform
+ if odd(transform) then
+ return figure.height, figure.width
+ else
+ return figure.width, figure.height
+ end
+ end
+end
+
+local pagecount = { }
+
+function checkers.generic(data)
+ local dr, du, ds = data.request, data.used, data.status
+ local name = du.fullname or "unknown generic"
+ local page = du.page or dr.page
+ local size = dr.size or "crop"
+ local color = dr.color or "natural"
+ local mask = dr.mask or "none"
+ local conversion = dr.conversion
+ local resolution = dr.resolution
+ local arguments = dr.arguments
+ local scanimage = dr.scanimage or scanimage
+ local userpassword = dr.userpassword
+ local ownerpassword = dr.ownerpassword
+ if not conversion or conversion == "" then
+ conversion = "default"
+ end
+ if not resolution or resolution == "" then
+ resolution = "default"
+ end
+ if not arguments or arguments == "" then
+ arguments = "default"
+ end
+ local hash = f_hash_full(
+ name,
+ page,
+ size,
+ color,
+ mask,
+ conversion,
+ resolution,
+ arguments
+ )
+ --
+ local figure = figures_loaded[hash]
+ if figure == nil then
+ figure = createimage {
+ filename = name,
+ page = page,
+ pagebox = dr.size,
+ keepopen = dr.keepopen or false,
+ userpassword = userpassword,
+ ownerpassword = ownerpassword,
+ -- visiblefilename = "", -- this prohibits the full filename ending up in the file
+ }
+ codeinjections.setfigurecolorspace(data,figure)
+ codeinjections.setfiguremask(data,figure)
+ if figure then
+ -- new, bonus check (a bogus check in lmtx)
+ if page and page > 1 then
+ local f = scanimage {
+ filename = name,
+ userpassword = userpassword,
+ ownerpassword = ownerpassword,
+ }
+ if f and f.page and f.pages < page then
+ report_inclusion("no page %i in %a, using page 1",page,name)
+ page = 1
+ figure.page = page
+ end
+ end
+ -- till here
+ local f, comment = checkimage(scanimage(figure))
+ if not f then
+ ds.comment = comment
+ ds.found = false
+ ds.error = true
+ end
+ if figure.attr and not f.attr then
+ -- tricky as img doesn't allow it
+ f.attr = figure.attr
+ end
+ if dr.cmyk == v_yes then
+ f.enforcecmyk = true
+ elseif dr.cmyk == v_auto and attributes.colors.model == "cmyk" then
+ f.enforcecmyk = true
+ end
+ figure = f
+ end
+ local f, d = codeinjections.setfigurealternative(data,figure)
+ figure = f or figure
+ data = d or data
+ figures_loaded[hash] = figure
+ if trace_conversion then
+ report_inclusion("new graphic, using hash %a",hash)
+ end
+ else
+ if trace_conversion then
+ report_inclusion("existing graphic, using hash %a",hash)
+ end
+ end
+ if figure then
+ local width, height = checktransform(figure,dr.transform)
+ --
+ du.width = width
+ du.height = height
+ du.pages = figure.pages
+ du.depth = figure.depth or 0
+ du.colordepth = figure.colordepth or 0
+ du.xresolution = figure.xres or 0
+ du.yresolution = figure.yres or 0
+ du.xsize = figure.xsize or 0
+ du.ysize = figure.ysize or 0
+ du.rotation = figure.rotation or 0 -- in pdf multiples or 90% in jpeg 1
+ du.orientation = figure.orientation or 0 -- jpeg 1 2 3 4 (0=unset)
+ ds.private = figure
+ ds.hash = hash
+ end
+ return data
+end
+
+local nofimages = 0
+local pofimages = { }
+
+function figures.getrealpage(index)
+ return pofimages[index] or 0
+end
+
+local function updatepage(specification)
+ local n = specification.n
+ pofimages[n] = pofimages[n] or tex.count.realpageno -- so when reused we register the first one only
+end
+
+function includers.generic(data)
+ local dr, du, ds = data.request, data.used, data.status
+ -- here we set the 'natural dimensions'
+ dr.width = du.width
+ dr.height = du.height
+ local hash = figures.hash(data)
+ local figure = figures_used[hash]
+ -- figures.registerresource {
+ -- filename = du.fullname,
+ -- width = dr.width,
+ -- height = dr.height,
+ -- }
+ if figure == nil then
+ figure = ds.private -- the img object
+ if figure then
+ figure = (dr.copyimage or copyimage)(figure)
+ if figure then
+ figure.width = dr.width or figure.width
+ figure.height = dr.height or figure.height
+ end
+ end
+ figures_used[hash] = figure
+ end
+ if figure then
+ local nr = figures.boxnumber
+ nofimages = nofimages + 1
+ ds.pageindex = nofimages
+ local image = wrapimage(figure)
+ local pager = new_latelua { action = updatepage, n = nofimages }
+ image.next = pager
+ pager.prev = image
+ local box = hpack(image)
+ box.width = figure.width
+ box.height = figure.height
+ box.depth = 0
+ texsetbox(nr,box)
+ ds.objectnumber = figure.objnum
+ -- indexed[figure.index] = figure
+ ctx_relocateexternalfigure()
+ end
+ return data
+end
+
+-- -- -- nongeneric -- -- --
+
+local function checkers_nongeneric(data,command) -- todo: macros and context.*
+ local dr, du, ds = data.request, data.used, data.status
+ local name = du.fullname or "unknown nongeneric"
+ local hash = name
+ if dr.object then
+ -- hm, bugged ... waiting for an xform interface
+ if not objects.data["FIG"][hash] then
+ if type(command) == "function" then
+ command()
+ end
+ ctx_dosetfigureobject("FIG",hash)
+ end
+ ctx_doboxfigureobject("FIG",hash)
+ elseif type(command) == "function" then
+ command()
+ end
+ return data
+end
+
+local function includers_nongeneric(data)
+ return data
+end
+
+checkers.nongeneric = checkers_nongeneric
+includers.nongeneric = includers_nongeneric
+
+-- -- -- mov -- -- --
+
+function checkers.mov(data)
+ local dr, du, ds = data.request, data.used, data.status
+ local width = todimen(dr.width or figures.defaultwidth)
+ local height = todimen(dr.height or figures.defaultheight)
+ local foundname = du.fullname
+ dr.width, dr.height = width, height
+ du.width, du.height, du.foundname = width, height, foundname
+ if trace_inclusion then
+ report_inclusion("including movie %a, width %p, height %p",foundname,width,height)
+ end
+ -- we need to push the node.write in between ... we could make a shared helper for this
+ ctx_startfoundexternalfigure(width .. "sp",height .. "sp")
+ context(function()
+ nodeinjections.insertmovie {
+ width = width,
+ height = height,
+ factor = bpfactor,
+ ["repeat"] = dr["repeat"],
+ controls = dr.controls,
+ preview = dr.preview,
+ label = dr.label,
+ foundname = foundname,
+ }
+ end)
+ ctx_stopfoundexternalfigure()
+ return data
+end
+
+includers.mov = includers.nongeneric
+
+-- -- -- mps -- -- --
+
+internalschemes.mprun = true
+
+-- mprun.foo.1 mprun.6 mprun:foo.2
+
+local ctx_docheckfiguremprun = context.docheckfiguremprun
+local ctx_docheckfiguremps = context.docheckfiguremps
+
+local function internal(askedname)
+ local spec, mprun, mpnum = match(lower(askedname),"mprun([:%.]?)(.-)%.(%d+)")
+ -- mpnum = tonumber(mpnum) or 0 -- can be string or number, fed to context anyway
+ if spec ~= "" then
+ return mprun, mpnum
+ else
+ return "", mpnum
+ end
+end
+
+function existers.mps(askedname)
+ local mprun, mpnum = internal(askedname)
+ if mpnum then
+ return askedname, true, "mps", true
+ else
+ return existers.generic(askedname)
+ end
+end
+
+function checkers.mps(data)
+ local mprun, mpnum = internal(data.used.fullname)
+ if mpnum then
+ return checkers_nongeneric(data,function() ctx_docheckfiguremprun(mprun,mpnum) end)
+ else
+ return checkers_nongeneric(data,function() ctx_docheckfiguremps(data.used.fullname) end)
+ end
+end
+
+includers.mps = includers.nongeneric
+
+-- -- -- tex -- -- --
+
+local ctx_docheckfiguretex = context.docheckfiguretex
+
+function existers.tex(askedname)
+ askedname = resolvers.findfile(askedname)
+ return askedname ~= "" and askedname or false, true, "tex", true
+end
+
+function checkers.tex(data)
+ return checkers_nongeneric(data,function() ctx_docheckfiguretex(data.used.fullname) end)
+end
+
+includers.tex = includers.nongeneric
+
+-- -- -- buffer -- -- --
+
+local ctx_docheckfigurebuffer = context.docheckfigurebuffer
+
+function existers.buffer(askedname)
+ local name = file.nameonly(askedname)
+ local okay = buffers.exists(name)
+ return okay and name, true, "buffer", true -- always quit scanning
+end
+
+function checkers.buffer(data)
+ return checkers_nongeneric(data,function() ctx_docheckfigurebuffer(file.nameonly(data.used.fullname)) end)
+end
+
+includers.buffers = includers.nongeneric
+
+-- -- -- auto -- -- --
+
+function existers.auto(askedname)
+ local name = gsub(askedname, ".auto$", "")
+ local format = figures.guess(name)
+ -- if format then
+ -- report_inclusion("format guess %a for %a",format,name)
+ -- else
+ -- report_inclusion("format guess for %a is not possible",name)
+ -- end
+ return format and name, true, format
+end
+
+checkers.auto = checkers.generic
+includers.auto = includers.generic
+
+-- -- -- cld -- -- --
+
+local ctx_docheckfigurecld = context.docheckfigurecld
+
+function existers.cld(askedname)
+ askedname = resolvers.findfile(askedname)
+ return askedname ~= "" and askedname or false, true, "cld", true
+end
+
+function checkers.cld(data)
+ return checkers_nongeneric(data,function() ctx_docheckfigurecld(data.used.fullname) end)
+end
+
+includers.cld = includers.nongeneric
+
+-- -- -- converters -- -- --
+
+setmetatableindex(converters,"table")
+
+-- We keep this helper because it has been around for a while and therefore it can
+-- be a depedency in an existing workflow.
+
+function programs.makeoptions(options)
+ local to = type(options)
+ return (to == "table" and concat(options," ")) or (to == "string" and options) or ""
+end
+
+function programs.run(binary,argument,variables)
+ local found = nil
+ if type(binary) == "table" then
+ for i=1,#binary do
+ local b = binary[i]
+ found = os.which(b)
+ if found then
+ binary = b
+ break
+ end
+ end
+ if not found then
+ binary = concat(binary, " | ")
+ end
+ elseif binary then
+ found = os.which(match(binary,"[%S]+"))
+ end
+ if type(argument) == "table" then
+ argument = concat(argument," ") -- for old times sake
+ end
+ if not found then
+ report_inclusion("program %a is not installed",binary or "?")
+ elseif not argument or argument == "" then
+ report_inclusion("nothing to run, no arguments for program %a",binary)
+ else
+ -- no need to use the full found filename (found) .. we also don't quote the program
+ -- name any longer as in luatex there is too much messing with these names
+ local command = format([[%s %s]],binary,replacetemplate(longtostring(argument),variables))
+ if trace_conversion or trace_programs then
+ report_inclusion("running command: %s",command)
+ end
+ os.execute(command)
+ end
+end
+
+-- the rest of the code has been moved to grph-con.lua
+
+-- -- -- bases -- -- --
+
+local bases = allocate()
+figures.bases = bases
+
+local bases_list = nil -- index => { basename, fullname, xmlroot }
+local bases_used = nil -- [basename] => { basename, fullname, xmlroot } -- pointer to list
+local bases_found = nil
+local bases_enabled = false
+
+local function reset()
+ bases_list = allocate()
+ bases_used = allocate()
+ bases_found = allocate()
+ bases_enabled = false
+ bases.list = bases_list
+ bases.used = bases_used
+ bases.found = bases_found
+end
+
+reset()
+
+function bases.use(basename)
+ if basename == "reset" then
+ reset()
+ else
+ basename = file.addsuffix(basename,"xml")
+ if not bases_used[basename] then
+ local t = { basename, nil, nil }
+ bases_used[basename] = t
+ bases_list[#bases_list+1] = t
+ if not bases_enabled then
+ bases_enabled = true
+ xml.registerns("rlx","http://www.pragma-ade.com/schemas/rlx") -- we should be able to do this per xml file
+ end
+ if trace_bases then
+ report_inclusion("registering base %a",basename)
+ end
+ end
+ end
+end
+
+implement { name = "usefigurebase", actions = bases.use, arguments = "string" }
+
+local function bases_find(basename,askedlabel)
+ if trace_bases then
+ report_inclusion("checking for %a in base %a",askedlabel,basename)
+ end
+ basename = file.addsuffix(basename,"xml")
+ local t = bases_found[askedlabel]
+ if t == nil then
+ local base = bases_used[basename]
+ local page = 0
+ if base[2] == nil then
+ -- no yet located
+ for i=1,#figure_paths do
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
+ local xmlfile = path .. "/" .. basename
+ if io.exists(xmlfile) then
+ base[2] = xmlfile
+ base[3] = xml.load(xmlfile)
+ if trace_bases then
+ report_inclusion("base %a loaded",xmlfile)
+ end
+ break
+ end
+ end
+ end
+ t = false
+ if base[2] and base[3] then -- rlx:library
+ for e in xml.collected(base[3],"/(*:library|figurelibrary)/*:figure/*:label") do
+ page = page + 1
+ if xml.text(e) == askedlabel then
+ t = {
+ base = file.replacesuffix(base[2],"pdf"),
+ format = "pdf",
+ name = xml.text(e,"../*:file"), -- to be checked
+ page = page,
+ }
+ bases_found[askedlabel] = t
+ if trace_bases then
+ report_inclusion("figure %a found in base %a",askedlabel,base[2])
+ end
+ return t
+ end
+ end
+ if trace_bases and not t then
+ report_inclusion("figure %a not found in base %a",askedlabel,base[2])
+ end
+ end
+ end
+ return t
+end
+
+-- we can access sequential or by name
+
+local function bases_locate(askedlabel)
+ for i=1,#bases_list do
+ local entry = bases_list[i]
+ local t = bases_find(entry[1],askedlabel,1,true)
+ if t then
+ return t
+ end
+ end
+ return false
+end
+
+function identifiers.base(data)
+ if bases_enabled then
+ local dr, du, ds = data.request, data.used, data.status
+ local fbl = bases_locate(dr.name or dr.label)
+ if fbl then
+ du.page = fbl.page
+ du.format = fbl.format
+ du.fullname = fbl.base
+ ds.fullname = fbl.name
+ ds.format = fbl.format
+ ds.page = fbl.page
+ ds.status = 10
+ end
+ end
+ return data
+end
+
+bases.locate = bases_locate
+bases.find = bases_find
+
+identifiers.list = {
+ identifiers.base,
+ identifiers.default
+}
+
+-- tracing
+
+statistics.register("graphics processing time", function()
+ local nofprocessed = figures.nofprocessed
+ if nofprocessed > 0 then
+ local nofnames, nofbadnames = 0, 0
+ for hash, data in next, figures_found do
+ nofnames = nofnames + 1
+ if data.badname then
+ nofbadnames = nofbadnames + 1
+ end
+ end
+ return format("%s seconds including tex, %s processed images, %s unique asked, %s bad names",
+ statistics.elapsedtime(figures),nofprocessed,nofnames,nofbadnames)
+ else
+ return nil
+ end
+end)
+
+-- helper
+
+function figures.applyratio(width,height,w,h) -- width and height are strings and w and h are numbers
+ if not width or width == "" then
+ if not height or height == "" then
+ return figures.defaultwidth, figures.defaultheight
+ else
+ height = todimen(height)
+ if w and h then
+ return height * w/h, height
+ else
+ return figures.defaultwidth, height
+ end
+ end
+ else
+ width = todimen(width)
+ if not height or height == "" then
+ if w and h then
+ return width, width * h/w
+ else
+ return width, figures.defaultheight
+ end
+ else
+ return width, todimen(height)
+ end
+ end
+end
+
+-- example of simple plugins:
+--
+-- figures.converters.png = {
+-- png = function(oldname,newname,resolution)
+-- local command = string.format('gm convert -depth 1 "%s" "%s"',oldname,newname)
+-- logs.report(string.format("running command %s",command))
+-- os.execute(command)
+-- end,
+-- }
+
+-- local n = "foo.pdf"
+-- local d = figures.getinfo(n)
+-- if d then
+-- for i=1,d.used.pages do
+-- local p = figures.getinfo(n,i)
+-- if p then
+-- local u = p.used
+-- print(u.width,u.height,u.orientation)
+-- end
+-- end
+-- end
+
+function figures.getinfo(name,page)
+ if type(name) == "string" then
+ name = { name = name, page = page }
+ end
+ if name.name then
+ local data = figures.push(name)
+ data = figures.identify(data)
+ if data.status and data.status.status > 0 then
+ data = figures.check(data)
+ end
+ figures.pop()
+ return data
+ end
+end
+
+function figures.getpdfinfo(name,page,metadata)
+ -- not that useful but as we have it for detailed inclusion we can as
+ -- we expose it
+ if type(name) ~= "table" then
+ name = { name = name, page = page, metadata = metadata }
+ end
+ return codeinjections.getinfo(name)
+end
+
+-- interfacing
+
+implement {
+ name = "figure_push",
+ scope = "private",
+ actions = figures.push,
+ arguments = {
+ {
+ { "name" },
+ { "label" },
+ { "page" },
+ { "file" },
+ { "size" },
+ { "object" },
+ { "prefix" },
+ { "cache" },
+ { "format" },
+ { "preset" },
+ { "controls" },
+ { "resources" },
+ { "preview" },
+ { "display" },
+ { "mask" },
+ { "conversion" },
+ { "resolution" },
+ { "color" },
+ { "cmyk" },
+ { "arguments" },
+ { "repeat" },
+ { "transform" },
+ { "compact" },
+ { "width", "dimen" },
+ { "height", "dimen" },
+ { "userpassword" },
+ { "ownerpassword" },
+ }
+ }
+}
+
+-- beware, we get a number passed by default
+
+implement { name = "figure_pop", scope = "private", actions = figures.pop }
+implement { name = "figure_done", scope = "private", actions = figures.done }
+implement { name = "figure_dummy", scope = "private", actions = figures.dummy }
+implement { name = "figure_identify", scope = "private", actions = figures.identify }
+implement { name = "figure_scale", scope = "private", actions = figures.scale }
+implement { name = "figure_check", scope = "private", actions = figures.check }
+implement { name = "figure_include", scope = "private", actions = figures.include }
+
+implement {
+ name = "setfigurelookuporder",
+ actions = figures.setorder,
+ arguments = "string"
+}
+
+implement {
+ name = "figure_reset",
+ scope = "private",
+ arguments = { "integer", "dimen", "dimen" },
+ actions = function(box,width,height)
+ figures.boxnumber = box
+ figures.defaultwidth = width
+ figures.defaultheight = height
+ end
+}
+
+-- require("util-lib-imp-gm")
+--
+-- figures.converters.tif.pdf = function(oldname,newname,resolution)
+-- logs.report("graphics","using gm library to convert %a",oldname)
+-- utilities.graphicmagick.convert {
+-- inputname = oldname,
+-- outputname = newname,
+-- }
+-- end
+--
+-- \externalfigure[t:/sources/hakker1b.tiff]
+
+-- something relatively new:
+
+local registered = { }
+
+local ctx_doexternalfigurerepeat = context.doexternalfigurerepeat
+
+implement {
+ name = "figure_register_page",
+ arguments = "3 strings",
+ actions = function(a,b,c)
+ registered[#registered+1] = { a, b, c }
+ context(#registered)
+ end
+}
+
+implement {
+ name = "figure_nof_registered_pages",
+ actions = function()
+ context(#registered)
+ end
+}
+
+implement {
+ name = "figure_flush_registered_pages",
+ arguments = "string",
+ actions = function(n)
+ local f = registered[tonumber(n)]
+ if f then
+ ctx_doexternalfigurerepeat(f[1],f[2],f[3],n)
+ end
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-inc.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-inc.mkxl
new file mode 100644
index 00000000000..3c2e8e5c1d9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-inc.mkxl
@@ -0,0 +1,1073 @@
+%D \module
+%D [ file=grph-inc, % moved from core-fig
+%D version=2006.08.26, % overhaul of 1997.03.31
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Figure Inclusion,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \enabledirectives[graphics.conversion.eps.cleanup.ai]
+
+% \setupexternalfigures[directory=dirfile://./test/**]
+% \externalfigure[crappname(2).eps][frame=on]
+
+% todo: messages
+
+\writestatus{loading}{ConTeXt Graphic Macros / Figure Inclusion}
+
+\registerctxluafile{grph-img}{}
+\registerctxluafile{grph-inc}{autosuffix}
+\registerctxluafile{grph-bmp}{}
+\registerctxluafile{grph-chk}{}
+\registerctxluafile{grph-con}{}
+\registerctxluafile{grph-fil}{}
+%registerctxluafile{grph-mem}{} % obsolete
+\registerctxluafile{grph-u3d}{} % this will become a module
+%registerctxluafile{grph-swf}{} % this will become a module
+
+\unprotect
+
+%D Including graphics is complicated by the fact that we need to locate them first,
+%D optionally manipulate them and scale then next. Lookups are to be done as efficient
+%D as possible and inclusion of the data might happens only once. In \MKIV\ much of this
+%D is delegated to the \LUA\ end. There is not so much less code as in \MKII\ but it's
+%D more powerful, flexible, pluggable and some of the extended functionality has been
+%D moved from modules to the core. The overall functionality is rather stable and has
+%D not changed much over the years.
+
+\ifdefined\dotagfigure \else \aliased\let\dotagfigure\relax \fi
+
+\installcorenamespace{externalfigure}
+\installcorenamespace{externalfigureinstance}
+\installcorenamespace{externalfigurecollection}
+
+\installframedcommandhandler \??externalfigure {externalfigure} \??externalfigure
+
+\aliased\let\setupexternalfigures\setupexternalfigure
+
+\setupexternalfigures[% we really need the defaults
+ \c!method =,
+ \c!label =,
+ \c!size =,
+ \c!conversion =,
+ \c!resolution =,
+ \c!prefix =,
+ \c!cache =,
+ \c!page =\zerocount,
+ \c!file =,
+ \c!display =,
+ \c!mask =,
+ \c!preset =\v!yes,
+ \c!split =,
+ \c!color =,
+ \c!arguments =,
+ \c!symbol =\v!no,
+ \c!controls =\v!no,
+ \c!resources =,
+ \c!preview =\v!no,
+ \c!repeat =\v!no,
+ \c!foregroundcolor=,
+ \c!interaction =\v!none,
+ \c!hfactor =,
+ \c!wfactor =,
+ \c!factor =,
+ \c!defaultwidth =8\lineheight,
+ \c!defaultheight =6\lineheight,
+ \c!maxwidth =\externalfigureparameter\c!width,
+ \c!maxheight =\externalfigureparameter\c!height,
+ \c!xscale =,
+ \c!yscale =,
+ \c!scale =,
+ \c!sx =\externalfigureparameter\c!s,
+ \c!sy =\externalfigureparameter\c!s,
+ \c!s =1,
+ \c!width =,
+ \c!height =,
+ \c!lines =,
+ \c!grid =,
+ \c!bodyfont =\bodyfontsize,
+ \c!object =\v!yes,
+ \c!corner =\v!rectangular,
+ \c!frame =\v!off,
+ \c!option =,
+ \c!reset =\v!no,
+ \c!directory =,
+ \c!radius =.5\bodyfontsize,
+ \c!background =,
+ \c!splitcolor =\s!white,
+ \c!order =,
+ \c!equalwidth =,
+ \c!equalheight =,
+ \c!location ={\v!local,\v!global},
+ \c!frames =\v!off,
+ \c!ymax =24,
+ \c!xmax =,
+ \c!align =\v!none, % New, for Tacos extremely large graphics.
+ \c!crossreference =\v!no,
+ \c!transform =\v!auto,
+ \c!userpassword =,
+ \c!ownerpassword =,
+ \c!compact =,
+ \c!cmyk =,
+ ]
+
+%D Defining figures.
+
+\newcount\c_grph_include_nesting
+
+\newtoks \everyexternalfigureresets % for the moment still public
+\newtoks \everyexternalfigurechecks % for the moment still public
+
+% \useexternalfigure[alpha][cow]
+% \useexternalfigure[beta] [cow] [width=1cm]
+% \useexternalfigure[gamma][cow][alpha]
+% \useexternalfigure[delta][cow][alpha][width=2cm]
+%
+% full width : \externalfigure[cow] \par
+% 3cm width : \externalfigure[cow] [width=3cm] \par
+% full width : \externalfigure[alpha] \par
+% 1cm width : \externalfigure[beta] \par
+% full width : \externalfigure[gamma] \par
+% 2cm width : \externalfigure[delta] \par
+% 4cm width : \externalfigure[beta] [width=4cm] \par
+% 5cm width : \externalfigure[gamma][width=5cm] \par
+%
+% \defineexternalfigure[a][width=10cm]
+% \defineexternalfigure[b][width=5cm]
+% \externalfigure[cow][a]
+% \externalfigure[cow][b][height=8cm]
+%
+% \useexternalfigure[x][cow][width=10cm,height=1cm]
+% \externalfigure[x]
+% \externalfigure[x][width=3cm]
+%
+% [label] [filename]
+% [label] [filename] [parent]
+% [label] [filename] [parent] [settings]
+% [label] [filename] [settings]
+%
+% new: more convenient/efficient than
+%
+% \use..[a][a][setting] \externalfigure[b][a]
+%
+% is equivalent to:
+%
+% \def..[a][setting] \externalfigure[b][a]
+%
+% see x-res modules for usage:
+%
+% \defineexternalfigure[name][settings]
+
+%D Defining is persistent, i.e.\ when you redefine an instance, the already set
+%D parameters need to be set again or otherwise the old values will be used.
+%D
+%D New: \type {method=auto}: strips suffix and uses \quote {order} which is handy in
+%D some of four workflows where sources are used for web and print and where the web
+%D tools need a suffix (like gif) which we don't want as we want a high quality
+%D format.
+
+\newconditional\c_grph_include_trace_inheritance
+
+\installtextracker
+ {graphics.inheritance}
+ {\settrue \c_grph_include_trace_inheritance}
+ {\setfalse\c_grph_include_trace_inheritance}
+
+\installcorenamespace{externalfiguredefinition}
+
+\aliased\let\defineexternalfigures\defineexternalfigure
+
+% label file parent settings
+% label file settings
+% label file parent
+
+\permanent\tolerant\protected\def\useexternalfigure[#1]#*[#2]#*[#3]#*[#4]%
+ {\iftok{#1}\emptytoks
+ \iftok{#2}\emptytoks\else
+ \ifhastok={#3}%
+ \grph_include_use_indeed{#2}{#2}{#3}{#4}%
+ \else
+ \grph_include_use_indeed{#2}{#2}\empty{#4}%
+ \fi
+ \fi
+ \orelse\iftok{#2}\emptytoks
+ \ifhastok={#3}%
+ \grph_include_use_indeed{#1}{#1}\empty{#3}%
+ \else
+ \grph_include_use_indeed{#1}{#1}{#3}{#4}%
+ \fi
+ \else
+ \ifhastok={#3}%
+ \grph_include_use_indeed{#1}{#2}\empty{#3}
+ \else
+ \grph_include_use_indeed{#1}{#2}{#3}{#4}%
+ \fi
+ \fi}
+
+\def\grph_include_use_indeed#1#2#3#4%
+ {\dodoglobal\setvalue{\??externalfigureinstance#1}{\grph_include_setup{#2}{#3}{#4}}%
+ \grph_include_analyze_collection[#2][#4]}
+
+% inclusion
+
+\permanent\tolerant\protected\def\externalfigure[#1]#*[#2]#*[#3]%
+ {\ifhastok={#2}%
+ \grph_include_place[#1][][#2]%
+ \else
+ \grph_include_place[#1][#2][#3]%
+ \fi}
+
+% todo: chain them
+
+\def\grph_include_setup#1#2#3% name parent settings
+ {\edef\m_grph_include_name {#1}%
+ \edef\m_grph_include_parent{#2}%
+ \ifempty\m_grph_include_name \else
+ \let\p_grph_include_name\m_grph_include_name
+ \fi
+ \ifempty\m_grph_include_parent \else
+ \grph_include_inherit_from_parent\m_grph_include_parent
+ \fi
+ \setupcurrentexternalfigure[#3]}
+
+\def\grph_include_inherit_from_parent#1%
+ {\ifcsname\??externalfigure#1:\s!parent\endcsname
+ \let\currentexternalfigure#1%
+ \fi
+ \ifcsname\??externalfigureinstance#1\endcsname
+ \ifconditional\c_grph_include_trace_inheritance\writestatus\m!figures{inheriting from instance: #1}\fi
+ \csname\??externalfigureinstance#1\endcsname
+ \fi}
+
+\newtoks\t_grph_include_local_settings
+
+\appendtoks
+ \enforced\let\textunderscore\letterunderscore % {\string _} % space needed as _ is now letter in unprotected mode (probably no longer needed)
+ %
+ \dontcomplain
+ \restorecatcodes
+ \forgetall
+\to \t_grph_include_local_settings
+
+\def\grph_include_place_inherit
+ {\ifconditional\c_grph_include_trace_inheritance
+ \writestatus\m!figures{label: \p_grph_include_label, name: \p_grph_include_name, parent: \p_grph_include_parent}%
+ \fi
+ \ifempty\p_grph_include_parent
+ % nothing to be done
+ \orelse\ifx\p_grph_include_parent\p_grph_include_label
+ % redundant
+ \else
+ \grph_include_inherit_from_parent\p_grph_include_parent
+ \fi
+ \ifempty\p_grph_include_label
+ % nothing to be done
+ \else
+ \grph_include_inherit_from_parent\p_grph_include_label
+ \fi}
+
+\def\grph_include_place[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings]
+ {\bgroup
+ \advance\c_grph_include_nesting\plusone
+ \edef\currentexternalfigure{\the\c_grph_include_nesting}%
+ \checkexternalfigureparent % each inherits from the root
+ %
+ \the\everyexternalfigureresets
+ %
+ \edef\p_grph_include_label{#1}%
+ \let\p_grph_include_name\p_grph_include_label
+ \ifhastok={#2}%
+ % [label] [settings]
+ \let\p_grph_include_parent\p_grph_include_label
+ \grph_include_place_inherit
+ \setupcurrentexternalfigure[#2]%
+ \else
+ % [label] [parent] [settings]
+ \edef\p_grph_include_parent{#2}%
+ \ifempty\p_grph_include_parent
+ \let\p_grph_include_parent\p_grph_include_label
+ \fi
+ \grph_include_place_inherit
+ \setupcurrentexternalfigure[#3]%
+ \fi
+ %
+ \the\everyexternalfigurechecks
+ %
+ \the\t_grph_include_local_settings
+ %
+ \edef\p_width {\externalfigureparameter\c!width}%
+ \edef\p_height {\externalfigureparameter\c!height}%
+ \edef\p_label {\externalfigureparameter\c!label}%
+ \edef\p_reference{\externalfigureparameter\c!reference}%
+ %
+ \dostarttagged\t!image\empty
+ \clf_figure_push {
+ name {\p_grph_include_name}%
+ label {\ifempty\p_label\p_grph_include_label\else\p_label\fi}%
+ page {\externalfigureparameter\c!page}%
+ file {\externalfigureparameter\c!file}%
+ size {\externalfigureparameter\c!size}%
+ object {\externalfigureparameter\c!object}%
+ prefix {\externalfigureparameter\c!prefix}%
+ cache {\externalfigureparameter\c!cache}%
+ format {\externalfigureparameter\c!method}%
+ preset {\externalfigureparameter\c!prefix}%
+ controls {\externalfigureparameter\c!controls}%
+ resources {\externalfigureparameter\c!resources}%
+ preview {\externalfigureparameter\c!preview}%
+ display {\externalfigureparameter\c!display}%
+ mask {\externalfigureparameter\c!mask}%
+ conversion {\externalfigureparameter\c!conversion}%
+ resolution {\externalfigureparameter\c!resolution}%
+ color {\externalfigureparameter\c!color}% unprocessed raw key
+ cmyk {\externalfigureparameter\c!cmyk}% kind of special
+ arguments {\externalfigureparameter\c!arguments}% used for converters
+ repeat {\externalfigureparameter\c!repeat}%
+ transform {\externalfigureparameter\c!transform}%
+ compact {\externalfigureparameter\c!compact}% experiment, share fonts
+ userpassword {\externalfigureparameter\c!userpassword}%
+ ownerpassword{\externalfigureparameter\c!ownerpassword}%
+ \ifempty\p_width \else
+ width \dimexpr\p_width\relax
+ \fi
+ \ifempty\p_height \else
+ height \dimexpr\p_height\relax
+ \fi
+ }%\relax
+ \clf_figure_identify
+ \relax
+ \ifconditional\c_grph_include_test_only
+ \ifcase\figurestatus \else
+ \clf_figure_check
+ \clf_figure_dummy
+ \clf_figure_scale
+ \clf_figure_done
+ \fi
+ \grph_include_set_mode
+ \else
+ \ifcase\figurestatus
+ \clf_figure_dummy
+ \clf_figure_scale
+ \else
+ \clf_figure_check
+ \clf_figure_include
+ \clf_figure_scale
+ \fi
+ \clf_figure_done
+ \grph_include_set_mode
+ \grph_include_finalize
+ \fi
+ \clf_figure_pop
+ \dotagfigure
+ %
+ \scratchcounter\zerocount
+ \edef\p_crossreference{\externalfigureparameter\c!crossreference}%
+ \iflocation\iftrialtypesetting\else
+ \ifempty\p_crossreference
+ % nothing
+ \orelse\ifx\p_crossreference\v!no
+ % nothing
+ \orelse\ifx\p_crossreference\v!yes
+ \ifhastok={#2}%
+ \scratchcounter\clf_figure_register_page{#1}{}{#2}\relax
+ \else
+ \scratchcounter\clf_figure_register_page{#1}{#2}{#3}\relax
+ \fi
+ \else
+ \scratchcounter-\p_crossreference % passed by repeater
+ \fi
+ \fi\fi
+ \naturalvpack
+ attr \imageattribute \plustwo
+ \ifnum\scratchcounter>\zerocount
+ {\strc_references_cross_forward {ex:\number \scratchcounter}{\box\foundexternalfigure}}%
+ \orelse\ifnum\scratchcounter<\zerocount
+ {\strc_references_cross_backward{ex:\number-\scratchcounter}{\box\foundexternalfigure}}%
+ \else
+ {\box\foundexternalfigure}%
+ \fi
+ %
+ % \naturalvpack attr \imageattribute \plustwo \bgroup
+ % \ifcmpnum\scratchcounter\zerocount
+ % \strc_references_cross_backward{ex:\number-\scratchcounter}{\box\foundexternalfigure}%
+ % \or % equal
+ % \box\foundexternalfigure%
+ % \or % more
+ % \strc_references_cross_forward {ex:\number \scratchcounter}{\box\foundexternalfigure}%
+ % \fi
+ % \egroup
+ %
+ \dostoptagged
+ \egroup}
+
+%D Next we provide a cross referenced scale-up mechanism:
+
+\def\strc_references_cross_forward#1#2%
+ {\begingroup
+ \strc_references_set_simple_internal_reference{cross:b:#1}%
+ \naturalhpack
+ attr \destinationattribute\number\lastdestinationattribute
+ {\naturalhpack{\strc_references_flush_destination_nodes\directgotodumbbox{#2}[cross:f:#1]}}%
+ \endgroup}
+
+\def\strc_references_cross_backward#1#2%
+ {\begingroup
+ \strc_references_set_simple_internal_reference{cross:f:#1}%
+ \naturalhpack
+ attr \destinationattribute\number\lastdestinationattribute
+ {\naturalhpack{\strc_references_flush_destination_nodes\directgotodumbbox{#2}[cross:b:#1]}}%
+ \endgroup}
+
+\aliased\let\doexternalfigurerepeat\gobblefourarguments % called from lua end
+
+\permanent\tolerant\protected\def\placeregisteredexternalfigures[#1]%
+ {\page
+ \begingroup
+ \enforced\protected\def\doexternalfigurerepeat{\grph_include_place_registered_indeed{#1}}%
+ \dorecurse\clf_figure_nof_registered_pages
+ {\page
+ \clf_figure_flush_registered_pages\recurselevel
+ \page}%
+ \endgroup
+ \page}
+
+\protected\def\grph_include_place_registered_indeed#1#2#3#4#5% called from lua end
+ {\grph_include_place[#2][#3][#4,%
+ \c!hfactor=,\c!wfactor=,\c!factor=,%
+ \c!maxwidth=,\c!maxheight=,%
+ \c!xscale=,\c!yscale=,\c!scale=,%
+ \c!sx=,\c!sy=,\c!s=,%
+ \c!width=,\c!height=,%
+ \c!crossreference=#5,%
+ #1]}
+
+%D Scaling:
+
+\mutable\let\dowithfigure\relax % name might change (into a proper hook)
+
+\permanent\protected\def\doscalefigure % used at lua end
+ {\global\setbox\foundexternalfigure\vpack{\scale[\v!figure]{\dowithfigure{\box\foundexternalfigure}}}}
+
+\definescale % some day we will inherit
+ [\v!figure]
+ [\c!hfactor =\externalfigureparameter\c!hfactor,
+ \c!wfactor =\externalfigureparameter\c!wfactor,
+ \c!factor =\externalfigureparameter\c!factor,
+ \c!maxwidth =\externalfigureparameter\c!maxwidth,
+ \c!maxheight =\externalfigureparameter\c!maxheight,
+ \c!equalwidth =\externalfigureparameter\c!equalwidth,
+ \c!equalheight=\externalfigureparameter\c!equalheight,
+ \c!xscale =\externalfigureparameter\c!xscale,
+ \c!yscale =\externalfigureparameter\c!yscale,
+ \c!scale =\externalfigureparameter\c!scale,
+ \c!sx =\externalfigureparameter\c!sx,
+ \c!sy =\externalfigureparameter\c!sy,
+ \c!s =\externalfigureparameter\c!s,
+ \c!width =\externalfigureparameter\c!width,
+ \c!height =\externalfigureparameter\c!height,
+ \c!lines =\externalfigureparameter\c!lines]
+
+%D You can register additional suffixes with the following command:
+%D
+%D \starttyping
+%D \definegraphictypesynonym[jbig] [jb2]
+%D \definegraphictypesynonym[jbig2][jb2]
+%D \definegraphictypesynonym[jbg] [jb2]
+%D \stoptyping
+
+\permanent\tolerant\protected\def\definegraphictypesynonym[#1]#*[#2]%
+ {\clf_registerfiguresuffix{#1}{#2}}
+
+%D Additional paths can be installed with the regular setup command. The next
+%D macro picks up the list.
+
+\permanent\protected\def\setfigurepathlist
+ {\clf_setfigurepaths{\externalfigureparameter\c!location}{\externalfigureparameter\c!directory}}
+
+%D Variables:
+
+\newbox \foundexternalfigure
+\newtoks\externalfigurepostprocessors
+
+\permanent\def\figurestatus {\numexpr\clf_figurestatus{status}{0}\relax} % number: 0 = not found
+\permanent\def\figurewidth {\clf_figurestatus{width}{0}sp}
+\permanent\def\figureheight {\clf_figurestatus{height}{0}sp}
+\permanent\def\figurexscale {\clf_figurestatus{xscale}{1}}
+\permanent\def\figureyscale {\clf_figurestatus{yscale}{1}}
+\permanent\def\figurereference {\clf_figurestatus{reference}{}}
+
+\permanent\def\figuresize {\clf_figurerequest{size}{}}
+\permanent\def\figurelabel {\clf_figurerequest{label}{}}
+\permanent\def\figurefileoriginal {\clf_figurerequest{name}{}}
+\permanent\def\figurefilepage {\clf_figurerequest{page}{1}}
+\permanent\def\figurefileoptions {\clf_figurerequest{options}{}}
+\permanent\def\figurefileconversion{\clf_figurerequest{conversion}{}}
+\permanent\def\figurefileresolution{\clf_figurerequest{resolution}{}}
+\permanent\def\figurefilecolor {\clf_figurerequest{color}{}}
+\permanent\def\figurefilearguments {\clf_figurerequest{arguments}{}}
+\permanent\def\figurefilecache {\clf_figurerequest{cache}{}}
+\permanent\def\figurefileprefix {\clf_figurerequest{prefix}{}}
+
+\permanent\def\figurenaturalwidth {\clf_figureused{width}{\number\dimexpr\externalfigureparameter\c!defaultwidth\relax}sp}
+\permanent\def\figurenaturalheight {\clf_figureused{height}{\number\dimexpr\externalfigureparameter\c!defaultheight\relax}sp}
+\permanent\def\figurexresolution {\clf_figureused{xresolution}{0}}
+\permanent\def\figureyresolution {\clf_figureused{yresolution}{0}}
+\permanent\def\figureorientation {\clf_figureused{orientation}{1}}
+\permanent\def\figurerotation {\clf_figureused{rotation}{0}}
+\permanent\def\figurexsize {\clf_figureused{xsize}{0}}
+\permanent\def\figureysize {\clf_figureused{ysize}{0}}
+\permanent\def\figurecolordepth {\clf_figureused{colordepth}{0}}
+\permanent\def\figuredepth {\clf_figureused{depth}{0}}
+
+\permanent\def\figurefullname {\clf_figureused{fullname}{}}
+\permanent\def\noffigurepages {\clf_figureused{pages}{0}}
+
+
+% \permanent\def\figurefilepath {\clf_figurefilepath} % public in lua
+% \permanent\def\figurefilename {\clf_figurefilename} % public in lua
+% \permanent\def\figurefiletype {\clf_figurefiletype} % public in lua
+
+\permanent\let\naturalfigurewidth \figurenaturalwidth
+\permanent\let\naturalfigureheight \figurenaturalheight
+
+\aliased\let\figurescalewidth \figurewidth
+\aliased\let\figurescaleheight \figureheight
+\aliased\let\figurescalexscale \figurexscale
+\aliased\let\figurescaleyscale \figureyscale
+
+%D Abuse:
+%D
+%D \starttyping
+%D \externalfigure[rubish.pdf] \ifcase\figurestatus\relax \ctxlua{os.exit(999)} \fi
+%D \stoptyping
+
+%D Calculating:
+
+% \enabletrackers[figures.conversion]
+% \externalfigure[demo.svg]
+% \externalfigure[demo.svg][conversion=png]
+
+%D The following registers are used (if only to be downward compatible).
+
+\newconditional\c_grph_include_skip
+\newconditional\c_grph_include_test_only
+\newconditional\c_grph_include_level \setfalse\c_grph_include_level % true=background false=normal
+\newconditional\c_grph_include_flush \settrue \c_grph_include_flush % true=place false=ignore
+
+\newsystemmode\v!figure
+
+\def\grph_include_set_mode
+ {\ifcase\figurestatus
+ \globalresetsystemmode\v!figure % todo, also: \v!resource
+ \else
+ \globalsetsystemmode \v!figure % todo, also: \v!resource
+ \fi}
+
+\appendtoks
+ \clf_setfigurepaths
+ {\externalfigureparameter\c!location}%
+ {\externalfigureparameter\c!directory}%
+ \clf_figure_reset
+ \foundexternalfigure
+ \externalfigureparameter\c!defaultwidth
+ \externalfigureparameter\c!defaultheight
+ \relax
+\to \everyexternalfigureresets
+
+\appendtoks
+ \edef\p_option{\externalfigureparameter\c!option}%
+ \ifx\p_option\v!frame
+ \setfalse\c_grph_include_skip
+ \letexternalfigureparameter\c!frame\v!on
+ \orelse\ifx\p_option\v!empty
+ \settrue\c_grph_include_skip
+ \letexternalfigureparameter\c!frame\v!off
+ \else
+ \setfalse\c_grph_include_skip
+ \fi
+ % fake color in gray bitmaps, assumes that
+ % a transparent color is used
+ \edef\p_foregroundcolor{\externalfigureparameter\c!foregroundcolor}%
+ \ifempty\p_foregroundcolor \else
+ \setexternalfigureparameter\c!background{\v!foreground,\v!color}%
+ \letexternalfigureparameter\c!backgroundcolor\p_foregroundcolor
+ \fi
+\to \everyexternalfigurechecks
+
+%D Internal graphics are handled at the \TEX\ end:
+
+\def\grph_include_process_tex#1%
+ {\framed
+ [\c!strut=\v!no,\c!align=\v!normal,\c!frame=\v!off,
+ \c!offset=\v!overlay,\c!width=\v!fit,\c!height=\v!fit]
+ {\blank[\v!disable]#1\endgraf\removelastskip}} % disable should stay here!
+
+% used al lua end:
+
+\permanent\protected\def\docheckfigurebuffer #1{\global\setbox\foundexternalfigure\vpack{\grph_include_process_tex{\getbuffer[#1]}}}
+\permanent\protected\def\docheckfiguretex #1{\global\setbox\foundexternalfigure\vpack{\grph_include_process_tex{\input{#1}}}}
+\permanent\protected\def\docheckfigurecld #1{\global\setbox\foundexternalfigure\vbox {\cldprocessfile{#1}}}
+\permanent\protected\def\docheckfiguremps #1{\global\setbox\foundexternalfigure\vpack{\convertMPtoPDF{#1}11}}
+\permanent\protected\def\docheckfiguremprun #1#2{\global\setbox\foundexternalfigure\vpack{\useMPrun{#1}{#2}}}
+
+\permanent\protected\def\relocateexternalfigure
+ {\global\setbox\foundexternalfigure\vpack to \ht\foundexternalfigure\bgroup
+ %
+ % The \vss can (!) introduce 1 sp excess visible in xform which in itself
+ % is not that important but some don't like these cosmetic side effects, for
+ % instance we can get:
+ %
+ % vss : \vbox(845.1575+0.0)x597.23125, glue set 845.15747fil, direction TLT
+ % vskip : \vbox(845.1575+0.0)x597.23125, direction TLT
+ %
+ % or
+ %
+ % 1 0 0 1 0 0.00003 cm
+ % 1 0 0 1 0 0 cm
+ %
+ % This is a known property of using glue and can even depend on the architecture
+ % (float implementation). Anyway, let's for now use a skip. Of course this can
+ % shift the issue elsewhere, as vss is used a lot elsewhere.
+ %
+ % \vss
+ \vkern\ht\foundexternalfigure
+ %
+ \ht\foundexternalfigure\zeropoint
+ \dp\foundexternalfigure\zeropoint
+ \hpack to \wd\foundexternalfigure\bgroup
+ \box\foundexternalfigure
+ \hss
+ \egroup
+ \egroup}
+
+\permanent\protected\def\startfoundexternalfigure#1#2% ht wd
+ {\global\setbox\foundexternalfigure\vbox to #2\bgroup\vss\hbox to #1\bgroup}
+
+\permanent\protected\def\stopfoundexternalfigure
+ {\hss\egroup\egroup}
+
+\permanent\protected\def\emptyfoundexternalfigure % sort of obsolete
+ {\startfoundexternalfigure{\externalfigureparameter\c!defaultwidth}{\externalfigureparameter\c!defaultheight}%
+ \stopfoundexternalfigure}
+
+% \doifmodeelse{*\v!last}
+% {\settrue \c_grph_include_flush}
+% {\setfalse\c_grph_include_flush}%
+
+\def\grph_include_finalize
+ {\global\setbox\foundexternalfigure\vbox
+ {\ifcase\figurestatus
+ \letexternalfigureparameter\c!frame\v!on
+ \fi
+ \ifconditional\c_grph_include_flush
+ \ifconditional\c_grph_include_level % probably background
+ \ifconditional\c_grph_include_skip
+ % nothing
+ \fakebox\foundexternalfigure
+ \orelse\ifcase\figurestatus
+ % nothing
+ \else
+ \the\externalfigurepostprocessors
+ \box\foundexternalfigure
+ \fi
+ \else
+ \iftrialtypesetting \else \feedbackexternalfigure \fi
+ \settrue\c_grph_include_level
+ \ifconditional\c_grph_include_skip
+ \ifcase\figurestatus
+ \grph_include_replacement\figurelabel\figurefileoriginal{unknown}%
+ \else
+ \grph_include_replacement\figurelabel\figurefullname{skipped}%
+ \fi
+ \orelse\ifcase\figurestatus
+ \grph_include_replacement\figurelabel\figurefileoriginal{unknown}%
+ \else
+ \the\externalfigurepostprocessors
+ \edef\p_reset{\externalfigureparameter\c!reset}%
+ \ifx\p_reset\v!yes
+ \wd\foundexternalfigure\figurewidth
+ \ht\foundexternalfigure\figureheight
+ \dp\foundexternalfigure\zeropoint
+ \box\foundexternalfigure
+ \else
+ \letexternalfigureparameter\c!offset\v!overlay
+ \letexternalfigureparameter\c!width \figurewidth
+ \letexternalfigureparameter\c!height\figureheight
+ \inheritedexternalfigureframed{\box\foundexternalfigure}%
+ \fi
+ \fi
+ \fi
+ \else
+ % maybe also \the\externalfigurepostprocessors
+ \iftrialtypesetting \else \feedbackexternalfigure \fi
+ \fi}}
+
+\mutable\let\feedbackexternalfigure\relax % hook
+
+\permanent\protected\def\getfiguredimensions
+ {\dodoubleempty\grph_include_get_dimensions}
+
+\def\grph_include_get_dimensions[#1][#2]%
+ {\startnointerference
+ \settrue\c_grph_include_test_only
+ \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]%
+ \stopnointerference}
+
+\permanent\protected\def\doifelsefigure#1%
+ {\getfiguredimensions[#1]% so data is available !
+ \ifcase\figurestatus
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\aliased\let\doiffigureelse\doifelsefigure
+
+% No placement, handy for preprocessing:
+
+\permanent\tolerant\protected\def\registerexternalfigure[#1]#*[#2]#*[#3]%
+ {\startnointerference
+ \c_grph_include_test_only
+ \setfalse\c_grph_include_flush % == test ?
+ \externalfigure[#1][#2][#3]% or
+ \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]%
+ \stopnointerference}
+
+% Helpers will be replaced when xforms are accessible at the lua end but then
+% we need to do the object offset there too.
+
+\permanent\protected\def\dosetfigureobject#1#2%
+ {\setobject{#1}{#2}\vpack{\box\foundexternalfigure}}
+
+\permanent\protected\def\doboxfigureobject#1#2%
+ {\global\setbox\foundexternalfigure\vpack{\getobject{#1}{#2}}} % probably one vbox too many
+
+% Figure bases
+
+\permanent\protected\def\usefigurebase[#1]%
+ {\clf_usefigurebase{#1}}
+
+\appendtoks
+ \setfigurepathlist % the path may be used elsewhere too (as in x-res-04)
+\to \everysetupexternalfigure
+
+\appendtoks
+ \clf_setfigurelookuporder{\externalfigureparameter\c!order}%
+\to \everysetupexternalfigure
+
+\definecolor[missingfigurecolor][s=.8]
+
+\def\grph_include_replacement#1#2#3%
+ {\bgroup
+ \letexternalfigureparameter\c!width\figurewidth
+ \letexternalfigureparameter\c!height\figureheight
+ \letexternalfigureparameter\c!background\v!color
+ \setexternalfigureparameter\c!backgroundcolor{missingfigurecolor}%
+ \setexternalfigureparameter\c!align{\v!middle,\v!lohi}% we default to \v!none
+ \inheritedexternalfigureframed
+ {\tt\tfxx \nohyphens
+ name: \expanded{\verbatimstring{#1}}\\%
+ file: \expanded{\verbatimstring{#2}}\\%
+ state: \expanded{\verbatimstring{#3}}}%
+ \egroup}
+
+% maybe setuphandler
+
+\newconditional\c_grph_include_in_collection
+
+\newdimen\d_grph_include_collection_minwidth
+\newdimen\d_grph_include_collection_maxwidth
+\newdimen\d_grph_include_collection_minheight
+\newdimen\d_grph_include_collection_maxheight
+
+\def\grph_include_analyze_collection[#1][#2]%
+ {\ifconditional\c_grph_include_in_collection
+ \setfalse\c_grph_include_in_collection
+ \getfiguredimensions[#1][#2]%
+ \settrue\c_grph_include_in_collection
+ \scratchdimen\naturalfigurewidth
+ \ifdim\scratchdimen>\d_grph_include_collection_maxwidth \d_grph_include_collection_maxwidth \scratchdimen \fi
+ \ifdim\scratchdimen<\d_grph_include_collection_minwidth \d_grph_include_collection_minwidth \scratchdimen \fi
+ \scratchdimen\naturalfigureheight
+ \ifdim\scratchdimen>\d_grph_include_collection_maxheight \d_grph_include_collection_maxheight\scratchdimen \fi
+ \ifdim\scratchdimen<\d_grph_include_collection_minheight \d_grph_include_collection_minheight\scratchdimen \fi
+ \fi}
+
+\mutable\let\currentexternalfigurecollection\empty
+
+\permanent\protected\def\startexternalfigurecollection[#1]%
+ {\begingroup
+ \def\currentexternalfigurecollection{#1}%
+ \settrue\c_grph_include_in_collection
+ \d_grph_include_collection_minwidth \maxdimen
+ \d_grph_include_collection_maxwidth \zeropoint
+ \d_grph_include_collection_minheight\maxdimen
+ \d_grph_include_collection_maxheight\zeropoint}
+
+\permanent\protected\def\stopexternalfigurecollection
+ {\xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!minwidth \endcsname{\the\d_grph_include_collection_minwidth }%
+ \xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!maxwidth \endcsname{\the\d_grph_include_collection_maxwidth }%
+ \xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!minheight\endcsname{\the\d_grph_include_collection_minheight}%
+ \xdefcsname\??externalfigurecollection\currentexternalfigurecollection:\c!maxheight\endcsname{\the\d_grph_include_collection_maxheight}%
+ \endgroup}
+
+\permanent\def\externalfigurecollectionparameter#1#2%
+ {\csname
+ \ifcsname\??externalfigurecollection#1:#2\endcsname
+ \??externalfigurecollection#1:#2%
+ \else
+ \s!empty
+ \fi
+ \endcsname}
+
+\permanent\def\externalfigurecollectionminwidth #1{\externalfigurecollectionparameter{#1}\c!minwidth }
+\permanent\def\externalfigurecollectionmaxwidth #1{\externalfigurecollectionparameter{#1}\c!maxwidth }
+\permanent\def\externalfigurecollectionminheight#1{\externalfigurecollectionparameter{#1}\c!minheight}
+\permanent\def\externalfigurecollectionmaxheight#1{\externalfigurecollectionparameter{#1}\c!maxheight}
+
+\aliased\let\efcparameter\externalfigurecollectionparameter % still needed ?
+\aliased\let\efcminwidth \externalfigurecollectionminwidth % still needed ?
+\aliased\let\efcmaxwidth \externalfigurecollectionmaxwidth % still needed ?
+\aliased\let\efcminheight\externalfigurecollectionminheight % still needed ?
+\aliased\let\efcmaxheight\externalfigurecollectionmaxheight % still needed ?
+
+% \startexternalfigurecollection[name]
+% \useexternalfigure[cow] [cow.pdf]
+% \useexternalfigure[mill][mill.png]
+% \stopexternalfigurecollection
+% \starttext
+% \bTABLE
+% \bTR
+% \bTD \externalfigure[cow] [height=\externalfigurecollectionmaxheight{name}] \eTD
+% \bTD \externalfigure[mill][height=\externalfigurecollectionmaxheight{name}] \eTD
+% \eTR
+% \eTABLE
+% \stoptext
+
+\permanent\protected\def\overlayfigure#1%
+ {\externalfigure[#1][\c!width=\d_overlay_width,\c!height=\d_overlay_height]}
+
+% Experimental (will become cleaner):
+
+\permanent\tolerant\protected\def\includesvgfile[#1]#*[#2]%
+ {\dontleavehmode\begingroup
+ \getdummyparameters[\c!offset=\zeropoint,#2]%
+ \clf_includesvgfile{#1}\dimexpr\dummyparameter\c!offset\relax
+ \endgroup}
+
+\permanent\tolerant\protected\def\includesvgbuffer[#1]#*[#2]%
+ {\dontleavehmode\begingroup
+ \getdummyparameters[\c!offset=\zeropoint,#2]%
+ \clf_includesvgbuffer{#1}\dimexpr\dummyparameter\c!offset\relax
+ \endgroup}
+
+% Bonus:
+
+\useexternalfigure
+ [\v!buffer]
+ [\jobname.buffer]
+ [\c!object=\v!no]
+
+% Another two:
+
+\defineexternalfigure
+ [\v!inline]
+ [\c!height=\lineheight]
+
+\definemeasure
+ [\v!combination]
+ [(\textwidth
+ -\effectiveleftskip
+ -\effectiverightskip
+ -\numexpr\combinationparameter\c!nx-\plusone\relax\dimexpr\combinationparameter\c!distance\relax
+ )/\combinationparameter\c!nx]
+
+\defineexternalfigure
+ [\v!combination]
+ [\c!width=\measure{\v!combination}]
+
+% \startcombination[nx=2,ny=1]
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% \stopcombination
+
+% \startcombination[nx=2,ny=1]
+% {\externalfigure[dummy][width=\measure{combination}]} {}
+% {\externalfigure[dummy][width=\measure{combination}]} {}
+% \stopcombination
+
+% \startcombination[nx=2,ny=2]
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% \stopcombination
+
+% \startcombination[nx=3,ny=1]
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% \stopcombination
+
+% \startcombination[nx=4,ny=1]
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% {\externalfigure[dummy][combination]} {}
+% \stopcombination
+
+\permanent\protected\def\inlinefigure[#1]%
+ {\dontleavehmode
+ \sbox{\externalfigure[#1][\v!inline]}}
+
+%D Needs to be done global:
+
+\definelayer[epdfcontent]
+
+\protect \endinput
+
+%D Moved here because this already old code is nowhere documents (so I need to check
+%D it:
+%
+% \starttyping
+% \starttext
+%
+% \startluaparameterset [u3d:myset:controls:1]
+% view = {
+% name = 'default',
+% bg = {1,1,1},
+% mag = 100,
+% coo = {0,0,0},
+% c2c = {0,0,1},
+% rot = {40,0,60},
+% roo = 6,
+% lights = 'CAD'
+% },
+% js = 'cloudq.js'
+% \stopluaparameterset
+%
+% \startluaparameterset [u3d:myset:controls:2]
+% views = {
+% {
+% name = 'AnglePositioning',
+% bg = {1,1,1},
+% azimuth = 45,
+% altitude = 45,
+% roo = 50,
+% aac = 2.5,
+% lights = 'Artwork'
+% },
+% {
+% name = 'RotationPositioning',
+% bg = {1,1,1},
+% rot = {0,45,45},
+% roo = 50,
+% aac = 2.5,
+% lights = 'Artwork'
+% },
+% {
+% name = 'VectorPositioning',
+% bg = {1,0,0},
+% c2c = {1,1,math.sqrt(2)},
+% roo = 50,
+% aac = 2.5,
+% lights = 'CAD'
+% },
+% {
+% name = 'PositionPositioning',
+% bg = {1,0,0},
+% pos = {1+25,1+25,1+50/math.sqrt(2)},
+% aac = 2.5,
+% lights = 'CAD'
+% },
+% {
+% name = 'ortho',
+% bg = {1,1,1},
+% mag = 300,
+% lights = 'CAD',
+% crossection = {}
+% }
+% },
+% view = {
+% name = 'default',
+% bg = {1,1,1},
+% c2c = {-1,-1,0},
+% roo = 50,
+% aac = 2.5,
+% roll = 45,
+% lights = 'CAD',
+% crossection = {
+% normal = {-1,-1,-1},
+% transparent = true
+% },
+% nodes = {
+% {
+% name = 'xlabel',
+% visible = false
+% },
+% {
+% name = 'ylabel',
+% opacity = 0.5
+% },
+% {
+% name = 'zlabel',
+% rendermode = 'Wireframe'
+% }
+% }
+% }
+% \stopluaparameterset
+%
+% \useexternalfigure
+% [cloudq]
+% [cloudq.u3d]
+% [width=0.7\textwidth,
+% height=.7\textwidth,
+% display=u3d:myset:display:1,
+% controls=u3d:myset:controls:1]
+%
+% \useexternalfigure
+% [axes]
+% [axes.u3d]
+% [width=0.7\textwidth,
+% height=.7\textwidth,
+% controls=u3d:myset:controls:1]
+%
+% \startluaparameterset[u3d:myset:display:2]
+% toolbar = true,
+% preview = 'cloudq.png'
+% \stopluaparameterset
+% \startluaparameterset[u3d:myset:display:3]
+% toolbar = true,
+% tree = false,
+% preview = 'axes.png'
+% \stopluaparameterset
+% \startluaparameterset[u3d:myset:display:4]
+% toolbar = true,
+% tree = false,
+% view = {
+% name = 'view',
+% bg = {0.1,0.1,0.1},
+% c2c = {-1,-1,0},
+% roo = 50,
+% aac = 2.5,
+% roll = 45,
+% lights = 'Red'
+% }
+% \stopluaparameterset
+% \startluaparameterset[u3d:myset:display:5]
+% toolbar = true,
+% tree = false,
+% view = 'ortho'
+% \stopluaparameterset
+%
+% \placefigure[here]{none}{\externalfigure[cloudq][frame=on,display=u3d:myset:display:2]}
+% \placefigure[here]{none}{\externalfigure[axes] [frame=on,display=u3d:myset:display:3]}
+% \placefigure[here]{none}{\externalfigure[axes] [frame=on,display=u3d:myset:display:4]}
+% \placefigure[here]{none}{\externalfigure[axes] [frame=on,display=u3d:myset:display:5,width=0.5\textwidth,height=.5\textwidth]}
+%
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-pat.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-pat.mkxl
new file mode 100644
index 00000000000..92fd5ad749a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-pat.mkxl
@@ -0,0 +1,119 @@
+%D \module
+%D [ file=grph-par,
+%D version=2016.07.08,
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Patterns,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This works ok in Okular and MuPDF but somehow xforms don't work in Acrobat
+%D (full nor reader). Also the basic offset is kind of unspecified. So \unknown\
+%D we're dealing with a fragile feature. So, don't rely on where the first (ulr)
+%D tile occurs.
+%D
+%D The two commands introduced here are not documented (yet).
+
+\writestatus{loading}{ConTeXt Graphic Macros / Patterns}
+
+\unprotect
+
+\registerctxluafile{grph-pat}{}
+
+\permanent\tolerant\protected\def\registerpattern[#1]#*[#2]%
+ {\begingroup
+ \letdummyparameter\c!name \s!dummy
+ \letdummyparameter\c!width \v!auto
+ \letdummyparameter\c!height \v!auto
+ \letdummyparameter\c!hoffset\zeropoint
+ \letdummyparameter\c!voffset\zeropoint
+ \unless\iftok{#2}\emptytoks
+ \setdummyparameter\c!name{#1}%
+ \getdummyparameters[#2]%
+ \orelse\ifhastok={#1}%
+ \getdummyparameters[#1]%
+ \else
+ \setdummyparameter\c!name{#1}%
+ \fi
+ \dowithnextboxcs\syst_boxes_registerpattern_indeed\hbox}
+
+\immutable\edef\v!auto_m{-\v!auto}
+
+\def\syst_boxes_registerpattern_indeed
+ {%\finalizeobjectbox\nextbox
+ \edef\p_width {\dummyparameter\c!width}%
+ \edef\p_height {\dummyparameter\c!height}%
+ \edef\p_hoffset{\dummyparameter\c!hoffset}%
+ \edef\p_voffset{\dummyparameter\c!voffset}%
+ \scratchwidth \dimexpr\ifx\p_width \v!auto\wd \nextbox\else\p_width \fi\relax
+ \scratchheight \dimexpr\ifx\p_height \v!auto\htdp\nextbox\else\p_height \fi\relax
+ \scratchhoffset\dimexpr\ifx\p_hoffset\v!auto\scratchwidth /2\orelse\ifx\p_hoffset\v!auto_m-\scratchwidth /2\else\p_hoffset\fi\relax
+ \scratchvoffset\dimexpr\ifx\p_voffset\v!auto\scratchheight/2\orelse\ifx\p_voffset\v!auto_m-\scratchheight/2\else\p_voffset\fi\relax
+ \clf_registerpattern
+ name {\dummyparameter\c!name}
+ number \nextbox
+ width \scratchwidth
+ height \scratchheight
+ hoffset \scratchhoffset
+ voffset \scratchvoffset
+ \relax
+ \endgroup}
+
+\permanent\tolerant\protected\def\applypattern[#1]#*[#2]%
+ {\hbox\bgroup
+ \letdummyparameter\c!name \s!dummy
+ \letdummyparameter\c!width \zeropoint
+ \letdummyparameter\c!height\zeropoint
+ \unless\iftok{#2}\emptytoks
+ \setdummyparameter\c!name{#1}%
+ \getdummyparameters[#2]%
+ \orelse\ifhastok={#1}%
+ \getdummyparameters[#1]%
+ \else
+ \setdummyparameter\c!name{#1}%
+ \fi
+ \clf_applypattern
+ name {\dummyparameter\c!name}
+ number \nextbox
+ width \dimexpr\dummyparameter\c!width\relax
+ height \dimexpr\dummyparameter\c!height\relax
+ \relax
+ \box\nextbox
+ \egroup}
+
+\protect
+
+\continueifinputfile{grph-pat.mkxl}
+
+\nopdfcompression
+
+\starttext
+
+ \registerpattern[demo]{It \darkred Works!}
+
+ \framed[offset=overlay]{\applypattern[demo][width=7cm,height=4cm]}
+
+ \blank
+
+ \registerpattern[name=more,hoffset=0bp,voffset=0pt]{\externalfigure[cow.pdf][width=1cm]}
+
+ \framed[offset=overlay]{\applypattern[name=more,width=7cm,height=4cm]}
+
+ \blank
+
+ \registerpattern[name=more,hoffset=auto,voffset=auto]{\externalfigure[cow.pdf][width=1cm]}
+
+ \framed[offset=overlay]{\applypattern[name=more,width=7cm,height=4cm]}
+
+ \blank
+
+ \registerpattern[name=more,hoffset=-auto,voffset=-auto]{\externalfigure[cow.pdf][width=1cm]}
+
+ \framed[offset=overlay]{\applypattern[name=more,width=7cm,height=4cm]}
+
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-raw.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-raw.mkxl
new file mode 100644
index 00000000000..66194551bfc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-raw.mkxl
@@ -0,0 +1,64 @@
+%D \module
+%D [ file=grph-raw,
+%D version=2006.08.26, % overhaul of 1997.03.31
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Raw Bitmaps,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Graphic Macros / Raw Bitmaps}
+
+%D \startluacode
+%D function document.TestBitmap(nx,ny)
+%D local random = math.random
+%D local maxbit = 2^24
+%D for i=1,nx do
+%D for i=1,ny do
+%D context("%06x",random(0,maxbit))
+%D end
+%D end
+%D end
+%D \stopluacode
+%D
+%D \def\TestBitmap#1#2{\ctxlua{document.TestBitmap(#1,#2)}}
+%D
+%D \blank
+%D
+%D \startMPcode
+%D draw textext("\bitmapimage[x=100,y=100]{\TestBitmap{100}{100}}") xsized 10cm ;
+%D \stopMPcode
+%D
+%D \blank
+%D
+%D \startMPcode
+%D draw textext("\bitmapimage[x=200,y=50]{\TestBitmap{50}{200}}") xsized 10cm ;
+%D \stopMPcode
+
+\registerctxluafile{grph-raw}{}
+
+\unprotect
+
+\permanent\protected\def\bitmapimage[#1]#2%
+ {\hbox\bgroup
+ \getdummyparameters[\c!color=rgb,\c!width=,\c!height=,\c!x=,\c!y=,#1]%
+ \clf_bitmapimage
+ data {#2}%
+ colorspace {\directdummyparameter\c!color}%
+ width {\directdummyparameter\c!width}%
+ height {\directdummyparameter\c!height}%
+ xresolution {\directdummyparameter\c!x}%
+ yresolution {\directdummyparameter\c!y}%
+ \relax
+ \egroup}
+
+\permanent\protected\def\startbitmapimage[#1]#2\stopbitmapimage
+ {\bitmapimage[#1]{#2}}
+
+\aliased\let\stopbitmapimage\relax
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-rul.lmt b/Master/texmf-dist/tex/context/base/mkxl/grph-rul.lmt
new file mode 100644
index 00000000000..d8da5f76054
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-rul.lmt
@@ -0,0 +1,124 @@
+if not modules then modules = { } end modules ['grph-rul'] = {
+ version = 1.001,
+ comment = "companion to grph-rul.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local attributes = attributes
+local nodes = nodes
+local context = context
+
+local nuts = nodes.nuts
+local nodepool = nuts.pool
+local userrule = nuts.rules.userrule
+local outlinerule = nuts.pool.outlinerule
+local ruleactions = nuts.rules.ruleactions
+
+local setattrlist = nuts.setattrlist
+local setattr = nuts.setattr
+local tonode = nuts.tonode
+
+local getattribute = tex.getattribute
+
+local a_color = attributes.private('color')
+local a_transparency = attributes.private('transparency')
+local a_colormodel = attributes.private('colormodel')
+
+local floor = math.floor
+local getrandom = utilities.randomizer.get
+
+do
+
+ local function unsupported() end
+
+ ruleactions.mp = unsupported
+ ruleactions.fill = unsupported
+ ruleactions.draw = unsupported
+ ruleactions.stroke = unsupported
+ ruleactions.box = unsupported
+
+end
+
+interfaces.implement {
+ name = "frule",
+ arguments = { {
+ { "width", "dimension" },
+ { "height", "dimension" },
+ { "depth", "dimension" },
+ { "radius", "dimension" },
+ { "line", "dimension" },
+ { "type", "string" },
+ { "data", "string" },
+ { "name", "string" },
+ { "radius", "dimension" },
+ { "corner", "string" },
+ } } ,
+ actions = function(t)
+ local rule = userrule(t)
+ if t.type == "mp" then
+ t.ma = getattribute(a_colormodel) or 1
+ t.ca = getattribute(a_color)
+ t.ta = getattribute(a_transparency)
+ else
+ setattrlist(rule,true)
+ end
+ context(tonode(rule)) -- will become context.nodes.flush
+ end
+}
+
+interfaces.implement {
+ name = "outlinerule",
+ public = true,
+ protected = true,
+ arguments = { {
+ { "width", "dimension" },
+ { "height", "dimension" },
+ { "depth", "dimension" },
+ { "line", "dimension" },
+ } } ,
+ actions = function(t)
+ local rule = outlinerule(t.width,t.height,t.depth,t.line)
+ setattrlist(rule,true)
+ context(tonode(rule)) -- will become context.nodes.flush
+ end
+}
+
+interfaces.implement {
+ name = "framedoutline",
+ arguments = { "dimension", "dimension", "dimension", "dimension" },
+ actions = function(w,h,d,l)
+ local rule = outlinerule(w,h,d,l)
+ setattrlist(rule,true)
+ context(tonode(rule)) -- will become context.nodes.flush
+ end
+}
+
+interfaces.implement {
+ name = "fakeword",
+ arguments = { {
+ { "factor", "dimension" },
+ { "name", "string" }, -- can be type
+ { "min", "dimension" },
+ { "max", "dimension" },
+ { "n", "integer" },
+ } } ,
+ actions = function(t)
+ local factor = t.factor or 0
+ local amount = getrandom("fakeword",t.min,t.max)
+ local rule = userrule {
+ height = 1.25*factor,
+ depth = 0.25*factor,
+ width = floor(amount/10000) * 10000,
+ line = 0.10*factor,
+ ma = getattribute(a_colormodel) or 1,
+ ca = getattribute(a_color),
+ ta = getattribute(a_transparency),
+ type = "mp",
+ name = t.name,
+ }
+ setattrlist(rule,true)
+ context(tonode(rule))
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-rul.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-rul.mkxl
new file mode 100644
index 00000000000..034e91734e3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-rul.mkxl
@@ -0,0 +1,89 @@
+%D \module
+%D [ file=grph-rul,
+%D version=2016.02.05, % from experiments
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Rule Trickery,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Graphic Macros / Rule Trickery}
+
+\registerctxluafile{grph-rul}{autosuffix}
+
+\unprotect
+
+\permanent\protected\def\frule{\relax\clf_frule} % will become a public implementer
+
+% just for fun:
+
+% \defineoverlay[normalframe]
+% [\frule
+% width \overlaywidth
+% height\overlayheight
+% line \overlaylinewidth
+% \relax]
+
+% \defineoverlay[ovalframe]
+% [\frule
+% width \overlaywidth
+% height \overlayheight
+% line \overlaylinewidth
+% radius \overlayradius
+% \relax]
+
+\protect \endinput
+
+% \starttext
+%
+% \testfeatureonce{25}{\dontleavehmode
+% \ruledhbox\bgroup
+% \red \frule width 2cm height 2cm depth 1cm radius 2mm line 2pt type fill\relax
+% \hskip-2cm
+% \green \frule width 2cm height 2cm depth 1cm radius 2mm line 2pt\relax
+% \egroup
+% \space}
+%
+% \blank
+%
+% \startuseMPgraphic{demoshape:back}
+% fill
+% unitcircle xysized (RuleWidth,RuleHeight+RuleDepth)
+% withcolor RuleColor ;
+% \stopuseMPgraphic
+%
+% \startuseMPgraphic{demoshape:fore}
+% draw
+% unitcircle xysized (RuleWidth,RuleHeight+RuleDepth)
+% withcolor RuleColor
+% withpen pencircle scaled RuleThickness ;
+% \stopuseMPgraphic
+%
+% \testfeatureonce{100}{\dontleavehmode
+% \ruledhbox\bgroup
+% \red \frule width 1cm height 3mm depth 1mm type mp line 2pt data {\includeMPgraphic{demoshape:back}}\relax
+% \hskip-1cm
+% \green \frule width 1cm height 3mm depth 1mm type mp line 2pt data {\includeMPgraphic{demoshape:fore}}\relax
+% \egroup
+% \space}
+%
+% \blank
+%
+% \dontleavehmode
+% \testfeatureonce{1}{\setbox\scratchbox\hbox{\framed {test}}}
+% \framed {test}
+% \testfeatureonce{1}{\setbox\scratchbox\hbox{\framed[background=normalframe,frame=off]{test}}}
+% \framed[background=normalframe,frame=off]{test}
+% \testfeatureonce{1}{\setbox\scratchbox\hbox{\framed[corner=round] {test}}}
+% \framed[corner=round] {test}
+% \testfeatureonce{1}{\setbox\scratchbox\hbox{\framed[background=ovalframe,frame=off] {test}}}
+% \framed[background=ovalframe,frame=off] {test}
+% \testfeatureonce{1}{\setbox\scratchbox\hbox{\framed[background=ovalframe,frame=on] {test}}}
+% \framed[background=ovalframe,frame=on] {test}
+%
+% \stoptext
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-trf.lmt b/Master/texmf-dist/tex/context/base/mkxl/grph-trf.lmt
new file mode 100644
index 00000000000..f68d6a6a807
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-trf.lmt
@@ -0,0 +1,126 @@
+if not modules then modules = { } end modules ['grph-trf'] = {
+ version = 1.001,
+ comment = "companion to grph-trf.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- see grph-trf-todo.lua for older preliminary code for the rest
+
+local sind, cosd, tand, abs = math.sind, math.cosd, math.tand, math.abs
+
+local setdimension = tex.setdimensionvalue
+
+local function analyzerotate(rotation,width,height,depth,total,notfit,obeydepth)
+ --
+ -- print(rotation,width,height,depth,notfit,obeydepth)
+ --
+ local sin = sind(rotation)
+ local cos = cosd(rotation)
+ local abssin = abs(sin)
+ local abscos = abs(cos)
+ local xsize = 0
+ local ysize = 0
+ local xposition = 0
+ local yposition = 0
+ local xoffset = 0
+ local yoffset = 0
+ local newwidth = width
+ local newheight = height
+ local newdepth = depth
+ -- print(sin,cos)
+ if sin > 0 then
+ if cos > 0 then
+ xsize = cos * width + sin * total
+ ysize = sin * width + cos * total
+ yposition = cos * total
+ if notfit then
+ xoffset = - sin * height
+ newwidth = sin * depth + cos * width
+ else
+ newwidth = xsize + xposition - xoffset
+ end
+ if obeydepth then
+ yoffset = cos * depth
+ end
+ newheight = ysize - yoffset
+ newdepth = yoffset
+ -- print("case 1, done")
+ else
+ xsize = abscos * width + sin * total
+ ysize = sin * width + abscos * total
+ xposition = abscos * width
+ if notfit then
+ xoffset = - xsize + sin * depth
+ end
+ if obeydepth then
+ yoffset = abscos * height
+ newwidth = abssin * total + abscos * width + xoffset
+ else
+ newwidth = xsize
+ end
+ newheight = ysize - yoffset
+ newdepth = yoffset
+ -- print("case 2, done")
+ end
+ else
+ if cos < 0 then
+ xsize = abscos * width + abssin * total
+ ysize = abssin * width + abscos * total
+ xposition = xsize
+ yposition = abssin * width
+ if notfit then
+ xoffset = - xsize + abssin * height
+ end
+ if obeydepth then
+ yoffset = ysize + cos * depth
+ end
+ newwidth = notfit and (abssin * height) or xsize
+ newheight = ysize - yoffset
+ newdepth = yoffset
+ -- print("case 3, done")
+ else
+ xsize = cos * width + abssin * total
+ ysize = abssin * width + cos * total
+ xposition = abssin * total
+ yposition = cos * total
+ if notfit then
+ xoffset = - abssin * depth
+ newwidth = xsize + xoffset
+ else
+ newwidth = xsize
+ end
+ if obeydepth then
+ yoffset = cos * depth
+ end
+ newheight = ysize - yoffset + sin * width
+ newdepth = yoffset - sin * width
+ -- print("case 4, done")
+ end
+ end
+ setdimension("d_grph_rotate_x_size", xsize)
+ setdimension("d_grph_rotate_y_size", ysize)
+ setdimension("d_grph_rotate_x_position", xposition)
+ setdimension("d_grph_rotate_y_position", yposition)
+ setdimension("d_grph_rotate_x_offset", xoffset)
+ setdimension("d_grph_rotate_y_offset", yoffset)
+ setdimension("d_grph_rotate_new_width", newwidth)
+ setdimension("d_grph_rotate_new_height", newheight)
+ setdimension("d_grph_rotate_new_depth", newdepth)
+end
+
+interfaces.implement {
+ name = "analyzerotate",
+ actions = analyzerotate,
+ arguments = {
+-- "integer",
+ "number",
+ "dimension",
+ "dimension",
+ "dimension",
+ "dimension",
+ "conditional",
+ "conditional",
+ },
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/grph-trf.mkxl b/Master/texmf-dist/tex/context/base/mkxl/grph-trf.mkxl
new file mode 100644
index 00000000000..c7e0f5e2f21
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/grph-trf.mkxl
@@ -0,0 +1,1003 @@
+%D \module
+%D [ file=grph-trf,
+%D version=2006.08.26, % overhaul/split of 1997.03.31 core-fig
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Transformations,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Graphic Macros / Transformations}
+
+\unprotect
+
+%D We probably use too many dimens as the width calculations can go away. Some of
+%D this is an inheritance of limited backends (some supported fractions, some
+%D 1000's, some dimentions) so we calculate all of them. Nowadays scaling is always
+%D available so we could simplify the code. On the other hand, we now get some extra
+%D values for free.
+%D
+%D We could move the calculations to \LUA\ and clean up this lot anyway. On the
+%D other hand, there is some danger of messing up so it has a real low priority.
+
+\registerctxluafile{grph-trf}{autosuffix}
+
+% local:
+
+\newdimen\d_grph_scale_x_size
+\newdimen\d_grph_scale_y_size
+\newdimen\d_grph_scale_x_offset
+\newdimen\d_grph_scale_y_offset
+
+\newdimen\d_grph_scale_h_size
+\newdimen\d_grph_scale_v_size
+
+\newconditional\c_grph_scale_done
+\newconditional\c_grph_scale_scaling_done
+\newconditional\c_grph_scale_limit_factors \settrue\c_grph_scale_limit_factors
+
+\newconditional\c_grph_scale_swap_factor
+
+\newdimen\d_grph_scale_wd
+\newdimen\d_grph_scale_ht
+\newdimen\d_grph_scale_dp
+
+% global
+
+\newdimen\d_grph_scale_used_x_size
+\newdimen\d_grph_scale_used_y_size
+
+\newcount\c_grph_scale_used_x_scale
+\newcount\c_grph_scale_used_y_scale
+
+\let \m_grph_scale_used_x_scale\!!plusone
+\let \m_grph_scale_used_y_scale\!!plusone
+
+\newdimen\d_grph_scale_outer_v_size % we cannot manipulate any global vsize !
+
+% scratch:
+
+\let\m_grph_scale_temp \empty
+\let\m_grph_scale_temp_x\empty
+\let\m_grph_scale_temp_y\empty
+
+% public:
+
+\mutable\let\finalscaleboxxscale \!!plusone
+\mutable\let\finalscaleboxyscale \!!plusone
+\mutable\let\finalscaleboxwidth \!!zeropoint
+\mutable\let\finalscaleboxheight \!!zeropoint
+
+% we can let sx/sy win (first check)
+
+\installcorenamespace{scale}
+\installcorenamespace{scalegrid}
+\installcorenamespace{scalenorm}
+\installcorenamespace{scalefact}
+
+\installcommandhandler \??scale {scale} \??scale % we can have instances
+
+\setupscale
+ [\c!sx=\scaleparameter\c!s,
+ \c!sy=\scaleparameter\c!s,
+ \c!s=1,
+ %\c!scale=,
+ %\c!xscale=,
+ %\c!yscale=,
+ %\c!width=,
+ %\c!height=,
+ %\c!lines=,
+ %\c!factor=,
+ %\c!hfactor=,
+ %\c!wfactor=,
+ %\c!grid=,
+ %\c!equalwidth=,
+ %\c!equalheight=,
+ \c!maxwidth=\scaleparameter\c!width,
+ \c!maxheight=\scaleparameter\c!height]
+
+\permanent\tolerant\protected\def\scale[#1]#*[#2]%
+ {\bgroup
+ % this is quite common so we might make this a helper
+ \ifarguments
+ \let\currentscale\empty
+ \or
+ \ifhastok={#1}%
+ \let\currentscale\empty
+ \setupcurrentscale[#1]%
+ \else
+ \edef\currentscale{#1}%
+ \fi
+ \or
+ \edef\currentscale{#1}%
+ \setupcurrentscale[#2]%
+ \fi
+ %
+ \dowithnextboxcs\grph_scale_finish\hbox}
+
+\def\grph_scale_finish
+ {% todo: p_scale_
+ \edef\p_scale {\scaleparameter\c!scale }%
+ \edef\p_xscale {\scaleparameter\c!xscale }%
+ \edef\p_yscale {\scaleparameter\c!yscale }%
+ \edef\p_width {\scaleparameter\c!width }%
+ \edef\p_height {\scaleparameter\c!height }%
+ \edef\p_depth {\scaleparameter\c!depth }%
+ \edef\p_lines {\scaleparameter\c!lines }%
+ \edef\p_factor {\scaleparameter\c!factor }%
+ \edef\p_hfactor {\scaleparameter\c!hfactor }%
+ \edef\p_wfactor {\scaleparameter\c!wfactor }%
+ % \edef\p_grid {\scaleparameter\c!grid }% used once
+ \edef\p_maxwidth {\scaleparameter\c!maxwidth }%
+ \edef\p_maxheight {\scaleparameter\c!maxheight }%
+ \edef\p_sx {\scaleparameter\c!sx }%
+ \edef\p_sy {\scaleparameter\c!sy }%
+ \edef\p_equalwidth {\scaleparameter\c!equalwidth }%
+ \edef\p_equalheight{\scaleparameter\c!equalheight}%
+ %
+ \d_grph_scale_dp\dp\nextbox
+ \ifx\p_depth\v!no \ifzeropt\d_grph_scale_dp \else
+ \setbox\nextbox\naturalhpack{\raise\d_grph_scale_dp\box\nextbox}% new
+ \d_grph_scale_dp\dp\nextbox
+ \fi \fi
+ \d_grph_scale_wd\wd\nextbox
+ \d_grph_scale_ht\ht\nextbox
+ \d_grph_scale_dp\dp\nextbox
+ %
+ \glet\finalscaleboxxscale \!!plusone
+ \glet\finalscaleboxyscale \!!plusone
+ \xdef\finalscaleboxwidth {\the\d_grph_scale_wd}%
+ \xdef\finalscaleboxheight{\the\d_grph_scale_ht}%
+ %
+ \forgetall
+ \dontcomplain
+ %
+ \setfalse\c_grph_scale_done
+ \grph_scale_calculate
+ \ifconditional\c_grph_scale_done
+ \grph_scale_apply
+ \fi
+ \grph_scale_position
+ %
+ \box\nextbox
+ \egroup}
+
+\def\grph_scale_apply
+ {\d_grph_scale_wd\finalscaleboxxscale\d_grph_scale_wd
+ \d_grph_scale_ht\finalscaleboxyscale\d_grph_scale_ht
+ \d_grph_scale_dp\finalscaleboxyscale\d_grph_scale_dp
+ \ifdim\d_grph_scale_wd=\wd\nextbox
+ \ifdim\d_grph_scale_ht=\ht\nextbox
+ \ifdim\d_grph_scale_dp=\dp\nextbox
+ % \grph_scale_apply_nop
+ \else
+ \grph_scale_apply_yes
+ \fi
+ \else
+ \grph_scale_apply_yes
+ \fi
+ \else
+ \grph_scale_apply_yes
+ \fi}
+
+\def\grph_scale_apply_yes
+ {\setbox\nextbox\hcontainer
+ {\dostartscaling \finalscaleboxxscale \finalscaleboxyscale
+ \smashedbox\nextbox
+ \dostopscaling}%
+ \wd\nextbox\d_grph_scale_wd
+ \ht\nextbox\d_grph_scale_ht
+ \dp\nextbox\d_grph_scale_dp}
+
+\def\m_grph_scale_stamp_c{11}
+
+\def\grph_scale_calculate
+ {\ifdim\d_grph_scale_ht>\zeropoint \ifdim\d_grph_scale_wd>\zeropoint
+ \edef\m_grph_scale_stamp_a{\p_scale\p_xscale\p_yscale\p_factor\p_wfactor\p_hfactor\p_lines\p_width\p_height}%
+ \edef\m_grph_scale_stamp_b{\p_sx\p_sy}%
+ \ifempty\m_grph_scale_stamp_a
+ \ifx\m_grph_scale_stamp_b\m_grph_scale_stamp_c
+ % no scaling, don't change this (previous attempts failed anyway)
+ \insidefloattrue % trick
+ \grph_scale_calculations_yes
+ \else
+ \grph_scale_check_sx_sy
+ \grph_scale_calculations_nop
+ \fi
+ \else
+ \ifempty\m_grph_scale_stamp_b
+ % no need to check further
+ \else
+ \grph_scale_check_sx_sy
+ \fi
+ \grph_scale_calculations_yes
+ \fi
+ \fi \fi}
+
+\def\grph_scale_check_sx_sy
+ {\ifdim\p_sx\onepoint=\onepoint\else\edef\p_width {\the\dimexpr\p_sx\d_grph_scale_wd}\fi
+ \ifdim\p_sy\onepoint=\onepoint\else\edef\p_height{\the\dimexpr\p_sy\d_grph_scale_ht}\fi}
+
+\def\grph_scale_rounded#1%
+ {\thewithoutunit\dimexpr#1\points*100+32768\scaledpoint\relax}
+
+\def\grph_scale_calculations_nop
+ {\settrue\c_grph_scale_done
+ \xdef\finalscaleboxwidth {\the\dimexpr\p_sx\d_grph_scale_wd\relax}%
+ \xdef\finalscaleboxheight{\the\dimexpr\p_sy\d_grph_scale_ht\relax}%
+ \glet\finalscaleboxxscale\p_sx
+ \glet\finalscaleboxyscale\p_sy
+ \ifempty\finalscaleboxxscale\let\finalscaleboxxscale\!!plusone\fi
+ \ifempty\finalscaleboxyscale\let\finalscaleboxyscale\!!plusone\fi}
+
+\let\grph_scale_calculations_report\relax
+
+\def\grph_scale_calculations_yes
+ {\settrue\c_grph_scale_done
+ % initial values
+ \d_grph_scale_x_offset\zeropoint
+ \d_grph_scale_y_offset\zeropoint
+ \d_grph_scale_x_size \d_grph_scale_wd
+ \d_grph_scale_y_size \d_grph_scale_ht % alleen ht wordt geschaald!
+ % final values
+ \global\d_grph_scale_used_x_size \zeropoint % see note * (core-fig)
+ \global\d_grph_scale_used_y_size \zeropoint % see note * (core-fig)
+ \c_grph_scale_used_x_scale \plusone % see note * (core-fig)
+ \c_grph_scale_used_y_scale \plusone % see note * (core-fig)
+ \let\m_grph_scale_used_x_scale \!!plusone
+ \let\m_grph_scale_used_y_scale \!!plusone
+ % preparations
+ \setfalse\c_grph_scale_scaling_done
+ \grph_scale_check_parameters
+ % calculators
+ % beware, they operate in sequence, and calculate missing dimensions / messy
+ % grph_scale_by_nature % when? needed?
+ \ifconditional\c_grph_scale_scaling_done\else\grph_scale_by_factor \fi
+ \ifconditional\c_grph_scale_scaling_done\else\grph_scale_by_scale \fi
+ \ifconditional\c_grph_scale_scaling_done\else\grph_scale_by_dimension\fi
+ % used in actual scaling
+ \xdef\finalscaleboxwidth {\the\d_grph_scale_used_x_size}%
+ \xdef\finalscaleboxheight {\the\d_grph_scale_used_y_size}%
+ \glet\finalscaleboxxscale \m_grph_scale_used_x_scale
+ \glet\finalscaleboxyscale \m_grph_scale_used_y_scale
+ \grph_scale_calculations_report}
+
+\defcsname\??scalegrid\v!yes \endcsname{\getnoflines \d_grph_scale_used_y_size\edef\p_height{\the\noflines\lineheight}}
+\defcsname\??scalegrid\v!height \endcsname{\getrawnoflines\d_grph_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+\strutdepth}}
+\defcsname\??scalegrid\v!depth \endcsname{\getrawnoflines\d_grph_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight-\strutdepth}}
+\defcsname\??scalegrid\v!halfline\endcsname{\getrawnoflines\d_grph_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+.5\lineheight}}
+\defcsname\??scalegrid\v!fit \endcsname{\getrawnoflines\d_grph_scale_used_y_size\edef\p_height{\the\noflines\lineheight}}
+\letcsname\??scalegrid\empty \endcsname\donothing
+
+\def\grph_scale_check_parameters % resolve self referencing loops
+ {\ifempty\p_maxwidth \else \edef\p_maxwidth {\the\dimexpr\p_maxwidth }\fi
+ \ifempty\p_maxheight\else \edef\p_maxheight{\the\dimexpr\p_maxheight }\fi
+ \ifempty\p_lines \else \edef\p_height {\the\dimexpr\p_lines\lineheight}\fi
+ \begincsname\??scalegrid\scaleparameter\c!grid\endcsname}
+
+\def\grph_scale_by_nature % where ! ! ! ! !
+ {\ifempty\p_width \else \global\d_grph_scale_used_x_size\p_width \fi
+ \ifempty\p_height\else \global\d_grph_scale_used_y_size\p_height\fi
+ \ifempty\p_scale \else \c_grph_scale_used_x_scale\p_scale
+ \c_grph_scale_used_y_scale\p_scale \fi
+ \ifempty\p_xscale\else \c_grph_scale_used_x_scale\p_xscale\fi
+ \ifempty\p_yscale\else \c_grph_scale_used_y_scale\p_yscale\fi}
+
+% \defineexternalfigure[width-6][factor=auto,maxwidth=\textheight,maxheight=\textwidth]
+% \defineexternalfigure[width-7][factor=auto,maxwidth=\textwidth,maxheight=\textheight]
+% \placefigure{none}{\rotate[frame=on,offset=overlay]{\externalfigure[t:/sources/cow.pdf][width-6]}} \page
+% \placefigure{none}{\framed[frame=on,offset=overlay]{\externalfigure[t:/sources/cow.pdf][width-7]}}
+
+%D The \typpe {min} option makes sure that the smallest available space determines
+%D the max size (so we can get a bleed on the other axis):
+%D
+%D \startlinecorrection
+%D \startcombination[nx=2,ny=2,distance=4cm]
+%D {\externalfigure[hacker][factor=max,maxwidth=6cm,maxheight=6cm]} {}
+%D {\externalfigure[mill] [factor=max,maxwidth=6cm,maxheight=6cm]} {}
+%D {\externalfigure[hacker][factor=min,maxwidth=6cm,maxheight=6cm]} {}
+%D {\externalfigure[mill] [factor=min,maxwidth=6cm,maxheight=6cm]} {}
+%D \stopcombination
+%D \stoplinecorrection
+
+\def\m_grph_scale_factor_set{\v!min,\v!max,\v!fit,\v!broad,\v!auto} % can be an \edef
+
+\def\grph_scale_by_factor
+ {\doifelseinset\p_factor\m_grph_scale_factor_set
+ \grph_scale_by_factor_a
+ {\doifelseinset\p_hfactor\m_grph_scale_factor_set
+ \grph_scale_by_factor_b
+ {\doifelseinset\p_wfactor\m_grph_scale_factor_set
+ \grph_scale_by_factor_c
+ \grph_scale_by_factor_d}}}
+
+\def\grph_scale_by_factor_a
+ {\grph_scale_apply_size
+ \ifdim\d_grph_scale_x_size >\d_grph_scale_y_size
+ \grph_scale_calculate_norm \d_grph_scale_used_x_size\p_factor\p_maxwidth\hsize\d_grph_scale_h_size
+ \grph_scale_calculate_scales\d_grph_scale_used_x_size\d_grph_scale_x_size
+ \d_grph_scale_used_y_size\m_grph_scale_used_x_scale\d_grph_scale_y_size
+ \else
+ \grph_scale_calculate_norm \d_grph_scale_used_y_size\p_factor\p_maxheight\d_grph_scale_outer_v_size\d_grph_scale_v_size
+ \grph_scale_calculate_scales\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size
+ \fi
+ \grph_scale_by_factor_indeed}
+
+\def\grph_scale_by_factor_b
+ {\grph_scale_apply_size
+ \grph_scale_calculate_norm \d_grph_scale_used_y_size\p_hfactor\p_maxheight\d_grph_scale_outer_v_size\d_grph_scale_v_size
+ \grph_scale_calculate_scales\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size
+ \grph_scale_by_factor_indeed}
+
+\def\grph_scale_by_factor_c
+ {\grph_scale_apply_size
+ \grph_scale_calculate_norm \d_grph_scale_used_x_size\p_wfactor\p_maxwidth\hsize\d_grph_scale_h_size
+ \grph_scale_calculate_scales\d_grph_scale_used_x_size\d_grph_scale_x_size
+ \d_grph_scale_used_y_size\m_grph_scale_used_x_scale\d_grph_scale_y_size
+ \grph_scale_by_factor_indeed}
+
+\def\grph_scale_by_factor_d
+ {\grph_scale_calculate_norm\d_grph_scale_used_y_size\p_factor \p_height \textheight\d_grph_scale_v_size
+ \grph_scale_calculate_norm\d_grph_scale_used_y_size\p_hfactor\p_height \textheight\d_grph_scale_v_size
+ \grph_scale_calculate_norm\d_grph_scale_used_x_size\p_wfactor\p_width \hsize \hsize}
+
+\def\grph_scale_by_factor_indeed
+ {\grph_scale_calculate_fact\p_factor
+ \settrue\c_grph_scale_scaling_done
+ \ifconditional\c_grph_scale_limit_factors
+ \ifdim\d_grph_scale_used_x_size\ifconditional\c_grph_scale_swap_factor<\else>\fi\d_grph_scale_h_size
+ \global\d_grph_scale_used_y_size\zeropoint
+ \global\d_grph_scale_used_x_size\d_grph_scale_h_size
+ \orelse\ifdim\d_grph_scale_used_y_size\ifconditional\c_grph_scale_swap_factor<\else>\fi\d_grph_scale_v_size
+ \global\d_grph_scale_used_x_size\zeropoint
+ \global\d_grph_scale_used_y_size\d_grph_scale_v_size
+ \fi
+ \fi
+ \grph_scale_by_dimension}
+
+\def\grph_scale_by_scale
+ {\edef\m_grph_scale_temp{\p_scale\p_xscale\p_yscale}%
+ \ifempty\m_grph_scale_temp \else
+ \grph_scale_apply_scale\m_grph_scale_used_x_scale\p_xscale
+ \grph_scale_apply_scale\m_grph_scale_used_y_scale\p_yscale
+ % \global\d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size\relax % no global needed here
+ % \global\d_grph_scale_used_y_size\m_grph_scale_used_y_scale\d_grph_scale_y_size\relax % no global needed here
+ % wrong: we need to recalculate the scale
+ \global\d_grph_scale_used_x_size\zeropoint
+ \global\d_grph_scale_used_y_size\zeropoint
+ %
+ \ifempty\p_maxwidth
+ \ifempty\p_maxheight\orelse\ifdim\d_grph_scale_y_size>\p_maxheight\relax
+ \global\d_grph_scale_used_y_size\p_maxheight
+ \fi
+ \orelse\ifdim\d_grph_scale_x_size>\p_maxwidth\relax
+ \global\d_grph_scale_used_x_size\p_maxwidth
+ \fi
+ \fi}
+
+\def\grph_scale_by_dimension
+ {\ifdim\d_grph_scale_used_x_size>\zeropoint
+ \ifdim\d_grph_scale_used_y_size>\zeropoint
+ \grph_scale_by_dimension_a
+ \else
+ \grph_scale_by_dimension_b
+ \fi
+ \else
+ \ifdim\d_grph_scale_used_y_size>\zeropoint
+ \grph_scale_by_dimension_c
+ \else
+ \grph_scale_by_dimension_d
+ \fi
+ \fi}
+
+\def\grph_scale_by_dimension_a
+ {\grph_scale_by_dimension_indeed
+ {\grph_scale_calculate_scale\m_grph_scale_used_y_scale\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \grph_scale_calculate_scale\m_grph_scale_used_x_scale\d_grph_scale_used_x_size\d_grph_scale_x_size}%
+ {\grph_scale_calculate_scale\m_grph_scale_used_y_scale\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \grph_scale_calculate_scale\m_grph_scale_used_x_scale\d_grph_scale_used_x_size\d_grph_scale_x_size}%
+ {\grph_scale_calculate_scale\m_grph_scale_used_y_scale\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \grph_scale_calculate_scale\m_grph_scale_used_x_scale\d_grph_scale_used_x_size\d_grph_scale_x_size}}
+
+\def\grph_scale_by_dimension_b
+ {\grph_scale_by_dimension_indeed
+ {\grph_scale_calculate_scales\d_grph_scale_used_x_size\d_grph_scale_x_size
+ \d_grph_scale_used_y_size\m_grph_scale_used_x_scale\d_grph_scale_y_size}%
+ {\grph_scale_calculate_scales\d_grph_scale_used_x_size\d_grph_scale_x_size
+ \d_grph_scale_used_y_size\m_grph_scale_used_x_scale\d_grph_scale_y_size}%
+ {\grph_scale_calculate_scales\d_grph_scale_used_x_size\d_grph_scale_x_size
+ \d_grph_scale_used_y_size\m_grph_scale_used_x_scale\d_grph_scale_y_size}}
+
+\def\grph_scale_by_dimension_c
+ {\grph_scale_by_dimension_indeed % weird .. three same cases
+ {\grph_scale_calculate_scales\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size}%
+ {\grph_scale_calculate_scales\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size}%
+ {\grph_scale_calculate_scales\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size}}
+
+\def\grph_scale_by_dimension_d
+ {\grph_scale_by_dimension_indeed
+ {\grph_scale_apply_scale\m_grph_scale_used_x_scale\p_xscale
+ \grph_scale_apply_scale\m_grph_scale_used_y_scale\p_yscale
+ \global\d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size
+ \global\d_grph_scale_used_y_size\m_grph_scale_used_y_scale\d_grph_scale_y_size}%
+ {\grph_scale_calculate_scales\d_grph_scale_used_x_size\d_grph_scale_x_size
+ \d_grph_scale_used_y_size\m_grph_scale_used_x_scale\d_grph_scale_y_size}%
+ {\grph_scale_calculate_scales\d_grph_scale_used_y_size\d_grph_scale_y_size
+ \d_grph_scale_used_x_size\m_grph_scale_used_x_scale\d_grph_scale_x_size}}
+
+\def\grph_scale_by_dimension_indeed#1#2#3%
+ {#1\relax
+ \ifempty\p_maxwidth\orelse\ifdim\d_grph_scale_used_x_size>\p_maxwidth\relax
+ \global\d_grph_scale_used_x_size\p_maxwidth
+ #2\relax
+ \fi
+ \ifempty\p_maxheight\orelse\ifdim\d_grph_scale_used_y_size>\p_maxheight\relax
+ \global\d_grph_scale_used_y_size\p_maxheight
+ #3\relax
+ \fi}
+
+% we can use \lastnamedcs if we want to squeeze out some more
+
+\def\grph_scale_calculate_norm#1#2% todo: swap 1 and 2 and pass one less
+ {\csname\??scalenorm\ifcsname\??scalenorm#2\endcsname#2\else\s!unknown\fi\endcsname#1#2}
+
+\def\grph_scale_calculate_fact#1%
+ {\csname\??scalefact\ifcsname\??scalefact#1\endcsname#1\else\s!unknown\fi\endcsname}
+
+\defcsname\??scalenorm\v!max \endcsname#1#-#-#2#-{\global#1#2}
+\defcsname\??scalenorm\v!fit \endcsname#1#-#-#-#2{\global#1#2}
+\defcsname\??scalenorm\v!broad \endcsname#1#-#-#-#2{\global#1\dimexpr#2-4\externalfigureparameter\c!bodyfont\relax}
+\defcsname\??scalenorm\s!unknown\endcsname#1#2#-#-#-{\global#1\dimexpr#2\dimexpr\externalfigureparameter\c!bodyfont/10\relax\relax} % brr ex
+\defcsname\??scalenorm\v!auto \endcsname#1#-#2#-#-{\ifempty#2\else\global#1#2\fi}
+\defcsname\??scalenorm\empty \endcsname#1#-#2#-#-{\ifempty#2\else\global#1#2\fi}
+\defcsname\??scalenorm\s!default\endcsname#1#-#2#-#-{\ifempty#2\else\global#1#2\fi}
+
+\defcsname\??scalefact\v!min \endcsname{\global\settrue \c_grph_scale_swap_factor}
+\defcsname\??scalefact\s!unknown\endcsname{\global\setfalse\c_grph_scale_swap_factor}
+
+\defcsname\??scalenorm\v!min\endcsname#-#-#-#-#-% an ugly hack
+ {\d_grph_scale_used_x_size\hsize
+ \d_grph_scale_used_y_size\vsize}
+
+\def\grph_scale_calculate_scales#1#2%
+ {\edef\m_grph_scale_used_x_scale{\luaexpr{\number#1/\number#2}}%
+ \let\m_grph_scale_used_y_scale\m_grph_scale_used_x_scale}
+
+\def\grph_scale_calculate_scale#1#2#3%
+ {\edef#1{\luaexpr{\number#2/\number#3}}}
+
+\def\grph_scale_apply_scale#1#2% #1 = parameter / scale can be empty
+ {% no overflow
+ \edef#1{\luaexpr
+ {\number
+ \ifempty#2%
+ \ifempty\p_scale \plusthousand \else
+ \ifnum \p_scale=\zerocount \plusthousand \else
+ \p_scale \fi\fi
+ \orelse\ifnum#2=\zerocount
+ \ifempty\p_scale \plusthousand \else
+ \ifnum \p_scale=\zerocount \plusthousand \else
+ \p_scale \fi\fi
+ \else
+ #2%
+ \fi
+ /1000}}}
+
+\def\grph_scale_apply_size
+ {\ifempty\p_maxheight
+ \d_grph_scale_outer_v_size\textheight
+ \ifinner
+ \d_grph_scale_outer_v_size \vsize % \textheight =\vsize
+ \scratchdimen\vsize % \scratchdimen=\textheight
+ \orelse\ifinsidefloat
+ \d_grph_scale_outer_v_size \vsize % \textheight =\vsize
+ \scratchdimen\vsize % \scratchdimen=\textheight
+ \orelse\ifinpagebody
+ \d_grph_scale_outer_v_size \vsize % \textheight =\vsize
+ \scratchdimen\vsize % \scratchdimen=\textheight
+ \orelse\ifdim\pagegoal<\maxdimen
+ \ifdim\pagetotal<\pagegoal
+ \scratchdimen\dimexpr\pagegoal-\pagetotal\relax
+ \else
+ \scratchdimen\d_grph_scale_outer_v_size % \textheight
+ \fi
+ \else
+ \scratchdimen\d_grph_scale_outer_v_size % \textheight
+ \fi
+ \else
+ \scratchdimen\p_maxheight
+ \d_grph_scale_outer_v_size\scratchdimen
+ \fi
+ \ifempty\p_height
+ \d_grph_scale_v_size\scratchdimen
+ \else
+ \d_grph_scale_v_size\p_height
+ \fi
+ \ifempty\p_width
+ \d_grph_scale_h_size\hsize
+ \else
+ \d_grph_scale_h_size\p_width
+ \fi}
+
+% \startcombination
+% {\externalfigure[cow.pdf] [frame=on,height=3cm,equalwidth=6cm]} {a cow}
+% {\externalfigure[mill.png][frame=on,height=3cm,equalwidth=6cm]} {a mill}
+% \stopcombination
+
+\def\grph_scale_position
+ {\ifempty\p_equalwidth \else
+ \scratchdimen\p_equalwidth\relax
+ \ifdim\d_grph_scale_wd<\scratchdimen
+ \setbox\nextbox\naturalhpack to \scratchdimen{\hss\box\nextbox\hss}%
+ \fi
+ \fi
+ \ifempty\p_equalheight \else
+ \scratchdimen\p_equalheight\relax
+ \ifdim\d_grph_scale_ht<\scratchdimen
+ \setbox\nextbox\naturalvpack to \scratchdimen{\vss\box\nextbox\vss}%
+ \fi
+ \fi}
+
+\permanent\protected\def\fastscale#1%
+ {\ifnum#1=1000\relax
+ \expandafter\grph_scale_fast_nop
+ \else
+ \expandafter\grph_scale_fast_yes
+ \fi{#1}}
+
+\def\grph_scale_fast_nop#1%
+ {\hbox}
+
+\def\grph_scale_fast_yes#1%
+ {\edef\finalscaleboxxscale{\withoutpt\the\dimexpr#1\onepoint/1000\relax}% brrr
+ \let\finalscaleboxyscale\finalscaleboxxscale
+ \dowithnextboxcs\grph_scale_fast_finish\hbox} % container ?
+
+\def\grph_scale_fast_finish
+ {\grph_scale_apply
+ \box\nextbox
+ \endgroup}
+
+\permanent\protected\def\fastsxsy#1#2%
+ {\bgroup
+ \edef\p_sx{#1}%
+ \edef\p_sy{#2}%
+ \dowithnextboxcs\grph_scale_fast_sx_xy_finish\hbox} % container?
+
+\def\grph_scale_fast_sx_xy_finish
+ {\grph_scale_check_sx_sy
+ \d_grph_scale_wd\wd\nextbox
+ \d_grph_scale_ht\ht\nextbox
+ \d_grph_scale_dp\dp\nextbox
+ \grph_scale_calculations_nop
+ \grph_scale_apply
+ \box\nextbox
+ \egroup}
+
+%D \macros
+%D {clip, setupclipping}
+%D
+%D Although related to figures, clipping can be applied to arbitrary content. We can
+%D use \METAPOST\ to provide a non rectangular clipping path.
+%D
+%D \starttyping
+%D \startMPclip{fun}
+%D clip currentpicture to fullcircle
+%D shifted (.5,.5) xscaled \width yscaled \height ;
+%D \stopMPclip
+%D \stoptyping
+%D
+%D We get a rectangular piece of the figure when we say:
+%D
+%D \starttyping
+%D \clip[x=2,y=1]{\externalfigure[photo]}
+%D \stoptyping
+%D
+%D When we want to clip to the oval we defined a few lines ago, we say:
+%D
+%D \starttyping
+%D \clip[nx=1,ny=1,x=1,y=1,mp=fun]{\externalfigure[photo]}
+%D \stoptyping
+%D
+%D The general characteristics of clipping can be set up with
+%D
+%D \showsetup{setupclipping}
+
+\installcorenamespace{clipping}
+
+\installdirectcommandhandler \??clipping {clipping}
+
+\permanent\tolerant\protected\def\clip[#1]% nb top->bottom left->right
+ {\bgroup
+ \ifparameter#1\or
+ \setupcurrentclipping[#1]%
+ \fi
+ \dowithnextboxcs\grph_clip_finish\hbox}
+
+\def\grph_clip_finish
+ {\doifelse{\clippingparameter\c!state}\v!start
+ \grph_clip_yes_finish
+ \grph_clip_nop_finish}
+
+\def\grph_clip_yes_finish
+ {\ifdim\clippingparameter\c!width>\zeropoint
+ \scratchwidth \clippingparameter\c!width
+ \scratchxoffset\clippingparameter\c!hoffset
+ \else
+ \scratchwidth\dimexpr\wd\nextbox/\clippingparameter\c!nx\relax
+ \scratchxoffset\dimexpr\clippingparameter\c!x\scratchwidth-\scratchwidth\relax
+ \scratchwidth\clippingparameter\c!sx\scratchwidth
+ \fi
+ \relax % sure
+ \ifdim\clippingparameter\c!height>\zeropoint
+ \scratchheight\clippingparameter\c!height
+ \scratchyoffset\dimexpr\ht\nextbox-\clippingparameter\c!voffset-\scratchheight\relax
+ \else
+ \scratchheight\dimexpr\ht\nextbox/\clippingparameter\c!ny\relax
+ \scratchyoffset\dimexpr-\clippingparameter\c!y\scratchheight-\clippingparameter\c!sy\scratchheight+\scratchheight\relax
+ \scratchheight\clippingparameter\c!sy\scratchheight
+ \advance\scratchyoffset \ht\nextbox
+ \fi
+ \setbox\nextbox\naturalhpack
+ {\advance\scratchxoffset -\clippingparameter\c!leftoffset \relax
+ \advance\scratchyoffset -\clippingparameter\c!bottomoffset\relax
+ \hskip-\scratchxoffset
+ \lower\scratchyoffset
+ \box\nextbox}%
+ \wd\nextbox\zeropoint
+ \ht\nextbox\zeropoint
+ \dp\nextbox\zeropoint
+ \setbox\nextbox\naturalhpack
+ {\advance\scratchwidth \dimexpr\clippingparameter\c!leftoffset +\clippingparameter\c!rightoffset\relax
+ \advance\scratchheight\dimexpr\clippingparameter\c!bottomoffset+\clippingparameter\c!topoffset \relax
+ \dostartclipping{\clippingparameter\c!mp}\scratchwidth\scratchheight
+ \box\nextbox
+ \dostopclipping}%
+ \setbox\nextbox\hcontainer
+ {\hskip-\clippingparameter\c!leftoffset
+ \lower \clippingparameter\c!bottomoffset
+ \box\nextbox}%
+ \wd\nextbox\scratchwidth
+ \ht\nextbox\scratchheight
+ \dp\nextbox\zeropoint
+ \box\nextbox
+ \egroup}
+
+\def\grph_clip_nop_finish
+ {\box\nextbox
+ \egroup}
+
+\setupclipping
+ [\c!state=\v!start,
+ \c!n=\plusone, % was \plustwo
+ \c!nx=\clippingparameter\c!n,\c!x=\plusone,\c!sx=\plusone,
+ \c!ny=\clippingparameter\c!n,\c!y=\plusone,\c!sy=\plusone,
+ \c!width=\zeropoint,
+ \c!height=\zeropoint,
+ \c!hoffset=\zeropoint,
+ \c!voffset=\zeropoint,
+ \c!offset=\zeropoint,
+ \c!leftoffset=\clippingparameter\c!offset,
+ \c!rightoffset=\clippingparameter\c!offset,
+ \c!topoffset=\clippingparameter\c!offset,
+ \c!bottomoffset=\clippingparameter\c!offset,
+ \c!mp=]
+
+%D \startbuffer
+%D \startuseMPgraphic{test}
+%D path p ; p := fullcircle scaled 4cm ;
+%D draw p withpen pencircle scaled 1cm ;
+%D setbounds currentpicture to boundingbox p ;
+%D \stopuseMPgraphic
+%D
+%D \hbox to \hsize \bgroup
+%D \hss
+%D \ruledhbox{\useMPgraphic{test}}%
+%D \hss
+%D \ruledhbox{\clip{\useMPgraphic{test}}}%
+%D \hss
+%D \egroup
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D Mirroring.
+
+\permanent\protected\def\mirror
+ {\bgroup
+ \dowithnextboxcs\grph_mirror_finish\hbox}
+
+\def\grph_mirror_finish
+ {\scratchdimen\wd\nextbox
+ % better use an hbox (if no \forgetall, leftskip etc may creep in)
+ %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\wd\nextbox\box\nextbox\dostopmirroring}%
+ \setbox\nextbox\naturalhpack
+ {\dostartmirroring
+ \hskip-\wd\nextbox
+ \box\nextbox
+ \dostopmirroring}%
+ \wd\nextbox\scratchdimen
+ \box\nextbox
+ \egroup}
+
+%D A couple of examples, demonstrating how the depth is taken care of:
+%D
+%D \startbuffer
+%D test\rotate[frame=on, rotation=0] {gans}%
+%D test\rotate[frame=on, rotation=90] {gans}%
+%D test\rotate[frame=on, rotation=180]{gans}%
+%D test\rotate[frame=on, rotation=270]{gans}%
+%D test
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D When we rotate over arbitrary angles, we need to relocate the resulting box
+%D because rotation brings that box onto the negative axis. The calculations (mostly
+%D sin and cosine) need to be tuned for the way a box is packages (i.e. the refence
+%D point). A typical example of drawing, scribbling, and going back to the days of
+%D school math.
+%D
+%D We do a bit more calculations than needed, simply because that way it's easier to
+%D debug the code.
+
+\installcorenamespace {rotate}
+\installcorenamespace {rotatelocation}
+\installcorenamespace {rotatepreset}
+
+%D These are set at the \LUA\ end (it's a cheaper operation than setting a dimen
+%D register and these are actually kind of constants not used in further
+%D calculations):
+
+\mutable\dimendef\d_grph_rotate_x_size \zeropoint
+\mutable\dimendef\d_grph_rotate_y_size \zeropoint
+\mutable\dimendef\d_grph_rotate_x_offset \zeropoint
+\mutable\dimendef\d_grph_rotate_y_offset \zeropoint
+\mutable\dimendef\d_grph_rotate_x_position\zeropoint
+\mutable\dimendef\d_grph_rotate_y_position\zeropoint
+
+\mutable\dimendef\d_grph_rotate_new_width \zeropoint
+\mutable\dimendef\d_grph_rotate_new_height\zeropoint
+\mutable\dimendef\d_grph_rotate_new_depth \zeropoint
+
+%D These aren't:
+
+\newdimen\d_grph_rotate_used_height
+
+\newdimen\d_grph_rotate_width
+\newdimen\d_grph_rotate_height
+\newdimen\d_grph_rotate_depth
+
+\newdimen\d_grph_rotate_saved_width
+\newdimen\d_grph_rotate_saved_height
+\newdimen\d_grph_rotate_saved_depth
+
+\newconditional\c_grph_rotate_obey_depth
+\newconditional\c_grph_rotate_not_fit
+\newconditional\c_grph_rotate_center
+
+\installframedcommandhandler \??rotate {rotate} \??rotate
+
+\setuprotate
+ [\c!rotation=90,
+ \c!location=\v!normal,
+ \c!width=\v!fit,
+ \c!height=\v!fit,
+ \c!offset=\v!overlay,
+ \c!frame=\v!off]
+
+\let\p_rotation_location\empty
+\let\p_rotation_rotation\empty
+
+\permanent\tolerant\protected\def\rotate[#1]% \bgroup: \rotate kan argument zijn
+ {\bgroup
+ \ifparameter#1\or
+ \setupcurrentrotate[#1]%
+ \fi
+ \edef\p_rotation_location{\rotateparameter\c!location}%
+ \edef\p_rotation_rotation{\rotateparameter\c!rotation}%
+ \ifcsname\??rotatelocation\p_rotation_location\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\grph_rotate_default
+ \fi}
+
+\def\grph_rotate_framed
+ {\resetrotateparameter\c!location
+ \dowithnextboxcs\grph_rotate_finish\vbox
+ \inheritedrotateframed}
+
+\def\grph_rotate_normal
+ {\dowithnextboxcs\grph_rotate_finish\vbox}
+
+\def\grph_rotate_finish
+ {\grph_rotate_finish_indeed
+ \egroup}
+
+\def\grph_rotate_default
+ {\setfalse\c_grph_rotate_not_fit
+ \setfalse\c_grph_rotate_center
+ \settrue \c_grph_rotate_obey_depth
+ \grph_rotate_framed}
+
+\letcsname\??rotatelocation\v!default\endcsname\grph_rotate_default
+
+\defcsname\??rotatelocation\v!depth\endcsname
+ {\setfalse\c_grph_rotate_not_fit
+ \setfalse\c_grph_rotate_center
+ \settrue \c_grph_rotate_obey_depth
+ \grph_rotate_normal}
+
+\defcsname\??rotatelocation\v!fit\endcsname
+ {\settrue \c_grph_rotate_not_fit
+ \setfalse\c_grph_rotate_center
+ \settrue \c_grph_rotate_obey_depth
+ \grph_rotate_normal}
+
+\defcsname\??rotatelocation\v!broad\endcsname
+ {\setfalse\c_grph_rotate_not_fit
+ \setfalse\c_grph_rotate_center
+ \setfalse\c_grph_rotate_obey_depth
+ \grph_rotate_normal}
+
+\defcsname\??rotatelocation\v!high\endcsname
+ {\setfalse\c_grph_rotate_not_fit
+ \setfalse\c_grph_rotate_center
+ \setfalse\c_grph_rotate_obey_depth
+ \grph_rotate_framed}
+
+\defcsname\??rotatelocation\v!middle\endcsname
+ {\setfalse\c_grph_rotate_not_fit
+ \settrue \c_grph_rotate_center
+ \setfalse\c_grph_rotate_obey_depth % hm, depth ?
+ \grph_rotate_normal}
+
+\permanent\protected\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop % a fast low level one
+ {\ifcase#1\relax
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\grph_rotate_box
+ \fi{#1}}
+
+\def\grph_rotate_box#1% {angle} \hbox/\vbox/\vtop
+ {\bgroup
+ \hbox\bgroup % compatibility hack
+ \edef\p_rotation_rotation{#1}%
+ \dowithnextboxcs\grph_rotate_finish_box}
+
+\def\grph_rotate_finish_box
+ {\setfalse\c_grph_rotate_not_fit % this is the same as broad but
+ \setfalse\c_grph_rotate_center % without the following grab as
+ \setfalse\c_grph_rotate_obey_depth % we call finish directly
+ \grph_rotate_finish_indeed
+ \egroup
+ \egroup}
+
+\def\grph_rotate_finish_indeed
+ {\naturalhpack\bgroup
+ \ifempty\p_rotation_rotation
+ \grph_rotate_finish_nop
+ \else
+ \grph_rotate_finish_yes
+ \fi
+ \egroup}
+
+\def\grph_rotate_finish_nop
+ {\boxcursor\box\nextbox}
+
+\defcsname\??rotatepreset\v!left\endcsname
+ {\edef\p_rotation_rotation{90}}
+
+\defcsname\??rotatepreset\v!right\endcsname
+ {\edef\p_rotation_rotation{270}}
+
+\defcsname\??rotatepreset\v!inner\endcsname
+ {\signalrightpage
+ \doifelserightpage{\def\p_rotation_rotation{270}}{\def\p_rotation_rotation{90}}}
+
+\defcsname\??rotatepreset\v!outer\endcsname
+ {\signalrightpage
+ \doifelserightpage{\def\p_rotation_rotation{90}}{\def\p_rotation_rotation{270}}}
+
+\letcsname\??rotatepreset\v!default\endcsname\empty
+
+\def\grph_rotate_finish_yes
+ {\begincsname\??rotatepreset\p_rotation_rotation\endcsname
+ \setbox\nextbox\naturalvpack{\box\nextbox}% not really needed
+ \dontcomplain
+ \ifconditional\c_grph_rotate_center
+ \d_grph_rotate_saved_width \wd\nextbox
+ \d_grph_rotate_saved_height\ht\nextbox
+ \d_grph_rotate_saved_depth \dp\nextbox
+ \setbox\nextbox\naturalhpack{\hskip-.5\wd\nextbox\lower.5\ht\nextbox\box\nextbox}%
+ \smashbox\nextbox
+ \fi
+ %
+ \d_grph_rotate_width \wd\nextbox
+ \d_grph_rotate_height\ht\nextbox
+ \d_grph_rotate_depth \dp\nextbox
+ %
+ \setbox\nextbox\naturalvpack{\naturalhpack{\raise\dp\nextbox\box\nextbox}}% can we do without
+ %
+ \d_grph_rotate_used_height\ht\nextbox
+ %
+ \clf_analyzerotate % rather accurate
+ \p_rotation_rotation\space
+ \d_grph_rotate_width
+ \d_grph_rotate_height
+ \d_grph_rotate_depth
+ \d_grph_rotate_used_height
+ \c_grph_rotate_not_fit
+ \c_grph_rotate_obey_depth
+ \relax
+ %
+ \setbox\nextbox\naturalvpack to \d_grph_rotate_y_size
+ {\vfilll
+ \hcontainer to \d_grph_rotate_x_size
+ {\dostartrotation\p_rotation_rotation
+ \wd\nextbox\zeropoint
+ \ht\nextbox\zeropoint
+ \box\nextbox
+ \dostoprotation
+ \hfill}%
+ \kern\d_grph_rotate_y_position}%
+ %
+ \setbox\nextbox\naturalhpack
+ {\kern\dimexpr\d_grph_rotate_x_position+\d_grph_rotate_x_offset\relax
+ \lower\d_grph_rotate_y_offset
+ \box\nextbox}%
+ %
+ \ifconditional\c_grph_rotate_center
+ \setbox\nextbox\naturalhpack{\hskip.5\d_grph_rotate_saved_width\lower-.5\d_grph_rotate_saved_height\box\nextbox}%
+ \wd\nextbox\d_grph_rotate_saved_width
+ \ht\nextbox\d_grph_rotate_saved_height
+ \dp\nextbox\d_grph_rotate_saved_depth
+ \else
+ \wd\nextbox\d_grph_rotate_new_width
+ \ht\nextbox\d_grph_rotate_new_height
+ \dp\nextbox\d_grph_rotate_new_depth
+ \fi
+ %
+ \boxcursor\box\nextbox}
+
+% \dostepwiserecurse{0}{360}{10}
+% {\startlinecorrection[blank]
+% \hbox
+% {\expanded{\setuprotate[rotation=\recurselevel]}%
+% \traceboxplacementtrue
+% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=depth] {\ruledhbox{\bfb (depth)}}}}%
+% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=fit] {\ruledhbox{\bfb (fit)}}}}%
+% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=broad] {\ruledhbox{\bfb (broad)}}}}%
+% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=normal]{\ruledhbox{\bfb (normal)}}}}%
+% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=high] {\ruledhbox{\bfb (high)}}}}}
+% \stoplinecorrection}
+
+% \def\Test{\ruledhbox{%
+% \def\DemoX{\vl\kern.5\emwidth\vl}%
+% \kern\emwidth\ruledhpack{\green\rotate[rotation=20] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\blue \rotate[rotation=0] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\red \rotate[rotation=-20] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\green\rotate[rotation=200] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\blue \rotate[rotation=180] {\ruledhpack{\DemoX}}}%
+% \kern\emwidth\ruledhpack{\red \rotate[rotation=-200]{\ruledhpack{\DemoX}}}%
+% \kern\emwidth}}
+
+% \startTEXpage[offset=10pt,align=middle]
+% \setuprotate[location=fit] \Test \par {\infofont\setstrut\strut fit} \par
+% \setuprotate[location=depth] \Test \par {\infofont\setstrut\strut depth} \par
+% \setuprotate[location=broad] \Test \par {\infofont\setstrut\strut broad} \par
+% \setuprotate[location=high] \Test \par {\infofont\setstrut\strut high} \par
+% \setuprotate[location=middle] \Test \par {\infofont\setstrut\strut middle} \par
+% \setuprotate[location=default] \Test \par {\infofont\setstrut\strut default} \par
+% \stopTEXpage
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/hand-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/hand-ini.mkxl
new file mode 100644
index 00000000000..3fd82f239b4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/hand-ini.mkxl
@@ -0,0 +1,113 @@
+%D \module
+%D [ file=hand-ini,
+%D version=2008.02.12,
+%D title=\CONTEXT\ Handling Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Handling is implemented differently in \MKIV. Maybe I'll cook up
+%D some compatibility hack.
+
+% \definefontfeature[demo][default][mode=node,expansion=quality]
+% \definefontfeature[demo][default][mode=node,protrusion=pure]
+
+% experimental setup:
+%
+% \showframe \setupalign[hanging] \enabletrackers[fonts.protrusion]
+%
+% \definefontfeature[default] [default][mode=node,script=latn]
+% %definefontfeature[whatever][default][mode=node,lfbd=yes,rtbd=yes,script=latn]
+% \definefontfeature[whatever][default][mode=node,protrusion=quality]
+% \definefontfeature[whocares][default][mode=node,protrusion=yes,opbd=yes,script=latn] % left|right|yes
+%
+% \definedfont[fxlbi.otf*default] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
+% \definedfont[fxlbi.otf*whatever] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
+% \definedfont[fxlbi.otf*whocares] \input tufte 0123456789 \par \dorecurse{15}{1 2 3 4 5 6 7 8 9 0 } \par
+%
+% %definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn,featurefile=texgyrepagella-regularxx.fea]
+% \definefontfeature[whocares][default][mode=node,protrusion=2,opbd=yes,script=latn]
+%
+% \definedfont[texgyrepagella-regularxx.otf*whocares] \input tufte
+
+\unprotect
+
+%D Probbaly not yet used by many.
+
+\permanent\tolerant\protected\def\setupfontexpansion [#1]#*[#2]{\clf_setupfontexpansion {#1}{#2}}
+\permanent\tolerant\protected\def\setupfontprotrusion[#1]#*[#2]{\clf_setupfontprotrusion{#1}{#2}}
+
+% \setupfontprotrusion[quality-upright][vector=quality]
+% \setupfontprotrusion[quality-slanted][vector=quality,right=1.5]
+
+\pushoverloadmode
+
+ \let\adjustspacing\relax \newcount\adjustspacing % a little bit protection
+ \let\protrudechars\relax \newcount\protrudechars % a little bit protection
+
+\popoverloadmode
+
+%D At some point we can introduce extreme expansion, i.e. \type {\normaladjustspacing\plustwo}.
+
+% 0 = disabled
+% 1 = notused (thesis)
+% 2 = glyph + kern
+% 3 = glyph only (default)
+
+\def\font_expansion_enable {\normaladjustspacing\plusthree}
+\def\font_expansion_enable_k{\normaladjustspacing\plustwo}
+%def\font_expansion_enable_n{\normaladjustspacing\plusone}
+\def\font_expansion_disable {\normaladjustspacing\zerocount}
+
+\def\font_protruding_enable_b{\normalprotrudechars\plusthree} % also deal with r2l (experimental lmtx)
+\def\font_protruding_enable {\normalprotrudechars\plustwo }
+\def\font_protruding_disable {\normalprotrudechars\zerocount}
+
+\appendtoks \font_expansion_disable \to \everyforgetall % Here or not here?
+\appendtoks \font_protruding_disable \to \everyforgetall % Here or not here?
+
+% \def\fonthandlingerror{\writestatus\m!fonts{font handling is replaced by features in mkiv}}
+%
+% \let\fonthandling\empty
+%
+% \protected\def\startfonthandling #1{\fonthandlingerror\fonthandlingerror\gobbleuntil\stopfonthandling} % can't happen
+% \protected\def\definefonthandling {\dotripleempty\dodefinefonthandling}
+% \protected\def\setupfonthandling {\dodoubleempty\dosetupfonthandling }
+% \def\dodefinefonthandling[#1][#2][#3]{\fonthandlingerror}
+% \def\dosetupfonthandling [#1][#2]{\fonthandlingerror}
+% \def\usehandling [#1]{\fonthandlingerror}
+
+\installcorenamespace{expansion}
+
+\installcommandhandler \??expansion {expansion} \??expansion
+
+\appendtoks
+ \setuevalue{\??expansion:\currentexpansion}%
+ {\adjustspacingstep \expansionparameter\c!step\relax
+ \adjustspacingstretch\expansionparameter\c!stretch\relax
+ \adjustspacingshrink \expansionparameter\c!shrink\relax}%
+\to \everydefineexpansion
+
+\setupexpansion
+ [\c!step=1,
+ \c!stretch=40,
+ \c!shrink=20]
+
+% \defineexpansion
+% [myexpansion]
+% [\c!stretch=50,
+% \c!shrink=20]
+
+\permanent\tolerant\protected\def\setexpansion[#1]{\begincsname\??expansion:#1\endcsname}
+
+%D New in \LMTX: can be used grouped.
+
+\permanent\protected\def\noexpansion {\bitwiseflip\glyphoptions\noexpansioncode}
+\permanent\protected\def\noprotrusion{\bitwiseflip\glyphoptions\noprotrusioncode}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/java-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/java-ini.mkxl
new file mode 100644
index 00000000000..f0e260eeaa3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/java-ini.mkxl
@@ -0,0 +1,157 @@
+%D \module
+%D [ file=java-ini,
+%D version=1998.01.30,
+%D title=\CONTEXT\ JavaScript Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt JavaScript Macros / Initialization}
+
+\registerctxluafile{java-ini}{}
+
+\unprotect
+
+%D \macros
+%D {JS*}
+%D
+%D Because \JAVASCRIPT's are activated by the user, for instance by activating on a
+%D button, their support is closely related to the referencing mechanism.
+%D Integration takes place by
+%D
+%D \starttyping
+%D \goto{calculate total}[Sum()]
+%D \stoptyping
+%D
+%D The \type {()} classify this as a script. If they are absent, the keyword is
+%D treated as a normal reference. One can pass arguments to such a script by saying:
+%D
+%D \starttyping
+%D \goto{calculate total}[Sum(1.5,2.3)]
+%D \stoptyping
+
+%D \macros
+%D {startJScode}
+%D
+%D A piece of \JAVASCRIPT\ code is defined by saying:
+%D
+%D \starttyping
+%D \startJScode{name}
+%D name = 4 ;
+%D \stopJScode
+%D \stoptyping
+%D
+%D This assumes uses no preamble or presumes that the preamble is always loaded, the
+%D next definition also tells \CONTEXT\ to actually include the preamble needed.
+%D
+%D \starttyping
+%D \startJScode{uses} used {later}
+%D uses = 6 ;
+%D \stopJScode
+%D \stoptyping
+%D
+%D \macros
+%D {startJSpreamble}
+%D
+%D One can define insert \JAVASCRIPT\ code at the document level by using:
+%D
+%D \starttyping
+%D \startJSpreamble{oeps}
+%D oeps = 1 ;
+%D \stopJSpreamble
+%D \stoptyping
+%D
+%D which is the same as:
+%D
+%D \starttyping
+%D \startJSpreamble{now} used now
+%D now = 2 ;
+%D \stopJSpreamble
+%D \stoptyping
+%D
+%D while the next definition is only included when actually used.
+%D
+%D \starttyping
+%D \startJSpreamble{later} used later
+%D later = 3 ;
+%D \stopJSpreamble
+%D \stoptyping
+%D
+%D This command may be used more that once, but always before the first page is
+%D shipped out.
+%D
+%D \macros
+%D {setJSpreamble, addtoJSpreamble}
+%D
+%D In addition to the previous preamble definitions, we can set a preamble \quote
+%D {in||line} and add tokens to a preamble.
+%D
+%D \macros
+%D {useJSpreamblenow}
+%D
+%D This macro can be used to force inclusion of postponed \JAVASCRIPT\ preambles.
+
+\def\m_java_escape_u{\letterbackslash u}
+
+\permanent\protected\def\startJScode
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \enforced\let\u\m_java_escape_u
+ \java_start_code}
+
+\def\java_start_code#1\stopJScode
+ {\normalexpanded{\endgroup\clf_storejavascriptcode{#1}}}
+
+\aliased\let\stopJScode\relax
+
+\permanent\protected\def\startJSpreamble
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \enforced\let\u\m_java_escape_u
+ \java_start_preamble}
+
+\def\java_start_preamble#1\stopJSpreamble
+ {\normalexpanded{\endgroup\clf_storejavascriptpreamble{#1}}}
+
+\aliased\let\stopJSpreamble\relax
+
+\permanent\protected\def\setJSpreamble #1#2{\clf_setjavascriptpreamble {#1}{#2}}
+\permanent\protected\def\addtoJSpreamble#1#2{\clf_addtojavascriptpreamble{#1}{#2}}
+
+%D \macros
+%D {useJSscripts}
+%D
+%D In due time, users will build their collections of scripts, which can be used
+%D (loaded) when applicable. Although not all public, we will provide some general
+%D purpose scripts, collected in files with names like \type {java-...}. One can
+%D load these scripts with \type {\useJSscripts}, like:
+%D
+%D \starttyping
+%D \useJSscripts[fld]
+%D \stoptyping
+%D
+%D The not so complicated implementation of this macro is:
+
+\permanent\tolerant\protected\def\useJSscripts[#1]#*[#2]%
+ {\clf_usejavascriptscripts {#1}% two steps as this one calls tex code
+ \clf_usejavascriptpreamble{#2}}% so this one comes later
+
+\permanent\tolerant\protected\def\useJSpreamble[#1]%
+ {\clf_usejavascriptpreamble{#1}}% so this one comes later
+
+%D Here:
+
+\definefilesynonym[java-imp-fld.mkiv] [java-imp-fields.mkiv]
+\definefilesynonym[java-imp-stp.mkiv] [java-imp-steps.mkiv]
+\definefilesynonym[java-imp-fil.mkiv] [java-imp-print.mkiv]
+\definefilesynonym[java-imp-rhh.mkiv] [java-imp-highlight.mkiv]
+\definefilesynonym[java-imp-exa.mkiv] [java-imp-example.mkiv]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-def.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-def.mkxl
new file mode 100644
index 00000000000..85c1f3ac775
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-def.mkxl
@@ -0,0 +1,844 @@
+%D \module
+%D [ file=lang-def,
+%D version=2011.01.24, % merge of language files
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Languages Definitions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Language Macros / Definitions}
+
+%D See \type {lang-*.tex} for some historic notes.
+
+\unprotect
+
+% Germanic Languages: Danish, Faeroese, Icelandic, Norwegian,
+% Swedish, German, Yiddish, Afrikaans, Dutch, English, Flemush,
+% Frisian, Plattdeutsch
+
+\installlanguage
+ [\s!en]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!month,\space,\v!day,{,\space},\v!year},
+ \s!patterns=\s!us,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=3]
+
+\installlanguage
+ [\s!nl]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!de]
+ [\c!spacing=\v!packed,
+ \s!lefthyphenmin=3,
+ \s!righthyphenmin=3,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsinglesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!day,{.\space},\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!da]
+ [\c!spacing=\v!packed,
+ \c!leftsentence={\hbox{\endash\enskip}},
+ \c!rightsentence={\hbox{\enskip\endash}},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsinglesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!day,{.\space},\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!sv]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\upperrightsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperrightdoubleninequote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!af]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!year,\space,\v!month,\space,\v!day}]
+
+\installlanguage
+ [\s!nb]
+ [\c!spacing=\v!packed,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!nn]
+ [\c!spacing=\v!packed,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+
+\installlanguage [\s!no] [\s!nb]
+\installlanguage [\s!norwegian] [\s!nb]
+\installlanguage [\s!bokmal] [\s!nb]
+\installlanguage [\s!nynorsk] [\s!nn]
+
+\installlanguage % old german
+ [deo]
+ [\c!spacing=\v!packed,
+ \c!default=\s!de]
+
+\installlanguage
+ [de-de]
+ [\c!spacing=\v!packed,
+ \c!default=\s!de]
+
+\installlanguage
+ [de-at]
+ [\c!spacing=\v!packed,
+ \c!default=\s!de,
+ \c!leftquote=\leftguillemot,
+ \c!rightquote=\rightguillemot,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot]
+
+\installlanguage
+ [de-ch]
+ [\c!spacing=\v!packed,
+ \c!default=\s!de]
+
+%D And some alternative (but very real) english patterns:
+
+\installlanguage
+ [en-gb]
+ [\c!default=\s!en,
+ \s!patterns=\s!gb,
+ \s!lefthyphenmin=3,
+ \s!righthyphenmin=3,
+ % the reverse of american (or maybe the american did it the reverse)
+ \c!leftquote=\upperleftdoublesixquote,
+ \c!rightquote=\upperrightdoubleninequote,
+ \c!leftquotation=\upperleftsinglesixquote,
+ \c!rightquotation=\upperrightsingleninequote]
+
+\installlanguage
+ [en-us]
+ [\c!default=\s!en,
+ \s!patterns=\s!us]
+
+\installlanguage [\s!uk] [\s!en-\s!gb]
+\installlanguage [\s!us] [\s!en-\s!us]
+
+\installlanguage [usenglish] [\s!en-\s!us]
+\installlanguage [ukenglish] [\s!en-\s!gb]
+\installlanguage [english] [\s!en]
+\installlanguage [dutch] [\s!nl]
+\installlanguage [german] [\s!de]
+\installlanguage [danish] [\s!da]
+\installlanguage [swedish] [\s!sv]
+\installlanguage [afrikaans] [\s!af]
+
+% Slavic Languages: Belarussian, Russian, Ukrainian, Bulgarian,
+% Macedonian, Serbian, Croatian, Slovenian, Czech, Kushubian,
+% Lusatian/Sorbian/Wendish, Polish, Slovak, Albanian, Illyrian,
+% Armenian
+
+\installlanguage
+ [\s!pl]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,{.\space},\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!cs]
+ [\c!spacing=\v!packed,
+ \c!leftsentence={\nobreakspace\endash\thickglue\penalty\zerocount\relax},
+ \c!rightsentence=\c!leftsentence,
+ \c!leftsubsentence=\c!leftsentence,
+ \c!rightsubsentence=\c!rightsentence,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsinglesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!day,{.\fourperemspace},\v!month,\space,\v!year},
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=3]
+
+\installlanguage
+ [\s!sk]
+ [\c!spacing=\v!packed,
+ \c!leftsentence={\nobreakspace\endash\thickglue\penalty\zerocount\relax},
+ \c!rightsentence=\c!leftsentence,
+ \c!leftsubsentence=\c!leftsentence,
+ \c!rightsubsentence=\c!rightsentence,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsinglesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!day,{.\fourperemspace},\v!month,\space,\v!year},
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=3]
+
+\installlanguage
+ [\s!hr]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!sl]
+ [\c!command=\v!no,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\guilsingleright,
+ \c!rightquote=\guilsingleleft,
+ \c!leftquotation=\rightguillemot,
+ \c!rightquotation=\leftguillemot,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+
+\installlanguage [\s!polish] [\s!pl]
+\installlanguage [\s!czech] [\s!cs]
+\installlanguage [\s!slovak] [\s!sk]
+\installlanguage [\s!croatian] [\s!hr]
+\installlanguage [\s!slovenian] [\s!sl]
+\installlanguage [slovene] [\s!sl] % both possible (mojca: still needed?)
+
+% Cyrillic Languages
+
+\installlanguage
+ [\s!ru]
+ [\s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\leftguillemot,
+ \c!rightsentence=\rightguillemot,
+ \c!leftsubsentence=\lowerleftdoubleninequote,
+ \c!rightsubsentence=\upperrightdoubleninequote,
+ \c!leftquote=\lowerleftdoubleninequote,
+ \c!rightquote=\upperrightdoubleninequote,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!ua]
+ [\s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\leftguillemot,
+ \c!rightsentence=\rightguillemot,
+ \c!leftsubsentence=\lowerleftdoubleninequote,
+ \c!rightsubsentence=\upperrightdoubleninequote,
+ \c!leftquote=\lowerleftdoubleninequote,
+ \c!rightquote=\upperrightdoubleninequote,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,\space,\v!month,\space,\v!year},
+ \s!patterns=\s!uk]
+
+\installlanguage
+ [\s!be]
+ [\s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\leftguillemot,
+ \c!rightsentence=\rightguillemot,
+ \c!leftsubsentence=\lowerleftdoubleninequote,
+ \c!rightsubsentence=\upperrightdoublesixquote,
+ \c!leftquote=\lowerleftdoubleninequote,
+ \c!rightquote=\upperrightdoublesixquote,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+ \installlanguage
+ [\s!sr]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\hbox{\endash\space},
+ \c!rightsentence=\hbox{\space\endash},
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\upperrightsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperleftdoubleninequote,
+ \c!date={\v!day,{.},\space,\v!month,\space,\v!year}]
+
+\installlanguage
+ [\s!mk]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\endash,
+ \c!rightsentence=\endash,
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\upperleftsingleninequote,
+ \c!rightquote=\upperrightsinglesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage [\s!russian] [\s!ru]
+\installlanguage [\s!ukrainian] [\s!ua]
+\installlanguage [\s!belarussian][\s!be]
+\installlanguage [\s!serbian] [\s!sr]
+\installlanguage [\s!sr-latn] [\s!sr]
+\installlanguage [\s!sr-cyrl] [\s!sr]
+\installlanguage [\s!macedonian] [\s!mk]
+
+
+% Uralic Languages: Cheremiss, Estonian, Finnish, Karelian, Laap,
+% Mordvinian, Permian tongues, Hungarian, Ostyak, Vogul, Samoyed
+
+\installlanguage
+ [\s!fi]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!year,\space,\v!month,\space,\v!day}]
+
+\installlanguage
+ [\s!et]
+ [\c!default=\s!en,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\leftguillemot,
+ \c!rightquote=\rightguillemot,
+ \c!leftquotation=\lowerrightdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!time={h,{.},m},
+ \c!date={\v!day,.,\space,\v!month,\space,\v!year},
+ \s!patterns=\s!et]
+
+\installlanguage
+ [\s!hu]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\lowerleftsingleninequote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!year,.,\space,\v!month,\space,\v!day,.}]
+
+\installlanguage [\s!finnish] [\s!fi]
+\installlanguage [\s!estonian] [\s!et]
+\installlanguage [\s!hungarian] [\s!hu]
+
+% Altaic Languages: Uigur, Uzbek, Azeri/Azerbaijani, Chuvash,
+% Turkish, Turkmen, Kazakh, Kazar, Kireghiz, Noghay, Talar,
+% Buryat, Kalmuck, Khalkha
+
+\installlanguage
+ [\s!tr]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!year,\space,\v!month,\space,\v!day}]
+
+\installlanguage
+ [\s!tk]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!year,\space,\v!month,\space,\v!day},
+ \s!patterns=\s!tk,
+ \s!lefthyphenmin=1,
+ \s!righthyphenmin=2]
+
+\installlanguage [\s!turkish] [\s!tr]
+\installlanguage [\s!turkmen] [\s!tk]
+
+% Anatolian Languages
+
+% Hebrew
+
+\installlanguage % same as arabic now .. someone needs to fix this
+ [\s!he]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,\space,\v!month,{،\space},\v!year}]
+
+\installlanguage % same as arabic now .. someone needs to fix this
+ [\s!yi]
+ [\s!he]
+
+\installlanguage [\s!hebrew] [\s!he]
+\installlanguage [\s!yiddish] [\s!yi]
+
+% Arabic Languages
+
+\installlanguage
+ [\s!ar]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,\space,\v!month,{،\space},\v!year}]
+
+\installlanguage [\s!arabic] [\s!ar]
+
+\installlanguage
+ [\s!pe]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\leftguillemot,
+ \c!rightquote=\rightguillemot,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage [\s!persian] [\s!pe]
+\installlanguage [\s!fa] [\s!pe] % these two are redundant but sometimes might
+\installlanguage [\s!farsi] [\s!fa] % sound more natural .. best set labels to 'pe'
+
+% Just aliases to "ar" for now
+
+\installlanguage[\s!ar-ae][\c!default=\s!ar] % U.A.E.
+\installlanguage[\s!ar-bh][\c!default=\s!ar] % Bahrain
+\installlanguage[\s!ar-eg][\c!default=\s!ar] % Egypt
+\installlanguage[\s!ar-in][\c!default=\s!ar] % India?
+\installlanguage[\s!ar-kw][\c!default=\s!ar] % Kuwait
+\installlanguage[\s!ar-ly][\c!default=\s!ar] % Libya
+\installlanguage[\s!ar-om][\c!default=\s!ar] % Oman
+\installlanguage[\s!ar-qa][\c!default=\s!ar] % Qatar
+\installlanguage[\s!ar-sa][\c!default=\s!ar] % Saudi Arabia
+\installlanguage[\s!ar-sd][\c!default=\s!ar] % Sudan
+\installlanguage[\s!ar-tn][\c!default=\s!ar] % Tunisia
+\installlanguage[\s!ar-ye][\c!default=\s!ar] % Yemen
+
+% Farsi (Persian)
+
+\installlanguage[\s!ar-ir][\c!default=\s!pe]
+%installlanguage[\s!pe-ir][\c!default=\s!pe]
+%installlanguage[\s!fa-ir][\c!default=\s!fa]
+
+% Syriac months
+
+\installlanguage[\s!ar-sy][\c!default=\s!ar] % Syria
+\installlanguage[\s!ar-iq][\c!default=\s!ar-sy] % Iraq
+\installlanguage[\s!ar-jo][\c!default=\s!ar-sy] % Jordan
+\installlanguage[\s!ar-lb][\c!default=\s!ar-sy] % Lebanon
+
+% Maghribi months
+
+\installlanguage[\s!ar-dz][\c!default=\s!ar] % Algeria
+\installlanguage[\s!ar-ma][\c!default=\s!ar] % Morocco
+
+% Artificial Languages: Esperanto
+
+\installlanguage
+ [\s!esperanto]
+ [%\c!spacing=\v!packed,
+ %\c!leftsentence=\emdash,
+ %\c!rightsentence=\emdash,
+ %\c!leftsubsentence=\emdash,
+ %\c!rightsubsentence=\emdash,
+ %\c!leftquote=\lowerleftdoubleninequote,
+ %\c!rightquote=\upperrightdoublesixquote,
+ %\c!leftquotation=\lowerleftdoubleninequote,
+ %\c!rightquotation=\upperrightdoublesixquote,
+ %\c!date={\v!year,~m.,\space,\v!month,\space,\v!day,~d.},
+ \s!patterns=eo,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=2]
+
+% Baltic Languages: Lettish/Latvian, Lietuvių/Lithuanian
+
+\installlanguage
+ [\s!lt]
+ [\c!command=\v!no,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\lowerleftdoubleninequote,
+ \c!rightquote=\upperrightdoublesixquote,
+ \c!leftquotation=\lowerleftdoubleninequote,
+ \c!rightquotation=\upperrightdoublesixquote,
+ \c!date={\v!year,~m.,\space,\v!month,\space,\v!day,~d.},
+ \s!patterns=\s!lt,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=2]
+
+\installlanguage [\s!lithuanian] [\s!lt]
+
+% Celtic: Breton, Welsh, Irish, Manx, Scottish Gaelic
+
+% CJK: Chinese, Japanese, Korean
+
+\installlanguage
+ [\s!cn]
+ [\c!leftsentence=——,
+ \c!rightsentence=——,
+ \c!leftsubsentence=——,
+ \c!rightsubsentence=——,
+ \c!leftquote=‘,
+ \c!rightquote=’,
+ \c!leftquotation=“,
+ \c!rightquotation=”,
+ \c!date={\v!year,年,\space,\v!month,\v!day,日}]
+
+\installlanguage
+ [\s!ja]
+ [\c!leftsentence=——,
+ \c!rightsentence=——,
+ \c!leftsubsentence=——,
+ \c!rightsubsentence=——,
+ \c!leftquote=‘,
+ \c!rightquote=’,
+ \c!leftquotation=「,
+ \c!rightquotation=」,
+ \c!date={西暦,\v!year,年,\v!month,月,\v!day,日}]
+
+\installlanguage
+ [\s!kr]
+ [\c!leftsentence=——,
+ \c!rightsentence=——,
+ \c!leftsubsentence=——,
+ \c!rightsubsentence=——,
+ \c!leftquote=‘,
+ \c!rightquote=’,
+ \c!leftquotation=“,
+ \c!rightquotation=”,
+ % \c!date={서기,\space,\v!year,\labeltext{\v!year},\space,\v!month,\labeltext{\v!month},\space,\v!day,\labeltext{\v!day}}]
+ \c!date={\v!year,\labeltext{\v!year},\space,\v!month,\labeltext{\v!month},\space,\v!day,\labeltext{\v!day}}]
+
+\installlanguage [\s!chinese] [\s!cn]
+\installlanguage [\s!japanese] [\s!ja]
+\installlanguage [\s!korean] [\s!kr]
+
+% Greek
+
+\installlanguage
+ [\s!gr]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=“,
+ \c!rightquote=”,
+ \c!leftquotation=«,
+ \c!rightquotation=»,
+ \c!date={\v!day\space\v!month\space\v!year},
+ \s!patterns=\s!agr] % ok?
+
+\installlanguage [\s!greek] [\s!gr]
+
+\installlanguage
+ [\s!agr]
+ [\s!default=\s!gr,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote]
+
+\installlanguage [\s!ancientgreek] [\s!agr]
+
+% Indo-Iranian Languages: 34.
+
+% Italic Languages: Latin, Italian, Rhaeto-Romanic, Rumanian,
+% Sardian, Catalan, French, Ladino, Portuguese, Proven\c{c}al,
+% Spanish
+
+\installlanguage
+ [\s!fr]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\leftguillemot,
+ \c!rightquote=\rightguillemot,
+ \c!leftquotation=\leftguillemot,
+ \c!rightquotation=\rightguillemot,
+ \c!time={h,{\Uchar104 },m},% we need to cheat in order to get the h
+ \c!date={\v!day:mnem,\v!space,\v!month,\v!space,\v!year}]
+
+\installlanguage
+ [\s!es]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,{ de },\v!month,{ de },\v!year}]
+
+\installlanguage [sp] [\s!es] % old times context
+
+\installlanguage
+ [\s!ca]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+% Note GB left|/|right (sub)sentences are for \quote {incisi}.
+
+\installlanguage
+ [\s!it]
+ [\c!command=\v!no,
+ \c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\endash,
+ \c!rightsubsentence=\endash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!leftspeech=\leftguillemot,
+ \c!middlespeech=\leftguillemot,
+ \c!rightspeech=\rightguillemot,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage % the same as italian
+ [\s!la]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+\installlanguage % ancient latin
+ [\s!ala]
+ [\c!default=\s!la]
+
+\installlanguage
+ [\s!pt]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!year,\space,\v!month,\space,\v!day}]
+
+\installlanguage[\s!pt-br][\c!default=\s!pt] % Brazil
+\installlanguage[\s!es-es][\c!default=\s!es] % Spain
+\installlanguage[\s!es-la][\c!default=\s!es] % Latin America
+
+\installlanguage
+ [\s!ro]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\leftguillemot,
+ \c!rightquote=\rightguillemot,
+ \c!leftquotation=\lowerrightdoubleninequote,
+ \c!rightquotation=\upperleftdoublesixquote,
+ \c!date={\v!day,\space,\v!month,\space,\v!year}]
+
+%D For compatibility reasons we also define:
+
+\installlanguage [\s!french] [\s!fr]
+\installlanguage [\s!spanish] [\s!es]
+\installlanguage [\s!catalan] [\s!ca]
+\installlanguage [\s!italian] [\s!it]
+\installlanguage [\s!latin] [\s!la]
+\installlanguage [\s!portuguese] [\s!pt]
+\installlanguage [\s!romanian] [\s!ro]
+
+% Vietnamese Language
+
+\installlanguage
+ [\s!vi]
+ [\c!spacing=\v!packed,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\quoteleft,
+ \c!rightquote=\quoteright,
+ \c!leftquotation=\quotedblleft,
+ \c!rightquotation=\quotedblright,
+ \c!date={{ },dd,{/},mm,{/},yy}]
+
+\installlanguage [\s!vietnamese] [\s!vi]
+
+% Thai (teaser for Mojca)
+
+\installlanguage
+ [\s!th]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!month,\space,\v!day,{,\space},\v!year},
+ \s!patterns=\s!th,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=3]
+
+\installlanguage [\s!thai] [\s!th]
+
+%D Malayalam (needs to be checked)
+
+\installlanguage
+ [\s!ml]
+ [\c!spacing=\v!broad,
+ \c!leftsentence=\emdash,
+ \c!rightsentence=\emdash,
+ \c!leftsubsentence=\emdash,
+ \c!rightsubsentence=\emdash,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!date={\v!month,\space,\v!day,{,\space},\v!year},
+ \s!patterns=\s!ml,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=3]
+
+\installlanguage [\s!malayalam] [\s!ml]
+
+%D Todo: generate this one from languages.data
+
+\installlanguage[nld][\s!nl]
+\installlanguage[deu][\s!de]
+\installlanguage[eng][\s!en]
+\installlanguage[fra][\s!fr]
+%installlanguage[grk][\s!agr]
+
+%D This might go:
+
+\installlanguage[cz][\s!cs]
+%installlanguage[fa][\s!fr] % for dutchies only
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-dis.lmt b/Master/texmf-dist/tex/context/base/mkxl/lang-dis.lmt
new file mode 100644
index 00000000000..263225691f0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-dis.lmt
@@ -0,0 +1,222 @@
+if not modules then modules = { } end modules ['lang-dis'] = {
+ version = 1.001,
+ comment = "companion to lang-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local concat = table.concat
+
+local tex = tex
+local nodes = nodes
+
+local tasks = nodes.tasks
+local nuts = nodes.nuts
+
+local enableaction = tasks.enableaction
+local setaction = tasks.setaction
+
+local setfield = nuts.setfield
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getattr = nuts.getattr
+local getsubtype = nuts.getsubtype
+local setsubtype = nuts.setsubtype
+local getchar = nuts.getchar
+local setchar = nuts.setchar
+local getdisc = nuts.getdisc
+local setdisc = nuts.setdisc
+local getlanguage = nuts.getlanguage
+local getboth = nuts.getboth
+local setlist = nuts.setlist
+local setlink = nuts.setlink
+local isglyph = nuts.isglyph
+
+local copy_node = nuts.copy
+local remove_node = nuts.remove
+local flush_list = nuts.flush_list
+local flush_node = nuts.flush_node
+
+local nextdisc = nuts.traversers.disc
+
+local new_disc = nuts.pool.disc
+
+local nodecodes = nodes.nodecodes
+local disccodes = nodes.disccodes
+
+local disc_code = nodecodes.disc
+local glyph_code = nodecodes.glyph
+
+local explicitdisc_code = disccodes.explicit
+
+local a_visualize = attributes.private("visualizediscretionary")
+local setattribute = tex.setattribute
+
+local getlanguagedata = languages.getdata
+local prehyphenchar = language.prehyphenchar
+local posthyphenchar = language.posthyphenchar
+
+local check_regular = true
+
+local setlistcolor = nodes.tracers.colors.setlist
+
+function languages.visualizediscretionaries(head)
+ for d in nextdisc, head do
+ if getattr(d,a_visualize) then
+ local pre, post, replace = getdisc(d)
+ if pre then
+ setlistcolor(pre,"darkred")
+ end
+ if post then
+ setlistcolor(post,"darkgreen")
+ end
+ if replace then
+ setlistcolor(replace,"darkblue")
+ end
+ end
+ end
+ return head
+end
+
+local enabled = false
+
+function languages.showdiscretionaries(v)
+ if v == false then
+ setattribute(a_visualize,unsetvalue)
+ else -- also nil
+ if not enabled then
+ enableaction("processors","languages.visualizediscretionaries")
+ enabled = true
+ end
+ setattribute(a_visualize,1)
+ end
+end
+
+interfaces.implement {
+ name = "showdiscretionaries",
+ actions = languages.showdiscretionaries
+}
+
+do
+
+ local toutf = nodes.listtoutf
+ local utfchar = utf.char
+ local f_disc = string.formatters["{%s}{%s}{%s}"]
+ local replace = lpeg.replacer( {
+ [utfchar(0x200C)] = "|",
+ [utfchar(0x200D)] = "|",
+ }, nil, true)
+
+ local function convert(list)
+ return list and replace(toutf(list)) or ""
+ end
+
+ function languages.serializediscretionary(d) -- will move to tracer
+ local pre, post, replace = getdisc(d)
+ return f_disc(convert(pre),convert(post),convert(replace))
+ end
+
+end
+
+-- --
+
+local wiped = 0
+
+local flatten_discretionaries = nuts.flatten_discretionaries -- todo in nodes
+
+-- if flatten_discretionaries then
+
+ function languages.flatten(head)
+ local h, n = flatten_discretionaries(head)
+ wiped = wiped + n
+ return h, n > 0
+ end
+
+-- else
+--
+-- local function wipe(head,delayed)
+-- local p, n = getboth(delayed)
+-- local _, _, h, _, _, t = getdisc(delayed,true)
+-- if p or n then
+-- if h then
+-- setlink(p,h)
+-- setlink(t,n)
+-- setfield(delayed,"replace")
+-- else
+-- setlink(p,n)
+-- end
+-- end
+-- if head == delayed then
+-- head = h
+-- end
+-- wiped = wiped + 1
+-- flush_node(delayed)
+-- return head
+-- end
+--
+-- function languages.flatten(head)
+-- local delayed = nil
+-- for d in nextdisc, head do
+-- if delayed then
+-- head = wipe(head,delayed)
+-- end
+-- delayed = d
+-- end
+-- if delayed then
+-- return wipe(head,delayed), true
+-- else
+-- return head, false
+-- end
+-- end
+--
+-- end
+
+function languages.nofflattened()
+ return wiped -- handy for testing
+end
+
+-- experiment: for now not in not in export mode!
+
+local flatten = languages.flatten
+
+nodes.handlers.flattenline = flatten
+
+function nodes.handlers.flatten(head,where)
+ if head and (where == "box" or where == "adjusted_hbox") then
+ return flatten(head)
+ end
+ return head
+end
+
+directives.register("hyphenator.flatten",function(v)
+ -- use with care
+ setaction("processors","nodes.handlers.flatten",v)
+ setaction("contributers","nodes.handlers.flattenline",v)
+end)
+
+-- moved here:
+
+function languages.explicithyphen(template)
+ local pre, post
+ local disc = new_disc()
+ if template then
+ local langdata = getlanguagedata(getlanguage(template))
+ local instance = langdata and langdata.instance
+ if instance then
+ local prechr = prehyphenchar(instance)
+ local postchr = posthyphenchar(instance)
+ if prechr >= 0 then
+ pre = copy_node(template)
+ setchar(pre,prechr)
+ end
+ if postchr >= 0 then
+ post = copy_node(template)
+ setchar(post,postchr)
+ end
+ end
+ end
+ setdisc(disc,pre,post,nil,explicitdisc_code,tex.exhyphenpenalty)
+ return disc
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-frd.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-frd.mkxl
new file mode 100644
index 00000000000..352e5016dec
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-frd.mkxl
@@ -0,0 +1,143 @@
+%D \module
+%D [ file=lang-frd,
+%D version=2004.01.15,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Language Frequency Table Data,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\endinput
+
+%D This is experimental work! Old stuff, whenever I need it I might
+%D do it in \LUA.
+
+% http://www.onzetaal.nl/advies/letterfreq.html
+
+\startcharactertable[nl]
+ \charfreq a 7.47
+ \charfreq b 1.58
+ \charfreq c 1.24
+ \charfreq d 5.93
+ \charfreq e 18.91
+ \charfreq f .81
+ \charfreq g 3.4
+ \charfreq h 2.38
+ \charfreq i 6.5
+ \charfreq j 1.46
+ \charfreq k 2.25
+ \charfreq l 3.57
+ \charfreq m 2.21
+ \charfreq n 10.03
+ \charfreq o 6.06
+ \charfreq p 1.57
+ \charfreq q .009
+ \charfreq r 6.41
+ \charfreq s 3.73
+ \charfreq t 6.79
+ \charfreq u 1.99
+ \charfreq v 2.85
+ \charfreq w 1.52
+ \charfreq x .04
+ \charfreq y .035
+ \charfreq z 1.39
+\stopcharactertable
+
+% http://caislab.icu.ac.kr/course/2001/spring/ice605/down/010306.pdf
+
+% \startcharactertable[en]
+% \charfreq a 8.2
+% \charfreq b 1.5
+% \charfreq c 2.8
+% \charfreq d 4.3
+% \charfreq e 12.7
+% \charfreq f 2.2
+% \charfreq g 2
+% \charfreq h 6.1
+% \charfreq i 7
+% \charfreq j .2
+% \charfreq k .8
+% \charfreq l 4
+% \charfreq m 2.4
+% \charfreq n 6.7
+% \charfreq o 7.5
+% \charfreq p 1.9
+% \charfreq q .1
+% \charfreq r 6
+% \charfreq s 6.3
+% \charfreq t 9.1
+% \charfreq u 2.8
+% \charfreq v 1
+% \charfreq w 2.3
+% \charfreq x .1
+% \charfreq y 2
+% \charfreq z .1
+% \stopcharactertable
+
+% http://www.blankenburg.de/gat/pages/fach/info/analyse2.htm
+
+\startcharactertable[en]
+ \charfreq a 8.04
+ \charfreq b 1.54
+ \charfreq c 3.06
+ \charfreq d 3.99
+ \charfreq e 12.51
+ \charfreq f 2.3
+ \charfreq g 1.96
+ \charfreq h 5.49
+ \charfreq i 7.26
+ \charfreq j .16
+ \charfreq k .67
+ \charfreq l 4.14
+ \charfreq m 2.53
+ \charfreq n 7.09
+ \charfreq o 7.6
+ \charfreq p 2
+ \charfreq q .11
+ \charfreq r 6.12
+ \charfreq s 6.54
+ \charfreq t 9.25
+ \charfreq u 2.71
+ \charfreq v .99
+ \charfreq w 1.92
+ \charfreq x .19
+ \charfreq y 1.73
+ \charfreq z .09
+\stopcharactertable
+
+% http://www.blankenburg.de/gat/pages/fach/info/analyse2.htm
+
+\startcharactertable[de]
+ \charfreq a 6.47
+ \charfreq b 1.93
+ \charfreq c 2.68
+ \charfreq d 4.83
+ \charfreq e 17.48
+ \charfreq f 1.65
+ \charfreq g 3.06
+ \charfreq h 4.23
+ \charfreq i 7.73
+ \charfreq j .27
+ \charfreq k 1.46
+ \charfreq l 3.49
+ \charfreq m 2.58
+ \charfreq n 9.84
+ \charfreq o 2.98
+ \charfreq p .96
+ \charfreq q .02
+ \charfreq r 7.54
+ \charfreq s 6.83
+ \charfreq t 6.13
+ \charfreq u 4.17
+ \charfreq v .94
+ \charfreq w 1.48
+ \charfreq x .04
+ \charfreq y .08
+ \charfreq z 1.14
+\stopcharactertable
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-frq.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-frq.mkxl
new file mode 100644
index 00000000000..6b9853af574
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-frq.mkxl
@@ -0,0 +1,234 @@
+%D \module
+%D [ file=lang-frq,
+%D version=2004.01.15,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Frequency Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\endinput
+
+\writestatus{loading}{ConTeXt Language Macros / Frequency Tables}
+
+%D Some day I might redo this \LUA. But anyway, who uses it. It's rather old code.
+
+\unprotect
+
+%M \usemodule[layout]
+
+%D \macros
+%D {charwidthmethod}
+%D
+%D This module implements a method for determining the width of an
+%D average character in a language. It uses the dimensions of the
+%D current fonts.
+%D
+%D \def\ShwChrWd#1#2#3%
+%D {\chardef\charwidthmethod#1\relax
+%D \mainlanguage[#2#3]\the\dimexpr(\averagecharwidth)}
+%D
+%D \starttabulate[|c|c|c|c|c|c|]
+%D \HL
+%D \NC \NC\bf0=amount\NC\bf1=.5em\NC2=ex\NC\bf3=frequency\NC\bf4=list\NC\NR
+%D \HL
+%D \NC\bf en\NC\ShwChrWd0en\NC\ShwChrWd1en\NC\ShwChrWd2en\NC\ShwChrWd3en\NC\ShwChrWd4en\NC\NR
+%D \NC\bf nl\NC\ShwChrWd0nl\NC\ShwChrWd1nl\NC\ShwChrWd2nl\NC\ShwChrWd3nl\NC\ShwChrWd4nl\NC\NR
+%D \NC\bf de\NC\ShwChrWd0de\NC\ShwChrWd1de\NC\ShwChrWd2de\NC\ShwChrWd3de\NC\ShwChrWd4de\NC\NR
+%D \HL
+%D \stoptabulate
+%D
+%D Method~1 ignores the widths and assumes that each character has a
+%D width of .5em, which is true for most monospaced fonts. Method~2
+%D takes the x as starting point, and assumes that it's height kind of
+%D matches its width. Method~3 is the best one, and determines the
+%D average width based on the language specific character table.
+%D Method~4 is a mixture between the first two methods: character
+%D specific widths applied to an equal distribution. Method~0 reports
+%D the total count, which normally is~100.
+
+\setnewconstant\charwidthmethod=3 % 0=amount 1=em 2=ex 3=frequency 4=flattened >4=ex
+
+%D \macros
+%D {charwidthlanguage}
+%D
+%D The language used for the calculations is defined as:
+
+\def\charwidthlanguage{\currentmainlanguage}
+
+%D \macros
+%D {charfreq}
+%D
+%D This method comes into action in the following macro:
+
+\def\charfreq#1 #2 % character fraction
+ {+(\ifcase\charwidthmethod
+ #2\dimexpr100\onepoint\relax
+ \or
+ #2\dimexpr\emwidth/2\relax
+ \or
+ #2\dimexpr\exheight\relax
+ \or
+ #2\fontcharwd\font`#1%
+ \or
+ \dimexpr100\fontcharwd\font`#1/\charactertsize\charwidthlanguage\relax % ugly hack
+ \else
+ #2\dimexpr\exheight\relax
+ \fi)}
+
+%D \macros
+%D {startcharactertable}
+%D
+%D A frequency table is defined with the following macro. The \type
+%D {charfreq} macro is used in this table.
+
+\installcorenamespace{frequencywidths}
+\installcorenamespace{frequencycounts}
+
+\aliased\let\stopcharactertable\relax
+
+\permanent\protected\def\startcharactertable[#1]#2\stopcharactertable % \dimexpr has fuzzy lookahead
+ {\startnointerference
+ \gdefcsname\??frequencywidths#1\endcsname{#2}% the width vector
+ \scratchcounter\zerocount \def\charfreq##1 ##2 {\advance\scratchcounter\plusone} #2%
+ \xdefcsname\??frequencycounts#1\endcsname{\the\scratchcounter}% the character count
+ \stopnointerference}
+
+%D \macros
+%D {charactertable,charactertsize}
+%D
+%D The table content as well as the number of entries can be fetched with
+%D the following two macros. The architecture of the table and calling
+%D macro permits a fully expandable application.
+
+\permanent\def\charactertable#1%
+ {\csname\??frequencywidths\ifcsname\??frequencywidths#1\endcsname#1\else\s!en\fi\endcsname}
+
+\permanent\def\charactertsize#1%
+ {\csname\??frequencycounts\ifcsname\??frequencycounts#1\endcsname#1\else\s!en\fi\endcsname}
+
+%D Although it is of hardly any use, you can inherit a character table:
+%D
+%D \starttyping
+%D \startcharactertable[cz] \charactertable{en} \stopcharactertable
+%D \stoptyping
+
+\startcharactertable[en]
+ % empty
+\stopcharactertable % kind of default
+
+%D \macros
+%D {averagecharwidth}
+%D
+%D This macro reports the average width for the current main
+%D language (\the \dimexpr (\averagecharwidth)).
+
+\permanent\def\averagecharwidth{\dimexpr(\zeropoint\charactertable\charwidthlanguage)/100\relax}
+
+\permanent\protected\def\showcharfreq
+ {\hbox\bgroup
+ \charwidthlanguage:%
+ \dostepwiserecurse\zerocount\plusfour\plusone
+ {\setconstant\charwidthmethod\recurselevel\relax
+ \enspace\recurselevel/\the\dimexpr(\averagecharwidth)}%
+ \egroup}
+
+%D Just for fun, we show a few frequency tables as graphic (\in {figure}
+%D [fig:charfreq]).
+%D
+%D \startbuffer
+%D \definepalet [charfreq] [en=darkred, nl=darkgreen, de=darkblue]
+%D
+%D \def\charfreq#1 #2 %
+%D {\startMPdrawing
+%D interim linejoin := butt ;
+%D a := ASCII "#1" ;
+%D if (a >= (ASCII "a")) and (a <= (ASCII "z")) :
+%D draw ((0,#2*.25cm)--origin--(0,#2*.5cm))
+%D shifted (a*4mm+o,0)
+%D withpen pencircle scaled .5mm
+%D withcolor c;
+%D fi ;
+%D \stopMPdrawing}
+%D
+%D \resetMPdrawing
+%D \startMPdrawing
+%D numeric a, o ; a := o := 0 ;
+%D color c ; c := .5white ;
+%D string s ; s := "" ;
+%D \stopMPdrawing
+%D
+%D \startMPdrawing o := 0mm ; c := \MPcolor{charfreq:en} ; \stopMPdrawing
+%D \charactertable{en}
+%D
+%D \startMPdrawing o := 1mm ; c := \MPcolor{charfreq:nl} ; \stopMPdrawing
+%D \charactertable{nl}
+%D
+%D \startMPdrawing o := 2mm ; c := \MPcolor{charfreq:de} ; \stopMPdrawing
+%D \charactertable{de}
+%D
+%D \startMPdrawing
+%D for a := ASCII "a" upto ASCII "z" :
+%D draw textext.bot("\strut\tttf " & char a) shifted (a*4mm+1mm,-1mm) ;
+%D endfor ;
+%D \stopMPdrawing
+%D
+%D \MPdrawingdonetrue \getMPdrawing \resetMPdrawing
+%D \stopbuffer
+%D
+%D \placefigure
+%D [here]
+%D [fig:charfreq]
+%D {The character distributions for English, Dutch and German.}
+%D {\getbuffer}
+%D
+%D A few samples of usage of this mechanism are shown below:
+%D
+%D \startbuffer
+%D {\mainlanguage[en]\hsize65\averagecharwidth\mainlanguage[en]\input ward \blank}
+%D {\mainlanguage[nl]\hsize65\averagecharwidth\mainlanguage[en]\input ward \blank}
+%D {\mainlanguage[de]\hsize65\averagecharwidth\mainlanguage[en]\input ward \blank}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D Although the widthts differ, the consequenes for breaking the paragraph
+%D into lines are minimal.
+
+%D \macros
+%D {freezeaveragecharacterwidth}
+%D
+%D This macro can be used to make sure that the width does not change during a
+%D page break when another font is used.
+
+\aliased\let\normalaveragecharacterwidth\averagecharacterwidth
+
+\permanent\def\freezeaveragecharacterwidth % global
+ {\enforced\xdef\averagecharacterwidth{\dimexpr\the\normalaveragecharacterwidth\relax}}
+
+%D Example:
+%D
+%D \starttyping
+%D \input lang-frq.mkiv
+%D \input lang-frd.mkiv
+%D
+%D \setupbodyfont
+%D [dejavu]
+%D
+%D \setemeasure{textwidth}{\the\dimexpr70\averagecharwidth}
+%D
+%D \setuplayout
+%D [width=\measure{textwidth}]
+%D
+%D \showframe
+%D
+%D \starttext
+%D \input ward
+%D \stoptext
+%D \stoptyping
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-hyp.lmt b/Master/texmf-dist/tex/context/base/mkxl/lang-hyp.lmt
new file mode 100644
index 00000000000..c356dbf3c47
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-hyp.lmt
@@ -0,0 +1,1806 @@
+if not modules then modules = { } end modules ['lang-hyp'] = {
+ version = 1.001,
+ comment = "companion to lang-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- In an automated workflow hypenation of long titles can be somewhat problematic
+-- especially when demands conflict. For that reason I played a bit with a Lua based
+-- variant of the traditional hyphenation machinery. This mechanism has been extended
+-- several times in projects, of which a good description can be found in TUGboat,
+-- Volume 27 (2006), No. 2 — Proceedings of EuroTEX2006: Automatic non-standard
+-- hyphenation in OpenOffice.org by László Németh.
+--
+-- Being the result of two days experimenting the following implementation is probably
+-- not completely okay yet. If there is demand I might add some more features and plugs.
+-- The performance is quite okay but can probably improved a bit, although this is not
+-- the most critital code. For instance, on a metafun manual run the overhead is about
+-- 0.3 seconds on 19 seconds which is not that bad.
+--
+-- In the procecess of wrapping up (for the ctx conference proceedings) I cleaned up
+-- and extended the code a bit. It can be used in production.
+--
+-- . a l g o r i t h m .
+-- 4l1g4
+-- l g o3
+-- 1g o
+-- 2i t h
+-- 4h1m
+-- ---------------------
+-- 4 1 4 3 2 0 4 1
+-- a l-g o-r i t h-m
+
+-- . a s s z o n n y a l .
+-- s1s z/sz=sz,1,3
+-- n1n y/ny=ny,1,3
+-- -----------------------
+-- 0 1 0 0 0 1 0 0 0/sz=sz,2,3,ny=ny,6,3
+-- a s-s z o n-n y a l/sz=sz,2,3,ny=ny,6,3
+--
+-- ab1cd/ef=gh,2,2 : acd - efd (pattern/replacement,start,length
+--
+-- todo : support hjcodes (<32 == length) like luatex does now (no need/demand so far)
+-- maybe : support hyphenation over range (can alsready be done using attributes/language)
+-- maybe : reset dictionary.hyphenated when a pattern is added and/or forced reset option
+-- todo : check subtypes (because they have subtle meanings in the line breaking)
+--
+-- word start (in tex engine):
+--
+-- boundary : yes when wordboundary
+-- hlist : when hyphenationbounds 1 or 3
+-- vlist : when hyphenationbounds 1 or 3
+-- rule : when hyphenationbounds 1 or 3
+-- dir : when hyphenationbounds 1 or 3
+-- whatsit : when hyphenationbounds 1 or 3
+-- glue : yes
+-- math : skipped
+-- glyph : exhyphenchar (one only) : yes (so no -- ---)
+-- otherwise : yes
+--
+-- word end (in tex engine):
+--
+-- boundary : yes
+-- glyph : yes when different language
+-- glue : yes
+-- penalty : yes
+-- kern : yes when not italic (for some historic reason)
+-- hlist : when hyphenationbounds 2 or 3
+-- vlist : when hyphenationbounds 2 or 3
+-- rule : when hyphenationbounds 2 or 3
+-- dir : when hyphenationbounds 2 or 3
+-- whatsit : when hyphenationbounds 2 or 3
+-- ins : when hyphenationbounds 2 or 3
+-- adjust : when hyphenationbounds 2 or 3
+
+local type, rawget, rawset, tonumber, next = type, rawget, rawset, tonumber, next
+
+local P, R, S, Cg, Cf, Ct, Cc, C, Carg, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.Cg, lpeg.Cf, lpeg.Ct, lpeg.Cc, lpeg.C, lpeg.Carg, lpeg.Cs
+local lpegmatch = lpeg.match
+
+local context = context
+
+local concat = table.concat
+local insert = table.insert
+local remove = table.remove
+local formatters = string.formatters
+local utfchar = utf.char
+local utfbyte = utf.byte
+
+if not characters then
+ require("char-ini")
+end
+
+local setmetatableindex = table.setmetatableindex
+
+-- \enabletrackers[hyphenator.steps=silent] will not write to the terminal
+
+local trace_steps = false trackers.register("hyphenator.steps", function(v) trace_steps = v end)
+local trace_visualize = false trackers.register("hyphenator.visualize",function(v) trace_visualize = v end)
+
+local report = logs.reporter("hyphenator")
+
+local implement = interfaces and interfaces.implement or function() end
+
+languages = languages or { }
+local hyphenators = languages.hyphenators or { }
+languages.hyphenators = hyphenators
+local traditional = hyphenators.traditional or { }
+hyphenators.traditional = traditional
+
+local dictionaries = setmetatableindex(function(t,k)
+ local v = {
+ patterns = { },
+ hyphenated = { },
+ specials = { },
+ exceptions = { },
+ loaded = false,
+ }
+ t[k] = v
+ return v
+end)
+
+hyphenators.dictionaries = dictionaries
+
+local character = lpeg.patterns.utf8character
+local digit = R("09")
+local weight = digit/tonumber + Cc(0)
+local fence = P(".")
+local hyphen = P("-")
+local space = P(" ")
+local char = character - space
+local validcharacter = (character - S("./"))
+local keycharacter = character - S("/")
+----- basepart = Ct( (Cc(0) * fence)^-1 * (weight * validcharacter)^1 * weight * (fence * Cc(0))^-1)
+local specpart = (P("/") * Cf ( Ct("") *
+ Cg ( Cc("before") * C((1-P("="))^1) * P("=") ) *
+ Cg ( Cc("after") * C((1-P(","))^1) ) *
+ ( P(",") *
+ Cg ( Cc("start") * ((1-P(","))^1/tonumber) * P(",") ) *
+ Cg ( Cc("length") * ((1-P(-1) )^1/tonumber) )
+ )^-1
+ , rawset))^-1
+
+local make_hashkey_p = Cs((digit/"" + keycharacter)^1)
+----- make_pattern_p = basepart * specpart
+local make_hashkey_e = Cs((hyphen/"" + keycharacter)^1)
+local make_pattern_e = Ct(P(char) * (hyphen * Cc(true) * P(char) + P(char) * Cc(false))^1) -- catch . and char after -
+
+-- local make_hashkey_c = Cs((digit + keycharacter/"")^1)
+-- local make_pattern_c = Ct((P(1)/tonumber)^1)
+
+-- local cache = setmetatableindex(function(t,k)
+-- local n = lpegmatch(make_hashkey_c,k)
+-- local v = lpegmatch(make_pattern_c,n)
+-- t[k] = v
+-- return v
+-- end)
+--
+-- local weight_n = digit + Cc("0")
+-- local basepart_n = Cs( (Cc("0") * fence)^-1 * (weight * validcharacter)^1 * weight * (fence * Cc("0"))^-1) / cache
+-- local make_pattern_n = basepart_n * specpart
+
+local make_pattern_c = Ct((P(1)/tonumber)^1)
+
+-- us + nl: 17664 entries -> 827 unique (saves some 3M)
+
+local cache = setmetatableindex(function(t,k)
+ local v = lpegmatch(make_pattern_c,k)
+ t[k] = v
+ return v
+end)
+
+local weight_n = digit + Cc("0")
+local fence_n = fence / "0"
+local char_n = validcharacter / ""
+local basepart_n = Cs(fence_n^-1 * (weight_n * char_n)^1 * weight_n * fence_n^-1) / cache
+local make_pattern_n = basepart_n * specpart
+
+local function register_pattern(patterns,specials,str,specification)
+ local k = lpegmatch(make_hashkey_p,str)
+ -- local v1, v2 = lpegmatch(make_pattern_p,str)
+ local v1, v2 = lpegmatch(make_pattern_n,str)
+ patterns[k] = v1 -- is this key still ok for complex patterns
+ if specification then
+ specials[k] = specification
+ elseif v2 then
+ specials[k] = v2
+ end
+end
+
+local function unregister_pattern(patterns,specials,str)
+ local k = lpegmatch(make_hashkey_p,str)
+ patterns[k] = nil
+ specials[k] = nil
+end
+
+local p_lower = lpeg.patterns.utf8lower
+
+local function register_exception(exceptions,str,specification)
+ local l = lpegmatch(p_lower,str)
+ local k = lpegmatch(make_hashkey_e,l)
+ local v = lpegmatch(make_pattern_e,l)
+ exceptions[k] = v
+end
+
+local p_pattern = ((Carg(1) * Carg(2) * C(char^1)) / register_pattern + 1)^1
+local p_exception = ((Carg(1) * C(char^1)) / register_exception + 1)^1
+local p_split = Ct(C(character)^1)
+
+function traditional.loadpatterns(language,filename)
+ local dictionary = dictionaries[language]
+ if not dictionary.loaded then
+ if not filename or filename == "" then
+ filename = "lang-" .. language
+ end
+ filename = file.addsuffix(filename,"lua")
+ local fullname = resolvers.findfile(filename)
+ if fullname and fullname ~= "" then
+ local specification = dofile(fullname)
+ if specification then
+ local patterns = specification.patterns
+ if patterns then
+ local data = patterns.data
+ if data and data ~= "" then
+ lpegmatch(p_pattern,data,1,dictionary.patterns,dictionary.specials)
+ end
+ end
+ local exceptions = specification.exceptions
+ if exceptions then
+ local data = exceptions.data
+ if data and data ~= "" then
+ lpegmatch(p_exception,data,1,dictionary.exceptions)
+ end
+ end
+ end
+ end
+ dictionary.loaded = true
+ end
+ return dictionary
+end
+
+local lcchars = characters.lcchars
+local uccodes = characters.uccodes
+local categories = characters.categories
+local nofwords = 0
+local nofhashed = 0
+
+local steps = nil
+local f_show = formatters["%w%s"]
+
+local function show_log()
+ if trace_steps == true then
+ report()
+ local w = #steps[1][1]
+ for i=1,#steps do
+ local s = steps[i]
+ report("%s%w%S %S",s[1],w - #s[1] + 3,s[2],s[3] or "")
+ end
+ report()
+ end
+end
+
+local function show_1(wsplit)
+ local u = concat(wsplit," ")
+ steps = { { f_show(0,u), f_show(0,u) } }
+end
+
+local function show_2(c,m,wsplit,done,i,spec)
+ local s = lpegmatch(p_split,c)
+ local t = { }
+ local n = #m
+ local w = #wsplit
+ for j=1,n do
+ t[#t+1] = m[j]
+ t[#t+1] = s[j]
+ end
+ local m = 2*i-2
+ local l = #t
+ local s = spec and table.sequenced(spec) or ""
+ if m == 0 then
+ steps[#steps+1] = { f_show(m, concat(t,"",2)), f_show(1,concat(done," ",2,#done),s) }
+ elseif i+1 == w then
+ steps[#steps+1] = { f_show(m-1,concat(t,"",1,#t-1)), f_show(1,concat(done," ",2,#done),s) }
+ else
+ steps[#steps+1] = { f_show(m-1,concat(t)), f_show(1,concat(done," ",2,#done),s) }
+ end
+end
+
+local function show_3(wsplit,done)
+ local t = { }
+ local h = { }
+ local n = #wsplit
+ for i=1,n do
+ local w = wsplit[i]
+ if i > 1 then
+ local d = done[i]
+ t[#t+1] = i > 2 and d % 2 == 1 and "-" or " "
+ h[#h+1] = d
+ end
+ t[#t+1] = w
+ h[#h+1] = w
+ end
+ steps[#steps+1] = { f_show(0,concat(h)), f_show(0,concat(t)) }
+ show_log()
+end
+
+local function show_4(wsplit,done)
+ steps = { { concat(wsplit," ") } }
+ show_log()
+end
+
+function traditional.lasttrace()
+ return steps
+end
+
+-- We could reuse the w table but as we cache the resolved words there is not much gain in
+-- that complication.
+--
+-- Beware: word can be a table and when n is passed to we can assume reuse so we need to
+-- honor that n then.
+--
+-- todo: a fast variant for tex ... less lookups (we could check is dictionary has changed)
+-- ... although due to caching the already done words, we don't do much here
+
+local function hyphenate(dictionary,word,n) -- odd is okay
+ nofwords = nofwords + 1
+ local hyphenated = dictionary.hyphenated
+ local isstring = type(word) == "string"
+ if isstring then
+ local done = hyphenated[word]
+ if done ~= nil then
+ return done
+ end
+ elseif n then
+ local done = hyphenated[concat(word,"",1,n)]
+ if done ~= nil then
+ return done
+ end
+ else
+ local done = hyphenated[concat(word)]
+ if done ~= nil then
+ return done
+ end
+ end
+ local key
+ if isstring then
+ key = word
+ word = lpegmatch(p_split,word)
+ if not n then
+ n = #word
+ end
+ else
+ if not n then
+ n = #word
+ end
+ key = concat(word,"",1,n)
+ end
+ local l = 1
+ local w = { "." }
+ -- local d = dictionary.codehash
+ for i=1,n do
+ local c = word[i]
+ -- l = l + (d[c] or 1)
+ l = l + 1
+ w[l] = lcchars[c] or c
+ end
+ l = l + 1
+ w[l] = "."
+ local c = concat(w,"",2,l-1)
+ --
+ local done = hyphenated[c]
+ if done ~= nil then
+ hyphenated[key] = done
+ nofhashed = nofhashed + 1
+ return done
+ end
+ --
+ local exceptions = dictionary.exceptions
+ local exception = exceptions[c]
+ if exception then
+ if trace_steps then
+ show_4(w,exception)
+ end
+ hyphenated[key] = exception
+ nofhashed = nofhashed + 1
+ return exception
+ end
+ --
+ if trace_steps then
+ show_1(w)
+ end
+ --
+ local specials = dictionary.specials
+ local patterns = dictionary.patterns
+ --
+ local spec
+ for i=1,l do
+ for j=i,l do
+ local c = concat(w,"",i,j)
+ local m = patterns[c]
+ if m then
+ local s = specials[c]
+ if not done then
+ done = { }
+ spec = nil
+ -- the string that we resolve has explicit fences (.) so done starts at
+ -- the first fence and runs upto the last one so we need one slot less
+ for i=1,l do
+ done[i] = 0
+ end
+ end
+ -- we run over the pattern that always has a (zero) value for each character
+ -- plus one more as we look at both sides
+ for k=1,#m do
+ local new = m[k]
+ if not new then
+ break
+ elseif new == true then
+ report("fatal error")
+ break
+ elseif new > 0 then
+ local pos = i + k - 1
+ local old = done[pos]
+ if not old then
+ -- break ?
+ elseif new > old then
+ done[pos] = new
+ if s then
+ local b = i + (s.start or 1) - 1
+ if b > 0 then
+ local e = b + (s.length or 2) - 1
+ if e > 0 then
+ if pos >= b and pos <= e then
+ if spec then
+ spec[pos] = { s, k - 1 }
+ else
+ spec = { [pos] = { s, k - 1 } }
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ if trace_steps and done then
+ show_2(c,m,w,done,i,s)
+ end
+ end
+ end
+ end
+ if trace_steps and done then
+ show_3(w,done)
+ end
+ if done then
+ local okay = false
+ for i=3,#done do
+ if done[i] % 2 == 1 then
+ done[i-2] = spec and spec[i] or true
+ okay = true
+ else
+ done[i-2] = false
+ end
+ end
+ if okay then
+ done[#done] = nil
+ done[#done] = nil
+ else
+ done = false
+ end
+ else
+ done = false
+ end
+ hyphenated[key] = done
+ nofhashed = nofhashed + 1
+ return done
+end
+
+function traditional.gettrace(language,word)
+ if not word or word == "" then
+ return
+ end
+ local dictionary = dictionaries[language]
+ if dictionary then
+ local hyphenated = dictionary.hyphenated
+ hyphenated[word] = nil
+ hyphenate(dictionary,word)
+ return steps
+ end
+end
+
+local methods = setmetatableindex(function(t,k) local v = hyphenate t[k] = v return v end)
+
+function traditional.installmethod(name,f)
+ if rawget(methods,name) then
+ report("overloading %a is not permitted",name)
+ else
+ methods[name] = f
+ end
+end
+
+local s_detail_1 = "-"
+local f_detail_2 = formatters["%s-%s"]
+local f_detail_3 = formatters["{%s}{%s}{}"]
+local f_detail_4 = formatters["{%s%s}{%s%s}{%s}"]
+
+function traditional.injecthyphens(dictionary,word,specification)
+ if not word then
+ return false
+ end
+ if not specification then
+ return word
+ end
+ local hyphens = hyphenate(dictionary,word)
+ if not hyphens then
+ return word
+ end
+
+ -- the following code is similar to code later on but here we have strings while there
+ -- we have hyphen specs
+
+ local word = lpegmatch(p_split,word)
+ local size = #word
+
+ local leftmin = specification.leftcharmin or 2
+ local rightmin = size - (specification.rightcharmin or leftmin)
+ local leftchar = specification.leftchar
+ local rightchar = specification.rightchar
+
+ local result = { }
+ local rsize = 0
+ local position = 1
+
+ while position <= size do
+ if position >= leftmin and position <= rightmin then
+ local hyphen = hyphens[position]
+ if not hyphen then
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ elseif hyphen == true then
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ rsize = rsize + 1
+ if leftchar and rightchar then
+ result[rsize] = f_detail_3(rightchar,leftchar)
+ else
+ result[rsize] = s_detail_1
+ end
+ position = position + 1
+ else
+ local o, h = hyphen[2]
+ if o then
+ h = hyphen[1]
+ else
+ h = hyphen
+ o = 1
+ end
+ local b = position - o + (h.start or 1)
+ local e = b + (h.length or 2) - 1
+ if b > 0 and e >= b then
+ for i=1,b-position do
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ end
+ rsize = rsize + 1
+ if leftchar and rightchar then
+ result[rsize] = f_detail_4(h.before,rightchar,leftchar,h.after,concat(word,"",b,e))
+ else
+ result[rsize] = f_detail_2(h.before,h.after)
+ end
+ position = e + 1
+ else
+ -- error
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ end
+ end
+ else
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ end
+ end
+ return concat(result)
+end
+
+do
+
+ local word = C((1-space)^1)
+ local spaces = space^1
+
+ local u_pattern = (Carg(1) * Carg(2) * word / unregister_pattern + spaces)^1
+ local r_pattern = (Carg(1) * Carg(2) * word * Carg(3) / register_pattern + spaces)^1
+ local e_pattern = (Carg(1) * word / register_exception + spaces)^1
+
+ function traditional.registerpattern(language,str,specification)
+ local dictionary = dictionaries[language]
+ if specification == false then
+ lpegmatch(u_pattern,str,1,dictionary.patterns,dictionary.specials)
+ -- unregister_pattern(dictionary.patterns,dictionary.specials,str)
+ else
+ lpegmatch(r_pattern,str,1,dictionary.patterns,dictionary.specials,type(specification) == "table" and specification or false)
+ -- register_pattern(dictionary.patterns,dictionary.specials,str,specification)
+ end
+ end
+
+ function traditional.registerexception(language,str)
+ lpegmatch(e_pattern,str,1,dictionaries[language].exceptions)
+ end
+
+end
+
+-- todo: unicodes or utfhash ?
+
+if context then
+
+ local nodecodes = nodes.nodecodes
+ local disccodes = nodes.disccodes
+
+ local glyph_code = nodecodes.glyph
+ local disc_code = nodecodes.disc
+ local math_code = nodecodes.math
+ local hlist_code = nodecodes.hlist
+
+ local automaticdisc_code = disccodes.automatic
+ local regulardisc_code = disccodes.regular
+
+ local nuts = nodes.nuts
+ local tonode = nodes.tonode
+ local nodepool = nuts.pool
+
+ local new_disc = nodepool.disc
+ local new_penalty = nodepool.penalty
+
+ local getfield = nuts.getfield
+ local getfont = nuts.getfont
+ local getid = nuts.getid
+ local getattr = nuts.getattr
+ local getnext = nuts.getnext
+ local getprev = nuts.getprev
+ local getsubtype = nuts.getsubtype
+ local getlist = nuts.getlist
+ local getlanguage = nuts.getlanguage
+ local getattrlist = nuts.getattrlist
+ local setattrlist = nuts.setattrlist
+ local isglyph = nuts.isglyph
+ local ischar = nuts.ischar
+
+ local setchar = nuts.setchar
+ local setdisc = nuts.setdisc
+ local setlink = nuts.setlink
+ local setprev = nuts.setprev
+ local setnext = nuts.setnext
+
+ local insert_before = nuts.insert_before
+ local insert_after = nuts.insert_after
+ local copy_node = nuts.copy
+ local copy_list = nuts.copy_list
+ local remove_node = nuts.remove
+ local end_of_math = nuts.end_of_math
+ local node_tail = nuts.tail
+
+ local nexthlist = nuts.traversers.hlist
+ local nextdisc = nuts.traversers.disc
+
+ local setcolor = nodes.tracers.colors.set
+
+ local variables = interfaces.variables
+ local v_reset = variables.reset
+ local v_yes = variables.yes
+ local v_word = variables.word
+ local v_all = variables.all
+
+ local settings_to_array = utilities.parsers.settings_to_array
+
+ local unsetvalue = attributes.unsetvalue
+ local texsetattribute = tex.setattribute
+
+ local prehyphenchar = language.prehyphenchar
+ local posthyphenchar = language.posthyphenchar
+ local preexhyphenchar = language.preexhyphenchar
+ local postexhyphenchar = language.postexhyphenchar
+
+ local a_hyphenation = attributes.private("hyphenation")
+
+ local interwordpenalty = 5000
+
+ function traditional.loadpatterns(language)
+ return dictionaries[language]
+ end
+
+ -- for the moment we use an independent data structure
+
+ setmetatableindex(dictionaries,function(t,k)
+ if type(k) == "string" then
+ -- this will force a load if not yet loaded (we need a nicer way) for the moment
+ -- that will do (nneeded for examples that register a pattern specification
+ languages.getnumber(k)
+ end
+ local specification = languages.getdata(k)
+ local dictionary = {
+ patterns = { },
+ exceptions = { },
+ hyphenated = { },
+ specials = { },
+ instance = false,
+ characters = { },
+ unicodes = { },
+ }
+ if specification then
+ local resources = specification.resources
+ if resources then
+ local characters = dictionary.characters or { }
+ local unicodes = dictionary.unicodes or { }
+ for i=1,#resources do
+ local r = resources[i]
+ if not r.in_dictionary then
+ r.in_dictionary = true
+ local patterns = r.patterns
+ if patterns then
+ local data = patterns.data
+ if data then
+ -- regular patterns
+ lpegmatch(p_pattern,data,1,dictionary.patterns,dictionary.specials)
+ end
+ local extra = patterns.extra
+ if extra then
+ -- special patterns
+ lpegmatch(p_pattern,extra,1,dictionary.patterns,dictionary.specials)
+ end
+ end
+ local exceptions = r.exceptions
+ if exceptions then
+ local data = exceptions.data
+ if data and data ~= "" then
+ lpegmatch(p_exception,data,1,dictionary.exceptions)
+ end
+ end
+ local usedchars = lpegmatch(p_split,patterns.characters)
+ for i=1,#usedchars do
+ local char = usedchars[i]
+ local code = utfbyte(char)
+ local upper = uccodes[code]
+ characters[char] = code
+ unicodes [code] = char
+ if type(upper) == "table" then
+ for i=1,#upper do
+ local u = upper[i]
+ unicodes[u] = utfchar(u)
+ end
+ else
+ unicodes[upper] = utfchar(upper)
+ end
+ end
+ end
+ end
+ dictionary.characters = characters
+ dictionary.unicodes = unicodes
+ setmetatableindex(characters,function(t,k) local v = k and utfbyte(k) t[k] = v return v end)
+ end
+ t[specification.number] = dictionary
+ dictionary.instance = specification.instance -- needed for hyphenchars
+ end
+ t[k] = dictionary
+ return dictionary
+ end)
+
+ -- Beware: left and right min doesn't mean that in a 1 mmm hsize there can be snippets
+ -- with less characters than either of them! This could be an option but such a narrow
+ -- hsize doesn't make sense anyway.
+
+ -- We assume that featuresets are defined global ... local definitions (also mid paragraph)
+ -- make not much sense anyway. For the moment we assume no predefined sets so we don't need
+ -- to store them. Nor do we need to hash them in order to save space ... no sane user will
+ -- define many of them.
+
+ local featuresets = hyphenators.featuresets or { }
+ hyphenators.featuresets = featuresets
+
+ storage.shared.noflanguagesfeaturesets = storage.shared.noflanguagesfeaturesets or 0
+
+ local noffeaturesets = storage.shared.noflanguagesfeaturesets
+
+ storage.register("languages/hyphenators/featuresets",featuresets,"languages.hyphenators.featuresets")
+
+ ----- hash = table.sequenced(featureset,",") -- no need now
+
+ local function register(name,featureset)
+ noffeaturesets = noffeaturesets + 1
+ featureset.attribute = noffeaturesets
+ featuresets[noffeaturesets] = featureset -- access by attribute
+ featuresets[name] = featureset -- access by name
+ storage.shared.noflanguagesfeaturesets = noffeaturesets
+ return noffeaturesets
+ end
+
+ local function makeset(...)
+ -- a bit overkill, supporting variants but who cares
+ local set = { }
+ for i=1,select("#",...) do
+ local list = select(i,...)
+ local kind = type(list)
+ local used = nil
+ if kind == "string" then
+ if list == v_all then
+ -- not ok ... now all get ignored
+ return setmetatableindex(function(t,k) local v = utfchar(k) t[k] = v return v end)
+ elseif list ~= "" then
+ used = lpegmatch(p_split,list)
+ set = set or { }
+ for i=1,#used do
+ local char = used[i]
+ set[utfbyte(char)] = char
+ end
+ end
+ elseif kind == "table" then
+ if next(list) then
+ set = set or { }
+ for byte, char in next, list do
+ set[byte] = char == true and utfchar(byte) or char
+ end
+ elseif #list > 0 then
+ set = set or { }
+ for i=1,#list do
+ local l = list[i]
+ if type(l) == "number" then
+ set[l] = utfchar(l)
+ else
+ set[utfbyte(l)] = l
+ end
+ end
+ end
+ end
+ end
+ return set
+ end
+
+ -- category pd (tex also sees --- and -- as hyphens but do we really want that
+
+ local defaulthyphens = {
+ [0x002D] = true, -- HYPHEN-MINUS
+ [0x00AD] = 0x002D, -- SOFT HYPHEN (active in ConTeXt)
+ -- [0x058A] = true, -- ARMENIAN HYPHEN
+ -- [0x1400] = true, -- CANADIAN SYLLABICS HYPHEN
+ -- [0x1806] = true, -- MONGOLIAN TODO SOFT HYPHEN
+ [0x2010] = true, -- HYPHEN
+ -- [0x2011] = true, -- NON-BREAKING HYPHEN
+ -- [0x2012] = true, -- FIGURE DASH
+ [0x2013] = true, -- EN DASH
+ [0x2014] = true, -- EM DASH
+ -- [0x2015] = true, -- HORIZONTAL BAR
+ -- [0x2027] = true, -- HYPHENATION POINT
+ -- [0x2E17] = true, -- DOUBLE OBLIQUE HYPHEN
+ -- [0x2E1A] = true, -- HYPHEN WITH DIAERESIS
+ -- [0x2E3A] = true, -- TWO-EM DASH
+ -- [0x2E3B] = true, -- THREE-EM DASH
+ -- [0x2E40] = true, -- DOUBLE HYPHEN
+ -- [0x301C] = true, -- WAVE DASH
+ -- [0x3030] = true, -- WAVY DASH
+ -- [0x30A0] = true, -- KATAKANA-HIRAGANA DOUBLE HYPHEN
+ -- [0xFE31] = true, -- PRESENTATION FORM FOR VERTICAL EM DASH
+ -- [0xFE32] = true, -- PRESENTATION FORM FOR VERTICAL EN DASH
+ -- [0xFE58] = true, -- SMALL EM DASH
+ -- [0xFE63] = true, -- SMALL HYPHEN-MINUS
+ -- [0xFF0D] = true, -- FULLWIDTH HYPHEN-MINUS
+ }
+
+ local defaultjoiners = {
+ [0x200C] = true, -- nzwj
+ [0x200D] = true, -- zwj
+ }
+
+ local function somehyphenchar(c)
+ c = tonumber(c)
+ return c ~= 0 and c or nil
+ end
+
+ local function definefeatures(name,featureset)
+ local extrachars = featureset.characters -- "[]()"
+ local hyphenchars = featureset.hyphens
+ local joinerchars = featureset.joiners
+ local alternative = featureset.alternative
+ local rightwordmin = tonumber(featureset.rightwordmin)
+ local charmin = tonumber(featureset.charmin) -- luatex now also has hyphenationmin
+ local leftcharmin = tonumber(featureset.leftcharmin)
+ local rightcharmin = tonumber(featureset.rightcharmin)
+ local leftchar = somehyphenchar(featureset.leftchar)
+ local rightchar = somehyphenchar(featureset.rightchar)
+ local rightchars = featureset.rightchars
+local rightedge = featureset.rightedge
+local autohyphen = v_yes -- featureset.autohyphen -- insert disc
+local hyphenonly = v_yes -- featureset.hyphenonly -- don't hyphenate around
+ rightchars = rightchars == v_word and true or tonumber(rightchars)
+ joinerchars = joinerchars == v_yes and defaultjoiners or joinerchars -- table
+ hyphenchars = hyphenchars == v_yes and defaulthyphens or hyphenchars -- table
+ -- not yet ok: extrachars have to be ignored so it cannot be all)
+ featureset.extrachars = makeset(joinerchars or "",extrachars or "")
+ featureset.hyphenchars = makeset(hyphenchars or "")
+ featureset.alternative = alternative or "hyphenate"
+ featureset.rightwordmin = rightwordmin and rightwordmin > 0 and rightwordmin or nil
+ featureset.charmin = charmin and charmin > 0 and charmin or nil
+ featureset.leftcharmin = leftcharmin and leftcharmin > 0 and leftcharmin or nil
+ featureset.rightcharmin = rightcharmin and rightcharmin > 0 and rightcharmin or nil
+ featureset.rightchars = rightchars
+ featureset.leftchar = leftchar
+ featureset.rightchar = rightchar
+ -- featureset.strict = rightedge == "tex"
+featureset.autohyphen = autohyphen == v_yes
+featureset.hyphenonly = hyphenonly == v_yes
+ return register(name,featureset)
+ end
+
+ local function setfeatures(n)
+ if not n or n == v_reset then
+ n = false
+ else
+ local f = featuresets[n]
+ if not f and type(n) == "string" then
+ local t = settings_to_array(n)
+ local s = { }
+ for i=1,#t do
+ local ti = t[i]
+ local fs = featuresets[ti]
+ if fs then
+ for k, v in next, fs do
+ s[k] = v
+ end
+ end
+ end
+ n = register(n,s)
+ else
+ n = f and f.attribute
+ end
+ end
+ texsetattribute(a_hyphenation,n or unsetvalue)
+ end
+
+ traditional.definefeatures = definefeatures
+ traditional.setfeatures = setfeatures
+
+ implement {
+ name = "definehyphenationfeatures",
+ actions = definefeatures,
+ arguments = {
+ "string",
+ {
+ { "characters" },
+ { "hyphens" },
+ { "joiners" },
+ { "rightchars" },
+ { "rightwordmin", "integer" },
+ { "charmin", "integer" },
+ { "leftcharmin", "integer" },
+ { "rightcharmin", "integer" },
+ { "leftchar", "integer" },
+ { "rightchar", "integer" },
+ { "alternative" },
+ { "rightedge" },
+ }
+ }
+ }
+
+ implement {
+ name = "sethyphenationfeatures",
+ actions = setfeatures,
+ arguments = "string"
+ }
+
+ implement {
+ name = "registerhyphenationpattern",
+ actions = traditional.registerpattern,
+ arguments = { "string", "string", "boolean" }
+ }
+
+ implement {
+ name = "registerhyphenationexception",
+ actions = traditional.registerexception,
+ arguments = "2 strings",
+ }
+
+ -- This is a relative large function with local variables and local functions. A previous
+ -- implementation had the functions outside but this is cleaner and as efficient. The test
+ -- runs 100 times over tufte.tex, knuth.tex, zapf.tex, ward.tex and darwin.tex in lower
+ -- and uppercase with a 1mm hsize.
+ --
+ -- language=0 language>0 4 | 3 * slower
+ --
+ -- tex 2.34 | 1.30 2.55 | 1.45 0.21 | 0.15
+ -- lua 2.42 | 1.38 3.30 | 1.84 0.88 | 0.46
+ --
+ -- Of course we have extra overhead (virtual Lua machine) but also we check attributes and
+ -- support specific local options). The test puts the typeset text in boxes and discards
+ -- it. If we also flush the runtime is 4.31|2.56 and 4.99|2.94 seconds so the relative
+ -- difference is (somehow) smaller. The test has 536 pages. There is a little bit of extra
+ -- overhead because we store the patterns in a different way.
+ --
+ -- As usual I will look for speedups. Some 0.01 seconds could be gained by sharing patterns
+ -- which is not impressive but it does save some 3M memory on this test. (Some optimizations
+ -- already brought the 3.30 seconds down to 3.14 but it all depends on aggressive caching.)
+
+ -- As we kick in the hyphenator before fonts get handled, we don't look at implicit (font)
+ -- kerns or ligatures.
+
+ local starttiming = statistics.starttiming
+ local stoptiming = statistics.stoptiming
+
+ -- local strictids = {
+ -- [nodecodes.hlist] = true,
+ -- [nodecodes.vlist] = true,
+ -- [nodecodes.rule] = true,
+ -- [nodecodes.dir] = true,
+ -- [nodecodes.whatsit] = true,
+ -- [nodecodes.ins] = true,
+ -- [nodecodes.adjust] = true,
+ --
+ -- [nodecodes.math] = true,
+ -- [nodecodes.disc] = true,
+ --
+ -- [nodecodes.accent] = true, -- never used in context
+ -- }
+
+ -- a lot of overhead when only one char
+
+ function traditional.hyphenate(head)
+
+ local first = head
+ local tail = nil
+ local last = nil
+ local current = first
+ local dictionary = nil
+ local instance = nil
+ local characters = nil
+ local unicodes = nil
+ local exhyphenchar = tex.exhyphenchar
+ local extrachars = nil
+ local hyphenchars = nil
+ local language = nil
+ local lastfont = nil
+ local start = nil
+ local stop = nil
+ local word = { } -- we reuse this table
+ local size = 0
+ local leftchar = false
+ local rightchar = false -- utfbyte("-")
+ local leftexchar = false
+ local rightexchar = false -- utfbyte("-")
+ local leftmin = 0
+ local rightmin = 0
+ local charmin = 1
+ local leftcharmin = nil
+ local rightcharmin = nil
+ ----- leftwordmin = nil
+ local rightwordmin = nil
+ local rightchars = nil
+ local leftchar = nil
+ local rightchar = nil
+ local attr = nil
+ local lastwordlast = nil
+ local hyphenated = hyphenate
+ ----- strict = nil
+ local exhyphenpenalty = tex.exhyphenpenalty
+ local hyphenpenalty = tex.hyphenpenalty
+ local autohyphen = false
+ local hyphenonly = false
+
+ -- We cannot use an 'enabled' boolean (false when no characters or extras) because we
+ -- can have plugins that set a characters metatable and so) ... it doesn't save much
+ -- anyway. Using (unicodes and unicodes[code]) and a nil table when no characters also
+ -- doesn't save much. So there not that much to gain for languages that don't hyphenate.
+ --
+ -- enabled = (unicodes and (next(unicodes) or getmetatable(unicodes)))
+ -- or (extrachars and next(extrachars))
+ --
+ -- This can be used to not add characters i.e. keep size 0 but then we need to check for
+ -- attributes that change it, which costs time too. Not much to gain there.
+
+ starttiming(traditional)
+
+ local function insertpenalty()
+ local p = new_penalty(interwordpenalty)
+ setattrlist(p,last)
+ if trace_visualize then
+ nuts.setvisual(p,"penalty")
+ end
+ last = getprev(last)
+ first, last = insert_after(first,last,p)
+ end
+
+ local function synchronizefeatureset(a)
+ local f = a and featuresets[a]
+ if f then
+ hyphenated = methods[f.alternative or "hyphenate"]
+ extrachars = f.extrachars
+ hyphenchars = f.hyphenchars
+ rightwordmin = f.rightwordmin
+ charmin = f.charmin
+ leftcharmin = f.leftcharmin
+ rightcharmin = f.rightcharmin
+ leftchar = f.leftchar
+ rightchar = f.rightchar
+ -- strict = f.strict and strictids
+ rightchars = f.rightchars
+ autohyphen = f.autohyphen
+ hyphenonly = f.hyphenonly
+ if rightwordmin and rightwordmin > 0 and lastwordlast ~= rightwordmin then
+ -- so we can change mid paragraph but it's kind of unpredictable then
+ if not tail then
+ tail = node_tail(first)
+ end
+ last = tail
+ local inword = false
+ local count = 0
+ while last and rightwordmin > 0 do
+ local id = getid(last)
+ if id == glyph_code then
+ count = count + 1
+ inword = true
+ if trace_visualize then
+ setcolor(last,"darkgreen")
+ end
+ elseif inword then
+ inword = false
+ rightwordmin = rightwordmin - 1
+ if rightchars == true then
+ if rightwordmin > 0 then
+ insertpenalty()
+ end
+ elseif rightchars and count <= rightchars then
+ insertpenalty()
+ end
+ end
+ last = getprev(last)
+ end
+ lastwordlast = rightwordmin
+ end
+ if not charmin or charmin == 0 then
+ charmin = 1
+ end
+ else
+ hyphenated = methods.hyphenate
+ extrachars = false
+ hyphenchars = false
+ rightwordmin = false
+ charmin = 1
+ leftcharmin = false
+ rightcharmin = false
+ leftchar = false
+ rightchar = false
+ -- strict = false
+ autohyphen = false
+ hyphenonly = false
+ end
+
+ return a
+ end
+
+ local function flush(hyphens) -- todo: no need for result
+
+ local rightmin = size - rightmin
+ local result = { }
+ local rsize = 0
+ local position = 1
+
+ -- todo: remember last dics and don't go back to before that (plus message) ...
+ -- for simplicity we also assume that we don't start with a dics node
+ --
+ -- there can be a conflict: if we backtrack then we can end up in another disc
+ -- and get out of sync (dup chars and so)
+
+ while position <= size do
+ if position >= leftmin and position <= rightmin then
+ local hyphen = hyphens[position]
+ if not hyphen then
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ elseif hyphen == true then
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ rsize = rsize + 1
+ result[rsize] = true
+ position = position + 1
+ else
+ local o, h = hyphen[2]
+ if o then
+ -- { hyphen, offset)
+ h = hyphen[1]
+ else
+ -- hyphen
+ h = hyphen
+ o = 1
+ end
+ local b = position - o + (h.start or 1)
+ local e = b + (h.length or 2) - 1
+ if b > 0 and e >= b then
+ for i=1,b-position do
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ end
+ rsize = rsize + 1
+ result[rsize] = {
+ h.before or "", -- pre
+ h.after or "", -- post
+ concat(word,"",b,e), -- replace
+ h.right, -- optional after pre
+ h.left, -- optional before post
+ }
+ position = e + 1
+ else
+ -- error
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ end
+ end
+ else
+ rsize = rsize + 1
+ result[rsize] = word[position]
+ position = position + 1
+ end
+ end
+
+ local function serialize(replacement,leftchar,rightchar)
+ if not replacement then
+ return
+ elseif replacement == true then
+ local glyph = copy_node(stop)
+ setchar(glyph,leftchar or rightchar)
+ return glyph
+ end
+ local head = nil
+ local current = nil
+ if leftchar then
+ head = copy_node(stop)
+ current = head
+ setchar(head,leftchar)
+ end
+ local rsize = #replacement
+ if rsize == 1 then
+ local glyph = copy_node(stop)
+ setchar(glyph,characters[replacement])
+ if head then
+ insert_after(current,current,glyph)
+ else
+ head = glyph
+ end
+ current = glyph
+ elseif rsize > 0 then
+ local list = lpegmatch(p_split,replacement) -- this is an utf split (could be cached)
+ for i=1,#list do
+ local glyph = copy_node(stop)
+ setchar(glyph,characters[list[i]])
+ if head then
+ insert_after(current,current,glyph)
+ else
+ head = glyph
+ end
+ current = glyph
+ end
+ end
+ if rightchar then
+ local glyph = copy_node(stop)
+ insert_after(current,current,glyph)
+ setchar(glyph,rightchar)
+ end
+ return head
+ end
+
+ local current = start
+ local attrnode = start -- will be different, just the first char
+
+ for i=1,rsize do
+ local r = result[i]
+ if r == true then
+ local disc = new_disc()
+ local pre = nil
+ local post = nil
+ if rightchar then
+ pre = serialize(true,rightchar)
+ end
+ if leftchar then
+ post = serialize(true,leftchar)
+ end
+ setdisc(disc,pre,post,nil,regulardisc_code,hyphenpenalty)
+ if attrnode then
+ setattrlist(disc,attrnode)
+ end
+ -- could be a replace as well
+ insert_before(first,current,disc)
+ elseif type(r) == "table" then
+ local disc = new_disc()
+ local pre = r[1]
+ local post = r[2]
+ local replace = r[3]
+ local right = r[4] ~= false and rightchar
+ local left = r[5] ~= false and leftchar
+ if pre then
+ if pre ~= "" then
+ pre = serialize(pre,false,right)
+ else
+ pre = nil
+ end
+ end
+ if post then
+ if post ~= "" then
+ post = serialize(post,left,false)
+ else
+ post = nil
+ end
+ end
+ if replace then
+ if replace ~= "" then
+ replace = serialize(replace)
+ else
+ replace = nil
+ end
+ end
+ -- maybe regular code
+ setdisc(disc,pre,post,replace,regulardisc_code,hyphenpenalty)
+ if attrnode then
+ setattrlist(disc,attrnode)
+ end
+ insert_before(first,current,disc)
+ else
+ setchar(current,characters[r])
+ if i < rsize then
+ current = getnext(current)
+ end
+ end
+ end
+ if current and current ~= stop then
+ local current = getnext(current)
+ local last = getnext(stop)
+ while current ~= last do
+ first, current = remove_node(first,current,true)
+ end
+ end
+
+ end
+
+ local function inject(leftchar,rightchar,code,attrnode)
+ if first ~= current then
+ local disc = new_disc()
+ first, current, glyph = remove_node(first,current)
+ first, current = insert_before(first,current,disc)
+ if trace_visualize then
+ setcolor(glyph,"darkred") -- these get checked
+ setcolor(disc,"darkgreen") -- in the colorizer
+ end
+ local pre = nil
+ local post = nil
+ local replace = glyph
+ if leftchar and leftchar > 0 then
+ post = copy_node(glyph)
+ setchar(post,leftchar)
+ end
+ pre = copy_node(glyph)
+ setchar(pre,rightchar and rightchar > 0 and rightchar or code)
+ setdisc(disc,pre,post,replace,automaticdisc_code,hyphenpenalty) -- ex ?
+ if attrnode then
+ setattrlist(disc,attrnode)
+ end
+ end
+ return current
+ end
+
+ local function injectseries(current,last,next,attrnode)
+ local disc = new_disc()
+ local start = current
+ first, current = insert_before(first,current,disc)
+ setprev(start)
+ setnext(last)
+ if next then
+ setlink(current,next)
+ else
+ setnext(current)
+ end
+ local pre = copy_list(start)
+ local post = nil
+ local replace = start
+ setdisc(disc,pre,post,replace,automaticdisc_code,hyphenpenalty) -- ex ?
+ if attrnode then
+ setattrlist(disc,attrnode)
+ end
+ return current
+ end
+
+ local a = getattr(first,a_hyphenation)
+ if a ~= attr then
+ attr = synchronizefeatureset(a)
+ end
+
+ -- The first attribute in a word determines the way a word gets hyphenated and if
+ -- relevant, other properties are also set then. We could optimize for silly one-char
+ -- cases but it has no priority as the code is still not that much slower than the
+ -- native hyphenator and this variant also provides room for extensions.
+
+ local skipping = false
+
+ -- In "word word word." the sequences "word" and "." can be a different font!
+
+ while current and current ~= last do -- and current
+ local code, id = isglyph(current)
+ if code then
+ if skipping then
+ current = getnext(current)
+ else
+ local lang = getlanguage(current)
+ local font = getfont(current)
+ if lang ~= language or font ~= lastfont then
+ if dictionary and size > charmin and leftmin + rightmin <= size then
+ -- only german has many words starting with an uppercase character
+ if categories[word[1]] == "lu" and getfield(start,"uchyph") < 0 then
+ -- skip
+ else
+ local hyphens = hyphenated(dictionary,word,size)
+ if hyphens then
+ flush(hyphens)
+ end
+ end
+ end
+ lastfont = font
+ if language ~= lang and lang > 0 then
+ --
+ dictionary = dictionaries[lang]
+ instance = dictionary.instance
+ characters = dictionary.characters
+ unicodes = dictionary.unicodes
+ --
+ local a = getattr(current,a_hyphenation)
+ attr = synchronizefeatureset(a)
+ leftchar = leftchar or (instance and posthyphenchar (instance)) -- we can make this more
+ rightchar = rightchar or (instance and prehyphenchar (instance)) -- efficient if needed
+ leftexchar = (instance and preexhyphenchar (instance))
+ rightexchar = (instance and postexhyphenchar(instance))
+ leftmin = leftcharmin or getfield(current,"lhmin")
+ rightmin = rightcharmin or getfield(current,"rhmin")
+ if not leftchar or leftchar < 0 then
+ leftchar = false
+ end
+ if not rightchar or rightchar < 0 then
+ rightchar = false
+ end
+ --
+ local char = unicodes[code] or (extrachars and extrachars[code])
+ if char then
+ word[1] = char
+ size = 1
+ start = current
+ else
+ size = 0
+ end
+ else
+ size = 0
+ end
+ language = lang
+ elseif language <= 0 then
+ --
+ elseif size > 0 then
+ local char = unicodes[code] or (extrachars and extrachars[code])
+ if char then
+ size = size + 1
+ word[size] = char
+ elseif dictionary then
+ if not hyphenonly or code ~= exhyphenchar then
+ if size > charmin and leftmin + rightmin <= size then
+ if categories[word[1]] == "lu" and getfield(start,"uchyph") < 0 then
+ -- skip
+ else
+ local hyphens = hyphenated(dictionary,word,size)
+ if hyphens then
+ flush(hyphens)
+ end
+ end
+ end
+ end
+ size = 0
+ if code == exhyphenchar then -- normally the -
+ local next = getnext(current)
+ local last = current
+ local font = getfont(current)
+ while next and ischar(next,font) == code do
+ last = next
+ next = getnext(next)
+ end
+ if not autohyphen then
+ current = last
+ elseif current == last then
+ current = inject(leftexchar,rightexchar,code,current)
+ else
+ current = injectseries(current,last,next,current)
+ end
+ if hyphenonly then
+ skipping = true
+ end
+ elseif hyphenchars then
+ local char = hyphenchars[code]
+ if char == true then
+ char = code
+ end
+ if char then
+ current = inject(leftchar and char or nil,rightchar and char or nil,char,current)
+ end
+ end
+ end
+ else
+ local a = getattr(current,a_hyphenation)
+ if a ~= attr then
+ attr = synchronizefeatureset(a) -- influences extrachars
+ leftchar = leftchar or (instance and posthyphenchar (instance)) -- we can make this more
+ rightchar = rightchar or (instance and prehyphenchar (instance)) -- efficient if needed
+ leftexchar = (instance and preexhyphenchar (instance))
+ rightexchar = (instance and postexhyphenchar(instance))
+ leftmin = leftcharmin or getfield(current,"lhmin")
+ rightmin = rightcharmin or getfield(current,"rhmin")
+ if not leftchar or leftchar < 0 then
+ leftchar = false
+ end
+ if not rightchar or rightchar < 0 then
+ rightchar = false
+ end
+ end
+ --
+ local char = unicodes[code] or (extrachars and extrachars[code])
+ if char then
+ word[1] = char
+ size = 1
+ start = current
+ end
+ end
+ stop = current
+ current = getnext(current)
+ end
+ else
+ if skipping then
+ skipping = false
+ end
+ if id == disc_code then
+ size = 0
+ current = getnext(current)
+ if hyphenonly then
+ skipping = true
+ end
+ -- elseif strict and strict[id] then
+ -- current = id == math_code and getnext(end_of_math(current)) or getnext(current)
+ -- size = 0
+ else
+ current = id == math_code and getnext(end_of_math(current)) or getnext(current)
+ end
+ if size > 0 then
+ if dictionary and size > charmin and leftmin + rightmin <= size then
+ if categories[word[1]] == "lu" and getfield(start,"uchyph") < 0 then
+ -- skip
+ else
+ local hyphens = hyphenated(dictionary,word,size)
+ if hyphens then
+ flush(hyphens)
+ end
+ end
+ end
+ size = 0
+ end
+ end
+ end
+ -- we can have quit due to last so we need to flush the last seen word, we could move
+ -- this in the loop and test for current but ... messy
+ if dictionary and size > charmin and leftmin + rightmin <= size then
+ if categories[word[1]] == "lu" and getfield(start,"uchyph") < 0 then
+ -- skip
+ else
+ local hyphens = hyphenated(dictionary,word,size)
+ if hyphens then
+ flush(hyphens)
+ end
+ end
+ end
+
+ stoptiming(traditional)
+
+ return head
+ end
+
+ statistics.register("hyphenation",function()
+ if nofwords > 0 or statistics.elapsed(traditional) > 0 then
+ return string.format("%s words hyphenated, %s unique, used time %s",
+ nofwords,nofhashed,statistics.elapsedseconds(traditional) or 0)
+ end
+ end)
+
+ local texmethod = "builders.kernel.hyphenation"
+ local oldmethod = texmethod
+ local newmethod = texmethod
+
+ -- local newmethod = "languages.hyphenators.traditional.hyphenate"
+ --
+ -- nodes.tasks.prependaction("processors","words",newmethod)
+ -- nodes.tasks.disableaction("processors",oldmethod)
+ --
+ -- nodes.tasks.replaceaction("processors","words",oldmethod,newmethod)
+
+ -- \enabledirectives[hyphenators.method=traditional]
+ -- \enabledirectives[hyphenators.method=builtin]
+
+ -- push / pop ? check first attribute
+
+ -- local replaceaction = nodes.tasks.replaceaction -- no longer overload this way (too many local switches)
+
+ local hyphenate = language.hyphenate
+ local hyphenating = nuts.hyphenating
+ local methods = { }
+ local usedmethod = false
+ local stack = { }
+
+ local original = hyphenating and
+ function(head)
+ return (hyphenating(head))
+ end
+ or
+ function(head)
+ hyphenate(tonode(head))
+ return head -- a nut
+ end
+
+ -- local has_language = language.has_language
+ --
+ -- local function original(head) -- kernel.hyphenation(head)
+ -- local h = tonode(head)
+ -- if has_language(h) then
+ -- hyphenate(h)
+ -- end
+ -- return head
+ -- end
+
+ local getcount = tex.getcount
+
+ hyphenators.methods = methods
+ local optimize = false
+
+ directives.register("hyphenator.optimize", function(v) optimize = v end)
+
+ function hyphenators.handler(head,groupcode)
+ if usedmethod then
+ if optimize and (groupcode == "hbox" or groupcode == "adjusted_hbox") then
+ if getcount("hyphenstate") > 0 then
+ forced = false
+ return usedmethod(head)
+ else
+ return head
+ end
+ else
+ return usedmethod(head)
+ end
+ else
+ return head
+ end
+ end
+
+ methods.tex = original
+ methods.original = original
+ methods.expanded = original -- was expanded before 1.005
+ methods.traditional = languages.hyphenators.traditional.hyphenate
+ methods.none = false -- function(head) return head, false end
+
+ usedmethod = original
+
+ local function setmethod(method)
+ usedmethod = type(method) == "string" and methods[method]
+ if usedmethod == nil then
+ usedmethod = methods.tex
+ end
+ end
+ local function pushmethod(method)
+ insert(stack,usedmethod)
+ usedmethod = type(method) == "string" and methods[method]
+ if usedmethod == nil then
+ usedmethod = methods.tex
+ end
+ end
+ local function popmethod()
+ usedmethod = remove(stack) or methods.tex
+ end
+
+ hyphenators.setmethod = setmethod
+ hyphenators.pushmethod = pushmethod
+ hyphenators.popmethod = popmethod
+
+ directives.register("hyphenators.method",setmethod)
+
+ function hyphenators.setup(specification)
+ local method = specification.method
+ if method then
+ setmethod(method)
+ end
+ end
+
+ implement { name = "sethyphenationmethod", actions = setmethod, arguments = "string" }
+ implement { name = "pushhyphenation", actions = pushmethod, arguments = "string" }
+ implement { name = "pophyphenation", actions = popmethod }
+
+ -- can become a runtime loaded one:
+
+ local context = context
+ local ctx_NC = context.NC
+ local ctx_NR = context.NR
+ local ctx_verbatim = context.verbatim
+
+ function hyphenators.showhyphenationtrace(language,word)
+ if not word or word == "" then
+ return
+ end
+ local saved = trace_steps
+ trace_steps = "silent"
+ local steps = traditional.gettrace(language,word)
+ trace_steps = saved
+ if steps then
+ local n = #steps
+ if n > 0 then
+ context.starttabulate { "|r|l|l|l|" }
+ for i=1,n do
+ local s = steps[i]
+ ctx_NC() if i > 1 and i < n then context(i-1) end
+ ctx_NC() ctx_verbatim(s[1])
+ ctx_NC() ctx_verbatim(s[2])
+ ctx_NC() ctx_verbatim(s[3])
+ ctx_NC()
+ ctx_NR()
+ end
+ context.stoptabulate()
+ end
+ end
+ end
+
+ implement {
+ name = "showhyphenationtrace",
+ actions = hyphenators.showhyphenationtrace,
+ arguments = "2 strings",
+ }
+
+ function nodes.stripdiscretionaries(head)
+ for l in nexthlist, head do
+ for d in nextdisc, getlist(l) do
+ remove_node(h,false,true)
+ end
+ end
+ return head
+ end
+
+
+else
+
+ -- traditional.loadpatterns("nl","lang-nl")
+ -- traditional.loadpatterns("de","lang-de")
+ -- traditional.loadpatterns("us","lang-us")
+
+ -- traditional.registerpattern("nl","e1ë", { start = 1, length = 2, before = "e", after = "e" } )
+ -- traditional.registerpattern("nl","oo7ë", { start = 2, length = 3, before = "o", after = "e" } )
+ -- traditional.registerpattern("de","qqxc9xkqq",{ start = 3, length = 4, before = "ab", after = "cd" } )
+
+ -- local specification = {
+ -- leftcharmin = 2,
+ -- rightcharmin = 2,
+ -- leftchar = "<",
+ -- rightchar = ">",
+ -- }
+
+ -- print("reëel", traditional.injecthyphens(dictionaries.nl,"reëel", specification),"r{e>}{}{}{ 32 hyphenated with length 1
+
+local function sethjcodes(instance,loaded,what,factor)
+ local l = loaded[what]
+ local c = l and l.characters
+ if c then
+ local hjcounts = factor and languages.hjcounts or false
+ --
+ local h = loaded.codehash
+ if not h then
+ h = { }
+ loaded.codehash = h
+ end
+ --
+ local function setcode(l)
+ local u = uccodes[l]
+ local s = l
+ if hjcounts then
+ local c = hjcounts[l]
+ if c then
+ c = c.count
+ if not c then
+ -- error, keep as 1
+ elseif c <= 0 then
+ -- counts as 0 i.e. ignored
+ s = 32
+ elseif c >= 31 then
+ -- counts as 31
+ s = 31
+ else
+ -- count c times
+ s = c
+ end
+ end
+ end
+ sethjcode(instance,l,s)
+ h[l] = s
+ if u ~= l and type(u) == "number" then
+ sethjcode(instance,u,s)
+ h[u] = lccodes[l]
+ end
+ end
+ --
+ local s = tex.savinghyphcodes
+ tex.savinghyphcodes = 0
+ if type(c) == "table" then
+ for l in next, c do
+ setcode(utfbyte(l))
+ end
+ else
+ for l in utfvalues(c) do
+ setcode(l)
+ end
+ end
+ tex.savinghyphcodes = s
+ end
+end
+
+-- 2'2 conflicts with 4' ... and luatex barks on it
+
+local P, R, Cs, Ct, lpegmatch, lpegpatterns = lpeg.P, lpeg.R, lpeg.Cs, lpeg.Ct, lpeg.match, lpeg.patterns
+
+local utfsplit = utf.split
+
+local space = lpegpatterns.space
+local whitespace = lpegpatterns.whitespace^1
+local nospace = lpegpatterns.utf8char - whitespace
+local digit = lpegpatterns.digit
+----- endofstring = #whitespace + P(-1)
+local endofstring = #whitespace
+
+local word = (digit/"")^0 * (digit/"" * endofstring + digit/" " + nospace)^1
+local anyword = (1-whitespace)^1
+local analyze = Ct((whitespace + Cs(word))^1)
+
+local function unique(tag,requested,loaded)
+ local nofloaded = #loaded
+ if nofloaded == 0 then
+ return ""
+ elseif nofloaded == 1 then
+ return loaded[1]
+ else
+ insert(loaded,1," ") -- no need then for special first word
+ -- insert(loaded, " ")
+ loaded = concat(loaded," ")
+ local t = lpegmatch(analyze,loaded) or { }
+ local h = { }
+ local b = { }
+ for i=1,#t do
+ local ti = t[i]
+ local hi = h[ti]
+ if not hi then
+ h[ti] = 1
+ elseif hi == 1 then
+ h[ti] = 2
+ b[#b+1] = utfsplit(ti," ")
+ end
+ end
+ -- sort
+ local nofbad = #b
+ if nofbad > 0 then
+ local word
+ for i=1,nofbad do
+ local bi = b[i]
+ local p = P(bi[1])
+ for i=2,#bi do
+ p = p * digit * P(bi[i])
+ end
+ if word then
+ word = word + p
+ else
+ word = p
+ end
+ report_initialization("language %a, patterns %a, discarding conflict (0-9)%{[0-9]}t(0-9)",tag,requested,bi)
+ end
+ t, h, b = nil, nil, nil -- permit gc
+ local someword = digit^0 * word * digit^0 * endofstring / ""
+ -- local strip = Cs(someword^-1 * (someword + anyword + whitespace)^1)
+ local strip = Cs((someword + anyword + whitespace)^1)
+ return lpegmatch(strip,loaded) or loaded
+ else
+ return loaded
+ end
+ end
+end
+
+local shared = false
+
+local function loaddefinitions(tag,specification)
+ statistics.starttiming(languages)
+ local data, instance = resolve(tag)
+ local requested = specification.patterns or ""
+ local definitions = settings_to_array(requested)
+ if #definitions > 0 then
+ if trace_patterns then
+ report_initialization("pattern specification for language %a: %s",tag,specification.patterns)
+ end
+ local ploaded = instance:patterns()
+ local eloaded = instance:hyphenation()
+ if not ploaded or ploaded == "" then
+ ploaded = { }
+ else
+ ploaded = { ploaded }
+ end
+ if not eloaded or eloaded == "" then
+ eloaded = { }
+ else
+ eloaded = { eloaded }
+ end
+ local dataused = data.used
+ local ok = false
+ local resources = data.resources or { }
+ data.resources = resources
+ if not shared then
+ local found = resolvers.findfile("lang-exc.lua")
+ if found then
+ shared = dofile(found)
+ if type(shared) == "table" then
+ shared = concat(shared," ")
+ else
+ shared = true
+ end
+ else
+ shared = true
+ end
+ end
+ for i=1,#definitions do
+ local definition = definitions[i]
+ if definition == "" then
+ -- error
+ elseif definition == v_reset then
+ if trace_patterns then
+ report_initialization("clearing patterns for language %a",tag)
+ end
+ instance:clear_patterns()
+ instance:clear_hyphenation()
+ ploaded = { }
+ eloaded = { }
+ elseif not dataused[definition] then
+ dataused[definition] = definition
+ local filename = "lang-" .. definition .. ".lua"
+ local fullname = resolvers.findfile(filename) or ""
+ if fullname == "" then
+ fullname = resolvers.findfile(filename .. ".gz") or ""
+ end
+ if fullname ~= "" then
+ if trace_patterns then
+ report_initialization("loading definition %a for language %a from %a",definition,tag,fullname)
+ end
+ local suffix, gzipped = gzip.suffix(fullname)
+ local loaded = table.load(fullname,gzipped and gzip.load)
+ if loaded then -- todo: version test
+ ok, nofloaded = true, nofloaded + 1
+ sethjcodes(instance,loaded,"patterns",specification.factor)
+ sethjcodes(instance,loaded,"exceptions",specification.factor)
+ local p = validdata(loaded,"patterns",tag)
+ local e = validdata(loaded,"exceptions",tag)
+ if p and p ~= "" then
+ ploaded[#ploaded+1] = p
+ end
+ if e and e ~= "" then
+ eloaded[#eloaded+1] = e
+ end
+ resources[#resources+1] = loaded -- so we can use them otherwise
+ else
+ report_initialization("invalid definition %a for language %a in %a",definition,tag,filename)
+ end
+ elseif trace_patterns then
+ report_initialization("invalid definition %a for language %a in %a",definition,tag,filename)
+ end
+ elseif trace_patterns then
+ report_initialization("definition %a for language %a already loaded",definition,tag)
+ end
+ end
+ if #ploaded > 0 then
+ -- why not always clear
+ instance:clear_patterns()
+ instance:patterns(unique(tag,requested,ploaded))
+ end
+ if #eloaded > 0 then
+ -- why not always clear
+ instance:clear_hyphenation()
+ instance:hyphenation(concat(eloaded," "))
+ end
+ if type(shared) == "string" then
+ instance:hyphenation(shared)
+ end
+ return ok
+ elseif trace_patterns then
+ report_initialization("no definitions for language %a",tag)
+ end
+ statistics.stoptiming(languages)
+end
+
+storage.shared.noflanguages = storage.shared.noflanguages or 0
+
+local noflanguages = storage.shared.noflanguages
+
+function languages.define(tag,parent)
+ noflanguages = noflanguages + 1
+ if trace_patterns then
+ report_initialization("assigning number %a to %a",noflanguages,tag)
+ end
+ numbers[noflanguages] = tag
+ registered[tag] = {
+ tag = tag,
+ parent = parent or "",
+ patterns = "",
+ loaded = false,
+ used = { },
+ dirty = true,
+ number = noflanguages,
+ instance = nil, -- luatex data structure
+ synonyms = { },
+ }
+ storage.shared.noflanguages = noflanguages
+end
+
+function languages.setsynonym(synonym,tag) -- convenience function
+ local l = registered[tag]
+ if l then
+ l.synonyms[synonym] = true -- maybe some day more info
+ end
+end
+
+function languages.installed(separator)
+ return concat(sortedkeys(registered),separator or ",")
+end
+
+function languages.current(n)
+ return numbers[n and tonumber(n) or currentlanguage()]
+end
+
+function languages.associate(tag,script,language) -- not yet used
+ associated[tag] = { script, language }
+end
+
+function languages.association(tag) -- not yet used
+ if not tag then
+ tag = numbers[currentlanguage()]
+ elseif type(tag) == "number" then
+ tag = numbers[tag]
+ end
+ local lat = tag and associated[tag]
+ if lat then
+ return lat[1], lat[2]
+ end
+end
+
+function languages.loadable(tag,defaultlanguage) -- hack
+ local l = registered[tag] -- no synonyms
+ if l and resolvers.findfile("lang-"..l.patterns..".lua") then
+ return true
+ else
+ return false
+ end
+end
+
+-- a bit messy, we will do all language setting in lua as we can now assign
+-- and 'patterns' will go away here.
+
+function languages.unload(tag)
+ local l = registered[tag]
+ if l then
+ l.dirty = true
+ end
+end
+
+if environment.initex then
+
+ function languages.getnumber()
+ return 0
+ end
+
+else
+
+ function languages.getnumber(tag,default,patterns,factor)
+ local l = registered[tag]
+ if l then
+ if l.dirty then
+ l.factor = factor == v_yes and true or false
+ if trace_patterns then
+ report_initialization("checking patterns for %a with default %a",tag,default)
+ end
+ -- patterns is already resolved to parent patterns if applicable
+ if patterns and patterns ~= "" then
+ if l.patterns ~= patterns then
+ l.patterns = patterns
+ if trace_patterns then
+ report_initialization("loading patterns for %a using specification %a",tag,patterns)
+ end
+ loaddefinitions(tag,l)
+ else
+ -- unchanged
+ end
+ elseif l.patterns == "" then
+ l.patterns = tag
+ if trace_patterns then
+ report_initialization("loading patterns for %a using tag",tag)
+ end
+ local ok = loaddefinitions(tag,l)
+ if not ok and tag ~= default then
+ l.patterns = default
+ if trace_patterns then
+ report_initialization("loading patterns for %a using default",tag)
+ end
+ loaddefinitions(tag,l)
+ end
+ end
+ l.loaded = true
+ l.dirty = false
+ end
+ return l.number
+ else
+ return 0
+ end
+ end
+
+ numbers[0] = "null"
+
+ registered.null = {
+ number = 0,
+ instance = new_language(0),
+ }
+
+end
+
+-- not that usefull, global values
+
+function languages.prehyphenchar (what) return prehyphenchar (tolang(what)) end
+function languages.posthyphenchar (what) return posthyphenchar (tolang(what)) end
+function languages.preexhyphenchar (what) return preexhyphenchar (tolang(what)) end
+function languages.postexhyphenchar(what) return postexhyphenchar(tolang(what)) end
+-------- languages.lefthyphenmin (what) return lefthyphenmin (tolang(what)) end
+-------- languages.righthyphenmin (what) return righthyphenmin (tolang(what)) end
+
+-- e['implementer']= 'imple{m}{-}{-}menter'
+-- e['manual'] = 'man{}{}{}'
+-- e['as'] = 'a-s'
+-- e['user-friendly'] = 'user=friend-ly'
+-- e['exceptionally-friendly'] = 'excep-tionally=friend-ly'
+
+local invalid = { "{", "}", "-" }
+
+local function collecthjcodes(data,str)
+ local found = data.extras and data.extras.characters or { }
+ for s in utfcharacters(str) do
+ if not found[s] then
+ found[s] = true
+ end
+ end
+ for i=1,#invalid do -- less checks this way
+ local c = invalid[i]
+ if found[c] then
+ found[c] = nil
+ end
+ end
+ data.extras = { characters = found }
+ sethjcodes(data.instance,data,"extras",data.factor)
+end
+
+function languages.loadwords(tag,filename)
+ local data, instance = resolve(tag)
+ if data then
+ statistics.starttiming(languages)
+ local str = io.loaddata(filename) or ""
+ collecthjcodes(data,str)
+ instance:hyphenation(str)
+ statistics.stoptiming(languages)
+ end
+end
+
+
+function languages.setexceptions(tag,str)
+ local data, instance = resolve(tag)
+ if data then
+ str = strip(str) -- we need to strip leading spaces
+ collecthjcodes(data,str)
+ instance:hyphenation(str)
+ end
+end
+
+function languages.hyphenate(tag,str)
+ -- todo: does this still work?
+ local data, instance = resolve(tag)
+ if data then
+ return instance:hyphenate(str)
+ else
+ return str
+ end
+end
+
+-- hyphenation.define ("zerolanguage")
+-- hyphenation.loadpatterns ("zerolanguage") -- else bug
+-- hyphenation.loadexceptions("zerolanguage") -- else bug
+
+languages.logger = languages.logger or { }
+
+function languages.logger.report()
+ local result, r = { }, 0
+ for tag, l in sortedpairs(registered) do
+ if l.loaded then
+ r = r + 1
+ result[r] = format("%s:%s:%s",tag,l.parent,l.number)
+ end
+ end
+ return r > 0 and concat(result," ") or "none"
+end
+
+-- must happen at the tex end .. will use lang-def.lua
+
+languages.associate('en','latn','eng')
+languages.associate('uk','latn','eng')
+languages.associate('nl','latn','nld')
+languages.associate('de','latn','deu')
+languages.associate('fr','latn','fra')
+
+statistics.register("loaded patterns", function()
+ local result = languages.logger.report()
+ if result ~= "none" then
+ -- return result
+ return format("%s, load time: %s",result,statistics.elapsedtime(languages))
+ end
+end)
+
+-- statistics.register("language load time", function()
+-- -- often zero so we can merge that in the above
+-- return statistics.elapsedseconds(languages, format(", nofpatterns: %s",nofloaded))
+-- end)
+
+-- interface
+
+implement {
+ name = "languagenumber",
+ actions = { languages.getnumber, context },
+ arguments = "4 strings"
+}
+
+implement {
+ name = "installedlanguages",
+ actions = { languages.installed, context },
+}
+
+implement {
+ name = "definelanguage",
+ actions = languages.define,
+ arguments = "2 strings"
+}
+
+implement {
+ name = "setlanguagesynonym",
+ actions = languages.setsynonym,
+ arguments = "2 strings"
+}
+
+implement {
+ name = "unloadlanguage",
+ actions = languages.unload,
+ arguments = "string"
+}
+
+implement {
+ name = "setlanguageexceptions",
+ actions = languages.setexceptions,
+ arguments = "2 strings"
+}
+
+implement {
+ name = "currentprehyphenchar",
+ actions = function()
+ local c = prehyphenchar(tolang())
+ if c and c > 0 then
+ context.char(c)
+ end
+ end
+}
+
+implement {
+ name = "currentposthyphenchar",
+ actions = function()
+ local c = posthyphenchar(tolang())
+ if c and c > 0 then
+ context.char(c)
+ end
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-ini.mkxl
new file mode 100644
index 00000000000..5df975c661f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-ini.mkxl
@@ -0,0 +1,787 @@
+%D \module
+%D [ file=lang-ini,
+%D version=1996.01.25,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \cldcontext{languages.numbers[tex.count.mainlanguagenumber]}
+
+%D This module implements multi||language support of \CONTEXT, which should not be
+%D confused with the multi||lingual interface. This support will be extended when
+%D needed. Properties of languages are defined in \TEX\ files as well as \LUA\
+%D files.
+
+\writestatus{loading}{ConTeXt Language Macros / Initialization}
+
+\registerctxluafile{lang-ini}{autosuffix}
+\registerctxluafile{lang-def}{}
+\registerctxluafile{lang-cnt}{}
+
+\unprotect
+
+\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi
+\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi
+
+%D When loading hyphenation patterns, \TEX\ assign a number to each loaded table,
+%D starting with~0. Switching to a specific table is done by assigning the relevant
+%D number to the predefined \COUNTER\ \type {\language}. However, in \MKIV\ a lot
+%D of management is delegated to \LUA.
+
+%D We keep track of the last loaded patterns by means of a pseudo \COUNTER. This
+%D just one of those situations in which we don't want to spent a real one. Language
+%D zero has no patterns, first of all because I like to start numbering at one. It
+%D may come in handy for special purposes as well.
+
+\normallanguage\zerocount
+
+%D \macros
+%D {currentlanguage, setupcurrentlanguage}
+%D
+%D Instead of numbers,we are going to use symbolic names for the languages. The
+%D current langage is saved in the macro \type {\currentlanguage}. The setup macro
+%D is mainly used for cosmetic purposes.
+%D
+%D \starttyping
+%D \dorecurse{3}
+%D {\language[nl]
+%D \startmode[*en] english \stopmode
+%D \startmode[*nl] dutch \stopmode
+%D \language[en]
+%D \startmode[*en] english \stopmode
+%D \startmode[*nl] dutch \stopmode}
+%D \stoptyping
+
+\mutable\let\askedlanguage \empty
+\mutable\let\currentlanguage \empty
+\mutable\let\currentmainlanguage\empty
+
+%D \macros
+%D {defaultlanguage,languageparameter,specificlanguageparameter}
+%D
+%D We don't use the commandhandler here (yet) because we have a rather special
+%D fallback mechanism so quite some compatibility testing is needed.
+
+\installcorenamespace{language}
+\installcorenamespace{languagelinked}
+
+\mutable\def\currentusedlanguage{\currentlanguage}
+
+\permanent\def\defaultlanguage#1%
+ {\ifcsname\??language#1\s!default\endcsname
+ \expandafter\defaultlanguage\lastnamedcs
+ \else
+ #1%
+ \fi}
+
+\permanent\def\languageparameter#1%
+ {\ifcsname\??language\currentlanguage#1\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??language\currentlanguage\s!default\endcsname
+ \expandafter\specificlanguageparameter\lastnamedcs{#1}%
+ \orelse\ifcsname\??language\s!default#1\endcsname
+ \lastnamedcs
+ \fi}
+
+\permanent\def\specificlanguageparameter#1#2%
+ {\ifcsname\??language#1#2\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??language#1\s!default\endcsname
+ \expandafter\specificlanguageparameter\lastnamedcs{#2}%
+ \orelse\ifcsname\??language\s!default#2\endcsname
+ \lastnamedcs
+ \fi}
+
+\permanent\def\mainlanguageparameter#1%
+ {\ifcsname\??language\currentmainlanguage#1\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??language\currentmainlanguage\s!default\endcsname
+ \expandafter\specificlanguageparameter\lastnamedcs{#1}%
+ \orelse\ifcsname\??language\s!default#1\endcsname
+ \lastnamedcs
+ \fi}
+
+\aliased\let\usedlanguageparameter\languageparameter
+
+\permanent\def\askedlanguageparameter#1% assumes \currentusedlanguage being set
+ {\ifcsname\??language\currentusedlanguage#1\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??language\currentusedlanguage\s!default\endcsname
+ \expandafter\specificlanguageparameter\lastnamedcs{#1}%
+ \orelse\ifcsname\??language\s!default#1\endcsname
+ \lastnamedcs
+ \fi}
+
+\permanent\protected\def\setusedlanguage#1%
+ {\edef\currentusedlanguage{\reallanguagetag{#1}}%
+ \ifempty\currentusedlanguage
+ \let\currentusedlanguage \currentlanguage
+ \enforced\let\usedlanguageparameter\languageparameter
+ \orelse\ifx\currentusedlanguage\v!global
+ \let\currentusedlanguage \currentmainlanguage
+ \enforced\let\usedlanguageparameter\mainlanguageparameter
+ \orelse\ifx\currentusedlanguage\v!local
+ \let\currentusedlanguage \currentlanguage
+ \enforced\let\usedlanguageparameter\languageparameter
+ \else
+ \enforced\let\usedlanguageparameter\askedlanguageparameter
+ \fi}
+
+\permanent\protected\def\setupcurrentlanguage[#1]%
+ {\setcurrentlanguage\currentmainlanguage{#1}}
+
+\permanent\protected\def\setcurrentlanguage#1#2% sets modes: **id (currentmain) *id (current)
+ {\edef\p_askedlanguage{#1}% otherwise clash with \askedlanguage
+ \ifempty\p_askedlanguage \else
+ \ifempty\currentmainlanguage\else\resetsystemmode{\systemmodeprefix\currentmainlanguage}\fi
+ \let\currentmainlanguage\p_askedlanguage
+ \setsystemmode{\systemmodeprefix\currentmainlanguage}%
+ \fi
+ \edef\p_askedlanguage{#2}%
+ \ifempty\p_askedlanguage \else
+ \ifempty\currentlanguage\else\resetsystemmode\currentlanguage\fi
+ \let\currentlanguage\p_askedlanguage
+ \setsystemmode\currentlanguage
+ \fi}
+
+%D The internal macros will be defined later.
+
+%D \macros
+%D {installlanguage}
+%D
+%D Hyphenation patterns can only be loaded when the format file is prepared. The
+%D next macro takes care of this loading. A language is specified with
+%D
+%D \showsetup{installlanguage}
+%D
+%D When \type {state} equals \type {start}, both patterns and additional hyphenation
+%D specifications are loaded. These files are seached for in the patterns path
+%D have names like \type {lang-nl.lua}.
+%D
+%D The \type {spacing} variable specifies how the spaces after punctuation has to be
+%D handled. English is by tradition more tolerant to inter||sentence spacing than
+%D other languages.
+%D
+%D This macro also defines \type {\identifier} as a shortcut switch to the language.
+%D Furthermore the command defined as being language specific, are executed. With
+%D \type {default} we can default to another language (patterns) at format
+%D generation time. Patterns are loaded at runtime.
+
+\newtoks \everysetuplanguage
+
+\aliased\let\installedlanguages\clf_installedlanguages % no need for \clf_
+
+\permanent\protected\def\doifelselanguage#1%
+ {\ifcsname\??language#1\c!state\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doiflanguageelse\doifelselanguage
+
+\permanent\def\reallanguagetag#1%
+ {\ifcsname\??languagelinked#1\endcsname\lastnamedcs\else#1\fi}
+
+% \language[#1] gave unwanted side effect of loading language specifics
+
+\mutable\let\currentsetuplanguage\empty
+
+\permanent\tolerant\protected\def\installlanguage[#1]#*[#2]%
+ {\ifcondition\validassignment{#2}%
+ \doifelselanguage{#1}
+ {\getparameters[\??language#1][#2]}
+ {\defcsname\??languagelinked#1\endcsname{#1}%
+ \getparameters[\??language#1][\c!state=\v!start,#2]%
+ \lang_basics_install_indeed{#1}{#1}}%
+ \edef\currentsetuplanguage{#1}%
+ \clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}%
+ \the\everysetuplanguage
+ \else
+ \defcsname\??languagelinked#1\endcsname{#2}%
+ \clf_setlanguagesynonym{#1}{#2}%
+ \lang_basics_install_indeed{#1}{#2}%
+ \fi}
+
+\def\lang_basics_install_indeed#1#2%
+ {\ifcstok{\specificlanguageparameter{#1}\c!command}\v!no\orelse\ifcsname#1\endcsname\else
+ \frozen\instance\protected\defcsname#1\endcsname{\lang_basics_set_current[#2]}%
+ \fi}
+
+%D When the second argument is a language identifier, a synonym is created. This
+%D feature is present because we used dutch mnemonics in the dutch version, but
+%D nowadays conform a standard.
+
+\permanent\protected\def\doifelsepatterns#1%
+ {\begingroup % will change
+ \lang_basics_set_current[#1]%
+ \ifnum\normallanguage>\zerocount
+ \endgroup\expandafter\firstoftwoarguments
+ \else
+ \endgroup\expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifpatternselse\doifelsepatterns
+
+%D \macros
+%D {setuplanguage}
+%D
+%D Quick and dirty, but useful:
+%D
+%D \showsetup{setuplanguage}
+%D
+%D Beware, this command can only be used when a language is installed.
+
+\ifdefined\lang_basics_synchronize \else
+ \let\lang_basics_synchronize\relax % be nice for setups till we have one
+\fi
+
+\installmacrostack\currentlanguage
+
+\permanent\tolerant\protected\def\setuplanguage[#1]#*[#2]%
+ {\ifarguments
+ % only synchronize
+ \or
+ \let\currentsetuplanguage\currentlanguage
+ \getparameters[\??language\currentsetuplanguage][#1]%
+ \the\everysetuplanguage
+ \or
+ \push_macro_currentlanguage % can be default
+ \edef\currentsetuplanguage{\reallanguagetag{#1}}%
+ \getparameters[\??language\currentsetuplanguage][#2]%
+ \the\everysetuplanguage
+ \pop_macro_currentlanguage
+ %\doif\currentsetuplanguage\currentlanguage we can have influenced inheritance (default)
+ \fi
+ \lang_basics_synchronize}
+
+\appendtoks
+ \clf_unloadlanguage{\currentsetuplanguage}%
+\to \everysetuplanguage
+
+\setuplanguage
+ [\s!default]
+ [\s!patterns=,
+ \s!lefthyphenmin=2,
+ \s!righthyphenmin=2,
+ \s!lefthyphenchar=-1,
+ \s!righthyphenchar=45,
+ % used in compound i.e. interfaced with c! and can be anything so no numbers
+ \c!lefthyphen=,
+ \c!righthyphen=-,
+ \c!hyphen=-,
+ \c!spacing=\v!packed,
+ \c!compoundhyphen=\compoundhyphen,
+ \c!rightcompoundhyphen=\compoundhyphen,
+ \c!leftcompoundhyphen=,
+ \c!midsentence=---,
+ \c!leftsentence=---,
+ \c!rightsentence=---,
+ \c!leftsubsentence=---,
+ \c!rightsubsentence=---,
+ \c!leftquote=\upperleftsinglesixquote,
+ \c!rightquote=\upperrightsingleninequote,
+ \c!leftquotation=\upperleftdoublesixquote,
+ \c!rightquotation=\upperrightdoubleninequote,
+ \c!leftspeech=\languageparameter\c!leftquotation,
+ \c!middlespeech=,
+ \c!rightspeech=\languageparameter\c!rightquotation,
+ \c!limittext=\unknown,
+ \c!time={h,:,m},
+ \c!date={\v!year,\ ,\v!month,\ ,\v!day},
+ \c!text=Ag,
+ \c!font=] % \v!auto : experimental !
+
+% to be tested:
+%
+% \setuplanguage
+% [\s!default]
+% [\c!righthyphenchar="AD]
+
+%D The values \type {leftsentence} and \type {rightsentence} can be (and are) used
+%D to implement automatic subsentence boundary glyphs, like in {\fr |<|french
+%D guillemots|>|} or {\de |<|german guillemots|>|} or {\nl |<|dutch dashes|>|} like
+%D situations. Furthermore \type {leftquotation} and \type {leftquote} come into
+%D view \quotation {when we quote} or \quote {quote} something.
+
+%D \macros
+%D {currentdatespecification, currenttimespecification}
+%D
+%D Just to make things easy we can ask for the current date specification by saying:
+
+\permanent\def\currentdatespecification{\languageparameter\c!date}
+\permanent\def\currenttimespecification{\languageparameter\c!time}
+
+%D Carefull reading of these macros shows that it's legal to say
+%D
+%D \starttyping
+%D \installlanguage [du] [de]
+%D \stoptyping
+
+%D \macros
+%D {language,mainlanguage}
+%D
+%D Switching to another language (actually another hyphenation pattern) is done
+%D with:
+%D
+%D \starttyping
+%D \language[identifier]
+%D \stoptyping
+%D
+%D or with \type {\identifier}. Just to be compatible with \PLAIN\ \TEX, we still
+%D support the original meaning, so
+%D
+%D \starttyping
+%D \language=1
+%D \stoptyping
+%D
+%D is a valid operation, where the relation between number and language depends on
+%D the order in installing languages.
+%D
+%D \showsetup{language}
+%D \showsetup{mainlanguage}
+%D
+%D Both commands take a predefined language identifier as argument. We can use \type
+%D {\mainlanguage[identifier]} for setting the (indeed) main language. This is the
+%D language used for translating labels like {\em figure} and {\em table}. The main
+%D language defaults to the current language.
+
+\newtoks \everylanguage
+
+\installcorenamespace{languagenumbers}
+
+\appendtoks
+ % we need to reassign the number because new patterns can be defined later on
+ % so let's hope not that many \setups happen during a run
+ \gletcsname\??languagenumbers\currentlanguage\endcsname\undefined
+\to \everysetuplanguage
+
+\def\lang_basics_synchronize_yes
+ {\zerocount % see below
+ \global\expandafter\chardef\csname\??languagenumbers\currentlanguage\endcsname
+ \clf_languagenumber
+ {\currentlanguage}%
+ {\defaultlanguage\currentlanguage}%
+ {\languageparameter\s!patterns}%
+ {\languageparameter\c!factor}%
+ \relax
+ \normallanguage\csname\??languagenumbers\currentlanguage\endcsname}
+
+\let\lang_basics_synchronize_nop\zerocount % not loaded anyway
+
+\letvalue{\??languagenumbers}\lang_basics_synchronize_nop % initime
+
+\appendtoks
+ \letvalue{\??languagenumbers}\lang_basics_synchronize_yes % runtime
+\to \everydump
+
+\def\lang_basics_synchronize
+ {\normallanguage\csname\??languagenumbers
+ \ifcsname\??languagenumbers\currentlanguage\endcsname
+ \currentlanguage
+ \fi
+ \endcsname
+ \relax
+ \the\everylanguage
+ \relax}
+
+\newcount\hyphenstate
+\newcount\hyphenminoffset
+
+% This is the old implementation: a hack that sets the min values, because we want
+% to keep the language set:
+%
+% \protected\def\nohyphens % nicer for url's
+% {\ifrelax\dohyphens
+% \protected\edef\dohyphens
+% {\hyphenminoffset\the\hyphenminoffset\relax
+% \lang_basics_synchronize_min_max}%
+% \fi
+% \hyphenminoffset\plusthousand
+% \lang_basics_synchronize_min_max}
+%
+% \let\dohyphens\relax
+
+% But this one is nicer because we do keep the language set as well as don't mess
+% with the min values (it's more efficient too). We might get some more bits in
+% this mode (engine specific).
+
+\exhyphenchar 45 % to permit breaking at explicit hyphens
+
+% \uchyph\plusone :
+
+% \chardef \completehyphenationmodecode \numexpr
+\permanent \integerdef \completehyphenationmodecode \numexpr
+ \normalhyphenationmodecode % \discretionary
+ + \automatichyphenationmodecode % -
+ + \explicithyphenationmodecode % \-
+ + \syllablehyphenationmodecode % pattern driven
+ + \uppercasehyphenationmodecode % replaces \uchyph
+ + \compoundhyphenationmodecode % replaces \compoundhyphenmode
+ % \strictstarthyphenationmodecode % replaces \hyphenationbounds (strict = original tex)
+ % \strictendhyphenationmodecode % replaces \hyphenationbounds (strict = original tex)
+ + \automaticpenaltyhyphenationmodecode % replaces \hyphenpenaltymode (otherwise use \exhyphenpenalty)
+ + \explicitpenaltyhyphenationmodecode % replaces \hyphenpenaltymode (otherwise use \exhyphenpenalty)
+ + \permitgluehyphenationmodecode % turn glue into kern in \discretionary
+ + \permitallhyphenationmodecode % okay, let's be even more tolerant
+ + \permitmathreplacehyphenationmodecode % and again we're more permissive
+\relax
+
+\permanent\protected\def\dohyphens{\hyphenationmode\completehyphenationmodecode}
+\permanent\protected\def\nohyphens{\hyphenationmode\zerocount}
+
+\permanent\protected\def\usehyphensparameter#1%
+ {\edef\p_hyphens{#1\c!hyphens}%
+ \ifx\p_hyhens\v!no
+ \nohyphens
+ \fi}
+
+\dohyphens
+
+%D The rest stays the same as in mkiv:
+
+\permanent\protected\def\lesshyphens
+ {\advance\hyphenminoffset\plusone
+ \lang_basics_synchronize_min_max}
+
+\permanent\protected\def\morehyphens
+ {\ifcase\hyphenminoffset \else
+ \advance\hyphenminoffset\minusone
+ \fi
+ \lang_basics_synchronize_min_max}
+
+\protected\def\lang_basics_synchronize_min_max % maybe store this at the lua end
+ {% these values are stored along with glyph nodes
+ \lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin +\hyphenminoffset\relax
+ \righthyphenmin\numexpr0\languageparameter\s!righthyphenmin+\hyphenminoffset\relax
+ \hyphenationmin\numexpr0\languageparameter\s!hyphenmin\relax
+ % these values are stored with the language (global!)
+ \prehyphenchar \languageparameter\s!righthyphenchar\relax
+ \posthyphenchar\languageparameter\s!lefthyphenchar \relax}
+
+\appendtoks
+ \lang_basics_synchronize_min_max
+\to \everylanguage
+
+\permanent\protected\def\unhyphenated
+ {\groupedcommand{\lefthyphenmin\maxdimen}\donothing}
+
+% \appendtoks
+% \setups[\languageparameter\c!setups]%
+% \to \everylanguage
+
+%D You can setup the default language to reset settings.
+
+\mutable\let\currentlanguagesetups\empty
+
+\appendtoks
+ \edef\currentlanguagesetups{\languageparameter\c!setups}%
+ \ifempty\currentlanguagesetups \else
+ \setups[\currentlanguagesetups]%
+ \fi
+\to \everylanguage
+
+% new
+
+\appendtoks
+ \usebidiparameter\languageparameter
+\to \everylanguage
+
+% this will move to core-spa !
+
+\appendtoks
+ \edef\p_spacing{\languageparameter\c!spacing}%
+ \ifx\p_spacing\v!broad
+ \nonfrenchspacing
+ \else
+ \frenchspacing
+ \fi
+\to \everylanguage
+
+% \mainlanguage[nl] \setuplanguage[nl][lefthyphen=,righthyphen=?]
+%
+% \dorecurse{100}{dit is toch wel een heel\normalhyphendiscretionary lang\normalhyphendiscretionary woord \recurselevel\ }
+% \dorecurse{100}{dit is toch wel een heellangwoord \recurselevel\ }
+
+% new experimental feature
+
+\permanent\protected\def\setuplanguages
+ {\setuplanguage[\s!default]}
+
+% \setuplanguages[\c!font=\v!auto]
+% \setuplanguage[\s!default][\c!font=\v!auto]
+% \setuplanguage[nl][\c!font=\v!auto]
+
+\appendtoks
+ \edef\p_language_font{\languageparameter\c!font}%
+ \ifempty\p_language_font
+ \orelse\ifx\p_language_font\v!auto
+ \doaddfeature\currentlanguage
+ \else
+ \doaddfeature\p_language_font
+ \fi
+\to \everylanguage
+
+%D Fast switcher
+
+\def\lang_basics_switch_asked
+ {\ifcsname\??languagelinked\askedlanguage\endcsname
+ \edef\askedlanguage{\lastnamedcs}%
+ \ifx\currentlanguage\askedlanguage \else
+ \setcurrentlanguage\currentmainlanguage\askedlanguage
+ \lang_basics_synchronize
+ \fi
+ \fi}
+
+\permanent\protected\def\uselanguageparameter#1%
+ {\edef\askedlanguage{#1\c!language}%
+ \ifempty\askedlanguage\else\lang_basics_switch_asked\fi}
+
+\permanent\protected\def\douselanguageparameter#1% fast setter
+ {\edef\askedlanguage{#1}%
+ \ifempty\askedlanguage\else\lang_basics_switch_asked\fi}
+
+\protected\def\lang_basics_set_current[#1]%
+ {\edef\askedlanguage{#1}%
+ \ifempty\askedlanguage\else\lang_basics_switch_asked\fi}
+
+\pushoverloadmode
+
+ \permanent\protected\def\language
+ {\doifelsenextoptionalcs\lang_basics_set_current\normallanguage}
+
+ \aliased\let\setlanguage\language % we make these synonyms
+
+ \aliased\let\patterns\gobbleoneargument
+
+\popoverloadmode
+
+\newcount\mainlanguagenumber
+
+%D Beware: you might need to use \type {\dontleavehmode} outside and|/|or \type {\par}
+%D inside the group!
+
+\permanent\protected\def\startlanguage
+ {\begingroup\language}
+
+\permanent\let\stoplanguage\endgroup
+
+\permanent\protected\def\mainlanguage[#1]%
+ {\edef\askedlanguage{#1}%
+ \ifempty\askedlanguage
+ \orelse\ifcsname\??languagelinked\askedlanguage\endcsname
+ %\edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}%
+ \edef\askedlanguage{\lastnamedcs}%
+ \ifx\currentlanguage\askedlanguage
+ \ifx\currentmainlanguage\askedlanguage \else
+ \setcurrentlanguage\askedlanguage\askedlanguage
+ \lang_basics_synchronize
+ \fi
+ \else
+ \setcurrentlanguage\askedlanguage\askedlanguage
+ \lang_basics_synchronize
+ \fi
+ \fi
+ \mainlanguagenumber\normallanguage}
+
+\appendtoks
+ \normallanguage\mainlanguagenumber
+\to \everybeforepagebody
+
+%D Used at all?
+
+\permanent\def\splitsequence#1#2%
+ {\doifelse{#1}\v!no{#2}{\doifelse{#1}\v!yes{\languageparameter\c!limittext}{#1}}}
+
+\permanent\def\splitsymbol#1%
+ {\splitsequence{#1}{\languageparameter\c!limittext}}
+
+%D Just like with subsentence boundary symbols, quotes placement depends on the
+%D current language, therefore we show the defaults here.
+%D
+%D \def\ShowLanguageValues [#1] [#2] #3 #4
+%D {\blank
+%D \startlinecorrection
+%D \vbox\bgroup
+%D \language[#1]
+%D \midaligned{\bf#2 subsentence symbol and quotes}
+%D \framed[width=\hsize,frame=off,topframe=on,bottomframe=on,offset=.5ex]
+%D {\hfil\quotation{#3 #4}\hfil\quote{#2}\hfil
+%D \startsubsentence\startsubsentence#3\stopsubsentence#4\stopsubsentence\hfil}
+%D \egroup
+%D \stoplinecorrection
+%D \blank}
+%D
+%D \ShowLanguageValues [af] [afrikaans] afrikaanse ...
+%D \ShowLanguageValues [ca] [catalan] catalan ...
+%D \ShowLanguageValues [cs] [czech] tjechisch tex
+%D \ShowLanguageValues [cs] [slovak] slowaakse ...
+%D \ShowLanguageValues [da] [danish] deense ...
+%D \ShowLanguageValues [de] [german] duitse degelijkheid
+%D \ShowLanguageValues [en] [english] engelse humor
+%D \ShowLanguageValues [et] [estonian] ...
+%D \ShowLanguageValues [fi] [finnish] finse ...
+%D \ShowLanguageValues [fr] [french] franse slag
+%D \ShowLanguageValues [it] [italian] italiaanse ...
+%D \ShowLanguageValues [la] [latin] latijnse missen
+%D \ShowLanguageValues [nl] [dutch] nederlandse zuinigheid
+%D \ShowLanguageValues [nb] [bokmal] noorse zalm
+%D \ShowLanguageValues [nn] [nnynorsk] noorse zalm
+%D \ShowLanguageValues [pl] [polish] poolse vlag
+%D \ShowLanguageValues [pt] [portuguese] portugese ...
+%D \ShowLanguageValues [es] [spanish] spaans benauwd
+%D \ShowLanguageValues [sv] [swedish] zweedse ...
+%D \ShowLanguageValues [tr] [turkish] turks fruit
+
+%D We support a lot of languages. These are specified and loaded in separate files,
+%D according to their roots. Here we only take care of (postponed) setting of the
+%D current language.
+%D
+%D \unprotect
+%D \placetable{The germanic languages (\type{lang-ger})}
+%D \starttable[||||]
+%D \HL
+%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
+%D \HL
+%D \NC \s!nl \NC dutch \NC germanic \NC\FR
+%D \NC \s!en \NC english \NC germanic \NC\MR
+%D \NC \s!de \NC german \NC germanic \NC\MR
+%D \NC \s!da \NC danish \NC germanic \NC\MR
+%D \NC \s!sv \NC swedish \NC germanic \NC\MR
+%D \NC \s!af \NC afrikaans \NC germanic \NC\MR
+%D \NC \s!nb \NC bokmal \NC germanic \NC\LR
+%D \NC \s!nn \NC nynorsk \NC germanic \NC\LR
+%D \HL
+%D \stoptable
+%D \protect
+%D
+%D \unprotect
+%D \placetable{The italic languages (\type{lang-ita})}
+%D \starttable[||||]
+%D \HL
+%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
+%D \HL
+%D \NC \s!fr \NC french \NC italic \NC\FR
+%D \NC \s!ca \NC catalan \NC italic \NC\MR
+%D \NC \s!es \NC spanish \NC italic \NC\MR
+%D \NC \s!it \NC italian \NC italic \NC\MR
+%D \NC \s!la \NC latin \NC italic \NC\MR
+%D \NC \s!pt \NC portuguese \NC italic \NC\LR
+%D \HL
+%D \stoptable
+%D \protect
+%D
+%D \unprotect
+%D \placetable{The slavic languages (\type{lang-sla})}
+%D \starttable[||||]
+%D \HL
+%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
+%D \HL
+%D \NC \s!pl \NC polish \NC slavic \NC\FR
+%D \NC \s!cs \NC czech \NC slavic \NC\MR
+%D \NC \s!sk \NC slavik \NC slavic \NC\LR
+%D \HL
+%D \stoptable
+%D \protect
+%D \unprotect
+%D
+%D \placetable{The altaic languages (\type{lang-alt})}
+%D \starttable[||||]
+%D \HL
+%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
+%D \HL
+%D \NC \s!tr \NC turkish \NC altaic \NC\SR
+%D \HL
+%D \stoptable
+%D
+%D \placetable{The uralic languages (\type{lang-ura})}
+%D \starttable[||||]
+%D \HL
+%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
+%D \HL
+%D \NC \s!fi \NC finnish \NC uralic \NC\SR
+%D \HL
+%D \stoptable
+%D \protect
+
+\permanent\protected\def\nopatterns{\normallanguage\minusone}
+
+%D We default to the language belonging to the interface. This is one of the few
+%D places outside the interface modules where \type {\startinterface} is used.
+
+\setupcurrentlanguage[\s!en]
+
+\permanent\protected\def\initializemainlanguage
+ {\mainlanguage[\currentlanguage]%
+ \showmessage\m!languages9\currentlanguage}
+
+%D New:
+
+\permanent\let\stopexceptions\relax
+
+\tolerant\permanent\protected\def\startexceptions[#1]#:#2\stopexceptions
+ {\begingroup
+ \edef\askedlanguage{\reallanguagetag{#1}}%
+ \ifempty\askedlanguage
+ \let\askedlanguage\currentlanguage
+ \fi
+ \clf_setlanguageexceptions{\askedlanguage}{#2}%
+ \endgroup}
+
+\pushoverloadmode
+
+\permanent\protected\def\hyphenation
+ {\clf_setlanguageexceptions{\currentlanguage}}
+
+\popoverloadmode
+
+%D New:
+
+\permanent\protected\def\traceddiscretionary#1#%
+ {\dontleavehmode\lang_basics_traced_discretionary{#1}}
+
+\protected\def\lang_basics_traced_discretionary#1#2#3#4%
+ {\normaldiscretionary#1{\darkred#2}{\darkgreen#3}{\darkblue#4}}
+
+\installtextracker
+ {discretionaries}
+ {\enforced\let\discretionary\traceddiscretionary}
+ {\enforced\let\discretionary\normaldiscretionary}
+
+\permanent\protected\def\samplediscretionary
+ {\traceddiscretionary
+ {pre\clf_currentprehyphenchar}%
+ {\clf_currentposthyphenchar post}%
+ {replace}}
+
+%D A typical \LMTX\ feature:
+%D
+%D \starttyping
+%D whatever\par
+%D {\nokerning whatever}\par
+%D efficient ff fi\par
+%D {\noligaturing efficient ff fi}\par
+%D {\nokerning\noligaturing efficient ff fi}\par
+%D {e{\noligaturing ffi}cient}\par
+%D {ef{\noleftligaturing f}icient ff fi}\par
+%D {ef{\norightligaturing f}icient ff fi}\par
+%D \stoptyping
+
+\immutable\chardef\nokerningcode \numexpr\noleftkerncode +\norightkerncode \relax
+\immutable\chardef\noligaturingcode\numexpr\noleftligaturecode+\norightligaturecode\relax
+
+\permanent\protected\def\nokerning {\bitwiseflip\glyphoptions\nokerningcode}
+\permanent\protected\def\noligaturing{\bitwiseflip\glyphoptions\noligaturingcode}
+
+\permanent\protected\def\noleftkerning {\bitwiseflip\glyphoptions\noleftkerncode}
+\permanent\protected\def\noleftligaturing {\bitwiseflip\glyphoptions\noleftligaturecode}
+\permanent\protected\def\norightkerning {\bitwiseflip\glyphoptions\norightkerncode}
+\permanent\protected\def\norightligaturing{\bitwiseflip\glyphoptions\norightligaturecode}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-lab.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-lab.mkxl
new file mode 100644
index 00000000000..369049ed162
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-lab.mkxl
@@ -0,0 +1,377 @@
+%D \module
+%D [ file=lang-lab,
+%D version=1997.08.27,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Labels,
+%D author=Hans Hagen / Tobias Burnus,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Language Macros / Labels}
+
+\registerctxluafile{lang-lab}{}
+\registerctxluafile{lang-txt}{}
+
+\unprotect
+
+%D Left-overs:
+
+\ifdefined\sixperemspace \else
+ \permanent\def\sixperemspace{\normalUchar"2006}
+\fi
+
+%D In this module we deal with language dependant labels and prefixes, like in {\em
+%D Figure~12} and {\em Chapter 1}. In this file we set the default values. Users can
+%D easily overrule these.
+%D
+%D This module is dedicated to the grandfather of Tobias Burnus, who's extensive
+%D languages oriented library helped us a lot in finding the right translations. All
+%D those labels are collected in files that reflect their common ancestor.
+%D
+%D Not all languages can be satisfied with the labeling mechanism as provided here.
+%D Chinese for instance put a label in front as well as after a part number. This is
+%D why the current implementation of labels supports two labels too.
+
+%D \macros
+%D {setupheadtext, setuplabeltext}
+%D
+%D First we present some macros that deal with what we will call head and label
+%D texts. Such texts are defines by:
+%D
+%D \showsetup{setupheadtext}
+%D \showsetup{setuplabeltext}
+%D
+%D A regular \CONTEXT\ stores some 1500 labels at most.
+%D
+%D These commands accept all kind of inputs:
+%D
+%D \starttyping
+%D \setuplabeltext [language] [labellabel=text]
+%D \setuplabeltext [language] [labellabel=text,labellabel=text,...]
+%D \setuplabeltext [labellabel=text]
+%D \setuplabeltext [labellabel=text,labellabel=text,...]
+%D \stoptyping
+%D
+%D The last two cases concern the current language.
+
+\installcorenamespace{label}
+
+% \let\currentlabelcategory\empty
+
+\permanent\tolerant\protected\def\definelabelclass[#1]#*[#2]%
+ {\normalexpanded
+ {\lang_labels_define_class_indeed
+ {#1}%
+ {\ifchknum#2\or#2\else\zerocount\fi}%
+ \expandafter\noexpand\csname lang_labels_#1_text_1\endcsname
+ \expandafter\noexpand\csname #1language\endcsname
+ \expandafter\noexpand\csname lang_labels_#1_text_2\endcsname
+ \expandafter\noexpand\csname left#1text\endcsname
+ \expandafter\noexpand\csname right#1text\endcsname
+ \expandafter\noexpand\csname #1texts\endcsname
+ \expandafter\noexpand\csname #1text\endcsname}}
+
+% hm, not interfaced
+
+\mutable\let\thetextprefix\empty
+
+\mutable\let\currenttextprefixclass\s!unknown
+\mutable\let\currenttextprefixname \empty
+\mutable\let\currenttextprefixtag \s!unknown
+
+\protected\def\lang_labels_define_class_indeed#1#2#3#4#5#6#7#8#9%
+ {\permanent\instance\protected\defcsname setup#1text\endcsname{\protecttextprefixes#2\def\currenttextprefixclass{#1}\lang_labels_text_prefix_setup}%
+ \permanent\instance\protected\defcsname preset#1text\endcsname{\protecttextprefixes 1\def\currenttextprefixclass{#1}\lang_labels_text_prefix_setup}%
+ \permanent\instance\protected\defcsname copy#1text\endcsname{\protecttextprefixes 1\def\currenttextprefixclass{#1}\lang_labels_text_prefix_copy }%
+ \permanent\instance\protected\defcsname start#1text\endcsname{\protecttextprefixes 1\def\currenttextprefixclass{#1}\lang_labels_text_prefix_start[#1]}%
+ \permanent\instance \letcsname stop#1text\endcsname \relax
+ \permanent\instance\def#4{\reallanguagetag{\defaultlanguage\currentmainlanguage}}%
+ \ifnum#2=\plustwo % used for math and tags
+ \instance\def#3{#5#4}%
+% \instance\def#5##1##2% ##1=language
+% {\ifcsname\??label\currentlabelcategory#1:##1:##2\endcsname
+% \lastnamedcs
+% \orelse\ifcsname\??label#1:##1:##2\endcsname
+% \lastnamedcs
+% \orelse\ifcsname\??language##1\s!default\endcsname
+% \expandafter#5\lastnamedcs{##2}%
+% \orelse\ifcsname\??label\currentlabelcategory#1:##2\endcsname
+% \lastnamedcs
+% \orelse\ifcsname\??label#1:##2\endcsname
+% \lastnamedcs
+% \orelse\ifcsname\??label\currentlabelcategory#1:\s!en:##2\endcsname
+% \lastnamedcs
+% \orelse\ifcsname\??label#1:\s!en:##2\endcsname
+% \lastnamedcs
+% \else
+% ##2%
+% \fi}%
+ \instance\def#5##1##2% ##1=language
+ {\ifcsname\??label#1:##1:##2\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??language##1\s!default\endcsname
+ \expandafter#5\lastnamedcs{##2}%
+ \orelse\ifcsname\??label#1:##2\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??label#1:\s!en:##2\endcsname
+ \lastnamedcs
+ \else
+ ##2%
+ \fi}%
+ \permanent\instance\let#6\gobbleoneargument
+ \permanent\instance\let#7\gobbleoneargument
+ \permanent\instance\let#8\gobbletwoarguments
+ \permanent\instance\let#9#3%
+ \else
+ \instance\protected\def#3{#5#4}%
+ \instance\protected\def#5##1##2%
+ {\ifcsname\??label#1:##1:##2\endcsname
+ \enforced\expandafter\let\expandafter\thetextprefix\lastnamedcs
+ \orelse\ifcsname\??language#4\s!default\endcsname
+ \expandafter#5\lastnamedcs{##2}%
+ \orelse\ifcsname\??label#1:##2\endcsname
+ \enforced\expandafter\let\expandafter\thetextprefix\lastnamedcs
+ \orelse\ifcsname\??label#1:\s!en:##2\endcsname
+ \enforced\expandafter\let\expandafter\thetextprefix\lastnamedcs
+ \else
+ \enforced\let\thetextprefix\dummytextprefix
+ \fi}%
+ \permanent \instance\protected\def#6##1{#3{##1}\expandafter\firstoftwoarguments \thetextprefix}% \flushleftlabelclass
+ \permanent\instance\protected\def#7##1{#3{##1}\expandafter\secondoftwoarguments \thetextprefix}% \flushrightlabelclass
+ \permanent\instance\protected\def#8##1{#3{##1}\expandafter\lang_labels_flush_both\thetextprefix}% \flushbothlabelclass #2
+ \permanent\instance\protected\def#9##1{#3{##1}\expandafter\firstoftwoarguments \thetextprefix}% \flushleftlabelclass
+ \fi
+ \appendtoks
+ \enforced\permanent\instance\let#6\firstofoneargument % to be checked
+ \enforced\permanent\instance\let#7\firstofoneargument % to be checked
+ \enforced\permanent\instance\let#8\firstofoneargument % to be checked
+ \enforced\permanent\instance\let#9\firstofoneargument % to be checked
+ \to \everysimplifycommands}
+
+% why not lang_* ?
+
+% \let\flushleftlabelclass \firstoftwoarguments
+% \let\flushrightlabelclass\secondoftwoarguments
+
+\permanent\def\lang_labels_flush_both#1#2#3{#1#3#2}
+
+\permanent\def\dummytextprefix{\empty\empty}
+
+%D \macros
+%D {headtext, labeltext, leftlabeltext, rightlabeltext, labeltexts}
+%D
+%D Once defined, head and label texts can be called upon using:
+%D
+%D \showsetup{headtext}
+%D \showsetup{labeltext}
+%D
+%D \macros
+%D {presetheadtext,presetlabeltext}
+%D
+%D These macros enable us to automatically define head and label texts without
+%D replacing predefined ones. They are internal macros.
+
+\appendtoks \enforced\let\labellanguage\currentlanguage \to \everycurrentdate
+
+\newconstant\protecttextprefixes
+
+\tolerant\def\lang_labels_text_prefix_start[#1]#*[#2]#*[#3]% class language name
+ {\ifarguments\or\or
+ \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
+ \edef\currenttextprefixname{#2}%
+ \else
+ \edef\currenttextprefixtag{\reallanguagetag{#2}}%
+ \edef\currenttextprefixname{#3}%
+ \fi
+ \grabuntil{stop#1text}\lang_labels_text_prefix_start_indeed}
+
+\def\lang_labels_text_prefix_start_indeed#1% text (not special checking done here yet, only for long texts anyway)
+ {\edefcsname\??label\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname{{\clf_strip{#1}}\empty}}
+
+\tolerant\def\lang_labels_text_prefix_setup[#1]#*[#2]%
+ {\ifarguments\or
+ \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
+ \processcommalist[#1]\lang_labels_text_prefix_setup_indeed
+ \else
+ \edef\currenttextprefixtag{\reallanguagetag{#1}}%
+ \processcommalist[#2]\lang_labels_text_prefix_setup_indeed
+ \fi}
+
+\def\lang_labels_text_prefix_setup_indeed#1%
+ {\lang_labels_text_prefix_assign[#1]}
+
+\def\lang_labels_text_prefix_assign[#1=#2]%
+ {\lang_labels_text_prefix_assign_indeed{#1}[#2,,]}
+
+\def\lang_labels_text_prefix_assign_indeed#1%
+ {\ifcase\protecttextprefixes
+ % no checking
+ \expandafter\lang_labels_text_prefix_assign_yes
+ \or
+ % checking
+ \ifcsname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname
+ \expandafter\expandafter\expandafter\lang_labels_text_prefix_assign_nop
+ \else
+ \expandafter\expandafter\expandafter\lang_labels_text_prefix_assign_yes
+ \fi
+ \or
+ % simple assignment (a bit overkill but it fits in the whole)
+ \expandafter\lang_labels_text_prefix_assign_dumb
+ \fi{#1}}
+
+\let\m_lang_labels_left \empty
+\let\m_lang_labels_right\empty
+
+\def\lang_labels_text_prefix_assign_yes#1[#2,#3,#4]%
+ {\def\m_lang_labels_left {#2}% no longer an edef ... else \Word undefined expansion issues
+ \def\m_lang_labels_right{#3}% no longer an edef ... else \Word undefined expansion issues
+ \defcsname\??label\currenttextprefixclass:\currenttextprefixtag:#1%
+ \ifempty\m_lang_labels_right
+ \ifempty\m_lang_labels_left
+ \endcsname{\empty\empty}%
+ \else
+ \endcsname{{#2}\empty}%
+ \fi
+ \else
+ \endcsname{{#2}{#3}}%
+ \fi}
+
+\def\lang_labels_text_prefix_assign_nop#1[#2]%
+ {}
+
+\def\lang_labels_text_prefix_assign_dumb#1[#2,#3]%
+ {\defcsname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}}
+
+\permanent\protected\def\setlabeltextpair#1#2#3#4#5% a fast one for usage at the Lua end
+ {%\writestatus{!!!!}{#1:\reallanguagetag{#2}:#3}%
+ \defcsname\??label#1:\reallanguagetag{#2}:#3\endcsname{{#4}{#5}}} % class tag key left right
+
+\tolerant\def\lang_labels_text_prefix_copy[#1]#*[#2]%
+ {\ifarguments\or
+ \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
+ \processcommalist[#1]\lang_labels_text_prefix_copy_indeed
+ \else
+ \edef\currenttextprefixtag{\reallanguagetag{#1}}%
+ \processcommalist[#2]\lang_labels_text_prefix_copy_indeed
+ \fi}
+
+\def\lang_labels_text_prefix_copy_indeed#1%
+ {\lang_labels_text_prefix_copy_pair[#1]}
+
+\def\lang_labels_text_prefix_copy_pair[#1=#2]%
+ {\lang_labels_text_prefix_copy_pair_indeed{#1}[#2,,]}
+
+% \def\lang_labels_text_prefix_copy_pair_indeed#1[#2,#3]%
+% {\expandafter\let
+% \csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\expandafter\endcsname
+% \csname\??label\currenttextprefixclass:\currenttextprefixtag:#2\endcsname}
+%
+% this delays the aliasing so that we can switch mainlanguage in between
+
+\def\lang_labels_text_prefix_copy_pair_indeed#1[#2,#3]%
+ {\edefcsname\??label\currenttextprefixclass:#1\endcsname
+ {{\noexpand\csname\??label\currenttextprefixclass:\noexpand\reallanguagetag\noexpand\currentmainlanguage:#2\endcsname}{}}}
+
+\definelabelclass [head] [0] % titles
+\definelabelclass [label] [0] % texts
+\definelabelclass [mathlabel] [0] % functions
+\definelabelclass [taglabel] [2] % tags
+
+\clf_definelabels{head}{titles}\s!true\relax
+\clf_definelabels{label}{texts}\s!true\relax
+\clf_definelabels{mathlabel}{functions}\s!false\relax
+\clf_definelabels{taglabel}{tags}\s!false\relax
+
+%D \macros
+%D {translate}
+%D
+%D Sometimes macros contain language specific words that are to be typeset. Such
+%D macros can be made (more) language independant by using:
+%D
+%D \showsetup{translate}
+%D
+%D like for instance:
+%D
+%D \starttyping
+%D \translate[en=something,nl=iets]
+%D \stoptyping
+%D
+%D which expands to {\em something} or {\em iets}, depending on de current language.
+
+\installcorenamespace{translation}
+
+\permanent\tolerant\protected\def\translate[#1]%
+ {\getparameters[\??translation][#1]%
+ \ifcsname\??translation\currentlanguage\endcsname
+ \lastnamedcs
+ \orelse\ifcsname\??translation\s!en\endcsname
+ \lastnamedcs
+ \else
+ [translation #1]%
+ \fi}
+
+%D When used without argument, the last defined values are used. This enables
+%D repetitive use like
+%D
+%D \starttyping
+%D \en \translate\ means \nl \translate
+%D \stoptyping
+
+%D \macros
+%D {assigntranslation}
+%D
+%D This macro is a system macro, and can be used to assign a translation to a macro.
+%D Its form is:
+%D
+%D \starttyping
+%D \assigntranslation[en=something,nl=iets]\to\command
+%D \stoptyping
+
+% nicer is \edef\command{\translated[...]} ... todo
+
+\permanent\protected\def\assigntranslation[#1]\to#2% bad, this \to
+ {\getparameters[\??translation][#1]%
+ \edef#2{\begincsname\??translation\currentlanguage\endcsname}}
+
+%D \macros
+%D {commalistsentence}
+%D
+%D Redone in \LUA:
+%D
+%D \startbuffer
+%D \commalistsentence[aap,noot,mies]
+%D \commalistsentence[aap,noot]
+%D \commalistsentence[aap]
+%D \commalistsentence[a,b,c]
+%D \commalistsentence[a,b,c][{ \& },{ and }]
+%D \commalistsentence[a,b,c][+,-]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+
+\permanent\tolerant\protected\def\commalistsentence[#1]#*[#2]%
+ {\clf_concatcommalist
+ text {#1}%
+ separators {#2}%
+ separator {\detokenize\expandafter{\normalexpanded{\labeltext{and-1}}}}%
+ last {\detokenize\expandafter{\normalexpanded{\labeltext{and-2}}}}%
+ \relax}
+
+\setuplabeltext [\s!nl] [and-1={{, }}, and-2={{ en }}] % 1, 2 en 3
+\setuplabeltext [\s!en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3
+\setuplabeltext [\s!de] [and-1={{, }}, and-2={{ und }}] % 1, 2 und 3
+\setuplabeltext [\s!hr] [and-1={{, }}, and-2={{ i }}] % 1, 2 i 3
+
+%D Goodie (handy at \LUA\ end):
+
+\permanent\protected\def\LABELTEXT#1{\WORD{\labeltext{#1}}} % only for simple cases!
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-mis.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-mis.mkxl
new file mode 100644
index 00000000000..7b6c9085736
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-mis.mkxl
@@ -0,0 +1,586 @@
+%D \module
+%D [ file=lang-mis,
+%D version=1997.03.20, % used to be supp-lan.tex
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Compounds,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This one will be updated stepwise to \LMTX. See lang-mis.mkiv for previous
+%D implementations and removed code.
+
+\writestatus{loading}{ConTeXt Language Macros / Compounds}
+
+%D More or less replaced.
+
+%D \gdef\starttest#1\stoptest{\starttabulate[|l|l|p|]#1\stoptabulate}
+%D \gdef\test #1{\NC\detokenize{#1}\NC\hyphenatedword{#1}\NC#1\NC\NR}
+
+\unprotect
+
+%D One of \TEX's strong points in building paragraphs is the way hyphenations are
+%D handled. Although for real good hyphenation of non||english languages some
+%D extensions to the program are needed, fairly good results can be reached with the
+%D standard mechanisms and an additional macro, at least in Dutch.
+%D
+%D \CONTEXT\ originates in the wish to typeset educational materials, especially in
+%D a technical environment. In production oriented environments, a lot of compound
+%D words are used. Because the Dutch language poses no limits on combining words, we
+%D often favor putting dashes between those words, because it facilitates reading,
+%D at least for those who are not that accustomed to it.
+%D
+%D In \TEX\ compound words, separated by a hyphen, are not hyphenated at all. In
+%D spite of the multiple pass paragraph typesetting this can lead to parts of words
+%D sticking into the margin. The solution lays in saying \type
+%D {spoelwater||terugwinunit} instead of \type {spoelwater-terugwinunit}. By using a
+%D one character command like \type {|}, delimited by the same character \type {|},
+%D we get ourselves both a decent visualization (in \TEXEDIT\ and colored verbatim
+%D we color these commands yellow) and an efficient way of combining words.
+%D
+%D The sequence \type{||} simply leads to two words connected by a hyphen. Because
+%D we want to distinguish such a hyphen from the one inserted when \TEX\ hyphenates
+%D a word, we use a bit longer one.
+%D
+%D \hyphenation {spoel-wa-ter te-rug-win-unit}
+%D
+%D \starttest
+%D \test {spoelwater||terugwinunit}
+%D \stoptest
+%D
+%D As we already said, the \type{|} is a command. This commands accepts an optional
+%D argument before it's delimiter, which is also a \type{|}.
+%D
+%D \hyphenation {po-ly-meer che-mie}
+%D
+%D \starttest
+%D \test {polymeer|*|chemie}
+%D \stoptest
+%D
+%D Arguments like \type{*} are not interpreted and inserted directly, in contrary to
+%D arguments like:
+%D
+%D \starttest
+%D \test {polymeer|~|chemie}
+%D \test {|(|polymeer|)|chemie}
+%D \test {polymeer|(|chemie|)| }
+%D \stoptest
+%D
+%D Although such situations seldom occur |<|we typeset thousands of pages before we
+%D encountered one that forced us to enhance this mechanism|>| we also have to take
+%D care of comma's.
+%D
+%D \hyphenation {uit-stel-len}
+%D
+%D \starttest
+%D \test {op||, in|| en uitstellen}
+%D \stoptest
+%D
+%D The next special case (concerning quotes) was brought to my attention by Piet
+%D Tutelaers, one of the driving forces behind rebuilding hyphenation patterns for
+%D the dutch language.\footnote{In 1996 the spelling of the dutch language has been
+%D slightly reformed which made this topic actual again.} We'll also take care of
+%D this case.
+%D
+%D \starttest
+%D \test {AOW|'|er}
+%D \test {cd|'|tje}
+%D \test {ex|-|PTT|'|er}
+%D \test {rock|-|'n|-|roller}
+%D \stoptest
+%D
+%D Tobias Burnus pointed out that I should also support something like
+%D
+%D \starttest
+%D \test {well|_|known}
+%D \stoptest
+%D
+%D to stress the compoundness of hyphenated words.
+%D
+%D Of course we also have to take care of the special case:
+%D
+%D \starttest
+%D \test {text||color and ||font}
+%D \stoptest
+
+%D \macros
+%D {installdiscretionaries}
+%D
+%D The mechanism described here is one of the older inner parts of \CONTEXT. The
+%D most recent extensions concerns some special cases as well as the possibility to
+%D install other characters as delimiters. The prefered way of specifying compound
+%D words is using \type{||}, which is installed by:
+%D
+%D \starttyping
+%D \installdiscretionary | -
+%D \stoptyping
+%D
+%D Some alternative definitions are:
+%D
+%D \startbuffer
+%D \installdiscretionary * -
+%D \installdiscretionary + -
+%D \installdiscretionary / -
+%D \installdiscretionary ~ -
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D after which we can say:
+%D
+%D \start \getbuffer
+%D \starttest
+%D \test {test**test**test}
+%D \test {test++test++test}
+%D \test {test//test//test}
+%D \test {test~~test~~test}
+%D \stoptest
+%D \stop
+
+%D \macros
+%D {compoundhyphen}
+%D
+%D Now let's go to the macros. First we define some variables. In the main \CONTEXT\
+%D modules these can be tuned by a setup command. Watch the (maybe) better looking
+%D compound hyphen.
+
+% hm why ex
+
+\ifdefined\compoundhyphen \else
+ \permanent\protected\def\compoundhyphen{\hbox{-\kern-.10775\emwidth-}} % .25\exheight
+\fi
+
+%D The last two variables are needed for subsentences |<|like this one|>| which we
+%D did not yet mention. We want to enable breaking but at the same time don't want
+%D compound characters like |-| or || to be separated from the words. \TEX\ hackers
+%D will recognise the next two macro's:
+
+\ifdefined\prewordbreak \else \permanent\protected\def\prewordbreak {\penalty\plustenthousand\hskip\zeropoint\relax} \fi
+\ifdefined\postwordbreak\else \permanent\protected\def\postwordbreak {\penalty\zerocount \hskip\zeropoint\relax} \fi
+\ifdefined\hspaceamount \else \def\hspaceamount#1#2{.16667\emwidth} \fi % will be overloaded
+
+%frozen\protected\def\permithyphenation{\ifhmode\prewordbreak\fi} % doesn't remove spaces
+\permanent\protected\def\permithyphenation{\ifhmode\wordboundary\fi} % doesn't remove spaces
+
+%D \macros
+%D {beginofsubsentence,endofsubsentence,
+%D beginofsubsentencespacing,endofsubsentencespacing}
+%D
+%D In the previous macros we provided two hooks which can be used to support nested
+%D sub||sentences. In \CONTEXT\ these hooks are used to insert a small space when
+%D needed.
+
+%D The following piece of code is a torture test compound handling. The \type
+%D {\relax} before the \type {\ifmmode} is needed because of the alignment scanner
+%D (in \ETEX\ this problem is not present because there a protected macro is not
+%D expanded. Thanks to Tobias Burnus for providing this example.
+%D
+%D \startformula
+%D \left|f(x_n)-{1\over2}\right| =
+%D {\cases{|{1\over2}-x_n| &for $0\le x_n < {1\over2}$\cr
+%D |x_n-{1\over2}| &for ${1\over2}2xxx
+
+\def\lang_discretionaries_hyphen_like#1#2%
+ {\ifconditional\spaceafterdiscretionary
+ %prewordbreak\hbox{#1}\relax
+ \wordboundary\hbox{#1}\relax
+ \orelse\ifconditional\punctafterdiscretionary
+ %prewordbreak\hbox{#1}\relax
+ \wordboundary\hbox{#1}\relax
+ \else
+ %\prewordbreak#2\postwordbreak % was prewordbreak
+ \wordboundary#2\wordboundary
+ \fi}
+
+\definetextmodediscretionary {}
+ {\lang_discretionaries_hyphen_like\textmodehyphen\textmodehyphendiscretionary}
+
+\definetextmodediscretionary -
+ {\lang_discretionaries_hyphen_like\normalhyphen\normalhyphendiscretionary}
+
+\definetextmodediscretionary _
+ {\lang_discretionaries_hyphen_like\composedhyphen\composedhyphendiscretionary}
+
+\definetextmodediscretionary )
+ {\lang_discretionaries_hyphen_like{)}{\discretionary{-)}{}{)}}}
+
+\definetextmodediscretionary (
+ {\ifdim\lastskip>\zeropoint
+ %(\prewordbreak
+ (\wordboundary
+ \else
+ %\prewordbreak\discretionary{}{(-}{(}\prewordbreak
+ \wordboundary\discretionary{}{(-}{(}\wordboundary
+ %\discretionary options \plusthree{}{(-}{(}%
+ \fi}
+
+\definetextmodediscretionary ~
+ %{\prewordbreak\discretionary{-}{}{\thinspace}\postwordbreak}
+ {\wordboundary\discretionary{-}{}{\thinspace}\wordboundary}
+ %{\discretionary options \plusthree{-}{}{\thinspace}}
+
+\definetextmodediscretionary '
+ %{\prewordbreak\discretionary{-}{}{'}\postwordbreak}
+ {\wordboundary\discretionary{-}{}{'}\wordboundary}
+ %{\discretionary options \plusthree{-}{}{'}}
+
+\definetextmodediscretionary ^
+ %{\prewordbreak\discretionary{\hbox{\normalstartimath|\normalstopimath}}{}{\hbox{\normalstartimath|\normalstopimath}}%
+ % \postwordbreak} % bugged
+ {\wordboundary
+ \discretionary{\hbox{\normalstartimath|\normalstopimath}}{}{\hbox{\normalstartimath|\normalstopimath}}%
+ \wordboundary} % bugged
+ %{\discretionary options \plusthree{\hbox{\normalstartimath|\normalstopimath}}{}{\hbox{\normalstartimath|\normalstopimath}}}
+
+\definetextmodediscretionary <
+ %{\beginofsubsentence\prewordbreak\beginofsubsentencespacing
+ {\beginofsubsentence\wordboundary\beginofsubsentencespacing
+ \aftergroup\ignorespaces} % tricky, we need to go over the \nextnextnext
+
+\definetextmodediscretionary >
+ {\removeunwantedspaces
+ %\endofsubsentencespacing\prewordbreak\endofsubsentence}
+ \endofsubsentencespacing\wordboundary\endofsubsentence}
+
+\definetextmodediscretionary =
+ {\removeunwantedspaces
+ %\prewordbreak\midsentence\prewordbreak
+ \wordboundary\midsentence\wordboundary
+ \aftergroup\ignorespaces}
+
+% french
+
+%definetextmodediscretionary : {\removeunwantedspaces\prewordbreak\kern\hspaceamount\empty{:}:}
+%definetextmodediscretionary ; {\removeunwantedspaces\prewordbreak\kern\hspaceamount\empty{;};}
+%definetextmodediscretionary ? {\removeunwantedspaces\prewordbreak\kern\hspaceamount\empty{?}?}
+%definetextmodediscretionary ! {\removeunwantedspaces\prewordbreak\kern\hspaceamount\empty{!}!}
+
+\definetextmodediscretionary : {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{:}:}
+\definetextmodediscretionary ; {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{;};}
+\definetextmodediscretionary ? {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{?}?}
+\definetextmodediscretionary ! {\removeunwantedspaces\wordboundary\kern\hspaceamount\empty{!}!}
+
+%definetextmodediscretionary * {\prewordbreak\discretionary{-}{}{\kern.05\emwidth}\prewordbreak}
+\definetextmodediscretionary * {\wordboundary\discretionary{-}{}{\kern.05\emwidth}\wordboundary}
+
+% spanish
+
+%definetextmodediscretionary ?? {\prewordbreak\questiondown}
+%definetextmodediscretionary !! {\prewordbreak\exclamdown}
+
+\definetextmodediscretionary ?? {\wordboundary\questiondown}
+\definetextmodediscretionary !! {\wordboundary\exclamdown}
+
+%D \installdiscretionary | +
+%D \installdiscretionary + =
+
+\permanent\protected\def\defaultdiscretionaryhyphen{\compoundhyphen}
+
+\installdiscretionary | \defaultdiscretionaryhyphen % installs in ctx and prt will fall back on it
+
+%D \macros
+%D {fakecompoundhyphen}
+%D
+%D In headers and footers as well as in active pieces of text we need a dirty hack.
+%D Try to imagine what is needed to savely break the next text across a line and at
+%D the same time make the words interactive.
+%D
+%D \starttyping
+%D \goto{Some||Long||Word}
+%D \stoptyping
+
+\permanent\protected\def\fakecompoundhyphen
+ {\enforced\permanent\protected\def\|{\mathortext\vert\lang_compounds_fake_hyphen}}
+
+\def\lang_compounds_fake_hyphen
+ {\enforced\permanent\protected\def##1|%
+ {\doifelsenothing{##1}\compoundhyphen{##1}%
+ \kern\d_lang_discretionaries_breakpoint
+ \allowbreak}}
+
+%D \macros
+%D {midworddiscretionary}
+%D
+%D If needed, one can add a discretionary hyphen using \type
+%D {\midworddiscretionary}. This macro does the same as \PLAIN\ \TEX's \type {\-},
+%D but, like the ones implemented earlier, this one also looks ahead for spaces and
+%D grouping tokens.
+
+\permanent\protected\def\midworddiscretionary
+ {\futurelet\nexttoken\lang_discretionaries_mid_word}
+
+\def\lang_discretionaries_mid_word
+ {\ifx\nexttoken\blankspace\orelse
+ \ifx\nexttoken\bgroup \orelse
+ \ifx\nexttoken\egroup \orelse
+ \discretionary{-}{}{}%
+ \fi}
+
+% \aliased\let\ignorecompoundcharacter\relax
+
+%D \macros
+%D {disablediscretionaries,disablecompoundcharacter}
+%D
+%D Occasionally we need to disable this mechanism. For the moment we assume that
+%D \type {|} is used.
+
+\aliased\let\disablediscretionaries \ignorediscretionaries
+%aliased\let\disablecompoundcharacters\ignorecompoundcharacter
+
+%D \macros
+%D {normalcompound}
+%D
+%D Handy in for instance XML. (Kind of obsolete)
+
+\ifdefined\normalcompound \else \aliased\let\normalcompound=| \fi
+
+%D \macros
+%D {compound}
+%D
+%D We will overload the already active \type {|} so we have to save its meaning in
+%D order to be able to use this handy macro.
+%D
+%D \starttyping
+%D so test\compound{}test can be used instead of test||test
+%D \stoptyping
+
+\bgroup
+
+ \catcode\barasciicode\activecatcode
+
+ \permanent\protected\gdef\compound#1{|#1|}
+
+ \doglobal \appendtoks
+ \enforced\permanent\protected\def|#1|{\ifx#1\empty\empty-\else#1\fi}%
+ \to \everysimplifycommands
+
+\egroup
+
+%D Here we hook some code into the clean up mechanism needed for verbatim data.
+
+\appendtoks
+ %disablecompoundcharacters
+ \disablediscretionaries
+\to \everycleanupfeatures
+
+%D Here:
+%D
+%D \startbuffer
+%D {\red somelongword}{\blue \compounddiscretionary}{\green somelongword}
+%D \stopbuffer
+%D
+%D \typebuffer \blank {\hsize3mm\getbuffer\par} \blank
+
+\permanent\protected\def\compounddiscretionary
+ {\discretionary
+ options \plusthree
+ {\ifnum\prehyphenchar >\zerocount\char\prehyphenchar \fi}%
+ {\ifnum\posthyphenchar>\zerocount\char\posthyphenchar\fi}%
+ {\ifnum\posthyphenchar>\zerocount\char\posthyphenchar\fi}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-rep.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-rep.mkxl
new file mode 100644
index 00000000000..36e48424249
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-rep.mkxl
@@ -0,0 +1,74 @@
+%D \module
+%D [ file=lang-rep,
+%D version=2013.04.28,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Substitution,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D As I needed an example of messing with nodes for the bacho\TEX\ tutorial
+%D I cooked up this. In the end I decided to stick to a simpler example and
+%D just finished this off in case someone really needs it.
+
+\writestatus{loading}{ConTeXt Language Macros / Replacements}
+
+\unprotect
+
+\registerctxluafile{lang-rep}{}
+
+\definesystemattribute[replacements][public,global]
+
+%D \startluacode
+%D
+%D -- todo: other nodes (prelude to more experiments with auto dropped caps)
+%D
+%D languages.replacements.add("basics", {
+%D ["aap"] = "monkey",
+%D ["noot"] = "nut",
+%D ["never"] = "forever",
+%D ["newer"] = "cooler",
+%D ["new"] = "cool",
+%D -- ["special"] = "veryspe{>>>}{<<<}{=}cial",
+%D })
+%D
+%D \stopluacode
+%D
+%D \replaceword[more][this][that]
+%D \replaceword[more][crap][support]
+%D \replaceword[more][---][—]
+%D \replaceword[basics][special][veryspe{>>>}{<<<}{=}cial]
+%D
+%D \starttyping
+%D \start \setreplacements[basics] What the heck, it's now or never, isn't it new? \par \stop
+%D \start \setreplacements[more] Do we --- {\it really} --- need this kind of crap? \par \stop
+%D \start \setreplacements[basics] All kinds of special thingies! \par \stop
+%D \start \setreplacements[basics] \hsize1mm special \par \stop
+%D \stoptyping
+
+\permanent\protected\def\setreplacements[#1]%
+ {\clf_setreplacements{#1}}
+
+\permanent\protected\def\resetreplacements
+ {\c_attr_replacements\attributeunsetvalue}
+
+\permanent\tolerant\protected\def\replaceword[#1]#*[#2]#*[#3]%
+ {\ifarguments\or\or
+ \clf_addreplacementslist{#1}{#2}%
+ \or
+ \clf_addreplacements{#1}{#2}{#3}%
+ \fi}
+
+\appendtoks
+ \resetreplacements
+\to \everyresettypesetting
+
+\appendtoks
+ \resetreplacements
+\to \everyinitializeverbatim
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-spa.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-spa.mkxl
new file mode 100644
index 00000000000..3e4972acbe8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-spa.mkxl
@@ -0,0 +1,74 @@
+%D \module
+%D [ file=lang-spa,
+%D version=2002.04.17,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Spacing,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Language Macros / Spacing}
+
+%D This module was created in the process of enhancing support for French (with the
+%D help of Daniel Flipo).
+%D
+%D This will (or already has) become obsolete!
+
+\unprotect
+
+\definehspace [\s!fr] [quotation] [\flexiblespaceamount{.8}{.3}{.8}]
+\definehspace [\s!fr] [sentence] [\fixedspaceamount{1}]
+
+%definehspace [\s!fr] [quote] [\flexiblespaceamount{.8}{.3}{.8}]
+%definehspace [\s!fr] [speech] [\flexiblespaceamount{.8}{.3}{.8}]
+
+\definehspace [\s!fr] [interquotation] [\zeropoint]
+\definehspace [\s!fr] [intersentence] [\zeropoint]
+
+\definehspace [\string :] [\zeropoint]
+\definehspace [\string ;] [\zeropoint]
+\definehspace [\string !] [\zeropoint]
+\definehspace [\string ?] [\zeropoint]
+
+\definehspace [\s!fr] [\string :] [\spaceamount]
+\definehspace [\s!fr] [\string ;] [.16667em]
+\definehspace [\s!fr] [\string !] [.16667em]
+\definehspace [\s!fr] [\string ?] [.16667em]
+
+%D Alternative discretionary handlers:
+
+%definetextmodediscretionary : {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{:}:}
+%definetextmodediscretionary ; {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{;};}
+%definetextmodediscretionary ? {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{?}?}
+%definetextmodediscretionary ! {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{!}!}
+
+\definetextmodediscretionary : {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{:}:}
+\definetextmodediscretionary ; {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{;};}
+\definetextmodediscretionary ? {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{?}?}
+\definetextmodediscretionary ! {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{!}!}
+
+%D \startbuffer
+%D \mainlanguage[en] \quotation{test \quotation{test} test}\par
+%D \mainlanguage[nl] \quotation{test \quotation{test} test}\par
+%D \mainlanguage[fr] \quotation{test \quotation{test} test}\par
+%D
+%D \mainlanguage[en] \quotation{\quotation{test} test}\par
+%D \mainlanguage[nl] \quotation{\quotation{test} test}\par
+%D \mainlanguage[fr] \quotation{\quotation{test} test}\par
+%D
+%D \mainlanguage[en] |<|test |<|test|>| test|>| \par
+%D \mainlanguage[nl] |<|test |<|test|>| test|>| \par
+%D \mainlanguage[fr] |<|test |<|test|>| test|>| \par
+%D
+%D \mainlanguage[en] |<||<|test|>| test|>| \par
+%D \mainlanguage[nl] |<||<|test|>| test|>| \par
+%D \mainlanguage[fr] |<||<|test|>| test|>| \par
+%D \stopbuffer
+%D
+%D \typebuffer {\getbuffer}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-tra.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-tra.mkxl
new file mode 100644
index 00000000000..b087832e04b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-tra.mkxl
@@ -0,0 +1,95 @@
+%D \module
+%D [ file=lang-tra,
+%D version=2020.10.31,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Transliteration,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Language Macros / Transliteration}
+
+\registerctxluafile{lang-tra}{}
+
+\unprotect
+
+\definesystemattribute[transliteration][public,global]
+
+\installcorenamespace {transliteration}
+
+\permanent\tolerant\protected\def\definetransliteration[#1]#*[#2]%
+ {\clf_definedtransliteration{#1}{#2}}
+
+\permanent\protected\def\settransliteration[#1]%
+ {\clf_settransliteration{#1}}
+
+\permanent\protected\def\starttransliteration[#1]%
+ {\begingroup
+ \clf_settransliteration{#1}}
+
+\permanent\protected\def\stoptransliteration
+ {\endgroup}
+
+\permanent\protected\def\resettransliteration
+ {\c_attr_transliteration\attributeunsetvalue}
+
+\appendtoks
+ \resettransliteration
+\to \everyinitializeverbatim
+
+\protect \endinput
+
+% \setupbodyfont[dejavu]
+%
+% \input lang-tra.mkiv
+%
+% \definetransliteration[serbian][serbian to latin]
+%
+% \starttext
+%
+% \settransliteration[serbian to latin]
+%
+% \startchapter[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \start
+% \settransliteration[serbian to latin]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stop
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stopchapter
+%
+% \resettransliteration
+%
+% \startchapter[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \start
+% \settransliteration[serbian to latin]
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stop
+% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ
+% \stopchapter
+%
+% \definehead[ChapterA][chapter]
+% \definehead[ChapterB][chapter]
+%
+% \startsetups s-to-l
+% \settransliteration[serbian to latin]
+% \red
+% \stopsetups
+%
+% % maybe we need a setups key for this
+% % hm, \definesetups [xxx] [aa,bb,cc]
+%
+% \setuphead[ChapterB][commandbefore=\setups{s-to-l}]
+%
+% \startChapterA[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% \stopChapterA
+%
+% \startChapterB[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}]
+% \stopChapterB
+%
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-url.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-url.mkxl
new file mode 100644
index 00000000000..04a55fcf93f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-url.mkxl
@@ -0,0 +1,167 @@
+%D \module
+%D [ file=lang-url,
+%D version=2008.01.22, % used to be lang-mis
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Language Options,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{lang-url}{}
+
+\unprotect
+
+%D Traditionally this code is in the language namespace as
+%D hyphenation relates to languages.
+
+%D \macros
+%D {hyphenatedurl}
+%D
+%D For those who want to put full \URL's in a text, we offer
+%D
+%D \startbuffer
+%D \hyphenatedurl{http://optimist.optimist/optimist/optimist.optimist#optimist}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D which breaks at the appropriate places. Watch the \type{#}
+%D hack.
+%D
+%D When passed as argument, like in \type {\goto}, one needs
+%D to substitute a \type {\\} for each \type{#}.
+%D
+%D \startbuffer
+%D \hyphenatedurl{http://this.is.a.rather/strange/reference#indeed}
+%D \stopbuffer
+%D
+%D \typebuffer
+
+\newtoks\everyhyphenatedurl
+
+\appendtoks
+ \resetfontfeature
+ \resetcharacterspacing
+ %
+ \enforced\let\&\letterampersand
+ \enforced\let\#\letterhash
+ \enforced\let\~\lettertilde
+ \enforced\let\\\letterbackslash
+ \enforced\let\$\letterdollar
+ \enforced\let\^\letterhat
+ \enforced\let\_\letterunderscore
+ \enforced\let\{\letterleftbrace
+ \enforced\let\}\letterrightbrace
+ \enforced\let\|\letterbar
+ \enforced\let~=\lettertilde
+ \enforced\let|=\letterbar
+ \enforced\let\Ux\eUx
+\to \everyhyphenatedurl
+
+\mutable\let\hyphenatedurlseparator \empty % \periodcentered
+\mutable\let\hyphenatedurldiscretionary\empty
+
+\setnewconstant\hyphenatedurllefthyphenmin \plusthree
+\setnewconstant\hyphenatedurlrighthyphenmin\plusthree
+
+\def\lang_url_more{\penalty\plustenthousand\hskip\scratchskipone\penalty\plustenthousand}
+\def\lang_url_less{\penalty\plustenthousand\hskip\scratchskiptwo\penalty\plustenthousand}
+\def\lang_url_trac{\penalty\plustenthousand\hsmash{\darkred\vl}\penalty\plustenthousand}
+
+\def\lang_url_a#1{\lang_url_more\char#1\lang_url_show\discretionary{}{\hyphenatedurlseparator}{}}
+\def\lang_url_b#1{\lang_url_more\discretionary{\hyphenatedurlseparator}{}{}\lang_url_show\char#1\relax}
+\def\lang_url_d {\lang_url_more\discretionary{\lang_url_show}{\lang_url_show}{\lang_url_show}}
+\def\lang_url_l#1{\lang_url_less\char#1\relax}
+\def\lang_url_c#1{\lang_url_more\char#1\relax}
+\def\lang_url_L#1{\lang_url_less\char#1\relax}
+\def\lang_url_C#1{\lang_url_more\char#1\relax}
+
+\permanent\protected\def\showhyphenatedurlbreaks % for old times sake
+ {\let\lang_url_show\lang_url_trac}
+
+\installtextracker
+ {languages.url}
+ {\let\lang_url_show\lang_url_trac}
+ {\let\lang_url_show\relax}
+
+\let\lang_url_show\relax
+
+\permanent\protected\def\sethyphenatedurlnormal#1{\clf_sethyphenatedurlcharacters{#1}{\v!normal}}
+\permanent\protected\def\sethyphenatedurlbefore#1{\clf_sethyphenatedurlcharacters{#1}{\v!before}}
+\permanent\protected\def\sethyphenatedurlafter #1{\clf_sethyphenatedurlcharacters{#1}{\v!after }}
+
+% \sethyphenatedurlafter{ABCDEF}
+
+\permanent\protected\def\hyphenatedurl#1%
+ {\dontleavehmode
+ \begingroup
+ \the\everyhyphenatedurl
+ \normallanguage\zerocount % \nohyphens in mkiv
+ \scratchskipone\zeropoint\s!plus\dimexpr\emwidth/12\s!minus\dimexpr\emwidth/24\relax % 1.00pt @ 12pt
+ \scratchskiptwo\zeropoint\s!plus\dimexpr\emwidth/48\s!minus\dimexpr\emwidth/96\relax % 0.25pt @ 12pt
+ \unprotect
+ \normalexpanded{\noexpand\clf_hyphenatedurl
+ {\noexpand\detokenize{#1}}%
+ \hyphenatedurllefthyphenmin
+ \hyphenatedurlrighthyphenmin
+ {\hyphenatedurldiscretionary}%
+ }%
+ \protect
+ \endgroup}
+
+%D \macros
+%D {hyphenatedfilename}
+%D
+%D For the moment we treat filenames in a similar way,
+%D
+%D \starttyping
+%D \hyphenatedfilename{here/there/filename.suffix}
+%D \stoptyping
+
+\ifdefined\hyphenatedfilename \else \aliased\let\hyphenatedfilename\hyphenatedurl \fi
+
+% \def\test#1%
+% {\dontleavehmode
+% \begingroup
+% \tttf
+% \hyphenatedurl {%
+% \letterampersand #1\letterampersand #1\letterampersand #1\letterampersand #1\letterampersand
+% \letterhash #1\letterhash #1\letterpercent #1\letterslash #1\letterampersand
+% }%
+% \endgroup}
+
+% \dorecurse{100}{\test{a} \test{ab} \test{abc} \test{abcd} \test{abcde} \test{abcdef}}
+
+\protect \endinput
+
+% \setuppapersize[A7]
+%
+% \protected\def\WhateverA#1%
+% {\dontleavehmode
+% \begingroup
+% \prehyphenchar"B7\relax
+% \setbox\scratchbox\hbox{\tttf#1}%
+% \prehyphenchar`-\relax
+% \unhbox\scratchbox
+% \endgroup}
+%
+% \protected\def\WhateverB#1%
+% {\dontleavehmode
+% \begingroup
+% \tttf
+% \prehyphenchar\minusone
+% % \localrightbox{\llap{_}}%
+% \localrightbox{\llap{\smash{\lower1.5ex\hbox{\char"2192}}}}%
+% \setbox\scratchbox\hbox{#1}%
+% \prehyphenchar`-\relax
+% \unhbox\scratchbox
+% \endgroup}
+%
+% \begingroup \hsize1cm
+% \WhateverA{thisisaboringandverylongcommand}\par
+% \WhateverB{thisisaboringandverylongcommand}\par
+% \endgroup
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lang-wrd.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lang-wrd.mkxl
new file mode 100644
index 00000000000..ba1cfc5710d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lang-wrd.mkxl
@@ -0,0 +1,69 @@
+%D \module
+%D [ file=lang-wrd,
+%D version=2006.XX.XX,
+%D title=\CONTEXT\ Language Macros,
+%D subtitle=Checking,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Experimental.
+
+\writestatus{loading}{ConTeXt Language Macros / Checking}
+
+\registerctxluafile{lang-wrd}{}
+
+\unprotect
+
+% \loadspellchecklist[en][words-en.txt]
+% \loadspellchecklist[us][words-en.txt]
+% \loadspellchecklist[nl][words-nl.txt]
+% \setupspellchecking[state=start,method=1]
+%
+% \setupspellchecking[state=start,method=2]
+% ...
+% \typefile{\jobname.words}
+%
+% beware, maybe some day we will honour grouping
+%
+% 1: spell checking
+% 2: word counting
+% 3: language coloring
+
+\installcorenamespace{spell}
+
+\installdirectcommandhandler \??spell {spellchecking}
+
+\appendtoks
+ \ifcstok{\directspellcheckingparameter\c!state}\v!start
+ \clf_enablespellchecking
+ method {\directspellcheckingparameter\c!method}%
+ list {\directspellcheckingparameter\c!list}%
+ \relax
+ \else
+ \clf_disablespellchecking
+ \fi
+\to \everysetupspellchecking
+
+\permanent\tolerant\protected\def\loadspellchecklist[#1]#*[#2]% can be public implementor
+ {\clf_loadspellchecklist{#1}{#2}}
+
+\setupspellchecking
+ [\c!state=\v!stop,
+ \c!method=1,
+ \c!list=]
+
+\definecolor[word:yes] [g=.75]
+\definecolor[word:no] [r=.75]
+
+%definecolor[word:unset] [s=.75]
+\definecolor[word:en] [b=.75]
+\definecolor[word:de] [r=.75]
+\definecolor[word:nl] [g=.75]
+\definecolor[word:unknown][r=.75,g=.75]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/layo-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/layo-ini.lmt
new file mode 100644
index 00000000000..1570075d9a1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/layo-ini.lmt
@@ -0,0 +1,115 @@
+if not modules then modules = { } end modules ['layo-ini'] = {
+ version = 1.001,
+ comment = "companion to layo-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- We need to share information between the TeX and Lua end about the typographical
+-- model. This happens here. This code might move.
+
+local texgetcount = tex.getcount
+local conditionals = tex.conditionals
+
+layouts = {
+ status = { },
+}
+
+local status = layouts.status
+
+function status.leftorrightpageaction(left,right)
+ if left == nil then
+ left, right = false, true
+ end
+ if not conditionals.layoutisdoublesided then
+ return left, right
+ elseif conditionals.layoutissinglesided then
+ return left, right
+ elseif texgetcount("pagenoshift") % 2 == 0 then
+ if texgetcount("realpageno") % 2 == 0 then
+ return right, left
+ else
+ return left, right
+ end
+ else
+ if texgetcount("realpageno") % 2 == 0 then
+ return left, right
+ else
+ return right, left
+ end
+ end
+end
+
+function status.isleftpage(r)
+ if not conditionals.layoutisdoublesided then
+ return false
+ elseif conditionals.layoutissinglesided then
+ return false
+ elseif texgetcount("pagenoshift") % 2 == 0 then
+ return (r or texgetcount("realpageno")) % 2 == 0
+ else
+ return not (r or texgetcount("realpageno")) % 2 == 0
+ end
+end
+
+-- Instead of making these these driver specific we make them generic. We can even consider
+-- to make these registers at the tex end.
+
+local canvas = {
+ pagespec = "default", -- v_default
+ paperwidth = 0,
+ paperheight = 0,
+ topoffset = 0,
+ leftoffset = 0,
+ height = 0,
+ width = 0,
+ cropoffset = 0,
+ bleedoffset = 0,
+ trimoffset = 0,
+ artoffset = 0,
+ doublesided = false,
+ marked = false,
+ copies = false,
+}
+
+function layouts.setupcanvas(specification)
+ local paperheight = specification.paperheight or canvas.paperheight
+ local paperwidth = specification.paperwidth or canvas.paperwidth
+ local cropoffset = specification.cropoffset or 0
+ local trimoffset = cropoffset - (specification.trimoffset or 0)
+ local bleedoffset = trimoffset - (specification.bleedoffset or 0)
+ local artoffset = bleedoffset - (specification.artoffset or 0)
+ --
+ canvas.paperheight = paperheight
+ canvas.paperwidth = paperwidth
+ canvas.cropoffset = cropoffset
+ canvas.trimoffset = trimoffset
+ canvas.bleedoffset = bleedoffset
+ canvas.artoffset = artoffset
+ --
+ canvas.pagespec = specification.mode or pagespec
+ canvas.topoffset = specification.topoffset or 0
+ canvas.leftoffset = specification.leftoffset or 0
+ canvas.height = specification.height or paperheight
+ canvas.width = specification.width or paperwidth
+ canvas.marked = specification.print
+ --
+ local copies = specification.copies
+ if type(copies) == "number" and copies < 2 then
+ canvas.copies = false
+ end
+ --
+ local doublesided = specification.doublesided
+ if doublesided ~= nil then
+ canvas.doublesided = doublesided
+ end
+end
+
+function layouts.getpagedimensions()
+ return canvas.paperwidth, canvas.paperheight
+end
+
+function layouts.getcanvas()
+ return canvas
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/layo-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/layo-ini.mkxl
new file mode 100644
index 00000000000..73b7e978e16
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/layo-ini.mkxl
@@ -0,0 +1,30 @@
+%D \module
+%D [ file=layo-ini,
+%D version=2011.02.18,
+%D title=\CONTEXT\ Layout Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Layout Macros / Initialization}
+
+%D This module deals with the basic variables etc. for layout and code from other
+%D modules will move here. This will make the dependencies somewhat cleaner.
+
+\unprotect
+
+%D We need to check this in case a smaller format is loaded.
+
+\ifdefined\layoutisdoublesided \else \newconditional\layoutisdoublesided \fi
+\ifdefined\layoutissinglesided \else \newconditional\layoutissinglesided \fi
+\ifdefined\pagenoshift \else \newcount \pagenoshift \fi
+\ifdefined\realpageno \else \newcount \realpageno \fi
+
+\registerctxluafile{layo-ini}{autosuffix}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-curl.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-curl.lmt
new file mode 100644
index 00000000000..b307397948c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-curl.lmt
@@ -0,0 +1,296 @@
+if not modules then modules = { } end modules ['libs-imp-curl'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/curl/libcurl.dll
+
+local libname = "curl"
+local libfile = "libcurl"
+
+local curllib = resolvers.libraries.validoptional(libname)
+
+if not curllib then return end
+
+-- We're good, so we continue.
+
+local next, type = next, type
+local lower, gsub = string.lower, string.gsub
+
+local mapping = {
+ ["acceptencoding"] = 102,
+ ["accepttimeoutms"] = 212,
+ ["addressscope"] = 171,
+ ["append"] = 50,
+ ["autoreferer"] = 58,
+ ["buffersize"] = 98,
+ ["cainfo"] = 65,
+ ["capath"] = 97,
+ ["certinfo"] = 172,
+ -- ["chunkbgnfunction"] = 198,
+ ["chunkdata"] = 201,
+ -- ["chunkendfunction"] = 199,
+ ["closepolicy"] = 72,
+ ["closesocketdata"] = 209,
+ -- ["closesocketfunction"] = 208,
+ ["connectonly"] = 141,
+ ["connecttimeout"] = 78,
+ ["connecttimeoutms"] = 156,
+ -- ["convfromnetworkfunction"] = 142,
+ -- ["convfromutf8function"] = 144,
+ -- ["convtonetworkfunction"] = 143,
+ ["cookie"] = 22,
+ ["cookiefile"] = 31,
+ ["cookiejar"] = 82,
+ ["cookielist"] = 135,
+ ["cookiesessionv"] = 96,
+ ["copypostfields"] = 165,
+ ["crlf"] = 27,
+ ["crlfile"] = 169,
+ ["customrequest"] = 36,
+ ["debugdata"] = 95,
+ -- ["debugfunction"] = 94,
+ ["dirlistonly"] = 48,
+ ["dnscachetimeout"] = 92,
+ ["dnsinterface"] = 221,
+ ["dnslocalip4"] = 222,
+ ["dnslocalip6"] = 223,
+ ["dnsservers"] = 211,
+ ["dnsuseglobalcache"] = 91,
+ ["egdsocket"] = 77,
+ ["errorbuffer"] = 10,
+ ["expect100timeoutms"] = 227,
+ ["failonerror"] = 45,
+ ["file"] = 1,
+ ["filetime"] = 69,
+ ["fnmatchdata"] = 202,
+ -- ["fnmatchfunction"] = 200,
+ ["followlocation"] = 52,
+ ["forbidreuse"] = 75,
+ ["freshconnect"] = 74,
+ ["ftpaccount"] = 134,
+ ["ftpalternativetouser"] = 147,
+ ["ftpcreatemissingdirs"] = 110,
+ ["ftpfilemethod"] = 138,
+ ["ftpresponsetimeout"] = 112,
+ ["ftpskippasvip"] = 137,
+ ["ftpsslccc"] = 154,
+ ["ftpuseeprt"] = 106,
+ ["ftpuseepsv"] = 85,
+ ["ftpusepret"] = 188,
+ ["ftpport"] = 17,
+ ["ftpsslauth"] = 129,
+ ["gssapidelegation"] = 210,
+ ["header"] = 42,
+ ["headerdata"] = 29,
+ -- ["headerfunction"] = 79,
+ ["http200aliases"] = 104,
+ ["httpcontentdecoding"] = 158,
+ ["httptransferdecoding"] = 157,
+ ["httpversion"] = 84,
+ ["httpauth"] = 107,
+ ["httpget"] = 80,
+ ["httpheader"] = 23,
+ ["httppost"] = 24,
+ ["httpproxytunnel"] = 61,
+ ["ignorecontentlength"] = 136,
+ ["infile"] = 9,
+ ["infilesize"] = 14,
+ ["infilesizelarge"] = 115,
+ ["interface"] = 62,
+ ["interleavedata"] = 195,
+ -- ["interleavefunction"] = 196,
+ ["ioctldata"] = 131,
+ -- ["ioctlfunction"] = 130,
+ ["ipresolve"] = 113,
+ ["issuercert"] = 170,
+ ["keypasswd"] = 26,
+ ["krblevel"] = 63,
+ ["localport"] = 139,
+ ["localportrange"] = 140,
+ ["loginoptions"] = 224,
+ ["lowspeedlimit"] = 19,
+ ["lowspeedtime"] = 20,
+ ["mailauth"] = 217,
+ ["mailfrom"] = 186,
+ ["mailrcpt"] = 187,
+ ["maxrecvspeedlarge"] = 146,
+ ["maxsendspeedlarge"] = 145,
+ ["maxconnects"] = 71,
+ ["maxfilesize"] = 114,
+ ["maxfilesizelarge"] = 117,
+ ["maxredirs"] = 68,
+ ["netrc"] = 51,
+ ["netrcfile"] = 118,
+ ["newdirectoryperms"] = 160,
+ ["newfileperms"] = 159,
+ ["nobody"] = 44,
+ ["noprogress"] = 43,
+ ["noproxy"] = 177,
+ ["nosignal"] = 99,
+ ["opensocketdata"] = 164,
+ -- ["opensocketfunction"] = 163,
+ ["password"] = 174,
+ ["port"] = 3,
+ ["post"] = 47,
+ -- ["postfields"] = 15,
+ -- ["postfieldsize"] = 60,
+ -- ["postfieldsizelarge"] = 120,
+ ["postquote"] = 39,
+ ["postredir"] = 161,
+ ["prequote"] = 93,
+ ["private"] = 103,
+ ["progressdata"] = 57,
+ -- ["progressfunction"] = 56,
+ ["protocols"] = 181,
+ ["proxy"] = 4,
+ ["proxytransfermode"] = 166,
+ ["proxyauth"] = 111,
+ ["proxypassword"] = 176,
+ ["proxyport"] = 59,
+ ["proxytype"] = 101,
+ ["proxyusername"] = 175,
+ ["proxyuserpwd"] = 6,
+ ["put"] = 54,
+ ["quote"] = 28,
+ ["randomfile"] = 76,
+ ["range"] = 7,
+ ["readdata"] = 9,
+ -- ["readfunction"] = 12,
+ ["redirprotocols"] = 182,
+ ["referer"] = 16,
+ ["resolve"] = 203,
+ ["resumefrom"] = 21,
+ ["resumefromlarge"] = 116,
+ ["rtspclientcseq"] = 193,
+ ["rtsprequest"] = 189,
+ ["rtspservercseq"] = 194,
+ ["rtspsessionid"] = 190,
+ ["rtspstreamuri"] = 191,
+ ["rtsptransport"] = 192,
+ ["rtspheader"] = 23,
+ ["saslir"] = 218,
+ ["seekdata"] = 168,
+ -- ["seekfunction"] = 167,
+ ["serverresponsetimeout"] = 112,
+ ["share"] = 100,
+ ["sockoptdata"] = 149,
+ -- ["sockoptfunction"] = 148,
+ ["socks5gssapinec"] = 180,
+ ["socks5gssapiservice"] = 179,
+ ["sshauthtypes"] = 151,
+ ["sshhostpublickeymd5"] = 162,
+ ["sshkeydata"] = 185,
+ -- ["sshkeyfunction"] = 184,
+ ["sshknownhosts"] = 183,
+ ["sshprivatekeyfile"] = 153,
+ ["sshpublickeyfile"] = 152,
+ ["sslcipherlist"] = 83,
+ ["sslctxdata"] = 109,
+ -- ["sslctxfunction"] = 108,
+ ["sslenablealpn"] = 226,
+ ["sslenablenpn"] = 225,
+ ["ssloptions"] = 216,
+ ["sslsessionidcache"] = 150,
+ ["sslverifyhost"] = 81,
+ ["sslverifypeer"] = 64,
+ ["sslcert"] = 25,
+ ["sslcerttype"] = 86,
+ ["sslengine"] = 89,
+ ["sslenginedefault"] = 90,
+ ["sslkey"] = 87,
+ ["sslkeytype"] = 88,
+ ["sslversion"] = 32,
+ ["stderr"] = 37,
+ ["tcpkeepalive"] = 213,
+ ["tcpkeepidle"] = 214,
+ ["tcpkeepintvl"] = 215,
+ ["tcpnodelay"] = 121,
+ ["telnetoptions"] = 70,
+ ["tftpblksize"] = 178,
+ ["timecondition"] = 33,
+ ["timeout"] = 13,
+ ["timeoutms"] = 155,
+ ["timevalue"] = 34,
+ ["tlsauthpassword"] = 205,
+ ["tlsauthtype"] = 206,
+ ["tlsauthusername"] = 204,
+ ["transferencoding"] = 207,
+ ["transfertext"] = 53,
+ ["unrestrictedauth"] = 105,
+ ["upload"] = 46,
+ ["url"] = 2,
+ ["usessl"] = 119,
+ ["useragent"] = 18,
+ ["username"] = 173,
+ ["userpwd"] = 5,
+ ["verbose"] = 41,
+ ["wildcardmatch"] = 197,
+ ["writedata"] = 1,
+ -- ["writefunction"] = 11,
+ ["writeheader"] = 29,
+ ["writeinfo"] = 40,
+ ["xferinfodata"] = 57,
+ -- ["xferinfofunction"] = 219,
+ ["xoauth2bearer"] = 220,
+}
+
+table.setmetatableindex(mapping,function(t,k)
+ local s = gsub(lower(k),"[^a-z0-9]","")
+ local v = rawget(t,s) or false
+ t[k] = v
+ return v
+end)
+
+local curl_fetch = curllib.fetch
+local curl_escape = curllib.escape
+local curl_unescape = curllib.unescape
+local curl_getversion = curllib.getversion
+
+local report = logs.reporter(libname)
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local function fetch(options)
+ if okay() then
+ local t = type(options)
+ if t == "table" then
+ local o = { }
+ for name, value in next, options do
+ local index = mapping[name]
+ if index then
+ o[index] = value
+ end
+ end
+ return curl_fetch(o)
+ elseif t == "string" then
+ return curl_fetch { [mapping.url] = options }
+ else
+ report("invalid argument")
+ end
+ end
+end
+
+local curl = {
+ getversion = function () return okay() and curl_getversion() end,
+ escape = function (s) return okay() and curl_escape (s) end,
+ unescape = function (s) return okay() and curl_unescape (s) end,
+ fetch = fetch,
+}
+
+-- inspect(curl.fetch("http://www.pragma-ade.com/index.html"))
+-- inspect(curl.fetch { url = "http://www.pragma-ade.com/index.html" })
+
+package.loaded[libname] = curl
+
+return curl
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-ghostscript.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-ghostscript.lmt
new file mode 100644
index 00000000000..b129a58c143
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-ghostscript.lmt
@@ -0,0 +1,111 @@
+if not modules then modules = { } end modules ['libs-imp-ghostscript'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local libname = "ghostscript"
+local libfile = "gsdll64" -- what on unix?
+
+local gslib = resolvers.libraries.validoptional(libname)
+
+if not gslib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local insert = table.insert
+local formatters = string.formatters
+
+local ghostscript = utilities.ghostscript or { }
+utilities.ghostscript = ghostscript
+
+local gs_execute = gslib.execute
+local nofruns = 0
+local report = logs.reporter(libname)
+
+function ghostscript.convert(specification)
+ if okay() then
+ --
+ nofruns = nofruns + 1
+ statistics.starttiming(ghostscript)
+ --
+ local inputname = specification.inputname
+ if not inputname or inputname == "" then
+ report("invalid run %s, no inputname specified",nofruns)
+ statistics.stoptiming(ghostscript)
+ return false
+ end
+ local outputname = specification.outputname
+ if not outputname or outputname == "" then
+ outputname = file.replacesuffix(inputname,"pdf")
+ end
+ --
+ if not lfs.isfile(inputname) then
+ report("invalid run %s, input file %a is not found",nofruns,inputname)
+ statistics.stoptiming(ghostscript)
+ return false
+ end
+ --
+ local device = specification.device
+ if not device or device == "" then
+ device = "pdfwrite"
+ end
+ --
+ local code = specification.code
+ if not code or code == "" then
+ code = ".setpdfwrite"
+ end
+ --
+ local options = specification.options or { }
+ --
+ insert(options,"-dNOPAUSE")
+ insert(options,"-dBATCH")
+ insert(options,"-dSAFER")
+ insert(options,formatters["-sDEVICE=%s"](device))
+ insert(options,formatters["-sOutputFile=%s"](outputname))
+ insert(options,"-c")
+ insert(options,code)
+ insert(options,"-f")
+ insert(options,inputname)
+ --
+ report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname)
+ report("")
+ local done = gslib_execute(options)
+ report("")
+ --
+ statistics.stoptiming(ghostscript)
+ if done then
+ return outputname
+ else
+ report("run %s quit with errors",nofruns)
+ return false
+ end
+ end
+end
+
+function ghostscript.statistics(report)
+ local runtime = statistics.elapsedtime(ghostscript)
+ if report then
+ report("nofruns %s, runtime %s",nofruns,runtime)
+ else
+ return {
+ runtime = runtime,
+ nofruns = nofruns,
+ }
+ end
+end
+
+-- for i=1,100 do
+-- ghostscript.convert { inputname = "temp.eps" }
+-- ghostscript.convert { inputname = "t:/escrito/tiger.eps" }
+-- end
+-- ghostscript.statistics(true)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
new file mode 100644
index 00000000000..6f5d1d967fd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
@@ -0,0 +1,77 @@
+if not modules then modules = { } end modules ['libs-imp-graphicsmagick'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local libname = "graphicsmagick"
+local libfile = { "CORE_RL_magick_", "CORE_RL_wand_" }
+
+local gmlib = resolvers.libraries.validoptional(libname)
+
+if not gmlib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local graphicsmagick = utilities.graphicsmagick or { }
+utilities.graphicsmagick = graphicsmagick
+utilities.graphicmagick = graphicsmagick
+
+local gm_execute = gmlib.execute
+local nofruns = 0
+local report = logs.reporter(libname)
+
+function graphicsmagick.convert(specification)
+ if okay() then
+ --
+ nofruns = nofruns + 1
+ statistics.starttiming(graphicsmagick)
+ --
+ local inputname = specification.inputname
+ if not inputname or inputname == "" then
+ report("invalid run %s, no inputname specified",nofruns)
+ statistics.stoptiming(graphicsmagick)
+ return false
+ end
+ local outputname = specification.outputname
+ if not outputname or outputname == "" then
+ outputname = file.replacesuffix(inputname,"pdf")
+ end
+ --
+ if not lfs.isfile(inputname) then
+ report("invalid run %s, input file %a is not found",nofruns,inputname)
+ statistics.stoptiming(graphicsmagick)
+ return false
+ end
+ --
+ report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname)
+ --
+ gm_execute { inputfile = inputname, outputfile = outputname }
+ --
+ statistics.stoptiming(graphicsmagick)
+ end
+end
+
+function graphicsmagick.statistics(report)
+ local runtime = statistics.elapsedtime(graphicsmagick)
+ if report then
+ report("nofruns %s, runtime %s",nofruns,runtime)
+ else
+ return {
+ runtime = runtime,
+ nofruns = nofruns,
+ }
+ end
+end
+
+-- graphicsmagick.convert { inputname = "t:/sources/hacker.jpg", outputname = "e:/tmp/hacker.png" }
+-- graphicsmagick.statistics(true)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt
new file mode 100644
index 00000000000..f8e4a990715
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt
@@ -0,0 +1,58 @@
+if not modules then modules = { } end modules ['libs-imp-kpse'] = {
+ version = 1.001,
+ comment = "companion to luat-imp-kpse.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is an experiment. It might make sense to have this available in case I want
+-- more runners to use LuaMetaTeX in which case (as with mtxrun using LuaTeX) we
+-- need to load kpse.
+
+local libname = "kpse"
+local libfile = (os.platform == "win64" and "kpathsea*w64")
+ or (os.platform == "win32" and "kpathsea*w32")
+ or "libkpathsea"
+local libkpse = resolvers.libraries.validoptional(libname)
+
+if package.loaded[libname] then
+ return package.loaded[libname]
+end
+
+-- This is a variant that loaded directly:
+
+-- kpse = libkpse -- the library will issue warnings anyway
+--
+-- resolvers.libraries.optionalloaded(libname,libfile) -- no need to chedk if true
+
+-- This variant delays loading and has a bit more protection:
+
+local function okay()
+ if libkpse and resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local kpse = { }
+
+for k, v in next, libkpse do
+ kpse[k] = function(...) if okay() then return v(...) end end
+end
+
+-- We properly register the module:
+
+package.loaded[libname] = kpse
+
+optional.loaded.kpse = kpse
+
+-- A simple test:
+
+-- kpse.set_program_name("pdftex")
+-- print("find file:",kpse.find_file("oeps.tex"))
+-- print("find file:",kpse.find_file("context.mkii"))
+
+return kpse
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.mkxl b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.mkxl
new file mode 100644
index 00000000000..f76c9902904
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.mkxl
@@ -0,0 +1,38 @@
+%D \module
+%D [ file=libs-imp-kpse,
+%D version=2020.05.19,
+%D title=\CONTEXT\ System Modules,
+%D subtitle=KPSE File Searching,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is not really a module. It's more some left over from an experiment. Who
+%D know when it comes in handy; probably never in a real run, but I might want to
+%D make a \LUAMETATEX\ plain format one day, just for the fun of it.
+
+% \registerctxluafile{libs-imp-kpse}{autosuffix}
+
+\continueifinputfile{libs-imp-kpse.mkxl}
+
+\starttext
+
+\startTEXpage
+ \startluacode
+ local kpse = require("libs-imp-kpse")
+
+ kpse.set_program_name("pdftex")
+
+ local name = "context.mkii"
+
+ context("%s: %s",name,kpse.find_file(name))
+ \stopluacode
+\stopTEXpage
+
+\stoptext
+
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mujs.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mujs.lmt
new file mode 100644
index 00000000000..264c8e53126
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mujs.lmt
@@ -0,0 +1,126 @@
+if not modules then modules = { } end modules ['libs-imp-mujs'] = {
+ version = 1.001,
+ comment = "companion to luat-imp-mujs.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is an experiment. When a new user knows \JAVASCRIPT\ it can be a
+-- stepping stone to using \LUA.
+
+-- local ecmascript = optional.mujs.initialize("libmujs")
+-- local execute = optional.mujs.execute
+
+local libname = "mujs"
+local libfile = "libmujs"
+
+if package.loaded[libname] then
+ return package.loaded[libname]
+end
+
+local mujslib = resolvers.libraries.validoptional(libname)
+
+if not mujslib then
+ return
+end
+
+local files = { }
+local openfile = io.open
+local findfile = resolvers.findfile
+
+local mujs_execute = mujslib.execute
+local mujs_dofile = mujslib.dofile
+local mujs_reset = mujslib.reset
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ mujs_execute(
+ "var catcodes = { " ..
+ "'tex': " .. tex.texcatcodes .. "," ..
+ "'ctx': " .. tex.ctxcatcodes .. "," ..
+ "'prt': " .. tex.prtcatcodes .. "," ..
+ "'vrb': " .. tex.vrbcatcodes .. "," ..
+ "};"
+ )
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+mujslib.setfindfile(findfile)
+
+mujslib.setopenfile(function(name)
+ local full = findfile(name)
+ if full then
+ local f = openfile(full,"rb")
+ if f then
+ for i=1,100 do
+ if not files[i] then
+ files[i] = f
+ return i
+ end
+ end
+ end
+ end
+end)
+
+mujslib.setclosefile(function(id)
+ local f = files[id]
+ if f then
+ f:close()
+ files[id] = false
+ end
+end)
+
+mujslib.setreadfile(function(id,how)
+ local f = files[id]
+ if f then
+ return (f:read(how or "*l"))
+ end
+end)
+
+mujslib.setseekfile(function(id,whence,offset)
+ local f = files[id]
+ if f then
+ return (f:seek(whence,offset))
+ end
+end)
+
+local reporters = {
+ console = logs.reporter("mujs","console"),
+ report = logs.reporter("mujs","report"),
+}
+
+mujslib.setconsole(function(category,name)
+ reporters[category](name)
+end)
+
+local mujs = {
+ ["execute"] = function(c,s) if okay() then mujs_execute(c,s) end end,
+ ["dofile"] = function(n) if okay() then mujs_dofile(n) end end,
+ ["reset"] = function(n) if okay() then mujs_reset(n) end end,
+}
+
+package.loaded[libname] = mujs
+
+optional.loaded.mujs = mujs
+
+interfaces.implement {
+ name = "ecmacode",
+ actions = mujs.execute,
+ arguments = "string",
+ public = true,
+}
+
+interfaces.implement {
+ name = "ecmafile",
+ actions = mujs.dofile,
+ arguments = "string",
+ public = true,
+ protected = true,
+}
+
+return mujs
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mujs.mkxl b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mujs.mkxl
new file mode 100644
index 00000000000..a8fe5801f39
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mujs.mkxl
@@ -0,0 +1,121 @@
+%D \module
+%D [ file=libs-imp-mujs,
+%D version=2020.02.08,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=MuJS interpreter,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Just an experiment:
+%D
+%D \starttyping
+%D http://mujs.com
+%D \stoptyping
+
+\ifdefined\ecmacode
+ \expandafter \endinput
+\fi
+
+\registerctxluafile{libs-imp-mujs}{autosuffix}
+
+\unprotect
+
+% todo: environment
+
+\let\stopecmacode\relax
+
+\protected\def\startecmacode % \stopecmacode
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \luat_start_ecma_code_indeed}
+
+\def\luat_start_ecma_code_indeed#1\stopecmacode
+ {\normalexpanded{\endgroup\noexpand\ecmacode{#1}}}
+
+\protect
+
+\continueifinputfile{libs-imp-mujs.mkxl}
+
+\usemodule[article-basic,abbreviations-logos]
+
+\starttext
+
+\startbuffer
+\startluacode
+ local mujs = require("libs-imp-mujs")
+
+ mujs.execute [[
+ var MyMax = 1000;
+ ]]
+
+ mujs.execute [[
+ console("Example One!");
+ texsprint("\\startpacked");
+ for (var i = 1; i <= MyMax; i = i + 1) {
+ texprint(
+ "This is a buildbot compilation challenge for Mojca: "
+ .concat(Math.sqrt(i/MyMax))
+ .concat("!\\par")
+ );
+ }
+ texsprint("\\stoppacked");
+ ]]
+
+ -- mujs.execute [[
+ -- something very bad: an error
+ -- ]]
+\stopluacode
+
+\startecmacode
+ console("Example Two!");
+ for (var i = 1; i <= MyMax; i = i + 1) {
+ texsprint(
+ "And an opportunity for Alan to attract highschool students to \\TeX: "
+ .concat(i)
+ .concat("! ")
+ );
+ }
+\stopecmacode
+
+\ecmacode {
+ console("Example Three!");
+ texprint("And otherwise a way to prototype \\JAVASCRIPT\\ code in \\PDF.")
+}
+
+\startecmacode
+ var f = File("libs-imp-mujs.mkxl","r");
+ console(f);
+ // var l = f.read(400);
+ var l = f.read("*a");
+ console(l);
+ f.close();
+\stopecmacode
+
+\startecmacode
+ console("Example Four!");
+ texsprint("\\startMPcode "
+ .concat(' fill fullcircle scaled 6cm withcolor "darkred";')
+ .concat(' fill fullcircle scaled 4cm withcolor "darkgreen";')
+ .concat(' fill fullcircle scaled 2cm withcolor "darkblue";')
+ .concat("\\stopMPcode ")
+ );
+\stopecmacode
+
+\startluacode
+ context.startMPcode()
+ context('fill fullcircle scaled 6cm withcolor "middlecyan";')
+ context('fill fullcircle scaled 4cm withcolor "middlemagenta";')
+ context('fill fullcircle scaled 2cm withcolor "middleyellow";')
+ context.stopMPcode()
+\stopluacode
+\stopbuffer
+
+\typebuffer \page \getbuffer
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mysql.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mysql.lmt
new file mode 100644
index 00000000000..3e938a6de48
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-mysql.lmt
@@ -0,0 +1,220 @@
+if not modules then modules = { } end modules ['libs-imp-mysql'] = {
+ version = 1.001,
+ comment = "companion to util-sql.lua",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/mysql/libmysql.dll
+
+local libname = "mysql"
+local libfile = "libmysql"
+
+local mysqllib = resolvers.libraries.validoptional(libname)
+
+if not mysqllib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local lpegmatch = lpeg.match
+local setmetatable = setmetatable
+
+local sql = utilities.sql or require("util-sql")
+local report = logs.reporter(libname)
+
+local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
+local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
+
+local mysql_open = mysqllib.open
+local mysql_close = mysqllib.close
+local mysql_execute = mysqllib.execute
+local mysql_getmessage = mysqllib.getmessage
+
+local helpers = sql.helpers
+local methods = sql.methods
+local validspecification = helpers.validspecification
+local preparetemplate = helpers.preparetemplate
+local querysplitter = helpers.querysplitter
+local cache = { }
+local timeout -- = 3600 -- to be tested
+
+local function connect(specification)
+ local db = mysql_open(
+ specification.database or "",
+ specification.username or "",
+ specification.password or "",
+ specification.host or "",
+ specification.port
+ )
+ if db and timeout then
+ mysql_execute(db,formatters["SET SESSION connect_timeout=%s ;"](timeout))
+ end
+ return db
+end
+
+local function execute_once(specification,retry)
+ if okay() then
+ if trace_sql then
+ report("executing mysql")
+ end
+ if not validspecification(specification) then
+ report("error in specification")
+ end
+ local query = preparetemplate(specification)
+ if not query then
+ report("error in preparation")
+ return
+ else
+ query = lpegmatch(querysplitter,query)
+ end
+ local base = specification.database -- or specification.presets and specification.presets.database
+ if not base then
+ report("no database specified")
+ return
+ end
+ local result = { }
+ local keys = { }
+ local id = specification.id
+ local db = nil
+ if id then
+ local session = cache[id]
+ if session then
+ db = session.db
+ else
+ db = connect(specification)
+ if not db then
+ report("no session database specified")
+ else
+ cache[id] = {
+ specification = specification,
+ db = db,
+ }
+ end
+ end
+ else
+ db = connect(specification)
+ end
+ if not db then
+ report("no database opened")
+ else
+ local converter = specification.converter
+ local nofrows = 0
+ local callback = nil
+ if converter then
+ local convert = converter.mysql
+ callback = function(nofcolumns,values,fields)
+ nofrows = nofrows + 1
+ result[nofrows] = convert(values)
+ end
+ else
+ callback = function(nofcolumns,values,fields)
+ local column = { }
+ for i=1,nofcolumns do
+ local field
+ if fields then
+ field = fields[i]
+ keys[i] = field
+ else
+ field = keys[i]
+ end
+ if field then
+ column[field] = values[i]
+ end
+ end
+ nofrows = nofrows + 1
+ result[nofrows] = column
+ end
+ end
+ for i=1,#query do
+ local okay = mysql_execute(db,query[i],callback)
+ if not okay then
+ if id and retry and i == 1 then
+ report("error: %s, retrying to connect",mysql_getmessage(db))
+ mysql_close(db)
+ cache[id] = nil
+ return execute_once(specification,false)
+ else
+ report("error: %s",mysql_getmessage(db))
+ end
+ end
+ end
+ end
+ if db and not id then
+ mysql_close(db)
+ end
+ -- bonus
+ local one = result[1]
+ if one then
+ setmetatable(result,{ __index = one } )
+ end
+ --
+ return result, keys
+ else
+ report("error: ","no library loaded")
+ end
+end
+
+local function execute(specification)
+ return execute_once(specification,true)
+end
+
+-- Here we build the dataset stepwise so we don't use the data hack that
+-- is used in the client variant.
+
+local wraptemplate = [[
+local converters = utilities.sql.converters
+local deserialize = utilities.sql.deserialize
+
+local tostring = tostring
+local tonumber = tonumber
+local booleanstring = string.booleanstring
+
+%s
+
+return function(cells)
+ -- %s (not needed)
+ -- %s (not needed)
+ return {
+ %s
+ }
+end
+]]
+
+-- return function(result)
+-- if not result then
+-- return { }
+-- end
+-- local nofrows = #result
+-- if nofrows == 0 then
+-- return { }
+-- end
+-- local target = { } -- no %s needed here
+-- for i=1,nofrows do
+-- target[%s] = {
+-- %s
+-- }
+-- end
+-- return result
+-- end
+
+local celltemplate = "cells[%s]"
+
+methods.mysql = {
+ execute = execute,
+ usesfiles = false,
+ wraptemplate = wraptemplate,
+ celltemplate = celltemplate,
+}
+
+package.loaded["util-sql-imp-ffi"] = methods.mysql
+package.loaded["util-sql-imp-mysql"] = methods.mysql
+package.loaded["util-sql-imp-library"] = methods.mysql
+package.loaded[libname] = methods.mysql
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-postgress.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-postgress.lmt
new file mode 100644
index 00000000000..629079b01a5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-postgress.lmt
@@ -0,0 +1,200 @@
+if not modules then modules = { } end modules ['libs-imp-postgress'] = {
+ version = 1.001,
+ comment = "companion to util-sql.lua",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Not yet untested !
+
+-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/postgress/libpq.dll
+
+-- we can now share the code between mysql, postgress, sqlite ... todo
+
+local libname = "postgress"
+local libfile = "libpq"
+
+local postgresslib = resolvers.libraries.validoptional(libname)
+
+if not postgresslib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local lpegmatch = lpeg.match
+local setmetatable = setmetatable
+
+local sql = utilities.sql or require("util-sql")
+local report = logs.reporter(libname)
+
+local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
+local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
+
+local postgress_open = postgresslib.open
+local postgress_close = postgresslib.close
+local postgress_execute = postgresslib.execute
+local postgress_getmessage = postgresslib.getmessage
+
+local helpers = sql.helpers
+local methods = sql.methods
+local validspecification = helpers.validspecification
+local preparetemplate = helpers.preparetemplate
+local querysplitter = helpers.querysplitter -- not needed
+local cache = { }
+
+local function connect(specification)
+ return postgress_open(
+ specification.database or "",
+ specification.username or "",
+ specification.password or "",
+ specification.host or "",
+ specification.port
+ )
+end
+
+local function execute_once(specification,retry)
+ if okay() then
+ if trace_sql then
+ report("executing postgress")
+ end
+ if not validspecification(specification) then
+ report("error in specification")
+ end
+ local query = preparetemplate(specification)
+ if not query then
+ report("error in preparation")
+ return
+ else
+ query = lpegmatch(querysplitter,query) -- not needed
+ end
+ local base = specification.database -- or specification.presets and specification.presets.database
+ if not base then
+ report("no database specified")
+ return
+ end
+ local result = { }
+ local keys = { }
+ local id = specification.id
+ local db = nil
+ if id then
+ local session = cache[id]
+ if session then
+ db = session.db
+ else
+ db = connect(specification)
+ if not db then
+ report("no session database specified")
+ else
+ cache[id] = {
+ specification = specification,
+ db = db,
+ }
+ end
+ end
+ else
+ db = connect(specification)
+ end
+ if not db then
+ report("no database opened")
+ else
+ local converter = specification.converter
+ local nofrows = 0
+ local callback = nil
+ if converter then
+ local convert = converter.postgress
+ callback = function(nofcolumns,values,fields)
+ nofrows = nofrows + 1
+ result[nofrows] = convert(values)
+ end
+ else
+ callback = function(nofcolumns,values,fields)
+ local column = { }
+ for i=1,nofcolumns do
+ local field
+ if fields then
+ field = fields[i]
+ keys[i] = field
+ else
+ field = keys[i]
+ end
+ if field then
+ column[field] = values[i]
+ end
+ end
+ nofrows = nofrows + 1
+ result[nofrows] = column
+ end
+ end
+ for i=1,#query do
+ local okay = postgress_execute(db,query[i],callback)
+ if not okay then
+ if id and retry and i == 1 then
+ report("error: %s, retrying to connect",postgress_getmessage(db))
+ postgress_close(db)
+ cache[id] = nil
+ return execute_once(specification,false)
+ else
+ report("error: %s",postgress_getmessage(db))
+ end
+ end
+ end
+ end
+ if db and not id then
+ postgress_close(db)
+ end
+ -- bonus
+ local one = result[1]
+ if one then
+ setmetatable(result,{ __index = one } )
+ end
+ --
+ return result, keys
+ else
+ report("error: ","no library loaded")
+ end
+end
+
+local function execute(specification)
+ return execute_once(specification,true)
+end
+
+-- Here we build the dataset stepwise so we don't use the data hack that
+-- is used in the client variant.
+
+local wraptemplate = [[
+local converters = utilities.sql.converters
+local deserialize = utilities.sql.deserialize
+
+local tostring = tostring
+local tonumber = tonumber
+local booleanstring = string.booleanstring
+
+%s
+
+return function(cells)
+ -- %s (not needed)
+ -- %s (not needed)
+ return {
+ %s
+ }
+end
+]]
+
+local celltemplate = "cells[%s]"
+
+methods.postgress = {
+ execute = execute,
+ usesfiles = false,
+ wraptemplate = wraptemplate,
+ celltemplate = celltemplate,
+}
+
+package.loaded["util-sql-imp-postgress"] = methods.postgress
+package.loaded[libname] = methods.postgress
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-sqlite.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-sqlite.lmt
new file mode 100644
index 00000000000..5d38986f347
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-sqlite.lmt
@@ -0,0 +1,187 @@
+if not modules then modules = { } end modules ['libs-imp-sqlite'] = {
+ version = 1.001,
+ comment = "companion to util-sql.lua",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/sqlite/sqlite3.dll
+
+local libname = "sqlite"
+local libfile = "sqlite3"
+
+local sqlitelib = resolvers.libraries.validoptional(libname)
+
+if not sqlitelib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local next, tonumber = next, tonumber
+local setmetatable = setmetatable
+local formatters = string.formatters
+
+local sql = utilities.sql or require("util-sql")
+local report = logs.reporter(libname)
+
+local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
+local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
+
+local sqlite_open = sqlitelib.open
+local sqlite_close = sqlitelib.close
+local sqlite_execute = sqlitelib.execute
+local sqlite_getmessage = sqlitelib.getmessage
+
+local helpers = sql.helpers
+local methods = sql.methods
+local validspecification = helpers.validspecification
+local preparetemplate = helpers.preparetemplate
+local cache = { }
+
+-- synchronous journal_mode locking_mode 1000 logger inserts
+--
+-- normal normal normal 6.8
+-- off off normal 0.1
+-- normal off normal 2.1
+-- normal persist normal 5.8
+-- normal truncate normal 4.2
+-- normal truncate exclusive 4.1
+
+local f_preamble = formatters[ [[
+ATTACH `%s` AS `%s` ;
+PRAGMA `%s`.synchronous = normal ;
+]] ]
+
+local function execute(specification)
+ if okay() then
+ if trace_sql then
+ report("executing sqlite")
+ end
+ if not validspecification(specification) then
+ report("error in specification")
+ end
+ local query = preparetemplate(specification)
+ if not query then
+ report("error in preparation")
+ return
+ end
+ local base = specification.database -- or specification.presets and specification.presets.database
+ if not base then
+ report("no database specified")
+ return
+ end
+ local filename = file.addsuffix(base,"db")
+ local result = { }
+ local keys = { }
+ local id = specification.id
+ local db = nil
+ local preamble = nil
+ if id then
+ local session = cache[id]
+ if session then
+ db = session.db
+ else
+ db = sqlite_open(filename)
+ preamble = f_preamble(filename,base,base)
+ if not db then
+ report("no session database specified")
+ else
+ cache[id] = {
+ name = filename,
+ db = db,
+ }
+ end
+ end
+ else
+ db = open_db(filename)
+ preamble = f_preamble(filename,base,base)
+ end
+ if not db then
+ report("no database opened")
+ else
+ local converter = specification.converter
+ local nofrows = 0
+ local callback = nil
+ if preamble then
+ query = preamble .. query -- only needed in open
+ end
+ if converter then
+ local convert = converter.sqlite
+ callback = function(nofcolumns,values,fields)
+ nofrows = nofrows + 1
+ result[nofrows] = convert(values)
+ end
+ else
+ callback = function(nofcolumns,values,fields)
+ local column = { }
+ for i=1,nofcolumns do
+ local field
+ if fields then
+ field = fields[i]
+ keys[i] = field
+ else
+ field = keys[i]
+ end
+ if field then
+ column[field] = values[i]
+ end
+ end
+ nofrows = nofrows + 1
+ result[nofrows] = column
+ end
+ end
+ local okay = sqlite_execute(db,query,callback)
+ if not okay then
+ report("error: %s",sqlite_getmessage(db))
+ -- elseif converter then
+ -- result = converter.sqlite(result)
+ end
+ end
+ if db and not id then
+ sqlite_close(db)
+ end
+ return result, keys
+ else
+ report("error: ","no library loaded")
+ end
+end
+
+local wraptemplate = [[
+local converters = utilities.sql.converters
+local deserialize = utilities.sql.deserialize
+
+local tostring = tostring
+local tonumber = tonumber
+local booleanstring = string.booleanstring
+
+%s
+
+return function(cells)
+ -- %s (not needed)
+ -- %s (not needed)
+ return {
+ %s
+ }
+end
+]]
+
+local celltemplate = "cells[%s]"
+
+methods.sqlite = {
+ execute = execute,
+ usesfiles = false,
+ wraptemplate = wraptemplate,
+ celltemplate = celltemplate,
+}
+
+package.loaded["util-sql-imp-sqlite"] = methods.sqlite
+package.loaded[libname] = methods.sqlite
+
+return methods.sqlite
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-zint.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-zint.lmt
new file mode 100644
index 00000000000..2c346ae7d5f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-zint.lmt
@@ -0,0 +1,161 @@
+if not modules then modules = { } end modules ['libs-imp-ghostscript'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local libname = "zint"
+local libfile = "libzint" -- what on unix?
+-- local libfile = "/usr/local/lib/libzint.so"
+
+local zintlib = resolvers.libraries.validoptional(libname)
+
+if not zintlib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local zint = utilities.zint or { }
+utilities.zint = zint
+
+local zintlib_execute = zintlib.execute
+
+local next, type, unpack = next, type, unpack
+local lower, gsub = string.lower, string.gsub
+
+local mapping = {
+ ["code 11"] = 1, ["pharma one-track"] = 51, ["aztec code"] = 92,
+ ["standard 2of5"] = 2, ["pzn"] = 52, ["daft code"] = 93,
+ ["interleaved 2of5"] = 3, ["pharma two-track"] = 53, ["micro qr code"] = 97,
+ ["iata 2of5"] = 4, ["pdf417"] = 55, ["hibc code 128"] = 98,
+ ["data logic"] = 6, ["pdf417 trunc"] = 56, ["hibc code 39"] = 99,
+ ["industrial 2of5"] = 7, ["maxicode"] = 57, ["hibc data matrix"] = 102,
+ ["code 39"] = 8, ["qr code"] = 58, ["hibc qr code"] = 104,
+ ["extended code 39"] = 9, ["code 128-b"] = 60, ["hibc pdf417"] = 106,
+ ["ean"] = 13, ["ap standard customer"] = 63, ["hibc micropdf417"] = 108,
+ ["ean + check"] = 14, ["ap reply paid"] = 66, ["hibc codablock-f"] = 110,
+ ["gs1-128"] = 16, ["ap routing"] = 67, ["hibc aztec code"] = 112,
+ ["codabar"] = 18, ["ap redirection"] = 68, ["dotcode"] = 115,
+ ["code 128"] = 20, ["isbn"] = 69, ["han xin code"] = 116,
+ ["leitcode"] = 21, ["rm4scc"] = 70, ["rm mailmark"] = 121,
+ ["identcode"] = 22, ["data matrix"] = 71, ["aztec runes"] = 128,
+ ["code 16k"] = 23, ["ean-14"] = 72, ["code 32"] = 129,
+ ["code 49"] = 24, ["vin (north america)"] = 73, ["comp ean"] = 130,
+ ["code 93"] = 25, ["codablock-f"] = 74, ["comp gs1-128"] = 131,
+ ["flattermarken"] = 28, ["nve-18"] = 75, ["comp databar omni"] = 132,
+ ["gs1 databar omni"] = 29, ["japanese post"] = 76, ["comp databar ltd"] = 133,
+ ["gs1 databar ltd"] = 30, ["korea post"] = 77, ["comp databar expom"] = 134,
+ ["gs1 databar expom"] = 31, ["gs1 databar stack"] = 79, ["comp upc-a"] = 135,
+ ["telepen alpha"] = 32, ["gs1 databar stack omni"] = 80, ["comp upc-e"] = 136,
+ ["upc-a"] = 34, ["gs1 databar eso"] = 81, ["comp databar stack"] = 137,
+ ["upc-a + check"] = 35, ["planet"] = 82, ["comp databar stack omni"] = 138,
+ ["upc-e"] = 37, ["micropdf"] = 84, ["comp databar eso"] = 139,
+ ["upc-e + check"] = 38, ["usps onecode"] = 85, ["channel code"] = 140,
+ ["postnet"] = 40, ["uk plessey"] = 86, ["code one"] = 141,
+ ["msi plessey"] = 47, ["telepen numeric"] = 87, ["grid matrix"] = 142,
+ ["fim"] = 49, ["itf-14"] = 89, ["upnqr"] = 143,
+ ["logmars"] = 50, ["kix code"] = 90, ["rmqr"] = 145,
+}
+
+table.setmetatableindex(mapping,function(t,k)
+ local s = gsub(lower(k),"[^a-z0-9]","")
+ local v = rawget(t,s) or false
+ t[k] = v
+ return v
+end)
+
+local report = logs.reporter("zint")
+local context = context
+local shown = false
+
+----- f_rectangle = string.formatters["%sofill unitsquare xysized (%N,%N) shifted (%N,%N);"]
+
+local function execute(specification)
+ if okay() then
+ local code = specification.code
+ local text = specification.text
+ if code then
+ local id = mapping[code]
+ if id then
+ specification.code = id
+ local result = zintlib_execute(specification)
+ if result then
+ -- not that fast but if needed we can speed it up
+ context.startMPcode()
+ local rectangles = result.rectangles
+ local hexagons = result.hexagons
+ local circles = result.circles
+ local strings = result.strings
+ if rectangles then
+ local n = #rectangles
+ for i=1,n do
+ local r = rectangles[i]
+ context("%sofill unitsquare xysized (%N,%N) shifted (%N,%N);",
+ i == n and "d" or "n",r[3],r[4],r[1],r[2])
+ -- rectangles[i] = f_rectangle(i == n and "d" or "n",r[3],r[4],r[1],r[2])
+ end
+ -- context("% t",rectangles)
+ end
+ if hexagons then
+ local n = #hexagons
+ for i=1,#hexagons do
+ context("%sofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;",
+ i == n and "d" or "n",unpack(hexagons[i]))
+ end
+ end
+ if circles then
+ local n = #circles
+ for i=1,#circles do
+ local c = circles[i]
+ context("%sofill unitcircle scaled %N shifted (%N,%N);",
+ i == n and "d" or "n",c[3],c[1],c[2])
+ end
+ end
+ if strings then
+ -- We set the font at the encapsulating level.
+ for i=1,#strings do
+ local s = strings[i]
+ context('draw textext("%s") scaled (%N/10) shifted (%N,%N);',
+ s[4],s[3],s[1],s[2])
+ end
+ end
+ context.stopMPcode()
+ end
+ else
+ report("unknown barcode alternative %a",code)
+ if not shown then
+ report("")
+ report("valid barcode alternatives:")
+ report("")
+ local list = table.sortedkeys(mapping)
+ for i=1,#list do
+ report(" %s", list[i])
+ end
+ report("")
+ shown = true
+ end
+ end
+ end
+ end
+end
+
+optional.loaded.zint = { execute = execute }
+
+interfaces.implement {
+ name = "zint",
+ actions = execute,
+ arguments = {
+ {
+ { "code" },
+ { "text" },
+ }
+ }
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-zint.mkxl b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-zint.mkxl
new file mode 100644
index 00000000000..b2adf05ad82
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-zint.mkxl
@@ -0,0 +1,64 @@
+%D \module
+%D [ file=m-zint,
+%D version=2010.12.07,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Zint Barcode Generator,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Using \type {zint} seems to be the easiest way to generate
+%D (PDF417) barcodes so therefore we now have this module. There
+%D are proper (also windows) binaries at:
+%D
+%D \starttyping
+%D http://www.zint.org.uk
+%D \stoptyping
+%D
+%D There is a bit more code than needed as we want to be able to
+%D feed names.
+
+\registerctxluafile{libs-imp-zint}{autosuffix}
+
+\unprotect
+
+\definefont[usedzintfont][dejavusansmono at 10bp]
+
+\permanent\protected\def\barcode[#1]% [alternative=,text=]
+ {\bgroup
+ \usedzintfont
+ \getdummyparameters
+ [\c!alternative=,\c!text=,#1]%
+ \scale
+ [#1]%
+ {\clf_zint
+ code {\dummyparameter\c!alternative}
+ text {\dummyparameter\c!text}
+ \relax}
+ \egroup}
+
+\protect
+
+\continueifinputfile{libs-imp-zint.mkxl}
+
+\starttext
+
+% \dorecurse{1000}{
+ \startTEXpage
+ \barcode[alternative=PDF417,text={Hans Hagen}]%
+ \blank
+ \barcode[alternative=PDF417,text={Ton Otten}]%
+ \blank
+ \barcode[alternative=ISBN,text=9789490688011]%
+ \blank
+ \barcode[alternative=isbn,text=9789490688011,width=3cm]%
+ \stopTEXpage
+% }
+
+\stoptext
+
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/libs-ini.mkxl
new file mode 100644
index 00000000000..d77046fbffe
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-ini.mkxl
@@ -0,0 +1,32 @@
+%D \module
+%D [ file=libs-ini,
+%D version=2020.01.02,
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Libraries,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{libs-ini}{} % shared with mkiv
+
+\registerctxluafile{libs-imp-curl}{autosuffix}
+\registerctxluafile{libs-imp-ghostscript}{autosuffix}
+\registerctxluafile{libs-imp-graphicsmagick}{autosuffix}
+
+% These are loaded on demand:
+
+% \registerctxluafile{libs-imp-mysql}{autosuffix}
+% \registerctxluafile{libs-imp-sqlite}{autosuffix}
+% \registerctxluafile{libs-imp-postgress}{autosuffix}
+% \registerctxluafile{libs-imp-kpse}{autosuffix}
+
+\unprotect
+
+% \permanent\protected\def\uselibrary[#1]%
+% {\clf_uselibrary{#1}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-ano.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-ano.lmt
new file mode 100644
index 00000000000..86bcd4ad5dd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-ano.lmt
@@ -0,0 +1,1401 @@
+if not modules then modules = { } end modules ['lpdf-ano'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- when using rotation: \disabledirectives[refences.sharelinks] (maybe flag links)
+
+-- todo: /AA << WC << ... >> >> : WillClose actions etc
+
+-- internal references are indicated by a number (and turned into )
+-- we only flush internal destinations that are referred
+
+local next, tostring, tonumber, rawget, type = next, tostring, tonumber, rawget, type
+local rep, format, find = string.rep, string.format, string.find
+local min = math.min
+local lpegmatch = lpeg.match
+local formatters = string.formatters
+local sortedkeys, concat = table.sortedkeys, table.concat
+
+local backends, lpdf = backends, lpdf
+
+local trace_references = false trackers.register("references.references", function(v) trace_references = v end)
+local trace_destinations = false trackers.register("references.destinations", function(v) trace_destinations = v end)
+local trace_bookmarks = false trackers.register("references.bookmarks", function(v) trace_bookmarks = v end)
+
+local log_destinations = false directives.register("destinations.log", function(v) log_destinations = v end)
+local untex_urls = true directives.register("references.untexurls", function(v) untex_urls = v end)
+
+local report_references = logs.reporter("backend","references")
+local report_destinations = logs.reporter("backend","destinations")
+local report_bookmarks = logs.reporter("backend","bookmarks")
+
+local variables = interfaces.variables
+local v_auto = variables.auto
+local v_page = variables.page
+local v_name = variables.name
+
+local factor = number.dimenfactors.bp
+
+local settings_to_array = utilities.parsers.settings_to_array
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
+
+local javascriptcode = interactions.javascripts.code
+
+local references = structures.references
+local bookmarks = structures.bookmarks
+
+local flaginternals = references.flaginternals
+local usedinternals = references.usedinternals
+local usedviews = references.usedviews
+
+local runners = references.runners
+local specials = references.specials
+local handlers = references.handlers
+local executers = references.executers
+
+local nodepool = nodes.pool
+
+local new_latelua = nodepool.latelua
+
+local texgetcount = tex.getcount
+
+local jobpositions = job.positions
+local getpos = jobpositions.getpos
+local gethpos = jobpositions.gethpos
+local getvpos = jobpositions.getvpos
+
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfconstant = lpdf.constant
+local pdfnull = lpdf.null
+local pdfaddtocatalog = lpdf.addtocatalog
+local pdfaddtonames = lpdf.addtonames
+local pdfaddtopageattributes = lpdf.addtopageattributes
+local pdfrectangle = lpdf.rectangle
+
+local pdfflushobject
+local pdfshareobjectreference
+local pdfreserveobject
+local pdfpagereference
+local pdfdelayedobject
+local pdfregisterannotation
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfshareobjectreference = lpdf.shareobjectreference
+ pdfreserveobject = lpdf.reserveobject
+ pdfpagereference = lpdf.pagereference
+ pdfdelayedobject = lpdf.delayedobject
+ pdfregisterannotation = lpdf.registerannotation
+end)
+
+-- todo: 3dview
+
+----- pdf_annot = pdfconstant("Annot")
+local pdf_uri = pdfconstant("URI")
+local pdf_gotor = pdfconstant("GoToR")
+local pdf_goto = pdfconstant("GoTo")
+local pdf_launch = pdfconstant("Launch")
+local pdf_javascript = pdfconstant("JavaScript")
+local pdf_link = pdfconstant("Link")
+local pdf_n = pdfconstant("N")
+local pdf_t = pdfconstant("T")
+local pdf_fit = pdfconstant("Fit")
+local pdf_named = pdfconstant("Named")
+
+local autoprefix = "#"
+local usedautoprefixes = { }
+
+local function registerautoprefix(name)
+ local internal = autoprefix .. name
+ if usedautoprefixes[internal] == nil then
+ usedautoprefixes[internal] = false
+ end
+ return internal
+end
+
+local function useautoprefix(name)
+ local internal = autoprefix .. name
+ usedautoprefixes[internal] = true
+ return internal
+end
+
+local function checkautoprefixes(destinations)
+ for k, v in next, usedautoprefixes do
+ if not v then
+ if trace_destinations then
+ report_destinations("flushing unused autoprefix %a",k)
+ end
+ destinations[k] = nil
+ end
+ end
+end
+
+local maxslice = 32 -- could be made configureable ... 64 is also ok
+
+local function pdfmakenametree(list,apply)
+ if not next(list) then
+ return
+ end
+ local slices = { }
+ local sorted = sortedkeys(list)
+ local size = #sorted
+ local maxslice = maxslice
+ if size <= 1.5*maxslice then
+ maxslice = size
+ end
+ for i=1,size,maxslice do
+ local amount = min(i+maxslice-1,size)
+ local names = pdfarray { }
+ local n = 0
+ for j=i,amount do
+ local name = sorted[j]
+ local target = list[name]
+ n = n + 1 ; names[n] = tostring(name)
+ n = n + 1 ; names[n] = apply and apply(target) or target
+ end
+ local first = sorted[i]
+ local last = sorted[amount]
+ local limits = pdfarray {
+ first,
+ last,
+ }
+ local d = pdfdictionary {
+ Names = names,
+ Limits = limits,
+ }
+ slices[#slices+1] = {
+ reference = pdfreference(pdfflushobject(d)),
+ limits = limits,
+ }
+ end
+ local function collectkids(slices,first,last)
+ local f = slices[first]
+ local l = slices[last]
+ if f and l then
+ local k = pdfarray()
+ local n = 0
+ local d = pdfdictionary {
+ Kids = k,
+ Limits = pdfarray {
+ f.limits[1],
+ l.limits[2],
+ },
+ }
+ for i=first,last do
+ n = n + 1 ; k[n] = slices[i].reference
+ end
+ return d
+ end
+ end
+ if #slices == 1 then
+ return slices[1].reference
+ else
+ while true do
+ local size = #slices
+ if size > maxslice then
+ local temp = { }
+ local n = 0
+ for i=1,size,maxslice do
+ local kids = collectkids(slices,i,min(i+maxslice-1,size))
+ if kids then
+ n = n + 1
+ temp[n] = {
+ reference = pdfreference(pdfflushobject(kids)),
+ limits = kids.Limits,
+ }
+ else
+ -- error
+ end
+ end
+ slices = temp
+ else
+ local kids = collectkids(slices,1,size)
+ if kids then
+ return pdfreference(pdfflushobject(kids))
+ else
+ -- error
+ return
+ end
+ end
+ end
+ end
+end
+
+lpdf.makenametree = pdfmakenametree
+
+-- Bah, I hate this kind of features .. anyway, as we have delayed resolving we
+-- only support a document-wide setup and it has to be set before the first one
+-- is used. Also, we default to a non-intrusive gray and the outline is kept
+-- thin without dashing lines. This is as far as I'm prepared to go. This way
+-- it can also be used as a debug feature.
+
+local pdf_border_style = pdfarray { 0, 0, 0 } -- radius radius linewidth
+local pdf_border_color = nil
+local set_border = false
+
+local function pdfborder()
+ set_border = true
+ return pdf_border_style, pdf_border_color
+end
+
+lpdf.border = pdfborder
+
+directives.register("references.border",function(v)
+ if v and not set_border then
+ if type(v) == "string" then
+ local m = attributes.list[attributes.private('color')] or { }
+ local c = m and m[v]
+ local v = c and attributes.colors.value(c)
+ if v then
+ local r = v[3]
+ local g = v[4]
+ local b = v[5]
+ -- if r == g and g == b then
+ -- pdf_border_color = pdfarray { r } -- reduced, not not ... bugged viewers
+ -- else
+ pdf_border_color = pdfarray { r, g, b } -- always rgb
+ -- end
+ end
+ end
+ if not pdf_border_color then
+ pdf_border_color = pdfarray { .6, .6, .6 } -- no reduce to { 0.6 } as there are buggy viewers out there
+ end
+ pdf_border_style = pdfarray { 0, 0, .5 } -- < 0.5 is not show by acrobat (at least not in my version)
+ end
+end)
+
+-- the used and flag code here is somewhat messy in the sense
+-- that it belongs in strc-ref but at the same time depends on
+-- the backend so we keep it here
+
+-- the caching is somewhat memory intense on the one hand but
+-- it saves many small temporary tables so it might pay off
+
+local pagedestinations = setmetatableindex(function(t,k)
+ k = tonumber(k)
+ if not k or k <= 0 then
+ return pdfnull()
+ end
+ local v = rawget(t,k)
+ if v then
+ -- report_references("page number expected, got %s: %a",type(k),k)
+ return v
+ end
+ local v = k > 0 and pdfarray {
+ pdfreference(pdfpagereference(k)),
+ pdf_fit,
+ } or pdfnull()
+ t[k] = v
+ return v
+end)
+
+local pagereferences = setmetatableindex(function(t,k)
+ k = tonumber(k)
+ if not k or k <= 0 then
+ return nil
+ end
+ local v = rawget(t,k)
+ if v then
+ return v
+ end
+ local v = pdfdictionary { -- can be cached
+ S = pdf_goto,
+ D = pagedestinations[k],
+ }
+ t[k] = v
+ return v
+end)
+
+local defaultdestination = pdfarray { 0, pdf_fit }
+
+-- fit is default (see lpdf-nod)
+
+local destinations = { }
+local reported = setmetatableindex("table")
+
+local function pdfregisterdestination(name,reference)
+ local d = destinations[name]
+ if d then
+ if not reported[name][reference] then
+ report_destinations("ignoring duplicate destination %a with reference %a",name,reference)
+ reported[name][reference] = true
+ end
+ else
+ destinations[name] = reference
+ end
+end
+
+lpdf.registerdestination = pdfregisterdestination
+
+logs.registerfinalactions(function()
+ if log_destinations and next(destinations) then
+ local report = logs.startfilelogging("references","used destinations")
+ local n = 0
+ for destination, pagenumber in table.sortedhash(destinations) do
+ report("% 4i : %-5s : %s",pagenumber,usedviews[destination] or defaultview,destination)
+ n = n + 1
+ end
+ logs.stopfilelogging()
+ report_destinations("%s destinations saved in log file",n)
+ end
+end)
+
+local function pdfdestinationspecification()
+ if next(destinations) then -- safeguard
+ checkautoprefixes(destinations)
+ local r = pdfmakenametree(destinations,pdfreference)
+ if r then
+ pdfaddtonames("Dests",r)
+ end
+ if not log_destinations then
+ destinations = nil
+ end
+ end
+end
+
+lpdf.destinationspecification = pdfdestinationspecification
+
+lpdf.registerdocumentfinalizer(pdfdestinationspecification,"collect destinations")
+
+-- todo
+
+local destinations = { }
+
+local f_xyz = formatters["<< /D [ %i 0 R /XYZ %.6N %.6N null ] >>"]
+local f_fit = formatters["<< /D [ %i 0 R /Fit ] >>"]
+local f_fitb = formatters["<< /D [ %i 0 R /FitB ] >>"]
+local f_fith = formatters["<< /D [ %i 0 R /FitH %.6N ] >>"]
+local f_fitv = formatters["<< /D [ %i 0 R /FitV %.6N ] >>"]
+local f_fitbh = formatters["<< /D [ %i 0 R /FitBH %.6N ] >>"]
+local f_fitbv = formatters["<< /D [ %i 0 R /FitBV %.6N ] >>"]
+local f_fitr = formatters["<< /D [ %i 0 R /FitR %.6N %.6N %.6N %.6N ] >>"]
+
+local v_standard = variables.standard
+local v_frame = variables.frame
+local v_width = variables.width
+local v_minwidth = variables.minwidth
+local v_height = variables.height
+local v_minheight = variables.minheight
+local v_fit = variables.fit
+local v_tight = variables.tight
+
+-- nicer is to create dictionaries and set properties but it's a bit overkill
+
+-- The problem with the following settings is that they are guesses: we never know
+-- if a box is part of something larger that needs to be in view, or that we are
+-- dealing with a vbox or vtop so the used h/d values cannot be trusted in a tight
+-- view. Of course some decent additional offset would be nice so maybe i'll add
+-- that some day. I never use anything else than 'fit' anyway as I think that the
+-- document should fit the device (and vice versa). In fact, with todays swipe
+-- and finger zooming this whole view is rather useless and as with any zooming
+-- one looses the overview and keeps zooming.
+
+-- todo: scaling
+
+-- local destinationactions = {
+-- [v_standard] = function(r,w,h,d) return f_xyz (r,gethpos()*factor,(getvpos()+h)*factor) end, -- local left,top with no zoom
+-- [v_frame] = function(r,w,h,d) return f_fitr (r,pdfrectangle(w,h,d)) end, -- fit rectangle in window
+-- [v_width] = function(r,w,h,d) return f_fith (r,(getvpos()+h)*factor) end, -- top coordinate, fit width of page in window
+-- [v_minwidth] = function(r,w,h,d) return f_fitbh(r,(getvpos()+h)*factor) end, -- top coordinate, fit width of content in window
+-- [v_height] = function(r,w,h,d) return f_fitv (r,gethpos()*factor) end, -- left coordinate, fit height of page in window
+-- [v_minheight] = function(r,w,h,d) return f_fitbv(r,gethpos()*factor) end, -- left coordinate, fit height of content in window [v_fit] = f_fit, -- fit page in window
+-- [v_tight] = f_fitb, -- fit content in window
+-- [v_fit] = f_fit,
+-- }
+
+local destinationactions = {
+ [v_standard] = function(r,w,h,d,o) -- local left,top with no zoom
+ local tx, ty = getpos()
+ return f_xyz(r,tx*factor,(ty+h+2*o)*factor) -- we can assume margins
+ end,
+ [v_frame] = function(r,w,h,d,o) -- fit rectangle in window
+ return f_fitr(r,pdfrectangle(w,h,d,o))
+ end,
+ [v_width] = function(r,w,h,d,o) -- top coordinate, fit width of page in window
+ return f_fith(r,(getvpos()+h+o)*factor)
+ end,
+ [v_minwidth] = function(r,w,h,d,o) -- top coordinate, fit width of content in window
+ return f_fitbh(r,(getvpos()+h+o)*factor)
+ end,
+ [v_height] = function(r,w,h,d,o) -- left coordinate, fit height of page in window
+ return f_fitv(r,(gethpos())*factor)
+ end,
+ [v_minheight] = function(r,w,h,d,o) -- left coordinate, fit height of content in window
+ return f_fitbv(r,(gethpos())*factor)
+ end,
+ [v_tight] = f_fitb, -- fit content in window
+ [v_fit] = f_fit, -- fit content in window
+}
+
+local mapping = {
+ [v_standard] = v_standard, xyz = v_standard,
+ [v_frame] = v_frame, fitr = v_frame,
+ [v_width] = v_width, fith = v_width,
+ [v_minwidth] = v_minwidth, fitbh = v_minwidth,
+ [v_height] = v_height, fitv = v_height,
+ [v_minheight] = v_minheight, fitbv = v_minheight,
+ [v_fit] = v_fit, fit = v_fit,
+ [v_tight] = v_tight, fitb = v_tight,
+}
+
+local defaultview = v_fit
+local defaultaction = destinationactions[defaultview]
+local offset = 0 -- 65536*5
+
+directives.register("destinations.offset", function(v)
+ offset = string.todimen(v) or 0
+end)
+
+-- A complication is that we need to use named destinations when we have views so we
+-- end up with a mix. A previous versions just output multiple destinations but now
+-- that we moved all to here we can be more sparse.
+
+local pagedestinations = setmetatableindex(function(t,k) -- not the same as the one above!
+ local v = pdfdelayedobject(f_fit(k))
+ t[k] = v
+ return v
+end)
+
+local function flushdestination(specification)
+ local names = specification.names
+ local view = specification.view
+ local r = pdfpagereference(texgetcount("realpageno"))
+ if (references.innermethod ~= v_name) and (view == defaultview or not view or view == "") then
+ r = pagedestinations[r]
+ else
+ local action = view and destinationactions[view] or defaultaction
+ r = pdfdelayedobject(action(r,specification.width,specification.height,specification.depth,offset))
+ end
+ for n=1,#names do
+ local name = names[n]
+ if name then
+ pdfregisterdestination(name,r)
+ end
+ end
+end
+
+function nodeinjections.destination(width,height,depth,names,view)
+ -- todo check if begin end node / was comment
+ view = view and mapping[view] or defaultview
+ if trace_destinations then
+ report_destinations("width %p, height %p, depth %p, names %|t, view %a",width,height,depth,names,view)
+ end
+ local method = references.innermethod
+ local noview = view == defaultview
+ local doview = false
+ -- we could save some aut's by using a name when given but it doesn't pay off apart
+ -- from making the code messy and tracing hard .. we only save some destinations
+ -- which we already share anyway
+ if method == v_page then
+ for n=1,#names do
+ local name = names[n]
+ local used = usedviews[name]
+ if used and used ~= true then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ -- if noview then
+ -- usedviews[name] = view
+ -- names[n] = false
+ -- else
+ usedviews[name] = view
+ names[n] = false
+ -- end
+ else
+ usedviews[name] = view
+ end
+ end
+ elseif method == v_name then
+ for n=1,#names do
+ local name = names[n]
+ local used = usedviews[name]
+ if used and used ~= true then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ local used = usedinternals[name]
+ usedviews[name] = view
+ names[n] = registerautoprefix(name)
+ doview = true
+ else
+ usedviews[name] = view
+ doview = true
+ end
+ end
+ else
+ for n=1,#names do
+ local name = names[n]
+ if usedviews[name] then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ if noview then
+ usedviews[name] = view
+ names[n] = false
+ else
+ local used = usedinternals[name]
+ if used and used ~= defaultview then
+ usedviews[name] = view
+ names[n] = registerautoprefix(name)
+ doview = true
+ else
+ names[n] = false
+ end
+ end
+ else
+ usedviews[name] = view
+ doview = true
+ end
+ end
+ end
+ if doview then
+ return new_latelua {
+ action = flushdestination,
+ width = width,
+ height = height,
+ depth = depth,
+ names = names,
+ view = view,
+ }
+ end
+end
+
+-- we could share dictionaries ... todo
+
+local function pdflinkpage(page)
+ return pagereferences[page]
+end
+
+local function pdflinkinternal(internal,page)
+ -- local method = references.innermethod
+ if internal then
+ flaginternals[internal] = true -- for bookmarks and so
+ local used = usedinternals[internal]
+ if used == defaultview or used == true then
+ return pagereferences[page]
+ else
+ if type(internal) ~= "string" then
+ internal = useautoprefix(internal)
+ end
+ return pdfdictionary {
+ S = pdf_goto,
+ D = internal,
+ }
+ end
+ else
+ return pagereferences[page]
+ end
+end
+
+local function pdflinkname(destination,internal,page)
+ local method = references.innermethod
+ if method == v_auto then
+ local used = defaultview
+ if internal then
+ flaginternals[internal] = true -- for bookmarks and so
+ used = usedinternals[internal] or defaultview
+ end
+ if used == defaultview then -- or used == true then
+ return pagereferences[page]
+ else
+ return pdfdictionary {
+ S = pdf_goto,
+ D = destination,
+ }
+ end
+ elseif method == v_name then
+ -- flaginternals[internal] = true -- for bookmarks and so
+ return pdfdictionary {
+ S = pdf_goto,
+ D = destination,
+ }
+ else
+ return pagereferences[page]
+ end
+end
+
+-- annotations
+
+local function pdffilelink(filename,destination,page,actions)
+ if not filename or filename == "" or file.basename(filename) == tex.jobname then
+ return false
+ end
+ filename = file.addsuffix(filename,"pdf")
+ if (not destination or destination == "") or (references.outermethod == v_page) then
+ destination = pdfarray { (page or 1) - 1, pdf_fit }
+ end
+ return pdfdictionary {
+ S = pdf_gotor, -- can also be pdf_launch
+ F = filename,
+ D = destination or defaultdestination,
+ NewWindow = actions.newwindow and true or nil,
+ }
+end
+
+local untex = references.urls.untex
+
+local function pdfurllink(url,destination,page)
+ if not url or url == "" then
+ return false
+ end
+ if untex_urls then
+ url = untex(url) -- last minute cleanup of \* and spaces
+ end
+ if destination and destination ~= "" then
+ url = url .. "#" .. destination
+ end
+ return pdfdictionary {
+ S = pdf_uri,
+ URI = url,
+ }
+end
+
+local function pdflaunch(program,parameters)
+ if not program or program == "" then
+ return false
+ end
+ return pdfdictionary {
+ S = pdf_launch,
+ F = program,
+ D = ".",
+ P = parameters ~= "" and parameters or nil
+ }
+end
+
+local function pdfjavascript(name,arguments)
+ local script = javascriptcode(name,arguments) -- make into object (hash)
+ if script then
+ return pdfdictionary {
+ S = pdf_javascript,
+ JS = script,
+ }
+ end
+end
+
+local function pdfaction(actions)
+ local nofactions = #actions
+ if nofactions > 0 then
+ local a = actions[1]
+ local action = runners[a.kind]
+ if action then
+ action = action(a,actions)
+ end
+ if action then
+ local first = action
+ for i=2,nofactions do
+ local a = actions[i]
+ local what = runners[a.kind]
+ if what then
+ what = what(a,actions)
+ end
+ if action == what then
+ -- ignore this one, else we get a loop
+ elseif what then
+ action.Next = what
+ action = what
+ else
+ -- error
+ return nil
+ end
+ end
+ return first, actions.n or #actions
+ end
+ end
+end
+
+lpdf.action = pdfaction
+
+function codeinjections.prerollreference(actions) -- share can become option
+ if actions then
+ local main, n = pdfaction(actions)
+ if main then
+ local bs, bc = pdfborder()
+ main = pdfdictionary {
+ Subtype = pdf_link,
+ -- Border = bs,
+ Border = pdfshareobjectreference(bs),
+ C = bc,
+ H = (not actions.highlight and pdf_n) or nil,
+ A = pdfshareobjectreference(main),
+ F = 4, -- print (mandate in pdf/a)
+ }
+ return main("A"), n
+ end
+ end
+end
+
+-- local function use_normal_annotations()
+--
+-- local function reference(width,height,depth,prerolled) -- keep this one
+-- if prerolled then
+-- if trace_references then
+-- report_references("width %p, height %p, depth %p, prerolled %a",width,height,depth,prerolled)
+-- end
+-- return pdfannotation_node(width,height,depth,prerolled)
+-- end
+-- end
+--
+-- local function finishreference()
+-- end
+--
+-- return reference, finishreference
+--
+-- end
+
+-- eventually we can do this for special refs only
+
+local hashed = { }
+local nofunique = 0
+local nofused = 0
+local nofspecial = 0
+local share = true
+
+local f_annot = formatters["<< /Type /Annot %s /Rect [ %.6N %.6N %.6N %.6N ] >>"]
+local f_quadp = formatters["<< /Type /Annot %s /QuadPoints [ %s ] /Rect [ %.6N %.6N %.6N %.6N ] >>"]
+
+directives.register("references.sharelinks", function(v)
+ share = v
+end)
+
+setmetatableindex(hashed,function(t,k)
+ local v = pdfdelayedobject(k)
+ if share then
+ t[k] = v
+ end
+ nofunique = nofunique + 1
+ return v
+end)
+
+local function toquadpoints(paths)
+ local t, n = { }, 0
+ for i=1,#paths do
+ local path = paths[i]
+ local size = #path
+ for j=1,size do
+ local p = path[j]
+ n = n + 1 ; t[n] = p[1]
+ n = n + 1 ; t[n] = p[2]
+ end
+ local m = size % 4
+ if m > 0 then
+ local p = path[size]
+ for j=size+1,m do
+ n = n + 1 ; t[n] = p[1]
+ n = n + 1 ; t[n] = p[2]
+ end
+ end
+ end
+ return concat(t," ")
+end
+
+local function finishreference(specification)
+ local prerolled = specification.prerolled
+ local quadpoints = specification.mesh
+ local llx, lly,
+ urx, ury = pdfrectangle(specification.width,specification.height,specification.depth)
+ local specifier = nil
+ if quadpoints and #quadpoints > 0 then
+ specifier = f_quadp(prerolled,toquadpoints(quadpoints),llx,lly,urx,ury)
+ else
+ specifier = f_annot(prerolled,llx,lly,urx,ury)
+ end
+ nofused = nofused + 1
+ return pdfregisterannotation(hashed[specifier])
+end
+
+local function finishannotation(specification)
+ local prerolled = specification.prerolled
+ local objref = specification.objref
+ if type(prerolled) == "function" then
+ prerolled = prerolled()
+ end
+ local annot = f_annot(prerolled,pdfrectangle(specification.width,specification.height,specification.depth))
+ if objref then
+ pdfdelayedobject(annot,objref)
+ else
+ objref = pdfdelayedobject(annot)
+ end
+ nofspecial = nofspecial + 1
+ return pdfregisterannotation(objref)
+end
+
+function nodeinjections.reference(width,height,depth,prerolled,mesh)
+ if prerolled then
+ if trace_references then
+ report_references("link: width %p, height %p, depth %p, prerolled %a",width,height,depth,prerolled)
+ end
+ return new_latelua {
+ action = finishreference,
+ width = width,
+ height = height,
+ depth = depth,
+ prerolled = prerolled,
+ mesh = mesh,
+ }
+ end
+end
+
+function nodeinjections.annotation(width,height,depth,prerolled,objref)
+ if prerolled then
+ if trace_references then
+ report_references("special: width %p, height %p, depth %p, prerolled %a",width,height,depth,
+ type(prerolled) == "string" and prerolled or "-")
+ end
+ return new_latelua {
+ action = finishannotation,
+ width = width,
+ height = height,
+ depth = depth,
+ prerolled = prerolled,
+ objref = objref or false,
+ }
+ end
+end
+
+-- beware, we register during a latelua sweep so we have to make sure that
+-- we finalize after that (also in a latelua for the moment as we have no
+-- callback yet)
+
+local annotations = nil
+
+function lpdf.registerannotation(n)
+ if annotations then
+ annotations[#annotations+1] = pdfreference(n)
+ else
+ annotations = pdfarray { pdfreference(n) } -- no need to use lpdf.array cum suis
+ end
+end
+
+pdfregisterannotation = lpdf.registerannotation
+
+function lpdf.annotationspecification()
+ if annotations then
+ local r = pdfdelayedobject(tostring(annotations)) -- delayed so okay in latelua
+ if r then
+ pdfaddtopageattributes("Annots",pdfreference(r))
+ end
+ annotations = nil
+ end
+end
+
+lpdf.registerpagefinalizer(lpdf.annotationspecification,"finalize annotations")
+
+statistics.register("pdf annotations", function()
+ if nofused > 0 or nofspecial > 0 then
+ return format("%s links (%s unique), %s special",nofused,nofunique,nofspecial)
+ else
+ return nil
+ end
+end)
+
+-- runners and specials
+
+local splitter = lpeg.splitat(",",true)
+
+runners["inner"] = function(var,actions)
+ local internal = false
+ local name = nil
+ local method = references.innermethod
+ local vi = var.i
+ local page = var.r
+ if vi then
+ local vir = vi.references
+ if vir then
+ -- todo: no need for it when we have a real reference ... although we need
+ -- this mess for prefixes anyway
+ local reference = vir.reference
+ if reference and reference ~= "" then
+ reference = lpegmatch(splitter,reference) or reference
+ var.inner = reference
+ local prefix = var.p
+ if prefix and prefix ~= "" then
+ var.prefix = prefix
+ name = prefix .. ":" .. reference
+ else
+ name = reference
+ end
+ end
+ internal = vir.internal
+ if internal then
+ flaginternals[internal] = true
+ end
+ end
+ end
+ if name then
+ return pdflinkname(name,internal,page)
+ elseif internal then
+ return pdflinkinternal(internal,page)
+ elseif page then
+ return pdflinkpage(page)
+ else
+ -- real bad
+ end
+end
+
+runners["inner with arguments"] = function(var,actions)
+ report_references("todo: inner with arguments")
+ return false
+end
+
+runners["outer"] = function(var,actions)
+ local file, url = references.checkedfileorurl(var.outer,var.outer)
+ if file then
+ return pdffilelink(file,var.arguments,nil,actions)
+ elseif url then
+ return pdfurllink(url,var.arguments,nil,actions)
+ end
+end
+
+runners["outer with inner"] = function(var,actions)
+ return pdffilelink(references.checkedfile(var.outer),var.inner,var.r,actions)
+end
+
+runners["special outer with operation"] = function(var,actions)
+ local handler = specials[var.special]
+ return handler and handler(var,actions)
+end
+
+runners["special outer"] = function(var,actions)
+ report_references("todo: special outer")
+ return false
+end
+
+runners["special"] = function(var,actions)
+ local handler = specials[var.special]
+ return handler and handler(var,actions)
+end
+
+runners["outer with inner with arguments"] = function(var,actions)
+ report_references("todo: outer with inner with arguments")
+ return false
+end
+
+runners["outer with special and operation and arguments"] = function(var,actions)
+ report_references("todo: outer with special and operation and arguments")
+ return false
+end
+
+runners["outer with special"] = function(var,actions)
+ report_references("todo: outer with special")
+ return false
+end
+
+runners["outer with special and operation"] = function(var,actions)
+ report_references("todo: outer with special and operation")
+ return false
+end
+
+runners["special operation"] = runners["special"]
+runners["special operation with arguments"] = runners["special"]
+
+local reported = { }
+
+function specials.internal(var,actions) -- better resolve in strc-ref
+ local o = var.operation
+ local i = o and tonumber(o)
+ local v = i and references.internals[i]
+ if v then
+ flaginternals[i] = true -- also done in pdflinkinternal
+ return pdflinkinternal(i,v.references.realpage)
+ end
+ local v = i or o or ""
+ if not reported[v] then
+ report_references("no internal reference %a",v)
+ reported[v] = true
+ end
+end
+
+-- realpage already resolved
+
+specials.i = specials.internal
+
+local pages = references.pages
+
+function specials.page(var,actions)
+ local file = var.f
+ if file then
+ return pdffilelink(references.checkedfile(file),nil,var.operation,actions)
+ else
+ local p = var.r
+ if not p then -- todo: call special from reference code
+ p = pages[var.operation]
+ if type(p) == "function" then -- double
+ p = p()
+ else
+ p = references.realpageofpage(tonumber(p))
+ end
+ end
+ return pdflinkpage(p or var.operation)
+ end
+end
+
+function specials.realpage(var,actions)
+ local file = var.f
+ if file then
+ return pdffilelink(references.checkedfile(file),nil,var.operation,actions)
+ else
+ return pdflinkpage(var.operation)
+ end
+end
+
+function specials.userpage(var,actions)
+ local file = var.f
+ if file then
+ return pdffilelink(references.checkedfile(file),nil,var.operation,actions)
+ else
+ local p = var.r
+ if not p then -- todo: call special from reference code
+ p = var.operation
+ if p then -- no function and special check here. only numbers
+ p = references.realpageofpage(tonumber(p))
+ end
+ -- if p then
+ -- var.r = p
+ -- end
+ end
+ return pdflinkpage(p or var.operation)
+ end
+end
+
+function specials.deltapage(var,actions)
+ local p = tonumber(var.operation)
+ if p then
+ p = references.checkedrealpage(p + texgetcount("realpageno"))
+ return pdflinkpage(p)
+ end
+end
+
+-- sections
+
+function specials.section(var,actions)
+ -- a bit duplicate
+ local sectionname = var.arguments
+ local destination = var.operation
+ local internal = structures.sections.internalreference(sectionname,destination)
+ if internal then
+ var.special = "internal"
+ var.operation = internal
+ var.arguments = nil
+ return specials.internal(var,actions)
+ end
+end
+
+-- todo, do this in references namespace ordered instead (this is an experiment)
+
+local splitter = lpeg.splitat(":")
+
+function specials.order(var,actions) -- references.specials !
+ local operation = var.operation
+ if operation then
+ local kind, name, n = lpegmatch(splitter,operation)
+ local order = structures.lists.ordered[kind]
+ order = order and order[name]
+ local v = order[tonumber(n)]
+ local r = v and v.references.realpage
+ if r then
+ var.operation = r -- brrr, but test anyway
+ return specials.page(var,actions)
+ end
+ end
+end
+
+function specials.url(var,actions)
+ return pdfurllink(references.checkedurl(var.operation),var.arguments,nil,actions)
+end
+
+function specials.file(var,actions)
+ return pdffilelink(references.checkedfile(var.operation),var.arguments,nil,actions)
+end
+
+function specials.fileorurl(var,actions)
+ local file, url = references.checkedfileorurl(var.operation,var.operation)
+ if file then
+ return pdffilelink(file,var.arguments,nil,actions)
+ elseif url then
+ return pdfurllink(url,var.arguments,nil,actions)
+ end
+end
+
+function specials.program(var,content)
+ local program = references.checkedprogram(var.operation)
+ return pdflaunch(program,var.arguments)
+end
+
+function specials.javascript(var)
+ return pdfjavascript(var.operation,var.arguments)
+end
+
+specials.JS = specials.javascript
+
+executers.importform = pdfdictionary { S = pdf_named, N = pdfconstant("AcroForm:ImportFDF") }
+executers.exportform = pdfdictionary { S = pdf_named, N = pdfconstant("AcroForm:ExportFDF") }
+executers.first = pdfdictionary { S = pdf_named, N = pdfconstant("FirstPage") }
+executers.previous = pdfdictionary { S = pdf_named, N = pdfconstant("PrevPage") }
+executers.next = pdfdictionary { S = pdf_named, N = pdfconstant("NextPage") }
+executers.last = pdfdictionary { S = pdf_named, N = pdfconstant("LastPage") }
+executers.backward = pdfdictionary { S = pdf_named, N = pdfconstant("GoBack") }
+executers.forward = pdfdictionary { S = pdf_named, N = pdfconstant("GoForward") }
+executers.print = pdfdictionary { S = pdf_named, N = pdfconstant("Print") }
+executers.exit = pdfdictionary { S = pdf_named, N = pdfconstant("Quit") }
+executers.close = pdfdictionary { S = pdf_named, N = pdfconstant("Close") }
+executers.save = pdfdictionary { S = pdf_named, N = pdfconstant("Save") }
+executers.savenamed = pdfdictionary { S = pdf_named, N = pdfconstant("SaveAs") }
+executers.opennamed = pdfdictionary { S = pdf_named, N = pdfconstant("Open") }
+executers.help = pdfdictionary { S = pdf_named, N = pdfconstant("HelpUserGuide") }
+executers.toggle = pdfdictionary { S = pdf_named, N = pdfconstant("FullScreen") }
+executers.search = pdfdictionary { S = pdf_named, N = pdfconstant("Find") }
+executers.searchagain = pdfdictionary { S = pdf_named, N = pdfconstant("FindAgain") }
+executers.gotopage = pdfdictionary { S = pdf_named, N = pdfconstant("GoToPage") }
+executers.query = pdfdictionary { S = pdf_named, N = pdfconstant("AcroSrch:Query") }
+executers.queryagain = pdfdictionary { S = pdf_named, N = pdfconstant("AcroSrch:NextHit") }
+executers.fitwidth = pdfdictionary { S = pdf_named, N = pdfconstant("FitWidth") }
+executers.fitheight = pdfdictionary { S = pdf_named, N = pdfconstant("FitHeight") }
+
+local function fieldset(arguments)
+ -- [\dogetfieldset{#1}]
+ return nil
+end
+
+function executers.resetform(arguments)
+ arguments = (type(arguments) == "table" and arguments) or settings_to_array(arguments)
+ return pdfdictionary {
+ S = pdfconstant("ResetForm"),
+ Field = fieldset(arguments[1])
+ }
+end
+
+local formmethod = "post" -- "get" "post"
+local formformat = "xml" -- "xml" "html" "fdf"
+
+-- bit 3 = html bit 6 = xml bit 4 = get
+
+local flags = {
+ get = {
+ html = 12, fdf = 8, xml = 40,
+ },
+ post = {
+ html = 4, fdf = 0, xml = 32,
+ }
+}
+
+function executers.submitform(arguments)
+ arguments = (type(arguments) == "table" and arguments) or settings_to_array(arguments)
+ local flag = flags[formmethod] or flags.post
+ flag = (flag and (flag[formformat] or flag.xml)) or 32 -- default: post, xml
+ return pdfdictionary {
+ S = pdfconstant("SubmitForm"),
+ F = arguments[1],
+ Field = fieldset(arguments[2]),
+ Flags = flag,
+ -- \PDFsubmitfiller
+ }
+end
+
+local pdf_hide = pdfconstant("Hide")
+
+function executers.hide(arguments)
+ return pdfdictionary {
+ S = pdf_hide,
+ H = true,
+ T = arguments,
+ }
+end
+
+function executers.show(arguments)
+ return pdfdictionary {
+ S = pdf_hide,
+ H = false,
+ T = arguments,
+ }
+end
+
+local pdf_movie = pdfconstant("Movie")
+local pdf_start = pdfconstant("Start")
+local pdf_stop = pdfconstant("Stop")
+local pdf_resume = pdfconstant("Resume")
+local pdf_pause = pdfconstant("Pause")
+
+local function movie_or_sound(operation,arguments)
+ arguments = (type(arguments) == "table" and arguments) or settings_to_array(arguments)
+ return pdfdictionary {
+ S = pdf_movie,
+ T = format("movie %s",arguments[1] or "noname"),
+ Operation = operation,
+ }
+end
+
+function executers.startmovie (arguments) return movie_or_sound(pdf_start ,arguments) end
+function executers.stopmovie (arguments) return movie_or_sound(pdf_stop ,arguments) end
+function executers.resumemovie(arguments) return movie_or_sound(pdf_resume,arguments) end
+function executers.pausemovie (arguments) return movie_or_sound(pdf_pause ,arguments) end
+
+function executers.startsound (arguments) return movie_or_sound(pdf_start ,arguments) end
+function executers.stopsound (arguments) return movie_or_sound(pdf_stop ,arguments) end
+function executers.resumesound(arguments) return movie_or_sound(pdf_resume,arguments) end
+function executers.pausesound (arguments) return movie_or_sound(pdf_pause ,arguments) end
+
+function specials.action(var)
+ local operation = var.operation
+ if var.operation and operation ~= "" then
+ local e = executers[operation]
+ if type(e) == "table" then
+ return e
+ elseif type(e) == "function" then
+ return e(var.arguments)
+ end
+ end
+end
+
+local function build(levels,start,parent,method,nested)
+ local startlevel = levels[start].level
+ local noflevels = #levels
+ local i = start
+ local n = 0
+ local child, entry, m, prev, first, last, f, l
+ while i and i <= noflevels do
+ local current = levels[i]
+ if current.usedpage == false then
+ -- safeguard
+ i = i + 1
+ else
+ local level = current.level
+ local title = current.title
+ local reference = current.reference
+ local opened = current.opened
+ local reftype = type(reference)
+ local block = nil
+ local variant = "unknown"
+ if reftype == "table" then
+ -- we're okay
+ variant = "list"
+ block = reference.block
+ realpage = reference.realpage
+ elseif reftype == "string" then
+ local resolved = references.identify("",reference)
+ realpage = resolved and structures.references.setreferencerealpage(resolved) or 0
+ if realpage > 0 then
+ variant = "realpage"
+ realpage = realpage
+ reference = structures.pages.collected[realpage]
+ block = reference and reference.block
+ end
+ elseif reftype == "number" then
+ if reference > 0 then
+ variant = "realpage"
+ realpage = reference
+ reference = structures.pages.collected[realpage]
+ block = reference and reference.block
+ end
+ else
+ -- error
+ end
+ current.block = block
+ if variant == "unknown" then
+ -- error, ignore
+ i = i + 1
+ -- elseif (level < startlevel) or (i > 1 and block ~= levels[i-1].reference.block) then
+ elseif (level < startlevel) or (i > 1 and block ~= levels[i-1].block) then
+ if nested then -- could be an option but otherwise we quit too soon
+ if entry then
+ pdfflushobject(child,entry)
+ else
+ report_bookmarks("error 1")
+ end
+ return i, n, first, last
+ else
+ report_bookmarks("confusing level change at level %a around %a",level,title)
+ startlevel = level
+ end
+ end
+ if level == startlevel then
+ if trace_bookmarks then
+ report_bookmarks("%3i %w%s %s",realpage,(level-1)*2,(opened and "+") or "-",title)
+ end
+ local prev = child
+ child = pdfreserveobject()
+ if entry then
+ entry.Next = child and pdfreference(child)
+ pdfflushobject(prev,entry)
+ end
+ local action = nil
+ if variant == "list" then
+ action = pdflinkinternal(reference.internal,reference.realpage)
+ elseif variant == "realpage" then
+ action = pagereferences[realpage]
+ else
+ -- hm, what to do
+ end
+ entry = pdfdictionary {
+ Title = pdfunicode(title),
+ Parent = parent,
+ Prev = prev and pdfreference(prev),
+ A = action,
+ }
+ -- entry.Dest = pdflinkinternal(reference.internal,reference.realpage)
+ if not first then
+ first, last = child, child
+ end
+ prev = child
+ last = prev
+ n = n + 1
+ i = i + 1
+ elseif i < noflevels and level > startlevel then
+ i, m, f, l = build(levels,i,pdfreference(child),method,true)
+ if entry then
+ entry.Count = (opened and m) or -m
+ if m > 0 then
+ entry.First = pdfreference(f)
+ entry.Last = pdfreference(l)
+ end
+ else
+ report_bookmarks("error 2")
+ end
+ else
+ -- missing intermediate level but ok
+ i, m, f, l = build(levels,i,pdfreference(child),method,true)
+ if entry then
+ entry.Count = (opened and m) or -m
+ if m > 0 then
+ entry.First = pdfreference(f)
+ entry.Last = pdfreference(l)
+ end
+ pdfflushobject(child,entry)
+ else
+ report_bookmarks("error 3")
+ end
+ return i, n, first, last
+ end
+ end
+ end
+ pdfflushobject(child,entry)
+ return nil, n, first, last
+end
+
+function codeinjections.addbookmarks(levels,method)
+ if levels and #levels > 0 then
+ local parent = pdfreserveobject()
+ local _, m, first, last = build(levels,1,pdfreference(parent),method or "internal",false)
+ local dict = pdfdictionary {
+ Type = pdfconstant("Outlines"),
+ First = pdfreference(first),
+ Last = pdfreference(last),
+ Count = m,
+ }
+ pdfflushobject(parent,dict)
+ pdfaddtocatalog("Outlines",lpdf.reference(parent))
+ end
+end
+
+-- this could also be hooked into the frontend finalizer
+
+lpdf.registerdocumentfinalizer(function() bookmarks.place() end,1,"bookmarks") -- hm, why indirect call
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-aux.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-aux.lmt
new file mode 100644
index 00000000000..91636ad04e0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-aux.lmt
@@ -0,0 +1,153 @@
+if not modules then modules = { } end modules ['lpdf-aux'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local tonumber = tonumber
+local format, concat = string.format, table.concat
+local utfchar, utfbyte, char = utf.char, utf.byte, string.char
+local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local P, C, R, S, Cc, Cs, V = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc, lpeg.Cs, lpeg.V
+local rshift = bit32.rshift
+
+lpdf = lpdf or { }
+
+-- tosixteen --
+
+local cache = table.setmetatableindex(function(t,k) -- can be made weak
+ local v = utfbyte(k)
+ if v < 0x10000 then
+ v = format("%04x",v)
+ else
+ v = v - 0x10000
+ v = format("%04x%04x",rshift(v,10)+0xD800,v%1024+0xDC00)
+ end
+ t[k] = v
+ return v
+end)
+
+local unified = Cs(Cc(""))
+
+function lpdf.tosixteen(str) -- an lpeg might be faster (no table)
+ if not str or str == "" then
+ return "" -- not () as we want an indication that it's unicode
+ else
+ return lpegmatch(unified,str)
+ end
+end
+
+-- fromsixteen --
+
+-- local zero = S(" \n\r\t") + P("\\ ")
+-- local one = C(4)
+-- local two = P("d") * R("89","af") * C(2) * C(4)
+--
+-- local pattern = P { "start",
+-- start = V("wrapped") + V("unwrapped") + V("original"),
+-- original = Cs(P(1)^0),
+-- wrapped = P("<") * V("unwrapped") * P(">") * P(-1),
+-- unwrapped = P("feff")
+-- * Cs( (
+-- zero / ""
+-- + two / function(a,b)
+-- a = (tonumber(a,16) - 0xD800) * 1024
+-- b = (tonumber(b,16) - 0xDC00)
+-- return utfchar(a+b)
+-- end
+-- + one / function(a)
+-- return utfchar(tonumber(a,16))
+-- end
+-- )^1 ) * P(-1)
+-- }
+--
+-- function lpdf.fromsixteen(s)
+-- return lpegmatch(pattern,s) or s
+-- end
+
+local more = 0
+
+local pattern = C(4) / function(s) -- needs checking !
+ local now = tonumber(s,16)
+ if more > 0 then
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
+ more = 0
+ return utfchar(now)
+ elseif now >= 0xD800 and now <= 0xDBFF then
+ more = now
+ return "" -- else the c's end up in the stream
+ else
+ return utfchar(now)
+ end
+end
+
+local pattern = P(true) / function() more = 0 end * Cs(pattern^0)
+
+function lpdf.fromsixteen(str)
+ if not str or str == "" then
+ return ""
+ else
+ return lpegmatch(pattern,str)
+ end
+end
+
+-- frombytes --
+
+local b_pattern = Cs((P("\\")/"" * (
+ S("()")
+ + S("nrtbf")/ { n = "\n", r = "\r", t = "\t", b = "\b", f = "\f" }
+ + lpegpatterns.octdigit^-3 / function(s) return char(tonumber(s,8)) end)
++ P(1))^0)
+
+local u_pattern = lpegpatterns.utfbom_16_be * lpegpatterns.utf16_to_utf8_be -- official
+ + lpegpatterns.utfbom_16_le * lpegpatterns.utf16_to_utf8_le -- we've seen these
+
+local h_pattern = lpegpatterns.hextobytes
+
+local zero = S(" \n\r\t") + P("\\ ")
+local one = C(4)
+local two = P("d") * R("89","af") * C(2) * C(4)
+
+local x_pattern = P { "start",
+ start = V("wrapped") + V("unwrapped") + V("original"),
+ original = Cs(P(1)^0),
+ wrapped = P("<") * V("unwrapped") * P(">") * P(-1),
+ unwrapped = P("feff")
+ * Cs( (
+ zero / ""
+ + two / function(a,b)
+ a = (tonumber(a,16) - 0xD800) * 1024
+ b = (tonumber(b,16) - 0xDC00)
+ return utfchar(a+b)
+ end
+ + one / function(a)
+ return utfchar(tonumber(a,16))
+ end
+ )^1 ) * P(-1)
+}
+
+function lpdf.frombytes(s,hex)
+ if not s or s == "" then
+ return ""
+ end
+ if hex then
+ local x = lpegmatch(x_pattern,s)
+ if x then
+ return x
+ end
+ local h = lpegmatch(h_pattern,s)
+ if h then
+ return h
+ end
+ else
+ local u = lpegmatch(u_pattern,s)
+ if u then
+ return u
+ end
+ end
+ return lpegmatch(b_pattern,s)
+end
+
+-- done --
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-col.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-col.lmt
new file mode 100644
index 00000000000..ea60e0551d8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-col.lmt
@@ -0,0 +1,837 @@
+if not modules then modules = { } end modules ['lpdf-col'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type, next, tostring, tonumber = type, next, tostring, tonumber
+local char, byte, format, gsub, rep, gmatch = string.char, string.byte, string.format, string.gsub, string.rep, string.gmatch
+local settings_to_array, settings_to_numbers = utilities.parsers.settings_to_array, utilities.parsers.settings_to_numbers
+local concat = table.concat
+local round = math.round
+local formatters = string.formatters
+
+local backends, lpdf, nodes = backends, lpdf, nodes
+
+local allocate = utilities.storage.allocate
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
+
+local nodepool = nodes.nuts.pool
+local register = nodepool.register
+local setstate = nodepool.setstate
+
+local pdfconstant = lpdf.constant
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfverbose = lpdf.verbose
+
+local pdfflushobject
+local pdfdelayedobject
+local pdfflushstreamobject
+local pdfshareobjectreference
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfdelayedobject = lpdf.delayedobject
+ pdfflushstreamobject = lpdf.flushstreamobject
+ pdfshareobjectreference = lpdf.shareobjectreference
+end)
+
+local addtopageattributes = lpdf.addtopageattributes
+local adddocumentcolorspace = lpdf.adddocumentcolorspace
+local adddocumentextgstate = lpdf.adddocumentextgstate
+
+local colors = attributes.colors
+local registercolor = colors.register
+local colorsvalue = colors.value
+local forcedmodel = colors.forcedmodel
+local getpagecolormodel = colors.getpagecolormodel
+local colortoattributes = colors.toattributes
+
+local transparencies = attributes.transparencies
+local registertransparancy = transparencies.register
+local transparenciesvalue = transparencies.value
+local transparencytoattribute = transparencies.toattribute
+
+local unsetvalue = attributes.unsetvalue
+
+local setmetatableindex = table.setmetatableindex
+
+local c_transparency = pdfconstant("Transparency")
+
+local f_gray = formatters["%.3N g %.3N G"]
+local f_rgb = formatters["%.3N %.3N %.3N rg %.3N %.3N %.3N RG"]
+local f_cmyk = formatters["%.3N %.3N %.3N %.3N k %.3N %.3N %.3N %.3N K"]
+local f_spot = formatters["/%s cs /%s CS %s SCN %s scn"]
+local f_tr = formatters["Tr%s"]
+local f_cm = formatters["q %.6N %.6N %.6N %.6N %.6N %.6N cm"]
+local f_effect = formatters["%s Tc %s w %s Tr"] -- %.6N ?
+local f_tr_gs = formatters["/Tr%s gs"]
+local f_num_1 = formatters["%.3N %.3N"]
+local f_num_2 = formatters["%.3N %.3N"]
+local f_num_3 = formatters["%.3N %.3N %.3N"]
+local f_num_4 = formatters["%.3N %.3N %.3N %.3N"]
+
+local report_color = logs.reporter("colors","backend")
+
+-- page groups (might move to lpdf-ini.lua)
+
+local colorspaceconstants = allocate { -- v_none is ignored
+ gray = pdfconstant("DeviceGray"),
+ rgb = pdfconstant("DeviceRGB"),
+ cmyk = pdfconstant("DeviceCMYK"),
+ all = pdfconstant("DeviceRGB"), -- brr
+}
+
+local transparencygroups = { }
+
+lpdf.colorspaceconstants = colorspaceconstants
+lpdf.transparencygroups = transparencygroups
+
+setmetatableindex(transparencygroups, function(transparencygroups,colormodel)
+ local cs = colorspaceconstants[colormodel]
+ if cs then
+ local d = pdfdictionary {
+ S = c_transparency,
+ CS = cs,
+ I = true,
+ }
+ -- local g = pdfreference(pdfflushobject(tostring(d)))
+ local g = pdfreference(pdfdelayedobject(tostring(d)))
+ transparencygroups[colormodel] = g
+ return g
+ else
+ transparencygroups[colormodel] = false
+ return false
+ end
+end)
+
+local function addpagegroup()
+ local model = getpagecolormodel()
+ if model then
+ local g = transparencygroups[model]
+ if g then
+ addtopageattributes("Group",g)
+ end
+ end
+end
+
+lpdf.registerpagefinalizer(addpagegroup,3,"pagegroup")
+
+-- injection code (needs a bit reordering)
+
+-- color injection
+
+function nodeinjections.rgbcolor(r,g,b)
+ return register(setstate(f_rgb(r,g,b,r,g,b)))
+end
+
+function nodeinjections.cmykcolor(c,m,y,k)
+ return register(setstate(f_cmyk(c,m,y,k,c,m,y,k)))
+end
+
+function nodeinjections.graycolor(s) -- caching 0/1 does not pay off
+ return register(setstate(f_gray(s,s)))
+end
+
+function nodeinjections.spotcolor(n,f,d,p)
+ if type(p) == "string" then
+ p = gsub(p,","," ") -- brr misuse of spot
+ end
+ return register(setstate(f_spot(n,n,p,p)))
+end
+
+function nodeinjections.transparency(n)
+ return register(setstate(f_tr_gs(n)))
+end
+
+-- a bit weird but let's keep it here for a while
+
+local effects = {
+ normal = 0,
+ inner = 0,
+ outer = 1,
+ both = 2,
+ hidden = 3,
+}
+
+local bp = number.dimenfactors.bp
+
+function nodeinjections.effect(effect,stretch,rulethickness)
+ -- always, no zero test (removed)
+ rulethickness = bp * rulethickness
+ effect = effects[effect] or effects['normal']
+ return register(setstate(f_effect(stretch,rulethickness,effect))) -- watch order
+end
+
+-- spot- and indexcolors
+
+local pdf_separation = pdfconstant("Separation")
+local pdf_indexed = pdfconstant("Indexed")
+local pdf_device_n = pdfconstant("DeviceN")
+local pdf_device_rgb = pdfconstant("DeviceRGB")
+local pdf_device_cmyk = pdfconstant("DeviceCMYK")
+local pdf_device_gray = pdfconstant("DeviceGray")
+local pdf_extgstate = pdfconstant("ExtGState")
+
+local pdf_rgb_range = pdfarray { 0, 1, 0, 1, 0, 1 }
+local pdf_cmyk_range = pdfarray { 0, 1, 0, 1, 0, 1, 0, 1 }
+local pdf_gray_range = pdfarray { 0, 1 }
+
+local f_rgb_function = formatters["dup %s mul exch dup %s mul exch %s mul"]
+local f_cmyk_function = formatters["dup %s mul exch dup %s mul exch dup %s mul exch %s mul"]
+local f_gray_function = formatters["%s mul"]
+
+local documentcolorspaces = pdfdictionary()
+
+local spotcolorhash = { } -- not needed
+local spotcolornames = { }
+local indexcolorhash = { }
+local delayedindexcolors = { }
+
+function registrations.spotcolorname(name,e)
+ spotcolornames[name] = e or name
+end
+
+function registrations.getspotcolorreference(name)
+ return spotcolorhash[name]
+end
+
+-- beware: xpdf/okular/evince cannot handle the spot->process shade
+
+-- This should become delayed i.e. only flush when used; in that case we need
+-- need to store the specification and then flush them when accesssomespotcolor
+-- is called. At this moment we assume that splotcolors that get defined are
+-- also used which keeps the overhad small anyway. Tricky for mp ...
+
+local processcolors
+
+local function registersomespotcolor(name,noffractions,names,p,colorspace,range,funct)
+ noffractions = tonumber(noffractions) or 1 -- to be checked
+ if noffractions == 0 then
+ -- can't happen
+ elseif noffractions == 1 then
+ local dictionary = pdfdictionary {
+ FunctionType = 4,
+ Domain = { 0, 1 },
+ Range = range,
+ }
+ local calculations = pdfflushstreamobject(format("{ %s }",funct),dictionary)
+ -- local calculations = pdfobject {
+ -- type = "stream",
+ -- immediate = true,
+ -- string = format("{ %s }",funct),
+ -- attr = dictionary(),
+ -- }
+ local array = pdfarray {
+ pdf_separation,
+ pdfconstant(spotcolornames[name] or name),
+ colorspace,
+ pdfreference(calculations),
+ }
+ local m = pdfflushobject(array)
+ local mr = pdfreference(m)
+ spotcolorhash[name] = m
+ documentcolorspaces[name] = mr
+ adddocumentcolorspace(name,mr)
+ else
+ local cnames = pdfarray()
+ local domain = pdfarray()
+ local colorants = pdfdictionary()
+ for n in gmatch(names,"[^,]+") do
+ local name = spotcolornames[n] or n
+ -- the cmyk names assume that they are indeed these colors
+ if n == "cyan" then
+ name = "Cyan"
+ elseif n == "magenta" then
+ name = "Magenta"
+ elseif n == "yellow" then
+ name = "Yellow"
+ elseif n == "black" then
+ name = "Black"
+ else
+ local sn = spotcolorhash[name] or spotcolorhash[n]
+ if not sn then
+ report_color("defining %a as colorant",name)
+ colors.definespotcolor("",name,"p=1",true)
+ sn = spotcolorhash[name] or spotcolorhash[n]
+ end
+ if sn then
+ colorants[name] = pdfreference(sn)
+ else
+ -- maybe some day generate colorants (spot colors for multi) automatically
+ report_color("unknown colorant %a, using black instead",name or n)
+ name = "Black"
+ end
+ end
+ cnames[#cnames+1] = pdfconstant(name)
+ domain[#domain+1] = 0
+ domain[#domain+1] = 1
+ end
+ if not processcolors then
+ local specification = pdfdictionary {
+ ColorSpace = pdfconstant("DeviceCMYK"),
+ Components = pdfarray {
+ pdfconstant("Cyan"),
+ pdfconstant("Magenta"),
+ pdfconstant("Yellow"),
+ pdfconstant("Black")
+ }
+ }
+ processcolors = pdfreference(pdfflushobject(specification))
+ end
+ local dictionary = pdfdictionary {
+ FunctionType = 4,
+ Domain = domain,
+ Range = range,
+ }
+ local calculation = pdfflushstreamobject(format("{ %s %s }",rep("pop ",noffractions),funct),dictionary)
+ local channels = pdfdictionary {
+ Subtype = pdfconstant("NChannel"),
+ Colorants = colorants,
+ Process = processcolors,
+ }
+ local array = pdfarray {
+ pdf_device_n,
+ cnames,
+ colorspace,
+ pdfreference(calculation),
+ pdfshareobjectreference(tostring(channels)), -- optional but needed for shades
+ }
+ local m = pdfflushobject(array)
+ local mr = pdfreference(m)
+ spotcolorhash[name] = m
+ documentcolorspaces[name] = mr
+ adddocumentcolorspace(name,mr)
+ end
+end
+
+-- wrong name
+
+local function registersomeindexcolor(name,noffractions,names,p,colorspace,range,funct)
+ noffractions = tonumber(noffractions) or 1 -- to be checked
+ local cnames = pdfarray()
+ local domain = pdfarray()
+ local names = settings_to_array(#names == 0 and name or names)
+ local values = settings_to_numbers(p)
+ names [#names +1] = "None"
+ values[#values+1] = 1
+ -- check for #names == #values
+ for i=1,#names do
+ local name = names[i]
+ local spot = spotcolornames[name]
+ cnames[#cnames+1] = pdfconstant(spot ~= "" and spot or name)
+ domain[#domain+1] = 0
+ domain[#domain+1] = 1
+ end
+ local dictionary = pdfdictionary {
+ FunctionType = 4,
+ Domain = domain,
+ Range = range,
+ }
+ local n = pdfflushstreamobject(format("{ %s %s }",rep("exch pop ",noffractions),funct),dictionary) -- exch pop
+ local a = pdfarray {
+ pdf_device_n,
+ cnames,
+ colorspace,
+ pdfreference(n),
+ }
+ local vector = { }
+ local set = { }
+ local n = #values
+ for i=255,0,-1 do
+ for j=1,n do
+ set[j] = format("%02X",round(values[j]*i))
+ end
+ vector[#vector+1] = concat(set)
+ end
+ vector = pdfverbose { "<", concat(vector, " "), ">" }
+ local n = pdfflushobject(pdfarray{ pdf_indexed, a, 255, vector })
+ adddocumentcolorspace(format("%s_indexed",name),pdfreference(n))
+ return n
+end
+
+-- actually, names (parent) is the hash
+
+local function delayindexcolor(name,names,func)
+ local hash = (names ~= "" and names) or name
+ delayedindexcolors[hash] = func
+end
+
+local function indexcolorref(name) -- actually, names (parent) is the hash
+ local parent = colors.spotcolorparent(name)
+ local data = indexcolorhash[name]
+ if data == nil then
+ local delayedindexcolor = delayedindexcolors[parent]
+ if type(delayedindexcolor) == "function" then
+ data = delayedindexcolor()
+ delayedindexcolors[parent] = true
+ end
+ indexcolorhash[parent] = data or false
+ end
+ return data
+end
+
+function registrations.rgbspotcolor(name,noffractions,names,p,r,g,b)
+ if noffractions == 1 then
+ registersomespotcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_rgb_function(r,g,b))
+ else
+ registersomespotcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_num_3(r,g,b))
+ end
+ delayindexcolor(name,names,function()
+ return registersomeindexcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_rgb_function(r,g,b))
+ end)
+end
+
+function registrations.cmykspotcolor(name,noffractions,names,p,c,m,y,k)
+ if noffractions == 1 then
+ registersomespotcolor(name,noffractions,names,p,pdf_device_cmyk,pdf_cmyk_range,f_cmyk_function(c,m,y,k))
+ else
+ registersomespotcolor(name,noffractions,names,p,pdf_device_cmyk,pdf_cmyk_range,f_num_4(c,m,y,k))
+ end
+ delayindexcolor(name,names,function()
+ return registersomeindexcolor(name,noffractions,names,p,pdf_device_cmyk,pdf_cmyk_range,f_cmyk_function(c,m,y,k))
+ end)
+end
+
+function registrations.grayspotcolor(name,noffractions,names,p,s)
+ if noffractions == 1 then
+ registersomespotcolor(name,noffractions,names,p,pdf_device_gray,pdf_gray_range,f_gray_function(s))
+ else
+ registersomespotcolor(name,noffractions,names,p,pdf_device_gray,pdf_gray_range,f_num_1(s))
+ end
+ delayindexcolor(name,names,function()
+ return registersomeindexcolor(name,noffractions,names,p,pdf_device_gray,pdf_gray_range,f_gray_function(s))
+ end)
+end
+
+function registrations.rgbindexcolor(name,noffractions,names,p,r,g,b)
+ registersomeindexcolor(name,noffractions,names,p,pdf_device_rgb,pdf_rgb_range,f_rgb_function(r,g,b))
+end
+
+function registrations.cmykindexcolor(name,noffractions,names,p,c,m,y,k)
+ registersomeindexcolor(name,noffractions,names,p,pdf_device_cmyk,pdf_cmyk_range,f_cmyk_function(c,m,y,k))
+end
+
+function registrations.grayindexcolor(name,noffractions,names,p,s)
+ registersomeindexcolor(name,noffractions,names,p,pdf_device_gray,pdf_gray_range,f_gray_function(s))
+end
+
+function codeinjections.setfigurecolorspace(data,figure)
+ local color = data.request.color
+ if color then -- != v_default
+ local ref = indexcolorref(color)
+ if ref then
+ figure.colorspace = ref
+ data.used.color = color
+ data.used.colorref = ref
+ end
+ end
+end
+
+-- transparency
+
+local pdftransparencies = { [0] =
+ pdfconstant("Normal"),
+ pdfconstant("Normal"),
+ pdfconstant("Multiply"),
+ pdfconstant("Screen"),
+ pdfconstant("Overlay"),
+ pdfconstant("SoftLight"),
+ pdfconstant("HardLight"),
+ pdfconstant("ColorDodge"),
+ pdfconstant("ColorBurn"),
+ pdfconstant("Darken"),
+ pdfconstant("Lighten"),
+ pdfconstant("Difference"),
+ pdfconstant("Exclusion"),
+ pdfconstant("Hue"),
+ pdfconstant("Saturation"),
+ pdfconstant("Color"),
+ pdfconstant("Luminosity"),
+ pdfconstant("Compatible"), -- obsolete; 'Normal' is used in this case
+}
+
+local documenttransparencies = { }
+local transparencyhash = { } -- share objects
+
+local done, signaled = false, false
+
+function registrations.transparency(n,a,t)
+ if not done then
+ local d = pdfdictionary {
+ Type = pdf_extgstate,
+ ca = 1,
+ CA = 1,
+ BM = pdftransparencies[1],
+ AIS = false,
+ }
+ local m = pdfflushobject(d)
+ local mr = pdfreference(m)
+ transparencyhash[0] = m
+ documenttransparencies[0] = mr
+ adddocumentextgstate("Tr0",mr)
+ done = true
+ end
+ if n > 0 and not transparencyhash[n] then
+ local d = pdfdictionary {
+ Type = pdf_extgstate,
+ ca = tonumber(t),
+ CA = tonumber(t),
+ BM = pdftransparencies[tonumber(a)] or pdftransparencies[0],
+ AIS = false,
+ }
+ local m = pdfflushobject(d)
+ local mr = pdfreference(m)
+ transparencyhash[n] = m
+ documenttransparencies[n] = mr
+ adddocumentextgstate(f_tr(n),mr)
+ end
+end
+
+statistics.register("page group warning", function()
+ if done then
+ local model = getpagecolormodel()
+ if model and not transparencygroups[model] then
+ return "transparencies are used but no pagecolormodel is set"
+ end
+ end
+end)
+
+-- Literals needed to inject code in the mp stream, we cannot use attributes there
+-- since literals may have qQ's, much may go away once we have mplib code in place.
+--
+-- This module assumes that some functions are defined in the colors namespace
+-- which most likely will be loaded later.
+
+local function lpdfcolor(model,ca,default) -- todo: use gray when no color
+ if colors.supported then
+ local cv = colorsvalue(ca)
+ if cv then
+ if model == 1 then
+ model = cv[1]
+ end
+ model = forcedmodel(model)
+ if model == 2 then
+ local s = cv[2]
+ return f_gray(s,s)
+ elseif model == 3 then
+ local r = cv[3]
+ local g = cv[4]
+ local b = cv[5]
+ return f_rgb(r,g,b,r,g,b)
+ elseif model == 4 then
+ local c = cv[6]
+ local m = cv[7]
+ local y = cv[8]
+ local k = cv[9]
+ return f_cmyk(c,m,y,k,c,m,y,k)
+ else
+ local n = cv[10]
+ local f = cv[11]
+ local d = cv[12]
+ local p = cv[13]
+ if type(p) == "string" then
+ p = gsub(p,","," ") -- brr misuse of spot
+ end
+ return f_spot(n,n,p,p)
+ end
+ else
+ return f_gray(default or 0,default or 0)
+ end
+ else
+ return ""
+ end
+end
+
+lpdf.color = lpdfcolor
+
+interfaces.implement {
+ name = "lpdf_color",
+ actions = { lpdfcolor, context },
+ arguments = "integer"
+}
+
+function lpdf.colorspec(model,ca,default)
+ if ca and ca > 0 then
+ local cv = colors.value(ca)
+ if cv then
+ if model == 1 then
+ model = cv[1]
+ end
+ if model == 2 then
+ return pdfarray { cv[2] }
+ elseif model == 3 then
+ return pdfarray { cv[3],cv[4],cv[5] }
+ elseif model == 4 then
+ return pdfarray { cv[6],cv[7],cv[8],cv[9] }
+ elseif model == 5 then
+ return pdfarray { cv[13] }
+ end
+ end
+ end
+ if default then
+ return default
+ end
+end
+
+function lpdf.pdfcolor(attribute) -- bonus, for pgf and friends
+ return lpdfcolor(1,attribute)
+end
+
+function lpdf.transparency(ct,default) -- kind of overlaps with transparencycode
+ -- beware, we need this hack because normally transparencies are not
+ -- yet registered and therefore the number is not not known ... we
+ -- might use the attribute number itself in the future
+ if transparencies.supported then
+ local ct = transparenciesvalue(ct)
+ if ct then
+ return f_tr_gs(registertransparancy(nil,ct[1],ct[2],true))
+ else
+ return f_tr_gs(0)
+ end
+ else
+ return ""
+ end
+end
+
+function lpdf.colorvalue(model,ca,default)
+ local cv = colorsvalue(ca)
+ if cv then
+ if model == 1 then
+ model = cv[1]
+ end
+ model = forcedmodel(model)
+ if model == 2 then
+ return f_num_1(cv[2])
+ elseif model == 3 then
+ return f_num_3(cv[3],cv[4],cv[5])
+ elseif model == 4 then
+ return f_num_4(cv[6],cv[7],cv[8],cv[9])
+ else
+ return f_num_1(cv[13])
+ end
+ else
+ return f_num_1(default or 0)
+ end
+end
+
+function lpdf.colorvalues(model,ca,default)
+ local cv = colorsvalue(ca)
+ if cv then
+ if model == 1 then
+ model = cv[1]
+ end
+ model = forcedmodel(model)
+ if model == 2 then
+ return cv[2]
+ elseif model == 3 then
+ return cv[3], cv[4], cv[5]
+ elseif model == 4 then
+ return cv[6], cv[7], cv[8], cv[9]
+ elseif model == 5 then
+ return cv[13]
+ end
+ else
+ return default or 0
+ end
+end
+
+function lpdf.transparencyvalue(ta,default)
+ local tv = transparenciesvalue(ta)
+ if tv then
+ return tv[2]
+ else
+ return default or 1
+ end
+end
+
+function lpdf.colorspace(model,ca)
+ local cv = colorsvalue(ca)
+ if cv then
+ if model == 1 then
+ model = cv[1]
+ end
+ model = forcedmodel(model)
+ if model == 2 then
+ return "DeviceGray"
+ elseif model == 3 then
+ return "DeviceRGB"
+ elseif model == 4 then
+ return "DeviceCMYK"
+ end
+ end
+ return "DeviceGRAY"
+end
+
+-- by registering we getconversion for free (ok, at the cost of overhead)
+
+local intransparency = false
+local pdfcolor = lpdf.color
+
+function lpdf.rgbcode(model,r,g,b)
+ if colors.supported then
+ return pdfcolor(model,registercolor(nil,'rgb',r,g,b))
+ else
+ return ""
+ end
+end
+
+function lpdf.cmykcode(model,c,m,y,k)
+ if colors.supported then
+ return pdfcolor(model,registercolor(nil,'cmyk',c,m,y,k))
+ else
+ return ""
+ end
+end
+
+function lpdf.graycode(model,s)
+ if colors.supported then
+ return pdfcolor(model,registercolor(nil,'gray',s))
+ else
+ return ""
+ end
+end
+
+function lpdf.spotcode(model,n,f,d,p)
+ if colors.supported then
+ return pdfcolor(model,registercolor(nil,'spot',n,f,d,p)) -- incorrect
+ else
+ return ""
+ end
+end
+
+function lpdf.transparencycode(a,t)
+ if transparencies.supported then
+ intransparency = true
+ return f_tr_gs(registertransparancy(nil,a,t,true)) -- true forces resource
+ else
+ return ""
+ end
+end
+
+function lpdf.finishtransparencycode()
+ if transparencies.supported and intransparency then
+ intransparency = false
+ return f_tr_gs(0) -- we happen to know this -)
+ else
+ return ""
+ end
+end
+
+do
+
+ local pdfprint, pdfcolor, pdftransparency
+
+ updaters.register("backend.update.lpdf",function()
+ pdfprint = lpdf.print
+ pdfcolor = lpdf.color
+ pdftransparency = lpdf.transparency
+ end)
+
+ local c_cache = setmetatableindex(function(t,m)
+ -- We inherit the outer transparency.
+ local v = setmetatableindex(function(t,c)
+ local p = "q " .. pdfcolor(m,c)
+ t[c] = p
+ return p
+ end)
+ t[m] = v
+ return v
+ end)
+
+ local t_cache = setmetatableindex(function(t,transparency)
+ local p = pdftransparency(transparency)
+ local v = setmetatableindex(function(t,colormodel)
+ local v = setmetatableindex(function(t,color)
+ local v = "q " .. pdfcolor(colormodel,color) .. " " .. p
+ t[color] = v
+ return v
+ end)
+ t[colormodel] = v
+ return v
+ end)
+ t[transparency] = v
+ return v
+ end)
+
+ updaters.register("backend.update.lpdf",function()
+
+ local vfinjectors = fonts.helpers.vfinjectors
+
+ vfinjectors.pdf = function(pos_h,pos_v,packet)
+ pdfprint(packet[2],packet[3])
+ end
+
+ vfinjectors.startcolor = function(pos_h,pos_v,packet)
+ local color = type(packet) == "table" and packet[2] or packet
+ if color then
+ local m, c = colortoattributes(color)
+ local t = transparencytoattribute(color)
+ if t and t ~= unsetvalue then
+ pdfprint("page", t_cache[t][m][c]) -- "q " .. pdfcolor(m,c) .. " " .. pdftransparency(t)
+ else
+ pdfprint("page", c_cache[m][c]) -- "q " .. pdfcolor(m,c))
+ end
+ else
+ pdfprint("page", "q")
+ end
+ end
+
+ vfinjectors.stopcolor = function()
+ -- pdfprint("text", "Q")
+ pdfprint("page", "Q")
+ end
+
+ end)
+
+end
+
+-- These generate the in-stream color commands:
+
+do
+
+ local color = lpdf.color
+ local transparency = lpdf.transparency
+
+ local fonts = { }
+ lpdf.fonts = fonts
+
+ fonts.color_indirect = function(c,t)
+ if c and t then
+ return color(1,c) .. " " .. transparency(t)
+ elseif c then
+ return color(1,c)
+ elseif t then
+ return transparency(t)
+ else
+ return false
+ end
+ end
+
+ local colors = attributes.colors
+ local rgbtocmyk = colors.rgbtocmyk
+
+ local f_cmyk = formatters["%.3N %.3f %.3N %.3N k"]
+ local f_rgb = formatters["%.3N %.3f %.3N rg"]
+ local f_gray = formatters["%.3N g"]
+
+ fonts.color_direct = function(r,g,b)
+ local m = colors.model
+ if r == g and g == b then
+ return f_gray(r)
+ elseif m == "cmyk" then
+ return f_cmyk(rgbtocmyk(r,g,b))
+ else
+ return f_rgb(r,g,b)
+ end
+ end
+
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-emb.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-emb.lmt
new file mode 100644
index 00000000000..4337e5931dd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-emb.lmt
@@ -0,0 +1,2233 @@
+if not modules then modules = { } end modules ['lpdf-ini'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- vkgoeswild: Pink Floyd - Shine on You Crazy Diamond - piano cover (around that
+-- time I redid the code, a reminder so to say)
+
+-- At some point I wanted to have access to the shapes so that we could use them in
+-- metapost. So, after looking at the cff and ttf specifications, I decided to write
+-- parsers. At somepoint we needed a cff parser anyway in order to calculate the
+-- dimensions. Then variable fonts came around and a option was added to recreate
+-- streams of operators and a logical next step was to do all inclusion that way. It
+-- was only then that I found out that some of the juggling also happens in the the
+-- backend, but spread over places, so I could have saved myself some time
+-- deciphering the specifications. Anyway, here we go.
+--
+-- Color fonts are a bit messy. Catching issues with older fonts will break new ones
+-- so I don't think that it's wise to build in too many catches (like for fonts with
+-- zero boundingboxes, weird dimensions, transformations that in a next version are
+-- fixed, etc.). Better is then to wait till something gets fixed. If a spec doesn't
+-- tell me how to deal with it ... I'll happily wait till it does. After all we're
+-- not in a hurry as these fonts are mostly meant for the web or special purposes
+-- with manual tweaking in desk top publishing applications. Keep in mind that Emoji
+-- can have funny dimensions (e.g. to be consistent within a font, so no tight ones).
+
+-- When we have moved to lmtx I will document a bit more. Till then it's experimental
+-- and subjected to change.
+
+local next, type, unpack, rawget = next, type, unpack, rawget
+local char, byte, gsub, sub, match, rep, gmatch = string.char, string.byte, string.gsub, string.sub, string.match, string.rep, string.gmatch
+local formatters = string.formatters
+local format = string.format
+local concat, sortedhash, sort = table.concat, table.sortedhash, table.sort
+local utfchar = utf.char
+local random, round, max, abs, ceiling = math.random, math.round, math.max, math.abs, math.ceiling
+local extract, lshift, rshift, band, bor = bit32.extract, bit32.lshift, bit32.rshift, bit32.band, bit32.bor
+local idiv = number.idiv
+local setmetatableindex = table.setmetatableindex
+
+local pdfnull = lpdf.null
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfstring = lpdf.string
+local pdfreference = lpdf.reference
+
+local pdfreserveobject
+local pdfflushobject
+local pdfflushstreamobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+ pdfflushobject = lpdf.flushobject
+ pdfflushstreamobject = lpdf.flushstreamobject
+end)
+
+local report_fonts = logs.reporter("backend","fonts")
+
+local trace_fonts = false
+local trace_details = false
+
+local dimenfactors = number.dimenfactors
+local bpfactor = dimenfactors.bp
+local ptfactor = dimenfactors.pt
+
+trackers.register("backend.pdf.fonts",function(v) trace_fonts = v end)
+
+local readers = fonts.handlers.otf.readers
+local getinfo = readers.getinfo
+
+local setposition = utilities.files.setposition
+local readstring = utilities.files.readstring
+local openfile = utilities.files.open
+local closefile = utilities.files.close
+
+local getmapentry = fonts.mappings.getentry
+
+-- needs checking: signed vs unsigned
+
+local tocardinal1 = char
+
+local function tocardinal2(n)
+ return char(extract(n,8,8),extract(n,0,8))
+end
+
+local function tocardinal3(n)
+ return char(extract(n,16,8),extract(n,8,8),extract(n,0,8))
+end
+
+local function tocardinal4(n)
+ return char(extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
+end
+
+local function tointeger2(n)
+ return char(extract(n,8,8),extract(n,0,8))
+end
+
+local function tointeger3(n)
+ return char(extract(n,16,8),extract(n,8,8),extract(n,0,8))
+end
+
+local function tointeger4(n)
+ return char(extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
+end
+
+local function tocardinal8(n)
+ local l = idiv(n,0x100000000)
+ local r = n % 0x100000000
+ return char(extract(l,24,8),extract(l,16,8),extract(l,8,8),extract(l,0,8),
+ extract(r,24,8),extract(r,16,8),extract(r,8,8),extract(r,0,8))
+end
+
+-- A couple of shared helpers.
+
+local tounicodedictionary, widtharray, collectindices, subsetname, includecidset, forcecidset, tocidsetdictionary
+
+do
+
+ -- Because we supply tounicodes ourselves we only use bfchar mappings (as in the
+ -- backend). In fact, we can now no longer pass the tounicodes to the frontend but
+ -- pick them up from the descriptions.
+
+ local f_mapping_2 = formatters["<%02X> <%s>"]
+ local f_mapping_4 = formatters["<%04X> <%s>"]
+
+ local tounicode = fonts.mappings.tounicode
+
+local tounicode_template = [[
+%%!PS-Adobe-3.0 Resource-CMap
+%%%%DocumentNeededResources: ProcSet (CIDInit)
+%%%%IncludeResource: ProcSet (CIDInit)
+%%%%BeginResource: CMap (TeX-%s-0)
+%%%%Title: (TeX-%s-0 TeX %s 0)|
+%%%%Version: 1.000
+%%%%EndComments
+/CIDInit /ProcSet findresource begin
+ 12 dict begin
+ begincmap
+ /CIDSystemInfo
+ << /Registry (TeX) /Ordering (%s) /Supplement 0 >>
+ def
+ /CMapName
+ /TeX-Identity-%s
+ def
+ /CMapType
+ 2
+ def
+ 1 begincodespacerange
+ <%s> <%s>
+ endcodespacerange
+ %i beginbfchar
+%s
+ endbfchar
+ endcmap
+ CMapName currentdict /CMap defineresource pop
+ end
+end
+%%%%EndResource
+%%%%EOF]]
+
+ tounicodedictionary = function(details,indices,maxindex,name,wide)
+ local mapping = { }
+ local length = 0
+ if maxindex > 0 then
+ local f_mapping = wide and f_mapping_4 or f_mapping_2
+ for index=1,maxindex do
+ local data = indices[index]
+ if data then
+ length = length + 1
+ local unicode = data.unicode
+ if unicode then
+ unicode = tounicode(unicode)
+ else
+ unicode = "FFFD"
+ end
+ mapping[length] = f_mapping(index,unicode)
+ end
+ end
+ end
+ local name = gsub(name,"%+","-") -- like luatex does
+ local first = wide and "0000" or "00"
+ local last = wide and "FFFF" or "FF"
+ local blob = format(tounicode_template,name,name,name,name,name,first,last,length,concat(mapping,"\n"))
+ return blob
+ end
+
+ widtharray = function(details,indices,maxindex,units)
+ local widths = pdfarray()
+ local length = 0
+ local factor = 10000 / units
+ if maxindex > 0 then
+ local lastindex = -1
+ local sublist = nil
+ for index=1,maxindex do
+ local data = indices[index]
+ if data then
+ local width = data.width -- hm, is inaccurate for cff, so take from elsewhere
+ if width then
+ -- width = round(width * 10000 / units) / 10
+ width = round(width * factor) / 10
+ else
+ width = 0
+ end
+ if index == lastindex + 1 then
+ sublist[#sublist+1] = width
+ else
+ if sublist then
+ length = length + 1
+ widths[length] = sublist
+ end
+ sublist = pdfarray { width }
+ length = length + 1
+ widths[length] = index
+ end
+ lastindex = index
+ end
+ end
+ length = length + 1
+ widths[length] = sublist
+ end
+ return widths
+ end
+
+ collectindices = function(descriptions,indices)
+ local minindex = 0xFFFF
+ local maxindex = 0
+ local reverse = { }
+ -- todo: already at definition time trigger copying streams
+ -- and add extra indices ... first i need a good example of
+ -- a clash
+ -- for unicode, data in next, descriptions do
+ -- local i = data.index or unicode
+ -- if reverse[i] then
+ -- print("CLASH")
+ -- else
+ -- reverse[i] = data
+ -- end
+ -- end
+ for unicode, data in next, descriptions do
+ reverse[data.index or unicode] = data
+ end
+ for index in next, indices do
+ if index > maxindex then
+ maxindex = index
+ end
+ if index < minindex then
+ minindex = index
+ end
+ indices[index] = reverse[index]
+ end
+ if minindex > maxindex then
+ minindex = maxindex
+ end
+ return indices, minindex, maxindex
+ end
+
+ includecidset = false
+ forcecidset = false -- for private testing only
+
+ directives.register("backend.pdf.forcecidset",function(v)
+ forcecidset = v
+ end)
+
+ tocidsetdictionary = function(indices,min,max)
+ if includecidset or forcecidset then
+ local b = { }
+ local m = idiv(max+7,8)
+ for i=0,max do
+ b[i] = 0
+ end
+ b[0] = bor(b[0],lshift(1,7)) -- force notdef into the file
+ for i=min,max do
+ if indices[i] then
+ local bi = idiv(i,8)
+ local ni = i % 8
+ b[bi] = bor(b[bi],lshift(1,7-ni))
+ end
+ end
+ b = char(unpack(b,0,#b))
+ return pdfreference(pdfflushstreamobject(b))
+ end
+ end
+
+ -- Actually we can use the same as we only embed once.
+
+ -- subsetname = function(name)
+ -- return "CONTEXT" .. name
+ -- end
+
+ local prefixes = { } -- todo: set fixed one
+
+ subsetname = function(name)
+ local prefix
+ while true do
+ prefix = utfchar(random(65,90),random(65,90),random(65,90),random(65,90),random(65,90),random(65,90))
+ if not prefixes[prefix] then
+ prefixes[prefix] = true
+ break
+ end
+ end
+ return prefix .. "+" .. name
+ end
+
+end
+
+-- The three writers: opentype, truetype and type1.
+
+local mainwriters = { }
+
+do
+
+ -- advh = os2.ascender - os2.descender
+ -- tsb = default_advh - os2.ascender
+
+ -- truetype has the following tables:
+
+ -- head : mandate
+ -- hhea : mandate
+ -- vhea : mandate
+ -- hmtx : mandate
+ -- maxp : mandate
+ -- glyf : mandate
+ -- loca : mandate
+ --
+ -- cvt : if needed (but we flatten)
+ -- fpgm : if needed (but we flatten)
+ -- prep : if needed (but we flatten)
+ -- PCLT : if needed (but we flatten)
+ --
+ -- name : not needed for T2: backend does that
+ -- post : not needed for T2: backend does that
+ -- OS/2 : not needed for T2: backend does that
+ -- cmap : not needed for T2: backend does that
+
+ local streams = utilities.streams
+ local openstring = streams.openstring
+ local readcardinal2 = streams.readcardinal2
+ ----- readcardinal4 = streams.readcardinal4
+
+ local otfreaders = fonts.handlers.otf.readers
+
+ local function readcardinal4(f) -- this needs to be sorted out
+ local a = readcardinal2(f)
+ local b = readcardinal2(f)
+ if a and b then
+ return a * 0x10000 + b
+ end
+ end
+
+ -- -- --
+
+ local tablereaders = { }
+ local tablewriters = { }
+ local tablecreators = { }
+ local tableloaders = { }
+
+ local openfontfile, closefontfile, makefontfile, makemetadata do
+
+ local details = {
+ details = true,
+ platformnames = true,
+ platformextras = true,
+ }
+
+ -- .022 sec on luatex manual, neglectable:
+
+ -- local function checksum(data)
+ -- local s = openstring(data)
+ -- local n = 0
+ -- local d = #data
+ -- while true do
+ -- local c = readcardinal4(s)
+ -- if c then
+ -- n = (n + c) % 0x100000000
+ -- else
+ -- break
+ -- end
+ -- end
+ -- return n
+ -- end
+
+ local function checksum(data)
+ local s = openstring(data)
+ local n = 0
+ local d = #data
+ while true do
+ local a = readcardinal2(s)
+ local b = readcardinal2(s)
+ if b then
+ n = (n + a * 0x10000 + b) % 0x100000000
+ else
+ break
+ end
+ end
+ return n
+ end
+
+ openfontfile = function(details)
+ return {
+ offset = 0,
+ order = { },
+ used = { },
+ details = details,
+ streams = details.streams,
+ }
+ end
+
+ closefontfile = function(fontfile)
+ for k, v in next, fontfile do
+ fontfile[k] = nil -- so it can be collected asap
+ end
+ end
+
+ local metakeys = {
+ "uniqueid", "version",
+ "copyright", "license", "licenseurl",
+ "manufacturer", "vendorurl",
+ "family", "subfamily",
+ "typographicfamily", "typographicsubfamily",
+ "fullname", "postscriptname",
+ }
+
+ local template = [[
+
+
+
+
+
+%s
+
+
+
+
+]]
+
+ makemetadata = function(fontfile)
+ local names = fontfile.streams.names
+ local list = { }
+ local f_name = formatters["%s"]
+ for i=1,#metakeys do
+ local m = metakeys[i]
+ local n = names[m]
+ if n then
+ list[#list+1] = f_name(m,n,m)
+ end
+ end
+ return format(template,concat(list,"\n"))
+ end
+
+ makefontfile = function(fontfile)
+ local order = fontfile.order
+ local used = fontfile.used
+ local count = 0
+ for i=1,#order do
+ local tag = order[i]
+ local data = fontfile[tag]
+ if data and #data > 0 then
+ count = count + 1
+ else
+ fontfile[tag] = false
+ end
+ end
+ local offset = 12 + (count * 16)
+ local headof = 0
+ local list = {
+ "" -- placeholder
+ }
+ local i = 1
+ local k = 0
+ while i <= count do
+ i = lshift(i,1)
+ k = k + 1
+ end
+ local searchrange = lshift(i,3)
+ local entryselector = k - 1
+ local rangeshift = lshift(count,4) - lshift(i,3)
+ local index = {
+ tocardinal4(0x00010000), -- tables.version
+ tocardinal2(count),
+ tocardinal2(searchrange),
+ tocardinal2(entryselector),
+ tocardinal2(rangeshift),
+ }
+ --
+ local ni = #index
+ local nl = #list
+ for i=1,#order do
+ local tag = order[i]
+ local data = fontfile[tag]
+ if data then
+ local csum = checksum(data)
+ local dlength = #data
+ local length = idiv(dlength+3,4) * 4
+ local padding = length - dlength
+ nl = nl + 1 ; list[nl] = data
+ for i=1,padding do
+ nl = nl + 1 ; list[nl] = "\0"
+ end
+ if #tag == 3 then
+ tag = tag .. " "
+ end
+ ni = ni + 1 ; index[ni] = tag -- must be 4 chars
+ ni = ni + 1 ; index[ni] = tocardinal4(csum)
+ ni = ni + 1 ; index[ni] = tocardinal4(offset)
+ ni = ni + 1 ; index[ni] = tocardinal4(dlength)
+ used[i] = offset -- not used
+ if tag == "head" then
+ headof = offset
+ end
+ offset = offset + length
+ end
+ end
+ list[1] = concat(index)
+ local off = #list[1] + headof + 1 + 8
+ list = concat(list)
+ local csum = (0xB1B0AFBA - checksum(list)) % 0x100000000
+ list = sub(list,1,off-1) .. tocardinal4(csum) .. sub(list,off+4,#list)
+ return list
+ end
+
+ local function register(fontfile,name)
+ local u = fontfile.used
+ local o = fontfile.order
+ if not u[name] then
+ o[#o+1] = name
+ u[name] = true
+ end
+ end
+
+ local function create(fontfile,name)
+ local t = { }
+ fontfile[name] = t
+ return t
+ end
+
+ local function write(fontfile,name)
+ local t = fontfile[name]
+ if not t then
+ return
+ end
+ register(fontfile,name)
+ if type(t) == "table" then
+ if t[0] then
+ fontfile[name] = concat(t,"",0,#t)
+ elseif #t > 0 then
+ fontfile[name] = concat(t)
+ else
+ fontfile[name] = false
+ end
+ end
+ end
+
+ tablewriters.head = function(fontfile)
+ register(fontfile,"head")
+ local t = fontfile.streams.fontheader
+ fontfile.head = concat {
+ tocardinal4(t.version),
+ tocardinal4(t.fontversionnumber),
+ tocardinal4(t.checksum),
+ tocardinal4(t.magic),
+ tocardinal2(t.flags),
+ tocardinal2(t.units),
+ tocardinal8(t.created),
+ tocardinal8(t.modified),
+ tocardinal2(t.xmin),
+ tocardinal2(t.ymin),
+ tocardinal2(t.xmax),
+ tocardinal2(t.ymax),
+ tocardinal2(t.macstyle),
+ tocardinal2(t.smallpixels),
+ tocardinal2(t.directionhint),
+ tocardinal2(t.indextolocformat),
+ tocardinal2(t.glyphformat),
+ }
+ end
+
+ tablewriters.hhea = function(fontfile)
+ register(fontfile,"hhea")
+ local t = fontfile.streams.horizontalheader
+ local n = t and fontfile.nofglyphs or 0
+ fontfile.hhea = concat {
+ tocardinal4(t.version),
+ tocardinal2(t.ascender),
+ tocardinal2(t.descender),
+ tocardinal2(t.linegap),
+ tocardinal2(t.maxadvancewidth),
+ tocardinal2(t.minleftsidebearing),
+ tocardinal2(t.minrightsidebearing),
+ tocardinal2(t.maxextent),
+ tocardinal2(t.caretsloperise),
+ tocardinal2(t.caretsloperun),
+ tocardinal2(t.caretoffset),
+ tocardinal2(t.reserved_1),
+ tocardinal2(t.reserved_2),
+ tocardinal2(t.reserved_3),
+ tocardinal2(t.reserved_4),
+ tocardinal2(t.metricdataformat),
+ tocardinal2(n) -- t.nofmetrics
+ }
+ end
+
+ tablewriters.vhea = function(fontfile)
+ local t = fontfile.streams.verticalheader
+ local n = t and fontfile.nofglyphs or 0
+ register(fontfile,"vhea")
+ fontfile.vhea = concat {
+ tocardinal4(t.version),
+ tocardinal2(t.ascender),
+ tocardinal2(t.descender),
+ tocardinal2(t.linegap),
+ tocardinal2(t.maxadvanceheight),
+ tocardinal2(t.mintopsidebearing),
+ tocardinal2(t.minbottomsidebearing),
+ tocardinal2(t.maxextent),
+ tocardinal2(t.caretsloperise),
+ tocardinal2(t.caretsloperun),
+ tocardinal2(t.caretoffset),
+ tocardinal2(t.reserved_1),
+ tocardinal2(t.reserved_2),
+ tocardinal2(t.reserved_3),
+ tocardinal2(t.reserved_4),
+ tocardinal2(t.metricdataformat),
+ tocardinal2(n) -- t.nofmetrics
+ }
+ end
+
+ tablewriters.maxp = function(fontfile)
+ register(fontfile,"maxp")
+ local t = fontfile.streams.maximumprofile
+ local n = fontfile.nofglyphs
+ -- if fontfile.streams.cffinfo then
+ -- error
+ -- end
+ fontfile.maxp = concat {
+ tocardinal4(0x00010000),
+ tocardinal2(n),
+ tocardinal2(t.points),
+ tocardinal2(t.contours),
+ tocardinal2(t.compositepoints),
+ tocardinal2(t.compositecontours),
+ tocardinal2(t.zones),
+ tocardinal2(t.twilightpoints),
+ tocardinal2(t.storage),
+ tocardinal2(t.functiondefs),
+ tocardinal2(t.instructiondefs),
+ tocardinal2(t.stackelements),
+ tocardinal2(t.sizeofinstructions),
+ tocardinal2(t.componentelements),
+ tocardinal2(t.componentdepth),
+ }
+ end
+
+ tablecreators.loca = function(fontfile) return create(fontfile,"loca") end
+ tablewriters .loca = function(fontfile) return write (fontfile,"loca") end
+
+ tablecreators.glyf = function(fontfile) return create(fontfile,"glyf") end
+ tablewriters .glyf = function(fontfile) return write (fontfile,"glyf") end
+
+ tablecreators.hmtx = function(fontfile) return create(fontfile,"hmtx") end
+ tablewriters .hmtx = function(fontfile) return write (fontfile,"hmtx") end
+
+ tablecreators.vmtx = function(fontfile) return create(fontfile,"vmtx") end
+ tablewriters .vmtx = function(fontfile) return write (fontfile,"vmtx") end
+
+ tableloaders .cmap = function(fontfile) return read (fontfile,"cmap") end
+ tablewriters .cmap = function(fontfile) return write (fontfile,"cmap") end
+
+ tableloaders .name = function(fontfile) return read (fontfile,"name") end
+ tablewriters .name = function(fontfile) return write (fontfile,"name") end
+
+ tableloaders .post = function(fontfile) return read (fontfile,"post") end
+ tablewriters .post = function(fontfile) return write (fontfile,"post") end
+
+ end
+
+ mainwriters["truetype"] = function(details)
+ --
+ local fontfile = openfontfile(details)
+ local basefontname = details.basefontname
+ local streams = details.streams
+ local blobs = streams.streams
+ local fontheader = streams.fontheader
+ local horizontalheader = streams.horizontalheader
+ local verticalheader = streams.verticalheader
+ local maximumprofile = streams.maximumprofile
+ local names = streams.names
+ local descriptions = details.rawdata.descriptions
+ local metadata = details.rawdata.metadata
+ local indices = details.indices
+ local metabbox = { fontheader.xmin, fontheader.ymin, fontheader.xmax, fontheader.ymax }
+ local indices,
+ minindex,
+ maxindex = collectindices(descriptions,indices)
+ local glyphstreams = tablecreators.glyf(fontfile)
+ local locations = tablecreators.loca(fontfile)
+ local horizontals = tablecreators.hmtx(fontfile)
+ local verticals = tablecreators.vmtx(fontfile)
+ --
+ local zero2 = tocardinal2(0)
+ local zero4 = tocardinal4(0)
+ --
+ local horizontal = horizontalheader.nofmetrics > 0
+ local vertical = verticalheader.nofmetrics > 0
+ --
+ local streamoffset = 0
+ local lastoffset = zero4
+ local g, h, v = 0, 0, 0
+ --
+ -- todo: locate notdef
+ --
+ if minindex > 0 then
+ local blob = blobs[0]
+ if blob and #blob > 0 then
+ locations[0] = lastoffset
+ g = g + 1 ; glyphstreams[g] = blob
+ h = h + 1 ; horizontals [h] = zero4
+ if vertical then
+ v = v + 1 ; verticals[v] = zero4
+ end
+ streamoffset = streamoffset + #blob
+ lastoffset = tocardinal4(streamoffset)
+ else
+ report_fonts("missing .notdef in font %a",basefontname)
+ end
+ -- todo: use a rep for h/v
+ for index=1,minindex-1 do
+ locations[index] = lastoffset
+ h = h + 1 ; horizontals[h] = zero4
+ if vertical then
+ v = v + 1 ; verticals[v] = zero4
+ end
+ end
+ end
+ for index=minindex,maxindex do
+ locations[index] = lastoffset
+ local data = indices[index]
+ if data then
+ local blob = blobs[index] -- we assume padding
+ if blob and #blob > 0 then
+ g = g + 1 ; glyphstreams[g] = blob
+ h = h + 1 ; horizontals [h] = tocardinal2(data.width or 0)
+ h = h + 1 ; horizontals [h] = tocardinal2(data.boundingbox[1])
+ if vertical then
+ v = v + 1 ; verticals[v] = tocardinal2(data.height or 0)
+ v = v + 1 ; verticals[v] = tocardinal2(data.boundingbox[3])
+ end
+ streamoffset = streamoffset + #blob
+ lastoffset = tocardinal4(streamoffset)
+ else
+ h = h + 1 ; horizontals[h] = zero4
+ if vertical then
+ v = v + 1 ; verticals[v] = zero4
+ end
+ report_fonts("missing blob for index %i in font %a",index,basefontname)
+ end
+ else
+ h = h + 1 ; horizontals[h] = zero4
+ if vertical then
+ v = v + 1 ; verticals[v] = zero4
+ end
+ end
+ end
+ locations[maxindex+1] = lastoffset -- cf spec
+ --
+ local nofglyphs = maxindex + 1 -- include zero
+ --
+ fontheader.checksum = 0
+ fontheader.indextolocformat = 1
+ maximumprofile.nofglyphs = nofglyphs
+ --
+ fontfile.format = "tff"
+ fontfile.basefontname = basefontname
+ fontfile.nofglyphs = nofglyphs
+ --
+ tablewriters.head(fontfile)
+ tablewriters.hhea(fontfile)
+ if vertical then
+ tablewriters.vhea(fontfile)
+ end
+ tablewriters.maxp(fontfile)
+
+ tablewriters.loca(fontfile)
+ tablewriters.glyf(fontfile)
+
+ tablewriters.hmtx(fontfile)
+ if vertical then
+ tablewriters.vmtx(fontfile)
+ end
+ --
+ local fontdata = makefontfile(fontfile)
+ local fontmeta = makemetadata(fontfile)
+ --
+ fontfile = closefontfile(fontfile)
+ --
+ local units = metadata.units
+ local basefont = pdfconstant(basefontname)
+ local widths = widtharray(details,indices,maxindex,units)
+ local object = details.objectnumber
+ local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,true)
+ local tocidset = tocidsetdictionary(indices,minindex,maxindex)
+ local metabbox = metadata.boundingbox or { 0, 0, 0, 0 }
+ local fontbbox = pdfarray { unpack(metabbox) }
+ local ascender = metadata.ascender
+ local descender = metadata.descender
+ local capheight = metadata.capheight or fontbbox[4]
+ local stemv = metadata.weightclass
+ local italicangle = metadata.italicangle
+ local xheight = metadata.xheight or fontbbox[4]
+ --
+ if stemv then
+ stemv = (stemv/65)^2 + 50
+ end
+ --
+ local function scale(n)
+ if n then
+ return round((n) * 10000 / units) / 10
+ else
+ return 0
+ end
+ end
+ --
+ local reserved = pdfreserveobject()
+ local child = pdfdictionary {
+ Type = pdfconstant("Font"),
+ Subtype = pdfconstant("CIDFontType2"),
+ BaseFont = basefont,
+ FontDescriptor = pdfreference(reserved),
+ W = pdfreference(pdfflushobject(widths)),
+ CIDToGIDMap = pdfconstant("Identity"),
+ CIDSystemInfo = pdfdictionary {
+ Registry = pdfstring("Adobe"),
+ Ordering = pdfstring("Identity"),
+ Supplement = 0,
+ }
+ }
+ local descendants = pdfarray {
+ pdfreference(pdfflushobject(child)),
+ }
+ local descriptor = pdfdictionary {
+ Type = pdfconstant("FontDescriptor"),
+ FontName = basefont,
+ Flags = 4,
+ FontBBox = fontbbox,
+ Ascent = scale(ascender),
+ Descent = scale(descender),
+ ItalicAngle = round(italicangle or 0),
+ CapHeight = scale(capheight),
+ StemV = scale(stemv),
+ XHeight = scale(xheight),
+ FontFile2 = pdfreference(pdfflushstreamobject(fontdata)),
+ CIDSet = tocidset,
+ Metadata = fontmeta and pdfreference(pdfflushstreamobject(fontmeta)) or nil,
+ }
+ local parent = pdfdictionary {
+ Type = pdfconstant("Font"),
+ Subtype = pdfconstant("Type0"),
+ Encoding = pdfconstant(details.properties.writingmode == "vertical" and "Identity-V" or "Identity-H"),
+ BaseFont = basefont,
+ DescendantFonts = descendants,
+ ToUnicode = pdfreference(pdfflushstreamobject(tounicode)),
+ }
+ pdfflushobject(reserved,descriptor)
+ pdfflushobject(object,parent)
+ --
+ -- if trace_details then
+ -- local name = "temp.ttf"
+ -- report_fonts("saving %a",name)
+ -- io.savedata(name,fontdata)
+ -- inspect(fonts.handlers.otf.readers.loadfont(name))
+ -- end
+ --
+ end
+
+ do
+ -- todo : cff2
+
+ local details = {
+ details = true,
+ platformnames = true,
+ platformextras = true,
+ }
+
+ tablecreators.cff = function(fontfile)
+ fontfile.charstrings = { }
+ fontfile.charmappings = { }
+ fontfile.cffstrings = { }
+ fontfile.cffhash = { }
+ return fontfile.charstrings , fontfile.charmappings
+ end
+
+ local todictnumber, todictreal, todictinteger, todictoffset do
+
+ local maxnum = 0x7FFFFFFF
+ local minnum = - 0x7FFFFFFF - 1
+ local epsilon = 1.0e-5
+
+ local int2tag = "\28"
+ local int4tag = "\29"
+ local realtag = "\30"
+
+ todictinteger = function(n)
+ if not n then
+ return char(band(139,0xFF))
+ elseif n >= -107 and n <= 107 then
+ return char(band(n + 139,0xFF))
+ elseif n >= 108 and n <= 1131 then
+ n = 0xF700 + n - 108
+ return char(band(rshift(n,8),0xFF),band(n,0xFF))
+ elseif n >= -1131 and n <= -108 then
+ n = 0xFB00 - n - 108
+ return char(band(rshift(n,8),0xFF),band(n,0xFF))
+ elseif n >= -32768 and n <= 32767 then
+ -- return int2tag .. tointeger2(n)
+ return char(28,extract(n,8,8),extract(n,0,8))
+ else
+ -- return int4tag .. tointeger4(n)
+ return char(29,extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
+ end
+ end
+
+ -- -- not called that often
+ --
+ -- local encoder = readers.cffencoder
+ --
+ -- todictinteger = function(n)
+ -- if not n then
+ -- return encoder[0]
+ -- elseif n >= -1131 and n <= 1131 then
+ -- return encoder[n]
+ -- elseif n >= -32768 and n <= 32767 then
+ -- -- return int2tag .. tointeger2(n)
+ -- return char(28,extract(n,8,8),extract(n,0,8))
+ -- else
+ -- -- return int4tag .. tointeger4(n)
+ -- return char(29,extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8))
+ -- end
+ -- end
+
+ todictoffset = function(n)
+ return int4tag .. tointeger4(n)
+ end
+
+ local e = false
+ local z = byte("0")
+ local dp = 10
+ local ep = 11
+ local em = 12
+ local mn = 14
+ local es = 15
+
+ local fg = formatters["%g"]
+
+ todictreal = function(v)
+ local s = fg(v)
+ local t = { [0] = realtag }
+ local n = 0
+ for s in gmatch(s,".") do
+ if s == "e" or s == "E" then
+ e = true
+ elseif s == "+" then
+ -- skip
+ elseif s == "-" then
+ n = n + 1
+ if e then
+ t[n] = em
+ e = false
+ else
+ t[n] = mn
+ end
+ else
+ if e then
+ n = n + 1
+ t[n] = ep
+ e = false
+ end
+ n = n + 1
+ if s == "." then
+ t[n] = dp
+ else
+ t[n] = byte(s) - z
+ end
+ end
+ end
+ n = n + 1
+ t[n] = es
+ if (n % 2) ~= 0 then
+ n = n + 1
+ t[n] = es
+ end
+ local j = 0
+ for i=1,n,2 do
+ j = j + 1
+ t[j] = char(t[i]*0x10+t[i+1])
+ end
+ t = concat(t,"",0,j)
+ return t
+ end
+
+ todictnumber = function(n)
+ if not n or n == 0 then
+ return todictinteger(0)
+ elseif (n > maxnum or n < minnum or (abs(n - round(n)) > epsilon)) then
+ return todictreal(n)
+ else
+ return todictinteger(n)
+ end
+ end
+
+ end
+
+ local todictkey = char
+
+ local function todictstring(fontfile,value)
+ if not value then
+ value = ""
+ end
+ local s = fontfile.cffstrings
+ local h = fontfile.cffhash
+ local n = h[value]
+ if not n then
+ n = #s + 1
+ s[n] = value
+ h[value] = n
+ end
+ return todictinteger(390+n)
+ end
+
+ local function todictboolean(b)
+ return todictinteger(b and 1 or 0)
+ end
+
+ local function todictdeltas(t)
+ local r = { }
+ for i=1,#t do
+ r[i] = todictnumber(t[i]-(t[i-1] or 0))
+ end
+ return concat(r)
+ end
+
+ local function todictarray(t)
+ local r = { }
+ for i=1,#t do
+ r[i] = todictnumber(t[i])
+ end
+ return concat(r)
+ end
+
+ local function writestring(target,source,offset,what)
+ target[#target+1] = source
+ -- report_fonts("string : %-11s %06i # %05i",what,offset,#source)
+ return offset + #source
+ end
+
+ local function writetable(target,source,offset,what)
+ source = concat(source)
+ target[#target+1] = source
+ -- report_fonts("table : %-11s %06i # %05i",what,offset,#source)
+ return offset + #source
+ end
+
+ local function writeindex(target,source,offset,what)
+ local n = #source
+ local t = #target
+ t = t + 1 ; target[t] = tocardinal2(n)
+ if n > 0 then
+ local data = concat(source)
+ local size = #data -- assume the worst
+ local offsetsize, tocardinal
+ if size < 0xFF then
+ offsetsize, tocardinal = 1, tocardinal1
+ elseif size < 0xFFFF then
+ offsetsize, tocardinal = 2, tocardinal2
+ elseif size < 0xFFFFFF then
+ offsetsize, tocardinal = 3, tocardinal3
+ elseif size < 0xFFFFFFFF then
+ offsetsize, tocardinal = 4, tocardinal4
+ end
+ -- report_fonts("index : %-11s %06i # %05i (%i entries with offset size %i)",what,offset,#data,n,offsetsize)
+ offset = offset + 2 + 1 + (n + 1) * offsetsize + size
+ -- bytes per offset
+ t = t + 1 ; target[t] = tocardinal1(offsetsize)
+ -- list of offsets (one larger for length calculation)
+ local offset = 1 -- mandate
+ t = t + 1 ; target[t] = tocardinal(offset)
+ for i=1,n do
+ offset = offset + #source[i]
+ t = t + 1 ; target[t] = tocardinal(offset)
+ end
+ t = t + 1 ; target[t] = data
+ else
+ -- report_fonts("index : %-11s %06i # %05i (no entries)",what,offset,0)
+ offset = offset + 2
+ end
+ -- print("offset",offset,#concat(target))
+ return offset
+ end
+
+ tablewriters.cff = function(fontfile)
+ --
+ local streams = fontfile.streams
+ local cffinfo = streams.cffinfo or { }
+ local names = streams.names or { }
+ local fontheader = streams.fontheader or { }
+ local basefontname = fontfile.basefontname
+ --
+ local offset = 0
+ local dictof = 0
+ local target = { }
+ --
+ local charstrings = fontfile.charstrings
+ local nofglyphs = #charstrings + 1
+ local fontmatrix = { 0.001, 0, 0, 0.001, 0, 0 } -- todo
+ local fontbbox = fontfile.fontbbox
+ local defaultwidth = cffinfo.defaultwidth or 0
+ local nominalwidth = cffinfo.nominalwidth or 0
+ local bluevalues = cffinfo.bluevalues
+ local otherblues = cffinfo.otherblues
+ local familyblues = cffinfo.familyblues
+ local familyotherblues = cffinfo.familyotherblues
+ local bluescale = cffinfo.bluescale
+ local blueshift = cffinfo.blueshift
+ local bluefuzz = cffinfo.bluefuzz
+ local stdhw = cffinfo.stdhw
+ local stdvw = cffinfo.stdvw
+ --
+ if defaultwidth == 0 then defaultwidth = nil end
+ if nomimalwidth == 0 then nominalwidth = nil end
+ if bluevalues then bluevalues = todictarray(bluevalues) end
+ if otherblues then otherblues = todictarray(otherblues) end
+ if familyblues then familyblues = todictarray(familyblues) end
+ if familyotherblues then familyotherblues = todictarray(familyotherblues) end
+ if bluescale then bluescale = todictnumber(bluescale) end
+ if blueshift then blueshift = todictnumber(blueshift) end
+ if bluefuzz then bluefuzz = todictnumber(bluefuzz) end
+ if stdhw then stdhw = todictdeltas(stdhw) end
+ if stdvw then stdvw = todictdeltas(stdvw) end
+ --
+ local fontversion = todictstring(fontfile,fontheader.fontversion or "uknown version")
+ local familyname = todictstring(fontfile,cffinfo.familyname or names.family or basefontname)
+ local fullname = todictstring(fontfile,cffinfo.fullname or basefontname)
+ local weight = todictstring(fontfile,cffinfo.weight or "Normal")
+ local fontbbox = todictarray(fontbbox)
+ local strokewidth = todictnumber(cffinfo.strokewidth)
+ local monospaced = todictboolean(cffinfo.monospaced)
+ local italicangle = todictnumber(cffinfo.italicangle)
+ local underlineposition = todictnumber(cffinfo.underlineposition)
+ local underlinethickness = todictnumber(cffinfo.underlinethickness)
+ local charstringtype = todictnumber(2)
+ local fontmatrix = todictarray(fontmatrix)
+ local ros = todictstring(fontfile,"Adobe") -- registry
+ .. todictstring(fontfile,"Identity") -- identity
+ .. todictnumber(0) -- supplement
+ local cidcount = todictnumber(fontfile.nofglyphs)
+ local fontname = todictstring(fontfile,basefontname)
+ local fdarrayoffset = todictoffset(0)
+ local fdselectoffset = todictoffset(0)
+ local charstringoffset = todictoffset(0)
+ local charsetoffset = todictoffset(0)
+ local privateoffset = todictoffset(0)
+ --
+ local defaultwidthx = todictnumber(defaultwidth)
+ local nominalwidthx = todictnumber(nominalwidth)
+ local private = ""
+ .. (defaultwidthx and (defaultwidthx .. todictkey(20)) or "")
+ .. (nominalwidthx and (nominalwidthx .. todictkey(21)) or "")
+ .. (bluevalues and (bluevalues .. todictkey(6)) or "")
+ .. (otherblues and (otherblues .. todictkey(7)) or "")
+ .. (familyblues and (familyblues .. todictkey(8)) or "")
+ .. (familyotherblues and (familyotherblues .. todictkey(9)) or "")
+ .. (bluescale and (bluescale .. todictkey(12,9)) or "")
+ .. (blueshift and (blueshift .. todictkey(12,10)) or "")
+ .. (bluefuzz and (bluefuzz .. todictkey(12,11)) or "")
+ .. (stdhw and (stdhw .. todictkey(12,12)) or "")
+ .. (stdvw and (stdvw .. todictkey(12,13)) or "")
+ local privatesize = todictnumber(#private)
+ local privatespec = privatesize .. privateoffset
+ --
+ -- header (fixed @ 1)
+ --
+ local header =
+ tocardinal1(1) -- major
+ .. tocardinal1(0) -- minor
+ .. tocardinal1(4) -- header size
+ .. tocardinal1(4) -- offset size
+ --
+ offset = writestring(target,header,offset,"header")
+ --
+ -- name index (fixed @ 2) (has to be sorted)
+ --
+ local names = {
+ basefontname,
+ }
+ --
+ offset = writeindex(target,names,offset,"names")
+ --
+ -- topdict index (fixed @ 3)
+ --
+ local topvars =
+ charstringoffset .. todictkey(17)
+ .. charsetoffset .. todictkey(15)
+ .. fdarrayoffset .. todictkey(12,36)
+ .. fdselectoffset .. todictkey(12,37)
+ .. privatespec .. todictkey(18)
+ --
+ local topdict = {
+ ros .. todictkey(12,30) -- first
+ .. cidcount .. todictkey(12,34)
+ .. familyname .. todictkey( 3)
+ .. fullname .. todictkey( 2)
+ .. weight .. todictkey( 4)
+ .. fontbbox .. todictkey( 5)
+ .. monospaced .. todictkey(12, 1)
+ .. italicangle .. todictkey(12, 2)
+ .. underlineposition .. todictkey(12, 3)
+ .. underlinethickness .. todictkey(12, 4)
+ .. charstringtype .. todictkey(12, 6)
+ .. fontmatrix .. todictkey(12, 7)
+ .. strokewidth .. todictkey(12, 8)
+ .. topvars
+ }
+ --
+ offset = writeindex(target,topdict,offset,"topdict")
+ dictof = #target
+ --
+ -- string index (fixed @ 4)
+ --
+ offset = writeindex(target,fontfile.cffstrings,offset,"strings")
+ --
+ -- global subroutine index (fixed @ 5)
+ --
+ offset = writeindex(target,{},offset,"globals")
+ --
+ -- Encoding (cff1)
+ --
+ -- offset = writeindex(target,{},offset,"encoding")
+ --
+ -- Charsets
+ --
+ charsetoffset = todictoffset(offset)
+ offset = writetable(target,fontfile.charmappings,offset,"charsets")
+ --
+ -- fdselect
+ --
+ local fdselect =
+ tocardinal1(3) -- format
+ .. tocardinal2(1) -- n of ranges
+ -- entry 1
+ .. tocardinal2(0) -- first gid
+ .. tocardinal1(0) -- fd index
+ -- entry 2
+-- .. tocardinal2(fontfile.sparsemax-1) -- sentinel
+ .. tocardinal2(fontfile.sparsemax) -- sentinel
+ --
+ fdselectoffset = todictoffset(offset)
+ offset = writestring(target,fdselect,offset,"fdselect")
+ --
+ -- charstrings
+ --
+ charstringoffset = todictoffset(offset)
+ offset = writeindex(target,charstrings,offset,"charstrings")
+ --
+ -- font dict
+ --
+ -- offset = writeindex(target,{},offset,"fontdict")
+ --
+ -- private
+ --
+ privateoffset = todictoffset(offset)
+ privatespec = privatesize .. privateoffset
+ offset = writestring(target,private,offset,"private")
+ --
+ local fdarray = {
+ fontname .. todictkey(12,38)
+ .. privatespec .. todictkey(18)
+ }
+ fdarrayoffset = todictoffset(offset)
+ offset = writeindex(target,fdarray,offset,"fdarray")
+ --
+ topdict = target[dictof]
+ topdict = sub(topdict,1,#topdict-#topvars)
+ topvars =
+ charstringoffset .. todictkey(17)
+ .. charsetoffset .. todictkey(15)
+ .. fdarrayoffset .. todictkey(12,36)
+ .. fdselectoffset .. todictkey(12,37)
+ .. privatespec .. todictkey(18)
+ target[dictof] = topdict .. topvars
+ --
+ target = concat(target)
+ -- if trace_details then
+ -- local name = "temp.cff"
+ -- report_fonts("saving %a",name)
+ -- io.savedata(name,target)
+ -- inspect(fonts.handlers.otf.readers.cffcheck(name))
+ -- end
+ return target
+ end
+
+ end
+
+ -- todo: check widths (missing a decimal)
+
+ mainwriters["opentype"] = function(details)
+ --
+ local fontfile = openfontfile(details)
+ local basefontname = details.basefontname
+ local streams = details.streams
+ local blobs = streams.streams
+ local fontheader = streams.fontheader
+ local maximumprofile = streams.maximumprofile
+ local names = streams.names
+ local descriptions = details.rawdata.descriptions
+ local metadata = details.rawdata.metadata
+ local indices = details.indices
+ local metabbox = { fontheader.xmin, fontheader.ymin, fontheader.xmax, fontheader.ymax }
+ local correction = 1
+
+ -- (*) We share code with type1 and when we have old school tfm with
+ -- pfb but without descriptions we're kind of toast.
+
+ if not descriptions or not next(descriptions) then
+ -- This is good enough, we only need indices and widths.
+ descriptions = details.fontdata.characters
+ -- This is a hack, we have no basepoints.
+ correction = details.fontdata.parameters.size / 1000
+ -- And this needs checking.
+ correction = correction * bpfactor / ptfactor
+ metadata = { }
+ end
+
+ --
+
+ local indices,
+ minindex,
+ maxindex = collectindices(descriptions,indices)
+ local streamoffset = 0
+ local glyphstreams,
+ charmappings = tablecreators.cff(fontfile)
+ --
+ local zero2 = tocardinal2(0)
+ local zero4 = tocardinal4(0)
+ --
+ -- we need to locate notdef (or store its unicode someplace)
+ --
+ local blob = blobs[0] or "\14"
+ local sparsemax = 1
+ local lastoffset = zero4
+ glyphstreams[sparsemax] = blob
+ charmappings[sparsemax] = tocardinal1(0) -- format 0
+ streamoffset = streamoffset + #blob
+ lastoffset = tocardinal4(streamoffset)
+ if minindex == 0 then
+ minindex = 1
+ end
+ for index=minindex,maxindex do
+ if indices[index] then
+ local blob = blobs[index] or "\14"
+ sparsemax = sparsemax + 1
+ glyphstreams[sparsemax] = blob
+ charmappings[sparsemax] = tocardinal2(index)
+ streamoffset = streamoffset + #blob
+ lastoffset = tocardinal4(streamoffset)
+ end
+ end
+ --
+ fontfile.nofglyphs = maxindex + 1
+ fontfile.sparsemax = sparsemax
+ fontfile.format = "cff"
+ fontfile.basefontname = basefontname
+ fontfile.fontbbox = metabbox
+ --
+ local fontdata = tablewriters.cff(fontfile)
+ local fontmeta = makemetadata(fontfile)
+ --
+ fontfile = closefontfile(fontfile)
+ --
+ local units = fontheader.units or metadata.units
+
+ local basefont = pdfconstant(basefontname)
+ local widths = widtharray(details,indices,maxindex,units * correction)
+ local object = details.objectnumber
+ local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,true)
+ local tocidset = tocidsetdictionary(indices,minindex,maxindex)
+ local fontbbox = pdfarray { unpack(metabbox) }
+ local ascender = metadata.ascender or 0
+ local descender = metadata.descender or 0
+ local capheight = metadata.capheight or fontbbox[4]
+ local stemv = metadata.weightclass
+ local italicangle = metadata.italicangle
+ local xheight = metadata.xheight or fontbbox[4]
+ if stemv then
+ stemv = (stemv/65)^2 + 50
+ else
+-- stemv = 2
+ end
+ --
+ local function scale(n)
+ if n then
+ return round((n) * 10000 / units) / 10
+ else
+ return 0
+ end
+ end
+ --
+ local reserved = pdfreserveobject()
+ local child = pdfdictionary {
+ Type = pdfconstant("Font"),
+ Subtype = pdfconstant("CIDFontType0"),
+ BaseFont = basefont,
+ FontDescriptor = pdfreference(reserved),
+ W = pdfreference(pdfflushobject(widths)),
+ CIDSystemInfo = pdfdictionary {
+ Registry = pdfstring("Adobe"),
+ Ordering = pdfstring("Identity"),
+ Supplement = 0,
+ }
+ }
+ local descendants = pdfarray {
+ pdfreference(pdfflushobject(child)),
+ }
+ local fontstream = pdfdictionary {
+ Subtype = pdfconstant("CIDFontType0C"),
+ }
+ local descriptor = pdfdictionary {
+ Type = pdfconstant("FontDescriptor"),
+ FontName = basefont,
+ Flags = 4,
+ FontBBox = fontbbox,
+ Ascent = scale(ascender),
+ Descent = scale(descender),
+ ItalicAngle = round(italicangle or 0),
+ CapHeight = scale(capheight),
+ StemV = scale(stemv),
+ XHeight = scale(xheight),
+ CIDSet = tocidset,
+ FontFile3 = pdfreference(pdfflushstreamobject(fontdata,fontstream())),
+ Metadata = fontmeta and pdfreference(pdfflushstreamobject(fontmeta)) or nil,
+ }
+ local parent = pdfdictionary {
+ Type = pdfconstant("Font"),
+ Subtype = pdfconstant("Type0"),
+ Encoding = pdfconstant(details.properties.writingmode == "vertical" and "Identity-V" or "Identity-H"),
+ BaseFont = basefont,
+ DescendantFonts = descendants,
+ ToUnicode = pdfreference(pdfflushstreamobject(tounicode)),
+ }
+ pdfflushobject(reserved,descriptor)
+ pdfflushobject(object,parent)
+ end
+
+ mainwriters["type1"] = function(details)
+ -- We abuse the cff includer which is ok but for special cases like
+ -- tfm -> pfb we don't have the right descriptions and scale so this
+ -- is why we cheat elsewhere. Maybe I should just drop that kind of
+ -- support and assume afm files to be present. See (*) above.
+ local s = details.streams
+ local m = details.rawdata.metadata
+ if m then
+ local h = s.horizontalheader
+ local c = s.cffinfo
+ local n = s.names
+ h.ascender = m.ascender or h.ascender
+ h.descender = m.descender or h.descender
+ n.copyright = m.copyright or n.copyright
+ n.family = m.familyname or n.familyname
+ n.fullname = m.fullname or n.fullname
+ n.fontname = m.fontname or n.fontname
+ n.subfamily = m.subfamilyname or n.subfamilyname
+ n.version = m.version or n.version
+ setmetatableindex(h,m)
+ setmetatableindex(c,m)
+ setmetatableindex(n,m)
+ end
+ mainwriters["opentype"](details)
+ end
+
+ do
+
+ -- The methods might become plugins.
+
+ local methods = { }
+
+ local pdfimage = lpdf.epdf.image
+ local openpdf = pdfimage.open
+ local closepdf = pdfimage.close
+ local copypage = pdfimage.copy
+
+ local embedimage = images.embed
+
+ local f_glyph = formatters["G%d"]
+ local f_char = formatters["BT /V%d 1 Tf [<%04X>] TJ ET"]
+ local f_width = formatters["%.6N 0 d0"]
+ local f_index = formatters["I%d"]
+ local f_image_xy = formatters["%.6N 0 d0 1 0 0 1 %.6N %.6N cm /%s Do"]
+ local f_image_c = formatters["/%s Do"]
+ local f_image_c_xy = formatters["%.6N 0 0 %.6N %.6N %.6N cm /%s Do"]
+ local f_image_w = formatters["%.6N 0 d0 %s"]
+ local f_image_d = formatters["%.6N 0 d0 1 0 0 1 0 %.6N cm /%s Do"]
+ local f_stream = formatters["%.6N 0 d0 %s"]
+ local f_stream_c = formatters["%.6N 0 0 0 0 0 d1 %s"]
+ local f_stream_d = formatters["%.6N 0 d0 1 0 0 1 0 %.6N cm %s"]
+ -- local f_stream_s = formatters["%.6N 0 0 %.6N 0 0 cm /%s Do"]
+
+ -- A type 3 font has at most 256 characters and Acrobat also wants a zero slot
+ -- to be filled. We can share a mandate zero slot character. We also need to
+ -- make sure that we use bytes as index in the page stream as well as in the
+ -- tounicode vector.
+
+ -- All this type three magic is a tribute to Don Knuth who uses bitmap fonts in
+ -- his books.
+
+ local c_notdef = nil
+ local r_notdef = nil
+ local w_notdef = nil
+ local fontbbox = nil
+
+ -- pk inclusion (not really tested but not really used either)
+
+ function methods.pk(filename)
+ local pkfullname = resolvers.findpk(basedfontname,resolution)
+ if not pkfullname or pkfullname == "" then
+ return
+ end
+ local readers = fonts.handlers.tfm.readers
+ local result = readers.loadpk(pkfullname)
+ local convert = readers.pktopdf
+ if not result or result.error then
+ return
+ end
+ local resolution = 600
+ local widthfactor = resolution / 72
+ local scalefactor = 72 / resolution / 10
+ local factor = widthfactor / 65536
+ local function pktopdf(glyph,data)
+ return convert(glyph,data,factor) -- return pdfcode, width
+ end
+ return result.glyphs, scalefactor, pktopdf, false, false
+ end
+
+ -- pdf inclusion
+
+ local used = setmetatableindex("table")
+
+ -- function lpdf.registerfontmethod(name,f)
+ -- if f and not methods[name] then
+ -- methods[name] = f
+ -- end
+ -- end
+
+ function methods.pdf(filename,details)
+ local properties = details.properties
+ local pdfshapes = properties.indexdata[1]
+ local pdfdoc = openpdf(pdfshapes.filename)
+ local xforms = pdfdictionary()
+ local nofglyphs = 0
+ if pdfdoc then
+ local scale = 10 * details.parameters.size/details.parameters.designsize
+ local units = details.parameters.units
+ local factor = units * bpfactor / scale
+ local fixdepth = pdfshapes.fixdepth
+ local useddoc = used[pdfdoc]
+ local function pdftopdf(glyph,data)
+ local width = (data.width or 0) * factor
+ local image = useddoc[glyph]
+ local reference = nil
+ if not image then
+ image = embedimage(copypage(pdfdoc,glyph))
+ nofglyphs = nofglyphs + 1
+ local name = f_glyph(nofglyphs)
+ local stream = nil
+ if fixdepth then
+ local depth = data.depth or 0
+ if depth ~= 0 then
+ local d = data.dropin.descriptions[data.index]
+ local b = d.boundingbox
+ local l = b[1]
+ local r = b[3]
+ local w = r - l
+ local scale = w / d.width
+ local x = l
+ -- local y = - b[4] - b[2] - (d.depth or 0)
+ local y = - (d.depth or 0)
+ local scale = w / (image.width * bpfactor)
+ stream = f_image_c_xy(scale,scale,x,y,name)
+ end
+ end
+ if not stream then
+ stream = f_image_c(name)
+ end
+ useddoc[glyph] = image
+ image.embedded_name = name
+ image.embedded_stream = stream
+ image.embedded_reference = pdfreference(image.objnum)
+ end
+ xforms[image.embedded_name] = image.embedded_reference
+ return f_image_w(width,image.embedded_stream), width
+ end
+ local function closepdf()
+ -- closepdf(pdfdoc)
+ end
+ local function getresources()
+ return pdfdictionary { XObject = xforms }
+ end
+ return pdfshapes, 1/units, pdftopdf, closepdf, getresources
+ end
+ end
+
+ -- box inclusion (todo: we can share identical glyphs if needed but the gain
+ -- is minimal especially when we use compact font mode)
+
+ function methods.box(filename,details)
+ local properties = details.properties
+ local boxes = properties.indexdata[1]
+ local xforms = pdfdictionary()
+ local nofglyphs = 0
+ local scale = 10 * details.parameters.size/details.parameters.designsize
+ local units = details.parameters.units
+ local function boxtopdf(image,data) -- image == glyph
+ nofglyphs = nofglyphs + 1
+ local scale = units / scale -- e.g. 1000 / 12
+ local width = (data.width or 0) * bpfactor * scale
+ local depth = - (data.depth or 0) * bpfactor * scale
+ local name = f_glyph(nofglyphs)
+ local stream = f_image_c_xy(scale,scale,0,depth,name)
+ image.embedded_name = name
+ image.embedded_stream = stream
+ image.embedded_reference = pdfreference(image.objnum)
+ xforms[name] = image.embedded_reference
+ return f_image_w(width,stream), width
+ end
+ local function wrapup()
+ end
+ local function getresources()
+ return pdfdictionary { XObject = xforms }
+ end
+ return boxes, 1/units, boxtopdf, wrapup, getresources
+ end
+
+ -- mps inclusion
+
+ local decompress = gzip.decompress
+ local metapost = metapost
+ local simplemprun = metapost.simple
+ local setparameterset = metapost.setparameterset
+
+ function methods.mps(filename,details)
+ local properties = details.properties
+ local parameters = details.parameters
+ local mpshapes = properties.indexdata[1] -- indexdata will change
+ if mpshapes then
+ local scale = 10 * parameters.size/parameters.designsize
+ local units = mpshapes.units or parameters.units
+ local factor = units * bpfactor / scale
+ local fixdepth = mpshapes.fixdepth
+ local usecolor = mpshapes.usecolor
+ local specification = mpshapes.specification or { }
+ local shapedefinitions = mpshapes.shapes
+ local instance = mpshapes.instance
+ --
+ simplemprun(instance,"begingroup;",true,true)
+ setparameterset("mpsfont",specification)
+ specification.scale = specification.scale or scale
+ specification.parameters = parameters
+ specification.properties = properties
+ specification.parentdata = details.fontdata.parentdata
+ -------------.characters = details.fontdata.characters
+ -------------.descriptions = details.fontdata.descriptions
+ if shapedefinitions then
+ local preamble = shapedefinitions.parameters.preamble
+ if preamble then
+ simplemprun(instance,preamble,true,true)
+ end
+ end
+ --
+ local function mpstopdf(mp,data)
+ local width = data.width
+ if decompress then
+ mp = decompress(mp)
+ end
+ local pdf = simplemprun(instance,mp,true)
+ local width = width * factor
+ if usecolor then
+ return f_stream_c(width,pdf), width
+ elseif fixdepth then
+ local depth = data.depth or 0
+ local height = data.height or 0
+ if depth ~= 0 or height ~= 0 then
+ return f_stream_d(width,(-height-depth)*factor,pdf), width
+ end
+ end
+ return f_stream(width,pdf), width
+ end
+ --
+ local function resetmps()
+ setparameterset("mpsfont")
+ simplemprun(instance,"endgroup;",true,true)
+ specification.parameters = nil
+ specification.properties = nil
+ specification.parentdata = nil
+ -------------.characters = nil
+ -------------.descriptions = nil
+ end
+ --
+ local function getresources()
+ return lpdf.collectedresources {
+ serialize = false,
+ }
+ end
+ --
+ return mpshapes, 1/units, mpstopdf, resetmps, getresources
+ end
+ end
+
+ -- png inclusion
+
+ -- With d1 the image mask is used when given and obeys color. So it is needed for pure bw
+ -- bitmap fonts, so here we really need d0.
+ --
+ -- Acrobat X pro only seems to see the image mask but other viewers are doing it ok. Acrobat
+ -- reader crashes. We really need to add a notdef!
+
+ local files = utilities.files
+ local openfile = files.open
+ local closefile = files.close
+ local setposition = files.setposition
+ local readstring = files.readstring
+
+ function methods.png(filename,details)
+ local properties = details.properties
+ local pngshapes = properties.indexdata[1]
+ if pngshapes then
+ local parameters = details.parameters
+ local png = properties.png
+ local hash = png.hash
+ local xforms = pdfdictionary()
+ local nofglyphs = 0
+ local scale = 10 * parameters.size/parameters.designsize
+ local factor = bpfactor / scale
+ -- local units = parameters.units -- / 1000
+ local units = 1000
+ local filehandle = openfile(details.filename,true)
+ local function pngtopdf(glyph,data)
+ -- local info = graphics.identifiers.png(glyph.data,"string")
+ local offset = glyph.o
+ local size = glyph.s
+ local pdfdata = nil
+ if offset and size then
+ setposition(filehandle,offset)
+ local blob = readstring(filehandle,size)
+ local info = graphics.identifiers.png(blob,"string")
+ info.enforcecmyk = pngshapes.enforcecmyk
+ local image = lpdf.injectors.png(info,"string")
+ local width = (data.width or 0) * factor
+ if image then
+ embedimage(image)
+ nofglyphs = nofglyphs + 1
+ local xoffset = (glyph.x or 0) / units
+ local yoffset = (glyph.y or 0) / units
+ local name = f_glyph(nofglyphs)
+ xforms[name] = pdfreference(image.objnum)
+ pdfdata = f_image_xy(width,xoffset,yoffset,name)
+ end
+ end
+ return pdfdata or f_stream(width), width
+ end
+ local function closepng()
+ if filehandle then
+ closefile(filehandle)
+ end
+ pngshapes = nil
+ end
+ local function getresources()
+ return pdfdictionary { XObject = xforms }
+ end
+ return pngshapes, 1, pngtopdf, closepng, getresources
+ end
+ end
+
+ function methods.color(filename,details)
+ local colrshapes = details.properties.indexdata[1]
+ local colrvalues = details.properties.indexdata[2]
+ local usedfonts = { }
+ local function colrtopdf(description,data)
+ -- descriptions by index
+ local colorlist = description.colors
+ if colorlist then
+ local dropdata = data.dropin
+ local dropid = dropdata.properties.id
+ local dropunits = dropdata.parameters.units -- shared
+ local descriptions = dropdata.descriptions
+ usedfonts[dropid] = dropid
+ local w = description.width or 0
+ local s = #colorlist
+ local l = nil
+ local t = { f_width(w) }
+ local n = 1
+ local d = colrvalues[#colrvalues]
+ for i=1,s do
+ local entry = colorlist[i]
+ local v = colrvalues[entry.class] or d
+ if v and l ~= v then
+ n = n + 1 ; t[n] = v
+ l = v
+ end
+ local e = descriptions[entry.slot]
+ if e then
+ n = n + 1 ; t[n] = f_char(dropid,e.index)
+ end
+ end
+ return concat(t," "), w / dropunits
+ end
+ end
+ local function getresources()
+ return lpdf.collectedresources {
+ serialize = false,
+ fonts = usedfonts,
+ fontprefix = "V",
+ }
+ end
+ return colrshapes, 1, colrtopdf, false, getresources
+ end
+
+ mainwriters["type3"] = function(details)
+ local properties = details.properties
+ local basefontname = properties.basefontname or details.basefontname or properties.name -- messy
+ local askedmethod = properties.method or "pk"
+ local method = methods[askedmethod] or methods.pk
+ if not method then
+ return
+ end
+ local glyphs, scalefactor, glyphtopdf, reset, getresources = method(basedfontname,details)
+ if not glyphs then
+ return
+ end
+ local parameters = details.parameters
+ local object = details.objectnumber
+ local factor = parameters.factor -- normally 1
+ local fontmatrix = pdfarray { scalefactor, 0, 0, scalefactor, 0, 0 }
+ local indices,
+ minindex,
+ maxindex = collectindices(details.fontdata.characters,details.indices)
+ local widths = pdfarray()
+ local differences = pdfarray()
+ local charprocs = pdfdictionary()
+ local basefont = pdfconstant(basefontname)
+ local d = 0
+ local w = 0
+ local forcenotdef = minindex > 0
+ local lastindex = -0xFF
+ if forcenotdef then
+ widths[0] = 0
+ minindex = 0
+ lastindex = 0
+ d = 2
+ if not c_notdef then
+ w_notdef = 0
+ c_notdef = pdfconstant(".notdef")
+ r_notdef = pdfreference(pdfflushstreamobject("0 0 d0"))
+ end
+ differences[1] = w_notdef
+ differences[2] = c_notdef
+ charprocs[".notdef"] = r_notdef
+ end
+
+ for i=1,maxindex-minindex+1 do
+ widths[i] = 0
+ end
+
+ for index, data in sortedhash(indices) do
+ local name = f_index(index)
+ local glyph = glyphs[index]
+ if glyph then
+ local stream, width = glyphtopdf(glyph,data)
+ if stream then
+ if index - 1 ~= lastindex then
+ d = d + 1 differences[d] = index
+ end
+ lastindex = index
+ d = d + 1 differences[d] = pdfconstant(name)
+ charprocs[name] = pdfreference(pdfflushstreamobject(stream))
+ widths[index-minindex+1] = width
+ end
+ else
+ report_fonts("missing glyph %i in type3 font %a",index,basefontname)
+ end
+ end
+ if not fontbbox then
+ -- The specification permits zero values and these are actually also more
+ -- robust as then there are no assumptions and no accuracy is needed.
+ fontbbox = pdfarray { 0, 0, 0, 0 }
+ end
+ local encoding = pdfdictionary {
+ Type = pdfconstant("Encoding"),
+ Differences = differences,
+ }
+ local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,false)
+ local resources = getresources and getresources()
+ if not resources or not next(resources) then
+ -- resources = lpdf.procset(true)
+ resources = nil
+ end
+ local descriptor = pdfdictionary {
+ -- most is optional in type3
+ Type = pdfconstant("FontDescriptor"),
+ FontName = basefont,
+ Flags = 4,
+ ItalicAngle = 0,
+ }
+ local parent = pdfdictionary {
+ Type = pdfconstant("Font"),
+ Subtype = pdfconstant("Type3"),
+ Name = basefont,
+ FontBBox = fontbbox,
+ FontMatrix = fontmatrix,
+ CharProcs = pdfreference(pdfflushobject(charprocs)),
+ Encoding = pdfreference(pdfflushobject(encoding)),
+ FirstChar = minindex,
+ LastChar = maxindex,
+ Widths = pdfreference(pdfflushobject(widths)),
+ FontDescriptor = pdfreference(pdfflushobject(descriptor)),
+ Resources = resources,
+ ToUnicode = tounicode and pdfreference(pdfflushstreamobject(tounicode)),
+ }
+ pdfflushobject(object,parent)
+ if reset then
+ reset()
+ end
+ end
+
+ end
+
+end
+
+-- writingmode
+
+local usedfonts = fonts.hashes.identifiers -- for now
+local noffonts = 0
+
+-- The main injector.
+
+-- here we need to test for sharing otherwise we reserve too many
+-- objects
+
+local getstreamhash = fonts.handlers.otf.getstreamhash
+local loadstreamdata = fonts.handlers.otf.loadstreamdata
+
+-- we can actually now number upwards (so not use fontid in /F)
+
+local objects = setmetatableindex(function(t,k)
+ local v
+ if type(k) == "number" then
+ local h = getstreamhash(k)
+ v = rawget(t,h)
+ if not v then
+ v = pdfreserveobject()
+ t[h] = v
+ end
+ if trace_fonts then
+ report_fonts("font id %i bound to hash %s and object %i",k,h,v)
+ end
+ else
+ -- no problem as it can be svg only
+ -- report_fonts("fatal error, hash %s asked but not used",k,h,v)
+ v = pdfreserveobject()
+ t[k] = v
+ end
+ return v
+end)
+
+local n = 0
+
+local names = setmetatableindex(function(t,k)
+ local v
+ if type(k) == "number" then
+ local h = getstreamhash(k)
+ v = rawget(t,h)
+ if not v then
+ n = n + 1
+ v = n
+ t[h] = v
+ end
+ if trace_fonts then
+ report_fonts("font id %i bound to hash %s and name %i",k,h,n)
+ end
+ end
+ t[k] = v
+ return v
+end)
+
+function lpdf.flushfonts()
+
+ local mainfonts = { }
+
+ statistics.starttiming(objects)
+
+ for fontid, used in sortedhash(lpdf.usedcharacters) do
+
+ -- for a bitmap we need a different hash unless we stick to a fixed high
+ -- resolution which makes much sense
+
+ local hash = getstreamhash(fontid)
+ if hash then
+ local parent = mainfonts[hash]
+ if not parent then
+ local fontdata = usedfonts[fontid]
+ local rawdata = fontdata.shared and fontdata.shared.rawdata
+ local resources = fontdata.resources
+ local properties = fontdata.properties -- writingmode and type3
+ local parameters = fontdata.parameters -- used in type3
+ if not rawdata then
+ -- we have a virtual font that loaded directly ... at some point i will
+ -- sort this out (in readanddefine we need to do a bit more) .. the problem
+ -- is that we have a hybrid font then
+ for xfontid, xfontdata in next, fonts.hashes.identifiers do
+ if fontid ~= xfontid then
+ local xhash = getstreamhash(xfontid)
+ if hash == xhash then
+ rawdata = xfontdata.shared and xfontdata.shared.rawdata
+ if rawdata then
+ resources = xfontdata.resources
+ properties = xfontdata.properties
+ parameters = xfontdata.parameters
+ break
+ end
+ end
+ end
+ end
+ end
+ if rawdata then
+ parent = {
+ hash = hash,
+ fontdata = fontdata,
+ filename = resources.filename or properties.filename or "unset",
+ indices = { },
+ rawdata = rawdata,
+ properties = properties, -- we assume consistency
+ parameters = parameters, -- we assume consistency
+ streams = { },
+ objectnumber = objects[hash],
+ basefontname = subsetname(properties.psname or properties.name or "unset"),
+ name = names[hash],
+ }
+ mainfonts[hash] = parent
+ noffonts = noffonts + 1
+ end
+ end
+ if parent then
+ local indices = parent.indices
+ for k in next, used do
+ indices[k] = true
+ end
+ end
+ end
+ end
+
+ -- this is no not yet ok for tfm / type 1 .. we need to move the nested blobs ourside the loop
+
+ for hash, details in sortedhash(mainfonts) do
+ local filename = details.filename
+ if next(details.indices) then
+ if trace_fonts then
+ report_fonts("embedding %a hashed as %a",filename,hash)
+ end
+ local properties = details.properties
+ local bitmap = properties.usedbitmap
+ local method = properties.method -- will be pk | pdf | svg | ...
+ if bitmap or method then
+ local format = "type3"
+ local writer = mainwriters[format]
+ if writer then
+ if trace_fonts then
+ report_fonts("using main writer %a",format)
+ end
+ writer(details)
+ end
+ else
+ local format = properties.format
+ local writer = mainwriters[format]
+ if not writer then
+ -- This will move to the tpk module where we will also deal
+ -- with bitmaps then.
+ local encoding, pfbfile, encfile = getmapentry(filename)
+ if trace_fonts then
+ report_fonts("file %a resolved to encoding %a and file %a",filename,encoding,pfbfile)
+ end
+ if encoding and pfbfile then
+ filename = pfbfile
+ format = "type1"
+ --
+ -- another (temp) hack
+ local size = details.fontdata.parameters.size
+ local factor = details.fontdata.parameters.factor
+ local descriptions = { }
+ local characters = details.fontdata.characters
+ --
+ local names, _, _, metadata = fonts.constructors.handlers.pfb.loadvector(pfbfile)
+ local reverse = table.swapped(names)
+ local vector = encoding.vector
+ local indices = details.indices
+ local remapped = { }
+ local factor = bpfactor * size / 65536
+ for k, v in next, indices do
+ local name = vector[k]
+ local index = reverse[name] or 0
+ local width = factor * (characters[k].width or 0)
+ descriptions[k] = {
+ width = width,
+ index = index,
+ name = name,
+ }
+ remapped[index] = true
+ end
+ details.indices = remapped
+ --
+ details.rawdata.descriptions = descriptions
+ details.filename = filename
+ details.rawdata.metadata = { }
+ --
+ properties.filename = filename
+ properties.format = format
+ writer = mainwriters[format]
+ end
+ end
+ if not writer then
+ local pfbfile = file.replacesuffix(filename,"pfb")
+ if encoding and pfbfile then
+ filename = pfbfile
+ format = "type1"
+ --
+ -- another (temp) hack
+ local size = details.fontdata.parameters.size
+ local factor = details.fontdata.parameters.factor
+ local descriptions = { }
+ local characters = details.fontdata.characters
+ --
+ local names, _, _, metadata = fonts.constructors.handlers.pfb.loadvector(pfbfile)
+ local reverse = table.swapped(names)
+ local vector = encoding.vector
+ local indices = details.indices
+ local remapped = { }
+ local factor = bpfactor * size / 65536
+ for k, v in next, indices do
+ local name = vector[k]
+ local index = reverse[name] or 0
+ local width = factor * (characters[k].width or 0)
+ descriptions[k] = {
+ width = width,
+ index = index,
+ name = name,
+ }
+ remapped[index] = true
+ end
+ details.indices = remapped
+ --
+ details.rawdata.descriptions = descriptions
+ details.filename = filename
+ details.rawdata.metadata = { }
+ --
+ properties.filename = filename
+ properties.format = format
+ writer = mainwriters[format]
+ end
+ end
+ if writer then
+ if trace_fonts then
+ report_fonts("using main writer %a",format)
+ end
+ -- better move this test to the writers .. cleaner
+ local streams = loadstreamdata(details.fontdata)
+ if streams and streams.fontheader and streams.names then
+ details.streams = streams
+ writer(details)
+ details.streams = { }
+ elseif trace_fonts then
+ -- can be ok for e.g. emoji
+ report_fonts("no streams in %a",filename)
+ end
+ -- free some memory
+ else -- if trace_fonts then
+ report_fonts("no %a writer for %a",format,filename)
+ end
+ end
+ else -- not problem for svg ...
+ -- report_fonts("no indices for %a",filename)
+ end
+ if trace_fonts then
+ report_fonts("embedded indices: % t",table.sortedkeys(details.indices))
+ end
+ mainfonts[details.hash] = false -- done
+ end
+
+ statistics.stoptiming(objects)
+
+end
+
+statistics.register("font embedding time",function()
+ if noffonts > 0 then
+ return format("%s seconds, %s fonts", statistics.elapsedtime(objects),noffonts)
+ end
+end)
+
+-- this is temporary
+
+function lpdf.setomitcidset(v)
+ -- dummy: no longer needed
+ includecidset = not toboolean(v)
+end
+
+function lpdf.setomitcharset(v)
+ -- dummy
+end
+
+function lpdf.getfontobjectnumber(k)
+ return objects[k]
+end
+
+function lpdf.getfontname(k)
+ return names[k]
+end
+
+-- local done = false -- todo:
+
+-- updaters.register("backend.update",function()
+-- if not done then
+ lpdf.registerdocumentfinalizer(lpdf.flushfonts,1,"wrapping up fonts")
+-- done = true
+-- end
+-- end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-enc.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-enc.lmt
new file mode 100644
index 00000000000..090fb15cd5d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-enc.lmt
@@ -0,0 +1,157 @@
+if not modules then modules = { } end modules ['lpdf-enc'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- delayed loading
+
+local pdfconstant = lpdf.constant
+
+return lpdf.dictionary {
+ Type = pdfconstant("Encoding"),
+ Differences = lpdf.array {
+ 24,
+ pdfconstant("breve"),
+ pdfconstant("caron"),
+ pdfconstant("circumflex"),
+ pdfconstant("dotaccent"),
+ pdfconstant("hungarumlaut"),
+ pdfconstant("ogonek"),
+ pdfconstant("ring"),
+ pdfconstant("tilde"),
+ 39,
+ pdfconstant("quotesingle"),
+ 96,
+ pdfconstant("grave"),
+ 128,
+ pdfconstant("bullet"),
+ pdfconstant("dagger"),
+ pdfconstant("daggerdbl"),
+ pdfconstant("ellipsis"),
+ pdfconstant("emdash"),
+ pdfconstant("endash"),
+ pdfconstant("florin"),
+ pdfconstant("fraction"),
+ pdfconstant("guilsinglleft"),
+ pdfconstant("guilsinglright"),
+ pdfconstant("minus"),
+ pdfconstant("perthousand"),
+ pdfconstant("quotedblbase"),
+ pdfconstant("quotedblleft"),
+ pdfconstant("quotedblright"),
+ pdfconstant("quoteleft"),
+ pdfconstant("quoteright"),
+ pdfconstant("quotesinglbase"),
+ pdfconstant("trademark"),
+ pdfconstant("fi"),
+ pdfconstant("fl"),
+ pdfconstant("Lslash"),
+ pdfconstant("OE"),
+ pdfconstant("Scaron"),
+ pdfconstant("Ydieresis"),
+ pdfconstant("Zcaron"),
+ pdfconstant("dotlessi"),
+ pdfconstant("lslash"),
+ pdfconstant("oe"),
+ pdfconstant("scaron"),
+ pdfconstant("zcaron"),
+ 160,
+ pdfconstant("Euro"),
+ 164,
+ pdfconstant("currency"),
+ 166,
+ pdfconstant("brokenbar"),
+ 168,
+ pdfconstant("dieresis"),
+ pdfconstant("copyright"),
+ pdfconstant("ordfeminine"),
+ 172,
+ pdfconstant("logicalnot"),
+ pdfconstant(".notdef"),
+ pdfconstant("registered"),
+ pdfconstant("macron"),
+ pdfconstant("degree"),
+ pdfconstant("plusminus"),
+ pdfconstant("twosuperior"),
+ pdfconstant("threesuperior"),
+ pdfconstant("acute"),
+ pdfconstant("mu"),
+ 183,
+ pdfconstant("periodcentered"),
+ pdfconstant("cedilla"),
+ pdfconstant("onesuperior"),
+ pdfconstant("ordmasculine"),
+ 188,
+ pdfconstant("onequarter"),
+ pdfconstant("onehalf"),
+ pdfconstant("threequarters"),
+ 192,
+ pdfconstant("Agrave"),
+ pdfconstant("Aacute"),
+ pdfconstant("Acircumflex"),
+ pdfconstant("Atilde"),
+ pdfconstant("Adieresis"),
+ pdfconstant("Aring"),
+ pdfconstant("AE"),
+ pdfconstant("Ccedilla"),
+ pdfconstant("Egrave"),
+ pdfconstant("Eacute"),
+ pdfconstant("Ecircumflex"),
+ pdfconstant("Edieresis"),
+ pdfconstant("Igrave"),
+ pdfconstant("Iacute"),
+ pdfconstant("Icircumflex"),
+ pdfconstant("Idieresis"),
+ pdfconstant("Eth"),
+ pdfconstant("Ntilde"),
+ pdfconstant("Ograve"),
+ pdfconstant("Oacute"),
+ pdfconstant("Ocircumflex"),
+ pdfconstant("Otilde"),
+ pdfconstant("Odieresis"),
+ pdfconstant("multiply"),
+ pdfconstant("Oslash"),
+ pdfconstant("Ugrave"),
+ pdfconstant("Uacute"),
+ pdfconstant("Ucircumflex"),
+ pdfconstant("Udieresis"),
+ pdfconstant("Yacute"),
+ pdfconstant("Thorn"),
+ pdfconstant("germandbls"),
+ pdfconstant("agrave"),
+ pdfconstant("aacute"),
+ pdfconstant("acircumflex"),
+ pdfconstant("atilde"),
+ pdfconstant("adieresis"),
+ pdfconstant("aring"),
+ pdfconstant("ae"),
+ pdfconstant("ccedilla"),
+ pdfconstant("egrave"),
+ pdfconstant("eacute"),
+ pdfconstant("ecircumflex"),
+ pdfconstant("edieresis"),
+ pdfconstant("igrave"),
+ pdfconstant("iacute"),
+ pdfconstant("icircumflex"),
+ pdfconstant("idieresis"),
+ pdfconstant("eth"),
+ pdfconstant("ntilde"),
+ pdfconstant("ograve"),
+ pdfconstant("oacute"),
+ pdfconstant("ocircumflex"),
+ pdfconstant("otilde"),
+ pdfconstant("odieresis"),
+ pdfconstant("divide"),
+ pdfconstant("oslash"),
+ pdfconstant("ugrave"),
+ pdfconstant("uacute"),
+ pdfconstant("ucircumflex"),
+ pdfconstant("udieresis"),
+ pdfconstant("yacute"),
+ pdfconstant("thorn"),
+ pdfconstant("ydieresis"),
+ },
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-epa.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-epa.lmt
new file mode 100644
index 00000000000..b37e9c0432a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-epa.lmt
@@ -0,0 +1,1107 @@
+if not modules then modules = { } end modules ['lpdf-epa'] = {
+ version = 1.001,
+ comment = "companion to lpdf-epa.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Links can also have quadpoint
+
+-- embedded files ... not bound to a page
+
+local type, tonumber, next = type, tonumber, next
+local format, gsub, lower, find = string.format, string.gsub, string.lower, string.find
+local formatters = string.formatters
+local concat, merged = table.concat, table.merged
+local abs = math.abs
+local expandname = file.expandname
+local allocate = utilities.storage.allocate
+local bor, band = bit32.bor, bit32.band
+local isfile = lfs.isfile
+
+local trace_links = false trackers.register("figures.links", function(v) trace_links = v end)
+local trace_comments = false trackers.register("figures.comments", function(v) trace_comments = v end)
+local trace_fields = false trackers.register("figures.fields", function(v) trace_fields = v end)
+local trace_outlines = false trackers.register("figures.outlines", function(v) trace_outlines = v end)
+
+local report_link = logs.reporter("backend","link")
+local report_comment = logs.reporter("backend","comment")
+local report_field = logs.reporter("backend","field")
+local report_outline = logs.reporter("backend","outline")
+
+local lpdf = lpdf
+local backends = backends
+local context = context
+
+local nodeinjections = backends.pdf.nodeinjections
+
+local setmacro = tokens.setters.macro
+
+local pdfarray = lpdf.array
+local pdfdictionary = lpdf.dictionary
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+
+local pdfreserveobject
+local pdfgetpos
+
+updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+ pdfgetpos = lpdf.getpos
+end)
+
+local pdfcopyboolean = lpdf.copyboolean
+local pdfcopyunicode = lpdf.copyunicode
+local pdfcopyarray = lpdf.copyarray
+local pdfcopydictionary = lpdf.copydictionary
+local pdfcopynumber = lpdf.copynumber
+local pdfcopyinteger = lpdf.copyinteger
+local pdfcopystring = lpdf.copystring
+local pdfcopyconstant = lpdf.copyconstant
+
+local createimage = images.create
+local embedimage = images.embed
+
+local hpack_node = nodes.hpack
+
+local loadpdffile = lpdf.epdf.load
+
+local nameonly = file.nameonly
+
+local variables = interfaces.variables
+local codeinjections = backends.pdf.codeinjections
+----- urlescaper = lpegpatterns.urlescaper
+----- utftohigh = lpegpatterns.utftohigh
+local escapetex = characters.filters.utf.private.escape
+
+local bookmarks = structures.bookmarks
+
+local maxdimen = 0x3FFFFFFF -- 2^30-1
+
+local bpfactor = number.dimenfactors.bp
+
+local layerspec = {
+ "epdfcontent"
+}
+
+local getpos = function() getpos = backends.codeinjections.getpos return getpos() end
+
+local collected = allocate()
+local tobesaved = allocate()
+
+local jobembedded = {
+ collected = collected,
+ tobesaved = tobesaved,
+}
+
+job.embedded = jobembedded
+
+local function initializer()
+ tobesaved = jobembedded.tobesaved
+ collected = jobembedded.collected
+end
+
+job.register('job.embedded.collected',tobesaved,initializer)
+
+local function validdocument(specification)
+ if figures and not specification then
+ specification = figures and figures.current()
+ specification = specification and specification.status
+ end
+ if specification then
+ local fullname = specification.fullname
+ local expanded = lower(expandname(fullname))
+ -- we could add a check for duplicate page insertion
+ tobesaved[expanded] = true
+ --- but that is messy anyway so we forget about it
+ return specification, fullname, loadpdffile(fullname) -- costs time
+ end
+end
+
+local function getmediasize(specification,pagedata)
+ local xscale = specification.xscale or 1
+ local yscale = specification.yscale or 1
+ ----- size = specification.size or "crop" -- todo
+ local mediabox = pagedata.MediaBox
+ local llx = mediabox[1]
+ local lly = mediabox[2]
+ local urx = mediabox[3]
+ local ury = mediabox[4]
+ local width = xscale * (urx - llx) -- \\overlaywidth, \\overlayheight
+ local height = yscale * (ury - lly) -- \\overlaywidth, \\overlayheight
+ return llx, lly, urx, ury, width, height, xscale, yscale
+end
+
+local function getdimensions(annotation,llx,lly,xscale,yscale,width,height,report)
+ local rectangle = annotation.Rect
+ local a_llx = rectangle[1]
+ local a_lly = rectangle[2]
+ local a_urx = rectangle[3]
+ local a_ury = rectangle[4]
+ local x = xscale * (a_llx - llx)
+ local y = yscale * (a_lly - lly)
+ local w = xscale * (a_urx - a_llx)
+ local h = yscale * (a_ury - a_lly)
+ if w > width or h > height or w < 0 or h < 0 or abs(x) > (maxdimen/2) or abs(y) > (maxdimen/2) then
+ report("broken rectangle [%.6F %.6F %.6F %.6F] (max: %.6F)",a_llx,a_lly,a_urx,a_ury,maxdimen/2)
+ return
+ end
+ return x, y, w, h, a_llx, a_lly, a_urx, a_ury
+end
+
+local layerused = false
+
+-- local function initializelayer(height,width)
+-- if not layerused then
+-- context.definelayer(layerspec, { height = height .. "bp", width = width .. "bp" })
+-- layerused = true
+-- end
+-- end
+
+local function initializelayer(height,width)
+-- if not layerused then
+ context.setuplayer(layerspec, { height = height .. "bp", width = width .. "bp" })
+ layerused = true
+-- end
+end
+
+function codeinjections.flushmergelayer()
+ if layerused then
+ context.flushlayer(layerspec)
+ layerused = false
+ end
+end
+
+local f_namespace = formatters["lpdf-epa-%s-"]
+
+local function makenamespace(filename)
+ filename = gsub(lower(nameonly(filename)),"[^%a%d]+","-")
+ return f_namespace(filename)
+end
+
+local function add_link(x,y,w,h,destination,what)
+ x = x .. "bp"
+ y = y .. "bp"
+ w = w .. "bp"
+ h = h .. "bp"
+ if trace_links then
+ report_link("destination %a, type %a, dx %s, dy %s, wd %s, ht %s",destination,what,x,y,w,h)
+ end
+ local locationspec = { -- predefining saves time
+ x = x,
+ y = y,
+ preset = "leftbottom",
+ }
+ local buttonspec = {
+ width = w,
+ height = h,
+ offset = variables.overlay,
+ frame = trace_links and variables.on or variables.off,
+ }
+ context.setlayer (
+ layerspec,
+ locationspec,
+ function() context.button ( buttonspec, "", { destination } ) end
+ -- context.nested.button(buttonspec, "", { destination }) -- time this
+ )
+end
+
+local function link_goto(x,y,w,h,document,annotation,pagedata,namespace)
+ local a = annotation.A
+ if a then
+ local destination = a.D -- [ 18 0 R /Fit ]
+ local what = "page"
+ if type(destination) == "string" then
+ local destinations = document.destinations
+ local wanted = destinations[destination]
+ destination = wanted and wanted.D -- is this ok? isn't it destination already a string?
+ if destination then what = "named" end
+ end
+ local pagedata = destination and destination[1]
+ if pagedata then
+ local destinationpage = pagedata.number
+ if destinationpage then
+ add_link(x,y,w,h,namespace .. destinationpage,what)
+ end
+ end
+ end
+end
+
+local function link_uri(x,y,w,h,document,annotation)
+ local url = annotation.A.URI
+ if url then
+ -- url = lpegmatch(urlescaper,url)
+ -- url = lpegmatch(utftohigh,url)
+ url = escapetex(url)
+ add_link(x,y,w,h,formatters["url(%s)"](url),"url")
+ end
+end
+
+-- The rules in PDF on what a 'file specification' is, is in fact quite elaborate
+-- (see section 3.10 in the 1.7 reference) so we need to test for string as well
+-- as a table. TH/20140916
+
+-- When embedded is set then files need to have page references which is seldom the
+-- case but you can generate them with context:
+--
+-- \setupinteraction[state=start,page={page,page}]
+--
+-- see tests/mkiv/interaction/cross[1|2|3].tex for an example
+
+local embedded = false directives.register("figures.embedded", function(v) embedded = v end)
+local reported = { }
+
+local function link_file(x,y,w,h,document,annotation)
+ local a = annotation.A
+ if a then
+ local filename = a.F
+ if type(filename) == "table" then
+ filename = filename.F
+ end
+ if filename then
+ filename = escapetex(filename)
+ local destination = a.D
+ if not destination then
+ add_link(x,y,w,h,formatters["file(%s)"](filename),"file")
+ elseif type(destination) == "string" then
+ add_link(x,y,w,h,formatters["%s::%s"](filename,destination),"file (named)")
+ else
+ -- hm, zero offset so maybe: destination + 1
+ destination = tonumber(destination[1]) -- array
+ if destination then
+ destination = destination + 1
+ local loaded = collected[lower(expandname(filename))]
+ if embedded and loaded then
+ add_link(x,y,w,h,makenamespace(filename) .. destination,what)
+ else
+ if loaded and not reported[filename] then
+ report_link("reference to an also loaded file %a, consider using directive: figures.embedded",filename)
+ reported[filename] = true
+ end
+ add_link(x,y,w,h,formatters["%s::page(%s)"](filename,destination),"file (page)")
+ end
+ else
+ add_link(x,y,w,h,formatters["file(%s)"](filename),"file")
+ end
+ end
+ end
+ end
+end
+
+-- maybe handler per subtype and then one loop but then what about order ...
+
+function codeinjections.mergereferences(specification)
+ local specification, fullname, document = validdocument(specification)
+ if not document then
+ return ""
+ end
+ local pagenumber = specification.page or 1
+ local pagedata = document.pages[pagenumber]
+ local annotations = pagedata and pagedata.Annots
+ local namespace = makenamespace(fullname)
+ local reference = namespace .. pagenumber
+ if annotations and #annotations > 0 then
+ local llx, lly, urx, ury, width, height, xscale, yscale = getmediasize(specification,pagedata,xscale,yscale)
+ initializelayer(height,width)
+ for i=1,#annotations do
+ local annotation = annotations[i]
+ if annotation then
+ if annotation.Subtype == "Link" then
+ local a = annotation.A
+ if not a then
+ local d = annotation.Dest
+ if d then
+ annotation.A = { S = "GoTo", D = d } -- no need for a dict
+ end
+ end
+ if not a then
+ report_link("missing link annotation")
+ else
+ local x, y, w, h = getdimensions(annotation,llx,lly,xscale,yscale,width,height,report_link)
+ if x then
+ local linktype = a.S
+ if linktype == "GoTo" then
+ link_goto(x,y,w,h,document,annotation,pagedata,namespace)
+ elseif linktype == "GoToR" then
+ link_file(x,y,w,h,document,annotation)
+ elseif linktype == "URI" then
+ link_uri(x,y,w,h,document,annotation)
+ elseif trace_links then
+ report_link("unsupported link annotation %a",linktype)
+ end
+ end
+ end
+ end
+ elseif trace_links then
+ report_link("broken annotation, index %a",i)
+ end
+ end
+ end
+ -- moved outside previous test
+ setmacro("mergedfigurereference",reference,"global")
+ if trace_links then
+ report_link("setting figure reference to %a",reference)
+ end
+ specification.reference = reference
+ return namespace
+end
+
+function codeinjections.mergeviewerlayers(specification)
+ -- todo: parse included page for layers .. or only for whole document inclusion
+ if true then
+ return
+ end
+ local specification, fullname, document = validdocument(specification)
+ if not document then
+ return ""
+ end
+ local namespace = makenamespace(fullname)
+ local layers = document.layers
+ if layers then
+ for i=1,#layers do
+ local layer = layers[i]
+ if layer then
+ local tag = namespace .. gsub(layer," ",":")
+ local title = tag
+ if trace_links then
+ report_link("using layer %a",tag)
+ end
+ attributes.viewerlayers.define { -- also does some cleaning
+ tag = tag, -- todo: #3A or so
+ title = title,
+ visible = variables.start,
+ editable = variables.yes,
+ printable = variables.yes,
+ }
+ codeinjections.useviewerlayer(tag)
+ elseif trace_links then
+ report_link("broken layer, index %a",i)
+ end
+ end
+ end
+end
+
+-- It took a bit of puzzling and playing around to come to the following
+-- implementation. In the end it looks simple but as usual it takes a while
+-- to see what the specification (and implementation) boils down to. Lots of
+-- shared properties and such. The scaling took some trial and error as
+-- viewers differ. I had to extend some low level helpers to make it more
+-- comfortable. Hm, the specification is somewhat incomplete as some fields
+-- are permitted even if not mentioned so in the end we can share more code.
+--
+-- If all works ok, we can get rid of some copies which saves time and space.
+
+local commentlike = {
+ Text = "text",
+ FreeText = "freetext",
+ Line = "line",
+ Square = "shape",
+ Circle = "shape",
+ Polygon = "poly",
+ PolyLine = "poly",
+ Highlight = "markup",
+ Underline = "markup",
+ Squiggly = "markup",
+ StrikeOut = "markup",
+ Caret = "text",
+ Stamp = "stamp",
+ Ink = "ink",
+ Popup = "popup",
+}
+
+local function copyBS(v) -- dict can be shared
+ if v then
+ -- return pdfdictionary {
+ -- Type = copypdfconstant(V.Type),
+ -- W = copypdfnumber (V.W),
+ -- S = copypdfstring (V.S),
+ -- D = copypdfarray (V.D),
+ -- }
+ return copypdfdictionary(v)
+ end
+end
+
+local function copyBE(v) -- dict can be shared
+ if v then
+ -- return pdfdictionary {
+ -- S = copypdfstring(V.S),
+ -- I = copypdfnumber(V.I),
+ -- }
+ return copypdfdictionary(v)
+ end
+end
+
+local function copyBorder(v) -- dict can be shared
+ if v then
+ -- todo
+ return copypdfarray(v)
+ end
+end
+
+local function copyPopup(v,references)
+ if v then
+ local p = references[v]
+ if p then
+ return pdfreference(p)
+ end
+ end
+end
+
+local function copyParent(v,references)
+ if v then
+ local p = references[v]
+ if p then
+ return pdfreference(p)
+ end
+ end
+end
+
+local function copyIRT(v,references)
+ if v then
+ local p = references[v]
+ if p then
+ return pdfreference(p)
+ end
+ end
+end
+
+local function copyC(v)
+ if v then
+ -- todo: check color space
+ return pdfcopyarray(v)
+ end
+end
+
+local function finalizer(d,xscale,yscale,a_llx,a_ury)
+ local q = d.QuadPoints or d.Vertices or d.CL
+ if q then
+ return function()
+ local h, v = pdfgetpos() -- already scaled
+ for i=1,#q,2 do
+ q[i] = xscale * q[i] + (h*bpfactor - xscale * a_llx)
+ q[i+1] = yscale * q[i+1] + (v*bpfactor - yscale * a_ury)
+ end
+ return d()
+ end
+ end
+ q = d.InkList or d.Path
+ if q then
+ return function()
+ local h, v = pdfgetpos() -- already scaled
+ for i=1,#q do
+ local q = q[i]
+ for i=1,#q,2 do
+ q[i] = xscale * q[i] + (h*bpfactor - xscale * a_llx)
+ q[i+1] = yscale * q[i+1] + (v*bpfactor - yscale * a_ury)
+ end
+ end
+ return d()
+ end
+ end
+ return d()
+end
+
+local validstamps = {
+ Approved = true,
+ Experimental = true,
+ NotApproved = true,
+ AsIs = true,
+ Expired = true,
+ NotForPublicRelease = true,
+ Confidential = true,
+ Final = true,
+ Sold = true,
+ Departmental = true,
+ ForComment = true,
+ TopSecret = true,
+ Draft = true,
+ ForPublicRelease = true,
+}
+
+-- todo: we can use runlocal instead of steps
+
+local function validStamp(v)
+ local name = "Stamped" -- fallback
+ if v then
+ local ok = validstamps[v]
+ if ok then
+ name = ok
+ else
+ for k in next, validstamps do
+ if find(v,k.."$") then
+ name = k
+ validstamps[v] = k
+ break
+ end
+ end
+ end
+ end
+ -- we temporary return to \TEX:
+ context.predefinesymbol { name }
+ context.step()
+ -- beware, an error is not reported
+ return pdfconstant(name), codeinjections.analyzenormalsymbol(name)
+end
+
+local annotationflags = lpdf.flags.annotations
+
+local function copyF(v,lock) -- todo: bxor 24
+ if lock then
+ v = bor(v or 0,annotationflags.ReadOnly + annotationflags.Locked + annotationflags.LockedContents)
+ end
+ if v then
+ return pdfcopyinteger(v)
+ end
+end
+
+-- Speed is not really an issue so we don't optimize this code too much. In the end (after
+-- testing we end up with less code that we started with.
+
+function codeinjections.mergecomments(specification)
+ local specification, fullname, document = validdocument(specification)
+ if not document then
+ return ""
+ end
+ local pagenumber = specification.page or 1
+ local pagedata = document.pages[pagenumber]
+ local annotations = pagedata and pagedata.Annots
+ if annotations and #annotations > 0 then
+ local llx, lly, urx, ury, width, height, xscale, yscale = getmediasize(specification,pagedata,xscale,yscale)
+ initializelayer(height,width)
+ --
+ local lockflags = specification.lock -- todo: proper parameter
+ local references = { }
+ local usedpopups = { }
+ for i=1,#annotations do
+ local annotation = annotations[i]
+ if annotation then
+ local subtype = annotation.Subtype
+ if commentlike[subtype] then
+ references[annotation] = pdfreserveobject()
+ local p = annotation.Popup
+ if p then
+ usedpopups[p] = true
+ end
+ end
+ end
+ end
+ --
+ for i=1,#annotations do
+ -- we keep the order
+ local annotation = annotations[i]
+ if annotation then
+ local reference = references[annotation]
+ if reference then
+ local subtype = annotation.Subtype
+ local kind = commentlike[subtype]
+ if kind ~= "popup" or usedpopups[annotation] then
+ local x, y, w, h, a_llx, a_lly, a_urx, a_ury = getdimensions(annotation,llx,lly,xscale,yscale,width,height,report_comment)
+ if x then
+ local voffset = h
+ local dictionary = pdfdictionary {
+ Subtype = pdfconstant (subtype),
+ -- common (skipped: P AP AS OC AF BM StructParent)
+ Contents = pdfcopyunicode(annotation.Contents),
+ NM = pdfcopystring (annotation.NM),
+ M = pdfcopystring (annotation.M),
+ F = copyF (annotation.F,lockflags),
+ C = copyC (annotation.C),
+ ca = pdfcopynumber (annotation.ca),
+ CA = pdfcopynumber (annotation.CA),
+ Lang = pdfcopystring (annotation.Lang),
+ -- also common
+ CreationDate = pdfcopystring (annotation.CreationDate),
+ T = pdfcopyunicode(annotation.T),
+ Subj = pdfcopyunicode(annotation.Subj),
+ -- border
+ Border = pdfcopyarray (annotation.Border),
+ BS = copyBS (annotation.BS),
+ BE = copyBE (annotation.BE),
+ -- sort of common
+ Popup = copyPopup (annotation.Popup,references),
+ RC = pdfcopyunicode(annotation.RC) -- string or stream
+ }
+ if kind == "markup" then
+ dictionary.IRT = copyIRT (annotation.IRT,references)
+ dictionary.RT = pdfconstant (annotation.RT)
+ dictionary.IT = pdfcopyconstant (annotation.IT)
+ dictionary.QuadPoints = pdfcopyarray (annotation.QuadPoints)
+ -- dictionary.RD = pdfcopyarray (annotation.RD)
+ elseif kind == "text" then
+ -- somehow F fails to view : /F 24 : bit4=nozoom bit5=norotate
+ dictionary.F = nil
+ dictionary.Open = pdfcopyboolean (annotation.Open)
+ dictionary.Name = pdfcopyunicode (annotation.Name)
+ dictionary.State = pdfcopystring (annotation.State)
+ dictionary.StateModel = pdfcopystring (annotation.StateModel)
+ dictionary.IT = pdfcopyconstant (annotation.IT)
+ dictionary.QuadPoints = pdfcopyarray (annotation.QuadPoints)
+ dictionary.RD = pdfcopyarray (annotation.RD) -- caret
+ dictionary.Sy = pdfcopyconstant (annotation.Sy) -- caret
+ voffset = 0
+ elseif kind == "freetext" then
+ dictionary.DA = pdfcopystring (annotation.DA)
+ dictionary.Q = pdfcopyinteger (annotation.Q)
+ dictionary.DS = pdfcopystring (annotation.DS)
+ dictionary.CL = pdfcopyarray (annotation.CL)
+ dictionary.IT = pdfcopyconstant (annotation.IT)
+ dictionary.LE = pdfcopyconstant (annotation.LE)
+ -- dictionary.RC = pdfcopystring (annotation.RC)
+ elseif kind == "line" then
+ dictionary.LE = pdfcopyarray (annotation.LE)
+ dictionary.IC = pdfcopyarray (annotation.IC)
+ dictionary.LL = pdfcopynumber (annotation.LL)
+ dictionary.LLE = pdfcopynumber (annotation.LLE)
+ dictionary.Cap = pdfcopyboolean (annotation.Cap)
+ dictionary.IT = pdfcopyconstant (annotation.IT)
+ dictionary.LLO = pdfcopynumber (annotation.LLO)
+ dictionary.CP = pdfcopyconstant (annotation.CP)
+ dictionary.Measure = pdfcopydictionary(annotation.Measure) -- names
+ dictionary.CO = pdfcopyarray (annotation.CO)
+ voffset = 0
+ elseif kind == "shape" then
+ dictionary.IC = pdfcopyarray (annotation.IC)
+ -- dictionary.RD = pdfcopyarray (annotation.RD)
+ voffset = 0
+ elseif kind == "stamp" then
+ local name, appearance = validStamp(annotation.Name)
+ dictionary.Name = name
+ dictionary.AP = appearance
+ voffset = 0
+ elseif kind == "ink" then
+ dictionary.InkList = pdfcopyarray (annotation.InkList)
+ elseif kind == "poly" then
+ dictionary.Vertices = pdfcopyarray (annotation.Vertices)
+ -- dictionary.LE = pdfcopyarray (annotation.LE) -- todo: names in array
+ dictionary.IC = pdfcopyarray (annotation.IC)
+ dictionary.IT = pdfcopyconstant (annotation.IT)
+ dictionary.Measure = pdfcopydictionary(annotation.Measure)
+ dictionary.Path = pdfcopyarray (annotation.Path)
+ -- dictionary.RD = pdfcopyarray (annotation.RD)
+ elseif kind == "popup" then
+ dictionary.Open = pdfcopyboolean (annotation.Open)
+ dictionary.Parent = copyParent (annotation.Parent,references)
+ voffset = 0
+ end
+ if dictionary then
+ local locationspec = {
+ x = x .. "bp",
+ y = y .. "bp",
+ voffset = voffset .. "bp",
+ preset = "leftbottom",
+ }
+ local finalize = finalizer(dictionary,xscale,yscale,a_llx,a_ury)
+ context.setlayer(layerspec,locationspec,function()
+ context(hpack_node(nodeinjections.annotation(w/bpfactor,h/bpfactor,0,finalize,reference)))
+ end)
+ end
+ end
+ else
+ -- report_comment("skipping annotation, index %a",i)
+ end
+ end
+ elseif trace_comments then
+ report_comment("broken annotation, index %a",i)
+ end
+ end
+ end
+ return namespace
+end
+
+local widgetflags = lpdf.flags.widgets
+
+local function flagstoset(flag,flags)
+ local t = { }
+ if flags then
+ for k, v in next, flags do
+ if band(flag,v) ~= 0 then
+ t[k] = true
+ end
+ end
+ end
+ return t
+end
+
+-- BS : border style dict
+-- R : rotation 0 90 180 270
+-- BG : background array
+-- CA : caption string
+-- RC : roll over caption
+-- AC : down caption
+-- I/RI/IX : icon streams
+-- IF : fit dictionary
+-- TP : text position number
+
+-- Opt : array of texts
+-- TI : top index
+
+-- V : value
+-- DV : default value
+-- DS : default string
+-- RV : rich
+-- Q : quadding (0=left 1=middle 2=right)
+
+function codeinjections.mergefields(specification)
+ local specification, fullname, document = validdocument(specification)
+ if not document then
+ return ""
+ end
+ local pagenumber = specification.page or 1
+ local pagedata = document.pages[pagenumber]
+ local annotations = pagedata and pagedata.Annots
+ if annotations and #annotations > 0 then
+ local llx, lly, urx, ury, width, height, xscale, yscale = getmediasize(specification,pagedata,xscale,yscale)
+ initializelayer(height,width)
+ --
+ for i=1,#annotations do
+ -- we keep the order
+ local annotation = annotations[i]
+ if annotation then
+ local subtype = annotation.Subtype
+ if subtype == "Widget" then
+ local parent = annotation.Parent or { }
+ local name = annotation.T or parent.T
+ local what = annotation.FT or parent.FT
+ if name and what then
+ local x, y, w, h, a_llx, a_lly, a_urx, a_ury = getdimensions(annotation,llx,lly,xscale,yscale,width,height,report_field)
+ if x then
+ x = x .. "bp"
+ y = y .. "bp"
+ local W, H = w, h
+ w = w .. "bp"
+ h = h .. "bp"
+ if trace_fields then
+ report_field("field %a, type %a, dx %s, dy %s, wd %s, ht %s",name,what,x,y,w,h)
+ end
+ local locationspec = {
+ x = x,
+ y = y,
+ preset = "leftbottom",
+ }
+ --
+ local aflags = flagstoset(annotation.F or parent.F, annotationflags)
+ local wflags = flagstoset(annotation.Ff or parent.Ff, widgetflags)
+ if what == "Tx" then
+ -- DA DV F FT MaxLen MK Q T V | AA OC
+ if wflags.MultiLine then
+ wflags.MultiLine = nil
+ what = "text"
+ else
+ what = "line"
+ end
+ -- via context
+ local fieldspec = {
+ width = w,
+ height = h,
+ offset = variables.overlay,
+ frame = trace_links and variables.on or variables.off,
+ n = annotation.MaxLen or (parent and parent.MaxLen),
+ type = what,
+ option = concat(merged(aflags,wflags),","),
+ }
+ context.setlayer (layerspec,locationspec,function()
+ context.definefieldbody ( { name } , fieldspec )
+ context.fieldbody ( { name } )
+ end)
+ --
+ elseif what == "Btn" then
+ if wflags.Radio or wflags.RadiosInUnison then
+ -- AP AS DA F Ff FT H MK T V | AA OC
+ wflags.Radio = nil
+ wflags.RadiosInUnison = nil
+ what = "radio"
+ elseif wflags.PushButton then
+ -- AP DA F Ff FT H MK T | AA OC
+ --
+ -- Push buttons only have an appearance and some associated
+ -- actions so they are not worth copying.
+ --
+ wflags.PushButton = nil
+ what = "push"
+ else
+ -- AP AS DA F Ff FT H MK T V | OC AA
+ what = "check"
+ -- direct
+ local AP = annotation.AP or (parent and parent.AP)
+ if AP then
+ local a = document.__xrefs__[AP]
+ if a and pdfe.copyappearance then
+ local o = pdfe.copyappearance(document,a)
+ if o then
+ AP = pdfreference(o)
+ end
+ end
+ end
+ local dictionary = pdfdictionary {
+ Subtype = pdfconstant("Widget"),
+ FT = pdfconstant("Btn"),
+ T = pdfcopyunicode(annotation.T or parent.T),
+ F = pdfcopyinteger(annotation.F or parent.F),
+ Ff = pdfcopyinteger(annotation.Ff or parent.Ff),
+ AS = pdfcopyconstant(annotation.AS or (parent and parent.AS)),
+ AP = AP and pdfreference(AP),
+ }
+ local finalize = dictionary()
+ context.setlayer(layerspec,locationspec,function()
+ context(hpack_node(nodeinjections.annotation(W/bpfactor,H/bpfactor,0,finalize)))
+ end)
+ --
+ end
+ elseif what == "Ch" then
+ -- F Ff FT Opt T | AA OC (rest follows)
+ if wflags.PopUp then
+ wflags.PopUp = nil
+ if wflags.Edit then
+ wflags.Edit = nil
+ what = "combo"
+ else
+ what = "popup"
+ end
+ else
+ what = "choice"
+ end
+ elseif what == "Sig" then
+ what = "signature"
+ else
+ what = nil
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+-- Beware, bookmarks can be in pdfdoc encoding or in unicode. However, in mkiv we
+-- write out the strings in unicode (hex). When we read them in, we check for a bom
+-- and convert to utf.
+
+function codeinjections.getbookmarks(filename)
+
+ -- The first version built a nested tree and flattened that afterwards ... but I decided
+ -- to keep it simple and flat.
+
+ local list = bookmarks.extras.get(filename)
+
+ if list then
+ return list
+ else
+ list = { }
+ end
+
+ local document = nil
+
+ if isfile(filename) then
+ document = loadpdffile(filename)
+ else
+ report_outline("unknown file %a",filename)
+ bookmarks.extras.register(filename,list)
+ return list
+ end
+
+ local outlines = document.Catalog.Outlines
+ local pages = document.pages
+ local nofpages = document.nofpages
+ local destinations = document.destinations
+
+ -- I need to check this destination analyzer with the one in annotations .. best share
+ -- code (and not it's inconsistent). On the todo list ...
+
+ local function setdestination(current,entry)
+ local destination = nil
+ local action = current.A
+ if action then
+ local subtype = action.S
+ if subtype == "GoTo" then
+ destination = action.D
+ local kind = type(destination)
+ if kind == "string" then
+ entry.destination = destination
+ destination = destinations[destination]
+ local pagedata = destination and destination[1]
+ if pagedata then
+ entry.realpage = pagedata.number
+ end
+ elseif kind == "table" then
+ local pageref = #destination
+ if pageref then
+ local pagedata = pages[pageref]
+ if pagedata then
+ entry.realpage = pagedata.number
+ end
+ end
+ end
+ -- elseif subtype then
+ -- report("unsupported bookmark action %a",subtype)
+ end
+ else
+ local destination = current.Dest
+ if destination then
+ if type(destination) == "string" then
+ local wanted = destinations[destination]
+ destination = wanted and wanted.D
+ if destination then
+ entry.destination = destination
+ end
+ else
+ local pagedata = destination and destination[1]
+ if pagedata and pagedata.Type == "Page" then
+ entry.realpage = pagedata.number
+ -- else
+ -- report("unsupported bookmark destination (no page)")
+ end
+ end
+ end
+ end
+ end
+
+ local function traverse(current,depth)
+ while current do
+ -- local title = current.Title
+ local title = current("Title") -- can be pdfdoc or unicode
+ if title then
+ local entry = {
+ level = depth,
+ title = title,
+ }
+ list[#list+1] = entry
+ setdestination(current,entry)
+ if trace_outlines then
+ report_outline("%w%s",2*depth,title)
+ end
+ end
+ local first = current.First
+ if first then
+ local current = first
+ while current do
+ local title = current.Title
+ if title and trace_outlines then
+ report_outline("%w%s",2*depth,title)
+ end
+ local entry = {
+ level = depth,
+ title = title,
+ }
+ setdestination(current,entry)
+ list[#list+1] = entry
+ traverse(current.First,depth+1)
+ current = current.Next
+ end
+ end
+ current = current.Next
+ end
+ end
+
+ if outlines then
+ if trace_outlines then
+ report_outline("outline of %a:",document.filename)
+ report_outline()
+ end
+ traverse(outlines,0)
+ if trace_outlines then
+ report_outline()
+ end
+ elseif trace_outlines then
+ report_outline("no outline in %a",document.filename)
+ end
+
+ bookmarks.extras.register(filename,list)
+
+ return list
+
+end
+
+function codeinjections.mergebookmarks(specification)
+ -- codeinjections.getbookmarks(document)
+ if not specification then
+ specification = figures and figures.current()
+ specification = specification and specification.status
+ end
+ if specification then
+ local fullname = specification.fullname
+ local bookmarks = backends.codeinjections.getbookmarks(fullname)
+ local realpage = tonumber(specification.page) or 1
+ for i=1,#bookmarks do
+ local b = bookmarks[i]
+ if not b.usedpage then
+ if b.realpage == realpage then
+ if trace_options then
+ report_outline("using %a at page %a of file %a",b.title,realpage,fullname)
+ end
+ b.usedpage = true
+ b.section = structures.sections.currentsectionindex()
+ b.pageindex = specification.pageindex
+ end
+ end
+ end
+ end
+end
+
+-- A bit more than a placeholder but in the same perspective as
+-- inclusion of comments and fields:
+--
+-- getinfo{ filename = "tt.pdf", metadata = true }
+-- getinfo{ filename = "tt.pdf", page = 1, metadata = "xml" }
+-- getinfo("tt.pdf")
+
+function codeinjections.getinfo(specification)
+ if type(specification) == "string" then
+ specification = { filename = specification }
+ end
+ local filename = specification.filename
+ if type(filename) == "string" and isfile(filename) then
+ local pdffile = loadpdffile(filename)
+ if pdffile then
+ local pagenumber = specification.page or 1
+ local metadata = specification.metadata
+ local catalog = pdffile.Catalog
+ local info = pdffile.Info
+ local pages = pdffile.pages
+ local nofpages = pdffile.nofpages
+ if metadata then
+ local m = catalog.Metadata
+ if m then
+ m = m()
+ if metadata == "xml" then
+ metadata = xml.convert(m)
+ else
+ metadata = m
+ end
+ else
+ metadata = nil
+ end
+ else
+ metadata = nil
+ end
+ if pagenumber > nofpages then
+ pagenumber = nofpages
+ end
+ local nobox = { 0, 0, 0, 0 }
+ local crop = nobox
+ local media = nobox
+ local page = pages[pagenumber]
+ if page then
+ crop = page.CropBox or nobox
+ media = page.MediaBox or crop or nobox
+ end
+ local bbox = crop or media or nobox
+ return {
+ filename = filename,
+ pdfversion = tonumber(catalog.Version),
+ nofpages = nofpages,
+ title = info.Title,
+ creator = info.Creator,
+ producer = info.Producer,
+ creationdate = info.CreationDate,
+ modification = info.ModDate,
+ metadata = metadata,
+ width = bbox[4] - bbox[2],
+ height = bbox[3] - bbox[1],
+ cropbox = { crop[1], crop[2], crop[3], crop[4] }, -- we need access
+ mediabox = { media[1], media[2], media[3], media[4] } , -- we need access
+ }
+ end
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-fld.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-fld.lmt
new file mode 100644
index 00000000000..eacbb085d88
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-fld.lmt
@@ -0,0 +1,1501 @@
+if not modules then modules = { } end modules ['lpdf-fld'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- TURN OFF: preferences -> forms -> highlight -> etc
+
+-- The problem with widgets is that so far each version of acrobat has some
+-- rendering problem. I tried to keep up with this but it makes no sense to do so as
+-- one cannot rely on the viewer not changing. Especially Btn fields are tricky as
+-- their appearences need to be synchronized in the case of children but e.g.
+-- acrobat 10 does not retain the state and forces a check symbol. If you make a
+-- file in acrobat then it has MK entries that seem to overload the already present
+-- appearance streams (they're probably only meant for printing) as it looks like
+-- the viewer has some fallback on (auto generated) MK behaviour built in. So ...
+-- hard to test. Unfortunately not even the default appearance is generated. This
+-- will probably be solved at some point.
+--
+-- Also, for some reason the viewer does not always show custom appearances when
+-- fields are being rolled over or clicked upon, and circles or checks pop up when
+-- you don't expect them. I fear that this kind of instability eventually will kill
+-- pdf forms. After all, the manual says: "individual annotation handlers may ignore
+-- this entry and provide their own appearances" and one might wonder what
+-- 'individual' means here, but effectively this renders the whole concept of
+-- appearances useless.
+--
+-- Okay, here is one observation. A pdf file contains objects and one might consider
+-- each one to be a static entity when read in. However, acrobat starts rendering
+-- and seems to manipulate (appearance streams) of objects in place (this is visible
+-- when the file is saved again). And, combined with some other caching and hashing,
+-- this might give side effects for shared objects. So, it seems that for some cases
+-- one can best be not too clever and not share but duplicate information. Of course
+-- this defeats the whole purpose of these objects. Of course I can be wrong.
+--
+-- A rarther weird side effect of the viewer is that the highlighting of fields
+-- obscures values, unless you uses one of the BS variants, and this makes custum
+-- appearances rather useless as there is no way to control this apart from changing
+-- the viewer preferences. It could of course be a bug but it would be nice if the
+-- highlighting was at least transparent. I have no clue why the built in shapes
+-- work ok (some xform based appearances are generated) while equally valid other
+-- xforms fail. It looks like acrobat appearances come on top (being refered to in
+-- the MK) while custom ones are behind the highlight rectangle. One can disable the
+-- "Show border hover color for fields" option in the preferences. If you load
+-- java-imp-rhh this side effect gets disabled and you get what you expect (it took
+-- me a while to figure out this hack).
+--
+-- When highlighting is enabled, those default symbols flash up, so it looks like we
+-- have some inteference between this setting and custom appearances.
+--
+-- Anyhow, the NeedAppearances is really needed in order to get a rendering for
+-- printing especially when highlighting (those colorfull foregrounds) is on.
+
+local tostring, tonumber, next = tostring, tonumber, next
+local gmatch, lower, format, formatters = string.gmatch, string.lower, string.format, string.formatters
+local lpegmatch = lpeg.match
+local bpfactor, todimen = number.dimenfactors.bp, string.todimen
+local sortedhash = table.sortedhash
+local trace_fields = false trackers.register("backends.fields", function(v) trace_fields = v end)
+
+local report_fields = logs.reporter("backend","fields")
+
+local backends, lpdf = backends, lpdf
+
+local variables = interfaces.variables
+local context = context
+
+local references = structures.references
+local settings_to_array = utilities.parsers.settings_to_array
+
+local pdfbackend = backends.pdf
+
+local nodeinjections = pdfbackend.nodeinjections
+local codeinjections = pdfbackend.codeinjections
+local registrations = pdfbackend.registrations
+
+local registeredsymbol = codeinjections.registeredsymbol
+
+local pdfstream = lpdf.stream
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfstring = lpdf.string
+local pdfconstant = lpdf.constant
+local pdfaction = lpdf.action
+
+local pdfflushobject
+local pdfshareobjectreference
+local pdfshareobject
+local pdfreserveobject
+local pdfpagereference
+local pdfmajorversion
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfshareobjectreference = lpdf.shareobjectreference
+ pdfshareobject = lpdf.shareobject
+ pdfreserveobject = lpdf.reserveobject
+ pdfpagereference = lpdf.pagereference
+ pdfmajorversion = lpdf.majorversion
+end)
+
+local pdfcolor = lpdf.color
+local pdfcolorvalues = lpdf.colorvalues
+local pdflayerreference = lpdf.layerreference
+
+local hpack_node = node.hpack
+
+local submitoutputformat = 0 -- 0=unknown 1=HTML 2=FDF 3=XML => not yet used, needs to be checked
+
+local pdf_widget = pdfconstant("Widget")
+local pdf_tx = pdfconstant("Tx")
+local pdf_sig = pdfconstant("Sig")
+local pdf_ch = pdfconstant("Ch")
+local pdf_btn = pdfconstant("Btn")
+local pdf_yes = pdfconstant("Yes")
+local pdf_off = pdfconstant("Off")
+local pdf_p = pdfconstant("P") -- None Invert Outline Push
+local pdf_n = pdfconstant("N") -- None Invert Outline Push
+--
+local pdf_no_rect = pdfarray { 0, 0, 0, 0 }
+
+local splitter = lpeg.splitat("=>")
+
+local formats = {
+ html = 1, fdf = 2, xml = 3,
+}
+
+function codeinjections.setformsmethod(name)
+ submitoutputformat = formats[lower(name)] or formats.xml
+end
+
+local flag = { -- /Ff
+ ReadOnly = 0x00000001, -- 2^ 0
+ Required = 0x00000002, -- 2^ 1
+ NoExport = 0x00000004, -- 2^ 2
+ MultiLine = 0x00001000, -- 2^12
+ Password = 0x00002000, -- 2^13
+ NoToggleToOff = 0x00004000, -- 2^14
+ Radio = 0x00008000, -- 2^15
+ PushButton = 0x00010000, -- 2^16
+ PopUp = 0x00020000, -- 2^17
+ Edit = 0x00040000, -- 2^18
+ Sort = 0x00080000, -- 2^19
+ FileSelect = 0x00100000, -- 2^20
+ DoNotSpellCheck = 0x00400000, -- 2^22
+ DoNotScroll = 0x00800000, -- 2^23
+ Comb = 0x01000000, -- 2^24
+ RichText = 0x02000000, -- 2^25
+ RadiosInUnison = 0x02000000, -- 2^25
+ CommitOnSelChange = 0x04000000, -- 2^26
+}
+
+local plus = { -- /F
+ Invisible = 0x00000001, -- 2^0
+ Hidden = 0x00000002, -- 2^1
+ Printable = 0x00000004, -- 2^2
+ Print = 0x00000004, -- 2^2
+ NoZoom = 0x00000008, -- 2^3
+ NoRotate = 0x00000010, -- 2^4
+ NoView = 0x00000020, -- 2^5
+ ReadOnly = 0x00000040, -- 2^6
+ Locked = 0x00000080, -- 2^7
+ ToggleNoView = 0x00000100, -- 2^8
+ LockedContents = 0x00000200, -- 2^9
+ AutoView = 0x00000100, -- 2^8
+}
+
+-- todo: check what is interfaced
+
+flag.readonly = flag.ReadOnly
+flag.required = flag.Required
+flag.protected = flag.Password
+flag.sorted = flag.Sort
+flag.unavailable = flag.NoExport
+flag.nocheck = flag.DoNotSpellCheck
+flag.fixed = flag.DoNotScroll
+flag.file = flag.FileSelect
+
+plus.hidden = plus.Hidden
+plus.printable = plus.Printable
+plus.auto = plus.AutoView
+
+lpdf.flags.widgets = flag
+lpdf.flags.annotations = plus
+
+-- some day .. lpeg with function or table
+
+local function fieldflag(specification) -- /Ff
+ local o, n = specification.option, 0
+ if o and o ~= "" then
+ for f in gmatch(o,"[^, ]+") do
+ n = n + (flag[f] or 0)
+ end
+ end
+ return n
+end
+
+local function fieldplus(specification) -- /F
+ local o, n = specification.option, 0
+ if o and o ~= "" then
+ for p in gmatch(o,"[^, ]+") do
+ n = n + (plus[p] or 0)
+ end
+ end
+-- n = n + 4
+ return n
+end
+
+-- keep:
+--
+-- local function checked(what)
+-- local set, bug = references.identify("",what)
+-- if not bug and #set > 0 then
+-- local r, n = pdfaction(set)
+-- return pdfshareobjectreference(r)
+-- end
+-- end
+--
+-- local function fieldactions(specification) -- share actions
+-- local d, a = { }, nil
+-- a = specification.mousedown
+-- or specification.clickin if a and a ~= "" then d.D = checked(a) end
+-- a = specification.mouseup
+-- or specification.clickout if a and a ~= "" then d.U = checked(a) end
+-- a = specification.regionin if a and a ~= "" then d.E = checked(a) end -- Enter
+-- a = specification.regionout if a and a ~= "" then d.X = checked(a) end -- eXit
+-- a = specification.afterkey if a and a ~= "" then d.K = checked(a) end
+-- a = specification.format if a and a ~= "" then d.F = checked(a) end
+-- a = specification.validate if a and a ~= "" then d.V = checked(a) end
+-- a = specification.calculate if a and a ~= "" then d.C = checked(a) end
+-- a = specification.focusin if a and a ~= "" then d.Fo = checked(a) end
+-- a = specification.focusout if a and a ~= "" then d.Bl = checked(a) end
+-- a = specification.openpage if a and a ~= "" then d.PO = checked(a) end
+-- a = specification.closepage if a and a ~= "" then d.PC = checked(a) end
+-- -- a = specification.visiblepage if a and a ~= "" then d.PV = checked(a) end
+-- -- a = specification.invisiblepage if a and a ~= "" then d.PI = checked(a) end
+-- return next(d) and pdfdictionary(d)
+-- end
+
+local mapping = {
+ mousedown = "D", clickin = "D",
+ mouseup = "U", clickout = "U",
+ regionin = "E",
+ regionout = "X",
+ afterkey = "K",
+ format = "F",
+ validate = "V",
+ calculate = "C",
+ focusin = "Fo",
+ focusout = "Bl",
+ openpage = "PO",
+ closepage = "PC",
+ -- visiblepage = "PV",
+ -- invisiblepage = "PI",
+}
+
+local function fieldactions(specification) -- share actions
+ local d = nil
+ for key, target in sortedhash(mapping) do -- sort so that we can compare pdf
+ local code = specification[key]
+ if code and code ~= "" then
+ -- local a = checked(code)
+ local set, bug = references.identify("",code)
+ if not bug and #set > 0 then
+ local a = pdfaction(set) -- r, n
+ if a then
+ local r = pdfshareobjectreference(a)
+ if d then
+ d[target] = r
+ else
+ d = pdfdictionary { [target] = r }
+ end
+ else
+ report_fields("invalid field action %a, case %s",code,2)
+ end
+ else
+ report_fields("invalid field action %a, case %s",code,1)
+ end
+ end
+ end
+ -- if d then
+ -- d = pdfshareobjectreference(d) -- not much overlap or maybe only some patterns
+ -- end
+ return d
+end
+
+-- fonts and color
+
+local pdfdocencodingvector, pdfdocencodingcapsule
+
+-- The pdf doc encoding vector is needed in order to trigger propper unicode. Interesting is that when
+-- a glyph is not in the vector, it is still visible as it is taken from some other font. Messy.
+
+-- To be checked: only when text/line fields.
+
+local function checkpdfdocencoding()
+ report_fields("adding pdfdoc encoding vector")
+ local encoding = dofile(resolvers.findfile("lpdf-enc.lmt")) -- no checking, fatal if not present
+ pdfdocencodingvector = pdfreference(pdfflushobject(encoding))
+ local capsule = pdfdictionary {
+ PDFDocEncoding = pdfdocencodingvector
+ }
+ pdfdocencodingcapsule = pdfreference(pdfflushobject(capsule))
+ checkpdfdocencoding = function() end
+end
+
+local fontnames = {
+ rm = {
+ tf = "Times-Roman",
+ bf = "Times-Bold",
+ it = "Times-Italic",
+ sl = "Times-Italic",
+ bi = "Times-BoldItalic",
+ bs = "Times-BoldItalic",
+ },
+ ss = {
+ tf = "Helvetica",
+ bf = "Helvetica-Bold",
+ it = "Helvetica-Oblique",
+ sl = "Helvetica-Oblique",
+ bi = "Helvetica-BoldOblique",
+ bs = "Helvetica-BoldOblique",
+ },
+ tt = {
+ tf = "Courier",
+ bf = "Courier-Bold",
+ it = "Courier-Oblique",
+ sl = "Courier-Oblique",
+ bi = "Courier-BoldOblique",
+ bs = "Courier-BoldOblique",
+ },
+ symbol = {
+ dingbats = "ZapfDingbats",
+ }
+}
+
+local usedfonts = { }
+
+local function fieldsurrounding(specification)
+ local fontsize = specification.fontsize or "12pt"
+ local fontstyle = specification.fontstyle or "rm"
+ local fontalternative = specification.fontalternative or "tf"
+ local colorvalue = tonumber(specification.colorvalue)
+ local s = fontnames[fontstyle]
+ if not s then
+ fontstyle, s = "rm", fontnames.rm
+ end
+ local a = s[fontalternative]
+ if not a then
+ alternative, a = "tf", s.tf
+ end
+ local tag = fontstyle .. fontalternative
+ fontsize = todimen(fontsize)
+ fontsize = fontsize and (bpfactor * fontsize) or 12
+ fontraise = 0.1 * fontsize -- todo: figure out what the natural one is and compensate for strutdp
+ local fontcode = formatters["%0.4F Tf %0.4F Ts"](fontsize,fontraise)
+ -- we could test for colorvalue being 1 (black) and omit it then
+ local colorcode = pdfcolor(3,colorvalue) -- we force an rgb color space
+ if trace_fields then
+ report_fields("using font, style %a, alternative %a, size %p, tag %a, code %a",fontstyle,fontalternative,fontsize,tag,fontcode)
+ report_fields("using color, value %a, code %a",colorvalue,colorcode)
+ end
+ local stream = pdfstream {
+ pdfconstant(tag),
+ formatters["%s %s"](fontcode,colorcode)
+ }
+ usedfonts[tag] = a -- the name
+ -- move up with "x.y Ts"
+ return tostring(stream)
+end
+
+-- Can we use any font?
+
+codeinjections.fieldsurrounding = fieldsurrounding
+
+local function registerfonts()
+ if next(usedfonts) then
+ checkpdfdocencoding() -- already done
+ local pdffontlist = pdfdictionary()
+ local pdffonttype = pdfconstant("Font")
+ local pdffontsubtype = pdfconstant("Type1")
+ for tag, name in sortedhash(usedfonts) do
+ local f = pdfdictionary {
+ Type = pdffonttype,
+ Subtype = pdffontsubtype,
+ Name = pdfconstant(tag),
+ BaseFont = pdfconstant(name),
+ Encoding = pdfdocencodingvector,
+ }
+ pdffontlist[tag] = pdfreference(pdfflushobject(f))
+ end
+ return pdffontlist
+ end
+end
+
+-- symbols
+
+local function fieldappearances(specification)
+ -- todo: caching
+ local values = specification.values
+ local default = specification.default -- todo
+ if not values then
+ -- error
+ return
+ end
+ local v = settings_to_array(values)
+ local n, r, d
+ if #v == 1 then
+ n, r, d = v[1], v[1], v[1]
+ elseif #v == 2 then
+ n, r, d = v[1], v[1], v[2]
+ else
+ n, r, d = v[1], v[2], v[3]
+ end
+ local appearance = pdfdictionary {
+ N = registeredsymbol(n),
+ R = registeredsymbol(r),
+ D = registeredsymbol(d),
+ }
+ return pdfshareobjectreference(appearance)
+-- return pdfreference(pdfflushobject(appearance))
+end
+
+-- The rendering part of form support has always been crappy and didn't really
+-- improve over time. Did bugs become features? Who knows. Why provide for instance
+-- control over appearance and then ignore it when the mouse clicks someplace else.
+-- Strangely enough a lot of effort went into JavaScript support while basic
+-- appearance control of checkboxes stayed poor. I found this link when googling for
+-- conformation after the n^th time looking into this behaviour:
+--
+-- https://stackoverflow.com/questions/15479855/pdf-appearance-streams-checkbox-not-shown-correctly-after-focus-lost
+--
+-- ... "In particular check boxes, therefore, whenever not interacting with the user, shall
+-- be displayed using their normal captions, not their appearances."
+--
+-- So: don't use check boxes. In fact, even radio buttons can have these funny "flash some
+-- funny symbol" side effect when clocking on them. I tried all combinations if /H and /AP
+-- and /AS and ... Because (afaiks) the acrobat interface assumes that one uses dingbats no
+-- one really cared about getting custom appeances done well. This erratic behaviour might
+-- as well be the reason why no open source viewer ever bothered implementing forms. It's
+-- probably also why most forms out there look kind of bad.
+
+local function fieldstates_precheck(specification)
+ local values = specification.values
+ local default = specification.default
+ if not values or values == "" then
+ return
+ end
+ local yes = settings_to_array(values)[1]
+ local yesshown, yesvalue = lpegmatch(splitter,yes)
+ if not (yesshown and yesvalue) then
+ yesshown = yes
+ end
+ return default == settings_to_array(yesshown)[1] and pdf_yes or pdf_off
+end
+
+local function fieldstates_check(specification)
+ -- we don't use Opt here (too messy for radio buttons)
+ local values = specification.values
+ local default = specification.default
+ if not values or values == "" then
+ -- error
+ return
+ end
+ local v = settings_to_array(values)
+ local yes, off, yesn, yesr, yesd, offn, offr, offd
+ if #v == 1 then
+ yes, off = v[1], v[1]
+ else
+ yes, off = v[1], v[2]
+ end
+ local yesshown, yesvalue = lpegmatch(splitter,yes)
+ if not (yesshown and yesvalue) then
+ yesshown = yes, yes
+ end
+ yes = settings_to_array(yesshown)
+ local offshown, offvalue = lpegmatch(splitter,off)
+ if not (offshown and offvalue) then
+ offshown = off, off
+ end
+ off = settings_to_array(offshown)
+ if #yes == 1 then
+ yesn, yesr, yesd = yes[1], yes[1], yes[1]
+ elseif #yes == 2 then
+ yesn, yesr, yesd = yes[1], yes[1], yes[2]
+ else
+ yesn, yesr, yesd = yes[1], yes[2], yes[3]
+ end
+ if #off == 1 then
+ offn, offr, offd = off[1], off[1], off[1]
+ elseif #off == 2 then
+ offn, offr, offd = off[1], off[1], off[2]
+ else
+ offn, offr, offd = off[1], off[2], off[3]
+ end
+ if not yesvalue then
+ yesvalue = yesdefault or yesn
+ end
+ if not offvalue then
+ offvalue = offn
+ end
+ if default == yesn then
+ default = pdf_yes
+ yesvalue = yesvalue == yesn and "Yes" or "Off"
+ else
+ default = pdf_off
+ yesvalue = "Off"
+ end
+ local appearance
+ -- if false then
+ if true then
+ -- needs testing
+ appearance = pdfdictionary { -- maybe also cache components
+ N = pdfshareobjectreference(pdfdictionary { Yes = registeredsymbol(yesn), Off = registeredsymbol(offn) }),
+ R = pdfshareobjectreference(pdfdictionary { Yes = registeredsymbol(yesr), Off = registeredsymbol(offr) }),
+ D = pdfshareobjectreference(pdfdictionary { Yes = registeredsymbol(yesd), Off = registeredsymbol(offd) }),
+ }
+ else
+ appearance = pdfdictionary { -- maybe also cache components
+ N = pdfdictionary { Yes = registeredsymbol(yesn), Off = registeredsymbol(offn) },
+ R = pdfdictionary { Yes = registeredsymbol(yesr), Off = registeredsymbol(offr) },
+ D = pdfdictionary { Yes = registeredsymbol(yesd), Off = registeredsymbol(offd) }
+ }
+ end
+ local appearanceref = pdfshareobjectreference(appearance)
+ -- local appearanceref = pdfreference(pdfflushobject(appearance))
+ return appearanceref, default, yesvalue
+end
+
+-- It looks like there is always a (MK related) symbol used and that the appearances
+-- are only used as ornaments behind a symbol. So, contrary to what we did when
+-- widgets showed up, we now limit ourself to more dumb definitions. Especially when
+-- highlighting is enabled weird interferences happen. So, we play safe (some nice
+-- code has been removed that worked well till recently).
+
+local function fieldstates_radio(specification,name,parent)
+ local values = values or specification.values
+ local default = default or parent.default -- specification.default
+ if not values or values == "" then
+ -- error
+ return
+ end
+ local v = settings_to_array(values)
+ local yes, off, yesn, yesr, yesd, offn, offr, offd
+ if #v == 1 then
+ yes, off = v[1], v[1]
+ else
+ yes, off = v[1], v[2]
+ end
+ -- yes keys might be the same in the three appearances within a field
+ -- but can best be different among fields ... don't ask why
+ local yessymbols, yesvalue = lpegmatch(splitter,yes) -- n,r,d=>x
+ if not (yessymbols and yesvalue) then
+ yessymbols = yes
+ end
+ if not yesvalue then
+ yesvalue = name
+ end
+ yessymbols = settings_to_array(yessymbols)
+ if #yessymbols == 1 then
+ yesn = yessymbols[1]
+ yesr = yesn
+ yesd = yesr
+ elseif #yessymbols == 2 then
+ yesn = yessymbols[1]
+ yesr = yessymbols[2]
+ yesd = yesr
+ else
+ yesn = yessymbols[1]
+ yesr = yessymbols[2]
+ yesd = yessymbols[3]
+ end
+ -- we don't care about names, as all will be /Off
+ local offsymbols = lpegmatch(splitter,off) or off
+ offsymbols = settings_to_array(offsymbols)
+ if #offsymbols == 1 then
+ offn = offsymbols[1]
+ offr = offn
+ offd = offr
+ elseif #offsymbols == 2 then
+ offn = offsymbols[1]
+ offr = offsymbols[2]
+ offd = offr
+ else
+ offn = offsymbols[1]
+ offr = offsymbols[2]
+ offd = offsymbols[3]
+ end
+ if default == name then
+ default = pdfconstant(name)
+ else
+ default = pdf_off
+ end
+ --
+ local appearance
+ if false then -- needs testing
+ appearance = pdfdictionary { -- maybe also cache components
+ N = pdfshareobjectreference(pdfdictionary { [name] = registeredsymbol(yesn), Off = registeredsymbol(offn) }),
+ R = pdfshareobjectreference(pdfdictionary { [name] = registeredsymbol(yesr), Off = registeredsymbol(offr) }),
+ D = pdfshareobjectreference(pdfdictionary { [name] = registeredsymbol(yesd), Off = registeredsymbol(offd) }),
+ }
+ else
+ appearance = pdfdictionary { -- maybe also cache components
+ N = pdfdictionary { [name] = registeredsymbol(yesn), Off = registeredsymbol(offn) },
+ R = pdfdictionary { [name] = registeredsymbol(yesr), Off = registeredsymbol(offr) },
+ D = pdfdictionary { [name] = registeredsymbol(yesd), Off = registeredsymbol(offd) }
+ }
+ end
+ local appearanceref = pdfshareobjectreference(appearance) -- pdfreference(pdfflushobject(appearance))
+ return appearanceref, default, yesvalue
+end
+
+local function fielddefault(field,pdf_yes)
+ local default = field.default
+ if not default or default == "" then
+ local values = settings_to_array(field.values)
+ default = values[1]
+ end
+ if not default or default == "" then
+ return pdf_off
+ else
+ return pdf_yes or pdfconstant(default)
+ end
+end
+
+local function fieldoptions(specification)
+ local values = specification.values
+ local default = specification.default
+ if values then
+ local v = settings_to_array(values)
+ for i=1,#v do
+ local vi = v[i]
+ local shown, value = lpegmatch(splitter,vi)
+ if shown and value then
+ v[i] = pdfarray { pdfunicode(value), shown }
+ else
+ v[i] = pdfunicode(v[i])
+ end
+ end
+ return pdfarray(v)
+ end
+end
+
+local mapping = {
+ -- acrobat compliant (messy, probably some pdfdoc encoding interference here)
+ check = "4", -- 0x34
+ circle = "l", -- 0x6C
+ cross = "8", -- 0x38
+ diamond = "u", -- 0x75
+ square = "n", -- 0x6E
+ star = "H", -- 0x48
+}
+
+local function todingbat(n)
+ if n and n ~= "" then
+ return mapping[n] or ""
+ end
+end
+
+local function fieldrendering(specification)
+ local bvalue = tonumber(specification.backgroundcolorvalue)
+ local fvalue = tonumber(specification.framecolorvalue)
+ local svalue = specification.fontsymbol
+ if bvalue or fvalue or (svalue and svalue ~= "") then
+ return pdfdictionary {
+ BG = bvalue and pdfarray { pdfcolorvalues(3,bvalue) } or nil, -- or zero_bg,
+ BC = fvalue and pdfarray { pdfcolorvalues(3,fvalue) } or nil, -- or zero_bc,
+ CA = svalue and pdfstring (svalue) or nil,
+ }
+ end
+end
+
+-- layers
+
+local function fieldlayer(specification) -- we can move this in line
+ local layer = specification.layer
+ return (layer and pdflayerreference(layer)) or nil
+end
+
+-- defining
+
+local fields, radios, clones, fieldsets, calculationset = { }, { }, { }, { }, nil
+
+local xfdftemplate = [[
+
+
+
+
+
+%s
+
+
+]]
+
+function codeinjections.exportformdata(name)
+ local result = { }
+ for k, v in sortedhash(fields) do
+ result[#result+1] = formatters[" %s"](v.name or k,v.default or "")
+ end
+ local base = file.basename(tex.jobname)
+ local xfdf = format(xfdftemplate,base,table.concat(result,"\n"))
+ if not name or name == "" then
+ name = base
+ end
+ io.savedata(file.addsuffix(name,"xfdf"),xfdf)
+end
+
+function codeinjections.definefieldset(tag,list)
+ fieldsets[tag] = list
+end
+
+function codeinjections.getfieldset(tag)
+ return fieldsets[tag]
+end
+
+local function fieldsetlist(tag)
+ if tag then
+ local ft = fieldsets[tag]
+ if ft then
+ local a = pdfarray()
+ for name in gmatch(list,"[^, ]+") do
+ local f = field[name]
+ if f and f.pobj then
+ a[#a+1] = pdfreference(f.pobj)
+ end
+ end
+ return a
+ end
+ end
+end
+
+function codeinjections.setfieldcalculationset(tag)
+ calculationset = tag
+end
+
+interfaces.implement {
+ name = "setfieldcalculationset",
+ actions = codeinjections.setfieldcalculationset,
+ arguments = "string",
+}
+
+local function predefinesymbols(specification)
+ local values = specification.values
+ if values then
+ local symbols = settings_to_array(values)
+ for i=1,#symbols do
+ local symbol = symbols[i]
+ local a, b = lpegmatch(splitter,symbol)
+ codeinjections.presetsymbol(a or symbol)
+ end
+ end
+end
+
+function codeinjections.getdefaultfieldvalue(name)
+ local f = fields[name]
+ if f then
+ local values = f.values
+ local default = f.default
+ if not default or default == "" then
+ local symbols = settings_to_array(values)
+ local symbol = symbols[1]
+ if symbol then
+ local a, b = lpegmatch(splitter,symbol) -- splits at =>
+ default = a or symbol
+ end
+ end
+ return default
+ end
+end
+
+function codeinjections.definefield(specification)
+ local n = specification.name
+ local f = fields[n]
+ if not f then
+ local fieldtype = specification.type
+ if not fieldtype then
+ if trace_fields then
+ report_fields("invalid definition for %a, unknown type",n)
+ end
+ elseif fieldtype == "radio" then
+ local values = specification.values
+ if values and values ~= "" then
+ values = settings_to_array(values)
+ for v=1,#values do
+ radios[values[v]] = { parent = n }
+ end
+ fields[n] = specification
+ if trace_fields then
+ report_fields("defining %a as type %a",n,"radio")
+ end
+ elseif trace_fields then
+ report_fields("invalid definition of radio %a, missing values",n)
+ end
+ elseif fieldtype == "sub" then
+ -- not in main field list !
+ local radio = radios[n]
+ if radio then
+ -- merge specification
+ for key, value in next, specification do
+ radio[key] = value
+ end
+ if trace_fields then
+ local p = radios[n] and radios[n].parent
+ report_fields("defining %a as type sub of radio %a",n,p)
+ end
+ elseif trace_fields then
+ report_fields("invalid definition of radio sub %a, no parent given",n)
+ end
+ predefinesymbols(specification)
+ elseif fieldtype == "text" or fieldtype == "line" then
+ fields[n] = specification
+ if trace_fields then
+ report_fields("defining %a as type %a",n,fieldtype)
+ end
+ if specification.values ~= "" and specification.default == "" then
+ specification.default, specification.values = specification.values, nil
+ end
+ else
+ fields[n] = specification
+ if trace_fields then
+ report_fields("defining %a as type %a",n,fieldtype)
+ end
+ predefinesymbols(specification)
+ end
+ elseif trace_fields then
+ report_fields("invalid definition for %a, already defined",n)
+ end
+end
+
+function codeinjections.clonefield(specification) -- obsolete
+ local p = specification.parent
+ local c = specification.children
+ local v = specification.alternative
+ if not p or not c then
+ if trace_fields then
+ report_fields("invalid clone, children %a, parent %a, alternative %a",c,p,v)
+ end
+ return
+ end
+ local x = fields[p] or radios[p]
+ if not x then
+ if trace_fields then
+ report_fields("invalid clone, unknown parent %a",p)
+ end
+ return
+ end
+ for n in gmatch(c,"[^, ]+") do
+ local f, r, c = fields[n], radios[n], clones[n]
+ if f or r or c then
+ if trace_fields then
+ report_fields("already cloned, child %a, parent %a, alternative %a",n,p,v)
+ end
+ else
+ if trace_fields then
+ report_fields("cloning, child %a, parent %a, alternative %a",n,p,v)
+ end
+ clones[n] = specification
+ predefinesymbols(specification)
+ end
+ end
+end
+
+function codeinjections.getfieldcategory(name)
+ local f = fields[name] or radios[name] or clones[name]
+ if f then
+ local g = f.category
+ if not g or g == "" then
+ local v, p, t = f.alternative, f.parent, f.type
+ if v == "clone" or v == "copy" then
+ f = fields[p] or radios[p]
+ g = f and f.category
+ elseif t == "sub" then
+ f = fields[p]
+ g = f and f.category
+ end
+ end
+ return g
+ end
+end
+
+--
+
+function codeinjections.validfieldcategory(name)
+ return fields[name] or radios[name] or clones[name]
+end
+
+function codeinjections.validfieldset(name)
+ return fieldsets[tag]
+end
+
+function codeinjections.validfield(name)
+ return fields[name]
+end
+
+--
+
+local alignments = {
+ flushleft = 0, right = 0,
+ center = 1, middle = 1,
+ flushright = 2, left = 2,
+}
+
+local function fieldalignment(specification)
+ return alignments[specification.align] or 0
+end
+
+local function enhance(specification,option)
+ local so = specification.option
+ if so and so ~= "" then
+ specification.option = so .. "," .. option
+ else
+ specification.option = option
+ end
+ return specification
+end
+
+-- finish (if we also collect parents we can inline the kids which is
+-- more efficient ... but hardly anyone used widgets so ...)
+
+local collected = pdfarray()
+local forceencoding = false
+
+-- todo : check #opt
+
+local function finishfields()
+ local sometext = forceencoding
+ local somefont = next(usedfonts)
+ for name, field in sortedhash(fields) do
+ local kids = field.kids
+ if kids then
+ pdfflushobject(field.kidsnum,kids)
+ end
+ local opt = field.opt
+ if opt then
+ pdfflushobject(field.optnum,opt)
+ end
+ local type = field.type
+ if not sometext and (type == "text" or type == "line") then
+ sometext = true
+ end
+ end
+ for name, field in sortedhash(radios) do
+ local kids = field.kids
+ if kids then
+ pdfflushobject(field.kidsnum,kids)
+ end
+ local opt = field.opt
+ if opt then
+ pdfflushobject(field.optnum,opt)
+ end
+ end
+ if #collected > 0 then
+ local acroform = pdfdictionary {
+ NeedAppearances = pdfmajorversion() == 1 or nil,
+ Fields = pdfreference(pdfflushobject(collected)),
+ CO = fieldsetlist(calculationset),
+ }
+ if sometext or somefont then
+ checkpdfdocencoding()
+ if sometext then
+ usedfonts.tttf = fontnames.tt.tf
+ acroform.DA = "/tttf 12 Tf 0 g"
+ end
+ acroform.DR = pdfdictionary {
+ Font = registerfonts(),
+ Encoding = pdfdocencodingcapsule,
+ }
+ end
+ -- maybe:
+ -- if sometext then
+ -- checkpdfdocencoding()
+ -- if sometext then
+ -- usedfonts.tttf = fontnames.tt.tf
+ -- acroform.DA = "/tttf 12 Tf 0 g"
+ -- end
+ -- acroform.DR = pdfdictionary {
+ -- Font = registerfonts(),
+ -- Encoding = pdfdocencodingcapsule,
+ -- }
+ -- elseif somefont then
+ -- acroform.DR = pdfdictionary {
+ -- Font = registerfonts(),
+ -- }
+ -- end
+ lpdf.addtocatalog("AcroForm",pdfreference(pdfflushobject(acroform)))
+ end
+end
+
+lpdf.registerdocumentfinalizer(finishfields,"form fields")
+
+local methods = { }
+
+function nodeinjections.typesetfield(name,specification)
+ local field = fields[name] or radios[name] or clones[name]
+ if not field then
+ report_fields( "unknown child %a",name)
+ -- unknown field
+ return
+ end
+ local alternative, parent = field.alternative, field.parent
+ if alternative == "copy" or alternative == "clone" then -- only in clones
+ field = fields[parent] or radios[parent]
+ end
+ local method = methods[field.type]
+ if method then
+ return method(name,specification,alternative)
+ else
+ report_fields( "unknown method %a for child %a",field.type,name)
+ end
+end
+
+local function save_parent(field,specification,d)
+ local kidsnum = pdfreserveobject()
+ d.Kids = pdfreference(kidsnum)
+ field.kidsnum = kidsnum
+ field.kids = pdfarray()
+-- if d.Opt then
+-- local optnum = pdfreserveobject()
+-- d.Opt = pdfreference(optnum)
+-- field.optnum = optnum
+-- field.opt = pdfarray()
+-- end
+ local pnum = pdfflushobject(d)
+ field.pobj = pnum
+ collected[#collected+1] = pdfreference(pnum)
+end
+
+local function save_kid(field,specification,d,optname)
+ local kn = pdfreserveobject()
+ field.kids[#field.kids+1] = pdfreference(kn)
+-- if optname then
+-- local opt = field.opt
+-- if opt then
+-- opt[#opt+1] = optname
+-- end
+-- end
+ local width = specification.width or 0
+ local height = specification.height or 0
+ local depth = specification.depth or 0
+ local box = hpack_node(nodeinjections.annotation(width,height,depth,d(),kn))
+ -- redundant
+ box.width = width
+ box.height = height
+ box.depth = depth
+ return box
+end
+
+local function makelineparent(field,specification)
+ local text = pdfunicode(field.default)
+ local length = tonumber(specification.length or 0) or 0
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ T = pdfunicode(specification.title),
+ F = fieldplus(specification),
+ Ff = fieldflag(specification),
+ OC = fieldlayer(specification),
+ DA = fieldsurrounding(specification),
+ AA = fieldactions(specification),
+ FT = pdf_tx,
+ Q = fieldalignment(specification),
+ MaxLen = length == 0 and 1000 or length,
+ DV = text,
+ V = text,
+ }
+ save_parent(field,specification,d)
+end
+
+local function makelinechild(name,specification)
+ local field = clones[name]
+ local parent = nil
+ if field then
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("forcing parent text %a",parent.name)
+ end
+ makelineparent(parent,specification)
+ end
+ else
+ parent = fields[name]
+ field = parent
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("using parent text %a",name)
+ end
+ makelineparent(parent,specification)
+ end
+ end
+ if trace_fields then
+ report_fields("using child text %a",name)
+ end
+ -- we could save a little by not setting some key/value when it's the
+ -- same as parent but it would cost more memory to keep track of it
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ Parent = pdfreference(parent.pobj),
+ F = fieldplus(specification),
+ OC = fieldlayer(specification),
+ DA = fieldsurrounding(specification),
+ AA = fieldactions(specification),
+ MK = fieldrendering(specification),
+ Q = fieldalignment(specification),
+ }
+ return save_kid(parent,specification,d)
+end
+
+function methods.line(name,specification)
+ return makelinechild(name,specification)
+end
+
+function methods.text(name,specification)
+ return makelinechild(name,enhance(specification,"MultiLine"))
+end
+
+-- copy of line ... probably also needs a /Lock
+
+local function makesignatureparent(field,specification)
+ local text = pdfunicode(field.default)
+ local length = tonumber(specification.length or 0) or 0
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ T = pdfunicode(specification.title),
+ F = fieldplus(specification),
+ Ff = fieldflag(specification),
+ OC = fieldlayer(specification),
+ DA = fieldsurrounding(specification),
+ AA = fieldactions(specification),
+ FT = pdf_sig,
+ Q = fieldalignment(specification),
+ MaxLen = length == 0 and 1000 or length,
+ DV = text,
+ V = text,
+ }
+ save_parent(field,specification,d)
+end
+
+local function makesignaturechild(name,specification)
+ local field = clones[name]
+ local parent = nil
+ if field then
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("forcing parent signature %a",parent.name)
+ end
+ makesignatureparent(parent,specification)
+ end
+ else
+ parent = fields[name]
+ field = parent
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("using parent text %a",name)
+ end
+ makesignatureparent(parent,specification)
+ end
+ end
+ if trace_fields then
+ report_fields("using child text %a",name)
+ end
+ -- we could save a little by not setting some key/value when it's the
+ -- same as parent but it would cost more memory to keep track of it
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ Parent = pdfreference(parent.pobj),
+ F = fieldplus(specification),
+ OC = fieldlayer(specification),
+ DA = fieldsurrounding(specification),
+ AA = fieldactions(specification),
+ MK = fieldrendering(specification),
+ Q = fieldalignment(specification),
+ }
+ return save_kid(parent,specification,d)
+end
+
+function methods.signature(name,specification)
+ return makesignaturechild(name,specification)
+end
+--
+
+local function makechoiceparent(field,specification)
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ T = pdfunicode(specification.title),
+ F = fieldplus(specification),
+ Ff = fieldflag(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification),
+ FT = pdf_ch,
+ Opt = fieldoptions(field), -- todo
+ }
+ save_parent(field,specification,d)
+end
+
+local function makechoicechild(name,specification)
+ local field = clones[name]
+ local parent = nil
+ if field then
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("forcing parent choice %a",parent.name)
+ end
+ makechoiceparent(parent,specification,extras)
+ end
+ else
+ parent = fields[name]
+ field = parent
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("using parent choice %a",name)
+ end
+ makechoiceparent(parent,specification,extras)
+ end
+ end
+ if trace_fields then
+ report_fields("using child choice %a",name)
+ end
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ Parent = pdfreference(parent.pobj),
+ F = fieldplus(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification),
+ }
+ return save_kid(parent,specification,d) -- do opt here
+end
+
+function methods.choice(name,specification)
+ return makechoicechild(name,specification)
+end
+
+function methods.popup(name,specification)
+ return makechoicechild(name,enhance(specification,"PopUp"))
+end
+
+function methods.combo(name,specification)
+ return makechoicechild(name,enhance(specification,"PopUp,Edit"))
+end
+
+local function makecheckparent(field,specification)
+ local default = fieldstates_precheck(field)
+ local d = pdfdictionary {
+ T = pdfunicode(specification.title), -- todo: when tracing use a string
+ F = fieldplus(specification),
+ Ff = fieldflag(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification), -- can be shared
+ FT = pdf_btn,
+ V = fielddefault(field,default),
+ }
+ save_parent(field,specification,d)
+end
+
+local function makecheckchild(name,specification)
+ local field = clones[name]
+ local parent = nil
+ if field then
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("forcing parent check %a",parent.name)
+ end
+ makecheckparent(parent,specification,extras)
+ end
+ else
+ parent = fields[name]
+ field = parent
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("using parent check %a",name)
+ end
+ makecheckparent(parent,specification,extras)
+ end
+ end
+ if trace_fields then
+ report_fields("using child check %a",name)
+ end
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ Parent = pdfreference(parent.pobj),
+ F = fieldplus(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification), -- can be shared
+ H = pdf_n,
+ }
+ local fontsymbol = specification.fontsymbol
+ if fontsymbol and fontsymbol ~= "" then
+ specification.fontsymbol = todingbat(fontsymbol)
+ specification.fontstyle = "symbol"
+ specification.fontalternative = "dingbats"
+ d.DA = fieldsurrounding(specification)
+ d.MK = fieldrendering(specification)
+ return save_kid(parent,specification,d)
+ else
+ local appearance, default, value = fieldstates_check(field)
+ d.AS = default
+ d.AP = appearance
+ return save_kid(parent,specification,d)
+ end
+end
+
+function methods.check(name,specification)
+ return makecheckchild(name,specification)
+end
+
+local function makepushparent(field,specification) -- check if we can share with the previous
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ T = pdfunicode(specification.title),
+ F = fieldplus(specification),
+ Ff = fieldflag(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification), -- can be shared
+ FT = pdf_btn,
+ AP = fieldappearances(field),
+ H = pdf_p,
+ }
+ save_parent(field,specification,d)
+end
+
+local function makepushchild(name,specification)
+ local field, parent = clones[name], nil
+ if field then
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("forcing parent push %a",parent.name)
+ end
+ makepushparent(parent,specification)
+ end
+ else
+ parent = fields[name]
+ field = parent
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("using parent push %a",name)
+ end
+ makepushparent(parent,specification)
+ end
+ end
+ if trace_fields then
+ report_fields("using child push %a",name)
+ end
+ local fontsymbol = specification.fontsymbol
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ Parent = pdfreference(field.pobj),
+ F = fieldplus(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification), -- can be shared
+ H = pdf_p,
+ }
+ if fontsymbol and fontsymbol ~= "" then
+ specification.fontsymbol = todingbat(fontsymbol)
+ specification.fontstyle = "symbol"
+ specification.fontalternative = "dingbats"
+ d.DA = fieldsurrounding(specification)
+ d.MK = fieldrendering(specification)
+ else
+ d.AP = fieldappearances(field)
+ end
+ return save_kid(parent,specification,d)
+end
+
+function methods.push(name,specification)
+ return makepushchild(name,enhance(specification,"PushButton"))
+end
+
+local function makeradioparent(field,specification)
+ specification = enhance(specification,"Radio,RadiosInUnison,Print,NoToggleToOff")
+ local d = pdfdictionary {
+ T = field.name,
+ FT = pdf_btn,
+ -- F = fieldplus(specification),
+ Ff = fieldflag(specification),
+ -- H = pdf_n,
+ V = fielddefault(field),
+ }
+ save_parent(field,specification,d)
+end
+
+-- local function makeradiochild(name,specification)
+-- local field = clones[name]
+-- local parent = nil
+-- local pname = nil
+-- if field then
+-- pname = field.parent
+-- field = radios[pname]
+-- parent = fields[pname]
+-- if not parent.pobj then
+-- if trace_fields then
+-- report_fields("forcing parent radio %a",parent.name)
+-- end
+-- makeradioparent(parent,parent)
+-- end
+-- else
+-- field = radios[name]
+-- if not field then
+-- report_fields("there is some problem with field %a",name)
+-- return nil
+-- end
+-- pname = field.parent
+-- parent = fields[pname]
+-- if not parent.pobj then
+-- if trace_fields then
+-- report_fields("using parent radio %a",name)
+-- end
+-- makeradioparent(parent,parent)
+-- end
+-- end
+-- if trace_fields then
+-- report_fields("using child radio %a with values %a and default %a",name,field.values,field.default)
+-- end
+-- local fontsymbol = specification.fontsymbol
+-- -- fontsymbol = "circle"
+-- local d = pdfdictionary {
+-- Subtype = pdf_widget,
+-- Parent = pdfreference(parent.pobj),
+-- F = fieldplus(specification),
+-- OC = fieldlayer(specification),
+-- AA = fieldactions(specification),
+-- H = pdf_n,
+-- -- H = pdf_p,
+-- -- P = pdfpagereference(true),
+-- }
+-- if fontsymbol and fontsymbol ~= "" then
+-- specification.fontsymbol = todingbat(fontsymbol)
+-- specification.fontstyle = "symbol"
+-- specification.fontalternative = "dingbats"
+-- d.DA = fieldsurrounding(specification)
+-- d.MK = fieldrendering(specification)
+-- return save_kid(parent,specification,d) -- todo: what if no value
+-- else
+-- local appearance, default, value = fieldstates_radio(field,name,fields[pname])
+-- d.AP = appearance
+-- d.AS = default -- /Whatever
+-- return save_kid(parent,specification,d,value)
+-- end
+-- end
+
+local function makeradiochild(name,specification)
+ local field, parent = clones[name], nil
+ if field then
+ field = radios[field.parent]
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("forcing parent radio %a",parent.name)
+ end
+ makeradioparent(parent,parent)
+ end
+ else
+ field = radios[name]
+ if not field then
+ report_fields("there is some problem with field %a",name)
+ return nil
+ end
+ parent = fields[field.parent]
+ if not parent.pobj then
+ if trace_fields then
+ report_fields("using parent radio %a",name)
+ end
+ makeradioparent(parent,parent)
+ end
+ end
+ if trace_fields then
+ report_fields("using child radio %a with values %a and default %a",name,field.values,field.default)
+ end
+ local fontsymbol = specification.fontsymbol
+ -- fontsymbol = "circle"
+ local d = pdfdictionary {
+ Subtype = pdf_widget,
+ Parent = pdfreference(parent.pobj),
+ F = fieldplus(specification),
+ OC = fieldlayer(specification),
+ AA = fieldactions(specification),
+ H = pdf_n,
+ }
+ if fontsymbol and fontsymbol ~= "" then
+ specification.fontsymbol = todingbat(fontsymbol)
+ specification.fontstyle = "symbol"
+ specification.fontalternative = "dingbats"
+ d.DA = fieldsurrounding(specification)
+ d.MK = fieldrendering(specification)
+ end
+ local appearance, default, value = fieldstates_radio(field,name,fields[field.parent])
+ d.AP = appearance
+ d.AS = default -- /Whatever
+-- d.MK = pdfdictionary { BC = pdfarray {0}, BG = pdfarray { 1 } }
+d.BS = pdfdictionary { S = pdfconstant("I"), W = 1 }
+ return save_kid(parent,specification,d,value)
+end
+
+function methods.sub(name,specification)
+ return makeradiochild(name,enhance(specification,"Radio,RadiosInUnison"))
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-fmt.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-fmt.lmt
new file mode 100644
index 00000000000..c6a3f25ff5e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-fmt.lmt
@@ -0,0 +1,1020 @@
+if not modules then modules = { } end modules ['lpdf-fmt'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Peter Rolf and Hans Hagen",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- Thanks to Luigi and Steffen for testing.
+
+-- context --directives="backend.format=PDF/X-1a:2001" --trackers=backend.format yourfile
+
+local tonumber = tonumber
+local lower, gmatch, format, find = string.lower, string.gmatch, string.format, string.find
+local concat, serialize, sortedhash = table.concat, table.serialize, table.sortedhash
+
+local trace_format = false trackers.register("backend.format", function(v) trace_format = v end)
+local trace_variables = false trackers.register("backend.variables", function(v) trace_variables = v end)
+
+local report_backend = logs.reporter("backend","profiles")
+
+local backends, lpdf = backends, lpdf
+
+local codeinjections = backends.pdf.codeinjections
+
+local variables = interfaces.variables
+local viewerlayers = attributes.viewerlayers
+local colors = attributes.colors
+local transparencies = attributes.transparencies
+
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+local pdfflushobject = lpdf.flushobject
+local pdfstring = lpdf.string
+local pdfverbose = lpdf.verbose
+local pdfflushstreamfileobject = lpdf.flushstreamfileobject
+
+local addtoinfo = lpdf.addtoinfo
+local injectxmpinfo = lpdf.injectxmpinfo
+local insertxmpinfo = lpdf.insertxmpinfo
+
+local settings_to_array = utilities.parsers.settings_to_array
+local settings_to_hash = utilities.parsers.settings_to_hash
+
+--[[
+ Comments by Peter:
+
+ output intent : only one profile per color space (and device class)
+ default color space : (theoretically) several profiles per color space possible
+
+ The default color space profiles define the current gamuts (part of/all the
+ colors we have in the document), while the output intent profile declares the
+ gamut of the output devices (the colors that we get normally a printer or
+ monitor).
+
+ Example:
+
+ I have two RGB pictures (both 'painted' in /DeviceRGB) and I declare sRGB as
+ default color space for one picture and AdobeRGB for the other. As output
+ intent I use ISO_coated_v2_eci.icc.
+
+ If I had more than one output intent profile for the combination CMYK/printer I
+ can't decide which one to use. But it is no problem to use several default color
+ space profiles for the same color space as it's just a different color
+ transformation. The relation between picture and profile is clear.
+]]--
+
+local channels = {
+ gray = 1,
+ grey = 1,
+ rgb = 3,
+ cmyk = 4,
+}
+
+local prefixes = {
+ gray = "DefaultGray",
+ grey = "DefaultGray",
+ rgb = "DefaultRGB",
+ cmyk = "DefaultCMYK",
+}
+
+local formatspecification = nil
+local formatname = nil
+
+-- * correspondent document wide flags (write once) needed for permission tests
+
+-- defaults as mt
+
+local formats = utilities.storage.allocate {
+ version = {
+ external_icc_profiles = 1.4, -- 'p' in name; URL reference of output intent
+ jbig2_compression = 1.4,
+ jpeg2000_compression = 1.5, -- not supported yet
+ nchannel_colorspace = 1.6, -- 'n' in name; n-channel colorspace support
+ open_prepress_interface = 1.3, -- 'g' in name; reference to external graphics
+ optional_content = 1.5,
+ transparency = 1.4,
+ object_compression = 1.5,
+ attachments = 1.7,
+ },
+ default = {
+ pdf_version = 1.7, -- todo: block tex primitive
+ format_name = "default",
+ xmp_file = "lpdf-pdx.xml",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ nchannel_colorspace = true, -- unknown
+ internal_icc_profiles = true, -- controls profile inclusion
+ external_icc_profiles = true, -- controls profile inclusion
+ include_intents = true,
+ open_prepress_interface = true, -- unknown
+ optional_content = true, -- todo: block at lua level
+ transparency = true, -- todo: block at lua level
+ jbig2_compression = true, -- todo: block at lua level (dropped anyway)
+ jpeg2000_compression = true, -- todo: block at lua level (dropped anyway)
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = true,
+ inject_metadata = function()
+ -- nothing
+ end
+ },
+ data = {
+ ["pdf/x-1a:2001"] = {
+ pdf_version = 1.3,
+ format_name = "PDF/X-1a:2001",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ spot_colors = true,
+ internal_icc_profiles = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ addtoinfo("GTS_PDFXVersion","PDF/X-1a:2001")
+ injectxmpinfo("xml://rdf:RDF","PDF/X-1a:2001",false)
+ end
+ },
+ ["pdf/x-1a:2003"] = {
+ pdf_version = 1.4,
+ format_name = "PDF/X-1a:2003",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ spot_colors = true,
+ internal_icc_profiles = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ addtoinfo("GTS_PDFXVersion","PDF/X-1a:2003")
+ injectxmpinfo("xml://rdf:RDF","PDF/X-1a:2003",false)
+ end
+ },
+ ["pdf/x-3:2002"] = {
+ pdf_version = 1.3,
+ format_name = "PDF/X-3:2002",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ include_intents = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ addtoinfo("GTS_PDFXVersion","PDF/X-3:2002")
+ end
+ },
+ ["pdf/x-3:2003"] = {
+ pdf_version = 1.4,
+ format_name = "PDF/X-3:2003",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ include_intents = true,
+ jbig2_compression = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ addtoinfo("GTS_PDFXVersion","PDF/X-3:2003")
+ end
+ },
+ ["pdf/x-4"] = {
+ pdf_version = 1.6,
+ format_name = "PDF/X-4",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ include_intents = true,
+ optional_content = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","PDF/X-4",false)
+ insertxmpinfo("xml://rdf:Description/xmpMM:InstanceID","1",false)
+ insertxmpinfo("xml://rdf:Description/xmpMM:InstanceID","default",false)
+ end
+ },
+ ["pdf/x-4p"] = {
+ pdf_version = 1.6,
+ format_name = "PDF/X-4p",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ external_icc_profiles = true,
+ include_intents = true,
+ optional_content = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","PDF/X-4p",false)
+ insertxmpinfo("xml://rdf:Description/xmpMM:InstanceID","1",false)
+ insertxmpinfo("xml://rdf:Description/xmpMM:InstanceID","default",false)
+ end
+ },
+ ["pdf/x-5g"] = {
+ pdf_version = 1.6,
+ format_name = "PDF/X-5g",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ include_intents = true,
+ open_prepress_interface = true,
+ optional_content = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ -- todo
+ end
+ },
+ ["pdf/x-5pg"] = {
+ pdf_version = 1.6,
+ format_name = "PDF/X-5pg",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ external_icc_profiles = true,
+ include_intents = true,
+ open_prepress_interface = true,
+ optional_content = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ -- todo
+ end
+ },
+ ["pdf/x-5n"] = {
+ pdf_version = 1.6,
+ format_name = "PDF/X-5n",
+ xmp_file = "lpdf-pdx.xml",
+ gts_flag = "GTS_PDFX",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ calibrated_rgb_colors = true,
+ spot_colors = true,
+ cielab_colors = true,
+ internal_icc_profiles = true,
+ include_intents = true,
+ optional_content = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ nchannel_colorspace = true,
+ object_compression = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ -- todo
+ end
+ },
+ ["pdf/a-1a:2005"] = {
+ pdf_version = 1.4,
+ format_name = "pdf/a-1a:2005",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true, -- new: forms are allowed (with limitations); no JS, other restrictions are unknown (TODO)
+ tagging = true, -- new: the only difference to PDF/A-1b
+ internal_icc_profiles = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","1A",false)
+ end
+ },
+ ["pdf/a-1b:2005"] = {
+ pdf_version = 1.4,
+ format_name = "pdf/a-1b:2005",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ internal_icc_profiles = true,
+ include_cidsets = true,
+ include_charsets = true,
+ attachments = false,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","1B",false)
+ end
+ },
+ -- Only PDF/A Attachments are allowed but we don't check the attachments
+ -- for any quality: they are just blobs.
+ ["pdf/a-2a"] = {
+ pdf_version = 1.7,
+ format_name = "pdf/a-2a",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = true,
+ internal_icc_profiles = true,
+ transparency = true, -- new
+ jbig2_compression = true,
+ jpeg2000_compression = true, -- new
+ object_compression = true, -- new
+ include_cidsets = false,
+ include_charsets = false,
+ attachments = true, -- new
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","2A",false)
+ end
+ },
+ ["pdf/a-2b"] = {
+ pdf_version = 1.7,
+ format_name = "pdf/a-2b",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = false,
+ internal_icc_profiles = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = false,
+ include_charsets = false,
+ attachments = true,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","2B",false)
+ end
+ },
+ -- This is like the b variant, but it requires Unicode mapping of fonts
+ -- which we do anyway.
+ ["pdf/a-2u"] = {
+ pdf_version = 1.7,
+ format_name = "pdf/a-2u",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = false,
+ internal_icc_profiles = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = false,
+ include_charsets = false,
+ attachments = true,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","2U",false)
+ end
+ },
+ -- Any type of attachment is allowed but we don't check the quality
+ -- of them.
+ ["pdf/a-3a"] = {
+ pdf_version = 1.7,
+ format_name = "pdf/a-3a",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = true,
+ internal_icc_profiles = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = false,
+ include_charsets = false,
+ attachments = true,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","3A",false)
+ end
+ },
+ ["pdf/a-3b"] = {
+ pdf_version = 1.7,
+ format_name = "pdf/a-3b",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = false,
+ internal_icc_profiles = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = false,
+ include_charsets = false,
+ attachments = true,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","3B",false)
+ end
+ },
+ ["pdf/a-3u"] = {
+ pdf_version = 1.7,
+ format_name = "pdf/a-3u",
+ xmp_file = "lpdf-pda.xml",
+ gts_flag = "GTS_PDFA1",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = false,
+ internal_icc_profiles = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = false,
+ include_charsets = false,
+ attachments = true,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","3U",false)
+ end
+ },
+ ["pdf/ua-1"] = { -- based on PDF/A-3a, but no 'gts_flag'
+ pdf_version = 1.7,
+ format_name = "pdf/ua-1",
+ xmp_file = "lpdf-pua.xml",
+ gray_scale = true,
+ cmyk_colors = true,
+ rgb_colors = true,
+ spot_colors = true,
+ calibrated_rgb_colors = true, -- unknown
+ cielab_colors = true, -- unknown
+ include_intents = true,
+ forms = true,
+ tagging = true,
+ internal_icc_profiles = true,
+ transparency = true,
+ jbig2_compression = true,
+ jpeg2000_compression = true,
+ object_compression = true,
+ include_cidsets = true,
+ include_charsets = true, --- really ?
+ attachments = true,
+ inject_metadata = function()
+ injectxmpinfo("xml://rdf:RDF","3A",false)
+ injectxmpinfo("xml://rdf:RDF","1",false)
+ end
+ },
+ }
+}
+
+lpdf.formats = formats -- it does not hurt to have this one visible
+
+local filenames = {
+ "colorprofiles.xml",
+ "colorprofiles.lua",
+}
+
+local function locatefile(filename)
+ local fullname = resolvers.findfile(filename,"icc",1,true)
+ if not fullname or fullname == "" then
+ fullname = resolvers.finders.byscheme("loc",filename) -- could be specific to the project
+ end
+ return fullname or ""
+end
+
+local function loadprofile(name,filename)
+ local profile = false
+ local databases = filename and filename ~= "" and settings_to_array(filename) or filenames
+ for i=1,#databases do
+ local filename = locatefile(databases[i])
+ if filename and filename ~= "" then
+ local suffix = file.suffix(filename)
+ local lname = lower(name)
+ if suffix == "xml" then
+ local xmldata = xml.load(filename) -- no need for caching it
+ if xmldata then
+ profile = xml.filter(xmldata,format('xml://profiles/profile/(info|filename)[lower(text())=="%s"]/../table()',lname))
+ end
+ elseif suffix == "lua" then
+ local luadata = loadfile(filename)
+ luadata = ludata and luadata()
+ if luadata then
+ profile = luadata[name] or luadata[lname] -- hashed
+ if not profile then
+ for i=1,#luadata do
+ local li = luadata[i]
+ if lower(li.info) == lname then -- indexed
+ profile = li
+ break
+ end
+ end
+ end
+ end
+ end
+ if profile then
+ if next(profile) then
+ report_backend("profile specification %a loaded from %a",name,filename)
+ return profile
+ elseif trace_format then
+ report_backend("profile specification %a loaded from %a but empty",name,filename)
+ end
+ return false
+ end
+ end
+ end
+ report_backend("profile specification %a not found in %a",name,concat(filenames, ", "))
+end
+
+local function urls(url)
+ if not url or url == "" then
+ return nil
+ else
+ local u = pdfarray()
+ for url in gmatch(url,"([^, ]+)") do
+ if find(url,"^http") then
+ u[#u+1] = pdfdictionary {
+ FS = pdfconstant("URL"),
+ F = pdfstring(url),
+ }
+ end
+ end
+ return u
+ end
+end
+
+local function profilename(filename)
+ return lower(file.basename(filename))
+end
+
+local internalprofiles = { }
+
+local function handleinternalprofile(s,include)
+ local filename, colorspace = s.filename or "", s.colorspace or ""
+ if filename == "" or colorspace == "" then
+ report_backend("error in internal profile specification: %s",serialize(s,false))
+ else
+ local tag = profilename(filename)
+ local profile = internalprofiles[tag]
+ if not profile then
+ local colorspace = lower(colorspace)
+ if include then
+ -- local fullname = resolvers.findctxfile(filename) or ""
+ local fullname = locatefile(filename)
+ local channel = channels[colorspace] or nil
+ if fullname == "" then
+ report_backend("error, couldn't locate profile %a",filename)
+ elseif not channel then
+ report_backend("error, couldn't resolve channel entry for colorspace %a",colorspace)
+ else
+ profile = pdfflushstreamfileobject(fullname,pdfdictionary{ N = channel },false) -- uncompressed
+ internalprofiles[tag] = profile
+ if trace_format then
+ report_backend("including %a color profile from %a",colorspace,fullname)
+ end
+ end
+ else
+ internalprofiles[tag] = true
+ if trace_format then
+ report_backend("not including %a color profile %a",colorspace,filename)
+ end
+ end
+ end
+ return profile
+ end
+end
+
+local externalprofiles = { }
+
+local function handleexternalprofile(s,include) -- specification (include ignored here)
+ local name, url, filename, checksum, version, colorspace =
+ s.info or s.filename or "", s.url or "", s.filename or "", s.checksum or "", s.version or "", s.colorspace or ""
+ if false then -- somehow leads to invalid pdf
+ local iccprofile = colors.iccprofile(filename)
+ if iccprofile then
+ name = name ~= "" and name or iccprofile.tags.desc.cleaned or ""
+ url = url ~= "" and url or iccprofile.tags.dmnd.cleaned or ""
+ checksum = checksum ~= "" and checksum or file.checksum(iccprofile.fullname) or ""
+ version = version ~= "" and version or iccprofile.header.version or ""
+ colorspace = colorspace ~= "" and colorspace or iccprofile.header.colorspace or ""
+ end
+ -- table.print(iccprofile)
+ end
+ if name == "" or url == "" or checksum == "" or version == "" or colorspace == "" or filename == "" then
+ local profile = handleinternalprofile(s)
+ if profile then
+ report_backend("incomplete external profile specification, falling back to internal")
+ else
+ report_backend("error in external profile specification: %s",serialize(s,false))
+ end
+ else
+ local tag = profilename(filename)
+ local profile = externalprofiles[tag]
+ if not profile then
+ local d = pdfdictionary {
+ ProfileName = name, -- not file name!
+ ProfileCS = colorspace,
+ URLs = urls(url), -- array containing at least one URL
+ CheckSum = pdfverbose { "<", lower(checksum), ">" }, -- 16byte MD5 hash
+ ICCVersion = pdfverbose { "<", version, ">" }, -- bytes 8..11 from the header of the ICC profile, as a hex string
+ }
+ profile = pdfflushobject(d)
+ externalprofiles[tag] = profile
+ end
+ return profile
+ end
+end
+
+local loadeddefaults = { }
+
+local function handledefaultprofile(s,spec) -- specification
+ local filename, colorspace = s.filename or "", lower(s.colorspace or "")
+ if filename == "" or colorspace == "" then
+ report_backend("error in default profile specification: %s",serialize(s,false))
+ elseif not loadeddefaults[colorspace] then
+ local tag = profilename(filename)
+ local n = internalprofiles[tag] -- or externalprofiles[tag]
+ if n == true then -- not internalized
+ report_backend("no default profile %a for colorspace %a",filename,colorspace)
+ elseif n then
+ local a = pdfarray {
+ pdfconstant("ICCBased"),
+ pdfreference(n),
+ }
+ -- used in page /Resources, so this must be inserted at runtime
+ lpdf.adddocumentcolorspace(prefixes[colorspace],pdfreference(pdfflushobject(a)))
+ loadeddefaults[colorspace] = true
+ report_backend("setting %a as default %a color space",filename,colorspace)
+ else
+ report_backend("no default profile %a for colorspace %a",filename,colorspace)
+ end
+ elseif trace_format then
+ report_backend("a default %a colorspace is already in use",colorspace)
+ end
+end
+
+local loadedintents = { }
+local intents = pdfarray()
+
+local function handleoutputintent(s,spec)
+ local url = s.url or ""
+ local filename = s.filename or ""
+ local name = s.info or filename
+ local id = s.id or ""
+ local outputcondition = s.outputcondition or ""
+ local info = s.info or ""
+ if name == "" or id == "" then
+ report_backend("error in output intent specification: %s",serialize(s,false))
+ elseif not loadedintents[name] then
+ local tag = profilename(filename)
+ local internal, external = internalprofiles[tag], externalprofiles[tag]
+ if internal or external then
+ local d = {
+ Type = pdfconstant("OutputIntent"),
+ S = pdfconstant(spec.gts_flag or "GTS_PDFX"),
+ OutputConditionIdentifier = id,
+ RegistryName = url,
+ OutputCondition = outputcondition,
+ Info = info,
+ }
+ if internal and internal ~= true then
+ d.DestOutputProfile = pdfreference(internal)
+ elseif external and external ~= true then
+ d.DestOutputProfileRef = pdfreference(external)
+ else
+ report_backend("omitting reference to profile for intent %a",name)
+ end
+ intents[#intents+1] = pdfreference(pdfflushobject(pdfdictionary(d)))
+ if trace_format then
+ report_backend("setting output intent to %a with id %a for entry %a",name,id,#intents)
+ end
+ else
+ report_backend("invalid output intent %a",name)
+ end
+ loadedintents[name] = true
+ elseif trace_format then
+ report_backend("an output intent with name %a is already in use",name)
+ end
+end
+
+local function handleiccprofile(message,spec,name,filename,how,options,alwaysinclude,gts_flag)
+ if name and name ~= "" then
+ local list = settings_to_array(name)
+ for i=1,#list do
+ local name = list[i]
+ local profile = loadprofile(name,filename)
+ if trace_format then
+ report_backend("handling %s %a",message,name)
+ end
+ if profile then
+ if formatspecification.cmyk_colors then
+ profile.colorspace = profile.colorspace or "CMYK"
+ else
+ profile.colorspace = profile.colorspace or "RGB"
+ end
+ local external = formatspecification.external_icc_profiles
+ local internal = formatspecification.internal_icc_profiles
+ local include = formatspecification.include_intents
+ local always, never = options[variables.always], options[variables.never]
+ if always or alwaysinclude then
+ if trace_format then
+ report_backend("forcing internal profiles") -- can make preflight unhappy
+ end
+ -- internal, external = true, false
+ internal, external = not never, false
+ elseif never then
+ if trace_format then
+ report_backend("forcing external profiles") -- can make preflight unhappy
+ end
+ internal, external = false, true
+ end
+ if external then
+ if trace_format then
+ report_backend("handling external profiles cf. %a",name)
+ end
+ handleexternalprofile(profile,false)
+ else
+ if trace_format then
+ report_backend("handling internal profiles cf. %a",name)
+ end
+ if internal then
+ handleinternalprofile(profile,always or include)
+ else
+ report_backend("no profile inclusion for %a",formatname)
+ end
+ end
+ how(profile,spec)
+ elseif trace_format then
+ report_backend("unknown profile %a",name)
+ end
+ end
+ end
+end
+
+local function flushoutputintents()
+ if #intents > 0 then
+ lpdf.addtocatalog("OutputIntents",pdfreference(pdfflushobject(intents)))
+ end
+end
+
+lpdf.registerdocumentfinalizer(flushoutputintents,2,"output intents")
+
+function codeinjections.setformat(s)
+ local format = s.format or ""
+ local level = tonumber(s.level)
+ local intent = s.intent or ""
+ local profile = s.profile or ""
+ local option = s.option or ""
+ local filename = s.file or ""
+ if format ~= "" then
+ local spec = formats.data[lower(format)]
+ if spec then
+ formatspecification = spec
+ formatname = spec.format_name
+ report_backend("setting format to %a",formatname)
+ local xmp_file = formatspecification.xmp_file or ""
+ if xmp_file == "" then
+ -- weird error
+ else
+ codeinjections.setxmpfile(xmp_file)
+ end
+ if not level then
+ level = 3 -- good compromise, default anyway
+ end
+ local pdf_version = spec.pdf_version * 10
+ local inject_metadata = spec.inject_metadata
+ local majorversion = math.floor(math.div(pdf_version,10))
+ local minorversion = math.floor(math.mod(pdf_version,10))
+ local objectcompression = spec.object_compression and pdf_version >= 15
+ local compresslevel = level or lpdf.compresslevel() -- keep default
+ local objectcompresslevel = (objectcompression and (level or lpdf.objectcompresslevel())) or 0
+ lpdf.setcompression(compresslevel,objectcompresslevel)
+ lpdf.setversion(majorversion,minorversion)
+ if objectcompression then
+ report_backend("forcing pdf version %s.%s, compression level %s, object compression level %s",
+ majorversion,minorversion,compresslevel,objectcompresslevel)
+ elseif compresslevel > 0 then
+ report_backend("forcing pdf version %s.%s, compression level %s, object compression disabled",
+ majorversion,minorversion,compresslevel)
+ else
+ report_backend("forcing pdf version %s.%s, compression disabled",
+ majorversion,minorversion)
+ end
+ --
+ -- cid sets can always omitted now, but those validators still complain so let's
+ -- for a while keep it (for luigi):
+ --
+ lpdf.setomitcidset (formatspecification.include_cidsets == false and 1 or 0) -- why a number
+ lpdf.setomitcharset(formatspecification.include_charsets == false and 1 or 0) -- why a number
+ --
+ -- maybe block by pdf version
+ --
+ codeinjections.settaggingsupport(formatspecification.tagging)
+ codeinjections.setattachmentsupport(formatspecification.attachments)
+ --
+ -- context.setupcolors { -- not this way
+ -- cmyk = spec.cmyk_colors and variables.yes or variables.no,
+ -- rgb = spec.rgb_colors and variables.yes or variables.no,
+ -- }
+ --
+ colors.forcesupport(
+ spec.gray_scale or false,
+ spec.rgb_colors or false,
+ spec.cmyk_colors or false,
+ spec.spot_colors or false,
+ spec.nchannel_colorspace or false
+ )
+ transparencies.forcesupport(
+ spec.transparency or false
+ )
+ viewerlayers.forcesupport(
+ spec.optional_content or false
+ )
+ viewerlayers.setfeatures(
+ spec.has_order or false -- new
+ )
+ --
+ -- spec.jbig2_compression : todo, block in image inclusion
+ -- spec.jpeg2000_compression : todo, block in image inclusion
+ --
+ if type(inject_metadata) == "function" then
+ inject_metadata()
+ end
+ local options = settings_to_hash(option)
+ handleiccprofile("color profile",spec,profile,filename,handledefaultprofile,options,true)
+ handleiccprofile("output intent",spec,intent,filename,handleoutputintent,options,false)
+ if trace_variables then
+ for k, v in sortedhash(formats.default) do
+ local v = formatspecification[k]
+ if type(v) ~= "function" then
+ report_backend("%a = %a",k,v or false)
+ end
+ end
+ end
+ function codeinjections.setformat(noname)
+ if trace_format then
+ report_backend("error, format is already set to %a, ignoring %a",formatname,noname.format)
+ end
+ end
+ else
+ report_backend("error, format %a is not supported",format)
+ end
+ elseif level then
+ lpdf.setcompression(level,level)
+ else
+ -- we ignore this as we hook it in \everysetupbackend
+ end
+end
+
+directives.register("backend.format", function(v) -- table !
+ local tv = type(v)
+ if tv == "table" then
+ codeinjections.setformat(v)
+ elseif tv == "string" then
+ codeinjections.setformat { format = v }
+ end
+end)
+
+interfaces.implement {
+ name = "setformat",
+ actions = codeinjections.setformat,
+ arguments = { { "*" } }
+}
+
+function codeinjections.getformatoption(key)
+ return formatspecification and formatspecification[key]
+end
+
+-- function codeinjections.getformatspecification()
+-- return formatspecification
+-- end
+
+function codeinjections.supportedformats()
+ local t = { }
+ for k, v in sortedhash(formats.data) do
+ t[#t+1] = k
+ end
+ return t
+end
+
+-- The following is somewhat cleaner but then we need to flag that there are
+-- color spaces set so that the page flusher does not optimize the (at that
+-- moment) still empty array away. So, next(d_colorspaces) should then become
+-- a different test, i.e. also on flag. I'll add that when we need more forward
+-- referencing.
+--
+-- local function embedprofile = handledefaultprofile
+--
+-- local function flushembeddedprofiles()
+-- for colorspace, filename in next, defaults do
+-- embedprofile(colorspace,filename)
+-- end
+-- end
+--
+-- local function handledefaultprofile(s)
+-- defaults[lower(s.colorspace)] = s.filename
+-- end
+--
+-- lpdf.registerdocumentfinalizer(flushembeddedprofiles,1,"embedded color profiles")
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-fnt.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-fnt.lmt
new file mode 100644
index 00000000000..ee16303b060
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-fnt.lmt
@@ -0,0 +1,194 @@
+if not modules then modules = { } end modules ['lpdf-fnt'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is experimental code.
+
+local match, gmatch = string.match, string.gmatch
+local tonumber, rawget = tonumber, rawget
+
+local pdfe = lpdf.epdf
+local pdfreference = lpdf.reference
+
+local pdfreserveobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+end)
+
+local tobemerged = { }
+local trace_merge = false trackers.register("graphics.fonts",function(v) trace_merge = v end)
+local report_merge = logs.reporter("graphics","fonts")
+
+local function register(usedname,cleanname)
+ local cleanname = cleanname or fonts.names.cleanname(usedname)
+ local fontid = fonts.definers.internal { name = cleanname }
+ if fontid then
+ local objref = pdfreserveobject()
+ if trace_merge then
+ report_merge("registering %a with name %a, id %a and object %a",usedname,cleanname,fontid,objref)
+ end
+ return {
+ id = fontid,
+ reference = objref,
+ indices = { },
+ cleanname = cleanname,
+ }
+ end
+ return false
+end
+
+function lpdf.registerfont(usedname,cleanname)
+ local v = register(usedname,cleanname)
+ tobemerged[usedname] = v
+ return v
+end
+
+table.setmetatableindex(tobemerged,function(t,k)
+ return lpdf.registerfont(k)
+end)
+
+local function finalizefont(v)
+ local indextoslot = fonts.helpers.indextoslot
+ if v then
+ local id = v.id
+ local n = 0
+ for i in next, v.indices do
+ local u = indextoslot(id,i)
+ n = n + 1
+ end
+ v.n = n
+ end
+end
+
+statistics.register("merged fonts", function()
+ if next(tobemerged) then
+ local t = { }
+ for k, v in table.sortedhash(tobemerged) do
+ t[#t+1] = string.formatters["%s (+%i)"](k,v.n)
+ end
+ return table.concat(t," ")
+ end
+end)
+
+function lpdf.finalizefonts()
+ for k, v in next, tobemerged do
+ finalizefont(v)
+ end
+end
+
+callback.register("font_descriptor_objnum_provider",function(name)
+ local m = rawget(tobemerged,name)
+ if m then
+ -- finalizefont(m)
+ local r = m.reference or 0
+ if trace_merge then
+ report_merge("using object %a for font descriptor of %a",r,name)
+ end
+ return r
+ end
+ return 0
+end)
+
+local function getunicodes1(str,indices)
+ for s in gmatch(str,"beginbfrange%s*(.-)%s*endbfrange") do
+ for first, last, offset in gmatch(s,"<([^>]+)>%s+<([^>]+)>%s+<([^>]+)>") do
+ for i=tonumber(first,16),tonumber(last,16) do
+ indices[i] = true
+ end
+ end
+ end
+ for s in gmatch(str,"beginbfchar%s*(.-)%s*endbfchar") do
+ for old, new in gmatch(s,"<([^>]+)>%s+<([^>]+)>") do
+ indices[tonumber(old,16)] = true
+ end
+ end
+end
+
+local function getunicodes2(widths,indices)
+ for i=1,#widths,2 do
+ local start = widths[i]
+ local count = #widths[i+1]
+ if start and count then
+ for i=start,start+count-1 do
+ indices[i] = true
+ end
+ end
+ end
+end
+
+local function checkedfonts(pdfdoc,xref,copied,page)
+ local list = page.Resources.Font
+ local done = { }
+ for k, somefont in pdfe.expanded(list) do
+ if somefont.Subtype == "Type0" and somefont.Encoding == "Identity-H" then
+ local descendants = somefont.DescendantFonts
+ if descendants then
+ for i=1,#descendants do
+ local d = descendants[i]
+ if d then
+ local subtype = d.Subtype
+ if subtype == "CIDFontType0" or subtype == "CIDFontType2" then
+ local basefont = somefont.BaseFont
+ if basefont then
+ local fontname = match(basefont,"^[A-Z]+%+(.+)$")
+ local fontdata = tobemerged[fontname]
+ if fontdata then
+ local descriptor = d.FontDescriptor
+ if descriptor then
+ local okay = false
+ local widths = d.W
+ if widths then
+ getunicodes2(widths,fontdata.indices)
+ okay = true
+ else
+ local tounicode = somefont.ToUnicode
+ if tounicode then
+ getunicodes1(tounicode(),fontdata.indices)
+ okay = true
+ end
+ end
+ if okay then
+ local r = xref[descriptor]
+ done[r] = fontdata.reference
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return next(done) and done
+end
+
+function lpdf.epdf.plugin(pdfdoc,xref,copied,page) -- needs checking
+ local done = checkedfonts(pdfdoc,xref,copied,page)
+ if done then
+ return {
+ FontDescriptor = function(xref,copied,object,key,value,copyobject)
+ local r = value[3]
+ local d = done[r]
+ if d then
+ return pdfreference(d)
+ else
+ return copyobject(xref,copied,object,key,value)
+ end
+ end
+ }
+ end
+end
+
+lpdf.registerdocumentfinalizer(lpdf.finalizefonts)
+
+-- already defined in font-ocl but the context variatn will go here
+--
+-- function lpdf.vfimage(wd,ht,dp,data,name)
+-- return { "image", { filename = name, width = wd, height = ht, depth = dp } }
+-- end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-grp.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-grp.lmt
new file mode 100644
index 00000000000..6adbe8c3c91
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-grp.lmt
@@ -0,0 +1,302 @@
+if not modules then modules = { } end modules ['lpdf-grp'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type, tonumber = type, tonumber
+local formatters, gsub = string.formatters, string.gsub
+local concat = table.concat
+local round = math.round
+
+local backends, lpdf = backends, lpdf
+
+local nodeinjections = backends.pdf.nodeinjections
+
+local colors = attributes.colors
+local basepoints = number.dimenfactors.bp
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
+
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfboolean = lpdf.boolean
+local pdfreference = lpdf.reference
+
+local pdfflushobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+end)
+
+local createimage = images.create
+local wrapimage = images.wrap
+local embedimage = images.embed
+
+-- can also be done indirectly:
+--
+-- 12 : << /AntiAlias false /ColorSpace 8 0 R /Coords [ 0.0 0.0 1.0 0.0 ] /Domain [ 0.0 1.0 ] /Extend [ true true ] /Function 22 0 R /ShadingType 2 >>
+-- 22 : << /Bounds [ ] /Domain [ 0.0 1.0 ] /Encode [ 0.0 1.0 ] /FunctionType 3 /Functions [ 31 0 R ] >>
+-- 31 : << /C0 [ 1.0 0.0 ] /C1 [ 0.0 1.0 ] /Domain [ 0.0 1.0 ] /FunctionType 2 /N 1.0 >>
+
+local function shade(stype,name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps,fractions)
+ local func = nil
+ --
+ -- domain has to be consistently added in all dictionaries here otherwise
+ -- acrobat fails with a drawing error
+ --
+ domain = pdfarray(domain)
+ n = tonumber(n)
+ --
+ if steps then
+ local list = pdfarray()
+ local bounds = pdfarray()
+ local encode = pdfarray()
+ for i=1,steps do
+ if i < steps then
+ bounds[i] = fractions[i] or 1
+ end
+ encode[2*i-1] = 0
+ encode[2*i] = 1
+ list [i] = pdfdictionary {
+ FunctionType = 2,
+ Domain = domain,
+ C0 = pdfarray(color_a[i]),
+ C1 = pdfarray(color_b[i]),
+ N = n,
+ }
+ end
+ func = pdfdictionary {
+ FunctionType = 3,
+ Bounds = bounds,
+ Encode = encode,
+ Functions = list,
+ Domain = domain,
+ }
+ else
+ func = pdfdictionary {
+ FunctionType = 2,
+ Domain = domain,
+ C0 = pdfarray(color_a),
+ C1 = pdfarray(color_b),
+ N = n,
+ }
+ end
+ separation = separation and registrations.getspotcolorreference(separation)
+ local s = pdfdictionary {
+ ShadingType = stype,
+ ColorSpace = separation and pdfreference(separation) or pdfconstant(colorspace),
+ Domain = domain,
+ Function = pdfreference(pdfflushobject(func)),
+ Coords = pdfarray(coordinates),
+ Extend = pdfarray { true, true },
+ AntiAlias = pdfboolean(true),
+ }
+ lpdf.adddocumentshade(name,pdfreference(pdfflushobject(s)))
+end
+
+function lpdf.circularshade(name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps,fractions)
+ shade(3,name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps,fractions)
+end
+
+function lpdf.linearshade(name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps,fractions)
+ shade(2,name,domain,color_a,color_b,n,colorspace,coordinates,separation,steps,fractions)
+end
+
+-- inline bitmaps but xform'd
+--
+-- we could derive the colorspace if we strip the data
+-- and divide by x*y
+
+local template = "q BI %s ID %s > EI Q"
+local factor = 72/300
+
+function nodeinjections.injectbitmap(t)
+ -- encoding is ascii hex, no checking here
+ local xresolution, yresolution = t.xresolution or 0, t.yresolution or 0
+ if xresolution == 0 or yresolution == 0 then
+ return -- fatal error
+ end
+ local colorspace = t.colorspace
+ if colorspace ~= "rgb" and colorspace ~= "cmyk" and colorspace ~= "gray" then
+ -- not that efficient but ok
+ local d = gsub(t.data,"[^0-9a-f]","")
+ local b = math.round(#d / (xresolution * yresolution))
+ if b == 2 then
+ colorspace = "gray"
+ elseif b == 6 then
+ colorspace = "rgb"
+ elseif b == 8 then
+ colorspace = "cmyk"
+ end
+ end
+ colorspace = lpdf.colorspaceconstants[colorspace]
+ if not colorspace then
+ return -- fatal error
+ end
+ local d = pdfdictionary {
+ W = xresolution,
+ H = yresolution,
+ CS = colorspace,
+ BPC = 8,
+ F = pdfconstant("AHx"),
+ -- CS = nil,
+ -- BPC = 1,
+ -- IM = true,
+ }
+ -- for some reasons it only works well if we take a 1bp boundingbox
+ local urx, ury = 1/basepoints, 1/basepoints
+ -- urx = (xresolution/300)/basepoints
+ -- ury = (yresolution/300)/basepoints
+ local width, height = t.width or 0, t.height or 0
+ if width == 0 and height == 0 then
+ width = factor * xresolution / basepoints
+ height = factor * yresolution / basepoints
+ elseif width == 0 then
+ width = height * xresolution / yresolution
+ elseif height == 0 then
+ height = width * yresolution / xresolution
+ end
+ local a = pdfdictionary {
+ BBox = pdfarray { 0, 0, urx * basepoints, ury * basepoints }
+ }
+ local image = createimage {
+ stream = formatters[template](d(),t.data),
+ width = width,
+ height = height,
+ bbox = { 0, 0, urx, ury },
+ attr = a(),
+ nobbox = true,
+ }
+ return wrapimage(image)
+end
+
+-- general graphic helpers
+
+function codeinjections.setfigurealternative(data,figure)
+ local request = data.request
+ local display = request.display
+ if display and display ~= "" then
+ local nested = figures.push {
+ name = display,
+ page = request.page,
+ size = request.size,
+ prefix = request.prefix,
+ cache = request.cache,
+ width = request.width,
+ height = request.height,
+ }
+ figures.identify()
+ local displayfigure = figures.check()
+ if displayfigure then
+ -- figure.aform = true
+ embedimage(figure)
+ local a = pdfarray {
+ pdfdictionary {
+ Image = pdfreference(figure.objnum),
+ DefaultForPrinting = true,
+ }
+ }
+ local d = pdfdictionary {
+ Alternates = pdfreference(pdfflushobject(a)),
+ }
+ displayfigure.attr = d()
+ figures.pop()
+ return displayfigure, nested
+ else
+ figures.pop()
+ end
+ end
+end
+
+function codeinjections.getpreviewfigure(request)
+ local figure = figures.initialize(request)
+ if not figure then
+ return
+ end
+ figure = figures.identify(figure)
+ if not (figure and figure.status and figure.status.fullname) then
+ return
+ end
+ figure = figures.check(figure)
+ if not (figure and figure.status and figure.status.fullname) then
+ return
+ end
+ local image = figure.status.private
+ if image then
+ embedimage(image)
+ end
+ return figure
+end
+
+function codeinjections.setfiguremask(data,figure) -- mark
+ local request = data.request
+ local mask = request.mask
+ if mask and mask ~= "" then
+ figures.push {
+ name = mask,
+ page = request.page,
+ size = request.size,
+ prefix = request.prefix,
+ cache = request.cache,
+ width = request.width,
+ height = request.height,
+ }
+ mask = figures.identify()
+ mask = figures.check(mask)
+ if mask then
+ local image = mask.status.private
+ if image then
+ figures.include(mask)
+ embedimage(image)
+ local d = pdfdictionary {
+ Interpolate = false,
+ SMask = pdfreference(mask.status.objectnumber),
+ }
+ figure.attr = d()
+ end
+ end
+ figures.pop()
+ end
+end
+
+-- experimental (q Q is not really needed)
+
+local saveboxresource = tex.boxresources.save
+local nofpatterns = 0
+local f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6N %.6N re f Q"]
+
+function lpdf.registerpattern(specification)
+ nofpatterns = nofpatterns + 1
+ local d = pdfdictionary {
+ Type = pdfconstant("Pattern"),
+ PatternType = 1,
+ PaintType = 1,
+ TilingType = 2,
+ XStep = (specification.width or 10) * basepoints,
+ YStep = (specification.height or 10) * basepoints,
+ Matrix = {
+ 1, 0, 0, 1,
+ (specification.hoffset or 0) * basepoints,
+ (specification.voffset or 0) * basepoints,
+ },
+ }
+
+ local resources = lpdf.collectedresources{ patterns = false }
+ local attributes = d()
+ local onlybounds = 1
+ local patternobj = saveboxresource(specification.number,attributes,resources,true,onlybounds)
+ lpdf.adddocumentpattern("Pt" .. nofpatterns,lpdf.reference(patternobj ))
+ return nofpatterns
+end
+
+function lpdf.patternstream(n,width,height)
+ return f_pattern("Pt" .. n,width*basepoints,height*basepoints)
+end
+
+backends.pdf.codeinjections.registerpattern = lpdf.registerpattern
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-img.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-img.lmt
new file mode 100644
index 00000000000..50034c36025
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-img.lmt
@@ -0,0 +1,1351 @@
+if not modules then modules = { } end modules ['lpdf-img'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This started as an experiment but has potential for some (cached) optimizations.
+-- At some point we can also use it for fonts. For small images performance is ok
+-- with pure lua but for bigger images we can use some helpers. Normally in a
+-- typesetting workflow non-interlaced images are used. One should convert
+-- interlaced images to more efficient non-interlaced ones (ok, we can cache
+-- them if needed).
+--
+-- The \LUA\ code is slightly optimized so we could have done with less lines if
+-- we wanted but best gain a little. The idea is that we collect striped (in stages)
+-- so that we can play with substitutions.
+
+local type = type
+local concat, move = table.concat, table.move
+local ceil, min = math.ceil, math.min
+local char, byte, find, gmatch = string.char, string.byte, string.find, string.gmatch
+local idiv = number.idiv
+local band, rshift = bit32.band, bit32.rshift
+
+local loaddata = io.loaddata
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local streams = utilities.streams
+local openstring = streams.openstring
+local readstring = streams.readstring
+local readbytetable = streams.readbytetable
+
+local newreader = io.newreader
+
+local tobytetable = string.bytetable
+
+local lpdf = lpdf or { }
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfstring = lpdf.string
+local pdfreference = lpdf.reference
+local pdfverbose = lpdf.verbose
+
+local pdfflushstreamobject
+local pdfmajorversion
+local pdfminorversion
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushstreamobject = lpdf.flushstreamobject
+ pdfmajorversion = lpdf.majorversion
+ pdfminorversion = lpdf.minorversion
+end)
+
+local createimage = images.create
+
+local zlibcompress = (xzip or zlib).compress
+local zlibdecompress = (xzip or zlib).decompress
+
+local trace = false
+
+local report_jpg = logs.reporter("graphics","jpg")
+local report_jp2 = logs.reporter("graphics","jp2")
+local report_png = logs.reporter("graphics","png")
+
+trackers.register("graphics.backend", function(v) trace = v end)
+
+local injectors = { }
+lpdf.injectors = injectors
+
+-- todo: load from a virtual file
+
+local function loadcontent(filename,method)
+ return method == "string" and filename or loaddata(filename)
+end
+
+local function newcontent(filename,method)
+ return newreader(filename,method)
+end
+
+--
+
+local chars = setmetatableindex(function(t,k) -- share this one
+ local v = (k <= 0 and "\000") or (k >= 255 and "\255") or char(k)
+ t[k] = v
+ return v
+end)
+
+do
+
+ function injectors.jpg(specification,method)
+ if specification.error then
+ return
+ end
+ local filename = specification.filename
+ if not filename then
+ return
+ end
+ local colorspace = specification.colorspace or jpg_gray
+ local decodearray = nil
+ ----- procset = colorspace == 0 and "image b" or "image c"
+ if colorspace == 1 then
+ colorspace = "DeviceGray"
+ elseif colorspace == 2 then
+ colorspace = "DeviceRGB"
+ elseif colorspace == 3 then
+ colorspace = "DeviceCMYK"
+ decodearray = pdfarray { 1, 0, 1, 0, 1, 0, 1, 0 }
+ end
+ -- todo: set filename
+ local xsize = specification.xsize
+ local ysize = specification.ysize
+ local colordepth = specification.colordepth
+ local content = loadcontent(filename,method)
+ local xobject = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Image"),
+ -- BBox = pdfarray { 0, 0, xsize, ysize },
+ Width = xsize,
+ Height = ysize,
+ BitsPerComponent = colordepth,
+ Filter = pdfconstant("DCTDecode"),
+ ColorSpace = pdfconstant(colorspace),
+ Decode = decodearray,
+ Length = #content, -- specification.length
+ } + specification.attr
+ if trace then
+ report_jpg("%s: width %i, height %i, colordepth %i, size %i",filename,xsize,ysize,colordepth,#content)
+ end
+ return createimage {
+ bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
+ transform = specification.transform,
+ nolength = true,
+ nobbox = true,
+ notype = true,
+ stream = content,
+ attr = xobject(),
+ }
+ end
+
+end
+
+do
+
+ function injectors.jp2(specification,method)
+ if specification.error then
+ return
+ end
+ local filename = specification.filename
+ if not filename then
+ return
+ end
+ -- todo: set filename
+ local xsize = specification.xsize
+ local ysize = specification.ysize
+ local content = loadcontent(filename,method)
+ local xobject = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Image"),
+ BBox = pdfarray { 0, 0, xsize, ysize },
+ Width = xsize,
+ Height = ysize,
+ Filter = pdfconstant("JPXDecode"),
+ Length = #content, -- specification.length
+ } + specification.attr
+ if trace then
+ report_jp2("%s: width %i, height %i, size %i",filename,xsize,ysize,#content)
+ end
+ return createimage {
+ bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
+ transform = specification.transform,
+ nolength = true,
+ nobbox = true,
+ notype = true,
+ stream = content,
+ attr = xobject(),
+ }
+ end
+
+end
+
+do
+
+ -- We don't like interlaced files. You can deinterlace them beforehand because otherwise
+ -- each run you add runtime. Actually, even masked images can best be converted to PDF
+ -- beforehand.
+
+ -- The amount of code is larger that I like and looks somewhat redundant but we sort of
+ -- optimize a few combinations that happen often.
+
+ local pngapplyfilter = pngdecode.applyfilter
+ local pngsplitmask = pngdecode.splitmask
+ local pnginterlace = pngdecode.interlace
+ local pngexpand = pngdecode.expand
+ local pngtocmyk = pngdecode.tocmyk
+
+ local filtermask, decodemask, decodestrip, transpose, expand, tocmyk
+
+ local newindex = lua.newindex
+ local newtable = lua.newtable
+
+ local function newoutput(size)
+ if newindex then
+ return newindex(size,0)
+ end
+ local t = newtable and newtable(size,0) or { }
+ for i=1,size do
+ t[i] = 0
+ end
+ return t
+ end
+
+ local function convert(t)
+ if type(t) == "table" then
+ for i=1,#t do
+ local ti = t[i]
+ if ti ~= "" then -- soon gone
+ t[i] = chars[ti]
+ end
+ end
+ return concat(t)
+ else
+ return t
+ end
+ end
+
+ local function zero(t,k)
+ return 0
+ end
+
+ local function applyfilter(t,xsize,ysize,bpp)
+ local len = xsize * bpp + 1
+ local n = 1
+ local m = len - 1
+ for i=1,ysize do
+ local filter = t[n]
+ t[n] = ""
+ if filter == 0 then
+ elseif filter == 1 then
+ for j=n+bpp+1,n+m do
+ t[j] = (t[j] + t[j-bpp]) % 256
+ end
+ elseif filter == 2 then
+ for j=n+1,n+m do
+ t[j] = (t[j] + t[j-len]) % 256
+ end
+ elseif filter == 3 then
+ for j=n+1,n+bpp do
+ t[j] = (t[j] + idiv(t[j-len],2)) % 256
+ end
+ for j=n+bpp+1,n+m do
+ t[j] = (t[j] + idiv(t[j-bpp] + t[j-len],2)) % 256
+ end
+ elseif filter == 4 then
+ for j=n+1,n+bpp do
+ local p = j - len
+ local b = t[p]
+ if b > 0 then
+ t[j] = (t[j] + b) % 256
+ end
+ end
+ for j=n+bpp+1,n+m do
+ local p = j - len
+ local a = t[j-bpp]
+ local b = t[p]
+ local c = t[p-bpp]
+ local pa = b - c
+ local pb = a - c
+ local pc = pa + pb
+ if pa < 0 then pa = - pa end
+ if pb < 0 then pb = - pb end
+ if pc < 0 then pc = - pc end
+ t[j] = (t[j] + ((pa <= pb and pa <= pc and a) or (pb <= pc and b) or c)) % 256
+ end
+ end
+ n = n + len
+ end
+ return t
+ end
+
+ local filtermask_l = function (content,xsize,ysize,colordepth,colorspace,hasfilter)
+ local mask = { }
+ local bytes = colordepth == 16 and 2 or 1
+ local bpp = colorspace == "DeviceRGB" and 3 or 1
+ local length = #content
+ local size = ysize * xsize * ((bpp+1)*bytes + (hasfilter and 1 or 0))
+ local n = 1
+ local l = 1
+ if bytes == 2 then
+ if bpp == 1 then
+ for i=1,ysize do
+ if hasfilter then
+ content[n] = "" ; n = n + 1
+ end
+ for j=1,xsize do
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ mask[l] = chars[content[n]] ; l = l + 1
+ content[n] = "" ; n = n + 1
+ mask[l] = chars[content[n]] ; l = l + 1
+ content[n] = "" ; n = n + 1
+ end
+ end
+ elseif bpp == 3 then
+ for i=1,ysize do
+ if hasfilter then
+ content[n] = "" ; n = n + 1
+ end
+ for j=1,xsize do
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ mask[l] = chars[content[n]] ; l = l + 1
+ content[n] = "" ; n = n + 1
+ mask[l] = chars[content[n]] ; l = l + 1
+ content[n] = "" ; n = n + 1
+ end
+ end
+ else
+ return "", ""
+ end
+ else
+ if bpp == 1 then
+ for i=1,ysize do
+ if hasfilter then
+ content[n] = "" ; n = n + 1
+ end
+ for j=1,xsize do
+ content[n] = chars[content[n]] ; n = n + 1
+ mask[l] = chars[content[n]] ; l = l + 1
+ content[n] = "" ; n = n + 1
+ end
+ end
+ elseif bpp == 3 then
+ for i=1,ysize do
+ if hasfilter then
+ content[n] = "" ; n = n + 1
+ end
+ for j=1,xsize do
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ content[n] = chars[content[n]] ; n = n + 1
+ mask[l] = chars[content[n]] ; l = l + 1
+ content[n] = "" ; n = n + 1
+ end
+ end
+ else
+ return "", ""
+ end
+ end
+ return concat(content), concat(mask)
+ end
+
+ local decodemask_l = function(content,xsize,ysize,colordepth,colorspace)
+ local bytes = colordepth == 16 and 2 or 1
+ local bpp = colorspace == "DeviceRGB" and 3 or 1
+ local slice = bytes*(bpp+1)
+ local length = #content
+ local size = ysize * xsize * ((bpp+1)*bytes + 1) -- assume filter
+ content = openstring(content)
+ content = readbytetable(content,length)
+ setmetatableindex(content,zero)
+ applyfilter(content,xsize,ysize,slice)
+ content, mask = filtermask(content,xsize,ysize,colordepth,colorspace,true)
+ return content, mask
+ end
+
+ local filtermask_c = function(content,xsize,ysize,colordepth,colorspace)
+ local bytes = colordepth == 16 and 2 or 1
+ local bpp = colorspace == "DeviceRGB" and 3 or 1
+ return pngsplitmask(content,xsize,ysize,bpp,bytes)
+ end
+
+ local decodemask_c = function(content,xsize,ysize,colordepth,colorspace)
+ local mask = true
+ local filter = false
+ local bytes = colordepth == 16 and 2 or 1
+ local bpp = colorspace == "DeviceRGB" and 3 or 1
+ local slice = bytes * (bpp + 1) -- always a mask
+ content = pngapplyfilter(content,xsize,ysize,slice)
+ return pngsplitmask(content,xsize,ysize,bpp,bytes,mask,filter)
+ end
+
+ local function decodestrip_l(s,nx,ny,slice)
+ local input = readbytetable(s,ny*(nx*slice+1))
+ setmetatableindex(input,zero)
+ applyfilter(input,nx,ny,slice)
+ return input, true
+ end
+
+ local function decodestrip_c(s,nx,ny,slice)
+ local input = readstring(s,ny*(nx*slice+1))
+ input = pngapplyfilter(input,nx,ny,slice)
+ return input, false
+ end
+
+ local xstart = { 0, 4, 0, 2, 0, 1, 0 }
+ local ystart = { 0, 0, 4, 0, 2, 0, 1 }
+ local xstep = { 8, 8, 4, 4, 2, 2, 1 }
+ local ystep = { 8, 8, 8, 4, 4, 2, 2 }
+
+ local xblock = { 8, 4, 4, 2, 2, 1, 1 }
+ local yblock = { 8, 8, 4, 4, 2, 2, 1 }
+
+ local function transpose_l(xsize,ysize,slice,pass,input,output,filter)
+ local xstart = xstart[pass]
+ local xstep = xstep[pass]
+ local ystart = ystart[pass]
+ local ystep = ystep[pass]
+ local nx = idiv(xsize + xstep - xstart - 1,xstep)
+ local ny = idiv(ysize + ystep - ystart - 1,ystep)
+ local offset = filter and 1 or 0
+ local xstep = xstep * slice
+ local xstart = xstart * slice
+ local xsize = xsize * slice
+ local target = ystart * xsize + xstart + 1
+ local ystep = ystep * xsize
+ local start = 1
+ local plus = nx * xstep
+ local step = plus - xstep
+ if not output then
+ output = newoutput(xsize*(parts or slice)*ysize)
+ end
+ if slice == 1 then
+ for j=0,ny-1 do
+ start = start + offset
+ local target = target + j * ystep
+ for target=target,target+step,xstep do
+ output[target] = input[start]
+ start = start + slice
+ end
+ end
+ elseif slice == 2 then
+ for j=0,ny-1 do
+ start = start + offset
+ local target = target + j * ystep
+ for target=target,target+step,xstep do
+ output[target] = input[start]
+ output[target+1] = input[start+1]
+ start = start + slice
+ end
+ end
+ elseif slice == 3 then
+ for j=0,ny-1 do
+ start = start + offset
+ local target = target + j * ystep
+ for target=target,target+step,xstep do
+ output[target] = input[start]
+ output[target+1] = input[start+1]
+ output[target+2] = input[start+2]
+ start = start + slice
+ end
+ end
+ elseif slice == 4 then
+ for j=0,ny-1 do
+ start = start + offset
+ local target = target + j * ystep
+ for target=target,target+step,xstep do
+ output[target] = input[start]
+ output[target+1] = input[start+1]
+ output[target+2] = input[start+2]
+ output[target+3] = input[start+3]
+ start = start + slice
+ end
+ end
+ else
+ local delta = slice - 1
+ for j=0,ny-1 do
+ start = start + offset
+ local target = target + j * ystep
+ for target=target,target+step,xstep do
+ move(input,start,start+delta,target,output)
+ start = start + slice
+ end
+ end
+ end
+ return output;
+ end
+
+ local transpose_c = pnginterlace
+
+ -- print(band(rshift(v,4),0x03),extract(v,4,2))
+ -- print(band(rshift(v,6),0x03),extract(v,6,2))
+
+ local function expand_l(t,xsize,ysize,parts,run,factor,filter)
+ local size = ysize * xsize + 1 -- a bit of overshoot, needs testing, probably a few bytes us ok
+ local xline = filter and (run+1) or run
+ local f = filter and 1 or 0
+ local l = xline - 1
+ local n = 1
+ local o = newoutput(size)
+ local k = 0
+ if factor then
+ if parts == 4 then
+ for i=1,ysize do
+ for j=n+f,n+l do
+ local v = t[j]
+ if v == 0 then
+ k = k + 2
+ else
+ k = k + 1 ; o[k] = extract4(v,4) * 0x11
+ k = k + 1 ; o[k] = extract4(v,0) * 0x11
+ end
+ end
+ k = i * xsize
+ n = n + xline
+ end
+ elseif parts == 2 then
+ for i=1,ysize do
+ for j=n+f,n+l do
+ local v = t[j]
+ if v == 0 then
+ k = k + 4
+ else
+ k = k + 1 ; o[k] = extract2(v,6) * 0x55
+ k = k + 1 ; o[k] = extract2(v,4) * 0x55
+ k = k + 1 ; o[k] = extract2(v,2) * 0x55
+ k = k + 1 ; o[k] = extract2(v,0) * 0x55
+ end
+ end
+ k = i * xsize
+ n = n + xline
+ end
+ else
+ for i=1,ysize do
+ for j=n+f,n+l do
+ local v = t[j]
+ if v == 0 then
+ k = k + 8
+ else
+ k = k + 1 ; if band(v,0x80) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,7) * 0xFF
+ k = k + 1 ; if band(v,0x40) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,6) * 0xFF
+ k = k + 1 ; if band(v,0x20) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,5) * 0xFF
+ k = k + 1 ; if band(v,0x10) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,4) * 0xFF
+ k = k + 1 ; if band(v,0x08) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,3) * 0xFF
+ k = k + 1 ; if band(v,0x04) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,2) * 0xFF
+ k = k + 1 ; if band(v,0x02) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,1) * 0xFF
+ k = k + 1 ; if band(v,0x01) ~= 0 then o[k] = 0xFF end -- o[k] = extract1(v,0) * 0xFF
+ end
+ end
+ k = i * xsize
+ n = n + xline
+ end
+ end
+ else
+ if parts == 4 then
+ for i=1,ysize do
+ for j=n+f,n+l do
+ local v = t[j]
+ if v == 0 then
+ k = k + 2
+ else
+ k = k + 1 ; o[k] = extract4(v,4)
+ k = k + 1 ; o[k] = extract4(v,0)
+ end
+ end
+ k = i * xsize
+ n = n + xline
+ end
+ elseif parts == 2 then
+ for i=1,ysize do
+ for j=n+f,n+l do
+ local v = t[j]
+ if v == 0 then
+ k = k + 4
+ else
+ k = k + 1 ; o[k] = extract2(v,6)
+ k = k + 1 ; o[k] = extract2(v,4)
+ k = k + 1 ; o[k] = extract2(v,2)
+ k = k + 1 ; o[k] = extract2(v,0)
+ end
+ end
+ k = i * xsize
+ n = n + xline
+ end
+ else
+ for i=1,ysize do
+ for j=n+f,n+l do
+ local v = t[j]
+ if v == 0 then
+ k = k + 8
+ else
+ k = k + 1 ; if band(v,0x80) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,7)
+ k = k + 1 ; if band(v,0x40) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,6)
+ k = k + 1 ; if band(v,0x20) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,5)
+ k = k + 1 ; if band(v,0x10) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,4)
+ k = k + 1 ; if band(v,0x08) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,3)
+ k = k + 1 ; if band(v,0x04) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,2)
+ k = k + 1 ; if band(v,0x02) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,1)
+ k = k + 1 ; if band(v,0x01) ~= 0 then o[k] = 1 end -- o[k] = extract1(v,0)
+ end
+ end
+ k = i * xsize
+ n = n + xline
+ end
+ end
+ end
+ for i=size,xsize * ysize +1,-1 do
+ o[i] = nil
+ end
+ return o, false
+ end
+
+ local expand_c = pngexpand
+
+ local function analyze(colordepth,colorspace,palette,mask)
+ -- return bytes, parts, factor
+ if palette then
+ if colordepth == 16 then
+ return 2, false, false
+ elseif colordepth == 8 then
+ return 1, false, false
+ elseif colordepth == 4 then
+ return 1, 4, false
+ elseif colordepth == 2 then
+ return 1, 2, false
+ elseif colordepth == 1 then
+ return 1, 1, false
+ end
+ elseif colorspace == "DeviceGray" then
+ if colordepth == 16 then
+ return mask and 4 or 2, false, false
+ elseif colordepth == 8 then
+ return mask and 2 or 1, false, false
+ elseif colordepth == 4 then
+ return 1, 4, true
+ elseif colordepth == 2 then
+ return 1, 2, true
+ elseif colordepth == 1 then
+ return 1, 1, true
+ end
+ else
+ if colordepth == 16 then
+ return mask and 8 or 6, false, false
+ elseif colordepth == 8 then
+ return mask and 4 or 3, false, false
+ elseif colordepth == 4 then
+ return 3, 4, true
+ elseif colordepth == 2 then
+ return 3, 2, true
+ elseif colordepth == 1 then
+ return 3, 1, true
+ end
+ end
+ return false, false, false
+ end
+
+ -- 1 6 4 6 2 6 4 6
+ -- 7 7 7 7 7 7 7 7
+ -- 5 6 5 6 5 6 5 6
+ -- 7 7 7 7 7 7 7 7
+ -- 3 6 4 6 3 6 4 6
+ -- 7 7 7 7 7 7 7 7
+ -- 5 6 5 6 5 6 5 6
+ -- 7 7 7 7 7 7 7 7
+
+ local function deinterlace(content,xsize,ysize,colordepth,colorspace,palette,mask)
+ local slice, parts, factor = analyze(colordepth,colorspace,palette,mask)
+ if slice then
+ content = openstring(zlibdecompress(content))
+ local filter = false
+ local output = false
+ for pass=1,7 do
+ local xstart = xstart[pass]
+ local xstep = xstep[pass]
+ local ystart = ystart[pass]
+ local ystep = ystep[pass]
+ local nx = idiv(xsize + xstep - xstart - 1,xstep)
+ local ny = idiv(ysize + ystep - ystart - 1,ystep)
+ if nx > 0 and ny > 0 then
+ local input, filter
+ if parts then
+ local nxx = ceil(nx*parts/8)
+ input, filter = decodestrip(content,nxx,ny,slice)
+ input, filter = expand(input,nx,ny,parts,nxx,factor,filter)
+ else
+ input, filter = decodestrip(content,nx,ny,slice)
+ end
+ output = transpose(xsize,ysize,slice,pass,input,output,filter)
+ end
+ -- if pass == 3 then
+ -- break -- still looks ok, could be nice for a preroll
+ -- end
+ end
+ return output, parts and 8 or false
+ end
+ end
+
+ -- 1 (palette used), 2 (color used), and 4 (alpha channel used)
+
+ -- paeth:
+ --
+ -- p = a + b - c
+ -- pa = abs(p - a) => a + b - c - a => b - c
+ -- pb = abs(p - b) => a + b - c - b => a - c
+ -- pc = abs(p - c) => a + b - c - c => a + b - c - c => a - c + b - c => pa + pb
+
+ local function full(t,k) local v = "\xFF" t[k] = v return v end
+
+ local function expandvector(transparent)
+ local s = openstring(transparent)
+ local n = #transparent
+ local r = { }
+ for i=0,n-1 do
+ r[i] = readstring(s,1) -- readchar
+ end
+ setmetatableindex(r,full)
+ return r
+ end
+
+ local function createmask_l(content,palette,transparent,xsize,ysize,colordepth,colorspace)
+ if palette then
+ local r = expandvector(transparent)
+ local size = xsize*ysize
+ local len = ceil(xsize*colordepth/8) + 1
+ local o = newoutput(xsize*ysize)
+ local u = setmetatableindex(zero)
+ content = zlibdecompress(content)
+ content = openstring(content)
+ for i=0,ysize-1 do
+ local t = readbytetable(content,len)
+ local k = i * xsize
+ local filter = t[1]
+ if filter == 0 then
+ elseif filter == 1 then
+ for j=3,len do
+ t[j] = (t[j] + t[j-1]) % 256
+ end
+ elseif filter == 2 then
+ for j=2,len do
+ t[j] = (t[j] + u[j]) % 256
+ end
+ elseif filter == 3 then
+ local j = 2
+ t[j] = (t[j] + idiv(u[j],2)) % 256
+ for j=3,len do
+ t[j] = (t[j] + idiv(t[j-1] + u[j],2)) % 256
+ end
+ elseif filter == 4 then
+ local j = 2
+ local p = j - len
+ local b = t[p]
+ if b < 0 then
+ b = - b
+ end
+ if b > 0 then
+ t[j] = (t[j] + b) % 256
+ end
+ for j=3,len do
+ local p = j - len
+ local a = t[j-1]
+ local b = t[p]
+ local c = t[p-1]
+ local pa = b - c
+ local pb = a - c
+ local pc = pa + pb
+ if pa < 0 then pa = - pa end
+ if pb < 0 then pb = - pb end
+ if pc < 0 then pc = - pc end
+ t[j] = (t[j] + ((pa <= pb and pa <= pc and a) or (pb <= pc and b) or c)) % 256
+ end
+ end
+ if colordepth == 8 then
+ for j=2,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[v]
+ end
+ elseif colordepth == 4 then
+ for j=2,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[extract4(v,4)]
+ k = k + 1 ; o[k] = r[extract4(v,0)]
+ end
+ elseif colordepth == 2 then
+ for j=2,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[extract2(v,6)]
+ k = k + 1 ; o[k] = r[extract2(v,4)]
+ k = k + 1 ; o[k] = r[extract2(v,2)]
+ k = k + 1 ; o[k] = r[extract2(v,0)]
+ end
+ else
+ for j=2,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[extract1(v,7)]
+ k = k + 1 ; o[k] = r[extract1(v,6)]
+ k = k + 1 ; o[k] = r[extract1(v,5)]
+ k = k + 1 ; o[k] = r[extract1(v,4)]
+ k = k + 1 ; o[k] = r[extract1(v,3)]
+ k = k + 1 ; o[k] = r[extract1(v,2)]
+ k = k + 1 ; o[k] = r[extract1(v,1)]
+ k = k + 1 ; o[k] = r[extract1(v,0)]
+ end
+ end
+ u = t
+ end
+ return concat(o,"",1,size)
+ end
+ end
+
+ local function createmask_c(content,palette,transparent,xsize,ysize,colordepth,colorspace)
+ if palette then
+ local r = expandvector(transparent)
+ local size = xsize*ysize
+ local len = ceil(xsize*colordepth/8)
+ local o = newoutput(size)
+ content = zlibdecompress(content)
+ content = pngapplyfilter(content,len,ysize,1) -- nostrip (saves copy)
+ content = openstring(content)
+ for i=0,ysize-1 do
+ local t = readbytetable(content,len)
+ local k = i * xsize
+ if colordepth == 8 then
+ for j=1,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[v]
+ end
+ elseif colordepth == 4 then
+ for j=1,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[extract4(v,4)]
+ k = k + 1 ; o[k] = r[extract4(v,0)]
+ end
+ elseif colordepth == 2 then
+ for j=1,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[extract2(v,6)]
+ k = k + 1 ; o[k] = r[extract2(v,4)]
+ k = k + 1 ; o[k] = r[extract2(v,2)]
+ k = k + 1 ; o[k] = r[extract2(v,0)]
+ end
+ else
+ for j=1,len do
+ local v = t[j]
+ k = k + 1 ; o[k] = r[extract1(v,7)]
+ k = k + 1 ; o[k] = r[extract1(v,6)]
+ k = k + 1 ; o[k] = r[extract1(v,5)]
+ k = k + 1 ; o[k] = r[extract1(v,4)]
+ k = k + 1 ; o[k] = r[extract1(v,3)]
+ k = k + 1 ; o[k] = r[extract1(v,2)]
+ k = k + 1 ; o[k] = r[extract1(v,1)]
+ k = k + 1 ; o[k] = r[extract1(v,0)]
+ end
+ end
+ end
+ return concat(o,"",1,size)
+ end
+ end
+
+ local function tocmyk_l(content,colordepth)
+ local l = #content
+ local t = { }
+ local n = 0
+ if colordepth == 8 then
+ for i=1,l,3 do
+ local r, g, b = byte(content,i,i+2)
+ n = n + 1 ; t[n] = char(255-r,255-g,255-b,0) -- a tad faster than chars[...]
+ end
+ else
+ for i=1,l,6 do
+ local r1, r2, g1, g2, b1, b2 = byte(content,i,i+5)
+ n = n + 1 ; t[n] = char(255-r1,255-r2,255-g1,255-g2,255-b1,255-b2,0,0)
+ end
+ end
+ return concat(t)
+ end
+
+ local tocmyk_c = pngtocmyk or tocmyk_l
+
+ local function converttocmyk(content,colorspace,colordepth)
+ if colorspace == "DeviceRGB" and colordepth == 8 or colordepth == 16 then
+ local done = tocmyk(content,colordepth)
+ if done then
+ content = done
+ colorspace = "DeviceCMYK"
+ end
+ end
+ return content, colorspace
+ end
+
+ local function switch(v)
+ if v then
+ filtermask = filtermask_l
+ decodemask = decodemask_l
+ decodestrip = decodestrip_l
+ transpose = transpose_l
+ expand = expand_l
+ createmask = createmask_l
+ tocmyk = tocmyk_l
+ else
+ filtermask = filtermask_c
+ decodemask = decodemask_c
+ decodestrip = decodestrip_c
+ transpose = transpose_c
+ expand = expand_c
+ createmask = createmask_c
+ tocmyk = tocmyk_c
+ end
+ end
+
+ if pngapplyfilter then
+ switch(false)
+ directives.register("graphics.png.purelua",switch)
+ else
+ switch(true)
+ end
+
+ local alwaysdecode = false -- trucky with palettes
+ local compresslevel = 3
+
+ directives.register("graphics.png.recompress", function(v)
+ alwaysdecode = v
+ end)
+
+ directives.register("graphics.png.compresslevel", function(v)
+ v = tonumber(v)
+ if compresslevel >= 0 or compresslevel <= 9 then
+ compresslevel = v
+ end
+ end)
+
+ function injectors.png(specification,method) -- todo: method in specification
+ if specification.error then
+ return
+ end
+ local filename = specification.filename
+ if not filename then
+ return
+ end
+ local colorspace = specification.colorspace
+ if not colorspace then
+ return
+ end
+ local interlace = specification.interlace or 0
+ if interlace == 1 then
+ interlace = true
+ elseif interlace == 0 then
+ interlace = false
+ else
+ report_png("unknown interlacing %i",interlace)
+ return
+ end
+ local tables = specification.tables
+ if not tables then
+ return
+ end
+ local idat = tables.idat
+ if not idat then
+ return
+ end
+ local pngfile = newcontent(filename,method)
+ if not pngfile then
+ return
+ end
+ local content = idat(pngfile,true)
+ tables.idat = false
+ --
+ -- if tables.gama then
+ -- report_png("ignoring gamma correction")
+ -- end
+ --
+ local xsize = specification.xsize
+ local ysize = specification.ysize
+ local colordepth = specification.colordepth or 8
+ local mask = false
+ local transparent = false
+ local palette = false
+ local enforcecmyk = specification.enforcecmyk
+ local colors = 1
+ if colorspace == 0 then -- gray | image b
+ colorspace = "DeviceGray"
+ transparent = true
+ elseif colorspace == 2 then -- rgb | image c
+ colorspace = "DeviceRGB"
+ colors = 3
+ transparent = true
+ elseif colorspace == 3 then -- palette | image c+i
+ colorspace = "DeviceRGB"
+ palette = true
+ transparent = true
+ elseif colorspace == 4 then -- gray | alpha | image b
+ colorspace = "DeviceGray"
+ mask = true
+ elseif colorspace == 6 then -- rgb | alpha | image c
+ colorspace = "DeviceRGB"
+ colors = 3
+ mask = true
+ else
+ report_png("unknown colorspace %i",colorspace)
+ return
+ end
+ --
+ if transparent then
+ local trns = tables.trns
+ if trns then
+ transparent = trns(pngfile,true)
+ if transparent == "" then
+ transparent = false
+ end
+ tables.trns = false
+ else
+ transparent = false
+ end
+ end
+ --
+ local decode = alwaysdecode -- tricky, might go away
+ local filter = pdfconstant("FlateDecode")
+ local major = pdfmajorversion()
+ local minor = pdfminorversion()
+ if major > 1 then
+ -- we're okay
+ elseif minor < 5 and colordepth == 16 then
+ report_png("16 bit colordepth not supported in pdf < 1.5")
+ return
+ elseif minor < 4 and (mask or transparent) then
+ report_png("alpha channels not supported in pdf < 1.4")
+ return
+ elseif minor < 2 then
+ report_png("you'd better use a version > 1.2")
+ return
+ -- decode = true
+ end
+ --
+ -- todo: compresslevel (or delegate)
+ --
+ if palette then
+ local plte = tables.plte
+ if plte then
+ palette = plte(pngfile,true)
+ if palette == "" then
+ palette = false
+ end
+ tables.plte = false
+ else
+ palette = false
+ end
+ end
+ --
+ if interlace then
+ local r, p = deinterlace(content,xsize,ysize,colordepth,colorspace,palette,mask)
+ if not r then
+ return
+ end
+ if p then
+ colordepth = p
+ end
+ if mask then
+ if not (colordepth == 8 or colordepth == 16) then
+ report_png("mask can't be split from the image")
+ return
+ end -- get rid of bpp:
+ content, mask = filtermask(r,xsize,ysize,colordepth,colorspace,false)
+ else
+ content = convert(r) -- can be in deinterlace if needed
+ end
+ if enforcecmyk then
+ content, colorspace = converttocmyk(content,colorspace,colordepth)
+ end
+ if compresslevel > 0 then
+ content = zlibcompress(content,compresslevel)
+ else
+ filter = nil
+ end
+ decode = true
+ elseif mask then
+ if not (colordepth == 8 or colordepth == 16) then
+ report_png("mask can't be split from the image")
+ return
+ end
+ content = zlibdecompress(content)
+ content, mask = decodemask(content,xsize,ysize,colordepth,colorspace)
+ if enforcecmyk and not palette then
+ content, colorspace = converttocmyk(content,colorspace,colordepth)
+ end
+ if compresslevel > 0 then
+ content = zlibcompress(content,compresslevel)
+ else
+ filter = nil
+ end
+ decode = true -- we don't copy the filter byte
+ elseif transparent then
+ -- in test suite
+ -- how about decode/recompress here
+ if palette then
+ mask = createmask(content,palette,transparent,xsize,ysize,colordepth,colorspace)
+ else
+ pallette = false
+ end
+ elseif decode or (enforcecmyk and not palette) then
+ -- this one needs checking
+ local bytes = analyze(colordepth,colorspace)
+ if bytes then
+ content = zlibdecompress(content)
+ content = decodestrip(openstring(content),xsize,ysize,bytes)
+ if enforcecmyk and not palette then
+ content, colorspace = converttocmyk(content,colorspace,colordepth)
+ end
+ if compresslevel > 0 then
+ content = zlibcompress(content,compresslevel)
+ else
+ filter = nil
+ end
+ else
+ return
+ end
+ decode = true -- due to enforcecmyk
+ else
+ -- print("PASS ON")
+ end
+ if palette then
+ local colorspace = "DeviceRGB"
+ local nofbytes = 3
+ if enforcecmyk then
+ palette = converttocmyk(palette,colorspace,8)
+ colorspace = "DeviceCMYK"
+ nofbytes = 4
+ end
+ palette = pdfarray {
+ pdfconstant("Indexed"),
+ pdfconstant(colorspace),
+ idiv(#palette,nofbytes),
+ pdfreference(pdfflushstreamobject(palette)),
+ }
+ end
+ pngfile:close()
+ local xobject = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Image"),
+ -- BBox = pdfarray { 0, 0, xsize, ysize },
+ Width = xsize,
+ Height = ysize,
+ BitsPerComponent = colordepth,
+ Filter = filter,
+ ColorSpace = palette or pdfconstant(colorspace),
+ Length = #content,
+ } + specification.attr
+ if mask then
+ local d = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Image"),
+ Width = xsize,
+ Height = ysize,
+ BitsPerComponent = palette and 8 or colordepth,
+ ColorSpace = pdfconstant("DeviceGray"),
+ }
+ xobject.SMask = pdfreference(pdfflushstreamobject(mask,d()))
+ end
+ if not decode then
+ xobject.DecodeParms = pdfdictionary {
+ Colors = colors,
+ Columns = xsize,
+ BitsPerComponent = colordepth,
+ Predictor = 15,
+ }
+ end
+ if trace then
+ report_png("%s: width %i, height %i, colordepth %i, size %i, palette %l, mask %l, transparent %l, decode %l",filename,xsize,ysize,colordepth,#content,palette,mask,transparent,decode)
+ end
+ if specification.colorref then
+ xobject.ColorSpace = pdfreference(specification.colorref)
+ end
+ local width = specification.width or xsize * 65536
+ local height = specification.height or ysize * 65536
+ return createimage {
+ bbox = { 0, 0, width/xsize, height/ysize }, -- mandate
+ transform = specification.transform,
+ nolength = true,
+ nobbox = true,
+ notype = true,
+ stream = content,
+ attr = xobject(),
+ }
+ end
+
+end
+
+do
+
+ local function pack(specification,what)
+ local t = { }
+ local n = 0
+ local s = specification.colorspace
+ local d = specification.data
+ local x = specification.xsize
+ local y = specification.ysize
+ if what == "mask" then
+ d = specification.mask
+ s = 1
+ elseif what == "indexed" then
+ s = 1
+ elseif what == "index" then
+ d = specification.index
+ s = - s
+ end
+ if s > 0 then
+ if s == 1 then
+ for i=1,y do
+ local r = d[i]
+ for j=1,x do
+ n = n + 1 ; t[n] = chars[r[j]]
+ end
+ end
+ elseif s == 2 then
+ for i=1,y do
+ local r = d[i]
+ for j=1,x do
+ local c = r[j]
+ n = n + 1 ; t[n] = chars[c[1]]
+ n = n + 1 ; t[n] = chars[c[2]]
+ n = n + 1 ; t[n] = chars[c[3]]
+ -- n = n + 1 ; t[n] = char(c[1],c[2],c[3]) -- test this
+ end
+ end
+ elseif s == 3 then
+ for i=1,y do
+ local r = d[i]
+ for j=1,x do
+ local c = r[j]
+ n = n + 1 ; t[n] = chars[c[1]]
+ n = n + 1 ; t[n] = chars[c[2]]
+ n = n + 1 ; t[n] = chars[c[3]]
+ n = n + 1 ; t[n] = chars[c[4]]
+ -- n = n + 1 ; t[n] = char(c[1],c[2],c[3],c[4]) -- test this
+ end
+ end
+ end
+ return concat(t)
+ else
+ local z = d[0] and 0 or 1
+ if s == -1 then
+ local f = formatters["%02X"]
+ for i=z,#d do
+ n = n + 1 ; t[n] = f(d[i])
+ end
+ elseif s == -2 then
+ local f = formatters["%02X%02X%02X"]
+ for i=z,#d do
+ local c = d[i]
+ n = n + 1 ; t[n] = f(c[1],c[2],c[3])
+ end
+ elseif s == -3 then
+ local f = formatters["%02X%02X%02X%02X"]
+ for i=z,#d do
+ local c = d[i]
+ n = n + 1 ; t[n] = f(c[1],c[2],c[3],c[4])
+ end
+ end
+ return "<" .. concat(t," ") .. ">"
+ end
+ return ""
+ end
+
+ function injectors.bitmap(specification)
+ local data = specification.data
+ if not data then
+ return
+ end
+ local xsize = specification.xsize or 0
+ local ysize = specification.ysize or 0
+ if xsize == 0 or ysize == 0 then
+ return
+ end
+ local colorspace = specification.colorspace or 1
+ if colorspace == 1 then
+ colorspace = "DeviceGray"
+ elseif colorspace == 2 then
+ colorspace = "DeviceRGB"
+ elseif colorspace == 3 then
+ colorspace = "DeviceCMYK"
+ end
+ local colordepth = (specification.colordepth or 2) == 16 or 8
+ local index = specification.index
+ local content = pack(specification,index and "indexed" or "data")
+ local mask = specification.mask
+ local colorspace = pdfconstant(colorspace)
+ if index then
+ colorspace = pdfarray {
+ pdfconstant("Indexed"),
+ colorspace,
+ #index + (index[0] and 0 or -1), -- upper index
+ pdfverbose(pack(specification,"index"))
+ }
+ end
+ local xobject = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Image"),
+ BBox = pdfarray { 0, 0, xsize, ysize },
+ Width = xsize,
+ Height = ysize,
+ BitsPerComponent = colordepth,
+ ColorSpace = colorspace,
+ Length = #content, -- specification.length
+ }
+ if mask then
+ local d = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Image"),
+ Width = xsize,
+ Height = ysize,
+ BitsPerComponent = colordepth,
+ ColorSpace = pdfconstant("DeviceGray"),
+ }
+ xobject.SMask = pdfreference(pdfflushstreamobject(pack(specification,"mask"),d()))
+ end
+ return createimage {
+ bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
+ -- nolength = true,
+ nobbox = true,
+ notype = true,
+ stream = content,
+ attr = xobject(),
+ }
+ end
+
+ backends.pdf.codeinjections.bitmap = injectors.bitmap
+
+end
+
+-- local function validcompression(data)
+-- local d = utilities.streams.openstring(data)
+-- local b1 = utilities.streams.readbyte(d)
+-- local b2 = utilities.streams.readbyte(d)
+-- print(b1,b2)
+-- if (b1 * 256 + b2) % 31 ~= 0 then
+-- return false, "no zlib compressed file"
+-- end
+-- local method = band(b1,15)
+-- if method ~= 8 then
+-- return false, "method 8 expected"
+-- end
+-- local detail = band(rshift(b1,4),15)
+-- if detail > 7 then
+-- return false, "window 32 expected"
+-- end
+-- local preset = band(rshift(b2,5),1)
+-- if preset ~= 0 then
+-- return false, "unexpected preset dictionary"
+-- end
+-- return true
+-- end
+
+backends.pdf.codeinjections.jpg = lpdf.injectors.jpg
+backends.pdf.codeinjections.jp2 = lpdf.injectors.jp2
+backends.pdf.codeinjections.png = lpdf.injectors.png
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-ini.lmt
new file mode 100644
index 00000000000..27625606aa6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-ini.lmt
@@ -0,0 +1,1363 @@
+if not modules then modules = { } end modules ['lpdf-ini'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- beware of "too many locals" here
+
+local setmetatable, getmetatable, type, next, tostring, tonumber, rawset = setmetatable, getmetatable, type, next, tostring, tonumber, rawset
+local char, byte, format, gsub, concat, match, sub, gmatch = string.char, string.byte, string.format, string.gsub, table.concat, string.match, string.sub, string.gmatch
+local utfchar, utfbyte, utfvalues = utf.char, utf.byte, utf.values
+local sind, cosd, max, min = math.sind, math.cosd, math.max, math.min
+local sort, sortedhash = table.sort, table.sortedhash
+local P, C, R, S, Cc, Cs, V = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc, lpeg.Cs, lpeg.V
+local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local formatters = string.formatters
+local isboolean = string.is_boolean
+local rshift = bit32.rshift
+
+local report_objects = logs.reporter("backend","objects")
+local report_finalizing = logs.reporter("backend","finalizing")
+local report_blocked = logs.reporter("backend","blocked")
+
+local implement = interfaces.implement
+
+local context = context
+
+-- In ConTeXt MkIV we use utf8 exclusively so all strings get mapped onto a hex
+-- encoded utf16 string type between <>. We could probably save some bytes by using
+-- strings between () but then we end up with escaped ()\ too.
+
+pdf = type(pdf) == "table" and pdf or { }
+local factor = number.dimenfactors.bp
+
+local codeinjections = { }
+local nodeinjections = { }
+
+local backends = backends
+
+local pdfbackend = {
+ comment = "backend for directly generating pdf output",
+ nodeinjections = nodeinjections,
+ codeinjections = codeinjections,
+ registrations = { },
+ tables = { },
+}
+
+backends.pdf = pdfbackend
+
+lpdf = lpdf or { }
+local lpdf = lpdf
+lpdf.flags = lpdf.flags or { } -- will be filled later
+
+table.setmetatableindex(lpdf, function(t,k)
+ report_blocked("function %a is not accessible",k)
+ os.exit()
+end)
+
+local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end)
+local trace_resources = false trackers.register("backend.resources", function(v) trace_resources = v end)
+
+local pdfreserveobject
+local pdfimmediateobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+ pdfimmediateobject = lpdf.immediateobject
+end)
+
+do
+
+ updaters.register("backend.update.lpdf",function()
+ job.positions.registerhandlers {
+ getpos = drivers.getpos,
+ getrpos = drivers.getrpos,
+ gethpos = drivers.gethpos,
+ getvpos = drivers.getvpos,
+ }
+ lpdf.getpos = drivers.getpos
+ end)
+
+ local pdfgetmatrix, pdfhasmatrix, pdfgetpos
+
+ updaters.register("backend.update.lpdf",function()
+ pdfgetmatrix = lpdf.getmatrix
+ pdfhasmatrix = lpdf.hasmatrix
+ pdfgetpos = lpdf.getpos
+ end)
+
+ -- local function transform(llx,lly,urx,ury,rx,sx,sy,ry)
+ -- local x1 = llx * rx + lly * sy
+ -- local y1 = llx * sx + lly * ry
+ -- local x2 = llx * rx + ury * sy
+ -- local y2 = llx * sx + ury * ry
+ -- local x3 = urx * rx + lly * sy
+ -- local y3 = urx * sx + lly * ry
+ -- local x4 = urx * rx + ury * sy
+ -- local y4 = urx * sx + ury * ry
+ -- llx = min(x1,x2,x3,x4);
+ -- lly = min(y1,y2,y3,y4);
+ -- urx = max(x1,x2,x3,x4);
+ -- ury = max(y1,y2,y3,y4);
+ -- return llx, lly, urx, ury
+ -- end
+ --
+ -- function lpdf.transform(llx,lly,urx,ury) -- not yet used so unchecked
+ -- if pdfhasmatrix() then
+ -- local sx, rx, ry, sy = pdfgetmatrix()
+ -- local w, h = urx - llx, ury - lly
+ -- return llx, lly, llx + sy*w - ry*h, lly + sx*h - rx*w
+ -- -- return transform(llx,lly,urx,ury,sx,rx,ry,sy)
+ -- else
+ -- return llx, lly, urx, ury
+ -- end
+ -- end
+
+ -- funny values for tx and ty
+
+ function lpdf.rectangle(width,height,depth,offset)
+ local tx, ty = pdfgetpos()
+ if offset then
+ tx = tx - offset
+ ty = ty + offset
+ width = width + 2*offset
+ height = height + offset
+ depth = depth + offset
+ end
+ if pdfhasmatrix() then
+ local rx, sx, sy, ry = pdfgetmatrix()
+ return
+ factor * tx,
+ factor * (ty - ry*depth + sx*width),
+ factor * (tx + rx*width - sy*height),
+ factor * (ty + ry*height - sx*width)
+ else
+ return
+ factor * tx,
+ factor * (ty - depth),
+ factor * (tx + width),
+ factor * (ty + height)
+ end
+ end
+
+end
+
+-- we could use a hash of predefined unicodes
+
+-- local function tosixteen(str) -- an lpeg might be faster (no table)
+-- if not str or str == "" then
+-- return "" -- not () as we want an indication that it's unicode
+-- else
+-- local r, n = { ""
+-- return concat(r)
+-- end
+-- end
+
+local tosixteen, fromsixteen, topdfdoc, frompdfdoc, toeight, fromeight
+
+do
+
+ local cache = table.setmetatableindex(function(t,k) -- can be made weak
+ local v = utfbyte(k)
+ if v < 0x10000 then
+ v = format("%04x",v)
+ else
+ v = v - 0x10000
+ v = format("%04x%04x",rshift(v,10)+0xD800,v%1024+0xDC00)
+ -- v = format("%04x%04x",rshift(v-0x10000,10)+0xD800,v%1024+0xDC00)
+ end
+ t[k] = v
+ return v
+ end)
+
+ local unified = Cs(Cc(""))
+
+ tosixteen = function(str) -- an lpeg might be faster (no table)
+ if not str or str == "" then
+ return "" -- not () as we want an indication that it's unicode
+ else
+ return lpegmatch(unified,str)
+ end
+ end
+
+ local more = 0
+
+ local pattern = C(4) / function(s) -- needs checking !
+ local now = tonumber(s,16)
+ if more > 0 then
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000
+ more = 0
+ return utfchar(now)
+ elseif now >= 0xD800 and now <= 0xDBFF then
+ more = now
+ return "" -- else the c's end up in the stream
+ else
+ return utfchar(now)
+ end
+ end
+
+ local pattern = P(true) / function() more = 0 end * Cs(pattern^0)
+
+ fromsixteen = function(str)
+ if not str or str == "" then
+ return ""
+ else
+ return lpegmatch(pattern,str)
+ end
+ end
+
+ local toregime = regimes.toregime
+ local fromregime = regimes.fromregime
+ local escaped = Cs(Cc("(") * (S("\\()\n\r\t\b\f")/"\\%0" + P(1))^0 * Cc(")"))
+
+ topdfdoc = function(str,default)
+ if not str or str == "" then
+ return ""
+ else
+ return lpegmatch(escaped,toregime("pdfdoc",str,default)) -- could be combined if needed
+ end
+ end
+
+ frompdfdoc = function(str)
+ if not str or str == "" then
+ return ""
+ else
+ return fromregime("pdfdoc",str)
+ end
+ end
+
+ if not toregime then topdfdoc = function(s) return s end end
+ if not fromregime then frompdfdoc = function(s) return s end end
+
+ toeight = function(str)
+ if not str or str == "" then
+ return "()"
+ else
+ return lpegmatch(escaped,str)
+ end
+ end
+
+ local b_pattern = Cs((P("\\")/"" * (
+ S("()")
+ + S("nrtbf") / { n = "\n", r = "\r", t = "\t", b = "\b", f = "\f" }
+ + lpegpatterns.octdigit^-3 / function(s) return char(tonumber(s,8)) end)
+ + P(1))^0)
+
+ fromeight = function(str)
+ if not str or str == "" then
+ return ""
+ else
+ return lpegmatch(unescape,str)
+ end
+ end
+
+ local u_pattern = lpegpatterns.utfbom_16_be * lpegpatterns.utf16_to_utf8_be -- official
+ + lpegpatterns.utfbom_16_le * lpegpatterns.utf16_to_utf8_le -- we've seen these
+
+ local h_pattern = lpegpatterns.hextobytes
+
+ local zero = S(" \n\r\t") + P("\\ ")
+ local one = C(4)
+ local two = P("d") * R("89","af") * C(2) * C(4)
+
+ local x_pattern = P { "start",
+ start = V("wrapped") + V("unwrapped") + V("original"),
+ original = Cs(P(1)^0),
+ wrapped = P("<") * V("unwrapped") * P(">") * P(-1),
+ unwrapped = P("feff")
+ * Cs( (
+ zero / ""
+ + two / function(a,b)
+ a = (tonumber(a,16) - 0xD800) * 1024
+ b = (tonumber(b,16) - 0xDC00)
+ return utfchar(a+b)
+ end
+ + one / function(a)
+ return utfchar(tonumber(a,16))
+ end
+ )^1 ) * P(-1)
+ }
+
+ function lpdf.frombytes(s,hex)
+ if not s or s == "" then
+ return ""
+ end
+ if hex then
+ local x = lpegmatch(x_pattern,s)
+ if x then
+ return x
+ end
+ local h = lpegmatch(h_pattern,s)
+ if h then
+ return h
+ end
+ else
+ local u = lpegmatch(u_pattern,s)
+ if u then
+ return u
+ end
+ end
+ return lpegmatch(b_pattern,s)
+ end
+
+ lpdf.tosixteen = tosixteen
+ lpdf.toeight = toeight
+ lpdf.topdfdoc = topdfdoc
+ lpdf.fromsixteen = fromsixteen
+ lpdf.fromeight = fromeight
+ lpdf.frompdfdoc = frompdfdoc
+
+end
+
+local tostring_a, tostring_d
+
+do
+
+ local f_key_null = formatters["/%s null"]
+ local f_key_value = formatters["/%s %s"]
+ -- local f_key_dictionary = formatters["/%s << % t >>"]
+ -- local f_dictionary = formatters["<< % t >>"]
+ local f_key_dictionary = formatters["/%s << %s >>"]
+ local f_dictionary = formatters["<< %s >>"]
+ -- local f_key_array = formatters["/%s [ % t ]"]
+ -- local f_array = formatters["[ % t ]"]
+ local f_key_array = formatters["/%s [ %s ]"]
+ local f_array = formatters["[ %s ]"]
+ local f_key_number = formatters["/%s %N"] -- always with max 9 digits and integer is possible
+ local f_tonumber = formatters["%N"] -- always with max 9 digits and integer is possible
+
+ tostring_d = function(t,contentonly,key)
+ if next(t) then
+ local r = { }
+ local n = 0
+ local e
+ for k, v in next, t do
+ if k == "__extra__" then
+ e = v
+ elseif k == "__stream__" then
+ -- do nothing (yet)
+ else
+ n = n + 1
+ r[n] = k
+ end
+ end
+ if n > 1 then
+ sort(r)
+ end
+ for i=1,n do
+ local k = r[i]
+ local v = t[k]
+ local tv = type(v)
+ -- mostly tables
+ if tv == "table" then
+ -- local mv = getmetatable(v)
+ -- if mv and mv.__lpdftype then
+ if v.__lpdftype__ then
+ -- if v == t then
+ -- report_objects("ignoring circular reference in dictionary")
+ -- r[i] = f_key_null(k)
+ -- else
+ r[i] = f_key_value(k,tostring(v))
+ -- end
+ elseif v[1] then
+ r[i] = f_key_value(k,tostring_a(v))
+ else
+ r[i] = f_key_value(k,tostring_d(v))
+ end
+ elseif tv == "string" then
+ r[i] = f_key_value(k,toeight(v))
+ elseif tv == "number" then
+ r[i] = f_key_number(k,v)
+ else
+ r[i] = f_key_value(k,tostring(v))
+ end
+ end
+ if e then
+ r[n+1] = e
+ end
+ r = concat(r," ")
+ if contentonly then
+ return r
+ elseif key then
+ return f_key_dictionary(key,r)
+ else
+ return f_dictionary(r)
+ end
+ elseif contentonly then
+ return ""
+ else
+ return "<< >>"
+ end
+ end
+
+ tostring_a = function(t,contentonly,key)
+ local tn = #t
+ if tn ~= 0 then
+ local r = { }
+ for k=1,tn do
+ local v = t[k]
+ local tv = type(v)
+ -- mostly numbers and tables
+ if tv == "number" then
+ r[k] = f_tonumber(v)
+ elseif tv == "table" then
+ -- local mv = getmetatable(v)
+ -- if mv and mv.__lpdftype then
+ if v.__lpdftype__ then
+ -- if v == t then
+ -- report_objects("ignoring circular reference in array")
+ -- r[k] = "null"
+ -- else
+ r[k] = tostring(v)
+ -- end
+ elseif v[1] then
+ r[k] = tostring_a(v)
+ else
+ r[k] = tostring_d(v)
+ end
+ elseif tv == "string" then
+ r[k] = toeight(v)
+ else
+ r[k] = tostring(v)
+ end
+ end
+ local e = t.__extra__
+ if e then
+ r[tn+1] = e
+ end
+ r = concat(r," ")
+ if contentonly then
+ return r
+ elseif key then
+ return f_key_array(key,r)
+ else
+ return f_array(r)
+ end
+ elseif contentonly then
+ return ""
+ else
+ return "[ ]"
+ end
+ end
+
+end
+
+local f_tonumber = formatters["%N"]
+
+local tostring_x = function(t) return concat(t," ") end
+local tostring_s = function(t) return toeight(t[1]) end
+local tostring_p = function(t) return topdfdoc(t[1],t[2]) end
+local tostring_u = function(t) return tosixteen(t[1]) end
+----- tostring_n = function(t) return tostring(t[1]) end -- tostring not needed
+local tostring_n = function(t) return f_tonumber(t[1]) end -- tostring not needed
+local tostring_c = function(t) return t[1] end -- already prefixed (hashed)
+local tostring_z = function() return "null" end
+local tostring_t = function() return "true" end
+local tostring_f = function() return "false" end
+local tostring_r = function(t) local n = t[1] return n and n > 0 and (n .. " 0 R") or "null" end
+
+local tostring_v = function(t)
+ local s = t[1]
+ if type(s) == "table" then
+ return concat(s)
+ else
+ return s
+ end
+end
+
+local tostring_l = function(t)
+ local s = t[1]
+ if not s or s == "" then
+ return "()"
+ elseif t[2] then
+ return "<" .. s .. ">"
+ else
+ return "(" .. s .. ")"
+ end
+end
+
+local function value_x(t) return t end
+local function value_s(t) return t[1] end
+local function value_p(t) return t[1] end
+local function value_u(t) return t[1] end
+local function value_n(t) return t[1] end
+local function value_c(t) return sub(t[1],2) end
+local function value_d(t) return tostring_d(t,true) end
+local function value_a(t) return tostring_a(t,true) end
+local function value_z() return nil end
+local function value_t(t) return t.value or true end
+local function value_f(t) return t.value or false end
+local function value_r(t) return t[1] or 0 end -- null
+local function value_v(t) return t[1] end
+local function value_l(t) return t[1] end
+
+local function add_to_d(t,v)
+ local k = type(v)
+ if k == "string" then
+ if t.__extra__ then
+ t.__extra__ = t.__extra__ .. " " .. v
+ else
+ t.__extra__ = v
+ end
+ elseif k == "table" then
+ for k, v in next, v do
+ t[k] = v
+ end
+ end
+ return t
+end
+
+local function add_to_a(t,v)
+ local k = type(v)
+ if k == "string" then
+ if t.__extra__ then
+ t.__extra__ = t.__extra__ .. " " .. v
+ else
+ t.__extra__ = v
+ end
+ elseif k == "table" then
+ local n = #t
+ for i=1,#v do
+ n = n + 1
+ t[n] = v[i]
+ end
+ end
+ return t
+end
+
+local function add_x(t,k,v) rawset(t,k,tostring(v)) end
+
+local mt_x = { __index = { __lpdftype__ = "stream" }, __tostring = tostring_x, __call = value_x, __newindex = add_x }
+local mt_d = { __index = { __lpdftype__ = "dictionary" }, __tostring = tostring_d, __call = value_d, __add = add_to_d }
+local mt_a = { __index = { __lpdftype__ = "array" }, __tostring = tostring_a, __call = value_a, __add = add_to_a }
+local mt_u = { __index = { __lpdftype__ = "unicode" }, __tostring = tostring_u, __call = value_u }
+local mt_s = { __index = { __lpdftype__ = "string" }, __tostring = tostring_s, __call = value_s }
+local mt_p = { __index = { __lpdftype__ = "docstring" }, __tostring = tostring_p, __call = value_p }
+local mt_n = { __index = { __lpdftype__ = "number" }, __tostring = tostring_n, __call = value_n }
+local mt_c = { __index = { __lpdftype__ = "constant" }, __tostring = tostring_c, __call = value_c }
+local mt_z = { __index = { __lpdftype__ = "null" }, __tostring = tostring_z, __call = value_z }
+local mt_t = { __index = { __lpdftype__ = "true" }, __tostring = tostring_t, __call = value_t }
+local mt_f = { __index = { __lpdftype__ = "false" }, __tostring = tostring_f, __call = value_f }
+local mt_r = { __index = { __lpdftype__ = "reference" }, __tostring = tostring_r, __call = value_r }
+local mt_v = { __index = { __lpdftype__ = "verbose" }, __tostring = tostring_v, __call = value_v }
+local mt_l = { __index = { __lpdftype__ = "literal" }, __tostring = tostring_l, __call = value_l }
+
+local function pdfstream(t) -- we need to add attributes
+ if t then
+ local tt = type(t)
+ if tt == "table" then
+ for i=1,#t do
+ t[i] = tostring(t[i])
+ end
+ elseif tt == "string" then
+ t = { t }
+ else
+ t = { tostring(t) }
+ end
+ end
+ return setmetatable(t or { },mt_x)
+end
+
+local function pdfdictionary(t)
+ return setmetatable(t or { },mt_d)
+end
+
+local function pdfarray(t)
+ if type(t) == "string" then
+ return setmetatable({ t },mt_a)
+ else
+ return setmetatable(t or { },mt_a)
+ end
+end
+
+local function pdfstring(str,default)
+ return setmetatable({ str or default or "" },mt_s)
+end
+
+local function pdfdocstring(str,default,defaultchar)
+ return setmetatable({ str or default or "", defaultchar or " " },mt_p)
+end
+
+local function pdfunicode(str,default)
+ return setmetatable({ str or default or "" },mt_u) -- could be a string
+end
+
+local function pdfliteral(str,hex) -- can also produce a hex <> instead of () literal
+ return setmetatable({ str, hex },mt_l)
+end
+
+local pdfnumber, pdfconstant
+
+do
+
+ local cache = { } -- can be weak
+
+ pdfnumber = function(n,default) -- 0-10
+ if not n then
+ n = default
+ end
+ local c = cache[n]
+ if not c then
+ c = setmetatable({ n },mt_n)
+ -- cache[n] = c -- too many numbers
+ end
+ return c
+ end
+
+ for i=-1,9 do cache[i] = pdfnumber(i) end
+
+ local replacer = S("\0\t\n\r\f ()[]{}/%%#\\") / {
+ ["\00"]="#00",
+ ["\09"]="#09",
+ ["\10"]="#0a",
+ ["\12"]="#0c",
+ ["\13"]="#0d",
+ [ " " ]="#20",
+ [ "#" ]="#23",
+ [ "%" ]="#25",
+ [ "(" ]="#28",
+ [ ")" ]="#29",
+ [ "/" ]="#2f",
+ [ "[" ]="#5b",
+ [ "\\"]="#5c",
+ [ "]" ]="#5d",
+ [ "{" ]="#7b",
+ [ "}" ]="#7d",
+ } + P(1)
+
+ local escaped = Cs(Cc("/") * replacer^0)
+
+ local cache = table.setmetatableindex(function(t,k)
+ local v = setmetatable({ lpegmatch(escaped,k) }, mt_c)
+ t[k] = v
+ return v
+ end)
+
+ pdfconstant = function(str,default)
+ if not str then
+ str = default or "none"
+ end
+ return cache[str]
+ end
+
+ local escaped = Cs(replacer^0)
+
+ function lpdf.escaped(str)
+ return lpegmatch(escaped,str) or str
+ end
+
+end
+
+local pdfnull, pdfboolean, pdfreference, pdfverbose
+
+do
+
+ local p_null = { } setmetatable(p_null, mt_z)
+ local p_true = { } setmetatable(p_true, mt_t)
+ local p_false = { } setmetatable(p_false,mt_f)
+
+ pdfnull = function()
+ return p_null
+ end
+
+ pdfboolean = function(b,default)
+ if type(b) == "boolean" then
+ return b and p_true or p_false
+ else
+ return default and p_true or p_false
+ end
+ end
+
+ -- print(pdfboolean(false),pdfboolean(false,false),pdfboolean(false,true))
+ -- print(pdfboolean(true),pdfboolean(true,false),pdfboolean(true,true))
+ -- print(pdfboolean(nil,true),pdfboolean(nil,false))
+
+ local r_zero = setmetatable({ 0 },mt_r)
+
+ pdfreference = function(r) -- maybe make a weak table
+ if r and r ~= 0 then
+ return setmetatable({ r },mt_r)
+ else
+ return r_zero
+ end
+ end
+
+ local v_zero = setmetatable({ 0 },mt_v)
+ local v_empty = setmetatable({ "" },mt_v)
+
+ pdfverbose = function(t) -- maybe check for type
+ if t == 0 then
+ return v_zero
+ elseif t == "" then
+ return v_empty
+ else
+ return setmetatable({ t },mt_v)
+ end
+ end
+
+end
+
+lpdf.stream = pdfstream -- THIS WILL PROBABLY CHANGE
+lpdf.dictionary = pdfdictionary
+lpdf.array = pdfarray
+lpdf.docstring = pdfdocstring
+lpdf.string = pdfstring
+lpdf.unicode = pdfunicode
+lpdf.number = pdfnumber
+lpdf.constant = pdfconstant
+lpdf.null = pdfnull
+lpdf.boolean = pdfboolean
+lpdf.reference = pdfreference
+lpdf.verbose = pdfverbose
+lpdf.literal = pdfliteral
+
+-- three priority levels, default=2
+
+local pagefinalizers = { { }, { }, { } }
+local documentfinalizers = { { }, { }, { } }
+
+local pageresources, pageattributes, pagesattributes
+
+local function resetpageproperties()
+ pageresources = pdfdictionary()
+ pageattributes = pdfdictionary()
+ pagesattributes = pdfdictionary()
+end
+
+function lpdf.getpageproperties()
+ return {
+ pageresources = pageresources,
+ pageattributes = pageattributes,
+ pagesattributes = pagesattributes,
+ }
+end
+
+resetpageproperties()
+
+local function addtopageresources (k,v) pageresources [k] = v end
+local function addtopageattributes (k,v) pageattributes [k] = v end
+local function addtopagesattributes(k,v) pagesattributes[k] = v end
+
+lpdf.addtopageresources = addtopageresources
+lpdf.addtopageattributes = addtopageattributes
+lpdf.addtopagesattributes = addtopagesattributes
+
+local function set(where,what,f,when,comment)
+ if type(when) == "string" then
+ when, comment = 2, when
+ elseif not when then
+ when = 2
+ end
+ local w = where[when]
+ w[#w+1] = { f, comment }
+ if trace_finalizers then
+ report_finalizing("%s set: [%s,%s]",what,when,#w)
+ end
+end
+
+local function run(where,what)
+ if trace_finalizers then
+ report_finalizing("start backend, category %a, n %a",what,#where)
+ end
+ for i=1,#where do
+ local w = where[i]
+ for j=1,#w do
+ local wj = w[j]
+ if trace_finalizers then
+ report_finalizing("%s finalizer: [%s,%s] %s",what,i,j,wj[2] or "")
+ end
+ wj[1]()
+ end
+ end
+ if trace_finalizers then
+ report_finalizing("stop finalizing")
+ end
+end
+
+local function registerpagefinalizer(f,when,comment)
+ set(pagefinalizers,"page",f,when,comment)
+end
+
+local function registerdocumentfinalizer(f,when,comment)
+ set(documentfinalizers,"document",f,when,comment)
+end
+
+lpdf.registerpagefinalizer = registerpagefinalizer
+lpdf.registerdocumentfinalizer = registerdocumentfinalizer
+
+function lpdf.finalizepage(shipout)
+ if shipout and not environment.initex then
+ -- resetpageproperties() -- maybe better before
+ run(pagefinalizers,"page")
+ resetpageproperties() -- maybe better before
+ end
+end
+
+function lpdf.finalizedocument()
+ if not environment.initex then
+ run(documentfinalizers,"document")
+ function lpdf.finalizedocument()
+ -- report_finalizing("serious error: the document is finalized multiple times")
+ function lpdf.finalizedocument() end
+ end
+ end
+end
+
+callbacks.register("finish_pdfpage", lpdf.finalizepage)
+callbacks.register("finish_pdffile", lpdf.finalizedocument)
+
+do
+
+ -- some minimal tracing, handy for checking the order
+
+ local function trace_set(what,key)
+ if trace_resources then
+ report_finalizing("setting key %a in %a",key,what)
+ end
+ end
+
+ local function trace_flush(what)
+ if trace_resources then
+ report_finalizing("flushing %a",what)
+ end
+ end
+
+ lpdf.protectresources = true
+
+ local catalog = pdfdictionary { Type = pdfconstant("Catalog") } -- nicer, but when we assign we nil the Type
+ local info = pdfdictionary { Type = pdfconstant("Info") } -- nicer, but when we assign we nil the Type
+ ----- names = pdfdictionary { Type = pdfconstant("Names") } -- nicer, but when we assign we nil the Type
+
+ local function checkcatalog()
+ if not environment.initex then
+ trace_flush("catalog")
+ return true
+ end
+ end
+
+ local function checkinfo()
+ if not environment.initex then
+ trace_flush("info")
+ if lpdf.majorversion() > 1 then
+ for k, v in next, info do
+ if k == "CreationDate" or k == "ModDate" then
+ -- mandate >= 2.0
+ else
+ info[k] = nil
+ end
+ end
+ end
+ return true
+ end
+ end
+
+ local function flushcatalog()
+ if checkcatalog() then
+ catalog.Type = nil
+-- pdfsetcatalog(catalog())
+ end
+ end
+
+ local function flushinfo()
+ if checkinfo() then
+ info.Type = nil
+ end
+ end
+
+ function lpdf.getcatalog()
+ if checkcatalog() then
+ catalog.Type = pdfconstant("Catalog")
+ return pdfreference(pdfimmediateobject(tostring(catalog)))
+ end
+ end
+
+ function lpdf.getinfo()
+ if checkinfo() then
+ return pdfreference(pdfimmediateobject(tostring(info)))
+ end
+ end
+
+ function lpdf.addtocatalog(k,v)
+ if not (lpdf.protectresources and catalog[k]) then
+ trace_set("catalog",k)
+ catalog[k] = v
+ end
+ end
+
+ function lpdf.addtoinfo(k,v)
+ if not (lpdf.protectresources and info[k]) then
+ trace_set("info",k)
+ info[k] = v
+ end
+ end
+
+ local names = pdfdictionary {
+ -- Type = pdfconstant("Names")
+ }
+
+ local function flushnames()
+ if next(names) and not environment.initex then
+ names.Type = pdfconstant("Names")
+ trace_flush("names")
+ lpdf.addtocatalog("Names",pdfreference(pdfimmediateobject(tostring(names))))
+ end
+ end
+
+ function lpdf.addtonames(k,v)
+ if not (lpdf.protectresources and names[k]) then
+ trace_set("names", k)
+ names [k] = v
+ end
+ end
+
+ local r_extgstates, r_colorspaces, r_patterns, r_shades
+ local d_extgstates, d_colorspaces, d_patterns, d_shades
+ local p_extgstates, p_colorspaces, p_patterns, p_shades
+
+ local function checkextgstates () if d_extgstates then addtopageresources("ExtGState", p_extgstates ) end end
+ local function checkcolorspaces() if d_colorspaces then addtopageresources("ColorSpace",p_colorspaces) end end
+ local function checkpatterns () if d_patterns then addtopageresources("Pattern", p_patterns ) end end
+ local function checkshades () if d_shades then addtopageresources("Shading", p_shades ) end end
+
+ local function flushextgstates () if d_extgstates then trace_flush("extgstates") pdfimmediateobject(r_extgstates, tostring(d_extgstates )) end end
+ local function flushcolorspaces() if d_colorspaces then trace_flush("colorspaces") pdfimmediateobject(r_colorspaces,tostring(d_colorspaces)) end end
+ local function flushpatterns () if d_patterns then trace_flush("patterns") pdfimmediateobject(r_patterns, tostring(d_patterns )) end end
+ local function flushshades () if d_shades then trace_flush("shades") pdfimmediateobject(r_shades, tostring(d_shades )) end end
+
+ -- patterns are special as they need resources to so we can get recursive references and in that case
+ -- acrobat doesn't show anything (other viewers handle it well)
+ --
+ -- todo: share them
+ -- todo: force when not yet set
+
+ local pdfgetfontobjectnumber
+
+ updaters.register("backend.update.lpdf",function()
+ pdfgetfontobjectnumber = lpdf.getfontobjectnumber
+ end)
+
+ local f_font = formatters["%s%d"]
+
+ function lpdf.collectedresources(options)
+ local ExtGState = d_extgstates and next(d_extgstates ) and p_extgstates
+ local ColorSpace = d_colorspaces and next(d_colorspaces) and p_colorspaces
+ local Pattern = d_patterns and next(d_patterns ) and p_patterns
+ local Shading = d_shades and next(d_shades ) and p_shades
+ local Font
+ if options and options.patterns == false then
+ Pattern = nil
+ end
+ local fonts = options and options.fonts
+ if fonts and next(fonts) then
+ local prefix = options.fontprefix or "F"
+ Font = pdfdictionary { }
+ for k, v in sortedhash(fonts) do
+ Font[f_font(prefix,v)] = pdfreference(pdfgetfontobjectnumber(k))
+ end
+ end
+ if ExtGState or ColorSpace or Pattern or Shading or Font then
+ local collected = pdfdictionary {
+ ExtGState = ExtGState,
+ ColorSpace = ColorSpace,
+ Pattern = Pattern,
+ Shading = Shading,
+ Font = Font,
+ }
+ if options and options.serialize == false then
+ return collected
+ else
+ return collected()
+ end
+ elseif options and options.notempty then
+ return nil
+ elseif options and options.serialize == false then
+ return pdfdictionary { }
+ else
+ return ""
+ end
+ end
+
+ function lpdf.adddocumentextgstate (k,v)
+ if not d_extgstates then
+ r_extgstates = pdfreserveobject()
+ d_extgstates = pdfdictionary()
+ p_extgstates = pdfreference(r_extgstates)
+ end
+ d_extgstates[k] = v
+ end
+
+ function lpdf.adddocumentcolorspace(k,v)
+ if not d_colorspaces then
+ r_colorspaces = pdfreserveobject()
+ d_colorspaces = pdfdictionary()
+ p_colorspaces = pdfreference(r_colorspaces)
+ end
+ d_colorspaces[k] = v
+ end
+
+ function lpdf.adddocumentpattern(k,v)
+ if not d_patterns then
+ r_patterns = pdfreserveobject()
+ d_patterns = pdfdictionary()
+ p_patterns = pdfreference(r_patterns)
+ end
+ d_patterns[k] = v
+ end
+
+ function lpdf.adddocumentshade(k,v)
+ if not d_shades then
+ r_shades = pdfreserveobject()
+ d_shades = pdfdictionary()
+ p_shades = pdfreference(r_shades)
+ end
+ d_shades[k] = v
+ end
+
+ registerdocumentfinalizer(flushextgstates,3,"extended graphic states")
+ registerdocumentfinalizer(flushcolorspaces,3,"color spaces")
+ registerdocumentfinalizer(flushpatterns,3,"patterns")
+ registerdocumentfinalizer(flushshades,3,"shades")
+
+ registerdocumentfinalizer(flushnames,3,"names") -- before catalog
+ registerdocumentfinalizer(flushcatalog,3,"catalog")
+ registerdocumentfinalizer(flushinfo,3,"info")
+
+ registerpagefinalizer(checkextgstates,3,"extended graphic states")
+ registerpagefinalizer(checkcolorspaces,3,"color spaces")
+ registerpagefinalizer(checkpatterns,3,"patterns")
+ registerpagefinalizer(checkshades,3,"shades")
+
+end
+
+-- in strc-bkm: lpdf.registerdocumentfinalizer(function() structures.bookmarks.place() end,1)
+
+function lpdf.rotationcm(a)
+ local s = sind(a)
+ local c = cosd(a)
+ return format("%.6F %.6F %.6F %.6F 0 0 cm",c,s,-s,c)
+end
+
+-- ! -> universaltime
+
+do
+
+ -- It's a bit of a historical mess here.
+
+ local osdate, ostime, ostimezone = os.date, os.time, os.timezone
+
+ local metadata = nil
+ local timestamp = osdate("%Y-%m-%dT%X") .. ostimezone(true)
+
+ function lpdf.getmetadata()
+ if not metadata then
+ local contextversion = environment.version
+ local luatexversion = format("%1.2f",LUATEXVERSION)
+ local luatexfunctionality = tostring(LUATEXFUNCTIONALITY)
+ metadata = {
+ producer = format("LuaTeX-%s",luatexversion),
+ creator = format("LuaTeX %s %s + ConTeXt LMTX %s",luatexversion,luatexfunctionality,contextversion),
+ luatexversion = luatexversion,
+ contextversion = contextversion,
+ luatexfunctionality = luatexfunctionality,
+ luaversion = tostring(LUAVERSION),
+ platform = os.platform,
+ time = timestamp,
+ }
+ end
+ return metadata
+ end
+
+ function lpdf.settime(n)
+ if n then
+ n = converters.totime(n)
+ if n then
+ converters.settime(n)
+ timestamp = osdate("%Y-%m-%dT%X") .. ostimezone(true) -- probably not ok
+ end
+ end
+ if metadata then
+ metadata.time = timestamp
+ end
+ return timestamp
+ end
+
+ lpdf.settime(tonumber(resolvers.variable("start_time")) or tonumber(resolvers.variable("SOURCE_DATE_EPOCH"))) -- bah
+
+ function lpdf.pdftimestamp(str)
+ local t = type(str)
+ if t == "string" then
+ local Y, M, D, h, m, s, Zs, Zh, Zm = match(str,"^(%d%d%d%d)%-(%d%d)%-(%d%d)T(%d%d):(%d%d):(%d%d)([%+%-])(%d%d):(%d%d)$")
+ return Y and format("D:%s%s%s%s%s%s%s%s'%s'",Y,M,D,h,m,s,Zs,Zh,Zm)
+ else
+ return osdate("D:%Y%m%d%H%M%S",t == "number" and str or ostime()) -- maybe "!D..." : universal time
+ end
+ end
+
+ function lpdf.id(date)
+ local banner = environment.jobname or tex.jobname or "unknown"
+ if not date then
+ return banner
+ else
+ return format("%s | %s",banner,timestamp)
+ end
+ end
+
+end
+
+-- return nil is nicer in test prints
+
+function lpdf.checkedkey(t,key,variant)
+ local pn = t and t[key]
+ if pn ~= nil then
+ local tn = type(pn)
+ if tn == variant then
+ if variant == "string" then
+ if pn ~= "" then
+ return pn
+ end
+ elseif variant == "table" then
+ if next(pn) then
+ return pn
+ end
+ else
+ return pn
+ end
+ elseif tn == "string" then
+ if variant == "number" then
+ return tonumber(pn)
+ elseif variant == "boolean" then
+ return isboolean(pn,nil,true)
+ end
+ end
+ end
+ -- return nil
+end
+
+function lpdf.checkedvalue(value,variant) -- code not shared
+ if value ~= nil then
+ local tv = type(value)
+ if tv == variant then
+ if variant == "string" then
+ if value ~= "" then
+ return value
+ end
+ elseif variant == "table" then
+ if next(value) then
+ return value
+ end
+ else
+ return value
+ end
+ elseif tv == "string" then
+ if variant == "number" then
+ return tonumber(value)
+ elseif variant == "boolean" then
+ return isboolean(value,nil,true)
+ end
+ end
+ end
+end
+
+function lpdf.limited(n,min,max,default)
+ if not n then
+ return default
+ else
+ n = tonumber(n)
+ if not n then
+ return default
+ elseif n > max then
+ return max
+ elseif n < min then
+ return min
+ else
+ return n
+ end
+ end
+end
+
+-- The next variant of ActualText is what Taco and I could come up with
+-- eventually. As of September 2013 Acrobat copies okay, Sumatra copies a
+-- question mark, pdftotext injects an extra space and Okular adds a
+-- newline plus space.
+
+-- return formatters["BT /Span << /ActualText (CONTEXT) >> BDC [] TJ % t EMC ET"](code)
+
+do
+
+ local f_actual_text_p = formatters["BT /Span << /ActualText >> BDC %s EMC ET"]
+ local f_actual_text_b = formatters["BT /Span << /ActualText >> BDC"]
+ local s_actual_text_e = "EMC ET"
+ local f_actual_text_b_not = formatters["/Span << /ActualText >> BDC"]
+ local s_actual_text_e_not = "EMC"
+ local f_actual_text = formatters["/Span <> BDC"]
+
+ local context = context
+ local pdfdirect = nodes.pool.directliteral -- we can use nuts.write deep down
+ local tounicode = fonts.mappings.tounicode
+
+ function codeinjections.unicodetoactualtext(unicode,pdfcode)
+ return f_actual_text_p(type(unicode) == "string" and unicode or tounicode(unicode),pdfcode)
+ end
+
+ function codeinjections.startunicodetoactualtext(unicode)
+ return f_actual_text_b(type(unicode) == "string" and unicode or tounicode(unicode))
+ end
+
+ function codeinjections.stopunicodetoactualtext()
+ return s_actual_text_e
+ end
+
+ function codeinjections.startunicodetoactualtextdirect(unicode)
+ return f_actual_text_b_not(type(unicode) == "string" and unicode or tounicode(unicode))
+ end
+
+ function codeinjections.stopunicodetoactualtextdirect()
+ return s_actual_text_e_not
+ end
+
+ implement {
+ name = "startactualtext",
+ arguments = "string",
+ actions = function(str)
+ context(pdfdirect(f_actual_text(tosixteen(str))))
+ end
+ }
+
+ implement {
+ name = "stopactualtext",
+ actions = function()
+ context(pdfdirect("EMC"))
+ end
+ }
+
+ local setstate = nodes.nuts.pool.setstate
+
+ function nodeinjections.startalternate(str)
+ return setstate(f_actual_text(tosixteen(str)))
+ end
+
+ function nodeinjections.stopalternate()
+ return setstate("EMC")
+ end
+
+
+end
+
+-- interface
+
+implement { name = "lpdf_collectedresources", actions = { lpdf.collectedresources, context } }
+implement { name = "lpdf_addtocatalog", arguments = "2 strings", actions = lpdf.addtocatalog }
+implement { name = "lpdf_addtoinfo", arguments = "2 strings", actions = function(a,b,c) lpdf.addtoinfo(a,b,c) end } -- gets adapted
+implement { name = "lpdf_addtonames", arguments = "2 strings", actions = lpdf.addtonames }
+implement { name = "lpdf_addtopageattributes", arguments = "2 strings", actions = lpdf.addtopageattributes }
+implement { name = "lpdf_addtopagesattributes", arguments = "2 strings", actions = lpdf.addtopagesattributes }
+implement { name = "lpdf_addtopageresources", arguments = "2 strings", actions = lpdf.addtopageresources }
+implement { name = "lpdf_adddocumentextgstate", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentextgstate (a,pdfverbose(b)) end }
+implement { name = "lpdf_adddocumentcolorspace", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentcolorspace(a,pdfverbose(b)) end }
+implement { name = "lpdf_adddocumentpattern", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentpattern (a,pdfverbose(b)) end }
+implement { name = "lpdf_adddocumentshade", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentshade (a,pdfverbose(b)) end }
+
+-- more helpers: copy from lepd to lpdf
+
+function lpdf.copyconstant(v)
+ if v ~= nil then
+ return pdfconstant(v)
+ end
+end
+
+function lpdf.copyboolean(v)
+ if v ~= nil then
+ return pdfboolean(v)
+ end
+end
+
+function lpdf.copyunicode(v)
+ if v then
+ return pdfunicode(v)
+ end
+end
+
+function lpdf.copyarray(a)
+ if a then
+ local t = pdfarray()
+ for i=1,#a do
+ t[i] = a(i)
+ end
+ return t
+ end
+end
+
+function lpdf.copydictionary(d)
+ if d then
+ local t = pdfdictionary()
+ for k, v in next, d do
+ t[k] = d(k)
+ end
+ return t
+ end
+end
+
+function lpdf.copynumber(v)
+ return v
+end
+
+function lpdf.copyinteger(v)
+ return v -- maybe checking or round ?
+end
+
+function lpdf.copyfloat(v)
+ return v
+end
+
+function lpdf.copystring(v)
+ if v then
+ return pdfstring(v)
+ end
+end
+
+do
+
+ -- This is obsolete but old viewers might still use it as directive
+ -- for what to send to a postscript printer.
+
+ local a_procset, d_procset
+
+ function lpdf.procset(dict)
+ if not a_procset then
+ a_procset = pdfarray {
+ pdfconstant("PDF"),
+ pdfconstant("Text"),
+ pdfconstant("ImageB"),
+ pdfconstant("ImageC"),
+ pdfconstant("ImageI"),
+ }
+ a_procset = pdfreference(pdfimmediateobject(tostring(a_procset)))
+ end
+ if dict then
+ if not d_procset then
+ d_procset = pdfdictionary {
+ ProcSet = a_procset
+ }
+ d_procset = pdfreference(pdfimmediateobject(tostring(d_procset)))
+ end
+ return d_procset
+ else
+ return a_procset
+ end
+ end
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-lmt.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-lmt.lmt
new file mode 100644
index 00000000000..fbc002a9327
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-lmt.lmt
@@ -0,0 +1,3019 @@
+if not modules then modules = { } end modules ['lpdf-lmt'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- The code below was originally in back-lpd.lua but it makes more sense in
+-- this namespace. I will rename variables.
+--
+-- There is no way that a lua based backend can compete with the original one
+-- for relative simple text runs. And we're talking seconds here on say 500
+-- pages with paragraphs alternativng between three fonts and colors. But such
+-- documents are rare so in practice we are quite okay, especially because in
+-- ConTeXt we can gain quite a bit elsewhere. So, when we loose 30% on such
+-- simple documents, we break even on for instance the manual, and gain 30% on
+-- Thomas's turture test (also for other reasons). But .. who knows what magic
+-- I can cook up in due time.
+
+-- If you consider this complex, watch:
+--
+-- https://www.youtube.com/watch?v=6H-cAzfB2qo
+--
+-- or in distractionmode:
+--
+-- https://www.youtube.com/watch?v=TYuTE_1jvvE
+-- https://www.youtube.com/watch?v=nnicGKX3lvM
+--
+-- For the moment we have to support the built in backend as well as the alternative. So
+-- the next interface is suboptimal and will change at some time. At that moment I will
+-- also optimize and extend.
+
+local type, next, unpack, tonumber, rawget = type, next, unpack, tonumber, rawget
+local char, rep, find = string.char, string.rep, string.find
+local formatters, splitupstring = string.formatters, string.splitup
+local band, extract = bit32.band, bit32.extract
+local concat, sortedhash = table.concat, table.sortedhash
+local setmetatableindex = table.setmetatableindex
+local loaddata = io.loaddata
+
+local bpfactor = number.dimenfactors.bp
+
+-- local md5HEX = md5.HEX
+local osuuid = os.uuid
+local zlibcompress = (xzip or zlib).compress
+
+local nuts = nodes.nuts
+local tonut = nodes.tonut
+
+local pdfreference = lpdf.reference
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfliteral = lpdf.literal -- not to be confused with a whatsit!
+
+local pdfreserveobject
+local pdfpagereference
+local pdfflushobject
+local pdfsharedobject
+local pdfflushstreamobject
+local pdfdeferredobject
+local pdfimmediateobject
+
+local pdfgetfontname
+local pdfgetfontobjectnumber
+
+local pdfgetpagereference
+
+updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+ pdfpagereference = lpdf.pagereference
+ pdfflushobject = lpdf.flushobject
+ pdfsharedobject = lpdf.shareobjectreference
+ pdfflushstreamobject = lpdf.flushstreamobject
+ pdfdeferredobject = lpdf.deferredobject
+ pdfimmediateobject = lpdf.immediateobject
+ --
+ pdfgetfontname = lpdf.getfontname
+ pdfgetfontobjectnumber = lpdf.getfontobjectnumber
+ --
+ pdfgetpagereference = lpdf.getpagereference
+end)
+
+local pdf_pages = pdfconstant("Pages")
+local pdf_page = pdfconstant("Page")
+local pdf_xobject = pdfconstant("XObject")
+local pdf_form = pdfconstant("Form")
+
+local fonthashes = fonts.hashes
+local characters = fonthashes.characters
+local descriptions = fonthashes.descriptions
+local parameters = fonthashes.parameters
+local properties = fonthashes.properties
+
+local report = logs.reporter("backend")
+local report_objects = logs.reporter("backend","objects")
+
+local trace_objects = false trackers.register("backend.objects", function(v) trace_objects = v end)
+local trace_details = false trackers.register("backend.details", function(v) trace_details = v end)
+
+-- we collect them:
+
+local flushers = { }
+
+-- used variables
+
+local pdf_h, pdf_v
+local need_tm, need_tf, cur_tmrx, cur_factor, cur_f, cur_e
+local need_width, need_mode, done_width, done_mode
+local mode
+local f_pdf_cur, f_pdf, fs_cur, fs, f_cur, f_x_scale, f_y_scale
+local tj_delta, cw
+local usedfonts, usedxforms, usedximages, usedxgroups
+local getxformname, getximagename
+local boundingbox, shippingmode, objectnumber
+local tmrx, tmry, tmsx, tmsy, tmtx, tmty
+local cmrx, cmry, cmsx, cmsy, cmtx, cmty
+local tmef
+
+local function usefont(t,k) -- a bit redundant hash
+ local v = pdfgetfontname(k)
+ t[k] = v
+ return v
+end
+
+local function reset_variables(specification)
+ pdf_h, pdf_v = 0, 0
+ cmrx, cmry = 1.0, 1.0
+ cmsx, cmsy = 0.0, 0.0
+ cmtx, cmty = 0.0, 0.0
+ tmrx, tmry = 1.0, 1.0
+ tmsx, tmsy = 0.0, 0.0
+ tmtx, tmty = 0.0, 0.0
+ tmef = 1.0
+ need_tm = false
+ need_tf = false
+ need_width = 0
+ need_mode = 0
+ done_width = false
+ done_mode = false
+ mode = "page"
+ shippingmode = specification.shippingmode
+ objectnumber = specification.objectnumber
+ cur_tmrx = 0.0
+ f_cur = 0
+ f_pdf_cur = 0 -- nullfont
+ f_pdf = 0 -- nullfont
+ fs_cur = 0
+ fs = 0
+ f_x_scale = 1.0
+ f_y_scale = 1.0
+ cur_factor = 0
+ cur_f = false
+ cur_e = false
+ tj_delta = 0.0
+ cw = 0.0
+ usedfonts = setmetatableindex(usefont)
+ usedxforms = { }
+ usedximages = { }
+ -- usedxgroups = { }
+ boundingbox = specification.boundingbox
+end
+
+-- buffer
+
+local buffer = lua.newtable(1024,0) -- { }
+local b = 0
+
+local function reset_buffer()
+ b = 0
+end
+
+-- fonts
+
+local fontcharacters
+local fontdescriptions
+local fontparameters
+local fontproperties
+local usedcharacters = setmetatableindex("table")
+local pdfcharacters
+
+local horizontalmode = true
+local scalefactor = 1
+local threshold = 655360
+local thresfactor = 100
+local tjfactor = 100 / 65536
+
+lpdf.usedcharacters = usedcharacters
+
+function flushers.updatefontstate(font)
+ fontcharacters = characters[font]
+ fontdescriptions = descriptions[font]
+ fontparameters = parameters[font]
+ fontproperties = properties[font]
+ local size = fontparameters.size -- or bad news
+ local designsize = fontparameters.designsize or size
+ pdfcharacters = usedcharacters[font]
+ horizontalmode = fontparameters.writingmode ~= "vertical"
+ scalefactor = (designsize/size) * tjfactor
+ --
+ local fthreshold = fontproperties.threshold
+ threshold = (fthreshold and (size * fthreshold / 100)) or 655360
+ -- when we bolden the threshold should be smaller .. a hack .. i need to redo all this
+ if (fontparameters.extendfactor or 1) == 1 then
+ -- we're probably okay
+ elseif fontparameters.hshift or fontparameters.vshift then
+ -- we could be okay
+ else
+ -- some vf magic going on
+ threshold = threshold / 5
+ end
+end
+
+-- helpers
+
+local f_cm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"]
+local f_tm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N Tm"]
+
+local saved_text_pos_v = 0
+local saved_text_pos_h = 0
+
+local function begin_text()
+ saved_text_pos_h = pdf_h
+ saved_text_pos_v = pdf_v
+ b = b + 1 ; buffer[b] = "BT"
+ need_tf = true
+ need_width = 0
+ need_mode = 0
+ mode = "text"
+end
+
+local function end_text()
+ if done_width then
+ b = b + 1 ; buffer[b] = "0 w"
+ done_width = false
+ end
+ if done_mode then
+ b = b + 1 ; buffer[b] = "0 Tr"
+ done_mode = false
+ end
+ b = b + 1 ; buffer[b] = "ET"
+ pdf_h = saved_text_pos_h
+ pdf_v = saved_text_pos_v
+ mode = "page"
+end
+
+local saved_chararray_pos_h
+local saved_chararray_pos_v
+
+local saved_b = 0
+
+local function begin_chararray()
+ saved_chararray_pos_h = pdf_h
+ saved_chararray_pos_v = pdf_v
+ cw = horizontalmode and saved_chararray_pos_h or - saved_chararray_pos_v
+ tj_delta = 0
+ saved_b = b
+ b = b + 1 ; buffer[b] = " ["
+ mode = "chararray"
+end
+
+local function end_chararray()
+ b = b + 1 ; buffer[b] = "] TJ"
+ buffer[saved_b] = concat(buffer,"",saved_b,b)
+ b = saved_b
+ pdf_h = saved_chararray_pos_h
+ pdf_v = saved_chararray_pos_v
+ mode = "text"
+end
+
+local function begin_charmode()
+ b = b + 1 ; buffer[b] = "<"
+ mode = "char"
+end
+
+local function end_charmode()
+ b = b + 1 ; buffer[b] = ">"
+ mode = "chararray"
+end
+
+local function calc_pdfpos(h,v)
+ -- mostly char
+ if mode == "page" then
+ cmtx = h - pdf_h
+ cmty = v - pdf_v
+ return h ~= pdf_h or v ~= pdf_v
+ elseif mode == "text" then
+ tmtx = h - saved_text_pos_h
+ tmty = v - saved_text_pos_v
+ return h ~= pdf_h or v ~= pdf_v
+ elseif horizontalmode then
+ tmty = v - saved_text_pos_v
+ tj_delta = cw - h
+ return tj_delta ~= 0 or v ~= pdf_v
+ else
+ tmtx = h - saved_text_pos_h
+ tj_delta = cw + v
+ return tj_delta ~= 0 or h ~= pdf_h
+ end
+end
+
+local function pdf_set_pos(h,v)
+ local move = calc_pdfpos(h,v)
+ if move then
+ b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor)
+ pdf_h = pdf_h + cmtx
+ pdf_v = pdf_v + cmty
+ end
+end
+
+local function pdf_reset_pos()
+ if mode == "page" then
+ cmtx = - pdf_h
+ cmty = - pdf_v
+ if pdf_h == 0 and pdf_v == 0 then
+ return
+ end
+ elseif mode == "text" then
+ tmtx = - saved_text_pos_h
+ tmty = - saved_text_pos_v
+ if pdf_h == 0 and pdf_v == 0 then
+ return
+ end
+ elseif horizontalmode then
+ tmty = - saved_text_pos_v
+ tj_delta = cw
+ if tj_delta == 0 and pdf_v == 0 then
+ return
+ end
+ else
+ tmtx = - saved_text_pos_h
+ tj_delta = cw
+ if tj_delta == 0 and pdf_h == 0 then
+ return
+ end
+ end
+ b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor)
+ pdf_h = pdf_h + cmtx
+ pdf_v = pdf_v + cmty
+end
+
+local function pdf_set_pos_temp(h,v)
+ local move = calc_pdfpos(h,v)
+ if move then
+ b = b + 1 ; buffer[b] = f_cm(cmrx, cmsx, cmsy, cmry, cmtx*bpfactor, cmty*bpfactor)
+ end
+end
+
+-- these dummy returns makes using them a bit faster
+
+local function pdf_end_string_nl()
+ if mode == "char" then
+ end_charmode()
+ return end_chararray()
+ elseif mode == "chararray" then
+ return end_chararray()
+ end
+end
+
+local function pdf_goto_textmode()
+ if mode == "page" then
+ pdf_reset_pos()
+ return begin_text()
+ elseif mode ~= "text" then
+ if mode == "char" then
+ end_charmode()
+ return end_chararray()
+ else -- if mode == "chararray" then
+ return end_chararray()
+ end
+ end
+end
+
+local function pdf_goto_pagemode()
+ if mode ~= "page" then
+ if mode == "char" then
+ end_charmode()
+ end_chararray()
+ return end_text()
+ elseif mode == "chararray" then
+ end_chararray()
+ return end_text()
+ elseif mode == "text" then
+ return end_text()
+ end
+ end
+end
+
+local function pdf_goto_fontmode()
+ if mode == "char" then
+ end_charmode()
+ end_chararray()
+ end_text()
+ elseif mode == "chararray" then
+ end_chararray()
+ end_text()
+ elseif mode == "text" then
+ end_text()
+ end
+ pdf_reset_pos()
+ mode = "page"
+end
+
+-- characters
+do
+
+ local round = math.round
+
+ -- across pages ... todo: clean up because we don't need to pass the font
+ -- as fontparameters already has checked / set it we can also have a variable
+ -- for it so
+
+ local naturalwidth = nil
+ local hshift = false
+ local vshift = false
+
+ -- local naturalwidths = setmetatableindex(function(t,font)
+ -- local d = descriptions[font]
+ -- local c = characters[font]
+ -- local f = parameters[font].hfactor or parameters[font].factor
+ -- local v = setmetatableindex(function(t,char)
+ -- local w
+ -- local e = d and d[char]
+ -- if e then
+ -- w = e.width
+ -- if w then
+ -- w = w * f
+ -- end
+ -- end
+ -- if not w then
+ -- e = c and c[char]
+ -- if e then
+ -- w = e.width or 0
+ -- end
+ -- end
+ -- if not w then
+ -- w = 0
+ -- end
+ -- t[char] = w
+ -- return w
+ -- end)
+ -- t[font] = v
+ -- return v
+ -- end)
+
+ -- when changing this, check math: compact-001.tex (rule width)
+
+ local naturalwidths = setmetatableindex(function(t,font)
+ local d = descriptions[font]
+ local c = characters[font]
+ local f = parameters[font].hfactor or parameters[font].factor
+ local v = setmetatableindex(function(t,char)
+ local w
+ local e = c and c[char]
+ if e then
+ w = e.width or 0
+ end
+ if not w then
+ e = d and d[char]
+ if e then
+ w = e.width
+ if w then
+ w = w * f
+ end
+ end
+ end
+ if not w then
+ w = 0
+ end
+ t[char] = w
+ return w
+ end)
+ t[font] = v
+ return v
+ end)
+
+ local function setup_fontparameters(font,factor,f,e,sx,sy)
+ local slant = fontparameters.slantfactor or 0
+ local extend = fontparameters.extendfactor or 1
+ local squeeze = fontparameters.squeezefactor or 1
+ local expand = 1 + factor / 1000000
+ local format = fontproperties.format
+ if e then
+ extend = extend * e
+ end
+ tmef = expand
+ tmrx = expand * extend
+ tmsy = slant
+ tmry = squeeze
+ need_width = fontparameters.width or 0
+ need_mode = fontparameters.mode or 0
+ f_cur = font
+ f_pdf = usedfonts[font] -- cache
+ cur_factor = factor
+ cur_f = f
+ cur_e = e
+ tj_delta = 0
+ f_x_scale = 1.0
+ f_y_scale = 1.0
+ fs = fontparameters.size * bpfactor
+ if f then
+ fs = fs * f
+ end
+ -- kind of special:
+ if format == "opentype" or format == "type1" then
+ fs = fs * 1000 / fontparameters.units -- can we avoid this ?
+ end
+ --
+ f_x_scale = sx
+ if f_x_scale ~= 1.0 then
+ tmrx = tmrx * f_x_scale
+ end
+ f_y_scale = sy
+ if f_y_scale ~= 1.0 then
+ tmry = tmry * f_y_scale
+ end
+ --
+ naturalwidth = naturalwidths[font]
+ --
+ hshift = fontparameters.hshift
+ vshift = fontparameters.vshift
+ end
+
+ local f_width = formatters["%.6N w"]
+ local f_mode = formatters["%i Tr"] -- can be hash
+ local f_font = formatters["/F%i %.6N Tf"] -- can be hash
+
+ local s_width = "0 w"
+ local s_mode = "0 Tr"
+
+ local width_factor = 72.27 / 72000.0
+
+ local function set_font()
+ -- if need_width and need_width ~= 0 then
+ if need_width ~= 0 then
+ b = b + 1 ; buffer[b] = f_width(width_factor*need_width)
+ done_width = true
+ elseif done_width then
+ b = b + 1 ; buffer[b] = s_width
+ done_width = false
+ end
+ -- if need_mode and need_mode ~= 0 then
+ if need_mode ~= 0 then
+ b = b + 1 ; buffer[b] = f_mode(need_mode)
+ done_mode = true
+ elseif done_mode then
+ b = b + 1 ; buffer[b] = s_mode
+ done_mode = false
+ end
+ b = b + 1 ; buffer[b] = f_font(f_pdf,fs)
+ f_pdf_cur = f_pdf
+ fs_cur = fs
+ need_tf = false
+ need_tm = true
+ end
+
+ local function set_textmatrix(h,v)
+ local move = calc_pdfpos(h,v)
+ if need_tm or move then
+ b = b + 1 ; buffer[b] = f_tm(tmrx, tmsx, tmsy, tmry, tmtx*bpfactor, tmty*bpfactor)
+ pdf_h = saved_text_pos_h + tmtx
+ pdf_v = saved_text_pos_v + tmty
+ need_tm = false
+ end
+ cur_tmrx = tmrx
+ end
+
+ local f_hex_4 = formatters["%04X"]
+ local f_hex_2 = formatters["%02X"]
+
+ local h_hex_4 = setmetatableindex(function(t,k) -- we already have this somewhere
+ if k < 256 then -- maybe 512
+ -- not sparse in this range
+ for i=0,255 do
+ t[i] = f_hex_4(i)
+ end
+ return t[k]
+ else
+ local v = f_hex_4(k)
+ t[k] = v
+ return v
+ end
+ end)
+ local h_hex_2 = setmetatableindex(function(t,k) -- we already have this somewhere
+ local v = k < 256 and f_hex_2(k) or "00"
+ t[k] = v
+ return v
+ end)
+
+ -- local trace_threshold = false trackers.register("backends.pdf.threshold", function(v) trace_threshold = v end)
+
+ -- local f_skip = formatters["%.2N"]
+
+ -- I will redo this mess ... we no longer have the mkiv pdf generator that we used in
+ -- luatex (a precursor to lmtx and also for comparison) but only in lmtx now so ...
+ -- time to move on I guess.
+
+ flushers.character = function(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width)
+ if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then
+ pdf_goto_textmode()
+ setup_fontparameters(font,factor,f,e,sx,sy)
+ set_font()
+ elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_f ~= f or cur_e ~= e then
+ setup_fontparameters(font,factor,f,e,sx,sy)
+ need_tm = true
+ end
+
+ local move = calc_pdfpos(pos_h,pos_v)
+
+ -- if trace_threshold then
+ -- report(
+ -- "font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p",
+ -- font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw
+ -- )
+ -- end
+
+ if move or need_tm then
+ if not need_tm then
+ if horizontalmode then
+ if (saved_text_pos_v + tmty) ~= pdf_v then
+ need_tm = true
+ elseif tj_delta >= threshold or tj_delta <= -threshold then
+ need_tm = true
+ end
+ else
+ if (saved_text_pos_h + tmtx) ~= pdf_h then
+ need_tm = true
+ elseif tj_delta >= threshold or tj_delta <= -threshold then
+ need_tm = true
+ end
+ end
+ end
+
+ if hshift then pos_h = pos_h + hshift end
+ if vshift then pos_v = pos_v - vshift end
+
+ if need_tm then
+ pdf_goto_textmode()
+ set_textmatrix(pos_h,pos_v)
+ begin_chararray()
+ move = calc_pdfpos(pos_h,pos_v)
+ end
+ if move then
+ local d = tj_delta * scalefactor / f_x_scale
+ if d <= -0.5 or d >= 0.5 then
+ if mode == "char" then
+ end_charmode()
+ end
+ b = b + 1 ; buffer[b] = round(d) -- or f_skip(d)
+ end
+ cw = cw - tj_delta
+ end
+ end
+
+ if mode == "chararray" then
+ begin_charmode()
+ end
+
+ cw = cw + naturalwidth[char] * tmef * f_x_scale
+
+ local index = data.index or char
+
+ b = b + 1 ; buffer[b] = font > 0 and h_hex_4[index] or h_hex_2[index]
+
+ if not pdfcharacters[index] then
+ pdfcharacters[index] = true
+ end
+
+ end
+
+ flushers.fontchar = function(font,char,data)
+ local dummy = usedfonts[font]
+ local index = data.index or char
+ if not pdfcharacters[index] then
+ pdfcharacters[index] = true
+ end
+ return dummy
+ end
+
+end
+
+-- literals
+
+local flushliteral do
+
+ local nodeproperties = nodes.properties.data
+ local literalvalues = nodes.literalvalues
+
+ local originliteral_code = literalvalues.origin
+ local pageliteral_code = literalvalues.page
+ local alwaysliteral_code = literalvalues.always
+ local rawliteral_code = literalvalues.raw
+ local textliteral_code = literalvalues.text
+ local fontliteral_code = literalvalues.font
+
+ flushliteral = function(current,pos_h,pos_v)
+ local p = nodeproperties[current]
+ if p then
+ local str = p.data
+ if str and str ~= "" then
+ local mode = p.mode
+ if mode == originliteral_code then
+ pdf_goto_pagemode()
+ pdf_set_pos(pos_h,pos_v)
+ elseif mode == pageliteral_code then
+ pdf_goto_pagemode()
+ elseif mode == textliteral_code then
+ pdf_goto_textmode()
+ elseif mode == fontliteral_code then
+ pdf_goto_fontmode()
+ elseif mode == alwaysliteral_code then -- aka direct
+ pdf_end_string_nl()
+ need_tm = true
+ elseif mode == rawliteral_code then
+ pdf_end_string_nl()
+ else
+ report("invalid literal mode %a when flushing %a",mode,str)
+ return
+ end
+ b = b + 1 ; buffer[b] = str
+ end
+ end
+ end
+
+ flushers.literal = flushliteral
+
+ function lpdf.print(mode,str)
+ -- This only works inside objects, don't change this to flush
+ -- in between. It's different from luatex but okay.
+ if str then
+ mode = literalvalues[mode]
+ else
+ mode, str = originliteral_code, mode
+ end
+ if str and str ~= "" then
+ if mode == originliteral_code then
+ pdf_goto_pagemode()
+ -- pdf_set_pos(pdf_h,pdf_v)
+ elseif mode == pageliteral_code then
+ pdf_goto_pagemode()
+ elseif mode == textliteral_code then
+ pdf_goto_textmode()
+ elseif mode == fontliteral_code then
+ pdf_goto_fontmode()
+ elseif mode == alwaysliteral_code then
+ pdf_end_string_nl()
+ need_tm = true
+ elseif mode == rawliteral_code then
+ pdf_end_string_nl()
+ else
+ report("invalid literal mode %a when flushing %a",mode,str)
+ return
+ end
+ b = b + 1 ; buffer[b] = str
+ end
+ end
+
+end
+
+-- grouping & orientation
+
+do
+
+ local matrices = { }
+ local positions = { }
+ local nofpositions = 0
+ local nofmatrices = 0
+
+ local flushsave = function(current,pos_h,pos_v)
+ nofpositions = nofpositions + 1
+ positions[nofpositions] = { pos_h, pos_v, nofmatrices }
+ pdf_goto_pagemode()
+ pdf_set_pos(pos_h,pos_v)
+ b = b + 1 ; buffer[b] = "q"
+ end
+
+ local flushrestore = function(current,pos_h,pos_v)
+ if nofpositions < 1 then
+ return
+ end
+ local t = positions[nofpositions]
+ -- local h = pos_h - t[1]
+ -- local v = pos_v - t[2]
+ if shippingmode == "page" then
+ nofmatrices = t[3]
+ end
+ pdf_goto_pagemode()
+ pdf_set_pos(pos_h,pos_v)
+ b = b + 1 ; buffer[b] = "Q"
+ nofpositions = nofpositions - 1
+ end
+
+ local nodeproperties = nodes.properties.data
+
+ local s_matrix_0 = "1 0 0 1 0 0 cm"
+ local f_matrix_2 = formatters["%.6N 0 0 %.6N 0 0 cm"]
+ local f_matrix_4 = formatters["%.6N %.6N %.6N %.6N 0 0 cm"]
+
+ local flushsetmatrix = function(current,pos_h,pos_v)
+ local p = nodeproperties[current]
+ if p then
+ local m = p.matrix
+ if m then
+ local rx, sx, sy, ry = unpack(m)
+ local s
+ if not rx then
+ rx = 1
+ elseif rx == 0 then
+ rx = 0.0001
+ end
+ if not ry then
+ ry = 1
+ elseif ry == 0 then
+ ry = 0.0001
+ end
+ if not sx then
+ sx = 0
+ end
+ if not sy then
+ sy = 0
+ end
+ --
+ if sx == 0 and sy == 0 then
+ if rx == 1 and ry == 1 then
+ s = s_matrix_0
+ else
+ s = f_matrix_2(rx,ry)
+ end
+ else
+ s = f_matrix_4(rx,sx,sy,ry)
+ end
+ --
+ if shippingmode == "page" then
+ local tx = pos_h * (1 - rx) - pos_v * sy
+ local ty = pos_v * (1 - ry) - pos_h * sx
+ if nofmatrices > 0 then
+ local t = matrices[nofmatrices]
+ local r_x, s_x, s_y, r_y, te, tf = t[1], t[2], t[3], t[4], t[5], t[6]
+ rx, sx = rx * r_x + sx * s_y, rx * s_x + sx * r_y
+ sy, ry = sy * r_x + ry * s_y, sy * s_x + ry * r_y
+ tx, ty = tx * r_x + ty * s_y, tx * s_x + ty * r_y
+ end
+ nofmatrices = nofmatrices + 1
+ matrices[nofmatrices] = { rx, sx, sy, ry, tx, ty }
+ end
+ --
+ pdf_goto_pagemode()
+ pdf_set_pos(pos_h,pos_v)
+ --
+ b = b + 1
+ buffer[b] = s
+ end
+ end
+ end
+
+ flushers.setmatrix = flushsetmatrix
+ flushers.save = flushsave
+ flushers.restore = flushrestore
+
+ function lpdf.hasmatrix()
+ return nofmatrices > 0
+ end
+
+ function lpdf.getmatrix()
+ if nofmatrices > 0 then
+ return unpack(matrices[nofmatrices])
+ else
+ return 1, 0, 0, 1, 0, 0
+ end
+ end
+
+ flushers.pushorientation = function(orientation,pos_h,pos_v,pos_r)
+ pdf_goto_pagemode()
+ pdf_set_pos(pos_h,pos_v)
+ b = b + 1 ; buffer[b] = "q"
+ if orientation == 1 then
+ b = b + 1 ; buffer[b] = "0 -1 1 0 0 0 cm" -- 90
+ elseif orientation == 2 then
+ b = b + 1 ; buffer[b] = "-1 0 0 -1 0 0 cm" -- 180
+ elseif orientation == 3 then
+ b = b + 1 ; buffer[b] = "0 1 -1 0 0 0 cm" -- 270
+ end
+ end
+
+ flushers.poporientation = function(orientation,pos_h,pos_v,pos_r)
+ pdf_goto_pagemode()
+ pdf_set_pos(pos_h,pos_v)
+ b = b + 1 ; buffer[b] = "Q"
+ end
+
+ --
+
+ flushers.startmatrix = function(current,pos_h,pos_v)
+ flushsave(current,pos_h,pos_v)
+ flushsetmatrix(current,pos_h,pos_v)
+ end
+
+ flushers.stopmatrix = function(current,pos_h,pos_v)
+ flushrestore(current,pos_h,pos_v)
+ end
+
+ flushers.startscaling = function(current,pos_h,pos_v)
+ flushsave(current,pos_h,pos_v)
+ flushsetmatrix(current,pos_h,pos_v)
+ end
+
+ flushers.stopscaling = function(current,pos_h,pos_v)
+ flushrestore(current,pos_h,pos_v)
+ end
+
+ flushers.startrotation = function(current,pos_h,pos_v)
+ flushsave(current,pos_h,pos_v)
+ flushsetmatrix(current,pos_h,pos_v)
+ end
+
+ flushers.stoprotation = function(current,pos_h,pos_v)
+ flushrestore(current,pos_h,pos_v)
+ end
+
+ flushers.startmirroring = function(current,pos_h,pos_v)
+ flushsave(current,pos_h,pos_v)
+ flushsetmatrix(current,pos_h,pos_v)
+ end
+
+ flushers.stopmirroring = function(current,pos_h,pos_v)
+ flushrestore(current,pos_h,pos_v)
+ end
+
+ flushers.startclipping = function(current,pos_h,pos_v)
+ flushsave(current,pos_h,pos_v)
+ -- lpdf.print("origin",formatters["0 w %s W n"](nodeproperties[current].path))
+ pdf_goto_pagemode()
+ b = b + 1 ; buffer[b] = formatters["0 w %s W n"](nodeproperties[current].path)
+ end
+
+ flushers.stopclipping = function(current,pos_h,pos_v)
+ flushrestore(current,pos_h,pos_v)
+ end
+
+end
+
+do
+
+ local nodeproperties = nodes.properties.data
+
+ flushers.setstate = function(current,pos_h,pos_v)
+ local p = nodeproperties[current]
+ if p then
+ local d = p.data
+ if d and d ~= "" then
+ pdf_goto_pagemode()
+ b = b + 1 ; buffer[b] = d
+ end
+ end
+ end
+
+end
+
+-- rules
+
+local flushedxforms = { } -- actually box resources but can also be direct
+local localconverter = nil -- will be set
+
+local flushimage do
+
+ local rulecodes = nodes.rulecodes
+ local newrule = nodes.pool.rule
+
+ local setprop = nuts.setprop
+ local getprop = nuts.getprop
+
+ local getwhd = nuts.getwhd
+ local flushlist = nuts.flush_list
+ local getdata = nuts.getdata
+
+ local normalrule_code = rulecodes.normal
+ local boxrule_code = rulecodes.box
+ local imagerule_code = rulecodes.image
+ local emptyrule_code = rulecodes.empty
+ local userrule_code = rulecodes.user
+ local overrule_code = rulecodes.over
+ local underrule_code = rulecodes.under
+ local fractionrule_code = rulecodes.fraction
+ local radicalrule_code = rulecodes.radical
+ local outlinerule_code = rulecodes.outline
+
+ local processrule = nodes.rules.process
+
+ local f_fm = formatters["/Fm%d Do"]
+ local f_im = formatters["/Im%d Do"]
+ local f_gr = formatters["/Gp%d Do"]
+
+ local s_b = "q"
+ local s_e = "Q"
+
+ local f_v = formatters["[] 0 d 0 J %.6N w 0 0 m %.6N 0 l S"]
+ local f_h = formatters["[] 0 d 0 J %.6N w 0 0 m 0 %.6N l S"]
+
+ local f_f = formatters["0 0 %.6N %.6N re f"]
+ local f_o = formatters["[] 0 d 0 J 0 0 %.6N %.6N re S"]
+ local f_w = formatters["[] 0 d 0 J %.6N w 0 0 %.6N %.6N re S"]
+
+ local f_b = formatters["%.6N w 0 %.6N %.6N %.6N re f"]
+ local f_x = formatters["[] 0 d 0 J %.6N w %.6N %.6N %.6N %.6N re S"]
+ local f_y = formatters["[] 0 d 0 J %.6N w %.6N %.6N %.6N %.6N re S %.6N 0 m %.6N 0 l S"]
+
+ -- Historically the index is an object which is kind of bad.
+
+ local boxresources, n = { }, 0
+
+ getxformname = function(index)
+ local l = boxresources[index]
+ if l then
+ return l.name
+ else
+ report("no box resource %S",index)
+ end
+ end
+
+ lpdf.getxformname = getxformname
+
+ local function saveboxresource(box,attributes,resources,immediate,kind,margin)
+ n = n + 1
+ local immediate = true
+ local margin = margin or 0 -- or dimension
+ local objnum = pdfreserveobject()
+ local list = tonut(type(box) == "number" and tex.takebox(box) or box)
+ --
+ local width, height, depth = getwhd(list)
+ --
+ local l = {
+ width = width,
+ height = height,
+ depth = depth,
+ margin = margin,
+ attributes = attributes,
+ resources = resources,
+ list = nil,
+ type = kind,
+ name = n,
+ index = objnum,
+ objnum = objnum,
+ }
+ boxresources[objnum] = l
+ if immediate then
+ localconverter(list,"xform",objnum,l)
+ flushedxforms[objnum] = { true , objnum }
+ flushlist(list)
+ else
+ l.list = list
+ end
+ return objnum
+ end
+
+ local function useboxresource(index,wd,ht,dp)
+ local l = boxresources[index]
+ if l then
+ if wd or ht or dp then
+ wd, ht, dp = wd or 0, ht or 0, dp or 0
+ else
+ wd, ht, dp = l.width, l.height, l.depth
+ end
+ local rule = newrule(wd,ht,dp) -- newboxrule
+ rule.subtype = boxrule_code
+ setprop(tonut(rule),"index",index)
+ return rule, wd, ht, dp
+ else
+ report("no box resource %S",index)
+ end
+ end
+
+ local function getboxresourcedimensions(index)
+ local l = boxresources[index]
+ if l then
+ return l.width, l.height, l.depth, l.margin
+ else
+ report("no box resource %S",index)
+ end
+ end
+
+ local function getboxresourcebox(index)
+ local l = boxresources[index]
+ if l then
+ return l.list
+ end
+ end
+
+ -- updaters.register("backend.update.tex",function()
+ updaters.register("backend.update.lpdf",function()
+ tex.saveboxresource = saveboxresource
+ tex.useboxresource = useboxresource
+ tex.getboxresourcedimensions = getboxresourcedimensions
+ tex.getboxresourcebox = getboxresourcebox
+ end)
+
+ -- a bit of a mess: index is now objnum but that has to change to a proper index
+ -- ... an engine inheritance
+
+ local function flushpdfxform(current,pos_h,pos_v,pos_r,size_h,size_v)
+ -- object properties
+ local objnum = getprop(current,"index")
+ local name = getxformname(objnum)
+ local info = flushedxforms[objnum]
+ local r = boxresources[objnum]
+ if not info then
+ info = { false , objnum }
+ flushedxforms[objnum] = info
+ end
+ local wd, ht, dp = getboxresourcedimensions(objnum)
+ -- or: wd, ht, dp = r.width, r.height, r.depth
+ -- sanity check
+ local htdp = ht + dp
+ if wd == 0 or size_h == 0 or htdp == 0 or size_v == 0 then
+ return
+ end
+ -- calculate scale
+ local rx, ry = 1, 1
+ if wd ~= size_h or htdp ~= size_v then
+ rx = size_h / wd
+ ry = size_v / htdp
+ end
+ -- flush the reference
+ usedxforms[objnum] = true
+ pdf_goto_pagemode()
+ calc_pdfpos(pos_h,pos_v)
+ tx = cmtx * bpfactor
+ ty = cmty * bpfactor
+ b = b + 1 ; buffer[b] = s_b
+ b = b + 1 ; buffer[b] = f_cm(rx,0,0,ry,tx,ty)
+ b = b + 1 ; buffer[b] = f_fm(name)
+ b = b + 1 ; buffer[b] = s_e
+ end
+
+ -- place image also used in vf but we can use a different one if we need it
+
+ local imagetypes = images.types -- pdf png jpg jp2 jbig2 stream
+ local img_none = imagetypes.none
+ local img_pdf = imagetypes.pdf
+ local img_stream = imagetypes.stream
+
+ local one_bp = 65536 * bpfactor
+
+ local imageresources, n = { }, 0
+
+ getximagename = function(index) -- not used
+ local l = imageresources[index]
+ if l then
+ return l.name
+ else
+ report("no image resource %S",index)
+ end
+ end
+
+ -- Groups are flushed immediately but we can decide to make them into a
+ -- specific whatsit ... but not now. We could hash them if needed when
+ -- we use lot sof them in mp ... but not now.
+
+ usedxgroups = { }
+ local groups = 0
+ local group = nil
+
+ local flushgroup = function(content,bbox)
+ if not group then
+ group = pdfdictionary {
+ Type = pdfconstant("Group"),
+ S = pdfconstant("Transparency"),
+ }
+ end
+ local wrapper = pdfdictionary {
+ Type = pdf_xobject,
+ Subtype = pdf_form,
+ FormType = 1,
+ Group = group,
+ BBox = pdfarray(bbox),
+ Resources = lpdf.collectedresources { serialize = false },
+ }
+ local objnum = pdfflushstreamobject(content,wrapper,false)
+ groups = groups + 1
+ usedxgroups[groups] = objnum
+ return f_gr(groups)
+ end
+
+ flushers.group = flushgroup
+ lpdf.flushgroup = flushgroup -- todo: access via driver in mlib-pps
+
+ -- end of experiment
+
+ local pdfincludeimage
+
+ updaters.register("backend.update.lpdf",function()
+ pdfincludeimage = lpdf.includeimage
+ end)
+
+ local function flushpdfximage(current,pos_h,pos_v,pos_r,size_h,size_v)
+
+ local width,
+ height,
+ depth = getwhd(current)
+ local total = height + depth
+ local transform = getprop(current,"transform") or 0 -- we never set it ... so just use rotation then
+ local index = getprop(current,"index") or 0
+ local kind,
+ xorigin,
+ yorigin,
+ xsize,
+ ysize,
+ rotation, -- transform / orientation / rotation : it's a mess (i need to redo this)
+ objnum,
+ groupref = pdfincludeimage(index) -- needs to be sorted out, bad name (no longer mixed anyway)
+
+ if not kind then
+ report("invalid image %S",index)
+ return
+ end
+
+ local rx, sx, sy, ry, tx, ty = 1, 0, 0, 1, 0, 0
+
+ -- tricky: xsize and ysize swapped
+
+ if kind == img_pdf or kind == img_stream then
+ rx, ry, tx, ty = 1/xsize, 1/ysize, xorigin/xsize, yorigin/ysize
+ else
+ -- if kind == img_png then
+ -- -- if groupref > 0 and img_page_group_val == 0 then
+ -- -- img_page_group_val = groupref
+ -- -- end
+ -- end
+ rx, ry = bpfactor, bpfactor
+ end
+
+ if band(transform,7) > 3 then
+ -- mirror
+ rx, tx = -rx, -tx
+ end
+ local t = band(transform + rotation,3)
+ if t == 0 then
+ -- nothing
+ elseif t == 1 then
+ -- rotation over 90 degrees (counterclockwise)
+ rx, sx, sy, ry, tx, ty = 0, rx, -ry, 0, -ty, tx
+ elseif t == 2 then
+ -- rotation over 180 degrees (counterclockwise)
+ rx, ry, tx, ty = -rx, -ry, -tx, -ty
+ elseif t == 3 then
+ -- rotation over 270 degrees (counterclockwise)
+ rx, sx, sy, ry, tx, ty = 0, -rx, ry, 0, ty, -tx
+ end
+
+ rx = rx * width
+ sx = sx * total
+ sy = sy * width
+ ry = ry * total
+ tx = pos_h - tx * width
+ ty = pos_v - ty * total
+
+ local t = transform + rotation
+
+ if band(transform,7) > 3 then
+ t = t + 1
+ end
+
+ t = band(t,3)
+
+ if t == 0 then
+ -- no transform
+ elseif t == 1 then
+ -- rotation over 90 degrees (counterclockwise)
+ tx = tx + width
+ elseif t == 2 then
+ -- rotation over 180 degrees (counterclockwise)
+ tx = tx + width
+ ty = ty + total
+ elseif t == 3 then
+ -- rotation over 270 degrees (counterclockwise)
+ ty = ty + total
+ end
+
+ -- a flaw in original, can go:
+ --
+ -- if img_page_group_val == 0 then
+ -- img_page_group_val = group_ref
+ -- end
+
+ usedximages[index] = objnum -- hm
+
+ pdf_goto_pagemode()
+
+ calc_pdfpos(tx,ty)
+
+ tx = cmtx * bpfactor
+ ty = cmty * bpfactor
+
+ b = b + 1 ; buffer[b] = s_b
+ b = b + 1 ; buffer[b] = f_cm(rx,sx,sy,ry,tx,ty)
+ b = b + 1 ; buffer[b] = f_im(index)
+ b = b + 1 ; buffer[b] = s_e
+ end
+
+ flushimage = function(index,width,height,depth,pos_h,pos_v)
+
+ -- used in vf characters
+
+ local total = height + depth
+ local kind,
+ xorigin, yorigin,
+ xsize, ysize,
+ rotation,
+ objnum,
+ groupref = pdfincludeimage(index)
+
+ local rx = width / xsize
+ local sx = 0
+ local sy = 0
+ local ry = total / ysize
+ local tx = pos_h
+ -- to be sorted out
+ -- local ty = pos_v - depth
+ local ty = pos_v -- we assume that depth is dealt with in the caller (for now)
+
+ usedximages[index] = objnum
+
+ pdf_goto_pagemode()
+
+ calc_pdfpos(tx,ty)
+
+ tx = cmtx * bpfactor
+ ty = cmty * bpfactor
+
+ b = b + 1 ; buffer[b] = s_b
+ b = b + 1 ; buffer[b] = f_cm(rx,sx,sy,ry,tx,ty)
+ b = b + 1 ; buffer[b] = f_im(index)
+ b = b + 1 ; buffer[b] = s_e
+ end
+
+ flushers.image = flushimage
+
+ -- For the moment we need this hack because the engine checks the 'image'
+ -- command in virtual fonts (so we use lua instead).
+ --
+ -- These will be replaced by a new more advanced one ... some day ... or
+ -- never because the next are like the other engines and compensate for
+ -- small sizes which is needed for inaccurate viewers.
+
+ flushers.rule = function(current,pos_h,pos_v,pos_r,size_h,size_v,subtype)
+
+ if subtype == emptyrule_code then
+ return
+ elseif subtype == boxrule_code then
+ return flushpdfxform(current,pos_h,pos_v,pos_r,size_h,size_v)
+ elseif subtype == imagerule_code then
+ return flushpdfximage(current,pos_h,pos_v,pos_r,size_h,size_v)
+ end
+ if subtype == userrule_code or subtype >= overrule_code and subtype <= radicalrule_code then
+ pdf_goto_pagemode()
+ b = b + 1 ; buffer[b] = s_b
+ pdf_set_pos_temp(pos_h,pos_v)
+ processrule(current,size_h,size_v,pos_r) -- so we pass direction
+ b = b + 1 ; buffer[b] = s_e
+ return
+ end
+
+ pdf_goto_pagemode()
+
+ -- local saved_b = b
+
+ b = b + 1 ; buffer[b] = s_b
+
+ local dim_h = size_h * bpfactor
+ local dim_v = size_v * bpfactor
+ local rule
+
+ if dim_v <= one_bp then
+ pdf_set_pos_temp(pos_h,pos_v + 0.5 * size_v)
+ rule = f_v(dim_v,dim_h)
+ elseif dim_h <= one_bp then
+ pdf_set_pos_temp(pos_h + 0.5 * size_h,pos_v)
+ rule = f_h(dim_h,dim_v)
+ else
+ pdf_set_pos_temp(pos_h,pos_v)
+ if subtype == outlinerule_code then
+ local linewidth = getdata(current)
+ if linewidth > 0 then
+ rule = f_w(linewidth * bpfactor,dim_h,dim_v)
+ else
+ rule = f_o(dim_h,dim_v)
+ end
+ else
+ rule = f_f(dim_h,dim_v)
+ end
+ end
+
+ b = b + 1 ; buffer[b] = rule
+ b = b + 1 ; buffer[b] = s_e
+
+ -- buffer[saved_b] = concat(buffer," ",saved_b,b)
+ -- b = saved_b
+
+ end
+
+ flushers.simplerule = function(pos_h,pos_v,pos_r,size_h,size_v)
+ pdf_goto_pagemode()
+
+ b = b + 1 ; buffer[b] = s_b
+
+ local dim_h = size_h * bpfactor
+ local dim_v = size_v * bpfactor
+ local rule
+
+ if dim_v <= one_bp then
+ pdf_set_pos_temp(pos_h,pos_v + 0.5 * size_v)
+ rule = f_v(dim_v,dim_h)
+ elseif dim_h <= one_bp then
+ pdf_set_pos_temp(pos_h + 0.5 * size_h,pos_v)
+ rule = f_h(dim_h,dim_v)
+ else
+ pdf_set_pos_temp(pos_h,pos_v)
+ rule = f_f(dim_h,dim_v)
+ end
+
+ b = b + 1 ; buffer[b] = rule
+ b = b + 1 ; buffer[b] = s_e
+ end
+
+ flushers.specialrule = function(pos_h,pos_v,pos_r,width,height,depth,line,outline,baseline)
+ pdf_goto_pagemode()
+
+ b = b + 1 ; buffer[b] = s_b
+
+ local width = bpfactor * width
+ local height = bpfactor * height
+ local depth = bpfactor * depth
+ local total = height + depth
+ local line = bpfactor * line
+ local half = line / 2
+ local rule
+
+ if outline then
+ local d = -depth + half
+ local w = width - line
+ local t = total - line
+ if baseline then
+ rule = f_y(line,half,d,w,t,half,w)
+ else
+ rule = f_x(line,half,d,w,t)
+ end
+ else
+ rule = f_b(line,-depth,width,total)
+ end
+ pdf_set_pos_temp(pos_h,pos_v)
+
+ b = b + 1 ; buffer[b] = rule
+ b = b + 1 ; buffer[b] = s_e
+ end
+
+end
+
+--- basics
+
+local wrapup, registerpage do
+
+ local pages = { }
+ local maxkids = 10
+ local nofpages = 0
+ local pagetag = "unset"
+
+ registerpage = function(object)
+ nofpages = nofpages + 1
+ local objnum = pdfpagereference(nofpages)
+ pages[nofpages] = {
+ page = nofpages, -- original number, only for diagnostics
+ objnum = objnum,
+ object = object,
+ tag = pagetag,
+ }
+ end
+
+ function lpdf.setpagetag(tag)
+ pagetag = tag or "unset"
+ end
+
+ function lpdf.getnofpages()
+ return nofpages
+ end
+
+ function lpdf.getpagetags()
+ local list = { }
+ for i=1,nofpages do
+ list[i] = pages[i].tag
+ end
+ return list
+ end
+
+ function lpdf.setpageorder(mapping)
+ -- mapping can be a hash so:
+ local list = table.sortedkeys(mapping)
+ local n = #list
+ if n == nofpages then
+ local done = { }
+ local hash = { }
+ for i=1,n do
+ local order = mapping[list[i]]
+ if hash[order] then
+ report("invalid page order, duplicate entry %i",order)
+ return
+ elseif order < 1 or order > nofpages then
+ report("invalid page order, no page %i",order)
+ return
+ else
+ done[i] = pages[order]
+ hash[order] = true
+ end
+ end
+ pages = done
+ else
+ report("invalid page order, %i entries expected",nofpages)
+ end
+ end
+
+ -- We can have this, but then via codeinjections etc. Later.
+
+ -- function structures.pages.swapthem()
+ -- local n = lpdf.getnofpages()
+ -- local t = { }
+ -- for i=1,n do
+ -- t[i] = i
+ -- end
+ -- for i=2,math.odd(n) and n or (n-1),2 do
+ -- t[i] = i+1
+ -- t[i+1] = i
+ -- end
+ -- lpdf.setpageorder(t)
+ -- end
+
+ wrapup = function(driver)
+
+ -- hook (to reshuffle pages)
+ local pagetree = { }
+ local parent = nil
+ local minimum = 0
+ local maximum = 0
+ local current = 0
+ if #pages > 1.5 * maxkids then
+ repeat
+ local plist, pnode
+ if current == 0 then
+ plist, minimum = pages, 1
+ elseif current == 1 then
+ plist, minimum = pagetree, 1
+ else
+ plist, minimum = pagetree, maximum + 1
+ end
+ maximum = #plist
+ if maximum > minimum then
+ local kids
+ for i=minimum,maximum do
+ local p = plist[i]
+ if not pnode or #kids == maxkids then
+ kids = pdfarray()
+ parent = pdfreserveobject()
+ pnode = pdfdictionary {
+ objnum = parent,
+ Type = pdf_pages,
+ Kids = kids,
+ Count = 0,
+ }
+ pagetree[#pagetree+1] = pnode
+ end
+ kids[#kids+1] = pdfreference(p.objnum)
+ pnode.Count = pnode.Count + (p.Count or 1)
+ p.Parent = pdfreference(parent)
+ end
+ end
+ current = current + 1
+ until maximum == minimum
+ -- flush page tree
+ for i=1,#pagetree do
+ local entry = pagetree[i]
+ local objnum = entry.objnum
+ entry.objnum = nil
+ pdfflushobject(objnum,entry)
+ end
+ else
+ -- ugly
+ local kids = pdfarray()
+ local list = pdfdictionary {
+ Type = pdf_pages,
+ Kids = kids,
+ Count = nofpages,
+ }
+ parent = pdfreserveobject()
+ for i=1,nofpages do
+ local page = pages[i]
+ kids[#kids+1] = pdfreference(page.objnum)
+ page.Parent = pdfreference(parent)
+ end
+ pdfflushobject(parent,list)
+ end
+ for i=1,nofpages do
+ local page = pages[i]
+ local object = page.object
+ object.Parent = page.Parent
+ pdfflushobject(page.objnum,object)
+ end
+ lpdf.addtocatalog("Pages",pdfreference(parent))
+
+ end
+
+end
+
+pdf_h, pdf_v = 0, 0
+
+local function initialize(driver,details)
+ reset_variables(details)
+ reset_buffer()
+end
+
+-- This will all move and be merged and become less messy.
+
+-- todo: more clever resource management: a bit tricky as we can inject
+-- stuff in the page stream
+
+local compact = false
+
+do
+
+ -- This is more a convenience feature and it might even be not entirely robust.
+ -- It removes redundant color directives which makes the page stream look a bit
+ -- nicer (also when figuring out issues). I might add more here but there is
+ -- some additional overhead involved so runtime can be impacted.
+
+ local P, R, S, Cs, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.Cs, lpeg.match
+
+ local p_ds = (R("09") + S(" ."))^1
+ ----- p_nl = S("\n\r")^1
+ local p_nl = S("\n")^1
+ local p_eg = P("Q")
+
+ local p_cl = p_ds * (P("rg") + P("g") + P("k")) * p_ds * (P("RG") + P("G") + P("K"))
+ ----- p_cl = (p_ds * (P("rg") + P("g") + P("k") + P("RG") + P("G") + P("K")))^1
+ local p_tr = P("/Tr") * p_ds * P("gs")
+
+ local p_no_cl = (p_cl * p_nl) / ""
+ local p_no_tr = (p_tr * p_nl) / ""
+ local p_no_nl = 1 - p_nl
+
+ local p_do_cl = p_cl * p_nl
+ local p_do_tr = p_tr * p_nl
+
+ local p_do_eg = p_eg * p_nl
+
+ local pattern = Cs( (
+ (p_no_cl + p_no_tr)^0 * p_do_eg -- transparencies and colors before Q
+ + p_no_tr * p_no_cl * p_do_tr * p_do_cl -- transparencies and colors before others
+ + p_no_cl * p_do_cl -- successive colors
+ + p_no_tr * p_do_tr -- successive transparencies
+ + p_no_nl^1
+ + 1
+ )^1 )
+
+ local oldsize = 0
+ local newsize = 0
+
+ directives.register("pdf.compact", function(v)
+ compact = v and function(s)
+ oldsize = oldsize + #s
+ s = lpegmatch(pattern,s) or s
+ newsize = newsize + #s
+ return s
+ end
+ end)
+
+ statistics.register("pdf pagestream",function()
+ if oldsize ~= newsize then
+ return string.format("old size: %i, new size %i",oldsize,newsize)
+ end
+ end)
+
+
+end
+
+local flushdeferred -- defined later
+
+local level = 0
+
+local finalize do
+
+ local f_font = formatters["F%d"]
+
+ local f_form = formatters["Fm%d"]
+ local f_group = formatters["Gp%d"]
+ local f_image = formatters["Im%d"]
+
+ finalize = function(driver,details)
+
+ level = level + 1
+
+ pdf_goto_pagemode() -- for now
+
+ local objnum = details.objnum
+ local specification = details.specification
+
+ local content = concat(buffer,"\n",1,b)
+
+ if compact then
+ content = compact(content)
+ end
+
+ local fonts = nil
+ local xforms = nil
+
+ if next(usedfonts) then
+ fonts = pdfdictionary { }
+ for k, v in next, usedfonts do
+ fonts[f_font(v)] = pdfreference(pdfgetfontobjectnumber(k)) -- we can overload for testing
+ end
+ end
+
+ -- messy: use real indexes for both ... so we need to change some in the
+ -- full luatex part
+
+ if next(usedxforms) or next(usedximages) or next(usedxgroups) then
+ xforms = pdfdictionary { }
+ for k in sortedhash(usedxforms) do
+ xforms[f_form(getxformname(k))] = pdfreference(k)
+ end
+ for k, v in sortedhash(usedximages) do
+ xforms[f_image(k)] = pdfreference(v)
+ end
+ for k, v in sortedhash(usedxgroups) do
+ xforms[f_group(k)] = pdfreference(v)
+ end
+ end
+
+ reset_buffer()
+
+ -- finish_pdfpage_callback(shippingmode == "page")
+
+ if shippingmode == "page" then
+
+ local pageproperties = lpdf.getpageproperties()
+
+ local pageresources = pageproperties.pageresources
+ local pageattributes = pageproperties.pageattributes
+ local pagesattributes = pageproperties.pagesattributes
+
+ pageresources.Font = fonts
+ pageresources.XObject = xforms
+ pageresources.ProcSet = lpdf.procset()
+
+ local bbox = pdfarray {
+ boundingbox[1] * bpfactor,
+ boundingbox[2] * bpfactor,
+ boundingbox[3] * bpfactor,
+ boundingbox[4] * bpfactor,
+ }
+
+ local contentsobj = pdfflushstreamobject(content,false,false)
+
+ pageattributes.Type = pdf_page
+ pageattributes.Contents = pdfreference(contentsobj)
+ pageattributes.Resources = pageresources
+ -- pageattributes.Resources = pdfreference(pdfflushobject(pageresources))
+ -- pageattributes.MediaBox = bbox
+ pageattributes.MediaBox = pdfsharedobject(bbox)
+ pageattributes.Parent = nil -- precalculate
+ pageattributes.Group = nil -- todo
+
+ -- resources can be indirect
+
+ registerpage(pageattributes)
+
+ lpdf.finalizepage(true)
+
+ local TrimBox = pageattributes.TrimBox
+ local CropBox = pageattributes.CropBox
+ local BleedBox = pageattributes.BleedBox
+
+ -- Indirect objects don't work in all viewers.
+
+ if TrimBox then pageattributes.TrimBox = pdfsharedobject(TrimBox ) end
+ if CropBox then pageattributes.CropBox = pdfsharedobject(CropBox ) end
+ if BleedBox then pageattributes.BleedBox = pdfsharedobject(BleedBox) end
+
+ else
+
+ local xformtype = specification.type or 0
+ local margin = specification.margin or 0
+ local attributes = specification.attributes or ""
+ local resources = specification.resources or ""
+
+ local wrapper = nil
+
+ if xformtype == 0 then
+ wrapper = pdfdictionary {
+ Type = pdf_xobject,
+ Subtype = pdf_form,
+ FormType = 1,
+ BBox = nil,
+ Matrix = nil,
+ Resources = nil,
+ }
+ else
+ wrapper = pdfdictionary {
+ BBox = nil,
+ Matrix = nil,
+ Resources = nil,
+ }
+ end
+ if xformtype == 0 or xformtype == 1 or xformtype == 3 then
+ wrapper.BBox = pdfarray {
+ -margin * bpfactor,
+ -margin * bpfactor,
+ (boundingbox[3] + margin) * bpfactor,
+ (boundingbox[4] + margin) * bpfactor,
+ }
+ end
+ if xformtype == 0 or xformtype == 2 or xformtype == 3 then
+ -- can be shared too
+ wrapper.Matrix = pdfarray { 1, 0, 0, 1, 0, 0 }
+ end
+
+ -- todo: additional = resources
+
+ local boxresources = lpdf.collectedresources { serialize = false }
+ boxresources.Font = fonts
+ boxresources.XObject = xforms
+
+ -- todo: maybe share them
+ -- wrapper.Resources = pdfreference(pdfflushobject(boxresources))
+
+ if resources ~= "" then
+ boxresources = boxresources + resources
+ end
+ if attributes ~= "" then
+ wrapper = wrapper + attributes
+ end
+
+ wrapper.Resources = next(boxresources) and boxresources or nil
+ wrapper.ProcSet = lpdf.procset()
+
+ pdfflushstreamobject(content,wrapper,false,specification.objnum)
+
+ end
+
+ for objnum in sortedhash(usedxforms) do
+ local f = flushedxforms[objnum]
+ if f[1] == false then
+ f[1] = true
+ local objnum = f[2] -- specification.objnum
+ local specification = boxresources[objnum]
+ local list = specification.list
+ localconverter(list,"xform",f[2],specification)
+ end
+ end
+
+ pdf_h, pdf_v = 0, 0
+
+ if level == 1 then
+ flushdeferred()
+ end
+ level = level - 1
+
+ end
+
+end
+
+updaters.register("backend.update",function()
+ local saveboxresource = tex.boxresources.save
+ --
+ -- also in lpdf-res .. brrr .. needs fixing
+ --
+ backends.codeinjections.registerboxresource = function(n,offset)
+ local r = saveboxresource(n,nil,nil,false,0,offset or 0)
+ return r
+ end
+end)
+
+-- now comes the pdf file handling
+
+local objects = { }
+local streams = { } -- maybe just parallel to objects (no holes)
+local nofobjects = 0
+local offset = 0
+local f = false
+local flush = false
+local threshold = 40 -- also #("/Filter /FlateDecode") (compression threshold)
+local objectstream = true
+local compress = true
+local cache = false
+local info = ""
+local catalog = ""
+local lastdeferred = false
+local majorversion = 1
+local minorversion = 7
+local trailerid = true
+
+directives.register("backend.pdf.threshold",function(v)
+ if v then
+ threshold = tonumber(v) or 40
+ else
+ threshold = -1000
+ end
+end)
+
+local f_object = formatters["%i 0 obj\010%s\010endobj\010"]
+local f_stream_n_u = formatters["%i 0 obj\010<< /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
+local f_stream_n_c = formatters["%i 0 obj\010<< /Filter /FlateDecode /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
+local f_stream_d_u = formatters["%i 0 obj\010<< %s /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
+local f_stream_d_c = formatters["%i 0 obj\010<< %s /Filter /FlateDecode /Length %i >>\010stream\010%s\010endstream\010endobj\010"]
+local f_stream_d_r = formatters["%i 0 obj\010<< %s >>\010stream\010%s\010endstream\010endobj\010"]
+
+----- f_object_b = formatters["%i 0 obj\010"]
+local f_stream_b_n_u = formatters["%i 0 obj\010<< /Length %i >>\010stream\010"]
+local f_stream_b_n_c = formatters["%i 0 obj\010<< /Filter /FlateDecode /Length %i >>\010stream\010"]
+local f_stream_b_d_u = formatters["%i 0 obj\010<< %s /Length %i >>\010stream\010"]
+local f_stream_b_d_c = formatters["%i 0 obj\010<< %s /Filter /FlateDecode /Length %i >>\010stream\010"]
+local f_stream_b_d_r = formatters["%i 0 obj\010<< %s >>\010stream\010"]
+
+----- s_object_e = "\010endobj\010"
+local s_stream_e = "\010endstream\010endobj\010"
+
+do
+
+ -- Versions can be set but normally are managed by the official standards. When possible
+ -- reading and writing should look at these values.
+
+ function lpdf.setversion(major,minor)
+ majorversion = tonumber(major) or majorversion
+ minorversion = tonumber(minor) or minorversion
+ end
+
+ function lpdf.getversion(major,minor)
+ return majorversion, minorversion
+ end
+
+ function lpdf.majorversion() return majorversion end
+ function lpdf.minorversion() return minorversion end
+
+ -- It makes no sense to support levels so we only enable and disable and stick to level 3
+ -- which is both fast and efficient.
+
+ local frozen = false
+ local clevel = 3
+ local olevel = 1
+
+ function lpdf.setcompression(level,objectlevel,freeze)
+ if not frozen then
+ compress = level and level ~= 0 and true or false
+ objectstream = objectlevel and objectlevel ~= 0 and true or false
+ frozen = freeze
+ end
+ end
+
+ function lpdf.getcompression()
+ return compress and olevel or 0, objectstream and clevel or 0
+ end
+
+ function lpdf.compresslevel()
+ return compress and olevel or 0
+ end
+
+ function lpdf.objectcompresslevel()
+ return objectstream and clevel or 0
+ end
+
+ if environment.arguments.nocompression then
+ lpdf.setcompression(0,0,true)
+ end
+
+end
+
+local addtocache, flushcache, cache do
+
+ local data, d = { }, 0
+ local list, l = { }, 0
+ local coffset = 0
+ local indices = { }
+
+ local maxsize = 32 * 1024 -- uncompressed
+ local maxcount = 0xFF
+
+ addtocache = function(n,str)
+ local size = #str
+ if size == 0 then
+ -- todo: message
+ return
+ end
+ if coffset + size > maxsize or d == maxcount then
+ flushcache()
+ end
+ if d == 0 then
+ nofobjects = nofobjects + 1
+ objects[nofobjects] = false
+ streams[nofobjects] = indices
+ cache = nofobjects
+ end
+ objects[n] = - cache
+ indices[n] = d
+ d = d + 1
+ -- can have a comment n 0 obj as in luatex
+ data[d] = str
+ l = l + 1 ; list[l] = n
+ l = l + 1 ; list[l] = coffset
+ coffset = coffset + size + 1
+ end
+
+ local p_ObjStm = pdfconstant("ObjStm")
+
+ flushcache = function() -- references cannot be stored
+ if l > 0 then
+ list = concat(list," ")
+ data[0] = list
+ data = concat(data,"\010",0,d)
+ local strobj = pdfdictionary {
+ Type = p_ObjStm,
+ N = d,
+ First = #list + 1,
+ }
+ objects[cache] = offset
+ local b = nil
+ local e = s_stream_e
+ if compress then
+ local comp = zlibcompress(data,3)
+ if comp and #comp < #data then
+ data = comp
+ b = f_stream_b_d_c(cache,strobj(),#data)
+ else
+ b = f_stream_b_d_u(cache,strobj(),#data)
+ end
+ else
+ b = f_stream_b_d_u(cache,strobj(),#data)
+ end
+ flush(f,b)
+ flush(f,data)
+ flush(f,e)
+ offset = offset + #b + #data + #e
+ data, d = { }, 0
+ list, l = { }, 0
+ coffset = 0
+ indices = { }
+ end
+ end
+
+end
+
+do
+
+ local names = { }
+ local cache = { }
+ local nofpages = 0
+
+ local texgetcount = tex.getcount
+
+ function lpdf.reserveobject(name)
+ nofobjects = nofobjects + 1
+ objects[nofobjects] = false
+ if name then
+ names[name] = nofobjects
+ if trace_objects then
+ report_objects("reserving number %a under name %a",nofobjects,name)
+ end
+ elseif trace_objects then
+ report_objects("reserving number %a",nofobjects)
+ end
+ return nofobjects
+ end
+
+ function lpdf.pagereference(n,complete) -- true | false | nil | n [true,false]
+ if nofpages == 0 then
+ nofpages = structures.pages.nofpages
+ if nofpages == 0 then
+ nofpages = 1
+ end
+ end
+ if n == true or not n then
+ complete = n
+ n = texgetcount("realpageno")
+ end
+ local r = n > nofpages and pdfgetpagereference(nofpages) or pdfgetpagereference(n)
+ return complete and pdfreference(r) or r
+ end
+
+ function lpdf.nofpages()
+ return structures.pages.nofpages
+ end
+
+ function lpdf.object(...)
+ pdfdeferredobject(...)
+ end
+
+ function lpdf.delayedobject(data,n)
+ if n then
+ pdfdeferredobject(n,data)
+ else
+ n = pdfdeferredobject(data)
+ end
+-- pdfreferenceobject(n)
+ return n
+ end
+
+ function lpdf.flushobject(name,data)
+ if data then
+ local named = names[name]
+ if named then
+ if not trace_objects then
+ elseif trace_details then
+ report_objects("flushing data to reserved object with name %a, data: %S",name,data)
+ else
+ report_objects("flushing data to reserved object with name %a",name)
+ end
+ return pdfimmediateobject(named,tostring(data))
+ else
+ if not trace_objects then
+ elseif trace_details then
+ report_objects("flushing data to reserved object with number %s, data: %S",name,data)
+ else
+ report_objects("flushing data to reserved object with number %s",name)
+ end
+ return pdfimmediateobject(name,tostring(data))
+ end
+ else
+ if trace_objects and trace_details then
+ report_objects("flushing data: %S",name)
+ end
+ return pdfimmediateobject(tostring(name))
+ end
+ end
+
+ function lpdf.flushstreamobject(data,dict,compressed,objnum) -- default compressed
+ if trace_objects then
+ report_objects("flushing stream object of %s bytes",#data)
+ end
+ local dtype = type(dict)
+ local kind = compressed == "raw" and "raw" or "stream"
+ local nolength = nil
+ if compressed == "raw" then
+ compressed = nil
+ nolength = true
+ -- data = string.formatters["<< %s >>stream\n%s\nendstream"](attr,data)
+ end
+ return pdfdeferredobject {
+ objnum = objnum,
+ immediate = true,
+ nolength = nolength,
+ compresslevel = compressed == false and 0 or nil,
+ type = "stream",
+ string = data,
+ attr = (dtype == "string" and dict) or (dtype == "table" and dict()) or nil,
+ }
+ end
+
+ function lpdf.flushstreamfileobject(filename,dict,compressed,objnum) -- default compressed
+ if trace_objects then
+ report_objects("flushing stream file object %a",filename)
+ end
+ local dtype = type(dict)
+ return pdfdeferredobject {
+ objnum = objnum,
+ immediate = true,
+ compresslevel = compressed == false and 0 or nil,
+ type = "stream",
+ file = filename,
+ attr = (dtype == "string" and dict) or (dtype == "table" and dict()) or nil,
+ }
+ end
+
+ local shareobjectcache, shareobjectreferencecache = { }, { }
+
+ function lpdf.shareobject(content)
+ if content == nil then
+ -- invalid object not created
+ else
+ content = tostring(content)
+ local o = shareobjectcache[content]
+ if not o then
+ o = pdfimmediateobject(content)
+ shareobjectcache[content] = o
+ end
+ return o
+ end
+ end
+
+ function lpdf.shareobjectreference(content)
+ if content == nil then
+ -- invalid object not created
+ else
+ content = tostring(content)
+ local r = shareobjectreferencecache[content]
+ if not r then
+ local o = shareobjectcache[content]
+ if not o then
+ o = pdfimmediateobject(content)
+ shareobjectcache[content] = o
+ end
+ r = pdfreference(o)
+ shareobjectreferencecache[content] = r
+ end
+ return r
+ end
+ end
+
+end
+
+local pages = table.setmetatableindex(function(t,k)
+ local v = pdfreserveobject()
+ t[k] = v
+ return v
+end)
+
+function lpdf.getpagereference(n)
+ return pages[n]
+end
+
+local function flushnormalobj(data,n)
+ if not n then
+ nofobjects = nofobjects + 1
+ n = nofobjects
+ end
+ data = f_object(n,data)
+ if level == 0 then
+ objects[n] = offset
+ offset = offset + #data
+ flush(f,data)
+ else
+ if not lastdeferred then
+ lastdeferred = n
+ elseif n < lastdeferred then
+ lastdeferred = n
+ end
+ objects[n] = data
+ end
+ return n
+end
+
+local function flushstreamobj(data,n,dict,comp,nolength)
+ if not data then
+ report("no data for %S",dict)
+ return
+ end
+ if not n then
+ nofobjects = nofobjects + 1
+ n = nofobjects
+ end
+ local size = #data
+ if level == 0 then
+ local b = nil
+ local e = s_stream_e
+ if nolength then
+ b = f_stream_b_d_r(n,dict)
+ elseif comp ~= false and compress and size > threshold then
+ local compdata = zlibcompress(data,3)
+ if compdata then
+ local compsize = #compdata
+ if compsize > size - threshold then
+ b = dict and f_stream_b_d_u(n,dict,size) or f_stream_b_n_u(n,size)
+ else
+ data = compdata
+ b = dict and f_stream_b_d_c(n,dict,compsize) or f_stream_b_n_c(n,compsize)
+ end
+ else
+ b = dict and f_stream_b_d_u(n,dict,size) or f_stream_b_n_u(n,size)
+ end
+ else
+ b = dict and f_stream_b_d_u(n,dict,size) or f_stream_b_n_u(n,size)
+ end
+ flush(f,b)
+ flush(f,data)
+ flush(f,e)
+ objects[n] = offset
+ offset = offset + #b + #data + #e
+ else
+ if nolength then
+ data = f_stream_d_r(n,dict,data)
+ elseif comp ~= false and compress and size > threshold then
+ local compdata = zlibcompress(data,3)
+ if compdata then
+ local compsize = #compdata
+ if compsize > size - threshold then
+ data = dict and f_stream_d_u(n,dict,size,data) or f_stream_n_u(n,size,data)
+ else
+ data = dict and f_stream_d_c(n,dict,compsize,compdata) or f_stream_n_c(n,compsize,compdata)
+ end
+ else
+ data = dict and f_stream_d_u(n,dict,size,data) or f_stream_n_u(n,size,data)
+ end
+ else
+ data = dict and f_stream_d_u(n,dict,size,data) or f_stream_n_u(n,size,data)
+ end
+ if not lastdeferred then
+ lastdeferred = n
+ elseif n < lastdeferred then
+ lastdeferred = n
+ end
+ objects[n] = data
+ end
+ return n
+end
+
+flushdeferred = function() -- was forward defined
+ if lastdeferred then
+ for n=lastdeferred,nofobjects do
+ local o = objects[n]
+ if type(o) == "string" then
+ objects[n] = offset
+ offset = offset + #o
+ flush(f,o)
+ end
+ end
+ lastdeferred = false
+ end
+end
+
+function lpdf.immediateobject(a,b,c,d)
+ local kind --, immediate
+ local objnum, data, attr, filename
+ local compresslevel, objcompression, nolength
+ local argtype = type(a)
+ if argtype == "table" then
+ kind = a.type -- raw | stream
+ -- immediate = a.immediate
+ objnum = a.objnum
+ attr = a.attr
+ compresslevel = a.compresslevel
+ objcompression = a.objcompression
+ filename = a.file
+ data = a.string or a.stream or ""
+ nolength = a.nolength
+ if kind == "stream" then
+ if filename then
+ data = loaddata(filename) or ""
+ end
+ elseif kind == "raw"then
+ if filename then
+ data = loaddata(filename) or ""
+ end
+ elseif kind == "file"then
+ kind = "raw"
+ data = filename and loaddata(filename) or ""
+ elseif kind == "streamfile" then
+ kind = "stream"
+ data = filename and loaddata(filename) or ""
+ end
+ else
+ if argtype == "number" then
+ objnum = a
+ a, b, c = b, c, d
+ else
+ nofobjects = nofobjects + 1
+ objnum = nofobjects
+ end
+ if b then
+ if a == "stream" then
+ kind = "stream"
+ data = b
+ elseif a == "file" then
+ -- kind = "raw"
+ data = loaddata(b)
+ elseif a == "streamfile" then
+ kind = "stream"
+ data = loaddata(b)
+ else
+ data = "" -- invalid object
+ end
+ attr = c
+ else
+ -- kind = "raw"
+ data = a
+ end
+ end
+ if not objnum then
+ nofobjects = nofobjects + 1
+ objnum = nofobjects
+ end
+ -- todo: immediate
+ if kind == "stream" then
+ flushstreamobj(data,objnum,attr,compresslevel and compresslevel > 0 or nil,nolength)
+ elseif objectstream and objcompression ~= false then
+ addtocache(objnum,data)
+ else
+ flushnormalobj(data,objnum)
+ end
+ return objnum
+end
+
+lpdf.deferredobject = lpdf.immediateobject
+
+-- In lua 5.4 the methods are now moved one metalevel deeper so we need to get them
+-- from mt.__index instead. (I did get that at first.) It makes for a slightly (imo)
+-- nicer interface but no real gain in speed as we don't flush that often.
+
+local openfile, closefile do
+
+ -- I used to do but then figured out that when I open and save a file in a mode
+ -- that removes trailing spaces, the xref becomes invalid. The problem was then that a
+ -- reconstruction of the file by a viewer gives weird effects probably because percent symbols
+ -- gets interpreted then. Thanks to Ross Moore for noticing this side effect!
+
+ local f_used = formatters["%010i 00000 n\013\010"]
+ local f_link = formatters["%010i 00000 f\013\010"]
+ local f_first = formatters["%010i 65535 f\013\010"]
+
+ local f_pdf_tag = formatters["%%PDF-%i.%i\010"]
+ local f_xref = formatters["xref\0100 %i\010"]
+ local f_trailer_id = formatters["trailer\010<< %s /ID [ <%s> <%s> ] >>\010startxref\010%i\010%%%%EOF"]
+ local f_trailer_no = formatters["trailer\010<< %s >>\010startxref\010%i\010%%%%EOF"]
+ local f_startxref = formatters["startxref\010%i\010%%%%EOF"]
+
+ local inmemory = false
+ local close = false
+ local update = false
+
+ -- local removefile = os.remove
+
+ openfile = function(filename)
+ if inmemory then
+ local n = 0
+ f = { }
+ flush = function(f,s)
+ n = n + 1 f[n] = s
+ -- offset = offset + #s
+ end
+ close = function(f)
+ f = concat(f)
+ io.savedata(filename,f)
+ f = false
+ end
+ update = function(f,s)
+ f[1] = s
+ end
+ -- local n = 0
+ -- f = {
+ -- write = function(self,s)
+ -- n = n + 1 f[n] = s
+ -- end,
+ -- close = function(self)
+ -- f = concat(f)
+ -- io.savedata(filename,f)
+ -- f = false
+ -- end,
+ -- }
+ else
+ f = io.open(filename,"wb")
+ if not f then
+ -- message
+ os.exit()
+ end
+ -- f:setvbuf("full",64*1024)
+ local m = getmetatable(f)
+ flush = m.write or m.__index.write
+ close = m.close or m.__index.close
+ update = function(f,s)
+ f:seek("set",0)
+ f:write(s)
+ end
+ end
+ local v = f_pdf_tag(majorversion,minorversion)
+ -- local b = "%\xCC\xD5\xC1\xD4\xC5\xD8\xD0\xC4\xC6\010" -- LUATEXPDF (+128)
+ local b = "%\xC3\xCF\xCE\xD4\xC5\xD8\xD4\xD0\xC4\xC6\010" -- CONTEXTPDF (+128)
+ flush(f,v)
+ flush(f,b)
+ offset = offset + #v + #b
+ end
+
+ closefile = function(abort)
+ if abort then
+ close(f)
+ if not environment.arguments.nodummy then
+ f = io.open(abort,"wb")
+ if f then
+ local name = resolvers.findfile("context-lmtx-error.pdf")
+ if name then
+ local data = io.loaddata(name)
+ if data then
+ f:write(data)
+ f:close()
+ return
+ end
+ end
+ f:close()
+ end
+ end
+ os.remove(abort)
+ else
+ local xrefoffset = offset
+ local lastfree = 0
+ local noffree = 0
+ local catalog = lpdf.getcatalog()
+ local info = lpdf.getinfo()
+ if trailerid == true then
+ trailerid = md5.HEX(osuuid())
+ elseif trailerid and #trailerid > 32 then
+ trailerid = md5.HEX(trailerid)
+ else
+ trailerid = false
+ end
+ if objectstream then
+ flushdeferred()
+ flushcache()
+ --
+ xrefoffset = offset
+ --
+ nofobjects = nofobjects + 1
+ objects[nofobjects] = offset -- + 1
+ --
+ -- combine these three in one doesn't really give less code so
+ -- we go for the efficient ones
+ --
+ local nofbytes = 4
+ local c1, c2, c3, c4
+ if offset <= 0xFFFF then
+ nofbytes = 2
+ for i=1,nofobjects do
+ local o = objects[i]
+ if not o then
+ noffree = noffree + 1
+ else
+ local strm = o < 0
+ if strm then
+ o = -o
+ end
+ c1 = extract(o,8,8)
+ c2 = extract(o,0,8)
+ if strm then
+ objects[i] = char(2,c1,c2,streams[o][i])
+ else
+ objects[i] = char(1,c1,c2,0)
+ end
+ end
+ end
+ if noffree > 0 then
+ for i=nofobjects,1,-1 do
+ local o = objects[i]
+ if not o then
+ local f1 = extract(lastfree,8,8)
+ local f2 = extract(lastfree,0,8)
+ objects[i] = char(0,f1,f2,0)
+ lastfree = i
+ end
+ end
+ end
+ elseif offset <= 0xFFFFFF then
+ nofbytes = 3
+ for i=1,nofobjects do
+ local o = objects[i]
+ if not o then
+ noffree = noffree + 1
+ else
+ local strm = o < 0
+ if strm then
+ o = -o
+ end
+ c1 = extract(o,16,8)
+ c2 = extract(o, 8,8)
+ c3 = extract(o, 0,8)
+ if strm then
+ objects[i] = char(2,c1,c2,c3,streams[o][i])
+ else
+ objects[i] = char(1,c1,c2,c3,0)
+ end
+ end
+ end
+ if noffree > 0 then
+ for i=nofobjects,1,-1 do
+ local o = objects[i]
+ if not o then
+ local f1 = extract(lastfree,16,8)
+ local f2 = extract(lastfree, 8,8)
+ local f3 = extract(lastfree, 0,8)
+ objects[i] = char(0,f1,f2,f3,0)
+ lastfree = i
+ end
+ end
+ end
+ else
+ nofbytes = 4
+ for i=1,nofobjects do
+ local o = objects[i]
+ if not o then
+ noffree = noffree + 1
+ else
+ local strm = o < 0
+ if strm then
+ o = -o
+ end
+ c1 = extract(o,24,8)
+ c2 = extract(o,16,8)
+ c3 = extract(o, 8,8)
+ c4 = extract(o, 0,8)
+ if strm then
+ objects[i] = char(2,c1,c2,c3,c4,streams[o][i])
+ else
+ objects[i] = char(1,c1,c2,c3,c4,0)
+ end
+ end
+ end
+ if noffree > 0 then
+ for i=nofobjects,1,-1 do
+ local o = objects[i]
+ if not o then
+ local f1 = extract(lastfree,24,8)
+ local f2 = extract(lastfree,16,8)
+ local f3 = extract(lastfree, 8,8)
+ local f4 = extract(lastfree, 0,8)
+ objects[i] = char(0,f1,f2,f3,f4,0)
+ lastfree = i
+ end
+ end
+ end
+ end
+ objects[0] = rep("\0",1+nofbytes+1)
+ local data = concat(objects,"",0,nofobjects)
+ local xref = pdfdictionary {
+ Type = pdfconstant("XRef"),
+ Size = nofobjects + 1,
+ W = pdfarray { 1, nofbytes, 1 },
+ Root = catalog,
+ Info = info,
+ ID = trailerid and pdfarray { pdfliteral(trailerid,true), pdfliteral(trailerid,true) } or nil,
+ }
+ if compress then
+ local comp = zlibcompress(data,3)
+ if comp then
+ data = comp
+ flush(f,f_stream_b_d_c(nofobjects,xref(),#data))
+ else
+ flush(f,f_stream_b_d_u(nofobjects,xref(),#data))
+ end
+ else
+ flush(f,f_stream_b_d_u(nofobjects,xref(),#data))
+ end
+ flush(f,data)
+ flush(f,s_stream_e)
+ flush(f,f_startxref(xrefoffset))
+ else
+ flushdeferred()
+ xrefoffset = offset
+ flush(f,f_xref(nofobjects+1))
+ local trailer = pdfdictionary {
+ Size = nofobjects+1,
+ Root = catalog,
+ Info = info,
+ }
+ for i=1,nofobjects do
+ local o = objects[i]
+ if o then
+ objects[i] = f_used(o)
+ end
+ end
+ for i=nofobjects,1,-1 do
+ local o = objects[i]
+ if not o then
+ objects[i] = f_link(lastfree)
+ lastfree = i
+ end
+ end
+ objects[0] = f_first(lastfree)
+ flush(f,concat(objects,"",0,nofobjects))
+ trailer.Size = nofobjects + 1
+ if trailerid then
+ flush(f,f_trailer_id(trailer(),trailerid,trailerid,xrefoffset))
+ else
+ flush(f,f_trailer_no(trailer(),xrefoffset))
+ end
+ end
+ update(f,f_pdf_tag(majorversion,minorversion))
+ close(f)
+ end
+ io.flush()
+ closefile = function() end
+ end
+
+end
+
+-- For the moment we overload it here, although back-fil.lua eventually will
+-- be merged with back-pdf as it's pdf specific, or maybe back-imp-pdf or so.
+
+do -- updaters.register("backend.update.pdf",function()
+
+ -- We overload img but at some point it will even go away, so we just
+ -- reimplement what we need in context. This will change completely i.e.
+ -- we will drop the low level interface!
+
+ local codeinjections = backends.pdf.codeinjections
+
+ local imagetypes = images.types -- pdf png jpg jp2 jbig2 stream
+ local img_none = imagetypes.none
+
+ local rulecodes = nodes.rulecodes
+
+ local setprop = nodes.nuts.setprop
+
+ local report_images = logs.reporter("backend","images")
+
+ local lastindex = 0
+ local indices = { }
+
+ local bpfactor = number.dimenfactors.bp
+ local imagerule_code = rulecodes.image
+
+ function codeinjections.newimage(specification)
+ return specification
+ end
+
+ function codeinjections.copyimage(original)
+ return setmetatableindex(original)
+ end
+
+ function codeinjections.scanimgage(specification)
+ return specification
+ end
+
+ local function embedimage(specification)
+ if specification then
+ lastindex = lastindex + 1
+ index = lastindex
+ specification.index = index
+ local xobject = pdfdictionary { }
+ if not specification.notype then
+ xobject.Type = pdf_xobject
+ xobject.Subtype = pdf_form
+ xobject.FormType = 1
+ end
+ local bbox = specification.bbox
+ if bbox and not specification.nobbox then
+ xobject.BBox = pdfarray {
+ bbox[1] * bpfactor,
+ bbox[2] * bpfactor,
+ bbox[3] * bpfactor,
+ bbox[4] * bpfactor,
+ }
+ end
+ xobject = xobject + specification.attr
+ if bbox and not specification.width then
+ specification.width = bbox[3]
+ end
+ if bbox and not specification.height then
+ specification.height = bbox[4]
+ end
+ local dict = xobject()
+ --
+ nofobjects = nofobjects + 1
+ local objnum = nofobjects
+ local nolength = specification.nolength
+ local stream = specification.stream or specification.string
+ --
+ -- We cannot set type in native img so we need this hack or
+ -- otherwise we need to patch too much. Better that i write
+ -- a wrapper then. Anyway, it has to be done better: a key that
+ -- tells either or not to scale by xsize/ysize when flushing.
+ --
+ if not specification.type then
+ local kind = specification.kind
+ if kind then
+ -- take that one
+ elseif attr and find(attr,"BBox") then
+ kind = img_stream
+ else
+ -- hack: a bitmap
+ kind = img_none
+ end
+ specification.type = kind
+ specification.kind = kind
+ end
+ local compress = compresslevel and compresslevel > 0 or nil
+ flushstreamobj(stream,objnum,dict,compress,nolength)
+ specification.objnum = objnum
+ specification.rotation = specification.rotation or 0
+ specification.orientation = specification.orientation or 0
+ specification.transform = specification.transform or 0
+ specification.stream = nil
+ specification.attr = nil
+ specification.type = specification.kind or specification.type or img_none
+ indices[index] = specification -- better create a real specification
+ return specification
+ end
+ end
+
+ codeinjections.embedimage = embedimage
+
+ function codeinjections.wrapimage(specification)
+ --
+ local index = specification.index
+ if not index then
+ embedimage(specification)
+ end
+ --
+ local width = specification.width or 0
+ local height = specification.height or 0
+ local depth = specification.depth or 0
+ -- newimagerule
+ local n = nodes.pool.rule(width,height,depth)
+ n.subtype = imagerule_code
+ setprop(tonut(n),"index",specification.index)
+ return n
+ end
+
+ function lpdf.includeimage(index)
+ local specification = indices[index]
+ if specification then
+ local bbox = specification.bbox
+ local xorigin = bbox[1]
+ local yorigin = bbox[2]
+ local xsize = bbox[3] - xorigin -- we need the original ones, not the 'rotated' ones
+ local ysize = bbox[4] - yorigin -- we need the original ones, not the 'rotated' ones
+ local transform = specification.transform or 0
+ local objnum = specification.objnum or pdfreserveobject()
+ local groupref = nil
+ local kind = specification.kind or specification.type or img_none -- determines scaling type
+ return
+ kind,
+ xorigin, yorigin,
+ xsize, ysize,
+ transform,
+ objnum,
+ groupref
+ end
+ end
+
+end -- )
+
+do -- updaters.register("backend.update.lpdf",function()
+
+ -- todo: an md5 or sha2 hash can save space
+ -- todo: make a type 3 font instead
+ -- todo: move to lpdf namespace
+
+ local pdfimage
+ local newpdf
+ local openpdf
+ local closepdf
+ local copypage
+
+
+ updaters.register("backend.update.lpdf",function()
+ pdfimage = lpdf.epdf.image
+ newpdf = pdfimage.new
+ openpdf = pdfimage.open
+ closepdf = pdfimage.close
+ copypage = pdfimage.copy
+ end)
+
+ local embedimage = images.embed
+
+ local nofstreams = 0
+ local topdf = { }
+ local toidx = { }
+
+ local function storedata_s(pdf)
+ local idx = toidx[pdf]
+ if not idx then
+ nofstreams = nofstreams + 1
+ idx = nofstreams
+ toidx[pdf] = nofstreams
+ topdf[idx] = pdf
+ end
+ return idx
+ end
+
+ local function vfimage_s(id,wd,ht,dp,pos_h,pos_v)
+ local index = topdf[id]
+ if type(index) == "string" then
+ local pdfdoc = newpdf(index,#index)
+ local image = copypage(pdfdoc)
+ local bbox = image.bbox
+ image.width = bbox[3] - bbox[1]
+ image.height = bbox[4] - bbox[2]
+ embedimage(image)
+ index = image.index
+ topdf[id] = index
+ end
+ flushimage(index,wd,ht,dp,pos_h,pos_v)
+ end
+
+ local function storedata_n(name,page)
+ local idx = toidx[pdf]
+ if not idx then
+ nofstreams = nofstreams + 1
+ idx = nofstreams
+ toidx[pdf] = nofstreams
+ topdf[idx] = pdf
+ end
+ return idx
+ end
+
+ -- We need to have a way to close such a pdf ... esp for fonts.
+
+ local pdfdocs = { }
+
+ local function vfimage_n(name,page,wd,ht,dp,pos_h,pos_v)
+ local d = pdfdocs[name]
+ if not d then
+ d = { doc = openpdf(name), pages = { } }
+ pdfdocs[name] = d
+ end
+ local index = d.pages[page]
+ if not index then
+ local image = copypage(d.doc,page)
+ local bbox = image.bbox
+ image.width = bbox[3] - bbox[1]
+ image.height = bbox[4] - bbox[2]
+ embedimage(image)
+ index = image.index
+ d.pages[page] = index
+ end
+ flushimage(index,wd,ht,dp,pos_h,pos_v)
+ end
+
+ function lpdf.pdfvfimage(wd,ht,dp,data,name)
+ if type(data) == "number" then
+ return { "lua", function(font,char,pos_h,pos_v)
+ vfimage_n(name,data,wd,ht,dp,pos_h,pos_v)
+ end }
+ else
+ return { "lua", function(font,char,pos_h,pos_v)
+ local id = storedata_s(data)
+ vfimage_s(id,wd,ht,dp,pos_h,pos_v)
+ end }
+ end
+ end
+
+end -- )
+
+-- The driver.
+
+do
+
+ -- local addsuffix = file.addsuffix
+ local texgetbox = tex.getbox
+
+ local pdfname = nil
+ local converter = nil
+ local useddriver = nil -- a bit of a hack
+
+ local function outputfilename(driver)
+ return pdfname
+ end
+
+ -- todo: prevent twice
+
+ local function prepare(driver)
+ if not environment.initex then
+ -- install new functions in pdf namespace
+-- updaters.apply("backend.update.pdf")
+ -- install new functions in lpdf namespace
+ updaters.apply("backend.update.lpdf")
+ -- adapt existing shortcuts to lpdf namespace
+-- updaters.apply("backend.update.tex")
+-- -- adapt existing shortcuts to tex namespace
+ updaters.apply("backend.update")
+ --
+ pdfname = tex.jobname .. ".pdf"
+ openfile(pdfname)
+ --
+ luatex.registerstopactions(1,function()
+ if pdfname then
+ lpdf.finalizedocument()
+ closefile()
+ end
+ end)
+ --
+ luatex.registerpageactions(1,function()
+ if pdfname then
+ lpdf.finalizepage(true)
+ end
+ end)
+ -- --
+ lpdf.registerdocumentfinalizer(wrapup,nil,"wrapping up")
+ --
+ statistics.register("result saved in file", function()
+ local outputfilename = environment.outputfilename or environment.jobname or tex.jobname or ""
+ return string.format("%s.%s, compresslevel %s, objectcompresslevel %s",outputfilename,"pdf",lpdf.getcompression())
+ end)
+ --
+ end
+ converter = drivers.converters.lmtx
+ useddriver = driver
+ end
+
+ local function wrapup(driver)
+ if pdfname then
+ closefile()
+ pdfname = nil
+ end
+ end
+
+ local function cleanup(driver)
+ if pdfname then
+ closefile(pdfname)
+ pdfname = nil
+ end
+ end
+
+ local function convert(driver,boxnumber)
+ converter(driver,texgetbox(boxnumber),"page")
+ end
+
+ localconverter = function(...)
+ converter(useddriver,...)
+ end
+
+ drivers.install {
+ name = "pdf",
+ flushers = flushers,
+ actions = {
+ prepare = prepare,
+ wrapup = wrapup,
+ cleanup = cleanup,
+ --
+ initialize = initialize,
+ convert = convert,
+ finalize = finalize,
+ --
+ outputfilename = outputfilename,
+ },
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-mis.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-mis.lmt
new file mode 100644
index 00000000000..afb149d8af7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-mis.lmt
@@ -0,0 +1,639 @@
+if not modules then modules = { } end modules ['lpdf-mis'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Although we moved most pdf handling to the lua end, we didn't change
+-- the overall approach. For instance we share all resources i.e. we
+-- don't make subsets for each xform or page. The current approach is
+-- quite efficient. A big difference between MkII and MkIV is that we
+-- now use forward references. In this respect the MkII code shows that
+-- it evolved over a long period, when backends didn't provide forward
+-- referencing and references had to be tracked in multiple passes. Of
+-- course there are a couple of more changes.
+
+local next, tostring, type = next, tostring, type
+local format, gsub, formatters = string.format, string.gsub, string.formatters
+local concat, flattened = table.concat, table.flattened
+local settings_to_array = utilities.parsers.settings_to_array
+
+local backends, lpdf, nodes = backends, lpdf, nodes
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
+
+local getpagedimensions = layouts.getpagedimensions
+local getcanvas = layouts.getcanvas
+
+local nuts = nodes.nuts
+local copy_node = nuts.copy
+
+local nodepool = nuts.pool
+local setstate = nodepool.setstate
+local register = nodepool.register
+
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfverbose = lpdf.verbose
+local pdfstring = lpdf.string
+local pdfaction = lpdf.action
+
+local pdfflushobject
+local pdfflushstreamobject
+local pdfminorversion
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfflushstreamobject = lpdf.flushstreamobject
+ pdfminorversion = lpdf.minorversion
+end)
+
+local formattedtimestamp = lpdf.pdftimestamp
+local adddocumentextgstate = lpdf.adddocumentextgstate
+local addtocatalog = lpdf.addtocatalog
+local addtoinfo = lpdf.addtoinfo
+local addtopageattributes = lpdf.addtopageattributes
+local addtonames = lpdf.addtonames
+
+local pdfgetmetadata = lpdf.getmetadata
+
+local texset = tex.set
+
+local variables = interfaces.variables
+
+local v_stop = variables.stop
+local v_none = variables.none
+local v_max = variables.max
+local v_bookmark = variables.bookmark
+local v_fit = variables.fit
+local v_doublesided = variables.doublesided
+local v_singlesided = variables.singlesided
+local v_default = variables.default
+local v_auto = variables.auto
+local v_fixed = variables.fixed
+local v_landscape = variables.landscape
+local v_portrait = variables.portrait
+local v_page = variables.page
+local v_paper = variables.paper
+local v_attachment = variables.attachment
+local v_layer = variables.layer
+local v_lefttoright = variables.lefttoright
+local v_righttoleft = variables.righttoleft
+local v_title = variables.title
+local v_nomenubar = variables.nomenubar
+
+local positive = register(setstate("/GSpositive gs"))
+local negative = register(setstate("/GSnegative gs"))
+local overprint = register(setstate("/GSoverprint gs"))
+local knockout = register(setstate("/GSknockout gs"))
+
+local omitextraboxes = false
+
+directives.register("backend.omitextraboxes", function(v) omitextraboxes = v end)
+
+local function initializenegative()
+ local a = pdfarray { 0, 1 }
+ local g = pdfconstant("ExtGState")
+ local d = pdfdictionary {
+ FunctionType = 4,
+ Range = a,
+ Domain = a,
+ }
+ local negative = pdfdictionary { Type = g, TR = pdfreference(pdfflushstreamobject("{ 1 exch sub }",d)) } -- can be shared
+ local positive = pdfdictionary { Type = g, TR = pdfconstant("Identity") }
+ adddocumentextgstate("GSnegative", pdfreference(pdfflushobject(negative)))
+ adddocumentextgstate("GSpositive", pdfreference(pdfflushobject(positive)))
+ initializenegative = nil
+end
+
+local function initializeoverprint()
+ local g = pdfconstant("ExtGState")
+ local knockout = pdfdictionary { Type = g, OP = false, OPM = 0 }
+ local overprint = pdfdictionary { Type = g, OP = true, OPM = 1 }
+ adddocumentextgstate("GSknockout", pdfreference(pdfflushobject(knockout)))
+ adddocumentextgstate("GSoverprint", pdfreference(pdfflushobject(overprint)))
+ initializeoverprint = nil
+end
+
+function nodeinjections.overprint()
+ if initializeoverprint then initializeoverprint() end
+ return copy_node(overprint)
+end
+function nodeinjections.knockout ()
+ if initializeoverprint then initializeoverprint() end
+ return copy_node(knockout)
+end
+
+function nodeinjections.positive()
+ if initializenegative then initializenegative() end
+ return copy_node(positive)
+end
+function nodeinjections.negative()
+ if initializenegative then initializenegative() end
+ return copy_node(negative)
+end
+
+-- function codeinjections.addtransparencygroup()
+-- -- png: /CS /DeviceRGB /I true
+-- local d = pdfdictionary {
+-- S = pdfconstant("Transparency"),
+-- I = true,
+-- K = true,
+-- }
+-- lpdf.registerpagefinalizer(function() addtopageattributes("Group",d) end) -- hm
+-- end
+
+-- actions (todo: store and update when changed)
+
+local openpage, closepage, opendocument, closedocument
+
+function codeinjections.registerdocumentopenaction(open)
+ opendocument = open
+end
+
+function codeinjections.registerdocumentcloseaction(close)
+ closedocument = close
+end
+
+function codeinjections.registerpageopenaction(open)
+ openpage = open
+end
+
+function codeinjections.registerpagecloseaction(close)
+ closepage = close
+end
+
+local function flushdocumentactions()
+ if opendocument then
+ addtocatalog("OpenAction",pdfaction(opendocument))
+ end
+ if closedocument then
+ addtocatalog("CloseAction",pdfaction(closedocument))
+ end
+end
+
+local function flushpageactions()
+ if openpage or closepage then
+ local d = pdfdictionary()
+ if openpage then
+ d.O = pdfaction(openpage)
+ end
+ if closepage then
+ d.C = pdfaction(closepage)
+ end
+ addtopageattributes("AA",d)
+ end
+end
+
+lpdf.registerpagefinalizer (flushpageactions, "page actions")
+lpdf.registerdocumentfinalizer(flushdocumentactions,"document actions")
+
+--- info : this can change and move elsewhere
+
+local identity = { }
+
+function codeinjections.setupidentity(specification)
+ for k, v in next, specification do
+ if v ~= "" then
+ identity[k] = v
+ end
+ end
+end
+
+function codeinjections.getidentityvariable(name)
+ return identity[name]
+end
+
+local done = false -- using "setupidentity = function() end" fails as the meaning is frozen in register
+
+local function setupidentity()
+ if not done then
+ local metadata = pdfgetmetadata()
+ local creator = metadata.creator
+ local version = metadata.contextversion
+ local time = metadata.time
+ local jobname = environment.jobname or tex.jobname or "unknown"
+ --
+ local title = identity.title
+ if not title or title == "" then
+ title = tex.jobname
+ end
+ addtoinfo("Title", pdfunicode(title), title)
+ local subtitle = identity.subtitle or ""
+ if subtitle ~= "" then
+ addtoinfo("Subject", pdfunicode(subtitle), subtitle)
+ end
+ local author = identity.author or ""
+ if author ~= "" then
+ addtoinfo("Author", pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP
+ end
+ addtoinfo("Creator", pdfunicode(creator), creator)
+ addtoinfo("CreationDate", pdfstring(formattedtimestamp(time)))
+ local date = identity.date or ""
+ local pdfdate = date and formattedtimestamp(date)
+ if pdfdate then
+ addtoinfo("ModDate", pdfstring(pdfdate), date)
+ else
+ -- users should enter the date in 2010-01-19T23:27:50+01:00 format
+ -- and if not provided that way we use the creation time instead
+ addtoinfo("ModDate", pdfstring(formattedtimestamp(time)),time)
+ end
+ local keywords = identity.keywords or ""
+ if keywords ~= "" then
+ keywords = concat(settings_to_array(keywords), " ")
+ addtoinfo("Keywords", pdfunicode(keywords), keywords)
+ end
+ local id = lpdf.id()
+ addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
+ --
+ addtoinfo("ConTeXt.Version",version)
+ addtoinfo("ConTeXt.Time",os.date("%Y-%m-%d %H:%M"))
+ addtoinfo("ConTeXt.Jobname",jobname)
+ addtoinfo("ConTeXt.Url","www.pragma-ade.com")
+ addtoinfo("ConTeXt.Support","contextgarden.net")
+ addtoinfo("TeX.Support","tug.org")
+ --
+ done = true
+ else
+ -- no need for a message
+ end
+end
+
+lpdf.registerpagefinalizer(setupidentity,"identity")
+
+-- or when we want to be able to set things after pag e1:
+--
+-- lpdf.registerdocumentfinalizer(setupidentity,1,"identity")
+
+local function flushjavascripts()
+ local t = interactions.javascripts.flushpreambles()
+ if #t > 0 then
+ local a = pdfarray()
+ local pdf_javascript = pdfconstant("JavaScript")
+ for i=1,#t do
+ local ti = t[i]
+ local name = ti[1]
+ local script = ti[2]
+ local j = pdfdictionary {
+ S = pdf_javascript,
+ JS = pdfreference(pdfflushstreamobject(script)),
+ }
+ a[#a+1] = pdfstring(name)
+ a[#a+1] = pdfreference(pdfflushobject(j))
+ end
+ addtonames("JavaScript",pdfreference(pdfflushobject(pdfdictionary{ Names = a })))
+ end
+end
+
+lpdf.registerdocumentfinalizer(flushjavascripts,"javascripts")
+
+-- -- --
+
+local plusspecs = {
+ [v_max] = {
+ mode = "FullScreen",
+ },
+ [v_bookmark] = {
+ mode = "UseOutlines",
+ },
+ [v_attachment] = {
+ mode = "UseAttachments",
+ },
+ [v_layer] = {
+ mode = "UseOC",
+ },
+ [v_fit] = {
+ fit = true,
+ },
+ [v_doublesided] = {
+ layout = "TwoColumnRight",
+ },
+ [v_fixed] = {
+ fixed = true,
+ },
+ [v_landscape] = {
+ duplex = "DuplexFlipShortEdge",
+ },
+ [v_portrait] = {
+ duplex = "DuplexFlipLongEdge",
+ },
+ [v_page] = {
+ duplex = "Simplex" ,
+ },
+ [v_paper] = {
+ paper = true,
+ },
+ [v_title] ={
+ title = true,
+ },
+ [v_lefttoright] ={
+ direction = "L2R",
+ },
+ [v_righttoleft] ={
+ direction = "R2L",
+ },
+ [v_nomenubar] ={
+ nomenubar = true,
+ },
+}
+
+local pagespecs = {
+ --
+ [v_max] = plusspecs[v_max],
+ [v_bookmark] = plusspecs[v_bookmark],
+ [v_attachment] = plusspecs[v_attachment],
+ [v_layer] = plusspecs[v_layer],
+ [v_lefttoright] = plusspecs[v_lefttoright],
+ [v_righttoleft] = plusspecs[v_righttoleft],
+ [v_title] = plusspecs[v_title],
+ --
+ [v_none] = {
+ },
+ [v_fit] = {
+ mode = "UseNone",
+ fit = true,
+ },
+ [v_doublesided] = {
+ mode = "UseNone",
+ layout = "TwoColumnRight",
+ fit = true,
+ },
+ [v_singlesided] = {
+ mode = "UseNone"
+ },
+ [v_default] = {
+ mode = "UseNone",
+ layout = "auto",
+ },
+ [v_auto] = {
+ mode = "UseNone",
+ layout = "auto",
+ },
+ [v_fixed] = {
+ mode = "UseNone",
+ layout = "auto",
+ fixed = true, -- noscale
+ },
+ [v_landscape] = {
+ mode = "UseNone",
+ layout = "auto",
+ fixed = true,
+ duplex = "DuplexFlipShortEdge",
+ },
+ [v_portrait] = {
+ mode = "UseNone",
+ layout = "auto",
+ fixed = true,
+ duplex = "DuplexFlipLongEdge",
+ },
+ [v_page] = {
+ mode = "UseNone",
+ layout = "auto",
+ fixed = true,
+ duplex = "Simplex",
+ },
+ [v_paper] = {
+ mode = "UseNone",
+ layout = "auto",
+ fixed = true,
+ duplex = "Simplex",
+ paper = true,
+ },
+ [v_nomenubar] = {
+ mode = "UseNone",
+ layout = "auto",
+ nomenubar = true,
+ },
+}
+
+local function documentspecification()
+ local canvas = getcanvas()
+
+ -- move this to layo-ini ?
+
+ local pagespec = canvas.pagespec
+ if not pagespec or pagespec == "" then
+ pagespec = v_default
+ end
+ local settings = settings_to_array(pagespec)
+ -- so the first one detemines the defaults
+ local first = settings[1]
+ local defaults = pagespecs[first]
+ local spec = defaults or pagespecs[v_default]
+ -- successive keys can modify this
+ if spec.layout == "auto" then
+ if canvas.doublesided then
+ local s = pagespecs[v_doublesided] -- to be checked voor interfaces
+ for k, v in next, s do
+ spec[k] = v
+ end
+ else
+ spec.layout = false
+ end
+ end
+ -- we start at 2 when we have a valid first default set
+ for i=defaults and 2 or 1,#settings do
+ local s = plusspecs[settings[i]]
+ if s then
+ for k, v in next, s do
+ spec[k] = v
+ end
+ end
+ end
+
+ -- maybe interfaces.variables
+ local layout = spec.layout
+ local mode = spec.mode
+ local fit = spec.fit
+ local fixed = spec.fixed
+ local duplex = spec.duplex
+ local paper = spec.paper
+ local title = spec.title
+ local direction = spec.direction
+ local nomenubar = spec.nomenubar
+ if layout then
+ addtocatalog("PageLayout",pdfconstant(layout))
+ end
+ if mode then
+ addtocatalog("PageMode",pdfconstant(mode))
+ end
+ local prints = nil
+ local marked = canvas.marked
+ local copies = canvas.copies
+ if marked then
+ local pages = structures.pages
+ local marked = pages.allmarked(marked)
+ local nofmarked = marked and #marked or 0
+ if nofmarked > 0 then
+ -- the spec is wrong in saying that numbering starts at 1 which of course makes
+ -- sense as most real documents start with page 0 .. sigh
+ for i=1,#marked do marked[i] = marked[i] - 1 end
+ prints = pdfarray(flattened(pages.toranges(marked)))
+ end
+ end
+ if fit or fixed or duplex or copies or paper or prints or title or direction or nomenubar then
+ addtocatalog("ViewerPreferences",pdfdictionary {
+ FitWindow = fit and true or nil,
+ PrintScaling = fixed and pdfconstant("None") or nil,
+ Duplex = duplex and pdfconstant(duplex) or nil,
+ NumCopies = copies and copies or nil,
+ PickTrayByPDFSize = paper and true or nil,
+ PrintPageRange = prints or nil,
+ DisplayDocTitle = title and true or nil,
+ Direction = direction and pdfconstant(direction) or nil,
+ HideMenubar = nomenubar and true or nil,
+ })
+ end
+ addtoinfo ("Trapped", pdfconstant("False")) -- '/Trapped' in /Info, 'Trapped' in XMP
+ addtocatalog("Version", pdfconstant(format("1.%s",pdfminorversion())))
+ addtocatalog("Lang", pdfstring(tokens.getters.macro("currentmainlanguage")))
+end
+
+-- temp hack: the mediabox is not under our control and has a precision of 5 digits
+
+local factor = number.dimenfactors.bp
+local f_value = formatters["%.6N"]
+
+local function boxvalue(n) -- we could share them
+ return pdfverbose(f_value(factor * n))
+end
+
+local function pagespecification()
+ local canvas = getcanvas()
+ local paperwidth = canvas.paperwidth
+ local paperheight = canvas.paperheight
+ local leftoffset = canvas.leftoffset
+ local topoffset = canvas.topoffset
+ --
+ local llx = leftoffset
+ local urx = canvas.width - leftoffset
+ local lly = paperheight + topoffset - canvas.height
+ local ury = paperheight - topoffset
+ -- boxes can be cached
+ local function extrabox(WhatBox,offset,always)
+ if offset ~= 0 or always then
+ addtopageattributes(WhatBox, pdfarray {
+ boxvalue(llx + offset),
+ boxvalue(lly + offset),
+ boxvalue(urx - offset),
+ boxvalue(ury - offset),
+ })
+ end
+ end
+ if omitextraboxes then
+ -- only useful for testing / comparing
+ else
+ extrabox("CropBox",canvas.cropoffset,true) -- mandate for rendering
+ extrabox("TrimBox",canvas.trimoffset,true) -- mandate for pdf/x
+ extrabox("BleedBox",canvas.bleedoffset) -- optional
+ -- extrabox("ArtBox",canvas.artoffset) -- optional .. unclear what this is meant to do
+ end
+end
+
+lpdf.registerpagefinalizer(pagespecification,"page specification")
+lpdf.registerdocumentfinalizer(documentspecification,"document specification")
+
+-- Page Label support ...
+--
+-- In principle we can also support /P (prefix) as we can just use the verbose form
+-- and we can then forget about the /St (start) as we don't care about those few
+-- extra bytes due to lack of collapsing. Anyhow, for that we need a stupid prefix
+-- variant and that's not on the agenda now.
+
+local map = {
+ numbers = "D",
+ Romannumerals = "R",
+ romannumerals = "r",
+ Characters = "A",
+ characters = "a",
+}
+
+-- local function featurecreep()
+-- local pages, lastconversion, list = structures.pages.tobesaved, nil, pdfarray()
+-- local getstructureset = structures.sets.get
+-- for i=1,#pages do
+-- local p = pages[i]
+-- if not p then
+-- return -- fatal error
+-- else
+-- local numberdata = p.numberdata
+-- if numberdata then
+-- local conversionset = numberdata.conversionset
+-- if conversionset then
+-- local conversion = getstructureset("structure:conversions",p.block,conversionset,1,"numbers")
+-- if conversion ~= lastconversion then
+-- lastconversion = conversion
+-- list[#list+1] = i - 1 -- pdf starts numbering at 0
+-- list[#list+1] = pdfdictionary { S = pdfconstant(map[conversion] or map.numbers) }
+-- end
+-- end
+-- end
+-- if not lastconversion then
+-- lastconversion = "numbers"
+-- list[#list+1] = i - 1 -- pdf starts numbering at 0
+-- list[#list+1] = pdfdictionary { S = pdfconstant(map.numbers) }
+-- end
+-- end
+-- end
+-- addtocatalog("PageLabels", pdfdictionary { Nums = list })
+-- end
+
+local function featurecreep()
+ local pages = structures.pages.tobesaved
+ local list = pdfarray()
+ local getset = structures.sets.get
+ local stopped = false
+ local oldlabel = nil
+ local olconversion = nil
+ for i=1,#pages do
+ local p = pages[i]
+ if not p then
+ return -- fatal error
+ end
+ local label = p.viewerprefix or ""
+ if p.status == v_stop then
+ if not stopped then
+ list[#list+1] = i - 1 -- pdf starts numbering at 0
+ list[#list+1] = pdfdictionary {
+ P = pdfunicode(label),
+ }
+ stopped = true
+ end
+ oldlabel = nil
+ oldconversion = nil
+ stopped = false
+ else
+ local numberdata = p.numberdata
+ local conversion = nil
+ local number = p.number
+ if numberdata then
+ local conversionset = numberdata.conversionset
+ if conversionset then
+ conversion = getset("structure:conversions",p.block,conversionset,1,"numbers")
+ end
+ end
+ conversion = conversion and map[conversion] or map.numbers
+ if number == 1 or oldlabel ~= label or oldconversion ~= conversion then
+ list[#list+1] = i - 1 -- pdf starts numbering at 0
+ list[#list+1] = pdfdictionary {
+ S = pdfconstant(conversion),
+ St = number,
+ P = label ~= "" and pdfunicode(label) or nil,
+ }
+ end
+ oldlabel = label
+ oldconversion = conversion
+ stopped = false
+ end
+ end
+ addtocatalog("PageLabels", pdfdictionary { Nums = list })
+end
+
+lpdf.registerdocumentfinalizer(featurecreep,"featurecreep")
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-mov.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-mov.lmt
new file mode 100644
index 00000000000..42ba6fb008f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-mov.lmt
@@ -0,0 +1,68 @@
+if not modules then modules = { } end modules ['lpdf-mov'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format = string.format
+
+local lpdf = lpdf
+local context = context
+
+local nodeinjections = backends.pdf.nodeinjections
+local pdfconstant = lpdf.constant
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfborder = lpdf.border
+local write_node = node.write
+
+function nodeinjections.insertmovie(specification)
+ -- managed in figure inclusion: width, height, factor, repeat, controls, preview, label, foundname
+ local width = specification.width
+ local height = specification.height
+ local factor = specification.factor or number.dimenfactors.bp
+ local moviedict = pdfdictionary {
+ F = specification.foundname,
+ Aspect = pdfarray { factor * width, factor * height },
+ Poster = (specification.preview and true) or false,
+ }
+ local controldict = pdfdictionary {
+ ShowControls = (specification.controls and true) or false,
+ Mode = (specification["repeat"] and pdfconstant("Repeat")) or nil,
+ }
+ local bs, bc = pdfborder()
+ local action = pdfdictionary {
+ Subtype = pdfconstant("Movie"),
+ Border = bs,
+ C = bc,
+ T = format("movie %s",specification.label),
+ Movie = moviedict,
+ A = controldict,
+ }
+ write_node(nodeinjections.annotation(width,height,0,action())) -- test: context(...)
+end
+
+function nodeinjections.insertsound(specification)
+ -- managed in interaction: repeat, label, foundname
+ local soundclip = interactions.soundclips.soundclip(specification.label)
+ if soundclip then
+ local controldict = pdfdictionary {
+ Mode = (specification["repeat"] and pdfconstant("Repeat")) or nil
+ }
+ local sounddict = pdfdictionary {
+ F = soundclip.filename
+ }
+ local bs, bc = pdfborder()
+ local action = pdfdictionary {
+ Subtype = pdfconstant("Movie"),
+ Border = bs,
+ C = bc,
+ T = format("sound %s",specification.label),
+ Movie = sounddict,
+ A = controldict,
+ }
+ write_node(nodeinjections.annotation(0,0,0,action())) -- test: context(...)
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-pde.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-pde.lmt
new file mode 100644
index 00000000000..7fb14ada262
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-pde.lmt
@@ -0,0 +1,1211 @@
+if not modules then modules = { } end modules ['lpdf-epd'] = {
+ version = 1.001,
+ comment = "companion to lpdf-epa.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+ history = "this one replaces the poppler/pdfe binding",
+}
+
+-- \enabledirectives[graphics.pdf.uselua]
+-- \enabledirectives[graphics.pdf.recompress]
+-- \enabledirectives[graphics.pdf.stripmarked]
+
+-- maximum integer : +2^32
+-- maximum real : +2^15
+-- minimum real : 1/(2^16)
+
+-- get_flagged : does that still work
+
+-- ppdoc_permissions (ppdoc *pdf);
+
+-- PPSTRING_ENCODED 1 << 0
+-- PPSTRING_DECODED 1 << 1
+-- PPSTRING_EXEC 1 << 2 postscript only
+-- PPSTRING_PLAIN 0
+-- PPSTRING_BASE16 1 << 3
+-- PPSTRING_BASE85 1 << 4
+-- PPSTRING_UTF16BE 1 << 5
+-- PPSTRING_UTF16LE 1 << 6
+
+-- PPDOC_ALLOW_PRINT 1 << 2 printing
+-- PPDOC_ALLOW_MODIFY 1 << 3 filling form fields, signing, creating template pages
+-- PPDOC_ALLOW_COPY 1 << 4 copying, copying for accessibility
+-- PPDOC_ALLOW_ANNOTS 1 << 5 filling form fields, copying, signing
+-- PPDOC_ALLOW_EXTRACT 1 << 9 contents copying for accessibility
+-- PPDOC_ALLOW_ASSEMBLY 1 << 10 no effect
+-- PPDOC_ALLOW_PRINT_HIRES 1 << 11 no effect
+
+-- PPCRYPT_NONE 0 no encryption, go ahead
+-- PPCRYPT_DONE 1 encryption present but password succeeded, go ahead
+-- PPCRYPT_PASS -1 encryption present, need non-empty password
+-- PPCRYPT_FAIL -2 invalid or unsupported encryption (eg. undocumented in pdf spec)
+
+local setmetatable, type, next = setmetatable, type, next
+local tostring, tonumber, unpack = tostring, tonumber, unpack
+local char, byte, find = string.char, string.byte, string.find
+local abs = math.abs
+local concat, swapped, sortedhash, sortedkeys = table.concat, table.swapped, table.sortedhash, table.sortedkeys
+local utfchar = string.char
+local setmetatableindex = table.setmetatableindex
+local ioopen = io.open
+
+local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local P, C, S, R, Ct, Cc, V, Carg, Cs, Cf, Cg = lpeg.P, lpeg.C, lpeg.S, lpeg.R, lpeg.Ct, lpeg.Cc, lpeg.V, lpeg.Carg, lpeg.Cs, lpeg.Cf, lpeg.Cg
+
+if not lpdf then
+ require("lpdf-aux")
+end
+
+if not (number and number.dimenfactors) then
+ require("util-dim")
+end
+
+local pdfe = pdfe
+ lpdf = lpdf or { }
+local lpdf = lpdf
+local lpdf_epdf = { }
+ lpdf.epdf = lpdf_epdf
+
+local pdfopen = pdfe.open
+local pdfopenfile = pdfe.openfile
+local pdfnew = pdfe.new
+local pdfclose = pdfe.close
+
+local getcatalog = pdfe.getcatalog
+local getinfo = pdfe.getinfo
+local gettrailer = pdfe.gettrailer
+local getnofpages = pdfe.getnofpages
+local getversion = pdfe.getversion
+local getbox = pdfe.getbox
+local getstatus = pdfe.getstatus
+local unencrypt = pdfe.unencrypt
+
+local dictionarytotable = pdfe.dictionarytotable
+local arraytotable = pdfe.arraytotable
+local pagestotable = pdfe.pagestotable
+local readwholestream = pdfe.readwholestream
+
+local getfromreference = pdfe.getfromreference
+
+local report_epdf = logs.reporter("epdf")
+
+local allocate = utilities.storage.allocate
+
+local bpfactor = number.dimenfactors.bp
+
+local objectcodes = { [0] =
+ "none",
+ "null",
+ "bool",
+ "integer",
+ "number",
+ "name",
+ "string",
+ "array",
+ "dictionary",
+ "stream",
+ "reference",
+}
+
+local encryptioncodes = {
+ [0] = "notencrypted",
+ [1] = "unencrypted",
+ [-1] = "protected",
+ [-2] = "failure",
+}
+
+objectcodes = allocate(swapped(objectcodes,objectcodes))
+encryptioncodes = allocate(swapped(encryptioncodes,encryptioncodes))
+
+pdfe.objectcodes = objectcodes
+pdfe.encryptioncodes = encryptioncodes
+
+local null_object_code = objectcodes.null
+local reference_object_code = objectcodes.reference
+
+local none_object_code = objectcodes.none
+local null_object_code = objectcodes.null
+local bool_object_code = objectcodes.bool
+local integer_object_code = objectcodes.integer
+local number_object_code = objectcodes.number
+local name_object_code = objectcodes.name
+local string_object_code = objectcodes.string
+local array_object_code = objectcodes.array
+local dictionary_object_code = objectcodes.dictionary
+local stream_object_code = objectcodes.stream
+local reference_object_code = objectcodes.reference
+
+local checked_access
+local get_flagged -- from pdfe -> lpdf
+
+if lpdf.dictionary then
+
+ -- we're in context
+
+ local pdfdictionary = lpdf.dictionary
+ local pdfarray = lpdf.array
+ local pdfconstant = lpdf.constant
+ local pdfstring = lpdf.string
+ local pdfunicode = lpdf.unicode
+
+ get_flagged = function(t,f,k)
+ local tk = t[k] -- triggers resolve
+ local fk = f[k]
+ if not fk then
+ return tk
+ elseif fk == "name" then
+ return pdfconstant(tk)
+ elseif fk == "array" then
+ return pdfarray(tk)
+ elseif fk == "dictionary" then
+ return pdfarray(tk)
+ elseif fk == "rawtext" then
+ return pdfstring(tk)
+ elseif fk == "unicode" then
+ return pdfunicode(tk)
+ else
+ return tk
+ end
+ end
+
+else
+
+ get_flagged = function(t,f,k)
+ return t[k]
+ end
+
+end
+
+-- We need to convert the string from utf16 although there is no way to
+-- check if we have a regular string starting with a bom. So, we have
+-- na dilemma here: a pdf doc encoded string can be invalid utf.
+
+-- : implicit 0 appended if odd
+-- (byte encoded) : \( \) \\ escaped
+--
+-- : utf16be
+--
+-- \r \r \t \b \f \( \) \\ \NNN and \ : append next line
+--
+-- the getString function gives back bytes so we don't need to worry about
+-- the hex aspect.
+
+local some_dictionary
+local some_array
+local some_stream
+local some_reference
+
+local some_string = lpdf.frombytes
+
+local function get_value(document,t,key)
+ if not key then
+ return
+ end
+ local value = t[key]
+ if not value then
+ return
+ end
+ if type(value) ~= "table" then
+ return value
+ end
+ -- we can assume names to be simple and strings to be tables
+ local kind = value[1]
+ if kind == name_object_code then
+ return value[2]
+ elseif kind == string_object_code then
+ return some_string(value[2],value[3])
+ elseif kind == array_object_code then
+ return some_array(value[2],document)
+ elseif kind == dictionary_object_code then
+ return some_dictionary(value[2],document)
+ elseif kind == stream_object_code then
+ return some_stream(value,document)
+ elseif kind == reference_object_code then
+ return some_reference(value,document)
+ end
+ return value
+end
+
+some_dictionary = function (d,document)
+ local f = dictionarytotable(d,true)
+ local t = setmetatable({ __raw__ = f, __type__ = dictionary_object_code }, {
+ __index = function(t,k)
+ return get_value(document,f,k)
+ end,
+ __call = function(t,k)
+ return get_flagged(t,f,k)
+ end,
+ } )
+ return t, "dictionary"
+end
+
+some_array = function (a,document)
+ local f = arraytotable(a,true)
+ local n = #f
+ local t = setmetatable({ __raw__ = f, __type__ = array_object_code, n = n }, {
+ __index = function(t,k)
+ return get_value(document,f,k)
+ end,
+ __call = function(t,k)
+ return get_flagged(t,f,k)
+ end,
+ __len = function(t,k)
+ return n
+ end,
+ } )
+ return t, "array"
+end
+
+some_stream = function(s,d,document)
+ local f = dictionarytotable(d,true)
+ local t = setmetatable({ __raw__ = f, __type__ = stream_object_code }, {
+ __index = function(t,k)
+ return get_value(document,f,k)
+ end,
+ __call = function(t,raw)
+ if raw == false then
+ return readwholestream(s,false) -- original
+ else
+ return readwholestream(s,true) -- uncompressed
+ end
+ end,
+ } )
+ return t, "stream"
+end
+
+some_reference = function(r,document)
+ local objnum = r[3]
+ local cached = document.__cache__[objnum]
+ if not cached then
+ local kind, object, b, c = getfromreference(r[2])
+ if kind == dictionary_object_code then
+ cached = some_dictionary(object,document)
+ elseif kind == array_object_code then
+ cached = some_array(object,document)
+ elseif kind == stream_object_code then
+ cached = some_stream(object,b,document)
+ else
+ cached = { kind, object, b, c }
+ -- really cache this?
+ end
+ document.__cache__[objnum] = cached
+ document.__xrefs__[cached] = objnum
+ end
+ return cached
+end
+
+local resolvers = { }
+lpdf_epdf.resolvers = resolvers
+
+local function resolve(document,k)
+ local resolver = resolvers[k]
+ if resolver then
+ local entry = resolver(document)
+ document[k] = entry
+ return entry
+ end
+end
+
+local function getnames(document,n,target) -- direct
+ if n then
+ local Names = n.Names
+ if Names then
+ if not target then
+ target = { }
+ end
+ for i=1,#Names,2 do
+ target[Names[i]] = Names[i+1]
+ end
+ else
+ local Kids = n.Kids
+ if Kids then
+ for i=1,#Kids do
+ target = getnames(document,Kids[i],target)
+ end
+ end
+ end
+ return target
+ end
+end
+
+local function getkids(document,n,target) -- direct
+ if n then
+ local Kids = n.Kids
+ if Kids then
+ for i=1,#Kids do
+ target = getkids(document,Kids[i],target)
+ end
+ elseif target then
+ target[#target+1] = n
+ else
+ target = { n }
+ end
+ return target
+ end
+end
+
+function resolvers.destinations(document)
+ local Names = document.Catalog.Names
+ return getnames(document,Names and Names.Dests)
+end
+
+function resolvers.javascripts(document)
+ local Names = document.Catalog.Names
+ return getnames(document,Names and Names.JavaScript)
+end
+
+function resolvers.widgets(document)
+ local Names = document.Catalog.AcroForm
+ return Names and Names.Fields
+end
+
+function resolvers.embeddedfiles(document)
+ local Names = document.Catalog.Names
+ return getnames(document,Names and Names.EmbeddedFiles)
+end
+
+-- /OCProperties <<
+-- /OCGs [ 15 0 R 17 0 R 19 0 R 21 0 R 23 0 R 25 0 R 27 0 R ]
+-- /D <<
+-- /Order [ 15 0 R 17 0 R 19 0 R 21 0 R 23 0 R 25 0 R 27 0 R ]
+-- /ON [ 15 0 R 17 0 R 19 0 R 21 0 R 23 0 R 25 0 R 27 0 R ]
+-- /OFF [ ]
+-- >>
+-- >>
+
+function resolvers.layers(document)
+ local properties = document.Catalog.OCProperties
+ if properties then
+ local layers = properties.OCGs
+ if layers then
+ local t = { }
+ for i=1,#layers do
+ local layer = layers[i]
+ t[i] = layer.Name
+ end
+ -- t.n = n
+ return t
+ end
+ end
+end
+
+function resolvers.structure(document)
+ -- this might become a tree
+ return document.Catalog.StructTreeRoot
+end
+
+function resolvers.pages(document)
+ local __data__ = document.__data__
+ local __xrefs__ = document.__xrefs__
+ local __cache__ = document.__cache__
+ --
+ local nofpages = document.nofpages
+ local pages = { }
+ local rawpages = pagestotable(__data__)
+ document.pages = pages
+ --
+ for pagenumber=1,nofpages do
+ local rawpagedata = rawpages[pagenumber]
+ if rawpagedata then
+ local pagereference = rawpagedata[3]
+ local pageobject = rawpagedata[1]
+ local pagedata = some_dictionary(pageobject,document)
+ if pagedata and pageobject then
+ pagedata.number = pagenumber
+ pagedata.MediaBox = getbox(pageobject,"MediaBox")
+ pagedata.CropBox = getbox(pageobject,"CropBox")
+ pagedata.BleedBox = getbox(pageobject,"BleedBox")
+ pagedata.ArtBox = getbox(pageobject,"ArtBox")
+ pagedata.TrimBox = getbox(pageobject,"TrimBox")
+ pages[pagenumber] = pagedata
+ __xrefs__[pagedata] = pagereference
+ __cache__[pagereference] = pagedata
+ else
+ report_epdf("missing pagedata for page %i, case %i",pagenumber,1)
+ end
+ else
+ report_epdf("missing pagedata for page %i, case %i",pagenumber,2)
+ end
+ end
+ --
+ -- pages.n = nofpages
+ --
+ return pages
+end
+
+local loaded = { }
+local nofloaded = 0
+
+function lpdf_epdf.load(filename,userpassword,ownerpassword,fromstring)
+ local document = loaded[filename]
+ if not document then
+ statistics.starttiming(lpdf_epdf)
+ local __data__
+ local __file__
+ if fromstring then
+ __data__ = pdfnew(filename,#filename)
+ elseif pdfopenfile then
+ __data__ = pdfopenfile(ioopen(filename,"rb"))
+ else
+ __data__ = pdfopen(filename)
+ end
+ if __data__ then
+ if userpassword and getstatus(__data__) < 0 then
+ unencrypt(__data__,userpassword,nil)
+ end
+ if ownerpassword and getstatus(__data__) < 0 then
+ unencrypt(__data__,nil,ownerpassword)
+ end
+ if getstatus(__data__) < 0 then
+ report_epdf("the document is encrypted, provide proper passwords",getstatus(__data__))
+ __data__ = false
+ end
+ if __data__ then
+ document = {
+ filename = filename,
+ nofcopied = 0,
+ copied = { },
+ __cache__ = { },
+ __xrefs__ = { },
+ __fonts__ = { },
+ __copied__ = { },
+ __data__ = __data__,
+ }
+ document.Catalog = some_dictionary(getcatalog(__data__),document)
+ document.Info = some_dictionary(getinfo(__data__),document)
+ document.Trailer = some_dictionary(gettrailer(__data__),document)
+ --
+ setmetatableindex(document,resolve)
+ --
+ document.majorversion, document.minorversion = getversion(__data__)
+ --
+ document.nofpages = getnofpages(__data__)
+ else
+ document = false
+ end
+ else
+ document = false
+ end
+ loaded[filename] = document
+ loaded[document] = document
+ statistics.stoptiming(lpdf_epdf)
+ -- print(statistics.elapsedtime(lpdf_epdf))
+ end
+ if document then
+ nofloaded = nofloaded + 1
+ end
+ return document or nil
+end
+
+function lpdf_epdf.unload(filename)
+ if type(filename) == "table" then
+ filename = filename.filename
+ end
+ if type(filename) == "string" then
+ local document = loaded[filename]
+ if document then
+ loaded[document] = nil
+ loaded[filename] = nil
+ pdfclose(document.__data__)
+ end
+ end
+end
+
+-- for k, v in expanded(t) do
+
+local function expanded(t)
+ local function iterator(raw,k)
+ local k, v = next(raw,k)
+ if v then
+ return k, t[k]
+ end
+ end
+ return iterator, t.__raw__, nil
+end
+
+---------.expand = expand
+lpdf_epdf.expanded = expanded
+
+-- we could resolve the text stream in one pass if we directly handle the
+-- font but why should we complicate things
+
+local spaces = lpegpatterns.whitespace^1
+local optspaces = lpegpatterns.whitespace^0
+local comment = P("%") * (1 - lpegpatterns.newline)^0
+local numchar = P("\\")/"" * (R("09")^3/function(s) return char(tonumber(s,8)) end)
+ + P("\\") * P(1)
+local key = P("/") * C(R("AZ","az","09","__")^1)
+local number = Ct(Cc("number") * (lpegpatterns.number/tonumber))
+local keyword = Ct(Cc("name") * key)
+local operator = C((R("AZ","az")+P("*")+P("'")+P('"'))^1)
+
+local grammar = P { "start",
+ start = (comment + keyword + number + V("dictionary") + V("array") + V("hexstring") + V("decstring") + spaces)^1,
+ keyvalue = key * optspaces * V("start"),
+ array = Ct(Cc("array") * P("[") * Ct(V("start")^1) * P("]")),
+ dictionary = Ct(Cc("dict") * P("<<") * Ct(V("keyvalue")^1) * P(">>")),
+ hexstring = Ct(Cc("hex") * P("<") * Cs(( 1-P(">"))^1) * P(">")),
+ decstring = Ct(Cc("dec") * P("(") * Cs((numchar+1-(P")"))^1) * P(")")), -- untested
+}
+
+local operation = Ct(grammar^1 * operator)
+local parser = Ct((operation + P(1))^1)
+
+-- todo: speed this one up
+
+local numchar = P("\\") * (R("09")^3 + P(1))
+local number = lpegpatterns.number
+local keyword = P("/") * R("AZ","az","09","__")^1
+local operator = (R("AZ","az")+P("*")+P("'")+P('"'))^1
+
+local skipstart = P("BDC") + P("BMC") + P("DP") + P("MP")
+local skipstop = P("EMC")
+local skipkeep = P("/ActualText")
+
+local grammar = P { "skip",
+ start = keyword + number + V("dictionary") + V("array") + V("hexstring") + V("decstring") + spaces,
+ keyvalue = optspaces * (keyword * optspaces * V("start") * optspaces)^1,
+ xeyvalue = optspaces * ((keyword - skipkeep) * optspaces * V("start") * optspaces)^1,
+ array = P("[") * V("start")^0 * P("]"),
+ dictionary = P("<<") * V("keyvalue")^0 * P(">>"),
+ xictionary = P("<<") * V("xeyvalue")^0 * P(">>"),
+ hexstring = P("<") * ( 1-P(">"))^0 * P(">"),
+ decstring = P("(") * (numchar+1-(P")"))^0 * P(")"),
+ skip = (optspaces * ( keyword * optspaces * V("xictionary") * optspaces * skipstart + skipstop) / "")
+ + V("start")
+ + operator
+}
+
+local stripper = Cs((grammar + P(1))^1)
+
+function lpdf_epdf.parsecontent(str)
+ return lpegmatch(parser,str)
+end
+
+function lpdf_epdf.stripcontent(str)
+ if find(str,"EMC") then
+ return lpegmatch(stripper,str)
+ else
+ return str
+ end
+end
+
+-- beginbfrange :
+-- [ ]
+-- beginbfchar :
+
+local fromsixteen = lpdf.fromsixteen -- maybe inline the lpeg ... but not worth it
+
+local function f_bfchar(t,a,b)
+ t[tonumber(a,16)] = fromsixteen(b)
+end
+
+local function f_bfrange_1(t,a,b,c)
+ print("todo 1",a,b,c)
+ -- c is string
+ -- todo t[tonumber(a,16)] = fromsixteen(b)
+end
+
+local function f_bfrange_2(t,a,b,c)
+ print("todo 2",a,b,c)
+ -- c is table
+ -- todo t[tonumber(a,16)] = fromsixteen(b)
+end
+
+local optionals = spaces^0
+local hexstring = optionals * P("<") * C((1-P(">"))^1) * P(">")
+local bfchar = Carg(1) * hexstring * hexstring / f_bfchar
+local bfrange = Carg(1) * hexstring * hexstring * hexstring / f_bfrange_1
+ + Carg(1) * hexstring * hexstring * optionals * P("[") * Ct(hexstring^1) * optionals * P("]") / f_bfrange_2
+local fromunicode = (
+ P("beginbfchar" ) * bfchar ^1 * optionals * P("endbfchar" ) +
+ P("beginbfrange") * bfrange^1 * optionals * P("endbfrange") +
+ spaces +
+ P(1)
+)^1 * Carg(1)
+
+local function analyzefonts(document,resources) -- unfinished, see mtx-pdf for better code
+ local fonts = document.__fonts__
+ if resources then
+ local fontlist = resources.Font
+ if fontlist then
+ for id, data in expanded(fontlist) do
+ if not fonts[id] then
+ -- a quick hack ... I will look into it more detail if I find a real
+ -- -application for it
+ local tounicode = data.ToUnicode()
+ if tounicode then
+ tounicode = lpegmatch(fromunicode,tounicode,1,{})
+ end
+ fonts[id] = {
+ tounicode = type(tounicode) == "table" and tounicode or { }
+ }
+ setmetatableindex(fonts[id],"self")
+ end
+ end
+ end
+ end
+ return fonts
+end
+
+lpdf_epdf.analyzefonts = analyzefonts
+
+local more = 0
+local unic = nil -- cheaper than passing each time as Carg(1)
+
+local p_hex_to_utf = C(4) / function(s) -- needs checking !
+ local now = tonumber(s,16)
+ if more > 0 then
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+ more = 0
+ return unic[now] or utfchar(now)
+ elseif now >= 0xD800 and now <= 0xDBFF then
+ more = now
+ -- return ""
+ else
+ return unic[now] or utfchar(now)
+ end
+end
+
+local p_dec_to_utf = C(1) / function(s) -- needs checking !
+ local now = byte(s)
+ return unic[now] or utfchar(now)
+end
+
+local p_hex_to_utf = P(true) / function() more = 0 end * Cs(p_hex_to_utf^1)
+local p_dec_to_utf = P(true) / function() more = 0 end * Cs(p_dec_to_utf^1)
+
+function lpdf_epdf.getpagecontent(document,pagenumber)
+
+ local page = document.pages[pagenumber]
+
+ if not page then
+ return
+ end
+
+ local fonts = analyzefonts(document,page.Resources)
+
+ local content = page.Contents() or ""
+ local list = lpegmatch(parser,content)
+ local font = nil
+ -- local unic = nil
+
+ for i=1,#list do
+ local entry = list[i]
+ local size = #entry
+ local operator = entry[size]
+ if operator == "Tf" then
+ font = fonts[entry[1][2]]
+ unic = font and font.tounicode or { }
+ elseif operator == "TJ" then
+ local data = entry[1] -- { "array", { ... } }
+ local list = data[2] -- { { ... }, { ... } }
+ for i=1,#list do
+ local li = list[i]
+-- if type(li) == "table" then
+ local kind = li[1]
+ if kind == "hex" then
+ list[i] = lpegmatch(p_hex_to_utf,li[2])
+ elseif kind == "string" then
+ list[i] = lpegmatch(p_dec_to_utf,li[2])
+ else
+ list[i] = li[2] -- kern
+ end
+-- else
+-- -- kern
+-- end
+ end
+ elseif operator == "Tj" or operator == "'" or operator == '"' then
+ -- { string, Tj } { string, ' } { n, m, string, " }
+ local data = entry[size-1]
+ local list = data[2]
+ local kind = list[1]
+ if kind == "hex" then
+ list[2] = lpegmatch(p_hex_to_utf,li[2])
+ elseif kind == "string" then
+ list[2] = lpegmatch(p_dec_to_utf,li[2])
+ end
+ end
+ end
+
+ unic = nil -- can be collected
+
+ return list
+
+end
+
+-- This is also an experiment. When I really need it I can improve it, for instance
+-- with proper position calculating. It might be usefull for some search or so.
+
+local softhyphen = utfchar(0xAD) .. "$"
+local linefactor = 1.3
+
+function lpdf_epdf.contenttotext(document,list) -- maybe signal fonts
+ local last_y = 0
+ local last_f = 0
+ local text = { }
+ local last = 0
+
+ for i=1,#list do
+ local entry = list[i]
+ local size = #entry
+ local operator = entry[size]
+ if operator == "Tf" then
+ last_f = entry[2][2] -- size
+ elseif operator == "TJ" then
+ local data = entry[1] -- { "array", { ... } }
+ local list = data[2] -- { { ... }, { ... } }
+ for i=1,#list do
+ local li = list[i]
+ local kind = type(li)
+ if kind == "string" then
+ last = last + 1
+ text[last] = li
+ elseif kind == "number" and li < -50 then
+ last = last + 1
+ text[last] = " "
+ end
+ end
+ elseif operator == "Tj" then
+ last = last + 1
+ local li = entry[size-1]
+ local kind = type(li)
+ if kind == "string" then
+ last = last + 1
+ text[last] = li
+ end
+ elseif operator == "cm" or operator == "Tm" then
+ local data = entry
+ local ty = entry[6][2]
+ local dy = abs(last_y - ty)
+ if dy > linefactor*last_f then
+ if last > 0 then
+ if find(text[last],softhyphen,1,true) then
+ -- ignore
+ else
+ last = last + 1
+ text[last] = "\n"
+ end
+ end
+ end
+ last_y = ty
+ end
+ end
+
+ return concat(text)
+end
+
+function lpdf_epdf.getstructure(document,list) -- just a test
+ local depth = 0
+ for i=1,#list do
+ local entry = list[i]
+ local size = #entry
+ local operator = entry[size]
+ if operator == "BDC" then
+ report_epdf("%w%s : %s",depth,entry[1] or "?",entry[2] and entry[2].MCID or "?")
+ depth = depth + 1
+ elseif operator == "EMC" then
+ depth = depth - 1
+ elseif operator == "TJ" then
+ local list = entry[1]
+ for i=1,#list do
+ local li = list[i]
+ if type(li) == "string" then
+ report_epdf("%w > %s",depth,li)
+ elseif li < -50 then
+ report_epdf("%w >",depth,li)
+ end
+ end
+ elseif operator == "Tj" then
+ report_epdf("%w > %s",depth,entry[size-1])
+ end
+ end
+end
+
+if images then do
+
+ -- This can be made a bit faster (just get raw data and pass it) but I will
+ -- do that later. In the end the benefit is probably neglectable.
+
+ local recompress = false
+ local stripmarked = false
+
+ local copydictionary = nil
+ local copyarray = nil
+
+ local pdfreference = lpdf.reference
+ local pdfconstant = lpdf.constant
+ local pdfarray = lpdf.array
+ local pdfdictionary = lpdf.dictionary
+ local pdfnull = lpdf.null
+ local pdfliteral = lpdf.literal
+
+ local pdfreserveobject
+ local shareobjectreference
+ local pdfflushobject
+ local pdfflushstreamobject
+
+ updaters.register("backend.update.lpdf",function()
+ pdfreserveobject = lpdf.reserveobject
+ shareobjectreference = lpdf.shareobjectreference
+ pdfflushobject = lpdf.flushobject
+ pdfflushstreamobject = lpdf.flushstreamobject
+ end)
+
+ local report = logs.reporter("backend","xobjects")
+
+ local factor = 65536 / (7200/7227) -- 1/number.dimenfactors.bp
+
+ local createimage = images.create
+
+ directives.register("graphics.pdf.recompress", function(v) recompress = v end)
+ directives.register("graphics.pdf.stripmarked", function(v) stripmarked = v end)
+
+ local function scaledbbox(b)
+ return { b[1]*factor, b[2]*factor, b[3]*factor, b[4]*factor }
+ end
+
+ local codecs = {
+ ASCIIHexDecode = true,
+ ASCII85Decode = true,
+ RunLengthDecode = true,
+ FlateDecode = true,
+ LZWDecode = true,
+ }
+
+ local function deepcopyobject(xref,copied,value)
+ -- no need for tables, just nested loop with obj
+ local objnum = xref[value]
+ if objnum then
+ local usednum = copied[objnum]
+ if usednum then
+ -- report("%s object %i is reused",kind,objnum)
+ else
+ usednum = pdfreserveobject()
+ copied[objnum] = usednum
+ local entry = value
+ local kind = entry.__type__
+ if kind == array_object_code then
+ local a = copyarray(xref,copied,entry)
+ pdfflushobject(usednum,tostring(a))
+ elseif kind == dictionary_object_code then
+ local d = copydictionary(xref,copied,entry)
+ pdfflushobject(usednum,tostring(d))
+ elseif kind == stream_object_code then
+ local d = copydictionary(xref,copied,entry)
+ local filter = d.Filter
+ if filter and codecs[filter] and recompress then
+ -- recompress
+ d.Filter = nil
+ d.Length = nil
+ d.DecodeParms = nil -- relates to filter
+ d.DL = nil -- needed?
+ local s = entry() -- get uncompressed stream
+ pdfflushstreamobject(s,d,true,usednum) -- compress stream
+ else
+ -- keep as-is, even Length which indicates the
+ -- decompressed length
+ local s = entry(false) -- get compressed stream
+ -- pdfflushstreamobject(s,d,false,usednum,true) -- don't compress stream
+ pdfflushstreamobject(s,d,"raw",usednum) -- don't compress stream
+ end
+ else
+ local t = type(value)
+ if t == "string" then
+ value = pdfconstant(value)
+ elseif t == "table" then
+ local kind = value[1]
+ local entry = value[2]
+ if kind == name_object_code then
+ value = pdfconstant(entry)
+ elseif kind == string_object_code then
+ value = pdfliteral(entry,value[3])
+ elseif kind == null_object_code then
+ value = pdfnull()
+ elseif kind == reference_object_code then
+ value = deepcopyobject(xref,copied,entry)
+ elseif entry == nil then
+ value = pdfnull()
+ else
+ value = tostring(entry)
+ end
+ end
+ pdfflushobject(usednum,value)
+ end
+ end
+ return pdfreference(usednum)
+ elseif kind == stream_object_code then
+ report("stream not done: %s", objectcodes[kind] or "?")
+ else
+ report("object not done: %s", objectcodes[kind] or "?")
+ end
+ end
+
+ local function copyobject(xref,copied,object,key,value)
+ if not value then
+ value = object.__raw__[key]
+ end
+ local t = type(value)
+ if t == "string" then
+ return pdfconstant(value)
+ elseif t ~= "table" then
+ return value
+ end
+ local kind = value[1]
+ if kind == name_object_code then
+ return pdfconstant(value[2])
+ elseif kind == string_object_code then
+ return pdfliteral(value[2],value[3])
+ elseif kind == array_object_code then
+ return copyarray(xref,copied,object[key])
+ elseif kind == dictionary_object_code then
+ return copydictionary(xref,copied,object[key])
+ elseif kind == null_object_code then
+ return pdfnull()
+ elseif kind == reference_object_code then
+ -- expand
+ return deepcopyobject(xref,copied,object[key])
+ else
+ report("weird: %s", objecttypes[kind] or "?")
+ end
+ end
+
+ copyarray = function (xref,copied,object)
+ local target = pdfarray()
+ local source = object.__raw__
+ for i=1,#source do
+ target[i] = copyobject(xref,copied,object,i,source[i])
+ end
+ return target
+ end
+
+ local plugins = nil
+
+ -- Sorting the hash slows down upto 5% bit but it is still as fast as the C
+ -- code. We could loop over the index instead but sorting might be nicer in
+ -- the end.
+
+ copydictionary = function (xref,copied,object)
+ local target = pdfdictionary()
+ local source = object.__raw__
+ -- for key, value in next, source do
+ for key, value in sortedhash(source) do
+ if plugins then
+ local p = plugins[key]
+ if p then
+ target[key] = p(xref,copied,object,key,value,copyobject) -- maybe a table of methods
+ else
+ target[key] = copyobject(xref,copied,object,key,value)
+ end
+ else
+ target[key] = copyobject(xref,copied,object,key,value)
+ end
+ end
+ return target
+ end
+
+ -- local function copyresources(pdfdoc,xref,copied,pagedata)
+ -- local Resources = pagedata.Resources
+ -- if Resources then
+ -- local r = pdfreserveobject()
+ -- local d = copydictionary(xref,copied,Resources)
+ -- pdfflushobject(r,tostring(d))
+ -- return pdfreference(r)
+ -- end
+ -- end
+
+ local function copyresources(pdfdoc,xref,copied,pagedata)
+ local Resources = pagedata.Resources
+ --
+ -- -- This needs testing:
+ --
+ -- if not Resources then
+ -- local Parent = page.Parent
+ -- while (Parent and (Parent.__type__ == dictionary_object_code or Parent.__type__ == reference_object_code) do
+ -- Resources = Parent.Resources
+ -- if Resources then
+ -- break
+ -- end
+ -- Parent = Parent.Parent
+ -- end
+ -- end
+ if Resources then
+ local d = copydictionary(xref,copied,Resources)
+ return shareobjectreference(d)
+ end
+ end
+
+ local openpdf = lpdf_epdf.load
+ local closepdf = lpdf_epdf.unload
+
+ -- todo: keep track of already open files
+
+ local function newpdf(str,userpassword,ownerpassword)
+ return openpdf(str,userpassword,ownerpassword,true)
+ end
+
+ local sizes = {
+ crop = "CropBox",
+ media = "MediaBox",
+ bleed = "BleedBox",
+ art = "ArtBox",
+ trim = "TrimBox",
+ }
+
+ local function querypdf(pdfdoc,pagenumber,size)
+ if pdfdoc then
+ if not pagenumber then
+ pagenumber = 1
+ end
+ local root = pdfdoc.Catalog
+ local page = pdfdoc.pages[pagenumber]
+ if page then
+ local sizetag = sizes[size or "crop"] or sizes.crop
+ local mediabox = page.MediaBox or { 0, 0, 0, 0 }
+ local cropbox = page[sizetag] or mediabox
+ return {
+ filename = pdfdoc.filename,
+ pagenumber = pagenumber,
+ nofpages = pdfdoc.nofpages,
+ boundingbox = scaledbbox(cropbox),
+ cropbox = cropbox,
+ mediabox = mediabox,
+ bleedbox = page.BleedBox or cropbox,
+ trimbox = page.TrimBox or cropbox,
+ artbox = page.ArtBox or cropbox,
+ rotation = page.Rotate or 0,
+ xsize = cropbox[3] - cropbox[1],
+ ysize = cropbox[4] - cropbox[2],
+ }
+ end
+ end
+ end
+
+ local function copypage(pdfdoc,pagenumber,attributes,compact,width,height,attr)
+ if pdfdoc then
+ local root = pdfdoc.Catalog
+ local page = pdfdoc.pages[pagenumber or 1]
+ local pageinfo = querypdf(pdfdoc,pagenumber)
+ local contents = page.Contents
+ if contents then
+ local xref = pdfdoc.__xrefs__
+ local copied = pdfdoc.__copied__
+ if compact and lpdf_epdf.plugin then
+ plugins = lpdf_epdf.plugin(pdfdoc,xref,copied,page)
+ end
+ local xobject = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Form"),
+ FormType = 1,
+ Group = copyobject(xref,copied,page,"Group"),
+ LastModified = copyobject(xref,copied,page,"LastModified"),
+ Metadata = copyobject(xref,copied,page,"Metadata"),
+ PieceInfo = copyobject(xref,copied,page,"PieceInfo"),
+ Resources = copyresources(pdfdoc,xref,copied,page),
+ SeparationInfo = copyobject(xref,copied,page,"SeparationInfo"),
+ } + attr
+ if attributes then
+ for k, v in expanded(attributes) do
+ page[k] = v -- maybe nested
+ end
+ end
+ local content = ""
+ local nolength = nil
+ local ctype = contents.__type__
+ -- we always recompress because image object streams can not be
+ -- influenced (yet)
+ if ctype == stream_object_code then
+ if stripmarked then
+ content = contents() -- uncompressed
+ local stripped = lpdf_epdf.stripcontent(content)
+ if stripped ~= content then
+ -- report("%i bytes stripped on page %i",#content-#stripped,pagenumber or 1)
+ content = stripped
+ end
+ elseif recompress then
+ content = contents() -- uncompressed
+ else
+ local Filter = copyobject(xref,copied,contents,"Filter")
+ local Length = copyobject(xref,copied,contents,"Length")
+ if Length and Filter then
+ nolength = true
+ xobject.Length = Length
+ xobject.Filter = Filter
+ content = contents(false) -- uncompressed
+ else
+ content = contents() -- uncompressed
+ end
+ end
+ elseif ctype == array_object_code then
+ content = { }
+ for i=1,#contents do
+ content[i] = contents[i]() -- uncompressed
+ end
+ content = concat(content," ")
+ end
+ -- still not nice: we double wrap now
+ plugins = nil
+ local rotation = pageinfo.rotation
+ local boundingbox = pageinfo.boundingbox
+ local transform = nil
+ if rotation == 90 then
+ transform = 3
+ elseif rotation == 180 then
+ transform = 2
+ elseif rotation == 270 then
+ transform = 1
+ elseif rotation > 1 and rotation < 4 then
+ transform = rotation
+ end
+ xobject.BBox = pdfarray {
+ boundingbox[1] * bpfactor,
+ boundingbox[2] * bpfactor,
+ boundingbox[3] * bpfactor,
+ boundingbox[4] * bpfactor,
+ }
+ -- maybe like bitmaps
+ return createimage { -- beware: can be a img.new or a dummy
+ bbox = boundingbox,
+ transform = transform,
+ nolength = nolength,
+ nobbox = true,
+ notype = true,
+ stream = content, -- todo: no compress, pass directly also length, filter etc
+ attr = xobject(),
+ kind = images.types.stream,
+ }
+ else
+ -- maybe report an error
+ end
+ end
+ end
+
+ lpdf_epdf.image = {
+ open = openpdf,
+ close = closepdf,
+ new = newpdf,
+ query = querypdf,
+ copy = copypage,
+ }
+
+-- lpdf.injectors.pdf = function(specification)
+-- local d = lpdf_epdf.load(specification.filename)
+-- print(d)
+-- end
+
+
+end end
+
+-- local d = lpdf_epdf.load("e:/tmp/oeps.pdf")
+-- inspect(d)
+-- inspect(d.Catalog.Lang)
+-- inspect(d.Catalog.OCProperties.D.AS[1].Event)
+-- inspect(d.Catalog.Metadata())
+-- inspect(d.Catalog.Pages.Kids[1])
+-- inspect(d.layers)
+-- inspect(d.pages)
+-- inspect(d.destinations)
+-- inspect(lpdf_epdf.getpagecontent(d,1))
+-- inspect(lpdf_epdf.contenttotext(document,lpdf_epdf.getpagecontent(d,1)))
+-- inspect(lpdf_epdf.getstructure(document,lpdf_epdf.getpagecontent(d,1)))
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-ren.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-ren.lmt
new file mode 100644
index 00000000000..3794250d9ea
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-ren.lmt
@@ -0,0 +1,399 @@
+if not modules then modules = { } end modules ['lpdf-ren'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- rendering
+
+local tostring, tonumber, next = tostring, tonumber, next
+local concat = table.concat
+local formatters = string.formatters
+local settings_to_array = utilities.parsers.settings_to_array
+local getrandom = utilities.randomizer.get
+
+local backends, lpdf, nodes, node = backends, lpdf, nodes, node
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
+local viewerlayers = attributes.viewerlayers
+
+local references = structures.references
+
+references.executers = references.executers or { }
+local executers = references.executers
+
+local variables = interfaces.variables
+
+local v_no = variables.no
+local v_yes = variables.yes
+local v_start = variables.start
+local v_stop = variables.stop
+local v_reset = variables.reset
+local v_auto = variables.auto
+local v_random = variables.random
+
+local pdfconstant = lpdf.constant
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+
+local pdfflushobject
+local pdfreserveobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfreserveobject = lpdf.reserveobject
+end)
+
+local addtopageattributes = lpdf.addtopageattributes
+local addtopageresources = lpdf.addtopageresources
+local addtocatalog = lpdf.addtocatalog
+
+local escaped = lpdf.escaped
+
+local nuts = nodes.nuts
+local copy_node = nuts.copy
+
+local nodepool = nuts.pool
+local register = nodepool.register
+local setstate = nodepool.setstate
+
+local pdf_ocg = pdfconstant("OCG")
+local pdf_ocmd = pdfconstant("OCMD")
+local pdf_off = pdfconstant("OFF")
+local pdf_on = pdfconstant("ON")
+local pdf_view = pdfconstant("View")
+local pdf_design = pdfconstant("Design")
+local pdf_toggle = pdfconstant("Toggle")
+local pdf_setocgstate = pdfconstant("SetOCGState")
+
+local pdf_print = {
+ [v_yes] = pdfdictionary { PrintState = pdf_on },
+ [v_no ] = pdfdictionary { PrintState = pdf_off },
+}
+
+local pdf_intent = {
+ [v_yes] = pdf_view,
+ [v_no] = pdf_design,
+}
+
+local pdf_export = {
+ [v_yes] = pdf_on,
+ [v_no] = pdf_off,
+}
+
+-- We can have references to layers before they are places, for instance from
+-- hide and vide actions. This is why we need to be able to force usage of layers
+-- at several moments.
+
+-- management
+
+local pdfln, pdfld = { }, { }
+local textlayers, hidelayers, videlayers = pdfarray(), pdfarray(), pdfarray()
+local pagelayers, pagelayersreference, cache = nil, nil, { }
+local alphabetic = { }
+
+local escapednames = table.setmetatableindex(function(t,k)
+ local v = escaped(k)
+ t[k] = v
+ return v
+end)
+
+local specifications = { }
+local initialized = { }
+
+function codeinjections.defineviewerlayer(specification)
+ if viewerlayers.supported and textlayers then
+ local tag = specification.tag
+ if not specifications[tag] then
+ specifications[tag] = specification
+ end
+ end
+end
+
+local function useviewerlayer(name) -- move up so that we can use it as local
+ if not environment.initex and not initialized[name] then
+ local specification = specifications[name]
+ if specification then
+ specifications[name] = nil -- or not
+ initialized [name] = true
+ if not pagelayers then
+ pagelayers = pdfdictionary()
+ pagelayersreference = pdfreserveobject()
+ end
+ local tag = specification.tag
+ -- todo: reserve
+ local nn = pdfreserveobject()
+ local nr = pdfreference(nn)
+ local nd = pdfdictionary {
+ Type = pdf_ocg,
+ Name = specification.title or "unknown",
+ Usage = {
+ Intent = pdf_intent[specification.editable or v_yes], -- disable layer hiding by user (useless)
+ Print = pdf_print [specification.printable or v_yes], -- printable or not
+ Export = pdf_export[specification.export or v_yes], -- export or not
+ },
+ }
+ cache[#cache+1] = { nn, nd }
+ pdfln[tag] = nr -- was n
+ local dn = pdfreserveobject()
+ local dr = pdfreference(dn)
+ local dd = pdfdictionary {
+ Type = pdf_ocmd,
+ OCGs = pdfarray { nr },
+ }
+ cache[#cache+1] = { dn, dd }
+ pdfld[tag] = dr
+ textlayers[#textlayers+1] = nr
+ alphabetic[tag] = nr
+ if specification.visible == v_start then
+ videlayers[#videlayers+1] = nr
+ else
+ hidelayers[#hidelayers+1] = nr
+ end
+ pagelayers[escapednames[tag]] = dr -- check
+ else
+ -- todo: message
+ end
+ end
+end
+
+codeinjections.useviewerlayer = useviewerlayer
+
+local function layerreference(name)
+ local r = pdfln[name]
+ if r then
+ return r
+ else
+ useviewerlayer(name)
+ return pdfln[name]
+ end
+end
+
+lpdf.layerreference = layerreference -- also triggered when a hide or vide happens
+
+local function flushtextlayers()
+ if viewerlayers.supported then
+ if pagelayers then
+ pdfflushobject(pagelayersreference,pagelayers)
+ end
+ for i=1,#cache do
+ local ci = cache[i]
+ pdfflushobject(ci[1],ci[2])
+ end
+ if textlayers and #textlayers > 0 then -- we can group them if needed, like: layout
+ local sortedlayers = { }
+ for k, v in table.sortedhash(alphabetic) do
+ sortedlayers[#sortedlayers+1] = v -- maybe do a proper numeric sort as well
+ end
+ local d = pdfdictionary {
+ OCGs = textlayers,
+ D = pdfdictionary {
+ Name = "Document",
+ -- Order = (viewerlayers.hasorder and textlayers) or nil,
+ Order = (viewerlayers.hasorder and sortedlayers) or nil,
+ ON = videlayers,
+ OFF = hidelayers,
+ BaseState = pdf_on,
+ AS = pdfarray {
+ pdfdictionary {
+ Category = pdfarray { pdfconstant("Print") },
+ Event = pdfconstant("Print"),
+ OCGs = (viewerlayers.hasorder and sortedlayers) or nil,
+ }
+ },
+ },
+ }
+ addtocatalog("OCProperties",d)
+ textlayers = nil
+ end
+ end
+end
+
+local function flushpagelayers() -- we can share these
+ if pagelayers then
+ addtopageresources("Properties",pdfreference(pagelayersreference)) -- we could cache this
+ end
+end
+
+lpdf.registerpagefinalizer (flushpagelayers,"layers")
+lpdf.registerdocumentfinalizer(flushtextlayers,"layers")
+
+local function setlayer(what,arguments)
+ -- maybe just a gmatch of even better, earlier in lpeg
+ arguments = (type(arguments) == "table" and arguments) or settings_to_array(arguments)
+ local state = pdfarray { what }
+ for i=1,#arguments do
+ local p = layerreference(arguments[i])
+ if p then
+ state[#state+1] = p
+ end
+ end
+ return pdfdictionary {
+ S = pdf_setocgstate,
+ State = state,
+ }
+end
+
+function executers.hidelayer (arguments) return setlayer(pdf_off, arguments) end
+function executers.videlayer (arguments) return setlayer(pdf_on, arguments) end
+function executers.togglelayer(arguments) return setlayer(pdf_toggle,arguments) end
+
+-- injection
+
+local f_bdc = formatters["/OC /%s BDC"]
+local s_emc = "EMC"
+
+function codeinjections.startlayer(name) -- used in mp
+ if not name then
+ name = "unknown"
+ end
+ useviewerlayer(name)
+ return f_bdc(escapednames[name])
+end
+
+function codeinjections.stoplayer(name) -- used in mp
+ return s_emc
+end
+
+local cache = { }
+local stop = nil
+
+function nodeinjections.startlayer(name)
+ local c = cache[name]
+ if not c then
+ useviewerlayer(name)
+ c = register(setstate(f_bdc(escapednames[name])))
+ cache[name] = c
+ end
+ return copy_node(c)
+end
+
+function nodeinjections.stoplayer()
+ if not stop then
+ stop = register(setstate(s_emc))
+ end
+ return copy_node(stop)
+end
+
+-- experimental stacker code (slow, can be optimized): !!!! TEST CODE !!!!
+
+local values = viewerlayers.values
+local startlayer = codeinjections.startlayer
+local stoplayer = codeinjections.stoplayer
+
+function nodeinjections.startstackedlayer(s,t,first,last)
+ local r = { }
+ for i=first,last do
+ r[#r+1] = startlayer(values[t[i]])
+ end
+ r = concat(r," ")
+ return setstate(r)
+end
+
+function nodeinjections.stopstackedlayer(s,t,first,last)
+ local r = { }
+ for i=last,first,-1 do
+ r[#r+1] = stoplayer()
+ end
+ r = concat(r," ")
+ return setstate(r)
+end
+
+function nodeinjections.changestackedlayer(s,t1,first1,last1,t2,first2,last2)
+ local r = { }
+ for i=last1,first1,-1 do
+ r[#r+1] = stoplayer()
+ end
+ for i=first2,last2 do
+ r[#r+1] = startlayer(values[t2[i]])
+ end
+ r = concat(r," ")
+ return setstate(r)
+end
+
+-- transitions
+
+local pagetransitions = {
+ {"split","in","vertical"}, {"split","in","horizontal"},
+ {"split","out","vertical"}, {"split","out","horizontal"},
+ {"blinds","horizontal"}, {"blinds","vertical"},
+ {"box","in"}, {"box","out"},
+ {"wipe","east"}, {"wipe","west"}, {"wipe","north"}, {"wipe","south"},
+ {"dissolve"},
+ {"glitter","east"}, {"glitter","south"},
+ {"fly","in","east"}, {"fly","in","west"}, {"fly","in","north"}, {"fly","in","south"},
+ {"fly","out","east"}, {"fly","out","west"}, {"fly","out","north"}, {"fly","out","south"},
+ {"push","east"}, {"push","west"}, {"push","north"}, {"push","south"},
+ {"cover","east"}, {"cover","west"}, {"cover","north"}, {"cover","south"},
+ {"uncover","east"}, {"uncover","west"}, {"uncover","north"}, {"uncover","south"},
+ {"fade"},
+}
+
+local mapping = {
+ split = { "S" , pdfconstant("Split") },
+ blinds = { "S" , pdfconstant("Blinds") },
+ box = { "S" , pdfconstant("Box") },
+ wipe = { "S" , pdfconstant("Wipe") },
+ dissolve = { "S" , pdfconstant("Dissolve") },
+ glitter = { "S" , pdfconstant("Glitter") },
+ replace = { "S" , pdfconstant("R") },
+ fly = { "S" , pdfconstant("Fly") },
+ push = { "S" , pdfconstant("Push") },
+ cover = { "S" , pdfconstant("Cover") },
+ uncover = { "S" , pdfconstant("Uncover") },
+ fade = { "S" , pdfconstant("Fade") },
+ horizontal = { "Dm" , pdfconstant("H") },
+ vertical = { "Dm" , pdfconstant("V") },
+ ["in"] = { "M" , pdfconstant("I") },
+ out = { "M" , pdfconstant("O") },
+ east = { "Di" , 0 },
+ north = { "Di" , 90 },
+ west = { "Di" , 180 },
+ south = { "Di" , 270 },
+}
+
+local last = 0
+
+-- n: number, "stop", "reset", "random", "a,b,c" delay: number, "none"
+
+function codeinjections.setpagetransition(specification)
+ local n, delay = specification.n, specification.delay
+ if not n or n == "" then
+ return -- let's forget about it
+ elseif n == v_auto then
+ if last >= #pagetransitions then
+ last = 0
+ end
+ n = last + 1
+ elseif n == v_stop then
+ return
+ elseif n == v_reset then
+ last = 0
+ return
+ elseif n == v_random then
+ n = getrandom("transition",1,#pagetransitions)
+ else
+ n = tonumber(n)
+ end
+ local t = n and pagetransitions[n] or pagetransitions[1]
+ if not t then
+ t = settings_to_array(n)
+ end
+ if t and #t > 0 then
+ local d = pdfdictionary()
+ for i=1,#t do
+ local m = mapping[t[i]]
+ d[m[1]] = m[2]
+ end
+ delay = tonumber(delay)
+ if delay and delay > 0 then
+ addtopageattributes("Dur",delay)
+ end
+ addtopageattributes("Trans",d)
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-res.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-res.lmt
new file mode 100644
index 00000000000..d3c591343fc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-res.lmt
@@ -0,0 +1,41 @@
+if not modules then modules = { } end modules ['lpdf-res'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local codeinjections = backends.codeinjections
+
+local nuts = nodes.nuts
+local tonut = nodes.tonut
+
+local setwhd = nuts.setwhd
+local setlist = nuts.setlist
+
+local new_hlist = nuts.pool.hlist
+
+local boxresources = tex.boxresources
+local saveboxresource = boxresources.save
+local useboxresource = boxresources.use
+local getboxresourcedimensions = boxresources.getdimensions
+
+local pdfcollectedresources = lpdf.collectedresources
+
+function codeinjections.registerboxresource(n,offset)
+ local r = saveboxresource(n,nil,pdfcollectedresources(),true,0,offset or 0) -- direct, todo: accept functions as attr/resources
+ return r
+end
+
+function codeinjections.restoreboxresource(index)
+ local hbox = new_hlist()
+ local list, wd, ht, dp = useboxresource(index)
+ setlist(hbox,tonut(list))
+ setwhd(hbox,wd,ht,dp)
+ return hbox -- so we return a nut !
+end
+
+function codeinjections.boxresourcedimensions(index)
+ return getboxresourcedimensions(index)
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-rul.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-rul.lmt
new file mode 100644
index 00000000000..efcc6207372
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-rul.lmt
@@ -0,0 +1,388 @@
+if not modules then modules = { } end modules ['lpdf-rul'] = {
+ version = 1.001,
+ comment = "companion to grph-rul.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local tonumber, next, type = tonumber, next, type
+local concat = table.concat
+
+local attributes = attributes
+local nodes = nodes
+
+local bpfactor = number.dimenfactors.bp
+
+local nuts = nodes.nuts
+local ruleactions = nuts.rules.ruleactions
+
+local getwhd = nuts.getwhd
+
+local lefttoright_code = nodes.dirvalues.lefttoright
+
+local mpcolor = attributes.colors.mpcolor
+
+local trace_mp = false trackers.register("rules.mp", function(v) trace_mp = v end)
+
+local report_mp = logs.reporter("rules","mp")
+
+local floor = math.floor
+local getrandom = utilities.randomizer.get
+local formatters = string.formatters
+
+-- This is very pdf specific. Maybe move some to lpdf-rul.lua some day.
+
+local pdfprint ; pdfprint = function(...) pdfprint = lpdf.print return pdfprint(...) end
+
+-- updaters.register("backend.update",function() pdfprint = lpdf.print end)
+
+do
+
+ local simplemetapost = metapost.simple
+ local cachesize = 0
+ local maxcachesize = 256*1024
+ local cachethreshold = 1024
+ local caching = false -- otherwise random issues so we need a dedicated randomizer first
+
+ -- local maxcachesize = 8*1024
+ -- local cachethreshold = 1024/2
+
+ local cache = table.setmetatableindex(function(t,k)
+ local v = simplemetapost("rulefun",k) -- w, h, d
+ cachesize = cachesize + #v
+ if cachesize > maxcachesize then
+ -- print("old",cachesize)
+ for k, v in next, t do
+ local n = #v
+ if n > cachethreshold then
+ t[k] = nil
+ cachesize = cachesize - n
+ end
+ end
+ -- print("new",cachesize)
+ end
+ -- print(cachesize,maxcachesize,cachethreshold,#v)
+ t[k] = v
+ return v
+ end)
+
+ local replacer = utilities.templates.replacer
+
+ -- todo: RuleColor -> just string ?
+
+ local predefined = {
+ ["fake:word"] = replacer [[
+FakeWord(%width%,%height%,%depth%,%line%,%color%);
+ ]],
+ ["fake:rule"] = replacer[[
+%initializations%
+FakeRule(%width%,%height%,%depth%,%line%,%color%);
+ ]],
+ ["fake:rest"] = replacer [[
+RuleDirection := "%direction%" ;
+RuleOption := "%option%" ;
+RuleWidth := %width% ;
+RuleHeight := %height% ;
+RuleDepth := %depth% ;
+RuleH := %h% ;
+RuleV := %v% ;
+RuleThickness := %line% ;
+RuleFactor := %factor% ;
+RuleOffset := %offset% ;
+def RuleColor = %color% enddef ;
+%data%;
+ ]]
+ }
+
+ local initialized = false ;
+
+ local rule_mp = function(p,h,v,i,n)
+ local name = p.name or "fake:rest"
+ local code = (predefined[name] or predefined["fake:rest"]) {
+ data = p.data or "",
+ width = p.width * bpfactor,
+ height = p.height * bpfactor,
+ depth = p.depth * bpfactor,
+ factor = (p.factor or 0) * bpfactor, -- needs checking
+ offset = p.offset or 0,
+ line = (p.line or 65536) * bpfactor,
+ color = mpcolor(p.ma,p.ca,p.ta),
+ option = p.option or "",
+ direction = p.direction or lefttoright_code,
+ h = h * bpfactor,
+ v = v * bpfactor,
+ }
+ if not initialized then
+ initialized = true
+ simplemetapost("rulefun",formatters["randomseed := %s;"](getrandom("rulefun",0,4095)))
+ end
+ -- we enable extensions but we could also consider to delegate colors
+ -- to the node finalizer
+ local pdf = caching and cache[code] or simplemetapost("rulefun",code,true)
+ if trace_mp then
+ report_mp("code: %s",code)
+ report_mp("pdf : %s",pdf)
+ end
+ if pdf and pdf ~= "" then
+ pdfprint("direct",pdf)
+ end
+ end
+
+ updaters.register("backend.update.lpdf",function()
+ ruleactions.mp = rule_mp
+ end)
+
+end
+
+do
+
+ -- This is the old oval method that we keep it for compatibility reasons. Of
+ -- course one can use mp instead. It could be improved but at the cost of more
+ -- code than I'm willing to add for something hardly used.
+
+ local function round(p,kind)
+ local method = tonumber(p.corner) or 0
+ if method < 0 or method > 27 then
+ method = 0
+ end
+ local width = p.width or 0
+ local height = p.height or 0
+ local depth = p.depth or 0
+ local total = height + depth
+ local radius = p.radius or 655360
+ local line = p.line or 65536
+ local how = (method > 8 or kind ~= "fill") and "S" or "f"
+ local half = line / 2
+ local xmin = half * bpfactor
+ local xmax = ( width - half) * bpfactor
+ local ymax = ( height - half) * bpfactor
+ local ymin = (-depth + half) * bpfactor
+ local full = ( radius + half)
+ local xxmin = full * bpfactor
+ local xxmax = ( width - full) * bpfactor
+ local yymax = ( height - full) * bpfactor
+ local yymin = (-depth + full) * bpfactor
+ line = line * bpfactor
+ if xxmin <= xxmax and yymin <= yymax then
+ local list = nil
+ if method == 0 then
+ list = {
+ "q", line, "w", xxmin, ymin, "m", xxmax, ymin, "l", xmax, ymin, xmax, yymin, "y",
+ xmax, yymax, "l", xmax, ymax, xxmax, ymax, "y", xxmin, ymax, "l", xmin, ymax,
+ xmin, yymax, "y", xmin, yymin, "l", xmin, ymin, xxmin, ymin, "y", "h", how, "Q",
+ }
+ elseif method == 1 then
+ list = {
+ "q", line, "w", xxmin, ymin, "m", xxmax, ymin, "l", xmax, ymin, xmax, yymin, "y",
+ xmax, ymax, "l", xmin, ymax, "l", xmin, yymin, "l", xmin, ymin, xxmin, ymin, "y",
+ "h", how, "Q",
+ }
+ elseif method == 2 then
+ list = {
+ "q", line, "w", xxmin, ymin, "m", xmax, ymin, "l", xmax, ymax, "l", xxmin, ymax,
+ "l", xmin, ymax, xmin, yymax, "y", xmin, yymin, "l", xmin, ymin, xxmin, ymin,
+ "y", "h", how, "Q",
+ }
+ elseif method == 3 then
+ list = {
+ "q", line, "w", xmin, ymin, "m", xmax, ymin, "l", xmax, yymax, "l", xmax, ymax,
+ xxmax, ymax, "y", xxmin, ymax, "l", xmin, ymax, xmin, yymax, "y", xmin, ymin,
+ "l", "h", how, "Q",
+ }
+
+ elseif method == 4 then
+ list = {
+ "q", line, "w", xmin, ymin, "m", xxmax, ymin, "l", xmax, ymin, xmax, yymin, "y",
+ xmax, yymax, "l", xmax, ymax, xxmax, ymax, "y", xmin, ymax, "l", xmin, ymin, "l",
+ "h", how, "Q",
+ }
+ elseif method == 5 then
+ list = {
+ "q", line, "w", xmin, ymin, "m", xmax, ymin, "l", xmax, yymax, "l", xmax, ymax,
+ xxmax, ymax, "y", xmin, ymax, "l", xmin, ymin, "l", "h", how, "Q",
+ }
+ elseif method == 6 then
+ list = {
+ "q", line, "w", xmin, ymin, "m", xxmax, ymin, "l", xmax, ymin, xmax, yymin, "y",
+ xmax, ymax, "l", xmin, ymax, "l", xmin, ymin, "l", "h", how, "Q",
+ }
+ elseif method == 7 then
+ list = {
+ "q", line, "w", xxmin, ymin, "m", xmax, ymin, "l", xmax, ymax, "l", xmin, ymax,
+ "l", xmin, yymin, "l", xmin, ymin, xxmin, ymin, "y", "h", how, "Q",
+ }
+ elseif method == 8 then
+ list = {
+ "q", line, "w", xmin, ymin, "m", xmax, ymin, "l", xmax, ymax, "l", xxmin, ymax,
+ "l", xmin, ymax, xmin, yymax, "y", xmin, ymin, "l", "h", how, "Q",
+ }
+ elseif method == 9 then
+ list = {
+ "q", line, "w", xmin, ymax, "m", xmin, yymin, "l", xmin, ymin, xxmin, ymin, "y",
+ xxmax, ymin, "l", xmax, ymin, xmax, yymin, "y", xmax, ymax, "l", how, "Q",
+ }
+ elseif method == 10 then
+ list = {
+ "q", line, "w", xmax, ymax, "m", xxmin, ymax, "l", xmin, ymax, xmin, yymax, "y",
+ xmin, yymin, "l", xmin, ymin, xxmin, ymin, "y", xmax, ymin, "l", how, "Q",
+ }
+ elseif method == 11 then
+ list = {
+ "q", line, "w", xmax, ymin, "m", xmax, yymax, "l", xmax, ymax, xxmax, ymax, "y",
+ xxmin, ymax, "l", xmin, ymax, xmin, yymax, "y", xmin, ymin, "l", how, "Q",
+ }
+ elseif method == 12 then
+ list = {
+ "q", line, "w", xmin, ymax, "m", xxmax, ymax, "l", xmax, ymax, xmax, yymax, "y",
+ xmax, yymin, "l", xmax, ymin, xxmax, ymin, "y", xmin, ymin, "l", how, "Q",
+ }
+ elseif method == 13 then
+ list = {
+ "q", line, "w", xmin, ymax, "m", xxmax, ymax, "l", xmax, ymax, xmax, yymax, "y",
+ xmax, ymin, "l", how, "Q",
+ }
+ elseif method == 14 then
+ list = {
+ "q", line, "w", xmax, ymax, "m", xmax, yymin, "l", xmax, ymin, xxmax, ymin, "y",
+ xmin, ymin, "l", how, "Q",
+ }
+ elseif method == 15 then
+ list = {
+ "q", line, "w", xmax, ymin, "m", xxmin, ymin, "l", xmin, ymin, xmin, yymin, "y",
+ xmin, ymax, "l", how, "Q",
+ }
+ elseif method == 16 then
+ list = {
+ "q", line, "w", xmin, ymin, "m", xmin, yymax, "l", xmin, ymax, xxmin, ymax, "y",
+ xmax, ymax, "l", how, "Q",
+ }
+ elseif method == 17 then
+ list = {
+ "q", line, "w", xxmax, ymax, "m", xmax, ymax, xmax, yymax, "y", how, "Q",
+ }
+ elseif method == 18 then
+ list = {
+ "q", line, "w", xmax, yymin, "m", xmax, ymin, xxmax, ymin, "y", how, "Q",
+ }
+ elseif method == 19 then
+ list = {
+ "q", line, "w", xxmin, ymin, "m", xmin, ymin, xmin, yymin, "y", how, "Q",
+ }
+ elseif method == 20 then
+ list = {
+ "q", line, "w", xmin, yymax, "m", xmin, ymax, xxmin, ymax, "y", how, "Q",
+ }
+ elseif method == 21 then
+ list = {
+ "q", line, "w", xxmax, ymax, "m", xmax, ymax, xmax, yymax, "y", xmin, yymax, "m",
+ xmin, ymax, xxmin, ymax, "y", how, "Q",
+ }
+ elseif method == 22 then
+ list = {
+ "q", line, "w", xxmax, ymax, "m", xmax, ymax, xmax, yymax, "y", xmax, yymin, "m",
+ xmax, ymin, xxmax, ymin, "y", how, "Q",
+ }
+ elseif method == 23 then
+ list = {
+ "q", line, "w", xmax, yymin, "m", xmax, ymin, xxmax, ymin, "y", xxmin, ymin, "m",
+ xmin, ymin, xmin, yymin, "y", how, "Q",
+ }
+ elseif method == 24 then
+ list = {
+ "q", line, "w", xxmin, ymin, "m", xmin, ymin, xmin, yymin, "y", xmin, yymax, "m",
+ xmin, ymax, xxmin, ymax, "y", how, "Q",
+ }
+ elseif method == 25 then
+ list = {
+ "q", line, "w", xxmax, ymax, "m", xmax, ymax, xmax, yymax, "y", xmax, yymin, "m",
+ xmax, ymin, xxmax, ymin, "y", xxmin, ymin, "m", xmin, ymin, xmin, yymin, "y",
+ xmin, yymax, "m", xmin, ymax, xxmin, ymax, "y", how, "Q",
+ }
+ elseif method == 26 then
+ list = {
+ "q", line, "w", xmax, yymin, "m", xmax, ymin, xxmax, ymin, "y", xmin, yymax, "m",
+ xmin, ymax, xxmin, ymax, "y", how, "Q",
+ }
+
+ elseif method == 27 then
+ list = {
+ "q", line, "w", xxmax, ymax, "m", xmax, ymax, xmax, yymax, "y", xxmin, ymin, "m",
+ xmin, ymin, xmin, yymin, "y", how, "Q",
+ }
+ end
+ pdfprint("direct",concat(list," "))
+ end
+ end
+
+ local f_rectangle = formatters["%.6N w %.6N %.6N %.6N %.6N re %s"]
+ local f_baselined = formatters["%.6N w %.6N %.6N %.6N %.6N re s %.6N %.6N m %.6N %.6N l s"]
+ local f_dashlined = formatters["%.6N w %.6N %.6N %.6N %.6N re s [%.6N %.6N] 2 d %.6N %.6N m %.6N %.6N l s"]
+ local f_radtangle = formatters[
+[[%.6N w %.6N %.6N m
+%.6N %.6N l %.6N %.6N %.6N %.6N y
+%.6N %.6N l %.6N %.6N %.6N %.6N y
+%.6N %.6N l %.6N %.6N %.6N %.6N y
+%.6N %.6N l %.6N %.6N %.6N %.6N y
+h %s]]
+ ]
+
+ local rule_any = function(p,h,v,i,n)
+ if p.corner then
+ return round(p,i)
+ else
+ local l = (p.line or 65536)*bpfactor
+ local r = p and (p.radius or 0)*bpfactor or 0
+ local w = h * bpfactor
+ local h = v * bpfactor
+ local m = nil
+ local t = i == "fill" and "f" or "s"
+ local o = l / 2
+ if r > 0 then
+ w = w - o
+ h = h - o
+ m = f_radtangle(l, r,o, w-r,o, w,o,w,r, w,h-r, w,h,w-r,h, r,h, o,h,o,h-r, o,r, o,o,r,o, t)
+ else
+ w = w - l
+ h = h - l
+ m = f_rectangle(l,o,o,w,h,t)
+ end
+ pdfprint("direct",m)
+ end
+ end
+
+ local function rule_box(p,h,v,i,n)
+ local w, h, d = getwhd(n)
+ local line = p.line or 65536
+ local l = line *bpfactor
+ local w = w * bpfactor
+ local h = h * bpfactor
+ local d = d * bpfactor
+ local o = l / 2
+ if (d >= 0 and h >= 0) or (d <= 0 and h <= 0) then
+ local dashed = tonumber(p.dashed)
+ if dashed and dashed > 5*line then
+ dashed = dashed * bpfactor
+ local delta = (w - 2*dashed*floor(w/(2*dashed)))/2
+ pdfprint("direct",f_dashlined(l,o,o,w-l,h+d-l,dashed,dashed,delta,d,w-delta,d))
+ else
+ pdfprint("direct",f_baselined(l,o,o,w-l,h+d-l,0,d,w,d))
+ end
+ else
+ pdfprint("direct",f_rectangle(l,o,o,w-l,h+d-l))
+ end
+ end
+
+ updaters.register("backend.update.lpdf",function()
+ ruleactions.fill = rule_any
+ ruleactions.draw = rule_any
+ ruleactions.stroke = rule_any
+ ruleactions.box = rule_box
+ end)
+
+end
+
+
+ ruleactions.mp = unsupported
+
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-tag.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-tag.lmt
new file mode 100644
index 00000000000..44a84ea59bb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-tag.lmt
@@ -0,0 +1,743 @@
+if not modules then modules = { } end modules ['lpdf-tag'] = {
+ version = 1.001,
+ comment = "companion to lpdf-tag.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local next, type = next, type
+local format, match, gmatch = string.format, string.match, string.gmatch
+local concat, sortedhash = table.concat, table.sortedhash
+local lpegmatch, P, S, C = lpeg.match, lpeg.P, lpeg.S, lpeg.C
+local settings_to_hash = utilities.parsers.settings_to_hash
+local formatters = string.formatters
+
+local trace_tags = false trackers.register("structures.tags", function(v) trace_tags = v end)
+local trace_info = false trackers.register("structures.tags.info", function(v) trace_info = v end)
+
+local report_tags = logs.reporter("backend","tags")
+
+local backends = backends
+local lpdf = lpdf
+local nodes = nodes
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+
+local enableaction = nodes.tasks.enableaction
+local disableaction = nodes.tasks.disableaction
+
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfboolean = lpdf.boolean
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfmakenametree = lpdf.makenametree
+
+local addtocatalog = lpdf.addtocatalog
+local addtopageattributes = lpdf.addtopageattributes
+
+local pdfflushobject
+local pdfreserveobject
+local pdfpagereference
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfreserveobject = lpdf.reserveobject
+ pdfpagereference = lpdf.pagereference
+end)
+
+local texgetcount = tex.getcount
+
+local nodecodes = nodes.nodecodes
+
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glyph_code = nodecodes.glyph
+
+local a_tagged = attributes.private('tagged')
+local a_image = attributes.private('image')
+
+local nuts = nodes.nuts
+
+local nodepool = nuts.pool
+local setstate = nodepool.setstate
+local register = nodepool.register
+
+local getid = nuts.getid
+local getattr = nuts.getattr
+local getprev = nuts.getprev
+local getnext = nuts.getnext
+local getlist = nuts.getlist
+local getchar = nuts.getchar
+
+local setlink = nuts.setlink
+local setlist = nuts.setlist
+
+local copy_node = nuts.copy
+local tosequence = nuts.tosequence
+
+local nextnode = nuts.traversers.node
+
+local structure_kids -- delayed
+local structure_ref -- delayed
+local parent_ref -- delayed
+local root -- delayed
+local names = { }
+local tree = { }
+local elements = { }
+
+local structurestags = structures.tags
+local taglist = structurestags.taglist
+local specifications = structurestags.specifications
+local usedlabels = structurestags.labels
+local properties = structurestags.properties
+local usewithcare = structurestags.usewithcare
+
+local usedmapping = { }
+
+----- tagsplitter = structurestags.patterns.splitter
+
+local embeddedtags = false -- true will id all, for tracing, otherwise table
+local f_tagid = formatters["%s-%04i"]
+local embeddedfilelist = pdfarray() -- /AF crap
+
+-- for testing, not that it was ever used:
+
+directives.register("structures.tags.embed",function(v)
+ if type(v) == "string" then
+ if type(embeddedtags) ~= "table" then
+ embeddedtags = { }
+ end
+ for s in gmatch(v,"([^, ]+)") do
+ embeddedtags[s] = true
+ end
+ elseif v and not embeddedtags then
+ embeddedtags = true
+ end
+end)
+
+-- for old times sake, not that it was ever used:
+
+directives.register("structures.tags.embedmath",function(v)
+ if not v then
+ -- only enable
+ elseif embeddedtags == true then
+ -- already all tagged
+ elseif embeddedtags then
+ embeddedtags.math = true
+ else
+ embeddedtags = { math = true }
+ end
+end)
+
+function codeinjections.maptag(original,target,kind)
+ mapping[original] = { target, kind or "inline" }
+end
+
+-- mostly the same as the annotations tree
+
+local function finishstructure()
+ if root and #structure_kids > 0 then
+ local nums = pdfarray()
+ local n = 0
+ for i=1,#tree do
+ n = n + 1 ; nums[n] = i - 1
+ n = n + 1 ; nums[n] = pdfreference(pdfflushobject(tree[i]))
+ end
+ local parenttree = pdfdictionary {
+ Nums = nums
+ }
+ local idtree = pdfmakenametree(names)
+ --
+ local rolemap = pdfdictionary()
+ for k, v in next, usedmapping do
+ k = usedlabels[k] or k
+ local p = properties[k]
+ rolemap[k] = pdfconstant(p and p.pdf or "Span") -- or "Div"
+ end
+ local structuretree = pdfdictionary {
+ Type = pdfconstant("StructTreeRoot"),
+ K = pdfreference(pdfflushobject(structure_kids)),
+ ParentTree = pdfreference(pdfflushobject(parent_ref,parenttree)),
+ IDTree = idtree,
+ RoleMap = rolemap, -- sorted ?
+ }
+ pdfflushobject(structure_ref,structuretree)
+ addtocatalog("StructTreeRoot",pdfreference(structure_ref))
+ --
+ if lpdf.majorversion() == 1 then
+ local markinfo = pdfdictionary {
+ Marked = pdfboolean(true) or nil,
+ -- UserProperties = pdfboolean(true), -- maybe some day
+ -- Suspects = pdfboolean(true) or nil,
+ -- AF = #embeddedfilelist > 0 and pdfreference(pdfflushobject(embeddedfilelist)) or nil,
+ }
+ addtocatalog("MarkInfo",pdfreference(pdfflushobject(markinfo)))
+ end
+ --
+ for fulltag, element in sortedhash(elements) do -- sorting is easier on comparing pdf
+ pdfflushobject(element.knum,element.kids)
+ end
+ end
+end
+
+lpdf.registerdocumentfinalizer(finishstructure,"document structure")
+
+local index, pageref, pagenum, list = 0, nil, 0, nil
+
+local pdf_mcr = pdfconstant("MCR")
+local pdf_struct_element = pdfconstant("StructElem")
+local pdf_s = pdfconstant("S")
+
+local function initializepage()
+ index = 0
+ pagenum = texgetcount("realpageno")
+ pageref = pdfreference(pdfpagereference(pagenum))
+ list = pdfarray()
+ tree[pagenum] = list -- we can flush after done, todo
+end
+
+local function finishpage()
+ -- flush what can be flushed
+ addtopageattributes("StructParents",pagenum-1)
+ -- there might be more
+ addtopageattributes("Tabs",s)
+end
+
+-- here we can flush and free elements that are finished
+
+local pdf_userproperties = pdfconstant("UserProperties")
+
+-- /O /Table
+-- /Headers [ ]
+
+local function makeattribute(t)
+ if t and next(t) then
+ local properties = pdfarray()
+ for k, v in sortedhash(t) do -- easier on comparing pdf
+ properties[#properties+1] = pdfdictionary {
+ N = pdfunicode(k),
+ V = pdfunicode(v),
+ }
+ end
+ return pdfdictionary {
+ O = pdf_userproperties,
+ P = properties,
+ }
+ end
+end
+
+local function makeelement(fulltag,parent)
+ local specification = specifications[fulltag]
+ local tagname = specification.tagname
+ local tagnameused = tagname
+ local attributes = nil
+ if tagname == "ignore" then
+ return false
+ elseif tagname == "mstackertop" or tagname == "mstackerbot" or tagname == "mstackermid"then
+ -- TODO
+ return true
+ elseif tagname == "tabulatecell" then
+ local d = structurestags.gettabulatecell(fulltag)
+ if d and d.kind == 1 then
+ tagnameused = "tabulateheadcell"
+ end
+ elseif tagname == "tablecell" then
+ -- will become a plugin model
+ local d = structurestags.gettablecell(fulltag)
+ if d then
+ if d.kind == 1 then
+ tagnameused = "tableheadcell"
+ end
+ local rows = d.rows or 1
+ local cols = d.columns or 1
+ if rows > 1 or cols > 1 then
+ attributes = pdfdictionary {
+ O = pdfconstant("Table"),
+ RowSpan = rows > 1 and rows or nil,
+ ColSpan = cols > 1 and cols or nil,
+ }
+ end
+
+ end
+ end
+ --
+ local detail = specification.detail
+ local userdata = specification.userdata
+ --
+ usedmapping[tagname] = true
+ --
+ -- specification.attribute is unique
+ --
+ local id = nil
+ local af = nil
+ if embeddedtags then
+ local tagindex = specification.tagindex
+ if embeddedtags == true or embeddedtags[tagname] then
+ id = f_tagid(tagname,tagindex)
+ af = job.fileobjreferences.collected[id]
+ if af then
+ local r = pdfreference(af)
+ af = pdfarray { r }
+ -- embeddedfilelist[#embeddedfilelist+1] = r
+ end
+ end
+ end
+ --
+ local k = pdfarray()
+ local r = pdfreserveobject()
+ local t = usedlabels[tagnameused] or tagnameused
+ -- local a = nil
+ local d = pdfdictionary {
+ Type = pdf_struct_element,
+ S = pdfconstant(t),
+ ID = id,
+ T = detail and detail or nil,
+ P = parent.pref,
+ Pg = pageref,
+ K = pdfreference(r),
+ -- A = a and makeattribute(a) or nil,
+ A = attributes,
+ -- Alt = " Who cares ",
+ -- ActualText = " Hi Hans ",
+ AF = af,
+ }
+ local s = pdfreference(pdfflushobject(d))
+ if id and names then
+ names[id] = s
+ end
+ local kids = parent.kids
+ kids[#kids+1] = s
+ local e = {
+ tag = t,
+ pref = s,
+ kids = k,
+ knum = r,
+ pnum = pagenum
+ }
+ elements[fulltag] = e
+ return e
+end
+
+local f_BDC = formatters["/%s <> BDC"]
+
+local function makecontent(parent,id,specification)
+ local tag = parent.tag
+ local kids = parent.kids
+ local last = index
+ if id == "image" then
+ local list = specification.taglist
+ local data = usewithcare.images[list[#list]]
+ local label = data and data.label
+ local d = pdfdictionary {
+ Type = pdf_mcr,
+ Pg = pageref,
+ MCID = last,
+ Alt = pdfunicode(label ~= "" and label or "image"),
+ }
+ kids[#kids+1] = d
+ elseif pagenum == parent.pnum then
+ kids[#kids+1] = last
+ else
+ local d = pdfdictionary {
+ Type = pdf_mcr,
+ Pg = pageref,
+ MCID = last,
+ }
+ -- kids[#kids+1] = pdfreference(pdfflushobject(d))
+ kids[#kids+1] = d
+ end
+ --
+ index = index + 1
+ list[index] = parent.pref -- page related list
+ --
+ return f_BDC(tag,last)
+end
+
+local function makeignore(specification)
+ return "/Artifact BMC"
+end
+
+-- no need to adapt head, as we always operate on lists
+
+local EMCliteral = nil
+local visualize = nil
+
+function nodeinjections.addtags(head)
+
+ if not EMCliteral then
+ EMCliteral = register(setstate("EMC"))
+ end
+
+ local last = nil
+ local ranges = { }
+ local range = nil
+
+ if not root then
+ structure_kids = pdfarray()
+ structure_ref = pdfreserveobject()
+ parent_ref = pdfreserveobject()
+ root = { pref = pdfreference(structure_ref), kids = structure_kids }
+ names = pdfarray()
+ end
+
+ local function collectranges(head,list)
+ for n, id in nextnode, head do
+ if id == glyph_code then
+ -- maybe also disc
+if getchar(n) ~= 0 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
+ elseif range then
+ range[4] = n -- stop
+ end
+end
+ elseif id == hlist_code or id == vlist_code then
+ local at = getattr(n,a_image)
+ if at then
+ 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
+ last = nil
+ else
+ local list = getlist(n)
+ if list then
+ collectranges(list,n)
+ end
+ end
+ end
+ end
+ end
+
+ initializepage()
+
+ collectranges(head)
+
+-- inspect(taglist)
+-- inspect(ranges)
+
+ if trace_tags then
+ 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 tags = taglist[attr]
+ if tags then -- not ok ... only first lines
+ report_tags("%s => %s : %05i % t",tosequence(start,start),tosequence(stop,stop),attr,tags.taglist)
+ end
+ end
+ end
+
+ local top = nil
+ local noftop = 0
+
+ local function inject(start,stop,list,literal,left,right)
+ local prev = getprev(start)
+ if prev then
+ setlink(prev,literal)
+ end
+ if left then
+ setlink(literal,left,start)
+ else
+ setlink(literal,start)
+ end
+ if list and not prev then
+ setlist(list,literal)
+ end
+ local literal = copy_node(EMCliteral)
+ -- use insert instead:
+ local next = getnext(stop)
+ if next then
+ setlink(literal,next)
+ end
+ if right then
+ setlink(stop,right,literal)
+ else
+ setlink(stop,literal)
+ end
+ 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]
+
+ 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
+
+ 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
+ if prev then
+ literal = setstate(makecontent(prev,id,specification))
+ elseif ignore then
+ literal = setstate(makeignore(specification))
+ else
+ -- maybe also ignore or maybe better: comment or so
+ end
+
+ if literal then
+ local left,right
+ if trace_info then
+ local name = specification.tagname
+ if name then
+ if not visualize then
+ visualize = nodes.visualizers.register("tags")
+ end
+ left = visualize(name)
+ right = visualize()
+ end
+ end
+ inject(start,stop,list,literal,left,right)
+ end
+
+ top = taglist
+ noftop = noftags
+
+ else
+
+ local literal = setstate(makeignore(specification))
+
+ inject(start,stop,list,literal)
+
+ end
+
+ end
+
+ finishpage()
+
+ return head
+
+end
+
+-- variant: more structure but funny collapsing in viewer
+
+-- function nodeinjections.addtags(head)
+--
+-- local last, ranges, range = nil, { }, nil
+--
+-- local function collectranges(head,list)
+-- for n, id in nextnode, head do
+-- if id == glyph_code then
+-- local at = getattr(n,a_tagged)
+-- if not at then
+-- range = nil
+-- elseif last ~= at then
+-- range = { at, "glyph", n, n, list } -- attr id start stop list
+-- ranges[#ranges+1] = range
+-- last = at
+-- elseif range then
+-- range[4] = n -- stop
+-- end
+-- 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
+-- ranges[#ranges+1] = { at, "image", n, n, list } -- attr id start stop list
+-- end
+-- last = nil
+-- else
+-- local nl = getlist(n)
+-- collectranges(nl,n)
+-- end
+-- end
+-- end
+-- end
+--
+-- initializepage()
+--
+-- collectranges(head)
+--
+-- if trace_tags then
+-- 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 tags = taglist[attr]
+-- if tags then -- not ok ... only first lines
+-- report_tags("%s => %s : %05i % t",tosequence(start,start),tosequence(stop,stop),attr,tags.taglist)
+-- end
+-- end
+-- end
+--
+-- local top = nil
+-- local noftop = 0
+-- local last = nil
+--
+-- 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 tag = nil
+-- local common = 0
+-- -- local prev = root
+--
+-- 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
+--
+-- local result = { }
+-- local r = noftop - common
+-- if r > 0 then
+-- for i=1,r do
+-- result[i] = "EMC"
+-- end
+-- end
+--
+-- 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
+-- -- break
+-- -- elseif prv == true then
+-- -- -- skip this one
+-- -- else
+-- prev = prv
+-- r = r + 1
+-- result[r] = makecontent(prev,id)
+-- -- end
+-- end
+--
+-- if r > 0 then
+-- local literal = setstate(concat(result,"\n"))
+-- -- use insert instead:
+-- local literal = setstate(result)
+-- 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
+-- end
+--
+-- top = taglist
+-- noftop = noftags
+-- last = stop
+--
+-- end
+--
+-- if last and noftop > 0 then
+-- local result = { }
+-- for i=1,noftop do
+-- result[i] = "EMC"
+-- end
+-- local literal = setstate(concat(result,"\n"))
+-- -- use insert instead:
+-- local next = getnext(last)
+-- if next then
+-- setlink(literal,next)
+-- end
+-- setlink(last,literal)
+-- end
+--
+-- finishpage()
+--
+-- return head
+--
+-- end
+
+-- this belongs elsewhere (export is not pdf related)
+
+local permitted = true
+local enabled = false
+
+function codeinjections.settaggingsupport(option)
+ if option == false then
+ if enabled then
+ disableaction("shipouts","structures.tags.handler")
+ disableaction("shipouts","nodes.handlers.accessibility") -- maybe not this one
+ disableaction("math","noads.handlers.tags")
+ enabled = false
+ end
+ if permitted then
+ if trace_tags then
+ report_tags("blocking structure tags")
+ end
+ permitted = false
+ end
+ end
+end
+
+function codeinjections.enabletags()
+ if permitted and not enabled then
+ structures.tags.handler = nodeinjections.addtags
+ enableaction("shipouts","structures.tags.handler")
+ enableaction("shipouts","nodes.handlers.accessibility")
+ enableaction("math","noads.handlers.tags")
+ -- maybe also textblock
+ if trace_tags then
+ report_tags("enabling structure tags")
+ end
+ enabled = true
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-u3d.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-u3d.lmt
new file mode 100644
index 00000000000..6e02fde3044
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-u3d.lmt
@@ -0,0 +1,495 @@
+if not modules then modules = { } end modules ['lpdf-u3d'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- The following code is based on a working prototype provided
+-- by Michael Vidiassov. It is rewritten using the lpdf library
+-- and different checking is used. The macro calls are adapted
+-- (and will eventually be removed). The user interface needs
+-- an overhaul. There are some messy leftovers that will be
+-- removed in future versions.
+
+-- For some reason no one really tested this code so at some
+-- point we will end up with a reimplementation. For instance
+-- it makes sense to add the same activation code as with swf.
+
+local tonumber = tonumber
+local formatters, find = string.formatters, string.find
+local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs
+
+local backends, lpdf = backends, lpdf
+
+local nodeinjections = backends.pdf.nodeinjections
+
+local pdfconstant = lpdf.constant
+local pdfboolean = lpdf.boolean
+local pdfunicode = lpdf.unicode
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfnull = lpdf.null
+local pdfreference = lpdf.reference
+
+local pdfflushstreamobject
+local pdfflushstreamfileobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushstreamobject = lpdf.flushstreamobject
+ pdfflushstreamfileobject = lpdf.flushstreamfileobject
+end)
+
+local checkedkey = lpdf.checkedkey
+local limited = lpdf.limited
+
+local embedimage = images.embed
+
+local schemes = table.tohash {
+ "Artwork", "None", "White", "Day", "Night", "Hard",
+ "Primary", "Blue", "Red", "Cube", "CAD", "Headlamp",
+}
+
+local modes = table.tohash {
+ "Solid", "SolidWireframe", "Transparent", "TransparentWireframe", "BoundingBox",
+ "TransparentBoundingBox", "TransparentBoundingBoxOutline", "Wireframe",
+ "ShadedWireframe", "HiddenWireframe", "Vertices", "ShadedVertices", "Illustration",
+ "SolidOutline", "ShadedIllustration",
+}
+
+local function normalize(x, y, z)
+ local modulo = sqrt(x*x + y*y + z*z);
+ if modulo ~= 0 then
+ return x/modulo, y/modulo, z/modulo
+ else
+ return x, y, z
+ end
+end
+
+local function rotate(vect_x,vect_y,vect_z, tet, axis_x,axis_y,axis_z)
+ -- rotate vect by tet about axis counterclockwise
+ local c, s = cos(tet*pi/180), sin(tet*pi/180)
+ local r = 1 - c
+ local n = sqrt(axis_x*axis_x+axis_y*axis_y+axis_z*axis_z)
+ axis_x, axis_y, axis_z = axis_x/n, axis_y/n, axis_z/n
+ return
+ (axis_x*axis_x*r+c )*vect_x + (axis_x*axis_y*r-axis_z*s)*vect_y + (axis_x*axis_z*r+axis_y*s)*vect_z,
+ (axis_x*axis_y*r+axis_z*s)*vect_x + (axis_y*axis_y*r+c )*vect_y + (axis_y*axis_z*r-axis_x*s)*vect_z,
+ (axis_x*axis_z*r-axis_y*s)*vect_x + (axis_y*axis_z*r+axis_x*s)*vect_y + (axis_z*axis_z*r+c )*vect_z
+end
+
+local function make3dview(view)
+
+ local name = view.name
+ local name = pdfunicode(name ~= "" and name or "unknown view")
+
+ local viewdict = pdfdictionary {
+ Type = pdfconstant("3DView"),
+ XN = name,
+ IN = name,
+ NR = true,
+ }
+
+ local bg = checkedkey(view,"bg","table")
+ if bg then
+ viewdict.BG = pdfdictionary {
+ Type = pdfconstant("3DBG"),
+ C = pdfarray { limited(bg[1],1,1,1), limited(bg[2],1,1,1), limited(bg[3],1,1,1) },
+ }
+ end
+
+ local lights = checkedkey(view,"lights","string")
+ if lights and schemes[lights] then
+ viewdict.LS = pdfdictionary {
+ Type = pdfconstant("3DLightingScheme"),
+ Subtype = pdfconstant(lights),
+ }
+ end
+
+ -- camera position is taken from 3d model
+
+ local u3dview = checkedkey(view, "u3dview", "string")
+ if u3dview then
+ viewdict.MS = pdfconstant("U3D")
+ viewdict.U3DPath = u3dview
+ end
+
+ -- position the camera as given
+
+ local c2c = checkedkey(view, "c2c", "table")
+ local coo = checkedkey(view, "coo", "table")
+ local roo = checkedkey(view, "roo", "number")
+ local azimuth = checkedkey(view, "azimuth", "number")
+ local altitude = checkedkey(view, "altitude", "number")
+
+ if c2c or coo or roo or azimuth or altitude then
+
+ local pos = checkedkey(view, "pos", "table")
+ local dir = checkedkey(view, "dir", "table")
+ local upv = checkedkey(view, "upv", "table")
+ local roll = checkedkey(view, "roll", "table")
+
+ local coo_x, coo_y, coo_z = 0, 0, 0
+ local dir_x, dir_y, dir_z = 0, 0, 0
+ local trans_x, trans_y, trans_z = 0, 0, 0
+ local left_x, left_y, left_z = 0, 0, 0
+ local up_x, up_y, up_z = 0, 0, 0
+
+ -- point camera is aimed at
+
+ if coo then
+ coo_x, coo_y, coo_z = tonumber(coo[1]) or 0, tonumber(coo[2]) or 0, tonumber(coo[3]) or 0
+ end
+
+ -- distance from camera to target
+
+ if roo then
+ roo = abs(roo)
+ end
+ if not roo or roo == 0 then
+ roo = 0.000000000000000001
+ end
+
+ -- set it via camera position
+
+ if pos then
+ dir_x = coo_x - (tonumber(pos[1]) or 0)
+ dir_y = coo_y - (tonumber(pos[2]) or 0)
+ dir_z = coo_z - (tonumber(pos[3]) or 0)
+ if not roo then
+ roo = sqrt(dir_x*dir_x + dir_y*dir_y + dir_z*dir_z)
+ end
+ if dir_x == 0 and dir_y == 0 and dir_z == 0 then dir_y = 1 end
+ dir_x, dir_y, dir_z = normalize(dir_x,dir_y,dir_z)
+ end
+
+ -- set it directly
+
+ if dir then
+ dir_x, dir_y, dir_z = tonumber(dir[1] or 0), tonumber(dir[2] or 0), tonumber(dir[3] or 0)
+ if dir_x == 0 and dir_y == 0 and dir_z == 0 then dir_y = 1 end
+ dir_x, dir_y, dir_z = normalize(dir_x,dir_y,dir_z)
+ end
+
+ -- set it movie15 style with vector from target to camera
+
+ if c2c then
+ dir_x, dir_y, dir_z = - tonumber(c2c[1] or 0), - tonumber(c2c[2] or 0), - tonumber(c2c[3] or 0)
+ if dir_x == 0 and dir_y == 0 and dir_z == 0 then dir_y = 1 end
+ dir_x, dir_y, dir_z = normalize(dir_x,dir_y,dir_z)
+ end
+
+ -- set it with azimuth and altitutde
+
+ if altitude or azimuth then
+ dir_x, dir_y, dir_z = -1, 0, 0
+ if altitude then dir_x, dir_y, dir_z = rotate(dir_x,dir_y,dir_z, -altitude, 0,1,0) end
+ if azimuth then dir_x, dir_y, dir_z = rotate(dir_x,dir_y,dir_z, azimuth, 0,0,1) end
+ end
+
+ -- set it with rotation like in MathGL
+
+ if rot then
+ if dir_x == 0 and dir_y == 0 and dir_z == 0 then dir_z = -1 end
+ dir_x,dir_y,dir_z = rotate(dir_x,dir_y,dir_z, tonumber(rot[1]) or 0, 1,0,0)
+ dir_x,dir_y,dir_z = rotate(dir_x,dir_y,dir_z, tonumber(rot[2]) or 0, 0,1,0)
+ dir_x,dir_y,dir_z = rotate(dir_x,dir_y,dir_z, tonumber(rot[3]) or 0, 0,0,1)
+ end
+
+ -- set it with default movie15 orientation looking up y axis
+
+ if dir_x == 0 and dir_y == 0 and dir_z == 0 then dir_y = 1 end
+
+ -- left-vector
+ -- up-vector
+
+ if upv then
+ up_x, up_y, up_z = tonumber(upv[1]) or 0, tonumber(upv[2]) or 0, tonumber(upv[3]) or 0
+ else
+ -- set default up-vector
+ if abs(dir_x) == 0 and abs(dir_y) == 0 then
+ if dir_z < 0 then
+ up_y = 1 -- top view
+ else
+ up_y = -1 -- bottom view
+ end
+ else
+ -- other camera positions than top and bottom, up-vector = up_world - (up_world dot dir) dir
+ up_x, up_y, up_z = - dir_z*dir_x, - dir_z*dir_y, - dir_z*dir_z + 1
+ end
+ end
+
+ -- normalize up-vector
+
+ up_x, up_y, up_z = normalize(up_x,up_y,up_z)
+
+ -- left vector = up x dir
+
+ left_x, left_y, left_z = dir_z*up_y - dir_y*up_z, dir_x*up_z - dir_z*up_x, dir_y*up_x - dir_x*up_y
+
+ -- normalize left vector
+
+ left_x, left_y, left_z = normalize(left_x,left_y,left_z)
+
+ -- apply camera roll
+
+ if roll then
+ local sinroll = sin((roll/180.0)*pi)
+ local cosroll = cos((roll/180.0)*pi)
+ left_x = left_x*cosroll + up_x*sinroll
+ left_y = left_y*cosroll + up_y*sinroll
+ left_z = left_z*cosroll + up_z*sinroll
+ up_x = up_x*cosroll + left_x*sinroll
+ up_y = up_y*cosroll + left_y*sinroll
+ up_z = up_z*cosroll + left_z*sinroll
+ end
+
+ -- translation vector
+
+ trans_x, trans_y, trans_z = coo_x - roo*dir_x, coo_y - roo*dir_y, coo_z - roo*dir_z
+
+ viewdict.MS = pdfconstant("M")
+ viewdict.CO = roo
+ viewdict.C2W = pdfarray {
+ left_x, left_y, left_z,
+ up_x, up_y, up_z,
+ dir_x, dir_y, dir_z,
+ trans_x, trans_y, trans_z,
+ }
+
+ end
+
+ local aac = tonumber(view.aac) -- perspective projection
+ local mag = tonumber(view.mag) -- ortho projection
+
+ if aac and aac > 0 and aac < 180 then
+ viewdict.P = pdfdictionary {
+ Subtype = pdfconstant("P"),
+ PS = pdfconstant("Min"),
+ FOV = aac,
+ }
+ elseif mag and mag > 0 then
+ viewdict.P = pdfdictionary {
+ Subtype = pdfconstant("O"),
+ OS = mag,
+ }
+ end
+
+ local mode = modes[view.rendermode]
+ if mode then
+ pdfdictionary {
+ Type = pdfconstant("3DRenderMode"),
+ Subtype = pdfconstant(mode),
+ }
+ end
+
+ -- crosssection
+
+ local crosssection = checkedkey(view,"crosssection","table")
+ if crosssection then
+ local crossdict = pdfdictionary {
+ Type = pdfconstant("3DCrossSection")
+ }
+
+ local c = checkedkey(crosssection,"point","table") or checkedkey(crosssection,"center","table")
+ if c then
+ crossdict.C = pdfarray { tonumber(c[1]) or 0, tonumber(c[2]) or 0, tonumber(c[3]) or 0 }
+ end
+
+ local normal = checkedkey(crosssection,"normal","table")
+ if normal then
+ local x, y, z = tonumber(normal[1] or 0), tonumber(normal[2] or 0), tonumber(normal[3] or 0)
+ if sqrt(x*x + y*y + z*z) == 0 then
+ x, y, z = 1, 0, 0
+ end
+ crossdict.O = pdfarray {
+ pdfnull,
+ atan2(-z,sqrt(x*x + y*y))*180/pi,
+ atan2(y,x)*180/pi,
+ }
+ end
+
+ local orient = checkedkey(crosssection,"orient","table")
+ if orient then
+ crossdict.O = pdfarray {
+ tonumber(orient[1]) or 1,
+ tonumber(orient[2]) or 0,
+ tonumber(orient[3]) or 0,
+ }
+ end
+
+ crossdict.IV = cross.intersection or false
+ crossdict.ST = cross.transparent or false
+
+ viewdict.SA = next(crossdict) and pdfarray { crossdict } -- maybe test if # > 1
+ end
+
+ local nodes = checkedkey(view,"nodes","table")
+ if nodes then
+ local nodelist = pdfarray()
+ for i=1,#nodes do
+ local node = checkedkey(nodes,i,"table")
+ if node then
+ local position = checkedkey(node,"position","table")
+ nodelist[#nodelist+1] = pdfdictionary {
+ Type = pdfconstant("3DNode"),
+ N = node.name or ("node_" .. i), -- pdfunicode ?
+ M = position and #position == 12 and pdfarray(position),
+ V = node.visible or true,
+ O = node.opacity or 0,
+ RM = pdfdictionary {
+ Type = pdfconstant("3DRenderMode"),
+ Subtype = pdfconstant(node.rendermode or "Solid"),
+ },
+ }
+ end
+ end
+ viewdict.NA = nodelist
+ end
+
+ return viewdict
+
+end
+
+local stored_js, stored_3d, stored_pr, streams = { }, { }, { }, { }
+
+local f_image = formatters["q /GS gs %.6N 0 0 %.6N 0 0 cm /IM Do Q"]
+
+local function insert3d(spec) -- width, height, factor, display, controls, label, foundname
+
+ local width, height, factor = spec.width, spec.height, spec.factor or number.dimenfactors.bp
+ local display, controls, label, foundname = spec.display, spec.controls, spec.label, spec.foundname
+
+ local param = (display and parametersets[display]) or { }
+ local streamparam = (controls and parametersets[controls]) or { }
+ local name = "3D Artwork " .. (param.name or label or "Unknown")
+
+ local activationdict = pdfdictionary {
+ TB = pdfboolean(param.toolbar,true),
+ NP = pdfboolean(param.tree,false),
+ }
+
+ local stream = streams[label]
+ if not stream then
+
+ local subtype, subdata = "U3D", io.loaddata(foundname) or ""
+ if find(subdata,"^PRC") then
+ subtype = "PRC"
+ elseif find(subdata,"^U3D") then
+ subtype = "U3D"
+ elseif file.suffix(foundname) == "prc" then
+ subtype = "PRC"
+ end
+
+ local attr = pdfdictionary {
+ Type = pdfconstant("3D"),
+ Subtype = pdfconstant(subtype),
+ }
+ local streamviews = checkedkey(streamparam, "views", "table")
+ if streamviews then
+ local list = pdfarray()
+ for i=1,#streamviews do
+ local v = checkedkey(streamviews, i, "table")
+ if v then
+ list[#list+1] = make3dview(v)
+ end
+ end
+ attr.VA = list
+ end
+ if checkedkey(streamparam, "view", "table") then
+ attr.DV = make3dview(streamparam.view)
+ elseif checkedkey(streamparam, "view", "string") then
+ attr.DV = streamparam.view
+ end
+ local js = checkedkey(streamparam, "js", "string")
+ if js then
+ local jsref = stored_js[js]
+ if not jsref then
+ jsref = pdfflushstreamfileobject(js)
+ stored_js[js] = jsref
+ end
+ attr.OnInstantiate = pdfreference(jsref)
+ end
+ stored_3d[label] = pdfflushstreamfileobject(foundname,attr)
+ stream = 1
+ else
+ stream = stream + 1
+ end
+ streams[label] = stream
+
+ local name = pdfunicode(name)
+
+ local annot = pdfdictionary {
+ Subtype = pdfconstant("3D"),
+ T = name,
+ Contents = name,
+ NM = name,
+ ["3DD"] = pdfreference(stored_3d[label]),
+ ["3DA"] = activationdict,
+ }
+ if checkedkey(param,"view","table") then
+ annot["3DV"] = make3dview(param.view)
+ elseif checkedkey(param,"view","string") then
+ annot["3DV"] = param.view
+ end
+
+ local preview = checkedkey(param,"preview","string")
+ if preview then
+ activationdict.A = pdfconstant("XA")
+ local tag = formatters["%s:%s:%s"](label,stream,preview)
+ local ref = stored_pr[tag]
+ if not ref then
+ local figure = embedimage {
+ filename = preview,
+ width = width,
+ height = height
+ }
+ ref = figure.objnum
+ stored_pr[tag] = ref
+ end
+ if ref then -- see back-pdf ** .. here we have a local /IM !
+ local pw = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Form"),
+ FormType = 1,
+ BBox = pdfarray { 0, 0, pdfnumber(factor*width), pdfnumber(factor*height) },
+ Matrix = pdfarray { 1, 0, 0, 1, 0, 0 },
+ ProcSet = lpdf.procset(),
+ Resources = pdfdictionary {
+ XObject = pdfdictionary {
+ IM = pdfreference(ref)
+ }
+ },
+ ExtGState = pdfdictionary {
+ GS = pdfdictionary {
+ Type = pdfconstant("ExtGState"),
+ CA = 1,
+ ca = 1,
+ }
+ },
+ }
+ local pwd = pdfflushstreamobject(f_image(factor*width,factor*height),pw)
+ annot.AP = pdfdictionary {
+ N = pdfreference(pwd)
+ }
+ end
+ return annot, figure, ref
+ else
+ activationdict.A = pdfconstant("PV")
+ return annot, nil, nil
+ end
+end
+
+function nodeinjections.insertu3d(spec)
+ local annotation, preview, ref = insert3d { -- just spec
+ foundname = spec.foundname,
+ width = spec.width,
+ height = spec.height,
+ factor = spec.factor,
+ display = spec.display,
+ controls = spec.controls,
+ label = spec.label,
+ }
+ node.write(nodeinjections.annotation(spec.width,spec.height,0,annotation()))
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-wid.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-wid.lmt
new file mode 100644
index 00000000000..268ca119e02
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-wid.lmt
@@ -0,0 +1,789 @@
+if not modules then modules = { } end modules ['lpdf-wid'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- It's about time to give up on media in pdf and admit that pdf lost it to html.
+-- First we had movies and sound, quite easy to deal with, but obsolete now. Then we
+-- 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 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 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
+-- (even simple like starting and stopping videos) one has to revert to JavaScript,
+-- the other fragile bit. And, now that adobe quits flash in 2020 we're without any
+-- video anyway. Also, it won't play on all platforms and devices so let's wait for
+-- html5 media in pdf then.
+
+local tonumber, next = tonumber, next
+local gmatch, gsub, find, lower = string.gmatch, string.gsub, string.find, string.lower
+local filenameonly, basefilename, filesuffix, addfilesuffix = file.nameonly, file.basename, file.suffix, file.addsuffix
+local isfile, modificationtime = lfs.isfile, lfs.modification
+local stripstring = string.strip
+local settings_to_array = utilities.parsers.settings_to_array
+local settings_to_hash = utilities.parsers.settings_to_hash
+local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys
+
+local report_media = logs.reporter("backend","media")
+local report_attachment = logs.reporter("backend","attachment")
+
+local backends = backends
+local lpdf = lpdf
+local nodes = nodes
+local context = context
+
+local texgetcount = tex.getcount
+
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
+
+local executers = structures.references.executers
+local variables = interfaces.variables
+
+local v_hidden = variables.hidden
+local v_auto = variables.auto
+local v_embed = variables.embed
+local v_max = variables.max
+local v_yes = variables.yes
+
+local pdfconstant = lpdf.constant
+local pdfnull = lpdf.null
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfstring = lpdf.string
+local pdfboolean = lpdf.boolean
+local pdfaction = lpdf.action
+local pdfborder = lpdf.border
+
+local pdftransparencyvalue = lpdf.transparencyvalue
+local pdfcolorvalues = lpdf.colorvalues
+
+local pdfflushobject
+local pdfflushstreamobject
+local pdfflushstreamfileobject
+local pdfreserveobject
+local pdfpagereference
+local pdfshareobjectreference
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushobject = lpdf.flushobject
+ pdfflushstreamobject = lpdf.flushstreamobject
+ pdfflushstreamfileobject = lpdf.flushstreamfileobject
+ pdfreserveobject = lpdf.reserveobject
+ pdfpagereference = lpdf.pagereference
+ pdfshareobjectreference = lpdf.shareobjectreference
+end)
+
+
+local hpack_node = node.hpack
+local write_node = node.write -- test context(...) instead
+
+-- symbols
+
+local presets = { } -- xforms
+
+local function registersymbol(name,n)
+ presets[name] = pdfreference(n)
+end
+
+local function registeredsymbol(name)
+ return presets[name]
+end
+
+local function presetsymbol(symbol)
+ if not presets[symbol] then
+ context.predefinesymbol { symbol }
+ end
+end
+
+local function presetsymbollist(list)
+ if list then
+ for symbol in gmatch(list,"[^, ]+") do
+ presetsymbol(symbol)
+ end
+ end
+end
+
+codeinjections.registersymbol = registersymbol
+codeinjections.registeredsymbol = registeredsymbol
+codeinjections.presetsymbol = presetsymbol
+codeinjections.presetsymbollist = presetsymbollist
+
+-- comments
+
+-- local symbols = {
+-- Addition = pdfconstant("NewParagraph"),
+-- Attachment = pdfconstant("Attachment"),
+-- Balloon = pdfconstant("Comment"),
+-- Check = pdfconstant("Check Mark"),
+-- CheckMark = pdfconstant("Check Mark"),
+-- Circle = pdfconstant("Circle"),
+-- Cross = pdfconstant("Cross"),
+-- CrossHairs = pdfconstant("Cross Hairs"),
+-- Graph = pdfconstant("Graph"),
+-- InsertText = pdfconstant("Insert Text"),
+-- New = pdfconstant("Insert"),
+-- Paperclip = pdfconstant("Paperclip"),
+-- RightArrow = pdfconstant("Right Arrow"),
+-- RightPointer = pdfconstant("Right Pointer"),
+-- Star = pdfconstant("Star"),
+-- Tag = pdfconstant("Tag"),
+-- Text = pdfconstant("Note"),
+-- TextNote = pdfconstant("Text Note"),
+-- UpArrow = pdfconstant("Up Arrow"),
+-- UpLeftArrow = pdfconstant("Up-Left Arrow"),
+-- }
+
+local attachment_symbols = {
+ Graph = pdfconstant("Graph"),
+ Paperclip = pdfconstant("Paperclip"),
+ Pushpin = pdfconstant("PushPin"),
+}
+
+attachment_symbols.PushPin = attachment_symbols.Pushpin
+attachment_symbols.Default = attachment_symbols.Pushpin
+
+function lpdf.attachmentsymbols()
+ return sortedkeys(comment_symbols)
+end
+
+local comment_symbols = {
+ Comment = pdfconstant("Comment"),
+ Help = pdfconstant("Help"),
+ Insert = pdfconstant("Insert"),
+ Key = pdfconstant("Key"),
+ Newparagraph = pdfconstant("NewParagraph"),
+ Note = pdfconstant("Note"),
+ Paragraph = pdfconstant("Paragraph"),
+}
+
+comment_symbols.NewParagraph = Newparagraph
+comment_symbols.Default = Note
+
+function lpdf.commentsymbols()
+ return sortedkeys(comment_symbols)
+end
+
+local function analyzesymbol(symbol,collection)
+ if not symbol or symbol == "" then
+ return collection and collection.Default, nil
+ elseif collection and collection[symbol] then
+ return collection[symbol], nil
+ else
+ local setn, setr, setd
+ local set = settings_to_array(symbol)
+ if #set == 1 then
+ setn, setr, setd = set[1], set[1], set[1]
+ elseif #set == 2 then
+ setn, setr, setd = set[1], set[1], set[2]
+ else
+ setn, setr, setd = set[1], set[2], set[3]
+ end
+ local appearance = pdfdictionary {
+ N = setn and registeredsymbol(setn),
+ R = setr and registeredsymbol(setr),
+ D = setd and registeredsymbol(setd),
+ }
+ local appearanceref = pdfshareobjectreference(appearance)
+ return nil, appearanceref
+ end
+end
+
+local function analyzenormalsymbol(symbol)
+ local appearance = pdfdictionary {
+ N = registeredsymbol(symbol),
+ }
+ local appearanceref = pdfshareobjectreference(appearance)
+ return appearanceref
+end
+
+codeinjections.analyzesymbol = analyzesymbol
+codeinjections.analyzenormalsymbol = analyzenormalsymbol
+
+local function analyzelayer(layer)
+ -- todo: (specification.layer ~= "" and pdfreference(specification.layer)) or nil, -- todo: ref to layer
+end
+
+local function analyzecolor(colorvalue,colormodel)
+ local cvalue = colorvalue and tonumber(colorvalue)
+ local cmodel = colormodel and tonumber(colormodel) or 3
+ return cvalue and pdfarray { pdfcolorvalues(cmodel,cvalue) } or nil
+end
+
+local function analyzetransparency(transparencyvalue)
+ local tvalue = transparencyvalue and tonumber(transparencyvalue)
+ return tvalue and pdftransparencyvalue(tvalue) or nil
+end
+
+-- Attachments
+
+local nofattachments = 0
+local attachments = { }
+local filestreams = { }
+local referenced = { }
+local ignorereferenced = true -- fuzzy pdf spec .. twice in attachment list, can become an option
+local tobesavedobjrefs = utilities.storage.allocate()
+local collectedobjrefs = utilities.storage.allocate()
+local permitted = true
+local enabled = true
+
+function codeinjections.setattachmentsupport(option)
+ if option == false then
+ permitted = false
+ enabled = false
+ end
+end
+
+local fileobjreferences = {
+ collected = collectedobjrefs,
+ tobesaved = tobesavedobjrefs,
+}
+
+job.fileobjreferences = fileobjreferences
+
+local function initializer()
+ collectedobjrefs = job.fileobjreferences.collected or { }
+ tobesavedobjrefs = job.fileobjreferences.tobesaved or { }
+end
+
+job.register('job.fileobjreferences.collected', tobesavedobjrefs, initializer)
+
+local function flushembeddedfiles()
+ if enabled and next(filestreams) then
+ local e = pdfarray()
+ local f = pdfarray()
+ for tag, reference in sortedhash(filestreams) do
+ if not reference then
+ report_attachment("unreferenced file, tag %a",tag)
+ elseif referenced[tag] == "hidden" then
+ e[#e+1] = pdfstring(tag)
+ e[#e+1] = reference -- already a reference
+ f[#f+1] = reference -- collect all file description references
+ else
+ -- messy spec ... when annot not in named else twice in menu list acrobat
+ f[#f+1] = reference
+ end
+ end
+ if #e > 0 then
+ lpdf.addtonames("EmbeddedFiles",pdfreference(pdfflushobject(pdfdictionary{ Names = e })))
+ end
+ if #f > 0 then -- PDF/A-2|3: all associated files must have a relationship to the PDF document (global or part)
+ lpdf.addtocatalog("AF", pdfreference(pdfflushobject(f))) -- global (Catalog)
+ end
+ end
+end
+
+lpdf.registerdocumentfinalizer(flushembeddedfiles,"embeddedfiles")
+
+function codeinjections.embedfile(specification)
+ if enabled then
+ local data = specification.data
+ local filename = specification.file
+ local name = specification.name or ""
+ local title = specification.title or ""
+ local hash = specification.hash or filename
+ local keepdir = specification.keepdir -- can change
+ local usedname = specification.usedname
+ local filetype = specification.filetype
+ local compress = specification.compress
+ local mimetype = specification.mimetype or specification.mime
+ if filename == "" then
+ filename = nil
+ end
+ if compress == nil then
+ compress = true
+ end
+ if data then
+ local r = filestreams[hash]
+ if r == false then
+ return nil
+ elseif r then
+ return r
+ elseif not filename then
+ filename = specification.tag
+ if not filename or filename == "" then
+ filename = specification.registered
+ end
+ if not filename or filename == "" then
+ filename = hash
+ end
+ end
+ else
+ if not filename then
+ return nil
+ end
+ local r = filestreams[hash]
+ if r == false then
+ return nil
+ elseif r then
+ return r
+ else
+ local foundname = resolvers.findbinfile(filename) or ""
+ if foundname == "" or not isfile(foundname) then
+ filestreams[filename] = false
+ return nil
+ else
+ specification.foundname = foundname
+ end
+ end
+ end
+ -- needs to be cleaned up:
+ usedname = usedname ~= "" and usedname or filename or name
+ local basename = keepdir == true and usedname or basefilename(usedname)
+ local basename = gsub(basename,"%./","")
+ local savename = name ~= "" and name or basename
+ local foundname = specification.foundname or filename
+ if not filetype or filetype == "" then
+ filetype = name and (filename and filesuffix(filename)) or "txt"
+ end
+ savename = addfilesuffix(savename,filetype) -- type is mandate for proper working in viewer
+ local a = pdfdictionary {
+ Type = pdfconstant("EmbeddedFile"),
+ Subtype = mimetype and mimetype ~= "" and pdfconstant(mimetype) or nil,
+ }
+ local f
+ if data then
+ f = pdfflushstreamobject(data,a)
+ specification.data = true -- signal that still data but already flushed
+ else
+ local attributes = lfs.attributes(foundname)
+ local modification = modificationtime(foundname)
+ a.Params = {
+ Size = attributes.size,
+ ModDate = lpdf.pdftimestamp(modification),
+ }
+ f = pdfflushstreamfileobject(foundname,a,compress)
+ end
+ local d = pdfdictionary {
+ Type = pdfconstant("Filespec"),
+ F = pdfstring(savename),
+ -- UF = pdfstring(savename),
+ UF = pdfunicode(savename),
+ EF = pdfdictionary { F = pdfreference(f) },
+ Desc = title ~= "" and pdfunicode(title) or nil,
+ AFRelationship = pdfconstant("Unspecified"), -- Supplement, Data, Source, Alternative, Data
+ }
+ local r = pdfreference(pdfflushobject(d))
+ filestreams[hash] = r
+ return r
+ end
+end
+
+function nodeinjections.attachfile(specification)
+ if enabled then
+ local registered = specification.registered or ""
+ local data = specification.data
+ local hash
+ local filename
+ if data then
+ hash = md5.HEX(data)
+ else
+ filename = specification.file
+ if not filename or filename == "" then
+ report_attachment("no file specified, using registered %a instead",registered)
+ filename = registered
+ specification.file = registered
+ end
+ local foundname = resolvers.findbinfile(filename) or ""
+ if foundname == "" or not isfile(foundname) then
+ report_attachment("invalid filename %a, ignoring registered %a",filename,registered)
+ return nil
+ else
+ specification.foundname = foundname
+ end
+ hash = filename
+ end
+ specification.hash = hash
+ nofattachments = nofattachments + 1
+ local registered = specification.registered or ""
+ local title = specification.title or ""
+ local subtitle = specification.subtitle or ""
+ local author = specification.author or ""
+ local onlyname = filename and filenameonly(filename) or ""
+ if registered == "" then
+ registered = filename
+ end
+ if author == "" and title ~= "" then
+ author = title
+ title = onlyname or ""
+ end
+ if author == "" then
+ author = onlyname or ""
+ end
+ if title == "" then
+ title = registered
+ end
+ if title == "" and filename then
+ title = onlyname
+ end
+ local aref = attachments[registered]
+ if not aref then
+ aref = codeinjections.embedfile(specification)
+ attachments[registered] = aref
+ end
+ local reference = specification.reference
+ if reference and aref then
+ tobesavedobjrefs[reference] = aref[1]
+ end
+ if not aref then
+ report_attachment("skipping attachment, registered %a",registered)
+ -- already reported
+ elseif specification.method == v_hidden then
+ referenced[hash] = "hidden"
+ else
+ referenced[hash] = "annotation"
+ local name, appearance = analyzesymbol(specification.symbol,attachment_symbols)
+ local flags = specification.flags or 0 -- to keep it expandable
+ local d = pdfdictionary {
+ Subtype = pdfconstant("FileAttachment"),
+ FS = aref,
+ Contents = pdfunicode(title),
+ Name = name,
+ NM = pdfstring("attachment:"..nofattachments),
+ T = author ~= "" and pdfunicode(author) or nil,
+ Subj = subtitle ~= "" and pdfunicode(subtitle) or nil,
+ C = analyzecolor(specification.colorvalue,specification.colormodel),
+ CA = analyzetransparency(specification.transparencyvalue),
+ AP = appearance,
+ OC = analyzelayer(specification.layer),
+ -- F = pdfnull(), -- another rediculous need to satisfy validation
+ F = bit32.band(bit32.bor(flags,4),(1023-1-2-32-256)), -- set 3, clear 1,2,6,9; PDF 32000-1, p385
+ }
+ local width = specification.width or 0
+ local height = specification.height or 0
+ local depth = specification.depth or 0
+ local box = hpack_node(nodeinjections.annotation(width,height,depth,d()))
+ box.width = width
+ box.height = height
+ box.depth = depth
+ return box
+ end
+ end
+end
+
+function codeinjections.attachmentid(filename) -- not used in context
+ return filestreams[filename]
+end
+
+-- Comments
+
+local nofcomments = 0
+local usepopupcomments = false
+
+local defaultattributes = {
+ ["xmlns"] = "http://www.w3.org/1999/xhtml",
+ ["xmlns:xfa"] = "http://www.xfa.org/schema/xfa-data/1.0/",
+ ["xfa:contentType"] = "text/html",
+ ["xfa:APIVersion"] = "Acrobat:8.0.0",
+ ["xfa:spec"] = "2.4",
+}
+
+local function checkcontent(text,option)
+ if option and option.xml then
+ local root = xml.convert(text)
+ if root and not root.er then
+ xml.checkbom(root)
+ local body = xml.first(root,"/body")
+ if body then
+ local at = body.at
+ for k, v in next, defaultattributes do
+ if not at[k] then
+ at[k] = v
+ end
+ end
+ -- local content = xml.textonly(root)
+ local richcontent = xml.tostring(root)
+ return nil, pdfunicode(richcontent)
+ end
+ end
+ end
+ return pdfunicode(text)
+end
+
+function nodeinjections.comment(specification) -- brrr: seems to be done twice
+ nofcomments = nofcomments + 1
+ local text = specification.data or ""
+ if specification.space ~= v_yes then
+ text = stripstring(text)
+ text = gsub(text,"[\n\r] *","\n")
+ end
+ text = gsub(text,"\r","\n")
+ local name, appearance = analyzesymbol(specification.symbol,comment_symbols)
+ local tag = specification.tag or "" -- this is somewhat messy as recent
+ local title = specification.title or "" -- versions of acrobat see the title
+ local subtitle = specification.subtitle or "" -- as author
+ local author = specification.author or ""
+ local option = settings_to_hash(specification.option or "")
+ if author ~= "" then
+ if subtitle == "" then
+ subtitle = title
+ elseif title ~= "" then
+ subtitle = subtitle .. ", " .. title
+ end
+ title = author
+ end
+ if title == "" then
+ title = tag
+ end
+ local content, richcontent = checkcontent(text,option)
+ local d = pdfdictionary {
+ Subtype = pdfconstant("Text"),
+ Open = option[v_max] and pdfboolean(true) or nil,
+ Contents = content,
+ RC = richcontent,
+ T = title ~= "" and pdfunicode(title) or nil,
+ Subj = subtitle ~= "" and pdfunicode(subtitle) or nil,
+ C = analyzecolor(specification.colorvalue,specification.colormodel),
+ CA = analyzetransparency(specification.transparencyvalue),
+ OC = analyzelayer(specification.layer),
+ Name = name,
+ NM = pdfstring("comment:"..nofcomments),
+ AP = appearance,
+ }
+ local width = specification.width or 0
+ local height = specification.height or 0
+ local depth = specification.depth or 0
+ local box
+ if usepopupcomments then
+ -- rather useless as we can hide/vide
+ local nd = pdfreserveobject()
+ local nc = pdfreserveobject()
+ local c = pdfdictionary {
+ Subtype = pdfconstant("Popup"),
+ Parent = pdfreference(nd),
+ }
+ d.Popup = pdfreference(nc)
+ box = hpack_node(
+ nodeinjections.annotation(0,0,0,d(),nd),
+ nodeinjections.annotation(width,height,depth,c(),nc)
+ )
+ else
+ box = hpack_node(nodeinjections.annotation(width,height,depth,d()))
+ end
+ box.width = width -- redundant
+ box.height = height -- redundant
+ box.depth = depth -- redundant
+ return box
+end
+
+-- rendering stuff
+--
+-- object_1 -> <> >>
+-- object_2 -> <> >>
+-- rendering -> <>
+--
+-- we only work foreward here (currently)
+-- annotation is to be packed at the tex end
+
+-- aiff audio/aiff
+-- au audio/basic
+-- avi video/avi
+-- mid audio/midi
+-- mov video/quicktime
+-- mp3 audio/x-mp3 (mpeg)
+-- mp4 audio/mp4
+-- mp4 video/mp4
+-- mpeg video/mpeg
+-- smil application/smil
+-- swf application/x-shockwave-flash
+
+-- P media play parameters (evt /BE for controls etc
+-- A boolean (audio)
+-- C boolean (captions)
+-- O boolean (overdubs)
+-- S boolean (subtitles)
+-- PL pdfconstant("ADBE_MCI"),
+
+-- F = flags,
+-- T = title,
+-- Contents = rubish,
+-- AP = irrelevant,
+
+-- sound is different, no window (or zero) so we need to collect them and
+-- force them if not set
+
+local ms, mu, mf = { }, { }, { }
+
+local function delayed(label)
+ local a = pdfreserveobject()
+ mu[label] = a
+ return pdfreference(a)
+end
+
+local function insertrenderingwindow(specification)
+ local label = specification.label
+ -- local openpage = specification.openpage
+ -- local closepage = specification.closepage
+ if specification.option == v_auto then
+ if openpageaction then
+ -- \handlereferenceactions{\v!StartRendering{#2}}
+ end
+ if closepageaction then
+ -- \handlereferenceactions{\v!StopRendering {#2}}
+ end
+ end
+ local actions = nil
+ if openpage or closepage then
+ actions = pdfdictionary {
+ PO = (openpage and lpdfaction(openpage )) or nil,
+ PC = (closepage and lpdfaction(closepage)) or nil,
+ }
+ end
+ local page = tonumber(specification.page) or texgetcount("realpageno") -- todo
+ local r = mu[label] or pdfreserveobject() -- why the reserve here?
+ local a = pdfdictionary {
+ S = pdfconstant("Rendition"),
+ R = mf[label],
+ OP = 0,
+ AN = pdfreference(r),
+ }
+ local bs, bc = pdfborder()
+ local d = pdfdictionary {
+ Subtype = pdfconstant("Screen"),
+ P = pdfreference(pdfpagereference(page)),
+ A = a, -- needed in order to make the annotation clickable (i.e. don't bark)
+ Border = bs,
+ C = bc,
+ AA = actions,
+ }
+ local width = specification.width or 0
+ local height = specification.height or 0
+ if height == 0 or width == 0 then
+ -- todo: sound needs no window
+ end
+ write_node(nodeinjections.annotation(width,height,0,d(),r)) -- save ref
+ return pdfreference(r)
+end
+
+-- some dictionaries can have a MH (must honor) or BE (best effort) capsule
+
+local function insertrendering(specification)
+ local label = specification.label
+ local option = settings_to_hash(specification.option)
+ if not mf[label] then
+ local filename = specification.filename
+ local isurl = find(filename,"://",1,true)
+ local mimetype = specification.mimetype or specification.mime
+ -- local start = pdfdictionary {
+ -- Type = pdfconstant("MediaOffset"),
+ -- S = pdfconstant("T"), -- time
+ -- T = pdfdictionary { -- time
+ -- Type = pdfconstant("Timespan"),
+ -- S = pdfconstant("S"),
+ -- V = 3, -- time in seconds
+ -- },
+ -- }
+ -- local start = pdfdictionary {
+ -- Type = pdfconstant("MediaOffset"),
+ -- S = pdfconstant("F"), -- frame
+ -- F = 100 -- framenumber
+ -- }
+ -- local start = pdfdictionary {
+ -- Type = pdfconstant("MediaOffset"),
+ -- S = pdfconstant("M"), -- mark
+ -- M = "somemark",
+ -- }
+ -- local parameters = pdfdictionary {
+ -- BE = pdfdictionary {
+ -- B = start,
+ -- }
+ -- }
+ -- local parameters = pdfdictionary {
+ -- Type = pdfconstant(MediaPermissions),
+ -- TF = pdfstring("TEMPALWAYS") }, -- TEMPNEVER TEMPEXTRACT TEMPACCESS TEMPALWAYS
+ -- }
+ local descriptor = pdfdictionary {
+ Type = pdfconstant("Filespec"),
+ F = filename,
+ }
+ if isurl then
+ descriptor.FS = pdfconstant("URL")
+ elseif option[v_embed] then
+ descriptor.EF = codeinjections.embedfile {
+ file = filename,
+ mimetype = mimetype, -- yes or no
+ compress = false,
+ }
+ end
+ local clip = pdfdictionary {
+ Type = pdfconstant("MediaClip"),
+ S = pdfconstant("MCD"),
+ N = label,
+ CT = mimetype,
+ Alt = pdfarray { "", "file not found" }, -- language id + message
+ D = pdfreference(pdfflushobject(descriptor)),
+ -- P = pdfreference(pdfflushobject(parameters)),
+ }
+ local rendition = pdfdictionary {
+ Type = pdfconstant("Rendition"),
+ S = pdfconstant("MR"),
+ N = label,
+ C = pdfreference(pdfflushobject(clip)),
+ }
+ mf[label] = pdfreference(pdfflushobject(rendition))
+ end
+end
+
+local function insertrenderingobject(specification) -- todo
+ local label = specification.label
+ if not mf[label] then
+ report_media("unknown medium, label %a",label)
+ local clip = pdfdictionary { -- does not work that well one level up
+ Type = pdfconstant("MediaClip"),
+ S = pdfconstant("MCD"),
+ N = label,
+ D = pdfreference(unknown), -- not label but objectname, hm .. todo?
+ }
+ local rendition = pdfdictionary {
+ Type = pdfconstant("Rendition"),
+ S = pdfconstant("MR"),
+ N = label,
+ C = pdfreference(pdfflushobject(clip)),
+ }
+ mf[label] = pdfreference(pdfflushobject(rendition))
+ end
+end
+
+function codeinjections.processrendering(label)
+ local specification = interactions.renderings.rendering(label)
+ if not specification then
+ -- error
+ elseif specification.type == "external" then
+ insertrendering(specification)
+ else
+ insertrenderingobject(specification)
+ end
+end
+
+function codeinjections.insertrenderingwindow(specification)
+ local label = specification.label
+ codeinjections.processrendering(label)
+ ms[label] = insertrenderingwindow(specification)
+end
+
+local function set(operation,arguments)
+ codeinjections.processrendering(arguments)
+ return pdfdictionary {
+ S = pdfconstant("Rendition"),
+ OP = operation,
+ R = mf[arguments],
+ AN = ms[arguments] or delayed(arguments),
+ }
+end
+
+function executers.startrendering (arguments) return set(0,arguments) end
+function executers.stoprendering (arguments) return set(1,arguments) end
+function executers.pauserendering (arguments) return set(2,arguments) end
+function executers.resumerendering(arguments) return set(3,arguments) end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lpdf-xmp.lmt b/Master/texmf-dist/tex/context/base/mkxl/lpdf-xmp.lmt
new file mode 100644
index 00000000000..313488a3945
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lpdf-xmp.lmt
@@ -0,0 +1,311 @@
+if not modules then modules = { } end modules ['lpdf-xmp'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+ comment = "with help from Peter Rolf",
+}
+
+local tostring, type = tostring, type
+local format, gsub = string.format, string.gsub
+local utfchar = utf.char
+local xmlfillin = xml.fillin
+local md5HEX = md5.HEX
+
+local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end)
+local trace_info = false trackers.register("backend.info", function(v) trace_info = v end)
+
+local report_xmp = logs.reporter("backend","xmp")
+local report_info = logs.reporter("backend","info")
+
+local backends, lpdf = backends, lpdf
+
+local codeinjections = backends.pdf.codeinjections -- normally it is registered
+
+local pdfdictionary = lpdf.dictionary
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+
+local pdfgetmetadata = lpdf.getmetadata
+
+local pdfflushstreamobject
+
+updaters.register("backend.update.lpdf",function()
+ pdfflushstreamobject = lpdf.flushstreamobject
+end)
+
+-- The XMP packet wrapper is kind of fixed, see page 10 of XMPSpecificationsPart1.pdf from
+-- XMP-Toolkit-SDK-CC201607.zip. So we hardcode the id.
+
+local xpacket = format ( [[
+
+
+%%s
+
+]], utfchar(0xFEFF) )
+
+local mapping = {
+ -- user defined keys (pdfx:)
+ ["ConTeXt.Jobname"] = { "context", "rdf:Description/pdfx:ConTeXt.Jobname" },
+ ["ConTeXt.Time"] = { "date", "rdf:Description/pdfx:ConTeXt.Time" },
+ ["ConTeXt.Url"] = { "context", "rdf:Description/pdfx:ConTeXt.Url" },
+ ["ConTeXt.Support"] = { "context", "rdf:Description/pdfx:ConTeXt.Support" },
+ ["ConTeXt.Version"] = { "context", "rdf:Description/pdfx:ConTeXt.Version" },
+ ["ConTeXt.LMTX"] = { "context", "rdf:Description/pdfx:ConTeXt.LMTX" },
+ ["TeX.Support"] = { "metadata","rdf:Description/pdfx:TeX.Support" },
+ ["LuaTeX.Version"] = { "metadata","rdf:Description/pdfx:LuaTeX.Version" },
+ ["LuaTeX.Functionality"] = { "metadata","rdf:Description/pdfx:LuaTeX.Functionality" },
+ ["LuaTeX.LuaVersion"] = { "metadata","rdf:Description/pdfx:LuaTeX.LuaVersion" },
+ ["LuaTeX.Platform"] = { "metadata","rdf:Description/pdfx:LuaTeX.Platform" },
+ ["ID"] = { "id", "rdf:Description/pdfx:ID" }, -- has date
+ -- Adobe PDF schema
+ ["Keywords"] = { "metadata","rdf:Description/pdf:Keywords" },
+ ["Producer"] = { "metadata","rdf:Description/pdf:Producer" },
+ -- ["Trapped"] = { "pdf", "rdf:Description/pdf:Trapped" }, -- '/False' in /Info, but 'False' in XMP
+ -- Dublin Core schema
+ ["Author"] = { "metadata","rdf:Description/dc:creator/rdf:Seq/rdf:li" },
+ ["Format"] = { "metadata","rdf:Description/dc:format" }, -- optional, but nice to have
+ ["Subject"] = { "metadata","rdf:Description/dc:description/rdf:Alt/rdf:li" },
+ ["Title"] = { "metadata","rdf:Description/dc:title/rdf:Alt/rdf:li" },
+ -- XMP Basic schema
+ ["CreateDate"] = { "date", "rdf:Description/xmp:CreateDate" },
+ ["CreationDate"] = { "date", "rdf:Description/xmp:CreationDate" }, -- dummy
+ ["Creator"] = { "metadata","rdf:Description/xmp:CreatorTool" },
+ ["MetadataDate"] = { "date", "rdf:Description/xmp:MetadataDate" },
+ ["ModDate"] = { "date", "rdf:Description/xmp:ModDate" }, -- dummy
+ ["ModifyDate"] = { "date", "rdf:Description/xmp:ModifyDate" },
+ -- XMP Media Management schema
+ ["DocumentID"] = { "id", "rdf:Description/xmpMM:DocumentID" }, -- uuid
+ ["InstanceID"] = { "id", "rdf:Description/xmpMM:InstanceID" }, -- uuid
+ ["RenditionClass"] = { "pdf", "rdf:Description/xmpMM:RenditionClass" }, -- PDF/X-4
+ ["VersionID"] = { "pdf", "rdf:Description/xmpMM:VersionID" }, -- PDF/X-4
+ -- additional entries
+ -- PDF/X
+ ["GTS_PDFXVersion"] = { "pdf", "rdf:Description/pdfxid:GTS_PDFXVersion" },
+ -- optional entries
+ -- all what is visible in the 'document properties --> additional metadata' window
+ -- XMP Rights Management schema (optional)
+ ["Marked"] = { "pdf", "rdf:Description/xmpRights:Marked" },
+ -- ["Owner"] = { "metadata", "rdf:Description/xmpRights:Owner/rdf:Bag/rdf:li" }, -- maybe useful (not visible)
+ -- ["UsageTerms"] = { "metadata", "rdf:Description/xmpRights:UsageTerms" }, -- maybe useful (not visible)
+ ["WebStatement"] = { "metadata", "rdf:Description/xmpRights:WebStatement" },
+ -- Photoshop PDF schema (optional)
+ ["AuthorsPosition"] = { "metadata", "rdf:Description/photoshop:AuthorsPosition" },
+ ["Copyright"] = { "metadata", "rdf:Description/photoshop:Copyright" },
+ ["CaptionWriter"] = { "metadata", "rdf:Description/photoshop:CaptionWriter" },
+}
+
+local included = backends.included
+local lpdfid = lpdf.id
+
+function lpdf.id() -- overload of ini
+ return lpdfid(included.date)
+end
+
+local trailerid = nil
+local dates = nil
+
+local function update()
+ if trailer_id then
+ local b = toboolean(trailer_id) or trailer_id == ""
+ if b then
+ trailer_id = "This file is processed by ConTeXt and LuaTeX."
+ else
+ trailer_id = tostring(trailer_id)
+ end
+ local h = md5HEX(trailer_id)
+ if b then
+ report_info("using frozen trailer id")
+ else
+ report_info("using hashed trailer id %a (%a)",trailer_id,h)
+ end
+ trailerid = format("[<%s> <%s>]",h,h)
+ end
+ --
+ local t = type(dates)
+ if t == "number" or t == "string" then
+ local d = converters.totime(dates)
+ if d then
+ included.date = true
+ included.id = "fake"
+ report_info("forced date/time information %a will be used",lpdf.settime(d))
+ trailerid = false
+ elseif t == "string" then
+ dates = toboolean(dates)
+ included.date = dates
+ if dates ~= false then
+ included.id = true
+ else
+ report_info("no date/time but fake id information will be added")
+ trailerid = true
+ included.id = "fake"
+ end
+ end
+ end
+end
+
+lpdf.registerdocumentfinalizer(update,"trailer id and dates",1)
+
+directives.register("backend.trailerid", function(v) trailerid = v end)
+directives.register("backend.date", function(v) dates = v end)
+
+local function permitdetail(what)
+ local m = mapping[what]
+ if m then
+ return included[m[1]] and m[2]
+ else
+ return included[what] and true or false
+ end
+end
+
+lpdf.permitdetail = permitdetail
+
+-- maybe some day we will load the xmp file at runtime
+
+local xmp, xmpfile, xmpname = nil, nil, "lpdf-pdx.xml"
+
+local function setxmpfile(name)
+ if xmp then
+ report_xmp("discarding loaded file %a",xmpfile)
+ xmp = nil
+ end
+ xmpfile = name ~= "" and name
+end
+
+codeinjections.setxmpfile = setxmpfile
+
+interfaces.implement {
+ name = "setxmpfile",
+ arguments = "string",
+ actions = setxmpfile
+}
+
+local function valid_xmp()
+ if not xmp then
+ -- local xmpfile = xmpfile or resolvers.findfile(xmpname) or ""
+ if xmpfile and xmpfile ~= "" then
+ xmpfile = resolvers.findfile(xmpfile) or ""
+ end
+ if not xmpfile or xmpfile == "" then
+ xmpfile = resolvers.findfile(xmpname) or ""
+ end
+ if xmpfile ~= "" then
+ report_xmp("using file %a",xmpfile)
+ end
+ local xmpdata = xmpfile ~= "" and io.loaddata(xmpfile) or ""
+ xmp = xml.convert(xmpdata)
+ end
+ return xmp
+end
+
+function lpdf.addxmpinfo(tag,value,check)
+ local pattern = permitdetail(tag)
+ if type(pattern) == "string" then
+ xmlfillin(xmp or valid_xmp(),pattern,value,check)
+ end
+end
+
+-- redefined
+
+local pdfaddtoinfo = lpdf.addtoinfo
+local pdfaddxmpinfo = lpdf.addxmpinfo
+
+function lpdf.addtoinfo(tag,pdfvalue,strvalue)
+ local pattern = permitdetail(tag)
+ if pattern then
+ pdfaddtoinfo(tag,pdfvalue)
+ end
+ if type(pattern) == "string" then
+ local value = strvalue or gsub(tostring(pdfvalue),"^%((.*)%)$","%1") -- hack
+ if trace_info then
+ report_info("set %a to %a",tag,value)
+ end
+ xmlfillin(xmp or valid_xmp(),pattern,value,check)
+ end
+end
+
+local pdfaddtoinfo = lpdf.addtoinfo -- used later
+
+-- for the do-it-yourselvers
+
+function lpdf.insertxmpinfo(pattern,whatever,prepend)
+ xml.insert(xmp or valid_xmp(),pattern,whatever,prepend)
+end
+
+function lpdf.injectxmpinfo(pattern,whatever,prepend)
+ xml.inject(xmp or valid_xmp(),pattern,whatever,prepend)
+end
+
+-- flushing
+
+local add_xmp_blob = true directives.register("backend.xmp",function(v) add_xmp_blob = v end)
+
+local function flushxmpinfo()
+ commands.pushrandomseed()
+ commands.setrandomseed(os.time())
+
+ local documentid = "no unique document id here"
+ local instanceid = "no unique instance id here"
+ local metadata = pdfgetmetadata()
+ local time = metadata.time
+ local producer = metadata.producer
+ local creator = metadata.creator
+
+ if included.id ~= "fake" then
+ documentid = "uuid:" .. os.uuid()
+ instanceid = "uuid:" .. os.uuid()
+ end
+
+ pdfaddtoinfo("Producer",producer)
+ pdfaddtoinfo("Creator",creator)
+ pdfaddtoinfo("CreationDate",time)
+ pdfaddtoinfo("ModDate",time)
+
+ if add_xmp_blob then
+
+ pdfaddxmpinfo("DocumentID",documentid)
+ pdfaddxmpinfo("InstanceID",instanceid)
+ pdfaddxmpinfo("Producer",producer)
+ pdfaddxmpinfo("CreatorTool",creator)
+ pdfaddxmpinfo("CreateDate",time)
+ pdfaddxmpinfo("ModifyDate",time)
+ pdfaddxmpinfo("MetadataDate",time)
+ pdfaddxmpinfo("LuaTeX.Version",metadata.luatexversion)
+ pdfaddxmpinfo("LuaTeX.Functionality",metadata.luatexfunctionality)
+ pdfaddxmpinfo("LuaTeX.LuaVersion",metadata.luaversion)
+ pdfaddxmpinfo("LuaTeX.Platform",metadata.platform)
+
+ local blob = xml.tostring(xml.first(xmp or valid_xmp(),"/x:xmpmeta"))
+ local md = pdfdictionary {
+ Subtype = pdfconstant("XML"),
+ Type = pdfconstant("Metadata"),
+ }
+ if trace_xmp then
+ report_xmp("data flushed, see log file")
+ logs.pushtarget("logfile")
+ report_xmp("start xmp blob")
+ logs.newline()
+ logs.writer(blob)
+ logs.newline()
+ report_xmp("stop xmp blob")
+ logs.poptarget()
+ end
+ blob = format(xpacket,blob)
+ if not verbose and lpdf.compresslevel() > 0 then
+ blob = gsub(blob,">%s+<","><")
+ end
+ local r = pdfflushstreamobject(blob,md,false) -- uncompressed
+ lpdf.addtocatalog("Metadata",pdfreference(r))
+ end
+
+ commands.poprandomseed() -- hack
+end
+
+-- this will be enabled when we can inhibit compression for a stream at the lua end
+
+lpdf.registerdocumentfinalizer(flushxmpinfo,1,"metadata")
+
+directives.register("backend.verbosexmp", function(v)
+ verbose = v
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-bas.mkxl b/Master/texmf-dist/tex/context/base/mkxl/luat-bas.mkxl
new file mode 100644
index 00000000000..0add4ce6926
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-bas.mkxl
@@ -0,0 +1,52 @@
+%D \module
+%D [ file=luat-bas, % moved from luat-lib,
+%D version=2006.09.11,
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Basic \LUA\ Libraries,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Macros / Basic Lua Libraries}
+
+\registerctxluafile{l-bit32} {} % before sandbox
+\registerctxluafile{l-lua} {} % before sandbox
+\registerctxluafile{l-macro} {}
+\registerctxluafile{l-sandbox} {}
+\registerctxluafile{l-package} {}
+\registerctxluafile{l-lpeg} {}
+\registerctxluafile{l-function}{}
+\registerctxluafile{l-string} {}
+\registerctxluafile{l-table} {}
+\registerctxluafile{l-boolean} {}
+\registerctxluafile{l-number} {}
+\registerctxluafile{l-math} {}
+%registerctxluafile{l-aux} {}
+\registerctxluafile{l-io} {}
+\registerctxluafile{l-os} {}
+\registerctxluafile{l-file} {}
+\registerctxluafile{l-gzip} {}
+\registerctxluafile{l-md5} {}
+\registerctxluafile{l-sha} {}
+\registerctxluafile{l-dir} {}
+\registerctxluafile{l-unicode} {optimize}
+%registerctxluafile{l-utils} {}
+\registerctxluafile{l-url} {}
+\registerctxluafile{l-set} {}
+
+\registerctxluafile{l-macro-imp-optimize}{}
+
+% \registerctxluafile{socket}{}
+% \registerctxluafile{ltn12} {}
+% \registerctxluafile{mime} {}
+% \registerctxluafile{http} {}
+% \registerctxluafile{url} {}
+% \registerctxluafile{tp} {}
+% \registerctxluafile{ftp} {}
+% %registerctxluafile{smtp} {}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-cbk.lmt b/Master/texmf-dist/tex/context/base/mkxl/luat-cbk.lmt
new file mode 100644
index 00000000000..744d12e279a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-cbk.lmt
@@ -0,0 +1,287 @@
+if not modules then modules = { } end modules ['luat-cbk'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local insert, remove, concat = table.insert, table.remove, table.concat
+local find, format = string.find, string.format
+local collectgarbage, type, next = collectgarbage, type, next
+local round = math.round
+local sortedhash, sortedkeys, tohash = table.sortedhash, table.sortedkeys, table.tohash
+
+--[[ldx--
+
Callbacks are the real asset of . They permit you to hook
+your own code into the engine. Here we implement a few handy
+auxiliary functions.
When you (temporarily) want to install a callback function, and after a
+while wants to revert to the original one, you can use the following two
+functions. This only works for non-frozen ones.
By now most callbacks are frozen and most provide a way to plug in your own code. For instance
+all node list handlers provide before/after namespaces and the file handling code can be extended
+by adding schemes and if needed I can add more hooks. So there is no real need to overload a core
+callback function. It might be ok for quick and dirty testing but anyway you're on your own if
+you permanently overload callback functions.
+--ldx]]--
+
+-- This might become a configuration file only option when it gets abused too much.
+
+directives.register("system.callbacks.permitoverloads", function(v)
+ if block_overloads or permit_overloads then
+ -- once bad news, always bad news
+ elseif v then
+ permit_overloads = { }
+ report_system()
+ report_system("The callback system has been brought in an unprotected state. As a result of directly")
+ report_system("setting of callbacks subsystems of ConTeXt can stop working. There is no support for")
+ report_system("bugs resulting from this state. It's better to use the official extension mechanisms.")
+ report_system()
+ end
+end)
+
+sandbox.initializer {
+ category = "functions",
+ action = function()
+ block_overloads = true
+ end
+}
+
+if not list then -- otherwise counters get reset
+
+ list = utilities.storage.allocate(list_callbacks())
+
+ local supported = { }
+
+ for k in next, list do
+ list[k] = 0
+ supported[k] = true
+ end
+
+ callbacks.list = list
+ callbacks.supported = supported
+
+end
+
+local delayed = tohash {
+ "buildpage_filter",
+}
+
+if trace_calls then
+
+ local functions = { }
+
+ register_callback = function(name,func)
+ if type(func) == "function" then
+ if functions[name] then
+ functions[name] = func
+ return find_callback(name)
+ else
+ functions[name] = func
+ local cnuf = function(...)
+ list[name] = list[name] + 1
+ return functions[name](...)
+ end
+ return original_register(name,cnuf)
+ end
+ else
+ return original_register(name,func)
+ end
+ end
+
+end
+
+-- temporary, not public:
+
+callbacks.functions = { }
+
+-- till here
+
+local reported = { }
+
+local function register_usercall(what,name,func)
+ if list[name] then
+ if trace_callbacks or not reported[name] then
+ report_system()
+ report_system("disabling core code by %s user function into callback '%s' (reported only once)",what,name)
+ report_system()
+ reported[name] = true
+ end
+ permit_overloads[name] = true
+ return original_register(name,function(...)
+ if trace_callbacks then
+ report_callbacks("calling user function from '%s'",name)
+ end
+ return func(...)
+ end)
+ else
+ report_callbacks("not %s function into invalid callback '%s'",name)
+ return nil, format("unknown callback '%s'",name)
+ end
+end
+
+local function frozen_callback(name)
+ report_callbacks("not %s frozen %a","registering",name)
+ return nil, format("callback '%s' is frozen",name) -- no formatter yet
+end
+
+local function state(name)
+ local f = find_callback(name)
+ if f == false then
+ return "disabled"
+ elseif f then
+ return "enabled"
+ else
+ return "undefined"
+ end
+end
+
+function callbacks.known(name)
+ return list[name]
+end
+
+function callbacks.report()
+ for name, _ in sortedhash(list) do
+ local str = frozen[name]
+ if str then
+ report_callbacks("%s: %s -> %s",state(name),name,str)
+ else
+ report_callbacks("%s: %s",state(name),name)
+ end
+ end
+end
+
+function callbacks.freeze(name,freeze)
+ if not permit_overloads then
+ freeze = type(freeze) == "string" and freeze
+ if find(name,"*",1,true) then
+ local pattern = name
+ for name, _ in next, list do
+ if find(name,pattern) then
+ frozen[name] = freeze or frozen[name] or "frozen"
+ end
+ end
+ else
+ frozen[name] = freeze or frozen[name] or "frozen"
+ end
+ end
+end
+
+function callbacks.register(name,func,freeze)
+ if frozen[name] then
+ if permit_overloads then
+ return register_usercall("registering",name,func)
+ else
+ return frozen_callback(name)
+ end
+ elseif freeze then
+ frozen[name] = type(freeze) == "string" and freeze or "registered"
+ end
+ if delayed[name] and environment.initex then
+ return nil
+ end
+ return register_callback(name,func)
+end
+
+function callback.register(name,func) -- original
+ if not frozen[name] then
+ return register_callback(name,func)
+ elseif permit_overloads then
+ return register_usercall("registering",name,func)
+ else
+ return frozen_callback(name)
+ end
+end
+
+function callbacks.push(name,func)
+ if not frozen[name] or permit_overloads then
+ local sn = stack[name]
+ if not sn then
+ sn = { }
+ stack[name] = sn
+ end
+ insert(sn,find_callback(name))
+ if permit_overloads then
+ register_usercall("pushing",name,func)
+ else
+ register_callback(name,func)
+ end
+ else
+ report_callbacks("not %s frozen %a","pushing",name)
+ end
+end
+
+function callbacks.pop(name)
+ if not frozen[name] or permit_overloads then
+ local sn = stack[name]
+ if not sn or #sn == 0 then
+ -- some error
+ register_callback(name,nil) -- ! really needed
+ else
+ -- this fails: register_callback(name, remove(stack[name]))
+ local func = remove(sn)
+ register_callback(name,func)
+ end
+ end
+end
+
+if trace_calls then
+ statistics.register("callback details", function()
+ local t = { } -- todo: pass function to register and quit at nil
+ for name, n in sortedhash(list) do
+ if n > 0 then
+ t[#t+1] = format("%s -> %s",name,n)
+ end
+ end
+ return concat(t," ")
+ end)
+end
+
+statistics.register("callbacks overloaded by user", function()
+ if permit_overloads then
+ return concat(sortedkeys(permit_overloads)," ")
+ end
+end)
+
+-- this will move to a module
+
+commands = commands or { }
+
+function commands.showcallbacks()
+ local NC, NR, verbatim = context.NC, context.NR, context.type
+ context.starttabulate { "|l|l|p|" }
+ for name, _ in sortedhash(list) do
+ NC() verbatim(name) NC() verbatim(state(name)) NC() context(frozen[name] or "") NC() NR()
+ end
+ context.stoptabulate()
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-cod.lmt b/Master/texmf-dist/tex/context/base/mkxl/luat-cod.lmt
new file mode 100644
index 00000000000..49d90777df6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-cod.lmt
@@ -0,0 +1,308 @@
+if not modules then modules = { } end modules ['luat-cod'] = {
+ version = 1.001,
+ comment = "companion to luat-cod.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local type, loadfile, tonumber = type, loadfile, tonumber
+local match, gsub, find, format, gmatch = string.match, string.gsub, string.find, string.format, string.gmatch
+
+local texconfig, lua = texconfig, lua
+
+-- maybe pick up from commandline:
+--
+-- texconfig.interaction: 0=batchmode 1=nonstopmode 2=scrollmode 3=errornonstopmode 4=normal
+
+-- some basic housekeeping
+
+texconfig.kpse_init = false -- not needed in lmtx
+texconfig.shell_escape = 't' -- not needed in lmtx
+
+texconfig.max_in_open = 2000
+texconfig.nest_size = 10000
+texconfig.param_size = 100000
+texconfig.save_size = 500000
+texconfig.stack_size = 100000
+texconfig.buffer_size = 10000000
+texconfig.token_size = 10000000
+texconfig.node_size = 50000000
+
+texconfig.max_print_line = 100000
+texconfig.max_strings = 500000
+texconfig.max_pool = 10000000
+
+texconfig.hash_extra = 200000
+
+texconfig.expand_depth = 10000
+texconfig.function_size = 32768
+texconfig.properties_size = 10000
+texconfig.error_line = 250
+texconfig.half_error_line = 125
+
+texconfig.level_max = 500
+texconfig.level_chr = 46 -- period
+
+-- registering bytecode chunks
+
+local bytedata = lua.bytedata or { }
+local bytedone = lua.bytedone or { }
+
+---.bytecode = bytecode
+lua.bytedata = bytedata
+lua.bytedone = bytedone
+
+local setbytecode = lua.setbytecode
+----- getbytecode = lua.getbytecode
+
+lua.firstbytecode = 501
+lua.lastbytecode = lua.lastbytecode or (lua.firstbytecode - 1) -- as we load ourselves again ... maybe return earlier
+
+function lua.registeredcodes()
+ return lua.lastbytecode - lua.firstbytecode + 1
+end
+
+-- no file.* and utilities.parsers.* functions yet
+
+local strip = false if arg then for i=-1,#arg do if arg[i] == "--c:strip" then strip = true break end end end
+
+function lua.registercode(filename,options)
+ local barename = gsub(filename,"%.[%a%d]+$","")
+ local basename = match(barename,"^.+[/\\](.-)$") or barename
+ if not bytedone[basename] then
+ local opts = { }
+ if type(options) == "string" and options ~= "" then
+ for s in gmatch(options,"([a-z]+)") do
+ opts[s] = true
+ end
+ end
+ if barename == filename then
+ filename = filename .. (opts.autosuffix and ".lmt" or ".lua")
+ end
+ local code = environment.luafilechunk(filename,false,opts.optimize)
+ if code then
+ bytedone[basename] = true
+ if environment.initex and not opts.initexonly then
+ local n = lua.lastbytecode + 1
+ bytedata[n] = { name = barename, options = opts }
+ if strip or opts.strip then
+ setbytecode(n,code,true)
+ else
+ setbytecode(n,code)
+ end
+ lua.lastbytecode = n
+ end
+ elseif environment.initex then
+ texio.write_nl(format("\nerror loading file: %s (aborting)",filename))
+ os.exit()
+ end
+ end
+end
+
+local finalizers = { }
+
+function lua.registerfinalizer(f,comment)
+ comment = comment or "unknown"
+ if type(f) == "function" then
+ finalizers[#finalizers+1] = { action = f, comment = comment }
+ else
+ print(format("\nfatal error: invalid finalizer, action: %s\n",comment))
+ os.exit()
+ end
+end
+
+function lua.finalize(logger)
+ for i=1,#finalizers do
+ local finalizer = finalizers[i]
+ finalizer.action()
+ if logger then
+ logger("finalize action: %s",finalizer.comment)
+ end
+ end
+end
+
+-- A first start with environments. This will be overloaded later.
+
+environment = environment or { }
+local environment = environment
+
+-- no string.unquoted yet
+
+local sourcefile = gsub(arg and arg[1] or "","^\"(.*)\"$","%1")
+local sourcepath = find(sourcefile,"/",1,true) and gsub(sourcefile,"/[^/]+$","") or ""
+local targetpath = "."
+
+-- delayed (via metatable):
+--
+-- environment.jobname = tex.jobname
+-- environment.version = tostring(tex.toks.contextversiontoks)
+
+-- traditionally the revision has been a one character string and only
+-- pdftex went beyond "9" but anyway we test for it
+
+if LUATEXENGINE == nil then
+ LUATEXENGINE = status.luatex_engine and string.lower(status.luatex_engine) or "luametatex"
+end
+
+if LUATEXVERSION == nil then
+ LUATEXVERSION = status.luatex_version/100 + tonumber(status.luatex_revision)/10000
+end
+
+if CONTEXTLMTXMODE == nil then
+ CONTEXTLMTXMODE = 1
+end
+
+if LUATEXFUNCTIONALITY == nil then
+ LUATEXFUNCTIONALITY = status.development_id or 6346
+end
+
+if LUATEXFORMATID == nil then
+ LUATEXFORMATID = status.format_id or 0
+end
+
+if JITSUPPORTED == nil then
+ JITSUPPORTED = false
+end
+
+if INITEXMODE == nil then
+ INITEXMODE = status.run_state == 0 -- initializing updating production
+end
+
+environment.luatexengine = LUATEXENGINE
+environment.luatexversion = LUATEXVERSION
+environment.luatexfunctionality = LUATEXFUNCTIONALITY
+environment.jitsupported = JITSUPPORTED
+environment.initex = INITEXMODE
+environment.initexmode = INITEXMODE
+
+-- if INITEXMODE then
+-- -- we have about that amount so we preallocate then which gives less
+-- -- reallocations (we're talking tiny record so no real gain)
+-- lua.setbytecode(1024,nil)
+-- -- but we don't want to lie about the amount either so ...
+-- end
+
+if not environment.luafilechunk then
+
+ function environment.luafilechunk(filename)
+ local fullname = filename
+ if sourcepath ~= "" then
+ fullname = sourcepath .. "/" .. filename
+ end
+ if not lfs.isfile(fullname) then
+ fullname = gsub(fullname,"mkxl","mkiv")
+ end
+ local data = loadfile(fullname)
+ texio.write("terminal_and_logfile","<",data and "+ " or "- ",fullname,">")
+ if data then
+-- package.loaded[gsub(filename,"%..-$"] =
+ data()
+ end
+ return data
+ end
+
+end
+
+if not environment.engineflags then -- raw flags
+
+ local engineflags = { }
+
+ for i=-10,#arg do
+ local a = arg[i]
+ if a then
+ local flag, content = match(a,"^%-%-([^=]+)=?(.-)$")
+ if flag then
+ engineflags[flag] = content or ""
+ end
+ end
+ end
+
+ environment.engineflags = engineflags
+
+end
+
+-- We need a few premature callbacks in the format generator. We
+-- also do this when the format is loaded as otherwise we get
+-- a kpse error when disabled. This is an engine issue that will
+-- be sorted out in due time.
+
+-- print("!!!!!!!!!!!!!!!!!!!!!!",lfs.isfile) os.exit()
+
+if not lfs.isfile then
+
+ local attributes = lfs.attributes
+
+ function lfs.isdir(name)
+ return attributes(name,"mode") == "directory"
+ end
+
+ function lfs.isfile(name)
+ local a = attributes(name,"mode")
+ return a == "file" or a == "link" or nil
+ end
+
+end
+
+local isfile = lfs.isfile
+
+local function source_file(name)
+ local fullname = sourcepath .. "/" .. name
+ if isfile(fullname) then
+ return fullname
+ end
+ fullname = fullname .. ".tex"
+ if isfile(fullname) then
+ return fullname
+ end
+ if isfile(name) then
+ return name
+ end
+ name = name .. ".tex"
+ if isfile(name) then
+ return name
+ end
+ return nil
+end
+
+local function target_file(name)
+ return targetpath .. "/" .. name
+end
+
+local function find_log_file(name)
+ return target_file(name)
+end
+
+local function find_data_file(name)
+ return source_file(name)
+end
+
+local function open_data_file(name)
+ local fullname = source_file(name)
+ if fullname then
+ local f = io.open(fullname,'rb')
+ return {
+ reader = function()
+ return f:read("*line")
+ end
+ }
+ else
+ return false
+ end
+end
+
+callback.register('find_log_file', find_log_file)
+callback.register('find_data_file' , find_data_file )
+callback.register('open_data_file' , open_data_file )
+
+callback.register("trace_memory", function(what,success)
+ success = success and "succeeded" or "failed"
+ if logs then
+ logs.report("tex memory","bumping category %a %s, details: %s",
+ what,success,table.sequenced(status["get"..what.."state"]()))
+ elseif texio then
+ texio.write_nl(format("bumping tex '%s' memory %s",
+ what,success))
+ end
+ -- os.exit()
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-cod.mkxl b/Master/texmf-dist/tex/context/base/mkxl/luat-cod.mkxl
new file mode 100644
index 00000000000..ed4a1398119
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-cod.mkxl
@@ -0,0 +1,48 @@
+%D \module
+%D [ file=luat-cod,
+%D version=2005.05.26,
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Code,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \writestatus{loading}{ConTeXt Lua Macros / Code}
+
+\unprotect
+
+\newif\ifproductionrun
+
+\permanent\let\ctxdirectlua \directlua
+\permanent\def\ctxsprint #1{\directlua{tex.sprint(tex.ctxcatcodes,#1)}} % saves tokens
+\permanent\def\ctxwrite #1{\directlua{tex.write(#1)}} % saves tokens
+\permanent\def\ctxcommand #1{\directlua{commands.#1}} % saves tokens
+\permanent\def\ctxdirectcommand#1{\directlua{commands.#1}} % saves tokens
+\permanent\def\ctxreport #1{\directlua{logs.writer[[#1]]}}
+
+%D Take your choice \unknown
+
+\aliased\let\ctxlua \ctxdirectlua
+\aliased\let\luacode \ctxdirectlua
+\aliased\let\directluacode\ctxdirectlua
+
+%D Reporting the version of \LUA\ that we use is done as follows:
+
+\permanent\def\luaversion{\ctxwrite{LUAVERSION}}
+
+\permanent\def\registerctxluafile#1#2{\ctxlua{lua.registercode("#1","#2")}}
+\permanent\def\ctxloadluafile #1{\ctxlua{lua.registercode("#1")}}
+
+\registerctxluafile{luat-cod.lmt}{autosuffix}
+
+\toksapp \everydump {%
+ \permanent\let\ctxlatelua \latelua
+ \permanent\def\ctxlatecommand#1{\latelua{commands.#1}}%
+ \aliased\let\lateluacode \ctxlatelua
+} % no \appendtoks yet
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-fio.lmt b/Master/texmf-dist/tex/context/base/mkxl/luat-fio.lmt
new file mode 100644
index 00000000000..c70ed54e4aa
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-fio.lmt
@@ -0,0 +1,107 @@
+if not modules then modules = { } end modules ['luat-fio'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format = string.format
+local concat = table.concat
+
+texconfig.kpse_init = false -- can go away
+texconfig.shell_escape = 't' -- can go away
+texconfig.max_print_line = 100000 -- can go away
+texconfig.max_in_open = 1000 -- can go away
+
+if not resolvers.initialized() then
+
+ resolvers.reset()
+
+ -- we now load the file database as we might need files other than
+ -- tex and lua file on the given path
+
+ resolvers.load()
+
+ if callback then
+
+ local findbinfile = resolvers.findbinfile
+ local findtexfile = resolvers.findtexfile
+ local opentexfile = resolvers.opentexfile
+ local register = callbacks.register
+
+ local ioflush = io.flush
+ local ioread = io.read
+ local writenl = texio.write_nl
+
+ local function terminal()
+ writenl("\ntex console > ")
+ ioflush()
+ local line = ioread()
+ writenl("")
+ ioflush()
+ return line
+ end
+
+ -- local function find_data_file(name)
+ -- if not name or name == "" then
+ -- return "context terminal"
+ -- else
+ -- return findbinfile(name,"tex")
+ -- end
+ -- end
+ --
+ -- local function open_data_file(name)
+ -- if not name or name == "" or name == "context terminal" then
+ -- return {
+ -- reader = terminal,
+ -- noflines = 1,
+ -- filename = name,
+ -- }
+ -- else
+ -- name = opentexfile(name)
+ -- return name ~= "" and name or false
+ -- end
+ -- end
+
+ local function open_data_file(name)
+ if not name or name == "" then
+ return {
+ reader = terminal,
+ noflines = 1,
+ filename = "context terminal"
+ }
+ else
+ local fullname = findbinfile(name,"tex")
+ if fullname then
+ return opentexfile(fullname)
+ else
+ return false
+ end
+ end
+ end
+
+ local function find_any_file(name)
+ return name
+ end
+
+ register('find_log_file' , find_any_file, true)
+ register('find_format_file', find_any_file, true)
+ -- register('find_data_file' , find_data_file, true)
+ register('open_data_file' , open_data_file, true)
+
+ end
+
+end
+
+statistics.register("resource resolver", function()
+ local scandata = resolvers.scandata()
+ return format("loadtime %s seconds, %s scans with scantime %s seconds, %s shared scans, %s found files, scanned paths: %s",
+ resolvers.loadtime(),
+ scandata.n,
+ scandata.time,
+ scandata.shared,
+ #resolvers.foundintrees(),
+ #scandata.paths > 0 and concat(scandata.paths," ") or ""
+ )
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/luat-ini.lmt
new file mode 100644
index 00000000000..3bfd191b981
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-ini.lmt
@@ -0,0 +1,46 @@
+if not modules then modules = { } end modules ['luat-ini'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+--[[ldx--
+
We cannot load anything yet. However what we will do us reserve a few tables.
+These can be used for runtime user data or third party modules and will not be
+cluttered by macro package code.
+--ldx]]--
+
+userdata = userdata or { } -- for users (e.g. functions etc)
+thirddata = thirddata or { } -- only for third party modules
+moduledata = moduledata or { } -- only for development team
+documentdata = documentdata or { } -- for users (e.g. raw data)
+parametersets = parametersets or { } -- for special purposes
+
+table.setmetatableindex(moduledata,"table")
+table.setmetatableindex(thirddata, "table")
+
+if not global then
+ global = _G
+end
+
+LUATEXVERSION = status.luatex_version/100
+ + tonumber(status.luatex_revision)/10000
+
+LUATEXENGINE = status.luatex_engine and string.lower(status.luatex_engine)
+ or (string.find(status.banner,"LuajitTeX",1,true) and "luajittex" or "luatex")
+
+LUATEXFUNCTIONALITY = status.development_id or 6346
+
+LUATEXFORMATID = status.format_id or 0
+
+JITSUPPORTED = LUATEXENGINE == "luajittex" or jit
+
+INITEXMODE = status.ini_version
+
+CONTEXTLMTXMODE = 1
+
+function os.setlocale()
+ -- no need for a message
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/luat-ini.mkxl
new file mode 100644
index 00000000000..9a78c3934c4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-ini.mkxl
@@ -0,0 +1,299 @@
+%D \module
+%D [ file=luat-ini,
+%D version=2005.08.11,
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Macros / Initialization}
+
+\unprotect
+
+%D Loading lua code can be done using \type {startup.lua}. The following method uses
+%D the \TEX\ input file locator of kpse. At least we need to use that way of loading
+%D when we haven't yet define our own code, which we keep outside the format. We
+%D will keep code outside \TEX\ files as much as possible. The solutions evolved
+%D with the engine but one can find some history in the \MKIV\ files and articles.
+
+%ifdefined\setnaturalcatcodes \else \let\setnaturalcatcodes\relax \fi
+\ifdefined\obeylualines \else \let\obeylualines \relax \fi
+\ifdefined\obeyluatokens \else \let\obeyluatokens \relax \fi
+
+%D A few more goodies:
+
+\aliased\let\stoplua \relax % tex catcodes
+\aliased\let\stopluacode\relax % lua catcodes
+
+%D In the meantime the \LUATEX\ interface has become stable but we still
+%D see traces of old here (needs checking).
+
+\permanent\protected\def\startlua % \stoplua
+ {\begingroup
+ \obeylualines
+ \luat_start_lua_indeed}
+
+\def\luat_start_lua_indeed#1\stoplua
+ {\normalexpanded{\endgroup\noexpand\directlua{#1}}}
+
+\permanent\protected\def\startluacode % \stopluacode
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \luat_start_lua_code_indeed}
+
+\def\luat_start_lua_code_indeed#1\stopluacode
+ %{\normalexpanded{\endgroup\noexpand\directlua{#1}}}
+ {\directlua{#1\beginlocalcontrol\endgroup\endlocalcontrol}}
+
+%D Some delayed definitions:
+
+\ifdefined\obeylines \else \let\obeylines \relax \fi
+\ifdefined\obeyedline \else \let\obeyedline \relax \fi
+\ifdefined\obeyspaces \else \let\obeyspaces \relax \fi
+\ifdefined\obeyedspace \else \let\obeyedspace \relax \fi
+
+\aliased\let\obeylualines\relax % not used, will go away
+
+\newtoks\everyluacode
+
+%D It is nicer for checking with \type {s-system-macros} if we have some meaning:
+
+\pushoverloadmode
+ \let\-\explicitdiscretionary
+\popoverloadmode
+
+\ifdefined\n \else \mutable\def\n{n} \fi \ifdefined\r \else \mutable\def\r{r} \fi
+\ifdefined\f \else \mutable\def\f{f} \fi \ifdefined\t \else \mutable\def\t{t} \fi
+\ifdefined\a \else \mutable\def\a{a} \fi \ifdefined\b \else \mutable\def\b{b} \fi
+\ifdefined\v \else \mutable\def\v{v} \fi \ifdefined\s \else \mutable\def\s{s} \fi
+
+\ifdefined\+ \else \mutable\def\+{+} \fi \ifdefined\- \else \mutable\def\-{-} \fi
+
+\ifdefined\? \else \mutable\def\?{?} \fi \ifdefined\! \else \mutable\def\!{!} \fi % bonus
+
+\ifdefined\1 \else \mutable\def\1{1} \fi \ifdefined\2 \else \mutable\def\2{2} \fi
+\ifdefined\3 \else \mutable\def\3{3} \fi \ifdefined\4 \else \mutable\def\4{4} \fi
+\ifdefined\5 \else \mutable\def\5{5} \fi \ifdefined\6 \else \mutable\def\6{6} \fi
+\ifdefined\7 \else \mutable\def\7{7} \fi \ifdefined\8 \else \mutable\def\8{8} \fi
+\ifdefined\9 \else \mutable\def\9{9} \fi \ifdefined\0 \else \mutable\def\0{0} \fi
+
+\immutable\edef\lua_letter_backslash{\string\\}
+\immutable\edef\lua_letter_bar {\string\|} \immutable\edef\lua_letter_dash {\string\-}
+\immutable\edef\lua_letter_lparent {\string\(} \immutable\edef\lua_letter_rparent {\string\)}
+\immutable\edef\lua_letter_lbrace {\string\{} \immutable\edef\lua_letter_rbrace {\string\}}
+\immutable\edef\lua_letter_squote {\string\'} \immutable\edef\lua_letter_dquote {\string\"}
+\immutable\edef\lua_letter_n {\string\n} \immutable\edef\lua_letter_r {\string\r}
+\immutable\edef\lua_letter_f {\string\f} \immutable\edef\lua_letter_t {\string\t}
+\immutable\edef\lua_letter_a {\string\a} \immutable\edef\lua_letter_b {\string\b}
+\immutable\edef\lua_letter_v {\string\v} \immutable\edef\lua_letter_s {\string\s}
+\immutable\edef\lua_letter_one {\string\1} \immutable\edef\lua_letter_two {\string\2}
+\immutable\edef\lua_letter_three {\string\3} \immutable\edef\lua_letter_four {\string\4}
+\immutable\edef\lua_letter_five {\string\5} \immutable\edef\lua_letter_six {\string\6}
+\immutable\edef\lua_letter_seven {\string\7} \immutable\edef\lua_letter_eight {\string\8}
+\immutable\edef\lua_letter_nine {\string\9} \immutable\edef\lua_letter_zero {\string\0}
+
+\everyluacode {% \appendtoks
+ \enforced\let\\\lua_letter_backslash
+ \enforced\let\|\lua_letter_bar \enforced\let\-\lua_letter_dash
+ \enforced\let\(\lua_letter_lparent \enforced\let\)\lua_letter_rparent
+ \enforced\let\{\lua_letter_lbrace \enforced\let\}\lua_letter_rbrace
+ \enforced\let\'\lua_letter_squote \enforced\let\"\lua_letter_dquote
+ \enforced\let\n\lua_letter_n \enforced\let\r\lua_letter_r
+ \enforced\let\f\lua_letter_f \enforced\let\t\lua_letter_t
+ \enforced\let\a\lua_letter_a \enforced\let\b\lua_letter_b
+ \enforced\let\v\lua_letter_v \enforced\let\s\lua_letter_s
+ \enforced\let\1\lua_letter_one \enforced\let\2\lua_letter_two
+ \enforced\let\3\lua_letter_three \enforced\let\4\lua_letter_four
+ \enforced\let\5\lua_letter_five \enforced\let\6\lua_letter_six
+ \enforced\let\7\lua_letter_seven \enforced\let\8\lua_letter_eight
+ \enforced\let\9\lua_letter_nine \enforced\let\0\lua_letter_zero
+} % \to \everyluacode
+
+\permanent\protected\def\obeyluatokens
+ {\setcatcodetable\luacatcodes
+ \the\everyluacode}
+
+\immutable\edef\luamajorversion{\ctxwrite{LUAMINORVERSION}}
+\immutable\edef\luaminorversion{\ctxwrite{LUAMAJORVERSION}}
+
+%D We need a way to pass strings safely to \LUA\ without the need for tricky
+%D escaping. Compare:
+%D
+%D \starttyping
+%D \ctxlua {something("anything tricky can go here")}
+%D \ctxlua {something([\luastringsep[anything tricky can go here]\luastringsep])}
+%D \stoptyping
+
+\def\luastringsep{===} % this permits \typefile{self} otherwise nested b/e sep problems
+
+\edef\!!bs{[\luastringsep[} % later redefined as mutable
+\edef\!!es{]\luastringsep]}
+
+%D We have a the following available as primitive so there is no need for it:
+%D
+%D \starttyping
+%D \edef\luaescapestring#1{\!!bs#1\!!es}
+%D \stoptyping
+
+\permanent\protected\def\setdocumentfilename #1#2{\clf_setdocumentfilename\numexpr#1\relax{#2}}
+\permanent \def\getdocumentfilename #1{\clf_getdocumentfilename\numexpr#1\relax}
+\permanent\protected\def\setdocumentargument #1#2{\clf_setdocumentargument{#1}{#2}}
+\permanent \def\getdocumentargument #1{\clf_getdocumentargument{#1}{}}
+\permanent\protected\def\setdocumentargumentdefault#1#2{\clf_setdocumentdefaultargument{#1}{#2}}
+\permanent \def\getdocumentargumentdefault#1#2{\clf_getdocumentargument{#1}{#2}}
+
+% seldom used so no need for speedy variants:
+
+\permanent\def\doifelsedocumentargument #1{\doifelsesomething{\clf_getdocumentargument{#1}}}
+\permanent\def\doifdocumentargument #1{\doifsomething {\clf_getdocumentargument{#1}}}
+\permanent\def\doifnotdocumentargument #1{\doifnothing {\clf_getdocumentargument{#1}}}
+\permanent\def\doifelsedocumentfilename #1{\doifelsesomething{\clf_getdocumentfilename\numexpr#1\relax}}
+\permanent\def\doifdocumentfilename #1{\doifsomething {\clf_getdocumentfilename\numexpr#1\relax}}
+\permanent\def\doifnotdocumentfilename #1{\doifnothing {\clf_getdocumentfilename\numexpr#1\relax}}
+
+\aliased\let\doifdocumentargumentelse\doifelsedocumentargument
+\aliased\let\doifdocumentfilenameelse\doifelsedocumentfilename
+
+%D A handy helper:
+
+\permanent\def\luaexpanded#1{\luaescapestring\expandafter{\normalexpanded{#1}}}
+
+%D Experimental:
+
+\permanent\protected\def\startluaparameterset[#1]% \stopluaparameterset
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \luat_start_lua_parameter_set{#1}}
+
+\def\luat_start_lua_parameter_set#1#2\stopluaparameterset
+ {\ctxlua{parametersets["#1"]={#2}}%
+ \endgroup}
+
+\aliased\let\stopluaparameterset\relax
+
+\permanent\def\luaparameterset#1#2{\ctxlua{parametersets["#1"]={#2} context("#1")}}
+
+% todo: \mergeparameterset
+
+% usage:
+%
+% \startluaparameterset [u3d:myset:display:1]
+% toolbar=false,
+% tree=true
+% \stopluaparameterset
+%
+% option=u3d:myset:display:1
+%
+% or:
+%
+% option=\luaparameterset{u3d:myset:display:1}{toolbar=false,tree=true}
+
+%D A Handy helper:
+
+\permanent\def\luaconditional#1{\ifcase#1tru\else fals\fi e}
+
+%D Goodie:
+%D
+%D \starttyping
+%D \ctxluacode{context("%0.5f",1/3)}
+%D \stoptyping
+
+\permanent\protected\def\ctxluacode
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \catcode\leftbraceasciicode \plusone
+ \catcode\rightbraceasciicode\plustwo
+ \afterassignment\luat_lua_code
+ \scratchtoks=}
+
+% Hm, are we sure that the \* commands work out okay here? We could probably
+% use \setcatcodetable\luacatcodes instead of \obeyluatokens now.
+
+\def\luat_lua_code
+ {\normalexpanded{\endgroup\noexpand\directlua\expandafter{\the\scratchtoks}}} % \zerocount is default
+
+% \startctxfunction MyFunctionA
+% context(" A1 ")
+% \stopctxfunction
+%
+% \startctxfunctiondefinition MyFunctionB
+% context(" B2 ")
+% \stopctxfunctiondefinition
+%
+% \starttext
+% \dorecurse{10000}{\ctxfunction{MyFunctionA}} \page
+% \dorecurse{10000}{\MyFunctionB} \page
+% \dorecurse{10000}{\ctxlua{context(" C3 ")}} \page
+% \stoptext
+
+\installsystemnamespace{ctxfunction}
+
+\permanent\protected\def\startctxfunctiondefinition #1 % \stopctxfunctiondefinition
+ {\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_definition_indeed{#1}}
+
+\installsystemnamespace{luafunction}
+
+\def\luat_start_lua_function_definition_indeed#1#2\stopctxfunctiondefinition
+ {\endgroup
+ \expandafter\chardef\csname\??luafunction#1\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax
+ \edefcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}}
+
+\permanent\protected\def\setctxluafunction#1#2% experiment
+ {\expandafter\chardef\csname\??luafunction#1\endcsname#2\relax
+ \edefcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}}
+
+\aliased\let\stopctxfunctiondefinition\relax
+
+\permanent\protected\def\startctxfunction #1 % \stopctxfunction
+ {\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_indeed{#1}}
+
+\def\luat_start_lua_function_indeed#1#2\stopctxfunction
+ {\endgroup\edefcsname\??ctxfunction#1\endcsname{\noexpand\luafunction\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax}}
+
+\aliased\let\stopctxfunction\relax
+
+\permanent\def\ctxfunction#1%
+ {\begincsname\??ctxfunction#1\endcsname}
+
+%D In theory this is faster due to the call not being wrapped in a function but in
+%D practice the speedup can't be noticed. The actions called for often have lots of
+%D lookups so an extra one doesn't matter much. The kind of calls differs a lot per
+%D document and often there are other ways to optimize a style. For instance we can
+%D gain a lot when defining a font, but when a frozen definition is used that gain
+%D gets completely lost. For some calls (take list writers) it can get worse if only
+%D because readability gets worse and passing is already efficient due to selective
+%D flushing, while with the token scanners one has to scan all of them.
+
+% \startctxfunctiondefinition foo commands.foo() \stopctxfunctiondefinition
+%
+% \installctxfunction\foo{commands.foo}
+
+\permanent\protected\def\installctxfunction#1#2% expandable
+ {\edef\m_syst_name{\csstring#1}%
+ \global\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax}
+
+\permanent\protected\def\installctxscanner#1#2% expandable
+ {\edef\m_syst_name{\csstring#1}%
+ \global\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax}
+
+\permanent\protected\def\installprotectedctxfunction#1#2% protected
+ {\edef\m_syst_name{\csstring#1}%
+ \global\protected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax}
+
+\permanent\protected\def\installprotectedctxscanner#1#2% protected
+ {\edef\m_syst_name{\csstring#1}%
+ \global\protected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax}
+
+\permanent\protected\def\resetctxscanner#1%
+ {\edef\m_syst_name{\csstring#1}%
+ \gletcsname\m_syst_name\endcsname\relax}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-lib.mkxl b/Master/texmf-dist/tex/context/base/mkxl/luat-lib.mkxl
new file mode 100644
index 00000000000..61f9ccfd0fd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-lib.mkxl
@@ -0,0 +1,104 @@
+%D \module
+%D [ file=luat-lib,
+%D version=2006.09.11,
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Libraries,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Macros / Libraries}
+
+\registerctxluafile{util-str}{}
+\registerctxluafile{util-tab}{}
+\registerctxluafile{util-fil}{optimize}
+\registerctxluafile{util-sac}{optimize}
+\registerctxluafile{util-sto}{} % could also be done in trac-deb.mkiv
+\registerctxluafile{util-pck}{}
+\registerctxluafile{util-prs}{}
+\registerctxluafile{util-fmt}{}
+\registerctxluafile{util-dim}{}
+
+\registerctxluafile{trac-set}{}
+\registerctxluafile{luat-log}{autosuffix}
+\registerctxluafile{trac-inf}{autosuffix}
+\registerctxluafile{util-lua}{}
+\registerctxluafile{util-deb}{} % could also be done in trac-deb.mkiv
+
+\registerctxluafile{util-tpl}{} % needs tracker
+\registerctxluafile{util-seq}{}
+
+\registerctxluafile{util-sta}{}
+
+\registerctxluafile{util-sbx}{} % needs tracker and templates
+
+\registerctxluafile{util-soc-imp-reset} {}
+\registerctxluafile{util-soc-imp-socket} {}
+\registerctxluafile{util-soc-imp-ltn12} {}
+\registerctxluafile{util-soc-imp-mime} {}
+\registerctxluafile{util-soc-imp-url} {}
+\registerctxluafile{util-soc-imp-headers}{}
+\registerctxluafile{util-soc-imp-http} {}
+\registerctxluafile{util-soc-imp-tp} {}
+
+\registerctxluafile{util-zip}{}
+
+\registerctxluafile{data-ini}{}
+\registerctxluafile{data-exp}{}
+\registerctxluafile{data-env}{}
+\registerctxluafile{data-tmp}{}
+\registerctxluafile{data-met}{}
+\registerctxluafile{data-res}{}
+\registerctxluafile{data-inp}{}
+\registerctxluafile{data-out}{}
+\registerctxluafile{data-fil}{} % opener gets overloaded in data-tex
+
+\registerctxluafile{data-pre}{} % after data-res
+\registerctxluafile{data-bin}{} % before data-tex
+\registerctxluafile{data-tex}{} % after data-pre
+\registerctxluafile{data-vir}{}
+\registerctxluafile{data-zip}{}
+%registerctxluafile{data-crl}{}
+\registerctxluafile{data-sch}{}
+\registerctxluafile{data-tre}{}
+\registerctxluafile{data-lua}{}
+\registerctxluafile{data-ctx}{}
+\registerctxluafile{data-con}{}
+\registerctxluafile{data-use}{}
+\registerctxluafile{data-aux}{}
+
+\registerctxluafile{luat-cbk}{autosuffix}
+\registerctxluafile{luat-run}{}
+\registerctxluafile{luat-fio}{autosuffix}
+\registerctxluafile{luat-cnf}{}
+\registerctxluafile{luat-lua}{}
+\registerctxluafile{luat-sto}{}
+\registerctxluafile{luat-ini}{autosuffix}
+\registerctxluafile{util-env}{}
+\registerctxluafile{luat-env}{}
+\registerctxluafile{luat-exe}{} % simplified
+\registerctxluafile{luat-iop}{} % simplified
+%registerctxluafile{luat-bwc}{}
+\registerctxluafile{trac-lmx}{} % might become l-lmx or luat-lmx
+\registerctxluafile{luat-mac}{}
+%registerctxluafile{luat-prp}{} % for the moment of not much use
+
+\registerctxluafile{lxml-tab}{}
+\registerctxluafile{lxml-lpt}{}
+\registerctxluafile{lxml-xml}{}
+\registerctxluafile{lxml-aux}{}
+\registerctxluafile{lxml-mis}{}
+
+% \pushoverloadmode
+%
+% \ifdefined\writestatus \else \protected\def\writestatus#1#2{\ctxlua{logs.status([==[#1]==],[==[#2]==])}} \fi
+% \ifdefined\writestring \else \protected\def\writestring #1{\ctxlua{logs.writer([==[#1]==],"\string\n")}} \fi
+% \ifdefined\writeline \else \protected\def\writeline {\ctxlua{logs.newline()}} \fi
+%
+% \popoverloadmode
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-log.lmt b/Master/texmf-dist/tex/context/base/mkxl/luat-log.lmt
new file mode 100644
index 00000000000..522f4ac4ff6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-log.lmt
@@ -0,0 +1,739 @@
+if not modules then modules = { } end modules ['luat-log'] = {
+ version = 1.001,
+ comment = "companion to trac-log.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- In fact all writes could go through lua and we could write the console and
+-- terminal handler in lua then. Ok, maybe it's slower then, so a no-go.
+
+-- This used to be combined in trac-log but as we also split between mkiv and lmtx
+-- we now have dedicated files. A side effect is a smaller format and a smaller
+-- mtxrun.
+--
+-- We use different targets: "terminal" "logfile", "both" and have no number
+-- channel.
+
+local next, type, select, print = next, type, select, print
+local format, gmatch, find = string.format, string.gmatch, string.find
+local concat, insert, remove = table.concat, table.insert, table.remove
+local topattern = string.topattern
+local utfchar = utf.char
+local datetime = os.date
+local openfile = io.open
+
+local write_nl = texio.write_nl
+local write = texio.write
+
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+local settings_to_hash = utilities.parsers.settings_to_hash
+local sortedkeys = table.sortedkeys
+
+-- variant is set now
+
+local variant = "default"
+----- variant = "ansi"
+
+logs = logs or { }
+local logs = logs
+
+-- we extend the formatters:
+
+formatters.add (
+ formatters, "unichr",
+ [["U+" .. format("%%05X",%s) .. " (" .. utfchar(%s) .. ")"]]
+)
+
+formatters.add (
+ formatters, "chruni",
+ [[utfchar(%s) .. " (U+" .. format("%%05X",%s) .. ")"]]
+)
+
+-- basic loggers
+
+local function ignore() end
+
+setmetatableindex(logs, function(t,k) t[k] = ignore ; return ignore end)
+
+local report, subreport, status, settarget, setformats, settranslations
+
+local direct, subdirect, writer, pushtarget, poptarget, setlogfile, settimedlog, setprocessor, setformatters, newline
+
+-- we use formatters but best check for % then because for simple messages but
+-- we don't want this overhead for single messages (not that there are that
+-- many; we could have a special weak table)
+
+local function ansisupported(specification)
+ if specification ~= "ansi" and specification ~= "ansilog" then
+ return false
+ elseif os and os.enableansi then
+ return os.enableansi()
+ else
+ return false
+ end
+end
+
+do
+
+ if arg and ansisupported then
+ -- we're don't have environment.arguments yet
+ for k, v in next, arg do -- k can be negative !
+ if v == "--ansi" or v == "--c:ansi" then
+ if ansisupported("ansi") then
+ variant = "ansi"
+ end
+ break
+ elseif v == "--ansilog" or v == "--c:ansilog" then
+ if ansisupported("ansilog") then
+ variant = "ansilog"
+ end
+ break
+ end
+ end
+ end
+
+ local whereto = "both"
+ local target = nil
+ local targets = nil
+
+ local formats = table.setmetatableindex("self")
+ local translations = table.setmetatableindex("self")
+
+ local report_yes, subreport_yes, direct_yes, subdirect_yes, status_yes
+ local report_nop, subreport_nop, direct_nop, subdirect_nop, status_nop
+
+ local variants = {
+ default = {
+ formats = {
+ report_yes = formatters["%-15s > %s\n"],
+ report_nop = formatters["%-15s >\n"],
+ direct_yes = formatters["%-15s > %s"],
+ direct_nop = formatters["%-15s >"],
+ subreport_yes = formatters["%-15s > %s > %s\n"],
+ subreport_nop = formatters["%-15s > %s >\n"],
+ subdirect_yes = formatters["%-15s > %s > %s"],
+ subdirect_nop = formatters["%-15s > %s >"],
+ status_yes = formatters["%-15s : %s\n"],
+ status_nop = formatters["%-15s :\n"],
+ },
+ targets = setmetatableindex( {
+ logfile = "logfile",
+ log = "logfile",
+ file = "logfile",
+ console = "terminal",
+ terminal = "terminal",
+ both = "terminal_and_logfile",
+ }, function(t,k) t[k] = "terminal_and_logfile" end),
+ },
+ ansi = {
+ formats = {
+ report_yes = formatters["[0;33m%-15s [0;1m>[0m %s\n"],
+ report_nop = formatters["[0;33m%-15s [0;1m>[0m\n"],
+ direct_yes = formatters["[0;33m%-15s [0;1m>[0m %s"],
+ direct_nop = formatters["[0;33m%-15s [0;1m>[0m"],
+ subreport_yes = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m %s\n"],
+ subreport_nop = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m\n"],
+ subdirect_yes = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m %s"],
+ subdirect_nop = formatters["[0;33m%-15s [0;1m>[0;35m %s [0;1m>[0m"],
+ status_yes = formatters["[0;33m%-15s [0;1m:[0m %s\n"],
+ status_nop = formatters["[0;33m%-15s [0;1m:[0m\n"],
+ },
+ targets = setmetatableindex( {
+ logfile = false,
+ log = false,
+ file = false,
+ console = "terminal",
+ terminal = "terminal",
+ both = "terminal",
+ }, function(t,k) t[k] = "terminal" end),
+ }
+ }
+
+ variants.ansilog = {
+ formats = variants.ansi.formats,
+ targets = variants.default.targets,
+ }
+
+ logs.flush = io.flush
+
+ writer = function(...)
+ if target then
+ write_nl(target,...)
+ end
+ end
+
+ newline = function()
+ if target then
+ write_nl(target,"\n")
+ end
+ end
+
+ report = function(a,b,c,...)
+ if not target then
+ -- ignore
+ elseif c ~= nil then
+ write_nl(target,report_yes(translations[a],formatters[formats[b]](c,...)))
+ elseif b then
+ write_nl(target,report_yes(translations[a],formats[b]))
+ elseif a then
+ write_nl(target,report_nop(translations[a]))
+ else
+ write_nl(target,"\n")
+ end
+ end
+
+ direct = function(a,b,c,...)
+ if not target then
+ return ""
+ elseif c ~= nil then
+ return direct_yes(translations[a],formatters[formats[b]](c,...))
+ elseif b then
+ return direct_yes(translations[a],formats[b])
+ elseif a then
+ return direct_nop(translations[a])
+ else
+ return ""
+ end
+ end
+
+ subreport = function(a,s,b,c,...)
+ if not target then
+ -- ignore
+ elseif c ~= nil then
+ write_nl(target,subreport_yes(translations[a],translations[s],formatters[formats[b]](c,...)))
+ elseif b then
+ write_nl(target,subreport_yes(translations[a],translations[s],formats[b]))
+ elseif a then
+ write_nl(target,subreport_nop(translations[a],translations[s]))
+ else
+ write_nl(target,"\n")
+ end
+ end
+
+ subdirect = function(a,s,b,c,...)
+ if not target then
+ return ""
+ elseif c ~= nil then
+ return subdirect_yes(translations[a],translations[s],formatters[formats[b]](c,...))
+ elseif b then
+ return subdirect_yes(translations[a],translations[s],formats[b])
+ elseif a then
+ return subdirect_nop(translations[a],translations[s])
+ else
+ return ""
+ end
+ end
+
+ status = function(a,b,c,...)
+ if not target then
+ -- ignore
+ elseif c ~= nil then
+ write_nl(target,status_yes(translations[a],formatters[formats[b]](c,...)))
+ elseif b then
+ write_nl(target,status_yes(translations[a],formats[b]))
+ elseif a then
+ write_nl(target,status_nop(translations[a]))
+ else
+ write_nl(target,"\n")
+ end
+ end
+
+ settarget = function(askedwhereto)
+ whereto = askedwhereto or whereto or "both"
+ target = targets[whereto]
+ if not target then
+ whereto = "both"
+ target = targets[whereto]
+ end
+ if target == "terminal" or target == "terminal_and_logfile" then
+ logs.flush = io.flush
+ else
+ logs.flush = ignore
+ end
+ end
+
+ local stack = { }
+
+ pushtarget = function(newtarget)
+ insert(stack,target)
+ settarget(newtarget)
+ end
+
+ poptarget = function()
+ if #stack > 0 then
+ settarget(remove(stack))
+ end
+ end
+
+ setformats = function(f)
+ formats = f
+ end
+
+ settranslations = function(t)
+ translations = t
+ end
+
+ setprocessor = function(f)
+ local writeline = write_nl
+ write_nl = function(target,...)
+ if target then
+ writeline(target,f(...))
+ end
+ end
+ end
+
+ setformatters = function(specification)
+ local t = nil
+ local f = nil
+ local d = variants.default
+ if not specification then
+ --
+ elseif type(specification) == "table" then
+ t = specification.targets
+ f = specification.formats or specification
+ else
+ if not ansisupported(specification) then
+ specification = "default"
+ end
+ local v = variants[specification]
+ if v then
+ t = v.targets
+ f = v.formats
+ variant = specification
+ end
+ end
+ targets = t or d.targets
+ target = targets[whereto]
+ if f then
+ d = d.formats
+ else
+ f = d.formats
+ d = f
+ end
+ setmetatableindex(f,d)
+ report_yes = f.report_yes
+ report_nop = f.report_nop
+ subreport_yes = f.subreport_yes
+ subreport_nop = f.subreport_nop
+ direct_yes = f.direct_yes
+ direct_nop = f.direct_nop
+ subdirect_yes = f.subdirect_yes
+ subdirect_nop = f.subdirect_nop
+ status_yes = f.status_yes
+ status_nop = f.status_nop
+ settarget(whereto)
+ end
+
+ setformatters(variant)
+
+ setlogfile = ignore
+ settimedlog = ignore
+
+end
+
+logs.report = report
+logs.subreport = subreport
+logs.status = status
+logs.settarget = settarget
+logs.pushtarget = pushtarget
+logs.poptarget = poptarget
+logs.setformats = setformats
+logs.settranslations = settranslations
+
+logs.setlogfile = setlogfile
+logs.settimedlog = settimedlog
+logs.setprocessor = setprocessor
+logs.setformatters = setformatters
+
+logs.direct = direct
+logs.subdirect = subdirect
+logs.writer = writer
+logs.newline = newline
+
+local data = { }
+local states = nil
+local force = false
+
+function logs.reporter(category,subcategory)
+ local logger = data[category]
+ if not logger then
+ local state = states == true
+ if not state and type(states) == "table" then
+ for c, _ in next, states do
+ if find(category,c) then
+ state = true
+ break
+ end
+ end
+ end
+ logger = {
+ reporters = { },
+ state = state,
+ }
+ data[category] = logger
+ end
+ local reporter = logger.reporters[subcategory or "default"]
+ if not reporter then
+ if subcategory then
+ reporter = function(...)
+ if force or not logger.state then
+ subreport(category,subcategory,...)
+ end
+ end
+ logger.reporters[subcategory] = reporter
+ else
+ local tag = category
+ reporter = function(...)
+ if force or not logger.state then
+ report(category,...)
+ end
+ end
+ logger.reporters.default = reporter
+ end
+ end
+ return reporter
+end
+
+logs.new = logs.reporter -- for old times sake
+
+-- context specicific: this ends up in the macro stream
+
+local ctxreport = logs.writer
+
+function logs.setmessenger(m)
+ ctxreport = m
+end
+
+function logs.messenger(category,subcategory)
+ -- we need to avoid catcode mess (todo: fast context)
+ if subcategory then
+ return function(...)
+ ctxreport(subdirect(category,subcategory,...))
+ end
+ else
+ return function(...)
+ ctxreport(direct(category,...))
+ end
+ end
+end
+
+-- so far
+
+local function setblocked(category,value) -- v.state == value == true : disable
+ if category == true or category == "all" then
+ -- lock all
+ category, value = "*", true
+ elseif category == false then
+ -- unlock all
+ category, value = "*", false
+ elseif value == nil then
+ -- lock selective
+ value = true
+ end
+ if category == "*" then
+ states = value
+ for k, v in next, data do
+ v.state = value
+ end
+ else
+ alllocked = false
+ states = settings_to_hash(category,type(states)=="table" and states or nil)
+ for c in next, states do
+ local v = data[c]
+ if v then
+ v.state = value
+ else
+ c = topattern(c,true,true)
+ for k, v in next, data do
+ if find(k,c) then
+ v.state = value
+ end
+ end
+ end
+ end
+ end
+end
+
+function logs.disable(category,value)
+ setblocked(category,value == nil and true or value)
+end
+
+function logs.enable(category)
+ setblocked(category,false)
+end
+
+function logs.categories()
+ return sortedkeys(data)
+end
+
+function logs.show()
+ local n, c, s, max = 0, 0, 0, 0
+ for category, v in table.sortedpairs(data) do
+ n = n + 1
+ local state = v.state
+ local reporters = v.reporters
+ local nc = #category
+ if nc > c then
+ c = nc
+ end
+ for subcategory, _ in next, reporters do
+ local ns = #subcategory
+ if ns > c then
+ s = ns
+ end
+ local m = nc + ns
+ if m > max then
+ max = m
+ end
+ end
+ local subcategories = concat(sortedkeys(reporters),", ")
+ if state == true then
+ state = "disabled"
+ elseif state == false then
+ state = "enabled"
+ else
+ state = "unknown"
+ end
+ -- no new here
+ report("logging","category %a, subcategories %a, state %a",category,subcategories,state)
+ end
+ report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
+end
+
+local delayed_reporters = { }
+
+setmetatableindex(delayed_reporters,function(t,k)
+ local v = logs.reporter(k.name)
+ t[k] = v
+ return v
+end)
+
+function utilities.setters.report(setter,...)
+ delayed_reporters[setter](...)
+end
+
+directives.register("logs.blocked", function(v)
+ setblocked(v,true)
+end)
+
+directives.register("logs.target", function(v)
+ settarget(v)
+end)
+
+do
+
+ local report = logs.reporter("pages") -- not needed but saves checking when we grep for it
+ local texgetcount = tex and tex.getcount
+
+ local real, user, sub = 0, 0, 0
+
+ function logs.start_page_number()
+ real = texgetcount("realpageno")
+ user = texgetcount("userpageno")
+ sub = texgetcount("subpageno")
+ end
+
+ local timing = false
+ local usage = false
+ local lasttime = nil
+
+ logs.private = {
+ enablepagetiming = function()
+ usage = true
+ end,
+ getpagetiming = function()
+ return type(usage) == "table" and usage
+ end,
+ }
+
+ trackers.register("pages.timing", function() timing = "" end)
+
+ function logs.stop_page_number() -- the first page can includes the initialization so we omit this in average
+ if timing or usage then
+ local elapsed = statistics.currenttime(statistics)
+ local average, page
+ if not lasttime or real < 2 then
+ average = elapsed
+ page = elapsed
+ else
+ average = elapsed / (real - 1)
+ page = elapsed - lasttime
+ end
+ lasttime = elapsed
+ if timing then
+ timing = formatters[", total %0.03f, page %0.03f, average %0.03f"](elapsed,page,average)
+ end
+ if usage then
+ usage = {
+ page = {
+ real = real,
+ user = user,
+ sub = sub,
+ },
+ time = {
+ elapsed = elapsed,
+ page = page,
+ average = average,
+ }
+ }
+ end
+ end
+ if real <= 0 then
+ report("flushing page%s",timing)
+ elseif user <= 0 then
+ report("flushing realpage %s%s",real,timing)
+ elseif sub <= 0 then
+ report("flushing realpage %s, userpage %s%s",real,user,timing)
+ else
+ report("flushing realpage %s, userpage %s, subpage %s%s",real,user,sub,timing)
+ end
+ logs.flush()
+ end
+
+end
+
+-- we don't have show_open and show_close callbacks yet
+
+do
+ local texerror = tex and tex.error or print
+ local formatters = string.formatters
+
+ function logs.texerrormessage(fmt,first,...) -- for the moment we put this function here
+ texerror(first and formatters[fmt](first,...) or fmt)
+ end
+
+end
+
+-- this is somewhat slower but prevents out-of-order messages when print is mixed
+-- with texio.write
+
+-- io.stdout:setvbuf('no')
+-- io.stderr:setvbuf('no')
+
+-- windows: > nul 2>&1
+-- unix : > null 2>&1
+
+if package.helpers.report then
+ package.helpers.report = logs.reporter("package loader") -- when used outside mtxrun
+end
+
+do
+
+ local finalactions = { }
+ local fatalerrors = { }
+ local possiblefatal = { }
+ local loggingerrors = false
+
+ function logs.loggingerrors()
+ return loggingerrors
+ end
+
+ directives.register("logs.errors",function(v)
+ loggingerrors = v
+ if type(v) == "string" then
+ fatalerrors = settings_to_hash(v)
+ else
+ fatalerrors = { }
+ end
+ end)
+
+ function logs.registerfinalactions(...)
+ insert(finalactions,...) -- so we can force an order if needed
+ end
+
+ local what = nil
+ local report = nil
+ local state = nil
+ local target = nil
+
+ local function startlogging(t,r,w,s)
+ target = t
+ state = force
+ force = true
+ report = type(r) == "function" and r or logs.reporter(r)
+ what = w
+ pushtarget(target)
+ newline()
+ if s then
+ report("start %s: %s",what,s)
+ else
+ report("start %s",what or "")
+ end
+ if target == "logfile" then
+ newline()
+ end
+ return report
+ end
+
+ local function stoplogging()
+ if target == "logfile" then
+ newline()
+ end
+ report("stop %s",what or "")
+ if target == "logfile" then
+ newline()
+ end
+ poptarget()
+ state = oldstate
+ end
+
+ function logs.startfilelogging(...)
+ return startlogging("logfile", ...)
+ end
+
+ logs.stopfilelogging = stoplogging
+
+ local done = false
+
+ function logs.starterrorlogging(r,w,...)
+ if not done then
+ pushtarget("terminal")
+ newline()
+ logs.report("error logging","start possible issues")
+ poptarget()
+ done = true
+ end
+ if fatalerrors[w] then
+ possiblefatal[w] = true
+ end
+ return startlogging("terminal",r,w,...)
+ end
+
+ logs.stoperrorlogging = stoplogging
+
+ function logs.finalactions()
+ if #finalactions > 0 then
+ for i=1,#finalactions do
+ finalactions[i]()
+ end
+ if done then
+ pushtarget("terminal")
+ newline()
+ logs.report("error logging","stop possible issues")
+ poptarget()
+ end
+ return next(possiblefatal) and sortedkeys(possiblefatal) or false
+ end
+ end
+
+end
+
+-- just in case we load from context
+
+local dummy = function() end
+
+function logs.application(t)
+ return {
+ name = t.name or tex.jobname,
+ banner = t.banner,
+ report = logs.reporter(t.name),
+ moreinfo = dummy,
+ export = dummy,
+ help = dummy,
+ identify = dummy,
+ version = dummy,
+ }
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-soc.mkxl b/Master/texmf-dist/tex/context/base/mkxl/luat-soc.mkxl
new file mode 100644
index 00000000000..b2ce7048395
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-soc.mkxl
@@ -0,0 +1,52 @@
+%D \module
+%D [ file=luat-soc,
+%D version=2018.08.05,
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Socket Libraries,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Macros / Socket Libraries}
+
+%D In \LUATEX\ we provide the socket library that is more or less the standard one
+%D for \LUA. It has been around for a while and seems to be pretty stable. The
+%D binary module is copmpiled into \LUATEX\ and the accompanying .lua files are
+%D preloaded. These files are mostly written by Diego Nehab, Andre Carregal, Javier
+%D Guerra, and Fabio Mascarenhas with contributions from Diego Nehab, Mike Pall,
+%D David Burgess, Leonardo Godinho, Thomas Harning Jr., and Gary NG. The originals
+%D are part of and copyrighted by the Kepler project.
+%D
+%D Here we reload a slightly reworked version of these \type {.lua} files. We keep
+%D the same (documented) interface but streamlined some fo the code. No more
+%D modules, no more pre 5.2 \LUA, etc. Also, as it loads into the \CONTEXT
+%D ecosystem, we plug in some logging. (and maybe tracing in the future). As we
+%D don't support serial ports in \LUATEX, related code has been dropped.
+%D
+%D The files are reformatted so that we can more easilly add additional features
+%D and|/|or tracing options. Any error introduced there is our fault! The url module
+%D might be replaced by the one in \CONTEXT. When we need mbox a suitable variant
+%D will be provided.
+
+%D Currently we preload the related \LUA\ code in \LUATEX, but that might change at
+%D some point. We're prepared for that.
+
+% \registerctxluafile{util-soc-imp-reset} {}
+%
+% \registerctxluafile{util-soc-imp-socket} {}
+% % registerctxluafile{util-soc-imp-copas} {}
+% \registerctxluafile{util-soc-imp-ltn12} {}
+% % registerctxluafile{util-soc-imp-mbox} {}
+% \registerctxluafile{util-soc-imp-mime} {}
+% \registerctxluafile{util-soc-imp-url} {}
+% \registerctxluafile{util-soc-imp-headers}{}
+% \registerctxluafile{util-soc-imp-http} {}
+% \registerctxluafile{util-soc-imp-tp} {}
+% % registerctxluafile{util-soc-imp-ftp} {}
+% % registerctxluafile{util-soc-imp-smtp} {}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-usr.lmt b/Master/texmf-dist/tex/context/base/mkxl/luat-usr.lmt
new file mode 100644
index 00000000000..4b876b93539
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-usr.lmt
@@ -0,0 +1,177 @@
+if not modules then modules = { } end modules ['luat-usr'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local global = global
+
+local moduledata = moduledata
+local thirddata = thirddata
+local userdata = userdata
+local documentdata = documentdata
+
+local context = context
+local tostring = tostring
+local tonumber = tonumber
+local print = print
+
+local string = string
+local table = table
+local lpeg = lpeg
+local math = math
+local io = io
+local os = os
+local lpeg = lpeg
+
+local setmetatableindex = table.setmetatableindex
+local load = load
+local xpcall = xpcall
+local instance_banner = string.formatters["=[instance: %s]"] -- the = controls the lua error / see: lobject.c
+local tex_errormessage = context.errmessage
+
+local implement = interfaces.implement
+local reporter = logs.reporter
+
+local report_instance = reporter("lua instance")
+local report_script = reporter("lua script")
+local report_thread = reporter("lua thread")
+local newline = logs.newline
+
+lua.numbers = lua.numbers or { }
+lua.messages = lua.messages or { }
+
+local numbers = lua.numbers
+local messages = lua.messages
+
+storage.register("lua/numbers", numbers, "lua.numbers" )
+storage.register("lua/messages", messages, "lua.messages")
+
+-- First we implement a pure lua version of directlua and a persistent
+-- variant of it:
+
+local function runscript(code)
+ local done, message = loadstring(code)
+ if done then
+ done()
+ else
+ newline()
+ report_script("error : %s",message or "unknown")
+ report_script()
+ report_script("code : %s",code)
+ newline()
+ end
+end
+
+local threads = setmetatableindex(function(t,k)
+ local v = setmetatableindex({},global)
+ t[k] = v
+ return v
+end)
+
+local function runthread(name,code)
+ if not code or code == "" then
+ threads[name] = nil
+ else
+ local thread = threads[name]
+ local done, message = loadstring(code,nil,nil,thread)
+ if done then
+ done()
+ else
+ newline()
+ report_thread("thread: %s",name)
+ report_thread("error : %s",message or "unknown")
+ report_thread()
+ report_thread("code : %s",code)
+ newline()
+ end
+ end
+end
+
+interfaces.implement {
+ name = "luascript",
+ actions = runscript,
+ public = true,
+ protected = true,
+ arguments = "string"
+}
+
+interfaces.implement {
+ name = "luathread",
+ actions = runthread,
+ public = true,
+ protected = true,
+ arguments = "2 strings",
+}
+
+local function registername(name,message)
+ if not name or name == "" then
+ report_instance("no valid name given")
+ return
+ end
+ if not message or message == "" then
+ message = name
+ end
+ local lnn = numbers[name]
+ if not lnn then
+ lnn = #messages + 1
+ messages[lnn] = message
+ numbers[name] = lnn
+ end
+ local report = reporter("lua instance",message)
+ local proxy = {
+ -- we can access all via:
+ global = global, -- or maybe just a metatable
+ -- some protected data
+ moduledata = setmetatableindex(moduledata),
+ thirddata = setmetatableindex(thirddata),
+ -- less protected data
+ userdata = userdata,
+ documentdata = documentdata,
+ -- always there fast
+ context = context,
+ --
+ tostring = tostring,
+ tonumber = tonumber,
+ -- standard lua modules
+ string = string,
+ table = table,
+ lpeg = lpeg,
+ math = math,
+ io = io,
+ os = os,
+ lpeg = lpeg,
+ --
+ print = print,
+ report = report,
+ }
+ return function(code)
+ local code, message = load(code,nil,nil,proxy)
+ if not code then
+ report_instance("error: %s",message or code)
+ elseif not xpcall(code,report) then
+ tex_errormessage("hit return to continue or quit this run")
+ end
+ end
+end
+
+lua.registername = registername
+
+implement {
+ name = "registernamedlua",
+ arguments = "3 strings",
+ actions = function(name,message,csname)
+ if csname and csname ~= "" then
+ implement {
+ name = csname,
+ arguments = "string",
+ actions = registername(name,message) or report,
+ scope = "private",
+ }
+ else
+ report_instance("unvalid csname for %a",message or name or "?")
+ end
+ end
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/luat-usr.mkxl b/Master/texmf-dist/tex/context/base/mkxl/luat-usr.mkxl
new file mode 100644
index 00000000000..199d22b8e6f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/luat-usr.mkxl
@@ -0,0 +1,121 @@
+%D \module
+%D [ file=luat-usr,
+%D version=2005.08.11,% moved from luat-ini
+%D title=\CONTEXT\ Lua Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Macros / Userspace}
+
+\unprotect
+
+\registerctxluafile{luat-usr}{autosuffix}
+
+%D A few goodies:
+%D
+%D \startbuffer
+%D \luascript { context("foo 1:") context(i) }
+%D \luathread {test} { i = 10 context("bar 1:") context(i) }
+%D \luathread {test} { context("bar 2:") context(i) }
+%D \luathread {test} {}
+%D \luathread {test} { context("bar 3:") context(i) }
+%D \luascript { context("foo 2:") context(i) }
+%D \stopbuffer
+%D
+%D \typebuffer \startlines \getbuffer \stoplines
+
+% \luascript % defined at the lua end
+% \luathread % defined at the lua end
+
+%D \macros
+%D {definenamedlua}
+%D
+%D We provide an interface for defining instances. We don't have the definers yet
+%D so we do it low level:
+
+\def\s!lua {lua}
+\def\s!code {code}
+\def\s!data {data}
+\def\s!start{start}
+\def\s!stop {stop}
+
+%D Beware: because \type {\expanded} is een convert command, the error message will
+%D show \type{} as part of the message.
+
+\installsystemnamespace{luacode}
+
+\permanent\tolerant\protected\def\definenamedlua[#1]#*[#2]%
+ {\ifarguments \orelse \ifcsname\??luacode#1\endcsname \else
+ \bgroup
+ %
+ \edef\m_syst_lua_name{lua_code_#1}%
+ %
+ \clf_registernamedlua{#1}{#2}{\m_syst_lua_name}%
+ %
+ \frozen\instance\protected\xdefcsname\s!start#1\s!code\endcsname
+ {\begingroup
+ \obeylualines
+ \obeyluatokens
+ \csname\??luacode#1\endcsname}%
+ %
+ \aliased\gletcsname\s!stop#1\s!code\endcsname\relax
+ %
+ \normalexpanded{\xdefcsname\??luacode#1\endcsname##1\csname\s!stop#1\s!code\endcsname}%
+ {\noexpand\expandafter\endgroup
+ \noexpand\expandafter
+ \expandafter\noexpand\csname clf_\m_syst_lua_name\endcsname
+ \noexpand\expandafter{\noexpand\normalexpanded{##1}}}%
+ \frozen\instance\gletcsname#1\s!code\expandafter\endcsname\csname clf_\m_syst_lua_name\endcsname
+ \egroup
+ \fi}
+
+%D We predefine a few.
+
+% \definenamedlua[module][module instance] % not needed
+
+\appendtoks
+ \definenamedlua[user] [private user]
+ \definenamedlua[third] [third party module]
+ \definenamedlua[isolated][isolated]
+\to \everyjob
+
+%D In practice this works out as follows:
+%D
+%D \startbuffer
+%D \startluacode
+%D context("LUA")
+%D \stopluacode
+%D
+%D \startusercode
+%D global.context("USER 1")
+%D context.par()
+%D context("USER 2")
+%D context.par()
+%D if characters then
+%D context("ACCESS directly")
+%D elseif global.characters then
+%D context("ACCESS via global")
+%D else
+%D context("NO ACCESS at all")
+%D end
+%D context.par()
+%D if bogus then
+%D context("ACCESS directly")
+%D elseif global.bogus then
+%D context("ACCESS via global")
+%D else
+%D context("NO ACCESS at all")
+%D end
+%D context.par()
+%D \stopusercode
+%D \stopbuffer
+%D
+%D \typebuffer
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lxml-css.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lxml-css.mkxl
new file mode 100644
index 00000000000..325516e16fc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lxml-css.mkxl
@@ -0,0 +1,76 @@
+%D \module
+%D [ file=lxml-css,
+%D version=2010.01.28,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Css Helpers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{lxml-css}{}
+
+\unprotect
+
+\permanent\def\ctxmodulecss#1{\ctxlua{moduledata.css.#1}}
+
+% No stable interface yet.
+
+% \edef\CellPadding{\xmlatt{#1}{cellpadding}}
+% \ifempty\CellPadding
+% \edef\CellPadding{.25ex}
+% \else
+% \edef\CellPadding{\cssgetsinglepadding{\xmlatt{#1}{cellpadding}}}
+% \fi
+%
+% \starttexdefinition cssgetsinglepadding #1
+% \ctxlua {
+% context((moduledata.css.padding(
+% "#1",
+% \number\dimexpr0.1ex,
+% \number\dimexpr0.01\hsize,
+% \number\dimexpr1ex,
+% \number\dimexpr1em
+% ))) % returns 4 values therefore ()
+% }sp
+% \stoptexdefinition
+
+% \startxmlsetups html:settings
+% \xmlsetsetup{#1}{p}{html:p}
+% \stopxmlsetups
+%
+% \xmlmapvalue{ctx-before} {one} {\page BEFORE\par}
+% \xmlmapvalue{ctx-after} {two} {\par AFTER\page}
+% \xmlmapvalue{text-decoration}{underline}{U}
+% \xmlmapvalue{text-decoration}{overline} {O}
+%
+% \startxmlsetups html:p
+% \testfeatureonce{100000}{
+% \edef\foo{\xmlcssstylevalue{#1}{ctx-before}\xmlcssstylevalue{#1}{ctx-after}}
+% }
+% \page {\tttf style="\xmlatt{#1}{style}"} : \elapsedtime\ s \page
+% \xmlvalue{ctx-before}{\xmlcssstylevalue{#1}{ctx-before}}{}
+% \xmlflush{#1}
+% (\xmlcssstylevalue{#1}{text-decoration})
+% (\xmlcssmappedstylevalue{#1}{text-decoration}{text-decoration})
+% \xmlvalue{ctx-after} {\xmlcssstylevalue{#1}{ctx-after}}{}
+% \stopxmlsetups
+%
+% \startbuffer[temp]
+%
+%
foo 1
+%
foo 2
+%
+% \stopbuffer
+%
+% \xmlregistersetup{html:settings}
+% \xmlprocessbuffer{main}{temp}{}
+
+% \xmlcssstylevalue % defined at lua end
+% \xmlcssmappedstylevalue % defined at lua end
+
+\protect \endinput
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lxml-ctx.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lxml-ctx.mkxl
new file mode 100644
index 00000000000..f4b2edc798f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lxml-ctx.mkxl
@@ -0,0 +1,58 @@
+%D \module
+%D [ file=lxml-ctx,
+%D version=2007.08.17,
+%D title=\CONTEXT\ \XML\ Support,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Experimental. This might change! Also, it might become a module
+%D instead if core code.
+
+\writestatus{loading}{ConTeXt XML Support / Goodies}
+
+\registerctxluafile{lxml-ctx}{}
+
+\unprotect
+
+\settrue \xmllshowbuffer
+\setfalse\xmllshowtitle
+\settrue \xmllshowwarning
+
+\definehead
+ [lshowtitle]
+ [subsubsubsubsubject]
+
+\setuphead
+ [lshowtitle]
+ [\c!style=\tta]
+
+\permanent\protected\def\xmllshow#1%
+ {\ctxlua{xml.ctx.tshow {
+ pattern = \!!bs\detokenize{#1}\!!es,
+ \ifconditional\xmllshowtitle
+ title = "lshowtitle",
+ \fi
+ \ifconditional\xmllshowwarning
+ warning = true,
+ \fi
+ } }}
+
+\permanent\protected\def\xmllshowbuffer#1#2#3%
+ {\ctxlua{xml.ctx.tshow {
+ pattern = \!!bs\detokenize{#2}\!!es,
+ \ifconditional\xmllshowbuffer
+ xmlroot = "#1",
+ attribute = "#3",
+ \fi
+ \ifconditional\xmllshowwarning
+ warning = true,
+ \fi
+ } }}
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lxml-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lxml-ini.mkxl
new file mode 100644
index 00000000000..01d0f883f96
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lxml-ini.mkxl
@@ -0,0 +1,448 @@
+%D \module
+%D [ file=lxml-ini,
+%D version=2007.08.17,
+%D title=\CONTEXT\ \XML\ Support,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Todo: auto apply setups (manage at lua end)
+%D Todo: manuak: \xmlinclusion \xmlinclusions
+
+\writestatus{loading}{ConTeXt XML Support / Initialization}
+
+%registerctxluafile{lxml-tab}{} % loader
+%registerctxluafile{lxml-lpt}{} % parser
+%registerctxluafile{lxml-xml}{} % xml finalizers
+%registerctxluafile{lxml-aux}{} % extras using parser
+%registerctxluafile{lxml-mis}{} % extras independent of parser
+\registerctxluafile{lxml-ent}{} % entity hacks
+\registerctxluafile{lxml-tex}{} % tex finalizers
+\registerctxluafile{lxml-dir}{} % ctx hacks
+\registerctxluafile{lxml-ini}{} % interface
+
+\unprotect
+
+% todo: { } mandate so that we can alias
+
+% undocumented:
+
+\permanent\def\ctxlxml#1{\ctxlua{lxml.#1}}
+
+% for now indirect .. this will change when we have updated luatex (scan_argument)
+
+\permanent\def\xmlconcat #1#2#3{\clf_xmlconcat {#1}{#2}{\detokenize{#3}}}
+\permanent\def\xmlconcatrange #1#2#3#4#5{\clf_xmlconcatrange{#1}{#2}{#3}{#4}{\detokenize{#5}}}
+
+%D Maybe I should add \type {\protected} here:
+
+\permanent\def\xmlloadfile #1#2{\clf_xmlloadfile {#1}{#2}{\directxmlparameter\c!compress}}
+\permanent\def\xmlloadbuffer#1#2{\clf_xmlloadbuffer{#1}{#2}{\directxmlparameter\c!compress}}
+\permanent\def\xmlloaddata #1#2{\clf_xmlloaddata {#1}{#2}{\directxmlparameter\c!compress}}
+
+\aliased\let\xmlload\xmlloadfile
+
+%D These are defined at the \LUA\ end:
+
+% \xmlall \xmlatt \xmlattdef \xmlattribute \xmlattributedef \xmlbadinclusions
+% \xmlchainatt \xmlchainattdef \xmlchecknamespace \xmlcommand \xmlcontext \xmlcount
+% \xmldelete \xmldirect \xmldirectives \xmldirectivesafter \xmldirectivesbefore
+% \xmldisplayverbatim \xmlelement \xmlfilter \xmlfilterlist \xmlfirst \xmlflush
+% \xmlflushcontext \xmlflushlinewise \xmlflushpure \xmlflushspacewise \xmlflushtext
+% \xmlfunction \xmlinclude \xmlincludeoptions \xmlinclusion \xmlinclusionbase
+% \xmlinclusions \xmlindex \xmlinlineverbatim \xmllast \xmllastatt \xmllastmatch
+% \xmllastpar \xmlloaddirectives \xmlmain \xmlmatch \xmlname \xmlnamespace
+% \xmlnonspace \xmlpar \xmlparam \xmlpath \xmlpopmatch \xmlpos \xmlpure
+% \xmlpushmatch \xmlraw \xmlrefatt \xmlregisterns \xmlremapname \xmlremapnamespace
+% \xmlsave \xmlsetatt \xmlsetattribute \xmlsetpar \xmlsetparam \xmlsetsetup
+% \xmlsnippet \xmlstrip \xmlstripanywhere \xmlstripnolines \xmlstripped
+% \xmlstrippednolines \xmltag \xmltext \xmltobuffer \xmltobuffertextonly
+% \xmltobufferverbose \xmltofile \xmltoparameters \xmlverbatim
+
+\aliased\let\xmlposition\xmlindex
+
+\permanent\protected\def\xmlinfo#1{\hbox{\ttxx[\xmlname{#1}]}}
+\permanent\protected\def\xmlshow#1{\startpacked\ttx\xmlverbatim{#1}\stoppacked}
+
+% the next one is handy for mode runs because it enforces a consistent
+% #1 indexing (needed when using \xmltext{main:123}{...} like calls
+
+%let\xmladdindex \clf_xmladdindex
+
+% we need to pass the last argument as function, so
+
+\permanent\protected\def\xmlsetfunction#1#2#3{\ctxcommand{xmlsetfunction("#1",\!!bs#2\!!es,#3)}}
+
+% goodie:
+
+\immutable\def\xmltempbuffername{xml-temp}
+
+\permanent\protected\def\prettyprintbuffer#1#2% only used here
+ {\ifdefined\scitebuffer
+ \scitebuffer[#2][#1]%
+ \else
+ \typebuffer[#1][\c!option=#2]%
+ \fi}
+
+\permanent\protected\def\xmlprettyprint#1#2%
+ {\xmltobufferverbose{#1}{.}{\xmltempbuffername}%
+ \prettyprintbuffer\xmltempbuffername{#2}}
+
+\permanent\protected\def\xmlprettyprinttext#1#2%
+ {\xmltobuffertextonly{#1}{.}{\xmltempbuffername}%
+ \prettyprintbuffer\xmltempbuffername{#2}}
+
+\permanent\protected\def\inlineprettyprintbuffer#1#2% only used here
+ {\ifdefined\sciteinlinebuffer
+ \sciteinlinebuffer[#2][#1]%
+ \else
+ \typeinlinebuffer[#1][\c!option=#2]%
+ \fi}
+
+\permanent\protected\def\xmlinlineprettyprint#1#2%
+ {\xmltobufferverbose{#1}{.}{\xmltempbuffername}%
+ \inlineprettyprintbuffer\xmltempbuffername{#2}}
+
+\permanent\protected\def\xmlinlineprettyprinttext#1#2%
+ {\xmltobuffertextonly{#1}{.}{\xmltempbuffername}%
+ \inlineprettyprintbuffer\xmltempbuffername{#2}}
+
+% kind of special:
+
+\aliased\let\xmlstartraw\clf_xmlstartraw
+\aliased\let\xmlstopraw \clf_xmlstopraw
+
+\aliased\let\startxmlraw\clf_xmlstartraw
+\aliased\let\stopxmlraw \clf_xmlstopraw
+
+% These are expandable and defined at the \LUA\ end:
+
+% \xmldoif \xmldoifnot \xmldoifelse \xmldoiftext \xmldoifnottext \xmldoifelsetext
+% \xmldoifatt \xmldoifnotatt \xmldoifelseatt \xmldoifempty \xmldoifnotempty
+% \xmldoifelseempty \xmldoifselfempty \xmldoifnotselfempty \xmldoifelseselfempty
+
+\aliased\let\xmldoiftextelse \xmldoifelsetext
+\aliased\let\xmldoifemptyelse \xmldoifelseempty
+\aliased\let\xmldoifselfemptyelse \xmldoifelseselfempty
+
+% \startxmlsetups xml:include
+% \xmlinclude{main}{include}{filename|href}
+% \stopxmlsetups
+%
+% \xmlprependsetup{xml:include}
+
+% \let\xmlgrab\xmlsetsetup % obsolete
+% \let\xmlself\s!unknown % obsolete
+
+\aliased\let\xmlsetup\setupwithargumentswapped
+\aliased\let\xmls \setupwithargumentswapped % hardly any faster
+\aliased\let\xmlw \setupwithargument % hardly any faster
+
+% todo: 1:xml:whatever always before 3:xml:something
+
+\permanent\protected\def\xmlprependsetup #1{\clf_xmlprependsetup{*}{#1}}
+\permanent\protected\def\xmlappendsetup #1{\clf_xmlappendsetup {*}{#1}}
+\permanent\protected\def\xmlbeforesetup #1#2{\clf_xmlbeforesetup {*}{#1}{#2}}
+\permanent\protected\def\xmlaftersetup #1#2{\clf_xmlaftersetup {*}{#1}{#2}}
+\permanent\protected\def\xmlremovesetup #1{\clf_xmlremovesetup {*}{#1}}
+\permanent\protected\def\xmlresetsetups {\clf_xmlresetsetups {*}}
+
+\permanent\protected\def\xmlprependdocumentsetup #1#2{\clf_xmlprependsetup{#1}{#2}}
+\permanent\protected\def\xmlappenddocumentsetup #1#2{\clf_xmlappendsetup {#1}{#2}}
+\permanent\protected\def\xmlbeforedocumentsetup #1#2#3{\clf_xmlbeforesetup {#1}{#2}{#3}}
+\permanent\protected\def\xmlafterdocumentsetup #1#2#3{\clf_xmlaftersetup {#1}{#2}{#3}}
+\permanent\protected\def\xmlremovedocumentsetup #1#2{\clf_xmlremovesetup {#1}{#2}}
+\permanent\protected\def\xmlresetdocumentsetups #1{\clf_xmlresetsetups {#1}}
+
+\permanent\protected\def\xmlflushsetups #1{\clf_xmlflushsetups {#1}{*}{}} % #1 == id where to apply *
+\permanent\protected\def\xmlflushdocumentsetups #1#2{\clf_xmlflushsetups {#1}{*}{#2}} % #1 == id where to apply * and #2
+
+\aliased\let\xmlregistersetup \xmlappendsetup
+\aliased\let\xmlregisterdocumentsetup\xmlappenddocumentsetup
+
+\mutable\def\xmldocument{main}
+
+\permanent\protected\def\xmlregisteredsetups
+ {\xmlstarttiming
+ \xmlflushsetups\xmldocument
+ \xmldefaulttotext\xmldocument % after include
+ \xmlstoptiming}
+
+\permanent\protected\def\xmlregistereddocumentsetups#1#2% id setups
+ {\xmlstarttiming
+ % todo: test for duplicates !
+ \xmlflushdocumentsetups{#1}{#2}%
+ \xmldefaulttotext{#1}% after include
+ \xmlstoptiming}
+
+\permanent\protected\def\xmlstarttiming{\clf_xmlstarttiming} % undocumented
+\permanent\protected\def\xmlstoptiming {\clf_xmlstoptiming} % undocumented
+
+\def\lxml_process#1#2#3#4#5% flag \loader id name what initializersetup
+ {\begingroup
+ \edef\xmldocument{#3}% #2 can be \xmldocument and set as such
+ %xmlpushdocument{#3}%
+ #2{#3}{#4}%
+ \setcatcodetable\notcatcodes
+ \doifelsenothing{#5}%
+ {\xmlsetup{#3}{xml:process}}%
+ {\xmlsetup{#3}{#5}}%
+ %xmlpopdocument
+ \endgroup}
+
+\permanent\protected\def\xmlprocessfile {\lxml_process\plusone \xmlload}
+\permanent\protected\def\xmlprocessdata {\lxml_process\zerocount\xmlloaddata}
+\permanent\protected\def\xmlprocessbuffer{\lxml_process\zerocount\xmlloadbuffer}
+\aliased \let\xmlprocess \xmlprocessfile
+
+\startxmlsetups xml:flush
+ \xmlflush{#1}
+\stopxmlsetups
+
+\startxmlsetups xml:process
+ \xmlregistereddocumentsetups{#1}{#1}
+ \xmlmain{#1}
+\stopxmlsetups
+
+\permanent\protected\def\xmlloadonly#1#2#3%
+ {\xmlload{#1}{#2}%
+ \xmlregistereddocumentsetups{#1}{#3}}
+
+% replaced by concat
+%
+% \protected\def\xmlconnect#1#2#3% inefficient
+% {\scratchcounter\xmlcount{#1}{#2}\relax
+% \ifcase\scratchcounter \or
+% \xmlall{#1}{#2}%
+% \else
+% \dorecurse \scratchcounter
+% {\ifnum\recurselevel>\plusone#3\fi
+% \xmlidx{#1}{#2}\recurselevel}%
+% \fi}
+
+\permanent\protected\def\xmlcdataobeyedline {\obeyedline}
+\permanent\protected\def\xmlcdataobeyedspace{\strut\obeyedspace}
+\permanent\protected\def\xmlcdatabefore {\begingroup\tt}
+\permanent\protected\def\xmlcdataafter {\endgroup}
+
+% verbatim (dodo:pre/post whitespace, maybe splot verbatim and
+% cdata commands), experimental:
+%
+% \xmlsetfunction{main}{verbatim}{lxml.displayverbatim}
+% \xmlsetfunction{main}{verb} {lxml.inlineverbatim}
+
+% we use an xml: namespace so one has to define a suitable verbatim, say
+%
+% \definetyping[xml:verbatim][typing]
+%
+% this is experimental!
+
+\permanent\tolerant\protected\def\startxmldisplayverbatim[#1]%
+ {\startpacked
+ \edef\currenttyping{#1}%
+ \ifempty\currenttyping
+ \let\currenttyping\v!typing
+ \else % maybe test for existence
+ \edef\currenttyping{xml:\currenttyping}%
+ \fi
+ \enforced\protected\def\stopxmldisplayverbatim
+ {\endofverbatimlines
+ \stoppacked}%
+ \doinitializeverbatim
+ \beginofverbatimlines}
+
+\aliased\let\stopxmldisplayverbatim\relax
+
+\permanent\tolerant\protected\def\startxmlinlineverbatim[#1]%
+ {\begingroup
+ \edef\currenttype{#1}%
+ \ifempty\currenttype
+ \let\currenttype\v!type
+ \else % maybe test for existence
+ \edef\currenttype{xml:\currenttype}%
+ \fi
+ \enforced\let\stopxmlinlineverbatim\endgroup
+ \doinitializeverbatim}
+
+\aliased\let\stopxmlinlineverbatim\relax
+
+% processing instructions
+
+\permanent\protected\def\xmlinstalldirective#1#2%
+ {\clf_xmlinstalldirective{#1}{\csstring#2}}
+
+% an example:
+
+%
+
+\appendtoks
+ \xmlinstalldirective{tex}{xmltexcommand}%
+\to \everyjob
+
+\permanent\def\xmltexcommand#1{\begincsname#1\endcsname}
+
+% \def\xmlcontextdirective#1% kind class key value
+% {\executeifdefined{xml#1directive}\gobblethreearguments}
+
+% setting up xml:
+%
+% \setupxml[\c!default=] % mkiv only == text
+% \setupxml[\c!default=\v!none] % mkiv only, undefined -> hidden
+% \setupxml[\c!default=\v!text] % mkiv only, undefined -> text
+
+% \def\xmlctxdirective#1#2#3{\doif{#1}{clue}{\doif{#2}{page}}{\page[#3]}}
+
+\newconstant\xmlprocessingmode % 0=unset, 1=text, 2=hidden
+
+\installcorenamespace{xml}
+\installcorenamespace{xmldefaults}
+\installcorenamespace{xmlmapvalue}
+
+\installdirectcommandhandler \??xml {xml}
+
+\letvalue{\??xmldefaults\v!normal}\zerocount
+\letvalue{\??xmldefaults\v!none }\zerocount
+\letvalue{\??xmldefaults\v!text }\plusone
+\letvalue{\??xmldefaults\v!hidden}\plustwo
+
+\permanent\protected\def\xmldefaulttotext
+ {\ifcase\xmlprocessingmode
+ \expandafter\gobbleoneargument % 0 (none)
+ \or
+ \expandafter\clf_xmlsetcommandtotext % 1 (normal)
+ \or
+ \expandafter\clf_xmlsetcommandtonone % 2 (hidden)
+ \else
+ \expandafter\gobbleoneargument % (none)
+ \fi}
+
+\appendtoks
+ \xmlprocessingmode\executeifdefined{\??xmldefaults\directxmlparameter\c!default}\plusone
+\to \everysetupxml
+
+\setupxml
+ [\c!default=, % flush all
+ \c!compress=\v!no, % strip comment
+ \c!entities=\v!no] % load big entity file
+
+\appendtoks
+ \doif{\directxmlparameter\c!entities}\v!yes\clf_xmlloadentities
+\to \everysetupxml
+
+\permanent\def\xmlmapvalue #1#2#3{\setvalue{\??xmlmapvalue#1:#2}{#3}} % keep #3 to grab spaces
+\permanent\def\xmldoifelsevalue #1#2{\ifcsname\??xmlmapvalue#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
+
+\permanent\def\xmlvalue#1#2% #3
+ {\ifcsname\??xmlmapvalue#1:#2\endcsname
+ \expandafter\expandafter\expandafter\lastnamedcs\expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+\permanent\def\xmlmappedvalue#1#2#3%
+ {\ifcsname\??xmlmapvalue#1:#2\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \csname\??xmlmapvalue#1:#3\expandafter\endcsname
+ \fi}
+
+\aliased\let\xmldoifvalueelse\xmldoifelsevalue
+
+\aliased\let\xmlmapval\xmlmapvalue
+\aliased\let\xmlval \xmlvalue
+
+%D Experimental:
+
+\permanent\def\xmlgetindex #1{\clf_xmlgetindex {\xmldocument}{#1}}
+\permanent\def\xmlwithindex #1#2{\clf_xmlwithindex{\xmldocument}{#1}{#2}}
+\permanent\def\xmlreference #1#2{\string\xmlwithindex{#1}{#2}}
+
+%D Entities:
+%D
+%D \starttyping
+%D \xmlsetentity{tex}{\TEX{}} % {} needed
+%D \stoptyping
+
+\permanent\protected\def\xmlsetentity#1#2{\clf_xmlsetentity{#1}{\detokenize{#2}}}
+\permanent\protected\def\xmltexentity#1#2{\clf_xmltexentity{#1}{\detokenize{#2}}}
+
+%D The following might change (or even disappear) so we keep it undocumented.
+
+\setnewconstant\xmlautoentities\plusone % 0=off, 1=upper, 2=upper,lower
+
+\permanent\protected\def\xmle
+ {\ifcase\xmlautoentities
+ \expandafter\lxml_e_none
+ \or
+ \expandafter\lxml_e_upper
+ \or
+ \expandafter\lxml_e_upperlower
+ \else
+ \expandafter\lxml_e_none
+ \fi}
+
+\def\lxml_e_none#1#2% safe
+ {#1}
+
+\def\lxml_e_upper#1#2% can be abbreviation
+ {\ifcsname#2\endcsname
+ \csname#2\expandafter\endcsname
+ \else
+ #1%
+ \fi}
+
+\def\lxml_e_upperlower#1#2% can be anything, so unsafe
+ {\ifcsname#2\endcsname
+ \csname#2\expandafter\endcsname
+ \orelse\ifcsname#1\endcsname
+ \csname#1\expandafter\endcsname
+ \else
+ #1%
+ \fi}
+
+%D We keep these around as there are also MP, LUA and TEX variants but they are not
+%D the same as in \MKII.
+
+\permanent\tolerant\protected\def\processXMLbuffer[#1]{\xmlprocessbuffer{temp}{#1}{}}
+\permanent \protected\def\processXMLfile #1{\xmlprocessfile {temp}{#1}{}}
+\permanent \protected\def\XMLdata #1{\xmlprocessdata {temp}{#1}{}}
+
+\aliased\let\processxmlbuffer\processXMLbuffer
+\aliased\let\processxmlfile \processXMLfile
+\aliased\let\xmldata \XMLdata
+
+\permanent\protected\def\xmlsetinjectors [#1]{\clf_xmlsetinjectors{#1}}
+\permanent\protected\def\xmlresetinjectors {\clf_xmlresetinjectors{}}
+
+% \def\xmlinjector#1{\executeifdefined{#1}\donothing}
+
+\permanent\def\xmlinjector#1{\fastsetup{xml:directive:injector:#1}}
+
+\startsetups xml:directive:injector:page
+ \page
+\stopsetups
+
+\startsetups xml:directive:injector:column
+ \column
+\stopsetups
+
+\startsetups xml:directive:injector:blank
+ \blank
+\stopsetups
+
+\startsetups xml:directive:injector:noline
+ \vskip-\lineheight
+\stopsetups
+
+\aliased\let\xmlapplyselectors\clf_xmlapplyselectors
+
+% In the\MKIV\ file there is some commented code wrt handing entities with active
+% characters ... very old and obsolete.
+
+\protect \endinput
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/lxml-sor.mkxl b/Master/texmf-dist/tex/context/base/mkxl/lxml-sor.mkxl
new file mode 100644
index 00000000000..798047e0423
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/lxml-sor.mkxl
@@ -0,0 +1,99 @@
+%D \module
+%D [ file=lxml-sor,
+%D version=2009.08.24,
+%D title=\CONTEXT\ \XML\ Support,
+%D subtitle=Sorting,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D THIS IS VERY EXPERIMENTAL!
+
+\writestatus{loading}{ConTeXt XML Support / Sorting}
+
+\registerctxluafile{lxml-sor}{}
+
+\unprotect
+
+%D The flusher is unexpandable so that it can be used in tables (noalign
+%D interferences).
+
+% todo: public implementors
+
+\permanent\protected\def\xmlresetsorter #1{\ctxlxml{sorters.reset("#1")}}
+\permanent\protected\def\xmladdsortentry#1#2#3{\ctxlxml{sorters.add("#1","#2",\!!bs#3\!!es)}}
+\permanent\protected\def\xmlshowsorter #1{\ctxlxml{sorters.show("#1")}}
+\permanent \def\xmlflushsorter #1#2{\ctxlxml{sorters.flush("#1","#2")}}
+\permanent\protected\def\xmlsortentries #1{\ctxlxml{sorters.sort("#1")}}
+
+\protect \endinput
+
+\startbuffer[test]
+
+
+ one
+ alpha
+ alpha indeed
+
+
+ one
+ gamma
+ gamma indeed
+
+
+ one
+ beta
+ beta indeed
+
+
+ two
+ alpha
+ alpha again
+
+
+ two
+ gamma
+ gamma again
+
+
+ two
+ beta
+ beta again
+
+
+\stopbuffer
+
+\startxmlsetups xml:mysetups
+ \xmlsetsetup{\xmldocument}{demo|entry|content}{xml:*}
+\stopxmlsetups
+
+\xmlregistersetup{xml:mysetups}
+
+\startxmlsetups xml:demo
+ \xmlresetsorter{demo}
+ \xmlfilter{#1}{entry/command(xml:entry:getkeys)}
+ \blank sortkeys: \blank\xmlshowsorter{demo}\blank
+ \xmlsortentries{demo}
+ \xmlflushsorter{demo}{xml:entry:flush}
+\stopxmlsetups
+
+\startxmlsetups xml:entry:getkeys
+ \xmladdsortentry{demo}{#1}{\xmltext{#1}{category}}
+ \xmladdsortentry{demo}{#1}{\xmltext{#1}{key|entry}}
+\stopxmlsetups
+
+\startxmlsetups xml:entry:flush
+ \xmltext{#1}{content}\par
+\stopxmlsetups
+
+\startxmlsetups xml:entry
+ \xmltext{#1}{content}\par
+\stopxmlsetups
+
+\starttext
+ \xmlprocessbuffer{main}{test}{}
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/m-mkivmkxl.mkxl b/Master/texmf-dist/tex/context/base/mkxl/m-mkivmkxl.mkxl
new file mode 100644
index 00000000000..9aea14eb21f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/m-mkivmkxl.mkxl
@@ -0,0 +1,3 @@
+% mkiv spacing before figure
+
+% \let\checkprevdepth\baselinecorrection
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-acc.mklx b/Master/texmf-dist/tex/context/base/mkxl/math-acc.mklx
new file mode 100644
index 00000000000..9d86566302b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-acc.mklx
@@ -0,0 +1,153 @@
+%D \module
+%D [ file=math-acc,
+%D version=2013.07.31,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Accents,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Accents}
+
+% There are probably errors ... too distracted by amazing (piano) music videos running
+% on top of scite ... so: experimental code.
+
+\unprotect
+
+% This module permits overloading of accents so that we can do fancy things. The
+% implementation is similar to stackers. By default accenst are defined in a simple
+% way. Contrary to extensibles accents cannot grow indefinitely. Alas the
+% implementation of accents is different too, in the sense that they are
+% prepositioned i.e. are already raised. (In my opinion for no real reason as they
+% need to adapt anyway).
+%
+% $ \ruledhbox{$H$} \hat{H} \ruledhbox{$\widehat{H}$} \widehat{H} $
+%
+% One alternative is:
+%
+% \definemathoverextensible [top] [hoed] ["FE302]
+% \definemathoverextensible [top] [slang] ["FE303]
+%
+% $ \hoed{H} \ruledhbox{$\hoed{H}$} \ruledhbox{$\hoed{\tf H}$} \slang{H} $
+%
+% But that nills the italic correction (and I'm in nood to mess with that again).
+%
+% \definemathaccents [myaccents] [color=darkred]
+% \definemathtopaccent [myaccents] [mywidehat] ["0302]
+%
+% $ \hat{H} \widehat{H} \mywidehat{H} $
+
+%D Older implementations are kept in the \MKII\ and \MKIV\ modules for educational
+%D purposes.
+
+\installcorenamespace{mathaccents}
+
+\installcommandhandler \??mathaccents {mathaccents} \??mathaccents
+
+\setupmathaccents
+ [\c!top=,
+ \c!bottom=,
+ \c!mathstyle=,
+ \c!color=,
+ \c!define=\v!yes] % not used
+
+\definemathaccents
+ [\v!both]
+
+\definemathaccents
+ [\v!top]
+ [\v!both]
+
+\definemathaccents
+ [\v!bottom]
+ [\v!both]
+
+\permanent\tolerant\protected\def\definemathtopaccent[#1]#*[#2]#*[#3]% class name top
+ {\ifparameter#3\or
+ \frozen\instance\setuevalue{#2}{\math_accents_make_double {#1}\plusone{\number#3}\zerocount}%
+ \else
+ \frozen\instance\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusone{\number#2}\zerocount}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemathbottomaccent[#1]#*[#2]#*[#3]% class name bottom
+ {\ifparameter#3\or
+ \frozen\instance\setuevalue{#2}{\math_accents_make_double {#1}\plustwo\zerocount{\number#3}}%
+ \else
+ \frozen\instance\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plustwo\zerocount{\number#2}}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemathdoubleaccent[#1]#*[#2]#*[#3]#*[#4]% class name top bottom
+ {\ifparameter#4\or
+ \frozen\instance\setuevalue{#2}{\math_accents_make_double {#1}\plusthree{\number#3}{\number#4}}%
+ \else
+ \frozen\instance\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusthree{\number#2}{\number#3}}%
+ \fi}
+
+\let\math_accents_color_pop\donothing
+
+\def\math_accents_color_push_yes
+ {\pushcolor[\p_math_accent_color]%
+ \let\math_accents_color_pop\popcolor}
+
+\def\math_accents_color_push_nop
+ {\let\math_accents_color_pop\donothing}
+
+\protected\def\math_accents_make_double#class#kind#top#bottom#content%
+ {\begingroup
+ \edef\currentmathaccents {#class}%
+ \edef\p_math_accent_color{\mathaccentsparameter\c!color}%
+ \startusemathstyleparameter\mathaccentsparameter
+ \ifempty\p_math_accent_color
+ \math_accents_color_push_nop
+ \else
+ \math_accents_color_push_yes
+ \fi
+ \ifcase#kind\or
+ \Umathaccent \fam\zerocount#top
+ \or
+ \Umathaccent bottom \fam\zerocount#bottom
+ \or
+ \Umathaccent both \fam\zerocount#top
+ \fam\zerocount#bottom
+ \fi
+ {\math_accents_color_pop#content}%
+ \stopusemathstyleparameter
+ \endgroup}
+
+%D Relative new:
+
+\newconditional\c_math_accents_auto_dotless \settrue\c_math_accents_auto_dotless % cf opentype math
+
+\aliased\let\normalgrave\grave \permanent\protected\def\dotlessgrave#1{\normalgrave{\mathdotless#1}}
+\aliased\let\normalddot \ddot \permanent\protected\def\dotlessddot #1{\normalddot {\mathdotless#1}}
+\aliased\let\normalbar \bar \permanent\protected\def\dotlessbar #1{\normalbar {\mathdotless#1}}
+\aliased\let\normalacute\acute \permanent\protected\def\dotlessacute#1{\normalacute{\mathdotless#1}}
+\aliased\let\normalhat \hat \permanent\protected\def\dotlesshat #1{\normalhat {\mathdotless#1}}
+\aliased\let\normalcheck\check \permanent\protected\def\dotlesscheck#1{\normalcheck{\mathdotless#1}}
+\aliased\let\normalbreve\breve \permanent\protected\def\dotlessbreve#1{\normalbreve{\mathdotless#1}}
+\aliased\let\normaldot \dot \permanent\protected\def\dotlessdot #1{\normaldot {\mathdotless#1}}
+\aliased\let\normalring \ring \permanent\protected\def\dotlessring #1{\normalring {\mathdotless#1}}
+\aliased\let\normaltilde\tilde \permanent\protected\def\dotlesstilde#1{\normaltilde{\mathdotless#1}}
+\aliased\let\normaldddot\dddot \permanent\protected\def\dotlessdddot#1{\normaldddot{\mathdotless#1}}
+
+\def\math_accents_auto_dotless#1#2{\ifconditional\c_math_accents_auto_dotless\expandafter#2\else\expandafter#1\fi}
+
+\permanent\protected\def\grave {\math_accents_auto_dotless\normalgrave \dotlessgrave }
+\permanent\protected\def\ddot {\math_accents_auto_dotless\normalddot \dotlessddot }
+\permanent\protected\def\bar {\math_accents_auto_dotless\normalbar \dotlessbar }
+\permanent\protected\def\acute {\math_accents_auto_dotless\normalacute \dotlessacute }
+\permanent\protected\def\hat {\math_accents_auto_dotless\normalhat \dotlesshat }
+\permanent\protected\def\check {\math_accents_auto_dotless\normalcheck \dotlesscheck }
+\permanent\protected\def\breve {\math_accents_auto_dotless\normalbreve \dotlessbreve }
+\permanent\protected\def\dot {\math_accents_auto_dotless\normaldot \dotlessdot }
+\permanent\protected\def\ring {\math_accents_auto_dotless\normalring \dotlessring }
+\permanent\protected\def\tilde {\math_accents_auto_dotless\normaltilde \dotlesstilde }
+\permanent\protected\def\dddot {\math_accents_auto_dotless\normaldddot \dotlessdddot }
+
+\aliased\let\mathring\ring % for a while
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-act.lmt b/Master/texmf-dist/tex/context/base/mkxl/math-act.lmt
new file mode 100644
index 00000000000..9da79976484
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-act.lmt
@@ -0,0 +1,478 @@
+if not modules then modules = { } end modules ['math-act'] = {
+ version = 1.001,
+ comment = "companion to math-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Here we tweak some font properties (if needed). The commented sections
+-- have been removed (no longer viable) but can be found in the .lua variant.
+
+local type, next = type, next
+local fastcopy, insert, remove = table.fastcopy, table.insert, table.remove
+local formatters = string.formatters
+
+local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
+local trace_collecting = false trackers.register("math.collecting", function(v) trace_collecting = v end)
+
+local report_math = logs.reporter("mathematics","initializing")
+
+local context = context
+local commands = commands
+local mathematics = mathematics
+local texsetdimen = tex.setdimen
+local abs = math.abs
+
+local helpers = fonts.helpers
+local upcommand = helpers.commands.up
+local rightcommand = helpers.commands.right
+local charcommand = helpers.commands.char
+local prependcommands = helpers.prependcommands
+
+local sequencers = utilities.sequencers
+local appendgroup = sequencers.appendgroup
+local appendaction = sequencers.appendaction
+
+local fontchars = fonts.hashes.characters
+local fontproperties = fonts.hashes.properties
+
+local mathfontparameteractions = sequencers.new {
+ name = "mathparameters",
+ arguments = "target,original",
+}
+
+appendgroup("mathparameters","before") -- user
+appendgroup("mathparameters","system") -- private
+appendgroup("mathparameters","after" ) -- user
+
+function fonts.constructors.assignmathparameters(original,target)
+ local runner = mathfontparameteractions.runner
+ if runner then
+ runner(original,target)
+ end
+end
+
+function mathematics.initializeparameters(target,original)
+ local mathparameters = original.mathparameters
+ if mathparameters and next(mathparameters) then
+ mathparameters = mathematics.dimensions(mathparameters)
+ if not mathparameters.SpaceBeforeScript then
+ mathparameters.SpaceBeforeScript = mathparameters.SpaceAfterScript
+ end
+ target.mathparameters = mathparameters
+ end
+end
+
+sequencers.appendaction("mathparameters","system","mathematics.initializeparameters")
+
+local how = {
+ -- RadicalKernBeforeDegree = "horizontal",
+ -- RadicalKernAfterDegree = "horizontal",
+ ScriptPercentScaleDown = "unscaled",
+ ScriptScriptPercentScaleDown = "unscaled",
+ RadicalDegreeBottomRaisePercent = "unscaled",
+ NoLimitSupFactor = "unscaled",
+ NoLimitSubFactor = "unscaled",
+}
+
+function mathematics.scaleparameters(target,original)
+ if not target.properties.math_is_scaled then
+ local mathparameters = target.mathparameters
+ if mathparameters and next(mathparameters) then
+ local parameters = target.parameters
+ local factor = parameters.factor
+ local hfactor = parameters.hfactor
+ local vfactor = parameters.vfactor
+ for name, value in next, mathparameters do
+ local h = how[name]
+ if h == "unscaled" then
+ -- kept
+ elseif h == "horizontal" then
+ value = value * hfactor
+ elseif h == "vertical"then
+ value = value * vfactor
+ else
+ value = value * factor
+ end
+ mathparameters[name] = value
+ end
+ end
+ target.properties.math_is_scaled = true
+ end
+end
+
+-- AccentBaseHeight vs FlattenedAccentBaseHeight
+
+function mathematics.checkaccentbaseheight(target,original)
+ local mathparameters = target.mathparameters
+ if mathparameters and mathparameters.AccentBaseHeight == 0 then
+ mathparameters.AccentBaseHeight = target.parameters.x_height -- needs checking
+ end
+end
+
+function mathematics.checkprivateparameters(target,original)
+ local mathparameters = target.mathparameters
+ if mathparameters then
+ local parameters = target.parameters
+ local properties = target.properties
+ if parameters then
+ local size = parameters.size
+ if size then
+ if not mathparameters.FractionDelimiterSize then
+ mathparameters.FractionDelimiterSize = 1.01 * size
+ end
+ if not mathparameters.FractionDelimiterDisplayStyleSize then
+ mathparameters.FractionDelimiterDisplayStyleSize = 2.40 * size
+ end
+ elseif properties then
+ report_math("invalid parameters in font %a",properties.fullname or "?")
+ else
+ report_math("invalid parameters in font")
+ end
+ elseif properties then
+ report_math("no parameters in font %a",properties.fullname or "?")
+ else
+ report_math("no parameters and properties in font")
+ end
+ end
+end
+
+function mathematics.overloadparameters(target,original)
+ local mathparameters = target.mathparameters
+ if mathparameters and next(mathparameters) then
+ local goodies = target.goodies
+ if goodies then
+ for i=1,#goodies do
+ local goodie = goodies[i]
+ local mathematics = goodie.mathematics
+ local parameters = mathematics and mathematics.parameters
+ if parameters then
+ if trace_defining then
+ report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size)
+ end
+ for name, value in next, parameters do
+ local tvalue = type(value)
+ if tvalue == "string" then
+ report_math("comment for math parameter %a: %s",name,value)
+ else
+ local oldvalue = mathparameters[name]
+ local newvalue = oldvalue
+ if oldvalue then
+ if tvalue == "number" then
+ newvalue = value
+ elseif tvalue == "function" then
+ newvalue = value(oldvalue,target,original)
+ elseif not tvalue then
+ newvalue = nil
+ end
+ if trace_defining and oldvalue ~= newvalue then
+ report_math("overloading math parameter %a: %S => %S",name,oldvalue,newvalue)
+ end
+ else
+ report_math("invalid math parameter %a",name)
+ end
+ mathparameters[name] = newvalue
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+local function applytweaks(when,target,original)
+ local goodies = original.goodies
+ if goodies then
+ for i=1,#goodies do
+ local goodie = goodies[i]
+ local mathematics = goodie.mathematics
+ local tweaks = mathematics and mathematics.tweaks
+ if type(tweaks) == "table" then
+ tweaks = tweaks[when]
+ if type(tweaks) == "table" then
+ if trace_defining then
+ report_math("tweaking math of %a @ %p (%s)",target.properties.fullname,target.parameters.size,when)
+ end
+ for i=1,#tweaks do
+ local tweak= tweaks[i]
+ local tvalue = type(tweak)
+ if tvalue == "function" then
+ tweak(target,original)
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+function mathematics.tweakbeforecopyingfont(target,original)
+ local mathparameters = target.mathparameters -- why not hasmath
+ if mathparameters then
+ applytweaks("beforecopying",target,original)
+ end
+end
+
+function mathematics.tweakaftercopyingfont(target,original)
+ local mathparameters = target.mathparameters -- why not hasmath
+ if mathparameters then
+ applytweaks("aftercopying",target,original)
+ end
+end
+
+sequencers.appendaction("mathparameters","system","mathematics.scaleparameters")
+sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead
+sequencers.appendaction("mathparameters","system","mathematics.checkprivateparameters") -- after scaling !
+sequencers.appendaction("mathparameters","system","mathematics.overloadparameters")
+
+sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont")
+sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaftercopyingfont")
+
+-- no, it's a feature now (see good-mth):
+--
+-- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.overloaddimensions")
+
+-- a couple of predefined tweaks:
+
+local tweaks = { }
+mathematics.tweaks = tweaks
+
+-- helpers
+
+local setmetatableindex = table.setmetatableindex
+
+local getfontoffamily = tex.getfontoffamily
+
+local fontcharacters = fonts.hashes.characters
+local extensibles = utilities.storage.allocate()
+fonts.hashes.extensibles = extensibles
+
+local chardata = characters.data
+local extensibles = mathematics.extensibles
+
+-- we use numbers at the tex end (otherwise we could stick to chars)
+
+local e_left = extensibles.left
+local e_right = extensibles.right
+local e_horizontal = extensibles.horizontal
+local e_mixed = extensibles.mixed
+local e_unknown = extensibles.unknown
+
+local unknown = { e_unknown, false, false }
+
+local function extensiblecode(font,unicode)
+ local characters = fontcharacters[font]
+ local character = characters[unicode]
+ if not character then
+ return unknown
+ end
+ local first = character.next
+ local code = unicode
+ local next = first
+ while next do
+ code = next
+ character = characters[next]
+ next = character.next
+ end
+ local char = chardata[unicode]
+ if not char then
+ return unknown
+ end
+ if character.horiz_variants then
+ if character.vert_variants then
+ return { e_mixed, code, character }
+ else
+ local m = char.mathextensible
+ local e = m and extensibles[m]
+ return e and { e, code, character } or unknown
+ end
+ elseif character.vert_variants then
+ local m = char.mathextensible
+ local e = m and extensibles[m]
+ return e and { e, code, character } or unknown
+ elseif first then
+ -- assume accent (they seldom stretch .. sizes)
+ local m = char.mathextensible or char.mathstretch
+ local e = m and extensibles[m]
+ return e and { e, code, character } or unknown
+ else
+ return unknown
+ end
+end
+
+setmetatableindex(extensibles,function(extensibles,font)
+ local codes = { }
+ setmetatableindex(codes, function(codes,unicode)
+ local status = extensiblecode(font,unicode)
+ codes[unicode] = status
+ return status
+ end)
+ extensibles[font] = codes
+ return codes
+end)
+
+local function extensiblecode(family,unicode)
+ return extensibles[getfontoffamily(family or 0)][unicode][1]
+end
+
+-- left : [head] ...
+-- right : ... [head]
+-- horizontal : [head] ... [head]
+--
+-- abs(right["start"] - right["end"]) | right.advance | characters[right.glyph].width
+
+local function horizontalcode(family,unicode)
+ local font = getfontoffamily(family or 0)
+ local data = extensibles[font][unicode]
+ local kind = data[1]
+ local loffset = 0
+ local roffset = 0
+ if kind == e_left then
+ local charlist = data[3].horiz_variants
+ if charlist then
+ local left = charlist[1]
+ loffset = abs((left["start"] or 0) - (left["end"] or 0))
+ end
+ elseif kind == e_right then
+ local charlist = data[3].horiz_variants
+ if charlist then
+ local right = charlist[#charlist]
+ roffset = abs((right["start"] or 0) - (right["end"] or 0))
+ end
+ elseif kind == e_horizontal then
+ local charlist = data[3].horiz_variants
+ if charlist then
+ local left = charlist[1]
+ local right = charlist[#charlist]
+ loffset = abs((left ["start"] or 0) - (left ["end"] or 0))
+ roffset = abs((right["start"] or 0) - (right["end"] or 0))
+ end
+ end
+ return kind, loffset, roffset
+end
+
+mathematics.extensiblecode = extensiblecode
+mathematics.horizontalcode = horizontalcode
+
+interfaces.implement {
+ name = "extensiblecode",
+ arguments = { "integer", "integer" },
+ actions = { extensiblecode, context }
+}
+
+interfaces.implement {
+ name = "horizontalcode",
+ arguments = { "integer", "integer" },
+ actions = function(family,unicode)
+ local kind, loffset, roffset = horizontalcode(family,unicode)
+ texsetdimen("scratchleftoffset", loffset)
+ texsetdimen("scratchrightoffset",roffset)
+ context(kind)
+ end
+}
+
+
+local stack = { }
+
+function mathematics.registerfallbackid(n,id,name)
+ if trace_collecting then
+ report_math("resolved fallback font %i, name %a, id %a, used %a",
+ n,name,id,fontproperties[id].fontname)
+ end
+ stack[#stack][n] = id
+end
+
+interfaces.implement { -- will be shared with text
+ name = "registerfontfallbackid",
+ arguments = { "integer", "integer", "string" },
+ actions = mathematics.registerfallbackid,
+}
+
+function mathematics.resolvefallbacks(target,specification,fallbacks)
+ local definitions = fonts.collections.definitions[fallbacks]
+ if definitions then
+ local size = specification.size -- target.size
+ local list = { }
+ insert(stack,list)
+ context.pushcatcodes("prt") -- context.unprotect()
+ for i=1,#definitions do
+ local definition = definitions[i]
+ local name = definition.font
+ local features = definition.features or ""
+ local size = size * (definition.rscale or 1)
+ context.font_fallbacks_register_math(i,name,features,size)
+ if trace_collecting then
+ report_math("registering fallback font %i, name %a, size %a, features %a",i,name,size,features)
+ end
+ end
+ context.popcatcodes()
+ end
+end
+
+function mathematics.finishfallbacks(target,specification,fallbacks)
+ local list = remove(stack)
+ if list and #list > 0 then
+ local definitions = fonts.collections.definitions[fallbacks]
+ if definitions and #definitions > 0 then
+ if trace_collecting then
+ report_math("adding fallback characters to font %a",specification.hash)
+ end
+ local definedfont = fonts.definers.internal
+ local copiedglyph = fonts.handlers.vf.math.copy_glyph
+ local fonts = target.fonts
+ local size = specification.size -- target.size
+ local characters = target.characters
+ if not fonts then
+ fonts = { }
+ target.fonts = fonts
+ end
+ if #fonts == 0 then
+ fonts[1] = { id = 0, size = size } -- self, will be resolved later
+ end
+ local done = { }
+ for i=1,#definitions do
+ local definition = definitions[i]
+ local name = definition.font
+ local start = definition.start
+ local stop = definition.stop
+ local gaps = definition.gaps
+ local check = definition.check
+ local force = definition.force
+ local rscale = definition.rscale or 1
+ local offset = definition.offset or start
+ local id = list[i]
+ if id then
+ local index = #fonts + 1
+ fonts[index] = { id = id, size = size }
+ local chars = fontchars[id]
+ local function remap(unic,unicode,gap)
+ if check and not chars[unicode] then
+ return
+ end
+ if force or (not done[unic] and not characters[unic]) then
+ if trace_collecting then
+ report_math("replacing math character %C by %C using vector %a and font id %a for %a%s%s",
+ unic,unicode,fallbacks,id,fontproperties[id].fontname,check and ", checked",gap and ", gap plugged")
+ end
+ characters[unic] = copiedglyph(target,characters,chars,unicode,index)
+ done[unic] = true
+ end
+ end
+ local step = offset - start
+ for unicode = start, stop do
+ remap(unicode + step,unicode,false)
+ end
+ if gaps then
+ for unic, unicode in next, gaps do
+ remap(unic,unicode,true)
+ remap(unicode,unicode,true)
+ end
+ end
+ end
+ end
+ elseif trace_collecting then
+ report_math("no fallback characters added to font %a",specification.hash)
+ end
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-ali.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-ali.mkxl
new file mode 100644
index 00000000000..2007ed83ccf
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-ali.mkxl
@@ -0,0 +1,1964 @@
+%D \module
+%D [ file=math-ali,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Math Alignments,
+%D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Math Alignments}
+
+\unprotect
+
+%D The code here has been moved from other files. Beware: the \MKII\ and \MKIV\ code
+%D is not gathered in files with the same name. In the meantime this code has been
+%D adapted to \MKIV\ but more is possible. The code is somewhat complicated by the
+%D fact that alignments are tricky with rspect to tagging.
+
+% export:
+%
+% alignment : ok
+% cases :
+% matrix : ok
+% substack :
+
+%D \macros
+%D {definemathalignment, setupmathalignment, startmathalignment}
+%D
+%D Modules may provide additional alignment features. The following kind of plain
+%D mechanisms are provided by the core.
+
+\newtoks\t_math_align_a
+\newtoks\t_math_align_b
+\newtoks\t_math_align_c
+
+\newskip\d_math_eqalign_distance
+\newskip\d_math_eqalign_rulethickness
+
+\protected\def\math_eqalign_distance
+ {\relax
+ \ifdim\d_math_eqalign_distance>\zeropoint
+ % \hskip\d_math_eqalign_distance
+ \tabskip\d_math_eqalign_distance
+ \fi
+ \mathalignmentparameter\c!separator
+ \relax}
+
+\mutable\def\displayopenupvalue{.25\bodyfontsize}
+
+\def\math_build_eqalign
+ {\scratchtoks\emptytoks
+ \d_math_eqalign_distance\mathalignmentparameter\c!distance\relax
+ \scratchcounterone\mathalignmentparameter\c!m
+ \scratchcountertwo\mathalignmentparameter\c!n
+ \etoksapp\scratchtoks{\the\t_math_align_a}%
+ \scratchcounter\plusone
+ \dorecurse{\numexpr\scratchcounterone*\scratchcountertwo-\plusone\relax}
+ {\ifnum\scratchcounter=\scratchcountertwo
+ \scratchcounter\plusone
+ \etoksapp\scratchtoks{\math_eqalign_distance}%
+ \etoksapp\scratchtoks{\global\c_math_eqalign_column\zerocount}%
+ \else
+ \advance\scratchcounter\plusone
+ \fi
+ \etoksapp\scratchtoks{\the\t_math_align_b}}%
+ \etoksapp\scratchtoks{\the\t_math_align_c}}
+
+\def\math_math_in_eqalign#1%
+ {\startforceddisplaymath
+ \tabskip\zeropoint
+ \everycr\emptytoks
+ {{}#1{}}%
+ \stopforceddisplaymath}
+
+\def\math_text_in_eqalign#1%
+ {\startimath
+ \tabskip\zeropoint
+ \everycr\emptytoks
+ #1%
+ \stopimath}
+
+\permanent\protected\def\eqalign#1% why no halign here, probably because of displaywidth
+ {\emptyhbox % why no \dontleavehmode
+ \mskip\thinmuskip
+ \vcenter
+ {\math_openup\displayopenupvalue % was: \openup\jot
+ \mathsurround\zeropoint
+ \ialign{%
+ \strut
+ \hfil
+ \startforceddisplaymath{\alignmark\alignmark}\stopforceddisplaymath
+ \aligntab
+ \startforceddisplaymath{{}\alignmark\alignmark{}}\stopforceddisplaymath
+ \hfil\crcr
+ #1\crcr}%
+ }%
+ \mskip\thinmuskip}
+
+% preamble is scanned for tabskips so we need the span to prevent an error message
+
+\setnewconstant\eqalignmode\plusone
+
+% use zeroskipplusfill
+
+\def\math_prepare_r_eqalign_no
+ {\t_math_align_a
+ {\strut
+ \tabskip\zeropoint
+ \alignmark\alignmark % for picking up the number
+ \aligntab
+ \math_first_in_eqalign
+ \hfil
+ \math_left_of_eqalign
+ \span
+ \math_math_in_eqalign{\alignmark\alignmark}%
+ \math_right_of_eqalign
+ \tabskip\zeropoint}%
+ \t_math_align_b
+ {\aligntab
+ \math_next_in_eqalign
+ \math_left_of_eqalign
+ \span
+ \math_math_in_eqalign{\alignmark\alignmark}%
+ \math_right_of_eqalign
+ \tabskip\zeropoint}%
+ \ifnum\mathraggedstatus=\plusone
+ \t_math_align_c
+ {\hfil
+ \aligntab
+ \span
+ \math_text_in_eqalign{\alignmark\alignmark}%
+ \tabskip\zeropoint}%
+ \orelse\ifnum\mathraggedstatus=\plusthree
+ \t_math_align_c
+ {\hfil
+ \tabskip\zeropoint\s!plus 1\s!fill
+ \aligntab
+ \span
+ \math_text_in_eqalign{\alignmark\alignmark}%
+ \tabskip\zeropoint}%
+ \else
+ \t_math_align_c
+ {\hfil
+ \tabskip\centering
+ \aligntab
+ \span
+ \llap{\math_text_in_eqalign{\alignmark\alignmark}}%
+ \tabskip\zeropoint}%
+ \fi
+ \math_build_eqalign
+ \the\mathdisplayaligntweaks
+ \tabskip\centering}
+
+\def\math_prepare_l_eqalign_no % \checkeddisplaymath
+ {\t_math_align_a
+ {\strut
+ \tabskip\zeropoint
+ \alignmark\alignmark % for picking up the number
+ \aligntab
+ \math_first_in_eqalign
+ \hfil
+ \math_left_of_eqalign
+ \span
+ \math_math_in_eqalign{\alignmark\alignmark}%
+ \math_right_of_eqalign
+ \tabskip\zeropoint}%
+ \t_math_align_b
+ {\aligntab
+ \math_next_in_eqalign
+ \math_left_of_eqalign
+ \span
+ \math_math_in_eqalign{\alignmark\alignmark}%
+ \math_right_of_eqalign
+ \tabskip\zeropoint}%
+ \ifnum\mathraggedstatus=\plusone
+ \t_math_align_c
+ {\hfil
+ \aligntab
+ \kern-\displaywidth
+ \span
+ \rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
+ \tabskip\displaywidth}%
+ \orelse\ifnum\mathraggedstatus=\plusthree
+ \t_math_align_c
+ {\hfil
+ \tabskip\zeropoint\s!plus 1\s!fill
+ \aligntab
+ \kern-\displaywidth
+ \span
+ \math_rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
+ \tabskip\displaywidth}%
+ \else
+ \t_math_align_c
+ {\hfil
+ \tabskip\centering
+ \aligntab
+ \kern-\displaywidth
+ \span
+ \rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
+ \tabskip\displaywidth}%
+ \fi
+ \math_build_eqalign
+ \the\mathdisplayaligntweaks
+ \tabskip\centering}
+
+\def\math_halign_checked
+ {\halign \ifcase\eqalignmode \or to \checkeddisplaywidth \fi}
+
+\def\math_both_eqalign_no_normal#1#2%
+ {\ifmmode
+ \the\mathdisplayaligntweaks
+ \vcenter\bgroup
+ \enforced\let\math_finish_eqalign_no\egroup
+ \else
+ \enforced\let\math_finish_eqalign_no\relax
+ \fi
+ #1%
+ \math_halign_checked\expandafter\bgroup\the\scratchtoks\crcr#2\crcr\egroup
+ \math_finish_eqalign_no}
+
+\installcorenamespace {mathalignlocation}
+
+\defcsname\??mathalignlocation\v!top \endcsname{\let\math_alignment_halign_method\halign\tpack}
+\defcsname\??mathalignlocation\v!bottom\endcsname{\let\math_alignment_halign_method\halign\vpack}
+\defcsname\??mathalignlocation\v!center\endcsname{\let\math_alignment_halign_method\halign\vcenter}
+
+\let\math_alignment_halign_method\relax
+
+\def\math_both_eqalign_no_aligned#1%
+ {\let\math_alignment_halign_method\math_halign_checked
+ \ifmmode
+ \the\mathdisplayaligntweaks
+ \global\mathnumberstatus\plusone
+ \ifcase\mathraggedstatus
+ \def\math_finish_eqalign_no{\crcr\egroup}%
+ \else % we're in a mathbox
+ \ifcsname\??mathalignlocation\mathalignmentparameter\c!location\endcsname
+ \lastnamedcs % top|bottom|center as suggested by HM
+ \else
+ \vcenter
+ \fi
+ \bgroup
+ \def\math_finish_eqalign_no{\crcr\egroup\egroup}%
+ \fi
+ \fi
+ #1%
+ \math_alignment_halign_method\expandafter\bgroup\the\scratchtoks\crcr}
+
+\def\math_rlap#1%
+ {\setbox\scratchbox\hbox{#1}%
+ \ifdim\wd\scratchbox>\d_math_number_correction
+ \global\d_math_number_correction\wd\scratchbox
+ \fi
+ \box\scratchbox
+ \global\mathnumberstatus\plustwo}
+
+\def\math_handle_eqalign_no_r_normal {\math_both_eqalign_no_normal \math_prepare_r_eqalign_no}
+\def\math_handle_eqalign_no_l_normal {\math_both_eqalign_no_normal \math_prepare_l_eqalign_no}
+\def\math_handle_eqalign_no_r_aligned{\math_both_eqalign_no_aligned\math_prepare_r_eqalign_no}
+\def\math_handle_eqalign_no_l_aligned{\math_both_eqalign_no_aligned\math_prepare_l_eqalign_no}
+\def\math_finish_eqalign_no {\crcr\egroup}
+
+\aliased\let\reqalignno\relax % just in case someone used that
+\aliased\let\leqalignno\relax % just in case someone used that
+\aliased\let\eqalignno \relax % just in case someone used that
+
+%D Here we implement the user interface part. We start with basic math alignments:
+
+\newcount \c_math_eqalign_column
+\newconditional\c_math_eqalign_first
+
+\newtoks \everymathalignment
+\newtoks \everymathalignmentdone
+
+\permanent\tolerant\protected\def\math_alignment_NN[#1]#*[#2]%
+ {\aligntab
+ \strc_formulas_place_number_nested{#1}{#2}}
+
+\permanent\tolerant\protected\def\math_alignment_NR[#1]#*[#2]%
+ {\aligntab
+ \dostoptagged % finish cell
+ \strc_formulas_place_number_nested{#1}{#2}%
+ \math_number_right_of_eqalign
+ \global\settrue\c_math_eqalign_first
+ \crcr
+ \noalign{\dostoptagged}} % finish row
+
+\permanent\protected\def\math_alignment_NC
+ {\relax
+ \ifconditional\c_math_eqalign_first
+ \ifx\p_math_alignment_number\v!auto
+ \strc_formulas_place_number_nested{+}{}%
+ \fi
+ \global\setfalse\c_math_eqalign_first
+ \fi
+ \math_number_left_of_eqalign
+ \aligntab}
+
+\permanent\protected\def\math_alignment_EQ
+ {\NC=}
+
+\noaligned\tolerant\protected\def\math_common_TB[#1]%
+ {\noalign{\blank[#1]}}
+
+\installmacrostack\NC % maybe more to shared table definitions
+\installmacrostack\NN % maybe more to shared table definitions
+\installmacrostack\EQ % maybe more to shared table definitions
+\installmacrostack\NR % maybe more to shared table definitions
+\installmacrostack\BC % maybe more to shared table definitions
+\installmacrostack\EC % maybe more to shared table definitions
+\installmacrostack\TB % maybe more to shared table definitions
+
+\appendtoks
+ \push_macro_NC
+ \push_macro_NN
+ \push_macro_EQ
+ \push_macro_NR
+ \push_macro_TB
+ \enforced\let\NC\math_alignment_NC
+ \enforced\let\NN\math_alignment_NN
+ \enforced\let\EQ\math_alignment_EQ
+ \enforced\let\NR\math_alignment_NR
+ \enforced\let\TB\math_common_TB
+ \global\settrue\c_math_eqalign_first
+\to \everymathalignment
+
+\appendtoks
+ \pop_macro_TB
+ \pop_macro_NR
+ \pop_macro_EQ
+ \pop_macro_NN
+ \pop_macro_NC
+\to \everymathalignmentdone
+
+\let\math_alignment_snap_start\relax
+\let\math_alignment_snap_stop \relax
+
+% % experimental:
+%
+% \def\math_alignment_snap_start
+% {\ifgridsnapping
+% \edef\p_math_alignment_grid{\mathalignmentparameter\c!grid}%
+% \ifx\p_math_alignment_grid\v!no\else
+% \snaptogrid[\p_math_alignment_grid]\vbox\bgroup
+% \fi
+% \fi}
+%
+% \def\math_alignment_snap_stop
+% {\ifgridsnapping
+% \ifx\p_math_alignment_grid\v!no\else
+% \egroup
+% \fi
+% \fi}
+%
+% % doesn't work well, so:
+
+\let\math_alignment_snap_start\relax
+\let\math_alignment_snap_stop \relax
+
+% end of experimental
+
+\newconditional\c_math_alignment_auto_number
+
+% \begingroup not permitted ($$...assignments...\halign... ).. check in luametatex
+
+\permanent\tolerant\protected\def\math_alignment_start[#1]#*[#2]%
+ {\edef\currentmathalignment{#1}%
+ \ifarguments\or\or
+ \setupmathalignment[#1][#2]% bad! ungrouped
+ \fi
+ \math_alignment_snap_start
+ \the\everymathalignment
+ \c_math_eqalign_column\zerocount
+ \edef\p_math_alignment_number{\mathalignmentparameter\c!number}%
+ \processcommacommand
+ [\mathalignmentparameter\c!align]%
+ {\advance\c_math_eqalign_column\plusone\math_eqalign_set_column}% takes argument
+ \global\c_math_eqalign_column\plusone
+ \dostarttagged\t!math\empty
+ \dostarttagged\t!mtable\currentmathalignment
+ \numberedeqalign}
+
+\def\math_alignment_stop % can be protected
+ {\math_finish_eqalign_no
+ \dostoptagged
+ \dostoptagged
+ \the\everymathalignmentdone
+ \math_alignment_snap_stop}
+
+\installcorenamespace{mathalignment}
+\installcorenamespace{mathalignmentvariant}
+
+\installcommandhandler \??mathalignment {mathalignment} \??mathalignment
+
+\appendtoks
+ \frozen\instance\setuevalue{\e!start\currentmathalignment}{\math_alignment_start[\currentmathalignment]}%
+ \frozen\instance\setvalue {\e!stop \currentmathalignment}{\math_alignment_stop}%
+\to \everydefinemathalignment
+
+\setupmathalignment
+ [\c!n=2,
+ \c!m=1,
+ \c!distance=\emwidth,
+ \c!grid=\v!math]
+
+\definemathalignment[align] % default case (this is what amstex users expect)
+\definemathalignment[\v!mathalignment] % prefered case (this is cleaner, less clashing)
+
+% special case.. in case one mistypes ..
+
+\ifdefined \startalignment
+
+ \pushoverloadmode
+
+ \aliased\let\align_math_normal_start\startalign
+ \aliased\let\align_math_normal_stop \stopalign
+
+ \aliased\let\align_text_normal_start\startalignment
+ \aliased\let\align_text_normal_stop \stopalignment
+
+ \permanent\overloaded\protected\def\startalign
+ {\ifmmode
+ \enforced\let\stopalign\align_math_normal_stop % cannot be a protected def ... lookahead in align
+ \expandafter\align_math_normal_start
+ \orelse\ifinformula
+ \enforced\let\stopalign\align_math_normal_stop
+ \expandafter\align_math_normal_start
+ \else
+ \enforced\let\stopalign\align_text_normal_stop
+ \expandafter\align_text_normal_start
+ \fi}
+
+ \aliased\let\stopalign\relax
+
+ \permanent\overloaded\protected\def\startalignment
+ {\ifmmode
+ \enforced\let\stopalignment\align_math_normal_stop % cannot be a protected def ... lookahead in align
+ \expandafter\align_math_normal_start
+ \orelse\ifinformula
+ \enforced\let\stopalignment\align_math_normal_stop % cannot be a protected def ... lookahead in align
+ \expandafter\align_math_normal_start
+ \else
+ \enforced\let\stopalignment\align_text_normal_stop
+ \expandafter\align_text_normal_start
+ \fi}
+
+ \aliased\let\stopalignment\relax
+
+ \pushoverloadmode
+
+\fi
+
+%
+
+\permanent\protected\def\numberedeqalign
+ {\doifelse{\formulaparameter\c!location}\v!left
+ \math_handle_eqalign_no_l_aligned
+ \math_handle_eqalign_no_r_aligned}
+
+\def\math_first_in_eqalign
+ {\global\c_math_eqalign_column\plusone
+ \dostarttagged\t!mtablerow \empty
+ \dostarttagged\t!mtablecell\empty}
+
+\def\math_next_in_eqalign
+ {\global\advance\c_math_eqalign_column\plusone
+ \dostoptagged % finish cell
+ \dostarttagged\t!mtablecell\empty}
+
+\def\math_left_of_eqalign
+ {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname
+ \ifcase\lastnamedcs \or \relax \or \hfill \or \hfill \fi
+ \fi}
+
+\def\math_right_of_eqalign
+ {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname
+ \ifcase\lastnamedcs \or \hfill \or \relax \or \hfill \fi
+ \fi}
+
+\newconditional\c_math_alignment_local_number % not used but when true puts in front (todo)
+
+\def\math_number_right_of_eqalign
+ {\ifcase\wd\b_strc_formulas_number\else
+ \ifconditional\c_math_alignment_local_number
+ \ifcase\c_strc_math_number_location\or\or
+ \box\b_strc_formulas_number
+ \fi
+ \else
+ \box\b_strc_formulas_number
+ \fi
+ \fi}
+
+\def\math_number_left_of_eqalign
+ {\ifcase\wd\b_strc_formulas_number\else
+ \ifconditional\c_math_alignment_local_number
+ \ifcase\c_strc_math_number_location\or
+ \box\b_strc_formulas_number
+ \fi
+ \fi
+ \fi}
+
+\def\math_eqalign_set_column#1% we could just add to the preamble (as with other alignments)
+ {\expandafter\chardef\csname\??mathalignmentvariant\number\c_math_eqalign_column\expandafter\expandafter\expandafter\endcsname
+ \ifcsname\??mathalignmentvariant#1\endcsname\lastnamedcs\else\zerocount\fi\relax}
+
+\letvalue{\??mathalignmentvariant\v!normal}\zerocount
+\letvalue{\??mathalignmentvariant\v!left }\plusone
+\letvalue{\??mathalignmentvariant\v!right }\plustwo
+\letvalue{\??mathalignmentvariant\v!middle}\plusthree
+
+\permanent\protected\def\math_align_NR_generic[#1][#2]%
+ {\strc_formulas_place_number_nested{#1}{#2}\crcr}
+
+%D \starttyping
+%D \placeformula[eqn0]\startformula \startalign[n=1] a\NR \stopalign \stopformula See \in[eqn0]
+%D \placeformula[eqn1]\startformula \startalign[n=1] a\NR \stopalign \stopformula See \in[eqn1]
+%D \placeformula \startformula \startalign[n=1] a\NR[eqn2] \stopalign \stopformula See \in[eqn2]
+%D \placeformula[eqn3]\startformula \startalign[n=1] a\NR[+] \stopalign \stopformula See \in[eqn3]
+%D \stoptyping
+
+%D \startbuffer
+%D \placeformula \startformula \eqalignno {
+%D a &= b & \formulanumber \cr
+%D c &= d \cr
+%D &= e \cr
+%D &= f & \formulanumber
+%D } \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startalign
+%D \NC a \EQ b \NR[+]
+%D \NC c \EQ d \NR
+%D \NC \EQ f \NR[for:demo-a-1]
+%D \NC \EQ g \NR[for:demo-a-2][a]
+%D \NC \EQ h \NR[for:demo-a-3][b]
+%D \NC \EQ i \NR
+%D \stopalign \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startalign
+%D \NC a \EQ b \NR[+]
+%D \NC c \EQ d \NR
+%D \NC \EQ f \NR
+%D \NC \EQ g \NR
+%D \NC \EQ h \NR
+%D \NC \EQ i \NR[+]
+%D \stopalign \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startalign
+%D \NC a \NC \eq b \NR[+]
+%D \NC c \NC \neq d \NR
+%D \NC \NC \neq f \NR[for:demo-b-1]
+%D \NC \NC \geq g \NR[for:demo-b-2][a]
+%D \NC \NC \leq h \NR[for:demo-b-3][b]
+%D \NC \NC \neq i \NR
+%D \stopalign \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startalign[n=3,align={left,middle,right}]
+%D \NC l \NC = \NC r \NR
+%D \NC left \NC = \NC right \NR
+%D \stopalign \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startalign[n=3,align={right,middle,left}]
+%D \NC l \NC = \NC r \NR
+%D \NC left \NC = \NC right \NR
+%D \stopalign \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startalign[n=3,align={middle,middle,middle}]
+%D \NC l \NC = \NC r \NR
+%D \NC left \NC = \NC right \NR
+%D \stopalign \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula
+%D \startformula
+%D \startalign[n=3,align={middle,middle,middle}]
+%D \NC a \NC = \NC b \NR[+]
+%D \NC 2a \NC = \NC 2b \NR
+%D \stopalign
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula
+%D \startformulas
+%D \setupmathalignment[n=3,align={middle,middle,middle}]%
+%D \startformula
+%D \startalign
+%D \NC a \NC = \NC b \NR[+]
+%D \NC 2a \NC = \NC 2b \NR
+%D \stopalign
+%D \stopformula
+%D \startformula
+%D \startalign
+%D \NC a \NC = \NC b \NR[+]
+%D \NC 2a \NC = \NC 2b \NR
+%D \stopalign
+%D \stopformula
+%D \stopformulas
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula
+%D \startformulas
+%D \dorecurse{5}{\startformula
+%D \startalign[n=3,align={middle,middle,middle}]
+%D \NC a \NC = \NC b \NR[+]
+%D \NC 2a \NC = \NC 2b \NR
+%D \stopalign
+%D \stopformula}
+%D \stopformulas
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \macros
+%D {definemathcases, setupmathcases, startmathcases}
+%D
+%D Another wish \unknown
+
+\installcorenamespace{mathcases}
+
+\installcommandhandler \??mathcases {mathcases} \??mathcases
+
+\setupmathcases
+ [\c!distance=\emwidth,
+ \c!strut=\v!yes, % new
+ \c!numberdistance=2.5\emwidth,
+ \c!left={\left\{\mskip\thinmuskip},
+ \c!right={\right.}]
+
+\appendtoks
+ \frozen\instance\protected\edefcsname\e!start\currentmathcases\endcsname{\math_cases_start[\currentmathcases]}%
+ \frozen\instance \defcsname \e!stop \currentmathcases\endcsname{\math_cases_stop}%
+\to \everydefinemathcases
+
+\permanent\protected\def\math_cases_NC_zero
+ {\math_cases_NC}
+
+\permanent\protected\def\math_cases_MC_zero
+ {\math_cases_NC
+ \ifmmode\else
+ \startimath
+ \enforced\let\math_cases_end_math\stopimath
+ \fi}
+
+\let\math_cases_end_math\relax
+
+\permanent\protected\def\math_cases_NR_zero
+ {\unskip
+ \math_cases_end_math
+ \aligntab
+ \global\enforced\let\math_cases_NC\math_cases_NC_first
+ \dodirectdoubleempty\math_cases_NR}
+
+\permanent\protected\def\math_cases_NC_first
+ {\global\enforced\let\math_cases_NC\math_cases_NC_second}
+
+\permanent\protected\def\math_cases_NC_second
+ {\math_cases_end_math\aligntab}
+
+\let\math_cases_NR\math_align_NR_generic
+
+\installmacrostack\math_cases_NC
+
+\let\math_cases_strut\relax
+
+\permanent\tolerant\protected\def\math_cases_start[#1]#*[#2]%
+ {\begingroup
+ \edef\currentmathcases{#1}%
+ \ifarguments\or\or
+ \setupcurrentmathcases[#2]%
+ \fi
+ \edef\p_strut{\mathcasesparameter\c!strut}%
+ \ifx\p_strut\v!yes
+ \enforced\let\math_cases_strut\strut
+ \else
+ \enforced\let\math_cases_strut\relax
+ \fi
+ \mathcasesparameter\c!left
+ \vcenter\bgroup
+ \push_macro_math_cases_NC
+ % \enforced\let\endmath\relax
+ \enforced\let\NC\math_cases_NC_zero
+ \enforced\let\MC\math_cases_MC_zero
+ \enforced\let\NR\math_cases_NR_zero
+ \enforced\let\TB\math_common_TB
+ \global\enforced\let\math_cases_NC\math_cases_NC_first
+ \normalbaselines
+ \mathsurround\zeropoint
+ \everycr\emptytoks
+ \tabskip\zeropoint
+ \global\c_math_eqalign_column\plusone
+ \halign\bgroup
+ \startimath
+ \mathcasesparameter\c!style
+ \alignmark\alignmark
+ \stopimath
+ \hfil
+ \aligntab
+ \hskip\mathcasesparameter\c!distance\relax
+ \pop_macro_math_cases_NC
+ \math_cases_strut % looks better
+ \alignmark\alignmark
+ \hfil
+ \aligntab
+ \hskip\mathcasesparameter\c!numberdistance\relax
+ % \let\formuladistance\!!zeropoint
+ \span\math_text_in_eqalign{\alignmark\alignmark}%
+ \crcr} % todo: number
+
+% When we have just protected we get an extra row but we can no flag
+% this as a proper alignment related command which means that uit gets
+% expanded.
+
+\noaligned\permanent\protected\def\math_cases_stop
+ {\crcr
+ \egroup
+ \pop_macro_math_cases_NC
+ \egroup
+ \mathcasesparameter\c!right
+ \endgroup}
+
+\definemathcases[cases]
+\definemathcases[\v!mathcases]
+
+%D \startbuffer
+%D \placeformula \startformula \startcases
+%D \NC 2 \NC $ y > 0 $ \NR
+%D \NC 7 \NC $ x = 7 $ \NR[+]
+%D \NC 4 \NC otherwise \NR
+%D \stopcases \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula x \startcases
+%D \NC 2 \NC $ y > 0 $ \NR[+]
+%D \NC 7 \NC $ x = 7 $ \NR
+%D \NC 4 \NC otherwise \NR
+%D \stopcases \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula \startcases
+%D \NC 2 \NC $ y > 0 $ \NR
+%D \NC 7 \NC $ x = 7 $ \NR
+%D \NC 4 \NC otherwise \NR
+%D \stopcases \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \placeformula \startformula x \startcases
+%D \NC 2 \NC $ y > 0 $ \NR
+%D \NC 7 \NC $ x = 7 $ \NR
+%D \NC 4 \NC otherwise \NR
+%D \stopcases \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \macros
+%D {definemathmatrix, setupmathmatrix, startmathmatrix}
+%D
+%D Yet another one \unknown. This time we implement the lot a bit
+%D different which is a side effect of getting the tagging right. In
+%D retrospect the main alignment could be done this way but \unknown
+
+\installcorenamespace{mathmatrix}
+
+\installcommandhandler \??mathmatrix {mathmatrix} \??mathmatrix
+
+\setupmathmatrix
+ [\c!distance=\emwidth,
+ \c!left=,
+ \c!right=,
+ \c!align=\v!middle,
+ \c!rulecolor=,
+ \c!rulethickness=\linewidth]
+
+\appendtoks
+ \frozen\instance\protected\edefcsname\e!start\currentmathmatrix\endcsname{\math_matrix_start[\currentmathmatrix]}%
+ % \noaligned\protected should work here:
+ \frozen\instance \defcsname \e!stop \currentmathmatrix\endcsname{\math_matrix_stop}% no u else lookahead problem
+\to \everydefinemathmatrix
+
+\def\math_matrix_start_table
+ {\global\c_math_eqalign_column\zerocount
+ \dostarttagged\t!math\empty
+ \dostarttagged\t!mtable\empty}
+
+\def\math_matrix_stop_table
+ {\dostoptagged
+ \dostoptagged}
+
+% \def\math_matrix_start_row
+% {\noalign{\global\c_math_eqalign_column\zerocount}%
+% \dostarttagged\t!mtablerow\empty}
+%
+% \def\math_matrix_stop_row
+% {\dostoptagged}
+
+\def\math_matrix_start_row
+ {\beginlocalcontrol
+ \global\c_math_eqalign_column\zerocount
+ \dostarttagged\t!mtablerow\empty
+ \endlocalcontrol}
+
+\def\math_matrix_stop_row
+ {\beginlocalcontrol
+ \dostoptagged
+ \endlocalcontrol}
+
+\protected\def\math_matrix_start_cell
+ {\dostarttagged\t!mtablecell\empty
+ \hss
+ \math_left_of_eqalign
+ \startimath
+ \math_matrix_set_style
+ \tabskip\zeropoint
+ \everycr\emptytoks}
+
+\protected\def\math_matrix_stop_cell
+ {\stopimath
+ \math_right_of_eqalign
+ \hss
+ \dostoptagged}
+
+% We could construct a preamble with alignment and such embedded but the number
+% of matrices with many rows is normally so low that it doesn't pay of at all.
+
+\protected\def\math_matrix_distance
+ {\relax
+ \ifdim\d_math_eqalign_distance>\zeropoint
+ \hskip\d_math_eqalign_distance
+ \fi
+ \relax}
+
+\def\math_matrix_preamble
+ {\math_matrix_strut
+ \global\advance\c_math_eqalign_column\plusone
+ \math_matrix_start_cell
+ \alignmark\alignmark
+ \math_matrix_stop_cell
+ \aligntab
+ \aligntab
+ \math_matrix_distance
+ \global\advance\c_math_eqalign_column\plusone
+ \math_matrix_start_cell
+ \alignmark\alignmark
+ \math_matrix_stop_cell}
+
+\newconditional\c_math_matrix_first
+
+\permanent\protected\def\math_matrix_NR
+ {\aligntab\omit
+ \math_matrix_stop_row
+ \math_matrix_pickup
+ \crcr
+ \math_matrix_start_row}
+
+\permanent\protected\def\math_matrix_NC
+ {\ifconditional\c_math_matrix_first
+ \expandafter\math_matrix_NC_yes
+ \else
+ \expandafter\math_matrix_NC_nop
+ \fi}
+
+\permanent\protected\def\math_matrix_pickup{\global\settrue \c_math_matrix_first}
+\permanent\protected\def\math_matrix_NC_yes{\global\setfalse\c_math_matrix_first}
+\permanent\protected\def\math_matrix_NC_nop{\aligntab} % avoids lookahead
+
+% \def\math_matrix_stop_wrapup
+% {\crcr
+% \strut
+% \crcr
+% \noalign{\vskip-\struthtdp}}
+
+\def\math_matrix_check_rule_step#1%
+ {\doifelsenumber{#1}
+ {\scratchdimen#1\d_math_eqalign_rulethickness}
+ {\edef\p_rulecolor{#1}}}
+
+\def\math_matrix_check_rule[#1]%
+ {\d_math_eqalign_rulethickness\mathmatrixparameter\c!rulethickness\relax
+ \scratchdimen\d_math_eqalign_rulethickness
+ \edef\p_rulecolor{\mathmatrixparameter\c!rulecolor}%
+ \iftok{#1}\emptytoks\else
+ \rawprocesscommalist[#1]\math_matrix_check_rule_step
+ \fi
+ \ifempty\p_rulecolor\else
+ \dousecolorparameter\p_rulecolor
+ \fi}
+
+\noaligned\permanent\tolerant\protected\def\math_matrix_HL[#1]#*%
+ {\noalign\bgroup
+ \math_matrix_check_rule[#1]%
+ \divide\scratchdimen\plustwo
+ \autorule\s!height\scratchdimen\s!depth\scratchdimen\relax
+ \egroup}
+
+\permanent\tolerant\protected\def\math_matrix_VL[#1]#*%
+ {\NC
+ \math_matrix_check_rule[#1]%
+ \divide\d_math_eqalign_distance\plustwo
+ \hskip-\d_math_eqalign_distance
+ \autorule\s!width\scratchdimen\relax
+ \hskip-\d_math_eqalign_distance
+ \NC}
+
+\newtoks\everymathmatrix
+
+\appendtoks
+ \enforced\let\NR\math_matrix_NR
+ \enforced\let\NC\math_matrix_NC
+ \enforced\let\MC\math_matrix_NC
+ \enforced\let\HL\math_matrix_HL
+ \enforced\let\VL\math_matrix_VL
+ \enforced\let\TB\math_common_TB
+\to \everymathmatrix
+
+\def\math_matrix_start_processing
+ {\dontleavehmode
+ \bgroup
+ \tabskip\zeropoint
+ \math_matrix_pickup
+ \the\everymathmatrix
+ %
+ % \enforced\let\endmath\relax
+ %
+ \setbox\nextbox\vbox\bgroup
+ \math_matrix_start_table
+ \halign \bgroup
+ % preamble
+ \span\math_matrix_preamble
+ % done
+ \crcr
+ \math_matrix_start_row}
+
+\def\math_matrix_stop_processing
+ {%\math_matrix_stop_wrapup % optional
+ \math_matrix_stop_row
+ \egroup
+ \math_matrix_stop_table
+ \egroup
+ \mathmatrixleft
+ \math_matrix_finish_nextbox
+ \mathmatrixright
+ \egroup}
+
+\let\math_matrix_strut \strut
+\let\math_matrix_set_style\relax
+
+\def\math_matrix_check_settings
+ {\edef\p_strut{\mathmatrixparameter\c!strut}%
+ \ifx\p_strut\v!no
+ \enforced\let\math_matrix_strut\relax
+ \else
+ \enforced\let\math_matrix_strut\strut
+ \ifx\p_strut\v!yes\else
+ \spacing\p_strut
+ \fi
+ \fi
+ \d_math_eqalign_distance\mathmatrixparameter\c!distance\relax
+ % \d_math_eqalign_rulethickness\mathmatrixparameter\c!rulethickness\relax
+ % \edef\p_rulecolor{\mathmatrixparameter\c!rulecolor}
+ \edef\math_matrix_set_style{\mathmatrixparameter\c!style}}
+
+\def\math_matrix_set_defaults
+ {\normalbaselines % hm, spacing ?
+ \mathsurround\zeropoint
+ \tabskip\zeropoint}
+
+\def\math_matrix_set_columns_step
+ {\advance\c_math_eqalign_column\plusone
+ %\c_math_matrix_columns\c_math_eqalign_column
+ \math_eqalign_set_column}
+
+\def\math_matrix_set_columns
+ {\c_math_eqalign_column\zerocount
+ \rawprocesscommacommand[\mathmatrixparameter\c!align]\math_matrix_set_columns_step}
+
+\newcount\c_math_eqalign_column_saved
+
+% \installglobalmacrostack\c_math_matrix_first
+
+\tolerant\protected\def\math_matrix_start[#1]#*[#2]%
+ {\begingroup
+ \globalpushmacro\c_math_matrix_first % hm, does that work?
+ \c_math_eqalign_column_saved\c_math_eqalign_column
+ \globalpushmacro\c_math_eqalign_first
+ \edef\currentmathmatrix{#1}%
+ \setupcurrentmathmatrix[#2]%
+ \math_matrix_check_settings
+ \math_matrix_set_defaults
+ \math_matrix_set_columns
+ \math_matrix_start_processing}
+
+\def\math_matrix_stop
+ {\math_matrix_stop_processing
+ \globalpushmacro\c_math_eqalign_first
+ \global\c_math_eqalign_column\c_math_eqalign_column_saved
+ \globalpopmacro\c_math_matrix_first
+ \endgroup}
+
+% vcenter:
+%
+% delta = (height(v) + depth(v))/2
+% axis = math_axis_size(cur_size)
+% height(v) = delta + axis
+% depth(v) = delta - axis
+
+\installcorenamespace{mathmatrixalignlocation}
+
+\mutable\let\mathmatrixleft \empty % experimental hook
+\mutable\let\mathmatrixright\empty % experimental hook
+
+\setvalue{\??mathmatrixalignlocation\v!top }{\raise\dimexpr(\nextboxdp-\nextboxht)/2 +\mathaxisheight\mathstyle\relax}
+\setvalue{\??mathmatrixalignlocation\v!high }{\raise\dimexpr(\nextboxdp-\nextboxht)/2\relax}
+\setvalue{\??mathmatrixalignlocation\v!center}{\relax}
+\setvalue{\??mathmatrixalignlocation\v!lohi} {\relax}
+\setvalue{\??mathmatrixalignlocation\v!normal}{\relax}
+\setvalue{\??mathmatrixalignlocation\v!bottom}{\lower\dimexpr(\nextboxdp-\nextboxht)/2 +\mathaxisheight\mathstyle\relax}
+\setvalue{\??mathmatrixalignlocation\v!low }{\lower\dimexpr(\nextboxdp-\nextboxht)/2\relax}
+
+\def\math_matrix_finish_nextbox
+ {\begincsname\??mathmatrixalignlocation\mathmatrixparameter\c!location\endcsname\hbox\bgroup
+ \normalstartimath
+ \mathmatrixparameter\c!left
+ \vcenter{\box\nextbox}%
+ \mathmatrixparameter\c!right
+ \normalstopimath
+ \egroup}
+
+\definemathmatrix[matrix]
+\definemathmatrix[\v!mathmatrix]
+
+%D \startbuffer
+%D \placeformula \startformula[-] \startmatrix
+%D \NC 1 \NC x \NC a \NR
+%D \NC 2 \NC y \NC b \NR
+%D \NC 3 \NC z \NC c \NR
+%D \stopmatrix \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \definemathmatrix[bmatrix][left={\left[\mskip\thinmuskip},right={\mskip\thinmuskip\right]},strut=1.25]
+%D
+%D \startbuffer
+%D \placeformula \startformula[-] \startbmatrix
+%D \NC 1 \NC x \NC a \NR
+%D \NC 2 \NC y \NC b \NR
+%D \NC 3 \NC z \NC c \NR
+%D \stopbmatrix \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D Taco added some code (dedicated to Aditya Mahajan) that gives more
+%D control over aligments:
+
+%D \startbuffer
+%D \startformula
+%D \startmatrix
+%D \NC a + x \NC = \NC a + d \NR
+%D \NC y \NC = \NC d \NR
+%D \stopmatrix
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \startbuffer
+%D \startformula
+%D \startmatrix [distance=3pt,align={right,left}]
+%D \NC a + x \NC = a + d \NR
+%D \NC y \NC = d \NR
+%D \stopmatrix
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \startbuffer
+%D \startformula
+%D \startmatrix [left=\left(,right=\right)]
+%D \NC a + x \NR
+%D \NC y \NR
+%D \stopmatrix
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D A bit more complex code:
+%D
+%D \startbuffer
+%D \startformula
+%D \text{Let }{\cal R} = \bigcup_{P_{X_1},P_{X_2}}
+%D \left\{ (R_1, R_2) :
+%D \startmatrix[distance=1em,align={left,left,right}]
+%D \NC R_1 \NC < I(X_1 ; Y \mid X_2) \NC R_1 \NR
+%D \NC \hfill Q_2 \NC < I(X_2 ; Y \mid X_1) \NC R_2 \NR
+%D \NC R_1 + R_2 \NC < I(X_1 ; Y) \NC R_1 + R_2 \NR
+%D \stopmatrix
+%D \right\}
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \macros
+%D {startmatrices}
+%D
+%D Just a handy keystroke safer:
+
+\permanent\protected\def\startmatrices
+ {\begingroup
+ \setupmathmatrix}
+
+\permanent\protected\def\stopmatrices
+ {\endgroup}
+
+%D \startbuffer
+%D \startformula
+%D \startmatrix[left={\left(},right={\right)}]
+%D \NC A \NC B \NR \NC C \NC D \NR
+%D \stopmatrix
+%D =
+%D \startmatrix[left={\left(},right={\right)},location=low]
+%D \NC A \NC B \NR \NC C \NC D \NR
+%D \stopmatrix
+%D =
+%D \startmatrix[left={\left(},right={\right)},location=high]
+%D \NC A \NC B \NR \NC C \NC D \NR
+%D \stopmatrix
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \startformula
+%D \startmatrices[left={\left(},right={\right)}]
+%D \startmatrix
+%D \NC A \NC B \NR \NC C \NC D \NR
+%D \stopmatrix
+%D =
+%D \startmatrix[location=bottom]
+%D \NC A \NC B \NR \NC C \NC D \NR
+%D \stopmatrix
+%D =
+%D \startmatrix[location=top]
+%D \NC A \NC B \NR \NC C \NC D \NR
+%D \stopmatrix
+%D \stopmatrices
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer % does not run well: \getbuffer
+
+%D Handy for the \type {m-matrix} module:
+
+\permanent\tolerant\protected\def\startnamedmatrix[#1]#*[#2]%
+ {\begingroup
+ \edef\currentmathmatrix{#1}%
+ \setupcurrentmathmatrix[#2]%
+ \math_matrix_start[\currentmathmatrix]}
+
+\noaligned\permanent\protected\def\stopnamedmatrix
+ {\math_matrix_stop
+ \endgroup}
+
+%D The following code is derived from Aditya's simplematrix prototype but
+%D adapted to regular mathmatrices (which saves some code so it can go into
+%D the core):
+
+\def\math_matrix_simple_row#1%
+ {\rawprocesscommalist[#1]\math_matrix_simple_col
+ \toksapp\scratchtoks{\NR}}
+
+\def\math_matrix_simple_col#1%
+ {\toksapp\scratchtoks{\NC#1}}
+
+\permanent\tolerant\protected\def\math_matrix_simple[#1]#*[#2]#:#3%
+ {\begingroup
+ \edef\currentmathmatrix{#1}%
+ \setupcurrentmathmatrix[#2]%
+ \scratchtoks\emptytoks
+ \processlist[];\math_matrix_simple_row[#3]%
+ \math_matrix_start[\currentmathmatrix]%
+ \the\scratchtoks
+ \math_matrix_stop
+ \endgroup}
+
+%D We hook it into the normal mathmatrix code:
+
+\appendtoks
+ \edef\p_simplecommand{\mathmatrixparameter\c!simplecommand}%
+ \ifempty\p_simplecommand\else
+ \frozen\instance\setuevalue{\p_simplecommand}{\math_matrix_simple[\currentmathmatrix]}%
+ \fi
+\to \everydefinemathmatrix
+
+%D And predefine some matrices:
+
+\definemathmatrix[matrix:parentheses][\c!left={\left(\mskip\thinmuskip},\c!right={\mskip\thinmuskip\right)},\c!align=\v!middle]
+\definemathmatrix[matrix:brackets] [\c!left={\left[\mskip\thinmuskip},\c!right={\mskip\thinmuskip\right]},\c!align=\v!middle]
+\definemathmatrix[matrix:bars] [\c!left={\left|\mskip\thinmuskip},\c!right={\mskip\thinmuskip\right|},\c!align=\v!middle]
+
+\definemathmatrix[thematrix][matrix:parentheses][\c!simplecommand=thematrix]
+
+%D \startbuffer
+%D \startformula
+%D \thematrix{1,2,3,4;5,6,7,8;9,10,11,12}
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \startformula
+%D \startthematrix
+%D \NC 1\NC 2\NC 3\NC 4\NR
+%D \NC 5\NC 6\NC 7\NC 8\NR
+%D \NC 9\NC10\NC11\NC12\NR
+%D \stopthematrix
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \macros
+%D {startintertext}
+%D
+%D Preliminary feature:
+%D
+%D {\em example code}
+%D
+%D The intertext commands have to be expandable (in aligment lookahead) so
+%D we cannot use \type {\protected}.
+
+\permanent\def\startintertext#1\stopintertext
+ {\noalign{\math_intertext{#1}}}
+
+\permanent\let\stopintertext\relax
+
+\permanent\def\intertext#1%
+ {\noalign{\math_intertext{#1}}}
+
+\protected\def\math_intertext#1%
+ {\penalty\postdisplaypenalty
+ \afterdisplayspace
+ \vbox{\forgetall\noindent#1\par}%
+ \penalty\predisplaypenalty
+ \beforedisplayspace}
+
+%D \macros
+%D {substack}
+%D
+%D Preliminary code:
+%D
+%D \startbuffer
+%D \startformula
+%D \sum_{%
+%D \startsubstack
+%D i = 1 \NR
+%D i \neq n \NR
+%D i \neq m
+%D \stopsubstack
+%D }a_i
+%D \stopformula
+%D \stopbuffer
+%D
+%D \getbuffer which was typed as \typebuffer
+%D
+%D Notice that these macros give the correct spacing for
+%D subscripts. Compare for example
+%D
+%D \startbuffer
+%D \startformula
+%D \sum_{\startsubstack a \NR b \NR \stopsubstack}
+%D \text{ and }
+%D \sum_{\scriptstyle a \atop \scriptstyle}
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer which gives \getbuffer
+
+% no tagging yet : how is it supposed to be coded?
+
+\permanent\protected\def\startsubstack
+ {\begingroup
+ \vcenter\bgroup
+ \baselineskip\mathstacktotal
+ \lineskip\mathstackvgap
+ \lineskiplimit\lineskip
+ \mathsurround\zeropoint
+ \everycr\emptytoks
+ \enforced\let\NC\relax
+ \enforced\let\MC\relax
+ \enforced\let\NR\crcr
+ \halign\bgroup\hfil\normalstartimath\scriptstyle\alignmark\alignmark\normalstopimath\hfil\crcr}
+
+\noaligned\permanent\protected\def\stopsubstack
+ {\crcr
+ \egroup
+ \egroup
+ \endgroup}
+
+% %D \macros
+% %D {bordermatrix}
+% %D
+% %D In \PLAIN\ \TEX\ the width of a parenthesis is stored in
+% %D the \DIMENSION\ \type{\mathparentwd}. This value is derived from
+% %D the width of \type{\tenrm B}, so let's take care of it now:
+%
+% \ifdefined\mathparentwd \else \newdimen\mathparentwd \fi
+%
+% \let\normalbordermatrix\bordermatrix % move that code to here instead
+%
+% \protected\def\bordermatrix
+% {\begingroup
+% \setbox\scratchbox\hbox{\mr\char"239C}%
+% \global\mathparentwd\wd\scratchbox
+% \endgroup
+% \normalbordermatrix}
+%
+% \def\bordermatrix
+% {\begingroup
+% \mr
+% \global\mathparentwd\fontcharwd\font"239C\relax
+% \endgroup
+% \normalbordermatrix}
+
+%D \macros{overset, underset}
+%D
+%D The macros \type{\overset} and \type{\underset} are provided by
+%D \AMS\ packages in \LATEX. These macro allows you to place a symbol
+%D above or below another symbol, irrespective of whether the other
+%D symbol is a relation or something else, and without influencing the
+%D spacing. For most cases there is a better way to do such things
+%D (declaring a math command with limop option, or using accents), but
+%D occasionally these macros can be useful, for example:
+%D
+%D \startbuffer
+%D \startformula
+%D \overset{*}{X} \underset{*}{X}
+%D \stopformula
+%D \stopbuffer
+%D \typebuffer \getbuffer
+%D
+%D Use these macros sparingly. Remember, \TEX\ was designed for
+%D mathematics, so there is usually a proper method for typesetting
+%D common math notation.
+%D
+%D These macros are a cleaner version of \type {\binrel@} and
+%D \type {\binrel@@} macros in \AMSTEX\ packages.
+
+\def\math_binrel_apply#1%
+ {\begingroup
+ \setbox\scratchbox\hbox
+ {\thinmuskip 0mu
+ \medmuskip -1mu
+ \thickmuskip -1mu
+ \setbox\scratchbox\hbox{\normalstartimath#1\mathsurround\zeropoint\normalstopimath}%
+ \kern-\wd\scratchbox
+ \normalstartimath{}#1{}\mathsurround\zeropoint\normalstopimath}%
+ \ifdim\wd\scratchbox<\zeropoint
+ \endgroup
+ \expandafter\mathbin
+ \orelse\ifdim\wd\scratchbox>\zeropoint
+ \endgroup
+ \doubleexpandafter\mathrel
+ \else
+ \endgroup
+ \doubleexpandafter\firstofoneargument
+ \fi}
+
+\permanent\protected\def\overset#1#2%
+ {\math_binrel_apply{#2}{\mathop{\kern\zeropoint#2}\limits\normalsuperscript{#1}}}
+
+\permanent\protected\def\underset#1#2%
+ {\math_binrel_apply{#2}{\mathop{\kern\zeropoint#2}\limits\normalsubscript {#1}}}
+
+%D The following code comes from \type {math-str.mkiv}.
+%D
+%D Here we implement a basic math alignment mechanism. Numbers are also handled. The macros
+%D \type {\startinnermath} and \type {\stopinnermath} can be overloaded in specialized
+%D modules.
+
+\installcorenamespace{mathinnerstart}
+\installcorenamespace{mathinnerstop}
+
+% \protected\def\startinnermath{\csname\??mathinnerstart\formulaparameter\c!align\endcsname}
+% \protected\def\stopinnermath {\csname\??mathinnerstop \formulaparameter\c!align\endcsname}
+
+\permanent\protected\def\startinnermath{\expandnamespaceparameter\??mathinnerstart\formulaparameter\c!align\v!normal}
+\permanent\protected\def\stopinnermath {\expandnamespaceparameter\??mathinnerstop \formulaparameter\c!align\v!normal}
+
+\permanent\protected\def\mathinnerstrut
+ {\doif{\formulaparameter\c!strut}\v!yes\strut}
+
+\permanent\protected\def\defineinnermathhandler#1#2#3%
+ {\defcsname\??mathinnerstart#1\endcsname{#2}%
+ \defcsname\??mathinnerstop #1\endcsname{#3}}
+
+\installtextracker
+ {formulas.boxes}
+ {\enforced\let\math_hbox\ruledhbox}
+ {\enforced\let\math_hbox\hbox}
+
+\let\math_hbox\hbox
+
+\newconstant\mathraggedstatus % normal left center right
+\newconstant\mathnumberstatus % nothing normal shift_right
+
+\newdimen\d_math_number_correction
+
+\def\math_box_llapped_math_no
+ {\ifcase\mathraggedstatus\or
+ \box\b_strc_formulas_number
+ \or
+ \llap{\box\b_strc_formulas_number}%
+ \or
+ \llap{\box\b_strc_formulas_number}%
+ \fi}
+
+\def\math_box_rlapped_math_no
+ {\ifcase\mathraggedstatus\or
+ \rlap{\box\b_strc_formulas_number}%
+ \or
+ \rlap{\box\b_strc_formulas_number}%
+ \or
+ \box\b_strc_formulas_number
+ \fi}
+
+\newconditional\c_strc_math_has_number
+\newconditional\c_strc_math_display_overflow
+\newconstant \c_strc_math_number_location
+\newdimen \d_strc_math_number_width
+\newdimen \d_strc_math_display_width
+\newbox \b_strc_math_display
+\newconstant \c_strc_formulas_frame_mode
+\newdimen \d_strc_math_indent
+\newconditional\c_strc_math_indent
+
+\newdimen\d_strc_math_framed_width
+
+\setvalue{\??formulaoption\v!frame}%
+ {\edef\p_frame{\formulaparameter\c!frame}%
+ \ifx\p_frame\v!number
+ \c_strc_formulas_frame_mode\plustwo % inside frame
+ \else
+ \c_strc_formulas_frame_mode\plusone % outside frame
+ \fi}
+
+% mode: 0=no frame | 1=number inside frame | 2=number outside frame
+
+\def\strc_math_flush_aligned
+ {\ifcase\c_strc_math_vertical
+ \ifcase\mathraggedstatus\or\hfill\or\hfill\fi
+ \box\b_strc_math_display
+ \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi
+ \else
+ \ifconditional\c_strc_math_indent
+ \ifzeropt\d_strc_math_indent\else
+ \hangafter\plusone
+ \hangindent\d_strc_math_indent
+ \fi
+ \fi
+ \edef\p_interlinespace{\formulaparameter\c!interlinespace}%
+ \ifempty\p_interlinespace\else\baselineskip\p_interlinespace\fi
+ \global\d_strc_math_indent\zeropoint
+ \ifcase\mathraggedstatus\or\raggedleft\or\raggedcenter\or\raggedright\fi
+ \unhbox\b_strc_math_display
+ \fi}
+
+\def\strc_math_flush_box_normal
+ {\ifcase\c_strc_math_vertical
+ \hbox to \displaywidth\bgroup
+ \strc_math_flush_aligned
+ \egroup
+ \else
+ \strc_math_flush_aligned
+ \fi}
+
+\def\strc_math_flush_box_framed_common
+ {\d_strc_math_framed_width\displaywidth
+ \setformulaframedparameter\c!align{\formulaparameter\c!align}%
+ \letformulaframedparameter\c!strut\v!no
+ \d_framed_formula\ht\b_strc_math_display
+ \ifcase\mathraggedstatus\or\hfill\or\hfill \fi
+ \inheritedformulaframedframed{\box\b_strc_math_display}%
+ \ifcase\mathraggedstatus\or \or\hfill\or\hfill\fi}
+
+\def\strc_math_flush_box_framed_display
+ {\let\currentformulaframed\currentformula
+ \letformulaframedparameter\c!location\v!formula
+ \setformulaframedparameter\c!width{\d_strc_math_framed_width}%
+ \strc_math_flush_box_framed_common}
+
+\def\strc_math_flush_box_framed_fit_inline
+ {\let\currentformulaframed\currentformula
+ \letformulaframedparameter\c!location\empty
+ \letformulaframedparameter\c!width\v!fit
+ \strc_math_flush_box_framed_common}
+
+\def\strc_math_flush_box_framed_fit_display
+ {\let\currentformulaframed\currentformula
+ \letformulaframedparameter\c!location\v!formula
+ \letformulaframedparameter\c!width\v!fit
+ \strc_math_flush_box_framed_common}
+
+% combiners
+
+\def\strc_math_flush_box
+ {\ifcase\c_strc_formulas_frame_mode
+ \strc_math_flush_box_normal
+ \else
+ \strc_math_flush_box_framed_display
+ \fi}
+
+\def\strc_math_number_right_normal
+ {\strc_math_flush_aligned
+ \hss % hss makes room for number
+ \math_box_llapped_math_no}
+
+\def\strc_math_number_left_normal
+ {\math_box_rlapped_math_no
+ \strc_math_flush_aligned
+ \hss} % hss makes room for number
+
+\def\strc_math_number_right_normal_outside
+ {\ifconditional\c_strc_formulas_tight
+ \strc_math_flush_box_framed_fit_display
+ \else
+ \strc_math_flush_box_framed_display
+ \fi
+ \hss % hss makes room for number
+ \math_box_llapped_math_no}
+
+\def\strc_math_number_left_normal_outside
+ {\math_box_rlapped_math_no
+ \hss % hss makes room for number
+ \ifconditional\c_strc_formulas_tight
+ \strc_math_flush_box_framed_fit_display
+ \else
+ \strc_math_flush_box_framed_display
+ \fi}
+
+\def\strc_math_number_right_normal_inside
+ {\setbox\b_strc_math_display\hpack to \dimexpr\displaywidth-\d_framed_locator_lo-\d_framed_locator_ro\relax\bgroup
+ \strc_math_flush_aligned
+ \hss
+ \math_box_llapped_math_no
+ \egroup
+ \strc_math_flush_box_framed_fit_inline}
+
+\def\strc_math_number_left_normal_inside
+ {\setbox\b_strc_math_display\hpack to \dimexpr\displaywidth-\d_framed_locator_lo-\d_framed_locator_ro\relax\bgroup
+ \math_box_rlapped_math_no
+ \hss
+ \strc_math_flush_aligned
+ \egroup
+ \strc_math_flush_box_framed_fit_inline}
+
+\def\strc_math_number_right_overflow
+ {\vpack\bgroup
+ \strc_math_flush_box
+ \par
+ \hpack to \displaywidth\bgroup
+ \hss
+ \math_box_llapped_math_no
+ \egroup
+ \egroup}
+
+\def\strc_math_number_left_overflow
+ {\vpack\bgroup
+ \hpack to \displaywidth\bgroup
+ \math_box_rlapped_math_no
+ \hss
+ \egroup
+ \strc_math_flush_box
+ \egroup}
+
+\def\strc_math_number_right_overflow_outside
+ {\vpack\bgroup
+ \strc_math_flush_box_framed_fit_inline
+ %\hskip\zeropoint % nicely breaks the line without introducing funny vertical spacing ... why o why
+ \hpack to \displaywidth\bgroup
+ \hss
+ \math_box_llapped_math_no
+ \egroup
+ \egroup}
+
+\def\strc_math_number_left_overflow_outside
+ {\vpack\bgroup
+ \hpack to \dimexpr\displaywidth-\d_framed_locator_lo\relax\bgroup
+ \math_box_rlapped_math_no
+ \hss
+ \egroup
+ \hskip\zeropoint % nicely breaks the line without introducing funny vertical spacing ... why o why
+ \strc_math_flush_box_framed_fit_inline
+ \egroup}
+
+\def\strc_math_number_right_overflow_inside
+ {\setbox\b_strc_math_display\vpack\bgroup
+ \box\b_strc_math_display
+ \hpack to \displaywidth\bgroup
+ \hss
+ \math_box_llapped_math_no
+ \hskip\d_framed_locator_ro
+ \egroup
+ \egroup
+ \strc_math_flush_box_framed_fit_inline}
+
+\def\strc_math_number_left_overflow_inside
+ {\setbox\b_strc_math_display\vpack\bgroup
+ \hpack to \displaywidth\bgroup
+ % \hskip\d_framed_locator_lo
+ \math_box_rlapped_math_no
+ \hss
+ \egroup
+ \box\b_strc_math_display
+ \egroup
+ \strc_math_flush_box_framed_fit_inline}
+
+% checkers
+
+\def\strc_math_number_check
+ {\d_strc_math_display_width\wd\b_strc_math_display
+ \ifconditional\c_strc_formulas_tight
+ \ifdim\d_strc_math_display_width>\displaywidth
+ \settrue\c_strc_math_display_overflow
+ \else
+ \displaywidth\d_strc_math_display_width
+ \setfalse\c_strc_math_display_overflow
+ \fi
+ \else
+ \ifdim\d_strc_math_display_width>\displaywidth
+ \settrue\c_strc_math_display_overflow
+ \else
+ \setfalse\c_strc_math_display_overflow
+ \fi
+ \fi}
+
+\def\strc_math_number_check_outside
+ {\d_strc_math_display_width\naturalwd\b_strc_math_display
+ \ifdim\dimexpr\d_strc_math_display_width+\d_framed_locator_lo+\d_framed_locator_ro\relax>\displaywidth
+ \settrue\c_strc_math_display_overflow
+ \else
+ \setfalse\c_strc_math_display_overflow
+ \fi
+ % still ok?
+ \ifnum\mathraggedstatus=\plustwo
+ \d_strc_math_framed_width\dimexpr\displaywidth-2\wd\b_strc_formulas_number\relax
+ \else
+ \d_strc_math_framed_width\dimexpr\displaywidth- \wd\b_strc_formulas_number\relax
+ \fi}
+
+\let\strc_math_number_check_inside\strc_math_number_check_outside
+
+% offsets
+
+\def\strc_math_number_check_offsets
+ {\begingroup
+ \setbox\scratchbox\hbox
+ {\inheritedformulaframedframed
+ {\pack_framed_locator_set_lo\pack_framed_locator_set_ro}}%
+ \endgroup}
+
+% tracing
+
+\def\strc_math_traced_state_yes
+ {\llap{\setbox\scratchbox\hbox{\infofont
+ \ifcase\mathraggedstatus unset\or right\or middle\or left\fi
+ \space
+ \ifcase\c_strc_formulas_frame_mode no\or out\or in\fi
+ \space
+ \ifconditional\c_strc_math_display_overflow overflow\else fit\fi
+ \quad}\ht\scratchbox\zeropoint\dp\scratchbox\zeropoint\box\scratchbox}}
+
+\let\strc_math_traced_state\relax
+
+\installtextracker
+ {formulas.framed}
+ {\let\strc_math_traced_state\strc_math_traced_state_yes}
+ {\let\strc_math_traced_state\relax}
+
+% packaging
+
+\protected\def\strc_math_box_start#1%
+ {\hsize\displaywidth % \checkeddisplaymath
+ \global\mathnumberstatus\plusone
+ \mathraggedstatus#1\relax
+ %
+ \global\d_math_number_correction\zeropoint
+ %
+ \edef\p_location{\formulaparameter\c!location}%
+ \useformulacolorparameter\c!color
+ \c_strc_math_number_location\ifx\p_location\v!left\plusone\orelse\ifx\p_location\v!right\plustwo\else\zerocount\fi
+ %
+ %\strc_formulas_place_number % not here as we can have inner alignment numbers
+ \dontcomplain
+ \setbox\b_strc_math_display\math_hbox\bgroup % \checkeddisplaymath
+ \mathinnerstrut
+ \startforceddisplaymath}
+
+\def\strc_math_flush_number_no
+ {\ifcase\c_strc_math_vertical
+ \ifconditional\c_strc_math_display_overflow
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_flush_box_normal
+ \else
+ \strc_math_flush_box_framed_fit_inline
+ \fi
+ \else
+ \ifcase\c_strc_formulas_frame_mode
+ %\ifconditional\c_strc_formulas_tight
+ % \strc_math_flush_box_normal
+ %\else
+ \strc_math_flush_box_normal
+ %\fi
+ \else
+ \ifconditional\c_strc_formulas_tight
+ \strc_math_flush_box_framed_fit_inline
+ \else
+ \strc_math_flush_box_framed_display
+ \fi
+ \fi
+ \fi
+ \else
+ \strc_math_flush_box
+ \fi}
+
+\def\strc_math_flush_number_left
+ {\ifcase\c_strc_math_vertical
+ \ifconditional\c_strc_math_display_overflow
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_left_overflow
+ \or
+ \strc_math_number_left_overflow_outside
+ \or
+ \strc_math_number_left_overflow_inside
+ \fi
+ \else
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_left_normal
+ \or
+ \strc_math_number_left_normal_outside
+ \or
+ \strc_math_number_left_normal_inside
+ \fi
+ \fi
+ \else
+ \box\b_strc_formulas_number
+ \hfill
+ \strc_math_flush_aligned
+ \fi}
+
+\def\strc_math_flush_number_right
+ {\ifcase\c_strc_math_vertical
+ \ifconditional\c_strc_math_display_overflow
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_right_overflow
+ \or
+ \strc_math_number_right_overflow_outside
+ \or
+ \strc_math_number_right_overflow_inside
+ \fi
+ \else
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_right_normal
+ \or
+ \strc_math_number_right_normal_outside
+ \or
+ \strc_math_number_right_normal_inside
+ \fi
+ \fi
+ \else
+ \strc_math_flush_aligned
+ \hfill
+ \box\b_strc_formulas_number
+ \fi}
+
+\protected\def\strc_math_box_stop
+ {\stopforceddisplaymath
+ \egroup
+ % check number
+ \d_strc_math_number_width\wd\b_strc_formulas_number
+ %
+ \ifcase\mathnumberstatus
+ \setfalse\c_strc_math_has_number
+ \or\ifzeropt\d_strc_math_number_width
+ \setfalse\c_strc_math_has_number
+ \else
+ \settrue\c_strc_math_has_number
+ \fi\fi
+ % preroll left and right offsets
+ \ifcase\c_strc_formulas_frame_mode
+ % no frame
+ \else
+ \strc_math_number_check_offsets
+ \fi
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_check
+ \or
+ \strc_math_number_check_outside
+ \else
+ \strc_math_number_check_inside
+ \fi
+ \noindent % \noindentation % not \dontleavehmode
+ \hskip\d_strc_formulas_display_margin_left % was kern but that doesn't indent
+ \strc_math_traced_state
+ \ifcase\c_strc_math_vertical
+ \hbox to \displaywidth \bgroup
+ \or
+ \vbox \bgroup \hsize\displaywidth
+ \or
+ \bgroup \hsize\displaywidth
+ \fi
+ \ifcase\mathnumberstatus
+ \strc_math_flush_box
+ \or % status 1
+ \ifcase\c_strc_math_number_location
+ \strc_math_flush_box
+ \or % number left
+ \ifzeropt\wd\b_strc_formulas_number
+ \strc_math_flush_number_no
+ \else
+ \strc_math_flush_number_left
+ \fi
+ \else % number right
+ \ifzeropt\wd\b_strc_formulas_number
+ \strc_math_flush_number_no
+ \else
+ \strc_math_flush_number_right
+ \fi
+ \fi
+ \or % status 2
+ \hskip\d_math_number_correction % probably no longer used
+ \strc_math_flush_box
+ \hss
+ \else
+ \strc_math_flush_box
+ \fi
+ \ifcase\c_strc_math_vertical
+ \or
+ \or
+ \par
+ \fi
+ \egroup}
+
+\defineinnermathhandler\v!left {\strc_math_box_start\plusone }{\strc_math_box_stop}
+\defineinnermathhandler\v!middle {\strc_math_box_start\plustwo }{\strc_math_box_stop}
+\defineinnermathhandler\v!right {\strc_math_box_start\plusthree}{\strc_math_box_stop}
+\defineinnermathhandler\v!flushleft {\strc_math_box_start\plusthree}{\strc_math_box_stop}
+\defineinnermathhandler\v!center {\strc_math_box_start\plustwo }{\strc_math_box_stop}
+\defineinnermathhandler\v!flushright{\strc_math_box_start\plusone }{\strc_math_box_stop}
+\defineinnermathhandler\v!normal {\strc_math_box_start\plustwo }{\strc_math_box_stop}
+
+%D Some inline math tweak.
+
+\appendtoks
+ \ifcase\mathnestinglevel\or
+ % 4=disable 6=only when no spaces
+ \mathsurroundskip\mathematicsparameter\c!textdistance\relax
+ \ifzeropt\mathsurroundskip
+ \ifzeropt\gluestretch\mathsurroundskip
+ \ifzeropt\glueshrink\mathsurroundskip
+ \mathsurroundmode\plussix
+ \else
+ \mathsurroundskip\zeropoint
+ \mathsurroundmode\plusfour
+ \fi
+ \else
+ \mathsurroundmode\plussix
+ \fi
+ \else
+ \mathsurroundmode\plussix
+ \fi
+ \else
+ \mathsurroundmode\plusfour
+ \mathsurroundskip\zeropoint
+ \fi
+\to \everymathematics
+
+\setupmathematics
+ [\c!textdistance=\zeropoint]
+
+%D This is an experiment. No fancy spacing and alignments here. If we ever
+%D go that route it might result in incompatible rendering.
+
+\permanent\protected\def\startsplitformula
+ {\ifhmode
+ \par
+ \fi
+ \begingroup
+ \beforedisplayspace
+ % subset of \everydisplay:
+ \c_attr_mathmode\plusone
+ \settrue \indisplaymath
+ % end of subset
+ \informulatrue}
+
+\permanent\protected\def\stopsplitformula
+ {\afterdisplayspace
+ \endgroup}
+
+\protect \endinput
+
+% \placeformula \startformula[-] \startmatrix
+% \NC 1 \NC x \NC a \NR
+% \NC 2 \NC y \NC b \NR
+% \NC 3 \NC z \NC c \NR
+% \stopmatrix \stopformula
+
+% \definemathmatrix[bordermatrix][left={\left[\mskip\thinmuskip},right={\mskip\thinmuskip\right]}]
+
+% \placeformula \startformula[-] \startbordermatrix
+% \NC 1 \NC x \NC a \NR
+% \NC 2 \NC y \NC b \NR
+% \NC 3 \NC z \NC c \NR
+% \stopbordermatrix \stopformula
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-def.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-def.mkxl
new file mode 100644
index 00000000000..1f3da649d1d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-def.mkxl
@@ -0,0 +1,172 @@
+ %D \module
+%D [ file=math-tex,
+%D version=2001.04.12,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Definitions,
+%D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Definitions}
+
+\unprotect
+
+\pushoverloadmode % cap etc
+
+\startluacode
+ mathematics.define(\number\defaultmathfamily)
+ -- mathematics.xml.registerentities()
+\stopluacode
+
+\popoverloadmode
+
+\activatemathcharacters
+
+%D The \mfunction macro is an alternative for \hbox with a controlable font
+%D switch.
+
+\definemathcommand [arccos] [nolop] {\mfunctionlabeltext{arccos}}
+\definemathcommand [arcsin] [nolop] {\mfunctionlabeltext{arcsin}}
+\definemathcommand [arctan] [nolop] {\mfunctionlabeltext{arctan}}
+\definemathcommand [arccosh] [nolop] {\mfunctionlabeltext{arccosh}}
+\definemathcommand [arcsinh] [nolop] {\mfunctionlabeltext{arcsinh}}
+\definemathcommand [arctanh] [nolop] {\mfunctionlabeltext{arctanh}}
+\definemathcommand [acos] [nolop] {\mfunctionlabeltext{acos}}
+\definemathcommand [asin] [nolop] {\mfunctionlabeltext{asin}}
+\definemathcommand [atan] [nolop] {\mfunctionlabeltext{atan}}
+\definemathcommand [arg] [nolop] {\mfunctionlabeltext{arg}}
+\definemathcommand [cosh] [nolop] {\mfunctionlabeltext{cosh}}
+\definemathcommand [cos] [nolop] {\mfunctionlabeltext{cos}}
+\definemathcommand [coth] [nolop] {\mfunctionlabeltext{coth}}
+\definemathcommand [cot] [nolop] {\mfunctionlabeltext{cot}}
+\definemathcommand [csc] [nolop] {\mfunctionlabeltext{csc}}
+\definemathcommand [deg] [nolop] {\mfunctionlabeltext{deg}}
+\definemathcommand [det] [limop] {\mfunctionlabeltext{det}}
+\definemathcommand [dim] [nolop] {\mfunctionlabeltext{dim}}
+\definemathcommand [exp] [nolop] {\mfunctionlabeltext{exp}}
+\definemathcommand [gcd] [limop] {\mfunctionlabeltext{gcd}}
+\definemathcommand [hom] [nolop] {\mfunctionlabeltext{hom}}
+\definemathcommand [inf] [limop] {\mfunctionlabeltext{inf}}
+\definemathcommand [injlim] [limop] {\mfunctionlabeltext{injlim}}
+\definemathcommand [ker] [nolop] {\mfunctionlabeltext{ker}}
+\definemathcommand [lg] [nolop] {\mfunctionlabeltext{lg}}
+\definemathcommand [liminf] [limop] {\mfunctionlabeltext{liminf}}
+\definemathcommand [limsup] [limop] {\mfunctionlabeltext{limsup}}
+\definemathcommand [lim] [limop] {\mfunctionlabeltext{lim}}
+\definemathcommand [ln] [nolop] {\mfunctionlabeltext{ln}}
+\definemathcommand [log] [nolop] {\mfunctionlabeltext{log}}
+\definemathcommand [median] [limop] {\mfunctionlabeltext{median}}
+\definemathcommand [max] [limop] {\mfunctionlabeltext{max}}
+\definemathcommand [min] [limop] {\mfunctionlabeltext{min}}
+\definemathcommand [mod] [limop] {\mfunctionlabeltext{mod}}
+%definemathcommand [div] [limop] {\mfunctionlabeltext{div}} % overloads \div symbol
+\definemathcommand [projlim] [limop] {\mfunctionlabeltext{projlim}}
+\definemathcommand [Pr] [limop] {\mfunctionlabeltext{Pr}}
+\definemathcommand [sec] [nolop] {\mfunctionlabeltext{sec}}
+\definemathcommand [sinh] [nolop] {\mfunctionlabeltext{sinh}}
+\definemathcommand [sin] [nolop] {\mfunctionlabeltext{sin}}
+\definemathcommand [sup] [limop] {\mfunctionlabeltext{sup}}
+\definemathcommand [tanh] [nolop] {\mfunctionlabeltext{tanh}}
+\definemathcommand [tan] [nolop] {\mfunctionlabeltext{tan}}
+\definemathcommand [diff] {\mfunctionlabeltext{diff}}
+
+\aliased\let\normalmatharg\arg % todo: maybe automatically
+
+%D This needs checking:
+
+\permanent\protected\def\setoperatorlimits#1#2% operator limits
+ {\savenormalmeaning{#1}%
+ %frozen\protected\expandafter\def\expandafter#1\expandafter{\csname normal\csstring#1\endcsname#2}}
+ \frozen\protected\edef#1{\expandafter\noexpand\csname\s!normal\csstring#1\endcsname\noexpand#2}}
+
+\pushoverloadmode
+
+\setoperatorlimits \int \intlimits
+\setoperatorlimits \iint \intlimits
+\setoperatorlimits \iiint \intlimits
+\setoperatorlimits \oint \intlimits
+\setoperatorlimits \oiint \intlimits
+\setoperatorlimits \oiiint \intlimits
+\setoperatorlimits \intclockwise \intlimits
+\setoperatorlimits \ointclockwise \intlimits
+\setoperatorlimits \ointctrclockwise \intlimits
+
+\popoverloadmode
+
+%D \macros
+%D {centercolon, colonminus, minuscolon, colonequals, equalscolon,
+%D colonapprox, approxcolon, colonsim, simcolon, coloncolon,
+%D coloncolonminus, minuscoloncolon, coloncolonequals,
+%D equalscoloncolon, coloncolonapprox, approxcoloncolon,
+%D colonsim, simcoloncolon}
+%D
+%D The following colon related definitions are provided by Aditya
+%D Mahajan who derived them from \type {mathtools.sty} and \type
+%D {colonequals.sty}. This will be redone as part of the overhaul
+%D and font updates.
+%D
+%D In $a := b$ the colon is not vertically centered with the equal
+%D to. Also the distance between colon and equal to is a bit large.
+%D So, we define a vertically centered colon \tex {centercolon} and
+%D a few macros for colon and double colon relation symbols.
+%D
+%D \startlines
+%D \formula {A \centercolon B}
+%D \formula {A \colonminus B}
+%D \formula {A \minuscolon B}
+%D \formula {A \colonequals B}
+%D \formula {A \equalscolon B}
+%D \formula {A \colonapprox B}
+%D \formula {A \approxcolon B}
+%D \formula {A \colonsim B}
+%D \formula {A \simcolon B}
+%D \formula {A \coloncolon B}
+%D \formula {A \coloncolonminus B}
+%D \formula {A \minuscoloncolon B}
+%D \formula {A \coloncolonequals B}
+%D \formula {A \equalscoloncolon B}
+%D \formula {A \coloncolonapprox B}
+%D \formula {A \approxcoloncolon B}
+%D \formula {A \colonsim B}
+%D \formula {A \simcoloncolon B}
+%D \stoplines
+%D
+%D The next macros take care of the space between the colon and the
+%D relation symbol.
+
+\pushoverloadmode
+
+\definemathcommand [colonsep] {\mkern-1.2mu}
+\definemathcommand [doublecolonsep] {\mkern-0.9mu}
+
+\definemathcommand [centercolon] [rel] {\mathstylevcenteredhbox\colon}
+\definemathcommand [colonminus] [rel] {\centercolon\colonsep\mathrel{-}}
+%definemathcommand [minuscolon] [rel] {\mathrel{-}\colonsep\centercolon} % native char
+%definemathcommand [colonequals] [rel] {\centercolon\colonsep=} % native char
+%definemathcommand [equalscolon] [rel] {=\centercolon\colonsep} % native char
+\definemathcommand [colonapprox] [rel] {\centercolon\colonsep\approx}
+\definemathcommand [approxcolon] [rel] {\approx\centercolon\colonsep}
+\definemathcommand [colonsim] [rel] {\centercolon\colonsep\sim}
+\definemathcommand [simcolon] [rel] {\sim\centercolon\colonsep}
+
+\definemathcommand [coloncolon] [rel] {\centercolon\doublecolonsep\centercolon}
+\definemathcommand [coloncolonminus] [rel] {\coloncolon\colonsep\mathrel{-}}
+\definemathcommand [minuscoloncolon] [rel] {\mathrel{-}\colonsep\coloncolon}
+\definemathcommand [coloncolonequals] [rel] {\coloncolon\colonsep=} % native char
+\definemathcommand [equalscoloncolon] [rel] {=\coloncolon\colonsep}
+\definemathcommand [coloncolonapprox] [rel] {\coloncolon\colonsep\approx}
+\definemathcommand [approxcoloncolon] [rel] {\approx\coloncolon\colonsep}
+\definemathcommand [coloncolonsim] [rel] {\coloncolon\colonsep\sim}
+\definemathcommand [simcoloncolon] [rel] {\sim\coloncolon\colonsep}
+
+\popoverloadmode
+
+% \appendtoks
+% \def\over{\primitive\over}%
+% \to \everymathematics
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-del.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-del.mkxl
new file mode 100644
index 00000000000..07e6d794874
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-del.mkxl
@@ -0,0 +1,164 @@
+%D \module
+%D [ file=math-del,
+%D version=2007.07.19,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Delimiters,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Delimiters}
+
+\unprotect
+
+%D Old code that will be redone:
+%D
+%D \macros
+%D {checkdelimiters, fakeleftdelimiter, fakerightdelimiter}
+%D
+%D Handy for non matching situations (as with mathml):
+%D
+%D \starttyping
+%D \checkdelimiters{... bla bla ...}
+%D \fakeleftdelimiter
+%D ... bla bla ...
+%D \fakerightdelimiter
+%D \stoptyping
+
+% Actually we can do better now with lua hacks.
+
+\newcount\c_math_delimiter_nesting
+
+\permanent\protected\def\leftfakedelimiter {\advance\c_math_delimiter_nesting\minusone\gobbleoneargument}
+\permanent\protected\def\rightfakedelimiter{\advance\c_math_delimiter_nesting\plusone \gobbleoneargument}
+
+\permanent\protected\def\checkdelimiters#1%
+ {\c_math_delimiter_nesting\zerocount
+ \setbox\scratchbox\hbox\bgroup
+ \let\left \leftfakedelimiter
+ \let\right\rightfakedelimiter
+ \normalstartimath#1\expandafter\normalstopimath\expandafter
+ \egroup
+ \expandafter\c_math_delimiter_nesting\the\c_math_delimiter_nesting\relax}
+
+\permanent\protected\def\fakeleftdelimiter {\ifnum\c_math_delimiter_nesting>\zerocount\left .\fi}
+\permanent\protected\def\fakerightdelimiter{\ifnum\c_math_delimiter_nesting<\zerocount\right.\fi}
+
+%D The following macros are used in the MathML interpreter, so there is a good
+%D change of them never being documented for other usage.
+
+\aliased\let\normalordelimiter\secondoftwoarguments
+\aliased\let\normalorfiller \firstoftwoarguments
+
+\permanent\protected\def\enabledelimiter {\enforced\let\normalordelimiter\secondoftwoarguments}
+\permanent\protected\def\disabledelimiter{\enforced\let\normalordelimiter\firstoftwoarguments}
+
+\permanent\protected\def\enablefiller {\enforced\let\normalorfiller\secondoftwoarguments}
+\permanent\protected\def\disablefiller {\enforced\let\normalorfiller\firstoftwoarguments}
+
+\permanent\protected\def\mathopnolimits#1{\mathop{\mathrm#1}\nolimits} % was \rm, which follows text fonts (used in mml parser, check!)
+\permanent\protected\def\mathopdolimits#1{\mathop{\mathrm#1}} % was \rm, which follows text fonts (used in mml parser, check!)
+
+% A new experiment:
+
+% Hm, we already have \definemathextensible so we need to preserve that one. We now
+% use \definemathdelimiter.
+
+\installcorenamespace {mathdelimiter}
+
+\installcommandhandler \??mathdelimiter {mathdelimiter} \??mathdelimiter
+
+\aliased\let\setupmathdelimiters\setupmathdelimiter
+
+\setupmathdelimiters
+ [\c!symbol=0,
+ \c!define=\v!yes,
+ \c!factor=1.5,
+ \c!axis=\v!yes,
+ % \c!exact=\v!yes
+ \c!height=\exheight,
+ \c!depth=\exheight]
+
+\appendtoks
+ \ifcstok{\mathdelimiterparameter\c!define}\v!yes
+ \frozen\instance\setuevalue\currentmathdelimiter{\mathdelimiter[\currentmathdelimiter]}%
+ \fi
+\to \everydefinemathdelimiter
+
+\permanent\tolerant\protected\def\mathdelimiter[#1]#*[#2]%
+ {\mathop
+ {\edef\currentmathdelimiter{#1}%
+ \iftok{#2}\emptytoks
+ \edef\p_factor{\mathdelimiterparameter\c!factor}%
+ \orelse\ifhastok={#2}%
+ \setupcurrentmathdelimiter[#2]%
+ \edef\p_factor{\mathdelimiterparameter\c!factor}%
+ \else
+ \edef\p_factor{#2}%
+ \fi
+ \edef\p_exact{\mathdelimiterparameter\c!exact}%
+ \edef\p_axis {\mathdelimiterparameter\c!axis}%
+ \edef\p_leftoffset{\mathdelimiterparameter\c!leftoffset}%
+ \edef\p_rightoffset{\mathdelimiterparameter\c!rightoffset}%
+ \ifempty\p_leftoffset\else
+ \mskip\p_leftoffset
+ \fi
+ \Uvextensible
+ \ifx\p_exact\v!yes exact \fi
+ \ifx\p_axis \v!yes axis \fi
+ height \p_factor\dimexpr\mathdelimiterparameter\c!height\relax
+ depth \p_factor\dimexpr\mathdelimiterparameter\c!depth \relax
+ \Udelimiter\zerocount\zerocount\mathdelimiterparameter\c!symbol
+ \relax
+ \ifempty\p_rightoffset\else
+ \mskip\p_rightoffset
+ \fi}}
+
+\definemathdelimiter[integral][\c!symbol="222B]
+
+% \setupmathdelimiter[integral][rightoffset=-3mu,exact=yes,factor=2]
+%
+% \let\inlineint \int
+% \let\displayint\integral
+%
+% \protected\def\int{\ifmmode\inlineordisplaymath\inlineint\displayint\else\normalint\fi}
+%
+% \startlines
+% \ruledhbox{$\integral f\frac{1}{2}$}
+% \ruledhbox{$\integral[factor=1] f\frac{1}{2}$}
+% \ruledhbox{$\integral[factor=3] f\frac{1}{2}$}
+% \ruledhbox{$\int f\frac{1}{2}$}
+% \stoplines
+
+\permanent\protected\def\autointegral#1#2#3%
+ {\ifmmode
+ \setbox\nextbox\mathstylehbox{#3}%
+ \scratchdimen\ifdim\nextboxht>\nextboxdp\nextboxht\else\nextboxdp\fi
+ \mathlimop{%
+ \Uvextensible
+ height \scratchdimen
+ depth \scratchdimen
+ exact%
+ axis%
+ \Udelimiter \plusfour \zerocount "222B%
+ }%
+ \limits % nolimits needs more work: kerning and so
+ \normalsuperscript{#1}%
+ \normalsubscript{#2}%
+ \box\nextbox
+ \else
+ \char"222B\relax
+ \fi}
+
+% \startformula
+% a =
+% \autointegral{t}{b}1 +
+% \autointegral{t}{b}{\frac{\frac{3}{4}}{\frac{1}{2}}} +
+% \autointegral{t}{b}{\frac{\frac{\frac{\frac{1}{2}}{2}}{2}}{2}}
+% \stopformula
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-dis.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-dis.mkxl
new file mode 100644
index 00000000000..5b70970f3cc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-dis.mkxl
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=math-ali,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Display,
+%D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Display}
+
+\unprotect
+
+% display spacing code will move here
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-fen.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-fen.mkxl
new file mode 100644
index 00000000000..8aa0e62a8cb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-fen.mkxl
@@ -0,0 +1,841 @@
+%D \module
+%D [ file=math-fen,
+%D version=2012.02.18,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Fences,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Fences}
+
+\unprotect
+
+% maybe always "method=auto" for:
+%
+% \switchtobodyfont[cambria]
+% \ruledhbox{$f(x)$}
+% \ruledhbox{\mathdelimitersmode6$f\left(x\right)$}
+% \ruledhbox{\mathdelimitersmode7$f\left(x\right)$}
+% \ruledhbox{$f\left(\frac{1}{x}\right)$}
+
+% todo: mathstyle
+
+% \definemathfence [fancybracket] [bracket] [command=yes,color=blue]
+%
+% test $|x|$ test \par
+% test $||x||$ test (okay) \par
+% test $a\left|\frac{1}{b}\right|c$ test \par
+% test $a\left||\frac{1}{b}\right||c$ test (not okay) \par
+%
+% \setupmathfences [color=red]
+%
+% test $a\fenced[bar]{\frac{1}{b}}c$ test \par
+% test $a\fenced[doublebar]{\frac{1}{b}}c$ test \par
+% test $a\fenced[bracket]{\frac{1}{b}}c$ test \par
+% test $a\fancybracket{\frac{1}{b}}c$ test \par
+
+\installcorenamespace{mathfences}
+
+\installcommandhandler \??mathfences {mathfence} \??mathfences
+
+\aliased\let\setupmathfences\setupmathfence
+
+\setupmathfences
+ [\c!method=, % maybe always \v!auto
+ \c!left=,
+ \c!right=,
+ \c!middle=,
+ \c!mathstyle=,
+ \c!color=,
+ \c!command=,
+ \c!mathclass=,
+ \c!factor=\v!auto]
+
+\appendtoks
+ \edef\p_command{\mathfenceparameter\c!command}%
+ \ifx\p_command\v!yes
+ \setuevalue\currentmathfence{\math_fenced_fenced[\currentmathfence]}%
+ \fi
+\to \everydefinemathfence
+
+% we need the direct use of \Udelimiter because of { etc
+
+%D So we can do:
+%D
+%D \starttyping
+%D $ a + \fenced[bar][size=1] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=2] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=3] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=4] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=big] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=Big] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=bigg]{\frac {b} {c}} + d $
+%D $ a + \fenced[bar][size=Bigg]{\frac {b} {c}} + d $
+%D $ a + \fenced[bar][factor=1] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][factor=2] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar][factor=4] {\frac {b} {c}} + d $
+%D $ a + \fenced[bar] {\frac {b} {c}} + d $
+%D \stoptyping
+
+\newconditional\c_math_fenced_mirror \settrue \c_math_fenced_mirror
+\newconditional\c_math_fenced_sized \setfalse\c_math_fenced_sized
+
+\installcorenamespace {mathfencesize}
+
+\setvalue{\??mathfencesize big}{1}
+\setvalue{\??mathfencesize Big}{2}
+\setvalue{\??mathfencesize bigg}{3}
+\setvalue{\??mathfencesize Bigg}{4}
+
+\def\math_fenced_force_size#1#2%
+ {\c_attr_mathsize\numexpr
+ #1*\plushundred
+ +\ifcsname\??mathfencesize#2\endcsname\lastnamedcs\else#2\fi
+ \relax}
+
+\protected\def\math_fenced_inject#1#2#3#4%
+ {\ifx#1\empty
+ #2.%
+ \else
+ \edef\p_mathclass{\mathfenceparameter\c!mathclass}%
+ \ifconditional\c_math_fenced_sized
+ \let\p_factor\v!fixed
+ \else
+ \edef\p_factor{\mathfenceparameter\c!factor}%
+ \fi
+ \ifempty\p_factor
+ \ifempty\p_mathclass
+ #2%
+ \else
+ #3%
+ \s!class\p_mathclass
+ \fi
+ \orelse\ifx\p_factor\v!auto
+ \ifempty\p_mathclass
+ #2%
+ \else
+ #3%
+ \s!class\p_mathclass
+ \fi
+ \orelse\ifx\p_factor\v!none
+ #3%
+ \s!height\zeropoint % redundant with "exact"
+ \s!depth\zeropoint % redundant with "exact"
+ \ifempty\p_mathclass\else
+ \s!class\p_mathclass
+ \fi
+ \s!axis
+ \s!exact % new
+ % #2%
+ \else
+ %\scratchdimen\ifx\p_factor\v!fixed\scaledpoint\else\dimexpr\p_factor\bodyfontsize/2\relax\fi
+ \scratchdimen\ifx\p_factor\v!fixed\zeropoint\else\dimexpr\p_factor\bodyfontsize/2\relax\fi
+ #3%
+ \s!height\scratchdimen
+ \s!depth\scratchdimen
+ \ifempty\p_mathclass\else
+ \s!class\p_mathclass
+ \fi
+ \s!axis
+ \s!exact
+ \fi
+ \Udelimiter#4\fam#1\relax
+ \fi}
+
+\permanent\def\math_fenced_left
+ {\edef\p_left
+ {\ifconditional\c_math_fenced_mirror
+ \ifconditional\c_math_right_to_left
+ \mathfenceparameter\c!right
+ \else
+ \mathfenceparameter\c!left
+ \fi
+ \else
+ \mathfenceparameter\c!left
+ \fi}%
+ \math_fenced_color_push
+ \math_fenced_inject\p_left\normalleft\Uleft\plusfour
+ \math_fenced_color_pop}
+
+\permanent\def\math_fenced_middle
+ {\edef\p_middle{\mathfenceparameter\c!middle}%
+ \mskip\thinmuskip
+ \math_fenced_color_push
+ \math_fenced_inject\p_middle\normalmiddle\Umiddle\plusfour
+ \math_fenced_color_pop
+ \mskip\thinmuskip}
+
+\permanent\def\math_fenced_right
+ {\edef\p_right
+ {\ifconditional\c_math_fenced_mirror
+ \ifconditional\c_math_right_to_left
+ \mathfenceparameter\c!left
+ \else
+ \mathfenceparameter\c!right
+ \fi
+ \else
+ \mathfenceparameter\c!right
+ \fi}%
+ \math_fenced_color_push
+ \math_fenced_inject\p_right\normalright\Uright\plusfive
+ \math_fenced_color_pop}
+
+\def\math_fenced_color_do_push{\pushcolor[\p_math_fenced_color]}
+\let\math_fenced_color_do_pop \popcolor
+
+\let\math_fenced_color_push\donothing
+\let\math_fenced_color_pop \donothing
+
+\aliased\let\fence \relax
+\aliased\let\fenced\relax
+
+\newcount\c_math_fenced_nesting
+
+\protected\def\math_fenced_fenced_common
+ {\startusemathstyleparameter\mathfenceparameter
+ \enforced\let\fence\math_fenced_middle
+ \edef\p_math_fenced_color{\mathfenceparameter\c!color}%
+ \ifempty\p_math_fenced_color
+ \let\math_fenced_color_push\donothing
+ \let\math_fenced_color_pop \donothing
+ \else
+ \let\math_fenced_color_push\math_fenced_color_do_push
+ \let\math_fenced_color_pop \math_fenced_color_do_pop
+ \fi}
+
+\protected\def\math_fenced_fenced_start#1%
+ {\advance\c_math_fenced_nesting\plusone
+ \begingroup
+ \edef\currentmathfence{#1}%
+ \math_fenced_fenced_common
+ \math_fenced_left}
+
+\protected\def\math_fenced_fenced_stop#1%
+ {\edef\currentmathfence{#1}%
+ \math_fenced_right
+ \stopusemathstyleparameter
+ \endgroup
+ \advance\c_math_fenced_nesting\minusone}
+
+\tolerant\protected\def\math_fenced_fenced[#1]#*[#2]%
+ {\advance\c_math_fenced_nesting\plusone
+ \begingroup
+ \edef\currentmathfence{#1}%
+% under test:
+\c_attr_mathsize\attributeunsetvalue
+\letmathfenceparameter\c!size\empty
+\letmathfenceparameter\c!factor\v!auto
+% so far
+ \ifparameter#2\or\setupcurrentmathfence[#2]\fi
+ \math_fenced_fenced_common
+ \edef\p_size{\mathfenceparameter\c!size}%
+ \ifempty\p_size
+ \expandafter\math_fenced_fenced_indeed_adapt
+ \else
+ \expandafter\math_fenced_fenced_indeed_fixed
+ \fi}
+
+\protected\def\math_fenced_fenced_indeed_finish
+ {\stopusemathstyleparameter
+ \endgroup
+ \advance\c_math_fenced_nesting\minusone}
+
+\protected\def\math_fenced_fenced_indeed_fixed#1%
+ {\math_fenced_force_size\bigmathdelimitervariant\p_size
+ \settrue\c_math_fenced_sized
+ \math_fenced_left
+ \setfalse\c_math_fenced_sized
+ #1%
+ \settrue\c_math_fenced_sized
+ \math_fenced_right
+ \setfalse\c_math_fenced_sized
+ \math_fenced_fenced_indeed_finish}
+
+\protected\def\math_fenced_fenced_indeed_adapt#1%
+ {\setfalse\c_math_fenced_sized
+ \math_fenced_left
+ #1%
+ \setfalse\c_math_fenced_sized
+ \math_fenced_right
+ \math_fenced_fenced_indeed_finish}
+
+\appendtoks
+ \enforced\let\fenced\math_fenced_fenced
+\to \everymathematics
+
+% todo: | in mathmode letter
+%
+% \appendtoks
+% \let\bar\letterbar
+% \to \everymathematics
+%
+% but then we don't have it in embedded text too so ...
+
+\definemathfence [parenthesis] [\c!left="0028,\c!right="0029]
+\definemathfence [bracket] [\c!left="005B,\c!right="005D]
+\definemathfence [brace] [\c!left="007B,\c!right="007D]
+\definemathfence [bar] [\c!left="007C,\c!right="007C]
+\definemathfence [doublebar] [\c!left="2016,\c!right="2016]
+\definemathfence [triplebar] [\c!left="2980,\c!right="2980]
+\definemathfence [angle] [\c!left="27E8,\c!right="27E9]
+\definemathfence [doubleangle] [\c!left="27EA,\c!right="27EB]
+\definemathfence [solidus] [\c!left="2044,\c!right="2044]
+\definemathfence [ceiling] [\c!left="2308,\c!right="2309]
+\definemathfence [floor] [\c!left="230A,\c!right="230B]
+\definemathfence [moustache] [\c!left="23B0,\c!right="23B1]
+\definemathfence [uppercorner] [\c!left="231C,\c!right="231D]
+\definemathfence [lowercorner] [\c!left="231E,\c!right="231F]
+\definemathfence [group] [\c!left="27EE,\c!right="27EF]
+\definemathfence [openbracket] [\c!left="27E6,\c!right="27E7]
+
+\definemathfence [nothing]
+
+\definemathfence [mirrored] % \v!mirrored
+
+\definemathfence [mirroredparenthesis] [mirrored] [\c!right="0028,\c!left="0029]
+\definemathfence [mirroredbracket] [mirrored] [\c!right="005B,\c!left="005D]
+\definemathfence [mirroredbrace] [mirrored] [\c!right="007B,\c!left="007D]
+\definemathfence [mirroredbar] [mirrored] [\c!right="007C,\c!left="007C]
+\definemathfence [mirroreddoublebar] [mirrored] [\c!right="2016,\c!left="2016]
+\definemathfence [mirroredtriplebar] [mirrored] [\c!right="2980,\c!left="2980]
+\definemathfence [mirroredangle] [mirrored] [\c!right="27E8,\c!left="27E9]
+\definemathfence [mirroreddoubleangle] [mirrored] [\c!right="27EA,\c!left="27EB]
+\definemathfence [mirroredsolidus] [mirrored] [\c!right="2044,\c!left="2044]
+\definemathfence [mirroredceiling] [mirrored] [\c!right="2308,\c!left="2309]
+\definemathfence [mirroredfloor] [mirrored] [\c!right="230A,\c!left="230B]
+\definemathfence [mirroredmoustache] [mirrored] [\c!right="23B0,\c!left="23B1]
+\definemathfence [mirroreduppercorner] [mirrored] [\c!right="231C,\c!left="231D]
+\definemathfence [mirroredlowercorner] [mirrored] [\c!right="231E,\c!left="231F]
+\definemathfence [mirroredgroup] [mirrored] [\c!right="27EE,\c!left="27EF]
+\definemathfence [mirroredopenbracket] [mirrored] [\c!right="27E6,\c!left="27E7]
+
+\definemathfence [mirrorednothing] [mirrored]
+
+%D A bonus:
+
+\pushoverloadmode
+
+\immutable\protected\def\Lparenthesis {\math_fenced_fenced_start{parenthesis}} \immutable\protected\def\Rparenthesis {\math_fenced_fenced_stop {parenthesis}}
+\immutable\protected\def\Lbracket {\math_fenced_fenced_start{bracket}} \immutable\protected\def\Rbracket {\math_fenced_fenced_stop {bracket}}
+\immutable\protected\def\Lbrace {\math_fenced_fenced_start{brace}} \immutable\protected\def\Rbrace {\math_fenced_fenced_stop {brace}}
+\immutable\protected\def\Langle {\math_fenced_fenced_start{angle}} \immutable\protected\def\Rangle {\math_fenced_fenced_stop {angle}}
+\immutable\protected\def\Ldoubleangle {\math_fenced_fenced_start{doubleangle}} \immutable\protected\def\Rdoubleangle {\math_fenced_fenced_stop {doubleangle}}
+\immutable\protected\def\Lbar {\math_fenced_fenced_start{bar}} \immutable\protected\def\Rbar {\math_fenced_fenced_stop {bar}}
+\immutable\protected\def\Ldoublebar {\math_fenced_fenced_start{doublebar}} \immutable\protected\def\Rdoublebar {\math_fenced_fenced_stop {doublebar}}
+\immutable\protected\def\Ltriplebar {\math_fenced_fenced_start{triplebar}} \immutable\protected\def\Rtriplebar {\math_fenced_fenced_stop {triplebar}}
+\immutable\protected\def\Lsolidus {\math_fenced_fenced_start{solidus}} \immutable\protected\def\Rsolidus {\math_fenced_fenced_stop {solidus}}
+\immutable\protected\def\Lfloor {\math_fenced_fenced_start{floor}} \immutable\protected\def\Rfloor {\math_fenced_fenced_stop {floor}}
+\immutable\protected\def\Lceiling {\math_fenced_fenced_start{ceiling}} \immutable\protected\def\Rceiling {\math_fenced_fenced_stop {ceiling}}
+\immutable\protected\def\Lmoustache {\math_fenced_fenced_start{moustache}} \immutable\protected\def\Rmoustache {\math_fenced_fenced_stop {moustache}}
+\immutable\protected\def\Luppercorner {\math_fenced_fenced_start{uppercorner}} \immutable\protected\def\Ruppercorner {\math_fenced_fenced_stop {uppercorner}}
+\immutable\protected\def\Llowercorner {\math_fenced_fenced_start{lowercorner}} \immutable\protected\def\Rlowercorner {\math_fenced_fenced_stop {lowercorner}}
+\immutable\protected\def\Lgroup {\math_fenced_fenced_start{group}} \immutable\protected\def\Rgroup {\math_fenced_fenced_stop {group}}
+\immutable\protected\def\Lopenbracket {\math_fenced_fenced_start{openbracket}} \immutable\protected\def\Ropenbracket {\math_fenced_fenced_stop {openbracket}}
+\immutable\protected\def\Lnothing {\math_fenced_fenced_start{nothing}} \immutable\protected\def\Rnothing {\math_fenced_fenced_stop {nothing}}
+
+\immutable\protected\def\Lparenthesismirrored {\math_fenced_fenced_stop {mirroredparenthesis}} \immutable\protected\def\Rparenthesismirrored {\math_fenced_fenced_start{mirroredparenthesis}}
+\immutable\protected\def\Lbracketmirrored {\math_fenced_fenced_stop {mirroredbracket}} \immutable\protected\def\Rbracketmirrored {\math_fenced_fenced_start{mirroredbracket}}
+\immutable\protected\def\Lbracemirrored {\math_fenced_fenced_stop {mirroredbrace}} \immutable\protected\def\Rbracemirrored {\math_fenced_fenced_start{mirroredbrace}}
+\immutable\protected\def\Langlemirrored {\math_fenced_fenced_stop {mirroredangle}} \immutable\protected\def\Ranglemirrored {\math_fenced_fenced_start{mirroredangle}}
+\immutable\protected\def\Ldoubleanglemirrored {\math_fenced_fenced_stop {mirroreddoubleangle}} \immutable\protected\def\Rdoubleanglemirrored {\math_fenced_fenced_start{mirroreddoubleangle}}
+\immutable\protected\def\Lbarmirrored {\math_fenced_fenced_stop {mirroredbar}} \immutable\protected\def\Rbarmirrored {\math_fenced_fenced_start{mirroredbar}}
+\immutable\protected\def\Ldoublebarmirrored {\math_fenced_fenced_stop {mirroreddoublebar}} \immutable\protected\def\Rdoublebarmirrored {\math_fenced_fenced_start{mirroreddoublebar}}
+\immutable\protected\def\Ltriplebarmirrored {\math_fenced_fenced_stop {mirroredtriplebar}} \immutable\protected\def\Rtriplebarmirrored {\math_fenced_fenced_start{mirroredtriplebar}}
+\immutable\protected\def\Lsolidusmirrored {\math_fenced_fenced_stop {mirroredsolidus}} \immutable\protected\def\Rsolidusmirrored {\math_fenced_fenced_start{mirroredsolidus}}
+\immutable\protected\def\Lfloormirrored {\math_fenced_fenced_stop {mirroredfloor}} \immutable\protected\def\Rfloormirrored {\math_fenced_fenced_start{mirroredfloor}}
+\immutable\protected\def\Lceilingmirrored {\math_fenced_fenced_stop {mirroredceiling}} \immutable\protected\def\Rceilingmirrored {\math_fenced_fenced_start{mirroredceiling}}
+\immutable\protected\def\Lmoustachemirrored {\math_fenced_fenced_stop {mirroredmoustache}} \immutable\protected\def\Rmoustachemirrored {\math_fenced_fenced_start{mirroredmoustache}}
+\immutable\protected\def\Luppercornermirrored {\math_fenced_fenced_stop {mirroreduppercorner}} \immutable\protected\def\Ruppercornermirrored {\math_fenced_fenced_start{mirroreduppercorner}}
+\immutable\protected\def\Llowercornermirrored {\math_fenced_fenced_stop {mirroredlowercorner}} \immutable\protected\def\Rlowercornermirrored {\math_fenced_fenced_start{mirroredlowercorner}}
+\immutable\protected\def\Lgroupmirrored {\math_fenced_fenced_stop {mirroredgroup}} \immutable\protected\def\Rgroupmirrored {\math_fenced_fenced_start{mirroredgroup}}
+\immutable\protected\def\Lopenbracketmirrored {\math_fenced_fenced_stop {mirroredopenbracket}} \immutable\protected\def\Ropenbracketmirrored {\math_fenced_fenced_start{mirroredopenbracket}}
+\immutable\protected\def\Lnothingmirrored {\math_fenced_fenced_stop {mirrorednothing}} \immutable\protected\def\Rnothingmirrored {\math_fenced_fenced_start{mirrorednothing}}
+
+\definemathfence [interval] [\c!left="2997,\c!right="2998]
+\definemathfence [openinterval] [interval] [\c!left="2998,\c!right="2998]
+\definemathfence [leftopeninterval] [interval] [\c!left="2997,\c!right="2997]
+\definemathfence [rightopeninterval] [interval] [\c!left="2998,\c!right="2998]
+
+\immutable\protected\def\Linterval {\math_fenced_fenced_start{interval}}
+\immutable\protected\def\Lointerval {\math_fenced_fenced_start{openinterval}}
+\immutable\protected\def\Llointerval {\math_fenced_fenced_start{leftopeninterval}}
+\immutable\protected\def\Lrointerval {\math_fenced_fenced_start{rightopeninterval}}
+
+\immutable\protected\def\Rinterval {\math_fenced_fenced_stop {interval}}
+\immutable\protected\def\Rointerval {\math_fenced_fenced_stop {openinterval}}
+\immutable\protected\def\Rlointerval {\math_fenced_fenced_stop {leftopeninterval}}
+\immutable\protected\def\Rrointerval {\math_fenced_fenced_stop {rightopeninterval}}
+
+% \startformula
+% \left{ \frac{1}{a} \right}
+% \left[ \frac{1}{b} \right]
+% \left( \frac{1}{c} \right)
+% \left< \frac{1}{d} \right>
+% \left| \frac{1}{e} \right|
+% \stopformula
+
+\popoverloadmode
+
+\installcorenamespace{mathleft}
+\installcorenamespace{mathright}
+\installcorenamespace{mathmiddle}
+
+\pushoverloadmode
+
+\protected\def\left {\afterassignment\math_left \let\nexttoken}
+\protected\def\right {\afterassignment\math_right \let\nexttoken}
+\protected\def\middle{\afterassignment\math_middle\let\nexttoken}
+
+\popoverloadmode
+
+\let\leftorright\relax
+
+\newconditional\c_math_fenced_done
+\newconditional\c_math_fenced_unknown \settrue\c_math_fenced_unknown
+
+\permanent\protected\def\installmathfencepair#1#2#3#4%
+ {\letcsname\??mathleft \normalmeaning#1\endcsname#2%
+ \letcsname\??mathright\normalmeaning#3\endcsname#4}
+
+\def\math_unknown_left {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalleft \nexttoken\fi}
+\def\math_unknown_right {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalright \nexttoken\fi}
+\def\math_unknown_middle{\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalmiddle\nexttoken\fi}
+
+\letvalue{\??mathleft \s!unknown}\math_unknown_left
+\letvalue{\??mathright \s!unknown}\math_unknown_right
+\letvalue{\??mathmiddle\s!unknown}\math_unknown_middle
+
+\def\math_left
+ {\settrue\c_math_fenced_done
+ \ifcsname\??mathleft\normalmeaning\nexttoken\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\math_unknown_left
+ \fi}
+
+\def\math_right
+ {\settrue\c_math_fenced_done
+ \ifcsname\??mathright\normalmeaning\nexttoken\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\math_unknown_right
+ \fi}
+
+\def\math_middle
+ {\settrue\c_math_fenced_done
+ \ifcsname\??mathmiddle\normalmeaning\nexttoken\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\math_unknown_middle
+ \fi}
+
+\permanent\protected\def\lfence#1%
+ {\settrue\c_math_fenced_done
+ \let\nexttoken#1%
+ \ifcsname\??mathleft\normalmeaning\nexttoken\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\math_unknown_left
+ \fi}
+
+\permanent\protected\def\rfence#1%
+ {\settrue\c_math_fenced_done
+ \let\nexttoken#1%
+ \ifcsname\??mathright\normalmeaning\nexttoken\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\math_unknown_right
+ \fi}
+
+\permanent\protected\def\mfence#1%
+ {\settrue\c_math_fenced_done
+ \let\nexttoken#1%
+ \ifcsname\??mathmiddle\normalmeaning\nexttoken\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\math_unknown_middle
+ \fi}
+
+\normalexpanded{\installmathfencepair {|\detokenize {|}} \Ldoublebar {|\detokenize {|}} \Rdoublebar}
+\normalexpanded{\installmathfencepair {|\detokenize{||}} \Ltriplebar {|\detokenize{||}} \Rtriplebar}
+
+\installmathfencepair \bgroup \Lbrace \egroup \Rbrace
+\installmathfencepair \egroup \Rbracemirrored \bgroup \Lbracemirrored
+
+\installmathfencepair \letteropenbrace \Lbrace \letterclosebrace \Rbrace % as we escape in mp textexts
+
+\installmathfencepair . \Lnothing . \Rnothing
+\installmathfencepair . \Rnothingmirrored . \Lnothingmirrored
+
+\installmathfencepair [ \Lbracket ] \Rbracket
+\installmathfencepair ] \Rbracketmirrored [ \Lbracketmirrored
+
+\installmathfencepair ( \Lparenthesis ) \Rparenthesis
+\installmathfencepair ) \Rparenthesismirrored ( \Lparenthesismirrored
+
+\installmathfencepair < \Langle > \Rangle
+\installmathfencepair > \Ranglemirrored < \Langlemirrored
+
+\installmathfencepair / \Lsolidus / \Rsolidus
+%installmathfencepair / \Rsolidusmirrored / \Lsolidusmirrored
+
+\installmathfencepair | \Lbar | \Rbar
+%installmathfencepair | \Rbarmirrored | \Lbarmirrored
+
+\installmathfencepair ⌊ \Lfloor ⌋ \Rfloor
+\installmathfencepair ⌋ \Rfloormirrored ⌊ \Lfloormirrored
+\installmathfencepair ⌈ \Lceiling ⌉ \Rceiling
+\installmathfencepair ⌉ \Rceilingmirrored ⌈ \Lceilingmirrored
+
+\installmathfencepair ⟨ \Langle ⟩ \Rangle
+\installmathfencepair ⟩ \Ranglemirrored ⟨ \Langlemirrored
+
+\installmathfencepair ⟪ \Ldoubleangle ⟫ \Rdoubleangle
+\installmathfencepair ⟫ \Rdoubleanglemirrored ⟪ \Ldoubleanglemirrored
+
+\installmathfencepair ‖ \Ldoublebar ‖ \Rdoublebar
+%installmathfencepair ‖ \Rdoublebarmirrored ‖ \Ldoublebarmirrored
+
+\installmathfencepair ⦀ \Ltriplebar ⦀ \Rtriplebar
+%installmathfencepair ⦀ \Rtriplebarmirrored ⦀ \Ltriplebarmirrored
+
+% \installmathfencepair { \Lbrace } \Rbrace
+% \installmathfencepair } \Rbracemirrored { \Lbracemirrored
+
+\installmathfencepair ⦗ \Linterval ⦘ \Rinterval
+
+\appendtoks
+ \ignorediscretionaries % so $\mtext{a|b}$ works, this is ok because it's an \hbox
+\to \everymathematics
+
+% We unofficial support some synonyms as we need them for some fuzzy web related math.
+
+% The names in char-def.lua (historic mess):
+
+\pushoverloadmode
+
+\aliased\let\lbrack \lbracket
+\aliased\let\rbrack \rbracket
+\aliased\let\lceiling \lceil
+\aliased\let\rceiling \rceil
+\aliased\let\lparenthesis\lparent
+\aliased\let\rparenthesis\rparent
+\aliased\let\lparen \lparent
+\aliased\let\rparen \rparent
+
+% Just defined:
+
+\aliased\let\Lceil \Lceiling
+\aliased\let\Rceil \Rceiling
+\aliased\let\Lparent\Lparenthesis
+\aliased\let\Rparent\Rparenthesis
+\aliased\let\Lparen \Lparenthesis
+\aliased\let\Rparen \Rparenthesis
+
+\installmathfencepair \lbrace \Lbrace \rbrace \Rbrace
+\installmathfencepair \lbracket \Lbracket \rbracket \Rbracket
+\installmathfencepair \lbrack \Lbracket \rbracket \Rbracket
+\installmathfencepair \lparenthesis \Lparenthesis \rparenthesis \Rparenthesis
+\installmathfencepair \lparent \Lparenthesis \rparent \Rparenthesis
+\installmathfencepair \lparen \Lparenthesis \rparen \Rparenthesis
+\installmathfencepair \langle \Langle \rangle \Rangle
+\installmathfencepair \llangle \Ldoubleangle \rrangle \Rdoubleangle
+%installmathfencepair \lbar \Lbar \rbar \Rbar
+\installmathfencepair \lVert \Ldoublebar \rVert \Rdoublebar
+\installmathfencepair \vert \Lbar \vert \Rbar
+\installmathfencepair \solidus \Lsolidus \solidus \Rsolidus
+\installmathfencepair \lfloor \Lfloor \rfloor \Rfloor
+\installmathfencepair \lceiling \Lceiling \rceiling \Rceiling
+\installmathfencepair \lceil \Lceiling \rceil \Rceiling
+
+\installmathfencepair \ulcorner \Luppercorner \urcorner \Ruppercorner
+\installmathfencepair \llcorner \Llowercorner \lrcorner \Rlowercorner
+\installmathfencepair \lmoustache \Lmoustache \rmoustache \Rmoustache
+\installmathfencepair \llbracket \Lopenbracket \rrbracket \Ropenbracket
+\installmathfencepair \lgroup \Lgroup \rgroup \Rgroup
+
+\installmathfencepair \linterval \Linterval \rinterval \Rinterval
+%installmathfencepair \linterv \Linterval \rinterv \Rinterval
+\installmathfencepair \lointerval \Linterval \rointerval \Rinterval
+\installmathfencepair \llointerval \Llointerval \rlointerval \Rlointerval
+\installmathfencepair \lrointerval \Lrointerval \rrointerval \Rrointerval
+
+\aliased\let\textlbar\lbar \aliased\let\mathlbar\Lbar
+\aliased\let\textrbar\lbar \aliased\let\mathrbar\Rbar
+
+\immutable\protected\def\lbar{\mathortext\mathlbar\textlbar}
+\immutable\protected\def\rbar{\mathortext\mathrbar\textrbar}
+
+% \setupmathfences[color=darkgreen]
+
+\permanent\protected\def\{{\mathortext\lbrace \letterleftbrace } % or maybe a chardef
+\permanent\protected\def\}{\mathortext\rbrace \letterrightbrace } % or maybe a chardef
+\permanent\protected\def\[{\mathortext\lbracket \letterleftbracket } % or maybe a chardef
+\permanent\protected\def\]{\mathortext\rbracket \letterrightbracket } % or maybe a chardef
+\permanent\protected\def\({\mathortext\lparenthesis\letterleftparenthesis } % or maybe a chardef
+\permanent\protected\def\){\mathortext\rparenthesis\letterrightparenthesis} % or maybe a chardef
+\permanent\protected\def\|{\mathortext\vert \letterbar } % or maybe a chardef
+%permanent\protected\def\/{\mathortext\solidus \letterslash } % or maybe a chardef
+
+\installmathfencepair \{ \Lbrace \} \Rbrace
+\installmathfencepair \[ \Lbracket \] \Rbracket
+\installmathfencepair \( \Lparenthesis \) \Rparenthesis
+\installmathfencepair \< \Langle \> \Rangle
+\installmathfencepair \| \Lbar \| \Rbar
+
+\popoverloadmode
+
+%D As we have overloaded \type {\left} and \type {\right} we also need a more
+%D clever version of the following:
+
+% methods:
+%
+% 1: none
+% 2: lua
+% 3: tex
+
+% variants:
+%
+% 1: step 1
+% 2: step 2
+% 3: htdp * 1.33^n
+% 4: size * 1.33^n
+
+\setnewconstant\bigmathdelimitermethod \plustwo % \plusone
+\setnewconstant\bigmathdelimitervariant\plusthree
+
+\appendtoks
+ \bigmathdelimitermethod \mathfenceparameter\c!method\relax
+ \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax
+\to \everysetupmathfence
+
+\setupmathfence[\c!method=1,\c!alternative=2]
+
+% \protected\def\plainbigdelimiters % traditional method
+% {\bigmathdelimitermethod\plustwo}
+%
+% \plainbigdelimiters % is default for the moment but not so nice
+
+\installcorenamespace{mathbig}
+
+\setvalue{\??mathbig1}{0.85}
+\setvalue{\??mathbig2}{1.15}
+\setvalue{\??mathbig3}{1.45}
+\setvalue{\??mathbig4}{1.75}
+
+\permanent\protected\def\choosemathbig#1#2% so we accept \big{||} as well
+ {{\naturalhbox\bgroup
+ \startimath
+ \ifcase\bigmathdelimitermethod
+ \math_fenced_step#2\relax
+ \or
+ \math_fenced_force_size\bigmathdelimitervariant{#1}\relax
+ \math_fenced_step#2\relax
+ \else
+ \math_fenced_step#2{\vpack to\csname\??mathbig#1\endcsname\bodyfontsize{}}%
+ \fi
+ \nulldelimiterspace\zeropoint\relax
+ \mathsurround\zeropoint
+ \stopimath
+ \egroup}}
+
+% needs testing:
+%
+% \protected\def\choosemathbig#1#2% so we accept \big{||} as well
+% {{\naturalhbox\bgroup
+% \startimath
+% \ifcase\bigmathdelimitermethod
+% \Uvextensible#2\relax
+% \or
+% \math_fenced_force_size\bigmathdelimitervariant{#1}\relax
+% \Uvextensible#2\relax
+% \else
+% \scratchdimen.5\dimexpr\csname\??mathbig\number#1\endcsname\bodyfontsize+1.1\exheight\relax
+% \Uvextensible\s!axis \s!depth \scratchdimen \s!height \scratchdimen #2\relax
+% \fi
+% \nulldelimiterspace\zeropoint\relax
+% \mathsurround\zeropoint
+% \stopimath
+% \egroup}}
+
+\def\math_fenced_step#1#2%
+ {\setfalse\c_math_fenced_unknown
+ \setfalse\c_math_fenced_done
+ \left#1\relax
+ \ifconditional\c_math_fenced_done
+ #2%
+ \right.\relax
+ \else
+ \left.\relax
+ #2%
+ \setfalse\c_math_fenced_done
+ \right#1\relax
+ \ifconditional\c_math_fenced_done
+ \else
+ \right.\relax
+ \fi
+ \fi}
+
+\permanent\protected\def\mathdelimiterstep#1#2%
+ {\begingroup
+ \math_fenced_force_size\plusone{#1}%
+ \math_fenced_step#2\relax
+ \endgroup}
+
+\definemathcommand [big] {\choosemathbig1}
+\definemathcommand [Big] {\choosemathbig2}
+\definemathcommand [bigg] {\choosemathbig3}
+\definemathcommand [Bigg] {\choosemathbig4}
+
+\definemathcommand [bigl] [open] [one] {\big}
+\definemathcommand [bigm] [rel] [one] {\big}
+\definemathcommand [bigr] [close] [one] {\big}
+\definemathcommand [Bigl] [open] [one] {\Big}
+\definemathcommand [Bigm] [rel] [one] {\Big}
+\definemathcommand [Bigr] [close] [one] {\Big}
+\definemathcommand [biggl] [open] [one] {\bigg}
+\definemathcommand [biggm] [rel] [one] {\bigg}
+\definemathcommand [biggr] [close] [one] {\bigg}
+\definemathcommand [Biggl] [open] [one] {\Bigg}
+\definemathcommand [Biggm] [rel] [one] {\Bigg}
+\definemathcommand [Biggr] [close] [one] {\Bigg}
+
+% \definemathfence [integral] [\c!left="222B]
+%
+% \protected\def\Lintegral {\math_fenced_fenced_start{integral}}
+% \protected\def\Rintegral {\math_fenced_fenced_stop {integral}}
+%
+% \installmathfencepair \lintegral \Lintegral \rintegral \Rintegral
+%
+% \left\lintegral
+% \vrule height 3cm depth 3cm
+% \right\rintegral
+
+%definemathfence [fancybracket] [bracket] [command=yes,color=red]
+
+% experimental accents:
+%
+% \definemathoverextensible [top] [hoed] ["FE302]
+% \definemathoverextensible [top] [slang] ["FE303]
+
+%D The nested fences recovery code is needed for mathml and the original
+%D code can still be found in the mkiv file.
+
+\definesystemattribute[mathautofence][public]
+
+\let\math_fences_normal_left \left
+\let\math_fences_normal_right \right
+\let\math_fences_normal_middle\middle
+\let\math_fences_normal_both \leftorright
+
+\protected\def\math_fences_auto_left #1{\c_attr_mathautofence\plusone #1\c_attr_mathautofence\attributeunsetvalue}
+\protected\def\math_fences_auto_right #1{\c_attr_mathautofence\plustwo #1\c_attr_mathautofence\attributeunsetvalue}
+\protected\def\math_fences_auto_middle#1{\c_attr_mathautofence\plusthree#1\c_attr_mathautofence\attributeunsetvalue}
+\protected\def\math_fences_auto_both #1{\c_attr_mathautofence\plusfour #1\c_attr_mathautofence\attributeunsetvalue}
+
+\permanent\let\autofenceopen \math_fences_auto_left % for testing
+\permanent\let\autofenceclose \math_fences_auto_right % for testing
+\permanent\let\autofenceleft \math_fences_auto_left % for testing
+\permanent\let\autofenceright \math_fences_auto_right % for testing
+\permanent\let\autofencemiddle\math_fences_auto_middle % for testing
+\permanent\let\autofenceboth \math_fences_auto_both % for testing
+
+% fences are used not that often (i.e. no performance issue) so we can use a state
+% instead of \let ... also some state variable can come in handy in the future
+
+\newconditional\c_math_fences_auto
+
+\permanent\protected\def\enableautofences
+ {\clf_enableautofences
+ \glet\clf_enableautofences\relax % onlyonce anyway
+ \enforced\permanent\protected\gdef\enableautofences{\settrue\c_math_fences_auto}%
+ \enableautofences}
+
+\permanent\protected\def\disableautofences
+ {\setfalse\c_math_fences_auto}
+
+\protected\def\math_fences_used_left
+ {\ifconditional\c_math_fences_auto
+ \expandafter\math_fences_auto_left
+ \else
+ \expandafter\math_fences_normal_left
+ \fi}
+
+\protected\def\math_fences_used_right
+ {\ifconditional\c_math_fences_auto
+ \expandafter\math_fences_auto_right
+ \else
+ \expandafter\math_fences_normal_right
+ \fi}
+
+\protected\def\math_fences_used_middle
+ {\ifconditional\c_math_fences_auto
+ \expandafter\math_fences_auto_middle
+ \else
+ \expandafter\math_fences_normal_middle
+ \fi}
+
+\protected\def\math_fences_used_both
+ {\ifconditional\c_math_fences_auto
+ \expandafter\math_fences_auto_both
+ \else
+ \expandafter\math_fences_normal_both
+ \fi}
+
+\permanent\let\left \math_fences_used_left
+\permanent\let\right \math_fences_used_right
+\permanent\let\middle \math_fences_used_middle
+\permanent\let\leftorright\math_fences_used_both
+
+% wrappers
+
+\permanent\protected\def\startcheckedfences
+ {\begingroup
+ \enableautofences}
+
+\permanent\protected\def\stopcheckedfences
+ {\endgroup}
+
+% \appendtoks
+ % maybe: safeguard against overloading
+ %
+ % \let\left \math_fences_used_left
+ % \let\right \math_fences_used_right
+ % \let\middle \math_fences_used_middle
+ % \let\leftorright\math_fences_used_both
+% \to \everymathematics
+
+\appendtoks
+ \ifempty\currentmathfence
+ \doifelse{\mathfenceparameter\c!state}\v!auto\enableautofences\disableautofences
+ \fi
+\to \everysetupmathfence
+
+\newconstant\c_math_fences_delimiters_mode \c_math_fences_delimiters_mode"16 % \numexpr"02+"04+"10\relax
+
+%permanent\protected\def\enableautofencemode {\mathdelimitersmode\plussix} % the shift (1) is too fragile
+\permanent\protected\def\enableautofencemode {\mathdelimitersmode\c_math_fences_delimiters_mode}
+\permanent\protected\def\disableautofencemode{\mathdelimitersmode\zerocount}
+
+\appendtoks
+ \ifempty\currentmathfence
+ \doifelse{\mathfenceparameter\c!method}\v!auto\enableautofencemode\disableautofencemode
+ \fi
+\to \everysetupmathfence
+
+% some day default: \setupmathfences[\c!state=\v!auto]
+
+%D The next characters were used for constructing nicer extensibles but
+%D nowadays we have real characters.
+
+\immutable\Umathchardef\braceld\zerocount \defaultmathfamily "FF07A
+\immutable\Umathchardef\bracerd\zerocount \defaultmathfamily "FF07B
+\immutable\Umathchardef\bracelu\zerocount \defaultmathfamily "FF07C
+\immutable\Umathchardef\braceru\zerocount \defaultmathfamily "FF07D
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-for.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-for.mkxl
new file mode 100644
index 00000000000..e6ea402de99
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-for.mkxl
@@ -0,0 +1,47 @@
+%D \module
+%D [ file=strc-mat,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=Math Numbering,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / Math Formulas}
+
+%D This module only provides the code for defining formulas and
+%D fetching parameters. The action takes place later.
+
+\unprotect
+
+%D \macros
+%D {setupformulas,setupsubformulas,setupformulaframed}
+
+\installcorenamespace{formula}
+\installcorenamespace{subformula}
+\installcorenamespace{formulaframed}
+\installcorenamespace{formulaoption}
+
+\installcommandhandler \??formula {formula} \??formula
+\installcommandhandler \??subformula {subformula} \??subformula % maybe just setuphandler (no childs used yet)
+\installframedcommandhandler \??formulaframed {formulaframed} \??formulaframed
+
+\aliased\let\setupformulas \setupformula
+\aliased\let\setupsubformulas\setupsubformula
+
+\appendtoks
+ \normalexpanded{\defineformulaframed[\currentformula][\currentformulaparent]}%
+\to \everydefineformula
+
+\def\strc_formulas_option#1%
+ {\ifcsname\??formulaoption#1\endcsname
+ \lastnamedcs
+ \else
+ \font_basics_switchtobodyfont{#1}% for old time sake, might go away, only pt so maybe dimension and small test
+ \fi}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-frc.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-frc.mkxl
new file mode 100644
index 00000000000..8295195b5d6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-frc.mkxl
@@ -0,0 +1,833 @@
+%D \module
+%D [ file=math-frc,
+%D version=2013.04.06, % 2007.07.19,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Fractions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Fractions}
+
+\unprotect
+
+%D I need to check it all again as there was a bug in luatex with dimensions that could
+%D resulted in side effects that made me mess with spacing.
+
+\permanent\protected\def\topstrut{\vrule\s!width\zeropoint\s!height\strutht\s!depth\zeropoint\relax}
+\permanent\protected\def\botstrut{\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\strutdp\relax}
+
+\permanent\protected\def\mathtopstrut{\setbox\scratchbox\mathstylehbox{(}\vrule\s!width\zeropoint\s!height\ht\scratchbox\s!depth\zeropoint\relax}
+\permanent\protected\def\mathbotstrut{\setbox\scratchbox\mathstylehbox{(}\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\dp\scratchbox\relax}
+
+%D This module is reimplemented in \MKIV\ style.
+
+\registerctxluafile{math-frc}{}
+
+%D \macros
+%D {frac, xfrac, xxfrac}
+%D
+%D This is another one Tobias asked for. It replaces the primitive \type
+%D {\over}. We also take the opportunity to handle math style restoring,
+%D which makes sure units and chemicals come out ok. The \type {\frac}
+%D macro kind of replaces the awkward \type {\over} primitive. Say that
+%D we have the following formulas:
+%D
+%D \startbuffer[sample]
+%D test $\frac {1}{2}$ test $$1 + \frac {1}{2} = 1.5$$
+%D test $\xfrac {1}{2}$ test $$1 + \xfrac {1}{2} = 1.5$$
+%D test $\xxfrac{1}{2}$ test $$1 + \xxfrac{1}{2} = 1.5$$
+%D \stopbuffer
+%D
+%D \typebuffer[sample]
+%D
+%D With the most straightforward definitions, we get:
+%D
+%D \startbuffer[code]
+%D \def\dofrac#1#2#3{\relax\mathematics{{{#1{#2}}\over{#1{#3}}}}}
+%D
+%D \def\frac {\dofrac\mathstyle}
+%D \def\xfrac {\dofrac\scriptstyle}
+%D \def\xxfrac{\dofrac\scriptscriptstyle}
+%D \stopbuffer
+%D
+%D \typebuffer[code] \getbuffer[code,sample]
+%D
+%D Since this does not work well, we can try:
+%D
+%D \startbuffer[code]
+%D \def\xfrac #1#2{\hbox{$\dofrac\scriptstyle {#1}{#2}$}}
+%D \def\xxfrac#1#2{\hbox{$\dofrac\scriptscriptstyle{#1}{#2}$}}
+%D \stopbuffer
+%D
+%D \typebuffer[code] \getbuffer[code,sample]
+%D
+%D This for sure looks better than:
+%D
+%D \startbuffer[code]
+%D \def\xfrac #1#2{{\scriptstyle \dofrac\relax{#1}{#2}}}
+%D \def\xxfrac#1#2{{\scriptscriptstyle\dofrac\relax{#1}{#2}}}
+%D \stopbuffer
+%D
+%D \typebuffer[code] \getbuffer[code,sample]
+%D
+%D So we stick to the next definitions (watch the local overloading of
+%D \type {\xfrac}).
+%D
+%D In the meantime, in \LUATEX, we have better control over styles so the
+%D following macros are different from the \MKII\ ones.
+
+% obsolete, is now c!mathstyle
+%
+% 0=auto, 1=displaystyle, 2=textstyle, 3=scriptstyle, 4=scriptscriptstyle, 5=mathstyle
+%
+% $\mathfracmode0 \frac{1}{2}$
+% $\mathfracmode1 \frac{1}{2}$
+% $\mathfracmode2 \frac{1}{2}$
+% $\mathfracmode3 \frac{1}{2}$
+% $\mathfracmode4 \frac{1}{2}$
+% $\mathfracmode5 \frac{1}{2}$
+%
+% we keep the constant for a while
+
+\setnewconstant\mathfracmode\zerocount
+
+\installcorenamespace{mathfractions}
+\installcorenamespace{mathfractionstyle}
+\installcorenamespace{mathfractionalternative}
+
+\installcommandhandler \??mathfractions {mathfraction} \??mathfractions
+
+\aliased\let\setupmathfractions\setupmathfraction
+
+% color only applies to rule, use regular color for rest
+
+\setupmathfractions
+ [\c!mathstyle=,
+ \c!alternative=\v!inner,
+ \c!margin=\zeropoint,
+ \c!rulethickness=.25\exheight,
+ \c!left=0x2E,
+ \c!right=0x2E,
+ \c!strut=\v!yes,
+ \c!topdistance=,
+ \c!bottomdistance=,
+ \c!rule=\v!auto]
+
+\appendtoks
+ \instance\frozen\protected\edefcsname\currentmathfraction\endcsname{\math_frac{\currentmathfraction}}%
+\to \everydefinemathfraction
+
+% Sometimes users want control over the distances:
+
+\let\math_fraction_set_distance\relax
+
+\appendtoks
+ \math_fraction_set_distance
+\to \everymathematics
+
+% why only displaystyle .. a bit weak
+
+\protected\def\math_fraction_set_distance_top
+ {\Umathfractionnumup \displaystyle\m_math_fraction_distance_top
+ \relax}
+
+\protected\def\math_fraction_set_distance_bot
+ {\Umathfractiondenomdown\displaystyle\m_math_fraction_distance_bot
+ \relax}
+
+\protected\def\math_fraction_set_distance_all
+ {\Umathfractionnumup \displaystyle\m_math_fraction_distance_top
+ \Umathfractiondenomdown\displaystyle\m_math_fraction_distance_bot
+ \relax}
+
+\appendtoks
+ \ifempty\currentmathfraction
+ \edef\m_math_fraction_distance_top{\mathfractionparameter\c!topdistance}%
+ \edef\m_math_fraction_distance_bot{\mathfractionparameter\c!bottomdistance}%
+ \ifempty\m_math_fraction_distance_top
+ \ifempty\m_math_fraction_distance_bot
+ \let\math_fraction_set_distance\relax
+ \else
+ \let\math_fraction_set_distance\math_fraction_set_distance_bot
+ \fi
+ \else
+ \ifempty\m_math_fraction_distance_bot
+ \let\math_fraction_set_distance\math_fraction_set_distance_top
+ \else
+ \let\math_fraction_set_distance\math_fraction_set_distance_all
+ \fi
+ \fi
+ \fi
+\to \everysetupmathfraction
+
+% So far for control.
+
+\installcorenamespace{mathfractionstrut}
+
+\def\math_frac_no_strut
+ {\enforced\let\m_fractions_strut_top\relax
+ \enforced\let\m_fractions_strut_bot\relax}
+
+\setvalue{\??mathfractionstrut\v!yes}%
+ {\enforced\let\m_fractions_strut_top\mathstrut
+ \enforced\let\m_fractions_strut_bot\mathstrut}
+
+\setvalue{\??mathfractionstrut\v!math}%
+ {\enforced\let\m_fractions_strut_top\mathstrut
+ \enforced\let\m_fractions_strut_bot\mathstrut}
+
+\letvalue{\??mathfractionstrut\v!no}\math_frac_no_strut
+
+\setvalue{\??mathfractionstrut\v!tight}%
+ {\enforced\let\m_fractions_strut_top\mathbotstrut % indeed swapped name
+ \enforced\let\m_fractions_strut_bot\mathtopstrut} % indeed swapped name
+
+\math_frac_no_strut
+
+\newdimen\d_math_fraction_margin
+
+\protected\def\math_frac#1%
+ {\begingroup
+ \edef\currentmathfraction{#1}%
+ %
+ \edef\p_math_fraction_fences{\mathfractionparameter\c!fences}%
+ \ifempty\p_math_fraction_fences \else
+ \math_fenced_fenced_start\p_math_fraction_fences
+ \fi
+ %
+ \d_math_fraction_margin\mathfractionparameter\c!margin
+ %
+ \edef\p_math_fractions_color{\mathfractionparameter\c!color}%
+ %
+ \edef\p_math_fractions_strut{\mathfractionparameter\c!strut}%
+ \ifcsname\??mathfractionstrut\p_math_fractions_strut\endcsname
+ \lastnamedcs
+ \else
+ \math_frac_no_strut
+ \fi
+ %
+ \ifempty\p_math_fractions_color
+ \expandafter\math_frac_normal
+ \else
+ \expandafter\math_frac_colored
+ \fi}
+
+\protected\def\math_frac_wrapup
+ {\ifempty\p_math_fraction_fences \else
+ \math_fenced_fenced_stop\p_math_fraction_fences
+ \fi
+ \endgroup}
+
+\protected\def\math_frac_colored#1#2%
+ {\savecolor
+ \colo_helpers_activate\p_math_fractions_color
+ \math_frac_normal{\restorecolor#1}{\restorecolor#2}}
+
+\protected\def\math_frac_normal
+ {\expandnamespaceparameter\??mathfractionalternative\mathfractionparameter\c!alternative\v!inner}
+
+% we use utfchar anyway so we can as well do all at the lua end
+
+\def\math_frac_no_delim{0x2E}
+
+\def\math_frac_command
+ {\clf_mathfraction
+ {\mathfractionparameter\c!rule}%
+ \ifempty\p_math_fraction_fences
+ \mathfractionparameter\c!left \space
+ \mathfractionparameter\c!right\space
+ \else
+ \math_frac_no_delim\space
+ \math_frac_no_delim\space
+ \fi
+ \dimexpr\mathfractionparameter\c!rulethickness\relax
+ \relax}
+
+% Having a \withmarginornot{#1}{#2} makes not much sense nor do 4 tests or 4 redundant
+% kerns (longer node lists plus possible interference). A split in normal and margin
+% also makes testing easier. When left and right margins are needed we might merge the
+% variants again. After all, these are not real installers.
+
+% the denominator is in cramped!
+
+\setvalue{\??mathfractionalternative\v!inner}%
+ {\ifcase\d_math_fraction_margin
+ \expandafter\math_fraction_inner_normal
+ \else
+ \expandafter\math_fraction_inner_margin
+ \fi}
+
+\setvalue{\??mathfractionalternative\v!outer}%
+ {\ifcase\d_math_fraction_margin
+ \expandafter\math_fraction_outer_normal
+ \else
+ \expandafter\math_fraction_outer_margin
+ \fi}
+
+\setvalue{\??mathfractionalternative\v!both}%
+ {\ifcase\d_math_fraction_margin
+ \expandafter\math_fraction_both_normal
+ \else
+ \expandafter\math_fraction_both_margin
+ \fi}
+
+% todo: store first state and reuse second time
+
+% \def\math_fraction_inner_normal#1#2%
+% {\Ustack{%
+% {%
+% {\usemathstyleparameter\mathfractionparameter{\m_fractions_strut_top#1}}%
+% \math_frac_command
+% {\usemathstyleparameter\mathfractionparameter{\m_fractions_strut_bot#2}}%
+% }%
+% }%
+% \math_frac_wrapup}
+%
+% \def\math_fraction_outer_normal#1#2%
+% {\Ustack{%
+% \usemathstyleparameter\mathfractionparameter
+% {%
+% {\m_fractions_strut_top#1}%
+% \math_frac_command
+% {\m_fractions_strut_bot#2}%
+% }%
+% }%
+% \math_frac_wrapup}
+%
+% \def\math_fraction_both_normal#1#2%
+% {\Ustack{%
+% \usemathstyleparameter\mathfractionparameter
+% {%
+% {\usemathstyleparameter\mathfractionparameter\m_fractions_strut_top#1}%
+% \math_frac_command
+% {\usemathstyleparameter\mathfractionparameter\m_fractions_strut_bot#2}%
+% }%
+% }%
+% \math_frac_wrapup}
+%
+% \def\math_fraction_inner_margin#1#2%
+% {\Ustack{%
+% {%
+% {\kern\d_math_fraction_margin
+% \usemathstyleparameter\mathfractionparameter{\m_fractions_strut_top#1}%
+% \kern\d_math_fraction_margin}%
+% \math_frac_command
+% {\kern\d_math_fraction_margin
+% \usemathstyleparameter\mathfractionparameter{\m_fractions_strut_bot#2}%
+% \kern\d_math_fraction_margin}%
+% }%
+% }%
+% \math_frac_wrapup}
+%
+% \def\math_fraction_outer_margin#1#2%
+% {\Ustack{%
+% \usemathstyleparameter\mathfractionparameter
+% {%
+% {\kern\d_math_fraction_margin
+% \m_fractions_strut_top#1%
+% \kern\d_math_fraction_margin}%
+% \math_frac_command
+% {\kern\d_math_fraction_margin
+% \m_fractions_strut_bot#2%
+% \kern\d_math_fraction_margin}%
+% }%
+% }%
+% \math_frac_wrapup}
+%
+% \def\math_fraction_both_margin#1#2%
+% {\Ustack{%
+% \usemathstyleparameter\mathfractionparameter
+% {%
+% {\kern\d_math_fraction_margin
+% \usemathstyleparameter\mathfractionparameter\m_fractions_strut_top#1%
+% \kern\d_math_fraction_margin}%
+% \math_frac_command
+% {\kern\d_math_fraction_margin
+% \usemathstyleparameter\mathfractionparameter\m_fractions_strut_bot#2%
+% \kern\d_math_fraction_margin}%
+% }%
+% }%
+% \math_frac_wrapup}
+
+\def\math_frac_command_u
+ {\clf_umathfraction
+ {\mathfractionparameter\c!rule}%
+ \ifempty\p_math_fraction_fences
+ \mathfractionparameter\c!left \space
+ \mathfractionparameter\c!right\space
+ \else
+ \math_frac_no_delim\space
+ \math_frac_no_delim\space
+ \fi
+ \dimexpr\mathfractionparameter\c!rulethickness\relax
+ \relax}
+
+\def\math_fraction_inner_normal#1#2%
+ {\Ustack{% forces num style
+ \math_frac_command_u
+ {\usemathstyleparameter\mathfractionparameter{\m_fractions_strut_top#1}}%
+ {\usemathstyleparameter\mathfractionparameter{\m_fractions_strut_bot#2}}%
+ }%
+ \math_frac_wrapup}
+
+\def\math_fraction_outer_normal#1#2%
+ {\Ustack{% forces num style
+ \usemathstyleparameter\mathfractionparameter
+ \math_frac_command_u
+ {\m_fractions_strut_top#1}%
+ {\m_fractions_strut_bot#2}%
+ }%
+ \math_frac_wrapup}
+
+\def\math_fraction_both_normal#1#2%
+ {\Ustack{% forces num style
+ \usemathstyleparameter\mathfractionparameter
+ \math_frac_command_u
+ {\usemathstyleparameter\mathfractionparameter\m_fractions_strut_top#1}%
+ {\usemathstyleparameter\mathfractionparameter\m_fractions_strut_bot#2}%
+ }%
+ \math_frac_wrapup}
+
+\def\math_fraction_inner_margin#1#2%
+ {\Ustack{%
+ {%
+ \math_frac_command_u
+ {\kern\d_math_fraction_margin
+ \usemathstyleparameter\mathfractionparameter{\m_fractions_strut_top#1}%
+ \kern\d_math_fraction_margin}%
+ {\kern\d_math_fraction_margin
+ \usemathstyleparameter\mathfractionparameter{\m_fractions_strut_bot#2}%
+ \kern\d_math_fraction_margin}%
+ }%
+ }%
+ \math_frac_wrapup}
+
+\def\math_fraction_outer_margin#1#2%
+ {\Ustack{%
+ \usemathstyleparameter\mathfractionparameter
+ {%
+ \math_frac_command_u
+ {\kern\d_math_fraction_margin
+ \m_fractions_strut_top#1%
+ \kern\d_math_fraction_margin}%
+ {\kern\d_math_fraction_margin
+ \m_fractions_strut_bot#2%
+ \kern\d_math_fraction_margin}%
+ }%
+ }%
+ \math_frac_wrapup}
+
+\def\math_fraction_both_margin#1#2%
+ {\Ustack{%
+ \usemathstyleparameter\mathfractionparameter
+ {%
+ \math_frac_command_u
+ {\kern\d_math_fraction_margin
+ \usemathstyleparameter\mathfractionparameter\m_fractions_strut_top#1%
+ \kern\d_math_fraction_margin}%
+ {\kern\d_math_fraction_margin
+ \usemathstyleparameter\mathfractionparameter\m_fractions_strut_bot#2%
+ \kern\d_math_fraction_margin}%
+ }%
+ }%
+ \math_frac_wrapup}
+
+\definemathfraction[xfrac] [\c!alternative=\v!inner,\c!mathstyle=\s!script]
+\definemathfraction[xxfrac][\c!alternative=\v!inner,\c!mathstyle=\s!scriptscript]
+
+\aliased\let\normalxfrac\xfrac
+
+\permanent\protected\def\xfrac#1#2{\normalxfrac{\enforced\let\xfrac\xxfrac#1}{\enforced\let\xfrac\xxfrac#2}}
+
+%D Spacing (sensitive for definition of \triggermathstyle:
+
+% \ifcase\contextlmtxmode
+
+\permanent\protected\def\nomathfractiongaps {\normalexpanded{\math_no_fraction_gaps \mathstyletrigger\mathstyle}} % maybe collect settings
+\permanent\protected\def\overlaymathfractiongaps{\normalexpanded{\math_overlay_fraction_gaps\mathstyletrigger\mathstyle}} % maybe collect settings
+
+\protected\def\math_no_fraction_gaps#1%
+ {\Umathfractionnumup #1\zeropoint
+ \Umathfractiondenomdown#1\zeropoint}
+
+\protected\def\math_overlay_fraction_gaps#1%
+ {\Umathfractionnumup #1\zeropoint
+ \Umathfractionnumvgap #1\zeropoint
+ %Umathfractionrule #1\zeropoint
+ \Umathfractiondenomvgap#1\zeropoint
+ \Umathfractiondenomdown#1\zeropoint}
+
+% \else
+
+% \protected\def\math_no_fraction_gaps
+% {\Umathfractionnumup \mathstyle\zeropoint
+% \Umathfractiondenomdown\mathstyle\zeropoint}
+%
+% \protected\def\math_overlay_fraction_gaps
+% {\Umathfractionnumup \mathstyle\zeropoint
+% \Umathfractionnumvgap \mathstyle\zeropoint
+% %Umathfractionrule \mathstyle\zeropoint
+% \Umathfractiondenomvgap\mathstyle\zeropoint
+% \Umathfractiondenomdown\mathstyle\zeropoint}
+
+% \fi
+
+\installcorenamespace{mathfractiondistance}
+
+\letvalue{\??mathfractiondistance\v!none }\nomathfractiongaps
+\letvalue{\??mathfractiondistance\v!no }\nomathfractiongaps
+\letvalue{\??mathfractiondistance\v!overlay}\overlaymathfractiongaps
+
+\setupmathfractions
+ [\c!distance=\v!none]
+
+\appendtoks
+ \edef\p_distance{\rootmathfractionparameter\c!distance}%
+ \ifempty\p_distance\else
+ \ifcsname\??mathfractiondistance\p_distance\endcsname
+ \lastnamedcs
+ \fi
+ \fi
+\to \everymathematics
+
+% theshold is new!
+
+\let\math_fraction_set_threshold_inline \relax
+\let\math_fraction_set_threshold_display\relax
+
+\appendtoks
+ \math_fraction_set_threshold_inline
+ \math_fraction_set_threshold_display
+\to \everymathematics
+
+\appendtoks
+ \ifempty\currentmathfraction
+ \edef\p_threshold{\mathfractionparameter\c!inlinethreshold}%
+ \ifempty\p_threshold
+ \let\math_fraction_set_threshold_inline\relax
+ \orelse\ifx\p_threshold\v!auto
+ \let\math_fraction_set_threshold_inline\relax
+ \else
+ \let\math_fraction_set_threshold_inline\math_fraction_set_theshold_inline
+ \fi
+ \edef\p_threshold{\mathfractionparameter\c!displaythreshold}%
+ \ifempty\p_threshold
+ \let\math_fraction_set_threshold_display\relax
+ \orelse\ifx\p_threshold\v!auto
+ \let\math_fraction_set_threshold_display\relax
+ \else
+ \let\math_fraction_set_threshold_display\math_fraction_set_theshold_display
+ \fi
+ \fi
+\to \everysetupmathfraction
+
+\def\math_fraction_set_theshold_inline
+ {\edef\p_threshold{\mathfractionparameter\c!inlinethreshold}%
+ \Umathfractiondelsize\textstyle \p_threshold\dimexpr\textface\relax
+ \Umathfractiondelsize\scriptstyle \p_threshold\dimexpr\scriptface\relax
+ \Umathfractiondelsize\scriptscriptstyle\p_threshold\dimexpr\scriptscriptface\relax}
+
+\def\math_fraction_set_theshold_display
+ {\edef\p_threshold{\mathfractionparameter\c!displaythreshold}%
+ \Umathfractiondelsize\displaystyle \p_threshold\dimexpr\textface\relax}
+
+%D \macros
+%D {dfrac, tfrac, frac, dbinom, tbinom, binom}
+%D
+%D \startbuffer
+%D $\dfrac {1}{2} \tfrac {1}{2} \frac {1}{2}$
+%D $\dbinom{1}{2} \tbinom{1}{2} \binom{1}{2}$
+%D \stopbuffer
+%D
+%D \typebuffer
+%D \getbuffer
+
+% $$
+% {{a}\over{b}} +
+% {{a}\overwithdelims(){b}} +
+% {{a}\atopwithdelims(){b}} +
+% {{a}\abovewithdelims()\zeropoint{b}} +
+% \left({{a}\over{b}}\right)
+% $$
+
+% \dorecurse {10} { % weird
+% $$ {{a}\abovewithdelims()#1pt{b}} $$
+% }
+
+\definemathfraction[i:frac] [\c!alternative=\v!inner,\c!mathstyle=] % was script and then small but nothing needed
+\definemathfraction[i:tfrac][\c!alternative=\v!inner,\c!mathstyle=\s!text] % was script (before luatex fix)
+\definemathfraction[i:sfrac][\c!alternative=\v!inner,\c!mathstyle=\s!scriptscript]
+\definemathfraction[i:dfrac][\c!alternative=\v!inner,\c!mathstyle=\s!display]
+
+\definemathfraction[d:frac] [\c!alternative=\v!inner,\c!mathstyle=\s!cramped] % was cramped,text
+\definemathfraction[d:tfrac][\c!alternative=\v!both ,\c!mathstyle={\s!cramped,\s!text}] % was cramped,script (before luatex fix)
+\definemathfraction[d:sfrac][\c!alternative=\v!both ,\c!mathstyle={\s!cramped,\s!scriptscript}]
+\definemathfraction[d:dfrac][\c!alternative=\v!inner,\c!mathstyle=\s!display]
+
+%D \protected\def\ShowMathFractions#1#2%
+%D {\dontleavehmode
+%D \begingroup
+%D \showmathstruts
+%D \mathematics{x+\tfrac{#1}{#2}+1+\frac{#1}{#2}+2+\sfrac{#1}{#2}+g}%
+%D \endgroup}
+%D
+%D The default \type {tfrac}, \type {frac} and \type \sfrac} look like this:
+%D
+%D \blank
+%D \ShowMathFractions{a}{a}\par
+%D \ShowMathFractions{1}{x}\par
+%D \ShowMathFractions{a}{b}\par
+%D \ShowMathFractions{1}{b}\par
+%D \blank
+
+\permanent\protected\def\frac {\csname\inlineordisplaymath id:frac\endcsname}
+\permanent\protected\def\tfrac{\csname\inlineordisplaymath id:tfrac\endcsname}
+\permanent\protected\def\sfrac{\csname\inlineordisplaymath id:sfrac\endcsname}
+\permanent\protected\def\dfrac{\csname\inlineordisplaymath id:dfrac\endcsname}
+
+\definemathfraction[ams] [\c!strut=\v!no,\c!alternative=\v!outer]
+\definemathfraction[i:ams:frac][ams][\c!mathstyle={\s!cramped,\s!text}]
+\definemathfraction[d:ams:frac][ams][\c!mathstyle={\s!cramped,\s!display}]
+
+\permanent\protected\def\ctxfrac{\csname\inlineordisplaymath id:frac\endcsname}
+\permanent\protected\def\amsfrac{\csname\inlineordisplaymath id:ams:frac\endcsname}
+
+% \appendtoks
+% \doifelse{\mathfractionparameter\c!option}{ams}%
+% {\let\frac\amsfrac}%
+% {\let\frac\ctxfrac}%
+% \to \everysetupmathfraction
+
+\appendtoks
+ \doifelse{\mathematicsparameter\c!fractions}{ams}%
+ {\enforced\let\frac\amsfrac}%
+ {\enforced\let\frac\ctxfrac}%
+\to \everysetupmathematics
+
+% \definemathfraction[ddfrac][\c!mathstyle=\s!display]
+% \definemathfraction[ttfrac][\c!mathstyle=\s!text]
+% \definemathfraction[ssfrac][\c!mathstyle=\s!script]
+
+% \protected\def\binom #1#2{{\Ustack {{#1}\normalabovewithdelims()\zeropoint{#2}}}}
+% \protected\def\dbinom#1#2{{\displaystyle{{#1}\normalabovewithdelims()\zeropoint{#2}}}}
+% \protected\def\tbinom#1#2{{\textstyle {{#1}\normalabovewithdelims()\zeropoint{#2}}}}
+
+\definemathfraction
+ [binom]
+ [\c!alternative=\v!outer,
+ \c!rule=\v!no,
+ \c!left=0x28,
+ \c!right=0x29,
+ \c!mathstyle=\s!auto]
+
+\definemathfraction
+ [dbinom]
+ [binom]
+ [\c!mathstyle=\s!display]
+
+\definemathfraction
+ [tbinom]
+ [binom]
+ [\c!mathstyle=\s!text]
+
+%D \macros
+%D {cfrac}
+%D
+%D \startbuffer
+%D $\cfrac{12}{3} \cfrac[l]{12}{3} \cfrac[c]{12}{3} \cfrac[r]{12}{3}$
+%D $\cfrac{1}{23} \cfrac[l]{1}{23} \cfrac[c]{1}{23} \cfrac[r]{1}{23}$
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer
+%D
+%D Now we can align every combination we want:
+%D
+%D \startbuffer
+%D $\cfrac{12}{3} \cfrac[l]{12}{3} \cfrac[c]{12}{3} \cfrac[r]{12}{3}$
+%D $\cfrac{1}{23} \cfrac[l]{1}{23} \cfrac[c]{1}{23} \cfrac[r]{1}{23}$
+%D $\cfrac[cl]{12}{3} \cfrac[cc]{12}{3} \cfrac[cr]{12}{3}$
+%D $\cfrac[lc]{1}{23} \cfrac[cc]{1}{23} \cfrac[rc]{1}{23}$
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer
+
+\permanent\protected\def\cfrac
+ {\doifelsenextoptionalcs\math_cfrac_yes\math_cfrac_nop}
+
+\def\math_cfrac_nop {\math_cfrac_indeed[cc]}
+\def\math_cfrac_yes[#1]{\math_cfrac_indeed[#1cc]}
+
+\def\math_cfrac_indeed[#1#2#3]#4#5%
+ {{\displaystyle
+ \frac
+ {\strut
+ \ifx r#1\hfill\fi#4\ifx l#1\hfill\fi}%
+ {\ifx r#2\hfill\fi#5\ifx l#2\hfill\fi}%
+ \kern-\nulldelimiterspace}}
+
+%D \macros
+%D {splitfrac, splitdfrac}
+%D
+%D Occasionally one needs to typeset multi||line fractions.
+%D These commands use \tex{genfrac} to create such fractions.
+%D
+%D \startbuffer
+%D \startformula
+%D a=\frac{
+%D \splitfrac{xy + xy + xy + xy + xy}
+%D {+ xy + xy + xy + xy}
+%D }
+%D {z}
+%D =\frac{
+%D \splitdfrac{xy + xy + xy + xy + xy}
+%D {+ xy + xy + xy + xy}
+%D }
+%D {z}
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D These macros are based on Michael J.~Downes posting on
+%D comp.text.tex on 2001/12/06 but adapted a bit.
+
+\permanent\protected\def\splitfrac #1#2{{\textstyle {{\textstyle#1\quad\hfill}\normalabove\zeropoint{\textstyle\hfill\quad\mathstrut#2}}}}
+\permanent\protected\def\splitdfrac#1#2{{\displaystyle{{ #1\quad\hfill}\normalabove\zeropoint{ \hfill\quad\mathstrut#2}}}}
+
+%D For testing:
+
+% \protected\def\ShowMathFractions#1#2%
+% {\mathematics{x+\tfrac{#1}{#2}+1+\frac{#1}{#2}+2+\sfrac{#1}{#2}+g}}
+
+%D More fracking (for Alan):
+
+\protected\def\math_frac_colored_vulgar#1#2%
+ {\savecolor
+ \colo_helpers_activate\p_math_fractions_color
+ {\restorecolor#1}\Uskewed/{\restorecolor#2}}
+
+\protected\def\math_frac_normal_vulgar#1#2%
+ {{#1}\Uskewed/{#2}}
+
+\permanent\protected\def\vfrac#1#2%
+ {\bgroup
+ \edef\p_math_fractions_color{\namedmathfractionparameter\s!vfrac\c!color}%
+ \ifempty\p_math_fractions_color
+ \expandafter\math_frac_normal_vulgar
+ \else
+ \expandafter\math_frac_colored_vulgar
+ \fi
+ {#1}%
+ {#2}%
+ \egroup}
+
+\appendtoks
+ \edef\p_hfactor{\namedmathfractionparameter\s!vfrac\c!hfactor}%
+ \edef\p_vfactor{\namedmathfractionparameter\s!vfrac\c!vfactor}%
+ \Umathskewedfractionhgap\textstyle \p_hfactor\fontemwidth \mathstylefont\textstyle
+ \Umathskewedfractionhgap\scriptstyle \p_hfactor\fontemwidth \mathstylefont\scriptstyle
+ \Umathskewedfractionhgap\scriptscriptstyle\p_hfactor\fontemwidth \mathstylefont\scriptscriptstyle
+ \Umathskewedfractionvgap\textstyle \p_vfactor\fontexheight\mathstylefont\textstyle
+ \Umathskewedfractionvgap\scriptstyle \p_vfactor\fontexheight\mathstylefont\scriptstyle
+ \Umathskewedfractionvgap\scriptscriptstyle\p_vfactor\fontexheight\mathstylefont\scriptscriptstyle
+\to \everysetupmathfraction
+
+\setupmathfraction
+ [\s!vfrac]
+ [\c!hfactor=.2,
+ \c!vfactor=.1]
+
+\protect \endinput
+
+% I have no clue what \mthfrac and \mthsqrt are supposed to do but
+% I guess that it can be done with tweaking luatex's math parameters.
+% Otherwise I'll write something from scratch.
+
+% \def\math_stylebuilders_frac#1#2#3#4#5#6#7%
+% {\begingroup
+% \mathsurround\zeropoint
+% \setbox0\hbox{$#1 #6$}%
+% \setbox2\hbox{$#1 #7$}%
+% \dimen0\wd\ifdim\wd2>\wd0 2\else 0\fi
+% \setbox4\hbox to \dimen0{\leaders\hbox{#4}\hss#5}%
+% \mathord{\vcenter{{\offinterlineskip
+% \hbox to \dimen0{\hss\box0\hss}%
+% \kern\ht4%
+% \hbox to \dimen0{\hss\copy4\hss}%
+% \kern\ht4%
+% \hbox to \dimen0{\hss\box2\hss}}}}%
+% \endgroup}
+%
+% \def\math_stylebuilders_sqrt#1#2#3#4#5%
+% {\begingroup
+% \mathsurround\zeropoint
+% \setbox0\hbox{$#1 #5$}%
+% \ht0\dimexpr1.05\ht0+\onepoint\relax
+% \dp0\dimexpr1.05\dp0+\onepoint\relax
+% \setbox4\hbox to \wd0{\mr#2\leaders\hbox{#3}\hfill#4}%
+% \delimitershortfall\zeropoint
+% \nulldelimiterspace\zeropoint
+% \setbox2\hbox{$\left\delimiter"0270370 \vrule \s!height\ht0 \s!depth \dp0 \s!width\zeropoint\right.$}% is this the right code point?
+% \mathord{\vcenter{\hbox{\copy2\rlap{\raise\dimexpr\ht2-\ht4\relax\copy4}\copy0}}}%
+% \endgroup}
+%
+% \def\mthfrac#1#2#3#4#5{\mathchoice
+% {\math_stylebuilders_frac\displaystyle \textface {#1}{#2}{#3}{#4}{#5}}%
+% {\math_stylebuilders_frac\textstyle \textface {#1}{#2}{#3}{#4}{#5}}%
+% {\math_stylebuilders_frac\scriptstyle \scriptface {#1}{#2}{#3}{#4}{#5}}%
+% {\math_stylebuilders_frac\scriptscriptstyle\scriptscriptface{#1}{#2}{#3}{#4}{#5}}}
+%
+% \def\mthsqrt#1#2#3{\mathchoice
+% {\math_stylebuilders_sqrt\displaystyle \textface{#1}{#2}{#3}}%
+% {\math_stylebuilders_sqrt\textstyle \textface{#1}{#2}{#3}}%
+% {\math_stylebuilders_sqrt\scriptstyle \textface{#1}{#2}{#3}}%
+% {\math_stylebuilders_sqrt\scriptscriptstyle\textface{#1}{#2}{#3}}}
+
+% \protected\def\mthfrac#1#2#3{[mthfrac: #1 #2 #3]}
+% \protected\def\mthsqrt#1#2#3{[mthsqrt: #1 #2 #3]}
+
+% used for prototyping \Uskewed
+%
+% \protected\def\skewedfractiona#1#2{%
+% \raise
+% \Umathskewedfractionvgap\textstyle
+% \hbox\bgroup
+% $\scriptstyle#1\hskip\dimexpr\Umathskewedfractionhgap\scriptstyle/2\relax$%
+% \egroup
+% \hbox to \zeropoint\bgroup
+% \hss$\textstyle/$\hss
+% \egroup
+% \lower
+% \Umathskewedfractionvgap\textstyle
+% \hbox\bgroup
+% $\hskip\dimexpr\Umathskewedfractionhgap\scriptstyle/2\relax\scriptstyle#2$%
+% \egroup
+% }
+%
+% \protected\def\skewedfractionb#1#2{%
+% \raise
+% \Umathskewedfractionvgap\textstyle
+% \hbox\bgroup
+% $\scriptstyle#1\hskip\dimexpr\Umathskewedfractionhgap\textstyle/2\relax$%
+% \egroup
+% \hbox to \zeropoint\bgroup
+% \hss$\textstyle/$\hss
+% \egroup
+% \lower
+% \Umathskewedfractionvgap\textstyle
+% \hbox\bgroup
+% $\hskip\dimexpr\Umathskewedfractionhgap\textstyle/2\relax\scriptstyle#2$%
+% \egroup
+% }
+%
+% $\skewedfractiona{1}{2}$
+% $\skewedfractionb{1}{2}$
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-inc.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-inc.mkxl
new file mode 100644
index 00000000000..4db75e37e11
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-inc.mkxl
@@ -0,0 +1,69 @@
+%D \module
+%D [ file=math-inc,
+%D version=2018.06.23,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=XML inclusion,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / XML inclusion}
+
+\registerctxluafile{math-inc}{}
+
+%D I had some doubt about including this in \CONTEXT\ but it might serve some users
+%D anyway. It's always the question to what extent one can be really roundtrip. I
+%D might improve it when I need it.
+
+% Talking about creating from a source ... June Lee's transcription of
+% Close to You by Jacob Collier is an amazing example:
+%
+% https://www.youtube.com/watch?v=hdBVN-HMuqI
+
+\unprotect
+
+\definesymbol[mmlattachment][{\infofont\darkred mml}]
+\definesymbol[mmlcomment] [{\infofont\darkblue mml}]
+
+\permanent\protected\def\lxml_add_mml_blob#1#2%
+ {\relax
+ \clf_xmlformulatobuffer\number\c_strc_formulas_n{temp-xml-export}%
+ #2%
+ [\c!symbol=#1,%
+ \c!space=\v!yes,%
+ \c!buffer=temp-xml-export,%
+ \c!name={formula-\number\c_strc_formulas_n.xml}]%
+ \relax}
+
+\permanent\protected\def\xmlattachmml
+ {\iftrialtypesetting\orelse\ifexporting\iflocation
+ \dostarttagged\t!ignore\empty
+ \lxml_add_mml_blob{mmlattachment}\attachment
+ \dostoptagged
+ \fi\fi}
+
+\permanent\protected\def\xmlcommentmml
+ {\iftrialtypesetting\orelse\ifexporting\iflocation
+ \dostarttagged\t!ignore\empty
+ \lxml_add_mml_blob{mmlcomment}\comment
+ \dostoptagged
+ \fi\fi}
+
+%D This kind of feature creep is not yet configurable, nor documented.
+
+\permanent\protected\def\xmladdmmlsource
+ {\iftrialtypesetting\orelse\ifexporting\iflocation
+ \dostarttagged\t!ignore\empty
+ \inleftmargin{%
+ \lxml_add_mml_blob{mmlattachment}\attachment
+ \quad
+ \lxml_add_mml_blob{mmlcomment}\comment
+ }%
+ \dostoptagged
+ \fi\fi}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-ini.mkxl
new file mode 100644
index 00000000000..9f541c3512b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-ini.mkxl
@@ -0,0 +1,3022 @@
+%D \module
+%D [ file=math-ini,
+%D version=2008.01.02,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Initializations,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Initializations}
+
+% todo: hpack as we skip math anyway
+%
+% todo: 0x2061 : function application
+% todo: 0x2062 : invisible times
+% todo: 0x2063 : invisible comma
+
+% a bit tricky way to set ... no (pseudo) registers but math hash values:
+%
+% \normalexpanded{\Umathlimitabovevgap\displaystyle=40\dimexpr\the\Umathlimitabovevgap\displaystyle\relax}
+
+% Todo in luatex maincontrol.w: also accept a number here:
+%
+% case set_math_param_cmd:
+% p = cur_chr;
+% get_token();
+% if (cur_cmd != math_style_cmd) {
+%
+% plus two new math styles: larger/smaller
+%
+% \protected\def\Umathshow#1%
+% {\hbox{\infofont(\string#1:\the#1\textstyle,\the#1\scriptstyle,\the#1\scriptscriptstyle)}}
+
+%D This module provides namespaces for math fonts, thereby permitting mixed usage of
+%D math fonts. Although not strictly needed, we also provide a family name mapping
+%D mechanism as used in the (original) AMS math definition files, but here these
+%D names can recursively be remapped and if needed, dynamically be changed. We've
+%D tried to minimize the number of definition commands and use plain \TEX\
+%D definitions as fallback. We've tried to follow a couple of conventions from plain
+%D and AMS math in order to achieve backward compatinility. We also kept an eye on
+%D future usage of these modules in the perspective of MathML and unicode fonts.
+
+%D There is a subtle issue with grouping: the \type {\begingroup} method will not
+%D restore a changed mathstyle so best avoid that one. However, there are cases where
+%D we really need to use such grouping.
+
+% Weird, these fail, maybe amp is solved in a later state from char noads (needs a
+% fix in luatex):
+%
+% $\char"26$
+% $\a$
+% $\string&$
+
+% mathop applied to characters centers it vertically
+
+\unprotect
+
+%D We move these definitions into the format:
+
+% test [[\char948 \cldcontext{utf.char(948)}]]
+% test $[[\char948 \cldcontext{utf.char(948)}]]$
+
+\registerctxluafile{math-ini}{}
+\registerctxluafile{math-dim}{}
+\registerctxluafile{math-act}{autosuffix}
+\registerctxluafile{math-ext}{}
+\registerctxluafile{math-vfu}{autosuffix}
+\registerctxluafile{math-ttv}{}
+\registerctxluafile{math-map}{optimize}
+\registerctxluafile{math-ren}{}
+\registerctxluafile{math-noa}{autosuffix,optimize}
+\registerctxluafile{math-tag}{autosuffix}
+\registerctxluafile{math-fbk}{}
+\registerctxluafile{math-dir}{}
+\registerctxluafile{math-spa}{}
+
+%D A starter:
+%D
+%D \startbuffer
+%D \mathsurround 10pt
+%D \mathsurroundskip30pt
+%D x $x + \ruledhbox{$x$} + x$ x
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \start \blank \getbuffer \blank \stop
+
+\newcount\mathnestinglevel
+
+\appendtoks
+ \advance\mathnestinglevel\plusone
+\to \everymathematics
+
+%D A few compatibility helpers:
+
+\permanent\def\Umathbotaccent{\Umathaccent \s!bottom }
+\permanent\def\Umathtopaccent{\Umathaccent \s!top }
+\permanent\def\Umathaccents {\Umathaccent \s!both } % strange highlighting
+
+\ifdefined\Umathcharclass \else
+ \permanent\def\Umathcharclass{\numexpr\cldcontext{tex.getmathcode(token.scan_int())[1]}\relax}
+ \permanent\def\Umathcharfam {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[2]}\relax}
+ \permanent\def\Umathcharslot {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[3]}\relax}
+\fi
+
+%D The attributes that we will use (todo: pack some into one but uglier code):
+
+\definesystemattribute[mathalphabet] [public]
+\definesystemattribute[mathsize] [public]
+\definesystemattribute[mathpunctuation][public]
+\definesystemattribute[mathgreek] [public] % will become generic
+\definesystemattribute[mathalternate] [public]
+\definesystemattribute[mathrendering] [public]
+\definesystemattribute[mathcategory] [public]
+\definesystemattribute[mathmode] [public]
+\definesystemattribute[mathitalics] [public]
+\definesystemattribute[mathkernpairs] [public]
+\definesystemattribute[mathbidi] [public]
+\definesystemattribute[mathdomain] [public]
+\definesystemattribute[mathcollapsing] [public]
+\definesystemattribute[mathunstack] [public]
+
+\definesystemattribute[displaymath] [public]
+
+\mathflattenmode 31
+
+\ifdefined\ordlimits\else
+ \let\ordlimits\limits
+\fi
+
+\appendtoks
+ \c_attr_mathmode\plusone
+\to \everydisplay
+
+\appendtoks
+ \c_attr_mathmode \plusone
+ \c_attr_displaymath\plusone
+\to \everybeforedisplayformula
+
+\defaultmathfamily \zerocount % 255
+
+\permanent\protected\def\resetmathattributes{\clf_resetmathattributes}
+
+% handy
+
+\newconditional\indisplaymath
+
+\appendtoks
+ \setfalse\indisplaymath
+\to \everymath
+
+\appendtoks
+ \settrue\indisplaymath
+\to \everydisplay
+
+\permanent\def\inlineordisplaymath{\ifconditional\indisplaymath\expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments\fi}
+
+\permanent\protected\def\forcedisplaymath
+ {\ifmmode
+ \displaystyle
+ \settrue\indisplaymath
+ \fi}
+
+\permanent\protected\def\startforceddisplaymath
+ {\startimath
+ \displaystyle
+ \begingroup
+ \settrue\indisplaymath}
+
+\permanent\protected\def\stopforceddisplaymath
+ {\endgroup
+ \stopimath}
+
+\permanent\protected\def\startpickupmath % for the moment private
+ {\ifconditional\indisplaymath
+ \startforceddisplaymath
+ \enforced\let\stoppickupmath\stopforceddisplaymath
+ \else
+ \startimath
+ \enforced\let\stoppickupmath\stopimath
+ \fi}
+
+\aliased\let\stoppickupmath\relax
+
+% \protected\def\rawmathcharacter#1% slow but only for tracing
+% {\begingroup
+% \ifmmode
+% \resetmathattributes\Uchar#1%
+% \else
+% \startimath\resetmathattributes\Uchar#1\stopimath
+% \fi
+% \endgroup}
+
+\permanent\protected\def\rawmathematics#1% slow but only for tracing
+ {\begingroup
+ \ifmmode
+ \clf_resetmathattributes#1%
+ \else
+ \startimath\clf_resetmathattributes#1\stopimath
+ \fi
+ \endgroup}
+
+%D Some measures (maybe spac-mth):
+
+% \def\mathskipsmall {\mskip\thinmuskip}
+% \def\mathskipmedium{\mskip\medmuskip}
+% \def\mathskipbig {\mskip\thickmuskip}
+
+%D \macros
+%D {setupmathematics}
+%D
+%D Configuration for integrals. (If needed we can speed this up and make it
+%D installable; no processaction is needed then).
+
+\installcorenamespace{mathematics}
+
+\installswitchcommandhandler \??mathematics {mathematics} \??mathematics
+
+\installmacrostack\currentmathematics
+
+% \permanent\protected\def\startmathematics % no grouping, if ever then also an optional second
+% {\doifelsenextoptionalcs\math_mathematics_start_yes\math_mathematics_start_nop}
+%
+% \protected\def\math_mathematics_start_yes[#1]%
+% {\push_macro_currentmathematics
+% \edef\currentmathematics{#1}% check for valid
+% \the\everyswitchmathematics}
+%
+% \protected\def\math_mathematics_start_nop
+% {\push_macro_currentmathematics
+% \let\currentmathematics\empty
+% \the\everyswitchmathematics}
+
+\permanent\protected\tolerant\def\startmathematics[#1]% no grouping, if ever then also an optional second
+ {\push_macro_currentmathematics
+ \edef\currentmathematics{#1}% check for valid
+ \the\everyswitchmathematics}
+
+\permanent\protected\def\stopmathematics
+ {\pop_macro_currentmathematics
+ \the\everyswitchmathematics} % only needed at level zero
+
+\definemathematics[\v!default] % not needed, but nicer when nesting back to normal
+
+% Now we redefine \type {\mathematics} and \type {\m}:
+
+\pushoverloadmode
+
+ \permanent\protected\def\mathematics{\doifelsenextoptionalcs\math_m_yes\math_m_nop}
+
+ \aliased\let\m \mathematics % we keep the simple versions
+ \aliased\let\math\mathematics % we keep the simple versions
+
+\popoverloadmode
+
+\def\math_m_yes
+ {\relax
+ \ifmmode
+ \expandafter\math_m_yes_math
+ \else
+ \expandafter\math_m_yes_text
+ \fi}
+
+\def\math_m_yes_math[#1]#2%
+ {#2}
+
+\def\math_m_yes_text[#1]%
+ {\begingroup
+ \ifcondition\validassignment{#1}%
+ \setupcurrentmathematics[#1]%
+ \else
+ \edef\currentmathematics{#1}% check for valid
+ \fi
+ \edef\p_openup{\mathematicsparameter\c!openup}%
+ \ifx\p_openup\v!yes
+ \expandafter\math_m_yes_text_openedup
+ \else
+ \expandafter\math_m_yes_text_normal
+ \fi}
+
+\def\math_m_yes_text_openedup#1%
+ {\setbox\scratchbox\hbox\bgroup
+ \the\everyswitchmathematics\relax
+ \normalstartimath
+ #1%
+ \normalstopimath
+ \egroup
+ \ifdim\ht\scratchbox>\strutht
+ \math_inline_openup_start_yes
+ \orelse\ifdim\dp\scratchbox>\strutdp
+ \math_inline_openup_start_yes
+ \else
+ \math_inline_openup_start_nop
+ \fi
+ \unhbox\scratchbox % \normalstartimath#1\normalstopimath
+ \math_inline_openup_stop
+ \endgroup}
+
+\def\math_m_yes_text_normal#1%
+ {\the\everyswitchmathematics\relax
+ \normalstartimath
+ #1%
+ \normalstopimath
+ \endgroup}
+
+\def\math_m_nop#1%
+ {\relax
+ \ifmmode
+ #1%
+ \else
+ \normalstartimath
+ #1%
+ \normalstopimath
+ \fi}
+
+% e.g.: \definemathematics[i:mp][setups=i:tight,openup=yes]
+
+\immutable\mugluespecdef\defaultthickmuskip 5mu plus 5mu
+\immutable\mugluespecdef\defaultmedmuskip 4mu plus 2mu minus 4mu
+\immutable\mugluespecdef\defaultthinmuskip 3mu
+
+\immutable\mugluespecdef\halfthickmuskip 2.5mu plus 2.5mu
+\immutable\mugluespecdef\halfmedmuskip 2.0mu plus 1.0mu minus 2.0mu
+\immutable\mugluespecdef\halfthinmuskip 1.5mu
+
+\immutable\mugluespecdef\hairmuskip .15mu
+
+\immutable\integerdef \defaultrelpenalty 500
+\immutable\integerdef \defaultbinoppenalty 700
+\immutable\integerdef \defaultprerelpenalty -100
+\immutable\integerdef \defaultprebinoppenalty -100
+
+% we need to control these otherwise:
+%
+% \prerelpenalty \defaultprerelpenalty
+% \prebinoppenalty\defaultprebinoppenalty
+
+\startsetups math:spacing:default
+ \thickmuskip \defaultthickmuskip
+ \medmuskip \defaultmedmuskip
+ \thinmuskip \defaultthinmuskip
+ \relpenalty \defaultrelpenalty
+ \binoppenalty \defaultbinoppenalty
+ \prebinoppenalty\maxdimen
+ \prerelpenalty \maxdimen
+\stopsetups
+
+\startsetups math:spacing:split
+ \thickmuskip \defaultthickmuskip
+ \medmuskip \defaultmedmuskip
+ \thinmuskip \defaultthinmuskip
+ \relpenalty \defaultrelpenalty
+ \binoppenalty \defaultbinoppenalty
+ \prebinoppenalty\defaultprebinoppenalty
+ \prerelpenalty \defaultprerelpenalty
+\stopsetups
+
+\startsetups math:spacing:half
+ \thickmuskip \halfthickmuskip
+ \medmuskip \halfmedmuskip
+ \thinmuskip \halfthinmuskip
+ \relpenalty \defaultrelpenalty
+ \binoppenalty \defaultbinoppenalty
+ \prebinoppenalty\maxdimen
+ \prerelpenalty \maxdimen
+\stopsetups
+
+\startsetups math:spacing:tight
+ \ifcase\raggedstatus
+ \thickmuskip \halfthickmuskip
+ \medmuskip \halfmedmuskip
+ \thinmuskip \halfthinmuskip
+ \else
+ \thickmuskip 1\halfthickmuskip
+ \medmuskip 1\halfmedmuskip
+ \thinmuskip 1\halfthinmuskip
+ \fi
+ \relpenalty \defaultrelpenalty
+ \binoppenalty \maxdimen
+ \prebinoppenalty\maxdimen
+ \prerelpenalty \maxdimen
+\stopsetups
+
+\startsetups math:spacing:fixed
+ \ifcase\raggedstatus
+ \thickmuskip \halfthickmuskip
+ \medmuskip \halfmedmuskip
+ \thinmuskip \halfthinmuskip
+ \else
+ \thickmuskip 1\halfthickmuskip
+ \medmuskip 1\halfmedmuskip
+ \thinmuskip 1\halfthinmuskip
+ \fi
+ \relpenalty \maxdimen
+ \binoppenalty \maxdimen
+ \prebinoppenalty\maxdimen
+ \prerelpenalty \maxdimen
+\stopsetups
+
+% \dorecurse{80}{test \m[i:tight]{\red \fakeformula} test }
+
+\definemathematics[i:default][\c!setups=math:spacing:equal]
+\definemathematics[i:half] [\c!setups=math:spacing:half]
+\definemathematics[i:tight] [\c!setups=math:spacing:tight]
+\definemathematics[i:fixed] [\c!setups=math:spacing:fixed]
+
+% Normally the next is applied to only one character.
+%
+% $ABC$ $\cal ABC$ $\mathaltcal ABC$
+
+% todo: only in mmode
+% these commands are semi-public but should not be used directly (lua names wil change)
+
+\permanent\protected\def\setmathattribute #1#2{\ifmmode\clf_setmathattribute{#1}{#2}\fi}
+\permanent\protected\def\setmathalphabet #1{\ifmmode\clf_setmathalphabet{#1}\fi}
+\permanent\protected\def\setmathfontstyle #1{\ifmmode\clf_setmathstyle{#1}\fi}
+\permanent\protected\def\setmathfontalternate#1{\ifmmode\clf_setmathalternate\defaultmathfamily{#1}\fi}
+
+\installcorenamespace{mathstylealternative} % might become a setuphandler
+
+\permanent\protected\def\setmathfontstylealternate#1%
+ {\ifcsname\??mathstylealternative\fontclass:#1\endcsname
+ \expandafter\setmathfontalternate\lastnamedcs
+ \orelse\ifcsname\??mathstylealternative#1\endcsname
+ \expandafter\setmathfontalternate\lastnamedcs
+ \fi}
+
+\permanent\tolerant\protected\def\setupmathrendering[#1]#*[#2]% the name might change
+ {\ifparameter#2\or
+ \getparameters[\??mathstylealternative#1:][#2]%
+ \else
+ \getparameters[\??mathstylealternative][#1]%
+ \fi}
+
+\appendtoks
+ \edef\p_stylealternative{\mathematicsparameter\c!stylealternative}%
+ \ifempty\p_stylealternative\else
+ \clf_presetmathalternate\defaultmathfamily{\p_stylealternative}%
+ \fi
+\to \everymathematics
+
+% if there were many features we could have a feature pass over math nodes but it makes no
+% sense now so we have commands to deal with it
+
+% \enabletrackers[math.alternates]
+% \setupbodyfont[lucidaot]
+%
+% \startTEXpage
+% \setupmathematics[stylealternative={reset}]$x+\mathcal A$\par
+% \setupmathematics[stylealternative={reset,calligraphic}]$x+\mathcal A$\par
+% \setupmathematics[stylealternative={reset,italic}]$x+\mathcal A$\par
+% \setupmathematics[stylealternative={reset,calligraphic,italic}]$x+\mathcal A$
+% \stopTEXpage
+
+% no longer needed now we have enforce so the next few lines will go
+
+% \pushoverloadmode
+% \enforced\let\dotlessi\dotlessi
+% \enforced\let\dotlessj\dotlessj
+% \popoverloadmode
+
+\permanent\protected\def\mathaltcalligraphic{\setmathfontalternate{calligraphic}\cal} % set via goody file
+\permanent\protected\def\mathaltitalic {\setmathfontalternate{italic}} % set via goody file
+\permanent\protected\def\mathslashedzero {\begingroup\setmathfontalternate{zero}∅\endgroup} % set via goody file or automatic
+\permanent\protected\def\mathdotless {\setmathfontalternate{dotless}} % set via goody file or automatic
+\permanent\protected\def\mathdotlessi {\begingroup\mathdotless i\endgroup}
+\permanent\protected\def\mathdotlessj {\begingroup\mathdotless j\endgroup}
+
+\aliased\let\mathaltcal\mathaltcalligraphic
+\aliased\let\mathaltit \mathaltitalic
+
+%aliased\let\textslashedzero\slashedzero \permanent\protected\def\autoslashedzero{\mathortext\mathslashedzero\textslashedzero}
+\aliased\let\textdotlessi \dotlessi \permanent\protected\def\autodotlessi {\mathortext\mathdotlessi \textdotlessi}
+\aliased\let\textdotlessj \dotlessj \permanent\protected\def\autodotlessj {\mathortext\mathdotlessj \textdotlessj}
+
+\appendtoks
+ %enforced\let\slashedzero\autoslashedzero
+ \enforced\let\dotlessi\autodotlessi
+ \enforced\let\dotlessj\autodotlessj
+\to \everymathematics
+
+\aliased\let\setmathfontalternative \setmathfontalternate
+\aliased\let\setmathfontstylealternative\setmathfontstylealternate
+\aliased\let\mathalternate \setmathfontalternate
+
+\permanent\protected\def\mathupright {\setmathattribute\s!regular\s!tf\setmathfontstylealternate\s!tf}
+\permanent\protected\def\mathitalic {\setmathattribute\s!regular\s!it\setmathfontstylealternate\s!it}
+\permanent\protected\def\mathscript {\setmathalphabet \s!script \setmathfontstylealternate\s!script}
+\permanent\protected\def\mathfraktur {\setmathalphabet \s!fraktur \setmathfontstylealternate\s!fraktur}
+\permanent\protected\def\mathblackboard{\setmathalphabet \s!blackboard \setmathfontstylealternate\s!blackboard}
+
+\permanent\protected\def\mathrm {\setmathattribute\s!rm\s!tf \setmathfontstylealternate\s!tf}
+\permanent\protected\def\mathss {\setmathattribute\s!ss\s!tf \setmathfontstylealternate\s!tf}
+\permanent\protected\def\mathtt {\setmathattribute\s!tt\s!tf \setmathfontstylealternate\s!tf}
+
+\permanent\protected\def\mathtf {\setmathfontstyle\s!tf \setmathfontstylealternate\s!tf}
+\permanent\protected\def\mathsl {\setmathfontstyle\s!it \setmathfontstylealternate\s!it} % no sl
+\permanent\protected\def\mathit {\setmathfontstyle\s!it \setmathfontstylealternate\s!it}
+
+\permanent\protected\def\mathbf {\setmathfontstyle\s!bf \setmathfontstylealternate\s!bf}
+\permanent\protected\def\mathbs {\setmathfontstyle\s!bi \setmathfontstylealternate\s!bi} % no sl
+\permanent\protected\def\mathbi {\setmathfontstyle\s!bi \setmathfontstylealternate\s!bi}
+
+\aliased\let\mathdefault\mathitalic
+
+\appendtoks
+ \edef\p_default{\mathematicsparameter\c!default}%
+ \ifx\p_default\v!normal
+ \enforced\let\mathdefault\mathupright
+ \else
+ \enforced\let\mathdefault\mathitalic
+ \fi
+\to \everysetupmathematics
+
+\setupmathematics
+ [\c!default=\v!italic]
+
+\aliased\let\tfmath\mathtf % maybe a grouped command
+\aliased\let\slmath\mathsl
+\aliased\let\itmath\mathit
+
+\aliased\let\bfmath\mathbf
+\aliased\let\bsmath\mathbs
+\aliased\let\bimath\mathbi
+
+\aliased\let\Bbb\mathblackboard
+
+\permanent\protected\def\frak {\ifmmode\expandafter\mathfraktur \fi}
+\permanent\protected\def\cal {\ifmmode\expandafter\mathscript \fi}
+\permanent\protected\def\bbd {\ifmmode\expandafter\mathblackboard\fi}
+\permanent\protected\def\blackboard{\ifmmode\expandafter\mathblackboard\fi}
+\permanent\protected\def\fraktur {\ifmmode\expandafter\mathfraktur \fi}
+\permanent\protected\def\gothic {\ifmmode\expandafter\mathfraktur \fi}
+
+\permanent\protected\def\mathcal #1{{\mathscript #1}} % for AMS compatibility
+\permanent\protected\def\mathfrak#1{{\mathfraktur #1}} % for AMS compatibility
+\permanent\protected\def\mathbb #1{{\mathblackboard#1}} % for AMS compatibility
+
+\ifdefined\normaltf \else \permanent\let\normaltf\tf \fi \permanent\protected\def\tf{\ifmmode\mathtf\else\normaltf\fi}
+\ifdefined\normalbf \else \permanent\let\normalbf\bf \fi \permanent\protected\def\bf{\ifmmode\mathbf\else\normalbf\fi}
+\ifdefined\normalit \else \permanent\let\normalit\it \fi \permanent\protected\def\it{\ifmmode\mathit\else\normalit\fi}
+\ifdefined\normalsl \else \permanent\let\normalsl\sl \fi \permanent\protected\def\sl{\ifmmode\mathsl\else\normalsl\fi}
+\ifdefined\normalbi \else \permanent\let\normalbi\bi \fi \permanent\protected\def\bi{\ifmmode\mathbi\else\normalbi\fi}
+\ifdefined\normalbs \else \permanent\let\normalbs\bs \fi \permanent\protected\def\bs{\ifmmode\mathbs\else\normalbs\fi}
+
+\permanent\protected\def\rm{\ifmmode\mathrm\else\normalrm\fi}
+\permanent\protected\def\ss{\ifmmode\mathss\else\normalss\fi}
+\permanent\protected\def\tt{\ifmmode\mathtt\else\normaltt\fi}
+
+\ifdefined\mr \else \let\mr\relax \fi % hm ... permanent
+\ifdefined\mb \else \let\mb\relax \fi % hm ... permanent
+
+% 1: $\setmathattribute{ss}{bf}3$
+% 2: $\setmathattribute{ss}{bf}\setmathfontstylealternate{bf}3$
+% 3: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}3$
+% 4: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}\setmathfontstylealternate{bf}3$
+% 5: $e=mc^2 \quad \mb e=mc^2$
+
+\prependtoks
+ \mathdefault
+\to \everymathematics
+
+%D We could set the rendering attribute at the \LUA\ end but as there can be many
+%D small math snippets we keep track of the state at the \TEX\ end (mapping is
+%D export safe).
+%D
+%D \starttyping
+%D \startformula
+%D \reals {\mathbf R} \utfchar{"0211D} \utfchar{"1D411}
+%D \stopformula
+%D
+%D \setupmathematics
+%D [symbolset=blackboard-to-bold]
+%D
+%D \startformula
+%D \reals {\mathbf R} \utfchar{"0211D} \utfchar{"1D411}
+%D \stopformula
+%D \stoptyping
+
+\newcount\c_math_renderings_attribute
+
+\appendtoks
+ \c_math_renderings_attribute\clf_mathrenderset{\mathematicsparameter\c!symbolset}\relax
+\to \everysetupmathematics % only in mathematics
+
+\appendtoks
+ \ifcase\c_math_renderings_attribute\else
+ \c_attr_mathrendering\c_math_renderings_attribute
+ \fi
+\to \everymathematics
+
+\setupmathematics
+ [\c!symbolset=]
+
+%D \macros
+%D {boldsymbol}
+%D
+%D To be done.
+
+\mutable\let\mathboldsymbol\relax % yet unsupported, will be
+
+\permanent\protected\def\boldsymbol
+ {\mathortext\mathboldsymbol\bold}
+
+%D Helpers
+
+\permanent\def\utfmathclass #1{\clf_utfmathclass {#1}}
+\permanent\def\utfmathstretch#1{\clf_utfmathstretch{#1}}
+\permanent\def\utfmathcommand#1{\clf_utfmathcommand{#1}}
+\permanent\def\utfmathfiller #1{\clf_utfmathfiller {#1}}
+
+\permanent\def\utfmathcommandabove #1{\clf_utfmathcommandabove {#1}}
+\permanent\def\utfmathcommandbelow #1{\clf_utfmathcommandbelow {#1}}
+\permanent\def\utfmathcommandfiller#1{\clf_utfmathcommandfiller{#1}}
+
+\permanent\protected\def\doifelseutfmathaccent#1{\clf_doifelseutfmathaccent{#1}}
+\permanent\protected\def\doifelseutfmathabove #1{\clf_doifelseutfmathabove {#1}}
+\permanent\protected\def\doifelseutfmathbelow #1{\clf_doifelseutfmathbelow {#1}}
+\permanent\protected\def\doifelseutfmathfiller#1{\clf_doifelseutfmathfiller{#1}}
+\permanent\protected\def\doifelseutfmathlimop #1{\clf_doifelseutfmathlimop {#1}}
+
+\aliased\let\doifutfmathaccentelse \doifelseutfmathaccent
+\aliased\let\doifutfmathaboveelse \doifelseutfmathabove
+\aliased\let\doifutfmathbelowelse \doifelseutfmathbelow
+\aliased\let\doifutfmathfillerelse \doifelseutfmathfiller
+\aliased\let\doifutfmathlimopelse \doifelseutfmathlimop
+
+%D Not used that much:
+
+\installcorenamespace{mathcodecommand}
+
+\permanent\protected\def\mathlimop#1{\mathop{#1}} %no \limits
+\permanent\protected\def\mathbox #1{\dontleavehmode\hbox\Ustartmath\mathsurround\zeropoint#1\Ustopmath}
+\permanent\protected\def\mathnolop#1{\mathop{#1}\nolimits}
+
+\aliased\let\mathnothing\firstofoneunexpanded
+\aliased\let\mathalpha \firstofoneunexpanded
+
+\setnewconstant\mathordcode \zerocount \letvalue{\??mathcodecommand ord}\mathord
+\setnewconstant\mathopcode \plusone \letvalue{\??mathcodecommand op}\mathop
+\setnewconstant\mathbincode \plustwo \letvalue{\??mathcodecommand bin}\mathbin
+\setnewconstant\mathrelcode \plusthree \letvalue{\??mathcodecommand rel}\mathrel
+\setnewconstant\mathopencode \plusfour \letvalue{\??mathcodecommand open}\mathopen
+\setnewconstant\mathclosecode \plusfive \letvalue{\??mathcodecommand close}\mathclose
+\setnewconstant\mathpunctcode \plussix \letvalue{\??mathcodecommand punct}\mathpunct
+\setnewconstant\mathalphacode \plusseven \letvalue{\??mathcodecommand alpha}\mathalpha
+\setnewconstant\mathinnercode \zerocount \letvalue{\??mathcodecommand inner}\mathinner
+\setnewconstant\mathnothingcode \zerocount \letvalue{\??mathcodecommand nothing}\mathnothing
+\setnewconstant\mathlimopcode \plusone \letvalue{\??mathcodecommand limop}\mathlimop
+\setnewconstant\mathnolopcode \plusone \letvalue{\??mathcodecommand nolop}\mathnolop
+\setnewconstant\mathboxcode \zerocount \letvalue{\??mathcodecommand box}\mathbox
+\setnewconstant\mathchoicecode \zerocount %letvalue{\??mathcodecommand choice}\mathnothing
+
+\setnewconstant\mathaccentcode \pluseight
+\setnewconstant\mathradicalcode \plusnine
+
+\permanent \def\mathcodenumber #1{\the\csname math#1code\endcsname}
+\permanent\protected\def\mathcodecommand#1{\csname\??mathcodecommand#1\endcsname}
+\permanent \def\mathcodechecked#1{\ifcsname math#1code\endcsname\lastnamedcs\else#1\fi}
+
+% \startlines
+% $\mathopnolimits{\rm d}x$
+% $\mathopnolimits{\kern\zeropoint \rm d}x$
+% $\mathcodecommand{nolop}{\rm d}x$
+% $\mathcodecommand{nolop}{\kern\zeropoint\rm d}x$
+% \blank
+% $\mathcodecommand{nolop}{\mr d}x$
+% $\mathcodecommand{nolop}{\kern\zeropoint\mr d}x$
+% $\mathop{\kern\zeropoint\mr d}x$
+% $\mathopnolimits{\kern\zeropoint d}x$
+% \stoplines
+
+\installcorenamespace{mathcommand}
+
+% todo: define these commands as frozen!
+
+\permanent\tolerant\protected\def\definemathcommand[#1]#*[#2]#*[#3]#:#*#4% command class args meaning
+ {\ifparameter#3\or
+ \edef\scratchstringone{#3}% make this one m_arguments
+ \ifx\scratchstringone\v!one
+ \frozen\protected\defcsname\??mathcommand#1\endcsname##1{\mathcodecommand{#2}{#4{##1}}}%
+ \orelse\ifx\scratchstringone\v!two
+ \frozen\protected\defcsname\??mathcommand#1\endcsname##1##2{\mathcodecommand{#2}{#4{##1}{##2}}}%
+ \else
+ \frozen\protected\defcsname\??mathcommand#1\endcsname{\mathcodecommand{#2}{#4}}%
+ \fi
+ \orelse\ifparameter#2\or
+ \frozen\protected\defcsname\??mathcommand#1\endcsname{\mathcodecommand{#2}{#4}}%
+ \else
+ \frozen\protected\defcsname\??mathcommand#1\endcsname{\mathcodecommand{nothing}{#4}}%
+ \fi
+ \ifparameter#1\or % safeguard
+ \letcsname#1\expandafter\endcsname\csname\??mathcommand#1\endcsname
+ \fi}
+
+\permanent\protected\def\mathcommand#1%
+ {\begincsname\??mathcommand#1\endcsname}
+
+%D Let's define a few comands here:
+
+%definemathcommand [mathstrut] {\vphantom{(}}
+%definemathcommand [joinrel] {\mathrel{\mkern-3mu}}
+\definemathcommand [joinrel] [rel] {\mkern-3mu}
+
+\immutable\chardef\c_math_strut"28
+
+% \protected\def\math_strut_htdp#1%
+% {\s!height\fontcharht#1\c_math_strut
+% \s!depth \fontchardp#1\c_math_strut}
+%
+% now we need this (kind of inefficient):
+
+\protected\def\math_strut_htdp#1% nasty!
+ {\s!height\dimexpr\mathscale#1\fontcharht#1\c_math_strut/\glyphscale\relax
+ \s!depth \dimexpr\mathscale#1\fontchardp#1\c_math_strut/\glyphscale\relax}
+
+\protected\def\math_strut_normal
+ {\vrule
+ \s!width \zeropoint
+ \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}%
+ \relax}
+
+\protected\def\math_strut_visual
+ {\hskip-.01\emwidth
+ \vrule
+ \s!width .02\emwidth
+ \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}%
+ \relax
+ \hskip-.01\emwidth}
+
+\permanent\protected\def\showmathstruts % let's not overload \math_strut_normal
+ {\enforced\let\math_strut\math_strut_visual}
+
+\let\math_strut\math_strut_normal
+
+% \protected\def\mathstrut{\mathcodecommand{nothing}{\math_strut}}
+
+\pushoverloadmode
+
+ \definemathcommand [mathstrut] {\math_strut}
+
+\popoverloadmode
+
+%D We could have a arg variant \unknown\ but not now.
+
+\permanent\protected\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
+\permanent\protected\def\stackrel #1#2{\mathrel{\mathop{#2}\limits^{#1}}}
+
+%D Moved from font-ini.mkiv:
+%D
+%D \macros
+%D {mf,mbox,enablembox,mathop}
+%D
+%D Todo:
+
+\permanent\protected\def\mf{\begincsname\fontalternative\endcsname} % todo: \frozen
+
+% \let\normalmathop\mathop % already defined
+
+% no longer needed as we no longer switch fonts
+%
+% \protected\def\mathop
+% {\normalmathop
+% \bgroup
+% % no: \let\rm\mf
+% \afterassignment\math_op\let\nexttoken=}
+%
+% \def\math_op{\ifx\nexttoken\bgroup\else\nexttoken\egroup\fi}
+
+% this one too: \letvalue{\??mathcodecommand op}\mathop ?
+
+\permanent\protected\def\normalmbox
+ {\normalhbox\bgroup
+ \usemathematicsstyleandcolor\c!textstyle\c!textcolor % new
+ \dowithnextboxcs\math_mbox_finish\normalhbox}
+
+\def\math_mbox_finish
+ {\flushnextbox
+ \egroup}
+
+\permanent\protected\def\mbox % we cannot add \dontleavehmode ... else no \setbox0\mbox possible
+ {\ifmmode\normalmbox\else\normalhbox\fi}
+
+\permanent\protected\def\enablembox
+ {\toksapp\everymathematics{\math_enable_mbox}}
+
+\permanent\def\math_enable_mbox % brrrr
+ {\enforced\let\hbox\mbox}
+
+\permanent\protected\def\snappedmath#1% sort of \struttedbox
+ {\dontleavehmode
+ \begingroup
+ \setbox\scratchbox\normalhbox\bgroup
+ \startimath#1\stopimath
+ \egroup
+ \ht\scratchbox\strutht
+ \dp\scratchbox\strutdp
+ \box\scratchbox
+ \endgroup}
+
+\permanent\protected\def\mtext#1%
+ {\text{\usemathematicsstyleandcolor\c!textstyle\c!textcolor#1}}
+
+%D The next hack is needed needed for sine, cosine etc.
+
+\aliased\let\mathfunction\firstofoneunexpanded
+
+\let\math_tags_function \firstofoneunexpanded
+\let\math_tags_functionlabeltext\mathlabeltext
+
+\let\math_tags_mo\firstofoneunexpanded
+\let\math_tags_mi\firstofoneunexpanded
+
+\protected\def\math_tags_mn#1{\begingroup\mathupright\math_set_o_both#1\endgroup}
+\protected\def\math_tags_ms#1{\begingroup\mathupright\math_set_p_both#1\endgroup} % why not just \text
+
+% Once this is stable we can store the number at the tex end which is
+% faster. Functions getnumbers >= 1000.
+
+% \setupmathematics[functionstyle=normal] % will give ligatures and kerning
+
+\setupmathematics
+ [\c!textstyle=, % rm ss etc i.e. known alternatives, otherwise math
+ \c!textcolor=,
+ \c!functionstyle=, % rm ss etc i.e. known alternatives, otherwise math
+ \c!functioncolor=]
+
+\protected\def\math_mfunction_styled
+ {\begingroup
+ \usemathematicscolorparameter\c!functioncolor
+ \edef\p_functionstyle{\mathematicsparameter\c!functionstyle}%
+ \ifempty\p_functionstyle
+ \expandafter\math_mfunction_styled_none
+ \orelse\ifcsname\??alternativestyle\p_functionstyle\endcsname
+ \expandafter\math_mfunction_styled_text
+ \else
+ \expandafter\math_mfunction_styled_math
+ \fi}
+
+\protected\def\math_mfunction_styled_text#1%
+ %{\mathoptext{\csname\??alternativestyle\p_functionstyle\endcsname#1}%
+ {\expandafter\mathoptext\expandafter{\lastnamedcs#1}%
+ \endgroup}
+
+\protected\def\math_mfunction_styled_math#1%
+ {\p_functionstyle
+ #1%
+ \endgroup}
+
+\protected\def\math_mfunction_styled_none#1%
+ {\mathupright
+ #1%
+ \endgroup}
+
+\permanent\protected\def\mfunction#1%
+ {\begingroup
+ \math_tags_mfunctiontxt{#1}\c_apply_function
+ \math_mfunction_styled{#1}%
+ \endgroup}
+
+\permanent\protected\def\mfunctionlabeltext#1%
+ {\begingroup
+ \math_tags_mfunctionlab{#1}\c_apply_function
+ \math_mfunction_styled{\mathlabeltext{#1}}%
+ \endgroup}
+
+\let\math_tags_mfunctiontxt\gobbletwoarguments
+\let\math_tags_mfunctionlab\gobbletwoarguments
+
+\permanent\protected\def\math_tags_mo_indeed#1{\begingroup \c_attr_mathcategory\plusone #1\endgroup}
+\permanent\protected\def\math_tags_mi_indeed#1{\begingroup \c_attr_mathcategory\plustwo #1\endgroup}
+\permanent\protected\def\math_tags_mn_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusthree\math_set_o_both#1\endgroup}
+\permanent\protected\def\math_tags_ms_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusfour \math_set_p_both#1\endgroup} % todo: mathoptext
+
+\newconditional\c_apply_function
+
+\permanent\protected\def\math_tags_apply#1#2%
+ {\begingroup
+ \settrue\c_apply_function
+ #1%
+ \endgroup
+ \begingroup
+ % todo: auto ()
+ #2%
+ \endgroup}
+
+\ifdefined\apply \else \aliased\let\apply\relax \fi
+
+\mutable\let\mo\relax
+\mutable\let\mi\relax
+\mutable\let\mn\relax
+\mutable\let\ms\relax
+
+\appendtoks
+ \enforced\let\math_tags_mfunctiontxt\clf_tagmfunctiontxt
+ \enforced\let\math_tags_mfunctionlab\clf_tagmfunctionlab
+ \enforced\let\math_tags_mo \math_tags_mo_indeed
+ \enforced\let\math_tags_mi \math_tags_mi_indeed
+ \enforced\let\math_tags_mn \math_tags_mn_indeed
+ \enforced\let\math_tags_ms \math_tags_ms_indeed
+\to \everyenableelements
+
+\appendtoks
+ \enforced\let\mo \math_tags_mo
+ \enforced\let\mi \math_tags_mi
+ \enforced\let\mn \math_tags_mn
+ \enforced\let\ms \math_tags_ms
+ \enforced\let\apply\math_tags_apply
+\to\everymathematics
+
+% \def\mlimitsfunction #1{\mathlimopcomm{{\mr#1}}
+% \def\mnolimitsfunction#1{\mathnolopcomm{{\mr#1}}
+
+% %D Taco posted this solution as response to a mail by Olivier, so let's integrate
+% %D it here.
+%
+% \def\currentmscaledstyle{rm} % will be plugged into the typeface text=ss option
+%
+% \protected\def\math_function_style_opnolimits #1{\mathop{\mscaledtext{#1}}\nolimits}
+% \protected\def\math_function_style_mfunction #1{\mscaledtext{\math_tags_function{#1}}}
+% \protected\def\math_function_style_mfunctionlabeltext#1{\mscaledtext{\math_tags_functionlabeltext{#1}}}
+%
+% \protected\def\setmathfunctionstyle#1% rm ss tt (can be made faster if needed)
+% {\doifsomething{#1}
+% {\def\currentmscaledstyle{#1}%
+% \let\mathopnolimits \math_function_style_opnolimits
+% \let\mfunction \math_function_style_mfunction
+% \let\mfunctionlabeltext\math_function_style_mfunctionlabeltext}}
+
+\mutable\def\currentmscaledstyle{rm} % will be plugged into the typeface text=ss option
+
+\permanent\protected\def\mscaledtext#1%
+ {\mathchoice
+ {\hbox{\csname\currentmscaledstyle\endcsname\tf #1}}
+ {\hbox{\csname\currentmscaledstyle\endcsname\tf #1}}
+ {\hbox{\csname\currentmscaledstyle\endcsname\tfx #1}}
+ {\hbox{\csname\currentmscaledstyle\endcsname\tfxx#1}}}
+
+\permanent\protected\def\setmathfunctionstyle#1%
+ {\setupmathematics[\c!functionstyle=#1]} % for old times sake
+
+%D Usage:
+%D
+%D \starttyping
+%D \setmathfunctionstyle\fontstyle % or {rm} or {ss} or ..
+%D \rm test $\sin{(x^{\sin(x^{\sin(x)})})}$ test
+%D \ss test $\sin{(x^{\sin(x^{\sin(x)})})}$ test
+%D \tt test $\sin{(x^{\sin(x^{\sin(x)})})}$ test
+%D \stoptyping
+
+%D \macros
+%D {nonknuthmode, donknuthmode}
+%D
+%D The underscore is frequently used in manuals but unfortunately \TEX\ prefers
+%D it to be a math specific character. And since computer modern fonts didn't
+%D have an underscore, one had to use commands to fake one. Nowadays we do
+%D have underscores in latin modern, and since all other fonts have them, we
+%D decided to get away from the restriction to use the underscore character in
+%D text mode.
+%D
+%D \starttyping
+%D \def\test#1{#1}
+%D
+%D \nonknuthmode $x_2$ x_2 \test{$x_2$} \test{x_2}
+%D
+%D \donknuthmode $x_2$ x_2 \test{$x_2$} \test{x_2}
+%D \stoptyping
+%D
+%D The result is as expected: the first line typesets ok, while the second
+%D one triggers an error message.
+
+\setnewconstant\activemathcharcode "8000
+
+\newtoks\activatedmathcharacters
+
+\permanent\protected\def\activatemathcharacter#1%
+ {\appendtoks
+ \global\mathcode#1=\activemathcharcode
+ \to \activatedmathcharacters}
+
+\permanent\def\activatemathcharacters
+ {\the\activatedmathcharacters}
+
+% beware, not runtime, so has to happen at format generation
+
+\activatemathcharacter\circumflexasciicode
+\activatemathcharacter\underscoreasciicode
+\activatemathcharacter\ampersandasciicode
+
+\permanent\def\normalmathaligntab{&} % \let\normalmathaligntab\aligntab does to work well in a let to & (a def works ok)
+
+\appendtoks
+ \edef\p_ampersand{\mathematicsparameter\s!ampersand}%
+ \ifx\p_ampersand\v!normal
+ \enforced\let\specialmathaligntab\normalmathaligntab
+ \else
+ \enforced\let\specialmathaligntab\mathampersand
+ \fi
+\to \everysetupmathematics
+
+%D A simplified version of this code is:
+%D
+%D \starttyping
+%D \catcode"26=12
+%D
+%D \bgroup
+%D \global\mathcode"26="8000
+%D
+%D \catcode"26=4
+%D
+%D \xdef\normalmathaligntab{&}
+%D
+%D \catcode"26=13
+%D
+%D \global\everymath{\def&{\normalmathaligntab}}
+%D \egroup
+%D \stoptyping
+%D
+%D The following works okay:
+%D
+%D \starttyping
+%D A & B
+%D \stoptyping
+%D
+%D As does:
+%D
+%D \starttyping
+%D $A \Umathchar"2"0"26 B$
+%D \stoptyping
+%D
+%D But the next code:
+%D
+%D \starttyping
+%D $A \char"26 B$
+%D \stoptyping
+%D
+%D fails with: \type{Misplaced alignment tab character &} and here is the
+%D reason.
+%D
+%D When we have a letter or other category a check happens for an active
+%D character and when it has one then it gets expanded and fed back into the
+%D scanner (sort of).
+%D
+%D A \type {\char} is also fed back as raw character and again when it's letter
+%D of other goes through the same process.
+%D
+%D This means that we cannot have a definition like:
+%D
+%D \starttyping
+%D \def\AND{\char"26\relax}
+%D \stoptyping
+%D
+%D that can be used in math mode, which is why the cweb macros do:
+%D
+%D \starttyping
+%D \def\AND{\def\AND{\mathchar"2026\relax}\AND}
+%D \stoptyping
+%D
+%D Maybe we need an option to treat chars like chars.
+
+% \activatemathcharacter\primeasciicode
+
+% not used:
+%
+% \mathcode\spaceasciicode\activemathcharcode
+%
+% not used:
+%
+% \bgroup
+% \catcode\underscoreasciicode\activecatcode
+% \doglobal\appendtoks
+% \mathcode\underscoreasciicode\activemathcharcode
+% \let_\activemathunderscore
+% \to \everymathematics
+% \egroup
+
+% Here follows some plain legacy: primes.
+%
+% The \let\prime\math_prime_indeed might become an obsolete as we have \doubleprime
+% and \tripleprime and collapsing can nicely handle the script then.
+%
+% Collapsing to 0x2033 and 0x2034 happens elsewhere.
+%
+% \switchtobodyfont[modern]
+% \switchtobodyfont[cambria]
+% \switchtobodyfont[xits]
+% \switchtobodyfont[minion]
+% \setupbodyfont[dejavu]
+%
+% \startbuffer
+% \def\SampleLine#1{%
+% \NC#1
+% \NC\switchtobodyfont[#1]$f^2$ % 1
+% \NC\switchtobodyfont[#1]$f\prime^2$ % 2
+% \NC\switchtobodyfont[#1]$f\prime\prime^2$ % 3
+% \NC\switchtobodyfont[#1]$f\prime\prime\prime^2$ % 4
+% \NC\switchtobodyfont[#1]$f{\prime}^2$ % 5
+% \NC\switchtobodyfont[#1]$f{\prime\prime}^2$ % 6
+% \NC\switchtobodyfont[#1]$f{\prime\prime\prime}^2$ % 7
+% \NC\switchtobodyfont[#1]$f'(x)$ % 8
+% \NC\switchtobodyfont[#1]$f''(x)$ % 9
+% \NC\switchtobodyfont[#1]$f'''(x)$ % 10
+% \NC\NR
+% }
+%
+% \starttabulate[|Tl|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|Tc|]
+% \NC\NC1\NC2\NC3\NC4\NC5\NC6\NC7\NC8\NC9\NC10\NC\NR
+% \SampleLine{modern}
+% \SampleLine{cambria}
+% \SampleLine{xits}
+% \SampleLine{minion}
+% \stoptabulate
+% \stopbuffer
+%
+% \typebuffer \getbuffer
+
+% most math fonts have messed up primes, just test this: $\prime^{\prime^{\prime}}$
+
+{ \catcode\circumflexasciicode\othercatcode \immutable\glet\othercircumflextoken ^ }
+{ \catcode\circumflexasciicode\superscriptcatcode \immutable\glet\superscriptcircumflextoken^ }
+
+\ifdefined \prime \else
+ \Umathchardef\prime "0 "0 "2032
+\fi
+
+% \let\math_prime_indeed_normal\prime
+%
+% \appendtoks
+% \let\math_prime_indeed_normal\prime % gets defined later
+% \let\mathfontprime\prime % for tracing
+% \let\prime\math_prime_indeed % so this is needed
+% \to \everydump
+%
+% \protected\def\math_prime_indeed
+% {\iffontchar\textfont\zerocount"FE325\relax
+% ^\bgroup
+% \expandafter\math_prime_indeed_virtual % virtual mess (using funny signal)
+% \else
+% % \expandafter\math_prime_indeed_normal % gets collapsed
+% \expandafter\math_prime_indeed_crapped % gets collapsed
+% \fi}
+%
+% \def\math_prime_indeed_crapped
+% {{^{\math_prime_indeed_normal}}}
+%
+% % \let\prime\math_prime_indeed
+%
+% \def\math_prime_indeed_virtual
+% {\math_prime_indeed_normal
+% \futurelet\nexttoken\math_prime_indeed_choice}
+%
+% \installcorenamespace{mathprime}
+%
+% \def\math_prime_indeed_choice
+% {\csname\??mathprime
+% \ifx '\nexttoken a\else
+% \ifx \math_prime_indeed_normal\nexttoken a\else
+% \ifx \prime\nexttoken a\else
+% \ifx\superscriptcircumflextoken\nexttoken b\else
+% \ifx\othercircumflextoken \nexttoken b\else
+% c\fi\fi\fi\fi\fi
+% \endcsname}
+%
+% \setvalue{\??mathprime a}#1{\math_prime_indeed_virtual}
+% \setvalue{\??mathprime b}#1#2{#2\egroup}
+% \setvalue{\??mathprime c}{\egroup}
+%
+% \let\activemathprime\math_prime_indeed
+%
+% \bgroup
+%
+% \catcode\primeasciicode\activecatcode
+%
+% \global\everymathematics\expandafter{\the\everymathematics\let'\math_prime_indeed} % todo: do this at the lua end
+%
+% \egroup
+
+% $\char26$ gives an error because it expands to an active character that
+% then becomes an & which is then seen as an alignment character; anyway,
+% even when we switch like this the different meaning only happens when
+% we're in math mode which can be delayed till we're in a cell
+
+\bgroup
+
+ \catcode\underscoreasciicode\activecatcode
+ \catcode\circumflexasciicode\activecatcode
+ \catcode\ampersandasciicode \activecatcode
+
+ \aliased\glet\specialmathaligntab\normalmathaligntab
+
+ \permanent\protected\gdef\obeymathcatcodes{%
+ \enforced\let _\normalsubscript
+ \enforced\let ^\normalsuperscript
+ \enforced\def &\specialmathaligntab
+ }
+
+ \doglobal\appendtoks
+ \enforced\let _\normalsubscript
+ \enforced\let ^\normalsuperscript
+ \enforced\let &\specialmathaligntab
+ \to \everymathematics
+
+ % \permanent\protected\gdef\normalmathampersands
+ % {\let\specialmathaligntab\mathampersand}
+
+\egroup
+
+\newtoks\everydonknuthmode
+\newtoks\everynonknuthmode
+
+\newconditional \knuthmode
+
+\aliased\let\nonknuthmode\relax % no longer needed in MkIV
+\aliased\let\donknuthmode\relax % no longer needed in MkIV
+
+% \def\nonknuthmode
+% {\pushcatcodetable
+% \setcatcodetable\ctxcatcodes
+% \the\everynonknuthmode
+% \let\nonknuthmode\relax
+% \popcatcodetable}
+%
+% \def\donknuthmode
+% {\pushcatcodetable
+% \setcatcodetable\ctxcatcodes
+% \the\everydonknuthmode
+% \popcatcodetable}
+%
+% \bgroup
+%
+% \catcode\underscoreasciicode\activecatcode
+% \catcode\circumflexasciicode\activecatcode
+% \catcode\ampersandasciicode \activecatcode
+%
+% \global \everynonknuthmode {\appendtoks
+% \let_\normalsubscript
+% \let^\normalsuperscript
+% \let&\normalmathaligntab % use \def when it's \aligntab
+% \to \everymathematics}
+%
+% \egroup
+%
+% \appendtoks
+% \setfalse\knuthmode
+% \catcode\underscoreasciicode\othercatcode
+% \catcode\circumflexasciicode\othercatcode
+% \catcode\ampersandasciicode \othercatcode
+% \to \everynonknuthmode
+%
+% \appendtoks
+% \settrue\knuthmode
+% \catcode\underscoreasciicode\subscriptcatcode
+% \catcode\circumflexasciicode\superscriptcatcode
+% \catcode\ampersandasciicode \alignmentcatcode
+% \to \everydonknuthmode
+%
+% \appendtoks
+% \startextendcatcodetable\ctxcatcodes
+% \catcode\underscoreasciicode\othercatcode
+% \catcode\circumflexasciicode\othercatcode
+% \catcode\ampersandasciicode \othercatcode
+% \stopextendcatcodetable
+% \to \everynonknuthmode
+%
+% \appendtoks
+% \startextendcatcodetable\ctxcatcodes
+% \catcode\underscoreasciicode\subscriptcatcode
+% \catcode\circumflexasciicode\superscriptcatcode
+% \catcode\ampersandasciicode \alignmentcatcode
+% \stopextendcatcodetable
+% \to \everydonknuthmode
+
+%D Even more drastic (this code will move as nonknuthmode is default now)
+
+% \protected\def\enableasciimode
+% {\ctxlua{resolvers.macros.enablecomment()}%
+% \glet\enableasciimode\relax}
+%
+% \protected\def\asciimode
+% {\catcodetable\txtcatcodes
+% \enableasciimode
+% \nonknuthmode}
+%
+% \protected\def\startasciimode
+% {\pushcatcodetable
+% \catcodetable\txtcatcodes
+% \enableasciimode
+% \nonknuthmode}
+%
+% \protected\def\stopasciimode
+% {\popcatcodetable
+% \ifconditional\knuthmode\else\donknuthmode\fi}
+
+\permanent\protected\def\enableasciimode
+ {\clf_enableasciimode} % relaxes itself
+
+\permanent\protected\def\asciimode
+ {\catcodetable\txtcatcodes
+ \clf_enableasciimode}
+
+\permanent\protected\def\startasciimode
+ {\pushcatcodetable
+ \catcodetable\txtcatcodes
+ \clf_enableasciimode}
+
+\permanent\protected\def\stopasciimode
+ {\popcatcodetable}
+
+%D Needed for unicode:
+
+\permanent\def\nulloperator{\mathortext{\mathop{\emptyhbox}}{\emptyhbox}}
+
+%D Memory saver:
+
+\def\math_basics_check_compact
+ {\doifelse{\mathematicsparameter\c!compact}\v!yes
+ \enabledirectives\disabledirectives[math.virtual.optional]}
+
+\appendtoks
+ \ifempty\currentmathematics
+ \math_basics_check_compact % less tracing
+ \fi
+\to \everysetupmathematics
+
+\setupmathematics
+ [\c!compact=\v!no]
+
+% \enabletrackers[typesetters.directions.math]
+
+%D Right||to||left typesetting in math is supported by the \type {align} parameter
+%D with as option the \type {bidi} parameter. Of course support for special symbols
+%D like square roots depends on the font as well. We probably need to mirror a few
+%D more characters.
+%D
+%D \startbuffer
+%D \removeunwantedspaces
+%D \m{ ( 1 = 1) }\quad
+%D \m{ (123 = 123) }\quad
+%D \m{ a ( 1 = 1) b }\quad
+%D \m{ a (123 = 123) b }\quad
+%D \m{ x = 123 y + (1 / \sqrt {x}) }
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \starttabulate[|T|T||]
+%D \HL
+%D \NC align \NC bidi \NC \NC \NR
+%D \HL
+%D \NC l2r \NC no \NC \setupmathematics[bidi=no] \getbuffer \NC \NR
+%D \NC l2r \NC yes \NC \setupmathematics[bidi=yes] \getbuffer \NC \NR
+%D \NC r2l \NC no \NC \setupmathematics[align=r2l,bidi=no] \getbuffer \NC \NR
+%D \NC r2l \NC yes \NC \setupmathematics[align=r2l,bidi=yes] \getbuffer \NC \NR
+%D \HL
+%D \stoptabulate
+
+% We will use proper constants when we go numbers instead of XXX.
+
+\newconditional\c_math_right_to_left
+
+\installcorenamespace{mathaligndirection}
+
+\setvalue{\??mathaligndirection r2l}{\settrue\c_math_right_to_left}
+\setvalue{\??mathaligndirection\v!righttoleft}{\settrue\c_math_right_to_left}
+
+\appendtoks
+ \ifcsname\??mathaligndirection\mathematicsparameter\c!align\endcsname
+ \lastnamedcs
+ \else
+ \setfalse\c_math_right_to_left
+ \fi
+\to \everyswitchmathematics
+
+\protected\def\math_basics_synchronize_direction
+ {\mathdirection\ifconditional\c_math_right_to_left\directionrighttoleft\else\directionlefttoright\fi}
+
+% Not \everymathematics as it comes too late and I'm not in the mood for a mixed mode
+% kludge now (should be a property of beginmath nodes and passed to callbacks).
+
+\appendtoks
+ \math_basics_synchronize_direction
+\to \everyswitchmathematics
+
+% experimental (needed for an article)
+
+\installcorenamespace {mathbidi}
+
+\newcount\c_math_bidi
+
+\def\math_bidi_enable {\clf_setmathdirection\plusone \relax\c_math_bidi\plusone}
+\def\math_bidi_disable{\clf_setmathdirection\zerocount\relax\c_math_bidi\attributeunsetvalue}
+
+\letvalue{\??mathbidi\v!yes}\math_bidi_enable
+\letvalue{\??mathbidi\v!no }\math_bidi_disable
+
+\appendtoks
+ \edef\p_bidi{\mathematicsparameter\c!bidi}% still needed ?
+ \ifcsname\??mathbidi\p_bidi\endcsname\lastnamedcs\else\math_bidi_disable\fi
+\to \everysetupmathematics
+
+\appendtoks
+ \c_attr_mathbidi\ifconditional\c_math_right_to_left\c_math_bidi\else\attributeunsetvalue\fi
+\to \everyswitchmathematics
+
+%D Delayed: greek.
+%D
+%D \starttyping
+%D \usetypescript[cambria]\setupbodyfont[cambria]
+%D \startTEXpage
+%D $\alpha \mathgreekupright \alpha \mathgreekitalic \alpha$
+%D \stopTEXpage
+%D \stoptyping
+
+% [lc uc] normal (upright) = 2, italic = 3, none = 0/1
+
+% We can move the setting to the lua end and use abstract numbers instead
+% if funny ones here.
+
+\installcorenamespace{mathgreek}
+
+\newconstant\c_math_greek_attribute
+
+\setvalue{\??mathgreek\v!none }{1}
+\setvalue{\??mathgreek\v!normal}{2}
+\setvalue{\??mathgreek\v!italic}{3}
+
+% \appendtoks
+% \edef\p_sygreek{\mathematicsparameter\s!sygreek}%
+% \edef\p_lcgreek{\mathematicsparameter\s!lcgreek}%
+% \edef\p_ucgreek{\mathematicsparameter\s!ucgreek}%
+% \c_math_greek_attribute"% hex digits
+% \csname\??mathgreek\ifcsname\??mathgreek\p_sygreek\endcsname\p_sygreek\else\v!none\fi\endcsname
+% \csname\??mathgreek\ifcsname\??mathgreek\p_lcgreek\endcsname\p_lcgreek\else\v!none\fi\endcsname
+% \csname\??mathgreek\ifcsname\??mathgreek\p_ucgreek\endcsname\p_ucgreek\else\v!none\fi\endcsname
+% \relax
+% \ifcase\c_math_greek_attribute
+% \c_math_greek_attribute\attributeunsetvalue
+% \fi
+% \to \everyswitchmathematics
+
+\appendtoks
+ \edef\p_sygreek{\mathematicsparameter\s!sygreek}% still needed ?
+ \edef\p_lcgreek{\mathematicsparameter\s!lcgreek}% still needed ?
+ \edef\p_ucgreek{\mathematicsparameter\s!ucgreek}% still needed ?
+ \c_math_greek_attribute"% hex digits
+ \ifcsname\??mathgreek\p_sygreek\endcsname\lastnamedcs\else1\fi
+ \ifcsname\??mathgreek\p_lcgreek\endcsname\lastnamedcs\else1\fi
+ \ifcsname\??mathgreek\p_ucgreek\endcsname\lastnamedcs\else1\fi
+ \relax
+ \ifcase\c_math_greek_attribute
+ \c_math_greek_attribute\attributeunsetvalue
+ \fi
+\to \everyswitchmathematics
+
+% only used local
+
+\permanent\protected\def\mathgreekupright{\c_attr_mathgreek"222\relax}
+\permanent\protected\def\mathgreekitalic {\c_attr_mathgreek"333\relax}
+\permanent\protected\def\mathgreekdefault{\c_attr_mathgreek"000\relax}
+
+\aliased\let\mathgreeknormal\mathgreekupright
+\aliased\let\mathgreeknone \mathgreekdefault
+
+\appendtoks
+ \c_attr_mathgreek\c_math_greek_attribute
+\to \everymathematics
+
+\setupmathematics
+ [\s!sygreek=\v!normal,
+ \s!lcgreek=\v!italic,
+ \s!ucgreek=\v!normal] % was: none
+
+%D Math collapsing (ligatures)
+
+\installcorenamespace{mathcollapsing}
+
+\setnewconstant\c_math_collapsing_attribute\attributeunsetvalue
+
+\letvalue{\??mathcollapsing 1}\plusone % specials
+\letvalue{\??mathcollapsing 2}\plustwo % specials + mathlist
+\letvalue{\??mathcollapsing 3}\plusthree % mathlist + specials
+\letvalue{\??mathcollapsing\v!none }\attributeunsetvalue
+\letvalue{\??mathcollapsing\v!reset}\attributeunsetvalue
+
+\def\math_collapsing_initialize
+ {\ifnum\c_math_collapsing_attribute=\attributeunsetvalue \else
+ \clf_initializemathcollapsing % one time
+ \glet\math_collapsing_initialize\relax
+ \fi}
+
+\appendtoks
+ \edef\p_collapsing{\mathematicsparameter\s!collapsing}%
+ \c_math_collapsing_attribute
+ \ifcsname\??mathcollapsing\p_collapsing\endcsname\lastnamedcs\else\attributeunsetvalue\fi
+ \relax
+\to \everyswitchmathematics % only in mathematics
+
+\appendtoks
+ \math_collapsing_initialize
+ \c_attr_mathcollapsing\c_math_collapsing_attribute
+\to \everymathematics
+
+\setupmathematics
+ [\s!collapsing=1] % so that we at least do primes
+
+%D Math italics (experiment)
+
+%D We need keys but what names to use and because we have hardcoded solution
+%D we can stick to numbers.
+
+\installcorenamespace{mathitalics}
+
+\setnewconstant\c_math_italics_attribute\attributeunsetvalue
+
+\letvalue{\??mathitalics 1}\plusone % fontitalics
+\letvalue{\??mathitalics 2}\plustwo % fontdata
+\letvalue{\??mathitalics 3}\plusthree % quad based
+\letvalue{\??mathitalics 4}\plusfour % combination of 1 and 3
+\letvalue{\??mathitalics\v!none }\attributeunsetvalue
+\letvalue{\??mathitalics\v!reset}\attributeunsetvalue
+
+\def\math_italics_initialize
+ {\ifnum\c_math_italics_attribute=\attributeunsetvalue \else
+ \clf_initializemathitalics % one time
+ \glet\math_italics_initialize\relax
+ \fi}
+
+\appendtoks
+ \edef\p_italics{\mathematicsparameter\s!italics}%
+ \c_math_italics_attribute
+ \ifcsname\??mathitalics\p_italics\endcsname\lastnamedcs\else\attributeunsetvalue\fi
+ \relax
+ % \math_italics_initialize
+\to \everyswitchmathematics % only in mathematics
+
+\appendtoks
+ \math_italics_initialize
+ \c_attr_mathitalics\c_math_italics_attribute
+\to \everymathematics
+
+% \setupmathematics % done later
+% [\s!italics=3] % 4 is probably better
+
+% looks nicer but can generate bogus csnames
+%
+% \setvalue{\??mathitalics1}{\math_italics_initialize\c_math_italics_attribute\plusone } % fontitalics
+% \setvalue{\??mathitalics2}{\math_italics_initialize\c_math_italics_attribute\plustwo } % fontdata
+% \setvalue{\??mathitalics3}{\math_italics_initialize\c_math_italics_attribute\plusthree} % quad based
+% \setvalue{\??mathitalics4}{\math_italics_initialize\c_math_italics_attribute\plusfour } % combination of 1 and 3
+%
+% \appendtoks
+% \c_math_italics_attribute\attributeunsetvalue
+% \csname\??mathitalics\mathematicsparameter\s!italics\endcsname
+% \to \everyswitchmathematics % only in mathematics
+
+%D Math kerns (experiment)
+
+\installcorenamespace{mathkernpairs}
+
+\setnewconstant\c_math_kernpairs_attribute\attributeunsetvalue % no real need for an extra constant
+
+\def\math_kernpairs_initialize
+ {\ifnum\c_math_kernpairs_attribute=\attributeunsetvalue \else
+ \clf_initializemathkernpairs % one time
+ \glet\math_kernpairs_initialize\relax
+ \fi}
+
+\appendtoks
+ \edef\p_kernpairs{\mathematicsparameter\s!kernpairs}%
+ \c_math_kernpairs_attribute\ifx\p_kernpairs\v!yes\plusone\else\attributeunsetvalue\fi\relax
+\to \everyswitchmathematics % only in mathematics
+
+\appendtoks
+ \math_kernpairs_initialize
+ \c_attr_mathkernpairs\c_math_kernpairs_attribute
+\to \everymathematics
+
+\setupmathematics
+ [\s!kernpairs=\v!no]
+
+%D \macros
+%D {enablemathpunctuation,disablemathpunctuation}
+%D
+%D \startbuffer
+%D \enablemathpunctuation$(1,2) (1, 2) (1{,}2) \hbox{foo, not bar}$
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \blank{\getbuffer}\blank
+
+% \newconditional\automathpunctuation
+%
+% \protected\def\enablemathpunctuation {\settrue \automathpunctuation}
+% \protected\def\disablemathpunctuation{\setfalse\automathpunctuation}
+%
+% \appendtoks
+% \doifelse{\mathematicsparameter\v!autopunctuation}\v!yes\settrue\setfalse\automathpunctuation
+% \to \everyswitchmathematics
+%
+% \setupmathematics
+% [\v!autopunctuation=\v!no]
+%
+% \def\math_punctuation_next{\ifx\nexttoken\blankspace\signalcharacter\fi}
+%
+% \protected\def\math_punctuation_comma {\textcomma \futurelet\nexttoken\math_punctuation_next}
+% \protected\def\math_punctuation_period{\textperiod\futurelet\nexttoken\math_punctuation_next}
+%
+% \setnewconstant\c_math_comma "002C
+% \setnewconstant\c_math_period "002E
+% \setnewconstant\c_math_special"8000
+%
+% \bgroup
+%
+% \catcode\c_math_comma \activecatcode
+% \catcode\c_math_period\activecatcode
+%
+% \protected\gdef\math_punctuation_initialize_indeed
+% {\mathcode\c_math_comma \c_math_special
+% \mathcode\c_math_period\c_math_special
+% \let,\math_punctuation_comma
+% \let.\math_punctuation_period
+% \c_attr_mathpunctuation\plustwo}
+%
+% \protected\gdef\math_punctuation_initialize_yes
+% {\c_attr_mathpunctuation\plustwo}
+%
+% \protected\gdef\math_punctuation_initialize_nop
+% {\c_attr_mathpunctuation\plusone}
+%
+% \egroup
+%
+% \appendtoks
+% \ifconditional\automathpunctuation
+% \math_punctuation_initialize_indeed
+% \math_punctuation_initialize_yes
+% \let\enablemathpunctuation \math_punctuation_initialize_yes
+% \let\disablemathpunctuation\math_punctuation_initialize_nop
+% \fi
+% \to \everymathematics
+
+% Later I will look again into a \LUATEX\ based solution. It only makes sense
+% to delegate to \LUA\ when we have more variants and need analysis (experimental
+% trickery removed for a while).
+
+% \def\math_punctuation_comma_next {\ifx\nexttoken\blankspace\mathpunct\else\mathord\fi{\textcomma }}
+% \def\math_punctuation_period_next{\ifx\nexttoken\blankspace\mathpunct\else\mathord\fi{\textperiod}}
+%
+% \protected\def\math_punctuation_nop_comma {\mathpunct{\textcomma}}
+% \protected\def\math_punctuation_nop_period{\mathord{\textperiod}}
+%
+% \protected\def\math_punctuation_all_comma {\futurelet\nexttoken\math_punctuation_comma_next}
+% \protected\def\math_punctuation_all_period{\futurelet\nexttoken\math_punctuation_period_next}
+%
+% \let\math_punctuation_yes_comma \math_punctuation_all_comma
+% \let\math_punctuation_yes_period\math_punctuation_nop_period
+%
+% The next one is more efficient as it produces more flat noad lists for numbers.
+
+\setnewconstant\c_math_comma "002C
+\setnewconstant\c_math_period "002E
+%setnewconstant\c_math_colon "003A
+\setnewconstant\c_math_semicolon"003B
+\setnewconstant\c_math_special "8000
+
+% todo: use \Umathclass\c_math_comma\mathpunctcode etc for temporary switching
+
+\def\math_set_o_comma {\Umathcode\c_math_comma \mathordcode \zerocount\c_math_comma}
+\def\math_set_p_comma {\Umathcode\c_math_comma \mathpunctcode\zerocount\c_math_comma}
+\def\math_set_o_period {\Umathcode\c_math_period \mathordcode \zerocount\c_math_period}
+\def\math_set_p_period {\Umathcode\c_math_period \mathpunctcode\zerocount\c_math_period}
+\def\math_set_o_semicolon{\Umathcode\c_math_semicolon\mathordcode \zerocount\c_math_semicolon}
+\def\math_set_p_semicolon{\Umathcode\c_math_semicolon\mathpunctcode\zerocount\c_math_semicolon}
+
+\edef\math_set_o_both {\math_set_o_period\math_set_o_comma}
+\edef\math_set_p_both {\math_set_p_period\math_set_p_comma}
+
+\protected\def\math_punctuation_nop_comma {\begingroup\math_set_p_comma ,\endgroup}
+\protected\def\math_punctuation_nop_period {\begingroup\math_set_o_period .\endgroup}
+\protected\def\math_punctuation_nop_semicolon{\begingroup\math_set_p_semicolon;\endgroup}
+
+% todo: use new lookahead stuff
+
+\protected\def\math_punctuation_all_comma {\futurelet\nexttoken\math_punctuation_comma_next}
+\protected\def\math_punctuation_all_period {\futurelet\nexttoken\math_punctuation_period_next}
+\protected\def\math_punctuation_all_semicolon{\futurelet\nexttoken\math_punctuation_semicolon_next}
+
+ \let\math_punctuation_yes_comma \math_punctuation_all_comma
+ \let\math_punctuation_yes_period \math_punctuation_nop_period
+ \let\math_punctuation_yes_semicolon\math_punctuation_all_semicolon
+
+\def\math_punctuation_comma_next {\begingroup\Umathcode\c_math_comma \ifx\nexttoken\blankspace\mathordcode\else\mathordcode\fi\zerocount\c_math_comma ,\endgroup}
+\def\math_punctuation_period_next {\begingroup\Umathcode\c_math_period \ifx\nexttoken\blankspace\mathordcode\else\mathordcode\fi\zerocount\c_math_period .\endgroup}
+\def\math_punctuation_semicolon_next{\begingroup\Umathcode\c_math_semicolon\ifx\nexttoken\blankspace\mathordcode\else\mathordcode\fi\zerocount\c_math_semicolon;\endgroup}
+
+\installcorenamespace {mathautopunctuation}
+
+\bgroup
+
+ \catcode\c_math_comma \activecatcode
+ \catcode\c_math_period \activecatcode
+ \catcode\c_math_semicolon\activecatcode
+
+ \setgvalue{\??mathautopunctuation\v!no}%
+ {\let,\math_punctuation_nop_comma
+ \let.\math_punctuation_nop_period
+ \let;\math_punctuation_nop_semicolon}
+
+ % more efficient list:
+ %
+ % \setgvalue{\??mathautopunctuation\v!no}%
+ % {\Umathcode\c_math_period\mathordcode \zerocount\c_math_period
+ % \Umathcode\c_math_comma \mathpunctcode\zerocount\c_math_comma }
+
+ \setgvalue{\??mathautopunctuation\v!yes}%
+ {\let,\math_punctuation_yes_comma
+ \let.\math_punctuation_yes_period
+ \let;\math_punctuation_nop_semicolon}
+
+ \setgvalue{\??mathautopunctuation\v!all}%
+ {\let,\math_punctuation_all_comma
+ \let.\math_punctuation_all_period
+ \let;\math_punctuation_nop_semicolon}
+
+ \setgvalue{\??mathautopunctuation comma}%
+ {\let,\math_punctuation_yes_comma
+ \let.\math_punctuation_yes_period
+ \let;\math_punctuation_nop_semicolon}
+
+ \setgvalue{\??mathautopunctuation\v!yes\string,semicolon}%
+ {\let,\math_punctuation_yes_comma
+ \let.\math_punctuation_yes_period
+ \let;\math_punctuation_yes_semicolon}
+
+ \setgvalue{\??mathautopunctuation comma\string,semicolon}%
+ {\let,\math_punctuation_yes_comma
+ \let.\math_punctuation_yes_period
+ \let;\math_punctuation_yes_semicolon}
+
+ \setgvalue{\??mathautopunctuation\v!all\string,semicolon}%
+ {\let,\math_punctuation_all_comma
+ \let.\math_punctuation_all_period
+ \let;\math_punctuation_all_semicolon}
+
+\egroup
+
+% \appendtoks
+% \global\mathcode\c_math_comma \c_math_special
+% \global\mathcode\c_math_period \c_math_special
+% \global\mathcode\c_math_semicolon\c_math_special
+% \to \everyjob
+
+% \activatemathcharacter\c_math_comma
+% \activatemathcharacter\c_math_period
+% \activatemathcharacter\c_math_semicolon
+
+\appendtoks
+ \mathcode\c_math_comma \c_math_special
+ \mathcode\c_math_period \c_math_special
+ \mathcode\c_math_semicolon\c_math_special
+ \begincsname\??mathautopunctuation\mathematicsparameter\v!autopunctuation\endcsname
+\to \everymathematics
+
+\appendtoks
+ \ifcsname\??mathautopunctuation\mathematicsparameter\v!autopunctuation\endcsname \else
+ \letmathematicsparameter\v!autopunctuation\v!no
+ \fi
+\to \everysetupmathematics
+
+\permanent\protected\def\enablemathpunctuation {\csname\??mathautopunctuation\v!no \endcsname}
+\permanent\protected\def\disablemathpunctuation{\csname\??mathautopunctuation\v!yes\endcsname}
+
+\setupmathematics
+ [\v!autopunctuation=\v!no] % no | yes | all | comma | yes,semicolon | all,semicolon
+
+%D The consequences of setting this are as follows:
+%D
+%D \def\TestA#1#2#3%
+%D {\ifnum#1=0 \type{#2}\else\setupmathematics[autopunctuation={#2}]$#3$\fi}
+%D \def\TestB#1#2%
+%D {\NC \TestA{#1}{no} {#2}
+%D \NC \TestA{#1}{yes} {#2}
+%D \NC \TestA{#1}{yes,semicolon}{#2}
+%D \NC \TestA{#1}{all} {#2}
+%D \NC \TestA{#1}{all,semicolon}{#2}
+%D \NC \NR}
+%D \starttabulate[|c|c|c|c|c|]
+%D \TestB{0}{}
+%D \TestB{1}{(1,2)=(1, 2)}
+%D \TestB{1}{(1.2)=(1. 2)}
+%D \TestB{1}{(1;2)=(1; 2)}
+%D \stoptabulate
+
+%D \macros
+%D {mathstyle}
+%D
+%D If one want to be sure that something is typeset in the appropriate style, \type
+%D {\mathstyle} can be used:
+%D
+%D \starttyping
+%D \mathstyle{something}
+%D \stoptyping
+
+% \def\mathstyle#1%
+% {\mathchoice
+% {\displaystyle #1}%
+% {\textstyle #1}%
+% {\scriptstyle #1}%
+% {\scriptscriptstyle#1}}
+%
+% We now have a primitive operation for this. As the macro overloads a new
+% primitive introduced in \LUATEX, we need to use \type {\normalmathstyle} when we
+% consult the current math style.
+%
+% \let \mathstyle \Ustack % spoils cramped
+%
+% \let \mathstyle \firstofoneargument
+%
+% 0 = display
+% 1 = crampeddisplay
+% 2 = text
+% 3 = crampedtext
+% 4 = script
+% 5 = crampedscript
+% 6 = scriptscript
+% 7 = crampedscriptscript
+
+\permanent\def\uncramped#1%
+ {{\ifmathstyle
+ \or \displaystyle \or
+ \or \textstyle \or
+ \or \scriptstyle \or
+ \or \scriptscriptstyle \fi
+ #1}}
+
+\permanent\def\cramped#1%
+ {{\ifmathstyle
+ \crampeddisplaystyle \or \or % 0 -> 1
+ \crampedtextstyle \or \or % 2 -> 3
+ \crampedscriptstyle \or \or % 4 -> 5
+ \crampedscriptscriptstyle \fi % 6 -> 7
+ #1}}
+
+\permanent\def\triggermathstyle#1{\Ustyle\numexpr#1\relax}
+%permanent\def\mathstyletrigger#1{\numexpr#1\relax}
+\permanent\let\mathstyletrigger \firstofoneargument
+
+\permanent\def\triggeredmathstyleparameter#1% to bypass the relax
+ {\ifcase\numexpr\normalmathstyle\relax
+ #1\displaystyle \or % 0
+ #1\crampeddisplaystyle \or % 1
+ #1\textstyle \or % 2
+ #1\crampedtextstyle \or % 3
+ #1\scriptstyle \or % 4
+ #1\crampedscriptstyle \or % 5
+ #1\scriptscriptstyle \or % 6
+ #1\crampedscriptscriptstyle \else
+ % error
+ \fi}
+
+\permanent\def\mathstylefont#1% #1 is number (\normalmathstyle)
+ {\ifcase\numexpr#1\relax
+ \textfont \or
+ \textfont \or
+ \textfont \or
+ \textfont \or
+ \scriptfont \or
+ \scriptfont \or
+ \scriptscriptfont \or
+ \scriptscriptfont \else
+ \textfont
+ \fi\fam} % was \zerocount
+
+\permanent\def\somemathstylefont#1% #1 is number (\normalmathstyle)
+ {\ifcase\numexpr#1\relax
+ \textfont \or
+ \textfont \or
+ \textfont \or
+ \textfont \or
+ \scriptfont \or
+ \scriptfont \or
+ \scriptscriptfont \or
+ \scriptscriptfont \else
+ \textfont
+ \fi}
+
+\permanent\def\mathsmallstylefont#1% #1 is number (\normalmathstyle)
+ {\ifcase\numexpr#1\relax
+ \scriptfont \or
+ \scriptfont \or
+ \scriptfont \or
+ \scriptfont \or
+ \scriptscriptfont \or
+ \scriptscriptfont \or
+ \scriptscriptfont \or
+ \scriptscriptfont \else
+ \scriptfont
+ \fi\fam} % was \zerocount
+
+\permanent\def\mathstyleface#1% #1 is number (\normalmathstyle)
+ {\ifcase\numexpr#1\relax
+ \textface \or
+ \textface \or
+ \textface \or
+ \textface \or
+ \scriptface \or
+ \scriptface \or
+ \scriptscriptface \or
+ \scriptscriptface \else
+ \textface
+ \fi}
+
+\permanent\def\mathsmallstyleface#1% #1 is number (\normalmathstyle)
+ {\ifcase\numexpr#1\relax
+ \scriptface \or
+ \scriptface \or
+ \scriptface \or
+ \scriptface \or
+ \scriptscriptface \or
+ \scriptscriptface \or
+ \scriptscriptface \or
+ \scriptscriptface \else
+ \scriptface
+ \fi}
+
+\permanent\def\mathstylecommand#1#2#3%
+ {\ifcase\numexpr\normalmathstyle\relax
+ \expandafter#1\or
+ \expandafter#1\or
+ \expandafter#1\or
+ \expandafter#1\or
+ \expandafter#2\or
+ \expandafter#2\or
+ \expandafter#3\or
+ \expandafter#3\else
+ \expandafter#1\fi}
+
+% \permanent\def\textstyleface#1% #1 is number (\normalmathstyle)
+% {\ifcase\numexpr#1\relax
+% \tf \or
+% \tf \or
+% \tf \or
+% \tf \or
+% \tfx \or
+% \tfx \or
+% \tfxx \or
+% \tfxx \else
+% \tf
+% \fi}
+
+\permanent\protected\def\verbosemathstyle#1% #1 is number (\normalmathstyle)
+ {{\normalexpanded{\relax\darkgray\ttxx[\number#1:\ifcase\numexpr#1\relax
+ display\or % 0
+ crampeddisplay\or % 1
+ text\or % 2
+ crampedtext\or % 3
+ script\or % 4
+ crampedscript\or % 5
+ scriptscript\or % 6
+ crampedscriptscript\else % 7
+ unknown\fi]}}}
+
+\permanent\protected\def\showmathstyle{\verbosemathstyle\normalmathstyle}
+
+%D Handy too:
+
+\permanent\def\mathcharwd{\fontcharwd\mathstylefont\normalmathstyle}
+\permanent\def\mathcharht{\fontcharht\mathstylefont\normalmathstyle}
+\permanent\def\mathchardp{\fontchardp\mathstylefont\normalmathstyle}
+
+%D Some dimension fun:
+
+\aliased \let\mathexheight \exheight % also in math-ini.mkiv
+\permanent\def\mathemwidth {\Umathquad\normalmathstyle} % also in math-ini.mkiv
+
+%D A plain inheritance:
+
+\permanent\def\mathpalette#1#2%
+ {\mathchoice
+ {#1\displaystyle {#2}}%
+ {#1\textstyle {#2}}%
+ {#1\scriptstyle {#2}}%
+ {#1\scriptscriptstyle{#2}}}
+
+%D \macros
+%D {cramedllap, crampedrlap, crampedclap}
+%D
+%D In many cases, one wants to use the \tex {clap} macro in math mode while using
+%D subscripts. Normally, subscripts are in cramped mode, and these macros allow you
+%D to go to cramped mode. For example:
+%D
+%D \startbuffer
+%D \startformula
+%D \sum_{a^2 < b^2 < c^2} \quad
+%D \sum_{\clap{a^2 < b^2 < c^2}} \quad
+%D \sum_{\crampedclap{a^2 < b^2 < c^2}}
+%D \stopformula
+%D \stopbuffer
+%D
+%D \start
+%D \typebuffer
+%D \switchtobodyfont[24pt]
+%D \getbuffer
+%D \stop
+%D
+%D This used to be in \type {supp-math.mkxl}:
+
+\permanent\protected\def\crampedllap#1{\llap{\cramped#1}}
+\permanent\protected\def\crampedrlap#1{\rlap{\cramped#1}}
+\permanent\protected\def\crampedclap#1{\clap{\cramped#1}}
+
+%D Often we can use:
+%D
+%D \startbuffer
+%D $x^{\mathstylehbox{x^{\mathstylehbox{x}}}}$
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+% to be tested: {#1} but it could have side effects
+
+% \protected\def\mathstylehbox#1% sensitive for: a \over b => {a\over b} or \frac{a}{b}
+% {\normalexpanded{\hbox\bgroup
+% \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup}
+
+\permanent\protected\def\mathstylehbox#1#% sensitive for: a \over b => {a\over b} or \frac{a}{b}
+ {\math_style_hbox{#1}}
+
+\protected\def\math_style_hbox#1#2% sensitive for: a \over b => {a\over b} or \frac{a}{b}
+ {\normalexpanded{\hbox#1\bgroup
+ \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#2\stopimath\egroup}
+
+\permanent\protected\def\mathstylevbox#1%
+ {\normalexpanded{\vbox\bgroup
+ \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup}
+
+\permanent\protected\def\mathstylevcenter#1%
+ {\normalexpanded{\vcenter\bgroup
+ \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup}
+
+\permanent\protected\def\mathstylevcenteredhbox#1%
+ {\normalexpanded{\vcenter\bgroup\hbox\bgroup
+ \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup\egroup}
+
+\permanent\protected\def\mathstylevcenteredvbox#1%
+ {\normalexpanded{\vcenter\bgroup\vbox\bgroup
+ \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup\egroup}
+
+\permanent\protected\def\setmathsmalltextbox#1#2#%
+ {\normalizebodyfontsize\m_math_text_choice_face{\mathsmallstyleface\normalmathstyle}%
+ \setbox#1#2\bgroup
+ \font_basics_switchtobodyfont\m_math_text_choice_face
+ \let\next}
+
+\permanent\protected\def\setmathtextbox#1#2#%
+ {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
+ \setbox#1#2\bgroup
+ \font_basics_switchtobodyfont\m_math_text_choice_face
+ \let\next}
+
+%D Here is the new mechanism ... it might replace some of the above but we will do
+%D that stepwise. Keep in mind that cramped only affects superscripts and even then,
+%D only when in a smaller size than normal.
+%D
+%D \def\TestMe#1%
+%D {\NC \ttbf #1
+%D \NC \ruledhbox{$\setupmathstyle[#1]x + x_j^2 + x_i^{e^2} + \frac{1}{x}$}
+%D \NC \ruledhbox{$\setupmathstyle[#1,small]x + x_j^2 + x_i^{e^2} + \frac{1}{x}$}
+%D \NC \NR}
+%D
+%D \starttabulate[|l|r|l|]
+%D \HL
+%D \NC \NC \NC \ttbf ...,small \NC \NR
+%D \HL
+%D \TestMe{text} \TestMe{text,cramped}
+%D \TestMe{script} \TestMe{script,cramped}
+%D \TestMe{scriptscript} \TestMe{scriptscript,cramped}
+%D \TestMe{display} \TestMe{display,cramped}
+%D \HL
+%D \stoptabulate
+
+\permanent\def\triggerdisplaystyle
+ {\ifmathstyle
+ \displaystyle \or
+ \crampeddisplaystyle \or
+ \displaystyle \or
+ \crampeddisplaystyle \or
+ \displaystyle \or
+ \crampeddisplaystyle \or
+ \displaystyle \or
+ \crampeddisplaystyle \or
+ \fi}
+
+\permanent\def\triggertextstyle
+ {\ifmathstyle
+ \textstyle \or
+ \crampedtextstyle \or
+ \textstyle \or
+ \crampedtextstyle \or
+ \textstyle \or
+ \crampedtextstyle \or
+ \textstyle \or
+ \crampedtextstyle \else
+ \fi}
+
+\permanent\def\triggerscriptstyle
+ {\ifmathstyle
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \fi}
+
+\permanent\def\triggerscriptscriptstyle
+ {\ifmathstyle
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \fi}
+
+\permanent\def\triggeruncrampedstyle
+ {\ifmathstyle
+ \or \displaystyle \or
+ \or \textstyle \or
+ \or \scriptstyle \or
+ \or \scriptscriptstyle \fi}
+
+\permanent\def\triggercrampedstyle
+ {\ifmathstyle
+ \crampeddisplaystyle \or \or
+ \crampedtextstyle \or \or
+ \crampedscriptstyle \or \or
+ \crampedscriptscriptstyle \fi}
+
+\permanent\def\triggersmallstyle
+ {\ifmathstyle
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \fi}
+
+\permanent\def\triggeruncrampedsmallstyle
+ {\ifmathstyle
+ \scriptstyle \or
+ \scriptstyle \or
+ \scriptstyle \or
+ \scriptstyle \or
+ \scriptscriptstyle \or
+ \scriptscriptstyle \or
+ \scriptscriptstyle \or
+ \scriptscriptstyle \or
+ \fi}
+
+\permanent\def\triggercrampedsmallstyle
+ {\ifmathstyle
+ \crampedscriptstyle \or
+ \crampedscriptstyle \or
+ \crampedscriptstyle \or
+ \crampedscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \crampedscriptscriptstyle \or
+ \fi}
+
+\permanent\def\triggerbigstyle
+ {\ifmathstyle
+ \displaystyle \or
+ \crampeddisplaystyle \or
+ \textstyle \or
+ \crampedtextstyle \or
+ \textstyle \or
+ \crampedtextstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \or
+ \fi}
+
+\permanent\def\triggeruncrampedbigstyle
+ {\ifmathstyle
+ \displaystyle \or
+ \displaystyle \or
+ \textstyle \or
+ \textstyle \or
+ \textstyle \or
+ \textstyle \or
+ \scriptstyle \or
+ \scriptstyle \or
+ \fi}
+
+\permanent\def\triggercrampedbigstyle
+ {\ifmathstyle
+ \crampeddisplaystyle \or
+ \crampeddisplaystyle \or
+ \crampedtextstyle \or
+ \crampedtextstyle \or
+ \crampedtextstyle \or
+ \crampedtextstyle \or
+ \crampedscriptstyle \or
+ \crampedscriptstyle \or
+ \fi}
+
+\newcount\c_math_saved_style
+
+\permanent\protected\def\pushmathstyle % assumes begingroup .. endgroup
+ {\c_math_saved_style\mathstyle}
+
+\permanent\protected\def\popmathstyle
+ {\ifnum\mathstyle=\c_math_saved_style\else
+ \triggermathstyle\c_math_saved_style
+ \fi}
+
+\installcorenamespace{mathstylecommand}
+\installcorenamespace{mathstylecache}
+
+\newconstant\c_math_styles_state_style
+\newconstant\c_math_styles_state_cramped
+\newconstant\c_math_styles_state_size
+
+\def\math_style_add_to_cache_choice {%
+ \ifcase\c_math_styles_state_size
+ \ifcase\c_math_styles_state_style
+ \ifcase\c_math_styles_state_cramped
+ \relax \or
+ \noexpand\triggeruncrampedstyle \or
+ \noexpand\triggercrampedstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerdisplaystyle \or
+ \displaystyle \or
+ \crampeddisplaystyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggertextstyle \or
+ \textstyle \or
+ \crampedtextstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \fi
+ \fi
+ \or % small
+ \ifcase\c_math_styles_state_style
+ \ifcase\c_math_styles_state_cramped
+ \noexpand\triggersmallstyle \or
+ \noexpand\triggeruncrampedsmallstyle \or
+ \noexpand\triggercrampedsmallstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptscriptstyle \or
+ \scriptscriptstyle \or
+ \crampedscriptscriptstyle \fi
+ \fi
+ \or % large
+ \ifcase\c_math_styles_state_style
+ \ifcase\c_math_styles_state_cramped
+ \noexpand\triggerbigstyle \or
+ \noexpand\triggeruncrampedbigstyle \or
+ \noexpand\triggercrampedbigstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerdisplaystyle \or
+ \displaystyle \or
+ \crampeddisplaystyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggertextstyle \or
+ \textstyle \or
+ \crampedtextstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggertextstyle \or
+ \textstyle \or
+ \crampedtextstyle \fi
+ \or\ifcase\c_math_styles_state_cramped
+ \noexpand\triggerscriptstyle \or
+ \scriptstyle \or
+ \crampedscriptstyle \fi
+ \fi
+ \fi
+}
+
+\permanent\tolerant\protected\def\setmathstyle[#1]#;#=% so we accept [] and {}
+ {\edef\m_math_style_asked{#1#2}%
+ \ifempty\m_math_style_asked \else
+ \math_style_set_indeed
+ \fi}
+
+\permanent\def\installmathstyle#1#2%
+ {\ifcsname\??mathstylecommand#1\endcsname \else
+ \setvalue{\??mathstylecommand#1}{#2}%
+ \fi}
+
+\def\math_style_collect#1%
+ {\csname\??mathstylecommand#1\endcsname}
+
+\setvalue{\??mathstylecommand\s!display }{\c_math_styles_state_style \plusone}
+\setvalue{\??mathstylecommand\s!text }{\c_math_styles_state_style \plustwo}
+\setvalue{\??mathstylecommand\s!script }{\c_math_styles_state_style \plusthree}
+\setvalue{\??mathstylecommand\s!scriptscript}{\c_math_styles_state_style \plusfour}
+
+\setvalue{\??mathstylecommand\s!uncramped }{\c_math_styles_state_cramped\plusone}
+\setvalue{\??mathstylecommand\s!cramped }{\c_math_styles_state_cramped\plustwo}
+\setvalue{\??mathstylecommand\v!normal }{\c_math_styles_state_cramped\plusone}
+\setvalue{\??mathstylecommand\v!packed }{\c_math_styles_state_cramped\plustwo}
+
+\setvalue{\??mathstylecommand\v!small }{\c_math_styles_state_size \plusone}
+\setvalue{\??mathstylecommand\v!big }{\c_math_styles_state_size \plustwo}
+
+\permanent\protected\def\setupmathstyle[#1]%
+ {\edef\m_math_style_asked{#1}%
+ \ifempty\m_math_style_asked \else
+ \math_style_set_indeed
+ \fi}
+
+\permanent\protected\def\usemathstyleparameter#1% faster local variant
+ {\edef\m_math_style_asked{#1\c!mathstyle}%
+ \ifempty\m_math_style_asked \else
+ \math_style_set_indeed
+ \fi}
+
+%D \startbuffer
+%D \definemathstyle[mystyle][scriptscript]
+%D
+%D $text\startmathstyle[mystyle]scriptscript\stopmathstyle text$
+%D \stopbuffer
+%D
+%D \typebuffer \blank \start \getbuffer \stop \blank
+
+\installcorenamespace {mathstyle}
+
+\permanent\tolerant\protected\def\definemathstyle[#1]#*[#2]%
+ {\c_math_styles_state_style \zerocount
+ \c_math_styles_state_cramped\zerocount
+ \c_math_styles_state_size \zerocount
+ \rawprocesscommacommand[#2]\math_style_collect
+ \letcsname\??mathstyle#1\normalexpanded{\endcsname\math_style_add_to_cache_choice}}
+
+\def\math_style_set_indeed
+ {\ifcsname\??mathstyle\m_math_style_asked\endcsname
+ \lastnamedcs
+ \else
+ \math_style_set_mathstyle_mathstyle
+ \fi}
+
+\def\math_style_set_mathstyle_mathstyle
+ {\ifcsname\??mathstylecache\m_math_style_asked\endcsname
+ \lastnamedcs
+ \else
+ \math_style_set_mathstyle_mathstylecache
+ \fi}
+
+\def\math_style_set_mathstyle_mathstylecache
+ {\c_math_styles_state_style \zerocount
+ \c_math_styles_state_cramped\zerocount
+ \c_math_styles_state_size \zerocount
+ \rawprocesscommacommand[\m_math_style_asked]\math_style_collect
+ \gletcsname\??mathstylecache\m_math_style_asked\normalexpanded{\endcsname\math_style_add_to_cache_choice}%
+ \csname\??mathstylecache\m_math_style_asked\endcsname}
+
+\letvalue{\??mathstyle \??mathstyle }\math_style_set_mathstyle_mathstyle % still needed?
+\letvalue{\??mathstylecache\??mathstylecache}\math_style_set_mathstyle_mathstylecache % still needed?
+
+%D \startbuffer
+%D $x\begingroup\setupmathstyle[script]x\endgroup x$
+%D $x{\setupmathstyle[script]x}x$
+%D $x\startmathstyle[script]x\stopmathstyle x$
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\permanent\protected\def\startmathstyle[#1]%
+ {\edef\m_math_style_asked{#1}%
+ \ifempty\m_math_style_asked
+ \enforced\aliased\let\stopmathstyle\relax
+ \else
+ \bgroup
+ \math_style_set_indeed
+ \enforced\aliased\let\stopmathstyle\egroup
+ \fi}
+
+\aliased\let\stopmathstyle\relax
+
+\permanent\protected\def\startusemathstyleparameter#1%
+ {\edef\m_math_style_asked{#1\c!mathstyle}%
+ \ifempty\m_math_style_asked
+ \enforced\let\stopusemathstyleparameter\relax
+ \else
+ \bgroup
+ \math_style_set_indeed
+ \enforced\let\stopusemathstyleparameter\egroup
+ \fi}
+
+\aliased\let\stopusemathstyleparameter\relax
+
+%D Something similar can be used in the (re|)|definition of \type {\text}. This
+%D version is a variation on the one in the math module (see \type{m-math} and|/|or
+%D \type {m-newmat}).
+
+\let\m_math_text_choice_face\relax
+
+% if needed we can get rid of the normalize (predo in font code)
+
+% \def\math_text_choice_font#1#2#%
+% {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
+% \hbox#2\bgroup
+% \font_basics_switchtobodyfont\m_math_text_choice_face
+% #1%
+% \let\next}
+
+% \def\math_text_choice_word#1#2#%
+% {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
+% \hbox#2\bgroup
+% \font_basics_switchtobodyfont\m_math_text_choice_face
+% #1%
+% \nospacing % \normalnospaces\plusone
+% \let\next}
+
+%D We accept a low level box specification so that one can make helpers:
+%D
+%D \startbuffer
+%D \startformula
+%D \startalign[m=2,align={middle}]
+%D \NC \text to 6cm{One\hfill} \NC a = 1 \NR
+%D \NC \text to 6cm{One Two\hfill} \NC b = 2 \NR
+%D \NC \text to 6cm{One Two Three\hfill} \NC c = 3 \NR
+%D \stopalign
+%D \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\def\math_text_choice_font#1#2#%
+ {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
+ \hbox#2\bgroup
+ \bgroup
+ \aftergroup\hss
+ \aftergroup\egroup
+ \hss
+ \font_basics_switchtobodyfont\m_math_text_choice_face
+ #1%
+ \let\next}
+
+\def\math_text_choice_word#1#2#%
+ {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
+ \hbox#2\bgroup
+ \bgroup
+ \aftergroup\hss
+ \aftergroup\egroup
+ \hss
+ \font_basics_switchtobodyfont\m_math_text_choice_face
+ #1%
+ \nospacing % \normalnospaces\plusone
+ \let\next}
+
+% \ruledhbox{$\mathtext{abc ffi}$}
+% \ruledhbox{$\mathword{abc ffi}$}
+
+% I need to decide:
+%
+%mathscriptboxmode \zerocount % no kerning
+%mathscriptboxmode \plusone % lists
+\mathscriptboxmode \plustwo % lists and boxes
+\mathscriptcharmode \plusone % lists and boxes
+%mathscriptboxmode \plusthree % lists and boxes with \boundary=1 (also for testing and demo)
+\mathrulethicknessmode\plusone % adaptive
+
+\permanent\protected\def\mathtext {\mathortext{\math_text_choice_font\relax}\hbox}
+\permanent\protected\def\mathword {\mathortext{\math_text_choice_word\relax}\hbox}
+
+\permanent\protected\def\mathtexttf{\mathortext{\math_text_choice_font\tf}\hbox}
+\permanent\protected\def\mathtextit{\mathortext{\math_text_choice_font\it}\hbox}
+\permanent\protected\def\mathtextsl{\mathortext{\math_text_choice_font\sl}\hbox}
+\permanent\protected\def\mathtextbf{\mathortext{\math_text_choice_font\bf}\hbox}
+\permanent\protected\def\mathtextbi{\mathortext{\math_text_choice_font\bi}\hbox}
+\permanent\protected\def\mathtextbs{\mathortext{\math_text_choice_font\bs}\hbox}
+
+\permanent\protected\def\mathwordtf{\mathortext{\math_text_choice_word\tf}\hbox}
+\permanent\protected\def\mathwordit{\mathortext{\math_text_choice_word\it}\hbox}
+\permanent\protected\def\mathwordsl{\mathortext{\math_text_choice_word\sl}\hbox}
+\permanent\protected\def\mathwordbf{\mathortext{\math_text_choice_word\bf}\hbox}
+\permanent\protected\def\mathwordbi{\mathortext{\math_text_choice_word\bi}\hbox}
+\permanent\protected\def\mathwordbs{\mathortext{\math_text_choice_word\bs}\hbox}
+
+%D Safeguard against redefinitions:
+
+\appendtoks
+ \enforced\let\_\normalunderscore % is textunderscore or fakeunderscore
+\to \everymathematics
+
+%D Because we may overload \type {\text} in other (structuring) macros, we say:
+
+\appendtoks
+ \enforced\let\text\mathtext
+\to \everymathematics
+
+%D The next code is derived from plain \TEX. The names will change!
+
+\newcount\interdisplaylinepenalty \interdisplaylinepenalty\plushundred
+
+% Actually, not using an if saves one macro so there is no penalty
+% for splitting up this macro.
+%
+% \newif\ifdt@p
+%
+% \def\displ@y
+% {\global\dt@ptrue
+% \math_openup\displayopenupvalue % was \openup\jot
+% \everycr
+% {\noalign
+% {\ifdt@p
+% \global\dt@pfalse
+% \ifdim\prevdepth>-\thousandpoint
+% \vskip-\lineskiplimit
+% \vskip\normallineskiplimit
+% \fi
+% \else
+% \penalty\interdisplaylinepenalty
+% \fi}}}
+
+\newtoks\mathdisplayaligntweaks
+
+% this can become an option:
+
+\let\math_display_align_hack_indeed\relax
+
+\protected\def\math_display_align_hack % I don't like the global, maybe we should push and pop
+ {\glet\math_display_align_hack_indeed\math_display_align_hack_remove_skip
+ \math_openup\displayopenupvalue % was \math_openup\jot
+ \everycr{\noalign{\math_display_align_hack_indeed}}}
+
+\def\math_display_align_hack_remove_skip
+ {\ifdim\prevdepth>-\thousandpoint
+ \vskip\dimexpr-\lineskiplimit+\normallineskiplimit\relax
+ \fi
+ \glet\math_display_align_hack_indeed\math_display_align_hack_insert_penalty}
+
+\def\math_display_align_hack_insert_penalty
+ {\penalty\interdisplaylinepenalty}
+
+\appendtoks
+ \math_display_align_hack
+\to \mathdisplayaligntweaks
+
+%D Text in math:
+
+\permanent\protected\def\mathortext
+ {\ifmmode
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+% \defineactivecharacter _ {\mathortext{_}{\_}} text_text $a^2$
+
+% force text mode, will be overloaded later
+
+\ifdefined\text\else \aliased\let\text\hbox \fi
+
+% \protected\def\mathoptext#1{\mathop{\text{#1}}}
+
+\permanent\protected\def\mathoptext
+ {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}%
+ %\showmathstyle
+ \dowithnextbox
+ {\mathop{\box\nextbox}}%
+ \hbox\bgroup\font_basics_switchtobodyfont\m_math_text_choice_face\let\next}
+
+% new:
+
+% \startsetups math:morespacing
+% \Umathordordspacing\textstyle 1mu plus .5mu minus .25mu\relax
+% \stopsetups
+%
+% \setupmathematics
+% [setups=math:morespacing]
+
+\appendtoks
+ \edef\p_setups{\mathematicsparameter\c!setups}%
+ \ifempty\p_setups\else
+ \directsetup\p_setups
+ \fi
+\to \everyswitchmathematics
+
+% new:
+
+\permanent\protected\def\smallmathsymbol#1%
+ {\mathematics{\mathbin{\normalexpanded{\raise.15\exheight\hbox{\normalstartimath
+ \triggermathstyle{\the\numexpr\normalmathstyle+2\relax}#1%
+ \normalstopimath}}}}}
+
+% this should be a primitive:
+
+\permanent\def\mathextensiblecode#1#2{\clf_extensiblecode\numexpr#1\relax\numexpr#2\relax}
+\permanent\def\mathhorizontalcode#1#2{\clf_horizontalcode\numexpr#1\relax\numexpr#2\relax}
+
+% experimental:
+
+%D \starttyping
+%D \enabletrackers[math.openedup]
+%D
+%D \dorecurse{10}{\dorecurse{#1}{whatever }}
+%D
+%D \startitemize[packed]
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \stopitemize
+%D \startitemize[packed,columns]
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \stopitemize
+%D
+%D \dorecurse{5}{\dorecurse{#1}{whatever }\openedupimath{\frac{1}{2}} }
+%D
+%D \startitemize[packed,columns]
+%D \startitem whatever \openedupimath{1+2} whatever
+%D \startitem whatever \openedupimath{1+2} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{1+2} whatever
+%D \startitem whatever \openedupimath{1+2} whatever
+%D \stopitemize
+%D
+%D \dorecurse{5}{\dorecurse{#1}{whatever }\openedupimath{1+2} }
+%D
+%D \startitemize[packed]
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \startitem whatever \openedupimath{\frac{1}{2}} whatever
+%D \stopitemize
+%D
+%D \dorecurse{10}{whatever }
+%D \dorecurse {5}{\dorecurse{#1}{whatever }\openedupimath{\frac{1}{2}} }
+%D \dorecurse{10}{whatever }
+%D \stoptyping
+
+\def\m_math_inline_openup_ht{\dimexpr\ifinsidecolumns\strutdp\else\lineheight\fi/\plusfour\relax}
+\def\m_math_inline_openup_dp{\dimexpr\ifinsidecolumns\strutdp\else\lineheight\fi/\plusfour\relax}
+
+% \def\m_math_inline_openup_ht{\dimexpr\lineheight/\ifinsidecolumns\pluseight\else\plusfour\fi\relax}
+% \def\m_math_inline_openup_dp{\dimexpr\lineheight/\ifinsidecolumns\pluseight\else\plusfour\fi\relax}
+
+\installtextracker
+ {math.openedup}
+ {\let\math_inline_openup_start_yes\math_inline_openup_traced_start}
+ {\let\math_inline_openup_start_yes\math_inline_openup_normal_start}
+
+\protected\def\math_inline_openup_normal_start
+ {\scratchheight\dimexpr\ht\scratchbox+\m_math_inline_openup_ht\relax
+ \scratchdepth \dimexpr\dp\scratchbox+\m_math_inline_openup_dp\relax
+ \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax
+ \begingroup
+ \let\math_inline_openup_stop\math_inline_openup_normal_stop}
+
+\protected\def\math_inline_openup_normal_stop
+ {\endgroup
+ \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax}
+
+\protected\def\math_inline_openup_traced_start
+ {\scratchtopoffset \ht\scratchbox
+ \scratchbottomoffset\dp\scratchbox
+ \scratchheight \dimexpr\scratchtopoffset +\m_math_inline_openup_ht\relax
+ \scratchdepth \dimexpr\scratchbottomoffset+\m_math_inline_openup_dp\relax
+ \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax
+ \begingroup
+ \dousecolorparameter{darkred}%
+ \vrule\s!width\emwidth\s!height\scratchheight\s!depth-\scratchtopoffset\relax
+ \endgroup
+ \kern-\emwidth
+ \begingroup
+ \let\math_inline_openup_stop\math_inline_openup_traced_stop}
+
+\protected\def\math_inline_openup_traced_stop
+ {\endgroup
+ \kern-\emwidth
+ \begingroup
+ \dousecolorparameter{darkblue}%
+ \vrule\s!width\emwidth\s!height-\scratchbottomoffset\s!depth\scratchdepth\relax
+ \endgroup
+ \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax}
+
+\let\math_inline_openup_start_yes\math_inline_openup_normal_start
+\let\math_inline_openup_stop \relax
+
+\def\math_inline_openup_start_nop
+ {\let\math_inline_openup_stop\relax}
+
+\permanent\protected\def\openedupimath
+ {\dontleavehmode
+ \begingroup
+ \ifmmode
+ \expandafter\openedupimath_math
+ \else
+ \expandafter\openedupimath_text
+ \fi}
+
+\protected\def\openedupimath_math#1%
+ {\setbox\scratchbox\mathstylehbox{#1}%
+ \ifdim\ht\scratchbox>\strutht
+ \math_inline_openup_start_yes
+ \orelse\ifdim\dp\scratchbox>\strutdp
+ \math_inline_openup_start_yes
+ \else
+ \math_inline_openup_start_nop
+ \fi
+ #1%
+ \math_inline_openup_stop
+ \endgroup}
+
+\protected\def\openedupimath_text#1%
+ {\setbox\scratchbox\hbox{\startimath#1\stopimath}%
+ \ifdim\ht\scratchbox>\strutht
+ \math_inline_openup_start_yes
+ \orelse\ifdim\dp\scratchbox>\strutdp
+ \math_inline_openup_start_yes
+ \else
+ \math_inline_openup_start_nop
+ \fi
+ \startimath
+ #1%
+ \stopimath
+ \math_inline_openup_stop
+ \endgroup}
+
+% Also handy, especially for units:
+%
+% 0x002B=plus 0x2212=minus 0x2013=endash
+
+\permanent\protected\def\mathplus {+}
+\permanent\protected\def\mathminus {\ifmmode –\orelse\iffontchar\font`−−\else –\fi}
+\permanent\protected\def\mathplusminus{±}
+
+%D The \type {\displaywidth} is only known inside a display formula, so we need to catch
+%D it when still zero.
+
+\permanent\def\checkeddisplaywidth % hsize if zero
+ {\dimexpr
+ \ifzeropt\displaywidth
+ \hsize
+ \else
+ \displaywidth
+ \fi
+ \relax}
+
+\permanent\def\maximizeddisplaywidth % larger than zero but within hsize
+ {\dimexpr
+ \ifzeropt\displaywidth
+ \hsize
+ \orelse\ifdim\displaywidth>\hsize
+ \hsize
+ \else
+ \displaywidth
+ \fi
+ \relax}
+
+%D Experiment: (todo: same switch as italic, using \type {\everyswitchmathematics}).
+
+\newcount\c_math_domain_attribute
+
+\def\math_domain_initialize
+ {\ifnum\c_math_domain_attribute=\attributeunsetvalue \else
+ \clf_initializemathdomain % one time
+ \glet\math_domain_initialize\relax
+ \fi}
+
+\appendtoks
+ \edef\p_domain{\mathematicsparameter\c!domain}%
+ \ifempty\p_domain
+ \c_math_domain_attribute\attributeunsetvalue
+ \else
+ \c_math_domain_attribute\clf_getmathdomain\p_domain\relax
+ \math_domain_initialize
+ \fi
+\to \everyswitchmathematics % only in mathematics
+
+\appendtoks
+ \c_attr_mathdomain\c_math_domain_attribute
+\to \everymathematics
+
+\setupmathematics
+ [\s!italics=3] % for the moment only this one makes sense .. still experimental
+
+%D For special purposed we set this one:
+
+\installcorenamespace{mathrules}
+
+\permanent\protected\def\enablemathrules{\letgvalue{\??mathrules\fontclass}\plusone}
+
+\appendtoks
+ \mathrulesmode\ifcsname\??mathrules\fontclass\endcsname
+ \lastnamedcs
+ \else
+ \zerocount
+ \fi
+ \mathrulesfam\zerocount
+\to \everymathematics
+
+%D Maybe:
+
+% \starttabulate[|||c|c|]
+% \BC positive \BC negative \BC text \BC math \NC \NR
+% \NC \tex {f1} \tex {hairspace} \tex{,} \NC \tex {b1} \tex {neghairspace} \NC {\darkred\vl}\f1{\darkblue\vl} \NC ${\darkred\vl}\f1{\darkblue\vl}$ \NC \NR
+% \NC \tex {f2} \tex {thinspace} \tex{:} \NC \tex {b2} \tex {negthinspace} \tex{!} \NC {\darkred\vl}\f2{\darkblue\vl} \NC ${\darkred\vl}\f2{\darkblue\vl}$ \NC \NR
+% \NC \tex {f3} \tex {medspace} \tex{;} \NC \tex {b3} \tex {negmedspace} \NC {\darkred\vl}\f3{\darkblue\vl} \NC ${\darkred\vl}\f3{\darkblue\vl}$ \NC \NR
+% \NC \tex {f4} \tex {thickspace} \NC \tex {b4} \tex {negthickspace} \NC {\darkred\vl}\f4{\darkblue\vl} \NC ${\darkred\vl}\f4{\darkblue\vl}$ \NC \NR
+% \NC \tex {f5} \tex {enspace} \NC \tex {b5} \NC {\darkred\vl}\f5{\darkblue\vl} \NC ${\darkred\vl}\f5{\darkblue\vl}$ \NC \NR
+% \NC \tex {f6} \tex {emspace} \NC \tex {b6} \NC {\darkred\vl}\f6{\darkblue\vl} \NC ${\darkred\vl}\f6{\darkblue\vl}$ \NC \NR
+% \stoptabulate
+
+% \protected\def\negenspace{\kern-.5\emwidth}
+% \protected\def\negemspace{\kern- \emwidth}
+%
+% \protected\def\math_f#1%
+% {\ifcase#1\or
+% \hairspace
+% \or
+% \thinspace
+% \or
+% \medspace
+% \or
+% \thickspace
+% \or
+% \enspace
+% \or
+% \emspace
+% \fi}
+%
+% \protected\def\math_b#1%
+% {\ifcase#1\or
+% \neghairspace
+% \or
+% \negthinspace
+% \or
+% \negmedspace
+% \or
+% \negthickspace
+% \or
+% \negenspace
+% \or
+% \negemspace
+% \fi}
+%
+% \appendtoks
+% \let\f\math_f
+% \let\b\math_b
+% \to \everymathematics
+
+%D Experiment
+
+\permanent\protected\def\math_scripts_stack
+ {\c_attr_mathunstack\attributeunsetvalue}
+
+\permanent\protected\def\math_scripts_unstack
+ {\clf_enablescriptunstacking
+ \c_attr_mathunstack\plusone}
+
+\ifdefined\stackscripts \else \aliased\let\stackscripts \relax \fi
+\ifdefined\unstackscripts \else \aliased\let\unstackscripts\relax \fi
+
+\appendtoks
+ \enforced\let\stackscripts \math_scripts_stack
+ \enforced\let\unstackscripts\math_scripts_unstack
+\to \everymathematics
+
+%D Expensive (tracing and inject) but a primitive (using factors) is tricky as we
+%D want this frozen support.
+
+% \def\math_openup_parameter#1#2%
+% {\ifzeropt#1\displaystyle \orelse\ifdim#1\displaystyle =\maxdimen\else\frozen#1\displaystyle #2#1\displaystyle \fi
+% \ifzeropt#1\crampeddisplaystyle \orelse\ifdim#1\crampeddisplaystyle =\maxdimen\else\frozen#1\crampeddisplaystyle #2#1\crampeddisplaystyle \fi
+% \ifzeropt#1\textstyle \orelse\ifdim#1\textstyle =\maxdimen\else\frozen#1\textstyle #2#1\textstyle \fi
+% \ifzeropt#1\crampedtextstyle \orelse\ifdim#1\crampedtextstyle =\maxdimen\else\frozen#1\crampedtextstyle #2#1\crampedtextstyle \fi
+% \ifzeropt#1\scriptstyle \orelse\ifdim#1\scriptstyle =\maxdimen\else\frozen#1\scriptstyle #2#1\scriptstyle \fi
+% \ifzeropt#1\crampedscriptstyle \orelse\ifdim#1\crampedscriptstyle =\maxdimen\else\frozen#1\crampedscriptstyle #2#1\crampedscriptstyle \fi
+% \ifzeropt#1\scriptscriptstyle \orelse\ifdim#1\scriptscriptstyle =\maxdimen\else\frozen#1\scriptscriptstyle #2#1\scriptscriptstyle \fi
+% \ifzeropt#1\crampedscriptscriptstyle\orelse\ifdim#1\crampedscriptscriptstyle=\maxdimen\else\frozen#1\crampedscriptscriptstyle#2#1\crampedscriptscriptstyle\fi}
+
+% \def\mdim#1#2%
+% {\ifcase\ifzeropt#1#2\plusone\orelse\ifdim#1#2=\maxdimen\plusone\else\zerocount\fi}
+%
+% \def\mdim
+% {\afterassignment\mmdim\scratchdimen}
+%
+% \def\mmdim
+% {\ifcase\ifzeropt\scratchdimen\plusone\orelse\ifdim\scratchdimen=\maxdimen\plusone\else\zerocount\fi}
+%
+% \def\math_openup_parameter#1#2%
+% {\ifcondition\mdim#1\displaystyle \frozen#1\displaystyle #2\dimexpr#1\displaystyle \relax\fi
+% \ifcondition\mdim#1\crampeddisplaystyle \frozen#1\crampeddisplaystyle #2\dimexpr#1\crampeddisplaystyle \relax\fi
+% \ifcondition\mdim#1\textstyle \frozen#1\textstyle #2\dimexpr#1\textstyle \relax\fi
+% \ifcondition\mdim#1\crampedtextstyle \frozen#1\crampedtextstyle #2\dimexpr#1\crampedtextstyle \relax\fi
+% \ifcondition\mdim#1\scriptstyle \frozen#1\scriptstyle #2\dimexpr#1\scriptstyle \relax\fi
+% \ifcondition\mdim#1\crampedscriptstyle \frozen#1\crampedscriptstyle #2\dimexpr#1\crampedscriptstyle \relax\fi
+% \ifcondition\mdim#1\scriptscriptstyle \frozen#1\scriptscriptstyle #2\dimexpr#1\scriptscriptstyle \relax\fi
+% \ifcondition\mdim#1\crampedscriptscriptstyle\frozen#1\crampedscriptscriptstyle#2\dimexpr#1\crampedscriptscriptstyle\relax\fi}
+
+% \ifmathparameter : 0=zero, 1=set, 2=unset (les stracing clutter this way)
+
+%D New stuff:
+%D
+%D \starttyping
+%D $\mathopenupparameter\Umathradicalvgap{10.5}\sqrt[3]{x}$
+%D \stoptyping
+
+\permanent\protected\def\mathopenupparameter#1#2%
+ {\ifmathparameter#1\displaystyle \or\frozen#1\displaystyle #2#1\displaystyle \fi
+ \ifmathparameter#1\crampeddisplaystyle \or\frozen#1\crampeddisplaystyle #2#1\crampeddisplaystyle \fi
+ \ifmathparameter#1\textstyle \or\frozen#1\textstyle #2#1\textstyle \fi
+ \ifmathparameter#1\crampedtextstyle \or\frozen#1\crampedtextstyle #2#1\crampedtextstyle \fi
+ \ifmathparameter#1\scriptstyle \or\frozen#1\scriptstyle #2#1\scriptstyle \fi
+ \ifmathparameter#1\crampedscriptstyle \or\frozen#1\crampedscriptstyle #2#1\crampedscriptstyle \fi
+ \ifmathparameter#1\scriptscriptstyle \or\frozen#1\scriptscriptstyle #2#1\scriptscriptstyle \fi
+ \ifmathparameter#1\crampedscriptscriptstyle\or\frozen#1\crampedscriptscriptstyle#2#1\crampedscriptscriptstyle\fi}
+
+%D New stuff:
+%D
+%D \startbuffer
+%D $x\mathopen {!}+123+\mathclose {!}x$
+%D $x\tomathopen ! +123+\tomathclose ! x$
+%D $x\mathclose {!}+123+\mathopen {!}x$
+%D $x\tomathclose ! +123+\tomathopen ! x$
+%D $x ! +123+ ! x$
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startlines
+%D \getbuffer
+%D \stoplines
+
+\permanent\protected\def\tomathord {\Umathclass\zerocount}
+\permanent\protected\def\tomathop {\Umathclass\plusone } % \mathinfix
+\permanent\protected\def\tomathbin {\Umathclass\plustwo }
+\permanent\protected\def\tomathrel {\Umathclass\plusthree}
+\permanent\protected\def\tomathopen {\Umathclass\plusfour } % \mathprefix
+\permanent\protected\def\tomathclose{\Umathclass\plusfive } % \mathsuffix
+\permanent\protected\def\tomathpunct{\Umathclass\plussix }
+
+%D Prescripts. These work in \CONTEXT\ because we have the super- and subscript
+%D triggers enabled as active characters but when we would have
+%D
+%D \starttyping
+%D \catcode\underscoreasciicode\subscriptcatcode
+%D \catcode\circumflexasciicode\superscriptcatcode
+%D \stoptyping
+%D
+%D we also need the next line to disable character escaping via \type {^} in
+%D math mode:
+%D
+%D \startbuffer
+%D \blank \hbox{
+%D \ruledhbox{${\tf X} ^1 _2 ^^3 __4$}
+%D \ruledhbox{${\tf X} ^1 $}
+%D \ruledhbox{${\tf X} _2 $}
+%D \ruledhbox{${\tf X} ^^3 $}
+%D \ruledhbox{${\tf X} __4$}
+%D \ruledhbox{${\tf X} ^1 _2 $}
+%D \ruledhbox{${\tf X} ^1 ^^3 $}
+%D \ruledhbox{${\tf X} ^1 __4$}
+%D \ruledhbox{${\tf X} _2 ^^3 $}
+%D \ruledhbox{${\tf X} _2 __4$}
+%D \ruledhbox{${\tf X} ^1 _2 ^^3 $}
+%D \ruledhbox{${\tf X} ^1 _2 __4$}
+%D \ruledhbox{${\tf X} _2 ^^3 $}
+%D \ruledhbox{${\tf X} _2 ^^3 __4$}
+%D \ruledhbox{${\tf X} ^^3 __4$}
+%D } \blank
+%D
+%D \typebuffer \getbuffer
+
+\normalsupmarkmode\plusone % 2 also disable ^[^+] in text mode
+
+\protect \endinput
+
+% % not used (yet)
+%
+% \newtoks \everystartimath
+% \newtoks \everystopimath
+%
+% \protected\def\startimath{\Ustartmath\the\everystartimath}
+% \protected\def\stopimath {\the\everystopimath\Ustopmath}
+%
+% \protected\def\m%
+% {\relax
+% \ifmmode\expandafter\math_m_stay\else\expandafter\math_m_math\fi}
+%
+% \protected\def\math_m_math#1%
+% {\startimath#1\stopimath}
+%
+% \let\math_m_stay\firstofoneargument
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-inl.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-inl.mkxl
new file mode 100644
index 00000000000..2c7284458a5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-inl.mkxl
@@ -0,0 +1,22 @@
+%D \module
+%D [ file=math-inl,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Inline,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Inline}
+
+\unprotect
+
+% The \MKII\ math grid snapping code has gone. A pity as it was rather effective
+% and worked quite well (for a couple of projects where it was demanded). Other code
+% might show up / move here.
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-int.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-int.mkxl
new file mode 100644
index 00000000000..a8dcd3c9525
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-int.mkxl
@@ -0,0 +1,141 @@
+%D \module
+%D [ file=math-int,
+%D version=2007.07.19,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Scripts,
+%D author={Hans Hagen \& Taco Hoekwater \& Aditya Mahajan},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Integrals}
+
+% todo: int and sum etc can be stackers
+
+\unprotect
+
+%D \startbuffer
+%D $\int _a^b f(x) dx $ and also
+%D $\iint _a^b f(x,y) dxdy$,
+%D $\iiint _a^b f(x,y) dxdy$,
+%D \startformula
+%D \int _a^b f(x) dx \quad
+%D \iint _a^b f(x) dx \quad
+%D \iiint _a^b f(x) dx \quad
+%D \stopformula
+%D \stopbuffer
+%D
+%D Default: \getbuffer
+%D
+%D Displaylimits: \setupmathematics[integral=displaylimits] \getbuffer
+%D
+%D Limits: \setupmathematics[integral=limits] \getbuffer
+
+%D Adapted to mkiv by HH from code by AM.
+
+\installcorenamespace{mathintegral}
+
+\newconstant\mathintlimitmode
+
+\permanent\def\intlimits % also used elsewhere
+ {\ifcase\mathintlimitmode
+ \nolimits
+ \or
+ \displaylimits
+ \or
+ \limits
+ \or
+ \ifnum\attribute\mathmodeattribute=\plusone
+ \limits
+ \else
+ \nolimits
+ \fi
+ \else
+ % none
+ \fi}
+
+\letvalue{\??mathintegral nolimits}\zerocount
+\letvalue{\??mathintegral displaylimits}\plusone
+\letvalue{\??mathintegral limits}\plustwo
+\letvalue{\??mathintegral autolimits}\plusthree
+\letvalue{\??mathintegral none}\plusfour
+
+\appendtoks
+ \mathintlimitmode\executeifdefined{\??mathintegral\mathematicsparameter\s!integral}\zerocount
+\to \everyswitchmathematics
+
+\setupmathematics
+% [\v!integral=nolimits]
+ [\v!integral=autolimits]
+
+%D The following code is used for fallbacks and might become obsolete once
+%D we have enough \OPENTYPE\ math fonts.
+
+% \def\math_repeated_integal_i
+% {\int}
+
+% \def\math_repeated_integal_ii
+% {\math_repeated_integal_i
+% \math_repeated_integral_kern
+% \math_repeated_integal_i
+% \math_repeat_integral_finish
+% \intlimits}
+
+% \def\math_repeated_integal_iii
+% {\math_repeated_integal_i
+% \math_repeated_integral_kern
+% \math_repeated_integal_ii}
+%
+% \def\math_repeated_integal_iiii
+% {\math_repeated_integal_i
+% \math_repeated_integral_kern
+% \math_repeated_integal_iii}
+%
+% \protected\def\math_repeat_integral#1%
+% {\let\math_repeat_integral_finish\donothing
+% \iffontchar\textfont\zerocount#1\relax
+% \expandafter\math_repeat_integral_real
+% \else
+% \expandafter\math_repeat_integral_fake
+% \fi}
+%
+% \def\math_repeat_integral_fake#1#2%
+% {\let\math_repeat_integral_fake_symbol#2%
+% \futurelet\next\math_repeat_integral_fake_indeed}
+%
+% \def\math_repeat_integral_real#1#2%
+% {#1}
+%
+% \definemathcommand [iint] {\math_repeat_integral{"0222C}\normalint \math_repeated_integal_ii } % double
+% \definemathcommand [iiint] {\math_repeat_integral{"0222D}\normaliint \math_repeated_integal_iii } % tripple
+% \definemathcommand [iiiint] {\math_repeat_integral{"FFFFF}\normaliiint\math_repeated_integal_iiii} % quadruple
+%
+% \def\math_repeated_integral_kern
+% {\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}}
+%
+% \def\math_repeat_integral_fake_indeed
+% {\ifx\next\limits
+% \math_repeated_integral_correction
+% \orelse\ifx\next\displaylimits
+% \math_repeated_integral_correction
+% \orelse\ifx\next\nolimits
+% % nothing
+% \orelse\ifcase\mathintlimitmode
+% % nothing
+% \else
+% \math_repeated_integral_correction
+% \fi
+% \math_repeat_integral_fake_symbol}
+%
+% \def\math_repeated_integral_correction
+% {\mkern-7mu\mathchoice{\mkern-2mu}{}{}{}%
+% \mathop\bgroup\mkern7mu\mathchoice{\mkern2mu}{}{}{}\let\math_repeat_integral_finish\egroup}
+%
+% %D If the \type{\limits} option is used after \type {\iint}, use \type
+% %D {\mathop} and fudge the left hand space a bit to make the subscript
+% %D visually centered.
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-mis.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-mis.mkxl
new file mode 100644
index 00000000000..a824c593332
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-mis.mkxl
@@ -0,0 +1,60 @@
+%D \module
+%D [ file=math-mis,
+%D version=2013.04.06, % 2007.07.19,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Miscellaneous,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Miscellaneous}
+
+\unprotect
+
+%D This file contains left-overs moved from other files. It's mostly old stuff
+%D that we keep around for compatbility reasons.
+
+%D \macros
+%D {qedsymbol}
+%D
+%D [HH] The general Quod Erat Demonstrandum symbol is defined in such a way that
+%D we can configure it. Because this symbol is also used in text mode, we make it
+%D a normal text symbol with special behavior.
+
+\permanent\protected\def\qedsymbol#1%
+ {\ifhmode
+ \unskip\nobreakspace\hfill#1\par
+ \orelse\ifmmode
+ #1\relax % leading \eqno removed
+ \else
+ \dontleavehmode\emptyhbox\hfill#1\par
+ \fi}
+
+\definesymbol [qed] [\qedsymbol{\mathematics{\square}}]
+
+%D \macros
+%D {QED}
+%D
+%D [HH] For compatbility reasons we also provide the \type {\QED} command. In case
+%D this command is overloaded, we still have the symbol available. \symbol[qed]
+
+\permanent\protected\def\QED{\symbol[qed]}
+
+%D \macros
+%D {boxed}
+%D
+%D [HH] Another macro that users might expect (slightly adapted):
+
+\permanent\protected\def\boxed % maybe obsolete
+ {\ifmmode\expandafter\mframed\else\expandafter\framed\fi}
+
+%D Something low level for scientific calculator notation:
+
+\permanent\protected\def\scinot#1#2%
+ {#1\times10^{#2}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-noa.lmt b/Master/texmf-dist/tex/context/base/mkxl/math-noa.lmt
new file mode 100644
index 00000000000..118ab18267a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-noa.lmt
@@ -0,0 +1,2412 @@
+if not modules then modules = { } end modules ['math-noa'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to math-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- beware: this is experimental code and there will be a more generic (attribute value
+-- driven) interface too but for the moment this is ok (sometime in 2015-2016 i will
+-- start cleaning up as by then the bigger picture is clear and code has been used for
+-- years; the main handlers will get some extensions)
+--
+-- we will also make dedicated processors (faster)
+--
+-- beware: names will change as we wil make noads.xxx.handler i.e. xxx
+-- subnamespaces
+
+-- 20D6 -> 2190
+-- 20D7 -> 2192
+
+-- todo: most is mathchar_code so we can have simple dedicated loops
+
+-- nota bene: uunderdelimiter uoverdelimiter etc are radicals (we have 5 types)
+
+local next, tonumber = next, tonumber
+local utfchar, utfbyte = utf.char, utf.byte
+local formatters, gmatch = string.formatters, string.gmatch
+local sortedhash = table.sortedhash
+local insert, remove = table.insert, table.remove
+local div, round = math.div, math.round
+local bor, band = bit32.bor, bit32.band
+
+local fonts = fonts
+local nodes = nodes
+local node = node
+local mathematics = mathematics
+local context = context
+
+local otf = fonts.handlers.otf
+local otffeatures = fonts.constructors.features.otf
+local registerotffeature = otffeatures.register
+
+local privateattribute = attributes.private
+local registertracker = trackers.register
+local registerdirective = directives.register
+local logreporter = logs.reporter
+local setmetatableindex = table.setmetatableindex
+
+local colortracers = nodes.tracers.colors
+
+local trace_remapping = false registertracker("math.remapping", function(v) trace_remapping = v end)
+local trace_processing = false registertracker("math.processing", function(v) trace_processing = v end)
+local trace_analyzing = false registertracker("math.analyzing", function(v) trace_analyzing = v end)
+local trace_normalizing = false registertracker("math.normalizing", function(v) trace_normalizing = v end)
+local trace_collapsing = false registertracker("math.collapsing", function(v) trace_collapsing = v end)
+local trace_fixing = false registertracker("math.fixing", function(v) trace_foxing = v end)
+local trace_patching = false registertracker("math.patching", function(v) trace_patching = v end)
+local trace_goodies = false registertracker("math.goodies", function(v) trace_goodies = v end)
+local trace_variants = false registertracker("math.variants", function(v) trace_variants = v end)
+local trace_alternates = false registertracker("math.alternates", function(v) trace_alternates = v end)
+local trace_italics = false registertracker("math.italics", function(v) trace_italics = v end)
+local trace_kernpairs = false registertracker("math.kernpairs", function(v) trace_kernpairs = v end)
+local trace_domains = false registertracker("math.domains", function(v) trace_domains = v end)
+local trace_families = false registertracker("math.families", function(v) trace_families = v end)
+local trace_fences = false registertracker("math.fences", function(v) trace_fences = v end)
+local trace_unstacking = false registertracker("math.unstack", function(v) trace_unstacking = v end)
+
+local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end)
+
+local report_processing = logreporter("mathematics","processing")
+local report_remapping = logreporter("mathematics","remapping")
+local report_normalizing = logreporter("mathematics","normalizing")
+local report_collapsing = logreporter("mathematics","collapsing")
+local report_fixing = logreporter("mathematics","fixing")
+local report_patching = logreporter("mathematics","patching")
+local report_goodies = logreporter("mathematics","goodies")
+local report_variants = logreporter("mathematics","variants")
+local report_alternates = logreporter("mathematics","alternates")
+local report_italics = logreporter("mathematics","italics")
+local report_kernpairs = logreporter("mathematics","kernpairs")
+local report_domains = logreporter("mathematics","domains")
+local report_families = logreporter("mathematics","families")
+local report_fences = logreporter("mathematics","fences")
+local report_unstacking = logreporter("mathematics","unstack")
+
+local a_mathrendering = privateattribute("mathrendering")
+local a_exportstatus = privateattribute("exportstatus")
+
+local nuts = nodes.nuts
+local nodepool = nuts.pool
+local tonut = nuts.tonut
+local nutstring = nuts.tostring
+
+local setfield = nuts.setfield
+local setlink = nuts.setlink
+local setlist = nuts.setlist
+local setnext = nuts.setnext
+local setprev = nuts.setprev
+local setchar = nuts.setchar
+local setfam = nuts.setfam
+local setsubtype = nuts.setsubtype
+local setattr = nuts.setattr
+local setattrlist = nuts.setattrlist
+local setwidth = nuts.setwidth
+local setheight = nuts.setheight
+local setdepth = nuts.setdepth
+
+local getfield = nuts.getfield
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getboth = nuts.getboth
+local getid = nuts.getid
+local getsubtype = nuts.getsubtype
+local getchar = nuts.getchar
+local getfont = nuts.getfont
+local getfam = nuts.getfam
+local getattr = nuts.getattr
+local getattrs = nuts.getattrs
+local getlist = nuts.getlist
+local getwidth = nuts.getwidth
+local getheight = nuts.getheight
+local getdepth = nuts.getdepth
+
+local getnucleus = nuts.getnucleus
+local getsub = nuts.getsub
+local getsup = nuts.getsup
+local getsubpre = nuts.getsubpre
+local getsuppre = nuts.getsuppre
+
+local setnucleus = nuts.setnucleus
+local setsub = nuts.setsub
+local setsup = nuts.setsup
+local setsubpre = nuts.setsubpre
+local setsuppre = nuts.setsuppre
+
+local flush_node = nuts.flush
+local copy_node = nuts.copy
+local slide_nodes = nuts.slide
+local set_visual = nuts.setvisual
+
+local mlist_to_hlist = nuts.mlist_to_hlist
+
+local new_kern = nodepool.kern
+local new_submlist = nodepool.submlist
+local new_noad = nodepool.noad
+local new_delimiter = nodepool.delimiter
+local new_fence = nodepool.fence
+
+local fonthashes = fonts.hashes
+local fontdata = fonthashes.identifiers
+local fontcharacters = fonthashes.characters
+local fontitalics = fonthashes.italics
+
+local variables = interfaces.variables
+local texsetattribute = tex.setattribute
+local texgetattribute = tex.getattribute
+local getfontoffamily = tex.getfontoffamily
+local unsetvalue = attributes.unsetvalue
+local implement = interfaces.implement
+
+local v_reset = variables.reset
+
+local chardata = characters.data
+
+noads = noads or { } -- todo: only here
+local noads = noads
+
+noads.processors = noads.processors or { }
+local processors = noads.processors
+
+noads.handlers = noads.handlers or { }
+local handlers = noads.handlers
+
+local tasks = nodes.tasks
+local enableaction = tasks.enableaction
+local setaction = tasks.setaction
+
+local nodecodes = nodes.nodecodes
+local noadcodes = nodes.noadcodes
+local fencecodes = nodes.fencecodes
+
+local ordnoad_code = noadcodes.ord
+local opdisplaylimitsnoad_code = noadcodes.opdisplaylimits
+local oplimitsnoad_code = noadcodes.oplimits
+local opnolimitsnoad_code = noadcodes.opnolimits
+local binnoad_code = noadcodes.bin
+local relnode_code = noadcodes.rel
+local opennoad_code = noadcodes.open
+local closenoad_code = noadcodes.close
+local punctnoad_code = noadcodes.punct
+local innernoad_code = noadcodes.inner
+local undernoad_code = noadcodes.under
+local overnoad_code = noadcodes.over
+local vcenternoad_code = noadcodes.vcenter
+local ordlimitsnoad_code = noadcodes.ordlimits or oplimitsnoad_code
+
+local noad_code = nodecodes.noad -- attr nucleus sub sup
+local accent_code = nodecodes.accent -- attr nucleus sub sup accent
+local radical_code = nodecodes.radical -- attr nucleus sub sup left degree
+local fraction_code = nodecodes.fraction -- attr nucleus sub sup left right
+local subbox_code = nodecodes.subbox -- attr list
+local submlist_code = nodecodes.submlist -- attr list
+local mathchar_code = nodecodes.mathchar -- attr fam char
+local mathtextchar_code = nodecodes.mathtextchar -- attr fam char
+local delimiter_code = nodecodes.delimiter -- attr small_fam small_char large_fam large_char
+----- style_code = nodecodes.style -- attr style
+----- parameter_code = nodecodes.parameter -- attr style
+local math_choice = nodecodes.choice -- attr display text script scriptscript
+local fence_code = nodecodes.fence -- attr subtype
+
+local leftfence_code = fencecodes.left
+local middlefence_code = fencecodes.middle
+local rightfence_code = fencecodes.right
+
+-- local mathclasses = mathematics.classes
+-- local fenceclasses = {
+-- [leftfence_code] = mathclasses.open,
+-- [middlefence_code] = mathclasses.middle,
+-- [rightfence_code] = mathclasses.close,
+-- }
+
+-- this initial stuff is tricky as we can have removed and new nodes with the same address
+-- the only way out is a free-per-page list of nodes (not bad anyway)
+
+-- local gf = getfield local gt = setmetatableindex("number") getfield = function(n,f) gt[f] = gt[f] + 1 return gf(n,f) end mathematics.GETFIELD = gt
+-- local sf = setfield local st = setmetatableindex("number") setfield = function(n,f,v) st[f] = st[f] + 1 sf(n,f,v) end mathematics.SETFIELD = st
+
+local function process(start,what,n,parent)
+
+ if n then
+ n = n + 1
+ else
+ n = 0
+ end
+ --
+ local initial = start
+ --
+ slide_nodes(start) -- we still miss a prev in noads -- fences test code
+ --
+ while start do
+ local id = getid(start)
+ if trace_processing then
+ if id == noad_code then
+ report_processing("%w%S, class %a",n*2,nutstring(start),noadcodes[getsubtype(start)])
+ elseif id == mathchar_code then
+ local char = getchar(start)
+ local font = getfont(start)
+ local fam = getfam(start)
+ report_processing("%w%S, family %a, font %a, char %a, shape %c",n*2,nutstring(start),fam,font,char,char)
+ else
+ report_processing("%w%S",n*2,nutstring(start))
+ end
+ end
+ local proc = what[id]
+ if proc then
+ -- report_processing("start processing")
+ local done, newstart, newinitial = proc(start,what,n,parent) -- prev is bugged: or getprev(start)
+ if newinitial then
+ initial = newinitial -- temp hack .. we will make all return head
+ if newstart then
+ start = newstart
+ -- report_processing("stop processing (new start)")
+ else
+ -- report_processing("quit processing (done)")
+ break
+ end
+ else
+ if newstart then
+ start = newstart
+ -- report_processing("stop processing (new start)")
+ else
+ -- report_processing("stop processing")
+ end
+ end
+ elseif id == noad_code then
+ -- single characters are like this
+ local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
+ noad = getsup (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsub (start) if noad then process(noad,what,n,start) end -- list
+ if getsubpre then
+ noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list
+ end
+ elseif id == mathchar_code or id == mathtextchar_code or id == delimiter_code then
+ break
+ elseif id == subbox_code or id == submlist_code then
+ local noad = getlist(start) if noad then process(noad,what,n,start) end -- list (not getlist !)
+ elseif id == fraction_code then
+ local noad = getfield(start,"num") if noad then process(noad,what,n,start) end -- list
+ noad = getfield(start,"denom") if noad then process(noad,what,n,start) end -- list
+ noad = getfield(start,"left") if noad then process(noad,what,n,start) end -- delimiter
+ noad = getfield(start,"right") if noad then process(noad,what,n,start) end -- delimiter
+ elseif id == math_choice then
+ local noad = getfield(start,"display") if noad then process(noad,what,n,start) end -- list
+ noad = getfield(start,"text") if noad then process(noad,what,n,start) end -- list
+ noad = getfield(start,"script") if noad then process(noad,what,n,start) end -- list
+ noad = getfield(start,"scriptscript") if noad then process(noad,what,n,start) end -- list
+ elseif id == fence_code then
+ local noad = getfield(start,"delimiter") if noad then process(noad,what,n,start) end -- delimiter
+ elseif id == radical_code then
+ local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
+ noad = getsup (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsub (start) if noad then process(noad,what,n,start) end -- list
+ if getsubpre then
+ noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list
+ end
+ noad = getfield(start,"left") if noad then process(noad,what,n,start) end -- delimiter
+ noad = getfield(start,"degree") if noad then process(noad,what,n,start) end -- list
+ elseif id == accent_code then
+ local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
+ noad = getsup (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsub (start) if noad then process(noad,what,n,start) end -- list
+ if getsubpre then
+ noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list
+ noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list
+ end
+ noad = getfield(start,"accent") if noad then process(noad,what,n,start) end -- list
+ noad = getfield(start,"bot_accent") if noad then process(noad,what,n,start) end -- list
+ -- elseif id == style_code then
+ -- -- has a next
+ -- elseif id == parameter_code then
+ -- -- has a next
+ -- else
+ -- -- glue, penalty, etc
+ end
+ start = getnext(start)
+ end
+ if not parent then
+ return initial -- only first level -- for now
+ end
+end
+
+local function processnested(current,what,n)
+ local noad = nil
+ local id = getid(current)
+ if id == noad_code then
+ noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
+ noad = getsup (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsub (current) if noad then process(noad,what,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list
+ end
+ elseif id == subbox_code or id == submlist_code then
+ noad = getlist(current) if noad then process(noad,what,n,current) end -- list (not getlist !)
+ elseif id == fraction_code then
+ noad = getfield(current,"num") if noad then process(noad,what,n,current) end -- list
+ noad = getfield(current,"denom") if noad then process(noad,what,n,current) end -- list
+ noad = getfield(current,"left") if noad then process(noad,what,n,current) end -- delimiter
+ noad = getfield(current,"right") if noad then process(noad,what,n,current) end -- delimiter
+ elseif id == math_choice then
+ noad = getfield(current,"display") if noad then process(noad,what,n,current) end -- list
+ noad = getfield(current,"text") if noad then process(noad,what,n,current) end -- list
+ noad = getfield(current,"script") if noad then process(noad,what,n,current) end -- list
+ noad = getfield(current,"scriptscript") if noad then process(noad,what,n,current) end -- list
+ elseif id == fence_code then
+ noad = getfield(current,"delimiter") if noad then process(noad,what,n,current) end -- delimiter
+ elseif id == radical_code then
+ noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
+ noad = getsup (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsub (current) if noad then process(noad,what,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list
+ end
+ noad = getfield(current,"left") if noad then process(noad,what,n,current) end -- delimiter
+ noad = getfield(current,"degree") if noad then process(noad,what,n,current) end -- list
+ elseif id == accent_code then
+ noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
+ noad = getsup (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsub (current) if noad then process(noad,what,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list
+ end
+ noad = getfield(current,"accent") if noad then process(noad,what,n,current) end -- list
+ noad = getfield(current,"bot_accent") if noad then process(noad,what,n,current) end -- list
+ end
+end
+
+local function processstep(current,process,n,id)
+ local noad = nil
+ local id = id or getid(current)
+ if id == noad_code then
+ noad = getnucleus(current) if noad then process(noad,n,current) end -- list
+ noad = getsup (current) if noad then process(noad,n,current) end -- list
+ noad = getsub (current) if noad then process(noad,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,n,current) end -- list
+ end
+ elseif id == subbox_code or id == submlist_code then
+ noad = getlist(current) if noad then process(noad,n,current) end -- list (not getlist !)
+ elseif id == fraction_code then
+ noad = getfield(current,"num") if noad then process(noad,n,current) end -- list
+ noad = getfield(current,"denom") if noad then process(noad,n,current) end -- list
+ noad = getfield(current,"left") if noad then process(noad,n,current) end -- delimiter
+ noad = getfield(current,"right") if noad then process(noad,n,current) end -- delimiter
+ elseif id == math_choice then
+ noad = getfield(current,"display") if noad then process(noad,n,current) end -- list
+ noad = getfield(current,"text") if noad then process(noad,n,current) end -- list
+ noad = getfield(current,"script") if noad then process(noad,n,current) end -- list
+ noad = getfield(current,"scriptscript") if noad then process(noad,n,current) end -- list
+ elseif id == fence_code then
+ noad = getfield(current,"delimiter") if noad then process(noad,n,current) end -- delimiter
+ elseif id == radical_code then
+ noad = getnucleus(current) if noad then process(noad,n,current) end -- list
+ noad = getsup (current) if noad then process(noad,n,current) end -- list
+ noad = getsub (current) if noad then process(noad,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,n,current) end -- list
+ end
+ noad = getfield(current,"left") if noad then process(noad,n,current) end -- delimiter
+ noad = getfield(current,"degree") if noad then process(noad,n,current) end -- list
+ elseif id == accent_code then
+ noad = getnucleus(current) if noad then process(noad,n,current) end -- list
+ noad = getsup (current) if noad then process(noad,n,current) end -- list
+ noad = getsub (current) if noad then process(noad,n,current) end -- list
+ if getsubpre then
+ noad = getsuppre (current) if noad then process(noad,n,current) end -- list
+ noad = getsubpre (current) if noad then process(noad,n,current) end -- list
+ end
+ noad = getfield(current,"accent") if noad then process(noad,n,current) end -- list
+ noad = getfield(current,"bot_accent") if noad then process(noad,n,current) end -- list
+ end
+end
+
+local function processnoads(head,actions,banner)
+ if trace_processing then
+ report_processing("start %a",banner)
+ head = process(head,actions)
+ report_processing("stop %a",banner)
+ else
+ head = process(head,actions)
+ end
+ return head
+end
+
+noads.process = processnoads
+noads.processnested = processnested
+noads.processouter = process
+
+-- experiment (when not present fall back to fam 0) -- needs documentation
+
+local unknowns = { }
+local checked = { } -- simple case
+local tracked = false trackers.register("fonts.missing", function(v) tracked = v end)
+local cached = setmetatableindex("table") -- complex case
+
+local function errorchar(font,char)
+ local done = unknowns[char]
+ if done then
+ unknowns[char] = done + 1
+ else
+ unknowns[char] = 1
+ end
+ if tracked then
+ -- slower as we check each font too and we always replace as math has
+ -- more demands than text
+ local fake = cached[font][char]
+ if fake then
+ return fake
+ else
+ local kind, fake = fonts.checkers.placeholder(font,char)
+ if not fake or kind ~= "char" then
+ fake = 0x3F
+ end
+ cached[font][char] = fake
+ return fake
+ end
+ else
+ -- only simple checking, report at the end so one should take
+ -- action anyway ... we can miss a few checks but that is ok
+ -- as there is at least one reported
+ if not checked[char] then
+ if trace_normalizing then
+ report_normalizing("character %C is not available",char)
+ end
+ checked[char] = true
+ end
+ return 0x3F
+ end
+end
+
+-- 0-2 regular
+-- 3-5 bold
+-- 6-8 pseudobold
+
+-- this could best be integrated in the remapper, and if we run into problems, we
+-- might as well do this
+
+do
+
+ local families = { }
+ local a_mathfamily = privateattribute("mathfamily")
+ local boldmap = mathematics.boldmap
+
+ local familymap = { [0] =
+ "regular",
+ "regular",
+ "regular",
+ "bold",
+ "bold",
+ "bold",
+ "pseudobold",
+ "pseudobold",
+ "pseudobold",
+ }
+
+ families[fraction_code] = function(pointer,what,n,parent)
+ local a = getattr(pointer,a_mathfamily)
+ if a and a >= 0 then
+ if a > 0 then
+ setattr(pointer,a_mathfamily,0)
+ if a > 5 then
+ a = a - 3
+ end
+ end
+ setfam(pointer,a)
+ end
+ processnested(pointer,families,n+1)
+ end
+
+ families[noad_code] = function(pointer,what,n,parent)
+ local a = getattr(pointer,a_mathfamily)
+ if a and a >= 0 then
+ if a > 0 then
+ setattr(pointer,a_mathfamily,0)
+ if a > 5 then
+ a = a - 3
+ end
+ end
+ setfam(pointer,a)
+ end
+ processnested(pointer,families,n+1)
+ end
+
+ families[mathchar_code] = function(pointer)
+ if getfam(pointer) == 0 then
+ local a = getattr(pointer,a_mathfamily)
+ if a and a > 0 then
+ setattr(pointer,a_mathfamily,0)
+ if a > 5 then
+ local char = getchar(pointer)
+ local bold = boldmap[char]
+ local newa = a - 3
+ if not bold then
+ if trace_families then
+ report_families("no bold replacement for %C, family %s with remap %s becomes %s with remap %s",char,a,familymap[a],newa,familymap[newa])
+ end
+ setfam(pointer,newa)
+ elseif not fontcharacters[getfontoffamily(newa)][bold] then
+ if trace_families then
+ report_families("no bold character for %C, family %s with remap %s becomes %s with remap %s",char,a,familymap[a],newa,familymap[newa])
+ end
+ if newa > 3 then
+ setfam(pointer,newa-3)
+ end
+ else
+ setattr(pointer,a_exportstatus,char)
+ setchar(pointer,bold)
+ if trace_families then
+ report_families("replacing %C by bold %C, family %s with remap %s becomes %s with remap %s",char,bold,a,familymap[a],newa,familymap[newa])
+ end
+ setfam(pointer,newa)
+ end
+ else
+ local char = getchar(pointer)
+ if not fontcharacters[getfontoffamily(a)][char] then
+ if trace_families then
+ report_families("no bold replacement for %C",char)
+ end
+ else
+ if trace_families then
+ report_families("family of %C becomes %s with remap %s",char,a,familymap[a])
+ end
+ setfam(pointer,a)
+ end
+ end
+ end
+ end
+ end
+ families[delimiter_code] = function(pointer)
+ if getfield(pointer,"small_fam") == 0 then
+ local a = getattr(pointer,a_mathfamily)
+ if a and a > 0 then
+ setattr(pointer,a_mathfamily,0)
+ if a > 5 then
+ -- no bold delimiters in unicode
+ a = a - 3
+ end
+ local char = getfield(pointer,"small_char")
+ local okay = fontcharacters[getfontoffamily(a)][char]
+ if okay then
+ setfield(pointer,"small_fam",a)
+ elseif a > 2 then
+ setfield(pointer,"small_fam",a-3)
+ end
+ local char = getfield(pointer,"large_char")
+ local okay = fontcharacters[getfontoffamily(a)][char]
+ if okay then
+ setfield(pointer,"large_fam",a)
+ elseif a > 2 then
+ setfield(pointer,"large_fam",a-3)
+ end
+ else
+ setfield(pointer,"small_fam",0)
+ setfield(pointer,"large_fam",0)
+ end
+ end
+ end
+
+ -- will become:
+
+ -- families[delimiter_code] = function(pointer)
+ -- if getfam(pointer) == 0 then
+ -- local a = getattr(pointer,a_mathfamily)
+ -- if a and a > 0 then
+ -- setattr(pointer,a_mathfamily,0)
+ -- if a > 5 then
+ -- -- no bold delimiters in unicode
+ -- a = a - 3
+ -- end
+ -- local char = getchar(pointer)
+ -- local okay = fontcharacters[getfontoffamily(a)][char]
+ -- if okay then
+ -- setfam(pointer,a)
+ -- elseif a > 2 then
+ -- setfam(pointer,a-3)
+ -- end
+ -- else
+ -- setfam(pointer,0)
+ -- end
+ -- end
+ -- end
+
+ families[mathtextchar_code] = families[mathchar_code]
+
+ function handlers.families(head,style,penalties)
+ processnoads(head,families,"families")
+ return true -- not needed
+ end
+
+end
+
+-- character remapping
+
+do
+
+ local a_mathalphabet = privateattribute("mathalphabet")
+ local a_mathgreek = privateattribute("mathgreek")
+
+ local relocate = { }
+
+ local remapalphabets = mathematics.remapalphabets
+ local fallbackstyleattr = mathematics.fallbackstyleattr
+ local setnodecolor = colortracers.set
+
+ local function report_remap(tag,id,old,new,extra)
+ if new then
+ report_remapping("remapping %s in font (%s,%s) from %C to %C%s",
+ tag,id,fontdata[id].properties.fontname or "",old,new,extra)
+ else
+ -- error !
+ report_remapping("remapping %s in font (%s,%s) from %C to ?",
+ tag,id,fontdata[id].properties.fontname or "",old)
+ end
+ end
+
+ local function checked(pointer)
+ local char = getchar(pointer)
+ local font = getfont(pointer)
+ local data = fontcharacters[font]
+ if not data[char] then
+ local specials = characters.data[char].specials
+ if specials and (specials[1] == "char" or specials[1] == "font") then
+ local newchar = specials[#specials]
+ if trace_remapping then
+ report_remap("fallback",font,char,newchar)
+ end
+ if trace_analyzing then
+ setnodecolor(pointer,"font:isol")
+ end
+ setattr(pointer,a_exportstatus,char) -- testcase: exponentiale
+ setchar(pointer,newchar)
+ return true
+ end
+ end
+ end
+
+ -- We can optimize this if we really think that math is a bottleneck which it never
+ -- really is. Beware: the font is the text font in the family, so we only check the
+ -- text font here.
+
+ relocate[mathchar_code] = function(pointer)
+ local g = getattr(pointer,a_mathgreek) or 0
+ local a = getattr(pointer,a_mathalphabet) or 0
+ -- local g, a = getattrs(pointer,a_mathgreek,a_mathalphabet)
+ -- if not a then a = 0 end
+ -- if not g then g = 0 end
+ local char = getchar(pointer)
+ local font = getfont(pointer)
+ local characters = fontcharacters[font]
+ if a > 0 or g > 0 then
+ if a > 0 then
+ -- not really critital but we could use properties
+ setattr(pointer,a_mathgreek,0)
+ end
+ if g > 0 then
+ -- not really critital but we could use properties
+ setattr(pointer,a_mathalphabet,0)
+ end
+ local newchar = remapalphabets(char,a,g)
+ if newchar then
+ local newchardata = characters[newchar]
+ if newchardata then
+ if trace_remapping then
+ report_remap("char",font,char,newchar,newchardata.commands and " (virtual)" or "")
+ end
+ if trace_analyzing then
+ setnodecolor(pointer,"font:isol")
+ end
+ setchar(pointer,newchar)
+ return true
+ else
+ local fallback = fallbackstyleattr(a)
+ if fallback then
+ local newchar = remapalphabets(char,fallback,g)
+ if newchar then
+ if characters[newchar] then
+ if trace_remapping then
+ report_remap("char",font,char,newchar," (fallback remapping used)")
+ end
+ if trace_analyzing then
+ setnodecolor(pointer,"font:isol")
+ end
+ setchar(pointer,newchar)
+ return true
+ elseif trace_remapping then
+ report_remap("char",font,char,newchar," fails (no fallback character)")
+ end
+ elseif trace_remapping then
+ report_remap("char",font,char,newchar," fails (no fallback remap character)")
+ end
+ elseif trace_remapping then
+ report_remap("char",font,char,newchar," fails (no fallback style)")
+ end
+ end
+ elseif trace_remapping then
+ local chardata = characters[char]
+ if chardata and chardata.commands then
+ report_remap("char",font,char,char," (virtual)")
+ end
+ end
+ end
+ if not characters[char] then
+ local fam = getfam(pointer)
+ local fnt = getfontoffamily(fam,1)
+ setchar(pointer,errorchar(font,char))
+ if font ~= fnt then
+ errorchar(fnt,char)
+ errorchar(getfontoffamily(fam,2),char)
+ end
+ end
+ if trace_analyzing then
+ setnodecolor(pointer,"font:medi")
+ end
+ if check_coverage then
+ return checked(pointer)
+ end
+ end
+
+ relocate[mathtextchar_code] = function(pointer)
+ if trace_analyzing then
+ setnodecolor(pointer,"font:init")
+ end
+ end
+
+ relocate[delimiter_code] = function(pointer)
+ if trace_analyzing then
+ setnodecolor(pointer,"font:fina")
+ end
+ end
+
+ function handlers.relocate(head,style,penalties)
+ processnoads(head,relocate,"relocate")
+ return true -- not needed
+ end
+
+end
+
+-- rendering (beware, not exported)
+
+do
+
+ local render = { }
+
+ local rendersets = mathematics.renderings.numbers or { } -- store
+
+ render[mathchar_code] = function(pointer)
+ local attr = getattr(pointer,a_mathrendering)
+ if attr and attr > 0 then
+ local char = getchar(pointer)
+ local renderset = rendersets[attr]
+ if renderset then
+ local newchar = renderset[char]
+ if newchar then
+ local font = getfont(pointer)
+ local characters = fontcharacters[font]
+ if characters and characters[newchar] then
+ setchar(pointer,newchar)
+ setattr(pointer,a_exportstatus,char)
+ end
+ end
+ end
+ end
+ end
+
+ function handlers.render(head,style,penalties)
+ processnoads(head,render,"render")
+ return true -- not needed
+ end
+
+end
+
+-- some resize options (this works ok because the content is
+-- empty and no larger next will be forced)
+--
+-- beware: we don't use \delcode but \Udelcode and as such have
+-- no large_fam; also, we need to check for subtype and/or
+-- small_fam not being 0 because \. sits in 0,0 by default
+--
+-- todo: just replace the character by an ord noad
+-- and remove the right delimiter as well
+
+do
+
+ local a_mathsize = privateattribute("mathsize") -- this might move into other fence code
+ local resize = { }
+
+ resize[fence_code] = function(pointer)
+ local subtype = getsubtype(pointer)
+ if subtype == leftfence_code or subtype == rightfence_code then
+ local a = getattr(pointer,a_mathsize)
+ if a and a > 0 then
+ local method = div(a,100)
+ local size = a % 100
+ setattr(pointer,a_mathsize,0)
+ local delimiter = getfield(pointer,"delimiter")
+ local chr = getchar(delimiter)
+ if chr > 0 then
+ local fam = getfam(delimiter)
+ local id = getfontoffamily(fam)
+ if id > 0 then
+ local data = fontdata[id]
+ local char = mathematics.big(data,chr,size,method)
+ local ht = getheight(pointer)
+ local dp = getdepth(pointer)
+ if ht == 1 or dp == 1 then -- 1 scaled point is a signal
+ local chardata = data.characters[char]
+ if ht == 1 then
+ setheight(pointer,chardata.height)
+ end
+ if dp == 1 then
+ setdepth(pointer,chardata.depth)
+ end
+ end
+ if trace_fences then
+ report_fences("replacing %C by %C using method %a and size %a",chr,char,method,size)
+ end
+ setchar(delimiter,char)
+ end
+ end
+ end
+ end
+ end
+
+ function handlers.resize(head,style,penalties)
+ processnoads(head,resize,"resize")
+ return true -- not needed
+ end
+
+end
+
+-- still not perfect:
+
+do
+
+ local a_autofence = privateattribute("mathautofence")
+ local autofences = { }
+ local dummyfencechar = 0x2E
+
+ local function makefence(what,char)
+ local d = new_delimiter() -- todo: attr
+ local f = new_fence() -- todo: attr
+ if char then
+ local sym = getnucleus(char)
+ local chr = getchar(sym)
+ local fam = getfam(sym)
+ if chr == dummyfencechar then
+ chr = 0
+ end
+ setchar(d,chr)
+ setfam(d,fam)
+ flush_node(sym)
+ end
+ setattrlist(d,char)
+ setattrlist(f,char)
+ setsubtype(f,what)
+ setfield(f,"delimiter",d)
+ setfield(f,"class",-1) -- tex itself does this, so not fenceclasses[what]
+ return f
+ end
+
+ local function show(where,pointer)
+ print("")
+ local i = 0
+ for n in nuts.traverse(pointer) do
+ i = i + 1
+ print(i,where,nuts.tonode(n))
+ end
+ print("")
+ end
+
+ local function makelist(middle,noad,f_o,o_next,c_prev,f_c)
+-- report_fences(
+-- "middle %s, noad %s, open %s, opennext %s, closeprev %s, close %s",
+-- middle or "?",
+-- noad or "?",
+-- f_o or "?",
+-- o_next or "?",
+-- c_prev or "?",
+-- f_c or "?"
+-- )
+ local list = new_submlist()
+ setsubtype(noad,innernoad_code)
+ setnucleus(noad,list)
+ setlist(list,f_o)
+ setlink(f_o,o_next) -- prev of list is nil
+ setlink(c_prev,f_c) -- next of list is nil
+-- show("list",f_o)
+ if middle and next(middle) then
+ local prev = f_o
+ local current = o_next
+ while current ~= f_c do
+ local midl = middle[current]
+ local next = getnext(current)
+ if midl then
+ local fence = makefence(middlefence_code,current)
+ setnucleus(current)
+ flush_node(current)
+ middle[current] = nil
+ -- replace_node
+ setlink(prev,fence,next)
+ prev = fence
+ else
+ prev = current
+ end
+ current = next
+ end
+ end
+ return noad
+ end
+
+ -- relinking is now somewhat overdone
+
+ local function convert_both(open,close,middle)
+ local o_next = getnext(open)
+ if o_next == close then
+ return close
+ else
+ local c_prev, c_next = getboth(close)
+ local f_o = makefence(leftfence_code,open)
+ local f_c = makefence(rightfence_code,close)
+ makelist(middle,open,f_o,o_next,c_prev,f_c)
+ setnucleus(close)
+ flush_node(close)
+ -- open is now a list
+ setlink(open,c_next)
+ return open
+ end
+ end
+
+ local function convert_open(open,last,middle) -- last is really last (final case)
+ local f_o = makefence(leftfence_code,open)
+ local f_c = makefence(rightfence_code)
+ local o_next = getnext(open)
+ makelist(middle,open,f_o,o_next,last,nil)
+ -- open is now a list
+ setlink(open,l_next)
+ return open
+ end
+
+ local function convert_close(first,close,middle)
+ local f_o = makefence(leftfence_code)
+ local f_c = makefence(rightfence_code,close)
+ local c_prev = getprev(close)
+ local f_next = getnext(first)
+ makelist(middle, close, f_o,f_next,c_prev,f_c)
+ -- close is now a list
+ if c_prev ~= first then
+ setlink(first,close)
+ end
+ return close
+ end
+
+ local stacks = setmetatableindex("table")
+
+ -- 1=open 2=close 3=middle 4=both
+
+ local function processfences(pointer,n,parent)
+ local current = pointer
+ local last = pointer
+ local start = pointer
+ local done = false
+ local initial = pointer
+ local stack = nil
+ local middle = nil -- todo: use properties
+ while current do
+-- show("before",pointer)
+ local id = getid(current)
+ if id == noad_code then
+ local a = getattr(current,a_autofence)
+ if a and a > 0 then
+ local stack = stacks[n]
+ setattr(current,a_autofence,0) -- hm, better use a property
+ local level = #stack
+ if a == 1 then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"open","open")
+ end
+ insert(stack,current)
+ elseif a == 2 then
+ local open = remove(stack)
+ if open then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"close","both")
+ end
+ current = convert_both(open,current,middle)
+ elseif current == start then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"close","skip")
+ end
+ else
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"close","close")
+ end
+ current = convert_close(initial,current,middle)
+ if not parent then
+ initial = current
+ end
+ end
+ elseif a == 3 then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"middle","middle")
+ end
+ if middle then
+ middle[current] = last
+ else
+ middle = { [current] = last }
+ end
+ elseif a == 4 then
+ if not stack or #stack == 0 then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"both","open")
+ end
+ insert(stack,current)
+ else
+ local open = remove(stack)
+ if open then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"both","both")
+ end
+ current = convert_both(open,current,middle)
+ elseif current == start then
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"both","skip")
+ end
+ else
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,level,"both","close")
+ end
+ current = convert_close(initial,current,middle)
+ if not parent then
+ initial = current
+ end
+ end
+ end
+ end
+ done = true
+ else
+ processstep(current,processfences,n+1,id)
+ end
+ else
+ -- next at current level
+ processstep(current,processfences,n,id)
+ end
+-- show("after",pointer)
+ last = current
+ current = getnext(current)
+ end
+ if done then
+ local stack = stacks[n]
+ local s = #stack
+ if s > 0 then
+ for i=1,s do
+ local open = remove(stack)
+ if trace_fences then
+ report_fences("%2i: level %i, handling %s, action %s",n,#stack,"flush","open")
+ end
+ last = convert_open(open,last,middle)
+ end
+-- show("done",pointer)
+ end
+ end
+ end
+
+ -- we can have a first changed node .. an option is to have a leading dummy node in math
+ -- lists like the par node as it can save a lot of mess
+
+ local enabled = false
+
+ implement {
+ name = "enableautofences",
+ onlyonce = true,
+ actions = function()
+ enableaction("math","noads.handlers.autofences")
+ enabled = true
+ end
+ }
+
+ function handlers.autofences(head,style,penalties)
+ if enabled then -- tex.modes.c_math_fences_auto
+ -- inspect(nodes.totree(head))
+ processfences(head,1)
+ -- inspect(nodes.totree(head))
+ end
+ end
+
+end
+
+-- normalize scripts
+
+do
+
+ local unscript = { } noads.processors.unscript = unscript
+ local superscripts = characters.superscripts
+ local subscripts = characters.subscripts
+ local fractions = characters.fractions
+ local replaced = { }
+
+ local function replace(pointer,what,n,parent)
+ pointer = parent -- we're following the parent list (chars trigger this)
+ local next = getnext(pointer)
+ local start_super, stop_super, start_sub, stop_sub
+ local mode = "unset"
+ while next and getid(next) == noad_code do
+ local nextnucleus = getnucleus(next)
+ if nextnucleus and getid(nextnucleus) == mathchar_code and not getsub(next) and not getsup(next) then
+ local char = getchar(nextnucleus)
+ local s = superscripts[char]
+ if s then
+ if not start_super then
+ start_super = next
+ mode = "super"
+ elseif mode == "sub" then
+ break
+ end
+ stop_super = next
+ next = getnext(next)
+ setchar(nextnucleus,s)
+ replaced[char] = (replaced[char] or 0) + 1
+ if trace_normalizing then
+ report_normalizing("superscript %C becomes %C",char,s)
+ end
+ else
+ local s = subscripts[char]
+ if s then
+ if not start_sub then
+ start_sub = next
+ mode = "sub"
+ elseif mode == "super" then
+ break
+ end
+ stop_sub = next
+ next = getnext(next)
+ setchar(nextnucleus,s)
+ replaced[char] = (replaced[char] or 0) + 1
+ if trace_normalizing then
+ report_normalizing("subscript %C becomes %C",char,s)
+ end
+ else
+ break
+ end
+ end
+ else
+ break
+ end
+ end
+ if start_super then
+ if start_super == stop_super then
+ setsup(pointer,getnucleus(start_super))
+ else
+ local list = new_submlist() -- todo attr
+ setlist(list,start_super)
+ setsup(pointer,list)
+ end
+ if mode == "super" then
+ setnext(pointer,getnext(stop_super))
+ end
+ setnext(stop_super)
+ end
+ if start_sub then
+
+-- if mode == "sub" then
+-- local sup = getsup(pointer)
+-- if sup and not getsub(pointer) then
+-- local nxt = getnext(pointer)
+-- local new = new_noad(pointer)
+-- setnucleus(new,new_submlist())
+-- setlink(pointer,new,nxt)
+-- pointer = new
+-- end
+-- end
+
+ if start_sub == stop_sub then
+ setsub(pointer,getnucleus(start_sub))
+ else
+ local list = new_submlist() -- todo attr
+ setlist(list,start_sub)
+ setsub(pointer,list)
+ end
+ if mode == "sub" then
+ setnext(pointer,getnext(stop_sub))
+ end
+ setnext(stop_sub)
+ end
+ -- we could return stop
+ end
+
+ unscript[mathchar_code] = replace -- not noads as we need to recurse
+
+ function handlers.unscript(head,style,penalties)
+ processnoads(head,unscript,"unscript")
+ return true -- not needed
+ end
+
+end
+
+do
+
+ local unstack = { } noads.processors.unstack = unstack
+ local enabled = false
+ local a_unstack = privateattribute("mathunstack")
+
+ unstack[noad_code] = function(pointer)
+ if getattr(pointer,a_unstack) then
+ local sup = getsup(pointer)
+ local sub = getsub(pointer)
+ if sup and sub then
+ -- if trace_unstacking then
+ -- report_unstacking() -- todo ... what to show ...
+ -- end
+ local nxt = getnext(pointer)
+ local new = new_noad(pointer)
+ setnucleus(new,new_submlist())
+ setsub(pointer)
+ setsub(new,sub)
+ setlink(pointer,new,nxt)
+ end
+ end
+ end
+
+ function handlers.unstack(head,style,penalties)
+ if enabled then
+ processnoads(head,unstack,"unstack")
+ return true -- not needed
+ end
+ end
+
+ implement {
+ name = "enablescriptunstacking",
+ onlyonce = true,
+ actions = function()
+ enableaction("math","noads.handlers.unstack")
+ enabled = true
+ end
+ }
+
+end
+
+do
+
+ local function collected(list)
+ if list and next(list) then
+ local n, t = 0, { }
+ for k, v in sortedhash(list) do
+ n = n + 1
+ t[n] = formatters["%C"](k)
+ end
+ return formatters["% t (n=%s)"](t,n)
+ end
+ end
+
+ statistics.register("math script replacements", function()
+ return collected(replaced)
+ end)
+
+ statistics.register("unknown math characters", function()
+ return collected(unknowns)
+ end)
+
+end
+
+-- math alternates: (in xits lgf: $ABC$ $\cal ABC$ $\mathalternate{cal}\cal ABC$)
+-- math alternates: (in lucidaot lgf: $ABC \mathalternate{italic} ABC$)
+
+-- todo: set alternate for specific symbols
+-- todo: no need to do this when already loaded
+-- todo: use a fonts.hashes.mathalternates
+
+do
+
+ local last = 0
+
+ local known = setmetatableindex(function(t,k)
+ local v = bor(0,2^last)
+ t[k] = v
+ last = last + 1
+ return v
+ end)
+
+ local defaults = {
+ dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
+ -- zero = { feature = 'zero', value = 1, comment = "Slashed or Dotted Zero" }, -- in no math font (yet)
+ }
+
+ local function initializemathalternates(tfmdata)
+ local goodies = tfmdata.goodies
+ local autolist = defaults -- table.copy(defaults)
+
+ local function setthem(newalternates)
+ local resources = tfmdata.resources -- was tfmdata.shared
+ local mathalternates = resources.mathalternates
+ local alternates, attributes, registered, presets
+ if mathalternates then
+ alternates = mathalternates.alternates
+ attributes = mathalternates.attributes
+ registered = mathalternates.registered
+ else
+ alternates, attributes, registered = { }, { }, { }
+ mathalternates = {
+ attributes = attributes,
+ alternates = alternates,
+ registered = registered,
+ presets = { },
+ resets = { },
+ hashes = setmetatableindex("table")
+ }
+ resources.mathalternates = mathalternates
+ end
+ --
+ for name, data in sortedhash(newalternates) do
+ if alternates[name] then
+ -- ignore
+ else
+ local attr = known[name]
+ attributes[attr] = data
+ alternates[name] = attr
+ registered[#registered+1] = attr
+ end
+ end
+ end
+
+ if goodies then
+ local done = { }
+ for i=1,#goodies do
+ -- first one counts
+ -- we can consider sharing the attributes ... todo (only once scan)
+ local mathgoodies = goodies[i].mathematics
+ local alternates = mathgoodies and mathgoodies.alternates
+ if alternates then
+ if trace_goodies then
+ report_goodies("loading alternates for font %a",tfmdata.properties.name)
+ end
+ for k, v in next, autolist do
+ if not alternates[k] then
+ alternates[k] = v
+ end
+ end
+ setthem(alternates)
+ return
+ end
+ end
+ end
+
+ if trace_goodies then
+ report_goodies("loading default alternates for font %a",tfmdata.properties.name)
+ end
+ setthem(autolist)
+
+ end
+
+ registerotffeature {
+ name = "mathalternates",
+ description = "additional math alternative shapes",
+ initializers = {
+ base = initializemathalternates,
+ node = initializemathalternates,
+ }
+ }
+
+ -- local getalternate = otf.getalternate (runtime new method so ...)
+
+ -- todo: not shared but copies ... one never knows
+
+ local a_mathalternate = privateattribute("mathalternate")
+ local alternate = { } -- processors.alternate = alternate
+ local fontdata = fonts.hashes.identifiers
+ local fontresources = fonts.hashes.resources
+
+ local function getalternate(fam,tag,current)
+ local resources = fontresources[getfontoffamily(fam)]
+ local attribute = unsetvalue
+ if resources then
+ local mathalternates = resources.mathalternates
+ if mathalternates then
+ local presets = mathalternates.presets
+ if presets then
+ local resets = mathalternates.resets
+ attribute = presets[tag]
+ if not attribute then
+ attribute = 0
+ local alternates = mathalternates.alternates
+ for s in gmatch(tag,"[^, ]+") do
+ if s == v_reset then
+ resets[tag] = true
+ current = unsetvalue
+ else
+ local a = alternates[s] -- or known[s]
+ if a then
+ attribute = bor(attribute,a)
+ end
+ end
+ end
+ if attribute == 0 then
+ attribute = unsetvalue
+ end
+ presets[tag] = attribute
+ elseif resets[tag] then
+ current = unsetvalue
+ end
+ end
+ end
+ end
+ if attribute > 0 and current and current > 0 then
+ return bor(current,attribute)
+ else
+ return attribute
+ end
+ end
+
+ local function presetalternate(fam,tag)
+ texsetattribute(a_mathalternate,getalternate(fam,tag))
+ end
+
+ implement {
+ name = "presetmathalternate",
+ actions = presetalternate,
+ arguments = { "integer", "string" }
+ }
+
+ local function setalternate(fam,tag)
+ local a = texgetattribute(a_mathalternate)
+ local v = getalternate(fam,tag,a)
+ texsetattribute(a_mathalternate,v)
+ end
+
+ implement {
+ name = "setmathalternate",
+ actions = setalternate,
+ arguments = { "integer", "string" }
+ }
+
+ alternate[mathchar_code] = function(pointer) -- slow
+ local a = getattr(pointer,a_mathalternate)
+ if a and a > 0 then
+ setattr(pointer,a_mathalternate,0)
+ local fontid = getfont(pointer)
+ local resources = fontresources[fontid]
+ if resources then
+ local mathalternates = resources.mathalternates
+ if mathalternates then
+ local attributes = mathalternates.attributes
+ local registered = mathalternates.registered
+ local hashes = mathalternates.hashes
+ for i=1,#registered do
+ local r = registered[i]
+ if band(a,r) ~= 0 then
+ local char = getchar(pointer)
+ local alt = hashes[i][char]
+ if alt == nil then
+ local what = attributes[r]
+ alt = otf.getalternate(fontdata[fontid],char,what.feature,what.value) or false
+ if alt == char then
+ alt = false
+ end
+ hashes[i][char] = alt
+ end
+ if alt then
+ if trace_alternates then
+ local what = attributes[r]
+ report_alternates("alternate %a, value %a, replacing glyph %U by glyph %U",
+ tostring(what.feature),tostring(what.value),getchar(pointer),alt)
+ end
+ setchar(pointer,alt)
+ break
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ function handlers.alternates(head,style,penalties)
+ processnoads(head,alternate,"alternate")
+ return true -- not needed
+ end
+
+end
+
+-- italics: we assume that only characters matter
+--
+-- = we check for correction first because accessing nodes is slower
+-- = the actual glyph is not that important (we can control it with numbers)
+
+-- Italic correction in luatex math is (was) a mess. There are all kind of assumptions based on
+-- old fonts and new fonts. Eventually there should be a flag that can signal to ignore all
+-- those heuristics. We want to deal with it ourselves also in the perspective of mixed math
+-- and text. Also, for a while in context we had to deal with a mix of virtual math fonts and
+-- real ones.
+
+-- in opentype the italic correction of a limop is added to the width and luatex does
+-- some juggling that we want to avoid but we need to do something here (in fact, we could
+-- better fix the width of the character)
+
+do
+
+ local a_mathitalics = privateattribute("mathitalics")
+
+ local italics = { }
+ local default_factor = 1/20
+
+ local setcolor = colortracers.set
+ local resetcolor = colortracers.reset
+ local italic_kern = new_kern
+
+ local c_positive_d = "trace:dg"
+ local c_negative_d = "trace:dr"
+
+ local function insert_kern(current,kern)
+ local sub = new_submlist() -- todo: attr
+ local noad = new_noad() -- todo: attr
+ setlist(sub,kern)
+ setnext(kern,noad)
+ setnucleus(noad,current)
+ return sub
+ end
+
+ registertracker("math.italics.visualize", function(v)
+ if v then
+ italic_kern = function(k)
+ local n = new_kern(k) -- todo: attr
+ set_visual(n,"italic")
+ return n
+ end
+ else
+ italic_kern = new_kern
+ end
+ end)
+
+ local function getcorrection(method,font,char) -- -- or character.italic -- (this one is for tex)
+
+ local visual = chardata[char].visual
+
+ if method == 1 then
+ -- check on state
+ local italics = fontitalics[font]
+ if italics then
+ local character = fontcharacters[font][char]
+ if character then
+ local correction = character.italic
+ if correction and correction ~= 0 then
+ return correction, visual
+ end
+ end
+ end
+ elseif method == 2 then
+ -- no check
+ local character = fontcharacters[font][char]
+ if character then
+ local correction = character.italic
+ if correction and correction ~= 0 then
+ return correction, visual
+ end
+ end
+ elseif method == 3 then
+ -- check on visual
+ if visual == "it" or visual == "bi" then
+ local character = fontcharacters[font][char]
+ if character then
+ local correction = character.italic
+ if correction and correction ~= 0 then
+ return correction, visual
+ end
+ end
+ end
+ elseif method == 4 then
+ -- combination of 1 and 3
+ local italics = fontitalics[font]
+ if italics and (visual == "it" or visual == "bi") then
+ local character = fontcharacters[font][char]
+ if character then
+ local correction = character.italic
+ if correction and correction ~= 0 then
+ return correction, visual
+ end
+ end
+ end
+ end
+
+ end
+
+ italics[mathchar_code] = function(pointer,what,n,parent)
+ local method = getattr(pointer,a_mathitalics)
+ if method and method > 0 and method < 100 then
+ local char = getchar(pointer)
+ local font = getfont(pointer)
+ local correction, visual = getcorrection(method,font,char)
+ if correction and correction ~= 0 then
+ local next_noad = getnext(parent)
+ if not next_noad then
+ if n == 1 then
+ -- only at the outer level .. will become an option (always,endonly,none)
+ if trace_italics then
+ report_italics("method %a, flagging italic correction %p between %C and end math",method,correction,char)
+ end
+ if correction > 0 then
+ correction = correction + 100
+ else
+ correction = correction - 100
+ end
+ correction = round(correction)
+ setattr(pointer,a_mathitalics,correction)
+ setattr(parent,a_mathitalics,correction)
+ return -- so no reset later on
+ end
+ end
+ end
+ end
+ setattr(pointer,a_mathitalics,unsetvalue)
+ end
+
+ function handlers.italics(head,style,penalties)
+ processnoads(head,italics,"italics")
+ return true -- not needed
+ end
+
+ local enable = function()
+ enableaction("math", "noads.handlers.italics")
+ if trace_italics then
+ report_italics("enabling math italics")
+ end
+ -- we enable math (unless already enabled elsewhere)
+ typesetters.italics.enablemath()
+ enable = false
+ end
+
+ -- best do this only on math mode (less overhead)
+
+ function mathematics.setitalics(name)
+ if enable then
+ enable()
+ end
+ texsetattribute(a_mathitalics,name and name ~= v_reset and tonumber(name) or unsetvalue) -- maybe also v_none
+ end
+
+ function mathematics.getitalics(name)
+ if enable then
+ enable()
+ end
+ context(name and name ~= v_reset and tonumber(name) or unsetvalue)
+ end
+
+ function mathematics.resetitalics()
+ texsetattribute(a_mathitalics,unsetvalue)
+ end
+
+ implement {
+ name = "initializemathitalics",
+ actions = enable,
+ onlyonce = true,
+ }
+
+ implement {
+ name = "setmathitalics",
+ actions = mathematics.setitalics,
+ arguments = "string",
+ }
+
+ implement {
+ name = "getmathitalics",
+ actions = mathematics.getitalics,
+ arguments = "string",
+ }
+
+ implement {
+ name = "resetmathitalics",
+ actions = mathematics.resetitalics
+ }
+
+end
+
+do
+
+ -- math kerns (experiment) in goodies:
+ --
+ -- mathematics = {
+ -- kernpairs = {
+ -- [0x1D44E] = {
+ -- [0x1D44F] = 400, -- 𝑎𝑏
+ -- }
+ -- },
+ -- }
+
+ local a_kernpairs = privateattribute("mathkernpairs")
+ local kernpairs = { }
+
+ local function enable()
+ enableaction("math", "noads.handlers.kernpairs")
+ if trace_kernpairs then
+ report_kernpairs("enabling math kern pairs")
+ end
+ enable = false
+ end
+
+ implement {
+ name = "initializemathkernpairs",
+ actions = enable,
+ onlyonce = true,
+ }
+
+ local hash = setmetatableindex(function(t,font)
+ local g = fontdata[font].goodies
+ local m = g and g[1] and g[1].mathematics
+ local k = m and m.kernpairs
+ t[font] = k
+ return k
+ end)
+
+ -- no correction after prime because that moved to a superscript
+
+ kernpairs[mathchar_code] = function(pointer,what,n,parent)
+ if getattr(pointer,a_kernpairs) == 1 then
+ local font = getfont(pointer)
+ local list = hash[font]
+ if list then
+ local first = getchar(pointer)
+ local found = list[first]
+ if found then
+ local next = getnext(parent)
+ if next and getid(next) == noad_code then
+ pointer = getnucleus(next)
+ if pointer then
+ if getfont(pointer) == font then
+ local second = getchar(pointer)
+ local kern = found[second]
+ if kern then
+ kern = kern * fonts.hashes.parameters[font].hfactor
+ if trace_kernpairs then
+ report_kernpairs("adding %p kerning between %C and %C",kern,first,second)
+ end
+ setlink(parent,new_kern(kern),getnext(parent)) -- todo: attr
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ function handlers.kernpairs(head,style,penalties)
+ processnoads(head,kernpairs,"kernpairs")
+ return true -- not needed
+ end
+
+end
+
+-- primes and such
+
+do
+
+ -- is validpair stil needed?
+
+ local a_mathcollapsing = privateattribute("mathcollapsing")
+ local collapse = { }
+ local mathlists = characters.mathlists
+ local validpair = {
+ [ordnoad_code] = true,
+ [opdisplaylimitsnoad_code] = true,
+ [oplimitsnoad_code] = true,
+ [opnolimitsnoad_code] = true,
+ [binnoad_code] = true, -- new
+ [relnode_code] = true,
+ [opennoad_code] = true, -- new
+ [closenoad_code] = true, -- new
+ [punctnoad_code] = true, -- new
+ [innernoad_code] = false,
+ [undernoad_code] = false,
+ [overnoad_code] = false,
+ [vcenternoad_code] = false,
+ [ordlimitsnoad_code] = true,
+ }
+
+ local reported = setmetatableindex("table")
+
+ collapse[mathchar_code] = function(pointer,what,n,parent)
+
+ if parent and mathlists[getchar(pointer)] then
+ local found, last, lucleus, lsup, lsub, category
+ local tree = mathlists
+ local current = parent
+ while current and validpair[getsubtype(current)] do
+ local nucleus = getnucleus(current) -- == pointer
+ local sub = getsub(current)
+ local sup = getsup(current)
+ local char = getchar(nucleus)
+ if char then
+ local match = tree[char]
+ if match then
+ local method = getattr(current,a_mathcollapsing)
+ if method and method > 0 and method <= 3 then
+ local specials = match.specials
+ local mathlist = match.mathlist
+ local ligature
+ if method == 1 then
+ ligature = specials
+ elseif method == 2 then
+ ligature = specials or mathlist
+ else -- 3
+ ligature = mathlist or specials
+ end
+ if ligature then
+ category = mathlist and "mathlist" or "specials"
+ found = ligature
+ last = current
+ lucleus = nucleus
+ lsup = sup
+ lsub = sub
+ end
+ tree = match
+ if sub or sup then
+ break
+ else
+ current = getnext(current)
+ end
+ else
+ break
+ end
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+ if found and last and lucleus then
+ local id = getfont(lucleus)
+ local characters = fontcharacters[id]
+ local replace = characters and characters[found]
+ if not replace then
+ if not reported[id][found] then
+ reported[id][found] = true
+ report_collapsing("%s ligature %C from %s","ignoring",found,category)
+ end
+ elseif trace_collapsing then
+ report_collapsing("%s ligature %C from %s","creating",found,category)
+ end
+ setchar(pointer,found)
+ local l = getnext(last)
+ local c = getnext(parent)
+ if lsub then
+ setsub(parent,lsub)
+ setsub(last)
+ end
+ if lsup then
+ setsup(parent,lsup)
+ setsup(last)
+ end
+ while c ~= l do
+ local n = getnext(c)
+ flush_node(c)
+ c = n
+ end
+ setlink(parent,l)
+ end
+ end
+ end
+
+ function noads.handlers.collapse(head,style,penalties)
+ processnoads(head,collapse,"collapse")
+ return true -- not needed
+ end
+
+ local enable = function()
+ enableaction("math", "noads.handlers.collapse")
+ if trace_collapsing then
+ report_collapsing("enabling math collapsing")
+ end
+ enable = false
+ end
+
+ implement {
+ name = "initializemathcollapsing",
+ actions = enable,
+ onlyonce = true,
+ }
+
+end
+
+do
+ -- inner under over vcenter
+
+ local fixscripts = { }
+ local movesub = {
+ -- primes
+ [0x2032] = 0xFE932,
+ [0x2033] = 0xFE933,
+ [0x2034] = 0xFE934,
+ [0x2057] = 0xFE957,
+ -- reverse primes
+ [0x2035] = 0xFE935,
+ [0x2036] = 0xFE936,
+ [0x2037] = 0xFE937,
+ }
+
+ mathematics.virtualize(movesub)
+
+ local options_supported = tokens.defined("Unosuperscript")
+
+ local function fixsupscript(parent,current,current_char,new_char)
+ if new_char ~= current_char and new_char ~= true then
+ setchar(current,new_char)
+ if trace_fixing then
+ report_fixing("fixing subscript, replacing superscript %U by %U",current_char,new_char)
+ end
+ else
+ if trace_fixing then
+ report_fixing("fixing subscript, superscript %U",current_char)
+ end
+ end
+ if options_supported then
+ setfield(parent,"options",0x08+0x22)
+ end
+ end
+
+ -- local function movesubscript(parent,current_nucleus,oldchar,newchar)
+ -- local prev = getprev(parent)
+ -- if prev and getid(prev) == noad_code then
+ -- local psup = getsup(prev)
+ -- local psub = getsub(prev)
+ -- if not psup and not psub then
+ -- fixsupscript(prev,current_nucleus,oldchar,newchar)
+ -- local nucleus = getnucleus(parent)
+ -- local sub = getsub(parent)
+ -- setsup(prev,nucleus)
+ -- setsub(prev,sub)
+ -- local dummy = copy_node(nucleus)
+ -- setchar(dummy,0)
+ -- setnucleus(parent,dummy)
+ -- setsub(parent)
+ -- elseif not psup then
+ -- fixsupscript(prev,current_nucleus,oldchar,newchar)
+ -- local nucleus = getnucleus(parent)
+ -- setsup(prev,nucleus)
+ -- local dummy = copy_node(nucleus)
+ -- setchar(dummy,0)
+ -- setnucleus(parent,dummy)
+ -- end
+ -- end
+ -- end
+
+ local function move_none_none(parent,prev,nuc,oldchar,newchar)
+ fixsupscript(prev,nuc,oldchar,newchar)
+ local sub = getsub(parent)
+ setsup(prev,nuc)
+ setsub(prev,sub)
+ local dummy = copy_node(nuc)
+ setchar(dummy,0)
+ setnucleus(parent,dummy)
+ setsub(parent)
+ end
+
+ local function move_none_psub(parent,prev,nuc,oldchar,newchar)
+ fixsupscript(prev,nuc,oldchar,newchar)
+ setsup(prev,nuc)
+ local dummy = copy_node(nuc)
+ setchar(dummy,0)
+ setnucleus(parent,dummy)
+ end
+
+ fixscripts[mathchar_code] = function(pointer,what,n,parent,nested) -- todo: switch to turn in on and off
+ if parent then
+ local oldchar = getchar(pointer)
+ local newchar = movesub[oldchar]
+ if newchar then
+ local nuc = getnucleus(parent)
+ if pointer == nuc then
+ local sub = getsub(pointer)
+ local sup = getsup(pointer)
+ if sub then
+ if sup then
+ -- print("[char] sub sup")
+ else
+ -- print("[char] sub ---")
+ end
+ elseif sup then
+ -- print("[char] --- sup")
+ else
+ local prev = getprev(parent)
+ if prev and getid(prev) == noad_code then
+ local psub = getsub(prev)
+ local psup = getsup(prev)
+ if psub then
+ if psup then
+ -- print("sub sup [char] --- ---")
+ else
+ -- print("sub --- [char] --- ---")
+ move_none_psub(parent,prev,nuc,oldchar,newchar)
+ end
+ elseif psup then
+ -- print("--- sup [char] --- ---")
+ else
+ -- print("[char] --- ---")
+ move_none_none(parent,prev,nuc,oldchar,newchar)
+ end
+ else
+ -- print("no prev [char]")
+ end
+ end
+ else
+ -- print("[char]")
+ end
+ end
+ end
+ end
+
+ function noads.handlers.fixscripts(head,style,penalties)
+ processnoads(head,fixscripts,"fixscripts")
+ return true -- not needed
+ end
+
+end
+
+-- variants
+
+do
+
+ local variants = { }
+ local validvariants = { -- fast check on valid
+ [0x2229] = 0xFE00, [0x222A] = 0xFE00,
+ [0x2268] = 0xFE00, [0x2269] = 0xFE00,
+ [0x2272] = 0xFE00, [0x2273] = 0xFE00,
+ [0x228A] = 0xFE00, [0x228B] = 0xFE00,
+ [0x2293] = 0xFE00, [0x2294] = 0xFE00,
+ [0x2295] = 0xFE00,
+ [0x2297] = 0xFE00,
+ [0x229C] = 0xFE00,
+ [0x22DA] = 0xFE00, [0x22DB] = 0xFE00,
+ [0x2A3C] = 0xFE00, [0x2A3D] = 0xFE00,
+ [0x2A9D] = 0xFE00, [0x2A9E] = 0xFE00,
+ [0x2AAC] = 0xFE00, [0x2AAD] = 0xFE00,
+ [0x2ACB] = 0xFE00, [0x2ACC] = 0xFE00,
+ }
+
+ variants[mathchar_code] = function(pointer,what,n,parent) -- also set export value
+ local char = getchar(pointer)
+ local selector = validvariants[char]
+ if selector then
+ local next = getnext(parent)
+ if next and getid(next) == noad_code then
+ local nucleus = getnucleus(next)
+ if nucleus and getid(nucleus) == mathchar_code and getchar(nucleus) == selector then
+ local variant
+ local tfmdata = fontdata[getfont(pointer)]
+ local mathvariants = tfmdata.resources.variants -- and variantdata
+ if mathvariants then
+ mathvariants = mathvariants[selector]
+ if mathvariants then
+ variant = mathvariants[char]
+ end
+ end
+ if variant then
+ setchar(pointer,variant)
+ setattr(pointer,a_exportstatus,char) -- we don't export the variant as it's visual markup
+ if trace_variants then
+ report_variants("variant (%U,%U) replaced by %U",char,selector,variant)
+ end
+ else
+ if trace_variants then
+ report_variants("no variant (%U,%U)",char,selector)
+ end
+ end
+ setprev(next,pointer)
+ setnext(parent,getnext(next))
+ flush_node(next)
+ end
+ end
+ end
+ end
+
+ function handlers.variants(head,style,penalties)
+ processnoads(head,variants,"unicode variant")
+ return true -- not needed
+ end
+
+end
+
+-- for manuals
+
+do
+
+ local classes = { }
+ local colors = {
+ [relnode_code] = "trace:dr",
+ [ordnoad_code] = "trace:db",
+ [binnoad_code] = "trace:dg",
+ [opennoad_code] = "trace:dm",
+ [closenoad_code] = "trace:dm",
+ [punctnoad_code] = "trace:dc",
+ -- [opdisplaylimitsnoad_code] = "",
+ -- [oplimitsnoad_code] = "",
+ -- [opnolimitsnoad_code] = "",
+ -- [ordlimitsnoad_code] = "",
+ -- [innernoad_code = "",
+ -- [undernoad_code] = "",
+ -- [overnoad_code] = "",
+ -- [vcenternoad_code] = "",
+ }
+
+ local setcolor = colortracers.set
+ local resetcolor = colortracers.reset
+
+ classes[mathchar_code] = function(pointer,what,n,parent)
+ local color = colors[getsubtype(parent)]
+ if color then
+ setcolor(pointer,color)
+ else
+ resetcolor(pointer)
+ end
+ end
+
+ function handlers.classes(head,style,penalties)
+ processnoads(head,classes,"classes")
+ return true -- not needed
+ end
+
+ registertracker("math.classes",function(v)
+ setaction("math","noads.handlers.classes",v)
+ end)
+
+end
+
+-- experimental
+
+do
+
+ -- mathematics.registerdomain {
+ -- name = "foo",
+ -- parents = { "bar" },
+ -- characters = {
+ -- [0x123] = { char = 0x234, class = binary },
+ -- },
+ -- }
+
+ local domains = { }
+ local categories = { }
+ local numbers = { }
+ local a_mathdomain = privateattribute("mathdomain")
+ mathematics.domains = categories
+ local permitted = {
+ ordinary = ordnoad_code,
+ binary = binnoad_code,
+ relation = relnode_code,
+ punctuation = punctnoad_code,
+ inner = innernoad_code,
+ }
+
+ function mathematics.registerdomain(data)
+ local name = data.name
+ if not name then
+ return
+ end
+ local attr = #numbers + 1
+ categories[name] = data
+ numbers[attr] = data
+ data.attribute = attr
+ -- we delay hashing
+ return attr
+ end
+
+ local enable
+
+ enable = function()
+ enableaction("math", "noads.handlers.domains")
+ if trace_domains then
+ report_domains("enabling math domains")
+ end
+ enable = false
+ end
+
+ function mathematics.setdomain(name)
+ if enable then
+ enable()
+ end
+ local data = name and name ~= v_reset and categories[name]
+ texsetattribute(a_mathdomain,data and data.attribute or unsetvalue)
+ end
+
+ function mathematics.getdomain(name)
+ if enable then
+ enable()
+ end
+ local data = name and name ~= v_reset and categories[name]
+ context(data and data.attribute or unsetvalue)
+ end
+
+ implement {
+ name = "initializemathdomain",
+ actions = enable,
+ onlyonce = true,
+ }
+
+ implement {
+ name = "setmathdomain",
+ arguments = "string",
+ actions = mathematics.setdomain,
+ }
+
+ implement {
+ name = "getmathdomain",
+ arguments = "string",
+ actions = mathematics.getdomain,
+ }
+
+ local function makehash(data)
+ local hash = { }
+ local parents = data.parents
+ if parents then
+ local function merge(name)
+ if name then
+ local c = categories[name]
+ if c then
+ local hash = c.hash
+ if not hash then
+ hash = makehash(c)
+ end
+ for k, v in next, hash do
+ hash[k] = v
+ end
+ end
+ end
+ end
+ if type(parents) == "string" then
+ merge(parents)
+ elseif type(parents) == "table" then
+ for i=1,#parents do
+ merge(parents[i])
+ end
+ end
+ end
+ local characters = data.characters
+ if characters then
+ for k, v in next, characters do
+ -- local chr = n.char
+ local cls = v.class
+ if cls then
+ v.code = permitted[cls]
+ else
+ -- invalid class
+ end
+ hash[k] = v
+ end
+ end
+ data.hash = hash
+ return hash
+ end
+
+ domains[mathchar_code] = function(pointer,what,n,parent)
+ local attr = getattr(pointer,a_mathdomain)
+ if attr then
+ local domain = numbers[attr]
+ if domain then
+ local hash = domain.hash
+ if not hash then
+ hash = makehash(domain)
+ end
+ local char = getchar(pointer)
+ local okay = hash[char]
+ if okay then
+ local chr = okay.char
+ local cls = okay.code
+ if chr and chr ~= char then
+ setchar(pointer,chr)
+ end
+ if cls and cls ~= getsubtype(parent) then
+ setsubtype(parent,cls)
+ end
+ end
+ end
+ end
+ end
+
+ function handlers.domains(head,style,penalties)
+ processnoads(head,domains,"domains")
+ return true -- not needed
+ end
+
+end
+
+-- just for me
+
+function handlers.showtree(head,style,penalties)
+ inspect(nodes.totree(tonut(head)))
+end
+
+registertracker("math.showtree",function(v)
+ setaction("math","noads.handlers.showtree",v)
+end)
+
+-- also for me
+
+do
+
+ local applyvisuals = nuts.applyvisuals
+ local visual = false
+
+ function handlers.makeup(head)
+ applyvisuals(head,visual)
+ end
+
+ registertracker("math.makeup",function(v)
+ visual = v
+ setaction("math","noads.handlers.makeup",v)
+ end)
+
+end
+
+-- the normal builder
+
+do
+
+ local force_penalties = false
+
+ -- registertracker("math.penalties",function(v)
+ -- force_penalties = v
+ -- end)
+
+ function builders.kernel.mlist_to_hlist(head,style,penalties)
+ return mlist_to_hlist(head,style,force_penalties or penalties)
+ end
+
+ -- function builders.kernel.mlist_to_hlist(head,style,penalties)
+ -- local h = mlist_to_hlist(head,style,force_penalties or penalties)
+ -- inspect(nodes.totree(h,true,true,true))
+ -- return h
+ -- end
+
+ implement {
+ name = "setmathpenalties",
+ arguments = "integer",
+ actions = function(p)
+ force_penalties = p > 0
+ end,
+ }
+
+end
+
+local actions = tasks.actions("math") -- head, style, penalties
+
+local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
+
+function processors.mlist_to_hlist(head,style,penalties)
+ starttiming(noads)
+ head = actions(head,style,penalties)
+ stoptiming(noads)
+ return head
+end
+
+callbacks.register('mlist_to_hlist',processors.mlist_to_hlist,"preprocessing math list")
+
+-- tracing
+
+statistics.register("math processing time", function()
+ return statistics.elapsedseconds(noads)
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-pln.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-pln.mkxl
new file mode 100644
index 00000000000..81008f37b22
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-pln.mkxl
@@ -0,0 +1,237 @@
+%D \module
+%D [ file=math-pln,
+%D version=2001.11.16,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Plain Helpers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Here we collect some Plain \TEX\ leftovers.
+
+\writestatus{loading}{ConTeXt Math Macros / Plain Helpers}
+
+\unprotect
+
+% we need proper unicode:
+
+\def\relbar{\mathrel{\smash-}} % - has the same height as + .. no clue what this refers to
+
+% might change
+
+\permanent\protected\def\hrulefill{\leaders\hrule\hfill}
+%protected\def\dotfill {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill}
+
+% will move
+
+\permanent\def\oalign#1%
+ {\leavevmode % plain tex uses this
+ \vtop
+ {\baselineskip\zeroskip
+ \lineskip.25\exheight
+ \ialign{\alignmark\alignmark\crcr#1\crcr}}}
+
+\permanent\def\ooalign % chars over each other
+ {\lineskiplimit-\maxdimen
+ \oalign}
+
+% needs checking
+
+\permanent\protected\def\choose{\atopwithdelims()}
+\permanent\protected\def\brack {\atopwithdelims[]}
+\permanent\protected\def\brace {\atopwithdelims\{\}}
+
+% needs checking
+
+\permanent\protected\def\buildrel#1\over#2%
+ {\mathrel{\mathop{\kern\zeropoint#2}\limits^{#1}}}
+
+\permanent\protected\def\bmod
+ {\nonscript
+ \mskip-\medmuskip
+ \mkern5mu
+ \mfunction{mod}%
+ \penalty900
+ \mkern5mu
+ \nonscript
+ \mskip-\medmuskip}
+
+\permanent\protected\def\pmod#1%
+ {\allowbreak
+ \mkern18mu
+ (\mfunction{mod}\mskip\medmuskip#1)}
+
+\permanent\protected\def\cases#1%
+ {\left\{%
+ \mskip\thinmuskip
+ \vcenter
+ {\normalbaselines
+ \mathsurround\zeropoint
+ \ialign{%
+ \normalstartimath\alignmark\alignmark\hfil\normalstopimath
+ \aligntab
+ \quad\alignmark\alignmark\hfil
+ \crcr
+ #1%
+ \crcr}}%
+ \right.}
+
+\permanent\protected\def\matrix#1%
+ {\emptyhbox
+ \mskip\thinmuskip
+ \vcenter
+ {\normalbaselines
+ \mathsurround\zeropoint
+ \ialign{%
+ \hfil\normalstartimath\alignmark\alignmark\normalstopimath\hfil
+ \aligntab
+ \aligntab
+ \quad\hfil\normalstartimath\alignmark\alignmark\normalstopimath\hfil
+ \crcr
+ \mathstrut
+ \crcr
+ \noalign{\kern-\baselineskip}
+ #1\crcr
+ \mathstrut
+ \crcr
+ \noalign{\kern-\baselineskip}}}%
+ \mskip\thinmuskip}
+
+\permanent\protected\def\pmatrix#1%
+ {\left(\matrix{#1}\right)}
+
+\permanent\protected\def\math_openup
+ {\afterassignment\math_openup_indeed\scratchdimen}
+
+\aliased\let\math_closeup\relax
+
+\def\math_openup_indeed
+ {\enforced\permanent\protected\edef\math_closeup
+ {\lineskip \the\lineskip
+ \baselineskip \the\baselineskip
+ \lineskiplimit\the\lineskiplimit
+ \relax}%
+ \advance \lineskip \scratchdimen
+ \advance \baselineskip \scratchdimen
+ \advance \lineskiplimit \scratchdimen}
+
+\permanent\protected\def\openup {\math_openup } % the low level ones are used elsewhere
+\permanent\protected\def\closeup{\math_closeup} % the low level ones are used elsewhere
+
+\permanent\protected\def\displaylines#1%
+ {\the\mathdisplayaligntweaks
+ \tabskip\zeroskip
+ \halign
+ {\hbox to \displaywidth{%
+ \normalstartimath\tabskip\zeroskip\everycr\emptytoks\hfil\displaystyle\alignmark\alignmark\hfil\normalstopimath}\crcr
+ #1\crcr}}
+
+%D This comes from plain but I gave it a \CONTEXT\ touch:
+
+\permanent\def\math_border_NC_indeed
+ {\enforced\global\def\math_border_NC{\aligntab}}
+
+\aliased\let\math_border_NC\math_border_NC_indeed
+
+\permanent\def\math_border_NR
+ {\enforced\global\let\math_border_NC\math_border_NC_indeed
+ \cr}
+
+\protected\def\math_border_matrix#1#2#3% adapted plain
+ {\begingroup
+ %
+ \setbox\scratchbox\hbox\bgroup
+ \mr B%
+ \egroup
+ \scratchdimenone\wd\scratchbox
+ %
+ \scratchdimentwo.2\bodyfontsize
+ %
+ \mathsurround\zeropoint
+ %
+ \enforced\def\NC{\math_border_NC}%
+ \enforced\def\NR{\math_border_NR}%
+ %
+ \gdef\m_math_border_matrix
+ {\kern\scratchdimentwo
+ \glet\m_math_border_matrix\relax}%
+ %
+ \setbox\scratchboxone\vbox\bgroup
+ \everycr{\noalign\bgroup\m_math_border_matrix\egroup}%
+ \tabskip \zeroskip
+ \halign{% \ialign resets everycr
+ \startimath\alignmark\alignmark\stopimath
+ \hfil
+ \kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
+ \aligntab
+ \thinspace
+ \hfil
+ \startimath\alignmark\alignmark\stopimath
+ \hfil
+ \aligntab
+ \aligntab
+ \quad
+ \hfil
+ \startimath\alignmark\alignmark\stopimath
+ \hfil
+ \crcr
+ \omit
+ \strut
+ \hfil
+ \crcr
+ \noalign{\kern-\baselineskip}%
+ #3\crcr
+ \omit
+ \strut
+ \cr}%
+ \egroup
+ \setbox\scratchboxtwo\vbox\bgroup
+ \unvcopy\scratchboxone
+ \global\setbox\globalscratchbox\lastbox
+ \egroup
+ \setbox\scratchboxtwo\hbox\bgroup
+ \unhbox\globalscratchbox
+ \unskip
+ \global\setbox\globalscratchbox\lastbox
+ \egroup
+ \setbox\scratchboxtwo\hbox\bgroup
+ \startimath
+ \kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
+ \left#1\relax
+ \kern-\wd\globalscratchbox
+ \global\setbox\globalscratchbox\vbox\bgroup
+ \box\globalscratchbox
+ \kern\scratchdimentwo
+ \egroup
+ \vcenter\bgroup
+ \kern-\ht\globalscratchbox
+ \unvbox\scratchboxone
+ \kern-\baselineskip
+ \egroup
+ \thinspace
+ \right#2\relax
+ \stopimath
+ \egroup
+ \null
+ \thickspace
+ \vbox\bgroup
+ \kern\ht\globalscratchbox
+ \box\scratchboxtwo
+ \egroup
+ %
+ \endgroup}
+
+\permanent\protected\def\bordermatrix {\math_border_matrix()}
+\permanent\protected\def\bbordermatrix{\math_border_matrix[]}
+
+\permanent\protected\def\startbordermatrix #1\stopbordermatrix {\math_border_matrix(){#1}}
+\permanent\protected\def\startbbordermatrix#1\stopbbordermatrix{\math_border_matrix[]{#1}}
+
+\permanent\let\stopbordermatrix \relax
+\permanent\let\stopbbordermatrix\relax
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-rad.mklx b/Master/texmf-dist/tex/context/base/mkxl/math-rad.mklx
new file mode 100644
index 00000000000..8906efdc85a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-rad.mklx
@@ -0,0 +1,271 @@
+%D \module
+%D [ file=math-rad,
+%D version=2013.07.13,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Radicals,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Radicals}
+
+\unprotect
+
+%D \starttyping
+%D $\sqrt[3]{10}$
+%D \stoptyping
+%D
+%D This root command will be overloaded later:
+
+%D Old stuff:
+
+% \def\rootradical{\Uroot \defaultmathfamily "221A } % can be done in char-def
+% \def\surdradical{\Uradical \defaultmathfamily "221A } % can be done in char-def
+
+\permanent\protected\def\root#1\of{\rootradical{#1}} % #2
+
+\protected\def\sqrt{\doifelsenextoptionalcs\rootwithdegree\rootwithoutdegree} % will be redefined
+
+\permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird
+ {\normalexpanded{\rootradical
+ {\normalunexpanded{#1}}%
+ {\noexpand\triggermathstyle{\number\normalmathstyle}%
+ \normalunexpanded{#2}}}}
+
+% experimental new keyword: (maybe keywords should come after the symbol)
+%
+% \permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird
+% {\Uroot style \normalmathstyle "0 "221A {#1}{#2}}
+
+\permanent\protected\def\rootwithdegree[#1]{\rootradical{#1}}
+\permanent\protected\def\rootwithoutdegree {\rootradical {}}
+
+%D Even older stuff:
+
+% % is now a ordinary character
+%
+% \let\normalsurd\surd % \Uradical "0 "221A
+% \permanent\protected\def\surd{\normalsurd{}}
+
+%D The real thing. If needed one can control matters with one of the many
+%D \type {\Umath...} parameters.
+%D
+%D \starttyping
+%D \def\R {\Umathradicaldegreeafter\textstyle0pt}
+%D \def\RR{\Umathradicaldegreeafter\textstyle\dimexpr
+%D \Umathradicaldegreeafter\textstyle+.1em\relax}
+%D \def\RRR{\frozen\Umathradicaldegreeafter\textstyle\dimexpr
+%D \Umathradicaldegreeafter\textstyle+.2em\relax}
+%D
+%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par
+%D $ \sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D $ \RR\sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D
+%D \def\R {\Umathradicaldegreeafter\textstyle
+%D 0pt}
+%D \def\RR {\Umathradicaldegreeafter\textstyle
+%D 0.95\Umathradicaldegreeafter\textstyle}
+%D \def\RRR{\frozen\Umathradicaldegreeafter\textstyle
+%D 0.9\Umathradicaldegreeafter\textstyle}
+%D
+%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par
+%D $ \sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D $ \RR\sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D
+%D \def\RR {\mathopenupparameter\Umathradicaldegreeafter{.1}}
+%D
+%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par
+%D $ \sqrt[3]{5} {\RR\sqrt[3]{5}} \sqrt[3]{5} $\par
+%D \stoptyping
+
+\installcorenamespace{mathradical}
+\installcorenamespace{mathradicalalternative}
+
+\installcommandhandler \??mathradical {mathradical} \??mathradical
+
+\setupmathradical
+ [\c!alternative=\v!normal,
+ \c!mpoffset=.25\exheight]
+
+\appendtoks
+ \frozen\protected\instance\edefcsname\currentmathradical\endcsname{\math_radical_handle{\currentmathradical}}
+\to \everydefinemathradical
+
+\mutable\let\currentmathradical \empty
+\mutable\let\currentmathradicaldegree\empty
+
+\tolerant\protected\def\math_radical_handle#tag#*[#degree]#:#body%
+ {\begingroup
+ \edef\currentmathradical{#tag}%
+ \edef\currentmathradicaldegree{#degree}%
+ \ifempty\currentmathradicaldegree
+ \let\currentmathradicaldegree\m_math_no_degree
+ \fi
+ \math_radical_alternative{#body}%
+ \endgroup}
+
+\def\m_math_no_degree{{}}
+
+\def\math_radical_alternative{\csname\??mathradicalalternative\mathradicalparameter\c!alternative\endcsname}
+
+\setvalue{\??mathradicalalternative\v!default}% #body%
+ {\rootradical{\currentmathradicaldegree}} % {#body}}
+
+\setvalue{\??mathradicalalternative\v!normal}#body%
+ {\edef\p_color{\mathradicalparameter\c!color}%
+ \ifempty\p_color
+ \styledrootradical{\currentmathradicaldegree}{#body}% {} really needed as \rootradical expands first
+ \orelse\ifempty\currentmathradicaldegree
+ \pushcolor[\p_color]%
+ \styledrootradical{\currentmathradicaldegree}%
+ {\popcolor#body}%
+ \else
+ \pushcolor[\p_color]%
+ \styledrootradical{\popcolor\currentmathradicaldegree\pushcolor[\p_color]}%
+ {\popcolor#body}%
+ \fi}
+
+\startMPextensions
+ vardef math_radical_simple(expr w,h,d,o) =
+ (-h/2-o,h/2-o) --
+ (-h/4-o,-d-o) --
+ (-o,h+o) --
+ (w+o,h+o) --
+ (w+o,h-h/10+o)
+ enddef ;
+\stopMPextensions
+
+\startuniqueMPgraphic{minifun::math:radical:default}%{...}
+ draw
+ math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset)
+ % withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30
+ withpen pencircle scaled OverlayLineWidth
+ % dashed evenly
+ withcolor OverlayLineColor ;
+\stopuniqueMPgraphic
+
+% todo: spacing .. this is just an experiment (article driven)
+
+\setvalue{\??mathradicalalternative\v!mp}#body% we could use dowithnextbox
+ {\begingroup
+ \scratchoffset\mathradicalparameter\c!mpoffset
+ \setbox\nextbox\mathstylehbox{#body}%
+ % we use the \overlay variables as these are passes anyway and
+ % it's more efficient than using parameters
+ \d_overlay_width \wd\nextbox
+ \d_overlay_height \ht\nextbox
+ \d_overlay_depth \dp\nextbox
+ \d_overlay_offset \scratchoffset
+ \d_overlay_linewidth\the\dimexpr\triggeredmathstyleparameter\Umathfractionrule
+ %
+ \edef\overlaylinecolor{\mathradicalparameter\c!color}%
+ %
+ \edef\p_mp{\mathradicalparameter\c!mp}%
+ %
+ \setbox\scratchbox\hpack\bgroup % todo: tag this box as sqrt
+ \uniqueMPgraphic
+ {\p_mp}%
+ %{...}%
+ \egroup
+ \scratchdimen \wd\scratchbox
+ \scratchtopoffset \dimexpr\scratchoffset+\dp\nextbox\relax
+ \scratchbottomoffset\dimexpr\scratchoffset+\ht\nextbox/2\relax
+ \hpack to \scratchdimen{\hss\box\nextbox\hskip\scratchoffset}%
+ \hskip-\scratchdimen
+ \lower\dimexpr\scratchtopoffset\box\scratchbox%
+ \ifx\currentmathradicaldegree\empty \else
+ \setbox\scratchbox\mathstylehbox{\scriptscriptstyle\currentmathradicaldegree\hss}%
+ \wd\scratchbox\scratchdimen
+ \hskip-\scratchdimen
+ \raise\dimexpr\scratchbottomoffset\box\scratchbox
+ \fi
+ \endgroup}
+
+\definemathradical[sqrt][mp=minifun::math:radical:default]
+
+% \setupmathradical[sqrt][alternative=normal,color=darkblue]
+% \setupmathradical[sqrt][alternative=mp,color=darkgreen]
+
+%D Because I wanted to illustrate some more fun stuff another mechanism
+%D is provided as well ... let's put some dangerous tools in the hand of
+%D math jugglers like Aditya.
+
+\installcorenamespace{mathornament}
+\installcorenamespace{mathornamentalternative}
+
+\installcommandhandler \??mathornament {mathornament} \??mathornament
+
+\setupmathornament
+ [\c!alternative=\v!mp, % currently mp only .. maybe some day layer too
+ \c!mpoffset=.25\exheight]
+
+\appendtoks
+ \frozen\instance\setuevalue{\currentmathornament}{\math_ornament_handle{\currentmathornament}}%
+\to \everydefinemathornament
+
+\protected\def\math_ornament_handle#tag#body%
+ {\begingroup
+ \edef\currentmathornament{#tag}%
+ \csname\??mathornamentalternative\mathornamentparameter\c!alternative\endcsname{#body}%
+ \endgroup}
+
+\setvalue{\??mathornamentalternative\v!mp}#body% we could use dowithnextbox
+ {\begingroup
+ \scratchoffset\mathornamentparameter\c!mpoffset
+ \setbox\nextbox\mathstylehbox{#body}%
+ \d_overlay_width \wd\nextbox
+ \d_overlay_height \ht\nextbox
+ \d_overlay_depth \dp\nextbox
+ \d_overlay_offset \scratchoffset
+ \d_overlay_linewidth\linewidth
+ \edef\overlaylinecolor{\mathornamentparameter\c!color}%
+ \edef\p_mp{\mathornamentparameter\c!mp}%
+ % the width of the graphic determines the width of the final result
+ \setbox\scratchbox\hpack{\uniqueMPgraphic{\p_mp}}% todo: add code key + tag
+ \hpack to \wd\scratchbox{\hss\box\nextbox\hss}%
+ \hskip-\wd\scratchbox
+ \box\scratchbox
+ \endgroup}
+
+% \startMPextensions
+% vardef math_ornament_hat(expr w,h,d,o,l) =
+% image ( path p ; p :=
+% (w/2,h + 10l) --
+% (o + w,h + o) --
+% (w/2,h + 7l) --
+% (-o,h + o) --
+% cycle ;
+% fill p ;
+% setbounds currentpicture to (-o,0) -- (w+o,0) -- (w+o,h+2o) -- (-o,h+2o) -- cycle ;
+% )
+% enddef ;
+% \stopMPextensions
+%
+% \startuniqueMPgraphic{math:ornament:hat}
+% draw
+% math_ornament_hat(
+% OverlayWidth,
+% OverlayHeight,
+% OverlayDepth,
+% OverlayOffset,
+% OverlayLineWidth
+% )
+% withpen
+% pencircle
+% xscaled (2OverlayLineWidth)
+% yscaled (3OverlayLineWidth/4)
+% rotated 30
+% withcolor
+% OverlayLineColor ;
+% draw boundingbox currentpicture;
+% \stopuniqueMPgraphic
+%
+% \definemathornament [mathhat] [mp=math:ornament:hat]
+%
+% \dorecurse{8}{$\mathhat{\blackrule[width=#1ex,color=gray]}$ }
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-scr.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-scr.mkxl
new file mode 100644
index 00000000000..555f549f133
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-scr.mkxl
@@ -0,0 +1,58 @@
+%D \module
+%D [ file=math-scr,
+%D version=2007.07.19,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Scripts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Scripts}
+
+\unprotect
+
+%D These macros were first needed by Frits (Gajes) Spijkers (of the Math4All project
+%D that we participate in), and used for typesetting the minus sign that is keyed
+%D into scientific calculators. We use the monospaced signs, that we also define as
+%D symbol, so that they can be overloaded. We can probably do it nicer now (in lmtx).
+
+\def\math_scripts_raised_symbol#1%
+ {\mathchoice
+ {\math_scripts_raised_symbol_indeed5\tf {#1}}%
+ {\math_scripts_raised_symbol_indeed5\tf {#1}}%
+ {\math_scripts_raised_symbol_indeed4\tx {#1}}%
+ {\math_scripts_raised_symbol_indeed3\txx{#1}}}
+
+\def\math_scripts_raised_symbol_indeed#1#2#3%
+ {\mathord{{#2\raise.#1ex\hbox{#2\symbol[#3]}}}}
+
+\def\math_scripts_raised_number#1%
+ {\mathchoice
+ {\math_scripts_raised_number_indeed\tf {#1}}%
+ {\math_scripts_raised_number_indeed\tf {#1}}%
+ {\math_scripts_raised_number_indeed\tx {#1}}%
+ {\math_scripts_raised_number_indeed\txx{#1}}}
+
+\def\math_scripts_raised_number_indeed#1#2%
+ {\setbox\scratchbox\hbox{0}%
+ \mathord{\hbox to \wd\scratchbox{\hss#1\symbol[#2]\hss}}}
+
+\definesymbol[positive] [\getglyph{Mono}{+}]
+\definesymbol[negative] [\getglyph{Mono}{-}]
+\definesymbol[zeroamount][\getglyph{Mono}{-}]
+
+\permanent\protected\def\negative {\math_scripts_raised_symbol{negative}}
+\permanent\protected\def\positive {\math_scripts_raised_symbol{positive}}
+\permanent\protected\def\zeroamount{\math_scripts_raised_number{zeroamount}}
+
+%D How negative such a symbol looks is demonstrated in: $\negative 10^{\negative
+%D 10^{\negative 10}}$.
+
+% \setuptextformulas % why here
+% [\c!size=\v!normal]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-stc.mklx b/Master/texmf-dist/tex/context/base/mkxl/math-stc.mklx
new file mode 100644
index 00000000000..944185c23c4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-stc.mklx
@@ -0,0 +1,1379 @@
+%D \module
+%D [ file=math-stc,
+%D version=2012.12.29,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Stackers,
+%D comment=This replaces math-arr and friends,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Stackers}
+
+\unprotect
+
+%D WARNING: If the code here changes, the export needs to be checked! Stackers are
+%D rather special because the order in mathml matters, so we flush in [base under
+%D over] order. We also do some analysis at the \TEX\ end (passing the right
+%D variant). It's easy in the export to deal with it but in the pdf stream less
+%D trivial as we don't actually analyze there.
+%D
+%D At some point the \MKII\ arrow mechanism has been converted to \MKIV, but we kept
+%D most of the logic. We now have a more generic variant dealing with extensibles.
+%D There are a few demands than we need to meet:
+%D
+%D \startitemize
+%D \startitem
+%D The width of the extensible need to adapt itself automatically.
+%D \stopitem
+%D \startitem
+%D We need to be able to control horizontal and vertical offsets.
+%D \stopitem
+%D \startitem
+%D We best have a math as well as a text variant (which is handy for chemistry).
+%D \stopitem
+%D \startitem
+%D For historic reasons we need to deal with optional arguments in a special
+%D (reverse) way.
+%D \stopitem
+%D \startitem
+%D We need alternatives for extensibles on top, in the middle and at the bottom.
+%D \stopitem
+%D \stopitemize
+%D
+%D After I had experimented a bit with virtual characters for two headed arrows I
+%D discussed the issue with the Gyre folks and we came to the conclusion that it
+%D made sense to have real extensibles instead of constructing them out of snippets.
+%D After all, \OPENTYPE\ math provides for it. So, in December 2013 beta versions of
+%D Latin Modern and Gyre fonts came available that had these! Because we still want
+%D to support the traditional Latin Modern Virtual math font those were extended
+%D with a couple of virtual extensibles as well.
+%D
+%D {\em For the moment we still have some mess here: we can deal with known
+%D dimensions, but fillers (like \type {\rightarrowfil} don't work with \OPENTYPE\
+%D extensibles yet because there is no way to let them stretch like leaders. At some
+%D point \LUATEX\ might provide a auto||fit||to||encapsulated||box and if not I will
+%D cook up a \LUA\ based variant.}
+%D
+%D We could mess with something like \type {$mid\limits^{top}_{bottom}$} but we like
+%D a bit more control. At some point we need to add some hacks to get exports
+%D working well.
+%D
+%D In the end we have a more flexible mechanism which also handles text variants.
+
+%D When wrapping up some math developments I decided to add mp support here as well.
+%D A nice evening job with Joe Bonamassa performing live on the big screen (real
+%D nice bluray's). See meta-imp-mat.mkiv for examples.
+
+% possible improvements:
+%
+% - we could skip the left/right offsets when offset=normal, this saves some access time
+% at the lua end and some checking: use \mathhorizontalcode or \mathextensiblecode
+% but in practice arrows etc are not used that often
+
+\installcorenamespace {mathextensiblefallbacks}
+
+% currently no italic correction ... problem is that we don't know yet if we have an italic
+% below so we we need to postpone
+
+% \def\math_stackers_fallback
+% {\hbox to \scratchwidth{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname}}
+% %{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname }
+
+\def\math_stackers_fallback
+ {\mathstylehbox to \scratchwidth{\usemathstackerscolorparameter\c!color
+ \hss
+ \hskip\mathstackersparameter\c!topoffset\relax % for manual italic correction
+ \ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname
+ \lastnamedcs
+ \else
+ \Umathchar \fam \zerocount \scratchunicode
+ \fi
+ \hss}}
+
+\def\math_stackers_regular
+ {\mathstylehbox{\usemathstackerscolorparameter\c!color
+ \hskip\d_math_stackers_offset_l
+ \Umathaccent\fam\zerocount\scratchunicode
+ {\hskip\dimexpr\scratchwidth-\d_math_stackers_offset_l-\d_math_stackers_offset_r}%
+ \hskip\d_math_stackers_offset_r
+ }}
+
+\def\math_stackers_stretch % we don't have that one yet
+ {\mathstylehbox{\usemathstackerscolorparameter\c!color
+ \hskip\d_math_stackers_offset_l
+ \Umathaccent\fam\zerocount\scratchunicode
+ {\hskip\dimexpr\hsize-\d_math_stackers_offset_l-\d_math_stackers_offset_r}%
+ \hskip\d_math_stackers_offset_r
+ }}
+
+% these delimiters are a unuseable as they don't center for small arguments:
+%
+% $\Umathaccent 0 0 "2190{x}$ \par $\Umathaccent 0 0 "27F8{x}$\par
+% $\Udelimiterunder 0 "2190{x}$ \par $\Udelimiterunder 0 "27F8{x}$\par
+
+\setvalue{\??mathextensiblefallbacks}%
+ {\hpack{\vrule\s!width\scratchwidth\s!height.1\mathexheight\s!depth\zeropoint}}
+
+% \def\math_stackers_with_fallback#codepoint%
+% {\begingroup
+% \scratchunicode#codepoint\relax
+% \ifcase\mathextensiblecode\fam\scratchunicode\relax
+% \math_stackers_fallback
+% \else
+% \math_stackers_stretch
+% \fi
+% \endgroup}
+
+%D We don't really need this because we can assume that fonts have the right
+%D extensibles. If needed I will make a general virtual extender for \OPENTYPE\
+%D fonts.
+%D
+%D Because we have quite some control over positioning, we have somewhat extensive
+%D tracing built in.
+
+\let\math_stackers_top \relax
+\let\math_stackers_middle\relax
+\let\math_stackers_bottom\relax
+\let\math_stackers_skip \hskip
+
+\installtextracker
+ {math.stackers.texts}
+ {\let\math_stackers_top \filledhboxb
+ \let\math_stackers_middle\filledhboxr
+ \let\math_stackers_bottom\filledhboxg
+ \let\math_stackers_skip \math_stackers_skip_indeed}
+ {\let\math_stackers_top \relax
+ \let\math_stackers_middle\relax
+ \let\math_stackers_bottom\relax
+ \let\math_stackers_skip \hskip}
+
+\def\math_stackers_skip_indeed#amount%
+ {\filledhboxk{\unsetteststrut\strut\hskip#amount}} % \dontshowstruts
+
+\let\math_stackers_start_tagged_mid\relax
+\let\math_stackers_start_tagged_top\relax
+\let\math_stackers_start_tagged_bot\relax
+\let\math_stackers_stop_tagged \relax
+
+\appendtoks
+ \def\math_stackers_start_tagged_mid{\dostarttagged\t!mstackermid\empty\hbox\bgroup}%
+ \def\math_stackers_start_tagged_top{\dostarttagged\t!mstackertop\empty\hbox\bgroup}%
+ \def\math_stackers_start_tagged_bot{\dostarttagged\t!mstackerbot\empty\hbox\bgroup}%
+ \def\math_stackers_stop_tagged {\egroup\dostoptagged}%
+\to \everysetuptagging
+
+%D We define a full featured command handler.
+
+\installcorenamespace {mathstackers}
+
+\installcommandhandler \??mathstackers {mathstackers} \??mathstackers
+
+\setupmathstackers
+ [%c!alternative=\v!text, % text | mathematics
+ \c!left=,
+ \c!right=,
+ \c!mathclass=\s!rel,
+ \c!alternative=\v!normal,
+ \c!voffset=.25\mathexheight,
+ \c!hoffset=\zeropoint,
+ \c!topoffset=\zeropoint, % for manual italic correction
+ \c!distance=\mathstackersparameter\c!voffset, % distance between symbol and base (can be different from voffset)
+ \c!minheight=\mathexheight,
+ \c!mindepth=\zeropoint,
+ \c!minwidth=.5\mathemwidth,
+ \c!order=\v!normal,
+ \c!strut=,
+ \c!color=, % todo: when I need it
+ \c!topcommand=,
+ \c!middlecommand=,
+ \c!bottomcommand=,
+ \c!offset=\v!normal, % normal | min | max
+ \c!location=\v!top] % none | normal | small | medium | big
+
+%D We assume that the middle characters (that can be an extensible) to sit on
+%D top of the baseline by default.
+
+\installcorenamespace {mathstackerslocation}
+\installcorenamespace {mathstackersalternative}
+
+\letvalue{\??mathstackerslocation\v!top }\plusone % on top of baseline
+\letvalue{\??mathstackerslocation\v!high }\plustwo % 25 % down
+\letvalue{\??mathstackerslocation\v!middle }\plusthree % centered
+\letvalue{\??mathstackerslocation\v!low }\plusfour % 75 % down
+\letvalue{\??mathstackerslocation\v!bottom }\plusfive % below baseline
+\letvalue{\??mathstackerslocation }\zerocount
+
+%D First we implement the helper that deals with an extensible in the middle and
+%D top and|/|or bottom texts:
+
+\let\m_math_stackers_text_top \empty
+\let\m_math_stackers_text_bottom\empty
+\let\m_math_stackers_text_middle\empty
+
+\def\math_stackers_flushtext#command#text%
+ {\ifdim\scratchleftoffset >\zeropoint\math_stackers_skip\scratchleftoffset \fi
+ \ifx\p_strut\v!no \else
+ \strut
+ \fi
+ \mathstackersparameter#command#text%
+ \ifdim\scratchrightoffset>\zeropoint\math_stackers_skip\scratchrightoffset\fi}
+
+\def\math_stackers_toptext {\math_stackers_flushtext\c!topcommand \m_math_stackers_text_top }
+\def\math_stackers_bottomtext{\math_stackers_flushtext\c!bottomcommand\m_math_stackers_text_bottom}
+\def\math_stackers_middletext{\math_stackers_flushtext\c!middlecommand\m_math_stackers_text_middle}
+
+\def\math_stackers_content
+ {\ifcase\scratchcounter
+ \math_stackers_fallback
+ \or % left
+ \math_stackers_regular
+ \or % right
+ \math_stackers_regular
+ \or % horizontal
+ \math_stackers_regular
+ \else
+ \math_stackers_fallback
+ \fi}
+
+% no checking, we assume sane use
+
+\letvalue{\??mathstackersalternative\v!normal }\math_stackers_content
+\letvalue{\??mathstackersalternative\v!default}\math_stackers_content
+
+\setupmathstackers
+ [\c!mp=math:stacker:\number\scratchunicode,
+ \c!mpheight=\mathcharht\scratchunicode,
+ \c!mpdepth=\mathchardp\scratchunicode,
+ \c!mpoffset=.25\mathexheight]
+
+\setvalue{\??mathstackersalternative\v!mp}%
+ {\normalexpanded{\math_stackers_mp_box
+ {\the\dimexpr\mathstackersparameter\c!mpheight}%
+ {\the\dimexpr\mathstackersparameter\c!mpdepth}%
+ {\the\dimexpr\mathstackersparameter\c!mpoffset}%
+ {\the\dimexpr\triggeredmathstyleparameter\Umathfractionrule}%
+ {\the\dimexpr\triggeredmathstyleparameter\Umathaxis}%
+ {\the\mathexheight}%
+ {\the\mathemwidth}%
+ }}
+
+\protected\def\math_stackers_mp_box#1#2#3#4#5#6#7%
+ {\hpack\bgroup % todo: add code key + tag
+ % we can speed up \mathexheight expansion a bit
+ \d_overlay_width \scratchwidth
+ \d_overlay_height #1\relax
+ \d_overlay_depth #2\relax
+ \d_overlay_offset #3\relax
+ \d_overlay_linewidth#4\relax
+ \edef\overlaylinecolor{\mathstackersparameter\c!color}%
+ \edef\p_mp{\mathstackersparameter\c!mp}%
+ \uniqueMPgraphic{\p_mp}{axis=#5,ex=#6,em=#7}%
+ \egroup}
+
+\def\math_stackers_check_unicode#codepoint%
+ {\scratchunicode#codepoint\relax
+ \scratchhoffset\mathstackersparameter\c!hoffset\relax
+ \scratchvoffset\mathstackersparameter\c!voffset\relax
+ \scratchcounter\mathhorizontalcode\fam\scratchunicode\relax % also sets \leftscratchoffset and \rightscratchoffset
+ \ifx\p_offset\v!max
+ % heads/tails + hoffset
+ \orelse\ifx\p_offset\v!min
+ % heads/tails - hoffset
+ \advance\scratchleftoffset -\scratchhoffset
+ \advance\scratchrightoffset-\scratchhoffset
+ \else % \v!normal
+ % hoffset
+ \scratchleftoffset\zeropoint
+ \scratchrightoffset\zeropoint
+ \fi
+ \ifdim\scratchleftoffset<\zeropoint
+ \scratchleftoffset\zeropoint
+ \fi
+ \ifdim\scratchrightoffset<\zeropoint
+ \scratchrightoffset\zeropoint
+ \fi}
+
+\def\math_stackers_normalize_three
+ {\scratchheight\ht\scratchboxthree
+ \scratchdepth \dp\scratchboxthree
+ \scratchtopoffset \scratchheight
+ \scratchbottomoffset\scratchdepth
+ \scratchdimen\mathstackersparameter\c!minheight\relax
+ \ifdim\scratchheight<\scratchdimen
+ \scratchheight\scratchdimen
+ \ht\scratchboxthree\scratchheight
+ \fi
+ \scratchdimen\mathstackersparameter\c!mindepth\relax
+ \ifdim\scratchdepth<\scratchdimen
+ \scratchdepth\scratchdimen
+ \dp\scratchboxthree\scratchdepth
+ \fi
+ \advance\scratchtopoffset -\scratchheight
+ \advance\scratchbottomoffset-\scratchdepth
+ \ifdim\scratchtopoffset<\zeropoint
+ \scratchtopoffset\zeropoint
+ \fi
+ \ifdim\scratchbottomoffset<\zeropoint
+ \scratchbottomoffset\zeropoint
+ \fi}
+
+\protected\def\math_stackers_triplet#method#category#codepoint#toptext#bottomtext%
+ {\begingroup
+ \edef\currentmathstackers{#category}%
+ \mathstackersparameter\c!left\relax
+ \dostarttagged\t!mstacker\currentmathstackers
+ \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
+ {\edef\p_offset {\mathstackersparameter\c!offset}%
+ \edef\p_location {\mathstackersparameter\c!location}%
+ \edef\p_strut {\mathstackersparameter\c!strut}%
+ \edef\p_alternative{\mathstackersparameter\c!alternative}%
+ \edef\m_math_stackers_text_top {#toptext}%
+ \edef\m_math_stackers_text_bottom{#bottomtext}%
+ \ifparameter#bottomtext\or
+ \edef\p_order{\mathstackersparameter\c!order}%
+ \ifx\p_order\v!reverse
+ \swapmacros\m_math_stackers_text_top\m_math_stackers_text_bottom
+ \fi
+ \fi
+ \scratchleftoffset \zeropoint
+ \scratchrightoffset\zeropoint
+ \ifcase#method\relax
+ \math_stackers_check_unicode{#codepoint}%
+ \else
+ \edef\m_math_stackers_text_middle{#codepoint}%
+ \fi
+ \ifempty\m_math_stackers_text_top
+ \setbox\scratchboxone\emptyhbox
+ \else
+ \setmathsmalltextbox\scratchboxone\hbox{\math_stackers_toptext}%
+ \fi
+ \ifempty\m_math_stackers_text_bottom
+ \setbox\scratchboxtwo\emptyhbox
+ \else
+ \setmathsmalltextbox\scratchboxtwo\hbox{\math_stackers_bottomtext}%
+ \fi
+ %
+ \ifcase#method\relax
+ % e.g. extensible
+ %\scratchwidth\wd
+ % \ifdim\wd\scratchboxone>\wd\scratchboxtwo
+ % \scratchboxone
+ % \else
+ % \scratchboxtwo
+ % \fi
+ %\relax
+ \scratchwidth\mathcharwd\scratchunicode
+ \ifdim\wd\scratchboxone>\scratchwidth
+ \scratchwidth\wd\scratchboxone
+ \orelse\ifdim\wd\scratchboxtwo>\scratchwidth
+ \scratchwidth\wd\scratchboxtwo
+ \fi
+ \else
+ \ifempty\m_math_stackers_text_middle
+ \setbox\scratchboxthree\emptyhbox
+ \else
+ \setmathtextbox\scratchboxthree\hbox{\math_stackers_middletext}%
+ \fi
+ \scratchwidth\wd
+ \ifdim\wd\scratchboxone>\wd\scratchboxtwo
+ \ifdim\wd\scratchboxone>\wd\scratchboxthree
+ \scratchboxone
+ \else
+ \scratchboxthree
+ \fi
+ \orelse\ifdim\wd\scratchboxtwo>\wd\scratchboxthree
+ \scratchboxtwo
+ \else
+ \scratchboxthree
+ \fi
+ \relax
+ \fi
+ %
+ \scratchdimen\mathstackersparameter\c!minwidth\relax
+ \ifdim\scratchwidth<\scratchdimen
+ \scratchwidth\scratchdimen
+ \fi
+ \advance\scratchwidth2\scratchhoffset
+ %
+ \ifcase#method\relax
+ \dostarttagged\t!mstackermid\empty
+ \setbox\scratchboxthree\csname\??mathstackersalternative\p_alternative\endcsname
+ \dostoptagged
+ \fi
+ %
+ \ifdim\wd\scratchboxone<\scratchwidth
+ \setbox\scratchboxone\hpack to \scratchwidth{\hss\unhbox\scratchboxone\hss}% unhboxing makes leaders work
+ \fi
+ \ifdim\wd\scratchboxtwo<\scratchwidth
+ \setbox\scratchboxtwo\hpack to \scratchwidth{\hss\unhbox\scratchboxtwo\hss}%
+ \fi
+ \ifdim\wd\scratchboxthree<\scratchwidth
+ \setbox\scratchboxthree\hpack to \scratchwidth{\hss\unhbox\scratchboxthree\hss}%
+ \fi
+ %
+ \ifcsname\??mathstackerslocation\p_location\endcsname
+ \ifcase\csname\??mathstackerslocation\p_location\endcsname\relax
+ \scratchdistance\zeropoint
+ \or % top
+ \scratchdistance\zeropoint
+ \or % high
+ \scratchdistance.25\htdp\scratchboxthree
+ \or % centered
+ \scratchdistance.5\htdp\scratchboxthree
+ \or % low
+ \scratchdistance.75\htdp\scratchboxthree
+ \or % bottom
+ \scratchdistance\htdp\scratchboxthree
+ \else
+ \scratchdistance\zeropoint
+ \fi
+ \else
+ \scratchdistance\p_location\htdp\scratchboxthree
+ \fi
+ %
+ \ifzeropt\scratchdistance\else
+ \setbox\scratchboxthree\hpack{\lower\scratchdistance\box\scratchboxthree}%
+ \fi
+ %
+ \math_stackers_normalize_three
+ % analysis
+ \ifdim\htdp\scratchboxtwo>\zeropoint
+ \ifdim\htdp\scratchboxone>\zeropoint
+ \dosettagproperty\s!subtype\t!munderover
+ \else
+ \dosettagproperty\s!subtype\t!munder
+ \fi
+ \else
+ \ifdim\htdp\scratchboxone>\zeropoint
+ \dosettagproperty\s!subtype\t!mover
+ \else
+ % brrr
+ \fi
+ \fi
+ % base
+ \math_stackers_start_tagged_mid
+ \math_stackers_middle\bgroup
+ \box\scratchboxthree
+ \egroup
+ \math_stackers_stop_tagged
+ % under
+ \ifdim\htdp\scratchboxtwo>\zeropoint
+ \math_stackers_start_tagged_bot
+ \scratchoffset\scratchvoffset
+ \kern-\scratchwidth
+ \math_stackers_bottom\bgroup
+ \lower\dimexpr\ht\scratchboxtwo+\scratchdepth+\scratchoffset+\scratchbottomoffset\relax
+ \box\scratchboxtwo
+ \egroup
+ \math_stackers_stop_tagged
+ \fi
+ % over
+ \ifdim\htdp\scratchboxone>\zeropoint
+ \math_stackers_start_tagged_top
+ \scratchoffset\scratchvoffset
+ \kern-\scratchwidth
+ \math_stackers_top\bgroup
+ \raise\dimexpr\dp\scratchboxone+\scratchheight+\scratchoffset+\scratchtopoffset\relax
+ \box\scratchboxone
+ \egroup
+ \math_stackers_stop_tagged
+ \fi
+ %
+ }%
+ \dostoptagged
+ \mathstackersparameter\c!right\relax
+ \endgroup}
+ %\math_stackers_stop_group}
+
+\permanent\tolerant\protected\def\definemathextensible[#1]#*[#2]#*[#3]% category name unicode
+ {\ifarguments\or\or
+ \frozen\setuevalue{#1}{\math_stackers_auto_normal\noexpand\currentmathstackers{\number#2}}%
+ \or
+ \frozen\setuevalue{#2}{\math_stackers_auto_normal{#1}{\number#3}}%
+ \fi}
+
+\tolerant\protected\def\math_stackers_auto_normal#1#2#*[#3]#:#=#*#=%
+ {\begingroup
+ \scratchcounter#2\relax
+ \edef\currentmathstackers{\ifparameter#3\or#3\else#1\fi}%
+ \math_stackers_triplet\zerocount\currentmathstackers\scratchcounter{#4}{#5}%
+ \endgroup}
+
+%D A few direct accessors (in the meantime we redefined \mathextensible so we renamed the
+%D following):
+
+\permanent\tolerant\protected\def\directmathextensible[#category]%
+ {\begingroup
+ \math_stackers_handle_extensible{\ifparameter#category\or#category\else\v!mathematics\fi}} % will be defined later on
+
+\permanent\tolerant\protected\def\directtextextensible[#category]%
+ {\begingroup
+ \math_stackers_handle_extensible{\ifparameter#category\or#category\else\v!text\fi}} % will be defined later on
+
+\aliased\let\mathstacker\directmathextensible
+\aliased\let\textstacker\directtextextensible
+
+\def\math_stackers_handle_extensible#category#codepoint#toptext#bottomtext%
+ {\math_stackers_triplet\zerocount{#category}{#codepoint}{#toptext}{#bottomtext}%
+ \endgroup}
+
+%D The next one deals with under and over extensibles (arrows mostly):
+
+\installcorenamespace {mathclasses}
+
+\letvalue{\??mathclasses }\mathord
+\letvalue{\??mathclasses rel}\mathrel
+\letvalue{\??mathclasses ord}\mathord
+
+\def\math_class_by_parameter#1%
+ {\normalexpanded{\noexpand\math_class_by_parameter_indeed{#1\c!mathclass}}}
+
+\def\math_class_by_parameter_indeed#1%
+ {\csname\??mathclasses\ifcsname\??mathclasses#1\endcsname#1\fi\endcsname}
+
+% 1 0 name n 0 | 0 1 name n 0 | 1 1 name n n
+
+\let\math_stackers_stop_group\endgroup
+
+\protected\def\math_stackers_start_group#category%
+ {\begingroup
+ \edef\currentmathstackers{#category}%
+ \edef\p_limits{\mathstackersparameter\c!mathlimits}%
+ \ifx\p_limits\v!yes
+ \def\math_stackers_stop_group{\egroup\endgroup\ordlimits}%
+ \mathop\bgroup
+ \else
+ \let\math_stackers_stop_group\endgroup
+ \fi}
+
+\newconstant\c_math_stackers_top
+\newconstant\c_math_stackers_bottom
+\newconstant\c_math_stackers_codepoint
+\newconstant\c_math_stackers_extracode
+\newdimen \d_math_stackers_offset_l
+\newdimen \d_math_stackers_offset_r
+
+\setupmathstackers[lt=\zeropoint,rt=\zeropoint,lb=\zeropoint,rb=\zeropoint]
+
+\tolerant\protected\def\math_stackers_make_double#top#bottom#category#codepoint#codeextra#spacer[#settings]#:#text%
+ {\math_stackers_start_group{#category}%
+ \c_math_stackers_top #top\relax
+ \c_math_stackers_bottom #bottom\relax
+ \c_math_stackers_codepoint#codepoint\relax
+ \c_math_stackers_extracode#codeextra\relax
+ \ifparameter#settings\or
+ \setupcurrentmathstackers[#settings]%
+ \fi
+ \mathstackersparameter\c!left\relax
+ \dostarttagged\t!mstacker\currentmathstackers
+ \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
+ {\edef\m_math_stackers_text_middle {#text}%
+ %
+ \edef\p_offset {\mathstackersparameter\c!offset}%
+ \edef\p_location {\mathstackersparameter\c!location}%
+ \edef\p_strut {\mathstackersparameter\c!strut}%
+ \edef\p_alternative{\mathstackersparameter\c!alternative}%
+ %
+ \scratchleftoffset \zeropoint
+ \scratchrightoffset\zeropoint
+ %
+ \math_stackers_check_unicode\c_math_stackers_codepoint
+ %
+ \ifempty\math_stackers_middle
+ \setbox\scratchboxthree\emptyhbox
+ \else
+ \setmathtextbox\scratchboxthree\hbox{\math_stackers_middletext}%
+ \fi
+ \scratchwidth\wd\scratchboxthree
+ %
+ \scratchdimen\mathstackersparameter\c!minwidth\relax
+ \ifdim\scratchwidth<\scratchdimen
+ \scratchwidth\scratchdimen
+ \fi
+ \advance\scratchwidth2\scratchhoffset
+ %
+ %\scratchunicode\c_math_stackers_codepoint
+ \ifcase\c_math_stackers_bottom
+ \d_math_stackers_offset_l\mathstackersparameter{lt}%
+ \d_math_stackers_offset_r\mathstackersparameter{rt}%
+ \orelse\ifcase\c_math_stackers_top
+ \d_math_stackers_offset_l\mathstackersparameter{lb}%
+ \d_math_stackers_offset_r\mathstackersparameter{rb}%
+ \else
+ \d_math_stackers_offset_l\mathstackersparameter{lt}%
+ \d_math_stackers_offset_r\mathstackersparameter{rt}%
+ \fi
+ \setbox\scratchboxtwo\csname\??mathstackersalternative\p_alternative\endcsname
+ \setbox\scratchboxthree\hpack to \scratchwidth{\hss\box\scratchboxthree\hss}%
+ %
+ \ifcase\c_math_stackers_extracode\else
+ \scratchunicode\c_math_stackers_extracode
+ \d_math_stackers_offset_l\mathstackersparameter{lb}%
+ \d_math_stackers_offset_r\mathstackersparameter{rb}%
+ \setbox\scratchboxone\csname\??mathstackersalternative\p_alternative\endcsname
+ \fi
+ %
+ \math_stackers_normalize_three
+ % analysis
+ \ifcase\c_math_stackers_bottom
+ \ifcase\c_math_stackers_top
+ \dosettagproperty\s!subtype\t!munderover
+ \else
+ \dosettagproperty\s!subtype\t!mover
+ \fi
+ \else
+ \ifcase\c_math_stackers_top
+ \dosettagproperty\s!subtype\t!munder
+ \else
+ % brrr
+ \fi
+ \fi
+ % base
+ \math_stackers_start_tagged_mid
+ \math_stackers_middle\bgroup
+ \box\scratchboxthree
+ \egroup
+ \math_stackers_stop_tagged
+ %
+ \ifdim\htdp\scratchboxtwo>\zeropoint
+ \ifcase\c_math_stackers_bottom\else
+ \kern-\scratchwidth
+ % under
+ \math_stackers_start_tagged_bot
+ \math_stackers_bottom\bgroup
+ \lower\dimexpr
+ \scratchdepth
+ +\ht\scratchboxtwo
+ +\mathstackersparameter\c!distance % was \c!voffset
+ \relax
+ \ifcase\c_math_stackers_top
+ \box\scratchboxtwo
+ \else
+ \box\scratchboxone
+ \fi
+ \egroup
+ \math_stackers_stop_tagged
+ \fi
+ \ifcase\c_math_stackers_top\else
+ \kern-\scratchwidth
+ % over
+ \math_stackers_start_tagged_top
+ \math_stackers_top\bgroup
+ \raise\dimexpr
+ \scratchheight
+ +\dp\scratchboxtwo % new
+ +\mathstackersparameter\c!distance % was \c!voffset
+ \relax
+ \box\scratchboxtwo
+ \egroup
+ \math_stackers_stop_tagged
+ \fi
+ \fi}%
+ \dostoptagged
+ \mathstackersparameter\c!right\relax
+ \math_stackers_stop_group}
+
+\permanent\tolerant\protected\def\definemathoverextensible[#1]#*[#2]#*[#3]%
+ {\ifparameter#3\or
+ \frozen\setuevalue{#2}{\math_stackers_make_double\plusone \zerocount{#1}{\number#3}{0}}%
+ \else
+ \frozen\setuevalue{#1}{\math_stackers_make_double\plusone \zerocount\noexpand\currentmathstackers{\number#2}{0}}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemathunderextensible[#1]#*[#2]#*[#3]%
+ {\ifparameter#3\or
+ \frozen\setuevalue{#2}{\math_stackers_make_double\zerocount\plusone{#1}{\number#3}{0}}%
+ \else
+ \frozen\setuevalue{#1}{\math_stackers_make_double\zerocount\plusone\noexpand\currentmathstackers{\number#2}{0}}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemathdoubleextensible[#1]#*[#2]#*[#3]#*[#4]%
+ {\ifparameter#4\or
+ \frozen\setuevalue{#2}{\math_stackers_make_double\plusone \plusone{#1}{\number#3}{\number#4}}%
+ \else
+ \frozen\setuevalue{#1}{\math_stackers_make_double\plusone \plusone\noexpand\currentmathstackers{\number#2}{\number#3}}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemathover[#category]#spacer[#command]#spacer[#topcode]%
+ {\frozen\setuvalue{#command}{\math_stackers_handle_direct\plusone\zerocount{#category}{#topcode}{0}}}
+
+\permanent\tolerant\protected\def\definemathunder[#category]#spacer[#command]#spacer[#bottomcode]%
+ {\frozen\setuvalue{#command}{\math_stackers_handle_direct\zerocount\plusone{#category}{#bottomcode}{0}}}
+
+\permanent\tolerant\protected\def\definemathdouble[#category]#spacer[#command]#spacer[#topcode]#spacer[#bottomcode]%
+ {\frozen\setuvalue{#command}{\math_stackers_handle_direct\plusone\plusone{#category}{#topcode}{#bottomcode}}}
+
+\permanent\tolerant\protected\def\mathover[#category]#spacer[#settings]#:#topcode#text%
+ {\begingroup
+ \edef\currentmathstackers{\ifparameter#category\or#category\else\v!top\fi}%
+ \ifparameter#settings\or
+ \setupcurrentmathstackers[#settings]%
+ \fi
+ \math_stackers_make_double\plusone\zerocount
+ {\currentmathstackers}%
+ {#topcode}%
+ {0}%
+ {#text}%
+ \endgroup}
+
+\permanent\tolerant\protected\def\mathunder[#category]#spacer[#settings]#:#bottomcode#text%
+ {\begingroup
+ \edef\currentmathstackers{\ifparameter#category\or#category\else\v!bottom\fi}%
+ \ifparameter#settings\or
+ \setupcurrentmathstackers[#settings]%
+ \fi
+ \math_stackers_make_double\zerocount\plusone
+ {\currentmathstackers}%
+ {#bottomcode}%
+ {0}%
+ {#text}%
+ \endgroup}
+
+\permanent\tolerant\protected\def\mathdouble[#category]#spacer[#settings]#:#topcode#bottomcode#text%
+ {\begingroup
+ \edef\currentmathstackers{\ifparameter#category\or#category\else\v!both\fi}%
+ \ifparameter#settings\or
+ \setupcurrentmathstackers[#settings]%
+ \fi
+ \math_stackers_make_double\plusone\plusone
+ {\currentmathstackers}%
+ {#topcode}%
+ {#bottomcode}%
+ {#text}%
+ \endgroup}
+
+\def\math_stackers_handle_direct#top#bottom#category#topcode#bottomcode#text%
+ {\begingroup
+ \math_stackers_make_double#top#bottom{#category}{#topcode}{#bottomcode}{#text}%
+ \endgroup}
+
+%D A relative new one is a combination of accents and text (as needed in mathml):
+
+\protected\def\math_stackers_make_double_text#where#category#codepoint#text#extra%
+ {\math_stackers_start_group{#category}%
+ \mathstackersparameter\c!left\relax
+ \dostarttagged\t!mstacker\currentmathstackers
+ \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
+ {\edef\currentmathstackers{#category}%
+ %
+ \edef\p_offset {\mathstackersparameter\c!offset}%
+ \edef\p_location {\mathstackersparameter\c!location}%
+ \edef\p_strut {\mathstackersparameter\c!strut}%
+ \edef\p_alternative{\mathstackersparameter\c!alternative}%
+ %
+ \scratchleftoffset \zeropoint
+ \scratchrightoffset\zeropoint
+ %
+ \edef\m_math_stackers_text_middle{#text}%
+ \math_stackers_check_unicode{#codepoint}%
+ \scratchunicode#codepoint\relax
+ %
+ \ifempty\math_stackers_middle
+ \setbox\scratchboxthree\emptyhbox
+ \else
+ \setmathtextbox\scratchboxthree\hbox{\math_stackers_middletext}%
+ \fi
+ %
+ \ifcase#where\relax
+ \edef\m_math_stackers_text_top{#extra}%
+ \ifempty\math_stackers_top
+ \setbox\scratchboxone\emptyhbox
+ \else
+ \setmathsmalltextbox\scratchboxone\hbox{\math_stackers_toptext}%
+ \fi
+ \else
+ \edef\m_math_stackers_text_bottom{#extra}%
+ \ifempty\math_stackers_bottom
+ \setbox\scratchboxone\emptyhbox
+ \else
+ \setmathsmalltextbox\scratchboxone\hbox{\math_stackers_bottomtext}%
+ \fi
+ \fi
+ %
+ \scratchwidth\wd
+ \ifdim\wd\scratchboxone>\wd\scratchboxthree
+ \scratchboxone
+ \else
+ \scratchboxthree
+ \fi
+ \relax
+ \scratchdimen\mathstackersparameter\c!minwidth\relax
+ \ifdim\scratchwidth<\scratchdimen
+ \scratchwidth\scratchdimen
+ \fi
+ \advance\scratchwidth2\scratchhoffset
+ %
+ \ifdim\wd\scratchboxone<\scratchwidth
+ \setbox\scratchboxone\hpack to \scratchwidth{\hss\unhbox\scratchboxone\hss}%
+ \fi
+ \ifdim\wd\scratchboxthree<\scratchwidth
+ \setbox\scratchboxthree\hpack to \scratchwidth{\hss\unhbox\scratchboxthree\hss}%
+ \fi
+ %
+ \math_stackers_normalize_three
+ % analysis
+ \dosettagproperty\s!subtype\t!munderover
+ % base
+ \math_stackers_start_tagged_mid
+ \math_stackers_middle\bgroup
+ \box\scratchboxthree
+ \egroup
+ \math_stackers_stop_tagged
+ %
+ \setbox\scratchboxtwo\csname\??mathstackersalternative\p_alternative\endcsname
+ \kern-\scratchwidth
+ \ifcase#where\relax
+ % under
+ \math_stackers_start_tagged_bot
+ \math_stackers_bottom\bgroup
+ \lower\dimexpr
+ \scratchdepth
+ +\ht\scratchboxtwo
+ +\mathstackersparameter\c!distance
+ \relax
+ \box\scratchboxtwo % accent
+ \egroup
+ \math_stackers_stop_tagged
+ \kern-\scratchwidth
+ % over
+ \math_stackers_start_tagged_top
+ \math_stackers_top\bgroup
+ \raise\dimexpr
+ \scratchheight
+ +\dp\scratchboxone
+ +\mathstackersparameter\c!voffset
+ \relax
+ \box\scratchboxone % toptext
+ \egroup
+ \math_stackers_stop_tagged
+ \else
+ % under
+ \math_stackers_start_tagged_bot
+ \math_stackers_bottom\bgroup
+ \lower\dimexpr
+ \scratchdepth
+ +\ht\scratchboxone
+ +\mathstackersparameter\c!voffset
+ \relax
+ \box\scratchboxone % bottext
+ \egroup
+ \math_stackers_stop_tagged
+ \kern-\scratchwidth
+ % over
+ \math_stackers_start_tagged_top
+ \math_stackers_top\bgroup
+ \raise\dimexpr
+ \scratchheight
+ +\dp\scratchboxtwo % new
+ +\mathstackersparameter\c!distance
+ \relax
+ \box\scratchboxtwo % accent
+ \egroup
+ \math_stackers_stop_tagged
+ \fi
+ }%
+ \dostoptagged
+ \mathstackersparameter\c!right\relax
+ \math_stackers_stop_group}
+
+\permanent\tolerant\protected\def\definemathovertextextensible[#1]#*[#2]#*[#3]%
+ {\ifparameter#3\or
+ \frozen\setuevalue{#2}{\math_stackers_make_double_text\plusone{#1}{\number#3}}%
+ \else
+ \frozen\setuevalue{#1}{\math_stackers_make_double_text\plusone\noexpand\currentmathstackers{\number#2}}%
+ \fi}
+
+\permanent\tolerant\protected\def\definemathundertextextensible[#1]#*[#2]#*[#3]%
+ {\ifparameter#3\or
+ \frozen\setuevalue{#2}{\math_stackers_make_double_text\zerocount{#1}{\number#3}}%
+ \else
+ \frozen\setuevalue{#1}{\math_stackers_make_double_text\zerocount\noexpand\currentmathstackers{\number#2}}%
+ \fi}
+
+\permanent\tolerant\protected\def\mathovertext[#category]%
+ {\begingroup
+ \math_stackers_direct_double_text\plusone {\ifarguments#category\or#category\else\v!top\fi}}
+
+\permanent\tolerant\protected\def\mathundertext[#category]%
+ {\begingroup
+ \math_stackers_direct_double_text\zerocount{\ifarguments#category\or#category\else\v!bottom\fi}}
+
+\def\math_stackers_direct_double_text#where#category#codepoint#text#extra%%
+ {\math_stackers_make_double_text#where{#category}{#codepoint}{#text}{#extra}%
+ \endgroup}
+
+%D Here is a bonus macro that takes three texts. It can be used to get consistent
+%D mixed usage.
+
+\permanent\tolerant\protected\def\mathtriplet[#category]#:#middletext#toptext#bottomtext%
+ {\begingroup
+ \math_stackers_triplet\plusone{\ifarguments#category\or#category\else\currentmathstackers\fi}{#middletext}{#toptext}{#bottomtext}%
+ \endgroup}
+
+\permanent\tolerant\protected\def\definemathtriplet[#1]#*[#2]#*[#3]% category name default
+ {\ifarguments\or
+ \frozen\setuevalue{#1}{\math_stackers_auto_triplet_nop[\noexpand\currentmathstackers]}%
+ \or
+ \frozen\setuevalue{#2}{\math_stackers_auto_triplet_nop[#1]}%
+ \or
+ \frozen\setuevalue{#2}{\math_stackers_auto_triplet_yes[#1][#3]}%
+ \fi}
+
+\tolerant\protected\def\math_stackers_auto_triplet_yes[#1][#2]#*[#3]#:#=#*#=% [#2]% #2 gobble spaces
+ {\begingroup
+ \edef\currentmathstackers{#1}%
+ \def \m_math_stackers_text_middle{#2}%
+ \ifarguments#3\or\edef\currentmathstackers{#3}\fi
+ \math_stackers_triplet\plusone\currentmathstackers\m_math_stackers_text_middle{#4}{#5}%
+ \endgroup}
+
+\tolerant\protected\def\math_stackers_auto_triplet_nop[#1]#*[#2]#:#=#*#=#*#=% [#2]% #2 gobble spaces%
+ {\begingroup
+ \edef\currentmathstackers{#1}%
+ \ifarguments#2\or\edef\currentmathstackers{#2}\fi
+ \math_stackers_triplet\plusone\currentmathstackers{#3}{#4}{#5}%
+ \endgroup}
+
+%D Definitions:
+
+\definemathstackers
+ [\v!mathematics]
+ [\c!topcommand=\mathematics,
+ \c!middlecommand=\mathematics,
+ \c!bottomcommand=\mathematics]
+
+\definemathstackers
+ [\s!math]
+ [\v!mathematics]
+
+\definemathstackers
+ [\v!text]
+ [\v!mathematics]
+ [\c!topcommand=,
+ \c!middlecommand=\mathematics,
+ \c!bottomcommand=]
+
+\definemathstackers
+ [\v!reverse]
+ [\v!mathematics]
+ [\c!order=\v!reverse]
+
+\definemathstackers
+ [\v!both]
+ [\v!mathematics]
+ [\c!location=\v!top, % ?
+ \c!strut=\v!no,
+ \c!middlecommand=\mathematics,
+ \c!hoffset=\zeropoint]
+
+\definemathstackers
+ [\v!top]
+ [\v!both]
+
+\definemathstackers
+ [\v!bottom]
+ [\v!both]
+
+\definemathstackers
+ [\v!vfenced]
+ [\v!both]
+ [\c!mathclass=\s!ord,
+ \c!mathlimits=\v!yes]
+
+% these are needed for mathml:
+
+% \setupmathstackers
+% [\v!both]
+% [\c!hoffset=1pt,
+% \c!voffset=1pt]
+
+\definemathstackers
+ [\v!bothtext]
+ [\v!both]
+ [\c!strut=\v!yes]
+
+% These are compatibity definitions, math only.
+
+% todo: top= bottom= middle= is nicer (compare math-fen)
+
+%D We save a few definitions that we automatically got from the \type {char-def.lua}
+%D database.
+
+% Be careful in choosing what accents you take (the code below uses a combining
+% one):
+%
+% \startbuffer
+% % $\Umathaccent top 0 0 "20D7 {example}$
+% % $\Umathaccent top fixed 0 0 "20D7 {example}$
+% $\Umathaccent 0 0 "20D7 {example}$
+% $\Umathaccent fixed 0 0 "20D7 {example}$
+% $\Umathaccent bottom 0 0 "20D7 {example}$
+% $\Umathaccent bottom fixed 0 0 "20D7 {example}$
+% $\Umathaccent both 0 0 "20D7
+% 0 0 "20D7 {example}$
+% $\Umathaccent both fixed 0 0 "20D7
+% fixed 0 0 "20D7 {example}$
+% $\Umathaccent both 0 0 "20D7
+% fixed 0 0 "20D7 {example}$
+% $\Umathaccent both fixed 0 0 "20D7
+% 0 0 "20D7 {example}$
+% \stopbuffer
+%
+% \setupbodyfont[modern] \getbuffer
+% \setupbodyfont[xits] \getbuffer
+% \setupbodyfont[cambria] \getbuffer
+
+\immutable\protected\def\normaldoublebrace {\Umathaccents 0 \defaultmathfamily "23DE 0 \defaultmathfamily "23DF }
+\immutable\protected\def\normaldoubleparent{\Umathaccents 0 \defaultmathfamily "23DC 0 \defaultmathfamily "23DD }
+
+% let's keep this
+
+\aliased\let\normaloverbrace \overbrace
+\aliased\let\normalunderbrace \underbrace
+\aliased\let\normaloverparent \overparent
+\aliased\let\normalunderparent \underparent
+\aliased\let\normaloverbracket \overbracket
+\aliased\let\normalunderbracket \underbracket
+\aliased\let\normalunderleftarrow \underleftarrow
+\aliased\let\normaloverleftarrow \overleftarrow
+\aliased\let\normalunderrightarrow\underrightarrow
+\aliased\let\normaloverrightarrow \overrightarrow
+
+%D Here come the new ones:
+
+\definemathstackers [\v!none] [\v!mathematics] [\c!hoffset=\zeropoint]
+\definemathstackers [\v!normal] [\v!mathematics] [\c!hoffset=0.5\mathemwidth] % the default
+\definemathstackers [\v!small] [\v!mathematics] [\c!hoffset=1\mathemwidth]
+\definemathstackers [\v!medium] [\v!mathematics] [\c!hoffset=1.5\mathemwidth]
+\definemathstackers [\v!big] [\v!mathematics] [\c!hoffset=2\mathemwidth]
+
+\definemathextensible [\v!reverse] [xrel] ["002D]
+\definemathextensible [\v!reverse] [xequal] ["003D]
+\definemathextensible [\v!reverse] [xleftarrow] ["2190] % ["27F5]
+\definemathextensible [\v!reverse] [xrightarrow] ["2192] % ["27F6]
+\definemathextensible [\v!reverse] [xleftrightarrow] ["27F7]
+\definemathextensible [\v!reverse] [xLeftarrow] ["27F8]
+\definemathextensible [\v!reverse] [xRightarrow] ["27F9]
+\definemathextensible [\v!reverse] [xLeftrightarrow] ["27FA]
+\definemathextensible [\v!reverse] [xtwoheadleftarrow] ["219E]
+\definemathextensible [\v!reverse] [xtwoheadrightarrow] ["21A0]
+\definemathextensible [\v!reverse] [xmapsto] ["21A6]
+\definemathextensible [\v!reverse] [xhookleftarrow] ["21A9]
+\definemathextensible [\v!reverse] [xhookrightarrow] ["21AA]
+\definemathextensible [\v!reverse] [xleftharpoondown] ["21BD]
+\definemathextensible [\v!reverse] [xleftharpoonup] ["21BC]
+\definemathextensible [\v!reverse] [xrightharpoondown] ["21C1]
+\definemathextensible [\v!reverse] [xrightharpoonup] ["21C0]
+\definemathextensible [\v!reverse] [xrightoverleftarrow] ["21C4]
+\definemathextensible [\v!reverse] [xleftrightharpoons] ["21CB]
+\definemathextensible [\v!reverse] [xrightleftharpoons] ["21CC]
+\definemathextensible [\v!reverse] [xtriplerel] ["2261]
+
+\definemathextensible [\v!mathematics] [mrel] ["002D]
+\definemathextensible [\v!mathematics] [mequal] ["003D]
+\definemathextensible [\v!mathematics] [mleftarrow] ["2190] % ["27F5]
+\definemathextensible [\v!mathematics] [mrightarrow] ["2192] % ["27F6]
+\definemathextensible [\v!mathematics] [mleftrightarrow] ["27F7]
+\definemathextensible [\v!mathematics] [mLeftarrow] ["27F8]
+\definemathextensible [\v!mathematics] [mRightarrow] ["27F9]
+\definemathextensible [\v!mathematics] [mLeftrightarrow] ["27FA]
+\definemathextensible [\v!mathematics] [mtwoheadleftarrow] ["219E]
+\definemathextensible [\v!mathematics] [mtwoheadrightarrow] ["21A0]
+\definemathextensible [\v!mathematics] [mmapsto] ["21A6]
+\definemathextensible [\v!mathematics] [mhookleftarrow] ["21A9]
+\definemathextensible [\v!mathematics] [mhookrightarrow] ["21AA]
+\definemathextensible [\v!mathematics] [mleftharpoondown] ["21BD]
+\definemathextensible [\v!mathematics] [mleftharpoonup] ["21BC]
+\definemathextensible [\v!mathematics] [mrightharpoondown] ["21C1]
+\definemathextensible [\v!mathematics] [mrightharpoonup] ["21C0]
+\definemathextensible [\v!mathematics] [mrightoverleftarrow] ["21C4]
+\definemathextensible [\v!mathematics] [mleftrightharpoons] ["21CB]
+\definemathextensible [\v!mathematics] [mrightleftharpoons] ["21CC]
+\definemathextensible [\v!mathematics] [mtriplerel] ["2261]
+
+\definemathextensible [\v!mathematics] [eleftarrowfill] ["2190] % ["27F5]
+\definemathextensible [\v!mathematics] [erightarrowfill] ["2192] % ["27F6]
+\definemathextensible [\v!mathematics] [eleftrightarrowfill] ["27F7]
+\definemathextensible [\v!mathematics] [etwoheadrightarrowfill] ["27F9]
+\definemathextensible [\v!mathematics] [eleftharpoondownfill] ["21BD]
+\definemathextensible [\v!mathematics] [eleftharpoonupfill] ["21BC]
+\definemathextensible [\v!mathematics] [erightharpoondownfill] ["21C1]
+\definemathextensible [\v!mathematics] [erightharpoonupfill] ["21C0]
+
+\definemathextensible [\v!mathematics] [eoverbarfill] ["FE33E]
+\definemathextensible [\v!mathematics] [eunderbarfill] ["FE33F]
+\definemathextensible [\v!mathematics] [eoverbracefill] ["FE3DE]
+\definemathextensible [\v!mathematics] [eunderbracefill] ["FE3DF]
+\definemathextensible [\v!mathematics] [eoverparentfill] ["FE3DC]
+\definemathextensible [\v!mathematics] [eunderparentfill] ["FE3DD]
+\definemathextensible [\v!mathematics] [eoverbracketfill] ["FE3B4]
+\definemathextensible [\v!mathematics] [eunderbracketfill] ["FE3B5]
+
+\definemathextensible [\v!text] [trel] ["002D]
+\definemathextensible [\v!text] [tequal] ["003D]
+\definemathextensible [\v!text] [tmapsto] ["21A6]
+\definemathextensible [\v!text] [tleftarrow] ["2190] % ["27F5]
+\definemathextensible [\v!text] [trightarrow] ["2192] % ["27F6]
+\definemathextensible [\v!text] [tleftrightarrow] ["27F7]
+\definemathextensible [\v!text] [tLeftarrow] ["27F8]
+\definemathextensible [\v!text] [tRightarrow] ["27F9]
+\definemathextensible [\v!text] [tLeftrightarrow] ["27FA]
+\definemathextensible [\v!text] [ttwoheadleftarrow] ["219E]
+\definemathextensible [\v!text] [ttwoheadrightarrow] ["21A0]
+\definemathextensible [\v!text] [thookleftarrow] ["21A9]
+\definemathextensible [\v!text] [thookrightarrow] ["21AA]
+\definemathextensible [\v!text] [tleftharpoondown] ["21BD]
+\definemathextensible [\v!text] [tleftharpoonup] ["21BC]
+\definemathextensible [\v!text] [trightharpoondown] ["21C1]
+\definemathextensible [\v!text] [trightharpoonup] ["21C0]
+\definemathextensible [\v!text] [trightoverleftarrow] ["21C4]
+\definemathextensible [\v!text] [tleftrightharpoons] ["21CB]
+\definemathextensible [\v!text] [trightleftharpoons] ["21CC]
+\definemathextensible [\v!text] [ttriplerel] ["2261]
+
+\definemathoverextensible [\v!top] [overleftarrow] ["2190] % ["27F5]
+\definemathoverextensible [\v!top] [overrightarrow] ["2192] % ["27F6]
+\definemathoverextensible [\v!top] [overleftrightarrow] ["27F7]
+\definemathoverextensible [\v!top] [overtwoheadleftarrow] ["27F8]
+\definemathoverextensible [\v!top] [overtwoheadrightarrow] ["27F9]
+\definemathoverextensible [\v!top] [overleftharpoondown] ["21BD]
+\definemathoverextensible [\v!top] [overleftharpoonup] ["21BC]
+\definemathoverextensible [\v!top] [overrightharpoondown] ["21C1]
+\definemathoverextensible [\v!top] [overrightharpoonup] ["21C0]
+
+\definemathunderextensible [\v!bottom] [underleftarrow] ["2190] % ["27F5]
+\definemathunderextensible [\v!bottom] [underrightarrow] ["2192] % ["27F6]
+\definemathunderextensible [\v!bottom] [underleftrightarrow] ["27F7]
+\definemathunderextensible [\v!bottom] [undertwoheadleftarrow] ["27F8]
+\definemathunderextensible [\v!bottom] [undertwoheadrightarrow] ["27F9]
+\definemathunderextensible [\v!bottom] [underleftharpoondown] ["21BD]
+\definemathunderextensible [\v!bottom] [underleftharpoonup] ["21BC]
+\definemathunderextensible [\v!bottom] [underrightharpoondown] ["21C1]
+\definemathunderextensible [\v!bottom] [underrightharpoonup] ["21C0]
+
+%D We don't use overline and underline. This is one of the overlooked aspects of
+%D unicode cq. opentype math: why treat rules different than e.g. arrows and
+%D accents. It is a bit unfortunate that the opportunity to move math to new
+%D technologies happened outside the tex domain (and/or some aspects were kept while
+%D in fact they were side effects of limitations of traditional fonts). From the
+%D unicode aware tex engines' implementation point of view things could have been
+%D done a bit nicer but then: the community didn't seem to care too much and just
+%D has to follow now.
+%D
+%D Anyhow, we use a character based approach so that at least we get unicode stuff
+%D in the backend (okay, we still need to deal with some cut and paste issues but at
+%D least we now know what we deal with.
+
+% alternatively we can move the original to FE*
+
+\definemathoverextensible [\v!vfenced] [overbar] ["FE33E] % ["203E]
+\definemathunderextensible [\v!vfenced] [underbar] ["FE33F] % ["203E]
+\definemathdoubleextensible [\v!vfenced] [doublebar] ["FE33E] ["FE33F]
+
+\definemathoverextensible [\v!vfenced] [overbrace] ["FE3DE] % ["023DE]
+\definemathunderextensible [\v!vfenced] [underbrace] ["FE3DF] % ["023DF]
+\definemathdoubleextensible [\v!vfenced] [doublebrace] ["FE3DE] ["FE3DF]
+
+\definemathoverextensible [\v!vfenced] [overparent] ["FE3DC] % ["023DC]
+\definemathunderextensible [\v!vfenced] [underparent] ["FE3DD] % ["023DD]
+\definemathdoubleextensible [\v!vfenced] [doubleparent] ["FE3DC] ["FE3DD]
+
+\definemathoverextensible [\v!vfenced] [overbracket] ["FE3B4] % ["023B4]
+\definemathunderextensible [\v!vfenced] [underbracket] ["FE3B5] % ["023B5]
+\definemathdoubleextensible [\v!vfenced] [doublebracket] ["FE3B4] ["FE3B5]
+
+% \protected\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
+
+%D For mathml:
+
+\definemathdoubleextensible [\v!both] [overbarunderbar] ["FE33E] ["FE33F]
+\definemathdoubleextensible [\v!both] [overbraceunderbrace] ["FE3DE] ["FE3DF]
+\definemathdoubleextensible [\v!both] [overparentunderparent] ["FE3DC] ["FE3DD]
+\definemathdoubleextensible [\v!both] [overbracketunderbracket] ["FE3B4] ["FE3B5]
+
+\definemathovertextextensible [\v!bothtext] [overbartext] ["FE33E]
+\definemathundertextextensible [\v!bothtext] [underbartext] ["FE33F]
+\definemathovertextextensible [\v!bothtext] [overbracetext] ["FE3DE]
+\definemathundertextextensible [\v!bothtext] [underbracetext] ["FE3DF]
+\definemathovertextextensible [\v!bothtext] [overparenttext] ["FE3DC]
+\definemathundertextextensible [\v!bothtext] [underparenttext] ["FE3DD]
+\definemathovertextextensible [\v!bothtext] [overbrackettext] ["FE3B4]
+\definemathundertextextensible [\v!bothtext] [underbrackettext] ["FE3B5]
+
+%D Some bonus ones (for the moment here):
+
+\definemathstackers
+ [\v!chemistry]
+ [\c!offset=\v!max,
+ \c!left=\enspace,
+ \c!right=\enspace,
+ \c!hoffset=.5\mathemwidth]
+
+\definemathextensible [\v!chemistry] [cleftarrow] ["2190]
+\definemathextensible [\v!chemistry] [crightarrow] ["2192]
+\definemathextensible [\v!chemistry] [crightoverleftarrow] ["21C4]
+
+% for the moment:
+
+\def\math_stackers_hacked_fill#1#2#3%
+ {\mathematics
+ {\begingroup
+ \mathsurround\zeropoint
+ \thickmuskip \zeromuskip
+ \medmuskip \zeromuskip
+ \thinmuskip \zeromuskip
+ #1%
+ \mkern-7\onemuskip
+ \cleaders\mathstylehbox{\mkern-2\onemuskip#2\mkern-2\onemuskip}\hfill
+ \mkern-7\onemuskip
+ #3%
+ \endgroup}}
+
+% These will be defined in char-def as well once we have \leaders
+
+\immutable\protected\def\rightarrowfill {\math_stackers_hacked_fill \relbar \relbar \rightarrow}
+\immutable\protected\def\leftarrowfill {\math_stackers_hacked_fill \leftarrow \relbar \relbar }
+\immutable\protected\def\rightoverleftarrowfill{\math_stackers_hacked_fill \ctxdoublearrowfillleftend\ctxdoublearrowfillmiddlepart\ctxdoublearrowfillrightend}
+\immutable\protected\def\equalfill {\math_stackers_hacked_fill \Relbar \Relbar \Relbar}
+\immutable\protected\def\Rightarrowfill {\math_stackers_hacked_fill \Relbar \Relbar \Rightarrow}
+\immutable\protected\def\Leftarrowfill {\math_stackers_hacked_fill \Leftarrow \Relbar \Relbar}
+\immutable\protected\def\Leftrightarrowfill {\math_stackers_hacked_fill \Leftarrow \Relbar \Rightarrow}
+\immutable\protected\def\leftrightarrowfill {\math_stackers_hacked_fill \leftarrow \relbar \rightarrow}
+\immutable\protected\def\mapstofill {\math_stackers_hacked_fill{\mapstochar\relbar} \relbar \rightarrow}
+\immutable\protected\def\twoheadrightarrowfill {\math_stackers_hacked_fill \relbar \relbar \twoheadrightarrow}
+\immutable\protected\def\twoheadleftarrowfill {\math_stackers_hacked_fill \twoheadleftarrow \relbar \relbar}
+\immutable\protected\def\rightharpoondownfill {\math_stackers_hacked_fill \relbar \relbar \rightharpoondown}
+\immutable\protected\def\rightharpoonupfill {\math_stackers_hacked_fill \relbar \relbar \rightharpoonup}
+\immutable\protected\def\leftharpoondownfill {\math_stackers_hacked_fill \leftharpoondown \relbar \relbar}
+\immutable\protected\def\leftharpoonupfill {\math_stackers_hacked_fill \leftharpoonup \relbar \relbar}
+\immutable\protected\def\hookleftfill {\math_stackers_hacked_fill \leftarrow \relbar {\relbar\joinrel\rhook}}
+\immutable\protected\def\hookrightfill {\math_stackers_hacked_fill{\lhook\joinrel\relbar} \relbar \rightarrow}
+\immutable\protected\def\relfill {\math_stackers_hacked_fill \relbar \relbar \relbar}
+\immutable\protected\def\triplerelfill {\math_stackers_hacked_fill \equiv \equiv \equiv}
+
+% \permanent\protected\def\singlebond{{\xrel}} % or \def\singlebond{{\xrel[2]}}
+% \permanent\protected\def\doublebond{{\xequal}}
+% \permanent\protected\def\triplebond{{\xtriplerel}}
+
+%D For the moment (needs checking):
+
+\permanent\tolerant\protected\def\defineextensiblefiller[#1]#*[#2]%
+ {\immutable\letcsname\??mathextensiblefallbacks\number#2\expandafter\endcsname\csname#1\endcsname
+ %\immutable\letcsname#1\expandafter\endcsname\csname#1\endcsname
+ } % huh?
+
+%defineextensiblefiller [barfill] ["203E] % yet undefined
+\defineextensiblefiller [relfill] ["002D]
+\defineextensiblefiller [equalfill] ["003D]
+\defineextensiblefiller [leftarrowfill] ["2190]
+\defineextensiblefiller [rightarrowfill] ["2192]
+\defineextensiblefiller [twoheadleftarrowfill] ["219E]
+\defineextensiblefiller [twoheadrightarrowfill] ["21A0]
+\defineextensiblefiller [mapstofill] ["21A6]
+%defineextensiblefiller [hookleftarrowfill] ["21A9]
+%defineextensiblefiller [hookrightarrowfill] ["21AA]
+\defineextensiblefiller [leftharpoondownfill] ["21BD]
+\defineextensiblefiller [leftharpoonupfill] ["21BC]
+\defineextensiblefiller [rightharpoondownfill] ["21C1]
+\defineextensiblefiller [rightharpoonupfill] ["21C0]
+\defineextensiblefiller [rightoverleftarrowfill] ["21C4]
+%defineextensiblefiller [leftrightharpoonsfill] ["21CB] % yet undefined
+%defineextensiblefiller [rightleftharpoonsfill] ["21CC] % yet undefined
+\defineextensiblefiller [triplerelfill] ["2261]
+\defineextensiblefiller [leftrightarrowfill] ["27F7]
+\defineextensiblefiller [Leftarrowfill] ["27F8]
+\defineextensiblefiller [Rightarrowfill] ["27F9]
+\defineextensiblefiller [Leftrightarrowfill] ["27FA]
+%\defineextensiblefiller[Rightleftarrowfill] [.....]
+
+% These are fishy ... we need to check this because now these commands relax (there
+% are some entries in char-def.)
+%
+% %definemathoverextensible [overbarfill] ["FE33E]
+% %definemathunderextensible [underbarfill] ["FE33F]
+% \definemathoverextensible [overbracefill] ["FE3DE]
+% \definemathunderextensible [underbracefill] ["FE3DF]
+% \definemathoverextensible [overparentfill] ["FE3DC]
+% \definemathunderextensible [underparentfill] ["FE3DD]
+% \definemathoverextensible [overbracketfill] ["FE3B4]
+% \definemathunderextensible [underbracketfill] ["FE3B5]
+%
+% %defineextensiblefiller [overbarfill] ["FE33E]
+% %defineextensiblefiller [underbarfill] ["FE33F]
+% \defineextensiblefiller [overbracefill] ["FE3DE]
+% \defineextensiblefiller [underbracefill] ["FE3DF]
+% \defineextensiblefiller [overparentfill] ["FE3DC]
+% \defineextensiblefiller [underparentfill] ["FE3DD]
+% \defineextensiblefiller [overbracketfill] ["FE3B4]
+% \defineextensiblefiller [underbracketfill] ["FE3B5]
+
+%D Extra:
+
+\permanent\protected\edef\singlebond{\mathematics{\mathsurround\zeropoint\char\number"002D\relax}}
+\permanent\protected\edef\doublebond{\mathematics{\mathsurround\zeropoint\char\number"003D\relax}}
+\permanent\protected\edef\triplebond{\mathematics{\mathsurround\zeropoint\char\number"2261\relax}}
+
+% \mathchardef\singlebond"002D
+% \mathchardef\doublebond"003D
+% \mathchardef\triplebond"2261
+
+%D Also handy:
+
+\permanent\tolerant\protected\def\definemathunstacked[#1]#*[#2]#*[#3]% category name unicode
+ {\ifarguments\or\or
+ \frozen\setuevalue{#1}{\math_stackers_unstacked_normal\noexpand\currentmathstackers{\number#2}}%
+ \else
+ \frozen\setuevalue{#2}{\math_stackers_unstacked_normal{#1}{\number#3}}%
+ \fi}
+
+\protected\def\math_stackers_unstacked_normal#category#codepoint%
+ {\begingroup
+ \edef\currentmathstackers{#category}%
+ \edef\p_moffset{\mathstackersparameter\c!moffset}%
+ \ifempty\p_moffset \else
+ \mskip\p_moffset\relax
+ \fi
+ \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
+ {\usemathstackerscolorparameter\c!color
+ \Umathchar\zerocount\defaultmathfamily#codepoint}%
+ \ifempty\p_moffset \else
+ \mskip\p_moffset\relax
+ \fi
+ \endgroup}
+
+\definemathstackers [\v!wide] [\c!moffset=\thickmuskip,\c!mathclass=\s!rel]
+
+\definemathunstacked [\v!wide] [And] ["0026] % \mathrel{\;&\;}
+\definemathunstacked [\v!wide] [impliedby] ["27F8] % \mathrel{\;\Longleftarrow\;}
+\definemathunstacked [\v!wide] [implies] ["27F9] % \mathrel{\;\Longrightarrow\;}
+\definemathunstacked [\v!wide] [iff] ["27FA] % \mathrel{\;\Longleftrightarrow\;}
+
+% New (an example of using \mathexheight):
+
+\definemathstackers
+ [\v!symbol]
+ [\c!voffset=-.3\mathexheight,
+ \c!hoffset=\zeropoint,
+ \c!mathclass=ord,
+ \c!topoffset=.4\mathemwidth, % poor man's italic correction
+ \c!middlecommand=\mathematics]
+
+\definemathover[\v!symbol][interiorset]["2218]
+
+\protect \endinput
+
+% \mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}
+% \limits\normalsuperscript{\box0}\normalsubscript{\box2}}%
+
+% $\Uoverdelimiter \defaultmathfamily "2194 {xxxx}$
+% $\Uunderdelimiter\defaultmathfamily "2194 {xxxx}$
+% $\Udelimiterover \defaultmathfamily "2194 {xxxx}$
+% $\Udelimiterunder\defaultmathfamily "2194 {xxxx}$
+% $\Udelimiterover \defaultmathfamily "219A {\Udelimiterunder \defaultmathfamily "219B {xxxx}}$
+
+% $a \mathrel{\mathop{\filledhboxr{mid}}}\limits^{\filledhboxg{\strut top}}_{\filledhboxb{\strut bottom}} b$
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-tag.lmt b/Master/texmf-dist/tex/context/base/mkxl/math-tag.lmt
new file mode 100644
index 00000000000..eb58b5450d5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-tag.lmt
@@ -0,0 +1,596 @@
+if not modules then modules = { } end modules ['math-tag'] = {
+ version = 1.001,
+ comment = "companion to math-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- todo: have a local list with local tags that then get appended
+-- todo: use tex.getmathcodes (no table)
+
+-- use lpeg matchers
+
+local find, match = string.find, string.match
+local insert, remove, concat = table.insert, table.remove, table.concat
+
+local attributes = attributes
+local nodes = nodes
+
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+
+local getnext = nuts.getnext
+local getid = nuts.getid
+local getchar = nuts.getchar
+local getfont = nuts.getfont
+local getlist = nuts.getlist
+local getfield = nuts.getfield
+local getdisc = nuts.getdisc
+local getsubtype = nuts.getsubtype
+local getattr = nuts.getattr
+local getattrlist = nuts.getattrlist
+local setattr = nuts.setattr
+----- getcomponents = nuts.getcomponents -- not really needed
+local getwidth = nuts.getwidth
+
+local getnucleus = nuts.getnucleus
+local getsub = nuts.getsub
+local getsup = nuts.getsup
+
+local set_attributes = nuts.setattributes
+
+local nextnode = nuts.traversers.node
+
+local nodecodes = nodes.nodecodes
+
+local noad_code = nodecodes.noad -- attr nucleus sub sup
+local accent_code = nodecodes.accent -- attr nucleus sub sup accent
+local radical_code = nodecodes.radical -- attr nucleus sub sup left degree
+local fraction_code = nodecodes.fraction -- attr nucleus sub sup left right
+local subbox_code = nodecodes.subbox -- attr list
+local submlist_code = nodecodes.submlist -- attr list
+local mathchar_code = nodecodes.mathchar -- attr fam char
+local mathtextchar_code = nodecodes.mathtextchar -- attr fam char
+local delimiter_code = nodecodes.delimiter -- attr small_fam small_char large_fam large_char
+local style_code = nodecodes.style -- attr style
+local choice_code = nodecodes.choice -- attr display text script scriptscript
+local fence_code = nodecodes.fence -- attr subtype
+
+local accentcodes = nodes.accentcodes
+local fencecodes = nodes.fencecodes
+
+local fixedtopaccent_code = accentcodes.fixedtop
+local fixedbottomaccent_code = accentcodes.fixedbottom
+local fixedbothaccent_code = accentcodes.fixedboth
+
+local leftfence_code = fencecodes.left
+local middlefence_code = fencecodes.middle
+local rightfence_code = fencecodes.right
+
+local kerncodes = nodes.kerncodes
+
+local fontkern_code = kerncodes.fontkern
+local italickern_code = kerncodes.italickern
+
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glyph_code = nodecodes.glyph
+local disc_code = nodecodes.disc
+local glue_code = nodecodes.glue
+local kern_code = nodecodes.kern
+local math_code = nodecodes.math
+
+local processnoads = noads.process
+
+local a_tagged = attributes.private('tagged')
+local a_mathcategory = attributes.private('mathcategory')
+local a_mathmode = attributes.private('mathmode')
+
+local tags = structures.tags
+
+local start_tagged = tags.start
+local restart_tagged = tags.restart
+local stop_tagged = tags.stop
+local taglist = tags.taglist
+
+local chardata = characters.data
+
+local getmathcodes = tex.getmathcodes
+local mathcodes = mathematics.codes
+local ordinary_mathcode = mathcodes.ordinary
+local variable_mathcode = mathcodes.variable
+
+local fromunicode16 = fonts.mappings.fromunicode16
+local fontcharacters = fonts.hashes.characters
+
+local report_tags = logs.reporter("structure","tags")
+
+local process
+
+local function processsubsup(start)
+ -- At some point we might need to add an attribute signaling the
+ -- super- and subscripts because TeX and MathML use a different
+ -- order. The mrows are needed to keep mn's separated.
+ local nucleus = getnucleus(start)
+ local sup = getsup(start)
+ local sub = getsub(start)
+ if sub then
+ if sup then
+ setattr(start,a_tagged,start_tagged("msubsup"))
+ -- start_tagged("mrow")
+ process(nucleus)
+ -- stop_tagged()
+ start_tagged("mrow", { subscript = true })
+ process(sub)
+ stop_tagged()
+ start_tagged("mrow", { superscript = true })
+ process(sup)
+ stop_tagged()
+ stop_tagged()
+ else
+ setattr(start,a_tagged,start_tagged("msub"))
+ -- start_tagged("mrow")
+ process(nucleus)
+ -- stop_tagged()
+ start_tagged("mrow")
+ process(sub)
+ stop_tagged()
+ stop_tagged()
+ end
+ elseif sup then
+ setattr(start,a_tagged,start_tagged("msup"))
+ -- start_tagged("mrow")
+ process(nucleus)
+ -- stop_tagged()
+ start_tagged("mrow")
+ process(sup)
+ stop_tagged()
+ stop_tagged()
+ else
+ process(nucleus)
+ end
+end
+
+-- todo: check function here and keep attribute the same
+
+-- todo: variants -> original
+
+local actionstack = { }
+local fencesstack = { }
+
+-- glyph nodes and such can happen in under and over stuff
+
+-- local function getunicode(n) -- instead of getchar
+-- local char = getchar(n)
+-- -- local font = getfontoffamily(getfield(n,"fam"))
+-- local font = getfont(n)
+-- local data = fontcharacters[font][char]
+-- return data.unicode or char
+-- end
+
+local function getunicode(n) -- instead of getchar
+ -- local char, font = isglyph(n) -- no, we have a mathchar
+ local char, font = getchar(n), getfont(n)
+ local data = fontcharacters[font][char]
+ return data.unicode or char -- can be a table but unlikely for math characters
+end
+
+-------------------
+
+local content = { }
+local found = false
+
+content[mathchar_code] = function() found = true end
+
+local function hascontent(head)
+ found = false
+ processnoads(head,content,"content")
+ return found
+end
+
+--------------------
+
+-- todo: use properties
+
+-- local function showtag(n,id,old)
+-- local attr = getattr(n,a_tagged)
+-- local curr = tags.current()
+-- report_tags("%s, node %s, attr %s:%s (%s), top %s (%s)",
+-- old and "before" or "after ",
+-- nodecodes[id],
+-- getattrlist(n),
+-- attr or "?",attr and taglist[attr].tagname or "?",
+-- curr or "?",curr and taglist[curr].tagname or "?"
+-- )
+-- end
+
+process = function(start) -- we cannot use the processor as we have no finalizers (yet)
+ local mtexttag = nil
+ while start do
+ local id = getid(start)
+-- showtag(start,id,true)
+ if id == glyph_code or id == disc_code then
+ if not mtexttag then
+ mtexttag = start_tagged("mtext")
+ end
+ setattr(start,a_tagged,mtexttag)
+ elseif mtexttag and id == kern_code and (getsubtype(start) == fontkern_code or getsubtype(start) == italickern_code) then -- italickern
+ setattr(start,a_tagged,mtexttag)
+ else
+ if mtexttag then
+ stop_tagged()
+ mtexttag = nil
+ end
+ if id == mathchar_code then
+ local char = getchar(start)
+ local code = getmathcodes(char)
+ local tag
+ if code == ordinary_mathcode or code == variable_mathcode then
+ local ch = chardata[char]
+ local mc = ch and ch.mathclass
+ if mc == "number" then
+ tag = "mn"
+ elseif mc == "variable" or not mc then -- variable is default
+ tag = "mi"
+ else
+ tag = "mo"
+ end
+ else
+ tag = "mo"
+ end
+ local a = getattr(start,a_mathcategory)
+ if a then
+ setattr(start,a_tagged,start_tagged(tag,{ mathcategory = a }))
+ else
+ setattr(start,a_tagged,start_tagged(tag)) -- todo: a_mathcategory
+ end
+ stop_tagged()
+ -- showtag(start,id,false)
+ break -- okay?
+ elseif id == mathtextchar_code then -- or id == glyph_code
+ -- check for code
+ local a = getattr(start,a_mathcategory)
+ if a then
+ setattr(start,a_tagged,start_tagged("ms",{ mathcategory = a })) -- mtext
+ else
+ setattr(start,a_tagged,start_tagged("ms")) -- mtext
+ end
+ stop_tagged()
+ -- showtag(start,id,false)
+ break
+ elseif id == delimiter_code then
+ -- check for code
+ setattr(start,a_tagged,start_tagged("mo"))
+ stop_tagged()
+ -- showtag(start,id,false)
+ break
+ elseif id == style_code then
+ -- has a next
+ elseif id == noad_code then
+ -- setattr(start,a_tagged,tags.current())
+ processsubsup(start)
+ elseif id == subbox_code or id == hlist_code or id == vlist_code then
+ -- keep an eye on subbox_code and see what ends up in there
+ local attr = getattr(start,a_tagged)
+ if not attr then
+ -- just skip
+ else
+ local specification = taglist[attr]
+ if specification then
+ local tag = specification.tagname
+ if tag == "formulacaption" then
+ -- skip
+ elseif tag == "mstacker" then
+ local list = getlist(start)
+ if list then
+ process(list)
+ end
+ else
+ if tag ~= "mstackertop" and tag ~= "mstackermid" and tag ~= "mstackerbot" then
+ tag = "mtext"
+ end
+ local text = start_tagged(tag)
+ setattr(start,a_tagged,text)
+ local list = getlist(start)
+ if not list then
+ -- empty list
+ elseif not attr then
+ -- box comes from strange place
+ set_attributes(list,a_tagged,text) -- only the first node ?
+ else
+ -- Beware, the first node in list is the actual list so we definitely
+ -- need to nest. This approach is a hack, maybe I'll make a proper
+ -- nesting feature to deal with this at another level. Here we just
+ -- fake structure by enforcing the inner one.
+ --
+ -- todo: have a local list with local tags that then get appended
+ --
+ local tagdata = specification.taglist
+ local common = #tagdata + 1
+ local function runner(list,depth) -- quite inefficient
+ local cache = { } -- we can have nested unboxed mess so best local to runner
+ local keep = nil
+ -- local keep = { } -- win case we might need to move keep outside
+ for n, id, subtype in nextnode, list do
+ local mth = id == math_code and subtype
+ if mth == 0 then -- hm left_code
+ -- insert(keep,text)
+ keep = text
+ text = start_tagged("mrow")
+ common = common + 1
+ end
+ local aa = getattr(n,a_tagged)
+ if aa then
+ local ac = cache[aa]
+ if not ac then
+ local tagdata = taglist[aa].taglist
+ local extra = #tagdata
+ if common <= extra then
+ for i=common,extra do
+ ac = restart_tagged(tagdata[i]) -- can be made faster
+ end
+ for i=common,extra do
+ stop_tagged() -- can be made faster
+ end
+ else
+ ac = text
+ end
+ cache[aa] = ac
+ end
+ setattr(n,a_tagged,ac)
+ else
+ setattr(n,a_tagged,text)
+ end
+ if id == hlist_code or id == vlist_code then
+ runner(getlist(n),depth+1)
+ elseif id == glyph_code then
+ -- this should not be needed
+ -- local components = getcomponents(n) -- unlikely set
+ -- if components then
+ -- runner(getcomponent,depth+1)
+ -- end
+ elseif id == disc_code then
+ -- this should not be needed
+ local pre, post, replace = getdisc(n)
+ if pre then
+ runner(pre,depth+1)
+ end
+ if post then
+ runner(post,depth+1)
+ end
+ if replace then
+ runner(replace,depth+1)
+ end
+ end
+ if mth == 1 then
+ stop_tagged()
+ -- text = remove(keep)
+ text = keep
+ common = common - 1
+ end
+ end
+ end
+ runner(list,0)
+ end
+ stop_tagged()
+ end
+ end
+ end
+ elseif id == submlist_code then -- normally a hbox
+ local list = getlist(start)
+ if list then
+ local attr = getattr(start,a_tagged)
+ local last = attr and taglist[attr]
+ if last then
+ local tag = last.tagname
+ local detail = last.detail
+ if tag == "maction" then
+ if detail == "" then
+ setattr(start,a_tagged,start_tagged("mrow"))
+ process(list)
+ stop_tagged()
+ elseif actionstack[#actionstack] == action then
+ setattr(start,a_tagged,start_tagged("mrow"))
+ process(list)
+ stop_tagged()
+ else
+ insert(actionstack,action)
+ setattr(start,a_tagged,start_tagged("mrow",{ detail = action }))
+ process(list)
+ stop_tagged()
+ remove(actionstack)
+ end
+ elseif tag == "mstacker" then -- or tag == "mstackertop" or tag == "mstackermid" or tag == "mstackerbot" then
+ -- looks like it gets processed twice
+ -- do we still end up here ?
+ setattr(start,a_tagged,restart_tagged(attr)) -- so we just reuse the attribute
+ process(list)
+ stop_tagged()
+ else
+ setattr(start,a_tagged,start_tagged("mrow"))
+ process(list)
+ stop_tagged()
+ end
+ else -- never happens, we're always document
+ setattr(start,a_tagged,start_tagged("mrow"))
+ process(list)
+ stop_tagged()
+ end
+ end
+ elseif id == fraction_code then
+ local num = getfield(start,"num")
+ local denom = getfield(start,"denom")
+ local left = getfield(start,"left")
+ local right = getfield(start,"right")
+ if left then
+ setattr(left,a_tagged,start_tagged("mo"))
+ process(left)
+ stop_tagged()
+ end
+ setattr(start,a_tagged,start_tagged("mfrac"))
+ process(num)
+ process(denom)
+ stop_tagged()
+ if right then
+ setattr(right,a_tagged,start_tagged("mo"))
+ process(right)
+ stop_tagged()
+ end
+ elseif id == choice_code then
+ local display = getfield(start,"display")
+ local text = getfield(start,"text")
+ local script = getfield(start,"script")
+ local scriptscript = getfield(start,"scriptscript")
+ if display then
+ process(display)
+ end
+ if text then
+ process(text)
+ end
+ if script then
+ process(script)
+ end
+ if scriptscript then
+ process(scriptscript)
+ end
+ elseif id == fence_code then
+ local subtype = getsubtype(start)
+ local delim = getfield(start,"delimiter")
+ if subtype == leftfence_code then
+ -- left
+ local properties = { }
+ insert(fencesstack,properties)
+ setattr(start,a_tagged,start_tagged("mfenced",properties)) -- needs checking
+ if delim then
+ start_tagged("ignore")
+ local chr = getchar(delim)
+ if chr ~= 0 then
+ properties.left = chr
+ end
+ process(delim)
+ stop_tagged()
+ end
+ start_tagged("mrow") -- begin of subsequence
+ elseif subtype == middlefence_code then
+ -- middle
+ if delim then
+ start_tagged("ignore")
+ local top = fencesstack[#fencesstack]
+ local chr = getchar(delim)
+ if chr ~= 0 then
+ local mid = top.middle
+ if mid then
+ mid[#mid+1] = chr
+ else
+ top.middle = { chr }
+ end
+ end
+ process(delim)
+ stop_tagged()
+ end
+ stop_tagged() -- end of subsequence
+ start_tagged("mrow") -- begin of subsequence
+ elseif subtype == rightfence_code then
+ local properties = remove(fencesstack)
+ if not properties then
+ report_tags("missing right fence")
+ properties = { }
+ end
+ if delim then
+ start_tagged("ignore")
+ local chr = getchar(delim)
+ if chr ~= 0 then
+ properties.right = chr
+ end
+ process(delim)
+ stop_tagged()
+ end
+ stop_tagged() -- end of subsequence
+ stop_tagged()
+ else
+ -- can't happen
+ end
+ elseif id == radical_code then
+ local left = getfield(start,"left")
+ local degree = getfield(start,"degree")
+ if left then
+ start_tagged("ignore")
+ process(left) -- root symbol, ignored
+ stop_tagged()
+ end
+ if degree and hascontent(degree) then
+ setattr(start,a_tagged,start_tagged("mroot"))
+ processsubsup(start)
+ process(degree)
+ stop_tagged()
+ else
+ setattr(start,a_tagged,start_tagged("msqrt"))
+ processsubsup(start)
+ stop_tagged()
+ end
+ elseif id == accent_code then
+ local subtype = getsubtype(start)
+ local accent = getfield(start,"accent")
+ local bot_accent = getfield(start,"bot_accent")
+ if bot_accent then
+ if accent then
+ setattr(start,a_tagged,start_tagged("munderover", {
+ accent = true,
+ top = getunicode(accent),
+ bottom = getunicode(bot_accent),
+ topfixed = subtype == fixedtopaccent_code or subtype == fixedbothaccent_code,
+ bottomfixed = subtype == fixedbottomaccent_code or subtype == fixedbothaccent_code,
+ }))
+ processsubsup(start)
+ process(bot_accent)
+ process(accent)
+ stop_tagged()
+ else
+ setattr(start,a_tagged,start_tagged("munder", {
+ accent = true,
+ bottom = getunicode(bot_accent),
+ bottomfixed = subtype == fixedbottomaccent_code or subtype == fixedbothaccent_code,
+ }))
+ processsubsup(start)
+ process(bot_accent)
+ stop_tagged()
+ end
+ elseif accent then
+ setattr(start,a_tagged,start_tagged("mover", {
+ accent = true,
+ top = getunicode(accent),
+ topfixed = subtype == fixedtopaccent_code or subtype == fixedbothaccent_code,
+ }))
+ processsubsup(start)
+ process(accent)
+ stop_tagged()
+ else
+ processsubsup(start)
+ end
+ elseif id == glue_code then
+ -- setattr(start,a_tagged,start_tagged("mspace",{ width = getwidth(start) }))
+ setattr(start,a_tagged,start_tagged("mspace"))
+ stop_tagged()
+ else
+ setattr(start,a_tagged,start_tagged("merror", { detail = nodecodes[i] }))
+ stop_tagged()
+ end
+ end
+-- showtag(start,id,false)
+ start = getnext(start)
+ end
+ if mtexttag then
+ stop_tagged()
+ end
+end
+
+function noads.handlers.tags(head,style,penalties)
+ start_tagged("math", { mode = (getattr(head,a_mathmode) == 1) and "display" or "inline" })
+ setattr(head,a_tagged,start_tagged("mrow"))
+-- showtag(head,getid(head),true)
+ process(head)
+-- showtag(head,getid(head),false)
+ stop_tagged()
+ stop_tagged()
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-toy.mkxl b/Master/texmf-dist/tex/context/base/mkxl/math-toy.mkxl
new file mode 100644
index 00000000000..510872e3b62
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-toy.mkxl
@@ -0,0 +1,54 @@
+%D \module
+%D [ file=math-toy,
+%D version=2020.08.31,
+%D title=\CONTEXT\ Math Macros,
+%D subtitle=Toy math,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Math Macros / Toy}
+
+\unprotect
+
+%D Just an example:
+%D
+%D \starttyping
+%D \enabletrackers[math.toysymbol]
+%D
+%D \definemathtoysymbol[Plus] [bin][+]
+%D \definemathtoysymbol[Minus][bin][-]
+%D \definemathtoysymbol[Equal][rel][=]
+%D
+%D $\dorecurse{199}{x_{#1} \ifodd#1\relax\Plus\else\Minus\fi} x_{200} \Equal n$ \blank
+%D \stoptyping
+
+\permanent\tolerant\protected\def\definemathtoysymbol[#1]#*[#2]#*[#3]%
+ {\ifarguments\or\or\or
+ \setuevalue{#1}{\math_toy_define_symbol_indeed{\mathcodechecked{#2}}{#3}}%
+ \fi}
+
+\protected\def\math_toy_define_symbol_traced#1#2%
+ {\normalexpanded{\discretionary class #1 %
+ {$\Ustyle\number\mathstyle \darkred #2$}%
+ {$\Ustyle\number\mathstyle \darkblue #2$}%
+ {$\Ustyle\number\mathstyle \darkgreen #2$}}}
+
+\protected\def\math_toy_define_symbol_normal#1#2%
+ {\normalexpanded{\discretionary class #1 %
+ {$\Ustyle\number\mathstyle #2$}%
+ {$\Ustyle\number\mathstyle #2$}%
+ {$\Ustyle\number\mathstyle #2$}}}
+
+\installtextracker
+ {math.toysymbol}
+ {\let\math_toy_define_symbol_indeed\math_toy_define_symbol_traced}
+ {\let\math_toy_define_symbol_indeed\math_toy_define_symbol_normal}
+
+\let\math_toy_define_symbol_indeed\math_toy_define_symbol_normal
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/math-vfu.lmt b/Master/texmf-dist/tex/context/base/mkxl/math-vfu.lmt
new file mode 100644
index 00000000000..6584b0158d5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/math-vfu.lmt
@@ -0,0 +1,1153 @@
+if not modules then modules = { } end modules ['math-vfu'] = {
+ version = 1.001,
+ comment = "companion to math-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- All these math vectors .. thanks to Aditya and Mojca they become better and
+-- better. If you have problems with math fonts or miss characters report it to the
+-- ConTeXt mailing list. Also thanks to Boguslaw for finding a couple of errors.
+-- This mechanism will eventually disappear.
+
+-- 20D6 -> 2190
+-- 20D7 -> 2192
+
+local type, next, tonumber = type, next, tonumber
+local max = math.max
+local fastcopy = table.copy
+
+local fonts, nodes, mathematics = fonts, nodes, mathematics
+
+local trace_virtual = false trackers.register("math.virtual", function(v) trace_virtual = v end)
+local trace_timings = false trackers.register("math.timings", function(v) trace_timings = v end)
+
+local add_optional = false directives.register("math.virtual.optional",function(v) add_optional = v end)
+
+local report_virtual = logs.reporter("fonts","virtual math")
+
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local chardata = characters.data
+
+local mathencodings = allocate()
+fonts.encodings.math = mathencodings -- better is then: fonts.encodings.vectors
+local vfmath = allocate()
+fonts.handlers.vf.math = vfmath
+
+local helpers = fonts.helpers
+local vfcommands = helpers.commands
+local rightcommand = vfcommands.right
+local leftcommand = vfcommands.left
+local downcommand = vfcommands.down
+local upcommand = vfcommands.up
+local push = vfcommands.push
+local pop = vfcommands.pop
+
+local shared = { }
+
+-- local back = { "slot", 1, 0x2215 }
+--
+-- local function negate(main,characters,id,size,unicode,basecode)
+-- if not characters[unicode] then
+-- local basechar = characters[basecode]
+-- if basechar then
+-- local ht, wd = basechar.height, basechar.width
+-- characters[unicode] = {
+-- width = wd,
+-- height = ht,
+-- depth = basechar.depth,
+-- italic = basechar.italic,
+-- kerns = basechar.kerns,
+-- commands = {
+-- { "slot", 1, basecode },
+-- push,
+-- downcommand[ht/5],
+-- leftcommand[wd/2],
+-- back,
+-- push,
+-- }
+-- }
+-- end
+-- end
+-- end
+--
+-- \Umathchardef\braceld="0 "1 "FF07A
+-- \Umathchardef\bracerd="0 "1 "FF07B
+-- \Umathchardef\bracelu="0 "1 "FF07C
+-- \Umathchardef\braceru="0 "1 "FF07D
+
+local function brace(main,characters,id,size,unicode,first,rule,left,right,rule,last)
+ if not characters[unicode] then
+ characters[unicode] = {
+ horiz_variants = {
+ { extender = 0, glyph = first },
+ { extender = 1, glyph = rule },
+ { extender = 0, glyph = left },
+ { extender = 0, glyph = right },
+ { extender = 1, glyph = rule },
+ { extender = 0, glyph = last },
+ }
+ }
+ end
+end
+
+local function extension(main,characters,id,size,unicode,first,middle,last)
+ local chr = characters[unicode]
+ if not chr then
+ return -- skip
+ end
+ local fw = characters[first]
+ if not fw then
+ return
+ end
+ local mw = characters[middle]
+ if not mw then
+ return
+ end
+ local lw = characters[last]
+ if not lw then
+ return
+ end
+ fw = fw.width
+ mw = mw.width
+ lw = lw.width
+ if fw == 0 then
+ fw = 1
+ end
+ if lw == 0 then
+ lw = 1
+ end
+ chr.horiz_variants = {
+ { extender = 0, glyph = first, ["end"] = fw/2, start = 0, advance = fw },
+ { extender = 1, glyph = middle, ["end"] = mw/2, start = mw/2, advance = mw },
+ { extender = 0, glyph = last, ["end"] = 0, start = lw/2, advance = lw },
+ }
+end
+
+local function parent(main,characters,id,size,unicode,first,rule,last)
+ if not characters[unicode] then
+ characters[unicode] = {
+ horiz_variants = {
+ { extender = 0, glyph = first },
+ { extender = 1, glyph = rule },
+ { extender = 0, glyph = last },
+ }
+ }
+ end
+end
+
+local step = 0.2 -- 0.1 is nicer but gives larger files
+
+local function make(main,characters,id,size,n,m)
+ local old = 0xFF000 + n
+ local c = characters[old]
+ if c then
+ local upslot = 0xFF100 + n
+ local dnslot = 0xFF200 + n
+ local uprule = 0xFF300 + m
+ local dnrule = 0xFF400 + m
+ local xu = main.parameters.x_height + 0.3*size
+ local xd = 0.3*size
+ local w = c.width or 0
+ local h = c.height or 0
+ local d = c.depth or 0
+ local thickness = h - d
+ local rulewidth = step*size -- we could use an overlap
+ local slot = { "slot", id, old }
+ local rule = { "rule", thickness, rulewidth }
+ local up = upcommand[xu]
+ local dn = downcommand[xd]
+ local ht = xu + 3*thickness
+ local dp = 0
+ if not characters[uprule] then
+ characters[uprule] = {
+ width = rulewidth,
+ height = ht,
+ depth = dp,
+ commands = { push, up, rule, pop },
+ }
+ end
+ characters[upslot] = {
+ width = w,
+ height = ht,
+ depth = dp,
+ commands = { push, up, slot, pop },
+ }
+ local ht = 0
+ local dp = xd + 3*thickness
+ if not characters[dnrule] then
+ characters[dnrule] = {
+ width = rulewidth,
+ height = ht,
+ depth = dp,
+ commands = { push, dn, rule, pop }
+ }
+ end
+ characters[dnslot] = {
+ width = w,
+ height = ht,
+ depth = dp,
+ commands = { push, dn, slot, pop },
+ }
+ end
+end
+
+local function clipped(main,characters,id,size,unicode,original) -- push/pop needed?
+ local minus = characters[original]
+ if minus then
+ local mu = size/18
+ local step = 3*mu
+ local width = minus.width
+ if width > step then
+ width = width - step
+ step = step / 2
+ else
+ width = width / 2
+ step = width
+ end
+ characters[unicode] = {
+ width = width,
+ height = minus.height,
+ depth = minus.depth,
+ commands = {
+ push,
+ leftcommand[step],
+ { "slot", id, original },
+ pop,
+ }
+ }
+ end
+end
+
+local function raise(main,characters,id,size,unicode,private,n,id_of_smaller) -- this is a real fake mess
+ local raised = fonts.hashes.characters[main.fonts[id_of_smaller].id][private] -- characters[private]
+ if raised then
+ local up = 0.85 * main.parameters.x_height
+ local slot = { "slot", id_of_smaller, private }
+ local commands = {
+ push, upcommand[up], slot,
+ }
+ for i=2,n do
+ commands[#commands+1] = slot
+ end
+ commands[#commands+1] = pop
+ characters[unicode] = {
+ width = n * raised.width,
+ height = (raised.height or 0) + up,
+ depth = (raised.depth or 0) - up,
+ italic = raised.italic,
+ commands = commands,
+ }
+ end
+end
+
+local function dots(main,characters,id,size,unicode)
+ local c = characters[0x002E]
+ if c then
+ local w = c.width
+ local h = c.height
+ local d = c.depth
+ local mu = size/18
+ local right3mu = rightcommand[3*mu]
+ local right1mu = rightcommand[1*mu]
+ local up1size = upcommand[.1*size]
+ local up4size = upcommand[.4*size]
+ local up7size = upcommand[.7*size]
+ local right2muw = rightcommand[2*mu + w]
+ local slot = { "slot", id, 0x002E }
+ if unicode == 0x22EF then
+ local c = characters[0x022C5]
+ if c then
+ local width = c.width
+ local height = c.height
+ local depth = c.depth
+ local slot = { "slot", id, 0x022C5 }
+ characters[unicode] = {
+ width = 3*width + 2*3*mu,
+ height = height,
+ depth = depth,
+ commands = {
+ push, slot, right3mu, slot, right3mu, slot, pop,
+ }
+ }
+ end
+ elseif unicode == 0x22EE then
+ -- weird height !
+ characters[unicode] = {
+ width = w,
+ height = h+(1.4)*size,
+ depth = 0,
+ commands = {
+ push, push, slot, pop, up4size, push, slot, pop, up4size, slot, pop,
+ }
+ }
+ elseif unicode == 0x22F1 then
+ characters[unicode] = {
+ width = 3*w + 6*size/18,
+ height = 1.5*size,
+ depth = 0,
+ commands = {
+ push,
+ right1mu,
+ push, up7size, slot, pop,
+ right2muw,
+ push, up4size, slot, pop,
+ right2muw,
+ push, up1size, slot, pop,
+ right1mu,
+ pop
+ }
+ }
+ elseif unicode == 0x22F0 then
+ characters[unicode] = {
+ width = 3*w + 6*size/18,
+ height = 1.5*size,
+ depth = 0,
+ commands = {
+ push,
+ right1mu,
+ push, up1size, slot, pop,
+ right2muw,
+ push, up4size, slot, pop,
+ right2muw,
+ push, up7size, slot, pop,
+ right1mu,
+ pop
+ }
+ }
+ else
+ characters[unicode] = {
+ width = 3*w + 2*3*mu,
+ height = h,
+ depth = d,
+ commands = {
+ push, slot, right3mu, slot, right3mu, slot, pop,
+ }
+ }
+ end
+ end
+end
+
+local function vertbar(main,characters,id,size,parent,scale,unicode)
+ local cp = characters[parent]
+ if cp then
+ local sc = scale * size
+ local pc = { "slot", id, parent }
+ characters[unicode] = {
+ width = cp.width,
+ height = cp.height + sc,
+ depth = cp.depth + sc,
+ next = cp.next, -- can be extensible
+ commands = {
+ push, upcommand [sc], pc, pop,
+ push, downcommand[sc], pc, pop,
+ pc,
+ },
+ }
+ cp.next = unicode
+ end
+end
+
+local function jointwo(main,characters,id,size,unicode,u1,d12,u2,what)
+ local c1 = characters[u1]
+ local c2 = characters[u2]
+ if c1 and c2 then
+ local w1 = c1.width
+ local w2 = c2.width
+ local mu = size/18
+ characters[unicode] = {
+ width = w1 + w2 - d12 * mu,
+ height = max(c1.height or 0, c2.height or 0),
+ depth = max(c1.depth or 0, c2.depth or 0),
+ commands = {
+ { "slot", id, u1 },
+ leftcommand[d12*mu],
+ { "slot", id, u2 },
+ },
+ }
+ end
+end
+
+local function jointhree(main,characters,id,size,unicode,u1,d12,u2,d23,u3)
+ local c1 = characters[u1]
+ local c2 = characters[u2]
+ local c3 = characters[u3]
+ if c1 and c2 and c3 then
+ local w1 = c1.width
+ local w2 = c2.width
+ local w3 = c3.width
+ local mu = size/18
+ characters[unicode] = {
+ width = w1 + w2 + w3 - d12*mu - d23*mu,
+ height = max(c1.height or 0, c2.height or 0, c3.height or 0),
+ depth = max(c1.depth or 0, c2.depth or 0, c3.depth or 0),
+ commands = {
+ { "slot", id, u1 },
+ leftcommand[d12*mu],
+ { "slot", id, u2 },
+ leftcommand[d23*mu],
+ { "slot", id, u3 },
+ }
+ }
+ end
+end
+
+local function stack(main,characters,id,size,unicode,u1,d12,u2)
+ local c1 = characters[u1]
+ if not c1 then
+ return
+ end
+ local c2 = characters[u2]
+ if not c2 then
+ return
+ end
+ local w1 = c1.width or 0
+ local h1 = c1.height or 0
+ local d1 = c1.depth or 0
+ local w2 = c2.width or 0
+ local h2 = c2.height or 0
+ local d2 = c2.depth or 0
+ local mu = size/18
+ characters[unicode] = {
+ width = w1,
+ height = h1 + h2 + d12,
+ depth = d1,
+ commands = {
+ { "slot", id, u1 },
+ leftcommand[w1/2 + w2/2],
+ downcommand[-h1 + d2 -d12*mu],
+ { "slot", id, u2 },
+ }
+ }
+end
+
+local function repeated(main,characters,id,size,unicode,u,n,private,fraction) -- math-fbk.lua
+ local c = characters[u]
+ if c then
+ local width = c.width
+ local italic = fraction*width -- c.italic or 0 -- larger ones have funny italics
+ local tc = { "slot", id, u }
+ local tr = leftcommand[italic] -- see hack elsewhere
+ local commands = { }
+ for i=1,n-1 do
+ commands[#commands+1] = tc
+ commands[#commands+1] = tr
+ end
+ commands[#commands+1] = tc
+ local next = c.next
+ if next then
+ repeated(main,characters,id,size,private,next,n,private+1,fraction)
+ next = private
+ end
+ characters[unicode] = {
+ width = width + (n-1)*(width-italic),
+ height = c.height,
+ depth = c.depth,
+ italic = italic,
+ commands = commands,
+ next = next,
+ }
+ end
+end
+
+local function cloned(main,characters,id,size,source,target)
+ local data = characters[source]
+ if data then
+ characters[target] = data
+ return true
+ end
+end
+
+-- we use the fact that context defines the smallest sizes first .. a real dirty and ugly hack
+
+local data_of_smaller = nil
+local size_of_smaller = 0
+
+function vfmath.addmissing(main,id,size)
+
+ local id_of_smaller = nil
+
+ if size < size_of_smaller or size_of_smaller == 0 then
+ data_of_smaller = main.fonts[id]
+ id_of_smaller = id
+ else
+ id_of_smaller = #main.fonts + 1
+ main.fonts[id_of_smaller] = data_of_smaller
+ end
+
+ -- here id is the index in fonts (normally 14 or so) and that slot points to self
+
+ local characters = main.characters
+ local shared = main.shared
+ local variables = main.goodies.mathematics and main.goodies.mathematics.variables or { }
+ local joinrelfactor = variables.joinrelfactor or 3
+
+ for i=0x7A,0x7D do
+ make(main,characters,id,size,i,1)
+ end
+
+ brace (main,characters,id,size,0x23DE,0xFF17A,0xFF301,0xFF17D,0xFF17C,0xFF301,0xFF17B)
+ brace (main,characters,id,size,0x23DF,0xFF27C,0xFF401,0xFF27B,0xFF27A,0xFF401,0xFF27D)
+
+ parent (main,characters,id,size,0x23DC,0xFF17A,0xFF301,0xFF17B)
+ parent (main,characters,id,size,0x23DD,0xFF27C,0xFF401,0xFF27D)
+
+ -- negate (main,characters,id,size,0x2260,0x003D)
+ dots (main,characters,id,size,0x2026) -- ldots
+ dots (main,characters,id,size,0x22EE) -- vdots
+ dots (main,characters,id,size,0x22EF) -- cdots
+ dots (main,characters,id,size,0x22F1) -- ddots
+ dots (main,characters,id,size,0x22F0) -- udots
+
+ vertbar (main,characters,id,size,0x0007C,0.10,0xFF601) -- big : 0.85 bodyfontsize
+ vertbar (main,characters,id,size,0xFF601,0.30,0xFF602) -- Big : 1.15 bodyfontsize
+ vertbar (main,characters,id,size,0xFF602,0.30,0xFF603) -- bigg : 1.45 bodyfontsize
+ vertbar (main,characters,id,size,0xFF603,0.30,0xFF604) -- Bigg : 1.75 bodyfontsize
+ vertbar (main,characters,id,size,0x02016,0.10,0xFF605)
+ vertbar (main,characters,id,size,0xFF605,0.30,0xFF606)
+ vertbar (main,characters,id,size,0xFF606,0.30,0xFF607)
+ vertbar (main,characters,id,size,0xFF607,0.30,0xFF608)
+
+ clipped (main,characters,id,size,0xFF501,0x0002D) -- minus
+ clipped (main,characters,id,size,0xFF502,0x02190) -- lefthead
+ clipped (main,characters,id,size,0xFF503,0x02192) -- righthead
+ clipped (main,characters,id,size,0xFF504,0xFE321) -- mapsto
+ clipped (main,characters,id,size,0xFF505,0xFE322) -- lhook
+ clipped (main,characters,id,size,0xFF506,0xFE323) -- rhook
+ clipped (main,characters,id,size,0xFF507,0xFE324) -- mapsfrom
+ clipped (main,characters,id,size,0xFF508,0x021D0) -- double lefthead
+ clipped (main,characters,id,size,0xFF509,0x021D2) -- double righthead
+ clipped (main,characters,id,size,0xFF50A,0x0003D) -- equal
+ clipped (main,characters,id,size,0xFF50B,0x0219E) -- lefttwohead
+ clipped (main,characters,id,size,0xFF50C,0x021A0) -- righttwohead
+ clipped (main,characters,id,size,0xFF50D,0xFF350) -- lr arrow combi snippet
+ clipped (main,characters,id,size,0xFF50E,0xFF351) -- lr arrow combi snippet
+ clipped (main,characters,id,size,0xFF50F,0xFF352) -- lr arrow combi snippet
+ clipped (main,characters,id,size,0xFF510,0x02261) -- equiv
+
+ extension(main,characters,id,size,0x2190,0xFF502,0xFF501,0xFF501) -- \leftarrow
+ extension(main,characters,id,size,0x2192,0xFF501,0xFF501,0xFF503) -- \rightarrow
+
+ extension(main,characters,id,size,0x002D,0xFF501,0xFF501,0xFF501) -- \rel
+ extension(main,characters,id,size,0x003D,0xFF50A,0xFF50A,0xFF50A) -- \equal
+ extension(main,characters,id,size,0x2261,0xFF510,0xFF510,0xFF510) -- \equiv
+
+ jointwo (main,characters,id,size,0x21A6,0xFE321,0,0x02192) -- \mapstochar\rightarrow
+ jointwo (main,characters,id,size,0x21A9,0x02190,joinrelfactor,0xFE323) -- \leftarrow\joinrel\rhook
+ jointwo (main,characters,id,size,0x21AA,0xFE322,joinrelfactor,0x02192) -- \lhook\joinrel\rightarrow
+ jointwo (main,characters,id,size,0x27F5,0x02190,joinrelfactor,0x0002D) -- \leftarrow\joinrel\relbar
+ jointwo (main,characters,id,size,0x27F6,0x0002D,joinrelfactor,0x02192,2) -- \relbar\joinrel\rightarrow
+ jointwo (main,characters,id,size,0x27F7,0x02190,joinrelfactor,0x02192) -- \leftarrow\joinrel\rightarrow
+ jointwo (main,characters,id,size,0x27F8,0x021D0,joinrelfactor,0x0003D) -- \Leftarrow\joinrel\Relbar
+ jointwo (main,characters,id,size,0x27F9,0x0003D,joinrelfactor,0x021D2) -- \Relbar\joinrel\Rightarrow
+ jointwo (main,characters,id,size,0x27FA,0x021D0,joinrelfactor,0x021D2) -- \Leftarrow\joinrel\Rightarrow
+ jointhree(main,characters,id,size,0x27FB,0x02190,joinrelfactor,0x0002D,0,0xFE324) -- \leftarrow\joinrel\relbar\mapsfromchar
+ jointhree(main,characters,id,size,0x27FC,0xFE321,0,0x0002D,joinrelfactor,0x02192) -- \mapstochar\relbar\joinrel\rightarrow
+
+ extension(main,characters,id,size,0x21A6,0xFF504,0xFF501,0xFF503) -- \mapstochar\rightarrow
+ extension(main,characters,id,size,0x21A9,0xFF502,0xFF501,0xFF506) -- \leftarrow\joinrel\rhook
+ extension(main,characters,id,size,0x21AA,0xFF505,0xFF501,0xFF503) -- \lhook\joinrel\rightarrow
+ extension(main,characters,id,size,0x27F5,0xFF502,0xFF501,0xFF501) -- \leftarrow\joinrel\relbar
+ extension(main,characters,id,size,0x27F6,0xFF501,0xFF501,0xFF503) -- \relbar\joinrel\rightarrow
+ extension(main,characters,id,size,0x27F7,0xFF502,0xFF501,0xFF503) -- \leftarrow\joinrel\rightarrow
+ extension(main,characters,id,size,0x27F8,0xFF508,0xFF50A,0xFF50A) -- \Leftarrow\joinrel\Relbar
+ extension(main,characters,id,size,0x27F9,0xFF50A,0xFF50A,0xFF509) -- \Relbar\joinrel\Rightarrow
+ extension(main,characters,id,size,0x27FA,0xFF508,0xFF50A,0xFF509) -- \Leftarrow\joinrel\Rightarrow
+ extension(main,characters,id,size,0x27FB,0xFF502,0xFF501,0xFF507) -- \leftarrow\joinrel\relbar\mapsfromchar
+ extension(main,characters,id,size,0x27FC,0xFF504,0xFF501,0xFF503) -- \mapstochar\relbar\joinrel\rightarrow
+
+ extension(main,characters,id,size,0x219E,0xFF50B,0xFF501,0xFF501) -- \twoheadleftarrow\joinrel\relbar
+ extension(main,characters,id,size,0x21A0,0xFF501,0xFF501,0xFF50C) -- \relbar\joinrel\twoheadrightarrow
+ extension(main,characters,id,size,0x21C4,0xFF50D,0xFF50E,0xFF50F) -- leftoverright
+
+ -- 21CB leftrightharpoon
+ -- 21CC rightleftharpoon
+
+ stack(main,characters,id,size,0x2259,0x0003D,3,0x02227) -- \buildrel\wedge\over=
+
+ jointwo(main,characters,id,size,0x22C8,0x022B3,joinrelfactor,0x022B2) -- \mathrel\triangleright\joinrel\mathrel\triangleleft (4 looks better than 3)
+ jointwo(main,characters,id,size,0x22A7,0x0007C,joinrelfactor,0x0003D) -- \mathrel|\joinrel=
+ jointwo(main,characters,id,size,0x2260,0x00338,0,0x0003D) -- \not\equal
+ jointwo(main,characters,id,size,0x2284,0x00338,0,0x02282) -- \not\subset
+ jointwo(main,characters,id,size,0x2285,0x00338,0,0x02283) -- \not\supset
+ jointwo(main,characters,id,size,0x2209,0x00338,0,0x02208) -- \not\in
+ jointwo(main,characters,id,size,0x2254,0x03A,0,0x03D) -- := (≔)
+
+ repeated(main,characters,id,size,0x222C,0x222B,2,0xFF800,1/3)
+ repeated(main,characters,id,size,0x222D,0x222B,3,0xFF810,1/3)
+
+ if cloned(main,characters,id,size,0x2032,0xFE325) then
+ raise(main,characters,id,size,0x2032,0xFE325,1,id_of_smaller) -- prime
+ raise(main,characters,id,size,0x2033,0xFE325,2,id_of_smaller) -- double prime
+ raise(main,characters,id,size,0x2034,0xFE325,3,id_of_smaller) -- triple prime
+ -- to satisfy the prime resolver
+ characters[0xFE932] = characters[0x2032]
+ characters[0xFE933] = characters[0x2033]
+ characters[0xFE934] = characters[0x2034]
+ end
+
+ -- there are more (needs discussion first):
+
+ -- characters[0x20D6] = characters[0x2190]
+ -- characters[0x20D7] = characters[0x2192]
+
+ characters[0x02B9] = characters[0x2032] -- we're nice
+
+ data_of_smaller = main.fonts[id]
+ size_of_smaller = size
+
+end
+
+local unique = 0 -- testcase: \startTEXpage \math{!\text{-}\text{-}\text{-}} \stopTEXpage
+
+local reported = { }
+local reverse = { } -- index -> unicode
+
+setmetatableindex(reverse, function(t,name)
+ if trace_virtual then
+ report_virtual("initializing math vector %a",name)
+ end
+ local m = mathencodings[name]
+ local r = { }
+ for u, i in next, m do
+ r[i] = u
+ end
+ reverse[name] = r
+ return r
+end)
+
+local function copy_glyph(main,target,original,unicode,slot)
+ local addprivate = fonts.helpers.addprivate
+ local olddata = original[unicode]
+ if olddata then
+ local newdata = {
+ width = olddata.width,
+ height = olddata.height,
+ depth = olddata.depth,
+ italic = olddata.italic,
+ kerns = olddata.kerns,
+ tounicode = olddata.tounicode,
+ commands = { { "slot", slot, unicode } },
+ }
+ local glyphdata = newdata
+ local nextglyph = olddata.next
+ while nextglyph do
+ local oldnextdata = original[nextglyph]
+ if oldnextdata then
+ local newnextdata = {
+ width = oldnextdata.width,
+ height = oldnextdata.height,
+ depth = oldnextdata.depth,
+ tounicode = olddata.tounicode,
+ commands = { { "slot", slot, nextglyph } },
+ }
+ local newnextglyph = addprivate(main,formatters["M-N-%H"](nextglyph),newnextdata)
+ newdata.next = newnextglyph
+ local nextnextglyph = oldnextdata.next
+ if nextnextglyph == nextglyph then
+ break
+ else
+ olddata = oldnextdata
+ newdata = newnextdata
+ nextglyph = nextnextglyph
+ end
+ else
+ break -- safeguard (when testing stuff)
+ end
+ end
+ local hv = olddata.horiz_variants
+ if hv then
+ hv = fastcopy(hv)
+ newdata.horiz_variants = hv
+ for i=1,#hv do
+ local hvi = hv[i]
+ local oldglyph = hvi.glyph
+ local olddata = original[oldglyph]
+ local newdata = {
+ width = olddata.width,
+ height = olddata.height,
+ depth = olddata.depth,
+ tounicode = olddata.tounicode,
+ commands = { { "slot", slot, oldglyph } },
+ }
+ hvi.glyph = addprivate(main,formatters["M-H-%H"](oldglyph),newdata)
+ end
+ end
+ local vv = olddata.vert_variants
+ if vv then
+ vv = fastcopy(vv)
+ newdata.vert_variants = vv
+ for i=1,#vv do
+ local vvi = vv[i]
+ local oldglyph = vvi.glyph
+ local olddata = original[oldglyph]
+ local newdata = {
+ width = olddata.width,
+ height = olddata.height,
+ depth = olddata.depth,
+ tounicode = olddata.tounicode,
+ commands = { { "slot", slot, oldglyph } },
+ }
+ vvi.glyph = addprivate(main,formatters["M-V-%H"](oldglyph),newdata)
+ end
+ end
+ return newdata
+ end
+end
+
+vfmath.copy_glyph = copy_glyph
+
+-- It's time to get rid of this type 1 mess ... take iwona: uppercase /A .. Z but
+-- lowercase /a.math ... /z.math ... anyway, we now follow a slightly different
+-- route: use the "order" field. I can probably make it a bit leaner but it's not
+-- worth spending much time on now.
+
+function vfmath.define(specification,set,goodies)
+ local name = specification.name -- symbolic name
+ local size = specification.size -- given size
+ local loaded = { }
+ local fontlist = { }
+ local names = { }
+ local main = nil
+ local start = (trace_virtual or trace_timings) and os.clock()
+ local okset = { }
+ local n = 0
+ for s=1,#set do
+ local ss = set[s]
+ local ssname = ss.name
+ if add_optional and ss.optional then
+ if trace_virtual then
+ report_virtual("loading font %a subfont %s with name %a at %p is skipped",name,s,ssname,size)
+ end
+ else
+ if ss.features then
+ ssname = ssname .. "*" .. ss.features
+ end
+ if ss.main then
+ main = s
+ end
+ local alreadyloaded = names[ssname] -- for px we load one twice (saves .04 sec)
+ local f, id
+ if alreadyloaded then
+ f, id = alreadyloaded.f, alreadyloaded.id
+ if trace_virtual then
+ report_virtual("loading font %a subfont %s with name %a is reused",name,s,ssname)
+ end
+ else
+ f, id = fonts.constructors.readanddefine(ssname,size)
+ names[ssname] = { f = f, id = id }
+ end
+ if not f or id == 0 then
+ report_virtual("loading font %a subfont %s with name %a at %p is skipped, not found",name,s,ssname,size)
+ else
+ n = n + 1
+ okset[n] = ss
+ loaded[n] = f
+ fontlist[n] = { id = id, size = size }
+ if not shared[s] then
+ shared[n] = { }
+ end
+ if trace_virtual then
+ report_virtual("loading font %a subfont %s with name %a at %p as id %s using encoding %a",name,s,ssname,size,id,ss.vector)
+ end
+ end
+ end
+ end
+ -- beware, loaded[1] is already passed to tex (we need to make a simple copy then .. todo)
+ local parent = loaded[1] or { } -- a text font
+ local characters = { }
+ local parameters = { }
+ local mathparameters = { }
+ local descriptions = { }
+ local metadata = { }
+ local properties = {
+ hasitalics = true,
+ hasmath = true,
+ }
+ local goodies = { }
+ local main = {
+ metadata = metadata,
+ properties = properties,
+ characters = characters,
+ descriptions = descriptions,
+ parameters = parameters,
+ mathparameters = mathparameters,
+ fonts = fontlist,
+ goodies = goodies,
+ --
+ fullname = properties.fullname,
+ nomath = false,
+ }
+ --
+ for key, value in next, parent do
+ if type(value) ~= "table" then
+ main[key] = value
+ end
+ end
+ --
+ if parent.characters then
+ for unicode, character in next, parent.characters do
+ characters[unicode] = character
+ end
+ else
+ report_virtual("font %a has no characters",name)
+ end
+ --
+ if parent.parameters then
+ for key, value in next, parent.parameters do
+ parameters[key] = value
+ end
+ else
+ report_virtual("font %a has no parameters",name)
+ end
+ --
+ local description = { name = "" }
+ setmetatableindex(descriptions,function() return description end)
+ --
+ if parent.properties then
+ setmetatableindex(properties,parent.properties)
+ end
+ --
+ if parent.goodies then
+ setmetatableindex(goodies,parent.goodies)
+ end
+ --
+ local fullname = properties.fullname -- parent via mt
+ if fullname then
+ unique = unique + 1
+ properties.fullname = fullname .. "-" .. unique
+ end
+ --
+ if not parameters.x_height then
+ parameters.x_height = 0
+ end
+ --
+ local already_reported = false
+ local parameters_done = false
+ for s=1,n do
+ local ss, fs = okset[s], loaded[s]
+ if not fs then
+ -- skip, error
+ elseif add_optional and ss.optional then
+ -- skip, redundant
+ else
+ local newparameters = fs.parameters
+ local newmathparameters = fs.mathparameters
+ if newmathparameters then
+ if not parameters_done or ss.parameters then
+ mathparameters = newmathparameters
+ parameters_done = true
+ end
+ elseif not newparameters then
+ report_virtual("no parameters set in font %a",name)
+ elseif ss.extension then
+ mathparameters.math_x_height = newparameters.x_height or 0 -- math_x_height : height of x
+ mathparameters.default_rule_thickness = newparameters[ 8] or 0 -- default_rule_thickness : thickness of \over bars
+ mathparameters.big_op_spacing1 = newparameters[ 9] or 0 -- big_op_spacing1 : minimum clearance above a displayed op
+ mathparameters.big_op_spacing2 = newparameters[10] or 0 -- big_op_spacing2 : minimum clearance below a displayed op
+ mathparameters.big_op_spacing3 = newparameters[11] or 0 -- big_op_spacing3 : minimum baselineskip above displayed op
+ mathparameters.big_op_spacing4 = newparameters[12] or 0 -- big_op_spacing4 : minimum baselineskip below displayed op
+ mathparameters.big_op_spacing5 = newparameters[13] or 0 -- big_op_spacing5 : padding above and below displayed limits
+ -- report_virtual("loading and virtualizing font %a at size %p, setting ex parameters",name,size)
+ elseif ss.parameters then
+ mathparameters.x_height = newparameters.x_height or mathparameters.x_height
+ mathparameters.x_height = mathparameters.x_height or fp.x_height or 0 -- x_height : height of x
+ mathparameters.num1 = newparameters[ 8] or 0 -- num1 : numerator shift-up in display styles
+ mathparameters.num2 = newparameters[ 9] or 0 -- num2 : numerator shift-up in non-display, non-\atop
+ mathparameters.num3 = newparameters[10] or 0 -- num3 : numerator shift-up in non-display \atop
+ mathparameters.denom1 = newparameters[11] or 0 -- denom1 : denominator shift-down in display styles
+ mathparameters.denom2 = newparameters[12] or 0 -- denom2 : denominator shift-down in non-display styles
+ mathparameters.sup1 = newparameters[13] or 0 -- sup1 : superscript shift-up in uncramped display style
+ mathparameters.sup2 = newparameters[14] or 0 -- sup2 : superscript shift-up in uncramped non-display
+ mathparameters.sup3 = newparameters[15] or 0 -- sup3 : superscript shift-up in cramped styles
+ mathparameters.sub1 = newparameters[16] or 0 -- sub1 : subscript shift-down if superscript is absent
+ mathparameters.sub2 = newparameters[17] or 0 -- sub2 : subscript shift-down if superscript is present
+ mathparameters.sup_drop = newparameters[18] or 0 -- sup_drop : superscript baseline below top of large box
+ mathparameters.sub_drop = newparameters[19] or 0 -- sub_drop : subscript baseline below bottom of large box
+ mathparameters.delim1 = newparameters[20] or 0 -- delim1 : size of \atopwithdelims delimiters in display styles
+ mathparameters.delim2 = newparameters[21] or 0 -- delim2 : size of \atopwithdelims delimiters in non-displays
+ mathparameters.axis_height = newparameters[22] or 0 -- axis_height : height of fraction lines above the baseline
+ -- report_virtual("loading and virtualizing font %a at size %p, setting sy parameters",name,size)
+ end
+ if ss.overlay then
+ local fc = fs.characters
+ local first = ss.first
+ if first then
+ local last = ss.last or first
+ for unicode = first, last do
+ characters[unicode] = copy_glyph(main,characters,fc,unicode,s)
+ end
+ else
+ for unicode, data in next, fc do
+ characters[unicode] = copy_glyph(main,characters,fc,unicode,s)
+ end
+ end
+ else
+ local vectorname = ss.vector
+ if vectorname then
+ local offset = 0xFF000 -- todo: -- private
+ local vector = mathencodings[vectorname]
+ local rotcev = reverse[vectorname]
+ local isextension = ss.extension
+ if vector and rotcev then
+ local fc = fs.characters
+ local fd = fs.descriptions
+ local si = shared[s]
+ local fontname = fs.properties.name or "unknown"
+ local skewchar = ss.skewchar
+ local backmap = ss.backmap
+ -- we need to know the original order because the loader has made a
+ -- unicode font of it and weird glyphnames have spoiled that a bit
+ if backmap then
+ backmap = { }
+ for unicode, character in next, fc do
+ backmap[character.order or character.index or unicode] = unicode
+ end
+ end
+ for unicode, i in next, vector do
+ -- So, here we can have an extra remapping (compared to mkiv).
+ local index = backmap and backmap[i] or i
+ local fci = fc[index]
+ if not fci then
+ local rf = reported[fontname]
+ if not rf then rf = { } reported[fontname] = rf end
+ local rv = rf[vectorname]
+ if not rv then rv = { } rf[vectorname] = rv end
+ local ru = rv[unicode]
+ if not ru then
+ if trace_virtual then
+ local d = chardata[unicode].description
+ if index then
+ report_virtual("character %C has no index %H in vector %a for font %a (%S)",unicode,index,vectorname,fontname,d)
+ else
+ report_virtual("character %C has no entry in vector %a for font %a (%S)",unicode,vectorname,fontname,d)
+ end
+ elseif not already_reported then
+ report_virtual("the mapping is incomplete for %a at %p",name,size)
+ already_reported = true
+ end
+ rv[unicode] = true
+ end
+ else
+ local ref = si[index]
+ if not ref then
+ ref = { { 'slot', s, index } }
+ si[index] = ref
+ end
+ local kerns = fci.kerns
+ local width = fci.width
+ local italic = fci.italic
+-- if trace_virtual then
+-- report_virtual("character %C uses index %H in vector %a for font %a, %s, %s",
+-- unicode,index,vectorname,fontname,
+-- kerns and "adding kerns" or "no kerns",
+-- kerns and "adding italic" or "no italic"
+-- )
+-- end
+ if italic and italic > 0 then
+ -- int_a^b
+ if isextension then
+ width = width + italic -- for obscure reasons the integral as a width + italic correction
+ end
+ end
+ if kerns then
+ local krn = { }
+ for k, v in next, kerns do -- kerns is sparse
+ local rk = rotcev[k]
+ if rk then
+ krn[rk] = v -- kerns[k]
+ end
+ end
+ if not next(krn) then
+ krn = nil
+ end
+ local t = {
+ width = width,
+ height = fci.height,
+ depth = fci.depth,
+ italic = italic,
+ kerns = krn,
+ commands = ref,
+ }
+ if skewchar then
+ local k = kerns[skewchar]
+ if k then
+ t.top_accent = width/2 + k
+ end
+ end
+ characters[unicode] = t
+ else
+ characters[unicode] = {
+ width = width,
+ height = fci.height,
+ depth = fci.depth,
+ italic = italic,
+ commands = ref,
+ }
+ end
+ end
+ end
+ if isextension then
+ -- todo: if multiple ex, then 256 offsets per instance
+ local extension = mathencodings["large-to-small"]
+ local variants_done = fs.variants_done
+ for index, fci in next, fc do -- the raw ex file
+ if type(index) == "number" then
+ local ref = si[index]
+ if not ref then
+ ref = { { 'slot', s, index } }
+ si[index] = ref
+ end
+ local italic = fci.italic
+ local t = {
+ width = fci.width,
+ height = fci.height,
+ depth = fci.depth,
+ italic = italic,
+ commands = ref,
+ }
+ local n = fci.next
+ if n then
+ t.next = offset + n
+ elseif variants_done then
+ local vv = fci.vert_variants
+ if vv then
+ t.vert_variants = vv
+ end
+ local hv = fci.horiz_variants
+ if hv then
+ t.horiz_variants = hv
+ end
+ else
+ local vv = fci.vert_variants
+ if vv then
+ for i=1,#vv do
+ local vvi = vv[i]
+ vvi.glyph = vvi.glyph + offset
+ end
+ t.vert_variants = vv
+ end
+ local hv = fci.horiz_variants
+ if hv then
+ for i=1,#hv do
+ local hvi = hv[i]
+ hvi.glyph = hvi.glyph + offset
+ end
+ t.horiz_variants = hv
+ end
+ end
+ characters[offset + index] = t
+ end
+ end
+ fs.variants_done = true
+ for unicode, index in next, extension do
+ local cu = characters[unicode]
+ if cu then
+ cu.next = offset + index
+ else
+ local fci = fc[index]
+ if not fci then
+ -- do nothing
+ else
+ -- probably never entered
+ local ref = si[index]
+ if not ref then
+ ref = { { 'slot', s, index } }
+ si[index] = ref
+ end
+ local kerns = fci.kerns
+ if kerns then
+ local krn = { }
+ -- for k=1,#kerns do
+ -- krn[offset + k] = kerns[k]
+ -- end
+ for k, v in next, kerns do -- is kerns sparse?
+ krn[offset + k] = v
+ end
+ characters[unicode] = {
+ width = fci.width,
+ height = fci.height,
+ depth = fci.depth,
+ italic = fci.italic,
+ commands = ref,
+ kerns = krn,
+ next = offset + index,
+ }
+ else
+ characters[unicode] = {
+ width = fci.width,
+ height = fci.height,
+ depth = fci.depth,
+ italic = fci.italic,
+ commands = ref,
+ next = offset + index,
+ }
+ end
+ end
+ end
+ end
+ end
+ else
+ report_virtual("error in loading %a, problematic vector %a",name,vectorname)
+ end
+ end
+ end
+ mathematics.extras.copy(main) --not needed here (yet)
+ end
+ end
+-- inspect(characters[0x1D465])
+-- inspect(fonts.encodings.math["tex-it"])
+-- inspect(fontlist)
+ --
+ main.mathparameters = mathparameters -- still traditional ones
+ -- This should change (some day) as it's the only place where we look forward,
+ -- so better is to also reserve the id already which then involves some more
+ -- management (so not now).
+ fontlist[#fontlist+1] = {
+ -- id = font.nextid(),
+ id = 0, -- self
+ size = size,
+ }
+ vfmath.addmissing(main,#fontlist,size)
+ --
+ mathematics.addfallbacks(main)
+ --
+ main.properties.math_is_scaled = true -- signal
+ fonts.constructors.assignmathparameters(main,main)
+ --
+ main.MathConstants = main.mathparameters -- we directly pass it to TeX (bypasses the scaler) so this is needed
+ --
+ if trace_virtual or trace_timings then
+ report_virtual("loading and virtualizing font %a at size %p took %0.3f seconds",name,size,os.clock()-start)
+ end
+ --
+ main.oldmath = true
+ return main
+end
+
+function mathematics.makefont(name,set,goodies)
+ fonts.definers.methods.variants[name] = function(specification)
+ return vfmath.define(specification,set,goodies)
+ end
+end
+
+-- helpers
+
+function vfmath.setletters(font_encoding, name, uppercase, lowercase)
+ local enc = font_encoding[name]
+ for i = 0,25 do
+ enc[uppercase+i] = i + 0x41
+ enc[lowercase+i] = i + 0x61
+ end
+end
+
+function vfmath.setdigits(font_encoding, name, digits)
+ local enc = font_encoding[name]
+ for i = 0,9 do
+ enc[digits+i] = i + 0x30
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-blb.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-blb.mkxl
new file mode 100644
index 00000000000..247d3a34e3f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-blb.mkxl
@@ -0,0 +1,53 @@
+%D \module
+%D [ file=meta-blb,
+%D version=2018.04.12,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Blobs,
+%D author=Hans Hagen,
+%D date=\ currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Graphics / Blobs}
+
+\registerctxluafile{meta-blb}{}
+
+\unprotect
+
+\permanent\protected\def\MPLIBgetblobscaledcm#1#2#3#4#5#6#7#8#9%
+ {\clf_mpgetblob\MPtextbox#1\relax
+ \setbox\MPbox\hpack\bgroup
+ \dotransformnextbox{#2}{#3}{#4}{#5}{#6}{#7}%
+ \vpack to \zeropoint\bgroup
+ \vss
+ \hpack to \zeropoint \bgroup
+ % \fastsxsy{#8}{#9}{\raise\dp\MPtextbox\box\MPtextbox}%
+ \fastsxsy{#8}{#9}{\box\MPtextbox}%
+ \hss
+ \egroup
+ \egroup
+ \egroup
+ \smashbox\MPbox
+ \box\MPbox}
+
+%D An example of usage:
+
+\definefontfeature[followtext][liga=no]
+
+\permanent\protected\def\MPLIBfollowtext#1#2%
+ {\begingroup
+ \scratchcounter#1\relax
+ \setbox\scratchbox\hbox{\addff{followtext}#2}%
+ \clf_MPLIBconvertfollowtext\scratchcounter\scratchbox
+ \endgroup}
+
+%D New:
+
+\newtoks\mpblobtext
+
+\permanent\protected\mpblobtext{\global\setbox\mptextbox\vbox{\clf_mpblobtext}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-fig.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-fig.mkxl
new file mode 100644
index 00000000000..b8a22f6feff
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-fig.mkxl
@@ -0,0 +1,69 @@
+%D \module
+%D [ file=meta-fig,
+%D version=2000.09.07,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Stand Alone Graphics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Graphics / Stand Alone Graphics}
+
+\unprotect
+
+%D This module implements a method for defining stand||alone||graphics, that is,
+%D each graphic gets is own page. Because graphics are wrapped in a \type {\framed},
+%D you can add overlays to the graphic directly, and since the whole \CONTEXT\
+%D machinery is available, you can also add page backgrounds.
+%D
+%D \starttyping
+%D \setupMPpage
+%D [offset=1pt,
+%D background=color,
+%D backgroundcolor=green]
+%D
+%D \startMPpage
+%D fill fullcircle scaled 10cm withcolor red ;
+%D \stopMPpage
+%D
+%D \startMPpage
+%D fill fullsquare rotated 45 scaled 8cm withcolor blue ;
+%D \stopMPpage
+%D \stoptyping
+%D
+%D Although this is hardly of any use, you can mix these definitions with the text
+%D flow, since all settings are kept local. The page is clipped to the image size.
+
+\definefittingpage
+ [MPpage]
+ [\c!align=,
+ \c!command=\meta_process_graphic_command,
+ \c!instance=]
+
+\permanent\protected\def\setupMPpage
+ {\setupfittingpage[MPpage]}
+
+\protected\def\meta_process_graphic_command
+ {\meta_process_graphic_instance{\fittingpageparameter\c!instance}}
+
+%D \macros
+%D {MPfigure}
+%D
+%D A bit out of place, here but nevertheless:
+
+\permanent\protected\def\MPfigure#1#2% test for dup figure, can be replaced by a textext
+ {\bgroup
+ \getfiguredimensions[#1]% [\c!object=\v!no] already set
+ \startMPcode
+ draw externalfigure "#1"
+ xsized \the\dimexpr\figurewidth \relax\space % must be points
+ ysized \the\dimexpr\figureheight\relax\space % must be points
+ #2 ;
+ \stopMPcode
+ \egroup}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-fnt.lmt b/Master/texmf-dist/tex/context/base/mkxl/meta-fnt.lmt
new file mode 100644
index 00000000000..91acd9c0268
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-fnt.lmt
@@ -0,0 +1,150 @@
+if not modules then modules = { } end modules ['meta-fnt'] = {
+ version = 1.001,
+ comment = "companion to meta-fnt.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This was one of the demo modules that never was used for real so the \MKIV\
+-- variant has been replaced by one using the newer \LMTX\ interface, but only
+-- because we want to be (sort of) compatible. Instead of doing the work at the
+-- \LUA\ end we do it at the \TEX end.
+
+metapost.fonts = metapost.fonts or { }
+
+function metapost.fonts.define(specification)
+ local fontname = specification.fontname
+ local filename = specification.filename
+ local fontsize = specification.size
+ context.definemetafont (
+ { fontname },
+ { filename },
+ { size and { "at " .. size .. " sp" } or "" }
+ )
+end
+
+-- metapost.fonts.define {
+-- fontname = "bidi",
+-- filename = "bidi-symbols.mp",
+-- }
+
+-- okay, let's for the moment put this here:
+
+local tonumber = tonumber
+local find = string.find
+
+local context = context
+
+local fastserialize = table.fastserialize
+local settings_to_hash = utilities.parsers.settings_to_hash
+local settings_to_array = utilities.parsers.settings_to_array
+
+local addcharacters = fonts.constructors.addcharacters
+local fontdata = fonts.hashes.identifiers
+
+-- This is a prelude to a more advance mechanism: when we are in mp we can construct the
+-- whole composed character there.
+
+function fonts.helpers.combineglyphs(fnt, specification)
+ local hash = fastserialize(specification)
+ local fontid = fnt or font.current()
+ local tfmdata = fontdata[fontid]
+ local combhash = tfmdata.combhash or { }
+ local unicode = combhash[hash]
+ if not unicode then
+ local t = { }
+ local h = 0
+ local d = 0
+ local w = 0
+ local o = 0
+ local characters = tfmdata.characters
+ for i=1,#specification do
+ local s = specification[i]
+ local l = find(s,"=") and settings_to_hash(s)
+ local n = tonumber(l and l.unicode or s) or tonumber(s)
+ if n then
+ local data = characters[n]
+ if data then
+ local bb = data.boundingbox
+ if bb then
+ local llx = bb[1]
+ local lly = bb[2]
+ local urx = bb[3]
+ local ury = bb[4]
+ if ury > h then
+ h = ury
+ elseif - ury > d then
+ d = - ury
+ end
+ if - lly > d then
+ d = - lly
+ elseif lly > h then
+ h = lly
+ end
+ if llx < o then
+ o = llx
+ end
+ -- could be an extension to the "offset" command
+ local c = l and l.color
+ if c then
+ t[#t+1] = { "startcolor", c }
+ end
+ t[#t+1] = { "offset", 0, 0, n }
+ if c then
+ t[#t+1] = { "stopcolor" }
+ end
+ -- t[#t+1] = { "push" }
+ -- if c then
+ -- t[#t+1] = { "startcolor", c }
+ -- end
+ -- t[#t+1] = { "right", 0 }
+ -- t[#t+1] = { "char", n }
+ -- if c then
+ -- t[#t+1] = { "stopcolor" }
+ -- end
+ -- t[#t+1] = { "pop" }
+ if urx > w then
+ w = urx
+ end
+ else
+ local ht = data.height or 0 if ht > h then h = ht end
+ local dp = data.depth or 0 if dp > d then d = dp end
+ local wd = data.width or 0 if wd > w then w = wd end
+ t[#t+1] = { "char", n }
+ end
+ end
+ end
+ end
+ for i=1,#t do
+-- if t[i][1] == "right" then
+ if t[i][1] == "offset" then
+ t[i][2] = -o
+-- t[i][2] = o
+ end
+ end
+ -- cheat one: we get a private slot
+ unicode = fonts.helpers.addprivate(tfmdata,nil,{
+ commands = t,
+ width = w - o,
+ height = h,
+ depth = d,
+ })
+ -- cheat two: we overload it later
+ addcharacters(fontid,{ characters = { [unicode] = characters[unicode] } })
+ tfmdata.combhash = combhash
+ combhash[hash] = unicode
+ end
+ return unicode
+end
+
+interfaces.implement {
+ name = "combineglyphs",
+ public = true,
+ arguments = "string",
+ actions = function(list)
+ local list = settings_to_array(list)
+ local unicode = fonts.helpers.combineglyphs(font.current(),list)
+ context(unicode)
+ end,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-fnt.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-fnt.mkxl
new file mode 100644
index 00000000000..45d1db2988e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-fnt.mkxl
@@ -0,0 +1,44 @@
+%D \module
+%D [ file=meta-fnt,
+%D version=2013.09.06,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Fonts,
+%D author=Hans Hagen,
+%D date=\ currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Graphics / Fonts}
+
+\registerctxluafile{meta-fnt}{autosuffix}
+\registerctxluafile{font-mpf}{autosuffix}
+
+\unprotect
+
+%D Contrary to the \MKIV\ variant we dont' use the \LUA\ call but the \LUA\ call
+%D uses this here:
+
+\permanent\tolerant\protected\def\definemetafont[#1]#*[#2]#*[#3]%
+ {\doonlyonce{#2}{%
+ \definefontfeature[metafont-#2][metapost=#2]
+ \startMPcalculation{simplefun} input "#2" ; \stopMPcalculation
+ }%
+ \definefont[#1][Mono*metafont-#2 #3]}
+
+%D Demo:
+%D
+%D \starttyping
+%D \setupbodyfont[dejavu]
+%D \starttext
+%D \showglyphs
+%D \startTEXpage[offset=10pt]
+%D \definemetafont[MyDemoA][demo-symbols][at 10pt]\MyDemoA\char9754
+%D \definemetafont[MyDemoB][demo-symbols][at 30pt]\MyDemoB\char9754
+%D \stopTEXpage
+%D \stoptext
+%D \stoptyping
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-fun.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-fun.mkxl
new file mode 100644
index 00000000000..e30660392f1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-fun.mkxl
@@ -0,0 +1,25 @@
+%D \module
+%D [ file=meta-fun,
+%D version=2009.06.02,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Goodies,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Graphics / Goodies}
+
+\registerctxluafile{meta-fun}{}
+
+\unprotect
+
+%D Just a few handy helpers:
+
+\ifdefined\MPtoks\else \newtoks\MPtoks \fi
+\ifdefined\MPbox \else \newbox \MPbox \fi
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl
new file mode 100644
index 00000000000..009149e46ed
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl
@@ -0,0 +1,105 @@
+%D \module
+%D [ file=meta-grd,
+%D version=2012.06.28,
+%D title=\METAPOST\ Graphics,
+%D subtitle=grids,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Graphics / Grids}
+
+\unprotect
+
+%D This used to be a \TEX\ method, and a rather old one too. We keep it around but
+%D in a more modern way.
+%D
+%D \startbuffer
+%D \basegrid
+%D [nx=8,ny=5,
+%D dx=.5,dy=.25,
+%D unit=cm,scale=2,factor=1,
+%D offset=1ex,xstep=2,ystep=1,
+%D align=middle,style=\tt\tx]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \placefigure
+%D {An example of a grid.}
+%D {\getbuffer}
+
+\startuseMPgraphic{meta:grd:basegrid}
+ begingroup ;
+
+ save sc, dx, dy, wd, ht, ox, oy, ax, ay ;
+
+ sc = \directdummyparameter\c!factor*\directdummyparameter\c!scale ;
+ dx = \MPdpar\directdummyparameter\c!dx*sc ;
+ dy = \MPdpar\directdummyparameter\c!dy*sc ;
+ wd = \directdummyparameter\c!nx*dx ;
+ ht = \directdummyparameter\c!ny*dy ;
+ ox = \MPdpar\directdummyparameter\c!xoffset\relax ;
+ oy = \MPdpar\directdummyparameter\c!yoffset\relax ;
+
+ if "\directdummyparameter\c!align" = "\v!middle" :
+ ax = \MPdpar\directdummyparameter\c!dx/2
+ ay = \MPdpar\directdummyparameter\c!dy/2
+ else :
+ ax = 0 ;
+ ay = 0 ;
+ fi ;
+
+ draw image (
+ for i=0 step dx until wd : draw (i,0) -- (i,ht) ; endfor ;
+ for i=0 step dy until ht : draw (0,i) -- (wd,i) ; endfor ;
+ )
+ withpen pencircle scaled \MPdpar\directdummyparameter\c!rulethickness\space
+ withcolor "\directdummyparameter\c!rulecolor" ;
+
+ draw image (
+ if \directdummyparameter\c!xstep > 0 :
+ for i=1 step \directdummyparameter\c!xstep until \directdummyparameter\c!nx :
+ draw thetextext.bot(decimal i,(i*dx-ax,oy));
+ endfor ;
+ fi ;
+ if \directdummyparameter\c!ystep > 0 :
+ for i=1 step \directdummyparameter\c!ystep until \directdummyparameter\c!ny :
+ draw thetextext.lft(decimal i,(ox,i*dy-ay)) ;
+ endfor ;
+ fi ;
+ )
+ withcolor "\directdummyparameter\c!color" ;
+
+ endgroup ;
+\stopuseMPgraphic
+
+\permanent\tolerant\protected\def\basegrid[#1]%
+ {\dontleavehmode
+ \hbox\bgroup
+ \getdummyparameters
+ [\c!nx=10,\c!ny=10,%
+ \c!dx=.5,\c!dy=.5,%
+ \c!xstep=0,\c!ystep=0,%
+ \c!unit=\s!cm,\c!scale=1,\c!factor=1,%
+ \c!offset=.25\exheight,%
+ \c!xoffset=\directdummyparameter\c!offset,%
+ \c!yoffset=\directdummyparameter\c!offset,%
+ \c!align=,%
+ \c!color=\currentcolorname,%
+ \c!rulecolor=\currentcolorname,%
+ \c!rulethickness=\linewidth,%
+ #1]%
+ \usedummystyleandcolor\c!style\c!color
+ \setexpandeddummyparameter\c!dx{\directdummyparameter\c!dx\directdummyparameter\c!unit}%
+ \setexpandeddummyparameter\c!dy{\directdummyparameter\c!dy\directdummyparameter\c!unit}%
+ \useMPgraphic{meta:grd:basegrid}%
+ \egroup}
+
+\aliased\let\grid\basegrid
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-clock.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-clock.mkxl
new file mode 100644
index 00000000000..0612113ea42
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-clock.mkxl
@@ -0,0 +1,141 @@
+%D \module
+%D [ file=meta-imp-clock,
+%D version=2021.01.21,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Demo Clock Font,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is just a demo of defining a font in \METAPOST. The rendering as well as definitions
+%D are delayed till we actually need the glyph. A crazy examples made in crazy times.
+
+\startMPcalculation{simplefun}
+
+ % the 0 in getparameterdefault makes sure we convert to a number
+
+ picture DemoClocks[];
+
+ vardef ClockCircle =
+ image(draw fullcircle scaled 10 ;)
+ enddef ;
+
+ vardef ClockPoints =
+ image (
+ for i=1 upto 12 :
+ draw (0,5) rotated ((360 * i) / 12) withpen pencircle scaled 1 ;
+ endfor ;
+ )
+ enddef ;
+
+ vardef ClockTicks =
+ image (
+ for i=1 upto 12 :
+ draw ((0,4.5)--(0,5.5)) rotated ((360 * i) / 12) ;
+ endfor ;
+ )
+ enddef ;
+
+ vardef ClockCenter =
+ image (
+ draw origin withpen pencircle scaled 1 ;
+ )
+ enddef ;
+
+ vardef ClockHour =
+ image(
+ draw (origin -- (0,4)) rotated (
+ - 360 * (getparameterdefault "mpsfont" "hour" 0) / 12
+ - 360 * (getparameterdefault "mpsfont" "minute" 0) / (60 * 12)
+
+ ) )
+ enddef ;
+
+ vardef ClockMinute =
+ image(
+ draw (origin -- (0,5)) rotated (
+ - 360 * (getparameterdefault "mpsfont" "minute" 0) / 60
+ )
+ )
+ enddef ;
+
+ vardef DemoClock =
+ composeglyph(DemoClocks) ;
+ enddef ;
+
+ lmt_registerglyphs [
+ name = "clock",
+ units = 10,
+ width = 10,
+ height = 10,
+ depth = 0,
+ ] ;
+
+ lmt_registerglyph [
+ category = "clock",
+ ] ;
+
+\stopMPcalculation
+
+% \startluacode
+% metapost.metafonts.clock = { }
+% \stopluacode
+
+\continueifinputfile{meta-imp-clock.mkxl}
+
+% \enableexperiments[fonts.compact]
+
+\nopdfcompression
+
+\setuplayout[tight]
+
+\setupbodyfont[dejavu]
+
+\definefontfeature[clock][metapost=clock,metafont=clock]
+
+\definefont[ClockFont][Serif*clock]
+
+\starttext
+
+\unexpanded\def\MyClock#1#2%
+ {\begingroup
+ \ClockFont
+ \iffontchar\font\privatecharactercode{CLOCK:#1:#2}\else
+ % We could move this out to a helper \MyClockMake{#1}{#2} but normally
+ % it's efficient enough. (If we trace a lot it matters more.)
+ \setmetaglyph {
+ category {clock}
+ name {CLOCK:#1:#2}
+ code {DemoClock}
+ hour {#1}
+ minute {#2}
+ shapes {
+ { shape {ClockCircle} color {darkred} }
+ { shape {ClockTicks} color {middlegray} }
+ % { shape {ClockBullets} color {middlegray} }
+ { shape {ClockHour} color {darkgreen} }
+ { shape {ClockMinute} color {darkblue} }
+ { shape {ClockCenter} color {middlegray} }
+ }
+ }%
+ \fi
+ \setalternate{\twodigits{#1}:\twodigits{#2}}% cut'n'paste in acrobat
+ \privatecharacter{CLOCK:#1:#2}%
+ \endgroup}
+
+\dorecurse{8}{
+ \begingroup
+ \glyphxscale \numexpr 1000+#100\relax
+ \glyphyscale \glyphxscale
+ \veryraggedright
+ \dostepwiserecurse{0}{60}{1}{
+ \MyClock{3}{##1}\hskip\zeropoint plus \onepoint\allowbreak% space
+ }
+ \blank
+ \endgroup
+}
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-demo.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-demo.mkxl
new file mode 100644
index 00000000000..b89a4771bec
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-demo.mkxl
@@ -0,0 +1,233 @@
+%D \module
+%D [ file=meta-imp-demo,
+%D version=2021.01.21,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Demo Font,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is just a demo of defining a font in \METAPOST. The rendering as well as definitions
+%D are delayed till we actually need the glyph.
+
+\startMPcalculation{simplefun}
+
+ picture DemoSnippets[];
+
+ vardef DemoCircle = image(fill fullcircle scaled 10 ;) enddef ;
+ vardef DemoCenter = image(fill fullcircle scaled 3 ;) enddef ;
+
+ vardef DemoLeft = image(fill fullcircle scaled 3 shifted (-5, 0) ;) enddef ;
+ vardef DemoRight = image(fill fullcircle scaled 3 shifted ( 5, 0) ;) enddef ;
+ vardef DemoUp = image(fill fullcircle scaled 3 shifted ( 0, 5) ;) enddef ;
+ vardef DemoDown = image(fill fullcircle scaled 3 shifted ( 0,-5) ;) enddef ;
+ vardef DemoLowerLeft = image(fill fullcircle scaled 3 shifted (-5,-5) ;) enddef ;
+ vardef DemoLowerRight = image(fill fullcircle scaled 3 shifted ( 5,-5) ;) enddef ;
+ vardef DemoUpperRight = image(fill fullcircle scaled 3 shifted ( 5, 5) ;) enddef ;
+ vardef DemoUpperLeft = image(fill fullcircle scaled 3 shifted (-5, 5) ;) enddef ;
+
+ vardef DemoGlyph =
+ composeglyph(DemoSnippets) ;
+ enddef ;
+
+ lmt_registerglyphs [
+ name = "demo",
+ units = 10,
+ width = 10,
+ height = 10,
+ depth = 0,
+ ] ;
+
+ % we need to set up some basics (signals to the backend and such) at definition
+ % time so we just force a bogus shape (zero)
+
+ lmt_registerglyph [
+ category = "demo",
+ ] ;
+
+\stopMPcalculation
+
+\startluacode
+
+metapost.metafonts.demo = {
+ [utf.byte("g")] = {
+ code = "DemoGlyph",
+ shapes = {
+ { shape = "DemoCircle", color = "gray" },
+ { shape = "DemoLeft", color = "cyan" },
+ { shape = "DemoUp", color = "magenta" },
+ { shape = "DemoCenter", color = "yellow" },
+ }
+ },
+ [utf.byte("h")] = {
+ code = "DemoGlyph",
+ shapes = {
+ { shape = "DemoCircle", color = "gray" },
+ { shape = "DemoRight", color = "red" },
+ { shape = "DemoDown", color = "green" },
+ { shape = "DemoCenter", color = "blue" },
+ }
+ },
+ [19] = {
+ code = "DemoGlyph",
+ shapes = {
+ { shape = "DemoCircle", color = "gray" },
+ { shape = "DemoUp", color = "darkgray" },
+ { shape = "DemoDown", color = "darkgray" },
+ { shape = "DemoLeft", color = "darkgray" },
+ { shape = "DemoRight", color = "darkgray" },
+ { shape = "DemoCenter", color = "darkgray" },
+ }
+ },
+ ["weirdsymbol"] = {
+ code = "DemoGlyph",
+ shapes = {
+ { shape = "DemoCircle", color = "middlegray" },
+ { shape = "DemoUp", color = "red" },
+ { shape = "DemoDown", color = "green" },
+ { shape = "DemoLeft", color = "blue" },
+ { shape = "DemoRight", color = "magenta" },
+ { shape = "DemoCenter", color = "yellow" },
+ }
+ },
+ ["weirdersymbol"] = {
+ code = "DemoGlyph",
+ shapes = {
+ -- { shape = "DemoCircle", color = "gray" },
+ { shape = "DemoCenter", color = "darkgray" },
+ { shape = "DemoLowerLeft", color = "red" },
+ { shape = "DemoLowerRight", color = "green" },
+ { shape = "DemoUpperRight", color = "blue" },
+ { shape = "DemoUpperLeft", color = "yellow" },
+ { shape = "DemoUp", color = "darkred" },
+ { shape = "DemoDown", color = "darkgreen" },
+ { shape = "DemoLeft", color = "darkblue" },
+ { shape = "DemoRight", color = "darkmagenta" },
+ }
+ }
+}
+
+\stopluacode
+
+\continueifinputfile{meta-imp-demo.mkxl}
+
+\setuplayout[tight]
+
+\setupbodyfont[dejavu]
+
+\definefontfeature[demo][metapost=demo,metafont=demo]
+
+\definefont[DemoA][Serif*demo]
+\definefont[DemoB][Serif*demo sa .5]
+\definefont[DemoC][Serif*demo sa .25]
+
+\starttext
+
+ \startbuffer
+ x\ruledhbox{gh}%
+ x\ruledhbox{\char19}%
+ x\privatecharacter{weirdsymbol}%
+ x\privatecharacter{weirdersymbol}%
+ x%
+ \stopbuffer
+
+ \startTEXpage[offset=2pt]
+ \DemoA\getbuffer\par
+ \DemoB\getbuffer\quad\DemoC\getbuffer\par
+ \stopTEXpage
+
+ {\DemoA\ctxlua{fonts.helpers.setmetaglyph {
+ category = "demo",
+ name = "whatever",
+ code = "DemoGlyph",
+ shapes = {
+ { shape = "DemoCenter", color = "darkgray" },
+ { shape = "DemoLowerLeft", color = "darkred" },
+ { shape = "DemoLowerRight", color = "darkgreen" },
+ { shape = "DemoUpperRight", color = "darkblue" },
+ { shape = "DemoUpperLeft", color = "darkyellow" },
+ { shape = "DemoUp", color = "red" },
+ { shape = "DemoDown", color = "green" },
+ { shape = "DemoLeft", color = "blue" },
+ { shape = "DemoRight", color = "magenta" },
+ }
+ }}}
+
+ {\DemoA\setmetaglyph {
+ category {demo}
+ name {forever}
+ code {DemoGlyph}
+ shapes {
+ { shape {DemoCenter} color {middlegray} }
+ { shape {DemoLowerLeft} color {darkgray} }
+ { shape {DemoLowerRight} color {darkgray} }
+ { shape {DemoUpperRight} color {darkgray} }
+ { shape {DemoUpperLeft} color {darkgray} }
+ { shape {DemoUp} color {lightgray} }
+ { shape {DemoDown} color {lightgray} }
+ { shape {DemoLeft} color {lightgray} }
+ { shape {DemoRight} color {lightgray} }
+ }
+ }}
+
+ \startTEXpage[offset=2pt]
+ \DemoA
+ \privatecharacter{whatever}
+ \privatecharacter{forever}
+ \stopTEXpage
+
+ \DemoA\setupinterlinespace \dorecurse{10}{\dorecurse{1000}{g h }\par}\page
+ \DemoB\setupinterlinespace \dorecurse{20}{\dorecurse{1000}{g h }\par}\page
+ \DemoC\setupinterlinespace \dorecurse{30}{\dorecurse{1000}{g h }\par}\page
+
+ \unexpanded\def\MyChar#1%
+ {\begingroup
+ \DemoA
+ \iffontchar\font\privatecharactercode{forever-#1}\else
+ \setmetaglyph {
+ category {demo}
+ name {forever-#1}
+ code {DemoGlyph}
+ shapes {
+ { shape {DemoCenter} color {middlegray} }
+ { shape {DemoLowerLeft} color {dark#1} }
+ { shape {DemoLowerRight} color {dark#1} }
+ { shape {DemoUpperRight} color {dark#1} }
+ { shape {DemoUpperLeft} color {dark#1} }
+ { shape {DemoUp} color {light#1} }
+ { shape {DemoDown} color {light#1} }
+ { shape {DemoLeft} color {light#1} }
+ { shape {DemoRight} color {light#1} }
+ }
+ }%
+ \fi
+ \privatecharacter{forever-#1}%
+ \endgroup}
+
+ \dontcomplain
+
+ \dorecurse{1000}{%
+ \MyChar{red}\space
+ \MyChar{green}\space
+ \MyChar{blue}\space
+ \MyChar{yellow}\space
+ }
+
+ \page
+
+ \start
+ \glyphxscale 1200
+ \glyphyscale 800
+ \dorecurse{1000}{%
+ \MyChar{red}\allowbreak
+ \MyChar{green}\allowbreak
+ \MyChar{blue}\allowbreak
+ \MyChar{yellow}\allowbreak
+ }
+ \stop
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-experiments.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-experiments.mkxl
new file mode 100644
index 00000000000..644a8fff031
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-experiments.mkxl
@@ -0,0 +1,358 @@
+%D \module
+%D [ file=meta-imp-experiments,
+%D version=2020.03.18,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Experimental Graphics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This library implements some experimental functionality that eventually
+%D might end up someplace else.
+
+\startluacode
+
+ -- I decided to play with this kind of graphics after I read an article in a Dutch
+ -- popular science journal. It was an article about virusus in the mids of the time
+ -- when covid raged, so it also was a distraction.
+
+ -- This is a typical case of first prototyping it in Lua using the 'context' command
+ -- to generate MetaPost code and when that worked okay do it the following way. The
+ -- way data is passed is a bit messy.
+
+ do
+
+ local function sum(t)
+ local n = 0
+ for i=1,#t do
+ n = n + t[i]
+ end
+ return n
+ end
+
+ local function checked(data)
+ if data then
+ local n = #data
+ for i=1,n do
+ data[i][i] = 0
+ end
+ for i=1,n do
+ local di = data[i]
+ for j=i+1,n do
+ local dj = data[j]
+ local dji = dj[i]
+ if not dji then
+ dji = 0
+ dj[i] = 0
+ end
+ di[j] = dji
+ end
+ end
+ return data
+ else
+ return { }
+ end
+ end
+
+ local data, list = nil, nil
+
+ function mp.lmt_overlap_prepare()
+ data = checked(metapost.getparameter { "data" })
+ list = { }
+ for i=1,#data do
+ list[i] = sum(data[i])
+ end
+ end
+
+ function mp.lmt_overlap_reset()
+ data = nil
+ list = nil
+ end
+
+ function mp.lmt_overlap_n()
+ return #list
+ end
+
+ function mp.lmt_overlap_data(i, j)
+ if j then
+ return data[i][j]
+ else
+ return list[i]
+ end
+ end
+
+ local injectstring = mp.inject.string
+
+ function mp.lmt_overlap_text(i, j)
+ injectstring(data[i][j] or "")
+ end
+
+ function mp.lmt_overlap_label(i)
+ local labels = metapost.getparameter { "labels" }
+ injectstring(labels and labels[i] or "")
+ end
+
+ function mp.lmt_overlap_color(i)
+ local colors = metapost.getparameter { "colors" }
+ injectstring(colors and colors[i] or "darkgray")
+ end
+
+ function mp.lmt_overlap_total()
+ return sum(list)
+ end
+
+ end
+\stopluacode
+
+\startMPextensions
+
+presetparameters "overlap" [
+ options = "paths,lines",
+ gap = 4,
+ subgap = 2,
+ offset = 8,
+ color = "darkgray",
+ alternative = "circular",
+ colors = {
+ "darkred",
+ "darkgreen",
+ "darkblue",
+ "darkyellow",
+ "darkmagenta",
+ "darkcyan"
+ },
+] ;
+
+def lmt_overlap = applyparameters "overlap" "lmt_do_overlap" enddef ;
+
+vardef lmt_do_overlap_circular =
+
+ astep := 360 / steps ;
+
+ p := fullcircle scaled steps ;
+ r := origin -- (2*steps,0) ;
+
+ start := 0 ;
+ stop := 0 ;
+ for i=1 upto n:
+ stop := start + lua.mp.lmt_overlap_data(i) ;
+ first := start ;
+ last := stop ;
+ for j=1 upto n:
+ if i <> j :
+ last := first + lua.mp.lmt_overlap_data(i,j) ;
+ a := p intersectionpoint (r rotated (first * astep + 0.1)) ; % the 0.1 is somehow needed, why
+ b := p intersectionpoint (r rotated (last * astep - 0.1)) ; % the 0.1 is somehow needed, why
+ qq[i][j] := (p cutafter b) cutbefore a ;
+ first := last + subgap ;
+ fi ;
+ endfor ;
+ start := stop + gap + (n - 1) * subgap ;
+ endfor ;
+
+ if hasoption "options" "paths" :
+
+ for i=1 upto n :
+ for j=1 upto n :
+ if i <> j :
+ q := qq[i][j] ;
+ freelabeloffset := getparameter "offset" ;
+ freelabel(lua.mp.lmt_overlap_text(i,j), point .5 along q, origin) ;
+ if i < j :
+ s := qq[j][i] ;
+ a := point length(q) of q ;
+ b := point 0 of s ;
+ c := point length(s) of s ;
+ d := point 0 of q ;
+ q := q & a .. controls origin and origin .. b & s & c .. controls origin and origin .. d -- cycle ;
+ fill q withcolor lua.mp.lmt_overlap_color(i) withtransparency (1,.8) ;
+ fi ;
+ fi ;
+ endfor ;
+ endfor ;
+
+ fi ;
+
+ if hasoption "options" "lines" :
+
+ start := 0 ;
+ stop := 0 ;
+ for i=1 upto n:
+ stop := start + lua.mp.lmt_overlap_data(i) + (n - 2) * subgap ;
+ a := p intersectionpoint (r rotated (start * astep)) ;
+ b := p intersectionpoint (r rotated (stop * astep)) ;
+ q := (p cutbefore a) cutafter b ;
+ freelabeloffset := getparameterdefault "textoffset" (4 * getparameter "offset") ;
+ freelabel(lua.mp.lmt_overlap_label(i), point .5 along q, origin) ;
+ draw q withcolor white withpen pencircle scaled 5 ;
+ draw q withcolor getparameter "color" withpen pencircle scaled 5 ;
+ start := stop + gap + subgap ;
+ endfor ;
+
+ fi ;
+
+enddef ;
+
+vardef lmt_do_overlap_linear =
+ astep := 1 ; % 1.25
+
+ p := origin -- (astep * steps,0) ;
+ r := origin -- (0,astep * steps) ;
+
+ start := 0 ;
+ stop := 0 ;
+ for i=1 upto n:
+ stop := start + lua.mp.lmt_overlap_data(i) ;
+ first := start ;
+ last := stop ;
+ for j=1 upto n:
+ if i <> j :
+ last := first + lua.mp.lmt_overlap_data(i,j) ;
+ qq[i][j] := (first * astep,0) -- (last * astep,0) ;
+ first := last + subgap ;
+ fi ;
+ endfor ;
+ start := stop + gap + (n - 1) * subgap ;
+ endfor ;
+
+ if hasoption "options" "paths" :
+
+ for i=1 upto n :
+ for j=1 upto n :
+ if i < j :
+ qq[i][j] := qq[i][j] { up } .. { down } qq[j][i] { up } .. { down} cycle ;
+ fill qq[i][j] withcolor lua.mp.lmt_overlap_color(i) withtransparency (1,.8) ;
+ fi ;
+ endfor ;
+ endfor ;
+
+ for i=1 upto n :
+ for j=1 upto n :
+ if i < j :
+ t := thelabel(lua.mp.lmt_overlap_text(i,j), (center topboundary qq[i][j]) ) ;
+ fill boundingbox t enlarged (ExHeight/2) withcolor white ;
+ draw t ;
+ fi ;
+ endfor ;
+ endfor ;
+
+ fi ;
+
+ if hasoption "options" "lines" :
+
+ start := 0 ;
+ stop := 0 ;
+ for i=1 upto n:
+ stop := start + lua.mp.lmt_overlap_data(i) + (n - 2) * subgap ;
+ q := (start * astep,0) -- (stop * astep,0) ;
+ freelabeloffset := getparameterdefault "textoffset" (4 * getparameter "offset") ;
+ label.bot(lua.mp.lmt_overlap_label(i), (point .5 along q) shifted (0,- freelabeloffset/4)) ;
+ draw q withcolor white withpen pencircle scaled 5 ;
+ draw q withcolor getparameter "color" withpen pencircle scaled 5 ;
+ start := stop + gap + subgap ;
+ endfor ;
+
+ fi ;
+
+enddef ;
+
+vardef lmt_do_overlap =
+ image (
+
+ pushparameters "overlap" ;
+
+ save p, q, r, s, qq, a, b, c, d, t, n, gap, subgap, steps, astep, start, stop, first, last ;
+ path p, q, r, s, qq[][] ;
+ pair a, b, c, d ;
+ picture t ;
+ numeric n, gap, subgap, steps, astep, start, stop, first, last ;
+ save freelabeloffset; freelabeloffset := 8 ;
+ interim linecap := butt;
+ interim linejoin := squared;
+
+ lua.mp.lmt_overlap_prepare() ;
+
+ n := lua.mp.lmt_overlap_n();
+ gap := getparameter "gap" ;
+ subgap := getparameter "subgap" ;
+ steps := lua.mp.lmt_overlap_total() + (n * gap) + n * (n - 1) * subgap ;
+
+ if ((getparameter "alternative") = "linear") or ((getparameter "alternative") = "line") :
+ lmt_do_overlap_linear ;
+ else :
+ lmt_do_overlap_circular ;
+ fi ;
+
+ lua.mp.lmt_overlap_reset() ;
+
+ popparameters ;
+ )
+enddef ;
+
+\stopMPextensions
+
+\continueifinputfile{meta-imp-experiments.mkxl}
+
+% \useMPlibrary[experiments]
+
+\usemodule[article-basic]
+
+\starttext
+
+% todo: datafile: { data = { }, labels = { } }
+
+% % data = {
+% % { 0, 10, 30, 10, 20 },
+% % { 10, 0, 10, 20, 10 },
+% % { 30, 10, 0, 5, 15 },
+% % { 10, 20, 5, 0, 5 },
+% % { 20, 10, 15, 5, 0 }
+% % },
+% % data = {
+% % { 0 },
+% % { 10, 0 },
+% % { 30, 10, 0 },
+% % { 10, 20, 5, 0 },
+% % { 20, 10, 15, 5, 0 }
+% % },
+% data = {
+% { },
+% { 10 },
+% { 30, 10 },
+% { 10, 20, 5 },
+% { 20, 10, 15, 5 }
+% },
+
+\startbuffer
+\startMPcode{doublefun}
+ draw lmt_overlap [
+ alternative = "circular",
+ data = { { }, { 10 }, { 30, 10 }, { 10, 20, 5 }, { 20, 10, 15, 5 } },
+ labels = { "one", "two", "three", "four", "five" }
+ ] ;
+\stopMPcode
+\stopbuffer
+
+\startlinecorrection[blank]
+ \getbuffer
+\stoplinecorrection
+
+\startbuffer
+\startMPcode{doublefun}
+ draw lmt_overlap [
+ alternative = "linear",
+ data = { { }, { 10 }, { 30, 10 }, { 10, 20, 5 }, { 20, 10, 15, 5 } },
+ labels = { "one", "two", "three", "four", "five" }
+ ] ;
+\stopMPcode
+\stopbuffer
+
+\startlinecorrection[blank]
+ \getbuffer
+\stoplinecorrection
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-gamesymbols.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-gamesymbols.mkxl
new file mode 100644
index 00000000000..d79e59f69f4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-gamesymbols.mkxl
@@ -0,0 +1,349 @@
+%D \module
+%D [ file=meta-imp-gamesymbols,
+%D version=2019.10.10,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Game Symbols,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The \METAFUN\ code here is not optimal and efficient but as it serves as an
+%D example I decided to keep it simple. Also, performance is not really an issue
+%D here anyway. Inspired by the classic \quote {Concrete Mathematics} by Don Knuth
+%D we define dice and dominos, which happen to be \UNICODE\ characters now. We
+%D use this opportunity to demonstrate slightly different approached.
+
+%D Each dice gets it's own macro at the \METAPOST\ end. Watch how we use the \type
+%D {simplefun} instance in combination with a calculation wrapper. This will just
+%D execute the code and leave no traces in the text flow. The code itself is not
+%D that spectacular:
+
+\startMPcalculation{simplefun}
+
+ def DiceFrame =
+ pickup pencircle scaled 1/2 ;
+ draw unitsquare scaled 8 ;
+ pickup pencircle scaled 3/2 ;
+ enddef ;
+
+ vardef DiceOne =
+ DiceFrame ;
+ draw (4,4) ;
+ enddef ;
+ vardef DiceTwoA =
+ DiceFrame ;
+ draw (2,6) ; draw (6,2) ;
+ enddef ;
+ vardef DiceTwoB =
+ DiceFrame ;
+ draw (6,6) ; draw (2,2) ;
+ enddef ;
+ vardef DiceTwo =
+ if hasoption "mpsfont" "option" "reverse" :
+ DiceTwoB
+ else :
+ DiceTwoA
+ fi ;
+ enddef ;
+ vardef DiceThreeA =
+ DiceFrame ;
+ draw (2,6) ; draw (4,4) ; draw (6,2) ;
+ enddef ;
+ vardef DiceThreeB =
+ DiceFrame ;
+ draw (6,6) ; draw (4,4) ; draw (2,2) ;
+ enddef ;
+ vardef DiceThree =
+ if hasoption "mpsfont" "option" "reverse" :
+ DiceThreeB
+ else :
+ DiceThreeA
+ fi ;
+ enddef ;
+ vardef DiceFour =
+ DiceFrame ;
+ draw (2,6) ; draw (6,6) ; draw (2,2) ; draw (6,2) ;
+ enddef ;
+ vardef DiceFive =
+ DiceFrame ;
+ draw (2,6) ; draw (6,6) ; draw (4,4) ; draw (2,2) ; draw (6,2) ;
+ enddef ;
+ vardef DiceSix =
+ DiceFrame ;
+ draw (2,6) ; draw (6,6) ; draw (2,4) ; draw (6,4) ; draw (2,2) ; draw (6,2) ;
+ enddef ;
+
+ vardef DiceBad =
+ pickup pencircle scaled 1/2 ;
+ draw unitsquare scaled 8 ;
+ draw (1,7) -- (7,1) ; draw (1,1) -- (7,7) ;
+ enddef ;
+
+ lmt_registerglyphs [
+ name = "dice",
+ units = 12,
+ width = 8,
+ height = 8,
+ depth = 0,
+ usecolor = true,
+ ] ;
+
+ lmt_registerglyph [ category = "dice", unicode = "0x2680", code = "DiceOne;" ] ;
+ lmt_registerglyph [ category = "dice", unicode = "0x2681", code = "DiceTwo;" ] ;
+ lmt_registerglyph [ category = "dice", unicode = "0x2682", code = "DiceThree;" ] ;
+ lmt_registerglyph [ category = "dice", unicode = "0x2683", code = "DiceFour;" ] ;
+ lmt_registerglyph [ category = "dice", unicode = "0x2684", code = "DiceFive;" ] ;
+ lmt_registerglyph [ category = "dice", unicode = "0x2685", code = "DiceSix;" ] ;
+
+ lmt_registerglyph [ category = "dice", private = "invaliddice", code = "DiceBad;" ] ;
+
+\stopMPcalculation
+
+%D At the \TEX\ end we define three features. The reverse is just there for fun. The
+%D digits features will map digits onto dice.
+
+\definefontfeature
+ [dice:normal]
+ [default]
+ [metapost={category=dice}]
+
+\definefontfeature
+ [dice:reverse]
+ [default]
+ [metapost={category=dice,option=reverse}]
+
+\definefontfeature
+ [dice:digits]
+ [dice:digits=yes]
+
+%D The mapping to dice happens here:
+
+\startluacode
+
+ -- local invalid = fonts.helpers.privateslot("invaliddice")
+
+ fonts.handlers.otf.addfeature("dice:digits", {
+ type = "substitution",
+ order = { "dice:digits" },
+ nocheck = true,
+ data = {
+ [0x30] = "invaliddice",
+ [0x31] = 0x2680,
+ [0x32] = 0x2681,
+ [0x33] = 0x2682,
+ [0x34] = 0x2683,
+ [0x35] = 0x2684,
+ [0x36] = 0x2685,
+ [0x37] = "invaliddice",
+ [0x38] = "invaliddice",
+ [0x39] = "invaliddice",
+ },
+ } )
+
+\stopluacode
+
+%D An example is given at the the end of this file so we now move forward with
+%D the dominos.
+
+\startMPcalculation{simplefun}
+
+ %D Because there are so many dominos we predefine the shapes and then register
+ %D the lot in a loop.
+
+ picture Dominos[] ;
+
+ Dominos[0] := image() ;
+ Dominos[1] := image(draw(4,4);) ;
+ Dominos[2] := image(draw(2,6);draw(6,2););
+ Dominos[3] := image(draw(2,6);draw(4,4);draw(6,2););
+ Dominos[4] := image(draw(2,6);draw(6,6);draw(2,2);draw(6,2););
+ Dominos[5] := image(draw(2,6);draw(6,6);draw(4,4);draw(2,2);draw(6,2););
+ Dominos[6] := image(draw(2,6);draw(4,6);draw(6,6);draw(2,2);draw(4,2);draw(6,2););
+ % Dominos[7] := Dominos[0] ;
+ % Dominos[8] := Dominos[0] ;
+ % Dominos[9] := Dominos[0] ;
+
+ %D Defining the font properties is straightforward:
+
+ lmt_registerglyphs [
+ name = "dominos",
+ units = 12,
+ width = 16,
+ height = 8,
+ depth = 0,
+ usecolor = true,
+ ] ;
+
+ %D We have horizontal dominos:
+
+ def DrawDominoH(expr a, b) =
+ draw image (
+ pickup pencircle scaled 1/2 ;
+ if (getparameterdefault "mpsfont" "color" "") = "black" :
+ fillup unitsquare xyscaled (16,8) ;
+ draw (8,.5) -- (8,7.5) withcolor white ;
+ pickup pencircle scaled 3/2 ;
+ draw Dominos[a]
+ withpen currentpen
+ withcolor white ;
+ draw Dominos[b] shifted (8,0)
+ withpen currentpen
+ withcolor white ;
+ else :
+ draw unitsquare xyscaled (16,8) ;
+ draw (8,0) -- (8,8) ;
+ pickup pencircle scaled 3/2 ;
+ draw Dominos[a]
+ withpen currentpen ;
+ draw Dominos[b] shifted (8,0)
+ withpen currentpen ;
+ fi ;
+ ) ;
+ enddef ;
+
+ %D and vertical ones. We could use the above macro and rotate and shift and reflect
+ %D but why bother with it:
+
+ def DrawDominoV(expr a, b) = % is H rotated and shifted
+ draw image (
+ pickup pencircle scaled 1/2 ;
+ if (getparameterdefault "mpsfont" "color" "") = "black" :
+ fillup unitsquare xyscaled (8,16) ;
+ draw (.5,8) -- (7.5,8) withcolor white ;
+ pickup pencircle scaled 3/2 ;
+ draw Dominos[a] rotatedaround(center Dominos[a],90)
+ withpen currentpen
+ withcolor white ;
+ draw Dominos[b] rotatedaround(center Dominos[b],90) shifted (0,8)
+ withpen currentpen
+ withcolor white ;
+ else :
+ draw unitsquare xyscaled (8,16) ;
+ draw (0,8) -- (8,8) ;
+ pickup pencircle scaled 3/2 ;
+ draw Dominos[a] rotatedaround(center Dominos[a],90)
+ withpen currentpen ;
+ draw Dominos[b] rotatedaround(center Dominos[b],90) shifted (0,8)
+ withpen currentpen ;
+ fi ;
+ ) ;
+ enddef ;
+
+ %D We have two simple loops that define the horizontal range:
+
+ save unicode ; numeric unicode ; unicode := 127025 ; % 1F031
+
+ for i=0 upto 6 :
+ for j=0 upto 6 :
+ lmt_registerglyph [
+ category = "dominos",
+ unicode = unicode,
+ code = "DrawDominoH(" & decimal i & "," & decimal j & ");",
+ width = 16,
+ height = 8,
+ ] ;
+ unicode := unicode + 1 ;
+ endfor ;
+ endfor ;
+
+ %D and the vertical range:
+
+ save unicode ; numeric unicode ; unicode := 127075 ;
+
+ for i=0 upto 6 :
+ for j=0 upto 6 :
+ lmt_registerglyph [
+ category = "dominos",
+ unicode = unicode,
+ code = "DrawDominoV(" & decimal i & "," & decimal j & ");",
+ width = 8,
+ height = 16,
+ ] ;
+ unicode := unicode + 1 ;
+ endfor ;
+ endfor ;
+
+ %D Now we're done at the \METAFUN\ end.
+
+\stopMPcalculation
+
+%D We predefine two features:
+
+\definefontfeature
+ [dominos:white]
+ [default]
+ [metapost={category=dominos}]
+
+\definefontfeature
+ [dominos:black]
+ [default]
+ [metapost={category=dominos,color=black}]
+
+\definefontfeature
+ [dominos:digits]
+ [dominos:digits=yes]
+
+%D This last feature is yet to be defined. We could deal with the invalid
+%D dominos with some substitution trickery but let's keep it simple.
+
+\startluacode
+
+ local ligatures = { }
+ local unicode = 127025
+
+ for i=0x30,0x36 do
+ for j=0x30,0x36 do
+ ligatures[unicode] = { i, j }
+ unicode = unicode + 1 ;
+ end
+ end
+
+ fonts.handlers.otf.addfeature("dominos:digits", {
+ type = "ligature",
+ order = { "dominos:digits" },
+ nocheck = true,
+ data = ligatures,
+ } )
+
+\stopluacode
+
+\continueifinputfile{meta-imp-gamesymbols.mkxl}
+
+\starttext
+
+ \definefont[DominoW][Serif*dominos:white]
+ \definefont[DominoB][Serif*dominos:black]
+ \definefont[DominoD][Serif*dominos:white,dominos:digits]
+
+ \startTEXpage[offset=3pt]
+ \DominoW
+ \char"1F043\quad 🀱\quad
+ \char"1F052\quad 🀲\quad
+ \char"1F038\quad 🀳\quad
+ \darkgreen\char"1F049\quad \char"1F07B\quad
+ \DominoB
+ \char"1F087\quad
+ \char"1F088\quad
+ \char"1F089\quad
+ \DominoD
+ \darkred 12\quad56\quad64%
+ \stopTEXpage
+
+ \definefont[DiceN][Serif*dice:normal]
+ \definefont[DiceR][Serif*dice:reverse]
+ \definefont[DiceD][Serif*dice:normal,dice:digits]
+
+ \startTEXpage[offset=3pt]
+ \DiceN
+ \dostepwiserecurse{"2680}{"2685}{1}{\char#1\quad}%
+ \DiceN
+ \dostepwiserecurse{"2680}{"2685}{1}{\char#1\quad}%
+ \DiceD
+ \darkblue 2\quad5\quad3\quad0
+ \stopTEXpage
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-punk.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-punk.mkxl
new file mode 100644
index 00000000000..b03977f39b3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-punk.mkxl
@@ -0,0 +1,272 @@
+%D \module
+%D [ file=meta-imp-punk,
+%D version=2020.01.16,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Punk,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% This file is a merge of the original punk files by Donald Knuth, who
+% added this comment:
+%
+% Font inspired by Gerard and Marjan Unger's lectures, Feb 1985
+%
+% The regular punk files are part of TeXLive and in metafont format. All
+% errors introduced are ours. We also changed the encoding to unicode. In
+% due time we might add a few more more characters. We still need to
+% improve some of the metrics which involves a bit of trial and error. The
+% font just covers basic latin shapes but in ConTeXt MkIV we add virtual
+% composed shapes. There is a module m-punk.tex that implements this. This
+% derivate is also used in mk.tex (mk.pdf) which is one of our tests for
+% LuaTeX. We published an article on it in the MAPS (NTG magazine).
+%
+% 2008, mkiv variant: Taco Hoekwater & Hans Hagen
+% 2020, lmtx variant: Hans Hagen (playground)
+
+\startMPcalculation{simplefun}
+
+ picture PunkShapes[][];
+
+ numeric PunkId ; PunkId := 0 ;
+ numeric PunkBase ; PunkBase := 0 ;
+ string PunkName ; PunkName := "punk" ;
+ numeric PunkUsed ; PunkUsed := 0 ;
+ numeric PunkSlant ; PunkSlant := 0 ;
+ numeric PunkWeight ; PunkWeight := 1 ;
+ numeric PunkSqueeze ; PunkSqueeze := 1 ;
+ numeric PunkExtend ; PunkExtend := 1 ;
+ numeric PunkVariants ; PunkVariants := 0 ;
+
+ numeric PunkRatio ; PunkRatio := 2/3 ;
+ numeric PunkScale ; PunkScale := 20 ; % when zero we use the knuth values
+ numeric PunkN ; PunkN := 0 ;
+
+ def beginpunkchar(expr c, n, hor, ver) =
+ begingroup ;
+ save uc, w, h, d, hdev, vdev ;
+ hdev := hor * dev ; % modify horizontal amounts of deviation
+ vdev := ver * dev ; % modify vertical amounts of deviation
+ uc := if string c : utfnum(c) else : c fi ;
+ h := if PunkScale > 0 : PunkN else : n fi / PunkSqueeze ;
+ w := n * PunkExtend ;
+ d := 0 ;
+ clearxy ;
+ clearit ;
+ enddef ;
+
+ def endpunkchar =
+ if PunkSlant <> 0 :
+ currentpicture := currentpicture slanted PunkSlant ;
+ fi ;
+ save llx, lly, uly ;
+ llx := xpart llcorner currentpicture ;
+ lly := ypart llcorner currentpicture ;
+ uly := ypart ulcorner currentpicture ;
+
+ currentpicture := currentpicture shifted (- llx + 1, 0);
+ w := bbwidth(currentpicture) + 2 ;
+ h := uly ;
+ d := if lly < 0 : - lly else : 0 fi ;
+
+ PunkUsed := if PunkBase > 0 : PunkBase else : uc fi;
+ PunkShapes[PunkId][PunkUsed] := currentpicture ;
+ lmt_registerglyph [
+ category = PunkName,
+ unicode = PunkUsed,
+ tounicode = uc,
+ width = w,
+ height = h,
+ depth = d,
+ code = "draw PunkShapes[" & decimal PunkId & "][" & decimal PunkUsed & "]",
+ ] ;
+ if PunkBase > 0 :
+ PunkBase := PunkBase + 1 ;
+ fi ;
+ endgroup ;
+ enddef ;
+
+ def initialize_punk_upper =
+ PunkN := PunkScale ;
+ dev := 1 ;
+ enddef ;
+
+ def initialize_punk_lower =
+ PunkN := PunkScale * PunkRatio ;
+ dev := .5 ;
+ enddef ;
+
+ def revert_punk_lower =
+ PunkN := PunkScale ;
+ dev := 1 ;
+ enddef ;
+
+ def beginpunkfont =
+
+ begingroup ;
+
+ save dev;
+
+ save u ; u := 1 ;
+
+ PunkBase := 0 ;
+
+ pen linepen ; linepen := pencircle scaled (PunkWeight * u) ;
+ pen dotpen ; dotpen := linepen scaled 2 slanted -PunkSlant ;
+
+ pickup linepen ;
+
+ save pp ; vardef pp expr z =
+ z + (hdev * normaldeviate, vdev * normaldeviate)
+ enddef ;
+
+ save pd ; def pd expr z =
+ drawdot z withpen dotpen ;
+ enddef ;
+
+ PunkId := PunkId + 1 ;
+
+ lmt_registerglyphs [
+ name = PunkName, % todo: when we do name = name we get ['"name"'] = name
+ units = 25,
+ width = 25,
+ height = 25,
+ depth = 0,
+ usecolor = true,
+ ] ;
+
+ def endchar = endpunkchar enddef ;
+
+ enddef ;
+
+ def endpunkfont =
+ endgroup;
+ enddef ;
+
+ % We started out with immediate:
+
+ % def MakePunkFont (expr name, filename, slant, weight, squeeze, extend) =
+ % begingroup ;
+ % save PunkName, PunkFileName, PunkSlant, PunkWeight, PunkSqueeze, PunkExend, PunkVariants ;
+ % string PunkName, PunkFileName ;
+ % PunkFileName := filename ;
+ % PunkName := name ;
+ % PunkSlant := slant ;
+ % PunkWeight := weight ;
+ % PunkSqueeze := squeeze ;
+ % PunkExtend := extend ;
+ % PunkVariants := 0 ;
+ % beginpunkfont ;
+ % loadfile(PunkFileName) ;
+ % endpunkfont ;
+ % endgroup ;
+ % enddef ;
+ %
+ % MakePunkFont("punk", "punkfont-characters.mp", 1, 0 ) ;
+ % MakePunkFont("punkbold", "punkfont-characters.mp", 2, 0 ) ;
+ % MakePunkFont("punkslanted", "punkfont-characters.mp", 1, 0.15) ;
+ % MakePunkFont("punkboldslanted", "punkfont-characters.mp", 2, 0.15) ;
+
+ % And ended up with delayed:
+
+ def punkpreroll =
+ begingroup ;
+ save PunkName, PunkFileName, PunkSlant, PunkWeight, PunkSqueeze, PunkExtend, PunkVariants ;
+ string PunkName, PunkFileName ;
+ PunkName := getparameterdefault "mpsfont" "name" "punk" ;
+ PunkFileName := getparameterdefault "mpsfont" "filename" "punkfont-characters.mp" ;
+ PunkSlant := scantokens(getparameterdefault "mpsfont" "slant" "0") ;
+ PunkWeight := scantokens(getparameterdefault "mpsfont" "weight" "1") ;
+ PunkSqueeze := scantokens(getparameterdefault "mpsfont" "squeeze" "1") ;
+ PunkExtend := scantokens(getparameterdefault "mpsfont" "extend" "1") ;
+ PunkVariants := scantokens(getparameterdefault "mpsfont" "variants" "0");
+ beginpunkfont ;
+ loadfile(PunkFileName) ;
+ if PunkVariants > 0 :
+ PunkBase := 57344 ; % 0xE000 ; 0xF0000 ;
+ for i=1 upto PunkVariants :
+ loadfile(PunkFileName) ;
+ endfor ;
+ fi ;
+ endpunkfont ;
+ endgroup ;
+ enddef ;
+
+\stopMPcalculation
+
+% Are these names okay? If so it can go into the core.
+
+\permanent\protected\def\enablerandomvariants{\setcharactercasing[randomvariant]}
+\permanent\protected\def\randomvariants {\groupedcommand\enablerandomvariants\donothing}
+\permanent\protected\def\startrandomvariants {\begingroup\enablerandomvariants}
+\permanent\protected\def\stoprandomvariants {\endgroup}
+
+\definefontfeature [punk] [metapost={category=punk,preroll=punkpreroll}]
+\definefontfeature [punkrandom] [metapost={category=punk,preroll=punkpreroll,variants=10}]
+\definefontfeature [punkbold] [metapost={category=punk,preroll=punkpreroll,weight=2}]
+\definefontfeature [punkslanted] [metapost={category=punk,preroll=punkpreroll,slant=.15}]
+\definefontfeature [punkboldslanted] [metapost={category=punk,preroll=punkpreroll,slant=.15,weight=2}]
+\definefontfeature [punkveryslanted] [metapost={category=punk,preroll=punkpreroll,slant=-.15}]
+\definefontfeature [punksqueezed] [metapost={category=punk,preroll=punkpreroll,squeeze=.5}]
+\definefontfeature [punkextended] [metapost={category=punk,preroll=punkpreroll,extend=1.3}]
+
+\continueifinputfile{meta-imp-punk.mkxl}
+
+% immediate:
+%
+% \definefontfeature [punk] [metapost=punk]
+% \definefontfeature [punkbold] [metapost=punkbold]
+% \definefontfeature [punkslanted] [metapost=punkslanted]
+% \definefontfeature [punkboldslanted] [metapost=punkboldslanted]
+
+% delayed:
+
+% name=punk
+% filename=punkfont-characters.mp
+
+\setupbodyfont[dejavu]
+
+\definefont[PunkA][Serif*punk]
+\definefont[PunkB][Serif*punkbold]
+\definefont[PunkC][Serif*punkslanted]
+\definefont[PunkD][Serif*punkboldslanted]
+\definefont[PunkE][Serif*punkveryslanted]
+\definefont[PunkF][Serif*punkrandom]
+\definefont[PunkG][Serif*punksqueezed]
+\definefont[PunkH][Serif*punkextended]
+
+\starttext
+
+\startTEXpage[offset=10pt,width=30cm]
+ % \showglyphs
+ {\darkcyan \PunkA \samplefile{tufte} \par}
+ {\darkmagenta \PunkB \samplefile{tufte} \par}
+ {\darkred \PunkC \samplefile{tufte} \par}
+ {\darkgreen \PunkD \samplefile{tufte} \par}
+ {\darkblue \PunkE \samplefile{tufte} \par}
+ {\darkyellow \PunkF \enablerandomvariants \samplefile{tufte} \par}
+ {\darkgray \PunkG \samplefile{tufte} \par}
+ {\darkorange \PunkH \samplefile{tufte} \par}
+\stopTEXpage
+
+\startTEXpage[offset=10pt,width=20cm]
+ \PunkF \enablerandomvariants
+ \dostepwiserecurse{1}{2000}{1}{\glyphscale#1\relax f }
+\stopTEXpage
+
+% \setupbodyfont[dejavu] % one first needs to load a bodyfont !
+
+\setupbodyfont[punk]
+
+\startTEXpage[offset=10pt,width=20cm]
+ {\darkcyan \tf \samplefile{zapf} \par}
+ {\darkmagenta \bf \samplefile{zapf} \par}
+ {\darkred \sl \samplefile{zapf} \par}
+ {\darkgreen \bs \samplefile{zapf} \par}
+\stopTEXpage
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-symbols.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-symbols.mkxl
new file mode 100644
index 00000000000..f88fd6f8787
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-symbols.mkxl
@@ -0,0 +1,99 @@
+%D \module
+%D [ file=meta-imp-symbols,
+%D version=2019.10.01,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Symbols,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is an (experimental) prelude to more.
+
+\startMPcalculation{simplefun}
+
+ pen SymbolPen ; SymbolPen := pencircle scaled 1/4 ;
+
+ vardef SymbolBullet = fill unitcircle scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x2022 •
+ vardef SymbolDash = draw (origin--right) scaled 3 shifted (1.5,3.0) withpen SymbolPen scaled 2 enddef ; % 0x2013 –
+ vardef SymbolTriangle = draw unittriangle scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25B6 ⊳
+ vardef SymbolCircle = fill unitcircle scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x2218 ∘
+ vardef SymbolSquare = draw unitsquare scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25A1 □
+ vardef SymbolDiamond = draw unitdiamond scaled 3 shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x22C4 ⋄
+ vardef SymbolBlackTriangle = fillup unittriangle scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25B6 ▶
+ vardef SymbolBlackSquare = fillup unitsquare scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25A0 ■
+ vardef SymbolBlackDiamond = fillup unitdiamond scaled (3-1/16) shifted (1.5,1.5) withpen SymbolPen enddef ; % 0x25C6 ◆
+
+ vardef SymbolNotDef =
+ draw center unitcircle
+ scaled 3
+ shifted (1.5,1.5)
+ withpen SymbolPen scaled 4
+ enddef ;
+
+ vardef SymbolStar = % 0x22C6 % ⋆
+ SymbolNotDef
+ enddef ;
+
+ vardef SymbolCheckmark = % 0x2713 ✓
+ SymbolNotDef
+ enddef ;
+
+ vardef SymbolAsterisk = % 0x2217 ∗
+ SymbolNotDef
+ enddef ;
+
+ % We could set code directly to the meaning of the macro.
+
+ lmt_registerglyphs [
+ name = "symbols",
+ units = 10,
+ usecolor = true,
+ width = 6,
+ height = 6,
+ depth = 0,
+ code = "SymbolNotDef ;",
+ ] ;
+
+ lmt_registerglyph [ category = "symbols", unicode = "0x2022", code = "SymbolBullet ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x2013", code = "SymbolDash ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x22C6" ] ; % , code = "SymbolStar ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x22B3", code = "SymbolTriangle ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x2218", code = "SymbolCircle ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x25A1", code = "SymbolSquare ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x22C4", code = "SymbolDiamond ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x2713" ] ; % , code = "SymbolCheckmark ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x2217" ] ; % , code = "SymbolAsterisk ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x25B6", code = "SymbolBlackTriangle ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x25A0", code = "SymbolBlackSquare ;" ] ;
+ lmt_registerglyph [ category = "symbols", unicode = "0x25C6", code = "SymbolBlackDiamond ;" ] ;
+
+\stopMPcalculation
+
+\continueifinputfile{meta-imp-symbols.mkxl}
+
+\usemodule[article-basic] \setupbodyfont[pagella]
+
+\starttext
+
+\definefontfeature[metasymbols][metapost=symbols]
+
+\definefont[MyFont] [Serif*default,metasymbols sa 1]
+
+Some metasymbols:
+
+\startitem {\MyFont • □ ◆}\quad Regular rendering. \stopitem
+\startitem {\MyFont\red • □ ◆}\quad Rendering with color. \stopitem
+\startitem {\MyFont\blue\showglyphs • □ ◆}\quad Idem but with boundingboxes shown. \stopitem
+
+And some more:
+
+\startlines
+ • – ⋆ ⊳ ∘ □ ⋄ ✓ ∗ ▶ ■ ◆
+ {\MyFont • – ⋆ ⊳ ∘ □ ⋄ ✓ ∗ ▶ ■ ◆}
+\stoplines
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-threesix.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-threesix.mkxl
new file mode 100644
index 00000000000..56a400b45c0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-threesix.mkxl
@@ -0,0 +1,246 @@
+%D \module
+%D [ file=meta-imp-threesix,
+%D version=2019.00.00,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Don Knuths ThreeSix font,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The design of the font is if course by Don Knuth and can be found in facs9b.ps. I
+%D wish I was clever enough to understand all the good stuff in there.
+
+\startluacode
+ local unpack = unpack
+ local concat = table.concat
+ local gsub, gmatch, utfbyte = string.gsub, string.gmatch, utf.byte
+
+ local font36 = {
+ ["0"] = [[00111100 01111110 11000011 11000011 11000011 11000011 01111110 00111100]],
+ ["1"] = [[00011100 11111100 11101100 00001100 00001100 00001100 11111111 11111111]],
+ ["2"] = [[00111110 01110011 01110011 00000011 00001110 00111000 11110001 11111111]],
+ ["3"] = [[01111110 01100110 00000110 00111100 00000110 11100111 11100111 01111110]],
+ ["4"] = [[00001110 00011110 00110110 01100110 11111111 11111111 00000110 00001110]],
+ ["5"] = [[01111110 01111110 01000000 01111100 01000111 00000011 11000111 11111110]],
+ ["6"] = [[01111110 01100110 11000000 11011100 11100110 11000011 01100011 01111110]],
+ ["7"] = [[11111111 11111111 10000111 10001110 00011100 00011100 00011100 00011100]],
+ ["8"] = [[01111110 01100110 01100110 00111100 11000011 11000011 11000011 01111110]],
+ ["9"] = [[01111110 11000110 11000011 01100111 00111011 00000011 01100110 01111110]],
+ ["A"] = [[000110000 000111000 001111100 001101100 011001110 011111110 010000110 111100111]],
+ ["B"] = [[1111100 1110110 0110110 0111100 0110011 0110011 1110011 1111100]],
+ ["C"] = [[01111101 11110011 11100001 11100001 11100000 11100000 11100001 01111110]],
+ ["D"] = [[11111100 11100010 01100011 01100011 01100011 01100011 11100010 11111100]],
+ ["E"] = [[1111111 1110001 0110101 0111100 0110100 0110001 1110001 1111111]],
+ ["F"] = [[11111111 11100001 01100101 01111100 01100100 01100000 11111000 11111000]],
+ ["G"] = [[01111010 11100110 11100010 11100000 11100111 11100010 11100010 01111100]],
+ ["H"] = [[11100111 11100111 01000010 01111110 01000010 01000010 11100111 11100111]],
+ ["I"] = [[1111111 1111111 0011000 0011000 0011000 0011000 1111111 1111111]],
+ ["J"] = [[01111111 01111111 00000110 00000110 11110110 01100110 01100110 00111100]],
+ ["K"] = [[11101110 11100100 01101000 01110000 01111000 01101100 11100110 11101111]],
+ ["L"] = [[111111000 111111000 011000000 011000000 011000000 011000011 111000011 111111111]],
+ ["M"] = [[1100000011 1110000111 0111111110 0100110010 0100110010 0100000010 1100000011 1100000011]],
+ ["N"] = [[11000011 11100011 01110010 01111010 01011110 01001110 11100110 11100010]],
+ ["O"] = [[01111110 11000011 11000011 11000011 11000011 11000011 11000011 01111110]],
+ ["P"] = [[11111110 11100011 01100011 01111110 01100000 01100000 11111000 11111000]],
+ ["Q"] = [[01111100 11000110 11000110 11000110 11000110 11001110 11000110 01111101]],
+ ["R"] = [[11111100 11100110 01100110 01111100 01101000 01100100 11100010 11100111]],
+ ["S"] = [[01111110 11100001 11100001 01111000 00011110 10000111 11000011 10111110]],
+ ["T"] = [[1111111111 1100110011 1100110011 0000110000 0000110000 0000110000 0001111000 0001111000]],
+ ["U"] = [[111101111 111101111 011000010 011000010 011000010 011000010 011000010 001111100]],
+ ["V"] = [[11111000111 11111000111 01110000010 00110000100 00111000100 00011001000 00001101000 00001110000]],
+ ["W"] = [[111000000111 111000000111 110000000010 011000000100 011001000100 001101101000 001101101000 000110110000]],
+ ["X"] = [[1111001110 1111000110 0001101000 0000110000 0000110000 0001011000 0110001111 0111001111]],
+ ["Y"] = [[111100011 111100011 011000010 001110100 000111000 000011000 001111110 001111110]],
+ ["Z"] = [[11111111 10000111 00001110 00011100 00111000 01110000 11100001 11111111]],
+ }
+
+ local f_code = string.formatters["ThreeSix(%s);"]
+ local replace = { ["0"] = "N;", ["1"] = "Y;", [" "] = "L;" }
+
+ local function remap(str)
+ -- permit abundant spacing (bonus)
+ str = gsub(str,"%s+", " ")
+ -- remap what we got to macro calls
+ str = gsub(str,".",replace)
+ -- return the result
+ return str
+ end
+
+ function MP.registerthreesix(name)
+ fonts.dropins.registerglyphs {
+ name = name,
+ units = 12,
+ usecolor = true,
+ preamble = "InitializeThreeSix;",
+ }
+ for u, v in table.sortedhash(font36) do
+ local data = remap(v)
+ local ny = 8
+ local nx = ((#v + 1) // ny) - 1
+ local height = ny * 1.1 - 0.1
+ local width = nx * 1.1 - 0.1
+ fonts.dropins.registerglyph {
+ category = name,
+ unicode = utfbyte(u),
+ width = width,
+ height = height,
+ code = f_code(data),
+ }
+ end
+ end
+ MP.registerthreesix("fontthreesix")
+\stopluacode
+
+\startMPcalculation{simplefun}
+ def InitializeThreeSix =
+ save Y, N, L, S ;
+ save shape, fillcolor, mypen, random, threesixpen, spread, hoffset ;
+ string shape, fillcolor, mypen ; boolean random ; pen threesixpen ;
+ shape := getparameterdefault "mpsfont" "shape" "circle" ;
+ random := hasoption "mpsfont" "random" "true" ;
+ fillcolor := getparameterdefault "mpsfont" "color" "" ;
+ mypen := getparameterdefault "mpsfont" "pen" "" ;
+ spread := getparameterdefault "mpsfont" "spread" 0 ;
+ hoffset := 12 * spread / 2 ;
+ threesixpen := pencircle
+ if mypen = "fancy" :
+ xscaled 1/20 yscaled 2/20 rotated 45
+ else :
+ scaled 1/20
+ fi ;
+ if shape == "square" :
+ def S =
+ unitsquare if random : randomized 1/10 fi
+ shifted (nx,ny)
+ enddef ;
+ elseif shape = "diamond" :
+ def S =
+ unitdiamond if random : randomized 1/10 fi
+ shifted (nx,ny)
+ enddef ;
+ else :
+ def S =
+ unitcircle if random : randomizedcontrols 1/20 fi
+ shifted (nx,ny)
+ enddef ;
+ fi ;
+ if fillcolor = "" :
+ def N =
+ nx := nx + dx ;
+ draw S ;
+ enddef ;
+ else :
+ def N =
+ nx := nx + dx ;
+ draw S withcolor "lightgray" ;
+ enddef ;
+ fi ;
+ if fillcolor = "random" :
+ def Y =
+ nx := nx + dx ;
+ fillup S withcolor white randomized (2/3,2/3,2/3) ;
+ enddef ;
+ elseif fillcolor = "" :
+ def Y =
+ nx := nx + dx ;
+ fillup S ;
+ enddef ;
+ else :
+ def Y =
+ nx := nx + dx ;
+ fillup S withcolor fillcolor ;
+ enddef ;
+ fi ;
+ def L =
+ nx := - dx ;
+ ny := ny + dy ;
+ enddef ;
+ enddef ;
+
+ vardef ThreeSix (text code) =
+ save dx, dy, nx, ny ;
+ dx := 11/10 ;
+ dy := - 11/10 ;
+ nx := - dx ;
+ ny := 0 ;
+ pickup threesixpen ;
+ draw image (code) shifted (hoffset,-ny) ;
+ enddef ;
+\stopMPcalculation
+
+\definefontfeature % black and white, with some spread
+ [fontthreesix]
+ [default]
+ [metapost=fontthreesix]
+
+\definefontfeature % color, with some spread
+ [fontthreesix-tweak]
+ [default]
+ [metapost={category=fontthreesix,spread=.1}]
+
+\definefontfeature % color, with some spread
+ [fontthreesix-color]
+ [default]
+ [metapost={category=fontthreesix,shape=diamond,color=random,pen=fancy,spread=.1}]
+
+\definefontfeature % color, tight
+ [fontthreesix-initial]
+ [metapost={category=fontthreesix,color=random,shape=circle}] % units?
+
+\definefont[DEKFontA][Serif*fontthreesix]
+\definefont[DEKFontB][Serif*fontthreesix-color]
+\definefont[DEKFontC][Serif*fontthreesix-initial]
+\definefont[DEKFontD][Serif*fontthreesix-tweak]
+
+\continueifinputfile{meta-imp-threesix.mkxl}
+
+\starttext
+
+\definefontfeature % color, with some spread
+ [fontthreesix-color]
+ [default]
+ [metapost={category=fontthreesix,shape=diamond,color=random,pen=fancy,spread=.1,random=yes}]
+
+\definefont[DEKFontA][Serif*fontthreesix-color @ 200pt]
+\definefont[DEKFontB][Serif*fontthreesix-color @ 60pt]
+
+% Or course:
+
+\startTEXpage
+ \DEKFontA TEX
+\stopTEXpage
+
+\startTEXpage
+ \DEKFontA T\kern-0.05em\lower.75\exheight\hbox{E}\kern-.05emX
+\stopTEXpage
+
+% One of the \CONTEXT\ 2020 posters (inspired by NewYork State AC's press
+% conferences as these keywords apply quite well to the audience of the
+% meeting):
+
+% \startTEXpage[align={lohi,middle,nothyphenated},offset=20pt]
+% \offinterlineskip \vskip10pt
+% \DEKFontA T\kern-0.05em\lower.75\exheight\hbox{E}\kern-.05emX \vskip60pt
+% \DEKFontB TOUGH \vskip20pt
+% SMART \vskip20pt
+% UNITED \vskip20pt
+% DISCIPLINED \vskip20pt
+% LOVING \vskip10pt
+% \stopTEXpage
+
+\startpagemakeup
+ \setupalign[middle,nothyphenated]
+ \offinterlineskip \vfil\vfil
+ \DEKFontA T\kern-0.05em\lower.75\exheight\hbox{E}\kern-.05emX \vfil\vfil\vfil
+ \DEKFontB TOUGH \vfil
+ SMART \vfil
+ UNITED \vfil
+ DISCIPLINED \vfil
+ LOVING \vfil
+\stoppagemakeup
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-imp-txt.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-txt.mkxl
new file mode 100644
index 00000000000..c7586264ec3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-imp-txt.mkxl
@@ -0,0 +1,277 @@
+%D \module
+%D [ file=meta-txt,
+%D version=2000.07.06,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Text Tricks,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D See comments in the \MKIV\ module. This is an upgraded version for \LMTX,
+%D where we can so some things nicer.
+
+\unprotect
+
+%D Text in shapes. Here we use the option to prune a parshape when a new paragraph
+%D is seen. It's an experimental feature so I need to keep an eye on how it evolves.
+%D This time we combine \TEX, \METAPOST\ and \LUA, so we do't need a temporary file
+%D to communicate from \METAPOST\ to \TEX. We just store information in \LUA\ tables.
+
+\ifdefined\startshapetext \else
+ \writestatus{system}{something is wrong here}
+\fi
+
+%D Following:
+
+% \doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]}
+%
+% \unexpanded\def\getfollowtoken#1%
+% {\hbox\bgroup
+% \strut
+% \ctxlua{mp.follow_text(#1)}%
+% \egroup}
+
+\definefontfeature[mp:tp][liga=no]
+
+% if unknown RotPath : path RotPath ; RotPath := origin ; fi ;
+% if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ;
+% if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ;
+% if al < len[n]:
+% RotPath := RotPath scaled ((len[n]+ExtraRot)/al) ;
+% al := arclength RotPath ;
+% fi ;
+% if TraceRot :
+% draw RotPath withpen pencircle scaled 1pt withcolor blue ;
+% fi ;
+% if TraceRot :
+% draw boundingbox currentpicture withpen pencircle scaled .25pt withcolor blue ;
+% fi ;
+
+\protected\def\dofollowtokens#1#2%
+ {\dontleavehmode
+ \vpack\bgroup
+ \forgetall
+ \dontcomplain
+ \addff{mp:tp}%
+ \startMPcode
+ \includeMPgraphic{followtokens}
+ draw lmt_followtext [ path = RotPath, text = "#2", spread = #1 ] ;
+ \stopMPcode
+ \egroup}
+
+\protected\def\followtokens {\dofollowtokens{true}}
+\protected\def\followtokenscentered{\dofollowtokens{false}}
+
+%D Fuzzy counters:
+
+\startuseMPgraphic{fuzzycount}
+ begingroup
+ save height, span, drift, d, cp ;
+ height := 3/ 5 * LineHeight ;
+ span := 1/ 3 * height ;
+ drift := 1/10 * height ;
+ pickup pencircle scaled (1/12 * height) ;
+ def d = (uniformdeviate drift) enddef ;
+ for i := 1 upto \MPvar{n} :
+ draw
+ if (i mod 5)=0 : ((-d - 4.5span,d) -- (d -0.5span,height - d))
+ else : ((-d, d) -- (d, height - d)) fi
+ shifted (span*i,d-drift) ;
+ endfor;
+ picture cp ; cp := currentpicture ; % for readability
+ setbounds currentpicture to
+ (llcorner cp shifted (0,-ypart llcorner cp) --
+ lrcorner cp shifted (0,-ypart lrcorner cp) --
+ urcorner cp --
+ ulcorner cp -- cycle) ;
+ endgroup ;
+\stopuseMPgraphic
+
+\setupMPvariables
+ [fuzzycount]
+ [n=10]
+
+\protected\def\fuzzycount#1%
+ {\dontleavehmode\bgroup
+ \tx
+ \useMPgraphic{fuzzycount}{n=#1}%
+ \egroup}
+
+\defineconversion[fuzzy][\fuzzycount]
+
+%D English rules:
+
+\setupMPvariables
+ [EnglishRule]
+ [height=1ex,
+ width=\localhsize,
+ color=darkgray]
+
+\defineblank
+ [EnglishRule]
+ [medium]
+
+\startuniqueMPgraphic{EnglishRule}{height,width,color}
+ x1 = 0 ; x3 = \MPvar{width} ; x2 = x4 = .5x3 ;
+ y1 = y3 = 0 ; y2 = -y4 = \MPvar{height} / 2 ;
+ fill z1 .. z2 .. z3 & z3 .. z4 .. z1 & cycle withcolor \MPvar{color} ;
+\stopuniqueMPgraphic
+
+\protected\def\EnglishRule
+ {\startlinecorrection[EnglishRule]%
+ \setlocalhsize
+ \noindentation
+ \reuseMPgraphic{EnglishRule}%
+ \stoplinecorrection}
+
+%D Tight text (for old times sake): the following macro returns a tight bound
+%D character sequence.
+%D
+%D \useMPlibrary[txt]
+%D
+%D \startlinecorrection
+%D \TightText{\ss\bf 123}{0cm}{3cm}{red}
+%D \stoplinecorrection
+
+\protected\def\TightText#1#2#3#4%
+ {\hpack
+ {\startMPcode
+ picture p ; p := image (graphictext "#1" withfillcolor red) ;
+ draw p xsized #2 ysized #3 withcolor \MPcolor{#4} ;
+ \stopMPcode}}
+
+\protected\def\TightText#1#2#3#4%
+ {\dontleavehmode
+ \startMPcode
+ draw outlinetext.f ("#1") (\iftok{#4}\emptytoks \else withcolor \MPcolor{#4} \fi)
+ \iftok{#2}\emptytoks \else xsized #2 \fi
+ \iftok{#3}\emptytoks \else ysized #3 \fi
+ ;
+ \stopMPcode}
+
+\protect
+
+\continueifinputfile{meta-imp-txt.mkxl}
+
+\setupbodyfont[pagella,10pt]
+
+% \useMPlibrary[txt]
+
+\starttext
+
+%D Shapes:
+
+\startuseMPgraphic{test 1}
+ path p ; p := fullcircle scaled 6cm ;
+
+ build_parshape(p,BodyFontSize/2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
+
+ draw p withpen pencircle scaled 1pt ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{test 2}
+ path p ; p := fullsquare rotated 45 scaled 5cm ;
+
+ build_parshape(p,BodyFontSize/2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
+
+ draw p withpen pencircle scaled 1pt ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{test 3}
+ numeric w, h ; w := h := 6cm ;
+ path p ; p := (.5w,h) -- (0,h) -- (0,0) -- (w,0) &
+ (w,0) .. (.75w,.5h) .. (w,h) & (w,h) -- cycle ;
+
+ build_parshape(p,BodyFontSize/2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
+
+ draw p withpen pencircle scaled 1pt ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{test 4}
+ numeric w, h, o, d ;
+
+ def shape = (o,o) -- (w-o,o) & (w-o,o) .. (.75w-o,.5h) ..
+ (w-2o,h-o) & (w-2o,h-o) -- (o,h-o) -- cycle
+ enddef ;
+
+ d := BodyFontSize/2;
+
+ w := h := 6cm ; o := d ; path p ; p := shape ;
+ w := h := 6cm ; o := 0 ; path q ; q := shape ;
+
+ build_parshape(p,q,d,d,LineHeight,StrutHeight,StrutDepth,StrutHeight) ;
+
+ draw q withpen pencircle scaled 1pt ;
+\stopuseMPgraphic
+
+\defineoverlay[test 1][\useMPgraphic{test 1}]
+\defineoverlay[test 2][\useMPgraphic{test 2}]
+\defineoverlay[test 3][\useMPgraphic{test 3}]
+\defineoverlay[test 4][\useMPgraphic{test 4}]
+
+\startbuffer
+\startshapetext[test 1,test 2,test 3,test 4]
+ \setupalign[verytolerant,stretch,normal]%
+ \samplefile{douglas} % Douglas R. Hofstadter
+\stopshapetext
+\startTEXpage[offset=10pt]
+ \startcombination[2*2]
+ {\framed[offset=overlay,frame=off,background=test 1]{\getshapetext}} {test 1}
+ {\framed[offset=overlay,frame=off,background=test 2]{\getshapetext}} {test 2}
+ {\framed[offset=overlay,frame=off,background=test 3]{\getshapetext}} {test 3}
+ {\framed[offset=overlay,frame=off,background=test 4]{\getshapetext}} {test 4}
+ \stopcombination
+\stopTEXpage
+\stopbuffer
+
+\getbuffer
+
+\startMPextensions
+ boolean trace_parshape ; trace_parshape := true ;
+\stopMPextensions
+
+\getbuffer
+
+%D Fuzzycount (maybe handy):
+
+\startitemize[fuzzy,nostopper]
+ \startitem This is real fuzzy. \stopitem
+ \startitem But it can be even more fuzzier. \stopitem
+ \startitem And how about this. \stopitem
+\stopitemize
+
+\EnglishRule
+
+\startitemize[continue,broad]
+ \startitem This is real fuzzy. \stopitem
+ \startitem But it can be even more fuzzier. \stopitem
+ \startitem And how about this. \stopitem
+\stopitemize
+
+%D Tight text (manual stuff):
+
+\ruledhbox{\TightText{oeps wat doet dit}{10cm}{1cm}{red}} \blank
+\ruledhbox{\TightText{oeps wat doet dit}{10cm}{} {green}} \blank
+\ruledhbox{\TightText{oeps wat doet dit}{} {1cm}{blue}} \blank
+\ruledhbox{\TightText{oeps wat doet dit}{} {} {}} \blank
+
+%D Old fashioned:
+
+\startuseMPgraphic{followtokens}
+ path RotPath ; RotPath := reverse halfcircle xyscaled 3cm ;
+ draw RotPath ;
+\stopuseMPgraphic
+
+\startTEXpage
+ \followtokens{{\hskip1em}some text{\hskip1em}}
+\stopTEXpage
+
+\startTEXpage
+ \followtokenscentered{{\hskip1em}some text{\hskip1em}}
+\stopTEXpage
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/meta-ini.lmt
new file mode 100644
index 00000000000..ed7b2264f5d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-ini.lmt
@@ -0,0 +1,161 @@
+if not modules then modules = { } end modules ['meta-ini'] = {
+ version = 1.001,
+ comment = "companion to meta-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local tonumber = tonumber
+local format = string.format
+local concat = table.concat
+local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local P, Cs, R, S, C, Cc = lpeg.P, lpeg.Cs, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc
+
+metapost = metapost or { }
+local metapost = metapost
+local context = context
+
+local colorhash = attributes.list[attributes.private('color')]
+local textype = tex.type
+local MPcolor = context.MPcolor
+
+do
+
+ local dimenorname =
+ lpegpatterns.validdimen / function(s)
+ context("\\the\\dimexpr %s",s)
+ end
+ + (C(lpegpatterns.float) + Cc(1)) * lpegpatterns.space^0 * P("\\") * C(lpegpatterns.letter^1) / function(f,s)
+ local t = textype(s)
+ if t == "dimen" then
+ context("\\the\\dimexpr %s\\%s\\relax",f,s)
+ elseif t == "count" then
+ context("\\the\\numexpr \\%s * %s\\relax",s,f) -- \scratchcounter is not permitted
+ end
+ end
+
+ local splitter = lpeg.splitat("::",true)
+
+ interfaces.implement {
+ name = "prepareMPvariable",
+ arguments = "string",
+ actions = function(v)
+ if v == "" then
+ -- MPcolor("black")
+ context("black")
+ else
+ local typ, var = lpegmatch(splitter,v)
+ if not var then
+ -- parse
+ if colorhash[v] then
+ -- MPcolor(v)
+ context("%q",var)
+ elseif tonumber(v) then
+ context(v)
+ elseif not lpegmatch(dimenorname,v) then
+ context("\\number %s",v) -- 0.4 ...
+ end
+ elseif typ == "d" then -- to be documented
+ -- dimension
+ context("\\the\\dimexpr %s\\relax",var)
+ elseif typ == "n" then -- to be documented
+ -- number
+ context("\\the\\numexpr %s\\relax",var)
+ elseif typ == "s" then -- to be documented
+ -- string
+ -- context(var)
+ context("%q",var)
+ elseif typ == "c" then -- to be documented
+ -- color
+ -- MPcolor(var)
+ context("%q",var)
+ else
+ context(var)
+ end
+ end
+ end
+ }
+
+end
+
+do
+
+ local ctx_mathematics = context.mathematics
+
+ -- function metapost.formatnumber(f,n) -- just lua format
+ -- f = gsub(f,"@(%d)","%%.%1")
+ -- f = gsub(f,"@","%%")
+ -- f = format(f,tonumber(n) or 0)
+ -- f = gsub(f,"e([%+%-%d]+)",function(s)
+ -- return format("\\times10^{%s}",tonumber(s) or s) -- strips leading zeros
+ -- end)
+ -- context.mathematics(f)
+ -- end
+
+ -- formatters["\\times10^{%N}"](s) -- strips leading zeros too
+
+ local one = Cs((P("@")/"%%." * (R("09")^1) + P("@")/"%%" + 1)^0)
+ local two = Cs((P("e")/"" * ((S("+-")^0 * R("09")^1) / function(s)
+ -- return format("\\times10^{%s}",tonumber(s) or s)
+ return "\\times10^{" .. (tonumber(s) or s) .."}"
+ end) + 1)^1)
+
+ -- local two = Cs((P("e")/"" * ((S("+-")^0 * R("09")^1) / formatters["\\times10^{%N}"]) + 1)^1)
+
+ function metapost.formatnumber(fmt,n) -- just lua format
+ ctx_mathematics(lpegmatch(two,format(lpegmatch(one,fmt),n)))
+ end
+
+end
+
+do
+
+ -- this is an old pass-data-to-tex mechanism
+
+ local ctx_printtable = context.printtable
+
+ local data = false
+
+ function mp.mf_start_saving_data(n)
+ data = { }
+ end
+
+ function mp.mf_stop_saving_data()
+ if data then
+ -- nothing
+ end
+ end
+
+ function mp.mf_finish_saving_data()
+ if data then
+ -- nothing
+ end
+ end
+
+ function mp.mf_save_data(str)
+ if data then
+ data[#data+1] = str
+ end
+ end
+
+ local function getdata()
+ if data then
+ ctx_printtable(data,"\r")
+ end
+ end
+
+ interfaces.implement {
+ name = "getMPdata",
+ public = true,
+ protected = true,
+ actions = getdata,
+ }
+
+ interfaces.implement {
+ name = "rawMPdata",
+ public = true,
+ actions = getdata,
+ }
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-ini.mkxl
new file mode 100644
index 00000000000..823d369f0af
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-ini.mkxl
@@ -0,0 +1,1336 @@
+%D \module
+%D [ file=meta-ini,
+%D version=2008.03.25,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\ currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Some lmtx upgrading work needs to be done here.
+%D
+%D For real \METAFUN\ magic see \type {https://art-aleatoire.com/}.
+
+% initializations:
+%
+% - pass settings from tex to mp (delayed expansion)
+% - used by context core (and modules)
+% - cummulative definitions
+% - flushed each graphic
+% - can be disabled per instance
+% - managed at the tex end
+%
+% extensions:
+%
+% - add mp functionality (immediate expansion)
+% - cummulative
+% - all instances or subset of instances
+% - can be disabled per instance
+% - managed at the lua/mp end
+% - could be managed at the tex end but no real reason and also messy
+%
+% definitions:
+%
+% - add mp functionality (delayed expansion)
+% - cummulative
+% - per instance
+% - managed at the tex end
+%
+% inclusions:
+%
+% - add mp functionality (delayed expansion)
+% - cummulative only when [+]
+% - per instance
+% - managed at the tex end
+%
+% order of execution:
+%
+% definitions
+% extensions
+% inclusions
+% beginfig
+% initializations
+% graphic
+% endfig
+
+% The instance will be implemented stepwise ... I should redo some code in order to
+% make the macros look better than they do now.
+
+\writestatus{loading}{MetaPost Graphics / Initializations}
+
+\registerctxluafile{meta-ini}{autosuffix}
+
+\unprotect
+
+\newtoks \everyMPgraphic % mp % public or not ?
+
+\appendtoks
+ \restoreendofline % see interferences-001.tex
+\to \everyMPgraphic
+
+\mutable \def\MPruntimefile {mprun}
+\mutable \def\currentMPformat {metafun}
+\immutable\def\defaultMPinstance{metafun}
+
+\installcorenamespace{mpinstance}
+\installcorenamespace{mpinclusions}
+\installcorenamespace{mpdefinitions}
+\installcorenamespace{mpgraphic}
+\installcorenamespace{mpstaticgraphic}
+\installcorenamespace{mpclip}
+
+\newtoks \t_meta_initializations % tex, each
+
+\permanent\def\t_meta_inclusions {\csname\??mpinclusions \currentMPinstance\endcsname} % token register
+\permanent\def\t_meta_definitions{\csname\??mpdefinitions\currentMPinstance\endcsname} % token register
+
+%D The next command is, of course, dedicated to Mojca, who needs it for gnuplot.
+%D Anyway, the whole multiple engine mechanism is to keep her gnuplot from
+%D interfering.
+
+\permanent\tolerant\protected\def\startMPdefinitions#=#:#2\stopMPdefinitions
+ {\let\m_meta_saved_instance\currentMPinstance
+ \edef\currentMPinstance{#1}%
+ \ifempty\currentMPinstance
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \gtoksapp\t_meta_definitions{#2}%
+ \let\currentMPinstance\m_meta_saved_instance}
+
+\aliased\let\stopMPdefinitions\relax
+
+\permanent\tolerant\protected\def\startMPextensions#=#:#2\stopMPextensions % we could use buffers instead
+ {\clf_setmpextensions{#1}{#2}}
+
+\aliased\let\stopMPextensions\relax
+
+\permanent\protected\def\startMPinitializations#1\stopMPinitializations % for all instances, when enabled
+ {\gtoksapp\t_meta_initializations{#1}}
+
+\aliased\let\stopMPinitializations\relax
+
+\permanent\tolerant\protected\def\startMPinclusions[#1]#*#=#:#3\stopMPinclusions
+ {\let\m_meta_saved_instance\currentMPinstance % \pushmacro
+ \edef\currentMPinstance{#2}%
+ \ifempty\currentMPinstance
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \iftok{#1}{+}\else
+ \global\t_meta_inclusions\emptytoks
+ \fi
+ \gtoksapp\t_meta_inclusions{#3}%
+ \let\currentMPinstance\m_meta_saved_instance} % \popmacro
+
+\aliased\let\stopMPinclusions\relax
+
+% The next was broken since we added instances so it will go away!
+
+\permanent\tolerant\protected\def\MPinclusions[#1]#:#*#=#:#*#=%
+ {\let\m_meta_saved_instance\currentMPinstance
+ \iftok{#1}{+}\else
+ \global\t_meta_inclusions\emptytoks
+ \fi
+ \ifparameter#3\or
+ \edef\currentMPinstance{#2}%
+ \ifempty\currentMPinstance
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \gtoksapp\t_meta_inclusions{#3}%
+ \else
+ \let\currentMPinstance\defaultMPinstance
+ \gtoksapp\t_meta_inclusions{#2}%
+ \fi
+ \let\currentMPinstance\m_meta_saved_instance}
+
+% so far
+
+\installcommandhandler \??mpinstance {MPinstance} \??mpinstance
+
+\setupMPinstance
+ [\s!format=metafun,
+ \s!extensions=\v!no,
+ \s!initializations=\v!no,
+ \c!method=\s!default,
+ \c!textstyle=,
+ \c!textcolor=]
+
+\appendtoks
+ \ifcsname\??mpdefinitions\currentMPinstance\endcsname \else
+ \expandafter\newtoks\csname\??mpdefinitions\currentMPinstance\endcsname
+ \fi
+ \ifcsname\??mpinclusions\currentMPinstance\endcsname \else
+ \expandafter\newtoks\csname\??mpinclusions\currentMPinstance\endcsname
+ \fi
+ \t_meta_definitions\emptytoks % in case we redefine
+ \t_meta_inclusions \emptytoks % in case we redefine
+\to \everydefineMPinstance
+
+\permanent\protected\def\resetMPinstance[#1]%
+ {\writestatus\m!metapost{reset will be implemented when needed}}
+
+\def\meta_analyze_graphicname[#1]%
+ %{\normalexpanded{\meta_analyze_graphicname_indeed[#1::::]}}
+ {\normalexpanded{\meta_analyze_graphicname_indeed[#1}::::]}
+
+\def\meta_show_properties_indeed
+ {\writestatus{metapost}{name: \currentMPgraphicname, instance: \currentMPinstance, format: \currentMPformat}}
+
+\let\meta_show_properties\donothing
+
+\installtextracker
+ {metapost.properties}
+ {\let\meta_show_properties\meta_show_properties_indeed}
+ {\let\meta_show_properties\donothing}
+
+\protected\def\meta_analyze_graphicname_indeed[#1::#2::#3]% instance ::
+ {\edef\currentMPgraphicname{#2}%
+ \ifempty\currentMPgraphicname
+ \edef\currentMPgraphicname{#1}%
+ \let\currentMPinstance\defaultMPinstance
+ \orelse\ifcsname\??mpdefinitions#1\endcsname
+ \edef\currentMPinstance{#1}%
+ \else
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \edef\currentMPformat{\MPinstanceparameter\s!format}%
+ \meta_show_properties}
+
+\mutable\def\currentMPgraphicname{\s!unknown}
+\mutable\def\currentMPinstance {\defaultMPinstance}
+\mutable\def\currentMPformat {\currentMPinstance}
+
+\defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
+\defineMPinstance[minifun] [\s!format=minifun,\s!extensions=\v!yes,\s!initializations=\v!yes]
+\defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
+\defineMPinstance[lessfun] [\s!format=metafun]
+\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double]
+\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary]
+\defineMPinstance[decimalfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal]
+
+\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
+
+\defineMPinstance[metapost] [\s!format=mpost]
+\defineMPinstance[nofun] [\s!format=mpost]
+\defineMPinstance[doublepost] [\s!format=mpost,\c!method=\s!double]
+\defineMPinstance[binarypost] [\s!format=mpost,\c!method=\s!binary]
+\defineMPinstance[decimalpost][\s!format=mpost,\c!method=\s!decimal]
+
+\defineMPinstance[simplefun] [\s!format=metafun,\c!method=\s!double] % maybe use minifun
+
+%defineMPinstance[megapost] [\s!format=mpost,\c!method=\s!decimal]
+
+\newconditional\c_meta_include_initializations
+
+\def\meta_begin_graphic_group#1%
+ {\begingroup
+ \meta_analyze_graphicname[#1]}
+
+\def\meta_end_graphic_group
+ {\endgroup}
+
+\mutable\def\MPaskedfigure{false}
+
+\def\meta_flush_current_initializations
+ {\ifconditional\c_meta_include_initializations
+ \the\t_meta_initializations
+ \fi}
+
+\def\meta_flush_current_inclusions
+ {\the\t_meta_inclusions}
+
+\def\meta_flush_current_definitions
+ {\the\t_meta_definitions}
+
+\def\meta_start_current_graphic
+ {\begingroup
+ \meta_enable_include
+ \the\everyMPgraphic
+ \edef\p_initializations{\MPinstanceparameter\s!initializations}%
+ \ifx\p_initializations\v!yes
+ \settrue \c_meta_include_initializations
+ \else
+ \setfalse\c_meta_include_initializations
+ \fi
+ \edef\p_setups{\MPinstanceparameter\c!setups}%
+ \ifempty\p_setups \else
+ \setups[\p_setups]%
+ \fi
+ \useMPinstancestyleparameter\c!textstyle}
+
+\def\meta_set_current_color
+ {\useMPinstancecolorparameter\c!textcolor}
+
+\def\meta_stop_current_graphic
+ {\global\t_meta_definitions\emptytoks
+ \global\t_meta_inclusions\emptytoks
+ \endgroup}
+
+\def\meta_process_graphic_start
+ {\pushMPboundingbox
+ \setbox\b_meta_graphic\hpack\bgroup}
+
+\let\meta_relocate_graphic\relax % experimental hook
+
+\def\meta_process_graphic_stop
+ {\egroup
+ \meta_place_graphic
+ \meta_relocate_graphic
+ \popMPboundingbox}
+
+\protected\def\meta_process_graphic_instance#1%
+ {\edef\currentMPinstance{#1}%
+ \ifempty\currentMPinstance
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \edef\currentMPformat{\MPinstanceparameter\s!format}%
+ \meta_process_graphic}
+
+\protected\def\meta_process_graphic#1% todo: extensions and inclusions outside beginfig
+ {\meta_start_current_graphic
+ \forgetall
+ \edef\p_extensions{\MPinstanceparameter\s!extensions}%
+ \meta_process_graphic_start
+ \normalexpanded{\noexpand\clf_mpgraphic
+ instance {\currentMPinstance}%
+ format {\currentMPformat}%
+ data {#1;}%
+ initializations {\meta_flush_current_initializations}%
+ \ifx\p_extensions\v!yes
+ extensions {\clf_getmpextensions{\currentMPinstance}}% goes through tex again
+ \fi
+ inclusions {\meta_flush_current_inclusions}%
+ definitions {\meta_flush_current_definitions}%
+ figure {\MPaskedfigure}%
+ method {\MPinstanceparameter\c!method}%
+ namespace {\??graphicvariable\currentmpvariableclass:}%
+ \relax}%
+ \meta_process_graphic_stop
+ \meta_stop_current_graphic}
+
+\let\meta_process_graphic_figure_start\relax
+\let\meta_process_graphic_figure_stop \relax
+
+\let\normal_meta_process_graphic_start\relax
+\let\normal_meta_process_graphic_stop \relax
+
+\permanent\protected\def\processMPfigurefile#1% special case: obeys beginfig .. endfig and makes pages
+ {\begingroup
+ \let\normal_meta_process_graphic_start\meta_process_graphic_start
+ \let\normal_meta_process_graphic_stop \meta_process_graphic_stop
+ \let\meta_process_graphic_start\relax
+ \let\meta_process_graphic_stop \relax
+ \def\meta_process_graphic_figure_start{\startTEXpage[\c!offset=\v!overlay,\c!align=]\normal_meta_process_graphic_start}%
+ \def\meta_process_graphic_figure_stop {\normal_meta_process_graphic_stop\stopTEXpage}
+ \def\MPaskedfigure{all}%
+ \meta_process_graphic{input "#1" ;}%
+ \endgroup}
+
+%D Calling up previously defined graphics.
+
+% \def\includeMPgraphic#1% gets expanded !
+% {\ifcsname\??mpgraphic#1\endcsname
+% \csname\??mpgraphic#1\endcsname ; % ; is safeguard
+% \fi}
+%
+% \protected\def\meta_enable_include % public
+% {\let\meta_handle_use_graphic \thirdofthreearguments
+% \let\meta_handle_reusable_graphic\thirdofthreearguments}
+%
+% but ... we want this too:
+%
+% \startuseMPgraphic{x}
+% draw textext("\externalfigure[foo.pdf]") ;
+% \stopuseMPgraphic
+%
+% \useMPgraphic{x}
+%
+% so we cannot overload unless we let back to the original meanings each graphic
+% ... a better solution is:
+
+\permanent\def\includeMPgraphic#1% gets expanded !
+ {\ifcsname\??mpgraphic#1\endcsname
+ \doubleexpandafter\fourthoffourarguments\lastnamedcs ; % ; is safeguard
+ \fi}
+
+\let\meta_enable_include\relax
+
+%D Drawings (stepwise built):
+
+\newif\ifMPdrawingdone \MPdrawingdonefalse
+
+\permanent\protected\def\finalizeMPdrawing
+ {\MPdrawingdonetrue}
+
+\mutable\let\MPdrawingdata\empty
+
+\permanent\protected\def\resetMPdrawing
+ {\glet\MPdrawingdata\empty
+ \global\MPdrawingdonefalse}
+
+\permanent\protected\def\pushMPdrawing
+ {\globalpushmacro\MPdrawingdata
+ \glet\MPdrawingdata\empty}
+
+\permanent\protected\def\popMPdrawing
+ {\globalpopmacro\MPdrawingdata}
+
+\permanent\protected\def\getMPdrawing
+ {\ifMPdrawingdone
+ \expandafter\meta_process_graphic\expandafter{\MPdrawingdata}% is this expansion still needed?
+ \fi}
+
+\permanent\tolerant\def\startMPdrawing[#1]% todo: use pickup #:
+ {\meta_start_drawing{#1}}
+
+\def\meta_start_drawing#1#2\stopMPdrawing
+ {\relax
+ \bgroup
+ \meta_enable_include
+ \doifelse{#1}{-}
+ {\xdef\MPdrawingdata{\MPdrawingdata\detokenize{#2}}}%
+ {\xdef\MPdrawingdata{\MPdrawingdata#2}}%
+ \egroup}
+
+\aliased\let\stopMPdrawing\relax
+
+\permanent\def\MPdrawing#1%
+ {\relax
+ \bgroup
+ \meta_enable_include
+ \xdef\MPdrawingdata{\MPdrawingdata#1}%
+ \egroup}
+
+\permanent\protected\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
+ {\gdefcsname\??mpclip#1\endcsname{#2}}
+
+\aliased\let\stopMPclip\relax
+
+\mutable\def\width {0 } % left-over
+\mutable\def\height{0 } % left-over
+
+\mutable\let\currentMPclip\empty
+
+\protected\def\meta_grab_clip_path#1#2#3%
+ {\begingroup
+ \d_overlay_width #2\relax
+ \d_overlay_height#3\relax
+ \edef\width {\the\d_overlay_width \space}% hm
+ \edef\height{\the\d_overlay_height\space}% hm
+ \edef\currentMPclip{#1}%
+ \ifcsname\??mpclip\currentMPclip\endcsname
+ \meta_grab_clip_path_yes
+ \else
+ \meta_grab_clip_path_nop
+ \fi
+ \endgroup}
+
+\def\meta_grab_clip_path_yes
+ {\meta_start_current_graphic
+ \normalexpanded{\noexpand\clf_mpsetclippath
+ instance {\currentMPinstance}%
+ format {\currentMPformat}%
+ data {\csname\??mpclip\currentMPclip\endcsname}%
+ initializations {\meta_flush_current_initializations}%
+ useextensions {\MPinstanceparameter\s!extensions}%
+ inclusions {\meta_flush_current_inclusions}%
+ method {\MPinstanceparameter\c!method}%
+ width \d_overlay_width
+ height \d_overlay_height
+ \relax}%
+ \meta_stop_current_graphic}
+
+\def\meta_grab_clip_path_nop
+ {\clf_mpsetclippath
+ width \d_overlay_width
+ height \d_overlay_height
+ \relax}
+
+%D Since we want labels to follow the document settings, we also set the font
+%D related variables.
+
+\permanent\protected\def\MPfontsizehskip#1%
+ {\dontleavehmode
+ \begingroup
+ \definedfont[#1]%
+ \hskip\clf_currentdesignsize\scaledpoint\relax
+ \endgroup}
+
+\definefontsynonym[MetafunDefault][Regular*default]
+
+\startMPinitializations % scale is not yet ok
+ defaultfont:="\truefontname{MetafunDefault}";
+ % defaultscale:=\the\bodyfontsize/10pt; % only when hard coded 10pt
+ % defaultscale:=1;
+\stopMPinitializations
+
+%D A signal that we're in combined \CONTEXT||\METAFUN mode:
+
+\startMPextensions
+ string contextversion;contextversion:="\contextversion"; % expanded
+\stopMPextensions
+
+%D \macros
+%D {setupMPvariables}
+%D
+%D When we build collections of \METAPOST\ graphics, like background and buttons,
+%D the need for passing settings arises. By (mis|)|using the local prefix that
+%D belongs to \type {\framed}, we get a rather natural interface to backgrounds. To
+%D prevent conflicts, we will use the \type {-} in \METAPOST\ specific variables,
+%D like:
+%D
+%D \starttyping
+%D \setupMPvariables[meta:button][size=20pt]
+%D \stoptyping
+
+% \lineheight 2pt 2 \scratchcounter red 0.4 .5\bodyfontsize
+%
+% see cont-loc for test code
+
+%D Currently the inheritance of backgrounds does not work and we might drop it
+%D anyway (too messy)
+
+\newbox\b_meta_variable_box
+
+\mutable\let \currentmpvariableclass \empty % public
+
+\let \m_meta_current_variable \empty
+\let \m_meta_current_variable_template\empty
+
+% \installcorenamespace{graphicvariable} % already set
+
+\def\meta_prepare_variable_default{\MPcolor{black}} % just to be sure we use a color but ...
+
+\permanent\tolerant\protected\def\setupMPvariables[#1]#*[#2]%
+ {\ifarguments
+ \or
+ \getrawparameters[\??graphicvariable:][#1]%
+ \else
+ \getrawparameters[\??graphicvariable#1:][#2]%
+ \fi}
+
+\permanent\tolerant\protected\def\presetMPvariable[#1]#*[#2=#3]%
+ {\ifcsname\??graphicvariable#1:#2\endcsname \else
+ \defcsname\??graphicvariable#1:#2\endcsname{#3}%
+ \fi}
+
+\permanent\def\MPrawvar#1#2% no checking
+ {\begincsname\??graphicvariable#1:#2\endcsname}
+
+\permanent\def\MPvariable#1% todo: could be a framed chain
+ {\begincsname\??graphicvariable\currentmpvariableclass:#1\endcsname}
+
+\permanent\tolerant\protected\def\useMPvariables[#1]#*[#2]%
+ {\edef\currentmpvariableclass{#1}%
+ \meta_prepare_variables{#2}}
+
+\protected\def\meta_prepare_variables#1%
+ {\processcommalist[#1]\meta_prepare_variable}
+
+\protected\def\meta_prepare_variable#1%
+ {\edef\m_meta_current_variable_template
+ {\??graphicvariable\currentmpvariableclass:#1}%
+ \edef\m_meta_current_variable
+ {\begincsname\m_meta_current_variable_template\endcsname}%
+ \ifempty\m_meta_current_variable
+ \expandafter\meta_prepare_variable_nop
+ \else
+ \expandafter\meta_prepare_variable_yes
+ \fi}
+
+\protected\def\meta_prepare_instance_variables
+ {\expandafter\processcommalist\expandafter[\m_meta_instance_variables]\meta_prepare_instance_variable}
+
+\protected\def\meta_prepare_instance_variable#1%
+ {\edef\m_meta_current_variable_template
+ {\??graphicvariable\currentmpvariableclass:#1}%
+ \edef\m_meta_current_variable
+ {\ifcsname\m_meta_current_variable_template\endcsname
+ \lastnamedcs
+ \else
+ \begincsname\??graphicvariable\currentMPgraphicname:#1\endcsname
+ \fi}%
+ \ifempty\m_meta_current_variable
+ \expandafter\meta_prepare_variable_nop
+ \else
+ \expandafter\meta_prepare_variable_yes
+ \fi}
+
+\def\meta_prepare_variable_nop
+ {\expandafter\letcsname\m_meta_current_variable_template\endcsname\meta_prepare_variable_default}
+
+\def\meta_prepare_variable_color % we use the attribute so we dont' go through namedcolor (why not)
+ {\expandafter\edefcsname\m_meta_current_variable_template\endcsname{\MPcolor\m_meta_current_variable}}
+
+\def\meta_prepare_variable_number
+ {\expandafter\edefcsname\m_meta_current_variable_template\endcsname{\number\m_meta_current_variable}}% also accepts 0.number
+
+\def\meta_prepare_variable_dimension
+ {\expandafter\edefcsname\m_meta_current_variable_template\endcsname{\the\dimexpr\m_meta_current_variable}}
+
+\def\meta_prepare_variable_yes
+ {\ifchkdim\m_meta_current_variable\or
+ \meta_prepare_variable_dimension
+ \orelse\ifchknum\m_meta_current_variable\or
+ \meta_prepare_variable_number
+ \else
+ \doifelsecolor\m_meta_current_variable
+ \meta_prepare_variable_color
+ \meta_prepare_variable_dimension
+ \fi}
+
+\aliased\let\MPvar \MPvariable
+\aliased\let\setMPvariables\setupMPvariables
+
+%D \macros
+%D {startuniqueMPgraphic, uniqueMPgraphic}
+%D
+%D This macros is probably of most use to myself, since I like to use graphics that
+%D adapt themselves. The next \METAPOST\ kind of graphic is both unique and reused
+%D when possible.
+%D
+%D \starttyping
+%D \defineoverlay[example][\uniqueMPgraphic{test}]
+%D
+%D \startuniqueMPgraphic {test}
+%D draw OverlayBox ;
+%D \stopuniqueMPgraphic
+%D
+%D \startuniqueMPgraphic {test}
+%D draw OverlayBox ;
+%D \stopuniqueMPgraphic
+%D \stoptyping
+
+% todo: frozen or not?
+
+\permanent\def\overlaystamp % watch the \MPcolor, since colors can be redefined
+ {\the\d_overlay_width :%
+ \the\d_overlay_height :%
+ \the\d_overlay_depth :%
+ \the\d_overlay_offset :%
+ \the\d_overlay_linewidth:%
+ \MPcolor\overlaycolor :% % todo, expand once \m_overlaycolor
+ \MPcolor\overlaylinecolor} % todo, expand once \m_overlaylinecolor
+
+%D A better approach is to let additional variables play a role in determining the
+%D uniqueness. In the next macro, the second, optional, argument is used to
+%D guarantee the uniqueness, as well as prepare variables for passing them to
+%D \METAPOST.
+%D
+%D \starttyping
+%D \startuniqueMPgraphic{meta:hash}{gap,angle,...}
+%D \stoptyping
+%D
+%D The calling macro also accepts a second argument. For convenient use in overlay
+%D definitions, we use \type {{}} instead of \type {[]}.
+%D
+%D \starttyping
+%D \uniqueMPgraphic{meta:hash}{gap=10pt,angle=30}
+%D \stoptyping
+
+\newcount\c_meta_object_counter
+\newbox \b_meta_graphic
+
+% hm, isn't this already done elsewhere?
+
+\protected\def\meta_obey_box_depth
+ {\setbox\b_meta_graphic\hpack\bgroup
+ \raise\MPlly\box\b_meta_graphic
+ \egroup}
+
+\protected\def\meta_ignore_box_depth
+ {\normalexpanded
+ {\meta_obey_box_depth % hence the \protected
+ \wd\b_meta_graphic\the\wd\b_meta_graphic
+ \ht\b_meta_graphic\the\ht\b_meta_graphic
+ \dp\b_meta_graphic\the\dp\b_meta_graphic}}
+
+\protected\def\meta_obey_box_origin
+ {\setbox\b_meta_graphic\hpack\bgroup
+ \kern\MPllx\raise\MPlly\box\b_meta_graphic
+ \egroup}
+
+\permanent\protected\def\obeyMPboxdepth {\let\meta_relocate_box\meta_obey_box_depth}
+\permanent\protected\def\ignoreMPboxdepth{\let\meta_relocate_box\meta_ignore_box_depth}
+\permanent\protected\def\obeyMPboxorigin {\let\meta_relocate_box\meta_obey_box_origin}
+\permanent\protected\def\normalMPboxdepth{\let\meta_relocate_box\relax}
+
+\let\meta_relocate_box\relax
+
+\protected\def\meta_place_graphic % the converter also displaces so in fact we revert
+ {\meta_relocate_box
+ \box\b_meta_graphic}
+
+\protected\def\meta_reuse_box#1#2#3#4#5% space delimiting would save some tokens
+ {\MPllx#2\MPlly#3\MPurx#4\MPury#5%
+ \hpack container{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent
+
+\protected\def\meta_use_box
+ {\setunreferencedobject{MP}}
+
+\def\meta_handle_unique_graphic#1#2#3% when there are too many, we can store data at the lua end, although,
+ {\begingroup % when there are that many they're probably not that unique anyway
+ \edef\currentmpvariableclass{#1}%
+ \extendMPoverlaystamp{#2}% incl prepare
+ \ifcsname\??mpgraphic\overlaystamp:#1\endcsname
+ \lastnamedcs
+ \else
+ \meta_enable_include % redundant
+ \global\advance\c_meta_object_counter\plusone
+ \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox
+ \xdefcsname\??mpgraphic\overlaystamp:#1\endcsname{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
+ \csname\??mpgraphic\overlaystamp:#1\endcsname\empty
+ \fi
+ \endgroup}
+
+% todo: we partially expand
+
+\permanent\protected\def\startuniqueMPgraphic
+ {\dodoublegroupempty\meta_start_unique_graphic}
+
+\aliased\let\stopuniqueMPgraphic\relax
+
+\def\meta_start_unique_graphic#1%
+ {\normalexpanded{\meta_start_unique_graphic_indeed{#1}}}
+
+\permanent\protected\def\meta_start_unique_graphic_indeed#1#2#3\stopuniqueMPgraphic
+ {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_unique_graphic{#1}{#2}{#3}}}
+
+\permanent\tolerant\protected\def\uniqueMPgraphic#=#*#=%
+ {\meta_begin_graphic_group{#1}%
+ \setupMPvariables[#1][#2]%
+ \begincsname\??mpgraphic#1\endcsname\empty
+ \meta_end_graphic_group}
+
+\def\meta_handle_use_graphic#1#2#3%
+ {\begingroup
+ \edef\currentmpvariableclass{#1}%
+ \edef\m_meta_instance_variables{#2}%
+ \ifempty\m_meta_instance_variables \else
+ \meta_prepare_instance_variables
+ \fi
+ \meta_enable_include % redundant
+ \meta_process_graphic{#3}%
+ \endgroup}
+
+\permanent\protected\def\startuseMPgraphic % todo, modernize
+ {\dodoublegroupempty\meta_start_use_graphic}
+
+\aliased\let\stopuseMPgraphic\relax
+
+\def\meta_start_use_graphic#1%
+ {\normalexpanded{\meta_start_use_graphic_indeed{#1}}}
+
+\protected\def\meta_start_use_graphic_indeed#1#2#3\stopuseMPgraphic
+ {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_use_graphic{#1}{#2}{#3}}}
+
+\permanent\protected\def\startusableMPgraphic % redundant but handy % todo, modernize
+ {\dodoublegroupempty\meta_start_usable_graphic}
+
+\aliased\let\stopusableMPgraphic\relax
+
+\def\meta_start_usable_graphic#1%
+ {\normalexpanded{\meta_start_usable_graphic_indeed{#1}}}
+
+\protected\def\meta_start_usable_graphic_indeed#1#2#3\stopusableMPgraphic
+ {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_use_graphic{#1}{#2}{#3}}}
+
+\def\meta_handle_reusable_graphic#1#2#3%
+ {\begingroup
+ \edef\currentmpvariableclass{#1}%
+ \edef\m_meta_instance_variables{#2}%
+ \ifempty\m_meta_instance_variables \else
+ \meta_prepare_instance_variables
+ \fi
+ \meta_enable_include % redundant
+ \global\advance\c_meta_object_counter\plusone
+ \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox
+ \xdefcsname\??mpgraphic#1\endcsname{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
+ \csname\??mpgraphic#1\endcsname\empty
+ \endgroup}
+
+\permanent\protected\def\startreusableMPgraphic % todo, modernize
+ {\dodoublegroupempty\meta_start_reusable_graphic}
+
+\aliased\let\stopreusableMPgraphic\relax
+
+\def\meta_start_reusable_graphic#1%
+ {\normalexpanded{\meta_start_reusable_graphic_indeed{#1}}}
+
+\protected\def\meta_start_reusable_graphic_indeed#1#2#3\stopreusableMPgraphic
+ {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_reusable_graphic{#1}{#2}{#3}}}
+
+\mutable\let\usedMPgraphicname\empty
+
+\permanent\tolerant\protected\def\useMPgraphic#=#*#=%
+ {\meta_begin_graphic_group{#1}%
+ \ifcsname\??mpgraphic#1\endcsname
+ \edef\usedMPgraphicname{#1}%
+ \orelse\ifcsname\??mpgraphic\currentMPgraphicname\endcsname
+ \let\usedMPgraphicname\currentMPgraphicname
+ \else
+ \let\usedMPgraphicname\empty
+ \fi
+ \ifempty\usedMPgraphicname
+ % message
+ \else
+ \doifsomething{#2}{\setupMPvariables[\usedMPgraphicname][#2]}%
+ \csname\??mpgraphic\usedMPgraphicname\endcsname
+ \fi
+ \meta_end_graphic_group}
+
+\aliased\let\reuseMPgraphic \useMPgraphic % we can save a setup here if needed
+\aliased\let\reusableMPgraphic\reuseMPgraphic % we can save a setup here if needed
+
+%D \macros
+%D {startuniqueMPpagegraphic,uniqueMPpagegraphic}
+%D
+%D Experimental.
+
+\def\m_meta_page_prefix{\doifelseoddpage oe}
+
+\permanent\def\overlaypagestamp
+ {\m_meta_page_prefix :%
+ \the\d_overlay_width :%
+ \the\d_overlay_height :%
+ \the\d_overlay_depth :%
+ \the\d_overlay_offset :%
+ \the\d_overlay_linewidth:%
+ \MPcolor\overlaycolor :%
+ \MPcolor\overlaylinecolor}
+
+\permanent\tolerant\protected\def\startuniqueMPpagegraphic % todo the modern way
+ {\dodoublegroupempty\meta_start_unique_page_graphic}
+
+\aliased\let\stopuniqueMPpagegraphic\relax
+
+\def\meta_start_unique_page_graphic#1%
+ {\normalexpanded{\meta_start_unique_page_graphic_indeed{#1}}}
+
+\protected\def\meta_start_unique_page_graphic_indeed#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage
+ {\gdefcsname\??mpgraphic o:#1\endcsname{\meta_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state
+ \gdefcsname\??mpgraphic e:#1\endcsname{\meta_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined
+
+\permanent\tolerant\protected\def\uniqueMPpagegraphic#=#=%
+ {\meta_begin_graphic_group{#1}%
+ \enforced\let\overlaystamp\overlaypagestamp
+ \setupMPvariables[\m_meta_page_prefix:#1][#2]% prefix is new here
+ \csname\??mpgraphic\m_meta_page_prefix:#1\endcsname\empty
+ \meta_end_graphic_group}
+
+%D One way of defining a stamp is:
+%D
+%D \starttyping
+%D \def\extendMPoverlaystamp#1%
+%D {\def\docommand##1%
+%D {\edef\overlaystamp{\overlaystamp:\MPvariable{##1}}}%
+%D \processcommalist[#1]\docommand}
+%D \stoptyping
+%D
+%D Since we need to feed \METAPOST\ with expanded dimensions, we introduce a
+%D dedicated expansion engine. We redefine \type {\extendMPoverlaystamp} to
+
+\permanent\protected\def\extendMPoverlaystamp#1%
+ {\processcommalist[#1]\meta_extend_overlay_stamp}
+
+\def\meta_extend_overlay_stamp#1%
+ {\meta_prepare_instance_variable{#1}%
+ \enforced\permanent\edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}
+
+% \getMPdata % define at the lua end
+% \rawMPdata % define at the lua end
+
+%D We need this trick because we need to make sure that the tex scanner sees
+%D newlines and does not quit. Also, we do need to flush the buffer under a normal
+%D catcode regime in order to expand embedded tex macros. As usual with buffers,
+%D \type {#1} can be a list.
+
+\permanent\tolerant\protected\def\processMPbuffer[#1]%
+ {\meta_begin_graphic_group{#1}%
+ \meta_process_graphic{\clf_feedback{\currentMPgraphicname}}%
+ \meta_end_graphic_group}
+
+\permanent\tolerant\protected\def\runMPbuffer[#1]%
+ {\startnointerference\processMPbuffer[#1]\stopnointerference}
+
+%D \macros
+%D {startMPenvironment, resetMPenvironment}
+%D
+%D In order to synchronize the main \TEX\ run and the runs local to \METAPOST,
+%D environments can be passed.
+
+\permanent\protected\def\startMPenvironment
+ {\begingroup
+ \catcode\endoflineasciicode\ignorecatcode
+ \meta_start_environment}
+
+\tolerant\def\meta_start_environment[#1]#:#2\stopMPenvironment
+ {\endgroup
+ \edef\m_meta_option{#1}
+ \ifx\m_meta_option\s!reset
+ \resetMPenvironment % reset mp toks
+ \orelse\ifx\m_meta_option\v!global
+ #2% % use in main doc too
+ \orelse\ifx\m_meta_option\!!plustoken
+ #2% % use in main doc too
+ \fi
+ \clf_mptexset{\detokenize{#2}}}
+
+\aliased\let\stopMPenvironment\relax
+
+\permanent\protected\def\resetMPenvironment
+ {\clf_mptexreset}
+
+\permanent\protected\def\useMPenvironmentbuffer[#1]%
+ {\clf_mptexsetfrombuffer{#1}}
+
+%D This command takes \type {[reset]} as optional argument.
+%D
+%D \starttyping
+%D \startMPenvironment
+%D \setupbodyfont[pos,14.4pt]
+%D \stopMPenvironment
+%D
+%D \startMPcode
+%D draw btex \sl Hans Hagen etex scaled 5 ;
+%D \stopMPcode
+%D \stoptyping
+%D
+%D The most simple case:
+
+\permanent\tolerant\protected\def\startMPcode#=#:#2\stopMPcode
+ {\begingroup
+ \edef\currentMPinstance{#1}%
+ \ifempty\currentMPinstance
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \let\currentMPgraphicname\empty
+ \edef\currentMPformat{\MPinstanceparameter\s!format}%
+ \meta_enable_include
+ \meta_process_graphic{#2}%
+ \endgroup}
+
+\aliased\let\stopMPcode\relax
+
+%D This one is not optimized because it's only used for small snippets, if it
+%D is used at all.
+
+\permanent\tolerant\protected\def\MPcode#=#:#*#=%
+ {\ifparameter#1\or
+ \meta_begin_graphic_group{#1}%
+ \meta_enable_include
+ \meta_process_graphic{#2}%
+ \meta_end_graphic_group
+ \else
+ \let\currentMPinstance\defaultMPinstance
+ \meta_enable_include
+ \meta_process_graphic{#1}%
+ \fi}
+
+% a bit nasty (also needed for compatibility:
+
+% \startMPrun input mp-www.mp ; \stopMPrun
+% \externalfigure[mprun.3][width=10cm,height=8cm]
+
+% \startMPrun{mprun} input mp-www.mp ; \stopMPrun % instance
+% \externalfigure[mprun.4][width=10cm,height=8cm]
+
+\mutable\let\MPruninstance\defaultMPinstance
+
+\permanent\protected\def\useMPrun#1#2% name n
+ {\begingroup
+ \def\MPaskedfigure{#2}%
+ \normalexpanded{\useMPgraphic{\iftok{#1}\emptytoks mprun\else#1\fi}}%
+ \endgroup}
+
+\permanent\tolerant\protected\def\startMPrun#=#:#2\stopMPrun
+ {\normalexpanded{\startuseMPgraphic{\iftok{#1}\emptytoks mprun\else#1\fi}}#2\stopuseMPgraphic}
+
+\aliased\let\stopMPrun\relax
+
+%D The \type {\resetMPenvironment} is a quick way to erase
+%D the token list.
+%D
+%D You should be aware of independencies. For instance, if you use a font
+%D in a graphic that is not used in the main document, you need to load the
+%D typescript at the outer level (either directly or by using the global
+%D option).
+%D
+%D \starttyping
+%D \usetypescript[palatino][texnansi]
+%D
+%D \startMPenvironment
+%D \usetypescript[palatino][texnansi]
+%D \enableregime[utf]
+%D \setupbodyfont[palatino]
+%D \stopMPenvironment
+%D
+%D \startMPpage
+%D draw btex aap‒noot coördinatie – één etex ;
+%D \stopMPpage
+%D \stoptyping
+
+%D Loading specific \METAPOST\ related definitions is
+%D accomplished by:
+
+\permanent\protected\def\useMPlibrary[#1]{\clf_useMPlibrary{#1}}
+
+%D \macros
+%D {setMPtext, MPtext, MPstring, MPbetex}
+%D
+%D To be documented:
+%D
+%D \starttyping
+%D \setMPtext{identifier}{text}
+%D
+%D \MPtext {identifier}
+%D \MPstring{identifier}
+%D \MPbetex {identifier}
+%D \stoptyping
+
+\installcorenamespace{mptext}
+
+\permanent\protected\def\setMPtext#1#2{\dodoglobal\edefcsname\??mptext#1\endcsname{\detokenize{#2}}}
+\permanent \def\MPtext #1{\begincsname\??mptext#1\endcsname\empty}
+\permanent \def\MPstring #1{"\begincsname\??mptext#1\endcsname\empty"}
+\permanent \def\MPbetex #1{btex \begincsname\??mptext#1\endcsname\space etex}
+
+%D In order to communicate conveniently with the \TEX\ engine, we introduce some
+%D typesetting variables.
+
+% \setupcolors[state=stop,conversion=never] % quite tricky ... type mismatch
+
+\startMPinitializations
+ CurrentLayout:="\currentlayout";
+\stopMPinitializations
+
+%D A dirty trick, ** in colo-ini.lua (mpcolor). We cannot use a vardef, because
+%D that fails with spot colors.
+
+\startMPinitializations
+ def OverlayLineColor=\ifempty\overlaylinecolor black \else\MPcolor{\overlaylinecolor} \fi enddef;
+ def OverlayColor =\ifempty\overlaycolor black \else\MPcolor{\overlaycolor} \fi enddef;
+\stopMPinitializations
+
+\appendtoks
+ \disablediscretionaries
+ %\disablecompoundcharacters
+\to \everyMPgraphic
+
+\appendtoks
+ \baselineskip1\baselineskip
+ \lineheight 1\lineheight
+ \topskip 1\topskip
+\to \everyMPgraphic
+
+\appendtoks
+ \enforced\let\#\letterhash
+ \enforced\let\_\letterunderscore
+ \enforced\let\&\letterampersand
+ \enforced\let\{\letteropenbrace
+ \enforced\let\}\letterclosebrace
+\to \everyMPgraphic
+
+%D \macros
+%D {PDFMPformoffset}
+%D
+%D In \PDF, forms are clipped and therefore we have to take precautions to get this
+%D right. Since this is related to objects, we use the same offset as used there.
+
+\def\PDFMPformoffset{\objectoffset}
+
+\newtoks\everyinsertMPfile
+
+\startMPextensions
+ def initialize_form_numbers =
+ do_initialize_numbers;
+ enddef;
+\stopMPextensions
+
+\startMPextensions
+ vardef ForegroundBox =
+ unitsquare xysized(HSize,VSize)
+ enddef ;
+\stopMPextensions
+
+\startMPdefinitions {metapost}
+ if unknown context_bare : input mp-bare.mpiv ; fi ;
+\stopMPdefinitions
+\startMPdefinitions {binarypost}
+ if unknown context_bare : input mp-bare.mpiv ; fi ;
+\stopMPdefinitions
+\startMPdefinitions {decimalpost}
+ if unknown context_bare : input mp-bare.mpiv ; fi ;
+\stopMPdefinitions
+\startMPdefinitions {doublepost}
+ if unknown context_bare : input mp-bare.mpiv ; fi ;
+\stopMPdefinitions
+
+% \startMPdefinitions {nofun}
+% if unknown context_bare : input mp-bare.mpiv ; fi ;
+% \stopMPdefinitions
+
+%D And some more. These are not really needed since we don't use the normal figure
+%D inclusion macros any longer.
+
+\appendtoks
+ \externalfigurepostprocessors\emptytoks % safeguard
+\to \everyinsertMPfile
+
+%D We also take care of disabling fancy figure features, that can terribly interfere
+%D when dealing with symbols, background graphics and running (postponed) graphics.
+%D You won't believe me if I tell you what funny side effects can occur. One took me
+%D over a day to uncover when processing the screen version of the \METAFUN\ manual.
+
+\permanent\def\doifelseMPgraphic#1%
+ {\ifcsname\??mpgraphic #1\endcsname\expandafter\firstoftwoarguments \orelse
+ \ifcsname\??mpgraphic o:#1\endcsname\expandafter\firstoftwoarguments \orelse
+ \ifcsname\??mpgraphic e:#1\endcsname\expandafter\firstoftwoarguments \else
+ \expandafter\secondoftwoarguments\fi}
+
+\aliased\let\doifMPgraphicelse\doifelseMPgraphic
+
+%D New:
+
+\definelayerpreset % no dx,dy - else nasty non-mp placement
+ [mp]
+ [\c!y=-\MPury,
+ \c!x=\MPllx,
+ \c!method=\v!fit]
+
+\definelayer
+ [mp]
+ [\c!preset=mp]
+
+%D Usage:
+%D
+%D \starttyping
+%D \defineviewerlayer[one][state=start]
+%D \defineviewerlayer[two][state=stop]
+%D
+%D \startuseMPgraphic{step-1}
+%D fill fullcircle scaled 10cm withcolor red ;
+%D \stopuseMPgraphic
+%D
+%D \startuseMPgraphic{step-2}
+%D fill fullcircle scaled 5cm withcolor green ;
+%D \stopuseMPgraphic
+%D
+%D \setlayer[mp]{\viewerlayer[one]{\useMPgraphic{step-1}}}
+%D \setlayer[mp]{\viewerlayer[two]{\useMPgraphic{step-2}}}
+%D
+%D \ruledhbox{\flushlayer[mp]}
+%D \stoptyping
+%D
+%D Reusing graphics is also possible (now):
+%D
+%D \starttyping
+%D \startreusableMPgraphic{axis}
+%D tickstep := 1cm ; ticklength := 2mm ;
+%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
+%D tickstep := tickstep/2 ; ticklength := ticklength/2 ;
+%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
+%D \stopreusableMPgraphic
+%D
+%D \startuseMPgraphic{demo}
+%D drawpoint "1cm,1.5cm" ;
+%D \stopuseMPgraphic
+%D
+%D \definelayer[mp][preset=mp]
+%D \setlayer[mp]{\reuseMPgraphic{axis}}
+%D \setlayer[mp]{\useMPgraphic{demo}}
+%D \ruledhbox{\flushlayer[mp]}
+%D \stoptyping
+
+%D \macros
+%D {startstaticMPfigure,useMPstaticfigure}
+%D
+%D Static figures are processed only when there has been something changed. Here is
+%D Aditya Mahajan's testcase:
+%D
+%D \startbuffer
+%D \startstaticMPfigure{circle}
+%D fill fullcircle scaled 1cm withcolor blue;
+%D \stopstaticMPfigure
+%D
+%D \startstaticMPfigure{axis}
+%D drawarrow (0,0)--(2cm,0) ;
+%D drawarrow (0,0)--(0,2cm) ;
+%D label.llft(textext("(0,0)") ,origin) ;
+%D \stopstaticMPfigure
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\permanent\protected\def\startstaticMPfigure#1#2\stopstaticMPfigure
+ {\startreusableMPgraphic{\??mpstaticgraphic#1}#2\stopreusableMPgraphic}
+
+\permanent\tolerant\protected\def\startstaticMPgraphic#=#:#=#:#3\stopstaticMPgraphic
+ {\startreusableMPgraphic{\??mpstaticgraphic#1}{#2}#3\stopreusableMPgraphic}
+
+\aliased\let\stopstaticMPfigure \relax
+\aliased\let\stopstaticMPgraphic\relax
+
+\permanent\tolerant\protected\def\usestaticMPfigure[#1]#*[#2]%
+ {\ifarguments\or
+ \reuseMPgraphic{\??mpstaticgraphic#1}%
+ \else
+ \scale[#2]{\reuseMPgraphic{\??mpstaticgraphic#1}}%
+ \fi}
+
+%D Goody for preventing overflows:
+
+%frozen\def\MPdivten[#1]{\withoutpt\the\dimexpr#1pt/10\relax}
+\permanent\def\MPdivten[#1]{\thewithoutunit\dimexpr#1pt/10\relax}
+
+%D There is no way to distinguish the black color that you get when you issue a
+%D \type {draw} without color specification from a color that has an explicit black
+%D specification unless you set the variable \type {defaultcolormodel} to 1.
+%D Hoewever, in that case you cannot distinguish that draw from one with a \type
+%D {withoutcolor} specification. This means that we have to provide multiple
+%D variants of inheritance.
+%D
+%D In any case we need to tell the converter what the inherited color is to start
+%D with. Case~3 is kind of unpredictable as it closely relates to the order in which
+%D paths are flushed. If you want to inherit automatically from the surrounding, you
+%D can best stick to variant 1. Variant 0 (an isolated graphic) is the default.
+%D
+%D \startbuffer
+%D \startuseMPgraphic{test}
+%D drawoptions(withpen pencircle scaled 1pt) ;
+%D def shift_cp = currentpicture := currentpicture shifted (-15pt,0) ; enddef ;
+%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ;
+%D fill fullcircle scaled 10pt ; shift_cp ;
+%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ;
+%D fill fullcircle scaled 10pt withcolor red ; shift_cp ;
+%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ;
+%D fill fullcircle scaled 10pt ; shift_cp ;
+%D \stopuseMPgraphic
+%D
+%D \starttabulate
+%D \NC 0\quad \NC \MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
+%D \NC 1\quad \NC \MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
+%D \NC 2\quad \NC \MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
+%D \NC 3\quad \NC \MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\newconstant\MPcolormethod
+
+\appendtoks
+ \clf_mpsetoutercolor
+ \MPcolormethod\space
+ \c_attr_colormodel\space
+ \c_attr_color\space
+ \dogetattribute{transparency}\relax
+\to \everyMPgraphic
+
+% \startMPinitializations
+% defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi;
+% \stopMPinitializations
+
+%D macros
+%D {mprunvar,mpruntab,mprunset}
+%D
+%D \starttyping
+%D \startMPcode
+%D passvariable("version","1.0") ;
+%D passvariable("number",123) ;
+%D passvariable("string","whatever") ;
+%D passvariable("point",(1.5,2.8)) ;
+%D passvariable("triplet",(1/1,1/2,1/3)) ;
+%D passvariable("quad",(1.1,2.2,3.3,4.4)) ;
+%D passvariable("boolean",false) ;
+%D passvariable("path",fullcircle scaled 1cm) ;
+%D draw fullcircle scaled 20pt ;
+%D \stopMPcode
+%D
+%D \ctxlua{inspect(metapost.variables)}
+%D
+%D \MPrunvar{version} \MPruntab{quad}{3} (\MPrunset{triplet}{,})
+%D
+%D $(x,y) = (\MPruntab{point}{1},\MPruntab{point}{2})$
+%D $(x,y) = (\MPrunset{point}{,})$
+%D \stoptyping
+
+\permanent\def\MPrunvar #1{\clf_mprunvar{#1}} \aliased\let\mprunvar\MPrunvar
+\permanent\def\MPruntab#1#2{\clf_mpruntab{#1}#2\relax} \aliased\let\mpruntab\MPruntab % #2 is number
+\permanent\def\MPrunset#1#2{\clf_mprunset{#1}{#2}} \aliased\let\mprunset\MPrunset
+
+\prependtoks \clf_mppushvariables \to \everybeforepagebody
+\appendtoks \clf_mppopvariables \to \everyafterpagebody
+
+\aliased\let\MPpushvariables\clf_mppushvariables
+\aliased\let\MPpopvariables \clf_mppopvariables
+
+%D We also provide an outputless run:
+
+\permanent\tolerant\protected\def\startMPcalculation#=#:#2\stopMPcalculation
+ {\begingroup
+ \setbox\nextbox\hpack\bgroup
+ \edef\currentMPinstance{#1}%
+ \ifempty\currentMPinstance
+ \let\currentMPinstance\defaultMPinstance
+ \fi
+ \let\currentMPgraphicname\empty
+ \edef\currentMPformat{\MPinstanceparameter\s!format}%
+ \meta_enable_include
+ \meta_process_graphic{#2;draw origin}%
+ \egroup
+ \endgroup}
+
+\aliased\let\stopMPcalculation\relax
+
+%D \macros
+%D {setupMPgraphics}
+%D
+%D Here is a generic setup command:
+
+\installcorenamespace{MPgraphics}
+
+\installsetuponlycommandhandler \??MPgraphics {MPgraphics}
+
+%D Here we hook in the outer color. When \type {color} is set to \type {global} we
+%D get the outer color automatically. If you change this setting, you should do it
+%D grouped in order not to make other graphics behave in unexpected ways.
+
+\appendtoks
+ \doifelse{\directMPgraphicsparameter\c!color}\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}%
+\to \everysetupMPgraphics
+
+\setupMPgraphics
+ [\c!color=\v!local]
+
+% %D This can save some runtime: rename the mpy file from a first run (when stable) to
+% %D another file and reuse it. One can also use the original filename, but a copy is
+% %D often better.
+% %D
+% %D \starttyping
+% %D \setupMPgraphics
+% %D [mpy=\jobname.mpy]
+% %D \stoptyping
+%
+% \mutable\let\MPdataMPYfile\empty
+%
+% \appendtoks
+% \edef\p_mpy{\directMPgraphicsparameter{mpy}}%
+% \ifempty\p_mpy \else
+% \let\MPdataMPYfile\p_mpy
+% \clf_registermpyfile{\p_mpy}%
+% \fi
+% \to \everysetupMPgraphics
+
+%D Some more helpers (see \type {meta-grd.mkiv} for an example of usage):
+
+\permanent\def\MPdpar#1#2{\the\dimexpr#1#2\relax\empty}
+\permanent\def\MPnpar#1#2{\the\numexpr#1#2\relax\empty}
+\permanent\def\MPspar#1#2{"#1#2"}
+
+%D Done.
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-lua.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-lua.mkxl
new file mode 100644
index 00000000000..e06677d5eef
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-lua.mkxl
@@ -0,0 +1,95 @@
+%D \module
+%D [ file=meta-lua,
+%D version=2012.07.23,
+%D title=\METAPOST\ Integrated Graphics,
+%D subtitle=Templates,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Don't use this code yet. I use it in some experimental rendering of graphics
+%D based on output from database queries. It's not that pretty but will be
+%D considered when the (similar) lmx code is redone. Also, dropping the print
+%D variant makes it nicer. This experiment is part of playing with several template
+%D mechanisms. (Also see trac-lmx.)
+%D
+%D Note for myself: see if the (bar)chart code use in q2p can use this kind of
+%D magic. Basically we then need a channel to data.
+
+\writestatus{loading}{MetaPost Library Graphics / Templates}
+
+\registerctxluafile{meta-lua}{}
+
+\continueifinputfile{meta-lua.mkiv}
+
+\starttext
+
+% conforming btex ... etex
+
+\startbuffer[test-a]
+ blua for i=1,100,5 do elua
+ draw fullcircle scaled (blua p(i) elua * cm) withcolor green withpen pencircle scaled 4 ;
+ blua end elua
+
+ blua for i=1,100,10 do elua
+ draw fullcircle scaled (blua p(i) elua * cm) withcolor red withpen pencircle scaled 2 ;
+ blua end elua
+\stopbuffer
+
+\startMPpage[offset=10pt]
+ input "mpstemplate://buffer?name=test-a" ;
+\stopMPpage
+
+% conforming lmx
+
+\startbuffer[test-b]
+
+ draw fullcircle scaled ( * cm) withcolor green withpen pencircle scaled 4 ;
+
+
+
+ draw fullcircle scaled ( * cm) withcolor red withpen pencircle scaled 2 ;
+
+\stopbuffer
+
+\startMPpage[offset=10pt]
+ input "mpstemplate://buffer?name=test-b" ;
+\stopMPpage
+
+\startMPpage[offset=10pt]
+ picture p[] ; % we can't input nested
+ input "mpstemplate://buffer?name=test-a&method=metapost" ;
+ p[1] := currentpicture ; currentpicture := nullpicture ;
+ input "mpstemplate://buffer?name=test-b&method=xml" ;
+ p[2] := currentpicture ; currentpicture := nullpicture ;
+ draw p[1] ysized 3cm ;
+ draw p[2] ysized 4cm shifted (4cm,0) ;
+\stopMPpage
+
+% a mixture (using a wrapped input)
+
+\startMPpage[offset=10pt]
+ draw image (loadfile("mpstemplate://buffer?name=test-a&method=metapost")) ysized 3cm shifted (4cm,0cm) ;
+ draw image (loadfile("mpstemplate://buffer?name=test-b&method=xml")) ysized 3cm shifted (0cm,4cm) ;
+ draw loadimage ("mpstemplate://buffer?name=test-a&method=metapost") ysized 4cm shifted (4cm,4cm) ;
+ draw loadimage ("mpstemplate://buffer?name=test-b&method=xml") ysized 4cm shifted (0cm,0cm) ;
+\stopMPpage
+
+% conforming myself
+
+\startluacode
+ context.startMPpage { offset = "10pt" }
+ for i=1,100,5 do
+ context("draw fullcircle scaled (%s * cm) withcolor green withpen pencircle scaled 4 ;",i)
+ end
+ for i=1,100,10 do
+ context("draw fullcircle scaled (%s * cm) withcolor red withpen pencircle scaled 2 ;",i)
+ end
+ context.stopMPpage()
+\stopluacode
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-mac.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-mac.mkxl
new file mode 100644
index 00000000000..76b7396ae9e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-mac.mkxl
@@ -0,0 +1,45 @@
+%D \module
+%D [ file=meta-scn,
+%D version=2019.07.19,
+%D title=\METAPOST\ Graphics,
+%D subtitle=LMTX support,
+%D author=Hans Hagen,
+%D date=\ currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\permanent\protected\def\defineMPparameterset[#1]{\clf_lmt_parameters_define{#1}}
+\permanent\protected\def\presetMPparameters [#1]{\clf_lmt_parameters_preset{#1}}
+\permanent\protected\def\resetMPparameters [#1]{\clf_lmt_parameters_reset {#1}}
+
+\permanent\tolerant\protected\def\useMPmacro[#1]#*[#2]#*[#3]%
+ {\ifarguments\or
+ \let\currentMPinstance\defaultMPinstance
+ \meta_enable_include
+ \meta_process_graphic{lmt_#1;}%
+ \or
+ \doifelseassignment{#2}
+ {\let\currentMPinstance\defaultMPinstance
+ \meta_enable_include
+ \clf_lmt_parameters_preset{#1}[#2]%
+ \meta_process_graphic{lmt_#1;}%
+ \clf_lmt_parameters_reset{#1}}%
+ {\meta_begin_graphic_group{#1}%
+ \meta_enable_include
+ \meta_process_graphic{lmt_#1;}%
+ \meta_end_graphic_group}%
+ \or
+ \meta_begin_graphic_group{#1}%
+ \meta_enable_include
+ \clf_lmt_parameters_preset{#2}[#3]%
+ \meta_process_graphic{lmt_#2;}%
+ \clf_lmt_parameters_reset{#2}%
+ \meta_end_graphic_group
+ \fi}
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-nod.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-nod.mkxl
new file mode 100644
index 00000000000..0fbfefde0c8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-nod.mkxl
@@ -0,0 +1,248 @@
+%D \module
+%D [ file=meta-nod,
+%D version=2016.11.23,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Nodes,
+%D author={Alan Braslau and Hans Hagen},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{meta-nod}{}
+
+\unprotect
+
+\defineMPinstance
+ [nodes]
+ [\s!format=metafun,
+ \s!extensions=\v!yes,
+ \s!initializations=\v!yes,
+ \c!method=\s!double]
+
+\defineframed
+ [node]
+ [\c!frame=\v!off]
+
+\defineframed
+ [smallnode]
+ [node]
+ [\c!foregroundstyle=\small]
+
+% \startMPdefinitions{nodes}
+% loadmodule "node" ;
+% \stopMPdefinitions
+
+\protect
+
+%D This module provides a simple \TEX\ layer on top of the nodes library that is
+%D preloaded in \METAFUN. More information can be found in the manual and article.
+%D
+%D We strongly advice to use the \METAPOST\ interface and only provide this \TEX\
+%D variant as proof of concept. There are no plans to extend this module because we
+%D see no advantage in using a \TEX\ interface over a \METAPOST\ one.
+%D
+%D \startbuffer
+%D \startnodes
+%D \placenode[0,0]{A}
+%D \placenode[1,0]{B}
+%D \connectnodes [0,1] [option=doublearrow]
+%D \stopnodes
+%D
+%D \startnodes[dx=2cm,rotation=45]
+%D \placenode[0,0]{A}
+%D \placenode[1,0]{B}
+%D \placenode[1,1]{C}
+%D \placenode[0,1]{D}
+%D \connectnodes [0,2] [option=doublearrow,label=a,offset=.05]
+%D \connectnodes [1,3] [option=doublearrows]
+%D \stopnodes
+%D
+%D \startnodes[dx=2cm,dy=2cm]
+%D \nodeMPcode{ahlength := 12pt ; ahangle := 30 ; ahvariant := 1 ;}
+%D \mpcode{ahlength := 12pt ; ahangle := 30 ; ahvariant := 1 ;}
+%D \placenode[0,1]{\node{A}}
+%D \placenode[1,1]{\node{B}}
+%D \placenode[0,0]{\node{C}}
+%D \placenode[1,0]{\node{D}}
+%D \connectnodes [0,3] [option=arrow,label={ }]
+%D \connectnodes [1,2] [option=arrow]
+%D \stopnodes
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startlinecorrection \getbuffer \stoplinecorrection
+
+\unprotect
+
+\installcorenamespace{metanodes}
+\installcorenamespace{metanodesoption}
+\installcorenamespace{metanodesalternative}
+\installcorenamespace{metanodesposition}
+
+% todo: maybe instances
+
+\installparameterhandler \??metanodes {metanodes}
+\installsetuphandler \??metanodes {metanodes}
+
+\setupmetanodes
+ [\c!option =,
+ \c!alternative =,
+ \c!offset =0,
+ \c!position =,
+ \c!label =,
+ \c!dx =2\emwidth,
+ \c!dy =2\emwidth,
+ \c!rotation =90,
+ \c!rulethickness =.5pt,
+ \c!command =]
+
+\newtoks\t_every_meta_nodes
+\newtoks\t_meta_nodes
+
+%D Hm, we started out simple but it now quickly becomes the usual mess of \TEX,
+%D \METAPOST\ and \LUA. Hard to understand.
+
+\newcount\c_meta_nodes_n
+
+\aliased\let\stopnodes\relax
+
+\permanent\tolerant\protected\def\startnodes[#1]#:#2\stopnodes
+ {\hpack\bgroup
+ \setupcurrentmetanodes[#1]%
+ \edef\p_meta_option{\metanodesparameter\c!option}%
+ \edef\p_meta_alternative{\metanodesparameter\c!alternative}%
+ \the\t_every_meta_nodes
+ \c_meta_nodes_n\zerocount
+ \t_meta_nodes\emptytoks
+ #2\removeunwantedspaces
+ % for alan, will be commented:
+ \writestatus{metanodes}{\detokenize\expandafter{\the\t_meta_nodes}}%
+ \clf_grph_nodes_initialize
+ \startMPcode
+ mfun_node_init(%
+ \the\dimexpr\metanodesparameter\c!dx\relax,%
+ \the\dimexpr\metanodesparameter\c!dy\relax,%
+ \metanodesparameter\c!rotation%
+ ) ;
+ \the\t_meta_nodes ;
+ mfun_node_flush ;
+ \stopMPcode
+ \clf_grph_nodes_reset
+ \egroup}
+
+\permanent\tolerant\protected\def\grph_nodes_node[#1]#*[#2]%
+ {\grph_nodes_node_indeed[#1][#2]}
+
+\def\grph_nodes_node_indeed[#1,#2][#3]#4%
+ {\begingroup
+ \setupcurrentmetanodes[#3]%
+ \edef\p_label{#4}%
+ \edef\p_reference{\metanodesparameter\c!reference}%
+ \ifempty\p_reference\else
+ \clf_grph_nodes_register{\p_reference}\c_meta_nodes_n\relax
+ \fi
+ \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{%
+ mfun_node_make(\number#1,\number#2%
+ \ifempty\p_label
+ ,""%
+ \else
+ ,"\metanodesparameter\c!command{\p_label}"%
+ \fi
+ );%
+ }}%
+ \advance\c_meta_nodes_n\plusone}
+
+\aliased\let\placenode\relax
+
+\appendtoks
+ \enforced\let\placenode\grph_nodes_node
+\to \t_every_meta_nodes
+
+\permanent\tolerant\protected\def\grph_nodes_fromto[#1]#*[#2]%
+ {\grph_nodes_fromto_indeed[#1][#2]}% get rid of {n,m} % todo: we can use #_ or so
+
+\letvalue{\??metanodesposition }\empty
+\setvalue{\??metanodesposition top}{.top}
+\setvalue{\??metanodesposition bottom}{.bot}
+\setvalue{\??metanodesposition left}{.lft}
+\setvalue{\??metanodesposition right}{.rt}
+\setvalue{\??metanodesposition upperleft}{.ulft}
+\setvalue{\??metanodesposition topleft}{.ulft}
+\setvalue{\??metanodesposition lefttop}{.ulft}
+\setvalue{\??metanodesposition upperright}{.urt}
+\setvalue{\??metanodesposition topright}{.urt}
+\setvalue{\??metanodesposition righttop}{.urt}
+\setvalue{\??metanodesposition lowerleft}{.llft}
+\setvalue{\??metanodesposition bottomleft}{.llft}
+\setvalue{\??metanodesposition leftbottom}{.llft}
+\setvalue{\??metanodesposition lowerright}{.lrt}
+\setvalue{\??metanodesposition bottomright}{.lrt}
+\setvalue{\??metanodesposition rightbottom}{.lrt}
+
+\def\grph_nodes_fromto_indeed[#1,#2][#3]% we can't group because etoksapp doesn't like that
+ {\begingroup
+ \setupcurrentmetanodes[#3]%
+ \edef\p_label {\metanodesparameter\c!label}%
+ \edef\p_rulethickness{\metanodesparameter\c!rulethickness}%
+ \edef\p_command {\metanodesparameter\c!command}% better get an error early
+ \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{%
+ \ifcsname\??metanodesalternative\metanodesparameter\c!alternative\endcsname
+ \lastnamedcs
+ \else
+ \csname\??metanodesalternative\endcsname
+ \fi
+ \space
+ mfun_nodes_fromto\begincsname\??metanodesposition\metanodesparameter\c!position\endcsname(%
+ \metanodesparameter\c!offset,%
+ % \number#1,\number#2%
+ \clf_grph_nodes_resolve{#1},\clf_grph_nodes_resolve{#2}%
+ \ifempty\p_label
+ ,""%
+ \else
+ ,"\ifempty\p_command\p_label\else\p_command{\p_label}\fi"%
+ \fi
+ )%
+ \space
+ \ifcsname\??metanodesoption\metanodesparameter\c!option\endcsname
+ \lastnamedcs
+ \else
+ \csname\??metanodesoption\endcsname
+ \fi
+ \space
+ \ifempty\p_rulethickness \else
+ withpen pencircle scaled \the\dimexpr\p_rulethickness\relax
+ \fi
+ ;%
+ }}}
+
+\setvalue{\??metanodesalternative }{draw}
+\setvalue{\??metanodesalternative arrow}{drawarrow}
+\setvalue{\??metanodesalternative doublearrow}{drawdblarrow}
+\setvalue{\??metanodesalternative doublearrows}{drawdoublearrows}
+
+\setvalue{\??metanodesoption }{}
+\setvalue{\??metanodesoption dashed}{dashed evenly}
+\setvalue{\??metanodesoption dotted}{dashed withdots scaled .5}
+
+\aliased\let\connectnodes\relax
+
+\appendtoks
+ \enforced\let\connectnodes\grph_nodes_fromto
+\to \t_every_meta_nodes
+
+\permanent\protected\def\grph_nodes_code#1%
+ {\etoksapp\t_meta_nodes{#1}}
+
+\aliased\let\mpcode \relax
+\aliased\let\nodeMPcode\relax
+
+\appendtoks
+ \enforced\let\nodeMPcode\grph_nodes_code
+ \enforced\let\mpcode \grph_nodes_code
+\to \t_every_meta_nodes
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-pag.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-pag.mkxl
new file mode 100644
index 00000000000..86de11eeb5c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-pag.mkxl
@@ -0,0 +1,26 @@
+%D \module
+%D [ file=meta-pag,
+%D version=1999.07.10,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D These definitions used to be part of the old \type {core-mps} file, later changed
+%D into \type {meta-ini}, but keeping them separate is cleaner. In the meantime not
+%D that much is left here.
+
+\writestatus{loading}{MetaPost Graphics / Page Data Management}
+
+\unprotect
+
+\prependtoks
+ \calculatereducedvsizes % bah, this is really needed
+\to \everyMPgraphic
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-pdf.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-pdf.mkxl
new file mode 100644
index 00000000000..d53ff7780f6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-pdf.mkxl
@@ -0,0 +1,95 @@
+%D \module
+%D [ file=meta-pdf,
+%D version=2006.06.07,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Conversion to \PDF,
+%D author=Hans Hagen \& others (see text),
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{meta-pdf}{}
+
+\writestatus{loading}{MetaPost Graphics / MPS to PDF}
+
+\unprotect
+
+%D \macros
+%D {convertMPtoPDF}
+%D
+%D The next set of macros implements \METAPOST\ to \PDF\ conversion. The traditional
+%D method is in the MkII files and the older \MKIV\ method is kept in meta-pdh
+%D files. The main conversion command is still the same but the scale parameters are
+%D ignored in \MKIV:
+%D
+%D \starttyping
+%D \convertMPtoPDF {filename} {x scale} {y scale}
+%D \stoptyping
+%D
+%D Much code has gone due to the fact that we now use pre and post scripts and no
+%D specials. This also means that you should use a modern \METAPOST\ or reprocess
+%D graphics. The color control flags are also gone as we now integrate into the
+%D regular colorspace handling (i.e.\ no longer independent configurations.)
+
+\permanent\def\PDFMPformoffset{\ifdefined\objectoffset\objectoffset\else\zeropoint\fi} % obsolete, will go
+
+\mutable\let\MPfilename\empty
+
+\permanent\protected\def\convertMPtoPDF#1#2#3% scaling no longer supported at this level (so #2 & #3 are ignored)
+ {\dostarttagged\t!mpgraphic\empty
+ \naturalvpack attr \imageattribute 1 \bgroup
+ \message{[MP to PDF]}%
+ \xdef\MPfilename{#1}%
+ \resetMPboundingbox
+ \forgetall
+ \offinterlineskip
+ \setbox\MPbox\vpack\bgroup
+ \clf_convertmpstopdf{\MPfilename}%
+ \removeunwantedspaces % not that needed
+ \egroup
+ \finalizeMPbox
+ \box\MPbox
+ \egroup
+ \dostoptagged}
+
+\protect \endinput
+
+%D Test code:
+%D
+%D \startbuffer
+%D \startMPcode
+%D fill fullcircle scaled 3cm withcolor red ;
+%D fill fullcircle scaled 2cm withcolor green ;
+%D fill fullcircle scaled 1cm withcolor blue ;
+%D currentpicture := currentpicture shifted (-4cm,0) ;
+%D fill fullcircle scaled 3cm withcolor cmyk(0,0,1,0) ;
+%D fill fullcircle scaled 2cm withcolor cmyk(0,1,0,0) ;
+%D fill fullcircle scaled 1cm withcolor cmyk(0,0,1,0) ;
+%D currentpicture := currentpicture shifted (-4cm,0) ;
+%D draw fullcircle scaled 3cm dashed evenly ;
+%D draw fullcircle scaled 2cm dashed withdots ;
+%D draw origin withpen pencircle scaled 3mm;
+%D currentpicture := currentpicture shifted (-4cm,0) ;
+%D fill fullcircle scaled 2cm shifted (-.5cm,+.5cm) withcolor transparent(1,.5,red);
+%D fill fullcircle scaled 2cm shifted (-.5cm,-.5cm) withcolor transparent(1,.5,red);
+%D fill fullcircle scaled 2cm shifted (+.5cm,+.5cm) withcolor transparent(1,.5,green);
+%D fill fullcircle scaled 2cm shifted (+.5cm,-.5cm) withcolor transparent(1,.5,cmyk(1,0,1,.5));
+%D currentpicture := currentpicture shifted (12cm,-4cm) ;
+%D draw "o e p s" infont defaultfont scaled 2 shifted (-1cm,0) ;
+%D currentpicture := currentpicture shifted (-4cm,0) ;
+%D % bug: shift
+%D draw fullcircle scaled 3cm withpen pencircle yscaled 3mm xscaled 2mm rotated 30 ;
+%D draw fullcircle scaled 2cm withpen pencircle yscaled 3mm xscaled 2mm rotated 20 withcolor red ;
+%D filldraw fullcircle scaled 1cm withpen pencircle yscaled 3mm xscaled 2mm rotated 10 withcolor green ;
+%D currentpicture := currentpicture shifted (-4cm,0) ;
+%D % shade cannot handle shift
+%D circular_shade(fullcircle scaled 3cm,0,.2red,.9green) ;
+%D circular_shade(fullcircle scaled 3cm shifted(+4cm,0),0,cmyk(1,0,0,0),cmyk(0,1,0,0)) ;
+%D filldraw boundingbox currentpicture enlarged -3cm withpen pencircle scaled 1pt withcolor .5white ;
+%D \stopMPcode
+%D \stopbuffer
+%D
+%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-pdh.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-pdh.mkxl
new file mode 100644
index 00000000000..e2d0e15b62c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-pdh.mkxl
@@ -0,0 +1,716 @@
+%D \module
+%D [ file=meta-pdf,
+%D version=2006.06.07,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Conversion to \PDF,
+%D author=Hans Hagen \& others (see text),
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\endinput
+
+%D Formerly known as supp-pdf.tex and supp-mpe.tex and meta-pdf.mkiv.
+%D
+%D Beware: this file is not used but kept for historic purposed! Never
+%D mix this one into mkiv again as it uses other variables.
+
+% \useMPgraphic{1}
+% \testfeatureonce{250}{\setbox0\hbox{\convertMPtoPDF{test-mps-mpgraph.1}{1}{1}}}
+%
+% 8.4 : mkii, direct parsing by tex
+% 11.8 : mkiv, dirty conversion (10.8 with dirty tricks)
+% 14.5 : mkiv, clean conversion
+% 7.4 : mkiv, simulated clean direct lua from mp
+% 0.3 : time taken by tex to handle converted code
+%
+% timings may differ now that we revamped the backend
+
+\registerctxluafile{meta-pdf}{}
+
+%D We will clean up the color mess later.
+
+\writestatus{loading}{MetaPost Graphics / MPS to PDF}
+
+\unprotect
+
+%D First we define a handy constant:
+
+\bgroup \catcode\commentasciicode\othercatcode \xdef\letterpercent{\string%} \egroup
+
+%D \macros
+%D {convertMPtoPDF}
+%D
+%D The next set of macros implements \METAPOST\ to \PDF\
+%D conversion. The traditional method is in the MkII file.
+%D
+%D The main conversion command is:
+%D
+%D \starttyping
+%D \convertMPtoPDF {filename} {x scale} {y scale}
+%D \stoptyping
+%D
+%D The dimensions are derived from the bounding box. So we
+%D only have to say:
+%D
+%D \starttyping
+%D \convertMPtoPDF{mp-pra-1.eps}{1}{1}
+%D \convertMPtoPDF{mp-pra-1.eps}{.5}{.5}
+%D \stoptyping
+
+%D \macros
+%D {makeMPintoPDFobject,lastPDFMPobject}
+%D
+%D For experts there are a few more options. When attributes
+%D are to be added, the code must be embedded in an object
+%D accompanied with the appropriate directives. One can
+%D influence this process with \type {\makeMPintoPDFobject}.
+%D
+%D This option defaults to~0, because \CONTEXT\ takes care
+%D of objects at another level, which saves some bytes.
+%D
+%D \starttabulate[|l|l|p|]
+%D \NC 0 \NC never \NC don't use an object \NC\NR
+%D \NC 1 \NC always \NC always use an object \NC\NR
+%D \NC 2 \NC optional \NC use object when needed \NC\NR
+%D \stoptabulate
+%D
+%D The last object number used is avaliable in the macro
+%D \type {\lastPDFMPobject}.
+
+\ifdefined\makeMPintoPDFobject \else \newconstant\makeMPintoPDFobject \fi
+\ifdefined\everyMPtoPDFconversion \else \newtoks \everyMPtoPDFconversion \fi
+
+\let\lastPDFMPobject \!!zerocount
+\let\currentPDFresources\empty
+\let\setMPextensions \relax
+
+\def\PDFMPformoffset{\ifdefined\objectoffset\objectoffset\else\zeropoint\fi}
+
+\def\resetMPvariables#1#2#3%
+ {\glet\MPwidth \!!zeropoint
+ \glet\MPheight \!!zeropoint
+ \glet\MPllx \!!zerocount
+ \glet\MPlly \!!zerocount
+ \glet\MPurx \!!zerocount
+ \glet\MPury \!!zerocount
+ \xdef\MPxscale {#2}\ifempty\MPxscale\let\MPxscale\!!plusone\fi
+ \xdef\MPyscale {#3}\ifempty\MPyscale\let\MPyscale\!!plusone\fi
+ \xdef\MPfilename {#1}}
+
+%D The main macro:
+
+\def\convertMPtoPDF#1#2#3% watch the transparency reset
+ {\resetMPvariables{#1}{#2}{#3}%
+ \vpack\bgroup
+ \forgetall
+ \offinterlineskip
+ \setbox\scratchbox\vpack\bgroup
+ \setnormalcatcodes % we can be in verbatim or so
+ \message{[MP to PDF]}%
+ \startMPresources
+ \pdfliteral{\letterpercent\space mps begin}%
+ \pdfliteral{q 1 0 0 1 0 0 cm}%
+ \ctxlua{metapost.mptopdf.convertmpstopdf("\MPfilename")}\removeunwantedspaces
+ \pdfliteral{Q}%
+ \pdfliteral{\letterpercent\space mps end}%
+ \stopMPresources
+ \egroup
+ \setbox\scratchbox\hpack\bgroup
+ \hskip-\MPllx\onebasepoint
+ \raise-\MPlly\onebasepoint
+ \box\scratchbox
+ \egroup
+ \setbox\scratchbox\vpack to \MPheight\bgroup
+ \vfill
+ \hsize\MPwidth
+ \smashbox\scratchbox
+ \box\scratchbox
+ \egroup
+ \wd\scratchbox\MPwidth
+ \ht\scratchbox\MPheight
+ \dopackageMPgraphic\scratchbox
+ \egroup}
+
+\let\processMPtoPDFfile\convertMPtoPDF
+
+%D A common hook.
+
+\let\MPfshowcommand\empty
+
+%D Objects.
+
+\def\dopackageMPgraphic#1% #1 = boxregister
+ {\ifcase\makeMPintoPDFobject\or\or\ifempty\currentPDFresources\else
+ % an existing value of 2 signals object support (set elsewhere)
+ \makeMPintoPDFobject\plusone
+ \fi\fi
+ \ifcase\makeMPintoPDFobject
+ \box#1%
+ \or
+ \scratchdimen\PDFMPformoffset\relax
+ \ifdim\scratchdimen>\zeropoint % compensate for error
+ \setbox#1\vpack spread 2\scratchdimen
+ {\forgetall\vss\hpack spread 2\scratchdimen{\hss\box#1\hss}\vss}%
+ \fi
+ \setMPPDFobject{\currentPDFresources}{#1}%
+ \ifdim\scratchdimen>\zeropoint % compensate for error
+ \vpack to \MPheight
+ {\forgetall\vss\hpack to \MPwidth{\hss\getMPPDFobject\hss}\vss}%
+ \else
+ \getMPPDFobject
+ \fi
+ \glet\currentPDFresources\empty
+ \else
+ \box#1%
+ \fi}
+
+\def\setMPPDFobject#1#2% resources boxnumber
+ {\ifdefined\everyPDFxform\the\everyPDFxform\fi
+ \immediate\saveboxresource resources{#1}#2%
+ \edef\getMPPDFobject{\noexpand\useboxresource\the\lastsavedboxresourceindex}}
+
+\let\getMPPDFobject\relax
+
+%D \macros
+%D {deleteMPgraphic,
+%D startMPresources,
+%D stopMPresources}
+
+\ifdefined\deleteMPgraphic \else
+ \def\deleteMPgraphic#1{}
+\fi
+
+\ifdefined\startMPresources \else
+ \let\startMPresources\relax
+ \let\stopMPresources\relax
+\fi
+
+%D We implement extensions by using the \METAPOST\ special
+%D mechanism. Opposite to \TEX's specials, the \METAPOST\ ones
+%D are flushed before or after the graphic data, but thereby
+%D are no longer connected to a position.
+%D
+%D We implement specials by overloading the \type {fill}
+%D operator. By counting the fills, we can let the converter
+%D treat the appropriate fill in a special way. The
+%D specification of the speciality can have two forms,
+%D determined by the setting of a boolean variable:
+%D
+%D \starttyping
+%D _inline_specials_ := false ; % comment like code (default)
+%D _inline_specials_ := true ; % command like code
+%D \stoptyping
+%D
+%D When the specification is embedded as comment, it looks
+%D like:
+%D
+%D \starttyping
+%D %%MetaPostSpecial
+%D \stoptyping
+%D
+%D The in||line alternative is more tuned for \POSTSCRIPT,
+%D since it permits us to define a macro \type {special}.
+%D
+%D \starttyping
+%D inline : special
+%D \stoptyping
+%D
+%D The \type {identifier} determines what to do, and the data
+%D can be used to accomplish this. A type~2 shading function
+%D has identifier~2. Alltogether, the number of parameters is
+%D specified in \type {size}. The \type {number} is the number
+%D of the fill that needs the special treatment. For a type~2
+%D and~3 shaded fill, the datablock contains the following
+
+%D data:
+%D
+%D \starttyping
+%D from to n inner_r g b x y outer_r g b x y
+%D from to n inner_r g b x y radius outer_r g b x y radius
+%D \stoptyping
+
+\newconditional\manyMPspecials \settrue\manyMPspecials
+
+%D In case of \PDF, we need to prepare resourcs.
+
+\newtoks\MPstartresources
+\newtoks\MPstopresources
+
+\def\startMPresources
+ {\the\MPstartresources}
+
+\def\stopMPresources
+ {\the\MPstopresources}
+
+%D Some day we may consider collecting local resources.
+
+\appendtoks
+ \glet\currentPDFresources\empty % kind of redundant
+\to \MPstartresources
+
+% \appendtoks
+% \collectPDFresources
+% \glet\currentPDFresources\collectedPDFresources
+% \to \MPstopresources
+
+\appendtoksonce
+ \the\everyPDFxform
+\to \MPstopresources
+
+%D Special number~1 is dedicated to \CMYK\ support. If you
+%D want to know why: look at this:
+%D
+%D \startbuffer[mp]
+%D fill fullcircle xyscaled (3cm,1cm) withcolor \MPcolor{test} ;
+%D \stopbuffer
+%D
+%D \startbuffer[cmyk]
+%D \startcombination[4*1]
+%D {\definecolor[test][c=1,y=.3,k=.3] \processMPbuffer[mp]} {c=1 y=.3 k=.3}
+%D {\definecolor[test][c=.9,y=.15] \processMPbuffer[mp]} {c=.9 y=.15}
+%D {\definecolor[test][c=.25,y=.8] \processMPbuffer[mp]} {c=.25 y=.8}
+%D {\definecolor[test][c=.45,y=.1] \processMPbuffer[mp]} {c=.45 y=.1}
+%D \stopcombination
+%D \stopbuffer
+%D
+%D \placefigure
+%D {\CMYK\ support disabled,
+%D conversion to \RGB.}
+%D {\setupcolors[cmyk=nee,state=start]\getbuffer[cmyk]}
+%D
+%D \placefigure
+%D {\CMYK\ support enabled,
+%D no support in \METAPOST.}
+%D {\setupcolors[cmyk=ja,mpcmyk=nee,state=start]\getbuffer[cmyk]}
+%D
+%D \placefigure
+%D {\CMYK\ support enabled,
+%D no conversion to \RGB,
+%D support in \METAPOST}
+%D {\setupcolors[cmyk=ja,state=start]\getbuffer[cmyk]}
+
+% \let\revokeMPtransparencyspecial\relax
+
+%D Transparency support used specials 60 (rgb) and 61
+%D (cmyk).
+%D
+%D \startbuffer
+%D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0);
+%D
+%D fill p rotated 90 withcolor transparent(1,.5,yellow) ;
+%D fill p rotated 210 withcolor transparent(1,.5,green) ;
+%D fill p rotated 330 withcolor transparent(1,.5,blue) ;
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startlinecorrection \processMPbuffer \stoplinecorrection
+%D
+%D One can also communicate colors between \CONTEXT\ and
+%D \METAPOST:
+%D
+%D \startbuffer
+%D \definecolor[tcyan] [c=1,k=.2,t=.5]
+%D \definecolor[tmagenta][m=1,k=.2,t=.5]
+%D \definecolor[tyellow] [y=1,k=.2,t=.5]
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0);
+%D
+%D fill p rotated 90 withcolor \MPcolor{tcyan} ;
+%D fill p rotated 210 withcolor \MPcolor{tmagenta} ;
+%D fill p rotated 330 withcolor \MPcolor{tyellow} ;
+%D \stopbuffer
+%D
+%D \startlinecorrection \processMPbuffer \stoplinecorrection
+
+%D Shading is an example of a more advanced graphic feature,
+%D but users will seldom encounter those complications. Here
+%D we only show a few simple examples, but many other
+%D alternatives are possible by setting up the functions built
+%D in \PDF\ in the appropriate way.
+%D
+%D Shading has to do with interpolation between two or more
+%D points or user supplied ranges. In \PDF, the specifications
+%D of a shade has to be encapsulated in objects and passed on
+%D as resources. This is a \PDF\ level 1.3. feature. One can
+%D simulate three dimensional shades as well and define simple
+%D functions using a limited set of \POSTSCRIPT\ primitives.
+%D Given the power of \METAPOST\ and these \PDF\ features, we
+%D can achieve superb graphic effects.
+%D
+%D Since everything is hidden in \TEX\ and \METAPOST\ graphics,
+%D we can stick to high level \CONTEXT\ command, as shown in
+%D the following exmples.
+%D
+%D \startbuffer
+%D \startuniqueMPgraphic{CircularShade}
+%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ;
+%D circular_shade(p,0,.2red,.9red) ;
+%D \stopuniqueMPgraphic
+%D
+%D \startuniqueMPgraphic{LinearShade}
+%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ;
+%D linear_shade(p,0,.2blue,.9blue) ;
+%D \stopuniqueMPgraphic
+%D
+%D \startuniqueMPgraphic{DuotoneShade}
+%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ;
+%D linear_shade(p,2,.5green,.5red) ;
+%D \stopuniqueMPgraphic
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer
+%D
+%D These graphics can be hooked into the overlay mechanism,
+%D which is available in many commands.
+%D
+%D \startbuffer
+%D \defineoverlay[demo 1][\uniqueMPgraphic{CircularShade}]
+%D \defineoverlay[demo 2][\uniqueMPgraphic {LinearShade}]
+%D \defineoverlay[demo 3][\uniqueMPgraphic {DuotoneShade}]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer
+%D
+%D These backgrounds can for instance be applied to \type
+%D {\framed}:
+%D
+%D \startbuffer
+%D \setupframed[width=3cm,height=2cm,frame=off]
+%D \startcombination[3*1]
+%D {\framed[backgroundachtergrond=demo 1]{\bfd \white Demo 1}} {}
+%D {\framed[backgroundachtergrond=demo 2]{\bfd \white Demo 2}} {}
+%D {\framed[backgroundachtergrond=demo 3]{\bfd \white Demo 3}} {}
+%D \stopcombination
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startlinecorrection
+%D \getbuffer
+%D \stoplinecorrection
+%D
+%D There are a few more alternatives, determined by the second
+%D parameter passed to \type {circular_shade} and alike.
+%D
+%D \def\SomeShade#1#2#3#4#5%
+%D {\startuniqueMPgraphic{Shade-#1}
+%D width := OverlayWidth ;
+%D height := OverlayHeight ;
+%D path p ; p := unitsquare xscaled width yscaled height ;
+%D #2_shade(p,#3,#4,#5) ;
+%D \stopuniqueMPgraphic
+%D \defineoverlay[Shade-#1][\uniqueMPgraphic{Shade-#1}]%
+%D \framed[backgroundachtergrond=Shade-#1,width=2cm,height=2cm,frame=off]{}}
+%D
+%D \startlinecorrection
+%D \startcombination[5*1]
+%D {\SomeShade{10}{circular}{0}{.3blue}{.9blue}} {circular 0}
+%D {\SomeShade{11}{circular}{1}{.3blue}{.9blue}} {circular 1}
+%D {\SomeShade{12}{circular}{2}{.3blue}{.9blue}} {circular 2}
+%D {\SomeShade{13}{circular}{3}{.3blue}{.9blue}} {circular 3}
+%D {\SomeShade{14}{circular}{4}{.3blue}{.9blue}} {circular 4}
+%D \stopcombination
+%D \stoplinecorrection
+%D
+%D \blank
+%D
+%D \startlinecorrection
+%D \startcombination[5*1]
+%D {\SomeShade{20}{circular}{0}{.9green}{.3green}} {circular 0}
+%D {\SomeShade{21}{circular}{1}{.9green}{.3green}} {circular 1}
+%D {\SomeShade{22}{circular}{2}{.9green}{.3green}} {circular 2}
+%D {\SomeShade{23}{circular}{3}{.9green}{.3green}} {circular 3}
+%D {\SomeShade{24}{circular}{4}{.9green}{.3green}} {circular 4}
+%D \stopcombination
+%D \stoplinecorrection
+%D
+%D \blank
+%D
+%D \startlinecorrection
+%D \startcombination[4*1]
+%D {\SomeShade{30}{linear}{0}{.3red}{.9red}} {linear 0}
+%D {\SomeShade{31}{linear}{1}{.3red}{.9red}} {linear 1}
+%D {\SomeShade{32}{linear}{2}{.3red}{.9red}} {linear 2}
+%D {\SomeShade{33}{linear}{3}{.3red}{.9red}} {linear 3}
+%D \stopcombination
+%D \stoplinecorrection
+%D
+%D These macros closely cooperate with the \METAPOST\ module
+%D \type {mp-spec.mp}, which is part of the \CONTEXT\
+%D distribution.
+%D
+%D The low level (\PDF) implementation is based on the \TEX\
+%D based \METAPOST\ to \PDF\ converter. Shading is supported
+%D by overloading the \type {fill} operator as implemented
+%D earlier. In \PDF\ type~2 and~3 shading functions are
+%D specified in terms of:
+%D
+%D \starttabulate[|Tl|l|]
+%D \NC /Domain \NC sort of meeting range \NC \NR
+%D \NC /C0 \NC inner shade \NC \NR
+%D \NC /C1 \NC outer shade \NC \NR
+%D \NC /N \NC smaller values, bigger inner circles \NC \NR
+%D \stoptabulate
+
+% \newcount\currentPDFshade % 0 % global (document wide) counter
+%
+% \def\dosetMPsomePDFshade#1#2%
+% {\immediate\pdfobj
+% {<>}%
+% \immediate\pdfobj
+% {<>}%
+% \global\advance\currentPDFshade \plusone
+% \ctxlua{lpdf.adddocumentshade("Sh\the\currentPDFshade",lpdf.reference(\the\pdflastobj))}%
+% \setxvalue{\@@MPSK#2}{\noexpand\dohandleMPshade{\the\currentPDFshade}}}
+%
+% \def\dosetMPlinearshade {\dosetMPsomePDFshade2}% #1
+% \def\dosetMPcircularshade{\dosetMPsomePDFshade3}% #1
+%
+% \defineMPspecial{30}
+% {\normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs4}{\gMPs5}{\gMPs6}}\to\MPshadeA
+% \normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs{9}}{\gMPs{10}}{\gMPs{11}}}\to\MPshadeB
+% \edef\MPshadeC{\gMPs7 \gMPs8 \gMPs{12} \gMPs{13}}%
+% \dosetMPlinearshade{\gMPs{14}}}
+%
+% \defineMPspecial{31}
+% {\normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs4}{\gMPs5}{\gMPs6}}\to\MPshadeA
+% \normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}}\to\MPshadeB
+% \edef\MPshadeC{\gMPs7 \gMPs8 \gMPs9 \gMPs{13} \gMPs{14} \gMPs{15}}%
+% \dosetMPcircularshade{\gMPs{16}}}
+%
+% \defineMPspecial{32}
+% {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA
+% \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}}\to\MPshadeB
+% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{14} \gMPs{15}}%
+% \dosetMPlinearshade{\gMPs{16}}}
+%
+% \defineMPspecial{33}
+% {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA
+% \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}{\gMPs{14}}}\to\MPshadeB
+% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{10} \gMPs{15} \gMPs{16} \gMPs{17}}%
+% \dosetMPcircularshade{\gMPs{18}}}
+%
+% \defineMPspecial{34}
+% {\normalexpanded{\noexpand\resolveMPspotcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA
+% \normalexpanded{\noexpand\resolveMPspotcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}}\to\MPshadeB
+% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{14} \gMPs{15}}%
+% \dosetMPlinearshade{\gMPs{16}}}
+%
+% \defineMPspecial{35}
+% {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA
+% \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}{\gMPs{14}}}\to\MPshadeB
+% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{10} \gMPs{15} \gMPs{16} \gMPs{17}}%
+% \dosetMPcircularshade{\gMPs{18}}}
+%
+% \newconditional\ignoreMPpath
+%
+% \def\dohandleMPshade#1%
+% {\revokeMPtransparencyspecial
+% \settrue\ignoreMPpath
+% \def\extraMPpathcode{/Sh#1 sh Q}%
+% \pdfliteral{q /Pattern cs}}
+%
+% \defineMPspecial{10}
+% {\setxvalue{\@@MPSK\gMPs8}%
+% {\noexpand\handleMPfigurespecial{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}{\gMPs8}}}
+%
+% \def\handleMPfigurespecial#1#2#3#4#5#6#7#8% todo : combine with ext fig
+% {\letgvalueempty{\@@MPSK#8}%
+% \vbox to \zeropoint
+% {\vss
+% \hbox to \zeropoint
+% {\ifcase\pdfoutput\or % will be hooked into the special driver
+% \doiffileelse{#7}
+% {\doifundefinedelse{mps:x:#7}
+% {\immediate\pdfximage\s!width\onebasepoint\s!height\onebasepoint{#7}%
+% \setxvalue{mps:x:#7}{\pdfrefximage\the\pdflastximage}}%
+% {\message{[reusing figure #7]}}%
+% \pdfliteral{q #1 #2 #3 #4 #5 #6 cm}%
+% \rlap{\getvalue{mps:x:#7}}%
+% \pdfliteral{Q}}
+% {\message{[unknown figure #7]}}%
+% \fi
+% \hss}}}
+
+%D An example of using both special features is the
+%D following.
+%D
+%D \starttyping
+%D \startMPpage
+%D externalfigure "hakker1b.png" scaled 22cm rotated 10 shifted (-2cm,0cm);
+%D externalfigure "hakker1b.png" scaled 10cm rotated -10 ;
+%D externalfigure "hakker1b.png" scaled 7cm rotated 45 shifted (8cm,12cm) ;
+%D path p ; p := unitcircle xscaled 15cm yscaled 20cm;
+%D path q ; q := p rotatedaround(center p,90) ;
+%D path r ; r := buildcycle(p,q) ; clip currentpicture to r ;
+%D path s ; s := boundingbox currentpicture enlarged 5mm ;
+%D picture c ; c := currentpicture ; currentpicture := nullpicture ;
+%D circular_shade(s,0,.2red,.9red) ;
+%D addto currentpicture also c ;
+%D \stopMPpage
+%D \stoptyping
+
+% \defineMPspecial{20}
+% {\setxvalue{\@@MPSK\gMPs6}%
+% {\noexpand\handleMPhyperlink{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}}}
+%
+% \def\handleMPhyperlink#1#2#3#4#5#6%
+% {\letgvalueempty{\@@MPSK#6}%
+% \setbox\scratchbox\hbox
+% {\setbox\scratchbox\emptyhbox
+% \wd\scratchbox\dimexpr-#1\onebasepoint+#3\onebasepoint\relax
+% \ht\scratchbox\dimexpr-#2\onebasepoint+#4\onebasepoint\relax
+% \gotobox{\box\scratchbox}[#5]}%
+% \setbox\scratchbox\hbox
+% {\hskip\dimexpr\MPxoffset\onebasepoint+#1\onebasepoint\relax
+% \raise\dimexpr\MPyoffset\onebasepoint+#2\onebasepoint\relax
+% \box\scratchbox}%
+% \smashbox\scratchbox
+% \box\scratchbox}
+
+%D This special (number 50) passes positions to a tex file.
+%D This method uses a two||pass approach an (mis|)|used the
+%D context positioning macros. In \type {core-pos} we will
+%D implement the low level submacro needed.
+%D
+%D \startbuffer
+%D \definelayer[test]
+%D
+%D \setlayer
+%D [test]
+%D [x=\MPx{somepos-1},y=\MPy{somepos-1}]
+%D {Whatever we want here!}
+%D
+%D \setlayer
+%D [test]
+%D [x=\MPx{somepos-2},y=\MPy{somepos-2}]
+%D {Whatever we need there!}
+%D
+%D \startuseMPgraphic{oeps}
+%D draw fullcircle scaled 6cm withcolor red ;
+%D register ("somepos-1",1cm,2cm,center currentpicture) ;
+%D register ("somepos-2",4cm,3cm,(-1cm,-2cm)) ;
+%D \stopuseMPgraphic
+%D
+%D \framed[background=test,offset=overlay]{\useMPgraphic{oeps}}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D Here the width and height are not realy used, but one can
+%D imagine situations where tex has to work with values
+%D calculated by \METAPOST.
+%D
+%D \startlinecorrection
+%D \getbuffer
+%D \stoplinecorrection
+%D
+%D Later we will implement a more convenient macro:
+%D
+%D \starttyping
+%D \setMPlayer [test] [somepos-1] {Whatever we want here!}
+%D \setMPlayer [test] [somepos-2] {Whatever we need there!}
+%D \stoptyping
+
+\startMPinitializations
+ mp_shade_version := 2 ;
+\stopMPinitializations
+
+%D This is done much cleaner in \MPLIB.
+
+\def\MPStextext#1#2#3#4#5% if we clean up this plugin model, we can
+ {\def\MPtextdata{#3}% % delegate the splitter to lua + redesign
+ \def\MPtextsize{#2}%
+ \def\lastMPmoveX{#4}%
+ \def\lastMPmoveY{#5}%
+ \defconvertedcommand\MPtextdata\MPtextdata % no edef
+ \splitstring\MPtextdata\at::::\to\MPtexttag\and\MPtextnumber
+ \executeifdefined{handleMPtext\MPtexttag}
+ {\setbox\scratchbox\hbox % text
+ {\font\temp=#1\space at #2\onebasepoint
+ \let\c\char
+ \temp
+ \MPfshowcommand{#3}}%
+ \setbox\scratchbox\hpack
+ {\hskip#4\onebasepoint
+ \raise#5\onebasepoint
+ \box\scratchbox}%
+ \smashbox\scratchbox
+ \box\scratchbox}}
+
+We save the special variables on a stack. It's not that fast, but it make
+implementing the special more convenient.
+
+%D The boundingbox.
+
+\def\MPSboundingbox#1#2#3#4%
+ {\xdef\MPllx {#1}\xdef\MPlly{#2}\xdef\MPurx{#3}\xdef\MPury{#4}%
+ \xdef\MPwidth {\the\dimexpr#3\onebasepoint-#1\onebasepoint\relax}%
+ \xdef\MPheight{\the\dimexpr#4\onebasepoint-#2\onebasepoint\relax}}
+
+\MPSboundingbox0000
+
+%D Test code:
+
+% \startMPcode
+% fill fullcircle scaled 3cm withcolor red ;
+% fill fullcircle scaled 2cm withcolor green ;
+% fill fullcircle scaled 1cm withcolor blue ;
+% currentpicture := currentpicture shifted (-4cm,0) ;
+% fill fullcircle scaled 3cm withcolor cmyk(0,0,1,0) ;
+% fill fullcircle scaled 2cm withcolor cmyk(0,1,0,0) ;
+% fill fullcircle scaled 1cm withcolor cmyk(0,0,1,0) ;
+% currentpicture := currentpicture shifted (-4cm,0) ;
+% draw fullcircle scaled 3cm dashed evenly ;
+% draw fullcircle scaled 2cm dashed withdots ;
+% draw origin withpen pencircle scaled 3mm;
+% currentpicture := currentpicture shifted (-4cm,0) ;
+% fill fullcircle scaled 2cm shifted (-.5cm,+.5cm) withcolor transparent(1,.5,red);
+% fill fullcircle scaled 2cm shifted (-.5cm,-.5cm) withcolor transparent(1,.5,red);
+% fill fullcircle scaled 2cm shifted (+.5cm,+.5cm) withcolor transparent(1,.5,green);
+% fill fullcircle scaled 2cm shifted (+.5cm,-.5cm) withcolor transparent(1,.5,cmyk(1,0,1,.5));
+% currentpicture := currentpicture shifted (12cm,-4cm) ;
+% draw "o e p s" infont defaultfont scaled 2 shifted (-1cm,0) ;
+% currentpicture := currentpicture shifted (-4cm,0) ;
+% % bug: shift
+% draw fullcircle scaled 3cm withpen pencircle yscaled 3mm xscaled 2mm rotated 30 ;
+% draw fullcircle scaled 2cm withpen pencircle yscaled 3mm xscaled 2mm rotated 20 withcolor red ;
+% filldraw fullcircle scaled 1cm withpen pencircle yscaled 3mm xscaled 2mm rotated 10 withcolor green ;
+% currentpicture := currentpicture shifted (-4cm,0) ;
+% % shade cannot handle shift
+% circular_shade(fullcircle scaled 3cm,0,.2red,.9green) ;
+% circular_shade(fullcircle scaled 3cm shifted(+4cm,0),0,cmyk(1,0,0,0),cmyk(0,1,0,0)) ;
+% filldraw boundingbox currentpicture enlarged -3cm withpen pencircle scaled 1pt withcolor .5white ;
+% \stopMPcode
+
+% We cannot use attributes for switching colors in mp literals because
+% grouping (qQ) interferes.
+
+% \def\dohandleMPshade#1%
+% {\revokeMPtransparencyspecial
+% \settrue\ignoreMPpath
+% \def\extraMPpathcode{/#1 sh Q}%
+% \pdfliteral{q /Pattern cs}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-tex.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-tex.mkxl
new file mode 100644
index 00000000000..5937ce4083f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-tex.mkxl
@@ -0,0 +1,235 @@
+%D \module
+%D [ file=meta-tex,
+%D version=2006.06.07,
+%D title=\CONTEXT\ Support Macros,
+%D subtitle=\METAPOST\ fast text insertion,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{meta-tex}{}
+
+\unprotect
+
+% Ok, we support this in MkIV because Mojca kept the pressure on. It
+% looks a bit like a hack. But in fact this method is obsolete and
+% eventually might go away.
+
+\installcorenamespace{graphictextext}
+\installcorenamespace{graphictexdepth}
+\installcorenamespace{graphictexarguments}
+
+\permanent\protected\def\startTeXtexts#1\stopTeXtexts
+ {#1}
+
+\aliased\let\stopTeXtexts\relax
+
+\permanent\tolerant\protected\def\TeXtext[#1]#:#2#3% contrary to mkii we don't process yet but we do expand
+ {\setxvalue{\??graphictextext#2}{\meta_textext_indeed{#1}{#3}}}
+
+\protected\def\meta_textext_indeed#1#2%
+ {\begingroup
+ \setbox\nextbox\hbox{#2}%
+ \ifcsname\??graphictexdepth#1\endcsname
+ \lastnamedcs
+ \else
+ \syst_boxes_lower_nextbox_dp
+ \fi
+ \box\nextbox
+ \endgroup}
+
+\permanent\def\getTeXtext#1%
+ {\begincsname\??graphictextext#1\endcsname}
+
+\letvalue{\??graphictexdepth d}\syst_boxes_lower_nextbox_dp
+\letvalue{\??graphictexdepth \s!depth}\syst_boxes_lower_nextbox_dp
+\letvalue{\??graphictexdepth n}\donothing
+\letvalue{\??graphictexdepth\s!nodepth}\donothing
+
+% old hackery, slightly modernized
+
+\permanent\protected\def\definetextext[#1]%
+ {\tolerant\defcsname\??graphictexarguments#1\endcsname}
+
+\permanent\tolerant\def\sometxt[#1]#*[#2]%
+ {\ifarguments
+ \expandafter\meta_some_txt_a
+ \or
+ \expandafter\meta_some_txt_b
+ \or
+ \expandafter\meta_some_txt_c
+ \or
+ \fi{#1}{#2}}
+
+\def\meta_some_txt_a#1#2#3{textext.drt("\clf_metapostescaped{#3}")}
+\def\meta_some_txt_b#1#2#3{textext.drt("\mpsometxt{#1}{\clf_metapostescaped{#3}}")}
+\def\meta_some_txt_c#1#2#3{textext.drt("\mpsometxt{#1}[#2]{\clf_metapostescaped{#3}}")}
+
+\permanent\protected\def\mpsometxt#1%
+ {\begincsname\??graphictexarguments#1\endcsname}
+
+% \definetextext[framed]{\framed}
+%
+% \startMPcode
+% draw \sometxt[framed]{black} rotated 45 ;
+% \stopMPcode
+%
+% But Mojca wanted more! Two arguments.
+%
+% \definetextext[framed]{\framed}
+%
+% \startMPcode
+% draw \sometxt{This is for} rotated 45 ;
+% draw \sometxt[framed][foregroundstyle=bold]{Mojca's};
+% draw \sometxt[framed]{eyes only!} rotated -45 ;
+% \stopMPcode
+%
+% \definetextext[framed][#1]#2{\framed[width=4cm]{\switchtobodyfont[#1]#2}}
+% \definetextext[simple]{\framed[width=8cm]}
+%
+% \starttext
+%
+% \startMPcode
+% draw \sometxt{This is for} rotated 45 ;
+% draw \sometxt[framed][ss,16pt] {Mojca's};
+% draw \sometxt[framed]{eyes only!} rotated -45 ;
+% draw \sometxt[simple]{Quotes "indeed" work!} rotated 180 ;
+% \stopMPcode
+%
+% \stoptext
+%
+% a lua one:
+%
+% \protected\def\definetextext[#1]#2{\setvalue{@@st@@#1}{#2}}
+%
+% \def\sometxt #1#{\dosometxt{#1}} % grab optional [args]
+% \def\dosometxt #1#2{\ctxlua{metapost.sometxt(\!!bs#1\!!es,\!!bs#2\!!es)}}
+%
+% \def\sometxta #1{textext.drt("#1")}
+% \def\sometxtb #1#2{textext.drt("\getvalue{@@st@@#1}{#2}")}
+% \def\sometxtc #1#2#3{textext.drt("\getvalue{@@st@@#1}{\switchtobodyfont[#2]#3}")}
+
+% Best use the mp macro instead since it provides positioning.
+%
+% \startuseMPgraphic{testgraphic}
+% draw \sometxt{\ruledhbox{\strut hans hagen}} scaled 3;
+% % draw textext.drt("\ruledhbox{\strut hans hagen}") scaled 3;
+% % draw textext.dlft("\ruledhbox{\strut hans hagen}") scaled 3;
+% % draw textext.lft("\ruledhbox{\strut hans hagen}") scaled 3;
+% draw llcorner currentpicture -- urcorner currentpicture withcolor yellow;
+% draw lrcorner currentpicture -- ulcorner currentpicture withcolor yellow;
+% draw boundingbox currentpicture withcolor blue ;
+% draw origin withcolor red withpen pencircle scaled 1pt;
+% \stopuseMPgraphic
+%
+% {\showstruts\useMPgraphic{testgraphic}}
+
+\permanent\protected\def\MPexponent #1#2{\mathematics{#1\times10^{#2}}}
+\permanent\protected\def\MPformatted #1#2{\clf_metapostformatted{#1}{#2}}
+\permanent\protected\def\MPgraphformat#1#2{\clf_metapostgraphformat{#1}{#2}}
+
+%D Some new fun (but exprimental for a while):
+
+\permanent\protected\def\MPLIBoutlinetext#1#2#3% index kind text
+ {\begingroup
+ \setbox\scratchbox\hbox{#3}%
+ \clf_MPLIBconvertoutlinetext\numexpr#1\relax{#2}\scratchbox
+ \endgroup}
+
+%D For now here. We don't do the whole thing, because then one can as
+%D well just export to pdf. We assume consistent integration.
+
+\definefontsynonym[serif-normal-normal] [\s!Serif]
+\definefontsynonym[serif-normal-italic] [\s!SerifItalic]
+\definefontsynonym[serif-normal-oblique][\s!SerifSlanted]
+\definefontsynonym[serif-bold-normal] [\s!SerifBold]
+\definefontsynonym[serif-bold-italic] [\s!SerifBoldItalic]
+\definefontsynonym[serif-bold-oblique] [\s!SerifBoldSlanted]
+
+\definefontsynonym[sans-normal-normal] [\s!Sans]
+\definefontsynonym[sans-normal-italic] [\s!SansItalic]
+\definefontsynonym[sans-normal-oblique] [\s!SansSlanted]
+\definefontsynonym[sans-bold-normal] [\s!SansBold]
+\definefontsynonym[sans-bold-italic] [\s!SansBoldItalic]
+\definefontsynonym[sans-bold-oblique] [\s!SansBoldSlanted]
+
+\definefontsynonym[mono-normal-normal] [\s!Mono]
+\definefontsynonym[mono-normal-italic] [\s!MonoItalic]
+\definefontsynonym[mono-normal-oblique] [\s!MonoSlanted]
+\definefontsynonym[mono-bold-normal] [\s!MonoBold]
+\definefontsynonym[mono-bold-italic] [\s!MonoBoldItalic]
+\definefontsynonym[mono-bold-oblique] [\s!MonoBoldSlanted]
+
+\installcorenamespace {svgfamily}
+
+\setvalue{\??svgfamily }{serif}
+\setvalue{\??svgfamily serif}{serif}
+\setvalue{\??svgfamily sans}{sans}
+\setvalue{\??svgfamily mono}{mono}
+
+%D This can't change because otherwise \type {\scale[width=4cm]{graphic}} fails.
+
+\permanent\protected\def\svgscaled#1%
+ {\fastsxsy{#1}{#1}\svgnormal}
+
+\permanent\protected\def\svgnormal#1#2#3#4% family weight style text
+ {\bgroup
+ \edef\p_family{#1}%
+ \ifempty\p_family\else
+ \edef\p_font{\ifcsname\??svgfamily#1\endcsname\lastnamedcs\else#1\fi-#2-#3}%
+ \predefinedfont[\s!spec:\p_font*\s!default\space @ 10bp]%
+ \fi
+ #4%
+ \egroup}
+
+\permanent\protected\def\svgcolored#1#2#3#4% r g b text
+ {\colored[r=#1,g=#2,b=#3]{#4}}
+
+% \permanent\protected\def\svgplaced#1#2#3#4% dx dy width text
+% {\doifelsenothing{#3}%
+% {\hpack}%
+% {\hpack to #3}%
+% {\raise#2\onebasepoint\hbox{\kern#1\onebasepoint\relax#4}}}
+
+\permanent\protected\def\svgplaced#1#2#3#4% dx dy width text
+ {\doifelsenothing{#3}%
+ {\hpack}%
+ {\hpack to #3}%
+ {\offsetbox[\c!y=#2]\hbox{\kern#1\relax#4}}}
+
+\newdimen\grph_svg_scratchwidth % maybe \startsvgpos etc
+
+\permanent\protected\def\svgposchar#1#2#3% dx dy char
+ {\setbox\scratchbox\hpack\bgroup
+ \raise#2\onebasepoint\hbox\bgroup
+ \kern\dimexpr#1\onebasepoint-\grph_svg_scratchwidth\relax
+ \char#3\relax
+ \egroup
+ \egroup
+ \advance\grph_svg_scratchwidth\wd\scratchbox
+ \box\scratchbox}
+
+\permanent\protected\def\svgchar#1% char
+ {\char#1\relax}
+
+\definelayer[svgmps][\c!method=\v!fit]
+
+\permanent\protected\def\svgstartlayer
+ {\resetlayer[svgmps]%
+ \setlayer[svgmps]\bgroup}
+
+\permanent\protected\def\svgstoplayer
+ {\egroup
+ \flushlayer[svgmps]}
+
+\permanent\protected\def\svgsetlayer#1#2%
+ {\setlayer[svgmps][\c!x=#1\onebasepoint,\c!y=#2\onebasepoint]} % {#3}
+
+\permanent\protected\def\svghashed#1%
+ {\clf_svghashed#1\relax}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-xml.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-xml.mkxl
new file mode 100644
index 00000000000..bd93bda8c5b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/meta-xml.mkxl
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=meta-xml,
+%D version=2002.11.27,
+%D title=\METAPOST\ Graphics,
+%D subtitle=XML Hacks,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Graphics / XML Hacks}
+
+\unprotect
+
+% not needed in mkiv
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-cnt.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-cnt.lmt
new file mode 100644
index 00000000000..bddcb33b854
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-cnt.lmt
@@ -0,0 +1,2022 @@
+if not modules then modules = { } end modules ['mlib-cnt'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- The only useful reference that I could find about this topic is in wikipedia:
+--
+-- https://en.wikipedia.org/wiki/Marching_squares
+--
+-- I derived the edge code from:
+--
+-- https://physiology.arizona.edu/people/secomb/contours
+--
+-- and also here:
+--
+-- https://github.com/secomb/GreensV4
+--
+-- which has the banner:
+--
+-- TWS, November 1989. Converted to C September 2007. Revised February 2009.
+--
+-- and has a liberal licence. I optimized the code so that it runs a bit faster in Lua and
+-- there's probably more room for optimization (I tried several variants). For instance I
+-- don't use that many tables because access is costly. We don't have a compiler that does
+-- some optimizing (even then the c code can probably be made more efficient).
+--
+-- We often have the same node so it's cheaper to reuse the wsp tables and reconstruct
+-- the point in the path then to alias the original point. We can be more clever:
+-- straighten, but it's more work so maybe I will do that later; for now I only added
+-- a test for equality. There are some experiments in this file too and not all might
+-- work. It's a playground for me.
+--
+-- The code is meant for metafun so it is not general purpose. The bitmap variant is
+-- relatively fast and bitmaps compress well. When all is settled I might make a couple
+-- of helpers in C for this purpose but not now.
+--
+-- I removed optimization code (more aggressive flattening and such because it didn't really
+-- pay off now that we use combined paths with just line segments. I also moved some other
+-- code to a experimental copy. So we now only have the bare helpers needed here.
+
+-- Todo: look into zero case (lavel 1) for shapes ... omiting the background calculation
+-- speeds up quite a bit.
+
+local next, type, tostring = next, type, tostring
+local round, abs, min, max, floor = math.round, math.abs, math.min, math.max, math.floor
+local concat, move = table.concat, table.move
+
+local bor = bit32.bor -- it's really time to ditch support for luajit
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+local resettiming = statistics.resettiming
+local elapsedtiming = statistics.elapsed
+
+local formatters = string.formatters
+local setmetatableindex = table.setmetatableindex
+local sortedkeys = table.sortedkeys
+local sequenced = table.sequenced
+
+local metapost = metapost or { }
+local mp = mp or { }
+
+local getparameterset = metapost.getparameterset
+
+local mpflush = mp.flush
+local mpcolor = mp.color
+local mpstring = mp.string
+local mpdraw = mp.draw
+local mpfill = mp.fill
+local mpflatten = mp.flatten
+
+local report = logs.reporter("mfun contour")
+
+local version = 0.007
+
+-- we iterate using integers so that we get a better behaviour at zero
+
+local f_function_n = formatters [ [[
+ local math = math
+ local round = math.round
+ %s
+ return function(data,nx,ny,nxmin,nxmax,xstep,nymin,nymax,ystep)
+ local sx = nxmin
+ for mx=1,nx do
+ local dx = data[mx]
+ local x = sx * xstep
+ local sy = nymin
+ for my=1,ny do
+ local y = sy * ystep
+ dx[my] = %s
+ sy = sy + 1
+ end
+ sx = sx + 1
+ end
+ return 0
+ end
+]] ]
+
+local f_function_y = formatters [ [[
+ local math = math
+ local round = math.round
+ local nan = NaN
+ local inf = math.huge
+ %s
+ return function(data,nx,ny,nxmin,nxmax,xstep,nymin,nymax,ystep,dnan,dinf,report)
+ local sx = nxmin
+ local er = 0
+ for mx=nxmin,nxmax do
+ local dx = data[mx]
+ local x = sx * xstep
+ local sy = nymin
+ for my=nymin,nymax do
+ local y = sy * ystep
+ local n = %s
+ if n == nan then
+ er = er + 1
+ if er < 10 then
+ report("nan at (%s,%s)",x,y)
+ end
+ n = dnan
+ elseif n == inf then
+ er = er + 1
+ if er < 10 then
+ report("inf at (%s,%s)",x,y)
+ end
+ n = dinf
+ end
+ dx[my] = n
+ sy = sy + 1
+ end
+ sx = sx + 1
+ end
+ return er
+ end
+]] ]
+
+local f_color = formatters [ [[
+ local math = math
+ local min = math.min
+ local max = math.max
+ local n = %s
+ local minz = %s
+ local maxz = %s
+
+ local color_value = 0
+ local color_step = mp.lmt_color_functions.step
+ local color_shade = mp.lmt_color_functions.shade
+
+ local function step(...)
+ return color_step(color_value,n,...)
+ end
+ local function shade(...)
+ return color_shade(color_value,n,...)
+ end
+ local function lin(l)
+ return l/n
+ end
+ %s
+ return function(l)
+ color_value = l
+ return %s
+ end
+]] ]
+
+local inbetween = attributes and attributes.colors.helpers.inbetween
+
+mp.lmt_color_functions = {
+ step = function(l,n,r,g,b,s)
+ if not s then
+ s = 1
+ end
+ local f = l / n
+ local r = s * 1.5 - 4 * abs(f-r)
+ local g = s * 1.5 - 4 * abs(f-g)
+ local b = s * 1.5 - 4 * abs(f-b)
+ return min(max(r,0),1), min(max(g,0),1), min(max(b,0),1)
+ end,
+ shade = function(l,n,one,two)
+ local f = l / n
+ local r = inbetween(one,two,1,f)
+ local g = inbetween(one,two,2,f)
+ local b = inbetween(one,two,3,f)
+ return min(max(r,0),1), min(max(g,0),1), min(max(b,0),1)
+ end,
+}
+
+local f_box = formatters [ [[draw rawtexbox("contour",%s) xysized (%s,%s) ;]] ]
+
+local n_box = 0
+
+-- todo: remove old one, so we need to store old hashes
+
+local nofcontours = 0
+
+-- We don't want cosmetics like axis and labels to trigger a calculation,
+-- especially a slow one.
+
+local hashfields = {
+ "xmin", "xmax", "xstep", "ymin", "ymax", "ystep",
+ "levels", "colors", "level", "preamble", "function", "functions", "color", "values",
+ "background", "foreground", "linewidth", "backgroundcolor", "linecolor",
+}
+
+local function prepare(p)
+ local h = { }
+ for i=1,#hashfields do
+ local f = hashfields[i]
+ h[f] = p[f]
+ end
+ local hash = md5.HEX(sequenced(h))
+ local name = formatters["%s-m-c-%03i.lua"](tex.jobname,nofcontours)
+ return name, hash
+end
+
+local function getcache(p)
+ local cache = p.cache
+ if cache then
+ local name, hash = prepare(p)
+ local data = table.load(name)
+ if data and data.hash == hash and data.version == version then
+ p.result = data
+ return true
+ else
+ return false, hash, name
+ end
+ end
+ return false, nil, nil
+end
+
+local function setcache(p)
+ local result = p.result
+ local name = result.name
+ if name then
+ if result.bitmap then
+ result.bitmap = nil
+ else
+ result.data = nil
+ end
+ result.color = nil
+ result.action = nil
+ result.cached = nil
+ io.savedata(name, table.fastserialize(result))
+ else
+ os.remove((prepare(p)))
+ end
+end
+
+function mp.lmt_contours_start()
+
+ resettiming("lmt_contours")
+ starttiming("lmt_contours")
+
+ nofcontours = nofcontours + 1
+
+ local p = getparameterset()
+
+ local xmin = p.xmin
+ local xmax = p.xmax
+ local ymin = p.ymin
+ local ymax = p.ymax
+ local xstep = p.xstep
+ local ystep = p.ystep
+ local levels = p.levels
+ local colors = p.colors
+ local nx = 0
+ local ny = 0
+ local means = setmetatableindex("number")
+ local values = setmetatableindex("number")
+ local data = setmetatableindex("table")
+ local minmean = false
+ local maxmean = false
+
+ local cached, hash, name = getcache(p)
+
+ local function setcolors(preamble,levels,minz,maxz,color,nofvalues)
+ if colors then
+ local function f(k)
+ return #colors[1] == 1 and 0 or { 0, 0, 0 }
+ end
+ setmetatableindex(colors, function(t,k)
+ local v = f(k)
+ t[k] = v
+ return v
+ end)
+ local c = { }
+ local n = 1
+ for i=1,nofvalues do
+ c[i] = colors[n]
+ n = n + 1
+ end
+ return c, f
+ else
+ local tcolor = f_color(levels,minz,maxz,preamble,color)
+ local colors = { }
+ local fcolor = load(tcolor)
+ if type(fcolor) ~= "function" then
+ report("error in color function, case %i: %s",1,color)
+ fcolor = false
+ else
+ fcolor = fcolor()
+ if type(fcolor) ~= "function" then
+ report("error in color function, case %i: %s",2,color)
+ fcolor = false
+ end
+ end
+ if not fcolor then
+ local color_step = mp.lmt_color_functions.step
+ fcolor = function(l)
+ return color_step(l,levels,0.25,0.50,0.75)
+ end
+ end
+ for i=1,nofvalues do
+ colors[i] = { fcolor(i) }
+ end
+ if attributes.colors.model == "cmyk" then
+ for i=1,#colors do
+ local c = colors[i]
+ colors[i] = { 1 - c[1], 1 - c[2], 1 - c[3], 0 }
+ end
+ end
+ return colors, fcolor
+ end
+ end
+
+ if cached then
+ local result = p.result
+ local colors, color = setcolors(
+ p.preamble,
+ p.levels,
+ result.minz,
+ result.maxz,
+ p.color,
+ result.nofvalues
+ )
+ result.color = color
+ result.colors = colors
+ result.cached = true
+ return
+ end
+
+ local functioncode = p["function"]
+ local functionrange = p.range
+ local functionlist = functionrange and p.functions
+ local preamble = p.preamble
+
+ if xstep == 0 then xstep = (xmax - xmin)/100 end
+ if ystep == 0 then ystep = (ymax - ymin)/100 end
+
+ local nxmin = round(xmin/xstep)
+ local nxmax = round(xmax/xstep)
+ local nymin = round(ymin/ystep)
+ local nymax = round(ymax/ystep)
+ local nx = nxmax - nxmin + 1
+ local ny = nymax - nymin + 1
+
+ local function executed(data,code)
+ local fcode = p.check and f_function_y or f_function_n
+ fcode = fcode(preamble,code)
+ fcode = load(fcode)
+ if type(fcode) == "function" then
+ fcode = fcode()
+ end
+ if type(fcode) == "function" then
+ local er = fcode(
+ data, nx, ny,
+ nxmin, nxmax, xstep,
+ nymin, nymax, ystep,
+ p.defaultnan, p.defaultinf, report
+ )
+ if er > 0 then
+ report("%i errors in: %s",er,code)
+ end
+ return true
+ else
+ return false -- fatal error
+ end
+ end
+
+ -- for i=1,nx do
+ -- data[i] = lua.newtable(ny,0)
+ -- end
+
+ if functionlist then
+
+ local datalist = { }
+ local minr = functionrange[1]
+ local maxr = functionrange[2] or minr
+ local size = #functionlist
+
+ for l=1,size do
+
+ local func = setmetatableindex("table")
+ if not executed(func,functionlist[l]) then
+ report("error in executing function %i from functionlist",l)
+ return
+ end
+
+ local bit = l -- + 1
+
+ if l == 1 then
+ for i=1,nx do
+ local di = data[i]
+ local fi = func[i]
+ for j=1,ny do
+ local f = fi[j]
+ if f >= minr and f <= maxr then
+ di[j] = bit
+ else
+ di[j] = 0
+ end
+ end
+ end
+ else
+ for i=1,nx do
+ local di = data[i]
+ local fi = func[i]
+ for j=1,ny do
+ local f = fi[j]
+ if f >= minr and f <= maxr then
+ di[j] = bor(di[j],bit)
+ end
+ end
+ end
+ end
+
+ end
+
+ -- we can simplify the value mess below
+
+ elseif functioncode then
+
+ if not executed(data,functioncode) then
+ report("error in executing function")
+ return -- fatal error
+ end
+
+ else
+
+ report("no valid function(s)")
+ return -- fatal error
+
+ end
+
+ minz = data[1][1]
+ maxz = minz
+
+ for i=1,nx do
+ local d = data[i]
+ for j=1,ny do
+ local v = d[j]
+ if v < minz then
+ minz = v
+ elseif v > maxz then
+ maxz = v
+ end
+ end
+ end
+
+ if functionlist then
+
+ for i=minz,maxz do
+ values[i] = i
+ end
+
+ levels = maxz
+
+ minmean = minz
+ maxmean = maxz
+
+ else
+
+ local snap = (maxz - minz + 1) / levels
+
+ for i=1,nx do
+ local d = data[i]
+ for j=1,ny do
+ local dj = d[j]
+ local v = round((dj - minz) / snap)
+ values[v] = values[v] + 1
+ means [v] = means [v] + dj
+ d[j] = v
+ end
+ end
+
+ local list = sortedkeys(values)
+ local count = values
+ local remap = { }
+
+ values = { }
+
+ for i=1,#list do
+ local v = list[i]
+ local m = means[v] / count[v]
+ remap [v] = i
+ values[i] = m
+ if not minmean then
+ minmean = m
+ maxmean = m
+ elseif m < minmean then
+ minmean = m
+ elseif m > maxmean then
+ maxmean = m
+ end
+ end
+
+ for i=1,nx do
+ local d = data[i]
+ for j=1,ny do
+ d[j] = remap[d[j]]
+ end
+ end
+
+ end
+
+ -- due to rounding we have values + 1 so we can have a floor, ceil, round
+ -- option as well as levels -1
+
+ local nofvalues = #values
+
+ local colors = setcolors(
+ p.preamble,levels,minz,maxz,p.color,nofvalues
+ )
+
+ p.result = {
+ version = version,
+ values = values,
+ nofvalues = nofvalues,
+ minz = minz,
+ maxz = maxz,
+ minmean = minmean,
+ maxmean = maxmean,
+ data = data,
+ color = color,
+ nx = nx,
+ ny = ny,
+ colors = colors,
+ name = name,
+ hash = hash,
+ islist = functionlist and true or false,
+ }
+
+ report("index %i, nx %i, ny %i, levels %i", nofcontours, nx, ny, nofvalues)
+end
+
+function mp.lmt_contours_stop()
+ local p = getparameterset()
+ stoptiming("lmt_contours")
+ setcache(p)
+ p.result = nil
+ local f = p["function"]
+ local l = p.functions
+ report("index %i, %0.3f seconds for: %s", nofcontours, elapsedtiming("lmt_contours"), "[ " .. concat(l or { f } ," ] [ ") .. " ]")
+end
+
+function mp.lmt_contours_bitmap_set()
+ local p = getparameterset()
+ local result = p.result
+
+ local values = result.values
+ local nofvalues = result.nofvalues
+ local rawdata = result.data
+ local nx = result.nx
+ local ny = result.ny
+ local colors = result.colors
+ local depth = #colors[1] -- == 3 and "rgb" or "gray"
+
+ -- i need to figure out this offset of + 1
+
+ local bitmap = graphics.bitmaps.new(
+ nx, ny,
+ (depth == 3 and "rgb") or (depth == 4 and "cmyk") or "gray",
+ 1, false, true
+ )
+
+ local palette = bitmap.index or { } -- has to start at 0
+ local data = bitmap.data
+ local p = 0
+
+ if depth == 3 or depth == 4 then
+ for i=1,nofvalues do
+ local c = colors[i]
+ local r = round((c[1] or 0) * 255)
+ local g = round((c[2] or 0) * 255)
+ local b = round((c[3] or 0) * 255)
+ local k = depth == 4 and round((c[4] or 0) * 255) or nil
+ palette[p] = {
+ (r > 255 and 255) or (r < 0 and 0) or r,
+ (g > 255 and 255) or (g < 0 and 0) or g,
+ (b > 255 and 255) or (b < 0 and 0) or b,
+ k
+ }
+ p = p + 1
+ end
+ else
+ for i=1,nofvalues do
+ local s = colors[i][1]
+ local s = round((s or 0) * 255)
+ palette[p] = (
+ (s > 255 and 255) or (s < 0 and 0) or s
+ )
+ p = p + 1
+ end
+ end
+
+ -- As (1,1) is the left top corner so we need to flip of we start in
+ -- the left bottom (we cannot loop reverse because we want a properly
+ -- indexed table.
+
+ local k = 0
+ for y=ny,1,-1 do
+ k = k + 1
+ local d = data[k]
+ for x=1,nx do
+ d[x] = rawdata[x][y] - 1
+ end
+ end
+
+ result.bitmap = bitmap
+end
+
+function mp.lmt_contours_bitmap_get()
+ local p = getparameterset()
+ local result = p.result
+ local bitmap = result.bitmap
+ local box = nodes.hpack(graphics.bitmaps.flush(bitmap))
+ n_box = n_box + 1
+ nodes.boxes.savenode("contour",tostring(n_box),box)
+ return f_box(n_box,bitmap.xsize,bitmap.ysize)
+end
+
+function mp.lmt_contours_cleanup()
+ nodes.boxes.reset("contour")
+ n_box = 0
+end
+
+function mp.lmt_contours_edge_set()
+ local p = getparameterset()
+ local result = p.result
+
+ if result.cached then return end
+
+ local values = result.values
+ local nofvalues = result.nofvalues
+ local data = result.data
+ local nx = result.nx
+ local ny = result.ny
+
+ local xmin = p.xmin
+ local xmax = p.xmax
+ local ymin = p.ymin
+ local ymax = p.ymax
+ local xstep = p.xstep
+ local ystep = p.ystep
+
+ local wsp = { }
+ local edges = { }
+
+ for value=1,nofvalues do
+
+ local iwsp = 0
+ local di = data[1]
+ local dc
+ local edge = { }
+ local e = 0
+ -- the next loop is fast
+ for i=1,nx do
+ local di1 = data[i+1]
+ local dij = di[1]
+ local d = dij - value
+ local dij1
+ for j=1,ny do
+ if j < ny then
+ dij1 = di[j+1]
+ dc = dij1 - value
+ if (d >= 0 and dc < 0) or (d < 0 and dc >= 0) then
+ iwsp = iwsp + 1
+ local y = (d * (j+1) - dc * j) / (d - dc)
+ if i == 1 then
+ wsp[iwsp] = { i, y, 0, (i + (j-1)*nx) }
+ elseif i == nx then
+ wsp[iwsp] = { i, y, (i - 1 + (j-1)*nx), 0 }
+ else
+ local jx = (i + (j-1)*nx)
+ wsp[iwsp] = { i, y, jx - 1, jx }
+ end
+ end
+ end
+ if i < nx then
+ local dc = di1[j] - value
+ if (d >= 0 and dc < 0) or (d < 0 and dc >= 0) then
+ iwsp = iwsp + 1
+ local x = (d * (i+1) - dc * i) / (d - dc)
+ if j == 1 then
+ wsp[iwsp] = { x, j, 0, (i + (j-1)*nx) }
+ elseif j == ny then
+ wsp[iwsp] = { x, j, (i + (j-2)*nx), 0 }
+ else
+ local jx = i + (j-1)*nx
+ wsp[iwsp] = { x, j, jx - nx, jx }
+ end
+ end
+ end
+ dij = dij1
+ d = dc
+ end
+ di = di1
+ end
+ -- the next loop takes time
+ for i=1,iwsp do
+ local wspi = wsp[i]
+ for isq=3,4 do
+ local nsq = wspi[isq]
+ if nsq ~= 0 then
+ local px = wspi[1]
+ local py = wspi[2]
+ local p = { px, py }
+ local pn = 2
+ wspi[isq] = 0
+ while true do
+ for ii=1,iwsp do
+ local w = wsp[ii]
+ local n1 = w[3]
+ local n2 = w[4]
+ if n1 == nsq then
+ local x = w[1]
+ local y = w[2]
+ if x ~= px or y ~= py then
+ pn = pn + 1
+ p[pn] = x
+ pn = pn + 1
+ p[pn] = y
+ px = x
+ py = y
+ end
+ nsq = n2
+ w[3] = 0
+ w[4] = 0
+ if nsq == 0 then
+ if pn == 1 then
+ pn = pn + 1
+ p[pn] = w
+ end
+ goto flush
+ end
+ elseif n2 == nsq then
+ local x = w[1]
+ local y = w[2]
+ if x ~= px or y ~= py then
+ pn = pn + 1
+ p[pn] = x
+ pn = pn + 1
+ p[pn] = y
+ px = x
+ py = y
+ end
+ nsq = n1
+ w[3] = 0
+ w[4] = 0
+ if nsq == 0 then
+ goto flush
+ end
+ end
+ end
+ end
+ ::flush::
+ e = e + 1
+ edge[e] = p
+ if mpflatten then
+ mpflatten(p)
+ end
+ end
+ end
+ end
+
+
+ edges[value] = edge
+
+ end
+
+ result.edges = edges
+
+end
+
+function mp.lmt_contours_shade_set(edgetoo)
+ local p = getparameterset()
+ local result = p.result
+
+ if result.cached then return end
+
+ local values = result.values
+ local nofvalues = result.nofvalues
+ local data = result.data
+ local nx = result.nx
+ local ny = result.ny
+ local color = result.color
+
+ local edges = setmetatableindex("table")
+ local shades = setmetatableindex("table")
+
+ local sqtype = setmetatableindex("table")
+
+ local xspoly = { 0, 0, 0, 0, 0, 0 }
+ local yspoly = { 0, 0, 0, 0, 0, 0 }
+ local xrpoly = { }
+ local yrpoly = { }
+
+ local xrpoly = { } -- lua.newtable(2000,0)
+ local yrpoly = { } -- lua.newtable(2000,0)
+
+ -- for i=1,2000 do
+ -- xrpoly[i] = 0
+ -- yrpoly[i] = 0
+ -- end
+
+ -- Unlike a c compiler lua will not optimize loops to run in parallel so we expand
+ -- some of the loops and make sure we don't calculate when not needed. Not that nice
+ -- but not that bad either. Maybe I should just write this from scratch.
+
+-- local i = 0
+-- local j = 0
+
+ -- Analyze each rectangle separately. Overwrite lower colors
+
+ -- Unrolling the loops and copying code and using constants is faster and doesn't
+ -- produce much more code in the end, also because we then can leave out the not
+ -- seen branches. One can argue about the foundit2* blobs but by stepwise optimizing
+ -- this is the result.
+
+ shades[1] = { { 0, 0, nx - 1, 0, nx - 1, ny - 1, 0, ny - 1 } }
+ edges [1] = { { } }
+
+ -- this is way too slow ... i must have messed up some loop .. what is this with value 1
+
+ for value=1,nofvalues do
+-- for value=2,nofvalues do
+
+ local edge = { }
+ local nofe = 0
+ local shade = { }
+ local nofs = 0
+
+ for i=1,nx-1 do
+ local s = sqtype[i]
+ for j=1,ny-1 do
+ s[j] = 0
+ end
+ end
+
+ local nrp = 0
+
+ local function addedge(a,b,c,d)
+ nofe = nofe + 1 edge[nofe] = a
+ nofe = nofe + 1 edge[nofe] = b
+ nofe = nofe + 1 edge[nofe] = c
+ nofe = nofe + 1 edge[nofe] = d
+ end
+ while true do
+ -- search for a square of type 0 with >= 1 corner above contour level
+ local i
+ local j
+ local d0 = data[1]
+ local d1 = data[2]
+ for ii=1,nx do
+ local s = sqtype[ii]
+ for jj=1,ny do
+ if s[jj] == 0 then
+ if d0[jj] > value then i = ii j = jj goto foundit end
+ if d1[jj] > value then i = ii j = jj goto foundit end
+ local j1 = jj + 1
+ if d1[j1] > value then i = ii j = jj goto foundit end
+ if d0[j1] > value then i = ii j = jj goto foundit end
+ end
+ end
+ d0 = d1
+ d1 = data[ii+1]
+ end
+ break
+ ::foundit::
+ -- initialize r-polygon (nrp seems to be 1 or 2)
+ nrp = nrp + 1
+
+ local first = true
+ local nrpoly = 0
+ local nspoly = 0
+ local nrpm = -nrp
+ -- this is the main loop
+ while true do
+ -- search for a square of type -nrp
+ if first then
+ first = false
+ if sqtype[i][j] == 0 then -- true anyway
+ goto foundit1
+ end
+ end
+ for ii=1,nx do
+ local s = sqtype[ii]
+ for jj=1,ny do
+ if s[jj] == nrpm then
+ i = ii
+ j = jj
+ goto foundit1
+ end
+ end
+ end
+ break
+ ::foundit1::
+ while true do
+
+ -- search current then neighboring squares for square type 0, with a corner in common with current square above contour level
+
+ -- top/bottom ... a bit cheating here
+
+ local i_l, i_c, i_r -- i left current right
+ local j_b, j_c, j_t -- j bottom current top
+
+ local i_n = i + 1 -- i next (right)
+ local j_n = j + 1 -- j next (top)
+
+ local i_p = i - 1 -- i previous (bottom)
+ local j_p = j - 1 -- j previous (right)
+
+ local d_c = data[i]
+ local d_r = data[i_n]
+
+ local sq
+
+ i_c = i ; j_c = j ; if i_c < nx and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
+ if d_c[j_c] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit21 end
+ if d_c[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit22 end
+ if d_r[j_c] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit23 end
+ if d_r[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j_p ; j_t = j_n ; goto foundit24 end
+ end end
+
+ i_c = i_n ; j_c = j ; if i_c < nx and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
+ if d_r[j_c] > value then i_l = i ; i_r = i_n + 1 ; j_b = j_p ; j_t = j_n ; d_c = d_r ; d_r = data[i_r] ; goto foundit21 end
+ if d_r[j_n] > value then i_l = i ; i_r = i_n + 1 ; j_b = j_p ; j_t = j_n ; d_c = d_r ; d_r = data[i_r] ; goto foundit22 end
+ end end
+
+ i_c = i ; j_c = j_n ; if i_c < nx and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
+ if d_c[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j ; j_t = j_n + 1 ; goto foundit21 end
+ if d_r[j_n] > value then i_l = i_p ; i_r = i_n ; j_b = j ; j_t = j_n + 1 ; goto foundit23 end
+ end end
+
+ i_c = i_p ; j_c = j ; if i_c > 0 and j_c < ny then sq = sqtype[i_c] if sq[j_c] == 0 then
+ if d_c[j_c] > value then i_l = i_p - 1 ; i_r = i ; j_b = j_p ; j_t = j_n ; d_r = d_c ; d_c = data[i_p] ; goto foundit23 end
+ if d_c[j_n] > value then i_l = i_p - 1 ; i_r = i ; j_b = j_p ; j_t = j_n ; d_r = d_c ; d_c = data[i_p] ; goto foundit24 end
+ end end
+
+ i_c = i ; j_c = j_p ; if i < nx and j_c > 0 then sq = sqtype[i_c] if sq[j_c] == 0 then
+ if d_c[j] > value then i_l = i_p ; i_r = i_n ; j_b = j_p - 1 ; j_t = j ; goto foundit22 end
+ if d_r[j] > value then i_l = i_p ; i_r = i_n ; j_b = j_p - 1 ; j_t = j ; goto foundit24 end
+ end end
+
+ -- not found
+
+ sqtype[i][j] = nrp
+
+ break
+
+ -- define s-polygon for found square (i_c,j_c) - may have up to 6 sides
+
+ ::foundit21:: -- 1 2 3 4
+
+ sq[j_c] = nrpm
+
+ xspoly[1] = i_l ; yspoly[1] = j_b
+ xspoly[2] = i_c ; yspoly[2] = j_b
+ if d_r[j_c] > value then -- dd2
+ xspoly[3] = i_c ; yspoly[3] = j_c
+ if d_r[j_t] > value then -- dd3
+ xspoly[4] = i_l ; yspoly[4] = j_c
+ if d_c[j_t] > value then -- dd4
+ nspoly = 4
+ else
+ xspoly[5] = i_l ; yspoly[5] = j_c ; nspoly = 5
+ end
+ elseif d_c[j_t] > value then -- dd4
+ xspoly[4] = i_c ; yspoly[4] = j_c ;
+ xspoly[5] = i_l ; yspoly[5] = j_c ; nspoly = 5
+ else
+ xspoly[4] = i_l ; yspoly[4] = j_c ; nspoly = 4
+ if edgetoo then addedge(i_c, j_c, i_l, j_c) end
+ end
+ elseif d_r[j_t] > value then -- dd3
+ xspoly[3] = i_c ; yspoly[3] = j_b
+ xspoly[4] = i_c ; yspoly[4] = j_c
+ if d_c[j_t] > value then -- dd4
+ xspoly[5] = i_l ; yspoly[5] = j_c ; nspoly = 5
+ else
+ xspoly[5] = i_l ; yspoly[5] = j_c ;
+ xspoly[6] = i_l ; yspoly[6] = j_c ; nspoly = 6
+ end
+ elseif d_c[j_t] > value then -- dd4
+ if edgetoo then addedge(i_c, j_b, i_c, j_c) end
+ xspoly[3] = i_c ; yspoly[3] = j_c ;
+ xspoly[4] = i_l ; yspoly[4] = j_c ; nspoly = 4
+ else
+ if edgetoo then addedge(i_c, j_b, i_l, j_c) end
+ xspoly[3] = i_l ; yspoly[3] = j_c ; nspoly = 3
+ end
+ goto done
+
+ ::foundit22:: -- 4 1 2 3
+
+ sq[j_c] = nrpm
+
+ xspoly[1] = i_l ; yspoly[1] = j_c
+ xspoly[2] = i_l ; yspoly[2] = j_b
+ if d_c[j_c] > value then -- dd2
+ xspoly[3] = i_c ; yspoly[3] = j_b
+ if d_r[j_c] > value then -- dd3
+ xspoly[4] = i_c ; yspoly[4] = j_c
+ if d_r[j_t] > value then -- dd4
+ nspoly = 4
+ else
+ xspoly[5] = i_c ; yspoly[5] = j_c ; nspoly = 5 -- suspicious, the same
+ end
+ elseif d_r[j_t] > value then -- dd4
+ xspoly[4] = i_c ; yspoly[4] = j_b ;
+ xspoly[5] = i_c ; yspoly[5] = j_c ; nspoly = 5
+ else
+ if edgetoo then addedge(i_c, j_b, i_c, j_c) end
+ xspoly[4] = i_c ; yspoly[4] = j_c ; nspoly = 4
+ end
+ elseif d_r[j_c] > value then -- dd3
+ xspoly[3] = i_l ; yspoly[3] = j_b
+ xspoly[4] = i_c ; yspoly[4] = j_b
+ xspoly[5] = i_c ; yspoly[5] = j_c
+ if d_r[j_t] > value then -- dd4
+ nspoly = 5
+ else
+ xspoly[6] = i_c ; yspoly[6] = j_c ; nspoly = 6
+ end
+ elseif d_r[j_t] > value then -- dd4
+ if edgetoo then addedge(i_l, j_b, i_c, j_b) end
+ xspoly[3] = i_c ; yspoly[3] = j_b
+ xspoly[4] = i_c ; yspoly[4] = j_c ; nspoly = 4
+ else
+ if edgetoo then addedge(i_l, j_b, i_c, j_c) end
+ xspoly[3] = i_c ; yspoly[3] = j_c ; nspoly = 3
+ end
+ goto done
+
+ ::foundit23:: -- 2 3 4 1
+
+ sq[j_c] = nrpm
+
+ xspoly[1] = i_c ; yspoly[1] = j_b
+ xspoly[2] = i_c ; yspoly[2] = j_c
+ if d_r[j_t] > value then -- dd2
+ xspoly[3] = i_l ; yspoly[3] = j_c
+ if d_c[j_t] > value then -- dd3
+ xspoly[4] = i_l ; yspoly[4] = j_b
+ if d_c[j_c] > value then -- dd4
+ nspoly = 4
+ else
+ xspoly[5] = i_l ; yspoly[5] = j_b ; nspoly = 5
+ end
+ elseif d_c[j_c] > value then -- dd4
+ xspoly[4] = i_l ; yspoly[4] = j_c
+ xspoly[5] = i_l ; yspoly[5] = j_b ; nspoly = 5
+ else
+ if edgetoo then addedge(i_l, j_c, i_l, j_b) end
+ xspoly[4] = i_l ; yspoly[4] = j_b ; nspoly = 4
+ end
+ elseif d_c[j_t] > value then -- dd3
+ xspoly[3] = i_c ; yspoly[3] = j_c
+ xspoly[4] = i_l ; yspoly[4] = j_c
+ xspoly[5] = i_l ; yspoly[5] = j_b
+ if d_c[j_c] > value then -- dd4
+ nspoly = 5
+ else
+ xspoly[6] = i_l ; yspoly[6] = j_b ; nspoly = 6
+ end
+ elseif d_c[j_c] > value then -- dd4
+ if edgetoo then addedge(i_c, j_c, i_l, j_c) end
+ xspoly[3] = i_l ; yspoly[3] = j_c ;
+ xspoly[4] = i_l ; yspoly[4] = j_b ; nspoly = 4
+ else
+ if edgetoo then addedge(i_c, j_c, i_l, j_b) end
+ xspoly[3] = i_l ; yspoly[3] = j_b ; nspoly = 3
+ end
+ goto done
+
+ ::foundit24:: -- 3 4 1 2
+
+ sq[j_c] = nrpm
+
+ xspoly[1] = i_c ; yspoly[1] = j_c
+ xspoly[2] = i_l ; yspoly[2] = j_c
+ if d_c[j_t] > value then -- dd2
+ if d_c[j_c] > value then -- dd3
+ xspoly[3] = i_l ; yspoly[3] = j_b
+ xspoly[4] = i_c ; yspoly[4] = j_b
+ if d_r[j_c] > value then -- dd4
+ nspoly = 4
+ else
+ xspoly[5] = i_c ; yspoly[5] = j_b ; nspoly = 5
+ end
+ else
+ xspoly[3] = i_l ; yspoly[3] = j_b
+ if d_r[j_c] > value then -- dd4
+
+ local xv34 = (dd3*i_c-dd4*i_l)/(dd3 - dd4) -- probably i_l
+ print("4.4 : xv34",xv34,i_c,i_l)
+
+ -- if edgetoo then addedge(i_l, j_b, xv34, j_b) end
+ xspoly[4] = xv34 ; yspoly[4] = j_b ;
+ xspoly[5] = i_c ; yspoly[5] = j_b ; nspoly = 5
+ else
+ if edgetoo then addedge(i_l, j_b, i_c, j_b) end
+ xspoly[4] = i_c ; yspoly[4] = j_b ; nspoly = 4
+ end
+ end
+ elseif d_c[j_c] > value then -- dd3
+ xspoly[3] = i_l ; yspoly[3] = j_b
+ xspoly[4] = i_l ; yspoly[4] = j_b
+ xspoly[5] = i_c ; yspoly[5] = j_b
+ if d_r[j_c] > value then -- dd4
+ nspoly = 5
+ else
+ xspoly[6] = i_c ; yspoly[6] = j_b ; nspoly = 6
+ end
+ elseif d_r[j_c] > value then -- dd4
+ if edgetoo then addedge(i_l, j_c, i_l, j_b) end
+ xspoly[3] = i_l ; yspoly[3] = j_b
+ xspoly[4] = i_c ; yspoly[4] = j_b ; nspoly = 4
+ else
+ if edgetoo then addedge(i_l, j_c, i_c, j_b) end
+ xspoly[3] = i_c ; yspoly[3] = j_b ; nspoly = 3
+ end
+ -- goto done
+
+ ::done::
+ -- combine s-polygon with existing r-polygon, eliminating redundant segments
+
+ if nrpoly == 0 then
+ -- initiate r-polygon
+ for i=1,nspoly do
+ xrpoly[i] = xspoly[i]
+ yrpoly[i] = yspoly[i]
+ end
+ nrpoly = nspoly
+ else
+ -- search r-polygon and s-polygon for one side that matches
+ --
+ -- this is a bottleneck ... we keep this variant here but next go for a faster
+ -- alternative
+ --
+ -- local ispoly, irpoly
+ -- for r=nrpoly,1,-1 do
+ -- local r1
+ -- for s=1,nspoly do
+ -- local s1 = s % nspoly + 1
+ -- if xrpoly[r] == xspoly[s1] and yrpoly[r] == yspoly[s1] then
+ -- if not r1 then
+ -- r1 = r % nrpoly + 1
+ -- end
+ -- if xrpoly[r1] == xspoly[s] and yrpoly[r1] == yspoly[s] then
+ -- ispoly = s
+ -- irpoly = r
+ -- goto foundit3
+ -- end
+ -- end
+ -- end
+ -- end
+ --
+ -- local ispoly, irpoly
+ -- local xr1 = xrpoly[1]
+ -- local yr1 = yrpoly[1]
+ -- for r0=nrpoly,1,-1 do
+ -- for s0=1,nspoly do
+ -- if xr1 == xspoly[s0] and yr1 == yspoly[s0] then
+ -- if s0 == nspoly then
+ -- if xr0 == xspoly[1] and yr0 == yspoly[1] then
+ -- ispoly = s0
+ -- irpoly = r0
+ -- goto foundit3
+ -- end
+ -- else
+ -- local s1 = s0 + 1
+ -- if xr0 == xspoly[s1] and yr0 == yspoly[s1] then
+ -- ispoly = s0
+ -- irpoly = r0
+ -- goto foundit3
+ -- end
+ -- end
+ -- end
+ -- end
+ -- xr1 = xrpoly[r0]
+ -- yr1 = yrpoly[r0]
+ -- end
+ --
+ -- but ...
+ --
+ local minx = xspoly[1]
+ local miny = yspoly[1]
+ local maxx = xspoly[1]
+ local maxy = yspoly[1]
+ for i=1,nspoly do
+ local y = yspoly[i]
+ if y < miny then
+ miny = y
+ elseif y > maxy then
+ maxy = y
+ end
+ local x = xspoly[i]
+ if x < minx then
+ minx = y
+ elseif x > maxx then
+ maxx = x
+ end
+ end
+ -- we can delay accessing y ...
+ local ispoly, irpoly
+ local xr1 = xrpoly[1]
+ local yr1 = yrpoly[1]
+ for r0=nrpoly,1,-1 do
+ if xr1 >= minx and xr1 <= maxx and yr1 >= miny and yr1 <= maxy then
+ local xr0 = xrpoly[r0]
+ local yr0 = yrpoly[r0]
+ for s0=1,nspoly do
+ if xr1 == xspoly[s0] and yr1 == yspoly[s0] then
+ if s0 == nspoly then
+ if xr0 == xspoly[1] and yr0 == yspoly[1] then
+ ispoly = s0
+ irpoly = r0
+ goto foundit3
+ end
+ else
+ local s1 = s0 + 1
+ if xr0 == xspoly[s1] and yr0 == yspoly[s1] then
+ ispoly = s0
+ irpoly = r0
+ goto foundit3
+ end
+ end
+ end
+ end
+ xr1 = xr0
+ yr1 = yr0
+ else
+ xr1 = xrpoly[r0]
+ yr1 = yrpoly[r0]
+ end
+ end
+ --
+ goto nomatch3
+ ::foundit3::
+ local match1 = 0
+ local rpoly1 = irpoly + nrpoly
+ local spoly1 = ispoly - 1
+ for i=2,nspoly-1 do
+ -- search for further matches nearby
+ local ir = (rpoly1 - i) % nrpoly + 1
+ local is = (spoly1 + i) % nspoly + 1
+ if xrpoly[ir] == xspoly[is] and yrpoly[ir] == yspoly[is] then
+ match1 = match1 + 1
+ else
+ break -- goto nomatch1
+ end
+ end
+ ::nomatch1::
+ local match2 = 0
+ local rpoly2 = irpoly - 1
+ local spoly2 = ispoly + nspoly
+ for i=2,nspoly-1 do
+ -- search other way for further matches nearby
+ local ir = (rpoly2 + i) % nrpoly + 1
+ local is = (spoly2 - i) % nspoly + 1
+ if xrpoly[ir] == xspoly[is] and yrpoly[ir] == yspoly[is] then
+ match2 = match2 + 1
+ else
+ break -- goto nomatch2
+ end
+ end
+ ::nomatch2::
+ -- local dnrpoly = nspoly - 2 - 2*match1 - 2*match2
+ local dnrpoly = nspoly - 2*(match1 + match2 + 1)
+ local ispolystart = (ispoly + match1) % nspoly + 1 -- first node of s-polygon to include
+ local irpolyend = (rpoly1 - match1 - 1) % nrpoly + 1 -- last node of s-polygon to include
+ if dnrpoly ~= 0 then
+ local irpolystart = (irpoly + match2) % nrpoly + 1 -- first node of s-polygon to include
+ if irpolystart > irpolyend then
+ -- local ispolyend = (spoly1 - match2 + nspoly)%nspoly + 1 -- last node of s-polygon to include
+ if dnrpoly > 0 then
+ -- expand the arrays xrpoly and yrpoly
+ for i=nrpoly,irpolystart,-1 do
+ local k = i + dnrpoly
+ xrpoly[k] = xrpoly[i]
+ yrpoly[k] = yrpoly[i]
+ end
+ else -- if dnrpoly < 0 then
+ -- contract the arrays xrpoly and yrpoly
+ for i=irpolystart,nrpoly do
+ local k = i + dnrpoly
+ xrpoly[k] = xrpoly[i]
+ yrpoly[k] = yrpoly[i]
+ end
+ end
+ end
+ nrpoly = nrpoly + dnrpoly
+ end
+ if nrpoly < irpolyend then
+ for i=irpolyend,nrpoly+1,-1 do
+ -- otherwise these values get lost!
+ local k = i - nrpoly
+ xrpoly[k] = xrpoly[i]
+ yrpoly[k] = yrpoly[i]
+ end
+ end
+ local n = nspoly - 2 - match1 - match2
+ if n == 1 then
+ local irpoly1 = irpolyend % nrpoly + 1
+ local ispoly1 = ispolystart % nspoly + 1
+ xrpoly[irpoly1] = xspoly[ispoly1]
+ yrpoly[irpoly1] = yspoly[ispoly1]
+ elseif n > 0 then
+ -- often 2
+ for i=1,n do
+ local ii = i - 1
+ local ir = (irpolyend + ii) % nrpoly + 1
+ local is = (ispolystart + ii) % nspoly + 1
+ xrpoly[ir] = xspoly[is]
+ yrpoly[ir] = yspoly[is]
+ end
+ end
+ ::nomatch3::
+ end
+ end
+ end
+
+ if nrpoly > 0 then
+ local t = { }
+ local n = 0
+ for i=1,nrpoly do
+ n = n + 1 t[n] = xrpoly[i]
+ n = n + 1 t[n] = yrpoly[i]
+ end
+ if mpflatten then
+ mpflatten(t) -- maybe integrate
+ end
+ nofs = nofs + 1
+ shade[nofs] = t
+ -- print(value,nrpoly,#t,#t-nrpoly*2)
+ end
+
+ end
+
+ edges [value+1] = edge
+ shades[value+1] = shade
+-- edges [value] = edge
+-- shades[value] = shade
+ end
+
+ result.shades = shades
+ result.shapes = edges
+
+end
+
+-- accessors
+
+function mp.lmt_contours_nx (i) return getparameterset().result.nx end
+function mp.lmt_contours_ny (i) return getparameterset().result.ny end
+
+function mp.lmt_contours_nofvalues() return getparameterset().result.nofvalues end
+function mp.lmt_contours_value (i) return getparameterset().result.values[i] end
+
+function mp.lmt_contours_minz (i) return getparameterset().result.minz end
+function mp.lmt_contours_maxz (i) return getparameterset().result.maxz end
+
+function mp.lmt_contours_minmean (i) return getparameterset().result.minmean end
+function mp.lmt_contours_maxmean (i) return getparameterset().result.maxmean end
+
+function mp.lmt_contours_xrange () local p = getparameterset() mpstring(formatters["x = [%.3N,%.3N] ;"](p.xmin,p.xmax)) end
+function mp.lmt_contours_yrange () local p = getparameterset() mpstring(formatters["y = [%.3N,%.3N] ;"](p.ymin,p.ymax)) end
+
+function mp.lmt_contours_format()
+ local p = getparameterset()
+ return mpstring(p.result.islist and "@i" or p.zformat or p.format)
+end
+
+function mp.lmt_contours_function()
+ local p = getparameterset()
+ return mpstring(p.result.islist and concat(p["functions"], ", ") or p["function"])
+end
+
+function mp.lmt_contours_range()
+ local p = getparameterset()
+ local r = p.result.islist and p.range
+ if not r or #r == 0 then
+ return mpstring("")
+ elseif #r == 1 then
+ return mpstring(r[1])
+ else
+ return mpstring(formatters["z = [%s,%s]"](r[1],r[2]))
+ end
+end
+
+function mp.lmt_contours_edge_paths(value)
+ mpdraw(getparameterset().result.edges[value],true)
+ mpflush()
+end
+
+function mp.lmt_contours_shape_paths(value)
+ mpdraw(getparameterset().result.shapes[value],false)
+ mpflush()
+end
+
+function mp.lmt_contours_shade_paths(value)
+ mpfill(getparameterset().result.shades[value],true)
+ mpflush()
+end
+
+function mp.lmt_contours_color(value)
+ local p = getparameterset()
+ local color = p.result.colors[value]
+ if color then
+ mpcolor(color)
+ end
+end
+
+-- The next code is based on the wikipedia page. It was a bit tedius job to define the
+-- coordinates but hupefully I made no errors. I rendered all shapes independently and
+-- tripple checked bit one never knows ...
+
+-- maybe some day write from scatch, like this (axis are swapped):
+
+local d = 1/2
+
+local paths = {
+ { 0, d, d, 0 },
+ { 1, d, d, 0 },
+ { 0, d, 1, d },
+ { 1, d, d, 1 },
+ { 0, d, d, 1, d, 0, 1, d }, -- saddle
+ { d, 0, d, 1 },
+ { 0, d, d, 1 },
+ { 0, d, d, 1 },
+ { d, 0, d, 1 },
+ { 0, d, d, 0, 1, d, d, 1 }, -- saddle
+ { 1, d, d, 1 },
+ { 0, d, 1, d },
+ { d, 0, 1, d },
+ { d, 0, 0, d },
+}
+
+local function whatever(data,nx,ny,threshold)
+ local edges = { }
+ local e = 0
+ local d0 = data[1]
+ for j=1,ny-1 do
+ local d1 = data[j+1]
+ local k = j + 1
+ for i=1,nx-1 do
+ local v = 0
+ local l = i + 1
+ local c1 = d0[i]
+ if c1 < threshold then
+ v = v + 8
+ end
+ local c2 = d0[l]
+ if c2 < threshold then
+ v = v + 4
+ end
+ local c3 = d1[l]
+ if c3 < threshold then
+ v = v + 2
+ end
+ local c4 = d1[i]
+ if c4 < threshold then
+ v = v + 1
+ end
+ if v > 0 and v < 15 then
+ if v == 5 or v == 10 then
+ local a = (c1 + c2 + c3 + c4) / 4
+ if a < threshold then
+ v = v == 5 and 10 or 5
+ end
+ local p = paths[v]
+ e = e + 1 edges[e] = k - p[2]
+ e = e + 1 edges[e] = i + p[1]
+ e = e + 1 edges[e] = k - p[4]
+ e = e + 1 edges[e] = i + p[3]
+ e = e + 1 edges[e] = k - p[6]
+ e = e + 1 edges[e] = i + p[5]
+ e = e + 1 edges[e] = k - p[8]
+ e = e + 1 edges[e] = i + p[7]
+ else
+ local p = paths[v]
+ e = e + 1 edges[e] = k - p[2]
+ e = e + 1 edges[e] = i + p[1]
+ e = e + 1 edges[e] = k - p[4]
+ e = e + 1 edges[e] = i + p[3]
+ end
+ end
+ end
+ d0 = d1
+ end
+ return edges
+end
+
+-- todo: just fetch when needed, no need to cache
+
+function mp.lmt_contours_edge_set_by_cell()
+ local p = getparameterset()
+ local result = p.result
+
+ if result.cached then return end
+
+ local values = result.values
+ local nofvalues = result.nofvalues
+ local data = result.data
+ local nx = result.nx
+ local ny = result.ny
+ local lines = { }
+ result.lines = lines
+ for value=1,nofvalues do
+ lines[value] = whatever(data,ny,nx,value)
+ end
+end
+
+function mp.lmt_contours_edge_get_cell(value)
+ mpdraw(getparameterset().result.lines[value])
+ mpflush()
+end
+
+local singles = {
+ { d, 0, 0, 0, 0, d }, -- 1 0001
+ { d, 0, 0, d }, -- 2 0002
+ { 1, d, 1, 0, d, 0 }, -- 3 0010
+ { 1, d, 1, 0, 0, 0, 0, d }, -- 4 0011
+ { 1, d, 1, 0, d, 0, 0, d }, -- 5 0012
+ { 1, d, d, 0 }, -- 6 0020
+ { 1, d, d, 0, 0, 0, 0, d }, -- 7 0021
+ { 1, d, 0, d }, -- 8 0022
+ { d, 1, 1, 1, 1, d }, -- 9 0100
+ false, -- 10 0101
+ false, -- 11 0102
+ { d, 1, 1, 1, 1, 0, d, 0 }, -- 12 0110
+ { d, 1, 1, 1, 1, 0, 0, 0, 0, d }, -- 13 0111
+ { d, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 14 0112
+ { d, 1, 1, 1, 1, d, d, 0 }, -- 15 0120
+ { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, -- 16 0121
+ { d, 1, 1, 1, 1, d, 0, d }, -- 17 0122
+ { d, 1, 1, d }, -- 18 0200
+ false, -- 19 0201
+ false, -- 20 0202
+ { d, 1, 1, d, 1, 0, d, 0 }, -- 21 0210
+ { d, 1, 1, d, 1, 0, 0, 0, 0, d }, -- 22 0211
+ false, -- 23 0212
+ { d, 1, d, 0 }, -- 24 0220
+ { d, 1, d, 0, 0, 0, 0, d }, -- 25 0221
+ { d, 1, 0, d }, -- 26 0222
+ { 0, 1, d, 1, 0, d }, -- 27 1000
+ { 0, 1, d, 1, d, 0, 0, 0 }, -- 28 1001
+ { 0, 1, d, 1, d, 0, 0, d }, -- 29 1002
+ false, -- 30 1010
+ { 0, 1, d, 1, 1, d, 1, 0, 0, 0 }, -- 31 1011
+ { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, -- 32 1012
+ false, -- 33 1020
+ { 0, 1, d, 1, 1, d, d, 0, 0, 0 }, -- 34 1021
+ { 0, 1, d, 1, 1, d, 0, d }, -- 35 1022
+ { 0, 1, 1, 1, 1, d, 0, d }, -- 36 1100
+ { 0, 1, 1, 1, 1, d, d, 0, 0, 0 }, -- 37 1101
+ { 0, 1, 1, 1, 1, d, d, 0, 0, d }, -- 38 1102
+ { 0, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 39 1110
+ { 0, 1, 1, 1, 1, 0, 0, 0 }, -- 40 1111
+ { 0, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 41 1112
+ { 0, 1, 1, 1, 1, d, d, 0, 0, d }, -- 42 1120
+ { 0, 1, 1, 1, 1, d, d, 0, 0, 0 }, -- 43 1121
+ { 0, 1, 1, 1, 1, d, 0, d }, -- 44 1122
+ { 0, 1, d, 1, 1, d, 0, d }, -- 45 1200
+ { 0, 1, d, 1, 1, d, d, 0, 0, 0 }, -- 46 1201
+ false, -- 47 1202
+ { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, -- 48 1210
+ { 0, 1, d, 1, 1, d, 1, 0, 0, 0 }, -- 49 1211
+ false, -- 50 1212
+ { 0, 1, d, 1, d, 0, 0, d }, -- 51 1220
+ { 0, 1, d, 1, d, 0, 0, 0 }, -- 52 1221
+ { 0, 1, d, 1, 0, d }, -- 53 1222
+ { d, 1, 0, d }, -- 54 2000
+ { d, 1, d, 0, 0, 0, 0, d }, -- 55 2001
+ { d, 1, d, 0 }, -- 56 2002
+ false, -- 57 2010
+ { d, 1, 1, d, 1, 0, 0, 0, 0, d }, -- 58 2011
+ { d, 1, 1, d, 1, 0, d, 0 }, -- 59 2012
+ false, -- 60 2020
+ false, -- 61 2021
+ { d, 1, 1, d }, -- 62 2022
+ { d, 1, 1, 1, 1, d, 0, d }, -- 63 2100
+ { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, -- 64 2101
+ { d, 1, 1, 1, 1, d, d, 0 }, -- 65 2102
+ { d, 1, 1, 1, 1, 0, d, 0, 0, d }, -- 66 2110
+ { d, 1, 1, 1, 1, 0, 0, 0, 0, d }, -- 67 2111
+ { d, 1, 1, 1, 1, 0, d, 0 }, -- 68 2112
+ false, -- 69 2120
+ false, -- 70 2121
+ { d, 1, 1, 1, 1, d }, -- 71 2122
+ { 1, d, 0, d }, -- 72 2200
+ { 1, d, d, 0, 0, 0, 0, d }, -- 73 2201
+ { 1, d, d, 0 }, -- 74 2202
+ { 1, d, 1, 0, d, 0, 0, d }, -- 75 2210
+ { 1, d, 1, 0, 0, 0, 0, d }, -- 76 2211
+ { 1, d, 1, 0, d, 0 }, -- 77 2212
+ { d, 0, 0, d }, -- 78 2220
+ { 0, d, 0, 0, d, 0 }, -- 79 2221
+}
+
+local sadles = {
+ false, false, false, false, false, false, false, false, false,
+ { { d, 1, 1, 1, 1, d }, { d, 0, 0, 0, 0, d }, { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, false, false, false }, -- 10 0101
+ { { d, 1, 1, 1, 1, d }, { d, 0, 0, d }, { d, 1, 1, 1, 1, d, d, 0, 0, d }, false, false, false }, -- 11 0102
+ false, false, false, false, false, false, false,
+ { { d, 1, 1, d }, { d, 0, 0, 0, 0, d }, { d, 1, 1, d, d, 0, 0, 0, 0, d }, false, false, false }, -- 19 0201
+ { { d, 1, 1, d }, { d, 0, 0, d }, { d, 1, 1, d, d, 0, 0, d }, false, { d, 1, 0, d }, { 1, d, d, 0 } }, -- 20 0202
+ false, false,
+ { false, false, { d, 1, 1, d, 1, 0, d, 0, 0, d }, false, { d, 1, 0,d, }, { 1, d, 1, 0,d, 0 } }, -- 23 0212
+ false, false, false, false, false, false,
+ { { 0, 1, d, 1, 0, d }, { 1, d, 1, 0, d, 0 }, { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, false, false, false }, -- 30 1010
+ false, false,
+ { { 1, 0, d, 0, 0, d, }, { 1, d, d, 0 }, { 0, 1, d, 1, 1, d, d, 0, 0, d }, false, false, false }, -- 33 1020
+ false, false, false, false, false, false, false, false, false, false, false, false, false,
+ { false, false, { 0,1, d, 1, 1, d, d, 0, 0, d }, false, { 0,1, d, 1, 0, d }, {1, d, d, 0 } }, -- 47 1202
+ false, false,
+ { false, false, { 0, 1, d, 1, 1, d, 1, 0, d, 0, 0, d }, false, { 0, 1, d, 1, 0, d }, { 1, d, 1, 0, d, 0 } }, -- 50 1212
+ false, false, false, false, false, false,
+ { { d, 1, 0, d }, { 1, d, 1, 0, 0, d }, { d, 1, 1, d, 1, 0, d, 0, 0, d }, false, false, false }, -- 57 2010
+ false, false,
+ { { d, 1, 0,d }, { 1, d, d, 0 }, { d, 1, 1, d, d, 0, 0, d }, false, { d, 1, 1, d }, { d, 0, 0, d } }, -- 60 2020
+ { false, false, { d, 1, 1, d, d, 0, 0, 0, 0, d }, false, { d, 1, 1, d }, { d, 0, 0, 0, 0, d } }, -- 61 2021
+ false, false, false, false, false, false, false,
+ { false, false, { d, 1, 1, 1, 1, d, d, 0, 0, d }, false, { d, 1, 1, 1, 1, d }, { d, 0,0,d } }, -- 69 2120
+ { false, false, { d, 1, 1, 1, 1, d, d, 0, 0, 0, 0, d }, false, { d, 1, 1, 1, 1, d }, { d, 0, 0, 0, 0, d } }, -- 70 2121
+}
+
+local function whatever(data,nx,ny,threshold,background)
+
+ if background then
+
+ local llx = 1/2
+ local lly = llx
+ local urx = ny + llx
+ local ury = nx + lly
+
+ return { { llx, lly, urx, 0, urx, ury, 0, ury } }
+
+ else
+
+ local bands = { }
+ local b = 0
+
+ local function band(s,n,x,y) -- simple. no closure so fast
+ if n == 6 then
+ return {
+ x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
+ }
+ elseif n == 8 then
+ return {
+ x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
+ x - s[ 8], y + s[ 7],
+ }
+ elseif n == 10 then
+ return {
+ x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
+ x - s[ 8], y + s[ 7], x - s[10], y + s[ 9],
+ }
+ elseif n == 4 then
+ return {
+ x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3],
+ }
+ else -- 12
+ return {
+ x - s[ 2], y + s[ 1], x - s[ 4], y + s[ 3], x - s[ 6], y + s[ 5],
+ x - s[ 8], y + s[ 7], x - s[10], y + s[ 9], x - s[12], y + s[11],
+ }
+ end
+ end
+
+ local pp = { }
+
+ local d0 = data[1]
+ for j=1,ny-1 do
+ local d1 = data[j+1]
+ local k = j + 1
+ local p = false
+ for i=1,nx-1 do
+ local v = 0
+ local l = i + 1
+ local c1 = d0[i]
+ if c1 == threshold then
+ v = v + 27
+ elseif c1 > threshold then
+ v = v + 54
+ end
+ local c2 = d0[l]
+ if c2 == threshold then
+ v = v + 9
+ elseif c2 > threshold then
+ v = v + 18
+ end
+ local c3 = d1[l]
+ if c3 == threshold then
+ v = v + 3
+ elseif c3 > threshold then
+ v = v + 6
+ end
+ local c4 = d1[i]
+ if c4 == threshold then
+ v = v + 1
+ elseif c4 > threshold then
+ v = v + 2
+ end
+ if v > 0 and v < 80 then
+ if v == 40 then
+ -- a little optimization: full areas appended horizontally
+ if p then
+ p[4] = l -- i + 1
+ p[6] = l -- i + 1
+ else
+ -- x-0 y+1 x-1 y+1 x-1 y+0 x-0 y+0
+ p = { j, i, j, l, k, l, k, i }
+ b = b + 1 ; bands[b] = p
+ end
+ else
+ local s = singles[v]
+ if s then
+ b = b + 1 ; bands[b] = band(s,#s,k,i)
+ else
+ local s = sadles[v]
+ if s then
+ local m = (c1 + c2 + c3 + c4) / 4
+ if m < threshold then
+ local s1 = s[1] if s1 then b = b + 1 ; bands[b] = band(s1,#s1,i,j) end
+ local s2 = s[2] if s2 then b = b + 1 ; bands[b] = band(s2,#s2,i,j) end
+ elseif m == threshold then
+ local s3 = s[3] if s3 then b = b + 1 ; bands[b] = band(s3,#s3,i,j) end
+ local s4 = s[4] if s4 then b = b + 1 ; bands[b] = band(s4,#s4,i,j) end
+ else
+ local s5 = s[5] if s5 then b = b + 1 ; bands[b] = band(s5,#s5,i,j) end
+ local s6 = s[6] if s6 then b = b + 1 ; bands[b] = band(s6,#s6,i,j) end
+ end
+ end
+ end
+ p = false
+ end
+ else
+ p = false
+ end
+ end
+ d0 = d1
+ end
+ return bands
+ end
+end
+
+function mp.lmt_contours_edge_set_by_band(value)
+ local p = getparameterset()
+ local result = p.result
+
+ if result.cached then return end
+
+ local values = result.values
+ local nofvalues = result.nofvalues
+ local data = result.data
+ local nx = result.nx
+ local ny = result.ny
+ local bands = { }
+ result.bands = bands
+ for value=1,nofvalues do
+ bands[value] = whatever(data,ny,nx,value,value == 1)
+ end
+end
+
+function mp.lmt_contours_edge_get_band(value)
+ mpfill(getparameterset().result.bands[value],true)
+ mpflush()
+end
+
+-- Because we share some code surface plots also end up here. When working on the
+-- contour macros by concidence I ran into a 3D plot in
+--
+-- https://staff.science.uva.nl/a.j.p.heck/Courses/mptut.pdf
+--
+-- The code is pure MetaPost and works quite well. With a bit of optimization
+-- performance is also ok, but in the end a Lua solution is twice as fast and also
+-- permits some more tweaking at no cost. So, below is an adaptation of an example
+-- in the mentioned link. It's one of these cases where access to pseudo arrays
+-- is slowing down MP.
+
+local sqrt, sin, cos = math.sqrt, math.sin, math.cos
+
+local f_fill_rgb = formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"]
+local f_draw_rgb = formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"]
+local f_mesh_rgb = formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N) ;"]
+local f_fill_cmy = formatters["F (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N,0) ;"]
+local f_draw_cmy = formatters["D (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor %.3F ;"]
+local f_mesh_cmy = formatters["U (%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--(%.6N,%.6N)--C withcolor (%.3N,%.3N,%.3N,0) ;"]
+
+local f_function_n = formatters [ [[
+ local math = math
+ local round = math.round
+ %s
+ return function(x,y)
+ return %s
+ end
+]] ]
+
+local f_function_y = formatters [ [[
+ local math = math
+ local round = math.round
+ local nan = NaN
+ local inf = math.huge
+ local er = 0
+ %s
+ return function(x,y,dnan,dinf,report)
+ local n = %s
+ if n == nan then
+ er = er + 1
+ if er < 10 then
+ report("nan at (%s,%s)",x,y)
+ end
+ n = dnan
+ elseif n == inf then
+ er = er + 1
+ if er < 10 then
+ report("inf at (%s,%s)",x,y)
+ end
+ n = dinf
+ end
+ dx[my] = n
+ sy = sy + 1
+ end
+ return n, er
+end
+]] ]
+
+local f_color = formatters [ [[
+ local math = math
+ return function(f)
+ return %s
+ end
+]] ]
+
+function mp.lmt_surface_do(specification)
+ --
+ -- The projection and color brightness calculation have been inlined. We also store
+ -- differently.
+ --
+ -- todo: ignore weird paths
+ --
+ -- The prototype is now converted to use lmt parameter sets.
+ --
+ local p = getparameterset("surface")
+ --
+ local preamble = p.preamble or ""
+ local code = p.code or "return x + y"
+ local colorcode = p.color or "return f, f, f"
+ local linecolor = p.linecolor or 1
+ local xmin = p.xmin or -1
+ local xmax = p.xmax or 1
+ local ymin = p.ymin or -1
+ local ymax = p.ymax or 1
+ local xstep = p.xstep or .1
+ local ystep = p.ystep or .1
+ local bf = p.brightness or 100
+ local clip = p.clip or false
+ local lines = p.lines
+ local ha = p.snap or 0.01
+ local hb = 2 * ha
+ --
+ if lines == nil then lines = true end
+ --
+ if xstep == 0 then xstep = (xmax - xmin)/100 end
+ if ystep == 0 then ystep = (ymax - ymin)/100 end
+
+ local nxmin = round(xmin/xstep)
+ local nxmax = round(xmax/xstep)
+ local nymin = round(ymin/ystep)
+ local nymax = round(ymax/ystep)
+ local nx = nxmax - nxmin + 1
+ local ny = nymax - nymin + 1
+ --
+ local xvector = p.xvector or { -0.7, -0.7 }
+ local yvector = p.yvector or { 1, 0 }
+ local zvector = p.zvector or { 0, 1 }
+ local light = p.light or { 3, 3, 10 }
+ --
+ local xrx, xry = xvector[1], xvector[2]
+ local yrx, yry = yvector[1], yvector[2]
+ local zrx, zry = zvector[1], zvector[2]
+ local xp, yp, zp = light[1], light[2], light[3]
+ --
+ local data = setmetatableindex("table")
+ local dx = (xmax - xmin) / nx
+ local dy = (ymax - ymin) / ny
+ local xt = xmin
+ --
+ local minf, maxf
+ --
+ -- similar as contours but no data loop here
+ --
+ local fcode = load((p.check and f_function_y or f_function_n)(preamble,code))
+ local func = type(fcode) == "function" and fcode()
+ if type(func) ~= "function" then
+ return false -- fatal error
+ end
+ --
+ local ccode = load(f_color(colorcode))
+ local color = type(ccode) == "function" and ccode()
+ if type(color) ~= "function" then
+ return false -- fatal error
+ end
+ --
+ for i=0,nx do
+ local yt = ymin
+ for j=0,ny do
+ local zt = func(xt,yt)
+ -- projection from 3D to 2D coordinates
+ local x = xt * xrx + yt * yrx + zt * zrx
+ local y = xt * xry + yt * yry + zt * zry
+ local z = zt
+ -- numerical derivatives by central differences
+ local dfx = (func(xt+ha,yt) - func(xt-ha,yt)) / hb
+ local dfy = (func(xt,yt+ha) - func(xt,yt-ha)) / hb
+ -- compute brightness factor at a point
+ local ztp = zt - zp
+ local ytp = yt - yp
+ local xtp = xt - xp
+ local ztp = zt - zp
+ local ytp = yt - yp
+ local xtp = xt - xp
+ local ca = -ztp + dfy*ytp + dfx*xtp
+ local cb = sqrt(1+dfx*dfx+dfy*dfy)
+ local cc = sqrt(ztp*ztp + ytp*ytp + xtp*xtp)
+ local fac = bf*ca/(cb*cc*cc*cc)
+ -- addition: check range
+ if not minf then
+ minf = fac
+ maxf = fac
+ elseif fac < minf then
+ minf = fac
+ elseif fac > maxf then
+ maxf = fac
+ end
+ --
+ data[i][j] = { x, y, fac }
+ --
+ yt = yt + dy
+ end
+ xt = xt + dx
+ end
+ local result = { }
+ local r = 0
+ local range = maxf - minf
+ local cl = linecolor or 1
+ local enforce = attributes.colors.model == "cmyk"
+ for i=0,nx-1 do
+ for j=0,ny-1 do
+ -- points
+ local z1 = data[i] [j]
+ local z2 = data[i] [j+1]
+ local z3 = data[i+1][j+1]
+ local z4 = data[i+1][j]
+ -- color
+ local cf = z1[3]
+ if clip then
+ -- best clip here if needed
+ if cf < 0 then
+ cf = 0
+ elseif cf > 1 then
+ cf = 1
+ end
+ else
+ -- or remap when we want to
+ cf = (z1[3] - minf) / range
+ end
+ local z11 = z1[1]
+ local z12 = z1[2]
+ local z21 = z2[1]
+ local z22 = z2[2]
+ local z31 = z3[1]
+ local z32 = z3[2]
+ local z41 = z4[1]
+ local z42 = z4[2]
+ -- if lines then
+ -- -- fill first and draw then, previous shapes can be covered
+ -- else
+ -- -- fill and draw in one go to prevent artifacts
+ -- end
+ local cr, cg, cb = color(cf)
+ if not cr then cr = 0 end
+ if not cg then cg = 0 end
+ if not cb then cb = 0 end
+ if enforce then
+ cr, cg, cb = 1 - cr, 1 - cg, 1 - cb
+ r = r + 1
+ if lines then
+ result[r] = f_fill_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
+ r = r + 1
+ result[r] = f_draw_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cl)
+ else
+ result[r] = f_mesh_cmy(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
+ end
+ else
+ r = r + 1
+ if lines then
+ result[r] = f_fill_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
+ r = r + 1
+ result[r] = f_draw_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cl)
+ else
+ result[r] = f_mesh_rgb(z11,z12,z21,z22,z31,z32,z41,z42,cr,cg,cb)
+ end
+ end
+ end
+ end
+ mp.direct(concat(result))
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-ctx.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-ctx.lmt
new file mode 100644
index 00000000000..2569a6066b2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-ctx.lmt
@@ -0,0 +1,420 @@
+if not modules then modules = { } end modules ['mlib-ctx'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local type, tostring = type, tostring
+local format, concat = string.format, table.concat
+local settings_to_hash = utilities.parsers.settings_to_hash
+local formatters = string.formatters
+
+local report_metapost = logs.reporter ("metapost")
+local status_metapost = logs.messenger("metapost")
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
+local trace_graphic = false
+
+trackers.register("metapost.graphics",
+ function(v) trace_graphic = v end
+);
+
+local mplib = mplib
+
+metapost = metapost or { }
+local metapost = metapost
+local context = context
+
+local setters = tokens.setters
+local setmacro = setters.macro
+local implement = interfaces.implement
+
+local v_no = interfaces.variables.no
+
+local extensiondata = metapost.extensiondata or storage.allocate { }
+metapost.extensiondata = extensiondata
+
+storage.register("metapost/extensiondata",extensiondata,"metapost.extensiondata")
+
+function metapost.setextensions(instances,data)
+ if data and data ~= "" then
+ extensiondata[#extensiondata+1] = {
+ usedinall = not instances or instances == "",
+ instances = settings_to_hash(instances or ""),
+ extensions = data,
+ }
+ end
+end
+
+function metapost.getextensions(instance,state)
+ if state and state == v_no then
+ return ""
+ else
+ local t = { }
+ for i=1,#extensiondata do
+ local e = extensiondata[i]
+ local status = e.instances[instance]
+ if (status ~= true) and (e.usedinall or status) then
+ t[#t+1] = e.extensions
+ e.instances[instance] = true
+ end
+ end
+ return concat(t," ")
+ end
+end
+
+implement {
+ name = "setmpextensions",
+ actions = metapost.setextensions,
+ arguments = "2 strings",
+}
+
+implement {
+ name = "getmpextensions",
+ actions = { metapost.getextensions, context } ,
+ arguments = "string"
+}
+
+local patterns = {
+ "meta-imp-%s.mkxl",
+ "meta-imp-%s.mkiv",
+ "meta-imp-%s.tex",
+ -- obsolete:
+ "meta-%s.mkiv",
+ "meta-%s.tex"
+}
+
+local function action(name,foundname)
+ commands.loadlibrary(name,foundname,false)
+ status_metapost("library %a is loaded",name)
+end
+
+local function failure(name)
+ report_metapost("library %a is unknown or invalid",name)
+end
+
+implement {
+ name = "useMPlibrary",
+ arguments = "string",
+ actions = function(name)
+ resolvers.uselibrary {
+ name = name,
+ patterns = patterns,
+ action = action,
+ failure = failure,
+ onlyonce = true,
+ }
+ end
+}
+
+-- metapost.variables = { } -- to be stacked
+
+implement {
+ name = "mprunvar",
+ arguments = "string",
+ actions = function(name)
+ local value = metapost.variables[name]
+ if value ~= nil then
+ local tvalue = type(value)
+ if tvalue == "table" then
+ context(concat(value," "))
+ elseif tvalue == "number" or tvalue == "boolean" then
+ context(tostring(value))
+ elseif tvalue == "string" then
+ context(value)
+ end
+ end
+ end
+}
+
+implement {
+ name = "mpruntab",
+ arguments = { "string", "integer" },
+ actions = function(name,n)
+ local value = metapost.variables[name]
+ if value ~= nil then
+ local tvalue = type(value)
+ if tvalue == "table" then
+ context(value[n])
+ elseif tvalue == "number" or tvalue == "boolean" then
+ context(tostring(value))
+ elseif tvalue == "string" then
+ context(value)
+ end
+ end
+ end
+}
+
+implement {
+ name = "mprunset",
+ arguments = "2 strings",
+ actions = function(name,connector)
+ local value = metapost.variables[name]
+ if value ~= nil then
+ local tvalue = type(value)
+ if tvalue == "table" then
+ context(concat(value,connector))
+ elseif tvalue == "number" or tvalue == "boolean" then
+ context(tostring(value))
+ elseif tvalue == "string" then
+ context(value)
+ end
+ end
+ end
+}
+
+-- we need to move more from pps to here as pps is the plugin .. the order is a mess
+-- or just move the scanners to pps
+
+function metapost.graphic(specification)
+ metapost.pushformat(specification)
+ metapost.graphic_base_pass(specification)
+ metapost.popformat()
+end
+
+function metapost.startgraphic(t)
+ if not t then
+ t = { }
+ end
+ if not t.instance then
+ t.instance = metapost.defaultinstance
+ end
+ if not t.format then
+ t.format = metapost.defaultformat
+ end
+ if not t.method then
+ t.method = metapost.defaultmethod
+ end
+ t.data = { }
+ return t
+end
+
+function metapost.stopgraphic(t)
+ if t then
+ t.data = concat(t.data or { },"\n")
+ if trace_graphic then
+ report_metapost("\n"..t.data.."\n")
+ end
+ metapost.graphic(t)
+ end
+end
+
+function metapost.tographic(t,f,s,...)
+ local d = t.data
+ d[#d+1] = s and formatters[f](s,...) or f
+end
+
+implement {
+ name = "mpgraphic",
+ actions = metapost.graphic,
+ arguments = {
+ {
+ { "instance" },
+ { "format" },
+ { "data" },
+ { "initializations" },
+ { "extensions" },
+ { "inclusions" },
+ { "definitions" },
+ { "figure" },
+ { "method" },
+ { "namespace" },
+ }
+ }
+}
+
+implement {
+ name = "mpsetoutercolor",
+ actions = function(...) metapost.setoutercolor(...) end, -- not yet implemented
+ arguments = { "integer", "integer", "integer", "integer" }
+}
+
+-- this has to become a codeinjection
+
+function metapost.getclippath(specification) -- why not a special instance for this
+ local mpx = metapost.pushformat(specification)
+ local data = specification.data or ""
+ if mpx and data ~= "" then
+ starttiming(metapost)
+ starttiming(metapost.exectime)
+ local result = mpx:execute ( format ( "%s;%s;beginfig(1);%s;%s;endfig;",
+ specification.extensions or "",
+ specification.inclusions or "",
+ specification.initializations or "",
+ data
+ ) )
+ stoptiming(metapost.exectime)
+ if result.status > 0 then
+ report_metapost("%s: %s", result.status, result.error or result.term or result.log)
+ result = nil
+ else
+ result = metapost.filterclippath(result)
+ end
+ stoptiming(metapost)
+ metapost.popformat()
+ return result
+ else
+ metapost.popformat()
+ end
+end
+
+function metapost.filterclippath(result)
+ if result then
+ local figures = result.fig
+ if figures and #figures > 0 then
+ local figure = figures[1]
+ local objects = figure:objects()
+ if objects then
+ local lastclippath
+ for o=1,#objects do
+ local object = objects[o]
+ if object.type == "start_clip" then
+ lastclippath = object.path
+ end
+ end
+ return lastclippath
+ end
+ end
+ end
+end
+
+function metapost.theclippath(...)
+ local result = metapost.getclippath(...)
+ if result then -- we could just print the table
+ return concat(metapost.flushnormalpath(result)," ")
+ else
+ return ""
+ end
+end
+
+implement {
+ name = "mpsetclippath",
+ actions = function(specification)
+ local p = specification.data and metapost.theclippath(specification)
+ if not p or p == "" then
+ local b = number.dimenfactors.bp
+ local w = b * (specification.width or 0)
+ local h = b * (specification.height or 0)
+ p = formatters["0 0 m %.6N 0 l %.6N %.6N l 0 %.6N l"](w,w,h,h)
+ end
+ setmacro("MPclippath",p,"global")
+ end,
+ arguments = {
+ {
+ { "instance" },
+ { "format" },
+ { "data" },
+ { "initializations" },
+ { "useextensions" },
+ { "inclusions" },
+ { "method" },
+ { "namespace" },
+ { "width", "dimension" },
+ { "height", "dimension" },
+ },
+ }
+}
+
+statistics.register("metapost", function()
+ local n = metapost.nofruns
+ if n and n > 0 then
+ local elapsedtime = statistics.elapsedtime
+ local elapsed = statistics.elapsed
+ local runs, stats = metapost.nofscriptruns()
+ local instances,
+ memory = metapost.getstatistics(true)
+ return format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %s, memory: %0.3f M",
+ elapsedtime(metapost), elapsedtime(mplib), elapsedtime(metapost.exectime), n,
+ elapsedtime((elapsed(metapost) + elapsed(mplib) + elapsed(metapost.exectime)) / n),
+ instances, stats and stats or runs, memory/(1024*1024))
+ else
+ return nil
+ end
+end)
+
+-- only used in graphictexts
+
+metapost.tex = metapost.tex or { }
+local mptex = metapost.tex
+
+local environments = { }
+
+function mptex.set(str)
+ environments[#environments+1] = str
+end
+
+function mptex.setfrombuffer(name)
+ environments[#environments+1] = buffers.getcontent(name)
+end
+
+function mptex.get()
+ return concat(environments,"\n")
+end
+
+function mptex.reset()
+ environments = { }
+end
+
+implement {
+ name = "mppushvariables",
+ actions = metapost.pushvariables,
+}
+
+implement {
+ name = "mppopvariables",
+ actions = metapost.popvariables,
+}
+
+implement {
+ name = "mptexset",
+ arguments = "string",
+ actions = mptex.set
+}
+
+implement {
+ name = "mptexsetfrombuffer",
+ arguments = "string",
+ actions = mptex.setfrombuffer
+}
+
+implement {
+ name = "mptexget",
+ actions = { mptex.get, context }
+}
+
+implement {
+ name = "mptexreset",
+ actions = mptex.reset
+}
+
+-- moved from mlib-lua:
+
+mp = mp or { -- system namespace
+ set = { },
+ get = { },
+ aux = { },
+ scan = { },
+ skip = { },
+ inject = { },
+}
+
+MP = MP or { } -- user namespace
+
+-- We had this:
+--
+-- table.setmetatablecall(mp,function(t,k) mpprint(k) end)
+--
+-- but the next one is more interesting because we cannot use calls like:
+--
+-- lua.mp.somedefdname("foo")
+--
+-- which is due to expansion of somedefdname during suffix creation. So:
+--
+-- lua.mp("somedefdname","foo")
+
+table.setmetatablecall(mp,function(t,k,...) return t[k](...) end)
+table.setmetatablecall(MP,function(t,k,...) return t[k](...) end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-ctx.mkxl b/Master/texmf-dist/tex/context/base/mkxl/mlib-ctx.mkxl
new file mode 100644
index 00000000000..fb069b6ea88
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-ctx.mkxl
@@ -0,0 +1,34 @@
+%D \module
+%D [ file=mlib-ctx,
+%D version=2008.03.25,
+%D title=\METAPOST\ Integrated Graphics,
+%D subtitle=Basics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{MetaPost Library Graphics / Initializations}
+
+\installcorenamespace{graphicvariable}
+
+\registerctxluafile{mlib-fio}{autosuffix}
+\registerctxluafile{mlib-run}{autosuffix}
+\registerctxluafile{mlib-ctx}{autosuffix}
+\registerctxluafile{mlib-lua}{autosuffix}
+\registerctxluafile{mlib-mpf}{autosuffix}
+\registerctxluafile{mlib-scn}{autosuffix}
+\registerctxluafile{mlib-mat}{autosuffix}
+\registerctxluafile{mlib-ran}{autosuffix}
+\registerctxluafile{mlib-lmp}{autosuffix}
+\registerctxluafile{mlib-int}{autosuffix}
+\registerctxluafile{mlib-lmt}{autosuffix}
+\registerctxluafile{mlib-cnt}{autosuffix,optimize}
+\registerctxluafile{mlib-svg}{autosuffix,optimize}
+
+\unprotect
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-fio.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-fio.lmt
new file mode 100644
index 00000000000..9de61affef7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-fio.lmt
@@ -0,0 +1,289 @@
+if not modules then modules = { } end modules ['mlib-fio'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local type = type
+local find = string.find
+local concat = table.concat
+local suffix, addsuffix = file.suffix, file.addsuffix
+
+local findfile = resolvers.findfile
+local new_instance = mplib.new
+
+local trace_terminal = false trackers.register("metapost.terminal", function(v) trace_terminal = v end)
+
+local report_metapost = logs.reporter("metapost")
+local report_terminal = logs.reporter("metapost","terminal")
+local report_logger = logs.reporter("metapost","log")
+local report_error = logs.reporter("metapost","error")
+
+mplib.realtimelogging = false
+
+local l, nl, dl = { }, 0, false
+local t, nt, dt = { }, 0, false
+local e, ne, de = { }, 0, false
+
+local function logger(target,str)
+ if target == 1 then
+ -- log
+ elseif target == 2 or target == 3 then
+ -- term
+ if str == "\n" then
+ mplib.realtimelogging = true
+ if nl > 0 then
+ report_logger(concat(l,"",1,nl))
+ nl, dl = 0, false
+ elseif not dl then
+ report_logger("")
+ dl = true
+ end
+ else
+ nl = nl + 1
+ l[nl] = str
+ end
+ elseif target == 4 then
+ report_error(str)
+ end
+end
+
+local finders = { }
+mplib.finders = finders -- also used in meta-lua.lua
+
+local function validftype(ftype)
+ if ftype == "mp" then
+ return "mp"
+ else
+ return nil
+ end
+end
+
+-- We can have a list!
+
+local suffixlist = { "mpxl", "mpiv", "mp" } -- no "mf"
+
+local function findmpfile(name,ftype)
+ local validtyp = validftype(ftype)
+ local fullname = findfile(name,validtyp)
+ if fullname and fullname ~= "" then
+ return fullname
+ elseif suffix(name) == "" then
+ for i=1,#suffixlist do
+ fullname = findfile(addsuffix(name,suffixlist[i]),validtyp)
+ if fullname and fullname ~= "" then
+ return fullname
+ end
+ end
+ end
+ return nil
+end
+
+finders.file = function(specification,name,mode,kind)
+ if mode == "r" then
+ return findmpfile(name,kind)
+ elseif file.is_writable(name) then
+ return name
+ else
+ return nil
+ end
+end
+
+local function finder(name,mode,kind) -- fake message for mpost.map and metafun.mpvi
+ local specification = url.hashed(name)
+ local finder = finders[specification.scheme] or finders.file
+ local found = finder(specification,name,mode,validftype(ftype))
+ return found
+end
+
+local findtexfile = resolvers.findtexfile
+local opentexfile = resolvers.opentexfile
+local splitlines = string.splitlines
+
+local function writetoterminal(terminaldata,maxterm,d)
+ local t = type(d)
+ local n = 0
+ if t == "string" then
+ d = splitlines(d)
+ n = #d
+ for i=1,#d do
+ maxterm = maxterm + 1
+ terminaldata[maxterm] = d[i]
+ end
+ elseif t == "table" then
+ for i=1,#d do
+ local l = d[i]
+ if not l then
+ -- just ignore
+ elseif find(l,"[\n\r]") then
+ local s = splitlines(l)
+ local m = #s
+ for i=1,m do
+ maxterm = maxterm + 1
+ terminaldata[maxterm] = s[i]
+ end
+ n = n + m
+ else
+ maxterm = maxterm + 1
+ terminaldata[maxterm] = d[i]
+ n = 1
+ end
+ end
+ end
+ if trace_terminal then
+ report_metapost("writing %i lines, in cache %s",n,maxterm)
+ end
+ return maxterm
+end
+
+local function readfromterminal(terminaldata,maxterm,nowterm)
+ if nowterm >= maxterm then
+ terminaldata[nowterm] = false
+ maxterm = 0
+ nowterm = 0
+ if trace_terminal then
+ report_metapost("resetting, maxcache %i",#terminaldata)
+ end
+ return maxterm, nowterm, nil
+ else
+ if nowterm > 0 then
+ terminaldata[nowterm] = false
+ end
+ nowterm = nowterm + 1
+ local s = terminaldata[nowterm]
+ if trace_terminal then
+ report_metapost("reading line %i: %s",nowterm,s)
+ end
+ return maxterm, nowterm, s
+ end
+end
+
+local function fileopener()
+
+ -- these can go into the table itself
+
+ local terminaldata = { }
+ local maxterm = 0
+ local nowterm = 0
+
+ local terminal = {
+ name = "terminal",
+ close = function()
+ -- terminal = { }
+ -- maxterm = 0
+ -- nowterm = 0
+ end,
+ reader = function()
+ local line
+ maxterm, nowterm, line = readfromterminal(terminaldata,maxterm,nowterm)
+ return line
+ end,
+ writer = function(d)
+ maxterm = writetoterminal(terminaldata,maxterm,d)
+ end,
+ }
+
+ return function(name,mode,kind)
+ if name == "terminal" then
+ -- report_metapost("opening terminal")
+ return terminal
+ elseif mode == "w" then
+ -- we need an extra check here for permissions
+ local f = io.open(name,"wb")
+ if f then
+ -- report_metapost("opening file %a for writing",full)
+ return {
+ name = full,
+ writer = function(s) return f:write(s) end, -- io.write(f,s)
+ close = function() f:close() end,
+ }
+ end
+ else
+ local full = findtexfile(name,validftype(ftype))
+ if full then
+ -- report_metapost("opening file %a for reading",full)
+ return opentexfile(full)
+ end
+ end
+ end
+
+end
+
+local overloadmode = "warning"
+
+directives.register("metapost.overloadmode",function(v)
+ if v == "warning" or v == "error" then
+ overloadmode = v
+ else
+ overloadmode= false
+ end
+end)
+
+local propertycodes = {
+ [-3] = "mutable",
+ [ 1] = "primitive",
+ [ 2] = "permanent",
+ [ 3] = "immutable",
+}
+
+mplib.propertycodes = propertycodes
+
+local report = logs.reporter("metafun", "log")
+
+local function overload(property,name)
+ if overloadmode and property >= 0 then
+ -- turn of warning after format is loaded
+ local code = propertycodes[property] or "unknown"
+ report("overloading %s %a",code, name)
+ -- no overload permitted
+ if overloadmode == "error" then
+ luatex.abort()
+ end
+ return false
+ else
+ -- overload permitted
+ return true
+ end
+end
+
+local showcontext = mplib.showcontext
+
+local function handleerror(instance, message, helpinfo, interaction)
+ report()
+ report("error: %s", message)
+ report()
+ showcontext(instance)
+ report()
+ report(helpinfo)
+ report()
+ if interaction == 5 then
+ -- todo
+-- luatex.abort()
+ end
+end
+
+local function handlewarning(instance, message)
+ report()
+ report("warning: %s", message)
+ report()
+end
+
+function mplib.new(specification)
+ local instance
+ local openfile = fileopener()
+ specification.find_file = finder
+ specification.run_logger = logger
+ specification.run_overload = overload
+ specification.run_error = function(...) handleerror (instance,...) end
+ specification.run_warning = function(...) handlewarning(instance,...) end
+ specification.open_file = openfile
+ specification.interaction = "silent"
+ specification.job_name = tex.jobname -- mandate in order to get something back
+ specification.halt_on_error = true
+ instance = new_instance(specification)
+ return instance, openfile("terminal")
+end
+
+mplib.finder = finder
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-int.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-int.lmt
new file mode 100644
index 00000000000..a936e55924e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-int.lmt
@@ -0,0 +1,160 @@
+if not modules then modules = { } end modules ['mlib-int'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local factor = number.dimenfactors.bp
+local mpstring = mp.string
+local mpboolean = mp.boolean
+local getdimen = tex.getdimen
+local getcount = tex.getcount
+local getmacro = tokens.getters.macro
+local get = tex.get
+local emwidths = fonts.hashes.emwidths
+local exheights = fonts.hashes.exheights
+
+local registerscript = metapost.registerscript
+
+local on_right_page = structures.pages.on_right
+local is_odd_page = structures.pages.is_odd
+local in_body_page = structures.pages.in_body
+local page_fraction = structures.pages.fraction
+local layout_has_changed = structures.pages.has_changed
+
+local function defaultcolormodel() -- can be helper
+ local colormethod = getcount("MPcolormethod")
+ return (colormethod == 0 or colormethod == 1) and 1 or 3
+end
+
+do
+
+ local t = os.date("*t") -- maybe this should be a very early on global
+
+ -- If we want to do a vardef then we first need to catch an endgroup and
+ -- that then fails because we have a variable sitting there, so they need
+ -- to be def's at the mp end.
+
+ local assignment_code = metapost.codes.assignment
+
+ local mpscannext = mp.scan.next
+ local mpscaninteger = mp.scan.integer
+
+ local function item(name)
+ local n = mpscannext(true) -- keep
+ if n == assignment_code then
+ mpscannext()
+ t[name] = mpscaninteger()
+ else
+ return t[name]
+ end
+ end
+
+ registerscript("year", function() return item("year") end)
+ registerscript("month", function() return item("month") end)
+ registerscript("day", function() return item("day") end)
+ registerscript("hour", function() return item("hour") end)
+ registerscript("minute", function() return item("min") end)
+ registerscript("second", function() return item("sec") end)
+
+end
+
+registerscript("PaperHeight", function() return getdimen("paperheight") * factor end)
+registerscript("PaperWidth", function() return getdimen("paperwidth") * factor end)
+registerscript("PrintPaperHeight", function() return getdimen("printpaperheight") * factor end)
+registerscript("PrintPaperWidth", function() return getdimen("printpaperwidth") * factor end)
+registerscript("TopSpace", function() return getdimen("topspace") * factor end)
+registerscript("BottomSpace", function() return getdimen("bottomspace") * factor end)
+registerscript("BackSpace", function() return getdimen("backspace") * factor end)
+registerscript("CutSpace", function() return getdimen("cutspace") * factor end)
+registerscript("MakeupHeight", function() return getdimen("makeupheight") * factor end)
+registerscript("MakeupWidth", function() return getdimen("makeupwidth") * factor end)
+registerscript("TopHeight", function() return getdimen("topheight") * factor end)
+registerscript("TopDistance", function() return getdimen("topdistance") * factor end)
+registerscript("HeaderHeight", function() return getdimen("headerheight") * factor end)
+registerscript("HeaderDistance", function() return getdimen("headerdistance") * factor end)
+registerscript("TextHeight", function() return getdimen("textheight") * factor end)
+registerscript("FooterDistance", function() return getdimen("footerdistance") * factor end)
+registerscript("FooterHeight", function() return getdimen("footerheight") * factor end)
+registerscript("BottomDistance", function() return getdimen("bottomdistance") * factor end)
+registerscript("BottomHeight", function() return getdimen("bottomheight") * factor end)
+registerscript("LeftEdgeWidth", function() return getdimen("leftedgewidth") * factor end)
+registerscript("LeftEdgeDistance", function() return getdimen("leftedgedistance") * factor end)
+registerscript("LeftMarginWidth", function() return getdimen("leftmarginwidth") * factor end)
+registerscript("LeftMarginDistance", function() return getdimen("leftmargindistance") * factor end)
+registerscript("TextWidth", function() return getdimen("textwidth") * factor end)
+registerscript("RightMarginDistance", function() return getdimen("rightmargindistance") * factor end)
+registerscript("RightMarginWidth", function() return getdimen("rightmarginwidth") * factor end)
+registerscript("RightEdgeDistance", function() return getdimen("rightedgedistance") * factor end)
+registerscript("RightEdgeWidth", function() return getdimen("rightedgewidth") * factor end)
+registerscript("InnerMarginDistance", function() return getdimen("innermargindistance") * factor end)
+registerscript("InnerMarginWidth", function() return getdimen("innermarginwidth") * factor end)
+registerscript("OuterMarginDistance", function() return getdimen("outermargindistance") * factor end)
+registerscript("OuterMarginWidth", function() return getdimen("outermarginwidth") * factor end)
+registerscript("InnerEdgeDistance", function() return getdimen("inneredgedistance") * factor end)
+registerscript("InnerEdgeWidth", function() return getdimen("inneredgewidth") * factor end)
+registerscript("OuterEdgeDistance", function() return getdimen("outeredgedistance") * factor end)
+registerscript("OuterEdgeWidth", function() return getdimen("outeredgewidth") * factor end)
+registerscript("PageOffset", function() return getdimen("pagebackgroundoffset") * factor end)
+registerscript("PageDepth", function() return getdimen("pagebackgrounddepth") * factor end)
+registerscript("LayoutColumns", function() return getcount("layoutcolumns") end)
+registerscript("LayoutColumnDistance", function() return getdimen("layoutcolumndistance") * factor end)
+registerscript("LayoutColumnWidth", function() return getdimen("layoutcolumnwidth") * factor end)
+registerscript("SpineWidth", function() return getdimen("spinewidth") * factor end)
+registerscript("PaperBleed", function() return getdimen("paperbleed") * factor end)
+
+registerscript("RealPageNumber", function() return getcount("realpageno") end)
+registerscript("LastPageNumber", function() return getcount("lastpageno") end)
+
+registerscript("PageNumber", function() return getcount("pageno") end)
+registerscript("NOfPages", function() return getcount("lastpageno") end)
+
+registerscript("SubPageNumber", function() return getcount("subpageno") end)
+registerscript("NOfSubPages", function() return getcount("lastsubpageno") end)
+
+registerscript("CurrentColumn", function() return getcount("mofcolumns") end)
+registerscript("NOfColumns", function() return getcount("nofcolumns") end)
+
+registerscript("BaseLineSkip", function() return get ("baselineskip",true) * factor end)
+registerscript("LineHeight", function() return getdimen("lineheight") * factor end)
+registerscript("BodyFontSize", function() return getdimen("bodyfontsize") * factor end)
+
+registerscript("TopSkip", function() return get ("topskip",true) * factor end)
+registerscript("StrutHeight", function() return getdimen("strutht") * factor end)
+registerscript("StrutDepth", function() return getdimen("strutdp") * factor end)
+
+registerscript("PageNumber", function() return getcount("pageno") end)
+registerscript("RealPageNumber", function() return getcount("realpageno") end)
+registerscript("NOfPages", function() return getcount("lastpageno") end)
+
+registerscript("CurrentWidth", function() return get ("hsize") * factor end)
+registerscript("CurrentHeight", function() return get ("vsize") * factor end)
+
+registerscript("EmWidth", function() return emwidths [false] * factor end)
+registerscript("ExHeight", function() return exheights[false] * factor end)
+
+registerscript("HSize", function() return get ("hsize") * factor end)
+registerscript("VSize", function() return get ("vsize") * factor end)
+registerscript("LastPageNumber", function() return getcount("lastpageno") end)
+
+registerscript("OverlayWidth", function() return getdimen("d_overlay_width") * factor end)
+registerscript("OverlayHeight", function() return getdimen("d_overlay_height") * factor end)
+registerscript("OverlayDepth", function() return getdimen("d_overlay_depth") * factor end)
+registerscript("OverlayLineWidth", function() return getdimen("d_overlay_linewidth") * factor end)
+registerscript("OverlayOffset", function() return getdimen("d_overlay_offset") * factor end)
+registerscript("OverlayRegion", function() mpstring(getmacro("m_overlay_region")) end)
+--------------("CurrentLayout", function() mpstring(getmacro("currentlayout")) end)
+
+-- should be direct
+--
+-- registerscript("PageFraction", page_fraction)
+
+registerscript("PageFraction", function() return mpboolean(page_fraction ()) end)
+registerscript("OnRightPage", function() return mpboolean(on_right_page ()) end)
+registerscript("OnOddPage", function() return mpboolean(is_odd_page ()) end)
+registerscript("InPageBody", function() return mpboolean(in_body_page ()) end)
+registerscript("LayoutHasChanged", function() return mpboolean(layout_has_changed()) end)
+
+registerscript("defaultcolormodel", defaultcolormodel)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-lmp.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-lmp.lmt
new file mode 100644
index 00000000000..2b3e910babd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-lmp.lmt
@@ -0,0 +1,104 @@
+if not modules then modules = { } end modules ['mlib-lmp'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- path relates stuff ... todo: use a stack (or numeric index to list)
+
+local type = type
+
+local aux = mp.aux
+local mpnumeric = aux.numeric
+local mppair = aux.pair
+
+local registerscript = metapost.registerscript
+
+local scan = mp.scan
+local get = mp.get
+local scannumber = scan.number
+local scanstring = scan.string
+local scanpath = scan.path
+local scanproperty = scan.property
+local gethashentry = get.hashentry
+
+local p = nil
+local n = 0
+
+registerscript("pathreset", function()
+ p = nil
+ n = 0
+end)
+
+registerscript("pathlengthof", function()
+ p = scanpath()
+ n = p and #p or 1
+ mpnumeric(n)
+end)
+
+registerscript("pathpointof", function()
+ local i = scannumber()
+ if i > 0 and i <= n then
+ local pi = p[i]
+ mppair(pi[1],pi[2])
+ end
+end)
+
+registerscript("pathleftof", function()
+ local i = scannumber()
+ if i > 0 and i <= n then
+ local pi = p[i]
+ mppair(pi[5],pi[6])
+ end
+end)
+
+registerscript("pathrightof", function()
+ local i = scannumber()
+ if i > 0 and i <= n then
+ local pn
+ if i == 1 then
+ pn = p[2] or p[1]
+ else
+ pn = p[i+1] or p[1]
+ end
+ mppair(pn[3],pn[4])
+ end
+end)
+
+local report = logs.reporter("metapost", "log")
+local codes = metapost.codes
+local types = metapost.types
+local procodes = mplib.propertycodes
+
+registerscript("showproperty", function()
+ local k, s, p, d = scanproperty()
+ if k then
+ report("name %a, property %a, command %a, detail %a",s,procodes[p] or "-",codes[k] or "-",types[d] or "-")
+ end
+end)
+
+registerscript("showhashentry", function()
+ local s = scanstring()
+ if s then
+ local k, p, d = gethashentry(s)
+ if k then
+ report("name %a, property %a, command %a, detail %a",s,procodes[p] or "-",codes[k] or "-",types[d] or "-")
+ end
+ end
+end)
+
+local getmacro = tokens.getters.macro
+local mpgnamespace = getmacro("??graphicvariable")
+
+local scanmpstring = mp.scan.string
+
+local injectnumeric = mp.inject.numeric
+local injectstring = mp.inject.string
+
+-- registerscript("mpv_numeric", function() injectnumeric (getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring())) end)
+-- registerscript("mpv_dimension", function() return getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring()) end)
+-- registerscript("mpv_string", function() injectstring (getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring())) end)
+
+registerscript("mpvar", function() return getmacro(mpgnamespace .. getmacro("currentmpvariableclass") .. ":" .. scanmpstring(), true) end) -- Isn't it already edef'd?
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-lmt.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-lmt.lmt
new file mode 100644
index 00000000000..b7c869c3bac
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-lmt.lmt
@@ -0,0 +1,199 @@
+if not modules then modules = { } end modules ['mlib-lmt'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- todo: check for possible inject usage
+
+local type = type
+local round = math.round
+
+local aux = mp.aux
+local mpdirect = aux.direct
+local mppath = mp.path
+
+local scan = mp.scan
+local scannumeric = scan.numeric
+local scanpath = scan.path
+
+local injectpath = mp.inject.path
+local injectcolor = mp.inject.color
+
+local getparameter = metapost.getparameter
+local registerscript = metapost.registerscript
+
+function mp.lmt_function_x(xmin,xmax,xstep,code,shape) -- experimental
+ local code = "return function(x) return " .. code .. " end"
+ local action = load(code)
+ local points = { }
+ local nofpoints = 0
+ if action then
+ action = action()
+ end
+ if shape == "steps" then
+ local halfx = xstep / 2
+ local lastx = xmin
+ local lasty = action(xmin)
+ for xi = xmin, xmax, xstep do
+ local yi = action(xi)
+ local xx = lastx + halfx
+ nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, lasty }
+ nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, yi }
+ lastx = xi
+ lasty = yi
+ end
+ if points[nofpoints][1] ~= xmax then
+ local yi = action(xmax)
+ local xx = lastx + halfx
+ nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, lasty }
+ nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, yi }
+ lastx = xi
+ lasty = yi
+ end
+ else
+ for xi = xmin, xmax, xstep do
+ nofpoints = nofpoints + 1 ; points[nofpoints] = { xi, action(xi) }
+ end
+ if points[nofpoints][1] ~= xmax then
+ nofpoints = nofpoints + 1 ; points[nofpoints] = { xmax, action(xmax) }
+ end
+ end
+ mppath(points,shape == "curve" and ".." or "--",false)
+end
+
+function mp.lmt_mesh_set()
+ local mesh = getparameter { "mesh", "paths" }
+ structures.references.currentset.mesh = mesh
+end
+
+function mp.lmt_mesh_update()
+ local mesh = getparameter { "paths" } or getparameter { "mesh", "paths" }
+ mesh[scannumeric()] = scanpath(true)
+end
+
+-- moved here
+
+function mp.lmt_svg_include()
+ local labelfile = metapost.getparameter { "labelfile" }
+ if labelfile and labelfile ~= "" then
+ local labels = table.load(labelfile) -- todo: same path as svg file
+ if type(labels) == "table" then
+ for i=1,#labels do
+ metapost.remaptext(labels[i])
+ end
+ end
+ end
+ local fontname = metapost.getparameter { "fontname" }
+ if fontname and fontname ~= "" then
+ local unicode = metapost.getparameter { "unicode" }
+ if unicode then
+ mpdirect (
+ metapost.svgglyphtomp(fontname,math.round(unicode))
+ )
+ end
+ return
+ end
+ local colorfile = metapost.getparameter { "colormap" }
+ local colormap = false
+ if colorfile and colorfile ~= "" then
+ colormap = metapost.svgcolorremapper(colorfile)
+ end
+ local filename = metapost.getparameter { "filename" }
+ if filename and filename ~= "" then
+ mpdirect ( metapost.svgtomp {
+ data = io.loaddata(filename),
+ remap = true,
+ colormap = colormap,
+ id = filename,
+ } )
+ else
+ local buffer = metapost.getparameter { "buffer" }
+ if buffer then
+ mpdirect ( metapost.svgtomp {
+ data = buffers.getcontent(buffer),
+ -- remap = true,
+ colormap = colormap,
+ id = buffer or "buffer",
+ } )
+ else
+ local code = metapost.getparameter { "code" }
+ if code then
+ mpdirect ( metapost.svgtomp {
+ data = code,
+ colormap = colormap,
+ id = "code",
+ } )
+ end
+ end
+ end
+end
+
+registerscript("remaptext", function()
+ local parameters = metapost.scanparameters()
+ if parameters and parameters.label then
+ metapost.remaptext(parameters)
+ end
+end)
+
+do
+
+ local dropins = fonts.dropins
+ local registerglyph = dropins.registerglyph
+ local registerglyphs = dropins.registerglyphs
+
+ registerscript("registerglyph", function() registerglyph (metapost.getparameterset("mpsglyph")) end)
+ registerscript("registerglyphs",function() registerglyphs(metapost.getparameterset("mpsglyphs")) end)
+
+end
+
+todecimal = xdecimal and xdecimal.new or tonumber -- bonus
+
+-- mail on list by Mikael Sundqvist and Taco's analysis of near duplicate points (2021/02/11+)
+
+registerscript("scrutenized", function()
+ local p = scanpath()
+ local d = 10^scannumeric()
+ for i=1,#p do
+ local pi = p[i]
+ pi[1] = round(pi[1] * d) / d
+ pi[2] = round(pi[2] * d) / d
+ end
+ local x1 = round(p[1][1])
+ local y1 = round(p[1][2])
+ local n = 1
+ local m = #p
+ local t = { p[1], cycle = p.cycle }
+ for i=2,m-1 do
+ local pi = p[i]
+ local x2 = r(pi[1])
+ local y2 = r(pi[2])
+ if x1 ~= x2 or y1 ~= y2 then
+ n = n + 1
+ t[n] = p[i]
+ x1 = x2
+ y1 = y2
+ end
+ end
+ local x1 = r(p[1][1])
+ local y1 = r(p[1][2])
+ local x2 = r(p[m][1])
+ local y2 = r(p[m][2])
+ if x1 ~= x2 or y1 ~= y2 then
+ n = n + 1
+ t[n] = p[m]
+ end
+ mp.path(t)
+ -- injectpath(t)
+end)
+
+-- A goodie, mostly a side effect of updating the metafun manual.
+
+
+local labtorgb = attributes.colors.labtorgb
+
+registerscript("labtorgb", function()
+ injectcolor(labtorgb(scannumeric(),scannumeric(),scannumeric()))
+end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-lua.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-lua.lmt
new file mode 100644
index 00000000000..068d17f32f9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-lua.lmt
@@ -0,0 +1,210 @@
+if not modules then modules = { } end modules ['mlib-lua'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local type = type
+local insert, remove = table.insert, table.remove
+
+local trace = false trackers.register("metapost.instance",function(v) trace = v end)
+
+local report = logs.reporter("metapost","instance")
+
+local codes = mplib.getcodes()
+local types = mplib.gettypes()
+
+-- for k,v in next, mplib do if type(v) == "function" then local f = v mplib[k] = function(...) print(k) return v(...) end end end
+
+table.hashed(codes)
+table.hashed(types)
+
+metapost.codes = codes
+metapost.types = types
+
+local scan = mp.scan
+local skip = mp.skip
+local get = mp.get
+local inject = mp.inject
+
+local currentmpx = nil
+local stack = { }
+
+local function reports(s) report("%a scan %s", tostring(currentmpx),s) end -- temporary, till we're okay
+local function reporti(s) report("%a inject %s",tostring(currentmpx),s) end -- temporary, till we're okay
+
+local scan_next = mplib.scan_next
+local scan_expression = mplib.scan_expression
+local scan_token = mplib.scan_token
+local scan_symbol = mplib.scan_symbol
+local scan_property = mplib.scan_property
+local scan_numeric = mplib.scan_numeric
+local scan_integer = mplib.scan_integer
+local scan_boolean = mplib.scan_boolean
+local scan_string = mplib.scan_string
+local scan_pair = mplib.scan_pair
+local scan_color = mplib.scan_color
+local scan_cmykcolor = mplib.scan_cmykcolor
+local scan_transform = mplib.scan_transform
+local scan_path = mplib.scan_path
+local scan_pen = mplib.scan_pen
+
+local skip_token = mplib.skip_token
+
+local get_hashentry = mplib.gethashentry
+
+scan.next = function(k) if trace then reporti("next") end return scan_next (currentmpx,k) end
+scan.expression = function(k) if trace then reporti("expression") end return scan_expression(currentmpx,k) end
+scan.token = function(k) if trace then reporti("token") end return scan_token (currentmpx,k) end
+scan.symbol = function(k,e) if trace then reporti("symbol") end return scan_symbol (currentmpx,k,e) end
+scan.property = function(k) if trace then reporti("property") end return scan_property (currentmpx,k) end
+scan.numeric = function() if trace then reporti("numeric") end return scan_numeric (currentmpx) end
+scan.integer = function() if trace then reporti("integer") end return scan_integer (currentmpx) end
+scan.boolean = function() if trace then reporti("boolean") end return scan_boolean (currentmpx) end
+scan.string = function() if trace then reporti("string") end return scan_string (currentmpx) end
+scan.pair = function(t) if trace then reporti("pair") end return scan_pair (currentmpx,t) end
+scan.color = function(t) if trace then reporti("color") end return scan_color (currentmpx,t) end
+scan.cmykcolor = function(t) if trace then reporti("cmykcolor") end return scan_cmykcolor (currentmpx,t) end
+scan.transform = function(t) if trace then reporti("transform") end return scan_transform (currentmpx,t) end
+scan.path = function(t) if trace then reporti("path") end return scan_path (currentmpx,t) end
+scan.pen = function(t) if trace then reporti("pen") end return scan_pen (currentmpx,t) end
+
+skip.token = function(t) return skip_token (currentmpx,t) end
+
+get.hashentry = function(n) return get_hashentry (currentmpx,n) end
+
+local solvepath = mplib.solvepath
+local getstatus = mplib.getstatus
+
+mp.solve = function(...)
+ return solvepath(currentmpx,...)
+end
+
+local inject_path = mplib.inject_path
+local inject_numeric = mplib.inject_numeric
+local inject_pair = mplib.inject_pair
+local inject_boolean = mplib.inject_boolean
+local inject_integer = mplib.inject_integer
+local inject_string = mplib.inject_string
+local inject_color = mplib.inject_color
+local inject_cmykcolor = mplib.inject_cmykcolor
+local inject_transform = mplib.inject_transform
+local inject_whatever = mplib.inject_whatever
+
+
+------.path = function(t,cycle,curled) if trace then reporti("path") end return inject_path (currentmpx,t,cycle,curled) end
+inject.numeric = function(n) if trace then reporti("numeric") end return inject_numeric (currentmpx,n) end
+inject.pair = function(x,y) if trace then reporti("pair") end return inject_pair (currentmpx,x,y) end
+inject.boolean = function(b) if trace then reporti("boolean") end return inject_boolean (currentmpx,b) end
+inject.integer = function(i) if trace then reporti("integer") end return inject_integer (currentmpx,i) end
+inject.string = function(s) if trace then reporti("string") end return inject_string (currentmpx,s) end
+inject.color = function(r,g,b) if trace then reporti("color") end return inject_color (currentmpx,r,g,b) end
+inject.cmykcolor = function(c,m,y,k) if trace then reporti("cmykcolor") end return inject_cmykcolor(currentmpx,c,m,y,k) end
+inject.transform = function(x,y,xx,xy,yx,yy) if trace then reporti("transform") end return inject_transform(currentmpx,x,y,xx,xy,yx,yy) end
+inject.whatever = function(...) if trace then reporti("whatever") end return inject_whatever (currentmpx,...) end
+
+inject.triplet = inject.color
+inject.quadruplet = inject.cmykcolor
+
+local function same(p,n)
+ local f = p[1]
+ local l = p[n]
+ local nf = #f
+ local nl = #l
+ if nf == nl then
+ for i=1,nf do
+ if f[i] ~= l[i] then
+ return false
+ end
+ end
+ return true
+ end
+ return false
+end
+
+-- local p = mp.scan.path()
+-- mp.inject.path(p,true,true)
+
+function inject.path(p,close,connector)
+ local curled = false
+ local n = #p
+ if p.close or p.cycle then
+ close = true
+ end
+ if n > 1 then
+ -- [ ../true | --/false | nil/auto ]
+ if connector == nil or connector == "auto" then
+ connector = #p[1] > 2
+ end
+ if connector == false or connector == "--" then
+ curled = true
+ elseif connector == true or connector == ".." then
+ if close and not same(p,n) then
+ p[n+1] = p[1]
+ end
+ end
+ end
+ if trace then reporti("path") end
+ return inject_path(currentmpx,p,close,curled)
+end
+
+-- bonus:
+
+scan .number = scan .numeric
+inject.number = inject.numeric
+
+table.setmetatablecall(inject,function(t,...)
+ inject_whatever(currentmpx,...)
+end)
+
+-- experiment
+
+function mp.autoinject(m)
+ local t = type(m)
+ if t == "table" then
+ local n = #t
+ if n == 2 then
+ inject_pair(currentmpx,m)
+ elseif n == 3 then
+ inject_color(currentmpx,m)
+ elseif n == 4 then
+ inject_cmykcolor(currentmpx,m)
+ elseif n == 6 then
+ inject_transform(currentmpx,m)
+ end
+ elseif t == "number" then
+ inject_numeric(currentmpx,m)
+ elseif t == "string" then
+ inject_string(currentmpx,m)
+ elseif t == "boolean" then
+ inject_boolean(currentmpx,m)
+ end
+end
+
+function metapost.pushscriptrunner(mpx)
+ if trace then
+ report("%a => %a",tostring(currentmpx),tostring(mpx))
+ end
+ insert(stack,currentmpx)
+ currentmpx = mpx
+end
+
+function metapost.popscriptrunner()
+ local mpx = remove(stack)
+ if trace then
+ report("%a <= %a",tostring(mpx),tostring(currentmpx))
+ end
+ currentmpx = mpx
+end
+
+function metapost.currentmpx()
+ return currentmpx
+end
+
+-- mplib.getstates(): zero is "normal"
+
+function metapost.currentmpxstatus()
+ return getstatus(currentmpx) or 0
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-mat.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-mat.lmt
new file mode 100644
index 00000000000..3a63b32c784
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-mat.lmt
@@ -0,0 +1,139 @@
+if not modules then modules = { } end modules ['mlib-mat'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local scanners = mp.scan
+local injectors = mp.inject
+
+local scannumeric = scanners.numeric
+local scanpair = scanners.pair
+local scancolor = scanners.color
+
+local mppair = injectors.pair or mp.pair
+
+local registerscript = metapost.registerscript
+
+local m = xmath
+local c = xcomplex
+
+local m_acos = m.acos registerscript("m_acos", function() return m_acos (scannumeric()) end)
+local m_acosh = m.acosh registerscript("m_acosh", function() return m_acosh (scannumeric()) end)
+local m_asin = m.asin registerscript("m_asin", function() return m_asin (scannumeric()) end)
+local m_asinh = m.asinh registerscript("m_asinh", function() return m_asinh (scannumeric()) end)
+local m_atan = m.atan registerscript("m_atan", function() return m_atan (scannumeric()) end)
+local m_atan2 = m.atan2 registerscript("m_atan2", function() return m_atan2 (scanpair ()) end)
+local m_atanh = m.atanh registerscript("m_atanh", function() return m_atanh (scannumeric()) end)
+local m_cbrt = m.cbrt registerscript("m_cbrt", function() return m_cbrt (scannumeric()) end)
+local m_ceil = m.ceil registerscript("m_ceil", function() return m_ceil (scannumeric()) end)
+local m_copysign = m.copysign registerscript("m_copysign", function() return m_copysign (scanpair ()) end)
+local m_cos = m.cos registerscript("m_cos", function() return m_cos (scannumeric()) end)
+local m_cosh = m.cosh registerscript("m_cosh", function() return m_cosh (scannumeric()) end)
+local m_deg = m.deg registerscript("m_deg", function() return m_deg (scannumeric()) end)
+local m_erf = m.erf registerscript("m_erf", function() return m_erf (scannumeric()) end)
+local m_erfc = m.erfc registerscript("m_erfc", function() return m_erfc (scannumeric()) end)
+local m_exp = m.exp registerscript("m_exp", function() return m_exp (scannumeric()) end)
+local m_exp2 = m.exp2 registerscript("m_exp2", function() return m_exp2 (scannumeric()) end)
+local m_expm1 = m.expm1 registerscript("m_expm1", function() return m_expm1 (scannumeric()) end)
+local m_fabs = m.fabs registerscript("m_fabs", function() return m_fabs (scannumeric()) end)
+local m_fdim = m.fdim registerscript("m_fdim", function() return m_fdim (scanpair ()) end)
+local m_floor = m.floor registerscript("m_floor", function() return m_floor (scannumeric()) end)
+local m_fma = m.fma registerscript("m_fma", function() return m_fma (scancolor ()) end)
+local m_fmax = m.fmax registerscript("m_fmax", function() return m_fmax (scannumeric()) end)
+local m_fmin = m.fmin registerscript("m_fmin", function() return m_fmin (scannumeric()) end)
+local m_fmod = m.fmod registerscript("m_fmod", function() return m_fmod (scanpair ()) end)
+local m_frexp = m.frexp registerscript("m_frexp", function() return m_frexp (scannumeric()) end)
+local m_gamma = m.gamma registerscript("m_gamma", function() return m_gamma (scannumeric()) end)
+local m_hypot = m.hypot registerscript("m_hypot", function() return m_hypot (scanpair ()) end)
+local m_isfinite = m.isfinite registerscript("m_isfinite", function() return m_isfinite (scannumeric()) end)
+local m_isinf = m.isinf registerscript("m_isinf", function() return m_isinf (scannumeric()) end)
+local m_isnan = m.isnan registerscript("m_isnan", function() return m_isnan (scannumeric()) end)
+local m_isnormal = m.isnormal registerscript("m_isnormal", function() return m_isnormal (scannumeric()) end)
+local m_j0 = m.j0 registerscript("m_j0", function() return m_j0 (scannumeric()) end)
+local m_j1 = m.j1 registerscript("m_j1", function() return m_j1 (scannumeric()) end)
+local m_jn = m.jn registerscript("m_jn", function() return m_jn (scanpair ()) end)
+local m_ldexp = m.ldexp registerscript("m_ldexp", function() return m_ldexp (scanpair ()) end)
+local m_lgamma = m.lgamma registerscript("m_lgamma", function() return m_lgamma (scannumeric()) end)
+local m_log = m.log registerscript("m_log", function() return m_log (scannumeric()) end)
+local m_log10 = m.log10 registerscript("m_log10", function() return m_log10 (scannumeric()) end)
+local m_log1p = m.log1p registerscript("m_log1p", function() return m_log1p (scannumeric()) end)
+local m_log2 = m.log2 registerscript("m_log2", function() return m_log2 (scannumeric()) end)
+local m_logb = m.logb registerscript("m_logb", function() return m_logb (scannumeric()) end)
+local m_modf = m.modf registerscript("m_modf", function() return m_modf (scannumeric()) end)
+local m_nearbyint = m.nearbyint registerscript("m_nearbyint", function() return m_nearbyint(scannumeric()) end)
+local m_nextafter = m.nextafter registerscript("m_nextafter", function() return m_nextafter(scanpair ()) end)
+local m_pow = m.pow registerscript("m_pow", function() return m_pow (scanpair ()) end)
+local m_rad = m.rad registerscript("m_rad", function() return m_rad (scannumeric()) end)
+local m_remainder = m.remainder registerscript("m_remainder", function() return m_remainder(scanpair ()) end)
+local m_remquo = m.remquo registerscript("m_remquo", function() return m_remquo (scannumeric()) end)
+local m_round = m.round registerscript("m_round", function() return m_round (scannumeric()) end)
+local m_scalbn = m.scalbn registerscript("m_scalbn", function() return m_scalbn (scanpair ()) end)
+local m_sin = m.sin registerscript("m_sin", function() return m_sin (scannumeric()) end)
+local m_sinh = m.sinh registerscript("m_sinh", function() return m_sinh (scannumeric()) end)
+local m_sqrt = m.sqrt registerscript("m_sqrt", function() return m_sqrt (scannumeric()) end)
+local m_tan = m.tan registerscript("m_tan", function() return m_tan (scannumeric()) end)
+local m_tanh = m.tanh registerscript("m_tanh", function() return m_tanh (scannumeric()) end)
+local m_tgamma = m.tgamma registerscript("m_tgamma", function() return m_tgamma (scannumeric()) end)
+local m_trunc = m.trunc registerscript("m_trunc", function() return m_trunc (scannumeric()) end)
+local m_y0 = m.y0 registerscript("m_y0", function() return m_y0 (scannumeric()) end)
+local m_y1 = m.y1 registerscript("m_y1", function() return m_y1 (scannumeric()) end)
+local m_yn = m.yn registerscript("m_yn", function() return m_yn (scanpair ()) end)
+
+if not (c and c.sin) then
+ return
+end
+
+local c_topair = c.topair
+local c_new = c.new
+
+local c_sin = c.sin registerscript("c_sin", function() return mppair(c_topair(c_sin (c_new(scanpair())))) end)
+local c_cos = c.cos registerscript("c_cos", function() return mppair(c_topair(c_cos (c_new(scanpair())))) end)
+local c_tan = c.tan registerscript("c_tan", function() return mppair(c_topair(c_tan (c_new(scanpair())))) end)
+local c_sinh = c.sinh registerscript("c_sinh", function() return mppair(c_topair(c_sinh (c_new(scanpair())))) end)
+local c_cosh = c.cosh registerscript("c_cosh", function() return mppair(c_topair(c_cosh (c_new(scanpair())))) end)
+local c_tanh = c.tanh registerscript("c_tanh", function() return mppair(c_topair(c_tanh (c_new(scanpair())))) end)
+
+local c_asin = c.asin registerscript("c_asin", function() return mppair(c_topair(c_sin (c_new(scanpair())))) end)
+local c_acos = c.acos registerscript("c_acos", function() return mppair(c_topair(c_cos (c_new(scanpair())))) end)
+local c_atan = c.atan registerscript("c_atan", function() return mppair(c_topair(c_tan (c_new(scanpair())))) end)
+local c_asinh = c.asinh registerscript("c_asinh", function() return mppair(c_topair(c_sinh (c_new(scanpair())))) end)
+local c_acosh = c.acosh registerscript("c_acosh", function() return mppair(c_topair(c_cosh (c_new(scanpair())))) end)
+local c_atanh = c.atanh registerscript("c_atanh", function() return mppair(c_topair(c_tanh (c_new(scanpair())))) end)
+
+local c_sqrt = c.sqrt registerscript("c_sqrt", function() return mppair(c_topair(c_sqrt (c_new(scanpair())))) end)
+local c_abs = c.abs registerscript("c_abs", function() return c_topair(c_abs (c_new(scanpair()))) end)
+local c_arg = c.arg registerscript("c_arg", function() return c_topair(c_arg (c_new(scanpair()))) end)
+local c_conj = c.conj registerscript("c_conj", function() return mppair(c_topair(c_conj (c_new(scanpair())))) end)
+local c_exp = c.exp registerscript("c_exp", function() return mppair(c_topair(c_exp (c_new(scanpair())))) end)
+local c_log = c.log registerscript("c_log", function() return mppair(c_topair(c_log (c_new(scanpair())))) end)
+local c_proj = c.proj registerscript("c_proj", function() return mppair(c_topair(c_proj (c_new(scanpair())))) end)
+
+local c_erf = c.erf registerscript("c_erf", function() return mppair(c_topair(c_erf (c_new(scanpair())))) end)
+local c_erfc = c.erfc registerscript("c_erfc", function() return mppair(c_topair(c_erfc (c_new(scanpair())))) end)
+local c_erfcx = c.erfcx registerscript("c_erfcx", function() return mppair(c_topair(c_erfcx (c_new(scanpair())))) end)
+local c_erfi = c.erfi registerscript("c_erfi", function() return mppair(c_topair(c_erfi (c_new(scanpair())))) end)
+local c_dawson = c.dawson registerscript("c_dawson", function() return mppair(c_topair(c_dawson(c_new(scanpair())))) end)
+
+local c_voigt = c.voigt
+local c_voigt_hwhm = c.voigt_hwhm
+
+registerscript("c_voigt", function()
+ return mppair(c_topair(c_voigt(c_new(scanpair()),c_new(scanpair()),c_new(scanpair()))))
+end)
+
+registerscript("c_voigt_hwhm", function()
+ return mppair(c_topair(c_voigt_hwhm(c_new(scanpair()),c_new(scanpair()))))
+end)
+
+local c_pow = c.pow registerscript("c_pow", function() return mppair(c_topair(c_pow(c_new(scanpair()),c_new(scanpair())))) end)
+local c_add = c.add registerscript("c_add", function() return mppair(c_topair(c_add(c_new(scanpair()),c_new(scanpair())))) end)
+local c_sub = c.sub registerscript("c_sub", function() return mppair(c_topair(c_sub(c_new(scanpair()),c_new(scanpair())))) end)
+local c_mul = c.mul registerscript("c_mul", function() return mppair(c_topair(c_mul(c_new(scanpair()),c_new(scanpair())))) end)
+local c_div = c.div registerscript("c_div", function() return mppair(c_topair(c_div(c_new(scanpair()),c_new(scanpair())))) end)
+
+local c_imag = c.imag registerscript("c_imag", function() return c_topair(c_imag(c_new(scanpair()))) end)
+local c_real = c.real registerscript("c_real", function() return c_topair(c_real(c_new(scanpair()))) end)
+local c_neg = c.neg registerscript("c_new", function() return c_topair(c_neg (c_new(scanpair()))) end)
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-mpf.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-mpf.lmt
new file mode 100644
index 00000000000..f24d7fde09c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-mpf.lmt
@@ -0,0 +1,1260 @@
+if not modules then modules = { } end modules ['mlib-mpf'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- moved from mlib-lua:
+
+local type, tostring, tonumber, select, loadstring = type, tostring, tonumber, select, loadstring
+local find, match, gsub, gmatch = string.find, string.match, string.gsub, string.gmatch
+local concat = table.concat
+
+local formatters = string.formatters
+local lpegmatch = lpeg.match
+local lpegpatterns = lpeg.patterns
+
+local P, S, Ct, Cs, Cc, C = lpeg.P, lpeg.S, lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.C
+
+local report_luarun = logs.reporter("metapost","lua")
+local report_script = logs.reporter("metapost","script")
+local report_message = logs.reporter("metapost")
+
+local trace_luarun = false trackers.register("metapost.lua", function(v) trace_luarun = v end)
+local trace_script = false trackers.register("metapost.script",function(v) trace_script = v end)
+
+local be_tolerant = true directives.register("metapost.lua.tolerant", function(v) be_tolerant = v end)
+
+local set = mp.set
+local get = mp.get
+local aux = mp.aux
+local scan = mp.scan
+local skip = mp.skip
+local inject = mp.inject
+
+do
+
+ -- serializers
+
+ local f_integer = formatters["%i"]
+ local f_numeric = formatters["%F"]
+
+ -- no %n as that can produce -e notation and that is not so nice for scaled butmaybe we
+ -- should then switch between ... i.e. make a push/pop for the formatters here ... not now.
+
+ local f_integer = formatters["%i"]
+ local f_numeric = formatters["%F"]
+ local f_pair = formatters["(%F,%F)"]
+ local f_ctrl = formatters["(%F,%F) .. controls (%F,%F) and (%F,%F)"]
+ local f_triplet = formatters["(%F,%F,%F)"]
+ local f_quadruple = formatters["(%F,%F,%F,%F)"]
+ local f_transform = formatters["totransform(%F,%F,%F,%F,%F,%F)"]
+ local f_pen = formatters["(pencircle transformed totransform(%F,%F,%F,%F,%F,%F))"]
+
+ local f_points = formatters["%p"]
+ local f_pair_pt = formatters["(%p,%p)"]
+ local f_ctrl_pt = formatters["(%p,%p) .. controls (%p,%p) and (%p,%p)"]
+ local f_triplet_pt = formatters["(%p,%p,%p)"]
+ local f_quadruple_pt = formatters["(%p,%p,%p,%p)"]
+
+ local r = P('%') / "percent"
+ + P('"') / "dquote"
+ + P('\n') / "crlf"
+ -- + P(' ') / "space"
+ local a = Cc("&")
+ local q = Cc('"')
+ local p = Cs(q * (r * a)^-1 * (a * r * (P(-1) + a) + P(1))^0 * q)
+
+ mp.cleaned = function(s) return lpegmatch(p,s) or s end
+
+ -- management
+
+ -- sometimes we gain (e.g. .5 sec on the sync test)
+
+ local cache = table.makeweak()
+
+ local runscripts = { }
+ local runnames = { }
+ local nofscripts = 0
+
+ function metapost.registerscript(name,f)
+ nofscripts = nofscripts + 1
+ if f then
+ runscripts[nofscripts] = f
+ runnames[name] = nofscripts
+ else
+ runscripts[nofscripts] = name
+ end
+ if trace_script then
+ report_script("registering script %a as %i",name,nofscripts)
+ end
+ return nofscripts
+ end
+
+ function metapost.scriptindex(name)
+ local index = runnames[name] or 0
+ if trace_script then
+ report_script("fetching scriptindex %i of %a",index,name)
+ end
+ return index
+ end
+
+ -- The gbuffer sharing and such is not really needed now but make a dent when
+ -- we have a high volume of simpel calls (loops) so we keep it around for a
+ -- while.
+
+ local nesting = 0
+ local runs = 0
+ local gbuffer = { }
+ local buffer = gbuffer
+ local n = 0
+
+ local function mpdirect1(a)
+ n = n + 1 buffer[n] = a
+ end
+ local function mpdirect2(a,b)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ end
+ local function mpdirect3(a,b,c)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ end
+ local function mpdirect4(a,b,c,d)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ n = n + 1 buffer[n] = d
+ end
+ local function mpdirect5(a,b,c,d,e)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ n = n + 1 buffer[n] = d
+ n = n + 1 buffer[n] = e
+ end
+
+ local function mpflush(separator)
+ buffer[1] = concat(buffer,separator or "",1,n)
+ n = 1
+ end
+
+ function metapost.runscript(code)
+ nesting = nesting + 1
+ runs = runs + 1
+
+ local index = type(code) == "number"
+ local f
+ local result
+
+ if index then
+ f = runscripts[code]
+ if not f then
+ report_luarun("%i: bad index: %s",nesting,code)
+ elseif trace_luarun then
+ report_luarun("%i: index: %i",nesting,code)
+ end
+ else
+ if trace_luarun then
+ report_luarun("%i: code: %s",nesting,code)
+ end
+ f = cache[code]
+ if not f then
+ f = loadstring("return " .. code)
+ if f then
+ cache[code] = f
+ elseif be_tolerant then
+ f = loadstring(code)
+ if f then
+ cache[code] = f
+ end
+ end
+ end
+ end
+
+ -- returning nil is more efficient and a signal not to scan in mp
+
+ if f then
+
+ local lbuffer, ln
+
+ if nesting == 1 then
+ buffer = gbuffer
+ n = 0
+ else
+ lbuffer = buffer
+ ln = n
+ buffer = { }
+ n = 0
+ end
+
+ result = f()
+ if result then
+ local t = type(result)
+ -- we can consider to use the injector for tables but then we need to
+ -- check if concatination is expected so best keep this!
+ if t == "number" or t == "boolean" then
+ -- native types
+ elseif t == "string" or t == "table" then
+ -- (concatenated) passed to scantokens
+ else
+ -- scantokens
+ result = tostring(result)
+ end
+ if trace_luarun then
+ report_luarun("%i: %s result: %s",nesting,t,result)
+ end
+ elseif n == 0 then
+ -- result = ""
+ result = nil -- no scantokens done then
+ if trace_luarun then
+ report_luarun("%i: no buffered result",nesting)
+ end
+ elseif n == 1 then
+ result = buffer[1]
+ if trace_luarun then
+ report_luarun("%i: 1 buffered result: %s",nesting,result)
+ end
+ else
+ -- the space is why we sometimes have collectors
+ if nesting == 1 then
+ -- if we had no space we could pass result directly in lmtx
+ result = concat(buffer," ",1,n)
+ if n > 500 or #result > 10000 then
+ gbuffer = { } -- newtable(20,0)
+ lbuffer = gbuffer
+ end
+ else
+ -- if we had no space we could pass result directly in lmtx
+ result = concat(buffer," ")
+ end
+ if trace_luarun then
+ report_luarun("%i: %i buffered results: %s",nesting,n,result)
+ end
+ end
+
+ if nesting == 1 then
+ n = 0
+ else
+ buffer = lbuffer
+ n = ln
+ end
+
+ else
+ report_luarun("%i: no result, invalid code: %s",nesting,code)
+ result = ""
+ end
+
+ nesting = nesting - 1
+
+ return result
+ end
+
+ function metapost.nofscriptruns()
+ local c = mplib.getcallbackstate()
+ return c.count, string.format(
+ "%s (file: %s, text: %s, script: %s, log: %s)",
+ c.count, c.file, c.text, c.script, c.log
+ )
+ end
+
+ -- writers
+
+ local function mpp(value)
+ n = n + 1
+ local t = type(value)
+ if t == "number" then
+ buffer[n] = f_numeric(value)
+ elseif t == "string" then
+ buffer[n] = value
+ elseif t == "table" then
+ if #t == 6 then
+ buffer[n] = "totransform(" .. concat(value,",") .. ")"
+ else
+ buffer[n] = "(" .. concat(value,",") .. ")"
+ end
+ else -- boolean or whatever
+ buffer[n] = tostring(value)
+ end
+ end
+
+ local function mpprint(first,second,...)
+ if second == nil then
+ if first ~= nil then
+ mpp(first)
+ end
+ else
+ for i=1,select("#",first,second,...) do
+ local value = (select(i,first,second,...))
+ if value ~= nil then
+ mpp(value)
+ end
+ end
+ end
+ end
+
+ local function mpp(value)
+ n = n + 1
+ local t = type(value)
+ if t == "number" then
+ buffer[n] = f_numeric(value)
+ elseif t == "string" then
+ buffer[n] = lpegmatch(p,value)
+ elseif t == "table" then
+ if #t > 4 then
+ buffer[n] = ""
+ else
+ buffer[n] = "(" .. concat(value,",") .. ")"
+ end
+ else -- boolean or whatever
+ buffer[n] = tostring(value)
+ end
+ end
+
+ local function mpvprint(first,second,...) -- variable print
+ if second == nil then
+ if first ~= nil then
+ mpp(first)
+ end
+ else
+ for i=1,select("#",first,second,...) do
+ local value = (select(i,first,second,...))
+ if value ~= nil then
+ mpp(value)
+ end
+ end
+ end
+ end
+
+ local function mpstring(value)
+ n = n + 1
+ buffer[n] = lpegmatch(p,value)
+ end
+
+ local function mpboolean(b)
+ n = n + 1
+ buffer[n] = b and "true" or "false"
+ end
+
+ local function mpnumeric(f)
+ n = n + 1
+ if not f or f == 0 then
+ buffer[n] = "0"
+ else
+ buffer[n] = f_numeric(f)
+ end
+ end
+
+ local function mpinteger(i)
+ n = n + 1
+ -- buffer[n] = i and f_integer(i) or "0"
+ buffer[n] = i or "0"
+ end
+
+ local function mppoints(i)
+ n = n + 1
+ if not i or i == 0 then
+ buffer[n] = "0pt"
+ else
+ buffer[n] = f_points(i)
+ end
+ end
+
+ local function mppair(x,y)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_pair(x[1],x[2])
+ else
+ buffer[n] = f_pair(x,y)
+ end
+ end
+
+ local function mppairpoints(x,y)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_pair_pt(x[1],x[2])
+ else
+ buffer[n] = f_pair_pt(x,y)
+ end
+ end
+
+ local function mptriplet(x,y,z)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_triplet(x[1],x[2],x[3])
+ else
+ buffer[n] = f_triplet(x,y,z)
+ end
+ end
+
+ local function mptripletpoints(x,y,z)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_triplet_pt(x[1],x[2],x[3])
+ else
+ buffer[n] = f_triplet_pt(x,y,z)
+ end
+ end
+
+ local function mpquadruple(w,x,y,z)
+ n = n + 1
+ if type(w) == "table" then
+ buffer[n] = f_quadruple(w[1],w[2],w[3],w[4])
+ else
+ buffer[n] = f_quadruple(w,x,y,z)
+ end
+ end
+
+ local function mpquadruplepoints(w,x,y,z)
+ n = n + 1
+ if type(w) == "table" then
+ buffer[n] = f_quadruple_pt(w[1],w[2],w[3],w[4])
+ else
+ buffer[n] = f_quadruple_pt(w,x,y,z)
+ end
+ end
+
+ local function mptransform(x,y,xx,xy,yx,yy)
+ n = n + 1
+ if type(x) == "table" then
+ buffer[n] = f_transform(x[1],x[2],x[3],x[4],x[5],x[6])
+ else
+ buffer[n] = f_transform(x,y,xx,xy,yx,yy)
+ end
+ end
+
+ local function mpcolor(c,m,y,k)
+ n = n + 1
+ if type(c) == "table" then
+ local l = #c
+ if l == 4 then
+ buffer[n] = f_quadruple(c[1],c[2],c[3],c[4])
+ elseif l == 3 then
+ buffer[n] = f_triplet(c[1],c[2],c[3])
+ else
+ buffer[n] = f_numeric(c[1])
+ end
+ else
+ if k then
+ buffer[n] = f_quadruple(c,m,y,k)
+ elseif y then
+ buffer[n] = f_triplet(c,m,y)
+ else
+ buffer[n] = f_numeric(c)
+ end
+ end
+ end
+
+ -- we have three kind of connectors:
+ --
+ -- .. ... -- (true)
+
+ local function mp_path(f2,f6,t,connector,cycle)
+ if type(t) == "table" then
+ local tn = #t
+ if tn == 1 then
+ local t1 = t[1]
+ n = n + 1
+ if t.pen then
+ buffer[n] = f_pen(unpack(t1))
+ else
+ buffer[n] = f2(t1[1],t1[2])
+ end
+ elseif tn > 0 then
+ if connector == true or connector == nil then
+ connector = ".."
+ elseif connector == false then
+ connector = "--"
+ end
+ if cycle == nil then
+ cycle = t.cycle
+ if cycle == nil then
+ cycle = true
+ end
+ end
+ local six = connector == ".." -- otherwise we use whatever gets asked for
+ local controls = connector -- whatever
+ local a = t[1]
+ local b = t[2]
+ n = n + 1
+ buffer[n] = "("
+ n = n + 1
+ if six and #a == 6 and #b == 6 then
+ buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
+ controls = ".."
+ else
+ buffer[n] = f2(a[1],a[2])
+ controls = connector
+ end
+ for i=2,tn-1 do
+ a = b
+ b = t[i+1]
+ n = n + 1
+ buffer[n] = connector
+ n = n + 1
+ if six and #a == 6 and #b == 6 then
+ buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
+ controls = ".."
+ else
+ buffer[n] = f2(a[1],a[2])
+ controls = connector
+ end
+ end
+ n = n + 1
+ buffer[n] = connector
+ a = b
+ b = t[1]
+ n = n + 1
+ if cycle then
+ if six and #a == 6 and #b == 6 then
+ buffer[n] = f6(a[1],a[2],a[5],a[6],b[3],b[4])
+ controls = ".."
+ else
+ buffer[n] = f2(a[1],a[2])
+ controls = connector
+ end
+ n = n + 1
+ buffer[n] = connector
+ n = n + 1
+ buffer[n] = "cycle"
+ else
+ buffer[n] = f2(a[1],a[2])
+ end
+ n = n + 1
+ buffer[n] = ")"
+ end
+ end
+ end
+
+ local function mppath(...)
+ mp_path(f_pair,f_ctrl,...)
+ end
+
+ local function mppathpoints(...)
+ mp_path(f_pair_pt,f_ctrl_pt,...)
+ end
+
+ local function mpsize(t)
+ n = n + 1
+ buffer[n] = type(t) == "table" and f_numeric(#t) or "0"
+ end
+
+ local replacer = lpeg.replacer("@","%%")
+
+ local function mpfprint(fmt,...)
+ n = n + 1
+ if not find(fmt,"%",1,true) then
+ fmt = lpegmatch(replacer,fmt)
+ end
+ buffer[n] = formatters[fmt](...)
+ end
+
+ local function mpquoted(fmt,s,...)
+ if s then
+ n = n + 1
+ if not find(fmt,"%",1,true) then
+ fmt = lpegmatch(replacer,fmt)
+ end
+ -- buffer[n] = '"' .. formatters[fmt](s,...) .. '"'
+ buffer[n] = lpegmatch(p,formatters[fmt](s,...))
+ elseif fmt then
+ n = n + 1
+ -- buffer[n] = '"' .. fmt .. '"'
+ buffer[n] = lpegmatch(p,fmt)
+ else
+ -- something is wrong
+ end
+ end
+
+ aux.direct = mpdirect1
+ aux.direct1 = mpdirect1
+ aux.direct2 = mpdirect2
+ aux.direct3 = mpdirect3
+ aux.direct4 = mpdirect4
+ aux.flush = mpflush
+
+ aux.print = mpprint
+ aux.vprint = mpvprint
+ aux.boolean = mpboolean
+ aux.string = mpstring
+ aux.numeric = mpnumeric
+ aux.number = mpnumeric
+ aux.integer = mpinteger
+ aux.points = mppoints
+ aux.pair = mppair
+ aux.pairpoints = mppairpoints
+ aux.triplet = mptriplet
+ aux.tripletpoints = mptripletpoints
+ aux.quadruple = mpquadruple
+ aux.quadruplepoints = mpquadruplepoints
+ aux.path = mppath
+ aux.pathpoints = mppathpoints
+ aux.size = mpsize
+ aux.fprint = mpfprint
+ aux.quoted = mpquoted
+ aux.transform = mptransform
+ aux.color = mpcolor
+
+ -- for the moment
+
+ local function mpdraw(lines,list) -- n * 4
+ if list then
+ local c = #lines
+ for i=1,c do
+ local ci = lines[i]
+ local ni = #ci
+ n = n + 1 buffer[n] = i < c and "d(" or "D("
+ for j=1,ni,2 do
+ local l = j + 1
+ n = n + 1 buffer[n] = ci[j]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = ci[l]
+ n = n + 1 buffer[n] = l < ni and ")--(" or ");"
+ end
+ end
+ else
+ local l = #lines
+ local m = l - 4
+ for i=1,l,4 do
+ n = n + 1 buffer[n] = i < m and "d(" or "D("
+ n = n + 1 buffer[n] = lines[i]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+1]
+ n = n + 1 buffer[n] = ")--("
+ n = n + 1 buffer[n] = lines[i+2]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+3]
+ n = n + 1 buffer[n] = ");"
+ end
+ end
+ end
+
+ local function mpfill(lines,list)
+ if list then
+ local c = #lines
+ for i=1,c do
+ local ci = lines[i]
+ local ni = #ci
+ n = n + 1 buffer[n] = i < c and "f(" or "F("
+ for j=1,ni,2 do
+ local l = j + 1
+ n = n + 1 buffer[n] = ci[j]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = ci[l]
+ n = n + 1 buffer[n] = l < ni and ")--(" or ")--C;"
+ end
+ end
+ else
+ local l = #lines
+ local m = l - 4
+ for i=1,l,4 do
+ n = n + 1 buffer[n] = i < m and "f(" or "F("
+ n = n + 1 buffer[n] = lines[i]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+1]
+ n = n + 1 buffer[n] = ")--("
+ n = n + 1 buffer[n] = lines[i+2]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+3]
+ n = n + 1 buffer[n] = ")--C;"
+ end
+ end
+ end
+
+ aux.draw = mpdraw
+ aux.fill = mpfill
+
+ for k, v in next, aux do mp[k] = v end
+
+end
+
+do
+
+ -- Another experimental feature:
+
+ local mpnumeric = mp.numeric
+ local scanstring = scan.string
+ local scriptindex = metapost.scriptindex
+
+ function mp.mf_script_index(name)
+ local index = scriptindex(name)
+ -- report_script("method %i, name %a, index %i",1,name,index)
+ mpnumeric(index)
+ end
+
+ -- once bootstrapped ... (needs pushed mpx instances)
+
+ metapost.registerscript("scriptindex",function()
+ local name = scanstring()
+ local index = scriptindex(name)
+ -- report_script("method %i, name %a, index %i",2,name,index)
+ mpnumeric(index)
+ end)
+
+end
+
+-- the next will move to mlib-lmp.lua
+
+do
+
+ local mpnamedcolor = attributes.colors.mpnamedcolor
+ local mpprint = aux.print
+ local scanstring = scan.string
+
+ mp.mf_named_color = function(str)
+ mpprint(mpnamedcolor(str))
+ end
+
+ -- todo: we can inject but currently we always get a string back so then
+ -- we need to deal with it upstream in the color module ... not now
+
+ metapost.registerscript("namedcolor",function()
+ mpprint(mpnamedcolor(scanstring()))
+ end)
+
+end
+
+function mp.n(t) -- used ?
+ return type(t) == "table" and #t or 0
+end
+
+do
+
+ -- experiment: names can change
+
+ local mppath = aux.path
+ local mpsize = aux.size
+
+ local whitespace = lpegpatterns.whitespace
+ local newline = lpegpatterns.newline
+ local setsep = newline^2
+ local comment = (S("#%") + P("--")) * (1-newline)^0 * (whitespace - setsep)^0
+ local value = (1-whitespace)^1 / tonumber
+ local entry = Ct( value * whitespace * value)
+ local set = Ct((entry * (whitespace-setsep)^0 * comment^0)^1)
+ local series = Ct((set * whitespace^0)^1)
+
+ local pattern = whitespace^0 * series
+
+ local datasets = { }
+ mp.datasets = datasets
+
+ function mp.dataset(str)
+ return lpegmatch(pattern,str)
+ end
+
+ function datasets.load(tag,filename)
+ if not filename then
+ tag, filename = file.basename(tag), tag
+ end
+ local data = lpegmatch(pattern,io.loaddata(filename) or "")
+ datasets[tag] = {
+ data = data,
+ line = function(n) mppath(data[n or 1]) end,
+ size = function() mpsize(data) end,
+ }
+ end
+
+ table.setmetatablecall(datasets,function(t,k,f,...)
+ local d = datasets[k]
+ local t = type(d)
+ if t == "table" then
+ d = d[f]
+ if type(d) == "function" then
+ d(...)
+ else
+ mpvprint(...)
+ end
+ elseif t == "function" then
+ d(f,...)
+ end
+ end)
+
+end
+
+-- \startluacode
+-- local str = [[
+-- 10 20 20 20
+-- 30 40 40 60
+-- 50 10
+--
+-- 10 10 20 30
+-- 30 50 40 50
+-- 50 20 -- the last one
+--
+-- 10 20 % comment
+-- 20 10
+-- 30 40 # comment
+-- 40 20
+-- 50 10
+-- ]]
+--
+-- MP.myset = mp.dataset(str)
+--
+-- inspect(MP.myset)
+-- \stopluacode
+--
+-- \startMPpage
+-- color c[] ; c[1] := red ; c[2] := green ; c[3] := blue ;
+-- for i=1 upto lua("mp.print(mp.n(MP.myset))") :
+-- draw lua("mp.path(MP.myset[" & decimal i & "])") withcolor c[i] ;
+-- endfor ;
+-- \stopMPpage
+
+-- texts:
+
+do
+
+ local mptriplet = mp.triplet
+
+ local bpfactor = number.dimenfactors.bp
+ local textexts = nil
+ local mptriplet = mp.triplet
+ local nbdimensions = nodes.boxes.dimensions
+
+ function mp.mf_tt_initialize(tt)
+ textexts = tt
+ end
+
+ function mp.mf_tt_dimensions(n)
+ local box = textexts and textexts[n]
+ if box then
+ -- could be made faster with nuts but not critical
+ mptriplet(box.width*bpfactor,box.height*bpfactor,box.depth*bpfactor)
+ else
+ mptriplet(0,0,0)
+ end
+ end
+
+ function mp.mf_tb_dimensions(category,name)
+ local w, h, d = nbdimensions(category,name)
+ mptriplet(w*bpfactor,h*bpfactor,d*bpfactor)
+ end
+
+ function mp.report(a,b,c,...)
+ if c then
+ report_message("%s : %s",a,formatters[(gsub(b,"@","%%"))](c,...))
+ elseif b then
+ report_message("%s : %s",a,b)
+ elseif a then
+ report_message("%s : %s","message",a)
+ end
+ end
+
+end
+
+do
+
+ local mpprint = aux.print
+ local modes = tex.modes
+ local systemmodes = tex.systemmodes
+
+ function mp.mode(s)
+ mpprint(modes[s] and true or false)
+ end
+
+ function mp.systemmode(s)
+ mpprint(systemmodes[s] and true or false)
+ end
+
+ mp.processingmode = mp.mode
+
+end
+
+-- for alan's nodes:
+
+do
+
+ local mpprint = aux.print
+ local mpquoted = aux.quoted
+
+ function mp.isarray(str)
+ mpprint(find(str,"%d") and true or false)
+ end
+
+ function mp.prefix(str)
+ mpquoted(match(str,"^(.-)[%d%[]") or str)
+ end
+
+ -- function mp.dimension(str)
+ -- local n = 0
+ -- for s in gmatch(str,"%[?%-?%d+%]?") do --todo: lpeg
+ -- n = n + 1
+ -- end
+ -- mpprint(n)
+ -- end
+
+ mp.dimension = lpeg.counter(P("[") * lpegpatterns.integer * P("]") + lpegpatterns.integer,mpprint)
+
+ -- faster and okay as we don't have many variables but probably only
+ -- basename makes sense and even then it's not called that often
+
+ -- local hash = table.setmetatableindex(function(t,k)
+ -- local v = find(k,"%d") and true or false
+ -- t[k] = v
+ -- return v
+ -- end)
+ --
+ -- function mp.isarray(str)
+ -- mpprint(hash[str])
+ -- end
+ --
+ -- local hash = table.setmetatableindex(function(t,k)
+ -- local v = '"' .. (match(k,"^(.-)%d") or k) .. '"'
+ -- t[k] = v
+ -- return v
+ -- end)
+ --
+ -- function mp.prefix(str)
+ -- mpprint(hash[str])
+ -- end
+
+end
+
+do
+
+ local scanstring = scan.string
+ local scannumeric = scan.numeric
+ local skiptoken = skip.token
+
+ local injectstring = inject.string
+ local injectnumeric = inject.numeric
+
+ local registerscript = metapost.registerscript
+
+ local comma_code = metapost.codes.comma
+
+ local getmacro = tokens.getters.macro
+ local setmacro = tokens.setters.macro
+
+ local getdimen = tex.getdimen
+ local getcount = tex.getcount
+ local gettoks = tex.gettoks
+ local setdimen = tex.setdimen
+ local setcount = tex.setcount
+ local settoks = tex.settoks
+
+ local bpfactor = number.dimenfactors.bp
+
+ -- more helpers
+
+ registerscript("getmacro", function() injectstring (getmacro(scanstring())) end)
+ registerscript("getdimen", function() injectnumeric(getdimen(scanstring())*bpfactor) end)
+ registerscript("getcount", function() injectnumeric(getcount(scanstring())) end)
+ registerscript("gettoks", function() injectstring (gettoks (scanstring())) end)
+
+ registerscript("setmacro", function() setmacro(scanstring(),scanstring()) end)
+ registerscript("setdimen", function() setdimen(scanstring(),scannumeric()/bpfactor) end)
+ registerscript("setcount", function() setcount(scanstring(),scannumeric()) end)
+ registerscript("settoks", function() settoks (scanstring(),scanstring()) end)
+
+ registerscript("setglobalmacro", function() setmacro(scanstring(),scanstring(),"global") end)
+ registerscript("setglobaldimen", function() setdimen("global",scanstring(),scannumeric()/bpfactor) end)
+ registerscript("setglobalcount", function() setcount("global",scanstring(),scannumeric()) end)
+ registerscript("setglobaltoks", function() settoks ("global",scanstring(),scanstring()) end)
+
+
+ local utfnum = utf.byte
+ local utflen = utf.len
+ local utfsub = utf.sub
+
+ registerscript("utfnum", function()
+ injectnumeric(utfnum(scanstring()))
+ end)
+
+ registerscript("utflen", function()
+ injectnumeric(utflen(scanstring()))
+ end)
+
+ registerscript("utfsub", function() -- we have an optional third argument so we explicitly scan a text argument
+ injectstring(utfsub(scanstring(),skiptoken(comma_code) and scannumeric(),skiptoken(comma_code) and scannumeric()))
+ end)
+
+end
+
+-- position fun
+
+do
+
+ local mpprint = mp.print
+ local mpfprint = mp.fprint
+ local mpquoted = mp.quoted
+ local jobpositions = job.positions
+ local getwhd = jobpositions.whd
+ local getxy = jobpositions.xy
+ local getposition = jobpositions.position
+ local getpage = jobpositions.page
+ local getregion = jobpositions.region
+ local getmacro = tokens.getters.macro
+
+ function mp.positionpath(name)
+ local w, h, d = getwhd(name)
+ if w then
+ mpfprint("((%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle)",0,-d,w,-d,w,h,0,h)
+ else
+ mpprint("(origin--cycle)")
+ end
+ end
+
+ function mp.positioncurve(name)
+ local w, h, d = getwhd(name)
+ if w then
+ mpfprint("((%p,%p)..(%p,%p)..(%p,%p)..(%p,%p)..cycle)",0,-d,w,-d,w,h,0,h)
+ else
+ mpprint("(origin--cycle)")
+ end
+ end
+
+ function mp.positionbox(name)
+ local p, x, y, w, h, d = getposition(name)
+ if p then
+ mpfprint("((%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle)",x,y-d,x+w,y-d,x+w,y+h,x,y+h)
+ else
+ mpprint("(%p,%p)",x,y)
+ end
+ end
+
+ function mp.positionxy(name)
+ local x, y = getxy(name)
+ if x then
+ mpfprint("(%p,%p)",x,y)
+ else
+ mpprint("origin")
+ end
+ end
+
+ function mp.positionpage(name)
+ mpfprint("%i",getpage(name) or 0)
+ end
+
+ function mp.positionregion(name)
+ local r = getregion(name)
+ if r then
+ mpquoted(r)
+ else
+ mpquoted("unknown")
+ end
+ end
+
+ function mp.positionwhd(name)
+ local w, h, d = getwhd(name)
+ if w then
+ mpfprint("(%p,%p,%p)",w,h,d)
+ else
+ mpprint("(0,0,0)")
+ end
+ end
+
+ function mp.positionpxy(name)
+ local p, x, y = getposition(name)
+ if p then
+ mpfprint("(%p,%p,%p)",p,x,y)
+ else
+ mpprint("(0,0,0)")
+ end
+ end
+
+ function mp.positionanchor()
+ mpquoted(getmacro("MPanchorid"))
+ end
+
+end
+
+do
+
+ -- local mppair = mp.pair
+ --
+ -- function mp.textextanchor(s)
+ -- local x, y = match(s,"tx_anchor=(%S+) (%S+)") -- todo: make an lpeg
+ -- if x and y then
+ -- x = tonumber(x)
+ -- y = tonumber(y)
+ -- end
+ -- mppair(x or 0,y or 0)
+ -- end
+
+ local injectpair = inject.pair
+ local scanstring = scan.string
+
+ metapost.registerscript("textextanchor", function()
+ local x, y = match(scanstring(),"tx_anchor=(%S+) (%S+)") -- todo: make an lpeg
+ if x and y then
+ x = tonumber(x)
+ y = tonumber(y)
+ end
+ injectpair(x or 0,y or 0)
+ end)
+
+end
+
+do
+
+ local mpprint = mp.print
+ local mpquoted = mp.quoted
+ local getmacro = tokens.getters.macro
+
+ function mp.texvar(name)
+ mpprint(getmacro(metapost.namespace .. name))
+ end
+
+ function mp.texstr(name)
+ mpquoted(getmacro(metapost.namespace .. name))
+ end
+
+end
+
+do
+
+ local mpprint = aux.print
+ local mpvprint = aux.vprint
+
+ local hashes = { }
+
+ function mp.newhash(name)
+ if name then
+ hashes[name] = { }
+ else
+ for i=1,#hashes+1 do
+ if not hashes[i] then
+ hashes[i] = { }
+ mpvprint(i)
+ return
+ end
+ end
+ end
+ end
+
+ function mp.disposehash(n)
+ if tonumber(n) then
+ hashes[n] = false
+ else
+ hashes[n] = nil
+ end
+ end
+
+ function mp.inhash(n,key)
+ local h = hashes[n]
+ mpvprint(h and h[key] and true or false)
+ end
+
+ function mp.tohash(n,key,value)
+ local h = hashes[n]
+ if h then
+ if value == nil then
+ h[key] = true
+ else
+ h[key] = value
+ end
+ end
+ end
+
+ function mp.fromhash(n,key)
+ local h = hashes[n]
+ mpvprint(h and h[key] or false)
+ end
+
+ interfaces.implement {
+ name = "MPfromhash",
+ arguments = "2 strings",
+ actions = function(name,key)
+ local h = hashes[name] or hashes[tonumber(name)]
+ if h then
+ local v = h[key] or h[tonumber(key)]
+ if v then
+ context(v)
+ end
+ end
+ end
+ }
+
+end
+
+do
+
+ -- a bit overkill: just a find(str,"mf_object=") can be enough
+ --
+ -- todo : share with mlib-pps.lua metapost,isobject
+
+ local mpboolean = aux.boolean
+
+ local p1 = P("mf_object=")
+ local p2 = lpegpatterns.eol * p1
+ local pattern = (1-p2)^0 * p2 + p1
+
+ function mp.isobject(str)
+ mpboolean(pattern and str ~= "" and lpegmatch(pattern,str))
+ end
+
+end
+
+function mp.flatten(t)
+ local tn = #t
+
+ local t1 = t[1]
+ local t2 = t[2]
+ local t3 = t[3]
+ local t4 = t[4]
+
+ for i=1,tn-5,2 do
+ local t5 = t[i+4]
+ local t6 = t[i+5]
+ if t1 == t3 and t3 == t5 and ((t2 <= t4 and t4 <= t6) or (t6 <= t4 and t4 <= t2)) then
+ t[i+3] = t2
+ t4 = t2
+ t[i] = false
+ t[i+1] = false
+ elseif t2 == t4 and t4 == t6 and ((t1 <= t3 and t3 <= t5) or (t5 <= t3 and t3 <= t1)) then
+ t[i+2] = t1
+ t3 = t1
+ t[i] = false
+ t[i+1] = false
+ end
+ t1 = t3
+ t2 = t4
+ t3 = t5
+ t4 = t6
+ end
+
+ -- remove duplicates
+
+ local t1 = t[1]
+ local t2 = t[2]
+ for i=1,tn-2,2 do
+ local t3 = t[i+2]
+ local t4 = t[i+3]
+ if t1 == t3 and t2 == t4 then
+ t[i] = false
+ t[i+1] = false
+ end
+ t1 = t3
+ t2 = t4
+ end
+
+ -- move coordinates
+
+ local m = 0
+ for i=1,tn,2 do
+ if t[i] then
+ m = m + 1 t[m] = t[i]
+ m = m + 1 t[m] = t[i+1]
+ end
+ end
+
+ -- prune the table (not gc'd)
+
+ for i=tn,m+1,-1 do
+ t[i] = nil
+ end
+
+ -- safeguard so that we have at least one segment
+
+ if m == 2 then
+ t[3] = t[1]
+ t[4] = t[2]
+ end
+
+end
+
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-pdf.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-pdf.lmt
new file mode 100644
index 00000000000..c383d52ded1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-pdf.lmt
@@ -0,0 +1,742 @@
+if not modules then modules = { } end modules ['mlib-pdf'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local gsub = string.gsub
+local concat, insert, remove = table.concat, table.insert, table.remove
+local abs, sqrt, round = math.abs, math.sqrt, math.round
+local setmetatable, rawset, tostring, tonumber, type = setmetatable, rawset, tostring, tonumber, type
+local P, S, C, Ct, Cc, Cg, Cf, Carg = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.Carg
+local lpegmatch = lpeg.match
+local formatters = string.formatters
+
+local report_metapost = logs.reporter("metapost")
+
+local trace_variables = false trackers.register("metapost.variables",function(v) trace_variables = v end)
+
+local mplib = mplib
+local context = context
+
+local allocate = utilities.storage.allocate
+
+local copy_node = node.copy
+local write_node = node.write
+
+local pen_info = mplib.pen_info
+local getfields = mplib.getfields or mplib.fields -- todo: in lmtx get them once and then use gettype
+
+local save_table = false
+local force_stroke = false
+
+metapost = metapost or { }
+local metapost = metapost
+
+metapost.flushers = metapost.flushers or { }
+local pdfflusher = { }
+metapost.flushers.pdf = pdfflusher
+
+metapost.n = 0
+
+local mpsliteral = nodes.pool.originliteral
+
+local f_f = formatters["%.6N"]
+local f_m = formatters["%.6N %.6N m"]
+local f_c = formatters["%.6N %.6N %.6N %.6N %.6N %.6N c"]
+local f_l = formatters["%.6N %.6N l"]
+local f_cm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"]
+local f_M = formatters["%.6N M"]
+local f_j = formatters["%i j"]
+local f_J = formatters["%i J"]
+local f_d = formatters["[%s] %.6N d"]
+local f_w = formatters["%.6N w"]
+
+directives.register("metapost.savetable",function(v)
+ if type(v) == "string" then
+ save_table = file.addsuffix(v,"mpl")
+ elseif v then
+ save_table = file.addsuffix(environment.jobname .. "-graphic","mpl")
+ else
+ save_table = false
+ end
+end)
+
+trackers.register("metapost.forcestroke",function(v)
+ force_stroke = v
+end)
+
+-- Because in MKiV we always have two passes, we save the objects. When an extra
+-- mp run is done (due to for instance texts identifier in the parse pass), we
+-- get a new result table and the stored objects are forgotten. Otherwise they
+-- are reused.
+
+local function getobjects(result,figure,index)
+ return figure:objects()
+end
+
+function metapost.convert(specification,result)
+ local flusher = specification.flusher
+ local askedfig = specification.askedfig
+ if save_table then
+ table.save(save_table,metapost.totable(result,1)) -- direct
+ end
+ metapost.flush(specification,result)
+ return true -- done
+end
+
+function pdfflusher.tocomment(message)
+ if message then
+ return formatters["%% mps graphic %s: %s"](metapost.n,message)
+ else
+ return formatters["%% mps graphic %s"](metapost.n)
+ end
+end
+
+function pdfflusher.startfigure(n,llx,lly,urx,ury,message)
+ metapost.n = metapost.n + 1
+ context.startMPLIBtoPDF(f_f(llx),f_f(lly),f_f(urx),f_f(ury))
+end
+
+function pdfflusher.stopfigure(message)
+ context.stopMPLIBtoPDF()
+end
+
+function pdfflusher.flushfigure(pdfliterals) -- table
+ if #pdfliterals > 0 then
+ pdfliterals = concat(pdfliterals,"\n")
+ context(mpsliteral(pdfliterals))
+ end
+end
+
+function pdfflusher.textfigure(font,size,text,width,height,depth) -- we could save the factor
+ text = gsub(text,".","\\hbox{%1}") -- kerning happens in metapost (i have to check if this is true for mplib)
+ context.MPtextext(font,size,text,0,-number.dimenfactors.bp*depth)
+end
+
+local bend_tolerance = 131/65536
+
+local rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1
+
+local function pen_characteristics(object)
+ local t = pen_info(object)
+ rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty
+ divider = sx*sy - rx*ry
+ return not (sx == 1 and rx == 0 and ry == 0 and sy == 1 and tx == 0 and ty == 0), t.width
+end
+
+local function mpconcat(px, py) -- no tx, ty here / we can move this one inline if needed
+ return (sy*px-ry*py)/divider,(sx*py-rx*px)/divider
+end
+
+local function curved(ith,pth)
+ local d = pth.left_x - ith.right_x
+ if abs(ith.right_x - ith.x_coord - d) <= bend_tolerance and abs(pth.x_coord - pth.left_x - d) <= bend_tolerance then
+ d = pth.left_y - ith.right_y
+ if abs(ith.right_y - ith.y_coord - d) <= bend_tolerance and abs(pth.y_coord - pth.left_y - d) <= bend_tolerance then
+ return false
+ end
+ end
+ return true
+end
+
+local function flushnormalpath(path, t, open)
+ local pth, ith, nt
+ local length = #path
+ if t then
+ nt = #t
+ else
+ t = { }
+ nt = 0
+ end
+ for i=1,length do
+ nt = nt + 1
+ pth = path[i]
+ if not ith then
+ t[nt] = f_m(pth.x_coord,pth.y_coord)
+-- elseif curved(ith,pth) then
+elseif pth.curved then
+ t[nt] = f_c(ith.right_x,ith.right_y,pth.left_x,pth.left_y,pth.x_coord,pth.y_coord)
+ else
+ t[nt] = f_l(pth.x_coord,pth.y_coord)
+ end
+ ith = pth
+ end
+ if not open then
+ nt = nt + 1
+ local one = path[1]
+-- if curved(pth,one) then
+if one.curved then
+ t[nt] = f_c(pth.right_x,pth.right_y,one.left_x,one.left_y,one.x_coord,one.y_coord)
+ else
+ t[nt] = f_l(one.x_coord,one.y_coord)
+ end
+ elseif length == 1 then
+ -- special case .. draw point
+ local one = path[1]
+ nt = nt + 1
+ t[nt] = f_l(one.x_coord,one.y_coord)
+ end
+ return t
+end
+
+local function flushconcatpath(path, t, open)
+ local pth, ith, nt
+ local length = #path
+ if t then
+ nt = #t
+ else
+ t = { }
+ nt = 0
+ end
+ nt = nt + 1
+ t[nt] = f_cm(sx,rx,ry,sy,tx,ty)
+ for i=1,length do
+ nt = nt + 1
+ pth = path[i]
+ if not ith then
+ t[nt] = f_m(mpconcat(pth.x_coord,pth.y_coord))
+-- elseif curved(ith,pth) then
+elseif pth.curved then
+ local a, b = mpconcat(ith.right_x,ith.right_y)
+ local c, d = mpconcat(pth.left_x,pth.left_y)
+ t[nt] = f_c(a,b,c,d,mpconcat(pth.x_coord,pth.y_coord))
+ else
+ t[nt] = f_l(mpconcat(pth.x_coord, pth.y_coord))
+ end
+ ith = pth
+ end
+ if not open then
+ nt = nt + 1
+ local one = path[1]
+-- if curved(pth,one) then
+if one.curved then
+ local a, b = mpconcat(pth.right_x,pth.right_y)
+ local c, d = mpconcat(one.left_x,one.left_y)
+ t[nt] = f_c(a,b,c,d,mpconcat(one.x_coord, one.y_coord))
+ else
+ t[nt] = f_l(mpconcat(one.x_coord,one.y_coord))
+ end
+ elseif length == 1 then
+ -- special case .. draw point
+ nt = nt + 1
+ local one = path[1]
+ t[nt] = f_l(mpconcat(one.x_coord,one.y_coord))
+ end
+ return t
+end
+
+local function toboundingbox(path)
+ local size = #path
+ if size == 4 then
+ local pth = path[1]
+ local x = pth.x_coord
+ local y = pth.y_coord
+ local llx, lly, urx, ury = x, y, x, y
+ for i=2,size do
+ pth = path[i]
+ x = pth.x_coord
+ y = pth.y_coord
+ if x < llx then
+ llx = x
+ elseif x > urx then
+ urx = x
+ end
+ if y < lly then
+ lly = y
+ elseif y > ury then
+ ury = y
+ end
+ end
+ return { llx, lly, urx, ury }
+ else
+ return { 0, 0, 0, 0 }
+ end
+end
+
+metapost.flushnormalpath = flushnormalpath
+
+-- The flusher is pdf based, if another backend is used, we need to overload the
+-- flusher; this is beta code, the organization will change (already upgraded in
+-- sync with mplib)
+--
+-- We can avoid the before table but I like symmetry. There is of course a small
+-- performance penalty, but so is passing extra arguments (result, flusher, after)
+-- and returning stuff.
+--
+-- This variable stuff will change in lmtx.
+
+local ignore = function() end
+
+local space = P(" ")
+local equal = P("=")
+local key = C((1-equal)^1) * equal
+local newline = S("\n\r")^1
+local number = (((1-space-newline)^1) / tonumber) * (space^0)
+
+local p_number = number
+local p_string = C((1-newline)^0)
+local p_boolean = P("false") * Cc(false) + P("true") * Cc(true)
+local p_set = Ct(number^1)
+local p_path = Ct(Ct(number * number^-5)^1)
+
+local variable =
+ P("1:") * p_number
+ + P("2:") * p_string
+ + P("3:") * p_boolean
+ + S("4568") * P(":") * p_set
+ + P("7:") * p_path
+
+local pattern_tab = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset)
+
+local variable =
+ P("1:") * p_number
+ + P("2:") * p_string
+ + P("3:") * p_boolean
+ + S("4568") * P(":") * number^1
+ + P("7:") * (number * number^-5)^1
+
+local pattern_lst = (variable * newline^0)^0
+
+metapost.variables = { } -- currently across instances
+metapost.properties = { } -- to be stacked
+
+function metapost.untagvariable(str,variables) -- will be redone
+ if variables == false then
+ return lpegmatch(pattern_lst,str)
+ else
+ return lpegmatch(pattern_tab,str,1,variables or { })
+ end
+end
+
+-- function metapost.processspecial(str)
+-- lpegmatch(pattern_key,object.prescript,1,variables)
+-- end
+
+-- function metapost.processspecial(str)
+-- local code = loadstring(str)
+-- if code then
+-- if trace_variables then
+-- report_metapost("executing special code: %s",str)
+-- end
+-- code()
+-- else
+-- report_metapost("invalid special code: %s",str)
+-- end
+-- end
+
+local stack = { }
+
+local function pushproperties(figure)
+ -- maybe there will be getters in lmtx
+ local boundingbox = figure:boundingbox()
+ local slot = figure:charcode() or 0
+ local properties = {
+ llx = boundingbox[1],
+ lly = boundingbox[2],
+ urx = boundingbox[3],
+ ury = boundingbox[4],
+ slot = slot,
+ width = figure:width(),
+ height = figure:height(),
+ depth = figure:depth(),
+ italic = figure:italcorr(), -- figure:italic() in lmtx
+ number = slot,
+ }
+ insert(stack,properties)
+ metapost.properties = properties
+ return properties
+end
+
+local function popproperties()
+ metapost.properties = remove(stack)
+end
+
+function metapost.flush(specification,result)
+ if result then
+ local flusher = specification.flusher
+ local askedfig = specification.askedfig
+ local incontext = specification.incontext
+ local figures = result.fig
+ if figures then
+ flusher = flusher or pdfflusher
+ local resetplugins = metapost.resetplugins or ignore -- before figure
+ local processplugins = metapost.processplugins or ignore -- each object
+ local synchronizeplugins = metapost.synchronizeplugins or ignore
+ local pluginactions = metapost.pluginactions or ignore -- before / after
+ local startfigure = flusher.startfigure
+ local stopfigure = flusher.stopfigure
+ local flushfigure = flusher.flushfigure
+ local textfigure = flusher.textfigure
+ -- local processspecial = flusher.processspecial or metapost.processspecial
+ local tocomment = flusher.tocomment
+ for index=1,#figures do
+ local figure = figures[index]
+ local properties = pushproperties(figure)
+ if askedfig == "direct" or askedfig == "all" or askedfig == properties.number then
+ local objects = getobjects(result,figure,index)
+ local result = { }
+ local miterlimit = -1
+ local linecap = -1
+ local linejoin = -1
+ local dashed = false
+ local linewidth = false
+ local llx = properties.llx
+ local lly = properties.lly
+ local urx = properties.urx
+ local ury = properties.ury
+ if urx < llx then
+ -- invalid
+ startfigure(properties.number,0,0,0,0,"invalid",figure)
+ if tocomment then
+ result[#result+1] = tocomment("invalid")
+ end
+ stopfigure()
+ else
+
+ -- we need to be indirect if we want the one-pass solution
+
+ local groupstack = { }
+
+ local function processfigure()
+ if tocomment then
+ result[#result+1] = tocomment("begin")
+ end
+ result[#result+1] = "q"
+ if objects then
+ -- resetplugins(result) -- we should move the colorinitializer here
+ local savedpath = nil
+ local savedhtap = nil
+ for o=1,#objects do
+ local object = objects[o]
+ local objecttype = object.type
+ if objecttype == "fill" or objecttype == "outline" then
+ -- we use an indirect table as we want to overload
+ -- entries but this is not possible in userdata
+ --
+ -- can be optimized if no path
+ --
+ local original = object
+ local object = { }
+ setmetatable(object, {
+ __index = original
+ })
+ local before,
+ after = processplugins(object)
+ local evenodd = false
+ local collect = false
+ local both = false
+ local flush = false
+ local postscript = object.postscript
+ if not object.istext then
+ if postscript == "evenodd" then
+ evenodd = true
+ elseif postscript == "collect" then
+ collect = true
+ elseif postscript == "flush" then
+ flush = true
+ elseif postscript == "both" then
+ both = true
+ elseif postscript == "eoboth" then
+ evenodd = true
+ both = true
+ end
+ end
+ --
+ if flush and not savedpath then
+ -- forget about it
+ elseif collect then
+ if not savedpath then
+ savedpath = { object.path or false }
+ savedhtap = { object.htap or false }
+ else
+ savedpath[#savedpath+1] = object.path or false
+ savedhtap[#savedhtap+1] = object.htap or false
+ end
+ else
+ local objecttype = object.type -- can have changed
+ if before then
+ result = pluginactions(before,result,flushfigure)
+ end
+ local ml = object.miterlimit
+ if ml and ml ~= miterlimit then
+ miterlimit = ml
+ result[#result+1] = f_M(ml)
+ end
+ local lj = object.linejoin
+ if lj and lj ~= linejoin then
+ linejoin = lj
+ result[#result+1] = f_j(lj)
+ end
+ local lc = object.linecap
+ if lc and lc ~= linecap then
+ linecap = lc
+ result[#result+1] = f_J(lc)
+ end
+ if both then
+ if dashed ~= false then -- was just dashed test
+ result[#result+1] = "[] 0 d"
+ dashed = false
+ end
+ else
+ local dl = object.dash
+ if dl then
+ local d = f_d(concat(dl.dashes or {}," "),dl.offset)
+ if d ~= dashed then
+ dashed = d
+ result[#result+1] = d
+ end
+ elseif dashed ~= false then -- was just dashed test
+ result[#result+1] = "[] 0 d"
+ dashed = false
+ end
+ end
+ local path = object.path -- newpath
+ local transformed = false
+ local penwidth = 1
+ local open = path and path[1].left_type and path[#path].right_type -- at this moment only "end_point"
+ local pen = object.pen
+ if pen then
+ if pen.type == "elliptical" then
+ transformed, penwidth = pen_characteristics(original) -- boolean, value
+ if penwidth ~= linewidth then
+ result[#result+1] = f_w(penwidth)
+ linewidth = penwidth
+ end
+ if objecttype == "fill" then
+ objecttype = "both"
+ end
+ else -- calculated by mplib itself
+ objecttype = "fill"
+ end
+ end
+ if transformed then
+ result[#result+1] = "q"
+ end
+ if path then
+ if savedpath then
+ for i=1,#savedpath do
+ local path = savedpath[i]
+ if transformed then
+ flushconcatpath(path,result,open)
+ else
+ flushnormalpath(path,result,open)
+ end
+ end
+ savedpath = nil
+ end
+ if flush then
+ -- ignore this path
+ elseif transformed then
+ flushconcatpath(path,result,open)
+ else
+ flushnormalpath(path,result,open)
+ end
+ if force_stroke then
+ result[#result+1] = open and "S" or "h S"
+ elseif objecttype == "fill" then
+ result[#result+1] = evenodd and "h f*" or "h f" -- f* = eo
+ elseif objecttype == "outline" then
+ if both then
+ result[#result+1] = evenodd and "h B*" or "h B" -- B* = eo
+ else
+ result[#result+1] = open and "S" or "h S"
+ end
+ elseif objecttype == "both" then
+ result[#result+1] = evenodd and "h B*" or "h B" -- B* = eo -- b includes closepath
+ end
+ end
+ if transformed then
+ result[#result+1] = "Q"
+ end
+ local path = object.htap
+ if path then
+ if transformed then
+ result[#result+1] = "q"
+ end
+ if savedhtap then
+ for i=1,#savedhtap do
+ local path = savedhtap[i]
+ if transformed then
+ flushconcatpath(path,result,open)
+ else
+ flushnormalpath(path,result,open)
+ end
+ end
+ savedhtap = nil
+ evenodd = true
+ end
+ if transformed then
+ flushconcatpath(path,result,open)
+ else
+ flushnormalpath(path,result,open)
+ end
+ if force_stroke then
+ result[#result+1] = open and "S" or "h S"
+ elseif objecttype == "fill" then
+ result[#result+1] = evenodd and "h f*" or "h f" -- f* = eo
+ elseif objecttype == "outline" then
+ result[#result+1] = open and "S" or "h S"
+ elseif objecttype == "both" then
+ result[#result+1] = evenodd and "h B*" or "h B" -- B* = eo -- b includes closepath
+ end
+ if transformed then
+ result[#result+1] = "Q"
+ end
+ end
+ if after then
+ result = pluginactions(after,result,flushfigure)
+ end
+ end
+ if object.grouped then
+ -- can be qQ'd so changes can end up in groups
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
+ end
+ elseif objecttype == "start_clip" then
+ local evenodd = not object.istext and object.postscript == "evenodd"
+ result[#result+1] = "q"
+ flushnormalpath(object.path,result,false)
+ result[#result+1] = evenodd and "W* n" or "W n"
+ elseif objecttype == "stop_clip" then
+ result[#result+1] = "Q"
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
+ elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
+ -- skip
+ elseif objecttype == "start_group" then
+ if lpdf.flushgroup then
+ local before, after = processplugins(object)
+ if before then
+ result[#result+1] = "q"
+ result = pluginactions(before,result,flushfigure)
+ insert(groupstack, {
+ after = after,
+ result = result,
+ bbox = toboundingbox(object.path),
+ })
+ result = { }
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
+ else
+ insert(groupstack,false)
+ end
+ else
+ insert(groupstack,false)
+ end
+ elseif objecttype == "stop_group" then
+ local data = remove(groupstack)
+ if data then
+ local reference = lpdf.flushgroup(concat(result,"\r"),data.bbox)
+ result = data.result
+ result[#result+1] = reference
+ result = pluginactions(data.after,result,flushfigure)
+ result[#result+1] = "Q"
+ miterlimit, linecap, linejoin, dashed, linewidth = -1, -1, -1, "", false
+ end
+ -- if objecttype == "text" then
+ -- result[#result+1] = "q"
+ -- local ot = object.transform -- 3,4,5,6,1,2
+ -- result[#result+1] = f_cm(ot[3],ot[4],ot[5],ot[6],ot[1],ot[2])
+ -- flushfigure(result) -- flush accumulated literals
+ -- result = { }
+ -- textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth)
+ -- result[#result+1] = "Q"
+ -- elseif objecttype == "special" then
+ -- if processspecial then
+ -- processspecial(object.prescript)
+ -- end
+ -- else
+ else
+ -- error
+ end
+ end
+ end
+ result[#result+1] = "Q"
+ if tocomment then
+ result[#result+1] = tocomment("end")
+ end
+ flushfigure(result)
+ end
+ startfigure(properties.number,llx,lly,urx,ury,"begin",figure)
+ if incontext then
+ context(function() processfigure() end)
+ else
+ processfigure()
+ end
+ stopfigure("end")
+ end
+ if askedfig ~= "all" then
+ break
+ end
+ end
+ popproperties()
+ end
+ resetplugins(result) -- we should move the colorinitializer here
+ end
+ end
+end
+
+-- tracing:
+
+do
+
+ local result = { }
+
+ local flusher = {
+ startfigure = function()
+ result = { }
+ context.startnointerference()
+ end,
+ flushfigure = function(literals)
+ local n = #result
+ for i=1,#literals do
+ result[n+i] = literals[i]
+ end
+ end,
+ stopfigure = function()
+ context.stopnointerference()
+ end
+ }
+
+ local specification = {
+ flusher = flusher,
+ -- incontext = true,
+ }
+
+ function metapost.pdfliterals(result)
+ metapost.flush(specification,result)
+ return result
+ end
+
+end
+
+function metapost.totable(result,askedfig)
+ local askedfig = askedfig or 1
+ local figure = result and result.fig and result.fig[1]
+ if figure then
+ local results = { }
+ local objects = getobjects(result,figure,askedfig)
+ for o=1,#objects do
+ local object = objects[o]
+ local result = { }
+ local fields = getfields(object) -- hm, is this the whole list, if so, we can get it once
+ for f=1,#fields do
+ local field = fields[f]
+ result[field] = object[field]
+ end
+ results[o] = result
+ end
+ local boundingbox = figure:boundingbox()
+ return {
+ boundingbox = {
+ llx = boundingbox[1],
+ lly = boundingbox[2],
+ urx = boundingbox[3],
+ ury = boundingbox[4],
+ },
+ objects = results
+ }
+ else
+ return nil
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-pdf.mkxl b/Master/texmf-dist/tex/context/base/mkxl/mlib-pdf.mkxl
new file mode 100644
index 00000000000..6ded235145c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-pdf.mkxl
@@ -0,0 +1,157 @@
+%D \module
+%D [ file=mlib-pdf,
+%D version=2008.03.25,
+%D title=\METAPOST\ Integrated Graphics,
+%D subtitle=Conversion to PDF,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+%D We use bit more code that needed because we want to limit the amount of boxing.
+
+\registerctxluafile{mlib-pdf}{autosuffix}
+
+%D Some code is shared between MPLIB and MPS. The following variables are also
+%D available for introspection and other purposes.
+
+\ifdefined\MPwidth \else \newdimen\MPwidth \fi
+\ifdefined\MPheight \else \newdimen\MPheight \fi
+
+\ifdefined\MPllx \else \newdimen\MPllx \fi
+\ifdefined\MPlly \else \newdimen\MPlly \fi
+\ifdefined\MPurx \else \newdimen\MPurx \fi
+\ifdefined\MPury \else \newdimen\MPury \fi
+
+\ifdefined\MPbox \else \newbox \MPbox \fi
+
+\permanent\protected\def\setMPboundingbox#1#2#3#4% at some point we might pass them as base or scaled points
+ {\global\MPllx #1\onebasepoint
+ \global\MPlly #2\onebasepoint
+ \global\MPurx #3\onebasepoint
+ \global\MPury #4\onebasepoint
+ \global\MPwidth \dimexpr\MPurx-\MPllx\relax
+ \global\MPheight\dimexpr\MPury-\MPlly\relax}
+
+\permanent\protected\def\resetMPboundingbox
+ {\global\MPwidth \zeropoint
+ \global\MPheight\zeropoint
+ \global\MPllx \zeropoint
+ \global\MPlly \zeropoint
+ \global\MPurx \zeropoint
+ \global\MPury \zeropoint}
+
+\aliased\let\popMPboundingbox\relax
+
+\permanent\protected\def\pushMPboundingbox
+ {\enforced\permanent\protected\edef\popMPboundingbox
+ {\global\MPwidth \the\MPwidth
+ \global\MPheight\the\MPheight
+ \global\MPllx \the\MPllx
+ \global\MPlly \the\MPlly
+ \global\MPurx \the\MPurx
+ \global\MPury \the\MPury
+ \relax}}
+
+% we need to combine these
+
+\permanent\protected\def\repositionMPboxindeed
+ {\setbox\MPbox\hpack\bgroup
+ \kern-\MPllx
+ \raise-\MPlly
+ \box\MPbox
+ \egroup}
+
+\permanent\protected\def\repositionMPbox
+ {\ifzeropt\MPllx
+ \ifzeropt\MPlly
+ % okay
+ \else
+ \repositionMPboxindeed
+ \fi
+ \else
+ \repositionMPboxindeed
+ \fi}
+
+% combined
+
+\permanent\protected\def\finalizeMPbox
+ {\boxxoffset\MPbox-\MPllx\relax
+ \boxyoffset\MPbox\dimexpr\boxyoffset\MPbox-\MPheight-\MPlly\relax
+ \wd\MPbox\MPwidth
+ \ht\MPbox\MPheight}
+
+% MPLIB specific:
+
+\permanent\protected\def\startMPLIBtoPDF#1#2#3#4%
+ {\meta_process_graphic_figure_start
+ \dostarttagged\t!mpgraphic\empty
+ \naturalhpack attr \imageattribute \plusone \bgroup
+ \dousecolorparameter\s!black\forcecolorhack
+ \setMPboundingbox{#1}{#2}{#3}{#4}%
+ \setbox\MPbox\vpack\bgroup
+ % \forgetall % already done elsewhere
+ \noindent} % forces the proper cm in the backend
+
+\permanent\protected\def\stopMPLIBtoPDF
+ {\egroup
+ \finalizeMPbox
+ \box\MPbox
+ \egroup
+ \dostoptagged
+ \meta_process_graphic_figure_stop}
+
+%D Kind of special:
+%
+% test.mp:
+%
+% beginfig(1) fill fullcircle scaled 10cm withcolor red ; endfig ;
+% beginfig(2) draw fullcircle scaled 5cm withcolor blue ; endfig ;
+% beginfig(3) draw textext("just some text") ; endfig ;
+%
+% standalone pages:
+%
+% \starttext
+% \directMPgraphic{input "test.mp" ;}
+% \stoptext
+
+\aliased\let\normalstartMPLIBtoPDF\startMPLIBtoPDF
+\aliased\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF
+
+\permanent\protected\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF}
+\permanent\protected\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage}
+
+% can become \permanent\protected\def\directMPgraphic#=#*#=% but best test first
+
+\permanent\protected\def\directMPgraphic
+ {\dodoublegroupempty\mlib_direct_graphic}
+
+\def\mlib_direct_graphic#1#2% makes pages (todo: make boxes)
+ {\meta_begin_graphic_group{#1}%
+ \enforced\let\startMPLIBtoPDF\directstartMPLIBtoPDF
+ \enforced\let\stopMPLIBtoPDF \directstopMPLIBtoPDF
+ \meta_start_current_graphic
+ \forgetall
+ \edef\p_extensions{\MPinstanceparameter\s!extensions}%
+ \normalexpanded{\noexpand\clf_mpgraphic
+ instance {\currentMPinstance}%
+ format {\currentMPformat}%
+ data {#2;}%
+ initializations {\meta_flush_current_initializations}%
+ \ifx\p_extensions\v!yes
+ extensions {\clf_getmpextensions{\currentMPinstance}}%
+ \fi
+ inclusions {\meta_flush_current_inclusions}%
+ definitions {\meta_flush_current_definitions}%
+ figure {all}%
+ method {\MPinstanceparameter\c!method}%
+ \relax}%
+ \meta_stop_current_graphic
+ \meta_end_graphic_group}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-pps.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-pps.lmt
new file mode 100644
index 00000000000..32f23c39d27
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-pps.lmt
@@ -0,0 +1,1647 @@
+if not modules then modules = { } end modules ['mlib-pps'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local format, gmatch, match, split, gsub = string.format, string.gmatch, string.match, string.split, string.gsub
+local tonumber, type, unpack, next, select = tonumber, type, unpack, next, select
+local round, sqrt, min, max = math.round, math.sqrt, math.min, math.max
+local insert, remove, concat = table.insert, table.remove, table.concat
+local Cs, Cf, C, Cg, Ct, P, S, V, Carg = lpeg.Cs, lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V, lpeg.Carg
+local lpegmatch, tsplitat, tsplitter = lpeg.match, lpeg.tsplitat, lpeg.tsplitter
+local formatters = string.formatters
+local exists, savedata = io.exists, io.savedata
+
+local mplib = mplib
+local metapost = metapost
+local lpdf = lpdf
+local context = context
+
+local scan = mp.scan
+local inject = mp.inject
+
+local mpscanstring = scan.string
+local mpscannumeric = scan.numeric
+
+local injecttriplet = inject.triplet
+
+local registerscript = metapost.registerscript
+
+local implement = interfaces.implement
+local setmacro = interfaces.setmacro
+
+local texsetbox = tex.setbox
+local textakebox = tex.takebox -- or: nodes.takebox
+local texrunlocal = tex.runlocal
+local copy_list = node.copy_list
+local flush_list = node.flush_list
+local setmetatableindex = table.setmetatableindex
+local sortedhash = table.sortedhash
+
+local new_hlist = nodes.pool.hlist
+
+local starttiming = statistics.starttiming
+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")
+local report_scripts = logs.reporter("metapost","scripts")
+
+local colors = attributes.colors
+local defineprocesscolor = colors.defineprocesscolor
+local definespotcolor = colors.definespotcolor
+local definemultitonecolor = colors.definemultitonecolor
+local colorvalue = colors.value
+
+local transparencies = attributes.transparencies
+local registertransparency = transparencies.register
+local transparencyvalue = transparencies.value
+
+local rgbtocmyk = colors.rgbtocmyk -- or function() return 0,0,0,1 end
+local cmyktorgb = colors.cmyktorgb -- or function() return 0,0,0 end
+local rgbtogray = colors.rgbtogray -- or function() return 0 end
+local cmyktogray = colors.cmyktogray -- or function() return 0 end
+
+local nooutercolor = "0 g 0 G"
+local nooutertransparency = "/Tr0 gs" -- only when set
+local outercolormode = 0
+local outercolormodel = 1
+local outercolor = nooutercolor
+local outertransparency = nooutertransparency
+local innercolor = nooutercolor
+local innertransparency = nooutertransparency
+
+local pdfcolor = lpdf.color
+local pdftransparency = lpdf.transparency
+
+function metapost.setoutercolor(mode,colormodel,colorattribute,transparencyattribute)
+ -- has always to be called before conversion
+ -- todo: transparency (not in the mood now)
+ outercolormode = mode
+ outercolormodel = colormodel
+ if mode == 1 or mode == 3 then
+ -- inherit from outer (registered color)
+ outercolor = pdfcolor(colormodel,colorattribute) or nooutercolor
+ outertransparency = pdftransparency(transparencyattribute) or nooutertransparency
+ elseif mode == 2 then
+ -- stand alone (see m-punk.tex)
+ outercolor = ""
+ outertransparency = ""
+ else -- 0
+ outercolor = nooutercolor
+ outertransparency = nooutertransparency
+ end
+ innercolor = outercolor
+ innertransparency = outertransparency -- not yet used
+end
+
+-- todo: get this from the lpdf module
+
+local f_f = formatters["%.6N"]
+local f_f3 = formatters["%.3N"]
+local f_gray = formatters["%.3N g %.3N G"]
+local f_rgb = formatters["%.3N %.3N %.3N rg %.3N %.3N %.3N RG"]
+local f_cmyk = formatters["%.3N %.3N %.3N %.3N k %.3N %.3N %.3N %.3N K"]
+local f_cm_b = formatters["q %.6N %.6N %.6N %.6N %.6N %.6N cm"]
+local f_scn = formatters["%.3N"]
+
+local f_shade = formatters["MpSh%s"]
+local f_spot = formatters["/%s cs /%s CS %s SCN %s scn"]
+local s_cm_e = "Q"
+
+local function checked_color_pair(color,...)
+ if not color then
+ return innercolor, outercolor
+ end
+ if outercolormode == 3 then
+ innercolor = color(...)
+ return innercolor, innercolor
+ else
+ return color(...), outercolor
+ end
+end
+
+function metapost.colorinitializer()
+ innercolor = outercolor
+ innertransparency = outertransparency
+ return outercolor, outertransparency
+end
+
+--~
+
+local specificationsplitter = tsplitat(" ")
+local colorsplitter = tsplitter(":",tonumber) -- no need for :
+local domainsplitter = tsplitter(" ",tonumber)
+local centersplitter = domainsplitter
+local coordinatesplitter = domainsplitter
+
+-- thanks to taco's reading of the postscript manual:
+--
+-- x' = sx * x + ry * y + tx
+-- y' = rx * x + sy * y + ty
+
+local nofshades = 0 -- todo: hash resources, start at 1000 in order not to clash with older
+
+local function normalize(ca,cb)
+ if #cb == 1 then
+ if #ca == 4 then
+ cb[1], cb[2], cb[3], cb[4] = 0, 0, 0, 1-cb[1]
+ else
+ cb[1], cb[2], cb[3] = cb[1], cb[1], cb[1]
+ end
+ elseif #cb == 3 then
+ if #ca == 4 then
+ cb[1], cb[2], cb[3], cb[4] = rgbtocmyk(cb[1],cb[2],cb[3])
+ else
+ cb[1], cb[2], cb[3] = cmyktorgb(cb[1],cb[2],cb[3],cb[4])
+ end
+ end
+end
+
+
+local commasplitter = tsplitat(",")
+
+local function checkandconvertspot(n_a,f_a,c_a,v_a,n_b,f_b,c_b,v_b)
+ -- must be the same but we don't check
+ local name = f_shade(nofshades)
+ local ca = lpegmatch(commasplitter,v_a)
+ local cb = lpegmatch(commasplitter,v_b)
+ if #ca == 0 or #cb == 0 then
+ return { 0 }, { 1 }, "DeviceGray", name
+ else
+ for i=1,#ca do ca[i] = tonumber(ca[i]) or 0 end
+ for i=1,#cb do cb[i] = tonumber(cb[i]) or 1 end
+ --~ spotcolorconverter(n_a,f_a,c_a,v_a) -- not really needed
+ return ca, cb, n_a or n_b, name
+ end
+end
+
+local function checkandconvert(ca,cb,model)
+ local name = f_shade(nofshades)
+ if not ca or not cb or type(ca) == "string" then
+ return { 0 }, { 1 }, "DeviceGray", name
+ else
+ if #ca > #cb then
+ normalize(ca,cb)
+ elseif #ca < #cb then
+ normalize(cb,ca)
+ end
+ if not model then
+ model = colors.currentnamedmodel()
+ end
+ if model == "all" then
+ model= (#ca == 4 and "cmyk") or (#ca == 3 and "rgb") or "gray"
+ end
+ if model == "rgb" then
+ if #ca == 4 then
+ ca = { cmyktorgb(ca[1],ca[2],ca[3],ca[4]) }
+ cb = { cmyktorgb(cb[1],cb[2],cb[3],cb[4]) }
+ elseif #ca == 1 then
+ local a = 1 - ca[1]
+ local b = 1 - cb[1]
+ ca = { a, a, a }
+ cb = { b, b, b }
+ end
+ return ca, cb, "DeviceRGB", name, model
+ elseif model == "cmyk" then
+ if #ca == 3 then
+ ca = { rgbtocmyk(ca[1],ca[2],ca[3]) }
+ cb = { rgbtocmyk(cb[1],cb[2],cb[3]) }
+ elseif #ca == 1 then
+ ca = { 0, 0, 0, ca[1] }
+ cb = { 0, 0, 0, ca[1] }
+ end
+ return ca, cb, "DeviceCMYK", name, model
+ else
+ if #ca == 4 then
+ ca = { cmyktogray(ca[1],ca[2],ca[3],ca[4]) }
+ cb = { cmyktogray(cb[1],cb[2],cb[3],cb[4]) }
+ elseif #ca == 3 then
+ ca = { rgbtogray(ca[1],ca[2],ca[3]) }
+ cb = { rgbtogray(cb[1],cb[2],cb[3]) }
+ end
+ -- backend specific (will be renamed)
+ return ca, cb, "DeviceGray", name, model
+ end
+ end
+end
+
+-- We keep textexts in a shared list (as it's easier that way and we also had that in
+-- the beginning). Each graphic gets its own (1 based) subtable so that we can also
+-- handle multiple conversions in one go which is needed when we process mp files
+-- directly.
+
+local stack = { } -- quick hack, we will pass topofstack around
+local top = nil
+local nofruns = 0 -- askedfig: "all", "first", number
+
+local function preset(t,k)
+ -- references to textexts by mp index
+ local v = {
+ textrial = 0,
+ texfinal = 0,
+ texslots = { },
+ texorder = { },
+ texhash = { },
+ }
+ t[k] = v
+ return v
+end
+
+local function startjob(plugmode,kind,mpx)
+ insert(stack,top)
+ top = {
+ textexts = { }, -- all boxes, optionally with a different color
+ texstrings = { },
+ texregimes = { },
+ mapstrings = { },
+ mapindices = { },
+ mapmoves = { },
+ texlast = 0,
+ texdata = setmetatableindex({},preset), -- references to textexts in order or usage
+ plugmode = plugmode, -- some day we can then skip all pre/postscripts
+ extradata = mpx and metapost.getextradata(mpx),
+ }
+ if trace_runs then
+ report_metapost("starting %s run at level %i in %s mode",
+ kind,#stack+1,plugmode and "plug" or "normal")
+ end
+ return top
+end
+
+local function stopjob()
+ if top then
+ for slot, content in next, top.textexts do
+ if content then
+ flush_list(content)
+ if trace_textexts then
+ report_textexts("freeing text %s",slot)
+ end
+ end
+ end
+ if trace_runs then
+ report_metapost("stopping run at level %i",#stack+1)
+ end
+ top = remove(stack)
+ return top
+ end
+end
+
+function metapost.getjobdata()
+ return top
+end
+
+-- end of new
+
+local settext = function(box,slot,str)
+ if top then
+ -- if trace_textexts then
+ -- report_textexts("getting text %s from box %s",slot,box)
+ -- end
+ top.textexts[slot] = textakebox(box)
+ end
+end
+
+local gettext = function(box,slot)
+ if top then
+ texsetbox(box,top.textexts[slot])
+ top.textexts[slot] = false
+ -- if trace_textexts then
+ -- report_textexts("putting text %s in box %s",slot,box)
+ -- end
+ end
+end
+
+metapost.settext = settext
+metapost.gettext = gettext
+
+implement { name = "mpsettext", actions = settext, arguments = { "integer", "integer" } } -- box slot
+implement { name = "mpgettext", actions = gettext, arguments = { "integer", "integer" } } -- box slot
+
+-- rather generic pdf, so use this elsewhere too it no longer pays
+-- off to distinguish between outline and fill (we now have both
+-- too, e.g. in arrows)
+
+metapost.reducetogray = true
+
+local models = { }
+
+function models.all(cr)
+ local n = #cr
+ if n == 0 then
+ return checked_color_pair()
+ elseif metapost.reducetogray then
+ if n == 1 then
+ local s = cr[1]
+ return checked_color_pair(f_gray,s,s)
+ elseif n == 3 then
+ local r = cr[1]
+ local g = cr[2]
+ local b = cr[3]
+ if r == g and g == b then
+ return checked_color_pair(f_gray,r,r)
+ else
+ return checked_color_pair(f_rgb,r,g,b,r,g,b)
+ end
+ else
+ local c = cr[1]
+ local m = cr[2]
+ local y = cr[3]
+ local k = cr[4]
+ if c == m and m == y and y == 0 then
+ k = 1 - k
+ return checked_color_pair(f_gray,k,k)
+ else
+ return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)
+ end
+ end
+ elseif n == 1 then
+ local s = cr[1]
+ return checked_color_pair(f_gray,s,s)
+ elseif n == 3 then
+ local r = cr[1]
+ local g = cr[2]
+ local b = cr[3]
+ return checked_color_pair(f_rgb,r,g,b,r,g,b)
+ else
+ local c = cr[1]
+ local m = cr[2]
+ local y = cr[3]
+ local k = cr[4]
+ return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)
+ end
+end
+
+function models.rgb(cr)
+ local n = #cr
+ if n == 0 then
+ return checked_color_pair()
+ elseif metapost.reducetogray then
+ if n == 1 then
+ local s = cr[1]
+ checked_color_pair(f_gray,s,s)
+ elseif n == 3 then
+ local r = cr[1]
+ local g = cr[2]
+ local b = cr[3]
+ if r == g and g == b then
+ return checked_color_pair(f_gray,r,r)
+ else
+ return checked_color_pair(f_rgb,r,g,b,r,g,b)
+ end
+ else
+ local c = cr[1]
+ local m = cr[2]
+ local y = cr[3]
+ local k = cr[4]
+ if c == m and m == y and y == 0 then
+ k = 1 - k
+ return checked_color_pair(f_gray,k,k)
+ else
+ local r, g, b = cmyktorgb(c,m,y,k)
+ return checked_color_pair(f_rgb,r,g,b,r,g,b)
+ end
+ end
+ elseif n == 1 then
+ local s = cr[1]
+ return checked_color_pair(f_gray,s,s)
+ else
+ local r = cr[1]
+ local g = cr[2]
+ local b = cr[3]
+ local r, g, b
+ if n == 3 then
+ r, g, b = cmyktorgb(r,g,b,cr[4])
+ end
+ return checked_color_pair(f_rgb,r,g,b,r,g,b)
+ end
+end
+
+function models.cmyk(cr)
+ local n = #cr
+ if n == 0 then
+ return checked_color_pair()
+ elseif metapost.reducetogray then
+ if n == 1 then
+ local s = cr[1]
+ return checked_color_pair(f_gray,s,s)
+ elseif n == 3 then
+ local r = cr[1]
+ local g = cr[2]
+ local b = cr[3]
+ if r == g and g == b then
+ return checked_color_pair(f_gray,r,r)
+ else
+ local c, m, y, k = rgbtocmyk(r,g,b)
+ return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)
+ end
+ else
+ local c = cr[1]
+ local m = cr[2]
+ local y = cr[3]
+ local k = cr[4]
+ if c == m and m == y and y == 0 then
+ k = 1 - k
+ return checked_color_pair(f_gray,k,k)
+ else
+ return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)
+ end
+ end
+ elseif n == 1 then
+ local s = cr[1]
+ return checked_color_pair(f_gray,s,s)
+ else
+ local c = cr[1]
+ local m = cr[2]
+ local y = cr[3]
+ local k = cr[4]
+ if n == 3 then
+ if c == m and m == y then
+ k, c, m, y = 1 - c, 0, 0, 0
+ else
+ c, m, y, k = rgbtocmyk(c,m,y)
+ end
+ end
+ return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)
+ end
+end
+
+function models.gray(cr)
+ local n = #cr
+ local s = 0
+ if n == 0 then
+ return checked_color_pair()
+ elseif n == 4 then
+ s = cmyktogray(cr[1],cr[2],cr[3],cr[4])
+ elseif n == 3 then
+ s = rgbtogray(cr[1],cr[2],cr[3])
+ else
+ s = cr[1]
+ end
+ return checked_color_pair(f_gray,s,s)
+end
+
+models[1] = models.all
+models[2] = models.gray
+models[3] = models.rgb
+models[4] = models.cmyk
+
+setmetatableindex(models, function(t,k)
+ local v = models.gray
+ t[k] = v
+ return v
+end)
+
+local function colorconverter(cs)
+ return models[outercolormodel](cs)
+end
+
+local factor = 65536*(7227/7200)
+
+implement {
+ name = "mpsetsxsy",
+ arguments = { "dimen", "dimen", "dimen" },
+ actions = function(wd,ht,dp)
+ local hd = ht + dp
+ setmacro("mlib_sx",wd ~= 0 and factor/wd or 0)
+ setmacro("mlib_sy",hd ~= 0 and factor/hd or 0)
+ end
+}
+
+local function sxsy(wd,ht,dp) -- helper for text
+ local hd = ht + dp
+ return (wd ~= 0 and factor/wd) or 0, (hd ~= 0 and factor/hd) or 0
+end
+
+metapost.sxsy = sxsy
+
+-- for stock mp we need to declare the booleans first
+
+local do_begin_fig = "; beginfig(1) ; "
+local do_end_fig = "; endfig ;"
+local do_safeguard = ";"
+
+function metapost.preparetextextsdata()
+ local textexts = top.textexts
+ local collected = { }
+ for k, data in sortedhash(top.texdata) do -- sort is nicer in trace
+ local texorder = data.texorder
+ for n=1,#texorder do
+ local box = textexts[texorder[n]]
+ if box then
+ collected[n] = box
+ else
+ break
+ end
+ end
+ end
+ mp.mf_tt_initialize(collected)
+end
+
+local runmetapost = metapost.run
+
+local function checkaskedfig(askedfig) -- return askedfig, wrappit
+ if not askedfig then
+ return "direct", true
+ elseif askedfig == "all" then
+ return "all", false
+ elseif askedfig == "direct" then
+ return "all", true
+ else
+ askedfig = tonumber(askedfig)
+ if askedfig then
+ return askedfig, false
+ else
+ return "direct", true
+ end
+ end
+end
+
+-- This one is called from the \TEX\ end so the specification is different
+-- from the specification to metapost,run cum suis! The definitions and
+-- extension used to be handled here but are now delegated to the format
+-- initializers because we need to accumulate them for nested instances (a
+-- side effect of going single pass).
+
+function metapost.graphic_base_pass(specification)
+ local mpx = specification.mpx -- mandate
+ local top = startjob(true,"base",mpx)
+ local data = specification.data or ""
+ local inclusions = specification.inclusions or ""
+ local initializations = specification.initializations or ""
+ local askedfig,
+ wrappit = checkaskedfig(specification.figure)
+ nofruns = nofruns + 1
+ top.askedfig = askedfig
+ top.wrappit = wrappit
+ top.nofruns = nofruns
+ metapost.namespace = specification.namespace or ""
+ top.mpx = mpx
+ top.data = data
+ top.initializations = initializations
+ if trace_runs then
+ report_metapost("running job %s, asked figure %a",nofruns,askedfig)
+ end
+ runmetapost {
+ mpx = mpx,
+ askedfig = askedfig,
+ incontext = true,
+ data = {
+ inclusions,
+ wrappit and do_begin_fig or "",
+ initializations,
+ do_safeguard,
+ data,
+ wrappit and do_end_fig or "",
+ },
+ }
+ context(stopjob)
+end
+
+local function oldschool(mpx, data, trial_run, flusher, was_multi_pass, is_extra_pass, askedfig, incontext)
+ metapost.process {
+ mpx = mpx,
+ flusher = flusher,
+ askedfig = askedfig,
+ useplugins = incontext,
+ incontext = incontext,
+ data = data,
+ }
+end
+
+function metapost.process(specification,...)
+ if type(specification) ~= "table" then
+ oldschool(specification,...)
+ else
+ startjob(specification.incontext or specification.useplugins,"process",false)
+ runmetapost(specification)
+ stopjob()
+ end
+end
+
+-- -- the new plugin handler -- --
+
+local sequencers = utilities.sequencers
+local appendgroup = sequencers.appendgroup
+local appendaction = sequencers.appendaction
+
+local resetteractions = sequencers.new { arguments = "t" }
+local processoractions = sequencers.new { arguments = "object,prescript,before,after" }
+
+appendgroup(resetteractions, "system")
+appendgroup(processoractions,"system")
+
+-- later entries come first
+
+local scriptsplitter = Ct ( Ct (
+ C((1-S("= "))^1) * S("= ")^1 * C((1-S("\n\r"))^0) * S("\n\r")^0
+)^0 )
+
+local function splitprescript(script)
+ local hash = lpegmatch(scriptsplitter,script)
+ for i=#hash,1,-1 do
+ local h = hash[i]
+ if h == "reset" then
+ for k, v in next, hash do
+ if type(k) ~= "number" then
+ hash[k] = nil
+ end
+ end
+ else
+ hash[h[1]] = h[2]
+ end
+ end
+ if trace_scripts then
+ report_scripts(table.serialize(hash,"prescript"))
+ end
+ return hash
+end
+
+metapost.splitprescript = splitprescript
+
+-- -- not used:
+--
+-- local function splitpostscript(script)
+-- local hash = lpegmatch(scriptsplitter,script)
+-- for i=1,#hash do
+-- local h = hash[i]
+-- hash[h[1]] = h[2]
+-- end
+-- if trace_scripts then
+-- report_scripts(table.serialize(hash,"postscript"))
+-- end
+-- return hash
+-- end
+
+function metapost.pluginactions(what,t,flushfigure) -- before/after object, depending on what
+ if top and top.plugmode then -- hm, what about other features
+ for i=1,#what do
+ local wi = what[i]
+ if type(wi) == "function" then
+ -- assume injection
+ flushfigure(t) -- to be checked: too many 0 g 0 G
+ t = { }
+ wi()
+ else
+ t[#t+1] = wi
+ end
+ end
+ return t
+ end
+end
+
+function metapost.resetplugins(t) -- intialize plugins, before figure
+ if top and top.plugmode then
+ outercolormodel = colors.currentmodel() -- currently overloads the one set at the tex end
+ resetteractions.runner(t)
+ end
+end
+
+function metapost.processplugins(object) -- each object (second pass)
+ if top and top.plugmode then
+ local prescript = object.prescript -- specifications
+ if prescript and #prescript > 0 then
+ local before = { }
+ local after = { }
+ processoractions.runner(object,splitprescript(prescript) or { },before,after)
+ return #before > 0 and before, #after > 0 and after
+ else
+ local c = object.color
+ if c and #c > 0 then
+ local b, a = colorconverter(c)
+ return { b }, { a }
+ end
+ end
+ end
+end
+
+-- helpers
+
+local basepoints = number.dimenfactors["bp"]
+
+local function cm(object)
+ local op = object.path
+ if op then
+ local first = op[1]
+ local second = op[2]
+ local fourth = op[4]
+ if fourth then
+ local tx = first.x_coord
+ local ty = first.y_coord
+ local sx = second.x_coord - tx
+ local sy = fourth.y_coord - ty
+ local rx = second.y_coord - ty
+ local ry = fourth.x_coord - tx
+ if sx == 0 then sx = 0.00001 end
+ if sy == 0 then sy = 0.00001 end
+ return sx, rx, ry, sy, tx, ty
+ end
+ end
+ return 1, 0, 0, 1, 0, 0 -- weird case
+end
+
+metapost.cm = cm
+
+-- color
+
+local function cl_reset(t)
+ t[#t+1] = metapost.colorinitializer() -- only color
+end
+
+-- text
+
+local tx_reset, tx_process do
+
+ local eol = S("\n\r")^1
+ local cleaner = Cs((P("@@")/"@" + P("@")/"%%" + P(1))^0)
+ local splitter = Ct(
+ ( (
+ P("s:") * C((1-eol)^1)
+ + P("n:") * ((1-eol)^1/tonumber)
+ + P("b:") * ((1-eol)^1/toboolean)
+ ) * eol^0 )^0)
+
+ local function applyformat(s)
+ local t = lpegmatch(splitter,s)
+ if #t == 1 then
+ return s
+ else
+ local f = lpegmatch(cleaner,t[1])
+ return formatters[f](unpack(t,2))
+ end
+ end
+
+ local fmt = formatters["%s %s %s % t"]
+ ----- pat = tsplitat(":")
+ local pat = lpeg.tsplitter(":",tonumber) -- so that %F can do its work
+
+ local f_gray_yes = formatters["s=%.3N,a=%i,t=%.3N"]
+ local f_gray_nop = formatters["s=%.3N"]
+ local f_rgb_yes = formatters["r=%.3N,g=%.3N,b=%.3N,a=%.3N,t=%.3N"]
+ local f_rgb_nop = formatters["r=%.3N,g=%.3N,b=%.3N"]
+ local f_cmyk_yes = formatters["c=%.3N,m=%.3N,y=%.3N,k=%.3N,a=%.3N,t=%.3N"]
+ local f_cmyk_nop = formatters["c=%.3N,m=%.3N,y=%.3N,k=%.3N"]
+
+ local ctx_MPLIBsetNtext = context.MPLIBsetNtextX
+ local ctx_MPLIBsetCtext = context.MPLIBsetCtextX
+ local ctx_MPLIBsettext = context.MPLIBsettextX
+
+ local bp = number.dimenfactors.bp
+
+ local mp_index = 0
+ local mp_target = 0
+ local mp_c = nil
+ local mp_a = nil
+ local mp_t = nil
+
+ local function processtext()
+ local mp_text = top.texstrings[mp_index]
+ local mp_regime = top.texregimes[mp_index]
+ if mp_regime and tonumber(mp_regime) >= 0 then
+ mp_text = function()
+ context.sprint(mp_regime,top.texstrings[mp_index] or "")
+ end
+ end
+ if not mp_text then
+ report_textexts("missing text for index %a",mp_index)
+ elseif not mp_c then
+ ctx_MPLIBsetNtext(mp_target,mp_text)
+ elseif #mp_c == 1 then
+ if mp_a and mp_t then
+ ctx_MPLIBsetCtext(mp_target,f_gray_yes(mp_c[1],mp_a,mp_t),mp_text)
+ else
+ ctx_MPLIBsetCtext(mp_target,f_gray_nop(mp_c[1]),mp_text)
+ end
+ elseif #mp_c == 3 then
+ if mp_a and mp_t then
+ ctx_MPLIBsetCtext(mp_target,f_rgb_yes(mp_c[1],mp_c[2],mp_c[3],mp_a,mp_t),mp_text)
+ else
+ ctx_MPLIBsetCtext(mp_target,f_rgb_nop(mp_c[1],mp_c[2],mp_c[3]),mp_text)
+ end
+ elseif #mp_c == 4 then
+ if mp_a and mp_t then
+ ctx_MPLIBsetCtext(mp_target,f_cmyk_yes(mp_c[1],mp_c[2],mp_c[3],mp_c[4],mp_a,mp_t),mp_text)
+ else
+ ctx_MPLIBsetCtext(mp_target,f_cmyk_nop(mp_c[1],mp_c[2],mp_c[3],mp_c[4]),mp_text)
+ end
+ else
+ -- can't happen
+ ctx_MPLIBsetNtext(mp_target,mp_text)
+ end
+ end
+
+ local madetext = nil
+
+ local function mf_some_text(index,str,regime)
+ mp_target = index
+ mp_index = index
+ mp_c = nil
+ mp_a = nil
+ mp_t = nil
+ top.texstrings[mp_index] = str
+ top.texregimes[mp_index] = regime or -1
+ texrunlocal("mptexttoks")
+ local box = textakebox("mptextbox")
+ top.textexts[mp_target] = box
+ injecttriplet(bp*box.width,bp*box.height,bp*box.depth)
+ madetext = nil
+ end
+
+ local function mf_made_text(index)
+ mf_some_text(index,madetext,catcodes.numbers.ctxcatcodes) -- btex/etex ..
+ end
+
+ registerscript("sometextext", function() mf_some_text(mpscannumeric(),mpscanstring(),mpscannumeric()) end)
+ registerscript("madetextext", function() mf_made_text(mpscannumeric()) end)
+
+ -- a label can be anything, also something mp doesn't like in strings
+ -- so we return an index instead
+
+ function metapost.processing()
+ return top and true or false
+ end
+
+ function metapost.remaptext(replacement)
+ if top then
+ local mapstrings = top.mapstrings
+ local mapindices = top.mapindices
+ local label = replacement.label
+ local index = 0
+ if label then
+ local found = mapstrings[label]
+ if found then
+ setmetatableindex(found,replacement)
+ index = found.index
+ else
+ index = #mapindices + 1
+ replacement.index = index
+ mapindices[index] = replacement
+ mapstrings[label] = replacement
+ end
+ end
+ return index
+ else
+ return 0
+ end
+ end
+
+ function metapost.remappedtext(what)
+ return top and (top.mapstrings[what] or top.mapindices[tonumber(what)])
+ end
+
+ function mp.mf_map_move(index)
+ mp.triplet(top.mapmoves[index])
+ end
+
+ function mp.mf_map_text(index,str,regime)
+ local map = top.mapindices[tonumber(str)]
+ if type(map) == "table" then
+ local text = map.text
+ local overload = map.overload
+ local offset = 0
+ local width = 0
+ local where = nil
+ --
+ mp_index = index
+ -- the image text
+ if overload then
+ top.texstrings[mp_index] = map.template or map.label or "error"
+ top.texregimes[mp_index] = regime or -1
+ texrunlocal("mptexttoks")
+ local box = textakebox("mptextbox") or new_hlist()
+ width = bp * box.width
+ where = overload.where
+ end
+ -- the real text
+ top.texstrings[mp_index] = overload and overload.text or text or "error"
+ top.texregimes[mp_index] = regime or -1
+ texrunlocal("mptexttoks")
+ local box = textakebox("mptextbox") or new_hlist()
+ local twd = bp * box.width
+ local tht = bp * box.height
+ local tdp = bp * box.depth
+ -- the check
+ if where then
+ local scale = 1 -- / (map.scale or 1)
+ if where == "l" or where == "left" then
+ offset = scale * (twd - width)
+ elseif where == "m" or where == "middle" then
+ offset = scale * (twd - width) / 2
+ end
+ end
+ -- the result
+ top.textexts[mp_index] = box
+ top.mapmoves[mp_index] = { offset, map.dx or 0, map.dy or 0 }
+ --
+ mp.triplet(twd,tht,tdp)
+ madetext = nil
+ return
+ else
+ map = type(map) == "string" and map or str
+ return mf_some_text(index,context.escape(map) or map)
+ end
+ end
+
+ -- This is a bit messy. In regular metapost it's a kind of immediate replacement
+ -- so embedded btex ... etex is not really working as one would expect. We now have
+ -- a mix: it's immediate when we are at the outer level (rawmadetext) and indirect
+ -- (with the danger of stuff that doesn't work well in strings) when we are for
+ -- instance in a macro definition (rawtextext (pass back string)) ... of course one
+ -- should use textext so this is just a catch. When not in lmtx it's never immediate.
+
+ local reported = false
+ local alwayswrap = false -- CONTEXTLMTXMODE <= 1 -- was always nil due to typo
+
+ function metapost.maketext(s,mode)
+ if not reported then
+ reported = true
+ report_metapost("use 'textext(.....)' instead of 'btex ..... etex'")
+ end
+ if mode and mode == 1 then
+ if trace_btexetex then
+ report_metapost("ignoring verbatimtex: [[%s]]",s)
+ end
+ elseif alwayswrap then
+ if trace_btexetex then
+ report_metapost("rewrapping btex ... etex [[%s]]",s)
+ end
+ return 'rawtextext("' .. gsub(s,'"','"&ditto&"') .. '")' -- nullpicture
+ elseif metapost.currentmpxstatus() ~= 0 then
+ if trace_btexetex then
+ report_metapost("rewrapping btex ... etex at the outer level [[%s]]",s)
+ end
+ return 'rawtextext("' .. gsub(s,'"','"&ditto&"') .. '")' -- nullpicture
+ else
+ if trace_btexetex then
+ report_metapost("handling btex ... etex: [[%s]]",s)
+ end
+ -- madetext = utilities.strings.collapse(s)
+ madetext = s
+ return "rawmadetext" -- is assuming immediate processing
+ end
+ end
+
+ function mp.mf_formatted_text(index,fmt,...)
+ local t = { }
+ for i=1,select("#",...) do
+ local ti = select(i,...)
+ if type(ti) ~= "table" then
+ t[#t+1] = ti
+ end
+ end
+ local f = lpegmatch(cleaner,fmt)
+ local s = formatters[f](unpack(t)) or ""
+ mf_some_text(index,s)
+ end
+
+ interfaces.implement {
+ name = "mptexttoks",
+ actions = processtext,
+ }
+
+ tx_reset = function()
+ if top then
+ top.texhash = { }
+ top.texlast = 0
+ end
+ end
+
+ tx_process = function(object,prescript,before,after)
+ local data = top.texdata[metapost.properties.number] -- the current figure number, messy
+ local index = tonumber(prescript.tx_index)
+ if index then
+ if trace_textexts then
+ report_textexts("using index %a",index)
+ end
+ --
+ mp_c = object.color
+ if #mp_c == 0 then
+ local txc = prescript.tx_color
+ if txc then
+ mp_c = lpegmatch(pat,txc)
+ end
+ end
+ mp_a = tonumber(prescript.tr_alternative)
+ mp_t = tonumber(prescript.tr_transparency)
+ --
+ mp_index = index
+ mp_target = top.texlast - 1
+ top.texlast = mp_target
+ --
+ local mp_text = top.texstrings[mp_index]
+ local mp_hash = prescript.tx_cache
+ local box
+ if mp_hash == "no" then
+ texrunlocal("mptexttoks")
+ box = textakebox("mptextbox")
+ else
+ local cache = data.texhash
+ if mp_hash then
+ mp_hash = tonumber(mp_hash)
+ end
+ if mp_hash then
+ local extradata = top.extradata
+ if extradata then
+ cache = extradata.globalcache
+ if not cache then
+ cache = { }
+ extradata.globalcache = cache
+ end
+ if trace_runs then
+ if cache[mp_hash] then
+ report_textexts("reusing global entry %i",mp_hash)
+ else
+ report_textexts("storing global entry %i",mp_hash)
+ end
+ end
+ else
+ mp_hash = nil
+ end
+ end
+ if not mp_hash then
+ mp_hash = fmt(mp_text,mp_a or "-",mp_t or "-",mp_c or "-")
+ end
+ box = cache[mp_hash]
+ if box then
+ box = copy_list(box)
+ else
+ texrunlocal("mptexttoks")
+ box = textakebox("mptextbox")
+ cache[mp_hash] = box
+ end
+ end
+ top.textexts[mp_target] = box
+ --
+ if box then
+ -- we need to freeze the variables outside the function
+ local sx, rx, ry, sy, tx, ty = cm(object)
+ local target = mp_target
+ before[#before+1] = function()
+ context.MPLIBgettextscaledcm(target,
+ f_f(sx), -- bah ... %s no longer checks
+ f_f(rx), -- bah ... %s no longer checks
+ f_f(ry), -- bah ... %s no longer checks
+ f_f(sy), -- bah ... %s no longer checks
+ f_f(tx), -- bah ... %s no longer checks
+ f_f(ty), -- bah ... %s no longer checks
+ sxsy(box.width,box.height,box.depth))
+ end
+ else
+ before[#before+1] = function()
+ report_textexts("unknown %s",index)
+ end
+ end
+ if not trace_textexts then
+ object.path = false -- else: keep it
+ end
+ object.color = false
+ object.grouped = true
+ object.istext = true
+ end
+ end
+
+end
+
+-- we could probably redo normal textexts in the next way but as it's rather optimized
+-- we keep away from that (at least for now)
+
+local function bx_process(object,prescript,before,after)
+ local bx_category = prescript.bx_category
+ local bx_name = prescript.bx_name
+ if bx_category and bx_name then
+ if trace_textexts then
+ report_textexts("category %a, name %a",bx_category,bx_name)
+ end
+ local sx, rx, ry, sy, tx, ty = cm(object) -- needs to be frozen outside the function
+ local wd, ht, dp = nodes.boxes.dimensions(bx_category,bx_name)
+ before[#before+1] = function()
+ context.MPLIBgetboxscaledcm(bx_category,bx_name,
+ f_f(sx), -- bah ... %s no longer checks
+ f_f(rx), -- bah ... %s no longer checks
+ f_f(ry), -- bah ... %s no longer checks
+ f_f(sy), -- bah ... %s no longer checks
+ f_f(tx), -- bah ... %s no longer checks
+ f_f(ty), -- bah ... %s no longer checks
+ sxsy(wd,ht,dp))
+ end
+ if not trace_textexts then
+ object.path = false -- else: keep it
+ end
+ object.color = false
+ object.grouped = true
+ object.istext = true
+ end
+end
+
+-- graphics (we use the given index because pictures can be reused)
+
+
+local gt_reset, gt_process do
+
+ local graphics = { }
+
+
+ local mp_index = 0
+ local mp_str = ""
+
+ function mp.mf_graphic_text(index,str)
+ if not graphics[index] then
+ mp_index = index
+ mp_str = str
+ texrunlocal("mpgraphictexttoks")
+ end
+ end
+
+ interfaces.implement {
+ name = "mpgraphictexttoks",
+ actions = function()
+ context.MPLIBgraphictext(mp_index,mp_str)
+ end,
+ }
+
+end
+
+-- shades
+
+local function sh_process(object,prescript,before,after)
+ local sh_type = prescript.sh_type
+ if sh_type then
+ nofshades = nofshades + 1
+ local domain = lpegmatch(domainsplitter,prescript.sh_domain or "0 1")
+ local centera = lpegmatch(centersplitter,prescript.sh_center_a or "0 0")
+ local centerb = lpegmatch(centersplitter,prescript.sh_center_b or "0 0")
+ local transform = toboolean(prescript.sh_transform or "yes",true)
+ -- compensation for scaling
+ local sx = 1
+ local sy = 1
+ local sr = 1
+ local dx = 0
+ local dy = 0
+ if transform then
+ local first = lpegmatch(coordinatesplitter,prescript.sh_first or "0 0")
+ local setx = lpegmatch(coordinatesplitter,prescript.sh_set_x or "0 0")
+ local sety = lpegmatch(coordinatesplitter,prescript.sh_set_y or "0 0")
+
+ local x = setx[1] -- point that has different x
+ local y = sety[1] -- point that has different y
+
+ if x == 0 or y == 0 then
+ -- forget about it
+ else
+ local path = object.path
+ local path1x = path[1].x_coord
+ local path1y = path[1].y_coord
+ local path2x = path[x].x_coord
+ local path2y = path[y].y_coord
+
+ local dxa = path2x - path1x
+ local dya = path2y - path1y
+ local dxb = setx[2] - first[1]
+ local dyb = sety[2] - first[2]
+
+ if dxa == 0 or dya == 0 or dxb == 0 or dyb == 0 then
+ -- forget about it
+ else
+ sx = dxa / dxb ; if sx < 0 then sx = - sx end -- yes or no
+ sy = dya / dyb ; if sy < 0 then sy = - sy end -- yes or no
+
+ sr = sqrt(sx^2 + sy^2)
+
+ dx = path1x - sx*first[1]
+ dy = path1y - sy*first[2]
+ end
+ end
+ end
+
+ local steps = tonumber(prescript.sh_step) or 1
+ local sh_color_a = prescript.sh_color_a_1 or prescript.sh_color_a or "1"
+ local sh_color_b = prescript.sh_color_b_1 or prescript.sh_color_b or "1" -- sh_color_b_
+ local ca, cb, colorspace, name, model, separation, fractions
+ if prescript.sh_color == "into" and prescript.sp_name then
+ -- some spotcolor
+ local value_a, components_a, fractions_a, name_a
+ local value_b, components_b, fractions_b, name_b
+ for i=1,#prescript do
+ -- { "sh_color_a", "1" },
+ -- { "sh_color", "into" },
+ -- { "sh_radius_b", "0" },
+ -- { "sh_radius_a", "141.73225" },
+ -- { "sh_center_b", "425.19676 141.73225" },
+ -- { "sh_center_a", "425.19676 0" },
+ -- { "sh_factor", "1" },
+ local tag = prescript[i][1]
+ if not name_a and tag == "sh_color_a" then
+ value_a = prescript[i-5][2]
+ components_a = prescript[i-4][2]
+ fractions_a = prescript[i-3][2]
+ name_a = prescript[i-2][2]
+ elseif not name_b and tag == "sh_color_b" then
+ value_b = prescript[i-5][2]
+ components_b = prescript[i-4][2]
+ fractions_b = prescript[i-3][2]
+ name_b = prescript[i-2][2]
+ end
+ if name_a and name_b then
+ break
+ end
+ end
+ ca, cb, separation, name = checkandconvertspot(
+ name_a,fractions_a,components_a,value_a,
+ name_b,fractions_b,components_b,value_b
+ )
+ else
+ local colora = lpegmatch(colorsplitter,sh_color_a)
+ local colorb = lpegmatch(colorsplitter,sh_color_b)
+ ca, cb, colorspace, name, model = checkandconvert(colora,colorb)
+ -- test:
+ if steps > 1 then
+ ca = { ca }
+ cb = { cb }
+ fractions = { tonumber(prescript[formatters["sh_fraction_%i"](1)]) or 0 }
+ for i=2,steps do
+ local colora = lpegmatch(colorsplitter,prescript[formatters["sh_color_a_%i"](i)])
+ local colorb = lpegmatch(colorsplitter,prescript[formatters["sh_color_b_%i"](i)])
+ ca[i], cb[i] = checkandconvert(colora,colorb,model)
+ fractions[i] = tonumber(prescript[formatters["sh_fraction_%i"](i)]) or (i/steps)
+ end
+ end
+ end
+ if not ca or not cb then
+ ca, cb, colorspace, name = checkandconvert()
+ steps = 1
+ end
+ if sh_type == "linear" then
+ local coordinates = { dx + sx*centera[1], dy + sy*centera[2], dx + sx*centerb[1], dy + sy*centerb[2] }
+ lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates,separation,steps>1 and steps,fractions) -- backend specific (will be renamed)
+ elseif sh_type == "circular" then
+ local factor = tonumber(prescript.sh_factor) or 1
+ local radiusa = factor * tonumber(prescript.sh_radius_a)
+ local radiusb = factor * tonumber(prescript.sh_radius_b)
+ local coordinates = { dx + sx*centera[1], dy + sy*centera[2], sr*radiusa, dx + sx*centerb[1], dy + sy*centerb[2], sr*radiusb }
+ lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates,separation,steps>1 and steps,fractions) -- backend specific (will be renamed)
+ else
+ -- fatal error
+ end
+ before[#before+1] = "q /Pattern cs"
+ after [#after+1] = formatters["W n /%s sh Q"](name)
+ -- false, not nil, else mt triggered
+ object.colored = false -- hm, not object.color ?
+ object.type = false
+ object.grouped = true
+ end
+end
+
+-- bitmaps
+
+local function bm_process(object,prescript,before,after)
+ local bm_xresolution = prescript.bm_xresolution
+ if bm_xresolution then
+ before[#before+1] = f_cm_b(cm(object))
+ before[#before+1] = function()
+ figures.bitmapimage {
+ xresolution = tonumber(bm_xresolution),
+ yresolution = tonumber(prescript.bm_yresolution),
+ width = 1/basepoints,
+ height = 1/basepoints,
+ data = object.postscript
+ }
+ end
+ before[#before+1] = s_cm_e
+ object.path = false
+ object.color = false
+ object.grouped = true
+ end
+end
+
+-- positions
+
+local function ps_process(object,prescript,before,after)
+ local ps_label = prescript.ps_label
+ if ps_label then
+ local op = object.path
+ local first = op[1]
+ local third = op[3]
+ local x = first.x_coord
+ local y = first.y_coord
+ local w = third.x_coord - x
+ local h = third.y_coord - y
+ local properties = metapost.properties
+ x = x - properties.llx
+ y = properties.ury - y
+ before[#before+1] = function()
+ context.MPLIBpositionwhd(ps_label,x,y,w,h)
+ end
+ object.path = false
+ end
+end
+
+-- figures
+
+-- local sx, rx, ry, sy, tx, ty = cm(object)
+-- sxsy(box.width,box.height,box.depth))
+
+function mp.mf_external_figure(filename)
+ local f = figures.getinfo(filename)
+ local w = 0
+ local h = 0
+ if f then
+ local u = f.used
+ if u and u.fullname then
+ w = u.width or 0
+ h = u.height or 0
+ end
+ else
+ report_metapost("external figure %a not found",filename)
+ end
+ mp.triplet(w/65536,h/65536,0)
+end
+
+local function fg_process(object,prescript,before,after)
+ local fg_name = prescript.fg_name
+ if fg_name then
+ before[#before+1] = f_cm_b(cm(object)) -- beware: does not use the cm stack
+ before[#before+1] = function()
+ context.MPLIBfigure(fg_name,prescript.fg_mask or "")
+ end
+ before[#before+1] = s_cm_e
+ object.path = false
+ object.grouped = true
+ end
+end
+
+-- color and transparency
+
+local value = Cs ( (
+ (Carg(1) * C((1-P(","))^1)) / function(a,b) return f_f3(a * tonumber(b)) end
+ + P(","))^1
+)
+
+-- should be codeinjections
+
+local t_list = attributes.list[attributes.private('transparency')]
+local c_list = attributes.list[attributes.private('color')]
+
+local remappers = {
+ [1] = formatters["s=%s"],
+ [3] = formatters["r=%s,g=%s,b=%s"],
+ [4] = formatters["c=%s,m=%s,y=%s,k=%s"],
+}
+
+local processlast = 0
+local processhash = setmetatableindex(function(t,k)
+ processlast = processlast + 1
+ local v = formatters["mp_%s"](processlast)
+ defineprocesscolor(v,k,true,true)
+ t[k] = v
+ return v
+end)
+
+local function checked_transparency(alternative,transparency,before,after)
+ alternative = tonumber(alternative) or 1
+ transparency = tonumber(transparency) or 0
+ before[#before+1] = formatters["/Tr%s gs"](registertransparency(nil,alternative,transparency,true))
+ after [#after +1] = "/Tr0 gs" -- outertransparency
+end
+
+local function tr_process(object,prescript,before,after)
+ -- before can be shortcut to t
+ local tr_alternative = prescript.tr_alternative
+ if tr_alternative then
+ checked_transparency(tr_alternative,prescript.tr_transparency,before,after)
+ end
+ local cs = object.color
+ if cs and #cs > 0 then
+ local c_b, c_a
+ local sp_type = prescript.sp_type
+ if not sp_type then
+ c_b, c_a = colorconverter(cs)
+ else
+ local sp_name = prescript.sp_name or "black"
+ if sp_type == "spot" then
+ local sp_value = prescript.sp_value or "1"
+ local components = split(sp_value,":")
+ local specification = remappers[#components]
+ if specification then
+ specification = specification(unpack(components))
+ else
+ specification = "s=0"
+ end
+ local sp_spec = processhash[specification]
+ definespotcolor(sp_name,sp_spec,"p=1",true)
+ sp_type = "named"
+ elseif sp_type == "multitone" then -- (fractions of a multitone) don't work well in mupdf
+ local sp_value = prescript.sp_value or "1"
+ local sp_specs = { }
+ local sp_list = split(sp_value," ")
+ for i=1,#sp_list do
+ local sp_value = sp_list[i]
+ local components = split(sp_value,":")
+ local specification = remappers[#components]
+ if specification then
+ specification = specification(unpack(components))
+ else
+ specification = "s=0"
+ end
+ local sp_spec = processhash[specification]
+ sp_specs[i] = formatters["%s=1"](sp_spec)
+ end
+ sp_specs = concat(sp_specs,",")
+ definemultitonecolor(sp_name,sp_specs,"","")
+ sp_type = "named"
+ end
+ if sp_type == "named" then
+ -- we might move this to another namespace .. also, named can be a spotcolor
+ -- so we need to check for that too ... also we need to resolve indirect
+ -- colors so we might need the second pass for this (draw dots with \MPcolor)
+ if not tr_alternative then
+ -- todo: sp_name is not yet registered at this time
+ local t = t_list[sp_name] -- string or attribute
+ local v = t and transparencyvalue(t)
+ if v then
+ checked_transparency(v[1],v[2],before,after)
+ end
+ end
+ local c = c_list[sp_name] -- string or attribute
+ local v = c and colorvalue(c)
+ if v then
+ -- all=1 gray=2 rgb=3 cmyk=4
+ local colorspace = v[1]
+ local factor = cs[1]
+ if colorspace == 2 then
+ local s = factor * v[2]
+ c_b, c_a = checked_color_pair(f_gray,s,s)
+ elseif colorspace == 3 then
+ local r = factor * v[3]
+ local g = factor * v[4]
+ local b = factor * v[5]
+ c_b, c_a = checked_color_pair(f_rgb,r,g,b,r,g,b)
+ elseif colorspace == 4 or colorspace == 1 then
+ local c = factor * v[6]
+ local m = factor * v[7]
+ local y = factor * v[8]
+ local k = factor * v[9]
+ c_b, c_a = checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)
+ elseif colorspace == 5 then
+ -- not all viewers show the fractions ok
+ local name = v[10]
+ local value = split(v[13],",")
+ if factor ~= 1 then
+ for i=1,#value do
+ value[i] = f_scn(factor * (tonumber(value[i]) or 1))
+ end
+ end
+ value = concat(value," ")
+ c_b, c_a = checked_color_pair(f_spot,name,name,value,value)
+ else
+ local s = factor *v[2]
+ c_b, c_a = checked_color_pair(f_gray,s,s)
+ end
+ end
+ end
+ end
+ if c_a and c_b then
+ before[#before+1] = c_b
+ after [#after +1] = c_a
+ end
+ end
+end
+
+-- layers (nasty: we need to keep the 'grouping' right
+
+local function la_process(object,prescript,before,after)
+ local la_name = prescript.la_name
+ if la_name then
+ before[#before+1] = backends.codeinjections.startlayer(la_name)
+ insert(after,1,backends.codeinjections.stoplayer())
+ end
+end
+
+-- groups
+
+local function gr_process(object,prescript,before,after)
+ local gr_state = prescript.gr_state
+ if not gr_state then
+ return
+ elseif gr_state == "start" then
+ local gr_type = utilities.parsers.settings_to_set(prescript.gr_type)
+ local path = object.path
+ local p1 = path[1]
+ local p2 = path[2]
+ local p3 = path[3]
+ local p4 = path[4]
+ local llx = min(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord)
+ local lly = min(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord)
+ local urx = max(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord)
+ local ury = max(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord)
+ before[#before+1] = function()
+ context.MPLIBstartgroup(
+ gr_type.isolated and 1 or 0,
+ gr_type.knockout and 1 or 0,
+ llx, lly, urx, ury
+ )
+ end
+ elseif gr_state == "stop" then
+ after[#after+1] = function()
+ context.MPLIBstopgroup()
+ end
+ end
+ object.path = false
+ object.color = false
+ object.grouped = true
+end
+
+-- outlines
+
+local ot_reset, ot_process do
+
+ local outlinetexts = { } -- also in top data
+
+ ot_reset = function ()
+ outlinetexts = { }
+ end
+
+ local mp_index = 0
+ local mp_kind = ""
+ local mp_str = ""
+
+ function mp.mf_outline_text(index,str,kind)
+ if not outlinetexts[index] then
+ mp_index = index
+ mp_kind = kind
+ mp_str = str
+ texrunlocal("mpoutlinetoks")
+ end
+ end
+
+ interfaces.implement {
+ name = "mpoutlinetoks",
+ actions = function()
+ context.MPLIBoutlinetext(mp_index,mp_kind,mp_str)
+ end,
+ }
+
+ implement {
+ name = "MPLIBconvertoutlinetext",
+ arguments = { "integer", "string", "integer" },
+ actions = function(index,kind,box)
+ local boxtomp = fonts.metapost.boxtomp
+ if boxtomp then
+ outlinetexts[index] = boxtomp(box,kind)
+ else
+ outlinetexts[index] = ""
+ end
+ end
+ }
+
+ function mp.mf_get_outline_text(index) -- maybe we need a more private namespace
+ mp.print(outlinetexts[index] or "draw origin;")
+ end
+
+end
+
+-- mf_object=
+
+local p1 = P("mf_object=")
+local p2 = lpeg.patterns.eol * p1
+local pattern = (1-p2)^0 * p2 + p1
+
+function metapost.isobject(str)
+ return pattern and str ~= "" and lpegmatch(p,str) and true or false
+end
+
+local function installplugin(specification)
+ local reset = specification.reset
+ local process = specification.process
+ local object = specification.object
+ if reset then
+ appendaction(resetteractions,"system",reset)
+ end
+ if process then
+ appendaction(processoractions,"system",process)
+ end
+end
+
+metapost.installplugin = installplugin
+
+-- definitions
+
+installplugin { name = "outline", reset = ot_reset, process = ot_process }
+installplugin { name = "color", reset = cl_reset, process = cl_process }
+installplugin { name = "text", reset = tx_reset, process = tx_process }
+installplugin { name = "group", reset = gr_reset, process = gr_process }
+installplugin { name = "graphictext", reset = gt_reset, process = gt_process }
+installplugin { name = "shade", reset = sh_reset, process = sh_process }
+installplugin { name = "bitmap", reset = bm_reset, process = bm_process }
+installplugin { name = "box", reset = bx_reset, process = bx_process }
+installplugin { name = "position", reset = ps_reset, process = ps_process }
+installplugin { name = "figure", reset = fg_reset, process = fg_process }
+installplugin { name = "layer", reset = la_reset, process = la_process }
+installplugin { name = "transparency", reset = tr_reset, process = tr_process }
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-pps.mkxl b/Master/texmf-dist/tex/context/base/mkxl/mlib-pps.mkxl
new file mode 100644
index 00000000000..2fa721445e8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-pps.mkxl
@@ -0,0 +1,228 @@
+%D \module
+%D [ file=mlib-pps,
+%D version=2008.03.25,
+%D title=\METAPOST\ Integrated Graphics,
+%D subtitle=Basics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo: remove MPenvironment code
+
+\unprotect
+
+\registerctxluafile{mlib-pps}{autosuffix}
+
+%D Todo: catch nested graphics like external figures with dummies.
+
+% todo: figure out why this is shifted
+%
+% \setupbodyfont[palatino]
+%
+% \starttext
+% \startMPpage
+% draw textext("123") ;
+% \stopMPpage
+% \stoptext
+%
+% A slightly larger picture works ok so maybe there is some kind
+% of interference with the page builder.
+
+\newbox \MPtextbox
+\newtoks\everyMPLIBsettext % not used
+
+\permanent\protected\def\mlib_flush_environment
+ {%\writestatus\m!metapost{flushing environment}%
+ \clf_mptexget
+ \enforced\let\MPLIBflushenvironment\relax}% MPenvironments are depricated}
+
+\aliased\let\MPLIBflushenvironment\mlib_flush_environment
+
+\permanent\protected\def\MPLIBsetNtext#1% #2% box text
+ {\MPLIBflushenvironment
+ \dowithnextbox{\clf_mpsettext\nextbox #1}\hbox\bgroup % text
+ \meta_set_current_color
+ \enforced\let\MPLIBflushenvironment\mlib_flush_environment
+ \let\next} % gobble open brace
+
+\permanent\protected\def\MPLIBsetCtext#1#2% #3% box colorspec text
+ {\MPLIBflushenvironment
+ \dowithnextbox{\clf_mpsettext\nextbox #1}\hbox\bgroup % text
+ \directcolored[#2]%
+ \meta_set_current_color % so, textcolor wins !
+ \enforced\let\MPLIBflushenvironment\mlib_flush_environment
+ \let\next} % gobble open brace
+
+\aliased\let\MPLIBsettext\MPLIBsetNtext
+
+\permanent\protected\def\MPLIBsetNtextX#1% #2% box text
+ {\MPLIBflushenvironment
+ \hbox\bgroup % text
+ \meta_set_current_color
+ \enforced\let\MPLIBflushenvironment\mlib_flush_environment
+ \let\next}
+
+\permanent\protected\def\MPLIBsetCtextX#1#2% #3% box colorspec text
+ {\MPLIBflushenvironment
+ \hbox\bgroup % text
+ \directcolored[#2]%
+ \meta_set_current_color % so, textcolor wins !
+ \enforced\let\MPLIBflushenvironment\mlib_flush_environment
+ \let\next}
+
+\aliased\let\MPLIBsettextX\MPLIBsetNtextX
+
+\permanent\permanent\protected\def\MPLIBgettextscaled#1#2#3% why a copy .. can be used more often
+ {\clf_mpgettext\MPtextbox #1%
+ \vpack to \zeropoint
+ {\vss
+ %\hpack to \zeropoint \s!container
+ \hcontainer to \zeropoint
+ {\scale
+ [\c!sx=#2,\c!sy=#3]%
+ {\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}}
+
+\let\mlib_sx\!!zerocount % set at the lua end
+\let\mlib_sy\!!zerocount % set at the lua end
+
+\permanent\protected\def\MPLIBfigure#1#2%
+ {\setbox\scratchbox\hpack{\externalfigure[#1][\c!mask=#2]}%
+ \clf_mpsetsxsy\wd\scratchbox\ht\scratchbox\zeropoint
+ \vpack to \zeropoint
+ {\vss
+ \hpack to \zeropoint
+ {\fastsxsy{\mlib_sx}{\mlib_sy}{\box\scratchbox}\hss}}}
+
+% horrible (we could inline scale and matrix code):
+
+\permanent\protected\def\MPLIBgettextscaledcm#1#2#3#4#5#6#7#8#9% 2-7: sx,rx,ry,sy,tx,ty
+ {\clf_mpgettext\MPtextbox #1%
+ \setbox\MPbox\hpack\bgroup
+ \dotransformnextbox{#2}{#3}{#4}{#5}{#6}{#7}% does push pop ... will be changed to proper lua call (avoid small numbers)
+ \vpack to \zeropoint\bgroup
+ \vss
+ %\hpack to \zeropoint \s!container \bgroup
+ \hcontainer to \zeropoint \bgroup
+ % \scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}%
+ % \scale[\c!sx=#8,\c!sy=#9,\c!depth=\v!no]{\box\MPtextbox}%
+ \fastsxsy{#8}{#9}{\raise\dp\MPtextbox\box\MPtextbox}%
+ % This gives: LuaTeX warning: Misplaced \pdfrestore .. don't ask me why.
+ % but I'll retry it some day soon.
+ % \dostartscaling{#8}{#9}%
+ % \raise\dp\MPtextbox\box\MPtextbox
+ % \dostopscaling
+ \forcecolorhack % can go away ... already in the scale macro
+ \hss
+ \egroup
+ \egroup
+ \egroup
+ \smashbox\MPbox
+ \box\MPbox}
+
+% \putnextboxincache{hans}{1}\hbox{foo}
+%
+% \startMPcode
+% draw boundingbox rawtexbox("hans",1) ;
+% draw rawtexbox("hans",1) ;
+% \stopMPcode
+
+\permanent\protected\def\MPLIBgetboxscaledcm#1#2%
+ {\begingroup
+ \copyboxfromcache{#1}{#2}\MPtextbox % can be \clf_
+ \mlib_get_box_scaled_cm_next}
+
+\protected\def\mlib_get_box_scaled_cm_next#1#2#3#4#5#6#7#8% 1-6: sx,rx,ry,sy,tx,ty
+ {\setbox\MPbox\hpack\bgroup
+ \dotransformnextbox{#1}{#2}{#3}{#4}{#5}{#6}%
+ \vpack to \zeropoint\bgroup
+ \vss
+ \hpack to \zeropoint \bgroup
+ \fastsxsy{#7}{#8}{\raise\dp\MPtextbox\box\MPtextbox}%
+ \hss
+ \egroup
+ \egroup
+ \egroup
+ \smashbox\MPbox
+ \box\MPbox
+ \endgroup}
+
+\permanent\protected\def\MPLIBgraphictext#1% use at mp end
+ {\startTEXpage[\c!scale=10000]#1\stopTEXpage}
+
+%D \startbuffer
+%D \definelayer[test]
+%D
+%D \setlayerframed
+%D [test]
+%D [x=\MPx{somepos-1},y=\MPy{somepos-1}]
+%D [width=\MPw{somepos-1},height=\MPh{somepos-1}]
+%D {Whatever we want here!}
+%D
+%D \setlayerframed
+%D [test]
+%D [x=\MPx{somepos-2},y=\MPy{somepos-2}]
+%D [width=\MPw{somepos-2},height=\MPh{somepos-2}]
+%D {Whatever we need there!}
+%D
+%D \startuseMPgraphic{oeps}
+%D draw fullcircle scaled 6cm withcolor red ;
+%D register ("somepos-1",5cm,1cm,center currentpicture) ;
+%D register ("somepos-2",4cm,3cm,(-1cm,-2cm)) ;
+%D \stopuseMPgraphic
+%D
+%D \framed[background=test,offset=overlay]{\useMPgraphic{oeps}}
+%D \stopbuffer
+%D
+%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection
+
+\permanent\protected\def\MPLIBpositionwhd#1#2#3#4#5% bp !
+ {\dosavepositionwhd{#1}\zerocount{#2\onebasepoint}{#3\onebasepoint}{#4\onebasepoint}{#5\onebasepoint}\zeropoint}
+
+\def\mlib_stop_group#1#2#3#4#5#6% some day this might happen elsewhere
+ {\egroup
+ \setbox\scratchbox\hpack{\kern\onebasepoint\box\scratchbox}% weird correction
+ \wd\scratchbox \dimexpr#5\onebasepoint-#3\onebasepoint+2\onebasepoint\relax
+ \ht\scratchbox #6\onebasepoint
+ \dp\scratchbox-#4\onebasepoint
+ \setbox\scratchbox\hpack\bgroup
+ \kern-#3\onebasepoint
+ \box\scratchbox
+ \egroup
+ \saveboxresource
+ attr {/Group << /S /Transparency /I \ifnum#1=1 true \else false \fi /K \ifnum#2=1 true \else false \fi >>}
+ resources {\pdfbackendcurrentresources}
+ \scratchbox
+ \setbox\scratchbox\hpack\bgroup
+ \kern#3\onebasepoint
+ \kern-\onebasepoint
+ \useboxresource\lastsavedboxresourceindex
+ \egroup
+ \wd\scratchbox\zeropoint
+ \ht\scratchbox\zeropoint
+ \dp\scratchbox\zeropoint
+ \box\scratchbox
+ \endgroup}
+
+\aliased\let\MPLIBstopgroup\relax
+
+\permanent\protected\def\MPLIBstartgroup#1#2#3#4#5#6% isolated 0/1, knockout 0/1 llx lly urx ury
+ {\begingroup
+ \setbox\scratchbox\hpack\bgroup
+ \enforced\permanent\protected\def\MPLIBstopgroup{\mlib_stop_group{#1}{#2}{#3}{#4}{#5}{#6}}}
+
+% For now here ... will be cleaned up:
+
+\newtoks\mptexttoks
+\newbox \mptextbox
+\newtoks\mpoutlinetoks
+\newtoks\mpgraphictexttoks
+
+\mptexttoks {\global\setbox\mptextbox\hbox{\clf_mptexttoks}}
+\mpoutlinetoks {\global\setbox\mptextbox\vbox{\clf_mpoutlinetoks}}
+\mpgraphictexttoks{\global\setbox\mptextbox\vbox{\clf_mpgraphictexttoks}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-ran.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-ran.lmt
new file mode 100644
index 00000000000..a6d4fbe5bff
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-ran.lmt
@@ -0,0 +1,237 @@
+if not modules then modules = { } end modules ['mlib-ran'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local next = next
+local ceil, floor, random, sqrt, cos, sin, pi, max, min = math.ceil, math.floor, math.random, math.sqrt, math.cos, math.sin, math.pi, math.min, math.max
+local remove = table.remove
+
+-- Below is a bit of rainy saturday afternoon hobyism, while listening to Judith
+-- Owens redisCOVERed (came there via Leland Sklar who I have on a few live blurays;
+-- and who is also on YT). (Also nice: https://www.youtube.com/watch?v=GXqasIRaxlA)
+
+-- When Aditya pointed me to an article on mazes I ended up at poison distributions
+-- which to me looks nicer than what I normally do, fill a grid and then randomize
+-- the resulting positions. With some hooks this can be used for interesting patterns
+-- too. A few links:
+--
+-- https://bost.ocks.org/mike/algorithms/#maze-generation
+-- https://extremelearning.com.au/
+-- https://www.jasondavies.com/maps/random-points/
+-- http://devmag.org.za/2009/05/03/poisson-disk-sampling
+
+-- The next function is quite close to what us discribed in the poisson-disk-sampling
+-- link mentioned before. One can either use a one dimensional grid array or a two
+-- dimensional one. The example code uses some classes dealing with points. In the
+-- process I added some more control.
+
+-- we could do without the samplepoints list
+
+local function poisson(width, height, mindist, newpointscount, initialx, initialy)
+ local starttime = os.clock()
+ local cellsize = mindist / sqrt(2)
+ local nofwidth = ceil(width // cellsize)
+ local nofheight = ceil(height // cellsize)
+ local grid = lua.newtable(nofwidth,0) -- table.setmetatableindex("table")
+ local firstx = initialx or random() * width
+ local firsty = initialy or random() * height
+ local firstpoint = { firstx, firsty, 1 }
+ -- local samplepoints = { firstpoint }
+ local processlist = { firstpoint }
+ local nofprocesslist = 1
+ local nofsamplepoints = 1
+ local twopi = 2 * pi
+
+ for i=1,nofwidth do
+ local g = lua.newindex(nofheight,false)
+ grid[i] = g
+ end
+
+ local x = floor(firstx // cellsize) + 1 -- lua indices
+ local y = floor(firsty // cellsize) + 1 -- lua indices
+
+ x = max(1, min(x, width - 1))
+ y = max(1, min(y, height - 1))
+
+ grid[x][y] = firstpoint
+
+ -- The website shows graphic for this 5*5 grid snippet, if we use a one dimentional
+ -- array then we could have one loop; a first version used a metatable trick so we
+ -- had grid[i+gx][j+gy] but we no we also return the grid, so ... we now just check.
+
+ -- There is no need for the samplepoints list as we can get that from the grid but
+ -- instead we can store the index with the grid.
+
+ while nofprocesslist > 0 do
+ local point = remove(processlist,random(1,nofprocesslist))
+ nofprocesslist = nofprocesslist - 1
+ for i=1,newpointscount do -- we start at 1
+ local radius = mindist * (random() + 1)
+ local angle = twopi * random()
+ local nx = point[1] + radius * cos(angle)
+ local ny = point[2] + radius * sin(angle)
+ if nx > 1 and ny > 1 and nx <= width and ny <= height then -- lua indices
+ local gx = floor(nx // cellsize)
+ local gy = floor(ny // cellsize)
+ -- the 5x5 cells around the point
+ for i=-2,2 do
+ for j=-2,2 do
+ local cell = grid[i + gx]
+ if cell then
+ cell = cell[j + gy]
+ if cell and sqrt((cell[1] - nx)^2 + (cell[2] - ny)^2) < mindist then
+ goto next
+ end
+ end
+ end
+ end
+ -- local newpoint = { nx, ny }
+ nofprocesslist = nofprocesslist + 1
+ nofsamplepoints = nofsamplepoints + 1
+ local newpoint = { nx, ny, nofsamplepoints }
+ processlist [nofprocesslist] = newpoint
+ -- samplepoints[nofsamplepoints] = newpoint
+ grid[gx][gy] = newpoint
+ end
+ ::next::
+ end
+ end
+
+ return {
+ count = nofsamplepoints,
+ -- points = samplepoints,
+ grid = grid,
+ time = os.clock() - starttime,
+ }
+end
+
+-- For now:
+
+local randomizers = utilities.randomizers or { }
+utilities.randomizers = randomizers
+randomizers.poisson = poisson
+
+-- The MetaFun interface:
+
+local formatters = string.formatters
+local concat = table.concat
+
+local f_macro = formatters["%s(%N,%N);"]
+
+local f_macros = {
+ [2] = formatters["%s(%N,%N);"],
+ [3] = formatters["%s(%N,%N,%i);"],
+ [4] = formatters["%s(%N,%N,%i,%i);"],
+}
+
+local function grid_to_mp(t,f,n)
+ local grid = t.grid
+ local count = t.count
+ local result = { }
+ local r = 0
+ local macro = f or "draw"
+ local runner = f_macros[n or 2] or f_macros[2]
+ for i=1,#grid do
+ local g = grid[i]
+ if g then
+ for j=1,#g do
+ local v = g[j]
+ if v then
+ r = r + 1
+ result[r] = runner(macro,v[1],v[2],v[3],count)
+ end
+ end
+ end
+ end
+ return concat(result, " ")
+end
+
+local getparameter = metapost.getparameter
+
+local function lmt_poisson()
+ local initialx = getparameter { "initialx" }
+ local initialy = getparameter { "initialy" }
+ local width = getparameter { "width" }
+ local height = getparameter { "height" }
+ local distance = getparameter { "distance" }
+ local count = getparameter { "count" }
+
+ local result = poisson (
+ width, height, distance, count,
+ initialx > 0 and initialx or false,
+ initialy > 0 and initialy or false
+ )
+
+ if result then
+ logs.report("poisson","w=%N, h=%N, d=%N, c=%N, n=%i, runtime %.3f",
+ width, height, distance, count, result.count, result.time
+ )
+ end
+
+ return result
+end
+
+function mp.lmt_poisson_generate()
+ local result = lmt_poisson()
+ if result then
+ return grid_to_mp (
+ result,
+ getparameter { "macro" },
+ getparameter { "arguments" }
+ )
+ end
+end
+
+-- -- some playing around showed no benefit
+--
+-- function points_to_mp(t,f)
+-- local points = t.points
+-- local count = t.count
+-- local result = { }
+-- local r = 0
+-- local macro = f or "draw"
+-- local runner = f_macros[n or 2] or f_macros[2]
+-- for i=1,count do
+-- local v = points[i]
+-- r = r + 1
+-- result[r] = runner(macro,v[1],v[2],v[3],count)
+-- end
+-- return concat(result, " ")
+-- end
+--
+-- local result = false
+-- local i, j, n = 0, 0, 0
+--
+-- function mp.lmt_poison_start()
+-- result = lmt_poisson()
+-- end
+--
+-- function mp.lmt_poisson_stop()
+-- result = false
+-- end
+--
+-- function mp.lmt_poisson_count()
+-- return result and result.count or 0
+-- end
+--
+-- function mp.lmt_poisson_get(i)
+-- if result then
+-- return mp.pair(result.points[i])
+-- end
+-- end
+--
+-- function mp.lmt_poisson_generate()
+-- mp.lmt_poisson_start()
+-- if result then
+-- return grid_to_mp (
+-- result,
+-- getparameter { "macro" },
+-- getparameter { "arguments" }
+-- )
+-- end
+-- mp.lmt_poisson_stop()
+-- end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-run.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-run.lmt
new file mode 100644
index 00000000000..eacb148cc6c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-run.lmt
@@ -0,0 +1,722 @@
+if not modules then modules = { } end modules ['mlib-run'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- cmyk -> done, native
+-- spot -> done, but needs reworking (simpler)
+-- multitone ->
+-- shade -> partly done, todo: cm
+-- figure -> done
+-- hyperlink -> low priority, easy
+
+-- new * run
+-- or
+-- new * execute^1 * finish
+
+-- a*[b,c] == b + a * (c-b)
+
+--[[ldx--
+
The directional helpers and pen analysis are more or less translated from the
+ code. It really helps that Taco know that source so well. Taco and I spent
+quite some time on speeding up the and code. There is not
+much to gain, especially if one keeps in mind that when integrated in
+only a part of the time is spent in . Of course an integrated
+approach is way faster than an external and processing time
+nears zero.
+--ldx]]--
+
+local type, tostring, tonumber, next = type, tostring, tonumber, next
+local find, striplines = string.find, utilities.strings.striplines
+local concat, insert, remove, sortedkeys = table.concat, table.insert, table.remove, table.sortedkeys
+
+local emptystring = string.is_empty
+
+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 report_metapost = logs.reporter("metapost")
+local texerrormessage = logs.texerrormessage
+
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
+local formatters = string.formatters
+
+local mplib = mplib
+metapost = metapost or { }
+local metapost = metapost
+
+metapost.showlog = false
+metapost.lastlog = ""
+metapost.texerrors = false
+metapost.exectime = metapost.exectime or { } -- hack
+metapost.nofruns = 0
+
+local mpxformats = { }
+local nofformats = 0
+local mpxpreambles = { }
+local mpxterminals = { }
+local mpxextradata = { }
+
+-- The flatten hack is needed because the library currently barks on \n\n and the
+-- collapse because mp cannot handle snippets due to grouping issues.
+
+-- todo: pass tables to executempx instead of preparing beforehand,
+-- as it's more efficient for the terminal
+
+local function flatten(source,target)
+ for i=1,#source do
+ local d = source[i]
+ if type(d) == "table" then
+ flatten(d,target)
+ elseif d and d ~= "" then
+ target[#target+1] = d
+ end
+ end
+ return target
+end
+
+local function prepareddata(data)
+ if data and data ~= "" then
+ if type(data) == "table" then
+ data = flatten(data,{ })
+ data = #data > 1 and concat(data,"\n") or data[1]
+ end
+ return data
+ end
+end
+
+-- local function executempx(mpx,data)
+-- local terminal = mpxterminals[mpx]
+-- if terminal then
+-- terminal.writer(data)
+-- data = ""
+-- elseif type(data) == "table" then
+-- data = prepareddata(data,collapse)
+-- end
+-- metapost.nofruns = metapost.nofruns + 1
+-- return mpx:execute(data)
+-- end
+
+local function executempx(mpx,data)
+ local terminal = mpxterminals[mpx]
+ if terminal then
+ terminal.writer(data)
+ data = nil
+ elseif type(data) == "table" then
+ data = prepareddata(data,collapse)
+ end
+ metapost.nofruns = metapost.nofruns + 1
+ return mpx:execute(data)
+end
+
+directives.register("mplib.texerrors", function(v) metapost.texerrors = v end)
+trackers.register ("metapost.showlog", function(v) metapost.showlog = v end)
+
+function metapost.resetlastlog()
+ metapost.lastlog = ""
+end
+
+local new_instance = mplib.new
+local find_file = mplib.finder
+
+function metapost.reporterror(result)
+ if not result then
+ report_metapost("error: no result object returned")
+ return true
+ elseif result.status == 0 then
+ return false
+ elseif mplib.realtimelogging then
+ return false -- we already reported
+ else
+ local t = result.term
+ local e = result.error
+ local l = result.log
+ local report = metapost.texerrors and texerrormessage or report_metapost
+ if t and t ~= "" then
+ report("mp error: %s",striplines(t))
+ end
+ if e == "" or e == "no-error" then
+ e = nil
+ end
+ if e then
+ report("mp error: %s",striplines(e))
+ end
+ if not t and not e and l then
+ metapost.lastlog = metapost.lastlog .. "\n" .. l
+ report_metapost("log: %s",l)
+ else
+ report_metapost("error: unknown, no error, terminal or log messages")
+ end
+ return true
+ end
+end
+
+local f_preamble = formatters [ [[
+ boolean mplib ; mplib := true ;
+ let dump = endinput ;
+ input "%s" ;
+ randomseed:=%s;
+]] ]
+
+local methods = {
+ double = "double",
+ scaled = "scaled",
+ -- binary = "binary",
+ binary = "double",
+ decimal = "decimal",
+ default = "scaled",
+}
+
+function metapost.runscript(code)
+ return ""
+end
+
+function metapost.scripterror(str)
+ report_metapost("script error: %s",str)
+end
+
+-- todo: random_seed
+
+local seed = nil
+
+function metapost.load(name,method)
+ starttiming(mplib)
+ if not seed then
+ seed = job.getrandomseed()
+ if seed <= 1 then
+ seed = seed % 1000
+ elseif seed > 4095 then
+ seed = seed % 4096
+ end
+ end
+ method = method and methods[method] or "scaled"
+ local mpx, terminal = new_instance {
+-- noninteractive = true;
+-- ini_version = true,
+ math_mode = method,
+ run_script = metapost.runscript,
+ script_error = metapost.scripterror,
+ make_text = metapost.maketext,
+ extensions = 1,
+ -- random_seed = seed,
+ utf8_mode = true,
+ text_mode = true,
+ }
+ report_metapost("initializing number mode %a",method)
+ local result
+ if not mpx then
+ result = { status = 99, error = "out of memory"}
+ else
+ mpxterminals[mpx] = terminal
+ -- pushing permits advanced features
+ metapost.pushscriptrunner(mpx)
+ result = executempx(mpx,f_preamble(file.addsuffix(name,"mp"),seed))
+ metapost.popscriptrunner()
+ end
+ stoptiming(mplib)
+ metapost.reporterror(result)
+ return mpx, result
+end
+
+function metapost.checkformat(mpsinput,method)
+ local mpsinput = mpsinput or "metafun"
+ local foundfile = ""
+ if file.suffix(mpsinput) ~= "" then
+ foundfile = find_file(mpsinput) or ""
+ end
+ -- if foundfile == "" then
+ -- foundfile = find_file(file.replacesuffix(mpsinput,"mpvi")) or ""
+ -- end
+ if foundfile == "" then
+ foundfile = find_file(file.replacesuffix(mpsinput,"mpxl")) or ""
+ end
+ if foundfile == "" then
+ foundfile = find_file(file.replacesuffix(mpsinput,"mpiv")) or ""
+ end
+ if foundfile == "" then
+ foundfile = find_file(file.replacesuffix(mpsinput,"mp")) or ""
+ end
+ if foundfile == "" then
+ report_metapost("loading %a fails, format not found",mpsinput)
+ else
+ report_metapost("loading %a as %a using method %a",mpsinput,foundfile,method or "default")
+ local mpx, result = metapost.load(foundfile,method)
+ if mpx then
+ return mpx
+ else
+ report_metapost("error in loading %a",mpsinput)
+ metapost.reporterror(result)
+ end
+ end
+end
+
+function metapost.unload(mpx)
+ starttiming(mplib)
+ if mpx then
+ mpx:finish()
+ end
+ stoptiming(mplib)
+end
+
+metapost.defaultformat = "metafun"
+metapost.defaultinstance = "metafun"
+metapost.defaultmethod = "default"
+
+function metapost.getextradata(mpx)
+ return mpxextradata[mpx]
+end
+
+function metapost.pushformat(specification,f,m) -- was: instance, name, method
+ if type(specification) ~= "table" then
+ specification = {
+ instance = specification,
+ format = f,
+ method = m,
+ }
+ end
+ local instance = specification.instance
+ local format = specification.format
+ local method = specification.method
+ local definitions = specification.definitions
+ local extensions = specification.extensions
+ local preamble = nil
+ if not instance or instance == "" then
+ instance = metapost.defaultinstance
+ specification.instance = instance
+ end
+ if not format or format == "" then
+ format = metapost.defaultformat
+ specification.format = format
+ end
+ if not method or method == "" then
+ method = metapost.defaultmethod
+ specification.method = method
+ end
+ if definitions and definitions ~= "" then
+ preamble = definitions
+ end
+ if extensions and extensions ~= "" then
+ if preamble then
+ preamble = preamble .. "\n" .. extensions
+ else
+ preamble = extensions
+ end
+ end
+ nofformats = nofformats + 1
+ local usedinstance = instance .. ":" .. nofformats
+ local mpx = mpxformats [usedinstance]
+ local mpp = mpxpreambles[instance] or ""
+ -- report_metapost("push instance %a (%S)",usedinstance,mpx)
+ if preamble then
+ preamble = prepareddata(preamble)
+ mpp = mpp .. "\n" .. preamble
+ mpxpreambles[instance] = mpp
+ end
+ if not mpx then
+ report_metapost("initializing instance %a using format %a and method %a",usedinstance,format,method)
+ mpx = metapost.checkformat(format,method)
+ mpxformats [usedinstance] = mpx
+ mpxextradata[mpx] = { }
+ if mpp ~= "" then
+ preamble = mpp
+ end
+ end
+ if preamble then
+ metapost.pushscriptrunner(mpx)
+ executempx(mpx,preamble)
+ metapost.popscriptrunner()
+ end
+ specification.mpx = mpx
+ return mpx
+end
+
+-- luatex.wrapup(function()
+-- for k, mpx in next, mpxformats do
+-- mpx:finish()
+-- end
+-- end)
+
+function metapost.popformat()
+ nofformats = nofformats - 1
+end
+
+function metapost.reset(mpx)
+ if not mpx then
+ -- nothing
+ elseif type(mpx) == "string" then
+ if mpxformats[mpx] then
+ local instance = mpxformats[mpx]
+ instance:finish()
+ mpxterminals[mpx] = nil
+ mpxextradata[mpx] = nil
+ mpxformats [mpx] = nil
+ end
+ else
+ for name, instance in next, mpxformats do
+ if instance == mpx then
+ mpx:finish()
+ mpxterminals[mpx] = nil
+ mpxextradata[mpx] = nil
+ mpxformats [mpx] = nil
+ break
+ end
+ end
+ end
+end
+
+local mp_tra = { }
+local mp_tag = 0
+
+-- key/values
+
+do
+
+ local stack, top = { }, nil
+
+ function metapost.setvariable(k,v)
+ if top then
+ top[k] = v
+ else
+ metapost.variables[k] = v
+ end
+ end
+
+ function metapost.pushvariable(k)
+ local t = { }
+ if top then
+ insert(stack,top)
+ top[k] = t
+ else
+ metapost.variables[k] = t
+ end
+ top = t
+ end
+
+ function metapost.popvariable()
+ top = remove(stack)
+ end
+
+ local stack = { }
+
+ function metapost.pushvariables()
+ insert(stack,metapost.variables)
+ metapost.variables = { }
+ end
+
+ function metapost.popvariables()
+ metapost.variables = remove(stack) or metapost.variables
+ end
+
+end
+
+
+if not metapost.process then
+
+ function metapost.process(specification)
+ metapost.run(specification)
+ end
+
+end
+
+-- run, process, convert and flush all work with a specification with the
+-- following (often optional) fields
+--
+-- mpx string or mp object
+-- data string or table of strings
+-- flusher table with flush methods
+-- askedfig string ("all" etc) or number
+-- incontext boolean
+-- plugmode boolean
+
+local function makebeginbanner(specification)
+ return formatters["%% begin graphic: n=%s\n\n"](metapost.n)
+end
+
+local function makeendbanner(specification)
+ return "\n% end graphic\n\n"
+end
+
+function metapost.run(specification)
+ local mpx = specification.mpx
+ local data = specification.data
+ local converted = false
+ local result = { }
+ local mpxdone = type(mpx) == "string"
+ if mpxdone then
+ mpx = metapost.pushformat { instance = mpx, format = mpx }
+ end
+ if mpx and data then
+ local tra = nil
+ starttiming(metapost) -- why not at the outer level ...
+ metapost.variables = { } -- todo also push / pop
+ metapost.pushscriptrunner(mpx)
+ if trace_graphics then
+ tra = mp_tra[mpx]
+ if not tra then
+ mp_tag = mp_tag + 1
+ local jobname = tex.jobname
+ tra = {
+ inp = io.open(formatters["%s-mplib-run-%03i.mp"] (jobname,mp_tag),"w"),
+ log = io.open(formatters["%s-mplib-run-%03i.log"](jobname,mp_tag),"w"),
+ }
+ mp_tra[mpx] = tra
+ end
+ local banner = makebeginbanner(specification)
+ tra.inp:write(banner)
+ tra.log:write(banner)
+ end
+ local function process(d,i)
+ if d then
+ if trace_graphics then
+ if i then
+ tra.inp:write(formatters["\n%% begin snippet %s\n"](i))
+ end
+ if type(d) == "table" then
+ for i=1,#d do
+ tra.inp:write(d[i])
+ end
+ else
+ tra.inp:write(d)
+ end
+ if i then
+ tra.inp:write(formatters["\n%% end snippet %s\n"](i))
+ end
+ end
+ starttiming(metapost.exectime)
+ result = executempx(mpx,d)
+ stoptiming(metapost.exectime)
+ if trace_graphics and result then
+ local str = result.log or result.error
+ if str and str ~= "" then
+ tra.log:write(str)
+ end
+ end
+ if not metapost.reporterror(result) then
+ if metapost.showlog then
+ -- make function and overload in lmtx
+ local str = result.term ~= "" and result.term or "no terminal output"
+ if not emptystring(str) then
+ metapost.lastlog = metapost.lastlog .. "\n" .. str
+ report_metapost("log: %s",str)
+ end
+ end
+ if result.fig then
+ converted = metapost.convert(specification,result)
+ end
+ end
+ elseif i then
+ report_metapost("error: invalid graphic component %s",i)
+ else
+ report_metapost("error: invalid graphic")
+ end
+ end
+
+-- local data = prepareddata(data)
+ if type(data) == "table" then
+ if trace_tracingall then
+ executempx(mpx,"tracingall;")
+ end
+ process(data)
+-- for i=1,#data do
+-- process(data[i],i)
+-- end
+ else
+ if trace_tracingall then
+ data = "tracingall;" .. data
+ end
+ process(data)
+ end
+ if trace_graphics then
+ local banner = makeendbanner(specification)
+ tra.inp:write(banner)
+ tra.log:write(banner)
+ end
+ stoptiming(metapost)
+ metapost.popscriptrunner()
+ end
+ if mpxdone then
+ metapost.popformat()
+ end
+ return converted, result
+end
+
+if not metapost.convert then
+
+ function metapost.convert()
+ report_metapost('warning: no converter set')
+ end
+
+end
+
+-- This will be redone as we no longer output svg of ps!
+
+-- function metapost.directrun(formatname,filename,outputformat,astable,mpdata)
+-- local fullname = file.addsuffix(filename,"mp")
+-- local data = mpdata or io.loaddata(fullname)
+-- if outputformat ~= "svg" then
+-- outputformat = "mps"
+-- end
+-- if not data then
+-- report_metapost("unknown file %a",filename)
+-- else
+-- local mpx = metapost.checkformat(formatname)
+-- if not mpx then
+-- report_metapost("unknown format %a",formatname)
+-- else
+-- report_metapost("processing %a",(mpdata and (filename or "data")) or fullname)
+-- local result = executempx(mpx,data)
+-- if not result then
+-- report_metapost("error: no result object returned")
+-- elseif result.status > 0 then
+-- report_metapost("error: %s",(result.term or "no-term") .. "\n" .. (result.error or "no-error"))
+-- else
+-- if metapost.showlog then
+-- metapost.lastlog = metapost.lastlog .. "\n" .. result.term
+-- report_metapost("info: %s",result.term or "no-term")
+-- end
+-- local figures = result.fig
+-- if figures then
+-- local sorted = table.sortedkeys(figures)
+-- if astable then
+-- local result = { }
+-- report_metapost("storing %s figures in table",#sorted)
+-- for k=1,#sorted do
+-- local v = sorted[k]
+-- if outputformat == "mps" then
+-- result[v] = figures[v]:postscript()
+-- else
+-- result[v] = figures[v]:svg() -- (3) for prologues
+-- end
+-- end
+-- return result
+-- else
+-- local basename = file.removesuffix(file.basename(filename))
+-- for k=1,#sorted do
+-- local v = sorted[k]
+-- local output
+-- if outputformat == "mps" then
+-- output = figures[v]:postscript()
+-- else
+-- output = figures[v]:svg() -- (3) for prologues
+-- end
+-- local outname = formatters["%s-%s.%s"](basename,v,outputformat)
+-- report_metapost("saving %s bytes in %a",#output,outname)
+-- io.savedata(outname,output)
+-- end
+-- return #sorted
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+
+function metapost.directrun(formatname,filename,outputformat,astable,mpdata)
+ report_metapost("producing postscript and svg is no longer supported")
+end
+
+do
+
+ local result = { }
+ local width = 0
+ local height = 0
+ local depth = 0
+ local bbox = { 0, 0, 0, 0 }
+
+ local flusher = {
+ startfigure = function(n,llx,lly,urx,ury)
+ result = { }
+ width = urx - llx
+ height = ury
+ depth = -lly
+ bbox = { llx, lly, urx, ury }
+ end,
+ flushfigure = function(t)
+ local r = #result
+ for i=1,#t do
+ r = r + 1
+ result[r] = t[i]
+ end
+ end,
+ stopfigure = function()
+ end,
+ }
+
+ -- make table variant:
+
+ function metapost.simple(instance,code,useextensions,dontwrap)
+ -- can we pickup the instance ?
+ local mpx = metapost.pushformat {
+ instance = instance or "simplefun",
+ format = "metafun", -- or: minifun
+ method = "double",
+ }
+-- if not code then
+-- code = ""
+-- end
+ metapost.process {
+ mpx = mpx,
+ flusher = flusher,
+ askedfig = 1,
+ useplugins = useextensions,
+ data = dontwrap and { code } or { "beginfig(1);", code, "endfig;" },
+ incontext = false,
+ }
+ metapost.popformat()
+ if result then
+ local stream = concat(result," ")
+ result = { } -- nil -- cleanup .. weird, we can have a dangling q
+ return stream, width, height, depth, bbox
+ else
+ return "", 0, 0, 0, { 0, 0, 0, 0 }
+ end
+ end
+
+end
+
+local getstatistics = mplib.getstatistics
+
+function metapost.getstatistics(memonly)
+ if memonly then
+ local n, m = 0, 0
+ for name, mpx in next, mpxformats do
+ n = n + 1
+ m = m + getstatistics(mpx).memory
+ end
+ return n, m
+ else
+ local t = { }
+ for name, mpx in next, mpxformats do
+ t[name] = getstatistics(mpx)
+ end
+ return t
+ end
+end
+
+local gethashentries = mplib.gethashentries
+
+function metapost.gethashentries(name,full)
+ if name then
+ local mpx = mpxformats[name] or mpxformats[name .. ":1"]
+ if mpx then
+ return gethashentries(mpx,full)
+ end
+ else
+ local t = { }
+ for name, mpx in next, mpxformats do
+ t[name] = gethashtokens(mpx,full)
+ end
+ return t
+ end
+end
+
+local gethashtokens = mplib.gethashtokens
+
+function metapost.getinstancenames()
+ return sortedkeys(mpxformats)
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-scn.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-scn.lmt
new file mode 100644
index 00000000000..e68abf5873c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-scn.lmt
@@ -0,0 +1,799 @@
+if not modules then modules = { } end modules ['mlib-scn'] = {
+ version = 1.001,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- Very experimental, for Alan and me.
+
+-- for i = 1 upto 32000 : % 0.062
+-- ts := 5mm / 20;
+-- endfor ;
+--
+-- for i = 1 upto 32000 : % 0.219
+-- ts := (getparameter "axis" "sy") / 20;
+-- endfor ;
+--
+-- for i = 1 upto 32000 : % 0.266
+-- ts := (getparameterx "axis" "sy") / 20;
+-- endfor ;
+--
+-- pushparameters "axis";
+-- for i = 1 upto 32000 : % 0.250
+-- ts := (getparameterx "sy") / 20;
+-- endfor ;
+-- popparameters;
+
+local type, next, rawget, getmetatable, tonumber = type, next, rawget, getmetatable, tonumber
+local byte, gmatch = string.byte, string.gmatch
+local insert, remove = table.insert, table.remove
+
+local mplib = mplib
+local metapost = metapost
+
+local codes = metapost.codes
+local types = metapost.types
+
+local setmetatableindex = table.setmetatableindex
+
+local scanners = mp.scan
+local injectors = mp.inject
+
+local scannext = scanners.next
+local scanexpression = scanners.expression
+local scantoken = scanners.token
+local scansymbol = scanners.symbol
+local scanproperty = scanners.property
+local scannumeric = scanners.numeric
+local scannumber = scanners.number
+local scaninteger = scanners.integer
+local scanboolean = scanners.boolean
+local scanstring = scanners.string
+local scanpair = scanners.pair
+local scancolor = scanners.color
+local scancmykcolor = scanners.cmykcolor
+local scantransform = scanners.transform
+local scanpath = scanners.path
+local scanpen = scanners.pen
+
+local mpprint = mp.print
+local injectnumeric = injectors.numeric
+local injectstring = injectors.string
+local injectboolean = injectors.boolean
+local injectpair = injectors.pair
+local injecttriplet = injectors.color
+local injectquadruple = injectors.cmykcolor
+local injecttransform = injectors.transform
+local injectpath = injectors.path
+
+local report = logs.reporter("metapost")
+
+local semicolon_code = codes.semicolon
+local equals_code = codes.equals
+local comma_code = codes.comma
+local colon_code = codes.colon
+local leftbrace_code = codes.leftbrace
+local rightbrace_code = codes.rightbrace
+local leftbracket_code = codes.leftbracket
+local rightbracket_code = codes.rightbracket
+local leftdelimiter_code = codes.leftdelimiter
+local rightdelimiter_code = codes.rightdelimiter
+local numeric_code = codes.numeric
+local string_code = codes.string
+local capsule_code = codes.capsule
+local nullary_code = codes.nullary
+local tag_code = codes.tag
+local definedmacro_code = codes.definedmacro
+
+local typescanners = nil
+local tokenscanners = nil
+local scanset = nil
+local scanparameters = nil
+
+scanset = function() -- can be optimized, we now read twice
+ scantoken()
+ if scantoken(true) == rightbrace_code then
+ scantoken()
+ return { }
+ else
+ local l = { }
+ local i = 0
+ while true do
+ i = i + 1
+ local s = scansymbol(true)
+ if s == "{" then
+ l[i] = scanset()
+ elseif s == "[" then
+ local d = { }
+ scansymbol()
+ while true do
+ local s = scansymbol()
+ if s == "]" then
+ break;
+ elseif s == "," then
+ -- continue
+ else
+ local t = scantoken(true)
+ if t == equals_code or t == colon_code then
+ scantoken()
+ end
+ d[s] = tokenscanners[scantoken(true)]()
+ end
+ end
+ l[i] = d
+ else
+ local e = scanexpression(true)
+ l[i] = (typescanners[e] or scanexpression)()
+ end
+ if scantoken() == rightbrace_code then
+ break
+ else
+ -- whatever
+ end
+ end
+ return l
+ end
+end
+
+local function scan_pair () return scanpair (true) end
+local function scan_color () return scancolor (true) end
+local function scan_cmykcolor() return scancmykcolor(true) end
+local function scan_transform() return scantransform(true) end
+
+tokenscanners = {
+ [leftbrace_code] = scanset,
+ [numeric_code] = scannumeric,
+ [string_code] = scanstring,
+ [nullary_code] = scanboolean, -- todo
+}
+
+typescanners = {
+ [types.known] = scannumeric,
+ [types.numeric] = scannumeric,
+ [types.string] = scanstring,
+ [types.boolean] = scanboolean,
+ [types.pair] = scan_pair,
+ [types.color] = scan_color,
+ [types.cmykcolor] = scan_cmykcolor,
+ [types.transform] = scan_transform,
+ [types.path] = scanpath,
+ [types.pen] = scanpen,
+}
+
+table.setmetatableindex(tokenscanners,function()
+ local e = scanexpression(true)
+ return typescanners[e] or scanexpression
+end)
+
+-- a key like 'color' has code 'declare'
+
+local function scanparameters(fenced)
+ local data = { }
+ local close = "]"
+ if not fenced then
+ close = ";"
+ elseif scansymbol(true) == "[" then
+ scansymbol()
+ else
+ return data
+ end
+ while true do
+ -- local s = scansymbol()
+ local s = scansymbol(false,false)
+ if s == close then
+ break;
+ elseif s == "," then
+ -- continue
+ else
+ local t = scantoken(true)
+ if t == equals_code or t == colon_code then
+ -- optional equal or :
+ scantoken()
+ end
+ local kind = scantoken(true)
+ if kind == leftdelimiter_code or kind == tag_code or kind == capsule_code then
+ kind = scanexpression(true)
+ data[s] = (typescanners[kind] or scanexpression)()
+ elseif kind == leftbracket_code then
+ data[s] = get_parameters(true)
+ else
+ data[s] = tokenscanners[kind]()
+ end
+ end
+ end
+ return data
+end
+
+local namespaces = { }
+local presets = { }
+local passed = { }
+
+local function get_parameters(nested)
+ local data = { }
+ if nested or scansymbol(true) == "[" then
+ scansymbol()
+ else
+ return data
+ end
+ while true do
+ local s = scansymbol(false,false)
+ if s == "]" then
+ break;
+ elseif s == "," then
+ -- continue
+ else
+ local t = scantoken(true)
+ if t == equals_code or t == colon_code then
+ -- optional equal or :
+ scantoken()
+ end
+ local kind = scantoken(true)
+ if kind == leftdelimiter_code or kind == tag_code or kind == capsule_code then
+ kind = scanexpression(true)
+ data[s] = (typescanners[kind] or scanexpression)()
+ elseif kind == leftbracket_code then
+ data[s] = get_parameters(true)
+ else
+ data[s] = tokenscanners[kind]()
+ end
+ end
+ end
+ return data
+end
+
+local function getparameters()
+ local namespace = scanstring()
+ -- same as below
+ local parameters = get_parameters()
+ local presets = presets[namespace]
+ local passed = passed[namespace]
+ if passed then
+ if presets then
+ setmetatableindex(passed,presets)
+ end
+ setmetatableindex(parameters,passed)
+ elseif presets then
+ setmetatableindex(parameters,presets)
+ end
+ namespaces[namespace] = parameters
+ --
+end
+
+local function applyparameters()
+ local saved = namespaces
+ local namespace = scanstring()
+ local action = scanstring() -- before we scan the parameters
+ -- same as above
+ local parameters = get_parameters()
+ local presets = presets[namespace]
+ local passed = passed[namespace]
+ if passed then
+ if presets then
+ setmetatableindex(passed,presets)
+ end
+ setmetatableindex(parameters,passed)
+ elseif presets then
+ setmetatableindex(parameters,presets)
+ end
+ namespaces[namespace] = parameters
+ -- till here
+ mpprint(action)
+ namespaces = saved
+end
+
+local knownparameters = { }
+metapost.knownparameters = knownparameters
+
+local function presetparameters()
+ local namespace = scanstring()
+ local parent = nil
+ local t = scantoken(true)
+ if t == string_code then
+ parent = presets[scanstring()]
+ end
+ local p = get_parameters()
+ for k in next, p do
+ knownparameters[k] = true
+ end
+ if parent then
+ setmetatableindex(p,parent)
+ end
+ presets[namespace] = p
+end
+
+local function collectnames()
+ local l = { } -- can be reused but then we can't nest
+ local n = 0
+ while true do
+ local t = scantoken(true)
+ -- (1) not really needed
+ if t == numeric_code then
+ n = n + 1 l[n] = scaninteger(1)
+ elseif t == string_code then
+ n = n + 1 l[n] = scanstring(1)
+ elseif t == nullary_code then
+ n = n + 1 l[n] = scanboolean(1)
+ elseif t == leftbracket_code then
+ scantoken() -- leftbacket
+ n = n + 1 l[n] = scaninteger(1)
+ scantoken() -- rightbacket
+ elseif t == leftdelimiter_code or t == tag_code or t == capsule_code then
+ t = scanexpression(true)
+ n = n + 1 l[n] = (typescanners[t] or scanexpression)()
+ else
+ break
+ end
+ end
+ return l, n
+end
+
+local function get(v)
+ local t = type(v)
+ if t == "number" then
+ return injectnumeric(v)
+ elseif t == "boolean" then
+ return injectboolean(v)
+ elseif t == "string" then
+ return injectstring(v)
+ elseif t == "table" then
+ local n = #v
+ if type(v[1]) == "table" then
+ return injectpath(v)
+ elseif n == 2 then
+ return injectpair(v)
+ elseif n == 3 then
+ return injecttriplet(v)
+ elseif n == 4 then
+ return injectquadruple(v)
+ elseif n == 6 then
+ return injecttransform(v)
+ end
+ end
+ return injectnumeric(0)
+end
+
+local stack = { }
+
+local function pushparameters()
+ local l, n = collectnames()
+ insert(stack,namespaces)
+ for i=1,n do
+ local n = namespaces[l[i]]
+ if type(n) == "table" then
+ namespaces = n
+ else
+ break
+ end
+ end
+end
+
+local function popparameters()
+ local n = remove(stack)
+ if n then
+ namespaces = n
+ else
+ report("stack error")
+ end
+end
+
+-- todo:
+
+local function getparameter()
+ local list, n = collectnames()
+ local v = namespaces
+ for i=1,n do
+ local l = list[i]
+ local vl = v[l]
+ if vl == nil then
+ if type(l) == "number" then
+ vl = v[1]
+ if vl == nil then
+ return injectnumeric(0)
+ end
+ else
+ return injectnumeric(0)
+ end
+ end
+ v = vl
+ end
+ if v == nil then
+ return injectnumeric(0)
+ else
+ return get(v)
+ end
+end
+
+local function hasparameter()
+ local list, n = collectnames()
+ local v = namespaces
+ for i=1,n do
+ local l = list[i]
+ local vl = rawget(v,l)
+ if vl == nil then
+ if type(l) == "number" then
+ vl = rawget(v,1)
+ if vl == nil then
+ return injectboolean(false)
+ end
+ else
+ return injectboolean(false)
+ end
+ end
+ v = vl
+ end
+ if v == nil then
+ return injectboolean(false)
+ else
+ return injectboolean(true)
+ end
+end
+
+local function hasoption()
+ local list, n = collectnames()
+ if n > 1 then
+ local v = namespaces
+ if n > 2 then
+ for i=1,n-1 do
+ local l = list[i]
+ local vl = v[l]
+ if vl == nil then
+ return injectboolean(false)
+ end
+ v = vl
+ end
+ else
+ v = v[list[1]]
+ end
+ if type(v) == "string" then
+ -- no caching .. slow anyway
+ local o = list[n]
+ if v == o then
+ return injectboolean(true)
+ end
+ for vv in gmatch(v,"[^%s,]+") do
+ for oo in gmatch(o,"[^%s,]+") do
+ if vv == oo then
+ return injectboolean(true)
+ end
+ end
+ end
+ end
+ end
+ return injectboolean(false)
+end
+
+local function getparameterdefault()
+ local list, n = collectnames()
+ local v = namespaces
+ if n == 1 then
+ local l = list[1]
+ local vl = v[l]
+ if vl == nil then
+ -- maybe backtrack
+ local top = stack[#stack]
+ if top then
+ vl = top[l]
+ end
+ end
+ if vl == nil then
+ return injectnumeric(0)
+ else
+ if type(vl) == "string" then
+ local td = type(list[n])
+ if td == "number" then
+ vl = tonumber(vl)
+ elseif td == "boolean" then
+ vl = vl == "true"
+ end
+ end
+ return get(vl)
+ end
+ else
+ for i=1,n-1 do
+ local l = list[i]
+ local vl = v[l]
+ if vl == nil then
+ if type(l) == "number" then
+ vl = v[1]
+ if vl == nil then
+ return get(list[n])
+ end
+ else
+ local last = list[n]
+ if last == "*" then
+ -- so, only when not pushed
+ local m = getmetatable(namespaces[list[1]])
+ if n then
+ m = m.__index -- can also be a _m_
+ end
+ if m then
+ local v = m
+ for i=2,n-1 do
+ local l = list[i]
+ local vl = v[l]
+ if vl == nil then
+ return injectnumeric(0)
+ end
+ v = vl
+ end
+ if v == nil then
+ return injectnumeric(0)
+ else
+ return get(v)
+ end
+ end
+ return injectnumeric(0)
+ else
+ return get(last)
+ end
+ end
+ end
+ v = vl
+ end
+ if v == nil then
+ return get(list[n])
+ else
+ if type(v) == "string" then
+ local td = type(list[n])
+ if td == "number" then
+ v = tonumber(v)
+ elseif td == "boolean" then
+ v = v == "true"
+ end
+ end
+ return get(v)
+ end
+ end
+end
+
+local function getparametercount()
+ local list, n = collectnames()
+ local v = namespaces
+ for i=1,n do
+ v = v[list[i]]
+ if not v then
+ break
+ end
+ end
+ return injectnumeric(type(v) == "table" and #v or 0)
+end
+
+local function getmaxparametercount()
+ local list, n = collectnames()
+ local v = namespaces
+ for i=1,n do
+ v = v[list[i]]
+ if not v then
+ break
+ end
+ end
+ local n = 0
+ if type(v) == "table" then
+ local v1 = v[1]
+ if type(v1) == "table" then
+ n = #v1
+ for i=2,#v do
+ local vi = v[i]
+ if type(vi) == "table" then
+ local vn = #vi
+ if vn > n then
+ n = vn
+ end
+ else
+ break;
+ end
+ end
+ end
+
+ end
+ return injectnumeric(n)
+end
+
+local validconnectors = {
+ [".."] = true,
+ ["..."] = true,
+ ["--"] = true,
+}
+
+local function getparameterpath()
+ local list, n = collectnames()
+ local close = list[n]
+ if type(close) == "boolean" then
+ n = n - 1
+ else
+ close = false
+ end
+ local connector = list[n]
+ if type(connector) == "string" and validconnectors[connector] then
+ n = n - 1
+ else
+ connector = "--"
+ end
+ local v = namespaces
+ for i=1,n do
+ v = v[list[i]]
+ if not v then
+ break
+ end
+ end
+ if type(v) == "table" then
+ return injectpath(v,connector,close)
+ else
+ return injectpair(0,0)
+ end
+end
+
+local function getparameterpen()
+ local list, n = collectnames()
+ local v = namespaces
+ for i=1,n do
+ v = v[list[i]]
+ if not v then
+ break
+ end
+ end
+ if type(v) == "table" then
+ return injectpath(v,"..",true)
+ else
+ return injectpair(0,0)
+ end
+end
+
+local function getparametertext()
+ local list, n = collectnames()
+ local strut = list[n]
+ if type(strut) == "boolean" then
+ n = n - 1
+ else
+ strut = false
+ end
+ local v = namespaces
+ for i=1,n do
+ v = v[list[i]]
+ if not v then
+ break
+ end
+ end
+ if type(v) == "string" then
+ return injectstring("\\strut " .. v)
+ else
+ return injectstring("")
+ end
+end
+
+-- local function getparameteroption()
+-- local list, n = collectnames()
+-- local last = list[n]
+-- if type(last) == "string" then
+-- n = n - 1
+-- else
+-- return false
+-- end
+-- local v = namespaces
+-- for i=1,n do
+-- v = v[list[i]]
+-- if not v then
+-- break
+-- end
+-- end
+-- if type(v) == "string" and v ~= "" then
+-- for s in gmatch(v,"[^ ,]+") do
+-- if s == last then
+-- return true
+-- end
+-- end
+-- end
+-- return false
+-- end
+
+function metapost.scanparameters()
+-- scantoken() -- we scan the semicolon
+ return get_parameters()
+end
+
+local registerscript = metapost.registerscript
+
+registerscript("getparameters", getparameters)
+registerscript("applyparameters", applyparameters)
+registerscript("presetparameters", presetparameters)
+registerscript("hasparameter", hasparameter)
+registerscript("hasoption", hasoption)
+registerscript("getparameter", getparameter)
+registerscript("getparameterdefault", getparameterdefault)
+registerscript("getparametercount", getparametercount)
+registerscript("getmaxparametercount",getmaxparametercount)
+registerscript("getparameterpath", getparameterpath)
+registerscript("getparameterpen", getparameterpen)
+registerscript("getparametertext", getparametertext)
+--------------("getparameteroption", getparameteroption)
+registerscript("pushparameters", pushparameters)
+registerscript("popparameters", popparameters)
+
+function metapost.getparameter(list)
+ local n = #list
+ local v = namespaces
+ for i=1,n do
+ local l = list[i]
+ local vl = v[l]
+ if vl == nil then
+ return
+ end
+ v = vl
+ end
+ return v
+end
+
+function metapost.getparameterset(namespace)
+ return namespace and namespaces[namespace] or namespaces
+end
+
+function metapost.setparameterset(namespace,t)
+ namespaces[namespace] = t
+end
+
+-- goodies
+
+registerscript("definecolor", function()
+ scantoken() -- we scan the semicolon
+ local s = get_parameters()
+ attributes.colors.defineprocesscolordirect(s)
+end)
+
+-- tex scanners
+
+local scanners = tokens.scanners
+local scanhash = scanners.hash
+local scanstring = scanners.string
+local scanvalue = scanners.value
+local scaninteger = scanners.integer
+local scanboolean = scanners.boolean
+local scanfloat = scanners.float
+local scandimension = scanners.dimension
+
+local definitions = { }
+
+local bpfactor = number.dimenfactors.bp
+local comma = byte(",")
+local close = byte("]")
+
+local scanrest = function() return scanvalue(comma,close) or "" end
+local scandimension = function() return scandimension() * bpfactor end
+
+local scanners = {
+ ["integer"] = scaninteger,
+ ["number"] = scanfloat,
+ ["numeric"] = scanfloat,
+ ["boolean"] = scanboolean,
+ ["string"] = scanrest,
+ ["dimension"] = scandimension,
+}
+
+interfaces.implement {
+ name = "lmt_parameters_define",
+ arguments = "string",
+ actions = function(namespace)
+ local d = scanhash()
+ for k, v in next, d do
+ d[k] = scanners[v] or scanrest
+ end
+ definitions[namespace] = d
+ end,
+}
+
+interfaces.implement {
+ name = "lmt_parameters_preset",
+ arguments = "string",
+ actions = function(namespace)
+ passed[namespace] = scanhash(definitions[namespace])
+ end,
+}
+
+interfaces.implement {
+ name = "lmt_parameters_reset",
+ arguments = "string",
+ actions = function(namespace)
+ passed[namespace] = nil
+ end,
+}
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mlib-svg.lmt b/Master/texmf-dist/tex/context/base/mkxl/mlib-svg.lmt
new file mode 100644
index 00000000000..dca2b6d191d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mlib-svg.lmt
@@ -0,0 +1,3333 @@
+if not modules then modules = { } end modules ['mlib-svg'] = {
+ version = 1.001,
+ optimize = true,
+ comment = "companion to mlib-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- Just a few notes:
+--
+-- There is no real need to boost performance here .. we can always make a fast
+-- variant when really needed. I will also do some of the todo's when I run into
+-- proper fonts. I need to optimize this a bit but will do that once I'm satisfied
+-- with the outcome and don't need more hooks and plugs. At some point I will
+-- optimize the MetaPost part because now we probably have more image wrapping
+-- than needed.
+--
+-- As usual with these standards, things like a path can be very compact while the
+-- rest is very verbose which defeats the point. This is a first attempt. There will
+-- be a converter to MP as well as directly to PDF. This module was made for one of
+-- the dangerous curves talks at the 2019 CTX meeting. I will do the font when I
+-- need it (not that hard).
+--
+-- The fact that in the more recent versions of SVG the older text related elements
+-- are depricated and not even supposed to be supported, combined with the fact that
+-- the text element assumes css styling, demonstrates that there is not so much as a
+-- standard. It basically means that whatever technology dominates at some point
+-- (probably combined with some libraries that at that point exist) determine what
+-- is standard. Anyway, it probably also means that these formats are not that
+-- suitable for long term archival purposes. So don't take the next implementation
+-- too serious. So in the end we now have (1) attributes for properties (which is
+-- nice and clean and what attributes are for, (2) a style attribute that needs to
+-- be parsed, (3) classes that map to styles and (4) element related styles, plus a
+-- kind of inheritance (given the limited number of elements sticking to only as
+-- wrapper would have made much sense. Anyway, we need to deal with it. With all
+-- these style things going on, one can wonder where it will end. Basically svg
+-- became just a html element that way and less clean too. The same is true for
+-- tspan, which means that text itself is nested xml.
+--
+-- We can do a direct conversion to PDF but then we also loose the abstraction which
+-- in the future will be used, and for fonts we need to spawn out to TeX anyway, so
+-- the little overhead of calling MetaPost is okay I guess. Also, we want to
+-- overload labels, share fonts with the main document, etc. and are not aiming at a
+-- general purpose SVG converter. For going to PDF one can just use InkScape.
+--
+-- Written with Anne Clark on speakers as distraction.
+--
+-- Todo when I run into an example (but ony when needed and reasonable):
+--
+-- var(color,color)
+-- --color
+-- currentColor : when i run into an example
+-- a bit more shading
+-- clip = [ auto | rect(llx,lly,urx,ury) ] (in svg)
+-- xlink url ... whatever
+-- masks
+-- opacity per group (i need to add that to metafun first, inefficient pdf but
+-- maybe filldraw can help here)
+--
+-- Maybe in metafun:
+--
+-- penciled n -> withpen pencircle scaled n
+-- applied (...) -> transformed bymatrix (...)
+-- withopacity n -> withtransparency (1,n)
+
+-- When testing mbo files:
+--
+-- empty paths
+-- missing control points
+-- funny fontnames like abcdefverdana etc
+-- paths representing glyphs but also with style specs
+-- all kind of attributes
+-- very weird and inefficient shading
+
+-- One can run into pretty crazy images, like lines that are fills being clipped
+-- to some width. That's the danger of hiding yourself behind an interface I guess.
+
+local rawget, rawset, type, tonumber, tostring, next, setmetatable = rawget, rawset, type, tonumber, tostring, next, setmetatable
+
+local P, S, R, C, Ct, Cs, Cc, Cp, Cg, Cf, Carg = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.Cp, lpeg.Cg, lpeg.Cf, lpeg.Carg
+
+local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local sqrt, abs = math.sqrt, math.abs
+local concat, setmetatableindex, sortedhash = table.concat, table.setmetatableindex, table.sortedhash
+local gmatch, gsub, find, match = string.gmatch, string.gsub, string.find, string.match
+local formatters, fullstrip = string.formatters, string.fullstrip
+local utfsplit, utfbyte = utf.split, utf.byte
+
+local xmlconvert, xmlcollected, xmlcount, xmlfirst, xmlroot = xml.convert, xml.collected, xml.count, xml.first, xml.root
+local xmltext, xmltextonly = xml.text, xml.textonly
+local css = xml.css or { } -- testing
+
+local function xmlinheritattributes(c,pa)
+ local at = c.at
+ local dt = c.dt
+ if at and dt then
+ if pa then
+ setmetatableindex(at,pa)
+ end
+ for i=1,#dt do
+ local dti = dt[i]
+ if type(dti) == "table" then
+ xmlinheritattributes(dti,at)
+ end
+ end
+ else
+ -- comment of so
+ end
+end
+
+xml.inheritattributes = xmlinheritattributes
+
+-- Maybe some day helpers will move to the metapost.svg namespace!
+
+metapost = metapost or { }
+local metapost = metapost
+local context = context
+
+local report = logs.reporter("metapost","svg")
+
+local trace = false trackers.register("metapost.svg", function(v) trace = v end)
+local trace_text = false trackers.register("metapost.svg.text", function(v) trace_text = v end)
+local trace_path = false trackers.register("metapost.svg.path", function(v) trace_path = v end)
+local trace_result = false trackers.register("metapost.svg.result", function(v) trace_result = v end)
+local trace_colors = false trackers.register("metapost.svg.colors", function(v) trace_colors = v end)
+local trace_fonts = false trackers.register("metapost.svg.fonts", function(v) trace_fonts = v end)
+
+-- This is just an experiment. Todo: reset hash etc. Also implement
+-- an option handler.
+
+local svghash = false do
+
+ local svglast = 0
+ local svglist = false
+
+ local function checkhash(t,k)
+ local n = svglast + 1
+ svglast = n
+ svglist[n] = k
+ t[k] = n
+ return n
+ end
+
+ function metapost.startsvghashing()
+ svglast = 0
+ svglist = { }
+ svghash = setmetatableindex(checkhash)
+ end
+
+ function metapost.stopsvghashing()
+ svglast = 0
+ svglist = false
+ svghash = false
+ end
+
+ interfaces.implement {
+ name = "svghashed",
+ arguments = "integer",
+ actions = function(n)
+ local t = svglist and svglist[n]
+ if t then
+ context(t)
+ end
+ end
+ }
+
+end
+
+-- We have quite some closures because otherwise we run into the local variable
+-- limitations. It doesn't always look pretty now, sorry. I'll clean up this mess
+-- some day (the usual nth iteration of code).
+--
+-- Most of the conversion is rather trivial code till I ran into a file with arcs. A
+-- bit of searching lead to the a2c javascript function but it has some puzzling
+-- thingies (like sin and cos definitions that look like leftovers and possible
+-- division by zero). Anyway, we can if needed optimize it a bit more. Here does it
+-- come from:
+
+-- http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
+-- https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/src/path.js
+
+local a2c do
+
+ local pi, sin, cos, tan, asin, abs = math.pi, math.sin, math.cos, math.tan, math.asin, math.abs
+
+ local d120 = (pi * 120) / 180
+ local pi2 = 2 * pi
+
+ a2c = function(x1, y1, rx, ry, angle, large, sweep, x2, y2, f1, f2, cx, cy)
+
+ if (rx == 0 or ry == 0 ) or (x1 == x2 and y1 == y2) then
+ return { x1, y1, x2, y2, x2, y2 }
+ end
+
+ local recursive = f1
+ local rad = pi / 180 * angle
+ local res = nil
+ local cosrad = cos(-rad) -- local cosrad = cosd(angle)
+ local sinrad = sin(-rad) -- local sinrad = sind(angle)
+
+ if not recursive then
+
+ x1, y1 = x1 * cosrad - y1 * sinrad, x1 * sinrad + y1 * cosrad
+ x2, y2 = x2 * cosrad - y2 * sinrad, x2 * sinrad + y2 * cosrad
+
+ local x = (x1 - x2) / 2
+ local y = (y1 - y2) / 2
+ local xx = x * x
+ local yy = y * y
+ local h = xx / (rx * rx) + yy / (ry * ry)
+
+ if h > 1 then
+ h = sqrt(h)
+ rx = h * rx
+ ry = h * ry
+ end
+
+ local rx2 = rx * rx
+ local ry2 = ry * ry
+ local ry2xx = ry2 * xx
+ local rx2yy = rx2 * yy
+ local total = rx2yy + ry2xx -- otherwise overflow
+
+ local k = total == 0 and 0 or sqrt(abs((rx2 * ry2 - rx2yy - ry2xx) / total))
+
+ if large == sweep then
+ k = -k
+ end
+
+ cx = k * rx * y / ry + (x1 + x2) / 2
+ cy = k * -ry * x / rx + (y1 + y2) / 2
+
+ f1 = (y1 - cy) / ry -- otherwise crash on a tiny eps
+ f2 = (y2 - cy) / ry -- otherwise crash on a tiny eps
+
+ f1 = asin((f1 < -1.0 and -1.0) or (f1 > 1.0 and 1.0) or f1)
+ f2 = asin((f2 < -1.0 and -1.0) or (f2 > 1.0 and 1.0) or f2)
+
+ if x1 < cx then f1 = pi - f1 end
+ if x2 < cx then f2 = pi - f2 end
+
+ if f1 < 0 then f1 = pi2 + f1 end
+ if f2 < 0 then f2 = pi2 + f2 end
+
+ if sweep ~= 0 and f1 > f2 then f1 = f1 - pi2 end
+ if sweep == 0 and f2 > f1 then f2 = f2 - pi2 end
+
+ end
+
+ if abs(f2 - f1) > d120 then
+ local f2old = f2
+ local x2old = x2
+ local y2old = y2
+ f2 = f1 + d120 * ((sweep ~= 0 and f2 > f1) and 1 or -1)
+ x2 = cx + rx * cos(f2)
+ y2 = cy + ry * sin(f2)
+ res = a2c(x2, y2, rx, ry, angle, 0, sweep, x2old, y2old, f2, f2old, cx, cy)
+ end
+
+ local c1 = cos(f1)
+ local s1 = sin(f1)
+ local c2 = cos(f2)
+ local s2 = sin(f2)
+
+ local t = tan((f2 - f1) / 4)
+ local hx = 4 * rx * t / 3
+ local hy = 4 * ry * t / 3
+
+ local r = { x1 - hx * s1, y1 + hy * c1, x2 + hx * s2, y2 - hy * c2, x2, y2, unpack(res or { }) }
+
+ if not recursive then -- we can also check for sin/cos being 0/1
+ cosrad = cos(rad)
+ sinrad = sin(rad)
+ -- cosrad = cosd(angle)
+ -- sinrad = sind(angle)
+ for i0=1,#r,2 do
+ local i1 = i0 + 1
+ local x = r[i0]
+ local y = r[i1]
+ r[i0] = x * cosrad - y * sinrad
+ r[i1] = x * sinrad + y * cosrad
+ end
+ end
+
+ return r
+ end
+
+end
+
+-- We share some patterns.
+
+local p_digit = lpegpatterns.digit
+local p_hexdigit = lpegpatterns.hexdigit
+local p_space = lpegpatterns.whitespace
+
+local factors = {
+ ["pt"] = 1.25,
+ ["mm"] = 3.543307,
+ ["cm"] = 35.43307,
+ ["px"] = 1,
+ ["pc"] = 15,
+ ["in"] = 90,
+ ["em"] = 12 * 1.25,
+ ["ex"] = 8 * 1.25,
+}
+
+metapost.svgfactors = factors
+
+local percentage_r = 1/100
+local percentage_x = percentage_r
+local percentage_y = percentage_r
+
+local asnumber, asnumber_r, asnumber_x, asnumber_y, asnumber_vx, asnumber_vy
+local asnumber_vx_t, asnumber_vy_t
+local p_number, p_separator, p_optseparator, p_numbers, p_fournumbers, p_path
+local p_number_n, p_number_x, p_number_vx, p_number_y, p_number_vy, p_number_r
+
+do
+
+ -- incredible: we can find .123.456 => 0.123 0.456 ...
+
+ local p_command_x = C(S("Hh"))
+ local p_command_y = C(S("Vv"))
+ local p_command_xy = C(S("CcLlMmQqSsTt"))
+ local p_command_a = C(S("Aa"))
+ local p_command = C(S("Zz"))
+
+ p_optseparator = S("\t\n\r ,")^0
+ p_separator = S("\t\n\r ,")^1
+ p_number = (S("+-")^0 * (p_digit^0 * P(".") * p_digit^1 + p_digit^1 * P(".") + p_digit^1))
+ * (P("e") * S("+-")^0 * p_digit^1)^-1
+
+ local function convert (n) n = tonumber(n) return n end
+ local function convert_r (n,u) n = tonumber(n) if u == true then return percentage_r * n elseif u then return u * n else return n end end
+ local function convert_x (n,u) n = tonumber(n) if u == true then return percentage_x * n elseif u then return u * n else return n end end
+ local function convert_y (n,u) n = tonumber(n) if u == true then return percentage_y * n elseif u then return u * n else return n end end
+ local function convert_vx(n,u) n = tonumber(n) if u == true then return percentage_x * n elseif u then return u * n else return n end end
+ local function convert_vy(n,u) n = - tonumber(n) if u == true then return percentage_y * n elseif u then return u * n else return n end end
+
+ local p_unit = (P("p") * S("txc") + P("e") * S("xm") + S("mc") * P("m") + P("in")) / factors
+ local p_percent = P("%") * Cc(true)
+
+ local c_number_n = C(p_number)
+ local c_number_u = C(p_number) * (p_unit + p_percent)^-1
+
+ p_number_n = c_number_n / convert
+ p_number_x = c_number_u / convert_x
+ p_number_vx = c_number_u / convert_vx
+ p_number_y = c_number_u / convert_y
+ p_number_vy = c_number_u / convert_vy
+ p_number_r = c_number_u / convert_r
+
+ asnumber = function(s) return s and lpegmatch(p_number, s) or 0 end
+ asnumber_r = function(s) return s and lpegmatch(p_number_r, s) or 0 end
+ asnumber_x = function(s) return s and lpegmatch(p_number_x, s) or 0 end
+ asnumber_y = function(s) return s and lpegmatch(p_number_y, s) or 0 end
+ asnumber_vx = function(s) return s and lpegmatch(p_number_vx,s) or 0 end
+ asnumber_vy = function(s) return s and lpegmatch(p_number_vy,s) or 0 end
+
+ local p_number_vx_t = Ct { (p_number_vx + p_separator)^1 }
+ local p_number_vy_t = Ct { (p_number_vy + p_separator)^1 }
+
+ local zerotable = { 0 }
+
+ asnumber_vx_t = function(s) return s and lpegmatch(p_number_vx_t,s) or zerotable end
+ asnumber_vy_t = function(s) return s and lpegmatch(p_number_vy_t,s) or zerotable end
+
+ local p_numbersep = p_number_n + p_separator
+ p_numbers = p_optseparator * P("(") * p_numbersep^0 * p_optseparator * P(")")
+ p_fournumbers = p_numbersep^4
+ p_path = Ct ( (
+ p_command_xy * (p_optseparator * p_number_vx *
+ p_optseparator * p_number_vy )^1
+ + p_command_x * (p_optseparator * p_number_vx )^1
+ + p_command_y * (p_optseparator * p_number_vy )^1
+ + p_command_a * (p_optseparator * p_number_vx *
+ p_optseparator * p_number_vy *
+ p_optseparator * p_number_r *
+ p_optseparator * p_number_n * -- flags
+ p_optseparator * p_number_n * -- flags
+ p_optseparator * p_number_vx *
+ p_optseparator * p_number_vy )^1
+ + p_command
+ + p_separator
+ )^1 )
+
+
+end
+
+-- We can actually use the svg color definitions from the tex end but maybe a user
+-- doesn't want those replace the normal definitions.
+--
+-- local hexhash = setmetatableindex(function(t,k) local v = lpegmatch(p_hexcolor, k) t[k] = v return v end) -- per file
+-- local hexhash3 = setmetatableindex(function(t,k) local v = lpegmatch(p_hexcolor3,k) t[k] = v return v end) -- per file
+--
+-- local function hexcolor (c) return hexhash [c] end -- directly do hexhash [c]
+-- local function hexcolor3(c) return hexhash3[c] end -- directly do hexhash3[c]
+
+local colormap = false
+
+local function prepared(t)
+ if type(t) == "table" then
+ local mapping = t.mapping or { }
+ local mapper = t.mapper
+ local colormap = setmetatableindex(mapping)
+ if mapper then
+ setmetatableindex(colormap,function(t,k)
+ local v = mapper(k)
+ t[k] = v or k
+ return v
+ end)
+ end
+ return colormap
+ else
+ return false
+ end
+end
+
+local colormaps = setmetatableindex(function(t,k)
+ local v = false
+ if type(k) == "string" then
+ v = prepared(table.load(k)) -- todo: same path as svg file
+ elseif type(k) == "table" then
+ v = prepared(k)
+ k = k.name or k
+ end
+ t[k] = v
+ return v
+end)
+
+function metapost.svgcolorremapper(colormap)
+ return colormaps[colormap]
+end
+
+-- todo: cache colors per image / remapper
+
+local colorcomponents, withcolor, thecolor, usedcolors do
+
+ local svgcolors = {
+ aliceblue = 0xF0F8FF, antiquewhite = 0xFAEBD7, aqua = 0x00FFFF, aquamarine = 0x7FFFD4,
+ azure = 0xF0FFFF, beige = 0xF5F5DC, bisque = 0xFFE4C4, black = 0x000000,
+ blanchedalmond = 0xFFEBCD, blue = 0x0000FF, blueviolet = 0x8A2BE2, brown = 0xA52A2A,
+ burlywood = 0xDEB887, cadetblue = 0x5F9EA0, hartreuse = 0x7FFF00, chocolate = 0xD2691E,
+ coral = 0xFF7F50, cornflowerblue = 0x6495ED, cornsilk = 0xFFF8DC, crimson = 0xDC143C,
+ cyan = 0x00FFFF, darkblue = 0x00008B, darkcyan = 0x008B8B, darkgoldenrod = 0xB8860B,
+ darkgray = 0xA9A9A9, darkgreen = 0x006400, darkgrey = 0xA9A9A9, darkkhaki = 0xBDB76B,
+ darkmagenta = 0x8B008B, darkolivegreen = 0x556B2F, darkorange = 0xFF8C00, darkorchid = 0x9932CC,
+ darkred = 0x8B0000, darksalmon = 0xE9967A, darkseagreen = 0x8FBC8F, darkslateblue = 0x483D8B,
+ darkslategray = 0x2F4F4F, darkslategrey = 0x2F4F4F, darkturquoise = 0x00CED1, darkviolet = 0x9400D3,
+ deeppink = 0xFF1493, deepskyblue = 0x00BFFF, dimgray = 0x696969, dimgrey = 0x696969,
+ dodgerblue = 0x1E90FF, firebrick = 0xB22222, floralwhite = 0xFFFAF0, forestgreen = 0x228B22,
+ fuchsia = 0xFF00FF, gainsboro = 0xDCDCDC, ghostwhite = 0xF8F8FF, gold = 0xFFD700,
+ goldenrod = 0xDAA520, gray = 0x808080, green = 0x008000, greenyellow = 0xADFF2F,
+ grey = 0x808080, honeydew = 0xF0FFF0, hotpink = 0xFF69B4, indianred = 0xCD5C5C,
+ indigo = 0x4B0082, ivory = 0xFFFFF0, khaki = 0xF0E68C, lavender = 0xE6E6FA,
+ lavenderblush = 0xFFF0F5, lawngreen = 0x7CFC00, lemonchiffon = 0xFFFACD, lightblue = 0xADD8E6,
+ lightcoral = 0xF08080, lightcyan = 0xE0FFFF, lightgoldenrodyellow = 0xFAFAD2, lightgray = 0xD3D3D3,
+ lightgreen = 0x90EE90, lightgrey = 0xD3D3D3, lightpink = 0xFFB6C1, lightsalmon = 0xFFA07A,
+ lightseagreen = 0x20B2AA, lightskyblue = 0x87CEFA, lightslategray = 0x778899, lightslategrey = 0x778899,
+ lightsteelblue = 0xB0C4DE, lightyellow = 0xFFFFE0, lime = 0x00FF00, limegreen = 0x32CD32,
+ linen = 0xFAF0E6, magenta = 0xFF00FF, maroon = 0x800000, mediumaquamarine = 0x66CDAA,
+ mediumblue = 0x0000CD, mediumorchid = 0xBA55D3, mediumpurple = 0x9370DB, mediumseagreen = 0x3CB371,
+ mediumslateblue = 0x7B68EE, mediumspringgreen = 0x00FA9A, mediumturquoise = 0x48D1CC, mediumvioletred = 0xC71585,
+ midnightblue = 0x191970, mintcream = 0xF5FFFA, mistyrose = 0xFFE4E1, moccasin = 0xFFE4B5,
+ navajowhite = 0xFFDEAD, navy = 0x000080, oldlace = 0xFDF5E6, olive = 0x808000,
+ olivedrab = 0x6B8E23, orange = 0xFFA500, orangered = 0xFF4500, orchid = 0xDA70D6,
+ palegoldenrod = 0xEEE8AA, palegreen = 0x98FB98, paleturquoise = 0xAFEEEE, palevioletred = 0xDB7093,
+ papayawhip = 0xFFEFD5, peachpuff = 0xFFDAB9, peru = 0xCD853F, pink = 0xFFC0CB,
+ plum = 0xDDA0DD, powderblue = 0xB0E0E6, purple = 0x800080, red = 0xFF0000,
+ rosybrown = 0xBC8F8F, royalblue = 0x4169E1, saddlebrown = 0x8B4513, salmon = 0xFA8072,
+ sandybrown = 0xF4A460, seagreen = 0x2E8B57, seashell = 0xFFF5EE, sienna = 0xA0522D,
+ silver = 0xC0C0C0, skyblue = 0x87CEEB, slateblue = 0x6A5ACD, slategray = 0x708090,
+ slategrey = 0x708090, snow = 0xFFFAFA, springgreen = 0x00FF7F, steelblue = 0x4682B4,
+ tan = 0xD2B48C, teal = 0x008080, thistle = 0xD8BFD8, tomato = 0xFF6347,
+ turquoise = 0x40E0D0, violet = 0xEE82EE, wheat = 0xF5DEB3, white = 0xFFFFFF,
+ whitesmoke = 0xF5F5F5, yellow = 0xFFFF00, yellowgreen = 0x9ACD32,
+ }
+
+ local f_rgb = formatters['withcolor svgcolor(%.3N,%.3N,%.3N)']
+ local f_cmyk = formatters['withcolor svgcmyk(%.3N,%.3N,%.3N,%.3N)']
+ local f_gray = formatters['withcolor svggray(%.3N)']
+ local f_rgba = formatters['withcolor svgcolor(%.3N,%.3N,%.3N) withtransparency (1,%.3N)']
+ local f_graya = formatters['withcolor svggray(%.3N) withtransparency (1,%.3N)']
+ local f_name = formatters['withcolor "%s"']
+ local f_svgrgb = formatters['svgcolor(%.3N,%.3N,%.3N)']
+ local f_svgcmyk = formatters['svgcmyk(%.3N,%.3N,%.3N,%.3N)']
+ local f_svggray = formatters['svggray(%.3N)']
+ local f_svgname = formatters['"%s"']
+
+ local extract = bit32.extract
+
+ local triplets = setmetatableindex(function(t,k)
+ -- we delay building all these strings
+ local v = svgcolors[k]
+ if v then
+ v = { extract(v,16,8)/255, extract(v,8,8)/255, extract(v,0,8)/255 }
+ else
+ v = false
+ end
+ t[k] = v
+ return v
+ end)
+
+ local p_fraction = C(p_number) * C("%")^-1 / function(a,b) return tonumber(a) / (b and 100 or 255) end
+ local p_angle = C(p_number) * P("deg")^0 / function(a) return tonumber(a) end
+ local p_percent = C(p_number) * P("%") / function(a) return tonumber(a) / 100 end
+ local p_absolute = C(p_number) / tonumber
+
+ local p_left = P("(")
+ local p_right = P(")")
+ local p_a = P("a")^-1
+ local p_h_a_color = p_left
+ * p_angle
+ * p_separator * p_percent
+ * p_separator * p_percent
+ * p_separator^0 * p_absolute^0
+ * p_right
+
+ local colors = attributes.colors
+ local colorvalues = colors.values
+ local colorindex = attributes.list[attributes.private('color')]
+ local hsvtorgb = colors.hsvtorgb
+ local hwbtorgb = colors.hwbtorgb
+ local forcedmodel = colors.forcedmodel
+
+ local p_splitcolor =
+ P("#") * C(p_hexdigit*p_hexdigit)^1 / function(r,g,b)
+ if not r then
+ return "gray", 0
+ elseif not (g and b) then
+ return "gray", tonumber(r or "0", 16) / 255 or 0
+ else
+ return "rgb",
+ tonumber(r or "0", 16) / 255 or 0,
+ tonumber(g or "0", 16) / 255 or 0,
+ tonumber(b or "0", 16) / 255 or 0
+ end
+ end
+ + P("rgb") * p_a
+ * p_left * (p_fraction + p_separator)^-3 * (p_absolute + p_separator)^0 * p_right / function(r,g,b,a)
+ return "rgb", r or 0, g or 0, b or 0, a or false
+ end
+ + P("cmyk")
+ * p_left * (p_absolute + p_separator)^0 * p_right / function(c,m,y,k)
+ return "cmyk", c or 0, m or 0, y or 0, k or 0
+ end
+ + P("hsl") * p_a
+ * p_h_a_color / function(h,s,l,a)
+ local r, g, b = hsvtorgb(h,s,l,a)
+ return "rgb", r or 0, g or 0, b or 0, a or false
+ end
+ + P("hwb") * p_a
+ * p_h_a_color / function(h,w,b,a)
+ local r, g, b = hwbtorgb(h,w,b)
+ return "rgb", r or 0, g or 0, b or 0, a or false
+ end
+
+ function metapost.svgsplitcolor(color)
+ if type(color) == "string" then
+ local what, s1, s2, s3, s4 = lpegmatch(p_splitcolor,color)
+ if not what then
+ local t = triplets[color]
+ if t then
+ what, s1, s2, s3 = "rgb", t[1], t[2], t[3]
+ end
+ end
+ return what, s1, s2, s3, s4
+ else
+ return "gray", 0, false
+ end
+ end
+
+ local function registeredcolor(name)
+ local color = colorindex[name]
+ if color then
+ local v = colorvalues[color]
+ local t = forcedmodel(v[1])
+ if t == 2 then
+ return "gray", v[2]
+ elseif t == 3 then
+ return "rgb", v[3], v[4], v[5]
+ elseif t == 4 then
+ return "cmyk", v[6], v[7], v[8], v[9]
+ else
+ --
+ end
+ end
+ end
+
+ -- we can have a fast check for #000000
+
+ local function validcolor(color)
+ if usedcolors then
+ usedcolors[color] = usedcolors[color] + 1
+ end
+ if colormap then
+ local c = colormap[color]
+ local t = type(c)
+ if t == "table" then
+ local what = t[1]
+ if what == "rgb" then
+ return
+ what,
+ tonumber(t[2]) or 0,
+ tonumber(t[3]) or 0,
+ tonumber(t[4]) or 0,
+ tonumber(t[4]) or false
+ elseif what == "cmyk" then
+ return
+ what,
+ tonumber(t[2]) or 0,
+ tonumber(t[3]) or 0,
+ tonumber(t[4]) or 0,
+ tonumber(t[5]) or 0
+ elseif what == "gray" then
+ return
+ what,
+ tonumber(t[2]) or 0,
+ tonumber(t[3]) or false
+ end
+ elseif t == "string" then
+ color = c
+ end
+ end
+ local what, s1, s2, s3, s4 = registeredcolor(color)
+ if what then
+ return what, s1, s2, s3, s4
+ end
+ what, s1, s2, s3, s4 = lpegmatch(p_splitcolor,color)
+ if not what then
+ local t = triplets[color]
+ if t then
+ s1, s3, s3 = t[1], t[2], t[3]
+ what = "rgb"
+ end
+ end
+ return what, s1, s2, s3, s4
+ end
+
+ colorcomponents = function(color)
+ local what, s1, s2, s3, s4 = validcolor(color)
+ return s1, s2, s3, s4 -- so 4 means cmyk
+ end
+
+ withcolor = function(color)
+ local what, s1, s2, s3, s4 = validcolor(color)
+ -- print(color,what, s1, s2, s3, s4)
+ if what == "rgb" then
+ if s4 then
+ if s1 == s2 and s1 == s3 then
+ return f_graya(s1,s4)
+ else
+ return f_rgba(s1,s2,s3,s4)
+ end
+ else
+ if s1 == s2 and s1 == s3 then
+ return f_gray(s1)
+ else
+ return f_rgb(s1,s2,s3)
+ end
+ end
+ elseif what == "cmyk" then
+ return f_cmyk(s1,s2,s3,s4)
+ elseif what == "gray" then
+ if s2 then
+ return f_graya(s1,s2)
+ else
+ return f_gray(s1)
+ end
+ end
+ return f_name(color)
+ end
+
+ thecolor = function(color)
+ local what, s1, s2, s3, s4 = validcolor(color)
+ if what == "rgb" then
+ if s4 then
+ if s1 == s2 and s1 == s3 then
+ return f_svggraya(s1,s4)
+ else
+ return f_svgrgba(s1,s2,s3,s4)
+ end
+ else
+ if s1 == s2 and s1 == s3 then
+ return f_svggray(s1)
+ else
+ return f_svgrgb(s1,s2,s3)
+ end
+ end
+ elseif what == "cmyk" then
+ return f_cmyk(s1,s2,s3,s4)
+ elseif what == "gray" then
+ if s2 then
+ return f_svggraya(s1,s2)
+ else
+ return f_svggray(s1)
+ end
+ end
+ return f_svgname(color)
+ end
+
+end
+
+-- actually we can loop faster because we can go to the last one
+
+local grabpath, grablist do
+
+ local f_moveto = formatters['(%N,%N)']
+ local f_curveto_z = formatters['controls(%N,%N)and(%N,%N)..(%N,%N)']
+ local f_curveto_n = formatters['..controls(%N,%N)and(%N,%N)..(%N,%N)']
+ local f_lineto_z = formatters['(%N,%N)']
+ local f_lineto_n = formatters['--(%N,%N)']
+
+ local m = { __index = function() return 0 end }
+
+ grabpath = function(str)
+ local p = lpegmatch(p_path,str) or { }
+ local np = #p
+ local all = { entries = np, closed = false, curve = false }
+ if np == 0 then
+ return all
+ end
+ setmetatable(p,m)
+ local t = { } -- no real saving here if we share
+ local n = 0
+ local a = 0
+ local i = 0
+ local last = "M"
+ local prev = last
+ local kind = "L"
+ local x, y = 0, 0
+ local x1, y1 = 0, 0
+ local x2, y2 = 0, 0
+ local rx, ry = 0, 0
+ local ar, al = 0, 0
+ local as, ac = 0, nil
+ local mx, my = 0, 0
+ while i < np do
+ i = i + 1
+ local pi = p[i]
+ if type(pi) ~= "number" then
+ last = pi
+ i = i + 1
+ pi = p[i]
+ end
+ -- most often
+ if last == "c" then
+ x1 = x + pi
+ i = i + 1 ; y1 = y + p[i]
+ i = i + 1 ; x2 = x + p[i]
+ i = i + 1 ; y2 = y + p[i]
+ i = i + 1 ; x = x + p[i]
+ i = i + 1 ; y = y + p[i]
+ goto curveto
+ elseif last == "l" then
+ x = x + pi
+ i = i + 1 ; y = y + p[i]
+ goto lineto
+ elseif last == "h" then
+ x = x + pi
+ goto lineto
+ elseif last == "v" then
+ y = y + pi
+ goto lineto
+ elseif last == "a" then
+ x1 = x
+ y1 = y
+ rx = pi
+ i = i + 1 ; ry = p[i]
+ i = i + 1 ; ar = p[i]
+ i = i + 1 ; al = p[i]
+ i = i + 1 ; as = p[i]
+ i = i + 1 ; x = x + p[i]
+ i = i + 1 ; y = y + p[i]
+ goto arc
+ elseif last == "s" then
+ if prev == "C" then
+ x1 = 2 * x - x2
+ y1 = 2 * y - y2
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = x + pi
+ i = i + 1 ; y2 = y + p[i]
+ i = i + 1 ; x = x + p[i]
+ i = i + 1 ; y = y + p[i]
+ goto curveto
+ elseif last == "m" then
+ if n > 0 then
+ a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
+ end
+ x = x + pi
+ i = i + 1 ; y = y + p[i]
+ goto moveto
+ elseif last == "z" then
+ goto close
+ -- less frequent
+ elseif last == "C" then
+ x1 = pi
+ i = i + 1 ; y1 = p[i]
+ i = i + 1 ; x2 = p[i]
+ i = i + 1 ; y2 = p[i]
+ i = i + 1 ; x = p[i]
+ i = i + 1 ; y = p[i]
+ goto curveto
+ elseif last == "L" then
+ x = pi
+ i = i + 1 ; y = p[i]
+ goto lineto
+ elseif last == "H" then
+ x = pi
+ goto lineto
+ elseif last == "V" then
+ y = pi
+ goto lineto
+ elseif last == "A" then
+ x1 = x
+ y1 = y
+ rx = pi
+ i = i + 1 ; ry = p[i]
+ i = i + 1 ; ar = p[i]
+ i = i + 1 ; al = p[i]
+ i = i + 1 ; as = p[i]
+ i = i + 1 ; x = p[i]
+ i = i + 1 ; y = p[i]
+ goto arc
+ elseif last == "S" then
+ if prev == "C" then
+ x1 = 2 * x - x2
+ y1 = 2 * y - y2
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = pi
+ i = i + 1 ; y2 = p[i]
+ i = i + 1 ; x = p[i]
+ i = i + 1 ; y = p[i]
+ goto curveto
+ elseif last == "M" then
+ if n > 0 then
+ a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
+ end
+ x = pi ;
+ i = i + 1 ; y = p[i]
+ goto moveto
+ elseif last == "Z" then
+ goto close
+ -- very seldom
+ elseif last == "q" then
+ x1 = x + pi
+ i = i + 1 ; y1 = y + p[i]
+ i = i + 1 ; x2 = x + p[i]
+ i = i + 1 ; y2 = y + p[i]
+ goto quadratic
+ elseif last == "t" then
+ if prev == "C" then
+ x1 = 2 * x - x1
+ y1 = 2 * y - y1
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = x + pi
+ i = i + 1 ; y2 = y + p[i]
+ goto quadratic
+ elseif last == "Q" then
+ x1 = pi
+ i = i + 1 ; y1 = p[i]
+ i = i + 1 ; x2 = p[i]
+ i = i + 1 ; y2 = p[i]
+ goto quadratic
+ elseif last == "T" then
+ if prev == "C" then
+ x1 = 2 * x - x1
+ y1 = 2 * y - y1
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = pi
+ i = i + 1 ; y2 = p[i]
+ goto quadratic
+ else
+ goto continue
+ end
+ ::moveto::
+ n = n + 1 ; t[n] = f_moveto(x,y)
+ last = last == "M" and "L" or "l"
+ prev = "M"
+ mx = x
+ my = y
+ goto continue
+ ::lineto::
+ n = n + 1 ; t[n] = (n > 0 and f_lineto_n or f_lineto_z)(x,y)
+ prev = "L"
+ goto continue
+ ::curveto::
+ n = n + 1 ; t[n] = (n > 0 and f_curveto_n or f_curveto_z)(x1,y1,x2,y2,x,y)
+ prev = "C"
+ goto continue
+ ::arc::
+ ac = a2c(x1,y1,rx,ry,ar,al,as,x,y)
+ for i=1,#ac,6 do
+ n = n + 1 ; t[n] = (n > 0 and f_curveto_n or f_curveto_z)(
+ ac[i],ac[i+1],ac[i+2],ac[i+3],ac[i+4],ac[i+5]
+ )
+ end
+ prev = "A"
+ goto continue
+ ::quadratic::
+ n = n + 1 ; t[n] = (n > 0 and f_curveto_n or f_curveto_z)(
+ x + 2/3 * (x1-x ), y + 2/3 * (y1-y ),
+ x2 + 2/3 * (x1-x2), y2 + 2/3 * (y1-y2),
+ x2, y2
+ )
+ x = x2
+ y = y2
+ prev = "C"
+ goto continue
+ ::close::
+ -- n = n + 1 ; t[n] = prev == "C" and "..cycle" or "--cycle"
+ n = n + 1 ; t[n] = "--cycle"
+ if n > 0 then
+ a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
+ end
+ if i == np then
+ break
+ else
+ i = i - 1
+ end
+ kind = prev
+ prev = "Z"
+ -- this is kind of undocumented: a close also moves back
+ x = mx
+ y = my
+ ::continue::
+ end
+ if n > 0 then
+ a = a + 1 ; all[a] = concat(t,"",1,n) ; n = 0
+ end
+ if prev == "Z" then
+ all.closed = true
+ end
+ all.curve = (kind == "C" or kind == "A")
+ return all, p
+ end
+
+ -- this is a bit tricky as what are points for a mark ... the next can be simplified
+ -- a lot
+
+ grablist = function(p)
+ local np = #p
+ if np == 0 then
+ return nil
+ end
+ local t = { }
+ local n = 0
+ local a = 0
+ local i = 0
+ local last = "M"
+ local prev = last
+ local kind = "L"
+ local x, y = 0, 0
+ local x1, y1 = 0, 0
+ local x2, y2 = 0, 0
+ local rx, ry = 0, 0
+ local ar, al = 0, 0
+ local as, ac = 0, nil
+ local mx, my = 0, 0
+ while i < np do
+ i = i + 1
+ local pi = p[i]
+ if type(pi) ~= "number" then
+ last = pi
+ i = i + 1
+ pi = p[i]
+ end
+ -- most often
+ if last == "c" then
+ x1 = x + pi
+ i = i + 1 ; y1 = y + p[i]
+ i = i + 1 ; x2 = x + p[i]
+ i = i + 1 ; y2 = y + p[i]
+ i = i + 1 ; x = x + p[i]
+ i = i + 1 ; y = y + p[i]
+ goto curveto
+ elseif last == "l" then
+ x = x + pi
+ i = i + 1 ; y = y + p[i]
+ goto lineto
+ elseif last == "h" then
+ x = x + pi
+ goto lineto
+ elseif last == "v" then
+ y = y + pi
+ goto lineto
+ elseif last == "a" then
+ x1 = x
+ y1 = y
+ rx = pi
+ i = i + 1 ; ry = p[i]
+ i = i + 1 ; ar = p[i]
+ i = i + 1 ; al = p[i]
+ i = i + 1 ; as = p[i]
+ i = i + 1 ; x = x + p[i]
+ i = i + 1 ; y = y + p[i]
+ goto arc
+ elseif last == "s" then
+ if prev == "C" then
+ x1 = 2 * x - x2
+ y1 = 2 * y - y2
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = x + pi
+ i = i + 1 ; y2 = y + p[i]
+ i = i + 1 ; x = x + p[i]
+ i = i + 1 ; y = y + p[i]
+ goto curveto
+ elseif last == "m" then
+ x = x + pi
+ i = i + 1 ; y = y + p[i]
+ goto moveto
+ elseif last == "z" then
+ goto close
+ -- less frequent
+ elseif last == "C" then
+ x1 = pi
+ i = i + 1 ; y1 = p[i]
+ i = i + 1 ; x2 = p[i]
+ i = i + 1 ; y2 = p[i]
+ i = i + 1 ; x = p[i]
+ i = i + 1 ; y = p[i]
+ goto curveto
+ elseif last == "L" then
+ x = pi
+ i = i + 1 ; y = p[i]
+ goto lineto
+ elseif last == "H" then
+ x = pi
+ goto lineto
+ elseif last == "V" then
+ y = pi
+ goto lineto
+ elseif last == "A" then
+ x1 = x
+ y1 = y
+ rx = pi
+ i = i + 1 ; ry = p[i]
+ i = i + 1 ; ar = p[i]
+ i = i + 1 ; al = p[i]
+ i = i + 1 ; as = p[i]
+ i = i + 1 ; x = p[i]
+ i = i + 1 ; y = p[i]
+ goto arc
+ elseif last == "S" then
+ if prev == "C" then
+ x1 = 2 * x - x2
+ y1 = 2 * y - y2
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = pi
+ i = i + 1 ; y2 = p[i]
+ i = i + 1 ; x = p[i]
+ i = i + 1 ; y = p[i]
+ goto curveto
+ elseif last == "M" then
+ x = pi ;
+ i = i + 1 ; y = p[i]
+ goto moveto
+ elseif last == "Z" then
+ goto close
+ -- very seldom
+ elseif last == "q" then
+ x1 = x + pi
+ i = i + 1 ; y1 = y + p[i]
+ i = i + 1 ; x2 = x + p[i]
+ i = i + 1 ; y2 = y + p[i]
+ goto quadratic
+ elseif last == "t" then
+ if prev == "C" then
+ x1 = 2 * x - x1
+ y1 = 2 * y - y1
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = x + pi
+ i = i + 1 ; y2 = y + p[i]
+ goto quadratic
+ elseif last == "Q" then
+ x1 = pi
+ i = i + 1 ; y1 = p[i]
+ i = i + 1 ; x2 = p[i]
+ i = i + 1 ; y2 = p[i]
+ goto quadratic
+ elseif last == "T" then
+ if prev == "C" then
+ x1 = 2 * x - x1
+ y1 = 2 * y - y1
+ else
+ x1 = x
+ y1 = y
+ end
+ x2 = pi
+ i = i + 1 ; y2 = p[i]
+ goto quadratic
+ else
+ goto continue
+ end
+ ::moveto::
+ n = n + 1 ; t[n] = x
+ n = n + 1 ; t[n] = y
+ last = last == "M" and "L" or "l"
+ prev = "M"
+ mx = x
+ my = y
+ goto continue
+ ::lineto::
+ n = n + 1 ; t[n] = x
+ n = n + 1 ; t[n] = y
+ prev = "L"
+ goto continue
+ ::curveto::
+ n = n + 1 ; t[n] = x
+ n = n + 1 ; t[n] = y
+ prev = "C"
+ goto continue
+ ::arc::
+ ac = a2c(x1,y1,rx,ry,ar,al,as,x,y)
+ for i=1,#ac,6 do
+ n = n + 1 ; t[n] = ac[i+4]
+ n = n + 1 ; t[n] = ac[i+5]
+ end
+ prev = "A"
+ goto continue
+ ::quadratic::
+ n = n + 1 ; t[n] = x2
+ n = n + 1 ; t[n] = y2
+ x = x2
+ y = y2
+ prev = "C"
+ goto continue
+ ::close::
+ n = n + 1 ; t[n] = mx
+ n = n + 1 ; t[n] = my
+ if i == np then
+ break
+ end
+ kind = prev
+ prev = "Z"
+ x = mx
+ y = my
+ ::continue::
+ end
+ return t
+ end
+
+end
+
+-- todo: viewbox helper
+
+local s_wrapped_start = "draw image ("
+local f_wrapped_stop = formatters[") shifted (0,%N) scaled %N ;"]
+
+local handletransform, handleviewbox do
+
+ local sind = math.sind
+
+ --todo: better lpeg
+
+ local f_rotatedaround = formatters[" rotatedaround((%N,%N),%N)"]
+ local f_rotated = formatters[" rotated(%N)"]
+ local f_shifted = formatters[" shifted(%N,%N)"]
+ local f_slanted_x = formatters[" xslanted(%N)"]
+ local f_slanted_y = formatters[" yslanted(%N)"]
+ local f_scaled = formatters[" scaled(%N)"]
+ local f_xyscaled = formatters[" xyscaled(%N,%N)"]
+ local f_matrix = formatters[" transformed bymatrix(%N,%N,%N,%N,%N,%N)"]
+
+ local s_transform_start = "draw image ( "
+ local f_transform_stop = formatters[")%s ;"]
+
+ local function rotate(r,x,y)
+ if x then
+ return r and f_rotatedaround(x,-(y or x),-r)
+ elseif r then
+ return f_rotated(-r)
+ else
+ return ""
+ end
+ end
+
+ local function translate(x,y)
+ if y then
+ return f_shifted(x,-y)
+ elseif x then
+ return f_shifted(x,0)
+ else
+ return ""
+ end
+ end
+
+ local function scale(x,y)
+ if y then
+ return f_xyscaled(x,y)
+ elseif x then
+ return f_scaled(x)
+ else
+ return ""
+ end
+ end
+
+ local function skewx(x)
+ if x then
+ return f_slanted_x(sind(-x))
+ else
+ return ""
+ end
+ end
+
+ local function skewy(y)
+ if y then
+ return f_slanted_y(sind(-y))
+ else
+ return ""
+ end
+ end
+
+ local function matrix(rx,sx,sy,ry,tx,ty)
+ return f_matrix(rx or 1, sx or 0, sy or 0, ry or 1, tx or 0, - (ty or 0))
+ end
+
+ -- How to deal with units here? Anyway, order seems to matter.
+
+ local p_transform = Cf ( Ct("") * (
+ lpegpatterns.whitespace^0 * Cg(
+ C("translate") * (p_numbers / translate) -- maybe xy
+ + C("scale") * (p_numbers / scale)
+ + C("rotate") * (p_numbers / rotate)
+ + C("matrix") * (p_numbers / matrix)
+ + C("skewX") * (p_numbers / skewx)
+ + C("skewY") * (p_numbers / skewy)
+ )
+ )^1, rawset)
+
+ handletransform = function(at)
+ local t = at.transform
+ if t then
+ local e = lpegmatch(p_transform,t)
+ if e then
+ e = concat({
+ e.rotate or "",
+ e.skewX or "",
+ e.skewY or "",
+ e.scale or "",
+ e.translate or "",
+ e.matrix or "",
+ }, " ")
+ return s_transform_start, f_transform_stop(e), t
+ end
+ end
+ end
+
+ handleviewbox = function(v)
+ if v then
+ local x, y, w, h = lpegmatch(p_fournumbers,v)
+ if h then
+ return x, y, w, h
+ end
+ end
+ end
+
+end
+
+local dashed do
+
+ -- actually commas are mandate but we're tolerant
+
+ local f_dashed_n = formatters[" dashed dashpattern (%s ) "]
+ local f_dashed_y = formatters[" dashed dashpattern (%s ) shifted (%N,0) "]
+
+ local p_number = p_optseparator/"" * p_number_r
+ local p_on = Cc(" on ") * p_number
+ local p_off = Cc(" off ") * p_number
+ local p_dashed = Cs((p_on * p_off^-1)^1)
+
+ dashed = function(s,o)
+ if not find(s,",") then
+ -- a bit of a hack:
+ s = s .. " " .. s
+ end
+ return (o and f_dashed_y or f_dashed_n)(lpegmatch(p_dashed,s),o)
+ end
+
+end
+
+do
+
+ local handlers = { }
+ local process = false
+ local root = false
+ local result = false
+ local r = false
+ local definitions = false
+ local classstyles = false
+ local tagstyles = false
+
+ local tags = {
+ ["a"] = true,
+ -- ["altgGlyph"] = true,
+ -- ["altgGlyphDef"] = true,
+ -- ["altgGlyphItem"] = true,
+ -- ["animate"] = true,
+ -- ["animateColor"] = true,
+ -- ["animateMotion"] = true,
+ -- ["animateTransform"] = true,
+ ["circle"] = true,
+ ["clipPath"] = true,
+ -- ["color-profile"] = true,
+ -- ["cursor"] = true,
+ ["defs"] = true,
+ -- ["desc"] = true,
+ ["ellipse"] = true,
+ -- ["filter"] = true,
+ -- ["font"] = true,
+ -- ["font-face"] = true,
+ -- ["font-face-format"] = true,
+ -- ["font-face-name"] = true,
+ -- ["font-face-src"] = true,
+ -- ["font-face-uri"] = true,
+ -- ["foreignObject"] = true,
+ ["g"] = true,
+ -- ["glyph"] = true,
+ -- ["glyphRef"] = true,
+ -- ["hkern"] = true,
+ ["image"] = true,
+ ["line"] = true,
+ ["linearGradient"] = true,
+ ["marker"] = true,
+ -- ["mask"] = true,
+ -- ["metadata"] = true,
+ -- ["missing-glyph"] = true,
+ -- ["mpath"] = true,
+ ["path"] = true,
+ -- ["pattern"] = true,
+ ["polygon"] = true,
+ ["polyline"] = true,
+ ["radialGradient"] = true,
+ ["rect"] = true,
+ -- ["script"] = true,
+ -- ["set"] = true,
+ ["stop"] = true,
+ ["style"] = true,
+ ["svg"] = true,
+ -- ["switch"] = true,
+ ["symbol"] = true,
+ ["text"] = true,
+ -- ["textPath"] = true,
+ -- ["title"] = true,
+ ["tspan"] = true,
+ ["use"] = true,
+ -- ["view"] = true,
+ -- ["vkern"] = true,
+ }
+
+ local pathtracer = {
+ ["stroke"] = "darkred",
+ ["stroke-opacity"] = ".5",
+ ["stroke-width"] = ".5",
+ ["fill"] = "darkgray",
+ ["fill-opacity"] = ".75",
+ }
+
+ local function handlechains(c)
+ if tags[c.tg] then
+ local at = c.at
+ local dt = c.dt
+ if at and dt then
+ -- at["inkscape:connector-curvature"] = nil -- cleare entry and might prevent table growth
+ local estyle = rawget(at,"style")
+ if estyle and estyle ~= "" then
+ for k, v in gmatch(estyle,"%s*([^:]+):%s*([^;]+);?") do
+ at[k] = v
+ end
+ end
+ local eclass = rawget(at,"class")
+ if eclass and eclass ~= "" then
+ for c in gmatch(eclass,"[^ ]+") do
+ local s = classstyles[c]
+ if s then
+ for k, v in next, s do
+ at[k] = v
+ end
+ end
+ end
+ end
+ local tstyle = tagstyles[tag]
+ if tstyle then
+ for k, v in next, tstyle do
+ at[k] = v
+ end
+ end
+ if trace_path and pathtracer then
+ for k, v in next, pathtracer do
+ at[k] = v
+ end
+ end
+ for i=1,#dt do
+ local dti = dt[i]
+ if type(dti) == "table" then
+ handlechains(dti)
+ end
+ end
+ end
+ end
+ end
+
+ local handlestyle do
+
+ -- It can also be CDATA but that is probably dealt with because we only
+ -- check for style entries and ignore the rest. But maybe we also need
+ -- to check a style at the outer level?
+
+ local p_key = C((R("az","AZ","09","__","--")^1))
+ local p_spec = P("{") * C((1-P("}"))^1) * P("}")
+ local p_valid = Carg(1) * P(".") * p_key + Carg(2) * p_key
+ local p_grab = ((p_valid * p_space^0 * p_spec / rawset) + p_space^1 + P(1))^1
+
+ local fontspecification = css.fontspecification
+
+ handlestyle = function(c)
+ local s = xmltext(c)
+ lpegmatch(p_grab,s,1,classstyles,tagstyles)
+ for k, v in next, classstyles do
+ local t = { }
+ for k, v in gmatch(v,"%s*([^:]+):%s*([^;]+);?") do
+ if k == "font" then
+ local s = fontspecification(v)
+ for k, v in next, s do
+ t["font-"..k] = v
+ end
+ else
+ t[k] = v
+ end
+ end
+ classstyles[k] = t
+ end
+ for k, v in next, tagstyles do
+ local t = { }
+ for k, v in gmatch(v,"%s*([^:]+):%s*([^;]+);?") do
+ if k == "font" then
+ local s = fontspecification(v)
+ for k, v in next, s do
+ t["font-"..k] = v
+ end
+ else
+ t[k] = v
+ end
+ end
+ tagstyles[k] = t
+ end
+ end
+
+ function handlers.style()
+ -- ignore
+ end
+
+ end
+
+ -- We can have root in definitions and then do a metatable lookup but use
+ -- is not used that often I guess.
+
+ local function locate(id)
+ local res = definitions[id]
+ if res then
+ return res
+ end
+ local ref = gsub(id,"^url%(#(.-)%)$","%1")
+ local ref = gsub(ref,"^#","")
+ -- we can make a fast id lookup
+ local res = xmlfirst(root,"**[@id='"..ref.."']")
+ if res then
+ definitions[id] = res
+ end
+ return res
+ end
+
+ -- also locate
+
+ local function handleclippath(at)
+ local clippath = at["clip-path"]
+
+ if not clippath then
+ return
+ end
+
+ local spec = definitions[clippath] or locate(clippath)
+
+ -- do we really need thsi crap
+ if not spec then
+ local index = match(clippath,"(%d+)")
+ if index then
+ spec = xmlfirst(root,"clipPath["..tostring(tonumber(index) or 0).."]")
+ end
+ end
+ -- so far for the crap
+
+ if not spec then
+ report("unknown clip %a",clippath)
+ return
+ elseif spec.tg ~= "clipPath" then
+ report("bad clip %a",clippath)
+ return
+ end
+
+ ::again::
+ for c in xmlcollected(spec,"/(path|use|g)") do
+ local tg = c.tg
+ if tg == "use" then
+ local ca = c.at
+ local id = ca["xlink:href"]
+ if id then
+ spec = locate(id)
+ if spec then
+ local sa = spec.at
+ setmetatableindex(sa,ca)
+ if spec.tg == "path" then
+ local d = sa.d
+ if d then
+ local p = grabpath(d)
+ p.evenodd = sa["clip-rule"] == "evenodd"
+ p.close = true
+ return p, clippath
+ else
+ return
+ end
+ else
+ goto again
+ end
+ end
+ end
+ -- break
+ elseif tg == "path" then
+ local ca = c.at
+ local d = ca.d
+ if d then
+ local p = grabpath(d)
+ p.evenodd = ca["clip-rule"] == "evenodd"
+ p.close = true
+ return p, clippath
+ else
+ return
+ end
+ else
+ -- inherit?
+ end
+ end
+ end
+
+ local s_shade_linear = ' withshademethod "linear" '
+ local s_shade_circular = ' withshademethod "circular" '
+ local f_shade_step = formatters['withshadestep ( withshadefraction %N withshadecolors(%s,%s) )']
+ local f_shade_one = formatters['withprescript "sh_center_a=%N %N"']
+ local f_shade_two = formatters['withprescript "sh_center_b=%N %N"']
+
+ local f_color = formatters['withcolor "%s"']
+ local f_opacity = formatters['withtransparency (1,%N)']
+ local f_pen = formatters['withpen pencircle scaled %N']
+
+ -- todo: gradient unfinished
+ -- todo: opacity but first we need groups in mp
+
+ local function gradient(id)
+ local spec = definitions[id] -- no locate !
+ if spec then
+ local kind = spec.tg
+ local shade = nil
+ local n = 1
+ local a = spec.at
+ if kind == "linearGradient" then
+ shade = { s_shade_linear }
+ --
+ local x1 = rawget(a,"x1")
+ local y1 = rawget(a,"y1")
+ local x2 = rawget(a,"x2")
+ local y2 = rawget(a,"y2")
+ if x1 and y1 then
+ n = n + 1 ; shade[n] = f_shade_one(asnumber_vx(x1),asnumber_vy(y1))
+ end
+ if x2 and y2 then
+ n = n + 1 ; shade[n] = f_shade_one(asnumber_vx(x2),asnumber_vy(y2))
+ end
+ --
+ elseif kind == "radialGradient" then
+ shade = { s_shade_circular }
+ --
+ local cx = rawget(a,"cx") -- x center
+ local cy = rawget(a,"cy") -- y center
+ local r = rawget(a,"r" ) -- radius
+ local fx = rawget(a,"fx") -- focal points
+ local fy = rawget(a,"fy") -- focal points
+ --
+ if cx and cy then
+ -- todo
+ end
+ if r then
+ -- todo
+ end
+ if fx and fy then
+ -- todo
+ end
+ else
+ report("unknown gradient %a",id)
+ return
+ end
+ -- local gu = a.gradientUnits
+ -- local gt = a.gradientTransform
+ -- local sm = a.spreadMethod
+ local colora, colorb
+ -- startcolor ?
+ for c in xmlcollected(spec,"/stop") do
+ local a = c.at
+ local offset = rawget(a,"offset")
+ local colorb = rawget(a,"stop-color")
+ local opacity = rawget(a,"stop-opacity")
+ if colorb then
+ colorb = thecolor(colorb)
+ end
+ if not colora then
+ colora = colorb
+ end
+ -- what if no percentage
+
+ local fraction = offset and asnumber_r(offset)
+ if not fraction then
+ -- offset = tonumber(offset)
+ -- for now
+ fraction = xmlcount(spec,"/stop")/100
+ end
+
+ if colora and colorb and color_a ~= "" and color_b ~= "" then
+ n = n + 1 ; shade[n] = f_shade_step(fraction,colora,colorb)
+ end
+
+ colora = colorb
+ end
+ return concat(shade," ")
+ end
+ end
+
+ local function drawproperties(stroke,at,opacity)
+ local p = at["stroke-width"]
+ if p then
+ p = f_pen(asnumber_r(p))
+ end
+ local d = at["stroke-dasharray"]
+ if d == "none" then
+ d = nil
+ elseif d then
+ local o = at["stroke-dashoffset"]
+ if o and o ~= "none" then
+ o = asnumber_r(o)
+ else
+ o = false
+ end
+ d = dashed(d,o)
+ end
+ local c = withcolor(stroke)
+ local o = at["stroke-opacity"] or (opacity and at["opacity"])
+ if o == "none" then
+ o = nil
+ elseif o then
+ o = asnumber_r(o)
+ if o and o ~= 1 then
+ o = f_opacity(o)
+ else
+ o = nil
+ end
+ end
+ return p, d, c, o
+ end
+
+ local s_opacity_start = "draw image ("
+ local f_opacity_stop = formatters["setgroup currentpicture to boundingbox currentpicture withtransparency (1,%N)) ;"]
+
+ local function sharedopacity(at)
+ local o = at["opacity"]
+ if o and o ~= "none" then
+ o = asnumber_r(o)
+ if o and o ~= 1 then
+ return s_opacity_start, f_opacity_stop(o)
+ end
+ end
+ end
+
+ local function fillproperties(fill,at,opacity)
+ local c = c ~= "none" and (gradient(fill) or withcolor(fill)) or nil
+ local o = at["fill-opacity"] or (opacity and at["opacity"])
+ if o and o ~= "none" then
+ o = asnumber_r(o)
+ if o == 1 then
+ return c
+ elseif o then
+ return c, f_opacity(o), o == 0
+ end
+ end
+ return c
+ end
+
+ -- todo: clip = [ auto | rect(llx,lly,urx,ury) ]
+
+ local s_offset_start = "draw image ( "
+ local f_offset_stop = formatters[") shifted (%N,%N) ;"]
+ local s_rotation_start = "draw image ( "
+ local f_rotation_stop = formatters[") rotatedaround((0,0),-angle((%N,%N))) ;"]
+ local f_rotation_angle = formatters[") rotatedaround((0,0),-%N) ;"]
+
+ local function offset(at)
+ local x = asnumber_vx(rawget(at,"x"))
+ local y = asnumber_vy(rawget(at,"y"))
+ if x ~= 0 or y ~= 0 then
+ return s_offset_start, f_offset_stop(x,y)
+ end
+ end
+
+ local s_viewport_start = "draw image ("
+ local s_viewport_stop = ") ;"
+ local f_viewport_shift = formatters["currentpicture := currentpicture shifted (%03N,%03N);"]
+ local f_viewport_scale = formatters["currentpicture := currentpicture xysized (%03N,%03N);"]
+ local f_viewport_clip = formatters["clip currentpicture to (unitsquare xyscaled (%03N,%03N));"]
+
+ local function viewport(x,y,w,h,noclip,scale)
+ r = r + 1 ; result[r] = s_viewport_start
+ return function()
+ local okay = w ~= 0 and h ~= 0
+ if okay and scale then
+ r = r + 1 ; result[r] = f_viewport_scale(w,h)
+ end
+ if x ~= 0 or y ~= 0 then
+ r = r + 1 ; result[r] = f_viewport_shift(-x,y)
+ end
+ if okay and not noclip then
+ r = r + 1 ; result[r] = f_viewport_clip(w,-h)
+ end
+
+ r = r + 1 ; result[r] = s_viewport_stop
+ end
+ end
+
+ -- maybe forget about defs and just always locate (and then backtrack
+ -- over if needed)
+
+ function handlers.defs(c)
+ for c in xmlcollected(c,"/*") do
+ local a = c.at
+ if a then
+ local id = rawget(a,"id")
+ if id then
+ definitions["#" .. id ] = c
+ definitions["url(#" .. id .. ")"] = c
+ end
+ end
+ end
+ end
+
+ function handlers.symbol(c)
+ if uselevel == 0 then
+ local id = rawget(c.at,"id")
+ if id then
+ definitions["#" .. id ] = c
+ definitions["url(#" .. id .. ")"] = c
+ end
+ else
+ handlers.g(c)
+ end
+ end
+
+ local uselevel = 0
+ local bodyfontscale = 1
+
+ function handlers.use(c)
+ local at = c.at
+ local id = rawget(at,"href") or rawget(at,"xlink:href") -- better a rawget
+ local res = locate(id)
+ if res then
+ -- width height ?
+ uselevel = uselevel + 1
+ local boffset, eoffset = offset(at)
+ local btransform, etransform, transform = handletransform(at)
+
+ if boffset then
+ r = r + 1 result[r] = boffset
+ end
+
+ -- local clippath = at.clippath
+
+ if btransform then
+ r = r + 1 result[r] = btransform
+ end
+
+ local _transform = transform
+ local _clippath = clippath
+ at["transform"] = false
+ -- at["clip-path"] = false
+
+ process(res,"/*")
+
+ at["transform"] = _transform
+ -- at["clip-path"] = _clippath
+
+ if etransform then
+ r = r + 1 ; result[r] = etransform
+ end
+
+ if eoffset then
+ r = r + 1 result[r] = eoffset
+ end
+
+ uselevel = uselevel - 1
+ else
+ report("use: unknown definition %a",id)
+ end
+ end
+
+ local f_no_draw = formatters['nodraw (%s)']
+ local f_do_draw = formatters['draw (%s)']
+ local f_no_fill_c = formatters['nofill (%s..cycle)']
+ local f_do_fill_c = formatters['fill (%s..cycle)']
+ local f_eo_fill_c = formatters['eofill (%s..cycle)']
+ local f_no_fill_l = formatters['nofill (%s--cycle)']
+ local f_do_fill_l = formatters['fill (%s--cycle)']
+ local f_eo_fill_l = formatters['eofill (%s--cycle)']
+ local f_do_fill = f_do_fill_c
+ local f_eo_fill = f_eo_fill_c
+ local f_no_fill = f_no_fill_c
+-- local s_clip_start = 'draw image ('
+-- local f_clip_stop_c = formatters[') ; clip currentpicture to (%s..cycle) ;']
+-- local f_clip_stop_l = formatters[') ; clip currentpicture to (%s--cycle) ;']
+-- local f_clip_stop = f_clip_stop_c
+-- local f_eoclip_stop_c = formatters[') ; eoclip currentpicture to (%s..cycle) ;']
+-- local f_eoclip_stop_l = formatters[') ; eoclip currentpicture to (%s--cycle) ;']
+-- local f_eoclip_stop = f_eoclip_stop_c
+ local s_clip_start = 'save p ; picture p ; p := image ('
+ local f_clip_stop_c = formatters[') ; clip p to (%s..cycle) ; draw p ;']
+ local f_clip_stop_l = formatters[') ; clip p to (%s--cycle) ; draw p ;']
+ local f_clip_stop = f_clip_stop_c
+ local f_eoclip_stop_c = formatters[') ; eoclip p to (%s..cycle) ; draw p ;']
+ local f_eoclip_stop_l = formatters[') ; eoclip p to (%s--cycle) ; draw p ;']
+ local f_eoclip_stop = f_eoclip_stop_c
+
+ -- could be shared and then beginobject | endobject
+
+ local function flushobject(object,at,c,o)
+ local btransform, etransform = handletransform(at)
+ local cpath = handleclippath(at)
+
+ if cpath then
+ r = r + 1 ; result[r] = s_clip_start
+ end
+
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+
+ r = r + 1 ; result[r] = f_do_draw(object)
+
+ if c then
+ r = r + 1 ; result[r] = c
+ end
+
+ if o then
+ r = r + 1 ; result[r] = o
+ end
+
+ if etransform then
+ r = r + 1 ; result[r] = etransform
+ end
+
+ r = r + 1 ; result[r] = ";"
+
+ if cpath then
+ local f_done = cpath.evenodd
+ if cpath.curve then
+ f_done = f_done and f_eoclip_stop_c or f_clip_stop_c
+ else
+ f_done = f_done and f_eoclip_stop_l or f_clip_stop_l
+ end
+ r = r + 1 ; result[r] = f_done(cpath[1])
+ end
+ end
+
+ do
+
+ local flush
+
+ local f_linecap = formatters["interim linecap := %s ;"]
+ local f_linejoin = formatters["interim linejoin := %s ;"]
+ local f_miterlimit = formatters["interim miterlimit := %s ;"]
+
+ local s_begingroup = "begingroup;"
+ local s_endgroup = "endgroup;"
+
+ local linecaps = { butt = "butt", square = "squared", round = "rounded" }
+ local linejoins = { miter = "mitered", bevel = "beveled", round = "rounded" }
+
+ local function startlineproperties(at)
+ local cap = at["stroke-linecap"]
+ local join = at["stroke-linejoin"]
+ local limit = at["stroke-miterlimit"]
+ cap = cap and linecaps [cap]
+ join = join and linejoins[join]
+ limit = limit and asnumber_r(limit)
+ if cap or join or limit then
+ r = r + 1 ; result[r] = s_begingroup
+ if cap then
+ r = r + 1 ; result[r] = f_linecap(cap)
+ end
+ if join then
+ r = r + 1 ; result[r] = f_linejoin(join)
+ end
+ if limit then
+ r = r + 1 ; result[r] = f_miterlimit(limit)
+ end
+ return function()
+ at["stroke-linecap"] = false
+ at["stroke-linejoin"] = false
+ at["stroke-miterlimit"] = false
+ r = r + 1 ; result[r] = s_endgroup
+ at["stroke-linecap"] = cap
+ at["stroke-linejoin"] = join
+ at["stroke-miterlimit"] = limit
+ end
+ end
+ end
+
+ -- markers are a quite rediculous thing .. let's assume simple usage for now
+
+ function handlers.marker()
+ -- todo: is just a def too
+ end
+
+ -- kind of local svg ... so make a generic one
+ --
+ -- todo: combine more (offset+scale+rotation)
+
+ local function makemarker(where,c,x1,y1,x2,y2,x3,y3,parentat)
+ local at = c.at
+ local refx = rawget(at,"refX")
+ local refy = rawget(at,"refY")
+ local width = rawget(at,"markerWidth")
+ local height = rawget(at,"markerHeight")
+ local view = rawget(at,"viewBox")
+ local orient = rawget(at,"orient")
+ -- local ratio = rawget(at,"preserveAspectRatio")
+ local units = asnumber(at["markerUnits"] or parentat["stroke-width"]) or 1
+
+ local angx = 0
+ local angy = 0
+ local angle = 0
+
+ if where == "beg" then
+ if orient == "auto" then -- unchecked
+ -- no angle
+ angx = abs(x2 - x3)
+ angy = abs(y2 - y3)
+ elseif orient == "auto-start-reverse" then -- checked
+ -- points to start
+ angx = -abs(x2 - x3)
+ angy = -abs(y2 - y3)
+ elseif orient then -- unchecked
+ angle = asnumber_r(orient)
+ end
+ elseif where == "end" then
+ -- funny standard .. bug turned feature?
+ if orient == "auto" or orient == "auto-start-reverse" then
+ angx = abs(x1 - x2)
+ angy = abs(y1 - y2)
+ elseif orient then -- unchecked
+ angle = asnumber_r(orient)
+ end
+ elseif orient then -- unchecked
+ angle = asnumber_r(orient)
+ end
+ -- what wins: viewbox or w/h
+
+ refx = asnumber_x(refx)
+ refy = asnumber_y(refy)
+
+ width = (width and asnumber_x(width) or 3) * units
+ height = (height and asnumber_y(height) or 3) * units
+
+ local x = 0
+ local y = 0
+ local w = width
+ local h = height
+
+ -- kind of like the main svg
+
+ r = r + 1 ; result[r] = s_offset_start
+
+ local wrapupviewport
+-- todo : better viewbox code
+ local xpct, ypct, rpct
+ if view then
+ x, y, w, h = handleviewbox(view)
+ end
+
+ if width ~= 0 then
+ w = width
+ end
+ if height ~= 0 then
+ h = height
+ end
+
+ if h then
+ xpct = percentage_x
+ ypct = percentage_y
+ rpct = percentage_r
+ percentage_x = w / 100
+ percentage_y = h / 100
+ percentage_r = (sqrt(w^2 + h^2) / sqrt(2)) / 100
+ wrapupviewport = viewport(x,y,w,h,true,true) -- no clip
+ end
+
+ -- we can combine a lot here:
+
+ local hasref = refx ~= 0 or refy ~= 0
+ local hasrot = angx ~= 0 or angy ~= 0 or angle ~= 0
+
+ local btransform, etransform, transform = handletransform(at)
+
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+
+ if hasrot then
+ r = r + 1 ; result[r] = s_rotation_start
+ end
+
+ if hasref then
+ r = r + 1 ; result[r] = s_offset_start
+ end
+
+ local _transform = transform
+ at["transform"] = false
+
+ handlers.g(c)
+
+ at["transform"] = _transform
+
+ if hasref then
+ r = r + 1 ; result[r] = f_offset_stop(-refx,refy)
+ end
+
+ if hasrot then
+ if angle ~= 0 then
+ r = r + 1 ; result[r] = f_rotation_angle(angle)
+ else
+ r = r + 1 ; result[r] = f_rotation_stop(angx,angy)
+ end
+ end
+
+ if etransform then
+ r = r + 1 ; result[r] = etransform
+ end
+
+ if h then
+ percentage_x = xpct
+ percentage_y = ypct
+ percentage_r = rpct
+ if wrapupviewport then
+ wrapupviewport()
+ end
+ end
+ r = r + 1 ; result[r] = f_offset_stop(x2,y2)
+
+ end
+
+ -- do we need to metatable the attributes here?
+
+ local function addmarkers(list,begmarker,midmarker,endmarker,at)
+ local n = #list
+ if n > 3 then
+ if begmarker then
+ local m = locate(begmarker)
+ if m then
+ makemarker("beg",m,false,false,list[1],list[2],list[3],list[4],at)
+ end
+ end
+ if midmarker then
+ local m = locate(midmarker)
+ if m then
+ for i=3,n-2,2 do
+ makemarker("mid",m,list[i-2],list[i-1],list[i],list[i+1],list[i+2],list[i+3],at)
+ end
+ end
+ end
+ if endmarker then
+ local m = locate(endmarker)
+ if m then
+ makemarker("end",m,list[n-3],list[n-2],list[n-1],list[n],false,false,at)
+ end
+ end
+ else
+ -- no line
+ end
+ end
+
+ local function flush(shape,dofill,at,list,begmarker,midmarker,endmarker)
+
+ local fill = dofill and (at["fill"] or "black")
+ local stroke = at["stroke"] or "none"
+
+ local btransform, etransform = handletransform(at)
+ local cpath = handleclippath(at)
+
+ if cpath then
+ r = r + 1 ; result[r] = s_clip_start
+ end
+
+ local has_stroke = stroke and stroke ~= "none"
+ local has_fill = fill and fill ~= "none"
+
+ local bopacity, eopacity
+ if has_stroke and has_fill then
+ bopacity, eopacity = sharedopacity(at)
+ end
+
+ if bopacity then
+ r = r + 1 ; result[r] = bopacity
+ end
+
+ if has_fill then
+ local color, opacity = fillproperties(fill,at,not has_stroke)
+ local f_xx_fill = at["fill-rule"] == "evenodd" and f_eo_fill or f_do_fill
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+ r = r + 1 result[r] = f_xx_fill(shape)
+ if color then
+ r = r + 1 ; result[r] = color
+ end
+ if opacity then
+ r = r + 1 ; result[r] = opacity
+ end
+ r = r + 1 ; result[r] = etransform or ";"
+ end
+
+ if has_stroke then
+ local wrapup = startlineproperties(at)
+ local pen, dashing, color, opacity = drawproperties(stroke,at,not has_fill)
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+ r = r + 1 ; result[r] = f_do_draw(shape)
+ if pen then
+ r = r + 1 ; result[r] = pen
+ end
+ if dashing then
+ r = r + 1 ; result[r] = dashing
+ end
+ if color then
+ r = r + 1 ; result[r] = color
+ end
+ if opacity then
+ r = r + 1 ; result[r] = opacity
+ end
+ r = r + 1 ; result[r] = etransform or ";"
+ --
+ if list then
+ addmarkers(list,begmarker,midmarker,endmarker,at)
+ end
+ --
+ if wrapup then
+ wrapup()
+ end
+ end
+
+ if eopacity then
+ r = r + 1 ; result[r] = eopacity
+ end
+
+ if cpath then
+ r = r + 1 ; result[r] = (cpath.evenodd and f_eoclip_stop or f_clip_stop)(cpath[1])
+ end
+
+ end
+
+ local f_rectangle = formatters['unitsquare xyscaled (%N,%N) shifted (%N,%N)']
+ local f_rounded = formatters['roundedsquarexy(%N,%N,%N,%N) shifted (%N,%N)']
+ local f_line = formatters['((%N,%N)--(%N,%N))']
+ local f_ellipse = formatters['(fullcircle xyscaled (%N,%N) shifted (%N,%N))']
+ local f_circle = formatters['(fullcircle scaled %N shifted (%N,%N))']
+
+ function handlers.line(c)
+ local at = c.at
+ local x1 = rawget(at,"x1")
+ local y1 = rawget(at,"y1")
+ local x2 = rawget(at,"x2")
+ local y2 = rawget(at,"y2")
+
+ x1 = x1 and asnumber_vx(x1) or 0
+ y1 = y1 and asnumber_vy(y1) or 0
+ x2 = x2 and asnumber_vx(x2) or 0
+ y2 = y2 and asnumber_vy(y2) or 0
+
+ flush(f_line(x1,y1,x2,y2),false,at)
+ end
+
+ function handlers.rect(c)
+ local at = c.at
+ local width = rawget(at,"width")
+ local height = rawget(at,"height")
+ local x = rawget(at,"x")
+ local y = rawget(at,"y")
+ local rx = rawget(at,"rx")
+ local ry = rawget(at,"ry")
+
+ width = width and asnumber_x(width) or 0
+ height = height and asnumber_y(height) or 0
+ x = x and asnumber_vx(x) or 0
+ y = y and asnumber_vy(y) or 0
+
+ y = y - height
+
+ if rx then rx = asnumber(rx) end
+ if ry then ry = asnumber(ry) end
+
+ if rx or ry then
+ if not rx then rx = ry end
+ if not ry then ry = rx end
+ flush(f_rounded(width,height,rx,ry,x,y),true,at)
+ else
+ flush(f_rectangle(width,height,x,y),true,at)
+ end
+ end
+
+ function handlers.ellipse(c)
+ local at = c.at
+ local cx = rawget(at,"cx")
+ local cy = rawget(at,"cy")
+ local rx = rawget(at,"rx")
+ local ry = rawget(at,"ry")
+
+ cx = cx and asnumber_vx(cx) or 0
+ cy = cy and asnumber_vy(cy) or 0
+ rx = rx and asnumber_r (rx) or 0
+ ry = ry and asnumber_r (ry) or 0
+
+ flush(f_ellipse(2*rx,2*ry,cx,cy),true,at)
+ end
+
+ function handlers.circle(c)
+ local at = c.at
+ local cx = rawget(at,"cx")
+ local cy = rawget(at,"cy")
+ local r = rawget(at,"r")
+
+ cx = cx and asnumber_vx(cx) or 0
+ cy = cy and asnumber_vy(cy) or 0
+ r = r and asnumber_r (r) or 0
+
+ flush(f_circle(2*r,cx,cy),true,at)
+ end
+
+ local f_lineto_z = formatters['(%N,%N)']
+ local f_lineto_n = formatters['--(%N,%N)']
+
+ local p_pair = p_optseparator * p_number_vx * p_optseparator * p_number_vy
+ local p_open = Cc("(")
+ local p_close = Carg(1) * P(true) / function(s) return s end
+ local p_polyline = Cs(p_open * (p_pair / f_lineto_z) * (p_pair / f_lineto_n)^0 * p_close)
+ local p_polypair = Ct(p_pair^0)
+
+ local function poly(c,final)
+ local at = c.at
+ local points = rawget(at,"points")
+ if points then
+ local path = lpegmatch(p_polyline,points,1,final)
+ local list = nil
+ local begmarker = rawget(at,"marker-start")
+ local midmarker = rawget(at,"marker-mid")
+ local endmarker = rawget(at,"marker-end")
+ if begmarker or midmarker or endmarker then
+ list = lpegmatch(p_polypair,points)
+ end
+ flush(path,true,at,list,begmarker,midmarker,endmarker)
+ end
+ end
+
+ function handlers.polyline(c) poly(c, ")") end
+ function handlers.polygon (c) poly(c,"--cycle)") end
+
+ local s_image_start = "draw image ("
+ local s_image_stop = ") ;"
+
+ function handlers.path(c)
+ local at = c.at
+ local d = rawget(at,"d")
+ if d then
+ local shape, l = grabpath(d)
+ local fill = at["fill"] or "black"
+ local stroke = at["stroke"] or "none"
+ local n = #shape
+
+ local btransform, etransform = handletransform(at)
+ local cpath = handleclippath(at)
+ if cpath then
+ r = r + 1 ; result[r] = s_clip_start
+ end
+
+ -- todo: image (nicer for transform too)
+
+ if fill and fill ~= "none" then
+ local color, opacity = fillproperties(fill,at)
+ local f_xx_fill = at["fill-rule"] == "evenodd"
+ if shape.closed then
+ f_xx_fill = f_xx_fill and f_eo_fill or f_do_fill
+ elseif shape.curve then
+ f_xx_fill = f_xx_fill and f_eo_fill_c or f_do_fill_c
+ else
+ f_xx_fill = f_xx_fill and f_eo_fill_l or f_do_fill_l
+ end
+ if n == 1 then
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+ r = r + 1 result[r] = f_xx_fill(shape[1])
+ if color then
+ r = r + 1 ; result[r] = color
+ end
+ if opacity then
+ r = r + 1 ; result[r] = opacity
+ end
+ r = r + 1 ; result[r] = etransform or ";"
+ else
+ r = r + 1 ; result[r] = btransform or s_image_start
+ for i=1,n do
+ if i == n then
+ r = r + 1 ; result[r] = f_xx_fill(shape[i])
+ if color then
+ r = r + 1 ; result[r] = color
+ end
+ if opacity then
+ r = r + 1 ; result[r] = opacity
+ end
+ else
+ r = r + 1 ; result[r] = f_no_fill(shape[i])
+ end
+ r = r + 1 ; result[r] = ";"
+ end
+ r = r + 1 ; result[r] = etransform or s_image_stop
+ end
+ end
+
+ if stroke and stroke ~= "none" then
+ local begmarker = rawget(at,"marker-start")
+ local midmarker = rawget(at,"marker-mid")
+ local endmarker = rawget(at,"marker-end")
+ if begmarker or midmarker or endmarker then
+ list = grablist(l)
+ end
+ local wrapup = startlineproperties(at)
+ local pen, dashing, color, opacity = drawproperties(stroke,at)
+ if n == 1 and not list then
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+ r = r + 1 result[r] = f_do_draw(shape[1])
+ if pen then
+ r = r + 1 ; result[r] = pen
+ end
+ if dashing then
+ r = r + 1 ; result[r] = dashing
+ end
+ if color then
+ r = r + 1 ; result[r] = color
+ end
+ if opacity then
+ r = r + 1 ; result[r] = opacity
+ end
+ r = r + 1 result[r] = etransform or ";"
+ else
+ r = r + 1 result[r] = btransform or "draw image ("
+ for i=1,n do
+ r = r + 1 result[r] = f_do_draw(shape[i])
+ if pen then
+ r = r + 1 ; result[r] = pen
+ end
+ if dashing then
+ r = r + 1 ; result[r] = dashing
+ end
+ if color then
+ r = r + 1 ; result[r] = color
+ end
+ if opacity then
+ r = r + 1 ; result[r] = opacity
+ end
+ r = r + 1 ; result[r] = ";"
+ end
+ if list then
+ addmarkers(list,begmarker,midmarker,endmarker,at)
+ end
+ r = r + 1 ; result[r] = etransform or ") ;"
+ end
+ if wrapup then
+ wrapup()
+ end
+ end
+
+ if cpath then
+ r = r + 1 ; result[r] = f_clip_stop(cpath[1])
+ end
+
+ end
+ end
+
+ end
+
+ -- kind of special
+
+ do
+
+ -- some day:
+ --
+ -- specification = identifiers.jpg(data."string")
+ -- specification.data = data
+ -- inclusion takes from data
+ -- specification.data = false
+
+ local f_image = formatters[ [[figure("%s") xysized (%N,%N) shifted (%N,%N)]] ]
+
+ local nofimages = 0
+
+ function handlers.image(c)
+ local at = c.at
+ local im = rawget(at,"xlink:href")
+ if im then
+ local kind, data = match(im,"^data:image/([a-z]+);base64,(.*)$")
+ if kind == "png" then
+ -- ok
+ elseif kind == "jpeg" then
+ kind = "jpg"
+ else
+ kind = false
+ end
+ if kind and data then
+ local w = rawget(at,"width")
+ local h = rawget(at,"height")
+ local x = rawget(at,"x")
+ local y = rawget(at,"y")
+ w = w and asnumber_x(w)
+ h = h and asnumber_y(h)
+ x = x and asnumber_vx(x) or 0
+ y = y and asnumber_vy(y) or 0
+ nofimages = nofimages + 1
+ local name = "temp-svg-image-" .. nofimages .. "." .. kind
+ local data = mime.decode("base64")(data)
+ io.savedata(name,data)
+ if not w or not h then
+ local info = graphics.identifiers[kind](data,"string")
+ if info then
+ -- todo: keep aspect ratio attribute
+ local xsize = info.xsize
+ local ysize = info.ysize
+ if not w then
+ if not h then
+ w = xsize
+ h = ysize
+ else
+ w = (h / ysize) * xsize
+ end
+ else
+ h = (w / xsize) * ysize
+ end
+ end
+ end
+ -- safeguard:
+ if not w then w = h or 1 end
+ if not h then h = w or 1 end
+ luatex.registertempfile(name)
+ -- done:
+ flushobject(f_image(name,w,h,x,y - h),at)
+ else
+ -- nothing done
+ end
+ end
+ end
+
+ end
+
+ -- these transform: g a text svg symbol
+
+ do
+
+ function handlers.a(c)
+ process(c,"/*")
+ end
+
+ function handlers.g(c) -- much like flushobject so better split and share
+ local at = c.at
+
+ local btransform, etransform, transform = handletransform(at)
+ local cpath, clippath = handleclippath(at)
+
+ if cpath then
+ r = r + 1 ; result[r] = s_clip_start
+ end
+
+ if btransform then
+ r= r + 1 result[r] = btransform
+ end
+
+ local _transform = transform
+ local _clippath = clippath
+ at["transform"] = false
+ at["clip-path"] = false
+
+ process(c,"/*")
+
+ at["transform"] = _transform
+ at["clip-path"] = _clippath
+
+ if etransform then
+ r = r + 1 ; result[r] = etransform
+ end
+
+ if cpath then
+ local f_done = cpath.evenodd
+ if cpath.curve then
+ f_done = f_done and f_eoclip_stop_c or f_clip_stop_c
+ else
+ f_done = f_done and f_eoclip_stop_l or f_clip_stop_l
+ end
+ r = r + 1 ; result[r] = f_done(cpath[1])
+ end
+ end
+
+ -- this will never really work out
+ --
+ -- todo: register text in lua in mapping with id, then draw mapping unless overloaded
+ -- using lmt_svglabel with family,style,weight,size,id passed
+
+ -- nested tspans are messy: they can have displacements but in inkscape we also
+ -- see x and y (inner and outer element)
+
+ -- The size is a bit of an issue. I assume that the specified size relates to the
+ -- designsize but we want to be able to use other fonts.
+
+ do
+
+ local f_styled = formatters["\\svgstyled{%s}{%s}{%s}{%s}"]
+ local f_colored = formatters["\\svgcolored{%.3N}{%.3N}{%.3N}{"]
+-- local f_placed = formatters["\\svgplaced{%.3N}{%.3N}{}{"]
+local f_placed = formatters["\\svgplaced{%s}{%s}{}{"]
+ local f_poschar = formatters["\\svgposchar{%.3N}{%.3N}{%s}"]
+ local f_char = formatters["\\svgchar{%s}"]
+
+ local f_scaled = formatters["\\svgscaled{%N}{%s}{%s}{%s}"]
+ local f_normal = formatters["\\svgnormal{%s}{%s}{%s}"]
+ local f_hashed = formatters["\\svghashed{%s}"]
+
+ -- We move to the outer (x,y) and when we have an inner offset we
+ -- (need to) compensate for that outer offset.
+
+ -- local f_text_scaled_svg = formatters['(svgtext("%s") scaled %N shifted (%N,%N))']
+ -- local f_text_normal_svg = formatters['(svgtext("%s") shifted (%N,%N))']
+ -- local f_text_simple_svg = formatters['svgtext("%s")']
+
+ local anchors = {
+ ["start"] = "drt",
+ ["end"] = "dflt",
+ ["middle"] = "d",
+ }
+
+ local f_text_normal_svg = formatters['(textext.%s("%s") shifted (%N,%N))']
+ local f_text_simple_svg = formatters['textext.%s("%s")']
+
+ -- or just maptext
+
+ local f_mapped_normal_svg = formatters['(svgtext("%s") shifted (%N,%N))']
+ local f_mapped_simple_svg = formatters['svgtext("%s")']
+
+ local cssfamily = css.family
+ local cssstyle = css.style
+ local cssweight = css.weight
+ local csssize = css.size
+
+ local usedfonts = setmetatableindex(function(t,k)
+ local v = setmetatableindex("table")
+ t[k] = v
+ return v
+ end)
+
+ local p_texescape = lpegpatterns.texescape
+
+ -- For now as I need it for my (some 1500) test files.
+
+ local function checkedfamily(name)
+ if find(name,"^.-verdana.-$") then
+ name = "verdana"
+ end
+ return name
+ end
+
+ -- todo: only escape some chars and handle space
+
+ local defaultsize = 10
+
+ local function collect(t,c,x,y,size,scale,family,tx,ty)
+ local at = c.at
+ local ax = rawget(at,"x")
+ local ay = rawget(at,"y")
+ local dx = rawget(at,"dx")
+ local dy = rawget(at,"dy")
+ local v_fill = at["fill"]
+ local v_family = at["font-family"]
+ local v_style = at["font-style"]
+ local v_weight = at["font-weight"]
+ local v_size = at["font-size"]
+ --
+ ax = ax and asnumber_vx(ax) or x
+ ay = ay and asnumber_vy(ay) or y
+ --
+local d_x = dx and asnumber_vx(dx) or 0
+local d_y = dy and asnumber_vy(dy) or 0
+ --
+ if v_family then v_family = cssfamily(v_family) end
+ if v_style then v_style = cssstyle (v_style) end
+ if v_weight then v_weight = cssweight(v_weight) end
+ if v_size then v_size = csssize (v_size,factors) or tonumber(v_size) end
+ --
+ if not v_family then v_family = family end
+ if not v_weight then v_weight = "normal" end
+ if not v_style then v_style = "normal" end
+ --
+ if v_family then
+ v_family = fonts.names.cleanname(v_family)
+ v_family = checkedfamily(v_family)
+ end
+ --
+ usedfonts[v_family][v_weight][v_style] = true
+ --
+ ax = ax - x
+ ay = ay - y
+ --
+ local elayered = ax ~= 0 or ay ~= 0 or false
+-- local eplaced = dx ~= 0 or dy ~= 0 or false
+local eplaced = d_x ~= 0 or d_y ~= 0 or false
+ local usedsize, usedscaled
+
+ if elayered then
+ -- we're now at the outer level again so we need to scale
+ -- back to the outer level values
+ t[#t+1] = formatters["\\svgsetlayer{%0N}{%0N}{"](ax,-ay)
+ usedsize = v_size or defaultsize
+ usedscale = usedsize / defaultsize
+ else
+ -- we're nested so we can be scaled
+ usedsize = v_size or size
+ usedscale = (usedsize / defaultsize) / scale
+ end
+usedscale = (10 / bodyfontscale) * usedscale
+ --
+ if eplaced then
+if dx then
+ if not find(dx,"%a") then
+ dx = dx .. "bp"
+ elseif find(dx,"e") then
+ dx = formatters["%s\\dimexpr %s\\relax"](usedscale,dx)
+ end
+else
+ dx = "0pt"
+end
+if dy then
+ if not find(dy,"%a") then
+ dy = dy .. "bp"
+ elseif find(dy,"e") then
+ dy = formatters["%s\\dimexpr %s\\relax"](usedscale,dy)
+ end
+else
+ dy = "0pt"
+end
+ t[#t+1] = f_placed(dx,dy)
+ end
+ --
+-- if usedscale == 1 then
+-- t[#t+1] = f_normal( v_family,v_weight,v_style)
+-- else
+ t[#t+1] = f_scaled(usedscale,v_family,v_weight,v_style)
+-- end
+ t[#t+1] = "{"
+ --
+ if trace_fonts then
+ report("element : %s",c.tg)
+ report(" font family : %s",v_family)
+ report(" font weight : %s",v_weight)
+ report(" font style : %s",v_style)
+ report(" parent size : %s",size)
+ report(" parent scale : %s",scale)
+ report(" used size : %s",usedsize)
+ report(" used scale : %s",usedscale)
+ report(" layered : %l",elayered)
+ end
+ --
+ local ecolored = v_fill and v_fill ~= "" or false
+ if ecolored then
+ -- todo cmyk
+ local r, g, b = colorcomponents(v_fill)
+ if r and g and b then
+ t[#t+1] = f_colored(r,g,b)
+ else
+ ecolored = false
+ end
+ end
+ --
+ local dt = c.dt
+ local nt = #dt
+ for i=1,nt do
+ local di = dt[i]
+ if type(di) == "table" then
+ -- can be a tspan (should we pass dx too)
+ collect(t,di,x,y,usedsize,usedscale,v_family)
+ else
+ if i == 1 then
+ di = gsub(di,"^%s+","")
+ end
+ if i == nt then
+ di = gsub(di,"%s+$","")
+ end
+ local chars = utfsplit(di)
+ if svghash then
+ di = f_hashed(svghash[di])
+ elseif tx then
+ for i=1,#chars do
+ chars[i] = f_poschar(
+ (tx[i] or 0) - x,
+ (ty[i] or 0) - y,
+ utfbyte(chars[i])
+ )
+ end
+ di = "{" .. concat(chars) .. "}"
+ else
+ -- this needs to be texescaped ! and even quotes and newlines
+ -- or we could register it but that's a bit tricky as we nest
+ -- and don't know what we can expect here
+ -- di = lpegmatch(p_texescape,di) or di
+ for i=1,#chars do
+ chars[i] = f_char(utfbyte(chars[i]))
+ end
+ di = concat(chars)
+ end
+ t[#t+1] = di
+ end
+ end
+ --
+ if ecolored then
+ t[#t+1] = "}"
+ end
+ --
+ t[#t+1] = "}"
+ --
+ if eplaced then
+ t[#t+1] = "}"
+ end
+ if elayered then
+ t[#t+1] = "}"
+ end
+ --
+ return t
+ end
+
+ local s_startlayer = "\\svgstartlayer "
+ local s_stoplayer = "\\svgstoplayer "
+
+ function handlers.text(c)
+ local only = fullstrip(xmltextonly(c))
+ -- if metapost.processing() then
+ local at = c.at
+ local x = rawget(at,"x")
+ local y = rawget(at,"y")
+
+-- local dx = rawget(at,"dx")
+-- local dy = rawget(at,"dy")
+
+ local tx = asnumber_vx_t(x)
+ local ty = asnumber_vy_t(y)
+
+-- dx = dx and asnumber_vx(dx) or 0
+-- dy = dy and asnumber_vy(dy) or 0
+
+ x = tx[1] or 0 -- catch bad x/y spec
+ y = ty[1] or 0 -- catch bad x/y spec
+
+ local v_fill = at["fill"]
+ if not v_fill or v_fill == "none" then
+ v_fill = "black"
+ end
+ local color, opacity, invisible = fillproperties(v_fill,at)
+ local anchor = anchors[at["text-anchor"] or "start"] or "drt"
+ local r = metapost.remappedtext(only)
+-- x = x + dx
+-- y = y + dy
+ if r then
+ if x == 0 and y == 0 then
+ only = f_mapped_simple_svg(r.index)
+ else
+ only = f_mapped_normal_svg(r.index,x,y)
+ end
+ flushobject(only,at,color,opacity)
+ if trace_text then
+ report("text: %s",only)
+ end
+ elseif not invisible then -- can be an option
+ local scale = 1
+ local textid = 0
+ local result = { }
+ local nx = #tx
+ local ny = #ty
+ --
+ result[#result+1] = s_startlayer
+ if nx > 1 or ny > 1 then
+ concat(collect(result,c,x,y,defaultsize,1,"serif",tx,ty))
+ else
+ concat(collect(result,c,x,y,defaultsize,1,"serif"))
+ end
+ result[#result+1] = s_stoplayer
+ result = concat(result)
+ if x == 0 and y == 0 then
+ result = f_text_simple_svg(anchor,result)
+ else
+ result = f_text_normal_svg(anchor,result,x,y)
+ end
+ flushobject(result,at,color,opacity)
+ if trace_text then
+ report("text: %s",result)
+ end
+ elseif trace_text then
+ report("invisible text: %s",only)
+ end
+ -- elseif trace_text then
+ -- report("ignored text: %s",only)
+ -- end
+ end
+
+ function metapost.reportsvgfonts()
+ for family, weights in sortedhash(usedfonts) do
+ for weight, styles in sortedhash(weights) do
+ for style in sortedhash(styles) do
+ report("used font: %s-%s-%s",family,weight,style)
+ end
+ end
+ end
+ end
+
+ statistics.register("used svg fonts",function()
+ if next(usedfonts) then
+ -- also in log file
+ logs.startfilelogging(report,"used svg fonts")
+ local t = { }
+ for family, weights in sortedhash(usedfonts) do
+ for weight, styles in sortedhash(weights) do
+ for style in sortedhash(styles) do
+ report("%s-%s-%s",family,weight,style)
+ t[#t+1] = formatters["%s-%s-%s"](family,weight,style)
+ end
+ end
+ end
+ logs.stopfilelogging()
+ return concat(t," ")
+ end
+ end)
+
+ end
+
+ function handlers.svg(c,x,y,w,h,noclip,notransform,normalize)
+ local at = c.at
+
+ local wrapupviewport
+ local bhacked
+ local ehacked
+ local wd = w
+ -- local ex, em
+ local xpct, ypct, rpct
+
+ local btransform, etransform, transform = handletransform(at)
+
+bodyfontscale = tex.getdimen("bodyfontsize") / 65536
+
+ if trace then
+ report("view: %s, xpct %N, ypct %N","before",percentage_x,percentage_y)
+ end
+
+ local viewbox = at.viewBox
+
+ if viewbox then
+ x, y, w, h = handleviewbox(viewbox)
+ if trace then
+ report("viewbox: x %N, y %N, width %N, height %N",x,y,w,h)
+ end
+ end
+ if not w or not h or w == 0 or h == 0 then
+ noclip = true
+ end
+ if h then
+ --
+ -- em = factors["em"]
+ -- ex = factors["ex"]
+ -- factors["em"] = em
+ -- factors["ex"] = ex
+ --
+ xpct = percentage_x
+ ypct = percentage_y
+ rpct = percentage_r
+ percentage_x = w / 100
+ percentage_y = h / 100
+ percentage_r = (sqrt(w^2 + h^2) / sqrt(2)) / 100
+ if trace then
+ report("view: %s, xpct %N, ypct %N","inside",percentage_x,percentage_y)
+ end
+ wrapupviewport = viewport(x,y,w,h,noclip)
+ end
+ -- todo: combine transform and offset here
+
+ -- some fonts need this (bad transforms + viewbox)
+ if v and normalize and w and wd and w ~= wd and w > 0 and wd > 0 then
+ bhacked = s_wrapped_start
+ ehacked = f_wrapped_stop(y or 0,wd/w)
+ end
+ if btransform then
+ r = r + 1 ; result[r] = btransform
+ end
+ if bhacked then
+ r = r + 1 ; result[r] = bhacked
+ end
+ local boffset, eoffset = offset(at)
+ if boffset then
+ r = r + 1 result[r] = boffset
+ end
+
+ at["transform"] = false
+ at["viewBox"] = false
+
+ process(c,"/*")
+
+ at["transform"] = transform
+ at["viewBox"] = viewbox
+
+ if eoffset then
+ r = r + 1 result[r] = eoffset
+ end
+ if ehacked then
+ r = r + 1 ; result[r] = ehacked
+ end
+ if etransform then
+ r = r + 1 ; result[r] = etransform
+ end
+ if h then
+ --
+ -- factors["em"] = em
+ -- factors["ex"] = ex
+ --
+ percentage_x = xpct
+ percentage_y = ypct
+ percentage_r = rpct
+ if wrapupviewport then
+ wrapupviewport()
+ end
+ end
+ if trace then
+ report("view: %s, xpct %N, ypct %N","after",percentage_x,percentage_y)
+ end
+ end
+
+ end
+
+ process = function(x,p)
+ for c in xmlcollected(x,p) do
+ local tg = c.tg
+ local h = handlers[c.tg]
+ if h then
+ h(c)
+ end
+ end
+ end
+
+ -- For huge inefficient files there can be lots of garbage to collect so
+ -- maybe we should run the collector when a file is larger than say 50K.
+
+ function metapost.svgtomp(specification,pattern,notransform,normalize)
+ local mps = ""
+ local svg = specification.data
+ if type(svg) == "string" then
+ svg = xmlconvert(svg)
+ end
+ if svg then
+ local c = xmlfirst(svg,pattern or "/svg")
+ if c then
+ root = svg
+ result = { }
+ r = 0
+ definitions = { }
+ tagstyles = { }
+ classstyles = { }
+ colormap = specification.colormap
+ usedcolors = trace_colors and setmetatableindex("number") or false
+ for s in xmlcollected(c,"style") do -- can also be in a def, so let's play safe
+ handlestyle(c)
+ end
+ handlechains(c)
+ xmlinheritattributes(c) -- put this in handlechains
+ handlers.svg (
+ c,
+ specification.x,
+ specification.y,
+ specification.width,
+ specification.height,
+ specification.noclip,
+ notransform,
+ normalize,
+ specification.remap
+ )
+ if trace_result then
+ report("result graphic:\n %\n t",result)
+ end
+ if usedcolors and next(usedcolors) then
+ report("graphic %a uses colors: %s",specification.id or "unknown",table.sequenced(usedcolors))
+ end
+ mps = concat(result," ")
+ root = false
+ result = false
+ r = false
+ definitions = false
+ tagstyles = false
+ classstyles = false
+ colormap = false
+ else
+ report("missing svg root element")
+ end
+ else
+ report("bad svg blob")
+ end
+ return mps
+ end
+
+end
+
+-- These helpers might move to their own module .. some day ... also they will become
+-- a bit more efficient, because we now go to mp and back which is kind of redundant,
+-- but for now it will do.
+
+do
+
+ local bpfactor = number.dimenfactors.bp
+
+ function metapost.includesvgfile(filename,offset) -- offset in sp
+ if lfs.isfile(filename) then
+ context.startMPcode("doublefun")
+ context('draw lmt_svg [ filename = "%s", offset = %N ] ;',filename,(offset or 0)*bpfactor)
+ context.stopMPcode()
+ end
+ end
+
+ function metapost.includesvgbuffer(name,offset) -- offset in sp
+ context.startMPcode("doublefun")
+ context('draw lmt_svg [ buffer = "%s", offset = %N ] ;',name or "",(offset or 0)*bpfactor)
+ context.stopMPcode()
+ end
+
+ interfaces.implement {
+ name = "includesvgfile",
+ actions = metapost.includesvgfile,
+ arguments = { "string", "dimension" },
+ }
+
+ interfaces.implement {
+ name = "includesvgbuffer",
+ actions = metapost.includesvgbuffer,
+ arguments = { "string", "dimension" },
+ }
+
+ function metapost.showsvgpage(data)
+ local dd = data.data
+ if not dd then
+ local fn = data.filename
+ dd = fn and table.load(fn)
+ end
+ if type(dd) == "table" then
+ local comment = data.comment
+ local offset = data.pageoffset
+ local index = data.index
+ local first = math.max(index or 1,1)
+ local last = math.min(index or #dd,#dd)
+ for i=first,last do
+ local d = setmetatableindex( {
+ data = dd[i],
+ comment = comment and i or false,
+ pageoffset = offset or nil,
+ }, data)
+ metapost.showsvgpage(d)
+ end
+ elseif data.method == "code" then
+ context.startMPcode(doublefun)
+ context(metapost.svgtomp(data))
+ context.stopMPcode()
+ else
+ context.startMPpage { instance = "doublefun", offset = data.pageoffset or nil }
+ context(metapost.svgtomp(data))
+ local comment = data.comment
+ if comment then
+ context("draw boundingbox currentpicture withcolor .6red ;")
+ context('draw textext.bot("\\strut\\tttf %s") ysized (10pt) shifted center bottomboundary currentpicture ;',comment)
+ end
+ context.stopMPpage()
+ end
+ end
+
+ function metapost.typesvgpage(data)
+ local dd = data.data
+ if not dd then
+ local fn = data.filename
+ dd = fn and table.load(fn)
+ end
+ if type(dd) == "table" then
+ local index = data.index
+ if index and index > 0 and index <= #dd then
+ data = dd[index]
+ else
+ data = nil
+ end
+ end
+ if type(data) == "string" and data ~= "" then
+ buffers.assign("svgpage",data)
+ context.typebuffer ({ "svgpage" }, { option = "XML", strip = "yes" })
+ end
+ end
+
+ function metapost.svgtopdf(data,...)
+ local mps = metapost.svgtomp(data,...)
+ if mps then
+ -- todo: special instance, only basics needed
+ local pdf = metapost.simple("metafun",mps,true,false,"svg")
+ if pdf then
+ return pdf
+ else
+ -- message
+ end
+ else
+ -- message
+ end
+ end
+
+end
+
+do
+
+ local runner = sandbox.registerrunner {
+ name = "otfsvg2pdf",
+ program = "context",
+ template = "--batchmode --purgeall --runs=2 %filename%",
+ reporter = report_svg,
+ }
+
+ -- By using an independent pdf file instead of pdf streams we can use resources and still
+ -- cache. This is the old method updated. Maybe a future version will just do this runtime
+ -- but for now this is the most efficient method.
+
+ local decompress = gzip.decompress
+ local compress = gzip.compress
+
+ function metapost.svgshapestopdf(svgshapes,pdftarget,report_svg)
+ local texname = "temp-otf-svg-to-pdf.tex"
+ local pdfname = "temp-otf-svg-to-pdf.pdf"
+ local tucname = "temp-otf-svg-to-pdf.tuc"
+ local nofshapes = #svgshapes
+ local pdfpages = { filename = pdftarget }
+ local pdfpage = 0
+ local t = { }
+ local n = 0
+ --
+ os.remove(texname)
+ os.remove(pdfname)
+ os.remove(tucname)
+ --
+ if report_svg then
+ report_svg("processing %i svg containers",nofshapes)
+ statistics.starttiming(pdfpages)
+ end
+ --
+ -- can be option:
+ --
+ -- n = n + 1 ; t[n] = "\\nopdfcompression"
+ --
+ n = n + 1 ; t[n] = "\\starttext"
+ n = n + 1 ; t[n] = "\\setupMPpage[alternative=offset,instance=doublefun]"
+ --
+ for i=1,nofshapes do
+ local entry = svgshapes[i]
+ local data = entry.data
+ if decompress then
+ data = decompress(data) or data
+ end
+ local specification = {
+ data = xmlconvert(data),
+ x = 0,
+ y = 1000,
+ width = 1000,
+ height = 1000,
+ noclip = true,
+ }
+ for index=entry.first,entry.last do
+ if not pdfpages[index] then
+ pdfpage = pdfpage + 1
+ pdfpages[index] = pdfpage
+ local pattern = "/svg[@id='glyph" .. index .. "']"
+ n = n + 1 ; t[n] = "\\startMPpage"
+ n = n + 1 ; t[n] = metapost.svgtomp(specification,pattern,true,true) or ""
+ n = n + 1 ; t[n] = "\\stopMPpage"
+ end
+ end
+ end
+ n = n + 1 ; t[n] = "\\stoptext"
+ io.savedata(texname,concat(t,"\n"))
+ runner { filename = texname }
+ os.remove(pdftarget)
+ file.copy(pdfname,pdftarget)
+ if report_svg then
+ statistics.stoptiming(pdfpages)
+ report_svg("svg conversion time %s",statistics.elapsedseconds(pdfpages))
+ end
+ os.remove(texname)
+ os.remove(pdfname)
+ os.remove(tucname)
+ return pdfpages
+ end
+
+ function metapost.svgshapestomp(svgshapes,report_svg)
+ local nofshapes = #svgshapes
+ local mpshapes = { }
+ if report_svg then
+ report_svg("processing %i svg containers",nofshapes)
+ statistics.starttiming(mpshapes)
+ end
+ for i=1,nofshapes do
+ local entry = svgshapes[i]
+ local data = entry.data
+ if decompress then
+ data = decompress(data) or data
+ end
+ local specification = {
+ data = xmlconvert(data),
+ x = 0,
+ y = 1000,
+ width = 1000,
+ height = 1000,
+ noclip = true,
+ }
+ for index=entry.first,entry.last do
+ if not mpshapes[index] then
+ local pattern = "/svg[@id='glyph" .. index .. "']"
+ local mpcode = metapost.svgtomp(specification,pattern,true,true) or ""
+ if mpcode ~= "" and compress then
+ mpcode = compress(mpcode) or mpcode
+ end
+ mpshapes[index] = mpcode
+ end
+ end
+ end
+ if report_svg then
+ statistics.stoptiming(mpshapes)
+ report_svg("svg conversion time %s",statistics.elapsedseconds(mpshapes))
+ end
+ return mpshapes
+ end
+
+ function metapost.svgglyphtomp(fontname,unicode)
+ if fontname and unicode then
+ local id = fonts.definers.internal { name = fontname }
+ if id then
+ local tfmdata = fonts.hashes.identifiers[id]
+ if tfmdata then
+ local properties = tfmdata.properties
+ local svg = properties.svg
+ local hash = svg and svg.hash
+ local timestamp = svg and svg.timestamp
+ if hash then
+ local svgfile = containers.read(fonts.handlers.otf.svgcache,hash)
+ local svgshapes = svgfile and svgfile.svgshapes
+ if svgshapes then
+ if type(unicode) == "string" then
+ unicode = utfbyte(unicode)
+ end
+ local chardata = tfmdata.characters[unicode]
+ local index = chardata and chardata.index
+ if index then
+ for i=1,#svgshapes do
+ local entry = svgshapes[i]
+ if index >= entry.first and index <= entry.last then
+ local data = entry.data
+ if data then
+ local root = xml.convert(gzip.decompress(data) or data)
+ return metapost.svgtomp (
+ {
+ data = root,
+ x = 0,
+ y = 1000,
+ width = 1000,
+ height = 1000,
+ noclip = true,
+ },
+ "/svg[@id='glyph" .. index .. "']",
+ true,
+ true
+ )
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mult-aux.mkxl b/Master/texmf-dist/tex/context/base/mkxl/mult-aux.mkxl
new file mode 100644
index 00000000000..40667e17d85
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mult-aux.mkxl
@@ -0,0 +1,1172 @@
+%D \module
+%D [ file=mult-aux,
+%D version=2010.08.2,
+%D title=\CONTEXT\ Multilingual Macros,
+%D subtitle=Helpers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D A generalization of \MKIV-like inheritance. Just something to play with
+%D (interface might change). The code here evolved in an email exchange between me
+%D and Wolgang Schuster.
+
+\writestatus{loading}{ConTeXt Multilingual Macros / Helpers}
+
+\registerctxluafile{mult-aux}{}
+
+\unprotect
+
+\immutable\edef\??empty{\Uchar25} \immutable\letvalue{\Uchar25}\empty % hex 19
+
+% \edef\s!parent{\Uchar29} % inlining is ugly, a tiny bit faster, but neglectable on a run
+
+%D \starttyping
+%D \unprotect
+%D \def\????aa{@@@@aa}
+%D
+%D \installparameterhandler \????aa {whatever}
+%D \installsetuphandler \????aa {whatever}
+%D \installdefinehandler \????aa {whatever} \????aa % #3 == defaultroot
+%D \installfontandcolorhandler\????aa {whatever}
+%D
+%D % \installcommandhandler \????aa {whatever} \????aa
+%D \protect
+%D
+%D % \whateverparameter \c!test
+%D % \whateverparameterhash \c!test
+%D % \namedwhateverparameter \mycurrentwhatever \c!test
+%D % \usewhateverstyleandcolor \c!style \c!color
+%D % \everydefinewhatever (sets \currentwhatever)
+%D % \everypresetwhatever (can be used to reset parameters as we can redefine)
+%D % \everysetupwhatever (sets \currentwhatever)
+%D
+%D \starttext
+%D \definewhatever[first] \definewhatever[second][first]
+%D test: \def\currentwhatever{first} \whateverparameter{method} \par
+%D \setupwhatever [method=unset] test: \def\currentwhatever{first} \whateverparameter{method} \par
+%D \setupwhatever[first] [method=first] test: \def\currentwhatever{first} \whateverparameter{method} \par
+%D test: \def\currentwhatever{second} \whateverparameter{method} \par
+%D \setupwhatever[second][method=second] test: \def\currentwhatever{second} \whateverparameter{method} \par
+%D \stoptext
+%D \stoptyping
+
+% problem: every* could clash
+%
+% There can be less {} in the following definitions if we assume \??aa and \c!somecs
+%
+% todo: \def\detokenized...parameter#1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2\endcsname}} % always root
+%
+% it might be more efficient to do this at the lua and
+%
+% watch the push/pop and predefinition of current .. this is needed for nested
+% definitions and overloaded defines using the predefined one
+
+% todo: add (relaxed) postsetup and postdefine hooks, just after the everys
+
+%D Start of experimental code: especially tables can have many assignments and
+%D although most time is spent in the typesetting anyway, we can squeeze out a
+%D little bit. Of course having 500 rows of 50 columns each with some setting does
+%D not happen that often. One should keep in mind that in the average document
+%D having some 500 assignments is no exception but there we're talking of
+%D neglectable runtime for them. Of course in the definitions below there is no real
+%D gain, only in the generated \setup* commands. Another situation with many
+%D assignments is \XML\ where we can pass attributes and normally don't do testing
+%D of them making sense.
+%
+% \testfeatureonce{100000}{\getparameters[bla][a=111,b=222,c=333]}% 1.669s
+% \testfeatureonce{100000}{\mult_interfaces_get_parameters{bla} [a=111,b=222,c=333]}% 1.529s
+% \testfeatureonce{100000}{\def\m_mult_interfaces_namespace{bla}\mult_interfaces_get_parameters_indeed[a=111,b=222,c=333]}% 1.466s
+
+% KEEP THIS:
+%
+% \let\m_mult_interfaces_namespace\empty
+%
+% \def\mult_interfaces_get_parameters#1[#2%
+% {\if\noexpand#2]%
+% \expandafter\gobbleoneargument
+% \else
+% \def\m_mult_interfaces_namespace{#1}%
+% \expandafter\mult_interfaces_get_parameters_indeed
+% \fi#2}
+%
+% \def\mult_interfaces_get_parameters_indeed#1]% namespace already set
+% {\mult_interfaces_get_parameters_item#1,],^^^^0004}
+%
+% \def\mult_interfaces_get_parameters_item#1,#2% #2 takes space before ,
+% {\if,#1,% dirty trick for testing #1=empty
+% \expandafter\mult_interfaces_get_parameters_item
+% \orelse\if]#1%
+% \expandafter\gobbleoneargument
+% \else
+% \mult_interfaces_get_parameters_assign#1==\empty^^^^0004%
+% % \expandafter\mult_interfaces_get_parameters_item % saves skipping when at end
+% \fi#2}
+%
+% \def\mult_interfaces_get_parameters_error#1#2% #3%
+% {\mult_interfaces_get_parameters_error_indeed{#1}{#2}%
+% \gobbleoneargument}
+%
+% \def\mult_interfaces_get_parameters_error_indeed#1#2%
+% {\showassignerror{#2}{\the\inputlineno\space(#1)}}
+%
+% \def\mult_interfaces_get_parameters_assign#1=#2=#3#0^^^^0004%
+% {\ifx\empty#1\empty
+% \expandafter\mult_interfaces_get_parameters_error
+% \orelse\ifx#3\empty
+% \expandafter\mult_interfaces_get_parameters_error
+% \else
+% \expandafter\mult_interfaces_adef % assignment def
+% \fi
+% \m_mult_interfaces_namespace{#1}{#2}%
+% \doubleexpandafter\mult_interfaces_get_parameters_item}
+%
+% \startinterface english
+%
+% % some 10% faster
+%
+% \let\mult_interfaces_get_parameters_error\undefined
+%
+% \def\mult_interfaces_get_parameters_error_one#0\csname#2#3\endcsname#0%
+% {\mult_interfaces_get_parameters_error_indeed{#2}{#3}\iftrue}
+%
+% \def\mult_interfaces_get_parameters_error_two#0\csname#2#3\endcsname#0%
+% {\mult_interfaces_get_parameters_error_indeed{#2}{#3}}
+%
+% \def\mult_interfaces_get_parameters_assign#1=#2=#3#0^^^^0004%
+% {\ifx\empty#1\empty
+% \mult_interfaces_get_parameters_error_one
+% \orelse\ifx#3\empty
+% \mult_interfaces_get_parameters_error_two
+% \else
+% \defcsname\m_mult_interfaces_namespace#1\endcsname{#2}%
+% \fi
+% \doubleexpandafter\mult_interfaces_get_parameters_item}
+%
+% \stopinterface
+%
+% \newif\ifassignment
+%
+% \def\mult_check_for_assignment_indeed#0=#2#0^^^^0004%
+% {\if#2^^^^0003\assignmentfalse\else\assignmenttrue\fi}
+%
+% \def\mult_check_for_assignment_indeed_begin_#0=#2#0^^^^0004%
+% {\if#2^^^^0003}
+%
+% \def\mult_check_for_assignment#1%
+% {\expandafter\mult_check_for_assignment_indeed\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
+%
+% % End of experimental code.
+
+%D We keep the above as reference, but from now on experiment with the following
+%D implementation. In principle this one is faster, but because normally we don't
+%D have that many assignments it doesn't get noticed. For instance, the \LUAMETATEX\
+%D manual does less than 6000 assignments and the payoff starts around a tenfold of
+%D that. But \unknown\ it's less tracing, so that's another benefit.
+
+%D Watch out: we accept that a \[k=v,,k=v] will generate a case where a key can become
+%D a comma and trigger a warning but we intercept that elsewhere. The alternative is
+%D to skip to the comma first which takes more time.
+
+\let\m_mult_interfaces_namespace\empty
+
+\def\mult_interfaces_get_parameters#1[%
+ {\def\m_mult_interfaces_namespace{#1}%
+ \futureexpandis]\gobbleoneargument\mult_interfaces_get_parameters_indeed}
+
+\def\mult_interfaces_get_parameters_indeed#1]%
+ {\mult_interfaces_get_parameters_item#1\ignorearguments\ignorearguments}
+
+\def\mult_interfaces_get_parameters_item#*#1,%
+ {\ifarguments \else
+ \mult_interfaces_get_parameters_item_okay#1,\ignorearguments
+ \expandafter\mult_interfaces_get_parameters_item
+ \fi}
+
+\def\mult_interfaces_get_parameters_item_okay#1=#2,%
+ {\ifarguments
+ % done
+ \or
+ \mult_interfaces_get_parameters_item_error
+ \else
+ \mult_interfaces_adef\m_mult_interfaces_namespace{#1}{#2}%
+ \fi}
+
+\def\mult_interfaces_get_parameters_item_error#-#-#-#1#2%
+ {\if,#2\else\mult_interfaces_get_parameters_error_indeed{#1}{#2}\fi}
+
+\startinterface english
+
+ \def\mult_interfaces_get_parameters_item_okay#1=#2,%
+ {\ifarguments
+ % done
+ \or
+ \mult_interfaces_get_parameters_item_error
+ \else
+ \defcsname\m_mult_interfaces_namespace#1\endcsname{#2}%
+ \fi}
+
+ \def\mult_interfaces_get_parameters_item_error#-\defcsname#1#2\endcsname#-%
+ {\if,#2\else\mult_interfaces_get_parameters_error_indeed{#1}{#2}\fi}
+
+\stopinterface
+
+%D Used?
+
+\def\mult_check_for_assignment_indeed#-=#1#-^^^^0004%
+ {\if#1^^^^0003\assignmentfalse\else\assignmenttrue\fi}
+
+\def\mult_check_for_assignment_indeed_begin_#-=#1#-^^^^0004%
+ {\if#1^^^^0003}
+
+\def\mult_check_for_assignment#1%
+ {\expandafter\mult_check_for_assignment_indeed\detokenize{#1}=^^^^0003^^^^0003^^^^0004}
+
+%D Beware, zero arguments is an assignment!
+
+\def\mult_aux_no_assignment_indeed#1=#2]{\ifcase\ifarguments\plusone\or\zerocount\else\plusone\fi}
+\def\mult_aux_no_assignment#1]{\mult_aux_no_assignment_indeed#1\ignorearguments\relax}
+
+%D This can give wrong results when we pass e.g. \type{\c!format}, so either we need
+%D to use the \type {\k!} ones, but these are not defined in the english interface
+%D so from now on we assume that the low level ones are used with the symbolic names
+%D and that only the high level setup commands are used with language specific
+%D interfaces.
+
+% \startinterface english
+ \protected\def\mult_interfaces_let #1#2{\letcsname#1#2\endcsname}
+ \protected\def\mult_interfaces_lete#1#2{\letcsname#1#2\endcsname\empty}
+ \protected\def\mult_interfaces_def #1#2{\defcsname#1#2\endcsname}
+ \protected\def\mult_interfaces_edef#1#2{\edefcsname#1#2\endcsname}
+ \protected\def\mult_interfaces_gdef#1#2{\gdefcsname#1#2\endcsname}
+ \protected\def\mult_interfaces_xdef#1#2{\xdefcsname#1#2\endcsname}
+% \stopinterface
+
+%D Do, we only interface the assignment definition:
+
+\protected\def\mult_interfaces_adef#1#2{\defcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+
+\startinterface english
+ \protected\def\mult_interfaces_adef#1#2{\defcsname#1#2\endcsname}
+\stopinterface
+
+% the commented detokenized variant that backtracks ... needs testing usage first
+%
+% \let\whatever\relax
+%
+% \definetest[oeps][bagger=\whatever]
+%
+% \def\currenttest{oeps} \edef\hans{\detokenizedtestparameter{bagger}}\meaning\hans\par
+% \def\currenttest{oeps} \edef\hans{\detokenizedtestparameter{reggab}}\meaning\hans\par
+%
+% slower: \def#3##1{\csname\ifcsname#1#2:##1\endcsname\expandafter\csstring\lastnamedcs\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
+
+%D pre-expansion can be a bit faster but handly any effect on a normal run so let's
+%D go for saving some memory
+
+\def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter}
+
+\protected\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9%
+ {\frozen\def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
+ \frozen\def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
+ \frozen\edef#5##1##2{\noexpand\ifrelax##1\??empty\noexpand\else\noexpand#4##1{##2}\noexpand\fi}% is {} needed around ##1 ?
+ \frozen\def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}%
+ \frozen\def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack
+ \frozen\def#8##1{\begincsname#1#2:##1\endcsname}%
+ % TODO
+ \frozen\def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}}
+
+\permanent\protected\def\installparameterhandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_parameter_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname #2parameter\endcsname
+ \expandafter\noexpand\csname do#2parameter\endcsname % or: #2_parameter
+ \expandafter\noexpand\csname do#2parentparameter\endcsname % or: #2_parent_parameter
+ \expandafter\noexpand\csname named#2parameter\endcsname
+ \expandafter\noexpand\csname detokenized#2parameter\endcsname
+ \expandafter\noexpand\csname direct#2parameter\endcsname
+ \expandafter\noexpand\csname letfrom#2parameter\endcsname}} % strict#2parameter is gone
+
+\protected\def\mult_interfaces_install_root_parameter_handler#1#2#3%
+ {\frozen\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root
+ \frozen\def#3##1{\begincsname#1:##1\endcsname}}
+
+\permanent\protected\def\installrootparameterhandler#1#2%
+ {\normalexpanded
+ {\mult_interfaces_install_root_parameter_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname detokenizedroot#2parameter\endcsname
+ \expandafter\noexpand\csname root#2parameter\endcsname}}
+
+\protected\def\mult_interfaces_install_parameter_hash_handler#1#2#3#4#5#6#7#8#9%
+ {\frozen\def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used?
+ \frozen\def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
+ \frozen\def#5##1##2{\ifrelax##1\else#4##1{##2}\fi}%
+ \frozen\def#6{#1#2:}%
+ \frozen\def#7##1{#1##1:}%
+ \frozen\def#8{\ifempty#2\orelse\ifcsname#1#2:\s!parent\endcsname\else\letcsname#1#2:\s!parent\endcsname#1\fi}%
+ \frozen\protected\def#9##1{\edefcsname#1##1:\s!parent\endcsname{#1#2}}}
+
+\permanent\protected\def\installparameterhashhandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \immutable\letcsname#2namespace\endcsname#1%
+ \normalexpanded
+ {\mult_interfaces_install_parameter_hash_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname #2parameterhash\endcsname
+ \expandafter\noexpand\csname do#2parameterhash\endcsname % or : #2_parameter_hash
+ \expandafter\noexpand\csname do#2parentparameterhash\endcsname % or : #2_parent_parameter_hash
+ \expandafter\noexpand\csname current#2hash\endcsname
+ \expandafter\noexpand\csname named#2hash\endcsname
+ \expandafter\noexpand\csname check#2parent\endcsname
+ \expandafter\noexpand\csname chaintocurrent#2\endcsname}}
+
+%D In \MKIV\ we can probably use the english variant for all other languages too.
+
+% todo: inline the def/let
+
+% \startinterface english
+ \protected\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6%
+ {\frozen\protected\def#3##1{\defcsname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
+ \frozen\protected\def#4##1{\edefcsname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate)
+ \frozen\protected\def#5##1{\letcsname#1#2:##1\endcsname}% ##1 ##2
+ \frozen\protected\def#6##1{\letcsname#1#2:##1\endcsname\empty}}% ##1
+% \stopinterface
+
+\permanent\protected\def\installparametersethandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_parameter_set_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname set#2parameter\endcsname
+ \expandafter\noexpand\csname setexpanded#2parameter\endcsname
+ \expandafter\noexpand\csname let#2parameter\endcsname
+ \expandafter\noexpand\csname reset#2parameter\endcsname}}
+
+\mutable\let\dousecurrentstyleparameter\relax
+\mutable\let\dousecurrentcolorparameter\relax
+
+\mutable\let\currentstyleparameter\empty
+\mutable\let\currentcolorparameter\empty
+
+\protected\def\mult_interfaces_install_style_and_color_handler#1#2#3#4%
+ {\frozen\protected\def#2##1##2% style color
+ {\edef\currentstyleparameter{#1{##1}}% this name is public (can also set color e.g. in underline)
+ \ifempty\currentstyleparameter\else\dousecurrentstyleparameter\fi
+ \edef\currentcolorparameter{#1{##2}}% this name is public (so we do this after the style switch)
+ \ifempty\currentcolorparameter\else\dousecurrentcolorparameter\fi}%
+ \frozen\protected\def#3##1% style
+ {\edef\currentstyleparameter{#1{##1}}% this name is public
+ \ifempty\currentstyleparameter\else\dousecurrentstyleparameter\fi}%
+ \frozen\protected\def#4##1% color
+ {\edef\currentcolorparameter{#1{##1}}% this name is public
+ \ifempty\currentcolorparameter\else\dousecurrentcolorparameter\fi}}
+
+\permanent\protected\def\installstyleandcolorhandler#1#2%
+ {\normalexpanded
+ {\mult_interfaces_install_style_and_color_handler
+ \expandafter\noexpand\csname #2parameter\endcsname
+ \expandafter\noexpand\csname use#2styleandcolor\endcsname % maybe an alias use#2styleandcolorparameters
+ \expandafter\noexpand\csname use#2styleparameter\endcsname
+ \expandafter\noexpand\csname use#2colorparameter\endcsname}}
+
+\def\mult_check_for_parent#1#2#3#4%
+ {\ifcsname#1#4:\s!parent\endcsname\orelse\ifx#4\empty\else
+ \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}%
+ \edefcsname#1#4:\s!parent\endcsname{#2}%
+ \fi}
+
+ \def\mult_interfaces_chain#1#2{\ifcsname#1#2:\s!chain\endcsname\lastnamedcs\space\fi}
+\permanent\def\getparentchain #1#2{\begincsname#1#2:\s!chain\endcsname}
+\permanent\def\getcurrentparentchain#1#2{\begincsname#1#2:\s!chain\endcsname}
+
+% we could have a \setcurrent... macro and then always make them a frozen
+% but it might have a little impact on performance ... something to leave
+% to when we're done with the transition (it's kind of massive)
+
+\protected\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8% why is \expanded still needed in clones
+ {\newtoks#5%
+ \newtoks#6%
+ \frozen\tolerant\protected\def#2[##1]##*[##2]##*[##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
+ {\let#8#4%
+ % watch out: no \edef#4{##1} before the ifarguments because #1 can have macros
+ \ifarguments
+ \let#4\empty
+ \the#5% predefine
+ \let#7\empty
+ \letcsname#1#4:\s!chain\endcsname\empty
+ \edefcsname#1#4:\s!parent\endcsname{#3}%
+ \or
+ \edef#4{##1}%
+ \the#5% predefine
+ \let#7\empty
+ \edefcsname#1#4:\s!chain\endcsname{##1}%
+ \edefcsname#1#4:\s!parent\endcsname{#3}%
+ \or
+ \edef#4{##1}%
+ \the#5% predefine
+ \relax
+ \ifhastok={##2}%
+ \let#7\empty
+ \edefcsname#1#4:\s!chain\endcsname{##1}%
+ \edefcsname#1#4:\s!parent\endcsname{#3}%
+ \mult_interfaces_get_parameters{#1#4:}[##2]%
+ \else
+ \edef#7{##2}%
+ \ifempty#7%
+ \edefcsname#1#4:\s!chain\endcsname{##1}%
+ \edefcsname#1#4:\s!parent\endcsname{#3}%
+ \else
+ \mult_check_for_parent{#1}{#3}#4#7%
+ \edefcsname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}%
+ \edefcsname#1#4:\s!parent\endcsname{#1##2}%
+ \fi
+ \fi
+ \or
+ \edef#4{##1}%
+ \the#5% predefine
+ \edef#7{##2}%
+ \mult_check_for_parent{#1}{#3}#4#7%
+ \edefcsname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}%
+ \edefcsname#1#4:\s!parent\endcsname{#1##2}%
+ \mult_interfaces_get_parameters{#1#4:}[##3]%
+ \fi
+ \the#6%
+ \let#4#8}}
+
+\permanent\protected\def\installdefinehandler#1#2#3%
+ {\mutable\letcsname current#2\endcsname\empty
+ \mutable\letcsname current#2parent\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_define_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname define#2\endcsname
+ {\noexpand#3}% root
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname everypreset#2\endcsname
+ \expandafter\noexpand\csname everydefine#2\endcsname
+ \expandafter\noexpand\csname current#2parent\endcsname
+ \expandafter\noexpand\csname saved_defined_#2\endcsname}}
+
+\protected\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8%
+ {\newtoks#4%
+ \newtoks#7%
+ \frozen\protected\def#5{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
+ \frozen\tolerant\protected\def#2[##1]##*[##2]% maybe helper
+ {\let#6#3%
+ \ifnum\lastarguments=\plustwo
+ \def#8####1% we will have a simple one as well
+ {\edef#3{####1}%
+ \mult_interfaces_get_parameters{#1#3:}[##2]%
+ \the#4}%
+ \processcommalist[##1]#8%
+ \else
+ \let#3\empty
+ \mult_interfaces_get_parameters{#1:}[##1]%
+ \the#4%
+ \fi
+ \let#3#6%
+ \the#7}}
+
+\permanent\protected\def\installsetuphandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_setup_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname setup#2\endcsname
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname everysetup#2\endcsname
+ \expandafter\noexpand\csname setupcurrent#2\endcsname
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname
+ \expandafter\noexpand\csname everysetup#2root\endcsname
+ \expandafter\noexpand\csname nested_setup_current#2\endcsname}}
+
+\aliased\let\doingrootsetupnamed\plusone % \setuplayout[name][key=value]
+\aliased\let\doingrootsetuproot \plustwo % \setuplayout [key=value]
+\aliased\let\doingrootsetnamed \plusthree % \setuplayout[name]
+\aliased\let\doingrootsetroot \plusfour % \setuplayout
+
+\protected\def\mult_interfaces_install_switch_setup_handler_a#1#2#3%
+ {\frozen\protected\def#3{\mult_interfaces_get_parameters{#1#2:}}}
+
+\protected\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9%
+ {\newtoks#5%
+ \newconstant#2%
+ \newtoks#8%
+ \newtoks#9%
+ \frozen\tolerant\protected\def#4[##1]##*[##2]% maybe helper
+ {\ifarguments
+ % \setuplayout
+ \let#6#3% % previous becomes current
+ \let#3\empty % current becomes empty
+ #2\doingrootsetroot
+ \the#5%
+ \the#8% switchsetups
+ \or
+ \ifhastok={##1}%
+ % \setuplayout[key=value]
+ \let#7#3%
+ \let#6#3%
+ \let#3\empty
+ #2\doingrootsetuproot
+ \mult_interfaces_get_parameters{#1:}[##1]%
+ \the#5%
+ \the#8% switchsetups
+ \let#3#7%
+ \else
+ % \setuplayout[whatever]
+ \let#6#3% % previous becomes current
+ \edef#3{##1}% this will catch reset so one needs to test for it
+ \ifempty#3%
+ \let#7#6%
+ #2\doingrootsetuproot
+ \the#5%
+ \the#8% switchsetups
+ \let#3#7%
+ \else
+ #2\doingrootsetnamed
+ \the#5% % we can check for previous vs current
+ \the#8% switchsetups
+ \fi
+ \fi
+ \or
+ % \setuplayout[whatever][key=value]
+ \let#7#3%
+ \let#6#3%
+ \edef#3{##1}%
+ #2\doingrootsetupnamed
+ \mult_interfaces_get_parameters{#1#3:}[##2]%
+ \the#5%
+ \ifx#3#6\the#8\fi % only switchsetups if previous == current
+ \let#3#7%
+ \fi
+ #2\zerocount % mode is always zero at the end
+ \the#9}}
+
+\permanent\protected\def\installswitchsetuphandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \mutable\letcsname previous#2\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_switch_setup_handler_a
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname setupcurrent#2\endcsname
+ \mult_interfaces_install_switch_setup_handler_b
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname #2setupmode\endcsname
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname setup#2\endcsname
+ \expandafter\noexpand\csname everysetup#2\endcsname
+ \expandafter\noexpand\csname previous#2\endcsname
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname
+ \expandafter\noexpand\csname everyswitch#2\endcsname
+ \expandafter\noexpand\csname everysetup#2root\endcsname}}
+
+\protected\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8%
+ {\newtoks#4%
+ \frozen\protected\def#5{\mult_interfaces_get_parameters{#1#3:}}%
+ \frozen\tolerant\protected\def#2[##1]##*[##2]##*[##3]%
+ {\let#7#3%
+ \ifarguments
+ \let#3\empty
+ \the#5%
+ \or
+ \let#3\empty
+ \mult_interfaces_get_parameters{#1:}[##1]%
+ \the#4%
+ \or
+ \def#8####1%
+ {\edef#3{####1}%
+ #6% checks parent and sets if needed
+ \mult_interfaces_get_parameters{#1#3:}[##2]%
+ \the#4}%
+ \processcommalist[##1]#8%
+ \or
+ \def#8####1%
+ {\edef#3{####1}%
+ \defcsname#1#3:\s!parent\endcsname{#1##2}%
+ \mult_interfaces_get_parameters{#1#3:}[##3]% always sets parent
+ \the#4}%
+ \processcommalist[##1]#8%
+ \fi
+ \let#3#7}}
+
+\permanent\protected\def\installautosetuphandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_auto_setup_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname setup#2\endcsname
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname everysetup#2\endcsname
+ \expandafter\noexpand\csname setupcurrent#2\endcsname
+ \expandafter\noexpand\csname check#2parent\endcsname
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname
+ \expandafter\noexpand\csname nested_setup_current#2\endcsname}}
+
+\permanent\protected\def\installbasicparameterhandler#1#2%
+ {\installparameterhandler {#1}{#2}%
+ \installparameterhashhandler{#1}{#2}%
+ \installparametersethandler {#1}{#2}%
+ \installrootparameterhandler{#1}{#2}}
+
+\permanent\protected\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
+ {\installbasicparameterhandler{#1}{#2}%
+ \installautosetuphandler {#1}{#2}}
+
+\permanent\protected\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self)
+ {\installbasicparameterhandler{#1}{#2}%
+ \installautosetuphandler {#1}{#2}%
+ \installstyleandcolorhandler {#1}{#2}}
+
+\permanent\protected\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self)
+ {\installbasicparameterhandler{#1}{#2}%
+ \installdefinehandler {#1}{#2}{#3}%
+ \installsetuphandler {#1}{#2}%
+ \installstyleandcolorhandler {#1}{#2}}
+
+\permanent\protected\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self)
+ {\installbasicparameterhandler{#1}{#2}%
+ \installdefinehandler {#1}{#2}{#3}%
+ \installswitchsetuphandler {#1}{#2}%
+ \installstyleandcolorhandler {#1}{#2}}
+
+\permanent\protected\def\installautocommandhandler#1#2#3% automatically defined cloned setups
+ {\installbasicparameterhandler{#1}{#2}%
+ \installdefinehandler {#1}{#2}{#3}%
+ \installautosetuphandler {#1}{#2}%
+ \installstyleandcolorhandler {#1}{#2}}
+
+\permanent\protected\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining
+ {\installbasicparameterhandler{#1}{#2}%
+ \installsetuphandler {#1}{#2}%
+ \installstyleandcolorhandler {#1}{#2}}
+
+%D Many mechanisms have some kind of inheritance in place, and these are the
+%D speed||critical ones. Therefore there is no reason to stick to \type {\@@xxkey}
+%D for the sake of performance. For this reason we also provide a direct variant.
+%D This permits a more consistent treatment of namespaces. A \type
+%D {\whateverparameter} call is three times slower and a \type
+%D {\directwhateverparameter} call two times but for some 100K expansions we only
+%D loose some .1 second which is neglectable given the small amount of expansions in
+%D real runs.
+
+%D We don't need colons for such simple cases.
+
+\protected\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4#5%
+ {\frozen\def#3##1{\begincsname#1##1\endcsname}%
+ \frozen\def#4##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}%
+ \frozen\def#5##1{\begincsname#1##1\endcsname}}
+
+\permanent\protected\def\installdirectparameterhandler#1#2%
+ {\mutable\letcsname current#2\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_direct_parameter_handler
+ {\noexpand#1}%
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname #2parameter\endcsname
+ \expandafter\noexpand\csname detokenized#2parameter\endcsname
+ \expandafter\noexpand\csname direct#2parameter\endcsname}}
+
+\protected\def\mult_interfaces_install_direct_setup_handler#1#2#3#4%
+ {\newtoks#4%
+ \frozen\protected\def#2[##1]{\ifarguments\or\mult_interfaces_get_parameters#1[##1]\fi\the#4}%
+ \frozen\def#3{\mult_interfaces_get_parameters#1}}
+
+\permanent\protected\def\installdirectsetuphandler#1#2%
+ {\normalexpanded
+ {\mult_interfaces_install_direct_setup_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname setup#2\endcsname
+ \expandafter\noexpand\csname setupcurrent#2\endcsname % no \every (we use 'current' for consistency)
+ \expandafter\noexpand\csname everysetup#2\endcsname}}
+
+% \startinterface english
+ \protected\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5%
+ {\frozen\protected\def#2##1{\defcsname#1##1\endcsname}%
+ \frozen\protected\def#3##1{\edefcsname#1##1\endcsname}%
+ \frozen\protected\def#4##1{\letcsname#1##1\endcsname}%
+ \frozen\protected\def#5##1{\letcsname#1##1\endcsname\empty}}%
+% \stopinterface
+
+\permanent\protected\def\installdirectparametersethandler#1#2%
+ {\normalexpanded
+ {\mult_interfaces_install_direct_parameter_set_handler
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname set#2parameter\endcsname
+ \expandafter\noexpand\csname setexpanded#2parameter\endcsname
+ \expandafter\noexpand\csname let#2parameter\endcsname
+ \expandafter\noexpand\csname reset#2parameter\endcsname}}
+
+\aliased\let\installdirectstyleandcolorhandler\installstyleandcolorhandler
+
+\permanent\protected\def\installdirectcommandhandler#1#2%
+ {\installdirectparameterhandler {#1}{#2}%
+ \installdirectsetuphandler {#1}{#2}%
+ \installdirectparametersethandler {#1}{#2}%
+ \installdirectstyleandcolorhandler{#1}{#2}}
+
+\permanent\protected\def\installsetuponlycommandhandler#1#2%
+ {\installdirectparameterhandler {#1}{#2}%
+ \installdirectsetuphandler {#1}{#2}%
+ \installdirectparametersethandler{#1}{#2}}
+
+% Experiment:
+
+% \installcorenamespace {one}
+% \installcorenamespace {two}
+%
+% \installcommandhandler \??one {one} \??one
+% \installcommandhandler \??two {two} \??two
+%
+% \defineone[test] \setupone[test][alpha=first]
+% \definetwo[test] \setuptwo[test][beta=second]
+%
+% \protect
+%
+% \def\currentone{test}
+% \def\currenttwo{test}
+%
+% \relateparameterhandlers {two} {test} {one} {test}
+%
+% yes:\oneparameter{alpha}\par
+% nop:\oneparameter{beta}\par
+% yes:\twoparameter{alpha}\par
+% yes:\twoparameter{beta}\par
+
+\permanent\protected\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance}
+ {\immutable\edefcsname\csname#1namespace\endcsname#2:\s!parent\endcsname{\csname#3namespace\endcsname#4}}
+
+\permanent\protected\def\relateparameterhandlersbyns#1#2#3#4% {from} {instance} {to} {instance}
+ {\edefcsname#1#2:\s!parent\endcsname{#3#4}}
+
+%D Here is another experiment:
+
+\protected\def\mult_interfaces_install_action_handler#1#2#3%
+ {\frozen\tolerant\protected\defcsname#1\endcsname[##1]##*[##2]%
+ {\begingroup
+ \ifarguments
+ \let#2\empty
+ \or
+ %\ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##1}=^^^^0003^^^^0003^^^^0004%
+ % \ifcondition\mult_aux_no_assignment_indeed##1\ignorearguments
+ % \edef#2{##1}%
+ % \else
+ % \let#2\empty
+ % #3[##1]%
+ % \fi
+ \ifhastok={##1}%
+ \let#2\empty
+ #3[##1]%
+ \else
+ \edef#2{##1}%
+ \fi
+ \or
+ \edef#2{##1}%
+ #3[##2]%
+ \fi
+ \directsetup{handler:action:#1}%
+ \endgroup}}
+
+\permanent\protected\def\installactionhandler#1%
+ {\mutable\letcsname current#1\endcsname\empty
+ \normalexpanded
+ {\mult_interfaces_install_action_handler
+ {#1}%
+ \expandafter\noexpand\csname current#1\endcsname
+ \expandafter\noexpand\csname setupcurrent#1\endcsname}}
+
+% First we had, in tune with the regular system variables:
+%
+% \starttyping
+% \protected\def\installnamespace#1{\setvalue{????#1}{@@@@#1}}
+% \stoptyping
+%
+% The following variant is nicer and in principle faster but that gets unnoticed
+% unless lots of expansion happens. Also, we can use long tags but the internal
+% expansion will be relatively small (and unlikely more than 4 characters). For
+% instance, \??xx used to expand to @@xx but now becomes for instance 123::. This
+% is one character more but in quite some cases we had : after such a tag in the
+% old situation. In the new situation we create more namespaces and don't need that
+% : any more, so we end up with on the average the same amount of tokens and
+% definitely less when we consider cases like \??xx:\c!align: which now is just
+% \??somealign and therefore has length 5 now (instead of 4+1+5+1=10).
+%
+% Eventualy we will have a verbose \blablanamespace and the difference between core
+% and regular can go ... after all, \xxxparameter can already clash between the two
+% prefix groups .. if users use this mechanism a lot they should use verbose names
+% anyway (the old two character names were mostly an optimization as they also
+% expanded to these characters).
+
+% todo: register namespaces at lua end for logging and reverse resolve
+% todo: move this to syst-ini so that we can use it real early
+
+\newcount\c_mult_interfaces_n_of_namespaces
+
+\def\v_interfaces_prefix_template
+ {\number\c_mult_interfaces_n_of_namespaces>}
+
+\permanent\protected\def\installnamespace#1% for modules and users
+ {\ifcsname ????#1\endcsname
+ \writestatus\m!system{duplicate user namespace '#1'}\wait
+ \else
+ \global\advance\c_mult_interfaces_n_of_namespaces\plusone
+ \immutable\edefcsname ????#1\endcsname{\v_interfaces_prefix_template}%
+ \fi}
+
+\permanent\protected\def\installcorenamespace#1%
+ {\ifcsname ??#1\endcsname
+ \writestatus\m!system{duplicate core namespace '#1'}\wait
+ \else
+ \global\advance\c_mult_interfaces_n_of_namespaces\plusone
+ \immutable\edefcsname ??#1\endcsname{\v_interfaces_prefix_template}%
+ \clf_registernamespace\c_mult_interfaces_n_of_namespaces{#1}%
+ \fi}
+
+\def\mult_interfaces_get_parameters_error_indeed#1#2%
+ {\clf_showassignerror{#1}{#2}\inputlineno}
+
+% We install two core namespaces here, as we want nice error messages. Maybe
+% we will reserve the first 9.
+
+\installcorenamespace{fontinstanceready}
+\installcorenamespace{fontinstancebasic}
+\installcorenamespace{fontinstanceclass}
+
+%D The next one is handy for local assignments.
+
+\installcorenamespace{dummy}
+
+\letvalue\??dummy\empty
+
+\permanent \def\dummyparameter #1{\begincsname\??dummy#1\endcsname}
+\permanent \def\directdummyparameter #1{\begincsname\??dummy#1\endcsname}
+\permanent\protected\def\setdummyparameter #1{\defcsname\??dummy#1\endcsname}
+\permanent\protected\def\setexpandeddummyparameter#1{\edefcsname\??dummy#1\endcsname}
+\permanent\protected\def\letdummyparameter #1{\letcsname\??dummy#1\endcsname}
+
+\edef\mult_interfaces_dummy{\??dummy} % nor immutable
+
+\permanent\protected\def\getdummyparameters[#1%
+ {\if\noexpand#1]%
+ \expandafter\gobbleoneargument
+ \else
+ \let\m_mult_interfaces_namespace\mult_interfaces_dummy
+ \expandafter\mult_interfaces_get_parameters_indeed
+ \fi#1}
+
+\mult_interfaces_install_style_and_color_handler
+ \directdummyparameter
+ \usedummystyleandcolor
+ \usedummystyleparameter
+ \usedummycolorparameter
+
+% Maybe a \definecorenamespace[name][directparameter,directsetup][parent] but we
+% don't gain much. Actually we might just inline all definitions.
+
+% \enabletrackers[interfaces.namespaces,context.flush]
+%
+% \definenamespace
+% [xy]
+% [type=module,
+% comment=test module,
+% version=1,
+% name=test,
+% style=yes,
+% command=yes,
+% setup=list,
+% set=yes,
+% parent=xy]
+%
+% \unprotect
+% \getparameters
+% [\????xy]
+% [text=]
+% \protect
+%
+% \definetest[one]
+%
+% \starttext
+%
+% “\testparameter{text}”
+%
+% \setuptest[text=foo]
+%
+% “\testparameter{text}”
+%
+% \setuptest[one][text=bar]
+%
+% “\testparameter{text}”
+%
+% \stoptext
+%
+% This is a user (module) command:
+
+\permanent\tolerant\protected\def\definenamespace[#1]#*[#2]% namespace settings
+ {\clf_definenamespace{#1}{#2}}
+
+\permanent\protected\def\listnamespaces
+ {\clf_listnamespaces}
+
+%D Helper:
+%D
+%D \starttyping
+%D \showparentchain{@@am}{left}
+%D \stoptyping
+
+\permanent\protected\def\showparentchain#1#2%
+ {\writestatus\m!system{chain: [ \mult_interfaces_show_parent_chain{#1#2}]}}
+
+\def\mult_interfaces_show_parent_chain#1%
+ {#1 => %
+ \ifcsname#1:\s!parent\endcsname
+ \expandafter\mult_interfaces_show_parent_chain\lastnamedcs
+ \fi}
+
+%D Another helper (needs to be applied):
+
+\permanent\protected\def\doifelsecommandhandler#1#2% namespace name
+ {\ifcsname#1#2:\s!parent\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\aliased\let\doifcommandhandlerelse\doifelsecommandhandler
+
+\permanent\protected\def\doifcommandhandler#1#2% namespace name
+ {\ifcsname#1#2:\s!parent\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\permanent\protected\def\doifnotcommandhandler#1#2% namespace name
+ {\ifcsname#1#2:\s!parent\endcsname
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+% another set of (fast) helpers (grep for usage):
+
+\permanent\def\expandnamespaceparameter#1#2#3% \??xx \getp \c!xx \v!yy
+ {\csname#1\ifcsname#1\expandafter\expandafter\expandafter\mult_aux_expand_namespace_parameter#2#3}
+
+\def\mult_aux_expand_namespace_parameter#1#2% \cs \v!yy
+ {#1\endcsname#1\else#2\fi\endcsname}
+
+\permanent\def\expandnamespacemacro#1#2#3% \??xx \some_edefed_cs \c!yy
+ {\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname}
+
+\permanent\def\expandnamespacevalue#1#2% \??xx {...} \c!yy == optimized \expandcheckedcsname
+ {\csname#1\ifcsname#1\normalexpanded{\noexpand\syst_helpers_expand_checked_value{#2}}}
+
+\def\syst_helpers_expand_checked_value#1#2%
+ {#1\endcsname#1\else#2\fi\endcsname}
+
+%D Conventions:
+%D
+%D \starttyping
+%D \newcount \c_class_whatever
+%D \newconditional \c_class_whatever
+%D \newconstant \c_class_whatever
+%D \newdimen \d_class_whatever
+%D \newskip \s_class_whatever
+%D \newmuskip \s_class_whatever
+%D \newbox \b_class_whatever
+%D \newtoks \t_class_whatever
+%D
+%D \edef\p_class_whatever{\classparameter\c!whatever}
+%D \edef\m_class_whatever{whatever}
+%D \stoptyping
+
+% experiment: in principle this is faster but not that noticeable as we don't do that
+% many assignments and mechanism that do are also slow; the advantage is mostly nicer
+% in tracing
+
+\mutable\let\c_mult_set\relax
+
+\protected\def\mult_interfaces_install_definition_set#1#2#3#4#5#6#7%
+ {\newcount#3%
+ \let#6\empty
+ \protected\def#2%
+ {\expandafter\let\expandafter\c_mult_set\csname #1_t_#6\endcsname
+ \ifrelax\c_mult_set
+ \expandafter\newtoks\c_mult_set
+ \letcsname#1_t_#6\endcsname\c_mult_set
+ \fi}
+ \frozen\protected\def#4##1%
+ {\pushmacro#6%
+ \advance#3\plusone
+ \edef#6{##1}%
+ \unprotect}%
+ \frozen\protected\def#5%
+ {\protect
+ \advance#3\minusone
+ \popmacro#6}%
+ \frozen\protected\def#7##1%
+ {\edef#6{##1}%
+ #2%
+ \the\c_mult_set\relax}}
+
+\permanent\protected\def\installdefinitionset#1#2%
+ {\normalexpanded
+ {\mult_interfaces_install_definition_set
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname set_#2_toks\endcsname
+ \expandafter\noexpand\csname #2_nesting_depth\endcsname
+ \expandafter\noexpand\csname push#2\endcsname
+ \expandafter\noexpand\csname pop#2\endcsname
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname use#2\endcsname}}
+
+\protected\def\mult_interfaces_install_definition_set_member#1#2#3#4#5#6#7#8#9% no everysetups etc
+ {\let#5#2%
+ \frozen\protected\def#2%
+ {\ifcase#4\relax\expandafter#5\else\expandafter#6\fi}%
+ \tolerant\protected\def#6[##1]##*[##2]%
+ {\ifarguments\or
+ #3\toksapp\c_mult_set{#7[##1]}%
+ \or
+ #3\toksapp\c_mult_set{#8[##1][##2]}%
+ \fi}}
+
+\permanent\protected\def\installdefinitionsetmember#1#2#3#4%
+ {\normalexpanded
+ {\mult_interfaces_install_definition_set_member
+ {\noexpand#3}% \??aa
+ \expandafter\noexpand\csname setup#4\endcsname
+ \expandafter\noexpand\csname set_#2_toks\endcsname
+ \expandafter\noexpand\csname #2_nesting_depth\endcsname
+ \expandafter\noexpand\csname normal_setup_#4\endcsname
+ \expandafter\noexpand\csname delayed_setup_#4\endcsname
+ \expandafter\noexpand\csname setup#4_\s!single\endcsname
+ \expandafter\noexpand\csname setup#4_\s!double\endcsname}}
+
+%D Another experiment:
+
+\protected\def\mult_interfaces_install_parent_injector#1#2#3#4%
+ {\frozen\protected\def#4##1%
+ {\ifempty#3%
+ \defcsname#1#2:\s!parent\endcsname{#1##1}%
+ \fi}}
+
+\permanent\protected\def\installparentinjector#1#2%
+ {\normalexpanded{\mult_interfaces_install_parent_injector
+ {\noexpand#1}%
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname current#2parent\endcsname
+ \expandafter\noexpand\csname inject#2parent\endcsname}}
+
+% The \LUA\ based variant is twice as fast as the above but as said, we don't use
+% this one that often. It's more about less tracing than speed here.
+
+\permanent\protected\def\installmacrostack#1%
+ {\ifdefined#1\else\mutable\let#1\empty\fi
+ \protected\gdefcsname push_macro_\csstring#1\endcsname{\localpushmacro#1}%
+ \protected\gdefcsname pop_macro_\csstring#1\endcsname{\localpopmacro #1}}
+
+\permanent\protected\def\installglobalmacrostack#1%
+ {\ifdefined#1\else\mutable\glet#1\empty\fi
+ \protected\gdefcsname push_macro_\csstring#1\endcsname{\globalpushmacro#1}%
+ \protected\gdefcsname pop_macro_\csstring#1\endcsname{\globalpopmacro #1}}
+
+% \showmacrostack can be used to see if there are different entries
+
+% \unprotect
+%
+% \installcorenamespace {test} \installcommandhandler \??test {test} \??test
+% \protected\def\TestMeA[#1]%
+% {\edef\currenttest{#1}
+% \edef\p_before{\testparameter\c!before}%
+% \ifempty\p_before \relax \else \relax \fi}
+% \protected\def\TestMeB[#1]%
+% {\edef\currenttest{#1}
+% \doifelsenothing{\testparameter\c!before}\relax\relax}
+% \protected\def\TestMeC[#1]%
+% {\edef\currenttest{#1}
+% \expandafter\expandafter\expandafter\ifempty\testparameter\c!before \relax \else \relax \fi}
+% \protected\def\TestMeD[#1]%
+% {\edef\currenttest{#1}
+% \doubleexpandafter\ifempty\testparameter\c!before \relax \else \relax \fi}
+%
+% \protect
+%
+% \starttext
+% \definetest[foo] \definetest[bar][foo] \setuptest[bar][before=indeed]
+% \testfeatureonce{100000}{\TestMeA[bar]} A:\elapsedtime \par % 0.502
+% \testfeatureonce{100000}{\TestMeB[bar]} B:\elapsedtime \par % 0.530
+% \testfeatureonce{100000}{\TestMeC[bar]} C:\elapsedtime \par % 0.487
+% \testfeatureonce{100000}{\TestMeD[bar]} D:\elapsedtime \par % 0.493
+% \stoptext
+
+% There is no real demand for this ... even if this is two to three times as fast we
+% only gain a few milliseconds:
+%
+% \starttyping
+% \protected\def\foo#1{[foo:#1]}
+%
+% \installcommalistprocessor {foo} \foo
+% \installcommalistprocessorcommand \processfoolist \foo
+%
+% \infofont
+%
+% \commalistprocessor{foo}[a,b,c,{x,y,z},d]\par
+% \processfoolist[a, b, c, {x,y,z}, d]\par
+% \processcommalist[{x,y,z}]\foo\blank
+%
+% \commalistprocessor{foo}[{x,y,z},a]\par
+% \commalistprocessor{foo}[{x,y,z}]\par
+% \processfoolist[{x,y,z},a]\par
+% \processfoolist[{x,y,z}]\par
+% \processcommalist[{x,y,z}]\foo\blank
+%
+% \protected\def\foo#1{}
+%
+% \testfeatureonce{400000}{\processfoolist [fixed,middle,bar]} \elapsedtime\quad
+%%\testfeatureonce{400000}{\commalistprocessor{foo}[fixed,middle,bar]} \elapsedtime\quad
+% \testfeatureonce{400000}{\processcommalist [fixed,middle,bar]\foo} \elapsedtime\quad
+% \stoptyping
+%
+% For instance the luatex manual only has some 3000 calls. But I keep this around as one
+% never knows when we might need it.
+
+\installcorenamespace{commalistprocessor}
+\installcorenamespace{commalistprocessorwrap}
+\installcorenamespace{commalistprocessorfirst}
+\installcorenamespace{commalistprocessornext}
+\installcorenamespace{commalistprocessoraction}
+
+\permanent\protected\def\installcommalistprocessor#1#2% 5 macro names overhead
+ {\protected\edefcsname\??commalistprocessor#1\endcsname[%
+ {\csname\??commalistprocessorwrap#1\endcsname\relax}% \relax preserves {}
+ \protected\edefcsname\??commalistprocessorwrap#1\endcsname##1]%
+ {\csname\??commalistprocessorfirst#1\endcsname##1,]}
+ \protected\edefcsname\??commalistprocessorfirst#1\endcsname\relax
+ {\csname\??commalistprocessornext#1\endcsname}%
+ \protected\edefcsname\??commalistprocessornext#1\endcsname
+ {\noexpand\futureexpandis]%
+ \noexpand\gobbleoneargument
+ \csname\??commalistprocessoraction#1\endcsname}
+ \protected\edefcsname\??commalistprocessoraction#1\endcsname##1,%
+ {\noexpand#2{##1}%
+ \csname\??commalistprocessornext#1\endcsname}}
+
+\permanent\protected\def\installcommalistprocessorcommand#1#2% \processor \action
+ {\edef\p_name{\csstring#2}%
+ \installcommalistprocessor\p_name{#2}%
+ \expandafter\let\expandafter#1\csname\??commalistprocessor\p_name\endcsname}
+
+\permanent\protected\def\commalistprocessor#1{\csname\??commalistprocessor#1\endcsname}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mult-def.mkxl b/Master/texmf-dist/tex/context/base/mkxl/mult-def.mkxl
new file mode 100644
index 00000000000..13e22dadebf
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mult-def.mkxl
@@ -0,0 +1,32 @@
+%D \module
+%D [ file=mult-def,
+%D version=2008.10.22,
+%D title=\CONTEXT\ Multilingual Macros,
+%D subtitle=Definitions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\installcorenamespace{multilingual}
+
+\immutable\setvalue{\??multilingual czech}{cs}
+\immutable\setvalue{\??multilingual german}{de}
+\immutable\setvalue{\??multilingual english}{en}
+\immutable\setvalue{\??multilingual french}{fr}
+\immutable\setvalue{\??multilingual italian}{it}
+\immutable\setvalue{\??multilingual dutch}{nl}
+\immutable\setvalue{\??multilingual persian}{pe}
+\immutable\setvalue{\??multilingual romanian}{ro}
+
+\permanent\def\userinterfacetag{\ifcsname\??multilingual\currentinterface\endcsname\lastnamedcs\else en\fi}
+\permanent\def\userresponsestag{\ifcsname\??multilingual\currentresponses\endcsname\lastnamedcs\else en\fi}
+
+\clf_setuserinterface{\userinterfacetag}{\userresponsestag}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mult-dim.mklx b/Master/texmf-dist/tex/context/base/mkxl/mult-dim.mklx
new file mode 100644
index 00000000000..0526b3775a1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mult-dim.mklx
@@ -0,0 +1,156 @@
+%D \module
+%D [ file=core-gen,
+%D version=1995.10.10,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=General,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Core Macros / General}
+
+% we could write a proper parser now in lua
+
+\unprotect
+
+%D \macros
+%D {assigndimension,assignalfadimension}
+%D
+%D The following commands are used to process keyword based dimension setters.
+%D
+%D \starttyping
+%D \assigndimension
+%D {|small|medium|big|-small|-medium|-big|none}
+%D {\dimension}
+%D {value small}
+%D {value medium}
+%D {value big}
+%D \stoptyping
+%D
+%D The given keyword determines the result.
+
+\installcorenamespace{dimensionnormal}
+
+\def\assign_dimension_direct#value#dimension#small#medium#big{#dimension=#value\relax}
+
+\immutable\setvalue{\??dimensionnormal \v!none }#value#dimension#small#medium#big{#dimension\zeropoint}
+\immutable\setvalue{\??dimensionnormal \empty }#value#dimension#small#medium#big{#dimension\zeropoint}
+\immutable\setvalue{\??dimensionnormal \v!small }#value#dimension#small#medium#big{#dimension=#small\relax}
+\immutable\setvalue{\??dimensionnormal \v!medium}#value#dimension#small#medium#big{#dimension=#medium\relax}
+\immutable\setvalue{\??dimensionnormal \v!big }#value#dimension#small#medium#big{#dimension=#big\relax}
+\immutable\setvalue{\??dimensionnormal-\v!small }#value#dimension#small#medium#big{#dimension=-#small\relax}
+\immutable\setvalue{\??dimensionnormal-\v!medium}#value#dimension#small#medium#big{#dimension=-#medium\relax}
+\immutable\setvalue{\??dimensionnormal-\v!big }#value#dimension#small#medium#big{#dimension=-#big\relax}
+\immutable\letvalue{\??dimensionnormal\s!unknown}\assign_dimension_direct
+
+\permanent\protected\def\assigndimension#value%
+ {\ifcsname\??dimensionnormal#value\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\assign_dimension_direct
+ \fi{#value}}
+
+%D The next variant assigns to a macro instead of a dimension.
+%D
+%D \starttyping
+%D \assignalfadimension
+%D {|small|medium|big|none}
+%D {\macro}
+%D {value small}
+%D {value medium}
+%D {value big}
+%D \stoptyping
+%D
+%D This one is used for factors.
+
+\installcorenamespace{dimensionalfa}
+
+\def\assign_alpha_dimension_direct#value#macro#small#medium#big{\edef#macro{#value}}
+
+\immutable\setvalue{\??dimensionalfa\v!none }#value#macro#small#medium#big{\let #macro\!!zerocount}
+\immutable\setvalue{\??dimensionalfa\v!small }#value#macro#small#medium#big{\edef#macro{#small}}
+\immutable\setvalue{\??dimensionalfa\v!medium }#value#macro#small#medium#big{\edef#macro{#medium}}
+\immutable\setvalue{\??dimensionalfa\v!big }#value#macro#small#medium#big{\edef#macro{#big}}
+\immutable\letvalue{\??dimensionalfa\s!unknown}\assign_alpha_dimension_direct
+
+\permanent\protected\def\assignalfadimension#value%
+ {\ifcsname\??dimensionalfa#value\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\assign_alpha_dimension_direct
+ \fi
+ {#value}}
+
+%D \macros
+%D {assignvalue}
+%D
+%D A variant that does not assume dimenions ios the following:
+%D
+%D \starttyping
+%D \assignvalue
+%D {|small|medium|big}
+%D {\macro}
+%D {value small}
+%D {value medium}
+%D {value big}
+%D \stoptyping
+
+\installcorenamespace{dimensionvalue}
+
+\def\assign_value_direct#value#macro#small#medium#big{\edef#macro{#value}}
+
+\immutable\setvalue{\??dimensionvalue\v!small }#value#macro#small#medium#big{\edef#macro{#small}}
+\immutable\setvalue{\??dimensionvalue\v!medium }#value#macro#small#medium#big{\edef#macro{#medium}}
+\immutable\setvalue{\??dimensionvalue\v!big }#value#macro#small#medium#big{\edef#macro{#big}}
+\immutable\letvalue{\??dimensionvalue\s!unknown}\assign_value_direct
+
+\permanent\protected\def\assignvalue#value%
+ {\ifcsname\??dimensionvalue#value\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\assign_value_direct
+ \fi{#value}}
+
+%D \macros
+%D {assignwidth}
+%D
+%D This one is used a few times.
+%D
+%D \starttyping
+%D \assignwidth
+%D {|fit|broad}
+%D {\dimension}
+%D {text}
+%D {extra}
+%D \stoptyping
+
+\installcorenamespace{dimensionwidth}
+
+\newbox\b_assign_width
+
+\def\assign_width_direct#value#dimension#content#extra{#dimension=#value\relax}
+
+% line is like fit but can be used later as signal for ...
+
+\immutable\setvalue{\??dimensionwidth }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\wd\b_assign_width
+ \setbox\b_assign_width\emptybox}
+\immutable\setvalue{\??dimensionwidth\v!fit }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\wd\b_assign_width
+ \setbox\b_assign_width\emptybox}
+\immutable\setvalue{\??dimensionwidth\v!broad }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\dimexpr\wd\b_assign_width+#extra\relax
+ \setbox\b_assign_width\emptybox}
+\immutable\setvalue{\??dimensionwidth\v!line }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\wd\b_assign_width
+ \setbox\b_assign_width\emptybox}
+\immutable\letvalue{\??dimensionwidth\s!unknown}\assign_width_direct
+
+\permanent\protected\def\assignwidth#value%
+ {\ifcsname\??dimensionwidth#value\endcsname
+ \expandafter\lastnamedcs
+ \else
+ \expandafter\assign_width_direct
+ \fi{#value}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mult-ini.lmt b/Master/texmf-dist/tex/context/base/mkxl/mult-ini.lmt
new file mode 100644
index 00000000000..7c60d5b33af
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mult-ini.lmt
@@ -0,0 +1,389 @@
+if not modules then modules = { } end modules ['mult-ini'] = {
+ version = 1.001,
+ comment = "companion to mult-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format, gmatch, match, find, sub = string.format, string.gmatch, string.match, string.find, string.sub
+local lpegmatch = lpeg.match
+local serialize, concat = table.serialize, table.concat
+local rawget, type, tonumber, next = rawget, type, tonumber, next
+
+local context = context
+local commands = commands
+local implement = interfaces.implement
+
+local allocate = utilities.storage.allocate
+local mark = utilities.storage.mark
+local prtcatcodes = catcodes.numbers.prtcatcodes
+local vrbcatcodes = catcodes.numbers.vrbcatcodes
+local contextsprint = context.sprint
+local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
+
+local report_interface = logs.reporter("interface","initialization")
+
+interfaces = interfaces or { }
+interfaces.constants = mark(interfaces.constants or { })
+interfaces.variables = mark(interfaces.variables or { })
+interfaces.elements = mark(interfaces.elements or { })
+interfaces.formats = mark(interfaces.formats or { })
+interfaces.translations = mark(interfaces.translations or { })
+interfaces.setupstrings = mark(interfaces.setupstrings or { })
+interfaces.corenamespaces = mark(interfaces.corenamespaces or { })
+interfaces.usednamespaces = mark(interfaces.usednamespaces or { })
+
+local registerstorage = storage.register
+local sharedstorage = storage.shared
+
+local constants = interfaces.constants
+local variables = interfaces.variables
+local elements = interfaces.elements
+local formats = interfaces.formats
+local translations = interfaces.translations
+local setupstrings = interfaces.setupstrings
+local corenamespaces = interfaces.corenamespaces
+local usednamespaces = interfaces.usednamespaces
+local reporters = { } -- just an optimization
+
+local setmacro = tokens.setters.macro
+
+registerstorage("interfaces/constants", constants, "interfaces.constants")
+registerstorage("interfaces/variables", variables, "interfaces.variables")
+registerstorage("interfaces/elements", elements, "interfaces.elements")
+registerstorage("interfaces/formats", formats, "interfaces.formats")
+registerstorage("interfaces/translations", translations, "interfaces.translations")
+registerstorage("interfaces/setupstrings", setupstrings, "interfaces.setupstrings")
+registerstorage("interfaces/corenamespaces", corenamespaces, "interfaces.corenamespaces")
+registerstorage("interfaces/usednamespaces", usednamespaces, "interfaces.usednamespaces")
+
+interfaces.interfaces = {
+ "cs", "de", "en", "fr", "it", "nl", "ro", "pe",
+}
+
+sharedstorage.currentinterface = sharedstorage.currentinterface or "en"
+sharedstorage.currentresponse = sharedstorage.currentresponse or "en"
+
+local currentinterface = sharedstorage.currentinterface
+local currentresponse = sharedstorage.currentresponse
+
+interfaces.currentinterface = currentinterface
+interfaces.currentresponse = currentresponse
+
+local complete = allocate()
+interfaces.complete = complete
+
+local function resolve(t,k) -- one access needed to get loaded (not stored!)
+ report_interface("loading interface definitions from 'mult-def.lua'")
+ complete = dofile(resolvers.findfile("mult-def.lua"))
+ report_interface("loading interface messages from 'mult-mes.lua'")
+ complete.messages = dofile(resolvers.findfile("mult-mes.lua"))
+ interfaces.complete = complete
+ return rawget(complete,k)
+end
+
+setmetatableindex(complete, resolve)
+
+local function valueiskey(t,k) -- will be helper
+ t[k] = k
+ return k
+end
+
+setmetatableindex(variables, valueiskey)
+setmetatableindex(constants, valueiskey)
+setmetatableindex(elements, valueiskey)
+setmetatableindex(formats, valueiskey)
+setmetatableindex(translations, valueiskey)
+setmetatableindex(setupstrings, valueiskey)
+
+function interfaces.registernamespace(n,namespace)
+ corenamespaces[n] = namespace
+ usednamespaces[namespace] = n
+end
+
+function interfaces.getnamespace(n)
+ return usednamespaces[n] .. ">"
+end
+
+if documentdata then
+
+ local prefix, getmacro
+
+ function documentdata.variable(name)
+ if not prefix then
+ prefix = usednamespaces.variables .. ">document:"
+ end
+ if not getmacro then
+ getmacro = tokens.getters.macro
+ end
+ return getmacro(prefix..name)
+ end
+
+end
+
+local function resolve(t,k)
+ local v = logs.reporter(k)
+ t[k] = v
+ return v
+end
+
+setmetatableindex(reporters,resolve)
+
+for category, _ in next, translations do
+ -- We pre-create reporters for already defined messages
+ -- because otherwise listing is incomplete and we want
+ -- to use that for checking so delaying makes not much
+ -- sense there.
+ local r = reporters[category]
+end
+
+-- adding messages
+
+local function add(target,tag,values)
+ local t = target[tag]
+ if not f then
+ target[tag] = values
+ else
+ for k, v in next, values do
+ if f[k] then
+ -- error
+ else
+ f[k] = v
+ end
+ end
+ end
+end
+
+function interfaces.settranslation(tag,values)
+ add(translations,tag,values)
+end
+
+function interfaces.setformat(tag,values)
+ add(formats,tag,values)
+end
+
+local function getsetupstring(tag)
+ return setupstrings[tag] or tag
+end
+
+interfaces.getsetupstring = getsetupstring
+
+-- the old method:
+
+local replacer = lpeg.replacer { { "--", "%%a" } }
+
+local function fulltag(category,tag)
+ return formatters["%s:%s"](category,lpegmatch(replacer,tag))
+end
+
+function interfaces.setmessages(category,str)
+ for tag, message in gmatch(str,"(%S+) *: *(.-) *[\n\r]") do
+ if tag == "title" then
+ translations[tag] = translations[tag] or tag
+ else
+ formats[fulltag(category,tag)] = lpegmatch(replacer,message)
+ end
+ end
+end
+
+function interfaces.setmessage(category,tag,message)
+ formats[fulltag(category,tag)] = lpegmatch(replacer,message)
+end
+
+function interfaces.getmessage(category,tag,default)
+ return formats[fulltag(category,tag)] or default or "unknown message"
+end
+
+function interfaces.doifelsemessage(category,tag)
+ return rawget(formats,fulltag(category,tag))
+end
+
+local splitter = lpeg.splitat(",")
+
+function interfaces.showmessage(category,tag,arguments)
+ local r = reporters[category]
+ local f = formats[fulltag(category,tag)]
+ local t = type(arguments)
+ if t == "string" and #arguments > 0 then
+ r(f,lpegmatch(splitter,arguments))
+ elseif t == "table" then
+ r(f,unpack(arguments))
+ elseif arguments then
+ r(f,arguments)
+ else
+ r(f)
+ end
+end
+
+-- till here
+
+function interfaces.setvariable(variable,given)
+ variables[given] = variable
+end
+
+function interfaces.setconstant(constant,given)
+ constants[given] = constant
+end
+
+function interfaces.setelement(element,given)
+ elements[given] = element
+end
+
+-- the real thing:
+
+logs.setmessenger(context.verbatim.ctxreport)
+
+interfaces.cachedsetups = interfaces.cachedsetups or { }
+interfaces.hashedsetups = interfaces.hashedsetups or { }
+
+local cachedsetups = interfaces.cachedsetups
+local hashedsetups = interfaces.hashedsetups
+
+storage.register("interfaces/cachedsetups", cachedsetups, "interfaces.cachedsetups")
+storage.register("interfaces/hashedsetups", hashedsetups, "interfaces.hashedsetups")
+
+function interfaces.cachesetup(t)
+ local hash = serialize(t)
+ local done = hashedsetups[hash]
+ if done then
+ return cachedsetups[done]
+ else
+ done = #cachedsetups + 1
+ cachedsetups[done] = t
+ hashedsetups[hash] = done
+ return t
+ end
+end
+
+function interfaces.interfacedcommand(name)
+ local command = complete.commands[name]
+ return command and command[currentinterface] or name
+end
+
+-- interface
+
+function interfaces.writestatus(category,message)
+ reporters[category](message) -- could also be a setmetatablecall
+end
+
+function interfaces.message(str)
+ texio.write(str) -- overloaded
+end
+
+implement { name = "registernamespace", actions = interfaces.registernamespace, arguments = { "integer", "string" } }
+implement { name = "setinterfaceconstant", actions = interfaces.setconstant, arguments = "2 strings" }
+implement { name = "setinterfacevariable", actions = interfaces.setvariable, arguments = "2 strings" }
+implement { name = "setinterfaceelement", actions = interfaces.setelement, arguments = "2 strings" }
+implement { name = "setinterfacemessage", actions = interfaces.setmessage, arguments = "3 strings" }
+implement { name = "setinterfacemessages", actions = interfaces.setmessages, arguments = "2 strings" }
+
+implement {
+ name = "showmessage",
+ public = true,
+ protected = true,
+ arguments = "3 arguments" ,
+ actions = interfaces.showmessage,
+}
+
+implement {
+ name = "doifelsemessage",
+ public = true,
+ protected = true,
+ arguments = "2 arguments",
+ actions = { interfaces.doifelsemessage, commands.doifelse },
+}
+
+implement {
+ name = "getmessage",
+ public = true,
+ protected = true,
+ arguments = "3 arguments",
+ actions = function(...)
+ setmacro("currentmessagetext", interfaces.getmessage(...))
+ end,
+}
+
+implement {
+ name = "writestatus",
+ overload = true,
+ public = true,
+ protected = true,
+ arguments = "2 arguments",
+ actions = interfaces.writestatus,
+}
+
+implement {
+ name = "message",
+ overload = true,
+ public = true,
+ protected = true,
+ arguments = "string",
+ actions = interfaces.message,
+}
+
+local function gss(s)
+ contextsprint(vrbcatcodes,getsetupstring(s))
+end
+
+implement { -- will be overloaded
+ name = "getsetupstring",
+ public = true,
+ -- protected = true,
+ arguments = "string",
+ actions = gss,
+}
+
+implement {
+ name = "rawsetupstring",
+ public = true,
+ arguments = "string",
+ actions = gss,
+}
+
+
+local function showassignerror(namespace,key,line)
+ -- if key and key ~= "" and key ~= "," then
+ local ns, instance = match(namespace,"^(%d+)[^%a]+(%a*)")
+ if ns then
+ namespace = corenamespaces[tonumber(ns)] or ns
+ end
+ -- injected in the stream for timing:
+ if instance and instance ~= "" then
+ context.writestatus("setup",formatters["error in line %a, namespace %a, instance %a, key %a"](line,namespace,instance,key))
+ else
+ context.writestatus("setup",formatters["error in line %a, namespace %a, key %a"](line,namespace,key))
+ end
+ -- end
+end
+
+implement {
+ name = "showassignerror",
+ actions = showassignerror,
+ arguments = { "string", "string", "integer" },
+}
+
+-- a simple helper
+
+local settings_to_hash = utilities.parsers.settings_to_hash
+
+local makesparse = function(t)
+ for k, v in next, t do
+ if not v or v == "" then
+ t[k] = nil
+ end
+ end
+ return t
+end
+
+function interfaces.checkedspecification(specification)
+ local kind = type(specification)
+ if kind == "table" then
+ return makesparse(specification)
+ elseif kind == "string" and specification ~= "" then
+ return makesparse(settings_to_hash(specification))
+ else
+ return { }
+ end
+end
diff --git a/Master/texmf-dist/tex/context/base/mkxl/mult-ini.mkxl b/Master/texmf-dist/tex/context/base/mkxl/mult-ini.mkxl
new file mode 100644
index 00000000000..17f63ef93b9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/mult-ini.mkxl
@@ -0,0 +1,804 @@
+%D \module
+%D [ file=mult-ini,
+%D version=2008.10.22, % 1996.06.01,
+%D title=\CONTEXT\ Multilingual Macros,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module is a stripped down version of \type {mult-ini.tex}, which we keep
+%D around as \type {mult-kep.tex} for sentimental reasons. There you will find some
+%D more historic information.
+
+\writestatus{loading}{ConTeXt Multilingual Macros / Initialization}
+
+\unprotect
+
+\registerctxluafile{mult-ini}{autosuffix}
+\registerctxluafile{mult-fmt}{initexonly}
+
+%D \macros
+%D [constanten,variabelen,commands]
+%D {v!,c!,k!,s!,e!,m!,l!,r!,f!,p!,x!,y!}
+%D
+%D In the system modules we introduced some prefixed constants, variables (both
+%D macros) and registers. Apart from a tremendous saving in terms of memory and a
+%D gain in speed we use from now on prefixes when possible for just another reason:
+%D consistency and multi||linguality. Systematically using prefixed macros enables
+%D us to implement a multi||lingual user interface. Redefining these next set of
+%D prefixes therefore can have desastrous results.
+%D
+%D \startlinecorrection
+%D \starttable[|c|c|c|]
+%D \HL
+%D \NC \bf prefix \NC \bf meaning \NC \bf application \NC\SR
+%D \HL
+%D \NC \type{\c!prefix!} \NC c! \NC constant (direct) \NC\FR
+%D \NC \type{\k!prefix!} \NC k! \NC constant (indirect) \NC\FR
+%D \NC \type{\e!prefix!} \NC e! \NC element \NC\MR
+%D \NC \type{\f!prefix!} \NC f! \NC file \NC\MR
+%D \NC \type{\m!prefix!} \NC m! \NC age \NC\MR
+%D \NC \type{\s!prefix!} \NC s! \NC system \NC\MR
+%D \NC \type{\v!prefix!} \NC v! \NC variable \NC\MR
+%D \HL
+%D \stoptable
+%D \stoplinecorrection
+%D
+%D In the single||lingual version we used \type {!}, \type {!!}, \type {!!!} and
+%D \type {!!!!}. In the meantime some of these are obsolete (we had some 12
+%D originally).
+
+\immutable\def\c!prefix!{c!}
+\immutable\def\k!prefix!{k!}
+\immutable\def\e!prefix!{e!}
+\immutable\def\f!prefix!{f!} % for the moment we keep this one
+\immutable\def\m!prefix!{m!}
+\immutable\def\s!prefix!{s!}
+\immutable\def\v!prefix!{v!}
+\immutable\def\t!prefix!{t!}
+
+%D \macros
+%D [constants,variables,commands]
+%D {@@,??}
+%D
+%D Variables generated by the system can be recognized on their prefix \type {@@}.
+%D They are composed of a command (class) specific tag, which can be recognized on
+%D \type {??}, and a system constant, which has the prefix \type {c!}. We'll se some
+%D more of this.
+
+\immutable\def\??prefix {??}
+\immutable\def\@@prefix {@@}
+
+%D Just to be complete we repeat some of the already defined system constants here.
+%D Maybe their prefix \type {\s!} now falls into place.
+
+\def\s!next {next} \def\s!default {default}
+\def\s!dummy {dummy} \def\s!unknown {unknown}
+
+\def\s!do {do} \def\s!dodo {dodo}
+
+\def\s!complex {complex} \def\s!start {start}
+\def\s!simple {simple} \def\s!stop {stop}
+
+\def\s!true {true}
+\def\s!false {false}
+
+%D The word \type {height} takes 6~token memory cells. The control sequence \type
+%D {\height} on the other hand uses only one. Knowing this, we can improve the
+%D performance of \TEX, both is terms of speed and memory usage, by using control
+%D sequences instead of the words written in full.
+%D
+%D Where in the \ASCII\ file the second lines takes nine extra characters, \TEX\
+%D saves us 13~tokens.
+%D
+%D \starttyping
+%D \hrule width 10pt height 2pt depth 1pt
+%D \hrule \s!width 10pt \s!height 2pt \s!depth 1pt
+%D \stoptyping
+%D
+%D One condition is that we have defined \type {\s!height}, \type {\s!width} and
+%D \type {\s!depth} as respectively \type {height}, \type {width} and \type {depth}.
+%D Using this scheme therefore only makes sense when a token sequence is used more
+%D than once. Savings like this should of course be implemented in english, just
+%D because \TEX\ is english.
+
+\def\s!width {width}
+\def\s!height {height}
+\def\s!depth {depth}
+\def\s!spread {spread}
+\def\s!plus {plus}
+\def\s!minus {minus}
+\def\s!to {to}
+
+\def\s!fil {fil}
+\def\s!fill {fill}
+\def\s!filll {filll}
+
+\def\s!attr {attr}
+\def\s!axis {axis}
+\def\s!both {both}
+\def\s!bottom {bottom}
+\def\s!left {left}
+\def\s!options {options}
+\def\s!orientation{orientation}
+\def\s!reverse {reverse}
+\def\s!right {right}
+\def\s!top {top}
+\def\s!xmove {xmove}
+\def\s!xoffset {xoffset}
+\def\s!ymove {ymove}
+\def\s!yoffset {yoffset}
+
+%D \macros
+
+%D {defineinterfaceconstant,
+%D defineinterfacevariable,
+%D defineinterfaceelement,
+%D definesystemvariable,
+%D definesystemconstant,
+%D definemessageconstant,
+%D definefileconstant}
+%D
+%D The first part of this module is dedicated to dealing with multi||lingual
+%D constants and variables. When \CONTEXT\ grew bigger and bigger in terms of bytes
+%D and used string space, we switched to predefined constants. At the cost of more
+%D hash table entries, the macros not only becase more compact, they became much
+%D faster too. Maybe an even bigger advantage was that mispelling could no longer
+%D lead to problems. Even a multi||lingual interface became possible.
+%D
+%D Constants |<|we'll introduce the concept of variables later on|>| are preceded by
+%D a type specific prefix, followed by a \type {!}. To force consistency, we provide
+%D a few commands for defining such constants.
+%D
+%D \starttyping
+%D \defineinterfaceconstant {name} {meaning}
+%D \defineinterfacevariable {name} {meaning}
+%D \defineinterfaceelement {name} {meaning}
+%D \stoptyping
+%D
+%D Which is the same as:
+%D
+%D \starttyping
+%D \def\c!name{meaning}
+%D \def\v!name{meaning}
+%D \def\e!name{meaning}
+%D \stoptyping
+
+%permanent\protected\def\defineinterfaceconstant#1#2{\immutable\defcsname\c!prefix!#1\endcsname{#2}}
+\permanent\protected\def\defineinterfacevariable#1#2{\immutable\defcsname\v!prefix!#1\endcsname{#2}}
+\permanent\protected\def\defineinterfaceelement #1#2{\immutable\defcsname\e!prefix!#1\endcsname{#2}}
+
+%D Next come some interface independant constants:
+%D
+%D \starttyping
+%D \definefileconstant {name} {meaning}
+%D \stoptyping
+
+\permanent\protected\def\definefileconstant#1#2{\immutable\defcsname\f!prefix!#1\endcsname{#2}}
+
+%D And finaly we have the one argument, space saving constants
+%D
+%D \starttyping
+%D \definesystemconstant {name}
+%D \definemessageconstant {name}
+%D \stoptyping
+
+\permanent\protected\def\definesystemconstant #1{\immutable\defcsname\s!prefix!#1\endcsname{#1}}
+\permanent\protected\def\definemessageconstant#1{\immutable\defcsname\m!prefix!#1\endcsname{#1}}
+
+%D For now here:
+
+\permanent\protected\def\definetagconstant #1{\immutable\defcsname\t!prefix!#1\endcsname{#1}}
+\permanent\protected\def\aliastagconstant #1#2{\aliased \letcsname\t!prefix!#1\expandafter\endcsname\csname\t!prefix!#2\endcsname}
+
+%D In a parameter driven system, some parameters are shared by more system
+%D components. In \CONTEXT\ we can distinguish parameters by a unique prefix. Such a
+%D prefix is defined with:
+%D
+%D \starttyping
+%D \definesystemvariable {name}
+%D \stoptyping
+
+\permanent\protected\def\definesystemvariable#1{\immutable\edefcsname\??prefix#1\endcsname{\@@prefix#1}}
+
+\definesystemvariable{ms}
+
+%D \macros
+%D {selectinterface,
+%D defaultinterface, currentinterface, currentresponses}
+%D
+%D With \type {\selectinterface} we specify the language we are going to use. The
+%D system asks for the language wanted, and defaults to \type {\currentinterface}
+%D when we just give \type {enter}. By default the message system uses the current
+%D interface language, but \type {\currentresponses} can specify another language
+%D too.
+%D
+%D Because we want to generate formats directly too, we do not ask for interface
+%D specifications when these are already defined (like in cont-nl.tex and alike).
+
+\ifdefined\defaultinterface
+
+ \permanent\protected\def\selectinterface
+ {\writestatus{interface}{defining \currentinterface\space interface}%
+ %writeline
+ \writestatus{interface}{using \currentresponses\space messages}%
+ %\writeline
+ \enforced\permanent\let\selectinterface\relax}
+
+\else
+
+ \immutable\def\defaultinterface{english}
+
+ \permanent\overloaded\protected\def\selectinterface
+ {\enforced\permanent\protected\def\selectinterface##1##2%
+ {\bgroup
+ \endlinechar\minusone
+ \global\read16 to ##1
+ \egroup
+ \doifnothing\currentinterface{\let##1=##2}%
+ \doifundefined{\s!prefix!##1}{\let##1=##2}}%
+ \selectinterface\currentinterface\defaultinterface
+ \writestatus{interface}{defining \currentinterface\space interface}%
+ %\writeline
+ \selectinterface\currentresponses\currentinterface
+ \writestatus{interface}{using \currentresponses\space messages}%
+ %\writeline
+ \enforced\permanent\let\selectinterface\relax}
+
+\fi
+
+\ifdefined\currentinterface \else \aliased\let\currentinterface\defaultinterface \fi
+\ifdefined\currentresponses \else \aliased\let\currentresponses\defaultinterface \fi
+
+%D \macros
+%D {startinterface}
+%D
+%D Sometimes we want to define things only for specific interface languages. This
+%D can be done by means of the selector:
+%D
+%D \starttyping
+%D \startinterface language
+%D
+%D language specific definitions & commands
+%D
+%D \stopinterface
+%D \stoptyping
+
+\permanent\protected\def\startinterface #1
+ {\doifnot{#1}{all}{\doifnotinset\currentinterface{#1}{\gobbleuntil\stopinterface}}}
+
+\aliased\let\stopinterface\relax
+
+%D \macros
+%D {startmessages,
+%D getmessage,
+%D showmessage,
+%D makemessage}
+%D
+%D A package as large as \CONTEXT\ can hardly function without a decent message
+%D mechanism. Due to its multi||lingual interface, the message subsystem has to be
+%D multi||lingual too. A major drawback of this feature is that we have to code
+%D messages. As a result, the source becomes less self documented. On the other
+%D hand, consistency will improve.
+%D
+%D Because the overhead in terms of entries in the (already exhausted) hash table
+%D has to be minimal, messages are packed in libraries. We can extract a message
+%D from such a library in three ways:
+%D
+%D \starttyping
+%D \getmessage {library} {tag}
+%D \showmessage {library} {tag} {data}
+%D \makemessage {library} {tag} {data}
+%D \stoptyping
+%D
+%D The first command gets the message \type {tag} from the \type {library}
+%D specified. The other commands take an extra argument: a list of items to be
+%D inserted in the message text. While \type {\showmessage} shows the message at the
+%D terminal, the other commands generate the message as text. Before we explain the
+%D \type {data} argument, we give an example of a library.
+%D
+%D \starttyping
+%D \startmessages english library: alfa
+%D title: something
+%D 1: first message
+%D 2: second (--) message --
+%D \stopmessages
+%D \stoptyping
+%D
+%D The first message is a simple one and can be shown with:
+%D
+%D \starttyping
+%D \showmessage {alfa} {1} {}
+%D \stoptyping
+%D
+%D The second message on the other hand needs some extra data:
+%D
+%D \starttyping
+%D \showmessage {alfa} {2} {and last,to you}
+%D \stoptyping
+%D
+%D This message is shown as:
+%D
+%D \starttyping
+%D something : second (and last) message to you
+%D \stoptyping
+%D
+%D As we can see, the title entry is shown with the message. The data fields are
+%D comma separated and are specified in the message text by \type {--}.
+%D
+%D It is not required to define all messages in a library at once. We can add
+%D messages to a library in the following way:
+%D
+%D \starttyping
+%D \startmessages english library: alfa
+%D 10: tenth message
+%D \stopmessages
+%D \stoptyping
+%D
+%D Because such definitions can take place in different modules, the system gives a
+%D warning when a tag occurs more than once. The first occurrence takes preference
+%D over later ones, so we had better use a save offset, as shown in the example. As
+%D we can see, the title field is specified only the first time!
+%D
+%D Because we want to check for duplicate tags, the macros are a bit more
+%D complicated than neccessary. The \NEWLINE\ token is used as message separator.
+%D
+%D For internal purposes one can use \type {\setmessagetext}, which puts the message
+%D text asked for in \type {\currentmessagetext}.
+%D
+%D These will become obsolete:
+
+\permanent\protected\def\startmessages #1 library: #2 %
+ {\begingroup
+ \ifcsname\m!prefix!#2\endcsname\else\immutable\setgvalue{\m!prefix!#2}{#2}\fi
+ \catcode\endoflineasciicode\othercatcode
+ \doifelseinset{#1}{\currentresponses,all}\mult_messages_start_yes\mult_messages_start_nop{#2}}
+
+\def\mult_messages_start_yes#1#2\stopmessages
+ {\clf_setinterfacemessages{#1}{#2}%
+ \endgroup}
+
+\def\mult_messages_start_nop#1#2\stopmessages
+ {\endgroup}
+
+\aliased\let\stopmessages\relax
+
+\mutable\let\currentmessagetext\empty
+
+\permanent\protected\def\setinterfacemessage#1#2#3%
+ {\ifcsname\m!prefix!#1\endcsname\else\immutable\gdefcsname\m!prefix!#1\endcsname{#1}\fi
+ \clf_setinterfacemessage{#1}{#2}{#3}}
+
+% \getmessage % {tag} {index} -> \currentmessagetext
+% \doifelsemessage % {tag} {index}
+% \showmessage % {tag} {index} {detail}
+% \writestatus % {tag} {string}
+% \message % {string}
+
+\aliased\let\doifmessageelse\doifelsemessage
+
+\permanent\protected\def\inlinemessage #1{\dontleavehmode{\tttf#1}}
+\permanent\protected\def\displaymessage#1{\blank\inlinemessage{#1}\blank}
+
+% \getsetupstring % {tag} defined at the lua end
+% \rawsetupstring % {tag} defined at the lua end
+
+%D For old times sake:
+
+\aliased\let\showwarning\showmessage
+
+%D \macros
+%D {dosetvalue,dosetevalue,dosetgvalue,dosetxvalue,docopyvalue,doresetvalue} % dogetvalue
+%D
+%D We already defined these auxiliary macros in the system modules. Starting with
+%D this module however, we have to take multi||linguality a bit more serious.
+%D
+%D In due time, when we exclusively use the parameter handler code, we can drop the
+%D backmapping (\type{\c!k...}) and make \type {\c!c...} similar to \type {\v!...}.
+%D In that case we can simply the following setters.
+
+\pushoverloadmode
+
+\permanent\protected\def\doletvalue #1#2{\letcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\permanent\protected\def\dosetvalue #1#2{\defcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\permanent\protected\def\dosetevalue #1#2{\edefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\permanent\protected\def\dosetgvalue #1#2{\gdefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\permanent\protected\def\dosetxvalue #1#2{\xdefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname}
+\permanent\protected\def\doresetvalue #1#2{\letcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
+\permanent\protected\def\doignorevalue#1#2#3{\letcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty}
+
+\permanent\protected\def\docopyvalue#1#2#3%
+ {\ifcsname\k!prefix!#3\endcsname
+ \defcsname#1\csname\k!prefix!#3\endcsname\expandafter\endcsname\expandafter
+ {\csname#2\csname\k!prefix!#3\endcsname\endcsname}%
+ \else
+ \defcsname#1#3\expandafter\endcsname\expandafter
+ {\csname#2#3\endcsname}%
+ \fi}
+
+\startinterface english
+
+ \permanent\protected\def\doletvalue #1#2{\letcsname #1#2\endcsname}
+ \permanent\protected\def\dosetvalue #1#2{\defcsname #1#2\endcsname}
+ \permanent\protected\def\dosetevalue #1#2{\edefcsname#1#2\endcsname}
+ \permanent\protected\def\dosetgvalue #1#2{\gdefcsname#1#2\endcsname}
+ \permanent\protected\def\dosetxvalue #1#2{\xdefcsname#1#2\endcsname}
+ \permanent\protected\def\doresetvalue #1#2{\letcsname #1#2\endcsname\empty}
+ \permanent\protected\def\doignorevalue#1#2#3{\letcsname #1#2\endcsname\empty}
+
+ \permanent\protected\def\docopyvalue#1#2#3%
+ {\defcsname#1#3\expandafter\endcsname\expandafter
+ {\csname#2#3\endcsname}}
+
+\stopinterface
+
+\popoverloadmode
+
+%D We can now redefine some messages that will be introduced in the multi||lingual
+%D system module.
+
+\permanent\protected\def\showassignerror #1#2{\showmessage\m!check1{#1,#2}}
+\permanent\protected\def\showargumenterror#1#2{\showmessage\m!check2{#1,#2}}
+\permanent\protected\def\showdefinederror #1#2{\showmessage\m!check3{#1,#2}}
+
+%D \CONTEXT\ is a parameter driven package. This means that users instruct the
+%D system by means of variables, values and keywords. These instructions take the
+%D form:
+%D
+%D \starttyping
+%D \setupsomething[some variable=some value, another one=a keyword]
+%D \stoptyping
+%D
+%D or by keyword only:
+%D
+%D \starttyping
+%D \dosomething[this way,that way,no way]
+%D \stoptyping
+%D
+%D Because the same variables can occur in more than one setup command, we have to
+%D be able to distinguish them. This is achieved by assigning them a unique prefix.
+%D
+%D Imagine a setup command for boxed text, that enables us to specify the height and
+%D width of the box. Behide the scenes the command
+%D
+%D \starttyping
+%D \setupbox [width=12cm, height=3cm]
+%D \stoptyping
+%D
+%D results in something like
+%D
+%D \starttyping
+%D \ {12cm}
+%D \ {3cm}
+%D \stoptyping
+%D
+%D while a similar command for specifying the page dimensions
+%D of an \cap {A4} page results in:
+%D
+%D \starttyping
+%D \